Changeset 71768 in vbox
- Timestamp:
- Apr 9, 2018 2:10:52 PM (7 years ago)
- svn:sync-xref-src-repo-rev:
- 121871
- Location:
- trunk/src/VBox/Devices/Bus
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Bus/DevPciIch9.cpp
r71155 r71768 791 791 int rc; 792 792 793 rc = Msi Init(pPciDev, pMsiReg);793 rc = MsiR3Init(pPciDev, pMsiReg); 794 794 if (RT_FAILURE(rc)) 795 795 return rc; 796 796 797 rc = Msix Init(pPciDev->Int.s.CTX_SUFF(pBus)->CTX_SUFF(pPciHlp), pPciDev, pMsiReg);797 rc = MsixR3Init(pPciDev->Int.s.CTX_SUFF(pBus)->CTX_SUFF(pPciHlp), pPciDev, pMsiReg); 798 798 if (RT_FAILURE(rc)) 799 799 return rc; … … 2544 2544 if ( pciDevIsMsiCapable(pPciDev) 2545 2545 && uAddress - (uint32_t)pPciDev->Int.s.u8MsiCapOffset < (uint32_t)pPciDev->Int.s.u8MsiCapSize) 2546 Msi PciConfigWrite(pPciDev->Int.s.CTX_SUFF(pBus)->CTX_SUFF(pDevIns),2547 pPciDev->Int.s.CTX_SUFF(pBus)->CTX_SUFF(pPciHlp),2548 pPciDev, uAddress, u32Value, cb);2546 MsiR3PciConfigWrite(pPciDev->Int.s.CTX_SUFF(pBus)->CTX_SUFF(pDevIns), 2547 pPciDev->Int.s.CTX_SUFF(pBus)->CTX_SUFF(pPciHlp), 2548 pPciDev, uAddress, u32Value, cb); 2549 2549 else if ( pciDevIsMsixCapable(pPciDev) 2550 2550 && uAddress - (uint32_t)pPciDev->Int.s.u8MsixCapOffset < (uint32_t)pPciDev->Int.s.u8MsixCapSize) 2551 Msix PciConfigWrite(pPciDev->Int.s.CTX_SUFF(pBus)->CTX_SUFF(pDevIns),2552 pPciDev->Int.s.CTX_SUFF(pBus)->CTX_SUFF(pPciHlp),2553 pPciDev, uAddress, u32Value, cb);2551 MsixR3PciConfigWrite(pPciDev->Int.s.CTX_SUFF(pBus)->CTX_SUFF(pDevIns), 2552 pPciDev->Int.s.CTX_SUFF(pBus)->CTX_SUFF(pPciHlp), 2553 pPciDev, uAddress, u32Value, cb); 2554 2554 else 2555 2555 { -
trunk/src/VBox/Devices/Bus/MsiCommon.cpp
r68118 r71768 17 17 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. 18 18 */ 19 19 20 #define LOG_GROUP LOG_GROUP_DEV_PCI 20 21 #define PDMPCIDEV_INCLUDE_PRIVATE /* Hack to get pdmpcidevint.h included at the right point. */ … … 27 28 #include "PciInline.h" 28 29 30 29 31 DECLINLINE(uint16_t) msiGetMessageControl(PPDMPCIDEV pDev) 30 32 { 31 33 uint32_t idxMessageControl = pDev->Int.s.u8MsiCapOffset + VBOX_MSI_CAP_MESSAGE_CONTROL; 32 34 #ifdef IN_RING3 33 if (pciDevIsPassthrough(pDev)) {35 if (pciDevIsPassthrough(pDev)) 34 36 return pDev->Int.s.pfnConfigRead(pDev->Int.s.CTX_SUFF(pDevIns), pDev, idxMessageControl, 2); 35 }36 37 #endif 37 38 return PCIDevGetWord(pDev, idxMessageControl); … … 46 47 * up to date, which is a wrong assumption for the "emulate passthrough" case 47 48 * where only the callbacks give the correct data. */ 48 DECLINLINE(uint32_t *) msiGetMaskBits(PPDMPCIDEV pDev)49 DECLINLINE(uint32_t *) msiGetMaskBits(PPDMPCIDEV pDev) 49 50 { 50 51 uint8_t iOff = msiIs64Bit(pDev) ? VBOX_MSI_CAP_MASK_BITS_64 : VBOX_MSI_CAP_MASK_BITS_32; … … 87 88 return RT_MAKE_U64(lo, hi); 88 89 } 89 else 90 { 91 return PCIDevGetDWord(pDev, pDev->Int.s.u8MsiCapOffset + VBOX_MSI_CAP_MESSAGE_ADDRESS_32); 92 } 90 return PCIDevGetDWord(pDev, pDev->Int.s.u8MsiCapOffset + VBOX_MSI_CAP_MESSAGE_ADDRESS_32); 93 91 } 94 92 … … 109 107 #ifdef IN_RING3 110 108 111 DECLINLINE(bool) msiBitJustCleared(uint32_t uOldValue, 112 uint32_t uNewValue, 113 uint32_t uMask) 114 { 115 return (!!(uOldValue & uMask) && !(uNewValue & uMask)); 116 } 117 118 DECLINLINE(bool) msiBitJustSet(uint32_t uOldValue, 119 uint32_t uNewValue, 120 uint32_t uMask) 121 { 122 return (!(uOldValue & uMask) && !!(uNewValue & uMask)); 123 } 124 125 void MsiPciConfigWrite(PPDMDEVINS pDevIns, PCPDMPCIHLP pPciHlp, PPDMPCIDEV pDev, 126 uint32_t u32Address, uint32_t val, unsigned len) 109 DECLINLINE(bool) msiR3BitJustCleared(uint32_t uOldValue, uint32_t uNewValue, uint32_t uMask) 110 { 111 return !!(uOldValue & uMask) && !(uNewValue & uMask); 112 } 113 114 DECLINLINE(bool) msiR3BitJustSet(uint32_t uOldValue, uint32_t uNewValue, uint32_t uMask) 115 { 116 return !(uOldValue & uMask) && !!(uNewValue & uMask); 117 } 118 119 void MsiR3PciConfigWrite(PPDMDEVINS pDevIns, PCPDMPCIHLP pPciHlp, PPDMPCIDEV pDev, 120 uint32_t u32Address, uint32_t val, unsigned len) 127 121 { 128 122 int32_t iOff = u32Address - pDev->Int.s.u8MsiCapOffset; 129 123 Assert(iOff >= 0 && (pciDevIsMsiCapable(pDev) && iOff < pDev->Int.s.u8MsiCapSize)); 130 124 131 Log2(("Msi PciConfigWrite: %d <- %x (%d)\n", iOff, val, len));125 Log2(("MsiR3PciConfigWrite: %d <- %x (%d)\n", iOff, val, len)); 132 126 133 127 uint32_t uAddr = u32Address; … … 181 175 uint32_t uVector = maskUpdated*8 + iBitNum; 182 176 183 if (msi BitJustCleared(pDev->abConfig[uAddr], u8Val, iBit))177 if (msiR3BitJustCleared(pDev->abConfig[uAddr], u8Val, iBit)) 184 178 { 185 179 Log(("msi: mask updated bit %d@%x (%d)\n", iBitNum, uAddr, maskUpdated)); … … 193 187 } 194 188 } 195 if (msi BitJustSet(pDev->abConfig[uAddr], u8Val, iBit))189 if (msiR3BitJustSet(pDev->abConfig[uAddr], u8Val, iBit)) 196 190 { 197 191 Log(("msi: mask vector: %d\n", uVector)); … … 208 202 } 209 203 210 int Msi Init(PPDMPCIDEV pDev, PPDMMSIREG pMsiReg)204 int MsiR3Init(PPDMPCIDEV pDev, PPDMMSIREG pMsiReg) 211 205 { 212 206 if (pMsiReg->cMsiVectors == 0) … … 272 266 273 267 274 bool 268 bool MsiIsEnabled(PPDMPCIDEV pDev) 275 269 { 276 270 return pciDevIsMsiCapable(pDev) && msiIsEnabled(pDev); … … 326 320 pPciHlp->pfnIoApicSendMsi(pDevIns, GCAddr, u32Value, uTagSrc); 327 321 } 322 -
trunk/src/VBox/Devices/Bus/MsiCommon.h
r69124 r71768 3 3 * Header for MSI/MSI-X support routines. 4 4 */ 5 5 6 /* 6 7 * Copyright (C) 2010-2017 Oracle Corporation … … 30 31 #ifdef IN_RING3 31 32 /* Init MSI support in the device. */ 32 int Msi Init(PPDMPCIDEV pDev, PPDMMSIREG pMsiReg);33 int MsiR3Init(PPDMPCIDEV pDev, PPDMMSIREG pMsiReg); 33 34 #endif 34 35 … … 41 42 #ifdef IN_RING3 42 43 /* PCI config space accessors for MSI registers */ 43 void Msi PciConfigWrite(PPDMDEVINS pDevIns, PCPDMPCIHLP pPciHlp, PPDMPCIDEV pDev, uint32_t u32Address, uint32_t val, unsigned len);44 void MsiR3PciConfigWrite(PPDMDEVINS pDevIns, PCPDMPCIHLP pPciHlp, PPDMPCIDEV pDev, uint32_t u32Address, uint32_t val, unsigned len); 44 45 #endif 45 46 46 47 #ifdef IN_RING3 47 48 /* Init MSI-X support in the device. */ 48 int Msix Init(PCPDMPCIHLP pPciHlp, PPDMPCIDEV pDev, PPDMMSIREG pMsiReg);49 int MsixR3Init(PCPDMPCIHLP pPciHlp, PPDMPCIDEV pDev, PPDMMSIREG pMsiReg); 49 50 #endif 50 51 … … 57 58 #ifdef IN_RING3 58 59 /* PCI config space accessors for MSI-X */ 59 void Msix PciConfigWrite(PPDMDEVINS pDevIns, PCPDMPCIHLP pPciHlp, PPDMPCIDEV pDev, uint32_t u32Address, uint32_t val, unsigned len);60 void MsixR3PciConfigWrite(PPDMDEVINS pDevIns, PCPDMPCIHLP pPciHlp, PPDMPCIDEV pDev, uint32_t u32Address, uint32_t val, unsigned len); 60 61 #endif -
trunk/src/VBox/Devices/Bus/MsixCommon.cpp
r68423 r71768 15 15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. 16 16 */ 17 18 17 19 #define LOG_GROUP LOG_GROUP_DEV_PCI 18 20 #define PDMPCIDEV_INCLUDE_PRIVATE /* Hack to get pdmpcidevint.h included at the right point. */ … … 28 30 #include "PciInline.h" 29 31 30 #pragma pack(1)31 32 typedef struct 32 33 { … … 37 38 } MsixTableRecord; 38 39 AssertCompileSize(MsixTableRecord, VBOX_MSIX_ENTRY_SIZE); 39 #pragma pack() 40 40 41 41 42 /** @todo use accessors so that raw PCI devices work correctly with MSI-X. */ … … 114 115 #ifdef IN_RING3 115 116 116 PDMBOTHCBDECL(int) msix MMIORead(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS GCPhysAddr, void *pv, unsigned cb)117 PDMBOTHCBDECL(int) msixR3MMIORead(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS GCPhysAddr, void *pv, unsigned cb) 117 118 { 118 119 LogFlowFunc(("\n")); … … 130 131 VINF_IOM_MMIO_UNUSED_FF); 131 132 132 *(uint32_t *)pv = *(uint32_t*)msixGetPageOffset(pPciDev, off);133 *(uint32_t *)pv = *(uint32_t *)msixGetPageOffset(pPciDev, off); 133 134 return VINF_SUCCESS; 134 135 } 135 136 136 PDMBOTHCBDECL(int) msix MMIOWrite(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS GCPhysAddr, void const *pv, unsigned cb)137 PDMBOTHCBDECL(int) msixR3MMIOWrite(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS GCPhysAddr, void const *pv, unsigned cb) 137 138 { 138 139 LogFlowFunc(("\n")); … … 149 150 VINF_IOM_MMIO_UNUSED_FF); 150 151 151 *(uint32_t *)msixGetPageOffset(pPciDev, off) = *(uint32_t*)pv;152 *(uint32_t *)msixGetPageOffset(pPciDev, off) = *(uint32_t *)pv; 152 153 153 154 msixCheckPendingVector(pDevIns, (PCPDMPCIHLP)pPciDev->Int.s.pPciBusPtrR3, pPciDev, off / VBOX_MSIX_ENTRY_SIZE); … … 158 159 * @callback_method_impl{FNPCIIOREGIONMAP} 159 160 */ 160 static DECLCALLBACK(int) msix Map(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, uint32_t iRegion,161 RTGCPHYS GCPhysAddress, RTGCPHYS cb, PCIADDRESSSPACE enmType)161 static DECLCALLBACK(int) msixR3Map(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, uint32_t iRegion, 162 RTGCPHYS GCPhysAddress, RTGCPHYS cb, PCIADDRESSSPACE enmType) 162 163 { 163 164 Assert(enmType == PCI_ADDRESS_SPACE_MEM); … … 166 167 int rc = PDMDevHlpMMIORegister(pDevIns, GCPhysAddress, cb, pPciDev, 167 168 IOMMMIO_FLAGS_READ_PASSTHRU | IOMMMIO_FLAGS_WRITE_PASSTHRU, 168 msix MMIOWrite, msixMMIORead, "MSI-X tables");169 msixR3MMIOWrite, msixR3MMIORead, "MSI-X tables"); 169 170 170 171 if (RT_FAILURE(rc)) … … 174 175 } 175 176 176 int Msix Init(PCPDMPCIHLP pPciHlp, PPDMPCIDEV pDev, PPDMMSIREG pMsiReg)177 int MsixR3Init(PCPDMPCIHLP pPciHlp, PPDMPCIDEV pDev, PPDMMSIREG pMsiReg) 177 178 { 178 179 if (pMsiReg->cMsixVectors == 0) 179 180 return VINF_SUCCESS; 180 181 181 182 /* We cannot init MSI-X on raw devices yet. */ … … 205 206 if (!pciDevIsPassthrough(pDev)) 206 207 { 207 rc = PDMDevHlpPCIIORegionRegister(pDev->Int.s.CTX_SUFF(pDevIns), iBar, cbMsixRegion, PCI_ADDRESS_SPACE_MEM, msix Map);208 rc = PDMDevHlpPCIIORegionRegister(pDev->Int.s.CTX_SUFF(pDevIns), iBar, cbMsixRegion, PCI_ADDRESS_SPACE_MEM, msixR3Map); 208 209 if (RT_FAILURE (rc)) 209 210 return rc; … … 244 245 #endif 245 246 246 bool 247 bool MsixIsEnabled(PPDMPCIDEV pDev) 247 248 { 248 249 return pciDevIsMsixCapable(pDev) && msixIsEnabled(pDev); … … 292 293 293 294 294 void Msix PciConfigWrite(PPDMDEVINS pDevIns, PCPDMPCIHLP pPciHlp, PPDMPCIDEV pDev, uint32_t u32Address, uint32_t val, unsigned len)295 void MsixR3PciConfigWrite(PPDMDEVINS pDevIns, PCPDMPCIHLP pPciHlp, PPDMPCIDEV pDev, uint32_t u32Address, uint32_t val, unsigned len) 295 296 { 296 297 int32_t iOff = u32Address - pDev->Int.s.u8MsixCapOffset; 297 298 Assert(iOff >= 0 && (pciDevIsMsixCapable(pDev) && iOff < pDev->Int.s.u8MsixCapSize)); 298 299 299 Log2(("Msix PciConfigWrite: %d <- %x (%d)\n", iOff, val, len));300 Log2(("MsixR3PciConfigWrite: %d <- %x (%d)\n", iOff, val, len)); 300 301 301 302 uint32_t uAddr = u32Address;
Note:
See TracChangeset
for help on using the changeset viewer.