heap: add selective placement of function in IRAM

This commit aims to place in the IRAM section only the functions that
are relevent for performance instead of placing the entire content of
multi_heap.c, mullti_heap_poisoning.c and tlsf.c in the IRAM.
This commit is contained in:
Guillaume Souchere 2022-11-03 08:44:56 +01:00
parent 9e88f790ff
commit 47cfd0a0d8
3 changed files with 53 additions and 20 deletions

View File

@ -43,7 +43,7 @@ extern SLIST_HEAD(registered_heap_ll, heap_t_) registered_heaps;
bool heap_caps_match(const heap_t *heap, uint32_t caps); bool heap_caps_match(const heap_t *heap, uint32_t caps);
/* return all possible capabilities (across all priorities) for a given heap */ /* return all possible capabilities (across all priorities) for a given heap */
inline static IRAM_ATTR uint32_t get_all_caps(const heap_t *heap) inline static uint32_t get_all_caps(const heap_t *heap)
{ {
if (heap->heap == NULL) { if (heap->heap == NULL) {
return 0; return 0;

View File

@ -2,7 +2,53 @@
archive: libheap.a archive: libheap.a
entries: entries:
if HEAP_TLSF_USE_ROM_IMPL = n: if HEAP_TLSF_USE_ROM_IMPL = n:
tlsf (noflash) tlsf:tlsf_ffs (noflash)
multi_heap (noflash) tlsf:tlsf_fls (noflash)
tlsf:tlsf_block_size (noflash)
tlsf:tlsf_size (noflash)
tlsf:tlsf_align_size (noflash)
tlsf:tlsf_block_size_min (noflash)
tlsf:tlsf_block_size_max (noflash)
tlsf:tlsf_alloc_overhead (noflash)
tlsf:tlsf_get_pool (noflash)
tlsf:tlsf_malloc (noflash)
tlsf:tlsf_memalign_offs (noflash)
tlsf:tlsf_memalign (noflash)
tlsf:tlsf_free (noflash)
tlsf:tlsf_realloc (noflash)
multi_heap:assert_valid_block (noflash)
multi_heap:multi_heap_get_block_address_impl (noflash)
multi_heap:multi_heap_get_allocated_size_impl (noflash)
multi_heap:multi_heap_set_lock (noflash)
multi_heap:multi_heap_get_first_block (noflash)
multi_heap:multi_heap_get_next_block (noflash)
multi_heap:multi_heap_is_free (noflash)
multi_heap:multi_heap_malloc_impl (noflash)
multi_heap:multi_heap_free_impl (noflash)
multi_heap:multi_heap_realloc_impl (noflash)
multi_heap:multi_heap_aligned_alloc_impl_offs (noflash)
multi_heap:multi_heap_aligned_alloc_impl (noflash)
if HEAP_TLSF_USE_ROM_IMPL = y:
multi_heap:_multi_heap_lock (noflash)
multi_heap:_multi_heap_unlock (noflash)
multi_heap:multi_heap_in_rom_init (noflash)
if HEAP_POISONING_DISABLED = n: if HEAP_POISONING_DISABLED = n:
multi_heap_poisoning (noflash) multi_heap_poisoning:poison_allocated_region (noflash)
multi_heap_poisoning:verify_allocated_region (noflash)
multi_heap_poisoning:multi_heap_aligned_alloc (noflash)
multi_heap_poisoning:multi_heap_malloc (noflash)
multi_heap_poisoning:multi_heap_free (noflash)
multi_heap_poisoning:multi_heap_aligned_free (noflash)
multi_heap_poisoning:multi_heap_realloc (noflash)
multi_heap_poisoning:multi_heap_get_block_address (noflash)
multi_heap_poisoning:multi_heap_get_block_owner (noflash)
multi_heap_poisoning:multi_heap_get_allocated_size (noflash)
multi_heap_poisoning:multi_heap_internal_check_block_poisoning (noflash)
multi_heap_poisoning:multi_heap_internal_poison_fill_region (noflash)
if HEAP_POISONING_COMPREHENSIVE = y:
multi_heap_poisoning:verify_fill_pattern (noflash)
multi_heap_poisoning:block_absorb_post_hook (noflash)

View File

@ -105,18 +105,6 @@ void multi_heap_in_rom_init(void)
#else // CONFIG_HEAP_TLSF_USE_ROM_IMPL #else // CONFIG_HEAP_TLSF_USE_ROM_IMPL
/* Return true if this block is free. */
static inline bool is_free(const block_header_t *block)
{
return ((block->size & 0x01) != 0);
}
/* Data size of the block (excludes this block's header) */
static inline size_t block_data_size(const block_header_t *block)
{
return (block->size & ~0x03);
}
/* Check a block is valid for this heap. Used to verify parameters. */ /* Check a block is valid for this heap. Used to verify parameters. */
static void assert_valid_block(const heap_t *heap, const block_header_t *block) static void assert_valid_block(const heap_t *heap, const block_header_t *block)
{ {
@ -130,8 +118,7 @@ static void assert_valid_block(const heap_t *heap, const block_header_t *block)
void *multi_heap_get_block_address_impl(multi_heap_block_handle_t block) void *multi_heap_get_block_address_impl(multi_heap_block_handle_t block)
{ {
void *ptr = block_to_ptr(block); return block_to_ptr(block);
return (ptr);
} }
size_t multi_heap_get_allocated_size_impl(multi_heap_handle_t heap, void *p) size_t multi_heap_get_allocated_size_impl(multi_heap_handle_t heap, void *p)
@ -192,7 +179,7 @@ multi_heap_block_handle_t multi_heap_get_next_block(multi_heap_handle_t heap, mu
assert_valid_block(heap, block); assert_valid_block(heap, block);
block_header_t* next = block_next(block); block_header_t* next = block_next(block);
if(block_data_size(next) == 0) { if(block_size(next) == 0) {
//Last block: //Last block:
return NULL; return NULL;
} else { } else {
@ -203,7 +190,7 @@ multi_heap_block_handle_t multi_heap_get_next_block(multi_heap_handle_t heap, mu
bool multi_heap_is_free(multi_heap_block_handle_t block) bool multi_heap_is_free(multi_heap_block_handle_t block)
{ {
return is_free(block); return block_is_free(block);
} }
void *multi_heap_malloc_impl(multi_heap_handle_t heap, size_t size) void *multi_heap_malloc_impl(multi_heap_handle_t heap, size_t size)