Author: aandrejevic
Date: Fri Jun 12 16:25:23 2015
New Revision: 68110
URL:
http://svn.reactos.org/svn/reactos?rev=68110&view=rev
Log:
[NTVDM]
Make fast memory hooks FASTCALL.
Only register the VGA memory hook for the region that needs to be hooked.
Modified:
trunk/reactos/subsystems/mvdm/ntvdm/bios/bios.c
trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/emsdrv.c
trunk/reactos/subsystems/mvdm/ntvdm/hardware/video/vga.c
trunk/reactos/subsystems/mvdm/ntvdm/hardware/video/vga.h
trunk/reactos/subsystems/mvdm/ntvdm/memory.h
Modified: trunk/reactos/subsystems/mvdm/ntvdm/bios/bios.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/ntvdm/bios…
==============================================================================
--- trunk/reactos/subsystems/mvdm/ntvdm/bios/bios.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/mvdm/ntvdm/bios/bios.c [iso-8859-1] Fri Jun 12 16:25:23 2015
@@ -42,7 +42,7 @@
/* PRIVATE FUNCTIONS **********************************************************/
-static BOOLEAN NTAPI BiosRomWrite(ULONG Address, PVOID Buffer, ULONG Size)
+static BOOLEAN FASTCALL BiosRomWrite(ULONG Address, PVOID Buffer, ULONG Size)
{
/* Prevent writing to ROM */
return FALSE;
Modified: trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/emsdrv.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/ntvdm/dos/…
==============================================================================
--- trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/emsdrv.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/emsdrv.c [iso-8859-1] Fri Jun 12
16:25:23 2015
@@ -402,7 +402,7 @@
}
}
-static VOID NTAPI EmsReadMemory(ULONG Address, PVOID Buffer, ULONG Size)
+static VOID FASTCALL EmsReadMemory(ULONG Address, PVOID Buffer, ULONG Size)
{
ULONG i;
ULONG RelativeAddress = Address - TO_LINEAR(EMS_SEGMENT, 0);
@@ -422,7 +422,7 @@
}
}
-static BOOLEAN NTAPI EmsWriteMemory(ULONG Address, PVOID Buffer, ULONG Size)
+static BOOLEAN FASTCALL EmsWriteMemory(ULONG Address, PVOID Buffer, ULONG Size)
{
ULONG i;
ULONG RelativeAddress = Address - TO_LINEAR(EMS_SEGMENT, 0);
Modified: trunk/reactos/subsystems/mvdm/ntvdm/hardware/video/vga.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/ntvdm/hard…
==============================================================================
--- trunk/reactos/subsystems/mvdm/ntvdm/hardware/video/vga.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/mvdm/ntvdm/hardware/video/vga.c [iso-8859-1] Fri Jun 12
16:25:23 2015
@@ -21,8 +21,8 @@
/* PRIVATE VARIABLES **********************************************************/
-static CONST DWORD MemoryBase[] = { 0xA0000, 0xA0000, 0xB0000, 0xB8000 };
-static CONST DWORD MemoryLimit[] = { 0xBFFFF, 0xAFFFF, 0xB7FFF, 0xBFFFF };
+static CONST DWORD MemoryBase[] = { 0xA0000, 0xA0000, 0xB0000, 0xB8000 };
+static CONST DWORD MemorySize[] = { 0x20000, 0x10000, 0x8000, 0x8000 };
/*
* Activate this line if you want to use the real
@@ -429,11 +429,6 @@
return MemoryBase[(VgaGcRegisters[VGA_GC_MISC_REG] >> 2) & 0x03];
}
-static inline DWORD VgaGetVideoLimitAddress(VOID)
-{
- return MemoryLimit[(VgaGcRegisters[VGA_GC_MISC_REG] >> 2) & 0x03];
-}
-
static VOID VgaUpdateCursorPosition(VOID)
{
/*
@@ -1535,6 +1530,20 @@
{
case VGA_GC_MISC_REG:
{
+ /* Remove any existing VGA memory hook */
+ MemRemoveFastMemoryHook((PVOID)0xA0000, 0x20000);
+
+ if (VgaMiscRegister & VGA_MISC_RAM_ENABLED)
+ {
+ UCHAR MemoryMap = (VgaGcRegisters[VGA_GC_MISC_REG] >> 2) &
0x03;
+
+ /* Register a memory hook */
+ MemInstallFastMemoryHook((PVOID)MemoryBase[MemoryMap],
+ MemorySize[MemoryMap],
+ VgaReadMemory,
+ VgaWriteMemory);
+ }
+
/* The GC misc register decides if it's text or graphics mode */
ModeChanged = TRUE;
break;
@@ -1687,7 +1696,20 @@
UnregisterIoPort(0x3DA); // VGA_INSTAT1_READ_COLOR,
VGA_FEATURE_WRITE_COLOR
}
- // if (VgaMiscRegister & 0x02) { /* Enable RAM access */ } else { /*
Disable RAM access */ }
+ /* Remove any existing VGA memory hook */
+ MemRemoveFastMemoryHook((PVOID)0xA0000, 0x20000);
+
+ if (VgaMiscRegister & VGA_MISC_RAM_ENABLED)
+ {
+ UCHAR MemoryMap = (VgaGcRegisters[VGA_GC_MISC_REG] >> 2) &
0x03;
+
+ /* Register a memory hook */
+ MemInstallFastMemoryHook((PVOID)MemoryBase[MemoryMap],
+ MemorySize[MemoryMap],
+ VgaReadMemory,
+ VgaWriteMemory);
+ }
+
break;
}
@@ -1946,7 +1968,7 @@
VgaVerticalRetrace(0);
}
-VOID NTAPI VgaReadMemory(ULONG Address, PVOID Buffer, ULONG Size)
+VOID FASTCALL VgaReadMemory(ULONG Address, PVOID Buffer, ULONG Size)
{
DWORD i, j;
DWORD VideoAddress;
@@ -2007,7 +2029,7 @@
VgaLatchRegisters[3] = VgaMemory[(3 * VGA_BANK_SIZE) + LOWORD(VideoAddress)];
}
-BOOLEAN NTAPI VgaWriteMemory(ULONG Address, PVOID Buffer, ULONG Size)
+BOOLEAN FASTCALL VgaWriteMemory(ULONG Address, PVOID Buffer, ULONG Size)
{
DWORD i, j;
DWORD VideoAddress;
@@ -2177,9 +2199,6 @@
/* Clear the VGA memory */
VgaClearMemory();
-
- /* Register the memory hook */
- MemInstallFastMemoryHook((PVOID)0xA0000, 0x20000, VgaReadMemory, VgaWriteMemory);
/* Register the I/O Ports */
RegisterIoPort(0x3CC, VgaReadPort, NULL); // VGA_MISC_READ
Modified: trunk/reactos/subsystems/mvdm/ntvdm/hardware/video/vga.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/ntvdm/hard…
==============================================================================
--- trunk/reactos/subsystems/mvdm/ntvdm/hardware/video/vga.h [iso-8859-1] (original)
+++ trunk/reactos/subsystems/mvdm/ntvdm/hardware/video/vga.h [iso-8859-1] Fri Jun 12
16:25:23 2015
@@ -256,6 +256,8 @@
COORD VgaGetDisplayResolution(VOID);
VOID VgaRefreshDisplay(VOID);
+VOID FASTCALL VgaReadMemory(ULONG Address, PVOID Buffer, ULONG Size);
+BOOLEAN FASTCALL VgaWriteMemory(ULONG Address, PVOID Buffer, ULONG Size);
VOID VgaWriteFont(UINT FontNumber, CONST UCHAR *FontData, UINT Height);
VOID VgaClearMemory(VOID);
BOOLEAN VgaGetDoubleVisionState(PBOOLEAN Horizontal, PBOOLEAN Vertical);
Modified: trunk/reactos/subsystems/mvdm/ntvdm/memory.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/ntvdm/memo…
==============================================================================
--- trunk/reactos/subsystems/mvdm/ntvdm/memory.h [iso-8859-1] (original)
+++ trunk/reactos/subsystems/mvdm/ntvdm/memory.h [iso-8859-1] Fri Jun 12 16:25:23 2015
@@ -14,7 +14,7 @@
#define TOTAL_PAGES (MAX_ADDRESS / PAGE_SIZE)
typedef VOID
-(WINAPI *PMEMORY_READ_HANDLER)
+(FASTCALL *PMEMORY_READ_HANDLER)
(
ULONG Address,
PVOID Buffer,
@@ -22,7 +22,7 @@
);
typedef BOOLEAN
-(WINAPI *PMEMORY_WRITE_HANDLER)
+(FASTCALL *PMEMORY_WRITE_HANDLER)
(
ULONG Address,
PVOID Buffer,