mirror of
https://github.com/reactos/reactos.git
synced 2024-07-29 07:39:10 +00:00
[NTVDM]
Make fast memory hooks FASTCALL. Only register the VGA memory hook for the region that needs to be hooked. svn path=/trunk/; revision=68110
This commit is contained in:
parent
c063145e96
commit
70a31e656a
|
@ -42,7 +42,7 @@ PBIOS_CONFIG_TABLE Bct;
|
||||||
|
|
||||||
/* PRIVATE FUNCTIONS **********************************************************/
|
/* 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 */
|
/* Prevent writing to ROM */
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
|
@ -402,7 +402,7 @@ static VOID WINAPI EmsIntHandler(LPWORD Stack)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static VOID NTAPI EmsReadMemory(ULONG Address, PVOID Buffer, ULONG Size)
|
static VOID FASTCALL EmsReadMemory(ULONG Address, PVOID Buffer, ULONG Size)
|
||||||
{
|
{
|
||||||
ULONG i;
|
ULONG i;
|
||||||
ULONG RelativeAddress = Address - TO_LINEAR(EMS_SEGMENT, 0);
|
ULONG RelativeAddress = Address - TO_LINEAR(EMS_SEGMENT, 0);
|
||||||
|
@ -422,7 +422,7 @@ static VOID NTAPI EmsReadMemory(ULONG Address, PVOID Buffer, ULONG Size)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static BOOLEAN NTAPI EmsWriteMemory(ULONG Address, PVOID Buffer, ULONG Size)
|
static BOOLEAN FASTCALL EmsWriteMemory(ULONG Address, PVOID Buffer, ULONG Size)
|
||||||
{
|
{
|
||||||
ULONG i;
|
ULONG i;
|
||||||
ULONG RelativeAddress = Address - TO_LINEAR(EMS_SEGMENT, 0);
|
ULONG RelativeAddress = Address - TO_LINEAR(EMS_SEGMENT, 0);
|
||||||
|
|
|
@ -21,8 +21,8 @@
|
||||||
|
|
||||||
/* PRIVATE VARIABLES **********************************************************/
|
/* PRIVATE VARIABLES **********************************************************/
|
||||||
|
|
||||||
static CONST DWORD MemoryBase[] = { 0xA0000, 0xA0000, 0xB0000, 0xB8000 };
|
static CONST DWORD MemoryBase[] = { 0xA0000, 0xA0000, 0xB0000, 0xB8000 };
|
||||||
static CONST DWORD MemoryLimit[] = { 0xBFFFF, 0xAFFFF, 0xB7FFF, 0xBFFFF };
|
static CONST DWORD MemorySize[] = { 0x20000, 0x10000, 0x8000, 0x8000 };
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Activate this line if you want to use the real
|
* Activate this line if you want to use the real
|
||||||
|
@ -429,11 +429,6 @@ static inline DWORD VgaGetVideoBaseAddress(VOID)
|
||||||
return MemoryBase[(VgaGcRegisters[VGA_GC_MISC_REG] >> 2) & 0x03];
|
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)
|
static VOID VgaUpdateCursorPosition(VOID)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
|
@ -1535,6 +1530,20 @@ static inline VOID VgaWriteGc(BYTE Data)
|
||||||
{
|
{
|
||||||
case VGA_GC_MISC_REG:
|
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 */
|
/* The GC misc register decides if it's text or graphics mode */
|
||||||
ModeChanged = TRUE;
|
ModeChanged = TRUE;
|
||||||
break;
|
break;
|
||||||
|
@ -1687,7 +1696,20 @@ static VOID WINAPI VgaWritePort(USHORT Port, BYTE Data)
|
||||||
UnregisterIoPort(0x3DA); // VGA_INSTAT1_READ_COLOR, VGA_FEATURE_WRITE_COLOR
|
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;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1946,7 +1968,7 @@ VOID VgaRefreshDisplay(VOID)
|
||||||
VgaVerticalRetrace(0);
|
VgaVerticalRetrace(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID NTAPI VgaReadMemory(ULONG Address, PVOID Buffer, ULONG Size)
|
VOID FASTCALL VgaReadMemory(ULONG Address, PVOID Buffer, ULONG Size)
|
||||||
{
|
{
|
||||||
DWORD i, j;
|
DWORD i, j;
|
||||||
DWORD VideoAddress;
|
DWORD VideoAddress;
|
||||||
|
@ -2007,7 +2029,7 @@ VOID NTAPI VgaReadMemory(ULONG Address, PVOID Buffer, ULONG Size)
|
||||||
VgaLatchRegisters[3] = VgaMemory[(3 * VGA_BANK_SIZE) + LOWORD(VideoAddress)];
|
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 i, j;
|
||||||
DWORD VideoAddress;
|
DWORD VideoAddress;
|
||||||
|
@ -2177,9 +2199,6 @@ BOOLEAN VgaInitialize(HANDLE TextHandle)
|
||||||
|
|
||||||
/* Clear the VGA memory */
|
/* Clear the VGA memory */
|
||||||
VgaClearMemory();
|
VgaClearMemory();
|
||||||
|
|
||||||
/* Register the memory hook */
|
|
||||||
MemInstallFastMemoryHook((PVOID)0xA0000, 0x20000, VgaReadMemory, VgaWriteMemory);
|
|
||||||
|
|
||||||
/* Register the I/O Ports */
|
/* Register the I/O Ports */
|
||||||
RegisterIoPort(0x3CC, VgaReadPort, NULL); // VGA_MISC_READ
|
RegisterIoPort(0x3CC, VgaReadPort, NULL); // VGA_MISC_READ
|
||||||
|
|
|
@ -256,6 +256,8 @@ VOID VgaDetachFromConsole(BOOL ChangeMode);
|
||||||
|
|
||||||
COORD VgaGetDisplayResolution(VOID);
|
COORD VgaGetDisplayResolution(VOID);
|
||||||
VOID VgaRefreshDisplay(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 VgaWriteFont(UINT FontNumber, CONST UCHAR *FontData, UINT Height);
|
||||||
VOID VgaClearMemory(VOID);
|
VOID VgaClearMemory(VOID);
|
||||||
BOOLEAN VgaGetDoubleVisionState(PBOOLEAN Horizontal, PBOOLEAN Vertical);
|
BOOLEAN VgaGetDoubleVisionState(PBOOLEAN Horizontal, PBOOLEAN Vertical);
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
#define TOTAL_PAGES (MAX_ADDRESS / PAGE_SIZE)
|
#define TOTAL_PAGES (MAX_ADDRESS / PAGE_SIZE)
|
||||||
|
|
||||||
typedef VOID
|
typedef VOID
|
||||||
(WINAPI *PMEMORY_READ_HANDLER)
|
(FASTCALL *PMEMORY_READ_HANDLER)
|
||||||
(
|
(
|
||||||
ULONG Address,
|
ULONG Address,
|
||||||
PVOID Buffer,
|
PVOID Buffer,
|
||||||
|
@ -22,7 +22,7 @@ typedef VOID
|
||||||
);
|
);
|
||||||
|
|
||||||
typedef BOOLEAN
|
typedef BOOLEAN
|
||||||
(WINAPI *PMEMORY_WRITE_HANDLER)
|
(FASTCALL *PMEMORY_WRITE_HANDLER)
|
||||||
(
|
(
|
||||||
ULONG Address,
|
ULONG Address,
|
||||||
PVOID Buffer,
|
PVOID Buffer,
|
||||||
|
|
Loading…
Reference in a new issue