1 /*
2  * SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 #include <stddef.h>
8 #include <stdlib.h>
9 #include <stdio.h>
10 #include <string.h>
11 #include <assert.h>
12 #include <pthread.h>
13 
14 #include "freertos/FreeRTOS.h"
15 #include "freertos/task.h"
16 #include "freertos/queue.h"
17 #include "freertos/semphr.h"
18 #include "freertos/event_groups.h"
19 #include "freertos/portmacro.h"
20 #include "riscv/interrupt.h"
21 #include "esp_types.h"
22 #include "esp_random.h"
23 #include "esp_mac.h"
24 #include "esp_task.h"
25 #include "esp_intr_alloc.h"
26 #include "esp_attr.h"
27 #include "esp_log.h"
28 #include "esp_event.h"
29 #include "esp_heap_caps.h"
30 #include "esp_timer.h"
31 #include "esp_private/wifi_os_adapter.h"
32 #include "esp_private/wifi.h"
33 #include "esp_phy_init.h"
34 #include "soc/rtc_cntl_reg.h"
35 #include "soc/rtc.h"
36 #include "soc/syscon_reg.h"
37 #include "phy_init_data.h"
38 #include "esp_private/periph_ctrl.h"
39 #include "esp_private/esp_clk.h"
40 #include "nvs.h"
41 #include "os.h"
42 #include "esp_smartconfig.h"
43 #include "private/esp_coexist_internal.h"
44 #include "esp32c2/rom/ets_sys.h"
45 #include "private/esp_modem_wrapper.h"
46 
47 #define TAG "esp_adapter"
48 
49 #ifdef CONFIG_PM_ENABLE
50 extern void wifi_apb80m_request(void);
51 extern void wifi_apb80m_release(void);
52 #endif
53 
wifi_malloc(size_t size)54 IRAM_ATTR void *wifi_malloc( size_t size )
55 {
56     return malloc(size);
57 }
58 
wifi_realloc(void * ptr,size_t size)59 IRAM_ATTR void *wifi_realloc( void *ptr, size_t size )
60 {
61     return realloc(ptr, size);
62 }
63 
wifi_calloc(size_t n,size_t size)64 IRAM_ATTR void *wifi_calloc( size_t n, size_t size )
65 {
66     return calloc(n, size);
67 }
68 
wifi_zalloc_wrapper(size_t size)69 static void * IRAM_ATTR wifi_zalloc_wrapper(size_t size)
70 {
71     void *ptr = wifi_calloc(1, size);
72     return ptr;
73 }
74 
wifi_create_queue(int queue_len,int item_size)75 wifi_static_queue_t* wifi_create_queue( int queue_len, int item_size)
76 {
77     wifi_static_queue_t *queue = NULL;
78 
79     queue = (wifi_static_queue_t*)heap_caps_malloc(sizeof(wifi_static_queue_t), MALLOC_CAP_INTERNAL|MALLOC_CAP_8BIT);
80     if (!queue) {
81         return NULL;
82     }
83 
84     queue->handle = xQueueCreate( queue_len, item_size);
85     return queue;
86 }
87 
wifi_delete_queue(wifi_static_queue_t * queue)88 void wifi_delete_queue(wifi_static_queue_t *queue)
89 {
90     if (queue) {
91         vQueueDelete(queue->handle);
92         free(queue);
93     }
94 }
95 
wifi_create_queue_wrapper(int queue_len,int item_size)96 static void * wifi_create_queue_wrapper(int queue_len, int item_size)
97 {
98     return wifi_create_queue(queue_len, item_size);
99 }
100 
wifi_delete_queue_wrapper(void * queue)101 static void wifi_delete_queue_wrapper(void *queue)
102 {
103     wifi_delete_queue(queue);
104 }
105 
set_intr_wrapper(int32_t cpu_no,uint32_t intr_source,uint32_t intr_num,int32_t intr_prio)106 static void set_intr_wrapper(int32_t cpu_no, uint32_t intr_source, uint32_t intr_num, int32_t intr_prio)
107 {
108     intr_matrix_route(intr_source, intr_num);
109     esprv_intc_int_set_priority(intr_num, intr_prio);
110     esprv_intc_int_set_type(intr_num, INTR_TYPE_LEVEL);
111 }
112 
clear_intr_wrapper(uint32_t intr_source,uint32_t intr_num)113 static void clear_intr_wrapper(uint32_t intr_source, uint32_t intr_num)
114 {
115 
116 }
117 
set_isr_wrapper(int32_t n,void * f,void * arg)118 static void set_isr_wrapper(int32_t n, void *f, void *arg)
119 {
120     intr_handler_set(n, (intr_handler_t)f, arg);
121 }
122 
enable_intr_wrapper(uint32_t intr_mask)123 static void enable_intr_wrapper(uint32_t intr_mask)
124 {
125     esprv_intc_int_enable(intr_mask);
126 }
127 
disable_intr_wrapper(uint32_t intr_mask)128 static void disable_intr_wrapper(uint32_t intr_mask)
129 {
130     esprv_intc_int_disable(intr_mask);
131 }
132 
is_from_isr_wrapper(void)133 static bool IRAM_ATTR is_from_isr_wrapper(void)
134 {
135     return !xPortCanYield();
136 }
137 
wifi_thread_semphr_free(void * data)138 static void wifi_thread_semphr_free(void* data)
139 {
140     SemaphoreHandle_t *sem = (SemaphoreHandle_t*)(data);
141 
142     if (sem) {
143         vSemaphoreDelete(sem);
144     }
145 }
146 
wifi_thread_semphr_get_wrapper(void)147 static void * wifi_thread_semphr_get_wrapper(void)
148 {
149     static bool s_wifi_thread_sem_key_init = false;
150     static pthread_key_t s_wifi_thread_sem_key;
151     SemaphoreHandle_t sem = NULL;
152 
153     if (s_wifi_thread_sem_key_init == false) {
154         if (0 != pthread_key_create(&s_wifi_thread_sem_key, wifi_thread_semphr_free)) {
155             return NULL;
156         }
157         s_wifi_thread_sem_key_init = true;
158     }
159 
160     sem = pthread_getspecific(s_wifi_thread_sem_key);
161     if (!sem) {
162         sem = xSemaphoreCreateCounting(1, 0);
163         if (sem) {
164             pthread_setspecific(s_wifi_thread_sem_key, sem);
165             ESP_LOGV(TAG, "thread sem create: sem=%p", sem);
166         }
167     }
168 
169     ESP_LOGV(TAG, "thread sem get: sem=%p", sem);
170     return (void*)sem;
171 }
172 
recursive_mutex_create_wrapper(void)173 static void * recursive_mutex_create_wrapper(void)
174 {
175     return (void *)xSemaphoreCreateRecursiveMutex();
176 }
177 
mutex_create_wrapper(void)178 static void * mutex_create_wrapper(void)
179 {
180     return (void *)xSemaphoreCreateMutex();
181 }
182 
mutex_delete_wrapper(void * mutex)183 static void mutex_delete_wrapper(void *mutex)
184 {
185     vSemaphoreDelete(mutex);
186 }
187 
mutex_lock_wrapper(void * mutex)188 static int32_t IRAM_ATTR mutex_lock_wrapper(void *mutex)
189 {
190     return (int32_t)xSemaphoreTakeRecursive(mutex, portMAX_DELAY);
191 }
192 
mutex_unlock_wrapper(void * mutex)193 static int32_t IRAM_ATTR mutex_unlock_wrapper(void *mutex)
194 {
195     return (int32_t)xSemaphoreGiveRecursive(mutex);
196 }
197 
queue_create_wrapper(uint32_t queue_len,uint32_t item_size)198 static void * queue_create_wrapper(uint32_t queue_len, uint32_t item_size)
199 {
200     return (void *)xQueueCreate(queue_len, item_size);
201 }
202 
queue_send_wrapper(void * queue,void * item,uint32_t block_time_tick)203 static int32_t queue_send_wrapper(void *queue, void *item, uint32_t block_time_tick)
204 {
205     if (block_time_tick == OSI_FUNCS_TIME_BLOCKING) {
206         return (int32_t)xQueueSend(queue, item, portMAX_DELAY);
207     } else {
208         return (int32_t)xQueueSend(queue, item, block_time_tick);
209     }
210 }
211 
queue_send_from_isr_wrapper(void * queue,void * item,void * hptw)212 static int32_t IRAM_ATTR queue_send_from_isr_wrapper(void *queue, void *item, void *hptw)
213 {
214     return (int32_t)xQueueSendFromISR(queue, item, hptw);
215 }
216 
queue_send_to_back_wrapper(void * queue,void * item,uint32_t block_time_tick)217 static int32_t queue_send_to_back_wrapper(void *queue, void *item, uint32_t block_time_tick)
218 {
219     return (int32_t)xQueueGenericSend(queue, item, block_time_tick, queueSEND_TO_BACK);
220 }
221 
queue_send_to_front_wrapper(void * queue,void * item,uint32_t block_time_tick)222 static int32_t queue_send_to_front_wrapper(void *queue, void *item, uint32_t block_time_tick)
223 {
224     return (int32_t)xQueueGenericSend(queue, item, block_time_tick, queueSEND_TO_FRONT);
225 }
226 
queue_recv_wrapper(void * queue,void * item,uint32_t block_time_tick)227 static int32_t queue_recv_wrapper(void *queue, void *item, uint32_t block_time_tick)
228 {
229     if (block_time_tick == OSI_FUNCS_TIME_BLOCKING) {
230         return (int32_t)xQueueReceive(queue, item, portMAX_DELAY);
231     } else {
232         return (int32_t)xQueueReceive(queue, item, block_time_tick);
233     }
234 }
235 
event_group_wait_bits_wrapper(void * event,uint32_t bits_to_wait_for,int clear_on_exit,int wait_for_all_bits,uint32_t block_time_tick)236 static uint32_t event_group_wait_bits_wrapper(void *event, uint32_t bits_to_wait_for, int clear_on_exit, int wait_for_all_bits, uint32_t block_time_tick)
237 {
238     if (block_time_tick == OSI_FUNCS_TIME_BLOCKING) {
239         return (uint32_t)xEventGroupWaitBits(event, bits_to_wait_for, clear_on_exit, wait_for_all_bits, portMAX_DELAY);
240     } else {
241         return (uint32_t)xEventGroupWaitBits(event, bits_to_wait_for, clear_on_exit, wait_for_all_bits, block_time_tick);
242     }
243 }
244 
task_create_pinned_to_core_wrapper(void * task_func,const char * name,uint32_t stack_depth,void * param,uint32_t prio,void * task_handle,uint32_t core_id)245 static int32_t task_create_pinned_to_core_wrapper(void *task_func, const char *name, uint32_t stack_depth, void *param, uint32_t prio, void *task_handle, uint32_t core_id)
246 {
247     return (uint32_t)xTaskCreatePinnedToCore(task_func, name, stack_depth, param, prio, task_handle, (core_id < portNUM_PROCESSORS ? core_id : tskNO_AFFINITY));
248 }
249 
task_create_wrapper(void * task_func,const char * name,uint32_t stack_depth,void * param,uint32_t prio,void * task_handle)250 static int32_t task_create_wrapper(void *task_func, const char *name, uint32_t stack_depth, void *param, uint32_t prio, void *task_handle)
251 {
252     return (uint32_t)xTaskCreate(task_func, name, stack_depth, param, prio, task_handle);
253 }
254 
task_ms_to_tick_wrapper(uint32_t ms)255 static int32_t IRAM_ATTR task_ms_to_tick_wrapper(uint32_t ms)
256 {
257     return (int32_t)(ms / portTICK_PERIOD_MS);
258 }
259 
task_get_max_priority_wrapper(void)260 static int32_t task_get_max_priority_wrapper(void)
261 {
262     return (int32_t)(configMAX_PRIORITIES);
263 }
264 
esp_event_post_wrapper(const char * event_base,int32_t event_id,void * event_data,size_t event_data_size,uint32_t ticks_to_wait)265 static int32_t esp_event_post_wrapper(const char* event_base, int32_t event_id, void* event_data, size_t event_data_size, uint32_t ticks_to_wait)
266 {
267     if (ticks_to_wait == OSI_FUNCS_TIME_BLOCKING) {
268         return (int32_t)esp_event_post(event_base, event_id, event_data, event_data_size, portMAX_DELAY);
269     } else {
270         return (int32_t)esp_event_post(event_base, event_id, event_data, event_data_size, ticks_to_wait);
271     }
272 }
273 
wifi_apb80m_request_wrapper(void)274 static void IRAM_ATTR wifi_apb80m_request_wrapper(void)
275 {
276 #ifdef CONFIG_PM_ENABLE
277     wifi_apb80m_request();
278 #endif
279 }
280 
wifi_apb80m_release_wrapper(void)281 static void IRAM_ATTR wifi_apb80m_release_wrapper(void)
282 {
283 #ifdef CONFIG_PM_ENABLE
284     wifi_apb80m_release();
285 #endif
286 }
287 
timer_arm_wrapper(void * timer,uint32_t tmout,bool repeat)288 static void IRAM_ATTR timer_arm_wrapper(void *timer, uint32_t tmout, bool repeat)
289 {
290     ets_timer_arm(timer, tmout, repeat);
291 }
292 
wifi_reset_mac_wrapper(void)293 static void wifi_reset_mac_wrapper(void)
294 {
295     periph_module_reset(PERIPH_WIFI_MODULE);
296 }
297 
wifi_clock_enable_wrapper(void)298 static void wifi_clock_enable_wrapper(void)
299 {
300     wifi_module_enable();
301 }
302 
wifi_clock_disable_wrapper(void)303 static void wifi_clock_disable_wrapper(void)
304 {
305     wifi_module_disable();
306 }
307 
get_time_wrapper(void * t)308 static int get_time_wrapper(void *t)
309 {
310     return os_get_time(t);
311 }
312 
realloc_internal_wrapper(void * ptr,size_t size)313 static void * IRAM_ATTR realloc_internal_wrapper(void *ptr, size_t size)
314 {
315     return heap_caps_realloc(ptr, size, MALLOC_CAP_8BIT|MALLOC_CAP_DMA|MALLOC_CAP_INTERNAL);
316 }
317 
calloc_internal_wrapper(size_t n,size_t size)318 static void * IRAM_ATTR calloc_internal_wrapper(size_t n, size_t size)
319 {
320     return heap_caps_calloc(n, size, MALLOC_CAP_8BIT|MALLOC_CAP_DMA|MALLOC_CAP_INTERNAL);
321 }
322 
zalloc_internal_wrapper(size_t size)323 static void * IRAM_ATTR zalloc_internal_wrapper(size_t size)
324 {
325     void *ptr = heap_caps_calloc(1, size, MALLOC_CAP_8BIT|MALLOC_CAP_DMA|MALLOC_CAP_INTERNAL);
326     return ptr;
327 }
328 
nvs_open_wrapper(const char * name,unsigned int open_mode,nvs_handle_t * out_handle)329 static esp_err_t nvs_open_wrapper(const char* name, unsigned int open_mode, nvs_handle_t *out_handle)
330 {
331     return nvs_open(name,(nvs_open_mode_t)open_mode, out_handle);
332 }
333 
esp_log_writev_wrapper(unsigned int level,const char * tag,const char * format,va_list args)334 static void esp_log_writev_wrapper(unsigned int level, const char *tag, const char *format, va_list args)
335 {
336     return esp_log_writev((esp_log_level_t)level,tag,format,args);
337 }
338 
esp_log_write_wrapper(unsigned int level,const char * tag,const char * format,...)339 static void esp_log_write_wrapper(unsigned int level,const char *tag,const char *format, ...)
340 {
341     va_list list;
342     va_start(list, format);
343     esp_log_writev((esp_log_level_t)level, tag, format, list);
344     va_end(list);
345 }
346 
esp_read_mac_wrapper(uint8_t * mac,unsigned int type)347 static esp_err_t esp_read_mac_wrapper(uint8_t* mac, unsigned int type)
348 {
349     return esp_read_mac(mac, (esp_mac_type_t)type);
350 }
351 
coex_init_wrapper(void)352 static int coex_init_wrapper(void)
353 {
354 #if CONFIG_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE
355     return coex_init();
356 #else
357     return 0;
358 #endif
359 }
360 
coex_deinit_wrapper(void)361 static void coex_deinit_wrapper(void)
362 {
363 #if CONFIG_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE
364     coex_deinit();
365 #endif
366 }
367 
coex_enable_wrapper(void)368 static int coex_enable_wrapper(void)
369 {
370 #if CONFIG_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE
371     return coex_enable();
372 #else
373     return 0;
374 #endif
375 }
376 
coex_disable_wrapper(void)377 static void coex_disable_wrapper(void)
378 {
379 #if CONFIG_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE
380     coex_disable();
381 #endif
382 }
383 
coex_status_get_wrapper(void)384 static IRAM_ATTR uint32_t coex_status_get_wrapper(void)
385 {
386 #if CONFIG_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE
387     return coex_status_get(COEX_STATUS_GET_WIFI_BITMAP);
388 #else
389     return 0;
390 #endif
391 }
392 
coex_wifi_request_wrapper(uint32_t event,uint32_t latency,uint32_t duration)393 static int coex_wifi_request_wrapper(uint32_t event, uint32_t latency, uint32_t duration)
394 {
395 #if CONFIG_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE
396     return coex_wifi_request(event, latency, duration);
397 #else
398     return 0;
399 #endif
400 }
401 
coex_wifi_release_wrapper(uint32_t event)402 static IRAM_ATTR int coex_wifi_release_wrapper(uint32_t event)
403 {
404 #if CONFIG_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE
405     return coex_wifi_release(event);
406 #else
407     return 0;
408 #endif
409 }
410 
coex_wifi_channel_set_wrapper(uint8_t primary,uint8_t secondary)411 static int coex_wifi_channel_set_wrapper(uint8_t primary, uint8_t secondary)
412 {
413 #if CONFIG_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE
414     return coex_wifi_channel_set(primary, secondary);
415 #else
416     return 0;
417 #endif
418 }
419 
coex_event_duration_get_wrapper(uint32_t event,uint32_t * duration)420 static IRAM_ATTR int coex_event_duration_get_wrapper(uint32_t event, uint32_t *duration)
421 {
422 #if CONFIG_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE
423     return coex_event_duration_get(event, duration);
424 #else
425     return 0;
426 #endif
427 }
428 
coex_pti_get_wrapper(uint32_t event,uint8_t * pti)429 static int coex_pti_get_wrapper(uint32_t event, uint8_t *pti)
430 {
431 #if CONFIG_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE
432     return coex_pti_get(event, pti);
433 #else
434     return 0;
435 #endif
436 }
437 
coex_schm_status_bit_clear_wrapper(uint32_t type,uint32_t status)438 static void coex_schm_status_bit_clear_wrapper(uint32_t type, uint32_t status)
439 {
440 #if CONFIG_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE
441     coex_schm_status_bit_clear(type, status);
442 #endif
443 }
444 
coex_schm_status_bit_set_wrapper(uint32_t type,uint32_t status)445 static void coex_schm_status_bit_set_wrapper(uint32_t type, uint32_t status)
446 {
447 #if CONFIG_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE
448     coex_schm_status_bit_set(type, status);
449 #endif
450 }
451 
coex_schm_interval_set_wrapper(uint32_t interval)452 static IRAM_ATTR int coex_schm_interval_set_wrapper(uint32_t interval)
453 {
454 #if CONFIG_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE
455     return coex_schm_interval_set(interval);
456 #else
457     return 0;
458 #endif
459 }
460 
coex_schm_interval_get_wrapper(void)461 static uint32_t coex_schm_interval_get_wrapper(void)
462 {
463 #if CONFIG_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE
464     return coex_schm_interval_get();
465 #else
466     return 0;
467 #endif
468 }
469 
coex_schm_curr_period_get_wrapper(void)470 static uint8_t coex_schm_curr_period_get_wrapper(void)
471 {
472 #if CONFIG_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE
473     return coex_schm_curr_period_get();
474 #else
475     return 0;
476 #endif
477 }
478 
coex_schm_curr_phase_get_wrapper(void)479 static void * coex_schm_curr_phase_get_wrapper(void)
480 {
481 #if CONFIG_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE
482     return coex_schm_curr_phase_get();
483 #else
484     return NULL;
485 #endif
486 }
487 
coex_register_start_cb_wrapper(int (* cb)(void))488 static int coex_register_start_cb_wrapper(int (* cb)(void))
489 {
490 #if CONFIG_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE
491     return coex_register_start_cb(cb);
492 #else
493     return 0;
494 #endif
495 }
496 
coex_schm_process_restart_wrapper(void)497 static int coex_schm_process_restart_wrapper(void)
498 {
499 #if CONFIG_SW_COEXIST_ENABLE
500     return coex_schm_process_restart();
501 #else
502     return 0;
503 #endif
504 }
505 
coex_schm_register_cb_wrapper(int type,int (* cb)(int))506 static int coex_schm_register_cb_wrapper(int type, int(*cb)(int))
507 {
508 #if CONFIG_SW_COEXIST_ENABLE
509     return coex_schm_register_callback(type, cb);
510 #else
511     return 0;
512 #endif
513 }
514 
coex_schm_flexible_period_set_wrapper(uint8_t period)515 static int coex_schm_flexible_period_set_wrapper(uint8_t period)
516 {
517 #if CONFIG_ESP_COEX_POWER_MANAGEMENT
518     return coex_schm_flexible_period_set(period);
519 #else
520     return 0;
521 #endif
522 }
523 
coex_schm_flexible_period_get_wrapper(void)524 static uint8_t coex_schm_flexible_period_get_wrapper(void)
525 {
526 #if CONFIG_ESP_COEX_POWER_MANAGEMENT
527     return coex_schm_flexible_period_get();
528 #else
529     return 1;
530 #endif
531 }
532 
esp_empty_wrapper(void)533 static void IRAM_ATTR esp_empty_wrapper(void)
534 {
535 
536 }
537 
esp_phy_enable_wrapper(void)538 static void esp_phy_enable_wrapper(void)
539 {
540     esp_phy_enable(PHY_MODEM_WIFI);
541     phy_wifi_enable_set(1);
542 }
543 
esp_phy_disable_wrapper(void)544 static void esp_phy_disable_wrapper(void)
545 {
546     phy_wifi_enable_set(0);
547     esp_phy_disable(PHY_MODEM_WIFI);
548 }
549 
550 wifi_osi_funcs_t g_wifi_osi_funcs = {
551     ._version = ESP_WIFI_OS_ADAPTER_VERSION,
552     ._env_is_chip = esp_coex_common_env_is_chip_wrapper,
553     ._set_intr = set_intr_wrapper,
554     ._clear_intr = clear_intr_wrapper,
555     ._set_isr = set_isr_wrapper,
556     ._ints_on = enable_intr_wrapper,
557     ._ints_off = disable_intr_wrapper,
558     ._is_from_isr = is_from_isr_wrapper,
559     ._spin_lock_create = esp_coex_common_spin_lock_create_wrapper,
560     ._spin_lock_delete = free,
561     ._wifi_int_disable = esp_coex_common_int_disable_wrapper,
562     ._wifi_int_restore = esp_coex_common_int_restore_wrapper,
563     ._task_yield_from_isr = esp_coex_common_task_yield_from_isr_wrapper,
564     ._semphr_create = esp_coex_common_semphr_create_wrapper,
565     ._semphr_delete = esp_coex_common_semphr_delete_wrapper,
566     ._semphr_take = esp_coex_common_semphr_take_wrapper,
567     ._semphr_give = esp_coex_common_semphr_give_wrapper,
568     ._wifi_thread_semphr_get = wifi_thread_semphr_get_wrapper,
569     ._mutex_create = mutex_create_wrapper,
570     ._recursive_mutex_create = recursive_mutex_create_wrapper,
571     ._mutex_delete = mutex_delete_wrapper,
572     ._mutex_lock = mutex_lock_wrapper,
573     ._mutex_unlock = mutex_unlock_wrapper,
574     ._queue_create = queue_create_wrapper,
575     ._queue_delete = (void(*)(void *))vQueueDelete,
576     ._queue_send = queue_send_wrapper,
577     ._queue_send_from_isr = queue_send_from_isr_wrapper,
578     ._queue_send_to_back = queue_send_to_back_wrapper,
579     ._queue_send_to_front = queue_send_to_front_wrapper,
580     ._queue_recv = queue_recv_wrapper,
581     ._queue_msg_waiting = (uint32_t(*)(void *))uxQueueMessagesWaiting,
582     ._event_group_create = (void *(*)(void))xEventGroupCreate,
583     ._event_group_delete = (void(*)(void *))vEventGroupDelete,
584     ._event_group_set_bits = (uint32_t(*)(void *,uint32_t))xEventGroupSetBits,
585     ._event_group_clear_bits = (uint32_t(*)(void *,uint32_t))xEventGroupClearBits,
586     ._event_group_wait_bits = event_group_wait_bits_wrapper,
587     ._task_create_pinned_to_core = task_create_pinned_to_core_wrapper,
588     ._task_create = task_create_wrapper,
589     ._task_delete = (void(*)(void *))vTaskDelete,
590     ._task_delay = vTaskDelay,
591     ._task_ms_to_tick = task_ms_to_tick_wrapper,
592     ._task_get_current_task = (void *(*)(void))xTaskGetCurrentTaskHandle,
593     ._task_get_max_priority = task_get_max_priority_wrapper,
594     ._malloc = malloc,
595     ._free = free,
596     ._event_post = esp_event_post_wrapper,
597     ._get_free_heap_size = esp_get_free_internal_heap_size,
598     ._rand = esp_random,
599     ._dport_access_stall_other_cpu_start_wrap = esp_empty_wrapper,
600     ._dport_access_stall_other_cpu_end_wrap = esp_empty_wrapper,
601     ._wifi_apb80m_request = wifi_apb80m_request_wrapper,
602     ._wifi_apb80m_release = wifi_apb80m_release_wrapper,
603     ._phy_disable = esp_phy_disable_wrapper,
604     ._phy_enable = esp_phy_enable_wrapper,
605     ._phy_update_country_info = esp_phy_update_country_info,
606     ._read_mac = esp_read_mac_wrapper,
607     ._timer_arm = timer_arm_wrapper,
608     ._timer_disarm = esp_coex_common_timer_disarm_wrapper,
609     ._timer_done = esp_coex_common_timer_done_wrapper,
610     ._timer_setfn = esp_coex_common_timer_setfn_wrapper,
611     ._timer_arm_us = esp_coex_common_timer_arm_us_wrapper,
612     ._wifi_reset_mac = wifi_reset_mac_wrapper,
613     ._wifi_clock_enable = wifi_clock_enable_wrapper,
614     ._wifi_clock_disable = wifi_clock_disable_wrapper,
615     ._wifi_rtc_enable_iso = esp_empty_wrapper,
616     ._wifi_rtc_disable_iso = esp_empty_wrapper,
617     ._esp_timer_get_time = esp_timer_get_time,
618     ._nvs_set_i8 = nvs_set_i8,
619     ._nvs_get_i8 = nvs_get_i8,
620     ._nvs_set_u8 = nvs_set_u8,
621     ._nvs_get_u8 = nvs_get_u8,
622     ._nvs_set_u16 = nvs_set_u16,
623     ._nvs_get_u16 = nvs_get_u16,
624     ._nvs_open = nvs_open_wrapper,
625     ._nvs_close = nvs_close,
626     ._nvs_commit = nvs_commit,
627     ._nvs_set_blob = nvs_set_blob,
628     ._nvs_get_blob = nvs_get_blob,
629     ._nvs_erase_key = nvs_erase_key,
630     ._get_random = os_get_random,
631     ._get_time = get_time_wrapper,
632     ._random = os_random,
633     ._slowclk_cal_get = esp_coex_common_clk_slowclk_cal_get_wrapper,
634     ._log_write = esp_log_write_wrapper,
635     ._log_writev = esp_log_writev_wrapper,
636     ._log_timestamp = esp_log_timestamp,
637     ._malloc_internal =  esp_coex_common_malloc_internal_wrapper,
638     ._realloc_internal = realloc_internal_wrapper,
639     ._calloc_internal = calloc_internal_wrapper,
640     ._zalloc_internal = zalloc_internal_wrapper,
641     ._wifi_malloc = wifi_malloc,
642     ._wifi_realloc = wifi_realloc,
643     ._wifi_calloc = wifi_calloc,
644     ._wifi_zalloc = wifi_zalloc_wrapper,
645     ._wifi_create_queue = wifi_create_queue_wrapper,
646     ._wifi_delete_queue = wifi_delete_queue_wrapper,
647     ._coex_init = coex_init_wrapper,
648     ._coex_deinit = coex_deinit_wrapper,
649     ._coex_enable = coex_enable_wrapper,
650     ._coex_disable = coex_disable_wrapper,
651     ._coex_status_get = coex_status_get_wrapper,
652     ._coex_wifi_request = coex_wifi_request_wrapper,
653     ._coex_wifi_release = coex_wifi_release_wrapper,
654     ._coex_wifi_channel_set = coex_wifi_channel_set_wrapper,
655     ._coex_event_duration_get = coex_event_duration_get_wrapper,
656     ._coex_pti_get = coex_pti_get_wrapper,
657     ._coex_schm_status_bit_clear = coex_schm_status_bit_clear_wrapper,
658     ._coex_schm_status_bit_set = coex_schm_status_bit_set_wrapper,
659     ._coex_schm_interval_set = coex_schm_interval_set_wrapper,
660     ._coex_schm_interval_get = coex_schm_interval_get_wrapper,
661     ._coex_schm_curr_period_get = coex_schm_curr_period_get_wrapper,
662     ._coex_schm_curr_phase_get = coex_schm_curr_phase_get_wrapper,
663     ._coex_register_start_cb = coex_register_start_cb_wrapper,
664     ._coex_schm_process_restart = coex_schm_process_restart_wrapper,
665     ._coex_schm_register_cb = coex_schm_register_cb_wrapper,
666     ._coex_schm_flexible_period_set = coex_schm_flexible_period_set_wrapper,
667     ._coex_schm_flexible_period_get = coex_schm_flexible_period_get_wrapper,
668     ._magic = ESP_WIFI_OS_ADAPTER_MAGIC,
669 };
670