Author: hbelusca Date: Mon Feb 24 00:33:21 2014 New Revision: 62314
URL: http://svn.reactos.org/svn/reactos?rev=62314&view=rev Log: [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().
Modified: branches/ntvdm/subsystems/ntvdm/bios/bios32/bios32.c branches/ntvdm/subsystems/ntvdm/emulator.c
Modified: branches/ntvdm/subsystems/ntvdm/bios/bios32/bios32.c URL: http://svn.reactos.org/svn/reactos/branches/ntvdm/subsystems/ntvdm/bios/bios... ============================================================================== --- branches/ntvdm/subsystems/ntvdm/bios/bios32/bios32.c [iso-8859-1] (original) +++ branches/ntvdm/subsystems/ntvdm/bios/bios32/bios32.c [iso-8859-1] Mon Feb 24 00:33:21 2014 @@ -386,6 +386,10 @@ /* Initialize the Video BIOS */ if (!VidBios32Initialize(ConsoleOutput)) return FALSE;
+ /* Enable interrupts */ + setIF(1); + + /* We are done */ return TRUE; }
Modified: branches/ntvdm/subsystems/ntvdm/emulator.c URL: http://svn.reactos.org/svn/reactos/branches/ntvdm/subsystems/ntvdm/emulator.... ============================================================================== --- branches/ntvdm/subsystems/ntvdm/emulator.c [iso-8859-1] (original) +++ branches/ntvdm/subsystems/ntvdm/emulator.c [iso-8859-1] Mon Feb 24 00:33:21 2014 @@ -65,6 +65,10 @@ { 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,19 +85,23 @@ 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 @@ 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 @@ 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 @@ EmulatorIntAcknowledge, NULL /* TODO: Use a TLB */);
- /* Enable interrupts */ - setIF(1); - /* Initialize DMA */
/* Initialize the PIC, the PIT, the CMOS and the PC Speaker */