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