Changeset 56405 in vbox for trunk/src/VBox/Devices/Storage
- Timestamp:
- Jun 13, 2015 7:11:20 PM (10 years ago)
- svn:sync-xref-src-repo-rev:
- 101006
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Storage/DevATA.cpp
r56404 r56405 496 496 /** Status LUN: Media Notify. */ 497 497 R3PTRTYPE(PPDMIMEDIANOTIFY) pMediaNotify; 498 /** Flag whether GC is enabled. */499 bool f GCEnabled;498 /** Flag whether RC is enabled. */ 499 bool fRCEnabled; 500 500 /** Flag whether R0 is enabled. */ 501 501 bool fR0Enabled; … … 525 525 ******************************************************************************/ 526 526 RT_C_DECLS_BEGIN 527 PDMBOTHCBDECL(int) ataIOPortWrite1(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t u32, unsigned cb); 528 PDMBOTHCBDECL(int) ataIOPortRead1(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t *u32, unsigned cb); 529 PDMBOTHCBDECL(int) ataIOPortWriteStr1(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, RTGCPTR *pGCPtrSrc, PRTGCUINTREG pcTransfer, unsigned cb); 530 PDMBOTHCBDECL(int) ataIOPortReadStr1(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, RTGCPTR *pGCPtrDst, PRTGCUINTREG pcTransfer, unsigned cb); 527 528 PDMBOTHCBDECL(int) ataIOPortWrite1Data(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t u32, unsigned cb); 529 PDMBOTHCBDECL(int) ataIOPortRead1Data(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t *u32, unsigned cb); 530 PDMBOTHCBDECL(int) ataIOPortWriteStr1Data(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, RTGCPTR *pGCPtrSrc, PRTGCUINTREG pcTransfer, unsigned cb); 531 PDMBOTHCBDECL(int) ataIOPortReadStr1Data(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, RTGCPTR *pGCPtrDst, PRTGCUINTREG pcTransfer, unsigned cb); 532 PDMBOTHCBDECL(int) ataIOPortWrite1Other(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t u32, unsigned cb); 533 PDMBOTHCBDECL(int) ataIOPortRead1Other(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t *u32, unsigned cb); 531 534 PDMBOTHCBDECL(int) ataIOPortWrite2(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t u32, unsigned cb); 532 535 PDMBOTHCBDECL(int) ataIOPortRead2(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t *u32, unsigned cb); … … 5874 5877 rc = rc2; 5875 5878 5876 if (pThis->f GCEnabled)5879 if (pThis->fRCEnabled) 5877 5880 { 5878 5881 rc2 = PDMDevHlpIOPortRegisterRC(pPciDev->pDevIns, (RTIOPORT)GCPhysAddress + i * 8, 8, … … 5985 5988 * @see FNIOMIOPORTOUT for details. 5986 5989 */ 5987 PDMBOTHCBDECL(int) ataIOPortWrite1 (PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t u32, unsigned cb)5990 PDMBOTHCBDECL(int) ataIOPortWrite1Data(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t u32, unsigned cb) 5988 5991 { 5989 5992 uint32_t i = (uint32_t)(uintptr_t)pvUser; … … 5992 5995 5993 5996 Assert(i < 2); 5997 Assert(Port == pCtl->IOPortBase1); 5994 5998 5995 5999 int rc = PDMCritSectEnter(&pCtl->lock, VINF_IOM_R3_IOPORT_WRITE); 5996 6000 if (rc == VINF_SUCCESS) 5997 6001 { 5998 if (Port == pCtl->IOPortBase1) 5999 { 6000 /* Writes to the data port may be 16-bit or 32-bit. */ 6001 Assert(cb == 2 || cb == 4); 6002 rc = ataDataWrite(pCtl, Port, cb, (const uint8_t *)&u32); 6003 } 6004 else 6005 { 6006 /* Writes to the other command block ports should be 8-bit only. If they 6007 * are not, the high bits are simply discarded. Undocumented, but observed 6008 * on a real PIIX4 system. 6009 */ 6010 if (cb > 1) 6011 Log(("ataIOPortWrite1: suspect write to port %x val=%x size=%d\n", Port, u32, cb)); 6012 6013 rc = ataIOPortWriteU8(pCtl, Port, u32); 6014 } 6002 /* Writes to the data port may be 16-bit or 32-bit. */ 6003 Assert(cb == 2 || cb == 4); 6004 rc = ataDataWrite(pCtl, Port, cb, (const uint8_t *)&u32); 6005 6015 6006 PDMCritSectLeave(&pCtl->lock); 6016 6007 } … … 6023 6014 * @see FNIOMIOPORTIN for details. 6024 6015 */ 6025 PDMBOTHCBDECL(int) ataIOPortRead1 (PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t *pu32, unsigned cb)6016 PDMBOTHCBDECL(int) ataIOPortRead1Data(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t *pu32, unsigned cb) 6026 6017 { 6027 6018 uint32_t i = (uint32_t)(uintptr_t)pvUser; … … 6030 6021 6031 6022 Assert(i < 2); 6023 Assert(Port == pCtl->IOPortBase1); 6032 6024 6033 6025 int rc = PDMCritSectEnter(&pCtl->lock, VINF_IOM_R3_IOPORT_READ); 6034 6026 if (rc == VINF_SUCCESS) 6035 6027 { 6036 if (Port == pCtl->IOPortBase1) 6037 { 6038 /* Reads from the data register may be 16-bit or 32-bit. */ 6039 Assert(cb == 1 || cb == 2 || cb == 4); 6040 rc = ataDataRead(pCtl, Port, cb == 1 ? 2 : cb, (uint8_t *)pu32); 6041 if (cb <= 2) 6042 *pu32 &= 0xffff >> (16 - cb * 8); 6043 } 6044 else 6045 { 6046 /* Reads from the other command block registers should be 8-bit only. 6047 * If they are not, the low byte is propagated to the high bits. 6048 * Undocumented, but observed on a real PIIX4 system. 6049 */ 6050 rc = ataIOPortReadU8(pCtl, Port, pu32); 6051 if (cb > 1) 6052 { 6053 uint32_t pad; 6054 6055 /* Replicate the 8-bit result into the upper three bytes. */ 6056 pad = *pu32 & 0xff; 6057 pad = pad | (pad << 8); 6058 pad = pad | (pad << 16); 6059 *pu32 = pad; 6060 Log(("ataIOPortRead1: suspect read from port %x size=%d\n", Port, cb)); 6061 } 6062 } 6028 /* Reads from the data register may be 16-bit or 32-bit. */ 6029 Assert(cb == 1 || cb == 2 || cb == 4); 6030 rc = ataDataRead(pCtl, Port, cb == 1 ? 2 : cb, (uint8_t *)pu32); 6031 if (cb <= 2) 6032 *pu32 &= 0xffff >> (16 - cb * 8); 6033 6063 6034 PDMCritSectLeave(&pCtl->lock); 6064 6035 } … … 6073 6044 * @see FNIOMIOPORTINSTRING for details. 6074 6045 */ 6075 PDMBOTHCBDECL(int) ataIOPortReadStr1(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, RTGCPTR *pGCPtrDst, PRTGCUINTREG pcTransfer, unsigned cb) 6046 PDMBOTHCBDECL(int) ataIOPortReadStr1Data(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, RTGCPTR *pGCPtrDst, 6047 PRTGCUINTREG pcTransfer, unsigned cb) 6076 6048 { 6077 6049 uint32_t i = (uint32_t)(uintptr_t)pvUser; … … 6081 6053 6082 6054 Assert(i < 2); 6055 Assert(Port == pCtl->IOPortBase1); 6083 6056 6084 6057 rc = PDMCritSectEnter(&pCtl->lock, VINF_IOM_R3_IOPORT_READ); 6085 if (rc != VINF_SUCCESS) 6086 return rc; 6087 if (Port == pCtl->IOPortBase1) 6088 { 6089 uint32_t cTransAvailable, cTransfer = *pcTransfer, cbTransfer; 6090 RTGCPTR GCDst = *pGCPtrDst; 6058 if (rc == VINF_SUCCESS) 6059 { 6091 6060 ATADevState *s = &pCtl->aIfs[pCtl->iSelectedIf]; 6061 uint32_t cTransAvailable; 6062 uint32_t cTransfer = *pcTransfer; 6063 uint32_t cbTransfer; 6064 RTGCPTR GCDst = *pGCPtrDst; 6092 6065 Assert(cb == 2 || cb == 4); 6093 6066 … … 6131 6104 ataHCPIOTransferFinish(pCtl, s); 6132 6105 # endif /* IN_RING3 */ 6133 }6134 PDMCritSectLeave(&pCtl->lock);6106 PDMCritSectLeave(&pCtl->lock); 6107 } 6135 6108 return rc; 6136 6109 } … … 6141 6114 * @see FNIOMIOPORTOUTSTRING for details. 6142 6115 */ 6143 PDMBOTHCBDECL(int) ataIOPortWriteStr1(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, RTGCPTR *pGCPtrSrc, PRTGCUINTREG pcTransfer, unsigned cb) 6116 PDMBOTHCBDECL(int) ataIOPortWriteStr1Data(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, RTGCPTR *pGCPtrSrc, 6117 PRTGCUINTREG pcTransfer, unsigned cb) 6144 6118 { 6145 6119 uint32_t i = (uint32_t)(uintptr_t)pvUser; … … 6149 6123 6150 6124 Assert(i < 2); 6125 Assert(Port == pCtl->IOPortBase1); 6151 6126 6152 6127 rc = PDMCritSectEnter(&pCtl->lock, VINF_IOM_R3_IOPORT_WRITE); 6153 if (rc != VINF_SUCCESS) 6154 return rc; 6155 if (Port == pCtl->IOPortBase1) 6156 { 6128 if (rc == VINF_SUCCESS) 6129 { 6130 ATADevState *s = &pCtl->aIfs[pCtl->iSelectedIf]; 6157 6131 uint32_t cTransfer = *pcTransfer; 6158 6132 uint32_t cbTransfer; 6159 6133 RTGCPTR GCSrc = *pGCPtrSrc; 6160 ATADevState *s = &pCtl->aIfs[pCtl->iSelectedIf];6161 6134 Assert(cb == 2 || cb == 4); 6162 6135 … … 6200 6173 ataHCPIOTransferFinish(pCtl, s); 6201 6174 # endif /* IN_RING3 */ 6202 }6203 PDMCritSectLeave(&pCtl->lock);6175 PDMCritSectLeave(&pCtl->lock); 6176 } 6204 6177 return rc; 6205 6178 } 6206 6179 6207 6180 #endif /* !IN_RING0 */ 6181 6182 /** 6183 * Port I/O Handler for primary port range OUT operations. 6184 * @see FNIOMIOPORTOUT for details. 6185 */ 6186 PDMBOTHCBDECL(int) ataIOPortWrite1Other(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t u32, unsigned cb) 6187 { 6188 uint32_t i = (uint32_t)(uintptr_t)pvUser; 6189 PCIATAState *pThis = PDMINS_2_DATA(pDevIns, PCIATAState *); 6190 PATACONTROLLER pCtl = &pThis->aCts[i]; 6191 6192 Assert(i < 2); 6193 Assert(Port != pCtl->IOPortBase1); 6194 6195 int rc = PDMCritSectEnter(&pCtl->lock, VINF_IOM_R3_IOPORT_WRITE); 6196 if (rc == VINF_SUCCESS) 6197 { 6198 /* Writes to the other command block ports should be 8-bit only. If they 6199 * are not, the high bits are simply discarded. Undocumented, but observed 6200 * on a real PIIX4 system. 6201 */ 6202 if (cb > 1) 6203 Log(("ataIOPortWrite1: suspect write to port %x val=%x size=%d\n", Port, u32, cb)); 6204 6205 rc = ataIOPortWriteU8(pCtl, Port, u32); 6206 6207 PDMCritSectLeave(&pCtl->lock); 6208 } 6209 return rc; 6210 } 6211 6212 6213 /** 6214 * Port I/O Handler for primary port range IN operations. 6215 * @see FNIOMIOPORTIN for details. 6216 */ 6217 PDMBOTHCBDECL(int) ataIOPortRead1Other(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t *pu32, unsigned cb) 6218 { 6219 uint32_t i = (uint32_t)(uintptr_t)pvUser; 6220 PCIATAState *pThis = PDMINS_2_DATA(pDevIns, PCIATAState *); 6221 PATACONTROLLER pCtl = &pThis->aCts[i]; 6222 6223 Assert(i < 2); 6224 Assert(Port != pCtl->IOPortBase1); 6225 6226 int rc = PDMCritSectEnter(&pCtl->lock, VINF_IOM_R3_IOPORT_READ); 6227 if (rc == VINF_SUCCESS) 6228 { 6229 /* Reads from the other command block registers should be 8-bit only. 6230 * If they are not, the low byte is propagated to the high bits. 6231 * Undocumented, but observed on a real PIIX4 system. 6232 */ 6233 rc = ataIOPortReadU8(pCtl, Port, pu32); 6234 if (cb > 1) 6235 { 6236 uint32_t pad; 6237 6238 /* Replicate the 8-bit result into the upper three bytes. */ 6239 pad = *pu32 & 0xff; 6240 pad = pad | (pad << 8); 6241 pad = pad | (pad << 16); 6242 *pu32 = pad; 6243 Log(("ataIOPortRead1: suspect read from port %x size=%d\n", Port, cb)); 6244 } 6245 PDMCritSectLeave(&pCtl->lock); 6246 } 6247 return rc; 6248 } 6249 6208 6250 6209 6251 /** … … 7254 7296 PPDMIBASE pBase; 7255 7297 int rc; 7256 bool f GCEnabled;7298 bool fRCEnabled; 7257 7299 bool fR0Enabled; 7258 7300 uint32_t DelayIRQMillies; … … 7283 7325 N_("PIIX3 configuration error: unknown option specified")); 7284 7326 7285 rc = CFGMR3QueryBoolDef(pCfg, "GCEnabled", &f GCEnabled, true);7327 rc = CFGMR3QueryBoolDef(pCfg, "GCEnabled", &fRCEnabled, true); 7286 7328 if (RT_FAILURE(rc)) 7287 7329 return PDMDEV_SET_ERROR(pDevIns, rc, 7288 7330 N_("PIIX3 configuration error: failed to read GCEnabled as boolean")); 7289 Log(("%s: f GCEnabled=%d\n", __FUNCTION__, fGCEnabled));7331 Log(("%s: fRCEnabled=%d\n", __FUNCTION__, fRCEnabled)); 7290 7332 7291 7333 rc = CFGMR3QueryBoolDef(pCfg, "R0Enabled", &fR0Enabled, true); … … 7364 7406 7365 7407 pThis->pDevIns = pDevIns; 7366 pThis->f GCEnabled = fGCEnabled;7408 pThis->fRCEnabled = fRCEnabled; 7367 7409 pThis->fR0Enabled = fR0Enabled; 7368 7410 for (uint32_t i = 0; i < RT_ELEMENTS(pThis->aCts); i++) … … 7426 7468 for (uint32_t i = 0; i < RT_ELEMENTS(pThis->aCts); i++) 7427 7469 { 7428 rc = PDMDevHlpIOPortRegister(pDevIns, pThis->aCts[i].IOPortBase1, 8, (RTHCPTR)(uintptr_t)i, 7429 ataIOPortWrite1, ataIOPortRead1, 7430 ataIOPortWriteStr1, ataIOPortReadStr1, 7431 "ATA I/O Base 1"); 7432 if (RT_FAILURE(rc)) 7433 return PDMDEV_SET_ERROR(pDevIns, rc, N_("PIIX3 cannot register I/O handlers")); 7434 7435 if (fGCEnabled) 7436 { 7437 rc = PDMDevHlpIOPortRegisterRC(pDevIns, pThis->aCts[i].IOPortBase1, 8, (RTGCPTR)i, 7438 "ataIOPortWrite1", "ataIOPortRead1", 7439 "ataIOPortWriteStr1", "ataIOPortReadStr1", 7440 "ATA I/O Base 1"); 7441 if (RT_FAILURE(rc)) 7442 return PDMDEV_SET_ERROR(pDevIns, rc, N_("PIIX3 cannot register I/O handlers (GC)")); 7470 rc = PDMDevHlpIOPortRegister(pDevIns, pThis->aCts[i].IOPortBase1, 1, (RTHCPTR)(uintptr_t)i, 7471 ataIOPortWrite1Data, ataIOPortRead1Data, 7472 ataIOPortWriteStr1Data, ataIOPortReadStr1Data, "ATA I/O Base 1 - Data"); 7473 AssertLogRelRCReturn(rc, rc); 7474 rc = PDMDevHlpIOPortRegister(pDevIns, pThis->aCts[i].IOPortBase1 + 1, 7, (RTHCPTR)(uintptr_t)i, 7475 ataIOPortWrite1Other, ataIOPortRead1Other, NULL, NULL, "ATA I/O Base 1 - Other"); 7476 7477 AssertLogRelRCReturn(rc, rc); 7478 if (fRCEnabled) 7479 { 7480 rc = PDMDevHlpIOPortRegisterRC(pDevIns, pThis->aCts[i].IOPortBase1, 1, (RTGCPTR)i, 7481 "ataIOPortWrite1Data", "ataIOPortRead1Data", 7482 "ataIOPortWriteStr1Data", "ataIOPortReadStr1Data", "ATA I/O Base 1 - Data"); 7483 AssertLogRelRCReturn(rc, rc); 7484 rc = PDMDevHlpIOPortRegisterRC(pDevIns, pThis->aCts[i].IOPortBase1 + 1, 7, (RTGCPTR)i, 7485 "ataIOPortWrite1Other", "ataIOPortRead1Other", NULL, NULL, "ATA I/O Base 1 - Other"); 7486 AssertLogRelRCReturn(rc, rc); 7443 7487 } 7444 7488 … … 7446 7490 { 7447 7491 #if 1 7448 rc = PDMDevHlpIOPortRegisterR0(pDevIns, pThis->aCts[i].IOPortBase1, 8, (RTR0PTR)i,7449 "ataIOPortWrite1 ", "ataIOPortRead1", NULL, NULL, "ATA I/O Base 1");7492 rc = PDMDevHlpIOPortRegisterR0(pDevIns, pThis->aCts[i].IOPortBase1, 1, (RTR0PTR)i, 7493 "ataIOPortWrite1Data", "ataIOPortRead1Data", NULL, NULL, "ATA I/O Base 1 - Data"); 7450 7494 #else 7451 rc = PDMDevHlpIOPortRegisterR0(pDevIns, pThis->aCts[i].IOPortBase1, 8, (RTR0PTR)i, 7452 "ataIOPortWrite1", "ataIOPortRead1", "ataIOPortWriteStr1", "ataIOPortReadStr1", "ATA I/O Base 1"); 7495 rc = PDMDevHlpIOPortRegisterR0(pDevIns, pThis->aCts[i].IOPortBase1, 1, (RTR0PTR)i, 7496 "ataIOPortWrite1Data", "ataIOPortRead1Data", 7497 "ataIOPortWriteStr1Data", "ataIOPortReadStr1Data", "ATA I/O Base 1 - Data"); 7453 7498 #endif 7454 if (RT_FAILURE(rc)) 7455 return PDMDEV_SET_ERROR(pDevIns, rc, "PIIX3 cannot register I/O handlers (R0)."); 7499 AssertLogRelRCReturn(rc, rc); 7500 rc = PDMDevHlpIOPortRegisterR0(pDevIns, pThis->aCts[i].IOPortBase1 + 1, 7, (RTR0PTR)i, 7501 "ataIOPortWrite1Other", "ataIOPortRead1Other", NULL, NULL, "ATA I/O Base 1 - Other"); 7502 AssertLogRelRCReturn(rc, rc); 7456 7503 } 7457 7504 … … 7461 7508 return PDMDEV_SET_ERROR(pDevIns, rc, N_("PIIX3 cannot register base2 I/O handlers")); 7462 7509 7463 if (f GCEnabled)7510 if (fRCEnabled) 7464 7511 { 7465 7512 rc = PDMDevHlpIOPortRegisterRC(pDevIns, pThis->aCts[i].IOPortBase2, 1, (RTGCPTR)i,
Note:
See TracChangeset
for help on using the changeset viewer.