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