Changeset 81380 in vbox
- Timestamp:
- Oct 19, 2019 8:05:18 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Network/DevE1000.cpp
r81218 r81380 1079 1079 RCPTRTYPE(PPDMSCATTERGATHER) pTxSgRC; 1080 1080 RTRCPTR RCPtrAlignment; 1081 1082 1081 #if HC_ARCH_BITS != 32 1083 1082 uint32_t Alignment1; 1084 1083 #endif 1084 1085 /** Handle to PCI region \#0, the MMIO region. */ 1086 IOMIOPORTHANDLE hMmioRegion; 1087 /** Handle to PCI region \#2, the I/O ports. */ 1088 IOMIOPORTHANDLE hIoPorts; 1089 1085 1090 PDMCRITSECT cs; /**< Critical section - what is it protecting? */ 1086 1091 PDMCRITSECT csRx; /**< RX Critical section. */ … … 6002 6007 * @thread EMT 6003 6008 */ 6004 static inte1kRegReadAlignedU32(PE1KSTATE pThis, uint32_t offReg, uint32_t *pu32)6009 static VBOXSTRICTRC e1kRegReadAlignedU32(PE1KSTATE pThis, uint32_t offReg, uint32_t *pu32) 6005 6010 { 6006 6011 Assert(!(offReg & 3)); … … 6009 6014 * Lookup the register and check that it's readable. 6010 6015 */ 6011 intrc = VINF_SUCCESS;6012 int idxReg = e1kRegLookup(offReg);6016 VBOXSTRICTRC rc = VINF_SUCCESS; 6017 int idxReg = e1kRegLookup(offReg); 6013 6018 if (RT_LIKELY(idxReg != -1)) 6014 6019 { … … 6054 6059 * @thread EMT 6055 6060 */ 6056 static inte1kRegWriteAlignedU32(PE1KSTATE pThis, uint32_t offReg, uint32_t u32Value)6057 { 6058 intrc = VINF_SUCCESS;6059 int index = e1kRegLookup(offReg);6061 static VBOXSTRICTRC e1kRegWriteAlignedU32(PE1KSTATE pThis, uint32_t offReg, uint32_t u32Value) 6062 { 6063 VBOXSTRICTRC rc = VINF_SUCCESS; 6064 int index = e1kRegLookup(offReg); 6060 6065 if (RT_LIKELY(index != -1)) 6061 6066 { … … 6094 6099 6095 6100 /** 6096 * @callback_method_impl{FNIOMMMIO READ}6097 */ 6098 PDMBOTHCBDECL(int) e1kMMIORead(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS GCPhysAddr, void *pv, unsignedcb)6101 * @callback_method_impl{FNIOMMMIONEWREAD} 6102 */ 6103 static DECLCALLBACK(VBOXSTRICTRC) e1kMMIORead(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS off, void *pv, uint32_t cb) 6099 6104 { 6100 6105 RT_NOREF2(pvUser, cb); … … 6102 6107 STAM_PROFILE_ADV_START(&pThis->CTX_SUFF_Z(StatMMIORead), a); 6103 6108 6104 uint32_t offReg = GCPhysAddr - pThis->addrMMReg; 6105 Assert(offReg < E1K_MM_SIZE); 6109 Assert(off < E1K_MM_SIZE); 6106 6110 Assert(cb == 4); 6107 Assert(!( GCPhysAddr& 3));6108 6109 int rc = e1kRegReadAlignedU32(pThis, offReg, (uint32_t *)pv);6111 Assert(!(off & 3)); 6112 6113 VBOXSTRICTRC rcStrict = e1kRegReadAlignedU32(pThis, (uint32_t)off, (uint32_t *)pv); 6110 6114 6111 6115 STAM_PROFILE_ADV_STOP(&pThis->CTX_SUFF_Z(StatMMIORead), a); 6112 return rc ;6113 } 6114 6115 /** 6116 * @callback_method_impl{FNIOMMMIO WRITE}6117 */ 6118 PDMBOTHCBDECL(int) e1kMMIOWrite(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS GCPhysAddr, void const *pv, unsignedcb)6116 return rcStrict; 6117 } 6118 6119 /** 6120 * @callback_method_impl{FNIOMMMIONEWWRITE} 6121 */ 6122 static DECLCALLBACK(VBOXSTRICTRC) e1kMMIOWrite(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS off, void const *pv, uint32_t cb) 6119 6123 { 6120 6124 RT_NOREF2(pvUser, cb); … … 6122 6126 STAM_PROFILE_ADV_START(&pThis->CTX_SUFF_Z(StatMMIOWrite), a); 6123 6127 6124 uint32_t offReg = GCPhysAddr - pThis->addrMMReg; 6125 Assert(offReg < E1K_MM_SIZE); 6128 Assert(off < E1K_MM_SIZE); 6126 6129 Assert(cb == 4); 6127 Assert(!( GCPhysAddr& 3));6128 6129 int rc = e1kRegWriteAlignedU32(pThis, offReg, *(uint32_t const *)pv);6130 Assert(!(off & 3)); 6131 6132 VBOXSTRICTRC rcStrict = e1kRegWriteAlignedU32(pThis, (uint32_t)off, *(uint32_t const *)pv); 6130 6133 6131 6134 STAM_PROFILE_ADV_STOP(&pThis->CTX_SUFF_Z(StatMMIOWrite), a); 6132 return rc ;6133 } 6134 6135 /** 6136 * @callback_method_impl{FNIOMIOPORT IN}6137 */ 6138 PDMBOTHCBDECL(int) e1kIOPortIn(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT uPort, uint32_t *pu32, unsigned cb)6139 { 6140 PE1KSTATE pThis = PDMINS_2_DATA(pDevIns, PE1KSTATE);6141 intrc;6135 return rcStrict; 6136 } 6137 6138 /** 6139 * @callback_method_impl{FNIOMIOPORTNEWIN} 6140 */ 6141 static DECLCALLBACK(VBOXSTRICTRC) e1kIOPortIn(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT offPort, uint32_t *pu32, unsigned cb) 6142 { 6143 PE1KSTATE pThis = PDMINS_2_DATA(pDevIns, PE1KSTATE); 6144 VBOXSTRICTRC rc; 6142 6145 STAM_PROFILE_ADV_START(&pThis->CTX_SUFF_Z(StatIORead), a); 6143 6146 RT_NOREF_PV(pvUser); 6144 6147 6145 uPort -= pThis->IOPortBase;6146 6148 if (RT_LIKELY(cb == 4)) 6147 switch ( uPort)6149 switch (offPort) 6148 6150 { 6149 6151 case 0x00: /* IOADDR */ … … 6164 6166 6165 6167 default: 6166 E1kLog(("%s e1kIOPortIn: invalid port %#010x\n", pThis->szPrf, uPort));6168 E1kLog(("%s e1kIOPortIn: invalid port %#010x\n", pThis->szPrf, offPort)); 6167 6169 //rc = VERR_IOM_IOPORT_UNUSED; /* Why not? */ 6168 6170 rc = VINF_SUCCESS; … … 6170 6172 else 6171 6173 { 6172 E1kLog(("%s e1kIOPortIn: invalid op size: uPort=%RTiop cb=%08x", pThis->szPrf, uPort, cb));6173 rc = PDMDevHlpDBGFStop(pDevIns, RT_SRC_POS, "%s e1kIOPortIn: invalid op size: uPort=%RTiop cb=%08x\n", pThis->szPrf, uPort, cb);6174 E1kLog(("%s e1kIOPortIn: invalid op size: offPort=%RTiop cb=%08x", pThis->szPrf, offPort, cb)); 6175 rc = PDMDevHlpDBGFStop(pDevIns, RT_SRC_POS, "%s e1kIOPortIn: invalid op size: offPort=%RTiop cb=%08x\n", pThis->szPrf, offPort, cb); 6174 6176 } 6175 6177 STAM_PROFILE_ADV_STOP(&pThis->CTX_SUFF_Z(StatIORead), a); … … 6179 6181 6180 6182 /** 6181 * @callback_method_impl{FNIOMIOPORT OUT}6182 */ 6183 PDMBOTHCBDECL(int) e1kIOPortOut(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT uPort, uint32_t u32, unsigned cb)6184 { 6185 PE1KSTATE pThis = PDMINS_2_DATA(pDevIns, PE1KSTATE);6186 intrc;6183 * @callback_method_impl{FNIOMIOPORTNEWOUT} 6184 */ 6185 static DECLCALLBACK(VBOXSTRICTRC) e1kIOPortOut(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT offPort, uint32_t u32, unsigned cb) 6186 { 6187 PE1KSTATE pThis = PDMINS_2_DATA(pDevIns, PE1KSTATE); 6188 VBOXSTRICTRC rc; 6187 6189 STAM_PROFILE_ADV_START(&pThis->CTX_SUFF_Z(StatIOWrite), a); 6188 6190 RT_NOREF_PV(pvUser); 6189 6191 6190 E1kLog2(("%s e1kIOPortOut: uPort=%RTiop value=%08x\n", pThis->szPrf, uPort, u32));6192 E1kLog2(("%s e1kIOPortOut: offPort=%RTiop value=%08x\n", pThis->szPrf, offPort, u32)); 6191 6193 if (RT_LIKELY(cb == 4)) 6192 6194 { 6193 uPort -= pThis->IOPortBase; 6194 switch (uPort) 6195 switch (offPort) 6195 6196 { 6196 6197 case 0x00: /* IOADDR */ … … 6214 6215 6215 6216 default: 6216 E1kLog(("%s e1kIOPortOut: invalid port %#010x\n", pThis->szPrf, uPort));6217 rc = PDMDevHlpDBGFStop(pDevIns, RT_SRC_POS, "invalid port %#010x\n", uPort);6217 E1kLog(("%s e1kIOPortOut: invalid port %#010x\n", pThis->szPrf, offPort)); 6218 rc = PDMDevHlpDBGFStop(pDevIns, RT_SRC_POS, "invalid port %#010x\n", offPort); 6218 6219 } 6219 6220 } 6220 6221 else 6221 6222 { 6222 E1kLog(("%s e1kIOPortOut: invalid op size: uPort=%RTiop cb=%08x\n", pThis->szPrf, uPort, cb));6223 rc = PDMDevHlpDBGFStop(pDevIns, RT_SRC_POS, "%s: invalid op size: uPort=%RTiop cb=%#x\n", pThis->szPrf, uPort, cb);6223 E1kLog(("%s e1kIOPortOut: invalid op size: offPort=%RTiop cb=%08x\n", pThis->szPrf, offPort, cb)); 6224 rc = PDMDevHlpDBGFStop(pDevIns, RT_SRC_POS, "%s: invalid op size: offPort=%RTiop cb=%#x\n", pThis->szPrf, offPort, cb); 6224 6225 } 6225 6226 … … 6285 6286 /** 6286 6287 * @callback_method_impl{FNPCIIOREGIONMAP} 6287 */ 6288 static DECLCALLBACK(int) e1kMap(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, uint32_t iRegion, 6289 RTGCPHYS GCPhysAddress, RTGCPHYS cb, PCIADDRESSSPACE enmType) 6288 * 6289 * @todo Can remove this one later, it's realy just here for taking down 6290 * addresses for e1kInfo(), an alignment assertion and sentimentality. 6291 */ 6292 static DECLCALLBACK(int) e1kR3Map(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, uint32_t iRegion, 6293 RTGCPHYS GCPhysAddress, RTGCPHYS cb, PCIADDRESSSPACE enmType) 6290 6294 { 6291 6295 PE1KSTATE pThis = PDMINS_2_DATA(pDevIns, E1KSTATE *); 6292 RT_NOREF(pPciDev, iRegion); 6296 E1kLog(("%s e1kR3Map: iRegion=%u GCPhysAddress=%RGp\n", pThis->szPrf, iRegion, GCPhysAddress)); 6297 RT_NOREF(pPciDev, iRegion, cb); 6293 6298 Assert(pPciDev == pDevIns->apPciDevs[0]); 6294 6299 6295 int rc;6296 6300 switch (enmType) 6297 6301 { 6298 6302 case PCI_ADDRESS_SPACE_IO: 6299 6303 pThis->IOPortBase = (RTIOPORT)GCPhysAddress; 6300 rc = PDMDevHlpIOPortRegister(pDevIns, pThis->IOPortBase, cb, NULL /*pvUser*/,6301 e1kIOPortOut, e1kIOPortIn, NULL, NULL, "E1000");6302 if (pThis->fR0Enabled && RT_SUCCESS(rc))6303 rc = PDMDevHlpIOPortRegisterR0(pDevIns, pThis->IOPortBase, cb, NIL_RTR0PTR /*pvUser*/,6304 "e1kIOPortOut", "e1kIOPortIn", NULL, NULL, "E1000");6305 if (pThis->fRCEnabled && RT_SUCCESS(rc))6306 rc = PDMDevHlpIOPortRegisterRC(pDevIns, pThis->IOPortBase, cb, NIL_RTRCPTR /*pvUser*/,6307 "e1kIOPortOut", "e1kIOPortIn", NULL, NULL, "E1000");6308 6304 break; 6309 6305 6310 6306 case PCI_ADDRESS_SPACE_MEM: 6311 /*6312 * From the spec:6313 * For registers that should be accessed as 32-bit double words,6314 * partial writes (less than a 32-bit double word) is ignored.6315 * Partial reads return all 32 bits of data regardless of the6316 * byte enables.6317 */6318 #ifdef E1K_WITH_PREREG_MMIO6319 6307 pThis->addrMMReg = GCPhysAddress; 6320 if (GCPhysAddress == NIL_RTGCPHYS) 6321 rc = VINF_SUCCESS; 6322 else 6323 { 6324 Assert(!(GCPhysAddress & 7)); 6325 rc = PDMDevHlpMMIOExMap(pDevIns, pPciDev, iRegion, GCPhysAddress); 6326 } 6327 #else 6328 pThis->addrMMReg = GCPhysAddress; Assert(!(GCPhysAddress & 7)); 6329 rc = PDMDevHlpMMIORegister(pDevIns, GCPhysAddress, cb, NULL /*pvUser*/, 6330 IOMMMIO_FLAGS_READ_DWORD | IOMMMIO_FLAGS_WRITE_ONLY_DWORD, 6331 e1kMMIOWrite, e1kMMIORead, "E1000"); 6332 if (pThis->fR0Enabled && RT_SUCCESS(rc)) 6333 rc = PDMDevHlpMMIORegisterR0(pDevIns, GCPhysAddress, cb, NIL_RTR0PTR /*pvUser*/, 6334 "e1kMMIOWrite", "e1kMMIORead"); 6335 if (pThis->fRCEnabled && RT_SUCCESS(rc)) 6336 rc = PDMDevHlpMMIORegisterRC(pDevIns, GCPhysAddress, cb, NIL_RTRCPTR /*pvUser*/, 6337 "e1kMMIOWrite", "e1kMMIORead"); 6338 #endif 6308 Assert(!(GCPhysAddress & 7) || GCPhysAddress == NIL_RTGCPHYS); 6339 6309 break; 6340 6310 6341 6311 default: 6342 6312 /* We should never get here */ 6343 AssertMsgFailed(("Invalid PCI address space param in map callback")); 6344 rc = VERR_INTERNAL_ERROR; 6345 break; 6346 } 6347 return rc; 6313 AssertMsgFailedReturn(("Invalid PCI address space param in map callback"), VERR_INTERNAL_ERROR); 6314 } 6315 return VINF_SUCCESS; 6348 6316 } 6349 6317 … … 7250 7218 pDevIns->iInstance, pThis->IOPortBase, pThis->addrMMReg, 7251 7219 &pThis->macConfigured, g_aChips[pThis->eChip].pcszName, 7252 p This->fRCEnabled ? " GC" : "", pThis->fR0Enabled ? " R0" : "");7220 pDevIns->fRCEnabled ? " RC" : "", pDevIns->fR0Enabled ? " R0" : ""); 7253 7221 7254 7222 e1kCsEnter(pThis, VERR_INTERNAL_ERROR); /* Not sure why but PCNet does it */ … … 7607 7575 * @thread EMT 7608 7576 */ 7609 static DECLCALLBACK(void) e1kConfigurePciDev(PPDMPCIDEV pPciDev, E1KCHIP eChip)7577 static void e1kR3ConfigurePciDev(PPDMPCIDEV pPciDev, E1KCHIP eChip) 7610 7578 { 7611 7579 Assert(eChip < RT_ELEMENTS(g_aChips)); … … 7731 7699 * Validate configuration. 7732 7700 */ 7733 if (!CFGMR3AreValuesValid(pCfg, "MAC\0" "CableConnected\0" "AdapterType\0" 7734 "LineSpeed\0" "GCEnabled\0" "R0Enabled\0" 7735 "ItrEnabled\0" "ItrRxEnabled\0" 7736 "EthernetCRC\0" "GSOEnabled\0" "LinkUpDelay\0")) 7737 return PDMDEV_SET_ERROR(pDevIns, VERR_PDM_DEVINS_UNKNOWN_CFG_VALUES, 7738 N_("Invalid configuration for E1000 device")); 7701 PDMDEV_VALIDATE_CONFIG_RETURN(pDevIns, 7702 "MAC|" 7703 "CableConnected|" 7704 "AdapterType|" 7705 "LineSpeed|" 7706 "ItrEnabled|" 7707 "ItrRxEnabled|" 7708 "EthernetCRC|" 7709 "GSOEnabled|" 7710 "LinkUpDelay", ""); 7739 7711 7740 7712 /** @todo LineSpeed unused! */ 7741 7713 7742 /* Get config params */ 7714 /* 7715 * Get config params 7716 */ 7743 7717 rc = CFGMR3QueryBytes(pCfg, "MAC", pThis->macConfigured.au8, sizeof(pThis->macConfigured.au8)); 7744 7718 if (RT_FAILURE(rc)) … … 7754 7728 N_("Configuration error: Failed to get the value of 'AdapterType'")); 7755 7729 Assert(pThis->eChip <= E1K_CHIP_82545EM); 7756 rc = CFGMR3QueryBoolDef(pCfg, "GCEnabled", &pThis->fRCEnabled, true);7757 if (RT_FAILURE(rc))7758 return PDMDEV_SET_ERROR(pDevIns, rc,7759 N_("Configuration error: Failed to get the value of 'GCEnabled'"));7760 7761 rc = CFGMR3QueryBoolDef(pCfg, "R0Enabled", &pThis->fR0Enabled, true);7762 if (RT_FAILURE(rc))7763 return PDMDEV_SET_ERROR(pDevIns, rc,7764 N_("Configuration error: Failed to get the value of 'R0Enabled'"));7765 7730 7766 7731 rc = CFGMR3QueryBoolDef(pCfg, "EthernetCRC", &pThis->fEthernetCRC, true); … … 7799 7764 LogRel(("%s: WARNING! Link up delay is disabled!\n", pThis->szPrf)); 7800 7765 7801 LogRel(("%s: Chip=%s LinkUpDelay=%ums EthernetCRC=%s GSO=%s Itr=%s ItrRx=%s TID=%s R0=%s GC=%s\n", pThis->szPrf,7766 LogRel(("%s: Chip=%s LinkUpDelay=%ums EthernetCRC=%s GSO=%s Itr=%s ItrRx=%s TID=%s R0=%s RC=%s\n", pThis->szPrf, 7802 7767 g_aChips[pThis->eChip].pcszName, pThis->cMsLinkUpDelay, 7803 7768 pThis->fEthernetCRC ? "on" : "off", … … 7806 7771 pThis->fItrRxEnabled ? "enabled" : "disabled", 7807 7772 pThis->fTidEnabled ? "enabled" : "disabled", 7808 pThis->fR0Enabled ? "enabled" : "disabled", 7809 pThis->fRCEnabled ? "enabled" : "disabled")); 7773 pDevIns->fR0Enabled ? "enabled" : "disabled", 7774 pDevIns->fRCEnabled ? "enabled" : "disabled")); 7775 7776 /* 7777 * Initialize sub-components and register everything with the VMM. 7778 */ 7810 7779 7811 7780 /* Initialize the EEPROM. */ … … 7820 7789 7821 7790 rc = PDMDevHlpCritSectInit(pDevIns, &pThis->cs, RT_SRC_POS, "E1000#%d", iInstance); 7822 if (RT_FAILURE(rc)) 7823 return rc; 7791 AssertRCReturn(rc, rc); 7824 7792 rc = PDMDevHlpCritSectInit(pDevIns, &pThis->csRx, RT_SRC_POS, "E1000#%dRX", iInstance); 7825 if (RT_FAILURE(rc)) 7826 return rc; 7793 AssertRCReturn(rc, rc); 7827 7794 #ifdef E1K_WITH_TX_CS 7828 7795 rc = PDMDevHlpCritSectInit(pDevIns, &pThis->csTx, RT_SRC_POS, "E1000#%dTX", iInstance); 7829 if (RT_FAILURE(rc)) 7830 return rc; 7831 #endif /* E1K_WITH_TX_CS */ 7796 AssertRCReturn(rc, rc); 7797 #endif 7832 7798 7833 7799 /* Saved state registration. */ … … 7836 7802 e1kSavePrep, e1kSaveExec, NULL, 7837 7803 e1kLoadPrep, e1kLoadExec, e1kLoadDone); 7838 if (RT_FAILURE(rc)) 7839 return rc; 7804 AssertRCReturn(rc, rc); 7840 7805 7841 7806 /* Set PCI config registers and register ourselves with the PCI bus. */ 7842 7807 PDMPCIDEV_ASSERT_VALID(pDevIns, pDevIns->apPciDevs[0]); 7843 e1k ConfigurePciDev(pDevIns->apPciDevs[0], pThis->eChip);7808 e1kR3ConfigurePciDev(pDevIns->apPciDevs[0], pThis->eChip); 7844 7809 rc = PDMDevHlpPCIRegister(pDevIns, pDevIns->apPciDevs[0]); 7845 if (RT_FAILURE(rc)) 7846 return rc; 7810 AssertRCReturn(rc, rc); 7847 7811 7848 7812 #ifdef E1K_WITH_MSI … … 7857 7821 #endif 7858 7822 7859 7860 /* Map our registers to memory space (region 0, see e1kConfigurePCI)*/ 7861 rc = PDMDevHlpPCIIORegionRegister(pDevIns, 0, E1K_MM_SIZE, PCI_ADDRESS_SPACE_MEM, e1kMap); 7862 if (RT_FAILURE(rc)) 7863 return rc; 7864 #ifdef E1K_WITH_PREREG_MMIO 7865 rc = PDMDevHlpMMIOExPreRegister(pDevIns, 0, E1K_MM_SIZE, IOMMMIO_FLAGS_READ_DWORD | IOMMMIO_FLAGS_WRITE_ONLY_DWORD, "E1000", 7866 NULL /*pvUserR3*/, e1kMMIOWrite, e1kMMIORead, NULL /*pfnFillR3*/, 7867 NIL_RTR0PTR /*pvUserR0*/, pThis->fR0Enabled ? "e1kMMIOWrite" : NULL, 7868 pThis->fR0Enabled ? "e1kMMIORead" : NULL, NULL /*pszFillR0*/, 7869 NIL_RTRCPTR /*pvUserRC*/, pThis->fRCEnabled ? "e1kMMIOWrite" : NULL, 7870 pThis->fRCEnabled ? "e1kMMIORead" : NULL, NULL /*pszFillRC*/); 7871 AssertLogRelRCReturn(rc, rc); 7872 #endif 7873 /* Map our registers to IO space (region 2, see e1kConfigurePCI) */ 7874 rc = PDMDevHlpPCIIORegionRegister(pDevIns, 2, E1K_IOPORT_SIZE, PCI_ADDRESS_SPACE_IO, e1kMap); 7875 if (RT_FAILURE(rc)) 7876 return rc; 7823 /* 7824 * Map our registers to memory space (region 0, see e1kR3ConfigurePciDev) 7825 * From the spec (regarding flags): 7826 * For registers that should be accessed as 32-bit double words, 7827 * partial writes (less than a 32-bit double word) is ignored. 7828 * Partial reads return all 32 bits of data regardless of the 7829 * byte enables. 7830 */ 7831 rc = PDMDevHlpMmioCreateEx(pDevIns, E1K_MM_SIZE, IOMMMIO_FLAGS_READ_DWORD | IOMMMIO_FLAGS_WRITE_ONLY_DWORD, 7832 pDevIns->apPciDevs[0], 0 /*iPciRegion*/, 7833 e1kMMIOWrite, e1kMMIORead, NULL /*pfnFill*/, NULL /*pvUser*/, "E1000", &pThis->hMmioRegion); 7834 AssertRCReturn(rc, rc); 7835 rc = PDMDevHlpPCIIORegionRegisterMmio(pDevIns, 0, E1K_MM_SIZE, PCI_ADDRESS_SPACE_MEM, pThis->hMmioRegion, e1kR3Map); 7836 AssertRCReturn(rc, rc); 7837 7838 /* Map our registers to IO space (region 2, see e1kR3ConfigurePciDev) */ 7839 rc = PDMDevHlpIoPortCreate(pDevIns, E1K_IOPORT_SIZE, pDevIns->apPciDevs[0], 2 /*iPciRegion*/, 7840 e1kIOPortOut, e1kIOPortIn, NULL /*pvUser*/, "E1000", NULL /*paExtDescs*/, &pThis->hIoPorts); 7841 AssertRCReturn(rc, rc); 7842 rc = PDMDevHlpPCIIORegionRegisterIo(pDevIns, 2, E1K_IOPORT_SIZE, pThis->hIoPorts, e1kR3Map); 7843 AssertRCReturn(rc, rc); 7877 7844 7878 7845 /* Create transmit queue */ 7846 /** @todo Convert queues to be accessed via handles. Create a ring-3 task thingy for 1 item queues. */ 7879 7847 rc = PDMDevHlpQueueCreate(pDevIns, sizeof(PDMQUEUEITEMCORE), 1, 0, 7880 7848 e1kTxQueueConsumer, true, "E1000-Xmit", &pThis->pTxQueueR3); 7881 if (RT_FAILURE(rc)) 7882 return rc; 7849 AssertRCReturn(rc, rc); 7883 7850 pThis->pTxQueueR0 = PDMQueueR0Ptr(pThis->pTxQueueR3); 7884 7851 pThis->pTxQueueRC = PDMQueueRCPtr(pThis->pTxQueueR3); … … 7887 7854 rc = PDMDevHlpQueueCreate(pDevIns, sizeof(PDMQUEUEITEMCORE), 1, 0, 7888 7855 e1kCanRxQueueConsumer, true, "E1000-Rcv", &pThis->pCanRxQueueR3); 7889 if (RT_FAILURE(rc)) 7890 return rc; 7856 AssertRCReturn(rc, rc); 7891 7857 pThis->pCanRxQueueR0 = PDMQueueR0Ptr(pThis->pCanRxQueueR3); 7892 7858 pThis->pCanRxQueueRC = PDMQueueRCPtr(pThis->pCanRxQueueR3); … … 7897 7863 TMTIMER_FLAGS_NO_CRIT_SECT, 7898 7864 "E1000 Transmit Delay Timer", &pThis->pTXDTimerR3); 7899 if (RT_FAILURE(rc)) 7900 return rc; 7865 AssertRCReturn(rc, rc); 7901 7866 pThis->pTXDTimerR0 = TMTimerR0Ptr(pThis->pTXDTimerR3); 7902 7867 pThis->pTXDTimerRC = TMTimerRCPtr(pThis->pTXDTimerR3); … … 8108 8073 } 8109 8074 8110 #endif /* IN_RING3 */ 8075 #else /* !IN_RING3 */ 8076 8077 /** 8078 * @callback_method_impl{PDMDEVREGR0,pfnConstruct} 8079 */ 8080 static DECLCALLBACK(int) e1kRZConstruct(PPDMDEVINS pDevIns) 8081 { 8082 PE1KSTATE pThis = PDMINS_2_DATA(pDevIns, PE1KSTATE); 8083 //PE1KSTATER0 pThisCC = PDMINS_2_DATA_CC(pDevIns, PRTCSTATECC); 8084 //pThisCC->CTX_SUFF(pDevIns) = pDevIns; 8085 8086 int rc = PDMDevHlpMmioSetUpContext(pDevIns, pThis->hMmioRegion, e1kMMIOWrite, e1kMMIORead, NULL /*pvUser*/); 8087 AssertRCReturn(rc, rc); 8088 8089 rc = PDMDevHlpIoPortSetUpContext(pDevIns, pThis->hIoPorts, e1kIOPortOut, e1kIOPortIn, NULL /*pvUser*/); 8090 AssertRCReturn(rc, rc); 8091 8092 return VINF_SUCCESS; 8093 } 8094 8095 #endif /* !IN_RING3 */ 8111 8096 8112 8097 /** … … 8155 8140 #elif defined(IN_RING0) 8156 8141 /* .pfnEarlyConstruct = */ NULL, 8157 /* .pfnConstruct = */ NULL,8142 /* .pfnConstruct = */ e1kRZConstruct, 8158 8143 /* .pfnDestruct = */ NULL, 8159 8144 /* .pfnFinalDestruct = */ NULL, … … 8168 8153 /* .pfnReserved7 = */ NULL, 8169 8154 #elif defined(IN_RC) 8170 /* .pfnConstruct = */ NULL,8155 /* .pfnConstruct = */ e1kRZConstruct, 8171 8156 /* .pfnReserved0 = */ NULL, 8172 8157 /* .pfnReserved1 = */ NULL,
Note:
See TracChangeset
for help on using the changeset viewer.