fc94305671a372a8b67ee78492d4656351dc33e7
[reactos.git] / subsystems / ntvdm / emulator.h
1 /*
2 * COPYRIGHT: GPL - See COPYING in the top level directory
3 * PROJECT: ReactOS Virtual DOS Machine
4 * FILE: emulator.h
5 * PURPOSE: Minimal x86 machine emulator for the VDM (header file)
6 * PROGRAMMERS: Aleksandar Andrejevic <theflash AT sdf DOT lonestar DOT org>
7 */
8
9 #ifndef _EMULATOR_H_
10 #define _EMULATOR_H_
11
12 /* INCLUDES *******************************************************************/
13
14 #include "ntvdm.h"
15 #include <softx86/softx86.h>
16 #include <softx86/softx87.h>
17
18 /* DEFINES ********************************************************************/
19
20 #define EMULATOR_FLAG_CF (1 << 0)
21 #define EMULATOR_FLAG_PF (1 << 2)
22 #define EMULATOR_FLAG_AF (1 << 4)
23 #define EMULATOR_FLAG_ZF (1 << 6)
24 #define EMULATOR_FLAG_SF (1 << 7)
25 #define EMULATOR_FLAG_TF (1 << 8)
26 #define EMULATOR_FLAG_IF (1 << 9)
27 #define EMULATOR_FLAG_DF (1 << 10)
28 #define EMULATOR_FLAG_OF (1 << 11)
29 #define EMULATOR_FLAG_NT (1 << 14)
30 #define EMULATOR_FLAG_RF (1 << 16)
31 #define EMULATOR_FLAG_VM (1 << 17)
32 #define EMULATOR_FLAG_AC (1 << 18)
33 #define EMULATOR_FLAG_VIF (1 << 19)
34 #define EMULATOR_FLAG_VIP (1 << 20)
35 #define EMULATOR_FLAG_ID (1 << 21)
36 #define SPECIAL_INT_NUM 0xFF
37
38 enum
39 {
40 EMULATOR_EXCEPTION_DIVISION_BY_ZERO,
41 EMULATOR_EXCEPTION_DEBUG,
42 EMULATOR_EXCEPTION_NMI,
43 EMULATOR_EXCEPTION_BREAKPOINT,
44 EMULATOR_EXCEPTION_OVERFLOW,
45 EMULATOR_EXCEPTION_BOUND,
46 EMULATOR_EXCEPTION_INVALID_OPCODE,
47 EMULATOR_EXCEPTION_NO_FPU
48 };
49
50 typedef enum
51 {
52 EMULATOR_REG_AX,
53 EMULATOR_REG_CX,
54 EMULATOR_REG_DX,
55 EMULATOR_REG_BX,
56 EMULATOR_REG_SI,
57 EMULATOR_REG_DI,
58 EMULATOR_REG_SP,
59 EMULATOR_REG_BP,
60 EMULATOR_REG_ES,
61 EMULATOR_REG_CS,
62 EMULATOR_REG_SS,
63 EMULATOR_REG_DS,
64 } EMULATOR_REGISTER;
65
66 /* FUNCTIONS ******************************************************************/
67
68 BOOLEAN EmulatorInitialize();
69 VOID EmulatorSetStack(WORD Segment, WORD Offset);
70 VOID EmulatorExecute(WORD Segment, WORD Offset);
71 VOID EmulatorInterrupt(BYTE Number);
72 VOID EmulatorExternalInterrupt(BYTE Number);
73 ULONG EmulatorGetRegister(ULONG Register);
74 VOID EmulatorSetRegister(ULONG Register, ULONG Value);
75 BOOLEAN EmulatorGetFlag(ULONG Flag);
76 VOID EmulatorSetFlag(ULONG Flag);
77 VOID EmulatorClearFlag(ULONG Flag);
78 VOID EmulatorStep();
79 VOID EmulatorCleanup();
80 VOID EmulatorSetA20(BOOLEAN Enabled);
81
82 #endif
83
84 /* EOF */
85