VirtualBox

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

Last change on this file since 44023 was 42186, checked in by vboxsync, 12 years ago

SELM,DIS,CPUM,EM: Hidden selector register cleanups.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 32.8 KB
Line 
1/** @file
2 * VirtualBox - Types.
3 */
4
5/*
6 * Copyright (C) 2006-2007 Oracle Corporation
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
26#ifndef ___VBox_types_h
27#define ___VBox_types_h
28
29#include <VBox/cdefs.h>
30#include <iprt/types.h>
31
32
33/** @defgroup grp_types Basic VBox Types
34 * @{
35 */
36
37
38/** @defgroup grp_types_both Common Guest and Host Context Basic Types
39 * @ingroup grp_types
40 * @{
41 */
42
43
44/** @defgroup grp_types_hc Host Context Basic Types
45 * @ingroup grp_types_both
46 * @{
47 */
48
49/** @} */
50
51
52/** @defgroup grp_types_gc Guest Context Basic Types
53 * @ingroup grp_types_both
54 * @{
55 */
56
57/** @} */
58
59
60/** Pointer to per support driver session data.
61 * (The data is a R0 entity and private to the the R0 SUP part. All
62 * other should consider this a sort of handle.) */
63typedef R0PTRTYPE(struct SUPDRVSESSION *) PSUPDRVSESSION;
64
65/** Pointer to a VM. */
66typedef struct VM *PVM;
67/** Pointer to a VM - Ring-0 Ptr. */
68typedef R0PTRTYPE(struct VM *) PVMR0;
69/** Pointer to a VM - Ring-3 Ptr. */
70typedef R3PTRTYPE(struct VM *) PVMR3;
71/** Pointer to a VM - RC Ptr. */
72typedef RCPTRTYPE(struct VM *) PVMRC;
73
74/** Pointer to a virtual CPU structure. */
75typedef struct VMCPU * PVMCPU;
76/** Pointer to a virtual CPU structure - Ring-3 Ptr. */
77typedef R3PTRTYPE(struct VMCPU *) PVMCPUR3;
78/** Pointer to a virtual CPU structure - Ring-0 Ptr. */
79typedef R0PTRTYPE(struct VMCPU *) PVMCPUR0;
80/** Pointer to a virtual CPU structure - RC Ptr. */
81typedef RCPTRTYPE(struct VMCPU *) PVMCPURC;
82
83/** Pointer to a ring-0 (global) VM structure. */
84typedef R0PTRTYPE(struct GVM *) PGVM;
85
86/** Pointer to a ring-3 (user mode) VM structure. */
87typedef R3PTRTYPE(struct UVM *) PUVM;
88
89/** Pointer to a ring-3 (user mode) VMCPU structure. */
90typedef R3PTRTYPE(struct UVMCPU *) PUVMCPU;
91
92/** Virtual CPU ID. */
93typedef uint32_t VMCPUID;
94/** Pointer to a virtual CPU ID. */
95typedef VMCPUID *PVMCPUID;
96/** @name Special CPU ID values.
97 * Most of these are for request scheduling.
98 *
99 * @{ */
100/** All virtual CPUs. */
101#define VMCPUID_ALL UINT32_C(0xfffffff2)
102/** All virtual CPUs, descending order. */
103#define VMCPUID_ALL_REVERSE UINT32_C(0xfffffff3)
104/** Any virtual CPU.
105 * Intended for scheduling a VM request or some other task. */
106#define VMCPUID_ANY UINT32_C(0xfffffff4)
107/** Any virtual CPU; always queue for future execution.
108 * Intended for scheduling a VM request or some other task. */
109#define VMCPUID_ANY_QUEUE UINT32_C(0xfffffff5)
110/** The NIL value. */
111#define NIL_VMCPUID UINT32_C(0xfffffffd)
112/** @} */
113
114/**
115 * Virtual CPU set.
116 */
117typedef struct VMCPUSET
118{
119 /** The bitmap data. */
120 uint32_t au32Bitmap[8 /*256/32*/];
121} VMCPUSET;
122/** Pointer to a Virtual CPU set. */
123typedef VMCPUSET *PVMCPUSET;
124/** Pointer to a const Virtual CPU set. */
125typedef VMCPUSET const *PCVMCPUSET;
126
127
128/**
129 * VM State
130 */
131typedef enum VMSTATE
132{
133 /** The VM is being created. */
134 VMSTATE_CREATING = 0,
135 /** The VM is created. */
136 VMSTATE_CREATED,
137 /** The VM state is being loaded from file. */
138 VMSTATE_LOADING,
139 /** The VM is being powered on */
140 VMSTATE_POWERING_ON,
141 /** The VM is being resumed. */
142 VMSTATE_RESUMING,
143 /** The VM is runnning. */
144 VMSTATE_RUNNING,
145 /** Live save: The VM is running and the state is being saved. */
146 VMSTATE_RUNNING_LS,
147 /** Fault Tolerance: The VM is running and the state is being synced. */
148 VMSTATE_RUNNING_FT,
149 /** The VM is being reset. */
150 VMSTATE_RESETTING,
151 /** Live save: The VM is being reset and immediately suspended. */
152 VMSTATE_RESETTING_LS,
153 /** The VM is being suspended. */
154 VMSTATE_SUSPENDING,
155 /** Live save: The VM is being suspended during a live save operation, either as
156 * part of the normal flow or VMR3Reset. */
157 VMSTATE_SUSPENDING_LS,
158 /** Live save: The VM is being suspended by VMR3Suspend during live save. */
159 VMSTATE_SUSPENDING_EXT_LS,
160 /** The VM is suspended. */
161 VMSTATE_SUSPENDED,
162 /** Live save: The VM has been suspended and is waiting for the live save
163 * operation to move on. */
164 VMSTATE_SUSPENDED_LS,
165 /** Live save: The VM has been suspended by VMR3Suspend during a live save. */
166 VMSTATE_SUSPENDED_EXT_LS,
167 /** The VM is suspended and its state is being saved by EMT(0). (See SSM) */
168 VMSTATE_SAVING,
169 /** The VM is being debugged. (See DBGF.) */
170 VMSTATE_DEBUGGING,
171 /** Live save: The VM is being debugged while the live phase is going on. */
172 VMSTATE_DEBUGGING_LS,
173 /** The VM is being powered off. */
174 VMSTATE_POWERING_OFF,
175 /** Live save: The VM is being powered off and the save cancelled. */
176 VMSTATE_POWERING_OFF_LS,
177 /** The VM is switched off, awaiting destruction. */
178 VMSTATE_OFF,
179 /** Live save: Waiting for cancellation and transition to VMSTATE_OFF. */
180 VMSTATE_OFF_LS,
181 /** The VM is powered off because of a fatal error. */
182 VMSTATE_FATAL_ERROR,
183 /** Live save: Waiting for cancellation and transition to FatalError. */
184 VMSTATE_FATAL_ERROR_LS,
185 /** The VM is in guru meditation over a fatal failure. */
186 VMSTATE_GURU_MEDITATION,
187 /** Live save: Waiting for cancellation and transition to GuruMeditation. */
188 VMSTATE_GURU_MEDITATION_LS,
189 /** The VM is screwed because of a failed state loading. */
190 VMSTATE_LOAD_FAILURE,
191 /** The VM is being destroyed. */
192 VMSTATE_DESTROYING,
193 /** Terminated. */
194 VMSTATE_TERMINATED,
195 /** hack forcing the size of the enum to 32-bits. */
196 VMSTATE_MAKE_32BIT_HACK = 0x7fffffff
197} VMSTATE;
198
199/** @def VBOXSTRICTRC_STRICT_ENABLED
200 * Indicates that VBOXSTRICTRC is in strict mode.
201 */
202#if defined(__cplusplus) \
203 && ARCH_BITS == 64 /* cdecl requires classes and structs as hidden params. */ \
204 && !defined(_MSC_VER) /* trouble similar to 32-bit gcc. */ \
205 && ( defined(RT_STRICT) \
206 || defined(VBOX_STRICT) \
207 || defined(DEBUG) \
208 || defined(DOXYGEN_RUNNING) )
209# define VBOXSTRICTRC_STRICT_ENABLED 1
210# ifdef _MSC_VER
211# pragma warning(disable:4190)
212# endif
213#endif
214
215/** We need RTERR_STRICT_RC. */
216#if defined(VBOXSTRICTRC_STRICT_ENABLED) && !defined(RTERR_STRICT_RC)
217# define RTERR_STRICT_RC 1
218#endif
219
220/**
221 * Strict VirtualBox status code.
222 *
223 * This is normally an 32-bit integer and the only purpose of the type is to
224 * highlight the special handling that is required. But in strict build it is a
225 * class that causes compilation and runtime errors for some of the incorrect
226 * handling.
227 */
228#ifdef VBOXSTRICTRC_STRICT_ENABLED
229struct VBOXSTRICTRC
230{
231protected:
232 /** The status code. */
233 int32_t m_rc;
234
235public:
236 /** Default constructor setting the status to VERR_IPE_UNINITIALIZED_STATUS. */
237 VBOXSTRICTRC()
238#ifdef VERR_IPE_UNINITIALIZED_STATUS
239 : m_rc(VERR_IPE_UNINITIALIZED_STATUS)
240#else
241 : m_rc(-233 /*VERR_IPE_UNINITIALIZED_STATUS*/)
242#endif
243 {
244 }
245
246 /** Constructor for normal integer status codes. */
247 VBOXSTRICTRC(int32_t const rc)
248 : m_rc(rc)
249 {
250 }
251
252 /** Getter that VBOXSTRICTRC_VAL can use. */
253 int32_t getValue() const { return m_rc; }
254
255 /** @name Comparison operators
256 * @{ */
257 bool operator==(int32_t rc) const { return m_rc == rc; }
258 bool operator!=(int32_t rc) const { return m_rc != rc; }
259 bool operator<=(int32_t rc) const { return m_rc <= rc; }
260 bool operator>=(int32_t rc) const { return m_rc >= rc; }
261 bool operator<(int32_t rc) const { return m_rc < rc; }
262 bool operator>(int32_t rc) const { return m_rc > rc; }
263
264 bool operator==(const VBOXSTRICTRC &rRc) const { return m_rc == rRc.m_rc; }
265 bool operator!=(const VBOXSTRICTRC &rRc) const { return m_rc != rRc.m_rc; }
266 bool operator<=(const VBOXSTRICTRC &rRc) const { return m_rc <= rRc.m_rc; }
267 bool operator>=(const VBOXSTRICTRC &rRc) const { return m_rc >= rRc.m_rc; }
268 bool operator<(const VBOXSTRICTRC &rRc) const { return m_rc < rRc.m_rc; }
269 bool operator>(const VBOXSTRICTRC &rRc) const { return m_rc > rRc.m_rc; }
270 /** @} */
271
272 /** Special automatic cast for RT_SUCCESS_NP. */
273 operator RTErrStrictType2() const { return RTErrStrictType2(m_rc); }
274
275private:
276 /** @name Constructors that will prevent some of the bad types.
277 * @{ */
278 VBOXSTRICTRC(uint8_t rc) : m_rc(-999) { NOREF(rc); }
279 VBOXSTRICTRC(uint16_t rc) : m_rc(-999) { NOREF(rc); }
280 VBOXSTRICTRC(uint32_t rc) : m_rc(-999) { NOREF(rc); }
281 VBOXSTRICTRC(uint64_t rc) : m_rc(-999) { NOREF(rc); }
282
283 VBOXSTRICTRC(int8_t rc) : m_rc(-999) { NOREF(rc); }
284 VBOXSTRICTRC(int16_t rc) : m_rc(-999) { NOREF(rc); }
285 VBOXSTRICTRC(int64_t rc) : m_rc(-999) { NOREF(rc); }
286 /** @} */
287};
288#else
289typedef int32_t VBOXSTRICTRC;
290#endif
291
292/** @def VBOXSTRICTRC_VAL
293 * Explicit getter.
294 * @param rcStrict The strict VirtualBox status code.
295 */
296#ifdef VBOXSTRICTRC_STRICT_ENABLED
297# define VBOXSTRICTRC_VAL(rcStrict) ( (rcStrict).getValue() )
298#else
299# define VBOXSTRICTRC_VAL(rcStrict) (rcStrict)
300#endif
301
302/** @def VBOXSTRICTRC_TODO
303 * Returns that needs dealing with.
304 * @param rcStrict The strict VirtualBox status code.
305 */
306#define VBOXSTRICTRC_TODO(rcStrict) VBOXSTRICTRC_VAL(rcStrict)
307
308
309/** Pointer to a PDM Base Interface. */
310typedef struct PDMIBASE *PPDMIBASE;
311/** Pointer to a pointer to a PDM Base Interface. */
312typedef PPDMIBASE *PPPDMIBASE;
313
314/** Pointer to a PDM Device Instance. */
315typedef struct PDMDEVINS *PPDMDEVINS;
316/** Pointer to a pointer to a PDM Device Instance. */
317typedef PPDMDEVINS *PPPDMDEVINS;
318/** R3 pointer to a PDM Device Instance. */
319typedef R3PTRTYPE(PPDMDEVINS) PPDMDEVINSR3;
320/** R0 pointer to a PDM Device Instance. */
321typedef R0PTRTYPE(PPDMDEVINS) PPDMDEVINSR0;
322/** RC pointer to a PDM Device Instance. */
323typedef RCPTRTYPE(PPDMDEVINS) PPDMDEVINSRC;
324
325/** Pointer to a PDM USB Device Instance. */
326typedef struct PDMUSBINS *PPDMUSBINS;
327/** Pointer to a pointer to a PDM USB Device Instance. */
328typedef PPDMUSBINS *PPPDMUSBINS;
329
330/** Pointer to a PDM Driver Instance. */
331typedef struct PDMDRVINS *PPDMDRVINS;
332/** Pointer to a pointer to a PDM Driver Instance. */
333typedef PPDMDRVINS *PPPDMDRVINS;
334/** R3 pointer to a PDM Driver Instance. */
335typedef R3PTRTYPE(PPDMDRVINS) PPDMDRVINSR3;
336/** R0 pointer to a PDM Driver Instance. */
337typedef R0PTRTYPE(PPDMDRVINS) PPDMDRVINSR0;
338/** RC pointer to a PDM Driver Instance. */
339typedef RCPTRTYPE(PPDMDRVINS) PPDMDRVINSRC;
340
341/** Pointer to a PDM Service Instance. */
342typedef struct PDMSRVINS *PPDMSRVINS;
343/** Pointer to a pointer to a PDM Service Instance. */
344typedef PPDMSRVINS *PPPDMSRVINS;
345
346/** Pointer to a PDM critical section. */
347typedef union PDMCRITSECT *PPDMCRITSECT;
348/** Pointer to a const PDM critical section. */
349typedef const union PDMCRITSECT *PCPDMCRITSECT;
350
351/** R3 pointer to a timer. */
352typedef R3PTRTYPE(struct TMTIMER *) PTMTIMERR3;
353/** Pointer to a R3 pointer to a timer. */
354typedef PTMTIMERR3 *PPTMTIMERR3;
355
356/** R0 pointer to a timer. */
357typedef R0PTRTYPE(struct TMTIMER *) PTMTIMERR0;
358/** Pointer to a R3 pointer to a timer. */
359typedef PTMTIMERR0 *PPTMTIMERR0;
360
361/** RC pointer to a timer. */
362typedef RCPTRTYPE(struct TMTIMER *) PTMTIMERRC;
363/** Pointer to a RC pointer to a timer. */
364typedef PTMTIMERRC *PPTMTIMERRC;
365
366/** Pointer to a timer. */
367typedef CTX_SUFF(PTMTIMER) PTMTIMER;
368/** Pointer to a pointer to a timer. */
369typedef PTMTIMER *PPTMTIMER;
370
371/** SSM Operation handle. */
372typedef struct SSMHANDLE *PSSMHANDLE;
373/** Pointer to a const SSM stream method table. */
374typedef struct SSMSTRMOPS const *PCSSMSTRMOPS;
375
376/** Pointer to a CPUMCTX. */
377typedef struct CPUMCTX *PCPUMCTX;
378/** Pointer to a const CPUMCTX. */
379typedef const struct CPUMCTX *PCCPUMCTX;
380
381/** Pointer to a CPU context core. */
382typedef struct CPUMCTXCORE *PCPUMCTXCORE;
383/** Pointer to a const CPU context core. */
384typedef const struct CPUMCTXCORE *PCCPUMCTXCORE;
385
386/** Pointer to a selector register. */
387typedef struct CPUMSELREG *PCPUMSELREG;
388/** Pointer to a const selector register. */
389typedef const struct CPUMSELREG *PCCPUMSELREG;
390
391/** Pointer to selector hidden registers.
392 * @deprecated Replaced by PCPUMSELREG */
393typedef struct CPUMSELREG *PCPUMSELREGHID;
394/** Pointer to const selector hidden registers.
395 * @deprecated Replaced by PCCPUMSELREG */
396typedef const struct CPUMSELREG *PCCPUMSELREGHID;
397
398/** @} */
399
400
401/** @defgroup grp_types_idt Interrupt Descriptor Table Entry.
402 * @ingroup grp_types
403 * @todo This all belongs in x86.h!
404 * @{ */
405
406/** @todo VBOXIDT -> VBOXDESCIDT, skip the complex variations. We'll never use them. */
407
408/** IDT Entry, Task Gate view. */
409#pragma pack(1) /* paranoia */
410typedef struct VBOXIDTE_TASKGATE
411{
412 /** Reserved. */
413 unsigned u16Reserved1 : 16;
414 /** Task Segment Selector. */
415 unsigned u16TSS : 16;
416 /** More reserved. */
417 unsigned u8Reserved2 : 8;
418 /** Fixed value bit 0 - Set to 1. */
419 unsigned u1Fixed0 : 1;
420 /** Busy bit. */
421 unsigned u1Busy : 1;
422 /** Fixed value bit 2 - Set to 1. */
423 unsigned u1Fixed1 : 1;
424 /** Fixed value bit 3 - Set to 0. */
425 unsigned u1Fixed2 : 1;
426 /** Fixed value bit 4 - Set to 0. */
427 unsigned u1Fixed3 : 1;
428 /** Descriptor Privilege level. */
429 unsigned u2DPL : 2;
430 /** Present flag. */
431 unsigned u1Present : 1;
432 /** Reserved. */
433 unsigned u16Reserved3 : 16;
434} VBOXIDTE_TASKGATE;
435#pragma pack()
436/** Pointer to IDT Entry, Task gate view. */
437typedef VBOXIDTE_TASKGATE *PVBOXIDTE_TASKGATE;
438
439
440/** IDT Entry, Intertupt gate view. */
441#pragma pack(1) /* paranoia */
442typedef struct VBOXIDTE_INTERRUPTGATE
443{
444 /** Low offset word. */
445 unsigned u16OffsetLow : 16;
446 /** Segment Selector. */
447 unsigned u16SegSel : 16;
448 /** Reserved. */
449 unsigned u5Reserved2 : 5;
450 /** Fixed value bit 0 - Set to 0. */
451 unsigned u1Fixed0 : 1;
452 /** Fixed value bit 1 - Set to 0. */
453 unsigned u1Fixed1 : 1;
454 /** Fixed value bit 2 - Set to 0. */
455 unsigned u1Fixed2 : 1;
456 /** Fixed value bit 3 - Set to 0. */
457 unsigned u1Fixed3 : 1;
458 /** Fixed value bit 4 - Set to 1. */
459 unsigned u1Fixed4 : 1;
460 /** Fixed value bit 5 - Set to 1. */
461 unsigned u1Fixed5 : 1;
462 /** Gate size, 1 = 32 bits, 0 = 16 bits. */
463 unsigned u132BitGate : 1;
464 /** Fixed value bit 5 - Set to 0. */
465 unsigned u1Fixed6 : 1;
466 /** Descriptor Privilege level. */
467 unsigned u2DPL : 2;
468 /** Present flag. */
469 unsigned u1Present : 1;
470 /** High offset word. */
471 unsigned u16OffsetHigh : 16;
472} VBOXIDTE_INTERRUPTGATE;
473#pragma pack()
474/** Pointer to IDT Entry, Interrupt gate view. */
475typedef VBOXIDTE_INTERRUPTGATE *PVBOXIDTE_INTERRUPTGATE;
476
477/** IDT Entry, Trap Gate view. */
478#pragma pack(1) /* paranoia */
479typedef struct VBOXIDTE_TRAPGATE
480{
481 /** Low offset word. */
482 unsigned u16OffsetLow : 16;
483 /** Segment Selector. */
484 unsigned u16SegSel : 16;
485 /** Reserved. */
486 unsigned u5Reserved2 : 5;
487 /** Fixed value bit 0 - Set to 0. */
488 unsigned u1Fixed0 : 1;
489 /** Fixed value bit 1 - Set to 0. */
490 unsigned u1Fixed1 : 1;
491 /** Fixed value bit 2 - Set to 0. */
492 unsigned u1Fixed2 : 1;
493 /** Fixed value bit 3 - Set to 1. */
494 unsigned u1Fixed3 : 1;
495 /** Fixed value bit 4 - Set to 1. */
496 unsigned u1Fixed4 : 1;
497 /** Fixed value bit 5 - Set to 1. */
498 unsigned u1Fixed5 : 1;
499 /** Gate size, 1 = 32 bits, 0 = 16 bits. */
500 unsigned u132BitGate : 1;
501 /** Fixed value bit 5 - Set to 0. */
502 unsigned u1Fixed6 : 1;
503 /** Descriptor Privilege level. */
504 unsigned u2DPL : 2;
505 /** Present flag. */
506 unsigned u1Present : 1;
507 /** High offset word. */
508 unsigned u16OffsetHigh : 16;
509} VBOXIDTE_TRAPGATE;
510#pragma pack()
511/** Pointer to IDT Entry, Trap Gate view. */
512typedef VBOXIDTE_TRAPGATE *PVBOXIDTE_TRAPGATE;
513
514/** IDT Entry Generic view. */
515#pragma pack(1) /* paranoia */
516typedef struct VBOXIDTE_GENERIC
517{
518 /** Low offset word. */
519 unsigned u16OffsetLow : 16;
520 /** Segment Selector. */
521 unsigned u16SegSel : 16;
522 /** Reserved. */
523 unsigned u5Reserved : 5;
524 /** IDT Type part one (not used for task gate). */
525 unsigned u3Type1 : 3;
526 /** IDT Type part two. */
527 unsigned u5Type2 : 5;
528 /** Descriptor Privilege level. */
529 unsigned u2DPL : 2;
530 /** Present flag. */
531 unsigned u1Present : 1;
532 /** High offset word. */
533 unsigned u16OffsetHigh : 16;
534} VBOXIDTE_GENERIC;
535#pragma pack()
536/** Pointer to IDT Entry Generic view. */
537typedef VBOXIDTE_GENERIC *PVBOXIDTE_GENERIC;
538
539/** IDT Type1 value. (Reserved for task gate!) */
540#define VBOX_IDTE_TYPE1 0
541/** IDT Type2 value - Task gate. */
542#define VBOX_IDTE_TYPE2_TASK 0x5
543/** IDT Type2 value - 16 bit interrupt gate. */
544#define VBOX_IDTE_TYPE2_INT_16 0x6
545/** IDT Type2 value - 32 bit interrupt gate. */
546#define VBOX_IDTE_TYPE2_INT_32 0xe
547/** IDT Type2 value - 16 bit trap gate. */
548#define VBOX_IDTE_TYPE2_TRAP_16 0x7
549/** IDT Type2 value - 32 bit trap gate. */
550#define VBOX_IDTE_TYPE2_TRAP_32 0xf
551
552/** IDT Entry. */
553#pragma pack(1) /* paranoia */
554typedef union VBOXIDTE
555{
556 /** Task gate view. */
557 VBOXIDTE_TASKGATE Task;
558 /** Trap gate view. */
559 VBOXIDTE_TRAPGATE Trap;
560 /** Interrupt gate view. */
561 VBOXIDTE_INTERRUPTGATE Int;
562 /** Generic IDT view. */
563 VBOXIDTE_GENERIC Gen;
564
565 /** 8 bit unsigned integer view. */
566 uint8_t au8[8];
567 /** 16 bit unsigned integer view. */
568 uint16_t au16[4];
569 /** 32 bit unsigned integer view. */
570 uint32_t au32[2];
571 /** 64 bit unsigned integer view. */
572 uint64_t au64;
573} VBOXIDTE;
574#pragma pack()
575/** Pointer to IDT Entry. */
576typedef VBOXIDTE *PVBOXIDTE;
577/** Pointer to IDT Entry. */
578typedef VBOXIDTE const *PCVBOXIDTE;
579
580/** IDT Entry, 64-bit mode, Intertupt gate view. */
581#pragma pack(1) /* paranoia */
582typedef struct VBOXIDTE64_INTERRUPTGATE
583{
584 /** Low offset word. */
585 unsigned u16OffsetLow : 16;
586 /** Segment Selector. */
587 unsigned u16SegSel : 16;
588 /** Interrupt Stack Table Index. */
589 unsigned u3Ist : 3;
590 /** Fixed value bit 0 - Set to 0. */
591 unsigned u1Fixed0 : 1;
592 /** Fixed value bit 1 - Set to 0. */
593 unsigned u1Fixed1 : 1;
594 /** Fixed value bit 2 - Set to 0. */
595 unsigned u1Fixed2 : 1;
596 /** Fixed value bit 3 - Set to 0. */
597 unsigned u1Fixed3 : 1;
598 /** Fixed value bit 4 - Set to 0. */
599 unsigned u1Fixed4 : 1;
600 /** Fixed value bit 5 - Set to 0. */
601 unsigned u1Fixed5 : 1;
602 /** Fixed value bit 6 - Set to 1. */
603 unsigned u1Fixed6 : 1;
604 /** Fixed value bit 7 - Set to 1. */
605 unsigned u1Fixed7 : 1;
606 /** Gate size, 1 = 32 bits, 0 = 16 bits. */
607 unsigned u132BitGate : 1;
608 /** Fixed value bit 5 - Set to 0. */
609 unsigned u1Fixed8 : 1;
610 /** Descriptor Privilege level. */
611 unsigned u2DPL : 2;
612 /** Present flag. */
613 unsigned u1Present : 1;
614 /** High offset word. */
615 unsigned u16OffsetHigh : 16;
616 /** Offset bits 32..63. */
617 unsigned u32OffsetHigh64;
618 /** Reserved. */
619 unsigned u32Reserved;
620} VBOXIDTE64_INTERRUPTGATE;
621#pragma pack()
622/** Pointer to IDT Entry, 64-bit mode, Interrupt gate view. */
623typedef VBOXIDTE64_INTERRUPTGATE *PVBOXIDTE64_INTERRUPTGATE;
624
625/** IDT Entry, 64-bit mode, Trap gate view. */
626#pragma pack(1) /* paranoia */
627typedef struct VBOXIDTE64_TRAPGATE
628{
629 /** Low offset word. */
630 unsigned u16OffsetLow : 16;
631 /** Segment Selector. */
632 unsigned u16SegSel : 16;
633 /** Interrupt Stack Table Index. */
634 unsigned u3Ist : 3;
635 /** Fixed value bit 0 - Set to 0. */
636 unsigned u1Fixed0 : 1;
637 /** Fixed value bit 1 - Set to 0. */
638 unsigned u1Fixed1 : 1;
639 /** Fixed value bit 2 - Set to 0. */
640 unsigned u1Fixed2 : 1;
641 /** Fixed value bit 3 - Set to 0. */
642 unsigned u1Fixed3 : 1;
643 /** Fixed value bit 4 - Set to 0. */
644 unsigned u1Fixed4 : 1;
645 /** Fixed value bit 5 - Set to 1. */
646 unsigned u1Fixed5 : 1;
647 /** Fixed value bit 6 - Set to 1. */
648 unsigned u1Fixed6 : 1;
649 /** Fixed value bit 7 - Set to 1. */
650 unsigned u1Fixed7 : 1;
651 /** Gate size, 1 = 32 bits, 0 = 16 bits. */
652 unsigned u132BitGate : 1;
653 /** Fixed value bit 5 - Set to 0. */
654 unsigned u1Fixed8 : 1;
655 /** Descriptor Privilege level. */
656 unsigned u2DPL : 2;
657 /** Present flag. */
658 unsigned u1Present : 1;
659 /** High offset word. */
660 unsigned u16OffsetHigh : 16;
661 /** Offset bits 32..63. */
662 unsigned u32OffsetHigh64;
663 /** Reserved. */
664 unsigned u32Reserved;
665} VBOXIDTE64_TRAPGATE;
666#pragma pack()
667/** Pointer to IDT Entry, 64-bit mode, Trap gate view. */
668typedef VBOXIDTE64_TRAPGATE *PVBOXIDTE64_TRAPGATE;
669
670/** IDT Entry, 64-bit mode, Generic view. */
671#pragma pack(1) /* paranoia */
672typedef struct VBOXIDTE64_GENERIC
673{
674 /** Low offset word. */
675 unsigned u16OffsetLow : 16;
676 /** Segment Selector. */
677 unsigned u16SegSel : 16;
678 /** Reserved. */
679 unsigned u3Ist : 3;
680 /** Fixed value bit 0 - Set to 0. */
681 unsigned u1Fixed0 : 1;
682 /** Fixed value bit 1 - Set to 0. */
683 unsigned u1Fixed1 : 1;
684 /** IDT Type part one (not used for task gate). */
685 unsigned u3Type1 : 3;
686 /** IDT Type part two. */
687 unsigned u5Type2 : 5;
688 /** Descriptor Privilege level. */
689 unsigned u2DPL : 2;
690 /** Present flag. */
691 unsigned u1Present : 1;
692 /** High offset word. */
693 unsigned u16OffsetHigh : 16;
694 /** Offset bits 32..63. */
695 unsigned u32OffsetHigh64;
696 /** Reserved. */
697 unsigned u32Reserved;
698} VBOXIDTE64_GENERIC;
699#pragma pack()
700/** Pointer to IDT Entry, 64-bit mode, Generic view. */
701typedef VBOXIDTE64_GENERIC *PVBOXIDTE64_GENERIC;
702
703/** IDT Entry, 64-bit mode. */
704#pragma pack(1) /* paranoia */
705typedef union VBOXIDTE64
706{
707 /** Trap gate view. */
708 VBOXIDTE64_TRAPGATE Trap;
709 /** Interrupt gate view. */
710 VBOXIDTE64_INTERRUPTGATE Int;
711 /** Generic IDT view. */
712 VBOXIDTE64_GENERIC Gen;
713
714 /** 8 bit unsigned integer view. */
715 uint8_t au8[16];
716 /** 16 bit unsigned integer view. */
717 uint16_t au16[8];
718 /** 32 bit unsigned integer view. */
719 uint32_t au32[4];
720 /** 64 bit unsigned integer view. */
721 uint64_t au64[2];
722} VBOXIDTE64;
723#pragma pack()
724/** Pointer to IDT Entry. */
725typedef VBOXIDTE64 *PVBOXIDTE64;
726/** Pointer to IDT Entry. */
727typedef VBOXIDTE64 const *PCVBOXIDTE64;
728
729#pragma pack(1)
730/** IDTR */
731typedef struct VBOXIDTR
732{
733 /** Size of the IDT. */
734 uint16_t cbIdt;
735 /** Address of the IDT. */
736 uint64_t pIdt;
737} VBOXIDTR, *PVBOXIDTR;
738#pragma pack()
739
740/** @} */
741
742
743/** @def VBOXIDTE_OFFSET
744 * Return the offset of an IDT entry.
745 */
746#define VBOXIDTE_OFFSET(desc) \
747 ( ((uint32_t)((desc).Gen.u16OffsetHigh) << 16) \
748 | ( (desc).Gen.u16OffsetLow ) )
749
750/** @def VBOXIDTE64_OFFSET
751 * Return the offset of an IDT entry.
752 */
753#define VBOXIDTE64_OFFSET(desc) \
754 ( ((uint64_t)((desc).Gen.u32OffsetHigh64) << 32) \
755 | ((uint32_t)((desc).Gen.u16OffsetHigh) << 16) \
756 | ( (desc).Gen.u16OffsetLow ) )
757
758#pragma pack(1)
759/** GDTR */
760typedef struct VBOXGDTR
761{
762 /** Size of the GDT. */
763 uint16_t cbGdt;
764 /** Address of the GDT. */
765 uint64_t pGdt;
766} VBOXGDTR;
767#pragma pack()
768/** Pointer to GDTR. */
769typedef VBOXGDTR *PVBOXGDTR;
770
771/** @} */
772
773
774/**
775 * 32-bit Task Segment used in raw mode.
776 * @todo Move this to SELM! Use X86TSS32 instead.
777 */
778#pragma pack(1)
779typedef struct VBOXTSS
780{
781 /** 0x00 - Back link to previous task. (static) */
782 RTSEL selPrev;
783 uint16_t padding1;
784 /** 0x04 - Ring-0 stack pointer. (static) */
785 uint32_t esp0;
786 /** 0x08 - Ring-0 stack segment. (static) */
787 RTSEL ss0;
788 uint16_t padding_ss0;
789 /** 0x0c - Ring-1 stack pointer. (static) */
790 uint32_t esp1;
791 /** 0x10 - Ring-1 stack segment. (static) */
792 RTSEL ss1;
793 uint16_t padding_ss1;
794 /** 0x14 - Ring-2 stack pointer. (static) */
795 uint32_t esp2;
796 /** 0x18 - Ring-2 stack segment. (static) */
797 RTSEL ss2;
798 uint16_t padding_ss2;
799 /** 0x1c - Page directory for the task. (static) */
800 uint32_t cr3;
801 /** 0x20 - EIP before task switch. */
802 uint32_t eip;
803 /** 0x24 - EFLAGS before task switch. */
804 uint32_t eflags;
805 /** 0x28 - EAX before task switch. */
806 uint32_t eax;
807 /** 0x2c - ECX before task switch. */
808 uint32_t ecx;
809 /** 0x30 - EDX before task switch. */
810 uint32_t edx;
811 /** 0x34 - EBX before task switch. */
812 uint32_t ebx;
813 /** 0x38 - ESP before task switch. */
814 uint32_t esp;
815 /** 0x3c - EBP before task switch. */
816 uint32_t ebp;
817 /** 0x40 - ESI before task switch. */
818 uint32_t esi;
819 /** 0x44 - EDI before task switch. */
820 uint32_t edi;
821 /** 0x48 - ES before task switch. */
822 RTSEL es;
823 uint16_t padding_es;
824 /** 0x4c - CS before task switch. */
825 RTSEL cs;
826 uint16_t padding_cs;
827 /** 0x50 - SS before task switch. */
828 RTSEL ss;
829 uint16_t padding_ss;
830 /** 0x54 - DS before task switch. */
831 RTSEL ds;
832 uint16_t padding_ds;
833 /** 0x58 - FS before task switch. */
834 RTSEL fs;
835 uint16_t padding_fs;
836 /** 0x5c - GS before task switch. */
837 RTSEL gs;
838 uint16_t padding_gs;
839 /** 0x60 - LDTR before task switch. */
840 RTSEL selLdt;
841 uint16_t padding_ldt;
842 /** 0x64 - Debug trap flag */
843 uint16_t fDebugTrap;
844 /** 0x66 - Offset relative to the TSS of the start of the I/O Bitmap
845 * and the end of the interrupt redirection bitmap. */
846 uint16_t offIoBitmap;
847 /** 0x68 - 32 bytes for the virtual interrupt redirection bitmap. (VME) */
848 uint8_t IntRedirBitmap[32];
849} VBOXTSS;
850#pragma pack()
851/** Pointer to task segment. */
852typedef VBOXTSS *PVBOXTSS;
853/** Pointer to const task segment. */
854typedef const VBOXTSS *PCVBOXTSS;
855
856
857/** Pointer to a callback method table provided by the VM API user. */
858typedef struct VMM2USERMETHODS const *PCVMM2USERMETHODS;
859
860
861/**
862 * Data transport buffer (scatter/gather)
863 */
864typedef struct PDMDATASEG
865{
866 /** Length of buffer in entry. */
867 size_t cbSeg;
868 /** Pointer to the start of the buffer. */
869 void *pvSeg;
870} PDMDATASEG;
871/** Pointer to a data transport segment. */
872typedef PDMDATASEG *PPDMDATASEG;
873/** Pointer to a const data transport segment. */
874typedef PDMDATASEG const *PCPDMDATASEG;
875
876
877/**
878 * Forms of generic segment offloading.
879 */
880typedef enum PDMNETWORKGSOTYPE
881{
882 /** Invalid zero value. */
883 PDMNETWORKGSOTYPE_INVALID = 0,
884 /** TCP/IPv4 - no CWR/ECE encoding. */
885 PDMNETWORKGSOTYPE_IPV4_TCP,
886 /** TCP/IPv6 - no CWR/ECE encoding. */
887 PDMNETWORKGSOTYPE_IPV6_TCP,
888 /** UDP/IPv4. */
889 PDMNETWORKGSOTYPE_IPV4_UDP,
890 /** UDP/IPv6. */
891 PDMNETWORKGSOTYPE_IPV6_UDP,
892 /** TCP/IPv6 over IPv4 tunneling - no CWR/ECE encoding.
893 * The header offsets and sizes relates to IPv4 and TCP, the IPv6 header is
894 * figured out as needed.
895 * @todo Needs checking against facts, this is just an outline of the idea. */
896 PDMNETWORKGSOTYPE_IPV4_IPV6_TCP,
897 /** UDP/IPv6 over IPv4 tunneling.
898 * The header offsets and sizes relates to IPv4 and UDP, the IPv6 header is
899 * figured out as needed.
900 * @todo Needs checking against facts, this is just an outline of the idea. */
901 PDMNETWORKGSOTYPE_IPV4_IPV6_UDP,
902 /** The end of valid GSO types. */
903 PDMNETWORKGSOTYPE_END
904} PDMNETWORKGSOTYPE;
905
906
907/**
908 * Generic segment offloading context.
909 *
910 * We generally follow the E1000 specs wrt to which header fields we change.
911 * However the GSO type implies where the checksum fields are and that they are
912 * always updated from scratch (no half done pseudo checksums).
913 *
914 * @remarks This is part of the internal network GSO packets. Take great care
915 * when making changes. The size is expected to be exactly 8 bytes.
916 */
917typedef struct PDMNETWORKGSO
918{
919 /** The type of segmentation offloading we're performing (PDMNETWORKGSOTYPE). */
920 uint8_t u8Type;
921 /** The total header size. */
922 uint8_t cbHdrsTotal;
923 /** The max segment size (MSS) to apply. */
924 uint16_t cbMaxSeg;
925
926 /** Offset of the first header (IPv4 / IPv6). 0 if not not needed. */
927 uint8_t offHdr1;
928 /** Offset of the second header (TCP / UDP). 0 if not not needed. */
929 uint8_t offHdr2;
930 /** The header size used for segmentation (equal to offHdr2 in UFO). */
931 uint8_t cbHdrsSeg;
932 /** Unused. */
933 uint8_t u8Unused;
934} PDMNETWORKGSO;
935/** Pointer to a GSO context. */
936typedef PDMNETWORKGSO *PPDMNETWORKGSO;
937/** Pointer to a const GSO context. */
938typedef PDMNETWORKGSO const *PCPDMNETWORKGSO;
939
940
941/**
942 * The current ROM page protection.
943 *
944 * @remarks This is part of the saved state.
945 */
946typedef enum PGMROMPROT
947{
948 /** The customary invalid value. */
949 PGMROMPROT_INVALID = 0,
950 /** Read from the virgin ROM page, ignore writes.
951 * Map the virgin page, use write access handler to ignore writes. */
952 PGMROMPROT_READ_ROM_WRITE_IGNORE,
953 /** Read from the virgin ROM page, write to the shadow RAM.
954 * Map the virgin page, use write access handler to change the shadow RAM. */
955 PGMROMPROT_READ_ROM_WRITE_RAM,
956 /** Read from the shadow ROM page, ignore writes.
957 * Map the shadow page read-only, use write access handler to ignore writes. */
958 PGMROMPROT_READ_RAM_WRITE_IGNORE,
959 /** Read from the shadow ROM page, ignore writes.
960 * Map the shadow page read-write, disabled write access handler. */
961 PGMROMPROT_READ_RAM_WRITE_RAM,
962 /** The end of valid values. */
963 PGMROMPROT_END,
964 /** The usual 32-bit type size hack. */
965 PGMROMPROT_32BIT_HACK = 0x7fffffff
966} PGMROMPROT;
967
968
969/**
970 * Page mapping lock.
971 */
972typedef struct PGMPAGEMAPLOCK
973{
974#if defined(IN_RC) || defined(VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R0)
975 /** The locked page. */
976 void *pvPage;
977 /** Pointer to the CPU that made the mapping.
978 * In ring-0 and raw-mode context we don't intend to ever allow long term
979 * locking and this is a way of making sure we're still on the same CPU. */
980 PVMCPU pVCpu;
981#else
982 /** Pointer to the PGMPAGE and lock type.
983 * bit-0 abuse: set=write, clear=read. */
984 uintptr_t uPageAndType;
985/** Read lock type value. */
986# define PGMPAGEMAPLOCK_TYPE_READ ((uintptr_t)0)
987/** Write lock type value. */
988# define PGMPAGEMAPLOCK_TYPE_WRITE ((uintptr_t)1)
989/** Lock type mask. */
990# define PGMPAGEMAPLOCK_TYPE_MASK ((uintptr_t)1)
991 /** Pointer to the PGMCHUNKR3MAP. */
992 void *pvMap;
993#endif
994} PGMPAGEMAPLOCK;
995/** Pointer to a page mapping lock. */
996typedef PGMPAGEMAPLOCK *PPGMPAGEMAPLOCK;
997
998
999/** Pointer to a info helper callback structure. */
1000typedef struct DBGFINFOHLP *PDBGFINFOHLP;
1001/** Pointer to a const info helper callback structure. */
1002typedef const struct DBGFINFOHLP *PCDBGFINFOHLP;
1003
1004/** Pointer to a const register descriptor. */
1005typedef struct DBGFREGDESC const *PCDBGFREGDESC;
1006
1007
1008/** Configuration manager tree node - A key. */
1009typedef struct CFGMNODE *PCFGMNODE;
1010
1011/** Configuration manager tree leaf - A value. */
1012typedef struct CFGMLEAF *PCFGMLEAF;
1013
1014
1015/**
1016 * CPU modes.
1017 */
1018typedef enum CPUMMODE
1019{
1020 /** The usual invalid zero entry. */
1021 CPUMMODE_INVALID = 0,
1022 /** Real mode. */
1023 CPUMMODE_REAL,
1024 /** Protected mode (32-bit). */
1025 CPUMMODE_PROTECTED,
1026 /** Long mode (64-bit). */
1027 CPUMMODE_LONG
1028} CPUMMODE;
1029
1030
1031/**
1032 * CPU mode flags (DISSTATE::mode).
1033 */
1034typedef enum DISCPUMODE
1035{
1036 DISCPUMODE_INVALID = 0,
1037 DISCPUMODE_16BIT,
1038 DISCPUMODE_32BIT,
1039 DISCPUMODE_64BIT,
1040 /** hack forcing the size of the enum to 32-bits. */
1041 DISCPUMODE_MAKE_32BIT_HACK = 0x7fffffff
1042} DISCPUMODE;
1043
1044/** Pointer to the disassembler state. */
1045typedef struct DISSTATE *PDISSTATE;
1046/** Pointer to a const disassembler state. */
1047typedef struct DISSTATE const *PCDISSTATE;
1048
1049/** @deprecated PDISSTATE and change pCpu and pDisState to pDis. */
1050typedef PDISSTATE PDISCPUSTATE;
1051/** @deprecated PCDISSTATE and change pCpu and pDisState to pDis. */
1052typedef PCDISSTATE PCDISCPUSTATE;
1053
1054
1055/** @} */
1056
1057#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