VirtualBox

source: vbox/trunk/src/VBox/HostDrivers/Support/SUPDRV.h@ 5166

Last change on this file since 5166 was 4971, checked in by vboxsync, 17 years ago

GVM.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 23.6 KB
Line 
1/* $Revision: 4971 $ */
2/** @file
3 * VirtualBox Support Driver - Internal header.
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 __SUPDRV_h__
19#define __SUPDRV_h__
20
21
22/*******************************************************************************
23* Header Files *
24*******************************************************************************/
25#include <VBox/cdefs.h>
26#include <VBox/types.h>
27#include <iprt/assert.h>
28#include <iprt/asm.h>
29#include <VBox/sup.h>
30#ifdef USE_NEW_OS_INTERFACE
31# define USE_NEW_OS_INTERFACE_FOR_MM
32# define USE_NEW_OS_INTERFACE_FOR_GIP
33# undef USE_NEW_OS_INTERFACE_FOR_LOW
34#endif
35#if defined(USE_NEW_OS_INTERFACE) || defined(USE_NEW_OS_INTERFACE_FOR_LOW) || defined(USE_NEW_OS_INTERFACE_FOR_MM) || defined(USE_NEW_OS_INTERFACE_FOR_GIP)
36# include <iprt/memobj.h>
37# include <iprt/time.h>
38# include <iprt/timer.h>
39# include <iprt/string.h>
40# include <iprt/err.h>
41#endif
42
43
44#if defined(RT_OS_WINDOWS)
45 __BEGIN_DECLS
46# if (_MSC_VER >= 1400) && !defined(VBOX_WITH_PATCHED_DDK)
47# define _InterlockedExchange _InterlockedExchange_StupidDDKVsCompilerCrap
48# define _InterlockedExchangeAdd _InterlockedExchangeAdd_StupidDDKVsCompilerCrap
49# define _InterlockedCompareExchange _InterlockedCompareExchange_StupidDDKVsCompilerCrap
50# define _InterlockedAddLargeStatistic _InterlockedAddLargeStatistic_StupidDDKVsCompilerCrap
51# include <ntddk.h>
52# undef _InterlockedExchange
53# undef _InterlockedExchangeAdd
54# undef _InterlockedCompareExchange
55# undef _InterlockedAddLargeStatistic
56# else
57# include <ntddk.h>
58# endif
59# include <memory.h>
60# define memcmp(a,b,c) mymemcmp(a,b,c)
61 int VBOXCALL mymemcmp(const void *, const void *, size_t);
62 __END_DECLS
63
64#elif defined(RT_OS_LINUX)
65# include <linux/autoconf.h>
66# include <linux/version.h>
67# if defined(CONFIG_MODVERSIONS) && !defined(MODVERSIONS)
68# define MODVERSIONS
69# if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 71)
70# include <linux/modversions.h>
71# endif
72# endif
73# if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 0)
74# undef ALIGN
75# endif
76# ifndef KBUILD_STR
77# if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 16)
78# define KBUILD_STR(s) s
79# else
80# define KBUILD_STR(s) #s
81# endif
82# endif
83# include <linux/string.h>
84# include <linux/spinlock.h>
85# include <linux/slab.h>
86# include <asm/semaphore.h>
87# include <linux/timer.h>
88
89#elif defined(RT_OS_DARWIN)
90# include <libkern/libkern.h>
91# include <iprt/string.h>
92
93#elif defined(RT_OS_OS2)
94
95#elif defined(RT_OS_FREEBSD)
96# include <sys/libkern.h>
97# include <iprt/string.h>
98
99#elif defined(RT_OS_SOLARIS)
100# include <sys/cmn_err.h>
101# include <iprt/string.h>
102
103#else
104# error "unsupported OS."
105#endif
106
107#include "SUPDRVIOC.h"
108
109
110
111/*******************************************************************************
112* Defined Constants And Macros *
113*******************************************************************************/
114/*
115 * Hardcoded cookies.
116 */
117#define BIRD 0x64726962 /* 'bird' */
118#define BIRD_INV 0x62697264 /* 'drib' */
119
120
121/*
122 * Win32
123 */
124#if defined(RT_OS_WINDOWS)
125
126/* debug printf */
127# define OSDBGPRINT(a) DbgPrint a
128
129/** Maximum number of bytes we try to lock down in one go.
130 * This is supposed to have a limit right below 256MB, but this appears
131 * to actually be much lower. The values here have been determined experimentally.
132 */
133#ifdef RT_ARCH_X86
134# define MAX_LOCK_MEM_SIZE (32*1024*1024) /* 32mb */
135#endif
136#ifdef RT_ARCH_AMD64
137# define MAX_LOCK_MEM_SIZE (24*1024*1024) /* 24mb */
138#endif
139
140
141/*
142 * Linux
143 */
144#elif defined(RT_OS_LINUX)
145
146/* check kernel version */
147#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 4, 0)
148# error Unsupported kernel version!
149#endif
150
151__BEGIN_DECLS
152int linux_dprintf(const char *format, ...);
153__END_DECLS
154
155/* debug printf */
156# define OSDBGPRINT(a) printk a
157
158
159/*
160 * Darwin
161 */
162#elif defined(RT_OS_DARWIN)
163
164/* debug printf */
165# define OSDBGPRINT(a) printf a
166
167
168/*
169 * OS/2
170 */
171#elif defined(RT_OS_OS2)
172
173/* No log API in OS/2 only COM port. */
174# define OSDBGPRINT(a) SUPR0Printf a
175
176
177/*
178 * FreeBSD
179 */
180#elif defined(RT_OS_FREEBSD)
181
182/* No log API in OS/2 only COM port. */
183# define OSDBGPRINT(a) printf a
184
185
186/*
187 * Solaris
188 */
189#elif defined(RT_OS_SOLARIS)
190# define OSDBGPRINT(a) SUPR0Printf a
191
192
193#else
194/** @todo other os'es */
195# error "OS interface defines is not done for this OS!"
196#endif
197
198
199/* dprintf */
200#if (defined(DEBUG) && !defined(NO_LOGGING)) || defined(RT_OS_FREEBSD)
201# ifdef LOG_TO_COM
202# include <VBox/log.h>
203# define dprintf(a) RTLogComPrintf a
204# else
205# define dprintf(a) OSDBGPRINT(a)
206# endif
207#else
208# define dprintf(a) do {} while (0)
209#endif
210
211/* dprintf2 - extended logging. */
212#if defined(RT_OS_DARWIN) || defined(RT_OS_OS2) || defined(RT_OS_FREEBSD)
213# define dprintf2 dprintf
214#else
215# define dprintf2(a) do { } while (0)
216#endif
217
218
219/*
220 * Error codes.
221 */
222/** Invalid parameter. */
223#define SUPDRV_ERR_GENERAL_FAILURE (-1)
224/** Invalid parameter. */
225#define SUPDRV_ERR_INVALID_PARAM (-2)
226/** Invalid magic or cookie. */
227#define SUPDRV_ERR_INVALID_MAGIC (-3)
228/** Invalid loader handle. */
229#define SUPDRV_ERR_INVALID_HANDLE (-4)
230/** Failed to lock the address range. */
231#define SUPDRV_ERR_LOCK_FAILED (-5)
232/** Invalid memory pointer. */
233#define SUPDRV_ERR_INVALID_POINTER (-6)
234/** Failed to patch the IDT. */
235#define SUPDRV_ERR_IDT_FAILED (-7)
236/** Memory allocation failed. */
237#define SUPDRV_ERR_NO_MEMORY (-8)
238/** Already loaded. */
239#define SUPDRV_ERR_ALREADY_LOADED (-9)
240/** Permission denied. */
241#define SUPDRV_ERR_PERMISSION_DENIED (-10)
242/** Version mismatch. */
243#define SUPDRV_ERR_VERSION_MISMATCH (-11)
244
245
246
247/*******************************************************************************
248* Structures and Typedefs *
249*******************************************************************************/
250/** Pointer to the device extension. */
251typedef struct SUPDRVDEVEXT *PSUPDRVDEVEXT;
252
253#ifdef VBOX_WITH_IDT_PATCHING
254
255/**
256 * An IDT Entry.
257 */
258typedef struct SUPDRVIDTE
259{
260 /** Low offset word. */
261 uint32_t u16OffsetLow : 16;
262 /** Segment Selector. */
263 uint32_t u16SegSel : 16;
264#ifdef RT_ARCH_AMD64
265 /** Interrupt Stack Table index. */
266 uint32_t u3IST : 3;
267 /** Reserved, ignored. */
268 uint32_t u5Reserved : 5;
269#else
270 /** Reserved. */
271 uint32_t u5Reserved : 5;
272 /** IDT Type part one (not used for task gate). */
273 uint32_t u3Type1 : 3;
274#endif
275 /** IDT Type part two. */
276 uint32_t u5Type2 : 5;
277 /** Descriptor Privilege level. */
278 uint32_t u2DPL : 2;
279 /** Present flag. */
280 uint32_t u1Present : 1;
281 /** High offset word. */
282 uint32_t u16OffsetHigh : 16;
283#ifdef RT_ARCH_AMD64
284 /** The upper top part of the address. */
285 uint32_t u32OffsetTop;
286 /** Reserved dword for qword (aligning the struct), ignored. */
287 uint32_t u32Reserved;
288#endif
289} SUPDRVIDTE, *PSUPDRVIDTE;
290
291/** The u5Type2 value for an interrupt gate. */
292#define SUPDRV_IDTE_TYPE2_INTERRUPT_GATE 0x0e
293
294
295/**
296 * Patch code.
297 */
298typedef struct SUPDRVPATCH
299{
300#define SUPDRV_PATCH_CODE_SIZE 0x50
301 /** Patch code. */
302 uint8_t auCode[SUPDRV_PATCH_CODE_SIZE];
303 /** Changed IDT entry (for parnoid UnpatchIdt()). */
304 SUPDRVIDTE ChangedIdt;
305 /** Saved IDT entry. */
306 SUPDRVIDTE SavedIdt;
307 /** Pointer to the IDT.
308 * We ASSUME the IDT is not re(al)located after bootup and use this as key
309 * for the patches rather than processor number. This prevents some
310 * stupid nesting stuff from happening in case of processors sharing the
311 * IDT.
312 * We're fucked if the processors have different physical mapping for
313 * the(se) page(s), but we'll find that out soon enough in VBOX_STRICT mode.
314 */
315 void *pvIdt;
316 /** Pointer to the IDT entry. */
317 SUPDRVIDTE volatile *pIdtEntry;
318 /** Usage counter. */
319 uint32_t volatile cUsage;
320 /** The offset into auCode of the VMMR0Entry fixup. */
321 uint16_t offVMMR0EntryFixup;
322 /** The offset into auCode of the stub function. */
323 uint16_t offStub;
324 /** Pointer to the next patch. */
325 struct SUPDRVPATCH * volatile pNext;
326} SUPDRVPATCH, *PSUPDRVPATCH;
327
328/**
329 * Usage record for a patch.
330 */
331typedef struct SUPDRVPATCHUSAGE
332{
333 /** Next in the chain. */
334 struct SUPDRVPATCHUSAGE * volatile pNext;
335 /** The patch this usage applies to. */
336 PSUPDRVPATCH pPatch;
337 /** Usage count. */
338 uint32_t volatile cUsage;
339} SUPDRVPATCHUSAGE, *PSUPDRVPATCHUSAGE;
340
341#endif /* VBOX_WITH_IDT_PATCHING */
342
343
344/**
345 * Memory reference types.
346 */
347typedef enum
348{
349 /** Unused entry */
350 MEMREF_TYPE_UNUSED = 0,
351 /** Locked memory (r3 mapping only). */
352 MEMREF_TYPE_LOCKED,
353 /** Continous memory block (r3 and r0 mapping). */
354 MEMREF_TYPE_CONT,
355 /** Low memory block (r3 and r0 mapping). */
356 MEMREF_TYPE_LOW,
357 /** Memory block (r3 and r0 mapping). */
358 MEMREF_TYPE_MEM,
359 /** Locked memory (r3 mapping only) allocated by the support driver. */
360 MEMREF_TYPE_LOCKED_SUP,
361 /** Blow the type up to 32-bit and mark the end. */
362 MEMREG_TYPE_32BIT_HACK = 0x7fffffff
363} SUPDRVMEMREFTYPE, *PSUPDRVMEMREFTYPE;
364
365
366/**
367 * Structure used for tracking memory a session
368 * references in one way or another.
369 */
370typedef struct SUPDRVMEMREF
371{
372#ifdef USE_NEW_OS_INTERFACE_FOR_MM
373 /** The memory object handle. */
374 RTR0MEMOBJ MemObj;
375 /** The ring-3 mapping memory object handle. */
376 RTR0MEMOBJ MapObjR3;
377 /** Type of memory. */
378 SUPDRVMEMREFTYPE eType;
379
380#else /* !USE_NEW_OS_INTERFACE_FOR_MM */
381 /** Pointer to the R0 mapping of the memory.
382 * Set to NULL if N/A. */
383 void *pvR0;
384 /** Pointer to the R3 mapping of the memory.
385 * Set to NULL if N/A. */
386 RTR3PTR pvR3;
387 /** Size of the locked memory. */
388 unsigned cb;
389 /** Type of memory. */
390 SUPDRVMEMREFTYPE eType;
391
392 /** memory type specific information. */
393 union
394 {
395 struct
396 {
397#if defined(RT_OS_WINDOWS)
398 /** Pointer to memory descriptor list (MDL). */
399 PMDL *papMdl;
400 unsigned cMdls;
401#elif defined(RT_OS_LINUX)
402 struct page **papPages;
403 unsigned cPages;
404#else
405# error "Either no target was defined or we haven't ported the driver to the target yet."
406#endif
407 } locked;
408 struct
409 {
410#if defined(RT_OS_WINDOWS)
411 /** Pointer to memory descriptor list (MDL). */
412 PMDL pMdl;
413#elif defined(RT_OS_LINUX)
414 struct page *paPages;
415 unsigned cPages;
416#else
417# error "Either no target was defined or we haven't ported the driver to the target yet."
418#endif
419 } cont;
420 struct
421 {
422#if defined(RT_OS_WINDOWS)
423 /** Pointer to memory descriptor list (MDL). */
424 PMDL pMdl;
425#elif defined(RT_OS_LINUX)
426 /** Pointer to the array of page pointers. */
427 struct page **papPages;
428 /** Number of pages in papPages. */
429 unsigned cPages;
430#else
431# error "Either no target was defined or we haven't ported the driver to the target yet."
432#endif
433 } mem;
434#if defined(USE_NEW_OS_INTERFACE_FOR_LOW)
435 struct
436 {
437 /** The memory object handle. */
438 RTR0MEMOBJ MemObj;
439 /** The ring-3 mapping memory object handle. */
440 RTR0MEMOBJ MapObjR3;
441 } iprt;
442#endif
443 } u;
444#endif /* !USE_NEW_OS_INTERFACE_FOR_MM */
445} SUPDRVMEMREF, *PSUPDRVMEMREF;
446
447
448/**
449 * Bundle of locked memory ranges.
450 */
451typedef struct SUPDRVBUNDLE
452{
453 /** Pointer to the next bundle. */
454 struct SUPDRVBUNDLE * volatile pNext;
455 /** Referenced memory. */
456 SUPDRVMEMREF aMem[64];
457 /** Number of entries used. */
458 uint32_t volatile cUsed;
459} SUPDRVBUNDLE, *PSUPDRVBUNDLE;
460
461
462/**
463 * Loaded image.
464 */
465typedef struct SUPDRVLDRIMAGE
466{
467 /** Next in chain. */
468 struct SUPDRVLDRIMAGE * volatile pNext;
469 /** Pointer to the image. */
470 void *pvImage;
471 /** Pointer to the optional module initialization callback. */
472 PFNR0MODULEINIT pfnModuleInit;
473 /** Pointer to the optional module termination callback. */
474 PFNR0MODULETERM pfnModuleTerm;
475 /** Size of the image. */
476 uint32_t cbImage;
477 /** The offset of the symbol table. */
478 uint32_t offSymbols;
479 /** The number of entries in the symbol table. */
480 uint32_t cSymbols;
481 /** The offset of the string table. */
482 uint32_t offStrTab;
483 /** Size of the string table. */
484 uint32_t cbStrTab;
485 /** The ldr image state. (IOCtl code of last opration.) */
486 uint32_t uState;
487 /** Usage count. */
488 uint32_t volatile cUsage;
489 /** Image name. */
490 char szName[32];
491} SUPDRVLDRIMAGE, *PSUPDRVLDRIMAGE;
492
493
494/** Image usage record. */
495typedef struct SUPDRVLDRUSAGE
496{
497 /** Next in chain. */
498 struct SUPDRVLDRUSAGE * volatile pNext;
499 /** The image. */
500 PSUPDRVLDRIMAGE pImage;
501 /** Load count. */
502 uint32_t volatile cUsage;
503} SUPDRVLDRUSAGE, *PSUPDRVLDRUSAGE;
504
505
506/**
507 * Registered object.
508 * This takes care of reference counting and tracking data for access checks.
509 */
510typedef struct SUPDRVOBJ
511{
512 /** Magic value (SUPDRVOBJ_MAGIC). */
513 uint32_t u32Magic;
514 /** The object type. */
515 SUPDRVOBJTYPE enmType;
516 /** Pointer to the next in the global list. */
517 struct SUPDRVOBJ * volatile pNext;
518 /** Pointer to the object destructor.
519 * This may be set to NULL if the image containing the destructor get unloaded. */
520 PFNSUPDRVDESTRUCTOR pfnDestructor;
521 /** User argument 1. */
522 void *pvUser1;
523 /** User argument 2. */
524 void *pvUser2;
525 /** The total sum of all per-session usage. */
526 uint32_t volatile cUsage;
527 /** The creator user id. */
528 RTUID CreatorUid;
529 /** The creator group id. */
530 RTGID CreatorGid;
531 /** The creator process id. */
532 RTPROCESS CreatorProcess;
533} SUPDRVOBJ, *PSUPDRVOBJ;
534
535/** Magic number for SUPDRVOBJ::u32Magic. (Dame Agatha Mary Clarissa Christie). */
536#define SUPDRVOBJ_MAGIC 0x18900915
537
538/**
539 * The per-session object usage record.
540 */
541typedef struct SUPDRVUSAGE
542{
543 /** Pointer to the next in the list. */
544 struct SUPDRVUSAGE * volatile pNext;
545 /** Pointer to the object we're recording usage for. */
546 PSUPDRVOBJ pObj;
547 /** The usage count. */
548 uint32_t volatile cUsage;
549} SUPDRVUSAGE, *PSUPDRVUSAGE;
550
551
552/**
553 * Per session data.
554 * This is mainly for memory tracking.
555 */
556typedef struct SUPDRVSESSION
557{
558 /** Pointer to the device extension. */
559 PSUPDRVDEVEXT pDevExt;
560 /** Session Cookie. */
561 uint32_t u32Cookie;
562
563 /** Load usage records. (protected by SUPDRVDEVEXT::mtxLdr) */
564 PSUPDRVLDRUSAGE volatile pLdrUsage;
565#ifdef VBOX_WITH_IDT_PATCHING
566 /** Patch usage records. (protected by SUPDRVDEVEXT::SpinLock) */
567 PSUPDRVPATCHUSAGE volatile pPatchUsage;
568#endif
569 /** The VM associated with the session. */
570 PVM pVM;
571 /** List of generic usage records. (protected by SUPDRVDEVEXT::SpinLock) */
572 PSUPDRVUSAGE volatile pUsage;
573
574 /** Spinlock protecting the bundles and the GIP members. */
575 RTSPINLOCK Spinlock;
576#ifdef USE_NEW_OS_INTERFACE_FOR_GIP
577 /** The ring-3 mapping of the GIP (readonly). */
578 RTR0MEMOBJ GipMapObjR3;
579#else
580 /** The read-only usermode mapping address of the GID.
581 * This is NULL if the GIP hasn't been mapped. */
582 PSUPGLOBALINFOPAGE pGip;
583#endif
584 /** Set if the session is using the GIP. */
585 uint32_t fGipReferenced;
586 /** Bundle of locked memory objects. */
587 SUPDRVBUNDLE Bundle;
588
589 /** The user id of the session. (Set by the OS part.) */
590 RTUID Uid;
591 /** The group id of the session. (Set by the OS part.) */
592 RTGID Gid;
593 /** The process (id) of the session. (Set by the OS part.) */
594 RTPROCESS Process;
595 /** Which process this session is associated with. */
596 RTR0PROCESS R0Process;
597#if defined(RT_OS_OS2)
598 /** The system file number of this session. */
599 uint16_t sfn;
600 uint16_t Alignment; /**< Alignment */
601#endif
602#if defined(RT_OS_DARWIN) || defined(RT_OS_OS2) || defined(RT_OS_SOLARIS)
603 /** Pointer to the next session with the same hash. */
604 PSUPDRVSESSION pNextHash;
605#endif
606} SUPDRVSESSION;
607
608
609/**
610 * Device extension.
611 */
612typedef struct SUPDRVDEVEXT
613{
614 /** Spinlock to serialize the initialization,
615 * usage counting and destruction of the IDT entry override and objects. */
616 RTSPINLOCK Spinlock;
617
618#ifdef VBOX_WITH_IDT_PATCHING
619 /** List of patches. */
620 PSUPDRVPATCH volatile pIdtPatches;
621 /** List of patches Free. */
622 PSUPDRVPATCH volatile pIdtPatchesFree;
623#endif
624
625 /** List of registered objects. Protected by the spinlock. */
626 PSUPDRVOBJ volatile pObjs;
627 /** List of free object usage records. */
628 PSUPDRVUSAGE volatile pUsageFree;
629
630 /** Global cookie. */
631 uint32_t u32Cookie;
632
633 /** The IDT entry number.
634 * Only valid if pIdtPatches is set. */
635 uint8_t volatile u8Idt;
636
637 /** Loader mutex.
638 * This protects pvVMMR0, pvVMMR0Entry, pImages and SUPDRVSESSION::pLdrUsage. */
639 RTSEMFASTMUTEX mtxLdr;
640
641 /** VMM Module 'handle'.
642 * 0 if the code VMM isn't loaded and Idt are nops. */
643 void * volatile pvVMMR0;
644 /** VMMR0EntryInt() pointer. */
645 DECLR0CALLBACKMEMBER(int, pfnVMMR0EntryInt, (PVM pVM, unsigned uOperation, void *pvArg));
646 /** VMMR0EntryFast() pointer. */
647 DECLR0CALLBACKMEMBER(int, pfnVMMR0EntryFast, (PVM pVM, unsigned uOperation));
648 /** VMMR0EntryEx() pointer. */
649 DECLR0CALLBACKMEMBER(int, pfnVMMR0EntryEx, (PVM pVM, unsigned uOperation, PSUPVMMR0REQHDR pReq, uint64_t u64Arg));
650
651 /** Linked list of loaded code. */
652 PSUPDRVLDRIMAGE volatile pLdrImages;
653
654 /** GIP mutex.
655 * Any changes to any of the GIP members requires ownership of this mutex,
656 * except on driver init and termination. */
657 RTSEMFASTMUTEX mtxGip;
658 /** Pointer to the Global Info Page (GIP). */
659 PSUPGLOBALINFOPAGE pGip;
660 /** The physical address of the GIP. */
661 RTHCPHYS HCPhysGip;
662 /** Number of processes using the GIP.
663 * (The updates are suspend while cGipUsers is 0.)*/
664 uint32_t volatile cGipUsers;
665#ifdef USE_NEW_OS_INTERFACE_FOR_GIP
666 /** The ring-0 memory object handle for the GIP page. */
667 RTR0MEMOBJ GipMemObj;
668 /** The GIP timer handle. */
669 PRTTIMER pGipTimer;
670 /** If non-zero we've successfully called RTTimerRequestSystemGranularity(). */
671 uint32_t u32SystemTimerGranularityGrant;
672#endif
673#ifdef RT_OS_WINDOWS
674 /** The GIP timer object. */
675 KTIMER GipTimer;
676 /** The GIP DPC object associated with GipTimer. */
677 KDPC GipDpc;
678 /** The GIP DPC objects for updating per-cpu data. */
679 KDPC aGipCpuDpcs[32];
680 /** Pointer to the MDL for the pGip page. */
681 PMDL pGipMdl;
682 /** GIP timer interval (ms). */
683 ULONG ulGipTimerInterval;
684#endif
685#ifdef RT_OS_LINUX
686 /** The last jiffies. */
687 unsigned long ulLastJiffies;
688 /** The last mono time stamp. */
689 uint64_t volatile u64LastMonotime;
690 /** Set when GIP is suspended to prevent the timers from re-registering themselves). */
691 uint8_t volatile fGIPSuspended;
692# ifdef CONFIG_SMP
693 /** Array of per CPU data for SUPGIPMODE_ASYNC_TSC. */
694 struct LINUXCPU
695 {
696 /** The last mono time stamp. */
697 uint64_t volatile u64LastMonotime;
698 /** The last jiffies. */
699 unsigned long ulLastJiffies;
700 /** The Linux Process ID. */
701 unsigned iSmpProcessorId;
702 /** The per cpu timer. */
703 struct timer_list Timer;
704 } aCPUs[256];
705# endif
706#endif
707} SUPDRVDEVEXT;
708
709
710__BEGIN_DECLS
711
712/*******************************************************************************
713* OS Specific Functions *
714*******************************************************************************/
715void VBOXCALL supdrvOSObjInitCreator(PSUPDRVOBJ pObj, PSUPDRVSESSION pSession);
716bool VBOXCALL supdrvOSObjCanAccess(PSUPDRVOBJ pObj, PSUPDRVSESSION pSession, const char *pszObjName, int *prc);
717#ifndef USE_NEW_OS_INTERFACE_FOR_MM
718int VBOXCALL supdrvOSLockMemOne(PSUPDRVMEMREF pMem, PSUPPAGE paPages);
719void VBOXCALL supdrvOSUnlockMemOne(PSUPDRVMEMREF pMem);
720int VBOXCALL supdrvOSContAllocOne(PSUPDRVMEMREF pMem, PRTR0PTR ppvR0, PRTR3PTR ppvR3, PRTHCPHYS pHCPhys);
721void VBOXCALL supdrvOSContFreeOne(PSUPDRVMEMREF pMem);
722int VBOXCALL supdrvOSLowAllocOne(PSUPDRVMEMREF pMem, PRTR0PTR ppvR0, PRTR3PTR ppvR3, PSUPPAGE paPages);
723void VBOXCALL supdrvOSLowFreeOne(PSUPDRVMEMREF pMem);
724int VBOXCALL supdrvOSMemAllocOne(PSUPDRVMEMREF pMem, PRTR0PTR ppvR0, PRTR3PTR ppvR3);
725void VBOXCALL supdrvOSMemGetPages(PSUPDRVMEMREF pMem, PSUPPAGE paPages);
726void VBOXCALL supdrvOSMemFreeOne(PSUPDRVMEMREF pMem);
727#endif
728#ifndef USE_NEW_OS_INTERFACE_FOR_GIP
729int VBOXCALL supdrvOSGipMap(PSUPDRVDEVEXT pDevExt, PSUPGLOBALINFOPAGE *ppGip);
730int VBOXCALL supdrvOSGipUnmap(PSUPDRVDEVEXT pDevExt, PSUPGLOBALINFOPAGE pGip);
731void VBOXCALL supdrvOSGipResume(PSUPDRVDEVEXT pDevExt);
732void VBOXCALL supdrvOSGipSuspend(PSUPDRVDEVEXT pDevExt);
733unsigned VBOXCALL supdrvOSGetCPUCount(void);
734bool VBOXCALL supdrvOSGetForcedAsyncTscMode(void);
735#endif
736
737
738/*******************************************************************************
739* Shared Functions *
740*******************************************************************************/
741int VBOXCALL supdrvIOCtl(uintptr_t uIOCtl, PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession, PSUPREQHDR pReqHdr);
742int VBOXCALL supdrvIOCtlFast(uintptr_t uIOCtl, PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession);
743int VBOXCALL supdrvInitDevExt(PSUPDRVDEVEXT pDevExt);
744void VBOXCALL supdrvDeleteDevExt(PSUPDRVDEVEXT pDevExt);
745int VBOXCALL supdrvCreateSession(PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION *ppSession);
746void VBOXCALL supdrvCloseSession(PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession);
747void VBOXCALL supdrvCleanupSession(PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession);
748int VBOXCALL supdrvGipInit(PSUPDRVDEVEXT pDevExt, PSUPGLOBALINFOPAGE pGip, RTHCPHYS HCPhys, uint64_t u64NanoTS, unsigned uUpdateHz);
749void VBOXCALL supdrvGipTerm(PSUPGLOBALINFOPAGE pGip);
750void VBOXCALL supdrvGipUpdate(PSUPGLOBALINFOPAGE pGip, uint64_t u64NanoTS);
751void VBOXCALL supdrvGipUpdatePerCpu(PSUPGLOBALINFOPAGE pGip, uint64_t u64NanoTS, unsigned iCpu);
752
753__END_DECLS
754
755#endif
756
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