VirtualBox

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

Last change on this file since 78280 was 76585, checked in by vboxsync, 6 years ago

*: scm --fix-header-guard-endif

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