VirtualBox

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

Last change on this file since 55966 was 55966, checked in by vboxsync, 10 years ago

PGM,++: VBOXSTRICTRC for physical access handlers.

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