]>
Commit | Line | Data |
---|---|---|
1 | /** @file\r | |
2 | Console Splitter Driver. Any Handle that attatched console I/O protocols\r | |
3 | (Console In device, Console Out device, Console Error device, Simple Pointer\r | |
4 | protocol, Absolute Pointer protocol) can be bound by this driver.\r | |
5 | \r | |
6 | So far it works like any other driver by opening a SimpleTextIn and/or\r | |
7 | SimpleTextOut protocol with EFI_OPEN_PROTOCOL_BY_DRIVER attributes. The big\r | |
8 | difference is this driver does not layer a protocol on the passed in\r | |
9 | handle, or construct a child handle like a standard device or bus driver.\r | |
10 | This driver produces three virtual handles as children, one for console input\r | |
11 | splitter, one for console output splitter and one for error output splitter.\r | |
12 | These 3 virtual handles would be installed on gST.\r | |
13 | \r | |
14 | Each virtual handle, that supports the Console I/O protocol, will be produced\r | |
15 | in the driver entry point. The virtual handle are added on driver entry and\r | |
16 | never removed. Such design ensures sytem function well during none console\r | |
17 | device situation.\r | |
18 | \r | |
19 | Copyright (c) 2006 - 2008 Intel Corporation. <BR>\r | |
20 | All rights reserved. This program and the accompanying materials\r | |
21 | are licensed and made available under the terms and conditions of the BSD License\r | |
22 | which accompanies this distribution. The full text of the license may be found at\r | |
23 | http://opensource.org/licenses/bsd-license.php\r | |
24 | \r | |
25 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
26 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
27 | \r | |
28 | **/\r | |
29 | \r | |
30 | #include "ConSplitter.h"\r | |
31 | \r | |
32 | //\r | |
33 | // Text In Splitter Private Data template\r | |
34 | //\r | |
35 | GLOBAL_REMOVE_IF_UNREFERENCED TEXT_IN_SPLITTER_PRIVATE_DATA mConIn = {\r | |
36 | TEXT_IN_SPLITTER_PRIVATE_DATA_SIGNATURE,\r | |
37 | (EFI_HANDLE) NULL,\r | |
38 | {\r | |
39 | ConSplitterTextInReset,\r | |
40 | ConSplitterTextInReadKeyStroke,\r | |
41 | (EFI_EVENT) NULL\r | |
42 | },\r | |
43 | 0,\r | |
44 | (EFI_SIMPLE_TEXT_INPUT_PROTOCOL **) NULL,\r | |
45 | 0,\r | |
46 | {\r | |
47 | ConSplitterTextInResetEx,\r | |
48 | ConSplitterTextInReadKeyStrokeEx,\r | |
49 | (EFI_EVENT) NULL,\r | |
50 | ConSplitterTextInSetState,\r | |
51 | ConSplitterTextInRegisterKeyNotify,\r | |
52 | ConSplitterTextInUnregisterKeyNotify\r | |
53 | },\r | |
54 | 0,\r | |
55 | (EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL **) NULL,\r | |
56 | 0,\r | |
57 | {\r | |
58 | (LIST_ENTRY *) NULL,\r | |
59 | (LIST_ENTRY *) NULL\r | |
60 | },\r | |
61 | \r | |
62 | {\r | |
63 | ConSplitterSimplePointerReset,\r | |
64 | ConSplitterSimplePointerGetState,\r | |
65 | (EFI_EVENT) NULL,\r | |
66 | (EFI_SIMPLE_POINTER_MODE *) NULL\r | |
67 | },\r | |
68 | {\r | |
69 | 0x10000,\r | |
70 | 0x10000,\r | |
71 | 0x10000,\r | |
72 | TRUE,\r | |
73 | TRUE\r | |
74 | },\r | |
75 | 0,\r | |
76 | (EFI_SIMPLE_POINTER_PROTOCOL **) NULL,\r | |
77 | 0,\r | |
78 | \r | |
79 | {\r | |
80 | ConSplitterAbsolutePointerReset,\r | |
81 | ConSplitterAbsolutePointerGetState,\r | |
82 | (EFI_EVENT) NULL,\r | |
83 | (EFI_ABSOLUTE_POINTER_MODE *) NULL\r | |
84 | },\r | |
85 | \r | |
86 | {\r | |
87 | 0, // AbsoluteMinX\r | |
88 | 0, // AbsoluteMinY\r | |
89 | 0, // AbsoluteMinZ\r | |
90 | 0x10000, // AbsoluteMaxX\r | |
91 | 0x10000, // AbsoluteMaxY\r | |
92 | 0x10000, // AbsoluteMaxZ\r | |
93 | 0 // Attributes\r | |
94 | },\r | |
95 | 0,\r | |
96 | (EFI_ABSOLUTE_POINTER_PROTOCOL **) NULL,\r | |
97 | 0,\r | |
98 | FALSE,\r | |
99 | \r | |
100 | FALSE,\r | |
101 | {\r | |
102 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\r | |
103 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\r | |
104 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\r | |
105 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0\r | |
106 | },\r | |
107 | 0,\r | |
108 | {\r | |
109 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\r | |
110 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\r | |
111 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\r | |
112 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0\r | |
113 | },\r | |
114 | (EFI_EVENT) NULL,\r | |
115 | \r | |
116 | FALSE,\r | |
117 | FALSE\r | |
118 | };\r | |
119 | \r | |
120 | \r | |
121 | //\r | |
122 | // Uga Draw Protocol Private Data template\r | |
123 | //\r | |
124 | GLOBAL_REMOVE_IF_UNREFERENCED EFI_UGA_DRAW_PROTOCOL mUgaDrawProtocolTemplate = {\r | |
125 | ConSpliterUgaDrawGetMode,\r | |
126 | ConSpliterUgaDrawSetMode,\r | |
127 | ConSpliterUgaDrawBlt\r | |
128 | };\r | |
129 | \r | |
130 | //\r | |
131 | // Graphics Output Protocol Private Data template\r | |
132 | //\r | |
133 | GLOBAL_REMOVE_IF_UNREFERENCED EFI_GRAPHICS_OUTPUT_PROTOCOL mGraphicsOutputProtocolTemplate = {\r | |
134 | ConSpliterGraphicsOutputQueryMode,\r | |
135 | ConSpliterGraphicsOutputSetMode,\r | |
136 | ConSpliterGraphicsOutputBlt,\r | |
137 | NULL\r | |
138 | };\r | |
139 | \r | |
140 | \r | |
141 | //\r | |
142 | // Text Out Splitter Private Data template\r | |
143 | //\r | |
144 | GLOBAL_REMOVE_IF_UNREFERENCED TEXT_OUT_SPLITTER_PRIVATE_DATA mConOut = {\r | |
145 | TEXT_OUT_SPLITTER_PRIVATE_DATA_SIGNATURE,\r | |
146 | (EFI_HANDLE) NULL,\r | |
147 | {\r | |
148 | ConSplitterTextOutReset,\r | |
149 | ConSplitterTextOutOutputString,\r | |
150 | ConSplitterTextOutTestString,\r | |
151 | ConSplitterTextOutQueryMode,\r | |
152 | ConSplitterTextOutSetMode,\r | |
153 | ConSplitterTextOutSetAttribute,\r | |
154 | ConSplitterTextOutClearScreen,\r | |
155 | ConSplitterTextOutSetCursorPosition,\r | |
156 | ConSplitterTextOutEnableCursor,\r | |
157 | (EFI_SIMPLE_TEXT_OUTPUT_MODE *) NULL\r | |
158 | },\r | |
159 | {\r | |
160 | 1,\r | |
161 | 0,\r | |
162 | 0,\r | |
163 | 0,\r | |
164 | 0,\r | |
165 | FALSE,\r | |
166 | },\r | |
167 | {\r | |
168 | NULL,\r | |
169 | NULL,\r | |
170 | NULL\r | |
171 | },\r | |
172 | 0,\r | |
173 | 0,\r | |
174 | 0,\r | |
175 | 0,\r | |
176 | (EFI_UGA_PIXEL *) NULL,\r | |
177 | {\r | |
178 | NULL,\r | |
179 | NULL,\r | |
180 | NULL,\r | |
181 | NULL\r | |
182 | },\r | |
183 | (EFI_GRAPHICS_OUTPUT_BLT_PIXEL *) NULL,\r | |
184 | (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *) NULL,\r | |
185 | 0,\r | |
186 | 0,\r | |
187 | TRUE,\r | |
188 | {\r | |
189 | ConSpliterConsoleControlGetMode,\r | |
190 | ConSpliterConsoleControlSetMode,\r | |
191 | ConSpliterConsoleControlLockStdIn\r | |
192 | },\r | |
193 | \r | |
194 | 0,\r | |
195 | (TEXT_OUT_AND_GOP_DATA *) NULL,\r | |
196 | 0,\r | |
197 | (TEXT_OUT_SPLITTER_QUERY_DATA *) NULL,\r | |
198 | 0,\r | |
199 | (INT32 *) NULL,\r | |
200 | \r | |
201 | EfiConsoleControlScreenText,\r | |
202 | 0,\r | |
203 | 0,\r | |
204 | (CHAR16 *) NULL,\r | |
205 | (INT32 *) NULL\r | |
206 | };\r | |
207 | \r | |
208 | //\r | |
209 | // Standard Error Text Out Splitter Data Template\r | |
210 | //\r | |
211 | GLOBAL_REMOVE_IF_UNREFERENCED TEXT_OUT_SPLITTER_PRIVATE_DATA mStdErr = {\r | |
212 | TEXT_OUT_SPLITTER_PRIVATE_DATA_SIGNATURE,\r | |
213 | (EFI_HANDLE) NULL,\r | |
214 | {\r | |
215 | ConSplitterTextOutReset,\r | |
216 | ConSplitterTextOutOutputString,\r | |
217 | ConSplitterTextOutTestString,\r | |
218 | ConSplitterTextOutQueryMode,\r | |
219 | ConSplitterTextOutSetMode,\r | |
220 | ConSplitterTextOutSetAttribute,\r | |
221 | ConSplitterTextOutClearScreen,\r | |
222 | ConSplitterTextOutSetCursorPosition,\r | |
223 | ConSplitterTextOutEnableCursor,\r | |
224 | (EFI_SIMPLE_TEXT_OUTPUT_MODE *) NULL\r | |
225 | },\r | |
226 | {\r | |
227 | 1,\r | |
228 | 0,\r | |
229 | 0,\r | |
230 | 0,\r | |
231 | 0,\r | |
232 | FALSE,\r | |
233 | },\r | |
234 | {\r | |
235 | NULL,\r | |
236 | NULL,\r | |
237 | NULL\r | |
238 | },\r | |
239 | 0,\r | |
240 | 0,\r | |
241 | 0,\r | |
242 | 0,\r | |
243 | (EFI_UGA_PIXEL *) NULL,\r | |
244 | {\r | |
245 | NULL,\r | |
246 | NULL,\r | |
247 | NULL,\r | |
248 | NULL\r | |
249 | },\r | |
250 | (EFI_GRAPHICS_OUTPUT_BLT_PIXEL *) NULL,\r | |
251 | (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *) NULL,\r | |
252 | 0,\r | |
253 | 0,\r | |
254 | TRUE,\r | |
255 | {\r | |
256 | ConSpliterConsoleControlGetMode,\r | |
257 | ConSpliterConsoleControlSetMode,\r | |
258 | ConSpliterConsoleControlLockStdIn\r | |
259 | },\r | |
260 | \r | |
261 | 0,\r | |
262 | (TEXT_OUT_AND_GOP_DATA *) NULL,\r | |
263 | 0,\r | |
264 | (TEXT_OUT_SPLITTER_QUERY_DATA *) NULL,\r | |
265 | 0,\r | |
266 | (INT32 *) NULL,\r | |
267 | \r | |
268 | EfiConsoleControlScreenText,\r | |
269 | 0,\r | |
270 | 0,\r | |
271 | (CHAR16 *) NULL,\r | |
272 | (INT32 *) NULL\r | |
273 | };\r | |
274 | \r | |
275 | //\r | |
276 | // Driver binding instance for Console Input Device\r | |
277 | //\r | |
278 | EFI_DRIVER_BINDING_PROTOCOL gConSplitterConInDriverBinding = {\r | |
279 | ConSplitterConInDriverBindingSupported,\r | |
280 | ConSplitterConInDriverBindingStart,\r | |
281 | ConSplitterConInDriverBindingStop,\r | |
282 | 0xa,\r | |
283 | NULL,\r | |
284 | NULL\r | |
285 | };\r | |
286 | \r | |
287 | //\r | |
288 | // Driver binding instance for Console Out device\r | |
289 | //\r | |
290 | EFI_DRIVER_BINDING_PROTOCOL gConSplitterConOutDriverBinding = {\r | |
291 | ConSplitterConOutDriverBindingSupported,\r | |
292 | ConSplitterConOutDriverBindingStart,\r | |
293 | ConSplitterConOutDriverBindingStop,\r | |
294 | 0xa,\r | |
295 | NULL,\r | |
296 | NULL\r | |
297 | };\r | |
298 | \r | |
299 | //\r | |
300 | // Driver binding instance for Standard Error device\r | |
301 | //\r | |
302 | EFI_DRIVER_BINDING_PROTOCOL gConSplitterStdErrDriverBinding = {\r | |
303 | ConSplitterStdErrDriverBindingSupported,\r | |
304 | ConSplitterStdErrDriverBindingStart,\r | |
305 | ConSplitterStdErrDriverBindingStop,\r | |
306 | 0xa,\r | |
307 | NULL,\r | |
308 | NULL\r | |
309 | };\r | |
310 | \r | |
311 | //\r | |
312 | // Driver binding instance for Simple Pointer protocol\r | |
313 | //\r | |
314 | EFI_DRIVER_BINDING_PROTOCOL gConSplitterSimplePointerDriverBinding = {\r | |
315 | ConSplitterSimplePointerDriverBindingSupported,\r | |
316 | ConSplitterSimplePointerDriverBindingStart,\r | |
317 | ConSplitterSimplePointerDriverBindingStop,\r | |
318 | 0xa,\r | |
319 | NULL,\r | |
320 | NULL\r | |
321 | };\r | |
322 | \r | |
323 | //\r | |
324 | // Driver binding instance for Absolute Pointer protocol\r | |
325 | //\r | |
326 | EFI_DRIVER_BINDING_PROTOCOL gConSplitterAbsolutePointerDriverBinding = {\r | |
327 | ConSplitterAbsolutePointerDriverBindingSupported,\r | |
328 | ConSplitterAbsolutePointerDriverBindingStart,\r | |
329 | ConSplitterAbsolutePointerDriverBindingStop,\r | |
330 | 0xa,\r | |
331 | NULL,\r | |
332 | NULL\r | |
333 | };\r | |
334 | \r | |
335 | /**\r | |
336 | The Entry Point for module ConSplitter. The user code starts with this function.\r | |
337 | \r | |
338 | Installs driver module protocols and. Creates virtual device handles for ConIn,\r | |
339 | ConOut, and StdErr. Installs Simple Text In protocol, Simple Text In Ex protocol,\r | |
340 | Simple Pointer protocol, Absolute Pointer protocol on those virtual handlers.\r | |
341 | Installs Graphics Output protocol and/or UGA Draw protocol if needed.\r | |
342 | \r | |
343 | @param[in] ImageHandle The firmware allocated handle for the EFI image.\r | |
344 | @param[in] SystemTable A pointer to the EFI System Table.\r | |
345 | \r | |
346 | @retval EFI_SUCCESS The entry point is executed successfully.\r | |
347 | @retval other Some error occurs when executing this entry point.\r | |
348 | \r | |
349 | **/\r | |
350 | EFI_STATUS\r | |
351 | EFIAPI\r | |
352 | ConSplitterDriverEntry(\r | |
353 | IN EFI_HANDLE ImageHandle,\r | |
354 | IN EFI_SYSTEM_TABLE *SystemTable\r | |
355 | )\r | |
356 | {\r | |
357 | EFI_STATUS Status;\r | |
358 | \r | |
359 | //\r | |
360 | // Install driver model protocol(s).\r | |
361 | //\r | |
362 | Status = EfiLibInstallDriverBindingComponentName2 (\r | |
363 | ImageHandle,\r | |
364 | SystemTable,\r | |
365 | &gConSplitterConInDriverBinding,\r | |
366 | ImageHandle,\r | |
367 | &gConSplitterConInComponentName,\r | |
368 | &gConSplitterConInComponentName2\r | |
369 | );\r | |
370 | ASSERT_EFI_ERROR (Status);\r | |
371 | \r | |
372 | Status = EfiLibInstallDriverBindingComponentName2 (\r | |
373 | ImageHandle,\r | |
374 | SystemTable,\r | |
375 | &gConSplitterSimplePointerDriverBinding,\r | |
376 | NULL,\r | |
377 | &gConSplitterSimplePointerComponentName,\r | |
378 | &gConSplitterSimplePointerComponentName2\r | |
379 | );\r | |
380 | ASSERT_EFI_ERROR (Status);\r | |
381 | \r | |
382 | Status = EfiLibInstallDriverBindingComponentName2 (\r | |
383 | ImageHandle,\r | |
384 | SystemTable,\r | |
385 | &gConSplitterAbsolutePointerDriverBinding,\r | |
386 | NULL,\r | |
387 | &gConSplitterAbsolutePointerComponentName,\r | |
388 | &gConSplitterAbsolutePointerComponentName2\r | |
389 | );\r | |
390 | ASSERT_EFI_ERROR (Status);\r | |
391 | \r | |
392 | Status = EfiLibInstallDriverBindingComponentName2 (\r | |
393 | ImageHandle,\r | |
394 | SystemTable,\r | |
395 | &gConSplitterConOutDriverBinding,\r | |
396 | NULL,\r | |
397 | &gConSplitterConOutComponentName,\r | |
398 | &gConSplitterConOutComponentName2\r | |
399 | );\r | |
400 | ASSERT_EFI_ERROR (Status);\r | |
401 | \r | |
402 | Status = EfiLibInstallDriverBindingComponentName2 (\r | |
403 | ImageHandle,\r | |
404 | SystemTable,\r | |
405 | &gConSplitterStdErrDriverBinding,\r | |
406 | NULL,\r | |
407 | &gConSplitterStdErrComponentName,\r | |
408 | &gConSplitterStdErrComponentName2\r | |
409 | );\r | |
410 | ASSERT_EFI_ERROR (Status);\r | |
411 | \r | |
412 | //\r | |
413 | // Either Graphics Output protocol or UGA Draw protocol must be supported.\r | |
414 | //\r | |
415 | ASSERT (FeaturePcdGet (PcdConOutGopSupport) ||\r | |
416 | FeaturePcdGet (PcdConOutUgaSupport));\r | |
417 | \r | |
418 | //\r | |
419 | // The driver creates virtual handles for ConIn, ConOut, and StdErr.\r | |
420 | // The virtual handles will always exist even if no console exist in the\r | |
421 | // system. This is need to support hotplug devices like USB.\r | |
422 | //\r | |
423 | //\r | |
424 | // Create virtual device handle for StdErr Splitter\r | |
425 | //\r | |
426 | Status = ConSplitterTextOutConstructor (&mStdErr);\r | |
427 | if (!EFI_ERROR (Status)) {\r | |
428 | Status = gBS->InstallMultipleProtocolInterfaces (\r | |
429 | &mStdErr.VirtualHandle,\r | |
430 | &gEfiSimpleTextOutProtocolGuid,\r | |
431 | &mStdErr.TextOut,\r | |
432 | NULL\r | |
433 | );\r | |
434 | }\r | |
435 | //\r | |
436 | // Create virtual device handle for ConIn Splitter\r | |
437 | //\r | |
438 | Status = ConSplitterTextInConstructor (&mConIn);\r | |
439 | if (!EFI_ERROR (Status)) {\r | |
440 | Status = gBS->InstallMultipleProtocolInterfaces (\r | |
441 | &mConIn.VirtualHandle,\r | |
442 | &gEfiSimpleTextInProtocolGuid,\r | |
443 | &mConIn.TextIn,\r | |
444 | &gEfiSimpleTextInputExProtocolGuid,\r | |
445 | &mConIn.TextInEx,\r | |
446 | &gEfiSimplePointerProtocolGuid,\r | |
447 | &mConIn.SimplePointer,\r | |
448 | &gEfiAbsolutePointerProtocolGuid,\r | |
449 | &mConIn.AbsolutePointer,\r | |
450 | NULL\r | |
451 | );\r | |
452 | if (!EFI_ERROR (Status)) {\r | |
453 | //\r | |
454 | // Update the EFI System Table with new virtual console\r | |
455 | // and update the pointer to Simple Text Input protocol.\r | |
456 | //\r | |
457 | gST->ConsoleInHandle = mConIn.VirtualHandle;\r | |
458 | gST->ConIn = &mConIn.TextIn;\r | |
459 | }\r | |
460 | }\r | |
461 | //\r | |
462 | // Create virtual device handle for ConOut Splitter\r | |
463 | //\r | |
464 | Status = ConSplitterTextOutConstructor (&mConOut);\r | |
465 | if (!EFI_ERROR (Status)) {\r | |
466 | if (!FeaturePcdGet (PcdConOutGopSupport)) {\r | |
467 | //\r | |
468 | // If Graphics Outpurt protocol not supported, UGA Draw protocol is installed\r | |
469 | // on the virtual handle.\r | |
470 | //\r | |
471 | Status = gBS->InstallMultipleProtocolInterfaces (\r | |
472 | &mConOut.VirtualHandle,\r | |
473 | &gEfiSimpleTextOutProtocolGuid,\r | |
474 | &mConOut.TextOut,\r | |
475 | &gEfiUgaDrawProtocolGuid,\r | |
476 | &mConOut.UgaDraw,\r | |
477 | &gEfiConsoleControlProtocolGuid,\r | |
478 | &mConOut.ConsoleControl,\r | |
479 | NULL\r | |
480 | );\r | |
481 | } else if (!FeaturePcdGet (PcdConOutUgaSupport)) {\r | |
482 | //\r | |
483 | // If UGA Draw protocol not supported, Graphics Output Protocol is installed\r | |
484 | // on virtual handle.\r | |
485 | //\r | |
486 | Status = gBS->InstallMultipleProtocolInterfaces (\r | |
487 | &mConOut.VirtualHandle,\r | |
488 | &gEfiSimpleTextOutProtocolGuid,\r | |
489 | &mConOut.TextOut,\r | |
490 | &gEfiGraphicsOutputProtocolGuid,\r | |
491 | &mConOut.GraphicsOutput,\r | |
492 | &gEfiConsoleControlProtocolGuid,\r | |
493 | &mConOut.ConsoleControl,\r | |
494 | NULL\r | |
495 | );\r | |
496 | } else {\r | |
497 | //\r | |
498 | // Boot Graphics Output protocol and UGA Draw protocol are supported,\r | |
499 | // both they will be installed on virtual handle.\r | |
500 | //\r | |
501 | Status = gBS->InstallMultipleProtocolInterfaces (\r | |
502 | &mConOut.VirtualHandle,\r | |
503 | &gEfiSimpleTextOutProtocolGuid,\r | |
504 | &mConOut.TextOut,\r | |
505 | &gEfiGraphicsOutputProtocolGuid,\r | |
506 | &mConOut.GraphicsOutput,\r | |
507 | &gEfiUgaDrawProtocolGuid,\r | |
508 | &mConOut.UgaDraw,\r | |
509 | &gEfiConsoleControlProtocolGuid,\r | |
510 | &mConOut.ConsoleControl,\r | |
511 | NULL\r | |
512 | );\r | |
513 | }\r | |
514 | \r | |
515 | if (!EFI_ERROR (Status)) {\r | |
516 | //\r | |
517 | // Update the EFI System Table with new virtual console\r | |
518 | // and Update the pointer to Text Output protocol.\r | |
519 | //\r | |
520 | gST->ConsoleOutHandle = mConOut.VirtualHandle;\r | |
521 | gST->ConOut = &mConOut.TextOut;\r | |
522 | }\r | |
523 | \r | |
524 | }\r | |
525 | //\r | |
526 | // Update the CRC32 in the EFI System Table header\r | |
527 | //\r | |
528 | gST->Hdr.CRC32 = 0;\r | |
529 | gBS->CalculateCrc32 (\r | |
530 | (UINT8 *) &gST->Hdr,\r | |
531 | gST->Hdr.HeaderSize,\r | |
532 | &gST->Hdr.CRC32\r | |
533 | );\r | |
534 | \r | |
535 | return EFI_SUCCESS;\r | |
536 | \r | |
537 | }\r | |
538 | \r | |
539 | /**\r | |
540 | Construct console input devices' private data.\r | |
541 | \r | |
542 | @param ConInPrivate A pointer to the TEXT_IN_SPLITTER_PRIVATE_DATA\r | |
543 | structure.\r | |
544 | \r | |
545 | @retval EFI_OUT_OF_RESOURCES Out of resources.\r | |
546 | @retval EFI_SUCCESS Text Input Devcie's private data has been constructed.\r | |
547 | @retval other Failed to construct private data.\r | |
548 | \r | |
549 | **/\r | |
550 | EFI_STATUS\r | |
551 | ConSplitterTextInConstructor (\r | |
552 | TEXT_IN_SPLITTER_PRIVATE_DATA *ConInPrivate\r | |
553 | )\r | |
554 | {\r | |
555 | EFI_STATUS Status;\r | |
556 | \r | |
557 | //\r | |
558 | // Allocate buffer for Simple Text Input device\r | |
559 | //\r | |
560 | Status = ConSplitterGrowBuffer (\r | |
561 | sizeof (EFI_SIMPLE_TEXT_INPUT_PROTOCOL *),\r | |
562 | &ConInPrivate->TextInListCount,\r | |
563 | (VOID **) &ConInPrivate->TextInList\r | |
564 | );\r | |
565 | if (EFI_ERROR (Status)) {\r | |
566 | return EFI_OUT_OF_RESOURCES;\r | |
567 | }\r | |
568 | //\r | |
569 | // Create Event to support locking StdIn Device\r | |
570 | //\r | |
571 | Status = gBS->CreateEvent (\r | |
572 | EVT_TIMER | EVT_NOTIFY_SIGNAL,\r | |
573 | TPL_CALLBACK,\r | |
574 | ConSpliterConsoleControlLockStdInEvent,\r | |
575 | NULL,\r | |
576 | &ConInPrivate->LockEvent\r | |
577 | );\r | |
578 | ASSERT_EFI_ERROR (Status);\r | |
579 | //\r | |
580 | // Create Event to wait for a key\r | |
581 | //\r | |
582 | Status = gBS->CreateEvent (\r | |
583 | EVT_NOTIFY_WAIT,\r | |
584 | TPL_NOTIFY,\r | |
585 | ConSplitterTextInWaitForKey,\r | |
586 | ConInPrivate,\r | |
587 | &ConInPrivate->TextIn.WaitForKey\r | |
588 | );\r | |
589 | ASSERT_EFI_ERROR (Status);\r | |
590 | \r | |
591 | //\r | |
592 | // Allocate buffer for Simple Text Input Ex device\r | |
593 | //\r | |
594 | Status = ConSplitterGrowBuffer (\r | |
595 | sizeof (EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *),\r | |
596 | &ConInPrivate->TextInExListCount,\r | |
597 | (VOID **) &ConInPrivate->TextInExList\r | |
598 | );\r | |
599 | if (EFI_ERROR (Status)) {\r | |
600 | return EFI_OUT_OF_RESOURCES;\r | |
601 | }\r | |
602 | //\r | |
603 | // Create Event to wait for a key Ex\r | |
604 | //\r | |
605 | Status = gBS->CreateEvent (\r | |
606 | EVT_NOTIFY_WAIT,\r | |
607 | TPL_NOTIFY,\r | |
608 | ConSplitterTextInWaitForKey,\r | |
609 | ConInPrivate,\r | |
610 | &ConInPrivate->TextInEx.WaitForKeyEx\r | |
611 | );\r | |
612 | ASSERT_EFI_ERROR (Status);\r | |
613 | \r | |
614 | InitializeListHead (&ConInPrivate->NotifyList);\r | |
615 | \r | |
616 | ConInPrivate->AbsolutePointer.Mode = &ConInPrivate->AbsolutePointerMode;\r | |
617 | //\r | |
618 | // Allocate buffer for Absolute Pointer device\r | |
619 | //\r | |
620 | Status = ConSplitterGrowBuffer (\r | |
621 | sizeof (EFI_ABSOLUTE_POINTER_PROTOCOL *),\r | |
622 | &ConInPrivate->AbsolutePointerListCount,\r | |
623 | (VOID **) &ConInPrivate->AbsolutePointerList\r | |
624 | );\r | |
625 | if (EFI_ERROR (Status)) {\r | |
626 | return EFI_OUT_OF_RESOURCES;\r | |
627 | }\r | |
628 | //\r | |
629 | // Create Event to wait for device input for Absolute pointer device\r | |
630 | //\r | |
631 | Status = gBS->CreateEvent (\r | |
632 | EVT_NOTIFY_WAIT,\r | |
633 | TPL_NOTIFY,\r | |
634 | ConSplitterAbsolutePointerWaitForInput,\r | |
635 | ConInPrivate,\r | |
636 | &ConInPrivate->AbsolutePointer.WaitForInput\r | |
637 | );\r | |
638 | ASSERT_EFI_ERROR (Status);\r | |
639 | \r | |
640 | ConInPrivate->SimplePointer.Mode = &ConInPrivate->SimplePointerMode;\r | |
641 | //\r | |
642 | // Allocate buffer for Simple Pointer device\r | |
643 | //\r | |
644 | Status = ConSplitterGrowBuffer (\r | |
645 | sizeof (EFI_SIMPLE_POINTER_PROTOCOL *),\r | |
646 | &ConInPrivate->PointerListCount,\r | |
647 | (VOID **) &ConInPrivate->PointerList\r | |
648 | );\r | |
649 | if (EFI_ERROR (Status)) {\r | |
650 | return EFI_OUT_OF_RESOURCES;\r | |
651 | }\r | |
652 | //\r | |
653 | // Create Event to wait for device input for Simple pointer device\r | |
654 | //\r | |
655 | Status = gBS->CreateEvent (\r | |
656 | EVT_NOTIFY_WAIT,\r | |
657 | TPL_NOTIFY,\r | |
658 | ConSplitterSimplePointerWaitForInput,\r | |
659 | ConInPrivate,\r | |
660 | &ConInPrivate->SimplePointer.WaitForInput\r | |
661 | );\r | |
662 | \r | |
663 | return Status;\r | |
664 | }\r | |
665 | \r | |
666 | /**\r | |
667 | Construct console output devices' private data.\r | |
668 | \r | |
669 | @param ConOutPrivate A pointer to the TEXT_OUT_SPLITTER_PRIVATE_DATA\r | |
670 | structure.\r | |
671 | \r | |
672 | @retval EFI_OUT_OF_RESOURCES Out of resources.\r | |
673 | @retval EFI_SUCCESS Text Input Devcie's private data has been constructed.\r | |
674 | \r | |
675 | **/\r | |
676 | EFI_STATUS\r | |
677 | ConSplitterTextOutConstructor (\r | |
678 | TEXT_OUT_SPLITTER_PRIVATE_DATA *ConOutPrivate\r | |
679 | )\r | |
680 | {\r | |
681 | EFI_STATUS Status;\r | |
682 | EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Info;\r | |
683 | \r | |
684 | //\r | |
685 | // Copy protocols template\r | |
686 | //\r | |
687 | if (FeaturePcdGet (PcdConOutUgaSupport)) {\r | |
688 | CopyMem (&ConOutPrivate->UgaDraw, &mUgaDrawProtocolTemplate, sizeof (EFI_UGA_DRAW_PROTOCOL));\r | |
689 | }\r | |
690 | if (FeaturePcdGet (PcdConOutGopSupport)) {\r | |
691 | CopyMem (&ConOutPrivate->GraphicsOutput, &mGraphicsOutputProtocolTemplate, sizeof (EFI_GRAPHICS_OUTPUT_PROTOCOL));\r | |
692 | }\r | |
693 | \r | |
694 | //\r | |
695 | // Initilize console output splitter's private data.\r | |
696 | //\r | |
697 | ConOutPrivate->TextOut.Mode = &ConOutPrivate->TextOutMode;\r | |
698 | \r | |
699 | //\r | |
700 | // When new console device is added, the new mode will be set later,\r | |
701 | // so put current mode back to init state.\r | |
702 | //\r | |
703 | ConOutPrivate->TextOutMode.Mode = 0xFF;\r | |
704 | //\r | |
705 | // Allocate buffer for Console Out device\r | |
706 | //\r | |
707 | Status = ConSplitterGrowBuffer (\r | |
708 | sizeof (TEXT_OUT_AND_GOP_DATA),\r | |
709 | &ConOutPrivate->TextOutListCount,\r | |
710 | (VOID **) &ConOutPrivate->TextOutList\r | |
711 | );\r | |
712 | if (EFI_ERROR (Status)) {\r | |
713 | return EFI_OUT_OF_RESOURCES;\r | |
714 | }\r | |
715 | //\r | |
716 | // Allocate buffer for Text Out query data\r | |
717 | //\r | |
718 | Status = ConSplitterGrowBuffer (\r | |
719 | sizeof (TEXT_OUT_SPLITTER_QUERY_DATA),\r | |
720 | &ConOutPrivate->TextOutQueryDataCount,\r | |
721 | (VOID **) &ConOutPrivate->TextOutQueryData\r | |
722 | );\r | |
723 | if (EFI_ERROR (Status)) {\r | |
724 | return EFI_OUT_OF_RESOURCES;\r | |
725 | }\r | |
726 | \r | |
727 | //\r | |
728 | // Setup the DevNullTextOut console to 80 x 25\r | |
729 | //\r | |
730 | ConOutPrivate->TextOutQueryData[0].Columns = 80;\r | |
731 | ConOutPrivate->TextOutQueryData[0].Rows = 25;\r | |
732 | DevNullTextOutSetMode (ConOutPrivate, 0);\r | |
733 | \r | |
734 | if (FeaturePcdGet (PcdConOutUgaSupport)) {\r | |
735 | //\r | |
736 | // Setup the DevNullUgaDraw to 800 x 600 x 32 bits per pixel, 60Hz.\r | |
737 | //\r | |
738 | ConSpliterUgaDrawSetMode (&ConOutPrivate->UgaDraw, 800, 600, 32, 60);\r | |
739 | }\r | |
740 | if (FeaturePcdGet (PcdConOutGopSupport)) {\r | |
741 | //\r | |
742 | // Setup resource for mode information in Graphics Output Protocol interface\r | |
743 | //\r | |
744 | if ((ConOutPrivate->GraphicsOutput.Mode = AllocateZeroPool (sizeof (EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE))) == NULL) {\r | |
745 | return EFI_OUT_OF_RESOURCES;\r | |
746 | }\r | |
747 | if ((ConOutPrivate->GraphicsOutput.Mode->Info = AllocateZeroPool (sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION))) == NULL) {\r | |
748 | return EFI_OUT_OF_RESOURCES;\r | |
749 | }\r | |
750 | //\r | |
751 | // Setup the DevNullGraphicsOutput to 800 x 600 x 32 bits per pixel\r | |
752 | // DevNull will be updated to user-defined mode after driver has started.\r | |
753 | //\r | |
754 | if ((ConOutPrivate->GraphicsOutputModeBuffer = AllocateZeroPool (sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION))) == NULL) {\r | |
755 | return EFI_OUT_OF_RESOURCES;\r | |
756 | }\r | |
757 | Info = &ConOutPrivate->GraphicsOutputModeBuffer[0];\r | |
758 | Info->Version = 0;\r | |
759 | Info->HorizontalResolution = 800;\r | |
760 | Info->VerticalResolution = 600;\r | |
761 | Info->PixelFormat = PixelBltOnly;\r | |
762 | Info->PixelsPerScanLine = 800;\r | |
763 | CopyMem (ConOutPrivate->GraphicsOutput.Mode->Info, Info, sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION));\r | |
764 | ConOutPrivate->GraphicsOutput.Mode->SizeOfInfo = sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION);\r | |
765 | \r | |
766 | //\r | |
767 | // Initialize the following items, theset items remain unchanged in GraphicsOutput->SetMode()\r | |
768 | // GraphicsOutputMode->FrameBufferBase, GraphicsOutputMode->FrameBufferSize\r | |
769 | //\r | |
770 | ConOutPrivate->GraphicsOutput.Mode->FrameBufferBase = (EFI_PHYSICAL_ADDRESS) (UINTN) NULL;\r | |
771 | ConOutPrivate->GraphicsOutput.Mode->FrameBufferSize = 0;\r | |
772 | \r | |
773 | ConOutPrivate->GraphicsOutput.Mode->MaxMode = 1;\r | |
774 | //\r | |
775 | // Initial current mode to unknown state, and then set to mode 0\r | |
776 | //\r | |
777 | ConOutPrivate->GraphicsOutput.Mode->Mode = 0xffff;\r | |
778 | ConOutPrivate->GraphicsOutput.SetMode (&ConOutPrivate->GraphicsOutput, 0);\r | |
779 | }\r | |
780 | \r | |
781 | return EFI_SUCCESS;\r | |
782 | }\r | |
783 | \r | |
784 | \r | |
785 | /**\r | |
786 | Test to see if the specified protocol could be supported on the specified device.\r | |
787 | \r | |
788 | @param This Driver Binding protocol pointer.\r | |
789 | @param ControllerHandle Handle of device to test.\r | |
790 | @param Guid The specified protocol.\r | |
791 | \r | |
792 | @retval EFI_SUCCESS The specified protocol is supported on this device.\r | |
793 | @retval EFI_UNSUPPORTED The specified protocol attempts to be installed on virtul handle.\r | |
794 | @retval other Failed to open specified protocol on this device.\r | |
795 | \r | |
796 | **/\r | |
797 | EFI_STATUS\r | |
798 | ConSplitterSupported (\r | |
799 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r | |
800 | IN EFI_HANDLE ControllerHandle,\r | |
801 | IN EFI_GUID *Guid\r | |
802 | )\r | |
803 | {\r | |
804 | EFI_STATUS Status;\r | |
805 | VOID *Instance;\r | |
806 | \r | |
807 | //\r | |
808 | // Make sure the Console Splitter does not attempt to attach to itself\r | |
809 | //\r | |
810 | if (ControllerHandle == mConIn.VirtualHandle ||\r | |
811 | ControllerHandle == mConOut.VirtualHandle ||\r | |
812 | ControllerHandle == mStdErr.VirtualHandle\r | |
813 | ) {\r | |
814 | return EFI_UNSUPPORTED;\r | |
815 | }\r | |
816 | \r | |
817 | //\r | |
818 | // Check to see whether the specific protocol could be opened BY_DRIVER\r | |
819 | //\r | |
820 | Status = gBS->OpenProtocol (\r | |
821 | ControllerHandle,\r | |
822 | Guid,\r | |
823 | &Instance,\r | |
824 | This->DriverBindingHandle,\r | |
825 | ControllerHandle,\r | |
826 | EFI_OPEN_PROTOCOL_BY_DRIVER\r | |
827 | );\r | |
828 | \r | |
829 | if (EFI_ERROR (Status)) {\r | |
830 | return Status;\r | |
831 | }\r | |
832 | \r | |
833 | gBS->CloseProtocol (\r | |
834 | ControllerHandle,\r | |
835 | Guid,\r | |
836 | This->DriverBindingHandle,\r | |
837 | ControllerHandle\r | |
838 | );\r | |
839 | \r | |
840 | return EFI_SUCCESS;\r | |
841 | }\r | |
842 | \r | |
843 | /**\r | |
844 | Test to see if Console In Device could be supported on the Controller.\r | |
845 | \r | |
846 | @param This Driver Binding protocol instance pointer.\r | |
847 | @param ControllerHandle Handle of device to test.\r | |
848 | @param RemainingDevicePath Optional parameter use to pick a specific child\r | |
849 | device to start.\r | |
850 | \r | |
851 | @retval EFI_SUCCESS This driver supports this device.\r | |
852 | @retval other This driver does not support this device.\r | |
853 | \r | |
854 | **/\r | |
855 | EFI_STATUS\r | |
856 | EFIAPI\r | |
857 | ConSplitterConInDriverBindingSupported (\r | |
858 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r | |
859 | IN EFI_HANDLE ControllerHandle,\r | |
860 | IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r | |
861 | )\r | |
862 | {\r | |
863 | return ConSplitterSupported (\r | |
864 | This,\r | |
865 | ControllerHandle,\r | |
866 | &gEfiConsoleInDeviceGuid\r | |
867 | );\r | |
868 | }\r | |
869 | \r | |
870 | /**\r | |
871 | Test to see if Simple Pointer protocol could be supported on the Controller.\r | |
872 | \r | |
873 | @param This Driver Binding protocol instance pointer.\r | |
874 | @param ControllerHandle Handle of device to test.\r | |
875 | @param RemainingDevicePath Optional parameter use to pick a specific child\r | |
876 | device to start.\r | |
877 | \r | |
878 | @retval EFI_SUCCESS This driver supports this device.\r | |
879 | @retval other This driver does not support this device.\r | |
880 | \r | |
881 | **/\r | |
882 | EFI_STATUS\r | |
883 | EFIAPI\r | |
884 | ConSplitterSimplePointerDriverBindingSupported (\r | |
885 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r | |
886 | IN EFI_HANDLE ControllerHandle,\r | |
887 | IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r | |
888 | )\r | |
889 | {\r | |
890 | return ConSplitterSupported (\r | |
891 | This,\r | |
892 | ControllerHandle,\r | |
893 | &gEfiSimplePointerProtocolGuid\r | |
894 | );\r | |
895 | }\r | |
896 | \r | |
897 | /**\r | |
898 | Test to see if Absolute Pointer protocol could be supported on the Controller.\r | |
899 | \r | |
900 | @param This Driver Binding protocol instance pointer.\r | |
901 | @param ControllerHandle Handle of device to test.\r | |
902 | @param RemainingDevicePath Optional parameter use to pick a specific child\r | |
903 | device to start.\r | |
904 | \r | |
905 | @retval EFI_SUCCESS This driver supports this device.\r | |
906 | @retval other This driver does not support this device.\r | |
907 | \r | |
908 | **/\r | |
909 | EFI_STATUS\r | |
910 | EFIAPI\r | |
911 | ConSplitterAbsolutePointerDriverBindingSupported (\r | |
912 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r | |
913 | IN EFI_HANDLE ControllerHandle,\r | |
914 | IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r | |
915 | )\r | |
916 | {\r | |
917 | return ConSplitterSupported (\r | |
918 | This,\r | |
919 | ControllerHandle,\r | |
920 | &gEfiAbsolutePointerProtocolGuid\r | |
921 | );\r | |
922 | }\r | |
923 | \r | |
924 | \r | |
925 | /**\r | |
926 | Test to see if Console Out Device could be supported on the Controller.\r | |
927 | \r | |
928 | @param This Driver Binding protocol instance pointer.\r | |
929 | @param ControllerHandle Handle of device to test.\r | |
930 | @param RemainingDevicePath Optional parameter use to pick a specific child\r | |
931 | device to start.\r | |
932 | \r | |
933 | @retval EFI_SUCCESS This driver supports this device.\r | |
934 | @retval other This driver does not support this device.\r | |
935 | \r | |
936 | **/\r | |
937 | EFI_STATUS\r | |
938 | EFIAPI\r | |
939 | ConSplitterConOutDriverBindingSupported (\r | |
940 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r | |
941 | IN EFI_HANDLE ControllerHandle,\r | |
942 | IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r | |
943 | )\r | |
944 | {\r | |
945 | return ConSplitterSupported (\r | |
946 | This,\r | |
947 | ControllerHandle,\r | |
948 | &gEfiConsoleOutDeviceGuid\r | |
949 | );\r | |
950 | }\r | |
951 | \r | |
952 | /**\r | |
953 | Test to see if Standard Error Device could be supported on the Controller.\r | |
954 | \r | |
955 | @param This Driver Binding protocol instance pointer.\r | |
956 | @param ControllerHandle Handle of device to test.\r | |
957 | @param RemainingDevicePath Optional parameter use to pick a specific child\r | |
958 | device to start.\r | |
959 | \r | |
960 | @retval EFI_SUCCESS This driver supports this device.\r | |
961 | @retval other This driver does not support this device.\r | |
962 | \r | |
963 | **/\r | |
964 | EFI_STATUS\r | |
965 | EFIAPI\r | |
966 | ConSplitterStdErrDriverBindingSupported (\r | |
967 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r | |
968 | IN EFI_HANDLE ControllerHandle,\r | |
969 | IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r | |
970 | )\r | |
971 | {\r | |
972 | return ConSplitterSupported (\r | |
973 | This,\r | |
974 | ControllerHandle,\r | |
975 | &gEfiStandardErrorDeviceGuid\r | |
976 | );\r | |
977 | }\r | |
978 | \r | |
979 | \r | |
980 | /**\r | |
981 | Start ConSplitter on devcie handle by opening Console Device Guid on device handle\r | |
982 | and the console virtual handle. And Get the console interface on controller handle.\r | |
983 | \r | |
984 | @param This Driver Binding protocol instance pointer.\r | |
985 | @param ControllerHandle Handle of device.\r | |
986 | @param ConSplitterVirtualHandle Console virtual Handle.\r | |
987 | @param DeviceGuid The specified Console Device, such as ConInDev,\r | |
988 | ConOutDev.\r | |
989 | @param InterfaceGuid The specified protocol to be opened.\r | |
990 | @param Interface Protocol interface returned.\r | |
991 | \r | |
992 | @retval EFI_SUCCESS This driver supports this device.\r | |
993 | @retval other Failed to open the specified Console Device Guid\r | |
994 | or specified protocol.\r | |
995 | \r | |
996 | **/\r | |
997 | EFI_STATUS\r | |
998 | ConSplitterStart (\r | |
999 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r | |
1000 | IN EFI_HANDLE ControllerHandle,\r | |
1001 | IN EFI_HANDLE ConSplitterVirtualHandle,\r | |
1002 | IN EFI_GUID *DeviceGuid,\r | |
1003 | IN EFI_GUID *InterfaceGuid,\r | |
1004 | OUT VOID **Interface\r | |
1005 | )\r | |
1006 | {\r | |
1007 | EFI_STATUS Status;\r | |
1008 | VOID *Instance;\r | |
1009 | \r | |
1010 | //\r | |
1011 | // Check to see whether the ControllerHandle has the DeviceGuid on it.\r | |
1012 | //\r | |
1013 | Status = gBS->OpenProtocol (\r | |
1014 | ControllerHandle,\r | |
1015 | DeviceGuid,\r | |
1016 | &Instance,\r | |
1017 | This->DriverBindingHandle,\r | |
1018 | ControllerHandle,\r | |
1019 | EFI_OPEN_PROTOCOL_BY_DRIVER\r | |
1020 | );\r | |
1021 | if (EFI_ERROR (Status)) {\r | |
1022 | return Status;\r | |
1023 | }\r | |
1024 | \r | |
1025 | //\r | |
1026 | // Create virtual handle and open DeviceGuid on the virtul handle.\r | |
1027 | //\r | |
1028 | Status = gBS->OpenProtocol (\r | |
1029 | ControllerHandle,\r | |
1030 | DeviceGuid,\r | |
1031 | &Instance,\r | |
1032 | This->DriverBindingHandle,\r | |
1033 | ConSplitterVirtualHandle,\r | |
1034 | EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER\r | |
1035 | );\r | |
1036 | if (EFI_ERROR (Status)) {\r | |
1037 | goto Err;\r | |
1038 | }\r | |
1039 | \r | |
1040 | //\r | |
1041 | // Open InterfaceGuid on the virtul handle.\r | |
1042 | //\r | |
1043 | Status = gBS->OpenProtocol (\r | |
1044 | ControllerHandle,\r | |
1045 | InterfaceGuid,\r | |
1046 | Interface,\r | |
1047 | This->DriverBindingHandle,\r | |
1048 | ConSplitterVirtualHandle,\r | |
1049 | EFI_OPEN_PROTOCOL_GET_PROTOCOL\r | |
1050 | );\r | |
1051 | \r | |
1052 | if (!EFI_ERROR (Status)) {\r | |
1053 | return EFI_SUCCESS;\r | |
1054 | }\r | |
1055 | \r | |
1056 | //\r | |
1057 | // close the DeviceGuid on ConSplitter VirtualHandle.\r | |
1058 | //\r | |
1059 | gBS->CloseProtocol (\r | |
1060 | ControllerHandle,\r | |
1061 | DeviceGuid,\r | |
1062 | This->DriverBindingHandle,\r | |
1063 | ConSplitterVirtualHandle\r | |
1064 | );\r | |
1065 | \r | |
1066 | Err:\r | |
1067 | //\r | |
1068 | // close the DeviceGuid on ControllerHandle.\r | |
1069 | //\r | |
1070 | gBS->CloseProtocol (\r | |
1071 | ControllerHandle,\r | |
1072 | DeviceGuid,\r | |
1073 | This->DriverBindingHandle,\r | |
1074 | ControllerHandle\r | |
1075 | );\r | |
1076 | \r | |
1077 | return Status;\r | |
1078 | }\r | |
1079 | \r | |
1080 | \r | |
1081 | /**\r | |
1082 | Start Console In Consplitter on device handle.\r | |
1083 | \r | |
1084 | @param This Driver Binding protocol instance pointer.\r | |
1085 | @param ControllerHandle Handle of device to bind driver to.\r | |
1086 | @param RemainingDevicePath Optional parameter use to pick a specific child\r | |
1087 | device to start.\r | |
1088 | \r | |
1089 | @retval EFI_SUCCESS Console In Consplitter is added to ControllerHandle.\r | |
1090 | @retval other Console In Consplitter does not support this device.\r | |
1091 | \r | |
1092 | **/\r | |
1093 | EFI_STATUS\r | |
1094 | EFIAPI\r | |
1095 | ConSplitterConInDriverBindingStart (\r | |
1096 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r | |
1097 | IN EFI_HANDLE ControllerHandle,\r | |
1098 | IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r | |
1099 | )\r | |
1100 | {\r | |
1101 | EFI_STATUS Status;\r | |
1102 | EFI_SIMPLE_TEXT_INPUT_PROTOCOL *TextIn;\r | |
1103 | EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *TextInEx;\r | |
1104 | \r | |
1105 | //\r | |
1106 | // Start ConSplitter on ControllerHandle, and create the virtual\r | |
1107 | // agrogated console device on first call Start for a SimpleTextIn handle.\r | |
1108 | //\r | |
1109 | Status = ConSplitterStart (\r | |
1110 | This,\r | |
1111 | ControllerHandle,\r | |
1112 | mConIn.VirtualHandle,\r | |
1113 | &gEfiConsoleInDeviceGuid,\r | |
1114 | &gEfiSimpleTextInProtocolGuid,\r | |
1115 | (VOID **) &TextIn\r | |
1116 | );\r | |
1117 | if (EFI_ERROR (Status)) {\r | |
1118 | return Status;\r | |
1119 | }\r | |
1120 | \r | |
1121 | //\r | |
1122 | // Add this device into Text In devices list.\r | |
1123 | //\r | |
1124 | Status = ConSplitterTextInAddDevice (&mConIn, TextIn);\r | |
1125 | if (EFI_ERROR (Status)) {\r | |
1126 | return Status;\r | |
1127 | }\r | |
1128 | \r | |
1129 | Status = gBS->OpenProtocol (\r | |
1130 | ControllerHandle,\r | |
1131 | &gEfiSimpleTextInputExProtocolGuid,\r | |
1132 | (VOID **) &TextInEx,\r | |
1133 | This->DriverBindingHandle,\r | |
1134 | mConIn.VirtualHandle,\r | |
1135 | EFI_OPEN_PROTOCOL_GET_PROTOCOL\r | |
1136 | );\r | |
1137 | if (!EFI_ERROR (Status)) {\r | |
1138 | //\r | |
1139 | // If Simple Text Input Ex protocol exists,\r | |
1140 | // add this device into Text In Ex devices list.\r | |
1141 | //\r | |
1142 | Status = ConSplitterTextInExAddDevice (&mConIn, TextInEx);\r | |
1143 | }\r | |
1144 | \r | |
1145 | return Status;\r | |
1146 | }\r | |
1147 | \r | |
1148 | \r | |
1149 | /**\r | |
1150 | Start Simple Pointer Consplitter on device handle.\r | |
1151 | \r | |
1152 | @param This Driver Binding protocol instance pointer.\r | |
1153 | @param ControllerHandle Handle of device to bind driver to.\r | |
1154 | @param RemainingDevicePath Optional parameter use to pick a specific child\r | |
1155 | device to start.\r | |
1156 | \r | |
1157 | @retval EFI_SUCCESS Simple Pointer Consplitter is added to ControllerHandle.\r | |
1158 | @retval other Simple Pointer Consplitter does not support this device.\r | |
1159 | \r | |
1160 | **/\r | |
1161 | EFI_STATUS\r | |
1162 | EFIAPI\r | |
1163 | ConSplitterSimplePointerDriverBindingStart (\r | |
1164 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r | |
1165 | IN EFI_HANDLE ControllerHandle,\r | |
1166 | IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r | |
1167 | )\r | |
1168 | {\r | |
1169 | EFI_STATUS Status;\r | |
1170 | EFI_SIMPLE_POINTER_PROTOCOL *SimplePointer;\r | |
1171 | \r | |
1172 | //\r | |
1173 | // Start ConSplitter on ControllerHandle, and create the virtual\r | |
1174 | // agrogated console device on first call Start for a SimplePointer handle.\r | |
1175 | //\r | |
1176 | Status = ConSplitterStart (\r | |
1177 | This,\r | |
1178 | ControllerHandle,\r | |
1179 | mConIn.VirtualHandle,\r | |
1180 | &gEfiSimplePointerProtocolGuid,\r | |
1181 | &gEfiSimplePointerProtocolGuid,\r | |
1182 | (VOID **) &SimplePointer\r | |
1183 | );\r | |
1184 | if (EFI_ERROR (Status)) {\r | |
1185 | return Status;\r | |
1186 | }\r | |
1187 | \r | |
1188 | //\r | |
1189 | // Add this devcie into Simple Pointer devices list.\r | |
1190 | //\r | |
1191 | return ConSplitterSimplePointerAddDevice (&mConIn, SimplePointer);\r | |
1192 | }\r | |
1193 | \r | |
1194 | \r | |
1195 | /**\r | |
1196 | Start Absolute Pointer Consplitter on device handle.\r | |
1197 | \r | |
1198 | @param This Driver Binding protocol instance pointer.\r | |
1199 | @param ControllerHandle Handle of device to bind driver to.\r | |
1200 | @param RemainingDevicePath Optional parameter use to pick a specific child\r | |
1201 | device to start.\r | |
1202 | \r | |
1203 | @retval EFI_SUCCESS Absolute Pointer Consplitter is added to ControllerHandle.\r | |
1204 | @retval other Absolute Pointer Consplitter does not support this device.\r | |
1205 | \r | |
1206 | **/\r | |
1207 | EFI_STATUS\r | |
1208 | EFIAPI\r | |
1209 | ConSplitterAbsolutePointerDriverBindingStart (\r | |
1210 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r | |
1211 | IN EFI_HANDLE ControllerHandle,\r | |
1212 | IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r | |
1213 | )\r | |
1214 | {\r | |
1215 | EFI_STATUS Status;\r | |
1216 | EFI_ABSOLUTE_POINTER_PROTOCOL *AbsolutePointer;\r | |
1217 | \r | |
1218 | //\r | |
1219 | // Start ConSplitter on ControllerHandle, and create the virtual\r | |
1220 | // agrogated console device on first call Start for a AbsolutePointer handle.\r | |
1221 | //\r | |
1222 | Status = ConSplitterStart (\r | |
1223 | This,\r | |
1224 | ControllerHandle,\r | |
1225 | mConIn.VirtualHandle,\r | |
1226 | &gEfiAbsolutePointerProtocolGuid,\r | |
1227 | &gEfiAbsolutePointerProtocolGuid,\r | |
1228 | (VOID **) &AbsolutePointer\r | |
1229 | );\r | |
1230 | \r | |
1231 | if (EFI_ERROR (Status)) {\r | |
1232 | return Status;\r | |
1233 | }\r | |
1234 | \r | |
1235 | //\r | |
1236 | // Add this devcie into Absolute Pointer devices list.\r | |
1237 | //\r | |
1238 | return ConSplitterAbsolutePointerAddDevice (&mConIn, AbsolutePointer);\r | |
1239 | }\r | |
1240 | \r | |
1241 | \r | |
1242 | /**\r | |
1243 | Start Console Out Consplitter on device handle.\r | |
1244 | \r | |
1245 | @param This Driver Binding protocol instance pointer.\r | |
1246 | @param ControllerHandle Handle of device to bind driver to.\r | |
1247 | @param RemainingDevicePath Optional parameter use to pick a specific child\r | |
1248 | device to start.\r | |
1249 | \r | |
1250 | @retval EFI_SUCCESS Console Out Consplitter is added to ControllerHandle.\r | |
1251 | @retval other Console Out Consplitter does not support this device.\r | |
1252 | \r | |
1253 | **/\r | |
1254 | EFI_STATUS\r | |
1255 | EFIAPI\r | |
1256 | ConSplitterConOutDriverBindingStart (\r | |
1257 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r | |
1258 | IN EFI_HANDLE ControllerHandle,\r | |
1259 | IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r | |
1260 | )\r | |
1261 | {\r | |
1262 | EFI_STATUS Status;\r | |
1263 | EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *TextOut;\r | |
1264 | EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;\r | |
1265 | EFI_UGA_DRAW_PROTOCOL *UgaDraw;\r | |
1266 | UINTN SizeOfInfo;\r | |
1267 | EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Info;\r | |
1268 | \r | |
1269 | //\r | |
1270 | // Start ConSplitter on ControllerHandle, and create the virtual\r | |
1271 | // agrogated console device on first call Start for a ConsoleOut handle.\r | |
1272 | //\r | |
1273 | Status = ConSplitterStart (\r | |
1274 | This,\r | |
1275 | ControllerHandle,\r | |
1276 | mConOut.VirtualHandle,\r | |
1277 | &gEfiConsoleOutDeviceGuid,\r | |
1278 | &gEfiSimpleTextOutProtocolGuid,\r | |
1279 | (VOID **) &TextOut\r | |
1280 | );\r | |
1281 | if (EFI_ERROR (Status)) {\r | |
1282 | return Status;\r | |
1283 | }\r | |
1284 | \r | |
1285 | GraphicsOutput = NULL;\r | |
1286 | UgaDraw = NULL;\r | |
1287 | //\r | |
1288 | // Try to Open Graphics Output protocol\r | |
1289 | //\r | |
1290 | Status = gBS->OpenProtocol (\r | |
1291 | ControllerHandle,\r | |
1292 | &gEfiGraphicsOutputProtocolGuid,\r | |
1293 | (VOID **) &GraphicsOutput,\r | |
1294 | This->DriverBindingHandle,\r | |
1295 | mConOut.VirtualHandle,\r | |
1296 | EFI_OPEN_PROTOCOL_GET_PROTOCOL\r | |
1297 | );\r | |
1298 | \r | |
1299 | if (EFI_ERROR (Status) && FeaturePcdGet (PcdUgaConsumeSupport)) {\r | |
1300 | //\r | |
1301 | // Open UGA DRAW protocol\r | |
1302 | //\r | |
1303 | gBS->OpenProtocol (\r | |
1304 | ControllerHandle,\r | |
1305 | &gEfiUgaDrawProtocolGuid,\r | |
1306 | (VOID **) &UgaDraw,\r | |
1307 | This->DriverBindingHandle,\r | |
1308 | mConOut.VirtualHandle,\r | |
1309 | EFI_OPEN_PROTOCOL_GET_PROTOCOL\r | |
1310 | );\r | |
1311 | }\r | |
1312 | \r | |
1313 | //\r | |
1314 | // When new console device is added, the new mode will be set later,\r | |
1315 | // so put current mode back to init state.\r | |
1316 | //\r | |
1317 | mConOut.TextOutMode.Mode = 0xFF;\r | |
1318 | \r | |
1319 | //\r | |
1320 | // If both ConOut and StdErr incorporate the same Text Out device,\r | |
1321 | // their MaxMode and QueryData should be the intersection of both.\r | |
1322 | //\r | |
1323 | Status = ConSplitterTextOutAddDevice (&mConOut, TextOut, GraphicsOutput, UgaDraw);\r | |
1324 | ConSplitterTextOutSetAttribute (&mConOut.TextOut, EFI_TEXT_ATTR (EFI_LIGHTGRAY, EFI_BLACK));\r | |
1325 | \r | |
1326 | if (FeaturePcdGet (PcdConOutUgaSupport)) {\r | |
1327 | //\r | |
1328 | // Get the UGA mode data of ConOut from the current mode\r | |
1329 | //\r | |
1330 | if (GraphicsOutput != NULL) {\r | |
1331 | Status = GraphicsOutput->QueryMode (GraphicsOutput, GraphicsOutput->Mode->Mode, &SizeOfInfo, &Info);\r | |
1332 | if (EFI_ERROR (Status)) {\r | |
1333 | return Status;\r | |
1334 | }\r | |
1335 | ASSERT ( SizeOfInfo <= sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION));\r | |
1336 | \r | |
1337 | mConOut.UgaHorizontalResolution = Info->HorizontalResolution;\r | |
1338 | mConOut.UgaVerticalResolution = Info->VerticalResolution;\r | |
1339 | mConOut.UgaColorDepth = 32;\r | |
1340 | mConOut.UgaRefreshRate = 60;\r | |
1341 | \r | |
1342 | FreePool (Info);\r | |
1343 | \r | |
1344 | } else if (UgaDraw != NULL && FeaturePcdGet (PcdUgaConsumeSupport)) {\r | |
1345 | Status = UgaDraw->GetMode (\r | |
1346 | UgaDraw,\r | |
1347 | &mConOut.UgaHorizontalResolution,\r | |
1348 | &mConOut.UgaVerticalResolution,\r | |
1349 | &mConOut.UgaColorDepth,\r | |
1350 | &mConOut.UgaRefreshRate\r | |
1351 | );\r | |
1352 | }\r | |
1353 | }\r | |
1354 | \r | |
1355 | return Status;\r | |
1356 | }\r | |
1357 | \r | |
1358 | \r | |
1359 | /**\r | |
1360 | Start Standard Error Consplitter on device handle.\r | |
1361 | \r | |
1362 | @param This Driver Binding protocol instance pointer.\r | |
1363 | @param ControllerHandle Handle of device to bind driver to.\r | |
1364 | @param RemainingDevicePath Optional parameter use to pick a specific child\r | |
1365 | device to start.\r | |
1366 | \r | |
1367 | @retval EFI_SUCCESS Standard Error Consplitter is added to ControllerHandle.\r | |
1368 | @retval other Standard Error Consplitter does not support this device.\r | |
1369 | \r | |
1370 | **/\r | |
1371 | EFI_STATUS\r | |
1372 | EFIAPI\r | |
1373 | ConSplitterStdErrDriverBindingStart (\r | |
1374 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r | |
1375 | IN EFI_HANDLE ControllerHandle,\r | |
1376 | IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r | |
1377 | )\r | |
1378 | {\r | |
1379 | EFI_STATUS Status;\r | |
1380 | EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *TextOut;\r | |
1381 | \r | |
1382 | //\r | |
1383 | // Start ConSplitter on ControllerHandle, and create the virtual\r | |
1384 | // agrogated console device on first call Start for a StandardError handle.\r | |
1385 | //\r | |
1386 | Status = ConSplitterStart (\r | |
1387 | This,\r | |
1388 | ControllerHandle,\r | |
1389 | mStdErr.VirtualHandle,\r | |
1390 | &gEfiStandardErrorDeviceGuid,\r | |
1391 | &gEfiSimpleTextOutProtocolGuid,\r | |
1392 | (VOID **) &TextOut\r | |
1393 | );\r | |
1394 | if (EFI_ERROR (Status)) {\r | |
1395 | return Status;\r | |
1396 | }\r | |
1397 | \r | |
1398 | //\r | |
1399 | // When new console device is added, the new mode will be set later,\r | |
1400 | // so put current mode back to init state.\r | |
1401 | //\r | |
1402 | mStdErr.TextOutMode.Mode = 0xFF;\r | |
1403 | \r | |
1404 | //\r | |
1405 | // If both ConOut and StdErr incorporate the same Text Out device,\r | |
1406 | // their MaxMode and QueryData should be the intersection of both.\r | |
1407 | //\r | |
1408 | Status = ConSplitterTextOutAddDevice (&mStdErr, TextOut, NULL, NULL);\r | |
1409 | ConSplitterTextOutSetAttribute (&mStdErr.TextOut, EFI_TEXT_ATTR (EFI_MAGENTA, EFI_BLACK));\r | |
1410 | if (EFI_ERROR (Status)) {\r | |
1411 | return Status;\r | |
1412 | }\r | |
1413 | \r | |
1414 | if (mStdErr.CurrentNumberOfConsoles == 1) {\r | |
1415 | gST->StandardErrorHandle = mStdErr.VirtualHandle;\r | |
1416 | gST->StdErr = &mStdErr.TextOut;\r | |
1417 | //\r | |
1418 | // Update the CRC32 in the EFI System Table header\r | |
1419 | //\r | |
1420 | gST->Hdr.CRC32 = 0;\r | |
1421 | gBS->CalculateCrc32 (\r | |
1422 | (UINT8 *) &gST->Hdr,\r | |
1423 | gST->Hdr.HeaderSize,\r | |
1424 | &gST->Hdr.CRC32\r | |
1425 | );\r | |
1426 | }\r | |
1427 | \r | |
1428 | return Status;\r | |
1429 | }\r | |
1430 | \r | |
1431 | \r | |
1432 | /**\r | |
1433 | Stop ConSplitter on device handle by closing Console Device Guid on device handle\r | |
1434 | and the console virtual handle.\r | |
1435 | \r | |
1436 | @param This Protocol instance pointer.\r | |
1437 | @param ControllerHandle Handle of device.\r | |
1438 | @param ConSplitterVirtualHandle Console virtual Handle.\r | |
1439 | @param DeviceGuid The specified Console Device, such as ConInDev,\r | |
1440 | ConOutDev.\r | |
1441 | @param InterfaceGuid The specified protocol to be opened.\r | |
1442 | @param Interface Protocol interface returned.\r | |
1443 | \r | |
1444 | @retval EFI_SUCCESS Stop ConSplitter on ControllerHandle successfully.\r | |
1445 | @retval other Failed to Stop ConSplitter on ControllerHandle.\r | |
1446 | \r | |
1447 | **/\r | |
1448 | EFI_STATUS\r | |
1449 | ConSplitterStop (\r | |
1450 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r | |
1451 | IN EFI_HANDLE ControllerHandle,\r | |
1452 | IN EFI_HANDLE ConSplitterVirtualHandle,\r | |
1453 | IN EFI_GUID *DeviceGuid,\r | |
1454 | IN EFI_GUID *InterfaceGuid,\r | |
1455 | IN VOID **Interface\r | |
1456 | )\r | |
1457 | {\r | |
1458 | EFI_STATUS Status;\r | |
1459 | \r | |
1460 | Status = gBS->OpenProtocol (\r | |
1461 | ControllerHandle,\r | |
1462 | InterfaceGuid,\r | |
1463 | Interface,\r | |
1464 | This->DriverBindingHandle,\r | |
1465 | ControllerHandle,\r | |
1466 | EFI_OPEN_PROTOCOL_GET_PROTOCOL\r | |
1467 | );\r | |
1468 | if (EFI_ERROR (Status)) {\r | |
1469 | return Status;\r | |
1470 | }\r | |
1471 | //\r | |
1472 | // close the protocol refered.\r | |
1473 | //\r | |
1474 | gBS->CloseProtocol (\r | |
1475 | ControllerHandle,\r | |
1476 | DeviceGuid,\r | |
1477 | This->DriverBindingHandle,\r | |
1478 | ConSplitterVirtualHandle\r | |
1479 | );\r | |
1480 | \r | |
1481 | gBS->CloseProtocol (\r | |
1482 | ControllerHandle,\r | |
1483 | DeviceGuid,\r | |
1484 | This->DriverBindingHandle,\r | |
1485 | ControllerHandle\r | |
1486 | );\r | |
1487 | \r | |
1488 | return EFI_SUCCESS;\r | |
1489 | }\r | |
1490 | \r | |
1491 | \r | |
1492 | /**\r | |
1493 | Stop Console In ConSplitter on ControllerHandle by closing Console In Devcice GUID.\r | |
1494 | \r | |
1495 | @param This Driver Binding protocol instance pointer.\r | |
1496 | @param ControllerHandle Handle of device to stop driver on\r | |
1497 | @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of\r | |
1498 | children is zero stop the entire bus driver.\r | |
1499 | @param ChildHandleBuffer List of Child Handles to Stop.\r | |
1500 | \r | |
1501 | @retval EFI_SUCCESS This driver is removed ControllerHandle\r | |
1502 | @retval other This driver was not removed from this device\r | |
1503 | \r | |
1504 | **/\r | |
1505 | EFI_STATUS\r | |
1506 | EFIAPI\r | |
1507 | ConSplitterConInDriverBindingStop (\r | |
1508 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r | |
1509 | IN EFI_HANDLE ControllerHandle,\r | |
1510 | IN UINTN NumberOfChildren,\r | |
1511 | IN EFI_HANDLE *ChildHandleBuffer\r | |
1512 | )\r | |
1513 | {\r | |
1514 | EFI_STATUS Status;\r | |
1515 | EFI_SIMPLE_TEXT_INPUT_PROTOCOL *TextIn;\r | |
1516 | EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *TextInEx;\r | |
1517 | \r | |
1518 | if (NumberOfChildren == 0) {\r | |
1519 | return EFI_SUCCESS;\r | |
1520 | }\r | |
1521 | \r | |
1522 | Status = gBS->OpenProtocol (\r | |
1523 | ControllerHandle,\r | |
1524 | &gEfiSimpleTextInputExProtocolGuid,\r | |
1525 | (VOID **) &TextInEx,\r | |
1526 | This->DriverBindingHandle,\r | |
1527 | ControllerHandle,\r | |
1528 | EFI_OPEN_PROTOCOL_GET_PROTOCOL\r | |
1529 | );\r | |
1530 | if (!EFI_ERROR (Status)) {\r | |
1531 | //\r | |
1532 | // If Simple Text Input Ex protocol exists,\r | |
1533 | // remove device from Text Input Ex devices list.\r | |
1534 | //\r | |
1535 | Status = ConSplitterTextInExDeleteDevice (&mConIn, TextInEx);\r | |
1536 | if (EFI_ERROR (Status)) {\r | |
1537 | return Status;\r | |
1538 | }\r | |
1539 | }\r | |
1540 | \r | |
1541 | //\r | |
1542 | // Close Simple Text In protocol on controller handle and virtual handle.\r | |
1543 | //\r | |
1544 | Status = ConSplitterStop (\r | |
1545 | This,\r | |
1546 | ControllerHandle,\r | |
1547 | mConIn.VirtualHandle,\r | |
1548 | &gEfiConsoleInDeviceGuid,\r | |
1549 | &gEfiSimpleTextInProtocolGuid,\r | |
1550 | (VOID **) &TextIn\r | |
1551 | );\r | |
1552 | if (EFI_ERROR (Status)) {\r | |
1553 | return Status;\r | |
1554 | }\r | |
1555 | \r | |
1556 | //\r | |
1557 | // Remove device from Text Input devices list.\r | |
1558 | //\r | |
1559 | return ConSplitterTextInDeleteDevice (&mConIn, TextIn);\r | |
1560 | }\r | |
1561 | \r | |
1562 | \r | |
1563 | /**\r | |
1564 | Stop Simple Pointer protocol ConSplitter on ControllerHandle by closing\r | |
1565 | Simple Pointer protocol.\r | |
1566 | \r | |
1567 | @param This Driver Binding protocol instance pointer.\r | |
1568 | @param ControllerHandle Handle of device to stop driver on\r | |
1569 | @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of\r | |
1570 | children is zero stop the entire bus driver.\r | |
1571 | @param ChildHandleBuffer List of Child Handles to Stop.\r | |
1572 | \r | |
1573 | @retval EFI_SUCCESS This driver is removed ControllerHandle\r | |
1574 | @retval other This driver was not removed from this device\r | |
1575 | \r | |
1576 | **/\r | |
1577 | EFI_STATUS\r | |
1578 | EFIAPI\r | |
1579 | ConSplitterSimplePointerDriverBindingStop (\r | |
1580 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r | |
1581 | IN EFI_HANDLE ControllerHandle,\r | |
1582 | IN UINTN NumberOfChildren,\r | |
1583 | IN EFI_HANDLE *ChildHandleBuffer\r | |
1584 | )\r | |
1585 | {\r | |
1586 | EFI_STATUS Status;\r | |
1587 | EFI_SIMPLE_POINTER_PROTOCOL *SimplePointer;\r | |
1588 | \r | |
1589 | if (NumberOfChildren == 0) {\r | |
1590 | return EFI_SUCCESS;\r | |
1591 | }\r | |
1592 | \r | |
1593 | //\r | |
1594 | // Close Simple Pointer protocol on controller handle and virtual handle.\r | |
1595 | //\r | |
1596 | Status = ConSplitterStop (\r | |
1597 | This,\r | |
1598 | ControllerHandle,\r | |
1599 | mConIn.VirtualHandle,\r | |
1600 | &gEfiSimplePointerProtocolGuid,\r | |
1601 | &gEfiSimplePointerProtocolGuid,\r | |
1602 | (VOID **) &SimplePointer\r | |
1603 | );\r | |
1604 | if (EFI_ERROR (Status)) {\r | |
1605 | return Status;\r | |
1606 | }\r | |
1607 | \r | |
1608 | //\r | |
1609 | // Remove this device from Simple Pointer device list.\r | |
1610 | //\r | |
1611 | return ConSplitterSimplePointerDeleteDevice (&mConIn, SimplePointer);\r | |
1612 | }\r | |
1613 | \r | |
1614 | \r | |
1615 | /**\r | |
1616 | Stop Absolute Pointer protocol ConSplitter on ControllerHandle by closing\r | |
1617 | Absolute Pointer protocol.\r | |
1618 | \r | |
1619 | @param This Driver Binding protocol instance pointer.\r | |
1620 | @param ControllerHandle Handle of device to stop driver on\r | |
1621 | @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of\r | |
1622 | children is zero stop the entire bus driver.\r | |
1623 | @param ChildHandleBuffer List of Child Handles to Stop.\r | |
1624 | \r | |
1625 | @retval EFI_SUCCESS This driver is removed ControllerHandle\r | |
1626 | @retval other This driver was not removed from this device\r | |
1627 | \r | |
1628 | **/\r | |
1629 | EFI_STATUS\r | |
1630 | EFIAPI\r | |
1631 | ConSplitterAbsolutePointerDriverBindingStop (\r | |
1632 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r | |
1633 | IN EFI_HANDLE ControllerHandle,\r | |
1634 | IN UINTN NumberOfChildren,\r | |
1635 | IN EFI_HANDLE *ChildHandleBuffer\r | |
1636 | )\r | |
1637 | {\r | |
1638 | EFI_STATUS Status;\r | |
1639 | EFI_ABSOLUTE_POINTER_PROTOCOL *AbsolutePointer;\r | |
1640 | \r | |
1641 | if (NumberOfChildren == 0) {\r | |
1642 | return EFI_SUCCESS;\r | |
1643 | }\r | |
1644 | \r | |
1645 | //\r | |
1646 | // Close Absolute Pointer protocol on controller handle and virtual handle.\r | |
1647 | //\r | |
1648 | Status = ConSplitterStop (\r | |
1649 | This,\r | |
1650 | ControllerHandle,\r | |
1651 | mConIn.VirtualHandle,\r | |
1652 | &gEfiAbsolutePointerProtocolGuid,\r | |
1653 | &gEfiAbsolutePointerProtocolGuid,\r | |
1654 | (VOID **) &AbsolutePointer\r | |
1655 | );\r | |
1656 | if (EFI_ERROR (Status)) {\r | |
1657 | return Status;\r | |
1658 | }\r | |
1659 | \r | |
1660 | //\r | |
1661 | // Remove this device from Absolute Pointer device list.\r | |
1662 | //\r | |
1663 | return ConSplitterAbsolutePointerDeleteDevice (&mConIn, AbsolutePointer);\r | |
1664 | }\r | |
1665 | \r | |
1666 | \r | |
1667 | /**\r | |
1668 | Stop Console Out ConSplitter on device handle by closing Console Out Devcice GUID.\r | |
1669 | \r | |
1670 | @param This Driver Binding protocol instance pointer.\r | |
1671 | @param ControllerHandle Handle of device to stop driver on\r | |
1672 | @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of\r | |
1673 | children is zero stop the entire bus driver.\r | |
1674 | @param ChildHandleBuffer List of Child Handles to Stop.\r | |
1675 | \r | |
1676 | @retval EFI_SUCCESS This driver is removed ControllerHandle\r | |
1677 | @retval other This driver was not removed from this device\r | |
1678 | \r | |
1679 | **/\r | |
1680 | EFI_STATUS\r | |
1681 | EFIAPI\r | |
1682 | ConSplitterConOutDriverBindingStop (\r | |
1683 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r | |
1684 | IN EFI_HANDLE ControllerHandle,\r | |
1685 | IN UINTN NumberOfChildren,\r | |
1686 | IN EFI_HANDLE *ChildHandleBuffer\r | |
1687 | )\r | |
1688 | {\r | |
1689 | EFI_STATUS Status;\r | |
1690 | EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *TextOut;\r | |
1691 | \r | |
1692 | if (NumberOfChildren == 0) {\r | |
1693 | return EFI_SUCCESS;\r | |
1694 | }\r | |
1695 | \r | |
1696 | //\r | |
1697 | // Close Absolute Pointer protocol on controller handle and virtual handle.\r | |
1698 | //\r | |
1699 | Status = ConSplitterStop (\r | |
1700 | This,\r | |
1701 | ControllerHandle,\r | |
1702 | mConOut.VirtualHandle,\r | |
1703 | &gEfiConsoleOutDeviceGuid,\r | |
1704 | &gEfiSimpleTextOutProtocolGuid,\r | |
1705 | (VOID **) &TextOut\r | |
1706 | );\r | |
1707 | if (EFI_ERROR (Status)) {\r | |
1708 | return Status;\r | |
1709 | }\r | |
1710 | \r | |
1711 | //\r | |
1712 | // Remove this device from Text Out device list.\r | |
1713 | //\r | |
1714 | return ConSplitterTextOutDeleteDevice (&mConOut, TextOut);\r | |
1715 | }\r | |
1716 | \r | |
1717 | \r | |
1718 | /**\r | |
1719 | Stop Standard Error ConSplitter on ControllerHandle by closing Standard Error GUID.\r | |
1720 | \r | |
1721 | @param This Driver Binding protocol instance pointer.\r | |
1722 | @param ControllerHandle Handle of device to stop driver on\r | |
1723 | @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of\r | |
1724 | children is zero stop the entire bus driver.\r | |
1725 | @param ChildHandleBuffer List of Child Handles to Stop.\r | |
1726 | \r | |
1727 | @retval EFI_SUCCESS This driver is removed ControllerHandle\r | |
1728 | @retval other This driver was not removed from this device\r | |
1729 | \r | |
1730 | **/\r | |
1731 | EFI_STATUS\r | |
1732 | EFIAPI\r | |
1733 | ConSplitterStdErrDriverBindingStop (\r | |
1734 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r | |
1735 | IN EFI_HANDLE ControllerHandle,\r | |
1736 | IN UINTN NumberOfChildren,\r | |
1737 | IN EFI_HANDLE *ChildHandleBuffer\r | |
1738 | )\r | |
1739 | {\r | |
1740 | EFI_STATUS Status;\r | |
1741 | EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *TextOut;\r | |
1742 | \r | |
1743 | if (NumberOfChildren == 0) {\r | |
1744 | return EFI_SUCCESS;\r | |
1745 | }\r | |
1746 | \r | |
1747 | //\r | |
1748 | // Close Standard Error Device on controller handle and virtual handle.\r | |
1749 | //\r | |
1750 | Status = ConSplitterStop (\r | |
1751 | This,\r | |
1752 | ControllerHandle,\r | |
1753 | mStdErr.VirtualHandle,\r | |
1754 | &gEfiStandardErrorDeviceGuid,\r | |
1755 | &gEfiSimpleTextOutProtocolGuid,\r | |
1756 | (VOID **) &TextOut\r | |
1757 | );\r | |
1758 | if (EFI_ERROR (Status)) {\r | |
1759 | return Status;\r | |
1760 | }\r | |
1761 | //\r | |
1762 | // Delete this console error out device's data structures.\r | |
1763 | //\r | |
1764 | Status = ConSplitterTextOutDeleteDevice (&mStdErr, TextOut);\r | |
1765 | if (EFI_ERROR (Status)) {\r | |
1766 | return Status;\r | |
1767 | }\r | |
1768 | \r | |
1769 | if (mStdErr.CurrentNumberOfConsoles == 0) {\r | |
1770 | gST->StandardErrorHandle = NULL;\r | |
1771 | gST->StdErr = NULL;\r | |
1772 | //\r | |
1773 | // Update the CRC32 in the EFI System Table header\r | |
1774 | //\r | |
1775 | gST->Hdr.CRC32 = 0;\r | |
1776 | gBS->CalculateCrc32 (\r | |
1777 | (UINT8 *) &gST->Hdr,\r | |
1778 | gST->Hdr.HeaderSize,\r | |
1779 | &gST->Hdr.CRC32\r | |
1780 | );\r | |
1781 | }\r | |
1782 | \r | |
1783 | return Status;\r | |
1784 | }\r | |
1785 | \r | |
1786 | \r | |
1787 | /**\r | |
1788 | Take the passed in Buffer of size SizeOfCount and grow the buffer\r | |
1789 | by MAX (CONSOLE_SPLITTER_CONSOLES_ALLOC_UNIT, MaxGrow) * SizeOfCount\r | |
1790 | bytes. Copy the current data in Buffer to the new version of Buffer\r | |
1791 | and free the old version of buffer.\r | |
1792 | \r | |
1793 | @param SizeOfCount Size of element in array.\r | |
1794 | @param Count Current number of elements in array.\r | |
1795 | @param Buffer Bigger version of passed in Buffer with all the\r | |
1796 | data.\r | |
1797 | \r | |
1798 | @retval EFI_SUCCESS Buffer size has grown.\r | |
1799 | @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.\r | |
1800 | \r | |
1801 | **/\r | |
1802 | EFI_STATUS\r | |
1803 | ConSplitterGrowBuffer (\r | |
1804 | IN UINTN SizeOfCount,\r | |
1805 | IN UINTN *Count,\r | |
1806 | IN OUT VOID **Buffer\r | |
1807 | )\r | |
1808 | {\r | |
1809 | VOID *Ptr;\r | |
1810 | \r | |
1811 | //\r | |
1812 | // grow the buffer to new buffer size,\r | |
1813 | // copy the old buffer's content to the new-size buffer,\r | |
1814 | // then free the old buffer.\r | |
1815 | //\r | |
1816 | *Count += CONSOLE_SPLITTER_CONSOLES_ALLOC_UNIT;\r | |
1817 | Ptr = ReallocatePool (\r | |
1818 | SizeOfCount * ((*Count) - CONSOLE_SPLITTER_CONSOLES_ALLOC_UNIT),\r | |
1819 | SizeOfCount * (*Count),\r | |
1820 | *Buffer\r | |
1821 | );\r | |
1822 | if (Ptr == NULL) {\r | |
1823 | return EFI_OUT_OF_RESOURCES;\r | |
1824 | }\r | |
1825 | *Buffer = Ptr;\r | |
1826 | return EFI_SUCCESS;\r | |
1827 | }\r | |
1828 | \r | |
1829 | \r | |
1830 | /**\r | |
1831 | Add Text Input Device in Consplitter Text Input list.\r | |
1832 | \r | |
1833 | @param Private Text In Splitter pointer.\r | |
1834 | @param TextIn Simple Text Input protocol pointer.\r | |
1835 | \r | |
1836 | @retval EFI_SUCCESS Text Input Device added successfully.\r | |
1837 | @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.\r | |
1838 | \r | |
1839 | **/\r | |
1840 | EFI_STATUS\r | |
1841 | ConSplitterTextInAddDevice (\r | |
1842 | IN TEXT_IN_SPLITTER_PRIVATE_DATA *Private,\r | |
1843 | IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *TextIn\r | |
1844 | )\r | |
1845 | {\r | |
1846 | EFI_STATUS Status;\r | |
1847 | \r | |
1848 | //\r | |
1849 | // If the Text In List is full, enlarge it by calling ConSplitterGrowBuffer().\r | |
1850 | //\r | |
1851 | if (Private->CurrentNumberOfConsoles >= Private->TextInListCount) {\r | |
1852 | Status = ConSplitterGrowBuffer (\r | |
1853 | sizeof (EFI_SIMPLE_TEXT_INPUT_PROTOCOL *),\r | |
1854 | &Private->TextInListCount,\r | |
1855 | (VOID **) &Private->TextInList\r | |
1856 | );\r | |
1857 | if (EFI_ERROR (Status)) {\r | |
1858 | return EFI_OUT_OF_RESOURCES;\r | |
1859 | }\r | |
1860 | }\r | |
1861 | //\r | |
1862 | // Add the new text-in device data structure into the Text In List.\r | |
1863 | //\r | |
1864 | Private->TextInList[Private->CurrentNumberOfConsoles] = TextIn;\r | |
1865 | Private->CurrentNumberOfConsoles++;\r | |
1866 | \r | |
1867 | //\r | |
1868 | // Extra CheckEvent added to reduce the double CheckEvent().\r | |
1869 | //\r | |
1870 | gBS->CheckEvent (TextIn->WaitForKey);\r | |
1871 | \r | |
1872 | return EFI_SUCCESS;\r | |
1873 | }\r | |
1874 | \r | |
1875 | \r | |
1876 | /**\r | |
1877 | Remove Text Input Device from Consplitter Text Input list.\r | |
1878 | \r | |
1879 | @param Private Text In Splitter pointer.\r | |
1880 | @param TextIn Simple Text protocol pointer.\r | |
1881 | \r | |
1882 | @retval EFI_SUCCESS Simple Text Device removed successfully.\r | |
1883 | @retval EFI_NOT_FOUND No Simple Text Device found.\r | |
1884 | \r | |
1885 | **/\r | |
1886 | EFI_STATUS\r | |
1887 | ConSplitterTextInDeleteDevice (\r | |
1888 | IN TEXT_IN_SPLITTER_PRIVATE_DATA *Private,\r | |
1889 | IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *TextIn\r | |
1890 | )\r | |
1891 | {\r | |
1892 | UINTN Index;\r | |
1893 | //\r | |
1894 | // Remove the specified text-in device data structure from the Text In List,\r | |
1895 | // and rearrange the remaining data structures in the Text In List.\r | |
1896 | //\r | |
1897 | for (Index = 0; Index < Private->CurrentNumberOfConsoles; Index++) {\r | |
1898 | if (Private->TextInList[Index] == TextIn) {\r | |
1899 | for (Index = Index; Index < Private->CurrentNumberOfConsoles - 1; Index++) {\r | |
1900 | Private->TextInList[Index] = Private->TextInList[Index + 1];\r | |
1901 | }\r | |
1902 | \r | |
1903 | Private->CurrentNumberOfConsoles--;\r | |
1904 | return EFI_SUCCESS;\r | |
1905 | }\r | |
1906 | }\r | |
1907 | \r | |
1908 | return EFI_NOT_FOUND;\r | |
1909 | }\r | |
1910 | \r | |
1911 | /**\r | |
1912 | Add Text Input Ex Device in Consplitter Text Input Ex list.\r | |
1913 | \r | |
1914 | @param Private Text In Splitter pointer.\r | |
1915 | @param TextInEx Simple Text Input Ex Input protocol pointer.\r | |
1916 | \r | |
1917 | @retval EFI_SUCCESS Text Input Ex Device added successfully.\r | |
1918 | @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.\r | |
1919 | \r | |
1920 | **/\r | |
1921 | EFI_STATUS\r | |
1922 | ConSplitterTextInExAddDevice (\r | |
1923 | IN TEXT_IN_SPLITTER_PRIVATE_DATA *Private,\r | |
1924 | IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *TextInEx\r | |
1925 | )\r | |
1926 | {\r | |
1927 | EFI_STATUS Status;\r | |
1928 | \r | |
1929 | //\r | |
1930 | // If the Text Input Ex List is full, enlarge it by calling ConSplitterGrowBuffer().\r | |
1931 | //\r | |
1932 | if (Private->CurrentNumberOfExConsoles >= Private->TextInExListCount) {\r | |
1933 | Status = ConSplitterGrowBuffer (\r | |
1934 | sizeof (EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *),\r | |
1935 | &Private->TextInExListCount,\r | |
1936 | (VOID **) &Private->TextInExList\r | |
1937 | );\r | |
1938 | if (EFI_ERROR (Status)) {\r | |
1939 | return EFI_OUT_OF_RESOURCES;\r | |
1940 | }\r | |
1941 | }\r | |
1942 | //\r | |
1943 | // Add the new text-in device data structure into the Text Input Ex List.\r | |
1944 | //\r | |
1945 | Private->TextInExList[Private->CurrentNumberOfExConsoles] = TextInEx;\r | |
1946 | Private->CurrentNumberOfExConsoles++;\r | |
1947 | \r | |
1948 | //\r | |
1949 | // Extra CheckEvent added to reduce the double CheckEvent().\r | |
1950 | //\r | |
1951 | gBS->CheckEvent (TextInEx->WaitForKeyEx);\r | |
1952 | \r | |
1953 | return EFI_SUCCESS;\r | |
1954 | }\r | |
1955 | \r | |
1956 | /**\r | |
1957 | Remove Text Ex Device from Consplitter Text Input Ex list.\r | |
1958 | \r | |
1959 | @param Private Text In Splitter pointer.\r | |
1960 | @param TextInEx Simple Text Ex protocol pointer.\r | |
1961 | \r | |
1962 | @retval EFI_SUCCESS Simple Text Input Ex Device removed successfully.\r | |
1963 | @retval EFI_NOT_FOUND No Simple Text Input Ex Device found.\r | |
1964 | \r | |
1965 | **/\r | |
1966 | EFI_STATUS\r | |
1967 | ConSplitterTextInExDeleteDevice (\r | |
1968 | IN TEXT_IN_SPLITTER_PRIVATE_DATA *Private,\r | |
1969 | IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *TextInEx\r | |
1970 | )\r | |
1971 | {\r | |
1972 | UINTN Index;\r | |
1973 | //\r | |
1974 | // Remove the specified text-in device data structure from the Text Input Ex List,\r | |
1975 | // and rearrange the remaining data structures in the Text In List.\r | |
1976 | //\r | |
1977 | for (Index = 0; Index < Private->CurrentNumberOfExConsoles; Index++) {\r | |
1978 | if (Private->TextInExList[Index] == TextInEx) {\r | |
1979 | for (Index = Index; Index < Private->CurrentNumberOfExConsoles - 1; Index++) {\r | |
1980 | Private->TextInExList[Index] = Private->TextInExList[Index + 1];\r | |
1981 | }\r | |
1982 | \r | |
1983 | Private->CurrentNumberOfExConsoles--;\r | |
1984 | return EFI_SUCCESS;\r | |
1985 | }\r | |
1986 | }\r | |
1987 | \r | |
1988 | return EFI_NOT_FOUND;\r | |
1989 | }\r | |
1990 | \r | |
1991 | \r | |
1992 | /**\r | |
1993 | Add Simple Pointer Device in Consplitter Simple Pointer list.\r | |
1994 | \r | |
1995 | @param Private Text In Splitter pointer.\r | |
1996 | @param SimplePointer Simple Pointer protocol pointer.\r | |
1997 | \r | |
1998 | @retval EFI_SUCCESS Simple Pointer Device added successfully.\r | |
1999 | @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.\r | |
2000 | \r | |
2001 | **/\r | |
2002 | EFI_STATUS\r | |
2003 | ConSplitterSimplePointerAddDevice (\r | |
2004 | IN TEXT_IN_SPLITTER_PRIVATE_DATA *Private,\r | |
2005 | IN EFI_SIMPLE_POINTER_PROTOCOL *SimplePointer\r | |
2006 | )\r | |
2007 | {\r | |
2008 | EFI_STATUS Status;\r | |
2009 | \r | |
2010 | //\r | |
2011 | // If the Simple Pointer List is full, enlarge it by calling ConSplitterGrowBuffer().\r | |
2012 | //\r | |
2013 | if (Private->CurrentNumberOfPointers >= Private->PointerListCount) {\r | |
2014 | Status = ConSplitterGrowBuffer (\r | |
2015 | sizeof (EFI_SIMPLE_POINTER_PROTOCOL *),\r | |
2016 | &Private->PointerListCount,\r | |
2017 | (VOID **) &Private->PointerList\r | |
2018 | );\r | |
2019 | if (EFI_ERROR (Status)) {\r | |
2020 | return EFI_OUT_OF_RESOURCES;\r | |
2021 | }\r | |
2022 | }\r | |
2023 | //\r | |
2024 | // Add the new text-in device data structure into the Simple Pointer List.\r | |
2025 | //\r | |
2026 | Private->PointerList[Private->CurrentNumberOfPointers] = SimplePointer;\r | |
2027 | Private->CurrentNumberOfPointers++;\r | |
2028 | \r | |
2029 | return EFI_SUCCESS;\r | |
2030 | }\r | |
2031 | \r | |
2032 | \r | |
2033 | /**\r | |
2034 | Remove Simple Pointer Device from Consplitter Simple Pointer list.\r | |
2035 | \r | |
2036 | @param Private Text In Splitter pointer.\r | |
2037 | @param SimplePointer Simple Pointer protocol pointer.\r | |
2038 | \r | |
2039 | @retval EFI_SUCCESS Simple Pointer Device removed successfully.\r | |
2040 | @retval EFI_NOT_FOUND No Simple Pointer Device found.\r | |
2041 | \r | |
2042 | **/\r | |
2043 | EFI_STATUS\r | |
2044 | ConSplitterSimplePointerDeleteDevice (\r | |
2045 | IN TEXT_IN_SPLITTER_PRIVATE_DATA *Private,\r | |
2046 | IN EFI_SIMPLE_POINTER_PROTOCOL *SimplePointer\r | |
2047 | )\r | |
2048 | {\r | |
2049 | UINTN Index;\r | |
2050 | //\r | |
2051 | // Remove the specified text-in device data structure from the Simple Pointer List,\r | |
2052 | // and rearrange the remaining data structures in the Text In List.\r | |
2053 | //\r | |
2054 | for (Index = 0; Index < Private->CurrentNumberOfPointers; Index++) {\r | |
2055 | if (Private->PointerList[Index] == SimplePointer) {\r | |
2056 | for (Index = Index; Index < Private->CurrentNumberOfPointers - 1; Index++) {\r | |
2057 | Private->PointerList[Index] = Private->PointerList[Index + 1];\r | |
2058 | }\r | |
2059 | \r | |
2060 | Private->CurrentNumberOfPointers--;\r | |
2061 | return EFI_SUCCESS;\r | |
2062 | }\r | |
2063 | }\r | |
2064 | \r | |
2065 | return EFI_NOT_FOUND;\r | |
2066 | }\r | |
2067 | \r | |
2068 | \r | |
2069 | /**\r | |
2070 | Add Absolute Pointer Device in Consplitter Absolute Pointer list.\r | |
2071 | \r | |
2072 | @param Private Text In Splitter pointer.\r | |
2073 | @param AbsolutePointer Absolute Pointer protocol pointer.\r | |
2074 | \r | |
2075 | @retval EFI_SUCCESS Absolute Pointer Device added successfully.\r | |
2076 | @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.\r | |
2077 | \r | |
2078 | **/\r | |
2079 | EFI_STATUS\r | |
2080 | ConSplitterAbsolutePointerAddDevice (\r | |
2081 | IN TEXT_IN_SPLITTER_PRIVATE_DATA *Private,\r | |
2082 | IN EFI_ABSOLUTE_POINTER_PROTOCOL *AbsolutePointer\r | |
2083 | )\r | |
2084 | {\r | |
2085 | EFI_STATUS Status;\r | |
2086 | \r | |
2087 | //\r | |
2088 | // If the Absolute Pointer List is full, enlarge it by calling ConSplitterGrowBuffer().\r | |
2089 | //\r | |
2090 | if (Private->CurrentNumberOfAbsolutePointers >= Private->AbsolutePointerListCount) {\r | |
2091 | Status = ConSplitterGrowBuffer (\r | |
2092 | sizeof (EFI_ABSOLUTE_POINTER_PROTOCOL *),\r | |
2093 | &Private->AbsolutePointerListCount,\r | |
2094 | (VOID **) &Private->AbsolutePointerList\r | |
2095 | );\r | |
2096 | if (EFI_ERROR (Status)) {\r | |
2097 | return EFI_OUT_OF_RESOURCES;\r | |
2098 | }\r | |
2099 | }\r | |
2100 | //\r | |
2101 | // Add the new text-in device data structure into the Absolute Pointer List.\r | |
2102 | //\r | |
2103 | Private->AbsolutePointerList[Private->CurrentNumberOfAbsolutePointers] = AbsolutePointer;\r | |
2104 | Private->CurrentNumberOfAbsolutePointers++;\r | |
2105 | \r | |
2106 | return EFI_SUCCESS;\r | |
2107 | }\r | |
2108 | \r | |
2109 | \r | |
2110 | /**\r | |
2111 | Remove Absolute Pointer Device from Consplitter Absolute Pointer list.\r | |
2112 | \r | |
2113 | @param Private Text In Splitter pointer.\r | |
2114 | @param AbsolutePointer Absolute Pointer protocol pointer.\r | |
2115 | \r | |
2116 | @retval EFI_SUCCESS Absolute Pointer Device removed successfully.\r | |
2117 | @retval EFI_NOT_FOUND No Absolute Pointer Device found.\r | |
2118 | \r | |
2119 | **/\r | |
2120 | EFI_STATUS\r | |
2121 | ConSplitterAbsolutePointerDeleteDevice (\r | |
2122 | IN TEXT_IN_SPLITTER_PRIVATE_DATA *Private,\r | |
2123 | IN EFI_ABSOLUTE_POINTER_PROTOCOL *AbsolutePointer\r | |
2124 | )\r | |
2125 | {\r | |
2126 | UINTN Index;\r | |
2127 | //\r | |
2128 | // Remove the specified text-in device data structure from the Absolute Pointer List,\r | |
2129 | // and rearrange the remaining data structures from the Absolute Pointer List.\r | |
2130 | //\r | |
2131 | for (Index = 0; Index < Private->CurrentNumberOfAbsolutePointers; Index++) {\r | |
2132 | if (Private->AbsolutePointerList[Index] == AbsolutePointer) {\r | |
2133 | for (Index = Index; Index < Private->CurrentNumberOfAbsolutePointers - 1; Index++) {\r | |
2134 | Private->AbsolutePointerList[Index] = Private->AbsolutePointerList[Index + 1];\r | |
2135 | }\r | |
2136 | \r | |
2137 | Private->CurrentNumberOfAbsolutePointers--;\r | |
2138 | return EFI_SUCCESS;\r | |
2139 | }\r | |
2140 | }\r | |
2141 | \r | |
2142 | return EFI_NOT_FOUND;\r | |
2143 | }\r | |
2144 | \r | |
2145 | /**\r | |
2146 | Reallocate Text Out mode map.\r | |
2147 | \r | |
2148 | Allocate new buffer and copy original buffer into the new buffer.\r | |
2149 | \r | |
2150 | @param Private Consplitter Text Out pointer.\r | |
2151 | \r | |
2152 | @retval EFI_SUCCESS Buffer size has grown\r | |
2153 | @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.\r | |
2154 | \r | |
2155 | **/\r | |
2156 | EFI_STATUS\r | |
2157 | ConSplitterGrowMapTable (\r | |
2158 | IN TEXT_OUT_SPLITTER_PRIVATE_DATA *Private\r | |
2159 | )\r | |
2160 | {\r | |
2161 | UINTN Size;\r | |
2162 | UINTN NewSize;\r | |
2163 | UINTN TotalSize;\r | |
2164 | INT32 *TextOutModeMap;\r | |
2165 | INT32 *OldTextOutModeMap;\r | |
2166 | INT32 *SrcAddress;\r | |
2167 | INT32 Index;\r | |
2168 | \r | |
2169 | NewSize = Private->TextOutListCount * sizeof (INT32);\r | |
2170 | OldTextOutModeMap = Private->TextOutModeMap;\r | |
2171 | TotalSize = NewSize * (Private->TextOutQueryDataCount);\r | |
2172 | \r | |
2173 | //\r | |
2174 | // Allocate new buffer for Text Out List.\r | |
2175 | //\r | |
2176 | TextOutModeMap = AllocatePool (TotalSize);\r | |
2177 | if (TextOutModeMap == NULL) {\r | |
2178 | return EFI_OUT_OF_RESOURCES;\r | |
2179 | }\r | |
2180 | \r | |
2181 | SetMem (TextOutModeMap, TotalSize, 0xFF);\r | |
2182 | Private->TextOutModeMap = TextOutModeMap;\r | |
2183 | \r | |
2184 | //\r | |
2185 | // If TextOutList has been enlarged, need to realloc the mode map table\r | |
2186 | // The mode map table is regarded as a two dimension array.\r | |
2187 | //\r | |
2188 | // Old New\r | |
2189 | // 0 ---------> TextOutListCount ----> TextOutListCount\r | |
2190 | // | -------------------------------------------\r | |
2191 | // | | | |\r | |
2192 | // | | | |\r | |
2193 | // | | | |\r | |
2194 | // | | | |\r | |
2195 | // | | | |\r | |
2196 | // \/ | | |\r | |
2197 | // -------------------------------------------\r | |
2198 | // QueryDataCount\r | |
2199 | //\r | |
2200 | if (OldTextOutModeMap != NULL) {\r | |
2201 | \r | |
2202 | Size = Private->CurrentNumberOfConsoles * sizeof (INT32);\r | |
2203 | Index = 0;\r | |
2204 | SrcAddress = OldTextOutModeMap;\r | |
2205 | \r | |
2206 | //\r | |
2207 | // Copy the old data to the new one\r | |
2208 | //\r | |
2209 | while (Index < Private->TextOutMode.MaxMode) {\r | |
2210 | CopyMem (TextOutModeMap, SrcAddress, Size);\r | |
2211 | TextOutModeMap += NewSize;\r | |
2212 | SrcAddress += Size;\r | |
2213 | Index++;\r | |
2214 | }\r | |
2215 | //\r | |
2216 | // Free the old buffer\r | |
2217 | //\r | |
2218 | FreePool (OldTextOutModeMap);\r | |
2219 | }\r | |
2220 | \r | |
2221 | return EFI_SUCCESS;\r | |
2222 | }\r | |
2223 | \r | |
2224 | \r | |
2225 | /**\r | |
2226 | Add new device's output mode to console splitter's mode list.\r | |
2227 | \r | |
2228 | @param Private Text Out Splitter pointer\r | |
2229 | @param TextOut Simple Text Output protocol pointer.\r | |
2230 | \r | |
2231 | @retval EFI_SUCCESS Device added successfully.\r | |
2232 | @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.\r | |
2233 | \r | |
2234 | **/\r | |
2235 | EFI_STATUS\r | |
2236 | ConSplitterAddOutputMode (\r | |
2237 | IN TEXT_OUT_SPLITTER_PRIVATE_DATA *Private,\r | |
2238 | IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *TextOut\r | |
2239 | )\r | |
2240 | {\r | |
2241 | EFI_STATUS Status;\r | |
2242 | INT32 MaxMode;\r | |
2243 | INT32 Mode;\r | |
2244 | UINTN Index;\r | |
2245 | \r | |
2246 | MaxMode = TextOut->Mode->MaxMode;\r | |
2247 | Private->TextOutMode.MaxMode = MaxMode;\r | |
2248 | \r | |
2249 | //\r | |
2250 | // Grow the buffer if query data buffer is not large enough to\r | |
2251 | // hold all the mode supported by the first console.\r | |
2252 | //\r | |
2253 | while (MaxMode > (INT32) Private->TextOutQueryDataCount) {\r | |
2254 | Status = ConSplitterGrowBuffer (\r | |
2255 | sizeof (TEXT_OUT_SPLITTER_QUERY_DATA),\r | |
2256 | &Private->TextOutQueryDataCount,\r | |
2257 | (VOID **) &Private->TextOutQueryData\r | |
2258 | );\r | |
2259 | if (EFI_ERROR (Status)) {\r | |
2260 | return EFI_OUT_OF_RESOURCES;\r | |
2261 | }\r | |
2262 | }\r | |
2263 | //\r | |
2264 | // Allocate buffer for the output mode map\r | |
2265 | //\r | |
2266 | Status = ConSplitterGrowMapTable (Private);\r | |
2267 | if (EFI_ERROR (Status)) {\r | |
2268 | return EFI_OUT_OF_RESOURCES;\r | |
2269 | }\r | |
2270 | //\r | |
2271 | // As the first textout device, directly add the mode in to QueryData\r | |
2272 | // and at the same time record the mapping between QueryData and TextOut.\r | |
2273 | //\r | |
2274 | Mode = 0;\r | |
2275 | Index = 0;\r | |
2276 | while (Mode < MaxMode) {\r | |
2277 | Status = TextOut->QueryMode (\r | |
2278 | TextOut,\r | |
2279 | Mode,\r | |
2280 | &Private->TextOutQueryData[Mode].Columns,\r | |
2281 | &Private->TextOutQueryData[Mode].Rows\r | |
2282 | );\r | |
2283 | //\r | |
2284 | // If mode 1 (80x50) is not supported, make sure mode 1 in TextOutQueryData\r | |
2285 | // is clear to 0x0.\r | |
2286 | //\r | |
2287 | if ((EFI_ERROR(Status)) && (Mode == 1)) {\r | |
2288 | Private->TextOutQueryData[Mode].Columns = 0;\r | |
2289 | Private->TextOutQueryData[Mode].Rows = 0;\r | |
2290 | }\r | |
2291 | Private->TextOutModeMap[Index] = Mode;\r | |
2292 | Mode++;\r | |
2293 | Index += Private->TextOutListCount;\r | |
2294 | }\r | |
2295 | \r | |
2296 | return EFI_SUCCESS;\r | |
2297 | }\r | |
2298 | \r | |
2299 | /**\r | |
2300 | Reconstruct TextOutModeMap to get intersection of modes.\r | |
2301 | \r | |
2302 | This routine reconstruct TextOutModeMap to get the intersection\r | |
2303 | of modes for all console out devices. Because EFI/UEFI spec require\r | |
2304 | mode 0 is 80x25, mode 1 is 80x50, this routine will not check the\r | |
2305 | intersection for mode 0 and mode 1.\r | |
2306 | \r | |
2307 | @param TextOutModeMap Current text out mode map, begin with the mode 80x25\r | |
2308 | @param NewlyAddedMap New text out mode map, begin with the mode 80x25\r | |
2309 | @param MapStepSize Mode step size for one console device\r | |
2310 | @param NewMapStepSize New Mode step size for one console device\r | |
2311 | @param MaxMode IN: Current max text mode, OUT: Updated max text mode.\r | |
2312 | @param CurrentMode IN: Current text mode, OUT: Updated current text mode.\r | |
2313 | \r | |
2314 | **/\r | |
2315 | VOID\r | |
2316 | ConSplitterGetIntersection (\r | |
2317 | IN INT32 *TextOutModeMap,\r | |
2318 | IN INT32 *NewlyAddedMap,\r | |
2319 | IN UINTN MapStepSize,\r | |
2320 | IN UINTN NewMapStepSize,\r | |
2321 | IN OUT INT32 *MaxMode,\r | |
2322 | IN OUT INT32 *CurrentMode\r | |
2323 | )\r | |
2324 | {\r | |
2325 | INT32 Index;\r | |
2326 | INT32 *CurrentMapEntry;\r | |
2327 | INT32 *NextMapEntry;\r | |
2328 | INT32 *NewMapEntry;\r | |
2329 | INT32 CurrentMaxMode;\r | |
2330 | INT32 Mode;\r | |
2331 | \r | |
2332 | //\r | |
2333 | // According to EFI/UEFI spec, mode 0 and mode 1 have been reserved\r | |
2334 | // for 80x25 and 80x50 in Simple Text Out protocol, so don't make intersection\r | |
2335 | // for mode 0 and mode 1, mode number starts from 2.\r | |
2336 | //\r | |
2337 | Index = 2;\r | |
2338 | CurrentMapEntry = &TextOutModeMap[MapStepSize * 2];\r | |
2339 | NextMapEntry = CurrentMapEntry;\r | |
2340 | NewMapEntry = &NewlyAddedMap[NewMapStepSize * 2];\r | |
2341 | \r | |
2342 | CurrentMaxMode = *MaxMode;\r | |
2343 | Mode = *CurrentMode;\r | |
2344 | \r | |
2345 | while (Index < CurrentMaxMode) {\r | |
2346 | if (*NewMapEntry == -1) {\r | |
2347 | //\r | |
2348 | // This mode is not supported any more. Remove it. Special care\r | |
2349 | // must be taken as this remove will also affect current mode;\r | |
2350 | //\r | |
2351 | if (Index == *CurrentMode) {\r | |
2352 | Mode = -1;\r | |
2353 | } else if (Index < *CurrentMode) {\r | |
2354 | Mode--;\r | |
2355 | }\r | |
2356 | (*MaxMode)--;\r | |
2357 | } else {\r | |
2358 | if (CurrentMapEntry != NextMapEntry) {\r | |
2359 | CopyMem (NextMapEntry, CurrentMapEntry, MapStepSize * sizeof (INT32));\r | |
2360 | }\r | |
2361 | \r | |
2362 | NextMapEntry += MapStepSize;\r | |
2363 | }\r | |
2364 | \r | |
2365 | CurrentMapEntry += MapStepSize;\r | |
2366 | NewMapEntry += NewMapStepSize;\r | |
2367 | Index++;\r | |
2368 | }\r | |
2369 | \r | |
2370 | *CurrentMode = Mode;\r | |
2371 | \r | |
2372 | return ;\r | |
2373 | }\r | |
2374 | \r | |
2375 | /**\r | |
2376 | Sync the device's output mode to console splitter's mode list.\r | |
2377 | \r | |
2378 | @param Private Text Out Splitter pointer.\r | |
2379 | @param TextOut Simple Text Output protocol pointer.\r | |
2380 | \r | |
2381 | **/\r | |
2382 | VOID\r | |
2383 | ConSplitterSyncOutputMode (\r | |
2384 | IN TEXT_OUT_SPLITTER_PRIVATE_DATA *Private,\r | |
2385 | IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *TextOut\r | |
2386 | )\r | |
2387 | {\r | |
2388 | INT32 CurrentMaxMode;\r | |
2389 | INT32 Mode;\r | |
2390 | INT32 Index;\r | |
2391 | INT32 *TextOutModeMap;\r | |
2392 | INT32 *MapTable;\r | |
2393 | INT32 QueryMode;\r | |
2394 | TEXT_OUT_SPLITTER_QUERY_DATA *TextOutQueryData;\r | |
2395 | UINTN Rows;\r | |
2396 | UINTN Columns;\r | |
2397 | UINTN StepSize;\r | |
2398 | EFI_STATUS Status;\r | |
2399 | \r | |
2400 | //\r | |
2401 | // Must make sure that current mode won't change even if mode number changes\r | |
2402 | //\r | |
2403 | CurrentMaxMode = Private->TextOutMode.MaxMode;\r | |
2404 | TextOutModeMap = Private->TextOutModeMap;\r | |
2405 | StepSize = Private->TextOutListCount;\r | |
2406 | TextOutQueryData = Private->TextOutQueryData;\r | |
2407 | \r | |
2408 | //\r | |
2409 | // Query all the mode that the newly added TextOut supports\r | |
2410 | //\r | |
2411 | Mode = 0;\r | |
2412 | MapTable = TextOutModeMap + Private->CurrentNumberOfConsoles;\r | |
2413 | while (Mode < TextOut->Mode->MaxMode) {\r | |
2414 | Status = TextOut->QueryMode (TextOut, Mode, &Columns, &Rows);\r | |
2415 | \r | |
2416 | if (EFI_ERROR(Status)) {\r | |
2417 | if (Mode == 1) {\r | |
2418 | //\r | |
2419 | // If mode 1 (80x50) is not supported, make sure mode 1 in TextOutQueryData\r | |
2420 | // is clear to 0x0.\r | |
2421 | //\r | |
2422 | MapTable[StepSize] = Mode;\r | |
2423 | TextOutQueryData[Mode].Columns = 0;\r | |
2424 | TextOutQueryData[Mode].Rows = 0;\r | |
2425 | }\r | |
2426 | Mode++;\r | |
2427 | continue;\r | |
2428 | }\r | |
2429 | //\r | |
2430 | // Search the intersection map and QueryData database to see if they intersects\r | |
2431 | //\r | |
2432 | Index = 0;\r | |
2433 | while (Index < CurrentMaxMode) {\r | |
2434 | QueryMode = *(TextOutModeMap + Index * StepSize);\r | |
2435 | if ((TextOutQueryData[QueryMode].Rows == Rows) && (TextOutQueryData[QueryMode].Columns == Columns)) {\r | |
2436 | MapTable[Index * StepSize] = Mode;\r | |
2437 | break;\r | |
2438 | }\r | |
2439 | Index++;\r | |
2440 | }\r | |
2441 | Mode++;\r | |
2442 | }\r | |
2443 | //\r | |
2444 | // Now search the TextOutModeMap table to find the intersection of supported\r | |
2445 | // mode between ConSplitter and the newly added device.\r | |
2446 | //\r | |
2447 | ConSplitterGetIntersection (\r | |
2448 | TextOutModeMap,\r | |
2449 | MapTable,\r | |
2450 | StepSize,\r | |
2451 | StepSize,\r | |
2452 | &Private->TextOutMode.MaxMode,\r | |
2453 | &Private->TextOutMode.Mode\r | |
2454 | );\r | |
2455 | \r | |
2456 | return ;\r | |
2457 | }\r | |
2458 | \r | |
2459 | \r | |
2460 | /**\r | |
2461 | Sync output device between ConOut and StdErr output.\r | |
2462 | \r | |
2463 | @retval EFI_SUCCESS Sync implemented successfully.\r | |
2464 | @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.\r | |
2465 | \r | |
2466 | **/\r | |
2467 | EFI_STATUS\r | |
2468 | ConSplitterGetIntersectionBetweenConOutAndStrErr (\r | |
2469 | VOID\r | |
2470 | )\r | |
2471 | {\r | |
2472 | UINTN ConOutNumOfConsoles;\r | |
2473 | UINTN StdErrNumOfConsoles;\r | |
2474 | TEXT_OUT_AND_GOP_DATA *ConOutTextOutList;\r | |
2475 | TEXT_OUT_AND_GOP_DATA *StdErrTextOutList;\r | |
2476 | UINTN Indexi;\r | |
2477 | UINTN Indexj;\r | |
2478 | UINTN ConOutRows;\r | |
2479 | UINTN ConOutColumns;\r | |
2480 | UINTN StdErrRows;\r | |
2481 | UINTN StdErrColumns;\r | |
2482 | INT32 ConOutMaxMode;\r | |
2483 | INT32 StdErrMaxMode;\r | |
2484 | INT32 ConOutMode;\r | |
2485 | INT32 StdErrMode;\r | |
2486 | INT32 Mode;\r | |
2487 | INT32 Index;\r | |
2488 | INT32 *ConOutModeMap;\r | |
2489 | INT32 *StdErrModeMap;\r | |
2490 | INT32 *ConOutMapTable;\r | |
2491 | INT32 *StdErrMapTable;\r | |
2492 | TEXT_OUT_SPLITTER_QUERY_DATA *ConOutQueryData;\r | |
2493 | TEXT_OUT_SPLITTER_QUERY_DATA *StdErrQueryData;\r | |
2494 | UINTN ConOutStepSize;\r | |
2495 | UINTN StdErrStepSize;\r | |
2496 | BOOLEAN FoundTheSameTextOut;\r | |
2497 | UINTN ConOutMapTableSize;\r | |
2498 | UINTN StdErrMapTableSize;\r | |
2499 | \r | |
2500 | ConOutNumOfConsoles = mConOut.CurrentNumberOfConsoles;\r | |
2501 | StdErrNumOfConsoles = mStdErr.CurrentNumberOfConsoles;\r | |
2502 | ConOutTextOutList = mConOut.TextOutList;\r | |
2503 | StdErrTextOutList = mStdErr.TextOutList;\r | |
2504 | \r | |
2505 | Indexi = 0;\r | |
2506 | FoundTheSameTextOut = FALSE;\r | |
2507 | while ((Indexi < ConOutNumOfConsoles) && (!FoundTheSameTextOut)) {\r | |
2508 | Indexj = 0;\r | |
2509 | while (Indexj < StdErrNumOfConsoles) {\r | |
2510 | if (ConOutTextOutList->TextOut == StdErrTextOutList->TextOut) {\r | |
2511 | FoundTheSameTextOut = TRUE;\r | |
2512 | break;\r | |
2513 | }\r | |
2514 | \r | |
2515 | Indexj++;\r | |
2516 | StdErrTextOutList++;\r | |
2517 | }\r | |
2518 | \r | |
2519 | Indexi++;\r | |
2520 | ConOutTextOutList++;\r | |
2521 | }\r | |
2522 | \r | |
2523 | if (!FoundTheSameTextOut) {\r | |
2524 | return EFI_SUCCESS;\r | |
2525 | }\r | |
2526 | //\r | |
2527 | // Must make sure that current mode won't change even if mode number changes\r | |
2528 | //\r | |
2529 | ConOutMaxMode = mConOut.TextOutMode.MaxMode;\r | |
2530 | ConOutModeMap = mConOut.TextOutModeMap;\r | |
2531 | ConOutStepSize = mConOut.TextOutListCount;\r | |
2532 | ConOutQueryData = mConOut.TextOutQueryData;\r | |
2533 | \r | |
2534 | StdErrMaxMode = mStdErr.TextOutMode.MaxMode;\r | |
2535 | StdErrModeMap = mStdErr.TextOutModeMap;\r | |
2536 | StdErrStepSize = mStdErr.TextOutListCount;\r | |
2537 | StdErrQueryData = mStdErr.TextOutQueryData;\r | |
2538 | \r | |
2539 | //\r | |
2540 | // Allocate the map table and set the map table's index to -1.\r | |
2541 | //\r | |
2542 | ConOutMapTableSize = ConOutMaxMode * sizeof (INT32);\r | |
2543 | ConOutMapTable = AllocateZeroPool (ConOutMapTableSize);\r | |
2544 | if (ConOutMapTable == NULL) {\r | |
2545 | return EFI_OUT_OF_RESOURCES;\r | |
2546 | }\r | |
2547 | \r | |
2548 | SetMem (ConOutMapTable, ConOutMapTableSize, 0xFF);\r | |
2549 | \r | |
2550 | StdErrMapTableSize = StdErrMaxMode * sizeof (INT32);\r | |
2551 | StdErrMapTable = AllocateZeroPool (StdErrMapTableSize);\r | |
2552 | if (StdErrMapTable == NULL) {\r | |
2553 | return EFI_OUT_OF_RESOURCES;\r | |
2554 | }\r | |
2555 | \r | |
2556 | SetMem (StdErrMapTable, StdErrMapTableSize, 0xFF);\r | |
2557 | \r | |
2558 | //\r | |
2559 | // Find the intersection of the two set of modes. If they actually intersect, the\r | |
2560 | // correponding entry in the map table is set to 1.\r | |
2561 | //\r | |
2562 | Mode = 0;\r | |
2563 | while (Mode < ConOutMaxMode) {\r | |
2564 | //\r | |
2565 | // Search the intersection map and QueryData database to see if they intersect\r | |
2566 | //\r | |
2567 | Index = 0;\r | |
2568 | ConOutMode = *(ConOutModeMap + Mode * ConOutStepSize);\r | |
2569 | ConOutRows = ConOutQueryData[ConOutMode].Rows;\r | |
2570 | ConOutColumns = ConOutQueryData[ConOutMode].Columns;\r | |
2571 | while (Index < StdErrMaxMode) {\r | |
2572 | StdErrMode = *(StdErrModeMap + Index * StdErrStepSize);\r | |
2573 | StdErrRows = StdErrQueryData[StdErrMode].Rows;\r | |
2574 | StdErrColumns = StdErrQueryData[StdErrMode].Columns;\r | |
2575 | if ((StdErrRows == ConOutRows) && (StdErrColumns == ConOutColumns)) {\r | |
2576 | ConOutMapTable[Mode] = 1;\r | |
2577 | StdErrMapTable[Index] = 1;\r | |
2578 | break;\r | |
2579 | }\r | |
2580 | \r | |
2581 | Index++;\r | |
2582 | }\r | |
2583 | \r | |
2584 | Mode++;\r | |
2585 | }\r | |
2586 | //\r | |
2587 | // Now search the TextOutModeMap table to find the intersection of supported\r | |
2588 | // mode between ConSplitter and the newly added device.\r | |
2589 | //\r | |
2590 | ConSplitterGetIntersection (\r | |
2591 | ConOutModeMap,\r | |
2592 | ConOutMapTable,\r | |
2593 | mConOut.TextOutListCount,\r | |
2594 | 1,\r | |
2595 | &(mConOut.TextOutMode.MaxMode),\r | |
2596 | &(mConOut.TextOutMode.Mode)\r | |
2597 | );\r | |
2598 | \r | |
2599 | if (mConOut.TextOutMode.Mode < 0) {\r | |
2600 | mConOut.TextOut.SetMode (&(mConOut.TextOut), 0);\r | |
2601 | }\r | |
2602 | \r | |
2603 | ConSplitterGetIntersection (\r | |
2604 | StdErrModeMap,\r | |
2605 | StdErrMapTable,\r | |
2606 | mStdErr.TextOutListCount,\r | |
2607 | 1,\r | |
2608 | &(mStdErr.TextOutMode.MaxMode),\r | |
2609 | &(mStdErr.TextOutMode.Mode)\r | |
2610 | );\r | |
2611 | \r | |
2612 | if (mStdErr.TextOutMode.Mode < 0) {\r | |
2613 | mStdErr.TextOut.SetMode (&(mStdErr.TextOut), 0);\r | |
2614 | }\r | |
2615 | \r | |
2616 | FreePool (ConOutMapTable);\r | |
2617 | FreePool (StdErrMapTable);\r | |
2618 | \r | |
2619 | return EFI_SUCCESS;\r | |
2620 | }\r | |
2621 | \r | |
2622 | \r | |
2623 | /**\r | |
2624 | Add Grahpics Output modes into Consplitter Text Out list.\r | |
2625 | \r | |
2626 | @param Private Text Out Splitter pointer.\r | |
2627 | @param GraphicsOutput Graphics Output protocol pointer.\r | |
2628 | @param UgaDraw UGA Draw protocol pointer.\r | |
2629 | \r | |
2630 | @retval EFI_SUCCESS Output mode added successfully.\r | |
2631 | @retval other Failed to add output mode.\r | |
2632 | \r | |
2633 | **/\r | |
2634 | EFI_STATUS\r | |
2635 | ConSplitterAddGraphicsOutputMode (\r | |
2636 | IN TEXT_OUT_SPLITTER_PRIVATE_DATA *Private,\r | |
2637 | IN EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput,\r | |
2638 | IN EFI_UGA_DRAW_PROTOCOL *UgaDraw\r | |
2639 | )\r | |
2640 | {\r | |
2641 | EFI_STATUS Status;\r | |
2642 | UINTN Index;\r | |
2643 | UINTN CurrentIndex;\r | |
2644 | EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Mode;\r | |
2645 | UINTN SizeOfInfo;\r | |
2646 | EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Info;\r | |
2647 | EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE *CurrentGraphicsOutputMode;\r | |
2648 | EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *ModeBuffer;\r | |
2649 | EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *MatchedMode;\r | |
2650 | UINTN NumberIndex;\r | |
2651 | BOOLEAN Match;\r | |
2652 | BOOLEAN AlreadyExist;\r | |
2653 | UINT32 UgaHorizontalResolution;\r | |
2654 | UINT32 UgaVerticalResolution;\r | |
2655 | UINT32 UgaColorDepth;\r | |
2656 | UINT32 UgaRefreshRate;\r | |
2657 | \r | |
2658 | ASSERT (GraphicsOutput != NULL || UgaDraw != NULL);\r | |
2659 | \r | |
2660 | CurrentGraphicsOutputMode = Private->GraphicsOutput.Mode;\r | |
2661 | \r | |
2662 | Index = 0;\r | |
2663 | CurrentIndex = 0;\r | |
2664 | \r | |
2665 | if (Private->CurrentNumberOfUgaDraw != 0) {\r | |
2666 | //\r | |
2667 | // If any UGA device has already been added, then there is no need to\r | |
2668 | // calculate intersection of display mode of different GOP/UGA device,\r | |
2669 | // since only one display mode will be exported (i.e. user-defined mode)\r | |
2670 | //\r | |
2671 | goto Done;\r | |
2672 | }\r | |
2673 | \r | |
2674 | if (GraphicsOutput != NULL) {\r | |
2675 | if (Private->CurrentNumberOfGraphicsOutput == 0) {\r | |
2676 | //\r | |
2677 | // This is the first Graphics Output device added\r | |
2678 | //\r | |
2679 | CurrentGraphicsOutputMode->MaxMode = GraphicsOutput->Mode->MaxMode;\r | |
2680 | CurrentGraphicsOutputMode->Mode = GraphicsOutput->Mode->Mode;\r | |
2681 | CopyMem (CurrentGraphicsOutputMode->Info, GraphicsOutput->Mode->Info, GraphicsOutput->Mode->SizeOfInfo);\r | |
2682 | CurrentGraphicsOutputMode->SizeOfInfo = GraphicsOutput->Mode->SizeOfInfo;\r | |
2683 | CurrentGraphicsOutputMode->FrameBufferBase = GraphicsOutput->Mode->FrameBufferBase;\r | |
2684 | CurrentGraphicsOutputMode->FrameBufferSize = GraphicsOutput->Mode->FrameBufferSize;\r | |
2685 | \r | |
2686 | //\r | |
2687 | // Allocate resource for the private mode buffer\r | |
2688 | //\r | |
2689 | ModeBuffer = AllocatePool (sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION) * GraphicsOutput->Mode->MaxMode);\r | |
2690 | if (ModeBuffer == NULL) {\r | |
2691 | return EFI_OUT_OF_RESOURCES;\r | |
2692 | }\r | |
2693 | FreePool (Private->GraphicsOutputModeBuffer);\r | |
2694 | Private->GraphicsOutputModeBuffer = ModeBuffer;\r | |
2695 | \r | |
2696 | //\r | |
2697 | // Store all supported display modes to the private mode buffer\r | |
2698 | //\r | |
2699 | Mode = ModeBuffer;\r | |
2700 | for (Index = 0; Index < GraphicsOutput->Mode->MaxMode; Index++) {\r | |
2701 | //\r | |
2702 | // The Info buffer would be allocated by callee\r | |
2703 | //\r | |
2704 | Status = GraphicsOutput->QueryMode (GraphicsOutput, (UINT32) Index, &SizeOfInfo, &Info);\r | |
2705 | if (EFI_ERROR (Status)) {\r | |
2706 | return Status;\r | |
2707 | }\r | |
2708 | ASSERT ( SizeOfInfo <= sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION));\r | |
2709 | CopyMem (Mode, Info, SizeOfInfo);\r | |
2710 | Mode++;\r | |
2711 | FreePool (Info);\r | |
2712 | }\r | |
2713 | } else {\r | |
2714 | //\r | |
2715 | // Check intersection of display mode\r | |
2716 | //\r | |
2717 | ModeBuffer = AllocatePool (sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION) * CurrentGraphicsOutputMode->MaxMode);\r | |
2718 | if (ModeBuffer == NULL) {\r | |
2719 | return EFI_OUT_OF_RESOURCES;\r | |
2720 | }\r | |
2721 | \r | |
2722 | MatchedMode = ModeBuffer;\r | |
2723 | Mode = &Private->GraphicsOutputModeBuffer[0];\r | |
2724 | for (Index = 0; Index < CurrentGraphicsOutputMode->MaxMode; Index++) {\r | |
2725 | Match = FALSE;\r | |
2726 | \r | |
2727 | for (NumberIndex = 0; NumberIndex < GraphicsOutput->Mode->MaxMode; NumberIndex++) {\r | |
2728 | //\r | |
2729 | // The Info buffer would be allocated by callee\r | |
2730 | //\r | |
2731 | Status = GraphicsOutput->QueryMode (GraphicsOutput, (UINT32) NumberIndex, &SizeOfInfo, &Info);\r | |
2732 | if (EFI_ERROR (Status)) {\r | |
2733 | return Status;\r | |
2734 | }\r | |
2735 | if ((Info->HorizontalResolution == Mode->HorizontalResolution) &&\r | |
2736 | (Info->VerticalResolution == Mode->VerticalResolution)) {\r | |
2737 | //\r | |
2738 | // If GOP device supports one mode in current mode buffer,\r | |
2739 | // it will be added into matched mode buffer\r | |
2740 | //\r | |
2741 | Match = TRUE;\r | |
2742 | FreePool (Info);\r | |
2743 | break;\r | |
2744 | }\r | |
2745 | FreePool (Info);\r | |
2746 | }\r | |
2747 | \r | |
2748 | if (Match) {\r | |
2749 | AlreadyExist = FALSE;\r | |
2750 | \r | |
2751 | //\r | |
2752 | // Check if GOP mode has been in the mode buffer, ModeBuffer = MatchedMode at begin.\r | |
2753 | //\r | |
2754 | for (Info = ModeBuffer; Info < MatchedMode; Info++) {\r | |
2755 | if ((Info->HorizontalResolution == Mode->HorizontalResolution) &&\r | |
2756 | (Info->VerticalResolution == Mode->VerticalResolution)) {\r | |
2757 | AlreadyExist = TRUE;\r | |
2758 | break;\r | |
2759 | }\r | |
2760 | }\r | |
2761 | \r | |
2762 | if (!AlreadyExist) {\r | |
2763 | CopyMem (MatchedMode, Mode, sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION));\r | |
2764 | \r | |
2765 | //\r | |
2766 | // Physical frame buffer is no longer available, change PixelFormat to PixelBltOnly\r | |
2767 | //\r | |
2768 | MatchedMode->Version = 0;\r | |
2769 | MatchedMode->PixelFormat = PixelBltOnly;\r | |
2770 | ZeroMem (&MatchedMode->PixelInformation, sizeof (EFI_PIXEL_BITMASK));\r | |
2771 | \r | |
2772 | MatchedMode++;\r | |
2773 | }\r | |
2774 | }\r | |
2775 | \r | |
2776 | Mode++;\r | |
2777 | }\r | |
2778 | \r | |
2779 | //\r | |
2780 | // Drop the old mode buffer, assign it to a new one\r | |
2781 | //\r | |
2782 | FreePool (Private->GraphicsOutputModeBuffer);\r | |
2783 | Private->GraphicsOutputModeBuffer = ModeBuffer;\r | |
2784 | \r | |
2785 | //\r | |
2786 | // Physical frame buffer is no longer available when there are more than one physical GOP devices\r | |
2787 | //\r | |
2788 | CurrentGraphicsOutputMode->MaxMode = (UINT32) (((UINTN) MatchedMode - (UINTN) ModeBuffer) / sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION));\r | |
2789 | CurrentGraphicsOutputMode->Info->PixelFormat = PixelBltOnly;\r | |
2790 | ZeroMem (&CurrentGraphicsOutputMode->Info->PixelInformation, sizeof (EFI_PIXEL_BITMASK));\r | |
2791 | CurrentGraphicsOutputMode->SizeOfInfo = sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION);\r | |
2792 | CurrentGraphicsOutputMode->FrameBufferBase = (EFI_PHYSICAL_ADDRESS) (UINTN) NULL;\r | |
2793 | CurrentGraphicsOutputMode->FrameBufferSize = 0;\r | |
2794 | }\r | |
2795 | \r | |
2796 | //\r | |
2797 | // Graphics console driver can ensure the same mode for all GOP devices\r | |
2798 | //\r | |
2799 | for (Index = 0; Index < CurrentGraphicsOutputMode->MaxMode; Index++) {\r | |
2800 | Mode = &Private->GraphicsOutputModeBuffer[Index];\r | |
2801 | if ((Mode->HorizontalResolution == GraphicsOutput->Mode->Info->HorizontalResolution) &&\r | |
2802 | (Mode->VerticalResolution == GraphicsOutput->Mode->Info->VerticalResolution)) {\r | |
2803 | CurrentIndex = Index;\r | |
2804 | break;\r | |
2805 | }\r | |
2806 | }\r | |
2807 | if (Index >= CurrentGraphicsOutputMode->MaxMode) {\r | |
2808 | //\r | |
2809 | // if user defined mode is not found, set to default mode 800x600\r | |
2810 | //\r | |
2811 | for (Index = 0; Index < CurrentGraphicsOutputMode->MaxMode; Index++) {\r | |
2812 | Mode = &Private->GraphicsOutputModeBuffer[Index];\r | |
2813 | if ((Mode->HorizontalResolution == 800) && (Mode->VerticalResolution == 600)) {\r | |
2814 | CurrentIndex = Index;\r | |
2815 | break;\r | |
2816 | }\r | |
2817 | }\r | |
2818 | }\r | |
2819 | } else if (UgaDraw != NULL && FeaturePcdGet (PcdUgaConsumeSupport)) {\r | |
2820 | //\r | |
2821 | // Graphics console driver can ensure the same mode for all GOP devices\r | |
2822 | // so we can get the current mode from this video device\r | |
2823 | //\r | |
2824 | UgaDraw->GetMode (\r | |
2825 | UgaDraw,\r | |
2826 | &UgaHorizontalResolution,\r | |
2827 | &UgaVerticalResolution,\r | |
2828 | &UgaColorDepth,\r | |
2829 | &UgaRefreshRate\r | |
2830 | );\r | |
2831 | \r | |
2832 | CurrentGraphicsOutputMode->MaxMode = 1;\r | |
2833 | Info = CurrentGraphicsOutputMode->Info;\r | |
2834 | Info->Version = 0;\r | |
2835 | Info->HorizontalResolution = UgaHorizontalResolution;\r | |
2836 | Info->VerticalResolution = UgaVerticalResolution;\r | |
2837 | Info->PixelFormat = PixelBltOnly;\r | |
2838 | Info->PixelsPerScanLine = UgaHorizontalResolution;\r | |
2839 | CurrentGraphicsOutputMode->SizeOfInfo = sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION);\r | |
2840 | CurrentGraphicsOutputMode->FrameBufferBase = (EFI_PHYSICAL_ADDRESS) (UINTN) NULL;\r | |
2841 | CurrentGraphicsOutputMode->FrameBufferSize = 0;\r | |
2842 | \r | |
2843 | //\r | |
2844 | // Update the private mode buffer\r | |
2845 | //\r | |
2846 | CopyMem (&Private->GraphicsOutputModeBuffer[0], Info, sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION));\r | |
2847 | \r | |
2848 | //\r | |
2849 | // Only mode 0 is available to be set\r | |
2850 | //\r | |
2851 | CurrentIndex = 0;\r | |
2852 | }\r | |
2853 | \r | |
2854 | Done:\r | |
2855 | \r | |
2856 | if (GraphicsOutput != NULL) {\r | |
2857 | Private->CurrentNumberOfGraphicsOutput++;\r | |
2858 | }\r | |
2859 | if (UgaDraw != NULL && FeaturePcdGet (PcdUgaConsumeSupport)) {\r | |
2860 | Private->CurrentNumberOfUgaDraw++;\r | |
2861 | }\r | |
2862 | \r | |
2863 | //\r | |
2864 | // Force GraphicsOutput mode to be set,\r | |
2865 | // regardless whether the console is in EfiConsoleControlScreenGraphics or EfiConsoleControlScreenText mode\r | |
2866 | //\r | |
2867 | Private->HardwareNeedsStarting = TRUE;\r | |
2868 | //\r | |
2869 | // Current mode number may need update now, so set it to an invalid mode number\r | |
2870 | //\r | |
2871 | CurrentGraphicsOutputMode->Mode = 0xffff;\r | |
2872 | //\r | |
2873 | // Graphics console can ensure all GOP devices have the same mode which can be taken as current mode.\r | |
2874 | //\r | |
2875 | Status = Private->GraphicsOutput.SetMode (&Private->GraphicsOutput, (UINT32) CurrentIndex);\r | |
2876 | if (EFI_ERROR(Status)) {\r | |
2877 | //\r | |
2878 | // If user defined mode is not valid for display device, set to the default mode 800x600.\r | |
2879 | //\r | |
2880 | (Private->GraphicsOutputModeBuffer[0]).HorizontalResolution = 800;\r | |
2881 | (Private->GraphicsOutputModeBuffer[0]).VerticalResolution = 600;\r | |
2882 | Status = Private->GraphicsOutput.SetMode (&Private->GraphicsOutput, 0);\r | |
2883 | }\r | |
2884 | \r | |
2885 | return Status;\r | |
2886 | }\r | |
2887 | \r | |
2888 | /**\r | |
2889 | Set the current console out mode.\r | |
2890 | \r | |
2891 | This routine will get the current console mode information (column, row)\r | |
2892 | from ConsoleOutMode variable and set it; if the variable does not exist,\r | |
2893 | set to user defined console mode.\r | |
2894 | \r | |
2895 | @param Private Consplitter Text Out pointer.\r | |
2896 | \r | |
2897 | **/\r | |
2898 | VOID\r | |
2899 | ConsplitterSetConsoleOutMode (\r | |
2900 | IN TEXT_OUT_SPLITTER_PRIVATE_DATA *Private\r | |
2901 | )\r | |
2902 | {\r | |
2903 | UINTN Col;\r | |
2904 | UINTN Row;\r | |
2905 | UINTN Mode;\r | |
2906 | UINTN PreferMode;\r | |
2907 | UINTN BaseMode;\r | |
2908 | UINTN MaxMode;\r | |
2909 | EFI_STATUS Status;\r | |
2910 | CONSOLE_OUT_MODE ModeInfo;\r | |
2911 | EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *TextOut;\r | |
2912 | \r | |
2913 | PreferMode = 0xFF;\r | |
2914 | BaseMode = 0xFF;\r | |
2915 | TextOut = &Private->TextOut;\r | |
2916 | MaxMode = (UINTN) (TextOut->Mode->MaxMode);\r | |
2917 | \r | |
2918 | ModeInfo.Column = PcdGet32 (PcdConOutColumn);\r | |
2919 | ModeInfo.Row = PcdGet32 (PcdConOutRow);\r | |
2920 | \r | |
2921 | //\r | |
2922 | // To find the prefer mode and basic mode from Text Out mode list\r | |
2923 | //\r | |
2924 | for (Mode = 0; Mode < MaxMode; Mode++) {\r | |
2925 | Status = TextOut->QueryMode (TextOut, Mode, &Col, &Row);\r | |
2926 | if (!EFI_ERROR(Status)) {\r | |
2927 | if (Col == ModeInfo.Column && Row == ModeInfo.Row) {\r | |
2928 | PreferMode = Mode;\r | |
2929 | }\r | |
2930 | if (Col == 80 && Row == 25) {\r | |
2931 | BaseMode = Mode;\r | |
2932 | }\r | |
2933 | }\r | |
2934 | }\r | |
2935 | \r | |
2936 | //\r | |
2937 | // Set prefer mode to Text Out devices.\r | |
2938 | //\r | |
2939 | Status = TextOut->SetMode (TextOut, PreferMode);\r | |
2940 | if (EFI_ERROR(Status)) {\r | |
2941 | //\r | |
2942 | // if current mode setting is failed, default 80x25 mode will be set.\r | |
2943 | //\r | |
2944 | Status = TextOut->SetMode (TextOut, BaseMode);\r | |
2945 | ASSERT(!EFI_ERROR(Status));\r | |
2946 | \r | |
2947 | PcdSet32 (PcdConOutColumn, 80);\r | |
2948 | PcdSet32 (PcdConOutRow, 25);\r | |
2949 | }\r | |
2950 | \r | |
2951 | return ;\r | |
2952 | }\r | |
2953 | \r | |
2954 | \r | |
2955 | /**\r | |
2956 | Add Text Output Device in Consplitter Text Output list.\r | |
2957 | \r | |
2958 | @param Private Text Out Splitter pointer.\r | |
2959 | @param TextOut Simple Text Output protocol pointer.\r | |
2960 | @param GraphicsOutput Graphics Output protocol pointer.\r | |
2961 | @param UgaDraw UGA Draw protocol pointer.\r | |
2962 | \r | |
2963 | @retval EFI_SUCCESS Text Output Device added successfully.\r | |
2964 | @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.\r | |
2965 | \r | |
2966 | **/\r | |
2967 | EFI_STATUS\r | |
2968 | ConSplitterTextOutAddDevice (\r | |
2969 | IN TEXT_OUT_SPLITTER_PRIVATE_DATA *Private,\r | |
2970 | IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *TextOut,\r | |
2971 | IN EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput,\r | |
2972 | IN EFI_UGA_DRAW_PROTOCOL *UgaDraw\r | |
2973 | )\r | |
2974 | {\r | |
2975 | EFI_STATUS Status;\r | |
2976 | UINTN CurrentNumOfConsoles;\r | |
2977 | INT32 CurrentMode;\r | |
2978 | INT32 MaxMode;\r | |
2979 | UINT32 UgaHorizontalResolution;\r | |
2980 | UINT32 UgaVerticalResolution;\r | |
2981 | UINT32 UgaColorDepth;\r | |
2982 | UINT32 UgaRefreshRate;\r | |
2983 | TEXT_OUT_AND_GOP_DATA *TextAndGop;\r | |
2984 | UINTN SizeOfInfo;\r | |
2985 | EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Info;\r | |
2986 | \r | |
2987 | Status = EFI_SUCCESS;\r | |
2988 | CurrentNumOfConsoles = Private->CurrentNumberOfConsoles;\r | |
2989 | \r | |
2990 | //\r | |
2991 | // If the Text Out List is full, enlarge it by calling ConSplitterGrowBuffer().\r | |
2992 | //\r | |
2993 | while (CurrentNumOfConsoles >= Private->TextOutListCount) {\r | |
2994 | Status = ConSplitterGrowBuffer (\r | |
2995 | sizeof (TEXT_OUT_AND_GOP_DATA),\r | |
2996 | &Private->TextOutListCount,\r | |
2997 | (VOID **) &Private->TextOutList\r | |
2998 | );\r | |
2999 | if (EFI_ERROR (Status)) {\r | |
3000 | return EFI_OUT_OF_RESOURCES;\r | |
3001 | }\r | |
3002 | //\r | |
3003 | // Also need to reallocate the TextOutModeMap table\r | |
3004 | //\r | |
3005 | Status = ConSplitterGrowMapTable (Private);\r | |
3006 | if (EFI_ERROR (Status)) {\r | |
3007 | return EFI_OUT_OF_RESOURCES;\r | |
3008 | }\r | |
3009 | }\r | |
3010 | \r | |
3011 | TextAndGop = &Private->TextOutList[CurrentNumOfConsoles];\r | |
3012 | \r | |
3013 | TextAndGop->TextOut = TextOut;\r | |
3014 | TextAndGop->GraphicsOutput = GraphicsOutput;\r | |
3015 | TextAndGop->UgaDraw = UgaDraw;\r | |
3016 | \r | |
3017 | if ((GraphicsOutput == NULL) && (UgaDraw == NULL)) {\r | |
3018 | //\r | |
3019 | // If No GOP/UGA device then use the ConOut device\r | |
3020 | //\r | |
3021 | TextAndGop->TextOutEnabled = TRUE;\r | |
3022 | } else {\r | |
3023 | //\r | |
3024 | // If GOP/UGA device use ConOut device only used if screen is in Text mode\r | |
3025 | //\r | |
3026 | TextAndGop->TextOutEnabled = (BOOLEAN) (Private->ConsoleOutputMode == EfiConsoleControlScreenText);\r | |
3027 | }\r | |
3028 | \r | |
3029 | if (CurrentNumOfConsoles == 0) {\r | |
3030 | //\r | |
3031 | // Add the first device's output mode to console splitter's mode list\r | |
3032 | //\r | |
3033 | Status = ConSplitterAddOutputMode (Private, TextOut);\r | |
3034 | } else {\r | |
3035 | ConSplitterSyncOutputMode (Private, TextOut);\r | |
3036 | }\r | |
3037 | \r | |
3038 | Private->CurrentNumberOfConsoles++;\r | |
3039 | \r | |
3040 | //\r | |
3041 | // Scan both TextOutList, for the intersection TextOut device\r | |
3042 | // maybe both ConOut and StdErr incorporate the same Text Out\r | |
3043 | // device in them, thus the output of both should be synced.\r | |
3044 | //\r | |
3045 | ConSplitterGetIntersectionBetweenConOutAndStrErr ();\r | |
3046 | \r | |
3047 | CurrentMode = Private->TextOutMode.Mode;\r | |
3048 | MaxMode = Private->TextOutMode.MaxMode;\r | |
3049 | ASSERT (MaxMode >= 1);\r | |
3050 | \r | |
3051 | if (FeaturePcdGet (PcdConOutGopSupport)) {\r | |
3052 | //\r | |
3053 | // If GOP is produced by Consplitter, this device display mode will be added into Graphics Ouput modes.\r | |
3054 | //\r | |
3055 | if ((GraphicsOutput != NULL) || (UgaDraw != NULL && FeaturePcdGet (PcdUgaConsumeSupport))) {\r | |
3056 | ConSplitterAddGraphicsOutputMode (Private, GraphicsOutput, UgaDraw);\r | |
3057 | }\r | |
3058 | }\r | |
3059 | \r | |
3060 | if (FeaturePcdGet (PcdConOutUgaSupport)) {\r | |
3061 | UgaHorizontalResolution = 800;\r | |
3062 | UgaVerticalResolution = 600;\r | |
3063 | UgaColorDepth = 32;\r | |
3064 | UgaRefreshRate = 60;\r | |
3065 | \r | |
3066 | Status = EFI_DEVICE_ERROR;\r | |
3067 | //\r | |
3068 | // If UGA is produced by Consplitter\r | |
3069 | //\r | |
3070 | if (GraphicsOutput != NULL) {\r | |
3071 | Status = GraphicsOutput->QueryMode (GraphicsOutput, GraphicsOutput->Mode->Mode, &SizeOfInfo, &Info);\r | |
3072 | if (EFI_ERROR (Status)) {\r | |
3073 | return Status;\r | |
3074 | }\r | |
3075 | ASSERT ( SizeOfInfo <= sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION));\r | |
3076 | \r | |
3077 | UgaHorizontalResolution = Info->HorizontalResolution;\r | |
3078 | UgaVerticalResolution = Info->VerticalResolution;\r | |
3079 | \r | |
3080 | FreePool (Info);\r | |
3081 | \r | |
3082 | } else if (UgaDraw != NULL && FeaturePcdGet (PcdUgaConsumeSupport)) {\r | |
3083 | Status = UgaDraw->GetMode (\r | |
3084 | UgaDraw,\r | |
3085 | &UgaHorizontalResolution,\r | |
3086 | &UgaVerticalResolution,\r | |
3087 | &UgaColorDepth,\r | |
3088 | &UgaRefreshRate\r | |
3089 | );\r | |
3090 | }\r | |
3091 | \r | |
3092 | //\r | |
3093 | // Set UGA Draw mode,\r | |
3094 | // if GetMode is failed, set to 800x600 mode\r | |
3095 | //\r | |
3096 | Status = ConSpliterUgaDrawSetMode (\r | |
3097 | &Private->UgaDraw,\r | |
3098 | UgaHorizontalResolution,\r | |
3099 | UgaVerticalResolution,\r | |
3100 | UgaColorDepth,\r | |
3101 | UgaRefreshRate\r | |
3102 | );\r | |
3103 | }\r | |
3104 | \r | |
3105 | if (Private->ConsoleOutputMode == EfiConsoleControlScreenGraphics && GraphicsOutput != NULL) {\r | |
3106 | //\r | |
3107 | // We just added a new GOP or UGA device in graphics mode\r | |
3108 | //\r | |
3109 | if (FeaturePcdGet (PcdConOutGopSupport)) {\r | |
3110 | //\r | |
3111 | // Sync display output on new device based on GOP settings.\r | |
3112 | //\r | |
3113 | DevNullGopSync (Private, TextAndGop->GraphicsOutput, TextAndGop->UgaDraw);\r | |
3114 | } else if (FeaturePcdGet (PcdConOutUgaSupport)) {\r | |
3115 | //\r | |
3116 | // Sync display output on new device based on UGA settings.\r | |
3117 | //\r | |
3118 | DevNullUgaSync (Private, TextAndGop->GraphicsOutput, TextAndGop->UgaDraw);\r | |
3119 | }\r | |
3120 | } else if ((CurrentMode >= 0) && ((GraphicsOutput != NULL) || (UgaDraw != NULL)) && (CurrentMode < Private->TextOutMode.MaxMode)) {\r | |
3121 | //\r | |
3122 | // The new console supports the same mode of the current console so sync up\r | |
3123 | //\r | |
3124 | DevNullSyncStdOut (Private);\r | |
3125 | } else {\r | |
3126 | //\r | |
3127 | // If ConOut, then set the mode to Mode #0 which us 80 x 25\r | |
3128 | //\r | |
3129 | Private->TextOut.SetMode (&Private->TextOut, 0);\r | |
3130 | }\r | |
3131 | \r | |
3132 | //\r | |
3133 | // After adding new console device, all existing console devices should be\r | |
3134 | // synced to the current shared mode.\r | |
3135 | //\r | |
3136 | ConsplitterSetConsoleOutMode (Private);\r | |
3137 | \r | |
3138 | return Status;\r | |
3139 | }\r | |
3140 | \r | |
3141 | \r | |
3142 | /**\r | |
3143 | Remove Text Out Device in Consplitter Text Out list.\r | |
3144 | \r | |
3145 | @param Private Text Out Splitter pointer.\r | |
3146 | @param TextOut Simple Text Output Pointer protocol pointer.\r | |
3147 | \r | |
3148 | @retval EFI_SUCCESS Text Out Device removed successfully.\r | |
3149 | @retval EFI_NOT_FOUND No Text Out Device found.\r | |
3150 | \r | |
3151 | **/\r | |
3152 | EFI_STATUS\r | |
3153 | ConSplitterTextOutDeleteDevice (\r | |
3154 | IN TEXT_OUT_SPLITTER_PRIVATE_DATA *Private,\r | |
3155 | IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *TextOut\r | |
3156 | )\r | |
3157 | {\r | |
3158 | INT32 Index;\r | |
3159 | UINTN CurrentNumOfConsoles;\r | |
3160 | TEXT_OUT_AND_GOP_DATA *TextOutList;\r | |
3161 | EFI_STATUS Status;\r | |
3162 | \r | |
3163 | //\r | |
3164 | // Remove the specified text-out device data structure from the Text out List,\r | |
3165 | // and rearrange the remaining data structures in the Text out List.\r | |
3166 | //\r | |
3167 | CurrentNumOfConsoles = Private->CurrentNumberOfConsoles;\r | |
3168 | Index = (INT32) CurrentNumOfConsoles - 1;\r | |
3169 | TextOutList = Private->TextOutList;\r | |
3170 | while (Index >= 0) {\r | |
3171 | if (TextOutList->TextOut == TextOut) {\r | |
3172 | CopyMem (TextOutList, TextOutList + 1, sizeof (TEXT_OUT_AND_GOP_DATA) * Index);\r | |
3173 | CurrentNumOfConsoles--;\r | |
3174 | if (TextOutList->UgaDraw != NULL && FeaturePcdGet (PcdUgaConsumeSupport)) {\r | |
3175 | Private->CurrentNumberOfUgaDraw--;\r | |
3176 | }\r | |
3177 | if (TextOutList->GraphicsOutput != NULL) {\r | |
3178 | Private->CurrentNumberOfGraphicsOutput--;\r | |
3179 | }\r | |
3180 | break;\r | |
3181 | }\r | |
3182 | \r | |
3183 | Index--;\r | |
3184 | TextOutList++;\r | |
3185 | }\r | |
3186 | //\r | |
3187 | // The specified TextOut is not managed by the ConSplitter driver\r | |
3188 | //\r | |
3189 | if (Index < 0) {\r | |
3190 | return EFI_NOT_FOUND;\r | |
3191 | }\r | |
3192 | \r | |
3193 | if (CurrentNumOfConsoles == 0) {\r | |
3194 | //\r | |
3195 | // If the number of consoles is zero clear the Dev NULL device\r | |
3196 | //\r | |
3197 | Private->CurrentNumberOfConsoles = 0;\r | |
3198 | Private->TextOutMode.MaxMode = 1;\r | |
3199 | Private->TextOutQueryData[0].Columns = 80;\r | |
3200 | Private->TextOutQueryData[0].Rows = 25;\r | |
3201 | DevNullTextOutSetMode (Private, 0);\r | |
3202 | \r | |
3203 | return EFI_SUCCESS;\r | |
3204 | }\r | |
3205 | //\r | |
3206 | // Max Mode is realy an intersection of the QueryMode command to all\r | |
3207 | // devices. So we must copy the QueryMode of the first device to\r | |
3208 | // QueryData.\r | |
3209 | //\r | |
3210 | ZeroMem (\r | |
3211 | Private->TextOutQueryData,\r | |
3212 | Private->TextOutQueryDataCount * sizeof (TEXT_OUT_SPLITTER_QUERY_DATA)\r | |
3213 | );\r | |
3214 | \r | |
3215 | FreePool (Private->TextOutModeMap);\r | |
3216 | Private->TextOutModeMap = NULL;\r | |
3217 | TextOutList = Private->TextOutList;\r | |
3218 | \r | |
3219 | //\r | |
3220 | // Add the first TextOut to the QueryData array and ModeMap table\r | |
3221 | //\r | |
3222 | Status = ConSplitterAddOutputMode (Private, TextOutList->TextOut);\r | |
3223 | \r | |
3224 | //\r | |
3225 | // Now add one by one\r | |
3226 | //\r | |
3227 | Index = 1;\r | |
3228 | Private->CurrentNumberOfConsoles = 1;\r | |
3229 | TextOutList++;\r | |
3230 | while ((UINTN) Index < CurrentNumOfConsoles) {\r | |
3231 | ConSplitterSyncOutputMode (Private, TextOutList->TextOut);\r | |
3232 | Index++;\r | |
3233 | Private->CurrentNumberOfConsoles++;\r | |
3234 | TextOutList++;\r | |
3235 | }\r | |
3236 | \r | |
3237 | ConSplitterGetIntersectionBetweenConOutAndStrErr ();\r | |
3238 | \r | |
3239 | return Status;\r | |
3240 | }\r | |
3241 | \r | |
3242 | \r | |
3243 | /**\r | |
3244 | Reset the input device and optionaly run diagnostics\r | |
3245 | \r | |
3246 | @param This Protocol instance pointer.\r | |
3247 | @param ExtendedVerification Driver may perform diagnostics on reset.\r | |
3248 | \r | |
3249 | @retval EFI_SUCCESS The device was reset.\r | |
3250 | @retval EFI_DEVICE_ERROR The device is not functioning properly and could\r | |
3251 | not be reset.\r | |
3252 | \r | |
3253 | **/\r | |
3254 | EFI_STATUS\r | |
3255 | EFIAPI\r | |
3256 | ConSplitterTextInReset (\r | |
3257 | IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This,\r | |
3258 | IN BOOLEAN ExtendedVerification\r | |
3259 | )\r | |
3260 | {\r | |
3261 | EFI_STATUS Status;\r | |
3262 | EFI_STATUS ReturnStatus;\r | |
3263 | TEXT_IN_SPLITTER_PRIVATE_DATA *Private;\r | |
3264 | UINTN Index;\r | |
3265 | \r | |
3266 | Private = TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_THIS (This);\r | |
3267 | \r | |
3268 | Private->KeyEventSignalState = FALSE;\r | |
3269 | \r | |
3270 | //\r | |
3271 | // return the worst status met\r | |
3272 | //\r | |
3273 | for (Index = 0, ReturnStatus = EFI_SUCCESS; Index < Private->CurrentNumberOfConsoles; Index++) {\r | |
3274 | Status = Private->TextInList[Index]->Reset (\r | |
3275 | Private->TextInList[Index],\r | |
3276 | ExtendedVerification\r | |
3277 | );\r | |
3278 | if (EFI_ERROR (Status)) {\r | |
3279 | ReturnStatus = Status;\r | |
3280 | }\r | |
3281 | }\r | |
3282 | \r | |
3283 | return ReturnStatus;\r | |
3284 | }\r | |
3285 | \r | |
3286 | \r | |
3287 | /**\r | |
3288 | Reads the next keystroke from the input device. The WaitForKey Event can\r | |
3289 | be used to test for existance of a keystroke via WaitForEvent () call.\r | |
3290 | \r | |
3291 | @param Private Protocol instance pointer.\r | |
3292 | @param Key Driver may perform diagnostics on reset.\r | |
3293 | \r | |
3294 | @retval EFI_SUCCESS The keystroke information was returned.\r | |
3295 | @retval EFI_NOT_READY There was no keystroke data availiable.\r | |
3296 | @retval EFI_DEVICE_ERROR The keydtroke information was not returned due\r | |
3297 | to hardware errors.\r | |
3298 | \r | |
3299 | **/\r | |
3300 | EFI_STATUS\r | |
3301 | EFIAPI\r | |
3302 | ConSplitterTextInPrivateReadKeyStroke (\r | |
3303 | IN TEXT_IN_SPLITTER_PRIVATE_DATA *Private,\r | |
3304 | OUT EFI_INPUT_KEY *Key\r | |
3305 | )\r | |
3306 | {\r | |
3307 | EFI_STATUS Status;\r | |
3308 | UINTN Index;\r | |
3309 | EFI_INPUT_KEY CurrentKey;\r | |
3310 | \r | |
3311 | Key->UnicodeChar = 0;\r | |
3312 | Key->ScanCode = SCAN_NULL;\r | |
3313 | \r | |
3314 | //\r | |
3315 | // if no physical console input device exists, return EFI_NOT_READY;\r | |
3316 | // if any physical console input device has key input,\r | |
3317 | // return the key and EFI_SUCCESS.\r | |
3318 | //\r | |
3319 | for (Index = 0; Index < Private->CurrentNumberOfConsoles; Index++) {\r | |
3320 | Status = Private->TextInList[Index]->ReadKeyStroke (\r | |
3321 | Private->TextInList[Index],\r | |
3322 | &CurrentKey\r | |
3323 | );\r | |
3324 | if (!EFI_ERROR (Status)) {\r | |
3325 | *Key = CurrentKey;\r | |
3326 | return Status;\r | |
3327 | }\r | |
3328 | }\r | |
3329 | \r | |
3330 | return EFI_NOT_READY;\r | |
3331 | }\r | |
3332 | \r | |
3333 | /**\r | |
3334 | Return TRUE if StdIn is locked. The ConIn device on the virtual handle is\r | |
3335 | the only device locked.\r | |
3336 | \r | |
3337 | @retval TRUE StdIn locked\r | |
3338 | @retval FALSE StdIn working normally\r | |
3339 | \r | |
3340 | **/\r | |
3341 | BOOLEAN\r | |
3342 | ConSpliterConssoleControlStdInLocked (\r | |
3343 | VOID\r | |
3344 | )\r | |
3345 | {\r | |
3346 | return mConIn.PasswordEnabled;\r | |
3347 | }\r | |
3348 | \r | |
3349 | \r | |
3350 | /**\r | |
3351 | Record and check key sequence on StdIn.\r | |
3352 | \r | |
3353 | This timer event will fire when StdIn is locked. It will record the key sequence\r | |
3354 | on StdIn and also check to see if it matches the password. Any error in the\r | |
3355 | password will cause the check to reset. As long as a mConIn.PasswordEnabled is\r | |
3356 | TRUE, the StdIn splitter will not report any input.\r | |
3357 | \r | |
3358 | @param Event The Event this notify function registered to.\r | |
3359 | @param Context Pointer to the context data registerd to the\r | |
3360 | Event.\r | |
3361 | **/\r | |
3362 | VOID\r | |
3363 | EFIAPI\r | |
3364 | ConSpliterConsoleControlLockStdInEvent (\r | |
3365 | IN EFI_EVENT Event,\r | |
3366 | IN VOID *Context\r | |
3367 | )\r | |
3368 | {\r | |
3369 | EFI_STATUS Status;\r | |
3370 | EFI_INPUT_KEY Key;\r | |
3371 | CHAR16 BackSpaceString[2];\r | |
3372 | CHAR16 SpaceString[2];\r | |
3373 | \r | |
3374 | do {\r | |
3375 | Status = ConSplitterTextInPrivateReadKeyStroke (&mConIn, &Key);\r | |
3376 | if (!EFI_ERROR (Status)) {\r | |
3377 | //\r | |
3378 | // If key read successfully\r | |
3379 | //\r | |
3380 | if ((Key.UnicodeChar == CHAR_CARRIAGE_RETURN) && (Key.ScanCode == SCAN_NULL)) {\r | |
3381 | //\r | |
3382 | // If it's an ENTER, match password\r | |
3383 | //\r | |
3384 | mConIn.PwdAttempt[mConIn.PwdIndex] = CHAR_NULL;\r | |
3385 | if (StrCmp (mConIn.Password, mConIn.PwdAttempt) != 0) {\r | |
3386 | //\r | |
3387 | // Password not match\r | |
3388 | //\r | |
3389 | ConSplitterTextOutOutputString (&mConOut.TextOut, (CHAR16 *) L"\n\rPassword not correct\n\r");\r | |
3390 | mConIn.PwdIndex = 0;\r | |
3391 | } else {\r | |
3392 | //\r | |
3393 | // Key matches password sequence\r | |
3394 | //\r | |
3395 | gBS->SetTimer (mConIn.LockEvent, TimerPeriodic, 0);\r | |
3396 | mConIn.PasswordEnabled = FALSE;\r | |
3397 | Status = EFI_NOT_READY;\r | |
3398 | }\r | |
3399 | } else if ((Key.UnicodeChar == CHAR_BACKSPACE) && (Key.ScanCode == SCAN_NULL)) {\r | |
3400 | //\r | |
3401 | // BackSpace met\r | |
3402 | //\r | |
3403 | if (mConIn.PwdIndex > 0) {\r | |
3404 | BackSpaceString[0] = CHAR_BACKSPACE;\r | |
3405 | BackSpaceString[1] = 0;\r | |
3406 | \r | |
3407 | SpaceString[0] = L' ';\r | |
3408 | SpaceString[1] = 0;\r | |
3409 | \r | |
3410 | ConSplitterTextOutOutputString (&mConOut.TextOut, BackSpaceString);\r | |
3411 | ConSplitterTextOutOutputString (&mConOut.TextOut, SpaceString);\r | |
3412 | ConSplitterTextOutOutputString (&mConOut.TextOut, BackSpaceString);\r | |
3413 | \r | |
3414 | mConIn.PwdIndex--;\r | |
3415 | }\r | |
3416 | } else if ((Key.ScanCode == SCAN_NULL) && (Key.UnicodeChar >= 32)) {\r | |
3417 | //\r | |
3418 | // If it's not an ENTER, neigher a function key, nor a CTRL-X or ALT-X, record the input,\r | |
3419 | // value 32 stands for a Blank Space key.\r | |
3420 | //\r | |
3421 | if (mConIn.PwdIndex < (MAX_STD_IN_PASSWORD - 1)) {\r | |
3422 | if (mConIn.PwdIndex == 0) {\r | |
3423 | ConSplitterTextOutOutputString (&mConOut.TextOut, (CHAR16 *) L"\n\r");\r | |
3424 | }\r | |
3425 | \r | |
3426 | ConSplitterTextOutOutputString (&mConOut.TextOut, (CHAR16 *) L"*");\r | |
3427 | mConIn.PwdAttempt[mConIn.PwdIndex] = Key.UnicodeChar;\r | |
3428 | mConIn.PwdIndex++;\r | |
3429 | }\r | |
3430 | }\r | |
3431 | }\r | |
3432 | } while (!EFI_ERROR (Status));\r | |
3433 | }\r | |
3434 | \r | |
3435 | \r | |
3436 | /**\r | |
3437 | If Password is NULL or the Password is too big, then return an error. If the\r | |
3438 | Password is valid, then store the password, lock StdIn and arm the periodic timer.\r | |
3439 | \r | |
3440 | @param This Console Control protocol pointer.\r | |
3441 | @param Password The password input.\r | |
3442 | \r | |
3443 | @retval EFI_SUCCESS Lock the StdIn device.\r | |
3444 | @retval EFI_INVALID_PARAMETER Password is NULL.\r | |
3445 | @retval EFI_OUT_OF_RESOURCES Buffer allocation to store the password fails.\r | |
3446 | \r | |
3447 | **/\r | |
3448 | EFI_STATUS\r | |
3449 | EFIAPI\r | |
3450 | ConSpliterConsoleControlLockStdIn (\r | |
3451 | IN EFI_CONSOLE_CONTROL_PROTOCOL *This,\r | |
3452 | IN CHAR16 *Password\r | |
3453 | )\r | |
3454 | {\r | |
3455 | if (Password == NULL) {\r | |
3456 | return EFI_INVALID_PARAMETER;\r | |
3457 | }\r | |
3458 | \r | |
3459 | if (StrLen (Password) >= MAX_STD_IN_PASSWORD) {\r | |
3460 | //\r | |
3461 | // Currently have a max password size\r | |
3462 | //\r | |
3463 | return EFI_OUT_OF_RESOURCES;\r | |
3464 | }\r | |
3465 | //\r | |
3466 | // Save the password, initialize state variables and arm event timer\r | |
3467 | //\r | |
3468 | StrCpy (mConIn.Password, Password);\r | |
3469 | mConIn.PasswordEnabled = TRUE;\r | |
3470 | mConIn.PwdIndex = 0;\r | |
3471 | //\r | |
3472 | // Lock Timer Periodic is 25ms.\r | |
3473 | //\r | |
3474 | gBS->SetTimer (mConIn.LockEvent, TimerPeriodic, 10000 * 25);\r | |
3475 | \r | |
3476 | return EFI_SUCCESS;\r | |
3477 | }\r | |
3478 | \r | |
3479 | \r | |
3480 | /**\r | |
3481 | Reads the next keystroke from the input device. The WaitForKey Event can\r | |
3482 | be used to test for existance of a keystroke via WaitForEvent () call.\r | |
3483 | If the ConIn is password locked make it look like no keystroke is availible\r | |
3484 | \r | |
3485 | @param This Protocol instance pointer.\r | |
3486 | @param Key Driver may perform diagnostics on reset.\r | |
3487 | \r | |
3488 | @retval EFI_SUCCESS The keystroke information was returned.\r | |
3489 | @retval EFI_NOT_READY There was no keystroke data availiable.\r | |
3490 | @retval EFI_DEVICE_ERROR The keydtroke information was not returned due\r | |
3491 | to hardware errors.\r | |
3492 | \r | |
3493 | **/\r | |
3494 | EFI_STATUS\r | |
3495 | EFIAPI\r | |
3496 | ConSplitterTextInReadKeyStroke (\r | |
3497 | IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This,\r | |
3498 | OUT EFI_INPUT_KEY *Key\r | |
3499 | )\r | |
3500 | {\r | |
3501 | TEXT_IN_SPLITTER_PRIVATE_DATA *Private;\r | |
3502 | \r | |
3503 | Private = TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_THIS (This);\r | |
3504 | if (Private->PasswordEnabled) {\r | |
3505 | //\r | |
3506 | // If StdIn Locked return not ready\r | |
3507 | //\r | |
3508 | return EFI_NOT_READY;\r | |
3509 | }\r | |
3510 | \r | |
3511 | Private->KeyEventSignalState = FALSE;\r | |
3512 | \r | |
3513 | return ConSplitterTextInPrivateReadKeyStroke (Private, Key);\r | |
3514 | }\r | |
3515 | \r | |
3516 | \r | |
3517 | /**\r | |
3518 | This event aggregates all the events of the ConIn devices in the spliter.\r | |
3519 | \r | |
3520 | If the ConIn is password locked then return.\r | |
3521 | If any events of physical ConIn devices are signaled, signal the ConIn\r | |
3522 | spliter event. This will cause the calling code to call\r | |
3523 | ConSplitterTextInReadKeyStroke ().\r | |
3524 | \r | |
3525 | @param Event The Event assoicated with callback.\r | |
3526 | @param Context Context registered when Event was created.\r | |
3527 | \r | |
3528 | **/\r | |
3529 | VOID\r | |
3530 | EFIAPI\r | |
3531 | ConSplitterTextInWaitForKey (\r | |
3532 | IN EFI_EVENT Event,\r | |
3533 | IN VOID *Context\r | |
3534 | )\r | |
3535 | {\r | |
3536 | EFI_STATUS Status;\r | |
3537 | TEXT_IN_SPLITTER_PRIVATE_DATA *Private;\r | |
3538 | UINTN Index;\r | |
3539 | \r | |
3540 | Private = (TEXT_IN_SPLITTER_PRIVATE_DATA *) Context;\r | |
3541 | \r | |
3542 | if (Private->PasswordEnabled) {\r | |
3543 | //\r | |
3544 | // If StdIn Locked return not ready\r | |
3545 | //\r | |
3546 | return ;\r | |
3547 | }\r | |
3548 | \r | |
3549 | if (Private->KeyEventSignalState) {\r | |
3550 | //\r | |
3551 | // If KeyEventSignalState is flagged before, and not cleared by Reset() or ReadKeyStroke()\r | |
3552 | //\r | |
3553 | gBS->SignalEvent (Event);\r | |
3554 | return ;\r | |
3555 | }\r | |
3556 | \r | |
3557 | //\r | |
3558 | // If any physical console input device has key input, signal the event.\r | |
3559 | //\r | |
3560 | for (Index = 0; Index < Private->CurrentNumberOfConsoles; Index++) {\r | |
3561 | Status = gBS->CheckEvent (Private->TextInList[Index]->WaitForKey);\r | |
3562 | if (!EFI_ERROR (Status)) {\r | |
3563 | gBS->SignalEvent (Event);\r | |
3564 | Private->KeyEventSignalState = TRUE;\r | |
3565 | }\r | |
3566 | }\r | |
3567 | }\r | |
3568 | \r | |
3569 | \r | |
3570 | \r | |
3571 | /**\r | |
3572 | Test if the key has been registered on input device.\r | |
3573 | \r | |
3574 | @param RegsiteredData A pointer to a buffer that is filled in with the\r | |
3575 | keystroke state data for the key that was\r | |
3576 | registered.\r | |
3577 | @param InputData A pointer to a buffer that is filled in with the\r | |
3578 | keystroke state data for the key that was\r | |
3579 | pressed.\r | |
3580 | \r | |
3581 | @retval TRUE Key be pressed matches a registered key.\r | |
3582 | @retval FLASE Match failed.\r | |
3583 | \r | |
3584 | **/\r | |
3585 | BOOLEAN\r | |
3586 | IsKeyRegistered (\r | |
3587 | IN EFI_KEY_DATA *RegsiteredData,\r | |
3588 | IN EFI_KEY_DATA *InputData\r | |
3589 | )\r | |
3590 | {\r | |
3591 | ASSERT (RegsiteredData != NULL && InputData != NULL);\r | |
3592 | \r | |
3593 | if ((RegsiteredData->Key.ScanCode != InputData->Key.ScanCode) ||\r | |
3594 | (RegsiteredData->Key.UnicodeChar != InputData->Key.UnicodeChar)) {\r | |
3595 | return FALSE;\r | |
3596 | }\r | |
3597 | \r | |
3598 | //\r | |
3599 | // Assume KeyShiftState/KeyToggleState = 0 in Registered key data means these state could be ignored.\r | |
3600 | //\r | |
3601 | if (RegsiteredData->KeyState.KeyShiftState != 0 &&\r | |
3602 | RegsiteredData->KeyState.KeyShiftState != InputData->KeyState.KeyShiftState) {\r | |
3603 | return FALSE;\r | |
3604 | }\r | |
3605 | if (RegsiteredData->KeyState.KeyToggleState != 0 &&\r | |
3606 | RegsiteredData->KeyState.KeyToggleState != InputData->KeyState.KeyToggleState) {\r | |
3607 | return FALSE;\r | |
3608 | }\r | |
3609 | \r | |
3610 | return TRUE;\r | |
3611 | \r | |
3612 | }\r | |
3613 | \r | |
3614 | \r | |
3615 | /**\r | |
3616 | Reset the input device and optionaly run diagnostics\r | |
3617 | \r | |
3618 | @param This Protocol instance pointer.\r | |
3619 | @param ExtendedVerification Driver may perform diagnostics on reset.\r | |
3620 | \r | |
3621 | @retval EFI_SUCCESS The device was reset.\r | |
3622 | @retval EFI_DEVICE_ERROR The device is not functioning properly and could\r | |
3623 | not be reset.\r | |
3624 | \r | |
3625 | **/\r | |
3626 | EFI_STATUS\r | |
3627 | EFIAPI\r | |
3628 | ConSplitterTextInResetEx (\r | |
3629 | IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,\r | |
3630 | IN BOOLEAN ExtendedVerification\r | |
3631 | )\r | |
3632 | {\r | |
3633 | EFI_STATUS Status;\r | |
3634 | EFI_STATUS ReturnStatus;\r | |
3635 | TEXT_IN_SPLITTER_PRIVATE_DATA *Private;\r | |
3636 | UINTN Index;\r | |
3637 | \r | |
3638 | Private = TEXT_IN_EX_SPLITTER_PRIVATE_DATA_FROM_THIS (This);\r | |
3639 | \r | |
3640 | Private->KeyEventSignalState = FALSE;\r | |
3641 | \r | |
3642 | //\r | |
3643 | // return the worst status met\r | |
3644 | //\r | |
3645 | for (Index = 0, ReturnStatus = EFI_SUCCESS; Index < Private->CurrentNumberOfExConsoles; Index++) {\r | |
3646 | Status = Private->TextInExList[Index]->Reset (\r | |
3647 | Private->TextInExList[Index],\r | |
3648 | ExtendedVerification\r | |
3649 | );\r | |
3650 | if (EFI_ERROR (Status)) {\r | |
3651 | ReturnStatus = Status;\r | |
3652 | }\r | |
3653 | }\r | |
3654 | \r | |
3655 | return ReturnStatus;\r | |
3656 | \r | |
3657 | }\r | |
3658 | \r | |
3659 | \r | |
3660 | /**\r | |
3661 | Reads the next keystroke from the input device. The WaitForKey Event can\r | |
3662 | be used to test for existance of a keystroke via WaitForEvent () call.\r | |
3663 | \r | |
3664 | @param This Protocol instance pointer.\r | |
3665 | @param KeyData A pointer to a buffer that is filled in with the\r | |
3666 | keystroke state data for the key that was\r | |
3667 | pressed.\r | |
3668 | \r | |
3669 | @retval EFI_SUCCESS The keystroke information was returned.\r | |
3670 | @retval EFI_NOT_READY There was no keystroke data availiable.\r | |
3671 | @retval EFI_DEVICE_ERROR The keystroke information was not returned due\r | |
3672 | to hardware errors.\r | |
3673 | @retval EFI_INVALID_PARAMETER KeyData is NULL.\r | |
3674 | \r | |
3675 | **/\r | |
3676 | EFI_STATUS\r | |
3677 | EFIAPI\r | |
3678 | ConSplitterTextInReadKeyStrokeEx (\r | |
3679 | IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,\r | |
3680 | OUT EFI_KEY_DATA *KeyData\r | |
3681 | )\r | |
3682 | {\r | |
3683 | TEXT_IN_SPLITTER_PRIVATE_DATA *Private;\r | |
3684 | EFI_STATUS Status;\r | |
3685 | UINTN Index;\r | |
3686 | EFI_KEY_DATA CurrentKeyData;\r | |
3687 | \r | |
3688 | \r | |
3689 | if (KeyData == NULL) {\r | |
3690 | return EFI_INVALID_PARAMETER;\r | |
3691 | }\r | |
3692 | \r | |
3693 | Private = TEXT_IN_EX_SPLITTER_PRIVATE_DATA_FROM_THIS (This);\r | |
3694 | if (Private->PasswordEnabled) {\r | |
3695 | //\r | |
3696 | // If StdIn Locked return not ready\r | |
3697 | //\r | |
3698 | return EFI_NOT_READY;\r | |
3699 | }\r | |
3700 | \r | |
3701 | Private->KeyEventSignalState = FALSE;\r | |
3702 | \r | |
3703 | KeyData->Key.UnicodeChar = 0;\r | |
3704 | KeyData->Key.ScanCode = SCAN_NULL;\r | |
3705 | \r | |
3706 | //\r | |
3707 | // if no physical console input device exists, return EFI_NOT_READY;\r | |
3708 | // if any physical console input device has key input,\r | |
3709 | // return the key and EFI_SUCCESS.\r | |
3710 | //\r | |
3711 | for (Index = 0; Index < Private->CurrentNumberOfExConsoles; Index++) {\r | |
3712 | Status = Private->TextInExList[Index]->ReadKeyStrokeEx (\r | |
3713 | Private->TextInExList[Index],\r | |
3714 | &CurrentKeyData\r | |
3715 | );\r | |
3716 | if (!EFI_ERROR (Status)) {\r | |
3717 | CopyMem (KeyData, &CurrentKeyData, sizeof (CurrentKeyData));\r | |
3718 | return Status;\r | |
3719 | }\r | |
3720 | }\r | |
3721 | \r | |
3722 | return EFI_NOT_READY;\r | |
3723 | }\r | |
3724 | \r | |
3725 | \r | |
3726 | /**\r | |
3727 | Set certain state for the input device.\r | |
3728 | \r | |
3729 | @param This Protocol instance pointer.\r | |
3730 | @param KeyToggleState A pointer to the EFI_KEY_TOGGLE_STATE to set the\r | |
3731 | state for the input device.\r | |
3732 | \r | |
3733 | @retval EFI_SUCCESS The device state was set successfully.\r | |
3734 | @retval EFI_DEVICE_ERROR The device is not functioning correctly and\r | |
3735 | could not have the setting adjusted.\r | |
3736 | @retval EFI_UNSUPPORTED The device does not have the ability to set its\r | |
3737 | state.\r | |
3738 | @retval EFI_INVALID_PARAMETER KeyToggleState is NULL.\r | |
3739 | \r | |
3740 | **/\r | |
3741 | EFI_STATUS\r | |
3742 | EFIAPI\r | |
3743 | ConSplitterTextInSetState (\r | |
3744 | IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,\r | |
3745 | IN EFI_KEY_TOGGLE_STATE *KeyToggleState\r | |
3746 | )\r | |
3747 | {\r | |
3748 | TEXT_IN_SPLITTER_PRIVATE_DATA *Private;\r | |
3749 | EFI_STATUS Status;\r | |
3750 | UINTN Index;\r | |
3751 | \r | |
3752 | if (KeyToggleState == NULL) {\r | |
3753 | return EFI_INVALID_PARAMETER;\r | |
3754 | }\r | |
3755 | \r | |
3756 | Private = TEXT_IN_EX_SPLITTER_PRIVATE_DATA_FROM_THIS (This);\r | |
3757 | \r | |
3758 | //\r | |
3759 | // if no physical console input device exists, return EFI_SUCCESS;\r | |
3760 | // otherwise return the status of setting state of physical console input device\r | |
3761 | //\r | |
3762 | for (Index = 0; Index < Private->CurrentNumberOfExConsoles; Index++) {\r | |
3763 | Status = Private->TextInExList[Index]->SetState (\r | |
3764 | Private->TextInExList[Index],\r | |
3765 | KeyToggleState\r | |
3766 | );\r | |
3767 | if (EFI_ERROR (Status)) {\r | |
3768 | return Status;\r | |
3769 | }\r | |
3770 | }\r | |
3771 | \r | |
3772 | return EFI_SUCCESS;\r | |
3773 | \r | |
3774 | }\r | |
3775 | \r | |
3776 | \r | |
3777 | /**\r | |
3778 | Register a notification function for a particular keystroke for the input device.\r | |
3779 | \r | |
3780 | @param This Protocol instance pointer.\r | |
3781 | @param KeyData A pointer to a buffer that is filled in with the\r | |
3782 | keystroke information data for the key that was\r | |
3783 | pressed.\r | |
3784 | @param KeyNotificationFunction Points to the function to be called when the key\r | |
3785 | sequence is typed specified by KeyData.\r | |
3786 | @param NotifyHandle Points to the unique handle assigned to the\r | |
3787 | registered notification.\r | |
3788 | \r | |
3789 | @retval EFI_SUCCESS The notification function was registered\r | |
3790 | successfully.\r | |
3791 | @retval EFI_OUT_OF_RESOURCES Unable to allocate resources for necesssary data\r | |
3792 | structures.\r | |
3793 | @retval EFI_INVALID_PARAMETER KeyData or KeyNotificationFunction or NotifyHandle is NULL.\r | |
3794 | \r | |
3795 | **/\r | |
3796 | EFI_STATUS\r | |
3797 | EFIAPI\r | |
3798 | ConSplitterTextInRegisterKeyNotify (\r | |
3799 | IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,\r | |
3800 | IN EFI_KEY_DATA *KeyData,\r | |
3801 | IN EFI_KEY_NOTIFY_FUNCTION KeyNotificationFunction,\r | |
3802 | OUT EFI_HANDLE *NotifyHandle\r | |
3803 | )\r | |
3804 | {\r | |
3805 | TEXT_IN_SPLITTER_PRIVATE_DATA *Private;\r | |
3806 | EFI_STATUS Status;\r | |
3807 | UINTN Index;\r | |
3808 | TEXT_IN_EX_SPLITTER_NOTIFY *NewNotify;\r | |
3809 | LIST_ENTRY *Link;\r | |
3810 | TEXT_IN_EX_SPLITTER_NOTIFY *CurrentNotify;\r | |
3811 | \r | |
3812 | \r | |
3813 | if (KeyData == NULL || NotifyHandle == NULL || KeyNotificationFunction == NULL) {\r | |
3814 | return EFI_INVALID_PARAMETER;\r | |
3815 | }\r | |
3816 | \r | |
3817 | Private = TEXT_IN_EX_SPLITTER_PRIVATE_DATA_FROM_THIS (This);\r | |
3818 | \r | |
3819 | //\r | |
3820 | // If no physical console input device exists,\r | |
3821 | // return EFI_SUCCESS directly.\r | |
3822 | //\r | |
3823 | if (Private->CurrentNumberOfExConsoles <= 0) {\r | |
3824 | return EFI_SUCCESS;\r | |
3825 | }\r | |
3826 | \r | |
3827 | //\r | |
3828 | // Return EFI_SUCCESS if the (KeyData, NotificationFunction) is already registered.\r | |
3829 | //\r | |
3830 | for (Link = Private->NotifyList.ForwardLink; Link != &Private->NotifyList; Link = Link->ForwardLink) {\r | |
3831 | CurrentNotify = TEXT_IN_EX_SPLITTER_NOTIFY_FROM_THIS (Link);\r | |
3832 | if (IsKeyRegistered (&CurrentNotify->KeyData, KeyData)) {\r | |
3833 | if (CurrentNotify->KeyNotificationFn == KeyNotificationFunction) {\r | |
3834 | *NotifyHandle = CurrentNotify->NotifyHandle;\r | |
3835 | return EFI_SUCCESS;\r | |
3836 | }\r | |
3837 | }\r | |
3838 | }\r | |
3839 | \r | |
3840 | //\r | |
3841 | // Allocate resource to save the notification function\r | |
3842 | //\r | |
3843 | NewNotify = (TEXT_IN_EX_SPLITTER_NOTIFY *) AllocateZeroPool (sizeof (TEXT_IN_EX_SPLITTER_NOTIFY));\r | |
3844 | if (NewNotify == NULL) {\r | |
3845 | return EFI_OUT_OF_RESOURCES;\r | |
3846 | }\r | |
3847 | NewNotify->NotifyHandleList = (EFI_HANDLE *) AllocateZeroPool (sizeof (EFI_HANDLE) * Private->CurrentNumberOfExConsoles);\r | |
3848 | if (NewNotify->NotifyHandleList == NULL) {\r | |
3849 | gBS->FreePool (NewNotify);\r | |
3850 | return EFI_OUT_OF_RESOURCES;\r | |
3851 | }\r | |
3852 | NewNotify->Signature = TEXT_IN_EX_SPLITTER_NOTIFY_SIGNATURE;\r | |
3853 | NewNotify->KeyNotificationFn = KeyNotificationFunction;\r | |
3854 | NewNotify->NotifyHandle = (EFI_HANDLE) NewNotify;\r | |
3855 | CopyMem (&NewNotify->KeyData, KeyData, sizeof (KeyData));\r | |
3856 | \r | |
3857 | //\r | |
3858 | // Return the wrong status of registering key notify of\r | |
3859 | // physical console input device if meet problems\r | |
3860 | //\r | |
3861 | for (Index = 0; Index < Private->CurrentNumberOfExConsoles; Index++) {\r | |
3862 | Status = Private->TextInExList[Index]->RegisterKeyNotify (\r | |
3863 | Private->TextInExList[Index],\r | |
3864 | KeyData,\r | |
3865 | KeyNotificationFunction,\r | |
3866 | &NewNotify->NotifyHandleList[Index]\r | |
3867 | );\r | |
3868 | if (EFI_ERROR (Status)) {\r | |
3869 | gBS->FreePool (NewNotify->NotifyHandleList);\r | |
3870 | gBS->FreePool (NewNotify);\r | |
3871 | return Status;\r | |
3872 | }\r | |
3873 | }\r | |
3874 | \r | |
3875 | InsertTailList (&mConIn.NotifyList, &NewNotify->NotifyEntry);\r | |
3876 | \r | |
3877 | *NotifyHandle = NewNotify->NotifyHandle;\r | |
3878 | \r | |
3879 | return EFI_SUCCESS;\r | |
3880 | \r | |
3881 | }\r | |
3882 | \r | |
3883 | \r | |
3884 | /**\r | |
3885 | Remove a registered notification function from a particular keystroke.\r | |
3886 | \r | |
3887 | @param This Protocol instance pointer.\r | |
3888 | @param NotificationHandle The handle of the notification function being\r | |
3889 | unregistered.\r | |
3890 | \r | |
3891 | @retval EFI_SUCCESS The notification function was unregistered\r | |
3892 | successfully.\r | |
3893 | @retval EFI_INVALID_PARAMETER The NotificationHandle is invalid.\r | |
3894 | @retval EFI_NOT_FOUND Can not find the matching entry in database.\r | |
3895 | \r | |
3896 | **/\r | |
3897 | EFI_STATUS\r | |
3898 | EFIAPI\r | |
3899 | ConSplitterTextInUnregisterKeyNotify (\r | |
3900 | IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,\r | |
3901 | IN EFI_HANDLE NotificationHandle\r | |
3902 | )\r | |
3903 | {\r | |
3904 | TEXT_IN_SPLITTER_PRIVATE_DATA *Private;\r | |
3905 | EFI_STATUS Status;\r | |
3906 | UINTN Index;\r | |
3907 | TEXT_IN_EX_SPLITTER_NOTIFY *CurrentNotify;\r | |
3908 | LIST_ENTRY *Link;\r | |
3909 | \r | |
3910 | if (NotificationHandle == NULL) {\r | |
3911 | return EFI_INVALID_PARAMETER;\r | |
3912 | }\r | |
3913 | \r | |
3914 | if (((TEXT_IN_EX_SPLITTER_NOTIFY *) NotificationHandle)->Signature != TEXT_IN_EX_SPLITTER_NOTIFY_SIGNATURE) {\r | |
3915 | return EFI_INVALID_PARAMETER;\r | |
3916 | } \r | |
3917 | \r | |
3918 | Private = TEXT_IN_EX_SPLITTER_PRIVATE_DATA_FROM_THIS (This);\r | |
3919 | \r | |
3920 | //\r | |
3921 | // if no physical console input device exists,\r | |
3922 | // return EFI_SUCCESS directly.\r | |
3923 | //\r | |
3924 | if (Private->CurrentNumberOfExConsoles <= 0) {\r | |
3925 | return EFI_SUCCESS;\r | |
3926 | }\r | |
3927 | \r | |
3928 | for (Link = Private->NotifyList.ForwardLink; Link != &Private->NotifyList; Link = Link->ForwardLink) {\r | |
3929 | CurrentNotify = TEXT_IN_EX_SPLITTER_NOTIFY_FROM_THIS (Link);\r | |
3930 | if (CurrentNotify->NotifyHandle == NotificationHandle) {\r | |
3931 | for (Index = 0; Index < Private->CurrentNumberOfExConsoles; Index++) {\r | |
3932 | Status = Private->TextInExList[Index]->UnregisterKeyNotify (\r | |
3933 | Private->TextInExList[Index],\r | |
3934 | CurrentNotify->NotifyHandleList[Index]\r | |
3935 | );\r | |
3936 | if (EFI_ERROR (Status)) {\r | |
3937 | return Status;\r | |
3938 | }\r | |
3939 | }\r | |
3940 | RemoveEntryList (&CurrentNotify->NotifyEntry);\r | |
3941 | \r | |
3942 | gBS->FreePool (CurrentNotify->NotifyHandleList);\r | |
3943 | gBS->FreePool (CurrentNotify);\r | |
3944 | return EFI_SUCCESS;\r | |
3945 | }\r | |
3946 | }\r | |
3947 | \r | |
3948 | return EFI_NOT_FOUND;\r | |
3949 | \r | |
3950 | }\r | |
3951 | \r | |
3952 | \r | |
3953 | /**\r | |
3954 | Reset the input device and optionaly run diagnostics\r | |
3955 | \r | |
3956 | @param This Protocol instance pointer.\r | |
3957 | @param ExtendedVerification Driver may perform diagnostics on reset.\r | |
3958 | \r | |
3959 | @retval EFI_SUCCESS The device was reset.\r | |
3960 | @retval EFI_DEVICE_ERROR The device is not functioning properly and could\r | |
3961 | not be reset.\r | |
3962 | \r | |
3963 | **/\r | |
3964 | EFI_STATUS\r | |
3965 | EFIAPI\r | |
3966 | ConSplitterSimplePointerReset (\r | |
3967 | IN EFI_SIMPLE_POINTER_PROTOCOL *This,\r | |
3968 | IN BOOLEAN ExtendedVerification\r | |
3969 | )\r | |
3970 | {\r | |
3971 | EFI_STATUS Status;\r | |
3972 | EFI_STATUS ReturnStatus;\r | |
3973 | TEXT_IN_SPLITTER_PRIVATE_DATA *Private;\r | |
3974 | UINTN Index;\r | |
3975 | \r | |
3976 | Private = TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_SIMPLE_POINTER_THIS (This);\r | |
3977 | \r | |
3978 | Private->InputEventSignalState = FALSE;\r | |
3979 | \r | |
3980 | if (Private->CurrentNumberOfPointers == 0) {\r | |
3981 | return EFI_SUCCESS;\r | |
3982 | }\r | |
3983 | //\r | |
3984 | // return the worst status met\r | |
3985 | //\r | |
3986 | for (Index = 0, ReturnStatus = EFI_SUCCESS; Index < Private->CurrentNumberOfPointers; Index++) {\r | |
3987 | Status = Private->PointerList[Index]->Reset (\r | |
3988 | Private->PointerList[Index],\r | |
3989 | ExtendedVerification\r | |
3990 | );\r | |
3991 | if (EFI_ERROR (Status)) {\r | |
3992 | ReturnStatus = Status;\r | |
3993 | }\r | |
3994 | }\r | |
3995 | \r | |
3996 | return ReturnStatus;\r | |
3997 | }\r | |
3998 | \r | |
3999 | \r | |
4000 | /**\r | |
4001 | Reads the next keystroke from the input device. The WaitForKey Event can\r | |
4002 | be used to test for existance of a keystroke via WaitForEvent () call.\r | |
4003 | \r | |
4004 | @param Private Protocol instance pointer.\r | |
4005 | @param State The state information of simple pointer device.\r | |
4006 | \r | |
4007 | @retval EFI_SUCCESS The keystroke information was returned.\r | |
4008 | @retval EFI_NOT_READY There was no keystroke data availiable.\r | |
4009 | @retval EFI_DEVICE_ERROR The keydtroke information was not returned due\r | |
4010 | to hardware errors.\r | |
4011 | \r | |
4012 | **/\r | |
4013 | EFI_STATUS\r | |
4014 | EFIAPI\r | |
4015 | ConSplitterSimplePointerPrivateGetState (\r | |
4016 | IN TEXT_IN_SPLITTER_PRIVATE_DATA *Private,\r | |
4017 | IN OUT EFI_SIMPLE_POINTER_STATE *State\r | |
4018 | )\r | |
4019 | {\r | |
4020 | EFI_STATUS Status;\r | |
4021 | EFI_STATUS ReturnStatus;\r | |
4022 | UINTN Index;\r | |
4023 | EFI_SIMPLE_POINTER_STATE CurrentState;\r | |
4024 | \r | |
4025 | State->RelativeMovementX = 0;\r | |
4026 | State->RelativeMovementY = 0;\r | |
4027 | State->RelativeMovementZ = 0;\r | |
4028 | State->LeftButton = FALSE;\r | |
4029 | State->RightButton = FALSE;\r | |
4030 | \r | |
4031 | //\r | |
4032 | // if no physical console input device exists, return EFI_NOT_READY;\r | |
4033 | // if any physical console input device has key input,\r | |
4034 | // return the key and EFI_SUCCESS.\r | |
4035 | //\r | |
4036 | ReturnStatus = EFI_NOT_READY;\r | |
4037 | for (Index = 0; Index < Private->CurrentNumberOfPointers; Index++) {\r | |
4038 | \r | |
4039 | Status = Private->PointerList[Index]->GetState (\r | |
4040 | Private->PointerList[Index],\r | |
4041 | &CurrentState\r | |
4042 | );\r | |
4043 | if (!EFI_ERROR (Status)) {\r | |
4044 | if (ReturnStatus == EFI_NOT_READY) {\r | |
4045 | ReturnStatus = EFI_SUCCESS;\r | |
4046 | }\r | |
4047 | \r | |
4048 | if (CurrentState.LeftButton) {\r | |
4049 | State->LeftButton = TRUE;\r | |
4050 | }\r | |
4051 | \r | |
4052 | if (CurrentState.RightButton) {\r | |
4053 | State->RightButton = TRUE;\r | |
4054 | }\r | |
4055 | \r | |
4056 | if (CurrentState.RelativeMovementX != 0 && Private->PointerList[Index]->Mode->ResolutionX != 0) {\r | |
4057 | State->RelativeMovementX += (CurrentState.RelativeMovementX * (INT32) Private->SimplePointerMode.ResolutionX) / (INT32) Private->PointerList[Index]->Mode->ResolutionX;\r | |
4058 | }\r | |
4059 | \r | |
4060 | if (CurrentState.RelativeMovementY != 0 && Private->PointerList[Index]->Mode->ResolutionY != 0) {\r | |
4061 | State->RelativeMovementY += (CurrentState.RelativeMovementY * (INT32) Private->SimplePointerMode.ResolutionY) / (INT32) Private->PointerList[Index]->Mode->ResolutionY;\r | |
4062 | }\r | |
4063 | \r | |
4064 | if (CurrentState.RelativeMovementZ != 0 && Private->PointerList[Index]->Mode->ResolutionZ != 0) {\r | |
4065 | State->RelativeMovementZ += (CurrentState.RelativeMovementZ * (INT32) Private->SimplePointerMode.ResolutionZ) / (INT32) Private->PointerList[Index]->Mode->ResolutionZ;\r | |
4066 | }\r | |
4067 | } else if (Status == EFI_DEVICE_ERROR) {\r | |
4068 | ReturnStatus = EFI_DEVICE_ERROR;\r | |
4069 | }\r | |
4070 | }\r | |
4071 | \r | |
4072 | return ReturnStatus;\r | |
4073 | }\r | |
4074 | \r | |
4075 | \r | |
4076 | /**\r | |
4077 | Reads the next keystroke from the input device. The WaitForKey Event can\r | |
4078 | be used to test for existance of a keystroke via WaitForEvent () call.\r | |
4079 | If the ConIn is password locked make it look like no keystroke is availible\r | |
4080 | \r | |
4081 | @param This A pointer to protocol instance.\r | |
4082 | @param State A pointer to state information on the pointer device\r | |
4083 | \r | |
4084 | @retval EFI_SUCCESS The keystroke information was returned in State.\r | |
4085 | @retval EFI_NOT_READY There was no keystroke data availiable.\r | |
4086 | @retval EFI_DEVICE_ERROR The keydtroke information was not returned due\r | |
4087 | to hardware errors.\r | |
4088 | \r | |
4089 | **/\r | |
4090 | EFI_STATUS\r | |
4091 | EFIAPI\r | |
4092 | ConSplitterSimplePointerGetState (\r | |
4093 | IN EFI_SIMPLE_POINTER_PROTOCOL *This,\r | |
4094 | IN OUT EFI_SIMPLE_POINTER_STATE *State\r | |
4095 | )\r | |
4096 | {\r | |
4097 | TEXT_IN_SPLITTER_PRIVATE_DATA *Private;\r | |
4098 | \r | |
4099 | Private = TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_SIMPLE_POINTER_THIS (This);\r | |
4100 | if (Private->PasswordEnabled) {\r | |
4101 | //\r | |
4102 | // If StdIn Locked return not ready\r | |
4103 | //\r | |
4104 | return EFI_NOT_READY;\r | |
4105 | }\r | |
4106 | \r | |
4107 | Private->InputEventSignalState = FALSE;\r | |
4108 | \r | |
4109 | return ConSplitterSimplePointerPrivateGetState (Private, State);\r | |
4110 | }\r | |
4111 | \r | |
4112 | \r | |
4113 | /**\r | |
4114 | This event agregates all the events of the ConIn devices in the spliter.\r | |
4115 | If the ConIn is password locked then return.\r | |
4116 | If any events of physical ConIn devices are signaled, signal the ConIn\r | |
4117 | spliter event. This will cause the calling code to call\r | |
4118 | ConSplitterTextInReadKeyStroke ().\r | |
4119 | \r | |
4120 | @param Event The Event assoicated with callback.\r | |
4121 | @param Context Context registered when Event was created.\r | |
4122 | \r | |
4123 | **/\r | |
4124 | VOID\r | |
4125 | EFIAPI\r | |
4126 | ConSplitterSimplePointerWaitForInput (\r | |
4127 | IN EFI_EVENT Event,\r | |
4128 | IN VOID *Context\r | |
4129 | )\r | |
4130 | {\r | |
4131 | EFI_STATUS Status;\r | |
4132 | TEXT_IN_SPLITTER_PRIVATE_DATA *Private;\r | |
4133 | UINTN Index;\r | |
4134 | \r | |
4135 | Private = (TEXT_IN_SPLITTER_PRIVATE_DATA *) Context;\r | |
4136 | if (Private->PasswordEnabled) {\r | |
4137 | //\r | |
4138 | // If StdIn Locked return not ready\r | |
4139 | //\r | |
4140 | return ;\r | |
4141 | }\r | |
4142 | \r | |
4143 | //\r | |
4144 | // if InputEventSignalState is flagged before, and not cleared by Reset() or ReadKeyStroke()\r | |
4145 | //\r | |
4146 | if (Private->InputEventSignalState) {\r | |
4147 | gBS->SignalEvent (Event);\r | |
4148 | return ;\r | |
4149 | }\r | |
4150 | //\r | |
4151 | // if any physical console input device has key input, signal the event.\r | |
4152 | //\r | |
4153 | for (Index = 0; Index < Private->CurrentNumberOfPointers; Index++) {\r | |
4154 | Status = gBS->CheckEvent (Private->PointerList[Index]->WaitForInput);\r | |
4155 | if (!EFI_ERROR (Status)) {\r | |
4156 | gBS->SignalEvent (Event);\r | |
4157 | Private->InputEventSignalState = TRUE;\r | |
4158 | }\r | |
4159 | }\r | |
4160 | }\r | |
4161 | \r | |
4162 | /**\r | |
4163 | Resets the pointer device hardware.\r | |
4164 | \r | |
4165 | @param This Protocol instance pointer.\r | |
4166 | @param ExtendedVerification Driver may perform diagnostics on reset.\r | |
4167 | \r | |
4168 | @retval EFI_SUCCESS The device was reset.\r | |
4169 | @retval EFI_DEVICE_ERROR The device is not functioning correctly and\r | |
4170 | could not be reset.\r | |
4171 | \r | |
4172 | **/\r | |
4173 | EFI_STATUS\r | |
4174 | EFIAPI\r | |
4175 | ConSplitterAbsolutePointerReset (\r | |
4176 | IN EFI_ABSOLUTE_POINTER_PROTOCOL *This,\r | |
4177 | IN BOOLEAN ExtendedVerification\r | |
4178 | )\r | |
4179 | {\r | |
4180 | EFI_STATUS Status;\r | |
4181 | EFI_STATUS ReturnStatus;\r | |
4182 | TEXT_IN_SPLITTER_PRIVATE_DATA *Private;\r | |
4183 | UINTN Index;\r | |
4184 | \r | |
4185 | Private = TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_ABSOLUTE_POINTER_THIS (This);\r | |
4186 | \r | |
4187 | Private->AbsoluteInputEventSignalState = FALSE;\r | |
4188 | \r | |
4189 | if (Private->CurrentNumberOfAbsolutePointers == 0) {\r | |
4190 | return EFI_SUCCESS;\r | |
4191 | }\r | |
4192 | //\r | |
4193 | // return the worst status met\r | |
4194 | //\r | |
4195 | for (Index = 0, ReturnStatus = EFI_SUCCESS; Index < Private->CurrentNumberOfAbsolutePointers; Index++) {\r | |
4196 | Status = Private->AbsolutePointerList[Index]->Reset (\r | |
4197 | Private->AbsolutePointerList[Index],\r | |
4198 | ExtendedVerification\r | |
4199 | );\r | |
4200 | if (EFI_ERROR (Status)) {\r | |
4201 | ReturnStatus = Status;\r | |
4202 | }\r | |
4203 | }\r | |
4204 | \r | |
4205 | return ReturnStatus;\r | |
4206 | }\r | |
4207 | \r | |
4208 | \r | |
4209 | /**\r | |
4210 | Retrieves the current state of a pointer device.\r | |
4211 | \r | |
4212 | @param This Protocol instance pointer.\r | |
4213 | @param State A pointer to the state information on the\r | |
4214 | pointer device.\r | |
4215 | \r | |
4216 | @retval EFI_SUCCESS The state of the pointer device was returned in\r | |
4217 | State..\r | |
4218 | @retval EFI_NOT_READY The state of the pointer device has not changed\r | |
4219 | since the last call to GetState().\r | |
4220 | @retval EFI_DEVICE_ERROR A device error occurred while attempting to\r | |
4221 | retrieve the pointer device's current state.\r | |
4222 | \r | |
4223 | **/\r | |
4224 | EFI_STATUS\r | |
4225 | EFIAPI\r | |
4226 | ConSplitterAbsolutePointerGetState (\r | |
4227 | IN EFI_ABSOLUTE_POINTER_PROTOCOL *This,\r | |
4228 | IN OUT EFI_ABSOLUTE_POINTER_STATE *State\r | |
4229 | )\r | |
4230 | {\r | |
4231 | TEXT_IN_SPLITTER_PRIVATE_DATA *Private;\r | |
4232 | EFI_STATUS Status;\r | |
4233 | EFI_STATUS ReturnStatus;\r | |
4234 | UINTN Index;\r | |
4235 | EFI_ABSOLUTE_POINTER_STATE CurrentState;\r | |
4236 | \r | |
4237 | \r | |
4238 | Private = TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_ABSOLUTE_POINTER_THIS (This);\r | |
4239 | if (Private->PasswordEnabled) {\r | |
4240 | //\r | |
4241 | // If StdIn Locked return not ready\r | |
4242 | //\r | |
4243 | return EFI_NOT_READY;\r | |
4244 | }\r | |
4245 | \r | |
4246 | Private->AbsoluteInputEventSignalState = FALSE;\r | |
4247 | \r | |
4248 | State->CurrentX = 0;\r | |
4249 | State->CurrentY = 0;\r | |
4250 | State->CurrentZ = 0;\r | |
4251 | State->ActiveButtons = 0;\r | |
4252 | \r | |
4253 | //\r | |
4254 | // if no physical pointer device exists, return EFI_NOT_READY;\r | |
4255 | // if any physical pointer device has changed state,\r | |
4256 | // return the state and EFI_SUCCESS.\r | |
4257 | //\r | |
4258 | ReturnStatus = EFI_NOT_READY;\r | |
4259 | for (Index = 0; Index < Private->CurrentNumberOfAbsolutePointers; Index++) {\r | |
4260 | \r | |
4261 | Status = Private->AbsolutePointerList[Index]->GetState (\r | |
4262 | Private->AbsolutePointerList[Index],\r | |
4263 | &CurrentState\r | |
4264 | );\r | |
4265 | if (!EFI_ERROR (Status)) {\r | |
4266 | if (ReturnStatus == EFI_NOT_READY) {\r | |
4267 | ReturnStatus = EFI_SUCCESS;\r | |
4268 | }\r | |
4269 | \r | |
4270 | State->ActiveButtons = CurrentState.ActiveButtons;\r | |
4271 | \r | |
4272 | if (!(Private->AbsolutePointerMode.AbsoluteMinX == 0 && Private->AbsolutePointerMode.AbsoluteMaxX == 0)) {\r | |
4273 | State->CurrentX = CurrentState.CurrentX;\r | |
4274 | }\r | |
4275 | if (!(Private->AbsolutePointerMode.AbsoluteMinY == 0 && Private->AbsolutePointerMode.AbsoluteMaxY == 0)) {\r | |
4276 | State->CurrentY = CurrentState.CurrentY;\r | |
4277 | }\r | |
4278 | if (!(Private->AbsolutePointerMode.AbsoluteMinZ == 0 && Private->AbsolutePointerMode.AbsoluteMaxZ == 0)) {\r | |
4279 | State->CurrentZ = CurrentState.CurrentZ;\r | |
4280 | }\r | |
4281 | \r | |
4282 | } else if (Status == EFI_DEVICE_ERROR) {\r | |
4283 | ReturnStatus = EFI_DEVICE_ERROR;\r | |
4284 | }\r | |
4285 | }\r | |
4286 | \r | |
4287 | return ReturnStatus;\r | |
4288 | }\r | |
4289 | \r | |
4290 | \r | |
4291 | /**\r | |
4292 | This event agregates all the events of the pointer devices in the splitter.\r | |
4293 | If the ConIn is password locked then return.\r | |
4294 | If any events of physical pointer devices are signaled, signal the pointer\r | |
4295 | splitter event. This will cause the calling code to call\r | |
4296 | ConSplitterAbsolutePointerGetState ().\r | |
4297 | \r | |
4298 | @param Event The Event assoicated with callback.\r | |
4299 | @param Context Context registered when Event was created.\r | |
4300 | \r | |
4301 | **/\r | |
4302 | VOID\r | |
4303 | EFIAPI\r | |
4304 | ConSplitterAbsolutePointerWaitForInput (\r | |
4305 | IN EFI_EVENT Event,\r | |
4306 | IN VOID *Context\r | |
4307 | )\r | |
4308 | {\r | |
4309 | EFI_STATUS Status;\r | |
4310 | TEXT_IN_SPLITTER_PRIVATE_DATA *Private;\r | |
4311 | UINTN Index;\r | |
4312 | \r | |
4313 | Private = (TEXT_IN_SPLITTER_PRIVATE_DATA *) Context;\r | |
4314 | if (Private->PasswordEnabled) {\r | |
4315 | //\r | |
4316 | // If StdIn Locked return not ready\r | |
4317 | //\r | |
4318 | return ;\r | |
4319 | }\r | |
4320 | \r | |
4321 | //\r | |
4322 | // if AbsoluteInputEventSignalState is flagged before,\r | |
4323 | // and not cleared by Reset() or GetState(), signal it\r | |
4324 | //\r | |
4325 | if (Private->AbsoluteInputEventSignalState) {\r | |
4326 | gBS->SignalEvent (Event);\r | |
4327 | return ;\r | |
4328 | }\r | |
4329 | //\r | |
4330 | // if any physical console input device has key input, signal the event.\r | |
4331 | //\r | |
4332 | for (Index = 0; Index < Private->CurrentNumberOfAbsolutePointers; Index++) {\r | |
4333 | Status = gBS->CheckEvent (Private->AbsolutePointerList[Index]->WaitForInput);\r | |
4334 | if (!EFI_ERROR (Status)) {\r | |
4335 | gBS->SignalEvent (Event);\r | |
4336 | Private->AbsoluteInputEventSignalState = TRUE;\r | |
4337 | }\r | |
4338 | }\r | |
4339 | }\r | |
4340 | \r | |
4341 | \r | |
4342 | /**\r | |
4343 | Reset the text output device hardware and optionaly run diagnostics\r | |
4344 | \r | |
4345 | @param This Protocol instance pointer.\r | |
4346 | @param ExtendedVerification Driver may perform more exhaustive verfication\r | |
4347 | operation of the device during reset.\r | |
4348 | \r | |
4349 | @retval EFI_SUCCESS The text output device was reset.\r | |
4350 | @retval EFI_DEVICE_ERROR The text output device is not functioning\r | |
4351 | correctly and could not be reset.\r | |
4352 | \r | |
4353 | **/\r | |
4354 | EFI_STATUS\r | |
4355 | EFIAPI\r | |
4356 | ConSplitterTextOutReset (\r | |
4357 | IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r | |
4358 | IN BOOLEAN ExtendedVerification\r | |
4359 | )\r | |
4360 | {\r | |
4361 | EFI_STATUS Status;\r | |
4362 | TEXT_OUT_SPLITTER_PRIVATE_DATA *Private;\r | |
4363 | UINTN Index;\r | |
4364 | EFI_STATUS ReturnStatus;\r | |
4365 | \r | |
4366 | Private = TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This);\r | |
4367 | \r | |
4368 | //\r | |
4369 | // return the worst status met\r | |
4370 | //\r | |
4371 | for (Index = 0, ReturnStatus = EFI_SUCCESS; Index < Private->CurrentNumberOfConsoles; Index++) {\r | |
4372 | \r | |
4373 | if (Private->TextOutList[Index].TextOutEnabled) {\r | |
4374 | \r | |
4375 | Status = Private->TextOutList[Index].TextOut->Reset (\r | |
4376 | Private->TextOutList[Index].TextOut,\r | |
4377 | ExtendedVerification\r | |
4378 | );\r | |
4379 | if (EFI_ERROR (Status)) {\r | |
4380 | ReturnStatus = Status;\r | |
4381 | }\r | |
4382 | }\r | |
4383 | }\r | |
4384 | \r | |
4385 | This->SetAttribute (This, EFI_TEXT_ATTR (This->Mode->Attribute & 0x0F, EFI_BLACK));\r | |
4386 | \r | |
4387 | Status = DevNullTextOutSetMode (Private, 0);\r | |
4388 | if (EFI_ERROR (Status)) {\r | |
4389 | ReturnStatus = Status;\r | |
4390 | }\r | |
4391 | \r | |
4392 | return ReturnStatus;\r | |
4393 | }\r | |
4394 | \r | |
4395 | \r | |
4396 | /**\r | |
4397 | Write a Unicode string to the output device.\r | |
4398 | \r | |
4399 | @param This Protocol instance pointer.\r | |
4400 | @param WString The NULL-terminated Unicode string to be\r | |
4401 | displayed on the output device(s). All output\r | |
4402 | devices must also support the Unicode drawing\r | |
4403 | defined in this file.\r | |
4404 | \r | |
4405 | @retval EFI_SUCCESS The string was output to the device.\r | |
4406 | @retval EFI_DEVICE_ERROR The device reported an error while attempting to\r | |
4407 | output the text.\r | |
4408 | @retval EFI_UNSUPPORTED The output device's mode is not currently in a\r | |
4409 | defined text mode.\r | |
4410 | @retval EFI_WARN_UNKNOWN_GLYPH This warning code indicates that some of the\r | |
4411 | characters in the Unicode string could not be\r | |
4412 | rendered and were skipped.\r | |
4413 | \r | |
4414 | **/\r | |
4415 | EFI_STATUS\r | |
4416 | EFIAPI\r | |
4417 | ConSplitterTextOutOutputString (\r | |
4418 | IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r | |
4419 | IN CHAR16 *WString\r | |
4420 | )\r | |
4421 | {\r | |
4422 | EFI_STATUS Status;\r | |
4423 | TEXT_OUT_SPLITTER_PRIVATE_DATA *Private;\r | |
4424 | UINTN Index;\r | |
4425 | UINTN BackSpaceCount;\r | |
4426 | EFI_STATUS ReturnStatus;\r | |
4427 | CHAR16 *TargetString;\r | |
4428 | \r | |
4429 | This->SetAttribute (This, This->Mode->Attribute);\r | |
4430 | \r | |
4431 | Private = TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This);\r | |
4432 | \r | |
4433 | BackSpaceCount = 0;\r | |
4434 | for (TargetString = WString; *TargetString != L'\0'; TargetString++) {\r | |
4435 | if (*TargetString == CHAR_BACKSPACE) {\r | |
4436 | BackSpaceCount++;\r | |
4437 | }\r | |
4438 | \r | |
4439 | }\r | |
4440 | \r | |
4441 | if (BackSpaceCount == 0) {\r | |
4442 | TargetString = WString;\r | |
4443 | } else {\r | |
4444 | TargetString = AllocatePool (sizeof (CHAR16) * (StrLen (WString) + BackSpaceCount + 1));\r | |
4445 | ASSERT (TargetString != NULL);\r | |
4446 | \r | |
4447 | StrCpy (TargetString, WString);\r | |
4448 | }\r | |
4449 | //\r | |
4450 | // return the worst status met\r | |
4451 | //\r | |
4452 | Status = DevNullTextOutOutputString (Private, TargetString);\r | |
4453 | if (EFI_ERROR (Status)) {\r | |
4454 | ReturnStatus = Status;\r | |
4455 | }\r | |
4456 | \r | |
4457 | for (Index = 0, ReturnStatus = EFI_SUCCESS; Index < Private->CurrentNumberOfConsoles; Index++) {\r | |
4458 | \r | |
4459 | if (Private->TextOutList[Index].TextOutEnabled) {\r | |
4460 | Status = Private->TextOutList[Index].TextOut->OutputString (\r | |
4461 | Private->TextOutList[Index].TextOut,\r | |
4462 | TargetString\r | |
4463 | );\r | |
4464 | if (EFI_ERROR (Status)) {\r | |
4465 | ReturnStatus = Status;\r | |
4466 | }\r | |
4467 | }\r | |
4468 | }\r | |
4469 | \r | |
4470 | if (BackSpaceCount > 0) {\r | |
4471 | FreePool (TargetString);\r | |
4472 | }\r | |
4473 | \r | |
4474 | return ReturnStatus;\r | |
4475 | }\r | |
4476 | \r | |
4477 | \r | |
4478 | /**\r | |
4479 | Verifies that all characters in a Unicode string can be output to the\r | |
4480 | target device.\r | |
4481 | \r | |
4482 | @param This Protocol instance pointer.\r | |
4483 | @param WString The NULL-terminated Unicode string to be\r | |
4484 | examined for the output device(s).\r | |
4485 | \r | |
4486 | @retval EFI_SUCCESS The device(s) are capable of rendering the\r | |
4487 | output string.\r | |
4488 | @retval EFI_UNSUPPORTED Some of the characters in the Unicode string\r | |
4489 | cannot be rendered by one or more of the output\r | |
4490 | devices mapped by the EFI handle.\r | |
4491 | \r | |
4492 | **/\r | |
4493 | EFI_STATUS\r | |
4494 | EFIAPI\r | |
4495 | ConSplitterTextOutTestString (\r | |
4496 | IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r | |
4497 | IN CHAR16 *WString\r | |
4498 | )\r | |
4499 | {\r | |
4500 | EFI_STATUS Status;\r | |
4501 | TEXT_OUT_SPLITTER_PRIVATE_DATA *Private;\r | |
4502 | UINTN Index;\r | |
4503 | EFI_STATUS ReturnStatus;\r | |
4504 | \r | |
4505 | Private = TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This);\r | |
4506 | \r | |
4507 | //\r | |
4508 | // return the worst status met\r | |
4509 | //\r | |
4510 | for (Index = 0, ReturnStatus = EFI_SUCCESS; Index < Private->CurrentNumberOfConsoles; Index++) {\r | |
4511 | if (Private->TextOutList[Index].TextOutEnabled) {\r | |
4512 | Status = Private->TextOutList[Index].TextOut->TestString (\r | |
4513 | Private->TextOutList[Index].TextOut,\r | |
4514 | WString\r | |
4515 | );\r | |
4516 | if (EFI_ERROR (Status)) {\r | |
4517 | ReturnStatus = Status;\r | |
4518 | }\r | |
4519 | }\r | |
4520 | }\r | |
4521 | //\r | |
4522 | // There is no DevNullTextOutTestString () since a Unicode buffer would\r | |
4523 | // always return EFI_SUCCESS.\r | |
4524 | // ReturnStatus will be EFI_SUCCESS if no consoles are present\r | |
4525 | //\r | |
4526 | return ReturnStatus;\r | |
4527 | }\r | |
4528 | \r | |
4529 | \r | |
4530 | /**\r | |
4531 | Returns information for an available text mode that the output device(s)\r | |
4532 | supports.\r | |
4533 | \r | |
4534 | @param This Protocol instance pointer.\r | |
4535 | @param ModeNumber The mode number to return information on.\r | |
4536 | @param Columns Returns the columns of the text output device\r | |
4537 | for the requested ModeNumber.\r | |
4538 | @param Rows Returns the rows of the text output device\r | |
4539 | for the requested ModeNumber.\r | |
4540 | \r | |
4541 | @retval EFI_SUCCESS The requested mode information was returned.\r | |
4542 | @retval EFI_DEVICE_ERROR The device had an error and could not complete\r | |
4543 | the request.\r | |
4544 | @retval EFI_UNSUPPORTED The mode number was not valid.\r | |
4545 | \r | |
4546 | **/\r | |
4547 | EFI_STATUS\r | |
4548 | EFIAPI\r | |
4549 | ConSplitterTextOutQueryMode (\r | |
4550 | IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r | |
4551 | IN UINTN ModeNumber,\r | |
4552 | OUT UINTN *Columns,\r | |
4553 | OUT UINTN *Rows\r | |
4554 | )\r | |
4555 | {\r | |
4556 | TEXT_OUT_SPLITTER_PRIVATE_DATA *Private;\r | |
4557 | UINTN CurrentMode;\r | |
4558 | INT32 *TextOutModeMap;\r | |
4559 | \r | |
4560 | Private = TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This);\r | |
4561 | \r | |
4562 | //\r | |
4563 | // Check whether param ModeNumber is valid.\r | |
4564 | // ModeNumber should be within range 0 ~ MaxMode - 1.\r | |
4565 | //\r | |
4566 | if ( (ModeNumber > (UINTN)(((UINT32)-1)>>1)) ) {\r | |
4567 | return EFI_UNSUPPORTED;\r | |
4568 | }\r | |
4569 | \r | |
4570 | if ((INT32) ModeNumber >= This->Mode->MaxMode) {\r | |
4571 | return EFI_UNSUPPORTED;\r | |
4572 | }\r | |
4573 | \r | |
4574 | //\r | |
4575 | // We get the available mode from mode intersection map if it's available\r | |
4576 | //\r | |
4577 | if (Private->TextOutModeMap != NULL) {\r | |
4578 | TextOutModeMap = Private->TextOutModeMap + Private->TextOutListCount * ModeNumber;\r | |
4579 | CurrentMode = (UINTN)(*TextOutModeMap);\r | |
4580 | *Columns = Private->TextOutQueryData[CurrentMode].Columns;\r | |
4581 | *Rows = Private->TextOutQueryData[CurrentMode].Rows;\r | |
4582 | } else {\r | |
4583 | *Columns = Private->TextOutQueryData[ModeNumber].Columns;\r | |
4584 | *Rows = Private->TextOutQueryData[ModeNumber].Rows;\r | |
4585 | }\r | |
4586 | \r | |
4587 | if (*Columns <= 0 && *Rows <= 0) {\r | |
4588 | return EFI_UNSUPPORTED;\r | |
4589 | \r | |
4590 | }\r | |
4591 | \r | |
4592 | return EFI_SUCCESS;\r | |
4593 | }\r | |
4594 | \r | |
4595 | \r | |
4596 | /**\r | |
4597 | Sets the output device(s) to a specified mode.\r | |
4598 | \r | |
4599 | @param This Protocol instance pointer.\r | |
4600 | @param ModeNumber The mode number to set.\r | |
4601 | \r | |
4602 | @retval EFI_SUCCESS The requested text mode was set.\r | |
4603 | @retval EFI_DEVICE_ERROR The device had an error and could not complete\r | |
4604 | the request.\r | |
4605 | @retval EFI_UNSUPPORTED The mode number was not valid.\r | |
4606 | \r | |
4607 | **/\r | |
4608 | EFI_STATUS\r | |
4609 | EFIAPI\r | |
4610 | ConSplitterTextOutSetMode (\r | |
4611 | IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r | |
4612 | IN UINTN ModeNumber\r | |
4613 | )\r | |
4614 | {\r | |
4615 | EFI_STATUS Status;\r | |
4616 | TEXT_OUT_SPLITTER_PRIVATE_DATA *Private;\r | |
4617 | UINTN Index;\r | |
4618 | INT32 *TextOutModeMap;\r | |
4619 | EFI_STATUS ReturnStatus;\r | |
4620 | \r | |
4621 | Private = TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This);\r | |
4622 | \r | |
4623 | //\r | |
4624 | // Check whether param ModeNumber is valid.\r | |
4625 | // ModeNumber should be within range 0 ~ MaxMode - 1.\r | |
4626 | //\r | |
4627 | if ( (ModeNumber > (UINTN)(((UINT32)-1)>>1)) ) {\r | |
4628 | return EFI_UNSUPPORTED;\r | |
4629 | }\r | |
4630 | \r | |
4631 | if ((INT32) ModeNumber >= This->Mode->MaxMode) {\r | |
4632 | return EFI_UNSUPPORTED;\r | |
4633 | }\r | |
4634 | //\r | |
4635 | // If the mode is being set to the curent mode, then just clear the screen and return.\r | |
4636 | //\r | |
4637 | if (Private->TextOutMode.Mode == (INT32) ModeNumber) {\r | |
4638 | return ConSplitterTextOutClearScreen (This);\r | |
4639 | }\r | |
4640 | //\r | |
4641 | // return the worst status met\r | |
4642 | //\r | |
4643 | TextOutModeMap = Private->TextOutModeMap + Private->TextOutListCount * ModeNumber;\r | |
4644 | for (Index = 0, ReturnStatus = EFI_SUCCESS; Index < Private->CurrentNumberOfConsoles; Index++) {\r | |
4645 | \r | |
4646 | if (Private->TextOutList[Index].TextOutEnabled) {\r | |
4647 | Status = Private->TextOutList[Index].TextOut->SetMode (\r | |
4648 | Private->TextOutList[Index].TextOut,\r | |
4649 | TextOutModeMap[Index]\r | |
4650 | );\r | |
4651 | //\r | |
4652 | // If this console device is based on a GOP or UGA device, then sync up the bitmap from\r | |
4653 | // the GOP/UGA splitter and reclear the text portion of the display in the new mode.\r | |
4654 | //\r | |
4655 | if ((Private->TextOutList[Index].GraphicsOutput != NULL) || (Private->TextOutList[Index].UgaDraw != NULL)) {\r | |
4656 | Private->TextOutList[Index].TextOut->ClearScreen (Private->TextOutList[Index].TextOut);\r | |
4657 | }\r | |
4658 | \r | |
4659 | if (EFI_ERROR (Status)) {\r | |
4660 | ReturnStatus = Status;\r | |
4661 | }\r | |
4662 | }\r | |
4663 | }\r | |
4664 | //\r | |
4665 | // The DevNull Console will support any possible mode as it allocates memory\r | |
4666 | //\r | |
4667 | Status = DevNullTextOutSetMode (Private, ModeNumber);\r | |
4668 | if (EFI_ERROR (Status)) {\r | |
4669 | ReturnStatus = Status;\r | |
4670 | }\r | |
4671 | \r | |
4672 | return ReturnStatus;\r | |
4673 | }\r | |
4674 | \r | |
4675 | \r | |
4676 | /**\r | |
4677 | Sets the background and foreground colors for the OutputString () and\r | |
4678 | ClearScreen () functions.\r | |
4679 | \r | |
4680 | @param This Protocol instance pointer.\r | |
4681 | @param Attribute The attribute to set. Bits 0..3 are the\r | |
4682 | foreground color, and bits 4..6 are the\r | |
4683 | background color. All other bits are undefined\r | |
4684 | and must be zero. The valid Attributes are\r | |
4685 | defined in this file.\r | |
4686 | \r | |
4687 | @retval EFI_SUCCESS The attribute was set.\r | |
4688 | @retval EFI_DEVICE_ERROR The device had an error and could not complete\r | |
4689 | the request.\r | |
4690 | @retval EFI_UNSUPPORTED The attribute requested is not defined.\r | |
4691 | \r | |
4692 | **/\r | |
4693 | EFI_STATUS\r | |
4694 | EFIAPI\r | |
4695 | ConSplitterTextOutSetAttribute (\r | |
4696 | IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r | |
4697 | IN UINTN Attribute\r | |
4698 | )\r | |
4699 | {\r | |
4700 | EFI_STATUS Status;\r | |
4701 | TEXT_OUT_SPLITTER_PRIVATE_DATA *Private;\r | |
4702 | UINTN Index;\r | |
4703 | EFI_STATUS ReturnStatus;\r | |
4704 | \r | |
4705 | Private = TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This);\r | |
4706 | \r | |
4707 | //\r | |
4708 | // Check whether param Attribute is valid.\r | |
4709 | //\r | |
4710 | if ( (Attribute > (UINTN)(((UINT32)-1)>>1)) ) {\r | |
4711 | return EFI_UNSUPPORTED;\r | |
4712 | }\r | |
4713 | \r | |
4714 | //\r | |
4715 | // return the worst status met\r | |
4716 | //\r | |
4717 | for (Index = 0, ReturnStatus = EFI_SUCCESS; Index < Private->CurrentNumberOfConsoles; Index++) {\r | |
4718 | \r | |
4719 | if (Private->TextOutList[Index].TextOutEnabled) {\r | |
4720 | Status = Private->TextOutList[Index].TextOut->SetAttribute (\r | |
4721 | Private->TextOutList[Index].TextOut,\r | |
4722 | Attribute\r | |
4723 | );\r | |
4724 | if (EFI_ERROR (Status)) {\r | |
4725 | ReturnStatus = Status;\r | |
4726 | }\r | |
4727 | }\r | |
4728 | }\r | |
4729 | \r | |
4730 | Private->TextOutMode.Attribute = (INT32) Attribute;\r | |
4731 | \r | |
4732 | return ReturnStatus;\r | |
4733 | }\r | |
4734 | \r | |
4735 | \r | |
4736 | /**\r | |
4737 | Clears the output device(s) display to the currently selected background\r | |
4738 | color.\r | |
4739 | \r | |
4740 | @param This Protocol instance pointer.\r | |
4741 | \r | |
4742 | @retval EFI_SUCCESS The operation completed successfully.\r | |
4743 | @retval EFI_DEVICE_ERROR The device had an error and could not complete\r | |
4744 | the request.\r | |
4745 | @retval EFI_UNSUPPORTED The output device is not in a valid text mode.\r | |
4746 | \r | |
4747 | **/\r | |
4748 | EFI_STATUS\r | |
4749 | EFIAPI\r | |
4750 | ConSplitterTextOutClearScreen (\r | |
4751 | IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This\r | |
4752 | )\r | |
4753 | {\r | |
4754 | EFI_STATUS Status;\r | |
4755 | TEXT_OUT_SPLITTER_PRIVATE_DATA *Private;\r | |
4756 | UINTN Index;\r | |
4757 | EFI_STATUS ReturnStatus;\r | |
4758 | \r | |
4759 | Private = TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This);\r | |
4760 | \r | |
4761 | //\r | |
4762 | // return the worst status met\r | |
4763 | //\r | |
4764 | for (Index = 0, ReturnStatus = EFI_SUCCESS; Index < Private->CurrentNumberOfConsoles; Index++) {\r | |
4765 | \r | |
4766 | if (Private->TextOutList[Index].TextOutEnabled) {\r | |
4767 | Status = Private->TextOutList[Index].TextOut->ClearScreen (Private->TextOutList[Index].TextOut);\r | |
4768 | if (EFI_ERROR (Status)) {\r | |
4769 | ReturnStatus = Status;\r | |
4770 | }\r | |
4771 | }\r | |
4772 | }\r | |
4773 | \r | |
4774 | Status = DevNullTextOutClearScreen (Private);\r | |
4775 | if (EFI_ERROR (Status)) {\r | |
4776 | ReturnStatus = Status;\r | |
4777 | }\r | |
4778 | \r | |
4779 | return ReturnStatus;\r | |
4780 | }\r | |
4781 | \r | |
4782 | \r | |
4783 | /**\r | |
4784 | Sets the current coordinates of the cursor position\r | |
4785 | \r | |
4786 | @param This Protocol instance pointer.\r | |
4787 | @param Column The column position to set the cursor to. Must be\r | |
4788 | greater than or equal to zero and less than the\r | |
4789 | number of columns by QueryMode ().\r | |
4790 | @param Row The row position to set the cursor to. Must be\r | |
4791 | greater than or equal to zero and less than the\r | |
4792 | number of rows by QueryMode ().\r | |
4793 | \r | |
4794 | @retval EFI_SUCCESS The operation completed successfully.\r | |
4795 | @retval EFI_DEVICE_ERROR The device had an error and could not complete\r | |
4796 | the request.\r | |
4797 | @retval EFI_UNSUPPORTED The output device is not in a valid text mode,\r | |
4798 | or the cursor position is invalid for the\r | |
4799 | current mode.\r | |
4800 | \r | |
4801 | **/\r | |
4802 | EFI_STATUS\r | |
4803 | EFIAPI\r | |
4804 | ConSplitterTextOutSetCursorPosition (\r | |
4805 | IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r | |
4806 | IN UINTN Column,\r | |
4807 | IN UINTN Row\r | |
4808 | )\r | |
4809 | {\r | |
4810 | EFI_STATUS Status;\r | |
4811 | TEXT_OUT_SPLITTER_PRIVATE_DATA *Private;\r | |
4812 | UINTN Index;\r | |
4813 | EFI_STATUS ReturnStatus;\r | |
4814 | UINTN MaxColumn;\r | |
4815 | UINTN MaxRow;\r | |
4816 | INT32 *TextOutModeMap;\r | |
4817 | INT32 ModeNumber;\r | |
4818 | INT32 CurrentMode;\r | |
4819 | \r | |
4820 | Private = TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This);\r | |
4821 | TextOutModeMap = NULL;\r | |
4822 | ModeNumber = Private->TextOutMode.Mode;\r | |
4823 | \r | |
4824 | //\r | |
4825 | // Get current MaxColumn and MaxRow from intersection map\r | |
4826 | //\r | |
4827 | if (Private->TextOutModeMap != NULL) {\r | |
4828 | TextOutModeMap = Private->TextOutModeMap + Private->TextOutListCount * ModeNumber;\r | |
4829 | CurrentMode = *TextOutModeMap;\r | |
4830 | } else {\r | |
4831 | CurrentMode = ModeNumber;\r | |
4832 | }\r | |
4833 | \r | |
4834 | MaxColumn = Private->TextOutQueryData[CurrentMode].Columns;\r | |
4835 | MaxRow = Private->TextOutQueryData[CurrentMode].Rows;\r | |
4836 | \r | |
4837 | if (Column >= MaxColumn || Row >= MaxRow) {\r | |
4838 | return EFI_UNSUPPORTED;\r | |
4839 | }\r | |
4840 | //\r | |
4841 | // return the worst status met\r | |
4842 | //\r | |
4843 | for (Index = 0, ReturnStatus = EFI_SUCCESS; Index < Private->CurrentNumberOfConsoles; Index++) {\r | |
4844 | \r | |
4845 | if (Private->TextOutList[Index].TextOutEnabled) {\r | |
4846 | Status = Private->TextOutList[Index].TextOut->SetCursorPosition (\r | |
4847 | Private->TextOutList[Index].TextOut,\r | |
4848 | Column,\r | |
4849 | Row\r | |
4850 | );\r | |
4851 | if (EFI_ERROR (Status)) {\r | |
4852 | ReturnStatus = Status;\r | |
4853 | }\r | |
4854 | }\r | |
4855 | }\r | |
4856 | \r | |
4857 | DevNullTextOutSetCursorPosition (Private, Column, Row);\r | |
4858 | \r | |
4859 | return ReturnStatus;\r | |
4860 | }\r | |
4861 | \r | |
4862 | \r | |
4863 | /**\r | |
4864 | Makes the cursor visible or invisible\r | |
4865 | \r | |
4866 | @param This Protocol instance pointer.\r | |
4867 | @param Visible If TRUE, the cursor is set to be visible. If\r | |
4868 | FALSE, the cursor is set to be invisible.\r | |
4869 | \r | |
4870 | @retval EFI_SUCCESS The operation completed successfully.\r | |
4871 | @retval EFI_DEVICE_ERROR The device had an error and could not complete\r | |
4872 | the request, or the device does not support\r | |
4873 | changing the cursor mode.\r | |
4874 | @retval EFI_UNSUPPORTED The output device is not in a valid text mode.\r | |
4875 | \r | |
4876 | **/\r | |
4877 | EFI_STATUS\r | |
4878 | EFIAPI\r | |
4879 | ConSplitterTextOutEnableCursor (\r | |
4880 | IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,\r | |
4881 | IN BOOLEAN Visible\r | |
4882 | )\r | |
4883 | {\r | |
4884 | EFI_STATUS Status;\r | |
4885 | TEXT_OUT_SPLITTER_PRIVATE_DATA *Private;\r | |
4886 | UINTN Index;\r | |
4887 | EFI_STATUS ReturnStatus;\r | |
4888 | \r | |
4889 | Private = TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This);\r | |
4890 | \r | |
4891 | //\r | |
4892 | // return the worst status met\r | |
4893 | //\r | |
4894 | for (Index = 0, ReturnStatus = EFI_SUCCESS; Index < Private->CurrentNumberOfConsoles; Index++) {\r | |
4895 | \r | |
4896 | if (Private->TextOutList[Index].TextOutEnabled) {\r | |
4897 | Status = Private->TextOutList[Index].TextOut->EnableCursor (\r | |
4898 | Private->TextOutList[Index].TextOut,\r | |
4899 | Visible\r | |
4900 | );\r | |
4901 | if (EFI_ERROR (Status)) {\r | |
4902 | ReturnStatus = Status;\r | |
4903 | }\r | |
4904 | }\r | |
4905 | }\r | |
4906 | \r | |
4907 | DevNullTextOutEnableCursor (Private, Visible);\r | |
4908 | \r | |
4909 | return ReturnStatus;\r | |
4910 | }\r | |
4911 | \r |