mirror of
https://github.com/reactos/reactos.git
synced 2024-10-09 02:35:42 +00:00
6da6a5ce56
Start my work on modularizing registration of "32-bit" interrupts, i.e. interrupts that are implemented in 32-bit mode, but are stubbed with 16-bit code (so that 16-bit apps can call them). The 16-bit stub code uses a BOP call to our Control BOP function (BOP 0xFF) which can handle in theory many sub-functions (as the BOP 0x58 documented here: http://www.ragestorm.net/tutorial?id=27) specified as an additional BYTE in the call: 0xC4 0xC4 bop_code <optional_bop_subfunction> Here, for calling 32-bit interrupts we use our BOP 0xFF, subfunction 0xFF. The final aim would be to generate the 16-bit stub code when one calls the RegisterInt32 helper function (contrary to what's happening now, that is, the 16-bit stub code is generated for all of the interrupts at BIOS initialization time, and we use it for BIOS and DOS interrupts). svn path=/branches/ntvdm/; revision=60907
146 lines
3.4 KiB
C
146 lines
3.4 KiB
C
/*
|
|
* COPYRIGHT: GPL - See COPYING in the top level directory
|
|
* PROJECT: ReactOS Virtual DOS Machine
|
|
* FILE: emulator.h
|
|
* PURPOSE: Minimal x86 machine emulator for the VDM (header file)
|
|
* PROGRAMMERS: Aleksandar Andrejevic <theflash AT sdf DOT lonestar DOT org>
|
|
*/
|
|
|
|
#ifndef _EMULATOR_H_
|
|
#define _EMULATOR_H_
|
|
|
|
/* INCLUDES *******************************************************************/
|
|
|
|
#include "ntvdm.h"
|
|
#include <fast486.h>
|
|
|
|
/* DEFINES ********************************************************************/
|
|
|
|
/* FLAGS */
|
|
#define EMULATOR_FLAG_CF (1 << 0)
|
|
#define EMULATOR_FLAG_PF (1 << 2)
|
|
#define EMULATOR_FLAG_AF (1 << 4)
|
|
#define EMULATOR_FLAG_ZF (1 << 6)
|
|
#define EMULATOR_FLAG_SF (1 << 7)
|
|
#define EMULATOR_FLAG_TF (1 << 8)
|
|
#define EMULATOR_FLAG_IF (1 << 9)
|
|
#define EMULATOR_FLAG_DF (1 << 10)
|
|
#define EMULATOR_FLAG_OF (1 << 11)
|
|
#define EMULATOR_FLAG_NT (1 << 14)
|
|
#define EMULATOR_FLAG_RF (1 << 16)
|
|
#define EMULATOR_FLAG_VM (1 << 17)
|
|
#define EMULATOR_FLAG_AC (1 << 18)
|
|
#define EMULATOR_FLAG_VIF (1 << 19)
|
|
#define EMULATOR_FLAG_VIP (1 << 20)
|
|
#define EMULATOR_FLAG_ID (1 << 21)
|
|
|
|
/* Common definitions */
|
|
#define EMULATOR_BOP 0xC4C4
|
|
#define EMULATOR_INT_BOP 0xFF
|
|
#define EMULATOR_MAX_BOP_NUM 0xFF + 1
|
|
|
|
#define STACK_COUNTER 0
|
|
#define STACK_INT_NUM 1
|
|
#define STACK_IP 2
|
|
#define STACK_CS 3
|
|
#define STACK_FLAGS 4
|
|
|
|
enum
|
|
{
|
|
EMULATOR_EXCEPTION_DIVISION_BY_ZERO,
|
|
EMULATOR_EXCEPTION_DEBUG,
|
|
EMULATOR_EXCEPTION_NMI,
|
|
EMULATOR_EXCEPTION_BREAKPOINT,
|
|
EMULATOR_EXCEPTION_OVERFLOW,
|
|
EMULATOR_EXCEPTION_BOUND,
|
|
EMULATOR_EXCEPTION_INVALID_OPCODE,
|
|
EMULATOR_EXCEPTION_NO_FPU,
|
|
EMULATOR_EXCEPTION_DOUBLE_FAULT,
|
|
EMULATOR_EXCEPTION_FPU_SEGMENT,
|
|
EMULATOR_EXCEPTION_INVALID_TSS,
|
|
EMULATOR_EXCEPTION_NO_SEGMENT,
|
|
EMULATOR_EXCEPTION_STACK_SEGMENT,
|
|
EMULATOR_EXCEPTION_GPF,
|
|
EMULATOR_EXCEPTION_PAGE_FAULT
|
|
};
|
|
|
|
enum
|
|
{
|
|
EMULATOR_REG_AX,
|
|
EMULATOR_REG_CX,
|
|
EMULATOR_REG_DX,
|
|
EMULATOR_REG_BX,
|
|
EMULATOR_REG_SP,
|
|
EMULATOR_REG_BP,
|
|
EMULATOR_REG_SI,
|
|
EMULATOR_REG_DI,
|
|
EMULATOR_REG_ES,
|
|
EMULATOR_REG_CS,
|
|
EMULATOR_REG_SS,
|
|
EMULATOR_REG_DS,
|
|
EMULATOR_REG_FS,
|
|
EMULATOR_REG_GS
|
|
};
|
|
|
|
extern FAST486_STATE EmulatorContext;
|
|
|
|
/* FUNCTIONS ******************************************************************/
|
|
|
|
VOID WINAPI EmulatorReadMemory
|
|
(
|
|
PFAST486_STATE State,
|
|
ULONG Address,
|
|
PVOID Buffer,
|
|
ULONG Size
|
|
);
|
|
|
|
VOID WINAPI EmulatorWriteMemory
|
|
(
|
|
PFAST486_STATE State,
|
|
ULONG Address,
|
|
PVOID Buffer,
|
|
ULONG Size
|
|
);
|
|
|
|
VOID WINAPI EmulatorReadIo
|
|
(
|
|
PFAST486_STATE State,
|
|
ULONG Port,
|
|
PVOID Buffer,
|
|
ULONG DataCount,
|
|
UCHAR DataSize
|
|
);
|
|
|
|
VOID WINAPI EmulatorWriteIo
|
|
(
|
|
PFAST486_STATE State,
|
|
ULONG Port,
|
|
PVOID Buffer,
|
|
ULONG DataCount,
|
|
UCHAR DataSize
|
|
);
|
|
|
|
UCHAR WINAPI EmulatorIntAcknowledge
|
|
(
|
|
PFAST486_STATE State
|
|
);
|
|
|
|
BOOLEAN EmulatorInitialize(VOID);
|
|
VOID EmulatorSetStack(WORD Segment, DWORD Offset);
|
|
VOID EmulatorExecute(WORD Segment, WORD Offset);
|
|
VOID EmulatorInterrupt(BYTE Number);
|
|
VOID EmulatorInterruptSignal(VOID);
|
|
ULONG EmulatorGetRegister(ULONG Register);
|
|
ULONG EmulatorGetProgramCounter(VOID);
|
|
VOID EmulatorSetRegister(ULONG Register, ULONG Value);
|
|
BOOLEAN EmulatorGetFlag(ULONG Flag);
|
|
VOID EmulatorSetFlag(ULONG Flag);
|
|
VOID EmulatorClearFlag(ULONG Flag);
|
|
VOID EmulatorStep(VOID);
|
|
VOID EmulatorCleanup(VOID);
|
|
VOID EmulatorSetA20(BOOLEAN Enabled);
|
|
|
|
#endif // _EMULATOR_H_
|
|
|
|
/* EOF */
|