mirror of
https://github.com/espressif/esp-idf.git
synced 2025-11-03 16:41:44 +01:00
heap: add check for usage of flash content from iram
this commits: - adds build-time test to check that no call to flash regions are done from IRAM functions - resolves problems related to IRAM function using content in flash memory - update heap_caps_alloc_failed to use a default function name in DRAM when necessary instead of creating a function name variable in DRAM for each call of heap_caps_alloc_failed. This allows to save some extra bytes in RAM.
This commit is contained in:
@@ -22,7 +22,7 @@
|
||||
#include "esp_log.h"
|
||||
#include "heap_private.h"
|
||||
#include "esp_system.h"
|
||||
|
||||
#include "esp_private/cache_utils.h"
|
||||
|
||||
// forward declaration
|
||||
IRAM_ATTR static void *heap_caps_realloc_base( void *ptr, size_t size, uint32_t caps);
|
||||
@@ -61,10 +61,16 @@ IRAM_ATTR static void *dram_alloc_to_iram_addr(void *addr, size_t len)
|
||||
}
|
||||
|
||||
|
||||
static void heap_caps_alloc_failed(size_t requested_size, uint32_t caps, const char *function_name)
|
||||
IRAM_ATTR static void heap_caps_alloc_failed(size_t requested_size, uint32_t caps, const char *function_name)
|
||||
{
|
||||
static const DRAM_ATTR char *default_func_name = "<function_name>";
|
||||
if (alloc_failed_callback) {
|
||||
alloc_failed_callback(requested_size, caps, function_name);
|
||||
if (!spi_flash_cache_enabled() && !esp_ptr_internal(function_name)) {
|
||||
alloc_failed_callback(requested_size, caps, default_func_name);
|
||||
}
|
||||
else {
|
||||
alloc_failed_callback(requested_size, caps, function_name);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef CONFIG_HEAP_ABORT_WHEN_ALLOCATION_FAILS
|
||||
|
||||
Reference in New Issue
Block a user