x86: remove some acpi ifdefs in setup_32/64
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / arch / x86 / kernel / setup_32.c
blobe274ee6ff582b9b6184c6cf1f622fbd5f53d14f2
1 /*
2 * Copyright (C) 1995 Linus Torvalds
4 * Support of BIGMEM added by Gerhard Wichert, Siemens AG, July 1999
6 * Memory region support
7 * David Parsons <orc@pell.chi.il.us>, July-August 1999
9 * Added E820 sanitization routine (removes overlapping memory regions);
10 * Brian Moyle <bmoyle@mvista.com>, February 2001
12 * Moved CPU detection code to cpu/${cpu}.c
13 * Patrick Mochel <mochel@osdl.org>, March 2002
15 * Provisions for empty E820 memory regions (reported by certain BIOSes).
16 * Alex Achenbach <xela@slit.de>, December 2002.
21 * This file handles the architecture-dependent parts of initialization
24 #include <linux/sched.h>
25 #include <linux/mm.h>
26 #include <linux/mmzone.h>
27 #include <linux/screen_info.h>
28 #include <linux/ioport.h>
29 #include <linux/acpi.h>
30 #include <linux/apm_bios.h>
31 #include <linux/initrd.h>
32 #include <linux/bootmem.h>
33 #include <linux/seq_file.h>
34 #include <linux/console.h>
35 #include <linux/mca.h>
36 #include <linux/root_dev.h>
37 #include <linux/highmem.h>
38 #include <linux/module.h>
39 #include <linux/efi.h>
40 #include <linux/init.h>
41 #include <linux/edd.h>
42 #include <linux/iscsi_ibft.h>
43 #include <linux/nodemask.h>
44 #include <linux/kexec.h>
45 #include <linux/crash_dump.h>
46 #include <linux/dmi.h>
47 #include <linux/pfn.h>
48 #include <linux/pci.h>
49 #include <linux/init_ohci1394_dma.h>
50 #include <linux/kvm_para.h>
52 #include <video/edid.h>
54 #include <asm/mtrr.h>
55 #include <asm/apic.h>
56 #include <asm/e820.h>
57 #include <asm/mpspec.h>
58 #include <asm/mmzone.h>
59 #include <asm/setup.h>
60 #include <asm/arch_hooks.h>
61 #include <asm/sections.h>
62 #include <asm/dmi.h>
63 #include <asm/io_apic.h>
64 #include <asm/ist.h>
65 #include <asm/io.h>
66 #include <asm/vmi.h>
67 #include <setup_arch.h>
68 #include <asm/bios_ebda.h>
69 #include <asm/cacheflush.h>
70 #include <asm/processor.h>
71 #include <asm/efi.h>
72 #include <asm/bugs.h>
74 /* This value is set up by the early boot code to point to the value
75 immediately after the boot time page tables. It contains a *physical*
76 address, and must not be in the .bss segment! */
77 unsigned long init_pg_tables_start __initdata = ~0UL;
78 unsigned long init_pg_tables_end __initdata = ~0UL;
81 * Machine setup..
83 static struct resource data_resource = {
84 .name = "Kernel data",
85 .start = 0,
86 .end = 0,
87 .flags = IORESOURCE_BUSY | IORESOURCE_MEM
90 static struct resource code_resource = {
91 .name = "Kernel code",
92 .start = 0,
93 .end = 0,
94 .flags = IORESOURCE_BUSY | IORESOURCE_MEM
97 static struct resource bss_resource = {
98 .name = "Kernel bss",
99 .start = 0,
100 .end = 0,
101 .flags = IORESOURCE_BUSY | IORESOURCE_MEM
104 static struct resource video_ram_resource = {
105 .name = "Video RAM area",
106 .start = 0xa0000,
107 .end = 0xbffff,
108 .flags = IORESOURCE_BUSY | IORESOURCE_MEM
111 static struct resource standard_io_resources[] = { {
112 .name = "dma1",
113 .start = 0x0000,
114 .end = 0x001f,
115 .flags = IORESOURCE_BUSY | IORESOURCE_IO
116 }, {
117 .name = "pic1",
118 .start = 0x0020,
119 .end = 0x0021,
120 .flags = IORESOURCE_BUSY | IORESOURCE_IO
121 }, {
122 .name = "timer0",
123 .start = 0x0040,
124 .end = 0x0043,
125 .flags = IORESOURCE_BUSY | IORESOURCE_IO
126 }, {
127 .name = "timer1",
128 .start = 0x0050,
129 .end = 0x0053,
130 .flags = IORESOURCE_BUSY | IORESOURCE_IO
131 }, {
132 .name = "keyboard",
133 .start = 0x0060,
134 .end = 0x0060,
135 .flags = IORESOURCE_BUSY | IORESOURCE_IO
136 }, {
137 .name = "keyboard",
138 .start = 0x0064,
139 .end = 0x0064,
140 .flags = IORESOURCE_BUSY | IORESOURCE_IO
141 }, {
142 .name = "dma page reg",
143 .start = 0x0080,
144 .end = 0x008f,
145 .flags = IORESOURCE_BUSY | IORESOURCE_IO
146 }, {
147 .name = "pic2",
148 .start = 0x00a0,
149 .end = 0x00a1,
150 .flags = IORESOURCE_BUSY | IORESOURCE_IO
151 }, {
152 .name = "dma2",
153 .start = 0x00c0,
154 .end = 0x00df,
155 .flags = IORESOURCE_BUSY | IORESOURCE_IO
156 }, {
157 .name = "fpu",
158 .start = 0x00f0,
159 .end = 0x00ff,
160 .flags = IORESOURCE_BUSY | IORESOURCE_IO
161 } };
163 /* cpu data as detected by the assembly code in head.S */
164 struct cpuinfo_x86 new_cpu_data __cpuinitdata = { 0, 0, 0, 0, -1, 1, 0, 0, -1 };
165 /* common cpu data for all cpus */
166 struct cpuinfo_x86 boot_cpu_data __read_mostly = { 0, 0, 0, 0, -1, 1, 0, 0, -1 };
167 EXPORT_SYMBOL(boot_cpu_data);
169 unsigned int def_to_bigsmp;
171 #ifndef CONFIG_X86_PAE
172 unsigned long mmu_cr4_features;
173 #else
174 unsigned long mmu_cr4_features = X86_CR4_PAE;
175 #endif
177 /* for MCA, but anyone else can use it if they want */
178 unsigned int machine_id;
179 unsigned int machine_submodel_id;
180 unsigned int BIOS_revision;
182 /* Boot loader ID as an integer, for the benefit of proc_dointvec */
183 int bootloader_type;
185 /* user-defined highmem size */
186 static unsigned int highmem_pages = -1;
189 * Early DMI memory
191 int dmi_alloc_index;
192 char dmi_alloc_data[DMI_MAX_DATA];
195 * Setup options
197 struct screen_info screen_info;
198 EXPORT_SYMBOL(screen_info);
199 struct apm_info apm_info;
200 EXPORT_SYMBOL(apm_info);
201 struct edid_info edid_info;
202 EXPORT_SYMBOL_GPL(edid_info);
203 struct ist_info ist_info;
204 #if defined(CONFIG_X86_SPEEDSTEP_SMI) || \
205 defined(CONFIG_X86_SPEEDSTEP_SMI_MODULE)
206 EXPORT_SYMBOL(ist_info);
207 #endif
209 extern void early_cpu_init(void);
210 extern int root_mountflags;
212 unsigned long saved_video_mode;
214 #define RAMDISK_IMAGE_START_MASK 0x07FF
215 #define RAMDISK_PROMPT_FLAG 0x8000
216 #define RAMDISK_LOAD_FLAG 0x4000
218 static char __initdata command_line[COMMAND_LINE_SIZE];
220 #ifndef CONFIG_DEBUG_BOOT_PARAMS
221 struct boot_params __initdata boot_params;
222 #else
223 struct boot_params boot_params;
224 #endif
226 #if defined(CONFIG_EDD) || defined(CONFIG_EDD_MODULE)
227 struct edd edd;
228 #ifdef CONFIG_EDD_MODULE
229 EXPORT_SYMBOL(edd);
230 #endif
232 * copy_edd() - Copy the BIOS EDD information
233 * from boot_params into a safe place.
236 static inline void copy_edd(void)
238 memcpy(edd.mbr_signature, boot_params.edd_mbr_sig_buffer,
239 sizeof(edd.mbr_signature));
240 memcpy(edd.edd_info, boot_params.eddbuf, sizeof(edd.edd_info));
241 edd.mbr_signature_nr = boot_params.edd_mbr_sig_buf_entries;
242 edd.edd_info_nr = boot_params.eddbuf_entries;
244 #else
245 static inline void copy_edd(void)
248 #endif
250 #ifdef CONFIG_PROC_VMCORE
251 /* elfcorehdr= specifies the location of elf core header
252 * stored by the crashed kernel.
254 static int __init parse_elfcorehdr(char *arg)
256 if (!arg)
257 return -EINVAL;
259 elfcorehdr_addr = memparse(arg, &arg);
260 return 0;
262 early_param("elfcorehdr", parse_elfcorehdr);
263 #endif /* CONFIG_PROC_VMCORE */
266 * highmem=size forces highmem to be exactly 'size' bytes.
267 * This works even on boxes that have no highmem otherwise.
268 * This also works to reduce highmem size on bigger boxes.
270 static int __init parse_highmem(char *arg)
272 if (!arg)
273 return -EINVAL;
275 highmem_pages = memparse(arg, &arg) >> PAGE_SHIFT;
276 return 0;
278 early_param("highmem", parse_highmem);
281 * vmalloc=size forces the vmalloc area to be exactly 'size'
282 * bytes. This can be used to increase (or decrease) the
283 * vmalloc area - the default is 128m.
285 static int __init parse_vmalloc(char *arg)
287 if (!arg)
288 return -EINVAL;
290 __VMALLOC_RESERVE = memparse(arg, &arg);
291 return 0;
293 early_param("vmalloc", parse_vmalloc);
296 * reservetop=size reserves a hole at the top of the kernel address space which
297 * a hypervisor can load into later. Needed for dynamically loaded hypervisors,
298 * so relocating the fixmap can be done before paging initialization.
300 static int __init parse_reservetop(char *arg)
302 unsigned long address;
304 if (!arg)
305 return -EINVAL;
307 address = memparse(arg, &arg);
308 reserve_top_address(address);
309 return 0;
311 early_param("reservetop", parse_reservetop);
314 * Determine low and high memory ranges:
316 unsigned long __init find_max_low_pfn(void)
318 unsigned long max_low_pfn;
320 max_low_pfn = max_pfn;
321 if (max_low_pfn > MAXMEM_PFN) {
322 if (highmem_pages == -1)
323 highmem_pages = max_pfn - MAXMEM_PFN;
324 if (highmem_pages + MAXMEM_PFN < max_pfn)
325 max_pfn = MAXMEM_PFN + highmem_pages;
326 if (highmem_pages + MAXMEM_PFN > max_pfn) {
327 printk("only %luMB highmem pages available, ignoring highmem size of %uMB.\n", pages_to_mb(max_pfn - MAXMEM_PFN), pages_to_mb(highmem_pages));
328 highmem_pages = 0;
330 max_low_pfn = MAXMEM_PFN;
331 #ifndef CONFIG_HIGHMEM
332 /* Maximum memory usable is what is directly addressable */
333 printk(KERN_WARNING "Warning only %ldMB will be used.\n",
334 MAXMEM>>20);
335 if (max_pfn > MAX_NONPAE_PFN)
336 printk(KERN_WARNING "Use a HIGHMEM64G enabled kernel.\n");
337 else
338 printk(KERN_WARNING "Use a HIGHMEM enabled kernel.\n");
339 max_pfn = MAXMEM_PFN;
340 #else /* !CONFIG_HIGHMEM */
341 #ifndef CONFIG_HIGHMEM64G
342 if (max_pfn > MAX_NONPAE_PFN) {
343 max_pfn = MAX_NONPAE_PFN;
344 printk(KERN_WARNING "Warning only 4GB will be used.\n");
345 printk(KERN_WARNING "Use a HIGHMEM64G enabled kernel.\n");
347 #endif /* !CONFIG_HIGHMEM64G */
348 #endif /* !CONFIG_HIGHMEM */
349 } else {
350 if (highmem_pages == -1)
351 highmem_pages = 0;
352 #ifdef CONFIG_HIGHMEM
353 if (highmem_pages >= max_pfn) {
354 printk(KERN_ERR "highmem size specified (%uMB) is bigger than pages available (%luMB)!.\n", pages_to_mb(highmem_pages), pages_to_mb(max_pfn));
355 highmem_pages = 0;
357 if (highmem_pages) {
358 if (max_low_pfn-highmem_pages < 64*1024*1024/PAGE_SIZE){
359 printk(KERN_ERR "highmem size %uMB results in smaller than 64MB lowmem, ignoring it.\n", pages_to_mb(highmem_pages));
360 highmem_pages = 0;
362 max_low_pfn -= highmem_pages;
364 #else
365 if (highmem_pages)
366 printk(KERN_ERR "ignoring highmem size on non-highmem kernel!\n");
367 #endif
369 return max_low_pfn;
372 #ifndef CONFIG_NEED_MULTIPLE_NODES
373 static void __init setup_bootmem_allocator(void);
374 static unsigned long __init setup_memory(void)
377 * partially used pages are not usable - thus
378 * we are rounding upwards:
380 min_low_pfn = PFN_UP(init_pg_tables_end);
382 max_low_pfn = find_max_low_pfn();
384 #ifdef CONFIG_HIGHMEM
385 highstart_pfn = highend_pfn = max_pfn;
386 if (max_pfn > max_low_pfn) {
387 highstart_pfn = max_low_pfn;
389 memory_present(0, 0, highend_pfn);
390 printk(KERN_NOTICE "%ldMB HIGHMEM available.\n",
391 pages_to_mb(highend_pfn - highstart_pfn));
392 num_physpages = highend_pfn;
393 high_memory = (void *) __va(highstart_pfn * PAGE_SIZE - 1) + 1;
394 #else
395 memory_present(0, 0, max_low_pfn);
396 num_physpages = max_low_pfn;
397 high_memory = (void *) __va(max_low_pfn * PAGE_SIZE - 1) + 1;
398 #endif
399 #ifdef CONFIG_FLATMEM
400 max_mapnr = num_physpages;
401 #endif
402 printk(KERN_NOTICE "%ldMB LOWMEM available.\n",
403 pages_to_mb(max_low_pfn));
405 setup_bootmem_allocator();
407 return max_low_pfn;
410 static void __init zone_sizes_init(void)
412 unsigned long max_zone_pfns[MAX_NR_ZONES];
413 memset(max_zone_pfns, 0, sizeof(max_zone_pfns));
414 max_zone_pfns[ZONE_DMA] =
415 virt_to_phys((char *)MAX_DMA_ADDRESS) >> PAGE_SHIFT;
416 max_zone_pfns[ZONE_NORMAL] = max_low_pfn;
417 remove_all_active_ranges();
418 #ifdef CONFIG_HIGHMEM
419 max_zone_pfns[ZONE_HIGHMEM] = highend_pfn;
420 e820_register_active_regions(0, 0, highend_pfn);
421 #else
422 e820_register_active_regions(0, 0, max_low_pfn);
423 #endif
425 free_area_init_nodes(max_zone_pfns);
427 #else
428 extern unsigned long __init setup_memory(void);
429 extern void zone_sizes_init(void);
430 #endif /* !CONFIG_NEED_MULTIPLE_NODES */
432 #ifdef CONFIG_BLK_DEV_INITRD
434 static bool do_relocate_initrd = false;
436 static void __init reserve_initrd(void)
438 u64 ramdisk_image = boot_params.hdr.ramdisk_image;
439 u64 ramdisk_size = boot_params.hdr.ramdisk_size;
440 u64 ramdisk_end = ramdisk_image + ramdisk_size;
441 u64 end_of_lowmem = max_low_pfn << PAGE_SHIFT;
442 u64 ramdisk_here;
444 if (!boot_params.hdr.type_of_loader ||
445 !ramdisk_image || !ramdisk_size)
446 return; /* No initrd provided by bootloader */
448 initrd_start = 0;
450 if (ramdisk_size >= end_of_lowmem/2) {
451 free_early(ramdisk_image, ramdisk_end);
452 printk(KERN_ERR "initrd too large to handle, "
453 "disabling initrd\n");
454 return;
457 printk(KERN_INFO "old RAMDISK: %08llx - %08llx\n", ramdisk_image,
458 ramdisk_end);
461 if (ramdisk_end <= end_of_lowmem) {
462 /* All in lowmem, easy case */
464 * don't need to reserve again, already reserved early
465 * in i386_start_kernel
467 initrd_start = ramdisk_image + PAGE_OFFSET;
468 initrd_end = initrd_start+ramdisk_size;
469 return;
472 /* We need to move the initrd down into lowmem */
473 ramdisk_here = find_e820_area(min_low_pfn<<PAGE_SHIFT,
474 end_of_lowmem, ramdisk_size,
475 PAGE_SIZE);
477 if (ramdisk_here == -1ULL)
478 panic("Cannot find place for new RAMDISK of size %lld\n",
479 ramdisk_size);
481 /* Note: this includes all the lowmem currently occupied by
482 the initrd, we rely on that fact to keep the data intact. */
483 reserve_early(ramdisk_here, ramdisk_here + ramdisk_size,
484 "NEW RAMDISK");
485 initrd_start = ramdisk_here + PAGE_OFFSET;
486 initrd_end = initrd_start + ramdisk_size;
487 printk(KERN_INFO "Allocated new RAMDISK: %08llx - %08llx\n",
488 ramdisk_here, ramdisk_here + ramdisk_size);
490 do_relocate_initrd = true;
493 #define MAX_MAP_CHUNK (NR_FIX_BTMAPS << PAGE_SHIFT)
495 static void __init relocate_initrd(void)
497 u64 ramdisk_image = boot_params.hdr.ramdisk_image;
498 u64 ramdisk_size = boot_params.hdr.ramdisk_size;
499 u64 end_of_lowmem = max_low_pfn << PAGE_SHIFT;
500 u64 ramdisk_here;
501 unsigned long slop, clen, mapaddr;
502 char *p, *q;
504 if (!do_relocate_initrd)
505 return;
507 ramdisk_here = initrd_start - PAGE_OFFSET;
509 q = (char *)initrd_start;
511 /* Copy any lowmem portion of the initrd */
512 if (ramdisk_image < end_of_lowmem) {
513 clen = end_of_lowmem - ramdisk_image;
514 p = (char *)__va(ramdisk_image);
515 memcpy(q, p, clen);
516 q += clen;
517 /* need to free these low pages...*/
518 printk(KERN_INFO "Freeing old partial RAMDISK %08llx-%08llx\n",
519 ramdisk_image, ramdisk_image + clen - 1);
520 free_bootmem(ramdisk_image, clen);
521 ramdisk_image += clen;
522 ramdisk_size -= clen;
525 /* Copy the highmem portion of the initrd */
526 while (ramdisk_size) {
527 slop = ramdisk_image & ~PAGE_MASK;
528 clen = ramdisk_size;
529 if (clen > MAX_MAP_CHUNK-slop)
530 clen = MAX_MAP_CHUNK-slop;
531 mapaddr = ramdisk_image & PAGE_MASK;
532 p = early_ioremap(mapaddr, clen+slop);
533 memcpy(q, p+slop, clen);
534 early_iounmap(p, clen+slop);
535 q += clen;
536 ramdisk_image += clen;
537 ramdisk_size -= clen;
539 /* high pages is not converted by early_res_to_bootmem */
540 ramdisk_image = boot_params.hdr.ramdisk_image;
541 ramdisk_size = boot_params.hdr.ramdisk_size;
542 printk(KERN_INFO "Copied RAMDISK from %016llx - %016llx to %08llx - %08llx\n",
543 ramdisk_image, ramdisk_image + ramdisk_size - 1,
544 ramdisk_here, ramdisk_here + ramdisk_size - 1);
546 /* need to free that, otherwise init highmem will reserve it again */
547 free_early(ramdisk_image, ramdisk_image+ramdisk_size);
550 #endif /* CONFIG_BLK_DEV_INITRD */
552 void __init setup_bootmem_allocator(void)
554 int i;
555 unsigned long bootmap_size, bootmap;
557 * Initialize the boot-time allocator (with low memory only):
559 bootmap_size = bootmem_bootmap_pages(max_low_pfn)<<PAGE_SHIFT;
560 bootmap = find_e820_area(min_low_pfn<<PAGE_SHIFT,
561 max_pfn_mapped<<PAGE_SHIFT, bootmap_size,
562 PAGE_SIZE);
563 if (bootmap == -1L)
564 panic("Cannot find bootmem map of size %ld\n", bootmap_size);
565 reserve_early(bootmap, bootmap + bootmap_size, "BOOTMAP");
566 #ifdef CONFIG_BLK_DEV_INITRD
567 reserve_initrd();
568 #endif
569 bootmap_size = init_bootmem(bootmap >> PAGE_SHIFT, max_low_pfn);
570 printk(KERN_INFO " mapped low ram: 0 - %08lx\n",
571 max_pfn_mapped<<PAGE_SHIFT);
572 printk(KERN_INFO " low ram: %08lx - %08lx\n",
573 min_low_pfn<<PAGE_SHIFT, max_low_pfn<<PAGE_SHIFT);
574 printk(KERN_INFO " bootmap %08lx - %08lx\n",
575 bootmap, bootmap + bootmap_size);
576 for_each_online_node(i)
577 free_bootmem_with_active_regions(i, max_low_pfn);
578 early_res_to_bootmem(0, max_low_pfn<<PAGE_SHIFT);
583 * The node 0 pgdat is initialized before all of these because
584 * it's needed for bootmem. node>0 pgdats have their virtual
585 * space allocated before the pagetables are in place to access
586 * them, so they can't be cleared then.
588 * This should all compile down to nothing when NUMA is off.
590 static void __init remapped_pgdat_init(void)
592 int nid;
594 for_each_online_node(nid) {
595 if (nid != 0)
596 memset(NODE_DATA(nid), 0, sizeof(struct pglist_data));
600 #ifdef CONFIG_MCA
601 static void set_mca_bus(int x)
603 MCA_bus = x;
605 #else
606 static void set_mca_bus(int x) { }
607 #endif
609 static void probe_roms(void);
612 * Determine if we were loaded by an EFI loader. If so, then we have also been
613 * passed the efi memmap, systab, etc., so we should use these data structures
614 * for initialization. Note, the efi init code path is determined by the
615 * global efi_enabled. This allows the same kernel image to be used on existing
616 * systems (with a traditional BIOS) as well as on EFI systems.
618 void __init setup_arch(char **cmdline_p)
620 int i;
621 unsigned long max_low_pfn;
623 memcpy(&boot_cpu_data, &new_cpu_data, sizeof(new_cpu_data));
624 pre_setup_arch_hook();
625 early_cpu_init();
626 early_ioremap_init();
627 reserve_setup_data();
629 #ifdef CONFIG_EFI
630 if (!strncmp((char *)&boot_params.efi_info.efi_loader_signature,
631 "EL32", 4)) {
632 efi_enabled = 1;
633 efi_reserve_early();
635 #endif
637 ROOT_DEV = old_decode_dev(boot_params.hdr.root_dev);
638 screen_info = boot_params.screen_info;
639 edid_info = boot_params.edid_info;
640 apm_info.bios = boot_params.apm_bios_info;
641 ist_info = boot_params.ist_info;
642 saved_video_mode = boot_params.hdr.vid_mode;
643 if( boot_params.sys_desc_table.length != 0 ) {
644 set_mca_bus(boot_params.sys_desc_table.table[3] & 0x2);
645 machine_id = boot_params.sys_desc_table.table[0];
646 machine_submodel_id = boot_params.sys_desc_table.table[1];
647 BIOS_revision = boot_params.sys_desc_table.table[2];
649 bootloader_type = boot_params.hdr.type_of_loader;
651 #ifdef CONFIG_BLK_DEV_RAM
652 rd_image_start = boot_params.hdr.ram_size & RAMDISK_IMAGE_START_MASK;
653 rd_prompt = ((boot_params.hdr.ram_size & RAMDISK_PROMPT_FLAG) != 0);
654 rd_doload = ((boot_params.hdr.ram_size & RAMDISK_LOAD_FLAG) != 0);
655 #endif
656 ARCH_SETUP
658 setup_memory_map();
660 copy_edd();
662 if (!boot_params.hdr.root_flags)
663 root_mountflags &= ~MS_RDONLY;
664 init_mm.start_code = (unsigned long) _text;
665 init_mm.end_code = (unsigned long) _etext;
666 init_mm.end_data = (unsigned long) _edata;
667 init_mm.brk = init_pg_tables_end + PAGE_OFFSET;
669 code_resource.start = virt_to_phys(_text);
670 code_resource.end = virt_to_phys(_etext)-1;
671 data_resource.start = virt_to_phys(_etext);
672 data_resource.end = virt_to_phys(_edata)-1;
673 bss_resource.start = virt_to_phys(&__bss_start);
674 bss_resource.end = virt_to_phys(&__bss_stop)-1;
676 parse_setup_data();
678 parse_early_param();
680 if (acpi_mps_check()){
681 enable_local_apic = -1;
682 clear_cpu_cap(&boot_cpu_data, X86_FEATURE_APIC);
685 finish_e820_parsing();
687 probe_roms();
689 /* after parse_early_param, so could debug it */
690 insert_resource(&iomem_resource, &code_resource);
691 insert_resource(&iomem_resource, &data_resource);
692 insert_resource(&iomem_resource, &bss_resource);
694 strlcpy(command_line, boot_command_line, COMMAND_LINE_SIZE);
695 *cmdline_p = command_line;
697 if (efi_enabled)
698 efi_init();
700 if (ppro_with_ram_bug()) {
701 e820_update_range(0x70000000ULL, 0x40000ULL, E820_RAM,
702 E820_RESERVED);
703 sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map);
704 printk(KERN_INFO "fixed physical RAM map:\n");
705 e820_print_map("bad_ppro");
708 e820_register_active_regions(0, 0, -1UL);
710 * partially used pages are not usable - thus
711 * we are rounding upwards:
713 max_pfn = e820_end_of_ram();
715 /* preallocate 4k for mptable mpc */
716 early_reserve_e820_mpc_new();
717 /* update e820 for memory not covered by WB MTRRs */
718 mtrr_bp_init();
719 if (mtrr_trim_uncached_memory(max_pfn)) {
720 remove_all_active_ranges();
721 e820_register_active_regions(0, 0, -1UL);
722 max_pfn = e820_end_of_ram();
725 dmi_scan_machine();
727 io_delay_init();
730 * Parse the ACPI tables for possible boot-time SMP configuration.
732 acpi_boot_table_init();
734 #ifdef CONFIG_ACPI_NUMA
736 * Parse SRAT to discover nodes.
738 acpi_numa_init();
739 #endif
741 max_low_pfn = setup_memory();
743 #ifdef CONFIG_ACPI_SLEEP
745 * Reserve low memory region for sleep support.
747 acpi_reserve_bootmem();
748 #endif
749 #ifdef CONFIG_X86_FIND_SMP_CONFIG
751 * Find and reserve possible boot-time SMP configuration:
753 find_smp_config();
754 #endif
755 reserve_crashkernel();
757 reserve_ibft_region();
759 #ifdef CONFIG_KVM_CLOCK
760 kvmclock_init();
761 #endif
763 #ifdef CONFIG_VMI
765 * Must be after max_low_pfn is determined, and before kernel
766 * pagetables are setup.
768 vmi_init();
769 #endif
770 kvm_guest_init();
773 * NOTE: before this point _nobody_ is allowed to allocate
774 * any memory using the bootmem allocator. Although the
775 * allocator is now initialised only the first 8Mb of the kernel
776 * virtual address space has been mapped. All allocations before
777 * paging_init() has completed must use the alloc_bootmem_low_pages()
778 * variant (which allocates DMA'able memory) and care must be taken
779 * not to exceed the 8Mb limit.
782 paging_init();
785 * NOTE: On x86-32, only from this point on, fixmaps are ready for use.
788 #ifdef CONFIG_PROVIDE_OHCI1394_DMA_INIT
789 if (init_ohci1394_dma_early)
790 init_ohci1394_dma_on_all_controllers();
791 #endif
794 * NOTE: at this point the bootmem allocator is fully available.
797 #ifdef CONFIG_BLK_DEV_INITRD
798 relocate_initrd();
799 #endif
801 remapped_pgdat_init();
802 sparse_init();
803 zone_sizes_init();
805 paravirt_post_allocator_init();
807 #ifdef CONFIG_X86_GENERICARCH
808 generic_apic_probe();
809 #endif
811 early_quirks();
813 acpi_boot_init();
815 #if defined(CONFIG_X86_MPPARSE) || defined(CONFIG_X86_VISWS)
816 if (smp_found_config)
817 get_smp_config();
818 #endif
819 #if defined(CONFIG_SMP) && defined(CONFIG_X86_PC)
820 if (def_to_bigsmp)
821 printk(KERN_WARNING "More than 8 CPUs detected and "
822 "CONFIG_X86_PC cannot handle it.\nUse "
823 "CONFIG_X86_GENERICARCH or CONFIG_X86_BIGSMP.\n");
824 #endif
826 e820_reserve_resources();
827 e820_mark_nosave_regions(max_low_pfn);
829 request_resource(&iomem_resource, &video_ram_resource);
830 /* request I/O space for devices used on all i[345]86 PCs */
831 for (i = 0; i < ARRAY_SIZE(standard_io_resources); i++)
832 request_resource(&ioport_resource, &standard_io_resources[i]);
834 e820_setup_gap();
836 #ifdef CONFIG_VT
837 #if defined(CONFIG_VGA_CONSOLE)
838 if (!efi_enabled || (efi_mem_type(0xa0000) != EFI_CONVENTIONAL_MEMORY))
839 conswitchp = &vga_con;
840 #elif defined(CONFIG_DUMMY_CONSOLE)
841 conswitchp = &dummy_con;
842 #endif
843 #endif
846 static struct resource system_rom_resource = {
847 .name = "System ROM",
848 .start = 0xf0000,
849 .end = 0xfffff,
850 .flags = IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM
853 static struct resource extension_rom_resource = {
854 .name = "Extension ROM",
855 .start = 0xe0000,
856 .end = 0xeffff,
857 .flags = IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM
860 static struct resource adapter_rom_resources[] = { {
861 .name = "Adapter ROM",
862 .start = 0xc8000,
863 .end = 0,
864 .flags = IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM
865 }, {
866 .name = "Adapter ROM",
867 .start = 0,
868 .end = 0,
869 .flags = IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM
870 }, {
871 .name = "Adapter ROM",
872 .start = 0,
873 .end = 0,
874 .flags = IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM
875 }, {
876 .name = "Adapter ROM",
877 .start = 0,
878 .end = 0,
879 .flags = IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM
880 }, {
881 .name = "Adapter ROM",
882 .start = 0,
883 .end = 0,
884 .flags = IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM
885 }, {
886 .name = "Adapter ROM",
887 .start = 0,
888 .end = 0,
889 .flags = IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM
890 } };
892 static struct resource video_rom_resource = {
893 .name = "Video ROM",
894 .start = 0xc0000,
895 .end = 0xc7fff,
896 .flags = IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM
899 #define ROMSIGNATURE 0xaa55
901 static int __init romsignature(const unsigned char *rom)
903 const unsigned short * const ptr = (const unsigned short *)rom;
904 unsigned short sig;
906 return probe_kernel_address(ptr, sig) == 0 && sig == ROMSIGNATURE;
909 static int __init romchecksum(const unsigned char *rom, unsigned long length)
911 unsigned char sum, c;
913 for (sum = 0; length && probe_kernel_address(rom++, c) == 0; length--)
914 sum += c;
915 return !length && !sum;
918 static void __init probe_roms(void)
920 const unsigned char *rom;
921 unsigned long start, length, upper;
922 unsigned char c;
923 int i;
925 /* video rom */
926 upper = adapter_rom_resources[0].start;
927 for (start = video_rom_resource.start; start < upper; start += 2048) {
928 rom = isa_bus_to_virt(start);
929 if (!romsignature(rom))
930 continue;
932 video_rom_resource.start = start;
934 if (probe_kernel_address(rom + 2, c) != 0)
935 continue;
937 /* 0 < length <= 0x7f * 512, historically */
938 length = c * 512;
940 /* if checksum okay, trust length byte */
941 if (length && romchecksum(rom, length))
942 video_rom_resource.end = start + length - 1;
944 request_resource(&iomem_resource, &video_rom_resource);
945 break;
948 start = (video_rom_resource.end + 1 + 2047) & ~2047UL;
949 if (start < upper)
950 start = upper;
952 /* system rom */
953 request_resource(&iomem_resource, &system_rom_resource);
954 upper = system_rom_resource.start;
956 /* check for extension rom (ignore length byte!) */
957 rom = isa_bus_to_virt(extension_rom_resource.start);
958 if (romsignature(rom)) {
959 length = extension_rom_resource.end - extension_rom_resource.start + 1;
960 if (romchecksum(rom, length)) {
961 request_resource(&iomem_resource, &extension_rom_resource);
962 upper = extension_rom_resource.start;
966 /* check for adapter roms on 2k boundaries */
967 for (i = 0; i < ARRAY_SIZE(adapter_rom_resources) && start < upper; start += 2048) {
968 rom = isa_bus_to_virt(start);
969 if (!romsignature(rom))
970 continue;
972 if (probe_kernel_address(rom + 2, c) != 0)
973 continue;
975 /* 0 < length <= 0x7f * 512, historically */
976 length = c * 512;
978 /* but accept any length that fits if checksum okay */
979 if (!length || start + length > upper || !romchecksum(rom, length))
980 continue;
982 adapter_rom_resources[i].start = start;
983 adapter_rom_resources[i].end = start + length - 1;
984 request_resource(&iomem_resource, &adapter_rom_resources[i]);
986 start = adapter_rom_resources[i++].end & ~2047UL;