VirtualBox

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

Last change on this file since 19394 was 19394, checked in by vboxsync, 16 years ago

SUPDrv: expose RTMpPokeCpu, minor version incremented.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 34.3 KB
Line 
1/* $Revision: 19394 $ */
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/stdint.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 * @todo Pending work on next major version change:
186 * - Eliminate supdrvPageWasLockedByPageAlloc and supdrvPageGetPhys.
187 * - Remove SUPR0PageAlloc in favor of SUPR0PageAllocEx, removing
188 * and renaming the related IOCtls too.
189 */
190#define SUPDRV_IOC_VERSION 0x000b0001
191
192/** SUP_IOCTL_COOKIE. */
193typedef struct SUPCOOKIE
194{
195 /** The header.
196 * u32Cookie must be set to SUPCOOKIE_INITIAL_COOKIE.
197 * u32SessionCookie should be set to some random value. */
198 SUPREQHDR Hdr;
199 union
200 {
201 struct
202 {
203 /** Magic word. */
204 char szMagic[16];
205 /** The requested interface version number. */
206 uint32_t u32ReqVersion;
207 /** The minimum interface version number. */
208 uint32_t u32MinVersion;
209 } In;
210 struct
211 {
212 /** Cookie. */
213 uint32_t u32Cookie;
214 /** Session cookie. */
215 uint32_t u32SessionCookie;
216 /** Interface version for this session. */
217 uint32_t u32SessionVersion;
218 /** The actual interface version in the driver. */
219 uint32_t u32DriverVersion;
220 /** Number of functions available for the SUP_IOCTL_QUERY_FUNCS request. */
221 uint32_t cFunctions;
222 /** Session handle. */
223 R0PTRTYPE(PSUPDRVSESSION) pSession;
224 } Out;
225 } u;
226} SUPCOOKIE, *PSUPCOOKIE;
227/** @} */
228
229
230/** @name SUP_IOCTL_QUERY_FUNCS
231 * Query SUPR0 functions.
232 * @{
233 */
234#define SUP_IOCTL_QUERY_FUNCS(cFuncs) SUP_CTL_CODE_SIZE(2, SUP_IOCTL_QUERY_FUNCS_SIZE(cFuncs))
235#define SUP_IOCTL_QUERY_FUNCS_SIZE(cFuncs) RT_UOFFSETOF(SUPQUERYFUNCS, u.Out.aFunctions[(cFuncs)])
236#define SUP_IOCTL_QUERY_FUNCS_SIZE_IN sizeof(SUPREQHDR)
237#define SUP_IOCTL_QUERY_FUNCS_SIZE_OUT(cFuncs) SUP_IOCTL_QUERY_FUNCS_SIZE(cFuncs)
238
239/** A function. */
240typedef struct SUPFUNC
241{
242 /** Name - mangled. */
243 char szName[32];
244 /** Address. */
245 RTR0PTR pfn;
246} SUPFUNC, *PSUPFUNC;
247
248typedef struct SUPQUERYFUNCS
249{
250 /** The header. */
251 SUPREQHDR Hdr;
252 union
253 {
254 struct
255 {
256 /** Number of functions returned. */
257 uint32_t cFunctions;
258 /** Array of functions. */
259 SUPFUNC aFunctions[1];
260 } Out;
261 } u;
262} SUPQUERYFUNCS, *PSUPQUERYFUNCS;
263/** @} */
264
265
266/** @name SUP_IOCTL_IDT_INSTALL
267 * Install IDT patch for calling processor.
268 * @{
269 */
270#define SUP_IOCTL_IDT_INSTALL SUP_CTL_CODE_SIZE(3, SUP_IOCTL_IDT_INSTALL_SIZE)
271#define SUP_IOCTL_IDT_INSTALL_SIZE sizeof(SUPIDTINSTALL)
272#define SUP_IOCTL_IDT_INSTALL_SIZE_IN sizeof(SUPREQHDR)
273#define SUP_IOCTL_IDT_INSTALL_SIZE_OUT sizeof(SUPIDTINSTALL)
274typedef struct SUPIDTINSTALL
275{
276 /** The header. */
277 SUPREQHDR Hdr;
278 union
279 {
280 struct
281 {
282 /** The IDT entry number. */
283 uint8_t u8Idt;
284 } Out;
285 } u;
286} SUPIDTINSTALL, *PSUPIDTINSTALL;
287/** @} */
288
289
290/** @name SUP_IOCTL_IDT_REMOVE
291 * Remove IDT patch for calling processor.
292 * @{
293 */
294#define SUP_IOCTL_IDT_REMOVE SUP_CTL_CODE_SIZE(4, SUP_IOCTL_IDT_REMOVE_SIZE)
295#define SUP_IOCTL_IDT_REMOVE_SIZE sizeof(SUPIDTREMOVE)
296#define SUP_IOCTL_IDT_REMOVE_SIZE_IN sizeof(SUPIDTREMOVE)
297#define SUP_IOCTL_IDT_REMOVE_SIZE_OUT sizeof(SUPIDTREMOVE)
298typedef struct SUPIDTREMOVE
299{
300 /** The header. */
301 SUPREQHDR Hdr;
302} SUPIDTREMOVE, *PSUPIDTREMOVE;
303/** @}*/
304
305
306/** @name SUP_IOCTL_LDR_OPEN
307 * Open an image.
308 * @{
309 */
310#define SUP_IOCTL_LDR_OPEN SUP_CTL_CODE_SIZE(5, SUP_IOCTL_LDR_OPEN_SIZE)
311#define SUP_IOCTL_LDR_OPEN_SIZE sizeof(SUPLDROPEN)
312#define SUP_IOCTL_LDR_OPEN_SIZE_IN sizeof(SUPLDROPEN)
313#define SUP_IOCTL_LDR_OPEN_SIZE_OUT (sizeof(SUPREQHDR) + RT_SIZEOFMEMB(SUPLDROPEN, u.Out))
314typedef struct SUPLDROPEN
315{
316 /** The header. */
317 SUPREQHDR Hdr;
318 union
319 {
320 struct
321 {
322 /** Size of the image we'll be loading. */
323 uint32_t cbImage;
324 /** Image name.
325 * This is the NAME of the image, not the file name. It is used
326 * to share code with other processes. (Max len is 32 chars!) */
327 char szName[32];
328 } In;
329 struct
330 {
331 /** The base address of the image. */
332 RTR0PTR pvImageBase;
333 /** Indicate whether or not the image requires loading. */
334 bool fNeedsLoading;
335 } Out;
336 } u;
337} SUPLDROPEN, *PSUPLDROPEN;
338/** @} */
339
340
341/** @name SUP_IOCTL_LDR_LOAD
342 * Upload the image bits.
343 * @{
344 */
345#define SUP_IOCTL_LDR_LOAD SUP_CTL_CODE_BIG(6)
346#define SUP_IOCTL_LDR_LOAD_SIZE(cbImage) RT_UOFFSETOF(SUPLDRLOAD, u.In.achImage[cbImage])
347#define SUP_IOCTL_LDR_LOAD_SIZE_IN(cbImage) RT_UOFFSETOF(SUPLDRLOAD, u.In.achImage[cbImage])
348#define SUP_IOCTL_LDR_LOAD_SIZE_OUT sizeof(SUPREQHDR)
349
350/**
351 * Module initialization callback function.
352 * This is called once after the module has been loaded.
353 *
354 * @returns 0 on success.
355 * @returns Appropriate error code on failure.
356 */
357typedef DECLCALLBACK(int) FNR0MODULEINIT(void);
358/** Pointer to a FNR0MODULEINIT(). */
359typedef R0PTRTYPE(FNR0MODULEINIT *) PFNR0MODULEINIT;
360
361/**
362 * Module termination callback function.
363 * This is called once right before the module is being unloaded.
364 */
365typedef DECLCALLBACK(void) FNR0MODULETERM(void);
366/** Pointer to a FNR0MODULETERM(). */
367typedef R0PTRTYPE(FNR0MODULETERM *) PFNR0MODULETERM;
368
369/**
370 * Symbol table entry.
371 */
372typedef struct SUPLDRSYM
373{
374 /** Offset into of the string table. */
375 uint32_t offName;
376 /** Offset of the symbol relative to the image load address. */
377 uint32_t offSymbol;
378} SUPLDRSYM;
379/** Pointer to a symbol table entry. */
380typedef SUPLDRSYM *PSUPLDRSYM;
381/** Pointer to a const symbol table entry. */
382typedef SUPLDRSYM const *PCSUPLDRSYM;
383
384/**
385 * SUPLDRLOAD::u::In::EP type.
386 */
387typedef enum SUPLDRLOADEP
388{
389 SUPLDRLOADEP_NOTHING = 0,
390 SUPLDRLOADEP_VMMR0,
391 SUPLDRLOADEP_SERVICE,
392 SUPLDRLOADEP_32BIT_HACK = 0x7fffffff
393} SUPLDRLOADEP;
394
395typedef struct SUPLDRLOAD
396{
397 /** The header. */
398 SUPREQHDR Hdr;
399 union
400 {
401 struct
402 {
403 /** The address of module initialization function. Similar to _DLL_InitTerm(hmod, 0). */
404 PFNR0MODULEINIT pfnModuleInit;
405 /** The address of module termination function. Similar to _DLL_InitTerm(hmod, 1). */
406 PFNR0MODULETERM pfnModuleTerm;
407 /** Special entry points. */
408 union
409 {
410 /** SUPLDRLOADEP_VMMR0. */
411 struct
412 {
413 /** The module handle (i.e. address). */
414 RTR0PTR pvVMMR0;
415 /** Address of VMMR0EntryInt function. */
416 RTR0PTR pvVMMR0EntryInt;
417 /** Address of VMMR0EntryFast function. */
418 RTR0PTR pvVMMR0EntryFast;
419 /** Address of VMMR0EntryEx function. */
420 RTR0PTR pvVMMR0EntryEx;
421 } VMMR0;
422 /** SUPLDRLOADEP_SERVICE. */
423 struct
424 {
425 /** The service request handler.
426 * (PFNR0SERVICEREQHANDLER isn't defined yet.) */
427 RTR0PTR pfnServiceReq;
428 /** Reserved, must be NIL. */
429 RTR0PTR apvReserved[3];
430 } Service;
431 } EP;
432 /** Address. */
433 RTR0PTR pvImageBase;
434 /** Entry point type. */
435 SUPLDRLOADEP eEPType;
436 /** The offset of the symbol table. */
437 uint32_t offSymbols;
438 /** The number of entries in the symbol table. */
439 uint32_t cSymbols;
440 /** The offset of the string table. */
441 uint32_t offStrTab;
442 /** Size of the string table. */
443 uint32_t cbStrTab;
444 /** Size of image (including string and symbol tables). */
445 uint32_t cbImage;
446 /** The image data. */
447 char achImage[1];
448 } In;
449 } u;
450} SUPLDRLOAD, *PSUPLDRLOAD;
451/** @} */
452
453
454/** @name SUP_IOCTL_LDR_FREE
455 * Free an image.
456 * @{
457 */
458#define SUP_IOCTL_LDR_FREE SUP_CTL_CODE_SIZE(7, SUP_IOCTL_LDR_FREE_SIZE)
459#define SUP_IOCTL_LDR_FREE_SIZE sizeof(SUPLDRFREE)
460#define SUP_IOCTL_LDR_FREE_SIZE_IN sizeof(SUPLDRFREE)
461#define SUP_IOCTL_LDR_FREE_SIZE_OUT sizeof(SUPREQHDR)
462typedef struct SUPLDRFREE
463{
464 /** The header. */
465 SUPREQHDR Hdr;
466 union
467 {
468 struct
469 {
470 /** Address. */
471 RTR0PTR pvImageBase;
472 } In;
473 } u;
474} SUPLDRFREE, *PSUPLDRFREE;
475/** @} */
476
477
478/** @name SUP_IOCTL_LDR_GET_SYMBOL
479 * Get address of a symbol within an image.
480 * @{
481 */
482#define SUP_IOCTL_LDR_GET_SYMBOL SUP_CTL_CODE_SIZE(8, SUP_IOCTL_LDR_GET_SYMBOL_SIZE)
483#define SUP_IOCTL_LDR_GET_SYMBOL_SIZE sizeof(SUPLDRGETSYMBOL)
484#define SUP_IOCTL_LDR_GET_SYMBOL_SIZE_IN sizeof(SUPLDRGETSYMBOL)
485#define SUP_IOCTL_LDR_GET_SYMBOL_SIZE_OUT (sizeof(SUPREQHDR) + RT_SIZEOFMEMB(SUPLDRGETSYMBOL, u.Out))
486typedef struct SUPLDRGETSYMBOL
487{
488 /** The header. */
489 SUPREQHDR Hdr;
490 union
491 {
492 struct
493 {
494 /** Address. */
495 RTR0PTR pvImageBase;
496 /** The symbol name. */
497 char szSymbol[64];
498 } In;
499 struct
500 {
501 /** The symbol address. */
502 RTR0PTR pvSymbol;
503 } Out;
504 } u;
505} SUPLDRGETSYMBOL, *PSUPLDRGETSYMBOL;
506/** @} */
507
508
509/** @name SUP_IOCTL_CALL_VMMR0
510 * Call the R0 VMM Entry point.
511 *
512 * @todo Might have to convert this to a big request...
513 * @{
514 */
515#define SUP_IOCTL_CALL_VMMR0(cbReq) SUP_CTL_CODE_SIZE(9, SUP_IOCTL_CALL_VMMR0_SIZE(cbReq))
516#define SUP_IOCTL_CALL_VMMR0_SIZE(cbReq) RT_UOFFSETOF(SUPCALLVMMR0, abReqPkt[cbReq])
517#define SUP_IOCTL_CALL_VMMR0_SIZE_IN(cbReq) SUP_IOCTL_CALL_VMMR0_SIZE(cbReq)
518#define SUP_IOCTL_CALL_VMMR0_SIZE_OUT(cbReq) SUP_IOCTL_CALL_VMMR0_SIZE(cbReq)
519typedef struct SUPCALLVMMR0
520{
521 /** The header. */
522 SUPREQHDR Hdr;
523 union
524 {
525 struct
526 {
527 /** The VM handle. */
528 PVMR0 pVMR0;
529 /** VCPU id. */
530 uint32_t idCpu;
531 /** Which operation to execute. */
532 uint32_t uOperation;
533 /** Argument to use when no request packet is supplied. */
534 uint64_t u64Arg;
535 } In;
536 } u;
537 /** The VMMR0Entry request packet. */
538 uint8_t abReqPkt[1];
539} SUPCALLVMMR0, *PSUPCALLVMMR0;
540/** @} */
541
542
543/** @name SUP_IOCTL_LOW_ALLOC
544 * Allocate memory below 4GB (physically).
545 * @{
546 */
547#define SUP_IOCTL_LOW_ALLOC SUP_CTL_CODE_BIG(10)
548#define SUP_IOCTL_LOW_ALLOC_SIZE(cPages) ((uint32_t)RT_UOFFSETOF(SUPLOWALLOC, u.Out.aPages[cPages]))
549#define SUP_IOCTL_LOW_ALLOC_SIZE_IN (sizeof(SUPREQHDR) + RT_SIZEOFMEMB(SUPLOWALLOC, u.In))
550#define SUP_IOCTL_LOW_ALLOC_SIZE_OUT(cPages) SUP_IOCTL_LOW_ALLOC_SIZE(cPages)
551typedef struct SUPLOWALLOC
552{
553 /** The header. */
554 SUPREQHDR Hdr;
555 union
556 {
557 struct
558 {
559 /** Number of pages to allocate. */
560 uint32_t cPages;
561 } In;
562 struct
563 {
564 /** The ring-3 address of the allocated memory. */
565 RTR3PTR pvR3;
566 /** The ring-0 address of the allocated memory. */
567 RTR0PTR pvR0;
568 /** Array of pages. */
569 RTHCPHYS aPages[1];
570 } Out;
571 } u;
572} SUPLOWALLOC, *PSUPLOWALLOC;
573/** @} */
574
575
576/** @name SUP_IOCTL_LOW_FREE
577 * Free low memory.
578 * @{
579 */
580#define SUP_IOCTL_LOW_FREE SUP_CTL_CODE_SIZE(11, SUP_IOCTL_LOW_FREE_SIZE)
581#define SUP_IOCTL_LOW_FREE_SIZE sizeof(SUPLOWFREE)
582#define SUP_IOCTL_LOW_FREE_SIZE_IN sizeof(SUPLOWFREE)
583#define SUP_IOCTL_LOW_FREE_SIZE_OUT sizeof(SUPREQHDR)
584typedef struct SUPLOWFREE
585{
586 /** The header. */
587 SUPREQHDR Hdr;
588 union
589 {
590 struct
591 {
592 /** The ring-3 address of the memory to free. */
593 RTR3PTR pvR3;
594 } In;
595 } u;
596} SUPLOWFREE, *PSUPLOWFREE;
597/** @} */
598
599
600/** @name SUP_IOCTL_PAGE_ALLOC
601 * Allocate memory and map into the user process.
602 * The memory is of course locked.
603 * @{
604 */
605#define SUP_IOCTL_PAGE_ALLOC SUP_CTL_CODE_BIG(12)
606#define SUP_IOCTL_PAGE_ALLOC_SIZE(cPages) RT_UOFFSETOF(SUPPAGEALLOC, u.Out.aPages[cPages])
607#define SUP_IOCTL_PAGE_ALLOC_SIZE_IN (sizeof(SUPREQHDR) + RT_SIZEOFMEMB(SUPPAGEALLOC, u.In))
608#define SUP_IOCTL_PAGE_ALLOC_SIZE_OUT(cPages) SUP_IOCTL_PAGE_ALLOC_SIZE(cPages)
609typedef struct SUPPAGEALLOC
610{
611 /** The header. */
612 SUPREQHDR Hdr;
613 union
614 {
615 struct
616 {
617 /** Number of pages to allocate */
618 uint32_t cPages;
619 } In;
620 struct
621 {
622 /** Returned ring-3 address. */
623 RTR3PTR pvR3;
624 /** The physical addresses of the allocated pages. */
625 RTHCPHYS aPages[1];
626 } Out;
627 } u;
628} SUPPAGEALLOC, *PSUPPAGEALLOC;
629/** @} */
630
631
632/** @name SUP_IOCTL_PAGE_FREE
633 * Free memory allocated with SUP_IOCTL_PAGE_ALLOC or SUP_IOCTL_PAGE_ALLOC_EX.
634 * @{
635 */
636#define SUP_IOCTL_PAGE_FREE SUP_CTL_CODE_SIZE(13, SUP_IOCTL_PAGE_FREE_SIZE_IN)
637#define SUP_IOCTL_PAGE_FREE_SIZE sizeof(SUPPAGEFREE)
638#define SUP_IOCTL_PAGE_FREE_SIZE_IN sizeof(SUPPAGEFREE)
639#define SUP_IOCTL_PAGE_FREE_SIZE_OUT sizeof(SUPREQHDR)
640typedef struct SUPPAGEFREE
641{
642 /** The header. */
643 SUPREQHDR Hdr;
644 union
645 {
646 struct
647 {
648 /** Address of memory range to free. */
649 RTR3PTR pvR3;
650 } In;
651 } u;
652} SUPPAGEFREE, *PSUPPAGEFREE;
653/** @} */
654
655
656/** @name SUP_IOCTL_PAGE_LOCK
657 * Pin down physical pages.
658 * @{
659 */
660#define SUP_IOCTL_PAGE_LOCK SUP_CTL_CODE_BIG(14)
661#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)))
662#define SUP_IOCTL_PAGE_LOCK_SIZE_IN (sizeof(SUPREQHDR) + RT_SIZEOFMEMB(SUPPAGELOCK, u.In))
663#define SUP_IOCTL_PAGE_LOCK_SIZE_OUT(cPages) RT_UOFFSETOF(SUPPAGELOCK, u.Out.aPages[cPages])
664typedef struct SUPPAGELOCK
665{
666 /** The header. */
667 SUPREQHDR Hdr;
668 union
669 {
670 struct
671 {
672 /** Start of page range. Must be PAGE aligned. */
673 RTR3PTR pvR3;
674 /** The range size given as a page count. */
675 uint32_t cPages;
676 } In;
677
678 struct
679 {
680 /** Array of pages. */
681 RTHCPHYS aPages[1];
682 } Out;
683 } u;
684} SUPPAGELOCK, *PSUPPAGELOCK;
685/** @} */
686
687
688/** @name SUP_IOCTL_PAGE_UNLOCK
689 * Unpin physical pages.
690 * @{ */
691#define SUP_IOCTL_PAGE_UNLOCK SUP_CTL_CODE_SIZE(15, SUP_IOCTL_PAGE_UNLOCK_SIZE)
692#define SUP_IOCTL_PAGE_UNLOCK_SIZE sizeof(SUPPAGEUNLOCK)
693#define SUP_IOCTL_PAGE_UNLOCK_SIZE_IN sizeof(SUPPAGEUNLOCK)
694#define SUP_IOCTL_PAGE_UNLOCK_SIZE_OUT sizeof(SUPREQHDR)
695typedef struct SUPPAGEUNLOCK
696{
697 /** The header. */
698 SUPREQHDR Hdr;
699 union
700 {
701 struct
702 {
703 /** Start of page range of a range previuosly pinned. */
704 RTR3PTR pvR3;
705 } In;
706 } u;
707} SUPPAGEUNLOCK, *PSUPPAGEUNLOCK;
708/** @} */
709
710
711/** @name SUP_IOCTL_CONT_ALLOC
712 * Allocate contious memory.
713 * @{
714 */
715#define SUP_IOCTL_CONT_ALLOC SUP_CTL_CODE_SIZE(16, SUP_IOCTL_CONT_ALLOC_SIZE)
716#define SUP_IOCTL_CONT_ALLOC_SIZE sizeof(SUPCONTALLOC)
717#define SUP_IOCTL_CONT_ALLOC_SIZE_IN (sizeof(SUPREQHDR) + RT_SIZEOFMEMB(SUPCONTALLOC, u.In))
718#define SUP_IOCTL_CONT_ALLOC_SIZE_OUT sizeof(SUPCONTALLOC)
719typedef struct SUPCONTALLOC
720{
721 /** The header. */
722 SUPREQHDR Hdr;
723 union
724 {
725 struct
726 {
727 /** The allocation size given as a page count. */
728 uint32_t cPages;
729 } In;
730
731 struct
732 {
733 /** The address of the ring-0 mapping of the allocated memory. */
734 RTR0PTR pvR0;
735 /** The address of the ring-3 mapping of the allocated memory. */
736 RTR3PTR pvR3;
737 /** The physical address of the allocation. */
738 RTHCPHYS HCPhys;
739 } Out;
740 } u;
741} SUPCONTALLOC, *PSUPCONTALLOC;
742/** @} */
743
744
745/** @name SUP_IOCTL_CONT_FREE Input.
746 * @{
747 */
748/** Free contious memory. */
749#define SUP_IOCTL_CONT_FREE SUP_CTL_CODE_SIZE(17, SUP_IOCTL_CONT_FREE_SIZE)
750#define SUP_IOCTL_CONT_FREE_SIZE sizeof(SUPCONTFREE)
751#define SUP_IOCTL_CONT_FREE_SIZE_IN sizeof(SUPCONTFREE)
752#define SUP_IOCTL_CONT_FREE_SIZE_OUT sizeof(SUPREQHDR)
753typedef struct SUPCONTFREE
754{
755 /** The header. */
756 SUPREQHDR Hdr;
757 union
758 {
759 struct
760 {
761 /** The ring-3 address of the memory to free. */
762 RTR3PTR pvR3;
763 } In;
764 } u;
765} SUPCONTFREE, *PSUPCONTFREE;
766/** @} */
767
768
769/** @name SUP_IOCTL_GET_PAGING_MODE
770 * Get the host paging mode.
771 * @{
772 */
773#define SUP_IOCTL_GET_PAGING_MODE SUP_CTL_CODE_SIZE(18, SUP_IOCTL_GET_PAGING_MODE_SIZE)
774#define SUP_IOCTL_GET_PAGING_MODE_SIZE sizeof(SUPGETPAGINGMODE)
775#define SUP_IOCTL_GET_PAGING_MODE_SIZE_IN sizeof(SUPREQHDR)
776#define SUP_IOCTL_GET_PAGING_MODE_SIZE_OUT sizeof(SUPGETPAGINGMODE)
777typedef struct SUPGETPAGINGMODE
778{
779 /** The header. */
780 SUPREQHDR Hdr;
781 union
782 {
783 struct
784 {
785 /** The paging mode. */
786 SUPPAGINGMODE enmMode;
787 } Out;
788 } u;
789} SUPGETPAGINGMODE, *PSUPGETPAGINGMODE;
790/** @} */
791
792
793/** @name SUP_IOCTL_SET_VM_FOR_FAST
794 * Set the VM handle for doing fast call ioctl calls.
795 * @{
796 */
797#define SUP_IOCTL_SET_VM_FOR_FAST SUP_CTL_CODE_SIZE(19, SUP_IOCTL_SET_VM_FOR_FAST_SIZE)
798#define SUP_IOCTL_SET_VM_FOR_FAST_SIZE sizeof(SUPSETVMFORFAST)
799#define SUP_IOCTL_SET_VM_FOR_FAST_SIZE_IN sizeof(SUPSETVMFORFAST)
800#define SUP_IOCTL_SET_VM_FOR_FAST_SIZE_OUT sizeof(SUPREQHDR)
801typedef struct SUPSETVMFORFAST
802{
803 /** The header. */
804 SUPREQHDR Hdr;
805 union
806 {
807 struct
808 {
809 /** The ring-0 VM handle (pointer). */
810 PVMR0 pVMR0;
811 } In;
812 } u;
813} SUPSETVMFORFAST, *PSUPSETVMFORFAST;
814/** @} */
815
816
817/** @name SUP_IOCTL_GIP_MAP
818 * Map the GIP into user space.
819 * @{
820 */
821#define SUP_IOCTL_GIP_MAP SUP_CTL_CODE_SIZE(20, SUP_IOCTL_GIP_MAP_SIZE)
822#define SUP_IOCTL_GIP_MAP_SIZE sizeof(SUPGIPMAP)
823#define SUP_IOCTL_GIP_MAP_SIZE_IN sizeof(SUPREQHDR)
824#define SUP_IOCTL_GIP_MAP_SIZE_OUT sizeof(SUPGIPMAP)
825typedef struct SUPGIPMAP
826{
827 /** The header. */
828 SUPREQHDR Hdr;
829 union
830 {
831 struct
832 {
833 /** The physical address of the GIP. */
834 RTHCPHYS HCPhysGip;
835 /** Pointer to the read-only usermode GIP mapping for this session. */
836 R3PTRTYPE(PSUPGLOBALINFOPAGE) pGipR3;
837 /** Pointer to the supervisor mode GIP mapping. */
838 R0PTRTYPE(PSUPGLOBALINFOPAGE) pGipR0;
839 } Out;
840 } u;
841} SUPGIPMAP, *PSUPGIPMAP;
842/** @} */
843
844
845/** @name SUP_IOCTL_GIP_UNMAP
846 * Unmap the GIP.
847 * @{
848 */
849#define SUP_IOCTL_GIP_UNMAP SUP_CTL_CODE_SIZE(21, SUP_IOCTL_GIP_UNMAP_SIZE)
850#define SUP_IOCTL_GIP_UNMAP_SIZE sizeof(SUPGIPUNMAP)
851#define SUP_IOCTL_GIP_UNMAP_SIZE_IN sizeof(SUPGIPUNMAP)
852#define SUP_IOCTL_GIP_UNMAP_SIZE_OUT sizeof(SUPGIPUNMAP)
853typedef struct SUPGIPUNMAP
854{
855 /** The header. */
856 SUPREQHDR Hdr;
857} SUPGIPUNMAP, *PSUPGIPUNMAP;
858/** @} */
859
860
861/** @name SUP_IOCTL_CALL_SERVICE
862 * Call the a ring-0 service.
863 *
864 * @todo Might have to convert this to a big request, just like
865 * SUP_IOCTL_CALL_VMMR0
866 * @{
867 */
868#define SUP_IOCTL_CALL_SERVICE(cbReq) SUP_CTL_CODE_SIZE(22, SUP_IOCTL_CALL_SERVICE_SIZE(cbReq))
869#define SUP_IOCTL_CALL_SERVICE_SIZE(cbReq) RT_UOFFSETOF(SUPCALLSERVICE, abReqPkt[cbReq])
870#define SUP_IOCTL_CALL_SERVICE_SIZE_IN(cbReq) SUP_IOCTL_CALL_SERVICE_SIZE(cbReq)
871#define SUP_IOCTL_CALL_SERVICE_SIZE_OUT(cbReq) SUP_IOCTL_CALL_SERVICE_SIZE(cbReq)
872typedef struct SUPCALLSERVICE
873{
874 /** The header. */
875 SUPREQHDR Hdr;
876 union
877 {
878 struct
879 {
880 /** The service name. */
881 char szName[28];
882 /** Which operation to execute. */
883 uint32_t uOperation;
884 /** Argument to use when no request packet is supplied. */
885 uint64_t u64Arg;
886 } In;
887 } u;
888 /** The request packet passed to SUP. */
889 uint8_t abReqPkt[1];
890} SUPCALLSERVICE, *PSUPCALLSERVICE;
891/** @} */
892
893/** @name SUP_IOCTL_PAGE_ALLOC_EX
894 * Allocate memory and map it into kernel and/or user space. The memory is of
895 * course locked. This is an extended version of SUP_IOCTL_PAGE_ALLOC and the
896 * result should be freed using SUP_IOCTL_PAGE_FREE.
897 *
898 * @remarks Allocations without a kernel mapping may fail with
899 * VERR_NOT_SUPPORTED on some platforms just like with
900 * SUP_IOCTL_PAGE_ALLOC.
901 *
902 * @{
903 */
904#define SUP_IOCTL_PAGE_ALLOC_EX SUP_CTL_CODE_BIG(23)
905#define SUP_IOCTL_PAGE_ALLOC_EX_SIZE(cPages) RT_UOFFSETOF(SUPPAGEALLOCEX, u.Out.aPages[cPages])
906#define SUP_IOCTL_PAGE_ALLOC_EX_SIZE_IN (sizeof(SUPREQHDR) + RT_SIZEOFMEMB(SUPPAGEALLOCEX, u.In))
907#define SUP_IOCTL_PAGE_ALLOC_EX_SIZE_OUT(cPages) SUP_IOCTL_PAGE_ALLOC_EX_SIZE(cPages)
908typedef struct SUPPAGEALLOCEX
909{
910 /** The header. */
911 SUPREQHDR Hdr;
912 union
913 {
914 struct
915 {
916 /** Number of pages to allocate */
917 uint32_t cPages;
918 /** Whether it should have kernel mapping. */
919 bool fKernelMapping;
920 /** Whether it should have a user mapping. */
921 bool fUserMapping;
922 /** Reserved. Must be false. */
923 bool fReserved0;
924 /** Reserved. Must be false. */
925 bool fReserved1;
926 } In;
927 struct
928 {
929 /** Returned ring-3 address. */
930 RTR3PTR pvR3;
931 /** Returned ring-0 address. */
932 RTR0PTR pvR0;
933 /** The physical addresses of the allocated pages. */
934 RTHCPHYS aPages[1];
935 } Out;
936 } u;
937} SUPPAGEALLOCEX, *PSUPPAGEALLOCEX;
938/** @} */
939
940
941/** @name SUP_IOCTL_PAGE_MAP_KERNEL
942 * Maps a portion of memory allocated by SUP_IOCTL_PAGE_ALLOC_EX /
943 * SUPR0PageAllocEx into kernel space for use by a device or similar.
944 *
945 * The mapping will be freed together with the ring-3 mapping when
946 * SUP_IOCTL_PAGE_FREE or SUPR0PageFree is called.
947 *
948 * @remarks Not necessarily supported on all platforms.
949 *
950 * @{
951 */
952#define SUP_IOCTL_PAGE_MAP_KERNEL SUP_CTL_CODE_SIZE(24, SUP_IOCTL_PAGE_MAP_KERNEL_SIZE)
953#define SUP_IOCTL_PAGE_MAP_KERNEL_SIZE sizeof(SUPPAGEMAPKERNEL)
954#define SUP_IOCTL_PAGE_MAP_KERNEL_SIZE_IN sizeof(SUPPAGEMAPKERNEL)
955#define SUP_IOCTL_PAGE_MAP_KERNEL_SIZE_OUT sizeof(SUPPAGEMAPKERNEL)
956typedef struct SUPPAGEMAPKERNEL
957{
958 /** The header. */
959 SUPREQHDR Hdr;
960 union
961 {
962 struct
963 {
964 /** The pointer of to the previously allocated memory. */
965 RTR3PTR pvR3;
966 /** The offset to start mapping from. */
967 uint32_t offSub;
968 /** Size of the section to map. */
969 uint32_t cbSub;
970 /** Flags reserved for future fun. */
971 uint32_t fFlags;
972 } In;
973 struct
974 {
975 /** The ring-0 address corresponding to pvR3 + offSub. */
976 RTR0PTR pvR0;
977 } Out;
978 } u;
979} SUPPAGEMAPKERNEL, *PSUPPAGEMAPKERNEL;
980/** @} */
981
982
983/** @name SUP_IOCTL_LOGGER_SETTINGS
984 * Changes the ring-0 release or debug logger settings.
985 * @{
986 */
987#define SUP_IOCTL_LOGGER_SETTINGS(cbStrTab) SUP_CTL_CODE_SIZE(25, SUP_IOCTL_LOGGER_SETTINGS_SIZE(cbStrTab))
988#define SUP_IOCTL_LOGGER_SETTINGS_SIZE(cbStrTab) RT_UOFFSETOF(SUPLOGGERSETTINGS, u.In.szStrings[cbStrTab])
989#define SUP_IOCTL_LOGGER_SETTINGS_SIZE_IN(cbStrTab) RT_UOFFSETOF(SUPLOGGERSETTINGS, u.In.szStrings[cbStrTab])
990#define SUP_IOCTL_LOGGER_SETTINGS_SIZE_OUT sizeof(SUPREQHDR)
991typedef struct SUPLOGGERSETTINGS
992{
993 /** The header. */
994 SUPREQHDR Hdr;
995 union
996 {
997 struct
998 {
999 /** Which logger. */
1000 uint32_t fWhich;
1001 /** What to do with it. */
1002 uint32_t fWhat;
1003 /** Offset of the flags setting string. */
1004 uint32_t offFlags;
1005 /** Offset of the groups setting string. */
1006 uint32_t offGroups;
1007 /** Offset of the destination setting string. */
1008 uint32_t offDestination;
1009 /** The string table. */
1010 char szStrings[1];
1011 } In;
1012 } u;
1013} SUPLOGGERSETTINGS, *PSUPLOGGERSETTINGS;
1014
1015/** Debug logger. */
1016#define SUPLOGGERSETTINGS_WHICH_DEBUG 0
1017/** Release logger. */
1018#define SUPLOGGERSETTINGS_WHICH_RELEASE 1
1019
1020/** Change the settings. */
1021#define SUPLOGGERSETTINGS_WHAT_SETTINGS 0
1022/** Create the logger instance. */
1023#define SUPLOGGERSETTINGS_WHAT_CREATE 1
1024/** Destroy the logger instance. */
1025#define SUPLOGGERSETTINGS_WHAT_DESTROY 2
1026
1027/** @} */
1028
1029
1030#pragma pack() /* paranoia */
1031
1032#endif
1033
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