[uheap] Add a generic external heap based on the system memory map

Add an implementation of umalloc() using the generalised model of a
heap, placing the external heap in the largest usable region obtained
from the system memory map.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
Michael Brown
2025-05-19 16:11:59 +01:00
parent 490f1ecad8
commit 4d560af2b0
5 changed files with 240 additions and 0 deletions

View File

@@ -234,5 +234,6 @@ extern void memmap_update ( struct memmap_region *region, uint64_t start,
uint64_t size, unsigned int flags,
const char *name );
extern void memmap_update_used ( struct memmap_region *region );
extern size_t memmap_largest ( physaddr_t *start );
#endif /* _IPXE_MEMMAP_H */

18
src/include/ipxe/uheap.h Normal file
View File

@@ -0,0 +1,18 @@
#ifndef _IPXE_UHEAP_H
#define _IPXE_UHEAP_H
/** @file
*
* External ("user") heap
*
*/
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
#ifdef UMALLOC_UHEAP
#define UMALLOC_PREFIX_uheap
#else
#define UMALLOC_PREFIX_uheap __uheap_
#endif
#endif /* _IPXE_UHEAP_H */

View File

@@ -26,6 +26,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
PROVIDE_SINGLE_API ( UMALLOC_PREFIX_ ## _subsys, _api_func, _func )
/* Include all architecture-independent I/O API headers */
#include <ipxe/uheap.h>
#include <ipxe/efi/efi_umalloc.h>
#include <ipxe/linux/linux_umalloc.h>