VirtualBox

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

Last change on this file since 4803 was 4800, checked in by vboxsync, 17 years ago

Redid the supdrv interface. works on windows and linux while the other OSes still needs some adjusting/testing. internal networking is temporarily broken as the SUPCallVMMR0Ex interface is being reworked (this is what all this is really about).

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 23.3 KB
Line 
1/* $Revision: 4800 $ */
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/* bird debugging - #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 1//bird 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 /** 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 PFNSUPDRVDESTRUCTOR pfnDestructor;
520 /** User argument 1. */
521 void *pvUser1;
522 /** User argument 2. */
523 void *pvUser2;
524 /** The total sum of all per-session usage. */
525 uint32_t volatile cUsage;
526 /** The creator user id. */
527 RTUID CreatorUid;
528 /** The creator group id. */
529 RTGID CreatorGid;
530 /** The creator process id. */
531 RTPROCESS CreatorProcess;
532} SUPDRVOBJ, *PSUPDRVOBJ;
533
534/** Magic number for SUPDRVOBJ::u32Magic. (Dame Agatha Mary Clarissa Christie). */
535#define SUPDRVOBJ_MAGIC 0x18900915
536
537/**
538 * The per-session object usage record.
539 */
540typedef struct SUPDRVUSAGE
541{
542 /** Pointer to the next in the list. */
543 struct SUPDRVUSAGE * volatile pNext;
544 /** Pointer to the object we're recording usage for. */
545 PSUPDRVOBJ pObj;
546 /** The usage count. */
547 uint32_t volatile cUsage;
548} SUPDRVUSAGE, *PSUPDRVUSAGE;
549
550
551/**
552 * Per session data.
553 * This is mainly for memory tracking.
554 */
555typedef struct SUPDRVSESSION
556{
557 /** Pointer to the device extension. */
558 PSUPDRVDEVEXT pDevExt;
559 /** Session Cookie. */
560 uint32_t u32Cookie;
561
562 /** Load usage records. (protected by SUPDRVDEVEXT::mtxLdr) */
563 PSUPDRVLDRUSAGE volatile pLdrUsage;
564#ifndef VBOX_WITHOUT_IDT_PATCHING
565 /** Patch usage records. (protected by SUPDRVDEVEXT::SpinLock) */
566 PSUPDRVPATCHUSAGE volatile pPatchUsage;
567#else
568 /** The VM associated with the session. */
569 PVM pVM;
570#endif
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. */
616 RTSPINLOCK Spinlock;
617
618#ifndef VBOX_WITHOUT_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. */
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 /** VMMR0Entry() pointer. */
645 DECLR0CALLBACKMEMBER(int, pfnVMMR0Entry, (PVM pVM, unsigned uOperation, void *pvArg));
646
647 /** Linked list of loaded code. */
648 PSUPDRVLDRIMAGE volatile pLdrImages;
649
650 /** GIP mutex.
651 * Any changes to any of the GIP members requires ownership of this mutex,
652 * except on driver init and termination. */
653 RTSEMFASTMUTEX mtxGip;
654 /** Pointer to the Global Info Page (GIP). */
655 PSUPGLOBALINFOPAGE pGip;
656 /** The physical address of the GIP. */
657 RTHCPHYS HCPhysGip;
658 /** Number of processes using the GIP.
659 * (The updates are suspend while cGipUsers is 0.)*/
660 uint32_t volatile cGipUsers;
661#ifdef USE_NEW_OS_INTERFACE_FOR_GIP
662 /** The ring-0 memory object handle for the GIP page. */
663 RTR0MEMOBJ GipMemObj;
664 /** The GIP timer handle. */
665 PRTTIMER pGipTimer;
666 /** If non-zero we've successfully called RTTimerRequestSystemGranularity(). */
667 uint32_t u32SystemTimerGranularityGrant;
668#endif
669#ifdef RT_OS_WINDOWS
670 /** The GIP timer object. */
671 KTIMER GipTimer;
672 /** The GIP DPC object associated with GipTimer. */
673 KDPC GipDpc;
674 /** The GIP DPC objects for updating per-cpu data. */
675 KDPC aGipCpuDpcs[32];
676 /** Pointer to the MDL for the pGip page. */
677 PMDL pGipMdl;
678 /** GIP timer interval (ms). */
679 ULONG ulGipTimerInterval;
680#endif
681#ifdef RT_OS_LINUX
682 /** The last jiffies. */
683 unsigned long ulLastJiffies;
684 /** The last mono time stamp. */
685 uint64_t volatile u64LastMonotime;
686 /** Set when GIP is suspended to prevent the timers from re-registering themselves). */
687 uint8_t volatile fGIPSuspended;
688# ifdef CONFIG_SMP
689 /** Array of per CPU data for SUPGIPMODE_ASYNC_TSC. */
690 struct LINUXCPU
691 {
692 /** The last mono time stamp. */
693 uint64_t volatile u64LastMonotime;
694 /** The last jiffies. */
695 unsigned long ulLastJiffies;
696 /** The Linux Process ID. */
697 unsigned iSmpProcessorId;
698 /** The per cpu timer. */
699 struct timer_list Timer;
700 } aCPUs[256];
701# endif
702#endif
703} SUPDRVDEVEXT;
704
705
706__BEGIN_DECLS
707
708/*******************************************************************************
709* OS Specific Functions *
710*******************************************************************************/
711void VBOXCALL supdrvOSObjInitCreator(PSUPDRVOBJ pObj, PSUPDRVSESSION pSession);
712bool VBOXCALL supdrvOSObjCanAccess(PSUPDRVOBJ pObj, PSUPDRVSESSION pSession, const char *pszObjName, int *prc);
713#ifndef USE_NEW_OS_INTERFACE_FOR_MM
714int VBOXCALL supdrvOSLockMemOne(PSUPDRVMEMREF pMem, PSUPPAGE paPages);
715void VBOXCALL supdrvOSUnlockMemOne(PSUPDRVMEMREF pMem);
716int VBOXCALL supdrvOSContAllocOne(PSUPDRVMEMREF pMem, PRTR0PTR ppvR0, PRTR3PTR ppvR3, PRTHCPHYS pHCPhys);
717void VBOXCALL supdrvOSContFreeOne(PSUPDRVMEMREF pMem);
718int VBOXCALL supdrvOSLowAllocOne(PSUPDRVMEMREF pMem, PRTR0PTR ppvR0, PRTR3PTR ppvR3, PSUPPAGE paPages);
719void VBOXCALL supdrvOSLowFreeOne(PSUPDRVMEMREF pMem);
720int VBOXCALL supdrvOSMemAllocOne(PSUPDRVMEMREF pMem, PRTR0PTR ppvR0, PRTR3PTR ppvR3);
721void VBOXCALL supdrvOSMemGetPages(PSUPDRVMEMREF pMem, PSUPPAGE paPages);
722void VBOXCALL supdrvOSMemFreeOne(PSUPDRVMEMREF pMem);
723#endif
724#ifndef USE_NEW_OS_INTERFACE_FOR_GIP
725int VBOXCALL supdrvOSGipMap(PSUPDRVDEVEXT pDevExt, PSUPGLOBALINFOPAGE *ppGip);
726int VBOXCALL supdrvOSGipUnmap(PSUPDRVDEVEXT pDevExt, PSUPGLOBALINFOPAGE pGip);
727void VBOXCALL supdrvOSGipResume(PSUPDRVDEVEXT pDevExt);
728void VBOXCALL supdrvOSGipSuspend(PSUPDRVDEVEXT pDevExt);
729unsigned VBOXCALL supdrvOSGetCPUCount(void);
730bool VBOXCALL supdrvOSGetForcedAsyncTscMode(void);
731#endif
732
733
734/*******************************************************************************
735* Shared Functions *
736*******************************************************************************/
737int VBOXCALL supdrvIOCtl(uintptr_t uIOCtl, PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession, PSUPREQHDR pReqHdr);
738#ifdef VBOX_WITHOUT_IDT_PATCHING
739int VBOXCALL supdrvIOCtlFast(uintptr_t uIOCtl, PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession);
740#endif
741int VBOXCALL supdrvInitDevExt(PSUPDRVDEVEXT pDevExt);
742void VBOXCALL supdrvDeleteDevExt(PSUPDRVDEVEXT pDevExt);
743int VBOXCALL supdrvCreateSession(PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION *ppSession);
744void VBOXCALL supdrvCloseSession(PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession);
745void VBOXCALL supdrvCleanupSession(PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession);
746int VBOXCALL supdrvGipInit(PSUPDRVDEVEXT pDevExt, PSUPGLOBALINFOPAGE pGip, RTHCPHYS HCPhys, uint64_t u64NanoTS, unsigned uUpdateHz);
747void VBOXCALL supdrvGipTerm(PSUPGLOBALINFOPAGE pGip);
748void VBOXCALL supdrvGipUpdate(PSUPGLOBALINFOPAGE pGip, uint64_t u64NanoTS);
749void VBOXCALL supdrvGipUpdatePerCpu(PSUPGLOBALINFOPAGE pGip, uint64_t u64NanoTS, unsigned iCpu);
750
751__END_DECLS
752
753#endif
754
Note: See TracBrowser for help on using the repository browser.

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