debuggers.hg

view linux-2.6.10-xen-sparse/arch/xen/i386/kernel/setup.c @ 3666:e922aa58971a

bitkeeper revision 1.1159.212.75 (4201e86fqC-UkeTMjRJgsysdz4rT7w)

Merge scramble.cl.cam.ac.uk:/local/scratch/kaf24/xen-2.0-testing.bk
into scramble.cl.cam.ac.uk:/local/scratch/kaf24/xen-unstable.bk
author kaf24@scramble.cl.cam.ac.uk
date Thu Feb 03 09:01:35 2005 +0000 (2005-02-03)
parents 39a7a74fd6f9 351e129e3735
children bbe8541361dd
line source
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 */
22 /*
23 * This file handles the architecture-dependent parts of initialization
24 */
26 #include <linux/sched.h>
27 #include <linux/mm.h>
28 #include <linux/tty.h>
29 #include <linux/ioport.h>
30 #include <linux/acpi.h>
31 #include <linux/apm_bios.h>
32 #include <linux/initrd.h>
33 #include <linux/bootmem.h>
34 #include <linux/seq_file.h>
35 #include <linux/console.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/percpu.h>
43 #include <video/edid.h>
44 #include <asm/e820.h>
45 #include <asm/mpspec.h>
46 #include <asm/setup.h>
47 #include <asm/arch_hooks.h>
48 #include <asm/sections.h>
49 #include <asm/io_apic.h>
50 #include <asm/ist.h>
51 #include <asm/io.h>
52 #include <asm-xen/hypervisor.h>
53 #include "setup_arch_pre.h"
54 #include <bios_ebda.h>
56 /* Allows setting of maximum possible memory size */
57 static unsigned long xen_override_max_pfn;
59 int disable_pse __initdata = 0;
61 /*
62 * Machine setup..
63 */
65 #ifdef CONFIG_EFI
66 int efi_enabled = 0;
67 EXPORT_SYMBOL(efi_enabled);
68 #endif
70 /* cpu data as detected by the assembly code in head.S */
71 struct cpuinfo_x86 new_cpu_data __initdata = { 0, 0, 0, 0, -1, 0, 1, 0, -1 };
72 /* common cpu data for all cpus */
73 struct cpuinfo_x86 boot_cpu_data = { 0, 0, 0, 0, -1, 0, 1, 0, -1 };
75 unsigned long mmu_cr4_features;
76 EXPORT_SYMBOL_GPL(mmu_cr4_features);
78 #ifdef CONFIG_ACPI_INTERPRETER
79 int acpi_disabled = 0;
80 #else
81 int acpi_disabled = 1;
82 #endif
83 EXPORT_SYMBOL(acpi_disabled);
85 #ifdef CONFIG_ACPI_BOOT
86 int __initdata acpi_force = 0;
87 extern acpi_interrupt_flags acpi_sci_flags;
88 #endif
90 int MCA_bus;
91 /* for MCA, but anyone else can use it if they want */
92 unsigned int machine_id;
93 unsigned int machine_submodel_id;
94 unsigned int BIOS_revision;
95 unsigned int mca_pentium_flag;
97 /* For PCI or other memory-mapped resources */
98 unsigned long pci_mem_start = 0x10000000;
100 /* user-defined highmem size */
101 static unsigned int highmem_pages = -1;
103 /*
104 * Setup options
105 */
106 struct drive_info_struct { char dummy[32]; } drive_info;
107 struct screen_info screen_info;
108 struct apm_info apm_info;
109 struct sys_desc_table_struct {
110 unsigned short length;
111 unsigned char table[0];
112 };
113 struct edid_info edid_info;
114 struct ist_info ist_info;
115 struct e820map e820;
117 unsigned char aux_device_present;
119 extern void early_cpu_init(void);
120 extern void dmi_scan_machine(void);
121 extern void generic_apic_probe(char *);
122 extern int root_mountflags;
124 unsigned long saved_videomode;
126 #define RAMDISK_IMAGE_START_MASK 0x07FF
127 #define RAMDISK_PROMPT_FLAG 0x8000
128 #define RAMDISK_LOAD_FLAG 0x4000
130 static char command_line[COMMAND_LINE_SIZE];
132 unsigned char __initdata boot_params[PARAM_SIZE];
134 static struct resource data_resource = {
135 .name = "Kernel data",
136 .start = 0,
137 .end = 0,
138 .flags = IORESOURCE_BUSY | IORESOURCE_MEM
139 };
141 static struct resource code_resource = {
142 .name = "Kernel code",
143 .start = 0,
144 .end = 0,
145 .flags = IORESOURCE_BUSY | IORESOURCE_MEM
146 };
148 #ifdef CONFIG_XEN_PRIVILEGED_GUEST
149 static struct resource system_rom_resource = {
150 .name = "System ROM",
151 .start = 0xf0000,
152 .end = 0xfffff,
153 .flags = IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM
154 };
156 static struct resource extension_rom_resource = {
157 .name = "Extension ROM",
158 .start = 0xe0000,
159 .end = 0xeffff,
160 .flags = IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM
161 };
163 static struct resource adapter_rom_resources[] = { {
164 .name = "Adapter ROM",
165 .start = 0xc8000,
166 .end = 0,
167 .flags = IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM
168 }, {
169 .name = "Adapter ROM",
170 .start = 0,
171 .end = 0,
172 .flags = IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM
173 }, {
174 .name = "Adapter ROM",
175 .start = 0,
176 .end = 0,
177 .flags = IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM
178 }, {
179 .name = "Adapter ROM",
180 .start = 0,
181 .end = 0,
182 .flags = IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM
183 }, {
184 .name = "Adapter ROM",
185 .start = 0,
186 .end = 0,
187 .flags = IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM
188 }, {
189 .name = "Adapter ROM",
190 .start = 0,
191 .end = 0,
192 .flags = IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM
193 } };
195 #define ADAPTER_ROM_RESOURCES \
196 (sizeof adapter_rom_resources / sizeof adapter_rom_resources[0])
198 static struct resource video_rom_resource = {
199 .name = "Video ROM",
200 .start = 0xc0000,
201 .end = 0xc7fff,
202 .flags = IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM
203 };
204 #endif
206 static struct resource video_ram_resource = {
207 .name = "Video RAM area",
208 .start = 0xa0000,
209 .end = 0xbffff,
210 .flags = IORESOURCE_BUSY | IORESOURCE_MEM
211 };
213 static struct resource standard_io_resources[] = { {
214 .name = "dma1",
215 .start = 0x0000,
216 .end = 0x001f,
217 .flags = IORESOURCE_BUSY | IORESOURCE_IO
218 }, {
219 .name = "pic1",
220 .start = 0x0020,
221 .end = 0x0021,
222 .flags = IORESOURCE_BUSY | IORESOURCE_IO
223 }, {
224 .name = "timer0",
225 .start = 0x0040,
226 .end = 0x0043,
227 .flags = IORESOURCE_BUSY | IORESOURCE_IO
228 }, {
229 .name = "timer1",
230 .start = 0x0050,
231 .end = 0x0053,
232 .flags = IORESOURCE_BUSY | IORESOURCE_IO
233 }, {
234 .name = "keyboard",
235 .start = 0x0060,
236 .end = 0x006f,
237 .flags = IORESOURCE_BUSY | IORESOURCE_IO
238 }, {
239 .name = "dma page reg",
240 .start = 0x0080,
241 .end = 0x008f,
242 .flags = IORESOURCE_BUSY | IORESOURCE_IO
243 }, {
244 .name = "pic2",
245 .start = 0x00a0,
246 .end = 0x00a1,
247 .flags = IORESOURCE_BUSY | IORESOURCE_IO
248 }, {
249 .name = "dma2",
250 .start = 0x00c0,
251 .end = 0x00df,
252 .flags = IORESOURCE_BUSY | IORESOURCE_IO
253 }, {
254 .name = "fpu",
255 .start = 0x00f0,
256 .end = 0x00ff,
257 .flags = IORESOURCE_BUSY | IORESOURCE_IO
258 } };
260 #define STANDARD_IO_RESOURCES \
261 (sizeof standard_io_resources / sizeof standard_io_resources[0])
263 #ifdef CONFIG_XEN_PRIVILEGED_GUEST
264 #define romsignature(x) (*(unsigned short *)(x) == 0xaa55)
266 static int __init romchecksum(unsigned char *rom, unsigned long length)
267 {
268 unsigned char *p, sum = 0;
270 for (p = rom; p < rom + length; p++)
271 sum += *p;
272 return sum == 0;
273 }
275 static void __init probe_roms(void)
276 {
277 unsigned long start, length, upper;
278 unsigned char *rom;
279 int i;
281 /* video rom */
282 upper = adapter_rom_resources[0].start;
283 for (start = video_rom_resource.start; start < upper; start += 2048) {
284 rom = isa_bus_to_virt(start);
285 if (!romsignature(rom))
286 continue;
288 video_rom_resource.start = start;
290 /* 0 < length <= 0x7f * 512, historically */
291 length = rom[2] * 512;
293 /* if checksum okay, trust length byte */
294 if (length && romchecksum(rom, length))
295 video_rom_resource.end = start + length - 1;
297 request_resource(&iomem_resource, &video_rom_resource);
298 break;
299 }
301 start = (video_rom_resource.end + 1 + 2047) & ~2047UL;
302 if (start < upper)
303 start = upper;
305 /* system rom */
306 request_resource(&iomem_resource, &system_rom_resource);
307 upper = system_rom_resource.start;
309 /* check for extension rom (ignore length byte!) */
310 rom = isa_bus_to_virt(extension_rom_resource.start);
311 if (romsignature(rom)) {
312 length = extension_rom_resource.end - extension_rom_resource.start + 1;
313 if (romchecksum(rom, length)) {
314 request_resource(&iomem_resource, &extension_rom_resource);
315 upper = extension_rom_resource.start;
316 }
317 }
319 /* check for adapter roms on 2k boundaries */
320 for (i = 0; i < ADAPTER_ROM_RESOURCES && start < upper; start += 2048) {
321 rom = isa_bus_to_virt(start);
322 if (!romsignature(rom))
323 continue;
325 /* 0 < length <= 0x7f * 512, historically */
326 length = rom[2] * 512;
328 /* but accept any length that fits if checksum okay */
329 if (!length || start + length > upper || !romchecksum(rom, length))
330 continue;
332 adapter_rom_resources[i].start = start;
333 adapter_rom_resources[i].end = start + length - 1;
334 request_resource(&iomem_resource, &adapter_rom_resources[i]);
336 start = adapter_rom_resources[i++].end & ~2047UL;
337 }
338 }
339 #endif
341 /*
342 * Point at the empty zero page to start with. We map the real shared_info
343 * page as soon as fixmap is up and running.
344 */
345 shared_info_t *HYPERVISOR_shared_info = (shared_info_t *)empty_zero_page;
346 EXPORT_SYMBOL(HYPERVISOR_shared_info);
348 unsigned long *phys_to_machine_mapping, *pfn_to_mfn_frame_list;
349 EXPORT_SYMBOL(phys_to_machine_mapping);
351 DEFINE_PER_CPU(multicall_entry_t, multicall_list[8]);
352 DEFINE_PER_CPU(int, nr_multicall_ents);
354 /* Raw start-of-day parameters from the hypervisor. */
355 union xen_start_info_union xen_start_info_union;
357 static void __init limit_regions(unsigned long long size)
358 {
359 unsigned long long current_addr = 0;
360 int i;
362 if (efi_enabled) {
363 for (i = 0; i < memmap.nr_map; i++) {
364 current_addr = memmap.map[i].phys_addr +
365 (memmap.map[i].num_pages << 12);
366 if (memmap.map[i].type == EFI_CONVENTIONAL_MEMORY) {
367 if (current_addr >= size) {
368 memmap.map[i].num_pages -=
369 (((current_addr-size) + PAGE_SIZE-1) >> PAGE_SHIFT);
370 memmap.nr_map = i + 1;
371 return;
372 }
373 }
374 }
375 }
376 for (i = 0; i < e820.nr_map; i++) {
377 if (e820.map[i].type == E820_RAM) {
378 current_addr = e820.map[i].addr + e820.map[i].size;
379 if (current_addr >= size) {
380 e820.map[i].size -= current_addr-size;
381 e820.nr_map = i + 1;
382 return;
383 }
384 }
385 }
386 }
388 static void __init add_memory_region(unsigned long long start,
389 unsigned long long size, int type)
390 {
391 int x;
393 if (!efi_enabled) {
394 x = e820.nr_map;
396 if (x == E820MAX) {
397 printk(KERN_ERR "Ooops! Too many entries in the memory map!\n");
398 return;
399 }
401 e820.map[x].addr = start;
402 e820.map[x].size = size;
403 e820.map[x].type = type;
404 e820.nr_map++;
405 }
406 } /* add_memory_region */
408 #define E820_DEBUG 1
410 static void __init print_memory_map(char *who)
411 {
412 int i;
414 for (i = 0; i < e820.nr_map; i++) {
415 printk(" %s: %016Lx - %016Lx ", who,
416 e820.map[i].addr,
417 e820.map[i].addr + e820.map[i].size);
418 switch (e820.map[i].type) {
419 case E820_RAM: printk("(usable)\n");
420 break;
421 case E820_RESERVED:
422 printk("(reserved)\n");
423 break;
424 case E820_ACPI:
425 printk("(ACPI data)\n");
426 break;
427 case E820_NVS:
428 printk("(ACPI NVS)\n");
429 break;
430 default: printk("type %lu\n", e820.map[i].type);
431 break;
432 }
433 }
434 }
436 #if 0
437 /*
438 * Sanitize the BIOS e820 map.
439 *
440 * Some e820 responses include overlapping entries. The following
441 * replaces the original e820 map with a new one, removing overlaps.
442 *
443 */
444 struct change_member {
445 struct e820entry *pbios; /* pointer to original bios entry */
446 unsigned long long addr; /* address for this change point */
447 };
448 struct change_member change_point_list[2*E820MAX] __initdata;
449 struct change_member *change_point[2*E820MAX] __initdata;
450 struct e820entry *overlap_list[E820MAX] __initdata;
451 struct e820entry new_bios[E820MAX] __initdata;
453 static int __init sanitize_e820_map(struct e820entry * biosmap, char * pnr_map)
454 {
455 struct change_member *change_tmp;
456 unsigned long current_type, last_type;
457 unsigned long long last_addr;
458 int chgidx, still_changing;
459 int overlap_entries;
460 int new_bios_entry;
461 int old_nr, new_nr, chg_nr;
462 int i;
464 /*
465 Visually we're performing the following (1,2,3,4 = memory types)...
467 Sample memory map (w/overlaps):
468 ____22__________________
469 ______________________4_
470 ____1111________________
471 _44_____________________
472 11111111________________
473 ____________________33__
474 ___________44___________
475 __________33333_________
476 ______________22________
477 ___________________2222_
478 _________111111111______
479 _____________________11_
480 _________________4______
482 Sanitized equivalent (no overlap):
483 1_______________________
484 _44_____________________
485 ___1____________________
486 ____22__________________
487 ______11________________
488 _________1______________
489 __________3_____________
490 ___________44___________
491 _____________33_________
492 _______________2________
493 ________________1_______
494 _________________4______
495 ___________________2____
496 ____________________33__
497 ______________________4_
498 */
500 /* if there's only one memory region, don't bother */
501 if (*pnr_map < 2)
502 return -1;
504 old_nr = *pnr_map;
506 /* bail out if we find any unreasonable addresses in bios map */
507 for (i=0; i<old_nr; i++)
508 if (biosmap[i].addr + biosmap[i].size < biosmap[i].addr)
509 return -1;
511 /* create pointers for initial change-point information (for sorting) */
512 for (i=0; i < 2*old_nr; i++)
513 change_point[i] = &change_point_list[i];
515 /* record all known change-points (starting and ending addresses),
516 omitting those that are for empty memory regions */
517 chgidx = 0;
518 for (i=0; i < old_nr; i++) {
519 if (biosmap[i].size != 0) {
520 change_point[chgidx]->addr = biosmap[i].addr;
521 change_point[chgidx++]->pbios = &biosmap[i];
522 change_point[chgidx]->addr = biosmap[i].addr + biosmap[i].size;
523 change_point[chgidx++]->pbios = &biosmap[i];
524 }
525 }
526 chg_nr = chgidx; /* true number of change-points */
528 /* sort change-point list by memory addresses (low -> high) */
529 still_changing = 1;
530 while (still_changing) {
531 still_changing = 0;
532 for (i=1; i < chg_nr; i++) {
533 /* if <current_addr> > <last_addr>, swap */
534 /* or, if current=<start_addr> & last=<end_addr>, swap */
535 if ((change_point[i]->addr < change_point[i-1]->addr) ||
536 ((change_point[i]->addr == change_point[i-1]->addr) &&
537 (change_point[i]->addr == change_point[i]->pbios->addr) &&
538 (change_point[i-1]->addr != change_point[i-1]->pbios->addr))
539 )
540 {
541 change_tmp = change_point[i];
542 change_point[i] = change_point[i-1];
543 change_point[i-1] = change_tmp;
544 still_changing=1;
545 }
546 }
547 }
549 /* create a new bios memory map, removing overlaps */
550 overlap_entries=0; /* number of entries in the overlap table */
551 new_bios_entry=0; /* index for creating new bios map entries */
552 last_type = 0; /* start with undefined memory type */
553 last_addr = 0; /* start with 0 as last starting address */
554 /* loop through change-points, determining affect on the new bios map */
555 for (chgidx=0; chgidx < chg_nr; chgidx++)
556 {
557 /* keep track of all overlapping bios entries */
558 if (change_point[chgidx]->addr == change_point[chgidx]->pbios->addr)
559 {
560 /* add map entry to overlap list (> 1 entry implies an overlap) */
561 overlap_list[overlap_entries++]=change_point[chgidx]->pbios;
562 }
563 else
564 {
565 /* remove entry from list (order independent, so swap with last) */
566 for (i=0; i<overlap_entries; i++)
567 {
568 if (overlap_list[i] == change_point[chgidx]->pbios)
569 overlap_list[i] = overlap_list[overlap_entries-1];
570 }
571 overlap_entries--;
572 }
573 /* if there are overlapping entries, decide which "type" to use */
574 /* (larger value takes precedence -- 1=usable, 2,3,4,4+=unusable) */
575 current_type = 0;
576 for (i=0; i<overlap_entries; i++)
577 if (overlap_list[i]->type > current_type)
578 current_type = overlap_list[i]->type;
579 /* continue building up new bios map based on this information */
580 if (current_type != last_type) {
581 if (last_type != 0) {
582 new_bios[new_bios_entry].size =
583 change_point[chgidx]->addr - last_addr;
584 /* move forward only if the new size was non-zero */
585 if (new_bios[new_bios_entry].size != 0)
586 if (++new_bios_entry >= E820MAX)
587 break; /* no more space left for new bios entries */
588 }
589 if (current_type != 0) {
590 new_bios[new_bios_entry].addr = change_point[chgidx]->addr;
591 new_bios[new_bios_entry].type = current_type;
592 last_addr=change_point[chgidx]->addr;
593 }
594 last_type = current_type;
595 }
596 }
597 new_nr = new_bios_entry; /* retain count for new bios entries */
599 /* copy new bios mapping into original location */
600 memcpy(biosmap, new_bios, new_nr*sizeof(struct e820entry));
601 *pnr_map = new_nr;
603 return 0;
604 }
606 /*
607 * Copy the BIOS e820 map into a safe place.
608 *
609 * Sanity-check it while we're at it..
610 *
611 * If we're lucky and live on a modern system, the setup code
612 * will have given us a memory map that we can use to properly
613 * set up memory. If we aren't, we'll fake a memory map.
614 *
615 * We check to see that the memory map contains at least 2 elements
616 * before we'll use it, because the detection code in setup.S may
617 * not be perfect and most every PC known to man has two memory
618 * regions: one from 0 to 640k, and one from 1mb up. (The IBM
619 * thinkpad 560x, for example, does not cooperate with the memory
620 * detection code.)
621 */
622 static int __init copy_e820_map(struct e820entry * biosmap, int nr_map)
623 {
624 /* Only one memory region (or negative)? Ignore it */
625 if (nr_map < 2)
626 return -1;
628 do {
629 unsigned long long start = biosmap->addr;
630 unsigned long long size = biosmap->size;
631 unsigned long long end = start + size;
632 unsigned long type = biosmap->type;
634 /* Overflow in 64 bits? Ignore the memory map. */
635 if (start > end)
636 return -1;
638 /*
639 * Some BIOSes claim RAM in the 640k - 1M region.
640 * Not right. Fix it up.
641 */
642 if (type == E820_RAM) {
643 if (start < 0x100000ULL && end > 0xA0000ULL) {
644 if (start < 0xA0000ULL)
645 add_memory_region(start, 0xA0000ULL-start, type);
646 if (end <= 0x100000ULL)
647 continue;
648 start = 0x100000ULL;
649 size = end - start;
650 }
651 }
652 add_memory_region(start, size, type);
653 } while (biosmap++,--nr_map);
654 return 0;
655 }
656 #endif
658 #if defined(CONFIG_EDD) || defined(CONFIG_EDD_MODULE)
659 struct edd edd;
660 #ifdef CONFIG_EDD_MODULE
661 EXPORT_SYMBOL(edd);
662 #endif
663 /**
664 * copy_edd() - Copy the BIOS EDD information
665 * from boot_params into a safe place.
666 *
667 */
668 static inline void copy_edd(void)
669 {
670 memcpy(edd.mbr_signature, EDD_MBR_SIGNATURE, sizeof(edd.mbr_signature));
671 memcpy(edd.edd_info, EDD_BUF, sizeof(edd.edd_info));
672 edd.mbr_signature_nr = EDD_MBR_SIG_NR;
673 edd.edd_info_nr = EDD_NR;
674 }
675 #else
676 static inline void copy_edd(void)
677 {
678 }
679 #endif
681 /*
682 * Do NOT EVER look at the BIOS memory size location.
683 * It does not work on many machines.
684 */
685 #define LOWMEMSIZE() (0x9f000)
687 static void __init parse_cmdline_early (char ** cmdline_p)
688 {
689 char c = ' ', *to = command_line, *from = saved_command_line;
690 int len = 0;
691 int userdef = 0;
693 memcpy(saved_command_line, xen_start_info.cmd_line, MAX_CMDLINE);
694 /* Save unparsed command line copy for /proc/cmdline */
695 saved_command_line[COMMAND_LINE_SIZE-1] = '\0';
697 for (;;) {
698 /*
699 * "mem=nopentium" disables the 4MB page tables.
700 * "mem=XXX[kKmM]" defines a memory region from HIGH_MEM
701 * to <mem>, overriding the bios size.
702 * "memmap=XXX[KkmM]@XXX[KkmM]" defines a memory region from
703 * <start> to <start>+<mem>, overriding the bios size.
704 *
705 * HPA tells me bootloaders need to parse mem=, so no new
706 * option should be mem= [also see Documentation/i386/boot.txt]
707 */
708 if (c == ' ' && !memcmp(from, "mem=", 4)) {
709 if (to != command_line)
710 to--;
711 if (!memcmp(from+4, "nopentium", 9)) {
712 from += 9+4;
713 clear_bit(X86_FEATURE_PSE, boot_cpu_data.x86_capability);
714 disable_pse = 1;
715 } else {
716 /* If the user specifies memory size, we
717 * limit the BIOS-provided memory map to
718 * that size. exactmap can be used to specify
719 * the exact map. mem=number can be used to
720 * trim the existing memory map.
721 */
722 unsigned long long mem_size;
724 mem_size = memparse(from+4, &from);
725 #if 0
726 limit_regions(mem_size);
727 userdef=1;
728 #else
729 xen_override_max_pfn =
730 (unsigned long)(mem_size>>PAGE_SHIFT);
731 #endif
732 }
733 }
735 if (c == ' ' && !memcmp(from, "memmap=", 7)) {
736 if (to != command_line)
737 to--;
738 if (!memcmp(from+7, "exactmap", 8)) {
739 from += 8+7;
740 e820.nr_map = 0;
741 userdef = 1;
742 } else {
743 /* If the user specifies memory size, we
744 * limit the BIOS-provided memory map to
745 * that size. exactmap can be used to specify
746 * the exact map. mem=number can be used to
747 * trim the existing memory map.
748 */
749 unsigned long long start_at, mem_size;
751 mem_size = memparse(from+7, &from);
752 if (*from == '@') {
753 start_at = memparse(from+1, &from);
754 add_memory_region(start_at, mem_size, E820_RAM);
755 } else if (*from == '#') {
756 start_at = memparse(from+1, &from);
757 add_memory_region(start_at, mem_size, E820_ACPI);
758 } else if (*from == '$') {
759 start_at = memparse(from+1, &from);
760 add_memory_region(start_at, mem_size, E820_RESERVED);
761 } else {
762 limit_regions(mem_size);
763 userdef=1;
764 }
765 }
766 }
768 #ifdef CONFIG_X86_SMP
769 /*
770 * If the BIOS enumerates physical processors before logical,
771 * maxcpus=N at enumeration-time can be used to disable HT.
772 */
773 else if (!memcmp(from, "maxcpus=", 8)) {
774 extern unsigned int maxcpus;
776 maxcpus = simple_strtoul(from + 8, NULL, 0);
777 }
778 #endif
780 #ifdef CONFIG_ACPI_BOOT
781 /* "acpi=off" disables both ACPI table parsing and interpreter */
782 else if (!memcmp(from, "acpi=off", 8)) {
783 disable_acpi();
784 }
786 /* acpi=force to over-ride black-list */
787 else if (!memcmp(from, "acpi=force", 10)) {
788 acpi_force = 1;
789 acpi_ht = 1;
790 acpi_disabled = 0;
791 }
793 /* acpi=strict disables out-of-spec workarounds */
794 else if (!memcmp(from, "acpi=strict", 11)) {
795 acpi_strict = 1;
796 }
798 /* Limit ACPI just to boot-time to enable HT */
799 else if (!memcmp(from, "acpi=ht", 7)) {
800 if (!acpi_force)
801 disable_acpi();
802 acpi_ht = 1;
803 }
805 /* "pci=noacpi" disable ACPI IRQ routing and PCI scan */
806 else if (!memcmp(from, "pci=noacpi", 10)) {
807 acpi_disable_pci();
808 }
809 /* "acpi=noirq" disables ACPI interrupt routing */
810 else if (!memcmp(from, "acpi=noirq", 10)) {
811 acpi_noirq_set();
812 }
814 else if (!memcmp(from, "acpi_sci=edge", 13))
815 acpi_sci_flags.trigger = 1;
817 else if (!memcmp(from, "acpi_sci=level", 14))
818 acpi_sci_flags.trigger = 3;
820 else if (!memcmp(from, "acpi_sci=high", 13))
821 acpi_sci_flags.polarity = 1;
823 else if (!memcmp(from, "acpi_sci=low", 12))
824 acpi_sci_flags.polarity = 3;
826 #ifdef CONFIG_X86_IO_APIC
827 else if (!memcmp(from, "acpi_skip_timer_override", 24))
828 acpi_skip_timer_override = 1;
829 #endif
831 #ifdef CONFIG_X86_LOCAL_APIC
832 /* disable IO-APIC */
833 else if (!memcmp(from, "noapic", 6))
834 disable_ioapic_setup();
835 #endif /* CONFIG_X86_LOCAL_APIC */
836 #endif /* CONFIG_ACPI_BOOT */
838 /*
839 * highmem=size forces highmem to be exactly 'size' bytes.
840 * This works even on boxes that have no highmem otherwise.
841 * This also works to reduce highmem size on bigger boxes.
842 */
843 if (c == ' ' && !memcmp(from, "highmem=", 8))
844 highmem_pages = memparse(from+8, &from) >> PAGE_SHIFT;
846 /*
847 * vmalloc=size forces the vmalloc area to be exactly 'size'
848 * bytes. This can be used to increase (or decrease) the
849 * vmalloc area - the default is 128m.
850 */
851 if (c == ' ' && !memcmp(from, "vmalloc=", 8))
852 __VMALLOC_RESERVE = memparse(from+8, &from);
854 c = *(from++);
855 if (!c)
856 break;
857 if (COMMAND_LINE_SIZE <= ++len)
858 break;
859 *(to++) = c;
860 }
861 *to = '\0';
862 *cmdline_p = command_line;
863 if (userdef) {
864 printk(KERN_INFO "user-defined physical RAM map:\n");
865 print_memory_map("user");
866 }
867 }
869 #if 0 /* !XEN */
870 /*
871 * Callback for efi_memory_walk.
872 */
873 static int __init
874 efi_find_max_pfn(unsigned long start, unsigned long end, void *arg)
875 {
876 unsigned long *max_pfn = arg, pfn;
878 if (start < end) {
879 pfn = PFN_UP(end -1);
880 if (pfn > *max_pfn)
881 *max_pfn = pfn;
882 }
883 return 0;
884 }
886 /*
887 * Find the highest page frame number we have available
888 */
889 void __init find_max_pfn(void)
890 {
891 int i;
893 max_pfn = 0;
894 if (efi_enabled) {
895 efi_memmap_walk(efi_find_max_pfn, &max_pfn);
896 return;
897 }
899 for (i = 0; i < e820.nr_map; i++) {
900 unsigned long start, end;
901 /* RAM? */
902 if (e820.map[i].type != E820_RAM)
903 continue;
904 start = PFN_UP(e820.map[i].addr);
905 end = PFN_DOWN(e820.map[i].addr + e820.map[i].size);
906 if (start >= end)
907 continue;
908 if (end > max_pfn)
909 max_pfn = end;
910 }
911 }
912 #else
913 /* We don't use the fake e820 because we need to respond to user override. */
914 void __init find_max_pfn(void)
915 {
916 if ( xen_override_max_pfn < xen_start_info.nr_pages )
917 xen_override_max_pfn = xen_start_info.nr_pages;
918 max_pfn = xen_override_max_pfn;
919 }
920 #endif /* XEN */
922 /*
923 * Determine low and high memory ranges:
924 */
925 unsigned long __init find_max_low_pfn(void)
926 {
927 unsigned long max_low_pfn;
929 max_low_pfn = max_pfn;
930 if (max_low_pfn > MAXMEM_PFN) {
931 if (highmem_pages == -1)
932 highmem_pages = max_pfn - MAXMEM_PFN;
933 if (highmem_pages + MAXMEM_PFN < max_pfn)
934 max_pfn = MAXMEM_PFN + highmem_pages;
935 if (highmem_pages + MAXMEM_PFN > max_pfn) {
936 printk("only %luMB highmem pages available, ignoring highmem size of %uMB.\n", pages_to_mb(max_pfn - MAXMEM_PFN), pages_to_mb(highmem_pages));
937 highmem_pages = 0;
938 }
939 max_low_pfn = MAXMEM_PFN;
940 #ifndef CONFIG_HIGHMEM
941 /* Maximum memory usable is what is directly addressable */
942 printk(KERN_WARNING "Warning only %ldMB will be used.\n",
943 MAXMEM>>20);
944 if (max_pfn > MAX_NONPAE_PFN)
945 printk(KERN_WARNING "Use a PAE enabled kernel.\n");
946 else
947 printk(KERN_WARNING "Use a HIGHMEM enabled kernel.\n");
948 max_pfn = MAXMEM_PFN;
949 #else /* !CONFIG_HIGHMEM */
950 #ifndef CONFIG_X86_PAE
951 if (max_pfn > MAX_NONPAE_PFN) {
952 max_pfn = MAX_NONPAE_PFN;
953 printk(KERN_WARNING "Warning only 4GB will be used.\n");
954 printk(KERN_WARNING "Use a PAE enabled kernel.\n");
955 }
956 #endif /* !CONFIG_X86_PAE */
957 #endif /* !CONFIG_HIGHMEM */
958 } else {
959 if (highmem_pages == -1)
960 highmem_pages = 0;
961 #ifdef CONFIG_HIGHMEM
962 if (highmem_pages >= max_pfn) {
963 printk(KERN_ERR "highmem size specified (%uMB) is bigger than pages available (%luMB)!.\n", pages_to_mb(highmem_pages), pages_to_mb(max_pfn));
964 highmem_pages = 0;
965 }
966 if (highmem_pages) {
967 if (max_low_pfn-highmem_pages < 64*1024*1024/PAGE_SIZE){
968 printk(KERN_ERR "highmem size %uMB results in smaller than 64MB lowmem, ignoring it.\n", pages_to_mb(highmem_pages));
969 highmem_pages = 0;
970 }
971 max_low_pfn -= highmem_pages;
972 }
973 #else
974 if (highmem_pages)
975 printk(KERN_ERR "ignoring highmem size on non-highmem kernel!\n");
976 #endif
977 }
978 return max_low_pfn;
979 }
981 #ifndef CONFIG_DISCONTIGMEM
983 /*
984 * Free all available memory for boot time allocation. Used
985 * as a callback function by efi_memory_walk()
986 */
988 static int __init
989 free_available_memory(unsigned long start, unsigned long end, void *arg)
990 {
991 /* check max_low_pfn */
992 if (start >= ((max_low_pfn + 1) << PAGE_SHIFT))
993 return 0;
994 if (end >= ((max_low_pfn + 1) << PAGE_SHIFT))
995 end = (max_low_pfn + 1) << PAGE_SHIFT;
996 if (start < end)
997 free_bootmem(start, end - start);
999 return 0;
1001 /*
1002 * Register fully available low RAM pages with the bootmem allocator.
1003 */
1004 static void __init register_bootmem_low_pages(unsigned long max_low_pfn)
1006 int i;
1008 if (efi_enabled) {
1009 efi_memmap_walk(free_available_memory, NULL);
1010 return;
1012 for (i = 0; i < e820.nr_map; i++) {
1013 unsigned long curr_pfn, last_pfn, size;
1014 /*
1015 * Reserve usable low memory
1016 */
1017 if (e820.map[i].type != E820_RAM)
1018 continue;
1019 /*
1020 * We are rounding up the start address of usable memory:
1021 */
1022 curr_pfn = PFN_UP(e820.map[i].addr);
1023 if (curr_pfn >= max_low_pfn)
1024 continue;
1025 /*
1026 * ... and at the end of the usable range downwards:
1027 */
1028 last_pfn = PFN_DOWN(e820.map[i].addr + e820.map[i].size);
1030 if (last_pfn > max_low_pfn)
1031 last_pfn = max_low_pfn;
1033 /*
1034 * .. finally, did all the rounding and playing
1035 * around just make the area go away?
1036 */
1037 if (last_pfn <= curr_pfn)
1038 continue;
1040 size = last_pfn - curr_pfn;
1041 free_bootmem(PFN_PHYS(curr_pfn), PFN_PHYS(size));
1045 /*
1046 * workaround for Dell systems that neglect to reserve EBDA
1047 */
1048 static void __init reserve_ebda_region(void)
1050 unsigned int addr;
1051 addr = get_bios_ebda();
1052 if (addr)
1053 reserve_bootmem(addr, PAGE_SIZE);
1056 static unsigned long __init setup_memory(void)
1058 unsigned long bootmap_size, start_pfn, max_low_pfn;
1060 /*
1061 * partially used pages are not usable - thus
1062 * we are rounding upwards:
1063 */
1064 start_pfn = PFN_UP(__pa(xen_start_info.pt_base)) + xen_start_info.nr_pt_frames;
1066 find_max_pfn();
1068 max_low_pfn = find_max_low_pfn();
1070 #ifdef CONFIG_HIGHMEM
1071 highstart_pfn = highend_pfn = max_pfn;
1072 if (max_pfn > max_low_pfn) {
1073 highstart_pfn = max_low_pfn;
1075 printk(KERN_NOTICE "%ldMB HIGHMEM available.\n",
1076 pages_to_mb(highend_pfn - highstart_pfn));
1077 #endif
1078 printk(KERN_NOTICE "%ldMB LOWMEM available.\n",
1079 pages_to_mb(max_low_pfn));
1080 /*
1081 * Initialize the boot-time allocator (with low memory only):
1082 */
1083 bootmap_size = init_bootmem(start_pfn, max_low_pfn);
1085 register_bootmem_low_pages(max_low_pfn);
1087 /*
1088 * Reserve the bootmem bitmap itself as well. We do this in two
1089 * steps (first step was init_bootmem()) because this catches
1090 * the (very unlikely) case of us accidentally initializing the
1091 * bootmem allocator with an invalid RAM area.
1092 */
1093 reserve_bootmem(HIGH_MEMORY, (PFN_PHYS(start_pfn) +
1094 bootmap_size + PAGE_SIZE-1) - (HIGH_MEMORY));
1096 /* reserve EBDA region, it's a 4K region */
1097 reserve_ebda_region();
1099 /* could be an AMD 768MPX chipset. Reserve a page before VGA to prevent
1100 PCI prefetch into it (errata #56). Usually the page is reserved anyways,
1101 unless you have no PS/2 mouse plugged in. */
1102 if (boot_cpu_data.x86_vendor == X86_VENDOR_AMD &&
1103 boot_cpu_data.x86 == 6)
1104 reserve_bootmem(0xa0000 - 4096, 4096);
1106 #ifdef CONFIG_SMP
1107 /*
1108 * But first pinch a few for the stack/trampoline stuff
1109 * FIXME: Don't need the extra page at 4K, but need to fix
1110 * trampoline before removing it. (see the GDT stuff)
1111 */
1112 reserve_bootmem(PAGE_SIZE, PAGE_SIZE);
1113 #endif
1114 #ifdef CONFIG_ACPI_SLEEP
1115 /*
1116 * Reserve low memory region for sleep support.
1117 */
1118 acpi_reserve_bootmem();
1119 #endif
1120 #ifdef CONFIG_X86_FIND_SMP_CONFIG
1121 /*
1122 * Find and reserve possible boot-time SMP configuration:
1123 */
1124 find_smp_config();
1125 #endif
1127 #ifdef CONFIG_BLK_DEV_INITRD
1128 if (xen_start_info.mod_start) {
1129 if (INITRD_START + INITRD_SIZE <= (max_low_pfn << PAGE_SHIFT)) {
1130 /*reserve_bootmem(INITRD_START, INITRD_SIZE);*/
1131 initrd_start = INITRD_START + PAGE_OFFSET;
1132 initrd_end = initrd_start+INITRD_SIZE;
1133 initrd_below_start_ok = 1;
1135 else {
1136 printk(KERN_ERR "initrd extends beyond end of memory "
1137 "(0x%08lx > 0x%08lx)\ndisabling initrd\n",
1138 INITRD_START + INITRD_SIZE,
1139 max_low_pfn << PAGE_SHIFT);
1140 initrd_start = 0;
1143 #endif
1145 phys_to_machine_mapping = (unsigned long *)xen_start_info.mfn_list;
1147 return max_low_pfn;
1149 #else
1150 extern unsigned long setup_memory(void);
1151 #endif /* !CONFIG_DISCONTIGMEM */
1153 /*
1154 * Request address space for all standard RAM and ROM resources
1155 * and also for regions reported as reserved by the e820.
1156 */
1157 static void __init
1158 legacy_init_iomem_resources(struct resource *code_resource, struct resource *data_resource)
1160 int i;
1162 #ifdef CONFIG_XEN_PRIVILEGED_GUEST
1163 probe_roms();
1164 #endif
1165 for (i = 0; i < e820.nr_map; i++) {
1166 struct resource *res;
1167 if (e820.map[i].addr + e820.map[i].size > 0x100000000ULL)
1168 continue;
1169 res = alloc_bootmem_low(sizeof(struct resource));
1170 switch (e820.map[i].type) {
1171 case E820_RAM: res->name = "System RAM"; break;
1172 case E820_ACPI: res->name = "ACPI Tables"; break;
1173 case E820_NVS: res->name = "ACPI Non-volatile Storage"; break;
1174 default: res->name = "reserved";
1176 res->start = e820.map[i].addr;
1177 res->end = res->start + e820.map[i].size - 1;
1178 res->flags = IORESOURCE_MEM | IORESOURCE_BUSY;
1179 request_resource(&iomem_resource, res);
1180 if (e820.map[i].type == E820_RAM) {
1181 /*
1182 * We don't know which RAM region contains kernel data,
1183 * so we try it repeatedly and let the resource manager
1184 * test it.
1185 */
1186 request_resource(res, code_resource);
1187 request_resource(res, data_resource);
1192 /*
1193 * Request address space for all standard resources
1194 */
1195 static void __init register_memory(unsigned long max_low_pfn)
1197 unsigned long low_mem_size;
1198 int i;
1200 if (efi_enabled)
1201 efi_initialize_iomem_resources(&code_resource, &data_resource);
1202 else
1203 legacy_init_iomem_resources(&code_resource, &data_resource);
1205 /* EFI systems may still have VGA */
1206 request_resource(&iomem_resource, &video_ram_resource);
1208 /* request I/O space for devices used on all i[345]86 PCs */
1209 for (i = 0; i < STANDARD_IO_RESOURCES; i++)
1210 request_resource(&ioport_resource, &standard_io_resources[i]);
1212 /* Tell the PCI layer not to allocate too close to the RAM area.. */
1213 low_mem_size = ((max_low_pfn << PAGE_SHIFT) + 0xfffff) & ~0xfffff;
1214 if (low_mem_size > pci_mem_start)
1215 pci_mem_start = low_mem_size;
1218 /* Use inline assembly to define this because the nops are defined
1219 as inline assembly strings in the include files and we cannot
1220 get them easily into strings. */
1221 asm("\t.data\nintelnops: "
1222 GENERIC_NOP1 GENERIC_NOP2 GENERIC_NOP3 GENERIC_NOP4 GENERIC_NOP5 GENERIC_NOP6
1223 GENERIC_NOP7 GENERIC_NOP8);
1224 asm("\t.data\nk8nops: "
1225 K8_NOP1 K8_NOP2 K8_NOP3 K8_NOP4 K8_NOP5 K8_NOP6
1226 K8_NOP7 K8_NOP8);
1227 asm("\t.data\nk7nops: "
1228 K7_NOP1 K7_NOP2 K7_NOP3 K7_NOP4 K7_NOP5 K7_NOP6
1229 K7_NOP7 K7_NOP8);
1231 extern unsigned char intelnops[], k8nops[], k7nops[];
1232 static unsigned char *intel_nops[ASM_NOP_MAX+1] = {
1233 NULL,
1234 intelnops,
1235 intelnops + 1,
1236 intelnops + 1 + 2,
1237 intelnops + 1 + 2 + 3,
1238 intelnops + 1 + 2 + 3 + 4,
1239 intelnops + 1 + 2 + 3 + 4 + 5,
1240 intelnops + 1 + 2 + 3 + 4 + 5 + 6,
1241 intelnops + 1 + 2 + 3 + 4 + 5 + 6 + 7,
1242 };
1243 static unsigned char *k8_nops[ASM_NOP_MAX+1] = {
1244 NULL,
1245 k8nops,
1246 k8nops + 1,
1247 k8nops + 1 + 2,
1248 k8nops + 1 + 2 + 3,
1249 k8nops + 1 + 2 + 3 + 4,
1250 k8nops + 1 + 2 + 3 + 4 + 5,
1251 k8nops + 1 + 2 + 3 + 4 + 5 + 6,
1252 k8nops + 1 + 2 + 3 + 4 + 5 + 6 + 7,
1253 };
1254 static unsigned char *k7_nops[ASM_NOP_MAX+1] = {
1255 NULL,
1256 k7nops,
1257 k7nops + 1,
1258 k7nops + 1 + 2,
1259 k7nops + 1 + 2 + 3,
1260 k7nops + 1 + 2 + 3 + 4,
1261 k7nops + 1 + 2 + 3 + 4 + 5,
1262 k7nops + 1 + 2 + 3 + 4 + 5 + 6,
1263 k7nops + 1 + 2 + 3 + 4 + 5 + 6 + 7,
1264 };
1265 static struct nop {
1266 int cpuid;
1267 unsigned char **noptable;
1268 } noptypes[] = {
1269 { X86_FEATURE_K8, k8_nops },
1270 { X86_FEATURE_K7, k7_nops },
1271 { -1, NULL }
1272 };
1274 /* Replace instructions with better alternatives for this CPU type.
1276 This runs before SMP is initialized to avoid SMP problems with
1277 self modifying code. This implies that assymetric systems where
1278 APs have less capabilities than the boot processor are not handled.
1279 In this case boot with "noreplacement". */
1280 void apply_alternatives(void *start, void *end)
1282 struct alt_instr *a;
1283 int diff, i, k;
1284 unsigned char **noptable = intel_nops;
1285 for (i = 0; noptypes[i].cpuid >= 0; i++) {
1286 if (boot_cpu_has(noptypes[i].cpuid)) {
1287 noptable = noptypes[i].noptable;
1288 break;
1291 for (a = start; (void *)a < end; a++) {
1292 if (!boot_cpu_has(a->cpuid))
1293 continue;
1294 BUG_ON(a->replacementlen > a->instrlen);
1295 memcpy(a->instr, a->replacement, a->replacementlen);
1296 diff = a->instrlen - a->replacementlen;
1297 /* Pad the rest with nops */
1298 for (i = a->replacementlen; diff > 0; diff -= k, i += k) {
1299 k = diff;
1300 if (k > ASM_NOP_MAX)
1301 k = ASM_NOP_MAX;
1302 memcpy(a->instr + i, noptable[k], k);
1307 static int no_replacement __initdata = 0;
1309 void __init alternative_instructions(void)
1311 extern struct alt_instr __alt_instructions[], __alt_instructions_end[];
1312 if (no_replacement)
1313 return;
1314 apply_alternatives(__alt_instructions, __alt_instructions_end);
1317 static int __init noreplacement_setup(char *s)
1319 no_replacement = 1;
1320 return 0;
1323 __setup("noreplacement", noreplacement_setup);
1325 static char * __init machine_specific_memory_setup(void);
1327 /*
1328 * Determine if we were loaded by an EFI loader. If so, then we have also been
1329 * passed the efi memmap, systab, etc., so we should use these data structures
1330 * for initialization. Note, the efi init code path is determined by the
1331 * global efi_enabled. This allows the same kernel image to be used on existing
1332 * systems (with a traditional BIOS) as well as on EFI systems.
1333 */
1334 void __init setup_arch(char **cmdline_p)
1336 int i,j;
1338 unsigned long max_low_pfn;
1340 /* Force a quick death if the kernel panics. */
1341 extern int panic_timeout;
1342 if ( panic_timeout == 0 )
1343 panic_timeout = 1;
1345 HYPERVISOR_vm_assist(VMASST_CMD_enable,
1346 VMASST_TYPE_4gb_segments);
1348 memcpy(&boot_cpu_data, &new_cpu_data, sizeof(new_cpu_data));
1349 early_cpu_init();
1351 /*
1352 * FIXME: This isn't an official loader_type right
1353 * now but does currently work with elilo.
1354 * If we were configured as an EFI kernel, check to make
1355 * sure that we were loaded correctly from elilo and that
1356 * the system table is valid. If not, then initialize normally.
1357 */
1358 #ifdef CONFIG_EFI
1359 if ((LOADER_TYPE == 0x50) && EFI_SYSTAB)
1360 efi_enabled = 1;
1361 #endif
1363 ROOT_DEV = MKDEV(RAMDISK_MAJOR,0); /*old_decode_dev(ORIG_ROOT_DEV);*/
1364 drive_info = DRIVE_INFO;
1365 screen_info = SCREEN_INFO;
1366 edid_info = EDID_INFO;
1367 apm_info.bios = APM_BIOS_INFO;
1368 ist_info = IST_INFO;
1369 saved_videomode = VIDEO_MODE;
1370 if( SYS_DESC_TABLE.length != 0 ) {
1371 MCA_bus = SYS_DESC_TABLE.table[3] &0x2;
1372 machine_id = SYS_DESC_TABLE.table[0];
1373 machine_submodel_id = SYS_DESC_TABLE.table[1];
1374 BIOS_revision = SYS_DESC_TABLE.table[2];
1376 aux_device_present = AUX_DEVICE_INFO;
1378 #ifdef CONFIG_XEN_PHYSDEV_ACCESS
1379 /* This is drawn from a dump from vgacon:startup in standard Linux. */
1380 screen_info.orig_video_mode = 3;
1381 screen_info.orig_video_isVGA = 1;
1382 screen_info.orig_video_lines = 25;
1383 screen_info.orig_video_cols = 80;
1384 screen_info.orig_video_ega_bx = 3;
1385 screen_info.orig_video_points = 16;
1386 #endif
1388 #ifdef CONFIG_BLK_DEV_RAM
1389 rd_image_start = RAMDISK_FLAGS & RAMDISK_IMAGE_START_MASK;
1390 rd_prompt = ((RAMDISK_FLAGS & RAMDISK_PROMPT_FLAG) != 0);
1391 rd_doload = ((RAMDISK_FLAGS & RAMDISK_LOAD_FLAG) != 0);
1392 #endif
1393 ARCH_SETUP
1394 if (efi_enabled)
1395 efi_init();
1396 else {
1397 printk(KERN_INFO "BIOS-provided physical RAM map:\n");
1398 print_memory_map(machine_specific_memory_setup());
1401 copy_edd();
1403 if (!MOUNT_ROOT_RDONLY)
1404 root_mountflags &= ~MS_RDONLY;
1405 init_mm.start_code = (unsigned long) _text;
1406 init_mm.end_code = (unsigned long) _etext;
1407 init_mm.end_data = (unsigned long) _edata;
1408 init_mm.brk = (PFN_UP(__pa(xen_start_info.pt_base)) + xen_start_info.nr_pt_frames) << PAGE_SHIFT;
1410 /* XEN: This is nonsense: kernel may not even be contiguous in RAM. */
1411 /*code_resource.start = virt_to_phys(_text);*/
1412 /*code_resource.end = virt_to_phys(_etext)-1;*/
1413 /*data_resource.start = virt_to_phys(_etext);*/
1414 /*data_resource.end = virt_to_phys(_edata)-1;*/
1416 parse_cmdline_early(cmdline_p);
1418 max_low_pfn = setup_memory();
1420 /*
1421 * NOTE: before this point _nobody_ is allowed to allocate
1422 * any memory using the bootmem allocator. Although the
1423 * alloctor is now initialised only the first 8Mb of the kernel
1424 * virtual address space has been mapped. All allocations before
1425 * paging_init() has completed must use the alloc_bootmem_low_pages()
1426 * variant (which allocates DMA'able memory) and care must be taken
1427 * not to exceed the 8Mb limit.
1428 */
1430 #ifdef CONFIG_SMP
1431 smp_alloc_memory(); /* AP processor realmode stacks in low memory*/
1432 #endif
1433 paging_init();
1435 /* Make sure we have a large enough P->M table. */
1436 if (max_pfn > xen_start_info.nr_pages) {
1437 phys_to_machine_mapping = alloc_bootmem_low_pages(
1438 max_pfn * sizeof(unsigned long));
1439 memset(phys_to_machine_mapping, ~0,
1440 max_pfn * sizeof(unsigned long));
1441 memcpy(phys_to_machine_mapping,
1442 (unsigned long *)xen_start_info.mfn_list,
1443 xen_start_info.nr_pages * sizeof(unsigned long));
1444 free_bootmem(
1445 __pa(xen_start_info.mfn_list),
1446 PFN_PHYS(PFN_UP(xen_start_info.nr_pages *
1447 sizeof(unsigned long))));
1450 pfn_to_mfn_frame_list = alloc_bootmem_low_pages(PAGE_SIZE);
1451 for ( i=0, j=0; i < max_pfn; i+=(PAGE_SIZE/sizeof(unsigned long)), j++ )
1453 pfn_to_mfn_frame_list[j] =
1454 virt_to_machine(&phys_to_machine_mapping[i]) >> PAGE_SHIFT;
1456 HYPERVISOR_shared_info->arch.pfn_to_mfn_frame_list =
1457 virt_to_machine(pfn_to_mfn_frame_list) >> PAGE_SHIFT;
1460 /*
1461 * NOTE: at this point the bootmem allocator is fully available.
1462 */
1464 #ifdef CONFIG_EARLY_PRINTK
1466 char *s = strstr(*cmdline_p, "earlyprintk=");
1467 if (s) {
1468 extern void setup_early_printk(char *);
1470 setup_early_printk(s);
1471 printk("early console enabled\n");
1474 #endif
1477 dmi_scan_machine();
1479 #ifdef CONFIG_X86_GENERICARCH
1480 generic_apic_probe(*cmdline_p);
1481 #endif
1482 if (efi_enabled)
1483 efi_map_memmap();
1485 /*
1486 * Parse the ACPI tables for possible boot-time SMP configuration.
1487 */
1488 acpi_boot_init();
1490 #ifdef CONFIG_X86_LOCAL_APIC
1491 if (smp_found_config)
1492 get_smp_config();
1493 #endif
1495 /* XXX Disable irqdebug until we have a way to avoid interrupt
1496 * conflicts. */
1497 noirqdebug_setup("");
1499 register_memory(max_low_pfn);
1501 /* If we are a privileged guest OS then we should request IO privs. */
1502 if (xen_start_info.flags & SIF_PRIVILEGED) {
1503 dom0_op_t op;
1504 op.cmd = DOM0_IOPL;
1505 op.u.iopl.domain = DOMID_SELF;
1506 op.u.iopl.iopl = 1;
1507 if (HYPERVISOR_dom0_op(&op) != 0)
1508 panic("Unable to obtain IOPL, despite SIF_PRIVILEGED");
1509 current->thread.io_pl = 1;
1512 if (xen_start_info.flags & SIF_INITDOMAIN) {
1513 if (!(xen_start_info.flags & SIF_PRIVILEGED))
1514 panic("Xen granted us console access "
1515 "but not privileged status");
1517 #ifdef CONFIG_VT
1518 #if defined(CONFIG_VGA_CONSOLE)
1519 if (!efi_enabled ||
1520 (efi_mem_type(0xa0000) != EFI_CONVENTIONAL_MEMORY))
1521 conswitchp = &vga_con;
1522 #elif defined(CONFIG_DUMMY_CONSOLE)
1523 conswitchp = &dummy_con;
1524 #endif
1525 #endif
1526 } else {
1527 #ifdef CONFIG_XEN_PRIVILEGED_GUEST
1528 extern const struct consw xennull_con;
1529 extern int console_use_vt;
1530 #if defined(CONFIG_VGA_CONSOLE)
1531 /* disable VGA driver */
1532 ORIG_VIDEO_ISVGA = VIDEO_TYPE_VLFB;
1533 #endif
1534 conswitchp = &xennull_con;
1535 console_use_vt = 0;
1536 #endif
1540 #include "setup_arch_post.h"
1541 /*
1542 * Local Variables:
1543 * mode:c
1544 * c-file-style:"k&r"
1545 * c-basic-offset:8
1546 * End:
1547 */