2 Console Splitter Driver. Any Handle that attatched
3 EFI_CONSOLE_IDENTIFIER_PROTOCOL can be bound by this driver.
5 So far it works like any other driver by opening a SimpleTextIn and/or
6 SimpleTextOut protocol with EFI_OPEN_PROTOCOL_BY_DRIVER attributes. The big
7 difference is this driver does not layer a protocol on the passed in
8 handle, or construct a child handle like a standard device or bus driver.
9 This driver produces three virtual handles as children, one for console input
10 splitter, one for console output splitter and one for error output splitter.
11 EFI_CONSOLE_SPLIT_PROTOCOL will be attatched onto each virtual handle to
12 identify the splitter type.
14 Each virtual handle, that supports both the EFI_CONSOLE_SPLIT_PROTOCOL
15 and Console I/O protocol, will be produced in the driver entry point.
16 The virtual handle are added on driver entry and never removed.
17 Such design ensures sytem function well during none console device situation.
19 Copyright (c) 2006 - 2008 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
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.
30 #include "ConSplitter.h"
35 STATIC TEXT_IN_SPLITTER_PRIVATE_DATA mConIn
= {
36 TEXT_IN_SPLITTER_PRIVATE_DATA_SIGNATURE
,
39 ConSplitterTextInReset
,
40 ConSplitterTextInReadKeyStroke
,
44 (EFI_SIMPLE_TEXT_INPUT_PROTOCOL
**) NULL
,
47 ConSplitterTextInResetEx
,
48 ConSplitterTextInReadKeyStrokeEx
,
50 ConSplitterTextInSetState
,
51 ConSplitterTextInRegisterKeyNotify
,
52 ConSplitterTextInUnregisterKeyNotify
55 (EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
**) NULL
,
63 ConSplitterSimplePointerReset
,
64 ConSplitterSimplePointerGetState
,
66 (EFI_SIMPLE_POINTER_MODE
*) NULL
76 (EFI_SIMPLE_POINTER_PROTOCOL
**) NULL
,
80 ConSplitterAbsolutePointerReset
,
81 ConSplitterAbsolutePointerGetState
,
83 (EFI_ABSOLUTE_POINTER_MODE
*) NULL
90 0x10000, //AbsoluteMaxX
91 0x10000, //AbsoluteMaxY
92 0x10000, //AbsoluteMaxZ
96 (EFI_ABSOLUTE_POINTER_PROTOCOL
**) NULL
,
102 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
103 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
104 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
105 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
109 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
110 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
111 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
112 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
120 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UGA_DRAW_PROTOCOL gUgaDrawProtocolTemplate
= {
121 ConSpliterUgaDrawGetMode
,
122 ConSpliterUgaDrawSetMode
,
126 GLOBAL_REMOVE_IF_UNREFERENCED EFI_GRAPHICS_OUTPUT_PROTOCOL gGraphicsOutputProtocolTemplate
= {
127 ConSpliterGraphicsOutputQueryMode
,
128 ConSpliterGraphicsOutputSetMode
,
129 ConSpliterGraphicsOutputBlt
,
133 STATIC TEXT_OUT_SPLITTER_PRIVATE_DATA mConOut
= {
134 TEXT_OUT_SPLITTER_PRIVATE_DATA_SIGNATURE
,
137 ConSplitterTextOutReset
,
138 ConSplitterTextOutOutputString
,
139 ConSplitterTextOutTestString
,
140 ConSplitterTextOutQueryMode
,
141 ConSplitterTextOutSetMode
,
142 ConSplitterTextOutSetAttribute
,
143 ConSplitterTextOutClearScreen
,
144 ConSplitterTextOutSetCursorPosition
,
145 ConSplitterTextOutEnableCursor
,
146 (EFI_SIMPLE_TEXT_OUTPUT_MODE
*) NULL
165 (EFI_UGA_PIXEL
*) NULL
,
172 (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*) NULL
,
173 (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*) NULL
,
178 ConSpliterConsoleControlGetMode
,
179 ConSpliterConsoleControlSetMode
,
180 ConSpliterConsoleControlLockStdIn
184 (TEXT_OUT_AND_GOP_DATA
*) NULL
,
186 (TEXT_OUT_SPLITTER_QUERY_DATA
*) NULL
,
190 EfiConsoleControlScreenText
,
197 STATIC TEXT_OUT_SPLITTER_PRIVATE_DATA mStdErr
= {
198 TEXT_OUT_SPLITTER_PRIVATE_DATA_SIGNATURE
,
201 ConSplitterTextOutReset
,
202 ConSplitterTextOutOutputString
,
203 ConSplitterTextOutTestString
,
204 ConSplitterTextOutQueryMode
,
205 ConSplitterTextOutSetMode
,
206 ConSplitterTextOutSetAttribute
,
207 ConSplitterTextOutClearScreen
,
208 ConSplitterTextOutSetCursorPosition
,
209 ConSplitterTextOutEnableCursor
,
210 (EFI_SIMPLE_TEXT_OUTPUT_MODE
*) NULL
229 (EFI_UGA_PIXEL
*) NULL
,
236 (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*) NULL
,
237 (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*) NULL
,
242 ConSpliterConsoleControlGetMode
,
243 ConSpliterConsoleControlSetMode
,
244 ConSpliterConsoleControlLockStdIn
248 (TEXT_OUT_AND_GOP_DATA
*) NULL
,
250 (TEXT_OUT_SPLITTER_QUERY_DATA
*) NULL
,
254 EfiConsoleControlScreenText
,
261 EFI_DRIVER_BINDING_PROTOCOL gConSplitterConInDriverBinding
= {
262 ConSplitterConInDriverBindingSupported
,
263 ConSplitterConInDriverBindingStart
,
264 ConSplitterConInDriverBindingStop
,
270 EFI_DRIVER_BINDING_PROTOCOL gConSplitterSimplePointerDriverBinding
= {
271 ConSplitterSimplePointerDriverBindingSupported
,
272 ConSplitterSimplePointerDriverBindingStart
,
273 ConSplitterSimplePointerDriverBindingStop
,
280 // Driver binding instance for Absolute Pointer protocol
282 EFI_DRIVER_BINDING_PROTOCOL gConSplitterAbsolutePointerDriverBinding
= {
283 ConSplitterAbsolutePointerDriverBindingSupported
,
284 ConSplitterAbsolutePointerDriverBindingStart
,
285 ConSplitterAbsolutePointerDriverBindingStop
,
291 EFI_DRIVER_BINDING_PROTOCOL gConSplitterConOutDriverBinding
= {
292 ConSplitterConOutDriverBindingSupported
,
293 ConSplitterConOutDriverBindingStart
,
294 ConSplitterConOutDriverBindingStop
,
300 EFI_DRIVER_BINDING_PROTOCOL gConSplitterStdErrDriverBinding
= {
301 ConSplitterStdErrDriverBindingSupported
,
302 ConSplitterStdErrDriverBindingStart
,
303 ConSplitterStdErrDriverBindingStop
,
310 The user Entry Point for module ConSplitter. The user code starts with this function.
312 Installs driver module protocols and. Creates virtual device handles for ConIn,
313 ConOut, and StdErr. Installs Simple Text In protocol, Simple Text In Ex protocol,
314 Simple Pointer protocol, Absolute Pointer protocol on those virtual handlers.
315 Installs Graphics Output protocol and/or UGA Draw protocol if needed.
317 @param[in] ImageHandle The firmware allocated handle for the EFI image.
318 @param[in] SystemTable A pointer to the EFI System Table.
320 @retval EFI_SUCCESS The entry point is executed successfully.
321 @retval other Some error occurs when executing this entry point.
326 ConSplitterDriverEntry(
327 IN EFI_HANDLE ImageHandle
,
328 IN EFI_SYSTEM_TABLE
*SystemTable
334 // Install driver model protocol(s).
336 Status
= EfiLibInstallDriverBindingComponentName2 (
339 &gConSplitterConInDriverBinding
,
341 &gConSplitterConInComponentName
,
342 &gConSplitterConInComponentName2
344 ASSERT_EFI_ERROR (Status
);
346 Status
= EfiLibInstallDriverBindingComponentName2 (
349 &gConSplitterSimplePointerDriverBinding
,
351 &gConSplitterSimplePointerComponentName
,
352 &gConSplitterSimplePointerComponentName2
354 ASSERT_EFI_ERROR (Status
);
356 Status
= EfiLibInstallDriverBindingComponentName2 (
359 &gConSplitterAbsolutePointerDriverBinding
,
361 &gConSplitterAbsolutePointerComponentName
,
362 &gConSplitterAbsolutePointerComponentName2
364 ASSERT_EFI_ERROR (Status
);
366 Status
= EfiLibInstallDriverBindingComponentName2 (
369 &gConSplitterConOutDriverBinding
,
371 &gConSplitterConOutComponentName
,
372 &gConSplitterConOutComponentName2
374 ASSERT_EFI_ERROR (Status
);
376 Status
= EfiLibInstallDriverBindingComponentName2 (
379 &gConSplitterStdErrDriverBinding
,
381 &gConSplitterStdErrComponentName
,
382 &gConSplitterStdErrComponentName2
384 ASSERT_EFI_ERROR (Status
);
387 ASSERT (FeaturePcdGet (PcdConOutGopSupport
) ||
388 FeaturePcdGet (PcdConOutUgaSupport
));
390 // The driver creates virtual handles for ConIn, ConOut, and StdErr.
391 // The virtual handles will always exist even if no console exist in the
392 // system. This is need to support hotplug devices like USB.
395 // Create virtual device handle for StdErr Splitter
397 Status
= ConSplitterTextOutConstructor (&mStdErr
);
398 if (!EFI_ERROR (Status
)) {
399 Status
= gBS
->InstallMultipleProtocolInterfaces (
400 &mStdErr
.VirtualHandle
,
401 &gEfiSimpleTextOutProtocolGuid
,
403 &gEfiPrimaryStandardErrorDeviceGuid
,
409 // Create virtual device handle for ConIn Splitter
411 Status
= ConSplitterTextInConstructor (&mConIn
);
412 if (!EFI_ERROR (Status
)) {
413 Status
= gBS
->InstallMultipleProtocolInterfaces (
414 &mConIn
.VirtualHandle
,
415 &gEfiSimpleTextInProtocolGuid
,
417 &gEfiSimpleTextInputExProtocolGuid
,
419 &gEfiSimplePointerProtocolGuid
,
420 &mConIn
.SimplePointer
,
421 &gEfiAbsolutePointerProtocolGuid
,
422 &mConIn
.AbsolutePointer
,
423 &gEfiPrimaryConsoleInDeviceGuid
,
427 if (!EFI_ERROR (Status
)) {
429 // Update the EFI System Table with new virtual console
431 gST
->ConsoleInHandle
= mConIn
.VirtualHandle
;
432 gST
->ConIn
= &mConIn
.TextIn
;
436 // Create virtual device handle for ConOut Splitter
438 Status
= ConSplitterTextOutConstructor (&mConOut
);
439 if (!EFI_ERROR (Status
)) {
440 if (!FeaturePcdGet (PcdConOutGopSupport
)) {
442 // In EFI mode, UGA Draw protocol is installed
444 Status
= gBS
->InstallMultipleProtocolInterfaces (
445 &mConOut
.VirtualHandle
,
446 &gEfiSimpleTextOutProtocolGuid
,
448 &gEfiUgaDrawProtocolGuid
,
450 &gEfiConsoleControlProtocolGuid
,
451 &mConOut
.ConsoleControl
,
452 &gEfiPrimaryConsoleOutDeviceGuid
,
456 } else if (!FeaturePcdGet (PcdConOutUgaSupport
)) {
458 // In UEFI mode, Graphics Output Protocol is installed on virtual handle.
460 Status
= gBS
->InstallMultipleProtocolInterfaces (
461 &mConOut
.VirtualHandle
,
462 &gEfiSimpleTextOutProtocolGuid
,
464 &gEfiGraphicsOutputProtocolGuid
,
465 &mConOut
.GraphicsOutput
,
466 &gEfiConsoleControlProtocolGuid
,
467 &mConOut
.ConsoleControl
,
468 &gEfiPrimaryConsoleOutDeviceGuid
,
474 // In EFI and UEFI comptible mode, Graphics Output Protocol and UGA are
475 // installed on virtual handle.
477 Status
= gBS
->InstallMultipleProtocolInterfaces (
478 &mConOut
.VirtualHandle
,
479 &gEfiSimpleTextOutProtocolGuid
,
481 &gEfiGraphicsOutputProtocolGuid
,
482 &mConOut
.GraphicsOutput
,
483 &gEfiUgaDrawProtocolGuid
,
485 &gEfiConsoleControlProtocolGuid
,
486 &mConOut
.ConsoleControl
,
487 &gEfiPrimaryConsoleOutDeviceGuid
,
493 if (!EFI_ERROR (Status
)) {
495 // Update the EFI System Table with new virtual console
497 gST
->ConsoleOutHandle
= mConOut
.VirtualHandle
;
498 gST
->ConOut
= &mConOut
.TextOut
;
503 // Update the CRC32 in the EFI System Table header
506 gBS
->CalculateCrc32 (
518 Construct console input devices' private data.
520 @param ConInPrivate A pointer to the TEXT_IN_SPLITTER_PRIVATE_DATA
523 @retval EFI_OUT_OF_RESOURCES Out of resources.
524 @retval other Out of resources.
528 ConSplitterTextInConstructor (
529 TEXT_IN_SPLITTER_PRIVATE_DATA
*ConInPrivate
535 // Initilize console input splitter's private data.
537 Status
= ConSplitterGrowBuffer (
538 sizeof (EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*),
539 &ConInPrivate
->TextInListCount
,
540 (VOID
**) &ConInPrivate
->TextInList
542 if (EFI_ERROR (Status
)) {
543 return EFI_OUT_OF_RESOURCES
;
546 // Create Event to support locking StdIn Device
548 Status
= gBS
->CreateEvent (
549 EVT_TIMER
| EVT_NOTIFY_SIGNAL
,
551 ConSpliterConsoleControlLockStdInEvent
,
553 &ConInPrivate
->LockEvent
555 ASSERT_EFI_ERROR (Status
);
557 Status
= gBS
->CreateEvent (
560 ConSplitterTextInWaitForKey
,
562 &ConInPrivate
->TextIn
.WaitForKey
564 ASSERT_EFI_ERROR (Status
);
567 // Buffer for Simple Text Input Ex Protocol
569 Status
= ConSplitterGrowBuffer (
570 sizeof (EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*),
571 &ConInPrivate
->TextInExListCount
,
572 (VOID
**) &ConInPrivate
->TextInExList
574 if (EFI_ERROR (Status
)) {
575 return EFI_OUT_OF_RESOURCES
;
578 Status
= gBS
->CreateEvent (
581 ConSplitterTextInWaitForKey
,
583 &ConInPrivate
->TextInEx
.WaitForKeyEx
585 ASSERT_EFI_ERROR (Status
);
587 InitializeListHead (&ConInPrivate
->NotifyList
);
590 // Allocate Buffer and Create Event for Absolute Pointer and Simple Pointer Protocols
592 ConInPrivate
->AbsolutePointer
.Mode
= &ConInPrivate
->AbsolutePointerMode
;
594 Status
= ConSplitterGrowBuffer (
595 sizeof (EFI_ABSOLUTE_POINTER_PROTOCOL
*),
596 &ConInPrivate
->AbsolutePointerListCount
,
597 (VOID
**) &ConInPrivate
->AbsolutePointerList
599 if (EFI_ERROR (Status
)) {
600 return EFI_OUT_OF_RESOURCES
;
603 Status
= gBS
->CreateEvent (
606 ConSplitterAbsolutePointerWaitForInput
,
608 &ConInPrivate
->AbsolutePointer
.WaitForInput
610 ASSERT_EFI_ERROR (Status
);
612 ConInPrivate
->SimplePointer
.Mode
= &ConInPrivate
->SimplePointerMode
;
614 Status
= ConSplitterGrowBuffer (
615 sizeof (EFI_SIMPLE_POINTER_PROTOCOL
*),
616 &ConInPrivate
->PointerListCount
,
617 (VOID
**) &ConInPrivate
->PointerList
619 if (EFI_ERROR (Status
)) {
620 return EFI_OUT_OF_RESOURCES
;
623 Status
= gBS
->CreateEvent (
626 ConSplitterSimplePointerWaitForInput
,
628 &ConInPrivate
->SimplePointer
.WaitForInput
635 Construct console output devices' private data.
637 @param ConOutPrivate A pointer to the TEXT_IN_SPLITTER_PRIVATE_DATA
640 @retval EFI_OUT_OF_RESOURCES Out of resources.
644 ConSplitterTextOutConstructor (
645 TEXT_OUT_SPLITTER_PRIVATE_DATA
*ConOutPrivate
649 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*Info
;
652 // Copy protocols template
654 if (FeaturePcdGet (PcdConOutUgaSupport
)) {
655 CopyMem (&ConOutPrivate
->UgaDraw
, &gUgaDrawProtocolTemplate
, sizeof (EFI_UGA_DRAW_PROTOCOL
));
658 if (FeaturePcdGet (PcdConOutGopSupport
)) {
659 CopyMem (&ConOutPrivate
->GraphicsOutput
, &gGraphicsOutputProtocolTemplate
, sizeof (EFI_GRAPHICS_OUTPUT_PROTOCOL
));
663 // Initilize console output splitter's private data.
665 ConOutPrivate
->TextOut
.Mode
= &ConOutPrivate
->TextOutMode
;
668 // When new console device is added, the new mode will be set later,
669 // so put current mode back to init state.
671 ConOutPrivate
->TextOutMode
.Mode
= 0xFF;
673 Status
= ConSplitterGrowBuffer (
674 sizeof (TEXT_OUT_AND_GOP_DATA
),
675 &ConOutPrivate
->TextOutListCount
,
676 (VOID
**) &ConOutPrivate
->TextOutList
678 if (EFI_ERROR (Status
)) {
679 return EFI_OUT_OF_RESOURCES
;
682 Status
= ConSplitterGrowBuffer (
683 sizeof (TEXT_OUT_SPLITTER_QUERY_DATA
),
684 &ConOutPrivate
->TextOutQueryDataCount
,
685 (VOID
**) &ConOutPrivate
->TextOutQueryData
687 if (EFI_ERROR (Status
)) {
688 return EFI_OUT_OF_RESOURCES
;
691 // Setup the DevNullTextOut console to 80 x 25
693 ConOutPrivate
->TextOutQueryData
[0].Columns
= 80;
694 ConOutPrivate
->TextOutQueryData
[0].Rows
= 25;
695 DevNullTextOutSetMode (ConOutPrivate
, 0);
697 if (FeaturePcdGet (PcdConOutUgaSupport
)) {
699 // Setup the DevNullUgaDraw to 800 x 600 x 32 bits per pixel
701 ConSpliterUgaDrawSetMode (&ConOutPrivate
->UgaDraw
, 800, 600, 32, 60);
703 if (FeaturePcdGet (PcdConOutGopSupport
)) {
705 // Setup resource for mode information in Graphics Output Protocol interface
707 if ((ConOutPrivate
->GraphicsOutput
.Mode
= AllocateZeroPool (sizeof (EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE
))) == NULL
) {
708 return EFI_OUT_OF_RESOURCES
;
710 if ((ConOutPrivate
->GraphicsOutput
.Mode
->Info
= AllocateZeroPool (sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
))) == NULL
) {
711 return EFI_OUT_OF_RESOURCES
;
714 // Setup the DevNullGraphicsOutput to 800 x 600 x 32 bits per pixel
715 // DevNull will be updated to user-defined mode after driver has started.
717 if ((ConOutPrivate
->GraphicsOutputModeBuffer
= AllocateZeroPool (sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
))) == NULL
) {
718 return EFI_OUT_OF_RESOURCES
;
720 Info
= &ConOutPrivate
->GraphicsOutputModeBuffer
[0];
722 Info
->HorizontalResolution
= 800;
723 Info
->VerticalResolution
= 600;
724 Info
->PixelFormat
= PixelBltOnly
;
725 Info
->PixelsPerScanLine
= 800;
726 CopyMem (ConOutPrivate
->GraphicsOutput
.Mode
->Info
, Info
, sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
));
727 ConOutPrivate
->GraphicsOutput
.Mode
->SizeOfInfo
= sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
);
730 // Initialize the following items, theset items remain unchanged in GraphicsOutput->SetMode()
731 // GraphicsOutputMode->FrameBufferBase, GraphicsOutputMode->FrameBufferSize
733 ConOutPrivate
->GraphicsOutput
.Mode
->FrameBufferBase
= (EFI_PHYSICAL_ADDRESS
) (UINTN
) NULL
;
734 ConOutPrivate
->GraphicsOutput
.Mode
->FrameBufferSize
= 0;
736 ConOutPrivate
->GraphicsOutput
.Mode
->MaxMode
= 1;
738 // Initial current mode to unknow state, and then set to mode 0
740 ConOutPrivate
->GraphicsOutput
.Mode
->Mode
= 0xffff;
741 ConOutPrivate
->GraphicsOutput
.SetMode (&ConOutPrivate
->GraphicsOutput
, 0);
749 Test to see if the specified protocol could be supported on the ControllerHandle.
751 @param This Protocol instance pointer.
752 @param ControllerHandle Handle of device to test.
753 @param Guid The specified protocol guid.
755 @retval EFI_SUCCESS The specified protocol is supported on this device.
756 @retval other The specified protocol is not supported on this device.
760 ConSplitterSupported (
761 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
762 IN EFI_HANDLE ControllerHandle
,
770 // Make sure the Console Splitter does not attempt to attach to itself
772 if (ControllerHandle
== mConIn
.VirtualHandle
) {
773 return EFI_UNSUPPORTED
;
776 if (ControllerHandle
== mConOut
.VirtualHandle
) {
777 return EFI_UNSUPPORTED
;
780 if (ControllerHandle
== mStdErr
.VirtualHandle
) {
781 return EFI_UNSUPPORTED
;
784 // Check to see whether the handle has the ConsoleInDevice GUID on it
786 Status
= gBS
->OpenProtocol (
790 This
->DriverBindingHandle
,
792 EFI_OPEN_PROTOCOL_BY_DRIVER
795 if (EFI_ERROR (Status
)) {
802 This
->DriverBindingHandle
,
810 Test to see if Console In Device could be supported on the ControllerHandle.
812 @param This Protocol instance pointer.
813 @param ControllerHandle Handle of device to test.
814 @param RemainingDevicePath Optional parameter use to pick a specific child
817 @retval EFI_SUCCESS This driver supports this device
818 @retval other This driver does not support this device
823 ConSplitterConInDriverBindingSupported (
824 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
825 IN EFI_HANDLE ControllerHandle
,
826 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
829 return ConSplitterSupported (
832 &gEfiConsoleInDeviceGuid
837 Test to see if Simple Pointer protocol could be supported on the ControllerHandle.
839 @param This Protocol instance pointer.
840 @param ControllerHandle Handle of device to test.
841 @param RemainingDevicePath Optional parameter use to pick a specific child
844 @retval EFI_SUCCESS This driver supports this device
845 @retval other This driver does not support this device
850 ConSplitterSimplePointerDriverBindingSupported (
851 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
852 IN EFI_HANDLE ControllerHandle
,
853 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
856 return ConSplitterSupported (
859 &gEfiSimplePointerProtocolGuid
865 Test to see if Absolute Pointer protocol could be supported on the ControllerHandle.
867 @param This Protocol instance pointer.
868 @param ControllerHandle Handle of device to test.
869 @param RemainingDevicePath Optional parameter use to pick a specific child
872 @retval EFI_SUCCESS This driver supports this device
873 @retval other This driver does not support this device
878 ConSplitterAbsolutePointerDriverBindingSupported (
879 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
880 IN EFI_HANDLE ControllerHandle
,
881 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
884 return ConSplitterSupported (
887 &gEfiAbsolutePointerProtocolGuid
893 Test to see if Console Out Device could be supported on the ControllerHandle.
895 @param This Protocol instance pointer.
896 @param ControllerHandle Handle of device to test.
897 @param RemainingDevicePath Optional parameter use to pick a specific child
900 @retval EFI_SUCCESS This driver supports this device
901 @retval other This driver does not support this device
906 ConSplitterConOutDriverBindingSupported (
907 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
908 IN EFI_HANDLE ControllerHandle
,
909 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
912 return ConSplitterSupported (
915 &gEfiConsoleOutDeviceGuid
920 Test to see if Standard Error Device could be supported on the ControllerHandle.
922 @param This Protocol instance pointer.
923 @param ControllerHandle Handle of device to test.
924 @param RemainingDevicePath Optional parameter use to pick a specific child
927 @retval EFI_SUCCESS This driver supports this device
928 @retval other This driver does not support this device
933 ConSplitterStdErrDriverBindingSupported (
934 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
935 IN EFI_HANDLE ControllerHandle
,
936 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
939 return ConSplitterSupported (
942 &gEfiStandardErrorDeviceGuid
948 Start ConSplitter on devcie handle by opening Console Device Guid on device handle
949 and the console virtual handle. And Get the console interface on controller handle.
951 @param This Protocol instance pointer.
952 @param ControllerHandle Handle of device.
953 @param ConSplitterVirtualHandle Console virtual Handle.
954 @param DeviceGuid The specified Console Device, such as ConInDev,
956 @param InterfaceGuid The specified protocol to be opened.
957 @param Interface Protocol interface returned.
959 @retval EFI_SUCCESS This driver supports this device
960 @retval other Failed to open the specified Console Device Guid
961 or specified protocol.
966 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
967 IN EFI_HANDLE ControllerHandle
,
968 IN EFI_HANDLE ConSplitterVirtualHandle
,
969 IN EFI_GUID
*DeviceGuid
,
970 IN EFI_GUID
*InterfaceGuid
,
978 // Check to see whether the ControllerHandle has the InterfaceGuid on it.
980 Status
= gBS
->OpenProtocol (
984 This
->DriverBindingHandle
,
986 EFI_OPEN_PROTOCOL_BY_DRIVER
988 if (EFI_ERROR (Status
)) {
992 Status
= gBS
->OpenProtocol (
996 This
->DriverBindingHandle
,
997 ConSplitterVirtualHandle
,
998 EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
1000 if (EFI_ERROR (Status
)) {
1004 return gBS
->OpenProtocol (
1008 This
->DriverBindingHandle
,
1009 ConSplitterVirtualHandle
,
1010 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1016 Start Console In Consplitter on device handle.
1018 @param This Protocol instance pointer.
1019 @param ControllerHandle Handle of device to bind driver to.
1020 @param RemainingDevicePath Optional parameter use to pick a specific child
1023 @retval EFI_SUCCESS Console In Consplitter is added to ControllerHandle.
1024 @retval other Console In Consplitter does not support this device.
1029 ConSplitterConInDriverBindingStart (
1030 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1031 IN EFI_HANDLE ControllerHandle
,
1032 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
1036 EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*TextIn
;
1037 EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*TextInEx
;
1040 // Start ConSplitter on ControllerHandle, and create the virtual
1041 // agrogated console device on first call Start for a SimpleTextIn handle.
1043 Status
= ConSplitterStart (
1046 mConIn
.VirtualHandle
,
1047 &gEfiConsoleInDeviceGuid
,
1048 &gEfiSimpleTextInProtocolGuid
,
1051 if (EFI_ERROR (Status
)) {
1055 Status
= ConSplitterTextInAddDevice (&mConIn
, TextIn
);
1056 if (EFI_ERROR (Status
)) {
1060 Status
= gBS
->OpenProtocol (
1062 &gEfiSimpleTextInputExProtocolGuid
,
1063 (VOID
**) &TextInEx
,
1064 This
->DriverBindingHandle
,
1065 mConIn
.VirtualHandle
,
1066 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1068 if (EFI_ERROR (Status
)) {
1072 Status
= ConSplitterTextInExAddDevice (&mConIn
, TextInEx
);
1079 Start Simple Pointer Consplitter on device handle.
1081 @param This Protocol instance pointer.
1082 @param ControllerHandle Handle of device to bind driver to.
1083 @param RemainingDevicePath Optional parameter use to pick a specific child
1086 @retval EFI_SUCCESS Simple Pointer Consplitter is added to ControllerHandle.
1087 @retval other Simple Pointer Consplitter does not support this device.
1092 ConSplitterSimplePointerDriverBindingStart (
1093 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1094 IN EFI_HANDLE ControllerHandle
,
1095 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
1099 EFI_SIMPLE_POINTER_PROTOCOL
*SimplePointer
;
1101 Status
= ConSplitterStart (
1104 mConIn
.VirtualHandle
,
1105 &gEfiSimplePointerProtocolGuid
,
1106 &gEfiSimplePointerProtocolGuid
,
1107 (VOID
**) &SimplePointer
1109 if (EFI_ERROR (Status
)) {
1113 return ConSplitterSimplePointerAddDevice (&mConIn
, SimplePointer
);
1118 Start Absolute Pointer Consplitter on device handle.
1120 @param This Protocol instance pointer.
1121 @param ControllerHandle Handle of device to bind driver to.
1122 @param RemainingDevicePath Optional parameter use to pick a specific child
1125 @retval EFI_SUCCESS Absolute Pointer Consplitter is added to ControllerHandle.
1126 @retval other Absolute Pointer Consplitter does not support this device.
1131 ConSplitterAbsolutePointerDriverBindingStart (
1132 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1133 IN EFI_HANDLE ControllerHandle
,
1134 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
1138 EFI_ABSOLUTE_POINTER_PROTOCOL
*AbsolutePointer
;
1140 Status
= ConSplitterStart (
1143 mConIn
.VirtualHandle
,
1144 &gEfiAbsolutePointerProtocolGuid
,
1145 &gEfiAbsolutePointerProtocolGuid
,
1146 (VOID
**) &AbsolutePointer
1149 if (EFI_ERROR (Status
)) {
1153 return ConSplitterAbsolutePointerAddDevice (&mConIn
, AbsolutePointer
);
1158 Start Console Out Consplitter on device handle.
1160 @param This Protocol instance pointer.
1161 @param ControllerHandle Handle of device to bind driver to.
1162 @param RemainingDevicePath Optional parameter use to pick a specific child
1165 @retval EFI_SUCCESS Console Out Consplitter is added to ControllerHandle.
1166 @retval other Console Out Consplitter does not support this device.
1171 ConSplitterConOutDriverBindingStart (
1172 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1173 IN EFI_HANDLE ControllerHandle
,
1174 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
1178 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
;
1179 EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
;
1180 EFI_UGA_DRAW_PROTOCOL
*UgaDraw
;
1182 Status
= ConSplitterStart (
1185 mConOut
.VirtualHandle
,
1186 &gEfiConsoleOutDeviceGuid
,
1187 &gEfiSimpleTextOutProtocolGuid
,
1190 if (EFI_ERROR (Status
)) {
1194 GraphicsOutput
= NULL
;
1197 // Try to Open Graphics Output protocol
1199 Status
= gBS
->OpenProtocol (
1201 &gEfiGraphicsOutputProtocolGuid
,
1202 (VOID
**) &GraphicsOutput
,
1203 This
->DriverBindingHandle
,
1204 mConOut
.VirtualHandle
,
1205 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1208 if (EFI_ERROR (Status
) && FeaturePcdGet (PcdUgaConsumeSupport
)) {
1210 // Open UGA_DRAW protocol
1212 Status
= gBS
->OpenProtocol (
1214 &gEfiUgaDrawProtocolGuid
,
1216 This
->DriverBindingHandle
,
1217 mConOut
.VirtualHandle
,
1218 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1223 // When new console device is added, the new mode will be set later,
1224 // so put current mode back to init state.
1226 mConOut
.TextOutMode
.Mode
= 0xFF;
1229 // If both ConOut and StdErr incorporate the same Text Out device,
1230 // their MaxMode and QueryData should be the intersection of both.
1232 Status
= ConSplitterTextOutAddDevice (&mConOut
, TextOut
, GraphicsOutput
, UgaDraw
);
1233 ConSplitterTextOutSetAttribute (&mConOut
.TextOut
, EFI_TEXT_ATTR (EFI_LIGHTGRAY
, EFI_BLACK
));
1235 if (FeaturePcdGet (PcdConOutUgaSupport
) && FeaturePcdGet (PcdUgaConsumeSupport
)) {
1237 // Match the UGA mode data of ConOut with the current mode
1239 if (UgaDraw
!= NULL
) {
1242 &mConOut
.UgaHorizontalResolution
,
1243 &mConOut
.UgaVerticalResolution
,
1244 &mConOut
.UgaColorDepth
,
1245 &mConOut
.UgaRefreshRate
1254 Start Standard Error Consplitter on device handle.
1256 @param This Protocol instance pointer.
1257 @param ControllerHandle Handle of device to bind driver to.
1258 @param RemainingDevicePath Optional parameter use to pick a specific child
1261 @retval EFI_SUCCESS Standard Error Consplitter is added to ControllerHandle.
1262 @retval other Standard Error Consplitter does not support this device.
1267 ConSplitterStdErrDriverBindingStart (
1268 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1269 IN EFI_HANDLE ControllerHandle
,
1270 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
1274 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
;
1276 Status
= ConSplitterStart (
1279 mStdErr
.VirtualHandle
,
1280 &gEfiStandardErrorDeviceGuid
,
1281 &gEfiSimpleTextOutProtocolGuid
,
1284 if (EFI_ERROR (Status
)) {
1289 // When new console device is added, the new mode will be set later,
1290 // so put current mode back to init state.
1292 mStdErr
.TextOutMode
.Mode
= 0xFF;
1295 // If both ConOut and StdErr incorporate the same Text Out device,
1296 // their MaxMode and QueryData should be the intersection of both.
1298 Status
= ConSplitterTextOutAddDevice (&mStdErr
, TextOut
, NULL
, NULL
);
1299 ConSplitterTextOutSetAttribute (&mStdErr
.TextOut
, EFI_TEXT_ATTR (EFI_MAGENTA
, EFI_BLACK
));
1300 if (EFI_ERROR (Status
)) {
1304 if (mStdErr
.CurrentNumberOfConsoles
== 1) {
1305 gST
->StandardErrorHandle
= mStdErr
.VirtualHandle
;
1306 gST
->StdErr
= &mStdErr
.TextOut
;
1308 // Update the CRC32 in the EFI System Table header
1311 gBS
->CalculateCrc32 (
1312 (UINT8
*) &gST
->Hdr
,
1313 gST
->Hdr
.HeaderSize
,
1323 Stop ConSplitter on device handle by opening Console Device Guid on device handle
1324 and the console virtual handle.
1326 @param This Protocol instance pointer.
1327 @param ControllerHandle Handle of device.
1328 @param ConSplitterVirtualHandle Console virtual Handle.
1329 @param DeviceGuid The specified Console Device, such as ConInDev,
1331 @param InterfaceGuid The specified protocol to be opened.
1332 @param Interface Protocol interface returned.
1334 @retval EFI_SUCCESS Stop ConSplitter on ControllerHandle successfully.
1335 @retval other Failed to Stop ConSplitter on ControllerHandle.
1340 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1341 IN EFI_HANDLE ControllerHandle
,
1342 IN EFI_HANDLE ConSplitterVirtualHandle
,
1343 IN EFI_GUID
*DeviceGuid
,
1344 IN EFI_GUID
*InterfaceGuid
,
1350 Status
= gBS
->OpenProtocol (
1354 This
->DriverBindingHandle
,
1356 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1358 if (EFI_ERROR (Status
)) {
1362 // close the protocol refered.
1364 gBS
->CloseProtocol (
1367 This
->DriverBindingHandle
,
1368 ConSplitterVirtualHandle
1370 gBS
->CloseProtocol (
1373 This
->DriverBindingHandle
,
1382 Stop Console In ConSplitter on ControllerHandle by closing Console In Devcice GUID.
1384 @param This Protocol instance pointer.
1385 @param ControllerHandle Handle of device to stop driver on
1386 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
1387 children is zero stop the entire bus driver.
1388 @param ChildHandleBuffer List of Child Handles to Stop.
1390 @retval EFI_SUCCESS This driver is removed ControllerHandle
1391 @retval other This driver was not removed from this device
1396 ConSplitterConInDriverBindingStop (
1397 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1398 IN EFI_HANDLE ControllerHandle
,
1399 IN UINTN NumberOfChildren
,
1400 IN EFI_HANDLE
*ChildHandleBuffer
1404 EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*TextIn
;
1406 EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*TextInEx
;
1407 if (NumberOfChildren
== 0) {
1411 Status
= gBS
->OpenProtocol (
1413 &gEfiSimpleTextInputExProtocolGuid
,
1414 (VOID
**) &TextInEx
,
1415 This
->DriverBindingHandle
,
1417 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1419 if (EFI_ERROR (Status
)) {
1423 Status
= ConSplitterTextInExDeleteDevice (&mConIn
, TextInEx
);
1424 if (EFI_ERROR (Status
)) {
1429 Status
= ConSplitterStop (
1432 mConIn
.VirtualHandle
,
1433 &gEfiConsoleInDeviceGuid
,
1434 &gEfiSimpleTextInProtocolGuid
,
1437 if (EFI_ERROR (Status
)) {
1441 // Delete this console input device's data structures.
1443 return ConSplitterTextInDeleteDevice (&mConIn
, TextIn
);
1448 Stop Simple Pointer protocol ConSplitter on ControllerHandle by closing
1449 Simple Pointer protocol.
1451 @param This Protocol instance pointer.
1452 @param ControllerHandle Handle of device to stop driver on
1453 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
1454 children is zero stop the entire bus driver.
1455 @param ChildHandleBuffer List of Child Handles to Stop.
1457 @retval EFI_SUCCESS This driver is removed ControllerHandle
1458 @retval other This driver was not removed from this device
1463 ConSplitterSimplePointerDriverBindingStop (
1464 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1465 IN EFI_HANDLE ControllerHandle
,
1466 IN UINTN NumberOfChildren
,
1467 IN EFI_HANDLE
*ChildHandleBuffer
1471 EFI_SIMPLE_POINTER_PROTOCOL
*SimplePointer
;
1473 if (NumberOfChildren
== 0) {
1477 Status
= ConSplitterStop (
1480 mConIn
.VirtualHandle
,
1481 &gEfiSimplePointerProtocolGuid
,
1482 &gEfiSimplePointerProtocolGuid
,
1483 (VOID
**) &SimplePointer
1485 if (EFI_ERROR (Status
)) {
1489 // Delete this console input device's data structures.
1491 return ConSplitterSimplePointerDeleteDevice (&mConIn
, SimplePointer
);
1496 Stop Absolute Pointer protocol ConSplitter on ControllerHandle by closing
1497 Absolute Pointer protocol.
1499 @param This Protocol instance pointer.
1500 @param ControllerHandle Handle of device to stop driver on
1501 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
1502 children is zero stop the entire bus driver.
1503 @param ChildHandleBuffer List of Child Handles to Stop.
1505 @retval EFI_SUCCESS This driver is removed ControllerHandle
1506 @retval other This driver was not removed from this device
1511 ConSplitterAbsolutePointerDriverBindingStop (
1512 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1513 IN EFI_HANDLE ControllerHandle
,
1514 IN UINTN NumberOfChildren
,
1515 IN EFI_HANDLE
*ChildHandleBuffer
1519 EFI_ABSOLUTE_POINTER_PROTOCOL
*AbsolutePointer
;
1521 if (NumberOfChildren
== 0) {
1525 Status
= ConSplitterStop (
1528 mConIn
.VirtualHandle
,
1529 &gEfiAbsolutePointerProtocolGuid
,
1530 &gEfiAbsolutePointerProtocolGuid
,
1531 (VOID
**) &AbsolutePointer
1533 if (EFI_ERROR (Status
)) {
1537 // Delete this console input device's data structures.
1539 return ConSplitterAbsolutePointerDeleteDevice (&mConIn
, AbsolutePointer
);
1544 Stop Console Out ConSplitter on device handle by closing Console Out Devcice GUID.
1546 @param This Protocol instance pointer.
1547 @param ControllerHandle Handle of device to stop driver on
1548 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
1549 children is zero stop the entire bus driver.
1550 @param ChildHandleBuffer List of Child Handles to Stop.
1552 @retval EFI_SUCCESS This driver is removed ControllerHandle
1553 @retval other This driver was not removed from this device
1558 ConSplitterConOutDriverBindingStop (
1559 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1560 IN EFI_HANDLE ControllerHandle
,
1561 IN UINTN NumberOfChildren
,
1562 IN EFI_HANDLE
*ChildHandleBuffer
1566 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
;
1568 if (NumberOfChildren
== 0) {
1572 Status
= ConSplitterStop (
1575 mConOut
.VirtualHandle
,
1576 &gEfiConsoleOutDeviceGuid
,
1577 &gEfiSimpleTextOutProtocolGuid
,
1580 if (EFI_ERROR (Status
)) {
1585 // Delete this console output device's data structures.
1587 return ConSplitterTextOutDeleteDevice (&mConOut
, TextOut
);
1592 Stop Standard Error ConSplitter on ControllerHandle by closing Standard Error GUID.
1594 @param This Protocol instance pointer.
1595 @param ControllerHandle Handle of device to stop driver on
1596 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
1597 children is zero stop the entire bus driver.
1598 @param ChildHandleBuffer List of Child Handles to Stop.
1600 @retval EFI_SUCCESS This driver is removed ControllerHandle
1601 @retval other This driver was not removed from this device
1606 ConSplitterStdErrDriverBindingStop (
1607 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1608 IN EFI_HANDLE ControllerHandle
,
1609 IN UINTN NumberOfChildren
,
1610 IN EFI_HANDLE
*ChildHandleBuffer
1614 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
;
1616 if (NumberOfChildren
== 0) {
1620 Status
= ConSplitterStop (
1623 mStdErr
.VirtualHandle
,
1624 &gEfiStandardErrorDeviceGuid
,
1625 &gEfiSimpleTextOutProtocolGuid
,
1628 if (EFI_ERROR (Status
)) {
1632 // Delete this console error out device's data structures.
1634 Status
= ConSplitterTextOutDeleteDevice (&mStdErr
, TextOut
);
1635 if (EFI_ERROR (Status
)) {
1639 if (mStdErr
.CurrentNumberOfConsoles
== 0) {
1640 gST
->StandardErrorHandle
= NULL
;
1643 // Update the CRC32 in the EFI System Table header
1646 gBS
->CalculateCrc32 (
1647 (UINT8
*) &gST
->Hdr
,
1648 gST
->Hdr
.HeaderSize
,
1658 Take the passed in Buffer of size SizeOfCount and grow the buffer
1659 by MAX (CONSOLE_SPLITTER_CONSOLES_ALLOC_UNIT, MaxGrow) * SizeOfCount
1660 bytes. Copy the current data in Buffer to the new version of Buffer
1661 and free the old version of buffer.
1663 @param SizeOfCount Size of element in array
1664 @param Count Current number of elements in array
1665 @param Buffer Bigger version of passed in Buffer with all the
1668 @retval EFI_SUCCESS Buffer size has grown
1669 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
1673 ConSplitterGrowBuffer (
1674 IN UINTN SizeOfCount
,
1676 IN OUT VOID
**Buffer
1684 // grow the buffer to new buffer size,
1685 // copy the old buffer's content to the new-size buffer,
1686 // then free the old buffer.
1688 OldSize
= *Count
* SizeOfCount
;
1689 *Count
+= CONSOLE_SPLITTER_CONSOLES_ALLOC_UNIT
;
1690 NewSize
= *Count
* SizeOfCount
;
1692 Ptr
= AllocateZeroPool (NewSize
);
1694 return EFI_OUT_OF_RESOURCES
;
1697 CopyMem (Ptr
, *Buffer
, OldSize
);
1699 if (*Buffer
!= NULL
) {
1710 Add Text Input Device in Consplitter Text Input list.
1712 @param Private Text In Splitter pointer.
1713 @param TextIn Simple Text Input protocol pointer.
1715 @retval EFI_SUCCESS Text Input Device added successfully.
1716 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
1720 ConSplitterTextInAddDevice (
1721 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
1722 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*TextIn
1728 // If the Text In List is full, enlarge it by calling growbuffer().
1730 if (Private
->CurrentNumberOfConsoles
>= Private
->TextInListCount
) {
1731 Status
= ConSplitterGrowBuffer (
1732 sizeof (EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*),
1733 &Private
->TextInListCount
,
1734 (VOID
**) &Private
->TextInList
1736 if (EFI_ERROR (Status
)) {
1737 return EFI_OUT_OF_RESOURCES
;
1741 // Add the new text-in device data structure into the Text In List.
1743 Private
->TextInList
[Private
->CurrentNumberOfConsoles
] = TextIn
;
1744 Private
->CurrentNumberOfConsoles
++;
1747 // Extra CheckEvent added to reduce the double CheckEvent() in UI.c
1749 gBS
->CheckEvent (TextIn
->WaitForKey
);
1756 Remove Simple Text Device in Consplitter Absolute Pointer list.
1758 @param Private Text In Splitter pointer.
1759 @param TextIn Simple Text protocol pointer.
1761 @retval EFI_SUCCESS Simple Text Device removed successfully.
1762 @retval EFI_NOT_FOUND No Simple Text Device found.
1766 ConSplitterTextInDeleteDevice (
1767 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
1768 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*TextIn
1773 // Remove the specified text-in device data structure from the Text In List,
1774 // and rearrange the remaining data structures in the Text In List.
1776 for (Index
= 0; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
1777 if (Private
->TextInList
[Index
] == TextIn
) {
1778 for (Index
= Index
; Index
< Private
->CurrentNumberOfConsoles
- 1; Index
++) {
1779 Private
->TextInList
[Index
] = Private
->TextInList
[Index
+ 1];
1782 Private
->CurrentNumberOfConsoles
--;
1787 return EFI_NOT_FOUND
;
1791 Add Text Input Ex Device in Consplitter Text Input Ex list.
1793 @param Private Text In Splitter pointer.
1794 @param TextInEx Simple Text Ex Input protocol pointer.
1796 @retval EFI_SUCCESS Text Input Ex Device added successfully.
1797 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
1801 ConSplitterTextInExAddDevice (
1802 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
1803 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*TextInEx
1809 // If the TextInEx List is full, enlarge it by calling growbuffer().
1811 if (Private
->CurrentNumberOfExConsoles
>= Private
->TextInExListCount
) {
1812 Status
= ConSplitterGrowBuffer (
1813 sizeof (EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*),
1814 &Private
->TextInExListCount
,
1815 (VOID
**) &Private
->TextInExList
1817 if (EFI_ERROR (Status
)) {
1818 return EFI_OUT_OF_RESOURCES
;
1822 // Add the new text-in device data structure into the Text In List.
1824 Private
->TextInExList
[Private
->CurrentNumberOfExConsoles
] = TextInEx
;
1825 Private
->CurrentNumberOfExConsoles
++;
1828 // Extra CheckEvent added to reduce the double CheckEvent() in UI.c
1830 gBS
->CheckEvent (TextInEx
->WaitForKeyEx
);
1836 Remove Simple Text Ex Device in Consplitter Absolute Pointer list.
1838 @param Private Text In Splitter pointer.
1839 @param TextInEx Simple Text Ex protocol pointer.
1841 @retval EFI_SUCCESS Simple Text Ex Device removed successfully.
1842 @retval EFI_NOT_FOUND No Simple Text Ex Device found.
1846 ConSplitterTextInExDeleteDevice (
1847 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
1848 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*TextInEx
1853 // Remove the specified text-in device data structure from the Text In List,
1854 // and rearrange the remaining data structures in the Text In List.
1856 for (Index
= 0; Index
< Private
->CurrentNumberOfExConsoles
; Index
++) {
1857 if (Private
->TextInExList
[Index
] == TextInEx
) {
1858 for (Index
= Index
; Index
< Private
->CurrentNumberOfExConsoles
- 1; Index
++) {
1859 Private
->TextInExList
[Index
] = Private
->TextInExList
[Index
+ 1];
1862 Private
->CurrentNumberOfExConsoles
--;
1867 return EFI_NOT_FOUND
;
1872 Add Simple Pointer Device in Consplitter Simple Pointer list.
1874 @param Private Text In Splitter pointer.
1875 @param SimplePointer Simple Pointer protocol pointer.
1877 @retval EFI_SUCCESS Simple Pointer Device added successfully.
1878 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
1882 ConSplitterSimplePointerAddDevice (
1883 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
1884 IN EFI_SIMPLE_POINTER_PROTOCOL
*SimplePointer
1890 // If the Text In List is full, enlarge it by calling growbuffer().
1892 if (Private
->CurrentNumberOfPointers
>= Private
->PointerListCount
) {
1893 Status
= ConSplitterGrowBuffer (
1894 sizeof (EFI_SIMPLE_POINTER_PROTOCOL
*),
1895 &Private
->PointerListCount
,
1896 (VOID
**) &Private
->PointerList
1898 if (EFI_ERROR (Status
)) {
1899 return EFI_OUT_OF_RESOURCES
;
1903 // Add the new text-in device data structure into the Text In List.
1905 Private
->PointerList
[Private
->CurrentNumberOfPointers
] = SimplePointer
;
1906 Private
->CurrentNumberOfPointers
++;
1912 Remove Simple Pointer Device in Consplitter Absolute Pointer list.
1914 @param Private Text In Splitter pointer.
1915 @param SimplePointer Simple Pointer protocol pointer.
1917 @retval EFI_SUCCESS Simple Pointer Device removed successfully.
1918 @retval EFI_NOT_FOUND No Simple Pointer Device found.
1922 ConSplitterSimplePointerDeleteDevice (
1923 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
1924 IN EFI_SIMPLE_POINTER_PROTOCOL
*SimplePointer
1929 // Remove the specified text-in device data structure from the Text In List,
1930 // and rearrange the remaining data structures in the Text In List.
1932 for (Index
= 0; Index
< Private
->CurrentNumberOfPointers
; Index
++) {
1933 if (Private
->PointerList
[Index
] == SimplePointer
) {
1934 for (Index
= Index
; Index
< Private
->CurrentNumberOfPointers
- 1; Index
++) {
1935 Private
->PointerList
[Index
] = Private
->PointerList
[Index
+ 1];
1938 Private
->CurrentNumberOfPointers
--;
1943 return EFI_NOT_FOUND
;
1948 Add Absolute Pointer Device in Consplitter Absolute Pointer list.
1950 @param Private Text In Splitter pointer.
1951 @param AbsolutePointer Absolute Pointer protocol pointer.
1953 @retval EFI_SUCCESS Absolute Pointer Device added successfully.
1954 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
1958 ConSplitterAbsolutePointerAddDevice (
1959 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
1960 IN EFI_ABSOLUTE_POINTER_PROTOCOL
*AbsolutePointer
1966 // If the Absolute Pointer List is full, enlarge it by calling growbuffer().
1968 if (Private
->CurrentNumberOfAbsolutePointers
>= Private
->AbsolutePointerListCount
) {
1969 Status
= ConSplitterGrowBuffer (
1970 sizeof (EFI_ABSOLUTE_POINTER_PROTOCOL
*),
1971 &Private
->AbsolutePointerListCount
,
1972 (VOID
**) &Private
->AbsolutePointerList
1974 if (EFI_ERROR (Status
)) {
1975 return EFI_OUT_OF_RESOURCES
;
1979 // Add the new text-in device data structure into the Text In List.
1981 Private
->AbsolutePointerList
[Private
->CurrentNumberOfAbsolutePointers
] = AbsolutePointer
;
1982 Private
->CurrentNumberOfAbsolutePointers
++;
1988 Remove Absolute Pointer Device in Consplitter Absolute Pointer list.
1990 @param Private Text In Splitter pointer.
1991 @param AbsolutePointer Absolute Pointer protocol pointer.
1993 @retval EFI_SUCCESS Absolute Pointer Device removed successfully.
1994 @retval EFI_NOT_FOUND No Absolute Pointer Device found.
1998 ConSplitterAbsolutePointerDeleteDevice (
1999 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
2000 IN EFI_ABSOLUTE_POINTER_PROTOCOL
*AbsolutePointer
2005 // Remove the specified text-in device data structure from the Text In List,
2006 // and rearrange the remaining data structures in the Text In List.
2008 for (Index
= 0; Index
< Private
->CurrentNumberOfAbsolutePointers
; Index
++) {
2009 if (Private
->AbsolutePointerList
[Index
] == AbsolutePointer
) {
2010 for (Index
= Index
; Index
< Private
->CurrentNumberOfAbsolutePointers
- 1; Index
++) {
2011 Private
->AbsolutePointerList
[Index
] = Private
->AbsolutePointerList
[Index
+ 1];
2014 Private
->CurrentNumberOfAbsolutePointers
--;
2019 return EFI_NOT_FOUND
;
2023 ConSplitterGrowMapTable (
2024 IN TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
2030 INT32
*TextOutModeMap
;
2031 INT32
*OldTextOutModeMap
;
2035 NewSize
= Private
->TextOutListCount
* sizeof (INT32
);
2036 OldTextOutModeMap
= Private
->TextOutModeMap
;
2037 TotalSize
= NewSize
* Private
->TextOutQueryDataCount
;
2039 TextOutModeMap
= AllocateZeroPool (TotalSize
);
2040 if (TextOutModeMap
== NULL
) {
2041 return EFI_OUT_OF_RESOURCES
;
2044 SetMem (TextOutModeMap
, TotalSize
, 0xFF);
2045 Private
->TextOutModeMap
= TextOutModeMap
;
2048 // If TextOutList has been enlarged, need to realloc the mode map table
2049 // The mode map table is regarded as a two dimension array.
2052 // 0 ---------> TextOutListCount ----> TextOutListCount
2053 // | -------------------------------------------
2060 // -------------------------------------------
2063 if (OldTextOutModeMap
!= NULL
) {
2065 Size
= Private
->CurrentNumberOfConsoles
* sizeof (INT32
);
2067 SrcAddress
= OldTextOutModeMap
;
2070 // Copy the old data to the new one
2072 while (Index
< Private
->TextOutMode
.MaxMode
) {
2073 CopyMem (TextOutModeMap
, SrcAddress
, Size
);
2074 TextOutModeMap
+= NewSize
;
2079 // Free the old buffer
2081 FreePool (OldTextOutModeMap
);
2089 Add the device's output mode to console splitter's mode list.
2091 @param Private Text Out Splitter pointer
2092 @param TextOut Simple Text Output protocol pointer.
2094 @retval EFI_SUCCESS Device added successfully.
2095 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
2099 ConSplitterAddOutputMode (
2100 IN TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
,
2101 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
2109 MaxMode
= TextOut
->Mode
->MaxMode
;
2110 Private
->TextOutMode
.MaxMode
= MaxMode
;
2113 // Grow the buffer if query data buffer is not large enough to
2114 // hold all the mode supported by the first console.
2116 while (MaxMode
> (INT32
) Private
->TextOutQueryDataCount
) {
2117 Status
= ConSplitterGrowBuffer (
2118 sizeof (TEXT_OUT_SPLITTER_QUERY_DATA
),
2119 &Private
->TextOutQueryDataCount
,
2120 (VOID
**) &Private
->TextOutQueryData
2122 if (EFI_ERROR (Status
)) {
2123 return EFI_OUT_OF_RESOURCES
;
2127 // Allocate buffer for the output mode map
2129 Status
= ConSplitterGrowMapTable (Private
);
2130 if (EFI_ERROR (Status
)) {
2131 return EFI_OUT_OF_RESOURCES
;
2134 // As the first textout device, directly add the mode in to QueryData
2135 // and at the same time record the mapping between QueryData and TextOut.
2139 while (Mode
< MaxMode
) {
2140 Status
= TextOut
->QueryMode (
2143 &Private
->TextOutQueryData
[Mode
].Columns
,
2144 &Private
->TextOutQueryData
[Mode
].Rows
2147 // If mode 1 (80x50) is not supported, make sure mode 1 in TextOutQueryData
2150 if ((EFI_ERROR(Status
)) && (Mode
== 1)) {
2151 Private
->TextOutQueryData
[Mode
].Columns
= 0;
2152 Private
->TextOutQueryData
[Mode
].Rows
= 0;
2154 Private
->TextOutModeMap
[Index
] = Mode
;
2156 Index
+= Private
->TextOutListCount
;
2163 Reconstruct TextOutModeMap to get intersection of modes
2165 This routine reconstruct TextOutModeMap to get the intersection
2166 of modes for all console out devices. Because EFI/UEFI spec require
2167 mode 0 is 80x25, mode 1 is 80x50, this routine will not check the
2168 intersection for mode 0 and mode 1.
2170 @param TextOutModeMap Current text out mode map, begin with the mode 80x25
2171 @param NewlyAddedMap New text out mode map, begin with the mode 80x25
2172 @param MapStepSize Mode step size for one console device
2173 @param NewMapStepSize Mode step size for one console device
2174 @param MaxMode Current max text mode
2175 @param CurrentMode Current text mode
2181 ConSplitterGetIntersection (
2182 IN INT32
*TextOutModeMap
,
2183 IN INT32
*NewlyAddedMap
,
2184 IN UINTN MapStepSize
,
2185 IN UINTN NewMapStepSize
,
2187 OUT INT32
*CurrentMode
2191 INT32
*CurrentMapEntry
;
2192 INT32
*NextMapEntry
;
2193 INT32 CurrentMaxMode
;
2197 // According to EFI/UEFI spec, mode 0 and mode 1 have been reserved
2198 // for 80x25 and 80x50 in Simple Text Out protocol, so don't make intersection
2199 // for mode 0 and mode 1, mode number starts from 2.
2202 CurrentMapEntry
= &TextOutModeMap
[MapStepSize
* 2];
2203 NextMapEntry
= &TextOutModeMap
[MapStepSize
* 2];
2204 NewlyAddedMap
= &NewlyAddedMap
[NewMapStepSize
* 2];
2206 CurrentMaxMode
= *MaxMode
;
2207 Mode
= *CurrentMode
;
2209 while (Index
< CurrentMaxMode
) {
2210 if (*NewlyAddedMap
== -1) {
2212 // This mode is not supported any more. Remove it. Special care
2213 // must be taken as this remove will also affect current mode;
2215 if (Index
== *CurrentMode
) {
2217 } else if (Index
< *CurrentMode
) {
2222 if (CurrentMapEntry
!= NextMapEntry
) {
2223 CopyMem (NextMapEntry
, CurrentMapEntry
, MapStepSize
* sizeof (INT32
));
2226 NextMapEntry
+= MapStepSize
;
2229 CurrentMapEntry
+= MapStepSize
;
2230 NewlyAddedMap
+= NewMapStepSize
;
2234 *CurrentMode
= Mode
;
2241 Add the device's output mode to console splitter's mode list.
2243 @param Private Text Out Splitter pointer
2244 @param TextOut Simple Text Output protocol pointer.
2250 ConSplitterSyncOutputMode (
2251 IN TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
,
2252 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
2255 INT32 CurrentMaxMode
;
2258 INT32
*TextOutModeMap
;
2261 TEXT_OUT_SPLITTER_QUERY_DATA
*TextOutQueryData
;
2268 // Must make sure that current mode won't change even if mode number changes
2270 CurrentMaxMode
= Private
->TextOutMode
.MaxMode
;
2271 TextOutModeMap
= Private
->TextOutModeMap
;
2272 StepSize
= Private
->TextOutListCount
;
2273 TextOutQueryData
= Private
->TextOutQueryData
;
2276 // Query all the mode that the newly added TextOut supports
2279 MapTable
= TextOutModeMap
+ Private
->CurrentNumberOfConsoles
;
2280 while (Mode
< TextOut
->Mode
->MaxMode
) {
2281 Status
= TextOut
->QueryMode (TextOut
, Mode
, &Columns
, &Rows
);
2282 if (EFI_ERROR(Status
)) {
2284 MapTable
[StepSize
] = Mode
;
2285 TextOutQueryData
[Mode
].Columns
= 0;
2286 TextOutQueryData
[Mode
].Rows
= 0;
2292 // Search the intersection map and QueryData database to see if they intersects
2295 while (Index
< CurrentMaxMode
) {
2296 QueryMode
= *(TextOutModeMap
+ Index
* StepSize
);
2297 if ((TextOutQueryData
[QueryMode
].Rows
== Rows
) && (TextOutQueryData
[QueryMode
].Columns
== Columns
)) {
2298 MapTable
[Index
* StepSize
] = Mode
;
2308 // Now search the TextOutModeMap table to find the intersection of supported
2309 // mode between ConSplitter and the newly added device.
2311 ConSplitterGetIntersection (
2316 &Private
->TextOutMode
.MaxMode
,
2317 &Private
->TextOutMode
.Mode
2325 Sync output device between ConOut and StdErr output.
2327 @retval EFI_SUCCESS Sync implemented successfully.
2328 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
2332 ConSplitterGetIntersectionBetweenConOutAndStrErr (
2336 UINTN ConOutNumOfConsoles
;
2337 UINTN StdErrNumOfConsoles
;
2338 TEXT_OUT_AND_GOP_DATA
*ConOutTextOutList
;
2339 TEXT_OUT_AND_GOP_DATA
*StdErrTextOutList
;
2343 UINTN ConOutColumns
;
2345 UINTN StdErrColumns
;
2346 INT32 ConOutMaxMode
;
2347 INT32 StdErrMaxMode
;
2352 INT32
*ConOutModeMap
;
2353 INT32
*StdErrModeMap
;
2354 INT32
*ConOutMapTable
;
2355 INT32
*StdErrMapTable
;
2356 TEXT_OUT_SPLITTER_QUERY_DATA
*ConOutQueryData
;
2357 TEXT_OUT_SPLITTER_QUERY_DATA
*StdErrQueryData
;
2358 UINTN ConOutStepSize
;
2359 UINTN StdErrStepSize
;
2360 BOOLEAN FoundTheSameTextOut
;
2361 UINTN ConOutMapTableSize
;
2362 UINTN StdErrMapTableSize
;
2364 ConOutNumOfConsoles
= mConOut
.CurrentNumberOfConsoles
;
2365 StdErrNumOfConsoles
= mStdErr
.CurrentNumberOfConsoles
;
2366 ConOutTextOutList
= mConOut
.TextOutList
;
2367 StdErrTextOutList
= mStdErr
.TextOutList
;
2370 FoundTheSameTextOut
= FALSE
;
2371 while ((Indexi
< ConOutNumOfConsoles
) && (!FoundTheSameTextOut
)) {
2373 while (Indexj
< StdErrNumOfConsoles
) {
2374 if (ConOutTextOutList
->TextOut
== StdErrTextOutList
->TextOut
) {
2375 FoundTheSameTextOut
= TRUE
;
2380 StdErrTextOutList
++;
2384 ConOutTextOutList
++;
2387 if (!FoundTheSameTextOut
) {
2391 // Must make sure that current mode won't change even if mode number changes
2393 ConOutMaxMode
= mConOut
.TextOutMode
.MaxMode
;
2394 ConOutModeMap
= mConOut
.TextOutModeMap
;
2395 ConOutStepSize
= mConOut
.TextOutListCount
;
2396 ConOutQueryData
= mConOut
.TextOutQueryData
;
2398 StdErrMaxMode
= mStdErr
.TextOutMode
.MaxMode
;
2399 StdErrModeMap
= mStdErr
.TextOutModeMap
;
2400 StdErrStepSize
= mStdErr
.TextOutListCount
;
2401 StdErrQueryData
= mStdErr
.TextOutQueryData
;
2404 // Allocate the map table and set the map table's index to -1.
2406 ConOutMapTableSize
= ConOutMaxMode
* sizeof (INT32
);
2407 ConOutMapTable
= AllocateZeroPool (ConOutMapTableSize
);
2408 if (ConOutMapTable
== NULL
) {
2409 return EFI_OUT_OF_RESOURCES
;
2412 SetMem (ConOutMapTable
, ConOutMapTableSize
, 0xFF);
2414 StdErrMapTableSize
= StdErrMaxMode
* sizeof (INT32
);
2415 StdErrMapTable
= AllocateZeroPool (StdErrMapTableSize
);
2416 if (StdErrMapTable
== NULL
) {
2417 return EFI_OUT_OF_RESOURCES
;
2420 SetMem (StdErrMapTable
, StdErrMapTableSize
, 0xFF);
2423 // Find the intersection of the two set of modes. If they actually intersect, the
2424 // correponding entry in the map table is set to 1.
2427 while (Mode
< ConOutMaxMode
) {
2429 // Search the intersection map and QueryData database to see if they intersect
2432 ConOutMode
= *(ConOutModeMap
+ Mode
* ConOutStepSize
);
2433 ConOutRows
= ConOutQueryData
[ConOutMode
].Rows
;
2434 ConOutColumns
= ConOutQueryData
[ConOutMode
].Columns
;
2435 while (Index
< StdErrMaxMode
) {
2436 StdErrMode
= *(StdErrModeMap
+ Index
* StdErrStepSize
);
2437 StdErrRows
= StdErrQueryData
[StdErrMode
].Rows
;
2438 StdErrColumns
= StdErrQueryData
[StdErrMode
].Columns
;
2439 if ((StdErrRows
== ConOutRows
) && (StdErrColumns
== ConOutColumns
)) {
2440 ConOutMapTable
[Mode
] = 1;
2441 StdErrMapTable
[Index
] = 1;
2451 // Now search the TextOutModeMap table to find the intersection of supported
2452 // mode between ConSplitter and the newly added device.
2454 ConSplitterGetIntersection (
2457 mConOut
.TextOutListCount
,
2459 &(mConOut
.TextOutMode
.MaxMode
),
2460 &(mConOut
.TextOutMode
.Mode
)
2462 if (mConOut
.TextOutMode
.Mode
< 0) {
2463 mConOut
.TextOut
.SetMode (&(mConOut
.TextOut
), 0);
2466 ConSplitterGetIntersection (
2469 mStdErr
.TextOutListCount
,
2471 &(mStdErr
.TextOutMode
.MaxMode
),
2472 &(mStdErr
.TextOutMode
.Mode
)
2474 if (mStdErr
.TextOutMode
.Mode
< 0) {
2475 mStdErr
.TextOut
.SetMode (&(mStdErr
.TextOut
), 0);
2478 FreePool (ConOutMapTable
);
2479 FreePool (StdErrMapTable
);
2486 Add GOP or UGA output mode into Consplitter Text Out list.
2488 @param Private Text Out Splitter pointer.
2489 @param GraphicsOutput Graphics Output protocol pointer.
2490 @param UgaDraw UGA Draw protocol pointer.
2492 @retval EFI_SUCCESS Output mode added successfully.
2493 @retval other Failed to add output mode.
2497 ConSplitterAddGraphicsOutputMode (
2498 IN TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
,
2499 IN EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
,
2500 IN EFI_UGA_DRAW_PROTOCOL
*UgaDraw
2506 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*Mode
;
2508 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*Info
;
2509 EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE
*CurrentGraphicsOutputMode
;
2510 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*ModeBuffer
;
2511 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*MatchedMode
;
2514 BOOLEAN AlreadyExist
;
2515 UINT32 UgaHorizontalResolution
;
2516 UINT32 UgaVerticalResolution
;
2517 UINT32 UgaColorDepth
;
2518 UINT32 UgaRefreshRate
;
2520 if ((GraphicsOutput
== NULL
) && (UgaDraw
== NULL
)) {
2521 return EFI_UNSUPPORTED
;
2524 CurrentGraphicsOutputMode
= Private
->GraphicsOutput
.Mode
;
2529 if (Private
->CurrentNumberOfUgaDraw
!= 0) {
2531 // If any UGA device has already been added, then there is no need to
2532 // calculate intersection of display mode of different GOP/UGA device,
2533 // since only one display mode will be exported (i.e. user-defined mode)
2538 if (GraphicsOutput
!= NULL
) {
2539 if (Private
->CurrentNumberOfGraphicsOutput
== 0) {
2541 // This is the first Graphics Output device added
2543 CurrentGraphicsOutputMode
->MaxMode
= GraphicsOutput
->Mode
->MaxMode
;
2544 CurrentGraphicsOutputMode
->Mode
= GraphicsOutput
->Mode
->Mode
;
2545 CopyMem (CurrentGraphicsOutputMode
->Info
, GraphicsOutput
->Mode
->Info
, GraphicsOutput
->Mode
->SizeOfInfo
);
2546 CurrentGraphicsOutputMode
->SizeOfInfo
= GraphicsOutput
->Mode
->SizeOfInfo
;
2547 CurrentGraphicsOutputMode
->FrameBufferBase
= GraphicsOutput
->Mode
->FrameBufferBase
;
2548 CurrentGraphicsOutputMode
->FrameBufferSize
= GraphicsOutput
->Mode
->FrameBufferSize
;
2551 // Allocate resource for the private mode buffer
2553 ModeBuffer
= AllocatePool (GraphicsOutput
->Mode
->SizeOfInfo
* GraphicsOutput
->Mode
->MaxMode
);
2554 if (ModeBuffer
== NULL
) {
2555 return EFI_OUT_OF_RESOURCES
;
2557 FreePool (Private
->GraphicsOutputModeBuffer
);
2558 Private
->GraphicsOutputModeBuffer
= ModeBuffer
;
2561 // Store all supported display modes to the private mode buffer
2564 for (Index
= 0; Index
< GraphicsOutput
->Mode
->MaxMode
; Index
++) {
2565 Status
= GraphicsOutput
->QueryMode (GraphicsOutput
, (UINT32
) Index
, &SizeOfInfo
, &Info
);
2566 if (EFI_ERROR (Status
)) {
2569 CopyMem (Mode
, Info
, SizeOfInfo
);
2575 // Check intersection of display mode
2577 ModeBuffer
= AllocatePool (sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
) * CurrentGraphicsOutputMode
->MaxMode
);
2578 if (ModeBuffer
== NULL
) {
2579 return EFI_OUT_OF_RESOURCES
;
2582 MatchedMode
= ModeBuffer
;
2583 Mode
= &Private
->GraphicsOutputModeBuffer
[0];
2584 for (Index
= 0; Index
< CurrentGraphicsOutputMode
->MaxMode
; Index
++) {
2587 for (NumberIndex
= 0; NumberIndex
< GraphicsOutput
->Mode
->MaxMode
; NumberIndex
++) {
2588 Status
= GraphicsOutput
->QueryMode (GraphicsOutput
, (UINT32
) NumberIndex
, &SizeOfInfo
, &Info
);
2589 if (EFI_ERROR (Status
)) {
2592 if ((Info
->HorizontalResolution
== Mode
->HorizontalResolution
) &&
2593 (Info
->VerticalResolution
== Mode
->VerticalResolution
)) {
2602 AlreadyExist
= FALSE
;
2604 for (Info
= ModeBuffer
; Info
< MatchedMode
; Info
++) {
2605 if ((Info
->HorizontalResolution
== Mode
->HorizontalResolution
) &&
2606 (Info
->VerticalResolution
== Mode
->VerticalResolution
)) {
2607 AlreadyExist
= TRUE
;
2612 if (!AlreadyExist
) {
2613 CopyMem (MatchedMode
, Mode
, sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
));
2616 // Physical frame buffer is no longer available, change PixelFormat to PixelBltOnly
2618 MatchedMode
->Version
= 0;
2619 MatchedMode
->PixelFormat
= PixelBltOnly
;
2620 ZeroMem (&MatchedMode
->PixelInformation
, sizeof (EFI_PIXEL_BITMASK
));
2630 // Drop the old mode buffer, assign it to a new one
2632 FreePool (Private
->GraphicsOutputModeBuffer
);
2633 Private
->GraphicsOutputModeBuffer
= ModeBuffer
;
2636 // Physical frame buffer is no longer available when there are more than one physical GOP devices
2638 CurrentGraphicsOutputMode
->MaxMode
= (UINT32
) (((UINTN
) MatchedMode
- (UINTN
) ModeBuffer
) / sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
));
2639 CurrentGraphicsOutputMode
->Info
->PixelFormat
= PixelBltOnly
;
2640 ZeroMem (&CurrentGraphicsOutputMode
->Info
->PixelInformation
, sizeof (EFI_PIXEL_BITMASK
));
2641 CurrentGraphicsOutputMode
->SizeOfInfo
= sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
);
2642 CurrentGraphicsOutputMode
->FrameBufferBase
= (EFI_PHYSICAL_ADDRESS
) (UINTN
) NULL
;
2643 CurrentGraphicsOutputMode
->FrameBufferSize
= 0;
2647 // Graphics console driver can ensure the same mode for all GOP devices
2649 for (Index
= 0; Index
< CurrentGraphicsOutputMode
->MaxMode
; Index
++) {
2650 Mode
= &Private
->GraphicsOutputModeBuffer
[Index
];
2651 if ((Mode
->HorizontalResolution
== GraphicsOutput
->Mode
->Info
->HorizontalResolution
) &&
2652 (Mode
->VerticalResolution
== GraphicsOutput
->Mode
->Info
->VerticalResolution
)) {
2653 CurrentIndex
= Index
;
2657 if (Index
>= CurrentGraphicsOutputMode
->MaxMode
) {
2659 // if user defined mode is not found, set to default mode 800x600
2661 for (Index
= 0; Index
< CurrentGraphicsOutputMode
->MaxMode
; Index
++) {
2662 Mode
= &Private
->GraphicsOutputModeBuffer
[Index
];
2663 if ((Mode
->HorizontalResolution
== 800) && (Mode
->VerticalResolution
== 600)) {
2664 CurrentIndex
= Index
;
2670 if (UgaDraw
!= NULL
&& FeaturePcdGet (PcdUgaConsumeSupport
)) {
2672 // Graphics console driver can ensure the same mode for all GOP devices
2673 // so we can get the current mode from this video device
2677 &UgaHorizontalResolution
,
2678 &UgaVerticalResolution
,
2683 CurrentGraphicsOutputMode
->MaxMode
= 1;
2684 Info
= CurrentGraphicsOutputMode
->Info
;
2686 Info
->HorizontalResolution
= UgaHorizontalResolution
;
2687 Info
->VerticalResolution
= UgaVerticalResolution
;
2688 Info
->PixelFormat
= PixelBltOnly
;
2689 Info
->PixelsPerScanLine
= UgaHorizontalResolution
;
2690 CurrentGraphicsOutputMode
->SizeOfInfo
= sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
);
2691 CurrentGraphicsOutputMode
->FrameBufferBase
= (EFI_PHYSICAL_ADDRESS
) (UINTN
) NULL
;
2692 CurrentGraphicsOutputMode
->FrameBufferSize
= 0;
2695 // Update the private mode buffer
2697 CopyMem (&Private
->GraphicsOutputModeBuffer
[0], Info
, sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
));
2700 // Only mode 0 is available to be set
2707 if (GraphicsOutput
!= NULL
) {
2708 Private
->CurrentNumberOfGraphicsOutput
++;
2710 if (UgaDraw
!= NULL
&& FeaturePcdGet (PcdUgaConsumeSupport
)) {
2711 Private
->CurrentNumberOfUgaDraw
++;
2715 // Force GraphicsOutput mode to be set,
2716 // regardless whether the console is in EfiConsoleControlScreenGraphics or EfiConsoleControlScreenText mode
2718 Private
->HardwareNeedsStarting
= TRUE
;
2720 // Current mode number may need update now, so set it to an invalid mode number
2722 CurrentGraphicsOutputMode
->Mode
= 0xffff;
2724 // Graphics console can ensure all GOP devices have the same mode which can be taken as current mode.
2726 Status
= Private
->GraphicsOutput
.SetMode (&Private
->GraphicsOutput
, (UINT32
) CurrentIndex
);
2729 // If user defined mode is not valid for UGA, set to the default mode 800x600.
2731 if (EFI_ERROR(Status
)) {
2732 (Private
->GraphicsOutputModeBuffer
[0]).HorizontalResolution
= 800;
2733 (Private
->GraphicsOutputModeBuffer
[0]).VerticalResolution
= 600;
2734 Status
= Private
->GraphicsOutput
.SetMode (&Private
->GraphicsOutput
, 0);
2742 This routine will get the current console mode information (column, row)
2743 from ConsoleOutMode variable and set it; if the variable does not exist,
2744 set to user defined console mode.
2752 ConsplitterSetConsoleOutMode (
2753 IN TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
2764 CONSOLE_OUT_MODE
*ModeInfo
;
2765 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
;
2769 TextOut
= &Private
->TextOut
;
2770 MaxMode
= (UINTN
) (TextOut
->Mode
->MaxMode
);
2771 ModeInfoSize
= sizeof (CONSOLE_OUT_MODE
);
2773 ModeInfo
= AllocateZeroPool (sizeof(CONSOLE_OUT_MODE
));
2774 ASSERT(ModeInfo
!= NULL
);
2776 Status
= gRT
->GetVariable (
2778 &gEfiGenericPlatformVariableGuid
,
2785 // Set to the default mode 80 x 25 required by EFI/UEFI spec;
2786 // user can also define other valid default console mode here.
2788 if (EFI_ERROR(Status
)) {
2789 ModeInfo
->Column
= 80;
2791 Status
= gRT
->SetVariable (
2793 &gEfiGenericPlatformVariableGuid
,
2794 EFI_VARIABLE_BOOTSERVICE_ACCESS
| EFI_VARIABLE_NON_VOLATILE
,
2795 sizeof (CONSOLE_OUT_MODE
),
2800 for (Mode
= 0; Mode
< MaxMode
; Mode
++) {
2801 Status
= TextOut
->QueryMode (TextOut
, Mode
, &Col
, &Row
);
2802 if (!EFI_ERROR(Status
)) {
2803 if (Col
== ModeInfo
->Column
&& Row
== ModeInfo
->Row
) {
2806 if (Col
== 80 && Row
== 25) {
2812 Status
= TextOut
->SetMode (TextOut
, PreferMode
);
2815 // if current mode setting is failed, default 80x25 mode will be set.
2817 if (EFI_ERROR(Status
)) {
2818 Status
= TextOut
->SetMode (TextOut
, BaseMode
);
2819 ASSERT(!EFI_ERROR(Status
));
2821 ModeInfo
->Column
= 80;
2825 // Update ConOutMode variable
2827 Status
= gRT
->SetVariable (
2829 &gEfiGenericPlatformVariableGuid
,
2830 EFI_VARIABLE_BOOTSERVICE_ACCESS
| EFI_VARIABLE_NON_VOLATILE
,
2831 sizeof (CONSOLE_OUT_MODE
),
2836 gBS
->FreePool (ModeInfo
);
2841 Add Text Output Device in Consplitter Text Output list.
2843 @param Private Text Out Splitter pointer.
2844 @param TextOut Simple Text Output protocol pointer.
2845 @param GraphicsOutput Graphics Output protocol pointer.
2846 @param UgaDraw UGA Draw protocol pointer.
2848 @retval EFI_SUCCESS Text Output Device added successfully.
2849 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
2853 ConSplitterTextOutAddDevice (
2854 IN TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
,
2855 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
,
2856 IN EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
,
2857 IN EFI_UGA_DRAW_PROTOCOL
*UgaDraw
2861 UINTN CurrentNumOfConsoles
;
2864 UINT32 UgaHorizontalResolution
;
2865 UINT32 UgaVerticalResolution
;
2866 UINT32 UgaColorDepth
;
2867 UINT32 UgaRefreshRate
;
2868 TEXT_OUT_AND_GOP_DATA
*TextAndGop
;
2870 Status
= EFI_SUCCESS
;
2871 CurrentNumOfConsoles
= Private
->CurrentNumberOfConsoles
;
2874 // If the Text Out List is full, enlarge it by calling growbuffer().
2876 while (CurrentNumOfConsoles
>= Private
->TextOutListCount
) {
2877 Status
= ConSplitterGrowBuffer (
2878 sizeof (TEXT_OUT_AND_GOP_DATA
),
2879 &Private
->TextOutListCount
,
2880 (VOID
**) &Private
->TextOutList
2882 if (EFI_ERROR (Status
)) {
2883 return EFI_OUT_OF_RESOURCES
;
2886 // Also need to reallocate the TextOutModeMap table
2888 Status
= ConSplitterGrowMapTable (Private
);
2889 if (EFI_ERROR (Status
)) {
2890 return EFI_OUT_OF_RESOURCES
;
2894 TextAndGop
= &Private
->TextOutList
[CurrentNumOfConsoles
];
2896 TextAndGop
->TextOut
= TextOut
;
2897 TextAndGop
->GraphicsOutput
= GraphicsOutput
;
2898 TextAndGop
->UgaDraw
= UgaDraw
;
2900 if ((GraphicsOutput
== NULL
) && (UgaDraw
== NULL
)) {
2902 // If No GOP/UGA device then use the ConOut device
2904 TextAndGop
->TextOutEnabled
= TRUE
;
2907 // If GOP/UGA device use ConOut device only used if screen is in Text mode
2909 TextAndGop
->TextOutEnabled
= (BOOLEAN
) (Private
->ConsoleOutputMode
== EfiConsoleControlScreenText
);
2912 if (CurrentNumOfConsoles
== 0) {
2914 // Add the first device's output mode to console splitter's mode list
2916 Status
= ConSplitterAddOutputMode (Private
, TextOut
);
2918 ConSplitterSyncOutputMode (Private
, TextOut
);
2921 Private
->CurrentNumberOfConsoles
++;
2924 // Scan both TextOutList, for the intersection TextOut device
2925 // maybe both ConOut and StdErr incorporate the same Text Out
2926 // device in them, thus the output of both should be synced.
2928 ConSplitterGetIntersectionBetweenConOutAndStrErr ();
2930 CurrentMode
= Private
->TextOutMode
.Mode
;
2931 MaxMode
= Private
->TextOutMode
.MaxMode
;
2932 ASSERT (MaxMode
>= 1);
2935 // Update DevNull mode according to current video device
2937 if (FeaturePcdGet (PcdConOutGopSupport
)) {
2938 if ((GraphicsOutput
!= NULL
) || (UgaDraw
!= NULL
)) {
2939 ConSplitterAddGraphicsOutputMode (Private
, GraphicsOutput
, UgaDraw
);
2942 if (FeaturePcdGet (PcdConOutUgaSupport
)) {
2943 if (UgaDraw
!= NULL
&& FeaturePcdGet (PcdUgaConsumeSupport
)) {
2944 Status
= UgaDraw
->GetMode (
2946 &UgaHorizontalResolution
,
2947 &UgaVerticalResolution
,
2951 if (!EFI_ERROR (Status
)) {
2952 Status
= ConSpliterUgaDrawSetMode (
2954 UgaHorizontalResolution
,
2955 UgaVerticalResolution
,
2961 // If GetMode/SetMode is failed, set to 800x600 mode
2963 if(EFI_ERROR (Status
)) {
2964 Status
= ConSpliterUgaDrawSetMode (
2975 if (Private
->ConsoleOutputMode
== EfiConsoleControlScreenGraphics
&& GraphicsOutput
!= NULL
) {
2977 // We just added a new GOP or UGA device in graphics mode
2979 if (FeaturePcdGet (PcdConOutGopSupport
)) {
2980 DevNullGopSync (Private
, TextAndGop
->GraphicsOutput
, TextAndGop
->UgaDraw
);
2981 } else if (FeaturePcdGet (PcdConOutUgaSupport
)) {
2982 DevNullUgaSync (Private
, TextAndGop
->GraphicsOutput
, TextAndGop
->UgaDraw
);
2984 } else if ((CurrentMode
>= 0) && ((GraphicsOutput
!= NULL
) || (UgaDraw
!= NULL
)) && (CurrentMode
< Private
->TextOutMode
.MaxMode
)) {
2986 // The new console supports the same mode of the current console so sync up
2988 DevNullSyncStdOut (Private
);
2991 // If ConOut, then set the mode to Mode #0 which us 80 x 25
2993 Private
->TextOut
.SetMode (&Private
->TextOut
, 0);
2997 // After adding new console device, all existing console devices should be
2998 // synced to the current shared mode.
3000 ConsplitterSetConsoleOutMode (Private
);
3007 Remove Text Out Device in Consplitter Text Out list.
3009 @param Private Text Out Splitter pointer.
3010 @param TextOut Simple Text Output Pointer protocol pointer.
3012 @retval EFI_SUCCESS Text Out Device removed successfully.
3013 @retval EFI_NOT_FOUND No Text Out Device found.
3017 ConSplitterTextOutDeleteDevice (
3018 IN TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
,
3019 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
3023 UINTN CurrentNumOfConsoles
;
3024 TEXT_OUT_AND_GOP_DATA
*TextOutList
;
3028 // Remove the specified text-out device data structure from the Text out List,
3029 // and rearrange the remaining data structures in the Text out List.
3031 CurrentNumOfConsoles
= Private
->CurrentNumberOfConsoles
;
3032 Index
= (INT32
) CurrentNumOfConsoles
- 1;
3033 TextOutList
= Private
->TextOutList
;
3034 while (Index
>= 0) {
3035 if (TextOutList
->TextOut
== TextOut
) {
3036 CopyMem (TextOutList
, TextOutList
+ 1, sizeof (TEXT_OUT_AND_GOP_DATA
) * Index
);
3037 CurrentNumOfConsoles
--;
3038 if (TextOutList
->UgaDraw
!= NULL
&& FeaturePcdGet (PcdUgaConsumeSupport
)) {
3039 Private
->CurrentNumberOfUgaDraw
--;
3041 if (TextOutList
->GraphicsOutput
!= NULL
) {
3042 Private
->CurrentNumberOfGraphicsOutput
--;
3051 // The specified TextOut is not managed by the ConSplitter driver
3054 return EFI_NOT_FOUND
;
3057 if (CurrentNumOfConsoles
== 0) {
3059 // If the number of consoles is zero clear the Dev NULL device
3061 Private
->CurrentNumberOfConsoles
= 0;
3062 Private
->TextOutMode
.MaxMode
= 1;
3063 Private
->TextOutQueryData
[0].Columns
= 80;
3064 Private
->TextOutQueryData
[0].Rows
= 25;
3065 DevNullTextOutSetMode (Private
, 0);
3070 // Max Mode is realy an intersection of the QueryMode command to all
3071 // devices. So we must copy the QueryMode of the first device to
3075 Private
->TextOutQueryData
,
3076 Private
->TextOutQueryDataCount
* sizeof (TEXT_OUT_SPLITTER_QUERY_DATA
)
3079 FreePool (Private
->TextOutModeMap
);
3080 Private
->TextOutModeMap
= NULL
;
3081 TextOutList
= Private
->TextOutList
;
3084 // Add the first TextOut to the QueryData array and ModeMap table
3086 Status
= ConSplitterAddOutputMode (Private
, TextOutList
->TextOut
);
3089 // Now add one by one
3092 Private
->CurrentNumberOfConsoles
= 1;
3094 while ((UINTN
) Index
< CurrentNumOfConsoles
) {
3095 ConSplitterSyncOutputMode (Private
, TextOutList
->TextOut
);
3097 Private
->CurrentNumberOfConsoles
++;
3101 ConSplitterGetIntersectionBetweenConOutAndStrErr ();
3106 // ConSplitter TextIn member functions
3110 Reset the input device and optionaly run diagnostics
3112 @param This Protocol instance pointer.
3113 @param ExtendedVerification Driver may perform diagnostics on reset.
3115 @retval EFI_SUCCESS The device was reset.
3116 @retval EFI_DEVICE_ERROR The device is not functioning properly and could
3122 ConSplitterTextInReset (
3123 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*This
,
3124 IN BOOLEAN ExtendedVerification
3128 EFI_STATUS ReturnStatus
;
3129 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3132 Private
= TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
3134 Private
->KeyEventSignalState
= FALSE
;
3137 // return the worst status met
3139 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
3140 Status
= Private
->TextInList
[Index
]->Reset (
3141 Private
->TextInList
[Index
],
3142 ExtendedVerification
3144 if (EFI_ERROR (Status
)) {
3145 ReturnStatus
= Status
;
3149 return ReturnStatus
;
3154 Reads the next keystroke from the input device. The WaitForKey Event can
3155 be used to test for existance of a keystroke via WaitForEvent () call.
3157 @param This Protocol instance pointer.
3158 @param Key Driver may perform diagnostics on reset.
3160 @retval EFI_SUCCESS The keystroke information was returned.
3161 @retval EFI_NOT_READY There was no keystroke data availiable.
3162 @retval EFI_DEVICE_ERROR The keydtroke information was not returned due
3168 ConSplitterTextInPrivateReadKeyStroke (
3169 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
3170 OUT EFI_INPUT_KEY
*Key
3175 EFI_INPUT_KEY CurrentKey
;
3177 Key
->UnicodeChar
= 0;
3178 Key
->ScanCode
= SCAN_NULL
;
3181 // if no physical console input device exists, return EFI_NOT_READY;
3182 // if any physical console input device has key input,
3183 // return the key and EFI_SUCCESS.
3185 for (Index
= 0; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
3186 Status
= Private
->TextInList
[Index
]->ReadKeyStroke (
3187 Private
->TextInList
[Index
],
3190 if (!EFI_ERROR (Status
)) {
3196 return EFI_NOT_READY
;
3201 Return TRUE if StdIn is locked. The ConIn device on the virtual handle is
3202 the only device locked.
3206 @retval TRUE StdIn locked
3207 @retval FALSE StdIn working normally
3211 ConSpliterConssoleControlStdInLocked (
3215 return mConIn
.PasswordEnabled
;
3220 This timer event will fire when StdIn is locked. It will check the key
3221 sequence on StdIn to see if it matches the password. Any error in the
3222 password will cause the check to reset. As long a mConIn.PasswordEnabled is
3223 TRUE the StdIn splitter will not report any input.
3225 @param Event The Event this notify function registered to.
3226 @param Context Pointer to the context data registerd to the
3234 ConSpliterConsoleControlLockStdInEvent (
3241 CHAR16 BackSpaceString
[2];
3242 CHAR16 SpaceString
[2];
3245 Status
= ConSplitterTextInPrivateReadKeyStroke (&mConIn
, &Key
);
3246 if (!EFI_ERROR (Status
)) {
3248 // if it's an ENTER, match password
3250 if ((Key
.UnicodeChar
== CHAR_CARRIAGE_RETURN
) && (Key
.ScanCode
== SCAN_NULL
)) {
3251 mConIn
.PwdAttempt
[mConIn
.PwdIndex
] = CHAR_NULL
;
3252 if (StrCmp (mConIn
.Password
, mConIn
.PwdAttempt
)) {
3254 // Password not match
3256 ConSplitterTextOutOutputString (&mConOut
.TextOut
, (CHAR16
*) L
"\n\rPassword not correct\n\r");
3257 mConIn
.PwdIndex
= 0;
3260 // Key matches password sequence
3262 gBS
->SetTimer (mConIn
.LockEvent
, TimerPeriodic
, 0);
3263 mConIn
.PasswordEnabled
= FALSE
;
3264 Status
= EFI_NOT_READY
;
3266 } else if ((Key
.UnicodeChar
== CHAR_BACKSPACE
) && (Key
.ScanCode
== SCAN_NULL
)) {
3270 if (mConIn
.PwdIndex
> 0) {
3271 BackSpaceString
[0] = CHAR_BACKSPACE
;
3272 BackSpaceString
[1] = 0;
3274 SpaceString
[0] = ' ';
3277 ConSplitterTextOutOutputString (&mConOut
.TextOut
, BackSpaceString
);
3278 ConSplitterTextOutOutputString (&mConOut
.TextOut
, SpaceString
);
3279 ConSplitterTextOutOutputString (&mConOut
.TextOut
, BackSpaceString
);
3283 } else if ((Key
.ScanCode
== SCAN_NULL
) && (Key
.UnicodeChar
>= 32)) {
3285 // If it's not an ENTER, neigher a function key, nor a CTRL-X or ALT-X, record the input
3287 if (mConIn
.PwdIndex
< (MAX_STD_IN_PASSWORD
- 1)) {
3288 if (mConIn
.PwdIndex
== 0) {
3289 ConSplitterTextOutOutputString (&mConOut
.TextOut
, (CHAR16
*) L
"\n\r");
3292 ConSplitterTextOutOutputString (&mConOut
.TextOut
, (CHAR16
*) L
"*");
3293 mConIn
.PwdAttempt
[mConIn
.PwdIndex
] = Key
.UnicodeChar
;
3298 } while (!EFI_ERROR (Status
));
3303 If Password is NULL unlock the password state variable and set the event
3304 timer. If the Password is too big return an error. If the Password is valid
3305 Copy the Password and enable state variable and then arm the periodic timer
3308 @retval EFI_SUCCESS Lock the StdIn device
3309 @retval EFI_INVALID_PARAMETER Password is NULL
3310 @retval EFI_OUT_OF_RESOURCES Buffer allocation to store the password fails
3315 ConSpliterConsoleControlLockStdIn (
3316 IN EFI_CONSOLE_CONTROL_PROTOCOL
*This
,
3320 if (Password
== NULL
) {
3321 return EFI_INVALID_PARAMETER
;
3324 if (StrLen (Password
) >= MAX_STD_IN_PASSWORD
) {
3326 // Currently have a max password size
3328 return EFI_OUT_OF_RESOURCES
;
3331 // Save the password, initialize state variables and arm event timer
3333 StrCpy (mConIn
.Password
, Password
);
3334 mConIn
.PasswordEnabled
= TRUE
;
3335 mConIn
.PwdIndex
= 0;
3336 gBS
->SetTimer (mConIn
.LockEvent
, TimerPeriodic
, (10000 * 25));
3343 Reads the next keystroke from the input device. The WaitForKey Event can
3344 be used to test for existance of a keystroke via WaitForEvent () call.
3345 If the ConIn is password locked make it look like no keystroke is availible
3347 @param This Protocol instance pointer.
3348 @param Key Driver may perform diagnostics on reset.
3350 @retval EFI_SUCCESS The keystroke information was returned.
3351 @retval EFI_NOT_READY There was no keystroke data availiable.
3352 @retval EFI_DEVICE_ERROR The keydtroke information was not returned due
3358 ConSplitterTextInReadKeyStroke (
3359 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*This
,
3360 OUT EFI_INPUT_KEY
*Key
3363 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3365 Private
= TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
3366 if (Private
->PasswordEnabled
) {
3368 // If StdIn Locked return not ready
3370 return EFI_NOT_READY
;
3373 Private
->KeyEventSignalState
= FALSE
;
3375 return ConSplitterTextInPrivateReadKeyStroke (Private
, Key
);
3380 This event agregates all the events of the ConIn devices in the spliter.
3381 If the ConIn is password locked then return.
3382 If any events of physical ConIn devices are signaled, signal the ConIn
3383 spliter event. This will cause the calling code to call
3384 ConSplitterTextInReadKeyStroke ().
3386 @param Event The Event assoicated with callback.
3387 @param Context Context registered when Event was created.
3394 ConSplitterTextInWaitForKey (
3400 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3403 Private
= (TEXT_IN_SPLITTER_PRIVATE_DATA
*) Context
;
3404 if (Private
->PasswordEnabled
) {
3406 // If StdIn Locked return not ready
3412 // if KeyEventSignalState is flagged before, and not cleared by Reset() or ReadKeyStroke()
3414 if (Private
->KeyEventSignalState
) {
3415 gBS
->SignalEvent (Event
);
3419 // if any physical console input device has key input, signal the event.
3421 for (Index
= 0; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
3422 Status
= gBS
->CheckEvent (Private
->TextInList
[Index
]->WaitForKey
);
3423 if (!EFI_ERROR (Status
)) {
3424 gBS
->SignalEvent (Event
);
3425 Private
->KeyEventSignalState
= TRUE
;
3434 @param RegsiteredData A pointer to a buffer that is filled in with the
3435 keystroke state data for the key that was
3437 @param InputData A pointer to a buffer that is filled in with the
3438 keystroke state data for the key that was
3441 @retval TRUE Key be pressed matches a registered key.
3442 @retval FLASE Match failed.
3447 IN EFI_KEY_DATA
*RegsiteredData
,
3448 IN EFI_KEY_DATA
*InputData
3451 ASSERT (RegsiteredData
!= NULL
&& InputData
!= NULL
);
3453 if ((RegsiteredData
->Key
.ScanCode
!= InputData
->Key
.ScanCode
) ||
3454 (RegsiteredData
->Key
.UnicodeChar
!= InputData
->Key
.UnicodeChar
)) {
3459 // Assume KeyShiftState/KeyToggleState = 0 in Registered key data means these state could be ignored.
3461 if (RegsiteredData
->KeyState
.KeyShiftState
!= 0 &&
3462 RegsiteredData
->KeyState
.KeyShiftState
!= InputData
->KeyState
.KeyShiftState
) {
3465 if (RegsiteredData
->KeyState
.KeyToggleState
!= 0 &&
3466 RegsiteredData
->KeyState
.KeyToggleState
!= InputData
->KeyState
.KeyToggleState
) {
3475 // Simple Text Input Ex protocol functions
3480 Reset the input device and optionaly run diagnostics
3482 @param This Protocol instance pointer.
3483 @param ExtendedVerification Driver may perform diagnostics on reset.
3485 @retval EFI_SUCCESS The device was reset.
3486 @retval EFI_DEVICE_ERROR The device is not functioning properly and could
3492 ConSplitterTextInResetEx (
3493 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*This
,
3494 IN BOOLEAN ExtendedVerification
3498 EFI_STATUS ReturnStatus
;
3499 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3502 Private
= TEXT_IN_EX_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
3504 Private
->KeyEventSignalState
= FALSE
;
3507 // return the worst status met
3509 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfExConsoles
; Index
++) {
3510 Status
= Private
->TextInExList
[Index
]->Reset (
3511 Private
->TextInExList
[Index
],
3512 ExtendedVerification
3514 if (EFI_ERROR (Status
)) {
3515 ReturnStatus
= Status
;
3519 return ReturnStatus
;
3525 Reads the next keystroke from the input device. The WaitForKey Event can
3526 be used to test for existance of a keystroke via WaitForEvent () call.
3528 @param This Protocol instance pointer.
3529 @param KeyData A pointer to a buffer that is filled in with the
3530 keystroke state data for the key that was
3533 @retval EFI_SUCCESS The keystroke information was returned.
3534 @retval EFI_NOT_READY There was no keystroke data availiable.
3535 @retval EFI_DEVICE_ERROR The keystroke information was not returned due
3537 @retval EFI_INVALID_PARAMETER KeyData is NULL.
3542 ConSplitterTextInReadKeyStrokeEx (
3543 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*This
,
3544 OUT EFI_KEY_DATA
*KeyData
3547 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3550 EFI_KEY_DATA CurrentKeyData
;
3553 if (KeyData
== NULL
) {
3554 return EFI_INVALID_PARAMETER
;
3557 Private
= TEXT_IN_EX_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
3558 if (Private
->PasswordEnabled
) {
3560 // If StdIn Locked return not ready
3562 return EFI_NOT_READY
;
3565 Private
->KeyEventSignalState
= FALSE
;
3567 KeyData
->Key
.UnicodeChar
= 0;
3568 KeyData
->Key
.ScanCode
= SCAN_NULL
;
3571 // if no physical console input device exists, return EFI_NOT_READY;
3572 // if any physical console input device has key input,
3573 // return the key and EFI_SUCCESS.
3575 for (Index
= 0; Index
< Private
->CurrentNumberOfExConsoles
; Index
++) {
3576 Status
= Private
->TextInExList
[Index
]->ReadKeyStrokeEx (
3577 Private
->TextInExList
[Index
],
3580 if (!EFI_ERROR (Status
)) {
3581 CopyMem (KeyData
, &CurrentKeyData
, sizeof (CurrentKeyData
));
3586 return EFI_NOT_READY
;
3591 Set certain state for the input device.
3593 @param This Protocol instance pointer.
3594 @param KeyToggleState A pointer to the EFI_KEY_TOGGLE_STATE to set the
3595 state for the input device.
3597 @retval EFI_SUCCESS The device state was set successfully.
3598 @retval EFI_DEVICE_ERROR The device is not functioning correctly and
3599 could not have the setting adjusted.
3600 @retval EFI_UNSUPPORTED The device does not have the ability to set its
3602 @retval EFI_INVALID_PARAMETER KeyToggleState is NULL.
3607 ConSplitterTextInSetState (
3608 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*This
,
3609 IN EFI_KEY_TOGGLE_STATE
*KeyToggleState
3612 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3616 if (KeyToggleState
== NULL
) {
3617 return EFI_INVALID_PARAMETER
;
3620 Private
= TEXT_IN_EX_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
3623 // if no physical console input device exists, return EFI_SUCCESS;
3624 // otherwise return the status of setting state of physical console input device
3626 for (Index
= 0; Index
< Private
->CurrentNumberOfExConsoles
; Index
++) {
3627 Status
= Private
->TextInExList
[Index
]->SetState (
3628 Private
->TextInExList
[Index
],
3631 if (EFI_ERROR (Status
)) {
3642 Register a notification function for a particular keystroke for the input device.
3644 @param This Protocol instance pointer.
3645 @param KeyData A pointer to a buffer that is filled in with the
3646 keystroke information data for the key that was
3648 @param KeyNotificationFunction Points to the function to be called when the key
3649 sequence is typed specified by KeyData.
3650 @param NotifyHandle Points to the unique handle assigned to the
3651 registered notification.
3653 @retval EFI_SUCCESS The notification function was registered
3655 @retval EFI_OUT_OF_RESOURCES Unable to allocate resources for necesssary data
3657 @retval EFI_INVALID_PARAMETER KeyData or NotifyHandle is NULL.
3662 ConSplitterTextInRegisterKeyNotify (
3663 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*This
,
3664 IN EFI_KEY_DATA
*KeyData
,
3665 IN EFI_KEY_NOTIFY_FUNCTION KeyNotificationFunction
,
3666 OUT EFI_HANDLE
*NotifyHandle
3669 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3672 TEXT_IN_EX_SPLITTER_NOTIFY
*NewNotify
;
3674 TEXT_IN_EX_SPLITTER_NOTIFY
*CurrentNotify
;
3677 if (KeyData
== NULL
|| NotifyHandle
== NULL
|| KeyNotificationFunction
== NULL
) {
3678 return EFI_INVALID_PARAMETER
;
3681 Private
= TEXT_IN_EX_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
3684 // if no physical console input device exists,
3685 // return EFI_SUCCESS directly.
3687 if (Private
->CurrentNumberOfExConsoles
<= 0) {
3692 // Return EFI_SUCCESS if the (KeyData, NotificationFunction) is already registered.
3694 for (Link
= Private
->NotifyList
.ForwardLink
; Link
!= &Private
->NotifyList
; Link
= Link
->ForwardLink
) {
3695 CurrentNotify
= CR (
3697 TEXT_IN_EX_SPLITTER_NOTIFY
,
3699 TEXT_IN_EX_SPLITTER_NOTIFY_SIGNATURE
3701 if (IsKeyRegistered (&CurrentNotify
->KeyData
, KeyData
)) {
3702 if (CurrentNotify
->KeyNotificationFn
== KeyNotificationFunction
) {
3703 *NotifyHandle
= CurrentNotify
->NotifyHandle
;
3710 // Allocate resource to save the notification function
3712 NewNotify
= (TEXT_IN_EX_SPLITTER_NOTIFY
*) AllocateZeroPool (sizeof (TEXT_IN_EX_SPLITTER_NOTIFY
));
3713 if (NewNotify
== NULL
) {
3714 return EFI_OUT_OF_RESOURCES
;
3716 NewNotify
->NotifyHandleList
= (EFI_HANDLE
*) AllocateZeroPool (sizeof (EFI_HANDLE
) * Private
->CurrentNumberOfExConsoles
);
3717 if (NewNotify
->NotifyHandleList
== NULL
) {
3718 gBS
->FreePool (NewNotify
);
3719 return EFI_OUT_OF_RESOURCES
;
3721 NewNotify
->Signature
= TEXT_IN_EX_SPLITTER_NOTIFY_SIGNATURE
;
3722 NewNotify
->KeyNotificationFn
= KeyNotificationFunction
;
3723 CopyMem (&NewNotify
->KeyData
, KeyData
, sizeof (KeyData
));
3726 // Return the wrong status of registering key notify of
3727 // physical console input device if meet problems
3729 for (Index
= 0; Index
< Private
->CurrentNumberOfExConsoles
; Index
++) {
3730 Status
= Private
->TextInExList
[Index
]->RegisterKeyNotify (
3731 Private
->TextInExList
[Index
],
3733 KeyNotificationFunction
,
3734 &NewNotify
->NotifyHandleList
[Index
]
3736 if (EFI_ERROR (Status
)) {
3737 gBS
->FreePool (NewNotify
->NotifyHandleList
);
3738 gBS
->FreePool (NewNotify
);
3744 // Use gSimpleTextInExNotifyGuid to get a valid EFI_HANDLE
3746 Status
= gBS
->InstallMultipleProtocolInterfaces (
3747 &NewNotify
->NotifyHandle
,
3748 &gSimpleTextInExNotifyGuid
,
3752 ASSERT_EFI_ERROR (Status
);
3754 InsertTailList (&mConIn
.NotifyList
, &NewNotify
->NotifyEntry
);
3756 *NotifyHandle
= NewNotify
->NotifyHandle
;
3764 Remove a registered notification function from a particular keystroke.
3766 @param This Protocol instance pointer.
3767 @param NotificationHandle The handle of the notification function being
3770 @retval EFI_SUCCESS The notification function was unregistered
3772 @retval EFI_INVALID_PARAMETER The NotificationHandle is invalid.
3773 @retval EFI_NOT_FOUND Can not find the matching entry in database.
3778 ConSplitterTextInUnregisterKeyNotify (
3779 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*This
,
3780 IN EFI_HANDLE NotificationHandle
3783 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3786 TEXT_IN_EX_SPLITTER_NOTIFY
*CurrentNotify
;
3789 if (NotificationHandle
== NULL
) {
3790 return EFI_INVALID_PARAMETER
;
3793 Status
= gBS
->OpenProtocol (
3795 &gSimpleTextInExNotifyGuid
,
3799 EFI_OPEN_PROTOCOL_TEST_PROTOCOL
3801 if (EFI_ERROR (Status
)) {
3802 return EFI_INVALID_PARAMETER
;
3805 Private
= TEXT_IN_EX_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
3808 // if no physical console input device exists,
3809 // return EFI_SUCCESS directly.
3811 if (Private
->CurrentNumberOfExConsoles
<= 0) {
3815 for (Link
= Private
->NotifyList
.ForwardLink
; Link
!= &Private
->NotifyList
; Link
= Link
->ForwardLink
) {
3816 CurrentNotify
= CR (Link
, TEXT_IN_EX_SPLITTER_NOTIFY
, NotifyEntry
, TEXT_IN_EX_SPLITTER_NOTIFY_SIGNATURE
);
3817 if (CurrentNotify
->NotifyHandle
== NotificationHandle
) {
3818 for (Index
= 0; Index
< Private
->CurrentNumberOfExConsoles
; Index
++) {
3819 Status
= Private
->TextInExList
[Index
]->UnregisterKeyNotify (
3820 Private
->TextInExList
[Index
],
3821 CurrentNotify
->NotifyHandleList
[Index
]
3823 if (EFI_ERROR (Status
)) {
3827 RemoveEntryList (&CurrentNotify
->NotifyEntry
);
3828 Status
= gBS
->UninstallMultipleProtocolInterfaces (
3829 CurrentNotify
->NotifyHandle
,
3830 &gSimpleTextInExNotifyGuid
,
3834 ASSERT_EFI_ERROR (Status
);
3835 gBS
->FreePool (CurrentNotify
->NotifyHandleList
);
3836 gBS
->FreePool (CurrentNotify
);
3841 return EFI_NOT_FOUND
;
3847 Reset the input device and optionaly run diagnostics
3849 @param This Protocol instance pointer.
3850 @param ExtendedVerification Driver may perform diagnostics on reset.
3852 @retval EFI_SUCCESS The device was reset.
3853 @retval EFI_DEVICE_ERROR The device is not functioning properly and could
3859 ConSplitterSimplePointerReset (
3860 IN EFI_SIMPLE_POINTER_PROTOCOL
*This
,
3861 IN BOOLEAN ExtendedVerification
3865 EFI_STATUS ReturnStatus
;
3866 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3869 Private
= TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_SIMPLE_POINTER_THIS (This
);
3871 Private
->InputEventSignalState
= FALSE
;
3873 if (Private
->CurrentNumberOfPointers
== 0) {
3877 // return the worst status met
3879 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfPointers
; Index
++) {
3880 Status
= Private
->PointerList
[Index
]->Reset (
3881 Private
->PointerList
[Index
],
3882 ExtendedVerification
3884 if (EFI_ERROR (Status
)) {
3885 ReturnStatus
= Status
;
3889 return ReturnStatus
;
3894 Reads the next keystroke from the input device. The WaitForKey Event can
3895 be used to test for existance of a keystroke via WaitForEvent () call.
3897 @param This Protocol instance pointer. State -
3899 @retval EFI_SUCCESS The keystroke information was returned.
3900 @retval EFI_NOT_READY There was no keystroke data availiable.
3901 @retval EFI_DEVICE_ERROR The keydtroke information was not returned due
3907 ConSplitterSimplePointerPrivateGetState (
3908 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
3909 IN OUT EFI_SIMPLE_POINTER_STATE
*State
3913 EFI_STATUS ReturnStatus
;
3915 EFI_SIMPLE_POINTER_STATE CurrentState
;
3917 State
->RelativeMovementX
= 0;
3918 State
->RelativeMovementY
= 0;
3919 State
->RelativeMovementZ
= 0;
3920 State
->LeftButton
= FALSE
;
3921 State
->RightButton
= FALSE
;
3924 // if no physical console input device exists, return EFI_NOT_READY;
3925 // if any physical console input device has key input,
3926 // return the key and EFI_SUCCESS.
3928 ReturnStatus
= EFI_NOT_READY
;
3929 for (Index
= 0; Index
< Private
->CurrentNumberOfPointers
; Index
++) {
3931 Status
= Private
->PointerList
[Index
]->GetState (
3932 Private
->PointerList
[Index
],
3935 if (!EFI_ERROR (Status
)) {
3936 if (ReturnStatus
== EFI_NOT_READY
) {
3937 ReturnStatus
= EFI_SUCCESS
;
3940 if (CurrentState
.LeftButton
) {
3941 State
->LeftButton
= TRUE
;
3944 if (CurrentState
.RightButton
) {
3945 State
->RightButton
= TRUE
;
3948 if (CurrentState
.RelativeMovementX
!= 0 && Private
->PointerList
[Index
]->Mode
->ResolutionX
!= 0) {
3949 State
->RelativeMovementX
+= (CurrentState
.RelativeMovementX
* (INT32
) Private
->SimplePointerMode
.ResolutionX
) / (INT32
) Private
->PointerList
[Index
]->Mode
->ResolutionX
;
3952 if (CurrentState
.RelativeMovementY
!= 0 && Private
->PointerList
[Index
]->Mode
->ResolutionY
!= 0) {
3953 State
->RelativeMovementY
+= (CurrentState
.RelativeMovementY
* (INT32
) Private
->SimplePointerMode
.ResolutionY
) / (INT32
) Private
->PointerList
[Index
]->Mode
->ResolutionY
;
3956 if (CurrentState
.RelativeMovementZ
!= 0 && Private
->PointerList
[Index
]->Mode
->ResolutionZ
!= 0) {
3957 State
->RelativeMovementZ
+= (CurrentState
.RelativeMovementZ
* (INT32
) Private
->SimplePointerMode
.ResolutionZ
) / (INT32
) Private
->PointerList
[Index
]->Mode
->ResolutionZ
;
3959 } else if (Status
== EFI_DEVICE_ERROR
) {
3960 ReturnStatus
= EFI_DEVICE_ERROR
;
3964 return ReturnStatus
;
3969 Reads the next keystroke from the input device. The WaitForKey Event can
3970 be used to test for existance of a keystroke via WaitForEvent () call.
3971 If the ConIn is password locked make it look like no keystroke is availible
3973 @param This A pointer to protocol instance.
3974 @param State A pointer to state information on the pointer device
3976 @retval EFI_SUCCESS The keystroke information was returned in State.
3977 @retval EFI_NOT_READY There was no keystroke data availiable.
3978 @retval EFI_DEVICE_ERROR The keydtroke information was not returned due
3984 ConSplitterSimplePointerGetState (
3985 IN EFI_SIMPLE_POINTER_PROTOCOL
*This
,
3986 IN OUT EFI_SIMPLE_POINTER_STATE
*State
3989 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3991 Private
= TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_SIMPLE_POINTER_THIS (This
);
3992 if (Private
->PasswordEnabled
) {
3994 // If StdIn Locked return not ready
3996 return EFI_NOT_READY
;
3999 Private
->InputEventSignalState
= FALSE
;
4001 return ConSplitterSimplePointerPrivateGetState (Private
, State
);
4006 This event agregates all the events of the ConIn devices in the spliter.
4007 If the ConIn is password locked then return.
4008 If any events of physical ConIn devices are signaled, signal the ConIn
4009 spliter event. This will cause the calling code to call
4010 ConSplitterTextInReadKeyStroke ().
4012 @param Event The Event assoicated with callback.
4013 @param Context Context registered when Event was created.
4020 ConSplitterSimplePointerWaitForInput (
4026 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
4029 Private
= (TEXT_IN_SPLITTER_PRIVATE_DATA
*) Context
;
4030 if (Private
->PasswordEnabled
) {
4032 // If StdIn Locked return not ready
4038 // if InputEventSignalState is flagged before, and not cleared by Reset() or ReadKeyStroke()
4040 if (Private
->InputEventSignalState
) {
4041 gBS
->SignalEvent (Event
);
4045 // if any physical console input device has key input, signal the event.
4047 for (Index
= 0; Index
< Private
->CurrentNumberOfPointers
; Index
++) {
4048 Status
= gBS
->CheckEvent (Private
->PointerList
[Index
]->WaitForInput
);
4049 if (!EFI_ERROR (Status
)) {
4050 gBS
->SignalEvent (Event
);
4051 Private
->InputEventSignalState
= TRUE
;
4057 // Absolute Pointer Protocol functions
4062 Resets the pointer device hardware.
4064 @param This Protocol instance pointer.
4065 @param ExtendedVerification Driver may perform diagnostics on reset.
4067 @retval EFI_SUCCESS The device was reset.
4068 @retval EFI_DEVICE_ERROR The device is not functioning correctly and
4074 ConSplitterAbsolutePointerReset (
4075 IN EFI_ABSOLUTE_POINTER_PROTOCOL
*This
,
4076 IN BOOLEAN ExtendedVerification
4080 EFI_STATUS ReturnStatus
;
4081 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
4084 Private
= TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_ABSOLUTE_POINTER_THIS (This
);
4086 Private
->AbsoluteInputEventSignalState
= FALSE
;
4088 if (Private
->CurrentNumberOfAbsolutePointers
== 0) {
4092 // return the worst status met
4094 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfAbsolutePointers
; Index
++) {
4095 Status
= Private
->AbsolutePointerList
[Index
]->Reset (
4096 Private
->AbsolutePointerList
[Index
],
4097 ExtendedVerification
4099 if (EFI_ERROR (Status
)) {
4100 ReturnStatus
= Status
;
4104 return ReturnStatus
;
4109 Retrieves the current state of a pointer device.
4111 @param This Protocol instance pointer.
4112 @param State A pointer to the state information on the
4115 @retval EFI_SUCCESS The state of the pointer device was returned in
4117 @retval EFI_NOT_READY The state of the pointer device has not changed
4118 since the last call to GetState().
4119 @retval EFI_DEVICE_ERROR A device error occurred while attempting to
4120 retrieve the pointer device's current state.
4125 ConSplitterAbsolutePointerGetState (
4126 IN EFI_ABSOLUTE_POINTER_PROTOCOL
*This
,
4127 IN OUT EFI_ABSOLUTE_POINTER_STATE
*State
4130 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
4132 EFI_STATUS ReturnStatus
;
4134 EFI_ABSOLUTE_POINTER_STATE CurrentState
;
4137 Private
= TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_ABSOLUTE_POINTER_THIS (This
);
4138 if (Private
->PasswordEnabled
) {
4140 // If StdIn Locked return not ready
4142 return EFI_NOT_READY
;
4145 Private
->AbsoluteInputEventSignalState
= FALSE
;
4147 State
->CurrentX
= 0;
4148 State
->CurrentY
= 0;
4149 State
->CurrentZ
= 0;
4150 State
->ActiveButtons
= 0;
4153 // if no physical pointer device exists, return EFI_NOT_READY;
4154 // if any physical pointer device has changed state,
4155 // return the state and EFI_SUCCESS.
4157 ReturnStatus
= EFI_NOT_READY
;
4158 for (Index
= 0; Index
< Private
->CurrentNumberOfAbsolutePointers
; Index
++) {
4160 Status
= Private
->AbsolutePointerList
[Index
]->GetState (
4161 Private
->AbsolutePointerList
[Index
],
4164 if (!EFI_ERROR (Status
)) {
4165 if (ReturnStatus
== EFI_NOT_READY
) {
4166 ReturnStatus
= EFI_SUCCESS
;
4169 State
->ActiveButtons
= CurrentState
.ActiveButtons
;
4171 if (!(Private
->AbsolutePointerMode
.AbsoluteMinX
== 0 && Private
->AbsolutePointerMode
.AbsoluteMaxX
== 0)) {
4172 State
->CurrentX
= CurrentState
.CurrentX
;
4174 if (!(Private
->AbsolutePointerMode
.AbsoluteMinY
== 0 && Private
->AbsolutePointerMode
.AbsoluteMaxY
== 0)) {
4175 State
->CurrentY
= CurrentState
.CurrentY
;
4177 if (!(Private
->AbsolutePointerMode
.AbsoluteMinZ
== 0 && Private
->AbsolutePointerMode
.AbsoluteMaxZ
== 0)) {
4178 State
->CurrentZ
= CurrentState
.CurrentZ
;
4181 } else if (Status
== EFI_DEVICE_ERROR
) {
4182 ReturnStatus
= EFI_DEVICE_ERROR
;
4186 return ReturnStatus
;
4191 This event agregates all the events of the pointer devices in the splitter.
4192 If the ConIn is password locked then return.
4193 If any events of physical pointer devices are signaled, signal the pointer
4194 splitter event. This will cause the calling code to call
4195 ConSplitterAbsolutePointerGetState ().
4197 @param Event The Event assoicated with callback.
4198 @param Context Context registered when Event was created.
4205 ConSplitterAbsolutePointerWaitForInput (
4211 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
4214 Private
= (TEXT_IN_SPLITTER_PRIVATE_DATA
*) Context
;
4215 if (Private
->PasswordEnabled
) {
4217 // If StdIn Locked return not ready
4223 // if AbsoluteInputEventSignalState is flagged before,
4224 // and not cleared by Reset() or GetState(), signal it
4226 if (Private
->AbsoluteInputEventSignalState
) {
4227 gBS
->SignalEvent (Event
);
4231 // if any physical console input device has key input, signal the event.
4233 for (Index
= 0; Index
< Private
->CurrentNumberOfAbsolutePointers
; Index
++) {
4234 Status
= gBS
->CheckEvent (Private
->AbsolutePointerList
[Index
]->WaitForInput
);
4235 if (!EFI_ERROR (Status
)) {
4236 gBS
->SignalEvent (Event
);
4237 Private
->AbsoluteInputEventSignalState
= TRUE
;
4244 Reset the text output device hardware and optionaly run diagnostics
4246 @param This Protocol instance pointer.
4247 @param ExtendedVerification Driver may perform more exhaustive verfication
4248 operation of the device during reset.
4250 @retval EFI_SUCCESS The text output device was reset.
4251 @retval EFI_DEVICE_ERROR The text output device is not functioning
4252 correctly and could not be reset.
4257 ConSplitterTextOutReset (
4258 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4259 IN BOOLEAN ExtendedVerification
4263 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4265 EFI_STATUS ReturnStatus
;
4267 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4270 // return the worst status met
4272 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
4274 if (Private
->TextOutList
[Index
].TextOutEnabled
) {
4276 Status
= Private
->TextOutList
[Index
].TextOut
->Reset (
4277 Private
->TextOutList
[Index
].TextOut
,
4278 ExtendedVerification
4280 if (EFI_ERROR (Status
)) {
4281 ReturnStatus
= Status
;
4286 This
->SetAttribute (This
, EFI_TEXT_ATTR (This
->Mode
->Attribute
& 0x0F, EFI_BLACK
));
4288 Status
= DevNullTextOutSetMode (Private
, 0);
4289 if (EFI_ERROR (Status
)) {
4290 ReturnStatus
= Status
;
4293 return ReturnStatus
;
4298 Write a Unicode string to the output device.
4300 @param This Protocol instance pointer.
4301 @param String The NULL-terminated Unicode string to be
4302 displayed on the output device(s). All output
4303 devices must also support the Unicode drawing
4304 defined in this file.
4306 @retval EFI_SUCCESS The string was output to the device.
4307 @retval EFI_DEVICE_ERROR The device reported an error while attempting to
4309 @retval EFI_UNSUPPORTED The output device's mode is not currently in a
4311 @retval EFI_WARN_UNKNOWN_GLYPH This warning code indicates that some of the
4312 characters in the Unicode string could not be
4313 rendered and were skipped.
4318 ConSplitterTextOutOutputString (
4319 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4324 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4326 UINTN BackSpaceCount
;
4327 EFI_STATUS ReturnStatus
;
4328 CHAR16
*TargetString
;
4330 This
->SetAttribute (This
, This
->Mode
->Attribute
);
4332 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4335 for (TargetString
= WString
; *TargetString
!= L
'\0'; TargetString
++) {
4336 if (*TargetString
== CHAR_BACKSPACE
) {
4342 if (BackSpaceCount
== 0) {
4343 TargetString
= WString
;
4345 TargetString
= AllocatePool (sizeof (CHAR16
) * (StrLen (WString
) + BackSpaceCount
+ 1));
4346 StrCpy (TargetString
, WString
);
4349 // return the worst status met
4351 Status
= DevNullTextOutOutputString (Private
, TargetString
);
4352 if (EFI_ERROR (Status
)) {
4353 ReturnStatus
= Status
;
4356 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
4358 if (Private
->TextOutList
[Index
].TextOutEnabled
) {
4359 Status
= Private
->TextOutList
[Index
].TextOut
->OutputString (
4360 Private
->TextOutList
[Index
].TextOut
,
4363 if (EFI_ERROR (Status
)) {
4364 ReturnStatus
= Status
;
4369 if (BackSpaceCount
> 0) {
4370 FreePool (TargetString
);
4373 return ReturnStatus
;
4378 Verifies that all characters in a Unicode string can be output to the
4381 @param This Protocol instance pointer.
4382 @param String The NULL-terminated Unicode string to be
4383 examined for the output device(s).
4385 @retval EFI_SUCCESS The device(s) are capable of rendering the
4387 @retval EFI_UNSUPPORTED Some of the characters in the Unicode string
4388 cannot be rendered by one or more of the output
4389 devices mapped by the EFI handle.
4394 ConSplitterTextOutTestString (
4395 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4400 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4402 EFI_STATUS ReturnStatus
;
4404 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4407 // return the worst status met
4409 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
4410 if (Private
->TextOutList
[Index
].TextOutEnabled
) {
4411 Status
= Private
->TextOutList
[Index
].TextOut
->TestString (
4412 Private
->TextOutList
[Index
].TextOut
,
4415 if (EFI_ERROR (Status
)) {
4416 ReturnStatus
= Status
;
4421 // There is no DevNullTextOutTestString () since a Unicode buffer would
4422 // always return EFI_SUCCESS.
4423 // ReturnStatus will be EFI_SUCCESS if no consoles are present
4425 return ReturnStatus
;
4430 Returns information for an available text mode that the output device(s)
4433 @param This Protocol instance pointer.
4434 @param ModeNumber The mode number to return information on.
4435 @param Rows Returns the geometry of the text output device
4436 for the requested ModeNumber.
4438 @retval EFI_SUCCESS The requested mode information was returned.
4439 @retval EFI_DEVICE_ERROR The device had an error and could not complete
4441 @retval EFI_UNSUPPORTED The mode number was not valid.
4446 ConSplitterTextOutQueryMode (
4447 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4448 IN UINTN ModeNumber
,
4453 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4455 INT32
*TextOutModeMap
;
4457 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4460 // Check whether param ModeNumber is valid.
4461 // ModeNumber should be within range 0 ~ MaxMode - 1.
4463 if ( (ModeNumber
> (UINTN
)(((UINT32
)-1)>>1)) ) {
4464 return EFI_UNSUPPORTED
;
4467 if ((INT32
) ModeNumber
>= This
->Mode
->MaxMode
) {
4468 return EFI_UNSUPPORTED
;
4472 // We get the available mode from mode intersection map if it's available
4474 if (Private
->TextOutModeMap
!= NULL
) {
4475 TextOutModeMap
= Private
->TextOutModeMap
+ Private
->TextOutListCount
* ModeNumber
;
4476 CurrentMode
= (UINTN
)(*TextOutModeMap
);
4477 *Columns
= Private
->TextOutQueryData
[CurrentMode
].Columns
;
4478 *Rows
= Private
->TextOutQueryData
[CurrentMode
].Rows
;
4480 *Columns
= Private
->TextOutQueryData
[ModeNumber
].Columns
;
4481 *Rows
= Private
->TextOutQueryData
[ModeNumber
].Rows
;
4484 if (*Columns
<= 0 && *Rows
<= 0) {
4485 return EFI_UNSUPPORTED
;
4494 Sets the output device(s) to a specified mode.
4496 @param This Protocol instance pointer.
4497 @param ModeNumber The mode number to set.
4499 @retval EFI_SUCCESS The requested text mode was set.
4500 @retval EFI_DEVICE_ERROR The device had an error and could not complete
4502 @retval EFI_UNSUPPORTED The mode number was not valid.
4507 ConSplitterTextOutSetMode (
4508 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4513 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4515 INT32
*TextOutModeMap
;
4516 EFI_STATUS ReturnStatus
;
4518 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4521 // Check whether param ModeNumber is valid.
4522 // ModeNumber should be within range 0 ~ MaxMode - 1.
4524 if ( (ModeNumber
> (UINTN
)(((UINT32
)-1)>>1)) ) {
4525 return EFI_UNSUPPORTED
;
4528 if ((INT32
) ModeNumber
>= This
->Mode
->MaxMode
) {
4529 return EFI_UNSUPPORTED
;
4532 // If the mode is being set to the curent mode, then just clear the screen and return.
4534 if (Private
->TextOutMode
.Mode
== (INT32
) ModeNumber
) {
4535 return ConSplitterTextOutClearScreen (This
);
4538 // return the worst status met
4540 TextOutModeMap
= Private
->TextOutModeMap
+ Private
->TextOutListCount
* ModeNumber
;
4541 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
4543 if (Private
->TextOutList
[Index
].TextOutEnabled
) {
4544 Status
= Private
->TextOutList
[Index
].TextOut
->SetMode (
4545 Private
->TextOutList
[Index
].TextOut
,
4546 TextOutModeMap
[Index
]
4549 // If this console device is based on a GOP or UGA device, then sync up the bitmap from
4550 // the GOP/UGA splitter and reclear the text portion of the display in the new mode.
4552 if ((Private
->TextOutList
[Index
].GraphicsOutput
!= NULL
) || (Private
->TextOutList
[Index
].UgaDraw
!= NULL
)) {
4553 Private
->TextOutList
[Index
].TextOut
->ClearScreen (Private
->TextOutList
[Index
].TextOut
);
4556 if (EFI_ERROR (Status
)) {
4557 ReturnStatus
= Status
;
4562 // The DevNull Console will support any possible mode as it allocates memory
4564 Status
= DevNullTextOutSetMode (Private
, ModeNumber
);
4565 if (EFI_ERROR (Status
)) {
4566 ReturnStatus
= Status
;
4569 return ReturnStatus
;
4574 Sets the background and foreground colors for the OutputString () and
4575 ClearScreen () functions.
4577 @param This Protocol instance pointer.
4578 @param Attribute The attribute to set. Bits 0..3 are the
4579 foreground color, and bits 4..6 are the
4580 background color. All other bits are undefined
4581 and must be zero. The valid Attributes are
4582 defined in this file.
4584 @retval EFI_SUCCESS The attribute was set.
4585 @retval EFI_DEVICE_ERROR The device had an error and could not complete
4587 @retval EFI_UNSUPPORTED The attribute requested is not defined.
4592 ConSplitterTextOutSetAttribute (
4593 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4598 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4600 EFI_STATUS ReturnStatus
;
4602 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4605 // Check whether param Attribute is valid.
4607 if ( (Attribute
> (UINTN
)(((UINT32
)-1)>>1)) ) {
4608 return EFI_UNSUPPORTED
;
4612 // return the worst status met
4614 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
4616 if (Private
->TextOutList
[Index
].TextOutEnabled
) {
4617 Status
= Private
->TextOutList
[Index
].TextOut
->SetAttribute (
4618 Private
->TextOutList
[Index
].TextOut
,
4621 if (EFI_ERROR (Status
)) {
4622 ReturnStatus
= Status
;
4627 Private
->TextOutMode
.Attribute
= (INT32
) Attribute
;
4629 return ReturnStatus
;
4634 Clears the output device(s) display to the currently selected background
4637 @param This Protocol instance pointer.
4639 @retval EFI_SUCCESS The operation completed successfully.
4640 @retval EFI_DEVICE_ERROR The device had an error and could not complete
4642 @retval EFI_UNSUPPORTED The output device is not in a valid text mode.
4647 ConSplitterTextOutClearScreen (
4648 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
4652 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4654 EFI_STATUS ReturnStatus
;
4656 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4659 // return the worst status met
4661 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
4663 if (Private
->TextOutList
[Index
].TextOutEnabled
) {
4664 Status
= Private
->TextOutList
[Index
].TextOut
->ClearScreen (Private
->TextOutList
[Index
].TextOut
);
4665 if (EFI_ERROR (Status
)) {
4666 ReturnStatus
= Status
;
4671 Status
= DevNullTextOutClearScreen (Private
);
4672 if (EFI_ERROR (Status
)) {
4673 ReturnStatus
= Status
;
4676 return ReturnStatus
;
4681 Sets the current coordinates of the cursor position
4683 @param This Protocol instance pointer.
4684 @param Row the position to set the cursor to. Must be
4685 greater than or equal to zero and less than the
4686 number of columns and rows by QueryMode ().
4688 @retval EFI_SUCCESS The operation completed successfully.
4689 @retval EFI_DEVICE_ERROR The device had an error and could not complete
4691 @retval EFI_UNSUPPORTED The output device is not in a valid text mode,
4692 or the cursor position is invalid for the
4698 ConSplitterTextOutSetCursorPosition (
4699 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4705 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4707 EFI_STATUS ReturnStatus
;
4710 INT32
*TextOutModeMap
;
4714 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4715 TextOutModeMap
= NULL
;
4716 ModeNumber
= Private
->TextOutMode
.Mode
;
4719 // Get current MaxColumn and MaxRow from intersection map
4721 if (Private
->TextOutModeMap
!= NULL
) {
4722 TextOutModeMap
= Private
->TextOutModeMap
+ Private
->TextOutListCount
* ModeNumber
;
4723 CurrentMode
= *TextOutModeMap
;
4725 CurrentMode
= ModeNumber
;
4728 MaxColumn
= Private
->TextOutQueryData
[CurrentMode
].Columns
;
4729 MaxRow
= Private
->TextOutQueryData
[CurrentMode
].Rows
;
4731 if (Column
>= MaxColumn
|| Row
>= MaxRow
) {
4732 return EFI_UNSUPPORTED
;
4735 // return the worst status met
4737 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
4739 if (Private
->TextOutList
[Index
].TextOutEnabled
) {
4740 Status
= Private
->TextOutList
[Index
].TextOut
->SetCursorPosition (
4741 Private
->TextOutList
[Index
].TextOut
,
4745 if (EFI_ERROR (Status
)) {
4746 ReturnStatus
= Status
;
4751 DevNullTextOutSetCursorPosition (Private
, Column
, Row
);
4753 return ReturnStatus
;
4758 Makes the cursor visible or invisible
4760 @param This Protocol instance pointer.
4761 @param Visible If TRUE, the cursor is set to be visible. If
4762 FALSE, the cursor is set to be invisible.
4764 @retval EFI_SUCCESS The operation completed successfully.
4765 @retval EFI_DEVICE_ERROR The device had an error and could not complete
4766 the request, or the device does not support
4767 changing the cursor mode.
4768 @retval EFI_UNSUPPORTED The output device is not in a valid text mode.
4773 ConSplitterTextOutEnableCursor (
4774 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4779 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4781 EFI_STATUS ReturnStatus
;
4783 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4786 // return the worst status met
4788 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
4790 if (Private
->TextOutList
[Index
].TextOutEnabled
) {
4791 Status
= Private
->TextOutList
[Index
].TextOut
->EnableCursor (
4792 Private
->TextOutList
[Index
].TextOut
,
4795 if (EFI_ERROR (Status
)) {
4796 ReturnStatus
= Status
;
4801 DevNullTextOutEnableCursor (Private
, Visible
);
4803 return ReturnStatus
;