]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
x86/boot: Split parsing of boot_params into the parse_boot_params() helper function
authorMike Rapoport (Microsoft) <rppt@kernel.org>
Fri, 14 Feb 2025 09:06:50 +0000 (11:06 +0200)
committerIngo Molnar <mingo@kernel.org>
Fri, 21 Feb 2025 15:05:00 +0000 (16:05 +0100)
Makes setup_arch() a bit easier to comprehend.

No functional changes.

Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Link: https://lore.kernel.org/r/20250214090651.3331663-4-rppt@kernel.org
arch/x86/kernel/setup.c

index 3d95946ab749cde0995fe153a7ac6a5371acaf16..6fb9a851bc197fbbb467f3092023744ec3a0407e 100644 (file)
@@ -429,6 +429,46 @@ static void __init parse_setup_data(void)
        }
 }
 
+/*
+ * Translate the fields of 'struct boot_param' into global variables
+ * representing these parameters.
+ */
+static void __init parse_boot_params(void)
+{
+       ROOT_DEV = old_decode_dev(boot_params.hdr.root_dev);
+       screen_info = boot_params.screen_info;
+       edid_info = boot_params.edid_info;
+#ifdef CONFIG_X86_32
+       apm_info.bios = boot_params.apm_bios_info;
+       ist_info = boot_params.ist_info;
+#endif
+       saved_video_mode = boot_params.hdr.vid_mode;
+       bootloader_type = boot_params.hdr.type_of_loader;
+       if ((bootloader_type >> 4) == 0xe) {
+               bootloader_type &= 0xf;
+               bootloader_type |= (boot_params.hdr.ext_loader_type+0x10) << 4;
+       }
+       bootloader_version  = bootloader_type & 0xf;
+       bootloader_version |= boot_params.hdr.ext_loader_ver << 4;
+
+#ifdef CONFIG_BLK_DEV_RAM
+       rd_image_start = boot_params.hdr.ram_size & RAMDISK_IMAGE_START_MASK;
+#endif
+#ifdef CONFIG_EFI
+       if (!strncmp((char *)&boot_params.efi_info.efi_loader_signature,
+                    EFI32_LOADER_SIGNATURE, 4)) {
+               set_bit(EFI_BOOT, &efi.flags);
+       } else if (!strncmp((char *)&boot_params.efi_info.efi_loader_signature,
+                    EFI64_LOADER_SIGNATURE, 4)) {
+               set_bit(EFI_BOOT, &efi.flags);
+               set_bit(EFI_64BIT, &efi.flags);
+       }
+#endif
+
+       if (!boot_params.hdr.root_flags)
+               root_mountflags &= ~MS_RDONLY;
+}
+
 static void __init memblock_x86_reserve_range_setup_data(void)
 {
        struct setup_indirect *indirect;
@@ -806,35 +846,7 @@ void __init setup_arch(char **cmdline_p)
 
        setup_olpc_ofw_pgd();
 
-       ROOT_DEV = old_decode_dev(boot_params.hdr.root_dev);
-       screen_info = boot_params.screen_info;
-       edid_info = boot_params.edid_info;
-#ifdef CONFIG_X86_32
-       apm_info.bios = boot_params.apm_bios_info;
-       ist_info = boot_params.ist_info;
-#endif
-       saved_video_mode = boot_params.hdr.vid_mode;
-       bootloader_type = boot_params.hdr.type_of_loader;
-       if ((bootloader_type >> 4) == 0xe) {
-               bootloader_type &= 0xf;
-               bootloader_type |= (boot_params.hdr.ext_loader_type+0x10) << 4;
-       }
-       bootloader_version  = bootloader_type & 0xf;
-       bootloader_version |= boot_params.hdr.ext_loader_ver << 4;
-
-#ifdef CONFIG_BLK_DEV_RAM
-       rd_image_start = boot_params.hdr.ram_size & RAMDISK_IMAGE_START_MASK;
-#endif
-#ifdef CONFIG_EFI
-       if (!strncmp((char *)&boot_params.efi_info.efi_loader_signature,
-                    EFI32_LOADER_SIGNATURE, 4)) {
-               set_bit(EFI_BOOT, &efi.flags);
-       } else if (!strncmp((char *)&boot_params.efi_info.efi_loader_signature,
-                    EFI64_LOADER_SIGNATURE, 4)) {
-               set_bit(EFI_BOOT, &efi.flags);
-               set_bit(EFI_64BIT, &efi.flags);
-       }
-#endif
+       parse_boot_params();
 
        x86_init.oem.arch_setup();
 
@@ -858,8 +870,6 @@ void __init setup_arch(char **cmdline_p)
 
        copy_edd();
 
-       if (!boot_params.hdr.root_flags)
-               root_mountflags &= ~MS_RDONLY;
        setup_initial_init_mm(_text, _etext, _edata, (void *)_brk_end);
 
        /*