Changeset 12431 in vbox
- Timestamp:
- Sep 12, 2008 3:29:01 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/PC/DevACPI.cpp
r12428 r12431 189 189 uint8_t u8UseFdc; 190 190 bool fPowerButtonHandled; 191 191 192 192 /** ACPI port base interface. */ 193 193 PDMIBASE IBase; … … 399 399 AssertCompileSize(ACPITBLIOAPIC, 12); 400 400 401 /** Multiple APIC Description Table */402 401 #ifdef VBOX_WITH_SMP_GUESTS 403 404 #define PCAT_COMPAT 0x1 /**< system has also a dual-8259 setup */ 405 406 /* 402 #ifdef IN_RING3 /**@todo r=bird: Move this down to where it's used. */ 403 404 # define PCAT_COMPAT 0x1 /**< system has also a dual-8259 setup */ 405 406 /** 407 * Multiple APIC Description Table. 408 * 407 409 * This structure looks somewhat convoluted due layout of MADT table in MP case. 408 * There extpected to be multiple LAPIC records for each CPU, thus we cannot 410 * There extpected to be multiple LAPIC records for each CPU, thus we cannot 409 411 * use regular C structure and proxy to raw memory instead. 410 412 */ 411 class A CPITBLMADT412 { 413 /* 413 class AcpiTableMADT 414 { 415 /** 414 416 * All actual data stored in dynamically allocated memory pointed by this field. 415 417 */ 416 418 uint8_t* pData; 417 /* 419 /** 418 420 * Number of CPU entries in this MADT. 419 421 */ 420 422 uint32_t cCpus; 421 423 422 424 public: 423 /* 425 /** 424 426 * Address of ACPI header 425 427 */ … … 428 430 return (ACPITBLHEADER*)pData; 429 431 } 430 431 /* 432 433 /** 432 434 * Address of local APIC for each CPU. Note that different CPUs address different LAPICs, 433 435 * although address is the same for all of them. … … 437 439 return (uint32_t*)(header_addr() + 1); 438 440 } 439 440 /* 441 442 /** 441 443 * Address of APIC flags 442 444 */ … … 445 447 return (uint32_t*)(u32LAPIC_addr() + 1); 446 448 } 447 448 /* 449 450 /** 449 451 * Address of per-CPU LAPIC descriptions 450 452 */ … … 454 456 } 455 457 456 /* 458 /** 457 459 * Address of IO APIC description 458 460 */ … … 462 464 } 463 465 464 /* 466 /** 465 467 * Size of MADT. 466 468 * Note that this function assumes IOApic to be the last field in structure. … … 471 473 } 472 474 473 /* 475 /** 474 476 * Raw data of MADT. 475 477 */ … … 479 481 } 480 482 481 /* 483 /** 482 484 * Size of MADT for given ACPI config, useful to compute layout. 483 485 */ 484 486 static uint32_t sizeFor(ACPIState *s) 485 487 { 486 return A CPITBLMADT(s->cCpus).size();488 return AcpiTableMADT(s->cCpus).size(); 487 489 } 488 490 … … 490 492 * Constructor, only works in Ring 3, doesn't look like a big deal. 491 493 */ 492 A CPITBLMADT(uint16_t cpus)494 AcpiTableMADT(uint16_t cpus) 493 495 { 494 496 cCpus = cpus; 495 497 pData = 0; 496 #ifdef IN_RING3497 498 uint32_t sSize = size(); 498 499 pData = (uint8_t*)RTMemAllocZ(sSize); 499 #else 500 AssertMsgFailed(("cannot use in inner rings")); 501 #endif 502 } 503 504 ~ACPITBLMADT() 505 { 506 #ifdef IN_RING3 500 } 501 502 ~AcpiTableMADT() 503 { 507 504 RTMemFree(pData); 508 #else509 AssertMsgFailed(("cannot use in inner rings"));510 #endif511 505 } 512 506 }; 513 #else 507 #endif /* IN_RING3 */ 508 509 #else /* !VBOX_WITH_SMP_GUESTS */ 510 /** Multiple APIC Description Table */ 514 511 struct ACPITBLMADT 515 512 { … … 522 519 }; 523 520 AssertCompileSize(ACPITBLMADT, 64); 524 #endif 521 #endif /* !VBOX_WITH_SMP_GUESTS */ 525 522 526 523 #pragma pack() … … 754 751 static void acpiSetupMADT (ACPIState *s, RTGCPHYS32 addr) 755 752 { 756 #if VBOX_WITH_SMP_GUESTS753 #ifdef VBOX_WITH_SMP_GUESTS 757 754 uint16_t cpus = s->cCpus; 758 A CPITBLMADT madt(cpus);755 AcpiTableMADT madt(cpus); 759 756 760 757 acpiPrepareHeader(madt.header_addr(), "APIC", madt.size(), 2); 761 758 762 759 *madt.u32LAPIC_addr() = RT_H2LE_U32(0xfee00000); 763 760 *madt.u32Flags_addr() = RT_H2LE_U32(PCAT_COMPAT); 764 761 765 762 ACPITBLLAPIC* lapic = madt.LApics_addr(); 766 763 for (uint16_t i = 0; i < cpus; i++) … … 786 783 acpiPhyscpy (s, addr, madt.data(), madt.size()); 787 784 788 #else 785 #else /* !VBOX_WITH_SMP_GUESTS */ 789 786 ACPITBLMADT madt; 790 787 … … 813 810 madt.header.u8Checksum = acpiChecksum ((uint8_t*)&madt, sizeof(madt)); 814 811 acpiPhyscpy (s, addr, &madt, sizeof(madt)); 815 #endif 812 #endif /* !VBOX_WITH_SMP_GUESTS */ 816 813 } 817 814 … … 1664 1661 apic_addr = RT_ALIGN_32 (facs_addr + sizeof(ACPITBLFACS), 16); 1665 1662 #ifdef VBOX_WITH_SMP_GUESTS 1666 /* 1667 * @todo r=nike maybe some refactoring needed to compute tables layout,1663 /** 1664 * @todo nike: maybe some refactoring needed to compute tables layout, 1668 1665 * but as this code is executed only once it doesn't make sense to optimize much 1669 1666 */ 1670 dsdt_addr = RT_ALIGN_32 (apic_addr + A CPITBLMADT::sizeFor(s), 16);1667 dsdt_addr = RT_ALIGN_32 (apic_addr + AcpiTableMADT::sizeFor(s), 16); 1671 1668 #else 1672 1669 dsdt_addr = RT_ALIGN_32 (apic_addr + sizeof(ACPITBLMADT), 16); … … 1729 1726 1730 1727 /* Validate and read the configuration. */ 1731 if (!CFGMR3AreValuesValid (pCfgHandle, 1728 if (!CFGMR3AreValuesValid (pCfgHandle, 1732 1729 "RamSize\0" 1733 1730 "IOAPIC\0"
Note:
See TracChangeset
for help on using the changeset viewer.