VirtualBox

source: vbox/trunk/src/VBox/VMM/TRPMInternal.h@ 113

Last change on this file since 113 was 23, checked in by vboxsync, 18 years ago

string.h & stdio.h + header cleanups.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 5.6 KB
Line 
1/* $Id: TRPMInternal.h 23 2007-01-15 14:08:28Z vboxsync $ */
2/** @file
3 * TRPM - Internal header file.
4 */
5
6/*
7 * Copyright (C) 2006 InnoTek Systemberatung GmbH
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License as published by the Free Software Foundation,
13 * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
14 * distribution. VirtualBox OSE is distributed in the hope that it will
15 * be useful, but WITHOUT ANY WARRANTY of any kind.
16 *
17 * If you received this file as part of a commercial VirtualBox
18 * distribution, then only the terms of your commercial VirtualBox
19 * license agreement apply instead of the previous paragraph.
20 */
21
22#ifndef __TRPMInternal_h__
23#define __TRPMInternal_h__
24
25#include <VBox/cdefs.h>
26#include <VBox/types.h>
27#include <VBox/stam.h>
28#include <VBox/cpum.h>
29
30
31#if !defined(IN_TRPM_R3) && !defined(IN_TRPM_R0) && !defined(IN_TRPM_GC)
32# error "Not in TRPM! This is an internal header!"
33#endif
34
35/* Enable to allow trap forwarding in GC. */
36#define TRPM_FORWARD_TRAPS_IN_GC
37
38__BEGIN_DECLS
39
40
41/** @defgroup grp_trpm_int Internals
42 * @ingroup grp_trpm
43 * @internal
44 * @{
45 */
46
47/** @name TRPMGCTrapIn* flags.
48 * The lower bits are offsets into the CPUMCTXCORE structure.
49 * @{ */
50/** The mask for the operation. */
51#define TRPM_TRAP_IN_OP_MASK 0xffff
52/** Traps on MOV GS, eax. */
53#define TRPM_TRAP_IN_MOV_GS 1
54/** Traps on MOV FS, eax. */
55#define TRPM_TRAP_IN_MOV_FS 2
56/** Traps on MOV ES, eax. */
57#define TRPM_TRAP_IN_MOV_ES 3
58/** Traps on MOV DS, eax. */
59#define TRPM_TRAP_IN_MOV_DS 4
60/** Traps on IRET. */
61#define TRPM_TRAP_IN_IRET 5
62/** Set if this is a V86 resume. */
63#define TRPM_TRAP_IN_V86 BIT(30)
64/** If set this is a hypervisor register set. If cleared it's a guest set. */
65#define TRPM_TRAP_IN_HYPER BIT(31)
66/** @} */
67
68
69/**
70 * Converts a TRPM pointer into a VM pointer.
71 * @returns Pointer to the VM structure the TRPM is part of.
72 * @param pTRPM Pointer to TRPM instance data.
73 */
74#define TRPM2VM(pTRPM) ( (PVM)((char*)pTRPM - pTRPM->offVM) )
75
76
77/**
78 * TRPM Data (part of VM)
79 *
80 * IMPORTANT! Keep the nasm version of this struct up-to-date.
81 */
82#pragma pack(4)
83typedef struct TRPM
84{
85 /** Offset to the VM structure.
86 * See TRPM2VM(). */
87 RTINT offVM;
88
89 /** Active Interrupt or trap vector number.
90 * If not ~0U this indicates that we're currently processing
91 * a interrupt, trap, fault, abort, whatever which have arrived
92 * at that vector number.
93 */
94 RTUINT uActiveVector;
95
96 /** If set the active trap is a software interrupt. */
97 RTUINT fActiveSoftwareInterrupt;
98
99 /** Errorcode for the active interrupt/trap. */
100 RTGCUINT uActiveErrorCode;
101
102 /** CR2 at the time of the active exception. */
103 RTGCUINTPTR uActiveCR2;
104
105 /** Saved trap vector number. */
106 RTGCUINT uSavedVector;
107
108 /** Saved software interrupt indicator. */
109 RTUINT fSavedSoftwareInterrupt;
110
111 /** Saved errorcode. */
112 RTGCUINT uSavedErrorCode;
113
114 /** Saved cr2. */
115 RTGCUINTPTR uSavedCR2;
116
117 /** Previous trap vector # - for debugging. */
118 RTGCUINT uPrevVector;
119
120 /** IDT monitoring and sync flag */
121 RTUINT fDisableMonitoring; /** @todo r=bird: bool and 7 byte achPadding1. */
122
123 /** Padding to get the IDTs at a 16 byte alignement. */
124 char achPadding1[4];
125
126 /** IDTs. Aligned at 16 byte offset for speed. */
127 VBOXIDTE aIdt[256];
128
129 /** Bitmap for IDTEs that contain PATM handlers. (needed for relocation) */
130 uint32_t au32IdtPatched[8];
131
132 /** Bitmap for IDTEs that were changed. */
133 uint32_t au32IdtDirty[8];
134
135 /** Temporary Hypervisor trap handlers.
136 * NULL means default action. */
137 RTGCPTR aTmpTrapHandlers[256];
138
139 /** GC Pointer to the IDT shadow area (aIdt) placed in Hypervisor memory arena. */
140 RTGCPTR GCPtrIdt;
141 /** Current (last) Guest's IDTR. */
142 VBOXIDTR GuestIdtr;
143
144 /** padding. */
145 uint8_t au8Padding[2];
146
147 /** Checked trap & interrupt handler array */
148 RTGCPTR aGuestTrapHandler[256];
149
150 /** GC: The number of times writes to the Guest IDT were detected. */
151 STAMCOUNTER StatGCWriteGuestIDT;
152 /** HC: Profiling of the TRPMR3SyncIDT() method. */
153 STAMPROFILE StatSyncIDT;
154 /** GC: Statistics for the trap handlers. */
155 STAMPROFILEADV aStatGCTraps[0x14];
156
157 STAMCOUNTER StatForwardFailNoHandler;
158 STAMCOUNTER StatForwardFailPatchAddr;
159 STAMCOUNTER StatForwardFailGC;
160 STAMCOUNTER StatForwardFailHC;
161
162 /* R3: Statistics for interrupt handlers (allocated on the hypervisor heap). */
163 R3PTRTYPE(PSTAMCOUNTER) paStatForwardedIRQR3;
164 /* R0: Statistics for interrupt handlers (allocated on the hypervisor heap). */
165 R0PTRTYPE(PSTAMCOUNTER) paStatForwardedIRQR0;
166 /* GC: Statistics for interrupt handlers (allocated on the hypervisor heap). */
167 GCPTRTYPE(PSTAMCOUNTER) paStatForwardedIRQGC;
168} TRPM;
169#pragma pack()
170
171/** Pointer to TRPM Data. */
172typedef TRPM *PTRPM;
173
174TRPMGCDECL(int) trpmgcGuestIDTWriteHandler(PVM pVM, RTGCUINT uErrorCode, PCPUMCTXCORE pRegFrame, void *pvFault, void *pvRange, uintptr_t offRange);
175TRPMGCDECL(int) trpmgcShadowIDTWriteHandler(PVM pVM, RTGCUINT uErrorCode, PCPUMCTXCORE pRegFrame, void *pvFault, void *pvRange, uintptr_t offRange);
176
177
178#ifdef IN_RING3
179
180#endif
181
182
183#ifdef IN_RING0
184/**
185 * Code used for the dispatching of interrupts in HC.
186 * @internal
187 */
188DECLASM(int) trpmR0InterruptDispatcher(void);
189#endif
190
191/** @} */
192
193__END_DECLS
194
195#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