VirtualBox

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

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

PDM,PGM,DevPcArch,types.h: Added GCPhys2CCPtr conversion methods to PDMDEVHLP and removed some obsolete (or soon to be obsolete) methods.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 17.4 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/** Pointer to IDT Entry. */
388typedef VBOXIDTE const *PCVBOXIDTE;
389
390#pragma pack(1)
391/** IDTR */
392typedef struct VBOXIDTR
393{
394 /** Size of the IDT. */
395 uint16_t cbIdt;
396 /** Address of the IDT. */
397 uint64_t pIdt;
398} VBOXIDTR, *PVBOXIDTR;
399#pragma pack()
400
401#pragma pack(1)
402/** IDTR from version 1.6 */
403typedef struct VBOXIDTR_VER1_6
404{
405 /** Size of the IDT. */
406 uint16_t cbIdt;
407 /** Address of the IDT. */
408 uint32_t pIdt;
409} VBOXIDTR_VER1_6, *PVBOXIDTR_VER1_6;
410#pragma pack()
411
412/** @} */
413
414
415/** @def VBOXIDTE_OFFSET
416 * Return the offset of an IDT entry.
417 */
418#define VBOXIDTE_OFFSET(desc) \
419 ( ((uint32_t)((desc).Gen.u16OffsetHigh) << 16) \
420 | ( (desc).Gen.u16OffsetLow ) )
421
422#pragma pack(1)
423/** GDTR */
424typedef struct VBOXGDTR
425{
426 /** Size of the GDT. */
427 uint16_t cbGdt;
428 /** Address of the GDT. */
429 uint64_t pGdt;
430} VBOXGDTR;
431#pragma pack()
432/** Pointer to GDTR. */
433typedef VBOXGDTR *PVBOXGDTR;
434
435#pragma pack(1)
436/** GDTR from version 1.6 */
437typedef struct VBOXGDTR_VER1_6
438{
439 /** Size of the GDT. */
440 uint16_t cbGdt;
441 /** Address of the GDT. */
442 uint32_t pGdt;
443} VBOXGDTR_VER1_6;
444#pragma pack()
445
446/** @} */
447
448
449/**
450 * 32-bit Task Segment used in raw mode.
451 * @todo Move this to SELM! Use X86TSS32 instead.
452 */
453#pragma pack(1)
454typedef struct VBOXTSS
455{
456 /** 0x00 - Back link to previous task. (static) */
457 RTSEL selPrev;
458 uint16_t padding1;
459 /** 0x04 - Ring-0 stack pointer. (static) */
460 uint32_t esp0;
461 /** 0x08 - Ring-0 stack segment. (static) */
462 RTSEL ss0;
463 uint16_t padding_ss0;
464 /** 0x0c - Ring-1 stack pointer. (static) */
465 uint32_t esp1;
466 /** 0x10 - Ring-1 stack segment. (static) */
467 RTSEL ss1;
468 uint16_t padding_ss1;
469 /** 0x14 - Ring-2 stack pointer. (static) */
470 uint32_t esp2;
471 /** 0x18 - Ring-2 stack segment. (static) */
472 RTSEL ss2;
473 uint16_t padding_ss2;
474 /** 0x1c - Page directory for the task. (static) */
475 uint32_t cr3;
476 /** 0x20 - EIP before task switch. */
477 uint32_t eip;
478 /** 0x24 - EFLAGS before task switch. */
479 uint32_t eflags;
480 /** 0x28 - EAX before task switch. */
481 uint32_t eax;
482 /** 0x2c - ECX before task switch. */
483 uint32_t ecx;
484 /** 0x30 - EDX before task switch. */
485 uint32_t edx;
486 /** 0x34 - EBX before task switch. */
487 uint32_t ebx;
488 /** 0x38 - ESP before task switch. */
489 uint32_t esp;
490 /** 0x3c - EBP before task switch. */
491 uint32_t ebp;
492 /** 0x40 - ESI before task switch. */
493 uint32_t esi;
494 /** 0x44 - EDI before task switch. */
495 uint32_t edi;
496 /** 0x48 - ES before task switch. */
497 RTSEL es;
498 uint16_t padding_es;
499 /** 0x4c - CS before task switch. */
500 RTSEL cs;
501 uint16_t padding_cs;
502 /** 0x50 - SS before task switch. */
503 RTSEL ss;
504 uint16_t padding_ss;
505 /** 0x54 - DS before task switch. */
506 RTSEL ds;
507 uint16_t padding_ds;
508 /** 0x58 - FS before task switch. */
509 RTSEL fs;
510 uint16_t padding_fs;
511 /** 0x5c - GS before task switch. */
512 RTSEL gs;
513 uint16_t padding_gs;
514 /** 0x60 - LDTR before task switch. */
515 RTSEL selLdt;
516 uint16_t padding_ldt;
517 /** 0x64 - Debug trap flag */
518 uint16_t fDebugTrap;
519 /** 0x66 - Offset relative to the TSS of the start of the I/O Bitmap
520 * and the end of the interrupt redirection bitmap. */
521 uint16_t offIoBitmap;
522 /** 0x68 - 32 bytes for the virtual interrupt redirection bitmap. (VME) */
523 uint8_t IntRedirBitmap[32];
524} VBOXTSS;
525#pragma pack()
526/** Pointer to task segment. */
527typedef VBOXTSS *PVBOXTSS;
528/** Pointer to const task segment. */
529typedef const VBOXTSS *PCVBOXTSS;
530
531
532/**
533 * Data transport buffer (scatter/gather)
534 */
535typedef struct PDMDATASEG
536{
537 /** Length of buffer in entry. */
538 size_t cbSeg;
539 /** Pointer to the start of the buffer. */
540 void *pvSeg;
541} PDMDATASEG;
542/** Pointer to a data transport segment. */
543typedef PDMDATASEG *PPDMDATASEG;
544/** Pointer to a const data transport segment. */
545typedef PDMDATASEG const *PCPDMDATASEG;
546
547
548/**
549 * The current ROM page protection.
550 *
551 * @remarks This is part of the saved state.
552 */
553typedef enum PGMROMPROT
554{
555 /** The customary invalid value. */
556 PGMROMPROT_INVALID = 0,
557 /** Read from the virgin ROM page, ignore writes.
558 * Map the virgin page, use write access handler to ignore writes. */
559 PGMROMPROT_READ_ROM_WRITE_IGNORE,
560 /** Read from the virgin ROM page, write to the shadow RAM.
561 * Map the virgin page, use write access handler change the RAM. */
562 PGMROMPROT_READ_ROM_WRITE_RAM,
563 /** Read from the shadow ROM page, ignore writes.
564 * Map the shadow page read-only, use write access handler to ignore writes. */
565 PGMROMPROT_READ_RAM_WRITE_IGNORE,
566 /** Read from the shadow ROM page, ignore writes.
567 * Map the shadow page read-write, disabled write access handler. */
568 PGMROMPROT_READ_RAM_WRITE_RAM,
569 /** The end of valid values. */
570 PGMROMPROT_END,
571 /** The usual 32-bit type size hack. */
572 PGMROMPROT_32BIT_HACK = 0x7fffffff
573} PGMROMPROT;
574
575
576/**
577 * Page mapping lock.
578 *
579 * @remarks This doesn't work in structures shared between
580 * ring-3, ring-0 and/or GC.
581 */
582typedef struct PGMPAGEMAPLOCK
583{
584 /** @todo see PGMPhysIsPageMappingLockValid for possibly incorrect assumptions */
585#if defined(IN_RC) || defined(VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R0)
586 /** Just a dummy for the time being. */
587 uint32_t u32Dummy;
588#else
589 /** Pointer to the PGMPAGE. */
590 void *pvPage;
591 /** Pointer to the PGMCHUNKR3MAP. */
592 void *pvMap;
593#endif
594} PGMPAGEMAPLOCK;
595/** Pointer to a page mapping lock. */
596typedef PGMPAGEMAPLOCK *PPGMPAGEMAPLOCK;
597
598
599/** @} */
600
601#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