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 // Either Graphics Output protocol or 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
;
1277 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*Info
;
1280 // Start ConSplitter on ControllerHandle, and create the virtual
1281 // agrogated console device on first call Start for a ConsoleOut handle.
1283 Status
= ConSplitterStart (
1286 mConOut
.VirtualHandle
,
1287 &gEfiConsoleOutDeviceGuid
,
1288 &gEfiSimpleTextOutProtocolGuid
,
1291 if (EFI_ERROR (Status
)) {
1295 GraphicsOutput
= NULL
;
1298 // Try to Open Graphics Output protocol
1300 Status
= gBS
->OpenProtocol (
1302 &gEfiGraphicsOutputProtocolGuid
,
1303 (VOID
**) &GraphicsOutput
,
1304 This
->DriverBindingHandle
,
1305 mConOut
.VirtualHandle
,
1306 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1309 if (EFI_ERROR (Status
) && FeaturePcdGet (PcdUgaConsumeSupport
)) {
1311 // Open UGA DRAW protocol
1315 &gEfiUgaDrawProtocolGuid
,
1317 This
->DriverBindingHandle
,
1318 mConOut
.VirtualHandle
,
1319 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1324 // When new console device is added, the new mode will be set later,
1325 // so put current mode back to init state.
1327 mConOut
.TextOutMode
.Mode
= 0xFF;
1330 // If both ConOut and StdErr incorporate the same Text Out device,
1331 // their MaxMode and QueryData should be the intersection of both.
1333 Status
= ConSplitterTextOutAddDevice (&mConOut
, TextOut
, GraphicsOutput
, UgaDraw
);
1334 ConSplitterTextOutSetAttribute (&mConOut
.TextOut
, EFI_TEXT_ATTR (EFI_LIGHTGRAY
, EFI_BLACK
));
1336 if (FeaturePcdGet (PcdConOutUgaSupport
)) {
1338 // Get the UGA mode data of ConOut from the current mode
1340 if (GraphicsOutput
!= NULL
) {
1341 Status
= GraphicsOutput
->QueryMode (GraphicsOutput
, GraphicsOutput
->Mode
->Mode
, &SizeOfInfo
, &Info
);
1342 if (EFI_ERROR (Status
)) {
1345 ASSERT ( SizeOfInfo
<= sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
));
1347 mConOut
.UgaHorizontalResolution
= Info
->HorizontalResolution
;
1348 mConOut
.UgaVerticalResolution
= Info
->VerticalResolution
;
1349 mConOut
.UgaColorDepth
= 32;
1350 mConOut
.UgaRefreshRate
= 60;
1354 } else if (UgaDraw
!= NULL
&& FeaturePcdGet (PcdUgaConsumeSupport
)) {
1355 Status
= UgaDraw
->GetMode (
1357 &mConOut
.UgaHorizontalResolution
,
1358 &mConOut
.UgaVerticalResolution
,
1359 &mConOut
.UgaColorDepth
,
1360 &mConOut
.UgaRefreshRate
1370 Start Standard Error Consplitter on device handle.
1372 @param This Driver Binding protocol instance pointer.
1373 @param ControllerHandle Handle of device to bind driver to.
1374 @param RemainingDevicePath Optional parameter use to pick a specific child
1377 @retval EFI_SUCCESS Standard Error Consplitter is added to ControllerHandle.
1378 @retval other Standard Error Consplitter does not support this device.
1383 ConSplitterStdErrDriverBindingStart (
1384 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1385 IN EFI_HANDLE ControllerHandle
,
1386 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
1390 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
;
1393 // Start ConSplitter on ControllerHandle, and create the virtual
1394 // agrogated console device on first call Start for a StandardError handle.
1396 Status
= ConSplitterStart (
1399 mStdErr
.VirtualHandle
,
1400 &gEfiStandardErrorDeviceGuid
,
1401 &gEfiSimpleTextOutProtocolGuid
,
1404 if (EFI_ERROR (Status
)) {
1409 // When new console device is added, the new mode will be set later,
1410 // so put current mode back to init state.
1412 mStdErr
.TextOutMode
.Mode
= 0xFF;
1415 // If both ConOut and StdErr incorporate the same Text Out device,
1416 // their MaxMode and QueryData should be the intersection of both.
1418 Status
= ConSplitterTextOutAddDevice (&mStdErr
, TextOut
, NULL
, NULL
);
1419 ConSplitterTextOutSetAttribute (&mStdErr
.TextOut
, EFI_TEXT_ATTR (EFI_MAGENTA
, EFI_BLACK
));
1420 if (EFI_ERROR (Status
)) {
1424 if (mStdErr
.CurrentNumberOfConsoles
== 1) {
1425 gST
->StandardErrorHandle
= mStdErr
.VirtualHandle
;
1426 gST
->StdErr
= &mStdErr
.TextOut
;
1428 // Update the CRC32 in the EFI System Table header
1431 gBS
->CalculateCrc32 (
1432 (UINT8
*) &gST
->Hdr
,
1433 gST
->Hdr
.HeaderSize
,
1443 Stop ConSplitter on device handle by closing Console Device Guid on device handle
1444 and the console virtual handle.
1446 @param This Protocol instance pointer.
1447 @param ControllerHandle Handle of device.
1448 @param ConSplitterVirtualHandle Console virtual Handle.
1449 @param DeviceGuid The specified Console Device, such as ConInDev,
1451 @param InterfaceGuid The specified protocol to be opened.
1452 @param Interface Protocol interface returned.
1454 @retval EFI_SUCCESS Stop ConSplitter on ControllerHandle successfully.
1455 @retval other Failed to Stop ConSplitter on ControllerHandle.
1460 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1461 IN EFI_HANDLE ControllerHandle
,
1462 IN EFI_HANDLE ConSplitterVirtualHandle
,
1463 IN EFI_GUID
*DeviceGuid
,
1464 IN EFI_GUID
*InterfaceGuid
,
1470 Status
= gBS
->OpenProtocol (
1474 This
->DriverBindingHandle
,
1476 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1478 if (EFI_ERROR (Status
)) {
1482 // close the protocol refered.
1484 gBS
->CloseProtocol (
1487 This
->DriverBindingHandle
,
1488 ConSplitterVirtualHandle
1491 gBS
->CloseProtocol (
1494 This
->DriverBindingHandle
,
1503 Stop Console In ConSplitter on ControllerHandle by closing Console In Devcice GUID.
1505 @param This Driver Binding protocol instance pointer.
1506 @param ControllerHandle Handle of device to stop driver on
1507 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
1508 children is zero stop the entire bus driver.
1509 @param ChildHandleBuffer List of Child Handles to Stop.
1511 @retval EFI_SUCCESS This driver is removed ControllerHandle
1512 @retval other This driver was not removed from this device
1517 ConSplitterConInDriverBindingStop (
1518 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1519 IN EFI_HANDLE ControllerHandle
,
1520 IN UINTN NumberOfChildren
,
1521 IN EFI_HANDLE
*ChildHandleBuffer
1525 EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*TextIn
;
1526 EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*TextInEx
;
1528 if (NumberOfChildren
== 0) {
1532 Status
= gBS
->OpenProtocol (
1534 &gEfiSimpleTextInputExProtocolGuid
,
1535 (VOID
**) &TextInEx
,
1536 This
->DriverBindingHandle
,
1538 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1540 if (!EFI_ERROR (Status
)) {
1542 // If Simple Text Input Ex protocol exists,
1543 // remove device from Text Input Ex devices list.
1545 Status
= ConSplitterTextInExDeleteDevice (&mConIn
, TextInEx
);
1546 if (EFI_ERROR (Status
)) {
1552 // Close Simple Text In protocol on controller handle and virtual handle.
1554 Status
= ConSplitterStop (
1557 mConIn
.VirtualHandle
,
1558 &gEfiConsoleInDeviceGuid
,
1559 &gEfiSimpleTextInProtocolGuid
,
1562 if (EFI_ERROR (Status
)) {
1567 // Remove device from Text Input devices list.
1569 return ConSplitterTextInDeleteDevice (&mConIn
, TextIn
);
1574 Stop Simple Pointer protocol ConSplitter on ControllerHandle by closing
1575 Simple Pointer protocol.
1577 @param This Driver Binding protocol instance pointer.
1578 @param ControllerHandle Handle of device to stop driver on
1579 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
1580 children is zero stop the entire bus driver.
1581 @param ChildHandleBuffer List of Child Handles to Stop.
1583 @retval EFI_SUCCESS This driver is removed ControllerHandle
1584 @retval other This driver was not removed from this device
1589 ConSplitterSimplePointerDriverBindingStop (
1590 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1591 IN EFI_HANDLE ControllerHandle
,
1592 IN UINTN NumberOfChildren
,
1593 IN EFI_HANDLE
*ChildHandleBuffer
1597 EFI_SIMPLE_POINTER_PROTOCOL
*SimplePointer
;
1599 if (NumberOfChildren
== 0) {
1604 // Close Simple Pointer protocol on controller handle and virtual handle.
1606 Status
= ConSplitterStop (
1609 mConIn
.VirtualHandle
,
1610 &gEfiSimplePointerProtocolGuid
,
1611 &gEfiSimplePointerProtocolGuid
,
1612 (VOID
**) &SimplePointer
1614 if (EFI_ERROR (Status
)) {
1619 // Remove this device from Simple Pointer device list.
1621 return ConSplitterSimplePointerDeleteDevice (&mConIn
, SimplePointer
);
1626 Stop Absolute Pointer protocol ConSplitter on ControllerHandle by closing
1627 Absolute Pointer protocol.
1629 @param This Driver Binding protocol instance pointer.
1630 @param ControllerHandle Handle of device to stop driver on
1631 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
1632 children is zero stop the entire bus driver.
1633 @param ChildHandleBuffer List of Child Handles to Stop.
1635 @retval EFI_SUCCESS This driver is removed ControllerHandle
1636 @retval other This driver was not removed from this device
1641 ConSplitterAbsolutePointerDriverBindingStop (
1642 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1643 IN EFI_HANDLE ControllerHandle
,
1644 IN UINTN NumberOfChildren
,
1645 IN EFI_HANDLE
*ChildHandleBuffer
1649 EFI_ABSOLUTE_POINTER_PROTOCOL
*AbsolutePointer
;
1651 if (NumberOfChildren
== 0) {
1656 // Close Absolute Pointer protocol on controller handle and virtual handle.
1658 Status
= ConSplitterStop (
1661 mConIn
.VirtualHandle
,
1662 &gEfiAbsolutePointerProtocolGuid
,
1663 &gEfiAbsolutePointerProtocolGuid
,
1664 (VOID
**) &AbsolutePointer
1666 if (EFI_ERROR (Status
)) {
1671 // Remove this device from Absolute Pointer device list.
1673 return ConSplitterAbsolutePointerDeleteDevice (&mConIn
, AbsolutePointer
);
1678 Stop Console Out ConSplitter on device handle by closing Console Out Devcice GUID.
1680 @param This Driver Binding protocol instance pointer.
1681 @param ControllerHandle Handle of device to stop driver on
1682 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
1683 children is zero stop the entire bus driver.
1684 @param ChildHandleBuffer List of Child Handles to Stop.
1686 @retval EFI_SUCCESS This driver is removed ControllerHandle
1687 @retval other This driver was not removed from this device
1692 ConSplitterConOutDriverBindingStop (
1693 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1694 IN EFI_HANDLE ControllerHandle
,
1695 IN UINTN NumberOfChildren
,
1696 IN EFI_HANDLE
*ChildHandleBuffer
1700 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
;
1702 if (NumberOfChildren
== 0) {
1707 // Close Absolute Pointer protocol on controller handle and virtual handle.
1709 Status
= ConSplitterStop (
1712 mConOut
.VirtualHandle
,
1713 &gEfiConsoleOutDeviceGuid
,
1714 &gEfiSimpleTextOutProtocolGuid
,
1717 if (EFI_ERROR (Status
)) {
1722 // Remove this device from Text Out device list.
1724 return ConSplitterTextOutDeleteDevice (&mConOut
, TextOut
);
1729 Stop Standard Error ConSplitter on ControllerHandle by closing Standard Error GUID.
1731 @param This Driver Binding protocol instance pointer.
1732 @param ControllerHandle Handle of device to stop driver on
1733 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
1734 children is zero stop the entire bus driver.
1735 @param ChildHandleBuffer List of Child Handles to Stop.
1737 @retval EFI_SUCCESS This driver is removed ControllerHandle
1738 @retval other This driver was not removed from this device
1743 ConSplitterStdErrDriverBindingStop (
1744 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1745 IN EFI_HANDLE ControllerHandle
,
1746 IN UINTN NumberOfChildren
,
1747 IN EFI_HANDLE
*ChildHandleBuffer
1751 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
;
1753 if (NumberOfChildren
== 0) {
1758 // Close Standard Error Device on controller handle and virtual handle.
1760 Status
= ConSplitterStop (
1763 mStdErr
.VirtualHandle
,
1764 &gEfiStandardErrorDeviceGuid
,
1765 &gEfiSimpleTextOutProtocolGuid
,
1768 if (EFI_ERROR (Status
)) {
1772 // Delete this console error out device's data structures.
1774 Status
= ConSplitterTextOutDeleteDevice (&mStdErr
, TextOut
);
1775 if (EFI_ERROR (Status
)) {
1779 if (mStdErr
.CurrentNumberOfConsoles
== 0) {
1780 gST
->StandardErrorHandle
= NULL
;
1783 // Update the CRC32 in the EFI System Table header
1786 gBS
->CalculateCrc32 (
1787 (UINT8
*) &gST
->Hdr
,
1788 gST
->Hdr
.HeaderSize
,
1798 Take the passed in Buffer of size SizeOfCount and grow the buffer
1799 by MAX (CONSOLE_SPLITTER_CONSOLES_ALLOC_UNIT, MaxGrow) * SizeOfCount
1800 bytes. Copy the current data in Buffer to the new version of Buffer
1801 and free the old version of buffer.
1803 @param SizeOfCount Size of element in array.
1804 @param Count Current number of elements in array.
1805 @param Buffer Bigger version of passed in Buffer with all the
1808 @retval EFI_SUCCESS Buffer size has grown.
1809 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
1813 ConSplitterGrowBuffer (
1814 IN UINTN SizeOfCount
,
1816 IN OUT VOID
**Buffer
1822 // grow the buffer to new buffer size,
1823 // copy the old buffer's content to the new-size buffer,
1824 // then free the old buffer.
1826 *Count
+= CONSOLE_SPLITTER_CONSOLES_ALLOC_UNIT
;
1827 Ptr
= ReallocatePool (
1828 SizeOfCount
* ((*Count
) - CONSOLE_SPLITTER_CONSOLES_ALLOC_UNIT
),
1829 SizeOfCount
* (*Count
),
1833 return EFI_OUT_OF_RESOURCES
;
1841 Add Text Input Device in Consplitter Text Input list.
1843 @param Private Text In Splitter pointer.
1844 @param TextIn Simple Text Input protocol pointer.
1846 @retval EFI_SUCCESS Text Input Device added successfully.
1847 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
1851 ConSplitterTextInAddDevice (
1852 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
1853 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*TextIn
1859 // If the Text In List is full, enlarge it by calling ConSplitterGrowBuffer().
1861 if (Private
->CurrentNumberOfConsoles
>= Private
->TextInListCount
) {
1862 Status
= ConSplitterGrowBuffer (
1863 sizeof (EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*),
1864 &Private
->TextInListCount
,
1865 (VOID
**) &Private
->TextInList
1867 if (EFI_ERROR (Status
)) {
1868 return EFI_OUT_OF_RESOURCES
;
1872 // Add the new text-in device data structure into the Text In List.
1874 Private
->TextInList
[Private
->CurrentNumberOfConsoles
] = TextIn
;
1875 Private
->CurrentNumberOfConsoles
++;
1878 // Extra CheckEvent added to reduce the double CheckEvent().
1880 gBS
->CheckEvent (TextIn
->WaitForKey
);
1887 Remove Text Input Device from Consplitter Text Input list.
1889 @param Private Text In Splitter pointer.
1890 @param TextIn Simple Text protocol pointer.
1892 @retval EFI_SUCCESS Simple Text Device removed successfully.
1893 @retval EFI_NOT_FOUND No Simple Text Device found.
1897 ConSplitterTextInDeleteDevice (
1898 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
1899 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*TextIn
1904 // Remove the specified text-in device data structure from the Text In List,
1905 // and rearrange the remaining data structures in the Text In List.
1907 for (Index
= 0; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
1908 if (Private
->TextInList
[Index
] == TextIn
) {
1909 for (Index
= Index
; Index
< Private
->CurrentNumberOfConsoles
- 1; Index
++) {
1910 Private
->TextInList
[Index
] = Private
->TextInList
[Index
+ 1];
1913 Private
->CurrentNumberOfConsoles
--;
1918 return EFI_NOT_FOUND
;
1922 Add Text Input Ex Device in Consplitter Text Input Ex list.
1924 @param Private Text In Splitter pointer.
1925 @param TextInEx Simple Text Input Ex Input protocol pointer.
1927 @retval EFI_SUCCESS Text Input Ex Device added successfully.
1928 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
1932 ConSplitterTextInExAddDevice (
1933 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
1934 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*TextInEx
1940 // If the Text Input Ex List is full, enlarge it by calling ConSplitterGrowBuffer().
1942 if (Private
->CurrentNumberOfExConsoles
>= Private
->TextInExListCount
) {
1943 Status
= ConSplitterGrowBuffer (
1944 sizeof (EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*),
1945 &Private
->TextInExListCount
,
1946 (VOID
**) &Private
->TextInExList
1948 if (EFI_ERROR (Status
)) {
1949 return EFI_OUT_OF_RESOURCES
;
1953 // Add the new text-in device data structure into the Text Input Ex List.
1955 Private
->TextInExList
[Private
->CurrentNumberOfExConsoles
] = TextInEx
;
1956 Private
->CurrentNumberOfExConsoles
++;
1959 // Extra CheckEvent added to reduce the double CheckEvent().
1961 gBS
->CheckEvent (TextInEx
->WaitForKeyEx
);
1967 Remove Text Ex Device from Consplitter Text Input Ex list.
1969 @param Private Text In Splitter pointer.
1970 @param TextInEx Simple Text Ex protocol pointer.
1972 @retval EFI_SUCCESS Simple Text Input Ex Device removed successfully.
1973 @retval EFI_NOT_FOUND No Simple Text Input Ex Device found.
1977 ConSplitterTextInExDeleteDevice (
1978 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
1979 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*TextInEx
1984 // Remove the specified text-in device data structure from the Text Input Ex List,
1985 // and rearrange the remaining data structures in the Text In List.
1987 for (Index
= 0; Index
< Private
->CurrentNumberOfExConsoles
; Index
++) {
1988 if (Private
->TextInExList
[Index
] == TextInEx
) {
1989 for (Index
= Index
; Index
< Private
->CurrentNumberOfExConsoles
- 1; Index
++) {
1990 Private
->TextInExList
[Index
] = Private
->TextInExList
[Index
+ 1];
1993 Private
->CurrentNumberOfExConsoles
--;
1998 return EFI_NOT_FOUND
;
2003 Add Simple Pointer Device in Consplitter Simple Pointer list.
2005 @param Private Text In Splitter pointer.
2006 @param SimplePointer Simple Pointer protocol pointer.
2008 @retval EFI_SUCCESS Simple Pointer Device added successfully.
2009 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
2013 ConSplitterSimplePointerAddDevice (
2014 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
2015 IN EFI_SIMPLE_POINTER_PROTOCOL
*SimplePointer
2021 // If the Simple Pointer List is full, enlarge it by calling ConSplitterGrowBuffer().
2023 if (Private
->CurrentNumberOfPointers
>= Private
->PointerListCount
) {
2024 Status
= ConSplitterGrowBuffer (
2025 sizeof (EFI_SIMPLE_POINTER_PROTOCOL
*),
2026 &Private
->PointerListCount
,
2027 (VOID
**) &Private
->PointerList
2029 if (EFI_ERROR (Status
)) {
2030 return EFI_OUT_OF_RESOURCES
;
2034 // Add the new text-in device data structure into the Simple Pointer List.
2036 Private
->PointerList
[Private
->CurrentNumberOfPointers
] = SimplePointer
;
2037 Private
->CurrentNumberOfPointers
++;
2044 Remove Simple Pointer Device from Consplitter Simple Pointer list.
2046 @param Private Text In Splitter pointer.
2047 @param SimplePointer Simple Pointer protocol pointer.
2049 @retval EFI_SUCCESS Simple Pointer Device removed successfully.
2050 @retval EFI_NOT_FOUND No Simple Pointer Device found.
2054 ConSplitterSimplePointerDeleteDevice (
2055 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
2056 IN EFI_SIMPLE_POINTER_PROTOCOL
*SimplePointer
2061 // Remove the specified text-in device data structure from the Simple Pointer List,
2062 // and rearrange the remaining data structures in the Text In List.
2064 for (Index
= 0; Index
< Private
->CurrentNumberOfPointers
; Index
++) {
2065 if (Private
->PointerList
[Index
] == SimplePointer
) {
2066 for (Index
= Index
; Index
< Private
->CurrentNumberOfPointers
- 1; Index
++) {
2067 Private
->PointerList
[Index
] = Private
->PointerList
[Index
+ 1];
2070 Private
->CurrentNumberOfPointers
--;
2075 return EFI_NOT_FOUND
;
2080 Add Absolute Pointer Device in Consplitter Absolute Pointer list.
2082 @param Private Text In Splitter pointer.
2083 @param AbsolutePointer Absolute Pointer protocol pointer.
2085 @retval EFI_SUCCESS Absolute Pointer Device added successfully.
2086 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
2090 ConSplitterAbsolutePointerAddDevice (
2091 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
2092 IN EFI_ABSOLUTE_POINTER_PROTOCOL
*AbsolutePointer
2098 // If the Absolute Pointer List is full, enlarge it by calling ConSplitterGrowBuffer().
2100 if (Private
->CurrentNumberOfAbsolutePointers
>= Private
->AbsolutePointerListCount
) {
2101 Status
= ConSplitterGrowBuffer (
2102 sizeof (EFI_ABSOLUTE_POINTER_PROTOCOL
*),
2103 &Private
->AbsolutePointerListCount
,
2104 (VOID
**) &Private
->AbsolutePointerList
2106 if (EFI_ERROR (Status
)) {
2107 return EFI_OUT_OF_RESOURCES
;
2111 // Add the new text-in device data structure into the Absolute Pointer List.
2113 Private
->AbsolutePointerList
[Private
->CurrentNumberOfAbsolutePointers
] = AbsolutePointer
;
2114 Private
->CurrentNumberOfAbsolutePointers
++;
2121 Remove Absolute Pointer Device from Consplitter Absolute Pointer list.
2123 @param Private Text In Splitter pointer.
2124 @param AbsolutePointer Absolute Pointer protocol pointer.
2126 @retval EFI_SUCCESS Absolute Pointer Device removed successfully.
2127 @retval EFI_NOT_FOUND No Absolute Pointer Device found.
2131 ConSplitterAbsolutePointerDeleteDevice (
2132 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
2133 IN EFI_ABSOLUTE_POINTER_PROTOCOL
*AbsolutePointer
2138 // Remove the specified text-in device data structure from the Absolute Pointer List,
2139 // and rearrange the remaining data structures from the Absolute Pointer List.
2141 for (Index
= 0; Index
< Private
->CurrentNumberOfAbsolutePointers
; Index
++) {
2142 if (Private
->AbsolutePointerList
[Index
] == AbsolutePointer
) {
2143 for (Index
= Index
; Index
< Private
->CurrentNumberOfAbsolutePointers
- 1; Index
++) {
2144 Private
->AbsolutePointerList
[Index
] = Private
->AbsolutePointerList
[Index
+ 1];
2147 Private
->CurrentNumberOfAbsolutePointers
--;
2152 return EFI_NOT_FOUND
;
2156 Reallocate Text Out mode map.
2158 Allocate new buffer and copy original buffer into the new buffer.
2160 @param Private Consplitter Text Out pointer.
2162 @retval EFI_SUCCESS Buffer size has grown
2163 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
2167 ConSplitterGrowMapTable (
2168 IN TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
2174 INT32
*TextOutModeMap
;
2175 INT32
*OldTextOutModeMap
;
2179 NewSize
= Private
->TextOutListCount
* sizeof (INT32
);
2180 OldTextOutModeMap
= Private
->TextOutModeMap
;
2181 TotalSize
= NewSize
* (Private
->TextOutQueryDataCount
);
2184 // Allocate new buffer for Text Out List.
2186 TextOutModeMap
= AllocatePool (TotalSize
);
2187 if (TextOutModeMap
== NULL
) {
2188 return EFI_OUT_OF_RESOURCES
;
2191 SetMem (TextOutModeMap
, TotalSize
, 0xFF);
2192 Private
->TextOutModeMap
= TextOutModeMap
;
2195 // If TextOutList has been enlarged, need to realloc the mode map table
2196 // The mode map table is regarded as a two dimension array.
2199 // 0 ---------> TextOutListCount ----> TextOutListCount
2200 // | -------------------------------------------
2207 // -------------------------------------------
2210 if (OldTextOutModeMap
!= NULL
) {
2212 Size
= Private
->CurrentNumberOfConsoles
* sizeof (INT32
);
2214 SrcAddress
= OldTextOutModeMap
;
2217 // Copy the old data to the new one
2219 while (Index
< Private
->TextOutMode
.MaxMode
) {
2220 CopyMem (TextOutModeMap
, SrcAddress
, Size
);
2221 TextOutModeMap
+= NewSize
;
2226 // Free the old buffer
2228 FreePool (OldTextOutModeMap
);
2236 Add new device's output mode to console splitter's mode list.
2238 @param Private Text Out Splitter pointer
2239 @param TextOut Simple Text Output protocol pointer.
2241 @retval EFI_SUCCESS Device added successfully.
2242 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
2246 ConSplitterAddOutputMode (
2247 IN TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
,
2248 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
2256 MaxMode
= TextOut
->Mode
->MaxMode
;
2257 Private
->TextOutMode
.MaxMode
= MaxMode
;
2260 // Grow the buffer if query data buffer is not large enough to
2261 // hold all the mode supported by the first console.
2263 while (MaxMode
> (INT32
) Private
->TextOutQueryDataCount
) {
2264 Status
= ConSplitterGrowBuffer (
2265 sizeof (TEXT_OUT_SPLITTER_QUERY_DATA
),
2266 &Private
->TextOutQueryDataCount
,
2267 (VOID
**) &Private
->TextOutQueryData
2269 if (EFI_ERROR (Status
)) {
2270 return EFI_OUT_OF_RESOURCES
;
2274 // Allocate buffer for the output mode map
2276 Status
= ConSplitterGrowMapTable (Private
);
2277 if (EFI_ERROR (Status
)) {
2278 return EFI_OUT_OF_RESOURCES
;
2281 // As the first textout device, directly add the mode in to QueryData
2282 // and at the same time record the mapping between QueryData and TextOut.
2286 while (Mode
< MaxMode
) {
2287 Status
= TextOut
->QueryMode (
2290 &Private
->TextOutQueryData
[Mode
].Columns
,
2291 &Private
->TextOutQueryData
[Mode
].Rows
2294 // If mode 1 (80x50) is not supported, make sure mode 1 in TextOutQueryData
2297 if ((EFI_ERROR(Status
)) && (Mode
== 1)) {
2298 Private
->TextOutQueryData
[Mode
].Columns
= 0;
2299 Private
->TextOutQueryData
[Mode
].Rows
= 0;
2301 Private
->TextOutModeMap
[Index
] = Mode
;
2303 Index
+= Private
->TextOutListCount
;
2310 Reconstruct TextOutModeMap to get intersection of modes.
2312 This routine reconstruct TextOutModeMap to get the intersection
2313 of modes for all console out devices. Because EFI/UEFI spec require
2314 mode 0 is 80x25, mode 1 is 80x50, this routine will not check the
2315 intersection for mode 0 and mode 1.
2317 @param TextOutModeMap Current text out mode map, begin with the mode 80x25
2318 @param NewlyAddedMap New text out mode map, begin with the mode 80x25
2319 @param MapStepSize Mode step size for one console device
2320 @param NewMapStepSize New Mode step size for one console device
2321 @param MaxMode IN: Current max text mode, OUT: Updated max text mode.
2322 @param CurrentMode IN: Current text mode, OUT: Updated current text mode.
2326 ConSplitterGetIntersection (
2327 IN INT32
*TextOutModeMap
,
2328 IN INT32
*NewlyAddedMap
,
2329 IN UINTN MapStepSize
,
2330 IN UINTN NewMapStepSize
,
2331 IN OUT INT32
*MaxMode
,
2332 IN OUT INT32
*CurrentMode
2336 INT32
*CurrentMapEntry
;
2337 INT32
*NextMapEntry
;
2339 INT32 CurrentMaxMode
;
2343 // According to EFI/UEFI spec, mode 0 and mode 1 have been reserved
2344 // for 80x25 and 80x50 in Simple Text Out protocol, so don't make intersection
2345 // for mode 0 and mode 1, mode number starts from 2.
2348 CurrentMapEntry
= &TextOutModeMap
[MapStepSize
* 2];
2349 NextMapEntry
= CurrentMapEntry
;
2350 NewMapEntry
= &NewlyAddedMap
[NewMapStepSize
* 2];
2352 CurrentMaxMode
= *MaxMode
;
2353 Mode
= *CurrentMode
;
2355 while (Index
< CurrentMaxMode
) {
2356 if (*NewMapEntry
== -1) {
2358 // This mode is not supported any more. Remove it. Special care
2359 // must be taken as this remove will also affect current mode;
2361 if (Index
== *CurrentMode
) {
2363 } else if (Index
< *CurrentMode
) {
2368 if (CurrentMapEntry
!= NextMapEntry
) {
2369 CopyMem (NextMapEntry
, CurrentMapEntry
, MapStepSize
* sizeof (INT32
));
2372 NextMapEntry
+= MapStepSize
;
2375 CurrentMapEntry
+= MapStepSize
;
2376 NewMapEntry
+= NewMapStepSize
;
2380 *CurrentMode
= Mode
;
2386 Sync the device's output mode to console splitter's mode list.
2388 @param Private Text Out Splitter pointer.
2389 @param TextOut Simple Text Output protocol pointer.
2393 ConSplitterSyncOutputMode (
2394 IN TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
,
2395 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
2398 INT32 CurrentMaxMode
;
2401 INT32
*TextOutModeMap
;
2404 TEXT_OUT_SPLITTER_QUERY_DATA
*TextOutQueryData
;
2411 // Must make sure that current mode won't change even if mode number changes
2413 CurrentMaxMode
= Private
->TextOutMode
.MaxMode
;
2414 TextOutModeMap
= Private
->TextOutModeMap
;
2415 StepSize
= Private
->TextOutListCount
;
2416 TextOutQueryData
= Private
->TextOutQueryData
;
2419 // Query all the mode that the newly added TextOut supports
2422 MapTable
= TextOutModeMap
+ Private
->CurrentNumberOfConsoles
;
2423 while (Mode
< TextOut
->Mode
->MaxMode
) {
2424 Status
= TextOut
->QueryMode (TextOut
, Mode
, &Columns
, &Rows
);
2426 if (EFI_ERROR(Status
)) {
2429 // If mode 1 (80x50) is not supported, make sure mode 1 in TextOutQueryData
2432 MapTable
[StepSize
] = Mode
;
2433 TextOutQueryData
[Mode
].Columns
= 0;
2434 TextOutQueryData
[Mode
].Rows
= 0;
2440 // Search the intersection map and QueryData database to see if they intersects
2443 while (Index
< CurrentMaxMode
) {
2444 QueryMode
= *(TextOutModeMap
+ Index
* StepSize
);
2445 if ((TextOutQueryData
[QueryMode
].Rows
== Rows
) && (TextOutQueryData
[QueryMode
].Columns
== Columns
)) {
2446 MapTable
[Index
* StepSize
] = Mode
;
2454 // Now search the TextOutModeMap table to find the intersection of supported
2455 // mode between ConSplitter and the newly added device.
2457 ConSplitterGetIntersection (
2462 &Private
->TextOutMode
.MaxMode
,
2463 &Private
->TextOutMode
.Mode
2471 Sync output device between ConOut and StdErr output.
2473 @retval EFI_SUCCESS Sync implemented successfully.
2474 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
2478 ConSplitterGetIntersectionBetweenConOutAndStrErr (
2482 UINTN ConOutNumOfConsoles
;
2483 UINTN StdErrNumOfConsoles
;
2484 TEXT_OUT_AND_GOP_DATA
*ConOutTextOutList
;
2485 TEXT_OUT_AND_GOP_DATA
*StdErrTextOutList
;
2489 UINTN ConOutColumns
;
2491 UINTN StdErrColumns
;
2492 INT32 ConOutMaxMode
;
2493 INT32 StdErrMaxMode
;
2498 INT32
*ConOutModeMap
;
2499 INT32
*StdErrModeMap
;
2500 INT32
*ConOutMapTable
;
2501 INT32
*StdErrMapTable
;
2502 TEXT_OUT_SPLITTER_QUERY_DATA
*ConOutQueryData
;
2503 TEXT_OUT_SPLITTER_QUERY_DATA
*StdErrQueryData
;
2504 UINTN ConOutStepSize
;
2505 UINTN StdErrStepSize
;
2506 BOOLEAN FoundTheSameTextOut
;
2507 UINTN ConOutMapTableSize
;
2508 UINTN StdErrMapTableSize
;
2510 ConOutNumOfConsoles
= mConOut
.CurrentNumberOfConsoles
;
2511 StdErrNumOfConsoles
= mStdErr
.CurrentNumberOfConsoles
;
2512 ConOutTextOutList
= mConOut
.TextOutList
;
2513 StdErrTextOutList
= mStdErr
.TextOutList
;
2516 FoundTheSameTextOut
= FALSE
;
2517 while ((Indexi
< ConOutNumOfConsoles
) && (!FoundTheSameTextOut
)) {
2519 while (Indexj
< StdErrNumOfConsoles
) {
2520 if (ConOutTextOutList
->TextOut
== StdErrTextOutList
->TextOut
) {
2521 FoundTheSameTextOut
= TRUE
;
2526 StdErrTextOutList
++;
2530 ConOutTextOutList
++;
2533 if (!FoundTheSameTextOut
) {
2537 // Must make sure that current mode won't change even if mode number changes
2539 ConOutMaxMode
= mConOut
.TextOutMode
.MaxMode
;
2540 ConOutModeMap
= mConOut
.TextOutModeMap
;
2541 ConOutStepSize
= mConOut
.TextOutListCount
;
2542 ConOutQueryData
= mConOut
.TextOutQueryData
;
2544 StdErrMaxMode
= mStdErr
.TextOutMode
.MaxMode
;
2545 StdErrModeMap
= mStdErr
.TextOutModeMap
;
2546 StdErrStepSize
= mStdErr
.TextOutListCount
;
2547 StdErrQueryData
= mStdErr
.TextOutQueryData
;
2550 // Allocate the map table and set the map table's index to -1.
2552 ConOutMapTableSize
= ConOutMaxMode
* sizeof (INT32
);
2553 ConOutMapTable
= AllocateZeroPool (ConOutMapTableSize
);
2554 if (ConOutMapTable
== NULL
) {
2555 return EFI_OUT_OF_RESOURCES
;
2558 SetMem (ConOutMapTable
, ConOutMapTableSize
, 0xFF);
2560 StdErrMapTableSize
= StdErrMaxMode
* sizeof (INT32
);
2561 StdErrMapTable
= AllocateZeroPool (StdErrMapTableSize
);
2562 if (StdErrMapTable
== NULL
) {
2563 return EFI_OUT_OF_RESOURCES
;
2566 SetMem (StdErrMapTable
, StdErrMapTableSize
, 0xFF);
2569 // Find the intersection of the two set of modes. If they actually intersect, the
2570 // correponding entry in the map table is set to 1.
2573 while (Mode
< ConOutMaxMode
) {
2575 // Search the intersection map and QueryData database to see if they intersect
2578 ConOutMode
= *(ConOutModeMap
+ Mode
* ConOutStepSize
);
2579 ConOutRows
= ConOutQueryData
[ConOutMode
].Rows
;
2580 ConOutColumns
= ConOutQueryData
[ConOutMode
].Columns
;
2581 while (Index
< StdErrMaxMode
) {
2582 StdErrMode
= *(StdErrModeMap
+ Index
* StdErrStepSize
);
2583 StdErrRows
= StdErrQueryData
[StdErrMode
].Rows
;
2584 StdErrColumns
= StdErrQueryData
[StdErrMode
].Columns
;
2585 if ((StdErrRows
== ConOutRows
) && (StdErrColumns
== ConOutColumns
)) {
2586 ConOutMapTable
[Mode
] = 1;
2587 StdErrMapTable
[Index
] = 1;
2597 // Now search the TextOutModeMap table to find the intersection of supported
2598 // mode between ConSplitter and the newly added device.
2600 ConSplitterGetIntersection (
2603 mConOut
.TextOutListCount
,
2605 &(mConOut
.TextOutMode
.MaxMode
),
2606 &(mConOut
.TextOutMode
.Mode
)
2609 if (mConOut
.TextOutMode
.Mode
< 0) {
2610 mConOut
.TextOut
.SetMode (&(mConOut
.TextOut
), 0);
2613 ConSplitterGetIntersection (
2616 mStdErr
.TextOutListCount
,
2618 &(mStdErr
.TextOutMode
.MaxMode
),
2619 &(mStdErr
.TextOutMode
.Mode
)
2622 if (mStdErr
.TextOutMode
.Mode
< 0) {
2623 mStdErr
.TextOut
.SetMode (&(mStdErr
.TextOut
), 0);
2626 FreePool (ConOutMapTable
);
2627 FreePool (StdErrMapTable
);
2634 Add Grahpics Output modes into Consplitter Text Out list.
2636 @param Private Text Out Splitter pointer.
2637 @param GraphicsOutput Graphics Output protocol pointer.
2638 @param UgaDraw UGA Draw protocol pointer.
2640 @retval EFI_SUCCESS Output mode added successfully.
2641 @retval other Failed to add output mode.
2645 ConSplitterAddGraphicsOutputMode (
2646 IN TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
,
2647 IN EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
,
2648 IN EFI_UGA_DRAW_PROTOCOL
*UgaDraw
2654 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*Mode
;
2656 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*Info
;
2657 EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE
*CurrentGraphicsOutputMode
;
2658 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*ModeBuffer
;
2659 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*MatchedMode
;
2662 BOOLEAN AlreadyExist
;
2663 UINT32 UgaHorizontalResolution
;
2664 UINT32 UgaVerticalResolution
;
2665 UINT32 UgaColorDepth
;
2666 UINT32 UgaRefreshRate
;
2668 ASSERT (GraphicsOutput
!= NULL
|| UgaDraw
!= NULL
);
2670 CurrentGraphicsOutputMode
= Private
->GraphicsOutput
.Mode
;
2675 if (Private
->CurrentNumberOfUgaDraw
!= 0) {
2677 // If any UGA device has already been added, then there is no need to
2678 // calculate intersection of display mode of different GOP/UGA device,
2679 // since only one display mode will be exported (i.e. user-defined mode)
2684 if (GraphicsOutput
!= NULL
) {
2685 if (Private
->CurrentNumberOfGraphicsOutput
== 0) {
2687 // This is the first Graphics Output device added
2689 CopyMem (CurrentGraphicsOutputMode
, GraphicsOutput
->Mode
, sizeof (EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE
));
2690 CopyMem (CurrentGraphicsOutputMode
->Info
, GraphicsOutput
->Mode
->Info
, GraphicsOutput
->Mode
->SizeOfInfo
);
2693 // Allocate resource for the private mode buffer
2695 ModeBuffer
= AllocatePool (sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
) * GraphicsOutput
->Mode
->MaxMode
);
2696 if (ModeBuffer
== NULL
) {
2697 return EFI_OUT_OF_RESOURCES
;
2699 FreePool (Private
->GraphicsOutputModeBuffer
);
2700 Private
->GraphicsOutputModeBuffer
= ModeBuffer
;
2703 // Store all supported display modes to the private mode buffer
2706 for (Index
= 0; Index
< GraphicsOutput
->Mode
->MaxMode
; Index
++) {
2708 // The Info buffer would be allocated by callee
2710 Status
= GraphicsOutput
->QueryMode (GraphicsOutput
, (UINT32
) Index
, &SizeOfInfo
, &Info
);
2711 if (EFI_ERROR (Status
)) {
2714 ASSERT ( SizeOfInfo
<= sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
));
2715 CopyMem (Mode
, Info
, SizeOfInfo
);
2721 // Check intersection of display mode
2723 ModeBuffer
= AllocatePool (sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
) * CurrentGraphicsOutputMode
->MaxMode
);
2724 if (ModeBuffer
== NULL
) {
2725 return EFI_OUT_OF_RESOURCES
;
2728 MatchedMode
= ModeBuffer
;
2729 Mode
= &Private
->GraphicsOutputModeBuffer
[0];
2730 for (Index
= 0; Index
< CurrentGraphicsOutputMode
->MaxMode
; Index
++) {
2733 for (NumberIndex
= 0; NumberIndex
< GraphicsOutput
->Mode
->MaxMode
; NumberIndex
++) {
2735 // The Info buffer would be allocated by callee
2737 Status
= GraphicsOutput
->QueryMode (GraphicsOutput
, (UINT32
) NumberIndex
, &SizeOfInfo
, &Info
);
2738 if (EFI_ERROR (Status
)) {
2741 if ((Info
->HorizontalResolution
== Mode
->HorizontalResolution
) &&
2742 (Info
->VerticalResolution
== Mode
->VerticalResolution
)) {
2744 // If GOP device supports one mode in current mode buffer,
2745 // it will be added into matched mode buffer
2755 AlreadyExist
= FALSE
;
2758 // Check if GOP mode has been in the mode buffer, ModeBuffer = MatchedMode at begin.
2760 for (Info
= ModeBuffer
; Info
< MatchedMode
; Info
++) {
2761 if ((Info
->HorizontalResolution
== Mode
->HorizontalResolution
) &&
2762 (Info
->VerticalResolution
== Mode
->VerticalResolution
)) {
2763 AlreadyExist
= TRUE
;
2768 if (!AlreadyExist
) {
2769 CopyMem (MatchedMode
, Mode
, sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
));
2772 // Physical frame buffer is no longer available, change PixelFormat to PixelBltOnly
2774 MatchedMode
->Version
= 0;
2775 MatchedMode
->PixelFormat
= PixelBltOnly
;
2776 ZeroMem (&MatchedMode
->PixelInformation
, sizeof (EFI_PIXEL_BITMASK
));
2786 // Drop the old mode buffer, assign it to a new one
2788 FreePool (Private
->GraphicsOutputModeBuffer
);
2789 Private
->GraphicsOutputModeBuffer
= ModeBuffer
;
2792 // Physical frame buffer is no longer available when there are more than one physical GOP devices
2794 CurrentGraphicsOutputMode
->MaxMode
= (UINT32
) (((UINTN
) MatchedMode
- (UINTN
) ModeBuffer
) / sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
));
2795 CurrentGraphicsOutputMode
->Info
->PixelFormat
= PixelBltOnly
;
2796 ZeroMem (&CurrentGraphicsOutputMode
->Info
->PixelInformation
, sizeof (EFI_PIXEL_BITMASK
));
2797 CurrentGraphicsOutputMode
->SizeOfInfo
= sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
);
2798 CurrentGraphicsOutputMode
->FrameBufferBase
= (EFI_PHYSICAL_ADDRESS
) (UINTN
) NULL
;
2799 CurrentGraphicsOutputMode
->FrameBufferSize
= 0;
2803 // Graphics console driver can ensure the same mode for all GOP devices
2805 for (Index
= 0; Index
< CurrentGraphicsOutputMode
->MaxMode
; Index
++) {
2806 Mode
= &Private
->GraphicsOutputModeBuffer
[Index
];
2807 if ((Mode
->HorizontalResolution
== GraphicsOutput
->Mode
->Info
->HorizontalResolution
) &&
2808 (Mode
->VerticalResolution
== GraphicsOutput
->Mode
->Info
->VerticalResolution
)) {
2809 CurrentIndex
= Index
;
2813 if (Index
>= CurrentGraphicsOutputMode
->MaxMode
) {
2815 // if user defined mode is not found, set to default mode 800x600
2817 for (Index
= 0; Index
< CurrentGraphicsOutputMode
->MaxMode
; Index
++) {
2818 Mode
= &Private
->GraphicsOutputModeBuffer
[Index
];
2819 if ((Mode
->HorizontalResolution
== 800) && (Mode
->VerticalResolution
== 600)) {
2820 CurrentIndex
= Index
;
2825 } else if (UgaDraw
!= NULL
&& FeaturePcdGet (PcdUgaConsumeSupport
)) {
2827 // Graphics console driver can ensure the same mode for all GOP devices
2828 // so we can get the current mode from this video device
2832 &UgaHorizontalResolution
,
2833 &UgaVerticalResolution
,
2838 CurrentGraphicsOutputMode
->MaxMode
= 1;
2839 Info
= CurrentGraphicsOutputMode
->Info
;
2841 Info
->HorizontalResolution
= UgaHorizontalResolution
;
2842 Info
->VerticalResolution
= UgaVerticalResolution
;
2843 Info
->PixelFormat
= PixelBltOnly
;
2844 Info
->PixelsPerScanLine
= UgaHorizontalResolution
;
2845 CurrentGraphicsOutputMode
->SizeOfInfo
= sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
);
2846 CurrentGraphicsOutputMode
->FrameBufferBase
= (EFI_PHYSICAL_ADDRESS
) (UINTN
) NULL
;
2847 CurrentGraphicsOutputMode
->FrameBufferSize
= 0;
2850 // Update the private mode buffer
2852 CopyMem (&Private
->GraphicsOutputModeBuffer
[0], Info
, sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
));
2855 // Only mode 0 is available to be set
2862 if (GraphicsOutput
!= NULL
) {
2863 Private
->CurrentNumberOfGraphicsOutput
++;
2865 if (UgaDraw
!= NULL
&& FeaturePcdGet (PcdUgaConsumeSupport
)) {
2866 Private
->CurrentNumberOfUgaDraw
++;
2870 // Force GraphicsOutput mode to be set,
2871 // regardless whether the console is in EfiConsoleControlScreenGraphics or EfiConsoleControlScreenText mode
2873 Private
->HardwareNeedsStarting
= TRUE
;
2875 // Current mode number may need update now, so set it to an invalid mode number
2877 CurrentGraphicsOutputMode
->Mode
= 0xffff;
2879 // Graphics console can ensure all GOP devices have the same mode which can be taken as current mode.
2881 Status
= Private
->GraphicsOutput
.SetMode (&Private
->GraphicsOutput
, (UINT32
) CurrentIndex
);
2882 if (EFI_ERROR(Status
)) {
2884 // If user defined mode is not valid for display device, set to the default mode 800x600.
2886 (Private
->GraphicsOutputModeBuffer
[0]).HorizontalResolution
= 800;
2887 (Private
->GraphicsOutputModeBuffer
[0]).VerticalResolution
= 600;
2888 Status
= Private
->GraphicsOutput
.SetMode (&Private
->GraphicsOutput
, 0);
2895 Set the current console out mode.
2897 This routine will get the current console mode information (column, row)
2898 from ConsoleOutMode variable and set it; if the variable does not exist,
2899 set to user defined console mode.
2901 @param Private Consplitter Text Out pointer.
2905 ConsplitterSetConsoleOutMode (
2906 IN TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
2916 CONSOLE_OUT_MODE ModeInfo
;
2918 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
;
2922 TextOut
= &Private
->TextOut
;
2923 MaxMode
= (UINTN
) (TextOut
->Mode
->MaxMode
);
2925 ModeInfoSize
= sizeof (CONSOLE_OUT_MODE
);
2926 Status
= gRT
->GetVariable (
2928 &gEfiGenericPlatformVariableGuid
,
2934 if (EFI_ERROR(Status
)) {
2936 // If fail to get variable, set variable to the default mode 80 x 25
2937 // required by UEFI spec;
2939 ModeInfo
.Column
= 80;
2944 &gEfiGenericPlatformVariableGuid
,
2945 EFI_VARIABLE_BOOTSERVICE_ACCESS
| EFI_VARIABLE_NON_VOLATILE
,
2946 sizeof (CONSOLE_OUT_MODE
),
2952 // To find the prefer mode and basic mode from Text Out mode list
2954 for (Mode
= 0; Mode
< MaxMode
; Mode
++) {
2955 Status
= TextOut
->QueryMode (TextOut
, Mode
, &Col
, &Row
);
2956 if (!EFI_ERROR(Status
)) {
2957 if (Col
== ModeInfo
.Column
&& Row
== ModeInfo
.Row
) {
2960 if (Col
== 80 && Row
== 25) {
2967 // Set perfer mode to Text Out devices.
2969 Status
= TextOut
->SetMode (TextOut
, PreferMode
);
2970 if (EFI_ERROR(Status
)) {
2972 // if current mode setting is failed, default 80x25 mode will be set.
2974 Status
= TextOut
->SetMode (TextOut
, BaseMode
);
2975 ASSERT(!EFI_ERROR(Status
));
2977 ModeInfo
.Column
= 80;
2981 // Update ConOutMode variable
2985 &gEfiGenericPlatformVariableGuid
,
2986 EFI_VARIABLE_BOOTSERVICE_ACCESS
| EFI_VARIABLE_NON_VOLATILE
,
2987 sizeof (CONSOLE_OUT_MODE
),
2997 Add Text Output Device in Consplitter Text Output list.
2999 @param Private Text Out Splitter pointer.
3000 @param TextOut Simple Text Output protocol pointer.
3001 @param GraphicsOutput Graphics Output protocol pointer.
3002 @param UgaDraw UGA Draw protocol pointer.
3004 @retval EFI_SUCCESS Text Output Device added successfully.
3005 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
3009 ConSplitterTextOutAddDevice (
3010 IN TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
,
3011 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
,
3012 IN EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
,
3013 IN EFI_UGA_DRAW_PROTOCOL
*UgaDraw
3017 UINTN CurrentNumOfConsoles
;
3020 UINT32 UgaHorizontalResolution
;
3021 UINT32 UgaVerticalResolution
;
3022 UINT32 UgaColorDepth
;
3023 UINT32 UgaRefreshRate
;
3024 TEXT_OUT_AND_GOP_DATA
*TextAndGop
;
3026 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*Info
;
3028 Status
= EFI_SUCCESS
;
3029 CurrentNumOfConsoles
= Private
->CurrentNumberOfConsoles
;
3032 // If the Text Out List is full, enlarge it by calling ConSplitterGrowBuffer().
3034 while (CurrentNumOfConsoles
>= Private
->TextOutListCount
) {
3035 Status
= ConSplitterGrowBuffer (
3036 sizeof (TEXT_OUT_AND_GOP_DATA
),
3037 &Private
->TextOutListCount
,
3038 (VOID
**) &Private
->TextOutList
3040 if (EFI_ERROR (Status
)) {
3041 return EFI_OUT_OF_RESOURCES
;
3044 // Also need to reallocate the TextOutModeMap table
3046 Status
= ConSplitterGrowMapTable (Private
);
3047 if (EFI_ERROR (Status
)) {
3048 return EFI_OUT_OF_RESOURCES
;
3052 TextAndGop
= &Private
->TextOutList
[CurrentNumOfConsoles
];
3054 TextAndGop
->TextOut
= TextOut
;
3055 TextAndGop
->GraphicsOutput
= GraphicsOutput
;
3056 TextAndGop
->UgaDraw
= UgaDraw
;
3058 if ((GraphicsOutput
== NULL
) && (UgaDraw
== NULL
)) {
3060 // If No GOP/UGA device then use the ConOut device
3062 TextAndGop
->TextOutEnabled
= TRUE
;
3065 // If GOP/UGA device use ConOut device only used if screen is in Text mode
3067 TextAndGop
->TextOutEnabled
= (BOOLEAN
) (Private
->ConsoleOutputMode
== EfiConsoleControlScreenText
);
3070 if (CurrentNumOfConsoles
== 0) {
3072 // Add the first device's output mode to console splitter's mode list
3074 Status
= ConSplitterAddOutputMode (Private
, TextOut
);
3076 ConSplitterSyncOutputMode (Private
, TextOut
);
3079 Private
->CurrentNumberOfConsoles
++;
3082 // Scan both TextOutList, for the intersection TextOut device
3083 // maybe both ConOut and StdErr incorporate the same Text Out
3084 // device in them, thus the output of both should be synced.
3086 ConSplitterGetIntersectionBetweenConOutAndStrErr ();
3088 CurrentMode
= Private
->TextOutMode
.Mode
;
3089 MaxMode
= Private
->TextOutMode
.MaxMode
;
3090 ASSERT (MaxMode
>= 1);
3092 if (FeaturePcdGet (PcdConOutGopSupport
)) {
3094 // If GOP is produced by Consplitter, this device display mode will be added into Graphics Ouput modes.
3096 if ((GraphicsOutput
!= NULL
) || (UgaDraw
!= NULL
&& FeaturePcdGet (PcdUgaConsumeSupport
))) {
3097 ConSplitterAddGraphicsOutputMode (Private
, GraphicsOutput
, UgaDraw
);
3101 if (FeaturePcdGet (PcdConOutUgaSupport
)) {
3102 UgaHorizontalResolution
= 800;
3103 UgaVerticalResolution
= 600;
3105 UgaRefreshRate
= 60;
3107 Status
= EFI_DEVICE_ERROR
;
3109 // If UGA is produced by Consplitter
3111 if (GraphicsOutput
!= NULL
) {
3112 Status
= GraphicsOutput
->QueryMode (GraphicsOutput
, GraphicsOutput
->Mode
->Mode
, &SizeOfInfo
, &Info
);
3113 if (EFI_ERROR (Status
)) {
3116 ASSERT ( SizeOfInfo
<= sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
));
3118 UgaHorizontalResolution
= Info
->HorizontalResolution
;
3119 UgaVerticalResolution
= Info
->VerticalResolution
;
3123 } else if (UgaDraw
!= NULL
&& FeaturePcdGet (PcdUgaConsumeSupport
)) {
3124 Status
= UgaDraw
->GetMode (
3126 &UgaHorizontalResolution
,
3127 &UgaVerticalResolution
,
3134 // Set UGA Draw mode,
3135 // if GetMode is failed, set to 800x600 mode
3137 Status
= ConSpliterUgaDrawSetMode (
3139 UgaHorizontalResolution
,
3140 UgaVerticalResolution
,
3146 if (Private
->ConsoleOutputMode
== EfiConsoleControlScreenGraphics
&& GraphicsOutput
!= NULL
) {
3148 // We just added a new GOP or UGA device in graphics mode
3150 if (FeaturePcdGet (PcdConOutGopSupport
)) {
3152 // Sync display output on new device based on GOP settings.
3154 DevNullGopSync (Private
, TextAndGop
->GraphicsOutput
, TextAndGop
->UgaDraw
);
3155 } else if (FeaturePcdGet (PcdConOutUgaSupport
)) {
3157 // Sync display output on new device based on UGA settings.
3159 DevNullUgaSync (Private
, TextAndGop
->GraphicsOutput
, TextAndGop
->UgaDraw
);
3161 } else if ((CurrentMode
>= 0) && ((GraphicsOutput
!= NULL
) || (UgaDraw
!= NULL
)) && (CurrentMode
< Private
->TextOutMode
.MaxMode
)) {
3163 // The new console supports the same mode of the current console so sync up
3165 DevNullSyncStdOut (Private
);
3168 // If ConOut, then set the mode to Mode #0 which us 80 x 25
3170 Private
->TextOut
.SetMode (&Private
->TextOut
, 0);
3174 // After adding new console device, all existing console devices should be
3175 // synced to the current shared mode.
3177 ConsplitterSetConsoleOutMode (Private
);
3184 Remove Text Out Device in Consplitter Text Out list.
3186 @param Private Text Out Splitter pointer.
3187 @param TextOut Simple Text Output Pointer protocol pointer.
3189 @retval EFI_SUCCESS Text Out Device removed successfully.
3190 @retval EFI_NOT_FOUND No Text Out Device found.
3194 ConSplitterTextOutDeleteDevice (
3195 IN TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
,
3196 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
3200 UINTN CurrentNumOfConsoles
;
3201 TEXT_OUT_AND_GOP_DATA
*TextOutList
;
3205 // Remove the specified text-out device data structure from the Text out List,
3206 // and rearrange the remaining data structures in the Text out List.
3208 CurrentNumOfConsoles
= Private
->CurrentNumberOfConsoles
;
3209 Index
= (INT32
) CurrentNumOfConsoles
- 1;
3210 TextOutList
= Private
->TextOutList
;
3211 while (Index
>= 0) {
3212 if (TextOutList
->TextOut
== TextOut
) {
3213 CopyMem (TextOutList
, TextOutList
+ 1, sizeof (TEXT_OUT_AND_GOP_DATA
) * Index
);
3214 CurrentNumOfConsoles
--;
3215 if (TextOutList
->UgaDraw
!= NULL
&& FeaturePcdGet (PcdUgaConsumeSupport
)) {
3216 Private
->CurrentNumberOfUgaDraw
--;
3218 if (TextOutList
->GraphicsOutput
!= NULL
) {
3219 Private
->CurrentNumberOfGraphicsOutput
--;
3228 // The specified TextOut is not managed by the ConSplitter driver
3231 return EFI_NOT_FOUND
;
3234 if (CurrentNumOfConsoles
== 0) {
3236 // If the number of consoles is zero clear the Dev NULL device
3238 Private
->CurrentNumberOfConsoles
= 0;
3239 Private
->TextOutMode
.MaxMode
= 1;
3240 Private
->TextOutQueryData
[0].Columns
= 80;
3241 Private
->TextOutQueryData
[0].Rows
= 25;
3242 DevNullTextOutSetMode (Private
, 0);
3247 // Max Mode is realy an intersection of the QueryMode command to all
3248 // devices. So we must copy the QueryMode of the first device to
3252 Private
->TextOutQueryData
,
3253 Private
->TextOutQueryDataCount
* sizeof (TEXT_OUT_SPLITTER_QUERY_DATA
)
3256 FreePool (Private
->TextOutModeMap
);
3257 Private
->TextOutModeMap
= NULL
;
3258 TextOutList
= Private
->TextOutList
;
3261 // Add the first TextOut to the QueryData array and ModeMap table
3263 Status
= ConSplitterAddOutputMode (Private
, TextOutList
->TextOut
);
3266 // Now add one by one
3269 Private
->CurrentNumberOfConsoles
= 1;
3271 while ((UINTN
) Index
< CurrentNumOfConsoles
) {
3272 ConSplitterSyncOutputMode (Private
, TextOutList
->TextOut
);
3274 Private
->CurrentNumberOfConsoles
++;
3278 ConSplitterGetIntersectionBetweenConOutAndStrErr ();
3285 Reset the input device and optionaly run diagnostics
3287 @param This Protocol instance pointer.
3288 @param ExtendedVerification Driver may perform diagnostics on reset.
3290 @retval EFI_SUCCESS The device was reset.
3291 @retval EFI_DEVICE_ERROR The device is not functioning properly and could
3297 ConSplitterTextInReset (
3298 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*This
,
3299 IN BOOLEAN ExtendedVerification
3303 EFI_STATUS ReturnStatus
;
3304 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3307 Private
= TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
3309 Private
->KeyEventSignalState
= FALSE
;
3312 // return the worst status met
3314 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
3315 Status
= Private
->TextInList
[Index
]->Reset (
3316 Private
->TextInList
[Index
],
3317 ExtendedVerification
3319 if (EFI_ERROR (Status
)) {
3320 ReturnStatus
= Status
;
3324 return ReturnStatus
;
3329 Reads the next keystroke from the input device. The WaitForKey Event can
3330 be used to test for existance of a keystroke via WaitForEvent () call.
3332 @param Private Protocol instance pointer.
3333 @param Key Driver may perform diagnostics on reset.
3335 @retval EFI_SUCCESS The keystroke information was returned.
3336 @retval EFI_NOT_READY There was no keystroke data availiable.
3337 @retval EFI_DEVICE_ERROR The keydtroke information was not returned due
3343 ConSplitterTextInPrivateReadKeyStroke (
3344 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
3345 OUT EFI_INPUT_KEY
*Key
3350 EFI_INPUT_KEY CurrentKey
;
3352 Key
->UnicodeChar
= 0;
3353 Key
->ScanCode
= SCAN_NULL
;
3356 // if no physical console input device exists, return EFI_NOT_READY;
3357 // if any physical console input device has key input,
3358 // return the key and EFI_SUCCESS.
3360 for (Index
= 0; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
3361 Status
= Private
->TextInList
[Index
]->ReadKeyStroke (
3362 Private
->TextInList
[Index
],
3365 if (!EFI_ERROR (Status
)) {
3371 return EFI_NOT_READY
;
3375 Return TRUE if StdIn is locked. The ConIn device on the virtual handle is
3376 the only device locked.
3378 @retval TRUE StdIn locked
3379 @retval FALSE StdIn working normally
3383 ConSpliterConssoleControlStdInLocked (
3387 return mConIn
.PasswordEnabled
;
3392 This timer event will fire when StdIn is locked. It will check the key
3393 sequence on StdIn to see if it matches the password. Any error in the
3394 password will cause the check to reset. As long a mConIn.PasswordEnabled is
3395 TRUE the StdIn splitter will not report any input.
3397 @param Event The Event this notify function registered to.
3398 @param Context Pointer to the context data registerd to the
3403 ConSpliterConsoleControlLockStdInEvent (
3410 CHAR16 BackSpaceString
[2];
3411 CHAR16 SpaceString
[2];
3414 Status
= ConSplitterTextInPrivateReadKeyStroke (&mConIn
, &Key
);
3415 if (!EFI_ERROR (Status
)) {
3417 // if it's an ENTER, match password
3419 if ((Key
.UnicodeChar
== CHAR_CARRIAGE_RETURN
) && (Key
.ScanCode
== SCAN_NULL
)) {
3420 mConIn
.PwdAttempt
[mConIn
.PwdIndex
] = CHAR_NULL
;
3421 if (StrCmp (mConIn
.Password
, mConIn
.PwdAttempt
)) {
3423 // Password not match
3425 ConSplitterTextOutOutputString (&mConOut
.TextOut
, (CHAR16
*) L
"\n\rPassword not correct\n\r");
3426 mConIn
.PwdIndex
= 0;
3429 // Key matches password sequence
3431 gBS
->SetTimer (mConIn
.LockEvent
, TimerPeriodic
, 0);
3432 mConIn
.PasswordEnabled
= FALSE
;
3433 Status
= EFI_NOT_READY
;
3435 } else if ((Key
.UnicodeChar
== CHAR_BACKSPACE
) && (Key
.ScanCode
== SCAN_NULL
)) {
3439 if (mConIn
.PwdIndex
> 0) {
3440 BackSpaceString
[0] = CHAR_BACKSPACE
;
3441 BackSpaceString
[1] = 0;
3443 SpaceString
[0] = L
' ';
3446 ConSplitterTextOutOutputString (&mConOut
.TextOut
, BackSpaceString
);
3447 ConSplitterTextOutOutputString (&mConOut
.TextOut
, SpaceString
);
3448 ConSplitterTextOutOutputString (&mConOut
.TextOut
, BackSpaceString
);
3452 } else if ((Key
.ScanCode
== SCAN_NULL
) && (Key
.UnicodeChar
>= 32)) {
3454 // If it's not an ENTER, neigher a function key, nor a CTRL-X or ALT-X, record the input
3456 if (mConIn
.PwdIndex
< (MAX_STD_IN_PASSWORD
- 1)) {
3457 if (mConIn
.PwdIndex
== 0) {
3458 ConSplitterTextOutOutputString (&mConOut
.TextOut
, (CHAR16
*) L
"\n\r");
3461 ConSplitterTextOutOutputString (&mConOut
.TextOut
, (CHAR16
*) L
"*");
3462 mConIn
.PwdAttempt
[mConIn
.PwdIndex
] = Key
.UnicodeChar
;
3467 } while (!EFI_ERROR (Status
));
3472 If Password is NULL or the Password is too big, then return an error. If the
3473 Password is valid, then store the password, lock StdIn and arm the periodic timer.
3475 @param This Console Control protocol pointer.
3476 @param Password The password input.
3478 @retval EFI_SUCCESS Lock the StdIn device
3479 @retval EFI_INVALID_PARAMETER Password is NULL
3480 @retval EFI_OUT_OF_RESOURCES Buffer allocation to store the password fails
3485 ConSpliterConsoleControlLockStdIn (
3486 IN EFI_CONSOLE_CONTROL_PROTOCOL
*This
,
3490 if (Password
== NULL
) {
3491 return EFI_INVALID_PARAMETER
;
3494 if (StrLen (Password
) >= MAX_STD_IN_PASSWORD
) {
3496 // Currently have a max password size
3498 return EFI_OUT_OF_RESOURCES
;
3501 // Save the password, initialize state variables and arm event timer
3503 StrCpy (mConIn
.Password
, Password
);
3504 mConIn
.PasswordEnabled
= TRUE
;
3505 mConIn
.PwdIndex
= 0;
3506 gBS
->SetTimer (mConIn
.LockEvent
, TimerPeriodic
, (10000 * 25));
3513 Reads the next keystroke from the input device. The WaitForKey Event can
3514 be used to test for existance of a keystroke via WaitForEvent () call.
3515 If the ConIn is password locked make it look like no keystroke is availible
3517 @param This Protocol instance pointer.
3518 @param Key Driver may perform diagnostics on reset.
3520 @retval EFI_SUCCESS The keystroke information was returned.
3521 @retval EFI_NOT_READY There was no keystroke data availiable.
3522 @retval EFI_DEVICE_ERROR The keydtroke information was not returned due
3528 ConSplitterTextInReadKeyStroke (
3529 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*This
,
3530 OUT EFI_INPUT_KEY
*Key
3533 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3535 Private
= TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
3536 if (Private
->PasswordEnabled
) {
3538 // If StdIn Locked return not ready
3540 return EFI_NOT_READY
;
3543 Private
->KeyEventSignalState
= FALSE
;
3545 return ConSplitterTextInPrivateReadKeyStroke (Private
, Key
);
3550 This event agregates all the events of the ConIn devices in the spliter.
3551 If the ConIn is password locked then return.
3552 If any events of physical ConIn devices are signaled, signal the ConIn
3553 spliter event. This will cause the calling code to call
3554 ConSplitterTextInReadKeyStroke ().
3556 @param Event The Event assoicated with callback.
3557 @param Context Context registered when Event was created.
3562 ConSplitterTextInWaitForKey (
3568 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3571 Private
= (TEXT_IN_SPLITTER_PRIVATE_DATA
*) Context
;
3572 if (Private
->PasswordEnabled
) {
3574 // If StdIn Locked return not ready
3580 // if KeyEventSignalState is flagged before, and not cleared by Reset() or ReadKeyStroke()
3582 if (Private
->KeyEventSignalState
) {
3583 gBS
->SignalEvent (Event
);
3587 // if any physical console input device has key input, signal the event.
3589 for (Index
= 0; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
3590 Status
= gBS
->CheckEvent (Private
->TextInList
[Index
]->WaitForKey
);
3591 if (!EFI_ERROR (Status
)) {
3592 gBS
->SignalEvent (Event
);
3593 Private
->KeyEventSignalState
= TRUE
;
3601 Test if the key has been registered on input device.
3603 @param RegsiteredData A pointer to a buffer that is filled in with the
3604 keystroke state data for the key that was
3606 @param InputData A pointer to a buffer that is filled in with the
3607 keystroke state data for the key that was
3610 @retval TRUE Key be pressed matches a registered key.
3611 @retval FLASE Match failed.
3616 IN EFI_KEY_DATA
*RegsiteredData
,
3617 IN EFI_KEY_DATA
*InputData
3620 ASSERT (RegsiteredData
!= NULL
&& InputData
!= NULL
);
3622 if ((RegsiteredData
->Key
.ScanCode
!= InputData
->Key
.ScanCode
) ||
3623 (RegsiteredData
->Key
.UnicodeChar
!= InputData
->Key
.UnicodeChar
)) {
3628 // Assume KeyShiftState/KeyToggleState = 0 in Registered key data means these state could be ignored.
3630 if (RegsiteredData
->KeyState
.KeyShiftState
!= 0 &&
3631 RegsiteredData
->KeyState
.KeyShiftState
!= InputData
->KeyState
.KeyShiftState
) {
3634 if (RegsiteredData
->KeyState
.KeyToggleState
!= 0 &&
3635 RegsiteredData
->KeyState
.KeyToggleState
!= InputData
->KeyState
.KeyToggleState
) {
3645 Reset the input device and optionaly run diagnostics
3647 @param This Protocol instance pointer.
3648 @param ExtendedVerification Driver may perform diagnostics on reset.
3650 @retval EFI_SUCCESS The device was reset.
3651 @retval EFI_DEVICE_ERROR The device is not functioning properly and could
3657 ConSplitterTextInResetEx (
3658 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*This
,
3659 IN BOOLEAN ExtendedVerification
3663 EFI_STATUS ReturnStatus
;
3664 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3667 Private
= TEXT_IN_EX_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
3669 Private
->KeyEventSignalState
= FALSE
;
3672 // return the worst status met
3674 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfExConsoles
; Index
++) {
3675 Status
= Private
->TextInExList
[Index
]->Reset (
3676 Private
->TextInExList
[Index
],
3677 ExtendedVerification
3679 if (EFI_ERROR (Status
)) {
3680 ReturnStatus
= Status
;
3684 return ReturnStatus
;
3690 Reads the next keystroke from the input device. The WaitForKey Event can
3691 be used to test for existance of a keystroke via WaitForEvent () call.
3693 @param This Protocol instance pointer.
3694 @param KeyData A pointer to a buffer that is filled in with the
3695 keystroke state data for the key that was
3698 @retval EFI_SUCCESS The keystroke information was returned.
3699 @retval EFI_NOT_READY There was no keystroke data availiable.
3700 @retval EFI_DEVICE_ERROR The keystroke information was not returned due
3702 @retval EFI_INVALID_PARAMETER KeyData is NULL.
3707 ConSplitterTextInReadKeyStrokeEx (
3708 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*This
,
3709 OUT EFI_KEY_DATA
*KeyData
3712 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3715 EFI_KEY_DATA CurrentKeyData
;
3718 if (KeyData
== NULL
) {
3719 return EFI_INVALID_PARAMETER
;
3722 Private
= TEXT_IN_EX_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
3723 if (Private
->PasswordEnabled
) {
3725 // If StdIn Locked return not ready
3727 return EFI_NOT_READY
;
3730 Private
->KeyEventSignalState
= FALSE
;
3732 KeyData
->Key
.UnicodeChar
= 0;
3733 KeyData
->Key
.ScanCode
= SCAN_NULL
;
3736 // if no physical console input device exists, return EFI_NOT_READY;
3737 // if any physical console input device has key input,
3738 // return the key and EFI_SUCCESS.
3740 for (Index
= 0; Index
< Private
->CurrentNumberOfExConsoles
; Index
++) {
3741 Status
= Private
->TextInExList
[Index
]->ReadKeyStrokeEx (
3742 Private
->TextInExList
[Index
],
3745 if (!EFI_ERROR (Status
)) {
3746 CopyMem (KeyData
, &CurrentKeyData
, sizeof (CurrentKeyData
));
3751 return EFI_NOT_READY
;
3756 Set certain state for the input device.
3758 @param This Protocol instance pointer.
3759 @param KeyToggleState A pointer to the EFI_KEY_TOGGLE_STATE to set the
3760 state for the input device.
3762 @retval EFI_SUCCESS The device state was set successfully.
3763 @retval EFI_DEVICE_ERROR The device is not functioning correctly and
3764 could not have the setting adjusted.
3765 @retval EFI_UNSUPPORTED The device does not have the ability to set its
3767 @retval EFI_INVALID_PARAMETER KeyToggleState is NULL.
3772 ConSplitterTextInSetState (
3773 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*This
,
3774 IN EFI_KEY_TOGGLE_STATE
*KeyToggleState
3777 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3781 if (KeyToggleState
== NULL
) {
3782 return EFI_INVALID_PARAMETER
;
3785 Private
= TEXT_IN_EX_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
3788 // if no physical console input device exists, return EFI_SUCCESS;
3789 // otherwise return the status of setting state of physical console input device
3791 for (Index
= 0; Index
< Private
->CurrentNumberOfExConsoles
; Index
++) {
3792 Status
= Private
->TextInExList
[Index
]->SetState (
3793 Private
->TextInExList
[Index
],
3796 if (EFI_ERROR (Status
)) {
3807 Register a notification function for a particular keystroke for the input device.
3809 @param This Protocol instance pointer.
3810 @param KeyData A pointer to a buffer that is filled in with the
3811 keystroke information data for the key that was
3813 @param KeyNotificationFunction Points to the function to be called when the key
3814 sequence is typed specified by KeyData.
3815 @param NotifyHandle Points to the unique handle assigned to the
3816 registered notification.
3818 @retval EFI_SUCCESS The notification function was registered
3820 @retval EFI_OUT_OF_RESOURCES Unable to allocate resources for necesssary data
3822 @retval EFI_INVALID_PARAMETER KeyData or NotifyHandle is NULL.
3827 ConSplitterTextInRegisterKeyNotify (
3828 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*This
,
3829 IN EFI_KEY_DATA
*KeyData
,
3830 IN EFI_KEY_NOTIFY_FUNCTION KeyNotificationFunction
,
3831 OUT EFI_HANDLE
*NotifyHandle
3834 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3837 TEXT_IN_EX_SPLITTER_NOTIFY
*NewNotify
;
3839 TEXT_IN_EX_SPLITTER_NOTIFY
*CurrentNotify
;
3842 if (KeyData
== NULL
|| NotifyHandle
== NULL
|| KeyNotificationFunction
== NULL
) {
3843 return EFI_INVALID_PARAMETER
;
3846 Private
= TEXT_IN_EX_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
3849 // if no physical console input device exists,
3850 // return EFI_SUCCESS directly.
3852 if (Private
->CurrentNumberOfExConsoles
<= 0) {
3857 // Return EFI_SUCCESS if the (KeyData, NotificationFunction) is already registered.
3859 for (Link
= Private
->NotifyList
.ForwardLink
; Link
!= &Private
->NotifyList
; Link
= Link
->ForwardLink
) {
3860 CurrentNotify
= TEXT_IN_EX_SPLITTER_NOTIFY_FROM_THIS (Link
);
3861 if (IsKeyRegistered (&CurrentNotify
->KeyData
, KeyData
)) {
3862 if (CurrentNotify
->KeyNotificationFn
== KeyNotificationFunction
) {
3863 *NotifyHandle
= CurrentNotify
->NotifyHandle
;
3870 // Allocate resource to save the notification function
3872 NewNotify
= (TEXT_IN_EX_SPLITTER_NOTIFY
*) AllocateZeroPool (sizeof (TEXT_IN_EX_SPLITTER_NOTIFY
));
3873 if (NewNotify
== NULL
) {
3874 return EFI_OUT_OF_RESOURCES
;
3876 NewNotify
->NotifyHandleList
= (EFI_HANDLE
*) AllocateZeroPool (sizeof (EFI_HANDLE
) * Private
->CurrentNumberOfExConsoles
);
3877 if (NewNotify
->NotifyHandleList
== NULL
) {
3878 gBS
->FreePool (NewNotify
);
3879 return EFI_OUT_OF_RESOURCES
;
3881 NewNotify
->Signature
= TEXT_IN_EX_SPLITTER_NOTIFY_SIGNATURE
;
3882 NewNotify
->KeyNotificationFn
= KeyNotificationFunction
;
3883 CopyMem (&NewNotify
->KeyData
, KeyData
, sizeof (KeyData
));
3886 // Return the wrong status of registering key notify of
3887 // physical console input device if meet problems
3889 for (Index
= 0; Index
< Private
->CurrentNumberOfExConsoles
; Index
++) {
3890 Status
= Private
->TextInExList
[Index
]->RegisterKeyNotify (
3891 Private
->TextInExList
[Index
],
3893 KeyNotificationFunction
,
3894 &NewNotify
->NotifyHandleList
[Index
]
3896 if (EFI_ERROR (Status
)) {
3897 gBS
->FreePool (NewNotify
->NotifyHandleList
);
3898 gBS
->FreePool (NewNotify
);
3904 // Use gSimpleTextInExNotifyGuid to get a valid EFI_HANDLE
3906 Status
= gBS
->InstallMultipleProtocolInterfaces (
3907 &NewNotify
->NotifyHandle
,
3908 &gSimpleTextInExNotifyGuid
,
3912 ASSERT_EFI_ERROR (Status
);
3914 InsertTailList (&mConIn
.NotifyList
, &NewNotify
->NotifyEntry
);
3916 *NotifyHandle
= NewNotify
->NotifyHandle
;
3924 Remove a registered notification function from a particular keystroke.
3926 @param This Protocol instance pointer.
3927 @param NotificationHandle The handle of the notification function being
3930 @retval EFI_SUCCESS The notification function was unregistered
3932 @retval EFI_INVALID_PARAMETER The NotificationHandle is invalid.
3933 @retval EFI_NOT_FOUND Can not find the matching entry in database.
3938 ConSplitterTextInUnregisterKeyNotify (
3939 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*This
,
3940 IN EFI_HANDLE NotificationHandle
3943 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3946 TEXT_IN_EX_SPLITTER_NOTIFY
*CurrentNotify
;
3949 if (NotificationHandle
== NULL
) {
3950 return EFI_INVALID_PARAMETER
;
3953 Status
= gBS
->OpenProtocol (
3955 &gSimpleTextInExNotifyGuid
,
3959 EFI_OPEN_PROTOCOL_TEST_PROTOCOL
3961 if (EFI_ERROR (Status
)) {
3962 return EFI_INVALID_PARAMETER
;
3965 Private
= TEXT_IN_EX_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
3968 // if no physical console input device exists,
3969 // return EFI_SUCCESS directly.
3971 if (Private
->CurrentNumberOfExConsoles
<= 0) {
3975 for (Link
= Private
->NotifyList
.ForwardLink
; Link
!= &Private
->NotifyList
; Link
= Link
->ForwardLink
) {
3976 CurrentNotify
= TEXT_IN_EX_SPLITTER_NOTIFY_FROM_THIS (Link
);
3977 if (CurrentNotify
->NotifyHandle
== NotificationHandle
) {
3978 for (Index
= 0; Index
< Private
->CurrentNumberOfExConsoles
; Index
++) {
3979 Status
= Private
->TextInExList
[Index
]->UnregisterKeyNotify (
3980 Private
->TextInExList
[Index
],
3981 CurrentNotify
->NotifyHandleList
[Index
]
3983 if (EFI_ERROR (Status
)) {
3987 RemoveEntryList (&CurrentNotify
->NotifyEntry
);
3988 Status
= gBS
->UninstallMultipleProtocolInterfaces (
3989 CurrentNotify
->NotifyHandle
,
3990 &gSimpleTextInExNotifyGuid
,
3994 ASSERT_EFI_ERROR (Status
);
3995 gBS
->FreePool (CurrentNotify
->NotifyHandleList
);
3996 gBS
->FreePool (CurrentNotify
);
4001 return EFI_NOT_FOUND
;
4007 Reset the input device and optionaly run diagnostics
4009 @param This Protocol instance pointer.
4010 @param ExtendedVerification Driver may perform diagnostics on reset.
4012 @retval EFI_SUCCESS The device was reset.
4013 @retval EFI_DEVICE_ERROR The device is not functioning properly and could
4019 ConSplitterSimplePointerReset (
4020 IN EFI_SIMPLE_POINTER_PROTOCOL
*This
,
4021 IN BOOLEAN ExtendedVerification
4025 EFI_STATUS ReturnStatus
;
4026 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
4029 Private
= TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_SIMPLE_POINTER_THIS (This
);
4031 Private
->InputEventSignalState
= FALSE
;
4033 if (Private
->CurrentNumberOfPointers
== 0) {
4037 // return the worst status met
4039 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfPointers
; Index
++) {
4040 Status
= Private
->PointerList
[Index
]->Reset (
4041 Private
->PointerList
[Index
],
4042 ExtendedVerification
4044 if (EFI_ERROR (Status
)) {
4045 ReturnStatus
= Status
;
4049 return ReturnStatus
;
4054 Reads the next keystroke from the input device. The WaitForKey Event can
4055 be used to test for existance of a keystroke via WaitForEvent () call.
4057 @param Private Protocol instance pointer.
4058 @param State The state information of simple pointer device.
4060 @retval EFI_SUCCESS The keystroke information was returned.
4061 @retval EFI_NOT_READY There was no keystroke data availiable.
4062 @retval EFI_DEVICE_ERROR The keydtroke information was not returned due
4068 ConSplitterSimplePointerPrivateGetState (
4069 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
4070 IN OUT EFI_SIMPLE_POINTER_STATE
*State
4074 EFI_STATUS ReturnStatus
;
4076 EFI_SIMPLE_POINTER_STATE CurrentState
;
4078 State
->RelativeMovementX
= 0;
4079 State
->RelativeMovementY
= 0;
4080 State
->RelativeMovementZ
= 0;
4081 State
->LeftButton
= FALSE
;
4082 State
->RightButton
= FALSE
;
4085 // if no physical console input device exists, return EFI_NOT_READY;
4086 // if any physical console input device has key input,
4087 // return the key and EFI_SUCCESS.
4089 ReturnStatus
= EFI_NOT_READY
;
4090 for (Index
= 0; Index
< Private
->CurrentNumberOfPointers
; Index
++) {
4092 Status
= Private
->PointerList
[Index
]->GetState (
4093 Private
->PointerList
[Index
],
4096 if (!EFI_ERROR (Status
)) {
4097 if (ReturnStatus
== EFI_NOT_READY
) {
4098 ReturnStatus
= EFI_SUCCESS
;
4101 if (CurrentState
.LeftButton
) {
4102 State
->LeftButton
= TRUE
;
4105 if (CurrentState
.RightButton
) {
4106 State
->RightButton
= TRUE
;
4109 if (CurrentState
.RelativeMovementX
!= 0 && Private
->PointerList
[Index
]->Mode
->ResolutionX
!= 0) {
4110 State
->RelativeMovementX
+= (CurrentState
.RelativeMovementX
* (INT32
) Private
->SimplePointerMode
.ResolutionX
) / (INT32
) Private
->PointerList
[Index
]->Mode
->ResolutionX
;
4113 if (CurrentState
.RelativeMovementY
!= 0 && Private
->PointerList
[Index
]->Mode
->ResolutionY
!= 0) {
4114 State
->RelativeMovementY
+= (CurrentState
.RelativeMovementY
* (INT32
) Private
->SimplePointerMode
.ResolutionY
) / (INT32
) Private
->PointerList
[Index
]->Mode
->ResolutionY
;
4117 if (CurrentState
.RelativeMovementZ
!= 0 && Private
->PointerList
[Index
]->Mode
->ResolutionZ
!= 0) {
4118 State
->RelativeMovementZ
+= (CurrentState
.RelativeMovementZ
* (INT32
) Private
->SimplePointerMode
.ResolutionZ
) / (INT32
) Private
->PointerList
[Index
]->Mode
->ResolutionZ
;
4120 } else if (Status
== EFI_DEVICE_ERROR
) {
4121 ReturnStatus
= EFI_DEVICE_ERROR
;
4125 return ReturnStatus
;
4130 Reads the next keystroke from the input device. The WaitForKey Event can
4131 be used to test for existance of a keystroke via WaitForEvent () call.
4132 If the ConIn is password locked make it look like no keystroke is availible
4134 @param This A pointer to protocol instance.
4135 @param State A pointer to state information on the pointer device
4137 @retval EFI_SUCCESS The keystroke information was returned in State.
4138 @retval EFI_NOT_READY There was no keystroke data availiable.
4139 @retval EFI_DEVICE_ERROR The keydtroke information was not returned due
4145 ConSplitterSimplePointerGetState (
4146 IN EFI_SIMPLE_POINTER_PROTOCOL
*This
,
4147 IN OUT EFI_SIMPLE_POINTER_STATE
*State
4150 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
4152 Private
= TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_SIMPLE_POINTER_THIS (This
);
4153 if (Private
->PasswordEnabled
) {
4155 // If StdIn Locked return not ready
4157 return EFI_NOT_READY
;
4160 Private
->InputEventSignalState
= FALSE
;
4162 return ConSplitterSimplePointerPrivateGetState (Private
, State
);
4167 This event agregates all the events of the ConIn devices in the spliter.
4168 If the ConIn is password locked then return.
4169 If any events of physical ConIn devices are signaled, signal the ConIn
4170 spliter event. This will cause the calling code to call
4171 ConSplitterTextInReadKeyStroke ().
4173 @param Event The Event assoicated with callback.
4174 @param Context Context registered when Event was created.
4179 ConSplitterSimplePointerWaitForInput (
4185 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
4188 Private
= (TEXT_IN_SPLITTER_PRIVATE_DATA
*) Context
;
4189 if (Private
->PasswordEnabled
) {
4191 // If StdIn Locked return not ready
4197 // if InputEventSignalState is flagged before, and not cleared by Reset() or ReadKeyStroke()
4199 if (Private
->InputEventSignalState
) {
4200 gBS
->SignalEvent (Event
);
4204 // if any physical console input device has key input, signal the event.
4206 for (Index
= 0; Index
< Private
->CurrentNumberOfPointers
; Index
++) {
4207 Status
= gBS
->CheckEvent (Private
->PointerList
[Index
]->WaitForInput
);
4208 if (!EFI_ERROR (Status
)) {
4209 gBS
->SignalEvent (Event
);
4210 Private
->InputEventSignalState
= TRUE
;
4216 Resets the pointer device hardware.
4218 @param This Protocol instance pointer.
4219 @param ExtendedVerification Driver may perform diagnostics on reset.
4221 @retval EFI_SUCCESS The device was reset.
4222 @retval EFI_DEVICE_ERROR The device is not functioning correctly and
4228 ConSplitterAbsolutePointerReset (
4229 IN EFI_ABSOLUTE_POINTER_PROTOCOL
*This
,
4230 IN BOOLEAN ExtendedVerification
4234 EFI_STATUS ReturnStatus
;
4235 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
4238 Private
= TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_ABSOLUTE_POINTER_THIS (This
);
4240 Private
->AbsoluteInputEventSignalState
= FALSE
;
4242 if (Private
->CurrentNumberOfAbsolutePointers
== 0) {
4246 // return the worst status met
4248 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfAbsolutePointers
; Index
++) {
4249 Status
= Private
->AbsolutePointerList
[Index
]->Reset (
4250 Private
->AbsolutePointerList
[Index
],
4251 ExtendedVerification
4253 if (EFI_ERROR (Status
)) {
4254 ReturnStatus
= Status
;
4258 return ReturnStatus
;
4263 Retrieves the current state of a pointer device.
4265 @param This Protocol instance pointer.
4266 @param State A pointer to the state information on the
4269 @retval EFI_SUCCESS The state of the pointer device was returned in
4271 @retval EFI_NOT_READY The state of the pointer device has not changed
4272 since the last call to GetState().
4273 @retval EFI_DEVICE_ERROR A device error occurred while attempting to
4274 retrieve the pointer device's current state.
4279 ConSplitterAbsolutePointerGetState (
4280 IN EFI_ABSOLUTE_POINTER_PROTOCOL
*This
,
4281 IN OUT EFI_ABSOLUTE_POINTER_STATE
*State
4284 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
4286 EFI_STATUS ReturnStatus
;
4288 EFI_ABSOLUTE_POINTER_STATE CurrentState
;
4291 Private
= TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_ABSOLUTE_POINTER_THIS (This
);
4292 if (Private
->PasswordEnabled
) {
4294 // If StdIn Locked return not ready
4296 return EFI_NOT_READY
;
4299 Private
->AbsoluteInputEventSignalState
= FALSE
;
4301 State
->CurrentX
= 0;
4302 State
->CurrentY
= 0;
4303 State
->CurrentZ
= 0;
4304 State
->ActiveButtons
= 0;
4307 // if no physical pointer device exists, return EFI_NOT_READY;
4308 // if any physical pointer device has changed state,
4309 // return the state and EFI_SUCCESS.
4311 ReturnStatus
= EFI_NOT_READY
;
4312 for (Index
= 0; Index
< Private
->CurrentNumberOfAbsolutePointers
; Index
++) {
4314 Status
= Private
->AbsolutePointerList
[Index
]->GetState (
4315 Private
->AbsolutePointerList
[Index
],
4318 if (!EFI_ERROR (Status
)) {
4319 if (ReturnStatus
== EFI_NOT_READY
) {
4320 ReturnStatus
= EFI_SUCCESS
;
4323 State
->ActiveButtons
= CurrentState
.ActiveButtons
;
4325 if (!(Private
->AbsolutePointerMode
.AbsoluteMinX
== 0 && Private
->AbsolutePointerMode
.AbsoluteMaxX
== 0)) {
4326 State
->CurrentX
= CurrentState
.CurrentX
;
4328 if (!(Private
->AbsolutePointerMode
.AbsoluteMinY
== 0 && Private
->AbsolutePointerMode
.AbsoluteMaxY
== 0)) {
4329 State
->CurrentY
= CurrentState
.CurrentY
;
4331 if (!(Private
->AbsolutePointerMode
.AbsoluteMinZ
== 0 && Private
->AbsolutePointerMode
.AbsoluteMaxZ
== 0)) {
4332 State
->CurrentZ
= CurrentState
.CurrentZ
;
4335 } else if (Status
== EFI_DEVICE_ERROR
) {
4336 ReturnStatus
= EFI_DEVICE_ERROR
;
4340 return ReturnStatus
;
4345 This event agregates all the events of the pointer devices in the splitter.
4346 If the ConIn is password locked then return.
4347 If any events of physical pointer devices are signaled, signal the pointer
4348 splitter event. This will cause the calling code to call
4349 ConSplitterAbsolutePointerGetState ().
4351 @param Event The Event assoicated with callback.
4352 @param Context Context registered when Event was created.
4357 ConSplitterAbsolutePointerWaitForInput (
4363 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
4366 Private
= (TEXT_IN_SPLITTER_PRIVATE_DATA
*) Context
;
4367 if (Private
->PasswordEnabled
) {
4369 // If StdIn Locked return not ready
4375 // if AbsoluteInputEventSignalState is flagged before,
4376 // and not cleared by Reset() or GetState(), signal it
4378 if (Private
->AbsoluteInputEventSignalState
) {
4379 gBS
->SignalEvent (Event
);
4383 // if any physical console input device has key input, signal the event.
4385 for (Index
= 0; Index
< Private
->CurrentNumberOfAbsolutePointers
; Index
++) {
4386 Status
= gBS
->CheckEvent (Private
->AbsolutePointerList
[Index
]->WaitForInput
);
4387 if (!EFI_ERROR (Status
)) {
4388 gBS
->SignalEvent (Event
);
4389 Private
->AbsoluteInputEventSignalState
= TRUE
;
4396 Reset the text output device hardware and optionaly run diagnostics
4398 @param This Protocol instance pointer.
4399 @param ExtendedVerification Driver may perform more exhaustive verfication
4400 operation of the device during reset.
4402 @retval EFI_SUCCESS The text output device was reset.
4403 @retval EFI_DEVICE_ERROR The text output device is not functioning
4404 correctly and could not be reset.
4409 ConSplitterTextOutReset (
4410 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4411 IN BOOLEAN ExtendedVerification
4415 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4417 EFI_STATUS ReturnStatus
;
4419 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4422 // return the worst status met
4424 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
4426 if (Private
->TextOutList
[Index
].TextOutEnabled
) {
4428 Status
= Private
->TextOutList
[Index
].TextOut
->Reset (
4429 Private
->TextOutList
[Index
].TextOut
,
4430 ExtendedVerification
4432 if (EFI_ERROR (Status
)) {
4433 ReturnStatus
= Status
;
4438 This
->SetAttribute (This
, EFI_TEXT_ATTR (This
->Mode
->Attribute
& 0x0F, EFI_BLACK
));
4440 Status
= DevNullTextOutSetMode (Private
, 0);
4441 if (EFI_ERROR (Status
)) {
4442 ReturnStatus
= Status
;
4445 return ReturnStatus
;
4450 Write a Unicode string to the output device.
4452 @param This Protocol instance pointer.
4453 @param WString The NULL-terminated Unicode string to be
4454 displayed on the output device(s). All output
4455 devices must also support the Unicode drawing
4456 defined in this file.
4458 @retval EFI_SUCCESS The string was output to the device.
4459 @retval EFI_DEVICE_ERROR The device reported an error while attempting to
4461 @retval EFI_UNSUPPORTED The output device's mode is not currently in a
4463 @retval EFI_WARN_UNKNOWN_GLYPH This warning code indicates that some of the
4464 characters in the Unicode string could not be
4465 rendered and were skipped.
4470 ConSplitterTextOutOutputString (
4471 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4476 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4478 UINTN BackSpaceCount
;
4479 EFI_STATUS ReturnStatus
;
4480 CHAR16
*TargetString
;
4482 This
->SetAttribute (This
, This
->Mode
->Attribute
);
4484 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4487 for (TargetString
= WString
; *TargetString
!= L
'\0'; TargetString
++) {
4488 if (*TargetString
== CHAR_BACKSPACE
) {
4494 if (BackSpaceCount
== 0) {
4495 TargetString
= WString
;
4497 TargetString
= AllocatePool (sizeof (CHAR16
) * (StrLen (WString
) + BackSpaceCount
+ 1));
4498 StrCpy (TargetString
, WString
);
4501 // return the worst status met
4503 Status
= DevNullTextOutOutputString (Private
, TargetString
);
4504 if (EFI_ERROR (Status
)) {
4505 ReturnStatus
= Status
;
4508 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
4510 if (Private
->TextOutList
[Index
].TextOutEnabled
) {
4511 Status
= Private
->TextOutList
[Index
].TextOut
->OutputString (
4512 Private
->TextOutList
[Index
].TextOut
,
4515 if (EFI_ERROR (Status
)) {
4516 ReturnStatus
= Status
;
4521 if (BackSpaceCount
> 0) {
4522 FreePool (TargetString
);
4525 return ReturnStatus
;
4530 Verifies that all characters in a Unicode string can be output to the
4533 @param This Protocol instance pointer.
4534 @param WString The NULL-terminated Unicode string to be
4535 examined for the output device(s).
4537 @retval EFI_SUCCESS The device(s) are capable of rendering the
4539 @retval EFI_UNSUPPORTED Some of the characters in the Unicode string
4540 cannot be rendered by one or more of the output
4541 devices mapped by the EFI handle.
4546 ConSplitterTextOutTestString (
4547 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4552 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4554 EFI_STATUS ReturnStatus
;
4556 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4559 // return the worst status met
4561 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
4562 if (Private
->TextOutList
[Index
].TextOutEnabled
) {
4563 Status
= Private
->TextOutList
[Index
].TextOut
->TestString (
4564 Private
->TextOutList
[Index
].TextOut
,
4567 if (EFI_ERROR (Status
)) {
4568 ReturnStatus
= Status
;
4573 // There is no DevNullTextOutTestString () since a Unicode buffer would
4574 // always return EFI_SUCCESS.
4575 // ReturnStatus will be EFI_SUCCESS if no consoles are present
4577 return ReturnStatus
;
4582 Returns information for an available text mode that the output device(s)
4585 @param This Protocol instance pointer.
4586 @param ModeNumber The mode number to return information on.
4587 @param Columns Returns the columns of the text output device
4588 for the requested ModeNumber.
4589 @param Rows Returns the rows of the text output device
4590 for the requested ModeNumber.
4592 @retval EFI_SUCCESS The requested mode information was returned.
4593 @retval EFI_DEVICE_ERROR The device had an error and could not complete
4595 @retval EFI_UNSUPPORTED The mode number was not valid.
4600 ConSplitterTextOutQueryMode (
4601 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4602 IN UINTN ModeNumber
,
4607 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4609 INT32
*TextOutModeMap
;
4611 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4614 // Check whether param ModeNumber is valid.
4615 // ModeNumber should be within range 0 ~ MaxMode - 1.
4617 if ( (ModeNumber
> (UINTN
)(((UINT32
)-1)>>1)) ) {
4618 return EFI_UNSUPPORTED
;
4621 if ((INT32
) ModeNumber
>= This
->Mode
->MaxMode
) {
4622 return EFI_UNSUPPORTED
;
4626 // We get the available mode from mode intersection map if it's available
4628 if (Private
->TextOutModeMap
!= NULL
) {
4629 TextOutModeMap
= Private
->TextOutModeMap
+ Private
->TextOutListCount
* ModeNumber
;
4630 CurrentMode
= (UINTN
)(*TextOutModeMap
);
4631 *Columns
= Private
->TextOutQueryData
[CurrentMode
].Columns
;
4632 *Rows
= Private
->TextOutQueryData
[CurrentMode
].Rows
;
4634 *Columns
= Private
->TextOutQueryData
[ModeNumber
].Columns
;
4635 *Rows
= Private
->TextOutQueryData
[ModeNumber
].Rows
;
4638 if (*Columns
<= 0 && *Rows
<= 0) {
4639 return EFI_UNSUPPORTED
;
4648 Sets the output device(s) to a specified mode.
4650 @param This Protocol instance pointer.
4651 @param ModeNumber The mode number to set.
4653 @retval EFI_SUCCESS The requested text mode was set.
4654 @retval EFI_DEVICE_ERROR The device had an error and could not complete
4656 @retval EFI_UNSUPPORTED The mode number was not valid.
4661 ConSplitterTextOutSetMode (
4662 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4667 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4669 INT32
*TextOutModeMap
;
4670 EFI_STATUS ReturnStatus
;
4672 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4675 // Check whether param ModeNumber is valid.
4676 // ModeNumber should be within range 0 ~ MaxMode - 1.
4678 if ( (ModeNumber
> (UINTN
)(((UINT32
)-1)>>1)) ) {
4679 return EFI_UNSUPPORTED
;
4682 if ((INT32
) ModeNumber
>= This
->Mode
->MaxMode
) {
4683 return EFI_UNSUPPORTED
;
4686 // If the mode is being set to the curent mode, then just clear the screen and return.
4688 if (Private
->TextOutMode
.Mode
== (INT32
) ModeNumber
) {
4689 return ConSplitterTextOutClearScreen (This
);
4692 // return the worst status met
4694 TextOutModeMap
= Private
->TextOutModeMap
+ Private
->TextOutListCount
* ModeNumber
;
4695 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
4697 if (Private
->TextOutList
[Index
].TextOutEnabled
) {
4698 Status
= Private
->TextOutList
[Index
].TextOut
->SetMode (
4699 Private
->TextOutList
[Index
].TextOut
,
4700 TextOutModeMap
[Index
]
4703 // If this console device is based on a GOP or UGA device, then sync up the bitmap from
4704 // the GOP/UGA splitter and reclear the text portion of the display in the new mode.
4706 if ((Private
->TextOutList
[Index
].GraphicsOutput
!= NULL
) || (Private
->TextOutList
[Index
].UgaDraw
!= NULL
)) {
4707 Private
->TextOutList
[Index
].TextOut
->ClearScreen (Private
->TextOutList
[Index
].TextOut
);
4710 if (EFI_ERROR (Status
)) {
4711 ReturnStatus
= Status
;
4716 // The DevNull Console will support any possible mode as it allocates memory
4718 Status
= DevNullTextOutSetMode (Private
, ModeNumber
);
4719 if (EFI_ERROR (Status
)) {
4720 ReturnStatus
= Status
;
4723 return ReturnStatus
;
4728 Sets the background and foreground colors for the OutputString () and
4729 ClearScreen () functions.
4731 @param This Protocol instance pointer.
4732 @param Attribute The attribute to set. Bits 0..3 are the
4733 foreground color, and bits 4..6 are the
4734 background color. All other bits are undefined
4735 and must be zero. The valid Attributes are
4736 defined in this file.
4738 @retval EFI_SUCCESS The attribute was set.
4739 @retval EFI_DEVICE_ERROR The device had an error and could not complete
4741 @retval EFI_UNSUPPORTED The attribute requested is not defined.
4746 ConSplitterTextOutSetAttribute (
4747 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4752 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4754 EFI_STATUS ReturnStatus
;
4756 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4759 // Check whether param Attribute is valid.
4761 if ( (Attribute
> (UINTN
)(((UINT32
)-1)>>1)) ) {
4762 return EFI_UNSUPPORTED
;
4766 // return the worst status met
4768 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
4770 if (Private
->TextOutList
[Index
].TextOutEnabled
) {
4771 Status
= Private
->TextOutList
[Index
].TextOut
->SetAttribute (
4772 Private
->TextOutList
[Index
].TextOut
,
4775 if (EFI_ERROR (Status
)) {
4776 ReturnStatus
= Status
;
4781 Private
->TextOutMode
.Attribute
= (INT32
) Attribute
;
4783 return ReturnStatus
;
4788 Clears the output device(s) display to the currently selected background
4791 @param This Protocol instance pointer.
4793 @retval EFI_SUCCESS The operation completed successfully.
4794 @retval EFI_DEVICE_ERROR The device had an error and could not complete
4796 @retval EFI_UNSUPPORTED The output device is not in a valid text mode.
4801 ConSplitterTextOutClearScreen (
4802 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
4806 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4808 EFI_STATUS ReturnStatus
;
4810 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4813 // return the worst status met
4815 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
4817 if (Private
->TextOutList
[Index
].TextOutEnabled
) {
4818 Status
= Private
->TextOutList
[Index
].TextOut
->ClearScreen (Private
->TextOutList
[Index
].TextOut
);
4819 if (EFI_ERROR (Status
)) {
4820 ReturnStatus
= Status
;
4825 Status
= DevNullTextOutClearScreen (Private
);
4826 if (EFI_ERROR (Status
)) {
4827 ReturnStatus
= Status
;
4830 return ReturnStatus
;
4835 Sets the current coordinates of the cursor position
4837 @param This Protocol instance pointer.
4838 @param Column The column position to set the cursor to. Must be
4839 greater than or equal to zero and less than the
4840 number of columns by QueryMode ().
4841 @param Row The row position to set the cursor to. Must be
4842 greater than or equal to zero and less than the
4843 number of rows by QueryMode ().
4845 @retval EFI_SUCCESS The operation completed successfully.
4846 @retval EFI_DEVICE_ERROR The device had an error and could not complete
4848 @retval EFI_UNSUPPORTED The output device is not in a valid text mode,
4849 or the cursor position is invalid for the
4855 ConSplitterTextOutSetCursorPosition (
4856 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4862 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4864 EFI_STATUS ReturnStatus
;
4867 INT32
*TextOutModeMap
;
4871 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4872 TextOutModeMap
= NULL
;
4873 ModeNumber
= Private
->TextOutMode
.Mode
;
4876 // Get current MaxColumn and MaxRow from intersection map
4878 if (Private
->TextOutModeMap
!= NULL
) {
4879 TextOutModeMap
= Private
->TextOutModeMap
+ Private
->TextOutListCount
* ModeNumber
;
4880 CurrentMode
= *TextOutModeMap
;
4882 CurrentMode
= ModeNumber
;
4885 MaxColumn
= Private
->TextOutQueryData
[CurrentMode
].Columns
;
4886 MaxRow
= Private
->TextOutQueryData
[CurrentMode
].Rows
;
4888 if (Column
>= MaxColumn
|| Row
>= MaxRow
) {
4889 return EFI_UNSUPPORTED
;
4892 // return the worst status met
4894 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
4896 if (Private
->TextOutList
[Index
].TextOutEnabled
) {
4897 Status
= Private
->TextOutList
[Index
].TextOut
->SetCursorPosition (
4898 Private
->TextOutList
[Index
].TextOut
,
4902 if (EFI_ERROR (Status
)) {
4903 ReturnStatus
= Status
;
4908 DevNullTextOutSetCursorPosition (Private
, Column
, Row
);
4910 return ReturnStatus
;
4915 Makes the cursor visible or invisible
4917 @param This Protocol instance pointer.
4918 @param Visible If TRUE, the cursor is set to be visible. If
4919 FALSE, the cursor is set to be invisible.
4921 @retval EFI_SUCCESS The operation completed successfully.
4922 @retval EFI_DEVICE_ERROR The device had an error and could not complete
4923 the request, or the device does not support
4924 changing the cursor mode.
4925 @retval EFI_UNSUPPORTED The output device is not in a valid text mode.
4930 ConSplitterTextOutEnableCursor (
4931 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4936 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4938 EFI_STATUS ReturnStatus
;
4940 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4943 // return the worst status met
4945 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
4947 if (Private
->TextOutList
[Index
].TextOutEnabled
) {
4948 Status
= Private
->TextOutList
[Index
].TextOut
->EnableCursor (
4949 Private
->TextOutList
[Index
].TextOut
,
4952 if (EFI_ERROR (Status
)) {
4953 ReturnStatus
= Status
;
4958 DevNullTextOutEnableCursor (Private
, Visible
);
4960 return ReturnStatus
;