VirtualBox

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

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

Finally splitting up pdm.h. Working on integrating USB into PDM (USBProxy needs CFGM stuff).

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