1 | /* $Id: VBoxGuestInternal.h 8328 2008-04-23 13:17:00Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBoxGuest - Guest Additions Driver.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2007 Sun Microsystems, Inc.
|
---|
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 (GPL) as published by the Free Software
|
---|
13 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | *
|
---|
17 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
|
---|
18 | * Clara, CA 95054 USA or visit http://www.sun.com if you need
|
---|
19 | * additional information or have any questions.
|
---|
20 | */
|
---|
21 |
|
---|
22 | #ifndef ___VBoxGuestInternal_h
|
---|
23 | #define ___VBoxGuestInternal_h
|
---|
24 |
|
---|
25 | #include <iprt/types.h>
|
---|
26 | #include <iprt/semaphore.h>
|
---|
27 | #include <iprt/spinlock.h>
|
---|
28 | #include <VBox/VBoxGuest.h>
|
---|
29 | #include <VBox/VBoxGuestLib.h>
|
---|
30 |
|
---|
31 |
|
---|
32 | /** Pointer to a wait-for-event entry. */
|
---|
33 | typedef struct VBOXGUESTWAIT *PVBOXGUESTWAIT;
|
---|
34 |
|
---|
35 | /**
|
---|
36 | * VBox guest wait for event entry.
|
---|
37 | *
|
---|
38 | * Each waiting thread allocates one of these items and adds
|
---|
39 | * it to the wait list before going to sleep on the event sem.
|
---|
40 | */
|
---|
41 | typedef struct VBOXGUESTWAIT
|
---|
42 | {
|
---|
43 | /** The next entry in the list. */
|
---|
44 | PVBOXGUESTWAIT volatile pNext;
|
---|
45 | /** The previous entry in the list. */
|
---|
46 | PVBOXGUESTWAIT volatile pPrev;
|
---|
47 | /** The event semaphore. */
|
---|
48 | RTSEMEVENTMULTI Event;
|
---|
49 | /** The events we are waiting on. */
|
---|
50 | uint32_t fReqEvents;
|
---|
51 | /** The events we received. */
|
---|
52 | uint32_t volatile fResEvents;
|
---|
53 | #ifdef VBOX_HGCM
|
---|
54 | /** The HGCM request we're waiting for to complete. */
|
---|
55 | VMMDevHGCMRequestHeader volatile *pHGCMReq;
|
---|
56 | #endif
|
---|
57 | } VBOXGUESTWAIT;
|
---|
58 |
|
---|
59 | /**
|
---|
60 | * VBox guest wait for event list.
|
---|
61 | */
|
---|
62 | typedef struct VBOXGUESTWAITLIST
|
---|
63 | {
|
---|
64 | /** The head. */
|
---|
65 | PVBOXGUESTWAIT volatile pHead;
|
---|
66 | /** The tail. */
|
---|
67 | PVBOXGUESTWAIT volatile pTail;
|
---|
68 | } VBOXGUESTWAITLIST;
|
---|
69 | /** Pointer to a wait list. */
|
---|
70 | typedef VBOXGUESTWAITLIST *PVBOXGUESTWAITLIST;
|
---|
71 |
|
---|
72 |
|
---|
73 | /**
|
---|
74 | * VBox guest device (data) extension.
|
---|
75 | */
|
---|
76 | typedef struct VBOXGUESTDEVEXT
|
---|
77 | {
|
---|
78 | /** The base of the adapter I/O ports. */
|
---|
79 | RTIOPORT IOPortBase;
|
---|
80 | /** Pointer to the mapping of the VMMDev adapter memory. */
|
---|
81 | VMMDevMemory volatile *pVMMDevMemory;
|
---|
82 |
|
---|
83 | /** Preallocated VMMDevEvents for the IRQ handler. */
|
---|
84 | VMMDevEvents *pIrqAckEvents;
|
---|
85 | /** Spinlock protecting the signaling and resetting of the wait-for-event semaphores. */
|
---|
86 | RTSPINLOCK WaitSpinlock;
|
---|
87 | /** Wait-for-event list for threads waiting for multiple events. */
|
---|
88 | VBOXGUESTWAITLIST WaitList;
|
---|
89 | #ifdef VBOX_HGCM
|
---|
90 | /** Wait-for-event list for threads waiting on HGCM async completion.
|
---|
91 | * The entire list is evaluated upon the arrival of an HGCM event, unlike
|
---|
92 | * the other lists which are only evaluated till the first thread has been woken up. */
|
---|
93 | VBOXGUESTWAITLIST HGCMWaitList;
|
---|
94 | #endif
|
---|
95 | /** List of free wait-for-event entries. */
|
---|
96 | VBOXGUESTWAITLIST FreeList;
|
---|
97 | /** Mask of pending events. */
|
---|
98 | uint32_t volatile f32PendingEvents;
|
---|
99 |
|
---|
100 | /** Spinlock various items in the VBOXGUESTSESSION. */
|
---|
101 | RTSPINLOCK SessionSpinlock;
|
---|
102 |
|
---|
103 | /** The current clipboard client ID, 0 if no client.
|
---|
104 | * For implementing the VBOXGUEST_IOCTL_CLIPBOARD_CONNECT interface. */
|
---|
105 | uint32_t u32ClipboardClientId;
|
---|
106 | } VBOXGUESTDEVEXT;
|
---|
107 | /** Pointer to the VBoxGuest driver data. */
|
---|
108 | typedef VBOXGUESTDEVEXT *PVBOXGUESTDEVEXT;
|
---|
109 |
|
---|
110 |
|
---|
111 | /** Pointer to the VBoxGuest per session data. */
|
---|
112 | typedef struct VBOXGUESTSESSION *PVBOXGUESTSESSION;
|
---|
113 |
|
---|
114 | /**
|
---|
115 | * The VBoxGuest per session data.
|
---|
116 | *
|
---|
117 | * @remark Not quite sure whether this will be useful or not, but since
|
---|
118 | * its already there let's keep it for now in case it might come
|
---|
119 | * in handy later.
|
---|
120 | */
|
---|
121 | typedef struct VBOXGUESTSESSION
|
---|
122 | {
|
---|
123 | #if defined(RT_OS_OS2) || defined(RT_OS_FREEBSD) || defined(RT_OS_SOLARIS)
|
---|
124 | /** Pointer to the next session with the same hash. */
|
---|
125 | PVBOXGUESTSESSION pNextHash;
|
---|
126 | #endif
|
---|
127 | #if defined(RT_OS_OS2)
|
---|
128 | /** The system file number of this session. */
|
---|
129 | uint16_t sfn;
|
---|
130 | uint16_t Alignment; /**< Alignment */
|
---|
131 | #endif
|
---|
132 | /** The process (id) of the session.
|
---|
133 | * This is NIL if it's a kernel session. */
|
---|
134 | RTPROCESS Process;
|
---|
135 | /** Which process this session is associated with.
|
---|
136 | * This is NIL if it's a kernel session. */
|
---|
137 | RTR0PROCESS R0Process;
|
---|
138 | /** Pointer to the device extension. */
|
---|
139 | PVBOXGUESTDEVEXT pDevExt;
|
---|
140 |
|
---|
141 | #ifdef VBOX_HGCM
|
---|
142 | /** Array containing HGCM client IDs associated with this session.
|
---|
143 | * This will be automatically disconnected when the session is closed. */
|
---|
144 | uint32_t volatile aHGCMClientIds[8];
|
---|
145 | #endif
|
---|
146 | } VBOXGUESTSESSION;
|
---|
147 |
|
---|
148 |
|
---|
149 | __BEGIN_DECLS
|
---|
150 |
|
---|
151 | int VBoxGuestInitDevExt(PVBOXGUESTDEVEXT pDevExt, uint16_t IOPortBase, void *pvMMIOBase, uint32_t cbMMIO, VBOXOSTYPE enmOSType);
|
---|
152 | void VBoxGuestDeleteDevExt(PVBOXGUESTDEVEXT pDevExt);
|
---|
153 | bool VBoxGuestCommonISR(PVBOXGUESTDEVEXT pDevExt);
|
---|
154 | int VBoxGuestSetGuestCapabilities(uint32_t fOr, uint32_t fNot);
|
---|
155 |
|
---|
156 | int VBoxGuestCreateUserSession(PVBOXGUESTDEVEXT pDevExt, PVBOXGUESTSESSION *ppSession);
|
---|
157 | int VBoxGuestCreateKernelSession(PVBOXGUESTDEVEXT pDevExt, PVBOXGUESTSESSION *ppSession);
|
---|
158 | void VBoxGuestCloseSession(PVBOXGUESTDEVEXT pDevExt, PVBOXGUESTSESSION pSession);
|
---|
159 |
|
---|
160 | int VBoxGuestCommonIOCtlFast(unsigned iFunction, PVBOXGUESTDEVEXT pDevExt, PVBOXGUESTSESSION pSession);
|
---|
161 | int VBoxGuestCommonIOCtl(unsigned iFunction, PVBOXGUESTDEVEXT pDevExt, PVBOXGUESTSESSION pSession,
|
---|
162 | void *pvData, size_t cbData, size_t *pcbDataReturned);
|
---|
163 |
|
---|
164 | __END_DECLS
|
---|
165 |
|
---|
166 | #endif
|
---|
167 |
|
---|