2 * linux/arch/x86_64/kernel/head64.c -- prepare to run common code
4 * Copyright (C) 2000 Andrea Arcangeli <andrea@suse.de> SuSE
7 #include <linux/init.h>
8 #include <linux/linkage.h>
9 #include <linux/types.h>
10 #include <linux/kernel.h>
11 #include <linux/string.h>
12 #include <linux/percpu.h>
14 #include <asm/processor.h>
15 #include <asm/proto.h>
17 #include <asm/bootsetup.h>
18 #include <asm/setup.h>
20 #include <asm/pgtable.h>
21 #include <asm/tlbflush.h>
22 #include <asm/sections.h>
24 static void __init zap_identity_mappings(void)
26 pgd_t *pgd = pgd_offset_k(0UL);
31 /* Don't add a printk in there. printk relies on the PDA which is not initialized
33 static void __init clear_bss(void)
35 memset(__bss_start, 0,
36 (unsigned long) __bss_stop - (unsigned long) __bss_start);
39 #define NEW_CL_POINTER 0x228 /* Relative to real mode data */
40 #define OLD_CL_MAGIC_ADDR 0x20
41 #define OLD_CL_MAGIC 0xA33F
42 #define OLD_CL_OFFSET 0x22
44 static void __init copy_bootdata(char *real_mode_data)
46 unsigned long new_data;
49 memcpy(x86_boot_params, real_mode_data, BOOT_PARAM_SIZE);
50 new_data = *(u32 *) (x86_boot_params + NEW_CL_POINTER);
52 if (OLD_CL_MAGIC != *(u16 *)(real_mode_data + OLD_CL_MAGIC_ADDR)) {
55 new_data = __pa(real_mode_data) + *(u16 *)(real_mode_data + OLD_CL_OFFSET);
57 command_line = __va(new_data);
58 memcpy(boot_command_line, command_line, COMMAND_LINE_SIZE);
61 void __init x86_64_start_kernel(char * real_mode_data)
66 * Make sure kernel is aligned to 2MB address. Catching it at compile
67 * time is better. Change your config file and compile the kernel
68 * for a 2MB aligned address (CONFIG_PHYSICAL_START)
70 BUILD_BUG_ON(CONFIG_PHYSICAL_START & (__KERNEL_ALIGN - 1));
72 /* clear bss before set_intr_gate with early_idt_handler */
75 /* Make NULL pointers segfault */
76 zap_identity_mappings();
78 for (i = 0; i < IDT_ENTRIES; i++)
79 set_intr_gate(i, early_idt_handler);
80 asm volatile("lidt %0" :: "m" (idt_descr));
82 early_printk("Kernel alive\n");
84 for (i = 0; i < NR_CPUS; i++)
85 cpu_pda(i) = &boot_cpu_pda[i];
88 copy_bootdata(__va(real_mode_data));
90 cpu_set(0, cpu_online_map);