1 | /* $Id: tstDeviceSUP.cpp 76553 2019-01-01 01:45:53Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * tstDevice - Test framework for PDM devices/drivers, SUP library exports.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2017-2019 Oracle Corporation
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | * available from http://www.virtualbox.org. This file is free software;
|
---|
11 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | * General Public License (GPL) as published by the Free Software
|
---|
13 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | */
|
---|
17 |
|
---|
18 |
|
---|
19 | /*********************************************************************************************************************************
|
---|
20 | * Header Files *
|
---|
21 | *********************************************************************************************************************************/
|
---|
22 | #define LOG_GROUP LOG_GROUP_DEFAULT /** @todo */
|
---|
23 | #include <VBox/sup.h>
|
---|
24 |
|
---|
25 | #include <iprt/mem.h>
|
---|
26 | #include <iprt/semaphore.h>
|
---|
27 |
|
---|
28 | #include "tstDeviceInternal.h"
|
---|
29 |
|
---|
30 |
|
---|
31 | /*********************************************************************************************************************************
|
---|
32 | * Defined Constants And Macros *
|
---|
33 | *********************************************************************************************************************************/
|
---|
34 |
|
---|
35 |
|
---|
36 |
|
---|
37 | /*********************************************************************************************************************************
|
---|
38 | * Structures and Typedefs *
|
---|
39 | *********************************************************************************************************************************/
|
---|
40 |
|
---|
41 |
|
---|
42 |
|
---|
43 | /*********************************************************************************************************************************
|
---|
44 | * Global Variables *
|
---|
45 | *********************************************************************************************************************************/
|
---|
46 |
|
---|
47 |
|
---|
48 |
|
---|
49 | /*********************************************************************************************************************************
|
---|
50 | * Internal Functions *
|
---|
51 | *********************************************************************************************************************************/
|
---|
52 |
|
---|
53 | SUPR3DECL(int) SUPR3HardenedLdrLoadAppPriv(const char *pszFilename, PRTLDRMOD phLdrMod, uint32_t fFlags, PRTERRINFO pErrInfo)
|
---|
54 | {
|
---|
55 | RT_NOREF(fFlags, pErrInfo);
|
---|
56 | int rc = VINF_SUCCESS;
|
---|
57 |
|
---|
58 | if (!RTStrCmp(pszFilename, "VBoxVMM"))
|
---|
59 | rc = RTLdrLoad("tstDeviceVBoxVMMStubs", phLdrMod);
|
---|
60 | else
|
---|
61 | {
|
---|
62 | /* Implement loading of any missing libraries here. */
|
---|
63 | AssertFailed();
|
---|
64 | rc = VERR_NOT_FOUND;
|
---|
65 | }
|
---|
66 |
|
---|
67 | return rc;
|
---|
68 | }
|
---|
69 |
|
---|
70 |
|
---|
71 | SUPDECL(int) SUPSemEventCreate(PSUPDRVSESSION pSession, PSUPSEMEVENT phEvent)
|
---|
72 | {
|
---|
73 | PTSTDEVSUPDRVSESSION pThis = TSTDEV_PSUPDRVSESSION_2_PTSTDEVSUPDRVSESSION(pSession);
|
---|
74 | int rc = VINF_SUCCESS;
|
---|
75 | PTSTDEVSUPSEMEVENT pSupSem = (PTSTDEVSUPSEMEVENT)RTMemAllocZ(sizeof(TSTDEVSUPSEMEVENT));
|
---|
76 |
|
---|
77 | if (VALID_PTR(pSupSem))
|
---|
78 | {
|
---|
79 | pSupSem->fMulti = false;
|
---|
80 | rc = RTSemEventCreate(&pSupSem->u.hSemEvt);
|
---|
81 | if (RT_SUCCESS(rc))
|
---|
82 | {
|
---|
83 | RTListAppend(&pThis->LstSupSem, &pSupSem->NdSupSem);
|
---|
84 | *phEvent = TSTDEV_PTSTDEVSUPSEMEVENT_2_SUPSEMEVENT(pSupSem);
|
---|
85 | }
|
---|
86 | else
|
---|
87 | RTMemFree(pSupSem);
|
---|
88 | }
|
---|
89 | else
|
---|
90 | rc = VERR_NO_MEMORY;
|
---|
91 |
|
---|
92 | return rc;
|
---|
93 | }
|
---|
94 |
|
---|
95 | SUPDECL(int) SUPSemEventClose(PSUPDRVSESSION pSession, SUPSEMEVENT hEvent)
|
---|
96 | {
|
---|
97 | PTSTDEVSUPDRVSESSION pThis = TSTDEV_PSUPDRVSESSION_2_PTSTDEVSUPDRVSESSION(pSession);
|
---|
98 | PTSTDEVSUPSEMEVENT pSupSem = TSTDEV_SUPSEMEVENT_2_PTSTDEVSUPSEMEVENT(hEvent);
|
---|
99 |
|
---|
100 | PTSTDEVSUPSEMEVENT pIt;
|
---|
101 | RTListForEach(&pThis->LstSupSem, pIt, TSTDEVSUPSEMEVENT, NdSupSem)
|
---|
102 | {
|
---|
103 | if (pIt == pSupSem)
|
---|
104 | {
|
---|
105 | AssertReturn(!pSupSem->fMulti, VERR_INVALID_HANDLE);
|
---|
106 | RTListNodeRemove(&pSupSem->NdSupSem);
|
---|
107 | RTSemEventDestroy(pSupSem->u.hSemEvt);
|
---|
108 | RTMemFree(pSupSem);
|
---|
109 | return VINF_OBJECT_DESTROYED;
|
---|
110 | }
|
---|
111 | }
|
---|
112 |
|
---|
113 | AssertFailed();
|
---|
114 | return VERR_INVALID_HANDLE;
|
---|
115 | }
|
---|
116 |
|
---|
117 | SUPDECL(int) SUPSemEventSignal(PSUPDRVSESSION pSession, SUPSEMEVENT hEvent)
|
---|
118 | {
|
---|
119 | RT_NOREF(pSession);
|
---|
120 | PTSTDEVSUPSEMEVENT pSupSem = TSTDEV_SUPSEMEVENT_2_PTSTDEVSUPSEMEVENT(hEvent);
|
---|
121 | AssertReturn(!pSupSem->fMulti, VERR_INVALID_HANDLE);
|
---|
122 |
|
---|
123 | return RTSemEventSignal(pSupSem->u.hSemEvt);
|
---|
124 | }
|
---|
125 |
|
---|
126 | SUPDECL(int) SUPSemEventWait(PSUPDRVSESSION pSession, SUPSEMEVENT hEvent, uint32_t cMillies)
|
---|
127 | {
|
---|
128 | RT_NOREF(pSession);
|
---|
129 | PTSTDEVSUPSEMEVENT pSupSem = TSTDEV_SUPSEMEVENT_2_PTSTDEVSUPSEMEVENT(hEvent);
|
---|
130 | AssertReturn(!pSupSem->fMulti, VERR_INVALID_HANDLE);
|
---|
131 |
|
---|
132 | return RTSemEventWait(pSupSem->u.hSemEvt, cMillies);
|
---|
133 | }
|
---|
134 |
|
---|
135 | SUPDECL(int) SUPSemEventWaitNoResume(PSUPDRVSESSION pSession, SUPSEMEVENT hEvent, uint32_t cMillies)
|
---|
136 | {
|
---|
137 | RT_NOREF(pSession);
|
---|
138 | PTSTDEVSUPSEMEVENT pSupSem = TSTDEV_SUPSEMEVENT_2_PTSTDEVSUPSEMEVENT(hEvent);
|
---|
139 | AssertReturn(!pSupSem->fMulti, VERR_INVALID_HANDLE);
|
---|
140 |
|
---|
141 | return RTSemEventWaitNoResume(pSupSem->u.hSemEvt, cMillies);
|
---|
142 | }
|
---|
143 |
|
---|
144 | SUPDECL(int) SUPSemEventWaitNsAbsIntr(PSUPDRVSESSION pSession, SUPSEMEVENT hEvent, uint64_t uNsTimeout)
|
---|
145 | {
|
---|
146 | RT_NOREF(pSession);
|
---|
147 | PTSTDEVSUPSEMEVENT pSupSem = TSTDEV_SUPSEMEVENT_2_PTSTDEVSUPSEMEVENT(hEvent);
|
---|
148 | AssertReturn(!pSupSem->fMulti, VERR_INVALID_HANDLE);
|
---|
149 |
|
---|
150 | #if 0
|
---|
151 | return RTSemEventWaitEx(pSupSem->u.hSemEvt,
|
---|
152 | RTSEMWAIT_FLAGS_INTERRUPTIBLE | RTSEMWAIT_FLAGS_ABSOLUTE | RTSEMWAIT_FLAGS_NANOSECS,
|
---|
153 | uNsTimeout);
|
---|
154 | #else
|
---|
155 | RT_NOREF(uNsTimeout);
|
---|
156 | AssertFailed();
|
---|
157 | return VERR_NOT_IMPLEMENTED;
|
---|
158 | #endif
|
---|
159 | }
|
---|
160 |
|
---|
161 | SUPDECL(int) SUPSemEventWaitNsRelIntr(PSUPDRVSESSION pSession, SUPSEMEVENT hEvent, uint64_t cNsTimeout)
|
---|
162 | {
|
---|
163 | RT_NOREF(pSession);
|
---|
164 | PTSTDEVSUPSEMEVENT pSupSem = TSTDEV_SUPSEMEVENT_2_PTSTDEVSUPSEMEVENT(hEvent);
|
---|
165 | AssertReturn(!pSupSem->fMulti, VERR_INVALID_HANDLE);
|
---|
166 |
|
---|
167 | #if 0
|
---|
168 | return RTSemEventWaitEx(pSupSem->u.hSemEvt,
|
---|
169 | RTSEMWAIT_FLAGS_INTERRUPTIBLE | RTSEMWAIT_FLAGS_RELATIVE | RTSEMWAIT_FLAGS_NANOSECS,
|
---|
170 | cNsTimeout);
|
---|
171 | #else
|
---|
172 | RT_NOREF(cNsTimeout);
|
---|
173 | AssertFailed();
|
---|
174 | return VERR_NOT_IMPLEMENTED;
|
---|
175 | #endif
|
---|
176 | }
|
---|
177 |
|
---|
178 | SUPDECL(uint32_t) SUPSemEventGetResolution(PSUPDRVSESSION pSession)
|
---|
179 | {
|
---|
180 | RT_NOREF(pSession);
|
---|
181 | #if 0
|
---|
182 | return RTSemEventGetResolution();
|
---|
183 | #else
|
---|
184 | AssertFailed();
|
---|
185 | return 0;
|
---|
186 | #endif
|
---|
187 | }
|
---|
188 |
|
---|
189 | SUPDECL(int) SUPSemEventMultiCreate(PSUPDRVSESSION pSession, PSUPSEMEVENTMULTI phEventMulti)
|
---|
190 | {
|
---|
191 | RT_NOREF(pSession, phEventMulti);
|
---|
192 | AssertFailed();
|
---|
193 | return VERR_NOT_IMPLEMENTED;
|
---|
194 | }
|
---|
195 |
|
---|
196 | SUPDECL(int) SUPSemEventMultiClose(PSUPDRVSESSION pSession, SUPSEMEVENTMULTI hEventMulti)
|
---|
197 | {
|
---|
198 | RT_NOREF(pSession, hEventMulti);
|
---|
199 | AssertFailed();
|
---|
200 | return VERR_NOT_IMPLEMENTED;
|
---|
201 | }
|
---|
202 |
|
---|
203 | SUPDECL(int) SUPSemEventMultiSignal(PSUPDRVSESSION pSession, SUPSEMEVENTMULTI hEventMulti)
|
---|
204 | {
|
---|
205 | RT_NOREF(pSession, hEventMulti);
|
---|
206 | AssertFailed();
|
---|
207 | return VERR_NOT_IMPLEMENTED;
|
---|
208 | }
|
---|
209 |
|
---|
210 | SUPDECL(int) SUPSemEventMultiReset(PSUPDRVSESSION pSession, SUPSEMEVENTMULTI hEventMulti)
|
---|
211 | {
|
---|
212 | RT_NOREF(pSession, hEventMulti);
|
---|
213 | AssertFailed();
|
---|
214 | return VERR_NOT_IMPLEMENTED;
|
---|
215 | }
|
---|
216 |
|
---|
217 | SUPDECL(int) SUPSemEventMultiWait(PSUPDRVSESSION pSession, SUPSEMEVENTMULTI hEventMulti, uint32_t cMillies)
|
---|
218 | {
|
---|
219 | RT_NOREF(pSession, hEventMulti, cMillies);
|
---|
220 | AssertFailed();
|
---|
221 | return VERR_NOT_IMPLEMENTED;
|
---|
222 | }
|
---|
223 |
|
---|
224 | SUPDECL(int) SUPSemEventMultiWaitNoResume(PSUPDRVSESSION pSession, SUPSEMEVENTMULTI hEventMulti, uint32_t cMillies)
|
---|
225 | {
|
---|
226 | RT_NOREF(pSession, hEventMulti, cMillies);
|
---|
227 | AssertFailed();
|
---|
228 | return VERR_NOT_IMPLEMENTED;
|
---|
229 | }
|
---|
230 |
|
---|
231 | SUPDECL(int) SUPSemEventMultiWaitNsAbsIntr(PSUPDRVSESSION pSession, SUPSEMEVENTMULTI hEventMulti, uint64_t uNsTimeout)
|
---|
232 | {
|
---|
233 | RT_NOREF(pSession, hEventMulti, uNsTimeout);
|
---|
234 | AssertFailed();
|
---|
235 | return VERR_NOT_IMPLEMENTED;
|
---|
236 | }
|
---|
237 |
|
---|
238 | SUPDECL(int) SUPSemEventMultiWaitNsRelIntr(PSUPDRVSESSION pSession, SUPSEMEVENTMULTI hEventMulti, uint64_t cNsTimeout)
|
---|
239 | {
|
---|
240 | RT_NOREF(pSession, hEventMulti, cNsTimeout);
|
---|
241 | AssertFailed();
|
---|
242 | return VERR_NOT_IMPLEMENTED;
|
---|
243 | }
|
---|
244 |
|
---|
245 | SUPDECL(uint32_t) SUPSemEventMultiGetResolution(PSUPDRVSESSION pSession)
|
---|
246 | {
|
---|
247 | RT_NOREF(pSession);
|
---|
248 | AssertFailed();
|
---|
249 | return 0;
|
---|
250 | }
|
---|
251 |
|
---|