patch-2_6_7-vs1_9_1_12
[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
20 /* Don't add a printk in there. printk relies on the PDA which is not initialized 
21    yet. */
22 static void __init clear_bss(void)
23 {
24         extern char __bss_start[], __bss_end[];
25         memset(__bss_start, 0,
26                (unsigned long) __bss_end - (unsigned long) __bss_start);
27 }
28
29 extern char x86_boot_params[2048];
30
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
36
37 extern char saved_command_line[];
38
39 static void __init copy_bootdata(char *real_mode_data)
40 {
41         int new_data;
42         char * command_line;
43
44         memcpy(x86_boot_params, real_mode_data, 2048); 
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                         printk("so old bootloader that it does not support commandline?!\n");
49                         return;
50                 }
51                 new_data = OLD_CL_BASE_ADDR + * (u16 *) OLD_CL_OFFSET;
52                 printk("old bootloader convention, maybe loadlin?\n");
53         }
54         command_line = (char *) ((u64)(new_data));
55         memcpy(saved_command_line, command_line, COMMAND_LINE_SIZE);
56         printk("Bootdata ok (command line is %s)\n", saved_command_line);       
57 }
58
59 static void __init setup_boot_cpu_data(void)
60 {
61         int dummy, eax;
62
63         /* get vendor info */
64         cpuid(0, &boot_cpu_data.cpuid_level,
65               (int *)&boot_cpu_data.x86_vendor_id[0],
66               (int *)&boot_cpu_data.x86_vendor_id[8],
67               (int *)&boot_cpu_data.x86_vendor_id[4]);
68
69         /* get cpu type */
70         cpuid(1, &eax, &dummy, &dummy, (int *) &boot_cpu_data.x86_capability);
71         boot_cpu_data.x86 = (eax >> 8) & 0xf;
72         boot_cpu_data.x86_model = (eax >> 4) & 0xf;
73         boot_cpu_data.x86_mask = eax & 0xf;
74 }
75
76 extern char _end[];
77
78 void __init x86_64_start_kernel(char * real_mode_data)
79 {
80         char *s;
81
82         clear_bss();
83         pda_init(0);
84         copy_bootdata(real_mode_data);
85 #ifdef CONFIG_SMP
86         cpu_set(0, cpu_online_map);
87 #endif
88         /* default console: */
89         if (!strstr(saved_command_line, "console="))
90                 strcat(saved_command_line, " console=tty0"); 
91         s = strstr(saved_command_line, "earlyprintk=");
92         if (s != NULL)
93                 setup_early_printk(s);
94 #ifdef CONFIG_DISCONTIGMEM
95         s = strstr(saved_command_line, "numa=");
96         if (s != NULL)
97                 numa_setup(s+5);
98 #endif
99 #ifdef CONFIG_X86_IO_APIC
100         if (strstr(saved_command_line, "disableapic"))
101                 disable_apic = 1;
102 #endif
103         /* You need early console to see that */
104         if (__pa_symbol(&_end) >= KERNEL_TEXT_SIZE)
105                 panic("Kernel too big for kernel mapping\n");
106
107         setup_boot_cpu_data();
108         start_kernel();
109 }