[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 <mcb30@ipxe.org>
This commit is contained in:
Michael Brown
2025-05-23 12:13:02 +01:00
parent 11929389e4
commit 4a39b877dd
3 changed files with 177 additions and 162 deletions

View File

@@ -10,13 +10,15 @@
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
#include <stdint.h>
extern void initrd_reshuffle ( physaddr_t bottom );
extern int initrd_reshuffle_check ( size_t len, physaddr_t bottom );
#include <ipxe/memmap.h>
/** 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 */