1 | /* $Revision: 4824 $ */
|
---|
2 | /** @file
|
---|
3 | * VirtualBox Support Driver - IOCtl definitions.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2007 innotek GmbH
|
---|
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 as published by the Free Software Foundation,
|
---|
13 | * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
|
---|
14 | * distribution. VirtualBox OSE is distributed in the hope that it will
|
---|
15 | * be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | */
|
---|
17 |
|
---|
18 | #ifndef ___SUPDRVIOC_h___
|
---|
19 | #define ___SUPDRVIOC_h___
|
---|
20 |
|
---|
21 | /*
|
---|
22 | * Basic types.
|
---|
23 | */
|
---|
24 | #include <iprt/stdint.h>
|
---|
25 |
|
---|
26 | /*
|
---|
27 | * IOCtl numbers.
|
---|
28 | * We're using the Win32 type of numbers here, thus the macros below.
|
---|
29 | * The SUP_IOCTL_FLAG macro is used to separate requests from 32-bit
|
---|
30 | * and 64-bit processes.
|
---|
31 | */
|
---|
32 | #ifdef RT_ARCH_AMD64
|
---|
33 | # define SUP_IOCTL_FLAG 128
|
---|
34 | #elif defined(RT_ARCH_X86)
|
---|
35 | # define SUP_IOCTL_FLAG 0
|
---|
36 | #else
|
---|
37 | # error "dunno which arch this is!"
|
---|
38 | #endif
|
---|
39 |
|
---|
40 | #ifdef RT_OS_WINDOWS
|
---|
41 | # ifndef CTL_CODE
|
---|
42 | # include <Windows.h>
|
---|
43 | # endif
|
---|
44 | /* Automatic buffering, size not encoded. */
|
---|
45 | # define SUP_CTL_CODE_SIZE(Function, Size) CTL_CODE(FILE_DEVICE_UNKNOWN, (Function) | SUP_IOCTL_FLAG, METHOD_BUFFERED, FILE_WRITE_ACCESS)
|
---|
46 | # define SUP_CTL_CODE_BIG(Function) CTL_CODE(FILE_DEVICE_UNKNOWN, (Function) | SUP_IOCTL_FLAG, METHOD_BUFFERED, FILE_WRITE_ACCESS)
|
---|
47 | # define SUP_CTL_CODE_FAST(Function) CTL_CODE(FILE_DEVICE_UNKNOWN, (Function) | SUP_IOCTL_FLAG, METHOD_NEITHER, FILE_WRITE_ACCESS)
|
---|
48 | # define SUP_CTL_CODE_NO_SIZE(uIOCtl) (uIOCtl)
|
---|
49 |
|
---|
50 | #elif defined(RT_OS_SOLARIS)
|
---|
51 | /* No automatic buffering, size limited to 255 bytes. */
|
---|
52 | # include <sys/ioccom.h>
|
---|
53 | # define SUP_CTL_CODE_SIZE(Function, Size) _IOWRN('V', (Function) | SUP_IOCTL_FLAG, sizeof(SUPREQHDR))
|
---|
54 | # define SUP_CTL_CODE_BIG(Function) _IOWRN('V', (Function) | SUP_IOCTL_FLAG, sizeof(SUPREQHDR))
|
---|
55 | # define SUP_CTL_CODE_FAST(Function) _IO( 'V', (Function) | SUP_IOCTL_FLAG)
|
---|
56 | # define SUP_CTL_CODE_NO_SIZE(uIOCtl) (uIOCtl)
|
---|
57 |
|
---|
58 | #elif defined(RT_OS_OS2)
|
---|
59 | /* No automatic buffering, size not encoded. */
|
---|
60 | # define SUP_CTL_CATEGORY 0xc0
|
---|
61 | # define SUP_CTL_CODE_SIZE(Function, Size) ((unsigned char)(Function))
|
---|
62 | # define SUP_CTL_CODE_BIG(Function) ((unsigned char)(Function))
|
---|
63 | # define SUP_CTL_CATEGORY_FAST 0xc1
|
---|
64 | # define SUP_CTL_CODE_FAST(Function) ((unsigned char)(Function))
|
---|
65 | # define SUP_CTL_CODE_NO_SIZE(uIOCtl) (uIOCtl)
|
---|
66 |
|
---|
67 | #elif defined(RT_OS_LINUX)
|
---|
68 | /* No automatic buffering, size limited to 16KB. */
|
---|
69 | # include <linux/ioctl.h>
|
---|
70 | # define SUP_CTL_CODE_SIZE(Function, Size) _IOC(_IOC_READ | _IOC_WRITE, 'V', (Function) | SUP_IOCTL_FLAG, (Size))
|
---|
71 | # define SUP_CTL_CODE_BIG(Function) _IO('V', (Function) | SUP_IOCTL_FLAG)
|
---|
72 | # define SUP_CTL_CODE_FAST(Function) _IO('V', (Function) | SUP_IOCTL_FLAG)
|
---|
73 | # define SUP_CTL_CODE_NO_SIZE(uIOCtl) ((uIOCtl) & ~IOCSIZE_MASK)
|
---|
74 |
|
---|
75 | #elif defined(RT_OS_L4)
|
---|
76 | /* Implemented in suplib, no worries. */
|
---|
77 | # define SUP_CTL_CODE_SIZE(Function, Size) (Function)
|
---|
78 | # define SUP_CTL_CODE_BIG(Function) (Function)
|
---|
79 | # define SUP_CTL_CODE_FAST(Function) (Function)
|
---|
80 | # define SUP_CTL_CODE_NO_SIZE(uIOCtl) (uIOCtl)
|
---|
81 |
|
---|
82 | #else /* BSD Like */
|
---|
83 | /* Automatic buffering, size limited to 4KB on *BSD and 8KB on Darwin - commands the limit, 4KB. */
|
---|
84 | # include <sys/ioccom.h>
|
---|
85 | # define SUP_CTL_CODE_SIZE(Function, Size) _IOC(IOC_INOUT, 'V', (Function) | SUP_IOCTL_FLAG, (Size))
|
---|
86 | # define SUP_CTL_CODE_BIG(Function) _IO('V', (Function) | SUP_IOCTL_FLAG)
|
---|
87 | # define SUP_CTL_CODE_FAST(Function) _IO('V', (Function) | SUP_IOCTL_FLAG)
|
---|
88 | # define SUP_CTL_CODE_NO_SIZE(uIOCtl) ( (uIOCtl) & ~_IOC(0,0,0,IOCPARM_MASK) )
|
---|
89 | #endif
|
---|
90 |
|
---|
91 | /** Fast path IOCtl: VMMR0_DO_RAW_RUN */
|
---|
92 | #define SUP_IOCTL_FAST_DO_RAW_RUN SUP_CTL_CODE_FAST(64)
|
---|
93 | /** Fast path IOCtl: VMMR0_DO_HWACC_RUN */
|
---|
94 | #define SUP_IOCTL_FAST_DO_HWACC_RUN SUP_CTL_CODE_FAST(65)
|
---|
95 | /** Just a NOP call for profiling the latency of a fast ioctl call to VMMR0. */
|
---|
96 | #define SUP_IOCTL_FAST_DO_NOP SUP_CTL_CODE_FAST(66)
|
---|
97 |
|
---|
98 |
|
---|
99 |
|
---|
100 | /*******************************************************************************
|
---|
101 | * Structures and Typedefs *
|
---|
102 | *******************************************************************************/
|
---|
103 | #ifdef RT_ARCH_AMD64
|
---|
104 | # pragma pack(8) /* paranoia. */
|
---|
105 | #else
|
---|
106 | # pragma pack(4) /* paranoia. */
|
---|
107 | #endif
|
---|
108 |
|
---|
109 |
|
---|
110 | /**
|
---|
111 | * Common In/Out header.
|
---|
112 | */
|
---|
113 | typedef struct SUPREQHDR
|
---|
114 | {
|
---|
115 | /** Cookie. */
|
---|
116 | uint32_t u32Cookie;
|
---|
117 | /** Session cookie. */
|
---|
118 | uint32_t u32SessionCookie;
|
---|
119 | /** The size of the input. */
|
---|
120 | uint32_t cbIn;
|
---|
121 | /** The size of the output. */
|
---|
122 | uint32_t cbOut;
|
---|
123 | /** Flags. See SUPREQHDR_FLAGS_* for details and values. */
|
---|
124 | uint32_t fFlags;
|
---|
125 | /** The VBox status code of the operation, out direction only. */
|
---|
126 | int32_t rc;
|
---|
127 | } SUPREQHDR;
|
---|
128 | /** Pointer to a IOC header. */
|
---|
129 | typedef SUPREQHDR *PSUPREQHDR;
|
---|
130 |
|
---|
131 | /** @name SUPREQHDR::fFlags values
|
---|
132 | * @{ */
|
---|
133 | /** Masks out the magic value. */
|
---|
134 | #define SUPREQHDR_FLAGS_MAGIC_MASK UINT32_C(0xff0000ff)
|
---|
135 | /** The generic mask. */
|
---|
136 | #define SUPREQHDR_FLAGS_GEN_MASK UINT32_C(0x0000ff00)
|
---|
137 | /** The request specific mask. */
|
---|
138 | #define SUPREQHDR_FLAGS_REQ_MASK UINT32_C(0x00ff0000)
|
---|
139 |
|
---|
140 | /** There is extra input that needs copying on some platforms. */
|
---|
141 | #define SUPREQHDR_FLAGS_EXTRA_IN UINT32_C(0x00000100)
|
---|
142 | /** There is extra output that needs copying on some platforms. */
|
---|
143 | #define SUPREQHDR_FLAGS_EXTRA_OUT UINT32_C(0x00000200)
|
---|
144 |
|
---|
145 | /** The magic value. */
|
---|
146 | #define SUPREQHDR_FLAGS_MAGIC UINT32_C(0x42000042)
|
---|
147 | /** The default value. Use this when no special stuff is requested. */
|
---|
148 | #define SUPREQHDR_FLAGS_DEFAULT SUPREQHDR_FLAGS_MAGIC
|
---|
149 | /** @} */
|
---|
150 |
|
---|
151 |
|
---|
152 | /** @name SUP_IOCTL_COOKIE
|
---|
153 | * @{
|
---|
154 | */
|
---|
155 | /** Negotiate cookie. */
|
---|
156 | #define SUP_IOCTL_COOKIE SUP_CTL_CODE_SIZE(1, SUP_IOCTL_COOKIE_SIZE)
|
---|
157 | /** The request size. */
|
---|
158 | #define SUP_IOCTL_COOKIE_SIZE sizeof(SUPCOOKIE)
|
---|
159 | /** The SUPREQHDR::cbIn value. */
|
---|
160 | #define SUP_IOCTL_COOKIE_SIZE_IN sizeof(SUPREQHDR) + RT_SIZEOFMEMB(SUPCOOKIE, u.In)
|
---|
161 | /** The SUPREQHDR::cbOut value. */
|
---|
162 | #define SUP_IOCTL_COOKIE_SIZE_OUT sizeof(SUPREQHDR) + RT_SIZEOFMEMB(SUPCOOKIE, u.Out)
|
---|
163 | /** SUPCOOKIE_IN magic word. */
|
---|
164 | #define SUPCOOKIE_MAGIC "The Magic Word!"
|
---|
165 | /** The initial cookie. */
|
---|
166 | #define SUPCOOKIE_INITIAL_COOKIE 0x69726f74 /* 'tori' */
|
---|
167 |
|
---|
168 | /** Current interface version.
|
---|
169 | * The upper 16-bit is the major version, the the lower the minor version.
|
---|
170 | * When incompatible changes are made, the upper major number has to be changed. */
|
---|
171 | #define SUPDRVIOC_VERSION 0x00060000
|
---|
172 |
|
---|
173 | /** SUP_IOCTL_COOKIE. */
|
---|
174 | typedef struct SUPCOOKIE
|
---|
175 | {
|
---|
176 | /** The header.
|
---|
177 | * u32Cookie must be set to SUPCOOKIE_INITIAL_COOKIE.
|
---|
178 | * u32SessionCookie should be set to some random value. */
|
---|
179 | SUPREQHDR Hdr;
|
---|
180 | union
|
---|
181 | {
|
---|
182 | struct
|
---|
183 | {
|
---|
184 | /** Magic word. */
|
---|
185 | char szMagic[16];
|
---|
186 | /** The requested interface version number. */
|
---|
187 | uint32_t u32ReqVersion;
|
---|
188 | /** The minimum interface version number. */
|
---|
189 | uint32_t u32MinVersion;
|
---|
190 | } In;
|
---|
191 | struct
|
---|
192 | {
|
---|
193 | /** Cookie. */
|
---|
194 | uint32_t u32Cookie;
|
---|
195 | /** Session cookie. */
|
---|
196 | uint32_t u32SessionCookie;
|
---|
197 | /** Interface version for this session. */
|
---|
198 | uint32_t u32SessionVersion;
|
---|
199 | /** The actual interface version in the driver. */
|
---|
200 | uint32_t u32DriverVersion;
|
---|
201 | /** Number of functions available for the SUP_IOCTL_QUERY_FUNCS request. */
|
---|
202 | uint32_t cFunctions;
|
---|
203 | /** Session handle. */
|
---|
204 | R0PTRTYPE(PSUPDRVSESSION) pSession;
|
---|
205 | } Out;
|
---|
206 | } u;
|
---|
207 | } SUPCOOKIE, *PSUPCOOKIE;
|
---|
208 | /** @} */
|
---|
209 |
|
---|
210 |
|
---|
211 | /** @name SUP_IOCTL_QUERY_FUNCS
|
---|
212 | * Query SUPR0 functions.
|
---|
213 | * @{
|
---|
214 | */
|
---|
215 | #define SUP_IOCTL_QUERY_FUNCS(cFuncs) SUP_CTL_CODE_SIZE(2, SUP_IOCTL_QUERY_FUNCS_SIZE(cFuncs))
|
---|
216 | #define SUP_IOCTL_QUERY_FUNCS_SIZE(cFuncs) RT_OFFSETOF(SUPQUERYFUNCS, u.Out.aFunctions[(cFuncs)])
|
---|
217 | #define SUP_IOCTL_QUERY_FUNCS_SIZE_IN sizeof(SUPREQHDR)
|
---|
218 | #define SUP_IOCTL_QUERY_FUNCS_SIZE_OUT(cFuncs) SUP_IOCTL_QUERY_FUNCS_SIZE(cFuncs)
|
---|
219 |
|
---|
220 | /** A function. */
|
---|
221 | typedef struct SUPFUNC
|
---|
222 | {
|
---|
223 | /** Name - mangled. */
|
---|
224 | char szName[32];
|
---|
225 | /** Address. */
|
---|
226 | RTR0PTR pfn;
|
---|
227 | } SUPFUNC, *PSUPFUNC;
|
---|
228 |
|
---|
229 | typedef struct SUPQUERYFUNCS
|
---|
230 | {
|
---|
231 | /** The header. */
|
---|
232 | SUPREQHDR Hdr;
|
---|
233 | union
|
---|
234 | {
|
---|
235 | struct
|
---|
236 | {
|
---|
237 | /** Number of functions returned. */
|
---|
238 | uint32_t cFunctions;
|
---|
239 | /** Array of functions. */
|
---|
240 | SUPFUNC aFunctions[1];
|
---|
241 | } Out;
|
---|
242 | } u;
|
---|
243 | } SUPQUERYFUNCS, *PSUPQUERYFUNCS;
|
---|
244 | /** @} */
|
---|
245 |
|
---|
246 |
|
---|
247 | /** @name SUP_IOCTL_IDT_INSTALL
|
---|
248 | * Install IDT patch for calling processor.
|
---|
249 | * @{
|
---|
250 | */
|
---|
251 | #define SUP_IOCTL_IDT_INSTALL SUP_CTL_CODE_SIZE(3, SUP_IOCTL_IDT_INSTALL_SIZE)
|
---|
252 | #define SUP_IOCTL_IDT_INSTALL_SIZE sizeof(SUPIDTINSTALL)
|
---|
253 | #define SUP_IOCTL_IDT_INSTALL_SIZE_IN sizeof(SUPREQHDR)
|
---|
254 | #define SUP_IOCTL_IDT_INSTALL_SIZE_OUT sizeof(SUPIDTINSTALL)
|
---|
255 | typedef struct SUPIDTINSTALL
|
---|
256 | {
|
---|
257 | /** The header. */
|
---|
258 | SUPREQHDR Hdr;
|
---|
259 | union
|
---|
260 | {
|
---|
261 | struct
|
---|
262 | {
|
---|
263 | /** The IDT entry number. */
|
---|
264 | uint8_t u8Idt;
|
---|
265 | } Out;
|
---|
266 | } u;
|
---|
267 | } SUPIDTINSTALL, *PSUPIDTINSTALL;
|
---|
268 | /** @} */
|
---|
269 |
|
---|
270 |
|
---|
271 | /** @name SUP_IOCTL_IDT_REMOVE
|
---|
272 | * Remove IDT patch for calling processor.
|
---|
273 | * @{
|
---|
274 | */
|
---|
275 | #define SUP_IOCTL_IDT_REMOVE SUP_CTL_CODE_SIZE(4, SUP_IOCTL_IDT_REMOVE_SIZE)
|
---|
276 | #define SUP_IOCTL_IDT_REMOVE_SIZE sizeof(SUPIDTREMOVE)
|
---|
277 | #define SUP_IOCTL_IDT_REMOVE_SIZE_IN sizeof(SUPIDTREMOVE)
|
---|
278 | #define SUP_IOCTL_IDT_REMOVE_SIZE_OUT sizeof(SUPIDTREMOVE)
|
---|
279 | typedef struct SUPIDTREMOVE
|
---|
280 | {
|
---|
281 | /** The header. */
|
---|
282 | SUPREQHDR Hdr;
|
---|
283 | } SUPIDTREMOVE, *PSUPIDTREMOVE;
|
---|
284 | /** @}*/
|
---|
285 |
|
---|
286 |
|
---|
287 | /** @name SUP_IOCTL_LDR_OPEN
|
---|
288 | * Open an image.
|
---|
289 | * @{
|
---|
290 | */
|
---|
291 | #define SUP_IOCTL_LDR_OPEN SUP_CTL_CODE_SIZE(5, SUP_IOCTL_LDR_OPEN_SIZE)
|
---|
292 | #define SUP_IOCTL_LDR_OPEN_SIZE sizeof(SUPLDROPEN)
|
---|
293 | #define SUP_IOCTL_LDR_OPEN_SIZE_IN sizeof(SUPLDROPEN)
|
---|
294 | #define SUP_IOCTL_LDR_OPEN_SIZE_OUT (sizeof(SUPREQHDR) + RT_SIZEOFMEMB(SUPLDROPEN, u.Out))
|
---|
295 | typedef struct SUPLDROPEN
|
---|
296 | {
|
---|
297 | /** The header. */
|
---|
298 | SUPREQHDR Hdr;
|
---|
299 | union
|
---|
300 | {
|
---|
301 | struct
|
---|
302 | {
|
---|
303 | /** Size of the image we'll be loading. */
|
---|
304 | uint32_t cbImage;
|
---|
305 | /** Image name.
|
---|
306 | * This is the NAME of the image, not the file name. It is used
|
---|
307 | * to share code with other processes. (Max len is 32 chars!) */
|
---|
308 | char szName[32];
|
---|
309 | } In;
|
---|
310 | struct
|
---|
311 | {
|
---|
312 | /** The base address of the image. */
|
---|
313 | RTR0PTR pvImageBase;
|
---|
314 | /** Indicate whether or not the image requires loading. */
|
---|
315 | bool fNeedsLoading;
|
---|
316 | } Out;
|
---|
317 | } u;
|
---|
318 | } SUPLDROPEN, *PSUPLDROPEN;
|
---|
319 | /** @} */
|
---|
320 |
|
---|
321 |
|
---|
322 | /** @name SUP_IOCTL_LDR_LOAD
|
---|
323 | * Upload the image bits.
|
---|
324 | * @{
|
---|
325 | */
|
---|
326 | #define SUP_IOCTL_LDR_LOAD SUP_CTL_CODE_BIG(6)
|
---|
327 | #define SUP_IOCTL_LDR_LOAD_SIZE(cbImage) RT_OFFSETOF(SUPLDRLOAD, u.In.achImage[cbImage])
|
---|
328 | #define SUP_IOCTL_LDR_LOAD_SIZE_IN(cbImage) RT_OFFSETOF(SUPLDRLOAD, u.In.achImage[cbImage])
|
---|
329 | #define SUP_IOCTL_LDR_LOAD_SIZE_OUT sizeof(SUPREQHDR)
|
---|
330 |
|
---|
331 | /**
|
---|
332 | * Module initialization callback function.
|
---|
333 | * This is called once after the module has been loaded.
|
---|
334 | *
|
---|
335 | * @returns 0 on success.
|
---|
336 | * @returns Appropriate error code on failure.
|
---|
337 | */
|
---|
338 | typedef DECLCALLBACK(int) FNR0MODULEINIT(void);
|
---|
339 | /** Pointer to a FNR0MODULEINIT(). */
|
---|
340 | typedef R0PTRTYPE(FNR0MODULEINIT *) PFNR0MODULEINIT;
|
---|
341 |
|
---|
342 | /**
|
---|
343 | * Module termination callback function.
|
---|
344 | * This is called once right before the module is being unloaded.
|
---|
345 | */
|
---|
346 | typedef DECLCALLBACK(void) FNR0MODULETERM(void);
|
---|
347 | /** Pointer to a FNR0MODULETERM(). */
|
---|
348 | typedef R0PTRTYPE(FNR0MODULETERM *) PFNR0MODULETERM;
|
---|
349 |
|
---|
350 | /**
|
---|
351 | * Symbol table entry.
|
---|
352 | */
|
---|
353 | typedef struct SUPLDRSYM
|
---|
354 | {
|
---|
355 | /** Offset into of the string table. */
|
---|
356 | uint32_t offName;
|
---|
357 | /** Offset of the symbol relative to the image load address. */
|
---|
358 | uint32_t offSymbol;
|
---|
359 | } SUPLDRSYM, *PSUPLDRSYM;
|
---|
360 |
|
---|
361 | /**
|
---|
362 | * SUPLDRLOAD::u::In::EP type.
|
---|
363 | */
|
---|
364 | typedef enum SUPLDRLOADEP
|
---|
365 | {
|
---|
366 | SUPLDRLOADEP_NOTHING = 0,
|
---|
367 | SUPLDRLOADEP_VMMR0,
|
---|
368 | SUPLDRLOADEP_32BIT_HACK = 0x7fffffff
|
---|
369 | } SUPLDRLOADEP;
|
---|
370 |
|
---|
371 | typedef struct SUPLDRLOAD
|
---|
372 | {
|
---|
373 | /** The header. */
|
---|
374 | SUPREQHDR Hdr;
|
---|
375 | union
|
---|
376 | {
|
---|
377 | struct
|
---|
378 | {
|
---|
379 | /** The address of module initialization function. Similar to _DLL_InitTerm(hmod, 0). */
|
---|
380 | PFNR0MODULEINIT pfnModuleInit;
|
---|
381 | /** The address of module termination function. Similar to _DLL_InitTerm(hmod, 1). */
|
---|
382 | PFNR0MODULETERM pfnModuleTerm;
|
---|
383 | /** Special entry points. */
|
---|
384 | union
|
---|
385 | {
|
---|
386 | struct
|
---|
387 | {
|
---|
388 | /** The module handle (i.e. address). */
|
---|
389 | RTR0PTR pvVMMR0;
|
---|
390 | /** Address of VMMR0EntryInt function. */
|
---|
391 | RTR0PTR pvVMMR0EntryInt;
|
---|
392 | /** Address of VMMR0EntryFast function. */
|
---|
393 | RTR0PTR pvVMMR0EntryFast;
|
---|
394 | /** Address of VMMR0EntryEx function. */
|
---|
395 | RTR0PTR pvVMMR0EntryEx;
|
---|
396 | } VMMR0;
|
---|
397 | } EP;
|
---|
398 | /** Address. */
|
---|
399 | RTR0PTR pvImageBase;
|
---|
400 | /** Entry point type. */
|
---|
401 | SUPLDRLOADEP eEPType;
|
---|
402 | /** The offset of the symbol table. */
|
---|
403 | uint32_t offSymbols;
|
---|
404 | /** The number of entries in the symbol table. */
|
---|
405 | uint32_t cSymbols;
|
---|
406 | /** The offset of the string table. */
|
---|
407 | uint32_t offStrTab;
|
---|
408 | /** Size of the string table. */
|
---|
409 | uint32_t cbStrTab;
|
---|
410 | /** Size of image (including string and symbol tables). */
|
---|
411 | uint32_t cbImage;
|
---|
412 | /** The image data. */
|
---|
413 | char achImage[1];
|
---|
414 | } In;
|
---|
415 | } u;
|
---|
416 | } SUPLDRLOAD, *PSUPLDRLOAD;
|
---|
417 | /** @} */
|
---|
418 |
|
---|
419 |
|
---|
420 | /** @name SUP_IOCTL_LDR_FREE
|
---|
421 | * Free an image.
|
---|
422 | * @{
|
---|
423 | */
|
---|
424 | #define SUP_IOCTL_LDR_FREE SUP_CTL_CODE_SIZE(7, SUP_IOCTL_LDR_FREE_SIZE)
|
---|
425 | #define SUP_IOCTL_LDR_FREE_SIZE sizeof(SUPLDRFREE)
|
---|
426 | #define SUP_IOCTL_LDR_FREE_SIZE_IN sizeof(SUPLDRFREE)
|
---|
427 | #define SUP_IOCTL_LDR_FREE_SIZE_OUT sizeof(SUPREQHDR)
|
---|
428 | typedef struct SUPLDRFREE
|
---|
429 | {
|
---|
430 | /** The header. */
|
---|
431 | SUPREQHDR Hdr;
|
---|
432 | union
|
---|
433 | {
|
---|
434 | struct
|
---|
435 | {
|
---|
436 | /** Address. */
|
---|
437 | RTR0PTR pvImageBase;
|
---|
438 | } In;
|
---|
439 | } u;
|
---|
440 | } SUPLDRFREE, *PSUPLDRFREE;
|
---|
441 | /** @} */
|
---|
442 |
|
---|
443 |
|
---|
444 | /** @name SUP_IOCTL_LDR_GET_SYMBOL
|
---|
445 | * Get address of a symbol within an image.
|
---|
446 | * @{
|
---|
447 | */
|
---|
448 | #define SUP_IOCTL_LDR_GET_SYMBOL SUP_CTL_CODE_SIZE(8, SUP_IOCTL_LDR_GET_SYMBOL_SIZE)
|
---|
449 | #define SUP_IOCTL_LDR_GET_SYMBOL_SIZE sizeof(SUPLDRGETSYMBOL)
|
---|
450 | #define SUP_IOCTL_LDR_GET_SYMBOL_SIZE_IN sizeof(SUPLDRGETSYMBOL)
|
---|
451 | #define SUP_IOCTL_LDR_GET_SYMBOL_SIZE_OUT (sizeof(SUPREQHDR) + RT_SIZEOFMEMB(SUPLDRGETSYMBOL, u.Out))
|
---|
452 | typedef struct SUPLDRGETSYMBOL
|
---|
453 | {
|
---|
454 | /** The header. */
|
---|
455 | SUPREQHDR Hdr;
|
---|
456 | union
|
---|
457 | {
|
---|
458 | struct
|
---|
459 | {
|
---|
460 | /** Address. */
|
---|
461 | RTR0PTR pvImageBase;
|
---|
462 | /** The symbol name. */
|
---|
463 | char szSymbol[64];
|
---|
464 | } In;
|
---|
465 | struct
|
---|
466 | {
|
---|
467 | /** The symbol address. */
|
---|
468 | RTR0PTR pvSymbol;
|
---|
469 | } Out;
|
---|
470 | } u;
|
---|
471 | } SUPLDRGETSYMBOL, *PSUPLDRGETSYMBOL;
|
---|
472 | /** @} */
|
---|
473 |
|
---|
474 |
|
---|
475 | /** @name SUP_IOCTL_CALL_VMMR0
|
---|
476 | * Call the R0 VMM Entry point.
|
---|
477 | *
|
---|
478 | * @todo Might have to convert this to a big request...
|
---|
479 | * @{
|
---|
480 | */
|
---|
481 | #define SUP_IOCTL_CALL_VMMR0(cbReq) SUP_CTL_CODE_SIZE(9, SUP_IOCTL_CALL_VMMR0_SIZE(cbReq))
|
---|
482 | #define SUP_IOCTL_CALL_VMMR0_SIZE(cbReq) RT_OFFSETOF(SUPCALLVMMR0, abReqPkt[cbReq])
|
---|
483 | #define SUP_IOCTL_CALL_VMMR0_SIZE_IN(cbReq) SUP_IOCTL_CALL_VMMR0_SIZE(cbReq)
|
---|
484 | #define SUP_IOCTL_CALL_VMMR0_SIZE_OUT(cbReq) SUP_IOCTL_CALL_VMMR0_SIZE(cbReq)
|
---|
485 | typedef struct SUPCALLVMMR0
|
---|
486 | {
|
---|
487 | /** The header. */
|
---|
488 | SUPREQHDR Hdr;
|
---|
489 | union
|
---|
490 | {
|
---|
491 | struct
|
---|
492 | {
|
---|
493 | /** The VM handle. */
|
---|
494 | PVMR0 pVMR0;
|
---|
495 | /** Which operation to execute. */
|
---|
496 | uint32_t uOperation;
|
---|
497 | #if R0_ARCH_BITS == 64
|
---|
498 | /** Alignment. */
|
---|
499 | uint32_t u32Reserved;
|
---|
500 | #endif
|
---|
501 | /** Argument to use when no request packet is supplied. */
|
---|
502 | uint64_t u64Arg;
|
---|
503 | } In;
|
---|
504 | } u;
|
---|
505 | /** The VMMR0Entry request packet. */
|
---|
506 | uint8_t abReqPkt[1];
|
---|
507 | } SUPCALLVMMR0, *PSUPCALLVMMR0;
|
---|
508 | /** @} */
|
---|
509 |
|
---|
510 |
|
---|
511 | /** @name SUP_IOCTL_LOW_ALLOC
|
---|
512 | * Allocate memory below 4GB (physically).
|
---|
513 | * @{
|
---|
514 | */
|
---|
515 | #define SUP_IOCTL_LOW_ALLOC SUP_CTL_CODE_BIG(10)
|
---|
516 | #define SUP_IOCTL_LOW_ALLOC_SIZE(cPages) ((uint32_t)RT_OFFSETOF(SUPLOWALLOC, u.Out.aPages[cPages]))
|
---|
517 | #define SUP_IOCTL_LOW_ALLOC_SIZE_IN (sizeof(SUPREQHDR) + RT_SIZEOFMEMB(SUPLOWALLOC, u.In))
|
---|
518 | #define SUP_IOCTL_LOW_ALLOC_SIZE_OUT(cPages) SUP_IOCTL_LOW_ALLOC_SIZE(cPages)
|
---|
519 | typedef struct SUPLOWALLOC
|
---|
520 | {
|
---|
521 | /** The header. */
|
---|
522 | SUPREQHDR Hdr;
|
---|
523 | union
|
---|
524 | {
|
---|
525 | struct
|
---|
526 | {
|
---|
527 | /** Number of pages to allocate. */
|
---|
528 | uint32_t cPages;
|
---|
529 | } In;
|
---|
530 | struct
|
---|
531 | {
|
---|
532 | /** The ring-3 address of the allocated memory. */
|
---|
533 | RTR3PTR pvR3;
|
---|
534 | /** The ring-0 address of the allocated memory. */
|
---|
535 | RTR0PTR pvR0;
|
---|
536 | /** Array of pages. */
|
---|
537 | RTHCPHYS aPages[1];
|
---|
538 | } Out;
|
---|
539 | } u;
|
---|
540 | } SUPLOWALLOC, *PSUPLOWALLOC;
|
---|
541 | /** @} */
|
---|
542 |
|
---|
543 |
|
---|
544 | /** @name SUP_IOCTL_LOW_FREE
|
---|
545 | * Free low memory.
|
---|
546 | * @{
|
---|
547 | */
|
---|
548 | #define SUP_IOCTL_LOW_FREE SUP_CTL_CODE_SIZE(11, SUP_IOCTL_LOW_FREE_SIZE)
|
---|
549 | #define SUP_IOCTL_LOW_FREE_SIZE sizeof(SUPLOWFREE)
|
---|
550 | #define SUP_IOCTL_LOW_FREE_SIZE_IN sizeof(SUPLOWFREE)
|
---|
551 | #define SUP_IOCTL_LOW_FREE_SIZE_OUT sizeof(SUPREQHDR)
|
---|
552 | typedef struct SUPLOWFREE
|
---|
553 | {
|
---|
554 | /** The header. */
|
---|
555 | SUPREQHDR Hdr;
|
---|
556 | union
|
---|
557 | {
|
---|
558 | struct
|
---|
559 | {
|
---|
560 | /** The ring-3 address of the memory to free. */
|
---|
561 | RTR3PTR pvR3;
|
---|
562 | } In;
|
---|
563 | } u;
|
---|
564 | } SUPLOWFREE, *PSUPLOWFREE;
|
---|
565 | /** @} */
|
---|
566 |
|
---|
567 |
|
---|
568 | /** @name SUP_IOCTL_PAGE_ALLOC
|
---|
569 | * Allocate memory and map into the user process.
|
---|
570 | * The memory is of course locked.
|
---|
571 | * @{
|
---|
572 | */
|
---|
573 | #define SUP_IOCTL_PAGE_ALLOC SUP_CTL_CODE_BIG(12)
|
---|
574 | #define SUP_IOCTL_PAGE_ALLOC_SIZE(cPages) RT_OFFSETOF(SUPPAGEALLOC, u.Out.aPages[cPages])
|
---|
575 | #define SUP_IOCTL_PAGE_ALLOC_SIZE_IN (sizeof(SUPREQHDR) + RT_SIZEOFMEMB(SUPPAGEALLOC, u.In))
|
---|
576 | #define SUP_IOCTL_PAGE_ALLOC_SIZE_OUT(cPages) SUP_IOCTL_PAGE_ALLOC_SIZE(cPages)
|
---|
577 | typedef struct SUPPAGEALLOC
|
---|
578 | {
|
---|
579 | /** The header. */
|
---|
580 | SUPREQHDR Hdr;
|
---|
581 | union
|
---|
582 | {
|
---|
583 | struct
|
---|
584 | {
|
---|
585 | /** Number of pages to allocate */
|
---|
586 | uint32_t cPages;
|
---|
587 | } In;
|
---|
588 | struct
|
---|
589 | {
|
---|
590 | /** Returned ring-3 address. */
|
---|
591 | RTR3PTR pvR3;
|
---|
592 | /** The physical addresses of the allocated pages. */
|
---|
593 | RTHCPHYS aPages[1];
|
---|
594 | } Out;
|
---|
595 | } u;
|
---|
596 | } SUPPAGEALLOC, *PSUPPAGEALLOC;
|
---|
597 | /** @} */
|
---|
598 |
|
---|
599 |
|
---|
600 | /** @name SUP_IOCTL_PAGE_FREE
|
---|
601 | * Free memory allocated with SUP_IOCTL_PAGE_ALLOC.
|
---|
602 | * @{
|
---|
603 | */
|
---|
604 | #define SUP_IOCTL_PAGE_FREE SUP_CTL_CODE_SIZE(13, SUP_IOCTL_PAGE_FREE_SIZE_IN)
|
---|
605 | #define SUP_IOCTL_PAGE_FREE_SIZE sizeof(SUPPAGEFREE)
|
---|
606 | #define SUP_IOCTL_PAGE_FREE_SIZE_IN sizeof(SUPPAGEFREE)
|
---|
607 | #define SUP_IOCTL_PAGE_FREE_SIZE_OUT sizeof(SUPREQHDR)
|
---|
608 | typedef struct SUPPAGEFREE
|
---|
609 | {
|
---|
610 | /** The header. */
|
---|
611 | SUPREQHDR Hdr;
|
---|
612 | union
|
---|
613 | {
|
---|
614 | struct
|
---|
615 | {
|
---|
616 | /** Address of memory range to free. */
|
---|
617 | RTR3PTR pvR3;
|
---|
618 | } In;
|
---|
619 | } u;
|
---|
620 | } SUPPAGEFREE, *PSUPPAGEFREE;
|
---|
621 | /** @} */
|
---|
622 |
|
---|
623 |
|
---|
624 | /** @name SUP_IOCTL_PAGE_LOCK
|
---|
625 | * Pin down physical pages.
|
---|
626 | * @{
|
---|
627 | */
|
---|
628 | #define SUP_IOCTL_PAGE_LOCK SUP_CTL_CODE_BIG(14)
|
---|
629 | #define SUP_IOCTL_PAGE_LOCK_SIZE(cPages) (RT_MAX((size_t)SUP_IOCTL_PAGE_LOCK_SIZE_IN, (size_t)SUP_IOCTL_PAGE_LOCK_SIZE_OUT(cPages)))
|
---|
630 | #define SUP_IOCTL_PAGE_LOCK_SIZE_IN (sizeof(SUPREQHDR) + RT_SIZEOFMEMB(SUPPAGELOCK, u.In))
|
---|
631 | #define SUP_IOCTL_PAGE_LOCK_SIZE_OUT(cPages) RT_OFFSETOF(SUPPAGELOCK, u.Out.aPages[cPages])
|
---|
632 | typedef struct SUPPAGELOCK
|
---|
633 | {
|
---|
634 | /** The header. */
|
---|
635 | SUPREQHDR Hdr;
|
---|
636 | union
|
---|
637 | {
|
---|
638 | struct
|
---|
639 | {
|
---|
640 | /** Start of page range. Must be PAGE aligned. */
|
---|
641 | RTR3PTR pvR3;
|
---|
642 | /** The range size given as a page count. */
|
---|
643 | uint32_t cPages;
|
---|
644 | } In;
|
---|
645 |
|
---|
646 | struct
|
---|
647 | {
|
---|
648 | /** Array of pages. */
|
---|
649 | RTHCPHYS aPages[1];
|
---|
650 | } Out;
|
---|
651 | } u;
|
---|
652 | } SUPPAGELOCK, *PSUPPAGELOCK;
|
---|
653 | /** @} */
|
---|
654 |
|
---|
655 |
|
---|
656 | /** @name SUP_IOCTL_PAGE_UNLOCK
|
---|
657 | * Unpin physical pages.
|
---|
658 | * @{ */
|
---|
659 | #define SUP_IOCTL_PAGE_UNLOCK SUP_CTL_CODE_SIZE(15, SUP_IOCTL_PAGE_UNLOCK_SIZE)
|
---|
660 | #define SUP_IOCTL_PAGE_UNLOCK_SIZE sizeof(SUPPAGEUNLOCK)
|
---|
661 | #define SUP_IOCTL_PAGE_UNLOCK_SIZE_IN sizeof(SUPPAGEUNLOCK)
|
---|
662 | #define SUP_IOCTL_PAGE_UNLOCK_SIZE_OUT sizeof(SUPREQHDR)
|
---|
663 | typedef struct SUPPAGEUNLOCK
|
---|
664 | {
|
---|
665 | /** The header. */
|
---|
666 | SUPREQHDR Hdr;
|
---|
667 | union
|
---|
668 | {
|
---|
669 | struct
|
---|
670 | {
|
---|
671 | /** Start of page range of a range previuosly pinned. */
|
---|
672 | RTR3PTR pvR3;
|
---|
673 | } In;
|
---|
674 | } u;
|
---|
675 | } SUPPAGEUNLOCK, *PSUPPAGEUNLOCK;
|
---|
676 | /** @} */
|
---|
677 |
|
---|
678 |
|
---|
679 | /** @name SUP_IOCTL_CONT_ALLOC
|
---|
680 | * Allocate contious memory.
|
---|
681 | * @{
|
---|
682 | */
|
---|
683 | #define SUP_IOCTL_CONT_ALLOC SUP_CTL_CODE_SIZE(16, SUP_IOCTL_CONT_ALLOC_SIZE)
|
---|
684 | #define SUP_IOCTL_CONT_ALLOC_SIZE sizeof(SUPCONTALLOC)
|
---|
685 | #define SUP_IOCTL_CONT_ALLOC_SIZE_IN (sizeof(SUPREQHDR) + RT_SIZEOFMEMB(SUPCONTALLOC, u.In))
|
---|
686 | #define SUP_IOCTL_CONT_ALLOC_SIZE_OUT sizeof(SUPCONTALLOC)
|
---|
687 | typedef struct SUPCONTALLOC
|
---|
688 | {
|
---|
689 | /** The header. */
|
---|
690 | SUPREQHDR Hdr;
|
---|
691 | union
|
---|
692 | {
|
---|
693 | struct
|
---|
694 | {
|
---|
695 | /** The allocation size given as a page count. */
|
---|
696 | uint32_t cPages;
|
---|
697 | } In;
|
---|
698 |
|
---|
699 | struct
|
---|
700 | {
|
---|
701 | /** The address of the ring-0 mapping of the allocated memory. */
|
---|
702 | RTR0PTR pvR0;
|
---|
703 | /** The address of the ring-3 mapping of the allocated memory. */
|
---|
704 | RTR3PTR pvR3;
|
---|
705 | /** The physical address of the allocation. */
|
---|
706 | RTHCPHYS HCPhys;
|
---|
707 | } Out;
|
---|
708 | } u;
|
---|
709 | } SUPCONTALLOC, *PSUPCONTALLOC;
|
---|
710 | /** @} */
|
---|
711 |
|
---|
712 |
|
---|
713 | /** @name SUP_IOCTL_CONT_FREE Input.
|
---|
714 | * @{
|
---|
715 | */
|
---|
716 | /** Free contious memory. */
|
---|
717 | #define SUP_IOCTL_CONT_FREE SUP_CTL_CODE_SIZE(17, SUP_IOCTL_CONT_FREE_SIZE)
|
---|
718 | #define SUP_IOCTL_CONT_FREE_SIZE sizeof(SUPCONTFREE)
|
---|
719 | #define SUP_IOCTL_CONT_FREE_SIZE_IN sizeof(SUPCONTFREE)
|
---|
720 | #define SUP_IOCTL_CONT_FREE_SIZE_OUT sizeof(SUPREQHDR)
|
---|
721 | typedef struct SUPCONTFREE
|
---|
722 | {
|
---|
723 | /** The header. */
|
---|
724 | SUPREQHDR Hdr;
|
---|
725 | union
|
---|
726 | {
|
---|
727 | struct
|
---|
728 | {
|
---|
729 | /** The ring-3 address of the memory to free. */
|
---|
730 | RTR3PTR pvR3;
|
---|
731 | } In;
|
---|
732 | } u;
|
---|
733 | } SUPCONTFREE, *PSUPCONTFREE;
|
---|
734 | /** @} */
|
---|
735 |
|
---|
736 |
|
---|
737 | /** @name SUP_IOCTL_GET_PAGING_MODE
|
---|
738 | * Get the host paging mode.
|
---|
739 | * @{
|
---|
740 | */
|
---|
741 | #define SUP_IOCTL_GET_PAGING_MODE SUP_CTL_CODE_SIZE(18, SUP_IOCTL_GET_PAGING_MODE_SIZE)
|
---|
742 | #define SUP_IOCTL_GET_PAGING_MODE_SIZE sizeof(SUPGETPAGINGMODE)
|
---|
743 | #define SUP_IOCTL_GET_PAGING_MODE_SIZE_IN sizeof(SUPREQHDR)
|
---|
744 | #define SUP_IOCTL_GET_PAGING_MODE_SIZE_OUT sizeof(SUPGETPAGINGMODE)
|
---|
745 | typedef struct SUPGETPAGINGMODE
|
---|
746 | {
|
---|
747 | /** The header. */
|
---|
748 | SUPREQHDR Hdr;
|
---|
749 | union
|
---|
750 | {
|
---|
751 | struct
|
---|
752 | {
|
---|
753 | /** The paging mode. */
|
---|
754 | SUPPAGINGMODE enmMode;
|
---|
755 | } Out;
|
---|
756 | } u;
|
---|
757 | } SUPGETPAGINGMODE, *PSUPGETPAGINGMODE;
|
---|
758 | /** @} */
|
---|
759 |
|
---|
760 |
|
---|
761 | /** @name SUP_IOCTL_SET_VM_FOR_FAST
|
---|
762 | * Set the VM handle for doing fast call ioctl calls.
|
---|
763 | * @{
|
---|
764 | */
|
---|
765 | #define SUP_IOCTL_SET_VM_FOR_FAST SUP_CTL_CODE_SIZE(19, SUP_IOCTL_SET_VM_FOR_FAST_SIZE)
|
---|
766 | #define SUP_IOCTL_SET_VM_FOR_FAST_SIZE sizeof(SUPSETVMFORFAST)
|
---|
767 | #define SUP_IOCTL_SET_VM_FOR_FAST_SIZE_IN sizeof(SUPSETVMFORFAST)
|
---|
768 | #define SUP_IOCTL_SET_VM_FOR_FAST_SIZE_OUT sizeof(SUPREQHDR)
|
---|
769 | typedef struct SUPSETVMFORFAST
|
---|
770 | {
|
---|
771 | /** The header. */
|
---|
772 | SUPREQHDR Hdr;
|
---|
773 | union
|
---|
774 | {
|
---|
775 | struct
|
---|
776 | {
|
---|
777 | /** The ring-0 VM handle (pointer). */
|
---|
778 | PVMR0 pVMR0;
|
---|
779 | } In;
|
---|
780 | } u;
|
---|
781 | } SUPSETVMFORFAST, *PSUPSETVMFORFAST;
|
---|
782 | /** @} */
|
---|
783 |
|
---|
784 |
|
---|
785 | /** @name SUP_IOCTL_GIP_MAP
|
---|
786 | * Map the GIP into user space.
|
---|
787 | * @{
|
---|
788 | */
|
---|
789 | #define SUP_IOCTL_GIP_MAP SUP_CTL_CODE_SIZE(20, SUP_IOCTL_GIP_MAP_SIZE)
|
---|
790 | #define SUP_IOCTL_GIP_MAP_SIZE sizeof(SUPGIPMAP)
|
---|
791 | #define SUP_IOCTL_GIP_MAP_SIZE_IN sizeof(SUPREQHDR)
|
---|
792 | #define SUP_IOCTL_GIP_MAP_SIZE_OUT sizeof(SUPGIPMAP)
|
---|
793 | typedef struct SUPGIPMAP
|
---|
794 | {
|
---|
795 | /** The header. */
|
---|
796 | SUPREQHDR Hdr;
|
---|
797 | union
|
---|
798 | {
|
---|
799 | struct
|
---|
800 | {
|
---|
801 | /** The physical address of the GIP. */
|
---|
802 | RTHCPHYS HCPhysGip;
|
---|
803 | /** Pointer to the read-only usermode GIP mapping for this session. */
|
---|
804 | R3PTRTYPE(PSUPGLOBALINFOPAGE) pGipR3;
|
---|
805 | /** Pointer to the supervisor mode GIP mapping. */
|
---|
806 | R0PTRTYPE(PSUPGLOBALINFOPAGE) pGipR0;
|
---|
807 | } Out;
|
---|
808 | } u;
|
---|
809 | } SUPGIPMAP, *PSUPGIPMAP;
|
---|
810 | /** @} */
|
---|
811 |
|
---|
812 |
|
---|
813 | /** @name SUP_IOCTL_GIP_UNMAP
|
---|
814 | * Unmap the GIP.
|
---|
815 | * @{
|
---|
816 | */
|
---|
817 | #define SUP_IOCTL_GIP_UNMAP SUP_CTL_CODE_SIZE(21, SUP_IOCTL_GIP_UNMAP_SIZE)
|
---|
818 | #define SUP_IOCTL_GIP_UNMAP_SIZE sizeof(SUPGIPUNMAP)
|
---|
819 | #define SUP_IOCTL_GIP_UNMAP_SIZE_IN sizeof(SUPGIPUNMAP)
|
---|
820 | #define SUP_IOCTL_GIP_UNMAP_SIZE_OUT sizeof(SUPGIPUNMAP)
|
---|
821 | typedef struct SUPGIPUNMAP
|
---|
822 | {
|
---|
823 | /** The header. */
|
---|
824 | SUPREQHDR Hdr;
|
---|
825 | } SUPGIPUNMAP, *PSUPGIPUNMAP;
|
---|
826 | /** @} */
|
---|
827 |
|
---|
828 |
|
---|
829 | #pragma pack() /* paranoia */
|
---|
830 |
|
---|
831 | #endif
|
---|
832 |
|
---|