VirtualBox

Changeset 82904 in vbox for trunk


Ignore:
Timestamp:
Jan 29, 2020 12:19:30 PM (5 years ago)
Author:
vboxsync
Message:

Devices/tstDevice: Continue stubbing/implementing more PDM device helper callbacks, bugref:9006

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/testcase/tstDevice.cpp

    r82902 r82904  
    849849        AssertRC(rc);
    850850
     851        rc = RTCritSectInitEx(&Dut.CritSectNop.s.CritSect, RTCRITSECT_FLAGS_NOP, NIL_RTLOCKVALCLASS, RTLOCKVAL_SUB_CLASS_NONE, "DutNop");
     852        AssertRC(rc);
     853
    851854        PPDMCRITSECT pCritSect;
    852855        /* Figure out how much we need. */
  • trunk/src/VBox/Devices/testcase/tstDeviceInternal.h

    r82902 r82904  
    149149    /** Flags. */
    150150    uint32_t             fFlags;
     151    /** Assigned critical section. */
     152    PPDMCRITSECT         pCritSect;
    151153    /** @todo: */
    152154} TMTIMER;
     
    220222/** Pointer to a const I/O port handler. */
    221223typedef const RTDEVDUTIOPORT *PCRTDEVDUTIOPORT;
     224
     225
     226/**
     227 * Registered SSM handlers.
     228 */
     229typedef struct TSTDEVDUTSSM
     230{
     231    /** Node for the list of registered SSM handlers. */
     232    RTLISTNODE                      NdSsm;
     233    /** Version */
     234    uint32_t                        uVersion;
     235    PFNSSMDEVLIVEPREP               pfnLivePrep;
     236    PFNSSMDEVLIVEEXEC               pfnLiveExec;
     237    PFNSSMDEVLIVEVOTE               pfnLiveVote;
     238    PFNSSMDEVSAVEPREP               pfnSavePrep;
     239    PFNSSMDEVSAVEEXEC               pfnSaveExec;
     240    PFNSSMDEVSAVEDONE               pfnSaveDone;
     241    PFNSSMDEVLOADPREP               pfnLoadPrep;
     242    PFNSSMDEVLOADEXEC               pfnLoadExec;
     243    PFNSSMDEVLOADDONE               pfnLoadDone;
     244} TSTDEVDUTSSM;
     245/** Pointer to the registered SSM handlers. */
     246typedef TSTDEVDUTSSM *PTSTDEVDUTSSM;
     247/** Pointer to a const SSM handler. */
     248typedef const TSTDEVDUTSSM *PCTSTDEVDUTSSM;
     249
    222250
    223251/**
     
    320348    /** List of PDM threads. */
    321349    RTLISTANCHOR                    LstPdmThreads;
     350    /** List of SSM handlers (just one normally). */
     351    RTLISTANCHOR                    LstSsmHandlers;
    322352    /** The SUP session we emulate. */
    323353    TSTDEVSUPDRVSESSION             SupSession;
     354    /** The NOP critical section. */
     355    PDMCRITSECT                     CritSectNop;
    324356    /** The VM state associated with this device. */
    325357    PVM                             pVm;
  • trunk/src/VBox/Devices/testcase/tstDevicePdmDevHlp.cpp

    r82903 r82904  
    122122             pvUser, pszDesc, pszDesc, paExtDescs, phIoPorts));
    123123
    124     int rc = VERR_NOT_IMPLEMENTED;
    125     AssertFailed();
     124    /** @todo Verify there is no overlapping. */
     125
     126    RT_NOREF(pszDesc);
     127    int rc = VINF_SUCCESS;
     128    PRTDEVDUTIOPORT pIoPort = (PRTDEVDUTIOPORT)RTMemAllocZ(sizeof(RTDEVDUTIOPORT));
     129    if (RT_LIKELY(pIoPort))
     130    {
     131        pIoPort->cPorts      = cPorts;
     132        pIoPort->pvUserR3    = pvUser;
     133        pIoPort->pfnOutR3    = pfnOut;
     134        pIoPort->pfnInR3     = pfnIn;
     135        pIoPort->pfnOutStrR3 = pfnOutStr;
     136        pIoPort->pfnInStrR3  = pfnInStr;
     137        RTListAppend(&pDevIns->Internal.s.pDut->LstIoPorts, &pIoPort->NdIoPorts);
     138        *phIoPorts = (IOMIOPORTHANDLE)pIoPort;
     139    }
     140    else
     141        rc = VERR_NO_MEMORY;
    126142
    127143    LogFlow(("pdmR3DevHlp_IoPortCreateEx: caller='%s'/%d: returns %Rrc (*phIoPorts=%#x)\n",
     
    137153    LogFlow(("pdmR3DevHlp_IoPortMap: caller='%s'/%d: hIoPorts=%#x Port=%#x\n", pDevIns->pReg->szName, pDevIns->iInstance, hIoPorts, Port));
    138154
    139     int rc = VERR_NOT_IMPLEMENTED;
    140     AssertFailed();
    141 
    142     LogFlow(("pdmR3DevHlp_IoPortMap: caller='%s'/%d: returns %Rrc\n", pDevIns->pReg->szName, pDevIns->iInstance, rc));
    143     return rc;
     155    PRTDEVDUTIOPORT pIoPort = (PRTDEVDUTIOPORT)hIoPorts;
     156    pIoPort->PortStart = Port;
     157
     158    LogFlow(("pdmR3DevHlp_IoPortMap: caller='%s'/%d: returns VINF_SUCCESS\n", pDevIns->pReg->szName, pDevIns->iInstance, VINF_SUCCESS));
     159    return VINF_SUCCESS;
    144160}
    145161
     
    395411             pfnLoadPrep, pfnLoadExec, pfnLoadDone));
    396412
    397     RT_NOREF(uVersion, cbGuess, pszBefore, pfnLivePrep, pfnLiveExec, pfnLiveVote, pfnSavePrep, pfnSaveExec, pfnSaveDone,
    398              pfnLoadPrep, pfnLoadExec, pfnLoadDone);
    399     int rc = VERR_NOT_IMPLEMENTED;
    400     AssertFailed();
     413    RT_NOREF(cbGuess, pszBefore);
     414    int rc = VINF_SUCCESS;
     415    PTSTDEVDUTSSM pSsm = (PTSTDEVDUTSSM)RTMemAllocZ(sizeof(*pSsm));
     416    if (RT_LIKELY(pSsm))
     417    {
     418        pSsm->uVersion      = uVersion;
     419        pSsm->pfnLivePrep   = pfnLivePrep;
     420        pSsm->pfnLiveExec   = pfnLiveExec;
     421        pSsm->pfnLiveVote   = pfnLiveVote;
     422        pSsm->pfnSavePrep   = pfnSavePrep;
     423        pSsm->pfnSaveExec   = pfnSaveExec;
     424        pSsm->pfnSaveDone   = pfnSaveDone;
     425        pSsm->pfnLoadPrep   = pfnLoadPrep;
     426        pSsm->pfnLoadExec   = pfnLoadExec;
     427        pSsm->pfnLoadDone   = pfnLoadDone;
     428        RTListAppend(&pDevIns->Internal.s.pDut->LstSsmHandlers, &pSsm->NdSsm);
     429    }
     430    else
     431        rc = VERR_NO_MEMORY;
    401432
    402433    LogFlow(("pdmR3DevHlp_SSMRegister: caller='%s'/%d: returns %Rrc\n", pDevIns->pReg->szName, pDevIns->iInstance, rc));
     
    10931124             pDevIns->pReg->szName, pDevIns->iInstance, enmClock, pfnCallback, pvUser, fFlags, pszDesc, pszDesc, phTimer));
    10941125
    1095     int rc = VERR_NOT_IMPLEMENTED;
    1096     AssertFailed();
     1126    int rc = VINF_SUCCESS;
     1127    PTMTIMERR3 pTimer = (PTMTIMERR3)RTMemAllocZ(sizeof(TMTIMER));
     1128    if (RT_LIKELY(pTimer))
     1129    {
     1130        pTimer->enmClock       = enmClock;
     1131        pTimer->pfnCallbackDev = pfnCallback;
     1132        pTimer->pvUser         = pvUser;
     1133        pTimer->fFlags         = fFlags;
     1134        RTListAppend(&pDevIns->Internal.s.pDut->LstTimers, &pTimer->NdDevTimers);
     1135        *phTimer = (TMTIMERHANDLE)pTimer;
     1136    }
     1137    else
     1138        rc = VERR_NO_MEMORY;
    10971139
    10981140    LogFlow(("pdmR3DevHlp_TimerCreate: caller='%s'/%d: returns %Rrc\n", pDevIns->pReg->szName, pDevIns->iInstance, rc));
     
    12791321{
    12801322    RT_NOREF(pDevIns, hTimer);
    1281     int rc = VERR_NOT_IMPLEMENTED;
    1282     AssertFailed();
     1323
     1324#if 1 /** @todo */
     1325    int rc = VINF_SUCCESS;
     1326#else
     1327    int rc = VERR_NOT_IMPLEMENTED;
     1328    AssertFailed();
     1329#endif
     1330
    12831331    return rc;
    12841332}
     
    13041352static DECLCALLBACK(int) pdmR3DevHlp_TimerSetCritSect(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer, PPDMCRITSECT pCritSect)
    13051353{
    1306     RT_NOREF(pDevIns, hTimer, pCritSect);
    1307     int rc = VERR_NOT_IMPLEMENTED;
    1308     AssertFailed();
    1309     return rc;
     1354    PDMDEV_ASSERT_DEVINS(pDevIns);
     1355
     1356    PTMTIMERR3 pTimer = (PTMTIMERR3)hTimer;
     1357    pTimer->pCritSect = pCritSect;
     1358    return VINF_SUCCESS;
    13101359}
    13111360
     
    28442893             pDevIns->pReg->szName, pDevIns->iInstance, iLun, pBaseInterface, ppBaseInterface, pszDesc, pszDesc));
    28452894
    2846     int rc = VERR_NOT_IMPLEMENTED;
    2847     AssertFailed();
     2895#if 1
     2896    int rc = VERR_PDM_NO_ATTACHED_DRIVER;
     2897#else
     2898    int rc = VERR_NOT_IMPLEMENTED;
     2899    AssertFailed();
     2900#endif
    28482901
    28492902    LogFlow(("pdmR3DevHlp_DriverAttach: caller='%s'/%d: returns %Rrc\n", pDevIns->pReg->szName, pDevIns->iInstance, rc));
     
    32513304             pDevIns->pReg->szName, pDevIns->iInstance, pCritSect, pszNameFmt, pszNameFmt));
    32523305
    3253     RT_NOREF(pDevIns, pCritSect, RT_SRC_POS_ARGS, pszNameFmt, va);
    3254     int rc = VERR_NOT_IMPLEMENTED;
    3255     AssertFailed();
     3306    RT_NOREF(RT_SRC_POS_ARGS, pszNameFmt, va);
     3307    int rc = RTCritSectInit(&pCritSect->s.CritSect);
    32563308
    32573309    LogFlow(("pdmR3DevHlp_CritSectInit: caller='%s'/%d: returns %Rrc\n", pDevIns->pReg->szName, pDevIns->iInstance, rc));
     
    32653317    PDMDEV_ASSERT_DEVINS(pDevIns);
    32663318
    3267     PPDMCRITSECT pCritSect = NULL;
    3268     AssertFailed();
     3319    PPDMCRITSECT pCritSect = &pDevIns->Internal.s.pDut->CritSectNop;
    32693320
    32703321    LogFlow(("pdmR3DevHlp_CritSectGetNop: caller='%s'/%d: return %p\n",
     
    33033354    /*
    33043355     * Validate input.
    3305      *
    3306      * Note! We only allow the automatically created default critical section
    3307      *       to be replaced by this API.
    33083356     */
    33093357    PDMDEV_ASSERT_DEVINS(pDevIns);
    33103358    AssertPtrReturn(pCritSect, VERR_INVALID_POINTER);
    33113359
    3312 #if 0
    3313     LogFlow(("pdmR3DevHlp_SetDeviceCritSect: caller='%s'/%d: pCritSect=%p (%s)\n",
    3314              pDevIns->pReg->szName, pDevIns->iInstance, pCritSect, pCritSect->s.pszName));
    3315 #endif
    3316 
    3317     int rc = VERR_NOT_IMPLEMENTED;
    3318     AssertFailed();
    3319 
    3320     LogFlow(("pdmR3DevHlp_SetDeviceCritSect: caller='%s'/%d: returns %Rrc\n", pDevIns->pReg->szName, pDevIns->iInstance, rc));
    3321     return rc;
     3360    LogFlow(("pdmR3DevHlp_SetDeviceCritSect: caller='%s'/%d: pCritSect=%p\n",
     3361             pDevIns->pReg->szName, pDevIns->iInstance, pCritSect));
     3362
     3363    pDevIns->pCritSectRoR3 = pCritSect;
     3364    LogFlow(("pdmR3DevHlp_SetDeviceCritSect: caller='%s'/%d: returns %Rrc\n", pDevIns->pReg->szName, pDevIns->iInstance, VINF_SUCCESS));
     3365    return VINF_SUCCESS;
    33223366}
    33233367
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