VirtualBox

source: vbox/trunk/include/VBox/vmm/trpm.h@ 77921

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

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

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.5 KB
Line 
1/** @file
2 * TRPM - The Trap Monitor.
3 */
4
5/*
6 * Copyright (C) 2006-2019 Oracle Corporation
7 *
8 * This file is part of VirtualBox Open Source Edition (OSE), as
9 * available from http://www.virtualbox.org. This file is free software;
10 * you can redistribute it and/or modify it under the terms of the GNU
11 * General Public License (GPL) as published by the Free Software
12 * Foundation, in version 2 as it comes in the "COPYING" file of the
13 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
14 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
15 *
16 * The contents of this file may alternatively be used under the terms
17 * of the Common Development and Distribution License Version 1.0
18 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
19 * VirtualBox OSE distribution, in which case the provisions of the
20 * CDDL are applicable instead of those of the GPL.
21 *
22 * You may elect to license modified versions of this file under the
23 * terms and conditions of either the GPL or the CDDL or both.
24 */
25
26#ifndef VBOX_INCLUDED_vmm_trpm_h
27#define VBOX_INCLUDED_vmm_trpm_h
28#ifndef RT_WITHOUT_PRAGMA_ONCE
29# pragma once
30#endif
31
32#include <VBox/types.h>
33#include <iprt/x86.h>
34
35
36RT_C_DECLS_BEGIN
37/** @defgroup grp_trpm The Trap Monitor API
38 * @ingroup grp_vmm
39 * @{
40 */
41
42/**
43 * Trap: error code present or not
44 */
45typedef enum
46{
47 TRPM_TRAP_HAS_ERRORCODE = 0,
48 TRPM_TRAP_NO_ERRORCODE,
49 /** The usual 32-bit paranoia. */
50 TRPM_TRAP_32BIT_HACK = 0x7fffffff
51} TRPMERRORCODE;
52
53/**
54 * TRPM event type
55 */
56/** Note: must match trpm.mac! */
57typedef enum
58{
59 TRPM_TRAP = 0,
60 TRPM_HARDWARE_INT = 1,
61 TRPM_SOFTWARE_INT = 2,
62 /** The usual 32-bit paranoia. */
63 TRPM_32BIT_HACK = 0x7fffffff
64} TRPMEVENT;
65/** Pointer to a TRPM event type. */
66typedef TRPMEVENT *PTRPMEVENT;
67/** Pointer to a const TRPM event type. */
68typedef TRPMEVENT const *PCTRPMEVENT;
69
70/**
71 * Invalid trap handler for trampoline calls
72 */
73#define TRPM_INVALID_HANDLER 0
74
75VMMDECL(int) TRPMQueryTrap(PVMCPU pVCpu, uint8_t *pu8TrapNo, PTRPMEVENT penmType);
76VMMDECL(uint8_t) TRPMGetTrapNo(PVMCPU pVCpu);
77VMMDECL(RTGCUINT) TRPMGetErrorCode(PVMCPU pVCpu);
78VMMDECL(RTGCUINTPTR) TRPMGetFaultAddress(PVMCPU pVCpu);
79VMMDECL(uint8_t) TRPMGetInstrLength(PVMCPU pVCpu);
80VMMDECL(int) TRPMResetTrap(PVMCPU pVCpu);
81VMMDECL(int) TRPMAssertTrap(PVMCPU pVCpu, uint8_t u8TrapNo, TRPMEVENT enmType);
82VMMDECL(int) TRPMAssertXcptPF(PVMCPU pVCpu, RTGCUINTPTR uCR2, RTGCUINT uErrorCode);
83VMMDECL(void) TRPMSetErrorCode(PVMCPU pVCpu, RTGCUINT uErrorCode);
84VMMDECL(void) TRPMSetFaultAddress(PVMCPU pVCpu, RTGCUINTPTR uCR2);
85VMMDECL(void) TRPMSetInstrLength(PVMCPU pVCpu, uint8_t cbInstr);
86VMMDECL(bool) TRPMIsSoftwareInterrupt(PVMCPU pVCpu);
87VMMDECL(bool) TRPMHasTrap(PVMCPU pVCpu);
88VMMDECL(int) TRPMQueryTrapAll(PVMCPU pVCpu, uint8_t *pu8TrapNo, PTRPMEVENT pEnmType, PRTGCUINT puErrorCode, PRTGCUINTPTR puCR2, uint8_t *pcbInstr);
89VMMDECL(void) TRPMSaveTrap(PVMCPU pVCpu);
90VMMDECL(void) TRPMRestoreTrap(PVMCPU pVCpu);
91VMMDECL(int) TRPMForwardTrap(PVMCPU pVCpu, PCPUMCTXCORE pRegFrame, uint32_t iGate, uint32_t cbInstr, TRPMERRORCODE enmError, TRPMEVENT enmType, int32_t iOrgTrap);
92VMMDECL(int) TRPMRaiseXcpt(PVMCPU pVCpu, PCPUMCTXCORE pCtxCore, X86XCPT enmXcpt);
93VMMDECL(int) TRPMRaiseXcptErr(PVMCPU pVCpu, PCPUMCTXCORE pCtxCore, X86XCPT enmXcpt, uint32_t uErr);
94VMMDECL(int) TRPMRaiseXcptErrCR2(PVMCPU pVCpu, PCPUMCTXCORE pCtxCore, X86XCPT enmXcpt, uint32_t uErr, RTGCUINTPTR uCR2);
95
96
97#ifdef IN_RING3
98/** @defgroup grp_trpm_r3 TRPM Host Context Ring 3 API
99 * @{
100 */
101VMMR3DECL(int) TRPMR3Init(PVM pVM);
102VMMR3DECL(void) TRPMR3Relocate(PVM pVM, RTGCINTPTR offDelta);
103VMMR3DECL(void) TRPMR3ResetCpu(PVMCPU pVCpu);
104VMMR3DECL(void) TRPMR3Reset(PVM pVM);
105VMMR3DECL(int) TRPMR3Term(PVM pVM);
106VMMR3DECL(int) TRPMR3InjectEvent(PVM pVM, PVMCPU pVCpu, TRPMEVENT enmEvent, bool *pfInjected);
107# ifdef VBOX_WITH_RAW_MODE
108VMMR3_INT_DECL(int) TRPMR3GetImportRC(PVM pVM, const char *pszSymbol, PRTRCPTR pRCPtrValue);
109VMMR3DECL(int) TRPMR3SyncIDT(PVM pVM, PVMCPU pVCpu);
110VMMR3DECL(bool) TRPMR3IsGateHandler(PVM pVM, RTRCPTR GCPtr);
111VMMR3DECL(uint32_t) TRPMR3QueryGateByHandler(PVM pVM, RTRCPTR GCPtr);
112VMMR3DECL(int) TRPMR3EnableGuestTrapHandler(PVM pVM, unsigned iTrap);
113VMMR3DECL(int) TRPMR3SetGuestTrapHandler(PVM pVM, unsigned iTrap, RTRCPTR pHandler);
114VMMR3DECL(RTRCPTR) TRPMR3GetGuestTrapHandler(PVM pVM, unsigned iTrap);
115# endif
116/** @} */
117#endif
118
119
120#ifdef IN_RC
121/** @defgroup grp_trpm_rc The TRPM Raw-mode Context API
122 * @{
123 */
124
125/**
126 * Guest Context temporary trap handler
127 *
128 * @returns VBox status code (appropriate for GC return).
129 * In this context VINF_SUCCESS means to restart the instruction.
130 * @param pVM The cross context VM structure.
131 * @param pRegFrame Trap register frame.
132 */
133typedef DECLCALLBACK(int) FNTRPMGCTRAPHANDLER(PVM pVM, PCPUMCTXCORE pRegFrame);
134/** Pointer to a TRPMGCTRAPHANDLER() function. */
135typedef FNTRPMGCTRAPHANDLER *PFNTRPMGCTRAPHANDLER;
136
137VMMRCDECL(int) TRPMGCSetTempHandler(PVM pVM, unsigned iTrap, PFNTRPMGCTRAPHANDLER pfnHandler);
138VMMRCDECL(void) TRPMGCHyperReturnToHost(PVM pVM, int rc);
139/** @} */
140#endif
141
142
143#ifdef IN_RING0
144/** @defgroup grp_trpm_r0 TRPM Host Context Ring 0 API
145 * @{
146 */
147VMMR0DECL(void) TRPMR0DispatchHostInterrupt(PVM pVM);
148VMMR0DECL(void) TRPMR0SetupInterruptDispatcherFrame(PVM pVM, void *pvRet);
149/** @} */
150#endif
151
152/** @} */
153RT_C_DECLS_END
154
155#endif /* !VBOX_INCLUDED_vmm_trpm_h */
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette