2 * linux/arch/x86_64/kernel/head64.c -- 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/module.h>
18 #include <asm/processor.h>
19 #include <asm/proto.h>
21 #include <asm/bootsetup.h>
22 #include <asm/setup.h>
24 #include <asm/pgtable.h>
25 #include <asm/sections.h>
28 unsigned long start_pfn;
31 /* Don't add a printk in there. printk relies on the PDA which is not initialized
34 static void __init clear_bss(void)
36 memset(__bss_start, 0,
37 (unsigned long) __bss_stop - (unsigned long) __bss_start);
41 #define NEW_CL_POINTER 0x228 /* Relative to real mode data */
42 #define OLD_CL_MAGIC_ADDR 0x90020
43 #define OLD_CL_MAGIC 0xA33F
44 #define OLD_CL_BASE_ADDR 0x90000
45 #define OLD_CL_OFFSET 0x90022
47 extern char saved_command_line[];
49 static void __init copy_bootdata(char *real_mode_data)
55 memcpy(x86_boot_params, real_mode_data, BOOT_PARAM_SIZE);
56 new_data = *(int *) (x86_boot_params + NEW_CL_POINTER);
58 if (OLD_CL_MAGIC != * (u16 *) OLD_CL_MAGIC_ADDR) {
61 new_data = OLD_CL_BASE_ADDR + * (u16 *) OLD_CL_OFFSET;
63 command_line = (char *) ((u64)(new_data));
64 memcpy(saved_command_line, command_line, COMMAND_LINE_SIZE);
68 if ((max_cmdline = MAX_GUEST_CMDLINE) > COMMAND_LINE_SIZE)
69 max_cmdline = COMMAND_LINE_SIZE;
70 memcpy(saved_command_line, xen_start_info->cmd_line, max_cmdline);
71 saved_command_line[max_cmdline-1] = '\0';
76 #include <xen/interface/memory.h>
77 unsigned long *machine_to_phys_mapping;
78 EXPORT_SYMBOL(machine_to_phys_mapping);
79 unsigned int machine_to_phys_order;
80 EXPORT_SYMBOL(machine_to_phys_order);
83 void __init x86_64_start_kernel(char * real_mode_data)
86 struct xen_machphys_mapping mapping;
87 unsigned long machine_to_phys_nr_ents;
92 xen_start_info = (struct start_info *)real_mode_data;
93 if (!xen_feature(XENFEAT_auto_translated_physmap)) {
94 phys_to_machine_mapping =
95 (unsigned long *)xen_start_info->mfn_list;
96 start_pfn = (__pa(xen_start_info->pt_base) >> PAGE_SHIFT) +
97 xen_start_info->nr_pt_frames;
100 machine_to_phys_mapping = (unsigned long *)MACH2PHYS_VIRT_START;
101 machine_to_phys_nr_ents = MACH2PHYS_NR_ENTRIES;
102 if (HYPERVISOR_memory_op(XENMEM_machphys_mapping, &mapping) == 0) {
103 machine_to_phys_mapping = (unsigned long *)mapping.v_start;
104 machine_to_phys_nr_ents = mapping.max_mfn + 1;
106 while ((1UL << machine_to_phys_order) < machine_to_phys_nr_ents )
107 machine_to_phys_order++;
110 /* clear bss before set_intr_gate with early_idt_handler */
113 for (i = 0; i < IDT_ENTRIES; i++)
114 set_intr_gate(i, early_idt_handler);
115 asm volatile("lidt %0" :: "m" (idt_descr));
116 #endif /* CONFIG_XEN */
117 early_printk("Kernel alive\n");
121 * switch to init_level4_pgt from boot_level4_pgt
123 memcpy(init_level4_pgt, boot_level4_pgt, PTRS_PER_PGD*sizeof(pgd_t));
124 asm volatile("movq %0,%%cr3" :: "r" (__pa_symbol(&init_level4_pgt)));
127 for (i = 0; i < NR_CPUS; i++)
128 cpu_pda(i) = &boot_cpu_pda[i];
131 copy_bootdata(real_mode_data);
133 cpu_set(0, cpu_online_map);