VirtualBox

source: vbox/trunk/include/VBox/types.h@ 11303

Last change on this file since 11303 was 11303, checked in by vboxsync, 16 years ago

pdm: Retired PPDMDEVINSGC.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 14.5 KB
Line 
1/** @file
2 * VirtualBox - Types.
3 */
4
5/*
6 * Copyright (C) 2006-2007 Sun Microsystems, Inc.
7 *
8 * This file is part of VirtualBox Open Source Edition (OSE), as
9 * available from http://www.virtualbox.org. This file is free software;
10 * you can redistribute it and/or modify it under the terms of the GNU
11 * General Public License (GPL) as published by the Free Software
12 * Foundation, in version 2 as it comes in the "COPYING" file of the
13 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
14 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
15 *
16 * The contents of this file may alternatively be used under the terms
17 * of the Common Development and Distribution License Version 1.0
18 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
19 * VirtualBox OSE distribution, in which case the provisions of the
20 * CDDL are applicable instead of those of the GPL.
21 *
22 * You may elect to license modified versions of this file under the
23 * terms and conditions of either the GPL or the CDDL or both.
24 *
25 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
26 * Clara, CA 95054 USA or visit http://www.sun.com if you need
27 * additional information or have any questions.
28 */
29
30#ifndef ___VBox_types_h
31#define ___VBox_types_h
32
33#include <VBox/cdefs.h>
34#include <iprt/types.h>
35
36
37/** @defgroup grp_types Basic VBox Types
38 * @{
39 */
40
41
42/** @defgroup grp_types_both Common Guest and Host Context Basic Types
43 * @ingroup grp_types
44 * @{
45 */
46
47
48/** @defgroup grp_types_hc Host Context Basic Types
49 * @ingroup grp_types_both
50 * @{
51 */
52
53/** @deprecated
54 * @{ */
55typedef RTHCPHYS VBOXHCPHYS;
56typedef VBOXHCPHYS *PVBOXHCPHYS;
57#define NILVBOXHCPHYS NIL_RTHCPHYS
58typedef RTHCPTR VBOXHCPTR;
59typedef VBOXHCPTR *PVBOXHCPTR;
60/** @} */
61
62/** @} */
63
64
65/** @defgroup grp_types_gc Guest Context Basic Types
66 * @ingroup grp_types_both
67 * @{
68 */
69
70/** @} */
71
72
73/** Pointer to per support driver session data.
74 * (The data is a R0 entity and private to the the R0 SUP part. All
75 * other should consider this a sort of handle.) */
76typedef R0PTRTYPE(struct SUPDRVSESSION *) PSUPDRVSESSION;
77
78/** Pointer to a VM. */
79typedef struct VM *PVM;
80/** Pointer to a VM - Ring-0 Ptr. */
81typedef R0PTRTYPE(struct VM *) PVMR0;
82/** Pointer to a VM - Ring-3 Ptr. */
83typedef R3PTRTYPE(struct VM *) PVMR3;
84/** Pointer to a VM - RC Ptr. */
85typedef RCPTRTYPE(struct VM *) PVMRC;
86
87/** Pointer to a ring-0 (global) VM structure. */
88typedef R0PTRTYPE(struct GVM *) PGVM;
89
90/** Pointer to a ring-3 (user mode) VM structure. */
91typedef R3PTRTYPE(struct UVM *) PUVM;
92
93
94/** VM State
95 */
96typedef enum VMSTATE
97{
98 /** The VM is being created. */
99 VMSTATE_CREATING = 0,
100 /** The VM is created. */
101 VMSTATE_CREATED,
102 /** The VM is runnning. */
103 VMSTATE_RUNNING,
104 /** The VM state is being loaded from file. */
105 VMSTATE_LOADING,
106 /** The VM is screwed because of a failed state loading. */
107 VMSTATE_LOAD_FAILURE,
108 /** The VM state is being saved to file. */
109 VMSTATE_SAVING,
110 /** The VM is suspended. */
111 VMSTATE_SUSPENDED,
112 /** The VM is being reset. */
113 VMSTATE_RESETTING,
114 /** The VM is in guru meditation over a fatal failure. */
115 VMSTATE_GURU_MEDITATION,
116 /** The VM is switched off, awaiting destruction. */
117 VMSTATE_OFF,
118 /** The VM is being destroyed. */
119 VMSTATE_DESTROYING,
120 /** Terminated. */
121 VMSTATE_TERMINATED,
122 /** hack forcing the size of the enum to 32-bits. */
123 VMSTATE_MAKE_32BIT_HACK = 0x7fffffff
124} VMSTATE;
125
126
127/** Pointer to a PDM Driver Base Interface. */
128typedef struct PDMIBASE *PPDMIBASE;
129/** Pointer to a pointer to a PDM Driver Base Interface. */
130typedef PPDMIBASE *PPPDMIBASE;
131
132/** Pointer to a PDM Device Instance. */
133typedef struct PDMDEVINS *PPDMDEVINS;
134/** Pointer to a pointer to a PDM Device Instance. */
135typedef PPDMDEVINS *PPPDMDEVINS;
136/** R3 pointer to a PDM Device Instance. */
137typedef R3PTRTYPE(PPDMDEVINS) PPDMDEVINSR3;
138/** R0 pointer to a PDM Device Instance. */
139typedef R0PTRTYPE(PPDMDEVINS) PPDMDEVINSR0;
140/** RC pointer to a PDM Device Instance. */
141typedef RCPTRTYPE(PPDMDEVINS) PPDMDEVINSRC;
142
143/** Pointer to a PDM USB Device Instance. */
144typedef struct PDMUSBINS *PPDMUSBINS;
145/** Pointer to a pointer to a PDM USB Device Instance. */
146typedef PPDMUSBINS *PPPDMUSBINS;
147
148/** Pointer to a PDM Driver Instance. */
149typedef struct PDMDRVINS *PPDMDRVINS;
150/** Pointer to a pointer to a PDM Driver Instance. */
151typedef PPDMDRVINS *PPPDMDRVINS;
152
153/** Pointer to a PDM Service Instance. */
154typedef struct PDMSRVINS *PPDMSRVINS;
155/** Pointer to a pointer to a PDM Service Instance. */
156typedef PPDMSRVINS *PPPDMSRVINS;
157
158/** R3 pointer to a timer. */
159typedef R3PTRTYPE(struct TMTIMER *) PTMTIMERR3;
160/** Pointer to a R3 pointer to a timer. */
161typedef PTMTIMERR3 *PPTMTIMERR3;
162
163/** R0 pointer to a timer. */
164typedef R0PTRTYPE(struct TMTIMER *) PTMTIMERR0;
165/** Pointer to a R3 pointer to a timer. */
166typedef PTMTIMERR0 *PPTMTIMERR0;
167
168/** RC pointer to a timer. */
169typedef RCPTRTYPE(struct TMTIMER *) PTMTIMERRC;
170/** Pointer to a RC pointer to a timer. */
171typedef PTMTIMERRC *PPTMTIMERRC;
172/** @deprecated */
173typedef PTMTIMERRC PTMTIMERGC;
174
175/** Pointer to a timer. */
176typedef CTXALLSUFF(PTMTIMER) PTMTIMER;
177/** Pointer to a pointer to a timer. */
178typedef PTMTIMER *PPTMTIMER;
179
180/** SSM Operation handle. */
181typedef struct SSMHANDLE *PSSMHANDLE;
182
183/** Pointer to a CPUMCTX. */
184typedef struct CPUMCTX *PCPUMCTX;
185/** Pointer to a const CPUMCTX. */
186typedef const struct CPUMCTX *PCCPUMCTX;
187
188/** Pointer to a CPU context core. */
189typedef struct CPUMCTXCORE *PCPUMCTXCORE;
190/** Pointer to a const CPU context core. */
191typedef const struct CPUMCTXCORE *PCCPUMCTXCORE;
192
193/** Pointer to selector hidden registers. */
194typedef struct CPUMSELREGHID *PCPUMSELREGHID;
195/** Pointer to const selector hidden registers. */
196typedef const struct CPUMSELREGHID *PCCPUMSELREGHID;
197
198/** @} */
199
200
201/** @defgroup grp_types_idt Interrupt Descriptor Table Entry.
202 * @ingroup grp_types
203 * @todo This all belongs in x86.h!
204 * @{ */
205
206/** @todo VBOXIDT -> VBOXDESCIDT, skip the complex variations. We'll never use them. */
207
208/** IDT Entry, Task Gate view. */
209#pragma pack(1) /* paranoia */
210typedef struct VBOXIDTE_TASKGATE
211{
212 /** Reserved. */
213 unsigned u16Reserved1 : 16;
214 /** Task Segment Selector. */
215 unsigned u16TSS : 16;
216 /** More reserved. */
217 unsigned u8Reserved2 : 8;
218 /** Fixed value bit 0 - Set to 1. */
219 unsigned u1Fixed0 : 1;
220 /** Busy bit. */
221 unsigned u1Busy : 1;
222 /** Fixed value bit 2 - Set to 1. */
223 unsigned u1Fixed1 : 1;
224 /** Fixed value bit 3 - Set to 0. */
225 unsigned u1Fixed2: 1;
226 /** Fixed value bit 4 - Set to 0. */
227 unsigned u1Fixed3 : 1;
228 /** Descriptor Privilege level. */
229 unsigned u2DPL : 2;
230 /** Present flag. */
231 unsigned u1Present : 1;
232 /** Reserved. */
233 unsigned u16Reserved3 : 16;
234} VBOXIDTE_TASKGATE;
235#pragma pack()
236/** Pointer to IDT Entry, Task gate view. */
237typedef VBOXIDTE_TASKGATE *PVBOXIDTE_TASKGATE;
238
239
240/** IDT Entry, Intertupt gate view. */
241#pragma pack(1) /* paranoia */
242typedef struct VBOXIDTE_INTERRUPTGATE
243{
244 /** Low offset word. */
245 unsigned u16OffsetLow : 16;
246 /** Segment Selector. */
247 unsigned u16SegSel : 16;
248 /** Reserved. */
249 unsigned u5Reserved2 : 5;
250 /** Fixed value bit 0 - Set to 0. */
251 unsigned u1Fixed0 : 1;
252 /** Fixed value bit 1 - Set to 0. */
253 unsigned u1Fixed1 : 1;
254 /** Fixed value bit 2 - Set to 0. */
255 unsigned u1Fixed2 : 1;
256 /** Fixed value bit 3 - Set to 0. */
257 unsigned u1Fixed3: 1;
258 /** Fixed value bit 4 - Set to 1. */
259 unsigned u1Fixed4 : 1;
260 /** Fixed value bit 5 - Set to 1. */
261 unsigned u1Fixed5 : 1;
262 /** Gate size, 1 = 32 bits, 0 = 16 bits. */
263 unsigned u132BitGate : 1;
264 /** Fixed value bit 5 - Set to 0. */
265 unsigned u1Fixed6 : 1;
266 /** Descriptor Privilege level. */
267 unsigned u2DPL : 2;
268 /** Present flag. */
269 unsigned u1Present : 1;
270 /** High offset word. */
271 unsigned u16OffsetHigh : 16;
272} VBOXIDTE_INTERRUPTGATE;
273#pragma pack()
274/** Pointer to IDT Entry, Interrupt gate view. */
275typedef VBOXIDTE_INTERRUPTGATE *PVBOXIDTE_INTERRUPTGATE;
276
277/** IDT Entry, Trap Gate view. */
278#pragma pack(1) /* paranoia */
279typedef struct VBOXIDTE_TRAPGATE
280{
281 /** Low offset word. */
282 unsigned u16OffsetLow : 16;
283 /** Segment Selector. */
284 unsigned u16SegSel : 16;
285 /** Reserved. */
286 unsigned u5Reserved2 : 5;
287 /** Fixed value bit 0 - Set to 0. */
288 unsigned u1Fixed0 : 1;
289 /** Fixed value bit 1 - Set to 0. */
290 unsigned u1Fixed1 : 1;
291 /** Fixed value bit 2 - Set to 0. */
292 unsigned u1Fixed2 : 1;
293 /** Fixed value bit 3 - Set to 1. */
294 unsigned u1Fixed3: 1;
295 /** Fixed value bit 4 - Set to 1. */
296 unsigned u1Fixed4 : 1;
297 /** Fixed value bit 5 - Set to 1. */
298 unsigned u1Fixed5 : 1;
299 /** Gate size, 1 = 32 bits, 0 = 16 bits. */
300 unsigned u132BitGate : 1;
301 /** Fixed value bit 5 - Set to 0. */
302 unsigned u1Fixed6 : 1;
303 /** Descriptor Privilege level. */
304 unsigned u2DPL : 2;
305 /** Present flag. */
306 unsigned u1Present : 1;
307 /** High offset word. */
308 unsigned u16OffsetHigh : 16;
309} VBOXIDTE_TRAPGATE;
310#pragma pack()
311/** Pointer to IDT Entry, Trap Gate view. */
312typedef VBOXIDTE_TRAPGATE *PVBOXIDTE_TRAPGATE;
313
314/** IDT Entry Generic view. */
315#pragma pack(1) /* paranoia */
316typedef struct VBOXIDTE_GENERIC
317{
318 /** Low offset word. */
319 unsigned u16OffsetLow : 16;
320 /** Segment Selector. */
321 unsigned u16SegSel : 16;
322 /** Reserved. */
323 unsigned u5Reserved : 5;
324 /** IDT Type part one (not used for task gate). */
325 unsigned u3Type1 : 3;
326 /** IDT Type part two. */
327 unsigned u5Type2 : 5;
328 /** Descriptor Privilege level. */
329 unsigned u2DPL : 2;
330 /** Present flag. */
331 unsigned u1Present : 1;
332 /** High offset word. */
333 unsigned u16OffsetHigh : 16;
334} VBOXIDTE_GENERIC;
335#pragma pack()
336/** Pointer to IDT Entry Generic view. */
337typedef VBOXIDTE_GENERIC *PVBOXIDTE_GENERIC;
338
339/** IDT Type1 value. (Reserved for task gate!) */
340#define VBOX_IDTE_TYPE1 0
341/** IDT Type2 value - Task gate. */
342#define VBOX_IDTE_TYPE2_TASK 0x5
343/** IDT Type2 value - 16 bit interrupt gate. */
344#define VBOX_IDTE_TYPE2_INT_16 0x6
345/** IDT Type2 value - 32 bit interrupt gate. */
346#define VBOX_IDTE_TYPE2_INT_32 0xe
347/** IDT Type2 value - 16 bit trap gate. */
348#define VBOX_IDTE_TYPE2_TRAP_16 0x7
349/** IDT Type2 value - 32 bit trap gate. */
350#define VBOX_IDTE_TYPE2_TRAP_32 0xf
351
352/** IDT Entry. */
353#pragma pack(1) /* paranoia */
354typedef union VBOXIDTE
355{
356 /** Task gate view. */
357 VBOXIDTE_TASKGATE Task;
358 /** Trap gate view. */
359 VBOXIDTE_TRAPGATE Trap;
360 /** Interrupt gate view. */
361 VBOXIDTE_INTERRUPTGATE Int;
362 /** Generic IDT view. */
363 VBOXIDTE_GENERIC Gen;
364
365 /** 8 bit unsigned integer view. */
366 uint8_t au8[8];
367 /** 16 bit unsigned integer view. */
368 uint16_t au16[4];
369 /** 32 bit unsigned integer view. */
370 uint32_t au32[2];
371 /** 64 bit unsigned integer view. */
372 uint64_t au64;
373} VBOXIDTE;
374#pragma pack()
375/** Pointer to IDT Entry. */
376typedef VBOXIDTE *PVBOXIDTE;
377
378#pragma pack(1)
379/** IDTR */
380typedef struct VBOXIDTR
381{
382 /** Size of the IDT. */
383 uint16_t cbIdt;
384 /** Address of the IDT. */
385 uint64_t pIdt;
386} VBOXIDTR, *PVBOXIDTR;
387#pragma pack()
388/** @} */
389
390
391/** @def VBOXIDTE_OFFSET
392 * Return the offset of an IDT entry.
393 */
394#define VBOXIDTE_OFFSET(desc) \
395 ( ((uint32_t)((desc).Gen.u16OffsetHigh) << 16) \
396 | ( (desc).Gen.u16OffsetLow ) )
397
398#pragma pack(1)
399/** GDTR */
400typedef struct VBOXGDTR
401{
402 /** Size of the GDT. */
403 uint16_t cbGdt;
404 /** Address of the GDT. */
405 uint64_t pGdt;
406} VBOXGDTR;
407#pragma pack()
408/** Pointer to GDTR. */
409typedef VBOXGDTR *PVBOXGDTR;
410
411/** @} */
412
413
414/**
415 * Task Segment
416 */
417#pragma pack(1)
418typedef struct VBOXTSS
419{
420 /** Back link to previous task. (static) */
421 RTSEL selPrev;
422 uint16_t padding1;
423 /** Ring-0 stack pointer. (static) */
424 uint32_t esp0;
425 /** Ring-0 stack segment. (static) */
426 RTSEL ss0;
427 uint16_t padding_ss0;
428 /** Ring-1 stack pointer. (static) */
429 uint32_t esp1;
430 /** Ring-1 stack segment. (static) */
431 RTSEL ss1;
432 uint16_t padding_ss1;
433 /** Ring-2 stack pointer. (static) */
434 uint32_t esp2;
435 /** Ring-2 stack segment. (static) */
436 RTSEL ss2;
437 uint16_t padding_ss2;
438 /** Page directory for the task. (static) */
439 uint32_t cr3;
440 /** EIP before task switch. */
441 uint32_t eip;
442 /** EFLAGS before task switch. */
443 uint32_t eflags;
444 /** EAX before task switch. */
445 uint32_t eax;
446 /** ECX before task switch. */
447 uint32_t ecx;
448 /** EDX before task switch. */
449 uint32_t edx;
450 /** EBX before task switch. */
451 uint32_t ebx;
452 /** ESP before task switch. */
453 uint32_t esp;
454 /** EBP before task switch. */
455 uint32_t ebp;
456 /** ESI before task switch. */
457 uint32_t esi;
458 /** EDI before task switch. */
459 uint32_t edi;
460 /** ES before task switch. */
461 RTSEL es;
462 uint16_t padding_es;
463 /** CS before task switch. */
464 RTSEL cs;
465 uint16_t padding_cs;
466 /** SS before task switch. */
467 RTSEL ss;
468 uint16_t padding_ss;
469 /** DS before task switch. */
470 RTSEL ds;
471 uint16_t padding_ds;
472 /** FS before task switch. */
473 RTSEL fs;
474 uint16_t padding_fs;
475 /** GS before task switch. */
476 RTSEL gs;
477 uint16_t padding_gs;
478 /** LDTR before task switch. */
479 RTSEL selLdt;
480 uint16_t padding_ldt;
481 /** Debug trap flag */
482 uint16_t fDebugTrap;
483 /** Offset relative to the TSS of the start of the I/O Bitmap
484 * and the end of the interrupt redirection bitmap. */
485 uint16_t offIoBitmap;
486 /** 32 bytes for the virtual interrupt redirection bitmap. (VME) */
487 uint8_t IntRedirBitmap[32];
488} VBOXTSS;
489#pragma pack()
490/** Pointer to task segment. */
491typedef VBOXTSS *PVBOXTSS;
492/** Pointer to const task segment. */
493typedef const VBOXTSS *PCVBOXTSS;
494
495
496/**
497 * Data transport buffer (scatter/gather)
498 */
499typedef struct PDMDATASEG
500{
501 /** Length of buffer in entry. */
502 size_t cbSeg;
503 /** Pointer to the start of the buffer. */
504 void *pvSeg;
505} PDMDATASEG;
506/** Pointer to a data transport segment. */
507typedef PDMDATASEG *PPDMDATASEG;
508/** Pointer to a const data transport segment. */
509typedef PDMDATASEG const *PCPDMDATASEG;
510
511/** @} */
512
513#endif
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