2013-06-26 22:58:41 +00:00
|
|
|
/*
|
|
|
|
* 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"
|
2013-10-19 16:55:51 +00:00
|
|
|
#include <fast486.h>
|
2013-06-26 22:58:41 +00:00
|
|
|
|
|
|
|
/* DEFINES ********************************************************************/
|
|
|
|
|
2013-07-07 20:53:23 +00:00
|
|
|
/* FLAGS */
|
2013-06-26 22:58:41 +00:00
|
|
|
#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)
|
2013-07-07 20:53:23 +00:00
|
|
|
|
|
|
|
/* Common definitions */
|
2013-07-23 19:31:00 +00:00
|
|
|
#define EMULATOR_BOP 0xC4C4
|
|
|
|
#define EMULATOR_INT_BOP 0xBEEF
|
2013-10-24 01:01:49 +00:00
|
|
|
#define STACK_COUNTER 0
|
|
|
|
#define STACK_INT_NUM 1
|
|
|
|
#define STACK_IP 2
|
|
|
|
#define STACK_CS 3
|
|
|
|
#define STACK_FLAGS 4
|
2013-06-26 22:58:41 +00:00
|
|
|
|
|
|
|
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,
|
2013-07-07 20:53:23 +00:00
|
|
|
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
|
2013-06-26 22:58:41 +00:00
|
|
|
};
|
|
|
|
|
2013-07-03 23:38:51 +00:00
|
|
|
enum
|
2013-06-26 22:58:41 +00:00
|
|
|
{
|
|
|
|
EMULATOR_REG_AX,
|
|
|
|
EMULATOR_REG_CX,
|
|
|
|
EMULATOR_REG_DX,
|
|
|
|
EMULATOR_REG_BX,
|
|
|
|
EMULATOR_REG_SP,
|
|
|
|
EMULATOR_REG_BP,
|
2013-07-02 02:08:30 +00:00
|
|
|
EMULATOR_REG_SI,
|
|
|
|
EMULATOR_REG_DI,
|
2013-06-26 22:58:41 +00:00
|
|
|
EMULATOR_REG_ES,
|
|
|
|
EMULATOR_REG_CS,
|
|
|
|
EMULATOR_REG_SS,
|
|
|
|
EMULATOR_REG_DS,
|
2013-07-07 20:53:23 +00:00
|
|
|
EMULATOR_REG_FS,
|
|
|
|
EMULATOR_REG_GS
|
2013-07-03 23:38:51 +00:00
|
|
|
};
|
2013-06-26 22:58:41 +00:00
|
|
|
|
2013-10-19 16:55:51 +00:00
|
|
|
extern FAST486_STATE EmulatorContext;
|
2013-09-28 00:29:16 +00:00
|
|
|
|
2013-06-26 22:58:41 +00:00
|
|
|
/* FUNCTIONS ******************************************************************/
|
|
|
|
|
|
|
|
BOOLEAN EmulatorInitialize();
|
2013-08-09 23:52:08 +00:00
|
|
|
VOID EmulatorSetStack(WORD Segment, DWORD Offset);
|
2013-06-26 22:58:41 +00:00
|
|
|
VOID EmulatorExecute(WORD Segment, WORD Offset);
|
|
|
|
VOID EmulatorInterrupt(BYTE Number);
|
2013-10-27 00:37:01 +00:00
|
|
|
VOID EmulatorInterruptSignal(VOID);
|
2013-06-26 22:58:41 +00:00
|
|
|
ULONG EmulatorGetRegister(ULONG Register);
|
2013-08-09 23:52:08 +00:00
|
|
|
ULONG EmulatorGetProgramCounter(VOID);
|
2013-06-26 22:58:41 +00:00
|
|
|
VOID EmulatorSetRegister(ULONG Register, ULONG Value);
|
|
|
|
BOOLEAN EmulatorGetFlag(ULONG Flag);
|
|
|
|
VOID EmulatorSetFlag(ULONG Flag);
|
|
|
|
VOID EmulatorClearFlag(ULONG Flag);
|
|
|
|
VOID EmulatorStep();
|
|
|
|
VOID EmulatorCleanup();
|
|
|
|
VOID EmulatorSetA20(BOOLEAN Enabled);
|
|
|
|
|
2013-08-09 18:55:35 +00:00
|
|
|
#endif // _EMULATOR_H_
|
2013-06-26 22:58:41 +00:00
|
|
|
|
|
|
|
/* EOF */
|