VirtualBox

Changeset 81678 in vbox


Ignore:
Timestamp:
Nov 5, 2019 4:58:45 PM (5 years ago)
Author:
vboxsync
Message:

Virtio_1_0,DevVirtioScsi: s/virtio/virtioCore/ + s/VIRTIOSTATE/VIRTIOCORE/. bugref:9218 bugref:9440

Location:
trunk/src/VBox/Devices
Files:
3 edited

Legend:

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

    r81677 r81678  
    420420 * VirtIO Host SCSI device state, shared edition.
    421421 *
    422  * @extends     VIRTIOSTATE
     422 * @extends     VIRTIOCORE
    423423 */
    424424typedef struct VIRTIOSCSI
    425425{
    426     /** The virtio state.   */
    427     VIRTIOSTATE                     Virtio;
     426    /** The core virtio state.   */
     427    VIRTIOCORE                      Virtio;
    428428
    429429    bool                            fBootable;
     
    492492 * VirtIO Host SCSI device state, ring-3 edition.
    493493 *
    494  * @extends     VIRTIOSTATER3
     494 * @extends     VIRTIOCORER3
    495495 */
    496496typedef struct VIRTIOSCSIR3
    497497{
    498     /** The virtio ring-3 state. */
    499     VIRTIOSTATER3                   Virtio;
     498    /** The core virtio ring-3 state. */
     499    VIRTIOCORER3                    Virtio;
    500500
    501501    /** Array of per-target data. */
     
    539539typedef struct VIRTIOSCSIR0
    540540{
    541     /** The virtio ring-0 state. */
    542     VIRTIOSTATER0                   Virtio;
     541    /** The core virtio ring-0 state. */
     542    VIRTIOCORER0                    Virtio;
    543543} VIRTIOSCSIR0;
    544544/** Pointer to the ring-0 state of the VirtIO Host SCSI device. */
     
    551551typedef struct VIRTIOSCSIRC
    552552{
    553     /** The virtio raw-mode state. */
    554     VIRTIOSTATERC                   Virtio;
     553    /** The core virtio raw-mode state. */
     554    VIRTIOCORERC                    Virtio;
    555555} VIRTIOSCSIRC;
    556556/** Pointer to the ring-0 state of the VirtIO Host SCSI device. */
     
    728728    }
    729729
    730     if (virtioQueueIsEmpty(pDevIns, &pThis->Virtio, EVENTQ_IDX))
     730    if (virtioCoreQueueIsEmpty(pDevIns, &pThis->Virtio, EVENTQ_IDX))
    731731    {
    732732        LogFunc(("eventq is empty, events missed (driver didn't preload queue)!\n"));
     
    736736
    737737    PVIRTIO_DESC_CHAIN_T pDescChain;
    738     virtioR3QueueGet(pDevIns, &pThis->Virtio, EVENTQ_IDX, &pDescChain, true);
     738    virtioCoreR3QueueGet(pDevIns, &pThis->Virtio, EVENTQ_IDX, &pDescChain, true);
    739739
    740740    RTSGBUF reqSegBuf;
     
    742742    RTSgBufInit(&reqSegBuf, aReqSegs, RT_ELEMENTS(aReqSegs));
    743743
    744     virtioR3QueuePut(pDevIns, &pThis->Virtio, EVENTQ_IDX, &reqSegBuf, pDescChain, true);
    745     virtioQueueSync(pDevIns, &pThis->Virtio, EVENTQ_IDX);
     744    virtioCoreR3QueuePut(pDevIns, &pThis->Virtio, EVENTQ_IDX, &reqSegBuf, pDescChain, true);
     745    virtioCoreQueueSync(pDevIns, &pThis->Virtio, EVENTQ_IDX);
    746746
    747747    return VINF_SUCCESS;
     
    794794        pRespHdr->uResponse = VIRTIOSCSI_S_RESET;
    795795
    796     virtioR3QueuePut(pDevIns, &pThis->Virtio, qIdx, &reqSegBuf, pDescChain, true /* fFence */);
    797     virtioQueueSync(pDevIns, &pThis->Virtio, qIdx);
     796    virtioCoreR3QueuePut(pDevIns, &pThis->Virtio, qIdx, &reqSegBuf, pDescChain, true /* fFence */);
     797    virtioCoreQueueSync(pDevIns, &pThis->Virtio, qIdx);
    798798
    799799    RTMemFree(pabSenseBuf);
     
    950950
    951951
    952         virtioR3QueuePut(pDevIns, &pThis->Virtio, pReq->qIdx, &reqSegBuf, pReq->pDescChain, true /* fFence TBD */);
    953         virtioQueueSync(pDevIns, &pThis->Virtio, pReq->qIdx);
     952        virtioCoreR3QueuePut(pDevIns, &pThis->Virtio, pReq->qIdx, &reqSegBuf, pReq->pDescChain, true /* fFence TBD */);
     953        virtioCoreQueueSync(pDevIns, &pThis->Virtio, pReq->qIdx);
    954954
    955955
     
    14901490
    14911491    LogFunc(("Response code: %s\n", virtioGetReqRespText(bResponse)));
    1492     virtioR3QueuePut(pDevIns, &pThis->Virtio, qIdx, &reqSegBuf, pDescChain, true);
    1493     virtioQueueSync(pDevIns, &pThis->Virtio, qIdx);
     1492    virtioCoreR3QueuePut(pDevIns, &pThis->Virtio, qIdx, &reqSegBuf, pDescChain, true);
     1493    virtioCoreQueueSync(pDevIns, &pThis->Virtio, qIdx);
    14941494
    14951495    return VINF_SUCCESS;
     
    15211521    while (pThread->enmState == PDMTHREADSTATE_RUNNING)
    15221522    {
    1523         if (virtioQueueIsEmpty(pDevIns, &pThis->Virtio, qIdx))
     1523        if (virtioCoreQueueIsEmpty(pDevIns, &pThis->Virtio, qIdx))
    15241524        {
    15251525            /* Atomic interlocks avoid missing alarm while going to sleep & notifier waking the awoken */
     
    15491549             Log6Func(("fetching next descriptor chain from %s\n", QUEUENAME(qIdx)));
    15501550             PVIRTIO_DESC_CHAIN_T pDescChain;
    1551              int rc = virtioR3QueueGet(pDevIns, &pThis->Virtio, qIdx, &pDescChain, true);
     1551             int rc = virtioCoreR3QueueGet(pDevIns, &pThis->Virtio, qIdx, &pDescChain, true);
    15521552             if (rc == VERR_NOT_AVAILABLE)
    15531553             {
     
    16561656 * @callback_method_impl{FNVIRTIOQUEUENOTIFIED}
    16571657 */
    1658 static DECLCALLBACK(void) virtioScsiR3Notified(PVIRTIOSTATE pVirtio, PVIRTIOSTATECC pVirtioCC, uint16_t qIdx)
     1658static DECLCALLBACK(void) virtioScsiR3Notified(PVIRTIOCORE pVirtio, PVIRTIOCORECC pVirtioCC, uint16_t qIdx)
    16591659{
    16601660    PVIRTIOSCSI         pThis     = RT_FROM_MEMBER(pVirtio, VIRTIOSCSI, Virtio);
     
    16941694 * @callback_method_impl{FNVIRTIOSTATUSCHANGED}
    16951695 */
    1696 static DECLCALLBACK(void) virtioScsiR3StatusChanged(PVIRTIOSTATE pVirtio, PVIRTIOSTATECC pVirtioCC, uint32_t fVirtioReady)
     1696static DECLCALLBACK(void) virtioScsiR3StatusChanged(PVIRTIOCORE pVirtio, PVIRTIOCORECC pVirtioCC, uint32_t fVirtioReady)
    16971697{
    16981698    PVIRTIOSCSI     pThis     = RT_FROM_MEMBER(pVirtio, VIRTIOSCSI, Virtio);
     
    17041704    {
    17051705        LogFunc(("VirtIO ready\n-----------------------------------------------------------------------------------------\n"));
    1706         uint64_t fFeatures   = virtioGetNegotiatedFeatures(&pThis->Virtio);
     1706        uint64_t fFeatures   = virtioCoreGetNegotiatedFeatures(&pThis->Virtio);
    17071707        pThis->fHasT10pi     = fFeatures & VIRTIO_SCSI_F_T10_PI;
    17081708        pThis->fHasHotplug   = fFeatures & VIRTIO_SCSI_F_HOTPLUG;
     
    18491849#ifdef LOG_ENABLED
    18501850# define LOG_SCSI_CONFIG_ACCESSOR(member) \
    1851         virtioLogMappedIoValue(__FUNCTION__, #member, RT_SIZEOFMEMB(VIRTIOSCSI_CONFIG_T, member), \
     1851        virtioCoreLogMappedIoValue(__FUNCTION__, #member, RT_SIZEOFMEMB(VIRTIOSCSI_CONFIG_T, member), \
    18521852                               pv, cb, offIntra, fWrite, false, 0);
    18531853#else
     
    20242024     * Call the virtio core to let it load its state.
    20252025     */
    2026     return virtioR3LoadExec(&pThis->Virtio, pDevIns->pHlpR3, pSSM);
     2026    return virtioCoreR3LoadExec(&pThis->Virtio, pDevIns->pHlpR3, pSSM);
    20272027}
    20282028
     
    20662066     * Call the virtio core to let it save its state.
    20672067     */
    2068     return virtioR3SaveExec(&pThis->Virtio, pDevIns->pHlpR3, pSSM);
     2068    return virtioCoreR3SaveExec(&pThis->Virtio, pDevIns->pHlpR3, pSSM);
    20692069}
    20702070
     
    21592159
    21602160    if (pThisCC->enmQuiescingFor == kvirtIoScsiQuiescingForReset)
    2161         virtioR3PropagateResetNotification(pDevIns, &pThis->Virtio);
     2161        virtioCoreR3PropagateResetNotification(pDevIns, &pThis->Virtio);
    21622162    /** @todo r=bird: Do we need other notifications here for suspend and/or poweroff? */
    21632163
     
    22552255
    22562256    /* Ensure guest is working the queues too. */
    2257     virtioR3PropagateResumeNotification(pDevIns, &pThis->Virtio);
     2257    virtioCoreR3PropagateResumeNotification(pDevIns, &pThis->Virtio);
    22582258}
    22592259
     
    22932293    }
    22942294
    2295     virtioR3Term(pDevIns, &pThis->Virtio, &pThisCC->Virtio);
     2295    virtioCoreR3Term(pDevIns, &pThis->Virtio, &pThisCC->Virtio);
    22962296    return VINF_SUCCESS;
    22972297}
     
    23562356
    23572357    /* Initialize the generic Virtio core: */
    2358     pThisCC->Virtio.Callbacks.pfnStatusChanged  = virtioScsiR3StatusChanged;
    2359     pThisCC->Virtio.Callbacks.pfnQueueNotified  = virtioScsiR3Notified;
    2360     pThisCC->Virtio.Callbacks.pfnDevCapRead     = virtioScsiR3DevCapRead;
    2361     pThisCC->Virtio.Callbacks.pfnDevCapWrite    = virtioScsiR3DevCapWrite;
     2358    pThisCC->Virtio.pfnStatusChanged        = virtioScsiR3StatusChanged;
     2359    pThisCC->Virtio.pfnQueueNotified        = virtioScsiR3Notified;
     2360    pThisCC->Virtio.pfnDevCapRead           = virtioScsiR3DevCapRead;
     2361    pThisCC->Virtio.pfnDevCapWrite          = virtioScsiR3DevCapWrite;
    23622362
    23632363    VIRTIOPCIPARAMS VirtioPciParams;
     
    23722372    VirtioPciParams.uInterruptPin       = 0x01;
    23732373
    2374     rc = virtioR3Init(pDevIns, &pThis->Virtio, &pThisCC->Virtio, &VirtioPciParams, pThis->szInstance,
    2375                       VIRTIOSCSI_HOST_SCSI_FEATURES_OFFERED,
    2376                       &pThis->virtioScsiConfig /*pvDevSpecificCap*/, sizeof(pThis->virtioScsiConfig));
    2377 
     2374    rc = virtioCoreR3Init(pDevIns, &pThis->Virtio, &pThisCC->Virtio, &VirtioPciParams, pThis->szInstance,
     2375                          VIRTIOSCSI_HOST_SCSI_FEATURES_OFFERED,
     2376                          &pThis->virtioScsiConfig /*pvDevSpecificCap*/, sizeof(pThis->virtioScsiConfig));
    23782377    if (RT_FAILURE(rc))
    23792378        return PDMDEV_SET_ERROR(pDevIns, rc, N_("virtio-scsi: failed to initialize VirtIO"));
     
    23932392    for (uint16_t qIdx = 0; qIdx < VIRTIOSCSI_QUEUE_CNT; qIdx++)
    23942393    {
    2395         rc = virtioR3QueueAttach(&pThis->Virtio, qIdx, QUEUENAME(qIdx));
     2394        rc = virtioCoreR3QueueAttach(&pThis->Virtio, qIdx, QUEUENAME(qIdx));
    23962395        pThis->afQueueAttached[qIdx] = (rc == VINF_SUCCESS); /** @todo r=bird: This looks a bit fishy, esp. giving the following. */
    23972396
     
    25362535    PVIRTIOSCSICC pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PVIRTIOSCSICC);
    25372536
    2538     return virtioRZInit(pDevIns, &pThis->Virtio, &pThisCC->Virtio);
     2537    return virtioCoreRZInit(pDevIns, &pThis->Virtio, &pThisCC->Virtio);
    25392538}
    25402539
  • trunk/src/VBox/Devices/VirtIO/Virtio_1_0.cpp

    r81677 r81678  
    108108*   Internal Functions                                                                                                           *
    109109*********************************************************************************************************************************/
    110 static void virtioNotifyGuestDriver(PPDMDEVINS pDevIns, PVIRTIOSTATE pVirtio, uint16_t idxQueue, bool fForce);
    111 static int  virtioKick(PPDMDEVINS pDevIns, PVIRTIOSTATE pVirtio, uint8_t uCause, uint16_t uVec, bool fForce);
     110static void virtioNotifyGuestDriver(PPDMDEVINS pDevIns, PVIRTIOCORE pVirtio, uint16_t idxQueue, bool fForce);
     111static int  virtioKick(PPDMDEVINS pDevIns, PVIRTIOCORE pVirtio, uint8_t uCause, uint16_t uVec, bool fForce);
    112112
    113113/** @name Internal queue operations
     
    124124 * Accessor for virtq descriptor
    125125 */
    126 DECLINLINE(void) virtioReadDesc(PPDMDEVINS pDevIns, PVIRTIOSTATE pVirtio, uint16_t idxQueue,
     126DECLINLINE(void) virtioReadDesc(PPDMDEVINS pDevIns, PVIRTIOCORE pVirtio, uint16_t idxQueue,
    127127                                uint32_t idxDesc, PVIRTQ_DESC_T pDesc)
    128128{
     
    138138 * Accessors for virtq avail ring
    139139 */
    140 DECLINLINE(uint16_t) virtioReadAvailDescIdx(PPDMDEVINS pDevIns, PVIRTIOSTATE pVirtio, uint16_t idxQueue, uint32_t availIdx)
     140DECLINLINE(uint16_t) virtioReadAvailDescIdx(PPDMDEVINS pDevIns, PVIRTIOCORE pVirtio, uint16_t idxQueue, uint32_t availIdx)
    141141{
    142142    uint16_t uDescIdx;
     
    150150}
    151151
    152 DECLINLINE(uint16_t) virtioReadAvailRingIdx(PPDMDEVINS pDevIns, PVIRTIOSTATE pVirtio, uint16_t idxQueue)
     152DECLINLINE(uint16_t) virtioReadAvailRingIdx(PPDMDEVINS pDevIns, PVIRTIOCORE pVirtio, uint16_t idxQueue)
    153153{
    154154    uint16_t uIdx = 0;
     
    160160}
    161161
    162 DECLINLINE(bool) virtqIsEmpty(PPDMDEVINS pDevIns, PVIRTIOSTATE pVirtio, uint16_t idxQueue)
     162DECLINLINE(bool) virtqIsEmpty(PPDMDEVINS pDevIns, PVIRTIOCORE pVirtio, uint16_t idxQueue)
    163163{
    164164    return virtioReadAvailRingIdx(pDevIns, pVirtio, idxQueue) == pVirtio->virtqState[idxQueue].uAvailIdx;
     
    166166
    167167#if 0 /* unused */
    168 DECLINLINE(uint16_t) virtioReadAvailFlags(PPDMDEVINS pDevIns, PVIRTIOSTATE pVirtio, uint16_t idxQueue)
     168DECLINLINE(uint16_t) virtioReadAvailFlags(PPDMDEVINS pDevIns, PVIRTIOCORE pVirtio, uint16_t idxQueue)
    169169{
    170170    uint16_t fFlags;
     
    177177#endif
    178178
    179 DECLINLINE(uint16_t) virtioReadAvailUsedEvent(PPDMDEVINS pDevIns, PVIRTIOSTATE pVirtio, uint16_t idxQueue)
     179DECLINLINE(uint16_t) virtioReadAvailUsedEvent(PPDMDEVINS pDevIns, PVIRTIOCORE pVirtio, uint16_t idxQueue)
    180180{
    181181    uint16_t uUsedEventIdx;
     
    192192 * @{
    193193 */
    194 DECLINLINE(void) virtioWriteUsedElem(PPDMDEVINS pDevIns, PVIRTIOSTATE pVirtio, uint16_t idxQueue,
     194DECLINLINE(void) virtioWriteUsedElem(PPDMDEVINS pDevIns, PVIRTIOCORE pVirtio, uint16_t idxQueue,
    195195                                     uint32_t usedIdx, uint32_t uDescIdx, uint32_t uLen)
    196196{
     
    203203}
    204204
    205 DECLINLINE(void) virtioWriteUsedRingIdx(PPDMDEVINS pDevIns, PVIRTIOSTATE pVirtio, uint16_t idxQueue, uint16_t uIdx)
     205DECLINLINE(void) virtioWriteUsedRingIdx(PPDMDEVINS pDevIns, PVIRTIOCORE pVirtio, uint16_t idxQueue, uint16_t uIdx)
    206206{
    207207    AssertMsg(pVirtio->uDeviceStatus & VIRTIO_STATUS_DRIVER_OK, ("Called with guest driver not ready\n"));
     
    212212
    213213#ifdef LOG_ENABLED
    214 DECLINLINE(uint16_t) virtioReadUsedRingIdx(PPDMDEVINS pDevIns, PVIRTIOSTATE pVirtio, uint16_t idxQueue)
     214DECLINLINE(uint16_t) virtioReadUsedRingIdx(PPDMDEVINS pDevIns, PVIRTIOCORE pVirtio, uint16_t idxQueue)
    215215{
    216216    uint16_t uIdx = 0;
     
    223223#endif
    224224
    225 DECLINLINE(uint16_t) virtioReadUsedFlags(PPDMDEVINS pDevIns, PVIRTIOSTATE pVirtio, uint16_t idxQueue)
     225DECLINLINE(uint16_t) virtioReadUsedFlags(PPDMDEVINS pDevIns, PVIRTIOCORE pVirtio, uint16_t idxQueue)
    226226{
    227227    uint16_t fFlags = 0;
     
    234234
    235235#if 0 /* unused */
    236 DECLINLINE(void) virtioWriteUsedFlags(PPDMDEVINS pDevIns, PVIRTIOSTATE pVirtio, uint16_t idxQueue, uint32_t fFlags)
     236DECLINLINE(void) virtioWriteUsedFlags(PPDMDEVINS pDevIns, PVIRTIOCORE pVirtio, uint16_t idxQueue, uint32_t fFlags)
    237237{
    238238    AssertMsg(pVirtio->uDeviceStatus & VIRTIO_STATUS_DRIVER_OK, ("Called with guest driver not ready\n"));
     
    245245
    246246#if 0 /* unused */
    247 DECLINLINE(uint16_t) virtioReadUsedAvailEvent(PPDMDEVINS pDevIns, PVIRTIOSTATE pVirtio, uint16_t idxQueue)
     247DECLINLINE(uint16_t) virtioReadUsedAvailEvent(PPDMDEVINS pDevIns, PVIRTIOCORE pVirtio, uint16_t idxQueue)
    248248{
    249249    uint16_t uAvailEventIdx;
     
    259259
    260260#if 0 /* unused */
    261 DECLINLINE(void) virtioWriteUsedAvailEvent(PPDMDEVINS pDevIns, PVIRTIOSTATE pVirtio, uint16_t idxQueue, uint32_t uAvailEventIdx)
     261DECLINLINE(void) virtioWriteUsedAvailEvent(PPDMDEVINS pDevIns, PVIRTIOCORE pVirtio, uint16_t idxQueue, uint32_t uAvailEventIdx)
    262262{
    263263    /** VirtIO 1.0 uAvailEventIdx (avail_event) immediately follows ring */
     
    283283 *                      provided text with value of cb to indicate size next to it.
    284284 */
    285 void virtioHexDump(uint8_t *pv, uint32_t cb, uint32_t uBase, const char *pszTitle)
     285void virtioCoreHexDump(uint8_t *pv, uint32_t cb, uint32_t uBase, const char *pszTitle)
    286286{
    287287    if (pszTitle)
     
    326326 * @param   idx         The index if fHasIndex
    327327 */
    328 void virtioLogMappedIoValue(const char *pszFunc, const char *pszMember, uint32_t uMemberSize,
     328void virtioCoreLogMappedIoValue(const char *pszFunc, const char *pszMember, uint32_t uMemberSize,
    329329                            const void *pv, uint32_t cb, uint32_t uOffset, int fWrite,
    330330                            int fHasIndex, uint32_t idx)
     
    408408 * @returns VBox status code.
    409409 */
    410 int virtioR3QueueAttach(PVIRTIOSTATE pVirtio, uint16_t idxQueue, const char *pcszName)
     410int virtioCoreR3QueueAttach(PVIRTIOCORE pVirtio, uint16_t idxQueue, const char *pcszName)
    411411{
    412412    LogFunc(("%s\n", pcszName));
     
    424424 * See API comments in header file for description
    425425 */
    426 int virtioQueueSkip(PVIRTIOSTATE pVirtio, uint16_t idxQueue)
     426int virtioQueueSkip(PVIRTIOCORE pVirtio, uint16_t idxQueue)
    427427{
    428428    Assert(idxQueue < RT_ELEMENTS(pVirtio->virtqState));
     
    432432                    ("Guest driver not in ready state.\n"), VERR_INVALID_STATE);
    433433
    434     if (virtioQueueIsEmpty(pVirtio, idxQueue))
     434    if (virtioCoreQueueIsEmpty(pVirtio, idxQueue))
    435435        return VERR_NOT_AVAILABLE;
    436436
     
    452452 * @retval false Queue is available and has entries
    453453 */
    454 bool virtioQueueIsEmpty(PPDMDEVINS pDevIns, PVIRTIOSTATE pVirtio, uint16_t idxQueue)
     454bool virtioCoreQueueIsEmpty(PPDMDEVINS pDevIns, PVIRTIOCORE pVirtio, uint16_t idxQueue)
    455455{
    456456    if (pVirtio->uDeviceStatus & VIRTIO_STATUS_DRIVER_OK)
     
    467467 * Additionally it converts the OUT desc chain data to a contiguous virtual
    468468 * memory buffer for easy consumption by the caller. The caller must return the
    469  * descriptor chain pointer via virtioR3QueuePut() and then call virtioQueueSync()
     469 * descriptor chain pointer via virtioCoreR3QueuePut() and then call virtioCoreQueueSync()
    470470 * at some point to return the data to the guest and complete the transaction.
    471471 *
     
    482482 * @retval  VERR_NOT_AVAILABLE   If the queue is empty.
    483483 */
    484 int virtioR3QueueGet(PPDMDEVINS pDevIns, PVIRTIOSTATE pVirtio, uint16_t idxQueue,
    485                      PPVIRTIO_DESC_CHAIN_T ppDescChain, bool fRemove)
     484int virtioCoreR3QueueGet(PPDMDEVINS pDevIns, PVIRTIOCORE pVirtio, uint16_t idxQueue,
     485                         PPVIRTIO_DESC_CHAIN_T ppDescChain, bool fRemove)
    486486{
    487487    AssertReturn(ppDescChain, VERR_INVALID_PARAMETER);
     
    595595 *
    596596 * @note This does a write-ahead to the used ring of the guest's queue. The data
    597  *       written won't be seen by the guest until the next call to virtioQueueSync()
     597 *       written won't be seen by the guest until the next call to virtioCoreQueueSync()
    598598 *
    599599 *
     
    616616 * @retval  VERR_NOT_AVAILABLE Queue is empty
    617617 */
    618 int virtioR3QueuePut(PPDMDEVINS pDevIns, PVIRTIOSTATE pVirtio, uint16_t idxQueue, PRTSGBUF pSgVirtReturn,
    619                      PVIRTIO_DESC_CHAIN_T pDescChain, bool fFence)
     618int virtioCoreR3QueuePut(PPDMDEVINS pDevIns, PVIRTIOCORE pVirtio, uint16_t idxQueue, PRTSGBUF pSgVirtReturn,
     619                         PVIRTIO_DESC_CHAIN_T pDescChain, bool fFence)
    620620{
    621621    Assert(idxQueue < RT_ELEMENTS(pVirtio->virtqState));
     
    663663    /*
    664664     * Place used buffer's descriptor in used ring but don't update used ring's slot index.
    665      * That will be done with a subsequent client call to virtioQueueSync() */
     665     * That will be done with a subsequent client call to virtioCoreQueueSync() */
    666666    virtioWriteUsedElem(pDevIns, pVirtio, idxQueue, pVirtq->uUsedIdx++, pDescChain->uHeadIdx, (uint32_t)cbCopy);
    667667
     
    686686 * Updates the indicated virtq's "used ring" descriptor index to match the
    687687 * current write-head index, thus exposing the data added to the used ring by all
    688  * virtioR3QueuePut() calls since the last sync. This should be called after one or
     688 * virtioCoreR3QueuePut() calls since the last sync. This should be called after one or
    689689 * more virtQueuePut() calls to inform the guest driver there is data in the queue.
    690690 * Explicit notifications (e.g. interrupt or MSI-X) will be sent to the guest,
     
    701701 * @retval  VERR_INVALID_STATE VirtIO not in ready state
    702702 */
    703 int virtioQueueSync(PPDMDEVINS pDevIns, PVIRTIOSTATE pVirtio, uint16_t idxQueue)
     703int virtioCoreQueueSync(PPDMDEVINS pDevIns, PVIRTIOCORE pVirtio, uint16_t idxQueue)
    704704{
    705705    Assert(idxQueue < RT_ELEMENTS(pVirtio->virtqState));
     
    721721/**
    722722 */
    723 static void virtioR3QueueNotified(PVIRTIOSTATE pVirtio, PVIRTIOSTATECC pVirtioCC, uint16_t idxQueue, uint16_t uNotifyIdx)
     723static void virtioR3QueueNotified(PVIRTIOCORE pVirtio, PVIRTIOCORECC pVirtioCC, uint16_t idxQueue, uint16_t uNotifyIdx)
    724724{
    725725    /* See VirtIO 1.0, section 4.1.5.2 It implies that idxQueue and uNotifyIdx should match.
     
    740740
    741741    /* Inform client */
    742     pVirtioCC->Callbacks.pfnQueueNotified(pVirtio, pVirtioCC, idxQueue);
     742    pVirtioCC->pfnQueueNotified(pVirtio, pVirtioCC, idxQueue);
    743743}
    744744#endif /* IN_RING3 */
     
    760760 *                      as they only cause the guest driver to [re]scan queues for work to do.
    761761 */
    762 static void virtioNotifyGuestDriver(PPDMDEVINS pDevIns, PVIRTIOSTATE pVirtio, uint16_t idxQueue, bool fForce)
     762static void virtioNotifyGuestDriver(PPDMDEVINS pDevIns, PVIRTIOCORE pVirtio, uint16_t idxQueue, bool fForce)
    763763{
    764764    Assert(idxQueue < RT_ELEMENTS(pVirtio->virtqState));
     
    797797 * @param   uForce      True of out-of-band
    798798 */
    799 static int virtioKick(PPDMDEVINS pDevIns, PVIRTIOSTATE pVirtio, uint8_t uCause, uint16_t uMsixVector, bool fForce)
     799static int virtioKick(PPDMDEVINS pDevIns, PVIRTIOCORE pVirtio, uint8_t uCause, uint16_t uMsixVector, bool fForce)
    800800{
    801801   if (fForce)
     
    832832}
    833833
    834 static void virtioResetQueue(PVIRTIOSTATE pVirtio, uint16_t idxQueue)
     834static void virtioResetQueue(PVIRTIOCORE pVirtio, uint16_t idxQueue)
    835835{
    836836    Assert(idxQueue < RT_ELEMENTS(pVirtio->virtqState));
     
    847847}
    848848
    849 static void virtioResetDevice(PPDMDEVINS pDevIns, PVIRTIOSTATE pVirtio)
     849static void virtioResetDevice(PPDMDEVINS pDevIns, PVIRTIOCORE pVirtio)
    850850{
    851851    Log2Func(("\n"));
     
    874874 * @param   fEnabled    Flag indicating whether to enable queue or not
    875875 */
    876 void virtioQueueEnable(PVIRTIOSTATE pVirtio, uint16_t idxQueue, bool fEnabled)
     876void virtioCoreQueueEnable(PVIRTIOCORE pVirtio, uint16_t idxQueue, bool fEnabled)
    877877{
    878878    if (fEnabled)
     
    888888 * Invoked by client to reset the device and driver (see VirtIO 1.0 section 2.1.1/2.1.2)
    889889 */
    890 void virtioResetAll(PVIRTIOSTATE pVirtio)
     890void virtioCoreResetAll(PVIRTIOCORE pVirtio)
    891891{
    892892    LogFunc(("VIRTIO RESET REQUESTED!!!\n"));
     
    905905 * The driver itself will not  until the device has read the status change.
    906906 */
    907 static void virtioGuestR3WasReset(PPDMDEVINS pDevIns, PVIRTIOSTATE pVirtio, PVIRTIOSTATECC pVirtioCC)
     907static void virtioGuestR3WasReset(PPDMDEVINS pDevIns, PVIRTIOCORE pVirtio, PVIRTIOCORECC pVirtioCC)
    908908{
    909909    LogFunc(("Guest reset the device\n"));
    910910
    911911    /* Let the client know */
    912     pVirtioCC->Callbacks.pfnStatusChanged(pVirtio, pVirtioCC, 0);
     912    pVirtioCC->pfnStatusChanged(pVirtio, pVirtioCC, 0);
    913913    virtioResetDevice(pDevIns, pVirtio);
    914914}
     
    928928 * @param   pv          Pointer to location to write to or read from
    929929 */
    930 static int virtioCommonCfgAccessed(PPDMDEVINS pDevIns, PVIRTIOSTATE pVirtio, PVIRTIOSTATECC pVirtioCC,
     930static int virtioCommonCfgAccessed(PPDMDEVINS pDevIns, PVIRTIOCORE pVirtio, PVIRTIOCORECC pVirtioCC,
    931931                                   int fWrite, uint32_t offCfg, unsigned cb, void *pv)
    932932{
     
    952952#ifdef LOG_ENABLED
    953953# define LOG_COMMON_CFG_ACCESS(member, a_offIntra) \
    954     virtioLogMappedIoValue(__FUNCTION__, #member, RT_SIZEOFMEMB(VIRTIO_PCI_COMMON_CFG_T, member), \
     954    virtioCoreLogMappedIoValue(__FUNCTION__, #member, RT_SIZEOFMEMB(VIRTIO_PCI_COMMON_CFG_T, member), \
    955955                           pv, cb, a_offIntra, fWrite, false, 0);
    956956# define LOG_COMMON_CFG_ACCESS_INDEXED(member, idx, a_offIntra) \
    957     virtioLogMappedIoValue(__FUNCTION__, #member, RT_SIZEOFMEMB(VIRTIO_PCI_COMMON_CFG_T, member), \
     957    virtioCoreLogMappedIoValue(__FUNCTION__, #member, RT_SIZEOFMEMB(VIRTIO_PCI_COMMON_CFG_T, member), \
    958958                           pv, cb, a_offIntra, fWrite, true, idx);
    959959#else
     
    11251125                virtioGuestR3WasReset(pDevIns, pVirtio, pVirtioCC);
    11261126            if (fStatusChanged)
    1127                 pVirtioCC->Callbacks.pfnStatusChanged(pVirtio, pVirtioCC, fNewStatus & VIRTIO_STATUS_DRIVER_OK);
     1127                pVirtioCC->pfnStatusChanged(pVirtio, pVirtioCC, fNewStatus & VIRTIO_STATUS_DRIVER_OK);
    11281128#endif
    11291129            /*
     
    12021202static DECLCALLBACK(VBOXSTRICTRC) virtioMmioRead(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS off, void *pv, unsigned cb)
    12031203{
    1204     PVIRTIOSTATE   pVirtio   = PDMINS_2_DATA(pDevIns, PVIRTIOSTATE);
    1205     PVIRTIOSTATECC pVirtioCC = PDMINS_2_DATA_CC(pDevIns, PVIRTIOSTATECC);
    1206     Assert(pVirtio == (PVIRTIOSTATE)pvUser); RT_NOREF(pvUser);
     1204    PVIRTIOCORE   pVirtio   = PDMINS_2_DATA(pDevIns, PVIRTIOCORE);
     1205    PVIRTIOCORECC pVirtioCC = PDMINS_2_DATA_CC(pDevIns, PVIRTIOCORECC);
     1206    Assert(pVirtio == (PVIRTIOCORE)pvUser); RT_NOREF(pvUser);
    12071207
    12081208    /** @todo r=bird: This code does not handle reads spanning more than one
     
    12211221         * Callback to client to manage device-specific configuration.
    12221222         */
    1223         VBOXSTRICTRC rcStrict = pVirtioCC->Callbacks.pfnDevCapRead(pDevIns, offIntra, pv, cb);
     1223        VBOXSTRICTRC rcStrict = pVirtioCC->pfnDevCapRead(pDevIns, offIntra, pv, cb);
    12241224
    12251225        /*
     
    12711271static DECLCALLBACK(VBOXSTRICTRC) virtioMmioWrite(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS off, void const *pv, unsigned cb)
    12721272{
    1273     PVIRTIOSTATE   pVirtio   = PDMINS_2_DATA(pDevIns, PVIRTIOSTATE);
    1274     PVIRTIOSTATECC pVirtioCC = PDMINS_2_DATA_CC(pDevIns, PVIRTIOSTATECC);
    1275     Assert(pVirtio == (PVIRTIOSTATE)pvUser); RT_NOREF(pvUser);
     1273    PVIRTIOCORE   pVirtio   = PDMINS_2_DATA(pDevIns, PVIRTIOCORE);
     1274    PVIRTIOCORECC pVirtioCC = PDMINS_2_DATA_CC(pDevIns, PVIRTIOCORECC);
     1275    Assert(pVirtio == (PVIRTIOCORE)pvUser); RT_NOREF(pvUser);
    12761276
    12771277    /** @todo r=bird: This code does not handle writes spanning more than one
     
    12901290         * Pass this MMIO write access back to the client to handle
    12911291         */
    1292         return pVirtioCC->Callbacks.pfnDevCapWrite(pDevIns, offIntra, pv, cb);
     1292        return pVirtioCC->pfnDevCapWrite(pDevIns, offIntra, pv, cb);
    12931293#else
    12941294        return VINF_IOM_R3_MMIO_WRITE;
     
    13311331                                                        uint32_t uAddress, unsigned cb, uint32_t *pu32Value)
    13321332{
    1333     PVIRTIOSTATE   pVirtio   = PDMINS_2_DATA(pDevIns, PVIRTIOSTATE);
    1334     PVIRTIOSTATECC pVirtioCC = PDMINS_2_DATA_CC(pDevIns, PVIRTIOSTATECC);
     1333    PVIRTIOCORE   pVirtio   = PDMINS_2_DATA(pDevIns, PVIRTIOCORE);
     1334    PVIRTIOCORECC pVirtioCC = PDMINS_2_DATA_CC(pDevIns, PVIRTIOCORECC);
    13351335    RT_NOREF(pPciDev);
    13361336
     
    13711371                                                         uint32_t uAddress, unsigned cb, uint32_t u32Value)
    13721372{
    1373     PVIRTIOSTATE   pVirtio   = PDMINS_2_DATA(pDevIns, PVIRTIOSTATE);
    1374     PVIRTIOSTATECC pVirtioCC = PDMINS_2_DATA_CC(pDevIns, PVIRTIOSTATECC);
     1373    PVIRTIOCORE   pVirtio   = PDMINS_2_DATA(pDevIns, PVIRTIOCORE);
     1374    PVIRTIOCORECC pVirtioCC = PDMINS_2_DATA_CC(pDevIns, PVIRTIOCORECC);
    13751375    RT_NOREF(pPciDev);
    13761376
     
    14151415 * @returns VBox status code.
    14161416 */
    1417 int virtioR3SaveExec(PVIRTIOSTATE pVirtio, PCPDMDEVHLPR3 pHlp, PSSMHANDLE pSSM)
     1417int virtioCoreR3SaveExec(PVIRTIOCORE pVirtio, PCPDMDEVHLPR3 pHlp, PSSMHANDLE pSSM)
    14181418{
    14191419    pHlp->pfnSSMPutU64(pSSM, VIRTIO_SAVEDSTATE_MARKER);
     
    14291429    pHlp->pfnSSMPutU32(pSSM,    pVirtio->uDriverFeaturesSelect);
    14301430    pHlp->pfnSSMPutU64(pSSM,    pVirtio->uDriverFeatures);
    1431     Assert(pVirtio->uNumQueues == VIRTQ_MAX_CNT); /** @todo r=bird: See todo in struct & virtioR3LoadExec. */
     1431    Assert(pVirtio->uNumQueues == VIRTQ_MAX_CNT); /** @todo r=bird: See todo in struct & virtioCoreR3LoadExec. */
    14321432    pHlp->pfnSSMPutU32(pSSM,    pVirtio->uNumQueues);
    14331433
     
    14581458 * @returns VBox status code.
    14591459 */
    1460 int virtioR3LoadExec(PVIRTIOSTATE pVirtio, PCPDMDEVHLPR3 pHlp, PSSMHANDLE pSSM)
     1460int virtioCoreR3LoadExec(PVIRTIOCORE pVirtio, PCPDMDEVHLPR3 pHlp, PSSMHANDLE pSSM)
    14611461{
    14621462    /*
     
    15301530 * @param   pVirtio     Pointer to the shared virtio state.
    15311531 */
    1532 void virtioR3PropagateResetNotification(PPDMDEVINS pDevIns, PVIRTIOSTATE pVirtio)
     1532void virtioCoreR3PropagateResetNotification(PPDMDEVINS pDevIns, PVIRTIOCORE pVirtio)
    15331533{
    15341534    /** @todo r=bird: You probably need to do something here.  See
     
    15461546 * from stalling after suspend.
    15471547 */
    1548 void virtioR3PropagateResumeNotification(PPDMDEVINS pDevIns, PVIRTIOSTATE pVirtio)
     1548void virtioCoreR3PropagateResumeNotification(PPDMDEVINS pDevIns, PVIRTIOCORE pVirtio)
    15491549{
    15501550    virtioNotifyGuestDriver(pDevIns, pVirtio, 0 /* idxQueue */, true /* fForce */);
     
    15591559 * @param   pVirtioCC   Pointer to the ring-3 virtio state.
    15601560 */
    1561 void virtioR3Term(PPDMDEVINS pDevIns, PVIRTIOSTATE pVirtio, PVIRTIOSTATECC pVirtioCC)
     1561void virtioCoreR3Term(PPDMDEVINS pDevIns, PVIRTIOCORE pVirtio, PVIRTIOCORECC pVirtioCC)
    15621562{
    15631563    if (pVirtioCC->pbPrevDevSpecificCfg)
     
    15901590 *                                  configuration struct.
    15911591 */
    1592 int virtioR3Init(PPDMDEVINS pDevIns, PVIRTIOSTATE pVirtio, PVIRTIOSTATECC pVirtioCC, PVIRTIOPCIPARAMS pPciParams,
    1593                  const char *pcszInstance, uint64_t fDevSpecificFeatures, void *pvDevSpecificCfg, uint16_t cbDevSpecificCfg)
     1592int virtioCoreR3Init(PPDMDEVINS pDevIns, PVIRTIOCORE pVirtio, PVIRTIOCORECC pVirtioCC, PVIRTIOPCIPARAMS pPciParams,
     1593                     const char *pcszInstance, uint64_t fDevSpecificFeatures, void *pvDevSpecificCfg, uint16_t cbDevSpecificCfg)
    15941594{
    15951595    /*
     
    15971597     * data, otherwise we cannot get our bearings in the PCI configuration callbacks.
    15981598     */
    1599     AssertLogRelReturn(pVirtio == PDMINS_2_DATA(pDevIns, PVIRTIOSTATE), VERR_STATE_CHANGED);
    1600     AssertLogRelReturn(pVirtioCC == PDMINS_2_DATA_CC(pDevIns, PVIRTIOSTATECC), VERR_STATE_CHANGED);
    1601 
     1599    AssertLogRelReturn(pVirtio == PDMINS_2_DATA(pDevIns, PVIRTIOCORE), VERR_STATE_CHANGED);
     1600    AssertLogRelReturn(pVirtioCC == PDMINS_2_DATA_CC(pDevIns, PVIRTIOCORECC), VERR_STATE_CHANGED);
     1601
     1602    /*
     1603     * Caller must initialize these.
     1604     */
     1605    AssertReturn(pVirtioCC->pfnStatusChanged, VERR_INVALID_POINTER);
     1606    AssertReturn(pVirtioCC->pfnQueueNotified, VERR_INVALID_POINTER);
     1607    AssertReturn(pVirtioCC->pfnDevCapRead,    VERR_INVALID_POINTER);
     1608    AssertReturn(pVirtioCC->pfnDevCapWrite,   VERR_INVALID_POINTER);
    16021609
    16031610#if 0 /* Until pdmR3DvHlp_PCISetIrq() impl is fixed and Assert that limits vec to 0 is removed */
     
    18091816 *                      first member in the currenct context's device instance data!
    18101817 */
    1811 int virtioRZInit(PPDMDEVINS pDevIns, PVIRTIOSTATE pVirtio, PVIRTIOSTATECC pVirtioCC)
    1812 {
    1813     AssertLogRelReturn(pVirtio == PDMINS_2_DATA(pDevIns, PVIRTIOSTATE), VERR_STATE_CHANGED);
    1814     AssertLogRelReturn(pVirtioCC == PDMINS_2_DATA_CC(pDevIns, PVIRTIOSTATECC), VERR_STATE_CHANGED);
     1818int virtioCoreRZInit(PPDMDEVINS pDevIns, PVIRTIOCORE pVirtio, PVIRTIOCORECC pVirtioCC)
     1819{
     1820    AssertLogRelReturn(pVirtio == PDMINS_2_DATA(pDevIns, PVIRTIOCORE), VERR_STATE_CHANGED);
     1821    AssertLogRelReturn(pVirtioCC == PDMINS_2_DATA_CC(pDevIns, PVIRTIOCORECC), VERR_STATE_CHANGED);
    18151822
    18161823    int rc = PDMDevHlpMmioSetUpContext(pDevIns, pVirtio->hMmioPciCap, virtioMmioWrite, virtioMmioRead, pVirtio);
  • trunk/src/VBox/Devices/VirtIO/Virtio_1_0.h

    r81677 r81678  
    2626
    2727/** Pointer to the shared VirtIO state. */
    28 typedef struct VIRTIOSTATE *PVIRTIOSTATE;
     28typedef struct VIRTIOCORE *PVIRTIOCORE;
    2929/** Pointer to the ring-3 VirtIO state. */
    30 typedef struct VIRTIOSTATER3 *PVIRTIOSTATER3;
     30typedef struct VIRTIOCORER3 *PVIRTIOCORER3;
    3131/** Pointer to the ring-0 VirtIO state. */
    32 typedef struct VIRTIOSTATER0 *PVIRTIOSTATER0;
     32typedef struct VIRTIOCORER0 *PVIRTIOCORER0;
    3333/** Pointer to the raw-mode VirtIO state. */
    34 typedef struct VIRTIOSTATERC *PVIRTIOSTATERC;
     34typedef struct VIRTIOCORERC *PVIRTIOCORERC;
    3535/** Pointer to the instance data for the current context. */
    36 typedef CTX_SUFF(PVIRTIOSTATE) PVIRTIOSTATECC;
     36typedef CTX_SUFF(PVIRTIOCORE) PVIRTIOCORECC;
    3737
    3838
     
    5454    do { \
    5555        if (LogIsItEnabled(logLevel, LOG_GROUP)) \
    56             virtioHexDump((pv), (cb), (base), (title)); \
     56            virtioCoreHexDump((pv), (cb), (base), (title)); \
    5757    } while (0)
    5858#else
     
    7272 *
    7373 * Typical use is, When the client (worker thread) detects available data on the queue, it pulls the
    74  * next one of these descriptor chain structs off the queue using virtioR3QueueGet(), processes the
     74 * next one of these descriptor chain structs off the queue using virtioCoreR3QueueGet(), processes the
    7575 * virtual memory buffer pVirtSrc, produces result data to pass back to the guest driver and calls
    76  * virtioR3QueuePut() to return the result data to the client.
     76 * virtioCoreR3QueuePut() to return the result data to the client.
    7777 */
    7878typedef struct VIRTIO_DESC_CHAIN
     
    102102} VIRTIOPCIPARAMS, *PVIRTIOPCIPARAMS;
    103103
    104 /** @name VirtIO port I/O callbacks.
    105  * @{ */
    106 typedef struct VIRTIOCALLBACKS
    107 {
    108      /**
    109       * Implementation-specific client callback to notify client of significant device status
    110       * changes.
    111       *
    112       * @param   pVirtio    Pointer to the shared virtio state.
    113       * @param   pVirtioCC  Pointer to the ring-3 virtio state.
    114       * @param   fDriverOk  True if guest driver is okay (thus queues, etc... are
    115       *                     valid)
    116       */
    117      DECLCALLBACKMEMBER(void, pfnStatusChanged)(PVIRTIOSTATE pVirtio, PVIRTIOSTATECC pVirtioCC, uint32_t fDriverOk);
    118 
    119      /**
    120       * When guest-to-host queue notifications are enabled, the guest driver notifies the host
    121       * that the avail queue has buffers, and this callback informs the client.
    122       *
    123       * @param   pVirtio    Pointer to the shared virtio state.
    124       * @param   pVirtioCC  Pointer to the ring-3 virtio state.
    125       * @param   idxQueue   Index of the notified queue
    126       */
    127      DECLCALLBACKMEMBER(void, pfnQueueNotified)(PVIRTIOSTATE pVirtio, PVIRTIOSTATECC pVirtioCC, uint16_t idxQueue);
    128 
    129      /**
    130       * Implementation-specific client callback to access VirtIO Device-specific capabilities
    131       * (other VirtIO capabilities and features are handled in VirtIO implementation)
    132       *
    133       * @param   pDevIns    The device instance.
    134       * @param   offCap     Offset within device specific capabilities struct.
    135       * @param   pvBuf      Buffer in which to save read data.
    136       * @param   cbToRead   Number of bytes to read.
    137       */
    138      DECLCALLBACKMEMBER(int,  pfnDevCapRead)(PPDMDEVINS pDevIns, uint32_t offCap, void *pvBuf, uint32_t cbToRead);
    139 
    140      /**
    141       * Implementation-specific client ballback to access VirtIO Device-specific capabilities
    142       * (other VirtIO capabilities and features are handled in VirtIO implementation)
    143       *
    144       * @param   pDevIns    The device instance.
    145       * @param   offCap     Offset within device specific capabilities struct.
    146       * @param   pvBuf      Buffer with the bytes to write.
    147       * @param   cbToWrite  Number of bytes to write.
    148       */
    149      DECLCALLBACKMEMBER(int,  pfnDevCapWrite)(PPDMDEVINS pDevIns, uint32_t offCap, const void *pvBuf, uint32_t cbWrite);
    150 } VIRTIOCALLBACKS;
    151 /** @} */
    152104
    153105#define VIRTIO_F_VERSION_1                  RT_BIT_64(32)        /**< Required feature bit for 1.0 devices      */
     
    267219 * The core/common state of the VirtIO PCI devices, shared edition.
    268220 */
    269 typedef struct VIRTIOSTATE
     221typedef struct VIRTIOCORE
    270222{
    271223    char                        szInstance[16];                     /**< Instance name, e.g. "VIRTIOSCSI0"         */
     
    313265    /** The MMIO handle for the PCI capability region (\#2). */
    314266    IOMMMIOHANDLE               hMmioPciCap;
    315 } VIRTIOSTATE;
     267} VIRTIOCORE;
    316268
    317269
     
    319271 * The core/common state of the VirtIO PCI devices, ring-3 edition.
    320272 */
    321 typedef struct VIRTIOSTATER3
    322 {
    323     VIRTIOCALLBACKS             Callbacks;                          /**< Callback vectors to client                */
     273typedef struct VIRTIOCORER3
     274{
     275    /** @name Callbacks filled by the device before calling virtioCoreR3Init.
     276     * @{  */
     277    /**
     278     * Implementation-specific client callback to notify client of significant device status
     279     * changes.
     280     *
     281     * @param   pVirtio    Pointer to the shared virtio state.
     282     * @param   pVirtioCC  Pointer to the ring-3 virtio state.
     283     * @param   fDriverOk  True if guest driver is okay (thus queues, etc... are
     284     *                     valid)
     285     */
     286    DECLCALLBACKMEMBER(void, pfnStatusChanged)(PVIRTIOCORE pVirtio, PVIRTIOCORECC pVirtioCC, uint32_t fDriverOk);
     287
     288    /**
     289     * When guest-to-host queue notifications are enabled, the guest driver notifies the host
     290     * that the avail queue has buffers, and this callback informs the client.
     291     *
     292     * @param   pVirtio    Pointer to the shared virtio state.
     293     * @param   pVirtioCC  Pointer to the ring-3 virtio state.
     294     * @param   idxQueue   Index of the notified queue
     295     */
     296    DECLCALLBACKMEMBER(void, pfnQueueNotified)(PVIRTIOCORE pVirtio, PVIRTIOCORECC pVirtioCC, uint16_t idxQueue);
     297
     298    /**
     299     * Implementation-specific client callback to access VirtIO Device-specific capabilities
     300     * (other VirtIO capabilities and features are handled in VirtIO implementation)
     301     *
     302     * @param   pDevIns    The device instance.
     303     * @param   offCap     Offset within device specific capabilities struct.
     304     * @param   pvBuf      Buffer in which to save read data.
     305     * @param   cbToRead   Number of bytes to read.
     306     */
     307    DECLCALLBACKMEMBER(int,  pfnDevCapRead)(PPDMDEVINS pDevIns, uint32_t offCap, void *pvBuf, uint32_t cbToRead);
     308
     309    /**
     310     * Implementation-specific client ballback to access VirtIO Device-specific capabilities
     311     * (other VirtIO capabilities and features are handled in VirtIO implementation)
     312     *
     313     * @param   pDevIns    The device instance.
     314     * @param   offCap     Offset within device specific capabilities struct.
     315     * @param   pvBuf      Buffer with the bytes to write.
     316     * @param   cbToWrite  Number of bytes to write.
     317     */
     318    DECLCALLBACKMEMBER(int,  pfnDevCapWrite)(PPDMDEVINS pDevIns, uint32_t offCap, const void *pvBuf, uint32_t cbWrite);
     319    /** @} */
    324320
    325321    R3PTRTYPE(PVIRTIO_PCI_CFG_CAP_T)    pPciCfgCap;                 /**< Pointer to struct in the PCI configuration area. */
     
    333329    R3PTRTYPE(uint8_t *)        pbPrevDevSpecificCfg;               /**< Previous read dev-specific cfg of client  */
    334330    bool                        fGenUpdatePending;                  /**< If set, update cfg gen after driver reads */
    335 } VIRTIOSTATER3;
     331} VIRTIOCORER3;
    336332
    337333
     
    339335 * The core/common state of the VirtIO PCI devices, ring-0 edition.
    340336 */
    341 typedef struct VIRTIOSTATER0
     337typedef struct VIRTIOCORER0
    342338{
    343339    uint64_t                    uUnusedAtTheMoment;
    344 } VIRTIOSTATER0;
     340} VIRTIOCORER0;
    345341
    346342
     
    348344 * The core/common state of the VirtIO PCI devices, raw-mode edition.
    349345 */
    350 typedef struct VIRTIOSTATERC
     346typedef struct VIRTIOCORERC
    351347{
    352348    uint64_t                    uUnusedAtTheMoment;
    353 } VIRTIOSTATERC;
    354 
    355 
    356 /** @typedef VIRTIOSTATECC
     349} VIRTIOCORERC;
     350
     351
     352/** @typedef VIRTIOCORECC
    357353 * The instance data for the current context. */
    358 typedef CTX_SUFF(VIRTIOSTATE) VIRTIOSTATECC;
    359 
    360 
    361 /** virtq related flags */
     354typedef CTX_SUFF(VIRTIOCORE) VIRTIOCORECC;
     355
     356
     357/** @name virtq related flags
     358 * @{ */
    362359#define VIRTQ_DESC_F_NEXT                               1        /**< Indicates this descriptor chains to next  */
    363360#define VIRTQ_DESC_F_WRITE                              2        /**< Marks buffer as write-only (default ro)   */
     
    366363#define VIRTQ_USED_F_NO_NOTIFY                          1        /**< Dev to Drv: Don't notify when buf added   */
    367364#define VIRTQ_AVAIL_F_NO_INTERRUPT                      1        /**< Drv to Dev: Don't notify when buf eaten   */
    368 
    369 
    370 /** @name API for VirtIO client
     365/** @} */
     366
     367
     368/** @name API for VirtIO parent device
    371369 * @{ */
    372370
    373 int virtioR3QueueAttach(PVIRTIOSTATE pVirtio, uint16_t idxQueue, const char *pcszName);
     371int virtioCoreR3QueueAttach(PVIRTIOCORE pVirtio, uint16_t idxQueue, const char *pcszName);
    374372#if 0 /* no such function */
    375373/**
     
    379377 * @param idxQueue      Queue number
    380378 */
    381 int virtioQueueDetach(PVIRTIOSTATE pVirtio, uint16_t idxQueue);
     379int virtioCoreR3QueueDetach(PVIRTIOCORE pVirtio, uint16_t idxQueue);
    382380#endif
    383 int  virtioR3QueueGet(PPDMDEVINS pDevIns, PVIRTIOSTATE pVirtio, uint16_t idxQueue,
    384                       PPVIRTIO_DESC_CHAIN_T ppDescChain, bool fRemove);
    385 int  virtioR3QueuePut(PPDMDEVINS pDevIns, PVIRTIOSTATE pVirtio, uint16_t idxQueue, PRTSGBUF pSgVirtReturn,
    386                       PVIRTIO_DESC_CHAIN_T pDescChain, bool fFence);
    387 int  virtioQueueSync(PPDMDEVINS pDevIns, PVIRTIOSTATE pVirtio, uint16_t idxQueue);
    388 bool virtioQueueIsEmpty(PPDMDEVINS pDevIns, PVIRTIOSTATE pVirtio, uint16_t idxQueue);
    389 void virtioQueueEnable(PVIRTIOSTATE pVirtio, uint16_t idxQueue, bool fEnabled);
    390 
    391 #if 0 /** @todo unused */
    392 void virtioResetAll(PVIRTIOSTATE pVirtio);
    393 #endif
     381int  virtioCoreR3QueueGet(PPDMDEVINS pDevIns, PVIRTIOCORE pVirtio, uint16_t idxQueue,
     382                          PPVIRTIO_DESC_CHAIN_T ppDescChain, bool fRemove);
     383int  virtioCoreR3QueuePut(PPDMDEVINS pDevIns, PVIRTIOCORE pVirtio, uint16_t idxQueue, PRTSGBUF pSgVirtReturn,
     384                          PVIRTIO_DESC_CHAIN_T pDescChain, bool fFence);
     385int  virtioCoreQueueSync(PPDMDEVINS pDevIns, PVIRTIOCORE pVirtio, uint16_t idxQueue);
     386bool virtioCoreQueueIsEmpty(PPDMDEVINS pDevIns, PVIRTIOCORE pVirtio, uint16_t idxQueue);
     387void virtioCoreQueueEnable(PVIRTIOCORE pVirtio, uint16_t idxQueue, bool fEnabled);
    394388
    395389/**
     
    400394 * @param   fEnabled    Flag indicating whether to enable queue or not
    401395 */
    402 DECLINLINE(bool) virtioIsQueueEnabled(PVIRTIOSTATE pVirtio, uint16_t idxQueue)
     396DECLINLINE(bool) virtioCoreIsQueueEnabled(PVIRTIOCORE pVirtio, uint16_t idxQueue)
    403397{
    404398    Assert(idxQueue < RT_ELEMENTS(pVirtio->virtqState));
     
    408402
    409403/**
    410  * Get name of queue, by idxQueue, assigned at virtioR3QueueAttach()
     404 * Get name of queue, by idxQueue, assigned at virtioCoreR3QueueAttach()
    411405 *
    412406 * @param   pVirtio     Pointer to the virtio state.
     
    415409 * @returns Pointer to read-only queue name.
    416410 */
    417 DECLINLINE(const char *) virtioQueueGetName(PVIRTIOSTATE pVirtio, uint16_t idxQueue)
     411DECLINLINE(const char *) virtioCoreQueueGetName(PVIRTIOCORE pVirtio, uint16_t idxQueue)
    418412{
    419413    Assert((size_t)idxQueue < RT_ELEMENTS(pVirtio->virtqState));
     
    426420 * @returns Features the guest driver has accepted, finalizing the operational features
    427421 */
    428 DECLINLINE(uint64_t) virtioGetNegotiatedFeatures(PVIRTIOSTATE pVirtio)
     422DECLINLINE(uint64_t) virtioCoreGetNegotiatedFeatures(PVIRTIOCORE pVirtio)
    429423{
    430424    return pVirtio->uDriverFeatures;
     
    438432 * @param   pState          Virtio state
    439433 */
    440 DECLINLINE(uint64_t) virtioGetAcceptedFeatures(PVIRTIOSTATE pVirtio)
     434DECLINLINE(uint64_t) virtioCoreGetAcceptedFeatures(PVIRTIOCORE pVirtio)
    441435{
    442436    return pVirtio->uDriverFeatures;
     
    444438
    445439
    446 int  virtioR3SaveExec(PVIRTIOSTATE pVirtio, PCPDMDEVHLPR3 pHlp, PSSMHANDLE pSSM);
    447 int  virtioR3LoadExec(PVIRTIOSTATE pVirtio, PCPDMDEVHLPR3 pHlp, PSSMHANDLE pSSM);
    448 void virtioR3PropagateResetNotification(PPDMDEVINS pDevIns, PVIRTIOSTATE pVirtio);
    449 void virtioR3PropagateResumeNotification(PPDMDEVINS pDevIns, PVIRTIOSTATE pVirtio);
    450 void virtioR3Term(PPDMDEVINS pDevIns, PVIRTIOSTATE pVirtio, PVIRTIOSTATECC pVirtioCC);
    451 int  virtioR3Init(PPDMDEVINS pDevIns, PVIRTIOSTATE pVirtio, PVIRTIOSTATECC pVirtioCC, PVIRTIOPCIPARAMS pPciParams,
    452                   const char *pcszInstance, uint64_t fDevSpecificFeatures, void *pvDevSpecificCfg, uint16_t cbDevSpecificCfg);
    453 int  virtioRZInit(PPDMDEVINS pDevIns, PVIRTIOSTATE pVirtio, PVIRTIOSTATECC pVirtioCC);
    454 
    455 void virtioLogMappedIoValue(const char *pszFunc, const char *pszMember, uint32_t uMemberSize,
    456                             const void *pv, uint32_t cb, uint32_t uOffset,
    457                             int fWrite, int fHasIndex, uint32_t idx);
    458 void virtioHexDump(uint8_t *pv, uint32_t cb, uint32_t uBase, const char *pszTitle);
     440void virtioCoreLogMappedIoValue(const char *pszFunc, const char *pszMember, uint32_t uMemberSize,
     441                                const void *pv, uint32_t cb, uint32_t uOffset,
     442                                int fWrite, int fHasIndex, uint32_t idx);
     443void virtioCoreHexDump(uint8_t *pv, uint32_t cb, uint32_t uBase, const char *pszTitle);
     444
     445
     446int  virtioCoreR3SaveExec(PVIRTIOCORE pVirtio, PCPDMDEVHLPR3 pHlp, PSSMHANDLE pSSM);
     447int  virtioCoreR3LoadExec(PVIRTIOCORE pVirtio, PCPDMDEVHLPR3 pHlp, PSSMHANDLE pSSM);
     448#if 0 /** @todo unused */
     449void virtioCoreResetAll(PVIRTIOCORE pVirtio);
     450#endif
     451void virtioCoreR3PropagateResetNotification(PPDMDEVINS pDevIns, PVIRTIOCORE pVirtio);
     452void virtioCoreR3PropagateResumeNotification(PPDMDEVINS pDevIns, PVIRTIOCORE pVirtio);
     453void virtioCoreR3Term(PPDMDEVINS pDevIns, PVIRTIOCORE pVirtio, PVIRTIOCORECC pVirtioCC);
     454int  virtioCoreR3Init(PPDMDEVINS pDevIns, PVIRTIOCORE pVirtio, PVIRTIOCORECC pVirtioCC, PVIRTIOPCIPARAMS pPciParams,
     455                      const char *pcszInstance, uint64_t fDevSpecificFeatures, void *pvDevSpecificCfg, uint16_t cbDevSpecificCfg);
     456int  virtioCoreRZInit(PPDMDEVINS pDevIns, PVIRTIOCORE pVirtio, PVIRTIOCORECC pVirtioCC);
    459457/** @} */
    460458
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