From: Lennart Poettering Date: Wed, 26 Jun 2024 08:34:09 +0000 (+0200) Subject: stub: split out code that finds embedded initrds X-Git-Tag: v257-rc1~1041^2~19 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8e67de84028d9357403580cce62aa57ef9702d23;p=thirdparty%2Fsystemd.git stub: split out code that finds embedded initrds --- diff --git a/src/boot/efi/stub.c b/src/boot/efi/stub.c index eb3e905f3cf..8947f3aabfd 100644 --- a/src/boot/efi/stub.c +++ b/src/boot/efi/stub.c @@ -780,6 +780,26 @@ static void generate_embedded_initrds( /* ret_measured= */ NULL); } +static void lookup_embedded_initrds( + EFI_LOADED_IMAGE_PROTOCOL *loaded_image, + PeSectionVector sections[_UNIFIED_SECTION_MAX], + struct iovec initrds[static _INITRD_MAX]) { + + assert(loaded_image); + assert(sections); + assert(initrds); + + if (PE_SECTION_VECTOR_IS_SET(sections + UNIFIED_SECTION_INITRD)) + initrds[INITRD_BASE] = IOVEC_MAKE( + (const uint8_t*) loaded_image->ImageBase + sections[UNIFIED_SECTION_INITRD].memory_offset, + sections[UNIFIED_SECTION_INITRD].size); + + if (PE_SECTION_VECTOR_IS_SET(sections + UNIFIED_SECTION_UCODE)) + initrds[INITRD_UCODE] = IOVEC_MAKE( + (const uint8_t*) loaded_image->ImageBase + sections[UNIFIED_SECTION_UCODE].memory_offset, + sections[UNIFIED_SECTION_UCODE].size); +} + static EFI_STATUS run(EFI_HANDLE image) { _cleanup_(initrds_free) struct iovec initrds[_INITRD_MAX] = {}; void **dt_bases_addons_global = NULL, **dt_bases_addons_uki = NULL; @@ -930,15 +950,7 @@ static EFI_STATUS run(EFI_HANDLE image) { (const uint8_t*) loaded_image->ImageBase + sections[UNIFIED_SECTION_LINUX].memory_offset, sections[UNIFIED_SECTION_LINUX].size); - if (PE_SECTION_VECTOR_IS_SET(sections + UNIFIED_SECTION_INITRD)) - initrds[INITRD_BASE] = IOVEC_MAKE( - (const uint8_t*) loaded_image->ImageBase + sections[UNIFIED_SECTION_INITRD].memory_offset, - sections[UNIFIED_SECTION_INITRD].size); - - if (PE_SECTION_VECTOR_IS_SET(sections + UNIFIED_SECTION_UCODE)) - initrds[INITRD_UCODE] = IOVEC_MAKE( - (const uint8_t*) loaded_image->ImageBase + sections[UNIFIED_SECTION_UCODE].memory_offset, - sections[UNIFIED_SECTION_UCODE].size); + lookup_embedded_initrds(loaded_image, sections, initrds); _cleanup_pages_ Pages initrd_pages = {}; struct iovec final_initrd;