feat(esp8266): Add access align capacity to heap API

This commit is contained in:
Dong Heng
2018-05-21 15:25:29 +08:00
parent b0b1ddb118
commit 19f8a92a04
3 changed files with 54 additions and 5 deletions

View File

@ -15,6 +15,8 @@
#include "esp_wifi_os_adapter.h"
#include "esp_system.h"
#include "c_types.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/queue.h"
@ -271,6 +273,34 @@ static bool timer_delete_wrapper(void *timer, uint32_t ticks)
return xTimerDelete(timer, ticks);
}
static void *malloc_wrapper(uint32_t s, uint32_t cap)
{
if (cap & (OSI_MALLOC_CAP_8BIT | OSI_MALLOC_CAP_DMA))
return os_malloc(s);
else
return os_malloc_iram(s);
}
static void *zalloc_wrapper(uint32_t s, uint32_t cap)
{
return os_zalloc(s);
}
static void *realloc_wrapper(void *ptr, uint32_t s, uint32_t cap)
{
return os_realloc(ptr, s);
}
static void *calloc_wrapper(uint32_t cnt, uint32_t s, uint32_t cap)
{
return os_calloc(cnt, s);
}
static void free_wrapper(void *ptr)
{
os_free(ptr);
}
static void srand_wrapper(uint32_t seed)
{
/* empty function */
@ -327,8 +357,11 @@ wifi_osi_funcs_t s_wifi_osi_funcs = {
.timer_stop = timer_stop_wrapper,
.timer_delete = timer_delete_wrapper,
.malloc = malloc,
.free = free,
.malloc = malloc_wrapper,
.zalloc = zalloc_wrapper,
.realloc = realloc_wrapper,
.calloc = calloc_wrapper,
.free = free_wrapper,
.get_free_heap_size = get_free_heap_size_wrapper,
.srand = srand_wrapper,