feat(heap): move TLSF ROM patches and related files from esp_rom to heap

The TLSF ROM patch code (rom_patch_tlsf.c, rom_patch_multi_heap.c),
their headers, and the per-target *.rom.heap.ld linker scripts are
semantically owned by the heap component, not esp_rom. Move them
accordingly:

- components/esp_rom/patches/esp_rom_tlsf.c
  → components/heap/rom_patches/rom_patch_tlsf.c
- components/esp_rom/patches/esp_rom_multi_heap.c
  → components/heap/rom_patches/rom_patch_multi_heap.c
- components/esp_rom/include/esp_rom_tlsf.h
  → components/heap/rom_patches/include/rom_patch_tlsf.h
- components/esp_rom/include/esp_rom_multi_heap.h
  → components/heap/rom_patches/include/rom_patch_multi_heap.h
- components/esp_rom/<target>/ld/<target>.rom.heap.ld (×8)
  → components/heap/port/<target>/ld/<target>.rom.heap.ld

Update heap/CMakeLists.txt to:
- use target_linker_script() directly for *.rom.heap.ld
- guard post-registration ROM patch setup with NOT BOOTLOADER_BUILD
- drop stale CONFIG_HEAP_TLSF_CHECK_PATCH symbol reference
- drop esp_rom_include_multi_heap_patch from TLSF_CHECK_PATCH guard

Remove the corresponding entries from esp_rom/CMakeLists.txt.
This commit is contained in:
Guillaume Souchere
2026-04-23 12:21:31 +02:00
parent 3f3ef6f08e
commit a56354e9ab
27 changed files with 50 additions and 45 deletions
@@ -1,59 +0,0 @@
/*
* SPDX-FileCopyrightText: 2026 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#pragma once
#include <stddef.h>
#include "esp_rom_tlsf.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief TLSF ROM vtable stub table for esp32h2.
*
* This struct mirrors the TLSF function-pointer vtable stored in ROM.
* Its layout MUST exactly match the ROM vtable for the target chip.
* It is used by tlsf_set_rom_patches() to intercept TLSF calls.
*/
struct heap_tlsf_stub_table_t {
tlsf_t (*tlsf_create)(void *mem, size_t max_bytes);
tlsf_t (*tlsf_create_with_pool)(void *mem, size_t pool_bytes, size_t max_bytes);
pool_t (*tlsf_get_pool)(tlsf_t tlsf);
pool_t (*tlsf_add_pool)(tlsf_t tlsf, void *mem, size_t bytes);
void (*tlsf_remove_pool)(tlsf_t tlsf, pool_t pool);
void *(*tlsf_malloc)(tlsf_t tlsf, size_t size);
void *(*tlsf_memalign)(tlsf_t tlsf, size_t align, size_t size);
void *(*tlsf_memalign_offs)(tlsf_t tlsf, size_t align, size_t size, size_t offset);
void *(*tlsf_realloc)(tlsf_t tlsf, void *ptr, size_t size);
void (*tlsf_free)(tlsf_t tlsf, void *ptr);
size_t (*tlsf_block_size)(void *ptr);
size_t (*tlsf_size)(tlsf_t tlsf);
size_t (*tlsf_align_size)(void);
size_t (*tlsf_block_size_min)(void);
/* NOTE: The ROM signature is tlsf_block_size_max(control_t *control), but
* control_t is an internal TLSF type not exposed in any public header.
* Since tlsf_t is typedef'd as void* (same as control_t), the ABI is
* identical and we use tlsf_t here to keep this header self-contained. */
size_t (*tlsf_block_size_max)(tlsf_t tlsf);
size_t (*tlsf_pool_overhead)(void);
size_t (*tlsf_alloc_overhead)(void);
void (*tlsf_walk_pool)(pool_t pool, tlsf_walker walker, void *user);
int (*tlsf_check)(tlsf_t tlsf);
int (*tlsf_check_pool)(pool_t pool);
void *(*tlsf_malloc_addr)(tlsf_t tlsf, size_t size, void *address);
};
#ifdef __cplusplus
}
#endif
@@ -1,80 +0,0 @@
/*
* SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
/* ROM function interface esp32h2.rom.heap.ld for esp32h2
*
*
* Generated from ./target/esp32h2/interface-esp32h2.yml md5sum c0ad4e113e5b29bb9d799f10f03edbc1
*
* Compatible with ROM where ECO version equal or greater to 0.
*
* THIS FILE WAS AUTOMATICALLY GENERATED. DO NOT EDIT.
*/
/***************************************
Group heap
***************************************/
/* Functions */
tlsf_create = 0x400003f4;
tlsf_create_with_pool = 0x400003f8;
tlsf_get_pool = 0x400003fc;
tlsf_add_pool = 0x40000400;
tlsf_remove_pool = 0x40000404;
tlsf_malloc = 0x40000408;
tlsf_memalign = 0x4000040c;
tlsf_memalign_offs = 0x40000410;
tlsf_realloc = 0x40000414;
tlsf_free = 0x40000418;
tlsf_block_size = 0x4000041c;
tlsf_size = 0x40000420;
tlsf_align_size = 0x40000424;
tlsf_block_size_min = 0x40000428;
tlsf_block_size_max = 0x4000042c;
tlsf_pool_overhead = 0x40000430;
tlsf_alloc_overhead = 0x40000434;
tlsf_walk_pool = 0x40000438;
tlsf_check = 0x4000043c;
tlsf_poison_fill_pfunc_set = 0x40000444;
tlsf_poison_check_pfunc_set = 0x40000448;
multi_heap_get_block_address_impl = 0x4000044c;
multi_heap_get_allocated_size_impl = 0x40000450;
multi_heap_register_impl = 0x40000454;
multi_heap_set_lock = 0x40000458;
multi_heap_os_funcs_init = 0x4000045c;
multi_heap_internal_lock = 0x40000460;
multi_heap_internal_unlock = 0x40000464;
multi_heap_get_first_block = 0x40000468;
multi_heap_get_next_block = 0x4000046c;
multi_heap_is_free = 0x40000470;
multi_heap_malloc_impl = 0x40000474;
multi_heap_free_impl = 0x40000478;
multi_heap_realloc_impl = 0x4000047c;
multi_heap_aligned_alloc_impl_offs = 0x40000480;
multi_heap_aligned_alloc_impl = 0x40000484;
multi_heap_check = 0x40000488;
multi_heap_dump = 0x4000048c;
multi_heap_free_size_impl = 0x40000490;
multi_heap_minimum_free_size_impl = 0x40000494;
multi_heap_get_info_impl = 0x40000498;
/* Data (.data, .bss, .rodata) */
heap_tlsf_table_ptr = 0x4084ffd8;
PROVIDE (multi_heap_malloc = multi_heap_malloc_impl);
PROVIDE (multi_heap_free = multi_heap_free_impl);
PROVIDE (multi_heap_realloc = multi_heap_realloc_impl);
PROVIDE (multi_heap_get_allocated_size = multi_heap_get_allocated_size_impl);
PROVIDE (multi_heap_register = multi_heap_register_impl);
PROVIDE (multi_heap_get_info = multi_heap_get_info_impl);
PROVIDE (multi_heap_free_size = multi_heap_free_size_impl);
PROVIDE (multi_heap_minimum_free_size = multi_heap_minimum_free_size_impl);
PROVIDE (multi_heap_get_block_address = multi_heap_get_block_address_impl);
PROVIDE (multi_heap_aligned_alloc = multi_heap_aligned_alloc_impl);
PROVIDE (multi_heap_aligned_free = multi_heap_aligned_free_impl);
PROVIDE (multi_heap_check = multi_heap_check);
PROVIDE (multi_heap_set_lock = multi_heap_set_lock);
PROVIDE (multi_heap_os_funcs_init = multi_heap_mutex_init);
PROVIDE (multi_heap_internal_lock = multi_heap_internal_lock);
PROVIDE (multi_heap_internal_unlock = multi_heap_internal_unlock);