9 #include <rosrtl/string.h>
12 InitializeVideoAddressSpace(VOID
)
14 OBJECT_ATTRIBUTES ObjectAttributes
;
15 UNICODE_STRING PhysMemName
;
26 * Open the physical memory section
28 RtlRosInitUnicodeStringFromLiteral(&PhysMemName
, L
"\\Device\\PhysicalMemory");
29 InitializeObjectAttributes(&ObjectAttributes
,
34 Status
= ZwOpenSection(&PhysMemHandle
, SECTION_ALL_ACCESS
,
36 if (!NT_SUCCESS(Status
))
38 DbgPrint("Couldn't open \\Device\\PhysicalMemory\n");
43 * Map the BIOS and device registers into the address space
45 Offset
.QuadPart
= 0xa0000;
46 ViewSize
= 0x100000 - 0xa0000;
47 BaseAddress
= (PVOID
)0xa0000;
48 Status
= NtMapViewOfSection(PhysMemHandle
,
57 PAGE_EXECUTE_READWRITE
);
58 if (!NT_SUCCESS(Status
))
60 DbgPrint("Couldn't map physical memory (%x)\n", Status
);
61 NtClose(PhysMemHandle
);
64 NtClose(PhysMemHandle
);
65 if (BaseAddress
!= (PVOID
)0xa0000)
67 DbgPrint("Couldn't map physical memory at the right address "
68 "(was %x)\n", BaseAddress
);
73 * Map some memory to use for the non-BIOS parts of the v86 mode address
76 BaseAddress
= (PVOID
)0x1;
77 ViewSize
= 0xa0000 - 0x1000;
78 Status
= ZwAllocateVirtualMemory(NtCurrentProcess(),
83 PAGE_EXECUTE_READWRITE
);
84 if (!NT_SUCCESS(Status
))
86 DbgPrint("Failed to allocate virtual memory (Status %x)\n", Status
);
89 if (BaseAddress
!= (PVOID
)0x0)
91 DbgPrint("Failed to allocate virtual memory at right address "
92 "(was %x)\n", BaseAddress
);
97 * Get the real mode IVT from the kernel
99 Status
= NtVdmControl(0, IVT
);
100 if (!NT_SUCCESS(Status
))
102 DbgPrint("NtVdmControl failed (status %x)\n", Status
);
107 * Copy the real mode IVT into the right place
109 NullAddress
= (PVOID
)0x0; /* Workaround for GCC 3.4 */
110 memcpy(NullAddress
, IVT
, 1024);
113 * Get the BDA from the kernel
115 Status
= NtVdmControl(1, BDA
);
116 if (!NT_SUCCESS(Status
))
118 DbgPrint("NtVdmControl failed (status %x)\n", Status
);
123 * Copy the BDA into the right place
125 memcpy((PVOID
)0x400, BDA
, 256);