Author: aandrejevic
Date: Fri Aug 16 19:33:04 2013
New Revision: 59753
URL:
http://svn.reactos.org/svn/reactos?rev=59753&view=rev
Log:
[NTVDM]
Remove the "new emulator" started in emulator.c in favor of Soft386.
Modified:
branches/ntvdm/subsystems/ntvdm/emulator.c
branches/ntvdm/subsystems/ntvdm/emulator.h
branches/ntvdm/subsystems/ntvdm/registers.c
Modified: branches/ntvdm/subsystems/ntvdm/emulator.c
URL:
http://svn.reactos.org/svn/reactos/branches/ntvdm/subsystems/ntvdm/emulator…
==============================================================================
--- branches/ntvdm/subsystems/ntvdm/emulator.c [iso-8859-1] (original)
+++ branches/ntvdm/subsystems/ntvdm/emulator.c [iso-8859-1] Fri Aug 16 19:33:04 2013
@@ -24,7 +24,7 @@
softx86_ctx EmulatorContext;
softx87_ctx FpuEmulatorContext;
#else
-EMULATOR_CONTEXT EmulatorContext;
+SOFT386_STATE EmulatorContext;
#endif
static BOOLEAN A20Line = FALSE;
@@ -241,8 +241,8 @@
StackSegment = EmulatorContext.state->segment_reg[SX86_SREG_SS].val;
StackPointer = EmulatorContext.state->general_reg[SX86_REG_SP].val;
#else
- StackSegment = EmulatorContext.Registers[EMULATOR_REG_SS].LowWord;
- StackPointer = EmulatorContext.Registers[EMULATOR_REG_SP].LowWord;
+ StackSegment = EmulatorContext.SegmentRegs[SOFT386_REG_SS].LowWord;
+ StackPointer = EmulatorContext.SegmentRegs[SOFT386_REG_SP].LowWord;
#endif
/* Get the stack */
@@ -475,7 +475,14 @@
return EmulatorContext.state->segment_reg[Register - EMULATOR_REG_ES].val;
}
#else
- return EmulatorContext.Registers[Register].Long;
+ if (Register < EMULATOR_REG_ES)
+ {
+ return EmulatorContext.GeneralRegs[Register].Long;
+ }
+ else
+ {
+ return EmulatorContext.SegmentRegs[Register - EMULATOR_REG_ES].Selector;
+ }
#endif
}
@@ -484,7 +491,7 @@
#ifndef NEW_EMULATOR
return EmulatorContext.state->reg_ip;
#else
- return EmulatorContext.InstructionPointer.Long;
+ return EmulatorContext.InstPtr.Long;
#endif
}
Modified: branches/ntvdm/subsystems/ntvdm/emulator.h
URL:
http://svn.reactos.org/svn/reactos/branches/ntvdm/subsystems/ntvdm/emulator…
==============================================================================
--- branches/ntvdm/subsystems/ntvdm/emulator.h [iso-8859-1] (original)
+++ branches/ntvdm/subsystems/ntvdm/emulator.h [iso-8859-1] Fri Aug 16 19:33:04 2013
@@ -14,8 +14,10 @@
#include "ntvdm.h"
#ifndef NEW_EMULATOR
-#include <softx86/softx86.h>
-#include <softx86/softx87.h>
+#include <softx86.h>
+#include <softx87.h>
+#else
+#include <soft386.h>
#endif
/* DEFINES ********************************************************************/
@@ -38,38 +40,7 @@
#define EMULATOR_FLAG_VIP (1 << 20)
#define EMULATOR_FLAG_ID (1 << 21)
-/* CR0 */
-#define EMULATOR_CR0_PE (1 << 0)
-#define EMULATOR_CR0_MP (1 << 1)
-#define EMULATOR_CR0_EM (1 << 2)
-#define EMULATOR_CR0_TS (1 << 3)
-#define EMULATOR_CR0_ET (1 << 4)
-#define EMULATOR_CR0_NE (1 << 5)
-#define EMULATOR_CR0_WP (1 << 16)
-#define EMULATOR_CR0_AM (1 << 18)
-#define EMULATOR_CR0_NW (1 << 29)
-#define EMULATOR_CR0_CD (1 << 30)
-#define EMULATOR_CR0_PG (1 << 31)
-
-/* GDT Access byte */
-#define GDT_SEG_ACCESSED (1 << 0)
-#define GDT_DATA_WRITEABLE (1 << 1)
-#define GDT_CODE_READABLE (1 << 1)
-#define GDT_CONFORMING (1 << 2)
-#define GDT_DIRECTION (1 << 2)
-#define GDT_CODE_SEGMENT (1 << 3)
-#define GDT_PRESENT (1 << 7)
-
-/* GDT flags */
-#define GDT_32BIT_SEGMENT (1 << 2)
-#define GDT_PAGE_GRANULARITY (1 << 3)
-
/* Common definitions */
-#define EMULATOR_NUM_GENERAL_REGS 8
-#define EMULATOR_NUM_SEGMENT_REGS 6
-#define EMULATOR_NUM_CONTROL_REGS 8
-#define EMULATOR_NUM_DEBUG_REGS 8
-#define MAX_GDT_ENTRIES 8192
#define EMULATOR_BOP 0xC4C4
#define EMULATOR_INT_BOP 0xBEEF
#define STACK_INT_NUM 0
@@ -114,65 +85,11 @@
EMULATOR_REG_GS
};
-typedef union
-{
- struct
- {
- BYTE LowByte;
- BYTE HighByte;
- };
- WORD LowWord;
- DWORD Long;
-} EMULATOR_REGISTER, *PEMULATOR_REGISTER;
-
-typedef struct
-{
- ULONG Limit : 16;
- ULONG Base : 24;
- ULONG AccessByte : 8;
- ULONG LimitHigh : 4;
- ULONG Flags : 4;
- ULONG BaseHigh : 8;
-} EMULATOR_GDT_ENTRY;
-
-typedef struct
-{
- ULONG Offset : 16;
- ULONG Selector : 16;
- ULONG Zero : 8;
- ULONG TypeAndAttributes : 8;
- ULONG OffsetHigh : 16;
-} EMULATOR_IDT_ENTRY;
-
-typedef struct
-{
- WORD Size;
- DWORD Address;
-} EMULATOR_TABLE_REGISTER;
-
-typedef struct
-{
- EMULATOR_REGISTER Registers[EMULATOR_NUM_GENERAL_REGS
- + EMULATOR_NUM_SEGMENT_REGS];
- EMULATOR_REGISTER Flags;
- EMULATOR_REGISTER InstructionPointer;
- EMULATOR_REGISTER ControlRegisters[EMULATOR_NUM_CONTROL_REGS];
- EMULATOR_REGISTER DebugRegisters[EMULATOR_NUM_DEBUG_REGS];
- ULONGLONG TimeStampCounter;
- BOOLEAN OperandSizeOverload;
- BOOLEAN AddressSizeOverload;
- EMULATOR_TABLE_REGISTER Gdtr, Idtr;
- EMULATOR_GDT_ENTRY CachedDescriptors[EMULATOR_NUM_SEGMENT_REGS];
- UINT ExceptionCount;
-} EMULATOR_CONTEXT, *PEMULATOR_CONTEXT;
-
-typedef VOID (*EMULATOR_OPCODE_HANDLER)(PEMULATOR_CONTEXT Context, BYTE Opcode);
-
#ifndef NEW_EMULATOR
extern softx86_ctx EmulatorContext;
extern softx87_ctx FpuEmulatorContext;
#else
-extern EMULATOR_CONTEXT EmulatorContext;
+extern SOFT386_STATE EmulatorContext;
#endif
/* FUNCTIONS ******************************************************************/
Modified: branches/ntvdm/subsystems/ntvdm/registers.c
URL:
http://svn.reactos.org/svn/reactos/branches/ntvdm/subsystems/ntvdm/register…
==============================================================================
--- branches/ntvdm/subsystems/ntvdm/registers.c [iso-8859-1] (original)
+++ branches/ntvdm/subsystems/ntvdm/registers.c [iso-8859-1] Fri Aug 16 19:33:04 2013
@@ -21,7 +21,7 @@
#ifndef NEW_EMULATOR
return EmulatorContext.state->general_reg[EMULATOR_REG_AX].val;
#else
- return EmulatorContext.Registers[EMULATOR_REG_AX].Long;
+ return EmulatorContext.GeneralRegs[EMULATOR_REG_AX].Long;
#endif
}
@@ -32,7 +32,7 @@
#ifndef NEW_EMULATOR
EmulatorContext.state->general_reg[EMULATOR_REG_AX].val = Value;
#else
- EmulatorContext.Registers[EMULATOR_REG_AX].Long = Value;
+ EmulatorContext.GeneralRegs[EMULATOR_REG_AX].Long = Value;
#endif
}
@@ -43,7 +43,7 @@
#ifndef NEW_EMULATOR
return EmulatorContext.state->general_reg[EMULATOR_REG_AX].w.lo;
#else
- return EmulatorContext.Registers[EMULATOR_REG_AX].LowWord;
+ return EmulatorContext.GeneralRegs[EMULATOR_REG_AX].LowWord;
#endif
}
@@ -54,7 +54,7 @@
#ifndef NEW_EMULATOR
EmulatorContext.state->general_reg[EMULATOR_REG_AX].w.lo = Value;
#else
- EmulatorContext.Registers[EMULATOR_REG_AX].LowWord = Value;
+ EmulatorContext.GeneralRegs[EMULATOR_REG_AX].LowWord = Value;
#endif
}
@@ -65,7 +65,7 @@
#ifndef NEW_EMULATOR
return EmulatorContext.state->general_reg[EMULATOR_REG_AX].b.hi;
#else
- return EmulatorContext.Registers[EMULATOR_REG_AX].HighByte;
+ return EmulatorContext.GeneralRegs[EMULATOR_REG_AX].HighByte;
#endif
}
@@ -76,7 +76,7 @@
#ifndef NEW_EMULATOR
EmulatorContext.state->general_reg[EMULATOR_REG_AX].b.hi = Value;
#else
- EmulatorContext.Registers[EMULATOR_REG_AX].HighByte = Value;
+ EmulatorContext.GeneralRegs[EMULATOR_REG_AX].HighByte = Value;
#endif
}
@@ -87,7 +87,7 @@
#ifndef NEW_EMULATOR
return EmulatorContext.state->general_reg[EMULATOR_REG_AX].b.lo;
#else
- return EmulatorContext.Registers[EMULATOR_REG_AX].LowByte;
+ return EmulatorContext.GeneralRegs[EMULATOR_REG_AX].LowByte;
#endif
}
@@ -98,7 +98,7 @@
#ifndef NEW_EMULATOR
EmulatorContext.state->general_reg[EMULATOR_REG_AX].b.lo = Value;
#else
- EmulatorContext.Registers[EMULATOR_REG_AX].LowByte = Value;
+ EmulatorContext.GeneralRegs[EMULATOR_REG_AX].LowByte = Value;
#endif
}
@@ -109,7 +109,7 @@
#ifndef NEW_EMULATOR
return EmulatorContext.state->general_reg[EMULATOR_REG_BX].val;
#else
- return EmulatorContext.Registers[EMULATOR_REG_BX].Long;
+ return EmulatorContext.GeneralRegs[EMULATOR_REG_BX].Long;
#endif
}
@@ -120,7 +120,7 @@
#ifndef NEW_EMULATOR
EmulatorContext.state->general_reg[EMULATOR_REG_BX].val = Value;
#else
- EmulatorContext.Registers[EMULATOR_REG_BX].Long = Value;
+ EmulatorContext.GeneralRegs[EMULATOR_REG_BX].Long = Value;
#endif
}
@@ -131,7 +131,7 @@
#ifndef NEW_EMULATOR
return EmulatorContext.state->general_reg[EMULATOR_REG_BX].w.lo;
#else
- return EmulatorContext.Registers[EMULATOR_REG_BX].LowWord;
+ return EmulatorContext.GeneralRegs[EMULATOR_REG_BX].LowWord;
#endif
}
@@ -142,7 +142,7 @@
#ifndef NEW_EMULATOR
EmulatorContext.state->general_reg[EMULATOR_REG_BX].w.lo = Value;
#else
- EmulatorContext.Registers[EMULATOR_REG_BX].LowWord = Value;
+ EmulatorContext.GeneralRegs[EMULATOR_REG_BX].LowWord = Value;
#endif
}
@@ -153,7 +153,7 @@
#ifndef NEW_EMULATOR
return EmulatorContext.state->general_reg[EMULATOR_REG_BX].b.hi;
#else
- return EmulatorContext.Registers[EMULATOR_REG_BX].HighByte;
+ return EmulatorContext.GeneralRegs[EMULATOR_REG_BX].HighByte;
#endif
}
@@ -164,7 +164,7 @@
#ifndef NEW_EMULATOR
EmulatorContext.state->general_reg[EMULATOR_REG_BX].b.hi = Value;
#else
- EmulatorContext.Registers[EMULATOR_REG_BX].HighByte = Value;
+ EmulatorContext.GeneralRegs[EMULATOR_REG_BX].HighByte = Value;
#endif
}
@@ -175,7 +175,7 @@
#ifndef NEW_EMULATOR
return EmulatorContext.state->general_reg[EMULATOR_REG_BX].b.lo;
#else
- return EmulatorContext.Registers[EMULATOR_REG_BX].LowByte;
+ return EmulatorContext.GeneralRegs[EMULATOR_REG_BX].LowByte;
#endif
}
@@ -186,7 +186,7 @@
#ifndef NEW_EMULATOR
EmulatorContext.state->general_reg[EMULATOR_REG_BX].b.lo = Value;
#else
- EmulatorContext.Registers[EMULATOR_REG_BX].LowByte = Value;
+ EmulatorContext.GeneralRegs[EMULATOR_REG_BX].LowByte = Value;
#endif
}
@@ -199,7 +199,7 @@
#ifndef NEW_EMULATOR
return EmulatorContext.state->general_reg[EMULATOR_REG_CX].val;
#else
- return EmulatorContext.Registers[EMULATOR_REG_CX].Long;
+ return EmulatorContext.GeneralRegs[EMULATOR_REG_CX].Long;
#endif
}
@@ -210,7 +210,7 @@
#ifndef NEW_EMULATOR
EmulatorContext.state->general_reg[EMULATOR_REG_CX].val = Value;
#else
- EmulatorContext.Registers[EMULATOR_REG_CX].Long = Value;
+ EmulatorContext.GeneralRegs[EMULATOR_REG_CX].Long = Value;
#endif
}
@@ -221,7 +221,7 @@
#ifndef NEW_EMULATOR
return EmulatorContext.state->general_reg[EMULATOR_REG_CX].w.lo;
#else
- return EmulatorContext.Registers[EMULATOR_REG_CX].LowWord;
+ return EmulatorContext.GeneralRegs[EMULATOR_REG_CX].LowWord;
#endif
}
@@ -232,7 +232,7 @@
#ifndef NEW_EMULATOR
EmulatorContext.state->general_reg[EMULATOR_REG_CX].w.lo = Value;
#else
- EmulatorContext.Registers[EMULATOR_REG_CX].LowWord = Value;
+ EmulatorContext.GeneralRegs[EMULATOR_REG_CX].LowWord = Value;
#endif
}
@@ -243,7 +243,7 @@
#ifndef NEW_EMULATOR
return EmulatorContext.state->general_reg[EMULATOR_REG_CX].b.hi;
#else
- return EmulatorContext.Registers[EMULATOR_REG_CX].HighByte;
+ return EmulatorContext.GeneralRegs[EMULATOR_REG_CX].HighByte;
#endif
}
@@ -254,7 +254,7 @@
#ifndef NEW_EMULATOR
EmulatorContext.state->general_reg[EMULATOR_REG_CX].b.hi = Value;
#else
- EmulatorContext.Registers[EMULATOR_REG_CX].HighByte = Value;
+ EmulatorContext.GeneralRegs[EMULATOR_REG_CX].HighByte = Value;
#endif
}
@@ -265,7 +265,7 @@
#ifndef NEW_EMULATOR
return EmulatorContext.state->general_reg[EMULATOR_REG_CX].b.lo;
#else
- return EmulatorContext.Registers[EMULATOR_REG_CX].LowByte;
+ return EmulatorContext.GeneralRegs[EMULATOR_REG_CX].LowByte;
#endif
}
@@ -276,7 +276,7 @@
#ifndef NEW_EMULATOR
EmulatorContext.state->general_reg[EMULATOR_REG_CX].b.lo = Value;
#else
- EmulatorContext.Registers[EMULATOR_REG_CX].LowByte = Value;
+ EmulatorContext.GeneralRegs[EMULATOR_REG_CX].LowByte = Value;
#endif
}
@@ -289,7 +289,7 @@
#ifndef NEW_EMULATOR
return EmulatorContext.state->general_reg[EMULATOR_REG_DX].val;
#else
- return EmulatorContext.Registers[EMULATOR_REG_DX].Long;
+ return EmulatorContext.GeneralRegs[EMULATOR_REG_DX].Long;
#endif
}
@@ -300,7 +300,7 @@
#ifndef NEW_EMULATOR
EmulatorContext.state->general_reg[EMULATOR_REG_DX].val = Value;
#else
- EmulatorContext.Registers[EMULATOR_REG_DX].Long = Value;
+ EmulatorContext.GeneralRegs[EMULATOR_REG_DX].Long = Value;
#endif
}
@@ -311,7 +311,7 @@
#ifndef NEW_EMULATOR
return EmulatorContext.state->general_reg[EMULATOR_REG_DX].w.lo;
#else
- return EmulatorContext.Registers[EMULATOR_REG_DX].LowWord;
+ return EmulatorContext.GeneralRegs[EMULATOR_REG_DX].LowWord;
#endif
}
@@ -322,7 +322,7 @@
#ifndef NEW_EMULATOR
EmulatorContext.state->general_reg[EMULATOR_REG_DX].w.lo = Value;
#else
- EmulatorContext.Registers[EMULATOR_REG_DX].LowWord = Value;
+ EmulatorContext.GeneralRegs[EMULATOR_REG_DX].LowWord = Value;
#endif
}
@@ -333,7 +333,7 @@
#ifndef NEW_EMULATOR
return EmulatorContext.state->general_reg[EMULATOR_REG_DX].b.hi;
#else
- return EmulatorContext.Registers[EMULATOR_REG_DX].HighByte;
+ return EmulatorContext.GeneralRegs[EMULATOR_REG_DX].HighByte;
#endif
}
@@ -344,7 +344,7 @@
#ifndef NEW_EMULATOR
EmulatorContext.state->general_reg[EMULATOR_REG_DX].b.hi = Value;
#else
- EmulatorContext.Registers[EMULATOR_REG_DX].HighByte = Value;
+ EmulatorContext.GeneralRegs[EMULATOR_REG_DX].HighByte = Value;
#endif
}
@@ -355,7 +355,7 @@
#ifndef NEW_EMULATOR
return EmulatorContext.state->general_reg[EMULATOR_REG_DX].b.lo;
#else
- return EmulatorContext.Registers[EMULATOR_REG_DX].LowByte;
+ return EmulatorContext.GeneralRegs[EMULATOR_REG_DX].LowByte;
#endif
}
@@ -366,7 +366,7 @@
#ifndef NEW_EMULATOR
EmulatorContext.state->general_reg[EMULATOR_REG_DX].b.lo = Value;
#else
- EmulatorContext.Registers[EMULATOR_REG_DX].LowByte = Value;
+ EmulatorContext.GeneralRegs[EMULATOR_REG_DX].LowByte = Value;
#endif
}
@@ -409,7 +409,7 @@
#ifndef NEW_EMULATOR
return EmulatorContext.state->general_reg[EMULATOR_REG_BP].val;
#else
- return EmulatorContext.Registers[EMULATOR_REG_BP].Long;
+ return EmulatorContext.GeneralRegs[EMULATOR_REG_BP].Long;
#endif
}
@@ -420,7 +420,7 @@
#ifndef NEW_EMULATOR
EmulatorContext.state->general_reg[EMULATOR_REG_BP].val = Value;
#else
- EmulatorContext.Registers[EMULATOR_REG_BP].Long = Value;
+ EmulatorContext.GeneralRegs[EMULATOR_REG_BP].Long = Value;
#endif
}
@@ -431,7 +431,7 @@
#ifndef NEW_EMULATOR
return EmulatorContext.state->general_reg[EMULATOR_REG_BP].w.lo;
#else
- return EmulatorContext.Registers[EMULATOR_REG_BP].LowWord;
+ return EmulatorContext.GeneralRegs[EMULATOR_REG_BP].LowWord;
#endif
}
@@ -442,7 +442,7 @@
#ifndef NEW_EMULATOR
EmulatorContext.state->general_reg[EMULATOR_REG_BP].w.lo = Value;
#else
- EmulatorContext.Registers[EMULATOR_REG_BP].LowWord = Value;
+ EmulatorContext.GeneralRegs[EMULATOR_REG_BP].LowWord = Value;
#endif
}
@@ -455,7 +455,7 @@
#ifndef NEW_EMULATOR
return EmulatorContext.state->general_reg[EMULATOR_REG_SI].val;
#else
- return EmulatorContext.Registers[EMULATOR_REG_SI].Long;
+ return EmulatorContext.GeneralRegs[EMULATOR_REG_SI].Long;
#endif
}
@@ -466,7 +466,7 @@
#ifndef NEW_EMULATOR
EmulatorContext.state->general_reg[EMULATOR_REG_SI].val = Value;
#else
- EmulatorContext.Registers[EMULATOR_REG_SI].Long = Value;
+ EmulatorContext.GeneralRegs[EMULATOR_REG_SI].Long = Value;
#endif
}
@@ -477,7 +477,7 @@
#ifndef NEW_EMULATOR
return EmulatorContext.state->general_reg[EMULATOR_REG_SI].w.lo;
#else
- return EmulatorContext.Registers[EMULATOR_REG_SI].LowWord;
+ return EmulatorContext.GeneralRegs[EMULATOR_REG_SI].LowWord;
#endif
}
@@ -488,7 +488,7 @@
#ifndef NEW_EMULATOR
EmulatorContext.state->general_reg[EMULATOR_REG_SI].w.lo = Value;
#else
- EmulatorContext.Registers[EMULATOR_REG_SI].LowWord = Value;
+ EmulatorContext.GeneralRegs[EMULATOR_REG_SI].LowWord = Value;
#endif
}
@@ -501,7 +501,7 @@
#ifndef NEW_EMULATOR
return EmulatorContext.state->general_reg[EMULATOR_REG_DI].val;
#else
- return EmulatorContext.Registers[EMULATOR_REG_DI].Long;
+ return EmulatorContext.GeneralRegs[EMULATOR_REG_DI].Long;
#endif
}
@@ -512,7 +512,7 @@
#ifndef NEW_EMULATOR
EmulatorContext.state->general_reg[EMULATOR_REG_DI].val = Value;
#else
- EmulatorContext.Registers[EMULATOR_REG_DI].Long = Value;
+ EmulatorContext.GeneralRegs[EMULATOR_REG_DI].Long = Value;
#endif
}
@@ -523,7 +523,7 @@
#ifndef NEW_EMULATOR
return EmulatorContext.state->general_reg[EMULATOR_REG_DI].w.lo;
#else
- return EmulatorContext.Registers[EMULATOR_REG_DI].LowWord;
+ return EmulatorContext.GeneralRegs[EMULATOR_REG_DI].LowWord;
#endif
}
@@ -534,7 +534,7 @@
#ifndef NEW_EMULATOR
EmulatorContext.state->general_reg[EMULATOR_REG_DI].w.lo = Value;
#else
- EmulatorContext.Registers[EMULATOR_REG_DI].LowWord = Value;
+ EmulatorContext.GeneralRegs[EMULATOR_REG_DI].LowWord = Value;
#endif
}