VirtualBox

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

Last change on this file since 72358 was 71222, checked in by vboxsync, 7 years ago

NEM/win,VMM,PGM: Ported NEM runloop to ring-0. bugref:9044

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