VirtualBox

Changeset 92077 in vbox for trunk/src/VBox/Devices/testcase


Ignore:
Timestamp:
Oct 26, 2021 11:35:37 AM (3 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
147890
Message:

Devices/testcase/tstDevice: Started working on supporting R0 device instances, bugref:9006

Location:
trunk/src/VBox/Devices/testcase
Files:
1 added
2 edited

Legend:

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

    r92000 r92077  
    4747*********************************************************************************************************************************/
    4848
     49#define PDM_MAX_DEVICE_INSTANCE_SIZE      _4M
     50
    4951
    5052/*********************************************************************************************************************************
     
    143145/** Pointer to a PDM module descriptor. */
    144146typedef TSTDEVPDMMOD *PTSTDEVPDMMOD;
    145 /** Pointer to a const PDM module descriptor. */
    146 typedef const TSTDEVPDMMOD *PCTSTDEVPDMMOD;
    147 
    148 /**
    149  * PDM device descriptor.
    150  */
    151 typedef struct TSTDEVPDMDEV
    152 {
    153     /** Node for the known device list. */
    154     RTLISTNODE                      NdPdmDevs;
    155     /** Pointer to the PDM module containing the device. */
    156     PCTSTDEVPDMMOD                  pPdmMod;
    157     /** Device registration structure. */
    158     const PDMDEVREG                 *pReg;
    159 } TSTDEVPDMDEV;
    160 /** Pointer to a PDM device descriptor .*/
    161 typedef TSTDEVPDMDEV *PTSTDEVPDMDEV;
    162 /** Pointer to a constant PDM device descriptor .*/
    163 typedef const TSTDEVPDMDEV *PCTSTDEVPDMDEV;
    164147
    165148
     
    206189/** List of registered PDM modules. */
    207190RTLISTANCHOR g_LstPdmMods;
     191/** List of registered PDM R0 modules. */
     192RTLISTANCHOR g_LstPdmR0Mods;
    208193/** List of registered PDM devices. */
    209194RTLISTANCHOR g_LstPdmDevs;
     
    417402 *
    418403 * @returns Pointer to already loaded plugin, NULL if not found.
    419  * @param   pszFilename    The filename to check.
    420  */
    421 static PCTSTDEVPDMDEV tstDevPdmDeviceFind(const char *pszName)
     404 * @param   pszFilename     The filename to check.
     405 * @param   ppR0Reg         Where to store the pointer to the R0 registration record
     406 *                          if existing, optional.
     407 */
     408DECLHIDDEN(PCTSTDEVPDMDEV) tstDevPdmDeviceFind(const char *pszName, PCPDMDEVREGR0 *ppR0Reg)
    422409{
    423410    PCTSTDEVPDMDEV pIt;
     
    425412    {
    426413        if (!RTStrCmp(pIt->pReg->szName, pszName))
     414        {
     415            if (ppR0Reg)
     416            {
     417                *ppR0Reg = NULL;
     418
     419                PPDMDEVMODREGR0 pItR0;
     420                RTListForEach(&g_LstPdmR0Mods, pItR0, PDMDEVMODREGR0, ListEntry)
     421                {
     422                    for (uint32_t i = 0; i < pItR0->cDevRegs; i++)
     423                    {
     424                        PCPDMDEVREGR0 pReg = pItR0->papDevRegs[i];
     425                        if (!RTStrCmp(pReg->szName, pszName))
     426                        {
     427                            *ppR0Reg = pReg;
     428                            return pIt;
     429                        }
     430                    }
     431                }
     432            }
     433
    427434            return pIt;
     435        }
    428436    }
    429437
     
    500508    int rc = VINF_SUCCESS;
    501509    PCTSTDEVPDMDEVREGCBINT pRegCB = (PCTSTDEVPDMDEVREGCBINT)pCallbacks;
    502     if (!tstDevPdmDeviceFind(pReg->szName))
     510    if (!tstDevPdmDeviceFind(pReg->szName, NULL /*ppR0Reg*/))
    503511    {
    504512        PTSTDEVPDMDEV pPdmDev = (PTSTDEVPDMDEV)RTMemAllocZ(sizeof(TSTDEVPDMDEV));
     
    620628
    621629
     630/**
     631 * The PDMR0RegisterModule() export called by loaded R0 modules.
     632 *
     633 * @returns VBox status code.
     634 * @param   hMod                    The module handle.
     635 * @param   pModReg                 The module registration structure.
     636 */
    622637static int tstDevPdmR0RegisterModule(void *hMod, PPDMDEVMODREGR0 pModReg)
    623638{
    624     /*AssertFailed();*/ RT_NOREF(hMod, pModReg);
     639    RT_NOREF(hMod);
     640    RTListAppend(&g_LstPdmR0Mods, &pModReg->ListEntry);
    625641    return VINF_SUCCESS;
    626642}
     643
    627644
    628645
     
    815832 * @returns VBox status code.
    816833 * @param   pszName                 Name of the device to create.
    817  * @param   fR0Enabled              Flag whether R0 support should be enabled for this device.
    818  * @param   fRCEnabled              Flag whether RC support should be enabled for this device.
    819834 * @param   pDut                    The device under test structure the created PDM device instance is exercised under.
    820835 */
    821 static int tstDevPdmDevCreate(const char *pszName, bool fR0Enabled, bool fRCEnabled, PTSTDEVDUTINT pDut)
     836static int tstDevPdmDevR3Create(const char *pszName, PTSTDEVDUTINT pDut)
    822837{
    823838    int rc = VINF_SUCCESS;
    824     PCTSTDEVPDMDEV pPdmDev = tstDevPdmDeviceFind(pszName);
     839    PCTSTDEVPDMDEV pPdmDev = tstDevPdmDeviceFind(pszName, NULL);
    825840    if (RT_LIKELY(pPdmDev))
    826841    {
     
    848863        pDevIns->Internal.s.pDut          = pDut;
    849864        pDevIns->cbRing3                  = cb;
    850         pDevIns->fR0Enabled               = fR0Enabled;
    851         pDevIns->fRCEnabled               = fRCEnabled;
     865        pDevIns->fR0Enabled               = false;
     866        pDevIns->fRCEnabled               = false;
    852867        pDevIns->pvInstanceDataR3         = (uint8_t *)pDevIns + offShared;
    853868        pDevIns->pvInstanceDataForR3      = &pDevIns->achInstanceData[0];
     
    884899
    885900
     901DECLHIDDEN(int) tstDevPdmDeviceR3Construct(PTSTDEVDUTINT pDut)
     902{
     903    PPDMDEVINS pDevInsR3 = pDut->pDevIns;
     904
     905    pDevInsR3->pReg                     = pDut->pPdmDev->pReg;
     906    pDevInsR3->pvInstanceDataR3         = &pDevInsR3->achInstanceData[0];
     907    pDevInsR3->pHlpR3                   = &g_tstDevPdmDevHlpR3;
     908    pDevInsR3->pCfg                     = &pDut->Cfg;
     909    pDevInsR3->Internal.s.pDut          = pDut;
     910
     911    return pDevInsR3->pReg->pfnConstruct(pDevInsR3, 0, &pDut->Cfg);
     912}
     913
     914
    886915DECLCALLBACK(void *) tstDevTestsRun_QueryInterface(PPDMIBASE pInterface, const char *pszIID)
    887916{
     
    915944        Dut.SupSession.pDut = &Dut;
    916945        Dut.Cfg.pDut        = &Dut;
     946        Dut.pPdmDev         = tstDevPdmDeviceFind(pDevTstCfg->pszDevName, NULL /*ppPdmDevR0*/);
    917947
    918948        Dut.IBaseSts.pfnQueryInterface = tstDevTestsRun_QueryInterface;
     
    932962        AssertRC(rc);
    933963
    934         rc = tstDevPdmDevCreate(pDevTstCfg->pszDevName, pTest->fR0Enabled, pTest->fRCEnabled, &Dut);
     964        if (!pTest->fR0Enabled)
     965            rc = tstDevPdmDevR3Create(pDevTstCfg->pszDevName, &Dut);
     966        else
     967            rc = tstDevPdmDevR0R3Create(pDevTstCfg->pszDevName, pTest->fRCEnabled, &Dut);
    935968        if (RT_SUCCESS(rc))
    936969        {
     
    959992        RTListInit(&g_LstTestcases);
    960993        RTListInit(&g_LstPdmMods);
     994        RTListInit(&g_LstPdmR0Mods);
    961995        RTListInit(&g_LstPdmDevs);
    962996
  • trunk/src/VBox/Devices/testcase/tstDeviceInternal.h

    r92000 r92077  
    3333RT_C_DECLS_BEGIN
    3434
     35#define PDM_MAX_DEVICE_INSTANCE_SIZE      _4M
    3536
    3637/** Converts PDM device instance to the device under test structure. */
     
    3940/** Forward declaration of internal test device instance data. */
    4041typedef struct TSTDEVDUTINT *PTSTDEVDUTINT;
     42
     43
     44/** Pointer to a const PDM module descriptor. */
     45typedef const struct TSTDEVPDMMOD *PCTSTDEVPDMMOD;
     46
     47
     48/**
     49 * PDM device descriptor.
     50 */
     51typedef struct TSTDEVPDMDEV
     52{
     53    /** Node for the known device list. */
     54    RTLISTNODE                      NdPdmDevs;
     55    /** Pointer to the PDM module containing the device. */
     56    PCTSTDEVPDMMOD                  pPdmMod;
     57    /** Device registration structure. */
     58    const struct PDMDEVREGR3        *pReg;
     59} TSTDEVPDMDEV;
     60/** Pointer to a PDM device descriptor .*/
     61typedef TSTDEVPDMDEV *PTSTDEVPDMDEV;
     62/** Pointer to a constant PDM device descriptor .*/
     63typedef const TSTDEVPDMDEV *PCTSTDEVPDMDEV;
    4164
    4265
     
    334357
    335358
     359#ifdef IN_RING3
    336360/**
    337361 * Registered SSM handlers.
     
    357381/** Pointer to a const SSM handler. */
    358382typedef const TSTDEVDUTSSM *PCTSTDEVDUTSSM;
     383#endif
    359384
    360385
     
    442467    /** Pointer to the test this device is running under. */
    443468    PCTSTDEVTEST                    pTest;
     469    /** The PDM device registration record. */
     470    PCTSTDEVPDMDEV                  pPdmDev;
    444471    /** Pointer to the PDM device instance. */
    445     PPDMDEVINS                      pDevIns;
     472    struct PDMDEVINSR3             *pDevIns;
     473    /** Pointer to the PDM R0 device instance. */
     474    struct PDMDEVINSR0             *pDevInsR0;
    446475    /** CFGM root config node for the device. */
    447476    CFGMNODE                        Cfg;
     
    478507
    479508
     509#ifdef IN_RING3
    480510extern const PDMDEVHLPR3 g_tstDevPdmDevHlpR3;
     511#elif defined(IN_RING0)
     512//extern const PDMDEVHLPR0 g_tstDevPdmDevHlpR0;
     513#endif
    481514
    482515
     
    527560
    528561
     562DECLHIDDEN(PCTSTDEVPDMDEV) tstDevPdmDeviceFind(const char *pszName, PCPDMDEVREGR0 *ppR0Reg);
     563DECLHIDDEN(int) tstDevPdmDeviceR3Construct(PTSTDEVDUTINT pDut);
     564
     565DECLHIDDEN(int) tstDevPdmDevR0R3Create(const char *pszName, bool fRCEnabled, PTSTDEVDUTINT pDut);
     566
     567
    529568RT_C_DECLS_END
    530569
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