mirror of
https://github.com/espressif/ESP8266_RTOS_SDK.git
synced 2025-05-22 01:27:11 +08:00
feat(esp8266): Add access align capacity to heap API
This commit is contained in:
@ -28,6 +28,10 @@ extern "C" {
|
|||||||
#define OSI_QUEUE_SEND_BACK 1
|
#define OSI_QUEUE_SEND_BACK 1
|
||||||
#define OSI_QUEUE_SEND_OVERWRITE 2
|
#define OSI_QUEUE_SEND_OVERWRITE 2
|
||||||
|
|
||||||
|
#define OSI_MALLOC_CAP_32BIT (1 << 1)
|
||||||
|
#define OSI_MALLOC_CAP_8BIT (1 << 2)
|
||||||
|
#define OSI_MALLOC_CAP_DMA (1 << 3)
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint32_t (*enter_critical)(void);
|
uint32_t (*enter_critical)(void);
|
||||||
void (*exit_critical)(uint32_t tmp);
|
void (*exit_critical)(uint32_t tmp);
|
||||||
@ -74,7 +78,10 @@ typedef struct {
|
|||||||
bool (*timer_stop)(void *timer, uint32_t ticks);
|
bool (*timer_stop)(void *timer, uint32_t ticks);
|
||||||
bool (*timer_delete)(void *timer, uint32_t ticks);
|
bool (*timer_delete)(void *timer, uint32_t ticks);
|
||||||
|
|
||||||
void *(*malloc)(uint32_t size);
|
void *(*malloc)(uint32_t size, uint32_t cap);
|
||||||
|
void *(*zalloc)(uint32_t size, uint32_t cap);
|
||||||
|
void *(*realloc)(void *ptr, uint32_t size, uint32_t cap);
|
||||||
|
void *(*calloc)(uint32_t cnt, uint32_t size, uint32_t cap);
|
||||||
void (*free)(void *p);
|
void (*free)(void *p);
|
||||||
uint32_t (*get_free_heap_size)(void);
|
uint32_t (*get_free_heap_size)(void);
|
||||||
|
|
||||||
|
@ -131,8 +131,17 @@ extern wifi_osi_funcs_t s_wifi_osi_funcs;
|
|||||||
#define wifi_timer_delete(t, tk) \
|
#define wifi_timer_delete(t, tk) \
|
||||||
s_wifi_osi_funcs.timer_delete(t, tk)
|
s_wifi_osi_funcs.timer_delete(t, tk)
|
||||||
|
|
||||||
#define wifi_malloc(s) \
|
#define wifi_malloc(s, c) \
|
||||||
s_wifi_osi_funcs.malloc(s)
|
s_wifi_osi_funcs.malloc(s, c)
|
||||||
|
|
||||||
|
#define wifi_zalloc(s, c) \
|
||||||
|
s_wifi_osi_funcs.zalloc(s, c)
|
||||||
|
|
||||||
|
#define wifi_calloc(cnt, s, c) \
|
||||||
|
s_wifi_osi_funcs.calloc(cnt, s, c)
|
||||||
|
|
||||||
|
#define wifi_realloc(ptr, s, c) \
|
||||||
|
s_wifi_osi_funcs.realloc(ptr, s, c)
|
||||||
|
|
||||||
#define wifi_free(p) \
|
#define wifi_free(p) \
|
||||||
s_wifi_osi_funcs.free(p)
|
s_wifi_osi_funcs.free(p)
|
||||||
|
@ -15,6 +15,8 @@
|
|||||||
#include "esp_wifi_os_adapter.h"
|
#include "esp_wifi_os_adapter.h"
|
||||||
#include "esp_system.h"
|
#include "esp_system.h"
|
||||||
|
|
||||||
|
#include "c_types.h"
|
||||||
|
|
||||||
#include "freertos/FreeRTOS.h"
|
#include "freertos/FreeRTOS.h"
|
||||||
#include "freertos/task.h"
|
#include "freertos/task.h"
|
||||||
#include "freertos/queue.h"
|
#include "freertos/queue.h"
|
||||||
@ -271,6 +273,34 @@ static bool timer_delete_wrapper(void *timer, uint32_t ticks)
|
|||||||
return xTimerDelete(timer, 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)
|
static void srand_wrapper(uint32_t seed)
|
||||||
{
|
{
|
||||||
/* empty function */
|
/* empty function */
|
||||||
@ -327,8 +357,11 @@ wifi_osi_funcs_t s_wifi_osi_funcs = {
|
|||||||
.timer_stop = timer_stop_wrapper,
|
.timer_stop = timer_stop_wrapper,
|
||||||
.timer_delete = timer_delete_wrapper,
|
.timer_delete = timer_delete_wrapper,
|
||||||
|
|
||||||
.malloc = malloc,
|
.malloc = malloc_wrapper,
|
||||||
.free = free,
|
.zalloc = zalloc_wrapper,
|
||||||
|
.realloc = realloc_wrapper,
|
||||||
|
.calloc = calloc_wrapper,
|
||||||
|
.free = free_wrapper,
|
||||||
.get_free_heap_size = get_free_heap_size_wrapper,
|
.get_free_heap_size = get_free_heap_size_wrapper,
|
||||||
|
|
||||||
.srand = srand_wrapper,
|
.srand = srand_wrapper,
|
||||||
|
Reference in New Issue
Block a user