1 /* $Id: video.c,v 1.7 2003/10/20 18:02:04 gvg Exp $
8 InitializeVideoAddressSpace(VOID
)
10 OBJECT_ATTRIBUTES ObjectAttributes
;
11 UNICODE_STRING PhysMemName
;
21 * Open the physical memory section
23 RtlInitUnicodeStringFromLiteral(&PhysMemName
, L
"\\Device\\PhysicalMemory");
24 InitializeObjectAttributes(&ObjectAttributes
,
29 Status
= NtOpenSection(&PhysMemHandle
, SECTION_ALL_ACCESS
,
31 if (!NT_SUCCESS(Status
))
33 DbgPrint("Couldn't open \\Device\\PhysicalMemory\n");
38 * Map the BIOS and device registers into the address space
40 Offset
.QuadPart
= 0xa0000;
41 ViewSize
= 0x100000 - 0xa0000;
42 BaseAddress
= (PVOID
)0xa0000;
43 Status
= NtMapViewOfSection(PhysMemHandle
,
52 PAGE_EXECUTE_READWRITE
);
53 if (!NT_SUCCESS(Status
))
55 DbgPrint("Couldn't map physical memory (%x)\n", Status
);
56 NtClose(PhysMemHandle
);
59 NtClose(PhysMemHandle
);
60 if (BaseAddress
!= (PVOID
)0xa0000)
62 DbgPrint("Couldn't map physical memory at the right address "
63 "(was %x)\n", BaseAddress
);
68 * Map some memory to use for the non-BIOS parts of the v86 mode address
71 BaseAddress
= (PVOID
)0x1;
72 ViewSize
= 0xa0000 - 0x1000;
73 Status
= ZwAllocateVirtualMemory(NtCurrentProcess(),
78 PAGE_EXECUTE_READWRITE
);
79 if (!NT_SUCCESS(Status
))
81 DbgPrint("Failed to allocate virtual memory (Status %x)\n", Status
);
84 if (BaseAddress
!= (PVOID
)0x0)
86 DbgPrint("Failed to allocate virtual memory at right address "
87 "(was %x)\n", BaseAddress
);
92 * Get the real mode IVT from the kernel
94 Status
= NtVdmControl(0, IVT
);
95 if (!NT_SUCCESS(Status
))
97 DbgPrint("NtVdmControl failed (status %x)\n", Status
);
102 * Copy the real mode IVT into the right place
104 memcpy((PVOID
)0x0, IVT
, 1024);
107 * Get the BDA from the kernel
109 Status
= NtVdmControl(1, BDA
);
110 if (!NT_SUCCESS(Status
))
112 DbgPrint("NtVdmControl failed (status %x)\n", Status
);
117 * Copy the BDA into the right place
119 memcpy((PVOID
)0x400, BDA
, 256);