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)
65 /* clear bss before set_intr_gate with early_idt_handler */
68 /* Make NULL pointers segfault */
69 zap_identity_mappings();
71 for (i = 0; i < IDT_ENTRIES; i++)
72 set_intr_gate(i, early_idt_handler);
73 asm volatile("lidt %0" :: "m" (idt_descr));
75 early_printk("Kernel alive\n");
77 for (i = 0; i < NR_CPUS; i++)
78 cpu_pda(i) = &boot_cpu_pda[i];
81 copy_bootdata(__va(real_mode_data));
83 cpu_set(0, cpu_online_map);