VirtualBox

Changeset 79336 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Jun 25, 2019 5:26:10 PM (6 years ago)
Author:
vboxsync
Message:

Syncing code after adding PCI registration/memory mapping code (from DevBusLogic), and fixing up some log statements

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Storage/DevVirtioSCSI.cpp

    r79291 r79336  
    183183#endif
    184184
     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 */
     197PDMBOTHCBDECL(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 */
     218PDMBOTHCBDECL(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 */
     238PDMBOTHCBDECL(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 */
     265PDMBOTHCBDECL(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 */
     287static 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
    185360/**
    186361 * @copydoc FNPDMDEVRESET
     
    276451        return PDMDEV_SET_ERROR(pDevIns, rc,
    277452                                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));
    279454
    280455    rc = CFGMR3QueryBoolDef(pCfg, "R0Enabled", &pThis->fR0Enabled, true);
     
    282457        return PDMDEV_SET_ERROR(pDevIns, rc,
    283458                                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));
    285460
    286461    rc = CFGMR3QueryIntegerDef(pCfg, "NumTargets", &pThis->cTargets, true);
     
    288463        return PDMDEV_SET_ERROR(pDevIns, rc,
    289464                                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
     468LogFunc(("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);
    292482#if 0
    293483    if (fBootable)
     
    302492    }
    303493
    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;
    314494    pThis->pNotifierQueueR0 = PDMQueueR0Ptr(pThis->pNotifierQueueR3);
    315495    pThis->pNotifierQueueRC = PDMQueueRCPtr(pThis->pNotifierQueueR3);
     
    349529        pDevice->iLUN = i;
    350530        pDevice->pVirtioScsiR3 = pThis;
    351 Log(("Attaching: Lun=%d, pszName=%s\n",  pDevice->iLUN, pszName));
     531LogFunc(("Attaching: Lun=%d, pszName=%s\n",  pDevice->iLUN, pszName));
    352532        /* Attach SCSI driver. */
    353533        rc = PDMDevHlpDriverAttach(pDevIns, pDevice->iLUN, &pDevice->IBase, &pDevice->pDrvBase, pszName);
    354 Log(("rc=%d\n", rc));
    355534        if (RT_SUCCESS(rc))
    356535        {
     
    449628    int rc;
    450629
    451 LogFlowFunc(("iLun=%d"))
     630LogFlowFunc(("iLun=%d"));
    452631
    453632    AssertMsgReturn(fFlags & PDM_TACH_FLAGS_NOT_HOT_PLUG,
     
    529708
    530709}
     710
    531711
    532712/**
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette