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