From: Hermès Bélusca-Maïto Date: Mon, 24 Feb 2014 00:33:21 +0000 (+0000) Subject: [NTVDM] X-Git-Tag: backups/0.3.17@66124~1365^2~68 X-Git-Url: https://git.reactos.org/?p=reactos.git;a=commitdiff_plain;h=9542b8693415755d2067515155fd9af1e091ad51;hp=ec52f30bc5192db00484e007ddcd34ff23b3e3cd [NTVDM] - Move an "enable interrupts" command to where it belongs (i.e. in the BIOS32 initialization code; we do it at the very end). Otherwise some problems appears when trying to load 16-bit bios images. - Use the new macro REAL_TO_PHYS to convert "real-mode" pointers (valid inside the VM only) into "physical" ones (valid in ROS/Windows/whatever). - Add BIG HACKs (thanks Aleksander ;) ) in EmulatorRead/WriteMemory for wrapping up high memory addresses to low ones, so that we can load bios images (when you start running code at F000:FFF0). To test 16-bit bios images: in ntvdm.c, put a valid bios file name in the BiosInitialize(...) call, and disable all DOS calls that happen before EmulatorSimulate(). svn path=/branches/ntvdm/; revision=62314 --- diff --git a/subsystems/ntvdm/bios/bios32/bios32.c b/subsystems/ntvdm/bios/bios32/bios32.c index 6379c9b7369..a71ec25427a 100644 --- a/subsystems/ntvdm/bios/bios32/bios32.c +++ b/subsystems/ntvdm/bios/bios32/bios32.c @@ -386,6 +386,10 @@ BOOLEAN Bios32Initialize(IN HANDLE ConsoleInput, /* Initialize the Video BIOS */ if (!VidBios32Initialize(ConsoleOutput)) return FALSE; + /* Enable interrupts */ + setIF(1); + + /* We are done */ return TRUE; } diff --git a/subsystems/ntvdm/emulator.c b/subsystems/ntvdm/emulator.c index f29671939df..0732ebb2142 100644 --- a/subsystems/ntvdm/emulator.c +++ b/subsystems/ntvdm/emulator.c @@ -65,6 +65,10 @@ VOID WINAPI EmulatorReadMemory(PFAST486_STATE State, ULONG Address, PVOID Buffer { 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); @@ -81,20 +85,24 @@ VOID WINAPI EmulatorReadMemory(PFAST486_STATE State, ULONG Address, PVOID Buffer DWORD VgaAddress = max(Address, VgaGetVideoBaseAddress()); DWORD ActualSize = min(Address + Size - 1, VgaGetVideoLimitAddress()) - VgaAddress + 1; - LPBYTE DestBuffer = (LPBYTE)((ULONG_PTR)BaseAddress + VgaAddress); + 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, (LPVOID)((ULONG_PTR)BaseAddress + Address), Size); + 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); @@ -105,7 +113,7 @@ VOID WINAPI EmulatorWriteMemory(PFAST486_STATE State, ULONG Address, PVOID Buffe 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((LPVOID)((ULONG_PTR)BaseAddress + Address), Buffer, Size); + RtlCopyMemory(REAL_TO_PHYS(Address), Buffer, Size); /* * Check if we modified the VGA memory. @@ -116,7 +124,7 @@ VOID WINAPI EmulatorWriteMemory(PFAST486_STATE State, ULONG Address, PVOID Buffe DWORD VgaAddress = max(Address, VgaGetVideoBaseAddress()); DWORD ActualSize = min(Address + Size - 1, VgaGetVideoLimitAddress()) - VgaAddress + 1; - LPBYTE SrcBuffer = (LPBYTE)((ULONG_PTR)BaseAddress + VgaAddress); + LPBYTE SrcBuffer = (LPBYTE)REAL_TO_PHYS(VgaAddress); /* Write to the VGA memory */ VgaWriteMemory(VgaAddress, SrcBuffer, ActualSize); @@ -355,9 +363,6 @@ BOOLEAN EmulatorInitialize(HANDLE ConsoleInput, HANDLE ConsoleOutput) EmulatorIntAcknowledge, NULL /* TODO: Use a TLB */); - /* Enable interrupts */ - setIF(1); - /* Initialize DMA */ /* Initialize the PIC, the PIT, the CMOS and the PC Speaker */