2 * prepare to run common code
4 * Copyright (C) 2000 Andrea Arcangeli <andrea@suse.de> SuSE
6 * Jun Nakajima <jun.nakajima@intel.com>
10 #include <linux/init.h>
11 #include <linux/linkage.h>
12 #include <linux/types.h>
13 #include <linux/kernel.h>
14 #include <linux/string.h>
15 #include <linux/percpu.h>
16 #include <linux/start_kernel.h>
18 #include <linux/memblock.h>
20 #include <asm/processor.h>
21 #include <asm/proto.h>
23 #include <asm/setup.h>
25 #include <asm/pgtable.h>
26 #include <asm/tlbflush.h>
27 #include <asm/sections.h>
28 #include <asm/kdebug.h>
30 #include <asm/trampoline.h>
31 #include <asm/bios_ebda.h>
34 static void __init zap_identity_mappings(void)
36 pgd_t *pgd = pgd_offset_k(0UL);
41 /* Don't add a printk in there. printk relies on the PDA which is not initialized
43 static void __init clear_bss(void)
45 memset(__bss_start, 0,
46 (unsigned long) __bss_stop - (unsigned long) __bss_start);
50 static void __init copy_bootdata(char *real_mode_data)
55 memcpy(&boot_params, real_mode_data, sizeof boot_params);
56 if (boot_params.hdr.cmd_line_ptr) {
57 command_line = __va(boot_params.hdr.cmd_line_ptr);
58 memcpy(boot_command_line, command_line, COMMAND_LINE_SIZE);
63 if ((max_cmdline = MAX_GUEST_CMDLINE) > COMMAND_LINE_SIZE)
64 max_cmdline = COMMAND_LINE_SIZE;
65 memcpy(boot_command_line, xen_start_info->cmd_line, max_cmdline);
66 boot_command_line[max_cmdline-1] = '\0';
70 #include <xen/interface/memory.h>
72 void __init x86_64_start_kernel(char * real_mode_data)
75 * Build-time sanity checks on the kernel image and module
76 * area mappings. (these are purely build-time and produce no code)
78 BUILD_BUG_ON(MODULES_VADDR < KERNEL_IMAGE_START);
79 BUILD_BUG_ON(MODULES_VADDR-KERNEL_IMAGE_START < KERNEL_IMAGE_SIZE);
80 BUILD_BUG_ON(MODULES_LEN + KERNEL_IMAGE_SIZE > 2*PUD_SIZE);
81 BUILD_BUG_ON((KERNEL_IMAGE_START & ~PMD_MASK) != 0);
82 BUILD_BUG_ON((MODULES_VADDR & ~PMD_MASK) != 0);
83 BUILD_BUG_ON(!(MODULES_VADDR > __START_KERNEL));
84 BUILD_BUG_ON(!(((MODULES_END - 1) & PGDIR_MASK) ==
85 (__START_KERNEL & PGDIR_MASK)));
86 BUILD_BUG_ON(__fix_to_virt(__end_of_fixed_addresses) <= MODULES_END);
88 xen_start_info = (struct start_info *)real_mode_data;
92 /* clear bss before set_intr_gate with early_idt_handler */
95 /* Make NULL pointers segfault */
96 zap_identity_mappings();
98 for (i = 0; i < NUM_EXCEPTION_VECTORS; i++) {
99 #ifdef CONFIG_EARLY_PRINTK
100 set_intr_gate(i, &early_idt_handlers[i]);
102 set_intr_gate(i, early_idt_handler);
105 load_idt((const struct desc_ptr *)&idt_descr);
108 if (console_loglevel == 10)
109 early_printk("Kernel alive\n");
113 x86_64_start_reservations(real_mode_data);
116 void __init x86_64_start_reservations(char *real_mode_data)
118 copy_bootdata(__va(real_mode_data));
120 memblock_reserve(__pa_symbol(&_text),
121 __pa_symbol(&__bss_stop) - __pa_symbol(&_text));
123 #ifdef CONFIG_BLK_DEV_INITRD
124 /* Reserve INITRD if needed. */
125 if (xen_start_info->flags & SIF_MOD_START_PFN) {
126 reserve_pfn_range(xen_start_info->mod_start,
127 PFN_UP(xen_start_info->mod_len));
128 xen_initrd_start = xen_start_info->mod_start << PAGE_SHIFT;
129 } else if (xen_start_info->mod_start)
130 xen_initrd_start = __pa(xen_start_info->mod_start);
133 if (xen_feature(XENFEAT_auto_translated_physmap))
134 xen_start_info->mfn_list = ~0UL;
135 else if (xen_start_info->mfn_list < __START_KERNEL_map)
136 reserve_pfn_range(xen_start_info->first_p2m_pfn,
137 xen_start_info->nr_p2m_frames);
140 * At this point everything still needed from the boot loader
141 * or BIOS or kernel text should be early reserved or marked not
142 * RAM in e820. All other memory is free game.