aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86_64/kernel/head64.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
commit1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch)
tree0bba044c4ce775e45a88a51686b5d9f90697ea9d /arch/x86_64/kernel/head64.c
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history, even though we have it. We can create a separate "historical" git archive of that later if we want to, and in the meantime it's about 3.2GB when imported into git - space that would just make the early git days unnecessarily complicated, when we don't have a lot of good infrastructure for it. Let it rip!
Diffstat (limited to 'arch/x86_64/kernel/head64.c')
-rw-r--r--arch/x86_64/kernel/head64.c117
1 files changed, 117 insertions, 0 deletions
diff --git a/arch/x86_64/kernel/head64.c b/arch/x86_64/kernel/head64.c
new file mode 100644
index 000000000000..6cad46c98a23
--- /dev/null
+++ b/arch/x86_64/kernel/head64.c
@@ -0,0 +1,117 @@
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#include <linux/percpu.h>
15
16#include <asm/processor.h>
17#include <asm/proto.h>
18#include <asm/smp.h>
19#include <asm/bootsetup.h>
20#include <asm/setup.h>
21#include <asm/desc.h>
22
23/* Don't add a printk in there. printk relies on the PDA which is not initialized
24 yet. */
25static void __init clear_bss(void)
26{
27 extern char __bss_start[], __bss_end[];
28 memset(__bss_start, 0,
29 (unsigned long) __bss_end - (unsigned long) __bss_start);
30}
31
32extern char x86_boot_params[2048];
33
34#define NEW_CL_POINTER 0x228 /* Relative to real mode data */
35#define OLD_CL_MAGIC_ADDR 0x90020
36#define OLD_CL_MAGIC 0xA33F
37#define OLD_CL_BASE_ADDR 0x90000
38#define OLD_CL_OFFSET 0x90022
39
40extern char saved_command_line[];
41
42static void __init copy_bootdata(char *real_mode_data)
43{
44 int new_data;
45 char * command_line;
46
47 memcpy(x86_boot_params, real_mode_data, 2048);
48 new_data = *(int *) (x86_boot_params + NEW_CL_POINTER);
49 if (!new_data) {
50 if (OLD_CL_MAGIC != * (u16 *) OLD_CL_MAGIC_ADDR) {
51 printk("so old bootloader that it does not support commandline?!\n");
52 return;
53 }
54 new_data = OLD_CL_BASE_ADDR + * (u16 *) OLD_CL_OFFSET;
55 printk("old bootloader convention, maybe loadlin?\n");
56 }
57 command_line = (char *) ((u64)(new_data));
58 memcpy(saved_command_line, command_line, COMMAND_LINE_SIZE);
59 printk("Bootdata ok (command line is %s)\n", saved_command_line);
60}
61
62static void __init setup_boot_cpu_data(void)
63{
64 unsigned int dummy, eax;
65
66 /* get vendor info */
67 cpuid(0, (unsigned int *)&boot_cpu_data.cpuid_level,
68 (unsigned int *)&boot_cpu_data.x86_vendor_id[0],
69 (unsigned int *)&boot_cpu_data.x86_vendor_id[8],
70 (unsigned int *)&boot_cpu_data.x86_vendor_id[4]);
71
72 /* get cpu type */
73 cpuid(1, &eax, &dummy, &dummy,
74 (unsigned int *) &boot_cpu_data.x86_capability);
75 boot_cpu_data.x86 = (eax >> 8) & 0xf;
76 boot_cpu_data.x86_model = (eax >> 4) & 0xf;
77 boot_cpu_data.x86_mask = eax & 0xf;
78}
79
80extern char _end[];
81
82void __init x86_64_start_kernel(char * real_mode_data)
83{
84 char *s;
85 int i;
86
87 for (i = 0; i < 256; i++)
88 set_intr_gate(i, early_idt_handler);
89 asm volatile("lidt %0" :: "m" (idt_descr));
90 clear_bss();
91 pda_init(0);
92 copy_bootdata(real_mode_data);
93#ifdef CONFIG_SMP
94 cpu_set(0, cpu_online_map);
95#endif
96 /* default console: */
97 if (!strstr(saved_command_line, "console="))
98 strcat(saved_command_line, " console=tty0");
99 s = strstr(saved_command_line, "earlyprintk=");
100 if (s != NULL)
101 setup_early_printk(s);
102#ifdef CONFIG_DISCONTIGMEM
103 s = strstr(saved_command_line, "numa=");
104 if (s != NULL)
105 numa_setup(s+5);
106#endif
107#ifdef CONFIG_X86_IO_APIC
108 if (strstr(saved_command_line, "disableapic"))
109 disable_apic = 1;
110#endif
111 /* You need early console to see that */
112 if (__pa_symbol(&_end) >= KERNEL_TEXT_SIZE)
113 panic("Kernel too big for kernel mapping\n");
114
115 setup_boot_cpu_data();
116 start_kernel();
117}