xref: /openbmc/linux/arch/x86/kernel/head32.c (revision 72d7c3b3)
1700efc1bSEric W. Biederman /*
2700efc1bSEric W. Biederman  *  linux/arch/i386/kernel/head32.c -- prepare to run common code
3700efc1bSEric W. Biederman  *
4700efc1bSEric W. Biederman  *  Copyright (C) 2000 Andrea Arcangeli <andrea@suse.de> SuSE
5700efc1bSEric W. Biederman  *  Copyright (C) 2007 Eric Biederman <ebiederm@xmission.com>
6700efc1bSEric W. Biederman  */
7700efc1bSEric W. Biederman 
8700efc1bSEric W. Biederman #include <linux/init.h>
9700efc1bSEric W. Biederman #include <linux/start_kernel.h>
10c967da6aSYinghai Lu #include <linux/mm.h>
1172d7c3b3SYinghai Lu #include <linux/memblock.h>
12700efc1bSEric W. Biederman 
13a4c81cf6SYinghai Lu #include <asm/setup.h>
14a4c81cf6SYinghai Lu #include <asm/sections.h>
15a4c81cf6SYinghai Lu #include <asm/e820.h>
16816c25e7SThomas Gleixner #include <asm/page.h>
173e1e9002SRafael J. Wysocki #include <asm/trampoline.h>
18de934103SThomas Gleixner #include <asm/apic.h>
19de934103SThomas Gleixner #include <asm/io_apic.h>
2047a3d5daSThomas Gleixner #include <asm/bios_ebda.h>
2147a3d5daSThomas Gleixner 
2247a3d5daSThomas Gleixner static void __init i386_default_early_setup(void)
2347a3d5daSThomas Gleixner {
2447a3d5daSThomas Gleixner 	/* Initilize 32bit specific setup functions */
2547a3d5daSThomas Gleixner 	x86_init.resources.probe_roms = probe_roms;
2647a3d5daSThomas Gleixner 	x86_init.resources.reserve_resources = i386_reserve_resources;
2747a3d5daSThomas Gleixner 	x86_init.mpparse.setup_ioapic_ids = setup_ioapic_ids_from_mpc;
2847a3d5daSThomas Gleixner 
2947a3d5daSThomas Gleixner 	reserve_ebda_region();
3047a3d5daSThomas Gleixner }
31a4c81cf6SYinghai Lu 
32700efc1bSEric W. Biederman void __init i386_start_kernel(void)
33700efc1bSEric W. Biederman {
3472d7c3b3SYinghai Lu 	memblock_init();
3572d7c3b3SYinghai Lu 
36db8f77c8SYinghai Lu #ifdef CONFIG_X86_TRAMPOLINE
37db8f77c8SYinghai Lu 	/*
38db8f77c8SYinghai Lu 	 * But first pinch a few for the stack/trampoline stuff
39db8f77c8SYinghai Lu 	 * FIXME: Don't need the extra page at 4K, but need to fix
40db8f77c8SYinghai Lu 	 * trampoline before removing it. (see the GDT stuff)
41db8f77c8SYinghai Lu 	 */
4272d7c3b3SYinghai Lu 	memblock_x86_reserve_range(PAGE_SIZE, PAGE_SIZE + PAGE_SIZE, "EX TRAMPOLINE");
43db8f77c8SYinghai Lu #endif
44db8f77c8SYinghai Lu 
4593dbda7cSJeremy Fitzhardinge 	reserve_early(__pa_symbol(&_text), __pa_symbol(&__bss_stop), "TEXT DATA BSS");
46a4c81cf6SYinghai Lu 
47a4c81cf6SYinghai Lu #ifdef CONFIG_BLK_DEV_INITRD
48a4c81cf6SYinghai Lu 	/* Reserve INITRD */
49a4c81cf6SYinghai Lu 	if (boot_params.hdr.type_of_loader && boot_params.hdr.ramdisk_image) {
50c967da6aSYinghai Lu 		/* Assume only end is not page aligned */
51a4c81cf6SYinghai Lu 		u64 ramdisk_image = boot_params.hdr.ramdisk_image;
52a4c81cf6SYinghai Lu 		u64 ramdisk_size  = boot_params.hdr.ramdisk_size;
53c967da6aSYinghai Lu 		u64 ramdisk_end   = PAGE_ALIGN(ramdisk_image + ramdisk_size);
54a4c81cf6SYinghai Lu 		reserve_early(ramdisk_image, ramdisk_end, "RAMDISK");
55a4c81cf6SYinghai Lu 	}
56a4c81cf6SYinghai Lu #endif
57f7cf5a5bSThomas Gleixner 
5847a3d5daSThomas Gleixner 	/* Call the subarch specific early setup function */
5947a3d5daSThomas Gleixner 	switch (boot_params.hdr.hardware_subarch) {
603f4110a4SThomas Gleixner 	case X86_SUBARCH_MRST:
613f4110a4SThomas Gleixner 		x86_mrst_early_setup();
623f4110a4SThomas Gleixner 		break;
6347a3d5daSThomas Gleixner 	default:
6447a3d5daSThomas Gleixner 		i386_default_early_setup();
6547a3d5daSThomas Gleixner 		break;
6647a3d5daSThomas Gleixner 	}
67a4c81cf6SYinghai Lu 
68a4c81cf6SYinghai Lu 	/*
69a4c81cf6SYinghai Lu 	 * At this point everything still needed from the boot loader
70a4c81cf6SYinghai Lu 	 * or BIOS or kernel text should be early reserved or marked not
71a4c81cf6SYinghai Lu 	 * RAM in e820. All other memory is free game.
72a4c81cf6SYinghai Lu 	 */
73a4c81cf6SYinghai Lu 
74700efc1bSEric W. Biederman 	start_kernel();
75700efc1bSEric W. Biederman }
76