Changeset 82072 in vbox for trunk/src/VBox/Devices
- Timestamp:
- Nov 21, 2019 9:44:55 AM (5 years ago)
- Location:
- trunk/src/VBox/Devices
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Graphics/DevVGA-SVGA.cpp
r82071 r82072 519 519 SSMFIELD_ENTRY( VMSVGAState, u32CurrentGMRId), 520 520 SSMFIELD_ENTRY( VMSVGAState, u32RegCaps), 521 SSMFIELD_ENTRY_IGNORE( VMSVGAState, BasePort),522 521 SSMFIELD_ENTRY( VMSVGAState, u32IndexReg), 523 522 SSMFIELD_ENTRY_IGNORE( VMSVGAState, pSupDrvSession), … … 1510 1509 * @param u32 Value to write 1511 1510 */ 1512 PDMBOTHCBDECL(int)vmsvgaWritePort(PVGASTATE pThis, uint32_t u32)1511 static int vmsvgaWritePort(PVGASTATE pThis, uint32_t u32) 1513 1512 { 1514 1513 #ifdef IN_RING3 … … 1966 1965 1967 1966 /** 1968 * Port I/O Handler for IN operations. 1969 * 1970 * @returns VINF_SUCCESS or VINF_EM_*. 1971 * @returns VERR_IOM_IOPORT_UNUSED if the port is really unused and a ~0 value should be returned. 1972 * 1973 * @param pDevIns The device instance. 1974 * @param pvUser User argument. 1975 * @param uPort Port number used for the IN operation. 1976 * @param pu32 Where to store the result. This is always a 32-bit 1977 * variable regardless of what @a cb might say. 1978 * @param cb Number of bytes read. 1967 * @callback_method_impl{FNIOMIOPORTNEWIN} 1979 1968 */ 1980 PDMBOTHCBDECL(int) vmsvgaIORead(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT uPort, uint32_t *pu32, unsigned cb)1969 DECLCALLBACK(VBOXSTRICTRC) vmsvgaIORead(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT offPort, uint32_t *pu32, unsigned cb) 1981 1970 { 1982 1971 PVGASTATE pThis = PDMINS_2_DATA(pDevIns, PVGASTATE); 1983 1972 RT_NOREF_PV(pvUser); 1984 1973 1985 /* Ignore non-dword accesses. */ 1986 if (cb != 4) 1987 { 1988 Log(("Ignoring non-dword read at %x cb=%d\n", uPort, cb)); 1974 /* Only dword accesses. */ 1975 if (cb == 4) 1976 { 1977 switch (offPort) 1978 { 1979 case SVGA_INDEX_PORT: 1980 *pu32 = pThis->svga.u32IndexReg; 1981 break; 1982 1983 case SVGA_VALUE_PORT: 1984 return vmsvgaReadPort(pDevIns, pThis, pu32); 1985 1986 case SVGA_BIOS_PORT: 1987 Log(("Ignoring BIOS port read\n")); 1988 *pu32 = 0; 1989 break; 1990 1991 case SVGA_IRQSTATUS_PORT: 1992 LogFlow(("vmsvgaIORead: SVGA_IRQSTATUS_PORT %x\n", pThis->svga.u32IrqStatus)); 1993 *pu32 = pThis->svga.u32IrqStatus; 1994 break; 1995 1996 default: 1997 ASSERT_GUEST_MSG_FAILED(("vmsvgaIORead: Unknown register %u was read from.\n", offPort)); 1998 *pu32 = UINT32_MAX; 1999 break; 2000 } 2001 } 2002 else 2003 { 2004 Log(("Ignoring non-dword I/O port read at %x cb=%d\n", offPort, cb)); 1989 2005 *pu32 = UINT32_MAX; 1990 return VINF_SUCCESS; 1991 } 1992 1993 switch (uPort - pThis->svga.BasePort) 1994 { 1995 case SVGA_INDEX_PORT: 1996 *pu32 = pThis->svga.u32IndexReg; 1997 break; 1998 1999 case SVGA_VALUE_PORT: 2000 return vmsvgaReadPort(pDevIns, pThis, pu32); 2001 2002 case SVGA_BIOS_PORT: 2003 Log(("Ignoring BIOS port read\n")); 2004 *pu32 = 0; 2005 break; 2006 2007 case SVGA_IRQSTATUS_PORT: 2008 LogFlow(("vmsvgaIORead: SVGA_IRQSTATUS_PORT %x\n", pThis->svga.u32IrqStatus)); 2009 *pu32 = pThis->svga.u32IrqStatus; 2010 break; 2011 2012 default: 2013 ASSERT_GUEST_MSG_FAILED(("vmsvgaIORead: Unknown register %u (%#x) was read from.\n", uPort - pThis->svga.BasePort, uPort)); 2014 *pu32 = UINT32_MAX; 2015 break; 2016 } 2017 2006 } 2018 2007 return VINF_SUCCESS; 2019 2008 } 2020 2009 2021 2010 /** 2022 * Port I/O Handler for OUT operations. 2023 * 2024 * @returns VINF_SUCCESS or VINF_EM_*. 2025 * 2026 * @param pDevIns The device instance. 2027 * @param pvUser User argument. 2028 * @param uPort Port number used for the OUT operation. 2029 * @param u32 The value to output. 2030 * @param cb The value size in bytes. 2011 * @callback_method_impl{FNIOMIOPORTNEWOUT} 2031 2012 */ 2032 PDMBOTHCBDECL(int) vmsvgaIOWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT uPort, uint32_t u32, unsigned cb)2013 DECLCALLBACK(VBOXSTRICTRC) vmsvgaIOWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT offPort, uint32_t u32, unsigned cb) 2033 2014 { 2034 2015 PVGASTATE pThis = PDMINS_2_DATA(pDevIns, PVGASTATE); 2035 2016 RT_NOREF_PV(pvUser); 2036 2017 2037 /* Ignore non-dword accesses. */ 2038 if (cb != 4) 2039 { 2040 Log(("Ignoring non-dword write at %x val=%x cb=%d\n", uPort, u32, cb)); 2041 return VINF_SUCCESS; 2042 } 2043 2044 switch (uPort - pThis->svga.BasePort) 2045 { 2046 case SVGA_INDEX_PORT: 2047 pThis->svga.u32IndexReg = u32; 2048 break; 2049 2050 case SVGA_VALUE_PORT: 2051 return vmsvgaWritePort(pThis, u32); 2052 2053 case SVGA_BIOS_PORT: 2054 Log(("Ignoring BIOS port write (val=%x)\n", u32)); 2055 break; 2056 2057 case SVGA_IRQSTATUS_PORT: 2058 Log(("vmsvgaIOWrite SVGA_IRQSTATUS_PORT %x: status %x -> %x\n", u32, pThis->svga.u32IrqStatus, pThis->svga.u32IrqStatus & ~u32)); 2059 ASMAtomicAndU32(&pThis->svga.u32IrqStatus, ~u32); 2060 /* Clear the irq in case all events have been cleared. */ 2061 if (!(pThis->svga.u32IrqStatus & pThis->svga.u32IrqMask)) 2062 { 2063 Log(("vmsvgaIOWrite SVGA_IRQSTATUS_PORT: clearing IRQ\n")); 2064 PDMDevHlpPCISetIrqNoWait(pDevIns, 0, 0); 2065 } 2066 break; 2067 2068 default: 2069 ASSERT_GUEST_MSG_FAILED(("vmsvgaIOWrite: Unknown register %u (%#x) was written to, value %#x LB %u.\n", 2070 uPort - pThis->svga.BasePort, uPort, u32, cb)); 2071 break; 2072 } 2018 /* Only dword accesses. */ 2019 if (cb == 4) 2020 switch (offPort) 2021 { 2022 case SVGA_INDEX_PORT: 2023 pThis->svga.u32IndexReg = u32; 2024 break; 2025 2026 case SVGA_VALUE_PORT: 2027 return vmsvgaWritePort(pThis, u32); 2028 2029 case SVGA_BIOS_PORT: 2030 Log(("Ignoring BIOS port write (val=%x)\n", u32)); 2031 break; 2032 2033 case SVGA_IRQSTATUS_PORT: 2034 Log(("vmsvgaIOWrite SVGA_IRQSTATUS_PORT %x: status %x -> %x\n", u32, pThis->svga.u32IrqStatus, pThis->svga.u32IrqStatus & ~u32)); 2035 ASMAtomicAndU32(&pThis->svga.u32IrqStatus, ~u32); 2036 /* Clear the irq in case all events have been cleared. */ 2037 if (!(pThis->svga.u32IrqStatus & pThis->svga.u32IrqMask)) 2038 { 2039 Log(("vmsvgaIOWrite SVGA_IRQSTATUS_PORT: clearing IRQ\n")); 2040 PDMDevHlpPCISetIrqNoWait(pDevIns, 0, 0); 2041 } 2042 break; 2043 2044 default: 2045 ASSERT_GUEST_MSG_FAILED(("vmsvgaIOWrite: Unknown register %u was written to, value %#x LB %u.\n", offPort, u32, cb)); 2046 break; 2047 } 2048 else 2049 Log(("Ignoring non-dword write at %x val=%x cb=%d\n", offPort, u32, cb)); 2050 2073 2051 return VINF_SUCCESS; 2074 2052 } … … 5294 5272 5295 5273 Log(("vgasvgaR3IORegionMap: iRegion=%d GCPhysAddress=%RGp cb=%RGp enmType=%d\n", iRegion, GCPhysAddress, cb, enmType)); 5296 if (enmType == PCI_ADDRESS_SPACE_IO) 5297 { 5298 AssertReturn(iRegion == pThis->pciRegions.iIO, VERR_INTERNAL_ERROR); 5299 rc = PDMDevHlpIOPortRegister(pDevIns, (RTIOPORT)GCPhysAddress, cb, 0, 5300 vmsvgaIOWrite, vmsvgaIORead, NULL /* OutStr */, NULL /* InStr */, "VMSVGA"); 5301 if (RT_FAILURE(rc)) 5302 return rc; 5303 if (pDevIns->fR0Enabled) 5304 { 5305 rc = PDMDevHlpIOPortRegisterR0(pDevIns, (RTIOPORT)GCPhysAddress, cb, 0, 5306 "vmsvgaIOWrite", "vmsvgaIORead", NULL, NULL, "VMSVGA"); 5307 if (RT_FAILURE(rc)) 5308 return rc; 5309 } 5310 if (pDevIns->fRCEnabled) 5311 { 5312 rc = PDMDevHlpIOPortRegisterRC(pDevIns, (RTIOPORT)GCPhysAddress, cb, 0, 5313 "vmsvgaIOWrite", "vmsvgaIORead", NULL, NULL, "VMSVGA"); 5314 if (RT_FAILURE(rc)) 5315 return rc; 5316 } 5317 5318 pThis->svga.BasePort = GCPhysAddress; 5319 Log(("vmsvgaR3IORegionMap: base port = %x\n", pThis->svga.BasePort)); 5274 AssertReturn(iRegion == pThis->pciRegions.iFIFO && enmType == PCI_ADDRESS_SPACE_MEM_PREFETCH, VERR_INTERNAL_ERROR); 5275 if (GCPhysAddress != NIL_RTGCPHYS) 5276 { 5277 /* 5278 * Mapping the FIFO RAM. 5279 */ 5280 AssertLogRelMsg(cb == pThis->svga.cbFIFO, ("cb=%#RGp cbFIFO=%#x\n", cb, pThis->svga.cbFIFO)); 5281 rc = PDMDevHlpMMIOExMap(pDevIns, pPciDev, iRegion, GCPhysAddress); 5282 AssertRC(rc); 5283 5284 # if defined(VMSVGA_USE_FIFO_ACCESS_HANDLER) || defined(DEBUG_FIFO_ACCESS) 5285 if (RT_SUCCESS(rc)) 5286 { 5287 rc = PGMHandlerPhysicalRegister(PDMDevHlpGetVM(pDevIns), GCPhysAddress, 5288 # ifdef DEBUG_FIFO_ACCESS 5289 GCPhysAddress + (pThis->svga.cbFIFO - 1), 5290 # else 5291 GCPhysAddress + PAGE_SIZE - 1, 5292 # endif 5293 pThis->svga.hFifoAccessHandlerType, pThis, NIL_RTR0PTR, NIL_RTRCPTR, 5294 "VMSVGA FIFO"); 5295 AssertRC(rc); 5296 } 5297 # endif 5298 if (RT_SUCCESS(rc)) 5299 { 5300 pThis->svga.GCPhysFIFO = GCPhysAddress; 5301 Log(("vmsvgaR3IORegionMap: GCPhysFIFO=%RGp cbFIFO=%#x\n", GCPhysAddress, pThis->svga.cbFIFO)); 5302 } 5320 5303 } 5321 5304 else 5322 5305 { 5323 AssertReturn(iRegion == pThis->pciRegions.iFIFO && enmType == PCI_ADDRESS_SPACE_MEM_PREFETCH, VERR_INTERNAL_ERROR); 5324 if (GCPhysAddress != NIL_RTGCPHYS) 5325 { 5326 /* 5327 * Mapping the FIFO RAM. 5328 */ 5329 AssertLogRelMsg(cb == pThis->svga.cbFIFO, ("cb=%#RGp cbFIFO=%#x\n", cb, pThis->svga.cbFIFO)); 5330 rc = PDMDevHlpMMIOExMap(pDevIns, pPciDev, iRegion, GCPhysAddress); 5331 AssertRC(rc); 5332 5306 Assert(pThis->svga.GCPhysFIFO); 5333 5307 # if defined(VMSVGA_USE_FIFO_ACCESS_HANDLER) || defined(DEBUG_FIFO_ACCESS) 5334 if (RT_SUCCESS(rc)) 5335 { 5336 rc = PGMHandlerPhysicalRegister(PDMDevHlpGetVM(pDevIns), GCPhysAddress, 5337 # ifdef DEBUG_FIFO_ACCESS 5338 GCPhysAddress + (pThis->svga.cbFIFO - 1), 5339 # else 5340 GCPhysAddress + PAGE_SIZE - 1, 5341 # endif 5342 pThis->svga.hFifoAccessHandlerType, pThis, NIL_RTR0PTR, NIL_RTRCPTR, 5343 "VMSVGA FIFO"); 5344 AssertRC(rc); 5345 } 5308 rc = PGMHandlerPhysicalDeregister(PDMDevHlpGetVM(pDevIns), pThis->svga.GCPhysFIFO); 5309 AssertRC(rc); 5346 5310 # endif 5347 if (RT_SUCCESS(rc)) 5348 { 5349 pThis->svga.GCPhysFIFO = GCPhysAddress; 5350 Log(("vmsvgaR3IORegionMap: GCPhysFIFO=%RGp cbFIFO=%#x\n", GCPhysAddress, pThis->svga.cbFIFO)); 5351 } 5352 } 5353 else 5354 { 5355 Assert(pThis->svga.GCPhysFIFO); 5356 # if defined(VMSVGA_USE_FIFO_ACCESS_HANDLER) || defined(DEBUG_FIFO_ACCESS) 5357 rc = PGMHandlerPhysicalDeregister(PDMDevHlpGetVM(pDevIns), pThis->svga.GCPhysFIFO); 5358 AssertRC(rc); 5359 # endif 5360 pThis->svga.GCPhysFIFO = 0; 5361 } 5311 pThis->svga.GCPhysFIFO = 0; 5362 5312 } 5363 5313 return VINF_SUCCESS; … … 5487 5437 pHlp->pfnPrintf(pHlp, "Extension enabled: %RTbool\n", pThis->svga.fEnabled); 5488 5438 pHlp->pfnPrintf(pHlp, "Configured: %RTbool\n", pThis->svga.fConfigured); 5489 pHlp->pfnPrintf(pHlp, "Base I/O port: %#x\n", pThis->svga.BasePort); 5439 pHlp->pfnPrintf(pHlp, "Base I/O port: %#x\n", 5440 pThis->hIoPortVmSvga != NIL_IOMIOPORTHANDLE 5441 ? PDMDevHlpIoPortGetMappingAddress(pDevIns, pThis->hIoPortVmSvga) : UINT32_MAX); 5490 5442 pHlp->pfnPrintf(pHlp, "FIFO address: %RGp\n", pThis->svga.GCPhysFIFO); 5491 5443 pHlp->pfnPrintf(pHlp, "FIFO size: %u (%#x)\n", pThis->svga.cbFIFO, pThis->svga.cbFIFO); -
trunk/src/VBox/Devices/Graphics/DevVGA-SVGA.h
r77287 r82072 219 219 /** Register caps. */ 220 220 uint32_t u32RegCaps; 221 /** Physical address of command mmio range. */ 222 RTIOPORT BasePort; 223 RTIOPORT Padding0; 221 uint32_t Padding0; /* Used to be I/O port base address. */ 224 222 /** Port io index register. */ 225 223 uint32_t u32IndexReg; … … 366 364 DECLCALLBACK(int) vmsvgaR3IORegionMap(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, uint32_t iRegion, 367 365 RTGCPHYS GCPhysAddress, RTGCPHYS cb, PCIADDRESSSPACE enmType); 366 DECLCALLBACK(VBOXSTRICTRC) vmsvgaIORead(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT offPort, uint32_t *pu32, unsigned cb); 367 DECLCALLBACK(VBOXSTRICTRC) vmsvgaIOWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT offPort, uint32_t u32, unsigned cb); 368 368 369 369 DECLCALLBACK(void) vmsvgaPortSetViewport(PPDMIDISPLAYPORT pInterface, uint32_t uScreenId, -
trunk/src/VBox/Devices/Graphics/DevVGA.cpp
r82071 r82072 6639 6639 6640 6640 #ifdef VBOX_WITH_VMSVGA 6641 pThis->hIoPortVmSvga = NIL_IOMIOPORTHANDLE; 6641 6642 if (pThis->fVMSVGAEnabled) 6642 6643 { 6643 6644 /* Register the io command ports. */ 6644 rc = PDMDevHlpPCIIORegionRegister(pDevIns, pThis->pciRegions.iIO, 0x10, PCI_ADDRESS_SPACE_IO, vmsvgaR3IORegionMap); 6645 if (RT_FAILURE (rc)) 6646 return rc; 6645 rc = PDMDevHlpPCIIORegionCreateIo(pDevIns, pThis->pciRegions.iIO, 0x10, vmsvgaIOWrite, vmsvgaIORead, NULL /*pvUser*/, 6646 "VMSVGA", NULL /*paExtDescs*/, &pThis->hIoPortVmSvga); 6647 AssertRCReturn(rc, rc); 6648 6647 6649 rc = PDMDevHlpPCIIORegionRegister(pDevIns, pThis->pciRegions.iVRAM, pThis->vram_size, 6648 6650 PCI_ADDRESS_SPACE_MEM_PREFETCH, vgaR3IORegionMap); … … 7427 7429 rc = PDMDevHlpIoPortSetUpContext(pDevIns, pThis->hIoPortBios, vgaIoPortWriteBios, vgaIoPortReadBios, NULL /*pvUser*/); 7428 7430 AssertRCReturn(rc, rc); 7431 7432 # ifdef VBOX_WITH_VMSVGA 7433 if (pThis->hIoPortVmSvga != NIL_IOMIOPORTHANDLE) 7434 { 7435 rc = PDMDevHlpIoPortSetUpContext(pDevIns, pThis->hIoPortVmSvga, vmsvgaIOWrite, vmsvgaIORead, NULL /*pvUser*/); 7436 AssertRCReturn(rc, rc); 7437 } 7438 # endif 7429 7439 7430 7440 return VINF_SUCCESS; -
trunk/src/VBox/Devices/Graphics/DevVGA.h
r82069 r82072 540 540 IOMIOPORTHANDLE hIoPortCmdLogo; 541 541 542 # ifdef VBOX_WITH_VMSVGA 543 /** VMSVGA: I/O port PCI region. */ 544 IOMIOPORTHANDLE hIoPortVmSvga; 545 # endif 546 542 547 #endif /* VBOX */ 543 548 } VGAState; -
trunk/src/VBox/Devices/testcase/tstDeviceStructSizeRC.cpp
r80943 r82072 368 368 GEN_CHECK_OFF(VGASTATE, svga.u32CurrentGMRId); 369 369 GEN_CHECK_OFF(VGASTATE, svga.u32RegCaps); 370 GEN_CHECK_OFF(VGASTATE, svga.BasePort);371 370 GEN_CHECK_OFF(VGASTATE, svga.u32IndexReg); 372 371 GEN_CHECK_OFF(VGASTATE, svga.pSupDrvSession);
Note:
See TracChangeset
for help on using the changeset viewer.