diff options
author | Thomas Gleixner <tglx@linutronix.de> | 2007-10-11 05:17:24 -0400 |
---|---|---|
committer | Thomas Gleixner <tglx@linutronix.de> | 2007-10-11 05:17:24 -0400 |
commit | 250c22777fe1ccd7ac588579a6c16db4c0161cc5 (patch) | |
tree | 55c317efb7d792ec6fdae1d1937c67a502c48dec /arch/x86/kernel/head64.c | |
parent | 2db55d344e529492545cb3b755c7e9ba8e4fa94e (diff) |
x86_64: move kernel
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'arch/x86/kernel/head64.c')
-rw-r--r-- | arch/x86/kernel/head64.c | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/arch/x86/kernel/head64.c b/arch/x86/kernel/head64.c new file mode 100644 index 000000000000..6c34bdd22e26 --- /dev/null +++ b/arch/x86/kernel/head64.c | |||
@@ -0,0 +1,86 @@ | |||
1 | /* | ||
2 | * linux/arch/x86_64/kernel/head64.c -- prepare to run common code | ||
3 | * | ||
4 | * Copyright (C) 2000 Andrea Arcangeli <andrea@suse.de> SuSE | ||
5 | */ | ||
6 | |||
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> | ||
13 | |||
14 | #include <asm/processor.h> | ||
15 | #include <asm/proto.h> | ||
16 | #include <asm/smp.h> | ||
17 | #include <asm/bootsetup.h> | ||
18 | #include <asm/setup.h> | ||
19 | #include <asm/desc.h> | ||
20 | #include <asm/pgtable.h> | ||
21 | #include <asm/tlbflush.h> | ||
22 | #include <asm/sections.h> | ||
23 | |||
24 | static void __init zap_identity_mappings(void) | ||
25 | { | ||
26 | pgd_t *pgd = pgd_offset_k(0UL); | ||
27 | pgd_clear(pgd); | ||
28 | __flush_tlb(); | ||
29 | } | ||
30 | |||
31 | /* Don't add a printk in there. printk relies on the PDA which is not initialized | ||
32 | yet. */ | ||
33 | static void __init clear_bss(void) | ||
34 | { | ||
35 | memset(__bss_start, 0, | ||
36 | (unsigned long) __bss_stop - (unsigned long) __bss_start); | ||
37 | } | ||
38 | |||
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 | ||
43 | |||
44 | static void __init copy_bootdata(char *real_mode_data) | ||
45 | { | ||
46 | unsigned long new_data; | ||
47 | char * command_line; | ||
48 | |||
49 | memcpy(x86_boot_params, real_mode_data, BOOT_PARAM_SIZE); | ||
50 | new_data = *(u32 *) (x86_boot_params + NEW_CL_POINTER); | ||
51 | if (!new_data) { | ||
52 | if (OLD_CL_MAGIC != *(u16 *)(real_mode_data + OLD_CL_MAGIC_ADDR)) { | ||
53 | return; | ||
54 | } | ||
55 | new_data = __pa(real_mode_data) + *(u16 *)(real_mode_data + OLD_CL_OFFSET); | ||
56 | } | ||
57 | command_line = __va(new_data); | ||
58 | memcpy(boot_command_line, command_line, COMMAND_LINE_SIZE); | ||
59 | } | ||
60 | |||
61 | void __init x86_64_start_kernel(char * real_mode_data) | ||
62 | { | ||
63 | int i; | ||
64 | |||
65 | /* clear bss before set_intr_gate with early_idt_handler */ | ||
66 | clear_bss(); | ||
67 | |||
68 | /* Make NULL pointers segfault */ | ||
69 | zap_identity_mappings(); | ||
70 | |||
71 | for (i = 0; i < IDT_ENTRIES; i++) | ||
72 | set_intr_gate(i, early_idt_handler); | ||
73 | asm volatile("lidt %0" :: "m" (idt_descr)); | ||
74 | |||
75 | early_printk("Kernel alive\n"); | ||
76 | |||
77 | for (i = 0; i < NR_CPUS; i++) | ||
78 | cpu_pda(i) = &boot_cpu_pda[i]; | ||
79 | |||
80 | pda_init(0); | ||
81 | copy_bootdata(__va(real_mode_data)); | ||
82 | #ifdef CONFIG_SMP | ||
83 | cpu_set(0, cpu_online_map); | ||
84 | #endif | ||
85 | start_kernel(); | ||
86 | } | ||