summaryrefslogtreecommitdiffstats
path: root/src/boot/efi/stub.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2024-06-26 10:34:09 +0200
committerLennart Poettering <lennart@poettering.net>2024-06-26 17:09:45 +0200
commit8e67de84028d9357403580cce62aa57ef9702d23 (patch)
tree89deb75e3e213811f6e82d9a9291c666d83f3092 /src/boot/efi/stub.c
parentstub: split out code that generates embedded initrds (diff)
downloadsystemd-8e67de84028d9357403580cce62aa57ef9702d23.tar.xz
systemd-8e67de84028d9357403580cce62aa57ef9702d23.zip
stub: split out code that finds embedded initrds
Diffstat (limited to '')
-rw-r--r--src/boot/efi/stub.c30
1 files changed, 21 insertions, 9 deletions
diff --git a/src/boot/efi/stub.c b/src/boot/efi/stub.c
index eb3e905f3c..8947f3aabf 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;