VirtualBox

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

Last change on this file since 63687 was 62476, checked in by vboxsync, 8 years ago

(C) 2016

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