VirtualBox

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

Last change on this file since 4230 was 4161, checked in by vboxsync, 18 years ago

USE_NEW_OS_INTERFACE_FOR_MM & USE_NEW_OS_INTERFACE_FOR_GIP.

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