VirtualBox

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

Last change on this file since 19288 was 19285, checked in by vboxsync, 16 years ago

VBox/types.h: NIL_VMCPUID.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 17.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/** @} */
54
55
56/** @defgroup grp_types_gc Guest Context Basic Types
57 * @ingroup grp_types_both
58 * @{
59 */
60
61/** @} */
62
63
64/** Pointer to per support driver session data.
65 * (The data is a R0 entity and private to the the R0 SUP part. All
66 * other should consider this a sort of handle.) */
67typedef R0PTRTYPE(struct SUPDRVSESSION *) PSUPDRVSESSION;
68
69/** Pointer to a VM. */
70typedef struct VM *PVM;
71/** Pointer to a VM - Ring-0 Ptr. */
72typedef R0PTRTYPE(struct VM *) PVMR0;
73/** Pointer to a VM - Ring-3 Ptr. */
74typedef R3PTRTYPE(struct VM *) PVMR3;
75/** Pointer to a VM - RC Ptr. */
76typedef RCPTRTYPE(struct VM *) PVMRC;
77
78/** Pointer to a virtual CPU structure. */
79typedef struct VMCPU * PVMCPU;
80/** Pointer to a virtual CPU structure - Ring-3 Ptr. */
81typedef R3PTRTYPE(struct VMCPU *) PVMCPUR3;
82/** Pointer to a virtual CPU structure - Ring-0 Ptr. */
83typedef R0PTRTYPE(struct VMCPU *) PVMCPUR0;
84/** Pointer to a virtual CPU structure - RC Ptr. */
85typedef RCPTRTYPE(struct VMCPU *) PVMCPURC;
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/** Pointer to a ring-3 (user mode) VMCPU structure. */
94typedef R3PTRTYPE(struct UVMCPU *) PUVMCPU;
95
96/** Virtual CPU ID. */
97typedef uint32_t VMCPUID;
98/** Pointer to a virtual CPU ID. */
99typedef VMCPUID *PVMCPUID;
100/** @name Special CPU ID values.
101 * @{ */
102/** All virtual CPUs. */
103#define VMCPUID_ALL UINT32_C(0xffffffff)
104/** Any virtual CPU, preferrably an idle one.
105 * Intended for scheduling a VM request or some other task. */
106#define VMCPUID_ANY_IDLE UINT32_C(0xfffffffe)
107/** The NIL value. */
108#define NIL_VMCPUID UINT32_C(0xfffffff0)
109/** @} */
110
111/** VM State
112 */
113typedef enum VMSTATE
114{
115 /** The VM is being created. */
116 VMSTATE_CREATING = 0,
117 /** The VM is created. */
118 VMSTATE_CREATED,
119 /** The VM is runnning. */
120 VMSTATE_RUNNING,
121 /** The VM state is being loaded from file. */
122 VMSTATE_LOADING,
123 /** The VM is screwed because of a failed state loading. */
124 VMSTATE_LOAD_FAILURE,
125 /** The VM state is being saved to file. */
126 VMSTATE_SAVING,
127 /** The VM is suspended. */
128 VMSTATE_SUSPENDED,
129 /** The VM is being reset. */
130 VMSTATE_RESETTING,
131 /** The VM is in guru meditation over a fatal failure. */
132 VMSTATE_GURU_MEDITATION,
133 /** The VM is switched off, awaiting destruction. */
134 VMSTATE_OFF,
135 /** The VM is being destroyed. */
136 VMSTATE_DESTROYING,
137 /** Terminated. */
138 VMSTATE_TERMINATED,
139 /** hack forcing the size of the enum to 32-bits. */
140 VMSTATE_MAKE_32BIT_HACK = 0x7fffffff
141} VMSTATE;
142
143
144/** Pointer to a PDM Driver Base Interface. */
145typedef struct PDMIBASE *PPDMIBASE;
146/** Pointer to a pointer to a PDM Driver Base Interface. */
147typedef PPDMIBASE *PPPDMIBASE;
148
149/** Pointer to a PDM Device Instance. */
150typedef struct PDMDEVINS *PPDMDEVINS;
151/** Pointer to a pointer to a PDM Device Instance. */
152typedef PPDMDEVINS *PPPDMDEVINS;
153/** R3 pointer to a PDM Device Instance. */
154typedef R3PTRTYPE(PPDMDEVINS) PPDMDEVINSR3;
155/** R0 pointer to a PDM Device Instance. */
156typedef R0PTRTYPE(PPDMDEVINS) PPDMDEVINSR0;
157/** RC pointer to a PDM Device Instance. */
158typedef RCPTRTYPE(PPDMDEVINS) PPDMDEVINSRC;
159
160/** Pointer to a PDM USB Device Instance. */
161typedef struct PDMUSBINS *PPDMUSBINS;
162/** Pointer to a pointer to a PDM USB Device Instance. */
163typedef PPDMUSBINS *PPPDMUSBINS;
164
165/** Pointer to a PDM Driver Instance. */
166typedef struct PDMDRVINS *PPDMDRVINS;
167/** Pointer to a pointer to a PDM Driver Instance. */
168typedef PPDMDRVINS *PPPDMDRVINS;
169
170/** Pointer to a PDM Service Instance. */
171typedef struct PDMSRVINS *PPDMSRVINS;
172/** Pointer to a pointer to a PDM Service Instance. */
173typedef PPDMSRVINS *PPPDMSRVINS;
174
175/** R3 pointer to a timer. */
176typedef R3PTRTYPE(struct TMTIMER *) PTMTIMERR3;
177/** Pointer to a R3 pointer to a timer. */
178typedef PTMTIMERR3 *PPTMTIMERR3;
179
180/** R0 pointer to a timer. */
181typedef R0PTRTYPE(struct TMTIMER *) PTMTIMERR0;
182/** Pointer to a R3 pointer to a timer. */
183typedef PTMTIMERR0 *PPTMTIMERR0;
184
185/** RC pointer to a timer. */
186typedef RCPTRTYPE(struct TMTIMER *) PTMTIMERRC;
187/** Pointer to a RC pointer to a timer. */
188typedef PTMTIMERRC *PPTMTIMERRC;
189
190/** Pointer to a timer. */
191typedef CTX_SUFF(PTMTIMER) PTMTIMER;
192/** Pointer to a pointer to a timer. */
193typedef PTMTIMER *PPTMTIMER;
194
195/** SSM Operation handle. */
196typedef struct SSMHANDLE *PSSMHANDLE;
197
198/** Pointer to a CPUMCTX. */
199typedef struct CPUMCTX *PCPUMCTX;
200/** Pointer to a const CPUMCTX. */
201typedef const struct CPUMCTX *PCCPUMCTX;
202
203/** Pointer to a CPU context core. */
204typedef struct CPUMCTXCORE *PCPUMCTXCORE;
205/** Pointer to a const CPU context core. */
206typedef const struct CPUMCTXCORE *PCCPUMCTXCORE;
207
208/** Pointer to selector hidden registers. */
209typedef struct CPUMSELREGHID *PCPUMSELREGHID;
210/** Pointer to const selector hidden registers. */
211typedef const struct CPUMSELREGHID *PCCPUMSELREGHID;
212
213/** @} */
214
215
216/** @defgroup grp_types_idt Interrupt Descriptor Table Entry.
217 * @ingroup grp_types
218 * @todo This all belongs in x86.h!
219 * @{ */
220
221/** @todo VBOXIDT -> VBOXDESCIDT, skip the complex variations. We'll never use them. */
222
223/** IDT Entry, Task Gate view. */
224#pragma pack(1) /* paranoia */
225typedef struct VBOXIDTE_TASKGATE
226{
227 /** Reserved. */
228 unsigned u16Reserved1 : 16;
229 /** Task Segment Selector. */
230 unsigned u16TSS : 16;
231 /** More reserved. */
232 unsigned u8Reserved2 : 8;
233 /** Fixed value bit 0 - Set to 1. */
234 unsigned u1Fixed0 : 1;
235 /** Busy bit. */
236 unsigned u1Busy : 1;
237 /** Fixed value bit 2 - Set to 1. */
238 unsigned u1Fixed1 : 1;
239 /** Fixed value bit 3 - Set to 0. */
240 unsigned u1Fixed2: 1;
241 /** Fixed value bit 4 - Set to 0. */
242 unsigned u1Fixed3 : 1;
243 /** Descriptor Privilege level. */
244 unsigned u2DPL : 2;
245 /** Present flag. */
246 unsigned u1Present : 1;
247 /** Reserved. */
248 unsigned u16Reserved3 : 16;
249} VBOXIDTE_TASKGATE;
250#pragma pack()
251/** Pointer to IDT Entry, Task gate view. */
252typedef VBOXIDTE_TASKGATE *PVBOXIDTE_TASKGATE;
253
254
255/** IDT Entry, Intertupt gate view. */
256#pragma pack(1) /* paranoia */
257typedef struct VBOXIDTE_INTERRUPTGATE
258{
259 /** Low offset word. */
260 unsigned u16OffsetLow : 16;
261 /** Segment Selector. */
262 unsigned u16SegSel : 16;
263 /** Reserved. */
264 unsigned u5Reserved2 : 5;
265 /** Fixed value bit 0 - Set to 0. */
266 unsigned u1Fixed0 : 1;
267 /** Fixed value bit 1 - Set to 0. */
268 unsigned u1Fixed1 : 1;
269 /** Fixed value bit 2 - Set to 0. */
270 unsigned u1Fixed2 : 1;
271 /** Fixed value bit 3 - Set to 0. */
272 unsigned u1Fixed3: 1;
273 /** Fixed value bit 4 - Set to 1. */
274 unsigned u1Fixed4 : 1;
275 /** Fixed value bit 5 - Set to 1. */
276 unsigned u1Fixed5 : 1;
277 /** Gate size, 1 = 32 bits, 0 = 16 bits. */
278 unsigned u132BitGate : 1;
279 /** Fixed value bit 5 - Set to 0. */
280 unsigned u1Fixed6 : 1;
281 /** Descriptor Privilege level. */
282 unsigned u2DPL : 2;
283 /** Present flag. */
284 unsigned u1Present : 1;
285 /** High offset word. */
286 unsigned u16OffsetHigh : 16;
287} VBOXIDTE_INTERRUPTGATE;
288#pragma pack()
289/** Pointer to IDT Entry, Interrupt gate view. */
290typedef VBOXIDTE_INTERRUPTGATE *PVBOXIDTE_INTERRUPTGATE;
291
292/** IDT Entry, Trap Gate view. */
293#pragma pack(1) /* paranoia */
294typedef struct VBOXIDTE_TRAPGATE
295{
296 /** Low offset word. */
297 unsigned u16OffsetLow : 16;
298 /** Segment Selector. */
299 unsigned u16SegSel : 16;
300 /** Reserved. */
301 unsigned u5Reserved2 : 5;
302 /** Fixed value bit 0 - Set to 0. */
303 unsigned u1Fixed0 : 1;
304 /** Fixed value bit 1 - Set to 0. */
305 unsigned u1Fixed1 : 1;
306 /** Fixed value bit 2 - Set to 0. */
307 unsigned u1Fixed2 : 1;
308 /** Fixed value bit 3 - Set to 1. */
309 unsigned u1Fixed3: 1;
310 /** Fixed value bit 4 - Set to 1. */
311 unsigned u1Fixed4 : 1;
312 /** Fixed value bit 5 - Set to 1. */
313 unsigned u1Fixed5 : 1;
314 /** Gate size, 1 = 32 bits, 0 = 16 bits. */
315 unsigned u132BitGate : 1;
316 /** Fixed value bit 5 - Set to 0. */
317 unsigned u1Fixed6 : 1;
318 /** Descriptor Privilege level. */
319 unsigned u2DPL : 2;
320 /** Present flag. */
321 unsigned u1Present : 1;
322 /** High offset word. */
323 unsigned u16OffsetHigh : 16;
324} VBOXIDTE_TRAPGATE;
325#pragma pack()
326/** Pointer to IDT Entry, Trap Gate view. */
327typedef VBOXIDTE_TRAPGATE *PVBOXIDTE_TRAPGATE;
328
329/** IDT Entry Generic view. */
330#pragma pack(1) /* paranoia */
331typedef struct VBOXIDTE_GENERIC
332{
333 /** Low offset word. */
334 unsigned u16OffsetLow : 16;
335 /** Segment Selector. */
336 unsigned u16SegSel : 16;
337 /** Reserved. */
338 unsigned u5Reserved : 5;
339 /** IDT Type part one (not used for task gate). */
340 unsigned u3Type1 : 3;
341 /** IDT Type part two. */
342 unsigned u5Type2 : 5;
343 /** Descriptor Privilege level. */
344 unsigned u2DPL : 2;
345 /** Present flag. */
346 unsigned u1Present : 1;
347 /** High offset word. */
348 unsigned u16OffsetHigh : 16;
349} VBOXIDTE_GENERIC;
350#pragma pack()
351/** Pointer to IDT Entry Generic view. */
352typedef VBOXIDTE_GENERIC *PVBOXIDTE_GENERIC;
353
354/** IDT Type1 value. (Reserved for task gate!) */
355#define VBOX_IDTE_TYPE1 0
356/** IDT Type2 value - Task gate. */
357#define VBOX_IDTE_TYPE2_TASK 0x5
358/** IDT Type2 value - 16 bit interrupt gate. */
359#define VBOX_IDTE_TYPE2_INT_16 0x6
360/** IDT Type2 value - 32 bit interrupt gate. */
361#define VBOX_IDTE_TYPE2_INT_32 0xe
362/** IDT Type2 value - 16 bit trap gate. */
363#define VBOX_IDTE_TYPE2_TRAP_16 0x7
364/** IDT Type2 value - 32 bit trap gate. */
365#define VBOX_IDTE_TYPE2_TRAP_32 0xf
366
367/** IDT Entry. */
368#pragma pack(1) /* paranoia */
369typedef union VBOXIDTE
370{
371 /** Task gate view. */
372 VBOXIDTE_TASKGATE Task;
373 /** Trap gate view. */
374 VBOXIDTE_TRAPGATE Trap;
375 /** Interrupt gate view. */
376 VBOXIDTE_INTERRUPTGATE Int;
377 /** Generic IDT view. */
378 VBOXIDTE_GENERIC Gen;
379
380 /** 8 bit unsigned integer view. */
381 uint8_t au8[8];
382 /** 16 bit unsigned integer view. */
383 uint16_t au16[4];
384 /** 32 bit unsigned integer view. */
385 uint32_t au32[2];
386 /** 64 bit unsigned integer view. */
387 uint64_t au64;
388} VBOXIDTE;
389#pragma pack()
390/** Pointer to IDT Entry. */
391typedef VBOXIDTE *PVBOXIDTE;
392/** Pointer to IDT Entry. */
393typedef VBOXIDTE const *PCVBOXIDTE;
394
395#pragma pack(1)
396/** IDTR */
397typedef struct VBOXIDTR
398{
399 /** Size of the IDT. */
400 uint16_t cbIdt;
401 /** Address of the IDT. */
402 uint64_t pIdt;
403} VBOXIDTR, *PVBOXIDTR;
404#pragma pack()
405
406#pragma pack(1)
407/** IDTR from version 1.6 */
408typedef struct VBOXIDTR_VER1_6
409{
410 /** Size of the IDT. */
411 uint16_t cbIdt;
412 /** Address of the IDT. */
413 uint32_t pIdt;
414} VBOXIDTR_VER1_6, *PVBOXIDTR_VER1_6;
415#pragma pack()
416
417/** @} */
418
419
420/** @def VBOXIDTE_OFFSET
421 * Return the offset of an IDT entry.
422 */
423#define VBOXIDTE_OFFSET(desc) \
424 ( ((uint32_t)((desc).Gen.u16OffsetHigh) << 16) \
425 | ( (desc).Gen.u16OffsetLow ) )
426
427#pragma pack(1)
428/** GDTR */
429typedef struct VBOXGDTR
430{
431 /** Size of the GDT. */
432 uint16_t cbGdt;
433 /** Address of the GDT. */
434 uint64_t pGdt;
435} VBOXGDTR;
436#pragma pack()
437/** Pointer to GDTR. */
438typedef VBOXGDTR *PVBOXGDTR;
439
440#pragma pack(1)
441/** GDTR from version 1.6 */
442typedef struct VBOXGDTR_VER1_6
443{
444 /** Size of the GDT. */
445 uint16_t cbGdt;
446 /** Address of the GDT. */
447 uint32_t pGdt;
448} VBOXGDTR_VER1_6;
449#pragma pack()
450
451/** @} */
452
453
454/**
455 * 32-bit Task Segment used in raw mode.
456 * @todo Move this to SELM! Use X86TSS32 instead.
457 */
458#pragma pack(1)
459typedef struct VBOXTSS
460{
461 /** 0x00 - Back link to previous task. (static) */
462 RTSEL selPrev;
463 uint16_t padding1;
464 /** 0x04 - Ring-0 stack pointer. (static) */
465 uint32_t esp0;
466 /** 0x08 - Ring-0 stack segment. (static) */
467 RTSEL ss0;
468 uint16_t padding_ss0;
469 /** 0x0c - Ring-1 stack pointer. (static) */
470 uint32_t esp1;
471 /** 0x10 - Ring-1 stack segment. (static) */
472 RTSEL ss1;
473 uint16_t padding_ss1;
474 /** 0x14 - Ring-2 stack pointer. (static) */
475 uint32_t esp2;
476 /** 0x18 - Ring-2 stack segment. (static) */
477 RTSEL ss2;
478 uint16_t padding_ss2;
479 /** 0x1c - Page directory for the task. (static) */
480 uint32_t cr3;
481 /** 0x20 - EIP before task switch. */
482 uint32_t eip;
483 /** 0x24 - EFLAGS before task switch. */
484 uint32_t eflags;
485 /** 0x28 - EAX before task switch. */
486 uint32_t eax;
487 /** 0x2c - ECX before task switch. */
488 uint32_t ecx;
489 /** 0x30 - EDX before task switch. */
490 uint32_t edx;
491 /** 0x34 - EBX before task switch. */
492 uint32_t ebx;
493 /** 0x38 - ESP before task switch. */
494 uint32_t esp;
495 /** 0x3c - EBP before task switch. */
496 uint32_t ebp;
497 /** 0x40 - ESI before task switch. */
498 uint32_t esi;
499 /** 0x44 - EDI before task switch. */
500 uint32_t edi;
501 /** 0x48 - ES before task switch. */
502 RTSEL es;
503 uint16_t padding_es;
504 /** 0x4c - CS before task switch. */
505 RTSEL cs;
506 uint16_t padding_cs;
507 /** 0x50 - SS before task switch. */
508 RTSEL ss;
509 uint16_t padding_ss;
510 /** 0x54 - DS before task switch. */
511 RTSEL ds;
512 uint16_t padding_ds;
513 /** 0x58 - FS before task switch. */
514 RTSEL fs;
515 uint16_t padding_fs;
516 /** 0x5c - GS before task switch. */
517 RTSEL gs;
518 uint16_t padding_gs;
519 /** 0x60 - LDTR before task switch. */
520 RTSEL selLdt;
521 uint16_t padding_ldt;
522 /** 0x64 - Debug trap flag */
523 uint16_t fDebugTrap;
524 /** 0x66 - Offset relative to the TSS of the start of the I/O Bitmap
525 * and the end of the interrupt redirection bitmap. */
526 uint16_t offIoBitmap;
527 /** 0x68 - 32 bytes for the virtual interrupt redirection bitmap. (VME) */
528 uint8_t IntRedirBitmap[32];
529} VBOXTSS;
530#pragma pack()
531/** Pointer to task segment. */
532typedef VBOXTSS *PVBOXTSS;
533/** Pointer to const task segment. */
534typedef const VBOXTSS *PCVBOXTSS;
535
536
537/**
538 * Data transport buffer (scatter/gather)
539 */
540typedef struct PDMDATASEG
541{
542 /** Length of buffer in entry. */
543 size_t cbSeg;
544 /** Pointer to the start of the buffer. */
545 void *pvSeg;
546} PDMDATASEG;
547/** Pointer to a data transport segment. */
548typedef PDMDATASEG *PPDMDATASEG;
549/** Pointer to a const data transport segment. */
550typedef PDMDATASEG const *PCPDMDATASEG;
551
552
553/**
554 * The current ROM page protection.
555 *
556 * @remarks This is part of the saved state.
557 */
558typedef enum PGMROMPROT
559{
560 /** The customary invalid value. */
561 PGMROMPROT_INVALID = 0,
562 /** Read from the virgin ROM page, ignore writes.
563 * Map the virgin page, use write access handler to ignore writes. */
564 PGMROMPROT_READ_ROM_WRITE_IGNORE,
565 /** Read from the virgin ROM page, write to the shadow RAM.
566 * Map the virgin page, use write access handler change the RAM. */
567 PGMROMPROT_READ_ROM_WRITE_RAM,
568 /** Read from the shadow ROM page, ignore writes.
569 * Map the shadow page read-only, use write access handler to ignore writes. */
570 PGMROMPROT_READ_RAM_WRITE_IGNORE,
571 /** Read from the shadow ROM page, ignore writes.
572 * Map the shadow page read-write, disabled write access handler. */
573 PGMROMPROT_READ_RAM_WRITE_RAM,
574 /** The end of valid values. */
575 PGMROMPROT_END,
576 /** The usual 32-bit type size hack. */
577 PGMROMPROT_32BIT_HACK = 0x7fffffff
578} PGMROMPROT;
579
580
581/**
582 * Page mapping lock.
583 *
584 * @remarks This doesn't work in structures shared between
585 * ring-3, ring-0 and/or GC.
586 */
587typedef struct PGMPAGEMAPLOCK
588{
589 /** @todo see PGMPhysIsPageMappingLockValid for possibly incorrect assumptions */
590#if defined(IN_RC) || defined(VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R0)
591 /** Just a dummy for the time being. */
592 uint32_t u32Dummy;
593#else
594 /** Pointer to the PGMPAGE. */
595 void *pvPage;
596 /** Pointer to the PGMCHUNKR3MAP. */
597 void *pvMap;
598#endif
599} PGMPAGEMAPLOCK;
600/** Pointer to a page mapping lock. */
601typedef PGMPAGEMAPLOCK *PPGMPAGEMAPLOCK;
602
603
604/** @} */
605
606#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