VirtualBox

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

Last change on this file since 30040 was 28800, checked in by vboxsync, 15 years ago

Automated rebranding to Oracle copyright/license strings via filemuncher

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 27.0 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[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/** Tests if a valid CPU ID is present in the set.. */
128#define VMCPUSET_IS_PRESENT(pSet, idCpu) ASMBitTest( &(pSet)->au32Bitmap, (idCpu))
129/** Adds a CPU to the set. */
130#define VMCPUSET_ADD(pSet, idCpu) ASMBitSet( &(pSet)->au32Bitmap, (idCpu))
131/** Deletes a CPU from the set. */
132#define VMCPUSET_DEL(pSet, idCpu) ASMBitClear(&(pSet)->au32Bitmap, (idCpu))
133/** Empties the set. */
134#define VMCPUSET_EMPTY(pSet) memset(&(pSet)->au32Bitmap[0], '\0', sizeof((pSet)->au32Bitmap))
135/** Filles the set. */
136#define VMCPUSET_FILL(pSet) memset(&(pSet)->au32Bitmap[0], 0xff, sizeof((pSet)->au32Bitmap))
137/** Filles the set. */
138#define VMCPUSET_IS_EQUAL(pSet1, pSet2) (memcmp(&(pSet1)->au32Bitmap[0], &(pSet2)->au32Bitmap[0], sizeof((pSet1)->au32Bitmap)) == 0)
139
140
141/**
142 * VM State
143 */
144typedef enum VMSTATE
145{
146 /** The VM is being created. */
147 VMSTATE_CREATING = 0,
148 /** The VM is created. */
149 VMSTATE_CREATED,
150 /** The VM state is being loaded from file. */
151 VMSTATE_LOADING,
152 /** The VM is being powered on */
153 VMSTATE_POWERING_ON,
154 /** The VM is being resumed. */
155 VMSTATE_RESUMING,
156 /** The VM is runnning. */
157 VMSTATE_RUNNING,
158 /** Live save: The VM is running and the state is being saved. */
159 VMSTATE_RUNNING_LS,
160 /** The VM is being reset. */
161 VMSTATE_RESETTING,
162 /** Live save: The VM is being reset and immediately suspended. */
163 VMSTATE_RESETTING_LS,
164 /** The VM is being suspended. */
165 VMSTATE_SUSPENDING,
166 /** Live save: The VM is being suspended during a live save operation, either as
167 * part of the normal flow or VMR3Reset. */
168 VMSTATE_SUSPENDING_LS,
169 /** Live save: The VM is being suspended by VMR3Suspend during live save. */
170 VMSTATE_SUSPENDING_EXT_LS,
171 /** The VM is suspended. */
172 VMSTATE_SUSPENDED,
173 /** Live save: The VM has been suspended and is waiting for the live save
174 * operation to move on. */
175 VMSTATE_SUSPENDED_LS,
176 /** Live save: The VM has been suspended by VMR3Suspend during a live save. */
177 VMSTATE_SUSPENDED_EXT_LS,
178 /** The VM is suspended and its state is being saved by EMT(0). (See SSM) */
179 VMSTATE_SAVING,
180 /** The VM is being debugged. (See DBGF.) */
181 VMSTATE_DEBUGGING,
182 /** Live save: The VM is being debugged while the live phase is going on. */
183 VMSTATE_DEBUGGING_LS,
184 /** The VM is being powered off. */
185 VMSTATE_POWERING_OFF,
186 /** Live save: The VM is being powered off and the save cancelled. */
187 VMSTATE_POWERING_OFF_LS,
188 /** The VM is switched off, awaiting destruction. */
189 VMSTATE_OFF,
190 /** Live save: Waiting for cancellation and transition to VMSTATE_OFF. */
191 VMSTATE_OFF_LS,
192 /** The VM is powered off because of a fatal error. */
193 VMSTATE_FATAL_ERROR,
194 /** Live save: Waiting for cancellation and transition to FatalError. */
195 VMSTATE_FATAL_ERROR_LS,
196 /** The VM is in guru meditation over a fatal failure. */
197 VMSTATE_GURU_MEDITATION,
198 /** Live save: Waiting for cancellation and transition to GuruMeditation. */
199 VMSTATE_GURU_MEDITATION_LS,
200 /** The VM is screwed because of a failed state loading. */
201 VMSTATE_LOAD_FAILURE,
202 /** The VM is being destroyed. */
203 VMSTATE_DESTROYING,
204 /** Terminated. */
205 VMSTATE_TERMINATED,
206 /** hack forcing the size of the enum to 32-bits. */
207 VMSTATE_MAKE_32BIT_HACK = 0x7fffffff
208} VMSTATE;
209
210/** @def VBOXSTRICTRC_STRICT_ENABLED
211 * Indicates that VBOXSTRICTRC is in strict mode.
212 */
213#if defined(__cplusplus) \
214 && ARCH_BITS == 64 /* cdecl requires classes and structs as hidden params. */ \
215 && !defined(_MSC_VER) /* trouble similar to 32-bit gcc. */ \
216 && ( defined(RT_STRICT) \
217 || defined(VBOX_STRICT) \
218 || defined(DEBUG) \
219 || defined(DOXYGEN_RUNNING) )
220# define VBOXSTRICTRC_STRICT_ENABLED 1
221# ifdef _MSC_VER
222# pragma warning(disable:4190)
223# endif
224#endif
225
226/** We need RTERR_STRICT_RC. */
227#if defined(VBOXSTRICTRC_STRICT_ENABLED) && !defined(RTERR_STRICT_RC)
228# define RTERR_STRICT_RC 1
229#endif
230
231/**
232 * Strict VirtualBox status code.
233 *
234 * This is normally an 32-bit integer and the only purpose of the type is to
235 * highlight the special handling that is required. But in strict build it is a
236 * class that causes compilation and runtime errors for some of the incorrect
237 * handling.
238 */
239#ifdef VBOXSTRICTRC_STRICT_ENABLED
240struct VBOXSTRICTRC
241{
242protected:
243 /** The status code. */
244 int32_t m_rc;
245
246public:
247 /** Default constructor setting the status to VERR_IPE_UNINITIALIZED_STATUS. */
248 VBOXSTRICTRC()
249#ifdef VERR_IPE_UNINITIALIZED_STATUS
250 : m_rc(VERR_IPE_UNINITIALIZED_STATUS)
251#else
252 : m_rc(-233 /*VERR_IPE_UNINITIALIZED_STATUS*/)
253#endif
254 {
255 }
256
257 /** Constructor for normal integer status codes. */
258 VBOXSTRICTRC(int32_t const rc)
259 : m_rc(rc)
260 {
261 }
262
263 /** Getter that VBOXSTRICTRC_VAL can use. */
264 int32_t getValue() const { return m_rc; }
265
266 /** @name Comparison operators
267 * @{ */
268 bool operator==(int32_t rc) const { return m_rc == rc; }
269 bool operator!=(int32_t rc) const { return m_rc != rc; }
270 bool operator<=(int32_t rc) const { return m_rc <= rc; }
271 bool operator>=(int32_t rc) const { return m_rc >= rc; }
272 bool operator<(int32_t rc) const { return m_rc < rc; }
273 bool operator>(int32_t rc) const { return m_rc > rc; }
274 /** @} */
275
276 /** Special automatic cast for RT_SUCCESS_NP. */
277 operator RTErrStrictType2() const { return RTErrStrictType2(m_rc); }
278
279private:
280 /** @name Constructors that will prevent some of the bad types.
281 * @{ */
282 VBOXSTRICTRC(uint8_t rc) : m_rc(-999) { NOREF(rc); }
283 VBOXSTRICTRC(uint16_t rc) : m_rc(-999) { NOREF(rc); }
284 VBOXSTRICTRC(uint32_t rc) : m_rc(-999) { NOREF(rc); }
285 VBOXSTRICTRC(uint64_t rc) : m_rc(-999) { NOREF(rc); }
286
287 VBOXSTRICTRC(int8_t rc) : m_rc(-999) { NOREF(rc); }
288 VBOXSTRICTRC(int16_t rc) : m_rc(-999) { NOREF(rc); }
289 VBOXSTRICTRC(int64_t rc) : m_rc(-999) { NOREF(rc); }
290 /** @} */
291};
292#else
293typedef int32_t VBOXSTRICTRC;
294#endif
295
296/** @def VBOXSTRICTRC_VAL
297 * Explicit getter.
298 * @param rcStrict The strict VirtualBox status code.
299 */
300#ifdef VBOXSTRICTRC_STRICT_ENABLED
301# define VBOXSTRICTRC_VAL(rcStrict) ( (rcStrict).getValue() )
302#else
303# define VBOXSTRICTRC_VAL(rcStrict) (rcStrict)
304#endif
305
306/** @def VBOXSTRICTRC_TODO
307 * Returns that needs dealing with.
308 * @param rcStrict The strict VirtualBox status code.
309 */
310#define VBOXSTRICTRC_TODO(rcStrict) VBOXSTRICTRC_VAL(rcStrict)
311
312
313/** Pointer to a PDM Base Interface. */
314typedef struct PDMIBASE *PPDMIBASE;
315/** Pointer to a pointer to a PDM Base Interface. */
316typedef PPDMIBASE *PPPDMIBASE;
317
318/** Pointer to a PDM Device Instance. */
319typedef struct PDMDEVINS *PPDMDEVINS;
320/** Pointer to a pointer to a PDM Device Instance. */
321typedef PPDMDEVINS *PPPDMDEVINS;
322/** R3 pointer to a PDM Device Instance. */
323typedef R3PTRTYPE(PPDMDEVINS) PPDMDEVINSR3;
324/** R0 pointer to a PDM Device Instance. */
325typedef R0PTRTYPE(PPDMDEVINS) PPDMDEVINSR0;
326/** RC pointer to a PDM Device Instance. */
327typedef RCPTRTYPE(PPDMDEVINS) PPDMDEVINSRC;
328
329/** Pointer to a PDM USB Device Instance. */
330typedef struct PDMUSBINS *PPDMUSBINS;
331/** Pointer to a pointer to a PDM USB Device Instance. */
332typedef PPDMUSBINS *PPPDMUSBINS;
333
334/** Pointer to a PDM Driver Instance. */
335typedef struct PDMDRVINS *PPDMDRVINS;
336/** Pointer to a pointer to a PDM Driver Instance. */
337typedef PPDMDRVINS *PPPDMDRVINS;
338/** R3 pointer to a PDM Driver Instance. */
339typedef R3PTRTYPE(PPDMDRVINS) PPDMDRVINSR3;
340/** R0 pointer to a PDM Driver Instance. */
341typedef R0PTRTYPE(PPDMDRVINS) PPDMDRVINSR0;
342/** RC pointer to a PDM Driver Instance. */
343typedef RCPTRTYPE(PPDMDRVINS) PPDMDRVINSRC;
344
345/** Pointer to a PDM Service Instance. */
346typedef struct PDMSRVINS *PPDMSRVINS;
347/** Pointer to a pointer to a PDM Service Instance. */
348typedef PPDMSRVINS *PPPDMSRVINS;
349
350/** Pointer to a PDM critical section. */
351typedef union PDMCRITSECT *PPDMCRITSECT;
352/** Pointer to a const PDM critical section. */
353typedef const union PDMCRITSECT *PCPDMCRITSECT;
354
355/** R3 pointer to a timer. */
356typedef R3PTRTYPE(struct TMTIMER *) PTMTIMERR3;
357/** Pointer to a R3 pointer to a timer. */
358typedef PTMTIMERR3 *PPTMTIMERR3;
359
360/** R0 pointer to a timer. */
361typedef R0PTRTYPE(struct TMTIMER *) PTMTIMERR0;
362/** Pointer to a R3 pointer to a timer. */
363typedef PTMTIMERR0 *PPTMTIMERR0;
364
365/** RC pointer to a timer. */
366typedef RCPTRTYPE(struct TMTIMER *) PTMTIMERRC;
367/** Pointer to a RC pointer to a timer. */
368typedef PTMTIMERRC *PPTMTIMERRC;
369
370/** Pointer to a timer. */
371typedef CTX_SUFF(PTMTIMER) PTMTIMER;
372/** Pointer to a pointer to a timer. */
373typedef PTMTIMER *PPTMTIMER;
374
375/** SSM Operation handle. */
376typedef struct SSMHANDLE *PSSMHANDLE;
377/** Pointer to a const SSM stream method table. */
378typedef struct SSMSTRMOPS const *PCSSMSTRMOPS;
379
380/** Pointer to a CPUMCTX. */
381typedef struct CPUMCTX *PCPUMCTX;
382/** Pointer to a const CPUMCTX. */
383typedef const struct CPUMCTX *PCCPUMCTX;
384
385/** Pointer to a CPU context core. */
386typedef struct CPUMCTXCORE *PCPUMCTXCORE;
387/** Pointer to a const CPU context core. */
388typedef const struct CPUMCTXCORE *PCCPUMCTXCORE;
389
390/** Pointer to selector hidden registers. */
391typedef struct CPUMSELREGHID *PCPUMSELREGHID;
392/** Pointer to const selector hidden registers. */
393typedef const struct CPUMSELREGHID *PCCPUMSELREGHID;
394
395/** @} */
396
397
398/** @defgroup grp_types_idt Interrupt Descriptor Table Entry.
399 * @ingroup grp_types
400 * @todo This all belongs in x86.h!
401 * @{ */
402
403/** @todo VBOXIDT -> VBOXDESCIDT, skip the complex variations. We'll never use them. */
404
405/** IDT Entry, Task Gate view. */
406#pragma pack(1) /* paranoia */
407typedef struct VBOXIDTE_TASKGATE
408{
409 /** Reserved. */
410 unsigned u16Reserved1 : 16;
411 /** Task Segment Selector. */
412 unsigned u16TSS : 16;
413 /** More reserved. */
414 unsigned u8Reserved2 : 8;
415 /** Fixed value bit 0 - Set to 1. */
416 unsigned u1Fixed0 : 1;
417 /** Busy bit. */
418 unsigned u1Busy : 1;
419 /** Fixed value bit 2 - Set to 1. */
420 unsigned u1Fixed1 : 1;
421 /** Fixed value bit 3 - Set to 0. */
422 unsigned u1Fixed2: 1;
423 /** Fixed value bit 4 - Set to 0. */
424 unsigned u1Fixed3 : 1;
425 /** Descriptor Privilege level. */
426 unsigned u2DPL : 2;
427 /** Present flag. */
428 unsigned u1Present : 1;
429 /** Reserved. */
430 unsigned u16Reserved3 : 16;
431} VBOXIDTE_TASKGATE;
432#pragma pack()
433/** Pointer to IDT Entry, Task gate view. */
434typedef VBOXIDTE_TASKGATE *PVBOXIDTE_TASKGATE;
435
436
437/** IDT Entry, Intertupt gate view. */
438#pragma pack(1) /* paranoia */
439typedef struct VBOXIDTE_INTERRUPTGATE
440{
441 /** Low offset word. */
442 unsigned u16OffsetLow : 16;
443 /** Segment Selector. */
444 unsigned u16SegSel : 16;
445 /** Reserved. */
446 unsigned u5Reserved2 : 5;
447 /** Fixed value bit 0 - Set to 0. */
448 unsigned u1Fixed0 : 1;
449 /** Fixed value bit 1 - Set to 0. */
450 unsigned u1Fixed1 : 1;
451 /** Fixed value bit 2 - Set to 0. */
452 unsigned u1Fixed2 : 1;
453 /** Fixed value bit 3 - Set to 0. */
454 unsigned u1Fixed3: 1;
455 /** Fixed value bit 4 - Set to 1. */
456 unsigned u1Fixed4 : 1;
457 /** Fixed value bit 5 - Set to 1. */
458 unsigned u1Fixed5 : 1;
459 /** Gate size, 1 = 32 bits, 0 = 16 bits. */
460 unsigned u132BitGate : 1;
461 /** Fixed value bit 5 - Set to 0. */
462 unsigned u1Fixed6 : 1;
463 /** Descriptor Privilege level. */
464 unsigned u2DPL : 2;
465 /** Present flag. */
466 unsigned u1Present : 1;
467 /** High offset word. */
468 unsigned u16OffsetHigh : 16;
469} VBOXIDTE_INTERRUPTGATE;
470#pragma pack()
471/** Pointer to IDT Entry, Interrupt gate view. */
472typedef VBOXIDTE_INTERRUPTGATE *PVBOXIDTE_INTERRUPTGATE;
473
474/** IDT Entry, Trap Gate view. */
475#pragma pack(1) /* paranoia */
476typedef struct VBOXIDTE_TRAPGATE
477{
478 /** Low offset word. */
479 unsigned u16OffsetLow : 16;
480 /** Segment Selector. */
481 unsigned u16SegSel : 16;
482 /** Reserved. */
483 unsigned u5Reserved2 : 5;
484 /** Fixed value bit 0 - Set to 0. */
485 unsigned u1Fixed0 : 1;
486 /** Fixed value bit 1 - Set to 0. */
487 unsigned u1Fixed1 : 1;
488 /** Fixed value bit 2 - Set to 0. */
489 unsigned u1Fixed2 : 1;
490 /** Fixed value bit 3 - Set to 1. */
491 unsigned u1Fixed3: 1;
492 /** Fixed value bit 4 - Set to 1. */
493 unsigned u1Fixed4 : 1;
494 /** Fixed value bit 5 - Set to 1. */
495 unsigned u1Fixed5 : 1;
496 /** Gate size, 1 = 32 bits, 0 = 16 bits. */
497 unsigned u132BitGate : 1;
498 /** Fixed value bit 5 - Set to 0. */
499 unsigned u1Fixed6 : 1;
500 /** Descriptor Privilege level. */
501 unsigned u2DPL : 2;
502 /** Present flag. */
503 unsigned u1Present : 1;
504 /** High offset word. */
505 unsigned u16OffsetHigh : 16;
506} VBOXIDTE_TRAPGATE;
507#pragma pack()
508/** Pointer to IDT Entry, Trap Gate view. */
509typedef VBOXIDTE_TRAPGATE *PVBOXIDTE_TRAPGATE;
510
511/** IDT Entry Generic view. */
512#pragma pack(1) /* paranoia */
513typedef struct VBOXIDTE_GENERIC
514{
515 /** Low offset word. */
516 unsigned u16OffsetLow : 16;
517 /** Segment Selector. */
518 unsigned u16SegSel : 16;
519 /** Reserved. */
520 unsigned u5Reserved : 5;
521 /** IDT Type part one (not used for task gate). */
522 unsigned u3Type1 : 3;
523 /** IDT Type part two. */
524 unsigned u5Type2 : 5;
525 /** Descriptor Privilege level. */
526 unsigned u2DPL : 2;
527 /** Present flag. */
528 unsigned u1Present : 1;
529 /** High offset word. */
530 unsigned u16OffsetHigh : 16;
531} VBOXIDTE_GENERIC;
532#pragma pack()
533/** Pointer to IDT Entry Generic view. */
534typedef VBOXIDTE_GENERIC *PVBOXIDTE_GENERIC;
535
536/** IDT Type1 value. (Reserved for task gate!) */
537#define VBOX_IDTE_TYPE1 0
538/** IDT Type2 value - Task gate. */
539#define VBOX_IDTE_TYPE2_TASK 0x5
540/** IDT Type2 value - 16 bit interrupt gate. */
541#define VBOX_IDTE_TYPE2_INT_16 0x6
542/** IDT Type2 value - 32 bit interrupt gate. */
543#define VBOX_IDTE_TYPE2_INT_32 0xe
544/** IDT Type2 value - 16 bit trap gate. */
545#define VBOX_IDTE_TYPE2_TRAP_16 0x7
546/** IDT Type2 value - 32 bit trap gate. */
547#define VBOX_IDTE_TYPE2_TRAP_32 0xf
548
549/** IDT Entry. */
550#pragma pack(1) /* paranoia */
551typedef union VBOXIDTE
552{
553 /** Task gate view. */
554 VBOXIDTE_TASKGATE Task;
555 /** Trap gate view. */
556 VBOXIDTE_TRAPGATE Trap;
557 /** Interrupt gate view. */
558 VBOXIDTE_INTERRUPTGATE Int;
559 /** Generic IDT view. */
560 VBOXIDTE_GENERIC Gen;
561
562 /** 8 bit unsigned integer view. */
563 uint8_t au8[8];
564 /** 16 bit unsigned integer view. */
565 uint16_t au16[4];
566 /** 32 bit unsigned integer view. */
567 uint32_t au32[2];
568 /** 64 bit unsigned integer view. */
569 uint64_t au64;
570} VBOXIDTE;
571#pragma pack()
572/** Pointer to IDT Entry. */
573typedef VBOXIDTE *PVBOXIDTE;
574/** Pointer to IDT Entry. */
575typedef VBOXIDTE const *PCVBOXIDTE;
576
577#pragma pack(1)
578/** IDTR */
579typedef struct VBOXIDTR
580{
581 /** Size of the IDT. */
582 uint16_t cbIdt;
583 /** Address of the IDT. */
584 uint64_t pIdt;
585} VBOXIDTR, *PVBOXIDTR;
586#pragma pack()
587
588#pragma pack(1)
589/** IDTR from version 1.6 */
590typedef struct VBOXIDTR_VER1_6
591{
592 /** Size of the IDT. */
593 uint16_t cbIdt;
594 /** Address of the IDT. */
595 uint32_t pIdt;
596} VBOXIDTR_VER1_6, *PVBOXIDTR_VER1_6;
597#pragma pack()
598
599/** @} */
600
601
602/** @def VBOXIDTE_OFFSET
603 * Return the offset of an IDT entry.
604 */
605#define VBOXIDTE_OFFSET(desc) \
606 ( ((uint32_t)((desc).Gen.u16OffsetHigh) << 16) \
607 | ( (desc).Gen.u16OffsetLow ) )
608
609#pragma pack(1)
610/** GDTR */
611typedef struct VBOXGDTR
612{
613 /** Size of the GDT. */
614 uint16_t cbGdt;
615 /** Address of the GDT. */
616 uint64_t pGdt;
617} VBOXGDTR;
618#pragma pack()
619/** Pointer to GDTR. */
620typedef VBOXGDTR *PVBOXGDTR;
621
622#pragma pack(1)
623/** GDTR from version 1.6 */
624typedef struct VBOXGDTR_VER1_6
625{
626 /** Size of the GDT. */
627 uint16_t cbGdt;
628 /** Address of the GDT. */
629 uint32_t pGdt;
630} VBOXGDTR_VER1_6;
631#pragma pack()
632
633/** @} */
634
635
636/**
637 * 32-bit Task Segment used in raw mode.
638 * @todo Move this to SELM! Use X86TSS32 instead.
639 */
640#pragma pack(1)
641typedef struct VBOXTSS
642{
643 /** 0x00 - Back link to previous task. (static) */
644 RTSEL selPrev;
645 uint16_t padding1;
646 /** 0x04 - Ring-0 stack pointer. (static) */
647 uint32_t esp0;
648 /** 0x08 - Ring-0 stack segment. (static) */
649 RTSEL ss0;
650 uint16_t padding_ss0;
651 /** 0x0c - Ring-1 stack pointer. (static) */
652 uint32_t esp1;
653 /** 0x10 - Ring-1 stack segment. (static) */
654 RTSEL ss1;
655 uint16_t padding_ss1;
656 /** 0x14 - Ring-2 stack pointer. (static) */
657 uint32_t esp2;
658 /** 0x18 - Ring-2 stack segment. (static) */
659 RTSEL ss2;
660 uint16_t padding_ss2;
661 /** 0x1c - Page directory for the task. (static) */
662 uint32_t cr3;
663 /** 0x20 - EIP before task switch. */
664 uint32_t eip;
665 /** 0x24 - EFLAGS before task switch. */
666 uint32_t eflags;
667 /** 0x28 - EAX before task switch. */
668 uint32_t eax;
669 /** 0x2c - ECX before task switch. */
670 uint32_t ecx;
671 /** 0x30 - EDX before task switch. */
672 uint32_t edx;
673 /** 0x34 - EBX before task switch. */
674 uint32_t ebx;
675 /** 0x38 - ESP before task switch. */
676 uint32_t esp;
677 /** 0x3c - EBP before task switch. */
678 uint32_t ebp;
679 /** 0x40 - ESI before task switch. */
680 uint32_t esi;
681 /** 0x44 - EDI before task switch. */
682 uint32_t edi;
683 /** 0x48 - ES before task switch. */
684 RTSEL es;
685 uint16_t padding_es;
686 /** 0x4c - CS before task switch. */
687 RTSEL cs;
688 uint16_t padding_cs;
689 /** 0x50 - SS before task switch. */
690 RTSEL ss;
691 uint16_t padding_ss;
692 /** 0x54 - DS before task switch. */
693 RTSEL ds;
694 uint16_t padding_ds;
695 /** 0x58 - FS before task switch. */
696 RTSEL fs;
697 uint16_t padding_fs;
698 /** 0x5c - GS before task switch. */
699 RTSEL gs;
700 uint16_t padding_gs;
701 /** 0x60 - LDTR before task switch. */
702 RTSEL selLdt;
703 uint16_t padding_ldt;
704 /** 0x64 - Debug trap flag */
705 uint16_t fDebugTrap;
706 /** 0x66 - Offset relative to the TSS of the start of the I/O Bitmap
707 * and the end of the interrupt redirection bitmap. */
708 uint16_t offIoBitmap;
709 /** 0x68 - 32 bytes for the virtual interrupt redirection bitmap. (VME) */
710 uint8_t IntRedirBitmap[32];
711} VBOXTSS;
712#pragma pack()
713/** Pointer to task segment. */
714typedef VBOXTSS *PVBOXTSS;
715/** Pointer to const task segment. */
716typedef const VBOXTSS *PCVBOXTSS;
717
718
719/**
720 * Data transport buffer (scatter/gather)
721 */
722typedef struct PDMDATASEG
723{
724 /** Length of buffer in entry. */
725 size_t cbSeg;
726 /** Pointer to the start of the buffer. */
727 void *pvSeg;
728} PDMDATASEG;
729/** Pointer to a data transport segment. */
730typedef PDMDATASEG *PPDMDATASEG;
731/** Pointer to a const data transport segment. */
732typedef PDMDATASEG const *PCPDMDATASEG;
733
734
735/**
736 * Forms of generic segment offloading.
737 */
738typedef enum PDMNETWORKGSOTYPE
739{
740 /** Invalid zero value. */
741 PDMNETWORKGSOTYPE_INVALID = 0,
742 /** TCP/IPv4 - no CWR/ECE encoding. */
743 PDMNETWORKGSOTYPE_IPV4_TCP,
744 /** TCP/IPv6 - no CWR/ECE encoding. */
745 PDMNETWORKGSOTYPE_IPV6_TCP,
746 /** UDP/IPv4. */
747 PDMNETWORKGSOTYPE_IPV4_UDP,
748 /** UDP/IPv6. */
749 PDMNETWORKGSOTYPE_IPV6_UDP,
750 /** TCP/IPv6 over IPv4 tunneling - no CWR/ECE encoding.
751 * The header offsets and sizes relates to IPv4 and TCP, the IPv6 header is
752 * figured out as needed.
753 * @todo Needs checking against facts, this is just an outline of the idea. */
754 PDMNETWORKGSOTYPE_IPV4_IPV6_TCP,
755 /** UDP/IPv6 over IPv4 tunneling.
756 * The header offsets and sizes relates to IPv4 and UDP, the IPv6 header is
757 * figured out as needed.
758 * @todo Needs checking against facts, this is just an outline of the idea. */
759 PDMNETWORKGSOTYPE_IPV4_IPV6_UDP,
760 /** The end of valid GSO types. */
761 PDMNETWORKGSOTYPE_END
762} PDMNETWORKGSOTYPE;
763
764
765/**
766 * Generic segment offloading context.
767 *
768 * We generally follow the E1000 specs wrt to which header fields we change.
769 * However the GSO type implies where the checksum fields are and that they are
770 * always updated from scratch (no half done pseudo checksums).
771 *
772 * @remarks This is part of the internal network GSO packets. Take great care
773 * when making changes. The size is expected to be exactly 8 bytes.
774 */
775typedef struct PDMNETWORKGSO
776{
777 /** The type of segmentation offloading we're performing (PDMNETWORKGSOTYPE). */
778 uint8_t u8Type;
779 /** The total header size. */
780 uint8_t cbHdrs;
781 /** The max segment size (MSS) to apply. */
782 uint16_t cbMaxSeg;
783
784 /** Offset of the first header (IPv4 / IPv6). 0 if not not needed. */
785 uint8_t offHdr1;
786 /** Offset of the second header (TCP / UDP). 0 if not not needed. */
787 uint8_t offHdr2;
788 /** Unused. */
789 uint8_t au8Unused[2];
790} PDMNETWORKGSO;
791/** Pointer to a GSO context. */
792typedef PDMNETWORKGSO *PPDMNETWORKGSO;
793/** Pointer to a const GSO context. */
794typedef PDMNETWORKGSO const *PCPDMNETWORKGSO;
795
796
797/**
798 * The current ROM page protection.
799 *
800 * @remarks This is part of the saved state.
801 */
802typedef enum PGMROMPROT
803{
804 /** The customary invalid value. */
805 PGMROMPROT_INVALID = 0,
806 /** Read from the virgin ROM page, ignore writes.
807 * Map the virgin page, use write access handler to ignore writes. */
808 PGMROMPROT_READ_ROM_WRITE_IGNORE,
809 /** Read from the virgin ROM page, write to the shadow RAM.
810 * Map the virgin page, use write access handler change the RAM. */
811 PGMROMPROT_READ_ROM_WRITE_RAM,
812 /** Read from the shadow ROM page, ignore writes.
813 * Map the shadow page read-only, use write access handler to ignore writes. */
814 PGMROMPROT_READ_RAM_WRITE_IGNORE,
815 /** Read from the shadow ROM page, ignore writes.
816 * Map the shadow page read-write, disabled write access handler. */
817 PGMROMPROT_READ_RAM_WRITE_RAM,
818 /** The end of valid values. */
819 PGMROMPROT_END,
820 /** The usual 32-bit type size hack. */
821 PGMROMPROT_32BIT_HACK = 0x7fffffff
822} PGMROMPROT;
823
824
825/**
826 * Page mapping lock.
827 *
828 * @remarks This doesn't work in structures shared between
829 * ring-3, ring-0 and/or GC.
830 */
831typedef struct PGMPAGEMAPLOCK
832{
833 /** @todo see PGMPhysIsPageMappingLockValid for possibly incorrect assumptions */
834#if defined(IN_RC) || defined(VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R0)
835 /** Just a dummy for the time being. */
836 uint32_t u32Dummy;
837#else
838 /** Pointer to the PGMPAGE and lock type.
839 * bit-0 abuse: set=write, clear=read. */
840 uintptr_t uPageAndType;
841/** Read lock type value. */
842# define PGMPAGEMAPLOCK_TYPE_READ ((uintptr_t)0)
843/** Write lock type value. */
844# define PGMPAGEMAPLOCK_TYPE_WRITE ((uintptr_t)1)
845/** Lock type mask. */
846# define PGMPAGEMAPLOCK_TYPE_MASK ((uintptr_t)1)
847 /** Pointer to the PGMCHUNKR3MAP. */
848 void *pvMap;
849#endif
850} PGMPAGEMAPLOCK;
851/** Pointer to a page mapping lock. */
852typedef PGMPAGEMAPLOCK *PPGMPAGEMAPLOCK;
853
854
855/** Configuration manager tree node - A key. */
856typedef struct CFGMNODE *PCFGMNODE;
857
858/** Configuration manager tree leaf - A value. */
859typedef struct CFGMLEAF *PCFGMLEAF;
860
861/**
862 * CPU modes.
863 */
864typedef enum CPUMMODE
865{
866 /** The usual invalid zero entry. */
867 CPUMMODE_INVALID = 0,
868 /** Real mode. */
869 CPUMMODE_REAL,
870 /** Protected mode (32-bit). */
871 CPUMMODE_PROTECTED,
872 /** Long mode (64-bit). */
873 CPUMMODE_LONG
874} CPUMMODE;
875
876/** @} */
877
878#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