Changeset 79336 in vbox for trunk/src/VBox
- Timestamp:
- Jun 25, 2019 5:26:10 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Storage/DevVirtioSCSI.cpp
r79291 r79336 183 183 #endif 184 184 185 186 /** 187 * Memory mapped I/O Handler for read operations. 188 * 189 * @returns VBox status code. 190 * 191 * @param pDevIns The device instance. 192 * @param pvUser User argument. 193 * @param GCPhysAddr Physical address (in GC) where the read starts. 194 * @param pv Where to store the result. 195 * @param cb Number of bytes read. 196 */ 197 PDMBOTHCBDECL(int) virtioScsiMMIORead(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS GCPhysAddr, void *pv, unsigned cb) 198 { 199 RT_NOREF_PV(pDevIns); RT_NOREF_PV(pvUser); RT_NOREF_PV(GCPhysAddr); RT_NOREF_PV(pv); RT_NOREF_PV(cb); 200 201 /* the linux driver does not make use of the MMIO area. */ 202 AssertMsgFailed(("MMIO Read\n")); 203 return VINF_SUCCESS; 204 } 205 206 207 /** 208 * Memory mapped I/O Handler for write operations. 209 * 210 * @returns VBox status code. 211 * 212 * @param pDevIns The device instance. 213 * @param pvUser User argument. 214 * @param GCPhysAddr Physical address (in GC) where the read starts. 215 * @param pv Where to fetch the result. 216 * @param cb Number of bytes to write. 217 */ 218 PDMBOTHCBDECL(int) virtioScsiMMIOWrite(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS GCPhysAddr, void const *pv, unsigned cb) 219 { 220 RT_NOREF_PV(pDevIns); RT_NOREF_PV(pvUser); RT_NOREF_PV(GCPhysAddr); RT_NOREF_PV(pv); RT_NOREF_PV(cb); 221 222 /* the linux driver does not make use of the MMIO area. */ 223 AssertMsgFailed(("MMIO Write\n")); 224 return VINF_SUCCESS; 225 } 226 227 /** 228 * Port I/O Handler for IN operations. 229 * 230 * @returns VBox status code. 231 * 232 * @param pDevIns The device instance. 233 * @param pvUser User argument. 234 * @param uPort Port number used for the IN operation. 235 * @param pu32 Where to store the result. 236 * @param cb Number of bytes read. 237 */ 238 PDMBOTHCBDECL(int) virtioScsiIOPortRead(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT uPort, uint32_t *pu32, unsigned cb) 239 { 240 // PVIRTIOSCSI pVirtioScsi = PDMINS_2_DATA(pDevIns, PVIRTIOSCSI); 241 unsigned iRegister = uPort % 4; 242 NOREF(iRegister); 243 NOREF(pDevIns); 244 NOREF(pu32); 245 RT_NOREF_PV(pvUser); RT_NOREF_PV(cb); 246 247 Assert(cb == 1); 248 249 // return buslogicRegisterRead(pBusLogic, iRegister, pu32); 250 return 0; 251 } 252 253 254 /** 255 * Port I/O Handler for OUT operations. 256 * 257 * @returns VBox status code. 258 * 259 * @param pDevIns The device instance. 260 * @param pvUser User argument. 261 * @param uPort Port number used for the IN operation. 262 * @param u32 The value to output. 263 * @param cb The value size in bytes. 264 */ 265 PDMBOTHCBDECL(int) virtioScsiIOPortWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT uPort, uint32_t u32, unsigned cb) 266 { 267 // PVIRTIOSCSI pVirtioScsi = PDMINS_2_DATA(pDevIns, PVIRTIOSCSI); 268 unsigned iRegister = uPort % 4; 269 uint8_t uVal = (uint8_t)u32; 270 NOREF(uVal); 271 NOREF(iRegister); 272 RT_NOREF2(pvUser, cb); 273 NOREF(u32); 274 275 Assert(cb == 1); 276 277 // int rc = buslogicRegisterWrite(pBusLogic, iRegister, (uint8_t)uVal); 278 int rc = 0; 279 Log2(("#%d %s: pvUser=%#p cb=%d u32=%#x uPort=%#x rc=%Rrc\n", 280 pDevIns->iInstance, __FUNCTION__, pvUser, cb, u32, uPort, rc)); 281 282 return rc; 283 } 284 /** 285 * @callback_method_impl{FNPCIIOREGIONMAP} 286 */ 287 static DECLCALLBACK(int) devVirtioScsiR3MmioMap(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, uint32_t iRegion, 288 RTGCPHYS GCPhysAddress, RTGCPHYS cb, PCIADDRESSSPACE enmType) 289 { 290 RT_NOREF(pPciDev, iRegion); 291 PVIRTIOSCSI pThis = PDMINS_2_DATA(pDevIns, PVIRTIOSCSI); 292 int rc = VINF_SUCCESS; 293 294 Log2(("%s: registering MMIO area at GCPhysAddr=%RGp cb=%RGp\n", __FUNCTION__, GCPhysAddress, cb)); 295 296 Assert(cb >= 32); 297 298 if (enmType == PCI_ADDRESS_SPACE_MEM) 299 { 300 /* We use the assigned size here, because we currently only support page aligned MMIO ranges. */ 301 rc = PDMDevHlpMMIORegister(pDevIns, GCPhysAddress, cb, NULL /*pvUser*/, 302 IOMMMIO_FLAGS_READ_PASSTHRU | IOMMMIO_FLAGS_WRITE_PASSTHRU, 303 virtioScsiMMIOWrite, virtioScsiMMIORead, "virtio-scsi MMIO"); 304 if (RT_FAILURE(rc)) 305 return rc; 306 307 if (pThis->fR0Enabled) 308 { 309 rc = PDMDevHlpMMIORegisterR0(pDevIns, GCPhysAddress, cb, NIL_RTR0PTR /*pvUser*/, 310 "virtioScsiMMIOWrite", "virtioScsiMMIORead"); 311 if (RT_FAILURE(rc)) 312 return rc; 313 } 314 315 if (pThis->fGCEnabled) 316 { 317 rc = PDMDevHlpMMIORegisterRC(pDevIns, GCPhysAddress, cb, NIL_RTRCPTR /*pvUser*/, 318 "virtioScsiMMIOWrite", "virtioScsiMMIORead"); 319 if (RT_FAILURE(rc)) 320 return rc; 321 } 322 323 pThis->MMIOBase = GCPhysAddress; 324 } 325 else if (enmType == PCI_ADDRESS_SPACE_IO) 326 { 327 rc = PDMDevHlpIOPortRegister(pDevIns, (RTIOPORT)GCPhysAddress, 32, 328 NULL, virtioScsiIOPortWrite, virtioScsiIOPortRead, NULL, NULL, "virtio-scsi PCI"); 329 if (RT_FAILURE(rc)) 330 return rc; 331 332 if (pThis->fR0Enabled) 333 { 334 rc = PDMDevHlpIOPortRegisterR0(pDevIns, (RTIOPORT)GCPhysAddress, 32, 335 0, "virtioScsiIOPortWrite", "virtioScsiIOPortRead", NULL, NULL, "virtio-scsi PCI"); 336 if (RT_FAILURE(rc)) 337 return rc; 338 } 339 340 if (pThis->fGCEnabled) 341 { 342 rc = PDMDevHlpIOPortRegisterRC(pDevIns, (RTIOPORT)GCPhysAddress, 32, 343 0, "virtioScsiIOPortWrite", "virtioScsiIOPortRead", NULL, NULL, "virtio-scsi PCI"); 344 if (RT_FAILURE(rc)) 345 return rc; 346 } 347 348 pThis->IOPortBase = (RTIOPORT)GCPhysAddress; 349 } 350 else 351 AssertMsgFailed(("Invalid enmType=%d\n", enmType)); 352 353 return rc; 354 } 355 356 357 358 359 185 360 /** 186 361 * @copydoc FNPDMDEVRESET … … 276 451 return PDMDEV_SET_ERROR(pDevIns, rc, 277 452 N_("virtio-scsi configuration error: failed to read GCEnabled as boolean")); 278 Log (("%s: fGCEnabled=%d\n", __FUNCTION__, pThis->fGCEnabled));453 LogFunc(("fGCEnabled=%d\n", pThis->fGCEnabled)); 279 454 280 455 rc = CFGMR3QueryBoolDef(pCfg, "R0Enabled", &pThis->fR0Enabled, true); … … 282 457 return PDMDEV_SET_ERROR(pDevIns, rc, 283 458 N_("virtio-scsi configuration error: failed to read R0Enabled as boolean")); 284 Log (("%s: fR0Enabled=%d\n", __FUNCTION__, pThis->fR0Enabled));459 LogFunc(("R0Enabled=%d\n", pThis->fGCEnabled)); 285 460 286 461 rc = CFGMR3QueryIntegerDef(pCfg, "NumTargets", &pThis->cTargets, true); … … 288 463 return PDMDEV_SET_ERROR(pDevIns, rc, 289 464 N_("virtio-scsi configuration error: failed to read NumTargets as integer")); 290 Log(("%s: fGCEnabled=%d\n", __FUNCTION__, pThis->fGCEnabled)); 291 465 LogFunc(("NumTargets=%d\n", pThis->fGCEnabled)); 466 467 468 LogFunc(("Register PCI device\n")); 469 470 rc = PDMDevHlpPCIRegister(pDevIns, &pThis->dev); 471 if (RT_FAILURE(rc)) 472 return PDMDEV_SET_ERROR(pDevIns, rc, N_("virtio-scsi cannot register with PCI bus")); 473 474 // rc = PDMDevHlpPCIIORegionRegister(pDevIns, 0, 32, PCI_ADDRESS_SPACE_IO, devVirtioScsiR3MmioMap); 475 // if (RT_FAILURE(rc)) 476 // return PDMDEV_SET_ERROR(pDevIns, rc, N_("virtio-scsi cannot register PCI I/O address space")); 477 478 // rc = PDMDevHlpPCIIORegionRegister(pDevIns, 1, 32, PCI_ADDRESS_SPACE_MEM, devVirtioScsiR3MmioMap); 479 // if (RT_FAILURE(rc)) 480 // return PDMDEV_SET_ERROR(pDevIns, rc, N_("virtio-scsi cannot register PCI mmio address space")); 481 NOREF(devVirtioScsiR3MmioMap); 292 482 #if 0 293 483 if (fBootable) … … 302 492 } 303 493 304 /* Set up the compatibility I/O range. */305 rc = virtioScsiR3RegisterISARange(pThis, pThis->uDefaultISABaseCode);306 if (RT_FAILURE(rc))307 return PDMDEV_SET_ERROR(pDevIns, rc, N_("virtio-scsi cannot register ISA I/O handlers"));308 309 /* Initialize task queue. */310 rc = PDMDevHlpQueueCreate(pDevIns, sizeof(PDMQUEUEITEMCORE), 5, 0,311 virtioScsiR3NotifyQueueConsumer, true, "virtio-scsiTask", &pThis->pNotifierQueueR3);312 if (RT_FAILURE(rc))313 return rc;314 494 pThis->pNotifierQueueR0 = PDMQueueR0Ptr(pThis->pNotifierQueueR3); 315 495 pThis->pNotifierQueueRC = PDMQueueRCPtr(pThis->pNotifierQueueR3); … … 349 529 pDevice->iLUN = i; 350 530 pDevice->pVirtioScsiR3 = pThis; 351 Log (("Attaching: Lun=%d, pszName=%s\n", pDevice->iLUN, pszName));531 LogFunc(("Attaching: Lun=%d, pszName=%s\n", pDevice->iLUN, pszName)); 352 532 /* Attach SCSI driver. */ 353 533 rc = PDMDevHlpDriverAttach(pDevIns, pDevice->iLUN, &pDevice->IBase, &pDevice->pDrvBase, pszName); 354 Log(("rc=%d\n", rc));355 534 if (RT_SUCCESS(rc)) 356 535 { … … 449 628 int rc; 450 629 451 LogFlowFunc(("iLun=%d")) 630 LogFlowFunc(("iLun=%d")); 452 631 453 632 AssertMsgReturn(fFlags & PDM_TACH_FLAGS_NOT_HOT_PLUG, … … 529 708 530 709 } 710 531 711 532 712 /**
Note:
See TracChangeset
for help on using the changeset viewer.