VirtualBox

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

Last change on this file since 16254 was 12632, checked in by vboxsync, 16 years ago

VBox/types.h: Added VMCPUID.

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