[lkrn] Support initrd construction for RISC-V bare-metal kernels

Use the shared initrd reshuffling and CPIO header construction code
for RISC-V bare-metal kernels.  This allows for files to be injected
into the constructed ("magic") initrd image in exactly the same way as
is done for bzImage and UEFI kernels.

We append a dummy image encompassing the FDT to the end of the
reshuffle list, so that it ends up directly following the constructed
initrd in memory (but excluded from the initrd length, which was
recorded before constructing the FDT).

We also temporarily prepend the kernel binary itself to the reshuffle
list.  This is guaranteed to be safe (since reshuffling is designed to
be unable to fail), and avoids the requirement for the kernel segment
to be available before reshuffling.  This is useful since current
RISC-V bare-metal kernels tend to be distributed as EFI zboot images,
which require large temporary allocations from the external heap for
the intermediate images created during archive extraction.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
Michael Brown
2025-05-23 16:14:45 +01:00
parent c713ce5c7b
commit cd38ed4fab
2 changed files with 97 additions and 103 deletions

View File

@@ -52,12 +52,10 @@ struct lkrn_context {
physaddr_t ram;
/** Entry point */
physaddr_t entry;
/** Device tree */
physaddr_t fdt;
/** Initial ramdisk (if any) */
physaddr_t initrd;
/** Length of initial ramdisk (if any) */
size_t initrd_len;
/** Device tree */
physaddr_t fdt;
};
/** Compressed kernel image header */