• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2020 HiSilicon (Shanghai) Technologies CO., LIMITED.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  * Description: header file for wifi os api
15  */
16 
17 #ifndef _WIFI_OSDEP_H_
18 #define _WIFI_OSDEP_H_
19 
20 #if defined(CONFIG_OS_OSAL)
21 #include <soc_osal.h>
22 
23 #elif defined(__LITEOS__)
24 #include "los_sys.h"
25 #include "los_task.h"
26 #endif
27 
28 #ifdef __cplusplus
29 #if __cplusplus
30 extern "C" {
31 #endif /* __cplusplus */
32 #endif /* __cplusplus */
33 
34 #define WIFI_OS_OK 0
35 #define WIFI_OS_FAIL (-1)
36 
37 #define WIFI_ERR_LOG printf
38 
39 #if defined(CONFIG_OS_OSAL)
40 #define WIFI_WAIT_FOREVER OSAL_WAIT_FOREVER
41 #define WIFI_WAITMODE_OR OSAL_WAITMODE_OR
42 #define WIFI_WAITMODE_CLR OSAL_WAITMODE_CLR
43 /*
44  * OSAL API cant distinguish between normal error and read timeout
45  */
46 #define WIFI_ERRNO_EVENT_READ_TIMEOUT ((unsigned int)WIFI_OS_FAIL)
47 #define WIFI_TASK_STATUS_DETACHED 0
48 #elif defined(__LITEOS__)
49 #define WIFI_WAIT_FOREVER LOS_WAIT_FOREVER
50 #define WIFI_WAITMODE_OR LOS_WAITMODE_OR
51 #define WIFI_WAITMODE_CLR LOS_WAITMODE_CLR
52 #define WIFI_ERRNO_EVENT_READ_TIMEOUT LOS_ERRNO_EVENT_READ_TIMEOUT
53 #define WIFI_TASK_STATUS_DETACHED LOS_TASK_STATUS_DETACHED
54 #endif
55 
56 typedef void *(*wifi_tsk_entry_func)(void *param);
57 
58 typedef struct {
59     unsigned int stack_size;   /* Task stack size.CNcomment:栈大小 CNend */
60     char *task_name;           /* Task name.CNcomment:任务名 CNend */
61     wifi_tsk_entry_func task_entry; /* Task entry.CNcomment:任务入口。CNend */
62     const void *arg;           /* cbk paramter.CNcomment:回调函数入参 CNend */
63     unsigned int task_policy;  /* Task schedule policy. Not used by default.CNcomment:任务调度策略。默认没有使用。CNend */
64     unsigned int task_cpuid;   /* CPUID to which the task belongs. Not used by default.
65                                   CNcomment:任务所属的CPUID。默认没有使用。CNend */
66     unsigned short task_prio;  /* Task priority.CNcomment:任务优先级 CNend */
67     unsigned short res;         /* Reserved. Not used by default.CNcomment:预留字段。默认没有使用。CNend */
68 } wifi_task_attr;
69 
70 typedef enum {
71     WIFI_EVENT_WPA    = 0,
72     WIFI_EVENT_ELOOP  = 1,
73     WIFI_EVENT_SOFTAP = 2,
74     WIFI_EVENT_P2P    = 3,
75     WIFI_EVENT_MAX
76 } wifi_event_enum;
77 
78 unsigned long long os_tick_cnt_get(void);
79 
80 void os_intlock(unsigned int *int_save);
81 void os_intrestore(unsigned int int_save);
82 
83 void os_task_lock(unsigned int *int_save);
84 void os_task_unlock(unsigned int int_save);
85 void os_task_delay(unsigned int ms);
86 int os_task_create(unsigned int *task_id, wifi_task_attr *attr);
87 void os_task_delete(unsigned int task_id);
88 
89 int os_event_init(unsigned int *id, wifi_event_enum num);
90 int os_event_read(unsigned int id, unsigned int mask, unsigned int *event_bits,
91                   unsigned int flag, unsigned int timeout_ms);
92 int os_event_poll(unsigned int id, unsigned int mask, unsigned int *event_bits, unsigned int flag);
93 int os_event_write(unsigned int id, unsigned int events);
94 int os_event_clear(unsigned int id, unsigned int events);
95 int os_event_del(unsigned int id);
96 
97 int os_mux_create(unsigned int *mux_id);
98 int os_mux_pend(unsigned int mux_id, unsigned int timeout_ms);
99 int os_mux_post(unsigned int mux_id);
100 int os_mux_delete(unsigned int mux_id);
101 
102 #ifdef __cplusplus
103 #if __cplusplus
104 }
105 #endif /* __cplusplus */
106 #endif /* __cplusplus */
107 #endif /* _WIFI_OSDEP_H_ */
108