• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021 HiSilicon (Shanghai) Technologies CO., LIMITED.
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
17  */
18 
19 /* ****************************************************************************
20   1 头文件包含
21 **************************************************************************** */
22 #include "frw_main.h"
23 #include "frw_event.h"
24 #include "frw_timer.h"
25 #include "frw_task.h"
26 #include "oam_ext_if.h"
27 
28 #ifdef __cplusplus
29 #if __cplusplus
30 extern "C" {
31 #endif
32 #endif
33 
34 /* ****************************************************************************
35   2 全局变量定义
36 **************************************************************************** */
37 /* ROM化函数预留的回调接口 */
38 hi_void*            g_frw_rom_resv_func_cb[FRW_ROM_RESV_FUNC_BUTT] = {HI_NULL};
39 frw_init_enum_uint8 g_wlan_driver_init_state = FRW_INIT_STATE_BUTT;
40 hi_bool             g_frw_offload = HI_FALSE;    /* 默认非offload模式 */
41 
42 /* ****************************************************************************
43  功能描述  : 实现ROM化预留函数钩子注册,可以置空或者设置对应的钩子函数
44 **************************************************************************** */
frw_set_rom_resv_func(frw_rom_resv_func_enum_uint8 func_id,hi_void * func)45 hi_void frw_set_rom_resv_func(frw_rom_resv_func_enum_uint8 func_id, hi_void *func)
46 {
47     if (func_id >= FRW_ROM_RESV_FUNC_BUTT) {
48         return;
49     }
50 
51     g_frw_rom_resv_func_cb[func_id] = func;
52 }
53 
54 /* ****************************************************************************
55  功能描述  : 获取对应的预留钩子函数
56 **************************************************************************** */
frw_get_rom_resv_func(frw_rom_resv_func_enum_uint8 func_id)57 hi_void *frw_get_rom_resv_func(frw_rom_resv_func_enum_uint8 func_id)
58 {
59     if (func_id >= FRW_ROM_RESV_FUNC_BUTT) {
60         return HI_NULL;
61     }
62 
63     return g_frw_rom_resv_func_cb[func_id];
64 }
65 
66 /* ****************************************************************************
67  功能描述  : 设置wifi驱动架构: OFFLOAD-TRUE 或者非OFFLOAD-FALSE
68 **************************************************************************** */
frw_set_offload_mode(hi_bool mode)69 hi_void frw_set_offload_mode(hi_bool mode)
70 {
71     g_frw_offload = mode;
72 }
73 
74 /* ****************************************************************************
75  功能描述  : 获取wifi驱动架构: OFFLOAD-TRUE 或者非OFFLOAD-FALSE
76 **************************************************************************** */
frw_get_offload_mode(hi_void)77 hi_bool frw_get_offload_mode(hi_void)
78 {
79     return g_frw_offload;
80 }
81 
82 /* ****************************************************************************
83  功能描述  : FRW模块卸载
84 
85  修改历史      :
86   1.日    期   : 2012年9月18日
87     作    者   : HiSilicon
88     修改内容   : 新生成函数
89 **************************************************************************** */
frw_main_exit(hi_void)90 hi_void frw_main_exit(hi_void)
91 {
92     /* 卸载事件管理模块 */
93     frw_event_exit();
94     /* FRW Task exit */
95     frw_task_exit();
96     /* 卸载成功后在置状态位 */
97     frw_set_init_state(FRW_INIT_STATE_START);
98 
99     printk("frw_main_exit SUCCESSFULLY\r\n");
100 }
101 
102 /* ****************************************************************************
103  功能描述  : 设置初始化状态
104  输入参数  : 初始化状态
105  修改历史      :
106   1.日    期   : 2012年11月15日
107     作    者   : HiSilicon
108     修改内容   : 新生成函数
109 **************************************************************************** */
frw_set_init_state(frw_init_enum_uint8 init_state)110 hi_void frw_set_init_state(frw_init_enum_uint8 init_state)
111 {
112     if (init_state >= FRW_INIT_STATE_BUTT) {
113         return;
114     }
115     g_wlan_driver_init_state = init_state;
116 }
117 
118 /* ****************************************************************************
119  功能描述  : 获取初始化状态
120  输入参数  : 初始化状态
121  修改历史      :
122   1.日    期   : 2012年11月15日
123     作    者   : HiSilicon
124     修改内容   : 新生成函数
125 **************************************************************************** */
frw_get_init_state(hi_void)126 frw_init_enum_uint8 frw_get_init_state(hi_void)
127 {
128     return g_wlan_driver_init_state;
129 }
130 
131 /* ****************************************************************************
132  功能描述  : FRW模块初始化总入口,包含FRW模块内部所有特性的初始化。
133  输入参数  : TRUE-OFFLOAD模式 FALSE-非OFFLOAD模式
134  返 回 值  : 初始化返回值,成功或失败原因
135  修改历史      :
136   1.日    期   : 2012年9月18日
137     作    者   : HiSilicon
138     修改内容   : 新生成函数
139 **************************************************************************** */
frw_main_init(hi_bool mode,hi_u32 task_size)140 hi_u32 frw_main_init(hi_bool mode, hi_u32 task_size)
141 {
142     hi_unref_param(task_size);
143     frw_set_init_state(FRW_INIT_STATE_START);
144     /* 事件管理模块初始化 */
145     if (oal_unlikely(frw_event_init() != HI_SUCCESS)) {
146         oam_error_log0(0, 0, "{frw_main_init:: frw_event_init fail.}");
147         return HI_FAIL;
148     }
149     frw_timer_init();
150 
151     if (oal_unlikely(frw_task_init() != HI_SUCCESS)) {
152         oam_error_log0(0, 0, "{frw_main_init:: frw_task_init fail.}");
153         frw_main_exit(); /* 失败后调用模块退出函数释放所有内存 */
154         return HI_FAIL;
155     }
156     frw_set_offload_mode(mode);
157     /* 启动成功后,输出打印 设置状态始终放最后 */
158     frw_set_init_state(FRW_INIT_STATE_FRW_SUCC);
159 
160     printk("frw_main_init SUCCESSFULLY!\r\n");
161     return HI_SUCCESS;
162 }
163 
164 #ifdef __cplusplus
165 #if __cplusplus
166 }
167 #endif
168 #endif
169