Author: hbelusca
Date: Tue Sep 30 23:47:23 2014
New Revision: 64429
URL:
http://svn.reactos.org/svn/reactos?rev=64429&view=rev
Log:
[NTVDM]
Code reorganization: Move CPU code to specific files for modularity (prepares ground for
some future work).
We reintroduce also int32.c in which all the int32 handling code is moved to.
Part 1/2
Added:
trunk/reactos/subsystems/ntvdm/cpu/ (with props)
trunk/reactos/subsystems/ntvdm/cpu/bop.c
- copied unchanged from r64385, trunk/reactos/subsystems/ntvdm/bop.c
trunk/reactos/subsystems/ntvdm/cpu/bop.h
- copied unchanged from r64385, trunk/reactos/subsystems/ntvdm/bop.h
trunk/reactos/subsystems/ntvdm/cpu/callback.c
- copied, changed from r64385, trunk/reactos/subsystems/ntvdm/callback.c
trunk/reactos/subsystems/ntvdm/cpu/callback.h
- copied, changed from r64385, trunk/reactos/subsystems/ntvdm/callback.h
trunk/reactos/subsystems/ntvdm/cpu/cpu.c
- copied, changed from r64385, trunk/reactos/subsystems/ntvdm/emulator.c
trunk/reactos/subsystems/ntvdm/cpu/cpu.h
- copied, changed from r64385, trunk/reactos/subsystems/ntvdm/emulator.h
Removed:
trunk/reactos/subsystems/ntvdm/bop.c
trunk/reactos/subsystems/ntvdm/bop.h
trunk/reactos/subsystems/ntvdm/callback.c
trunk/reactos/subsystems/ntvdm/callback.h
Modified:
trunk/reactos/subsystems/ntvdm/CMakeLists.txt
trunk/reactos/subsystems/ntvdm/bios/bios.c
trunk/reactos/subsystems/ntvdm/bios/bios32/bios32.c
trunk/reactos/subsystems/ntvdm/bios/bios32/bios32p.h
trunk/reactos/subsystems/ntvdm/bios/bios32/kbdbios32.c
trunk/reactos/subsystems/ntvdm/bios/bios32/moubios32.c
trunk/reactos/subsystems/ntvdm/bios/bios32/vidbios32.c
trunk/reactos/subsystems/ntvdm/bios/kbdbios.c
trunk/reactos/subsystems/ntvdm/bios/rom.c
trunk/reactos/subsystems/ntvdm/bios/vidbios.c
trunk/reactos/subsystems/ntvdm/clock.c
trunk/reactos/subsystems/ntvdm/dos/dem.c
trunk/reactos/subsystems/ntvdm/dos/dos32krnl/bios.c
trunk/reactos/subsystems/ntvdm/dos/dos32krnl/dos.h
trunk/reactos/subsystems/ntvdm/dos/mouse32.c
trunk/reactos/subsystems/ntvdm/emulator.c
trunk/reactos/subsystems/ntvdm/emulator.h
trunk/reactos/subsystems/ntvdm/int32.c
trunk/reactos/subsystems/ntvdm/int32.h
trunk/reactos/subsystems/ntvdm/registers.c
trunk/reactos/subsystems/ntvdm/vddsup.c
Modified: trunk/reactos/subsystems/ntvdm/CMakeLists.txt
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/ntvdm/CMakeList…
==============================================================================
--- trunk/reactos/subsystems/ntvdm/CMakeLists.txt [iso-8859-1] (original)
+++ trunk/reactos/subsystems/ntvdm/CMakeLists.txt [iso-8859-1] Tue Sep 30 23:47:23 2014
@@ -14,6 +14,9 @@
bios/kbdbios.c
bios/rom.c
bios/vidbios.c
+ cpu/bop.c
+ cpu/callback.c
+ cpu/cpu.c
hardware/cmos.c
hardware/keyboard.c
hardware/mouse.c
@@ -27,10 +30,9 @@
dos/dos32krnl/dosfiles.c
dos/mouse32.c
dos/dem.c
- bop.c
- callback.c
clock.c
emulator.c
+ int32.c
io.c
registers.c
utils.c
Modified: trunk/reactos/subsystems/ntvdm/bios/bios.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/ntvdm/bios/bios…
==============================================================================
--- trunk/reactos/subsystems/ntvdm/bios/bios.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/ntvdm/bios/bios.c [iso-8859-1] Tue Sep 30 23:47:23 2014
@@ -11,8 +11,8 @@
#define NDEBUG
#include "emulator.h"
-#include "callback.h"
-#include "bop.h"
+#include "cpu/callback.h"
+#include "cpu/bop.h"
#include "bios.h"
#include "bios32/bios32.h"
Modified: trunk/reactos/subsystems/ntvdm/bios/bios32/bios32.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/ntvdm/bios/bios…
==============================================================================
--- trunk/reactos/subsystems/ntvdm/bios/bios32/bios32.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/ntvdm/bios/bios32/bios32.c [iso-8859-1] Tue Sep 30 23:47:23
2014
@@ -14,8 +14,9 @@
#include <reactos/buildno.h>
#include "emulator.h"
-#include "callback.h"
-#include "bop.h"
+#include "cpu/cpu.h" // for EMULATOR_FLAG_CF
+#include "int32.h"
+// #include "bop.h"
#include "../bios.h"
#include "../rom.h"
Modified: trunk/reactos/subsystems/ntvdm/bios/bios32/bios32p.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/ntvdm/bios/bios…
==============================================================================
--- trunk/reactos/subsystems/ntvdm/bios/bios32/bios32p.h [iso-8859-1] (original)
+++ trunk/reactos/subsystems/ntvdm/bios/bios32/bios32p.h [iso-8859-1] Tue Sep 30 23:47:23
2014
@@ -14,7 +14,7 @@
#include "ntvdm.h"
#include "../bios.h"
-/**/ #include "callback.h" /**/
+/**/ #include "int32.h" /**/
/* DEFINES ********************************************************************/
Modified: trunk/reactos/subsystems/ntvdm/bios/bios32/kbdbios32.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/ntvdm/bios/bios…
==============================================================================
--- trunk/reactos/subsystems/ntvdm/bios/bios32/kbdbios32.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/ntvdm/bios/bios32/kbdbios32.c [iso-8859-1] Tue Sep 30
23:47:23 2014
@@ -11,7 +11,8 @@
#define NDEBUG
#include "emulator.h"
-#include "callback.h"
+#include "cpu/cpu.h" // for EMULATOR_FLAG_ZF
+#include "int32.h"
#include "kbdbios32.h"
#include "../kbdbios.h"
Modified: trunk/reactos/subsystems/ntvdm/bios/bios32/moubios32.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/ntvdm/bios/bios…
==============================================================================
--- trunk/reactos/subsystems/ntvdm/bios/bios32/moubios32.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/ntvdm/bios/bios32/moubios32.c [iso-8859-1] Tue Sep 30
23:47:23 2014
@@ -11,7 +11,6 @@
#define NDEBUG
#include "emulator.h"
-#include "callback.h"
#include "moubios32.h"
#include "bios32p.h"
Modified: trunk/reactos/subsystems/ntvdm/bios/bios32/vidbios32.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/ntvdm/bios/bios…
==============================================================================
--- trunk/reactos/subsystems/ntvdm/bios/bios32/vidbios32.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/ntvdm/bios/bios32/vidbios32.c [iso-8859-1] Tue Sep 30
23:47:23 2014
@@ -13,7 +13,7 @@
#define NDEBUG
#include "emulator.h"
-#include "callback.h"
+#include "int32.h"
#include "vidbios32.h"
#include "../vidbios.h"
Modified: trunk/reactos/subsystems/ntvdm/bios/kbdbios.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/ntvdm/bios/kbdb…
==============================================================================
--- trunk/reactos/subsystems/ntvdm/bios/kbdbios.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/ntvdm/bios/kbdbios.c [iso-8859-1] Tue Sep 30 23:47:23 2014
@@ -11,8 +11,7 @@
#define NDEBUG
#include "emulator.h"
-#include "callback.h"
-#include "bop.h"
+#include "cpu/bop.h"
#include "bios.h"
// #include "kbdbios.h"
Modified: trunk/reactos/subsystems/ntvdm/bios/rom.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/ntvdm/bios/rom.…
==============================================================================
--- trunk/reactos/subsystems/ntvdm/bios/rom.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/ntvdm/bios/rom.c [iso-8859-1] Tue Sep 30 23:47:23 2014
@@ -11,7 +11,7 @@
#define NDEBUG
#include "emulator.h"
-#include "callback.h"
+#include "cpu/callback.h"
#include "utils.h"
#include "rom.h"
Modified: trunk/reactos/subsystems/ntvdm/bios/vidbios.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/ntvdm/bios/vidb…
==============================================================================
--- trunk/reactos/subsystems/ntvdm/bios/vidbios.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/ntvdm/bios/vidbios.c [iso-8859-1] Tue Sep 30 23:47:23 2014
@@ -12,8 +12,8 @@
#define NDEBUG
#include "emulator.h"
-#include "callback.h"
-#include "bop.h"
+#include "cpu/cpu.h"
+#include "cpu/bop.h"
#include "bios.h"
// #include "vidbios.h"
Removed: trunk/reactos/subsystems/ntvdm/bop.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/ntvdm/bop.c?rev…
==============================================================================
--- trunk/reactos/subsystems/ntvdm/bop.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/ntvdm/bop.c (removed)
@@ -1,50 +0,0 @@
-/*
- * COPYRIGHT: GPL - See COPYING in the top level directory
- * PROJECT: ReactOS Virtual DOS Machine
- * FILE: bop.c
- * PURPOSE: BIOS Operation Handlers
- * PROGRAMMERS: Aleksandar Andrejevic <theflash AT sdf DOT lonestar DOT org>
- * Hermes Belusca-Maito (hermes.belusca(a)sfr.fr)
- */
-
-/* INCLUDES *******************************************************************/
-
-// #define NDEBUG
-
-#include "emulator.h"
-#include "bop.h"
-
-/* PRIVATE VARIABLES **********************************************************/
-
-/*
- * This is the list of registered BOP handlers.
- */
-static EMULATOR_BOP_PROC BopProc[EMULATOR_MAX_BOP_NUM] = { NULL };
-
-/* PUBLIC FUNCTIONS ***********************************************************/
-
-VOID RegisterBop(BYTE BopCode, EMULATOR_BOP_PROC BopHandler)
-{
- BopProc[BopCode] = BopHandler;
-}
-
-VOID WINAPI EmulatorBiosOperation(PFAST486_STATE State, UCHAR BopCode)
-{
- WORD StackSegment, StackPointer;
- LPWORD Stack;
-
- /* Get the SS:SP */
- StackSegment = State->SegmentRegs[FAST486_REG_SS].Selector;
- StackPointer = State->GeneralRegs[FAST486_REG_ESP].LowWord;
-
- /* Get the stack */
- Stack = (LPWORD)SEG_OFF_TO_PTR(StackSegment, StackPointer);
-
- /* Call the BOP handler */
- if (BopProc[BopCode] != NULL)
- BopProc[BopCode](Stack);
- else
- DPRINT("Invalid BOP code: 0x%02X\n", BopCode);
-}
-
-/* EOF */
Removed: trunk/reactos/subsystems/ntvdm/bop.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/ntvdm/bop.h?rev…
==============================================================================
--- trunk/reactos/subsystems/ntvdm/bop.h [iso-8859-1] (original)
+++ trunk/reactos/subsystems/ntvdm/bop.h (removed)
@@ -1,28 +0,0 @@
-/*
- * COPYRIGHT: GPL - See COPYING in the top level directory
- * PROJECT: ReactOS Virtual DOS Machine
- * FILE: bop.h
- * PURPOSE: BIOS Operation Handlers
- * PROGRAMMERS: Aleksandar Andrejevic <theflash AT sdf DOT lonestar DOT org>
- * Hermes Belusca-Maito (hermes.belusca(a)sfr.fr)
- */
-
-#ifndef _BOP_H_
-#define _BOP_H_
-
-/* DEFINES ********************************************************************/
-
-/* BOP Identifiers */
-#define EMULATOR_BOP 0xC4C4
-#define EMULATOR_MAX_BOP_NUM 0xFF + 1
-
-/* FUNCTIONS ******************************************************************/
-
-typedef VOID (WINAPI *EMULATOR_BOP_PROC)(LPWORD Stack);
-
-VOID RegisterBop(BYTE BopCode, EMULATOR_BOP_PROC BopHandler);
-VOID WINAPI EmulatorBiosOperation(PFAST486_STATE State, UCHAR BopCode);
-
-#endif // _BOP_H_
-
-/* EOF */
Removed: trunk/reactos/subsystems/ntvdm/callback.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/ntvdm/callback.…
==============================================================================
--- trunk/reactos/subsystems/ntvdm/callback.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/ntvdm/callback.c (removed)
@@ -1,310 +0,0 @@
-/*
- * COPYRIGHT: GPL - See COPYING in the top level directory
- * PROJECT: ReactOS Virtual DOS Machine
- * FILE: callback.c
- * PURPOSE: 16 and 32-bit Callbacks Support
- * PROGRAMMERS: Aleksandar Andrejevic <theflash AT sdf DOT lonestar DOT org>
- * Hermes Belusca-Maito (hermes.belusca(a)sfr.fr)
- */
-
-/******************************************************************************\
-| WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! WARNING!
-|
-| Callbacks support supposes implicitely that the callbacks are used
-| in the SAME thread as the CPU thread, otherwise messing in parallel
-| with the CPU registers is 100% prone to bugs!!
-\******************************************************************************/
-
-/* INCLUDES *******************************************************************/
-
-#define NDEBUG
-
-#include "emulator.h"
-#include "callback.h"
-
-#include "bop.h"
-#include <isvbop.h>
-
-/* PRIVATE VARIABLES **********************************************************/
-
-/*
- * This is the list of registered 32-bit Interrupt handlers.
- */
-static EMULATOR_INT32_PROC Int32Proc[EMULATOR_MAX_INT32_NUM] = { NULL };
-
-/* BOP Identifiers */
-#define BOP_CONTROL 0xFF // Control BOP Handler
- #define BOP_CONTROL_DEFFUNC 0x00 // Default Control BOP Function
- #define BOP_CONTROL_INT32 0xFF // 32-bit Interrupt dispatcher
- // function code for the Control BOP Handler
-
-#define BOP(num) LOBYTE(EMULATOR_BOP), HIBYTE(EMULATOR_BOP), (num)
-#define UnSimulate16(trap) \
-do { \
- *(PUSHORT)(trap) = EMULATOR_BOP; \
- (trap) += sizeof(USHORT); \
- *(trap) = BOP_UNSIMULATE; \
-} while(0)
-// #define UnSimulate16 MAKELONG(EMULATOR_BOP, BOP_UNSIMULATE) //
BOP(BOP_UNSIMULATE)
-
-#define CALL16_TRAMPOLINE_SIZE (1 * sizeof(ULONGLONG))
-#define INT16_TRAMPOLINE_SIZE (1 * sizeof(ULONGLONG))
-
-//
-// WARNING WARNING!!
-//
-// If you modify the code stubs here, think also
-// about updating them in int32.c too!!
-//
-
-/* 16-bit generic interrupt code for calling a 32-bit interrupt handler */
-static BYTE Int16To32[] =
-{
- 0xFA, // cli
-
- /* Push the value of the interrupt to be called */
- 0x6A, 0xFF, // push i (patchable to 0x6A, 0xIntNum)
-
- /* The BOP Sequence */
-// BOP_SEQ:
- 0xF8, // clc
- BOP(BOP_CONTROL), // Control BOP
- BOP_CONTROL_INT32, // 32-bit Interrupt dispatcher
-
- 0x73, 0x04, // jnc EXIT (offset +4)
-
- 0xFB, // sti
-
- // HACK: The following instruction should be HLT!
- 0x90, // nop
-
- 0xEB, 0xF5, // jmp BOP_SEQ (offset -11)
-
-// EXIT:
- 0x44, 0x44, // inc sp, inc sp
- 0xCF, // iret
-};
-const ULONG Int16To32StubSize = sizeof(Int16To32);
-
-/* PUBLIC FUNCTIONS ***********************************************************/
-
-VOID
-InitializeContext(IN PCALLBACK16 Context,
- IN USHORT Segment,
- IN USHORT Offset)
-{
- Context->TrampolineFarPtr = MAKELONG(Offset, Segment);
- Context->TrampolineSize = max(CALL16_TRAMPOLINE_SIZE,
- INT16_TRAMPOLINE_SIZE);
- Context->Segment = Segment;
- Context->NextOffset = Offset + Context->TrampolineSize;
-}
-
-VOID
-Call16(IN USHORT Segment,
- IN USHORT Offset)
-{
- /* Save CS:IP */
- USHORT OrgCS = getCS();
- USHORT OrgIP = getIP();
-
- /* Set the new CS:IP */
- setCS(Segment);
- setIP(Offset);
-
- DPRINT("Call16(%04X:%04X)\n", Segment, Offset);
-
- /* Start CPU simulation */
- EmulatorSimulate();
-
- /* Restore CS:IP */
- setCS(OrgCS);
- setIP(OrgIP);
-}
-
-
-
-ULONG
-RegisterCallback16(IN ULONG FarPtr,
- IN LPBYTE CallbackCode,
- IN SIZE_T CallbackSize,
- OUT PSIZE_T CodeSize OPTIONAL)
-{
- LPBYTE CodeStart = (LPBYTE)FAR_POINTER(FarPtr);
- LPBYTE Code = CodeStart;
-
- SIZE_T OurCodeSize = CallbackSize;
-
- if (CallbackCode == NULL) CallbackSize = 0;
-
- if (CallbackCode)
- {
- /* 16-bit interrupt code */
- RtlCopyMemory(Code, CallbackCode, CallbackSize);
- Code += CallbackSize;
- }
-
- /* Return the real size of the code if needed */
- if (CodeSize) *CodeSize = OurCodeSize; // == (ULONG_PTR)Code - (ULONG_PTR)CodeStart;
-
- // /* Return the entry-point address for 32-bit calls */
- // return (ULONG_PTR)(CodeStart + CallbackSize);
- return OurCodeSize;
-}
-
-VOID
-RunCallback16(IN PCALLBACK16 Context,
- IN ULONG FarPtr)
-{
- PUCHAR TrampolineBase = (PUCHAR)FAR_POINTER(Context->TrampolineFarPtr);
- PUCHAR Trampoline = TrampolineBase;
- UCHAR OldTrampoline[CALL16_TRAMPOLINE_SIZE];
-
- /* Save the old trampoline */
- ((PULONGLONG)&OldTrampoline)[0] = ((PULONGLONG)TrampolineBase)[0];
-
- DPRINT1("RunCallback16(0x%p)\n", FarPtr);
-
- /* Build the generic entry-point for 16-bit far calls */
- *Trampoline++ = 0x9A; // Call far seg:off
- *(PULONG)Trampoline = FarPtr;
- Trampoline += sizeof(ULONG);
- UnSimulate16(Trampoline);
-
- /* Perform the call */
- Call16(HIWORD(Context->TrampolineFarPtr),
- LOWORD(Context->TrampolineFarPtr));
-
- /* Restore the old trampoline */
- ((PULONGLONG)TrampolineBase)[0] = ((PULONGLONG)&OldTrampoline)[0];
-}
-
-
-
-ULONG
-RegisterInt16(IN ULONG FarPtr,
- IN BYTE IntNumber,
- IN LPBYTE CallbackCode,
- IN SIZE_T CallbackSize,
- OUT PSIZE_T CodeSize OPTIONAL)
-{
- /* Get a pointer to the IVT and set the corresponding entry (far pointer) */
- LPDWORD IntVecTable = (LPDWORD)SEG_OFF_TO_PTR(0x0000, 0x0000);
- IntVecTable[IntNumber] = FarPtr;
-
- /* Register the 16-bit callback */
- return RegisterCallback16(FarPtr,
- CallbackCode,
- CallbackSize,
- CodeSize);
-}
-
-ULONG
-RegisterInt32(IN ULONG FarPtr,
- IN BYTE IntNumber,
- IN EMULATOR_INT32_PROC IntHandler,
- OUT PSIZE_T CodeSize OPTIONAL)
-{
- /* Array for holding our copy of the 16-bit interrupt callback */
- BYTE IntCallback[sizeof(Int16To32)/sizeof(BYTE)];
-
- /* Check whether the 32-bit interrupt was already registered */
-#if 0
- if (Int32Proc[IntNumber] != NULL)
- {
- DPRINT1("RegisterInt32: Interrupt 0x%02X already registered!\n",
IntNumber);
- return 0;
- }
-#endif
-
- /* Register the 32-bit interrupt handler */
- Int32Proc[IntNumber] = IntHandler;
-
- /* Copy the generic 16-bit interrupt callback and patch it */
- RtlCopyMemory(IntCallback, Int16To32, sizeof(Int16To32));
- IntCallback[2] = IntNumber;
-
- /* Register the 16-bit interrupt callback */
- return RegisterInt16(FarPtr,
- IntNumber,
- IntCallback,
- sizeof(IntCallback),
- CodeSize);
-}
-
-VOID
-Int32Call(IN PCALLBACK16 Context,
- IN BYTE IntNumber)
-{
- PUCHAR TrampolineBase = (PUCHAR)FAR_POINTER(Context->TrampolineFarPtr);
- PUCHAR Trampoline = TrampolineBase;
- UCHAR OldTrampoline[INT16_TRAMPOLINE_SIZE];
-
- DPRINT("Int32Call(0x%02X)\n", IntNumber);
-
- /* Save the old trampoline */
- ((PULONGLONG)&OldTrampoline)[0] = ((PULONGLONG)TrampolineBase)[0];
-
- /* Build the generic entry-point for 16-bit calls */
- if (IntNumber == 0x03)
- {
- /* We are redefining for INT 03h */
- *Trampoline++ = 0xCC; // Call INT 03h
- /** *Trampoline++ = 0x90; // nop **/
- }
- else
- {
- /* Normal interrupt */
- *Trampoline++ = 0xCD; // Call INT XXh
- *Trampoline++ = IntNumber;
- }
- UnSimulate16(Trampoline);
-
- /* Perform the call */
- Call16(HIWORD(Context->TrampolineFarPtr),
- LOWORD(Context->TrampolineFarPtr));
-
- /* Restore the old trampoline */
- ((PULONGLONG)TrampolineBase)[0] = ((PULONGLONG)&OldTrampoline)[0];
-}
-
-
-
-VOID WINAPI Int32Dispatch(LPWORD Stack)
-{
- /* Get the interrupt number */
- BYTE IntNum = LOBYTE(Stack[STACK_INT_NUM]);
-
- /* Call the 32-bit Interrupt handler */
- if (Int32Proc[IntNum] != NULL)
- Int32Proc[IntNum](Stack);
- else
- DPRINT1("Unhandled 32-bit interrupt: 0x%02X, AX = 0x%04X\n", IntNum,
getAX());
-}
-
-static VOID WINAPI ControlBop(LPWORD Stack)
-{
- /* Get the Function Number and skip it */
- BYTE FuncNum = *(PBYTE)SEG_OFF_TO_PTR(getCS(), getIP());
- setIP(getIP() + 1);
-
- switch (FuncNum)
- {
- case BOP_CONTROL_INT32:
- Int32Dispatch(Stack);
- break;
-
- default:
- // DPRINT1("Unassigned Control BOP Function: 0x%02X\n", FuncNum);
- DisplayMessage(L"Unassigned Control BOP Function: 0x%02X",
FuncNum);
- break;
- }
-}
-
-VOID InitializeCallbacks(VOID)
-{
- /* Register the Control BOP */
- RegisterBop(BOP_CONTROL, ControlBop);
-}
-
-/* EOF */
Removed: trunk/reactos/subsystems/ntvdm/callback.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/ntvdm/callback.…
==============================================================================
--- trunk/reactos/subsystems/ntvdm/callback.h [iso-8859-1] (original)
+++ trunk/reactos/subsystems/ntvdm/callback.h (removed)
@@ -1,73 +0,0 @@
-/*
- * COPYRIGHT: GPL - See COPYING in the top level directory
- * PROJECT: ReactOS Virtual DOS Machine
- * FILE: callback.h
- * PURPOSE: 32-bit Interrupt Handlers
- * PROGRAMMERS: Aleksandar Andrejevic <theflash AT sdf DOT lonestar DOT org>
- * Hermes Belusca-Maito (hermes.belusca(a)sfr.fr)
- */
-
-#ifndef _CALLBACK_H_
-#define _CALLBACK_H_
-
-/* DEFINES ********************************************************************/
-
-/* 32-bit Interrupt Identifiers */
-#define EMULATOR_MAX_INT32_NUM 0xFF + 1
-
-typedef struct _CALLBACK16
-{
- ULONG TrampolineFarPtr; // Where the trampoline zone is placed
- ULONG TrampolineSize; // Size of the trampoline zone
- USHORT Segment;
- USHORT NextOffset;
-} CALLBACK16, *PCALLBACK16;
-
-extern const ULONG Int16To32StubSize;
-
-/* FUNCTIONS ******************************************************************/
-
-typedef VOID (WINAPI *EMULATOR_INT32_PROC)(LPWORD Stack);
-
-VOID
-InitializeContext(IN PCALLBACK16 Context,
- IN USHORT Segment,
- IN USHORT Offset);
-
-VOID
-Call16(IN USHORT Segment,
- IN USHORT Offset);
-
-ULONG
-RegisterCallback16(IN ULONG FarPtr,
- IN LPBYTE CallbackCode,
- IN SIZE_T CallbackSize,
- OUT PSIZE_T CodeSize OPTIONAL);
-
-VOID
-RunCallback16(IN PCALLBACK16 Context,
- IN ULONG FarPtr);
-
-ULONG
-RegisterInt16(IN ULONG FarPtr,
- IN BYTE IntNumber,
- IN LPBYTE CallbackCode,
- IN SIZE_T CallbackSize,
- OUT PSIZE_T CodeSize OPTIONAL);
-
-ULONG
-RegisterInt32(IN ULONG FarPtr,
- IN BYTE IntNumber,
- IN EMULATOR_INT32_PROC IntHandler,
- OUT PSIZE_T CodeSize OPTIONAL);
-
-VOID
-Int32Call(IN PCALLBACK16 Context,
- IN BYTE IntNumber);
-
-VOID WINAPI Int32Dispatch(LPWORD Stack);
-VOID InitializeCallbacks(VOID);
-
-#endif // _CALLBACK_H_
-
-/* EOF */
Modified: trunk/reactos/subsystems/ntvdm/clock.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/ntvdm/clock.c?r…
==============================================================================
--- trunk/reactos/subsystems/ntvdm/clock.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/ntvdm/clock.c [iso-8859-1] Tue Sep 30 23:47:23 2014
@@ -12,6 +12,7 @@
#define NDEBUG
#include "emulator.h"
+#include "cpu/cpu.h"
// #include "clock.h"
@@ -62,7 +63,7 @@
VOID ClockUpdate(VOID)
{
- extern BOOLEAN CpuSimulate;
+ extern BOOLEAN CpuRunning;
UINT i;
#ifdef WORKING_TIMER
@@ -137,9 +138,9 @@
VgaHorizontalRetrace();
/* Continue CPU emulation */
- for (i = 0; VdmRunning && CpuSimulate && (i < STEPS_PER_CYCLE);
i++)
+ for (i = 0; VdmRunning && CpuRunning && (i < STEPS_PER_CYCLE);
i++)
{
- EmulatorStep();
+ CpuStep();
#ifdef IPS_DISPLAY
Cycles++;
#endif
Propchange: trunk/reactos/subsystems/ntvdm/cpu/
------------------------------------------------------------------------------
--- bugtraq:logregex (added)
+++ bugtraq:logregex Tue Sep 30 23:47:23 2014
@@ -0,0 +1,2 @@
+([Ii]ssue|[Bb]ug)s? #?(\d+)(,? ?#?(\d+))*(,? ?(and |or )?#?(\d+))?
+(\d+)
Propchange: trunk/reactos/subsystems/ntvdm/cpu/
------------------------------------------------------------------------------
bugtraq:message = See issue #%BUGID% for more details.
Propchange: trunk/reactos/subsystems/ntvdm/cpu/
------------------------------------------------------------------------------
bugtraq:url =
http://www.reactos.org/bugzilla/show_bug.cgi?id=%BUGID%
Propchange: trunk/reactos/subsystems/ntvdm/cpu/
------------------------------------------------------------------------------
tsvn:logminsize = 10
Copied: trunk/reactos/subsystems/ntvdm/cpu/callback.c (from r64385,
trunk/reactos/subsystems/ntvdm/callback.c)
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/ntvdm/cpu/callb…
==============================================================================
--- trunk/reactos/subsystems/ntvdm/callback.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/ntvdm/cpu/callback.c [iso-8859-1] Tue Sep 30 23:47:23 2014
@@ -19,85 +19,48 @@
#define NDEBUG
+#include "cpu.h"
+#include "callback.h"
#include "emulator.h"
-#include "callback.h"
#include "bop.h"
#include <isvbop.h>
/* PRIVATE VARIABLES **********************************************************/
-/*
- * This is the list of registered 32-bit Interrupt handlers.
- */
-static EMULATOR_INT32_PROC Int32Proc[EMULATOR_MAX_INT32_NUM] = { NULL };
+#define TRAMPOLINE_SIZE sizeof(ULONGLONG)
-/* BOP Identifiers */
-#define BOP_CONTROL 0xFF // Control BOP Handler
- #define BOP_CONTROL_DEFFUNC 0x00 // Default Control BOP Function
- #define BOP_CONTROL_INT32 0xFF // 32-bit Interrupt dispatcher
- // function code for the Control BOP Handler
-
-#define BOP(num) LOBYTE(EMULATOR_BOP), HIBYTE(EMULATOR_BOP), (num)
-#define UnSimulate16(trap) \
-do { \
- *(PUSHORT)(trap) = EMULATOR_BOP; \
- (trap) += sizeof(USHORT); \
- *(trap) = BOP_UNSIMULATE; \
-} while(0)
-// #define UnSimulate16 MAKELONG(EMULATOR_BOP, BOP_UNSIMULATE) //
BOP(BOP_UNSIMULATE)
-
-#define CALL16_TRAMPOLINE_SIZE (1 * sizeof(ULONGLONG))
-#define INT16_TRAMPOLINE_SIZE (1 * sizeof(ULONGLONG))
-
-//
-// WARNING WARNING!!
-//
-// If you modify the code stubs here, think also
-// about updating them in int32.c too!!
-//
-
-/* 16-bit generic interrupt code for calling a 32-bit interrupt handler */
-static BYTE Int16To32[] =
+static BYTE Yield[] =
{
- 0xFA, // cli
-
- /* Push the value of the interrupt to be called */
- 0x6A, 0xFF, // push i (patchable to 0x6A, 0xIntNum)
-
- /* The BOP Sequence */
-// BOP_SEQ:
- 0xF8, // clc
- BOP(BOP_CONTROL), // Control BOP
- BOP_CONTROL_INT32, // 32-bit Interrupt dispatcher
-
- 0x73, 0x04, // jnc EXIT (offset +4)
-
- 0xFB, // sti
-
- // HACK: The following instruction should be HLT!
- 0x90, // nop
-
- 0xEB, 0xF5, // jmp BOP_SEQ (offset -11)
-
-// EXIT:
- 0x44, 0x44, // inc sp, inc sp
- 0xCF, // iret
+ 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90,
+ 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, // 13x nop
+ BOP(BOP_UNSIMULATE), // UnSimulate16 BOP
};
-const ULONG Int16To32StubSize = sizeof(Int16To32);
+C_ASSERT(sizeof(Yield) == 16 * sizeof(BYTE));
/* PUBLIC FUNCTIONS ***********************************************************/
+
+VOID
+InitializeContextEx(IN PCALLBACK16 Context,
+ IN ULONG TrampolineSize,
+ IN USHORT Segment,
+ IN USHORT Offset)
+{
+ Context->TrampolineFarPtr = MAKELONG(Offset, Segment);
+ Context->TrampolineSize = max(TRAMPOLINE_SIZE, TrampolineSize);
+ Context->Segment = Segment;
+ Context->NextOffset = Offset + Context->TrampolineSize;
+}
VOID
InitializeContext(IN PCALLBACK16 Context,
IN USHORT Segment,
IN USHORT Offset)
{
- Context->TrampolineFarPtr = MAKELONG(Offset, Segment);
- Context->TrampolineSize = max(CALL16_TRAMPOLINE_SIZE,
- INT16_TRAMPOLINE_SIZE);
- Context->Segment = Segment;
- Context->NextOffset = Offset + Context->TrampolineSize;
+ InitializeContextEx(Context,
+ TRAMPOLINE_SIZE,
+ Segment,
+ Offset);
}
VOID
@@ -115,14 +78,39 @@
DPRINT("Call16(%04X:%04X)\n", Segment, Offset);
/* Start CPU simulation */
- EmulatorSimulate();
+ CpuSimulate();
/* Restore CS:IP */
setCS(OrgCS);
setIP(OrgIP);
}
+VOID
+RunCallback16(IN PCALLBACK16 Context,
+ IN ULONG FarPtr)
+{
+ PUCHAR TrampolineBase = (PUCHAR)FAR_POINTER(Context->TrampolineFarPtr);
+ PUCHAR Trampoline = TrampolineBase;
+ UCHAR OldTrampoline[TRAMPOLINE_SIZE];
+ /* Save the old trampoline */
+ ((PULONGLONG)&OldTrampoline)[0] = ((PULONGLONG)TrampolineBase)[0];
+
+ DPRINT("RunCallback16(0x%p)\n", FarPtr);
+
+ /* Build the generic entry-point for 16-bit far calls */
+ *Trampoline++ = 0x9A; // Call far seg:off
+ *(PULONG)Trampoline = FarPtr;
+ Trampoline += sizeof(ULONG);
+ UnSimulate16(Trampoline);
+
+ /* Perform the call */
+ Call16(HIWORD(Context->TrampolineFarPtr),
+ LOWORD(Context->TrampolineFarPtr));
+
+ /* Restore the old trampoline */
+ ((PULONGLONG)TrampolineBase)[0] = ((PULONGLONG)&OldTrampoline)[0];
+}
ULONG
RegisterCallback16(IN ULONG FarPtr,
@@ -152,159 +140,4 @@
return OurCodeSize;
}
-VOID
-RunCallback16(IN PCALLBACK16 Context,
- IN ULONG FarPtr)
-{
- PUCHAR TrampolineBase = (PUCHAR)FAR_POINTER(Context->TrampolineFarPtr);
- PUCHAR Trampoline = TrampolineBase;
- UCHAR OldTrampoline[CALL16_TRAMPOLINE_SIZE];
-
- /* Save the old trampoline */
- ((PULONGLONG)&OldTrampoline)[0] = ((PULONGLONG)TrampolineBase)[0];
-
- DPRINT1("RunCallback16(0x%p)\n", FarPtr);
-
- /* Build the generic entry-point for 16-bit far calls */
- *Trampoline++ = 0x9A; // Call far seg:off
- *(PULONG)Trampoline = FarPtr;
- Trampoline += sizeof(ULONG);
- UnSimulate16(Trampoline);
-
- /* Perform the call */
- Call16(HIWORD(Context->TrampolineFarPtr),
- LOWORD(Context->TrampolineFarPtr));
-
- /* Restore the old trampoline */
- ((PULONGLONG)TrampolineBase)[0] = ((PULONGLONG)&OldTrampoline)[0];
-}
-
-
-
-ULONG
-RegisterInt16(IN ULONG FarPtr,
- IN BYTE IntNumber,
- IN LPBYTE CallbackCode,
- IN SIZE_T CallbackSize,
- OUT PSIZE_T CodeSize OPTIONAL)
-{
- /* Get a pointer to the IVT and set the corresponding entry (far pointer) */
- LPDWORD IntVecTable = (LPDWORD)SEG_OFF_TO_PTR(0x0000, 0x0000);
- IntVecTable[IntNumber] = FarPtr;
-
- /* Register the 16-bit callback */
- return RegisterCallback16(FarPtr,
- CallbackCode,
- CallbackSize,
- CodeSize);
-}
-
-ULONG
-RegisterInt32(IN ULONG FarPtr,
- IN BYTE IntNumber,
- IN EMULATOR_INT32_PROC IntHandler,
- OUT PSIZE_T CodeSize OPTIONAL)
-{
- /* Array for holding our copy of the 16-bit interrupt callback */
- BYTE IntCallback[sizeof(Int16To32)/sizeof(BYTE)];
-
- /* Check whether the 32-bit interrupt was already registered */
-#if 0
- if (Int32Proc[IntNumber] != NULL)
- {
- DPRINT1("RegisterInt32: Interrupt 0x%02X already registered!\n",
IntNumber);
- return 0;
- }
-#endif
-
- /* Register the 32-bit interrupt handler */
- Int32Proc[IntNumber] = IntHandler;
-
- /* Copy the generic 16-bit interrupt callback and patch it */
- RtlCopyMemory(IntCallback, Int16To32, sizeof(Int16To32));
- IntCallback[2] = IntNumber;
-
- /* Register the 16-bit interrupt callback */
- return RegisterInt16(FarPtr,
- IntNumber,
- IntCallback,
- sizeof(IntCallback),
- CodeSize);
-}
-
-VOID
-Int32Call(IN PCALLBACK16 Context,
- IN BYTE IntNumber)
-{
- PUCHAR TrampolineBase = (PUCHAR)FAR_POINTER(Context->TrampolineFarPtr);
- PUCHAR Trampoline = TrampolineBase;
- UCHAR OldTrampoline[INT16_TRAMPOLINE_SIZE];
-
- DPRINT("Int32Call(0x%02X)\n", IntNumber);
-
- /* Save the old trampoline */
- ((PULONGLONG)&OldTrampoline)[0] = ((PULONGLONG)TrampolineBase)[0];
-
- /* Build the generic entry-point for 16-bit calls */
- if (IntNumber == 0x03)
- {
- /* We are redefining for INT 03h */
- *Trampoline++ = 0xCC; // Call INT 03h
- /** *Trampoline++ = 0x90; // nop **/
- }
- else
- {
- /* Normal interrupt */
- *Trampoline++ = 0xCD; // Call INT XXh
- *Trampoline++ = IntNumber;
- }
- UnSimulate16(Trampoline);
-
- /* Perform the call */
- Call16(HIWORD(Context->TrampolineFarPtr),
- LOWORD(Context->TrampolineFarPtr));
-
- /* Restore the old trampoline */
- ((PULONGLONG)TrampolineBase)[0] = ((PULONGLONG)&OldTrampoline)[0];
-}
-
-
-
-VOID WINAPI Int32Dispatch(LPWORD Stack)
-{
- /* Get the interrupt number */
- BYTE IntNum = LOBYTE(Stack[STACK_INT_NUM]);
-
- /* Call the 32-bit Interrupt handler */
- if (Int32Proc[IntNum] != NULL)
- Int32Proc[IntNum](Stack);
- else
- DPRINT1("Unhandled 32-bit interrupt: 0x%02X, AX = 0x%04X\n", IntNum,
getAX());
-}
-
-static VOID WINAPI ControlBop(LPWORD Stack)
-{
- /* Get the Function Number and skip it */
- BYTE FuncNum = *(PBYTE)SEG_OFF_TO_PTR(getCS(), getIP());
- setIP(getIP() + 1);
-
- switch (FuncNum)
- {
- case BOP_CONTROL_INT32:
- Int32Dispatch(Stack);
- break;
-
- default:
- // DPRINT1("Unassigned Control BOP Function: 0x%02X\n", FuncNum);
- DisplayMessage(L"Unassigned Control BOP Function: 0x%02X",
FuncNum);
- break;
- }
-}
-
-VOID InitializeCallbacks(VOID)
-{
- /* Register the Control BOP */
- RegisterBop(BOP_CONTROL, ControlBop);
-}
-
/* EOF */
Copied: trunk/reactos/subsystems/ntvdm/cpu/callback.h (from r64385,
trunk/reactos/subsystems/ntvdm/callback.h)
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/ntvdm/cpu/callb…
==============================================================================
--- trunk/reactos/subsystems/ntvdm/callback.h [iso-8859-1] (original)
+++ trunk/reactos/subsystems/ntvdm/cpu/callback.h [iso-8859-1] Tue Sep 30 23:47:23 2014
@@ -12,8 +12,14 @@
/* DEFINES ********************************************************************/
-/* 32-bit Interrupt Identifiers */
-#define EMULATOR_MAX_INT32_NUM 0xFF + 1
+#define BOP(num) LOBYTE(EMULATOR_BOP), HIBYTE(EMULATOR_BOP), (num)
+#define UnSimulate16(trap) \
+do { \
+ *(PUSHORT)(trap) = EMULATOR_BOP; \
+ (trap) += sizeof(USHORT); \
+ *(trap) = BOP_UNSIMULATE; \
+} while(0)
+// #define UnSimulate16 MAKELONG(EMULATOR_BOP, BOP_UNSIMULATE) //
BOP(BOP_UNSIMULATE)
typedef struct _CALLBACK16
{
@@ -23,11 +29,23 @@
USHORT NextOffset;
} CALLBACK16, *PCALLBACK16;
-extern const ULONG Int16To32StubSize;
+//
+// WARNING WARNING!!
+// If you're changing the indices here, you then need to
+// also fix the BOP code in callback.c !!!!!!!!!!!!!!!!!
+//
+#define STACK_INT_NUM 0
+#define STACK_IP 1
+#define STACK_CS 2
+#define STACK_FLAGS 3
/* FUNCTIONS ******************************************************************/
-typedef VOID (WINAPI *EMULATOR_INT32_PROC)(LPWORD Stack);
+VOID
+InitializeContextEx(IN PCALLBACK16 Context,
+ IN ULONG TrampolineSize,
+ IN USHORT Segment,
+ IN USHORT Offset);
VOID
InitializeContext(IN PCALLBACK16 Context,
@@ -38,36 +56,16 @@
Call16(IN USHORT Segment,
IN USHORT Offset);
+VOID
+RunCallback16(IN PCALLBACK16 Context,
+ IN ULONG FarPtr);
+
ULONG
RegisterCallback16(IN ULONG FarPtr,
IN LPBYTE CallbackCode,
IN SIZE_T CallbackSize,
OUT PSIZE_T CodeSize OPTIONAL);
-VOID
-RunCallback16(IN PCALLBACK16 Context,
- IN ULONG FarPtr);
-
-ULONG
-RegisterInt16(IN ULONG FarPtr,
- IN BYTE IntNumber,
- IN LPBYTE CallbackCode,
- IN SIZE_T CallbackSize,
- OUT PSIZE_T CodeSize OPTIONAL);
-
-ULONG
-RegisterInt32(IN ULONG FarPtr,
- IN BYTE IntNumber,
- IN EMULATOR_INT32_PROC IntHandler,
- OUT PSIZE_T CodeSize OPTIONAL);
-
-VOID
-Int32Call(IN PCALLBACK16 Context,
- IN BYTE IntNumber);
-
-VOID WINAPI Int32Dispatch(LPWORD Stack);
-VOID InitializeCallbacks(VOID);
-
#endif // _CALLBACK_H_
/* EOF */
Copied: trunk/reactos/subsystems/ntvdm/cpu/cpu.c (from r64385,
trunk/reactos/subsystems/ntvdm/emulator.c)
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/ntvdm/cpu/cpu.c…
==============================================================================
--- trunk/reactos/subsystems/ntvdm/emulator.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/ntvdm/cpu/cpu.c [iso-8859-1] Tue Sep 30 23:47:23 2014
@@ -10,8 +10,12 @@
#define NDEBUG
+#include "cpu.h"
+
#include "emulator.h"
#include "callback.h"
+#include "bop.h"
+#include <isvbop.h>
#include "clock.h"
#include "bios/rom.h"
@@ -24,29 +28,20 @@
#include "hardware/timer.h"
#include "hardware/vga.h"
-#include "bop.h"
-#include "vddsup.h"
#include "io.h"
-
-#include <isvbop.h>
/* PRIVATE VARIABLES **********************************************************/
FAST486_STATE EmulatorContext;
-BOOLEAN CpuSimulate = FALSE;
+BOOLEAN CpuRunning = FALSE;
/* No more than 'MaxCpuCallLevel' recursive CPU calls are allowed */
static const INT MaxCpuCallLevel = 32;
static INT CpuCallLevel = 0;
-LPVOID BaseAddress = NULL;
-BOOLEAN VdmRunning = TRUE;
+// BOOLEAN VdmRunning = TRUE;
-static BOOLEAN A20Line = FALSE;
-static BYTE Port61hState = 0x00;
-
-static HANDLE InputThread = NULL;
-
+#if 0
LPCWSTR ExceptionName[] =
{
L"Division By Zero",
@@ -58,90 +53,14 @@
L"Invalid Opcode",
L"FPU Not Available"
};
+#endif
-/* BOP Identifiers */
-#define BOP_DEBUGGER 0x56 // Break into the debugger from a 16-bit app
+// /* BOP Identifiers */
+// #define BOP_DEBUGGER 0x56 // Break into the debugger from a 16-bit app
/* PRIVATE FUNCTIONS **********************************************************/
-VOID WINAPI EmulatorReadMemory(PFAST486_STATE State, ULONG Address, PVOID Buffer, ULONG
Size)
-{
- UNREFERENCED_PARAMETER(State);
-
- // BIG HACK!!!! To make BIOS images working correctly,
- // until Aleksander rewrites memory management!!
- if (Address >= 0xFFFFFFF0) Address -= 0xFFF00000;
-
- /* If the A20 line is disabled, mask bit 20 */
- if (!A20Line) Address &= ~(1 << 20);
-
- /* Make sure the requested address is valid */
- if ((Address + Size) >= MAX_ADDRESS) return;
-
- /*
- * Check if we are going to read the VGA memory and
- * copy it into the virtual address space if needed.
- */
- if (((Address + Size) >= VgaGetVideoBaseAddress())
- && (Address < VgaGetVideoLimitAddress()))
- {
- DWORD VgaAddress = max(Address, VgaGetVideoBaseAddress());
- DWORD ActualSize = min(Address + Size - 1, VgaGetVideoLimitAddress())
- - VgaAddress + 1;
- LPBYTE DestBuffer = (LPBYTE)REAL_TO_PHYS(VgaAddress);
-
- /* Read from the VGA memory */
- VgaReadMemory(VgaAddress, DestBuffer, ActualSize);
- }
-
- /* Read the data from the virtual address space and store it in the buffer */
- RtlCopyMemory(Buffer, REAL_TO_PHYS(Address), Size);
-}
-
-VOID WINAPI EmulatorWriteMemory(PFAST486_STATE State, ULONG Address, PVOID Buffer, ULONG
Size)
-{
- UNREFERENCED_PARAMETER(State);
-
- // BIG HACK!!!! To make BIOS images working correctly,
- // until Aleksander rewrites memory management!!
- if (Address >= 0xFFFFFFF0) Address -= 0xFFF00000;
-
- /* If the A20 line is disabled, mask bit 20 */
- if (!A20Line) Address &= ~(1 << 20);
-
- /* Make sure the requested address is valid */
- if ((Address + Size) >= MAX_ADDRESS) return;
-
- /* Make sure we don't write to the ROM area */
- if ((Address + Size) >= ROM_AREA_START && (Address < ROM_AREA_END))
return;
-
- /* Read the data from the buffer and store it in the virtual address space */
- RtlCopyMemory(REAL_TO_PHYS(Address), Buffer, Size);
-
- /*
- * Check if we modified the VGA memory.
- */
- if (((Address + Size) >= VgaGetVideoBaseAddress())
- && (Address < VgaGetVideoLimitAddress()))
- {
- DWORD VgaAddress = max(Address, VgaGetVideoBaseAddress());
- DWORD ActualSize = min(Address + Size - 1, VgaGetVideoLimitAddress())
- - VgaAddress + 1;
- LPBYTE SrcBuffer = (LPBYTE)REAL_TO_PHYS(VgaAddress);
-
- /* Write to the VGA memory */
- VgaWriteMemory(VgaAddress, SrcBuffer, ActualSize);
- }
-}
-
-UCHAR WINAPI EmulatorIntAcknowledge(PFAST486_STATE State)
-{
- UNREFERENCED_PARAMETER(State);
-
- /* Get the interrupt number from the PIC */
- return PicGetInterrupt();
-}
-
+#if 0
VOID EmulatorException(BYTE ExceptionNumber, LPWORD Stack)
{
WORD CodeSegment, InstructionPointer;
@@ -175,15 +94,16 @@
EmulatorTerminate();
return;
}
+#endif
// FIXME: This function assumes 16-bit mode!!!
-VOID EmulatorExecute(WORD Segment, WORD Offset)
+VOID CpuExecute(WORD Segment, WORD Offset)
{
/* Tell Fast486 to move the instruction pointer */
Fast486ExecuteAt(&EmulatorContext, Segment, Offset);
}
-VOID EmulatorStep(VOID)
+VOID CpuStep(VOID)
{
/* Dump the state for debugging purposes */
// Fast486DumpState(&EmulatorContext);
@@ -192,7 +112,7 @@
Fast486StepInto(&EmulatorContext);
}
-VOID EmulatorSimulate(VOID)
+VOID CpuSimulate(VOID)
{
if (CpuCallLevel > MaxCpuCallLevel)
{
@@ -205,366 +125,45 @@
}
CpuCallLevel++;
- CpuSimulate = TRUE;
- while (VdmRunning && CpuSimulate) ClockUpdate();
+ CpuRunning = TRUE;
+ while (VdmRunning && CpuRunning) ClockUpdate();
CpuCallLevel--;
if (CpuCallLevel < 0) CpuCallLevel = 0;
/* This takes into account for reentrance */
- CpuSimulate = TRUE;
+ CpuRunning = TRUE;
}
-VOID EmulatorUnsimulate(VOID)
+VOID CpuUnsimulate(VOID)
{
/* Stop simulation */
- CpuSimulate = FALSE;
+ CpuRunning = FALSE;
}
+static VOID WINAPI CpuUnsimulateBop(LPWORD Stack)
+{
+ CpuUnsimulate();
+}
+
+#if 0
VOID EmulatorTerminate(VOID)
{
/* Stop the VDM */
VdmRunning = FALSE;
}
-
-VOID EmulatorInterrupt(BYTE Number)
-{
- /* Call the Fast486 API */
- Fast486Interrupt(&EmulatorContext, Number);
-}
-
-VOID EmulatorInterruptSignal(VOID)
-{
- /* Call the Fast486 API */
- Fast486InterruptSignal(&EmulatorContext);
-}
-
-VOID EmulatorSetA20(BOOLEAN Enabled)
-{
- A20Line = Enabled;
-}
-
-static VOID WINAPI EmulatorDebugBreakBop(LPWORD Stack)
-{
- DPRINT1("NTVDM: BOP_DEBUGGER\n");
- DebugBreak();
-}
-
-static VOID WINAPI EmulatorUnsimulateBop(LPWORD Stack)
-{
- EmulatorUnsimulate();
-}
-
-static BYTE WINAPI Port61hRead(ULONG Port)
-{
- return Port61hState;
-}
-
-static VOID WINAPI Port61hWrite(ULONG Port, BYTE Data)
-{
- // BOOLEAN SpeakerStateChange = FALSE;
- BYTE OldPort61hState = Port61hState;
-
- /* Only the four lowest bytes can be written */
- Port61hState = (Port61hState & 0xF0) | (Data & 0x0F);
-
- if ((OldPort61hState ^ Port61hState) & 0x01)
- {
- DPRINT("PIT 2 Gate %s\n", Port61hState & 0x01 ? "on" :
"off");
- PitSetGate(2, !!(Port61hState & 0x01));
- // SpeakerStateChange = TRUE;
- }
-
- if ((OldPort61hState ^ Port61hState) & 0x02)
- {
- /* There were some change for the speaker... */
- DPRINT("Speaker %s\n", Port61hState & 0x02 ? "on" :
"off");
- // SpeakerStateChange = TRUE;
- }
- // if (SpeakerStateChange) SpeakerChange();
- SpeakerChange();
-}
-
-static VOID WINAPI PitChan0Out(LPVOID Param, BOOLEAN State)
-{
- if (State)
- {
- DPRINT("PicInterruptRequest\n");
- PicInterruptRequest(0); // Raise IRQ 0
- }
- // else < Lower IRQ 0 >
-}
-
-static VOID WINAPI PitChan1Out(LPVOID Param, BOOLEAN State)
-{
-#if 0
- if (State)
- {
- /* Set bit 4 of Port 61h */
- Port61hState |= 1 << 4;
- }
- else
- {
- /* Clear bit 4 of Port 61h */
- Port61hState &= ~(1 << 4);
- }
-#else
- Port61hState = (Port61hState & 0xEF) | (State << 4);
#endif
-}
-
-static VOID WINAPI PitChan2Out(LPVOID Param, BOOLEAN State)
-{
- BYTE OldPort61hState = Port61hState;
-
-#if 0
- if (State)
- {
- /* Set bit 5 of Port 61h */
- Port61hState |= 1 << 5;
- }
- else
- {
- /* Clear bit 5 of Port 61h */
- Port61hState &= ~(1 << 5);
- }
-#else
- Port61hState = (Port61hState & 0xDF) | (State << 5);
-#endif
-
- if ((OldPort61hState ^ Port61hState) & 0x20)
- {
- DPRINT("PitChan2Out -- Port61hState changed\n");
- SpeakerChange();
- }
-}
-
-
-static DWORD
-WINAPI
-PumpConsoleInput(LPVOID Parameter)
-{
- HANDLE ConsoleInput = (HANDLE)Parameter;
- INPUT_RECORD InputRecord;
- DWORD Count;
-
- while (VdmRunning)
- {
- /* Make sure the task event is signaled */
- WaitForSingleObject(VdmTaskEvent, INFINITE);
-
- /* Wait for an input record */
- if (!ReadConsoleInput(ConsoleInput, &InputRecord, 1, &Count))
- {
- DWORD LastError = GetLastError();
- DPRINT1("Error reading console input (0x%p, %lu) - Error %lu\n",
ConsoleInput, Count, LastError);
- return LastError;
- }
-
- ASSERT(Count != 0);
-
- /* Check the event type */
- switch (InputRecord.EventType)
- {
- /*
- * Hardware events
- */
- case KEY_EVENT:
- KeyboardEventHandler(&InputRecord.Event.KeyEvent);
- break;
-
- case MOUSE_EVENT:
- MouseEventHandler(&InputRecord.Event.MouseEvent);
- break;
-
- case WINDOW_BUFFER_SIZE_EVENT:
- ScreenEventHandler(&InputRecord.Event.WindowBufferSizeEvent);
- break;
-
- /*
- * Interface events
- */
- case MENU_EVENT:
- MenuEventHandler(&InputRecord.Event.MenuEvent);
- break;
-
- case FOCUS_EVENT:
- FocusEventHandler(&InputRecord.Event.FocusEvent);
- break;
-
- default:
- break;
- }
- }
-
- return 0;
-}
-
-static VOID EnableExtraHardware(HANDLE ConsoleInput)
-{
- DWORD ConInMode;
-
- if (GetConsoleMode(ConsoleInput, &ConInMode))
- {
-#if 0
- // GetNumberOfConsoleMouseButtons();
- // GetSystemMetrics(SM_CMOUSEBUTTONS);
- // GetSystemMetrics(SM_MOUSEPRESENT);
- if (MousePresent)
- {
-#endif
- /* Support mouse input events if there is a mouse on the system */
- ConInMode |= ENABLE_MOUSE_INPUT;
-#if 0
- }
- else
- {
- /* Do not support mouse input events if there is no mouse on the system */
- ConInMode &= ~ENABLE_MOUSE_INPUT;
- }
-#endif
-
- SetConsoleMode(ConsoleInput, ConInMode);
- }
-}
/* PUBLIC FUNCTIONS ***********************************************************/
-static VOID
-DumpMemoryRaw(HANDLE hFile)
+BOOLEAN CpuInitialize(VOID)
{
- PVOID Buffer;
- SIZE_T Size;
-
- /* Dump the VM memory */
- SetFilePointer(hFile, 0, NULL, FILE_BEGIN);
- Buffer = REAL_TO_PHYS(NULL);
- Size = MAX_ADDRESS - (ULONG_PTR)(NULL);
- WriteFile(hFile, Buffer, Size, &Size, NULL);
-}
-
-static VOID
-DumpMemoryTxt(HANDLE hFile)
-{
-#define LINE_SIZE 75 + 2
- ULONG i;
- PBYTE Ptr1, Ptr2;
- CHAR LineBuffer[LINE_SIZE];
- PCHAR Line;
- SIZE_T LineSize;
-
- /* Dump the VM memory */
- SetFilePointer(hFile, 0, NULL, FILE_BEGIN);
- Ptr1 = Ptr2 = REAL_TO_PHYS(NULL);
- while (MAX_ADDRESS - (ULONG_PTR)PHYS_TO_REAL(Ptr1) > 0)
- {
- Ptr1 = Ptr2;
- Line = LineBuffer;
-
- /* Print the address */
- Line += snprintf(Line, LINE_SIZE + LineBuffer - Line, "%08x ",
PHYS_TO_REAL(Ptr1));
-
- /* Print up to 16 bytes... */
-
- /* ... in hexadecimal form first... */
- i = 0;
- while (i++ <= 0x0F && (MAX_ADDRESS - (ULONG_PTR)PHYS_TO_REAL(Ptr1)
> 0))
- {
- Line += snprintf(Line, LINE_SIZE + LineBuffer - Line, " %02x",
*Ptr1);
- ++Ptr1;
- }
-
- /* ... align with spaces if needed... */
- RtlFillMemory(Line, 0x0F + 4 - i, ' ');
- Line += 0x0F + 4 - i;
-
- /* ... then in character form. */
- i = 0;
- while (i++ <= 0x0F && (MAX_ADDRESS - (ULONG_PTR)PHYS_TO_REAL(Ptr2)
> 0))
- {
- *Line++ = ((*Ptr2 >= 0x20 && *Ptr2 <= 0x7E) || (*Ptr2 >=
0x80 && *Ptr2 < 0xFF) ? *Ptr2 : '.');
- ++Ptr2;
- }
-
- /* Newline */
- *Line++ = '\r';
- *Line++ = '\n';
-
- /* Finally write the line to the file */
- LineSize = Line - LineBuffer;
- WriteFile(hFile, LineBuffer, LineSize, &LineSize, NULL);
- }
-}
-
-VOID DumpMemory(BOOLEAN TextFormat)
-{
- static ULONG DumpNumber = 0;
-
- HANDLE hFile;
- WCHAR FileName[MAX_PATH];
-
- /* Build a suitable file name */
- _snwprintf(FileName, MAX_PATH,
- L"memdump%lu.%s",
- DumpNumber,
- TextFormat ? L"txt" : L"dat");
- ++DumpNumber;
-
- DPRINT1("Creating memory dump file '%S'...\n", FileName);
-
- /* Always create the dump file */
- hFile = CreateFileW(FileName,
- GENERIC_WRITE,
- 0,
- NULL,
- CREATE_ALWAYS,
- FILE_ATTRIBUTE_NORMAL,
- NULL);
-
- if (hFile == INVALID_HANDLE_VALUE)
- {
- DPRINT1("Error when creating '%S' for memory dumping, GetLastError()
= %u\n",
- FileName, GetLastError());
- return;
- }
-
- /* Dump the VM memory in the chosen format */
- if (TextFormat)
- DumpMemoryTxt(hFile);
- else
- DumpMemoryRaw(hFile);
-
- /* Close the file */
- CloseHandle(hFile);
-
- DPRINT1("Memory dump done\n");
-}
-
-BOOLEAN EmulatorInitialize(HANDLE ConsoleInput, HANDLE ConsoleOutput)
-{
- /* Allocate memory for the 16-bit address space */
- BaseAddress = HeapAlloc(GetProcessHeap(), /*HEAP_ZERO_MEMORY*/ 0, MAX_ADDRESS);
- if (BaseAddress == NULL)
- {
- wprintf(L"FATAL: Failed to allocate VDM memory.\n");
- return FALSE;
- }
- /*
- * For diagnostics purposes, we fill the memory with INT 0x03 codes
- * so that if a program wants to execute random code in memory, we can
- * retrieve the exact CS:IP where the problem happens.
- */
- RtlFillMemory(BaseAddress, MAX_ADDRESS, 0xCC);
-
- /* Initialize I/O ports */
- /* Initialize RAM */
-
- /* Initialize the internal clock */
- if (!ClockInitialize())
- {
- wprintf(L"FATAL: Failed to initialize the clock\n");
- return FALSE;
- }
+ // /* Initialize the internal clock */
+ // if (!ClockInitialize())
+ // {
+ // wprintf(L"FATAL: Failed to initialize the clock\n");
+ // return FALSE;
+ // }
/* Initialize the CPU */
Fast486Initialize(&EmulatorContext,
@@ -577,163 +176,16 @@
EmulatorIntAcknowledge,
NULL /* TODO: Use a TLB */);
- /* Initialize DMA */
-
- /* Initialize the PIC, the PIT, the CMOS and the PC Speaker */
- PicInitialize();
- PitInitialize();
- CmosInitialize();
- SpeakerInitialize();
-
- /* Set output functions */
- PitSetOutFunction(0, NULL, PitChan0Out);
- PitSetOutFunction(1, NULL, PitChan1Out);
- PitSetOutFunction(2, NULL, PitChan2Out);
-
- /* Register the I/O Ports */
- RegisterIoPort(CONTROL_SYSTEM_PORT61H, Port61hRead, Port61hWrite);
-
- /* Set the console input mode */
- // FIXME: Activate ENABLE_WINDOW_INPUT when we will want to perform actions
- // upon console window events (screen buffer resize, ...).
- SetConsoleMode(ConsoleInput, ENABLE_PROCESSED_INPUT /* | ENABLE_WINDOW_INPUT */);
- // SetConsoleMode(ConsoleOutput, ENABLE_PROCESSED_OUTPUT |
ENABLE_WRAP_AT_EOL_OUTPUT);
-
- /**/EnableExtraHardware(ConsoleInput);/**/
-
- /* Initialize the PS/2 port */
- PS2Initialize();
-
- /* Initialize the keyboard and mouse and connect them to their PS/2 ports */
- KeyboardInit(0);
- MouseInit(1);
-
- /**************** ATTACH INPUT WITH CONSOLE *****************/
- /* Start the input thread */
- InputThread = CreateThread(NULL, 0, &PumpConsoleInput, ConsoleInput, 0, NULL);
- if (InputThread == NULL)
- {
- DisplayMessage(L"Failed to create the console input thread.");
- return FALSE;
- }
- /************************************************************/
-
- /* Initialize the VGA */
- if (!VgaInitialize(ConsoleOutput))
- {
- DisplayMessage(L"Failed to initialize VGA support.");
- return FALSE;
- }
-
/* Initialize the software callback system and register the emulator BOPs */
- InitializeCallbacks();
- RegisterBop(BOP_DEBUGGER , EmulatorDebugBreakBop);
- RegisterBop(BOP_UNSIMULATE, EmulatorUnsimulateBop);
-
- /* Initialize VDD support */
- VDDSupInitialize();
+ // RegisterBop(BOP_DEBUGGER , EmulatorDebugBreakBop);
+ RegisterBop(BOP_UNSIMULATE, CpuUnsimulateBop);
return TRUE;
}
-VOID EmulatorCleanup(VOID)
+VOID CpuCleanup(VOID)
{
- VgaCleanup();
-
- /* Close the input thread handle */
- if (InputThread != NULL) CloseHandle(InputThread);
- InputThread = NULL;
-
- PS2Cleanup();
-
- SpeakerCleanup();
- CmosCleanup();
- // PitCleanup();
- // PicCleanup();
-
// Fast486Cleanup();
-
- /* Free the memory allocated for the 16-bit address space */
- if (BaseAddress != NULL) HeapFree(GetProcessHeap(), 0, BaseAddress);
-}
-
-
-
-VOID
-WINAPI
-VDDSimulate16(VOID)
-{
- EmulatorSimulate();
-}
-
-VOID
-WINAPI
-VDDTerminateVDM(VOID)
-{
- /* Stop the VDM */
- EmulatorTerminate();
-}
-
-PBYTE
-WINAPI
-Sim32pGetVDMPointer(IN ULONG Address,
- IN BOOLEAN ProtectedMode)
-{
- // FIXME
- UNREFERENCED_PARAMETER(ProtectedMode);
-
- /*
- * HIWORD(Address) == Segment (if ProtectedMode == FALSE)
- * or Selector (if ProtectedMode == TRUE )
- * LOWORD(Address) == Offset
- */
- return (PBYTE)FAR_POINTER(Address);
-}
-
-PBYTE
-WINAPI
-MGetVdmPointer(IN ULONG Address,
- IN ULONG Size,
- IN BOOLEAN ProtectedMode)
-{
- UNREFERENCED_PARAMETER(Size);
- return Sim32pGetVDMPointer(Address, ProtectedMode);
-}
-
-PVOID
-WINAPI
-VdmMapFlat(IN USHORT Segment,
- IN ULONG Offset,
- IN VDM_MODE Mode)
-{
- // FIXME
- UNREFERENCED_PARAMETER(Mode);
-
- return SEG_OFF_TO_PTR(Segment, Offset);
-}
-
-BOOL
-WINAPI
-VdmFlushCache(IN USHORT Segment,
- IN ULONG Offset,
- IN ULONG Size,
- IN VDM_MODE Mode)
-{
- // FIXME
- UNIMPLEMENTED;
- return TRUE;
-}
-
-BOOL
-WINAPI
-VdmUnmapFlat(IN USHORT Segment,
- IN ULONG Offset,
- IN PVOID Buffer,
- IN VDM_MODE Mode)
-{
- // FIXME
- UNIMPLEMENTED;
- return TRUE;
}
/* EOF */
Copied: trunk/reactos/subsystems/ntvdm/cpu/cpu.h (from r64385,
trunk/reactos/subsystems/ntvdm/emulator.h)
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/ntvdm/cpu/cpu.h…
==============================================================================
--- trunk/reactos/subsystems/ntvdm/emulator.h [iso-8859-1] (original)
+++ trunk/reactos/subsystems/ntvdm/cpu/cpu.h [iso-8859-1] Tue Sep 30 23:47:23 2014
@@ -6,8 +6,8 @@
* PROGRAMMERS: Aleksandar Andrejevic <theflash AT sdf DOT lonestar DOT org>
*/
-#ifndef _EMULATOR_H_
-#define _EMULATOR_H_
+#ifndef _CPU_H_
+#define _CPU_H_
/* INCLUDES *******************************************************************/
@@ -17,62 +17,24 @@
/* 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)
+#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)
-//
-// WARNING WARNING!!
-// If you're changing the indices here, you then need to
-// also fix the BOP code in callback.c !!!!!!!!!!!!!!!!!
-//
-#define STACK_INT_NUM 0
-#define STACK_IP 1
-#define STACK_CS 2
-#define STACK_FLAGS 3
-
-
-/* Basic Memory Management */
-#define MEM_ALIGN_UP(ptr, align) MEM_ALIGN_DOWN((ULONG_PTR)(ptr) + (align) - 1l,
(align))
-#define MEM_ALIGN_DOWN(ptr, align) (PVOID)((ULONG_PTR)(ptr) & ~((align) - 1l))
-
-#define TO_LINEAR(seg, off) (((seg) << 4) + (off))
-#define MAX_SEGMENT 0xFFFF
-#define MAX_OFFSET 0xFFFF
-#define MAX_ADDRESS 0x1000000 // 16 MB of RAM
-
-#define FAR_POINTER(x) \
- (PVOID)((ULONG_PTR)BaseAddress + TO_LINEAR(HIWORD(x), LOWORD(x)))
-
-#define SEG_OFF_TO_PTR(seg, off) \
- (PVOID)((ULONG_PTR)BaseAddress + TO_LINEAR((seg), (off)))
-
-#define REAL_TO_PHYS(ptr) (PVOID)((ULONG_PTR)(ptr) + (ULONG_PTR)BaseAddress)
-#define PHYS_TO_REAL(ptr) (PVOID)((ULONG_PTR)(ptr) - (ULONG_PTR)BaseAddress)
-
-
-/* BCD-Binary conversion */
-#define BINARY_TO_BCD(x) ((((x) / 1000) << 12) + (((x) / 100) << 8) + (((x) /
10) << 4) + ((x) % 10))
-#define BCD_TO_BINARY(x) (((x) >> 12) * 1000 + ((x) >> 8) * 100 + ((x)
>> 4) * 10 + ((x) & 0x0F))
-
-
-/* System I/O ports */
-#define CONTROL_SYSTEM_PORT61H 0x61
-
-
+#if 0
enum
{
EMULATOR_EXCEPTION_DIVISION_BY_ZERO,
@@ -91,51 +53,27 @@
EMULATOR_EXCEPTION_GPF,
EMULATOR_EXCEPTION_PAGE_FAULT
};
-
+#endif
extern FAST486_STATE EmulatorContext;
-extern LPVOID BaseAddress;
-extern BOOLEAN VdmRunning;
+// extern BOOLEAN VdmRunning;
/* FUNCTIONS ******************************************************************/
-VOID DumpMemory(BOOLEAN TextFormat);
+#if 0
+VOID EmulatorException(BYTE ExceptionNumber, LPWORD Stack);
+#endif
-VOID WINAPI EmulatorReadMemory
-(
- PFAST486_STATE State,
- ULONG Address,
- PVOID Buffer,
- ULONG Size
-);
+VOID CpuExecute(WORD Segment, WORD Offset);
+VOID CpuStep(VOID);
+VOID CpuSimulate(VOID);
+VOID CpuUnsimulate(VOID);
+#if 0
+VOID EmulatorTerminate(VOID);
+#endif
-VOID WINAPI EmulatorWriteMemory
-(
- PFAST486_STATE State,
- ULONG Address,
- PVOID Buffer,
- ULONG Size
-);
+BOOLEAN CpuInitialize(VOID);
+VOID CpuCleanup(VOID);
-UCHAR WINAPI EmulatorIntAcknowledge
-(
- PFAST486_STATE State
-);
-
-VOID EmulatorException(BYTE ExceptionNumber, LPWORD Stack);
-
-VOID EmulatorExecute(WORD Segment, WORD Offset);
-VOID EmulatorStep(VOID);
-VOID EmulatorSimulate(VOID);
-VOID EmulatorUnsimulate(VOID);
-VOID EmulatorTerminate(VOID);
-
-VOID EmulatorInterrupt(BYTE Number);
-VOID EmulatorInterruptSignal(VOID);
-VOID EmulatorSetA20(BOOLEAN Enabled);
-
-BOOLEAN EmulatorInitialize(HANDLE ConsoleInput, HANDLE ConsoleOutput);
-VOID EmulatorCleanup(VOID);
-
-#endif // _EMULATOR_H_
+#endif // _CPU_H_
/* EOF */
Modified: trunk/reactos/subsystems/ntvdm/dos/dem.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/ntvdm/dos/dem.c…
==============================================================================
--- trunk/reactos/subsystems/ntvdm/dos/dem.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/ntvdm/dos/dem.c [iso-8859-1] Tue Sep 30 23:47:23 2014
@@ -18,7 +18,7 @@
#include "utils.h"
#include "dem.h"
-#include "bop.h"
+#include "cpu/bop.h"
#include "bios/bios.h"
#include "mouse32.h"
Modified: trunk/reactos/subsystems/ntvdm/dos/dos32krnl/bios.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/ntvdm/dos/dos32…
==============================================================================
--- trunk/reactos/subsystems/ntvdm/dos/dos32krnl/bios.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/ntvdm/dos/dos32krnl/bios.c [iso-8859-1] Tue Sep 30 23:47:23
2014
@@ -11,7 +11,7 @@
#define NDEBUG
#include "emulator.h"
-#include "callback.h"
+#include "int32.h"
#include "dos.h"
Modified: trunk/reactos/subsystems/ntvdm/dos/dos32krnl/dos.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/ntvdm/dos/dos32…
==============================================================================
--- trunk/reactos/subsystems/ntvdm/dos/dos32krnl/dos.h [iso-8859-1] (original)
+++ trunk/reactos/subsystems/ntvdm/dos/dos32krnl/dos.h [iso-8859-1] Tue Sep 30 23:47:23
2014
@@ -13,7 +13,7 @@
#include "ntvdm.h"
-/**/ #include "callback.h" /**/
+/**/ #include "int32.h" /**/
/* DEFINES ********************************************************************/
Modified: trunk/reactos/subsystems/ntvdm/dos/mouse32.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/ntvdm/dos/mouse…
==============================================================================
--- trunk/reactos/subsystems/ntvdm/dos/mouse32.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/ntvdm/dos/mouse32.c [iso-8859-1] Tue Sep 30 23:47:23 2014
@@ -11,7 +11,8 @@
#define NDEBUG
#include "emulator.h"
-#include "callback.h"
+#include "cpu/cpu.h"
+#include "int32.h"
#include "mouse32.h"
#include "bios/bios.h"
Modified: trunk/reactos/subsystems/ntvdm/emulator.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/ntvdm/emulator.…
==============================================================================
--- trunk/reactos/subsystems/ntvdm/emulator.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/ntvdm/emulator.c [iso-8859-1] Tue Sep 30 23:47:23 2014
@@ -11,7 +11,13 @@
#define NDEBUG
#include "emulator.h"
-#include "callback.h"
+
+#include "cpu/callback.h"
+#include "cpu/cpu.h"
+#include "cpu/bop.h"
+#include <isvbop.h>
+
+#include "int32.h"
#include "clock.h"
#include "bios/rom.h"
@@ -24,20 +30,10 @@
#include "hardware/timer.h"
#include "hardware/vga.h"
-#include "bop.h"
#include "vddsup.h"
#include "io.h"
-#include <isvbop.h>
-
/* PRIVATE VARIABLES **********************************************************/
-
-FAST486_STATE EmulatorContext;
-BOOLEAN CpuSimulate = FALSE;
-
-/* No more than 'MaxCpuCallLevel' recursive CPU calls are allowed */
-static const INT MaxCpuCallLevel = 32;
-static INT CpuCallLevel = 0;
LPVOID BaseAddress = NULL;
BOOLEAN VdmRunning = TRUE;
@@ -176,51 +172,6 @@
return;
}
-// FIXME: This function assumes 16-bit mode!!!
-VOID EmulatorExecute(WORD Segment, WORD Offset)
-{
- /* Tell Fast486 to move the instruction pointer */
- Fast486ExecuteAt(&EmulatorContext, Segment, Offset);
-}
-
-VOID EmulatorStep(VOID)
-{
- /* Dump the state for debugging purposes */
- // Fast486DumpState(&EmulatorContext);
-
- /* Execute the next instruction */
- Fast486StepInto(&EmulatorContext);
-}
-
-VOID EmulatorSimulate(VOID)
-{
- if (CpuCallLevel > MaxCpuCallLevel)
- {
- DisplayMessage(L"Too many CPU levels of recursion (%d, expected maximum
%d)",
- CpuCallLevel, MaxCpuCallLevel);
-
- /* Stop the VDM */
- EmulatorTerminate();
- return;
- }
- CpuCallLevel++;
-
- CpuSimulate = TRUE;
- while (VdmRunning && CpuSimulate) ClockUpdate();
-
- CpuCallLevel--;
- if (CpuCallLevel < 0) CpuCallLevel = 0;
-
- /* This takes into account for reentrance */
- CpuSimulate = TRUE;
-}
-
-VOID EmulatorUnsimulate(VOID)
-{
- /* Stop simulation */
- CpuSimulate = FALSE;
-}
-
VOID EmulatorTerminate(VOID)
{
/* Stop the VDM */
@@ -248,11 +199,6 @@
{
DPRINT1("NTVDM: BOP_DEBUGGER\n");
DebugBreak();
-}
-
-static VOID WINAPI EmulatorUnsimulateBop(LPWORD Stack)
-{
- EmulatorUnsimulate();
}
static BYTE WINAPI Port61hRead(ULONG Port)
@@ -559,6 +505,8 @@
/* Initialize I/O ports */
/* Initialize RAM */
+ /* Initialize the CPU */
+
/* Initialize the internal clock */
if (!ClockInitialize())
{
@@ -567,15 +515,16 @@
}
/* Initialize the CPU */
- Fast486Initialize(&EmulatorContext,
- EmulatorReadMemory,
- EmulatorWriteMemory,
- EmulatorReadIo,
- EmulatorWriteIo,
- NULL,
- EmulatorBiosOperation,
- EmulatorIntAcknowledge,
- NULL /* TODO: Use a TLB */);
+ CpuInitialize();
+ // Fast486Initialize(&EmulatorContext,
+ // EmulatorReadMemory,
+ // EmulatorWriteMemory,
+ // EmulatorReadIo,
+ // EmulatorWriteIo,
+ // NULL,
+ // EmulatorBiosOperation,
+ // EmulatorIntAcknowledge,
+ // NULL /* TODO: Use a TLB */);
/* Initialize DMA */
@@ -626,9 +575,9 @@
}
/* Initialize the software callback system and register the emulator BOPs */
- InitializeCallbacks();
+ InitializeInt32();
RegisterBop(BOP_DEBUGGER , EmulatorDebugBreakBop);
- RegisterBop(BOP_UNSIMULATE, EmulatorUnsimulateBop);
+ // RegisterBop(BOP_UNSIMULATE, CpuUnsimulateBop);
/* Initialize VDD support */
VDDSupInitialize();
@@ -651,7 +600,7 @@
// PitCleanup();
// PicCleanup();
- // Fast486Cleanup();
+ CpuCleanup();
/* Free the memory allocated for the 16-bit address space */
if (BaseAddress != NULL) HeapFree(GetProcessHeap(), 0, BaseAddress);
@@ -663,7 +612,7 @@
WINAPI
VDDSimulate16(VOID)
{
- EmulatorSimulate();
+ CpuSimulate();
}
VOID
Modified: trunk/reactos/subsystems/ntvdm/emulator.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/ntvdm/emulator.…
==============================================================================
--- trunk/reactos/subsystems/ntvdm/emulator.h [iso-8859-1] (original)
+++ trunk/reactos/subsystems/ntvdm/emulator.h [iso-8859-1] Tue Sep 30 23:47:23 2014
@@ -15,35 +15,6 @@
#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)
-
-//
-// WARNING WARNING!!
-// If you're changing the indices here, you then need to
-// also fix the BOP code in callback.c !!!!!!!!!!!!!!!!!
-//
-#define STACK_INT_NUM 0
-#define STACK_IP 1
-#define STACK_CS 2
-#define STACK_FLAGS 3
-
/* Basic Memory Management */
#define MEM_ALIGN_UP(ptr, align) MEM_ALIGN_DOWN((ULONG_PTR)(ptr) + (align) - 1l,
(align))
@@ -92,7 +63,7 @@
EMULATOR_EXCEPTION_PAGE_FAULT
};
-extern FAST486_STATE EmulatorContext;
+// extern FAST486_STATE EmulatorContext;
extern LPVOID BaseAddress;
extern BOOLEAN VdmRunning;
@@ -123,10 +94,6 @@
VOID EmulatorException(BYTE ExceptionNumber, LPWORD Stack);
-VOID EmulatorExecute(WORD Segment, WORD Offset);
-VOID EmulatorStep(VOID);
-VOID EmulatorSimulate(VOID);
-VOID EmulatorUnsimulate(VOID);
VOID EmulatorTerminate(VOID);
VOID EmulatorInterrupt(BYTE Number);
Modified: trunk/reactos/subsystems/ntvdm/int32.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/ntvdm/int32.c?r…
==============================================================================
--- trunk/reactos/subsystems/ntvdm/int32.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/ntvdm/int32.c [iso-8859-1] Tue Sep 30 23:47:23 2014
@@ -14,25 +14,55 @@
#include "emulator.h"
#include "int32.h"
-#include "bop.h"
+#include "cpu/bop.h"
+#include <isvbop.h>
/* PRIVATE VARIABLES **********************************************************/
/*
* This is the list of registered 32-bit Interrupt handlers.
*/
-EMULATOR_INT32_PROC Int32Proc[EMULATOR_MAX_INT32_NUM] = { NULL };
+static EMULATOR_INT32_PROC Int32Proc[EMULATOR_MAX_INT32_NUM] = { NULL };
/* BOP Identifiers */
#define BOP_CONTROL 0xFF // Control BOP Handler
#define BOP_CONTROL_DEFFUNC 0x00 // Default Control BOP Function
+ #define BOP_CONTROL_INT32 0xFF // 32-bit Interrupt dispatcher
-/* 32-bit Interrupt dispatcher function code for the Control BOP Handler */
-#define BOP_CONTROL_INT32 0xFF
+#define INT16_TRAMPOLINE_SIZE sizeof(ULONGLONG) // == TRAMPOLINE_SIZE
+
+/* 16-bit generic interrupt code for calling a 32-bit interrupt handler */
+static BYTE Int16To32[] =
+{
+ 0xFA, // cli
+
+ /* Push the value of the interrupt to be called */
+ 0x6A, 0xFF, // push i (patchable to 0x6A, 0xIntNum)
+
+ /* The BOP Sequence */
+// BOP_SEQ:
+ 0xF8, // clc
+ BOP(BOP_CONTROL), // Control BOP
+ BOP_CONTROL_INT32, // 32-bit Interrupt dispatcher
+
+ 0x73, 0x04, // jnc EXIT (offset +4)
+
+ 0xFB, // sti
+
+ // HACK: The following instruction should be HLT!
+ 0x90, // nop
+
+ 0xEB, 0xF5, // jmp BOP_SEQ (offset -11)
+
+// EXIT:
+ 0x44, 0x44, // inc sp, inc sp
+ 0xCF, // iret
+};
+const ULONG Int16To32StubSize = sizeof(Int16To32);
/* PUBLIC FUNCTIONS ***********************************************************/
-VOID WINAPI Int32Dispatch(LPWORD Stack)
+static VOID WINAPI Int32Dispatch(LPWORD Stack)
{
/* Get the interrupt number */
BYTE IntNum = LOBYTE(Stack[STACK_INT_NUM]);
@@ -41,88 +71,127 @@
if (Int32Proc[IntNum] != NULL)
Int32Proc[IntNum](Stack);
else
- DPRINT("Unhandled 32-bit interrupt: 0x%02X, AX = 0x%04X\n", IntNum,
getAX());
+ DPRINT1("Unhandled 32-bit interrupt: 0x%02X, AX = 0x%04X\n", IntNum,
getAX());
}
-VOID WINAPI ControlBop(LPWORD Stack)
+static VOID WINAPI ControlBop(LPWORD Stack)
{
/* Get the Function Number and skip it */
BYTE FuncNum = *(PBYTE)SEG_OFF_TO_PTR(getCS(), getIP());
setIP(getIP() + 1);
- if (FuncNum == BOP_CONTROL_INT32)
- Int32Dispatch(Stack);
- else
- DPRINT("Unassigned Control BOP Function: 0x%02X\n", FuncNum);
+ switch (FuncNum)
+ {
+ case BOP_CONTROL_INT32:
+ Int32Dispatch(Stack);
+ break;
+
+ default:
+ // DPRINT1("Unassigned Control BOP Function: 0x%02X\n", FuncNum);
+ DisplayMessage(L"Unassigned Control BOP Function: 0x%02X",
FuncNum);
+ break;
+ }
}
-VOID InitializeInt32(WORD BiosSegment)
+ULONG
+RegisterInt16(IN ULONG FarPtr,
+ IN BYTE IntNumber,
+ IN LPBYTE CallbackCode,
+ IN SIZE_T CallbackSize,
+ OUT PSIZE_T CodeSize OPTIONAL)
{
- //
- // WARNING WARNING!!
- //
- // If you modify the code stubs here, think also
- // about updating them in callback.c too!!
- //
+ /* Get a pointer to the IVT and set the corresponding entry (far pointer) */
+ LPDWORD IntVecTable = (LPDWORD)SEG_OFF_TO_PTR(0x0000, 0x0000);
+ IntVecTable[IntNumber] = FarPtr;
- LPDWORD IntVecTable = (LPDWORD)BaseAddress;
- LPBYTE BiosCode = (LPBYTE)SEG_OFF_TO_PTR(BiosSegment, 0);
- USHORT i;
- WORD BopSeqOffset, Offset = 0;
+ /* Register the 16-bit callback */
+ return RegisterCallback16(FarPtr,
+ CallbackCode,
+ CallbackSize,
+ CodeSize);
+}
- /* Generate ISR stubs and fill the IVT */
- for (i = 0x00; i <= 0xFF; i++)
+ULONG
+RegisterInt32(IN ULONG FarPtr,
+ IN BYTE IntNumber,
+ IN EMULATOR_INT32_PROC IntHandler,
+ OUT PSIZE_T CodeSize OPTIONAL)
+{
+ /* Array for holding our copy of the 16-bit interrupt callback */
+ BYTE IntCallback[sizeof(Int16To32)/sizeof(BYTE)];
+
+ /* Check whether the 32-bit interrupt was already registered */
+#if 0
+ if (Int32Proc[IntNumber] != NULL)
{
- Offset = INT_HANDLER_OFFSET + (i << 4);
- IntVecTable[i] = MAKELONG(Offset, BiosSegment);
+ DPRINT1("RegisterInt32: Interrupt 0x%02X already registered!\n",
IntNumber);
+ return 0;
+ }
+#endif
- BiosCode[Offset++] = 0xFA; // cli
+ /* Register the 32-bit interrupt handler */
+ Int32Proc[IntNumber] = IntHandler;
- BiosCode[Offset++] = 0x6A; // push i
- BiosCode[Offset++] = (UCHAR)i;
+ /* Copy the generic 16-bit interrupt callback and patch it */
+ RtlCopyMemory(IntCallback, Int16To32, sizeof(Int16To32));
+ IntCallback[2] = IntNumber;
- BopSeqOffset = COMMON_STUB_OFFSET - (Offset + 3);
+ /* Register the 16-bit interrupt callback */
+ return RegisterInt16(FarPtr,
+ IntNumber,
+ IntCallback,
+ sizeof(IntCallback),
+ CodeSize);
+}
- BiosCode[Offset++] = 0xE9; // jmp near BOP_SEQ
- BiosCode[Offset++] = LOBYTE(BopSeqOffset);
- BiosCode[Offset++] = HIBYTE(BopSeqOffset);
+VOID
+Int32Call(IN PCALLBACK16 Context,
+ IN BYTE IntNumber)
+{
+ /*
+ * TODO: This function has almost the same code as RunCallback16.
+ * Something that may be nice is to have a common interface to
+ * build the trampoline...
+ */
+
+ PUCHAR TrampolineBase = (PUCHAR)FAR_POINTER(Context->TrampolineFarPtr);
+ PUCHAR Trampoline = TrampolineBase;
+ UCHAR OldTrampoline[INT16_TRAMPOLINE_SIZE];
+
+ DPRINT("Int32Call(0x%02X)\n", IntNumber);
+
+ ASSERT(Context->TrampolineSize == INT16_TRAMPOLINE_SIZE);
+
+ /* Save the old trampoline */
+ ((PULONGLONG)&OldTrampoline)[0] = ((PULONGLONG)TrampolineBase)[0];
+
+ /* Build the generic entry-point for 16-bit calls */
+ if (IntNumber == 0x03)
+ {
+ /* We are redefining for INT 03h */
+ *Trampoline++ = 0xCC; // Call INT 03h
+ /** *Trampoline++ = 0x90; // nop **/
}
+ else
+ {
+ /* Normal interrupt */
+ *Trampoline++ = 0xCD; // Call INT XXh
+ *Trampoline++ = IntNumber;
+ }
+ UnSimulate16(Trampoline);
- /* Write the common stub code */
- Offset = COMMON_STUB_OFFSET;
+ /* Perform the call */
+ Call16(HIWORD(Context->TrampolineFarPtr),
+ LOWORD(Context->TrampolineFarPtr));
-// BOP_SEQ:
- BiosCode[Offset++] = 0xF8; // clc
+ /* Restore the old trampoline */
+ ((PULONGLONG)TrampolineBase)[0] = ((PULONGLONG)&OldTrampoline)[0];
+}
- BiosCode[Offset++] = LOBYTE(EMULATOR_BOP); // BOP sequence
- BiosCode[Offset++] = HIBYTE(EMULATOR_BOP);
- BiosCode[Offset++] = BOP_CONTROL; // Control BOP
- BiosCode[Offset++] = BOP_CONTROL_INT32; // 32-bit Interrupt dispatcher
-
- BiosCode[Offset++] = 0x73; // jnc EXIT (offset +4)
- BiosCode[Offset++] = 0x04;
-
- BiosCode[Offset++] = 0xFB; // sti
-
- // HACK: The following instruction should be HLT!
- BiosCode[Offset++] = 0x90; // nop
-
- BiosCode[Offset++] = 0xEB; // jmp BOP_SEQ (offset -11)
- BiosCode[Offset++] = 0xF5;
-
-// EXIT:
- BiosCode[Offset++] = 0x44; // inc sp
- BiosCode[Offset++] = 0x44; // inc sp
-
- BiosCode[Offset++] = 0xCF; // iret
-
+VOID InitializeInt32(VOID)
+{
/* Register the Control BOP */
RegisterBop(BOP_CONTROL, ControlBop);
}
-VOID RegisterInt32(BYTE IntNumber, EMULATOR_INT32_PROC IntHandler)
-{
- Int32Proc[IntNumber] = IntHandler;
-}
-
/* EOF */
Modified: trunk/reactos/subsystems/ntvdm/int32.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/ntvdm/int32.h?r…
==============================================================================
--- trunk/reactos/subsystems/ntvdm/int32.h [iso-8859-1] (original)
+++ trunk/reactos/subsystems/ntvdm/int32.h [iso-8859-1] Tue Sep 30 23:47:23 2014
@@ -10,21 +10,39 @@
#ifndef _INT32_H_
#define _INT32_H_
+/* INCLUDES *******************************************************************/
+
+#include "cpu/callback.h"
+
/* DEFINES ********************************************************************/
/* 32-bit Interrupt Identifiers */
#define EMULATOR_MAX_INT32_NUM 0xFF + 1
-#define INT_HANDLER_OFFSET 0x1000
-#define COMMON_STUB_OFFSET 0x2000
+extern const ULONG Int16To32StubSize;
/* FUNCTIONS ******************************************************************/
typedef VOID (WINAPI *EMULATOR_INT32_PROC)(LPWORD Stack);
-VOID WINAPI Int32Dispatch(LPWORD Stack);
-VOID InitializeInt32(WORD BiosSegment);
-VOID RegisterInt32(BYTE IntNumber, EMULATOR_INT32_PROC IntHandler);
+ULONG
+RegisterInt16(IN ULONG FarPtr,
+ IN BYTE IntNumber,
+ IN LPBYTE CallbackCode,
+ IN SIZE_T CallbackSize,
+ OUT PSIZE_T CodeSize OPTIONAL);
+
+ULONG
+RegisterInt32(IN ULONG FarPtr,
+ IN BYTE IntNumber,
+ IN EMULATOR_INT32_PROC IntHandler,
+ OUT PSIZE_T CodeSize OPTIONAL);
+
+VOID
+Int32Call(IN PCALLBACK16 Context,
+ IN BYTE IntNumber);
+
+VOID InitializeInt32(VOID);
#endif // _INT32_H_
Modified: trunk/reactos/subsystems/ntvdm/registers.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/ntvdm/registers…
==============================================================================
--- trunk/reactos/subsystems/ntvdm/registers.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/ntvdm/registers.c [iso-8859-1] Tue Sep 30 23:47:23 2014
@@ -11,23 +11,9 @@
#define NDEBUG
#include "emulator.h"
+#include "cpu/cpu.h"
/* PUBLIC FUNCTIONS ***********************************************************/
-
-static inline BOOLEAN EmulatorGetFlag(ULONG Flag)
-{
- return (EmulatorContext.Flags.Long & Flag) ? TRUE : FALSE;
-}
-
-static inline VOID EmulatorSetFlag(ULONG Flag)
-{
- EmulatorContext.Flags.Long |= Flag;
-}
-
-static inline VOID EmulatorClearFlag(ULONG Flag)
-{
- EmulatorContext.Flags.Long &= ~Flag;
-}
VOID EmulatorSetStack(WORD Segment, DWORD Offset)
{
@@ -405,7 +391,7 @@
WINAPI
setEIP(ULONG Value)
{
- EmulatorExecute(getCS(), Value);
+ CpuExecute(getCS(), Value);
}
USHORT
@@ -419,7 +405,7 @@
WINAPI
setIP(USHORT Value)
{
- EmulatorExecute(getCS(), Value);
+ CpuExecute(getCS(), Value);
}
@@ -514,136 +500,112 @@
WINAPI
getCF(VOID)
{
- return EmulatorGetFlag(EMULATOR_FLAG_CF);
+ return EmulatorContext.Flags.Cf;
}
VOID
WINAPI
setCF(ULONG Flag)
{
- if (Flag & 1)
- EmulatorSetFlag(EMULATOR_FLAG_CF);
- else
- EmulatorClearFlag(EMULATOR_FLAG_CF);
+ EmulatorContext.Flags.Cf = !!(Flag & 1);
}
ULONG
WINAPI
getPF(VOID)
{
- return EmulatorGetFlag(EMULATOR_FLAG_PF);
+ return EmulatorContext.Flags.Pf;
}
VOID
WINAPI
setPF(ULONG Flag)
{
- if (Flag & 1)
- EmulatorSetFlag(EMULATOR_FLAG_PF);
- else
- EmulatorClearFlag(EMULATOR_FLAG_PF);
+ EmulatorContext.Flags.Pf = !!(Flag & 1);
}
ULONG
WINAPI
getAF(VOID)
{
- return EmulatorGetFlag(EMULATOR_FLAG_AF);
+ return EmulatorContext.Flags.Af;
}
VOID
WINAPI
setAF(ULONG Flag)
{
- if (Flag & 1)
- EmulatorSetFlag(EMULATOR_FLAG_AF);
- else
- EmulatorClearFlag(EMULATOR_FLAG_AF);
+ EmulatorContext.Flags.Af = !!(Flag & 1);
}
ULONG
WINAPI
getZF(VOID)
{
- return EmulatorGetFlag(EMULATOR_FLAG_ZF);
+ return EmulatorContext.Flags.Zf;
}
VOID
WINAPI
setZF(ULONG Flag)
{
- if (Flag & 1)
- EmulatorSetFlag(EMULATOR_FLAG_ZF);
- else
- EmulatorClearFlag(EMULATOR_FLAG_ZF);
+ EmulatorContext.Flags.Zf = !!(Flag & 1);
}
ULONG
WINAPI
getSF(VOID)
{
- return EmulatorGetFlag(EMULATOR_FLAG_SF);
+ return EmulatorContext.Flags.Sf;
}
VOID
WINAPI
setSF(ULONG Flag)
{
- if (Flag & 1)
- EmulatorSetFlag(EMULATOR_FLAG_SF);
- else
- EmulatorClearFlag(EMULATOR_FLAG_SF);
+ EmulatorContext.Flags.Sf = !!(Flag & 1);
}
ULONG
WINAPI
getIF(VOID)
{
- return EmulatorGetFlag(EMULATOR_FLAG_IF);
+ return EmulatorContext.Flags.If;
}
VOID
WINAPI
setIF(ULONG Flag)
{
- if (Flag & 1)
- EmulatorSetFlag(EMULATOR_FLAG_IF);
- else
- EmulatorClearFlag(EMULATOR_FLAG_IF);
+ EmulatorContext.Flags.If = !!(Flag & 1);
}
ULONG
WINAPI
getDF(VOID)
{
- return EmulatorGetFlag(EMULATOR_FLAG_DF);
+ return EmulatorContext.Flags.Df;
}
VOID
WINAPI
setDF(ULONG Flag)
{
- if (Flag & 1)
- EmulatorSetFlag(EMULATOR_FLAG_DF);
- else
- EmulatorClearFlag(EMULATOR_FLAG_DF);
+ EmulatorContext.Flags.Df = !!(Flag & 1);
}
ULONG
WINAPI
getOF(VOID)
{
- return EmulatorGetFlag(EMULATOR_FLAG_OF);
+ return EmulatorContext.Flags.Of;
}
VOID
WINAPI
setOF(ULONG Flag)
{
- if (Flag & 1)
- EmulatorSetFlag(EMULATOR_FLAG_OF);
- else
- EmulatorClearFlag(EMULATOR_FLAG_OF);
+ EmulatorContext.Flags.Of = !!(Flag & 1);
}
Modified: trunk/reactos/subsystems/ntvdm/vddsup.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/ntvdm/vddsup.c?…
==============================================================================
--- trunk/reactos/subsystems/ntvdm/vddsup.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/ntvdm/vddsup.c [iso-8859-1] Tue Sep 30 23:47:23 2014
@@ -13,8 +13,7 @@
#include "emulator.h"
#include "vddsup.h"
-#include "bop.h"
-
+#include "cpu/bop.h"
#include <isvbop.h>
typedef VOID (WINAPI *VDD_PROC)(VOID);