Update to 3.4-final.
[linux-flexiantxendom0-3.2.10.git] / arch / x86 / kernel / head32-xen.c
1 /*
2  *  linux/arch/i386/kernel/head32.c -- prepare to run common code
3  *
4  *  Copyright (C) 2000 Andrea Arcangeli <andrea@suse.de> SuSE
5  *  Copyright (C) 2007 Eric Biederman <ebiederm@xmission.com>
6  */
7
8 #include <linux/init.h>
9 #include <linux/start_kernel.h>
10 #include <linux/mm.h>
11 #include <linux/memblock.h>
12
13 #include <asm/setup.h>
14 #include <asm/sections.h>
15 #include <asm/e820.h>
16 #include <asm/trampoline.h>
17 #include <asm/apic.h>
18 #include <asm/io_apic.h>
19 #include <asm/tlbflush.h>
20
21 static void __init i386_default_early_setup(void)
22 {
23         /* Initialize 32bit specific setup functions */
24         x86_init.resources.reserve_resources = i386_reserve_resources;
25 #ifndef CONFIG_XEN
26         x86_init.mpparse.setup_ioapic_ids = setup_ioapic_ids_from_mpc;
27
28         reserve_ebda_region();
29 #endif
30 }
31
32 void __init i386_start_kernel(void)
33 {
34 #ifdef CONFIG_XEN
35         struct xen_platform_parameters pp;
36
37         WARN_ON(HYPERVISOR_vm_assist(VMASST_CMD_enable,
38                                      VMASST_TYPE_4gb_segments));
39
40         init_mm.pgd = swapper_pg_dir = (pgd_t *)xen_start_info->pt_base;
41
42         if (HYPERVISOR_xen_version(XENVER_platform_parameters, &pp) == 0) {
43                 hypervisor_virt_start = pp.virt_start;
44                 reserve_top_address(0UL - pp.virt_start);
45         }
46
47         BUG_ON(pte_index(hypervisor_virt_start));
48 #endif
49
50         memblock_reserve(__pa_symbol(&_text),
51                          __pa_symbol(&__bss_stop) - __pa_symbol(&_text));
52
53 #ifndef CONFIG_XEN
54 #ifdef CONFIG_BLK_DEV_INITRD
55         /* Reserve INITRD */
56         if (boot_params.hdr.type_of_loader && boot_params.hdr.ramdisk_image) {
57                 /* Assume only end is not page aligned */
58                 u64 ramdisk_image = boot_params.hdr.ramdisk_image;
59                 u64 ramdisk_size  = boot_params.hdr.ramdisk_size;
60                 u64 ramdisk_end   = PAGE_ALIGN(ramdisk_image + ramdisk_size);
61                 memblock_reserve(ramdisk_image, ramdisk_end - ramdisk_image);
62         }
63 #endif
64
65         /* Call the subarch specific early setup function */
66         switch (boot_params.hdr.hardware_subarch) {
67         case X86_SUBARCH_MRST:
68                 x86_mrst_early_setup();
69                 break;
70         case X86_SUBARCH_CE4100:
71                 x86_ce4100_early_setup();
72                 break;
73         default:
74                 i386_default_early_setup();
75                 break;
76         }
77 #else
78 #ifdef CONFIG_BLK_DEV_INITRD
79         BUG_ON(xen_start_info->flags & SIF_MOD_START_PFN);
80         if (xen_start_info->mod_start)
81                 xen_initrd_start = __pa(xen_start_info->mod_start);
82 #endif
83         {
84                 int max_cmdline;
85
86                 if ((max_cmdline = MAX_GUEST_CMDLINE) > COMMAND_LINE_SIZE)
87                         max_cmdline = COMMAND_LINE_SIZE;
88                 memcpy(boot_command_line, xen_start_info->cmd_line, max_cmdline);
89                 boot_command_line[max_cmdline-1] = '\0';
90         }
91
92         i386_default_early_setup();
93         xen_start_kernel();
94 #endif
95
96         /*
97          * At this point everything still needed from the boot loader
98          * or BIOS or kernel text should be early reserved or marked not
99          * RAM in e820. All other memory is free game.
100          */
101
102         start_kernel();
103 }