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>
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>
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>
63 #include <asm/io_apic.h>
67 #include <setup_arch.h>
68 #include <asm/bios_ebda.h>
69 #include <asm/cacheflush.h>
70 #include <asm/processor.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;
83 static struct resource data_resource
= {
84 .name
= "Kernel data",
87 .flags
= IORESOURCE_BUSY
| IORESOURCE_MEM
90 static struct resource code_resource
= {
91 .name
= "Kernel code",
94 .flags
= IORESOURCE_BUSY
| IORESOURCE_MEM
97 static struct resource bss_resource
= {
101 .flags
= IORESOURCE_BUSY
| IORESOURCE_MEM
104 static struct resource video_ram_resource
= {
105 .name
= "Video RAM area",
108 .flags
= IORESOURCE_BUSY
| IORESOURCE_MEM
111 static struct resource standard_io_resources
[] = { {
115 .flags
= IORESOURCE_BUSY
| IORESOURCE_IO
120 .flags
= IORESOURCE_BUSY
| IORESOURCE_IO
125 .flags
= IORESOURCE_BUSY
| IORESOURCE_IO
130 .flags
= IORESOURCE_BUSY
| IORESOURCE_IO
135 .flags
= IORESOURCE_BUSY
| IORESOURCE_IO
140 .flags
= IORESOURCE_BUSY
| IORESOURCE_IO
142 .name
= "dma page reg",
145 .flags
= IORESOURCE_BUSY
| IORESOURCE_IO
150 .flags
= IORESOURCE_BUSY
| IORESOURCE_IO
155 .flags
= IORESOURCE_BUSY
| IORESOURCE_IO
160 .flags
= IORESOURCE_BUSY
| IORESOURCE_IO
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
;
174 unsigned long mmu_cr4_features
= X86_CR4_PAE
;
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 */
185 /* user-defined highmem size */
186 static unsigned int highmem_pages
= -1;
192 char dmi_alloc_data
[DMI_MAX_DATA
];
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
);
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
;
223 struct boot_params boot_params
;
226 #if defined(CONFIG_EDD) || defined(CONFIG_EDD_MODULE)
228 #ifdef CONFIG_EDD_MODULE
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
;
245 static inline void copy_edd(void)
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
)
259 elfcorehdr_addr
= memparse(arg
, &arg
);
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
)
275 highmem_pages
= memparse(arg
, &arg
) >> PAGE_SHIFT
;
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
)
290 __VMALLOC_RESERVE
= memparse(arg
, &arg
);
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
;
307 address
= memparse(arg
, &arg
);
308 reserve_top_address(address
);
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
));
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",
335 if (max_pfn
> MAX_NONPAE_PFN
)
336 printk(KERN_WARNING
"Use a HIGHMEM64G enabled kernel.\n");
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 */
350 if (highmem_pages
== -1)
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
));
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
));
362 max_low_pfn
-= highmem_pages
;
366 printk(KERN_ERR
"ignoring highmem size on non-highmem kernel!\n");
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;
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;
399 #ifdef CONFIG_FLATMEM
400 max_mapnr
= num_physpages
;
402 printk(KERN_NOTICE
"%ldMB LOWMEM available.\n",
403 pages_to_mb(max_low_pfn
));
405 setup_bootmem_allocator();
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
);
422 e820_register_active_regions(0, 0, max_low_pfn
);
425 free_area_init_nodes(max_zone_pfns
);
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
;
444 if (!boot_params
.hdr
.type_of_loader
||
445 !ramdisk_image
|| !ramdisk_size
)
446 return; /* No initrd provided by bootloader */
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");
457 printk(KERN_INFO
"old RAMDISK: %08llx - %08llx\n", ramdisk_image
,
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
;
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
,
477 if (ramdisk_here
== -1ULL)
478 panic("Cannot find place for new RAMDISK of size %lld\n",
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
,
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
;
501 unsigned long slop
, clen
, mapaddr
;
504 if (!do_relocate_initrd
)
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
);
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
;
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
);
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)
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
,
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
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)
594 for_each_online_node(nid
) {
596 memset(NODE_DATA(nid
), 0, sizeof(struct pglist_data
));
601 static void set_mca_bus(int x
)
606 static void set_mca_bus(int x
) { }
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
)
621 unsigned long max_low_pfn
;
623 memcpy(&boot_cpu_data
, &new_cpu_data
, sizeof(new_cpu_data
));
624 pre_setup_arch_hook();
626 early_ioremap_init();
627 reserve_setup_data();
630 if (!strncmp((char *)&boot_params
.efi_info
.efi_loader_signature
,
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);
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;
680 if (acpi_mps_check()){
681 enable_local_apic
= -1;
682 clear_cpu_cap(&boot_cpu_data
, X86_FEATURE_APIC
);
685 finish_e820_parsing();
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
;
700 if (ppro_with_ram_bug()) {
701 e820_update_range(0x70000000ULL
, 0x40000ULL
, E820_RAM
,
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 */
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();
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.
741 max_low_pfn
= setup_memory();
743 #ifdef CONFIG_ACPI_SLEEP
745 * Reserve low memory region for sleep support.
747 acpi_reserve_bootmem();
749 #ifdef CONFIG_X86_FIND_SMP_CONFIG
751 * Find and reserve possible boot-time SMP configuration:
755 reserve_crashkernel();
757 reserve_ibft_region();
759 #ifdef CONFIG_KVM_CLOCK
765 * Must be after max_low_pfn is determined, and before kernel
766 * pagetables are setup.
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.
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();
794 * NOTE: at this point the bootmem allocator is fully available.
797 #ifdef CONFIG_BLK_DEV_INITRD
801 remapped_pgdat_init();
805 paravirt_post_allocator_init();
807 #ifdef CONFIG_X86_GENERICARCH
808 generic_apic_probe();
815 #if defined(CONFIG_X86_MPPARSE) || defined(CONFIG_X86_VISWS)
816 if (smp_found_config
)
819 #if defined(CONFIG_SMP) && defined(CONFIG_X86_PC)
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");
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
]);
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
;
846 static struct resource system_rom_resource
= {
847 .name
= "System ROM",
850 .flags
= IORESOURCE_BUSY
| IORESOURCE_READONLY
| IORESOURCE_MEM
853 static struct resource extension_rom_resource
= {
854 .name
= "Extension ROM",
857 .flags
= IORESOURCE_BUSY
| IORESOURCE_READONLY
| IORESOURCE_MEM
860 static struct resource adapter_rom_resources
[] = { {
861 .name
= "Adapter ROM",
864 .flags
= IORESOURCE_BUSY
| IORESOURCE_READONLY
| IORESOURCE_MEM
866 .name
= "Adapter ROM",
869 .flags
= IORESOURCE_BUSY
| IORESOURCE_READONLY
| IORESOURCE_MEM
871 .name
= "Adapter ROM",
874 .flags
= IORESOURCE_BUSY
| IORESOURCE_READONLY
| IORESOURCE_MEM
876 .name
= "Adapter ROM",
879 .flags
= IORESOURCE_BUSY
| IORESOURCE_READONLY
| IORESOURCE_MEM
881 .name
= "Adapter ROM",
884 .flags
= IORESOURCE_BUSY
| IORESOURCE_READONLY
| IORESOURCE_MEM
886 .name
= "Adapter ROM",
889 .flags
= IORESOURCE_BUSY
| IORESOURCE_READONLY
| IORESOURCE_MEM
892 static struct resource video_rom_resource
= {
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
;
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
--)
915 return !length
&& !sum
;
918 static void __init
probe_roms(void)
920 const unsigned char *rom
;
921 unsigned long start
, length
, upper
;
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
))
932 video_rom_resource
.start
= start
;
934 if (probe_kernel_address(rom
+ 2, c
) != 0)
937 /* 0 < length <= 0x7f * 512, historically */
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
);
948 start
= (video_rom_resource
.end
+ 1 + 2047) & ~2047UL;
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
))
972 if (probe_kernel_address(rom
+ 2, c
) != 0)
975 /* 0 < length <= 0x7f * 512, historically */
978 /* but accept any length that fits if checksum okay */
979 if (!length
|| start
+ length
> upper
|| !romchecksum(rom
, length
))
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;