VirtualBox

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

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

Make our devices use the RTGCPHYS32 type & backed out the alignment changes
Added SSMR3PutGCPhys32 & SSMR3GetGCPhys32
Removed obsolete VBOX types

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 15.6 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/** @} */
178
179
180/** @defgroup grp_types_idt Interrupt Descriptor Table Entry.
181 * @ingroup grp_types
182 * @todo This all belongs in x86.h!
183 * @{ */
184
185/** @todo VBOXIDT -> VBOXDESCIDT, skip the complex variations. We'll never use them. */
186
187/** IDT Entry, Task Gate view. */
188#pragma pack(1) /* paranoia */
189typedef struct VBOXIDTE_TASKGATE
190{
191 /** Reserved. */
192 unsigned u16Reserved1 : 16;
193 /** Task Segment Selector. */
194 unsigned u16TSS : 16;
195 /** More reserved. */
196 unsigned u8Reserved2 : 8;
197 /** Fixed value bit 0 - Set to 1. */
198 unsigned u1Fixed0 : 1;
199 /** Busy bit. */
200 unsigned u1Busy : 1;
201 /** Fixed value bit 2 - Set to 1. */
202 unsigned u1Fixed1 : 1;
203 /** Fixed value bit 3 - Set to 0. */
204 unsigned u1Fixed2: 1;
205 /** Fixed value bit 4 - Set to 0. */
206 unsigned u1Fixed3 : 1;
207 /** Descriptor Privilege level. */
208 unsigned u2DPL : 2;
209 /** Present flag. */
210 unsigned u1Present : 1;
211 /** Reserved. */
212 unsigned u16Reserved3 : 16;
213} VBOXIDTE_TASKGATE;
214#pragma pack()
215/** Pointer to IDT Entry, Task gate view. */
216typedef VBOXIDTE_TASKGATE *PVBOXIDTE_TASKGATE;
217
218
219/** IDT Entry, Intertupt gate view. */
220#pragma pack(1) /* paranoia */
221typedef struct VBOXIDTE_INTERRUPTGATE
222{
223 /** Low offset word. */
224 unsigned u16OffsetLow : 16;
225 /** Segment Selector. */
226 unsigned u16SegSel : 16;
227 /** Reserved. */
228 unsigned u5Reserved2 : 5;
229 /** Fixed value bit 0 - Set to 0. */
230 unsigned u1Fixed0 : 1;
231 /** Fixed value bit 1 - Set to 0. */
232 unsigned u1Fixed1 : 1;
233 /** Fixed value bit 2 - Set to 0. */
234 unsigned u1Fixed2 : 1;
235 /** Fixed value bit 3 - Set to 0. */
236 unsigned u1Fixed3: 1;
237 /** Fixed value bit 4 - Set to 1. */
238 unsigned u1Fixed4 : 1;
239 /** Fixed value bit 5 - Set to 1. */
240 unsigned u1Fixed5 : 1;
241 /** Gate size, 1 = 32 bits, 0 = 16 bits. */
242 unsigned u132BitGate : 1;
243 /** Fixed value bit 5 - Set to 0. */
244 unsigned u1Fixed6 : 1;
245 /** Descriptor Privilege level. */
246 unsigned u2DPL : 2;
247 /** Present flag. */
248 unsigned u1Present : 1;
249 /** High offset word. */
250 unsigned u16OffsetHigh : 16;
251} VBOXIDTE_INTERRUPTGATE;
252#pragma pack()
253/** Pointer to IDT Entry, Interrupt gate view. */
254typedef VBOXIDTE_INTERRUPTGATE *PVBOXIDTE_INTERRUPTGATE;
255
256/** IDT Entry, Trap Gate view. */
257#pragma pack(1) /* paranoia */
258typedef struct VBOXIDTE_TRAPGATE
259{
260 /** Low offset word. */
261 unsigned u16OffsetLow : 16;
262 /** Segment Selector. */
263 unsigned u16SegSel : 16;
264 /** Reserved. */
265 unsigned u5Reserved2 : 5;
266 /** Fixed value bit 0 - Set to 0. */
267 unsigned u1Fixed0 : 1;
268 /** Fixed value bit 1 - Set to 0. */
269 unsigned u1Fixed1 : 1;
270 /** Fixed value bit 2 - Set to 0. */
271 unsigned u1Fixed2 : 1;
272 /** Fixed value bit 3 - Set to 1. */
273 unsigned u1Fixed3: 1;
274 /** Fixed value bit 4 - Set to 1. */
275 unsigned u1Fixed4 : 1;
276 /** Fixed value bit 5 - Set to 1. */
277 unsigned u1Fixed5 : 1;
278 /** Gate size, 1 = 32 bits, 0 = 16 bits. */
279 unsigned u132BitGate : 1;
280 /** Fixed value bit 5 - Set to 0. */
281 unsigned u1Fixed6 : 1;
282 /** Descriptor Privilege level. */
283 unsigned u2DPL : 2;
284 /** Present flag. */
285 unsigned u1Present : 1;
286 /** High offset word. */
287 unsigned u16OffsetHigh : 16;
288} VBOXIDTE_TRAPGATE;
289#pragma pack()
290/** Pointer to IDT Entry, Trap Gate view. */
291typedef VBOXIDTE_TRAPGATE *PVBOXIDTE_TRAPGATE;
292
293/** IDT Entry Generic view. */
294#pragma pack(1) /* paranoia */
295typedef struct VBOXIDTE_GENERIC
296{
297 /** Low offset word. */
298 unsigned u16OffsetLow : 16;
299 /** Segment Selector. */
300 unsigned u16SegSel : 16;
301 /** Reserved. */
302 unsigned u5Reserved : 5;
303 /** IDT Type part one (not used for task gate). */
304 unsigned u3Type1 : 3;
305 /** IDT Type part two. */
306 unsigned u5Type2 : 5;
307 /** Descriptor Privilege level. */
308 unsigned u2DPL : 2;
309 /** Present flag. */
310 unsigned u1Present : 1;
311 /** High offset word. */
312 unsigned u16OffsetHigh : 16;
313} VBOXIDTE_GENERIC;
314#pragma pack()
315/** Pointer to IDT Entry Generic view. */
316typedef VBOXIDTE_GENERIC *PVBOXIDTE_GENERIC;
317
318/** IDT Type1 value. (Reserved for task gate!) */
319#define VBOX_IDTE_TYPE1 0
320/** IDT Type2 value - Task gate. */
321#define VBOX_IDTE_TYPE2_TASK 0x5
322/** IDT Type2 value - 16 bit interrupt gate. */
323#define VBOX_IDTE_TYPE2_INT_16 0x6
324/** IDT Type2 value - 32 bit interrupt gate. */
325#define VBOX_IDTE_TYPE2_INT_32 0xe
326/** IDT Type2 value - 16 bit trap gate. */
327#define VBOX_IDTE_TYPE2_TRAP_16 0x7
328/** IDT Type2 value - 32 bit trap gate. */
329#define VBOX_IDTE_TYPE2_TRAP_32 0xf
330
331/** IDT Entry. */
332#pragma pack(1) /* paranoia */
333typedef union VBOXIDTE
334{
335 /** Task gate view. */
336 VBOXIDTE_TASKGATE Task;
337 /** Trap gate view. */
338 VBOXIDTE_TRAPGATE Trap;
339 /** Interrupt gate view. */
340 VBOXIDTE_INTERRUPTGATE Int;
341 /** Generic IDT view. */
342 VBOXIDTE_GENERIC Gen;
343
344 /** 8 bit unsigned integer view. */
345 uint8_t au8[8];
346 /** 16 bit unsigned integer view. */
347 uint16_t au16[4];
348 /** 32 bit unsigned integer view. */
349 uint32_t au32[2];
350 /** 64 bit unsigned integer view. */
351 uint64_t au64;
352} VBOXIDTE;
353#pragma pack()
354/** Pointer to IDT Entry. */
355typedef VBOXIDTE *PVBOXIDTE;
356
357#pragma pack(1)
358/** IDTR */
359typedef struct VBOXIDTR
360{
361 /** Size of the IDT. */
362 uint16_t cbIdt;
363 /** Address of the IDT. */
364 uint32_t pIdt;
365} VBOXIDTR, *PVBOXIDTR;
366#pragma pack()
367/** @} */
368
369
370/** @defgroup grp_types_desc Descriptor Table Entry.
371 * @ingroup grp_types
372 * @{ */
373
374#pragma pack(1)
375/**
376 * Memory descriptor.
377 */
378typedef struct VBOXDESCGENERIC
379{
380 /** 0-15 - Limit - Low word. */
381 unsigned u16LimitLow : 16;
382 /** 16-31 - Base address - lowe word.
383 * Don't try set this to 24 because MSC is doing studing things then. */
384 unsigned u16BaseLow : 16;
385 /** 32-39 - Base address - first 8 bits of high word. */
386 unsigned u8BaseHigh1 : 8;
387 /** 40-43 - Segment Type. */
388 unsigned u4Type : 4;
389 /** 44 - Descriptor Type. System(=0) or code/data selector */
390 unsigned u1DescType : 1;
391 /** 45-46 - Descriptor Privelege level. */
392 unsigned u2Dpl : 2;
393 /** 47 - Flags selector present(=1) or not. */
394 unsigned u1Present : 1;
395 /** 48-51 - Segment limit 16-19. */
396 unsigned u4LimitHigh : 4;
397 /** 52 - Available for system software. */
398 unsigned u1Available : 1;
399 /** 53 - Reserved - 0. In long mode this is the 'Long' (L) attribute bit. */
400 unsigned u1Reserved : 1;
401 /** 54 - This flags meaning depends on the segment type. Try make sense out
402 * of the intel manual yourself. */
403 unsigned u1DefBig : 1;
404 /** 55 - Granularity of the limit. If set 4KB granularity is used, if
405 * clear byte. */
406 unsigned u1Granularity : 1;
407 /** 56-63 - Base address - highest 8 bits. */
408 unsigned u8BaseHigh2 : 8;
409} VBOXDESCGENERIC;
410#pragma pack()
411/** Pointer to a generic descriptor entry. */
412typedef VBOXDESCGENERIC *PVBOXDESCGENERIC;
413
414#pragma pack(1)
415/**
416 * Descriptor table entry.
417 */
418typedef union VBOXDESC
419{
420 /** Generic descriptor view. */
421 VBOXDESCGENERIC Gen;
422 /** IDT view. */
423 VBOXIDTE Idt;
424
425 /** 8 bit unsigned interger view. */
426 uint8_t au8[8];
427 /** 16 bit unsigned interger view. */
428 uint16_t au16[4];
429 /** 32 bit unsigned interger view. */
430 uint32_t au32[2];
431} VBOXDESC;
432#pragma pack()
433/** Pointer to descriptor table entry. */
434typedef VBOXDESC *PVBOXDESC;
435/** Pointer to const descriptor table entry. */
436typedef VBOXDESC const *PCVBOXDESC;
437
438
439#pragma pack(1)
440/** GDTR */
441typedef struct VBOXGDTR
442{
443 /** Size of the GDT. */
444 uint16_t cbGdt;
445 /** Address of the GDT. */
446 uint32_t pGdt;
447} VBOXGDTR;
448#pragma pack()
449/** Pointer to GDTR. */
450typedef VBOXGDTR *PVBOXGDTR;
451
452/** @} */
453
454
455/** @defgroup grp_types_pg Page Structures
456 * @ingroup grp_types
457 * @{
458 */
459
460/** These absolete / belong to PGM. Use VBox/x86.h structs everywhere else. */
461#define VBOXPTE X86PTE
462#define PVBOXPTE PX86PTE
463#define VBOXPT X86PT
464#define PVBOXPT PX86PT
465#define VBOXPDE X86PDE
466#define PVBOXPDE PX86PDE
467#define VBOXPD X86PD
468#define PVBOXPD PX86PD
469
470/** @} */
471
472
473
474/**
475 * Task Segment
476 */
477#pragma pack(1)
478typedef struct VBOXTSS
479{
480 /** Back link to previous task. (static) */
481 RTSEL selPrev;
482 uint16_t padding1;
483 /** Ring-0 stack pointer. (static) */
484 uint32_t esp0;
485 /** Ring-0 stack segment. (static) */
486 RTSEL ss0;
487 uint16_t padding_ss0;
488 /** Ring-1 stack pointer. (static) */
489 uint32_t esp1;
490 /** Ring-1 stack segment. (static) */
491 RTSEL ss1;
492 uint16_t padding_ss1;
493 /** Ring-2 stack pointer. (static) */
494 uint32_t esp2;
495 /** Ring-2 stack segment. (static) */
496 RTSEL ss2;
497 uint16_t padding_ss2;
498 /** Page directory for the task. (static) */
499 uint32_t cr3;
500 /** EIP before task switch. */
501 uint32_t eip;
502 /** EFLAGS before task switch. */
503 uint32_t eflags;
504 /** EAX before task switch. */
505 uint32_t eax;
506 /** ECX before task switch. */
507 uint32_t ecx;
508 /** EDX before task switch. */
509 uint32_t edx;
510 /** EBX before task switch. */
511 uint32_t ebx;
512 /** ESP before task switch. */
513 uint32_t esp;
514 /** EBP before task switch. */
515 uint32_t ebp;
516 /** ESI before task switch. */
517 uint32_t esi;
518 /** EDI before task switch. */
519 uint32_t edi;
520 /** ES before task switch. */
521 RTSEL es;
522 uint16_t padding_es;
523 /** CS before task switch. */
524 RTSEL cs;
525 uint16_t padding_cs;
526 /** SS before task switch. */
527 RTSEL ss;
528 uint16_t padding_ss;
529 /** DS before task switch. */
530 RTSEL ds;
531 uint16_t padding_ds;
532 /** FS before task switch. */
533 RTSEL fs;
534 uint16_t padding_fs;
535 /** GS before task switch. */
536 RTSEL gs;
537 uint16_t padding_gs;
538 /** LDTR before task switch. */
539 RTSEL selLdt;
540 uint16_t padding_ldt;
541 /** Debug trap flag */
542 uint16_t fDebugTrap;
543 /** Offset relative to the TSS of the start of the I/O Bitmap
544 * and the end of the interrupt redirection bitmap. */
545 uint16_t offIoBitmap;
546 /** 32 bytes for the virtual interrupt redirection bitmap. (VME) */
547 uint8_t IntRedirBitmap[32];
548} VBOXTSS;
549#pragma pack()
550/** Pointer to task segment. */
551typedef VBOXTSS *PVBOXTSS;
552/** Pointer to const task segment. */
553typedef const VBOXTSS *PCVBOXTSS;
554
555
556/** @} */
557
558#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