Merge 14981:15268 from trunk
[reactos.git] / reactos / ntoskrnl / inbv / inbv.c
1 /* $Id$
2 *
3 * COPYRIGHT: See COPYING in the top level directory
4 * PROJECT: ReactOS kernel
5 * FILE: ntoskrnl/inbv/inbv.c
6 * PURPOSE: Boot video support
7 *
8 * PROGRAMMERS: Casper S. Hornstrup (chorns@users.sourceforge.net)
9 */
10
11 /* INCLUDES ******************************************************************/
12
13 #include <ntoskrnl.h>
14 #include <ntos/bootvid.h>
15 #include <ddk/ntbootvid.h>
16 #define NDEBUG
17 #include <internal/debug.h>
18
19
20 /* GLOBALS *******************************************************************/
21
22 /* DATA **********************************************************************/
23
24 static HANDLE BootVidDevice = NULL;
25 static BOOL BootVidDriverInstalled = FALSE;
26 static NTBOOTVID_FUNCTION_TABLE BootVidFunctionTable;
27
28 /* FUNCTIONS *****************************************************************/
29
30 NTSTATUS
31 STATIC
32 InbvCheckBootVid(VOID)
33 {
34 IO_STATUS_BLOCK Iosb;
35
36 if (BootVidDevice == NULL)
37 {
38 NTSTATUS Status;
39 OBJECT_ATTRIBUTES ObjectAttributes;
40 UNICODE_STRING BootVidName;
41
42 RtlRosInitUnicodeStringFromLiteral(&BootVidName, L"\\Device\\BootVid");
43 InitializeObjectAttributes(&ObjectAttributes,
44 &BootVidName,
45 0,
46 NULL,
47 NULL);
48 Status = ZwOpenFile(&BootVidDevice,
49 FILE_ALL_ACCESS,
50 &ObjectAttributes,
51 &Iosb,
52 0,
53 0);
54 if (!NT_SUCCESS(Status))
55 {
56 return(Status);
57 }
58 }
59 return(STATUS_SUCCESS);
60 }
61
62
63 VOID
64 STDCALL
65 InbvAcquireDisplayOwnership(VOID)
66 {
67 }
68
69
70 BOOLEAN
71 STDCALL
72 InbvCheckDisplayOwnership(VOID)
73 {
74 return FALSE;
75 }
76
77
78 BOOLEAN
79 STDCALL
80 InbvDisplayString(IN PCHAR String)
81 {
82 return FALSE;
83 }
84
85
86 BOOLEAN
87 STDCALL
88 InbvResetDisplayParameters(ULONG SizeX, ULONG SizeY)
89 {
90 return(InbvResetDisplay());
91 }
92
93
94 VOID
95 STDCALL INIT_FUNCTION
96 InbvEnableBootDriver(IN BOOLEAN Enable)
97 {
98 NTSTATUS Status;
99 IO_STATUS_BLOCK Iosb;
100
101 Status = InbvCheckBootVid();
102 if (!NT_SUCCESS(Status))
103 {
104 return;
105 }
106
107 if (Enable)
108 {
109 /* Notify the hal we will acquire the display. */
110 HalAcquireDisplayOwnership(InbvResetDisplayParameters);
111
112 Status = NtDeviceIoControlFile(BootVidDevice,
113 NULL,
114 NULL,
115 NULL,
116 &Iosb,
117 IOCTL_BOOTVID_INITIALIZE,
118 NULL,
119 0,
120 &BootVidFunctionTable,
121 sizeof(BootVidFunctionTable));
122 if (!NT_SUCCESS(Status))
123 {
124 KEBUGCHECK(0);
125 }
126 BootVidDriverInstalled = TRUE;
127 CHECKPOINT;
128 }
129 else
130 {
131 Status = NtDeviceIoControlFile(BootVidDevice,
132 NULL,
133 NULL,
134 NULL,
135 &Iosb,
136 IOCTL_BOOTVID_CLEANUP,
137 NULL,
138 0,
139 NULL,
140 0);
141 if (!NT_SUCCESS(Status))
142 {
143 KEBUGCHECK(0);
144 }
145 BootVidDriverInstalled = FALSE;
146 /* Notify the hal we have released the display. */
147 HalReleaseDisplayOwnership();
148
149 NtClose(BootVidDevice);
150 BootVidDevice = NULL;
151 }
152 }
153
154
155 BOOLEAN
156 STDCALL
157 InbvEnableDisplayString(IN BOOLEAN Enable)
158 {
159 return FALSE;
160 }
161
162
163 VOID
164 STDCALL
165 InbvInstallDisplayStringFilter(IN PVOID Unknown)
166 {
167 }
168
169
170 BOOLEAN
171 STDCALL
172 InbvIsBootDriverInstalled(VOID)
173 {
174 return(BootVidDriverInstalled);
175 }
176
177
178 VOID
179 STDCALL
180 InbvNotifyDisplayOwnershipLost(IN PVOID Callback)
181 {
182 }
183
184
185 BOOLEAN
186 STDCALL
187 InbvResetDisplay(VOID)
188 {
189 if (!BootVidDriverInstalled)
190 {
191 return(FALSE);
192 }
193 return(BootVidFunctionTable.ResetDisplay());
194 }
195
196
197 VOID
198 STDCALL
199 InbvSetScrollRegion(IN ULONG Left,
200 IN ULONG Top,
201 IN ULONG Width,
202 IN ULONG Height)
203 {
204 }
205
206
207 VOID
208 STDCALL
209 InbvSetTextColor(IN ULONG Color)
210 {
211 }
212
213
214 VOID
215 STDCALL
216 InbvSolidColorFill(IN ULONG Left,
217 IN ULONG Top,
218 IN ULONG Width,
219 IN ULONG Height,
220 IN ULONG Color)
221 {
222 }
223
224 NTSTATUS
225 STDCALL
226 NtDisplayString(IN PUNICODE_STRING DisplayString)
227 {
228 OEM_STRING OemString;
229
230 RtlUnicodeStringToOemString(&OemString, DisplayString, TRUE);
231 HalDisplayString(OemString.Buffer);
232 RtlFreeOemString(&OemString);
233
234 return STATUS_SUCCESS;
235 }