VirtualBox

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

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

The Giant CDDL Dual-License Header Change.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 15.7 KB
Line 
1/** @file
2 * VirtualBox - Types.
3 */
4
5/*
6 * Copyright (C) 2006-2007 innotek GmbH
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
26#ifndef ___VBox_types_h
27#define ___VBox_types_h
28
29#include <VBox/cdefs.h>
30#include <iprt/types.h>
31
32
33/** @defgroup grp_types Basic VBox Types
34 * @{
35 */
36
37
38/** @defgroup grp_types_both Common Guest and Host Context Basic Types
39 * @ingroup grp_types
40 * @{
41 */
42
43
44/** @defgroup grp_types_hc Host Context Basic Types
45 * @ingroup grp_types_both
46 * @{
47 */
48
49/** @deprecated
50 * @{ */
51typedef RTHCPHYS VBOXHCPHYS;
52typedef VBOXHCPHYS *PVBOXHCPHYS;
53#define NILVBOXHCPHYS NIL_RTHCPHYS
54typedef RTHCPTR VBOXHCPTR;
55typedef VBOXHCPTR *PVBOXHCPTR;
56/** @} */
57
58/** @} */
59
60
61/** @defgroup grp_types_gc Guest Context Basic Types
62 * @ingroup grp_types_both
63 * @{
64 */
65
66/** @deprecated
67 * @{ */
68typedef RTGCPHYS VBOXGCPHYS;
69typedef VBOXGCPHYS *PVBOXGCPHYS;
70#define NILVBOXGCPHYS NIL_RTGCPHYS
71typedef RTGCPTR VBOXGCPTR;
72typedef VBOXGCPTR *PVBOXGCPTR;
73/** @} */
74
75/** @} */
76
77
78/** Pointer to per support driver session data.
79 * (The data is a R0 entity and private to the the R0 SUP part. All
80 * other should consider this a sort of handle.) */
81typedef R0PTRTYPE(struct SUPDRVSESSION *) PSUPDRVSESSION;
82
83/** Pointer to a VM. */
84typedef struct VM *PVM;
85/** Pointer to a VM - Ring-0 Ptr. */
86typedef R0PTRTYPE(struct VM *) PVMR0;
87/** Pointer to a VM - Ring-3 Ptr. */
88typedef R3PTRTYPE(struct VM *) PVMR3;
89/** Pointer to a VM - GC Ptr. */
90typedef GCPTRTYPE(struct VM *) PVMGC;
91
92/** Pointer to a the ring-0 (global) VM structure. */
93typedef R0PTRTYPE(struct GVM *) PGVM;
94
95
96/** VM State
97 */
98typedef enum VMSTATE
99{
100 /** The VM is being created. */
101 VMSTATE_CREATING = 0,
102 /** The VM is created. */
103 VMSTATE_CREATED,
104 /** The VM is runnning. */
105 VMSTATE_RUNNING,
106 /** The VM state is being loaded from file. */
107 VMSTATE_LOADING,
108 /** The VM is screwed because of a failed state loading. */
109 VMSTATE_LOAD_FAILURE,
110 /** The VM state is being saved to file. */
111 VMSTATE_SAVING,
112 /** The VM is suspended. */
113 VMSTATE_SUSPENDED,
114 /** The VM is being reset. */
115 VMSTATE_RESETTING,
116 /** The VM is in guru meditation over a fatal failure. */
117 VMSTATE_GURU_MEDITATION,
118 /** The VM is switched off, awaiting destruction. */
119 VMSTATE_OFF,
120 /** The VM is being destroyed. */
121 VMSTATE_DESTROYING,
122 /** Terminated. */
123 VMSTATE_TERMINATED,
124 /** hack forcing the size of the enum to 32-bits. */
125 VMSTATE_MAKE_32BIT_HACK = 0x7fffffff
126} VMSTATE;
127
128
129/** Pointer to a PDM Driver Base Interface. */
130typedef struct PDMIBASE *PPDMIBASE;
131/** Pointer to a pointer to a PDM Driver Base Interface. */
132typedef PPDMIBASE *PPPDMIBASE;
133
134/** Pointer to a PDM Device Instance. */
135typedef struct PDMDEVINS *PPDMDEVINS;
136/** Pointer to a pointer to a PDM Device Instance. */
137typedef PPDMDEVINS *PPPDMDEVINS;
138/** R3 pointer to a PDM Device Instance. */
139typedef R3PTRTYPE(PPDMDEVINS) PPDMDEVINSR3;
140/** R0 pointer to a PDM Device Instance. */
141typedef R0PTRTYPE(PPDMDEVINS) PPDMDEVINSR0;
142/** GC pointer to a PDM Device Instance. */
143typedef GCPTRTYPE(PPDMDEVINS) PPDMDEVINSGC;
144
145/** Pointer to a PDM USB Device Instance. */
146typedef struct PDMUSBINS *PPDMUSBINS;
147/** Pointer to a pointer to a PDM USB Device Instance. */
148typedef PPDMUSBINS *PPPDMUSBINS;
149
150/** Pointer to a PDM Driver Instance. */
151typedef struct PDMDRVINS *PPDMDRVINS;
152/** Pointer to a pointer to a PDM Driver Instance. */
153typedef PPDMDRVINS *PPPDMDRVINS;
154
155/** Pointer to a PDM Service Instance. */
156typedef struct PDMSRVINS *PPDMSRVINS;
157/** Pointer to a pointer to a PDM Service Instance. */
158typedef PPDMSRVINS *PPPDMSRVINS;
159
160/** R3 pointer to a timer. */
161typedef R3PTRTYPE(struct TMTIMER *) PTMTIMERR3;
162/** Pointer to a R3 pointer to a timer. */
163typedef PTMTIMERR3 *PPTMTIMERR3;
164
165/** R0 pointer to a timer. */
166typedef R0PTRTYPE(struct TMTIMER *) PTMTIMERR0;
167/** Pointer to a R3 pointer to a timer. */
168typedef PTMTIMERR0 *PPTMTIMERR0;
169
170/** GC pointer to a timer. */
171typedef GCPTRTYPE(struct TMTIMER *) PTMTIMERGC;
172/** Pointer to a GC pointer to a timer. */
173typedef PTMTIMERGC *PPTMTIMERGC;
174
175/** Pointer to a timer. */
176typedef CTXALLSUFF(PTMTIMER) PTMTIMER;
177/** Pointer to a pointer to a timer. */
178typedef CTXALLSUFF(PPTMTIMER) PPTMTIMER;
179
180/** SSM Operation handle. */
181typedef struct SSMHANDLE *PSSMHANDLE;
182
183/** @} */
184
185
186/** @defgroup grp_types_idt Interrupt Descriptor Table Entry.
187 * @ingroup grp_types
188 * @todo This all belongs in x86.h!
189 * @{ */
190
191/** @todo VBOXIDT -> VBOXDESCIDT, skip the complex variations. We'll never use them. */
192
193/** IDT Entry, Task Gate view. */
194#pragma pack(1) /* paranoia */
195typedef struct VBOXIDTE_TASKGATE
196{
197 /** Reserved. */
198 unsigned u16Reserved1 : 16;
199 /** Task Segment Selector. */
200 unsigned u16TSS : 16;
201 /** More reserved. */
202 unsigned u8Reserved2 : 8;
203 /** Fixed value bit 0 - Set to 1. */
204 unsigned u1Fixed0 : 1;
205 /** Busy bit. */
206 unsigned u1Busy : 1;
207 /** Fixed value bit 2 - Set to 1. */
208 unsigned u1Fixed1 : 1;
209 /** Fixed value bit 3 - Set to 0. */
210 unsigned u1Fixed2: 1;
211 /** Fixed value bit 4 - Set to 0. */
212 unsigned u1Fixed3 : 1;
213 /** Descriptor Privilege level. */
214 unsigned u2DPL : 2;
215 /** Present flag. */
216 unsigned u1Present : 1;
217 /** Reserved. */
218 unsigned u16Reserved3 : 16;
219} VBOXIDTE_TASKGATE;
220#pragma pack()
221/** Pointer to IDT Entry, Task gate view. */
222typedef VBOXIDTE_TASKGATE *PVBOXIDTE_TASKGATE;
223
224
225/** IDT Entry, Intertupt gate view. */
226#pragma pack(1) /* paranoia */
227typedef struct VBOXIDTE_INTERRUPTGATE
228{
229 /** Low offset word. */
230 unsigned u16OffsetLow : 16;
231 /** Segment Selector. */
232 unsigned u16SegSel : 16;
233 /** Reserved. */
234 unsigned u5Reserved2 : 5;
235 /** Fixed value bit 0 - Set to 0. */
236 unsigned u1Fixed0 : 1;
237 /** Fixed value bit 1 - Set to 0. */
238 unsigned u1Fixed1 : 1;
239 /** Fixed value bit 2 - Set to 0. */
240 unsigned u1Fixed2 : 1;
241 /** Fixed value bit 3 - Set to 0. */
242 unsigned u1Fixed3: 1;
243 /** Fixed value bit 4 - Set to 1. */
244 unsigned u1Fixed4 : 1;
245 /** Fixed value bit 5 - Set to 1. */
246 unsigned u1Fixed5 : 1;
247 /** Gate size, 1 = 32 bits, 0 = 16 bits. */
248 unsigned u132BitGate : 1;
249 /** Fixed value bit 5 - Set to 0. */
250 unsigned u1Fixed6 : 1;
251 /** Descriptor Privilege level. */
252 unsigned u2DPL : 2;
253 /** Present flag. */
254 unsigned u1Present : 1;
255 /** High offset word. */
256 unsigned u16OffsetHigh : 16;
257} VBOXIDTE_INTERRUPTGATE;
258#pragma pack()
259/** Pointer to IDT Entry, Interrupt gate view. */
260typedef VBOXIDTE_INTERRUPTGATE *PVBOXIDTE_INTERRUPTGATE;
261
262/** IDT Entry, Trap Gate view. */
263#pragma pack(1) /* paranoia */
264typedef struct VBOXIDTE_TRAPGATE
265{
266 /** Low offset word. */
267 unsigned u16OffsetLow : 16;
268 /** Segment Selector. */
269 unsigned u16SegSel : 16;
270 /** Reserved. */
271 unsigned u5Reserved2 : 5;
272 /** Fixed value bit 0 - Set to 0. */
273 unsigned u1Fixed0 : 1;
274 /** Fixed value bit 1 - Set to 0. */
275 unsigned u1Fixed1 : 1;
276 /** Fixed value bit 2 - Set to 0. */
277 unsigned u1Fixed2 : 1;
278 /** Fixed value bit 3 - Set to 1. */
279 unsigned u1Fixed3: 1;
280 /** Fixed value bit 4 - Set to 1. */
281 unsigned u1Fixed4 : 1;
282 /** Fixed value bit 5 - Set to 1. */
283 unsigned u1Fixed5 : 1;
284 /** Gate size, 1 = 32 bits, 0 = 16 bits. */
285 unsigned u132BitGate : 1;
286 /** Fixed value bit 5 - Set to 0. */
287 unsigned u1Fixed6 : 1;
288 /** Descriptor Privilege level. */
289 unsigned u2DPL : 2;
290 /** Present flag. */
291 unsigned u1Present : 1;
292 /** High offset word. */
293 unsigned u16OffsetHigh : 16;
294} VBOXIDTE_TRAPGATE;
295#pragma pack()
296/** Pointer to IDT Entry, Trap Gate view. */
297typedef VBOXIDTE_TRAPGATE *PVBOXIDTE_TRAPGATE;
298
299/** IDT Entry Generic view. */
300#pragma pack(1) /* paranoia */
301typedef struct VBOXIDTE_GENERIC
302{
303 /** Low offset word. */
304 unsigned u16OffsetLow : 16;
305 /** Segment Selector. */
306 unsigned u16SegSel : 16;
307 /** Reserved. */
308 unsigned u5Reserved : 5;
309 /** IDT Type part one (not used for task gate). */
310 unsigned u3Type1 : 3;
311 /** IDT Type part two. */
312 unsigned u5Type2 : 5;
313 /** Descriptor Privilege level. */
314 unsigned u2DPL : 2;
315 /** Present flag. */
316 unsigned u1Present : 1;
317 /** High offset word. */
318 unsigned u16OffsetHigh : 16;
319} VBOXIDTE_GENERIC;
320#pragma pack()
321/** Pointer to IDT Entry Generic view. */
322typedef VBOXIDTE_GENERIC *PVBOXIDTE_GENERIC;
323
324/** IDT Type1 value. (Reserved for task gate!) */
325#define VBOX_IDTE_TYPE1 0
326/** IDT Type2 value - Task gate. */
327#define VBOX_IDTE_TYPE2_TASK 0x5
328/** IDT Type2 value - 16 bit interrupt gate. */
329#define VBOX_IDTE_TYPE2_INT_16 0x6
330/** IDT Type2 value - 32 bit interrupt gate. */
331#define VBOX_IDTE_TYPE2_INT_32 0xe
332/** IDT Type2 value - 16 bit trap gate. */
333#define VBOX_IDTE_TYPE2_TRAP_16 0x7
334/** IDT Type2 value - 32 bit trap gate. */
335#define VBOX_IDTE_TYPE2_TRAP_32 0xf
336
337/** IDT Entry. */
338#pragma pack(1) /* paranoia */
339typedef union VBOXIDTE
340{
341 /** Task gate view. */
342 VBOXIDTE_TASKGATE Task;
343 /** Trap gate view. */
344 VBOXIDTE_TRAPGATE Trap;
345 /** Interrupt gate view. */
346 VBOXIDTE_INTERRUPTGATE Int;
347 /** Generic IDT view. */
348 VBOXIDTE_GENERIC Gen;
349
350 /** 8 bit unsigned integer view. */
351 uint8_t au8[8];
352 /** 16 bit unsigned integer view. */
353 uint16_t au16[4];
354 /** 32 bit unsigned integer view. */
355 uint32_t au32[2];
356 /** 64 bit unsigned integer view. */
357 uint64_t au64;
358} VBOXIDTE;
359#pragma pack()
360/** Pointer to IDT Entry. */
361typedef VBOXIDTE *PVBOXIDTE;
362
363#pragma pack(1)
364/** IDTR */
365typedef struct VBOXIDTR
366{
367 /** Size of the IDT. */
368 uint16_t cbIdt;
369 /** Address of the IDT. */
370 uint32_t pIdt;
371} VBOXIDTR, *PVBOXIDTR;
372#pragma pack()
373/** @} */
374
375
376/** @defgroup grp_types_desc Descriptor Table Entry.
377 * @ingroup grp_types
378 * @{ */
379
380#pragma pack(1)
381/**
382 * Memory descriptor.
383 */
384typedef struct VBOXDESCGENERIC
385{
386 /** 0-15 - Limit - Low word. */
387 unsigned u16LimitLow : 16;
388 /** 16-31 - Base address - lowe word.
389 * Don't try set this to 24 because MSC is doing studing things then. */
390 unsigned u16BaseLow : 16;
391 /** 32-39 - Base address - first 8 bits of high word. */
392 unsigned u8BaseHigh1 : 8;
393 /** 40-43 - Segment Type. */
394 unsigned u4Type : 4;
395 /** 44 - Descriptor Type. System(=0) or code/data selector */
396 unsigned u1DescType : 1;
397 /** 45-46 - Descriptor Privelege level. */
398 unsigned u2Dpl : 2;
399 /** 47 - Flags selector present(=1) or not. */
400 unsigned u1Present : 1;
401 /** 48-51 - Segment limit 16-19. */
402 unsigned u4LimitHigh : 4;
403 /** 52 - Available for system software. */
404 unsigned u1Available : 1;
405 /** 53 - Reserved - 0. In long mode this is the 'Long' (L) attribute bit. */
406 unsigned u1Reserved : 1;
407 /** 54 - This flags meaning depends on the segment type. Try make sense out
408 * of the intel manual yourself. */
409 unsigned u1DefBig : 1;
410 /** 55 - Granularity of the limit. If set 4KB granularity is used, if
411 * clear byte. */
412 unsigned u1Granularity : 1;
413 /** 56-63 - Base address - highest 8 bits. */
414 unsigned u8BaseHigh2 : 8;
415} VBOXDESCGENERIC;
416#pragma pack()
417/** Pointer to a generic descriptor entry. */
418typedef VBOXDESCGENERIC *PVBOXDESCGENERIC;
419
420#pragma pack(1)
421/**
422 * Descriptor table entry.
423 */
424typedef union VBOXDESC
425{
426 /** Generic descriptor view. */
427 VBOXDESCGENERIC Gen;
428 /** IDT view. */
429 VBOXIDTE Idt;
430
431 /** 8 bit unsigned interger view. */
432 uint8_t au8[8];
433 /** 16 bit unsigned interger view. */
434 uint16_t au16[4];
435 /** 32 bit unsigned interger view. */
436 uint32_t au32[2];
437} VBOXDESC;
438#pragma pack()
439/** Pointer to descriptor table entry. */
440typedef VBOXDESC *PVBOXDESC;
441/** Pointer to const descriptor table entry. */
442typedef VBOXDESC const *PCVBOXDESC;
443
444
445#pragma pack(1)
446/** GDTR */
447typedef struct VBOXGDTR
448{
449 /** Size of the GDT. */
450 uint16_t cbGdt;
451 /** Address of the GDT. */
452 uint32_t pGdt;
453} VBOXGDTR;
454#pragma pack()
455/** Pointer to GDTR. */
456typedef VBOXGDTR *PVBOXGDTR;
457
458/** @} */
459
460
461/** @defgroup grp_types_pg Page Structures
462 * @ingroup grp_types
463 * @{
464 */
465
466/** These absolete / belong to PGM. Use VBox/x86.h structs everywhere else. */
467#define VBOXPTE X86PTE
468#define PVBOXPTE PX86PTE
469#define VBOXPT X86PT
470#define PVBOXPT PX86PT
471#define VBOXPDE X86PDE
472#define PVBOXPDE PX86PDE
473#define VBOXPD X86PD
474#define PVBOXPD PX86PD
475
476/** @} */
477
478
479
480/**
481 * Task Segment
482 */
483#pragma pack(1)
484typedef struct VBOXTSS
485{
486 /** Back link to previous task. (static) */
487 RTSEL selPrev;
488 uint16_t padding1;
489 /** Ring-0 stack pointer. (static) */
490 uint32_t esp0;
491 /** Ring-0 stack segment. (static) */
492 RTSEL ss0;
493 uint16_t padding_ss0;
494 /** Ring-1 stack pointer. (static) */
495 uint32_t esp1;
496 /** Ring-1 stack segment. (static) */
497 RTSEL ss1;
498 uint16_t padding_ss1;
499 /** Ring-2 stack pointer. (static) */
500 uint32_t esp2;
501 /** Ring-2 stack segment. (static) */
502 RTSEL ss2;
503 uint16_t padding_ss2;
504 /** Page directory for the task. (static) */
505 uint32_t cr3;
506 /** EIP before task switch. */
507 uint32_t eip;
508 /** EFLAGS before task switch. */
509 uint32_t eflags;
510 /** EAX before task switch. */
511 uint32_t eax;
512 /** ECX before task switch. */
513 uint32_t ecx;
514 /** EDX before task switch. */
515 uint32_t edx;
516 /** EBX before task switch. */
517 uint32_t ebx;
518 /** ESP before task switch. */
519 uint32_t esp;
520 /** EBP before task switch. */
521 uint32_t ebp;
522 /** ESI before task switch. */
523 uint32_t esi;
524 /** EDI before task switch. */
525 uint32_t edi;
526 /** ES before task switch. */
527 RTSEL es;
528 uint16_t padding_es;
529 /** CS before task switch. */
530 RTSEL cs;
531 uint16_t padding_cs;
532 /** SS before task switch. */
533 RTSEL ss;
534 uint16_t padding_ss;
535 /** DS before task switch. */
536 RTSEL ds;
537 uint16_t padding_ds;
538 /** FS before task switch. */
539 RTSEL fs;
540 uint16_t padding_fs;
541 /** GS before task switch. */
542 RTSEL gs;
543 uint16_t padding_gs;
544 /** LDTR before task switch. */
545 RTSEL selLdt;
546 uint16_t padding_ldt;
547 /** Debug trap flag */
548 uint16_t fDebugTrap;
549 /** Offset relative to the TSS of the start of the I/O Bitmap
550 * and the end of the interrupt redirection bitmap. */
551 uint16_t offIoBitmap;
552 /** 32 bytes for the virtual interrupt redirection bitmap. (VME) */
553 uint8_t IntRedirBitmap[32];
554} VBOXTSS;
555#pragma pack()
556/** Pointer to task segment. */
557typedef VBOXTSS *PVBOXTSS;
558/** Pointer to const task segment. */
559typedef const VBOXTSS *PCVBOXTSS;
560
561
562/** @} */
563
564#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