mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
bt: Remove FreeRTOS static allocation from OSI functions
Previously, the BT OSI would use various FreeRTOS "create static" functions to
ensure that semaphores and queues were always allocated to internal memory.
However, from commit e21ab0332b
onwards, all
dynamic memory allocated by FreeRTOS will default to internal RAM.
Thus, the extra "create static" calls can be removed to simply the code.
This commit is contained in:
parent
420ebd208a
commit
51405fd9d4
@ -111,7 +111,6 @@ typedef struct {
|
||||
|
||||
typedef struct {
|
||||
void *handle;
|
||||
void *storage;
|
||||
} btdm_queue_item_t;
|
||||
|
||||
/* OSI function */
|
||||
@ -555,17 +554,8 @@ static void *semphr_create_wrapper(uint32_t max, uint32_t init)
|
||||
|
||||
void *handle = NULL;
|
||||
|
||||
#if !CONFIG_SPIRAM_USE_MALLOC
|
||||
/* IDF FreeRTOS guarantees that all dynamic memory allocation goes to internal RAM. */
|
||||
handle = (void *)xSemaphoreCreateCounting(max, init);
|
||||
#else
|
||||
StaticQueue_t *queue_buffer = NULL;
|
||||
|
||||
queue_buffer = heap_caps_malloc(sizeof(StaticQueue_t), MALLOC_CAP_INTERNAL|MALLOC_CAP_8BIT);
|
||||
assert(queue_buffer);
|
||||
semphr->storage = queue_buffer;
|
||||
|
||||
handle = (void *)xSemaphoreCreateCountingStatic(max, init, queue_buffer);
|
||||
#endif
|
||||
assert(handle);
|
||||
|
||||
#if CONFIG_BTDM_CTRL_HLI
|
||||
@ -601,11 +591,6 @@ static void semphr_delete_wrapper(void *semphr)
|
||||
if (handle) {
|
||||
vSemaphoreDelete(handle);
|
||||
}
|
||||
#ifdef CONFIG_SPIRAM_USE_MALLOC
|
||||
if (semphr_item->storage) {
|
||||
free(semphr_item->storage);
|
||||
}
|
||||
#endif
|
||||
|
||||
free(semphr);
|
||||
}
|
||||
@ -691,18 +676,9 @@ static void *queue_create_wrapper(uint32_t queue_len, uint32_t item_size)
|
||||
queue = (btdm_queue_item_t*)heap_caps_malloc(sizeof(btdm_queue_item_t), MALLOC_CAP_INTERNAL|MALLOC_CAP_8BIT);
|
||||
assert(queue);
|
||||
|
||||
#if CONFIG_SPIRAM_USE_MALLOC
|
||||
|
||||
queue->storage = heap_caps_calloc(1, sizeof(StaticQueue_t) + (queue_len*item_size), MALLOC_CAP_INTERNAL|MALLOC_CAP_8BIT);
|
||||
assert(queue->storage);
|
||||
|
||||
queue->handle = xQueueCreateStatic( queue_len, item_size, ((uint8_t*)(queue->storage)) + sizeof(StaticQueue_t), (StaticQueue_t*)(queue->storage));
|
||||
assert(queue->handle);
|
||||
|
||||
#else
|
||||
/* IDF FreeRTOS guarantees that all dynamic memory allocation goes to internal RAM. */
|
||||
queue->handle = xQueueCreate( queue_len, item_size);
|
||||
assert(queue->handle);
|
||||
#endif
|
||||
|
||||
return queue;
|
||||
}
|
||||
@ -714,13 +690,6 @@ static void queue_delete_wrapper(void *queue)
|
||||
if(queue_item->handle){
|
||||
vQueueDelete(queue_item->handle);
|
||||
}
|
||||
|
||||
#if CONFIG_SPIRAM_USE_MALLOC
|
||||
if (queue_item->storage) {
|
||||
free(queue_item->storage);
|
||||
}
|
||||
#endif
|
||||
|
||||
free(queue_item);
|
||||
}
|
||||
}
|
||||
|
@ -135,7 +135,6 @@ typedef struct vhci_host_callback {
|
||||
|
||||
typedef struct {
|
||||
void *handle;
|
||||
void *storage;
|
||||
} btdm_queue_item_t;
|
||||
|
||||
typedef void (* osi_intr_handler)(void);
|
||||
@ -511,16 +510,10 @@ static void *semphr_create_wrapper(uint32_t max, uint32_t init)
|
||||
btdm_queue_item_t *semphr = heap_caps_calloc(1, sizeof(btdm_queue_item_t), MALLOC_CAP_8BIT|MALLOC_CAP_INTERNAL);
|
||||
assert(semphr);
|
||||
|
||||
#if !CONFIG_SPIRAM_USE_MALLOC
|
||||
/* IDF FreeRTOS guarantees that all dynamic memory allocation goes to internal RAM. */
|
||||
semphr->handle = (void *)xSemaphoreCreateCounting(max, init);
|
||||
#else
|
||||
|
||||
semphr->storage = heap_caps_malloc(sizeof(StaticQueue_t), MALLOC_CAP_INTERNAL|MALLOC_CAP_8BIT);
|
||||
assert(semphr->storage);
|
||||
|
||||
semphr->handle = (void *)xSemaphoreCreateCountingStatic(max, init, semphr->storage);
|
||||
#endif
|
||||
assert(semphr->handle);
|
||||
|
||||
return semphr;
|
||||
}
|
||||
|
||||
@ -535,11 +528,6 @@ static void semphr_delete_wrapper(void *semphr)
|
||||
if (semphr_item->handle) {
|
||||
vSemaphoreDelete(semphr_item->handle);
|
||||
}
|
||||
#ifdef CONFIG_SPIRAM_USE_MALLOC
|
||||
if (semphr_item->storage) {
|
||||
free(semphr_item->storage);
|
||||
}
|
||||
#endif
|
||||
|
||||
free(semphr);
|
||||
}
|
||||
@ -595,18 +583,9 @@ static void *queue_create_wrapper(uint32_t queue_len, uint32_t item_size)
|
||||
queue = (btdm_queue_item_t*)heap_caps_malloc(sizeof(btdm_queue_item_t), MALLOC_CAP_INTERNAL|MALLOC_CAP_8BIT);
|
||||
assert(queue);
|
||||
|
||||
#if CONFIG_SPIRAM_USE_MALLOC
|
||||
|
||||
queue->storage = heap_caps_calloc(1, sizeof(StaticQueue_t) + (queue_len*item_size), MALLOC_CAP_INTERNAL|MALLOC_CAP_8BIT);
|
||||
assert(queue->storage);
|
||||
|
||||
queue->handle = xQueueCreateStatic( queue_len, item_size, ((uint8_t*)(queue->storage)) + sizeof(StaticQueue_t), (StaticQueue_t*)(queue->storage));
|
||||
assert(queue->handle);
|
||||
|
||||
#else
|
||||
/* IDF FreeRTOS guarantees that all dynamic memory allocation goes to internal RAM. */
|
||||
queue->handle = xQueueCreate( queue_len, item_size);
|
||||
assert(queue->handle);
|
||||
#endif
|
||||
|
||||
return queue;
|
||||
}
|
||||
@ -618,13 +597,6 @@ static void queue_delete_wrapper(void *queue)
|
||||
if(queue_item->handle){
|
||||
vQueueDelete(queue_item->handle);
|
||||
}
|
||||
|
||||
#if CONFIG_SPIRAM_USE_MALLOC
|
||||
if (queue_item->storage) {
|
||||
free(queue_item->storage);
|
||||
}
|
||||
#endif
|
||||
|
||||
free(queue_item);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user