Author: aandrejevic Date: Fri Jun 12 03:30:40 2015 New Revision: 68109
URL: http://svn.reactos.org/svn/reactos?rev=68109&view=rev Log: [FAST486][NTVDM] Use FASTCALL instead of NTAPI. Merge EmulatorReadMemory with MemRead and EmulatorWriteMemory with MemWrite.
Modified: trunk/reactos/include/reactos/libs/fast486/fast486.h trunk/reactos/lib/fast486/debug.c trunk/reactos/lib/fast486/fast486.c trunk/reactos/subsystems/mvdm/ntvdm/bios/vidbios.c trunk/reactos/subsystems/mvdm/ntvdm/cpu/bop.c trunk/reactos/subsystems/mvdm/ntvdm/cpu/bop.h trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/dosfiles.c trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/himem.c trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/memory.h trunk/reactos/subsystems/mvdm/ntvdm/dos/mouse32.c trunk/reactos/subsystems/mvdm/ntvdm/emulator.c trunk/reactos/subsystems/mvdm/ntvdm/emulator.h trunk/reactos/subsystems/mvdm/ntvdm/hardware/dma.c trunk/reactos/subsystems/mvdm/ntvdm/hardware/ps2.c trunk/reactos/subsystems/mvdm/ntvdm/io.c trunk/reactos/subsystems/mvdm/ntvdm/io.h trunk/reactos/subsystems/mvdm/ntvdm/memory.c trunk/reactos/subsystems/mvdm/ntvdm/memory.h
Modified: trunk/reactos/include/reactos/libs/fast486/fast486.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/libs/fast48... ============================================================================== --- trunk/reactos/include/reactos/libs/fast486/fast486.h [iso-8859-1] (original) +++ trunk/reactos/include/reactos/libs/fast486/fast486.h [iso-8859-1] Fri Jun 12 03:30:40 2015 @@ -182,7 +182,7 @@
typedef VOID -(NTAPI *FAST486_MEM_READ_PROC) +(FASTCALL *FAST486_MEM_READ_PROC) ( PFAST486_STATE State, ULONG Address, @@ -192,7 +192,7 @@
typedef VOID -(NTAPI *FAST486_MEM_WRITE_PROC) +(FASTCALL *FAST486_MEM_WRITE_PROC) ( PFAST486_STATE State, ULONG Address, @@ -202,7 +202,7 @@
typedef VOID -(NTAPI *FAST486_IO_READ_PROC) +(FASTCALL *FAST486_IO_READ_PROC) ( PFAST486_STATE State, USHORT Port, @@ -213,7 +213,7 @@
typedef VOID -(NTAPI *FAST486_IO_WRITE_PROC) +(FASTCALL *FAST486_IO_WRITE_PROC) ( PFAST486_STATE State, USHORT Port, @@ -224,7 +224,7 @@
typedef VOID -(NTAPI *FAST486_BOP_PROC) +(FASTCALL *FAST486_BOP_PROC) ( PFAST486_STATE State, UCHAR BopCode @@ -232,14 +232,14 @@
typedef UCHAR -(NTAPI *FAST486_INT_ACK_PROC) +(FASTCALL *FAST486_INT_ACK_PROC) ( PFAST486_STATE State );
typedef VOID -(NTAPI *FAST486_FPU_PROC) +(FASTCALL *FAST486_FPU_PROC) ( PFAST486_STATE State );
Modified: trunk/reactos/lib/fast486/debug.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/fast486/debug.c?rev=681... ============================================================================== --- trunk/reactos/lib/fast486/debug.c [iso-8859-1] (original) +++ trunk/reactos/lib/fast486/debug.c [iso-8859-1] Fri Jun 12 03:30:40 2015 @@ -43,91 +43,82 @@
/* PRIVATE FUNCTIONS **********************************************************/
-#if 0 -static inline VOID -NTAPI +FORCEINLINE +VOID +FASTCALL Fast486ExecutionControl(PFAST486_STATE State, FAST486_EXEC_CMD Command) { UCHAR Opcode; FAST486_OPCODE_HANDLER_PROC CurrentHandler; INT ProcedureCallCount = 0; + BOOLEAN Trap;
/* Main execution loop */ do { + Trap = State->Flags.Tf; + + if (!State->Halted) + { NextInst: - /* Check if this is a new instruction */ - if (State->PrefixFlags == 0) State->SavedInstPtr = State->InstPtr; - - /* Perform an instruction fetch */ - if (!Fast486FetchByte(State, &Opcode)) - { - /* Exception occurred */ + /* Check if this is a new instruction */ + if (State->PrefixFlags == 0) + { + State->SavedInstPtr = State->InstPtr; + State->SavedStackPtr = State->GeneralRegs[FAST486_REG_ESP]; + } + + /* Perform an instruction fetch */ + if (!Fast486FetchByte(State, &Opcode)) + { + /* Exception occurred */ + State->PrefixFlags = 0; + continue; + } + + // TODO: Check for CALL/RET to update ProcedureCallCount. + + /* Call the opcode handler */ + CurrentHandler = Fast486OpcodeHandlers[Opcode]; + CurrentHandler(State, Opcode); + + /* If this is a prefix, go to the next instruction immediately */ + if (CurrentHandler == Fast486OpcodePrefix) goto NextInst; + + /* A non-prefix opcode has been executed, reset the prefix flags */ State->PrefixFlags = 0; - continue; - } - - // TODO: Check for CALL/RET to update ProcedureCallCount. - - /* Call the opcode handler */ - CurrentHandler = Fast486OpcodeHandlers[Opcode]; - CurrentHandler(State, Opcode); - - /* If this is a prefix, go to the next instruction immediately */ - if (CurrentHandler == Fast486OpcodePrefix) goto NextInst; - - /* A non-prefix opcode has been executed, reset the prefix flags */ - State->PrefixFlags = 0; + }
/* * Check if there is an interrupt to execute, or a hardware interrupt signal * while interrupts are enabled. */ - if (State->Flags.Tf) + if (State->DoNotInterrupt) + { + /* Clear the interrupt delay flag */ + State->DoNotInterrupt = FALSE; + } + else if (Trap && !State->Halted) { /* Perform the interrupt */ - Fast486PerformInterrupt(State, 0x01); - - /* - * Flags and TF are pushed on stack so we can reset TF now, - * to not break into the INT 0x01 handler. - * After the INT 0x01 handler returns, the flags and therefore - * TF are popped back off the stack and restored, so TF will be - * automatically reset to its previous state. - */ - State->Flags.Tf = FALSE; - } - else if (State->IntStatus == FAST486_INT_EXECUTE) - { - /* Perform the interrupt */ - Fast486PerformInterrupt(State, State->PendingIntNum); + Fast486PerformInterrupt(State, FAST486_EXCEPTION_DB); + } + else if (State->Flags.If && State->IntSignaled) + { + /* No longer halted */ + State->Halted = FALSE; + + /* Acknowledge the interrupt and perform it */ + Fast486PerformInterrupt(State, State->IntAckCallback(State));
/* Clear the interrupt status */ - State->IntStatus = FAST486_INT_NONE; - } - else if (State->Flags.If && (State->IntStatus == FAST486_INT_SIGNAL)) - { - /* Acknowledge the interrupt to get the number */ - State->PendingIntNum = State->IntAckCallback(State); - - /* Set the interrupt status to execute on the next instruction */ - State->IntStatus = FAST486_INT_EXECUTE; - } - else if (State->IntStatus == FAST486_INT_DELAYED) - { - /* Restore the old state */ - State->IntStatus = FAST486_INT_EXECUTE; + State->IntSignaled = FALSE; } } while ((Command == FAST486_CONTINUE) || (Command == FAST486_STEP_OVER && ProcedureCallCount > 0) || (Command == FAST486_STEP_OUT && ProcedureCallCount >= 0)); } -#else -VOID -NTAPI -Fast486ExecutionControl(PFAST486_STATE State, FAST486_EXEC_CMD Command); -#endif
/* PUBLIC FUNCTIONS ***********************************************************/
Modified: trunk/reactos/lib/fast486/fast486.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/fast486/fast486.c?rev=6... ============================================================================== --- trunk/reactos/lib/fast486/fast486.c [iso-8859-1] (original) +++ trunk/reactos/lib/fast486/fast486.c [iso-8859-1] Fri Jun 12 03:30:40 2015 @@ -31,98 +31,10 @@ #include "opcodes.h" #include "fpu.h"
-/* DEFINES ********************************************************************/ - -typedef enum -{ - FAST486_STEP_INTO, - FAST486_STEP_OVER, - FAST486_STEP_OUT, - FAST486_CONTINUE -} FAST486_EXEC_CMD; - -/* PRIVATE FUNCTIONS **********************************************************/ - -VOID -NTAPI -Fast486ExecutionControl(PFAST486_STATE State, FAST486_EXEC_CMD Command) -{ - UCHAR Opcode; - FAST486_OPCODE_HANDLER_PROC CurrentHandler; - INT ProcedureCallCount = 0; - BOOLEAN Trap; - - /* Main execution loop */ - do - { - Trap = State->Flags.Tf; - - if (!State->Halted) - { -NextInst: - /* Check if this is a new instruction */ - if (State->PrefixFlags == 0) - { - State->SavedInstPtr = State->InstPtr; - State->SavedStackPtr = State->GeneralRegs[FAST486_REG_ESP]; - } - - /* Perform an instruction fetch */ - if (!Fast486FetchByte(State, &Opcode)) - { - /* Exception occurred */ - State->PrefixFlags = 0; - continue; - } - - // TODO: Check for CALL/RET to update ProcedureCallCount. - - /* Call the opcode handler */ - CurrentHandler = Fast486OpcodeHandlers[Opcode]; - CurrentHandler(State, Opcode); - - /* If this is a prefix, go to the next instruction immediately */ - if (CurrentHandler == Fast486OpcodePrefix) goto NextInst; - - /* A non-prefix opcode has been executed, reset the prefix flags */ - State->PrefixFlags = 0; - } - - /* - * Check if there is an interrupt to execute, or a hardware interrupt signal - * while interrupts are enabled. - */ - if (State->DoNotInterrupt) - { - /* Clear the interrupt delay flag */ - State->DoNotInterrupt = FALSE; - } - else if (Trap && !State->Halted) - { - /* Perform the interrupt */ - Fast486PerformInterrupt(State, FAST486_EXCEPTION_DB); - } - else if (State->Flags.If && State->IntSignaled) - { - /* No longer halted */ - State->Halted = FALSE; - - /* Acknowledge the interrupt and perform it */ - Fast486PerformInterrupt(State, State->IntAckCallback(State)); - - /* Clear the interrupt status */ - State->IntSignaled = FALSE; - } - } - while ((Command == FAST486_CONTINUE) || - (Command == FAST486_STEP_OVER && ProcedureCallCount > 0) || - (Command == FAST486_STEP_OUT && ProcedureCallCount >= 0)); -} - /* DEFAULT CALLBACKS **********************************************************/
static VOID -NTAPI +FASTCALL Fast486MemReadCallback(PFAST486_STATE State, ULONG Address, PVOID Buffer, ULONG Size) { UNREFERENCED_PARAMETER(State); @@ -130,7 +42,7 @@ }
static VOID -NTAPI +FASTCALL Fast486MemWriteCallback(PFAST486_STATE State, ULONG Address, PVOID Buffer, ULONG Size) { UNREFERENCED_PARAMETER(State); @@ -138,7 +50,7 @@ }
static VOID -NTAPI +FASTCALL Fast486IoReadCallback(PFAST486_STATE State, USHORT Port, PVOID Buffer, ULONG DataCount, UCHAR DataSize) { UNREFERENCED_PARAMETER(State); @@ -149,7 +61,7 @@ }
static VOID -NTAPI +FASTCALL Fast486IoWriteCallback(PFAST486_STATE State, USHORT Port, PVOID Buffer, ULONG DataCount, UCHAR DataSize) { UNREFERENCED_PARAMETER(State); @@ -160,7 +72,7 @@ }
static VOID -NTAPI +FASTCALL Fast486BopCallback(PFAST486_STATE State, UCHAR BopCode) { UNREFERENCED_PARAMETER(State); @@ -168,7 +80,7 @@ }
static UCHAR -NTAPI +FASTCALL Fast486IntAckCallback(PFAST486_STATE State) { UNREFERENCED_PARAMETER(State); @@ -177,7 +89,8 @@ return 0x01; }
-static VOID NTAPI +static VOID +FASTCALL Fast486FpuCallback(PFAST486_STATE State) { UNREFERENCED_PARAMETER(State);
Modified: trunk/reactos/subsystems/mvdm/ntvdm/bios/vidbios.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/ntvdm/bios/... ============================================================================== --- trunk/reactos/subsystems/mvdm/ntvdm/bios/vidbios.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/mvdm/ntvdm/bios/vidbios.c [iso-8859-1] Fri Jun 12 03:30:40 2015 @@ -15,6 +15,7 @@ #include "emulator.h" #include "cpu/cpu.h" #include "cpu/bop.h" +#include "memory.h"
#include "bios.h" // #include "vidbios.h"
Modified: trunk/reactos/subsystems/mvdm/ntvdm/cpu/bop.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/ntvdm/cpu/b... ============================================================================== --- trunk/reactos/subsystems/mvdm/ntvdm/cpu/bop.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/mvdm/ntvdm/cpu/bop.c [iso-8859-1] Fri Jun 12 03:30:40 2015 @@ -29,7 +29,7 @@ BopProc[BopCode] = BopHandler; }
-VOID WINAPI EmulatorBiosOperation(PFAST486_STATE State, UCHAR BopCode) +VOID FASTCALL EmulatorBiosOperation(PFAST486_STATE State, UCHAR BopCode) { WORD StackSegment, StackPointer; LPWORD Stack;
Modified: trunk/reactos/subsystems/mvdm/ntvdm/cpu/bop.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/ntvdm/cpu/b... ============================================================================== --- trunk/reactos/subsystems/mvdm/ntvdm/cpu/bop.h [iso-8859-1] (original) +++ trunk/reactos/subsystems/mvdm/ntvdm/cpu/bop.h [iso-8859-1] Fri Jun 12 03:30:40 2015 @@ -21,7 +21,7 @@ typedef VOID (WINAPI *EMULATOR_BOP_PROC)(LPWORD Stack);
VOID RegisterBop(BYTE BopCode, EMULATOR_BOP_PROC BopHandler); -VOID WINAPI EmulatorBiosOperation(PFAST486_STATE State, UCHAR BopCode); +VOID FASTCALL EmulatorBiosOperation(PFAST486_STATE State, UCHAR BopCode);
#endif // _BOP_H_
Modified: trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/dosfiles.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/ntvdm/dos/d... ============================================================================== --- trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/dosfiles.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/dosfiles.c [iso-8859-1] Fri Jun 12 03:30:40 2015 @@ -704,7 +704,10 @@ if (ReadFile(Descriptor->Win32Handle, LocalBuffer, Count, &BytesRead32, NULL)) { /* Write to the memory */ - MemWrite(TO_LINEAR(HIWORD(Buffer), LOWORD(Buffer)), LocalBuffer, LOWORD(BytesRead32)); + EmulatorWriteMemory(&EmulatorContext, + TO_LINEAR(HIWORD(Buffer), LOWORD(Buffer)), + LocalBuffer, + LOWORD(BytesRead32));
/* Update the position */ Descriptor->Position += BytesRead32; @@ -756,7 +759,11 @@ ASSERT(LocalBuffer != NULL);
/* Read from the memory */ - MemRead(TO_LINEAR(HIWORD(Buffer), LOWORD(Buffer)), LocalBuffer, Count); + EmulatorReadMemory(&EmulatorContext, + TO_LINEAR(HIWORD(Buffer), + LOWORD(Buffer)), + LocalBuffer, + Count);
/* Write the file */ if (WriteFile(Descriptor->Win32Handle, LocalBuffer, Count, &BytesWritten32, NULL))
Modified: trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/himem.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/ntvdm/dos/d... ============================================================================== --- trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/himem.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/himem.c [iso-8859-1] Fri Jun 12 03:30:40 2015 @@ -13,6 +13,7 @@ #include "ntvdm.h" #include "emulator.h" #include "cpu/bop.h" +#include "../../memory.h" #include "io.h" #include "hardware/ps2.h"
Modified: trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/memory.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/ntvdm/dos/d... ============================================================================== --- trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/memory.h [iso-8859-1] (original) +++ trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/memory.h [iso-8859-1] Fri Jun 12 03:30:40 2015 @@ -6,8 +6,8 @@ * PROGRAMMERS: Aleksandar Andrejevic <theflash AT sdf DOT lonestar DOT org> */
-#ifndef _MEMORY_H_ -#define _MEMORY_H_ +#ifndef _DOS_MEMORY_H_ +#define _DOS_MEMORY_H_
/* TYPEDEFS *******************************************************************/
@@ -45,6 +45,6 @@ BOOLEAN DosUnlinkUmb(VOID); VOID DosChangeMemoryOwner(WORD Segment, WORD NewOwner);
-#endif // _MEMORY_H_ +#endif // _DOS_MEMORY_H_
/* EOF */
Modified: trunk/reactos/subsystems/mvdm/ntvdm/dos/mouse32.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/ntvdm/dos/m... ============================================================================== --- trunk/reactos/subsystems/mvdm/ntvdm/dos/mouse32.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/mvdm/ntvdm/dos/mouse32.c [iso-8859-1] Fri Jun 12 03:30:40 2015 @@ -24,6 +24,7 @@ #include "bios/bios.h" #include "bios/bios32/bios32p.h"
+#include "memory.h" #include "io.h" #include "dos32krnl/dos.h"
Modified: trunk/reactos/subsystems/mvdm/ntvdm/emulator.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/ntvdm/emula... ============================================================================== --- trunk/reactos/subsystems/mvdm/ntvdm/emulator.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/mvdm/ntvdm/emulator.c [iso-8859-1] Fri Jun 12 03:30:40 2015 @@ -42,8 +42,6 @@ LPVOID BaseAddress = NULL; BOOLEAN VdmRunning = TRUE;
-static BOOLEAN A20Line = FALSE; - static HANDLE InputThread = NULL;
LPCWSTR ExceptionName[] = @@ -63,46 +61,7 @@
/* PRIVATE FUNCTIONS **********************************************************/
-VOID WINAPI EmulatorReadMemory(PFAST486_STATE State, ULONG Address, PVOID Buffer, ULONG Size) -{ - UNREFERENCED_PARAMETER(State); - - /* Mirror 0x000FFFF0 at 0xFFFFFFF0 */ - if (Address >= 0xFFFFFFF0) Address -= 0xFFF00000; - - /* If the A20 line is disabled, mask bit 20 */ - if (!A20Line) Address &= ~(1 << 20); - - if ((Address + Size - 1) >= MAX_ADDRESS) - { - ULONG ExtraStart = (Address < MAX_ADDRESS) ? MAX_ADDRESS - Address : 0; - - /* Fill the memory that was above the limit with 0xFF */ - RtlFillMemory((PVOID)((ULONG_PTR)Buffer + ExtraStart), Size - ExtraStart, 0xFF); - - if (Address < MAX_ADDRESS) Size = MAX_ADDRESS - Address; - else return; - } - - /* Read while calling fast memory hooks */ - MemRead(Address, Buffer, Size); -} - -VOID WINAPI EmulatorWriteMemory(PFAST486_STATE State, ULONG Address, PVOID Buffer, ULONG Size) -{ - UNREFERENCED_PARAMETER(State); - - /* If the A20 line is disabled, mask bit 20 */ - if (!A20Line) Address &= ~(1 << 20); - - if (Address >= MAX_ADDRESS) return; - Size = min(Size, MAX_ADDRESS - Address); - - /* Write while calling fast memory hooks */ - MemWrite(Address, Buffer, Size); -} - -UCHAR WINAPI EmulatorIntAcknowledge(PFAST486_STATE State) +UCHAR FASTCALL EmulatorIntAcknowledge(PFAST486_STATE State) { UNREFERENCED_PARAMETER(State);
@@ -110,7 +69,7 @@ return PicGetInterrupt(); }
-VOID WINAPI EmulatorFpu(PFAST486_STATE State) +VOID FASTCALL EmulatorFpu(PFAST486_STATE State) { /* The FPU is wired to IRQ 13 */ PicInterruptRequest(13); @@ -164,16 +123,6 @@ Fast486InterruptSignal(&EmulatorContext); }
-VOID EmulatorSetA20(BOOLEAN Enabled) -{ - A20Line = Enabled; -} - -BOOLEAN EmulatorGetA20(VOID) -{ - return A20Line; -} - static VOID WINAPI EmulatorDebugBreakBop(LPWORD Stack) { DPRINT1("NTVDM: BOP_DEBUGGER\n");
Modified: trunk/reactos/subsystems/mvdm/ntvdm/emulator.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/ntvdm/emula... ============================================================================== --- trunk/reactos/subsystems/mvdm/ntvdm/emulator.h [iso-8859-1] (original) +++ trunk/reactos/subsystems/mvdm/ntvdm/emulator.h [iso-8859-1] Fri Jun 12 03:30:40 2015 @@ -90,7 +90,7 @@ EMULATOR_EXCEPTION_PAGE_FAULT };
-// extern FAST486_STATE EmulatorContext; +extern FAST486_STATE EmulatorContext; extern LPVOID BaseAddress; extern BOOLEAN VdmRunning;
@@ -98,28 +98,12 @@
VOID DumpMemory(BOOLEAN TextFormat);
-VOID WINAPI EmulatorReadMemory -( - PFAST486_STATE State, - ULONG Address, - PVOID Buffer, - ULONG Size -); - -VOID WINAPI EmulatorWriteMemory -( - PFAST486_STATE State, - ULONG Address, - PVOID Buffer, - ULONG Size -); - -UCHAR WINAPI EmulatorIntAcknowledge +UCHAR FASTCALL EmulatorIntAcknowledge ( PFAST486_STATE State );
-VOID WINAPI EmulatorFpu +VOID FASTCALL EmulatorFpu ( PFAST486_STATE State ); @@ -129,8 +113,6 @@ VOID EmulatorTerminate(VOID);
VOID EmulatorInterruptSignal(VOID); -VOID EmulatorSetA20(BOOLEAN Enabled); -BOOLEAN EmulatorGetA20(VOID);
BOOLEAN EmulatorInitialize(HANDLE ConsoleInput, HANDLE ConsoleOutput); VOID EmulatorCleanup(VOID);
Modified: trunk/reactos/subsystems/mvdm/ntvdm/hardware/dma.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/ntvdm/hardw... ============================================================================== --- trunk/reactos/subsystems/mvdm/ntvdm/hardware/dma.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/mvdm/ntvdm/hardware/dma.c [iso-8859-1] Fri Jun 12 03:30:40 2015 @@ -477,13 +477,13 @@
if (Increment) { - MemWrite(CurrAddress, dmabuf, length); + EmulatorWriteMemory(&EmulatorContext, CurrAddress, dmabuf, length); } else { for (i = 0; i < length; i++) { - MemWrite(CurrAddress - i, dmabuf + i, sizeof(BYTE)); + EmulatorWriteMemory(&EmulatorContext, CurrAddress - i, dmabuf + i, sizeof(BYTE)); } }
@@ -498,13 +498,13 @@
if (Increment) { - MemRead(CurrAddress, dmabuf, length); + EmulatorReadMemory(&EmulatorContext, CurrAddress, dmabuf, length); } else { for (i = 0; i < length; i++) { - MemRead(CurrAddress - i, dmabuf + i, sizeof(BYTE)); + EmulatorReadMemory(&EmulatorContext, CurrAddress - i, dmabuf + i, sizeof(BYTE)); } }
Modified: trunk/reactos/subsystems/mvdm/ntvdm/hardware/ps2.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/ntvdm/hardw... ============================================================================== --- trunk/reactos/subsystems/mvdm/ntvdm/hardware/ps2.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/mvdm/ntvdm/hardware/ps2.c [iso-8859-1] Fri Jun 12 03:30:40 2015 @@ -15,6 +15,7 @@ #include "emulator.h" #include "ps2.h"
+#include "memory.h" #include "io.h" #include "pic.h" #include "clock.h"
Modified: trunk/reactos/subsystems/mvdm/ntvdm/io.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/ntvdm/io.c?... ============================================================================== --- trunk/reactos/subsystems/mvdm/ntvdm/io.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/mvdm/ntvdm/io.c [iso-8859-1] Fri Jun 12 03:30:40 2015 @@ -343,7 +343,7 @@ RtlZeroMemory(&IoPortProc[Port], sizeof(IoPortProc[Port])); }
-VOID WINAPI +VOID FASTCALL EmulatorReadIo(PFAST486_STATE State, USHORT Port, PVOID Buffer, @@ -418,7 +418,7 @@ } }
-VOID WINAPI +VOID FASTCALL EmulatorWriteIo(PFAST486_STATE State, USHORT Port, PVOID Buffer,
Modified: trunk/reactos/subsystems/mvdm/ntvdm/io.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/ntvdm/io.h?... ============================================================================== --- trunk/reactos/subsystems/mvdm/ntvdm/io.h [iso-8859-1] (original) +++ trunk/reactos/subsystems/mvdm/ntvdm/io.h [iso-8859-1] Fri Jun 12 03:30:40 2015 @@ -85,7 +85,7 @@
VOID UnregisterIoPort(USHORT Port);
-VOID WINAPI EmulatorReadIo +VOID FASTCALL EmulatorReadIo ( PFAST486_STATE State, USHORT Port, @@ -94,7 +94,7 @@ UCHAR DataSize );
-VOID WINAPI EmulatorWriteIo +VOID FASTCALL EmulatorWriteIo ( PFAST486_STATE State, USHORT Port,
Modified: trunk/reactos/subsystems/mvdm/ntvdm/memory.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/ntvdm/memor... ============================================================================== --- trunk/reactos/subsystems/mvdm/ntvdm/memory.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/mvdm/ntvdm/memory.c [iso-8859-1] Fri Jun 12 03:30:40 2015 @@ -36,6 +36,7 @@
static LIST_ENTRY HookList; static PMEM_HOOK PageTable[TOTAL_PAGES] = { NULL }; +static BOOLEAN A20Line = FALSE;
/* PRIVATE FUNCTIONS **********************************************************/
@@ -137,12 +138,32 @@
/* PUBLIC FUNCTIONS ***********************************************************/
-VOID -MemRead(ULONG Address, PVOID Buffer, ULONG Size) +VOID FASTCALL EmulatorReadMemory(PFAST486_STATE State, ULONG Address, PVOID Buffer, ULONG Size) { ULONG i, Offset, Length; - ULONG FirstPage = Address >> 12; - ULONG LastPage = (Address + Size - 1) >> 12; + ULONG FirstPage, LastPage; + + UNREFERENCED_PARAMETER(State); + + /* Mirror 0x000FFFF0 at 0xFFFFFFF0 */ + if (Address >= 0xFFFFFFF0) Address -= 0xFFF00000; + + /* If the A20 line is disabled, mask bit 20 */ + if (!A20Line) Address &= ~(1 << 20); + + if ((Address + Size - 1) >= MAX_ADDRESS) + { + ULONG ExtraStart = (Address < MAX_ADDRESS) ? MAX_ADDRESS - Address : 0; + + /* Fill the memory that was above the limit with 0xFF */ + RtlFillMemory((PVOID)((ULONG_PTR)Buffer + ExtraStart), Size - ExtraStart, 0xFF); + + if (Address < MAX_ADDRESS) Size = MAX_ADDRESS - Address; + else return; + } + + FirstPage = Address >> 12; + LastPage = (Address + Size - 1) >> 12;
if (FirstPage == LastPage) { @@ -161,12 +182,21 @@ } }
-VOID -MemWrite(ULONG Address, PVOID Buffer, ULONG Size) +VOID FASTCALL EmulatorWriteMemory(PFAST486_STATE State, ULONG Address, PVOID Buffer, ULONG Size) { ULONG i, Offset, Length; - ULONG FirstPage = Address >> 12; - ULONG LastPage = (Address + Size - 1) >> 12; + ULONG FirstPage, LastPage; + + UNREFERENCED_PARAMETER(State); + + /* If the A20 line is disabled, mask bit 20 */ + if (!A20Line) Address &= ~(1 << 20); + + if (Address >= MAX_ADDRESS) return; + Size = min(Size, MAX_ADDRESS - Address); + + FirstPage = Address >> 12; + LastPage = (Address + Size - 1) >> 12;
if (FirstPage == LastPage) { @@ -183,6 +213,16 @@ Buffer = (PVOID)((ULONG_PTR)Buffer + Length); } } +} + +VOID EmulatorSetA20(BOOLEAN Enabled) +{ + A20Line = Enabled; +} + +BOOLEAN EmulatorGetA20(VOID) +{ + return A20Line; }
VOID
Modified: trunk/reactos/subsystems/mvdm/ntvdm/memory.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/ntvdm/memor... ============================================================================== --- trunk/reactos/subsystems/mvdm/ntvdm/memory.h [iso-8859-1] (original) +++ trunk/reactos/subsystems/mvdm/ntvdm/memory.h [iso-8859-1] Fri Jun 12 03:30:40 2015 @@ -36,20 +36,27 @@ VOID MemExceptionHandler(ULONG FaultAddress, BOOLEAN Writing);
VOID -MemRead +FASTCALL +EmulatorReadMemory ( + PFAST486_STATE State, ULONG Address, PVOID Buffer, ULONG Size );
VOID -MemWrite +FASTCALL +EmulatorWriteMemory ( + PFAST486_STATE State, ULONG Address, PVOID Buffer, ULONG Size ); + +VOID EmulatorSetA20(BOOLEAN Enabled); +BOOLEAN EmulatorGetA20(VOID);
BOOL MemInstallFastMemoryHook