mirror of
https://github.com/espressif/esp-idf.git
synced 2025-07-30 10:47:19 +02:00
components/coex: Make sure sempher and queue used in isr is in DRAM
Closes https://github.com/espressif/esp-idf/issues/9032 Closes https://github.com/espressif/esp-idf/issues/8928 Closes https://github.com/espressif/esp-idf/issues/9129
This commit is contained in:
@ -289,16 +289,6 @@ static void * wifi_thread_semphr_get_wrapper(void)
|
|||||||
return (void*)sem;
|
return (void*)sem;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t IRAM_ATTR semphr_take_from_isr_wrapper(void *semphr, void *hptw)
|
|
||||||
{
|
|
||||||
return (int32_t)xSemaphoreTakeFromISR(semphr, hptw);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int32_t IRAM_ATTR semphr_give_from_isr_wrapper(void *semphr, void *hptw)
|
|
||||||
{
|
|
||||||
return (int32_t)xSemaphoreGiveFromISR(semphr, hptw);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int32_t semphr_take_wrapper(void *semphr, uint32_t block_time_tick)
|
static int32_t semphr_take_wrapper(void *semphr, uint32_t block_time_tick)
|
||||||
{
|
{
|
||||||
if (block_time_tick == OSI_FUNCS_TIME_BLOCKING) {
|
if (block_time_tick == OSI_FUNCS_TIME_BLOCKING) {
|
||||||
@ -313,6 +303,82 @@ static int32_t semphr_give_wrapper(void *semphr)
|
|||||||
return (int32_t)xSemaphoreGive(semphr);
|
return (int32_t)xSemaphoreGive(semphr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void *internal_semphr_create_wrapper(uint32_t max, uint32_t init)
|
||||||
|
{
|
||||||
|
wifi_static_queue_t *semphr = heap_caps_calloc(1, sizeof(wifi_static_queue_t), MALLOC_CAP_8BIT|MALLOC_CAP_INTERNAL);
|
||||||
|
if (!semphr) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef CONFIG_SPIRAM_USE_MALLOC
|
||||||
|
semphr->storage = heap_caps_calloc(1, sizeof(StaticSemaphore_t), MALLOC_CAP_8BIT|MALLOC_CAP_INTERNAL);
|
||||||
|
if (!semphr->storage) {
|
||||||
|
goto _error;
|
||||||
|
}
|
||||||
|
|
||||||
|
semphr->handle = xSemaphoreCreateCountingStatic(max, init, semphr->storage);
|
||||||
|
if (!semphr->handle) {
|
||||||
|
goto _error;
|
||||||
|
}
|
||||||
|
return (void *)semphr;
|
||||||
|
|
||||||
|
_error:
|
||||||
|
if (semphr) {
|
||||||
|
if (semphr->storage) {
|
||||||
|
free(semphr->storage);
|
||||||
|
}
|
||||||
|
|
||||||
|
free(semphr);
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
#else
|
||||||
|
semphr->handle = xSemaphoreCreateCounting(max, init);
|
||||||
|
return (void *)semphr;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void internal_semphr_delete_wrapper(void *semphr)
|
||||||
|
{
|
||||||
|
wifi_static_queue_t *semphr_item = (wifi_static_queue_t *)semphr;
|
||||||
|
if (semphr_item) {
|
||||||
|
if (semphr_item->handle) {
|
||||||
|
vSemaphoreDelete(semphr_item->handle);
|
||||||
|
}
|
||||||
|
#ifdef CONFIG_SPIRAM_USE_MALLOC
|
||||||
|
if (semphr_item->storage) {
|
||||||
|
free(semphr_item->storage);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
free(semphr_item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t IRAM_ATTR internal_semphr_take_from_isr_wrapper(void *semphr, void *hptw)
|
||||||
|
{
|
||||||
|
return (int32_t)xSemaphoreTakeFromISR(((wifi_static_queue_t *)semphr)->handle, hptw);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t IRAM_ATTR internal_semphr_give_from_isr_wrapper(void *semphr, void *hptw)
|
||||||
|
{
|
||||||
|
return (int32_t)xSemaphoreGiveFromISR(((wifi_static_queue_t *)semphr)->handle, hptw);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t internal_semphr_take_wrapper(void *semphr, uint32_t block_time_tick)
|
||||||
|
{
|
||||||
|
if (block_time_tick == OSI_FUNCS_TIME_BLOCKING) {
|
||||||
|
return (int32_t)xSemaphoreTake(((wifi_static_queue_t *)semphr)->handle, portMAX_DELAY);
|
||||||
|
} else {
|
||||||
|
return (int32_t)xSemaphoreTake(((wifi_static_queue_t *)semphr)->handle, block_time_tick);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t internal_semphr_give_wrapper(void *semphr)
|
||||||
|
{
|
||||||
|
return (int32_t)xSemaphoreGive(((wifi_static_queue_t *)semphr)->handle);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void * recursive_mutex_create_wrapper(void)
|
static void * recursive_mutex_create_wrapper(void)
|
||||||
{
|
{
|
||||||
return (void *)xSemaphoreCreateRecursiveMutex();
|
return (void *)xSemaphoreCreateRecursiveMutex();
|
||||||
@ -789,12 +855,12 @@ coex_adapter_funcs_t g_coex_adapter_funcs = {
|
|||||||
._int_disable = wifi_int_disable_wrapper,
|
._int_disable = wifi_int_disable_wrapper,
|
||||||
._int_enable = wifi_int_restore_wrapper,
|
._int_enable = wifi_int_restore_wrapper,
|
||||||
._task_yield_from_isr = task_yield_from_isr_wrapper,
|
._task_yield_from_isr = task_yield_from_isr_wrapper,
|
||||||
._semphr_create = semphr_create_wrapper,
|
._semphr_create = internal_semphr_create_wrapper,
|
||||||
._semphr_delete = semphr_delete_wrapper,
|
._semphr_delete = internal_semphr_delete_wrapper,
|
||||||
._semphr_take_from_isr = semphr_take_from_isr_wrapper,
|
._semphr_take_from_isr = internal_semphr_take_from_isr_wrapper,
|
||||||
._semphr_give_from_isr = semphr_give_from_isr_wrapper,
|
._semphr_give_from_isr = internal_semphr_give_from_isr_wrapper,
|
||||||
._semphr_take = semphr_take_wrapper,
|
._semphr_take = internal_semphr_take_wrapper,
|
||||||
._semphr_give = semphr_give_wrapper,
|
._semphr_give = internal_semphr_give_wrapper,
|
||||||
._is_in_isr = coex_is_in_isr_wrapper,
|
._is_in_isr = coex_is_in_isr_wrapper,
|
||||||
._malloc_internal = malloc_internal_wrapper,
|
._malloc_internal = malloc_internal_wrapper,
|
||||||
._free = free,
|
._free = free,
|
||||||
|
@ -271,16 +271,6 @@ static void * wifi_thread_semphr_get_wrapper(void)
|
|||||||
return (void*)sem;
|
return (void*)sem;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t IRAM_ATTR semphr_take_from_isr_wrapper(void *semphr, void *hptw)
|
|
||||||
{
|
|
||||||
return (int32_t)xSemaphoreTakeFromISR(semphr, hptw);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int32_t IRAM_ATTR semphr_give_from_isr_wrapper(void *semphr, void *hptw)
|
|
||||||
{
|
|
||||||
return (int32_t)xSemaphoreGiveFromISR(semphr, hptw);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int32_t semphr_take_wrapper(void *semphr, uint32_t block_time_tick)
|
static int32_t semphr_take_wrapper(void *semphr, uint32_t block_time_tick)
|
||||||
{
|
{
|
||||||
if (block_time_tick == OSI_FUNCS_TIME_BLOCKING) {
|
if (block_time_tick == OSI_FUNCS_TIME_BLOCKING) {
|
||||||
@ -295,6 +285,80 @@ static int32_t semphr_give_wrapper(void *semphr)
|
|||||||
return (int32_t)xSemaphoreGive(semphr);
|
return (int32_t)xSemaphoreGive(semphr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void *internal_semphr_create_wrapper(uint32_t max, uint32_t init)
|
||||||
|
{
|
||||||
|
wifi_static_queue_t *semphr = heap_caps_calloc(1, sizeof(wifi_static_queue_t), MALLOC_CAP_8BIT|MALLOC_CAP_INTERNAL);
|
||||||
|
if (!semphr) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef CONFIG_SPIRAM_USE_MALLOC
|
||||||
|
semphr->storage = heap_caps_calloc(1, sizeof(StaticSemaphore_t), MALLOC_CAP_8BIT|MALLOC_CAP_INTERNAL);
|
||||||
|
if (!semphr->storage) {
|
||||||
|
goto _error;
|
||||||
|
}
|
||||||
|
|
||||||
|
semphr->handle = xSemaphoreCreateCountingStatic(max, init, semphr->storage);
|
||||||
|
if (!semphr->handle) {
|
||||||
|
goto _error;
|
||||||
|
}
|
||||||
|
return (void *)semphr;
|
||||||
|
|
||||||
|
_error:
|
||||||
|
if (semphr) {
|
||||||
|
if (semphr->storage) {
|
||||||
|
free(semphr->storage);
|
||||||
|
}
|
||||||
|
|
||||||
|
free(semphr);
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
#else
|
||||||
|
semphr->handle = xSemaphoreCreateCounting(max, init);
|
||||||
|
return (void *)semphr;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void internal_semphr_delete_wrapper(void *semphr)
|
||||||
|
{
|
||||||
|
wifi_static_queue_t *semphr_item = (wifi_static_queue_t *)semphr;
|
||||||
|
if (semphr_item) {
|
||||||
|
if (semphr_item->handle) {
|
||||||
|
vSemaphoreDelete(semphr_item->handle);
|
||||||
|
}
|
||||||
|
#ifdef CONFIG_SPIRAM_USE_MALLOC
|
||||||
|
if (semphr_item->storage) {
|
||||||
|
free(semphr_item->storage);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
free(semphr_item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t IRAM_ATTR internal_semphr_take_from_isr_wrapper(void *semphr, void *hptw)
|
||||||
|
{
|
||||||
|
return (int32_t)xSemaphoreTakeFromISR(((wifi_static_queue_t *)semphr)->handle, hptw);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t IRAM_ATTR internal_semphr_give_from_isr_wrapper(void *semphr, void *hptw)
|
||||||
|
{
|
||||||
|
return (int32_t)xSemaphoreGiveFromISR(((wifi_static_queue_t *)semphr)->handle, hptw);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t internal_semphr_take_wrapper(void *semphr, uint32_t block_time_tick)
|
||||||
|
{
|
||||||
|
if (block_time_tick == OSI_FUNCS_TIME_BLOCKING) {
|
||||||
|
return (int32_t)xSemaphoreTake(((wifi_static_queue_t *)semphr)->handle, portMAX_DELAY);
|
||||||
|
} else {
|
||||||
|
return (int32_t)xSemaphoreTake(((wifi_static_queue_t *)semphr)->handle, block_time_tick);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t internal_semphr_give_wrapper(void *semphr)
|
||||||
|
{
|
||||||
|
return (int32_t)xSemaphoreGive(((wifi_static_queue_t *)semphr)->handle);
|
||||||
|
}
|
||||||
|
|
||||||
static void * recursive_mutex_create_wrapper(void)
|
static void * recursive_mutex_create_wrapper(void)
|
||||||
{
|
{
|
||||||
return (void *)xSemaphoreCreateRecursiveMutex();
|
return (void *)xSemaphoreCreateRecursiveMutex();
|
||||||
@ -778,12 +842,12 @@ wifi_osi_funcs_t g_wifi_osi_funcs = {
|
|||||||
coex_adapter_funcs_t g_coex_adapter_funcs = {
|
coex_adapter_funcs_t g_coex_adapter_funcs = {
|
||||||
._version = COEX_ADAPTER_VERSION,
|
._version = COEX_ADAPTER_VERSION,
|
||||||
._task_yield_from_isr = task_yield_from_isr_wrapper,
|
._task_yield_from_isr = task_yield_from_isr_wrapper,
|
||||||
._semphr_create = semphr_create_wrapper,
|
._semphr_create = internal_semphr_create_wrapper,
|
||||||
._semphr_delete = semphr_delete_wrapper,
|
._semphr_delete = internal_semphr_delete_wrapper,
|
||||||
._semphr_take_from_isr = semphr_take_from_isr_wrapper,
|
._semphr_take_from_isr = internal_semphr_take_from_isr_wrapper,
|
||||||
._semphr_give_from_isr = semphr_give_from_isr_wrapper,
|
._semphr_give_from_isr = internal_semphr_give_from_isr_wrapper,
|
||||||
._semphr_take = semphr_take_wrapper,
|
._semphr_take = internal_semphr_take_wrapper,
|
||||||
._semphr_give = semphr_give_wrapper,
|
._semphr_give = internal_semphr_give_wrapper,
|
||||||
._is_in_isr = coex_is_in_isr_wrapper,
|
._is_in_isr = coex_is_in_isr_wrapper,
|
||||||
._malloc_internal = malloc_internal_wrapper,
|
._malloc_internal = malloc_internal_wrapper,
|
||||||
._free = free,
|
._free = free,
|
||||||
|
@ -279,16 +279,6 @@ static void * wifi_thread_semphr_get_wrapper(void)
|
|||||||
return (void*)sem;
|
return (void*)sem;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t IRAM_ATTR semphr_take_from_isr_wrapper(void *semphr, void *hptw)
|
|
||||||
{
|
|
||||||
return (int32_t)xSemaphoreTakeFromISR(semphr, hptw);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int32_t IRAM_ATTR semphr_give_from_isr_wrapper(void *semphr, void *hptw)
|
|
||||||
{
|
|
||||||
return (int32_t)xSemaphoreGiveFromISR(semphr, hptw);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int32_t semphr_take_wrapper(void *semphr, uint32_t block_time_tick)
|
static int32_t semphr_take_wrapper(void *semphr, uint32_t block_time_tick)
|
||||||
{
|
{
|
||||||
if (block_time_tick == OSI_FUNCS_TIME_BLOCKING) {
|
if (block_time_tick == OSI_FUNCS_TIME_BLOCKING) {
|
||||||
@ -303,6 +293,80 @@ static int32_t semphr_give_wrapper(void *semphr)
|
|||||||
return (int32_t)xSemaphoreGive(semphr);
|
return (int32_t)xSemaphoreGive(semphr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void *internal_semphr_create_wrapper(uint32_t max, uint32_t init)
|
||||||
|
{
|
||||||
|
wifi_static_queue_t *semphr = heap_caps_calloc(1, sizeof(wifi_static_queue_t), MALLOC_CAP_8BIT|MALLOC_CAP_INTERNAL);
|
||||||
|
if (!semphr) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef CONFIG_SPIRAM_USE_MALLOC
|
||||||
|
semphr->storage = heap_caps_calloc(1, sizeof(StaticSemaphore_t), MALLOC_CAP_8BIT|MALLOC_CAP_INTERNAL);
|
||||||
|
if (!semphr->storage) {
|
||||||
|
goto _error;
|
||||||
|
}
|
||||||
|
|
||||||
|
semphr->handle = xSemaphoreCreateCountingStatic(max, init, semphr->storage);
|
||||||
|
if (!semphr->handle) {
|
||||||
|
goto _error;
|
||||||
|
}
|
||||||
|
return (void *)semphr;
|
||||||
|
|
||||||
|
_error:
|
||||||
|
if (semphr) {
|
||||||
|
if (semphr->storage) {
|
||||||
|
free(semphr->storage);
|
||||||
|
}
|
||||||
|
|
||||||
|
free(semphr);
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
#else
|
||||||
|
semphr->handle = xSemaphoreCreateCounting(max, init);
|
||||||
|
return (void *)semphr;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void internal_semphr_delete_wrapper(void *semphr)
|
||||||
|
{
|
||||||
|
wifi_static_queue_t *semphr_item = (wifi_static_queue_t *)semphr;
|
||||||
|
if (semphr_item) {
|
||||||
|
if (semphr_item->handle) {
|
||||||
|
vSemaphoreDelete(semphr_item->handle);
|
||||||
|
}
|
||||||
|
#ifdef CONFIG_SPIRAM_USE_MALLOC
|
||||||
|
if (semphr_item->storage) {
|
||||||
|
free(semphr_item->storage);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
free(semphr_item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t IRAM_ATTR internal_semphr_take_from_isr_wrapper(void *semphr, void *hptw)
|
||||||
|
{
|
||||||
|
return (int32_t)xSemaphoreTakeFromISR(((wifi_static_queue_t *)semphr)->handle, hptw);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t IRAM_ATTR internal_semphr_give_from_isr_wrapper(void *semphr, void *hptw)
|
||||||
|
{
|
||||||
|
return (int32_t)xSemaphoreGiveFromISR(((wifi_static_queue_t *)semphr)->handle, hptw);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t internal_semphr_take_wrapper(void *semphr, uint32_t block_time_tick)
|
||||||
|
{
|
||||||
|
if (block_time_tick == OSI_FUNCS_TIME_BLOCKING) {
|
||||||
|
return (int32_t)xSemaphoreTake(((wifi_static_queue_t *)semphr)->handle, portMAX_DELAY);
|
||||||
|
} else {
|
||||||
|
return (int32_t)xSemaphoreTake(((wifi_static_queue_t *)semphr)->handle, block_time_tick);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t internal_semphr_give_wrapper(void *semphr)
|
||||||
|
{
|
||||||
|
return (int32_t)xSemaphoreGive(((wifi_static_queue_t *)semphr)->handle);
|
||||||
|
}
|
||||||
|
|
||||||
static void * recursive_mutex_create_wrapper(void)
|
static void * recursive_mutex_create_wrapper(void)
|
||||||
{
|
{
|
||||||
return (void *)xSemaphoreCreateRecursiveMutex();
|
return (void *)xSemaphoreCreateRecursiveMutex();
|
||||||
@ -803,12 +867,12 @@ wifi_osi_funcs_t g_wifi_osi_funcs = {
|
|||||||
coex_adapter_funcs_t g_coex_adapter_funcs = {
|
coex_adapter_funcs_t g_coex_adapter_funcs = {
|
||||||
._version = COEX_ADAPTER_VERSION,
|
._version = COEX_ADAPTER_VERSION,
|
||||||
._task_yield_from_isr = task_yield_from_isr_wrapper,
|
._task_yield_from_isr = task_yield_from_isr_wrapper,
|
||||||
._semphr_create = semphr_create_wrapper,
|
._semphr_create = internal_semphr_create_wrapper,
|
||||||
._semphr_delete = semphr_delete_wrapper,
|
._semphr_delete = internal_semphr_delete_wrapper,
|
||||||
._semphr_take_from_isr = semphr_take_from_isr_wrapper,
|
._semphr_take_from_isr = internal_semphr_take_from_isr_wrapper,
|
||||||
._semphr_give_from_isr = semphr_give_from_isr_wrapper,
|
._semphr_give_from_isr = internal_semphr_give_from_isr_wrapper,
|
||||||
._semphr_take = semphr_take_wrapper,
|
._semphr_take = internal_semphr_take_wrapper,
|
||||||
._semphr_give = semphr_give_wrapper,
|
._semphr_give = internal_semphr_give_wrapper,
|
||||||
._is_in_isr = coex_is_in_isr_wrapper,
|
._is_in_isr = coex_is_in_isr_wrapper,
|
||||||
._malloc_internal = malloc_internal_wrapper,
|
._malloc_internal = malloc_internal_wrapper,
|
||||||
._free = free,
|
._free = free,
|
||||||
|
Reference in New Issue
Block a user