Fedora Core 2 Updates 2.6.10-1.771_FC2
[linux-2.6.git] / arch / xen / x86_64 / kernel / head64.c
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  *  $Id: head64.c,v 1.22 2001/07/06 14:28:20 ak Exp $
7  *
8  *  Jun Nakajima <jun.nakajima@intel.com>
9  *      Modified for Xen.
10  */
11
12 #include <linux/init.h>
13 #include <linux/linkage.h>
14 #include <linux/types.h>
15 #include <linux/kernel.h>
16 #include <linux/string.h>
17 #include <linux/percpu.h>
18
19 #include <asm/processor.h>
20 #include <asm/proto.h>
21 #include <asm/smp.h>
22 #include <asm/bootsetup.h>
23 #include <asm/setup.h>
24 #include <asm/desc.h>
25
26 unsigned long start_pfn;
27
28 /* Don't add a printk in there. printk relies on the PDA which is not initialized 
29    yet. */
30 #if 0
31 static void __init clear_bss(void)
32 {
33         extern char __bss_start[], __bss_end[];
34         memset(__bss_start, 0,
35                (unsigned long) __bss_end - (unsigned long) __bss_start);
36 }
37 #endif
38
39 extern char x86_boot_params[2048];
40
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
46
47 extern char saved_command_line[];
48
49 #if 0
50 static void __init copy_bootdata(char *real_mode_data)
51 {
52         int new_data;
53         char * command_line;
54
55         memcpy(x86_boot_params, real_mode_data, 2048); 
56         new_data = *(int *) (x86_boot_params + NEW_CL_POINTER);
57         if (!new_data) {
58                 if (OLD_CL_MAGIC != * (u16 *) OLD_CL_MAGIC_ADDR) {
59                         printk("so old bootloader that it does not support commandline?!\n");
60                         return;
61                 }
62                 new_data = OLD_CL_BASE_ADDR + * (u16 *) OLD_CL_OFFSET;
63                 printk("old bootloader convention, maybe loadlin?\n");
64         }
65         command_line = (char *) ((u64)(new_data));
66         memcpy(saved_command_line, command_line, COMMAND_LINE_SIZE);
67         printk("Bootdata ok (command line is %s)\n", saved_command_line);       
68 }
69 #endif
70
71 static void __init setup_boot_cpu_data(void)
72 {
73         int dummy, eax;
74
75         /* get vendor info */
76         cpuid(0, &boot_cpu_data.cpuid_level,
77               (int *)&boot_cpu_data.x86_vendor_id[0],
78               (int *)&boot_cpu_data.x86_vendor_id[8],
79               (int *)&boot_cpu_data.x86_vendor_id[4]);
80
81         /* get cpu type */
82         cpuid(1, &eax, &dummy, &dummy,
83                 (unsigned int *) &boot_cpu_data.x86_capability);
84         boot_cpu_data.x86 = (eax >> 8) & 0xf;
85         boot_cpu_data.x86_model = (eax >> 4) & 0xf;
86         boot_cpu_data.x86_mask = eax & 0xf;
87 }
88
89 extern char _end[];
90
91 void __init x86_64_start_kernel(char * real_mode_data)
92 {
93         int i;
94
95         phys_to_machine_mapping = (u32 *)xen_start_info.mfn_list;
96         start_pfn = (__pa(xen_start_info.pt_base) >> PAGE_SHIFT) +  xen_start_info.nr_pt_frames;
97
98         for (i = 0; i < 256; i++)
99                 set_intr_gate(i, early_idt_handler);
100 #if 0
101         asm volatile("lidt %0" :: "m" (idt_descr));
102 #endif
103         pda_init(0);
104         /*      copy_bootdata(real_mode_data); */
105 #ifdef CONFIG_SMP
106         cpu_set(0, cpu_online_map);
107 #endif
108         /* default console: */
109         if (!strstr(saved_command_line, "console="))
110                 strcat(saved_command_line, " console=tty0"); 
111 #if 0
112         s = strstr(saved_command_line, "earlyprintk=");
113         if (s != NULL)
114                 setup_early_printk(s);
115 #endif
116
117 #ifdef CONFIG_DISCONTIGMEM
118         s = strstr(saved_command_line, "numa=");
119         if (s != NULL)
120                 numa_setup(s+5);
121 #endif
122 #ifdef CONFIG_X86_IO_APIC
123         if (strstr(saved_command_line, "disableapic"))
124                 disable_apic = 1;
125 #endif
126         /* You need early console to see that */
127         if (__pa_symbol(&_end) >= KERNEL_TEXT_SIZE)
128                 panic("Kernel too big for kernel mapping\n");
129
130         setup_boot_cpu_data();
131         start_kernel();
132 }