Changeset 92077 in vbox for trunk/src/VBox/Devices/testcase
- Timestamp:
- Oct 26, 2021 11:35:37 AM (3 years ago)
- svn:sync-xref-src-repo-rev:
- 147890
- Location:
- trunk/src/VBox/Devices/testcase
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/testcase/tstDevice.cpp
r92000 r92077 47 47 *********************************************************************************************************************************/ 48 48 49 #define PDM_MAX_DEVICE_INSTANCE_SIZE _4M 50 49 51 50 52 /********************************************************************************************************************************* … … 143 145 /** Pointer to a PDM module descriptor. */ 144 146 typedef 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 TSTDEVPDMDEV152 {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;164 147 165 148 … … 206 189 /** List of registered PDM modules. */ 207 190 RTLISTANCHOR g_LstPdmMods; 191 /** List of registered PDM R0 modules. */ 192 RTLISTANCHOR g_LstPdmR0Mods; 208 193 /** List of registered PDM devices. */ 209 194 RTLISTANCHOR g_LstPdmDevs; … … 417 402 * 418 403 * @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 */ 408 DECLHIDDEN(PCTSTDEVPDMDEV) tstDevPdmDeviceFind(const char *pszName, PCPDMDEVREGR0 *ppR0Reg) 422 409 { 423 410 PCTSTDEVPDMDEV pIt; … … 425 412 { 426 413 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 427 434 return pIt; 435 } 428 436 } 429 437 … … 500 508 int rc = VINF_SUCCESS; 501 509 PCTSTDEVPDMDEVREGCBINT pRegCB = (PCTSTDEVPDMDEVREGCBINT)pCallbacks; 502 if (!tstDevPdmDeviceFind(pReg->szName ))510 if (!tstDevPdmDeviceFind(pReg->szName, NULL /*ppR0Reg*/)) 503 511 { 504 512 PTSTDEVPDMDEV pPdmDev = (PTSTDEVPDMDEV)RTMemAllocZ(sizeof(TSTDEVPDMDEV)); … … 620 628 621 629 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 */ 622 637 static int tstDevPdmR0RegisterModule(void *hMod, PPDMDEVMODREGR0 pModReg) 623 638 { 624 /*AssertFailed();*/ RT_NOREF(hMod, pModReg); 639 RT_NOREF(hMod); 640 RTListAppend(&g_LstPdmR0Mods, &pModReg->ListEntry); 625 641 return VINF_SUCCESS; 626 642 } 643 627 644 628 645 … … 815 832 * @returns VBox status code. 816 833 * @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.819 834 * @param pDut The device under test structure the created PDM device instance is exercised under. 820 835 */ 821 static int tstDevPdmDev Create(const char *pszName, bool fR0Enabled, bool fRCEnabled, PTSTDEVDUTINT pDut)836 static int tstDevPdmDevR3Create(const char *pszName, PTSTDEVDUTINT pDut) 822 837 { 823 838 int rc = VINF_SUCCESS; 824 PCTSTDEVPDMDEV pPdmDev = tstDevPdmDeviceFind(pszName );839 PCTSTDEVPDMDEV pPdmDev = tstDevPdmDeviceFind(pszName, NULL); 825 840 if (RT_LIKELY(pPdmDev)) 826 841 { … … 848 863 pDevIns->Internal.s.pDut = pDut; 849 864 pDevIns->cbRing3 = cb; 850 pDevIns->fR0Enabled = f R0Enabled;851 pDevIns->fRCEnabled = f RCEnabled;865 pDevIns->fR0Enabled = false; 866 pDevIns->fRCEnabled = false; 852 867 pDevIns->pvInstanceDataR3 = (uint8_t *)pDevIns + offShared; 853 868 pDevIns->pvInstanceDataForR3 = &pDevIns->achInstanceData[0]; … … 884 899 885 900 901 DECLHIDDEN(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 886 915 DECLCALLBACK(void *) tstDevTestsRun_QueryInterface(PPDMIBASE pInterface, const char *pszIID) 887 916 { … … 915 944 Dut.SupSession.pDut = &Dut; 916 945 Dut.Cfg.pDut = &Dut; 946 Dut.pPdmDev = tstDevPdmDeviceFind(pDevTstCfg->pszDevName, NULL /*ppPdmDevR0*/); 917 947 918 948 Dut.IBaseSts.pfnQueryInterface = tstDevTestsRun_QueryInterface; … … 932 962 AssertRC(rc); 933 963 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); 935 968 if (RT_SUCCESS(rc)) 936 969 { … … 959 992 RTListInit(&g_LstTestcases); 960 993 RTListInit(&g_LstPdmMods); 994 RTListInit(&g_LstPdmR0Mods); 961 995 RTListInit(&g_LstPdmDevs); 962 996 -
trunk/src/VBox/Devices/testcase/tstDeviceInternal.h
r92000 r92077 33 33 RT_C_DECLS_BEGIN 34 34 35 #define PDM_MAX_DEVICE_INSTANCE_SIZE _4M 35 36 36 37 /** Converts PDM device instance to the device under test structure. */ … … 39 40 /** Forward declaration of internal test device instance data. */ 40 41 typedef struct TSTDEVDUTINT *PTSTDEVDUTINT; 42 43 44 /** Pointer to a const PDM module descriptor. */ 45 typedef const struct TSTDEVPDMMOD *PCTSTDEVPDMMOD; 46 47 48 /** 49 * PDM device descriptor. 50 */ 51 typedef 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 .*/ 61 typedef TSTDEVPDMDEV *PTSTDEVPDMDEV; 62 /** Pointer to a constant PDM device descriptor .*/ 63 typedef const TSTDEVPDMDEV *PCTSTDEVPDMDEV; 41 64 42 65 … … 334 357 335 358 359 #ifdef IN_RING3 336 360 /** 337 361 * Registered SSM handlers. … … 357 381 /** Pointer to a const SSM handler. */ 358 382 typedef const TSTDEVDUTSSM *PCTSTDEVDUTSSM; 383 #endif 359 384 360 385 … … 442 467 /** Pointer to the test this device is running under. */ 443 468 PCTSTDEVTEST pTest; 469 /** The PDM device registration record. */ 470 PCTSTDEVPDMDEV pPdmDev; 444 471 /** 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; 446 475 /** CFGM root config node for the device. */ 447 476 CFGMNODE Cfg; … … 478 507 479 508 509 #ifdef IN_RING3 480 510 extern const PDMDEVHLPR3 g_tstDevPdmDevHlpR3; 511 #elif defined(IN_RING0) 512 //extern const PDMDEVHLPR0 g_tstDevPdmDevHlpR0; 513 #endif 481 514 482 515 … … 527 560 528 561 562 DECLHIDDEN(PCTSTDEVPDMDEV) tstDevPdmDeviceFind(const char *pszName, PCPDMDEVREGR0 *ppR0Reg); 563 DECLHIDDEN(int) tstDevPdmDeviceR3Construct(PTSTDEVDUTINT pDut); 564 565 DECLHIDDEN(int) tstDevPdmDevR0R3Create(const char *pszName, bool fRCEnabled, PTSTDEVDUTINT pDut); 566 567 529 568 RT_C_DECLS_END 530 569
Note:
See TracChangeset
for help on using the changeset viewer.