Commit a5954d5c34502ebeaae95b8719a734066f596f1e
1 parent
f537a28c
moved MP table init to BIOS
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@2172 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
1 changed file
with
15 additions
and
163 deletions
hw/pc.c
... | ... | @@ -40,6 +40,7 @@ static fdctrl_t *floppy_controller; |
40 | 40 | static RTCState *rtc_state; |
41 | 41 | static PITState *pit; |
42 | 42 | static IOAPICState *ioapic; |
43 | +static PCIDevice *i440fx_state; | |
43 | 44 | |
44 | 45 | static void ioport80_write(void *opaque, uint32_t addr, uint32_t data) |
45 | 46 | { |
... | ... | @@ -73,6 +74,14 @@ uint64_t cpu_get_tsc(CPUX86State *env) |
73 | 74 | } |
74 | 75 | } |
75 | 76 | |
77 | +/* SMM support */ | |
78 | +void cpu_smm_update(CPUState *env) | |
79 | +{ | |
80 | + if (i440fx_state && env == first_cpu) | |
81 | + i440fx_set_smm(i440fx_state, (env->hflags >> HF_SMM_SHIFT) & 1); | |
82 | +} | |
83 | + | |
84 | + | |
76 | 85 | /* IRQ handling */ |
77 | 86 | int cpu_get_pic_interrupt(CPUState *env) |
78 | 87 | { |
... | ... | @@ -398,156 +407,6 @@ static void main_cpu_reset(void *opaque) |
398 | 407 | cpu_reset(env); |
399 | 408 | } |
400 | 409 | |
401 | -/*************************************************/ | |
402 | - | |
403 | -static void putb(uint8_t **pp, int val) | |
404 | -{ | |
405 | - uint8_t *q; | |
406 | - q = *pp; | |
407 | - *q++ = val; | |
408 | - *pp = q; | |
409 | -} | |
410 | - | |
411 | -static void putstr(uint8_t **pp, const char *str) | |
412 | -{ | |
413 | - uint8_t *q; | |
414 | - q = *pp; | |
415 | - while (*str) | |
416 | - *q++ = *str++; | |
417 | - *pp = q; | |
418 | -} | |
419 | - | |
420 | -static void putle16(uint8_t **pp, int val) | |
421 | -{ | |
422 | - uint8_t *q; | |
423 | - q = *pp; | |
424 | - *q++ = val; | |
425 | - *q++ = val >> 8; | |
426 | - *pp = q; | |
427 | -} | |
428 | - | |
429 | -static void putle32(uint8_t **pp, int val) | |
430 | -{ | |
431 | - uint8_t *q; | |
432 | - q = *pp; | |
433 | - *q++ = val; | |
434 | - *q++ = val >> 8; | |
435 | - *q++ = val >> 16; | |
436 | - *q++ = val >> 24; | |
437 | - *pp = q; | |
438 | -} | |
439 | - | |
440 | -static int mpf_checksum(const uint8_t *data, int len) | |
441 | -{ | |
442 | - int sum, i; | |
443 | - sum = 0; | |
444 | - for(i = 0; i < len; i++) | |
445 | - sum += data[i]; | |
446 | - return sum & 0xff; | |
447 | -} | |
448 | - | |
449 | -/* Build the Multi Processor table in the BIOS. Same values as Bochs. */ | |
450 | -static void bios_add_mptable(uint8_t *bios_data) | |
451 | -{ | |
452 | - uint8_t *mp_config_table, *q, *float_pointer_struct; | |
453 | - int ioapic_id, offset, i, len; | |
454 | - | |
455 | - if (smp_cpus <= 1) | |
456 | - return; | |
457 | - | |
458 | - mp_config_table = bios_data + 0xb000; | |
459 | - q = mp_config_table; | |
460 | - putstr(&q, "PCMP"); /* "PCMP signature */ | |
461 | - putle16(&q, 0); /* table length (patched later) */ | |
462 | - putb(&q, 4); /* spec rev */ | |
463 | - putb(&q, 0); /* checksum (patched later) */ | |
464 | - putstr(&q, "QEMUCPU "); /* OEM id */ | |
465 | - putstr(&q, "0.1 "); /* vendor id */ | |
466 | - putle32(&q, 0); /* OEM table ptr */ | |
467 | - putle16(&q, 0); /* OEM table size */ | |
468 | - putle16(&q, 20); /* entry count */ | |
469 | - putle32(&q, 0xfee00000); /* local APIC addr */ | |
470 | - putle16(&q, 0); /* ext table length */ | |
471 | - putb(&q, 0); /* ext table checksum */ | |
472 | - putb(&q, 0); /* reserved */ | |
473 | - | |
474 | - for(i = 0; i < smp_cpus; i++) { | |
475 | - putb(&q, 0); /* entry type = processor */ | |
476 | - putb(&q, i); /* APIC id */ | |
477 | - putb(&q, 0x11); /* local APIC version number */ | |
478 | - if (i == 0) | |
479 | - putb(&q, 3); /* cpu flags: enabled, bootstrap cpu */ | |
480 | - else | |
481 | - putb(&q, 1); /* cpu flags: enabled */ | |
482 | - putb(&q, 0); /* cpu signature */ | |
483 | - putb(&q, 6); | |
484 | - putb(&q, 0); | |
485 | - putb(&q, 0); | |
486 | - putle16(&q, 0x201); /* feature flags */ | |
487 | - putle16(&q, 0); | |
488 | - | |
489 | - putle16(&q, 0); /* reserved */ | |
490 | - putle16(&q, 0); | |
491 | - putle16(&q, 0); | |
492 | - putle16(&q, 0); | |
493 | - } | |
494 | - | |
495 | - /* isa bus */ | |
496 | - putb(&q, 1); /* entry type = bus */ | |
497 | - putb(&q, 0); /* bus ID */ | |
498 | - putstr(&q, "ISA "); | |
499 | - | |
500 | - /* ioapic */ | |
501 | - ioapic_id = smp_cpus; | |
502 | - putb(&q, 2); /* entry type = I/O APIC */ | |
503 | - putb(&q, ioapic_id); /* apic ID */ | |
504 | - putb(&q, 0x11); /* I/O APIC version number */ | |
505 | - putb(&q, 1); /* enable */ | |
506 | - putle32(&q, 0xfec00000); /* I/O APIC addr */ | |
507 | - | |
508 | - /* irqs */ | |
509 | - for(i = 0; i < 16; i++) { | |
510 | - putb(&q, 3); /* entry type = I/O interrupt */ | |
511 | - putb(&q, 0); /* interrupt type = vectored interrupt */ | |
512 | - putb(&q, 0); /* flags: po=0, el=0 */ | |
513 | - putb(&q, 0); | |
514 | - putb(&q, 0); /* source bus ID = ISA */ | |
515 | - putb(&q, i); /* source bus IRQ */ | |
516 | - putb(&q, ioapic_id); /* dest I/O APIC ID */ | |
517 | - putb(&q, i); /* dest I/O APIC interrupt in */ | |
518 | - } | |
519 | - /* patch length */ | |
520 | - len = q - mp_config_table; | |
521 | - mp_config_table[4] = len; | |
522 | - mp_config_table[5] = len >> 8; | |
523 | - | |
524 | - mp_config_table[7] = -mpf_checksum(mp_config_table, q - mp_config_table); | |
525 | - | |
526 | - /* align to 16 */ | |
527 | - offset = q - bios_data; | |
528 | - offset = (offset + 15) & ~15; | |
529 | - float_pointer_struct = bios_data + offset; | |
530 | - | |
531 | - /* floating pointer structure */ | |
532 | - q = float_pointer_struct; | |
533 | - putstr(&q, "_MP_"); | |
534 | - /* pointer to MP config table */ | |
535 | - putle32(&q, mp_config_table - bios_data + 0x000f0000); | |
536 | - | |
537 | - putb(&q, 1); /* length in 16 byte units */ | |
538 | - putb(&q, 4); /* MP spec revision */ | |
539 | - putb(&q, 0); /* checksum (patched later) */ | |
540 | - putb(&q, 0); /* MP feature byte 1 */ | |
541 | - | |
542 | - putb(&q, 0); | |
543 | - putb(&q, 0); | |
544 | - putb(&q, 0); | |
545 | - putb(&q, 0); | |
546 | - float_pointer_struct[10] = | |
547 | - -mpf_checksum(float_pointer_struct, q - float_pointer_struct); | |
548 | -} | |
549 | - | |
550 | - | |
551 | 410 | static const int ide_iobase[2] = { 0x1f0, 0x170 }; |
552 | 411 | static const int ide_iobase2[2] = { 0x3f6, 0x376 }; |
553 | 412 | static const int ide_irq[2] = { 14, 15 }; |
... | ... | @@ -632,7 +491,7 @@ static void pc_init1(int ram_size, int vga_ram_size, int boot_device, |
632 | 491 | /* XXX: enable it in all cases */ |
633 | 492 | env->cpuid_features |= CPUID_APIC; |
634 | 493 | } |
635 | - register_savevm("cpu", i, 3, cpu_save, cpu_load, env); | |
494 | + register_savevm("cpu", i, 4, cpu_save, cpu_load, env); | |
636 | 495 | qemu_register_reset(main_cpu_reset, env); |
637 | 496 | if (pci_enabled) { |
638 | 497 | apic_init(env); |
... | ... | @@ -659,9 +518,6 @@ static void pc_init1(int ram_size, int vga_ram_size, int boot_device, |
659 | 518 | fprintf(stderr, "qemu: could not load PC bios '%s'\n", buf); |
660 | 519 | exit(1); |
661 | 520 | } |
662 | - if (bios_size == 65536) { | |
663 | - bios_add_mptable(phys_ram_base + bios_offset); | |
664 | - } | |
665 | 521 | |
666 | 522 | /* VGA BIOS load */ |
667 | 523 | if (cirrus_vga_enabled) { |
... | ... | @@ -747,7 +603,7 @@ static void pc_init1(int ram_size, int vga_ram_size, int boot_device, |
747 | 603 | } |
748 | 604 | |
749 | 605 | if (pci_enabled) { |
750 | - pci_bus = i440fx_init(); | |
606 | + pci_bus = i440fx_init(&i440fx_state); | |
751 | 607 | piix3_devfn = piix3_init(pci_bus); |
752 | 608 | } else { |
753 | 609 | pci_bus = NULL; |
... | ... | @@ -850,7 +706,10 @@ static void pc_init1(int ram_size, int vga_ram_size, int boot_device, |
850 | 706 | if (pci_enabled && acpi_enabled) { |
851 | 707 | piix4_pm_init(pci_bus, piix3_devfn + 3); |
852 | 708 | } |
853 | - | |
709 | + | |
710 | + if (i440fx_state) { | |
711 | + i440fx_init_memory_mappings(i440fx_state); | |
712 | + } | |
854 | 713 | #if 0 |
855 | 714 | /* ??? Need to figure out some way for the user to |
856 | 715 | specify SCSI devices. */ |
... | ... | @@ -868,13 +727,6 @@ static void pc_init1(int ram_size, int vga_ram_size, int boot_device, |
868 | 727 | lsi_scsi_attach(scsi, bdrv, -1); |
869 | 728 | } |
870 | 729 | #endif |
871 | - /* must be done after all PCI devices are instanciated */ | |
872 | - /* XXX: should be done in the Bochs BIOS */ | |
873 | - if (pci_enabled) { | |
874 | - pci_bios_init(); | |
875 | - if (acpi_enabled) | |
876 | - acpi_bios_init(); | |
877 | - } | |
878 | 730 | } |
879 | 731 | |
880 | 732 | static void pc_init_pci(int ram_size, int vga_ram_size, int boot_device, | ... | ... |