diff --git a/reactos/ntoskrnl/ke/i386/v86m.c b/reactos/ntoskrnl/ke/i386/v86m.c index 97f56a40eae..d71836dc778 100644 --- a/reactos/ntoskrnl/ke/i386/v86m.c +++ b/reactos/ntoskrnl/ke/i386/v86m.c @@ -32,7 +32,7 @@ #include #include -//#define NDEBUG +#define NDEBUG #include /* GLOBALS *******************************************************************/ @@ -283,10 +283,10 @@ KeV86Exception(ULONG ExceptionNr, PKTRAP_FRAME Tf, ULONG address) Ip = (PUCHAR)((Tf->Cs & 0xFFFF) * 16 + (Tf->Eip & 0xFFFF)); if (ExceptionNr != 14) { - DbgPrint("ExceptionNr %d Ip[0] %x Ip[1] %x Ip[2] %x Ip[3] %x Tf->Cs %x " - "Tf->Eip %x\n", ExceptionNr, Ip[0], Ip[1], Ip[2], Ip[3], Tf->Cs, - Tf->Eip); - DbgPrint("VTf %x VTf->regs %x\n", VTf, VTf->regs); + DPRINT("ExceptionNr %d Ip[0] %x Ip[1] %x Ip[2] %x Ip[3] %x Tf->Cs %x " + "Tf->Eip %x\n", ExceptionNr, Ip[0], Ip[1], Ip[2], Ip[3], Tf->Cs, + Tf->Eip); + DPRINT("VTf %x VTf->regs %x\n", VTf, VTf->regs); } if (ExceptionNr == 6 && memcmp(Ip, VTf->regs->RecoveryInstruction, 4) == 0 && diff --git a/reactos/subsys/csrss/video.c b/reactos/subsys/csrss/video.c new file mode 100644 index 00000000000..f68e1209b2b --- /dev/null +++ b/reactos/subsys/csrss/video.c @@ -0,0 +1,103 @@ +#include + +ULONG +InitializeVideoAddressSpace(VOID) +{ + OBJECT_ATTRIBUTES ObjectAttributes; + UNICODE_STRING PhysMemName; + NTSTATUS Status; + HANDLE PhysMemHandle; + PVOID BaseAddress; + LARGE_INTEGER Offset; + ULONG ViewSize; + PUCHAR TextMap; + CHAR IVT[1024]; + + /* + * Open the physical memory section + */ + RtlInitUnicodeString(&PhysMemName, L"\\Device\\PhysicalMemory"); + InitializeObjectAttributes(&ObjectAttributes, + &PhysMemName, + 0, + NULL, + NULL); + Status = NtOpenSection(&PhysMemHandle, SECTION_ALL_ACCESS, + &ObjectAttributes); + if (!NT_SUCCESS(Status)) + { + DbgPrint("Couldn't open \\Device\\PhysicalMemory\n"); + return(0); + } + + /* + * Map the BIOS and device registers into the address space + */ + Offset.QuadPart = 0xa0000; + ViewSize = 0x100000 - 0xa0000; + BaseAddress = (PVOID)0xa0000; + Status = NtMapViewOfSection(PhysMemHandle, + NtCurrentProcess(), + &BaseAddress, + 0, + 8192, + &Offset, + &ViewSize, + ViewUnmap, + 0, + PAGE_EXECUTE_READWRITE); + if (!NT_SUCCESS(Status)) + { + DbgPrint("Couldn't map physical memory (%x)\n", Status); + NtClose(PhysMemHandle); + return(0); + } + NtClose(PhysMemHandle); + if (BaseAddress != (PVOID)0xa0000) + { + DbgPrint("Couldn't map physical memory at the right address " + "(was %x)\n", BaseAddress); + return(0); + } + + /* + * Map some memory to use for the non-BIOS parts of the v86 mode address + * space + */ + BaseAddress = (PVOID)0x1; + ViewSize = 0xa0000 - 0x1000; + Status = ZwAllocateVirtualMemory(NtCurrentProcess(), + &BaseAddress, + 0, + &ViewSize, + MEM_COMMIT, + PAGE_EXECUTE_READWRITE); + if (!NT_SUCCESS(Status)) + { + DbgPrint("Failed to allocate virtual memory (Status %x)\n", Status); + return(0); + } + if (BaseAddress != (PVOID)0x0) + { + DbgPrint("Failed to allocate virtual memory at right address " + "(was %x)\n", BaseAddress); + return(0); + } + + /* + * Get the real mode IVT from the kernel + */ + Status = NtVdmControl(0, IVT); + if (!NT_SUCCESS(Status)) + { + DbgPrint("NtVdmControl failed (status %x)\n", Status); + return(0); + } + + /* + * Copy the real mode IVT into the right place + */ + memcpy((PVOID)0x0, IVT, 1024); + + return(1); +}