VirtualBox

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

Last change on this file since 11052 was 10963, checked in by vboxsync, 16 years ago

types: Merged PDMMAC and RTNETMAC into RTMAC.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 14.6 KB
Line 
1/** @file
2 * VirtualBox - Types.
3 */
4
5/*
6 * Copyright (C) 2006-2007 Sun Microsystems, Inc.
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 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
26 * Clara, CA 95054 USA or visit http://www.sun.com if you need
27 * additional information or have any questions.
28 */
29
30#ifndef ___VBox_types_h
31#define ___VBox_types_h
32
33#include <VBox/cdefs.h>
34#include <iprt/types.h>
35
36
37/** @defgroup grp_types Basic VBox Types
38 * @{
39 */
40
41
42/** @defgroup grp_types_both Common Guest and Host Context Basic Types
43 * @ingroup grp_types
44 * @{
45 */
46
47
48/** @defgroup grp_types_hc Host Context Basic Types
49 * @ingroup grp_types_both
50 * @{
51 */
52
53/** @deprecated
54 * @{ */
55typedef RTHCPHYS VBOXHCPHYS;
56typedef VBOXHCPHYS *PVBOXHCPHYS;
57#define NILVBOXHCPHYS NIL_RTHCPHYS
58typedef RTHCPTR VBOXHCPTR;
59typedef VBOXHCPTR *PVBOXHCPTR;
60/** @} */
61
62/** @} */
63
64
65/** @defgroup grp_types_gc Guest Context Basic Types
66 * @ingroup grp_types_both
67 * @{
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 - RC Ptr. */
85typedef RCPTRTYPE(struct VM *) PVMRC;
86
87/** Pointer to a ring-0 (global) VM structure. */
88typedef R0PTRTYPE(struct GVM *) PGVM;
89
90/** Pointer to a ring-3 (user mode) VM structure. */
91typedef R3PTRTYPE(struct UVM *) PUVM;
92
93
94/** VM State
95 */
96typedef enum VMSTATE
97{
98 /** The VM is being created. */
99 VMSTATE_CREATING = 0,
100 /** The VM is created. */
101 VMSTATE_CREATED,
102 /** The VM is runnning. */
103 VMSTATE_RUNNING,
104 /** The VM state is being loaded from file. */
105 VMSTATE_LOADING,
106 /** The VM is screwed because of a failed state loading. */
107 VMSTATE_LOAD_FAILURE,
108 /** The VM state is being saved to file. */
109 VMSTATE_SAVING,
110 /** The VM is suspended. */
111 VMSTATE_SUSPENDED,
112 /** The VM is being reset. */
113 VMSTATE_RESETTING,
114 /** The VM is in guru meditation over a fatal failure. */
115 VMSTATE_GURU_MEDITATION,
116 /** The VM is switched off, awaiting destruction. */
117 VMSTATE_OFF,
118 /** The VM is being destroyed. */
119 VMSTATE_DESTROYING,
120 /** Terminated. */
121 VMSTATE_TERMINATED,
122 /** hack forcing the size of the enum to 32-bits. */
123 VMSTATE_MAKE_32BIT_HACK = 0x7fffffff
124} VMSTATE;
125
126
127/** Pointer to a PDM Driver Base Interface. */
128typedef struct PDMIBASE *PPDMIBASE;
129/** Pointer to a pointer to a PDM Driver Base Interface. */
130typedef PPDMIBASE *PPPDMIBASE;
131
132/** Pointer to a PDM Device Instance. */
133typedef struct PDMDEVINS *PPDMDEVINS;
134/** Pointer to a pointer to a PDM Device Instance. */
135typedef PPDMDEVINS *PPPDMDEVINS;
136/** R3 pointer to a PDM Device Instance. */
137typedef R3PTRTYPE(PPDMDEVINS) PPDMDEVINSR3;
138/** R0 pointer to a PDM Device Instance. */
139typedef R0PTRTYPE(PPDMDEVINS) PPDMDEVINSR0;
140/** GC pointer to a PDM Device Instance. */
141typedef RCPTRTYPE(PPDMDEVINS) PPDMDEVINSGC;
142
143/** Pointer to a PDM USB Device Instance. */
144typedef struct PDMUSBINS *PPDMUSBINS;
145/** Pointer to a pointer to a PDM USB Device Instance. */
146typedef PPDMUSBINS *PPPDMUSBINS;
147
148/** Pointer to a PDM Driver Instance. */
149typedef struct PDMDRVINS *PPDMDRVINS;
150/** Pointer to a pointer to a PDM Driver Instance. */
151typedef PPDMDRVINS *PPPDMDRVINS;
152
153/** Pointer to a PDM Service Instance. */
154typedef struct PDMSRVINS *PPDMSRVINS;
155/** Pointer to a pointer to a PDM Service Instance. */
156typedef PPDMSRVINS *PPPDMSRVINS;
157
158/** R3 pointer to a timer. */
159typedef R3PTRTYPE(struct TMTIMER *) PTMTIMERR3;
160/** Pointer to a R3 pointer to a timer. */
161typedef PTMTIMERR3 *PPTMTIMERR3;
162
163/** R0 pointer to a timer. */
164typedef R0PTRTYPE(struct TMTIMER *) PTMTIMERR0;
165/** Pointer to a R3 pointer to a timer. */
166typedef PTMTIMERR0 *PPTMTIMERR0;
167
168/** GC pointer to a timer. */
169typedef RCPTRTYPE(struct TMTIMER *) PTMTIMERGC;
170/** Pointer to a GC pointer to a timer. */
171typedef PTMTIMERGC *PPTMTIMERGC;
172
173/** Pointer to a timer. */
174typedef CTXALLSUFF(PTMTIMER) PTMTIMER;
175/** Pointer to a pointer to a timer. */
176typedef CTXALLSUFF(PPTMTIMER) PPTMTIMER;
177
178/** SSM Operation handle. */
179typedef struct SSMHANDLE *PSSMHANDLE;
180
181/** Pointer to a CPUMCTX. */
182typedef struct CPUMCTX *PCPUMCTX;
183/** Pointer to a const CPUMCTX. */
184typedef const struct CPUMCTX *PCCPUMCTX;
185
186/** Pointer to a CPU context core. */
187typedef struct CPUMCTXCORE *PCPUMCTXCORE;
188/** Pointer to a const CPU context core. */
189typedef const struct CPUMCTXCORE *PCCPUMCTXCORE;
190
191/** Pointer to selector hidden registers. */
192typedef struct CPUMSELREGHID *PCPUMSELREGHID;
193/** Pointer to const selector hidden registers. */
194typedef const struct CPUMSELREGHID *PCCPUMSELREGHID;
195
196/** @} */
197
198
199/** @defgroup grp_types_idt Interrupt Descriptor Table Entry.
200 * @ingroup grp_types
201 * @todo This all belongs in x86.h!
202 * @{ */
203
204/** @todo VBOXIDT -> VBOXDESCIDT, skip the complex variations. We'll never use them. */
205
206/** IDT Entry, Task Gate view. */
207#pragma pack(1) /* paranoia */
208typedef struct VBOXIDTE_TASKGATE
209{
210 /** Reserved. */
211 unsigned u16Reserved1 : 16;
212 /** Task Segment Selector. */
213 unsigned u16TSS : 16;
214 /** More reserved. */
215 unsigned u8Reserved2 : 8;
216 /** Fixed value bit 0 - Set to 1. */
217 unsigned u1Fixed0 : 1;
218 /** Busy bit. */
219 unsigned u1Busy : 1;
220 /** Fixed value bit 2 - Set to 1. */
221 unsigned u1Fixed1 : 1;
222 /** Fixed value bit 3 - Set to 0. */
223 unsigned u1Fixed2: 1;
224 /** Fixed value bit 4 - Set to 0. */
225 unsigned u1Fixed3 : 1;
226 /** Descriptor Privilege level. */
227 unsigned u2DPL : 2;
228 /** Present flag. */
229 unsigned u1Present : 1;
230 /** Reserved. */
231 unsigned u16Reserved3 : 16;
232} VBOXIDTE_TASKGATE;
233#pragma pack()
234/** Pointer to IDT Entry, Task gate view. */
235typedef VBOXIDTE_TASKGATE *PVBOXIDTE_TASKGATE;
236
237
238/** IDT Entry, Intertupt gate view. */
239#pragma pack(1) /* paranoia */
240typedef struct VBOXIDTE_INTERRUPTGATE
241{
242 /** Low offset word. */
243 unsigned u16OffsetLow : 16;
244 /** Segment Selector. */
245 unsigned u16SegSel : 16;
246 /** Reserved. */
247 unsigned u5Reserved2 : 5;
248 /** Fixed value bit 0 - Set to 0. */
249 unsigned u1Fixed0 : 1;
250 /** Fixed value bit 1 - Set to 0. */
251 unsigned u1Fixed1 : 1;
252 /** Fixed value bit 2 - Set to 0. */
253 unsigned u1Fixed2 : 1;
254 /** Fixed value bit 3 - Set to 0. */
255 unsigned u1Fixed3: 1;
256 /** Fixed value bit 4 - Set to 1. */
257 unsigned u1Fixed4 : 1;
258 /** Fixed value bit 5 - Set to 1. */
259 unsigned u1Fixed5 : 1;
260 /** Gate size, 1 = 32 bits, 0 = 16 bits. */
261 unsigned u132BitGate : 1;
262 /** Fixed value bit 5 - Set to 0. */
263 unsigned u1Fixed6 : 1;
264 /** Descriptor Privilege level. */
265 unsigned u2DPL : 2;
266 /** Present flag. */
267 unsigned u1Present : 1;
268 /** High offset word. */
269 unsigned u16OffsetHigh : 16;
270} VBOXIDTE_INTERRUPTGATE;
271#pragma pack()
272/** Pointer to IDT Entry, Interrupt gate view. */
273typedef VBOXIDTE_INTERRUPTGATE *PVBOXIDTE_INTERRUPTGATE;
274
275/** IDT Entry, Trap Gate view. */
276#pragma pack(1) /* paranoia */
277typedef struct VBOXIDTE_TRAPGATE
278{
279 /** Low offset word. */
280 unsigned u16OffsetLow : 16;
281 /** Segment Selector. */
282 unsigned u16SegSel : 16;
283 /** Reserved. */
284 unsigned u5Reserved2 : 5;
285 /** Fixed value bit 0 - Set to 0. */
286 unsigned u1Fixed0 : 1;
287 /** Fixed value bit 1 - Set to 0. */
288 unsigned u1Fixed1 : 1;
289 /** Fixed value bit 2 - Set to 0. */
290 unsigned u1Fixed2 : 1;
291 /** Fixed value bit 3 - Set to 1. */
292 unsigned u1Fixed3: 1;
293 /** Fixed value bit 4 - Set to 1. */
294 unsigned u1Fixed4 : 1;
295 /** Fixed value bit 5 - Set to 1. */
296 unsigned u1Fixed5 : 1;
297 /** Gate size, 1 = 32 bits, 0 = 16 bits. */
298 unsigned u132BitGate : 1;
299 /** Fixed value bit 5 - Set to 0. */
300 unsigned u1Fixed6 : 1;
301 /** Descriptor Privilege level. */
302 unsigned u2DPL : 2;
303 /** Present flag. */
304 unsigned u1Present : 1;
305 /** High offset word. */
306 unsigned u16OffsetHigh : 16;
307} VBOXIDTE_TRAPGATE;
308#pragma pack()
309/** Pointer to IDT Entry, Trap Gate view. */
310typedef VBOXIDTE_TRAPGATE *PVBOXIDTE_TRAPGATE;
311
312/** IDT Entry Generic view. */
313#pragma pack(1) /* paranoia */
314typedef struct VBOXIDTE_GENERIC
315{
316 /** Low offset word. */
317 unsigned u16OffsetLow : 16;
318 /** Segment Selector. */
319 unsigned u16SegSel : 16;
320 /** Reserved. */
321 unsigned u5Reserved : 5;
322 /** IDT Type part one (not used for task gate). */
323 unsigned u3Type1 : 3;
324 /** IDT Type part two. */
325 unsigned u5Type2 : 5;
326 /** Descriptor Privilege level. */
327 unsigned u2DPL : 2;
328 /** Present flag. */
329 unsigned u1Present : 1;
330 /** High offset word. */
331 unsigned u16OffsetHigh : 16;
332} VBOXIDTE_GENERIC;
333#pragma pack()
334/** Pointer to IDT Entry Generic view. */
335typedef VBOXIDTE_GENERIC *PVBOXIDTE_GENERIC;
336
337/** IDT Type1 value. (Reserved for task gate!) */
338#define VBOX_IDTE_TYPE1 0
339/** IDT Type2 value - Task gate. */
340#define VBOX_IDTE_TYPE2_TASK 0x5
341/** IDT Type2 value - 16 bit interrupt gate. */
342#define VBOX_IDTE_TYPE2_INT_16 0x6
343/** IDT Type2 value - 32 bit interrupt gate. */
344#define VBOX_IDTE_TYPE2_INT_32 0xe
345/** IDT Type2 value - 16 bit trap gate. */
346#define VBOX_IDTE_TYPE2_TRAP_16 0x7
347/** IDT Type2 value - 32 bit trap gate. */
348#define VBOX_IDTE_TYPE2_TRAP_32 0xf
349
350/** IDT Entry. */
351#pragma pack(1) /* paranoia */
352typedef union VBOXIDTE
353{
354 /** Task gate view. */
355 VBOXIDTE_TASKGATE Task;
356 /** Trap gate view. */
357 VBOXIDTE_TRAPGATE Trap;
358 /** Interrupt gate view. */
359 VBOXIDTE_INTERRUPTGATE Int;
360 /** Generic IDT view. */
361 VBOXIDTE_GENERIC Gen;
362
363 /** 8 bit unsigned integer view. */
364 uint8_t au8[8];
365 /** 16 bit unsigned integer view. */
366 uint16_t au16[4];
367 /** 32 bit unsigned integer view. */
368 uint32_t au32[2];
369 /** 64 bit unsigned integer view. */
370 uint64_t au64;
371} VBOXIDTE;
372#pragma pack()
373/** Pointer to IDT Entry. */
374typedef VBOXIDTE *PVBOXIDTE;
375
376#pragma pack(1)
377/** IDTR */
378typedef struct VBOXIDTR
379{
380 /** Size of the IDT. */
381 uint16_t cbIdt;
382 /** Address of the IDT. */
383 uint64_t pIdt;
384} VBOXIDTR, *PVBOXIDTR;
385#pragma pack()
386/** @} */
387
388
389/** @def VBOXIDTE_OFFSET
390 * Return the offset of an IDT entry.
391 */
392#define VBOXIDTE_OFFSET(desc) \
393 ( ((uint32_t)((desc).Gen.u16OffsetHigh) << 16) \
394 | ( (desc).Gen.u16OffsetLow ) )
395
396#pragma pack(1)
397/** GDTR */
398typedef struct VBOXGDTR
399{
400 /** Size of the GDT. */
401 uint16_t cbGdt;
402 /** Address of the GDT. */
403 uint64_t pGdt;
404} VBOXGDTR;
405#pragma pack()
406/** Pointer to GDTR. */
407typedef VBOXGDTR *PVBOXGDTR;
408
409/** @} */
410
411
412/**
413 * Task Segment
414 */
415#pragma pack(1)
416typedef struct VBOXTSS
417{
418 /** Back link to previous task. (static) */
419 RTSEL selPrev;
420 uint16_t padding1;
421 /** Ring-0 stack pointer. (static) */
422 uint32_t esp0;
423 /** Ring-0 stack segment. (static) */
424 RTSEL ss0;
425 uint16_t padding_ss0;
426 /** Ring-1 stack pointer. (static) */
427 uint32_t esp1;
428 /** Ring-1 stack segment. (static) */
429 RTSEL ss1;
430 uint16_t padding_ss1;
431 /** Ring-2 stack pointer. (static) */
432 uint32_t esp2;
433 /** Ring-2 stack segment. (static) */
434 RTSEL ss2;
435 uint16_t padding_ss2;
436 /** Page directory for the task. (static) */
437 uint32_t cr3;
438 /** EIP before task switch. */
439 uint32_t eip;
440 /** EFLAGS before task switch. */
441 uint32_t eflags;
442 /** EAX before task switch. */
443 uint32_t eax;
444 /** ECX before task switch. */
445 uint32_t ecx;
446 /** EDX before task switch. */
447 uint32_t edx;
448 /** EBX before task switch. */
449 uint32_t ebx;
450 /** ESP before task switch. */
451 uint32_t esp;
452 /** EBP before task switch. */
453 uint32_t ebp;
454 /** ESI before task switch. */
455 uint32_t esi;
456 /** EDI before task switch. */
457 uint32_t edi;
458 /** ES before task switch. */
459 RTSEL es;
460 uint16_t padding_es;
461 /** CS before task switch. */
462 RTSEL cs;
463 uint16_t padding_cs;
464 /** SS before task switch. */
465 RTSEL ss;
466 uint16_t padding_ss;
467 /** DS before task switch. */
468 RTSEL ds;
469 uint16_t padding_ds;
470 /** FS before task switch. */
471 RTSEL fs;
472 uint16_t padding_fs;
473 /** GS before task switch. */
474 RTSEL gs;
475 uint16_t padding_gs;
476 /** LDTR before task switch. */
477 RTSEL selLdt;
478 uint16_t padding_ldt;
479 /** Debug trap flag */
480 uint16_t fDebugTrap;
481 /** Offset relative to the TSS of the start of the I/O Bitmap
482 * and the end of the interrupt redirection bitmap. */
483 uint16_t offIoBitmap;
484 /** 32 bytes for the virtual interrupt redirection bitmap. (VME) */
485 uint8_t IntRedirBitmap[32];
486} VBOXTSS;
487#pragma pack()
488/** Pointer to task segment. */
489typedef VBOXTSS *PVBOXTSS;
490/** Pointer to const task segment. */
491typedef const VBOXTSS *PCVBOXTSS;
492
493
494/** PDM MAC address.
495 * @obsolete Use RTMAC. */
496typedef RTMAC PDMMAC;
497/** Pointer to a MAC address. */
498typedef PDMMAC *PPDMMAC;
499/** Pointer to a const MAC address. */
500typedef const PDMMAC *PCPDMMAC;
501
502/**
503 * Data transport buffer (scatter/gather)
504 */
505typedef struct PDMDATASEG
506{
507 /** Length of buffer in entry. */
508 size_t cbSeg;
509 /** Pointer to the start of the buffer. */
510 void *pvSeg;
511} PDMDATASEG;
512/** Pointer to a data transport segment. */
513typedef PDMDATASEG *PPDMDATASEG;
514/** Pointer to a const data transport segment. */
515typedef PDMDATASEG const *PCPDMDATASEG;
516
517/** @} */
518
519#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