VirtualBox

Changeset 81703 in vbox


Ignore:
Timestamp:
Nov 6, 2019 11:51:57 AM (5 years ago)
Author:
vboxsync
Message:

DevVirtioNet.cpp,Virtio.cpp: Some cleanups prepping for refactoring to new PDM device style. bugref:9218

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Network/DevVirtioNet.cpp

    r81696 r81703  
    396396}
    397397
    398 static DECLCALLBACK(uint32_t) vnetIoCb_GetHostFeatures(void *pvState)
    399 {
    400     RT_NOREF_PV(pvState);
     398/**
     399 * @interface_method_impl{VPCIIOCALLBACKS,pfnGetHostFeatures}
     400 */
     401static DECLCALLBACK(uint32_t) vnetIoCb_GetHostFeatures(PVPCISTATE pVPciState)
     402{
     403    RT_NOREF_PV(pVPciState);
    401404
    402405    /* We support:
     
    429432}
    430433
    431 static DECLCALLBACK(uint32_t) vnetIoCb_GetHostMinimalFeatures(void *pvState)
    432 {
    433     RT_NOREF_PV(pvState);
     434/**
     435 * @interface_method_impl{VPCIIOCALLBACKS,pfnGetHostMinimalFeatures}
     436 */
     437static DECLCALLBACK(uint32_t) vnetIoCb_GetHostMinimalFeatures(PVPCISTATE pVPciState)
     438{
     439    RT_NOREF_PV(pVPciState);
    434440    return VNET_F_MAC;
    435441}
    436442
    437 static DECLCALLBACK(void) vnetIoCb_SetHostFeatures(void *pvState, uint32_t fFeatures)
    438 {
     443/**
     444 * @interface_method_impl{VPCIIOCALLBACKS,pfnSetHostFeatures}
     445 */
     446static DECLCALLBACK(void) vnetIoCb_SetHostFeatures(PVPCISTATE pVPciState, uint32_t fFeatures)
     447{
     448    PVNETSTATE pThis = RT_FROM_MEMBER(pVPciState, VNETSTATE, VPCI);
    439449    /** @todo Nothing to do here yet */
    440     PVNETSTATE pThis = (PVNETSTATE)pvState;
    441450    LogFlow(("%s vnetIoCb_SetHostFeatures: uFeatures=%x\n", INSTANCE(pThis), fFeatures));
    442451    vnetPrintFeatures(pThis, fFeatures, "The guest negotiated the following features");
    443452}
    444453
    445 static DECLCALLBACK(int) vnetIoCb_GetConfig(void *pvState, uint32_t offCfg, uint32_t cb, void *data)
    446 {
    447     PVNETSTATE pThis = (PVNETSTATE)pvState;
     454/**
     455 * @interface_method_impl{VPCIIOCALLBACKS,pfnGetConfig}
     456 */
     457static DECLCALLBACK(int) vnetIoCb_GetConfig(PVPCISTATE pVPciState, uint32_t offCfg, uint32_t cb, void *data)
     458{
     459    PVNETSTATE pThis = RT_FROM_MEMBER(pVPciState, VNETSTATE, VPCI);
    448460    if (offCfg + cb > sizeof(struct VNetPCIConfig))
    449461    {
     
    455467}
    456468
    457 static DECLCALLBACK(int) vnetIoCb_SetConfig(void *pvState, uint32_t offCfg, uint32_t cb, void *data)
    458 {
    459     PVNETSTATE pThis = (PVNETSTATE)pvState;
     469/**
     470 * @interface_method_impl{VPCIIOCALLBACKS,pfnSetConfig}
     471 */
     472static DECLCALLBACK(int) vnetIoCb_SetConfig(PVPCISTATE pVPciState, uint32_t offCfg, uint32_t cb, void *data)
     473{
     474    PVNETSTATE pThis = RT_FROM_MEMBER(pVPciState, VNETSTATE, VPCI);
    460475    if (offCfg + cb > sizeof(struct VNetPCIConfig))
    461476    {
    462477        Log(("%s vnetIoCb_SetConfig: Write beyond the config structure is attempted (offCfg=%#x cb=%x).\n", INSTANCE(pThis), offCfg, cb));
    463478        if (offCfg < sizeof(struct VNetPCIConfig))
    464             memcpy((uint8_t *)&pThis->config + offCfg, data,
    465                    sizeof(struct VNetPCIConfig) - offCfg);
     479            memcpy((uint8_t *)&pThis->config + offCfg, data, sizeof(struct VNetPCIConfig) - offCfg);
    466480        return VINF_SUCCESS;
    467481    }
     
    471485
    472486/**
     487 * @interface_method_impl{VPCIIOCALLBACKS,pfnReset}
     488 *
    473489 * Hardware reset. Revert all registers to initial values.
    474  *
    475  * @param   pThis      The device state structure.
    476  */
    477 static DECLCALLBACK(int) vnetIoCb_Reset(void *pvState)
    478 {
    479     PVNETSTATE pThis = (PVNETSTATE)pvState;
     490 */
     491static DECLCALLBACK(int) vnetIoCb_Reset(PVPCISTATE pVPciState)
     492{
     493    PVNETSTATE pThis = RT_FROM_MEMBER(pVPciState, VNETSTATE, VPCI);
    480494    Log(("%s Reset triggered\n", INSTANCE(pThis)));
    481495
     
    610624
    611625/**
     626 * @interface_method_impl{VPCIIOCALLBACKS,pfnReady}
     627 *
    612628 * This function is called when the driver becomes ready.
    613  *
    614  * @param   pThis      The device state structure.
    615  */
    616 static DECLCALLBACK(void) vnetIoCb_Ready(void *pvState)
    617 {
    618     PVNETSTATE pThis = (PVNETSTATE)pvState;
     629 */
     630static DECLCALLBACK(void) vnetIoCb_Ready(PVPCISTATE pVPciState)
     631{
     632    PVNETSTATE pThis = RT_FROM_MEMBER(pVPciState, VNETSTATE, VPCI);
    619633    Log(("%s Driver became ready, waking up RX thread...\n", INSTANCE(pThis)));
    620634/**
     
    655669PDMBOTHCBDECL(int) vnetIOPortIn(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT port, uint32_t *pu32, unsigned cb)
    656670{
    657     return vpciIOPortIn(pDevIns, pvUser, port, pu32, cb, &g_IOCallbacks);
     671    PVNETSTATE pThis = PDMDEVINS_2_DATA(pDevIns, PVNETSTATE);
     672    RT_NOREF(pvUser);
     673    return vpciIOPortIn(pDevIns, &pThis->VPCI, port, pu32, cb, &g_IOCallbacks);
    658674}
    659675
     
    664680PDMBOTHCBDECL(int) vnetIOPortOut(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT port, uint32_t u32, unsigned cb)
    665681{
    666     return vpciIOPortOut(pDevIns, pvUser, port, u32, cb, &g_IOCallbacks);
     682    PVNETSTATE pThis = PDMDEVINS_2_DATA(pDevIns, PVNETSTATE);
     683    RT_NOREF(pvUser);
     684    return vpciIOPortOut(pDevIns, &pThis->VPCI, port, u32, cb, &g_IOCallbacks);
    667685}
    668686
     
    11181136}
    11191137
    1120 static DECLCALLBACK(void) vnetR3QueueReceive(void *pvState, PVQUEUE pQueue)
    1121 {
    1122     RT_NOREF(pQueue);
    1123     PVNETSTATE pThis = (PVNETSTATE)pvState;
     1138static DECLCALLBACK(void) vnetR3QueueReceive(PPDMDEVINS pDevIns, PVPCISTATE pVPciState, PVQUEUE pQueue)
     1139{
     1140    PVNETSTATE pThis = RT_FROM_MEMBER(pVPciState, VNETSTATE, VPCI);
     1141    RT_NOREF(pThis, pQueue);
    11241142    Log(("%s Receive buffers has been added, waking up receive thread.\n", INSTANCE(pThis)));
    1125     vnetR3WakeupReceive(pThis->VPCI.CTX_SUFF(pDevIns));
     1143    vnetR3WakeupReceive(pDevIns);
    11261144}
    11271145
     
    14291447# ifdef VNET_TX_DELAY
    14301448
    1431 static DECLCALLBACK(void) vnetR3QueueTransmit(void *pvState, PVQUEUE pQueue)
    1432 {
    1433     PVNETSTATE pThis = (PVNETSTATE)pvState;
     1449static DECLCALLBACK(void) vnetR3QueueTransmit(PPDMDEVINS pDevIns, PVPCISTATE pVPciState, PVQUEUE pQueue)
     1450{
     1451    PVNETSTATE pThis = RT_FROM_MEMBER(pVPciState, VNETSTATE, VPCI);
     1452    RT_NOREF(pDevIns);
    14341453
    14351454    if (TMTimerIsActive(pThis->CTX_SUFF(pTxTimer)))
     
    15131532    while (pThread->enmState == PDMTHREADSTATE_RUNNING)
    15141533    {
    1515         rc = SUPSemEventWaitNoResume(pThis->pSupDrvSession, pThis->hTxEvent, RT_INDEFINITE_WAIT);
     1534        rc = PDMDevHlpSUPSemEventWaitNoResume(pDevIns, pThis->hTxEvent, RT_INDEFINITE_WAIT);
    15161535        if (RT_UNLIKELY(pThread->enmState != PDMTHREADSTATE_RUNNING))
    15171536            break;
     
    15381557 * @param   pThread     The send thread.
    15391558 */
    1540 static DECLCALLBACK(int) vnetTxThreadWakeUp(PPDMDEVINS pDevIns, PPDMTHREAD pThread)
    1541 {
    1542     RT_NOREF(pDevIns);
     1559static DECLCALLBACK(int) vnetR3TxThreadWakeUp(PPDMDEVINS pDevIns, PPDMTHREAD pThread)
     1560{
    15431561    PVNETSTATE pThis = (PVNETSTATE)pThread->pvUser;
    1544     return SUPSemEventSignal(pThis->pSupDrvSession, pThis->hTxEvent);
     1562    return PDMDevHlpSUPSemEventSignal(pDevIns, pThis->hTxEvent);
    15451563}
    15461564
    15471565static int vnetR3CreateTxThreadAndEvent(PPDMDEVINS pDevIns, PVNETSTATE pThis)
    15481566{
    1549     int rc = SUPSemEventCreate(pThis->pSupDrvSession, &pThis->hTxEvent);
     1567    int rc = PDMDevHlpSUPSemEventCreate(pDevIns, &pThis->hTxEvent);
    15501568    if (RT_FAILURE(rc))
    1551         return PDMDevHlpVMSetError(pDevIns, rc, RT_SRC_POS,
    1552                                    N_("VNET: Failed to create SUP event semaphore"));
     1569        return PDMDevHlpVMSetError(pDevIns, rc, RT_SRC_POS, N_("VNET: Failed to create SUP event semaphore"));
     1570
    15531571    rc = PDMDevHlpThreadCreate(pDevIns, &pThis->pTxThread, pThis, vnetR3TxThread,
    1554                                vnetTxThreadWakeUp, 0, RTTHREADTYPE_IO, INSTANCE(pThis));
     1572                               vnetR3TxThreadWakeUp, 0, RTTHREADTYPE_IO, INSTANCE(pThis));
    15551573    if (RT_FAILURE(rc))
    1556         return PDMDevHlpVMSetError(pDevIns, rc, RT_SRC_POS,
    1557                                    N_("VNET: Failed to create worker thread %s"), INSTANCE(pThis));
     1574        return PDMDevHlpVMSetError(pDevIns, rc, RT_SRC_POS, N_("VNET: Failed to create worker thread %s"), INSTANCE(pThis));
    15581575    return VINF_SUCCESS;
    15591576}
    15601577
    1561 static void vnetR3DestroyTxThreadAndEvent(PVNETSTATE pThis)
     1578static void vnetR3DestroyTxThreadAndEvent(PPDMDEVINS pDevIns, PVNETSTATE pThis)
    15621579{
    15631580    if (pThis->pTxThread)
     
    15721589    if (pThis->hTxEvent != NIL_SUPSEMEVENT)
    15731590    {
    1574         SUPSemEventClose(pThis->pSupDrvSession, pThis->hTxEvent);
     1591        PDMDevHlpSUPSemEventClose(pDevIns, pThis->hTxEvent);
    15751592        pThis->hTxEvent = NIL_SUPSEMEVENT;
    15761593    }
    15771594}
    15781595
    1579 static DECLCALLBACK(void) vnetR3QueueTransmit(void *pvState, PVQUEUE pQueue)
    1580 {
    1581     PVNETSTATE pThis = (PVNETSTATE)pvState;
     1596static DECLCALLBACK(void) vnetR3QueueTransmit(PPDMDEVINS pDevIns, PVPCISTATE pVPciState, PVQUEUE pQueue)
     1597{
     1598    PVNETSTATE pThis = RT_FROM_MEMBER(pVPciState, VNETSTATE, VPCI);
    15821599
    15831600    Log(("vnetR3QueueTransmit: disable kicking and wake up TX thread\n"));
    15841601    vringSetNotification(&pThis->VPCI, &pQueue->VRing, false);
    1585     SUPSemEventSignal(pThis->pSupDrvSession, pThis->hTxEvent);
     1602    PDMDevHlpSUPSemEventSignal(pDevIns, pThis->hTxEvent);
    15861603}
    15871604
     
    17351752
    17361753
    1737 static DECLCALLBACK(void) vnetR3QueueControl(void *pvState, PVQUEUE pQueue)
    1738 {
    1739     PVNETSTATE pThis = (PVNETSTATE)pvState;
    1740     uint8_t u8Ack;
     1754static DECLCALLBACK(void) vnetR3QueueControl(PPDMDEVINS pDevIns, PVPCISTATE pVPciState, PVQUEUE pQueue)
     1755{
     1756    PVNETSTATE pThis = RT_FROM_MEMBER(pVPciState, VNETSTATE, VPCI);
    17411757    VQUEUEELEM elem;
    17421758    while (vqueueGet(&pThis->VPCI, pQueue, &elem))
     
    17561772        }
    17571773
     1774        uint8_t    bAck;
    17581775        VNETCTLHDR CtlHdr;
    1759         PDMDevHlpPhysRead(pThis->VPCI.CTX_SUFF(pDevIns),
    1760                           elem.aSegsOut[0].addr,
    1761                           &CtlHdr, sizeof(CtlHdr));
     1776        PDMDevHlpPhysRead(pDevIns, elem.aSegsOut[0].addr, &CtlHdr, sizeof(CtlHdr));
    17621777        switch (CtlHdr.u8Class)
    17631778        {
    17641779            case VNET_CTRL_CLS_RX_MODE:
    1765                 u8Ack = vnetR3ControlRx(pThis, &CtlHdr, &elem);
     1780                bAck = vnetR3ControlRx(pThis, &CtlHdr, &elem);
    17661781                break;
    17671782            case VNET_CTRL_CLS_MAC:
    1768                 u8Ack = vnetR3ControlMac(pThis, &CtlHdr, &elem);
     1783                bAck = vnetR3ControlMac(pThis, &CtlHdr, &elem);
    17691784                break;
    17701785            case VNET_CTRL_CLS_VLAN:
    1771                 u8Ack = vnetR3ControlVlan(pThis, &CtlHdr, &elem);
     1786                bAck = vnetR3ControlVlan(pThis, &CtlHdr, &elem);
    17721787                break;
    17731788            default:
    1774                 u8Ack = VNET_ERROR;
    1775         }
    1776         Log(("%s Processed control message %u, ack=%u.\n", INSTANCE(pThis), CtlHdr.u8Class, u8Ack));
    1777         PDMDevHlpPCIPhysWrite(pThis->VPCI.CTX_SUFF(pDevIns),
    1778                               elem.aSegsIn[elem.nIn - 1].addr,
    1779                               &u8Ack, sizeof(u8Ack));
    1780 
    1781         vqueuePut(&pThis->VPCI, pQueue, &elem, sizeof(u8Ack));
     1789                bAck = VNET_ERROR;
     1790        }
     1791        Log(("%s Processed control message %u, ack=%u.\n", INSTANCE(pThis), CtlHdr.u8Class, bAck));
     1792        PDMDevHlpPCIPhysWrite(pDevIns, elem.aSegsIn[elem.nIn - 1].addr, &bAck, sizeof(bAck));
     1793
     1794        vqueuePut(&pThis->VPCI, pQueue, &elem, sizeof(bAck));
    17821795        vqueueSync(&pThis->VPCI, pQueue);
    17831796    }
     
    20072020    }
    20082021
    2009     vnetR3DestroyTxThreadAndEvent(pThis);
     2022    vnetR3DestroyTxThreadAndEvent(pDevIns, pThis);
     2023
    20102024    /*
    2011      * Zero some important members.
     2025     * Zero important members.
    20122026     */
    20132027    pThis->pDrvBase = NULL;
     
    21242138
    21252139#ifdef VNET_TX_DELAY
    2126     LogRel(("TxTimer stats (avg/min/max): %7d usec %7d usec %7d usec\n",
    2127             pThis->u32AvgDiff, pThis->u32MinDiff, pThis->u32MaxDiff));
    2128 #endif /* VNET_TX_DELAY */
     2140    LogRel(("TxTimer stats (avg/min/max): %7d usec %7d usec %7d usec\n", pThis->u32AvgDiff, pThis->u32MinDiff, pThis->u32MaxDiff));
     2141#endif
     2142
    21292143    Log(("%s Destroying instance\n", INSTANCE(pThis)));
    21302144    if (pThis->hEventMoreRxDescAvail != NIL_RTSEMEVENT)
     
    21562170     */
    21572171    pThis->hEventMoreRxDescAvail = NIL_RTSEMEVENT;
     2172#ifndef VNET_TX_DELAY
     2173    pThis->hTxEvent              = NIL_SUPSEMEVENT;
     2174    pThis->pTxThread             = NULL;
     2175#endif
    21582176
    21592177    /* Do our own locking. */
     
    21902208    Assert(pThis->cMsLinkUpDelay <= 300000); /* less than 5 minutes */
    21912209    if (pThis->cMsLinkUpDelay > 5000 || pThis->cMsLinkUpDelay < 100)
    2192         LogRel(("%s WARNING! Link up delay is set to %u seconds!\n",
    2193                 INSTANCE(pThis), pThis->cMsLinkUpDelay / 1000));
    2194     Log(("%s Link up delay is set to %u seconds\n",
    2195          INSTANCE(pThis), pThis->cMsLinkUpDelay / 1000));
    2196 
    2197     vnetPrintFeatures(pThis, vnetIoCb_GetHostFeatures(pThis), "Device supports the following features");
     2210        LogRel(("%s WARNING! Link up delay is set to %u seconds!\n", INSTANCE(pThis), pThis->cMsLinkUpDelay / 1000));
     2211    Log(("%s Link up delay is set to %u seconds\n", INSTANCE(pThis), pThis->cMsLinkUpDelay / 1000));
     2212
     2213    vnetPrintFeatures(pThis, vnetIoCb_GetHostFeatures(&pThis->VPCI), "Device supports the following features");
    21982214
    21992215    /* Initialize PCI config space */
     
    22442260    AssertRCReturn(rc, rc);
    22452261
    2246 #ifndef VNET_TX_DELAY
    2247     pThis->pSupDrvSession = PDMDevHlpGetSupDrvSession(pDevIns);
    2248     pThis->hTxEvent       = NIL_SUPSEMEVENT;
    2249     pThis->pTxThread      = NULL;
    2250 #else /* VNET_TX_DELAY */
     2262#ifdef VNET_TX_DELAY
    22512263    /* Create Transmit Delay Timer */
    22522264    rc = PDMDevHlpTMTimerCreate(pDevIns, TMCLOCK_VIRTUAL, vnetR3TxTimer, pThis, TMTIMER_FLAGS_NO_CRIT_SECT,
     
    22862298    AssertRCReturn(rc, rc);
    22872299
    2288     rc = vnetIoCb_Reset(pThis);
     2300    rc = vnetIoCb_Reset(&pThis->VPCI);
    22892301    AssertRCReturn(rc, rc);
    22902302
  • trunk/src/VBox/Devices/VirtIO/Virtio.cpp

    r81031 r81703  
    362362
    363363
    364 DECLINLINE(uint32_t) vpciGetHostFeatures(PVPCISTATE pState,
    365                                          PFNGETHOSTFEATURES pfnGetHostFeatures)
    366 {
    367     return pfnGetHostFeatures(pState)
     364DECLINLINE(uint32_t) vpciGetHostFeatures(PVPCISTATE pState, PCVPCIIOCALLBACKS  pCallbacks)
     365{
     366    return pCallbacks->pfnGetHostFeatures(pState)
    368367        | VPCI_F_NOTIFY_ON_EMPTY;
    369368}
     
    375374 *
    376375 * @param   pDevIns     The device instance.
    377  * @param   pvUser      Pointer to the device state structure.
     376 * @param   pState      The VPCI core state.
    378377 * @param   Port        Port number used for the IN operation.
    379378 * @param   pu32        Where to store the result.
     
    383382 */
    384383int vpciIOPortIn(PPDMDEVINS         pDevIns,
    385                  void              *pvUser,
     384                 PVPCISTATE         pState,
    386385                 RTIOPORT           Port,
    387386                 uint32_t          *pu32,
     
    389388                 PCVPCIIOCALLBACKS  pCallbacks)
    390389{
    391     VPCISTATE  *pState = PDMINS_2_DATA(pDevIns, VPCISTATE *);
    392     int         rc     = VINF_SUCCESS;
    393390    STAM_PROFILE_ADV_START(&pState->CTX_SUFF(StatIORead), a);
    394     RT_NOREF_PV(pvUser);
     391    int rc = VINF_SUCCESS;
    395392
    396393    /*
     
    415412        case VPCI_HOST_FEATURES:
    416413            /* Tell the guest what features we support. */
    417             *pu32 = vpciGetHostFeatures(pState, pCallbacks->pfnGetHostFeatures)
    418                     | VPCI_F_BAD_FEATURE;
     414            *pu32 = vpciGetHostFeatures(pState, pCallbacks) | VPCI_F_BAD_FEATURE;
    419415            break;
    420416
     
    473469 *
    474470 * @param   pDevIns     The device instance.
    475  * @param   pvUser      User argument.
     471 * @param   pState      The VPCI core state.
    476472 * @param   Port        Port number used for the IN operation.
    477473 * @param   u32         The value to output.
     
    480476 * @thread  EMT
    481477 */
    482 int vpciIOPortOut(PPDMDEVINS                pDevIns,
    483                   void                     *pvUser,
    484                   RTIOPORT                  Port,
    485                   uint32_t                  u32,
    486                   unsigned                  cb,
    487                   PCVPCIIOCALLBACKS         pCallbacks)
    488 {
    489     VPCISTATE  *pState = PDMINS_2_DATA(pDevIns, VPCISTATE *);
    490     int         rc     = VINF_SUCCESS;
    491     bool        fHasBecomeReady;
     478int vpciIOPortOut(PPDMDEVINS         pDevIns,
     479                  PVPCISTATE         pState,
     480                  RTIOPORT           Port,
     481                  uint32_t           u32,
     482                  unsigned           cb,
     483                  PCVPCIIOCALLBACKS  pCallbacks)
     484{
    492485    STAM_PROFILE_ADV_START(&pState->CTX_SUFF(StatIOWrite), a);
    493     RT_NOREF_PV(pvUser);
     486    int  rc = VINF_SUCCESS;
     487    bool fHasBecomeReady;
    494488
    495489    Port -= pState->IOPortBase;
     
    500494        case VPCI_GUEST_FEATURES:
    501495        {
    502             const uint32_t uHostFeatures = vpciGetHostFeatures(pState, pCallbacks->pfnGetHostFeatures);
    503 
    504             if (RT_LIKELY((u32 & ~uHostFeatures) == 0))
     496            const uint32_t fHostFeatures = vpciGetHostFeatures(pState, pCallbacks);
     497
     498            if (RT_LIKELY((u32 & ~fHostFeatures) == 0))
    505499            {
    506500                pState->uGuestFeatures = u32;
     
    522516                {
    523517                    Log(("%s Guest asked for features host does not support! (host=%x guest=%x)\n",
    524                          INSTANCE(pState), uHostFeatures, u32));
    525                     pState->uGuestFeatures = u32 & uHostFeatures;
     518                         INSTANCE(pState), fHostFeatures, u32));
     519                    pState->uGuestFeatures = u32 & fHostFeatures;
    526520                }
    527521            }
     
    565559                    // if (RT_LIKELY(rc == VINF_SUCCESS))
    566560                    // {
    567                         pState->Queues[u32].pfnCallback(pState, &pState->Queues[u32]);
     561                        pState->Queues[u32].pfnCallback(pDevIns, pState, &pState->Queues[u32]);
    568562                    //     vpciCsLeave(pState);
    569563                    // }
  • trunk/src/VBox/Devices/VirtIO/Virtio.h

    r81031 r81703  
    2222#endif
    2323
    24 #include <iprt/ctype.h>
     24#include <iprt/types.h>
     25
     26
     27/** Pointer to the core (/common) state of a VirtIO PCI device. */
     28typedef struct VPCISTATE *PVPCISTATE;
    2529
    2630
     
    120124 * Queue callback (consumer?).
    121125 *
    122  * @param   pvState         Pointer to the VirtIO PCI core state, VPCISTATE.
     126 * @param   pDevIns         The device instance.
     127 * @param   pVPciState      Pointer to the VirtIO PCI core state.
    123128 * @param   pQueue          Pointer to the queue structure.
    124129 */
    125 typedef DECLCALLBACK(void) FNVPCIQUEUECALLBACK(void *pvState, struct VQueue *pQueue);
     130typedef DECLCALLBACK(void) FNVPCIQUEUECALLBACK(PPDMDEVINS pDevIns, PVPCISTATE pVPciState, struct VQueue *pQueue);
    126131/** Pointer to a VQUEUE callback function. */
    127132typedef FNVPCIQUEUECALLBACK *PFNVPCIQUEUECALLBACK;
     
    169174 * @implements  PDMILEDPORTS
    170175 */
    171 typedef struct VPCIState_st
     176typedef struct VPCISTATE
    172177{
    173178    PDMCRITSECT            cs;      /**< Critical section - what is it protecting? */
     
    213218    VQUEUE                 Queues[VIRTIO_MAX_NQUEUES];
    214219
    215 #if defined(VBOX_WITH_STATISTICS)
     220#ifdef VBOX_WITH_STATISTICS
    216221    STAMPROFILEADV         StatIOReadR3;
    217222    STAMPROFILEADV         StatIOReadR0;
     
    225230    STAMPROFILE            StatCsR0;
    226231    STAMPROFILE            StatCsRC;
    227 #endif /* VBOX_WITH_STATISTICS */
     232#endif
    228233} VPCISTATE;
    229 /** Pointer to the core (/common) state of a VirtIO PCI device. */
    230 typedef VPCISTATE *PVPCISTATE;
    231 
    232 typedef DECLCALLBACK(uint32_t) FNGETHOSTFEATURES(void *pvState);
    233 typedef FNGETHOSTFEATURES *PFNGETHOSTFEATURES;
    234234
    235235/** @name VirtIO port I/O callbacks.
     
    237237typedef struct VPCIIOCALLBACKS
    238238{
    239      DECLCALLBACKMEMBER(uint32_t, pfnGetHostFeatures)(void *pvState);
    240      DECLCALLBACKMEMBER(uint32_t, pfnGetHostMinimalFeatures)(void *pvState);
    241      DECLCALLBACKMEMBER(void,     pfnSetHostFeatures)(void *pvState, uint32_t fFeatures);
    242      DECLCALLBACKMEMBER(int,      pfnGetConfig)(void *pvState, uint32_t offCfg, uint32_t cb, void *pvData);
    243      DECLCALLBACKMEMBER(int,      pfnSetConfig)(void *pvState, uint32_t offCfg, uint32_t cb, void *pvData);
    244      DECLCALLBACKMEMBER(int,      pfnReset)(void *pvState);
    245      DECLCALLBACKMEMBER(void,     pfnReady)(void *pvState);
     239     DECLCALLBACKMEMBER(uint32_t, pfnGetHostFeatures)(PVPCISTATE pVPciState);
     240     DECLCALLBACKMEMBER(uint32_t, pfnGetHostMinimalFeatures)(PVPCISTATE pVPciState);
     241     DECLCALLBACKMEMBER(void,     pfnSetHostFeatures)(PVPCISTATE pVPciState, uint32_t fFeatures);
     242     DECLCALLBACKMEMBER(int,      pfnGetConfig)(PVPCISTATE pVPciState, uint32_t offCfg, uint32_t cb, void *pvData);
     243     DECLCALLBACKMEMBER(int,      pfnSetConfig)(PVPCISTATE pVPciState, uint32_t offCfg, uint32_t cb, void *pvData);
     244     DECLCALLBACKMEMBER(int,      pfnReset)(PVPCISTATE pVPciState);
     245     DECLCALLBACKMEMBER(void,     pfnReady)(PVPCISTATE pVPciState);
    246246} VPCIIOCALLBACKS;
    247247/** Pointer to a const VirtIO port I/O callback structure. */
     
    251251int vpciRaiseInterrupt(VPCISTATE *pState, int rcBusy, uint8_t u8IntCause);
    252252int vpciIOPortIn(PPDMDEVINS         pDevIns,
    253                  void              *pvUser,
     253                 PVPCISTATE         pState,
    254254                 RTIOPORT           port,
    255255                 uint32_t          *pu32,
     
    257257                 PCVPCIIOCALLBACKS  pCallbacks);
    258258
    259 int vpciIOPortOut(PPDMDEVINS                pDevIns,
    260                   void                     *pvUser,
    261                   RTIOPORT                  port,
    262                   uint32_t                  u32,
    263                   unsigned                  cb,
    264                   PCVPCIIOCALLBACKS         pCallbacks);
     259int vpciIOPortOut(PPDMDEVINS        pDevIns,
     260                  PVPCISTATE        pState,
     261                  RTIOPORT          port,
     262                  uint32_t          u32,
     263                  unsigned          cb,
     264                  PCVPCIIOCALLBACKS pCallbacks);
    265265
    266266void  vpciSetWriteLed(PVPCISTATE pState, bool fOn);
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