added 2.6.29.6 aldebaran kernel
[nao-ulib.git] / kernel / 2.6.29.6-aldebaran-rt / arch / x86 / kernel / head64.c
blob4d7255c6b1d7d00599a5b728c55e7469bf05077a
1 /*
2 * prepare to run common code
4 * Copyright (C) 2000 Andrea Arcangeli <andrea@suse.de> SuSE
5 */
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 #include <linux/start_kernel.h>
14 #include <linux/io.h>
16 #include <asm/processor.h>
17 #include <asm/proto.h>
18 #include <asm/smp.h>
19 #include <asm/setup.h>
20 #include <asm/desc.h>
21 #include <asm/pgtable.h>
22 #include <asm/tlbflush.h>
23 #include <asm/sections.h>
24 #include <asm/kdebug.h>
25 #include <asm/e820.h>
26 #include <asm/bios_ebda.h>
27 #include <asm/trampoline.h>
29 static void __init zap_identity_mappings(void)
31 pgd_t *pgd = pgd_offset_k(0UL);
32 pgd_clear(pgd);
34 * preempt_disable/enable does not work this early in the
35 * bootup yet:
37 write_cr3(read_cr3());
40 /* Don't add a printk in there. printk relies on the PDA which is not initialized
41 yet. */
42 static void __init clear_bss(void)
44 memset(__bss_start, 0,
45 (unsigned long) __bss_stop - (unsigned long) __bss_start);
48 static void __init copy_bootdata(char *real_mode_data)
50 char * command_line;
52 memcpy(&boot_params, real_mode_data, sizeof boot_params);
53 if (boot_params.hdr.cmd_line_ptr) {
54 command_line = __va(boot_params.hdr.cmd_line_ptr);
55 memcpy(boot_command_line, command_line, COMMAND_LINE_SIZE);
59 void __init x86_64_start_kernel(char * real_mode_data)
61 int i;
64 * Build-time sanity checks on the kernel image and module
65 * area mappings. (these are purely build-time and produce no code)
67 BUILD_BUG_ON(MODULES_VADDR < KERNEL_IMAGE_START);
68 BUILD_BUG_ON(MODULES_VADDR-KERNEL_IMAGE_START < KERNEL_IMAGE_SIZE);
69 BUILD_BUG_ON(MODULES_LEN + KERNEL_IMAGE_SIZE > 2*PUD_SIZE);
70 BUILD_BUG_ON((KERNEL_IMAGE_START & ~PMD_MASK) != 0);
71 BUILD_BUG_ON((MODULES_VADDR & ~PMD_MASK) != 0);
72 BUILD_BUG_ON(!(MODULES_VADDR > __START_KERNEL));
73 BUILD_BUG_ON(!(((MODULES_END - 1) & PGDIR_MASK) ==
74 (__START_KERNEL & PGDIR_MASK)));
75 BUILD_BUG_ON(__fix_to_virt(__end_of_fixed_addresses) <= MODULES_END);
77 /* clear bss before set_intr_gate with early_idt_handler */
78 clear_bss();
80 /* Make NULL pointers segfault */
81 zap_identity_mappings();
83 /* Cleanup the over mapped high alias */
84 cleanup_highmap();
86 for (i = 0; i < NUM_EXCEPTION_VECTORS; i++) {
87 #ifdef CONFIG_EARLY_PRINTK
88 set_intr_gate(i, &early_idt_handlers[i]);
89 #else
90 set_intr_gate(i, early_idt_handler);
91 #endif
93 load_idt((const struct desc_ptr *)&idt_descr);
95 if (console_loglevel == 10)
96 early_printk("Kernel alive\n");
98 x86_64_start_reservations(real_mode_data);
101 void __init x86_64_start_reservations(char *real_mode_data)
103 copy_bootdata(__va(real_mode_data));
105 reserve_trampoline_memory();
107 reserve_early(__pa_symbol(&_text), __pa_symbol(&__bss_stop), "TEXT DATA BSS");
109 #ifdef CONFIG_BLK_DEV_INITRD
110 /* Reserve INITRD */
111 if (boot_params.hdr.type_of_loader && boot_params.hdr.ramdisk_image) {
112 unsigned long ramdisk_image = boot_params.hdr.ramdisk_image;
113 unsigned long ramdisk_size = boot_params.hdr.ramdisk_size;
114 unsigned long ramdisk_end = ramdisk_image + ramdisk_size;
115 reserve_early(ramdisk_image, ramdisk_end, "RAMDISK");
117 #endif
119 reserve_ebda_region();
122 * At this point everything still needed from the boot loader
123 * or BIOS or kernel text should be early reserved or marked not
124 * RAM in e820. All other memory is free game.
127 start_kernel();