ia64/xen-unstable

annotate xen/arch/x86/setup.c @ 6725:a5e9a7fcade9

cleanups
author kaf24@firebug.cl.cam.ac.uk
date Fri Sep 09 16:17:17 2005 +0000 (2005-09-09)
parents ec4a3f2d060e
children 813c37b68376
rev   line source
kaf24@1452 1
kaf24@1452 2 #include <xen/config.h>
kaf24@1452 3 #include <xen/init.h>
kaf24@1452 4 #include <xen/lib.h>
kaf24@1452 5 #include <xen/sched.h>
cl349@5247 6 #include <xen/domain.h>
kaf24@1452 7 #include <xen/serial.h>
kaf24@1506 8 #include <xen/softirq.h>
kaf24@1452 9 #include <xen/acpi.h>
kaf24@3338 10 #include <xen/console.h>
iap10@4287 11 #include <xen/serial.h>
kaf24@3338 12 #include <xen/trace.h>
kaf24@3338 13 #include <xen/multiboot.h>
kaf24@5356 14 #include <xen/domain_page.h>
iap10@6721 15 #include <xen/compile.h>
iap10@6721 16 #include <public/version.h>
kaf24@1452 17 #include <asm/bitops.h>
kaf24@1452 18 #include <asm/smp.h>
kaf24@1452 19 #include <asm/processor.h>
kaf24@1452 20 #include <asm/mpspec.h>
kaf24@1452 21 #include <asm/apic.h>
kaf24@1452 22 #include <asm/desc.h>
kaf24@3338 23 #include <asm/shadow.h>
kaf24@3344 24 #include <asm/e820.h>
kaf24@5536 25 #include <acm/acm_hooks.h>
kaf24@3338 26
kaf24@5157 27 extern void dmi_scan_machine(void);
kaf24@5211 28 extern void generic_apic_probe(void);
kaf24@5157 29
kaf24@3338 30 /*
kaf24@3338 31 * opt_xenheap_megabytes: Size of Xen heap in megabytes, excluding the
kaf24@3338 32 * pfn_info table and allocation bitmap.
kaf24@3338 33 */
kaf24@3338 34 static unsigned int opt_xenheap_megabytes = XENHEAP_DEFAULT_MB;
kaf24@4950 35 #if defined(CONFIG_X86_64)
kaf24@3338 36 integer_param("xenheap_megabytes", opt_xenheap_megabytes);
kaf24@3354 37 #endif
kaf24@1452 38
kaf24@5146 39 /* opt_nosmp: If true, secondary processors are ignored. */
kaf24@5900 40 static int opt_nosmp = 0;
kaf24@5146 41 boolean_param("nosmp", opt_nosmp);
kaf24@5146 42
kaf24@5146 43 /* maxcpus: maximum number of CPUs to activate. */
kaf24@5146 44 static unsigned int max_cpus = NR_CPUS;
kaf24@5146 45 integer_param("maxcpus", max_cpus);
kaf24@5146 46
kaf24@3334 47 /* opt_watchdog: If true, run a watchdog NMI on each processor. */
kaf24@3334 48 static int opt_watchdog = 0;
kaf24@3334 49 boolean_param("watchdog", opt_watchdog);
kaf24@3334 50
kaf24@4850 51 /* **** Linux config option: propagated to domain0. */
kaf24@4850 52 /* "acpi=off": Sisables both ACPI table parsing and interpreter. */
kaf24@4850 53 /* "acpi=force": Override the disable blacklist. */
kaf24@4850 54 /* "acpi=strict": Disables out-of-spec workarounds. */
kaf24@4850 55 /* "acpi=ht": Limit ACPI just to boot-time to enable HT. */
kaf24@4850 56 /* "acpi=noirq": Disables ACPI interrupt routing. */
kaf24@4850 57 static void parse_acpi_param(char *s);
kaf24@4850 58 custom_param("acpi", parse_acpi_param);
kaf24@4850 59
kaf24@4850 60 /* **** Linux config option: propagated to domain0. */
kaf24@4850 61 /* acpi_skip_timer_override: Skip IRQ0 overrides. */
kaf24@4850 62 extern int acpi_skip_timer_override;
kaf24@4850 63 boolean_param("acpi_skip_timer_override", acpi_skip_timer_override);
kaf24@4850 64
kaf24@4850 65 /* **** Linux config option: propagated to domain0. */
kaf24@4850 66 /* noapic: Disable IOAPIC setup. */
kaf24@4850 67 extern int skip_ioapic_setup;
kaf24@4850 68 boolean_param("noapic", skip_ioapic_setup);
kaf24@4850 69
kaf24@3594 70 int early_boot = 1;
kaf24@3594 71
kaf24@5146 72 cpumask_t cpu_present_map;
kaf24@5146 73
kaf24@5003 74 /* Limits of Xen heap, used to initialise the allocator. */
kaf24@5003 75 unsigned long xenheap_phys_start, xenheap_phys_end;
kaf24@3338 76
kaf24@2298 77 extern void arch_init_memory(void);
kaf24@1589 78 extern void init_IRQ(void);
kaf24@1589 79 extern void trap_init(void);
kaf24@5604 80 extern void early_time_init(void);
kaf24@1589 81 extern void ac_timer_init(void);
kaf24@5167 82 extern void initialize_keytable(void);
kaf24@5167 83 extern void early_cpu_init(void);
kaf24@1589 84
kaf24@5011 85 extern unsigned long cpu0_stack[];
kaf24@5011 86
kaf24@5214 87 struct cpuinfo_x86 boot_cpu_data = { 0, 0, 0, 0, -1, 1, 0, 0, -1 };
kaf24@1452 88
kaf24@5237 89 #if CONFIG_PAGING_LEVELS > 2
kaf24@1670 90 unsigned long mmu_cr4_features = X86_CR4_PSE | X86_CR4_PGE | X86_CR4_PAE;
kaf24@1670 91 #else
kaf24@5593 92 unsigned long mmu_cr4_features = X86_CR4_PSE;
kaf24@1670 93 #endif
kaf24@1452 94 EXPORT_SYMBOL(mmu_cr4_features);
kaf24@1452 95
kaf24@5289 96 struct vcpu *idle_task[NR_CPUS] = { &idle0_vcpu };
kaf24@1452 97
kaf24@4818 98 int acpi_disabled;
kaf24@1452 99
kaf24@4850 100 int acpi_force;
kaf24@4850 101 char acpi_param[10] = "";
kaf24@4850 102 static void parse_acpi_param(char *s)
kaf24@4850 103 {
kaf24@4850 104 /* Save the parameter so it can be propagated to domain0. */
kaf24@4850 105 strncpy(acpi_param, s, sizeof(acpi_param));
kaf24@4850 106 acpi_param[sizeof(acpi_param)-1] = '\0';
kaf24@4850 107
kaf24@4850 108 /* Interpret the parameter for use within Xen. */
kaf24@4850 109 if ( !strcmp(s, "off") )
kaf24@4850 110 {
kaf24@4850 111 disable_acpi();
kaf24@4850 112 }
kaf24@4850 113 else if ( !strcmp(s, "force") )
kaf24@4850 114 {
kaf24@4850 115 acpi_force = 1;
kaf24@4850 116 acpi_ht = 1;
kaf24@4850 117 acpi_disabled = 0;
kaf24@4850 118 }
kaf24@4850 119 else if ( !strcmp(s, "strict") )
kaf24@4850 120 {
kaf24@4850 121 acpi_strict = 1;
kaf24@4850 122 }
kaf24@4850 123 else if ( !strcmp(s, "ht") )
kaf24@4850 124 {
kaf24@4850 125 if ( !acpi_force )
kaf24@4850 126 disable_acpi();
kaf24@4850 127 acpi_ht = 1;
kaf24@4850 128 }
kaf24@4850 129 else if ( !strcmp(s, "noirq") )
kaf24@4850 130 {
kaf24@4850 131 acpi_noirq_set();
kaf24@4850 132 }
kaf24@4850 133 }
kaf24@4850 134
kaf24@1452 135 static void __init do_initcalls(void)
kaf24@1452 136 {
kaf24@1452 137 initcall_t *call;
kaf24@1452 138 for ( call = &__initcall_start; call < &__initcall_end; call++ )
kaf24@1452 139 (*call)();
kaf24@1452 140 }
kaf24@1452 141
kaf24@3338 142 static void __init start_of_day(void)
kaf24@1452 143 {
kaf24@5146 144 int i;
kaf24@5146 145
kaf24@5214 146 early_cpu_init();
kaf24@5214 147
kaf24@5298 148 paging_init();
kaf24@5298 149
kaf24@1452 150 /* Unmap the first page of CPU0's stack. */
kaf24@3686 151 memguard_guard_stack(cpu0_stack);
kaf24@1452 152
kaf24@1505 153 open_softirq(NEW_TLBFLUSH_CLOCK_PERIOD_SOFTIRQ, new_tlbflush_clock_period);
kaf24@1452 154
kaf24@1452 155 if ( opt_watchdog )
kaf24@1452 156 nmi_watchdog = NMI_LOCAL_APIC;
kaf24@1452 157
kaf24@3120 158 sort_exception_tables();
kaf24@3120 159
kaf24@3272 160 arch_do_createdomain(current);
kaf24@4972 161
kaf24@4972 162 /* Map default GDT into their final position in the idle page table. */
kaf24@5003 163 map_pages_to_xen(
kaf24@4972 164 GDT_VIRT_START(current) + FIRST_RESERVED_GDT_BYTE,
kaf24@5004 165 virt_to_phys(gdt_table) >> PAGE_SHIFT, 1, PAGE_HYPERVISOR);
kaf24@3272 166
kaf24@4850 167 find_smp_config();
kaf24@4850 168
kaf24@4850 169 smp_alloc_memory();
kaf24@4850 170
kaf24@5157 171 dmi_scan_machine();
kaf24@5157 172
kaf24@5211 173 generic_apic_probe();
kaf24@5157 174
kaf24@4850 175 acpi_boot_table_init();
kaf24@4850 176 acpi_boot_init();
kaf24@4850 177
kaf24@1452 178 if ( smp_found_config )
kaf24@1452 179 get_smp_config();
kaf24@4850 180
kaf24@4850 181 init_apic_mappings();
kaf24@4850 182
kaf24@4850 183 init_IRQ();
kaf24@4850 184
kaf24@1452 185 trap_init();
kaf24@4850 186
kaf24@5174 187 ac_timer_init();
kaf24@5174 188
kaf24@5604 189 early_time_init();
kaf24@1452 190
kaf24@2298 191 arch_init_memory();
kaf24@2298 192
kaf24@5536 193 scheduler_init();
kaf24@1452 194
kaf24@5214 195 identify_cpu(&boot_cpu_data);
kaf24@5214 196 if ( cpu_has_fxsr )
kaf24@5214 197 set_in_cr4(X86_CR4_OSFXSR);
kaf24@5214 198 if ( cpu_has_xmm )
kaf24@5214 199 set_in_cr4(X86_CR4_OSXMMEXCPT);
kaf24@5214 200
kaf24@5146 201 if ( opt_nosmp )
kaf24@5900 202 {
kaf24@5146 203 max_cpus = 0;
kaf24@5900 204 smp_num_siblings = 1;
kaf24@5900 205 boot_cpu_data.x86_num_cores = 1;
kaf24@5900 206 }
kaf24@5900 207
kaf24@5146 208 smp_prepare_cpus(max_cpus);
kaf24@5146 209
kaf24@5146 210 /* We aren't hotplug-capable yet. */
kaf24@5146 211 BUG_ON(!cpus_empty(cpu_present_map));
kaf24@5146 212 for_each_cpu ( i )
kaf24@5146 213 cpu_set(i, cpu_present_map);
kaf24@1452 214
kaf24@5604 215 /*
kaf24@5604 216 * Initialise higher-level timer functions. We do this fairly late
kaf24@5604 217 * (post-SMP) because the time bases and scale factors need to be updated
kaf24@5604 218 * regularly, and SMP initialisation can cause a long delay with
kaf24@5604 219 * interrupts not yet enabled.
kaf24@5604 220 */
kaf24@5604 221 init_xen_time();
kaf24@5177 222
kaf24@4850 223 initialize_keytable();
kaf24@1452 224
kaf24@5195 225 serial_init_postirq();
kaf24@1452 226
kaf24@5604 227 BUG_ON(!local_irq_is_enabled());
kaf24@5146 228
kaf24@5146 229 for_each_present_cpu ( i )
kaf24@1452 230 {
kaf24@5146 231 if ( num_online_cpus() >= max_cpus )
kaf24@5146 232 break;
kaf24@5146 233 if ( !cpu_online(i) )
kaf24@5146 234 __cpu_up(i);
kaf24@1452 235 }
kaf24@1452 236
kaf24@5146 237 printk("Brought up %ld CPUs\n", (long)num_online_cpus());
kaf24@5146 238 smp_cpus_done(max_cpus);
kaf24@1452 239
kaf24@1452 240 do_initcalls();
kaf24@1452 241
kaf24@5146 242 schedulers_start();
kaf24@1452 243
kaf24@4926 244 watchdog_enable();
kaf24@1452 245 }
kaf24@3338 246
kaf24@5011 247 #define EARLY_FAIL() for ( ; ; ) __asm__ __volatile__ ( "hlt" )
kaf24@5011 248
iap10@6238 249 static struct e820entry e820_raw[E820MAX];
iap10@6238 250
kaf24@3338 251 void __init __start_xen(multiboot_info_t *mbi)
kaf24@3338 252 {
riel@3992 253 char *cmdline;
kaf24@3338 254 module_t *mod = (module_t *)__va(mbi->mods_addr);
kaf24@6111 255 unsigned long nr_pages, modules_length;
kaf24@3338 256 unsigned long initial_images_start, initial_images_end;
kaf24@5859 257 unsigned long _initrd_start = 0, _initrd_len = 0;
kaf24@5859 258 unsigned int initrdidx = 1;
kaf24@6111 259 physaddr_t s, e;
kaf24@3354 260 int i, e820_raw_nr = 0, bytes = 0;
kaf24@5776 261 struct ns16550_defaults ns16550 = {
kaf24@5776 262 .data_bits = 8,
kaf24@5776 263 .parity = 'n',
kaf24@5776 264 .stop_bits = 1
kaf24@5776 265 };
kaf24@3338 266
kaf24@3338 267 /* Parse the command-line options. */
kaf24@3344 268 if ( (mbi->flags & MBI_CMDLINE) && (mbi->cmdline != 0) )
kaf24@5211 269 cmdline_parse(__va(mbi->cmdline));
kaf24@3338 270
kaf24@3338 271 /* Must do this early -- e.g., spinlocks rely on get_current(). */
kaf24@5289 272 set_current(&idle0_vcpu);
kaf24@4986 273 set_processor_id(0);
kaf24@3338 274
kaf24@5146 275 smp_prepare_boot_cpu();
kaf24@5146 276
kaf24@3338 277 /* We initialise the serial devices very early so we can get debugging. */
kaf24@5776 278 ns16550.io_base = 0x3f8;
kaf24@5776 279 ns16550.irq = 4;
kaf24@5776 280 ns16550_init(0, &ns16550);
kaf24@5776 281 ns16550.io_base = 0x2f8;
kaf24@5776 282 ns16550.irq = 3;
kaf24@5776 283 ns16550_init(1, &ns16550);
kaf24@5195 284 serial_init_preirq();
kaf24@3338 285
kaf24@3338 286 init_console();
kaf24@3338 287
kaf24@3344 288 /* Check that we have at least one Multiboot module. */
kaf24@3344 289 if ( !(mbi->flags & MBI_MODULES) || (mbi->mods_count == 0) )
kaf24@3338 290 {
kaf24@5542 291 printk("FATAL ERROR: dom0 kernel not specified."
kaf24@5542 292 " Check bootloader configuration.\n");
kaf24@5011 293 EARLY_FAIL();
kaf24@5011 294 }
kaf24@5011 295
kaf24@5011 296 if ( ((unsigned long)cpu0_stack & (STACK_SIZE-1)) != 0 )
kaf24@5011 297 {
kaf24@5011 298 printk("FATAL ERROR: Misaligned CPU0 stack.\n");
kaf24@5011 299 EARLY_FAIL();
kaf24@3338 300 }
kaf24@3338 301
kaf24@3338 302 xenheap_phys_end = opt_xenheap_megabytes << 20;
kaf24@3338 303
kaf24@3344 304 if ( mbi->flags & MBI_MEMMAP )
kaf24@3344 305 {
kaf24@3344 306 while ( bytes < mbi->mmap_length )
kaf24@3344 307 {
kaf24@3344 308 memory_map_t *map = __va(mbi->mmap_addr + bytes);
kaf24@3344 309 e820_raw[e820_raw_nr].addr =
kaf24@3344 310 ((u64)map->base_addr_high << 32) | (u64)map->base_addr_low;
kaf24@3344 311 e820_raw[e820_raw_nr].size =
kaf24@3344 312 ((u64)map->length_high << 32) | (u64)map->length_low;
kaf24@3344 313 e820_raw[e820_raw_nr].type =
kaf24@3346 314 (map->type > E820_SHARED_PAGE) ? E820_RESERVED : map->type;
kaf24@3344 315 e820_raw_nr++;
kaf24@3344 316 bytes += map->size + 4;
kaf24@3344 317 }
kaf24@3344 318 }
kaf24@3344 319 else if ( mbi->flags & MBI_MEMLIMITS )
kaf24@3344 320 {
kaf24@3344 321 e820_raw[0].addr = 0;
kaf24@3344 322 e820_raw[0].size = mbi->mem_lower << 10;
kaf24@3344 323 e820_raw[0].type = E820_RAM;
kaf24@3354 324 e820_raw[1].addr = 0x100000;
kaf24@3354 325 e820_raw[1].size = mbi->mem_upper << 10;
kaf24@3354 326 e820_raw[1].type = E820_RAM;
kaf24@3344 327 e820_raw_nr = 2;
kaf24@3344 328 }
kaf24@3344 329 else
kaf24@3344 330 {
kaf24@3344 331 printk("FATAL ERROR: Bootloader provided no memory information.\n");
kaf24@3344 332 for ( ; ; ) ;
kaf24@3344 333 }
kaf24@3344 334
kaf24@4950 335 max_page = init_e820(e820_raw, &e820_raw_nr);
kaf24@3338 336
kaf24@6111 337 modules_length = mod[mbi->mods_count-1].mod_end - mod[0].mod_start;
kaf24@3338 338
kaf24@6111 339 /* Find a large enough RAM extent to stash the DOM0 modules. */
kaf24@6111 340 for ( i = 0; ; i++ )
kaf24@3338 341 {
kaf24@6111 342 if ( i == e820.nr_map )
kaf24@6111 343 {
kaf24@6111 344 printk("Not enough memory to stash the DOM0 kernel image.\n");
kaf24@6111 345 for ( ; ; ) ;
kaf24@6111 346 }
kaf24@6134 347
kaf24@6134 348 if ( (e820.map[i].type == E820_RAM) &&
kaf24@6134 349 (e820.map[i].size >= modules_length) &&
kaf24@6134 350 ((e820.map[i].addr + e820.map[i].size) >=
kaf24@6134 351 (xenheap_phys_end + modules_length)) )
kaf24@6134 352 break;
kaf24@3338 353 }
kaf24@6111 354
kaf24@6134 355 /* Stash as near as possible to the beginning of the RAM extent. */
kaf24@6134 356 initial_images_start = e820.map[i].addr;
kaf24@6134 357 if ( initial_images_start < xenheap_phys_end )
kaf24@6134 358 initial_images_start = xenheap_phys_end;
kaf24@6134 359 initial_images_end = initial_images_start + modules_length;
kaf24@6134 360
kaf24@4950 361 #if defined(CONFIG_X86_32)
kaf24@3338 362 memmove((void *)initial_images_start, /* use low mapping */
kaf24@3338 363 (void *)mod[0].mod_start, /* use low mapping */
kaf24@3338 364 mod[mbi->mods_count-1].mod_end - mod[0].mod_start);
kaf24@4950 365 #elif defined(CONFIG_X86_64)
kaf24@3338 366 memmove(__va(initial_images_start),
kaf24@3338 367 __va(mod[0].mod_start),
kaf24@3338 368 mod[mbi->mods_count-1].mod_end - mod[0].mod_start);
kaf24@3338 369 #endif
kaf24@3338 370
kaf24@3354 371 /* Initialise boot-time allocator with all RAM situated after modules. */
kaf24@5003 372 xenheap_phys_start = init_boot_allocator(__pa(&_end));
kaf24@6111 373 nr_pages = 0;
kaf24@3354 374 for ( i = 0; i < e820.nr_map; i++ )
kaf24@3354 375 {
kaf24@3354 376 if ( e820.map[i].type != E820_RAM )
kaf24@3354 377 continue;
kaf24@6111 378
kaf24@3354 379 nr_pages += e820.map[i].size >> PAGE_SHIFT;
kaf24@6111 380
kaf24@6111 381 /* Initialise boot heap, skipping Xen heap and dom0 modules. */
kaf24@6111 382 s = e820.map[i].addr;
kaf24@6111 383 e = s + e820.map[i].size;
kaf24@6111 384 if ( s < xenheap_phys_end )
kaf24@6111 385 s = xenheap_phys_end;
kaf24@6111 386 if ( (s < initial_images_end) && (e > initial_images_start) )
kaf24@6111 387 s = initial_images_end;
kaf24@6111 388 init_boot_pages(s, e);
kaf24@6111 389
kaf24@5003 390 #if defined (CONFIG_X86_64)
kaf24@5003 391 /*
kaf24@5003 392 * x86/64 maps all registered RAM. Points to note:
kaf24@5003 393 * 1. The initial pagetable already maps low 64MB, so skip that.
kaf24@5003 394 * 2. We must map *only* RAM areas, taking care to avoid I/O holes.
kaf24@5003 395 * Failure to do this can cause coherency problems and deadlocks
kaf24@5003 396 * due to cache-attribute mismatches (e.g., AMD/AGP Linux bug).
kaf24@5003 397 */
kaf24@5003 398 {
kaf24@5004 399 /* Calculate page-frame range, discarding partial frames. */
kaf24@5004 400 unsigned long start, end;
kaf24@5005 401 start = PFN_UP(e820.map[i].addr);
kaf24@5005 402 end = PFN_DOWN(e820.map[i].addr + e820.map[i].size);
kaf24@5004 403 /* Clip the range to above 64MB. */
kaf24@5004 404 if ( end < (64UL << (20-PAGE_SHIFT)) )
kaf24@5004 405 continue;
kaf24@5004 406 if ( start < (64UL << (20-PAGE_SHIFT)) )
kaf24@5004 407 start = 64UL << (20-PAGE_SHIFT);
kaf24@5004 408 /* Request the mapping. */
kaf24@5003 409 map_pages_to_xen(
kaf24@5004 410 PAGE_OFFSET + (start << PAGE_SHIFT),
kaf24@5004 411 start, end-start, PAGE_HYPERVISOR);
kaf24@5003 412 }
kaf24@5003 413 #endif
kaf24@3354 414 }
kaf24@3354 415
kaf24@5003 416 memguard_init();
kaf24@4950 417
kaf24@3354 418 printk("System RAM: %luMB (%lukB)\n",
kaf24@3354 419 nr_pages >> (20 - PAGE_SHIFT),
kaf24@3354 420 nr_pages << (PAGE_SHIFT - 10));
kaf24@3354 421
kaf24@3354 422 init_frametable();
kaf24@3338 423
kaf24@3354 424 end_boot_allocator();
kaf24@3354 425
kaf24@6111 426 /* Initialise the Xen heap, skipping RAM holes. */
kaf24@6111 427 nr_pages = 0;
kaf24@6111 428 for ( i = 0; i < e820.nr_map; i++ )
kaf24@6111 429 {
kaf24@6111 430 if ( e820.map[i].type != E820_RAM )
kaf24@6111 431 continue;
kaf24@6111 432
kaf24@6111 433 s = e820.map[i].addr;
kaf24@6111 434 e = s + e820.map[i].size;
kaf24@6111 435 if ( s < xenheap_phys_start )
kaf24@6111 436 s = xenheap_phys_start;
kaf24@6111 437 if ( e > xenheap_phys_end )
kaf24@6111 438 e = xenheap_phys_end;
kaf24@6111 439
kaf24@6111 440 if ( s < e )
kaf24@6111 441 {
kaf24@6111 442 nr_pages += (e - s) >> PAGE_SHIFT;
kaf24@6111 443 init_xenheap_pages(s, e);
kaf24@6111 444 }
kaf24@6111 445 }
kaf24@6111 446
kaf24@6111 447 printk("Xen heap: %luMB (%lukB)\n",
kaf24@6111 448 nr_pages >> (20 - PAGE_SHIFT),
kaf24@6111 449 nr_pages << (PAGE_SHIFT - 10));
kaf24@3338 450
kaf24@3594 451 early_boot = 0;
kaf24@3338 452
kaf24@3338 453 start_of_day();
kaf24@3338 454
kaf24@3338 455 grant_table_init();
kaf24@3338 456
kaf24@3338 457 shadow_mode_init();
kaf24@3338 458
smh22@5514 459 /* initialize access control security module */
kaf24@5859 460 acm_init(&initrdidx, mbi, initial_images_start);
smh22@5514 461
kaf24@3338 462 /* Create initial domain 0. */
kaf24@3338 463 dom0 = do_createdomain(0, 0);
kaf24@3338 464 if ( dom0 == NULL )
kaf24@3338 465 panic("Error creating domain 0\n");
kaf24@3338 466
kaf24@4877 467 set_bit(_DOMF_privileged, &dom0->domain_flags);
smh22@5514 468 /* post-create hooks sets security label */
smh22@5514 469 acm_post_domain0_create(dom0->domain_id);
kaf24@3338 470
kaf24@4850 471 /* Grab the DOM0 command line. */
riel@3992 472 cmdline = (char *)(mod[0].string ? __va(mod[0].string) : NULL);
kaf24@3338 473 if ( cmdline != NULL )
kaf24@3338 474 {
kaf24@5366 475 static char dom0_cmdline[MAX_GUEST_CMDLINE];
kaf24@4850 476
kaf24@4850 477 /* Skip past the image name. */
kaf24@3338 478 while ( *cmdline == ' ' ) cmdline++;
kaf24@3338 479 if ( (cmdline = strchr(cmdline, ' ')) != NULL )
kaf24@3338 480 while ( *cmdline == ' ' ) cmdline++;
kaf24@4850 481
kaf24@4850 482 /* Copy the command line to a local buffer. */
kaf24@4850 483 strcpy(dom0_cmdline, cmdline);
kaf24@4850 484 cmdline = dom0_cmdline;
kaf24@4850 485
kaf24@4850 486 /* Append any extra parameters. */
kaf24@4850 487 if ( skip_ioapic_setup && !strstr(cmdline, "noapic") )
kaf24@4850 488 strcat(cmdline, " noapic");
kaf24@4850 489 if ( acpi_skip_timer_override &&
kaf24@4850 490 !strstr(cmdline, "acpi_skip_timer_override") )
kaf24@4850 491 strcat(cmdline, " acpi_skip_timer_override");
kaf24@4850 492 if ( (strlen(acpi_param) != 0) && !strstr(cmdline, "acpi=") )
kaf24@4850 493 {
kaf24@4850 494 strcat(cmdline, " acpi=");
kaf24@4850 495 strcat(cmdline, acpi_param);
kaf24@4850 496 }
kaf24@3338 497 }
kaf24@3338 498
kaf24@5859 499 if ( (initrdidx > 0) && (initrdidx < mbi->mods_count) )
kaf24@5859 500 {
kaf24@5859 501 _initrd_start = initial_images_start +
kaf24@5859 502 (mod[initrdidx].mod_start - mod[0].mod_start);
kaf24@5859 503 _initrd_len = mod[initrdidx].mod_end - mod[initrdidx].mod_start;
kaf24@5859 504 }
kaf24@5859 505
kaf24@3338 506 /*
kaf24@3338 507 * We're going to setup domain0 using the module(s) that we stashed safely
kaf24@3338 508 * above our heap. The second module, if present, is an initrd ramdisk.
kaf24@3338 509 */
kaf24@3935 510 if ( construct_dom0(dom0,
kaf24@3635 511 initial_images_start,
kaf24@3338 512 mod[0].mod_end-mod[0].mod_start,
kaf24@5859 513 _initrd_start,
kaf24@5859 514 _initrd_len,
kaf24@3338 515 cmdline) != 0)
kaf24@3338 516 panic("Could not set up DOM0 guest OS\n");
kaf24@3338 517
kaf24@3935 518 /* Scrub RAM that is still free and so may go to an unprivileged domain. */
kaf24@3338 519 scrub_heap_pages();
kaf24@3338 520
kaf24@3338 521 init_trace_bufs();
kaf24@3338 522
kaf24@3338 523 /* Give up the VGA console if DOM0 is configured to grab it. */
kaf24@3338 524 console_endboot(cmdline && strstr(cmdline, "tty0"));
kaf24@3338 525
iap10@4287 526 /* Hide UART from DOM0 if we're using it */
iap10@4287 527 serial_endboot();
iap10@4287 528
kaf24@3338 529 domain_unpause_by_systemcontroller(dom0);
kaf24@5146 530
kaf24@3338 531 startup_cpu_idle_loop();
kaf24@3338 532 }
kaf24@3914 533
kaf24@6725 534 void arch_get_xen_caps(xen_capabilities_info_t info)
iap10@6721 535 {
kaf24@6725 536 char *p = info;
iap10@6721 537
kaf24@6725 538 #if defined(CONFIG_X86_32) && !defined(CONFIG_X86_PAE)
kaf24@6725 539
kaf24@6725 540 p += sprintf(p, "xen_%d.%d_x86_32 ", XEN_VERSION, XEN_SUBVERSION);
kaf24@6725 541 if ( hvm_enabled )
kaf24@6725 542 p += sprintf(p, "hvm_%d.%d_x86_32 ", XEN_VERSION, XEN_SUBVERSION);
kaf24@6725 543
kaf24@6725 544 #elif defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
kaf24@6725 545
kaf24@6725 546 p += sprintf(p, "xen_%d.%d_x86_32p ", XEN_VERSION, XEN_SUBVERSION);
kaf24@6725 547 if ( hvm_enabled )
iap10@6721 548 {
kaf24@6725 549 //p += sprintf(p, "hvm_%d.%d_x86_32 ", XEN_VERSION, XEN_SUBVERSION);
kaf24@6725 550 //p += sprintf(p, "hvm_%d.%d_x86_32p ", XEN_VERSION, XEN_SUBVERSION);
iap10@6721 551 }
iap10@6721 552
kaf24@6725 553 #elif defined(CONFIG_X86_64)
iap10@6721 554
kaf24@6725 555 p += sprintf(p, "xen_%d.%d_x86_64 ", XEN_VERSION, XEN_SUBVERSION);
kaf24@6725 556 if ( hvm_enabled )
iap10@6721 557 {
kaf24@6725 558 //p += sprintf(p, "hvm_%d.%d_x86_32 ", XEN_VERSION, XEN_SUBVERSION);
kaf24@6725 559 //p += sprintf(p, "hvm_%d.%d_x86_32p ", XEN_VERSION, XEN_SUBVERSION);
kaf24@6725 560 p += sprintf(p, "hvm_%d.%d_x86_64 ", XEN_VERSION, XEN_SUBVERSION);
iap10@6721 561 }
kaf24@6725 562
kaf24@6725 563 #else
kaf24@6725 564
kaf24@6725 565 p++;
kaf24@6725 566
iap10@6721 567 #endif
iap10@6721 568
kaf24@6725 569 *(p-1) = 0;
iap10@6721 570
kaf24@6725 571 BUG_ON((p - info) > sizeof(info));
iap10@6721 572 }
iap10@6721 573
kaf24@3914 574 /*
kaf24@3914 575 * Local variables:
kaf24@3914 576 * mode: C
kaf24@3914 577 * c-set-style: "BSD"
kaf24@3914 578 * c-basic-offset: 4
kaf24@3914 579 * tab-width: 4
kaf24@3914 580 * indent-tabs-mode: nil
kaf24@3988 581 * End:
kaf24@3914 582 */