Changeset 44695 in vbox for trunk/src/VBox/Devices
- Timestamp:
- Feb 14, 2013 7:07:14 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Storage/DevLsiLogicSCSI.cpp
r44694 r44695 501 501 502 502 /* The interrupts are masked out. */ 503 pThis->uInterruptMask |= LSILOGIC_REG_HOST_INTR_MASK_DOORBELL |504 503 pThis->uInterruptMask |= LSILOGIC_REG_HOST_INTR_MASK_DOORBELL 504 | LSILOGIC_REG_HOST_INTR_MASK_REPLY; 505 505 /* Reset interrupt states. */ 506 506 pThis->uInterruptStatus = 0; … … 1194 1194 * @returns VBox status code. 1195 1195 * @param pThis Pointer to the LsiLogic device state. 1196 * @param uOffset Offset of the register to read. 1197 * @param pv Where to store the content of the register. 1198 * @param cb Number of bytes to read. 1199 */ 1200 static int lsilogicRegisterRead(PLSILOGICSCSI pThis, uint32_t uOffset, void *pv, unsigned cb) 1196 * @param offReg Offset of the register to read. 1197 * @param pu32 Where to store the content of the register. 1198 */ 1199 static int lsilogicRegisterRead(PLSILOGICSCSI pThis, uint32_t offReg, uint32_t *pu32) 1201 1200 { 1202 1201 int rc = VINF_SUCCESS; 1203 1202 uint32_t u32 = 0; 1203 Assert(!(offReg & 3)); 1204 1204 1205 1205 /* Align to a 4 byte offset. */ 1206 switch ( uOffset & ~3)1206 switch (offReg) 1207 1207 { 1208 1208 case LSILOGIC_REG_REPLY_QUEUE: 1209 1209 { 1210 /*1211 * Non 4-byte access may cause real strange behavior because the data is part of a physical guest address.1212 * But some drivers use 1-byte access to scan for SCSI controllers.1213 */1214 if (RT_UNLIKELY(cb != 4))1215 LogFlowFunc((": cb is not 4 (%u)\n", cb));1216 1217 1210 rc = PDMCritSectEnter(&pThis->ReplyPostQueueCritSect, VINF_IOM_R3_MMIO_READ); 1218 1211 if (rc != VINF_SUCCESS) … … 1289 1282 } 1290 1283 1291 /* Clip data according to the read size. */ 1292 switch (cb) 1293 { 1294 case 4: 1295 { 1296 *(uint32_t *)pv = u32; 1297 break; 1298 } 1299 case 2: 1300 { 1301 uint8_t uBitsOff = (uOffset - (uOffset & 3))*8; 1302 1303 u32 &= (0xffff << uBitsOff); 1304 *(uint16_t *)pv = (uint16_t)(u32 >> uBitsOff); 1305 break; 1306 } 1307 case 1: 1308 { 1309 uint8_t uBitsOff = (uOffset - (uOffset & 3))*8; 1310 1311 u32 &= (0xff << uBitsOff); 1312 *(uint8_t *)pv = (uint8_t)(u32 >> uBitsOff); 1313 break; 1314 } 1315 default: 1316 AssertMsgFailed(("Invalid access size %u\n", cb)); 1317 } 1318 1319 LogFlowFunc(("pThis=%#p uOffset=%#x pv=%#p{%.*Rhxs} cb=%u\n", pThis, uOffset, pv, cb, pv, cb)); 1320 1284 *pu32 = u32; 1285 LogFlowFunc(("pThis=%#p offReg=%#x u32=%#x\n", pThis, offReg, u32)); 1321 1286 return rc; 1322 1287 } … … 1337 1302 } 1338 1303 1339 PDMBOTHCBDECL(int) lsilogicIOPortRead (PPDMDEVINS pDevIns, void *pvUser, 1340 RTIOPORT Port, uint32_t *pu32, unsigned cb)1341 { 1342 PLSILOGICSCSI pThis = PDMINS_2_DATA(pDevIns, PLSILOGICSCSI); 1343 uint32_t uOffset = Port - pThis->IOPortBase; 1344 1345 Assert(cb <= 4);1346 1347 int rc = lsilogicRegisterRead(pThis, uOffset, pu32, cb);1304 /** 1305 * @callback_method_impl{FNIOMIOPORTIN} 1306 */ 1307 PDMBOTHCBDECL(int) lsilogicIOPortRead(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t *pu32, unsigned cb) 1308 { 1309 PLSILOGICSCSI pThis = PDMINS_2_DATA(pDevIns, PLSILOGICSCSI); 1310 uint32_t offReg = Port - pThis->IOPortBase; 1311 1312 int rc = lsilogicRegisterRead(pThis, offReg & ~(uint32_t)3, pu32); 1348 1313 if (rc == VINF_IOM_R3_MMIO_READ) 1349 1314 rc = VINF_IOM_R3_IOPORT_READ; … … 1361 1326 } 1362 1327 1363 PDMBOTHCBDECL(int) lsilogicMMIORead(PPDMDEVINS pDevIns, void *pvUser, 1364 RTGCPHYS GCPhysAddr, void *pv, unsigned cb) 1365 { 1366 PLSILOGICSCSI pThis = PDMINS_2_DATA(pDevIns, PLSILOGICSCSI); 1367 uint32_t uOffset = GCPhysAddr - pThis->GCPhysMMIOBase; 1368 1369 return lsilogicRegisterRead(pThis, uOffset, pv, cb); 1328 /** 1329 * @callback_method_impl{FNIOMMMIOREAD} 1330 */ 1331 PDMBOTHCBDECL(int) lsilogicMMIORead(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS GCPhysAddr, void *pv, unsigned cb) 1332 { 1333 PLSILOGICSCSI pThis = PDMINS_2_DATA(pDevIns, PLSILOGICSCSI); 1334 uint32_t offReg = GCPhysAddr - pThis->GCPhysMMIOBase; 1335 Assert(!(offReg & 3)); Assert(cb == 4); 1336 1337 return lsilogicRegisterRead(pThis, offReg, (uint32_t *)pv); 1370 1338 } 1371 1339 … … 3847 3815 ("PCI region type and size do not match\n")); 3848 3816 3849 if ((enmType == PCI_ADDRESS_SPACE_MEM) && (iRegion == 1)) 3850 { 3851 /* We use the assigned size here, because we currently only support page aligned MMIO ranges. */ 3817 if (enmType == PCI_ADDRESS_SPACE_MEM && iRegion == 1) 3818 { 3819 /* 3820 * Non-4-byte access to LSILOGIC_REG_REPLY_QUEUE may cause real strange 3821 * behavior because the data is part of a physical guest address. But 3822 * some drivers use 1-byte access to scan for SCSI controllers. So, we 3823 * simplify our code by telling IOM to read DWORDs. 3824 */ 3852 3825 rc = PDMDevHlpMMIORegister(pDevIns, GCPhysAddress, cb, NULL /*pvUser*/, 3853 IOMMMIO_FLAGS_READ_ PASSTHRU| IOMMMIO_FLAGS_WRITE_PASSTHRU,3826 IOMMMIO_FLAGS_READ_DWORD | IOMMMIO_FLAGS_WRITE_PASSTHRU, 3854 3827 lsilogicMMIOWrite, lsilogicMMIORead, pcszCtrl); 3855 3828 if (RT_FAILURE(rc)) … … 4956 4929 { 4957 4930 PLSILOGICSCSI pThis = PDMINS_2_DATA(pDevIns, PLSILOGICSCSI); 4958 int rc = VINF_SUCCESS; 4959 char szDevTag[20]; 4931 int rc = VINF_SUCCESS; 4960 4932 PDMDEV_CHECK_VERSIONS_RETURN(pDevIns); 4961 4933 … … 5017 4989 MMR3HeapFree(pszCtrlType); 5018 4990 4991 char szDevTag[20]; 5019 4992 RTStrPrintf(szDevTag, sizeof(szDevTag), "LSILOGIC%s-%u", 5020 4993 pThis->enmCtrlType == LSILOGICCTRLTYPE_SCSI_SPI ? "SPI" : "SAS", … … 5081 5054 pThis->IBase.pfnQueryInterface = lsilogicR3StatusQueryInterface; 5082 5055 pThis->ILeds.pfnQueryStatusLed = lsilogicR3StatusQueryStatusLed; 5056 5057 /* 5058 * Create critical sections protecting the reply post and free queues. 5059 */ 5060 rc = PDMDevHlpCritSectInit(pDevIns, &pThis->ReplyFreeQueueCritSect, RT_SRC_POS, "%sRFQ", szDevTag); 5061 if (RT_FAILURE(rc)) 5062 return PDMDEV_SET_ERROR(pDevIns, rc, N_("LsiLogic: cannot create critical section for reply free queue")); 5063 5064 rc = PDMDevHlpCritSectInit(pDevIns, &pThis->ReplyPostQueueCritSect, RT_SRC_POS, "%sRPQ", szDevTag); 5065 if (RT_FAILURE(rc)) 5066 return PDMDEV_SET_ERROR(pDevIns, rc, N_("LsiLogic: cannot create critical section for reply post queue")); 5083 5067 5084 5068 /* … … 5150 5134 5151 5135 /* 5152 * Create critical sections protecting the reply post and free queues.5153 */5154 rc = PDMDevHlpCritSectInit(pDevIns, &pThis->ReplyFreeQueueCritSect, RT_SRC_POS, "%sRFQ", szDevTag);5155 if (RT_FAILURE(rc))5156 return PDMDEV_SET_ERROR(pDevIns, rc,5157 N_("LsiLogic: cannot create critical section for reply free queue"));5158 5159 rc = PDMDevHlpCritSectInit(pDevIns, &pThis->ReplyPostQueueCritSect, RT_SRC_POS, "%sRPQ", szDevTag);5160 if (RT_FAILURE(rc))5161 return PDMDEV_SET_ERROR(pDevIns, rc,5162 N_("LsiLogic: cannot create critical section for reply post queue"));5163 5164 /*5165 5136 * Allocate task cache. 5166 5137 */ … … 5168 5139 lsilogicR3TaskStateCtor, lsilogicR3TaskStateDtor, NULL, 0); 5169 5140 if (RT_FAILURE(rc)) 5170 return PDMDEV_SET_ERROR(pDevIns, rc, 5171 N_("Cannot create task cache")); 5141 return PDMDEV_SET_ERROR(pDevIns, rc, N_("Cannot create task cache")); 5172 5142 5173 5143 if (pThis->enmCtrlType == LSILOGICCTRLTYPE_SCSI_SPI) … … 5183 5153 pThis->paDeviceStates = (PLSILOGICDEVICE)RTMemAllocZ(sizeof(LSILOGICDEVICE) * pThis->cDeviceStates); 5184 5154 if (!pThis->paDeviceStates) 5185 return PDMDEV_SET_ERROR(pDevIns, rc, 5186 N_("Failed to allocate memory for device states")); 5155 return PDMDEV_SET_ERROR(pDevIns, rc, N_("Failed to allocate memory for device states")); 5187 5156 5188 5157 for (unsigned i = 0; i < pThis->cDeviceStates; i++) … … 5200 5169 pDevice->ILed.pfnQueryStatusLed = lsilogicR3DeviceQueryStatusLed; 5201 5170 5202 RTStrPrintf(szName, sizeof(szName), "Device% d", i);5171 RTStrPrintf(szName, sizeof(szName), "Device%u", i); 5203 5172 5204 5173 /* Attach SCSI driver. */ … … 5277 5246 */ 5278 5247 char szTmp[128]; 5279 RTStrPrintf(szTmp, sizeof(szTmp), "%s% d", pDevIns->pReg->szName, pDevIns->iInstance);5248 RTStrPrintf(szTmp, sizeof(szTmp), "%s%u", pDevIns->pReg->szName, pDevIns->iInstance); 5280 5249 PDMDevHlpDBGFInfoRegister(pDevIns, szTmp, 5281 5250 pThis->enmCtrlType == LSILOGICCTRLTYPE_SCSI_SPI
Note:
See TracChangeset
for help on using the changeset viewer.