VirtualBox

Changeset 80148 in vbox for trunk/src/VBox/Devices/Storage


Ignore:
Timestamp:
Aug 6, 2019 6:36:58 AM (6 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
132589
Message:

Changed how MMIO items are accessed, simplified and fixed PCI CFG CAPs, finished host side Virtio library callbacks implemented, and starting toget device specific configuration negotiation (see #9440, Comment 41

File:
1 edited

Legend:

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

    r80108 r80148  
    6767 */
    6868
     69#define MATCH_SCSI_CONFIG(member) \
     70    ((int)uOffset >= RT_OFFSETOF(VIRTIO_SCSI_CONFIG_T, member) \
     71        &&  uOffset < (uint32_t)(RT_OFFSETOF(VIRTIO_SCSI_CONFIG_T, member) \
     72                               + RT_SIZEOFMEMB(VIRTIO_SCSI_CONFIG_T, member)) \
     73        &&   cb <= RT_SIZEOFMEMB(VIRTIO_SCSI_CONFIG_T, member) \
     74                  - (uOffset - RT_OFFSETOF(VIRTIO_SCSI_CONFIG_T, member)))
     75
     76#define LOG_ACCESSOR(member) \
     77        LogFunc(("Guest %s %s [%d:%d]: %.*Rhxs\n", \
     78                  fWrite ? "wrote" : "read ", #member,  mOffset, mOffset + cb, cb, pv));
     79
     80#define SCSI_CONFIG_ACCESSOR(member) \
     81    { \
     82        uint32_t mOffset = uOffset - RT_OFFSETOF(VIRTIO_SCSI_CONFIG_T, member); \
     83        if (fWrite) \
     84            memcpy(((char *)&pThis->virtioScsiConfig.member) + uOffset, (const char *)pv, cb); \
     85        else \
     86            memcpy((char *)pv, (const char *)(((char *)&pThis->virtioScsiConfig.member) + uOffset), cb); \
     87        LOG_ACCESSOR(member); \
     88    }
     89
     90#define SCSI_CONFIG_ACCESSOR_READONLY(member) \
     91    { \
     92        uint32_t mOffset = uOffset - RT_OFFSETOF(VIRTIO_SCSI_CONFIG_T, member); \
     93        if (fWrite) \
     94            LogFunc(("Guest attempted to write readonly virtio_pci_common_cfg.%s\n", #member)); \
     95        else \
     96        { \
     97            memcpy((char *)pv, (const char *)(((char *)&pThis->virtioScsiConfig.member) + uOffset), cb); \
     98            LOG_ACCESSOR(member); \
     99        } \
     100    }
     101
     102
    69103/** @name VirtIO 1.0 SCSI Host feature bits
    70104 * @{  */
     
    83117                                                    | VIRTIOSCSI_F_T10_PI  \
    84118
    85 typedef struct VIRTIO_PCI_DEV_CAP_T
    86 {
    87     uint32_t    uTestField1;
    88     uint32_t    uTestField2;
    89 } VIRTIO_PCI_DEV_CAP_T, *PVIRTIO_PCI_DEV_CAP_T;
     119typedef struct virtio_scsi_config
     120{
     121    uint32_t uNumQueues;                                    /** num_queues */
     122    uint32_t uSegMax;                                       /** seg_max */
     123    uint32_t uMaxSectors;                                   /** max_sectors */
     124    uint32_t uCmdPerLun;                                    /** cmd_per_lun */
     125    uint32_t uEventInfoSize;                                /** event_info_size */
     126    uint32_t uSenseSize;                                    /** sense_size */
     127    uint32_t uCdbSize;                                      /** cdb_size */
     128    uint16_t uMaxChannel;                                   /** max_channel */
     129    uint16_t uMaxTarget;                                    /** max_target */
     130    uint32_t uMaxLun;                                       /** max_lun */
     131} VIRTIO_SCSI_CONFIG_T, PVIRTIO_SCSI_CONFIG_T;
     132
     133#define CDB_SIZE                                    1      /* logic tbd */
     134#define SENSE_SIZE                                  1      /* logic tbd */
     135#define PI_BYTES_OUT                                1      /* logic tbd */
     136#define PI_BYTES_IN                                 1      /* logic tbd */
     137#define DATA_OUT                                    1      /* logic tbd */
     138typedef struct virtio_scsi_req_cmd
     139{
     140    /* Device-readable part */
     141    uint8_t  uLUN[8];                                       /** lun               */
     142    uint64_t uId;                                           /** id                */
     143    uint8_t  uTaskAttr;                                     /** task_attr         */
     144    uint8_t  uPrio;                                         /** prio              */
     145    uint8_t  uCrn;                                          /** crn               */
     146    uint8_t  uCdb[CDB_SIZE];                                /** cdb               */
     147
     148    /** Following three fields only present if VIRTIOSCSI_F_T10_PI negotiated */
     149
     150    uint32_t uPiBytesOut;                                   /** pi_bytesout       */
     151    uint32_t uPiBytesIn;                                    /** pi_bytesin        */
     152    uint8_t  uPiOut[PI_BYTES_OUT];                          /** pi_out[]          */
     153
     154    uint8_t  uDataOut[DATA_OUT];                            /** dataout           */
     155
     156    /* Device-writable part */
     157    uint32_t uSenseLen;                                     /** sense_len         */
     158    uint32_t uResidual;                                     /** residual          */
     159    uint16_t uStatusQualifier;                              /** status_qualifier  */
     160    uint8_t  uStatus;                                       /** status            */
     161    uint8_t  uResponse;                                     /** response          */
     162    uint8_t  uSense[SENSE_SIZE];                            /** sense             */
     163
     164    /** Following two fields only present if VIRTIOSCSI_F_T10_PI negotiated */
     165    uint8_t  uPiIn[PI_BYTES_IN];                            /** pi_in[]           */
     166    uint8_t  uDataIn[];                                     /** detain;           */
     167} VIRTIO_SCSI_REQ_CMD_T, *PVIRTIO_SCSI_REQ_CMD_T;
     168
     169/** Command-specific response values */
     170#define VIRTIOSCSI_S_OK                            0       /* control, command   */
     171#define VIRTIOSCSI_S_OVERRUN                       1       /* control */
     172#define VIRTIOSCSI_S_ABORTED                       2       /* control */
     173#define VIRTIOSCSI_S_BAD_TARGET                    3       /* control, command */
     174#define VIRTIOSCSI_S_RESET                         4       /* control */
     175#define VIRTIOSCSI_S_BUSY                          5       /* control, command */
     176#define VIRTIOSCSI_S_TRANSPORT_FAILURE             6       /* control, command */
     177#define VIRTIOSCSI_S_TARGET_FAILURE                7       /* control, command */
     178#define VIRTIOSCSI_S_NEXUS_FAILURE                 8       /* control, command */
     179#define VIRTIOSCSI_S_FAILURE                       9       /* control, command */
     180#define VIRTIOSCSI_S_INCORRECT_LUN                12       /* command */
     181
     182
     183/** task_attr */
     184#define VIRTIOSCSI_S_SIMPLE                        0
     185#define VIRTIOSCSI_S_ORDERED                       1
     186#define VIRTIOSCSI_S_HEAD                          2
     187#define VIRTIOSCSI_S_ACA                           3
     188
     189#define VIRTIOSCSI_T_TMF                           0
     190#define VIRTIOSCSI_T_TMF_ABORT_TASK                0
     191#define VIRTIOSCSI_T_TMF_ABORT_TASK_SET            1
     192#define VIRTIOSCSI_T_TMF_CLEAR_ACA                 2
     193#define VIRTIOSCSI_T_TMF_CLEAR_TASK_SET            3
     194#define VIRTIOSCSI_T_TMF_I_T_NEXUS_RESET           4
     195#define VIRTIOSCSI_T_TMF_LOGICAL_UNIT_RESET        5
     196#define VIRTIOSCSI_T_TMF_QUERY_TASK                6
     197#define VIRTIOSCSI_T_TMF_QUERY_TASK_SET            7
     198
     199typedef struct virtio_scsi_ctrl_tmf
     200{
     201     // Device-readable part
     202    uint32_t uType;                                          /** type           */
     203    uint32_t uSubtype;                                       /** subtype        */
     204    uint8_t  uLUN[8];                                        /** lun            */
     205    uint64_t uId;                                            /** id             */
     206    // Device-writable part
     207    uint8_t  uResponse;                                      /** response       */
     208} VIRTIO_SCSI_CTRL_BUF_T, *PVIRTIO_SCSI_CTRL_BUF_T;
     209
     210/* command-specific response values */
     211
     212#define VIRTIOSCSI_S_FUNCTION_COMPLETE            0
     213#define VIRTIOSCSI_S_FUNCTION_SUCCEEDED           10
     214#define VIRTIOSCSI_S_FUNCTION_REJECTED            11
     215
     216#define VIRTIOSCSI_T_AN_QUERY                     1         /** Asynchronous notification query */
     217#define VIRTIOSCSI_T_AN_SUBSCRIBE                 2         /** Asynchronous notification subscription */
     218
     219typedef struct virtio_scsi_ctrl_an
     220{
     221    // Device-readable part
     222    uint32_t  uType;                                         /** type            */
     223    uint8_t   uLUN[8];                                       /** lun             */
     224    uint32_t  uEventRequested;                               /** event_requested */
     225    // Device-writable part
     226    uint32_t  uEventActual;                                  /** event_actual    */
     227    uint8_t   uResponse;                                     /** response        */
     228}  VIRTIO_SCSI_CTRL_AN, *PVIRTIO_SCSI_CTRL_AN_T;
     229
     230#define VIRTIOSCSI_EVT_ASYNC_OPERATIONAL_CHANGE  2
     231#define VIRTIOSCSI_EVT_ASYNC_POWER_MGMT          4
     232#define VIRTIOSCSI_EVT_ASYNC_EXTERNAL_REQUEST    8
     233#define VIRTIOSCSI_EVT_ASYNC_MEDIA_CHANGE        16
     234#define VIRTIOSCSI_EVT_ASYNC_MULTI_HOST          32
     235#define VIRTIOSCSI_EVT_ASYNC_DEVICE_BUSY         64
     236
     237/** Device operation: controlq */
     238
     239typedef struct virtio_scsi_ctrl
     240{
     241    uint32_t type;                                           /** type            */
     242    uint8_t  response;                                       /** response        */
     243} VIRTIO_SCSI_CTRL_T, *PVIRTIO_SCSI_CTRL_T;
     244
     245#define VIRTIOSCSI_T_NO_EVENT                   0
     246
     247#define VIRTIOSCSI_T_TRANSPORT_RESET            1
     248#define VIRTIOSCSI_T_ASYNC_NOTIFY               2           /** Asynchronous notification */
     249#define VIRTIOSCSI_T_PARAM_CHANGE               3
     250
     251#define VIRTIOSCSI_EVT_RESET_HARD               0
     252#define VIRTIOSCSI_EVT_RESET_RESCAN             1
     253#define VIRTIOSCSI_EVT_RESET_REMOVED            2
     254
     255/** Device operation: eventq */
     256
     257#define VIRTIOSCSI_T_EVENTS_MISSED             0x80000000
     258typedef struct virtio_scsi_event {
     259    // Device-writable part
     260    uint32_t uEvent;                                         /** event:          */
     261    uint8_t  uLUN[8];                                        /** lun             */
     262    uint32_t uReason;                                        /** reason          */
     263} VIRTIO_SCSI_EVENT_T, *PVIRTIO_SCSI_EVENT_T;
    90264
    91265/**
     
    149323    /* virtioState must be first member */
    150324    VIRTIOSTATE                     virtioState;
    151 
    152     VIRTIO_PCI_DEV_CAP_T            devSpecificCap;
    153325
    154326    /* SCSI target instances data */
     
    194366    /** True if PDMDevHlpAsyncNotificationCompleted should be called when port goes idle */
    195367    bool volatile                   fSignalIdle;
     368
     369    VIRTIO_SCSI_CONFIG_T            virtioScsiConfig;
    196370
    197371} VIRTIOSCSI, *PVIRTIOSCSI;
     
    221395} VIRTIOSCSIREQ;
    222396typedef struct VIRTIOSCSIREQ *PVIRTIOSCSIREQ;
    223 
    224 
    225 #define CDB_SIZE                                    1      /* logic tbd */
    226 #define SENSE_SIZE                                  1      /* logic tbd */
    227 #define PI_BYTES_OUT                                1      /* logic tbd */
    228 #define PI_BYTES_IN                                 1      /* logic tbd */
    229 #define DATA_OUT                                    1      /* logic tbd */
    230 typedef struct virtio_scsi_req_cmd
    231 {
    232     /* Device-readable part */
    233     uint8_t  uLUN[8];                                       /** lun               */
    234     uint64_t uId;                                           /** id                */
    235     uint8_t  uTaskAttr;                                     /** task_attr         */
    236     uint8_t  uPrio;                                         /** prio              */
    237     uint8_t  uCrn;                                          /** crn               */
    238     uint8_t  uCdb[CDB_SIZE];                                /** cdb               */
    239 
    240     /** Following three fields only present if VIRTIOSCSI_F_T10_PI negotiated */
    241 
    242     uint32_t uPiBytesOut;                                   /** pi_bytesout       */
    243     uint32_t uPiBytesIn;                                    /** pi_bytesin        */
    244     uint8_t  uPiOut[PI_BYTES_OUT];                          /** pi_out[]          */
    245 
    246     uint8_t  uDataOut[DATA_OUT];                            /** dataout           */
    247 
    248     /* Device-writable part */
    249     uint32_t uSenseLen;                                     /** sense_len         */
    250     uint32_t uResidual;                                     /** residual          */
    251     uint16_t uStatusQualifier;                              /** status_qualifier  */
    252     uint8_t  uStatus;                                       /** status            */
    253     uint8_t  uResponse;                                     /** response          */
    254     uint8_t  uSense[SENSE_SIZE];                            /** sense             */
    255 
    256     /** Following two fields only present if VIRTIOSCSI_F_T10_PI negotiated */
    257     uint8_t  uPiIn[PI_BYTES_IN];                            /** pi_in[]           */
    258     uint8_t  uDataIn[];                                     /** detain;           */
    259 } VIRTIOSCSIREQCMD, *PVIRTIOSCSIREQCMD;
    260 
    261 /** Command-specific response values */
    262 #define VIRTIOSCSI_S_OK                            0       /* control, command   */
    263 #define VIRTIOSCSI_S_OVERRUN                       1       /* control */
    264 #define VIRTIOSCSI_S_ABORTED                       2       /* control */
    265 #define VIRTIOSCSI_S_BAD_TARGET                    3       /* control, command */
    266 #define VIRTIOSCSI_S_RESET                         4       /* control */
    267 #define VIRTIOSCSI_S_BUSY                          5       /* control, command */
    268 #define VIRTIOSCSI_S_TRANSPORT_FAILURE             6       /* control, command */
    269 #define VIRTIOSCSI_S_TARGET_FAILURE                7       /* control, command */
    270 #define VIRTIOSCSI_S_NEXUS_FAILURE                 8       /* control, command */
    271 #define VIRTIOSCSI_S_FAILURE                       9       /* control, command */
    272 #define VIRTIOSCSI_S_INCORRECT_LUN                12       /* command */
    273 
    274 
    275 /** task_attr */
    276 #define VIRTIOSCSI_S_SIMPLE                        0
    277 #define VIRTIOSCSI_S_ORDERED                       1
    278 #define VIRTIOSCSI_S_HEAD                          2
    279 #define VIRTIOSCSI_S_ACA                           3
    280 
    281 #define VIRTIOSCSI_T_TMF                           0
    282 #define VIRTIOSCSI_T_TMF_ABORT_TASK                0
    283 #define VIRTIOSCSI_T_TMF_ABORT_TASK_SET            1
    284 #define VIRTIOSCSI_T_TMF_CLEAR_ACA                 2
    285 #define VIRTIOSCSI_T_TMF_CLEAR_TASK_SET            3
    286 #define VIRTIOSCSI_T_TMF_I_T_NEXUS_RESET           4
    287 #define VIRTIOSCSI_T_TMF_LOGICAL_UNIT_RESET        5
    288 #define VIRTIOSCSI_T_TMF_QUERY_TASK                6
    289 #define VIRTIOSCSI_T_TMF_QUERY_TASK_SET            7
    290 
    291 typedef struct virtio_scsi_ctrl_tmf
    292 {
    293      // Device-readable part
    294     uint32_t uType;                                          /** type           */
    295     uint32_t uSubtype;                                       /** subtype        */
    296     uint8_t  uLUN[8];                                        /** lun            */
    297     uint64_t uId;                                            /** id             */
    298     // Device-writable part
    299     uint8_t  uResponse;                                      /** response       */
    300 } VIRTIOSCSICTRLBUF, *PVIRTIOSCSICTRLBUF;
    301 
    302 /* command-specific response values */
    303 
    304 #define VIRTIOSCSI_S_FUNCTION_COMPLETE            0
    305 #define VIRTIOSCSI_S_FUNCTION_SUCCEEDED           10
    306 #define VIRTIOSCSI_S_FUNCTION_REJECTED            11
    307 
    308 #define VIRTIOSCSI_T_AN_QUERY                     1         /** Asynchronous notification query */
    309 #define VIRTIOSCSI_T_AN_SUBSCRIBE                 2         /** Asynchronous notification subscription */
    310 
    311 typedef struct virtio_scsi_ctrl_an
    312 {
    313     // Device-readable part
    314     uint32_t  uType;                                         /** type            */
    315     uint8_t   uLUN[8];                                       /** lun             */
    316     uint32_t  uEventRequested;                               /** event_requested */
    317     // Device-writable part
    318     uint32_t  uEventActual;                                  /** event_actual    */
    319     uint8_t   uResponse;                                     /** response        */
    320 }  VIRTIOSCSICTRLAN, *PVIRTIOSCSICTRLAN;
    321 
    322 #define VIRTIOSCSI_EVT_ASYNC_OPERATIONAL_CHANGE  2
    323 #define VIRTIOSCSI_EVT_ASYNC_POWER_MGMT          4
    324 #define VIRTIOSCSI_EVT_ASYNC_EXTERNAL_REQUEST    8
    325 #define VIRTIOSCSI_EVT_ASYNC_MEDIA_CHANGE        16
    326 #define VIRTIOSCSI_EVT_ASYNC_MULTI_HOST          32
    327 #define VIRTIOSCSI_EVT_ASYNC_DEVICE_BUSY         64
    328 
    329 /** Device operation: controlq */
    330 
    331 typedef struct virtio_scsi_ctrl
    332 {
    333     uint32_t type;                                           /** type            */
    334     uint8_t  response;                                       /** response        */
    335 } VIRTIOSCSICTRL, *PVIRTIOSCSICTRL;
    336 
    337 #define VIRTIOSCSI_T_NO_EVENT                   0
    338 
    339 #define VIRTIOSCSI_T_TRANSPORT_RESET            1
    340 #define VIRTIOSCSI_T_ASYNC_NOTIFY               2           /** Asynchronous notification */
    341 #define VIRTIOSCSI_T_PARAM_CHANGE               3
    342 
    343 #define VIRTIOSCSI_EVT_RESET_HARD               0
    344 #define VIRTIOSCSI_EVT_RESET_RESCAN             1
    345 #define VIRTIOSCSI_EVT_RESET_REMOVED            2
    346 
    347 /** Device operation: eventq */
    348 
    349 #define VIRTIOSCSI_T_EVENTS_MISSED             0x80000000
    350 typedef struct virtio_scsi_event {
    351     // Device-writable part
    352     uint32_t uEvent;                                         /** event:          */
    353     uint8_t  uLUN[8];                                        /** lun             */
    354     uint32_t uReason;                                        /** reason          */
    355 } VIRTIOSCSIEVENT, *PVIRTIOSCSIEVENT;
    356 
    357 
    358397/*********************************************************************************************************************************/
    359398
     
    719758}
    720759
     760static int virtioScsiR3ConfigAccess(PVIRTIOSCSI pThis, uint32_t uOffset,
     761                                    const void *pv, size_t cb, uint8_t fWrite)
     762{
     763    int rc = VINF_SUCCESS;
     764    if (MATCH_SCSI_CONFIG(uNumQueues))
     765    {
     766        SCSI_CONFIG_ACCESSOR_READONLY(uNumQueues);
     767    }
     768    else
     769    if (MATCH_SCSI_CONFIG(uSegMax))
     770    {
     771        SCSI_CONFIG_ACCESSOR_READONLY(uSegMax);
     772    }
     773    else
     774    if (MATCH_SCSI_CONFIG(uMaxSectors))
     775    {
     776        SCSI_CONFIG_ACCESSOR_READONLY(uMaxSectors);
     777    }
     778    else
     779    if (MATCH_SCSI_CONFIG(uCmdPerLun))
     780    {
     781        SCSI_CONFIG_ACCESSOR_READONLY(uCmdPerLun);
     782    }
     783    else
     784    if (MATCH_SCSI_CONFIG(uEventInfoSize))
     785    {
     786        SCSI_CONFIG_ACCESSOR_READONLY(uEventInfoSize);
     787    }
     788    else
     789    if (MATCH_SCSI_CONFIG(uSenseSize))
     790    {
     791        SCSI_CONFIG_ACCESSOR(uSenseSize);
     792    }
     793    else
     794    if (MATCH_SCSI_CONFIG(uCdbSize))
     795    {
     796        SCSI_CONFIG_ACCESSOR(uCdbSize);
     797    }
     798    else
     799    if (MATCH_SCSI_CONFIG(uMaxChannel))
     800    {
     801        SCSI_CONFIG_ACCESSOR_READONLY(uMaxChannel);
     802    }
     803    else
     804    if (MATCH_SCSI_CONFIG(uMaxTarget))
     805    {
     806        SCSI_CONFIG_ACCESSOR_READONLY(uMaxTarget);
     807    }
     808    else
     809    if (MATCH_SCSI_CONFIG(uMaxLun))
     810    {
     811        SCSI_CONFIG_ACCESSOR_READONLY(uMaxLun);
     812    }
     813    else
     814    {
     815        LogFunc(("Bad access by guest to virtio_scsi_config: uoff=%d, cb=%d\n", uOffset, cb));
     816        rc = VERR_ACCESS_DENIED;
     817    }
     818    return rc;
     819}
     820
    721821/**
    722822 * virtio-scsi VirtIO Device-specific capabilities read callback
     
    724824 *
    725825 * @param   pDevIns     The device instance.
    726  * @param   GCPhysAddr  Guest driver physical address to read
     826 * @param   uOffset     Offset within device specific capabilities struct
    727827 * @param   pvBuf       Buffer in which to save read data
    728  * @param   cbRead      Number of bytes to read
    729  */
    730 static DECLCALLBACK(int) virtioScsiR3DevCapRead(PPDMDEVINS pDevIns, RTGCPHYS GCPhysAddr, const void *pvBuf, size_t cbRead)
    731 {
    732 /*TBD*/
    733     LogFunc(("Read from Device-Specific capabilities\n"));
    734     RT_NOREF(pDevIns);
    735     RT_NOREF(GCPhysAddr);
    736     RT_NOREF(pvBuf);
    737     RT_NOREF(cbRead);
    738     int rv = VINF_SUCCESS;
    739     return rv;
     828 * @param   cb          Number of bytes to read
     829 */
     830static DECLCALLBACK(int) virtioScsiR3DevCapRead(PPDMDEVINS pDevIns, uint32_t uOffset, const void *pv, size_t cb)
     831{
     832    int rc = VINF_SUCCESS;
     833    PVIRTIOSCSI  pThis = PDMINS_2_DATA(pDevIns, PVIRTIOSCSI);
     834
     835//    LogFunc(("Read from Device-Specific capabilities: uOffset: 0x%x, cb: 0x%x\n",
     836//              uOffset, cb));
     837
     838    rc = virtioScsiR3ConfigAccess(pThis, uOffset, pv, cb, false);
     839
     840    return rc;
    740841}
    741842
     
    745846 *
    746847 * @param   pDevIns     The device instance.
    747  * @param   GCPhysAddr  Guest driver physical address to write
     848 * @param   uOffset     Offset within device specific capabilities struct
    748849 * @param   pvBuf       Buffer in which to save read data
    749  * @param   cbWrite     Number of bytes to write
    750  */
    751 static DECLCALLBACK(int) virtioScsiR3DevCapWrite(PPDMDEVINS pDevIns, RTGCPHYS GCPhysAddr, const void *pvBuf, size_t cbWrite)
    752 {
    753 /*TBD*/
    754     LogFunc(("Write to Device-Specific capabilities\n"));
    755     RT_NOREF(pDevIns);
    756     RT_NOREF(GCPhysAddr);
    757     RT_NOREF(pvBuf);
    758     RT_NOREF(cbWrite);
    759     int rv = VINF_SUCCESS;
    760     return rv;
     850 * @param   cb          Number of bytes to write
     851 */
     852static DECLCALLBACK(int) virtioScsiR3DevCapWrite(PPDMDEVINS pDevIns, uint32_t uOffset, const void *pv, size_t cb)
     853{
     854    int rc = VINF_SUCCESS;
     855    PVIRTIOSCSI  pThis = PDMINS_2_DATA(pDevIns, PVIRTIOSCSI);
     856
     857//    LogFunc(("Write to Device-Specific capabilities: uOffset: 0x%x, cb: 0x%x\n",
     858//              uOffset, cb));
     859
     860    rc = virtioScsiR3ConfigAccess(pThis, uOffset, pv, cb, true);
     861
     862    return rc;
    761863}
    762864
     
    9351037    PVIRTIOSCSI  pThis = PDMINS_2_DATA(pDevIns, PVIRTIOSCSI);
    9361038    int  rc = VINF_SUCCESS;
    937     bool fBootable = true;
     1039    bool fBootable = false;
    9381040
    9391041    pThis->pDevInsR3 = pDevIns;
     
    9811083    pThis->IBase.pfnQueryInterface = virtioScsiR3DeviceQueryInterface;
    9821084
     1085    /* Configure virtio_scsi_config that transacts via VirtIO implementation's Dev. Specific Cap callbacks */
     1086    pThis->virtioScsiConfig.uNumQueues      = 3;    /* controlq, eventq, + n request queues*/
     1087    pThis->virtioScsiConfig.uSegMax         = 1024; /* initial guess */
     1088    pThis->virtioScsiConfig.uMaxSectors     = 0x10000;
     1089    pThis->virtioScsiConfig.uCmdPerLun      = 64;   /* initial guess */
     1090    pThis->virtioScsiConfig.uEventInfoSize  = 100;  /* VirtIO 1.0 spec says this should based on # of negotiated features */
     1091    pThis->virtioScsiConfig.uSenseSize      = 96;   /* from VirtIO 1.0 spec, must restore this on reset */
     1092    pThis->virtioScsiConfig.uCdbSize        = 32;   /* from VirtIO 1.0 spec, must restore this on reset */
     1093    pThis->virtioScsiConfig.uMaxChannel     = 0;    /* from VirtIO 1.0 spec */
     1094    pThis->virtioScsiConfig.uMaxTarget      = pThis->cTargets;
     1095    pThis->virtioScsiConfig.uMaxLun         = 16383; /* from VirtIO 1.0 spec */
     1096
    9831097    rc = virtioConstruct(pDevIns, pVirtio, iInstance, pVirtioPciParams,
    9841098                         VIRTIOSCSI_NAME_FMT, VIRTIOSCSI_N_QUEUES, VIRTIOSCSI_REGION_PCI_CAP,
    9851099                         virtioScsiR3DevCapRead, virtioScsiR3DevCapWrite,
    986                          sizeof(VIRTIO_PCI_DEV_CAP_T ) /* cbDevSpecificCap */,
    987                          false /* fHaveDevSpecificCap */, 0 /* uNotifyOffMultiplier */);
    988 
     1100                         sizeof(VIRTIO_SCSI_CONFIG_T) /* cbDevSpecificCap */,
     1101                         true /* fHaveDevSpecificCap */,
     1102                         0 /* uNotifyOffMultiplier */);
    9891103
    9901104    if (RT_FAILURE(rc))
    9911105        return PDMDEV_SET_ERROR(pDevIns, rc, N_("virtio-scsi: failed to initialize VirtIO"));
    992 
    9931106
    9941107    rc = PDMDevHlpPCIIORegionRegister(pDevIns, VIRTIOSCSI_REGION_MEM_IO, 32,
     
    10211134        PVIRTIOSCSITARGET pTarget = &pThis->aTargetInstances[iLUN];
    10221135
    1023         if (RTStrAPrintf(&pTarget->pszLunName, "vSCSI%u", iLUN) < 0)
     1136        if (RTStrAPrintf(&pTarget->pszLunName, "VSCSI%u", iLUN) < 0)
    10241137            AssertLogRelFailedReturn(VERR_NO_MEMORY);
    10251138
Note: See TracChangeset for help on using the changeset viewer.

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