Blame view
arch/x86/kernel/head64.c
3.29 KB
1da177e4c
|
1 |
/* |
835c34a16
|
2 |
* prepare to run common code |
1da177e4c
|
3 4 |
* * Copyright (C) 2000 Andrea Arcangeli <andrea@suse.de> SuSE |
1da177e4c
|
5 6 7 8 9 10 11 12 |
*/ #include <linux/init.h> #include <linux/linkage.h> #include <linux/types.h> #include <linux/kernel.h> #include <linux/string.h> #include <linux/percpu.h> |
eaf76e8b9
|
13 |
#include <linux/start_kernel.h> |
8b664aa66
|
14 |
#include <linux/io.h> |
72d7c3b33
|
15 |
#include <linux/memblock.h> |
1da177e4c
|
16 17 18 19 |
#include <asm/processor.h> #include <asm/proto.h> #include <asm/smp.h> |
1da177e4c
|
20 21 |
#include <asm/setup.h> #include <asm/desc.h> |
f6c2e3330
|
22 |
#include <asm/pgtable.h> |
cfd243d4a
|
23 |
#include <asm/tlbflush.h> |
2bc0414ee
|
24 |
#include <asm/sections.h> |
718fc13b4
|
25 |
#include <asm/kdebug.h> |
751752789
|
26 |
#include <asm/e820.h> |
3e1e9002a
|
27 |
#include <asm/trampoline.h> |
47a3d5da7
|
28 |
#include <asm/bios_ebda.h> |
1da177e4c
|
29 |
|
cfd243d4a
|
30 31 32 33 |
static void __init zap_identity_mappings(void) { pgd_t *pgd = pgd_offset_k(0UL); pgd_clear(pgd); |
cd5828966
|
34 |
__flush_tlb_all(); |
cfd243d4a
|
35 |
} |
1da177e4c
|
36 37 38 39 |
/* Don't add a printk in there. printk relies on the PDA which is not initialized yet. */ static void __init clear_bss(void) { |
1da177e4c
|
40 |
memset(__bss_start, 0, |
2bc0414ee
|
41 |
(unsigned long) __bss_stop - (unsigned long) __bss_start); |
1da177e4c
|
42 |
} |
1da177e4c
|
43 44 |
static void __init copy_bootdata(char *real_mode_data) { |
1da177e4c
|
45 |
char * command_line; |
30c826451
|
46 47 48 49 |
memcpy(&boot_params, real_mode_data, sizeof boot_params); if (boot_params.hdr.cmd_line_ptr) { command_line = __va(boot_params.hdr.cmd_line_ptr); memcpy(boot_command_line, command_line, COMMAND_LINE_SIZE); |
1da177e4c
|
50 |
} |
1da177e4c
|
51 |
} |
1da177e4c
|
52 53 |
void __init x86_64_start_kernel(char * real_mode_data) { |
1da177e4c
|
54 |
int i; |
b4e0409a3
|
55 56 57 58 59 60 61 62 63 64 65 66 |
/* * Build-time sanity checks on the kernel image and module * area mappings. (these are purely build-time and produce no code) */ BUILD_BUG_ON(MODULES_VADDR < KERNEL_IMAGE_START); BUILD_BUG_ON(MODULES_VADDR-KERNEL_IMAGE_START < KERNEL_IMAGE_SIZE); BUILD_BUG_ON(MODULES_LEN + KERNEL_IMAGE_SIZE > 2*PUD_SIZE); BUILD_BUG_ON((KERNEL_IMAGE_START & ~PMD_MASK) != 0); BUILD_BUG_ON((MODULES_VADDR & ~PMD_MASK) != 0); BUILD_BUG_ON(!(MODULES_VADDR > __START_KERNEL)); BUILD_BUG_ON(!(((MODULES_END - 1) & PGDIR_MASK) == (__START_KERNEL & PGDIR_MASK))); |
66d4bdf22
|
67 |
BUILD_BUG_ON(__fix_to_virt(__end_of_fixed_addresses) <= MODULES_END); |
b4e0409a3
|
68 |
|
3df0af0eb
|
69 70 |
/* clear bss before set_intr_gate with early_idt_handler */ clear_bss(); |
cfd243d4a
|
71 72 |
/* Make NULL pointers segfault */ zap_identity_mappings(); |
67e87f0a1
|
73 |
max_pfn_mapped = KERNEL_IMAGE_SIZE >> PAGE_SHIFT; |
5524ea320
|
74 |
for (i = 0; i < NUM_EXCEPTION_VECTORS; i++) { |
076f9776f
|
75 |
#ifdef CONFIG_EARLY_PRINTK |
8866cd9dc
|
76 |
set_intr_gate(i, &early_idt_handlers[i]); |
076f9776f
|
77 78 79 80 |
#else set_intr_gate(i, early_idt_handler); #endif } |
9d1c6e7c8
|
81 |
load_idt((const struct desc_ptr *)&idt_descr); |
f6c2e3330
|
82 |
|
12544697f
|
83 84 85 |
if (console_loglevel == 10) early_printk("Kernel alive "); |
2148270cd
|
86 |
|
f97013fd8
|
87 88 89 90 91 |
x86_64_start_reservations(real_mode_data); } void __init x86_64_start_reservations(char *real_mode_data) { |
278c0eb7f
|
92 |
copy_bootdata(__va(real_mode_data)); |
9de819fe7
|
93 |
|
24aa07882
|
94 95 |
memblock_reserve(__pa_symbol(&_text), __pa_symbol(&__bss_stop) - __pa_symbol(&_text)); |
751752789
|
96 |
|
2b8106a0a
|
97 |
#ifdef CONFIG_BLK_DEV_INITRD |
751752789
|
98 99 |
/* Reserve INITRD */ if (boot_params.hdr.type_of_loader && boot_params.hdr.ramdisk_image) { |
c967da6a0
|
100 |
/* Assume only end is not page aligned */ |
751752789
|
101 102 |
unsigned long ramdisk_image = boot_params.hdr.ramdisk_image; unsigned long ramdisk_size = boot_params.hdr.ramdisk_size; |
c967da6a0
|
103 |
unsigned long ramdisk_end = PAGE_ALIGN(ramdisk_image + ramdisk_size); |
24aa07882
|
104 |
memblock_reserve(ramdisk_image, ramdisk_end - ramdisk_image); |
751752789
|
105 |
} |
2b8106a0a
|
106 |
#endif |
751752789
|
107 |
|
47a3d5da7
|
108 |
reserve_ebda_region(); |
751752789
|
109 110 111 112 113 114 |
/* * At this point everything still needed from the boot loader * or BIOS or kernel text should be early reserved or marked not * RAM in e820. All other memory is free game. */ |
1da177e4c
|
115 116 |
start_kernel(); } |