[PATCH] x86-64: Modify discover_ebda to use virtual addresses
[deliverable/linux.git] / arch / x86_64 / kernel / head64.c
CommitLineData
1da177e4
LT
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
1da177e4
LT
5 */
6
7#include <linux/init.h>
8#include <linux/linkage.h>
9#include <linux/types.h>
10#include <linux/kernel.h>
11#include <linux/string.h>
12#include <linux/percpu.h>
13
14#include <asm/processor.h>
15#include <asm/proto.h>
16#include <asm/smp.h>
17#include <asm/bootsetup.h>
18#include <asm/setup.h>
19#include <asm/desc.h>
f6c2e333 20#include <asm/pgtable.h>
2bc0414e 21#include <asm/sections.h>
1da177e4
LT
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{
1da177e4 27 memset(__bss_start, 0,
2bc0414e 28 (unsigned long) __bss_stop - (unsigned long) __bss_start);
1da177e4
LT
29}
30
1da177e4 31#define NEW_CL_POINTER 0x228 /* Relative to real mode data */
278c0eb7 32#define OLD_CL_MAGIC_ADDR 0x20
1da177e4 33#define OLD_CL_MAGIC 0xA33F
278c0eb7 34#define OLD_CL_OFFSET 0x22
1da177e4 35
1da177e4
LT
36static void __init copy_bootdata(char *real_mode_data)
37{
278c0eb7 38 unsigned long new_data;
1da177e4
LT
39 char * command_line;
40
f9ba7053 41 memcpy(x86_boot_params, real_mode_data, BOOT_PARAM_SIZE);
278c0eb7 42 new_data = *(u32 *) (x86_boot_params + NEW_CL_POINTER);
1da177e4 43 if (!new_data) {
278c0eb7 44 if (OLD_CL_MAGIC != *(u16 *)(real_mode_data + OLD_CL_MAGIC_ADDR)) {
1da177e4
LT
45 return;
46 }
278c0eb7 47 new_data = __pa(real_mode_data) + *(u16 *)(real_mode_data + OLD_CL_OFFSET);
1da177e4 48 }
278c0eb7 49 command_line = __va(new_data);
adf48856 50 memcpy(boot_command_line, command_line, COMMAND_LINE_SIZE);
1da177e4
LT
51}
52
1da177e4
LT
53void __init x86_64_start_kernel(char * real_mode_data)
54{
1da177e4
LT
55 int i;
56
3df0af0e
YL
57 /* clear bss before set_intr_gate with early_idt_handler */
58 clear_bss();
59
60 for (i = 0; i < IDT_ENTRIES; i++)
1da177e4
LT
61 set_intr_gate(i, early_idt_handler);
62 asm volatile("lidt %0" :: "m" (idt_descr));
f6c2e333 63
43c85c9c 64 early_printk("Kernel alive\n");
2148270c 65
f6c2e333
SS
66 /*
67 * switch to init_level4_pgt from boot_level4_pgt
68 */
69 memcpy(init_level4_pgt, boot_level4_pgt, PTRS_PER_PGD*sizeof(pgd_t));
70 asm volatile("movq %0,%%cr3" :: "r" (__pa_symbol(&init_level4_pgt)));
71
365ba917
RT
72 for (i = 0; i < NR_CPUS; i++)
73 cpu_pda(i) = &boot_cpu_pda[i];
74
1da177e4 75 pda_init(0);
278c0eb7 76 copy_bootdata(__va(real_mode_data));
1da177e4
LT
77#ifdef CONFIG_SMP
78 cpu_set(0, cpu_online_map);
79#endif
1da177e4
LT
80 start_kernel();
81}
This page took 0.229904 seconds and 5 git commands to generate.