8 InitializeVideoAddressSpace(VOID)
10 OBJECT_ATTRIBUTES ObjectAttributes;
11 UNICODE_STRING PhysMemName;
22 * Open the physical memory section
24 RtlInitUnicodeStringFromLiteral(&PhysMemName, L"\\Device\\PhysicalMemory");
25 InitializeObjectAttributes(&ObjectAttributes,
30 Status = NtOpenSection(&PhysMemHandle, SECTION_ALL_ACCESS,
32 if (!NT_SUCCESS(Status))
34 DbgPrint("Couldn't open \\Device\\PhysicalMemory\n");
39 * Map the BIOS and device registers into the address space
41 Offset.QuadPart = 0xa0000;
42 ViewSize = 0x100000 - 0xa0000;
43 BaseAddress = (PVOID)0xa0000;
44 Status = NtMapViewOfSection(PhysMemHandle,
53 PAGE_EXECUTE_READWRITE);
54 if (!NT_SUCCESS(Status))
56 DbgPrint("Couldn't map physical memory (%x)\n", Status);
57 NtClose(PhysMemHandle);
60 NtClose(PhysMemHandle);
61 if (BaseAddress != (PVOID)0xa0000)
63 DbgPrint("Couldn't map physical memory at the right address "
64 "(was %x)\n", BaseAddress);
69 * Map some memory to use for the non-BIOS parts of the v86 mode address
72 BaseAddress = (PVOID)0x1;
73 ViewSize = 0xa0000 - 0x1000;
74 Status = ZwAllocateVirtualMemory(NtCurrentProcess(),
79 PAGE_EXECUTE_READWRITE);
80 if (!NT_SUCCESS(Status))
82 DbgPrint("Failed to allocate virtual memory (Status %x)\n", Status);
85 if (BaseAddress != (PVOID)0x0)
87 DbgPrint("Failed to allocate virtual memory at right address "
88 "(was %x)\n", BaseAddress);
93 * Get the real mode IVT from the kernel
95 Status = NtVdmControl(0, IVT);
96 if (!NT_SUCCESS(Status))
98 DbgPrint("NtVdmControl failed (status %x)\n", Status);
103 * Copy the real mode IVT into the right place
105 memcpy((PVOID)0x0, IVT, 1024);
108 * Get the BDA from the kernel
110 Status = NtVdmControl(1, BDA);
111 if (!NT_SUCCESS(Status))
113 DbgPrint("NtVdmControl failed (status %x)\n", Status);
118 * Copy the BDA into the right place
120 memcpy((PVOID)0x400, BDA, 256);