VirtualBox

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

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

VBox/types.h: Added the PVMCPU types.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 15.1 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
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/** RC pointer to a PDM Device Instance. */
141typedef RCPTRTYPE(PPDMDEVINS) PPDMDEVINSRC;
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/** RC pointer to a timer. */
169typedef RCPTRTYPE(struct TMTIMER *) PTMTIMERRC;
170/** Pointer to a RC pointer to a timer. */
171typedef PTMTIMERRC *PPTMTIMERRC;
172
173/** Pointer to a timer. */
174typedef CTX_SUFF(PTMTIMER) PTMTIMER;
175/** Pointer to a pointer to a timer. */
176typedef PTMTIMER *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#pragma pack(1)
388/** IDTR from version 1.6 */
389typedef struct VBOXIDTR_VER1_6
390{
391 /** Size of the IDT. */
392 uint16_t cbIdt;
393 /** Address of the IDT. */
394 uint32_t pIdt;
395} VBOXIDTR_VER1_6, *PVBOXIDTR_VER1_6;
396#pragma pack()
397
398/** @} */
399
400
401/** @def VBOXIDTE_OFFSET
402 * Return the offset of an IDT entry.
403 */
404#define VBOXIDTE_OFFSET(desc) \
405 ( ((uint32_t)((desc).Gen.u16OffsetHigh) << 16) \
406 | ( (desc).Gen.u16OffsetLow ) )
407
408#pragma pack(1)
409/** GDTR */
410typedef struct VBOXGDTR
411{
412 /** Size of the GDT. */
413 uint16_t cbGdt;
414 /** Address of the GDT. */
415 uint64_t pGdt;
416} VBOXGDTR;
417#pragma pack()
418/** Pointer to GDTR. */
419typedef VBOXGDTR *PVBOXGDTR;
420
421#pragma pack(1)
422/** GDTR from version 1.6 */
423typedef struct VBOXGDTR_VER1_6
424{
425 /** Size of the GDT. */
426 uint16_t cbGdt;
427 /** Address of the GDT. */
428 uint32_t pGdt;
429} VBOXGDTR_VER1_6;
430#pragma pack()
431
432/** @} */
433
434
435/**
436 * Task Segment
437 */
438#pragma pack(1)
439typedef struct VBOXTSS
440{
441 /** Back link to previous task. (static) */
442 RTSEL selPrev;
443 uint16_t padding1;
444 /** Ring-0 stack pointer. (static) */
445 uint32_t esp0;
446 /** Ring-0 stack segment. (static) */
447 RTSEL ss0;
448 uint16_t padding_ss0;
449 /** Ring-1 stack pointer. (static) */
450 uint32_t esp1;
451 /** Ring-1 stack segment. (static) */
452 RTSEL ss1;
453 uint16_t padding_ss1;
454 /** Ring-2 stack pointer. (static) */
455 uint32_t esp2;
456 /** Ring-2 stack segment. (static) */
457 RTSEL ss2;
458 uint16_t padding_ss2;
459 /** Page directory for the task. (static) */
460 uint32_t cr3;
461 /** EIP before task switch. */
462 uint32_t eip;
463 /** EFLAGS before task switch. */
464 uint32_t eflags;
465 /** EAX before task switch. */
466 uint32_t eax;
467 /** ECX before task switch. */
468 uint32_t ecx;
469 /** EDX before task switch. */
470 uint32_t edx;
471 /** EBX before task switch. */
472 uint32_t ebx;
473 /** ESP before task switch. */
474 uint32_t esp;
475 /** EBP before task switch. */
476 uint32_t ebp;
477 /** ESI before task switch. */
478 uint32_t esi;
479 /** EDI before task switch. */
480 uint32_t edi;
481 /** ES before task switch. */
482 RTSEL es;
483 uint16_t padding_es;
484 /** CS before task switch. */
485 RTSEL cs;
486 uint16_t padding_cs;
487 /** SS before task switch. */
488 RTSEL ss;
489 uint16_t padding_ss;
490 /** DS before task switch. */
491 RTSEL ds;
492 uint16_t padding_ds;
493 /** FS before task switch. */
494 RTSEL fs;
495 uint16_t padding_fs;
496 /** GS before task switch. */
497 RTSEL gs;
498 uint16_t padding_gs;
499 /** LDTR before task switch. */
500 RTSEL selLdt;
501 uint16_t padding_ldt;
502 /** Debug trap flag */
503 uint16_t fDebugTrap;
504 /** Offset relative to the TSS of the start of the I/O Bitmap
505 * and the end of the interrupt redirection bitmap. */
506 uint16_t offIoBitmap;
507 /** 32 bytes for the virtual interrupt redirection bitmap. (VME) */
508 uint8_t IntRedirBitmap[32];
509} VBOXTSS;
510#pragma pack()
511/** Pointer to task segment. */
512typedef VBOXTSS *PVBOXTSS;
513/** Pointer to const task segment. */
514typedef const VBOXTSS *PCVBOXTSS;
515
516
517/**
518 * Data transport buffer (scatter/gather)
519 */
520typedef struct PDMDATASEG
521{
522 /** Length of buffer in entry. */
523 size_t cbSeg;
524 /** Pointer to the start of the buffer. */
525 void *pvSeg;
526} PDMDATASEG;
527/** Pointer to a data transport segment. */
528typedef PDMDATASEG *PPDMDATASEG;
529/** Pointer to a const data transport segment. */
530typedef PDMDATASEG const *PCPDMDATASEG;
531
532/** @} */
533
534#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