ia64/xen-unstable

view linux-2.6.10-xen-sparse/arch/xen/i386/kernel/setup.c @ 3624:351e129e3735

bitkeeper revision 1.1159.223.59 (420156d4cxaGMuI8rtUWoTShsPVlNQ)

setup.c:
Always disable irqdebug until we have a way to avoid interrupt conflicts.

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