VirtualBox

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

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

Fixed init problems wrt. VM ownership by implementing the UVM structure (U = user mode) and moving problematic ring-3 stuff over there (emt+reqs, r3heap, stam, loader[VMMR0.r0]). Big change, but it works fine here... :-)

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