VirtualBox

source: vbox/trunk/src/VBox/HostDrivers/Support/SUPDRVIOC.h@ 1

最後變更 在這個檔案從1是 1,由 vboxsync 提交於 55 年 前

import

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Author Date Id Revision
檔案大小: 15.8 KB
 
1/** @file
2 *
3 * VBox host drivers - Ring-0 support drivers - Shared code:
4 * IOCtl definitions
5 */
6
7/*
8 * Copyright (C) 2006 InnoTek Systemberatung GmbH
9 *
10 * This file is part of VirtualBox Open Source Edition (OSE), as
11 * available from http://www.alldomusa.eu.org. This file is free software;
12 * you can redistribute it and/or modify it under the terms of the GNU
13 * General Public License as published by the Free Software Foundation,
14 * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
15 * distribution. VirtualBox OSE is distributed in the hope that it will
16 * be useful, but WITHOUT ANY WARRANTY of any kind.
17 *
18 * If you received this file as part of a commercial VirtualBox
19 * distribution, then only the terms of your commercial VirtualBox
20 * license agreement apply instead of the previous paragraph.
21 */
22
23#ifndef __SUPDRVIOC_h__
24#define __SUPDRVIOC_h__
25
26/*
27 * Basic types.
28 */
29#include <iprt/stdint.h>
30
31/*
32 * IOCtl numbers.
33 * We're using the Win32 type of numbers here, thus the macros below.
34 * The SUP_IOCTL_FLAG macro is used to separate requests from 32-bit
35 * and 64-bit processes.
36 */
37#ifdef __AMD64__
38# define SUP_IOCTL_FLAG 128
39#elif defined(__X86__)
40# define SUP_IOCTL_FLAG 0
41#else
42# error "dunno which arch this is!"
43#endif
44
45#ifdef __WIN__
46# define SUP_CTL_CODE(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
49/** @todo get rid of this duplication of window header #defines! */
50# ifndef CTL_CODE
51# define CTL_CODE(DeviceType, Function, Method, Access) \
52 ( ((DeviceType) << 16) | ((Access) << 14) | ((Function) << 2) | (Method) )
53# endif
54# ifndef METHOD_BUFFERED
55# define METHOD_BUFFERED 0
56# endif
57# ifndef METHOD_NEITHER
58# define METHOD_NEITHER 3
59# endif
60# ifndef FILE_WRITE_ACCESS
61# define FILE_WRITE_ACCESS 0x0002
62# endif
63# ifndef FILE_DEVICE_UNKNOWN
64# define FILE_DEVICE_UNKNOWN 0x00000022
65# endif
66
67#elif defined(__OS2__)
68# define SUP_CTL_CATEGORY ((unsigned short)'V')
69# define SUP_CTL_CODE(Function) ((unsigned short)(Function))
70
71#elif defined(__LINUX__) || defined(__L4__)
72# ifdef __X86__ /** @todo With the next major version change, drop this branch. */
73# define SUP_CTL_CODE(Function) \
74 ( (3U << 30) | ((0x22) << 8) | ((Function) | SUP_IOCTL_FLAG) | (sizeof(SUPDRVIOCTLDATA) << 16) )
75# define SUP_CTL_CODE_FAST(Function) \
76 ( (3U << 30) | ((0x22) << 8) | ((Function) | SUP_IOCTL_FLAG) | (0 << 16) )
77# else
78# include <sys/ioctl.h>
79# define SUP_CTL_CODE(Function) _IOWR('V', (Function) | SUP_IOCTL_FLAG, sizeof(SUPDRVIOCTLDATA))
80# define SUP_CTL_CODE_FAST(Function) _IO( 'V', (Function) | SUP_IOCTL_FLAG)
81# endif
82
83#else /* BSD */
84# include <sys/ioccom.h>
85# define SUP_CTL_CODE(Function) _IOWR('V', (Function) | SUP_IOCTL_FLAG, SUPDRVIOCTLDATA)
86# define SUP_CTL_CODE_FAST(Function) _IO( 'V', (Function) | SUP_IOCTL_FLAG)
87#endif
88
89
90/** Negotiate cookie. */
91#define SUP_IOCTL_COOKIE SUP_CTL_CODE( 1)
92/** Query SUPR0 functions. */
93#define SUP_IOCTL_QUERY_FUNCS SUP_CTL_CODE( 2)
94/** Install IDT patch for calling processor. */
95#define SUP_IOCTL_IDT_INSTALL SUP_CTL_CODE( 3)
96/** Remove IDT patch for calling processor. */
97#define SUP_IOCTL_IDT_REMOVE SUP_CTL_CODE( 4)
98/** Pin down physical pages. */
99#define SUP_IOCTL_PINPAGES SUP_CTL_CODE( 5)
100/** Unpin physical pages. */
101#define SUP_IOCTL_UNPINPAGES SUP_CTL_CODE( 6)
102/** Allocate contious memory. */
103#define SUP_IOCTL_CONT_ALLOC SUP_CTL_CODE( 7)
104/** Free contious memory. */
105#define SUP_IOCTL_CONT_FREE SUP_CTL_CODE( 8)
106/** Open an image. */
107#define SUP_IOCTL_LDR_OPEN SUP_CTL_CODE( 9)
108/** Upload the image bits. */
109#define SUP_IOCTL_LDR_LOAD SUP_CTL_CODE(10)
110/** Free an image. */
111#define SUP_IOCTL_LDR_FREE SUP_CTL_CODE(11)
112/** Get address of a symbol within an image. */
113#define SUP_IOCTL_LDR_GET_SYMBOL SUP_CTL_CODE(12)
114/** Call the R0 VMM Entry point. */
115#define SUP_IOCTL_CALL_VMMR0 SUP_CTL_CODE(14)
116/** Get the host paging mode. */
117#define SUP_IOCTL_GET_PAGING_MODE SUP_CTL_CODE(15)
118/** Allocate memory below 4GB (physically). */
119#define SUP_IOCTL_LOW_ALLOC SUP_CTL_CODE(16)
120/** Free low memory. */
121#define SUP_IOCTL_LOW_FREE SUP_CTL_CODE(17)
122/** Map the GIP into user space. */
123#define SUP_IOCTL_GIP_MAP SUP_CTL_CODE(18)
124/** Unmap the GIP. */
125#define SUP_IOCTL_GIP_UNMAP SUP_CTL_CODE(19)
126/** Set the VM handle for doing fast call ioctl calls. */
127#define SUP_IOCTL_SET_VM_FOR_FAST SUP_CTL_CODE(20)
128
129/** Fast path IOCtl: VMMR0_DO_RUN_GC */
130#define SUP_IOCTL_FAST_DO_RAW_RUN SUP_CTL_CODE_FAST(64)
131/** Fast path IOCtl: VMMR0_HWACC_RUN_GUEST */
132#define SUP_IOCTL_FAST_DO_HWACC_RUN SUP_CTL_CODE_FAST(65)
133
134
135/*******************************************************************************
136* Structures and Typedefs *
137*******************************************************************************/
138#ifdef __AMD64__
139# pragma pack(8) /* paranoia. */
140#else
141# pragma pack(4) /* paranoia. */
142#endif
143
144#ifndef __WIN__
145/**
146 * Structure used by OSes with less advanced ioctl interfaces, i.e. most
147 * Unix like OSes :-)
148 */
149typedef struct SUPDRVIOCTLDATA
150{
151 void *pvIn;
152 unsigned long cbIn;
153 void *pvOut;
154 unsigned long cbOut;
155
156} SUPDRVIOCTLDATA, *PSUPDRVIOCTLDATA;
157#endif
158
159/** SUP_IOCTL_COOKIE Input. */
160typedef struct SUPCOOKIE_IN
161{
162 /** Magic word. */
163 char szMagic[16];
164 /** The requested version number. */
165 uint32_t u32Version;
166} SUPCOOKIE_IN, *PSUPCOOKIE_IN;
167
168/** SUPCOOKIE_IN magic word. */
169#define SUPCOOKIE_MAGIC "The Magic Word!"
170/** Current interface version. */
171#define SUPDRVIOC_VERSION 0x00030001
172
173/** SUP_IOCTL_COOKIE Output. */
174typedef struct SUPCOOKIE_OUT
175{
176 /** Cookie. */
177 uint32_t u32Cookie;
178 /** Session cookie. */
179 uint32_t u32SessionCookie;
180 /** Interface version. High word(=uint16) is major, low word is minor. */
181 uint32_t u32Version;
182 /** Number of functions available for the SUP_IOCTL_QUERY_FUNCS request. */
183 uint32_t cFunctions;
184 /** Session handle. */
185 PSUPDRVSESSION pSession;
186} SUPCOOKIE_OUT, *PSUPCOOKIE_OUT;
187
188/** SUP_IOCTL_QUERY_FUNCS Input. */
189typedef struct SUPQUERYFUNCS_IN
190{
191 /** Cookie. */
192 uint32_t u32Cookie;
193 /** Session cookie. */
194 uint32_t u32SessionCookie;
195} SUPQUERYFUNCS_IN, *PSUPQUERYFUNCS_IN;
196
197/** Function. */
198typedef struct SUPFUNC
199{
200 /** Name - mangled. */
201 char szName[32];
202 /** Address. */
203 void *pfn;
204} SUPFUNC, *PSUPFUNC;
205
206/** SUP_IOCTL_QUERY_FUNCS Output. */
207typedef struct SUPQUERYFUNCS_OUT
208{
209 /** Number of functions returned. */
210 uint32_t cFunctions;
211 /** Array of functions. */
212 SUPFUNC aFunctions[1];
213} SUPQUERYFUNCS_OUT, *PSUPQUERYFUNCS_OUT;
214
215
216/** SUP_IOCTL_IDT_INSTALL Input. */
217typedef struct SUPIDTINSTALL_IN
218{
219 /** Cookie. */
220 uint32_t u32Cookie;
221 /** Session cookie. */
222 uint32_t u32SessionCookie;
223} SUPIDTINSTALL_IN, *PSUPIDTINSTALL_IN;
224
225/** SUP_IOCTL_IDT_INSTALL Output. */
226typedef struct SUPIDTINSTALL_OUT
227{
228 /** Cookie. */
229 uint8_t u8Idt;
230} SUPIDTINSTALL_OUT, *PSUPIDTINSTALL_OUT;
231
232
233
234/** SUP_IOCTL_IDT_REMOVE Input. */
235typedef struct SUPIDTREMOVE_IN
236{
237 /** Cookie. */
238 uint32_t u32Cookie;
239 /** Session cookie. */
240 uint32_t u32SessionCookie;
241} SUPIDTREMOVE_IN, *PSUPIDTREMOVE_IN;
242
243
244
245/** SUP_IOCTL_PINPAGES Input. */
246typedef struct SUPPINPAGES_IN
247{
248 /** Cookie. */
249 uint32_t u32Cookie;
250 /** Session cookie. */
251 uint32_t u32SessionCookie;
252 /** Start of page range. Must be PAGE aligned. */
253 void *pv;
254 /** Size of the range. Must be PAGE aligned. */
255 uint32_t cb;
256} SUPPINPAGES_IN, *PSUPPINPAGES_IN;
257
258/** SUP_IOCTL_PINPAGES Output. */
259typedef struct SUPPINPAGES_OUT
260{
261 /** Array of pages. */
262 SUPPAGE aPages[1];
263} SUPPINPAGES_OUT, *PSUPPINPAGES_OUT;
264
265
266
267/** SUP_IOCTL_UNPINPAGES Input. */
268typedef struct SUPUNPINPAGES_IN
269{
270 /** Cookie. */
271 uint32_t u32Cookie;
272 /** Session cookie. */
273 uint32_t u32SessionCookie;
274 /** Start of page range of a range previuosly pinned. */
275 void *pv;
276} SUPUNPINPAGES_IN, *PSUPUNPINPAGES_IN;
277
278
279/** SUP_IOCTL_CONT_ALLOC Input. */
280typedef struct SUPCONTALLOC_IN
281{
282 /** Cookie. */
283 uint32_t u32Cookie;
284 /** Session cookie. */
285 uint32_t u32SessionCookie;
286 /** Number of bytes to allocate. */
287 uint32_t cb;
288} SUPCONTALLOC_IN, *PSUPCONTALLOC_IN;
289
290
291/** SUP_IOCTL_CONT_ALLOC Output. */
292typedef struct SUPCONTALLOC_OUT
293{
294 /** The address of the ring-0 mapping of the allocated memory. */
295 void *pvR0;
296 /** The address of the ring-3 mapping of the allocated memory. */
297 void *pvR3;
298 /** The physical address of the allocation. */
299 RTHCPHYS HCPhys;
300} SUPCONTALLOC_OUT, *PSUPCONTALLOC_OUT;
301
302
303/** SUP_IOCTL_CONT_FREE Input. */
304typedef struct SUPCONTFREE_IN
305{
306 /** Cookie. */
307 uint32_t u32Cookie;
308 /** Session cookie. */
309 uint32_t u32SessionCookie;
310 /** The address (virtual, not physical address) of the memory to free. */
311 void *pv;
312} SUPCONTFREE_IN, *PSUPCONTFREE_IN;
313
314
315/** SUP_IOCTL_LDR_OPEN Input. */
316typedef struct SUPLDROPEN_IN
317{
318 /** Cookie. */
319 uint32_t u32Cookie;
320 /** Session cookie. */
321 uint32_t u32SessionCookie;
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} SUPLDROPEN_IN, *PSUPLDROPEN_IN;
329
330/** SUP_IOCTL_LDR_OPEN Output. */
331typedef struct SUPLDROPEN_OUT
332{
333 /** The base address of the image. */
334 void *pvImageBase;
335 /** Indicate whether or not the image requires loading. */
336 bool fNeedsLoading;
337} SUPLDROPEN_OUT, *PSUPLDROPEN_OUT;
338
339
340/**
341 * Module initialization callback function.
342 * This is called once after the module has been loaded.
343 *
344 * @returns 0 on success.
345 * @returns Appropriate error code on failure.
346 */
347typedef DECLCALLBACK(int) FNR0MODULEINIT(void);
348/** Pointer to a FNR0MODULEINIT(). */
349typedef FNR0MODULEINIT *PFNR0MODULEINIT;
350
351/**
352 * Module termination callback function.
353 * This is called once right before the module is being unloaded.
354 */
355typedef DECLCALLBACK(void) FNR0MODULETERM(void);
356/** Pointer to a FNR0MODULETERM(). */
357typedef FNR0MODULETERM *PFNR0MODULETERM;
358
359/**
360 * Symbol table entry.
361 */
362typedef struct SUPLDRSYM
363{
364 /** Offset into of the string table. */
365 uint32_t offName;
366 /** Offset of the symbol relative to the image load address. */
367 uint32_t offSymbol;
368} SUPLDRSYM, *PSUPLDRSYM;
369
370/** SUP_IOCTL_LDR_LOAD Input. */
371typedef struct SUPLDRLOAD_IN
372{
373 /** Cookie. */
374 uint32_t u32Cookie;
375 /** Session cookie. */
376 uint32_t u32SessionCookie;
377 /** The address of module initialization function. Similar to _DLL_InitTerm(hmod, 0). */
378 PFNR0MODULEINIT pfnModuleInit;
379 /** The address of module termination function. Similar to _DLL_InitTerm(hmod, 1). */
380 PFNR0MODULETERM pfnModuleTerm;
381 /** Special entry points. */
382 union
383 {
384 struct
385 {
386 /** The module handle (i.e. address). */
387 void *pvVMMR0;
388 /** Address of VMMR0Entry function. */
389 void *pvVMMR0Entry;
390 } VMMR0;
391 } EP;
392 /** Address. */
393 void *pvImageBase;
394 /** Entry point type. */
395 enum { EP_NOTHING, EP_VMMR0 }
396 eEPType;
397 /** The offset of the symbol table. */
398 uint32_t offSymbols;
399 /** The number of entries in the symbol table. */
400 uint32_t cSymbols;
401 /** The offset of the string table. */
402 uint32_t offStrTab;
403 /** Size of the string table. */
404 uint32_t cbStrTab;
405 /** Size of image (including string and symbol tables). */
406 uint32_t cbImage;
407 /** The image data. */
408 char achImage[1];
409} SUPLDRLOAD_IN, *PSUPLDRLOAD_IN;
410
411
412/** SUP_IOCTL_LDR_FREE Input. */
413typedef struct SUPLDRFREE_IN
414{
415 /** Cookie. */
416 uint32_t u32Cookie;
417 /** Session cookie. */
418 uint32_t u32SessionCookie;
419 /** Address. */
420 void *pvImageBase;
421} SUPLDRFREE_IN, *PSUPLDRFREE_IN;
422
423
424/** SUP_IOCTL_LDR_GET_SYMBOL Input. */
425typedef struct SUPLDRGETSYMBOL_IN
426{
427 /** Cookie. */
428 uint32_t u32Cookie;
429 /** Session cookie. */
430 uint32_t u32SessionCookie;
431 /** Address. */
432 void *pvImageBase;
433 /** The symbol name (variable length). */
434 char szSymbol[1];
435} SUPLDRGETSYMBOL_IN, *PSUPLDRGETSYMBOL_IN;
436
437/** SUP_IOCTL_LDR_GET_SYMBOL Output. */
438typedef struct SUPLDRGETSYMBOL_OUT
439{
440 /** The symbol address. */
441 void *pvSymbol;
442} SUPLDRGETSYMBOL_OUT, *PSUPLDRGETSYMBOL_OUT;
443
444
445/** SUP_IOCTL_CALL_VMMR0 Input. */
446typedef struct SUPCALLVMMR0_IN
447{
448 /** Cookie. */
449 uint32_t u32Cookie;
450 /** Session cookie. */
451 uint32_t u32SessionCookie;
452 /** The VM handle. */
453 PVM pVM;
454 /** Which operation to execute. */
455 uint32_t uOperation;
456 /** The size of the buffer pointed to by pvArg. */
457 uint32_t cbArg;
458 /** Argument to that operation. */
459 void *pvArg;
460} SUPCALLVMMR0_IN, *PSUPCALLVMMR0_IN;
461
462/** SUP_IOCTL_CALL_VMMR0 Output. */
463typedef struct SUPCALLVMMR0_OUT
464{
465 /** The VBox status code for the operation. */
466 int32_t rc;
467} SUPCALLVMMR0_OUT, *PSUPCALLVMMR0_OUT;
468
469
470/** SUP_IOCTL_GET_PAGING_MODE Input. */
471typedef struct SUPGETPAGINGMODE_IN
472{
473 /** Cookie. */
474 uint32_t u32Cookie;
475 /** Session cookie. */
476 uint32_t u32SessionCookie;
477} SUPGETPAGINGMODE_IN, *PSUPGETPAGINGMODE_IN;
478
479/** SUP_IOCTL_GET_PAGING_MODE Output. */
480typedef struct SUPGETPAGINGMODE_OUT
481{
482 /** The paging mode. */
483 SUPPAGINGMODE enmMode;
484} SUPGETPAGINGMODE_OUT, *PSUPGETPAGINGMODE_OUT;
485
486
487/** SUP_IOCTL_LOW_ALLOC Input. */
488typedef struct SUPLOWALLOC_IN
489{
490 /** Cookie. */
491 uint32_t u32Cookie;
492 /** Session cookie. */
493 uint32_t u32SessionCookie;
494 /** Number of pages to allocate. */
495 uint32_t cPages;
496} SUPLOWALLOC_IN, *PSUPLOWALLOC_IN;
497
498/** SUP_IOCTL_LOW_ALLOC Output. */
499typedef struct SUPLOWALLOC_OUT
500{
501 /** The address (virtual & linear) of the allocated memory. */
502 void *pvVirt;
503 /** Array of pages. */
504 SUPPAGE aPages[1];
505} SUPLOWALLOC_OUT, *PSUPLOWALLOC_OUT;
506
507
508/** SUP_IOCTL_LOW_FREE Input. */
509typedef struct SUPLOWFREE_IN
510{
511 /** Cookie. */
512 uint32_t u32Cookie;
513 /** Session cookie. */
514 uint32_t u32SessionCookie;
515 /** The address (virtual, not physical address) of the memory to free. */
516 void *pv;
517} SUPLOWFREE_IN, *PSUPLOWFREE_IN;
518
519
520/** SUP_IOCTL_GIP_MAP Input. */
521typedef struct SUPGIPMAP_IN
522{
523 /** Cookie. */
524 uint32_t u32Cookie;
525 /** Session cookie. */
526 uint32_t u32SessionCookie;
527} SUPGIPMAP_IN, *PSUPGIPMAP_IN;
528
529/** SUP_IOCTL_GIP_MAP Output. */
530typedef struct SUPGIPMAP_OUT
531{
532 /** Pointer to the read-only usermode GIP mapping for this session. */
533 PCSUPGLOBALINFOPAGE pGipR3;
534 /** Pointer to the supervisor mode GIP mapping. */
535 PCSUPGLOBALINFOPAGE pGipR0;
536 /** The physical address of the GIP. */
537 RTHCPHYS HCPhysGip;
538} SUPGIPMAP_OUT, *PSUPGIPMAP_OUT;
539
540
541/** SUP_IOCTL_GIP_UNMAP Input. */
542typedef struct SUPGIPUNMAP_IN
543{
544 /** Cookie. */
545 uint32_t u32Cookie;
546 /** Session cookie. */
547 uint32_t u32SessionCookie;
548} SUPGIPUNMAP_IN, *PSUPGIPUNMAP_IN;
549
550
551/** SUP_IOCTL_SET_VM_FOR_FAST Input. */
552typedef struct SUPSETVMFORFAST_IN
553{
554 /** Cookie. */
555 uint32_t u32Cookie;
556 /** Session cookie. */
557 uint32_t u32SessionCookie;
558 /** The ring-0 VM handle (pointer). */
559 PVMR0 pVMR0;
560} SUPSETVMFORFAST_IN, *PSUPSETVMFORFAST_IN;
561
562#pragma pack() /* paranoia */
563
564#endif
565
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

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