From 4a39b877dd165cc903da2e15cb1c42d1d115cc80 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Fri, 23 May 2025 12:13:02 +0100 Subject: [initrd] Split out initrd construction from bzimage.c Provide a reusable function initrd_load_all() to load all initrds (including any constructed CPIO headers) into a contiguous memory region, and support functions to find the constructed total length and permissible post-reshuffling load address range. Signed-off-by: Michael Brown --- src/include/ipxe/initrd.h | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'src/include') diff --git a/src/include/ipxe/initrd.h b/src/include/ipxe/initrd.h index 10533b53b..0b955a381 100644 --- a/src/include/ipxe/initrd.h +++ b/src/include/ipxe/initrd.h @@ -10,13 +10,15 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include - -extern void initrd_reshuffle ( physaddr_t bottom ); -extern int initrd_reshuffle_check ( size_t len, physaddr_t bottom ); +#include /** Initial ramdisk chunk alignment */ #define INITRD_ALIGN 4096 +extern void initrd_reshuffle ( void ); +extern int initrd_region ( size_t len, struct memmap_region *region ); +extern size_t initrd_load_all ( void *address ); + /** * Align initrd length * @@ -29,4 +31,15 @@ initrd_align ( size_t len ) { return ( ( len + INITRD_ALIGN - 1 ) & ~( INITRD_ALIGN - 1 ) ); } +/** + * Get required length for initrds + * + * @ret len Required length + */ +static inline __attribute__ (( always_inline )) size_t +initrd_len ( void ) { + + return initrd_load_all ( NULL ); +} + #endif /* _IPXE_INITRD_H */ -- cgit v1.2.3-55-g7522