- Simplify EmulatorReadMemory (first MMIO-mapped devices copy their memory image back to the VM' memory area, then data is read via RtlCopyMemory), and EmulatorWriteMemory (simplify VgaBuffer computation and rename this variable accordingly, for readability purposes).
- Fix Sim32pGetVDMPointer and MGetVdmPointer prototypes.

svn path=/branches/ntvdm/; revision=61356
This commit is contained in:
Hermès Bélusca-Maïto 2013-12-23 18:09:18 +00:00
parent 64091a6600
commit 8e9d50c603

View file

@ -43,21 +43,24 @@ VOID WINAPI EmulatorReadMemory(PFAST486_STATE State, ULONG Address, PVOID Buffer
/* Make sure the requested address is valid */ /* Make sure the requested address is valid */
if ((Address + Size) >= MAX_ADDRESS) return; if ((Address + Size) >= MAX_ADDRESS) return;
/* Read the data from the virtual address space and store it in the buffer */ /*
RtlCopyMemory(Buffer, (LPVOID)((ULONG_PTR)BaseAddress + Address), Size); * Check if we are going to read the VGA memory and
* copy it into the virtual address space if needed.
/* Check if we modified the console video memory */ */
if (((Address + Size) >= VgaGetVideoBaseAddress()) if (((Address + Size) >= VgaGetVideoBaseAddress())
&& (Address < VgaGetVideoLimitAddress())) && (Address < VgaGetVideoLimitAddress()))
{ {
DWORD VgaAddress = max(Address, VgaGetVideoBaseAddress()); DWORD VgaAddress = max(Address, VgaGetVideoBaseAddress());
DWORD ActualSize = min(Address + Size - 1, VgaGetVideoLimitAddress()) DWORD ActualSize = min(Address + Size - 1, VgaGetVideoLimitAddress())
- VgaAddress + 1; - VgaAddress + 1;
LPBYTE VgaBuffer = (LPBYTE)((ULONG_PTR)Buffer + VgaAddress - Address); LPBYTE DestBuffer = (LPBYTE)((ULONG_PTR)BaseAddress + VgaAddress);
/* Read from the VGA memory */ /* Read from the VGA memory */
VgaReadMemory(VgaAddress, VgaBuffer, ActualSize); VgaReadMemory(VgaAddress, DestBuffer, ActualSize);
} }
/* Read the data from the virtual address space and store it in the buffer */
RtlCopyMemory(Buffer, (LPVOID)((ULONG_PTR)BaseAddress + Address), Size);
} }
VOID WINAPI EmulatorWriteMemory(PFAST486_STATE State, ULONG Address, PVOID Buffer, ULONG Size) VOID WINAPI EmulatorWriteMemory(PFAST486_STATE State, ULONG Address, PVOID Buffer, ULONG Size)
@ -76,17 +79,19 @@ VOID WINAPI EmulatorWriteMemory(PFAST486_STATE State, ULONG Address, PVOID Buffe
/* Read the data from the buffer and store it in the virtual address space */ /* Read the data from the buffer and store it in the virtual address space */
RtlCopyMemory((LPVOID)((ULONG_PTR)BaseAddress + Address), Buffer, Size); RtlCopyMemory((LPVOID)((ULONG_PTR)BaseAddress + Address), Buffer, Size);
/* Check if we modified the console video memory */ /*
* Check if we modified the VGA memory.
*/
if (((Address + Size) >= VgaGetVideoBaseAddress()) if (((Address + Size) >= VgaGetVideoBaseAddress())
&& (Address < VgaGetVideoLimitAddress())) && (Address < VgaGetVideoLimitAddress()))
{ {
DWORD VgaAddress = max(Address, VgaGetVideoBaseAddress()); DWORD VgaAddress = max(Address, VgaGetVideoBaseAddress());
DWORD ActualSize = min(Address + Size - 1, VgaGetVideoLimitAddress()) DWORD ActualSize = min(Address + Size - 1, VgaGetVideoLimitAddress())
- VgaAddress + 1; - VgaAddress + 1;
LPBYTE VgaBuffer = (LPBYTE)((ULONG_PTR)Buffer + VgaAddress - Address); LPBYTE SrcBuffer = (LPBYTE)((ULONG_PTR)BaseAddress + VgaAddress);
/* Write to the VGA memory */ /* Write to the VGA memory */
VgaWriteMemory(VgaAddress, VgaBuffer, ActualSize); VgaWriteMemory(VgaAddress, SrcBuffer, ActualSize);
} }
} }
@ -178,8 +183,8 @@ VOID EmulatorSetA20(BOOLEAN Enabled)
PBYTE PBYTE
WINAPI WINAPI
Sim32pGetVDMPointer(IN ULONG Address, Sim32pGetVDMPointer(IN ULONG Address,
IN BOOL ProtectedMode) IN BOOLEAN ProtectedMode)
{ {
// FIXME // FIXME
UNREFERENCED_PARAMETER(ProtectedMode); UNREFERENCED_PARAMETER(ProtectedMode);
@ -189,14 +194,14 @@ Sim32pGetVDMPointer(IN ULONG Address,
* or Selector (if ProtectedMode == TRUE ) * or Selector (if ProtectedMode == TRUE )
* LOWORD(Address) == Offset * LOWORD(Address) == Offset
*/ */
return SEG_OFF_TO_PTR(HIWORD(Address), LOWORD(Address)); return (PBYTE)FAR_POINTER(Address);
} }
PBYTE PBYTE
WINAPI WINAPI
MGetVdmPointer(IN ULONG Address, MGetVdmPointer(IN ULONG Address,
IN ULONG Size, IN ULONG Size,
IN BOOL ProtectedMode) IN BOOLEAN ProtectedMode)
{ {
UNREFERENCED_PARAMETER(Size); UNREFERENCED_PARAMETER(Size);
return Sim32pGetVDMPointer(Address, ProtectedMode); return Sim32pGetVDMPointer(Address, ProtectedMode);