VirtualBox

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

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

Initial cleanup for PAE

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