VirtualBox

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

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

USB_NEW_OS_INTERFACE_FOR_LOW (prep)

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