heap_tlsf: use tlsf IMPL in ESP32C2 ROM

This commit is contained in:
jiangguangming
2021-03-19 17:29:42 +08:00
committed by wuzhenghui
parent a9f8b20431
commit 6ec373daf5
11 changed files with 95 additions and 36 deletions

View File

@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -12,7 +12,7 @@
#include <stdio.h>
#include <sys/cdefs.h>
#include "heap_tlsf.h"
#include <multi_heap.h>
#include "multi_heap.h"
#include "multi_heap_internal.h"
/* Note: Keep platform-specific parts in this header, this source
@@ -22,7 +22,7 @@
/* Defines compile-time configuration macros */
#include "multi_heap_config.h"
#ifndef MULTI_HEAP_POISONING
#if (!defined MULTI_HEAP_POISONING) && (!defined CONFIG_HEAP_ROM_IMPL)
/* if no heap poisoning, public API aliases directly to these implementations */
void *multi_heap_malloc(multi_heap_handle_t heap, size_t size)
__attribute__((alias("multi_heap_malloc_impl")));
@@ -77,6 +77,30 @@ typedef struct multi_heap_info {
tlsf_t heap_data;
} heap_t;
#ifdef CONFIG_HEAP_ROM_IMPL
void _multi_heap_lock(void *lock)
{
MULTI_HEAP_LOCK(lock);
}
void _multi_heap_unlock(void *lock)
{
MULTI_HEAP_UNLOCK(lock);
}
multi_heap_os_funcs_t multi_heap_os_funcs = {
.lock = _multi_heap_lock,
.unlock = _multi_heap_unlock,
};
void multi_heap_in_rom_init(void)
{
multi_heap_os_funcs_init(&multi_heap_os_funcs);
}
#else //#ifndef CONFIG_HEAP_ROM_IMPL
/* Return true if this block is free. */
static inline bool is_free(const block_header_t *block)
{
@@ -201,7 +225,6 @@ void *multi_heap_malloc_impl(multi_heap_handle_t heap, size_t size)
void multi_heap_free_impl(multi_heap_handle_t heap, void *p)
{
if (heap == NULL || p == NULL) {
return;
}
@@ -380,3 +403,4 @@ void multi_heap_get_info_impl(multi_heap_handle_t heap, multi_heap_info_t *info)
}
multi_heap_internal_unlock(heap);
}
#endif