VirtualBox

source: vbox/trunk/src/VBox/Devices/testcase/tstDeviceInternal.h@ 72919

Last change on this file since 72919 was 69305, checked in by vboxsync, 7 years ago

Devices/testcase: scm updates

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 7.6 KB
Line 
1/** @file
2 * tstDevice: Shared definitions between the framework and the shim library.
3 */
4
5/*
6 * Copyright (C) 2017 Oracle Corporation
7 *
8 * This file is part of VirtualBox Open Source Edition (OSE), as
9 * available from http://www.virtualbox.org. This file is free software;
10 * you can redistribute it and/or modify it under the terms of the GNU
11 * General Public License (GPL) as published by the Free Software
12 * Foundation, in version 2 as it comes in the "COPYING" file of the
13 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
14 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
15 */
16
17#ifndef ___tstDeviceInternal_h
18#define ___tstDeviceInternal_h
19
20#include <VBox/types.h>
21#include <iprt/assert.h>
22#include <iprt/list.h>
23#include <iprt/semaphore.h>
24
25#include "tstDevicePlugin.h"
26#include "tstDeviceVMMInternal.h"
27
28RT_C_DECLS_BEGIN
29
30
31/** Converts PDM device instance to the device under test structure. */
32#define TSTDEV_PDMDEVINS_2_DUT(a_pDevIns) ((a_pDevIns)->Internal.s.pDut)
33
34/**
35 * PDM module descriptor type.
36 */
37typedef enum TSTDEVPDMMODTYPE
38{
39 /** Invalid module type. */
40 TSTDEVPDMMODTYPE_INVALID = 0,
41 /** Ring 3 module. */
42 TSTDEVPDMMODTYPE_R3,
43 /** Ring 0 module. */
44 TSTDEVPDMMODTYPE_R0,
45 /** Raw context module. */
46 TSTDEVPDMMODTYPE_RC,
47 /** 32bit hack. */
48 TSTDEVPDMMODTYPE_32BIT_HACK = 0x7fffffff
49} TSTDEVPDMMODTYPE;
50
51/**
52 * Registered I/O port access handler.
53 */
54typedef struct RTDEVDUTIOPORT
55{
56 /** Node for the list of registered handlers. */
57 RTLISTNODE NdIoPorts;
58 /** Start I/O port the handler is for. */
59 RTIOPORT PortStart;
60 /** Number of ports handled. */
61 RTIOPORT cPorts;
62 /** Opaque user data - R3. */
63 void *pvUserR3;
64 /** Out handler - R3. */
65 PFNIOMIOPORTOUT pfnOutR3;
66 /** In handler - R3. */
67 PFNIOMIOPORTIN pfnInR3;
68 /** Out string handler - R3. */
69 PFNIOMIOPORTOUTSTRING pfnOutStrR3;
70 /** In string handler - R3. */
71 PFNIOMIOPORTINSTRING pfnInStrR3;
72
73 /** Opaque user data - R0. */
74 void *pvUserR0;
75 /** Out handler - R0. */
76 PFNIOMIOPORTOUT pfnOutR0;
77 /** In handler - R0. */
78 PFNIOMIOPORTIN pfnInR0;
79 /** Out string handler - R0. */
80 PFNIOMIOPORTOUTSTRING pfnOutStrR0;
81 /** In string handler - R0. */
82 PFNIOMIOPORTINSTRING pfnInStrR0;
83
84#ifdef TSTDEV_SUPPORTS_RC
85 /** Opaque user data - RC. */
86 void *pvUserRC;
87 /** Out handler - RC. */
88 PFNIOMIOPORTOUT pfnOutRC;
89 /** In handler - RC. */
90 PFNIOMIOPORTIN pfnInRC;
91 /** Out string handler - RC. */
92 PFNIOMIOPORTOUTSTRING pfnOutStrRC;
93 /** In string handler - RC. */
94 PFNIOMIOPORTINSTRING pfnInStrRC;
95#endif
96} RTDEVDUTIOPORT;
97/** Pointer to a registered I/O port handler. */
98typedef RTDEVDUTIOPORT *PRTDEVDUTIOPORT;
99/** Pointer to a const I/O port handler. */
100typedef const RTDEVDUTIOPORT *PCRTDEVDUTIOPORT;
101
102/**
103 * The Support Driver session state.
104 */
105typedef struct TSTDEVSUPDRVSESSION
106{
107 /** Pointer to the owning device under test instance. */
108 PTSTDEVDUTINT pDut;
109 /** List of event semaphores. */
110 RTLISTANCHOR LstSupSem;
111} TSTDEVSUPDRVSESSION;
112/** Pointer to the Support Driver session state. */
113typedef TSTDEVSUPDRVSESSION *PTSTDEVSUPDRVSESSION;
114
115/** Converts a Support Driver session handle to the internal state. */
116#define TSTDEV_PSUPDRVSESSION_2_PTSTDEVSUPDRVSESSION(a_pSession) ((PTSTDEVSUPDRVSESSION)(a_pSession))
117/** Converts the internal session state to a Support Driver session handle. */
118#define TSTDEV_PTSTDEVSUPDRVSESSION_2_PSUPDRVSESSION(a_pSession) ((PSUPDRVSESSION)(a_pSession))
119
120/**
121 * Support driver event semaphore.
122 */
123typedef struct TSTDEVSUPSEMEVENT
124{
125 /** Node for the event semaphore list. */
126 RTLISTNODE NdSupSem;
127 /** Flag whether this is multi event semaphore. */
128 bool fMulti;
129 /** Event smeaphore handles depending on the flag above. */
130 union
131 {
132 RTSEMEVENT hSemEvt;
133 RTSEMEVENTMULTI hSemEvtMulti;
134 } u;
135} TSTDEVSUPSEMEVENT;
136/** Pointer to a support event semaphore state. */
137typedef TSTDEVSUPSEMEVENT *PTSTDEVSUPSEMEVENT;
138
139/** Converts a Support event semaphore handle to the internal state. */
140#define TSTDEV_SUPSEMEVENT_2_PTSTDEVSUPSEMEVENT(a_pSupSemEvt) ((PTSTDEVSUPSEMEVENT)(a_pSupSemEvt))
141/** Converts the internal session state to a Support event semaphore handle. */
142#define TSTDEV_PTSTDEVSUPSEMEVENT_2_SUPSEMEVENT(a_pSupSemEvt) ((SUPSEMEVENT)(a_pSupSemEvt))
143
144/**
145 * The contex the device under test is currently in.
146 */
147typedef enum TSTDEVDUTCTX
148{
149 /** Invalid context. */
150 TSTDEVDUTCTX_INVALID = 0,
151 /** R3 context. */
152 TSTDEVDUTCTX_R3,
153 /** R0 context. */
154 TSTDEVDUTCTX_R0,
155 /** RC context. */
156 TSTDEVDUTCTX_RC,
157 /** 32bit hack. */
158 TSTDEVDUTCTX_32BIT_HACK = 0x7fffffff
159} TSTDEVDUTCTX;
160
161/**
162 * PCI region descriptor.
163 */
164typedef struct TSTDEVDUTPCIREGION
165{
166 /** Size of the region. */
167 RTGCPHYS cbRegion;
168 /** Address space type. */
169 PCIADDRESSSPACE enmType;
170 /** Region mapping callback. */
171 PFNPCIIOREGIONMAP pfnRegionMap;
172} TSTDEVDUTPCIREGION;
173/** Pointer to a PCI region descriptor. */
174typedef TSTDEVDUTPCIREGION *PTSTDEVDUTPCIREGION;
175/** Pointer to a const PCI region descriptor. */
176typedef const TSTDEVDUTPCIREGION *PCTSTDEVDUTPCIREGION;
177
178/**
179 * Device under test instance data.
180 */
181typedef struct TSTDEVDUTINT
182{
183 /** Pointer to the testcase this device is part of. */
184 PCTSTDEVTESTCASEREG pTestcaseReg;
185 /** Pointer to the PDM device instance. */
186 PPDMDEVINS pDevIns;
187 /** Current device context. */
188 TSTDEVDUTCTX enmCtx;
189 /** Critical section protecting the lists below. */
190 RTCRITSECTRW CritSectLists;
191 /** List of registered I/O port handlers. */
192 RTLISTANCHOR LstIoPorts;
193 /** List of timers registered. */
194 RTLISTANCHOR LstTimers;
195 /** List of registered MMIO regions. */
196 RTLISTANCHOR LstMmio;
197 /** List of MM Heap allocations. */
198 RTLISTANCHOR LstMmHeap;
199 /** List of PDM threads. */
200 RTLISTANCHOR LstPdmThreads;
201 /** The SUP session we emulate. */
202 TSTDEVSUPDRVSESSION SupSession;
203 /** The VM state assoicated with this device. */
204 PVM pVm;
205 /** The registered PCI device instance if this is a PCI device. */
206 PPDMPCIDEV pPciDev;
207 /** PCI Region descriptors. */
208 TSTDEVDUTPCIREGION aPciRegions[VBOX_PCI_NUM_REGIONS];
209} TSTDEVDUTINT;
210
211
212DECLHIDDEN(int) tstDevPdmLdrGetSymbol(PTSTDEVDUTINT pThis, const char *pszMod, TSTDEVPDMMODTYPE enmModType,
213 const char *pszSymbol, PFNRT *ppfn);
214
215
216DECLINLINE(int) tstDevDutLockShared(PTSTDEVDUTINT pThis)
217{
218 return RTCritSectRwEnterShared(&pThis->CritSectLists);
219}
220
221DECLINLINE(int) tstDevDutUnlockShared(PTSTDEVDUTINT pThis)
222{
223 return RTCritSectRwLeaveShared(&pThis->CritSectLists);
224}
225
226DECLINLINE(int) tstDevDutLockExcl(PTSTDEVDUTINT pThis)
227{
228 return RTCritSectRwEnterExcl(&pThis->CritSectLists);
229}
230
231DECLINLINE(int) tstDevDutUnlockExcl(PTSTDEVDUTINT pThis)
232{
233 return RTCritSectRwLeaveExcl(&pThis->CritSectLists);
234}
235
236RT_C_DECLS_END
237
238#endif
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette