sync hh.org
[hh.org.git] / arch / x86_64 / kernel / head64.c
blob9561eb3c5b5c5e78eed93277096eaf9d68752a64
1 /*
2 * linux/arch/x86_64/kernel/head64.c -- prepare to run common code
4 * Copyright (C) 2000 Andrea Arcangeli <andrea@suse.de> SuSE
5 */
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>
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/sections.h>
23 /* Don't add a printk in there. printk relies on the PDA which is not initialized
24 yet. */
25 static void __init clear_bss(void)
27 memset(__bss_start, 0,
28 (unsigned long) __bss_stop - (unsigned long) __bss_start);
31 #define NEW_CL_POINTER 0x228 /* Relative to real mode data */
32 #define OLD_CL_MAGIC_ADDR 0x90020
33 #define OLD_CL_MAGIC 0xA33F
34 #define OLD_CL_BASE_ADDR 0x90000
35 #define OLD_CL_OFFSET 0x90022
37 extern char saved_command_line[];
39 static void __init copy_bootdata(char *real_mode_data)
41 int new_data;
42 char * command_line;
44 memcpy(x86_boot_params, real_mode_data, BOOT_PARAM_SIZE);
45 new_data = *(int *) (x86_boot_params + NEW_CL_POINTER);
46 if (!new_data) {
47 if (OLD_CL_MAGIC != * (u16 *) OLD_CL_MAGIC_ADDR) {
48 return;
50 new_data = OLD_CL_BASE_ADDR + * (u16 *) OLD_CL_OFFSET;
52 command_line = (char *) ((u64)(new_data));
53 memcpy(saved_command_line, command_line, COMMAND_LINE_SIZE);
56 void __init x86_64_start_kernel(char * real_mode_data)
58 int i;
60 for (i = 0; i < 256; i++)
61 set_intr_gate(i, early_idt_handler);
62 asm volatile("lidt %0" :: "m" (idt_descr));
63 clear_bss();
65 early_printk("Kernel alive\n");
68 * switch to init_level4_pgt from boot_level4_pgt
70 memcpy(init_level4_pgt, boot_level4_pgt, PTRS_PER_PGD*sizeof(pgd_t));
71 asm volatile("movq %0,%%cr3" :: "r" (__pa_symbol(&init_level4_pgt)));
73 for (i = 0; i < NR_CPUS; i++)
74 cpu_pda(i) = &boot_cpu_pda[i];
76 pda_init(0);
77 copy_bootdata(real_mode_data);
78 #ifdef CONFIG_SMP
79 cpu_set(0, cpu_online_map);
80 #endif
81 start_kernel();