trpm.h revision ebd9b3761536fd550f8d068139ec1829d41bfd2b
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync/** @file
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * TRPM - The Trap Monitor.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync */
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync/*
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * Copyright (C) 2006-2007 Sun Microsystems, Inc.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync *
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * available from http://www.virtualbox.org. This file is free software;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * you can redistribute it and/or modify it under the terms of the GNU
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * General Public License (GPL) as published by the Free Software
e4dec40ee9c070be42661febd9ae047056007ec5vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync *
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * The contents of this file may alternatively be used under the terms
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * of the Common Development and Distribution License Version 1.0
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * VirtualBox OSE distribution, in which case the provisions of the
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * CDDL are applicable instead of those of the GPL.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync *
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * You may elect to license modified versions of this file under the
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * terms and conditions of either the GPL or the CDDL or both.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync *
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * Clara, CA 95054 USA or visit http://www.sun.com if you need
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * additional information or have any questions.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync */
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync#ifndef ___VBox_trpm_h
83f490cd5eec4567f8ee5c9e481f9d9c739b3061vboxsync#define ___VBox_trpm_h
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
83f490cd5eec4567f8ee5c9e481f9d9c739b3061vboxsync#include <VBox/cdefs.h>
83f490cd5eec4567f8ee5c9e481f9d9c739b3061vboxsync#include <VBox/types.h>
83f490cd5eec4567f8ee5c9e481f9d9c739b3061vboxsync#include <VBox/x86.h>
83f490cd5eec4567f8ee5c9e481f9d9c739b3061vboxsync
83f490cd5eec4567f8ee5c9e481f9d9c739b3061vboxsync
83f490cd5eec4567f8ee5c9e481f9d9c739b3061vboxsync__BEGIN_DECLS
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync/** @defgroup grp_trpm The Trap Monitor API
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * @{
e4dec40ee9c070be42661febd9ae047056007ec5vboxsync */
e4dec40ee9c070be42661febd9ae047056007ec5vboxsync
e4dec40ee9c070be42661febd9ae047056007ec5vboxsync/**
e4dec40ee9c070be42661febd9ae047056007ec5vboxsync * Trap: error code present or not
e4dec40ee9c070be42661febd9ae047056007ec5vboxsync */
e4dec40ee9c070be42661febd9ae047056007ec5vboxsynctypedef enum
e4dec40ee9c070be42661febd9ae047056007ec5vboxsync{
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync TRPM_TRAP_HAS_ERRORCODE = 0,
e4dec40ee9c070be42661febd9ae047056007ec5vboxsync TRPM_TRAP_NO_ERRORCODE,
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync /** The usual 32-bit paranoia. */
e4dec40ee9c070be42661febd9ae047056007ec5vboxsync TRPM_TRAP_32BIT_HACK = 0x7fffffff
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync} TRPMERRORCODE;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
83f490cd5eec4567f8ee5c9e481f9d9c739b3061vboxsync/**
83f490cd5eec4567f8ee5c9e481f9d9c739b3061vboxsync * TRPM event type
83f490cd5eec4567f8ee5c9e481f9d9c739b3061vboxsync */
553fe7e9c0f2700c19c346eec835ee7f29e2f89evboxsync/** Note: must match trpm.mac! */
553fe7e9c0f2700c19c346eec835ee7f29e2f89evboxsynctypedef enum
553fe7e9c0f2700c19c346eec835ee7f29e2f89evboxsync{
83f490cd5eec4567f8ee5c9e481f9d9c739b3061vboxsync TRPM_TRAP = 0,
83f490cd5eec4567f8ee5c9e481f9d9c739b3061vboxsync TRPM_HARDWARE_INT = 1,
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync TRPM_SOFTWARE_INT = 2,
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync /** The usual 32-bit paranoia. */
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync TRPM_32BIT_HACK = 0x7fffffff
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync} TRPMEVENT;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync/** Pointer to a TRPM event type. */
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsynctypedef TRPMEVENT *PTRPMEVENT;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync/** Pointer to a const TRPM event type. */
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsynctypedef TRPMEVENT const *PCTRPMEVENT;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync/**
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * Invalid trap handler for trampoline calls
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync */
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync#define TRPM_INVALID_HANDLER 0
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncVMMDECL(int) TRPMQueryTrap(PVM pVM, uint8_t *pu8TrapNo, PTRPMEVENT pEnmType);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncVMMDECL(uint8_t) TRPMGetTrapNo(PVM pVM);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncVMMDECL(RTGCUINT) TRPMGetErrorCode(PVM pVM);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncVMMDECL(RTGCUINTPTR) TRPMGetFaultAddress(PVM pVM);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncVMMDECL(int) TRPMResetTrap(PVM pVM);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncVMMDECL(int) TRPMAssertTrap(PVM pVM, uint8_t u8TrapNo, TRPMEVENT enmType);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncVMMDECL(void) TRPMSetErrorCode(PVM pVM, RTGCUINT uErrorCode);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncVMMDECL(void) TRPMSetFaultAddress(PVM pVM, RTGCUINTPTR uCR2);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncVMMDECL(bool) TRPMIsSoftwareInterrupt(PVM pVM);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncVMMDECL(bool) TRPMHasTrap(PVM pVM);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncVMMDECL(int) TRPMQueryTrapAll(PVM pVM, uint8_t *pu8TrapNo, PTRPMEVENT pEnmType, PRTGCUINT puErrorCode, PRTGCUINTPTR puCR2);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncVMMDECL(void) TRPMSaveTrap(PVM pVM);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncVMMDECL(void) TRPMRestoreTrap(PVM pVM);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncVMMDECL(int) TRPMForwardTrap(PVM pVM, PCPUMCTXCORE pRegFrame, uint32_t iGate, uint32_t opsize, TRPMERRORCODE enmError, TRPMEVENT enmType, int32_t iOrgTrap);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncVMMDECL(int) TRPMRaiseXcpt(PVM pVM, PCPUMCTXCORE pCtxCore, X86XCPT enmXcpt);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncVMMDECL(int) TRPMRaiseXcptErr(PVM pVM, PCPUMCTXCORE pCtxCore, X86XCPT enmXcpt, uint32_t uErr);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncVMMDECL(int) TRPMRaiseXcptErrCR2(PVM pVM, PCPUMCTXCORE pCtxCore, X86XCPT enmXcpt, uint32_t uErr, RTGCUINTPTR uCR2);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync#ifdef IN_RING3
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync/** @defgroup grp_trpm_r3 TRPM Host Context Ring 3 API
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * @ingroup grp_trpm
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * @{
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync */
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncVMMR3DECL(int) TRPMR3Init(PVM pVM);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncVMMR3DECL(void) TRPMR3Relocate(PVM pVM, RTGCINTPTR offDelta);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncVMMR3DECL(void) TRPMR3Reset(PVM pVM);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncVMMR3DECL(int) TRPMR3Term(PVM pVM);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncVMMR3DECL(int) TRPMR3EnableGuestTrapHandler(PVM pVM, unsigned iTrap);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncVMMR3DECL(int) TRPMR3SetGuestTrapHandler(PVM pVM, unsigned iTrap, RTRCPTR pHandler);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncVMMR3DECL(RTRCPTR) TRPMR3GetGuestTrapHandler(PVM pVM, unsigned iTrap);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncVMMR3DECL(void) TRPMR3DisableMonitoring(PVM pVM);
e4dec40ee9c070be42661febd9ae047056007ec5vboxsyncVMMR3DECL(int) TRPMR3SyncIDT(PVM pVM);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncVMMR3DECL(bool) TRPMR3IsGateHandler(PVM pVM, RTRCPTR GCPtr);
e4dec40ee9c070be42661febd9ae047056007ec5vboxsyncVMMR3DECL(uint32_t) TRPMR3QueryGateByHandler(PVM pVM, RTRCPTR GCPtr);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncVMMR3DECL(int) TRPMR3InjectEvent(PVM pVM, TRPMEVENT enmEvent);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync/** @} */
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync#endif
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e4dec40ee9c070be42661febd9ae047056007ec5vboxsync
e4dec40ee9c070be42661febd9ae047056007ec5vboxsync#ifdef IN_GC
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync/** @defgroup grp_trpm_gc The TRPM Guest Context API
e4dec40ee9c070be42661febd9ae047056007ec5vboxsync * @ingroup grp_trpm
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * @{
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync */
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync/**
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * Guest Context temporary trap handler
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync *
e4dec40ee9c070be42661febd9ae047056007ec5vboxsync * @returns VBox status code (appropriate for GC return).
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * In this context VBOX_SUCCESS means to restart the instruction.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * @param pVM VM handle.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * @param pRegFrame Trap register frame.
e4dec40ee9c070be42661febd9ae047056007ec5vboxsync */
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsynctypedef DECLCALLBACK(int) FNTRPMGCTRAPHANDLER(PVM pVM, PCPUMCTXCORE pRegFrame);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync/** Pointer to a TRPMGCTRAPHANDLER() function. */
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsynctypedef FNTRPMGCTRAPHANDLER *PFNTRPMGCTRAPHANDLER;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncVMMRCDECL(int) TRPMGCSetTempHandler(PVM pVM, unsigned iTrap, PFNTRPMGCTRAPHANDLER pfnHandler);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncVMMRCDECL(void) TRPMGCHyperReturnToHost(PVM pVM, int rc);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync/** @} */
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync#endif
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync#ifdef IN_RING0
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync/** @defgroup grp_trpm_r0 TRPM Host Context Ring 0 API
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * @ingroup grp_trpm
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * @{
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync */
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncVMMR0DECL(void) TRPMR0DispatchHostInterrupt(PVM pVM);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncVMMR0DECL(void) TRPMR0SetupInterruptDispatcherFrame(PVM pVM, void *pvRet);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync/** @} */
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync#endif
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync/** @} */
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync__END_DECLS
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync#endif
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync