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.27 2003/03/31 15:12:07 ak Exp $
7 */
8
9 #include <asm/bootsetup.h>
10 #include <linux/init.h>
11 #include <linux/linkage.h>
12 #include <linux/types.h>
13 #include <linux/kernel.h>
14 #include <linux/string.h>
15
16 #include <asm/processor.h>
17 #include <asm/proto.h>
18
clear_bss(void)19 static void __init clear_bss(void)
20 {
21 extern char __bss_start[], __bss_end[];
22 printk("Clearing %ld bytes of bss...", (unsigned long) __bss_end - (unsigned long) __bss_start);
23 memset(__bss_start, 0,
24 (unsigned long) __bss_end - (unsigned long) __bss_start);
25 printk("ok\n");
26 }
27
28 extern char x86_boot_params[2048];
29
30 #define NEW_CL_POINTER 0x228 /* Relative to real mode data */
31 #define OLD_CL_MAGIC_ADDR 0x90020
32 #define OLD_CL_MAGIC 0xA33F
33 #define OLD_CL_BASE_ADDR 0x90000
34 #define OLD_CL_OFFSET 0x90022
35
36 extern char saved_command_line[];
37
copy_bootdata(char * real_mode_data)38 static void __init copy_bootdata(char *real_mode_data)
39 {
40 int new_data;
41 char * command_line;
42
43 memcpy(x86_boot_params, real_mode_data, 2048);
44 new_data = *(int *) (x86_boot_params + NEW_CL_POINTER);
45 if (!new_data) {
46 if (OLD_CL_MAGIC != * (u16 *) OLD_CL_MAGIC_ADDR) {
47 printk("so old bootloader that it does not support commandline?!\n");
48 return;
49 }
50 new_data = OLD_CL_BASE_ADDR + * (u16 *) OLD_CL_OFFSET;
51 printk("old bootloader convention, maybe loadlin?\n");
52 }
53 command_line = (char *) ((u64)(new_data));
54 memcpy(saved_command_line, command_line, COMMAND_LINE_SIZE);
55 printk("Bootdata ok (command line is %s)\n", saved_command_line);
56 }
57
setup_boot_cpu_data(void)58 static void __init setup_boot_cpu_data(void)
59 {
60 int dummy, eax;
61
62 /* get vendor info */
63 cpuid(0, &boot_cpu_data.cpuid_level,
64 (int *)&boot_cpu_data.x86_vendor_id[0],
65 (int *)&boot_cpu_data.x86_vendor_id[8],
66 (int *)&boot_cpu_data.x86_vendor_id[4]);
67
68 /* get cpu type */
69 cpuid(1, &eax, &dummy, &dummy, (int *) &boot_cpu_data.x86_capability);
70 boot_cpu_data.x86 = (eax >> 8) & 0xf;
71 boot_cpu_data.x86_model = (eax >> 4) & 0xf;
72 boot_cpu_data.x86_mask = eax & 0xf;
73 }
74
x86_64_start_kernel(char * real_mode_data)75 void __init x86_64_start_kernel(char * real_mode_data)
76 {
77 char *s;
78
79 clear_bss(); /* must be the first thing in C and must not depend on .bss to be zero */
80 pda_init(0);
81 copy_bootdata(real_mode_data);
82 s = strstr(saved_command_line, "earlyprintk=");
83 if (s != NULL)
84 setup_early_printk(s+12);
85 #ifdef CONFIG_DISCONTIGMEM
86 extern int numa_setup(char *);
87 s = strstr(saved_command_line, "numa=");
88 if (s != NULL)
89 numa_setup(s+5);
90 #endif
91 early_printk("booting x86_64 kernel... ");
92 setup_boot_cpu_data();
93 start_kernel();
94 }
95