Skip to content

Commit d45dd0a

Browse files
rpptIngo Molnar
authored andcommitted
x86/boot: Split parsing of boot_params into the parse_boot_params() helper function
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
1 parent 297fb82 commit d45dd0a

File tree

1 file changed

+41
-31
lines changed

1 file changed

+41
-31
lines changed

arch/x86/kernel/setup.c

Lines changed: 41 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,46 @@ static void __init parse_setup_data(void)
429429
}
430430
}
431431

432+
/*
433+
* Translate the fields of 'struct boot_param' into global variables
434+
* representing these parameters.
435+
*/
436+
static void __init parse_boot_params(void)
437+
{
438+
ROOT_DEV = old_decode_dev(boot_params.hdr.root_dev);
439+
screen_info = boot_params.screen_info;
440+
edid_info = boot_params.edid_info;
441+
#ifdef CONFIG_X86_32
442+
apm_info.bios = boot_params.apm_bios_info;
443+
ist_info = boot_params.ist_info;
444+
#endif
445+
saved_video_mode = boot_params.hdr.vid_mode;
446+
bootloader_type = boot_params.hdr.type_of_loader;
447+
if ((bootloader_type >> 4) == 0xe) {
448+
bootloader_type &= 0xf;
449+
bootloader_type |= (boot_params.hdr.ext_loader_type+0x10) << 4;
450+
}
451+
bootloader_version = bootloader_type & 0xf;
452+
bootloader_version |= boot_params.hdr.ext_loader_ver << 4;
453+
454+
#ifdef CONFIG_BLK_DEV_RAM
455+
rd_image_start = boot_params.hdr.ram_size & RAMDISK_IMAGE_START_MASK;
456+
#endif
457+
#ifdef CONFIG_EFI
458+
if (!strncmp((char *)&boot_params.efi_info.efi_loader_signature,
459+
EFI32_LOADER_SIGNATURE, 4)) {
460+
set_bit(EFI_BOOT, &efi.flags);
461+
} else if (!strncmp((char *)&boot_params.efi_info.efi_loader_signature,
462+
EFI64_LOADER_SIGNATURE, 4)) {
463+
set_bit(EFI_BOOT, &efi.flags);
464+
set_bit(EFI_64BIT, &efi.flags);
465+
}
466+
#endif
467+
468+
if (!boot_params.hdr.root_flags)
469+
root_mountflags &= ~MS_RDONLY;
470+
}
471+
432472
static void __init memblock_x86_reserve_range_setup_data(void)
433473
{
434474
struct setup_indirect *indirect;
@@ -806,35 +846,7 @@ void __init setup_arch(char **cmdline_p)
806846

807847
setup_olpc_ofw_pgd();
808848

809-
ROOT_DEV = old_decode_dev(boot_params.hdr.root_dev);
810-
screen_info = boot_params.screen_info;
811-
edid_info = boot_params.edid_info;
812-
#ifdef CONFIG_X86_32
813-
apm_info.bios = boot_params.apm_bios_info;
814-
ist_info = boot_params.ist_info;
815-
#endif
816-
saved_video_mode = boot_params.hdr.vid_mode;
817-
bootloader_type = boot_params.hdr.type_of_loader;
818-
if ((bootloader_type >> 4) == 0xe) {
819-
bootloader_type &= 0xf;
820-
bootloader_type |= (boot_params.hdr.ext_loader_type+0x10) << 4;
821-
}
822-
bootloader_version = bootloader_type & 0xf;
823-
bootloader_version |= boot_params.hdr.ext_loader_ver << 4;
824-
825-
#ifdef CONFIG_BLK_DEV_RAM
826-
rd_image_start = boot_params.hdr.ram_size & RAMDISK_IMAGE_START_MASK;
827-
#endif
828-
#ifdef CONFIG_EFI
829-
if (!strncmp((char *)&boot_params.efi_info.efi_loader_signature,
830-
EFI32_LOADER_SIGNATURE, 4)) {
831-
set_bit(EFI_BOOT, &efi.flags);
832-
} else if (!strncmp((char *)&boot_params.efi_info.efi_loader_signature,
833-
EFI64_LOADER_SIGNATURE, 4)) {
834-
set_bit(EFI_BOOT, &efi.flags);
835-
set_bit(EFI_64BIT, &efi.flags);
836-
}
837-
#endif
849+
parse_boot_params();
838850

839851
x86_init.oem.arch_setup();
840852

@@ -858,8 +870,6 @@ void __init setup_arch(char **cmdline_p)
858870

859871
copy_edd();
860872

861-
if (!boot_params.hdr.root_flags)
862-
root_mountflags &= ~MS_RDONLY;
863873
setup_initial_init_mm(_text, _etext, _edata, (void *)_brk_end);
864874

865875
/*

0 commit comments

Comments
 (0)