Changeset 81933 in vbox
- Timestamp:
- Nov 18, 2019 8:52:53 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/PC/DevLpc-new.cpp
r81591 r81933 46 46 typedef struct LPCSTATE 47 47 { 48 /** Pointer to the ring-3 device instance. */49 PPDMDEVINSR3 pDevInsR3;50 51 48 /** The root complex base address. */ 52 49 RTGCPHYS32 GCPhys32Rcba; 53 /** Set if R0/RC context is enabled. */54 bool fRZEnabled;55 50 /** The ICH version (7 or 9). */ 56 51 uint8_t uIchVersion; 57 52 /** Explicit padding. */ 58 uint8_t abPadding[HC_ARCH_BITS == 32 ? 2 : 6];53 uint8_t abPadding[HC_ARCH_BITS == 32 ? 3 : 7]; 59 54 60 55 /** Number of MMIO reads. */ … … 66 61 /** Number of PCI config space writes. */ 67 62 STAMCOUNTER StatPciCfgWrites; 63 64 /** Handle to the MMIO region. */ 65 IOMMMIOHANDLE hMmio; 68 66 } LPCSTATE; 69 67 /** Pointer to the LPC state. */ … … 74 72 75 73 /** 76 * @callback_method_impl{FNIOMMMIO READ}77 */ 78 PDMBOTHCBDECL(int) lpcMmioRead(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS GCPhysAddr, void *pv, unsigned cb)74 * @callback_method_impl{FNIOMMMIONEWREAD} 75 */ 76 static DECLCALLBACK(VBOXSTRICTRC) lpcMmioRead(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS off, void *pv, unsigned cb) 79 77 { 80 78 RT_NOREF(pvUser, cb); 81 79 PLPCSTATE pThis = PDMDEVINS_2_DATA(pDevIns, PLPCSTATE); 82 RTGCPHYS32 const offReg = (RTGCPHYS32)GCPhysAddr - pThis->GCPhys32Rcba; 83 Assert(cb == 4); Assert(!(GCPhysAddr & 3)); /* IOMMMIO_FLAGS_READ_DWORD should make sure of this */ 80 Assert(cb == 4); Assert(!(off & 3)); /* IOMMMIO_FLAGS_READ_DWORD should make sure of this */ 84 81 85 82 uint32_t *puValue = (uint32_t *)pv; 86 if (off Reg== LPC_REG_HPET_CONFIG_POINTER)83 if (off == LPC_REG_HPET_CONFIG_POINTER) 87 84 { 88 85 *puValue = 0xf0; 89 86 Log(("lpcMmioRead: HPET_CONFIG_POINTER: %#x\n", *puValue)); 90 87 } 91 else if (off Reg== LPC_REG_GCS)88 else if (off == LPC_REG_GCS) 92 89 { 93 90 *puValue = 0; … … 97 94 { 98 95 *puValue = 0; 99 Log(("lpcMmioRead: WARNING! Unknown register %# x!\n", offReg));96 Log(("lpcMmioRead: WARNING! Unknown register %#RGp!\n", off)); 100 97 } 101 98 … … 106 103 107 104 /** 108 * @callback_method_impl{FNIOMMMIOWRITE} 109 */ 110 PDMBOTHCBDECL(int) lpcMmioWrite(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS GCPhysAddr, void const *pv, unsigned cb) 111 { 105 * @callback_method_impl{FNIOMMMIONEWWRITE} 106 */ 107 static DECLCALLBACK(VBOXSTRICTRC) lpcMmioWrite(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS off, void const *pv, unsigned cb) 108 { 109 PLPCSTATE pThis = PDMDEVINS_2_DATA(pDevIns, PLPCSTATE); 112 110 RT_NOREF(pvUser, pv); 113 PLPCSTATE pThis = PDMDEVINS_2_DATA(pDevIns, PLPCSTATE);114 RTGCPHYS32 const offReg = (RTGCPHYS32)GCPhysAddr - pThis->GCPhys32Rcba;115 111 116 112 if (cb == 4) 117 113 { 118 if (off Reg== LPC_REG_GCS)114 if (off == LPC_REG_GCS) 119 115 Log(("lpcMmioWrite: Ignorning write to GCS: %.*Rhxs\n", cb, pv)); 120 116 else 121 Log(("lpcMmioWrite: Ignorning write to unknown register %# x: %.*Rhxs\n", offReg, cb, pv));117 Log(("lpcMmioWrite: Ignorning write to unknown register %#RGp: %.*Rhxs\n", off, cb, pv)); 122 118 } 123 119 else 124 Log(("lpcMmioWrite: WARNING! Ignoring non-DWORD write to off Reg=%#x: %.*Rhxs\n", offReg, cb, pv));120 Log(("lpcMmioWrite: WARNING! Ignoring non-DWORD write to off=%#RGp: %.*Rhxs\n", off, cb, pv)); 125 121 126 122 STAM_REL_COUNTER_INC(&pThis->StatMmioWrites); … … 214 210 { 215 211 PDMDEV_CHECK_VERSIONS_RETURN(pDevIns); 216 PLPCSTATE pThis = PDMDEVINS_2_DATA(pDevIns, PLPCSTATE); 212 PLPCSTATE pThis = PDMDEVINS_2_DATA(pDevIns, PLPCSTATE); 213 PCPDMDEVHLPR3 pHlp = pDevIns->pHlpR3; 217 214 Assert(iInstance == 0); RT_NOREF(iInstance); 218 219 /*220 * Initialize state.221 */222 pThis->pDevInsR3 = pDevIns;223 215 224 216 /* 225 217 * Read configuration. 226 218 */ 227 PDMDEV_VALIDATE_CONFIG_RETURN(pDevIns, "RZEnabled|RCBA|ICHVersion", ""); 228 229 int rc = CFGMR3QueryBoolDef(pCfg, "RZEnabled", &pThis->fRZEnabled, true); 230 if (RT_FAILURE(rc)) 231 return PDMDEV_SET_ERROR(pDevIns, rc, N_("Configuration error: Failed to query boolean value \"RZEnabled\"")); 232 233 rc = CFGMR3QueryU8Def(pCfg, "ICHVersion", &pThis->uIchVersion, 7 /** @todo 9 */); 219 PDMDEV_VALIDATE_CONFIG_RETURN(pDevIns, "RCBA|ICHVersion", ""); 220 221 int rc = pHlp->pfnCFGMQueryU8Def(pCfg, "ICHVersion", &pThis->uIchVersion, 7 /** @todo 9 */); 234 222 if (RT_FAILURE(rc)) 235 223 return PDMDEV_SET_ERROR(pDevIns, rc, N_("Configuration error: Failed to query boolean value \"ICHVersion\"")); … … 238 226 return PDMDEV_SET_ERROR(pDevIns, rc, N_("Configuration error: Invalid \"ICHVersion\" value (must be 7 or 9)")); 239 227 240 rc = CFGMR3QueryU32Def(pCfg, "RCBA", &pThis->GCPhys32Rcba, UINT32_C(0xfed1c000));228 rc = pHlp->pfnCFGMQueryU32Def(pCfg, "RCBA", &pThis->GCPhys32Rcba, UINT32_C(0xfed1c000)); 241 229 if (RT_FAILURE(rc)) 242 230 return PDMDEV_SET_ERROR(pDevIns, rc, N_("Configuration error: Failed to query boolean value \"RCBA\"")); … … 359 347 /** @todo This should actually be done when RCBA is enabled, but was 360 348 * mentioned above we just want this working. */ 361 rc = PDMDevHlpM MIORegister(pDevIns, pThis->GCPhys32Rcba, 0x4000, pThis,362 IOMMMIO_FLAGS_READ_DWORD | IOMMMIO_FLAGS_WRITE_PASSTHRU,363 lpcMmioWrite, lpcMmioRead, "LPC Memory");349 rc = PDMDevHlpMmioCreateAndMap(pDevIns, pThis->GCPhys32Rcba, 0x4000, lpcMmioWrite, lpcMmioRead, 350 IOMMMIO_FLAGS_READ_DWORD | IOMMMIO_FLAGS_WRITE_PASSTHRU, 351 "LPC Memory", &pThis->hMmio); 364 352 AssertRCReturn(rc, rc); 365 353 … … 368 356 * Debug info and stats. 369 357 */ 370 PDMDevHlpSTAMRegister(pDevIns, &pThis->StatMmioReads, STAMTYPE_COUNTER, " /Devices/LPC/MMIOReads", STAMUNIT_OCCURENCES, "MMIO reads");371 PDMDevHlpSTAMRegister(pDevIns, &pThis->StatMmioWrites, STAMTYPE_COUNTER, " /Devices/LPC/MMIOWrites", STAMUNIT_OCCURENCES, "MMIO writes");372 PDMDevHlpSTAMRegister(pDevIns, &pThis->StatPciCfgReads, STAMTYPE_COUNTER, " /Devices/LPC/ConfigReads", STAMUNIT_OCCURENCES, "PCI config reads");373 PDMDevHlpSTAMRegister(pDevIns, &pThis->StatPciCfgWrites, STAMTYPE_COUNTER, " /Devices/LPC/ConfigWrites", STAMUNIT_OCCURENCES, "PCI config writes");358 PDMDevHlpSTAMRegister(pDevIns, &pThis->StatMmioReads, STAMTYPE_COUNTER, "MMIOReads", STAMUNIT_OCCURENCES, "MMIO reads"); 359 PDMDevHlpSTAMRegister(pDevIns, &pThis->StatMmioWrites, STAMTYPE_COUNTER, "MMIOWrites", STAMUNIT_OCCURENCES, "MMIO writes"); 360 PDMDevHlpSTAMRegister(pDevIns, &pThis->StatPciCfgReads, STAMTYPE_COUNTER, "ConfigReads", STAMUNIT_OCCURENCES, "PCI config reads"); 361 PDMDevHlpSTAMRegister(pDevIns, &pThis->StatPciCfgWrites, STAMTYPE_COUNTER, "ConfigWrites", STAMUNIT_OCCURENCES, "PCI config writes"); 374 362 375 363 PDMDevHlpDBGFInfoRegister(pDevIns, "lpc", "Display LPC status. (no arguments)", lpcInfo); … … 388 376 /* .uReserved0 = */ 0, 389 377 /* .szName = */ "lpc", 390 /* .fFlags = */ PDM_DEVREG_FLAGS_DEFAULT_BITS ,378 /* .fFlags = */ PDM_DEVREG_FLAGS_DEFAULT_BITS | PDM_DEVREG_FLAGS_NEW_STYLE, 391 379 /* .fClass = */ PDM_DEVREG_CLASS_MISC, 392 380 /* .cMaxInstances = */ 1,
Note:
See TracChangeset
for help on using the changeset viewer.