- 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
This commit is contained in:
Hermès Bélusca-Maïto 2014-02-24 00:33:21 +00:00
parent ec52f30bc5
commit 9542b86934
2 changed files with 16 additions and 7 deletions

View file

@ -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;
}

View file

@ -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 */