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