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