TRPMInternal.h revision 17ba03925269c071aa1567eb8c5a49c37a65f62f
/* $Id$ */
/** @file
* TRPM - Internal header file.
*/
/*
* Copyright (C) 2006-2007 innotek GmbH
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License as published by the Free Software Foundation,
* in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
* distribution. VirtualBox OSE is distributed in the hope that it will
* be useful, but WITHOUT ANY WARRANTY of any kind.
*
* If you received this file as part of a commercial VirtualBox
* distribution, then only the terms of your commercial VirtualBox
* license agreement apply instead of the previous paragraph.
*/
#ifndef ___TRPMInternal_h
#define ___TRPMInternal_h
# error "Not in TRPM! This is an internal header!"
#endif
/* Enable to allow trap forwarding in GC. */
#define TRPM_FORWARD_TRAPS_IN_GC
/** First interrupt handler. Used for validating input. */
#define TRPM_HANDLER_INT_BASE 0x20
/** @defgroup grp_trpm_int Internals
* @ingroup grp_trpm
* @internal
* @{
*/
/** @name TRPMGCTrapIn* flags.
* The lower bits are offsets into the CPUMCTXCORE structure.
* @{ */
/** The mask for the operation. */
#define TRPM_TRAP_IN_OP_MASK 0xffff
/** Traps on MOV GS, eax. */
#define TRPM_TRAP_IN_MOV_GS 1
/** Traps on MOV FS, eax. */
#define TRPM_TRAP_IN_MOV_FS 2
/** Traps on MOV ES, eax. */
#define TRPM_TRAP_IN_MOV_ES 3
/** Traps on MOV DS, eax. */
#define TRPM_TRAP_IN_MOV_DS 4
/** Traps on IRET. */
#define TRPM_TRAP_IN_IRET 5
/** Set if this is a V86 resume. */
/** If set this is a hypervisor register set. If cleared it's a guest set. */
/** @} */
/**
* Converts a TRPM pointer into a VM pointer.
* @returns Pointer to the VM structure the TRPM is part of.
* @param pTRPM Pointer to TRPM instance data.
*/
/**
* TRPM Data (part of VM)
*
* IMPORTANT! Keep the nasm version of this struct up-to-date.
*/
#pragma pack(4)
typedef struct TRPM
{
/** Offset to the VM structure.
* See TRPM2VM(). */
/** Active Interrupt or trap vector number.
* If not ~0U this indicates that we're currently processing
* a interrupt, trap, fault, abort, whatever which have arrived
* at that vector number.
*/
/** Active trap type. */
/** CR2 at the time of the active exception. */
/** Saved trap vector number. */
/** Saved trap type. */
/** Saved errorcode. */
/** Saved cr2. */
/** Previous trap vector # - for debugging. */
/** IDT monitoring and sync flag */
/** Padding to get the IDTs at a 16 byte alignement. */
char achPadding1[4];
/** IDTs. Aligned at 16 byte offset for speed. */
/** Bitmap for IDTEs that contain PATM handlers. (needed for relocation) */
/** Temporary Hypervisor trap handlers.
* NULL means default action. */
/** GC Pointer to the IDT shadow area (aIdt) placed in Hypervisor memory arena. */
/** Current (last) Guest's IDTR. */
/** padding. */
/** Checked trap & interrupt handler array */
/** GC: The number of times writes to the Guest IDT were detected. */
/** HC: Profiling of the TRPMR3SyncIDT() method. */
/** GC: Statistics for the trap handlers. */
/* R3: Statistics for interrupt handlers (allocated on the hypervisor heap). */
/* R0: Statistics for interrupt handlers (allocated on the hypervisor heap). */
/* GC: Statistics for interrupt handlers (allocated on the hypervisor heap). */
} TRPM;
#pragma pack()
/** Pointer to TRPM Data. */
TRPMGCDECL(int) trpmgcGuestIDTWriteHandler(PVM pVM, RTGCUINT uErrorCode, PCPUMCTXCORE pRegFrame, void *pvFault, void *pvRange, uintptr_t offRange);
TRPMGCDECL(int) trpmgcShadowIDTWriteHandler(PVM pVM, RTGCUINT uErrorCode, PCPUMCTXCORE pRegFrame, void *pvFault, void *pvRange, uintptr_t offRange);
/**
*
* @returns VBox status code.
* @param pVM The VM to operate on.
*/
#ifdef IN_RING3
/**
* Clear passthrough interrupt gate handler (reset to default handler)
*
* @returns VBox status code.
* @param pVM The VM to operate on.
*/
#endif
#ifdef IN_RING0
/**
* Calls the interrupt gate as if we received an interrupt while in Ring-0.
*
* @param uIP The interrupt gate IP.
* @param SelCS The interrupt gate CS.
* @param RSP The interrupt gate RSP. ~0 if no stack switch should take place. (only AMD64)
*/
/**
* Issues a software interrupt to the specified interrupt vector.
*
* @param uActiveVector The vector number.
*/
# ifndef VBOX_WITHOUT_IDT_PATCHING
/**
* Code used for the dispatching of interrupts in HC.
* @internal
*/
DECLASM(int) trpmR0InterruptDispatcher(void);
# endif /* !VBOX_WITHOUT_IDT_PATCHING */
#endif
/** @} */
#endif