VirtualBox

source: vbox/trunk/src/VBox/HostDrivers/Support/SUPDrvIOC.h@ 25180

Last change on this file since 25180 was 24498, checked in by vboxsync, 15 years ago

SUPDrvIOC.h: Note about the major version consumed by the 3.0 branch.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 36.6 KB
Line 
1/* $Revision: 24498 $ */
2/** @file
3 * VirtualBox Support Driver - IOCtl definitions.
4 */
5
6/*
7 * Copyright (C) 2006-2007 Sun Microsystems, Inc.
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 * The contents of this file may alternatively be used under the terms
18 * of the Common Development and Distribution License Version 1.0
19 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
20 * VirtualBox OSE distribution, in which case the provisions of the
21 * CDDL are applicable instead of those of the GPL.
22 *
23 * You may elect to license modified versions of this file under the
24 * terms and conditions of either the GPL or the CDDL or both.
25 *
26 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
27 * Clara, CA 95054 USA or visit http://www.sun.com if you need
28 * additional information or have any questions.
29 */
30
31#ifndef ___SUPDrvIOC_h___
32#define ___SUPDrvIOC_h___
33
34/*
35 * Basic types.
36 */
37#include <iprt/types.h>
38
39/*
40 * IOCtl numbers.
41 * We're using the Win32 type of numbers here, thus the macros below.
42 * The SUP_IOCTL_FLAG macro is used to separate requests from 32-bit
43 * and 64-bit processes.
44 */
45#ifdef RT_ARCH_AMD64
46# define SUP_IOCTL_FLAG 128
47#elif defined(RT_ARCH_X86)
48# define SUP_IOCTL_FLAG 0
49#else
50# error "dunno which arch this is!"
51#endif
52
53#ifdef RT_OS_WINDOWS
54# ifndef CTL_CODE
55# include <Windows.h>
56# endif
57 /* Automatic buffering, size not encoded. */
58# define SUP_CTL_CODE_SIZE(Function, Size) CTL_CODE(FILE_DEVICE_UNKNOWN, (Function) | SUP_IOCTL_FLAG, METHOD_BUFFERED, FILE_WRITE_ACCESS)
59# define SUP_CTL_CODE_BIG(Function) CTL_CODE(FILE_DEVICE_UNKNOWN, (Function) | SUP_IOCTL_FLAG, METHOD_BUFFERED, FILE_WRITE_ACCESS)
60# define SUP_CTL_CODE_FAST(Function) CTL_CODE(FILE_DEVICE_UNKNOWN, (Function) | SUP_IOCTL_FLAG, METHOD_NEITHER, FILE_WRITE_ACCESS)
61# define SUP_CTL_CODE_NO_SIZE(uIOCtl) (uIOCtl)
62
63#elif defined(RT_OS_SOLARIS)
64 /* No automatic buffering, size limited to 255 bytes. */
65# include <sys/ioccom.h>
66# define SUP_CTL_CODE_SIZE(Function, Size) _IOWRN('V', (Function) | SUP_IOCTL_FLAG, sizeof(SUPREQHDR))
67# define SUP_CTL_CODE_BIG(Function) _IOWRN('V', (Function) | SUP_IOCTL_FLAG, sizeof(SUPREQHDR))
68# define SUP_CTL_CODE_FAST(Function) _IO( 'V', (Function) | SUP_IOCTL_FLAG)
69# define SUP_CTL_CODE_NO_SIZE(uIOCtl) (uIOCtl)
70
71#elif defined(RT_OS_OS2)
72 /* No automatic buffering, size not encoded. */
73# define SUP_CTL_CATEGORY 0xc0
74# define SUP_CTL_CODE_SIZE(Function, Size) ((unsigned char)(Function))
75# define SUP_CTL_CODE_BIG(Function) ((unsigned char)(Function))
76# define SUP_CTL_CATEGORY_FAST 0xc1
77# define SUP_CTL_CODE_FAST(Function) ((unsigned char)(Function))
78# define SUP_CTL_CODE_NO_SIZE(uIOCtl) (uIOCtl)
79
80#elif defined(RT_OS_LINUX)
81 /* No automatic buffering, size limited to 16KB. */
82# include <linux/ioctl.h>
83# define SUP_CTL_CODE_SIZE(Function, Size) _IOC(_IOC_READ | _IOC_WRITE, 'V', (Function) | SUP_IOCTL_FLAG, (Size))
84# define SUP_CTL_CODE_BIG(Function) _IO('V', (Function) | SUP_IOCTL_FLAG)
85# define SUP_CTL_CODE_FAST(Function) _IO('V', (Function) | SUP_IOCTL_FLAG)
86# define SUP_CTL_CODE_NO_SIZE(uIOCtl) ((uIOCtl) & ~IOCSIZE_MASK)
87
88#elif defined(RT_OS_L4)
89 /* Implemented in suplib, no worries. */
90# define SUP_CTL_CODE_SIZE(Function, Size) (Function)
91# define SUP_CTL_CODE_BIG(Function) (Function)
92# define SUP_CTL_CODE_FAST(Function) (Function)
93# define SUP_CTL_CODE_NO_SIZE(uIOCtl) (uIOCtl)
94
95#else /* BSD Like */
96 /* Automatic buffering, size limited to 4KB on *BSD and 8KB on Darwin - commands the limit, 4KB. */
97# include <sys/ioccom.h>
98# define SUP_CTL_CODE_SIZE(Function, Size) _IOC(IOC_INOUT, 'V', (Function) | SUP_IOCTL_FLAG, (Size))
99# define SUP_CTL_CODE_BIG(Function) _IO('V', (Function) | SUP_IOCTL_FLAG)
100# define SUP_CTL_CODE_FAST(Function) _IO('V', (Function) | SUP_IOCTL_FLAG)
101# define SUP_CTL_CODE_NO_SIZE(uIOCtl) ( (uIOCtl) & ~_IOC(0,0,0,IOCPARM_MASK) )
102#endif
103
104/** Fast path IOCtl: VMMR0_DO_RAW_RUN */
105#define SUP_IOCTL_FAST_DO_RAW_RUN SUP_CTL_CODE_FAST(64)
106/** Fast path IOCtl: VMMR0_DO_HWACC_RUN */
107#define SUP_IOCTL_FAST_DO_HWACC_RUN SUP_CTL_CODE_FAST(65)
108/** Just a NOP call for profiling the latency of a fast ioctl call to VMMR0. */
109#define SUP_IOCTL_FAST_DO_NOP SUP_CTL_CODE_FAST(66)
110
111
112
113/*******************************************************************************
114* Structures and Typedefs *
115*******************************************************************************/
116#ifdef RT_ARCH_AMD64
117# pragma pack(8) /* paranoia. */
118#else
119# pragma pack(4) /* paranoia. */
120#endif
121
122
123/**
124 * Common In/Out header.
125 */
126typedef struct SUPREQHDR
127{
128 /** Cookie. */
129 uint32_t u32Cookie;
130 /** Session cookie. */
131 uint32_t u32SessionCookie;
132 /** The size of the input. */
133 uint32_t cbIn;
134 /** The size of the output. */
135 uint32_t cbOut;
136 /** Flags. See SUPREQHDR_FLAGS_* for details and values. */
137 uint32_t fFlags;
138 /** The VBox status code of the operation, out direction only. */
139 int32_t rc;
140} SUPREQHDR;
141/** Pointer to a IOC header. */
142typedef SUPREQHDR *PSUPREQHDR;
143
144/** @name SUPREQHDR::fFlags values
145 * @{ */
146/** Masks out the magic value. */
147#define SUPREQHDR_FLAGS_MAGIC_MASK UINT32_C(0xff0000ff)
148/** The generic mask. */
149#define SUPREQHDR_FLAGS_GEN_MASK UINT32_C(0x0000ff00)
150/** The request specific mask. */
151#define SUPREQHDR_FLAGS_REQ_MASK UINT32_C(0x00ff0000)
152
153/** There is extra input that needs copying on some platforms. */
154#define SUPREQHDR_FLAGS_EXTRA_IN UINT32_C(0x00000100)
155/** There is extra output that needs copying on some platforms. */
156#define SUPREQHDR_FLAGS_EXTRA_OUT UINT32_C(0x00000200)
157
158/** The magic value. */
159#define SUPREQHDR_FLAGS_MAGIC UINT32_C(0x42000042)
160/** The default value. Use this when no special stuff is requested. */
161#define SUPREQHDR_FLAGS_DEFAULT SUPREQHDR_FLAGS_MAGIC
162/** @} */
163
164
165/** @name SUP_IOCTL_COOKIE
166 * @{
167 */
168/** Negotiate cookie. */
169#define SUP_IOCTL_COOKIE SUP_CTL_CODE_SIZE(1, SUP_IOCTL_COOKIE_SIZE)
170/** The request size. */
171#define SUP_IOCTL_COOKIE_SIZE sizeof(SUPCOOKIE)
172/** The SUPREQHDR::cbIn value. */
173#define SUP_IOCTL_COOKIE_SIZE_IN sizeof(SUPREQHDR) + RT_SIZEOFMEMB(SUPCOOKIE, u.In)
174/** The SUPREQHDR::cbOut value. */
175#define SUP_IOCTL_COOKIE_SIZE_OUT sizeof(SUPREQHDR) + RT_SIZEOFMEMB(SUPCOOKIE, u.Out)
176/** SUPCOOKIE_IN magic word. */
177#define SUPCOOKIE_MAGIC "The Magic Word!"
178/** The initial cookie. */
179#define SUPCOOKIE_INITIAL_COOKIE 0x69726f74 /* 'tori' */
180
181/** Current interface version.
182 * The upper 16-bit is the major version, the the lower the minor version.
183 * When incompatible changes are made, the upper major number has to be changed.
184 *
185 * Update rules:
186 * -# Only update the major number when incompatible changes have been made to
187 * the IOC interface or the ABI provided via the functions returned by
188 * SUPQUERYFUNCS.
189 * -# When adding new features (new IOC number, new flags, new exports, ++)
190 * only update the minor number and change SUPLib.cpp to require the
191 * new IOC version.
192 * -# When incrementing the major number, clear the minor part and reset
193 * any IOC version requirements in SUPLib.cpp.
194 * -# When increment the major number, execute all pending work.
195 *
196 * @todo Pending work on next major version change:
197 * - Nothing.
198 *
199 * @remarks Major version 0x0011YYYY was consumed by the 3.0.12 release. The
200 * next major version used on the trunk will be 0x00120000!
201 */
202#define SUPDRV_IOC_VERSION 0x00100001
203
204/** SUP_IOCTL_COOKIE. */
205typedef struct SUPCOOKIE
206{
207 /** The header.
208 * u32Cookie must be set to SUPCOOKIE_INITIAL_COOKIE.
209 * u32SessionCookie should be set to some random value. */
210 SUPREQHDR Hdr;
211 union
212 {
213 struct
214 {
215 /** Magic word. */
216 char szMagic[16];
217 /** The requested interface version number. */
218 uint32_t u32ReqVersion;
219 /** The minimum interface version number. */
220 uint32_t u32MinVersion;
221 } In;
222 struct
223 {
224 /** Cookie. */
225 uint32_t u32Cookie;
226 /** Session cookie. */
227 uint32_t u32SessionCookie;
228 /** Interface version for this session. */
229 uint32_t u32SessionVersion;
230 /** The actual interface version in the driver. */
231 uint32_t u32DriverVersion;
232 /** Number of functions available for the SUP_IOCTL_QUERY_FUNCS request. */
233 uint32_t cFunctions;
234 /** Session handle. */
235 R0PTRTYPE(PSUPDRVSESSION) pSession;
236 } Out;
237 } u;
238} SUPCOOKIE, *PSUPCOOKIE;
239/** @} */
240
241
242/** @name SUP_IOCTL_QUERY_FUNCS
243 * Query SUPR0 functions.
244 * @{
245 */
246#define SUP_IOCTL_QUERY_FUNCS(cFuncs) SUP_CTL_CODE_BIG(2)
247#define SUP_IOCTL_QUERY_FUNCS_SIZE(cFuncs) RT_UOFFSETOF(SUPQUERYFUNCS, u.Out.aFunctions[(cFuncs)])
248#define SUP_IOCTL_QUERY_FUNCS_SIZE_IN sizeof(SUPREQHDR)
249#define SUP_IOCTL_QUERY_FUNCS_SIZE_OUT(cFuncs) SUP_IOCTL_QUERY_FUNCS_SIZE(cFuncs)
250
251/** A function. */
252typedef struct SUPFUNC
253{
254 /** Name - mangled. */
255 char szName[32];
256 /** Address. */
257 RTR0PTR pfn;
258} SUPFUNC, *PSUPFUNC;
259
260typedef struct SUPQUERYFUNCS
261{
262 /** The header. */
263 SUPREQHDR Hdr;
264 union
265 {
266 struct
267 {
268 /** Number of functions returned. */
269 uint32_t cFunctions;
270 /** Array of functions. */
271 SUPFUNC aFunctions[1];
272 } Out;
273 } u;
274} SUPQUERYFUNCS, *PSUPQUERYFUNCS;
275/** @} */
276
277
278/** @name SUP_IOCTL_LDR_OPEN
279 * Open an image.
280 * @{
281 */
282#define SUP_IOCTL_LDR_OPEN SUP_CTL_CODE_SIZE(3, SUP_IOCTL_LDR_OPEN_SIZE)
283#define SUP_IOCTL_LDR_OPEN_SIZE sizeof(SUPLDROPEN)
284#define SUP_IOCTL_LDR_OPEN_SIZE_IN sizeof(SUPLDROPEN)
285#define SUP_IOCTL_LDR_OPEN_SIZE_OUT (sizeof(SUPREQHDR) + RT_SIZEOFMEMB(SUPLDROPEN, u.Out))
286typedef struct SUPLDROPEN
287{
288 /** The header. */
289 SUPREQHDR Hdr;
290 union
291 {
292 struct
293 {
294 /** Size of the image we'll be loading. */
295 uint32_t cbImage;
296 /** Image name.
297 * This is the NAME of the image, not the file name. It is used
298 * to share code with other processes. (Max len is 32 chars!) */
299 char szName[32];
300 } In;
301 struct
302 {
303 /** The base address of the image. */
304 RTR0PTR pvImageBase;
305 /** Indicate whether or not the image requires loading. */
306 bool fNeedsLoading;
307 } Out;
308 } u;
309} SUPLDROPEN, *PSUPLDROPEN;
310/** @} */
311
312
313/** @name SUP_IOCTL_LDR_LOAD
314 * Upload the image bits.
315 * @{
316 */
317#define SUP_IOCTL_LDR_LOAD SUP_CTL_CODE_BIG(4)
318#define SUP_IOCTL_LDR_LOAD_SIZE(cbImage) RT_UOFFSETOF(SUPLDRLOAD, u.In.achImage[cbImage])
319#define SUP_IOCTL_LDR_LOAD_SIZE_IN(cbImage) RT_UOFFSETOF(SUPLDRLOAD, u.In.achImage[cbImage])
320#define SUP_IOCTL_LDR_LOAD_SIZE_OUT sizeof(SUPREQHDR)
321
322/**
323 * Module initialization callback function.
324 * This is called once after the module has been loaded.
325 *
326 * @returns 0 on success.
327 * @returns Appropriate error code on failure.
328 */
329typedef DECLCALLBACK(int) FNR0MODULEINIT(void);
330/** Pointer to a FNR0MODULEINIT(). */
331typedef R0PTRTYPE(FNR0MODULEINIT *) PFNR0MODULEINIT;
332
333/**
334 * Module termination callback function.
335 * This is called once right before the module is being unloaded.
336 */
337typedef DECLCALLBACK(void) FNR0MODULETERM(void);
338/** Pointer to a FNR0MODULETERM(). */
339typedef R0PTRTYPE(FNR0MODULETERM *) PFNR0MODULETERM;
340
341/**
342 * Symbol table entry.
343 */
344typedef struct SUPLDRSYM
345{
346 /** Offset into of the string table. */
347 uint32_t offName;
348 /** Offset of the symbol relative to the image load address. */
349 uint32_t offSymbol;
350} SUPLDRSYM;
351/** Pointer to a symbol table entry. */
352typedef SUPLDRSYM *PSUPLDRSYM;
353/** Pointer to a const symbol table entry. */
354typedef SUPLDRSYM const *PCSUPLDRSYM;
355
356/**
357 * SUPLDRLOAD::u::In::EP type.
358 */
359typedef enum SUPLDRLOADEP
360{
361 SUPLDRLOADEP_NOTHING = 0,
362 SUPLDRLOADEP_VMMR0,
363 SUPLDRLOADEP_SERVICE,
364 SUPLDRLOADEP_32BIT_HACK = 0x7fffffff
365} SUPLDRLOADEP;
366
367typedef struct SUPLDRLOAD
368{
369 /** The header. */
370 SUPREQHDR Hdr;
371 union
372 {
373 struct
374 {
375 /** The address of module initialization function. Similar to _DLL_InitTerm(hmod, 0). */
376 PFNR0MODULEINIT pfnModuleInit;
377 /** The address of module termination function. Similar to _DLL_InitTerm(hmod, 1). */
378 PFNR0MODULETERM pfnModuleTerm;
379 /** Special entry points. */
380 union
381 {
382 /** SUPLDRLOADEP_VMMR0. */
383 struct
384 {
385 /** The module handle (i.e. address). */
386 RTR0PTR pvVMMR0;
387 /** Address of VMMR0EntryInt function. */
388 RTR0PTR pvVMMR0EntryInt;
389 /** Address of VMMR0EntryFast function. */
390 RTR0PTR pvVMMR0EntryFast;
391 /** Address of VMMR0EntryEx function. */
392 RTR0PTR pvVMMR0EntryEx;
393 } VMMR0;
394 /** SUPLDRLOADEP_SERVICE. */
395 struct
396 {
397 /** The service request handler.
398 * (PFNR0SERVICEREQHANDLER isn't defined yet.) */
399 RTR0PTR pfnServiceReq;
400 /** Reserved, must be NIL. */
401 RTR0PTR apvReserved[3];
402 } Service;
403 } EP;
404 /** Address. */
405 RTR0PTR pvImageBase;
406 /** Entry point type. */
407 SUPLDRLOADEP eEPType;
408 /** The offset of the symbol table. */
409 uint32_t offSymbols;
410 /** The number of entries in the symbol table. */
411 uint32_t cSymbols;
412 /** The offset of the string table. */
413 uint32_t offStrTab;
414 /** Size of the string table. */
415 uint32_t cbStrTab;
416 /** Size of image (including string and symbol tables). */
417 uint32_t cbImage;
418 /** The image data. */
419 char achImage[1];
420 } In;
421 } u;
422} SUPLDRLOAD, *PSUPLDRLOAD;
423/** @} */
424
425
426/** @name SUP_IOCTL_LDR_FREE
427 * Free an image.
428 * @{
429 */
430#define SUP_IOCTL_LDR_FREE SUP_CTL_CODE_SIZE(5, SUP_IOCTL_LDR_FREE_SIZE)
431#define SUP_IOCTL_LDR_FREE_SIZE sizeof(SUPLDRFREE)
432#define SUP_IOCTL_LDR_FREE_SIZE_IN sizeof(SUPLDRFREE)
433#define SUP_IOCTL_LDR_FREE_SIZE_OUT sizeof(SUPREQHDR)
434typedef struct SUPLDRFREE
435{
436 /** The header. */
437 SUPREQHDR Hdr;
438 union
439 {
440 struct
441 {
442 /** Address. */
443 RTR0PTR pvImageBase;
444 } In;
445 } u;
446} SUPLDRFREE, *PSUPLDRFREE;
447/** @} */
448
449
450/** @name SUP_IOCTL_LDR_GET_SYMBOL
451 * Get address of a symbol within an image.
452 * @{
453 */
454#define SUP_IOCTL_LDR_GET_SYMBOL SUP_CTL_CODE_SIZE(6, SUP_IOCTL_LDR_GET_SYMBOL_SIZE)
455#define SUP_IOCTL_LDR_GET_SYMBOL_SIZE sizeof(SUPLDRGETSYMBOL)
456#define SUP_IOCTL_LDR_GET_SYMBOL_SIZE_IN sizeof(SUPLDRGETSYMBOL)
457#define SUP_IOCTL_LDR_GET_SYMBOL_SIZE_OUT (sizeof(SUPREQHDR) + RT_SIZEOFMEMB(SUPLDRGETSYMBOL, u.Out))
458typedef struct SUPLDRGETSYMBOL
459{
460 /** The header. */
461 SUPREQHDR Hdr;
462 union
463 {
464 struct
465 {
466 /** Address. */
467 RTR0PTR pvImageBase;
468 /** The symbol name. */
469 char szSymbol[64];
470 } In;
471 struct
472 {
473 /** The symbol address. */
474 RTR0PTR pvSymbol;
475 } Out;
476 } u;
477} SUPLDRGETSYMBOL, *PSUPLDRGETSYMBOL;
478/** @} */
479
480
481/** @name SUP_IOCTL_CALL_VMMR0
482 * Call the R0 VMM Entry point.
483 *
484 * @todo Might have to convert this to a big request...
485 * @{
486 */
487#define SUP_IOCTL_CALL_VMMR0(cbReq) SUP_CTL_CODE_SIZE(7, SUP_IOCTL_CALL_VMMR0_SIZE(cbReq))
488#define SUP_IOCTL_CALL_VMMR0_SIZE(cbReq) RT_UOFFSETOF(SUPCALLVMMR0, abReqPkt[cbReq])
489#define SUP_IOCTL_CALL_VMMR0_SIZE_IN(cbReq) SUP_IOCTL_CALL_VMMR0_SIZE(cbReq)
490#define SUP_IOCTL_CALL_VMMR0_SIZE_OUT(cbReq) SUP_IOCTL_CALL_VMMR0_SIZE(cbReq)
491typedef struct SUPCALLVMMR0
492{
493 /** The header. */
494 SUPREQHDR Hdr;
495 union
496 {
497 struct
498 {
499 /** The VM handle. */
500 PVMR0 pVMR0;
501 /** VCPU id. */
502 uint32_t idCpu;
503 /** Which operation to execute. */
504 uint32_t uOperation;
505 /** Argument to use when no request packet is supplied. */
506 uint64_t u64Arg;
507 } In;
508 } u;
509 /** The VMMR0Entry request packet. */
510 uint8_t abReqPkt[1];
511} SUPCALLVMMR0, *PSUPCALLVMMR0;
512/** @} */
513
514
515/** @name SUP_IOCTL_LOW_ALLOC
516 * Allocate memory below 4GB (physically).
517 * @{
518 */
519#define SUP_IOCTL_LOW_ALLOC SUP_CTL_CODE_BIG(8)
520#define SUP_IOCTL_LOW_ALLOC_SIZE(cPages) ((uint32_t)RT_UOFFSETOF(SUPLOWALLOC, u.Out.aPages[cPages]))
521#define SUP_IOCTL_LOW_ALLOC_SIZE_IN (sizeof(SUPREQHDR) + RT_SIZEOFMEMB(SUPLOWALLOC, u.In))
522#define SUP_IOCTL_LOW_ALLOC_SIZE_OUT(cPages) SUP_IOCTL_LOW_ALLOC_SIZE(cPages)
523typedef struct SUPLOWALLOC
524{
525 /** The header. */
526 SUPREQHDR Hdr;
527 union
528 {
529 struct
530 {
531 /** Number of pages to allocate. */
532 uint32_t cPages;
533 } In;
534 struct
535 {
536 /** The ring-3 address of the allocated memory. */
537 RTR3PTR pvR3;
538 /** The ring-0 address of the allocated memory. */
539 RTR0PTR pvR0;
540 /** Array of pages. */
541 RTHCPHYS aPages[1];
542 } Out;
543 } u;
544} SUPLOWALLOC, *PSUPLOWALLOC;
545/** @} */
546
547
548/** @name SUP_IOCTL_LOW_FREE
549 * Free low memory.
550 * @{
551 */
552#define SUP_IOCTL_LOW_FREE SUP_CTL_CODE_SIZE(9, SUP_IOCTL_LOW_FREE_SIZE)
553#define SUP_IOCTL_LOW_FREE_SIZE sizeof(SUPLOWFREE)
554#define SUP_IOCTL_LOW_FREE_SIZE_IN sizeof(SUPLOWFREE)
555#define SUP_IOCTL_LOW_FREE_SIZE_OUT sizeof(SUPREQHDR)
556typedef struct SUPLOWFREE
557{
558 /** The header. */
559 SUPREQHDR Hdr;
560 union
561 {
562 struct
563 {
564 /** The ring-3 address of the memory to free. */
565 RTR3PTR pvR3;
566 } In;
567 } u;
568} SUPLOWFREE, *PSUPLOWFREE;
569/** @} */
570
571
572/** @name SUP_IOCTL_PAGE_ALLOC_EX
573 * Allocate memory and map it into kernel and/or user space. The memory is of
574 * course locked. The result should be freed using SUP_IOCTL_PAGE_FREE.
575 *
576 * @remarks Allocations without a kernel mapping may fail with
577 * VERR_NOT_SUPPORTED on some platforms.
578 *
579 * @{
580 */
581#define SUP_IOCTL_PAGE_ALLOC_EX SUP_CTL_CODE_BIG(10)
582#define SUP_IOCTL_PAGE_ALLOC_EX_SIZE(cPages) RT_UOFFSETOF(SUPPAGEALLOCEX, u.Out.aPages[cPages])
583#define SUP_IOCTL_PAGE_ALLOC_EX_SIZE_IN (sizeof(SUPREQHDR) + RT_SIZEOFMEMB(SUPPAGEALLOCEX, u.In))
584#define SUP_IOCTL_PAGE_ALLOC_EX_SIZE_OUT(cPages) SUP_IOCTL_PAGE_ALLOC_EX_SIZE(cPages)
585typedef struct SUPPAGEALLOCEX
586{
587 /** The header. */
588 SUPREQHDR Hdr;
589 union
590 {
591 struct
592 {
593 /** Number of pages to allocate */
594 uint32_t cPages;
595 /** Whether it should have kernel mapping. */
596 bool fKernelMapping;
597 /** Whether it should have a user mapping. */
598 bool fUserMapping;
599 /** Reserved. Must be false. */
600 bool fReserved0;
601 /** Reserved. Must be false. */
602 bool fReserved1;
603 } In;
604 struct
605 {
606 /** Returned ring-3 address. */
607 RTR3PTR pvR3;
608 /** Returned ring-0 address. */
609 RTR0PTR pvR0;
610 /** The physical addresses of the allocated pages. */
611 RTHCPHYS aPages[1];
612 } Out;
613 } u;
614} SUPPAGEALLOCEX, *PSUPPAGEALLOCEX;
615/** @} */
616
617
618/** @name SUP_IOCTL_PAGE_MAP_KERNEL
619 * Maps a portion of memory allocated by SUP_IOCTL_PAGE_ALLOC_EX /
620 * SUPR0PageAllocEx into kernel space for use by a device or similar.
621 *
622 * The mapping will be freed together with the ring-3 mapping when
623 * SUP_IOCTL_PAGE_FREE or SUPR0PageFree is called.
624 *
625 * @remarks Not necessarily supported on all platforms.
626 *
627 * @{
628 */
629#define SUP_IOCTL_PAGE_MAP_KERNEL SUP_CTL_CODE_SIZE(11, SUP_IOCTL_PAGE_MAP_KERNEL_SIZE)
630#define SUP_IOCTL_PAGE_MAP_KERNEL_SIZE sizeof(SUPPAGEMAPKERNEL)
631#define SUP_IOCTL_PAGE_MAP_KERNEL_SIZE_IN sizeof(SUPPAGEMAPKERNEL)
632#define SUP_IOCTL_PAGE_MAP_KERNEL_SIZE_OUT sizeof(SUPPAGEMAPKERNEL)
633typedef struct SUPPAGEMAPKERNEL
634{
635 /** The header. */
636 SUPREQHDR Hdr;
637 union
638 {
639 struct
640 {
641 /** The pointer of to the previously allocated memory. */
642 RTR3PTR pvR3;
643 /** The offset to start mapping from. */
644 uint32_t offSub;
645 /** Size of the section to map. */
646 uint32_t cbSub;
647 /** Flags reserved for future fun. */
648 uint32_t fFlags;
649 } In;
650 struct
651 {
652 /** The ring-0 address corresponding to pvR3 + offSub. */
653 RTR0PTR pvR0;
654 } Out;
655 } u;
656} SUPPAGEMAPKERNEL, *PSUPPAGEMAPKERNEL;
657/** @} */
658
659
660/** @name SUP_IOCTL_PAGE_PROTECT
661 * Changes the page level protection of the user and/or kernel mappings of
662 * memory previously allocated by SUPR0PageAllocEx.
663 *
664 * @remarks Not necessarily supported on all platforms.
665 *
666 * @{
667 */
668#define SUP_IOCTL_PAGE_PROTECT SUP_CTL_CODE_SIZE(12, SUP_IOCTL_PAGE_PROTECT_SIZE)
669#define SUP_IOCTL_PAGE_PROTECT_SIZE sizeof(SUPPAGEPROTECT)
670#define SUP_IOCTL_PAGE_PROTECT_SIZE_IN sizeof(SUPPAGEPROTECT)
671#define SUP_IOCTL_PAGE_PROTECT_SIZE_OUT sizeof(SUPPAGEPROTECT)
672typedef struct SUPPAGEPROTECT
673{
674 /** The header. */
675 SUPREQHDR Hdr;
676 union
677 {
678 struct
679 {
680 /** The pointer of to the previously allocated memory.
681 * Pass NIL_RTR3PTR if the ring-0 mapping should remain unaffected. */
682 RTR3PTR pvR3;
683 /** The pointer of to the previously allocated memory.
684 * Pass NIL_RTR0PTR if the ring-0 mapping should remain unaffected. */
685 RTR0PTR pvR0;
686 /** The offset to start changing protection at. */
687 uint32_t offSub;
688 /** Size of the portion that should be changed. */
689 uint32_t cbSub;
690 /** Protection flags, RTMEM_PROT_*. */
691 uint32_t fProt;
692 } In;
693 } u;
694} SUPPAGEPROTECT, *PSUPPAGEPROTECT;
695/** @} */
696
697
698/** @name SUP_IOCTL_PAGE_FREE
699 * Free memory allocated with SUP_IOCTL_PAGE_ALLOC_EX.
700 * @{
701 */
702#define SUP_IOCTL_PAGE_FREE SUP_CTL_CODE_SIZE(13, SUP_IOCTL_PAGE_FREE_SIZE_IN)
703#define SUP_IOCTL_PAGE_FREE_SIZE sizeof(SUPPAGEFREE)
704#define SUP_IOCTL_PAGE_FREE_SIZE_IN sizeof(SUPPAGEFREE)
705#define SUP_IOCTL_PAGE_FREE_SIZE_OUT sizeof(SUPREQHDR)
706typedef struct SUPPAGEFREE
707{
708 /** The header. */
709 SUPREQHDR Hdr;
710 union
711 {
712 struct
713 {
714 /** Address of memory range to free. */
715 RTR3PTR pvR3;
716 } In;
717 } u;
718} SUPPAGEFREE, *PSUPPAGEFREE;
719/** @} */
720
721
722
723
724/** @name SUP_IOCTL_PAGE_LOCK
725 * Pin down physical pages.
726 * @{
727 */
728#define SUP_IOCTL_PAGE_LOCK SUP_CTL_CODE_BIG(14)
729#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)))
730#define SUP_IOCTL_PAGE_LOCK_SIZE_IN (sizeof(SUPREQHDR) + RT_SIZEOFMEMB(SUPPAGELOCK, u.In))
731#define SUP_IOCTL_PAGE_LOCK_SIZE_OUT(cPages) RT_UOFFSETOF(SUPPAGELOCK, u.Out.aPages[cPages])
732typedef struct SUPPAGELOCK
733{
734 /** The header. */
735 SUPREQHDR Hdr;
736 union
737 {
738 struct
739 {
740 /** Start of page range. Must be PAGE aligned. */
741 RTR3PTR pvR3;
742 /** The range size given as a page count. */
743 uint32_t cPages;
744 } In;
745
746 struct
747 {
748 /** Array of pages. */
749 RTHCPHYS aPages[1];
750 } Out;
751 } u;
752} SUPPAGELOCK, *PSUPPAGELOCK;
753/** @} */
754
755
756/** @name SUP_IOCTL_PAGE_UNLOCK
757 * Unpin physical pages.
758 * @{ */
759#define SUP_IOCTL_PAGE_UNLOCK SUP_CTL_CODE_SIZE(15, SUP_IOCTL_PAGE_UNLOCK_SIZE)
760#define SUP_IOCTL_PAGE_UNLOCK_SIZE sizeof(SUPPAGEUNLOCK)
761#define SUP_IOCTL_PAGE_UNLOCK_SIZE_IN sizeof(SUPPAGEUNLOCK)
762#define SUP_IOCTL_PAGE_UNLOCK_SIZE_OUT sizeof(SUPREQHDR)
763typedef struct SUPPAGEUNLOCK
764{
765 /** The header. */
766 SUPREQHDR Hdr;
767 union
768 {
769 struct
770 {
771 /** Start of page range of a range previuosly pinned. */
772 RTR3PTR pvR3;
773 } In;
774 } u;
775} SUPPAGEUNLOCK, *PSUPPAGEUNLOCK;
776/** @} */
777
778
779/** @name SUP_IOCTL_CONT_ALLOC
780 * Allocate contious memory.
781 * @{
782 */
783#define SUP_IOCTL_CONT_ALLOC SUP_CTL_CODE_SIZE(16, SUP_IOCTL_CONT_ALLOC_SIZE)
784#define SUP_IOCTL_CONT_ALLOC_SIZE sizeof(SUPCONTALLOC)
785#define SUP_IOCTL_CONT_ALLOC_SIZE_IN (sizeof(SUPREQHDR) + RT_SIZEOFMEMB(SUPCONTALLOC, u.In))
786#define SUP_IOCTL_CONT_ALLOC_SIZE_OUT sizeof(SUPCONTALLOC)
787typedef struct SUPCONTALLOC
788{
789 /** The header. */
790 SUPREQHDR Hdr;
791 union
792 {
793 struct
794 {
795 /** The allocation size given as a page count. */
796 uint32_t cPages;
797 } In;
798
799 struct
800 {
801 /** The address of the ring-0 mapping of the allocated memory. */
802 RTR0PTR pvR0;
803 /** The address of the ring-3 mapping of the allocated memory. */
804 RTR3PTR pvR3;
805 /** The physical address of the allocation. */
806 RTHCPHYS HCPhys;
807 } Out;
808 } u;
809} SUPCONTALLOC, *PSUPCONTALLOC;
810/** @} */
811
812
813/** @name SUP_IOCTL_CONT_FREE Input.
814 * @{
815 */
816/** Free contious memory. */
817#define SUP_IOCTL_CONT_FREE SUP_CTL_CODE_SIZE(17, SUP_IOCTL_CONT_FREE_SIZE)
818#define SUP_IOCTL_CONT_FREE_SIZE sizeof(SUPCONTFREE)
819#define SUP_IOCTL_CONT_FREE_SIZE_IN sizeof(SUPCONTFREE)
820#define SUP_IOCTL_CONT_FREE_SIZE_OUT sizeof(SUPREQHDR)
821typedef struct SUPCONTFREE
822{
823 /** The header. */
824 SUPREQHDR Hdr;
825 union
826 {
827 struct
828 {
829 /** The ring-3 address of the memory to free. */
830 RTR3PTR pvR3;
831 } In;
832 } u;
833} SUPCONTFREE, *PSUPCONTFREE;
834/** @} */
835
836
837/** @name SUP_IOCTL_GET_PAGING_MODE
838 * Get the host paging mode.
839 * @{
840 */
841#define SUP_IOCTL_GET_PAGING_MODE SUP_CTL_CODE_SIZE(18, SUP_IOCTL_GET_PAGING_MODE_SIZE)
842#define SUP_IOCTL_GET_PAGING_MODE_SIZE sizeof(SUPGETPAGINGMODE)
843#define SUP_IOCTL_GET_PAGING_MODE_SIZE_IN sizeof(SUPREQHDR)
844#define SUP_IOCTL_GET_PAGING_MODE_SIZE_OUT sizeof(SUPGETPAGINGMODE)
845typedef struct SUPGETPAGINGMODE
846{
847 /** The header. */
848 SUPREQHDR Hdr;
849 union
850 {
851 struct
852 {
853 /** The paging mode. */
854 SUPPAGINGMODE enmMode;
855 } Out;
856 } u;
857} SUPGETPAGINGMODE, *PSUPGETPAGINGMODE;
858/** @} */
859
860
861/** @name SUP_IOCTL_SET_VM_FOR_FAST
862 * Set the VM handle for doing fast call ioctl calls.
863 * @{
864 */
865#define SUP_IOCTL_SET_VM_FOR_FAST SUP_CTL_CODE_SIZE(19, SUP_IOCTL_SET_VM_FOR_FAST_SIZE)
866#define SUP_IOCTL_SET_VM_FOR_FAST_SIZE sizeof(SUPSETVMFORFAST)
867#define SUP_IOCTL_SET_VM_FOR_FAST_SIZE_IN sizeof(SUPSETVMFORFAST)
868#define SUP_IOCTL_SET_VM_FOR_FAST_SIZE_OUT sizeof(SUPREQHDR)
869typedef struct SUPSETVMFORFAST
870{
871 /** The header. */
872 SUPREQHDR Hdr;
873 union
874 {
875 struct
876 {
877 /** The ring-0 VM handle (pointer). */
878 PVMR0 pVMR0;
879 } In;
880 } u;
881} SUPSETVMFORFAST, *PSUPSETVMFORFAST;
882/** @} */
883
884
885/** @name SUP_IOCTL_GIP_MAP
886 * Map the GIP into user space.
887 * @{
888 */
889#define SUP_IOCTL_GIP_MAP SUP_CTL_CODE_SIZE(20, SUP_IOCTL_GIP_MAP_SIZE)
890#define SUP_IOCTL_GIP_MAP_SIZE sizeof(SUPGIPMAP)
891#define SUP_IOCTL_GIP_MAP_SIZE_IN sizeof(SUPREQHDR)
892#define SUP_IOCTL_GIP_MAP_SIZE_OUT sizeof(SUPGIPMAP)
893typedef struct SUPGIPMAP
894{
895 /** The header. */
896 SUPREQHDR Hdr;
897 union
898 {
899 struct
900 {
901 /** The physical address of the GIP. */
902 RTHCPHYS HCPhysGip;
903 /** Pointer to the read-only usermode GIP mapping for this session. */
904 R3PTRTYPE(PSUPGLOBALINFOPAGE) pGipR3;
905 /** Pointer to the supervisor mode GIP mapping. */
906 R0PTRTYPE(PSUPGLOBALINFOPAGE) pGipR0;
907 } Out;
908 } u;
909} SUPGIPMAP, *PSUPGIPMAP;
910/** @} */
911
912
913/** @name SUP_IOCTL_GIP_UNMAP
914 * Unmap the GIP.
915 * @{
916 */
917#define SUP_IOCTL_GIP_UNMAP SUP_CTL_CODE_SIZE(21, SUP_IOCTL_GIP_UNMAP_SIZE)
918#define SUP_IOCTL_GIP_UNMAP_SIZE sizeof(SUPGIPUNMAP)
919#define SUP_IOCTL_GIP_UNMAP_SIZE_IN sizeof(SUPGIPUNMAP)
920#define SUP_IOCTL_GIP_UNMAP_SIZE_OUT sizeof(SUPGIPUNMAP)
921typedef struct SUPGIPUNMAP
922{
923 /** The header. */
924 SUPREQHDR Hdr;
925} SUPGIPUNMAP, *PSUPGIPUNMAP;
926/** @} */
927
928
929/** @name SUP_IOCTL_CALL_SERVICE
930 * Call the a ring-0 service.
931 *
932 * @todo Might have to convert this to a big request, just like
933 * SUP_IOCTL_CALL_VMMR0
934 * @{
935 */
936#define SUP_IOCTL_CALL_SERVICE(cbReq) SUP_CTL_CODE_SIZE(22, SUP_IOCTL_CALL_SERVICE_SIZE(cbReq))
937#define SUP_IOCTL_CALL_SERVICE_SIZE(cbReq) RT_UOFFSETOF(SUPCALLSERVICE, abReqPkt[cbReq])
938#define SUP_IOCTL_CALL_SERVICE_SIZE_IN(cbReq) SUP_IOCTL_CALL_SERVICE_SIZE(cbReq)
939#define SUP_IOCTL_CALL_SERVICE_SIZE_OUT(cbReq) SUP_IOCTL_CALL_SERVICE_SIZE(cbReq)
940typedef struct SUPCALLSERVICE
941{
942 /** The header. */
943 SUPREQHDR Hdr;
944 union
945 {
946 struct
947 {
948 /** The service name. */
949 char szName[28];
950 /** Which operation to execute. */
951 uint32_t uOperation;
952 /** Argument to use when no request packet is supplied. */
953 uint64_t u64Arg;
954 } In;
955 } u;
956 /** The request packet passed to SUP. */
957 uint8_t abReqPkt[1];
958} SUPCALLSERVICE, *PSUPCALLSERVICE;
959/** @} */
960
961
962/** @name SUP_IOCTL_LOGGER_SETTINGS
963 * Changes the ring-0 release or debug logger settings.
964 * @{
965 */
966#define SUP_IOCTL_LOGGER_SETTINGS(cbStrTab) SUP_CTL_CODE_SIZE(23, SUP_IOCTL_LOGGER_SETTINGS_SIZE(cbStrTab))
967#define SUP_IOCTL_LOGGER_SETTINGS_SIZE(cbStrTab) RT_UOFFSETOF(SUPLOGGERSETTINGS, u.In.szStrings[cbStrTab])
968#define SUP_IOCTL_LOGGER_SETTINGS_SIZE_IN(cbStrTab) RT_UOFFSETOF(SUPLOGGERSETTINGS, u.In.szStrings[cbStrTab])
969#define SUP_IOCTL_LOGGER_SETTINGS_SIZE_OUT sizeof(SUPREQHDR)
970typedef struct SUPLOGGERSETTINGS
971{
972 /** The header. */
973 SUPREQHDR Hdr;
974 union
975 {
976 struct
977 {
978 /** Which logger. */
979 uint32_t fWhich;
980 /** What to do with it. */
981 uint32_t fWhat;
982 /** Offset of the flags setting string. */
983 uint32_t offFlags;
984 /** Offset of the groups setting string. */
985 uint32_t offGroups;
986 /** Offset of the destination setting string. */
987 uint32_t offDestination;
988 /** The string table. */
989 char szStrings[1];
990 } In;
991 } u;
992} SUPLOGGERSETTINGS, *PSUPLOGGERSETTINGS;
993
994/** Debug logger. */
995#define SUPLOGGERSETTINGS_WHICH_DEBUG 0
996/** Release logger. */
997#define SUPLOGGERSETTINGS_WHICH_RELEASE 1
998
999/** Change the settings. */
1000#define SUPLOGGERSETTINGS_WHAT_SETTINGS 0
1001/** Create the logger instance. */
1002#define SUPLOGGERSETTINGS_WHAT_CREATE 1
1003/** Destroy the logger instance. */
1004#define SUPLOGGERSETTINGS_WHAT_DESTROY 2
1005
1006/** @} */
1007
1008
1009/** @name Semaphore Types
1010 * @{ */
1011#define SUP_SEM_TYPE_EVENT 0
1012#define SUP_SEM_TYPE_EVENT_MULTI 1
1013/** @} */
1014
1015
1016/** @name SUP_IOCTL_SEM_CREATE
1017 * Create a semaphore
1018 * @{
1019 */
1020#define SUP_IOCTL_SEM_CREATE SUP_CTL_CODE_SIZE(24, SUP_IOCTL_SEM_CREATE_SIZE)
1021#define SUP_IOCTL_SEM_CREATE_SIZE sizeof(SUPSEMCREATE)
1022#define SUP_IOCTL_SEM_CREATE_SIZE_IN sizeof(SUPSEMCREATE)
1023#define SUP_IOCTL_SEM_CREATE_SIZE_OUT sizeof(SUPSEMCREATE)
1024typedef struct SUPSEMCREATE
1025{
1026 /** The header. */
1027 SUPREQHDR Hdr;
1028 union
1029 {
1030 struct
1031 {
1032 /** The semaphore type. */
1033 uint32_t uType;
1034 } In;
1035 struct
1036 {
1037 /** The handle of the created semaphore. */
1038 uint32_t hSem;
1039 } Out;
1040 } u;
1041} SUPSEMCREATE, *PSUPSEMCREATE;
1042
1043/** @} */
1044
1045
1046/** @name SUP_IOCTL_SEM_OP
1047 * Semaphore operations.
1048 * @{
1049 */
1050#define SUP_IOCTL_SEM_OP SUP_CTL_CODE_SIZE(25, SUP_IOCTL_SEM_OP_SIZE)
1051#define SUP_IOCTL_SEM_OP_SIZE sizeof(SUPSEMOP)
1052#define SUP_IOCTL_SEM_OP_SIZE_IN sizeof(SUPSEMOP)
1053#define SUP_IOCTL_SEM_OP_SIZE_OUT sizeof(SUPREQHDR)
1054typedef struct SUPSEMOP
1055{
1056 /** The header. */
1057 SUPREQHDR Hdr;
1058 union
1059 {
1060 struct
1061 {
1062 /** The semaphore type. */
1063 uint32_t uType;
1064 /** The semaphore handle. */
1065 uint32_t hSem;
1066 /** The operation. */
1067 uint32_t uOp;
1068 /** The number of milliseconds to wait if it's a wait operation. */
1069 uint32_t cMillies;
1070 } In;
1071 } u;
1072} SUPSEMOP, *PSUPSEMOP;
1073
1074/** Wait for a number of millisecons. */
1075#define SUPSEMOP_WAIT 0
1076/** Signal the semaphore. */
1077#define SUPSEMOP_SIGNAL 1
1078/** Reset the sempahore (only applicable to SUP_SEM_TYPE_EVENT_MULTI). */
1079#define SUPSEMOP_RESET 2
1080/** Close the semaphore handle. */
1081#define SUPSEMOP_CLOSE 3
1082
1083/** @} */
1084
1085/** @name SUP_IOCTL_VT_CAPS Input.
1086 * @{
1087 */
1088/** Free contious memory. */
1089#define SUP_IOCTL_VT_CAPS SUP_CTL_CODE_SIZE(26, SUP_IOCTL_VT_CAPS_SIZE)
1090#define SUP_IOCTL_VT_CAPS_SIZE sizeof(SUPVTCAPS)
1091#define SUP_IOCTL_VT_CAPS_SIZE_IN sizeof(SUPREQHDR)
1092#define SUP_IOCTL_VT_CAPS_SIZE_OUT sizeof(SUPVTCAPS)
1093typedef struct SUPVTCAPS
1094{
1095 /** The header. */
1096 SUPREQHDR Hdr;
1097 union
1098 {
1099 struct
1100 {
1101 /** The VT capability dword. */
1102 uint32_t Caps;
1103 } Out;
1104 } u;
1105} SUPVTCAPS, *PSUPVTCAPS;
1106/** @} */
1107
1108#pragma pack() /* paranoia */
1109
1110#endif
1111
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