2 Console Splitter Driver. Any Handle that attatched console I/O protocols
3 (Console In device, Console Out device, Console Error device, Simple Pointer
4 protocol, Absolute Pointer protocol) can be bound by this driver.
6 So far it works like any other driver by opening a SimpleTextIn and/or
7 SimpleTextOut protocol with EFI_OPEN_PROTOCOL_BY_DRIVER attributes. The big
8 difference is this driver does not layer a protocol on the passed in
9 handle, or construct a child handle like a standard device or bus driver.
10 This driver produces three virtual handles as children, one for console input
11 splitter, one for console output splitter and one for error output splitter.
12 These 3 virtual handles would be installed on gST.
14 Each virtual handle, that supports the Console I/O protocol, will be produced
15 in the driver entry point. The virtual handle are added on driver entry and
16 never removed. Such design ensures sytem function well during none console
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"
33 // Text In Splitter Private Data template
35 GLOBAL_REMOVE_IF_UNREFERENCED 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
122 // Uga Draw Protocol Private Data template
124 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UGA_DRAW_PROTOCOL mUgaDrawProtocolTemplate
= {
125 ConSpliterUgaDrawGetMode
,
126 ConSpliterUgaDrawSetMode
,
131 // Graphics Output Protocol Private Data template
133 GLOBAL_REMOVE_IF_UNREFERENCED EFI_GRAPHICS_OUTPUT_PROTOCOL mGraphicsOutputProtocolTemplate
= {
134 ConSpliterGraphicsOutputQueryMode
,
135 ConSpliterGraphicsOutputSetMode
,
136 ConSpliterGraphicsOutputBlt
,
142 // Text Out Splitter Private Data template
144 GLOBAL_REMOVE_IF_UNREFERENCED TEXT_OUT_SPLITTER_PRIVATE_DATA mConOut
= {
145 TEXT_OUT_SPLITTER_PRIVATE_DATA_SIGNATURE
,
148 ConSplitterTextOutReset
,
149 ConSplitterTextOutOutputString
,
150 ConSplitterTextOutTestString
,
151 ConSplitterTextOutQueryMode
,
152 ConSplitterTextOutSetMode
,
153 ConSplitterTextOutSetAttribute
,
154 ConSplitterTextOutClearScreen
,
155 ConSplitterTextOutSetCursorPosition
,
156 ConSplitterTextOutEnableCursor
,
157 (EFI_SIMPLE_TEXT_OUTPUT_MODE
*) NULL
176 (EFI_UGA_PIXEL
*) NULL
,
183 (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*) NULL
,
184 (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*) NULL
,
189 ConSpliterConsoleControlGetMode
,
190 ConSpliterConsoleControlSetMode
,
191 ConSpliterConsoleControlLockStdIn
195 (TEXT_OUT_AND_GOP_DATA
*) NULL
,
197 (TEXT_OUT_SPLITTER_QUERY_DATA
*) NULL
,
201 EfiConsoleControlScreenText
,
209 // Standard Error Text Out Splitter Data Template
211 GLOBAL_REMOVE_IF_UNREFERENCED TEXT_OUT_SPLITTER_PRIVATE_DATA mStdErr
= {
212 TEXT_OUT_SPLITTER_PRIVATE_DATA_SIGNATURE
,
215 ConSplitterTextOutReset
,
216 ConSplitterTextOutOutputString
,
217 ConSplitterTextOutTestString
,
218 ConSplitterTextOutQueryMode
,
219 ConSplitterTextOutSetMode
,
220 ConSplitterTextOutSetAttribute
,
221 ConSplitterTextOutClearScreen
,
222 ConSplitterTextOutSetCursorPosition
,
223 ConSplitterTextOutEnableCursor
,
224 (EFI_SIMPLE_TEXT_OUTPUT_MODE
*) NULL
243 (EFI_UGA_PIXEL
*) NULL
,
250 (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*) NULL
,
251 (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*) NULL
,
256 ConSpliterConsoleControlGetMode
,
257 ConSpliterConsoleControlSetMode
,
258 ConSpliterConsoleControlLockStdIn
262 (TEXT_OUT_AND_GOP_DATA
*) NULL
,
264 (TEXT_OUT_SPLITTER_QUERY_DATA
*) NULL
,
268 EfiConsoleControlScreenText
,
276 // Driver binding instance for Console Input Device
278 EFI_DRIVER_BINDING_PROTOCOL gConSplitterConInDriverBinding
= {
279 ConSplitterConInDriverBindingSupported
,
280 ConSplitterConInDriverBindingStart
,
281 ConSplitterConInDriverBindingStop
,
288 // Driver binding instance for Console Out device
290 EFI_DRIVER_BINDING_PROTOCOL gConSplitterConOutDriverBinding
= {
291 ConSplitterConOutDriverBindingSupported
,
292 ConSplitterConOutDriverBindingStart
,
293 ConSplitterConOutDriverBindingStop
,
300 // Driver binding instance for Standard Error device
302 EFI_DRIVER_BINDING_PROTOCOL gConSplitterStdErrDriverBinding
= {
303 ConSplitterStdErrDriverBindingSupported
,
304 ConSplitterStdErrDriverBindingStart
,
305 ConSplitterStdErrDriverBindingStop
,
312 // Driver binding instance for Simple Pointer protocol
314 EFI_DRIVER_BINDING_PROTOCOL gConSplitterSimplePointerDriverBinding
= {
315 ConSplitterSimplePointerDriverBindingSupported
,
316 ConSplitterSimplePointerDriverBindingStart
,
317 ConSplitterSimplePointerDriverBindingStop
,
324 // Driver binding instance for Absolute Pointer protocol
326 EFI_DRIVER_BINDING_PROTOCOL gConSplitterAbsolutePointerDriverBinding
= {
327 ConSplitterAbsolutePointerDriverBindingSupported
,
328 ConSplitterAbsolutePointerDriverBindingStart
,
329 ConSplitterAbsolutePointerDriverBindingStop
,
336 The Entry Point for module ConSplitter. The user code starts with this function.
338 Installs driver module protocols and. Creates virtual device handles for ConIn,
339 ConOut, and StdErr. Installs Simple Text In protocol, Simple Text In Ex protocol,
340 Simple Pointer protocol, Absolute Pointer protocol on those virtual handlers.
341 Installs Graphics Output protocol and/or UGA Draw protocol if needed.
343 @param[in] ImageHandle The firmware allocated handle for the EFI image.
344 @param[in] SystemTable A pointer to the EFI System Table.
346 @retval EFI_SUCCESS The entry point is executed successfully.
347 @retval other Some error occurs when executing this entry point.
352 ConSplitterDriverEntry(
353 IN EFI_HANDLE ImageHandle
,
354 IN EFI_SYSTEM_TABLE
*SystemTable
360 // Install driver model protocol(s).
362 Status
= EfiLibInstallDriverBindingComponentName2 (
365 &gConSplitterConInDriverBinding
,
367 &gConSplitterConInComponentName
,
368 &gConSplitterConInComponentName2
370 ASSERT_EFI_ERROR (Status
);
372 Status
= EfiLibInstallDriverBindingComponentName2 (
375 &gConSplitterSimplePointerDriverBinding
,
377 &gConSplitterSimplePointerComponentName
,
378 &gConSplitterSimplePointerComponentName2
380 ASSERT_EFI_ERROR (Status
);
382 Status
= EfiLibInstallDriverBindingComponentName2 (
385 &gConSplitterAbsolutePointerDriverBinding
,
387 &gConSplitterAbsolutePointerComponentName
,
388 &gConSplitterAbsolutePointerComponentName2
390 ASSERT_EFI_ERROR (Status
);
392 Status
= EfiLibInstallDriverBindingComponentName2 (
395 &gConSplitterConOutDriverBinding
,
397 &gConSplitterConOutComponentName
,
398 &gConSplitterConOutComponentName2
400 ASSERT_EFI_ERROR (Status
);
402 Status
= EfiLibInstallDriverBindingComponentName2 (
405 &gConSplitterStdErrDriverBinding
,
407 &gConSplitterStdErrComponentName
,
408 &gConSplitterStdErrComponentName2
410 ASSERT_EFI_ERROR (Status
);
413 // One of Either Graphics Output protocol and UGA Draw protocol must be supported.
415 ASSERT (FeaturePcdGet (PcdConOutGopSupport
) ||
416 FeaturePcdGet (PcdConOutUgaSupport
));
419 // The driver creates virtual handles for ConIn, ConOut, and StdErr.
420 // The virtual handles will always exist even if no console exist in the
421 // system. This is need to support hotplug devices like USB.
424 // Create virtual device handle for StdErr Splitter
426 Status
= ConSplitterTextOutConstructor (&mStdErr
);
427 if (!EFI_ERROR (Status
)) {
428 Status
= gBS
->InstallMultipleProtocolInterfaces (
429 &mStdErr
.VirtualHandle
,
430 &gEfiSimpleTextOutProtocolGuid
,
432 &gEfiPrimaryStandardErrorDeviceGuid
,
438 // Create virtual device handle for ConIn Splitter
440 Status
= ConSplitterTextInConstructor (&mConIn
);
441 if (!EFI_ERROR (Status
)) {
442 Status
= gBS
->InstallMultipleProtocolInterfaces (
443 &mConIn
.VirtualHandle
,
444 &gEfiSimpleTextInProtocolGuid
,
446 &gEfiSimpleTextInputExProtocolGuid
,
448 &gEfiSimplePointerProtocolGuid
,
449 &mConIn
.SimplePointer
,
450 &gEfiAbsolutePointerProtocolGuid
,
451 &mConIn
.AbsolutePointer
,
452 &gEfiPrimaryConsoleInDeviceGuid
,
456 if (!EFI_ERROR (Status
)) {
458 // Update the EFI System Table with new virtual console
459 // and update the pointer to Simple Text Input protocol.
461 gST
->ConsoleInHandle
= mConIn
.VirtualHandle
;
462 gST
->ConIn
= &mConIn
.TextIn
;
466 // Create virtual device handle for ConOut Splitter
468 Status
= ConSplitterTextOutConstructor (&mConOut
);
469 if (!EFI_ERROR (Status
)) {
470 if (!FeaturePcdGet (PcdConOutGopSupport
)) {
472 // If Graphics Outpurt protocol not supported, UGA Draw protocol is installed
473 // on the virtual handle.
475 Status
= gBS
->InstallMultipleProtocolInterfaces (
476 &mConOut
.VirtualHandle
,
477 &gEfiSimpleTextOutProtocolGuid
,
479 &gEfiUgaDrawProtocolGuid
,
481 &gEfiConsoleControlProtocolGuid
,
482 &mConOut
.ConsoleControl
,
483 &gEfiPrimaryConsoleOutDeviceGuid
,
487 } else if (!FeaturePcdGet (PcdConOutUgaSupport
)) {
489 // If UGA Draw protocol not supported, Graphics Output Protocol is installed
490 // on virtual handle.
492 Status
= gBS
->InstallMultipleProtocolInterfaces (
493 &mConOut
.VirtualHandle
,
494 &gEfiSimpleTextOutProtocolGuid
,
496 &gEfiGraphicsOutputProtocolGuid
,
497 &mConOut
.GraphicsOutput
,
498 &gEfiConsoleControlProtocolGuid
,
499 &mConOut
.ConsoleControl
,
500 &gEfiPrimaryConsoleOutDeviceGuid
,
506 // Boot Graphics Output protocol and UGA Draw protocol are supported,
507 // both they will be installed on virtual handle.
509 Status
= gBS
->InstallMultipleProtocolInterfaces (
510 &mConOut
.VirtualHandle
,
511 &gEfiSimpleTextOutProtocolGuid
,
513 &gEfiGraphicsOutputProtocolGuid
,
514 &mConOut
.GraphicsOutput
,
515 &gEfiUgaDrawProtocolGuid
,
517 &gEfiConsoleControlProtocolGuid
,
518 &mConOut
.ConsoleControl
,
519 &gEfiPrimaryConsoleOutDeviceGuid
,
525 if (!EFI_ERROR (Status
)) {
527 // Update the EFI System Table with new virtual console
528 // and Update the pointer to Text Output protocol.
530 gST
->ConsoleOutHandle
= mConOut
.VirtualHandle
;
531 gST
->ConOut
= &mConOut
.TextOut
;
536 // Update the CRC32 in the EFI System Table header
539 gBS
->CalculateCrc32 (
550 Construct console input devices' private data.
552 @param ConInPrivate A pointer to the TEXT_IN_SPLITTER_PRIVATE_DATA
555 @retval EFI_OUT_OF_RESOURCES Out of resources.
556 @retval EFI_SUCCESS Text Input Devcie's private data has been constructed.
557 @retval other Failed to construct private data.
561 ConSplitterTextInConstructor (
562 TEXT_IN_SPLITTER_PRIVATE_DATA
*ConInPrivate
568 // Allocate buffer for Simple Text Input device
570 Status
= ConSplitterGrowBuffer (
571 sizeof (EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*),
572 &ConInPrivate
->TextInListCount
,
573 (VOID
**) &ConInPrivate
->TextInList
575 if (EFI_ERROR (Status
)) {
576 return EFI_OUT_OF_RESOURCES
;
579 // Create Event to support locking StdIn Device
581 Status
= gBS
->CreateEvent (
582 EVT_TIMER
| EVT_NOTIFY_SIGNAL
,
584 ConSpliterConsoleControlLockStdInEvent
,
586 &ConInPrivate
->LockEvent
588 ASSERT_EFI_ERROR (Status
);
590 // Create Event to wait for a key
592 Status
= gBS
->CreateEvent (
595 ConSplitterTextInWaitForKey
,
597 &ConInPrivate
->TextIn
.WaitForKey
599 ASSERT_EFI_ERROR (Status
);
602 // Allocate buffer for Simple Text Input Ex device
604 Status
= ConSplitterGrowBuffer (
605 sizeof (EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*),
606 &ConInPrivate
->TextInExListCount
,
607 (VOID
**) &ConInPrivate
->TextInExList
609 if (EFI_ERROR (Status
)) {
610 return EFI_OUT_OF_RESOURCES
;
613 // Create Event to wait for a key Ex
615 Status
= gBS
->CreateEvent (
618 ConSplitterTextInWaitForKey
,
620 &ConInPrivate
->TextInEx
.WaitForKeyEx
622 ASSERT_EFI_ERROR (Status
);
624 InitializeListHead (&ConInPrivate
->NotifyList
);
626 ConInPrivate
->AbsolutePointer
.Mode
= &ConInPrivate
->AbsolutePointerMode
;
628 // Allocate buffer for Absolute Pointer device
630 Status
= ConSplitterGrowBuffer (
631 sizeof (EFI_ABSOLUTE_POINTER_PROTOCOL
*),
632 &ConInPrivate
->AbsolutePointerListCount
,
633 (VOID
**) &ConInPrivate
->AbsolutePointerList
635 if (EFI_ERROR (Status
)) {
636 return EFI_OUT_OF_RESOURCES
;
639 // Create Event to wait for device input for Absolute pointer device
641 Status
= gBS
->CreateEvent (
644 ConSplitterAbsolutePointerWaitForInput
,
646 &ConInPrivate
->AbsolutePointer
.WaitForInput
648 ASSERT_EFI_ERROR (Status
);
650 ConInPrivate
->SimplePointer
.Mode
= &ConInPrivate
->SimplePointerMode
;
652 // Allocate buffer for Simple Pointer device
654 Status
= ConSplitterGrowBuffer (
655 sizeof (EFI_SIMPLE_POINTER_PROTOCOL
*),
656 &ConInPrivate
->PointerListCount
,
657 (VOID
**) &ConInPrivate
->PointerList
659 if (EFI_ERROR (Status
)) {
660 return EFI_OUT_OF_RESOURCES
;
663 // Create Event to wait for device input for Simple pointer device
665 Status
= gBS
->CreateEvent (
668 ConSplitterSimplePointerWaitForInput
,
670 &ConInPrivate
->SimplePointer
.WaitForInput
677 Construct console output devices' private data.
679 @param ConOutPrivate A pointer to the TEXT_OUT_SPLITTER_PRIVATE_DATA
682 @retval EFI_OUT_OF_RESOURCES Out of resources.
683 @retval EFI_SUCCESS Text Input Devcie's private data has been constructed.
687 ConSplitterTextOutConstructor (
688 TEXT_OUT_SPLITTER_PRIVATE_DATA
*ConOutPrivate
692 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*Info
;
695 // Copy protocols template
697 if (FeaturePcdGet (PcdConOutUgaSupport
)) {
698 CopyMem (&ConOutPrivate
->UgaDraw
, &mUgaDrawProtocolTemplate
, sizeof (EFI_UGA_DRAW_PROTOCOL
));
700 if (FeaturePcdGet (PcdConOutGopSupport
)) {
701 CopyMem (&ConOutPrivate
->GraphicsOutput
, &mGraphicsOutputProtocolTemplate
, sizeof (EFI_GRAPHICS_OUTPUT_PROTOCOL
));
705 // Initilize console output splitter's private data.
707 ConOutPrivate
->TextOut
.Mode
= &ConOutPrivate
->TextOutMode
;
710 // When new console device is added, the new mode will be set later,
711 // so put current mode back to init state.
713 ConOutPrivate
->TextOutMode
.Mode
= 0xFF;
715 // Allocate buffer for Console Out device
717 Status
= ConSplitterGrowBuffer (
718 sizeof (TEXT_OUT_AND_GOP_DATA
),
719 &ConOutPrivate
->TextOutListCount
,
720 (VOID
**) &ConOutPrivate
->TextOutList
722 if (EFI_ERROR (Status
)) {
723 return EFI_OUT_OF_RESOURCES
;
726 // Allocate buffer for Text Out query data
728 Status
= ConSplitterGrowBuffer (
729 sizeof (TEXT_OUT_SPLITTER_QUERY_DATA
),
730 &ConOutPrivate
->TextOutQueryDataCount
,
731 (VOID
**) &ConOutPrivate
->TextOutQueryData
733 if (EFI_ERROR (Status
)) {
734 return EFI_OUT_OF_RESOURCES
;
738 // Setup the DevNullTextOut console to 80 x 25
740 ConOutPrivate
->TextOutQueryData
[0].Columns
= 80;
741 ConOutPrivate
->TextOutQueryData
[0].Rows
= 25;
742 DevNullTextOutSetMode (ConOutPrivate
, 0);
744 if (FeaturePcdGet (PcdConOutUgaSupport
)) {
746 // Setup the DevNullUgaDraw to 800 x 600 x 32 bits per pixel, 60Hz.
748 ConSpliterUgaDrawSetMode (&ConOutPrivate
->UgaDraw
, 800, 600, 32, 60);
750 if (FeaturePcdGet (PcdConOutGopSupport
)) {
752 // Setup resource for mode information in Graphics Output Protocol interface
754 if ((ConOutPrivate
->GraphicsOutput
.Mode
= AllocateZeroPool (sizeof (EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE
))) == NULL
) {
755 return EFI_OUT_OF_RESOURCES
;
757 if ((ConOutPrivate
->GraphicsOutput
.Mode
->Info
= AllocateZeroPool (sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
))) == NULL
) {
758 return EFI_OUT_OF_RESOURCES
;
761 // Setup the DevNullGraphicsOutput to 800 x 600 x 32 bits per pixel
762 // DevNull will be updated to user-defined mode after driver has started.
764 if ((ConOutPrivate
->GraphicsOutputModeBuffer
= AllocateZeroPool (sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
))) == NULL
) {
765 return EFI_OUT_OF_RESOURCES
;
767 Info
= &ConOutPrivate
->GraphicsOutputModeBuffer
[0];
769 Info
->HorizontalResolution
= 800;
770 Info
->VerticalResolution
= 600;
771 Info
->PixelFormat
= PixelBltOnly
;
772 Info
->PixelsPerScanLine
= 800;
773 CopyMem (ConOutPrivate
->GraphicsOutput
.Mode
->Info
, Info
, sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
));
774 ConOutPrivate
->GraphicsOutput
.Mode
->SizeOfInfo
= sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
);
777 // Initialize the following items, theset items remain unchanged in GraphicsOutput->SetMode()
778 // GraphicsOutputMode->FrameBufferBase, GraphicsOutputMode->FrameBufferSize
780 ConOutPrivate
->GraphicsOutput
.Mode
->FrameBufferBase
= (EFI_PHYSICAL_ADDRESS
) (UINTN
) NULL
;
781 ConOutPrivate
->GraphicsOutput
.Mode
->FrameBufferSize
= 0;
783 ConOutPrivate
->GraphicsOutput
.Mode
->MaxMode
= 1;
785 // Initial current mode to unknown state, and then set to mode 0
787 ConOutPrivate
->GraphicsOutput
.Mode
->Mode
= 0xffff;
788 ConOutPrivate
->GraphicsOutput
.SetMode (&ConOutPrivate
->GraphicsOutput
, 0);
796 Test to see if the specified protocol could be supported on the specified device.
798 @param This Driver Binding protocol pointer.
799 @param ControllerHandle Handle of device to test.
800 @param Guid The specified protocol.
802 @retval EFI_SUCCESS The specified protocol is supported on this device.
803 @retval EFI_UNSUPPORTED The specified protocol attempts to be installed on virtul handle.
804 @retval other Failed to open specified protocol on this device.
808 ConSplitterSupported (
809 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
810 IN EFI_HANDLE ControllerHandle
,
818 // Make sure the Console Splitter does not attempt to attach to itself
820 if (ControllerHandle
== mConIn
.VirtualHandle
||
821 ControllerHandle
== mConOut
.VirtualHandle
||
822 ControllerHandle
== mStdErr
.VirtualHandle
824 return EFI_UNSUPPORTED
;
828 // Check to see whether the specific protocol could be opened BY_DRIVER
830 Status
= gBS
->OpenProtocol (
834 This
->DriverBindingHandle
,
836 EFI_OPEN_PROTOCOL_BY_DRIVER
839 if (EFI_ERROR (Status
)) {
846 This
->DriverBindingHandle
,
854 Test to see if Console In Device could be supported on the Controller.
856 @param This Driver Binding protocol instance pointer.
857 @param ControllerHandle Handle of device to test.
858 @param RemainingDevicePath Optional parameter use to pick a specific child
861 @retval EFI_SUCCESS This driver supports this device.
862 @retval other This driver does not support this device.
867 ConSplitterConInDriverBindingSupported (
868 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
869 IN EFI_HANDLE ControllerHandle
,
870 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
873 return ConSplitterSupported (
876 &gEfiConsoleInDeviceGuid
881 Test to see if Simple Pointer protocol could be supported on the Controller.
883 @param This Driver Binding protocol instance pointer.
884 @param ControllerHandle Handle of device to test.
885 @param RemainingDevicePath Optional parameter use to pick a specific child
888 @retval EFI_SUCCESS This driver supports this device.
889 @retval other This driver does not support this device.
894 ConSplitterSimplePointerDriverBindingSupported (
895 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
896 IN EFI_HANDLE ControllerHandle
,
897 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
900 return ConSplitterSupported (
903 &gEfiSimplePointerProtocolGuid
908 Test to see if Absolute Pointer protocol could be supported on the Controller.
910 @param This Driver Binding protocol instance pointer.
911 @param ControllerHandle Handle of device to test.
912 @param RemainingDevicePath Optional parameter use to pick a specific child
915 @retval EFI_SUCCESS This driver supports this device.
916 @retval other This driver does not support this device.
921 ConSplitterAbsolutePointerDriverBindingSupported (
922 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
923 IN EFI_HANDLE ControllerHandle
,
924 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
927 return ConSplitterSupported (
930 &gEfiAbsolutePointerProtocolGuid
936 Test to see if Console Out Device could be supported on the Controller.
938 @param This Driver Binding protocol instance pointer.
939 @param ControllerHandle Handle of device to test.
940 @param RemainingDevicePath Optional parameter use to pick a specific child
943 @retval EFI_SUCCESS This driver supports this device.
944 @retval other This driver does not support this device.
949 ConSplitterConOutDriverBindingSupported (
950 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
951 IN EFI_HANDLE ControllerHandle
,
952 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
955 return ConSplitterSupported (
958 &gEfiConsoleOutDeviceGuid
963 Test to see if Standard Error Device could be supported on the Controller.
965 @param This Driver Binding protocol instance pointer.
966 @param ControllerHandle Handle of device to test.
967 @param RemainingDevicePath Optional parameter use to pick a specific child
970 @retval EFI_SUCCESS This driver supports this device.
971 @retval other This driver does not support this device.
976 ConSplitterStdErrDriverBindingSupported (
977 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
978 IN EFI_HANDLE ControllerHandle
,
979 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
982 return ConSplitterSupported (
985 &gEfiStandardErrorDeviceGuid
991 Start ConSplitter on devcie handle by opening Console Device Guid on device handle
992 and the console virtual handle. And Get the console interface on controller handle.
994 @param This Driver Binding protocol instance pointer.
995 @param ControllerHandle Handle of device.
996 @param ConSplitterVirtualHandle Console virtual Handle.
997 @param DeviceGuid The specified Console Device, such as ConInDev,
999 @param InterfaceGuid The specified protocol to be opened.
1000 @param Interface Protocol interface returned.
1002 @retval EFI_SUCCESS This driver supports this device.
1003 @retval other Failed to open the specified Console Device Guid
1004 or specified protocol.
1009 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1010 IN EFI_HANDLE ControllerHandle
,
1011 IN EFI_HANDLE ConSplitterVirtualHandle
,
1012 IN EFI_GUID
*DeviceGuid
,
1013 IN EFI_GUID
*InterfaceGuid
,
1014 OUT VOID
**Interface
1021 // Check to see whether the ControllerHandle has the DeviceGuid on it.
1023 Status
= gBS
->OpenProtocol (
1027 This
->DriverBindingHandle
,
1029 EFI_OPEN_PROTOCOL_BY_DRIVER
1031 if (EFI_ERROR (Status
)) {
1036 // Create virtual handle and open DeviceGuid on the virtul handle.
1038 Status
= gBS
->OpenProtocol (
1042 This
->DriverBindingHandle
,
1043 ConSplitterVirtualHandle
,
1044 EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
1046 if (EFI_ERROR (Status
)) {
1051 // Open InterfaceGuid on the virtul handle.
1053 Status
= gBS
->OpenProtocol (
1057 This
->DriverBindingHandle
,
1058 ConSplitterVirtualHandle
,
1059 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1062 if (!EFI_ERROR (Status
)) {
1067 // close the DeviceGuid on ConSplitter VirtualHandle.
1069 gBS
->CloseProtocol (
1072 This
->DriverBindingHandle
,
1073 ConSplitterVirtualHandle
1078 // close the DeviceGuid on ControllerHandle.
1080 gBS
->CloseProtocol (
1083 This
->DriverBindingHandle
,
1092 Start Console In Consplitter on device handle.
1094 @param This Driver Binding protocol instance pointer.
1095 @param ControllerHandle Handle of device to bind driver to.
1096 @param RemainingDevicePath Optional parameter use to pick a specific child
1099 @retval EFI_SUCCESS Console In Consplitter is added to ControllerHandle.
1100 @retval other Console In Consplitter does not support this device.
1105 ConSplitterConInDriverBindingStart (
1106 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1107 IN EFI_HANDLE ControllerHandle
,
1108 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
1112 EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*TextIn
;
1113 EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*TextInEx
;
1116 // Start ConSplitter on ControllerHandle, and create the virtual
1117 // agrogated console device on first call Start for a SimpleTextIn handle.
1119 Status
= ConSplitterStart (
1122 mConIn
.VirtualHandle
,
1123 &gEfiConsoleInDeviceGuid
,
1124 &gEfiSimpleTextInProtocolGuid
,
1127 if (EFI_ERROR (Status
)) {
1132 // Add this device into Text In devices list.
1134 Status
= ConSplitterTextInAddDevice (&mConIn
, TextIn
);
1135 if (EFI_ERROR (Status
)) {
1139 Status
= gBS
->OpenProtocol (
1141 &gEfiSimpleTextInputExProtocolGuid
,
1142 (VOID
**) &TextInEx
,
1143 This
->DriverBindingHandle
,
1144 mConIn
.VirtualHandle
,
1145 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1147 if (!EFI_ERROR (Status
)) {
1149 // If Simple Text Input Ex protocol exists,
1150 // add this device into Text In Ex devices list.
1152 Status
= ConSplitterTextInExAddDevice (&mConIn
, TextInEx
);
1160 Start Simple Pointer Consplitter on device handle.
1162 @param This Driver Binding protocol instance pointer.
1163 @param ControllerHandle Handle of device to bind driver to.
1164 @param RemainingDevicePath Optional parameter use to pick a specific child
1167 @retval EFI_SUCCESS Simple Pointer Consplitter is added to ControllerHandle.
1168 @retval other Simple Pointer Consplitter does not support this device.
1173 ConSplitterSimplePointerDriverBindingStart (
1174 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1175 IN EFI_HANDLE ControllerHandle
,
1176 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
1180 EFI_SIMPLE_POINTER_PROTOCOL
*SimplePointer
;
1183 // Start ConSplitter on ControllerHandle, and create the virtual
1184 // agrogated console device on first call Start for a SimplePointer handle.
1186 Status
= ConSplitterStart (
1189 mConIn
.VirtualHandle
,
1190 &gEfiSimplePointerProtocolGuid
,
1191 &gEfiSimplePointerProtocolGuid
,
1192 (VOID
**) &SimplePointer
1194 if (EFI_ERROR (Status
)) {
1199 // Add this devcie into Simple Pointer devices list.
1201 return ConSplitterSimplePointerAddDevice (&mConIn
, SimplePointer
);
1206 Start Absolute Pointer Consplitter on device handle.
1208 @param This Driver Binding protocol instance pointer.
1209 @param ControllerHandle Handle of device to bind driver to.
1210 @param RemainingDevicePath Optional parameter use to pick a specific child
1213 @retval EFI_SUCCESS Absolute Pointer Consplitter is added to ControllerHandle.
1214 @retval other Absolute Pointer Consplitter does not support this device.
1219 ConSplitterAbsolutePointerDriverBindingStart (
1220 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1221 IN EFI_HANDLE ControllerHandle
,
1222 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
1226 EFI_ABSOLUTE_POINTER_PROTOCOL
*AbsolutePointer
;
1229 // Start ConSplitter on ControllerHandle, and create the virtual
1230 // agrogated console device on first call Start for a AbsolutePointer handle.
1232 Status
= ConSplitterStart (
1235 mConIn
.VirtualHandle
,
1236 &gEfiAbsolutePointerProtocolGuid
,
1237 &gEfiAbsolutePointerProtocolGuid
,
1238 (VOID
**) &AbsolutePointer
1241 if (EFI_ERROR (Status
)) {
1246 // Add this devcie into Absolute Pointer devices list.
1248 return ConSplitterAbsolutePointerAddDevice (&mConIn
, AbsolutePointer
);
1253 Start Console Out Consplitter on device handle.
1255 @param This Driver Binding protocol instance pointer.
1256 @param ControllerHandle Handle of device to bind driver to.
1257 @param RemainingDevicePath Optional parameter use to pick a specific child
1260 @retval EFI_SUCCESS Console Out Consplitter is added to ControllerHandle.
1261 @retval other Console Out Consplitter does not support this device.
1266 ConSplitterConOutDriverBindingStart (
1267 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1268 IN EFI_HANDLE ControllerHandle
,
1269 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
1273 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
;
1274 EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
;
1275 EFI_UGA_DRAW_PROTOCOL
*UgaDraw
;
1278 // Start ConSplitter on ControllerHandle, and create the virtual
1279 // agrogated console device on first call Start for a ConsoleOut handle.
1281 Status
= ConSplitterStart (
1284 mConOut
.VirtualHandle
,
1285 &gEfiConsoleOutDeviceGuid
,
1286 &gEfiSimpleTextOutProtocolGuid
,
1289 if (EFI_ERROR (Status
)) {
1293 GraphicsOutput
= NULL
;
1296 // Try to Open Graphics Output protocol
1298 Status
= gBS
->OpenProtocol (
1300 &gEfiGraphicsOutputProtocolGuid
,
1301 (VOID
**) &GraphicsOutput
,
1302 This
->DriverBindingHandle
,
1303 mConOut
.VirtualHandle
,
1304 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1307 if (EFI_ERROR (Status
) && FeaturePcdGet (PcdUgaConsumeSupport
)) {
1309 // Open UGA DRAW protocol
1311 Status
= gBS
->OpenProtocol (
1313 &gEfiUgaDrawProtocolGuid
,
1315 This
->DriverBindingHandle
,
1316 mConOut
.VirtualHandle
,
1317 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1322 // When new console device is added, the new mode will be set later,
1323 // so put current mode back to init state.
1325 mConOut
.TextOutMode
.Mode
= 0xFF;
1328 // If both ConOut and StdErr incorporate the same Text Out device,
1329 // their MaxMode and QueryData should be the intersection of both.
1331 Status
= ConSplitterTextOutAddDevice (&mConOut
, TextOut
, GraphicsOutput
, UgaDraw
);
1332 ConSplitterTextOutSetAttribute (&mConOut
.TextOut
, EFI_TEXT_ATTR (EFI_LIGHTGRAY
, EFI_BLACK
));
1334 if (FeaturePcdGet (PcdConOutUgaSupport
) && FeaturePcdGet (PcdUgaConsumeSupport
)) {
1336 // Match the UGA mode data of ConOut with the current mode
1338 if (UgaDraw
!= NULL
) {
1341 &mConOut
.UgaHorizontalResolution
,
1342 &mConOut
.UgaVerticalResolution
,
1343 &mConOut
.UgaColorDepth
,
1344 &mConOut
.UgaRefreshRate
1353 Start Standard Error Consplitter on device handle.
1355 @param This Driver Binding protocol instance pointer.
1356 @param ControllerHandle Handle of device to bind driver to.
1357 @param RemainingDevicePath Optional parameter use to pick a specific child
1360 @retval EFI_SUCCESS Standard Error Consplitter is added to ControllerHandle.
1361 @retval other Standard Error Consplitter does not support this device.
1366 ConSplitterStdErrDriverBindingStart (
1367 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1368 IN EFI_HANDLE ControllerHandle
,
1369 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
1373 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
;
1376 // Start ConSplitter on ControllerHandle, and create the virtual
1377 // agrogated console device on first call Start for a StandardError handle.
1379 Status
= ConSplitterStart (
1382 mStdErr
.VirtualHandle
,
1383 &gEfiStandardErrorDeviceGuid
,
1384 &gEfiSimpleTextOutProtocolGuid
,
1387 if (EFI_ERROR (Status
)) {
1392 // When new console device is added, the new mode will be set later,
1393 // so put current mode back to init state.
1395 mStdErr
.TextOutMode
.Mode
= 0xFF;
1398 // If both ConOut and StdErr incorporate the same Text Out device,
1399 // their MaxMode and QueryData should be the intersection of both.
1401 Status
= ConSplitterTextOutAddDevice (&mStdErr
, TextOut
, NULL
, NULL
);
1402 ConSplitterTextOutSetAttribute (&mStdErr
.TextOut
, EFI_TEXT_ATTR (EFI_MAGENTA
, EFI_BLACK
));
1403 if (EFI_ERROR (Status
)) {
1407 if (mStdErr
.CurrentNumberOfConsoles
== 1) {
1408 gST
->StandardErrorHandle
= mStdErr
.VirtualHandle
;
1409 gST
->StdErr
= &mStdErr
.TextOut
;
1411 // Update the CRC32 in the EFI System Table header
1414 gBS
->CalculateCrc32 (
1415 (UINT8
*) &gST
->Hdr
,
1416 gST
->Hdr
.HeaderSize
,
1426 Stop ConSplitter on device handle by closing Console Device Guid on device handle
1427 and the console virtual handle.
1429 @param This Protocol instance pointer.
1430 @param ControllerHandle Handle of device.
1431 @param ConSplitterVirtualHandle Console virtual Handle.
1432 @param DeviceGuid The specified Console Device, such as ConInDev,
1434 @param InterfaceGuid The specified protocol to be opened.
1435 @param Interface Protocol interface returned.
1437 @retval EFI_SUCCESS Stop ConSplitter on ControllerHandle successfully.
1438 @retval other Failed to Stop ConSplitter on ControllerHandle.
1443 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1444 IN EFI_HANDLE ControllerHandle
,
1445 IN EFI_HANDLE ConSplitterVirtualHandle
,
1446 IN EFI_GUID
*DeviceGuid
,
1447 IN EFI_GUID
*InterfaceGuid
,
1453 Status
= gBS
->OpenProtocol (
1457 This
->DriverBindingHandle
,
1459 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1461 if (EFI_ERROR (Status
)) {
1465 // close the protocol refered.
1467 gBS
->CloseProtocol (
1470 This
->DriverBindingHandle
,
1471 ConSplitterVirtualHandle
1474 gBS
->CloseProtocol (
1477 This
->DriverBindingHandle
,
1486 Stop Console In ConSplitter on ControllerHandle by closing Console In Devcice GUID.
1488 @param This Driver Binding protocol instance pointer.
1489 @param ControllerHandle Handle of device to stop driver on
1490 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
1491 children is zero stop the entire bus driver.
1492 @param ChildHandleBuffer List of Child Handles to Stop.
1494 @retval EFI_SUCCESS This driver is removed ControllerHandle
1495 @retval other This driver was not removed from this device
1500 ConSplitterConInDriverBindingStop (
1501 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1502 IN EFI_HANDLE ControllerHandle
,
1503 IN UINTN NumberOfChildren
,
1504 IN EFI_HANDLE
*ChildHandleBuffer
1508 EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*TextIn
;
1509 EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*TextInEx
;
1511 if (NumberOfChildren
== 0) {
1515 Status
= gBS
->OpenProtocol (
1517 &gEfiSimpleTextInputExProtocolGuid
,
1518 (VOID
**) &TextInEx
,
1519 This
->DriverBindingHandle
,
1521 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1523 if (!EFI_ERROR (Status
)) {
1525 // If Simple Text Input Ex protocol exists,
1526 // remove device from Text Input Ex devices list.
1528 Status
= ConSplitterTextInExDeleteDevice (&mConIn
, TextInEx
);
1529 if (EFI_ERROR (Status
)) {
1535 // Close Simple Text In protocol on controller handle and virtual handle.
1537 Status
= ConSplitterStop (
1540 mConIn
.VirtualHandle
,
1541 &gEfiConsoleInDeviceGuid
,
1542 &gEfiSimpleTextInProtocolGuid
,
1545 if (EFI_ERROR (Status
)) {
1550 // Remove device from Text Input devices list.
1552 return ConSplitterTextInDeleteDevice (&mConIn
, TextIn
);
1557 Stop Simple Pointer protocol ConSplitter on ControllerHandle by closing
1558 Simple Pointer protocol.
1560 @param This Driver Binding protocol instance pointer.
1561 @param ControllerHandle Handle of device to stop driver on
1562 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
1563 children is zero stop the entire bus driver.
1564 @param ChildHandleBuffer List of Child Handles to Stop.
1566 @retval EFI_SUCCESS This driver is removed ControllerHandle
1567 @retval other This driver was not removed from this device
1572 ConSplitterSimplePointerDriverBindingStop (
1573 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1574 IN EFI_HANDLE ControllerHandle
,
1575 IN UINTN NumberOfChildren
,
1576 IN EFI_HANDLE
*ChildHandleBuffer
1580 EFI_SIMPLE_POINTER_PROTOCOL
*SimplePointer
;
1582 if (NumberOfChildren
== 0) {
1587 // Close Simple Pointer protocol on controller handle and virtual handle.
1589 Status
= ConSplitterStop (
1592 mConIn
.VirtualHandle
,
1593 &gEfiSimplePointerProtocolGuid
,
1594 &gEfiSimplePointerProtocolGuid
,
1595 (VOID
**) &SimplePointer
1597 if (EFI_ERROR (Status
)) {
1602 // Remove this device from Simple Pointer device list.
1604 return ConSplitterSimplePointerDeleteDevice (&mConIn
, SimplePointer
);
1609 Stop Absolute Pointer protocol ConSplitter on ControllerHandle by closing
1610 Absolute Pointer protocol.
1612 @param This Driver Binding protocol instance pointer.
1613 @param ControllerHandle Handle of device to stop driver on
1614 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
1615 children is zero stop the entire bus driver.
1616 @param ChildHandleBuffer List of Child Handles to Stop.
1618 @retval EFI_SUCCESS This driver is removed ControllerHandle
1619 @retval other This driver was not removed from this device
1624 ConSplitterAbsolutePointerDriverBindingStop (
1625 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1626 IN EFI_HANDLE ControllerHandle
,
1627 IN UINTN NumberOfChildren
,
1628 IN EFI_HANDLE
*ChildHandleBuffer
1632 EFI_ABSOLUTE_POINTER_PROTOCOL
*AbsolutePointer
;
1634 if (NumberOfChildren
== 0) {
1639 // Close Absolute Pointer protocol on controller handle and virtual handle.
1641 Status
= ConSplitterStop (
1644 mConIn
.VirtualHandle
,
1645 &gEfiAbsolutePointerProtocolGuid
,
1646 &gEfiAbsolutePointerProtocolGuid
,
1647 (VOID
**) &AbsolutePointer
1649 if (EFI_ERROR (Status
)) {
1654 // Remove this device from Absolute Pointer device list.
1656 return ConSplitterAbsolutePointerDeleteDevice (&mConIn
, AbsolutePointer
);
1661 Stop Console Out ConSplitter on device handle by closing Console Out Devcice GUID.
1663 @param This Driver Binding protocol instance pointer.
1664 @param ControllerHandle Handle of device to stop driver on
1665 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
1666 children is zero stop the entire bus driver.
1667 @param ChildHandleBuffer List of Child Handles to Stop.
1669 @retval EFI_SUCCESS This driver is removed ControllerHandle
1670 @retval other This driver was not removed from this device
1675 ConSplitterConOutDriverBindingStop (
1676 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1677 IN EFI_HANDLE ControllerHandle
,
1678 IN UINTN NumberOfChildren
,
1679 IN EFI_HANDLE
*ChildHandleBuffer
1683 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
;
1685 if (NumberOfChildren
== 0) {
1690 // Close Absolute Pointer protocol on controller handle and virtual handle.
1692 Status
= ConSplitterStop (
1695 mConOut
.VirtualHandle
,
1696 &gEfiConsoleOutDeviceGuid
,
1697 &gEfiSimpleTextOutProtocolGuid
,
1700 if (EFI_ERROR (Status
)) {
1705 // Remove this device from Text Out device list.
1707 return ConSplitterTextOutDeleteDevice (&mConOut
, TextOut
);
1712 Stop Standard Error ConSplitter on ControllerHandle by closing Standard Error GUID.
1714 @param This Driver Binding protocol instance pointer.
1715 @param ControllerHandle Handle of device to stop driver on
1716 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
1717 children is zero stop the entire bus driver.
1718 @param ChildHandleBuffer List of Child Handles to Stop.
1720 @retval EFI_SUCCESS This driver is removed ControllerHandle
1721 @retval other This driver was not removed from this device
1726 ConSplitterStdErrDriverBindingStop (
1727 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1728 IN EFI_HANDLE ControllerHandle
,
1729 IN UINTN NumberOfChildren
,
1730 IN EFI_HANDLE
*ChildHandleBuffer
1734 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
;
1736 if (NumberOfChildren
== 0) {
1741 // Close Standard Error Device on controller handle and virtual handle.
1743 Status
= ConSplitterStop (
1746 mStdErr
.VirtualHandle
,
1747 &gEfiStandardErrorDeviceGuid
,
1748 &gEfiSimpleTextOutProtocolGuid
,
1751 if (EFI_ERROR (Status
)) {
1755 // Delete this console error out device's data structures.
1757 Status
= ConSplitterTextOutDeleteDevice (&mStdErr
, TextOut
);
1758 if (EFI_ERROR (Status
)) {
1762 if (mStdErr
.CurrentNumberOfConsoles
== 0) {
1763 gST
->StandardErrorHandle
= NULL
;
1766 // Update the CRC32 in the EFI System Table header
1769 gBS
->CalculateCrc32 (
1770 (UINT8
*) &gST
->Hdr
,
1771 gST
->Hdr
.HeaderSize
,
1781 Take the passed in Buffer of size SizeOfCount and grow the buffer
1782 by MAX (CONSOLE_SPLITTER_CONSOLES_ALLOC_UNIT, MaxGrow) * SizeOfCount
1783 bytes. Copy the current data in Buffer to the new version of Buffer
1784 and free the old version of buffer.
1786 @param SizeOfCount Size of element in array.
1787 @param Count Current number of elements in array.
1788 @param Buffer Bigger version of passed in Buffer with all the
1791 @retval EFI_SUCCESS Buffer size has grown.
1792 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
1796 ConSplitterGrowBuffer (
1797 IN UINTN SizeOfCount
,
1799 IN OUT VOID
**Buffer
1805 // grow the buffer to new buffer size,
1806 // copy the old buffer's content to the new-size buffer,
1807 // then free the old buffer.
1809 *Count
+= CONSOLE_SPLITTER_CONSOLES_ALLOC_UNIT
;
1810 Ptr
= ReallocatePool (
1811 SizeOfCount
* ((*Count
) - CONSOLE_SPLITTER_CONSOLES_ALLOC_UNIT
),
1812 SizeOfCount
* (*Count
),
1816 return EFI_OUT_OF_RESOURCES
;
1824 Add Text Input Device in Consplitter Text Input list.
1826 @param Private Text In Splitter pointer.
1827 @param TextIn Simple Text Input protocol pointer.
1829 @retval EFI_SUCCESS Text Input Device added successfully.
1830 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
1834 ConSplitterTextInAddDevice (
1835 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
1836 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*TextIn
1842 // If the Text In List is full, enlarge it by calling ConSplitterGrowBuffer().
1844 if (Private
->CurrentNumberOfConsoles
>= Private
->TextInListCount
) {
1845 Status
= ConSplitterGrowBuffer (
1846 sizeof (EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*),
1847 &Private
->TextInListCount
,
1848 (VOID
**) &Private
->TextInList
1850 if (EFI_ERROR (Status
)) {
1851 return EFI_OUT_OF_RESOURCES
;
1855 // Add the new text-in device data structure into the Text In List.
1857 Private
->TextInList
[Private
->CurrentNumberOfConsoles
] = TextIn
;
1858 Private
->CurrentNumberOfConsoles
++;
1861 // Extra CheckEvent added to reduce the double CheckEvent().
1863 gBS
->CheckEvent (TextIn
->WaitForKey
);
1870 Remove Text Input Device from Consplitter Text Input list.
1872 @param Private Text In Splitter pointer.
1873 @param TextIn Simple Text protocol pointer.
1875 @retval EFI_SUCCESS Simple Text Device removed successfully.
1876 @retval EFI_NOT_FOUND No Simple Text Device found.
1880 ConSplitterTextInDeleteDevice (
1881 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
1882 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*TextIn
1887 // Remove the specified text-in device data structure from the Text In List,
1888 // and rearrange the remaining data structures in the Text In List.
1890 for (Index
= 0; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
1891 if (Private
->TextInList
[Index
] == TextIn
) {
1892 for (Index
= Index
; Index
< Private
->CurrentNumberOfConsoles
- 1; Index
++) {
1893 Private
->TextInList
[Index
] = Private
->TextInList
[Index
+ 1];
1896 Private
->CurrentNumberOfConsoles
--;
1901 return EFI_NOT_FOUND
;
1905 Add Text Input Ex Device in Consplitter Text Input Ex list.
1907 @param Private Text In Splitter pointer.
1908 @param TextInEx Simple Text Input Ex Input protocol pointer.
1910 @retval EFI_SUCCESS Text Input Ex Device added successfully.
1911 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
1915 ConSplitterTextInExAddDevice (
1916 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
1917 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*TextInEx
1923 // If the Text Input Ex List is full, enlarge it by calling ConSplitterGrowBuffer().
1925 if (Private
->CurrentNumberOfExConsoles
>= Private
->TextInExListCount
) {
1926 Status
= ConSplitterGrowBuffer (
1927 sizeof (EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*),
1928 &Private
->TextInExListCount
,
1929 (VOID
**) &Private
->TextInExList
1931 if (EFI_ERROR (Status
)) {
1932 return EFI_OUT_OF_RESOURCES
;
1936 // Add the new text-in device data structure into the Text Input Ex List.
1938 Private
->TextInExList
[Private
->CurrentNumberOfExConsoles
] = TextInEx
;
1939 Private
->CurrentNumberOfExConsoles
++;
1942 // Extra CheckEvent added to reduce the double CheckEvent().
1944 gBS
->CheckEvent (TextInEx
->WaitForKeyEx
);
1950 Remove Text Ex Device from Consplitter Text Input Ex list.
1952 @param Private Text In Splitter pointer.
1953 @param TextInEx Simple Text Ex protocol pointer.
1955 @retval EFI_SUCCESS Simple Text Input Ex Device removed successfully.
1956 @retval EFI_NOT_FOUND No Simple Text Input Ex Device found.
1960 ConSplitterTextInExDeleteDevice (
1961 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
1962 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*TextInEx
1967 // Remove the specified text-in device data structure from the Text Input Ex List,
1968 // and rearrange the remaining data structures in the Text In List.
1970 for (Index
= 0; Index
< Private
->CurrentNumberOfExConsoles
; Index
++) {
1971 if (Private
->TextInExList
[Index
] == TextInEx
) {
1972 for (Index
= Index
; Index
< Private
->CurrentNumberOfExConsoles
- 1; Index
++) {
1973 Private
->TextInExList
[Index
] = Private
->TextInExList
[Index
+ 1];
1976 Private
->CurrentNumberOfExConsoles
--;
1981 return EFI_NOT_FOUND
;
1986 Add Simple Pointer Device in Consplitter Simple Pointer list.
1988 @param Private Text In Splitter pointer.
1989 @param SimplePointer Simple Pointer protocol pointer.
1991 @retval EFI_SUCCESS Simple Pointer Device added successfully.
1992 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
1996 ConSplitterSimplePointerAddDevice (
1997 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
1998 IN EFI_SIMPLE_POINTER_PROTOCOL
*SimplePointer
2004 // If the Simple Pointer List is full, enlarge it by calling ConSplitterGrowBuffer().
2006 if (Private
->CurrentNumberOfPointers
>= Private
->PointerListCount
) {
2007 Status
= ConSplitterGrowBuffer (
2008 sizeof (EFI_SIMPLE_POINTER_PROTOCOL
*),
2009 &Private
->PointerListCount
,
2010 (VOID
**) &Private
->PointerList
2012 if (EFI_ERROR (Status
)) {
2013 return EFI_OUT_OF_RESOURCES
;
2017 // Add the new text-in device data structure into the Simple Pointer List.
2019 Private
->PointerList
[Private
->CurrentNumberOfPointers
] = SimplePointer
;
2020 Private
->CurrentNumberOfPointers
++;
2027 Remove Simple Pointer Device from Consplitter Simple Pointer list.
2029 @param Private Text In Splitter pointer.
2030 @param SimplePointer Simple Pointer protocol pointer.
2032 @retval EFI_SUCCESS Simple Pointer Device removed successfully.
2033 @retval EFI_NOT_FOUND No Simple Pointer Device found.
2037 ConSplitterSimplePointerDeleteDevice (
2038 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
2039 IN EFI_SIMPLE_POINTER_PROTOCOL
*SimplePointer
2044 // Remove the specified text-in device data structure from the Simple Pointer List,
2045 // and rearrange the remaining data structures in the Text In List.
2047 for (Index
= 0; Index
< Private
->CurrentNumberOfPointers
; Index
++) {
2048 if (Private
->PointerList
[Index
] == SimplePointer
) {
2049 for (Index
= Index
; Index
< Private
->CurrentNumberOfPointers
- 1; Index
++) {
2050 Private
->PointerList
[Index
] = Private
->PointerList
[Index
+ 1];
2053 Private
->CurrentNumberOfPointers
--;
2058 return EFI_NOT_FOUND
;
2063 Add Absolute Pointer Device in Consplitter Absolute Pointer list.
2065 @param Private Text In Splitter pointer.
2066 @param AbsolutePointer Absolute Pointer protocol pointer.
2068 @retval EFI_SUCCESS Absolute Pointer Device added successfully.
2069 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
2073 ConSplitterAbsolutePointerAddDevice (
2074 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
2075 IN EFI_ABSOLUTE_POINTER_PROTOCOL
*AbsolutePointer
2081 // If the Absolute Pointer List is full, enlarge it by calling ConSplitterGrowBuffer().
2083 if (Private
->CurrentNumberOfAbsolutePointers
>= Private
->AbsolutePointerListCount
) {
2084 Status
= ConSplitterGrowBuffer (
2085 sizeof (EFI_ABSOLUTE_POINTER_PROTOCOL
*),
2086 &Private
->AbsolutePointerListCount
,
2087 (VOID
**) &Private
->AbsolutePointerList
2089 if (EFI_ERROR (Status
)) {
2090 return EFI_OUT_OF_RESOURCES
;
2094 // Add the new text-in device data structure into the Absolute Pointer List.
2096 Private
->AbsolutePointerList
[Private
->CurrentNumberOfAbsolutePointers
] = AbsolutePointer
;
2097 Private
->CurrentNumberOfAbsolutePointers
++;
2104 Remove Absolute Pointer Device from Consplitter Absolute Pointer list.
2106 @param Private Text In Splitter pointer.
2107 @param AbsolutePointer Absolute Pointer protocol pointer.
2109 @retval EFI_SUCCESS Absolute Pointer Device removed successfully.
2110 @retval EFI_NOT_FOUND No Absolute Pointer Device found.
2114 ConSplitterAbsolutePointerDeleteDevice (
2115 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
2116 IN EFI_ABSOLUTE_POINTER_PROTOCOL
*AbsolutePointer
2121 // Remove the specified text-in device data structure from the Absolute Pointer List,
2122 // and rearrange the remaining data structures from the Absolute Pointer List.
2124 for (Index
= 0; Index
< Private
->CurrentNumberOfAbsolutePointers
; Index
++) {
2125 if (Private
->AbsolutePointerList
[Index
] == AbsolutePointer
) {
2126 for (Index
= Index
; Index
< Private
->CurrentNumberOfAbsolutePointers
- 1; Index
++) {
2127 Private
->AbsolutePointerList
[Index
] = Private
->AbsolutePointerList
[Index
+ 1];
2130 Private
->CurrentNumberOfAbsolutePointers
--;
2135 return EFI_NOT_FOUND
;
2139 Reallocate Text Out mode map.
2141 Allocate new buffer and copy original buffer into the new buffer.
2143 @param Private Consplitter Text Out pointer.
2145 @retval EFI_SUCCESS Buffer size has grown
2146 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
2150 ConSplitterGrowMapTable (
2151 IN TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
2157 INT32
*TextOutModeMap
;
2158 INT32
*OldTextOutModeMap
;
2162 NewSize
= Private
->TextOutListCount
* sizeof (INT32
);
2163 OldTextOutModeMap
= Private
->TextOutModeMap
;
2164 TotalSize
= NewSize
* (Private
->TextOutQueryDataCount
);
2167 // Allocate new buffer for Text Out List.
2169 TextOutModeMap
= AllocatePool (TotalSize
);
2170 if (TextOutModeMap
== NULL
) {
2171 return EFI_OUT_OF_RESOURCES
;
2174 SetMem (TextOutModeMap
, TotalSize
, 0xFF);
2175 Private
->TextOutModeMap
= TextOutModeMap
;
2178 // If TextOutList has been enlarged, need to realloc the mode map table
2179 // The mode map table is regarded as a two dimension array.
2182 // 0 ---------> TextOutListCount ----> TextOutListCount
2183 // | -------------------------------------------
2190 // -------------------------------------------
2193 if (OldTextOutModeMap
!= NULL
) {
2195 Size
= Private
->CurrentNumberOfConsoles
* sizeof (INT32
);
2197 SrcAddress
= OldTextOutModeMap
;
2200 // Copy the old data to the new one
2202 while (Index
< Private
->TextOutMode
.MaxMode
) {
2203 CopyMem (TextOutModeMap
, SrcAddress
, Size
);
2204 TextOutModeMap
+= NewSize
;
2209 // Free the old buffer
2211 FreePool (OldTextOutModeMap
);
2219 Add new device's output mode to console splitter's mode list.
2221 @param Private Text Out Splitter pointer
2222 @param TextOut Simple Text Output protocol pointer.
2224 @retval EFI_SUCCESS Device added successfully.
2225 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
2229 ConSplitterAddOutputMode (
2230 IN TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
,
2231 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
2239 MaxMode
= TextOut
->Mode
->MaxMode
;
2240 Private
->TextOutMode
.MaxMode
= MaxMode
;
2243 // Grow the buffer if query data buffer is not large enough to
2244 // hold all the mode supported by the first console.
2246 while (MaxMode
> (INT32
) Private
->TextOutQueryDataCount
) {
2247 Status
= ConSplitterGrowBuffer (
2248 sizeof (TEXT_OUT_SPLITTER_QUERY_DATA
),
2249 &Private
->TextOutQueryDataCount
,
2250 (VOID
**) &Private
->TextOutQueryData
2252 if (EFI_ERROR (Status
)) {
2253 return EFI_OUT_OF_RESOURCES
;
2257 // Allocate buffer for the output mode map
2259 Status
= ConSplitterGrowMapTable (Private
);
2260 if (EFI_ERROR (Status
)) {
2261 return EFI_OUT_OF_RESOURCES
;
2264 // As the first textout device, directly add the mode in to QueryData
2265 // and at the same time record the mapping between QueryData and TextOut.
2269 while (Mode
< MaxMode
) {
2270 Status
= TextOut
->QueryMode (
2273 &Private
->TextOutQueryData
[Mode
].Columns
,
2274 &Private
->TextOutQueryData
[Mode
].Rows
2277 // If mode 1 (80x50) is not supported, make sure mode 1 in TextOutQueryData
2280 if ((EFI_ERROR(Status
)) && (Mode
== 1)) {
2281 Private
->TextOutQueryData
[Mode
].Columns
= 0;
2282 Private
->TextOutQueryData
[Mode
].Rows
= 0;
2284 Private
->TextOutModeMap
[Index
] = Mode
;
2286 Index
+= Private
->TextOutListCount
;
2293 Reconstruct TextOutModeMap to get intersection of modes.
2295 This routine reconstruct TextOutModeMap to get the intersection
2296 of modes for all console out devices. Because EFI/UEFI spec require
2297 mode 0 is 80x25, mode 1 is 80x50, this routine will not check the
2298 intersection for mode 0 and mode 1.
2300 @param TextOutModeMap Current text out mode map, begin with the mode 80x25
2301 @param NewlyAddedMap New text out mode map, begin with the mode 80x25
2302 @param MapStepSize Mode step size for one console device
2303 @param NewMapStepSize New Mode step size for one console device
2304 @param MaxMode IN: Current max text mode, OUT: Updated max text mode.
2305 @param CurrentMode IN: Current text mode, OUT: Updated current text mode.
2309 ConSplitterGetIntersection (
2310 IN INT32
*TextOutModeMap
,
2311 IN INT32
*NewlyAddedMap
,
2312 IN UINTN MapStepSize
,
2313 IN UINTN NewMapStepSize
,
2314 IN OUT INT32
*MaxMode
,
2315 IN OUT INT32
*CurrentMode
2319 INT32
*CurrentMapEntry
;
2320 INT32
*NextMapEntry
;
2322 INT32 CurrentMaxMode
;
2326 // According to EFI/UEFI spec, mode 0 and mode 1 have been reserved
2327 // for 80x25 and 80x50 in Simple Text Out protocol, so don't make intersection
2328 // for mode 0 and mode 1, mode number starts from 2.
2331 CurrentMapEntry
= &TextOutModeMap
[MapStepSize
* 2];
2332 NextMapEntry
= CurrentMapEntry
;
2333 NewMapEntry
= &NewlyAddedMap
[NewMapStepSize
* 2];
2335 CurrentMaxMode
= *MaxMode
;
2336 Mode
= *CurrentMode
;
2338 while (Index
< CurrentMaxMode
) {
2339 if (*NewMapEntry
== -1) {
2341 // This mode is not supported any more. Remove it. Special care
2342 // must be taken as this remove will also affect current mode;
2344 if (Index
== *CurrentMode
) {
2346 } else if (Index
< *CurrentMode
) {
2351 if (CurrentMapEntry
!= NextMapEntry
) {
2352 CopyMem (NextMapEntry
, CurrentMapEntry
, MapStepSize
* sizeof (INT32
));
2355 NextMapEntry
+= MapStepSize
;
2358 CurrentMapEntry
+= MapStepSize
;
2359 NewMapEntry
+= NewMapStepSize
;
2363 *CurrentMode
= Mode
;
2369 Add the device's output mode to console splitter's mode list.
2371 @param Private Text Out Splitter pointer.
2372 @param TextOut Simple Text Output protocol pointer.
2376 ConSplitterSyncOutputMode (
2377 IN TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
,
2378 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
2381 INT32 CurrentMaxMode
;
2384 INT32
*TextOutModeMap
;
2387 TEXT_OUT_SPLITTER_QUERY_DATA
*TextOutQueryData
;
2394 // Must make sure that current mode won't change even if mode number changes
2396 CurrentMaxMode
= Private
->TextOutMode
.MaxMode
;
2397 TextOutModeMap
= Private
->TextOutModeMap
;
2398 StepSize
= Private
->TextOutListCount
;
2399 TextOutQueryData
= Private
->TextOutQueryData
;
2402 // Query all the mode that the newly added TextOut supports
2405 MapTable
= TextOutModeMap
+ Private
->CurrentNumberOfConsoles
;
2406 while (Mode
< TextOut
->Mode
->MaxMode
) {
2407 Status
= TextOut
->QueryMode (TextOut
, Mode
, &Columns
, &Rows
);
2409 if (EFI_ERROR(Status
)) {
2412 // If mode 1 (80x50) is not supported, make sure mode 1 in TextOutQueryData
2415 MapTable
[StepSize
] = Mode
;
2416 TextOutQueryData
[Mode
].Columns
= 0;
2417 TextOutQueryData
[Mode
].Rows
= 0;
2423 // Search the intersection map and QueryData database to see if they intersects
2426 while (Index
< CurrentMaxMode
) {
2427 QueryMode
= *(TextOutModeMap
+ Index
* StepSize
);
2428 if ((TextOutQueryData
[QueryMode
].Rows
== Rows
) && (TextOutQueryData
[QueryMode
].Columns
== Columns
)) {
2429 MapTable
[Index
* StepSize
] = Mode
;
2437 // Now search the TextOutModeMap table to find the intersection of supported
2438 // mode between ConSplitter and the newly added device.
2440 ConSplitterGetIntersection (
2445 &Private
->TextOutMode
.MaxMode
,
2446 &Private
->TextOutMode
.Mode
2454 Sync output device between ConOut and StdErr output.
2456 @retval EFI_SUCCESS Sync implemented successfully.
2457 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
2461 ConSplitterGetIntersectionBetweenConOutAndStrErr (
2465 UINTN ConOutNumOfConsoles
;
2466 UINTN StdErrNumOfConsoles
;
2467 TEXT_OUT_AND_GOP_DATA
*ConOutTextOutList
;
2468 TEXT_OUT_AND_GOP_DATA
*StdErrTextOutList
;
2472 UINTN ConOutColumns
;
2474 UINTN StdErrColumns
;
2475 INT32 ConOutMaxMode
;
2476 INT32 StdErrMaxMode
;
2481 INT32
*ConOutModeMap
;
2482 INT32
*StdErrModeMap
;
2483 INT32
*ConOutMapTable
;
2484 INT32
*StdErrMapTable
;
2485 TEXT_OUT_SPLITTER_QUERY_DATA
*ConOutQueryData
;
2486 TEXT_OUT_SPLITTER_QUERY_DATA
*StdErrQueryData
;
2487 UINTN ConOutStepSize
;
2488 UINTN StdErrStepSize
;
2489 BOOLEAN FoundTheSameTextOut
;
2490 UINTN ConOutMapTableSize
;
2491 UINTN StdErrMapTableSize
;
2493 ConOutNumOfConsoles
= mConOut
.CurrentNumberOfConsoles
;
2494 StdErrNumOfConsoles
= mStdErr
.CurrentNumberOfConsoles
;
2495 ConOutTextOutList
= mConOut
.TextOutList
;
2496 StdErrTextOutList
= mStdErr
.TextOutList
;
2499 FoundTheSameTextOut
= FALSE
;
2500 while ((Indexi
< ConOutNumOfConsoles
) && (!FoundTheSameTextOut
)) {
2502 while (Indexj
< StdErrNumOfConsoles
) {
2503 if (ConOutTextOutList
->TextOut
== StdErrTextOutList
->TextOut
) {
2504 FoundTheSameTextOut
= TRUE
;
2509 StdErrTextOutList
++;
2513 ConOutTextOutList
++;
2516 if (!FoundTheSameTextOut
) {
2520 // Must make sure that current mode won't change even if mode number changes
2522 ConOutMaxMode
= mConOut
.TextOutMode
.MaxMode
;
2523 ConOutModeMap
= mConOut
.TextOutModeMap
;
2524 ConOutStepSize
= mConOut
.TextOutListCount
;
2525 ConOutQueryData
= mConOut
.TextOutQueryData
;
2527 StdErrMaxMode
= mStdErr
.TextOutMode
.MaxMode
;
2528 StdErrModeMap
= mStdErr
.TextOutModeMap
;
2529 StdErrStepSize
= mStdErr
.TextOutListCount
;
2530 StdErrQueryData
= mStdErr
.TextOutQueryData
;
2533 // Allocate the map table and set the map table's index to -1.
2535 ConOutMapTableSize
= ConOutMaxMode
* sizeof (INT32
);
2536 ConOutMapTable
= AllocateZeroPool (ConOutMapTableSize
);
2537 if (ConOutMapTable
== NULL
) {
2538 return EFI_OUT_OF_RESOURCES
;
2541 SetMem (ConOutMapTable
, ConOutMapTableSize
, 0xFF);
2543 StdErrMapTableSize
= StdErrMaxMode
* sizeof (INT32
);
2544 StdErrMapTable
= AllocateZeroPool (StdErrMapTableSize
);
2545 if (StdErrMapTable
== NULL
) {
2546 return EFI_OUT_OF_RESOURCES
;
2549 SetMem (StdErrMapTable
, StdErrMapTableSize
, 0xFF);
2552 // Find the intersection of the two set of modes. If they actually intersect, the
2553 // correponding entry in the map table is set to 1.
2556 while (Mode
< ConOutMaxMode
) {
2558 // Search the intersection map and QueryData database to see if they intersect
2561 ConOutMode
= *(ConOutModeMap
+ Mode
* ConOutStepSize
);
2562 ConOutRows
= ConOutQueryData
[ConOutMode
].Rows
;
2563 ConOutColumns
= ConOutQueryData
[ConOutMode
].Columns
;
2564 while (Index
< StdErrMaxMode
) {
2565 StdErrMode
= *(StdErrModeMap
+ Index
* StdErrStepSize
);
2566 StdErrRows
= StdErrQueryData
[StdErrMode
].Rows
;
2567 StdErrColumns
= StdErrQueryData
[StdErrMode
].Columns
;
2568 if ((StdErrRows
== ConOutRows
) && (StdErrColumns
== ConOutColumns
)) {
2569 ConOutMapTable
[Mode
] = 1;
2570 StdErrMapTable
[Index
] = 1;
2580 // Now search the TextOutModeMap table to find the intersection of supported
2581 // mode between ConSplitter and the newly added device.
2583 ConSplitterGetIntersection (
2586 mConOut
.TextOutListCount
,
2588 &(mConOut
.TextOutMode
.MaxMode
),
2589 &(mConOut
.TextOutMode
.Mode
)
2592 if (mConOut
.TextOutMode
.Mode
< 0) {
2593 mConOut
.TextOut
.SetMode (&(mConOut
.TextOut
), 0);
2596 ConSplitterGetIntersection (
2599 mStdErr
.TextOutListCount
,
2601 &(mStdErr
.TextOutMode
.MaxMode
),
2602 &(mStdErr
.TextOutMode
.Mode
)
2605 if (mStdErr
.TextOutMode
.Mode
< 0) {
2606 mStdErr
.TextOut
.SetMode (&(mStdErr
.TextOut
), 0);
2609 FreePool (ConOutMapTable
);
2610 FreePool (StdErrMapTable
);
2617 Add display (GOP or UGA) output modes into Consplitter Text Out list.
2619 @param Private Text Out Splitter pointer.
2620 @param GraphicsOutput Graphics Output protocol pointer.
2621 @param UgaDraw UGA Draw protocol pointer.
2623 @retval EFI_SUCCESS Output mode added successfully.
2624 @retval other Failed to add output mode.
2628 ConSplitterAddDisplayOutputMode (
2629 IN TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
,
2630 IN EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
,
2631 IN EFI_UGA_DRAW_PROTOCOL
*UgaDraw
2637 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*Mode
;
2639 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*Info
;
2640 EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE
*CurrentGraphicsOutputMode
;
2641 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*ModeBuffer
;
2642 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*MatchedMode
;
2645 BOOLEAN AlreadyExist
;
2646 UINT32 UgaHorizontalResolution
;
2647 UINT32 UgaVerticalResolution
;
2648 UINT32 UgaColorDepth
;
2649 UINT32 UgaRefreshRate
;
2651 if ((GraphicsOutput
== NULL
) && (UgaDraw
== NULL
)) {
2652 return EFI_UNSUPPORTED
;
2655 CurrentGraphicsOutputMode
= Private
->GraphicsOutput
.Mode
;
2660 if (Private
->CurrentNumberOfUgaDraw
!= 0) {
2662 // If any UGA device has already been added, then there is no need to
2663 // calculate intersection of display mode of different GOP/UGA device,
2664 // since only one display mode will be exported (i.e. user-defined mode)
2669 if (GraphicsOutput
!= NULL
) {
2670 if (Private
->CurrentNumberOfGraphicsOutput
== 0) {
2672 // This is the first Graphics Output device added
2674 CurrentGraphicsOutputMode
->MaxMode
= GraphicsOutput
->Mode
->MaxMode
;
2675 CurrentGraphicsOutputMode
->Mode
= GraphicsOutput
->Mode
->Mode
;
2676 CopyMem (CurrentGraphicsOutputMode
->Info
, GraphicsOutput
->Mode
->Info
, GraphicsOutput
->Mode
->SizeOfInfo
);
2677 CurrentGraphicsOutputMode
->SizeOfInfo
= GraphicsOutput
->Mode
->SizeOfInfo
;
2678 CurrentGraphicsOutputMode
->FrameBufferBase
= GraphicsOutput
->Mode
->FrameBufferBase
;
2679 CurrentGraphicsOutputMode
->FrameBufferSize
= GraphicsOutput
->Mode
->FrameBufferSize
;
2682 // Allocate resource for the private mode buffer
2684 ModeBuffer
= AllocatePool (sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
) * GraphicsOutput
->Mode
->MaxMode
);
2685 if (ModeBuffer
== NULL
) {
2686 return EFI_OUT_OF_RESOURCES
;
2688 FreePool (Private
->GraphicsOutputModeBuffer
);
2689 Private
->GraphicsOutputModeBuffer
= ModeBuffer
;
2692 // Store all supported display modes to the private mode buffer
2695 for (Index
= 0; Index
< GraphicsOutput
->Mode
->MaxMode
; Index
++) {
2697 // The Info buffer would be allocated by callee
2699 Status
= GraphicsOutput
->QueryMode (GraphicsOutput
, (UINT32
) Index
, &SizeOfInfo
, &Info
);
2700 if (EFI_ERROR (Status
)) {
2703 ASSERT ( SizeOfInfo
<= sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
));
2704 CopyMem (Mode
, Info
, SizeOfInfo
);
2710 // Check intersection of display mode
2712 ModeBuffer
= AllocatePool (sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
) * CurrentGraphicsOutputMode
->MaxMode
);
2713 if (ModeBuffer
== NULL
) {
2714 return EFI_OUT_OF_RESOURCES
;
2717 MatchedMode
= ModeBuffer
;
2718 Mode
= &Private
->GraphicsOutputModeBuffer
[0];
2719 for (Index
= 0; Index
< CurrentGraphicsOutputMode
->MaxMode
; Index
++) {
2722 for (NumberIndex
= 0; NumberIndex
< GraphicsOutput
->Mode
->MaxMode
; NumberIndex
++) {
2724 // The Info buffer would be allocated by callee
2726 Status
= GraphicsOutput
->QueryMode (GraphicsOutput
, (UINT32
) NumberIndex
, &SizeOfInfo
, &Info
);
2727 if (EFI_ERROR (Status
)) {
2730 if ((Info
->HorizontalResolution
== Mode
->HorizontalResolution
) &&
2731 (Info
->VerticalResolution
== Mode
->VerticalResolution
)) {
2733 // If GOP device supports one mode in current mode buffer,
2734 // it will be added into matched mode buffer
2744 AlreadyExist
= FALSE
;
2747 // Check if GOP mode has been in the mode buffer, ModeBuffer = MatchedMode at begin.
2749 for (Info
= ModeBuffer
; Info
< MatchedMode
; Info
++) {
2750 if ((Info
->HorizontalResolution
== Mode
->HorizontalResolution
) &&
2751 (Info
->VerticalResolution
== Mode
->VerticalResolution
)) {
2752 AlreadyExist
= TRUE
;
2757 if (!AlreadyExist
) {
2758 CopyMem (MatchedMode
, Mode
, sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
));
2761 // Physical frame buffer is no longer available, change PixelFormat to PixelBltOnly
2763 MatchedMode
->Version
= 0;
2764 MatchedMode
->PixelFormat
= PixelBltOnly
;
2765 ZeroMem (&MatchedMode
->PixelInformation
, sizeof (EFI_PIXEL_BITMASK
));
2775 // Drop the old mode buffer, assign it to a new one
2777 FreePool (Private
->GraphicsOutputModeBuffer
);
2778 Private
->GraphicsOutputModeBuffer
= ModeBuffer
;
2781 // Physical frame buffer is no longer available when there are more than one physical GOP devices
2783 CurrentGraphicsOutputMode
->MaxMode
= (UINT32
) (((UINTN
) MatchedMode
- (UINTN
) ModeBuffer
) / sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
));
2784 CurrentGraphicsOutputMode
->Info
->PixelFormat
= PixelBltOnly
;
2785 ZeroMem (&CurrentGraphicsOutputMode
->Info
->PixelInformation
, sizeof (EFI_PIXEL_BITMASK
));
2786 CurrentGraphicsOutputMode
->SizeOfInfo
= sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
);
2787 CurrentGraphicsOutputMode
->FrameBufferBase
= (EFI_PHYSICAL_ADDRESS
) (UINTN
) NULL
;
2788 CurrentGraphicsOutputMode
->FrameBufferSize
= 0;
2792 // Graphics console driver can ensure the same mode for all GOP devices
2794 for (Index
= 0; Index
< CurrentGraphicsOutputMode
->MaxMode
; Index
++) {
2795 Mode
= &Private
->GraphicsOutputModeBuffer
[Index
];
2796 if ((Mode
->HorizontalResolution
== GraphicsOutput
->Mode
->Info
->HorizontalResolution
) &&
2797 (Mode
->VerticalResolution
== GraphicsOutput
->Mode
->Info
->VerticalResolution
)) {
2798 CurrentIndex
= Index
;
2802 if (Index
>= CurrentGraphicsOutputMode
->MaxMode
) {
2804 // if user defined mode is not found, set to default mode 800x600
2806 for (Index
= 0; Index
< CurrentGraphicsOutputMode
->MaxMode
; Index
++) {
2807 Mode
= &Private
->GraphicsOutputModeBuffer
[Index
];
2808 if ((Mode
->HorizontalResolution
== 800) && (Mode
->VerticalResolution
== 600)) {
2809 CurrentIndex
= Index
;
2815 if (UgaDraw
!= NULL
&& FeaturePcdGet (PcdUgaConsumeSupport
)) {
2817 // Graphics console driver can ensure the same mode for all GOP devices
2818 // so we can get the current mode from this video device
2822 &UgaHorizontalResolution
,
2823 &UgaVerticalResolution
,
2828 CurrentGraphicsOutputMode
->MaxMode
= 1;
2829 Info
= CurrentGraphicsOutputMode
->Info
;
2831 Info
->HorizontalResolution
= UgaHorizontalResolution
;
2832 Info
->VerticalResolution
= UgaVerticalResolution
;
2833 Info
->PixelFormat
= PixelBltOnly
;
2834 Info
->PixelsPerScanLine
= UgaHorizontalResolution
;
2835 CurrentGraphicsOutputMode
->SizeOfInfo
= sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
);
2836 CurrentGraphicsOutputMode
->FrameBufferBase
= (EFI_PHYSICAL_ADDRESS
) (UINTN
) NULL
;
2837 CurrentGraphicsOutputMode
->FrameBufferSize
= 0;
2840 // Update the private mode buffer
2842 CopyMem (&Private
->GraphicsOutputModeBuffer
[0], Info
, sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
));
2845 // Only mode 0 is available to be set
2852 if (GraphicsOutput
!= NULL
) {
2853 Private
->CurrentNumberOfGraphicsOutput
++;
2855 if (UgaDraw
!= NULL
&& FeaturePcdGet (PcdUgaConsumeSupport
)) {
2856 Private
->CurrentNumberOfUgaDraw
++;
2860 // Force GraphicsOutput mode to be set,
2861 // regardless whether the console is in EfiConsoleControlScreenGraphics or EfiConsoleControlScreenText mode
2863 Private
->HardwareNeedsStarting
= TRUE
;
2865 // Current mode number may need update now, so set it to an invalid mode number
2867 CurrentGraphicsOutputMode
->Mode
= 0xffff;
2869 // Graphics console can ensure all GOP devices have the same mode which can be taken as current mode.
2871 Status
= Private
->GraphicsOutput
.SetMode (&Private
->GraphicsOutput
, (UINT32
) CurrentIndex
);
2872 if (EFI_ERROR(Status
)) {
2874 // If user defined mode is not valid for display device, set to the default mode 800x600.
2876 (Private
->GraphicsOutputModeBuffer
[0]).HorizontalResolution
= 800;
2877 (Private
->GraphicsOutputModeBuffer
[0]).VerticalResolution
= 600;
2878 Status
= Private
->GraphicsOutput
.SetMode (&Private
->GraphicsOutput
, 0);
2886 This routine will get the current console mode information (column, row)
2887 from ConsoleOutMode variable and set it; if the variable does not exist,
2888 set to user defined console mode.
2890 @param Private Consplitter Text Out pointer.
2894 ConsplitterSetConsoleOutMode (
2895 IN TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
2906 CONSOLE_OUT_MODE
*ModeInfo
;
2907 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
;
2911 TextOut
= &Private
->TextOut
;
2912 MaxMode
= (UINTN
) (TextOut
->Mode
->MaxMode
);
2913 ModeInfoSize
= sizeof (CONSOLE_OUT_MODE
);
2915 ModeInfo
= AllocateZeroPool (sizeof(CONSOLE_OUT_MODE
));
2916 ASSERT(ModeInfo
!= NULL
);
2918 Status
= gRT
->GetVariable (
2920 &gEfiGenericPlatformVariableGuid
,
2927 // Set to the default mode 80 x 25 required by EFI/UEFI spec;
2928 // user can also define other valid default console mode here.
2930 if (EFI_ERROR(Status
)) {
2931 ModeInfo
->Column
= 80;
2933 Status
= gRT
->SetVariable (
2935 &gEfiGenericPlatformVariableGuid
,
2936 EFI_VARIABLE_BOOTSERVICE_ACCESS
| EFI_VARIABLE_NON_VOLATILE
,
2937 sizeof (CONSOLE_OUT_MODE
),
2942 for (Mode
= 0; Mode
< MaxMode
; Mode
++) {
2943 Status
= TextOut
->QueryMode (TextOut
, Mode
, &Col
, &Row
);
2944 if (!EFI_ERROR(Status
)) {
2945 if (Col
== ModeInfo
->Column
&& Row
== ModeInfo
->Row
) {
2948 if (Col
== 80 && Row
== 25) {
2954 Status
= TextOut
->SetMode (TextOut
, PreferMode
);
2957 // if current mode setting is failed, default 80x25 mode will be set.
2959 if (EFI_ERROR(Status
)) {
2960 Status
= TextOut
->SetMode (TextOut
, BaseMode
);
2961 ASSERT(!EFI_ERROR(Status
));
2963 ModeInfo
->Column
= 80;
2967 // Update ConOutMode variable
2969 Status
= gRT
->SetVariable (
2971 &gEfiGenericPlatformVariableGuid
,
2972 EFI_VARIABLE_BOOTSERVICE_ACCESS
| EFI_VARIABLE_NON_VOLATILE
,
2973 sizeof (CONSOLE_OUT_MODE
),
2978 gBS
->FreePool (ModeInfo
);
2983 Add Text Output Device in Consplitter Text Output list.
2985 @param Private Text Out Splitter pointer.
2986 @param TextOut Simple Text Output protocol pointer.
2987 @param GraphicsOutput Graphics Output protocol pointer.
2988 @param UgaDraw UGA Draw protocol pointer.
2990 @retval EFI_SUCCESS Text Output Device added successfully.
2991 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
2995 ConSplitterTextOutAddDevice (
2996 IN TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
,
2997 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
,
2998 IN EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
,
2999 IN EFI_UGA_DRAW_PROTOCOL
*UgaDraw
3003 UINTN CurrentNumOfConsoles
;
3006 UINT32 UgaHorizontalResolution
;
3007 UINT32 UgaVerticalResolution
;
3008 UINT32 UgaColorDepth
;
3009 UINT32 UgaRefreshRate
;
3010 TEXT_OUT_AND_GOP_DATA
*TextAndGop
;
3012 Status
= EFI_SUCCESS
;
3013 CurrentNumOfConsoles
= Private
->CurrentNumberOfConsoles
;
3016 // If the Text Out List is full, enlarge it by calling ConSplitterGrowBuffer().
3018 while (CurrentNumOfConsoles
>= Private
->TextOutListCount
) {
3019 Status
= ConSplitterGrowBuffer (
3020 sizeof (TEXT_OUT_AND_GOP_DATA
),
3021 &Private
->TextOutListCount
,
3022 (VOID
**) &Private
->TextOutList
3024 if (EFI_ERROR (Status
)) {
3025 return EFI_OUT_OF_RESOURCES
;
3028 // Also need to reallocate the TextOutModeMap table
3030 Status
= ConSplitterGrowMapTable (Private
);
3031 if (EFI_ERROR (Status
)) {
3032 return EFI_OUT_OF_RESOURCES
;
3036 TextAndGop
= &Private
->TextOutList
[CurrentNumOfConsoles
];
3038 TextAndGop
->TextOut
= TextOut
;
3039 TextAndGop
->GraphicsOutput
= GraphicsOutput
;
3040 TextAndGop
->UgaDraw
= UgaDraw
;
3042 if ((GraphicsOutput
== NULL
) && (UgaDraw
== NULL
)) {
3044 // If No GOP/UGA device then use the ConOut device
3046 TextAndGop
->TextOutEnabled
= TRUE
;
3049 // If GOP/UGA device use ConOut device only used if screen is in Text mode
3051 TextAndGop
->TextOutEnabled
= (BOOLEAN
) (Private
->ConsoleOutputMode
== EfiConsoleControlScreenText
);
3054 if (CurrentNumOfConsoles
== 0) {
3056 // Add the first device's output mode to console splitter's mode list
3058 Status
= ConSplitterAddOutputMode (Private
, TextOut
);
3060 ConSplitterSyncOutputMode (Private
, TextOut
);
3063 Private
->CurrentNumberOfConsoles
++;
3066 // Scan both TextOutList, for the intersection TextOut device
3067 // maybe both ConOut and StdErr incorporate the same Text Out
3068 // device in them, thus the output of both should be synced.
3070 ConSplitterGetIntersectionBetweenConOutAndStrErr ();
3072 CurrentMode
= Private
->TextOutMode
.Mode
;
3073 MaxMode
= Private
->TextOutMode
.MaxMode
;
3074 ASSERT (MaxMode
>= 1);
3077 // Update DevNull mode according to current video device
3079 if (FeaturePcdGet (PcdConOutGopSupport
)) {
3080 if ((GraphicsOutput
!= NULL
) || (UgaDraw
!= NULL
)) {
3081 ConSplitterAddDisplayOutputMode (Private
, GraphicsOutput
, UgaDraw
);
3084 if (FeaturePcdGet (PcdConOutUgaSupport
)) {
3085 if (UgaDraw
!= NULL
&& FeaturePcdGet (PcdUgaConsumeSupport
)) {
3086 Status
= UgaDraw
->GetMode (
3088 &UgaHorizontalResolution
,
3089 &UgaVerticalResolution
,
3093 if (!EFI_ERROR (Status
)) {
3094 Status
= ConSpliterUgaDrawSetMode (
3096 UgaHorizontalResolution
,
3097 UgaVerticalResolution
,
3103 // If GetMode/SetMode is failed, set to 800x600 mode
3105 if(EFI_ERROR (Status
)) {
3106 Status
= ConSpliterUgaDrawSetMode (
3117 if (Private
->ConsoleOutputMode
== EfiConsoleControlScreenGraphics
&& GraphicsOutput
!= NULL
) {
3119 // We just added a new GOP or UGA device in graphics mode
3121 if (FeaturePcdGet (PcdConOutGopSupport
)) {
3122 DevNullGopSync (Private
, TextAndGop
->GraphicsOutput
, TextAndGop
->UgaDraw
);
3123 } else if (FeaturePcdGet (PcdConOutUgaSupport
)) {
3124 DevNullUgaSync (Private
, TextAndGop
->GraphicsOutput
, TextAndGop
->UgaDraw
);
3126 } else if ((CurrentMode
>= 0) && ((GraphicsOutput
!= NULL
) || (UgaDraw
!= NULL
)) && (CurrentMode
< Private
->TextOutMode
.MaxMode
)) {
3128 // The new console supports the same mode of the current console so sync up
3130 DevNullSyncStdOut (Private
);
3133 // If ConOut, then set the mode to Mode #0 which us 80 x 25
3135 Private
->TextOut
.SetMode (&Private
->TextOut
, 0);
3139 // After adding new console device, all existing console devices should be
3140 // synced to the current shared mode.
3142 ConsplitterSetConsoleOutMode (Private
);
3149 Remove Text Out Device in Consplitter Text Out list.
3151 @param Private Text Out Splitter pointer.
3152 @param TextOut Simple Text Output Pointer protocol pointer.
3154 @retval EFI_SUCCESS Text Out Device removed successfully.
3155 @retval EFI_NOT_FOUND No Text Out Device found.
3159 ConSplitterTextOutDeleteDevice (
3160 IN TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
,
3161 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
3165 UINTN CurrentNumOfConsoles
;
3166 TEXT_OUT_AND_GOP_DATA
*TextOutList
;
3170 // Remove the specified text-out device data structure from the Text out List,
3171 // and rearrange the remaining data structures in the Text out List.
3173 CurrentNumOfConsoles
= Private
->CurrentNumberOfConsoles
;
3174 Index
= (INT32
) CurrentNumOfConsoles
- 1;
3175 TextOutList
= Private
->TextOutList
;
3176 while (Index
>= 0) {
3177 if (TextOutList
->TextOut
== TextOut
) {
3178 CopyMem (TextOutList
, TextOutList
+ 1, sizeof (TEXT_OUT_AND_GOP_DATA
) * Index
);
3179 CurrentNumOfConsoles
--;
3180 if (TextOutList
->UgaDraw
!= NULL
&& FeaturePcdGet (PcdUgaConsumeSupport
)) {
3181 Private
->CurrentNumberOfUgaDraw
--;
3183 if (TextOutList
->GraphicsOutput
!= NULL
) {
3184 Private
->CurrentNumberOfGraphicsOutput
--;
3193 // The specified TextOut is not managed by the ConSplitter driver
3196 return EFI_NOT_FOUND
;
3199 if (CurrentNumOfConsoles
== 0) {
3201 // If the number of consoles is zero clear the Dev NULL device
3203 Private
->CurrentNumberOfConsoles
= 0;
3204 Private
->TextOutMode
.MaxMode
= 1;
3205 Private
->TextOutQueryData
[0].Columns
= 80;
3206 Private
->TextOutQueryData
[0].Rows
= 25;
3207 DevNullTextOutSetMode (Private
, 0);
3212 // Max Mode is realy an intersection of the QueryMode command to all
3213 // devices. So we must copy the QueryMode of the first device to
3217 Private
->TextOutQueryData
,
3218 Private
->TextOutQueryDataCount
* sizeof (TEXT_OUT_SPLITTER_QUERY_DATA
)
3221 FreePool (Private
->TextOutModeMap
);
3222 Private
->TextOutModeMap
= NULL
;
3223 TextOutList
= Private
->TextOutList
;
3226 // Add the first TextOut to the QueryData array and ModeMap table
3228 Status
= ConSplitterAddOutputMode (Private
, TextOutList
->TextOut
);
3231 // Now add one by one
3234 Private
->CurrentNumberOfConsoles
= 1;
3236 while ((UINTN
) Index
< CurrentNumOfConsoles
) {
3237 ConSplitterSyncOutputMode (Private
, TextOutList
->TextOut
);
3239 Private
->CurrentNumberOfConsoles
++;
3243 ConSplitterGetIntersectionBetweenConOutAndStrErr ();
3250 Reset the input device and optionaly run diagnostics
3252 @param This Protocol instance pointer.
3253 @param ExtendedVerification Driver may perform diagnostics on reset.
3255 @retval EFI_SUCCESS The device was reset.
3256 @retval EFI_DEVICE_ERROR The device is not functioning properly and could
3262 ConSplitterTextInReset (
3263 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*This
,
3264 IN BOOLEAN ExtendedVerification
3268 EFI_STATUS ReturnStatus
;
3269 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3272 Private
= TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
3274 Private
->KeyEventSignalState
= FALSE
;
3277 // return the worst status met
3279 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
3280 Status
= Private
->TextInList
[Index
]->Reset (
3281 Private
->TextInList
[Index
],
3282 ExtendedVerification
3284 if (EFI_ERROR (Status
)) {
3285 ReturnStatus
= Status
;
3289 return ReturnStatus
;
3294 Reads the next keystroke from the input device. The WaitForKey Event can
3295 be used to test for existance of a keystroke via WaitForEvent () call.
3297 @param Private Protocol instance pointer.
3298 @param Key Driver may perform diagnostics on reset.
3300 @retval EFI_SUCCESS The keystroke information was returned.
3301 @retval EFI_NOT_READY There was no keystroke data availiable.
3302 @retval EFI_DEVICE_ERROR The keydtroke information was not returned due
3308 ConSplitterTextInPrivateReadKeyStroke (
3309 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
3310 OUT EFI_INPUT_KEY
*Key
3315 EFI_INPUT_KEY CurrentKey
;
3317 Key
->UnicodeChar
= 0;
3318 Key
->ScanCode
= SCAN_NULL
;
3321 // if no physical console input device exists, return EFI_NOT_READY;
3322 // if any physical console input device has key input,
3323 // return the key and EFI_SUCCESS.
3325 for (Index
= 0; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
3326 Status
= Private
->TextInList
[Index
]->ReadKeyStroke (
3327 Private
->TextInList
[Index
],
3330 if (!EFI_ERROR (Status
)) {
3336 return EFI_NOT_READY
;
3340 Return TRUE if StdIn is locked. The ConIn device on the virtual handle is
3341 the only device locked.
3343 @retval TRUE StdIn locked
3344 @retval FALSE StdIn working normally
3348 ConSpliterConssoleControlStdInLocked (
3352 return mConIn
.PasswordEnabled
;
3357 This timer event will fire when StdIn is locked. It will check the key
3358 sequence on StdIn to see if it matches the password. Any error in the
3359 password will cause the check to reset. As long a mConIn.PasswordEnabled is
3360 TRUE the StdIn splitter will not report any input.
3362 @param Event The Event this notify function registered to.
3363 @param Context Pointer to the context data registerd to the
3368 ConSpliterConsoleControlLockStdInEvent (
3375 CHAR16 BackSpaceString
[2];
3376 CHAR16 SpaceString
[2];
3379 Status
= ConSplitterTextInPrivateReadKeyStroke (&mConIn
, &Key
);
3380 if (!EFI_ERROR (Status
)) {
3382 // if it's an ENTER, match password
3384 if ((Key
.UnicodeChar
== CHAR_CARRIAGE_RETURN
) && (Key
.ScanCode
== SCAN_NULL
)) {
3385 mConIn
.PwdAttempt
[mConIn
.PwdIndex
] = CHAR_NULL
;
3386 if (StrCmp (mConIn
.Password
, mConIn
.PwdAttempt
)) {
3388 // Password not match
3390 ConSplitterTextOutOutputString (&mConOut
.TextOut
, (CHAR16
*) L
"\n\rPassword not correct\n\r");
3391 mConIn
.PwdIndex
= 0;
3394 // Key matches password sequence
3396 gBS
->SetTimer (mConIn
.LockEvent
, TimerPeriodic
, 0);
3397 mConIn
.PasswordEnabled
= FALSE
;
3398 Status
= EFI_NOT_READY
;
3400 } else if ((Key
.UnicodeChar
== CHAR_BACKSPACE
) && (Key
.ScanCode
== SCAN_NULL
)) {
3404 if (mConIn
.PwdIndex
> 0) {
3405 BackSpaceString
[0] = CHAR_BACKSPACE
;
3406 BackSpaceString
[1] = 0;
3408 SpaceString
[0] = L
' ';
3411 ConSplitterTextOutOutputString (&mConOut
.TextOut
, BackSpaceString
);
3412 ConSplitterTextOutOutputString (&mConOut
.TextOut
, SpaceString
);
3413 ConSplitterTextOutOutputString (&mConOut
.TextOut
, BackSpaceString
);
3417 } else if ((Key
.ScanCode
== SCAN_NULL
) && (Key
.UnicodeChar
>= 32)) {
3419 // If it's not an ENTER, neigher a function key, nor a CTRL-X or ALT-X, record the input
3421 if (mConIn
.PwdIndex
< (MAX_STD_IN_PASSWORD
- 1)) {
3422 if (mConIn
.PwdIndex
== 0) {
3423 ConSplitterTextOutOutputString (&mConOut
.TextOut
, (CHAR16
*) L
"\n\r");
3426 ConSplitterTextOutOutputString (&mConOut
.TextOut
, (CHAR16
*) L
"*");
3427 mConIn
.PwdAttempt
[mConIn
.PwdIndex
] = Key
.UnicodeChar
;
3432 } while (!EFI_ERROR (Status
));
3437 If Password is NULL or the Password is too big, then return an error. If the
3438 Password is valid, then store the password, lock StdIn and arm the periodic timer.
3440 @param This Console Control protocol pointer.
3441 @param Password The password input.
3443 @retval EFI_SUCCESS Lock the StdIn device
3444 @retval EFI_INVALID_PARAMETER Password is NULL
3445 @retval EFI_OUT_OF_RESOURCES Buffer allocation to store the password fails
3450 ConSpliterConsoleControlLockStdIn (
3451 IN EFI_CONSOLE_CONTROL_PROTOCOL
*This
,
3455 if (Password
== NULL
) {
3456 return EFI_INVALID_PARAMETER
;
3459 if (StrLen (Password
) >= MAX_STD_IN_PASSWORD
) {
3461 // Currently have a max password size
3463 return EFI_OUT_OF_RESOURCES
;
3466 // Save the password, initialize state variables and arm event timer
3468 StrCpy (mConIn
.Password
, Password
);
3469 mConIn
.PasswordEnabled
= TRUE
;
3470 mConIn
.PwdIndex
= 0;
3471 gBS
->SetTimer (mConIn
.LockEvent
, TimerPeriodic
, (10000 * 25));
3478 Reads the next keystroke from the input device. The WaitForKey Event can
3479 be used to test for existance of a keystroke via WaitForEvent () call.
3480 If the ConIn is password locked make it look like no keystroke is availible
3482 @param This Protocol instance pointer.
3483 @param Key Driver may perform diagnostics on reset.
3485 @retval EFI_SUCCESS The keystroke information was returned.
3486 @retval EFI_NOT_READY There was no keystroke data availiable.
3487 @retval EFI_DEVICE_ERROR The keydtroke information was not returned due
3493 ConSplitterTextInReadKeyStroke (
3494 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*This
,
3495 OUT EFI_INPUT_KEY
*Key
3498 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3500 Private
= TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
3501 if (Private
->PasswordEnabled
) {
3503 // If StdIn Locked return not ready
3505 return EFI_NOT_READY
;
3508 Private
->KeyEventSignalState
= FALSE
;
3510 return ConSplitterTextInPrivateReadKeyStroke (Private
, Key
);
3515 This event agregates all the events of the ConIn devices in the spliter.
3516 If the ConIn is password locked then return.
3517 If any events of physical ConIn devices are signaled, signal the ConIn
3518 spliter event. This will cause the calling code to call
3519 ConSplitterTextInReadKeyStroke ().
3521 @param Event The Event assoicated with callback.
3522 @param Context Context registered when Event was created.
3527 ConSplitterTextInWaitForKey (
3533 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3536 Private
= (TEXT_IN_SPLITTER_PRIVATE_DATA
*) Context
;
3537 if (Private
->PasswordEnabled
) {
3539 // If StdIn Locked return not ready
3545 // if KeyEventSignalState is flagged before, and not cleared by Reset() or ReadKeyStroke()
3547 if (Private
->KeyEventSignalState
) {
3548 gBS
->SignalEvent (Event
);
3552 // if any physical console input device has key input, signal the event.
3554 for (Index
= 0; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
3555 Status
= gBS
->CheckEvent (Private
->TextInList
[Index
]->WaitForKey
);
3556 if (!EFI_ERROR (Status
)) {
3557 gBS
->SignalEvent (Event
);
3558 Private
->KeyEventSignalState
= TRUE
;
3566 Test if the key has been registered on input device.
3568 @param RegsiteredData A pointer to a buffer that is filled in with the
3569 keystroke state data for the key that was
3571 @param InputData A pointer to a buffer that is filled in with the
3572 keystroke state data for the key that was
3575 @retval TRUE Key be pressed matches a registered key.
3576 @retval FLASE Match failed.
3581 IN EFI_KEY_DATA
*RegsiteredData
,
3582 IN EFI_KEY_DATA
*InputData
3585 ASSERT (RegsiteredData
!= NULL
&& InputData
!= NULL
);
3587 if ((RegsiteredData
->Key
.ScanCode
!= InputData
->Key
.ScanCode
) ||
3588 (RegsiteredData
->Key
.UnicodeChar
!= InputData
->Key
.UnicodeChar
)) {
3593 // Assume KeyShiftState/KeyToggleState = 0 in Registered key data means these state could be ignored.
3595 if (RegsiteredData
->KeyState
.KeyShiftState
!= 0 &&
3596 RegsiteredData
->KeyState
.KeyShiftState
!= InputData
->KeyState
.KeyShiftState
) {
3599 if (RegsiteredData
->KeyState
.KeyToggleState
!= 0 &&
3600 RegsiteredData
->KeyState
.KeyToggleState
!= InputData
->KeyState
.KeyToggleState
) {
3610 Reset the input device and optionaly run diagnostics
3612 @param This Protocol instance pointer.
3613 @param ExtendedVerification Driver may perform diagnostics on reset.
3615 @retval EFI_SUCCESS The device was reset.
3616 @retval EFI_DEVICE_ERROR The device is not functioning properly and could
3622 ConSplitterTextInResetEx (
3623 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*This
,
3624 IN BOOLEAN ExtendedVerification
3628 EFI_STATUS ReturnStatus
;
3629 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3632 Private
= TEXT_IN_EX_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
3634 Private
->KeyEventSignalState
= FALSE
;
3637 // return the worst status met
3639 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfExConsoles
; Index
++) {
3640 Status
= Private
->TextInExList
[Index
]->Reset (
3641 Private
->TextInExList
[Index
],
3642 ExtendedVerification
3644 if (EFI_ERROR (Status
)) {
3645 ReturnStatus
= Status
;
3649 return ReturnStatus
;
3655 Reads the next keystroke from the input device. The WaitForKey Event can
3656 be used to test for existance of a keystroke via WaitForEvent () call.
3658 @param This Protocol instance pointer.
3659 @param KeyData A pointer to a buffer that is filled in with the
3660 keystroke state data for the key that was
3663 @retval EFI_SUCCESS The keystroke information was returned.
3664 @retval EFI_NOT_READY There was no keystroke data availiable.
3665 @retval EFI_DEVICE_ERROR The keystroke information was not returned due
3667 @retval EFI_INVALID_PARAMETER KeyData is NULL.
3672 ConSplitterTextInReadKeyStrokeEx (
3673 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*This
,
3674 OUT EFI_KEY_DATA
*KeyData
3677 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3680 EFI_KEY_DATA CurrentKeyData
;
3683 if (KeyData
== NULL
) {
3684 return EFI_INVALID_PARAMETER
;
3687 Private
= TEXT_IN_EX_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
3688 if (Private
->PasswordEnabled
) {
3690 // If StdIn Locked return not ready
3692 return EFI_NOT_READY
;
3695 Private
->KeyEventSignalState
= FALSE
;
3697 KeyData
->Key
.UnicodeChar
= 0;
3698 KeyData
->Key
.ScanCode
= SCAN_NULL
;
3701 // if no physical console input device exists, return EFI_NOT_READY;
3702 // if any physical console input device has key input,
3703 // return the key and EFI_SUCCESS.
3705 for (Index
= 0; Index
< Private
->CurrentNumberOfExConsoles
; Index
++) {
3706 Status
= Private
->TextInExList
[Index
]->ReadKeyStrokeEx (
3707 Private
->TextInExList
[Index
],
3710 if (!EFI_ERROR (Status
)) {
3711 CopyMem (KeyData
, &CurrentKeyData
, sizeof (CurrentKeyData
));
3716 return EFI_NOT_READY
;
3721 Set certain state for the input device.
3723 @param This Protocol instance pointer.
3724 @param KeyToggleState A pointer to the EFI_KEY_TOGGLE_STATE to set the
3725 state for the input device.
3727 @retval EFI_SUCCESS The device state was set successfully.
3728 @retval EFI_DEVICE_ERROR The device is not functioning correctly and
3729 could not have the setting adjusted.
3730 @retval EFI_UNSUPPORTED The device does not have the ability to set its
3732 @retval EFI_INVALID_PARAMETER KeyToggleState is NULL.
3737 ConSplitterTextInSetState (
3738 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*This
,
3739 IN EFI_KEY_TOGGLE_STATE
*KeyToggleState
3742 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3746 if (KeyToggleState
== NULL
) {
3747 return EFI_INVALID_PARAMETER
;
3750 Private
= TEXT_IN_EX_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
3753 // if no physical console input device exists, return EFI_SUCCESS;
3754 // otherwise return the status of setting state of physical console input device
3756 for (Index
= 0; Index
< Private
->CurrentNumberOfExConsoles
; Index
++) {
3757 Status
= Private
->TextInExList
[Index
]->SetState (
3758 Private
->TextInExList
[Index
],
3761 if (EFI_ERROR (Status
)) {
3772 Register a notification function for a particular keystroke for the input device.
3774 @param This Protocol instance pointer.
3775 @param KeyData A pointer to a buffer that is filled in with the
3776 keystroke information data for the key that was
3778 @param KeyNotificationFunction Points to the function to be called when the key
3779 sequence is typed specified by KeyData.
3780 @param NotifyHandle Points to the unique handle assigned to the
3781 registered notification.
3783 @retval EFI_SUCCESS The notification function was registered
3785 @retval EFI_OUT_OF_RESOURCES Unable to allocate resources for necesssary data
3787 @retval EFI_INVALID_PARAMETER KeyData or NotifyHandle is NULL.
3792 ConSplitterTextInRegisterKeyNotify (
3793 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*This
,
3794 IN EFI_KEY_DATA
*KeyData
,
3795 IN EFI_KEY_NOTIFY_FUNCTION KeyNotificationFunction
,
3796 OUT EFI_HANDLE
*NotifyHandle
3799 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3802 TEXT_IN_EX_SPLITTER_NOTIFY
*NewNotify
;
3804 TEXT_IN_EX_SPLITTER_NOTIFY
*CurrentNotify
;
3807 if (KeyData
== NULL
|| NotifyHandle
== NULL
|| KeyNotificationFunction
== NULL
) {
3808 return EFI_INVALID_PARAMETER
;
3811 Private
= TEXT_IN_EX_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
3814 // if no physical console input device exists,
3815 // return EFI_SUCCESS directly.
3817 if (Private
->CurrentNumberOfExConsoles
<= 0) {
3822 // Return EFI_SUCCESS if the (KeyData, NotificationFunction) is already registered.
3824 for (Link
= Private
->NotifyList
.ForwardLink
; Link
!= &Private
->NotifyList
; Link
= Link
->ForwardLink
) {
3825 CurrentNotify
= TEXT_IN_EX_SPLITTER_NOTIFY_FROM_THIS (Link
);
3826 if (IsKeyRegistered (&CurrentNotify
->KeyData
, KeyData
)) {
3827 if (CurrentNotify
->KeyNotificationFn
== KeyNotificationFunction
) {
3828 *NotifyHandle
= CurrentNotify
->NotifyHandle
;
3835 // Allocate resource to save the notification function
3837 NewNotify
= (TEXT_IN_EX_SPLITTER_NOTIFY
*) AllocateZeroPool (sizeof (TEXT_IN_EX_SPLITTER_NOTIFY
));
3838 if (NewNotify
== NULL
) {
3839 return EFI_OUT_OF_RESOURCES
;
3841 NewNotify
->NotifyHandleList
= (EFI_HANDLE
*) AllocateZeroPool (sizeof (EFI_HANDLE
) * Private
->CurrentNumberOfExConsoles
);
3842 if (NewNotify
->NotifyHandleList
== NULL
) {
3843 gBS
->FreePool (NewNotify
);
3844 return EFI_OUT_OF_RESOURCES
;
3846 NewNotify
->Signature
= TEXT_IN_EX_SPLITTER_NOTIFY_SIGNATURE
;
3847 NewNotify
->KeyNotificationFn
= KeyNotificationFunction
;
3848 CopyMem (&NewNotify
->KeyData
, KeyData
, sizeof (KeyData
));
3851 // Return the wrong status of registering key notify of
3852 // physical console input device if meet problems
3854 for (Index
= 0; Index
< Private
->CurrentNumberOfExConsoles
; Index
++) {
3855 Status
= Private
->TextInExList
[Index
]->RegisterKeyNotify (
3856 Private
->TextInExList
[Index
],
3858 KeyNotificationFunction
,
3859 &NewNotify
->NotifyHandleList
[Index
]
3861 if (EFI_ERROR (Status
)) {
3862 gBS
->FreePool (NewNotify
->NotifyHandleList
);
3863 gBS
->FreePool (NewNotify
);
3869 // Use gSimpleTextInExNotifyGuid to get a valid EFI_HANDLE
3871 Status
= gBS
->InstallMultipleProtocolInterfaces (
3872 &NewNotify
->NotifyHandle
,
3873 &gSimpleTextInExNotifyGuid
,
3877 ASSERT_EFI_ERROR (Status
);
3879 InsertTailList (&mConIn
.NotifyList
, &NewNotify
->NotifyEntry
);
3881 *NotifyHandle
= NewNotify
->NotifyHandle
;
3889 Remove a registered notification function from a particular keystroke.
3891 @param This Protocol instance pointer.
3892 @param NotificationHandle The handle of the notification function being
3895 @retval EFI_SUCCESS The notification function was unregistered
3897 @retval EFI_INVALID_PARAMETER The NotificationHandle is invalid.
3898 @retval EFI_NOT_FOUND Can not find the matching entry in database.
3903 ConSplitterTextInUnregisterKeyNotify (
3904 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*This
,
3905 IN EFI_HANDLE NotificationHandle
3908 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3911 TEXT_IN_EX_SPLITTER_NOTIFY
*CurrentNotify
;
3914 if (NotificationHandle
== NULL
) {
3915 return EFI_INVALID_PARAMETER
;
3918 Status
= gBS
->OpenProtocol (
3920 &gSimpleTextInExNotifyGuid
,
3924 EFI_OPEN_PROTOCOL_TEST_PROTOCOL
3926 if (EFI_ERROR (Status
)) {
3927 return EFI_INVALID_PARAMETER
;
3930 Private
= TEXT_IN_EX_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
3933 // if no physical console input device exists,
3934 // return EFI_SUCCESS directly.
3936 if (Private
->CurrentNumberOfExConsoles
<= 0) {
3940 for (Link
= Private
->NotifyList
.ForwardLink
; Link
!= &Private
->NotifyList
; Link
= Link
->ForwardLink
) {
3941 CurrentNotify
= TEXT_IN_EX_SPLITTER_NOTIFY_FROM_THIS (Link
);
3942 if (CurrentNotify
->NotifyHandle
== NotificationHandle
) {
3943 for (Index
= 0; Index
< Private
->CurrentNumberOfExConsoles
; Index
++) {
3944 Status
= Private
->TextInExList
[Index
]->UnregisterKeyNotify (
3945 Private
->TextInExList
[Index
],
3946 CurrentNotify
->NotifyHandleList
[Index
]
3948 if (EFI_ERROR (Status
)) {
3952 RemoveEntryList (&CurrentNotify
->NotifyEntry
);
3953 Status
= gBS
->UninstallMultipleProtocolInterfaces (
3954 CurrentNotify
->NotifyHandle
,
3955 &gSimpleTextInExNotifyGuid
,
3959 ASSERT_EFI_ERROR (Status
);
3960 gBS
->FreePool (CurrentNotify
->NotifyHandleList
);
3961 gBS
->FreePool (CurrentNotify
);
3966 return EFI_NOT_FOUND
;
3972 Reset the input device and optionaly run diagnostics
3974 @param This Protocol instance pointer.
3975 @param ExtendedVerification Driver may perform diagnostics on reset.
3977 @retval EFI_SUCCESS The device was reset.
3978 @retval EFI_DEVICE_ERROR The device is not functioning properly and could
3984 ConSplitterSimplePointerReset (
3985 IN EFI_SIMPLE_POINTER_PROTOCOL
*This
,
3986 IN BOOLEAN ExtendedVerification
3990 EFI_STATUS ReturnStatus
;
3991 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3994 Private
= TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_SIMPLE_POINTER_THIS (This
);
3996 Private
->InputEventSignalState
= FALSE
;
3998 if (Private
->CurrentNumberOfPointers
== 0) {
4002 // return the worst status met
4004 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfPointers
; Index
++) {
4005 Status
= Private
->PointerList
[Index
]->Reset (
4006 Private
->PointerList
[Index
],
4007 ExtendedVerification
4009 if (EFI_ERROR (Status
)) {
4010 ReturnStatus
= Status
;
4014 return ReturnStatus
;
4019 Reads the next keystroke from the input device. The WaitForKey Event can
4020 be used to test for existance of a keystroke via WaitForEvent () call.
4022 @param Private Protocol instance pointer.
4023 @param State The state information of simple pointer device.
4025 @retval EFI_SUCCESS The keystroke information was returned.
4026 @retval EFI_NOT_READY There was no keystroke data availiable.
4027 @retval EFI_DEVICE_ERROR The keydtroke information was not returned due
4033 ConSplitterSimplePointerPrivateGetState (
4034 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
4035 IN OUT EFI_SIMPLE_POINTER_STATE
*State
4039 EFI_STATUS ReturnStatus
;
4041 EFI_SIMPLE_POINTER_STATE CurrentState
;
4043 State
->RelativeMovementX
= 0;
4044 State
->RelativeMovementY
= 0;
4045 State
->RelativeMovementZ
= 0;
4046 State
->LeftButton
= FALSE
;
4047 State
->RightButton
= FALSE
;
4050 // if no physical console input device exists, return EFI_NOT_READY;
4051 // if any physical console input device has key input,
4052 // return the key and EFI_SUCCESS.
4054 ReturnStatus
= EFI_NOT_READY
;
4055 for (Index
= 0; Index
< Private
->CurrentNumberOfPointers
; Index
++) {
4057 Status
= Private
->PointerList
[Index
]->GetState (
4058 Private
->PointerList
[Index
],
4061 if (!EFI_ERROR (Status
)) {
4062 if (ReturnStatus
== EFI_NOT_READY
) {
4063 ReturnStatus
= EFI_SUCCESS
;
4066 if (CurrentState
.LeftButton
) {
4067 State
->LeftButton
= TRUE
;
4070 if (CurrentState
.RightButton
) {
4071 State
->RightButton
= TRUE
;
4074 if (CurrentState
.RelativeMovementX
!= 0 && Private
->PointerList
[Index
]->Mode
->ResolutionX
!= 0) {
4075 State
->RelativeMovementX
+= (CurrentState
.RelativeMovementX
* (INT32
) Private
->SimplePointerMode
.ResolutionX
) / (INT32
) Private
->PointerList
[Index
]->Mode
->ResolutionX
;
4078 if (CurrentState
.RelativeMovementY
!= 0 && Private
->PointerList
[Index
]->Mode
->ResolutionY
!= 0) {
4079 State
->RelativeMovementY
+= (CurrentState
.RelativeMovementY
* (INT32
) Private
->SimplePointerMode
.ResolutionY
) / (INT32
) Private
->PointerList
[Index
]->Mode
->ResolutionY
;
4082 if (CurrentState
.RelativeMovementZ
!= 0 && Private
->PointerList
[Index
]->Mode
->ResolutionZ
!= 0) {
4083 State
->RelativeMovementZ
+= (CurrentState
.RelativeMovementZ
* (INT32
) Private
->SimplePointerMode
.ResolutionZ
) / (INT32
) Private
->PointerList
[Index
]->Mode
->ResolutionZ
;
4085 } else if (Status
== EFI_DEVICE_ERROR
) {
4086 ReturnStatus
= EFI_DEVICE_ERROR
;
4090 return ReturnStatus
;
4095 Reads the next keystroke from the input device. The WaitForKey Event can
4096 be used to test for existance of a keystroke via WaitForEvent () call.
4097 If the ConIn is password locked make it look like no keystroke is availible
4099 @param This A pointer to protocol instance.
4100 @param State A pointer to state information on the pointer device
4102 @retval EFI_SUCCESS The keystroke information was returned in State.
4103 @retval EFI_NOT_READY There was no keystroke data availiable.
4104 @retval EFI_DEVICE_ERROR The keydtroke information was not returned due
4110 ConSplitterSimplePointerGetState (
4111 IN EFI_SIMPLE_POINTER_PROTOCOL
*This
,
4112 IN OUT EFI_SIMPLE_POINTER_STATE
*State
4115 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
4117 Private
= TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_SIMPLE_POINTER_THIS (This
);
4118 if (Private
->PasswordEnabled
) {
4120 // If StdIn Locked return not ready
4122 return EFI_NOT_READY
;
4125 Private
->InputEventSignalState
= FALSE
;
4127 return ConSplitterSimplePointerPrivateGetState (Private
, State
);
4132 This event agregates all the events of the ConIn devices in the spliter.
4133 If the ConIn is password locked then return.
4134 If any events of physical ConIn devices are signaled, signal the ConIn
4135 spliter event. This will cause the calling code to call
4136 ConSplitterTextInReadKeyStroke ().
4138 @param Event The Event assoicated with callback.
4139 @param Context Context registered when Event was created.
4144 ConSplitterSimplePointerWaitForInput (
4150 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
4153 Private
= (TEXT_IN_SPLITTER_PRIVATE_DATA
*) Context
;
4154 if (Private
->PasswordEnabled
) {
4156 // If StdIn Locked return not ready
4162 // if InputEventSignalState is flagged before, and not cleared by Reset() or ReadKeyStroke()
4164 if (Private
->InputEventSignalState
) {
4165 gBS
->SignalEvent (Event
);
4169 // if any physical console input device has key input, signal the event.
4171 for (Index
= 0; Index
< Private
->CurrentNumberOfPointers
; Index
++) {
4172 Status
= gBS
->CheckEvent (Private
->PointerList
[Index
]->WaitForInput
);
4173 if (!EFI_ERROR (Status
)) {
4174 gBS
->SignalEvent (Event
);
4175 Private
->InputEventSignalState
= TRUE
;
4181 Resets the pointer device hardware.
4183 @param This Protocol instance pointer.
4184 @param ExtendedVerification Driver may perform diagnostics on reset.
4186 @retval EFI_SUCCESS The device was reset.
4187 @retval EFI_DEVICE_ERROR The device is not functioning correctly and
4193 ConSplitterAbsolutePointerReset (
4194 IN EFI_ABSOLUTE_POINTER_PROTOCOL
*This
,
4195 IN BOOLEAN ExtendedVerification
4199 EFI_STATUS ReturnStatus
;
4200 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
4203 Private
= TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_ABSOLUTE_POINTER_THIS (This
);
4205 Private
->AbsoluteInputEventSignalState
= FALSE
;
4207 if (Private
->CurrentNumberOfAbsolutePointers
== 0) {
4211 // return the worst status met
4213 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfAbsolutePointers
; Index
++) {
4214 Status
= Private
->AbsolutePointerList
[Index
]->Reset (
4215 Private
->AbsolutePointerList
[Index
],
4216 ExtendedVerification
4218 if (EFI_ERROR (Status
)) {
4219 ReturnStatus
= Status
;
4223 return ReturnStatus
;
4228 Retrieves the current state of a pointer device.
4230 @param This Protocol instance pointer.
4231 @param State A pointer to the state information on the
4234 @retval EFI_SUCCESS The state of the pointer device was returned in
4236 @retval EFI_NOT_READY The state of the pointer device has not changed
4237 since the last call to GetState().
4238 @retval EFI_DEVICE_ERROR A device error occurred while attempting to
4239 retrieve the pointer device's current state.
4244 ConSplitterAbsolutePointerGetState (
4245 IN EFI_ABSOLUTE_POINTER_PROTOCOL
*This
,
4246 IN OUT EFI_ABSOLUTE_POINTER_STATE
*State
4249 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
4251 EFI_STATUS ReturnStatus
;
4253 EFI_ABSOLUTE_POINTER_STATE CurrentState
;
4256 Private
= TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_ABSOLUTE_POINTER_THIS (This
);
4257 if (Private
->PasswordEnabled
) {
4259 // If StdIn Locked return not ready
4261 return EFI_NOT_READY
;
4264 Private
->AbsoluteInputEventSignalState
= FALSE
;
4266 State
->CurrentX
= 0;
4267 State
->CurrentY
= 0;
4268 State
->CurrentZ
= 0;
4269 State
->ActiveButtons
= 0;
4272 // if no physical pointer device exists, return EFI_NOT_READY;
4273 // if any physical pointer device has changed state,
4274 // return the state and EFI_SUCCESS.
4276 ReturnStatus
= EFI_NOT_READY
;
4277 for (Index
= 0; Index
< Private
->CurrentNumberOfAbsolutePointers
; Index
++) {
4279 Status
= Private
->AbsolutePointerList
[Index
]->GetState (
4280 Private
->AbsolutePointerList
[Index
],
4283 if (!EFI_ERROR (Status
)) {
4284 if (ReturnStatus
== EFI_NOT_READY
) {
4285 ReturnStatus
= EFI_SUCCESS
;
4288 State
->ActiveButtons
= CurrentState
.ActiveButtons
;
4290 if (!(Private
->AbsolutePointerMode
.AbsoluteMinX
== 0 && Private
->AbsolutePointerMode
.AbsoluteMaxX
== 0)) {
4291 State
->CurrentX
= CurrentState
.CurrentX
;
4293 if (!(Private
->AbsolutePointerMode
.AbsoluteMinY
== 0 && Private
->AbsolutePointerMode
.AbsoluteMaxY
== 0)) {
4294 State
->CurrentY
= CurrentState
.CurrentY
;
4296 if (!(Private
->AbsolutePointerMode
.AbsoluteMinZ
== 0 && Private
->AbsolutePointerMode
.AbsoluteMaxZ
== 0)) {
4297 State
->CurrentZ
= CurrentState
.CurrentZ
;
4300 } else if (Status
== EFI_DEVICE_ERROR
) {
4301 ReturnStatus
= EFI_DEVICE_ERROR
;
4305 return ReturnStatus
;
4310 This event agregates all the events of the pointer devices in the splitter.
4311 If the ConIn is password locked then return.
4312 If any events of physical pointer devices are signaled, signal the pointer
4313 splitter event. This will cause the calling code to call
4314 ConSplitterAbsolutePointerGetState ().
4316 @param Event The Event assoicated with callback.
4317 @param Context Context registered when Event was created.
4322 ConSplitterAbsolutePointerWaitForInput (
4328 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
4331 Private
= (TEXT_IN_SPLITTER_PRIVATE_DATA
*) Context
;
4332 if (Private
->PasswordEnabled
) {
4334 // If StdIn Locked return not ready
4340 // if AbsoluteInputEventSignalState is flagged before,
4341 // and not cleared by Reset() or GetState(), signal it
4343 if (Private
->AbsoluteInputEventSignalState
) {
4344 gBS
->SignalEvent (Event
);
4348 // if any physical console input device has key input, signal the event.
4350 for (Index
= 0; Index
< Private
->CurrentNumberOfAbsolutePointers
; Index
++) {
4351 Status
= gBS
->CheckEvent (Private
->AbsolutePointerList
[Index
]->WaitForInput
);
4352 if (!EFI_ERROR (Status
)) {
4353 gBS
->SignalEvent (Event
);
4354 Private
->AbsoluteInputEventSignalState
= TRUE
;
4361 Reset the text output device hardware and optionaly run diagnostics
4363 @param This Protocol instance pointer.
4364 @param ExtendedVerification Driver may perform more exhaustive verfication
4365 operation of the device during reset.
4367 @retval EFI_SUCCESS The text output device was reset.
4368 @retval EFI_DEVICE_ERROR The text output device is not functioning
4369 correctly and could not be reset.
4374 ConSplitterTextOutReset (
4375 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4376 IN BOOLEAN ExtendedVerification
4380 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4382 EFI_STATUS ReturnStatus
;
4384 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4387 // return the worst status met
4389 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
4391 if (Private
->TextOutList
[Index
].TextOutEnabled
) {
4393 Status
= Private
->TextOutList
[Index
].TextOut
->Reset (
4394 Private
->TextOutList
[Index
].TextOut
,
4395 ExtendedVerification
4397 if (EFI_ERROR (Status
)) {
4398 ReturnStatus
= Status
;
4403 This
->SetAttribute (This
, EFI_TEXT_ATTR (This
->Mode
->Attribute
& 0x0F, EFI_BLACK
));
4405 Status
= DevNullTextOutSetMode (Private
, 0);
4406 if (EFI_ERROR (Status
)) {
4407 ReturnStatus
= Status
;
4410 return ReturnStatus
;
4415 Write a Unicode string to the output device.
4417 @param This Protocol instance pointer.
4418 @param WString The NULL-terminated Unicode string to be
4419 displayed on the output device(s). All output
4420 devices must also support the Unicode drawing
4421 defined in this file.
4423 @retval EFI_SUCCESS The string was output to the device.
4424 @retval EFI_DEVICE_ERROR The device reported an error while attempting to
4426 @retval EFI_UNSUPPORTED The output device's mode is not currently in a
4428 @retval EFI_WARN_UNKNOWN_GLYPH This warning code indicates that some of the
4429 characters in the Unicode string could not be
4430 rendered and were skipped.
4435 ConSplitterTextOutOutputString (
4436 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4441 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4443 UINTN BackSpaceCount
;
4444 EFI_STATUS ReturnStatus
;
4445 CHAR16
*TargetString
;
4447 This
->SetAttribute (This
, This
->Mode
->Attribute
);
4449 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4452 for (TargetString
= WString
; *TargetString
!= L
'\0'; TargetString
++) {
4453 if (*TargetString
== CHAR_BACKSPACE
) {
4459 if (BackSpaceCount
== 0) {
4460 TargetString
= WString
;
4462 TargetString
= AllocatePool (sizeof (CHAR16
) * (StrLen (WString
) + BackSpaceCount
+ 1));
4463 StrCpy (TargetString
, WString
);
4466 // return the worst status met
4468 Status
= DevNullTextOutOutputString (Private
, TargetString
);
4469 if (EFI_ERROR (Status
)) {
4470 ReturnStatus
= Status
;
4473 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
4475 if (Private
->TextOutList
[Index
].TextOutEnabled
) {
4476 Status
= Private
->TextOutList
[Index
].TextOut
->OutputString (
4477 Private
->TextOutList
[Index
].TextOut
,
4480 if (EFI_ERROR (Status
)) {
4481 ReturnStatus
= Status
;
4486 if (BackSpaceCount
> 0) {
4487 FreePool (TargetString
);
4490 return ReturnStatus
;
4495 Verifies that all characters in a Unicode string can be output to the
4498 @param This Protocol instance pointer.
4499 @param WString The NULL-terminated Unicode string to be
4500 examined for the output device(s).
4502 @retval EFI_SUCCESS The device(s) are capable of rendering the
4504 @retval EFI_UNSUPPORTED Some of the characters in the Unicode string
4505 cannot be rendered by one or more of the output
4506 devices mapped by the EFI handle.
4511 ConSplitterTextOutTestString (
4512 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4517 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4519 EFI_STATUS ReturnStatus
;
4521 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4524 // return the worst status met
4526 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
4527 if (Private
->TextOutList
[Index
].TextOutEnabled
) {
4528 Status
= Private
->TextOutList
[Index
].TextOut
->TestString (
4529 Private
->TextOutList
[Index
].TextOut
,
4532 if (EFI_ERROR (Status
)) {
4533 ReturnStatus
= Status
;
4538 // There is no DevNullTextOutTestString () since a Unicode buffer would
4539 // always return EFI_SUCCESS.
4540 // ReturnStatus will be EFI_SUCCESS if no consoles are present
4542 return ReturnStatus
;
4547 Returns information for an available text mode that the output device(s)
4550 @param This Protocol instance pointer.
4551 @param ModeNumber The mode number to return information on.
4552 @param Columns Returns the columns of the text output device
4553 for the requested ModeNumber.
4554 @param Rows Returns the rows of the text output device
4555 for the requested ModeNumber.
4557 @retval EFI_SUCCESS The requested mode information was returned.
4558 @retval EFI_DEVICE_ERROR The device had an error and could not complete
4560 @retval EFI_UNSUPPORTED The mode number was not valid.
4565 ConSplitterTextOutQueryMode (
4566 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4567 IN UINTN ModeNumber
,
4572 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4574 INT32
*TextOutModeMap
;
4576 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4579 // Check whether param ModeNumber is valid.
4580 // ModeNumber should be within range 0 ~ MaxMode - 1.
4582 if ( (ModeNumber
> (UINTN
)(((UINT32
)-1)>>1)) ) {
4583 return EFI_UNSUPPORTED
;
4586 if ((INT32
) ModeNumber
>= This
->Mode
->MaxMode
) {
4587 return EFI_UNSUPPORTED
;
4591 // We get the available mode from mode intersection map if it's available
4593 if (Private
->TextOutModeMap
!= NULL
) {
4594 TextOutModeMap
= Private
->TextOutModeMap
+ Private
->TextOutListCount
* ModeNumber
;
4595 CurrentMode
= (UINTN
)(*TextOutModeMap
);
4596 *Columns
= Private
->TextOutQueryData
[CurrentMode
].Columns
;
4597 *Rows
= Private
->TextOutQueryData
[CurrentMode
].Rows
;
4599 *Columns
= Private
->TextOutQueryData
[ModeNumber
].Columns
;
4600 *Rows
= Private
->TextOutQueryData
[ModeNumber
].Rows
;
4603 if (*Columns
<= 0 && *Rows
<= 0) {
4604 return EFI_UNSUPPORTED
;
4613 Sets the output device(s) to a specified mode.
4615 @param This Protocol instance pointer.
4616 @param ModeNumber The mode number to set.
4618 @retval EFI_SUCCESS The requested text mode was set.
4619 @retval EFI_DEVICE_ERROR The device had an error and could not complete
4621 @retval EFI_UNSUPPORTED The mode number was not valid.
4626 ConSplitterTextOutSetMode (
4627 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4632 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4634 INT32
*TextOutModeMap
;
4635 EFI_STATUS ReturnStatus
;
4637 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4640 // Check whether param ModeNumber is valid.
4641 // ModeNumber should be within range 0 ~ MaxMode - 1.
4643 if ( (ModeNumber
> (UINTN
)(((UINT32
)-1)>>1)) ) {
4644 return EFI_UNSUPPORTED
;
4647 if ((INT32
) ModeNumber
>= This
->Mode
->MaxMode
) {
4648 return EFI_UNSUPPORTED
;
4651 // If the mode is being set to the curent mode, then just clear the screen and return.
4653 if (Private
->TextOutMode
.Mode
== (INT32
) ModeNumber
) {
4654 return ConSplitterTextOutClearScreen (This
);
4657 // return the worst status met
4659 TextOutModeMap
= Private
->TextOutModeMap
+ Private
->TextOutListCount
* ModeNumber
;
4660 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
4662 if (Private
->TextOutList
[Index
].TextOutEnabled
) {
4663 Status
= Private
->TextOutList
[Index
].TextOut
->SetMode (
4664 Private
->TextOutList
[Index
].TextOut
,
4665 TextOutModeMap
[Index
]
4668 // If this console device is based on a GOP or UGA device, then sync up the bitmap from
4669 // the GOP/UGA splitter and reclear the text portion of the display in the new mode.
4671 if ((Private
->TextOutList
[Index
].GraphicsOutput
!= NULL
) || (Private
->TextOutList
[Index
].UgaDraw
!= NULL
)) {
4672 Private
->TextOutList
[Index
].TextOut
->ClearScreen (Private
->TextOutList
[Index
].TextOut
);
4675 if (EFI_ERROR (Status
)) {
4676 ReturnStatus
= Status
;
4681 // The DevNull Console will support any possible mode as it allocates memory
4683 Status
= DevNullTextOutSetMode (Private
, ModeNumber
);
4684 if (EFI_ERROR (Status
)) {
4685 ReturnStatus
= Status
;
4688 return ReturnStatus
;
4693 Sets the background and foreground colors for the OutputString () and
4694 ClearScreen () functions.
4696 @param This Protocol instance pointer.
4697 @param Attribute The attribute to set. Bits 0..3 are the
4698 foreground color, and bits 4..6 are the
4699 background color. All other bits are undefined
4700 and must be zero. The valid Attributes are
4701 defined in this file.
4703 @retval EFI_SUCCESS The attribute was set.
4704 @retval EFI_DEVICE_ERROR The device had an error and could not complete
4706 @retval EFI_UNSUPPORTED The attribute requested is not defined.
4711 ConSplitterTextOutSetAttribute (
4712 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4717 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4719 EFI_STATUS ReturnStatus
;
4721 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4724 // Check whether param Attribute is valid.
4726 if ( (Attribute
> (UINTN
)(((UINT32
)-1)>>1)) ) {
4727 return EFI_UNSUPPORTED
;
4731 // return the worst status met
4733 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
4735 if (Private
->TextOutList
[Index
].TextOutEnabled
) {
4736 Status
= Private
->TextOutList
[Index
].TextOut
->SetAttribute (
4737 Private
->TextOutList
[Index
].TextOut
,
4740 if (EFI_ERROR (Status
)) {
4741 ReturnStatus
= Status
;
4746 Private
->TextOutMode
.Attribute
= (INT32
) Attribute
;
4748 return ReturnStatus
;
4753 Clears the output device(s) display to the currently selected background
4756 @param This Protocol instance pointer.
4758 @retval EFI_SUCCESS The operation completed successfully.
4759 @retval EFI_DEVICE_ERROR The device had an error and could not complete
4761 @retval EFI_UNSUPPORTED The output device is not in a valid text mode.
4766 ConSplitterTextOutClearScreen (
4767 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
4771 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4773 EFI_STATUS ReturnStatus
;
4775 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4778 // return the worst status met
4780 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
4782 if (Private
->TextOutList
[Index
].TextOutEnabled
) {
4783 Status
= Private
->TextOutList
[Index
].TextOut
->ClearScreen (Private
->TextOutList
[Index
].TextOut
);
4784 if (EFI_ERROR (Status
)) {
4785 ReturnStatus
= Status
;
4790 Status
= DevNullTextOutClearScreen (Private
);
4791 if (EFI_ERROR (Status
)) {
4792 ReturnStatus
= Status
;
4795 return ReturnStatus
;
4800 Sets the current coordinates of the cursor position
4802 @param This Protocol instance pointer.
4803 @param Column The column position to set the cursor to. Must be
4804 greater than or equal to zero and less than the
4805 number of columns by QueryMode ().
4806 @param Row The row position to set the cursor to. Must be
4807 greater than or equal to zero and less than the
4808 number of rows by QueryMode ().
4810 @retval EFI_SUCCESS The operation completed successfully.
4811 @retval EFI_DEVICE_ERROR The device had an error and could not complete
4813 @retval EFI_UNSUPPORTED The output device is not in a valid text mode,
4814 or the cursor position is invalid for the
4820 ConSplitterTextOutSetCursorPosition (
4821 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4827 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4829 EFI_STATUS ReturnStatus
;
4832 INT32
*TextOutModeMap
;
4836 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4837 TextOutModeMap
= NULL
;
4838 ModeNumber
= Private
->TextOutMode
.Mode
;
4841 // Get current MaxColumn and MaxRow from intersection map
4843 if (Private
->TextOutModeMap
!= NULL
) {
4844 TextOutModeMap
= Private
->TextOutModeMap
+ Private
->TextOutListCount
* ModeNumber
;
4845 CurrentMode
= *TextOutModeMap
;
4847 CurrentMode
= ModeNumber
;
4850 MaxColumn
= Private
->TextOutQueryData
[CurrentMode
].Columns
;
4851 MaxRow
= Private
->TextOutQueryData
[CurrentMode
].Rows
;
4853 if (Column
>= MaxColumn
|| Row
>= MaxRow
) {
4854 return EFI_UNSUPPORTED
;
4857 // return the worst status met
4859 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
4861 if (Private
->TextOutList
[Index
].TextOutEnabled
) {
4862 Status
= Private
->TextOutList
[Index
].TextOut
->SetCursorPosition (
4863 Private
->TextOutList
[Index
].TextOut
,
4867 if (EFI_ERROR (Status
)) {
4868 ReturnStatus
= Status
;
4873 DevNullTextOutSetCursorPosition (Private
, Column
, Row
);
4875 return ReturnStatus
;
4880 Makes the cursor visible or invisible
4882 @param This Protocol instance pointer.
4883 @param Visible If TRUE, the cursor is set to be visible. If
4884 FALSE, the cursor is set to be invisible.
4886 @retval EFI_SUCCESS The operation completed successfully.
4887 @retval EFI_DEVICE_ERROR The device had an error and could not complete
4888 the request, or the device does not support
4889 changing the cursor mode.
4890 @retval EFI_UNSUPPORTED The output device is not in a valid text mode.
4895 ConSplitterTextOutEnableCursor (
4896 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4901 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4903 EFI_STATUS ReturnStatus
;
4905 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4908 // return the worst status met
4910 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
4912 if (Private
->TextOutList
[Index
].TextOutEnabled
) {
4913 Status
= Private
->TextOutList
[Index
].TextOut
->EnableCursor (
4914 Private
->TextOutList
[Index
].TextOut
,
4917 if (EFI_ERROR (Status
)) {
4918 ReturnStatus
= Status
;
4923 DevNullTextOutEnableCursor (Private
, Visible
);
4925 return ReturnStatus
;