VServer 1.9.2 (patch-2.6.8.1-vs1.9.2.diff)
[linux-2.6.git] / arch / 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
9 #include <linux/init.h>
10 #include <linux/linkage.h>
11 #include <linux/types.h>
12 #include <linux/kernel.h>
13 #include <linux/string.h>
14
15 #include <asm/processor.h>
16 #include <asm/proto.h>
17 #include <asm/smp.h>
18 #include <asm/bootsetup.h>
19 #include <asm/setup.h>
20
21 /* Don't add a printk in there. printk relies on the PDA which is not initialized 
22    yet. */
23 static void __init clear_bss(void)
24 {
25         extern char __bss_start[], __bss_end[];
26         memset(__bss_start, 0,
27                (unsigned long) __bss_end - (unsigned long) __bss_start);
28 }
29
30 extern char x86_boot_params[2048];
31
32 #define NEW_CL_POINTER          0x228   /* Relative to real mode data */
33 #define OLD_CL_MAGIC_ADDR       0x90020
34 #define OLD_CL_MAGIC            0xA33F
35 #define OLD_CL_BASE_ADDR        0x90000
36 #define OLD_CL_OFFSET           0x90022
37
38 extern char saved_command_line[];
39
40 static void __init copy_bootdata(char *real_mode_data)
41 {
42         int new_data;
43         char * command_line;
44
45         memcpy(x86_boot_params, real_mode_data, 2048); 
46         new_data = *(int *) (x86_boot_params + NEW_CL_POINTER);
47         if (!new_data) {
48                 if (OLD_CL_MAGIC != * (u16 *) OLD_CL_MAGIC_ADDR) {
49                         printk("so old bootloader that it does not support commandline?!\n");
50                         return;
51                 }
52                 new_data = OLD_CL_BASE_ADDR + * (u16 *) OLD_CL_OFFSET;
53                 printk("old bootloader convention, maybe loadlin?\n");
54         }
55         command_line = (char *) ((u64)(new_data));
56         memcpy(saved_command_line, command_line, COMMAND_LINE_SIZE);
57         printk("Bootdata ok (command line is %s)\n", saved_command_line);       
58 }
59
60 static void __init setup_boot_cpu_data(void)
61 {
62         int dummy, eax;
63
64         /* get vendor info */
65         cpuid(0, &boot_cpu_data.cpuid_level,
66               (int *)&boot_cpu_data.x86_vendor_id[0],
67               (int *)&boot_cpu_data.x86_vendor_id[8],
68               (int *)&boot_cpu_data.x86_vendor_id[4]);
69
70         /* get cpu type */
71         cpuid(1, &eax, &dummy, &dummy, (int *) &boot_cpu_data.x86_capability);
72         boot_cpu_data.x86 = (eax >> 8) & 0xf;
73         boot_cpu_data.x86_model = (eax >> 4) & 0xf;
74         boot_cpu_data.x86_mask = eax & 0xf;
75 }
76
77 extern char _end[];
78
79 void __init x86_64_start_kernel(char * real_mode_data)
80 {
81         char *s;
82
83         clear_bss();
84         pda_init(0);
85         copy_bootdata(real_mode_data);
86 #ifdef CONFIG_SMP
87         cpu_set(0, cpu_online_map);
88 #endif
89         /* default console: */
90         if (!strstr(saved_command_line, "console="))
91                 strcat(saved_command_line, " console=tty0"); 
92         s = strstr(saved_command_line, "earlyprintk=");
93         if (s != NULL)
94                 setup_early_printk(s);
95 #ifdef CONFIG_DISCONTIGMEM
96         s = strstr(saved_command_line, "numa=");
97         if (s != NULL)
98                 numa_setup(s+5);
99 #endif
100 #ifdef CONFIG_X86_IO_APIC
101         if (strstr(saved_command_line, "disableapic"))
102                 disable_apic = 1;
103 #endif
104         /* You need early console to see that */
105         if (__pa_symbol(&_end) >= KERNEL_TEXT_SIZE)
106                 panic("Kernel too big for kernel mapping\n");
107
108         setup_boot_cpu_data();
109         start_kernel();
110 }