]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blame - arch/x86/kernel/head64.c
fix sparc32 breakage (result of vmlinux.lds.S bug)
[mirror_ubuntu-artful-kernel.git] / arch / x86 / 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>
cfd243d4 21#include <asm/tlbflush.h>
2bc0414e 22#include <asm/sections.h>
1da177e4 23
cfd243d4
VG
24static void __init zap_identity_mappings(void)
25{
26 pgd_t *pgd = pgd_offset_k(0UL);
27 pgd_clear(pgd);
28 __flush_tlb();
29}
30
1da177e4
LT
31/* Don't add a printk in there. printk relies on the PDA which is not initialized
32 yet. */
33static void __init clear_bss(void)
34{
1da177e4 35 memset(__bss_start, 0,
2bc0414e 36 (unsigned long) __bss_stop - (unsigned long) __bss_start);
1da177e4
LT
37}
38
1da177e4 39#define NEW_CL_POINTER 0x228 /* Relative to real mode data */
278c0eb7 40#define OLD_CL_MAGIC_ADDR 0x20
1da177e4 41#define OLD_CL_MAGIC 0xA33F
278c0eb7 42#define OLD_CL_OFFSET 0x22
1da177e4 43
1da177e4
LT
44static void __init copy_bootdata(char *real_mode_data)
45{
278c0eb7 46 unsigned long new_data;
1da177e4
LT
47 char * command_line;
48
f9ba7053 49 memcpy(x86_boot_params, real_mode_data, BOOT_PARAM_SIZE);
278c0eb7 50 new_data = *(u32 *) (x86_boot_params + NEW_CL_POINTER);
1da177e4 51 if (!new_data) {
278c0eb7 52 if (OLD_CL_MAGIC != *(u16 *)(real_mode_data + OLD_CL_MAGIC_ADDR)) {
1da177e4
LT
53 return;
54 }
278c0eb7 55 new_data = __pa(real_mode_data) + *(u16 *)(real_mode_data + OLD_CL_OFFSET);
1da177e4 56 }
278c0eb7 57 command_line = __va(new_data);
adf48856 58 memcpy(boot_command_line, command_line, COMMAND_LINE_SIZE);
1da177e4
LT
59}
60
1da177e4
LT
61void __init x86_64_start_kernel(char * real_mode_data)
62{
1da177e4
LT
63 int i;
64
3df0af0e
YL
65 /* clear bss before set_intr_gate with early_idt_handler */
66 clear_bss();
67
cfd243d4
VG
68 /* Make NULL pointers segfault */
69 zap_identity_mappings();
70
3df0af0e 71 for (i = 0; i < IDT_ENTRIES; i++)
1da177e4
LT
72 set_intr_gate(i, early_idt_handler);
73 asm volatile("lidt %0" :: "m" (idt_descr));
f6c2e333 74
43c85c9c 75 early_printk("Kernel alive\n");
2148270c 76
365ba917
RT
77 for (i = 0; i < NR_CPUS; i++)
78 cpu_pda(i) = &boot_cpu_pda[i];
79
1da177e4 80 pda_init(0);
278c0eb7 81 copy_bootdata(__va(real_mode_data));
1da177e4
LT
82#ifdef CONFIG_SMP
83 cpu_set(0, cpu_online_map);
84#endif
1da177e4
LT
85 start_kernel();
86}