VirtualBox

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

Last change on this file since 4753 was 4704, checked in by vboxsync, 17 years ago

Compile fix

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 23.2 KB
Line 
1/* $Revision: 4704 $ */
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) uprintf 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#ifndef VBOX_WITHOUT_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_WITHOUT_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 /** Blow the type up to 32-bit and mark the end. */
360 MEMREG_TYPE_32BIT_HACK = 0x7fffffff
361} SUPDRVMEMREFTYPE, *PSUPDRVMEMREFTYPE;
362
363
364/**
365 * Structure used for tracking memory a session
366 * references in one way or another.
367 */
368typedef struct SUPDRVMEMREF
369{
370#ifdef USE_NEW_OS_INTERFACE_FOR_MM
371 /** The memory object handle. */
372 RTR0MEMOBJ MemObj;
373 /** The ring-3 mapping memory object handle. */
374 RTR0MEMOBJ MapObjR3;
375 /** Type of memory. */
376 SUPDRVMEMREFTYPE eType;
377
378#else /* !USE_NEW_OS_INTERFACE_FOR_MM */
379 /** Pointer to the R0 mapping of the memory.
380 * Set to NULL if N/A. */
381 void *pvR0;
382 /** Pointer to the R3 mapping of the memory.
383 * Set to NULL if N/A. */
384 RTR3PTR pvR3;
385 /** Size of the locked memory. */
386 unsigned cb;
387 /** Type of memory. */
388 SUPDRVMEMREFTYPE eType;
389
390 /** memory type specific information. */
391 union
392 {
393 struct
394 {
395#if defined(RT_OS_WINDOWS)
396 /** Pointer to memory descriptor list (MDL). */
397 PMDL *papMdl;
398 unsigned cMdls;
399#elif defined(RT_OS_LINUX)
400 struct page **papPages;
401 unsigned cPages;
402#else
403# error "Either no target was defined or we haven't ported the driver to the target yet."
404#endif
405 } locked;
406 struct
407 {
408#if defined(RT_OS_WINDOWS)
409 /** Pointer to memory descriptor list (MDL). */
410 PMDL pMdl;
411#elif defined(RT_OS_LINUX)
412 struct page *paPages;
413 unsigned cPages;
414#else
415# error "Either no target was defined or we haven't ported the driver to the target yet."
416#endif
417 } cont;
418 struct
419 {
420#if defined(RT_OS_WINDOWS)
421 /** Pointer to memory descriptor list (MDL). */
422 PMDL pMdl;
423#elif defined(RT_OS_LINUX)
424 /** Pointer to the array of page pointers. */
425 struct page **papPages;
426 /** Number of pages in papPages. */
427 unsigned cPages;
428#else
429# error "Either no target was defined or we haven't ported the driver to the target yet."
430#endif
431 } mem;
432#if defined(USE_NEW_OS_INTERFACE_FOR_LOW)
433 struct
434 {
435 /** The memory object handle. */
436 RTR0MEMOBJ MemObj;
437 /** The ring-3 mapping memory object handle. */
438 RTR0MEMOBJ MapObjR3;
439 } iprt;
440#endif
441 } u;
442#endif /* !USE_NEW_OS_INTERFACE_FOR_MM */
443} SUPDRVMEMREF, *PSUPDRVMEMREF;
444
445
446/**
447 * Bundle of locked memory ranges.
448 */
449typedef struct SUPDRVBUNDLE
450{
451 /** Pointer to the next bundle. */
452 struct SUPDRVBUNDLE * volatile pNext;
453 /** Referenced memory. */
454 SUPDRVMEMREF aMem[64];
455 /** Number of entries used. */
456 uint32_t volatile cUsed;
457} SUPDRVBUNDLE, *PSUPDRVBUNDLE;
458
459
460/**
461 * Loaded image.
462 */
463typedef struct SUPDRVLDRIMAGE
464{
465 /** Next in chain. */
466 struct SUPDRVLDRIMAGE * volatile pNext;
467 /** Pointer to the image. */
468 void *pvImage;
469 /** Pointer to the optional module initialization callback. */
470 PFNR0MODULEINIT pfnModuleInit;
471 /** Pointer to the optional module termination callback. */
472 PFNR0MODULETERM pfnModuleTerm;
473 /** Size of the image. */
474 uint32_t cbImage;
475 /** The offset of the symbol table. */
476 uint32_t offSymbols;
477 /** The number of entries in the symbol table. */
478 uint32_t cSymbols;
479 /** The offset of the string table. */
480 uint32_t offStrTab;
481 /** Size of the string table. */
482 uint32_t cbStrTab;
483 /** The ldr image state. (IOCtl code of last opration.) */
484 uint32_t uState;
485 /** Usage count. */
486 uint32_t volatile cUsage;
487 /** Image name. */
488 char szName[32];
489} SUPDRVLDRIMAGE, *PSUPDRVLDRIMAGE;
490
491
492/** Image usage record. */
493typedef struct SUPDRVLDRUSAGE
494{
495 /** Next in chain. */
496 struct SUPDRVLDRUSAGE * volatile pNext;
497 /** The image. */
498 PSUPDRVLDRIMAGE pImage;
499 /** Load count. */
500 uint32_t volatile cUsage;
501} SUPDRVLDRUSAGE, *PSUPDRVLDRUSAGE;
502
503
504/**
505 * Registered object.
506 * This takes care of reference counting and tracking data for access checks.
507 */
508typedef struct SUPDRVOBJ
509{
510 /** Magic value (SUPDRVOBJ_MAGIC). */
511 uint32_t u32Magic;
512 /** The object type. */
513 SUPDRVOBJTYPE enmType;
514 /** Pointer to the next in the global list. */
515 struct SUPDRVOBJ * volatile pNext;
516 /** Pointer to the object destructor. */
517 PFNSUPDRVDESTRUCTOR pfnDestructor;
518 /** User argument 1. */
519 void *pvUser1;
520 /** User argument 2. */
521 void *pvUser2;
522 /** The total sum of all per-session usage. */
523 uint32_t volatile cUsage;
524 /** The creator user id. */
525 RTUID CreatorUid;
526 /** The creator group id. */
527 RTGID CreatorGid;
528 /** The creator process id. */
529 RTPROCESS CreatorProcess;
530} SUPDRVOBJ, *PSUPDRVOBJ;
531
532/** Magic number for SUPDRVOBJ::u32Magic. (Dame Agatha Mary Clarissa Christie). */
533#define SUPDRVOBJ_MAGIC 0x18900915
534
535/**
536 * The per-session object usage record.
537 */
538typedef struct SUPDRVUSAGE
539{
540 /** Pointer to the next in the list. */
541 struct SUPDRVUSAGE * volatile pNext;
542 /** Pointer to the object we're recording usage for. */
543 PSUPDRVOBJ pObj;
544 /** The usage count. */
545 uint32_t volatile cUsage;
546} SUPDRVUSAGE, *PSUPDRVUSAGE;
547
548
549/**
550 * Per session data.
551 * This is mainly for memory tracking.
552 */
553typedef struct SUPDRVSESSION
554{
555 /** Pointer to the device extension. */
556 PSUPDRVDEVEXT pDevExt;
557 /** Session Cookie. */
558 uint32_t u32Cookie;
559
560 /** Load usage records. (protected by SUPDRVDEVEXT::mtxLdr) */
561 PSUPDRVLDRUSAGE volatile pLdrUsage;
562#ifndef VBOX_WITHOUT_IDT_PATCHING
563 /** Patch usage records. (protected by SUPDRVDEVEXT::SpinLock) */
564 PSUPDRVPATCHUSAGE volatile pPatchUsage;
565#else
566 /** The VM associated with the session. */
567 PVM pVM;
568#endif
569 /** List of generic usage records. (protected by SUPDRVDEVEXT::SpinLock) */
570 PSUPDRVUSAGE volatile pUsage;
571
572 /** Spinlock protecting the bundles and the GIP members. */
573 RTSPINLOCK Spinlock;
574#ifdef USE_NEW_OS_INTERFACE_FOR_GIP
575 /** The ring-3 mapping of the GIP (readonly). */
576 RTR0MEMOBJ GipMapObjR3;
577#else
578 /** The read-only usermode mapping address of the GID.
579 * This is NULL if the GIP hasn't been mapped. */
580 PSUPGLOBALINFOPAGE pGip;
581#endif
582 /** Set if the session is using the GIP. */
583 uint32_t fGipReferenced;
584 /** Bundle of locked memory objects. */
585 SUPDRVBUNDLE Bundle;
586
587 /** The user id of the session. (Set by the OS part.) */
588 RTUID Uid;
589 /** The group id of the session. (Set by the OS part.) */
590 RTGID Gid;
591 /** The process (id) of the session. (Set by the OS part.) */
592 RTPROCESS Process;
593 /** Which process this session is associated with. */
594 RTR0PROCESS R0Process;
595#if defined(RT_OS_OS2)
596 /** The system file number of this session. */
597 uint16_t sfn;
598 uint16_t Alignment; /**< Alignment */
599#endif
600#if defined(RT_OS_DARWIN) || defined(RT_OS_OS2) || defined(RT_OS_SOLARIS)
601 /** Pointer to the next session with the same hash. */
602 PSUPDRVSESSION pNextHash;
603#endif
604} SUPDRVSESSION;
605
606
607/**
608 * Device extension.
609 */
610typedef struct SUPDRVDEVEXT
611{
612 /** Spinlock to serialize the initialization,
613 * usage counting and destruction of the IDT entry override. */
614 RTSPINLOCK Spinlock;
615
616#ifndef VBOX_WITHOUT_IDT_PATCHING
617 /** List of patches. */
618 PSUPDRVPATCH volatile pIdtPatches;
619 /** List of patches Free. */
620 PSUPDRVPATCH volatile pIdtPatchesFree;
621#endif
622
623 /** List of registered objects. */
624 PSUPDRVOBJ volatile pObjs;
625 /** List of free object usage records. */
626 PSUPDRVUSAGE volatile pUsageFree;
627
628 /** Global cookie. */
629 uint32_t u32Cookie;
630
631 /** The IDT entry number.
632 * Only valid if pIdtPatches is set. */
633 uint8_t volatile u8Idt;
634
635 /** Loader mutex.
636 * This protects pvVMMR0, pvVMMR0Entry, pImages and SUPDRVSESSION::pLdrUsage. */
637 RTSEMFASTMUTEX mtxLdr;
638
639 /** VMM Module 'handle'.
640 * 0 if the code VMM isn't loaded and Idt are nops. */
641 void * volatile pvVMMR0;
642 /** VMMR0Entry() pointer. */
643 DECLR0CALLBACKMEMBER(int, pfnVMMR0Entry, (PVM pVM, unsigned uOperation, void *pvArg));
644
645 /** Linked list of loaded code. */
646 PSUPDRVLDRIMAGE volatile pLdrImages;
647
648 /** GIP mutex.
649 * Any changes to any of the GIP members requires ownership of this mutex,
650 * except on driver init and termination. */
651 RTSEMFASTMUTEX mtxGip;
652 /** Pointer to the Global Info Page (GIP). */
653 PSUPGLOBALINFOPAGE pGip;
654 /** The physical address of the GIP. */
655 RTHCPHYS HCPhysGip;
656 /** Number of processes using the GIP.
657 * (The updates are suspend while cGipUsers is 0.)*/
658 uint32_t volatile cGipUsers;
659#ifdef USE_NEW_OS_INTERFACE_FOR_GIP
660 /** The ring-0 memory object handle for the GIP page. */
661 RTR0MEMOBJ GipMemObj;
662 /** The GIP timer handle. */
663 PRTTIMER pGipTimer;
664 /** If non-zero we've successfully called RTTimerRequestSystemGranularity(). */
665 uint32_t u32SystemTimerGranularityGrant;
666#endif
667#ifdef RT_OS_WINDOWS
668 /** The GIP timer object. */
669 KTIMER GipTimer;
670 /** The GIP DPC object associated with GipTimer. */
671 KDPC GipDpc;
672 /** The GIP DPC objects for updating per-cpu data. */
673 KDPC aGipCpuDpcs[32];
674 /** Pointer to the MDL for the pGip page. */
675 PMDL pGipMdl;
676 /** GIP timer interval (ms). */
677 ULONG ulGipTimerInterval;
678#endif
679#ifdef RT_OS_LINUX
680 /** The last jiffies. */
681 unsigned long ulLastJiffies;
682 /** The last mono time stamp. */
683 uint64_t volatile u64LastMonotime;
684 /** Set when GIP is suspended to prevent the timers from re-registering themselves). */
685 uint8_t volatile fGIPSuspended;
686# ifdef CONFIG_SMP
687 /** Array of per CPU data for SUPGIPMODE_ASYNC_TSC. */
688 struct LINUXCPU
689 {
690 /** The last mono time stamp. */
691 uint64_t volatile u64LastMonotime;
692 /** The last jiffies. */
693 unsigned long ulLastJiffies;
694 /** The Linux Process ID. */
695 unsigned iSmpProcessorId;
696 /** The per cpu timer. */
697 struct timer_list Timer;
698 } aCPUs[256];
699# endif
700#endif
701} SUPDRVDEVEXT;
702
703
704__BEGIN_DECLS
705
706/*******************************************************************************
707* OS Specific Functions *
708*******************************************************************************/
709void VBOXCALL supdrvOSObjInitCreator(PSUPDRVOBJ pObj, PSUPDRVSESSION pSession);
710bool VBOXCALL supdrvOSObjCanAccess(PSUPDRVOBJ pObj, PSUPDRVSESSION pSession, const char *pszObjName, int *prc);
711#ifndef USE_NEW_OS_INTERFACE_FOR_MM
712int VBOXCALL supdrvOSLockMemOne(PSUPDRVMEMREF pMem, PSUPPAGE paPages);
713void VBOXCALL supdrvOSUnlockMemOne(PSUPDRVMEMREF pMem);
714int VBOXCALL supdrvOSContAllocOne(PSUPDRVMEMREF pMem, PRTR0PTR ppvR0, PRTR3PTR ppvR3, PRTHCPHYS pHCPhys);
715void VBOXCALL supdrvOSContFreeOne(PSUPDRVMEMREF pMem);
716int VBOXCALL supdrvOSLowAllocOne(PSUPDRVMEMREF pMem, PRTR0PTR ppvR0, PRTR3PTR ppvR3, PSUPPAGE paPages);
717void VBOXCALL supdrvOSLowFreeOne(PSUPDRVMEMREF pMem);
718int VBOXCALL supdrvOSMemAllocOne(PSUPDRVMEMREF pMem, PRTR0PTR ppvR0, PRTR3PTR ppvR3);
719void VBOXCALL supdrvOSMemGetPages(PSUPDRVMEMREF pMem, PSUPPAGE paPages);
720void VBOXCALL supdrvOSMemFreeOne(PSUPDRVMEMREF pMem);
721#endif
722#ifndef USE_NEW_OS_INTERFACE_FOR_GIP
723int VBOXCALL supdrvOSGipMap(PSUPDRVDEVEXT pDevExt, PSUPGLOBALINFOPAGE *ppGip);
724int VBOXCALL supdrvOSGipUnmap(PSUPDRVDEVEXT pDevExt, PSUPGLOBALINFOPAGE pGip);
725void VBOXCALL supdrvOSGipResume(PSUPDRVDEVEXT pDevExt);
726void VBOXCALL supdrvOSGipSuspend(PSUPDRVDEVEXT pDevExt);
727unsigned VBOXCALL supdrvOSGetCPUCount(void);
728bool VBOXCALL supdrvOSGetForcedAsyncTscMode(void);
729#endif
730
731
732/*******************************************************************************
733* Shared Functions *
734*******************************************************************************/
735int VBOXCALL supdrvIOCtl(unsigned uIOCtl, PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession,
736 void *pvIn, unsigned cbIn, void *pvOut, unsigned cbOut, unsigned *pcbReturned);
737#ifdef VBOX_WITHOUT_IDT_PATCHING
738int VBOXCALL supdrvIOCtlFast(unsigned uIOCtl, PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession);
739#endif
740int VBOXCALL supdrvInitDevExt(PSUPDRVDEVEXT pDevExt);
741int VBOXCALL supdrvDeleteDevExt(PSUPDRVDEVEXT pDevExt);
742int VBOXCALL supdrvCreateSession(PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION *ppSession);
743void VBOXCALL supdrvCloseSession(PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession);
744void VBOXCALL supdrvCleanupSession(PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession);
745int VBOXCALL supdrvGipInit(PSUPDRVDEVEXT pDevExt, PSUPGLOBALINFOPAGE pGip, RTHCPHYS HCPhys, uint64_t u64NanoTS, unsigned uUpdateHz);
746void VBOXCALL supdrvGipTerm(PSUPGLOBALINFOPAGE pGip);
747void VBOXCALL supdrvGipUpdate(PSUPGLOBALINFOPAGE pGip, uint64_t u64NanoTS);
748void VBOXCALL supdrvGipUpdatePerCpu(PSUPGLOBALINFOPAGE pGip, uint64_t u64NanoTS, unsigned iCpu);
749
750__END_DECLS
751
752#endif
753
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