]> git.karo-electronics.de Git - karo-tx-linux.git/blob - arch/i386/kernel/setup.c
[PATCH] i386: Move e820/efi memmap walking code to e820.c
[karo-tx-linux.git] / arch / i386 / kernel / setup.c
1 /*
2  *  linux/arch/i386/kernel/setup.c
3  *
4  *  Copyright (C) 1995  Linus Torvalds
5  *
6  *  Support of BIGMEM added by Gerhard Wichert, Siemens AG, July 1999
7  *
8  *  Memory region support
9  *      David Parsons <orc@pell.chi.il.us>, July-August 1999
10  *
11  *  Added E820 sanitization routine (removes overlapping memory regions);
12  *  Brian Moyle <bmoyle@mvista.com>, February 2001
13  *
14  * Moved CPU detection code to cpu/${cpu}.c
15  *    Patrick Mochel <mochel@osdl.org>, March 2002
16  *
17  *  Provisions for empty E820 memory regions (reported by certain BIOSes).
18  *  Alex Achenbach <xela@slit.de>, December 2002.
19  *
20  */
21
22 /*
23  * This file handles the architecture-dependent parts of initialization
24  */
25
26 #include <linux/sched.h>
27 #include <linux/mm.h>
28 #include <linux/mmzone.h>
29 #include <linux/screen_info.h>
30 #include <linux/ioport.h>
31 #include <linux/acpi.h>
32 #include <linux/apm_bios.h>
33 #include <linux/initrd.h>
34 #include <linux/bootmem.h>
35 #include <linux/seq_file.h>
36 #include <linux/platform_device.h>
37 #include <linux/console.h>
38 #include <linux/mca.h>
39 #include <linux/root_dev.h>
40 #include <linux/highmem.h>
41 #include <linux/module.h>
42 #include <linux/efi.h>
43 #include <linux/init.h>
44 #include <linux/edd.h>
45 #include <linux/nodemask.h>
46 #include <linux/kexec.h>
47 #include <linux/crash_dump.h>
48 #include <linux/dmi.h>
49 #include <linux/pfn.h>
50
51 #include <video/edid.h>
52
53 #include <asm/apic.h>
54 #include <asm/e820.h>
55 #include <asm/mpspec.h>
56 #include <asm/mmzone.h>
57 #include <asm/setup.h>
58 #include <asm/arch_hooks.h>
59 #include <asm/sections.h>
60 #include <asm/io_apic.h>
61 #include <asm/ist.h>
62 #include <asm/io.h>
63 #include <setup_arch.h>
64 #include <bios_ebda.h>
65
66 /* This value is set up by the early boot code to point to the value
67    immediately after the boot time page tables.  It contains a *physical*
68    address, and must not be in the .bss segment! */
69 unsigned long init_pg_tables_end __initdata = ~0UL;
70
71 int disable_pse __devinitdata = 0;
72
73 /*
74  * Machine setup..
75  */
76 extern struct e820map e820;
77 extern struct resource code_resource;
78 extern struct resource data_resource;
79
80 /* cpu data as detected by the assembly code in head.S */
81 struct cpuinfo_x86 new_cpu_data __initdata = { 0, 0, 0, 0, -1, 1, 0, 0, -1 };
82 /* common cpu data for all cpus */
83 struct cpuinfo_x86 boot_cpu_data __read_mostly = { 0, 0, 0, 0, -1, 1, 0, 0, -1 };
84 EXPORT_SYMBOL(boot_cpu_data);
85
86 unsigned long mmu_cr4_features;
87
88 /* for MCA, but anyone else can use it if they want */
89 unsigned int machine_id;
90 #ifdef CONFIG_MCA
91 EXPORT_SYMBOL(machine_id);
92 #endif
93 unsigned int machine_submodel_id;
94 unsigned int BIOS_revision;
95 unsigned int mca_pentium_flag;
96
97 /* Boot loader ID as an integer, for the benefit of proc_dointvec */
98 int bootloader_type;
99
100 /* user-defined highmem size */
101 static unsigned int highmem_pages = -1;
102
103 /*
104  * Setup options
105  */
106 struct drive_info_struct { char dummy[32]; } drive_info;
107 #if defined(CONFIG_BLK_DEV_IDE) || defined(CONFIG_BLK_DEV_HD) || \
108     defined(CONFIG_BLK_DEV_IDE_MODULE) || defined(CONFIG_BLK_DEV_HD_MODULE)
109 EXPORT_SYMBOL(drive_info);
110 #endif
111 struct screen_info screen_info;
112 EXPORT_SYMBOL(screen_info);
113 struct apm_info apm_info;
114 EXPORT_SYMBOL(apm_info);
115 struct sys_desc_table_struct {
116         unsigned short length;
117         unsigned char table[0];
118 };
119 struct edid_info edid_info;
120 EXPORT_SYMBOL_GPL(edid_info);
121 struct ist_info ist_info;
122 #if defined(CONFIG_X86_SPEEDSTEP_SMI) || \
123         defined(CONFIG_X86_SPEEDSTEP_SMI_MODULE)
124 EXPORT_SYMBOL(ist_info);
125 #endif
126
127 extern void early_cpu_init(void);
128 extern int root_mountflags;
129
130 unsigned long saved_videomode;
131
132 #define RAMDISK_IMAGE_START_MASK        0x07FF
133 #define RAMDISK_PROMPT_FLAG             0x8000
134 #define RAMDISK_LOAD_FLAG               0x4000  
135
136 static char command_line[COMMAND_LINE_SIZE];
137
138 unsigned char __initdata boot_params[PARAM_SIZE];
139
140 static void __init limit_regions(unsigned long long size)
141 {
142         unsigned long long current_addr = 0;
143         int i;
144
145         if (efi_enabled) {
146                 efi_memory_desc_t *md;
147                 void *p;
148
149                 for (p = memmap.map, i = 0; p < memmap.map_end;
150                         p += memmap.desc_size, i++) {
151                         md = p;
152                         current_addr = md->phys_addr + (md->num_pages << 12);
153                         if (md->type == EFI_CONVENTIONAL_MEMORY) {
154                                 if (current_addr >= size) {
155                                         md->num_pages -=
156                                                 (((current_addr-size) + PAGE_SIZE-1) >> PAGE_SHIFT);
157                                         memmap.nr_map = i + 1;
158                                         return;
159                                 }
160                         }
161                 }
162         }
163         for (i = 0; i < e820.nr_map; i++) {
164                 current_addr = e820.map[i].addr + e820.map[i].size;
165                 if (current_addr < size)
166                         continue;
167
168                 if (e820.map[i].type != E820_RAM)
169                         continue;
170
171                 if (e820.map[i].addr >= size) {
172                         /*
173                          * This region starts past the end of the
174                          * requested size, skip it completely.
175                          */
176                         e820.nr_map = i;
177                 } else {
178                         e820.nr_map = i + 1;
179                         e820.map[i].size -= current_addr - size;
180                 }
181                 return;
182         }
183 }
184
185 #define E820_DEBUG      1
186
187 static void __init print_memory_map(char *who)
188 {
189         int i;
190
191         for (i = 0; i < e820.nr_map; i++) {
192                 printk(" %s: %016Lx - %016Lx ", who,
193                         e820.map[i].addr,
194                         e820.map[i].addr + e820.map[i].size);
195                 switch (e820.map[i].type) {
196                 case E820_RAM:  printk("(usable)\n");
197                                 break;
198                 case E820_RESERVED:
199                                 printk("(reserved)\n");
200                                 break;
201                 case E820_ACPI:
202                                 printk("(ACPI data)\n");
203                                 break;
204                 case E820_NVS:
205                                 printk("(ACPI NVS)\n");
206                                 break;
207                 default:        printk("type %lu\n", e820.map[i].type);
208                                 break;
209                 }
210         }
211 }
212
213 #if defined(CONFIG_EDD) || defined(CONFIG_EDD_MODULE)
214 struct edd edd;
215 #ifdef CONFIG_EDD_MODULE
216 EXPORT_SYMBOL(edd);
217 #endif
218 /**
219  * copy_edd() - Copy the BIOS EDD information
220  *              from boot_params into a safe place.
221  *
222  */
223 static inline void copy_edd(void)
224 {
225      memcpy(edd.mbr_signature, EDD_MBR_SIGNATURE, sizeof(edd.mbr_signature));
226      memcpy(edd.edd_info, EDD_BUF, sizeof(edd.edd_info));
227      edd.mbr_signature_nr = EDD_MBR_SIG_NR;
228      edd.edd_info_nr = EDD_NR;
229 }
230 #else
231 static inline void copy_edd(void)
232 {
233 }
234 #endif
235
236 static int __initdata user_defined_memmap = 0;
237
238 /*
239  * "mem=nopentium" disables the 4MB page tables.
240  * "mem=XXX[kKmM]" defines a memory region from HIGH_MEM
241  * to <mem>, overriding the bios size.
242  * "memmap=XXX[KkmM]@XXX[KkmM]" defines a memory region from
243  * <start> to <start>+<mem>, overriding the bios size.
244  *
245  * HPA tells me bootloaders need to parse mem=, so no new
246  * option should be mem=  [also see Documentation/i386/boot.txt]
247  */
248 static int __init parse_mem(char *arg)
249 {
250         if (!arg)
251                 return -EINVAL;
252
253         if (strcmp(arg, "nopentium") == 0) {
254                 clear_bit(X86_FEATURE_PSE, boot_cpu_data.x86_capability);
255                 disable_pse = 1;
256         } else {
257                 /* If the user specifies memory size, we
258                  * limit the BIOS-provided memory map to
259                  * that size. exactmap can be used to specify
260                  * the exact map. mem=number can be used to
261                  * trim the existing memory map.
262                  */
263                 unsigned long long mem_size;
264  
265                 mem_size = memparse(arg, &arg);
266                 limit_regions(mem_size);
267                 user_defined_memmap = 1;
268         }
269         return 0;
270 }
271 early_param("mem", parse_mem);
272
273 static int __init parse_memmap(char *arg)
274 {
275         if (!arg)
276                 return -EINVAL;
277
278         if (strcmp(arg, "exactmap") == 0) {
279 #ifdef CONFIG_CRASH_DUMP
280                 /* If we are doing a crash dump, we
281                  * still need to know the real mem
282                  * size before original memory map is
283                  * reset.
284                  */
285                 find_max_pfn();
286                 saved_max_pfn = max_pfn;
287 #endif
288                 e820.nr_map = 0;
289                 user_defined_memmap = 1;
290         } else {
291                 /* If the user specifies memory size, we
292                  * limit the BIOS-provided memory map to
293                  * that size. exactmap can be used to specify
294                  * the exact map. mem=number can be used to
295                  * trim the existing memory map.
296                  */
297                 unsigned long long start_at, mem_size;
298
299                 mem_size = memparse(arg, &arg);
300                 if (*arg == '@') {
301                         start_at = memparse(arg+1, &arg);
302                         add_memory_region(start_at, mem_size, E820_RAM);
303                 } else if (*arg == '#') {
304                         start_at = memparse(arg+1, &arg);
305                         add_memory_region(start_at, mem_size, E820_ACPI);
306                 } else if (*arg == '$') {
307                         start_at = memparse(arg+1, &arg);
308                         add_memory_region(start_at, mem_size, E820_RESERVED);
309                 } else {
310                         limit_regions(mem_size);
311                         user_defined_memmap = 1;
312                 }
313         }
314         return 0;
315 }
316 early_param("memmap", parse_memmap);
317
318 #ifdef CONFIG_PROC_VMCORE
319 /* elfcorehdr= specifies the location of elf core header
320  * stored by the crashed kernel.
321  */
322 static int __init parse_elfcorehdr(char *arg)
323 {
324         if (!arg)
325                 return -EINVAL;
326
327         elfcorehdr_addr = memparse(arg, &arg);
328         return 0;
329 }
330 early_param("elfcorehdr", parse_elfcorehdr);
331 #endif /* CONFIG_PROC_VMCORE */
332
333 /*
334  * highmem=size forces highmem to be exactly 'size' bytes.
335  * This works even on boxes that have no highmem otherwise.
336  * This also works to reduce highmem size on bigger boxes.
337  */
338 static int __init parse_highmem(char *arg)
339 {
340         if (!arg)
341                 return -EINVAL;
342
343         highmem_pages = memparse(arg, &arg) >> PAGE_SHIFT;
344         return 0;
345 }
346 early_param("highmem", parse_highmem);
347
348 /*
349  * vmalloc=size forces the vmalloc area to be exactly 'size'
350  * bytes. This can be used to increase (or decrease) the
351  * vmalloc area - the default is 128m.
352  */
353 static int __init parse_vmalloc(char *arg)
354 {
355         if (!arg)
356                 return -EINVAL;
357
358         __VMALLOC_RESERVE = memparse(arg, &arg);
359         return 0;
360 }
361 early_param("vmalloc", parse_vmalloc);
362
363 /*
364  * reservetop=size reserves a hole at the top of the kernel address space which
365  * a hypervisor can load into later.  Needed for dynamically loaded hypervisors,
366  * so relocating the fixmap can be done before paging initialization.
367  */
368 static int __init parse_reservetop(char *arg)
369 {
370         unsigned long address;
371
372         if (!arg)
373                 return -EINVAL;
374
375         address = memparse(arg, &arg);
376         reserve_top_address(address);
377         return 0;
378 }
379 early_param("reservetop", parse_reservetop);
380
381  /*
382   * This function checks if the entire range <start,end> is mapped with type.
383   *
384   * Note: this function only works correct if the e820 table is sorted and
385   * not-overlapping, which is the case
386   */
387 int __init
388 e820_all_mapped(unsigned long s, unsigned long e, unsigned type)
389 {
390         u64 start = s;
391         u64 end = e;
392         int i;
393         for (i = 0; i < e820.nr_map; i++) {
394                 struct e820entry *ei = &e820.map[i];
395                 if (type && ei->type != type)
396                         continue;
397                 /* is the region (part) in overlap with the current region ?*/
398                 if (ei->addr >= end || ei->addr + ei->size <= start)
399                         continue;
400                 /* if the region is at the beginning of <start,end> we move
401                  * start to the end of the region since it's ok until there
402                  */
403                 if (ei->addr <= start)
404                         start = ei->addr + ei->size;
405                 /* if start is now at or beyond end, we're done, full
406                  * coverage */
407                 if (start >= end)
408                         return 1; /* we're done */
409         }
410         return 0;
411 }
412
413 /*
414  * Determine low and high memory ranges:
415  */
416 unsigned long __init find_max_low_pfn(void)
417 {
418         unsigned long max_low_pfn;
419
420         max_low_pfn = max_pfn;
421         if (max_low_pfn > MAXMEM_PFN) {
422                 if (highmem_pages == -1)
423                         highmem_pages = max_pfn - MAXMEM_PFN;
424                 if (highmem_pages + MAXMEM_PFN < max_pfn)
425                         max_pfn = MAXMEM_PFN + highmem_pages;
426                 if (highmem_pages + MAXMEM_PFN > max_pfn) {
427                         printk("only %luMB highmem pages available, ignoring highmem size of %uMB.\n", pages_to_mb(max_pfn - MAXMEM_PFN), pages_to_mb(highmem_pages));
428                         highmem_pages = 0;
429                 }
430                 max_low_pfn = MAXMEM_PFN;
431 #ifndef CONFIG_HIGHMEM
432                 /* Maximum memory usable is what is directly addressable */
433                 printk(KERN_WARNING "Warning only %ldMB will be used.\n",
434                                         MAXMEM>>20);
435                 if (max_pfn > MAX_NONPAE_PFN)
436                         printk(KERN_WARNING "Use a PAE enabled kernel.\n");
437                 else
438                         printk(KERN_WARNING "Use a HIGHMEM enabled kernel.\n");
439                 max_pfn = MAXMEM_PFN;
440 #else /* !CONFIG_HIGHMEM */
441 #ifndef CONFIG_X86_PAE
442                 if (max_pfn > MAX_NONPAE_PFN) {
443                         max_pfn = MAX_NONPAE_PFN;
444                         printk(KERN_WARNING "Warning only 4GB will be used.\n");
445                         printk(KERN_WARNING "Use a PAE enabled kernel.\n");
446                 }
447 #endif /* !CONFIG_X86_PAE */
448 #endif /* !CONFIG_HIGHMEM */
449         } else {
450                 if (highmem_pages == -1)
451                         highmem_pages = 0;
452 #ifdef CONFIG_HIGHMEM
453                 if (highmem_pages >= max_pfn) {
454                         printk(KERN_ERR "highmem size specified (%uMB) is bigger than pages available (%luMB)!.\n", pages_to_mb(highmem_pages), pages_to_mb(max_pfn));
455                         highmem_pages = 0;
456                 }
457                 if (highmem_pages) {
458                         if (max_low_pfn-highmem_pages < 64*1024*1024/PAGE_SIZE){
459                                 printk(KERN_ERR "highmem size %uMB results in smaller than 64MB lowmem, ignoring it.\n", pages_to_mb(highmem_pages));
460                                 highmem_pages = 0;
461                         }
462                         max_low_pfn -= highmem_pages;
463                 }
464 #else
465                 if (highmem_pages)
466                         printk(KERN_ERR "ignoring highmem size on non-highmem kernel!\n");
467 #endif
468         }
469         return max_low_pfn;
470 }
471
472 /*
473  * workaround for Dell systems that neglect to reserve EBDA
474  */
475 static void __init reserve_ebda_region(void)
476 {
477         unsigned int addr;
478         addr = get_bios_ebda();
479         if (addr)
480                 reserve_bootmem(addr, PAGE_SIZE);       
481 }
482
483 #ifndef CONFIG_NEED_MULTIPLE_NODES
484 void __init setup_bootmem_allocator(void);
485 static unsigned long __init setup_memory(void)
486 {
487         /*
488          * partially used pages are not usable - thus
489          * we are rounding upwards:
490          */
491         min_low_pfn = PFN_UP(init_pg_tables_end);
492
493         find_max_pfn();
494
495         max_low_pfn = find_max_low_pfn();
496
497 #ifdef CONFIG_HIGHMEM
498         highstart_pfn = highend_pfn = max_pfn;
499         if (max_pfn > max_low_pfn) {
500                 highstart_pfn = max_low_pfn;
501         }
502         printk(KERN_NOTICE "%ldMB HIGHMEM available.\n",
503                 pages_to_mb(highend_pfn - highstart_pfn));
504         num_physpages = highend_pfn;
505         high_memory = (void *) __va(highstart_pfn * PAGE_SIZE - 1) + 1;
506 #else
507         num_physpages = max_low_pfn;
508         high_memory = (void *) __va(max_low_pfn * PAGE_SIZE - 1) + 1;
509 #endif
510 #ifdef CONFIG_FLATMEM
511         max_mapnr = num_physpages;
512 #endif
513         printk(KERN_NOTICE "%ldMB LOWMEM available.\n",
514                         pages_to_mb(max_low_pfn));
515
516         setup_bootmem_allocator();
517
518         return max_low_pfn;
519 }
520
521 void __init zone_sizes_init(void)
522 {
523         unsigned long max_zone_pfns[MAX_NR_ZONES];
524         memset(max_zone_pfns, 0, sizeof(max_zone_pfns));
525         max_zone_pfns[ZONE_DMA] =
526                 virt_to_phys((char *)MAX_DMA_ADDRESS) >> PAGE_SHIFT;
527         max_zone_pfns[ZONE_NORMAL] = max_low_pfn;
528 #ifdef CONFIG_HIGHMEM
529         max_zone_pfns[ZONE_HIGHMEM] = highend_pfn;
530         add_active_range(0, 0, highend_pfn);
531 #else
532         add_active_range(0, 0, max_low_pfn);
533 #endif
534
535         free_area_init_nodes(max_zone_pfns);
536 }
537 #else
538 extern unsigned long __init setup_memory(void);
539 extern void zone_sizes_init(void);
540 #endif /* !CONFIG_NEED_MULTIPLE_NODES */
541
542 void __init setup_bootmem_allocator(void)
543 {
544         unsigned long bootmap_size;
545         /*
546          * Initialize the boot-time allocator (with low memory only):
547          */
548         bootmap_size = init_bootmem(min_low_pfn, max_low_pfn);
549
550         register_bootmem_low_pages(max_low_pfn);
551
552         /*
553          * Reserve the bootmem bitmap itself as well. We do this in two
554          * steps (first step was init_bootmem()) because this catches
555          * the (very unlikely) case of us accidentally initializing the
556          * bootmem allocator with an invalid RAM area.
557          */
558         reserve_bootmem(__pa_symbol(_text), (PFN_PHYS(min_low_pfn) +
559                          bootmap_size + PAGE_SIZE-1) - __pa_symbol(_text));
560
561         /*
562          * reserve physical page 0 - it's a special BIOS page on many boxes,
563          * enabling clean reboots, SMP operation, laptop functions.
564          */
565         reserve_bootmem(0, PAGE_SIZE);
566
567         /* reserve EBDA region, it's a 4K region */
568         reserve_ebda_region();
569
570     /* could be an AMD 768MPX chipset. Reserve a page  before VGA to prevent
571        PCI prefetch into it (errata #56). Usually the page is reserved anyways,
572        unless you have no PS/2 mouse plugged in. */
573         if (boot_cpu_data.x86_vendor == X86_VENDOR_AMD &&
574             boot_cpu_data.x86 == 6)
575              reserve_bootmem(0xa0000 - 4096, 4096);
576
577 #ifdef CONFIG_SMP
578         /*
579          * But first pinch a few for the stack/trampoline stuff
580          * FIXME: Don't need the extra page at 4K, but need to fix
581          * trampoline before removing it. (see the GDT stuff)
582          */
583         reserve_bootmem(PAGE_SIZE, PAGE_SIZE);
584 #endif
585 #ifdef CONFIG_ACPI_SLEEP
586         /*
587          * Reserve low memory region for sleep support.
588          */
589         acpi_reserve_bootmem();
590 #endif
591 #ifdef CONFIG_X86_FIND_SMP_CONFIG
592         /*
593          * Find and reserve possible boot-time SMP configuration:
594          */
595         find_smp_config();
596 #endif
597         numa_kva_reserve();
598 #ifdef CONFIG_BLK_DEV_INITRD
599         if (LOADER_TYPE && INITRD_START) {
600                 if (INITRD_START + INITRD_SIZE <= (max_low_pfn << PAGE_SHIFT)) {
601                         reserve_bootmem(INITRD_START, INITRD_SIZE);
602                         initrd_start =
603                                 INITRD_START ? INITRD_START + PAGE_OFFSET : 0;
604                         initrd_end = initrd_start+INITRD_SIZE;
605                 }
606                 else {
607                         printk(KERN_ERR "initrd extends beyond end of memory "
608                             "(0x%08lx > 0x%08lx)\ndisabling initrd\n",
609                             INITRD_START + INITRD_SIZE,
610                             max_low_pfn << PAGE_SHIFT);
611                         initrd_start = 0;
612                 }
613         }
614 #endif
615 #ifdef CONFIG_KEXEC
616         if (crashk_res.start != crashk_res.end)
617                 reserve_bootmem(crashk_res.start,
618                         crashk_res.end - crashk_res.start + 1);
619 #endif
620 }
621
622 /*
623  * The node 0 pgdat is initialized before all of these because
624  * it's needed for bootmem.  node>0 pgdats have their virtual
625  * space allocated before the pagetables are in place to access
626  * them, so they can't be cleared then.
627  *
628  * This should all compile down to nothing when NUMA is off.
629  */
630 void __init remapped_pgdat_init(void)
631 {
632         int nid;
633
634         for_each_online_node(nid) {
635                 if (nid != 0)
636                         memset(NODE_DATA(nid), 0, sizeof(struct pglist_data));
637         }
638 }
639
640 #ifdef CONFIG_MCA
641 static void set_mca_bus(int x)
642 {
643         MCA_bus = x;
644 }
645 #else
646 static void set_mca_bus(int x) { }
647 #endif
648
649 /*
650  * Determine if we were loaded by an EFI loader.  If so, then we have also been
651  * passed the efi memmap, systab, etc., so we should use these data structures
652  * for initialization.  Note, the efi init code path is determined by the
653  * global efi_enabled. This allows the same kernel image to be used on existing
654  * systems (with a traditional BIOS) as well as on EFI systems.
655  */
656 void __init setup_arch(char **cmdline_p)
657 {
658         unsigned long max_low_pfn;
659
660         memcpy(&boot_cpu_data, &new_cpu_data, sizeof(new_cpu_data));
661         pre_setup_arch_hook();
662         early_cpu_init();
663
664         /*
665          * FIXME: This isn't an official loader_type right
666          * now but does currently work with elilo.
667          * If we were configured as an EFI kernel, check to make
668          * sure that we were loaded correctly from elilo and that
669          * the system table is valid.  If not, then initialize normally.
670          */
671 #ifdef CONFIG_EFI
672         if ((LOADER_TYPE == 0x50) && EFI_SYSTAB)
673                 efi_enabled = 1;
674 #endif
675
676         ROOT_DEV = old_decode_dev(ORIG_ROOT_DEV);
677         drive_info = DRIVE_INFO;
678         screen_info = SCREEN_INFO;
679         edid_info = EDID_INFO;
680         apm_info.bios = APM_BIOS_INFO;
681         ist_info = IST_INFO;
682         saved_videomode = VIDEO_MODE;
683         if( SYS_DESC_TABLE.length != 0 ) {
684                 set_mca_bus(SYS_DESC_TABLE.table[3] & 0x2);
685                 machine_id = SYS_DESC_TABLE.table[0];
686                 machine_submodel_id = SYS_DESC_TABLE.table[1];
687                 BIOS_revision = SYS_DESC_TABLE.table[2];
688         }
689         bootloader_type = LOADER_TYPE;
690
691 #ifdef CONFIG_BLK_DEV_RAM
692         rd_image_start = RAMDISK_FLAGS & RAMDISK_IMAGE_START_MASK;
693         rd_prompt = ((RAMDISK_FLAGS & RAMDISK_PROMPT_FLAG) != 0);
694         rd_doload = ((RAMDISK_FLAGS & RAMDISK_LOAD_FLAG) != 0);
695 #endif
696         ARCH_SETUP
697         if (efi_enabled)
698                 efi_init();
699         else {
700                 printk(KERN_INFO "BIOS-provided physical RAM map:\n");
701                 print_memory_map(machine_specific_memory_setup());
702         }
703
704         copy_edd();
705
706         if (!MOUNT_ROOT_RDONLY)
707                 root_mountflags &= ~MS_RDONLY;
708         init_mm.start_code = (unsigned long) _text;
709         init_mm.end_code = (unsigned long) _etext;
710         init_mm.end_data = (unsigned long) _edata;
711         init_mm.brk = init_pg_tables_end + PAGE_OFFSET;
712
713         code_resource.start = virt_to_phys(_text);
714         code_resource.end = virt_to_phys(_etext)-1;
715         data_resource.start = virt_to_phys(_etext);
716         data_resource.end = virt_to_phys(_edata)-1;
717
718         parse_early_param();
719
720         if (user_defined_memmap) {
721                 printk(KERN_INFO "user-defined physical RAM map:\n");
722                 print_memory_map("user");
723         }
724
725         strlcpy(command_line, saved_command_line, COMMAND_LINE_SIZE);
726         *cmdline_p = command_line;
727
728         max_low_pfn = setup_memory();
729
730         /*
731          * NOTE: before this point _nobody_ is allowed to allocate
732          * any memory using the bootmem allocator.  Although the
733          * alloctor is now initialised only the first 8Mb of the kernel
734          * virtual address space has been mapped.  All allocations before
735          * paging_init() has completed must use the alloc_bootmem_low_pages()
736          * variant (which allocates DMA'able memory) and care must be taken
737          * not to exceed the 8Mb limit.
738          */
739
740 #ifdef CONFIG_SMP
741         smp_alloc_memory(); /* AP processor realmode stacks in low memory*/
742 #endif
743         paging_init();
744         remapped_pgdat_init();
745         sparse_init();
746         zone_sizes_init();
747
748         /*
749          * NOTE: at this point the bootmem allocator is fully available.
750          */
751
752         dmi_scan_machine();
753
754 #ifdef CONFIG_X86_GENERICARCH
755         generic_apic_probe();
756 #endif  
757         if (efi_enabled)
758                 efi_map_memmap();
759
760 #ifdef CONFIG_ACPI
761         /*
762          * Parse the ACPI tables for possible boot-time SMP configuration.
763          */
764         acpi_boot_table_init();
765 #endif
766
767 #ifdef CONFIG_PCI
768 #ifdef CONFIG_X86_IO_APIC
769         check_acpi_pci();       /* Checks more than just ACPI actually */
770 #endif
771 #endif
772
773 #ifdef CONFIG_ACPI
774         acpi_boot_init();
775
776 #if defined(CONFIG_SMP) && defined(CONFIG_X86_PC)
777         if (def_to_bigsmp)
778                 printk(KERN_WARNING "More than 8 CPUs detected and "
779                         "CONFIG_X86_PC cannot handle it.\nUse "
780                         "CONFIG_X86_GENERICARCH or CONFIG_X86_BIGSMP.\n");
781 #endif
782 #endif
783 #ifdef CONFIG_X86_LOCAL_APIC
784         if (smp_found_config)
785                 get_smp_config();
786 #endif
787
788         register_memory();
789
790 #ifdef CONFIG_VT
791 #if defined(CONFIG_VGA_CONSOLE)
792         if (!efi_enabled || (efi_mem_type(0xa0000) != EFI_CONVENTIONAL_MEMORY))
793                 conswitchp = &vga_con;
794 #elif defined(CONFIG_DUMMY_CONSOLE)
795         conswitchp = &dummy_con;
796 #endif
797 #endif
798         tsc_init();
799 }
800
801 static __init int add_pcspkr(void)
802 {
803         struct platform_device *pd;
804         int ret;
805
806         pd = platform_device_alloc("pcspkr", -1);
807         if (!pd)
808                 return -ENOMEM;
809
810         ret = platform_device_add(pd);
811         if (ret)
812                 platform_device_put(pd);
813
814         return ret;
815 }
816 device_initcall(add_pcspkr);
817
818 /*
819  * Local Variables:
820  * mode:c
821  * c-file-style:"k&r"
822  * c-basic-offset:8
823  * End:
824  */