ea17567dbe72805a15f4f977e003147aca609daa
[deliverable/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/setup.h>
57 #include <asm/arch_hooks.h>
58 #include <asm/sections.h>
59 #include <asm/io_apic.h>
60 #include <asm/ist.h>
61 #include <asm/io.h>
62 #include <setup_arch.h>
63 #include <bios_ebda.h>
64
65 /* Forward Declaration. */
66 void __init find_max_pfn(void);
67
68 /* This value is set up by the early boot code to point to the value
69 immediately after the boot time page tables. It contains a *physical*
70 address, and must not be in the .bss segment! */
71 unsigned long init_pg_tables_end __initdata = ~0UL;
72
73 int disable_pse __devinitdata = 0;
74
75 /*
76 * Machine setup..
77 */
78
79 #ifdef CONFIG_EFI
80 int efi_enabled = 0;
81 EXPORT_SYMBOL(efi_enabled);
82 #endif
83
84 /* cpu data as detected by the assembly code in head.S */
85 struct cpuinfo_x86 new_cpu_data __initdata = { 0, 0, 0, 0, -1, 1, 0, 0, -1 };
86 /* common cpu data for all cpus */
87 struct cpuinfo_x86 boot_cpu_data __read_mostly = { 0, 0, 0, 0, -1, 1, 0, 0, -1 };
88 EXPORT_SYMBOL(boot_cpu_data);
89
90 unsigned long mmu_cr4_features;
91
92 /* for MCA, but anyone else can use it if they want */
93 unsigned int machine_id;
94 #ifdef CONFIG_MCA
95 EXPORT_SYMBOL(machine_id);
96 #endif
97 unsigned int machine_submodel_id;
98 unsigned int BIOS_revision;
99 unsigned int mca_pentium_flag;
100
101 /* For PCI or other memory-mapped resources */
102 unsigned long pci_mem_start = 0x10000000;
103 #ifdef CONFIG_PCI
104 EXPORT_SYMBOL(pci_mem_start);
105 #endif
106
107 /* Boot loader ID as an integer, for the benefit of proc_dointvec */
108 int bootloader_type;
109
110 /* user-defined highmem size */
111 static unsigned int highmem_pages = -1;
112
113 /*
114 * Setup options
115 */
116 struct drive_info_struct { char dummy[32]; } drive_info;
117 #if defined(CONFIG_BLK_DEV_IDE) || defined(CONFIG_BLK_DEV_HD) || \
118 defined(CONFIG_BLK_DEV_IDE_MODULE) || defined(CONFIG_BLK_DEV_HD_MODULE)
119 EXPORT_SYMBOL(drive_info);
120 #endif
121 struct screen_info screen_info;
122 EXPORT_SYMBOL(screen_info);
123 struct apm_info apm_info;
124 EXPORT_SYMBOL(apm_info);
125 struct sys_desc_table_struct {
126 unsigned short length;
127 unsigned char table[0];
128 };
129 struct edid_info edid_info;
130 EXPORT_SYMBOL_GPL(edid_info);
131 struct ist_info ist_info;
132 #if defined(CONFIG_X86_SPEEDSTEP_SMI) || \
133 defined(CONFIG_X86_SPEEDSTEP_SMI_MODULE)
134 EXPORT_SYMBOL(ist_info);
135 #endif
136 struct e820map e820;
137
138 extern void early_cpu_init(void);
139 extern int root_mountflags;
140
141 unsigned long saved_videomode;
142
143 #define RAMDISK_IMAGE_START_MASK 0x07FF
144 #define RAMDISK_PROMPT_FLAG 0x8000
145 #define RAMDISK_LOAD_FLAG 0x4000
146
147 static char command_line[COMMAND_LINE_SIZE];
148
149 unsigned char __initdata boot_params[PARAM_SIZE];
150
151 static struct resource data_resource = {
152 .name = "Kernel data",
153 .start = 0,
154 .end = 0,
155 .flags = IORESOURCE_BUSY | IORESOURCE_MEM
156 };
157
158 static struct resource code_resource = {
159 .name = "Kernel code",
160 .start = 0,
161 .end = 0,
162 .flags = IORESOURCE_BUSY | IORESOURCE_MEM
163 };
164
165 static struct resource system_rom_resource = {
166 .name = "System ROM",
167 .start = 0xf0000,
168 .end = 0xfffff,
169 .flags = IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM
170 };
171
172 static struct resource extension_rom_resource = {
173 .name = "Extension ROM",
174 .start = 0xe0000,
175 .end = 0xeffff,
176 .flags = IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM
177 };
178
179 static struct resource adapter_rom_resources[] = { {
180 .name = "Adapter ROM",
181 .start = 0xc8000,
182 .end = 0,
183 .flags = IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM
184 }, {
185 .name = "Adapter ROM",
186 .start = 0,
187 .end = 0,
188 .flags = IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM
189 }, {
190 .name = "Adapter ROM",
191 .start = 0,
192 .end = 0,
193 .flags = IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM
194 }, {
195 .name = "Adapter ROM",
196 .start = 0,
197 .end = 0,
198 .flags = IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM
199 }, {
200 .name = "Adapter ROM",
201 .start = 0,
202 .end = 0,
203 .flags = IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM
204 }, {
205 .name = "Adapter ROM",
206 .start = 0,
207 .end = 0,
208 .flags = IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM
209 } };
210
211 #define ADAPTER_ROM_RESOURCES \
212 (sizeof adapter_rom_resources / sizeof adapter_rom_resources[0])
213
214 static struct resource video_rom_resource = {
215 .name = "Video ROM",
216 .start = 0xc0000,
217 .end = 0xc7fff,
218 .flags = IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM
219 };
220
221 static struct resource video_ram_resource = {
222 .name = "Video RAM area",
223 .start = 0xa0000,
224 .end = 0xbffff,
225 .flags = IORESOURCE_BUSY | IORESOURCE_MEM
226 };
227
228 static struct resource standard_io_resources[] = { {
229 .name = "dma1",
230 .start = 0x0000,
231 .end = 0x001f,
232 .flags = IORESOURCE_BUSY | IORESOURCE_IO
233 }, {
234 .name = "pic1",
235 .start = 0x0020,
236 .end = 0x0021,
237 .flags = IORESOURCE_BUSY | IORESOURCE_IO
238 }, {
239 .name = "timer0",
240 .start = 0x0040,
241 .end = 0x0043,
242 .flags = IORESOURCE_BUSY | IORESOURCE_IO
243 }, {
244 .name = "timer1",
245 .start = 0x0050,
246 .end = 0x0053,
247 .flags = IORESOURCE_BUSY | IORESOURCE_IO
248 }, {
249 .name = "keyboard",
250 .start = 0x0060,
251 .end = 0x006f,
252 .flags = IORESOURCE_BUSY | IORESOURCE_IO
253 }, {
254 .name = "dma page reg",
255 .start = 0x0080,
256 .end = 0x008f,
257 .flags = IORESOURCE_BUSY | IORESOURCE_IO
258 }, {
259 .name = "pic2",
260 .start = 0x00a0,
261 .end = 0x00a1,
262 .flags = IORESOURCE_BUSY | IORESOURCE_IO
263 }, {
264 .name = "dma2",
265 .start = 0x00c0,
266 .end = 0x00df,
267 .flags = IORESOURCE_BUSY | IORESOURCE_IO
268 }, {
269 .name = "fpu",
270 .start = 0x00f0,
271 .end = 0x00ff,
272 .flags = IORESOURCE_BUSY | IORESOURCE_IO
273 } };
274
275 #define STANDARD_IO_RESOURCES \
276 (sizeof standard_io_resources / sizeof standard_io_resources[0])
277
278 #define romsignature(x) (*(unsigned short *)(x) == 0xaa55)
279
280 static int __init romchecksum(unsigned char *rom, unsigned long length)
281 {
282 unsigned char *p, sum = 0;
283
284 for (p = rom; p < rom + length; p++)
285 sum += *p;
286 return sum == 0;
287 }
288
289 static void __init probe_roms(void)
290 {
291 unsigned long start, length, upper;
292 unsigned char *rom;
293 int i;
294
295 /* video rom */
296 upper = adapter_rom_resources[0].start;
297 for (start = video_rom_resource.start; start < upper; start += 2048) {
298 rom = isa_bus_to_virt(start);
299 if (!romsignature(rom))
300 continue;
301
302 video_rom_resource.start = start;
303
304 /* 0 < length <= 0x7f * 512, historically */
305 length = rom[2] * 512;
306
307 /* if checksum okay, trust length byte */
308 if (length && romchecksum(rom, length))
309 video_rom_resource.end = start + length - 1;
310
311 request_resource(&iomem_resource, &video_rom_resource);
312 break;
313 }
314
315 start = (video_rom_resource.end + 1 + 2047) & ~2047UL;
316 if (start < upper)
317 start = upper;
318
319 /* system rom */
320 request_resource(&iomem_resource, &system_rom_resource);
321 upper = system_rom_resource.start;
322
323 /* check for extension rom (ignore length byte!) */
324 rom = isa_bus_to_virt(extension_rom_resource.start);
325 if (romsignature(rom)) {
326 length = extension_rom_resource.end - extension_rom_resource.start + 1;
327 if (romchecksum(rom, length)) {
328 request_resource(&iomem_resource, &extension_rom_resource);
329 upper = extension_rom_resource.start;
330 }
331 }
332
333 /* check for adapter roms on 2k boundaries */
334 for (i = 0; i < ADAPTER_ROM_RESOURCES && start < upper; start += 2048) {
335 rom = isa_bus_to_virt(start);
336 if (!romsignature(rom))
337 continue;
338
339 /* 0 < length <= 0x7f * 512, historically */
340 length = rom[2] * 512;
341
342 /* but accept any length that fits if checksum okay */
343 if (!length || start + length > upper || !romchecksum(rom, length))
344 continue;
345
346 adapter_rom_resources[i].start = start;
347 adapter_rom_resources[i].end = start + length - 1;
348 request_resource(&iomem_resource, &adapter_rom_resources[i]);
349
350 start = adapter_rom_resources[i++].end & ~2047UL;
351 }
352 }
353
354 static void __init limit_regions(unsigned long long size)
355 {
356 unsigned long long current_addr = 0;
357 int i;
358
359 if (efi_enabled) {
360 efi_memory_desc_t *md;
361 void *p;
362
363 for (p = memmap.map, i = 0; p < memmap.map_end;
364 p += memmap.desc_size, i++) {
365 md = p;
366 current_addr = md->phys_addr + (md->num_pages << 12);
367 if (md->type == EFI_CONVENTIONAL_MEMORY) {
368 if (current_addr >= size) {
369 md->num_pages -=
370 (((current_addr-size) + PAGE_SIZE-1) >> PAGE_SHIFT);
371 memmap.nr_map = i + 1;
372 return;
373 }
374 }
375 }
376 }
377 for (i = 0; i < e820.nr_map; i++) {
378 current_addr = e820.map[i].addr + e820.map[i].size;
379 if (current_addr < size)
380 continue;
381
382 if (e820.map[i].type != E820_RAM)
383 continue;
384
385 if (e820.map[i].addr >= size) {
386 /*
387 * This region starts past the end of the
388 * requested size, skip it completely.
389 */
390 e820.nr_map = i;
391 } else {
392 e820.nr_map = i + 1;
393 e820.map[i].size -= current_addr - size;
394 }
395 return;
396 }
397 }
398
399 void __init add_memory_region(unsigned long long start,
400 unsigned long long size, int type)
401 {
402 int x;
403
404 if (!efi_enabled) {
405 x = e820.nr_map;
406
407 if (x == E820MAX) {
408 printk(KERN_ERR "Ooops! Too many entries in the memory map!\n");
409 return;
410 }
411
412 e820.map[x].addr = start;
413 e820.map[x].size = size;
414 e820.map[x].type = type;
415 e820.nr_map++;
416 }
417 } /* add_memory_region */
418
419 #define E820_DEBUG 1
420
421 static void __init print_memory_map(char *who)
422 {
423 int i;
424
425 for (i = 0; i < e820.nr_map; i++) {
426 printk(" %s: %016Lx - %016Lx ", who,
427 e820.map[i].addr,
428 e820.map[i].addr + e820.map[i].size);
429 switch (e820.map[i].type) {
430 case E820_RAM: printk("(usable)\n");
431 break;
432 case E820_RESERVED:
433 printk("(reserved)\n");
434 break;
435 case E820_ACPI:
436 printk("(ACPI data)\n");
437 break;
438 case E820_NVS:
439 printk("(ACPI NVS)\n");
440 break;
441 default: printk("type %lu\n", e820.map[i].type);
442 break;
443 }
444 }
445 }
446
447 /*
448 * Sanitize the BIOS e820 map.
449 *
450 * Some e820 responses include overlapping entries. The following
451 * replaces the original e820 map with a new one, removing overlaps.
452 *
453 */
454 struct change_member {
455 struct e820entry *pbios; /* pointer to original bios entry */
456 unsigned long long addr; /* address for this change point */
457 };
458 static struct change_member change_point_list[2*E820MAX] __initdata;
459 static struct change_member *change_point[2*E820MAX] __initdata;
460 static struct e820entry *overlap_list[E820MAX] __initdata;
461 static struct e820entry new_bios[E820MAX] __initdata;
462
463 int __init sanitize_e820_map(struct e820entry * biosmap, char * pnr_map)
464 {
465 struct change_member *change_tmp;
466 unsigned long current_type, last_type;
467 unsigned long long last_addr;
468 int chgidx, still_changing;
469 int overlap_entries;
470 int new_bios_entry;
471 int old_nr, new_nr, chg_nr;
472 int i;
473
474 /*
475 Visually we're performing the following (1,2,3,4 = memory types)...
476
477 Sample memory map (w/overlaps):
478 ____22__________________
479 ______________________4_
480 ____1111________________
481 _44_____________________
482 11111111________________
483 ____________________33__
484 ___________44___________
485 __________33333_________
486 ______________22________
487 ___________________2222_
488 _________111111111______
489 _____________________11_
490 _________________4______
491
492 Sanitized equivalent (no overlap):
493 1_______________________
494 _44_____________________
495 ___1____________________
496 ____22__________________
497 ______11________________
498 _________1______________
499 __________3_____________
500 ___________44___________
501 _____________33_________
502 _______________2________
503 ________________1_______
504 _________________4______
505 ___________________2____
506 ____________________33__
507 ______________________4_
508 */
509
510 /* if there's only one memory region, don't bother */
511 if (*pnr_map < 2)
512 return -1;
513
514 old_nr = *pnr_map;
515
516 /* bail out if we find any unreasonable addresses in bios map */
517 for (i=0; i<old_nr; i++)
518 if (biosmap[i].addr + biosmap[i].size < biosmap[i].addr)
519 return -1;
520
521 /* create pointers for initial change-point information (for sorting) */
522 for (i=0; i < 2*old_nr; i++)
523 change_point[i] = &change_point_list[i];
524
525 /* record all known change-points (starting and ending addresses),
526 omitting those that are for empty memory regions */
527 chgidx = 0;
528 for (i=0; i < old_nr; i++) {
529 if (biosmap[i].size != 0) {
530 change_point[chgidx]->addr = biosmap[i].addr;
531 change_point[chgidx++]->pbios = &biosmap[i];
532 change_point[chgidx]->addr = biosmap[i].addr + biosmap[i].size;
533 change_point[chgidx++]->pbios = &biosmap[i];
534 }
535 }
536 chg_nr = chgidx; /* true number of change-points */
537
538 /* sort change-point list by memory addresses (low -> high) */
539 still_changing = 1;
540 while (still_changing) {
541 still_changing = 0;
542 for (i=1; i < chg_nr; i++) {
543 /* if <current_addr> > <last_addr>, swap */
544 /* or, if current=<start_addr> & last=<end_addr>, swap */
545 if ((change_point[i]->addr < change_point[i-1]->addr) ||
546 ((change_point[i]->addr == change_point[i-1]->addr) &&
547 (change_point[i]->addr == change_point[i]->pbios->addr) &&
548 (change_point[i-1]->addr != change_point[i-1]->pbios->addr))
549 )
550 {
551 change_tmp = change_point[i];
552 change_point[i] = change_point[i-1];
553 change_point[i-1] = change_tmp;
554 still_changing=1;
555 }
556 }
557 }
558
559 /* create a new bios memory map, removing overlaps */
560 overlap_entries=0; /* number of entries in the overlap table */
561 new_bios_entry=0; /* index for creating new bios map entries */
562 last_type = 0; /* start with undefined memory type */
563 last_addr = 0; /* start with 0 as last starting address */
564 /* loop through change-points, determining affect on the new bios map */
565 for (chgidx=0; chgidx < chg_nr; chgidx++)
566 {
567 /* keep track of all overlapping bios entries */
568 if (change_point[chgidx]->addr == change_point[chgidx]->pbios->addr)
569 {
570 /* add map entry to overlap list (> 1 entry implies an overlap) */
571 overlap_list[overlap_entries++]=change_point[chgidx]->pbios;
572 }
573 else
574 {
575 /* remove entry from list (order independent, so swap with last) */
576 for (i=0; i<overlap_entries; i++)
577 {
578 if (overlap_list[i] == change_point[chgidx]->pbios)
579 overlap_list[i] = overlap_list[overlap_entries-1];
580 }
581 overlap_entries--;
582 }
583 /* if there are overlapping entries, decide which "type" to use */
584 /* (larger value takes precedence -- 1=usable, 2,3,4,4+=unusable) */
585 current_type = 0;
586 for (i=0; i<overlap_entries; i++)
587 if (overlap_list[i]->type > current_type)
588 current_type = overlap_list[i]->type;
589 /* continue building up new bios map based on this information */
590 if (current_type != last_type) {
591 if (last_type != 0) {
592 new_bios[new_bios_entry].size =
593 change_point[chgidx]->addr - last_addr;
594 /* move forward only if the new size was non-zero */
595 if (new_bios[new_bios_entry].size != 0)
596 if (++new_bios_entry >= E820MAX)
597 break; /* no more space left for new bios entries */
598 }
599 if (current_type != 0) {
600 new_bios[new_bios_entry].addr = change_point[chgidx]->addr;
601 new_bios[new_bios_entry].type = current_type;
602 last_addr=change_point[chgidx]->addr;
603 }
604 last_type = current_type;
605 }
606 }
607 new_nr = new_bios_entry; /* retain count for new bios entries */
608
609 /* copy new bios mapping into original location */
610 memcpy(biosmap, new_bios, new_nr*sizeof(struct e820entry));
611 *pnr_map = new_nr;
612
613 return 0;
614 }
615
616 /*
617 * Copy the BIOS e820 map into a safe place.
618 *
619 * Sanity-check it while we're at it..
620 *
621 * If we're lucky and live on a modern system, the setup code
622 * will have given us a memory map that we can use to properly
623 * set up memory. If we aren't, we'll fake a memory map.
624 *
625 * We check to see that the memory map contains at least 2 elements
626 * before we'll use it, because the detection code in setup.S may
627 * not be perfect and most every PC known to man has two memory
628 * regions: one from 0 to 640k, and one from 1mb up. (The IBM
629 * thinkpad 560x, for example, does not cooperate with the memory
630 * detection code.)
631 */
632 int __init copy_e820_map(struct e820entry * biosmap, int nr_map)
633 {
634 /* Only one memory region (or negative)? Ignore it */
635 if (nr_map < 2)
636 return -1;
637
638 do {
639 unsigned long long start = biosmap->addr;
640 unsigned long long size = biosmap->size;
641 unsigned long long end = start + size;
642 unsigned long type = biosmap->type;
643
644 /* Overflow in 64 bits? Ignore the memory map. */
645 if (start > end)
646 return -1;
647
648 /*
649 * Some BIOSes claim RAM in the 640k - 1M region.
650 * Not right. Fix it up.
651 */
652 if (type == E820_RAM) {
653 if (start < 0x100000ULL && end > 0xA0000ULL) {
654 if (start < 0xA0000ULL)
655 add_memory_region(start, 0xA0000ULL-start, type);
656 if (end <= 0x100000ULL)
657 continue;
658 start = 0x100000ULL;
659 size = end - start;
660 }
661 }
662 add_memory_region(start, size, type);
663 } while (biosmap++,--nr_map);
664 return 0;
665 }
666
667 #if defined(CONFIG_EDD) || defined(CONFIG_EDD_MODULE)
668 struct edd edd;
669 #ifdef CONFIG_EDD_MODULE
670 EXPORT_SYMBOL(edd);
671 #endif
672 /**
673 * copy_edd() - Copy the BIOS EDD information
674 * from boot_params into a safe place.
675 *
676 */
677 static inline void copy_edd(void)
678 {
679 memcpy(edd.mbr_signature, EDD_MBR_SIGNATURE, sizeof(edd.mbr_signature));
680 memcpy(edd.edd_info, EDD_BUF, sizeof(edd.edd_info));
681 edd.mbr_signature_nr = EDD_MBR_SIG_NR;
682 edd.edd_info_nr = EDD_NR;
683 }
684 #else
685 static inline void copy_edd(void)
686 {
687 }
688 #endif
689
690 static int __initdata user_defined_memmap = 0;
691
692 /*
693 * "mem=nopentium" disables the 4MB page tables.
694 * "mem=XXX[kKmM]" defines a memory region from HIGH_MEM
695 * to <mem>, overriding the bios size.
696 * "memmap=XXX[KkmM]@XXX[KkmM]" defines a memory region from
697 * <start> to <start>+<mem>, overriding the bios size.
698 *
699 * HPA tells me bootloaders need to parse mem=, so no new
700 * option should be mem= [also see Documentation/i386/boot.txt]
701 */
702 static int __init parse_mem(char *arg)
703 {
704 if (!arg)
705 return -EINVAL;
706
707 if (strcmp(arg, "nopentium") == 0) {
708 clear_bit(X86_FEATURE_PSE, boot_cpu_data.x86_capability);
709 disable_pse = 1;
710 } else {
711 /* If the user specifies memory size, we
712 * limit the BIOS-provided memory map to
713 * that size. exactmap can be used to specify
714 * the exact map. mem=number can be used to
715 * trim the existing memory map.
716 */
717 unsigned long long mem_size;
718
719 mem_size = memparse(arg, &arg);
720 limit_regions(mem_size);
721 user_defined_memmap = 1;
722 }
723 return 0;
724 }
725 early_param("mem", parse_mem);
726
727 static int __init parse_memmap(char *arg)
728 {
729 if (!arg)
730 return -EINVAL;
731
732 if (strcmp(arg, "exactmap") == 0) {
733 #ifdef CONFIG_CRASH_DUMP
734 /* If we are doing a crash dump, we
735 * still need to know the real mem
736 * size before original memory map is
737 * reset.
738 */
739 find_max_pfn();
740 saved_max_pfn = max_pfn;
741 #endif
742 e820.nr_map = 0;
743 user_defined_memmap = 1;
744 } else {
745 /* If the user specifies memory size, we
746 * limit the BIOS-provided memory map to
747 * that size. exactmap can be used to specify
748 * the exact map. mem=number can be used to
749 * trim the existing memory map.
750 */
751 unsigned long long start_at, mem_size;
752
753 mem_size = memparse(arg, &arg);
754 if (*arg == '@') {
755 start_at = memparse(arg+1, &arg);
756 add_memory_region(start_at, mem_size, E820_RAM);
757 } else if (*arg == '#') {
758 start_at = memparse(arg+1, &arg);
759 add_memory_region(start_at, mem_size, E820_ACPI);
760 } else if (*arg == '$') {
761 start_at = memparse(arg+1, &arg);
762 add_memory_region(start_at, mem_size, E820_RESERVED);
763 } else {
764 limit_regions(mem_size);
765 user_defined_memmap = 1;
766 }
767 }
768 return 0;
769 }
770 early_param("memmap", parse_memmap);
771
772 #ifdef CONFIG_PROC_VMCORE
773 /* elfcorehdr= specifies the location of elf core header
774 * stored by the crashed kernel.
775 */
776 static int __init parse_elfcorehdr(char *arg)
777 {
778 if (!arg)
779 return -EINVAL;
780
781 elfcorehdr_addr = memparse(arg, &arg);
782 return 0;
783 }
784 early_param("elfcorehdr", parse_elfcorehdr);
785 #endif /* CONFIG_PROC_VMCORE */
786
787 /*
788 * highmem=size forces highmem to be exactly 'size' bytes.
789 * This works even on boxes that have no highmem otherwise.
790 * This also works to reduce highmem size on bigger boxes.
791 */
792 static int __init parse_highmem(char *arg)
793 {
794 if (!arg)
795 return -EINVAL;
796
797 highmem_pages = memparse(arg, &arg) >> PAGE_SHIFT;
798 return 0;
799 }
800 early_param("highmem", parse_highmem);
801
802 /*
803 * vmalloc=size forces the vmalloc area to be exactly 'size'
804 * bytes. This can be used to increase (or decrease) the
805 * vmalloc area - the default is 128m.
806 */
807 static int __init parse_vmalloc(char *arg)
808 {
809 if (!arg)
810 return -EINVAL;
811
812 __VMALLOC_RESERVE = memparse(arg, &arg);
813 return 0;
814 }
815 early_param("vmalloc", parse_vmalloc);
816
817 /*
818 * Callback for efi_memory_walk.
819 */
820 static int __init
821 efi_find_max_pfn(unsigned long start, unsigned long end, void *arg)
822 {
823 unsigned long *max_pfn = arg, pfn;
824
825 if (start < end) {
826 pfn = PFN_UP(end -1);
827 if (pfn > *max_pfn)
828 *max_pfn = pfn;
829 }
830 return 0;
831 }
832
833 static int __init
834 efi_memory_present_wrapper(unsigned long start, unsigned long end, void *arg)
835 {
836 memory_present(0, start, end);
837 return 0;
838 }
839
840 /*
841 * This function checks if the entire range <start,end> is mapped with type.
842 *
843 * Note: this function only works correct if the e820 table is sorted and
844 * not-overlapping, which is the case
845 */
846 int __init
847 e820_all_mapped(unsigned long s, unsigned long e, unsigned type)
848 {
849 u64 start = s;
850 u64 end = e;
851 int i;
852 for (i = 0; i < e820.nr_map; i++) {
853 struct e820entry *ei = &e820.map[i];
854 if (type && ei->type != type)
855 continue;
856 /* is the region (part) in overlap with the current region ?*/
857 if (ei->addr >= end || ei->addr + ei->size <= start)
858 continue;
859 /* if the region is at the beginning of <start,end> we move
860 * start to the end of the region since it's ok until there
861 */
862 if (ei->addr <= start)
863 start = ei->addr + ei->size;
864 /* if start is now at or beyond end, we're done, full
865 * coverage */
866 if (start >= end)
867 return 1; /* we're done */
868 }
869 return 0;
870 }
871
872 /*
873 * Find the highest page frame number we have available
874 */
875 void __init find_max_pfn(void)
876 {
877 int i;
878
879 max_pfn = 0;
880 if (efi_enabled) {
881 efi_memmap_walk(efi_find_max_pfn, &max_pfn);
882 efi_memmap_walk(efi_memory_present_wrapper, NULL);
883 return;
884 }
885
886 for (i = 0; i < e820.nr_map; i++) {
887 unsigned long start, end;
888 /* RAM? */
889 if (e820.map[i].type != E820_RAM)
890 continue;
891 start = PFN_UP(e820.map[i].addr);
892 end = PFN_DOWN(e820.map[i].addr + e820.map[i].size);
893 if (start >= end)
894 continue;
895 if (end > max_pfn)
896 max_pfn = end;
897 memory_present(0, start, end);
898 }
899 }
900
901 /*
902 * Determine low and high memory ranges:
903 */
904 unsigned long __init find_max_low_pfn(void)
905 {
906 unsigned long max_low_pfn;
907
908 max_low_pfn = max_pfn;
909 if (max_low_pfn > MAXMEM_PFN) {
910 if (highmem_pages == -1)
911 highmem_pages = max_pfn - MAXMEM_PFN;
912 if (highmem_pages + MAXMEM_PFN < max_pfn)
913 max_pfn = MAXMEM_PFN + highmem_pages;
914 if (highmem_pages + MAXMEM_PFN > max_pfn) {
915 printk("only %luMB highmem pages available, ignoring highmem size of %uMB.\n", pages_to_mb(max_pfn - MAXMEM_PFN), pages_to_mb(highmem_pages));
916 highmem_pages = 0;
917 }
918 max_low_pfn = MAXMEM_PFN;
919 #ifndef CONFIG_HIGHMEM
920 /* Maximum memory usable is what is directly addressable */
921 printk(KERN_WARNING "Warning only %ldMB will be used.\n",
922 MAXMEM>>20);
923 if (max_pfn > MAX_NONPAE_PFN)
924 printk(KERN_WARNING "Use a PAE enabled kernel.\n");
925 else
926 printk(KERN_WARNING "Use a HIGHMEM enabled kernel.\n");
927 max_pfn = MAXMEM_PFN;
928 #else /* !CONFIG_HIGHMEM */
929 #ifndef CONFIG_X86_PAE
930 if (max_pfn > MAX_NONPAE_PFN) {
931 max_pfn = MAX_NONPAE_PFN;
932 printk(KERN_WARNING "Warning only 4GB will be used.\n");
933 printk(KERN_WARNING "Use a PAE enabled kernel.\n");
934 }
935 #endif /* !CONFIG_X86_PAE */
936 #endif /* !CONFIG_HIGHMEM */
937 } else {
938 if (highmem_pages == -1)
939 highmem_pages = 0;
940 #ifdef CONFIG_HIGHMEM
941 if (highmem_pages >= max_pfn) {
942 printk(KERN_ERR "highmem size specified (%uMB) is bigger than pages available (%luMB)!.\n", pages_to_mb(highmem_pages), pages_to_mb(max_pfn));
943 highmem_pages = 0;
944 }
945 if (highmem_pages) {
946 if (max_low_pfn-highmem_pages < 64*1024*1024/PAGE_SIZE){
947 printk(KERN_ERR "highmem size %uMB results in smaller than 64MB lowmem, ignoring it.\n", pages_to_mb(highmem_pages));
948 highmem_pages = 0;
949 }
950 max_low_pfn -= highmem_pages;
951 }
952 #else
953 if (highmem_pages)
954 printk(KERN_ERR "ignoring highmem size on non-highmem kernel!\n");
955 #endif
956 }
957 return max_low_pfn;
958 }
959
960 /*
961 * Free all available memory for boot time allocation. Used
962 * as a callback function by efi_memory_walk()
963 */
964
965 static int __init
966 free_available_memory(unsigned long start, unsigned long end, void *arg)
967 {
968 /* check max_low_pfn */
969 if (start >= (max_low_pfn << PAGE_SHIFT))
970 return 0;
971 if (end >= (max_low_pfn << PAGE_SHIFT))
972 end = max_low_pfn << PAGE_SHIFT;
973 if (start < end)
974 free_bootmem(start, end - start);
975
976 return 0;
977 }
978 /*
979 * Register fully available low RAM pages with the bootmem allocator.
980 */
981 static void __init register_bootmem_low_pages(unsigned long max_low_pfn)
982 {
983 int i;
984
985 if (efi_enabled) {
986 efi_memmap_walk(free_available_memory, NULL);
987 return;
988 }
989 for (i = 0; i < e820.nr_map; i++) {
990 unsigned long curr_pfn, last_pfn, size;
991 /*
992 * Reserve usable low memory
993 */
994 if (e820.map[i].type != E820_RAM)
995 continue;
996 /*
997 * We are rounding up the start address of usable memory:
998 */
999 curr_pfn = PFN_UP(e820.map[i].addr);
1000 if (curr_pfn >= max_low_pfn)
1001 continue;
1002 /*
1003 * ... and at the end of the usable range downwards:
1004 */
1005 last_pfn = PFN_DOWN(e820.map[i].addr + e820.map[i].size);
1006
1007 if (last_pfn > max_low_pfn)
1008 last_pfn = max_low_pfn;
1009
1010 /*
1011 * .. finally, did all the rounding and playing
1012 * around just make the area go away?
1013 */
1014 if (last_pfn <= curr_pfn)
1015 continue;
1016
1017 size = last_pfn - curr_pfn;
1018 free_bootmem(PFN_PHYS(curr_pfn), PFN_PHYS(size));
1019 }
1020 }
1021
1022 /*
1023 * workaround for Dell systems that neglect to reserve EBDA
1024 */
1025 static void __init reserve_ebda_region(void)
1026 {
1027 unsigned int addr;
1028 addr = get_bios_ebda();
1029 if (addr)
1030 reserve_bootmem(addr, PAGE_SIZE);
1031 }
1032
1033 #ifndef CONFIG_NEED_MULTIPLE_NODES
1034 void __init setup_bootmem_allocator(void);
1035 static unsigned long __init setup_memory(void)
1036 {
1037 /*
1038 * partially used pages are not usable - thus
1039 * we are rounding upwards:
1040 */
1041 min_low_pfn = PFN_UP(init_pg_tables_end);
1042
1043 find_max_pfn();
1044
1045 max_low_pfn = find_max_low_pfn();
1046
1047 #ifdef CONFIG_HIGHMEM
1048 highstart_pfn = highend_pfn = max_pfn;
1049 if (max_pfn > max_low_pfn) {
1050 highstart_pfn = max_low_pfn;
1051 }
1052 printk(KERN_NOTICE "%ldMB HIGHMEM available.\n",
1053 pages_to_mb(highend_pfn - highstart_pfn));
1054 num_physpages = highend_pfn;
1055 high_memory = (void *) __va(highstart_pfn * PAGE_SIZE - 1) + 1;
1056 #else
1057 num_physpages = max_low_pfn;
1058 high_memory = (void *) __va(max_low_pfn * PAGE_SIZE - 1) + 1;
1059 #endif
1060 #ifdef CONFIG_FLATMEM
1061 max_mapnr = num_physpages;
1062 #endif
1063 printk(KERN_NOTICE "%ldMB LOWMEM available.\n",
1064 pages_to_mb(max_low_pfn));
1065
1066 setup_bootmem_allocator();
1067
1068 return max_low_pfn;
1069 }
1070
1071 void __init zone_sizes_init(void)
1072 {
1073 unsigned long zones_size[MAX_NR_ZONES] = {0, 0, 0};
1074 unsigned int max_dma, low;
1075
1076 max_dma = virt_to_phys((char *)MAX_DMA_ADDRESS) >> PAGE_SHIFT;
1077 low = max_low_pfn;
1078
1079 if (low < max_dma)
1080 zones_size[ZONE_DMA] = low;
1081 else {
1082 zones_size[ZONE_DMA] = max_dma;
1083 zones_size[ZONE_NORMAL] = low - max_dma;
1084 #ifdef CONFIG_HIGHMEM
1085 zones_size[ZONE_HIGHMEM] = highend_pfn - low;
1086 #endif
1087 }
1088 free_area_init(zones_size);
1089 }
1090 #else
1091 extern unsigned long __init setup_memory(void);
1092 extern void zone_sizes_init(void);
1093 #endif /* !CONFIG_NEED_MULTIPLE_NODES */
1094
1095 void __init setup_bootmem_allocator(void)
1096 {
1097 unsigned long bootmap_size;
1098 /*
1099 * Initialize the boot-time allocator (with low memory only):
1100 */
1101 bootmap_size = init_bootmem(min_low_pfn, max_low_pfn);
1102
1103 register_bootmem_low_pages(max_low_pfn);
1104
1105 /*
1106 * Reserve the bootmem bitmap itself as well. We do this in two
1107 * steps (first step was init_bootmem()) because this catches
1108 * the (very unlikely) case of us accidentally initializing the
1109 * bootmem allocator with an invalid RAM area.
1110 */
1111 reserve_bootmem(__PHYSICAL_START, (PFN_PHYS(min_low_pfn) +
1112 bootmap_size + PAGE_SIZE-1) - (__PHYSICAL_START));
1113
1114 /*
1115 * reserve physical page 0 - it's a special BIOS page on many boxes,
1116 * enabling clean reboots, SMP operation, laptop functions.
1117 */
1118 reserve_bootmem(0, PAGE_SIZE);
1119
1120 /* reserve EBDA region, it's a 4K region */
1121 reserve_ebda_region();
1122
1123 /* could be an AMD 768MPX chipset. Reserve a page before VGA to prevent
1124 PCI prefetch into it (errata #56). Usually the page is reserved anyways,
1125 unless you have no PS/2 mouse plugged in. */
1126 if (boot_cpu_data.x86_vendor == X86_VENDOR_AMD &&
1127 boot_cpu_data.x86 == 6)
1128 reserve_bootmem(0xa0000 - 4096, 4096);
1129
1130 #ifdef CONFIG_SMP
1131 /*
1132 * But first pinch a few for the stack/trampoline stuff
1133 * FIXME: Don't need the extra page at 4K, but need to fix
1134 * trampoline before removing it. (see the GDT stuff)
1135 */
1136 reserve_bootmem(PAGE_SIZE, PAGE_SIZE);
1137 #endif
1138 #ifdef CONFIG_ACPI_SLEEP
1139 /*
1140 * Reserve low memory region for sleep support.
1141 */
1142 acpi_reserve_bootmem();
1143 #endif
1144 #ifdef CONFIG_X86_FIND_SMP_CONFIG
1145 /*
1146 * Find and reserve possible boot-time SMP configuration:
1147 */
1148 find_smp_config();
1149 #endif
1150
1151 #ifdef CONFIG_BLK_DEV_INITRD
1152 if (LOADER_TYPE && INITRD_START) {
1153 if (INITRD_START + INITRD_SIZE <= (max_low_pfn << PAGE_SHIFT)) {
1154 reserve_bootmem(INITRD_START, INITRD_SIZE);
1155 initrd_start =
1156 INITRD_START ? INITRD_START + PAGE_OFFSET : 0;
1157 initrd_end = initrd_start+INITRD_SIZE;
1158 }
1159 else {
1160 printk(KERN_ERR "initrd extends beyond end of memory "
1161 "(0x%08lx > 0x%08lx)\ndisabling initrd\n",
1162 INITRD_START + INITRD_SIZE,
1163 max_low_pfn << PAGE_SHIFT);
1164 initrd_start = 0;
1165 }
1166 }
1167 #endif
1168 #ifdef CONFIG_KEXEC
1169 if (crashk_res.start != crashk_res.end)
1170 reserve_bootmem(crashk_res.start,
1171 crashk_res.end - crashk_res.start + 1);
1172 #endif
1173 }
1174
1175 /*
1176 * The node 0 pgdat is initialized before all of these because
1177 * it's needed for bootmem. node>0 pgdats have their virtual
1178 * space allocated before the pagetables are in place to access
1179 * them, so they can't be cleared then.
1180 *
1181 * This should all compile down to nothing when NUMA is off.
1182 */
1183 void __init remapped_pgdat_init(void)
1184 {
1185 int nid;
1186
1187 for_each_online_node(nid) {
1188 if (nid != 0)
1189 memset(NODE_DATA(nid), 0, sizeof(struct pglist_data));
1190 }
1191 }
1192
1193 /*
1194 * Request address space for all standard RAM and ROM resources
1195 * and also for regions reported as reserved by the e820.
1196 */
1197 static void __init
1198 legacy_init_iomem_resources(struct resource *code_resource, struct resource *data_resource)
1199 {
1200 int i;
1201
1202 probe_roms();
1203 for (i = 0; i < e820.nr_map; i++) {
1204 struct resource *res;
1205 #ifndef CONFIG_RESOURCES_64BIT
1206 if (e820.map[i].addr + e820.map[i].size > 0x100000000ULL)
1207 continue;
1208 #endif
1209 res = kzalloc(sizeof(struct resource), GFP_ATOMIC);
1210 switch (e820.map[i].type) {
1211 case E820_RAM: res->name = "System RAM"; break;
1212 case E820_ACPI: res->name = "ACPI Tables"; break;
1213 case E820_NVS: res->name = "ACPI Non-volatile Storage"; break;
1214 default: res->name = "reserved";
1215 }
1216 res->start = e820.map[i].addr;
1217 res->end = res->start + e820.map[i].size - 1;
1218 res->flags = IORESOURCE_MEM | IORESOURCE_BUSY;
1219 if (request_resource(&iomem_resource, res)) {
1220 kfree(res);
1221 continue;
1222 }
1223 if (e820.map[i].type == E820_RAM) {
1224 /*
1225 * We don't know which RAM region contains kernel data,
1226 * so we try it repeatedly and let the resource manager
1227 * test it.
1228 */
1229 request_resource(res, code_resource);
1230 request_resource(res, data_resource);
1231 #ifdef CONFIG_KEXEC
1232 request_resource(res, &crashk_res);
1233 #endif
1234 }
1235 }
1236 }
1237
1238 /*
1239 * Request address space for all standard resources
1240 *
1241 * This is called just before pcibios_init(), which is also a
1242 * subsys_initcall, but is linked in later (in arch/i386/pci/common.c).
1243 */
1244 static int __init request_standard_resources(void)
1245 {
1246 int i;
1247
1248 printk("Setting up standard PCI resources\n");
1249 if (efi_enabled)
1250 efi_initialize_iomem_resources(&code_resource, &data_resource);
1251 else
1252 legacy_init_iomem_resources(&code_resource, &data_resource);
1253
1254 /* EFI systems may still have VGA */
1255 request_resource(&iomem_resource, &video_ram_resource);
1256
1257 /* request I/O space for devices used on all i[345]86 PCs */
1258 for (i = 0; i < STANDARD_IO_RESOURCES; i++)
1259 request_resource(&ioport_resource, &standard_io_resources[i]);
1260 return 0;
1261 }
1262
1263 subsys_initcall(request_standard_resources);
1264
1265 static void __init register_memory(void)
1266 {
1267 unsigned long gapstart, gapsize, round;
1268 unsigned long long last;
1269 int i;
1270
1271 /*
1272 * Search for the bigest gap in the low 32 bits of the e820
1273 * memory space.
1274 */
1275 last = 0x100000000ull;
1276 gapstart = 0x10000000;
1277 gapsize = 0x400000;
1278 i = e820.nr_map;
1279 while (--i >= 0) {
1280 unsigned long long start = e820.map[i].addr;
1281 unsigned long long end = start + e820.map[i].size;
1282
1283 /*
1284 * Since "last" is at most 4GB, we know we'll
1285 * fit in 32 bits if this condition is true
1286 */
1287 if (last > end) {
1288 unsigned long gap = last - end;
1289
1290 if (gap > gapsize) {
1291 gapsize = gap;
1292 gapstart = end;
1293 }
1294 }
1295 if (start < last)
1296 last = start;
1297 }
1298
1299 /*
1300 * See how much we want to round up: start off with
1301 * rounding to the next 1MB area.
1302 */
1303 round = 0x100000;
1304 while ((gapsize >> 4) > round)
1305 round += round;
1306 /* Fun with two's complement */
1307 pci_mem_start = (gapstart + round) & -round;
1308
1309 printk("Allocating PCI resources starting at %08lx (gap: %08lx:%08lx)\n",
1310 pci_mem_start, gapstart, gapsize);
1311 }
1312
1313 #ifdef CONFIG_MCA
1314 static void set_mca_bus(int x)
1315 {
1316 MCA_bus = x;
1317 }
1318 #else
1319 static void set_mca_bus(int x) { }
1320 #endif
1321
1322 /*
1323 * Determine if we were loaded by an EFI loader. If so, then we have also been
1324 * passed the efi memmap, systab, etc., so we should use these data structures
1325 * for initialization. Note, the efi init code path is determined by the
1326 * global efi_enabled. This allows the same kernel image to be used on existing
1327 * systems (with a traditional BIOS) as well as on EFI systems.
1328 */
1329 void __init setup_arch(char **cmdline_p)
1330 {
1331 unsigned long max_low_pfn;
1332
1333 memcpy(&boot_cpu_data, &new_cpu_data, sizeof(new_cpu_data));
1334 pre_setup_arch_hook();
1335 early_cpu_init();
1336
1337 /*
1338 * FIXME: This isn't an official loader_type right
1339 * now but does currently work with elilo.
1340 * If we were configured as an EFI kernel, check to make
1341 * sure that we were loaded correctly from elilo and that
1342 * the system table is valid. If not, then initialize normally.
1343 */
1344 #ifdef CONFIG_EFI
1345 if ((LOADER_TYPE == 0x50) && EFI_SYSTAB)
1346 efi_enabled = 1;
1347 #endif
1348
1349 ROOT_DEV = old_decode_dev(ORIG_ROOT_DEV);
1350 drive_info = DRIVE_INFO;
1351 screen_info = SCREEN_INFO;
1352 edid_info = EDID_INFO;
1353 apm_info.bios = APM_BIOS_INFO;
1354 ist_info = IST_INFO;
1355 saved_videomode = VIDEO_MODE;
1356 if( SYS_DESC_TABLE.length != 0 ) {
1357 set_mca_bus(SYS_DESC_TABLE.table[3] & 0x2);
1358 machine_id = SYS_DESC_TABLE.table[0];
1359 machine_submodel_id = SYS_DESC_TABLE.table[1];
1360 BIOS_revision = SYS_DESC_TABLE.table[2];
1361 }
1362 bootloader_type = LOADER_TYPE;
1363
1364 #ifdef CONFIG_BLK_DEV_RAM
1365 rd_image_start = RAMDISK_FLAGS & RAMDISK_IMAGE_START_MASK;
1366 rd_prompt = ((RAMDISK_FLAGS & RAMDISK_PROMPT_FLAG) != 0);
1367 rd_doload = ((RAMDISK_FLAGS & RAMDISK_LOAD_FLAG) != 0);
1368 #endif
1369 ARCH_SETUP
1370 if (efi_enabled)
1371 efi_init();
1372 else {
1373 printk(KERN_INFO "BIOS-provided physical RAM map:\n");
1374 print_memory_map(machine_specific_memory_setup());
1375 }
1376
1377 copy_edd();
1378
1379 if (!MOUNT_ROOT_RDONLY)
1380 root_mountflags &= ~MS_RDONLY;
1381 init_mm.start_code = (unsigned long) _text;
1382 init_mm.end_code = (unsigned long) _etext;
1383 init_mm.end_data = (unsigned long) _edata;
1384 init_mm.brk = init_pg_tables_end + PAGE_OFFSET;
1385
1386 code_resource.start = virt_to_phys(_text);
1387 code_resource.end = virt_to_phys(_etext)-1;
1388 data_resource.start = virt_to_phys(_etext);
1389 data_resource.end = virt_to_phys(_edata)-1;
1390
1391 parse_early_param();
1392
1393 if (user_defined_memmap) {
1394 printk(KERN_INFO "user-defined physical RAM map:\n");
1395 print_memory_map("user");
1396 }
1397
1398 strlcpy(command_line, saved_command_line, COMMAND_LINE_SIZE);
1399 *cmdline_p = command_line;
1400
1401 max_low_pfn = setup_memory();
1402
1403 /*
1404 * NOTE: before this point _nobody_ is allowed to allocate
1405 * any memory using the bootmem allocator. Although the
1406 * alloctor is now initialised only the first 8Mb of the kernel
1407 * virtual address space has been mapped. All allocations before
1408 * paging_init() has completed must use the alloc_bootmem_low_pages()
1409 * variant (which allocates DMA'able memory) and care must be taken
1410 * not to exceed the 8Mb limit.
1411 */
1412
1413 #ifdef CONFIG_SMP
1414 smp_alloc_memory(); /* AP processor realmode stacks in low memory*/
1415 #endif
1416 paging_init();
1417 remapped_pgdat_init();
1418 sparse_init();
1419 zone_sizes_init();
1420
1421 /*
1422 * NOTE: at this point the bootmem allocator is fully available.
1423 */
1424
1425 dmi_scan_machine();
1426
1427 #ifdef CONFIG_X86_GENERICARCH
1428 generic_apic_probe();
1429 #endif
1430 if (efi_enabled)
1431 efi_map_memmap();
1432
1433 #ifdef CONFIG_ACPI
1434 /*
1435 * Parse the ACPI tables for possible boot-time SMP configuration.
1436 */
1437 acpi_boot_table_init();
1438 #endif
1439
1440 #ifdef CONFIG_X86_IO_APIC
1441 check_acpi_pci(); /* Checks more than just ACPI actually */
1442 #endif
1443
1444 #ifdef CONFIG_ACPI
1445 acpi_boot_init();
1446
1447 #if defined(CONFIG_SMP) && defined(CONFIG_X86_PC)
1448 if (def_to_bigsmp)
1449 printk(KERN_WARNING "More than 8 CPUs detected and "
1450 "CONFIG_X86_PC cannot handle it.\nUse "
1451 "CONFIG_X86_GENERICARCH or CONFIG_X86_BIGSMP.\n");
1452 #endif
1453 #endif
1454 #ifdef CONFIG_X86_LOCAL_APIC
1455 if (smp_found_config)
1456 get_smp_config();
1457 #endif
1458
1459 register_memory();
1460
1461 #ifdef CONFIG_VT
1462 #if defined(CONFIG_VGA_CONSOLE)
1463 if (!efi_enabled || (efi_mem_type(0xa0000) != EFI_CONVENTIONAL_MEMORY))
1464 conswitchp = &vga_con;
1465 #elif defined(CONFIG_DUMMY_CONSOLE)
1466 conswitchp = &dummy_con;
1467 #endif
1468 #endif
1469 tsc_init();
1470 }
1471
1472 static __init int add_pcspkr(void)
1473 {
1474 struct platform_device *pd;
1475 int ret;
1476
1477 pd = platform_device_alloc("pcspkr", -1);
1478 if (!pd)
1479 return -ENOMEM;
1480
1481 ret = platform_device_add(pd);
1482 if (ret)
1483 platform_device_put(pd);
1484
1485 return ret;
1486 }
1487 device_initcall(add_pcspkr);
1488
1489 /*
1490 * Local Variables:
1491 * mode:c
1492 * c-file-style:"k&r"
1493 * c-basic-offset:8
1494 * End:
1495 */
This page took 0.078825 seconds and 4 git commands to generate.