forked from espressif/esp-idf
Merge branch 'feature/add_rom_tlsf_function_prototype_v5.0' into 'release/v5.0'
esp_rom: add rom tlsf function prototype instead of void * (backport to v5.0) See merge request espressif/esp-idf!20684
This commit is contained in:
@ -1,32 +0,0 @@
|
|||||||
/*
|
|
||||||
* SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
|
||||||
*/
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* @brief Set the function to call for filling memory region when
|
|
||||||
* poisoning is configured.
|
|
||||||
*
|
|
||||||
* @param pfunc The callback function to trigger for poisoning
|
|
||||||
* a memory region.
|
|
||||||
*/
|
|
||||||
void tlsf_poison_fill_pfunc_set(void *pfunc);
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* @brief Set the function to call for checking memory region when
|
|
||||||
* poisoning is configured.
|
|
||||||
*
|
|
||||||
* @param pfunc The callback function to trigger for checking
|
|
||||||
* the content of a memory region.
|
|
||||||
*/
|
|
||||||
void tlsf_poison_check_pfunc_set(void *pfunc);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
45
components/esp_rom/include/esp_rom_tlsf.h
Normal file
45
components/esp_rom/include/esp_rom_tlsf.h
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
/*
|
||||||
|
* SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
|
*/
|
||||||
|
#pragma once
|
||||||
|
#include <stddef.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Defines the function prototypes for multi_heap_internal_poison_fill_region
|
||||||
|
* and multi_heap_internal_check_block_poisoning, these two function will
|
||||||
|
* be registered to the ROM tlsf IMPL through the function tlsf_poison_fill_pfunc_set()
|
||||||
|
* and tlsf_poison_check_pfunc_set() when the heap poisoning feature is enabled.
|
||||||
|
*/
|
||||||
|
typedef void (*poison_fill_pfunc_t)(void *start, size_t size, bool is_free);
|
||||||
|
typedef bool (*poison_check_pfunc_t)(void *start, size_t size, bool is_free, bool print_errors);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Set the function to call for filling memory region when
|
||||||
|
* poisoning is configured.
|
||||||
|
*
|
||||||
|
* @note Please keep in mind that this function in ROM still accepts void*.
|
||||||
|
*
|
||||||
|
* @param pfunc The callback function to trigger for poisoning
|
||||||
|
* a memory region.
|
||||||
|
*/
|
||||||
|
void tlsf_poison_fill_pfunc_set(poison_fill_pfunc_t pfunc);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Set the function to call for checking memory region when
|
||||||
|
* poisoning is configured.
|
||||||
|
*
|
||||||
|
* @param pfunc The callback function to trigger for checking
|
||||||
|
* the content of a memory region.
|
||||||
|
*/
|
||||||
|
void tlsf_poison_check_pfunc_set(poison_check_pfunc_t pfunc);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
@ -17,7 +17,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "esp_rom_caps.h"
|
#include "esp_rom_caps.h"
|
||||||
#include "rom/tlsf.h"
|
#include "esp_rom_tlsf.h"
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief Opaque types for TLSF implementation
|
* @brief Opaque types for TLSF implementation
|
||||||
@ -164,12 +164,11 @@ static inline __attribute__((__always_inline__)) void mapping_insert(size_t size
|
|||||||
* defined below
|
* defined below
|
||||||
* ---------------------------------------------------------------- */
|
* ---------------------------------------------------------------- */
|
||||||
|
|
||||||
typedef bool (*poison_check_pfunc_t)(void *start, size_t size, bool is_free, bool print_errors);
|
|
||||||
static poison_check_pfunc_t s_poison_check_region = NULL;
|
static poison_check_pfunc_t s_poison_check_region = NULL;
|
||||||
|
|
||||||
void tlsf_poison_check_pfunc_set(void *pfunc)
|
void tlsf_poison_check_pfunc_set(poison_check_pfunc_t pfunc)
|
||||||
{
|
{
|
||||||
s_poison_check_region = (poison_check_pfunc_t)pfunc;
|
s_poison_check_region = pfunc;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define tlsf_insist_no_assert(x) { if (!(x)) { status--; } }
|
#define tlsf_insist_no_assert(x) { if (!(x)) { status--; } }
|
||||||
|
@ -21,15 +21,13 @@
|
|||||||
/* Defines compile-time configuration macros */
|
/* Defines compile-time configuration macros */
|
||||||
#include "multi_heap_config.h"
|
#include "multi_heap_config.h"
|
||||||
|
|
||||||
#if !CONFIG_HEAP_TLSF_USE_ROM_IMPL
|
#if CONFIG_HEAP_TLSF_USE_ROM_IMPL
|
||||||
#include "tlsf.h"
|
|
||||||
#else
|
|
||||||
/* Header containing the declaration of tlsf_poison_fill_pfunc_set()
|
/* Header containing the declaration of tlsf_poison_fill_pfunc_set()
|
||||||
* and tlsf_poison_check_pfunc_set() used to register callbacks to
|
* and tlsf_poison_check_pfunc_set() used to register callbacks to
|
||||||
* fill and check memory region with given patterns in the heap
|
* fill and check memory region with given patterns in the heap
|
||||||
* components.
|
* components.
|
||||||
*/
|
*/
|
||||||
#include "rom/tlsf.h"
|
#include "esp_rom_tlsf.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef MULTI_HEAP_POISONING
|
#ifdef MULTI_HEAP_POISONING
|
||||||
|
Reference in New Issue
Block a user