Changeset 88549 in vbox
- Timestamp:
- Apr 15, 2021 4:35:16 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Bus/DevIommuIntel.cpp
r88537 r88549 495 495 496 496 /** 497 * Gets the index of the group the register belongs to given its MMIO offset. 498 * 499 * @returns The group index. 500 * @param offReg The MMIO offset of the register. 501 * @param cbReg The size of the access being made (for bounds checking on 502 * debug builds). 503 */ 504 DECLINLINE(uint8_t) dmarRegGetGroupIndex(uint16_t offReg, uint8_t cbReg) 505 { 506 uint16_t const offLast = offReg + cbReg - 1; 507 AssertCompile(DMAR_MMIO_GROUP_0_OFF_FIRST == 0); 508 AssertMsg(DMAR_IS_MMIO_OFF_VALID(offLast), ("off=%#x cb=%u\n", offReg, cbReg)); 509 return !(offLast < DMAR_MMIO_GROUP_0_OFF_END); 510 } 511 512 513 /** 497 514 * Gets the group the register belongs to given its MMIO offset. 498 515 * … … 507 524 DECLINLINE(uint8_t *) dmarRegGetGroup(PDMAR pThis, uint16_t offReg, uint8_t cbReg, uint8_t *pIdxGroup) 508 525 { 509 uint16_t const offLast = offReg + cbReg - 1; 510 AssertCompile(DMAR_MMIO_GROUP_0_OFF_FIRST == 0); 511 AssertMsg(DMAR_IS_MMIO_OFF_VALID(offLast), ("off=%#x cb=%u\n", offReg, cbReg)); 512 513 uint8_t *const apbRegs[] = { &pThis->abRegs0[0], &pThis->abRegs1[0] }; 514 *pIdxGroup = !(offLast < DMAR_MMIO_GROUP_0_OFF_END); 526 *pIdxGroup = dmarRegGetGroupIndex(offReg, cbReg); 527 uint8_t *apbRegs[] = { &pThis->abRegs0[0], &pThis->abRegs1[0] }; 528 return apbRegs[*pIdxGroup]; 529 } 530 531 532 /** 533 * Const/read-only version of dmarRegGetGroup. 534 * 535 * @copydoc dmarRegGetGroup 536 */ 537 DECLINLINE(uint8_t const*) dmarRegGetGroupRo(PCDMAR pThis, uint16_t offReg, uint8_t cbReg, uint8_t *pIdxGroup) 538 { 539 *pIdxGroup = dmarRegGetGroupIndex(offReg, cbReg); 540 uint8_t const *apbRegs[] = { &pThis->abRegs0[0], &pThis->abRegs1[0] }; 515 541 return apbRegs[*pIdxGroup]; 516 542 } … … 558 584 * @param pfRw1cMask Where to store the RW1C mask corresponding to this register. 559 585 */ 560 DECLINLINE(void) dmarRegReadRaw64(P DMAR pThis, uint16_t offReg, uint64_t *puReg, uint64_t *pfRwMask, uint64_t *pfRw1cMask)586 DECLINLINE(void) dmarRegReadRaw64(PCDMAR pThis, uint16_t offReg, uint64_t *puReg, uint64_t *pfRwMask, uint64_t *pfRw1cMask) 561 587 { 562 588 uint8_t idxGroup; 563 uint8_t const *pabRegs = dmarRegGetGroup (pThis, offReg, sizeof(uint64_t), &idxGroup);589 uint8_t const *pabRegs = dmarRegGetGroupRo(pThis, offReg, sizeof(uint64_t), &idxGroup); 564 590 Assert(idxGroup < RT_ELEMENTS(g_apbRwMasks)); 565 591 uint8_t const *pabRwMasks = g_apbRwMasks[idxGroup]; … … 580 606 * @param pfRw1cMask Where to store the RW1C mask corresponding to this register. 581 607 */ 582 DECLINLINE(void) dmarRegReadRaw32(P DMAR pThis, uint16_t offReg, uint32_t *puReg, uint32_t *pfRwMask, uint32_t *pfRw1cMask)608 DECLINLINE(void) dmarRegReadRaw32(PCDMAR pThis, uint16_t offReg, uint32_t *puReg, uint32_t *pfRwMask, uint32_t *pfRw1cMask) 583 609 { 584 610 uint8_t idxGroup; 585 uint8_t const *pabRegs = dmarRegGetGroup (pThis, offReg, sizeof(uint32_t), &idxGroup);611 uint8_t const *pabRegs = dmarRegGetGroupRo(pThis, offReg, sizeof(uint32_t), &idxGroup); 586 612 Assert(idxGroup < RT_ELEMENTS(g_apbRwMasks)); 587 613 uint8_t const *pabRwMasks = g_apbRwMasks[idxGroup]; … … 656 682 * @param offReg The MMIO offset of the register. 657 683 */ 658 static uint64_t dmarRegRead64(P DMAR pThis, uint16_t offReg)684 static uint64_t dmarRegRead64(PCDMAR pThis, uint16_t offReg) 659 685 { 660 686 uint64_t uCurReg; … … 674 700 * @param offReg The MMIO offset of the register. 675 701 */ 676 static uint32_t dmarRegRead32(P DMAR pThis, uint16_t offReg)702 static uint32_t dmarRegRead32(PCDMAR pThis, uint16_t offReg) 677 703 { 678 704 uint32_t uCurReg; … … 695 721 static VBOXSTRICTRC dmarIqtRegWrite(PPDMDEVINS pDevIns, uint16_t off, uint64_t uIqtReg) 696 722 { 697 /* We only care about the low dword of VTD_MMIO_OFF_IQT_REG. */ 698 PDMAR pThis = PDMDEVINS_2_DATA(pDevIns, PDMAR); 723 /* We only care about the low 32-bits. */ 699 724 if (off == VTD_MMIO_OFF_IQT_REG) 700 725 { 701 726 /* Verify if the queue tail offset is aligned according to the descriptor width in IQA_REG. */ 727 PDMAR pThis = PDMDEVINS_2_DATA(pDevIns, PDMAR); 702 728 uint16_t const offQueueTail = VTD_IQT_REG_GET_QT(uIqtReg); 703 729 uint64_t const uIqaReg = dmarRegRead64(pThis, VTD_MMIO_OFF_IQA_REG);
Note:
See TracChangeset
for help on using the changeset viewer.