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
,
436 // Create virtual device handle for ConIn Splitter
438 Status
= ConSplitterTextInConstructor (&mConIn
);
439 if (!EFI_ERROR (Status
)) {
440 Status
= gBS
->InstallMultipleProtocolInterfaces (
441 &mConIn
.VirtualHandle
,
442 &gEfiSimpleTextInProtocolGuid
,
444 &gEfiSimpleTextInputExProtocolGuid
,
446 &gEfiSimplePointerProtocolGuid
,
447 &mConIn
.SimplePointer
,
448 &gEfiAbsolutePointerProtocolGuid
,
449 &mConIn
.AbsolutePointer
,
452 if (!EFI_ERROR (Status
)) {
454 // Update the EFI System Table with new virtual console
455 // and update the pointer to Simple Text Input protocol.
457 gST
->ConsoleInHandle
= mConIn
.VirtualHandle
;
458 gST
->ConIn
= &mConIn
.TextIn
;
462 // Create virtual device handle for ConOut Splitter
464 Status
= ConSplitterTextOutConstructor (&mConOut
);
465 if (!EFI_ERROR (Status
)) {
466 if (!FeaturePcdGet (PcdConOutGopSupport
)) {
468 // If Graphics Outpurt protocol not supported, UGA Draw protocol is installed
469 // on the virtual handle.
471 Status
= gBS
->InstallMultipleProtocolInterfaces (
472 &mConOut
.VirtualHandle
,
473 &gEfiSimpleTextOutProtocolGuid
,
475 &gEfiUgaDrawProtocolGuid
,
477 &gEfiConsoleControlProtocolGuid
,
478 &mConOut
.ConsoleControl
,
481 } else if (!FeaturePcdGet (PcdConOutUgaSupport
)) {
483 // If UGA Draw protocol not supported, Graphics Output Protocol is installed
484 // on virtual handle.
486 Status
= gBS
->InstallMultipleProtocolInterfaces (
487 &mConOut
.VirtualHandle
,
488 &gEfiSimpleTextOutProtocolGuid
,
490 &gEfiGraphicsOutputProtocolGuid
,
491 &mConOut
.GraphicsOutput
,
492 &gEfiConsoleControlProtocolGuid
,
493 &mConOut
.ConsoleControl
,
498 // Boot Graphics Output protocol and UGA Draw protocol are supported,
499 // both they will be installed on virtual handle.
501 Status
= gBS
->InstallMultipleProtocolInterfaces (
502 &mConOut
.VirtualHandle
,
503 &gEfiSimpleTextOutProtocolGuid
,
505 &gEfiGraphicsOutputProtocolGuid
,
506 &mConOut
.GraphicsOutput
,
507 &gEfiUgaDrawProtocolGuid
,
509 &gEfiConsoleControlProtocolGuid
,
510 &mConOut
.ConsoleControl
,
515 if (!EFI_ERROR (Status
)) {
517 // Update the EFI System Table with new virtual console
518 // and Update the pointer to Text Output protocol.
520 gST
->ConsoleOutHandle
= mConOut
.VirtualHandle
;
521 gST
->ConOut
= &mConOut
.TextOut
;
526 // Update the CRC32 in the EFI System Table header
529 gBS
->CalculateCrc32 (
540 Construct console input devices' private data.
542 @param ConInPrivate A pointer to the TEXT_IN_SPLITTER_PRIVATE_DATA
545 @retval EFI_OUT_OF_RESOURCES Out of resources.
546 @retval EFI_SUCCESS Text Input Devcie's private data has been constructed.
547 @retval other Failed to construct private data.
551 ConSplitterTextInConstructor (
552 TEXT_IN_SPLITTER_PRIVATE_DATA
*ConInPrivate
558 // Allocate buffer for Simple Text Input device
560 Status
= ConSplitterGrowBuffer (
561 sizeof (EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*),
562 &ConInPrivate
->TextInListCount
,
563 (VOID
**) &ConInPrivate
->TextInList
565 if (EFI_ERROR (Status
)) {
566 return EFI_OUT_OF_RESOURCES
;
569 // Create Event to support locking StdIn Device
571 Status
= gBS
->CreateEvent (
572 EVT_TIMER
| EVT_NOTIFY_SIGNAL
,
574 ConSpliterConsoleControlLockStdInEvent
,
576 &ConInPrivate
->LockEvent
578 ASSERT_EFI_ERROR (Status
);
580 // Create Event to wait for a key
582 Status
= gBS
->CreateEvent (
585 ConSplitterTextInWaitForKey
,
587 &ConInPrivate
->TextIn
.WaitForKey
589 ASSERT_EFI_ERROR (Status
);
592 // Allocate buffer for Simple Text Input Ex device
594 Status
= ConSplitterGrowBuffer (
595 sizeof (EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*),
596 &ConInPrivate
->TextInExListCount
,
597 (VOID
**) &ConInPrivate
->TextInExList
599 if (EFI_ERROR (Status
)) {
600 return EFI_OUT_OF_RESOURCES
;
603 // Create Event to wait for a key Ex
605 Status
= gBS
->CreateEvent (
608 ConSplitterTextInWaitForKey
,
610 &ConInPrivate
->TextInEx
.WaitForKeyEx
612 ASSERT_EFI_ERROR (Status
);
614 InitializeListHead (&ConInPrivate
->NotifyList
);
616 ConInPrivate
->AbsolutePointer
.Mode
= &ConInPrivate
->AbsolutePointerMode
;
618 // Allocate buffer for Absolute Pointer device
620 Status
= ConSplitterGrowBuffer (
621 sizeof (EFI_ABSOLUTE_POINTER_PROTOCOL
*),
622 &ConInPrivate
->AbsolutePointerListCount
,
623 (VOID
**) &ConInPrivate
->AbsolutePointerList
625 if (EFI_ERROR (Status
)) {
626 return EFI_OUT_OF_RESOURCES
;
629 // Create Event to wait for device input for Absolute pointer device
631 Status
= gBS
->CreateEvent (
634 ConSplitterAbsolutePointerWaitForInput
,
636 &ConInPrivate
->AbsolutePointer
.WaitForInput
638 ASSERT_EFI_ERROR (Status
);
640 ConInPrivate
->SimplePointer
.Mode
= &ConInPrivate
->SimplePointerMode
;
642 // Allocate buffer for Simple Pointer device
644 Status
= ConSplitterGrowBuffer (
645 sizeof (EFI_SIMPLE_POINTER_PROTOCOL
*),
646 &ConInPrivate
->PointerListCount
,
647 (VOID
**) &ConInPrivate
->PointerList
649 if (EFI_ERROR (Status
)) {
650 return EFI_OUT_OF_RESOURCES
;
653 // Create Event to wait for device input for Simple pointer device
655 Status
= gBS
->CreateEvent (
658 ConSplitterSimplePointerWaitForInput
,
660 &ConInPrivate
->SimplePointer
.WaitForInput
667 Construct console output devices' private data.
669 @param ConOutPrivate A pointer to the TEXT_OUT_SPLITTER_PRIVATE_DATA
672 @retval EFI_OUT_OF_RESOURCES Out of resources.
673 @retval EFI_SUCCESS Text Input Devcie's private data has been constructed.
677 ConSplitterTextOutConstructor (
678 TEXT_OUT_SPLITTER_PRIVATE_DATA
*ConOutPrivate
682 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*Info
;
685 // Copy protocols template
687 if (FeaturePcdGet (PcdConOutUgaSupport
)) {
688 CopyMem (&ConOutPrivate
->UgaDraw
, &mUgaDrawProtocolTemplate
, sizeof (EFI_UGA_DRAW_PROTOCOL
));
690 if (FeaturePcdGet (PcdConOutGopSupport
)) {
691 CopyMem (&ConOutPrivate
->GraphicsOutput
, &mGraphicsOutputProtocolTemplate
, sizeof (EFI_GRAPHICS_OUTPUT_PROTOCOL
));
695 // Initilize console output splitter's private data.
697 ConOutPrivate
->TextOut
.Mode
= &ConOutPrivate
->TextOutMode
;
700 // When new console device is added, the new mode will be set later,
701 // so put current mode back to init state.
703 ConOutPrivate
->TextOutMode
.Mode
= 0xFF;
705 // Allocate buffer for Console Out device
707 Status
= ConSplitterGrowBuffer (
708 sizeof (TEXT_OUT_AND_GOP_DATA
),
709 &ConOutPrivate
->TextOutListCount
,
710 (VOID
**) &ConOutPrivate
->TextOutList
712 if (EFI_ERROR (Status
)) {
713 return EFI_OUT_OF_RESOURCES
;
716 // Allocate buffer for Text Out query data
718 Status
= ConSplitterGrowBuffer (
719 sizeof (TEXT_OUT_SPLITTER_QUERY_DATA
),
720 &ConOutPrivate
->TextOutQueryDataCount
,
721 (VOID
**) &ConOutPrivate
->TextOutQueryData
723 if (EFI_ERROR (Status
)) {
724 return EFI_OUT_OF_RESOURCES
;
728 // Setup the DevNullTextOut console to 80 x 25
730 ConOutPrivate
->TextOutQueryData
[0].Columns
= 80;
731 ConOutPrivate
->TextOutQueryData
[0].Rows
= 25;
732 DevNullTextOutSetMode (ConOutPrivate
, 0);
734 if (FeaturePcdGet (PcdConOutUgaSupport
)) {
736 // Setup the DevNullUgaDraw to 800 x 600 x 32 bits per pixel, 60Hz.
738 ConSpliterUgaDrawSetMode (&ConOutPrivate
->UgaDraw
, 800, 600, 32, 60);
740 if (FeaturePcdGet (PcdConOutGopSupport
)) {
742 // Setup resource for mode information in Graphics Output Protocol interface
744 if ((ConOutPrivate
->GraphicsOutput
.Mode
= AllocateZeroPool (sizeof (EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE
))) == NULL
) {
745 return EFI_OUT_OF_RESOURCES
;
747 if ((ConOutPrivate
->GraphicsOutput
.Mode
->Info
= AllocateZeroPool (sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
))) == NULL
) {
748 return EFI_OUT_OF_RESOURCES
;
751 // Setup the DevNullGraphicsOutput to 800 x 600 x 32 bits per pixel
752 // DevNull will be updated to user-defined mode after driver has started.
754 if ((ConOutPrivate
->GraphicsOutputModeBuffer
= AllocateZeroPool (sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
))) == NULL
) {
755 return EFI_OUT_OF_RESOURCES
;
757 Info
= &ConOutPrivate
->GraphicsOutputModeBuffer
[0];
759 Info
->HorizontalResolution
= 800;
760 Info
->VerticalResolution
= 600;
761 Info
->PixelFormat
= PixelBltOnly
;
762 Info
->PixelsPerScanLine
= 800;
763 CopyMem (ConOutPrivate
->GraphicsOutput
.Mode
->Info
, Info
, sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
));
764 ConOutPrivate
->GraphicsOutput
.Mode
->SizeOfInfo
= sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
);
767 // Initialize the following items, theset items remain unchanged in GraphicsOutput->SetMode()
768 // GraphicsOutputMode->FrameBufferBase, GraphicsOutputMode->FrameBufferSize
770 ConOutPrivate
->GraphicsOutput
.Mode
->FrameBufferBase
= (EFI_PHYSICAL_ADDRESS
) (UINTN
) NULL
;
771 ConOutPrivate
->GraphicsOutput
.Mode
->FrameBufferSize
= 0;
773 ConOutPrivate
->GraphicsOutput
.Mode
->MaxMode
= 1;
775 // Initial current mode to unknown state, and then set to mode 0
777 ConOutPrivate
->GraphicsOutput
.Mode
->Mode
= 0xffff;
778 ConOutPrivate
->GraphicsOutput
.SetMode (&ConOutPrivate
->GraphicsOutput
, 0);
786 Test to see if the specified protocol could be supported on the specified device.
788 @param This Driver Binding protocol pointer.
789 @param ControllerHandle Handle of device to test.
790 @param Guid The specified protocol.
792 @retval EFI_SUCCESS The specified protocol is supported on this device.
793 @retval EFI_UNSUPPORTED The specified protocol attempts to be installed on virtul handle.
794 @retval other Failed to open specified protocol on this device.
798 ConSplitterSupported (
799 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
800 IN EFI_HANDLE ControllerHandle
,
808 // Make sure the Console Splitter does not attempt to attach to itself
810 if (ControllerHandle
== mConIn
.VirtualHandle
||
811 ControllerHandle
== mConOut
.VirtualHandle
||
812 ControllerHandle
== mStdErr
.VirtualHandle
814 return EFI_UNSUPPORTED
;
818 // Check to see whether the specific protocol could be opened BY_DRIVER
820 Status
= gBS
->OpenProtocol (
824 This
->DriverBindingHandle
,
826 EFI_OPEN_PROTOCOL_BY_DRIVER
829 if (EFI_ERROR (Status
)) {
836 This
->DriverBindingHandle
,
844 Test to see if Console In Device could be supported on the Controller.
846 @param This Driver Binding protocol instance pointer.
847 @param ControllerHandle Handle of device to test.
848 @param RemainingDevicePath Optional parameter use to pick a specific child
851 @retval EFI_SUCCESS This driver supports this device.
852 @retval other This driver does not support this device.
857 ConSplitterConInDriverBindingSupported (
858 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
859 IN EFI_HANDLE ControllerHandle
,
860 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
863 return ConSplitterSupported (
866 &gEfiConsoleInDeviceGuid
871 Test to see if Simple Pointer protocol could be supported on the Controller.
873 @param This Driver Binding protocol instance pointer.
874 @param ControllerHandle Handle of device to test.
875 @param RemainingDevicePath Optional parameter use to pick a specific child
878 @retval EFI_SUCCESS This driver supports this device.
879 @retval other This driver does not support this device.
884 ConSplitterSimplePointerDriverBindingSupported (
885 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
886 IN EFI_HANDLE ControllerHandle
,
887 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
890 return ConSplitterSupported (
893 &gEfiSimplePointerProtocolGuid
898 Test to see if Absolute Pointer protocol could be supported on the Controller.
900 @param This Driver Binding protocol instance pointer.
901 @param ControllerHandle Handle of device to test.
902 @param RemainingDevicePath Optional parameter use to pick a specific child
905 @retval EFI_SUCCESS This driver supports this device.
906 @retval other This driver does not support this device.
911 ConSplitterAbsolutePointerDriverBindingSupported (
912 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
913 IN EFI_HANDLE ControllerHandle
,
914 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
917 return ConSplitterSupported (
920 &gEfiAbsolutePointerProtocolGuid
926 Test to see if Console Out Device could be supported on the Controller.
928 @param This Driver Binding protocol instance pointer.
929 @param ControllerHandle Handle of device to test.
930 @param RemainingDevicePath Optional parameter use to pick a specific child
933 @retval EFI_SUCCESS This driver supports this device.
934 @retval other This driver does not support this device.
939 ConSplitterConOutDriverBindingSupported (
940 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
941 IN EFI_HANDLE ControllerHandle
,
942 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
945 return ConSplitterSupported (
948 &gEfiConsoleOutDeviceGuid
953 Test to see if Standard Error Device could be supported on the Controller.
955 @param This Driver Binding protocol instance pointer.
956 @param ControllerHandle Handle of device to test.
957 @param RemainingDevicePath Optional parameter use to pick a specific child
960 @retval EFI_SUCCESS This driver supports this device.
961 @retval other This driver does not support this device.
966 ConSplitterStdErrDriverBindingSupported (
967 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
968 IN EFI_HANDLE ControllerHandle
,
969 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
972 return ConSplitterSupported (
975 &gEfiStandardErrorDeviceGuid
981 Start ConSplitter on devcie handle by opening Console Device Guid on device handle
982 and the console virtual handle. And Get the console interface on controller handle.
984 @param This Driver Binding protocol instance pointer.
985 @param ControllerHandle Handle of device.
986 @param ConSplitterVirtualHandle Console virtual Handle.
987 @param DeviceGuid The specified Console Device, such as ConInDev,
989 @param InterfaceGuid The specified protocol to be opened.
990 @param Interface Protocol interface returned.
992 @retval EFI_SUCCESS This driver supports this device.
993 @retval other Failed to open the specified Console Device Guid
994 or specified protocol.
999 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1000 IN EFI_HANDLE ControllerHandle
,
1001 IN EFI_HANDLE ConSplitterVirtualHandle
,
1002 IN EFI_GUID
*DeviceGuid
,
1003 IN EFI_GUID
*InterfaceGuid
,
1004 OUT VOID
**Interface
1011 // Check to see whether the ControllerHandle has the DeviceGuid on it.
1013 Status
= gBS
->OpenProtocol (
1017 This
->DriverBindingHandle
,
1019 EFI_OPEN_PROTOCOL_BY_DRIVER
1021 if (EFI_ERROR (Status
)) {
1026 // Create virtual handle and open DeviceGuid on the virtul handle.
1028 Status
= gBS
->OpenProtocol (
1032 This
->DriverBindingHandle
,
1033 ConSplitterVirtualHandle
,
1034 EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
1036 if (EFI_ERROR (Status
)) {
1041 // Open InterfaceGuid on the virtul handle.
1043 Status
= gBS
->OpenProtocol (
1047 This
->DriverBindingHandle
,
1048 ConSplitterVirtualHandle
,
1049 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1052 if (!EFI_ERROR (Status
)) {
1057 // close the DeviceGuid on ConSplitter VirtualHandle.
1059 gBS
->CloseProtocol (
1062 This
->DriverBindingHandle
,
1063 ConSplitterVirtualHandle
1068 // close the DeviceGuid on ControllerHandle.
1070 gBS
->CloseProtocol (
1073 This
->DriverBindingHandle
,
1082 Start Console In Consplitter on device handle.
1084 @param This Driver Binding protocol instance pointer.
1085 @param ControllerHandle Handle of device to bind driver to.
1086 @param RemainingDevicePath Optional parameter use to pick a specific child
1089 @retval EFI_SUCCESS Console In Consplitter is added to ControllerHandle.
1090 @retval other Console In Consplitter does not support this device.
1095 ConSplitterConInDriverBindingStart (
1096 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1097 IN EFI_HANDLE ControllerHandle
,
1098 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
1102 EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*TextIn
;
1103 EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*TextInEx
;
1106 // Start ConSplitter on ControllerHandle, and create the virtual
1107 // agrogated console device on first call Start for a SimpleTextIn handle.
1109 Status
= ConSplitterStart (
1112 mConIn
.VirtualHandle
,
1113 &gEfiConsoleInDeviceGuid
,
1114 &gEfiSimpleTextInProtocolGuid
,
1117 if (EFI_ERROR (Status
)) {
1122 // Add this device into Text In devices list.
1124 Status
= ConSplitterTextInAddDevice (&mConIn
, TextIn
);
1125 if (EFI_ERROR (Status
)) {
1129 Status
= gBS
->OpenProtocol (
1131 &gEfiSimpleTextInputExProtocolGuid
,
1132 (VOID
**) &TextInEx
,
1133 This
->DriverBindingHandle
,
1134 mConIn
.VirtualHandle
,
1135 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1137 if (!EFI_ERROR (Status
)) {
1139 // If Simple Text Input Ex protocol exists,
1140 // add this device into Text In Ex devices list.
1142 Status
= ConSplitterTextInExAddDevice (&mConIn
, TextInEx
);
1150 Start Simple Pointer Consplitter on device handle.
1152 @param This Driver Binding protocol instance pointer.
1153 @param ControllerHandle Handle of device to bind driver to.
1154 @param RemainingDevicePath Optional parameter use to pick a specific child
1157 @retval EFI_SUCCESS Simple Pointer Consplitter is added to ControllerHandle.
1158 @retval other Simple Pointer Consplitter does not support this device.
1163 ConSplitterSimplePointerDriverBindingStart (
1164 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1165 IN EFI_HANDLE ControllerHandle
,
1166 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
1170 EFI_SIMPLE_POINTER_PROTOCOL
*SimplePointer
;
1173 // Start ConSplitter on ControllerHandle, and create the virtual
1174 // agrogated console device on first call Start for a SimplePointer handle.
1176 Status
= ConSplitterStart (
1179 mConIn
.VirtualHandle
,
1180 &gEfiSimplePointerProtocolGuid
,
1181 &gEfiSimplePointerProtocolGuid
,
1182 (VOID
**) &SimplePointer
1184 if (EFI_ERROR (Status
)) {
1189 // Add this devcie into Simple Pointer devices list.
1191 return ConSplitterSimplePointerAddDevice (&mConIn
, SimplePointer
);
1196 Start Absolute Pointer Consplitter on device handle.
1198 @param This Driver Binding protocol instance pointer.
1199 @param ControllerHandle Handle of device to bind driver to.
1200 @param RemainingDevicePath Optional parameter use to pick a specific child
1203 @retval EFI_SUCCESS Absolute Pointer Consplitter is added to ControllerHandle.
1204 @retval other Absolute Pointer Consplitter does not support this device.
1209 ConSplitterAbsolutePointerDriverBindingStart (
1210 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1211 IN EFI_HANDLE ControllerHandle
,
1212 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
1216 EFI_ABSOLUTE_POINTER_PROTOCOL
*AbsolutePointer
;
1219 // Start ConSplitter on ControllerHandle, and create the virtual
1220 // agrogated console device on first call Start for a AbsolutePointer handle.
1222 Status
= ConSplitterStart (
1225 mConIn
.VirtualHandle
,
1226 &gEfiAbsolutePointerProtocolGuid
,
1227 &gEfiAbsolutePointerProtocolGuid
,
1228 (VOID
**) &AbsolutePointer
1231 if (EFI_ERROR (Status
)) {
1236 // Add this devcie into Absolute Pointer devices list.
1238 return ConSplitterAbsolutePointerAddDevice (&mConIn
, AbsolutePointer
);
1243 Start Console Out Consplitter on device handle.
1245 @param This Driver Binding protocol instance pointer.
1246 @param ControllerHandle Handle of device to bind driver to.
1247 @param RemainingDevicePath Optional parameter use to pick a specific child
1250 @retval EFI_SUCCESS Console Out Consplitter is added to ControllerHandle.
1251 @retval other Console Out Consplitter does not support this device.
1256 ConSplitterConOutDriverBindingStart (
1257 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1258 IN EFI_HANDLE ControllerHandle
,
1259 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
1263 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
;
1264 EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
;
1265 EFI_UGA_DRAW_PROTOCOL
*UgaDraw
;
1267 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*Info
;
1270 // Start ConSplitter on ControllerHandle, and create the virtual
1271 // agrogated console device on first call Start for a ConsoleOut handle.
1273 Status
= ConSplitterStart (
1276 mConOut
.VirtualHandle
,
1277 &gEfiConsoleOutDeviceGuid
,
1278 &gEfiSimpleTextOutProtocolGuid
,
1281 if (EFI_ERROR (Status
)) {
1285 GraphicsOutput
= NULL
;
1288 // Try to Open Graphics Output protocol
1290 Status
= gBS
->OpenProtocol (
1292 &gEfiGraphicsOutputProtocolGuid
,
1293 (VOID
**) &GraphicsOutput
,
1294 This
->DriverBindingHandle
,
1295 mConOut
.VirtualHandle
,
1296 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1299 if (EFI_ERROR (Status
) && FeaturePcdGet (PcdUgaConsumeSupport
)) {
1301 // Open UGA DRAW protocol
1305 &gEfiUgaDrawProtocolGuid
,
1307 This
->DriverBindingHandle
,
1308 mConOut
.VirtualHandle
,
1309 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1314 // When new console device is added, the new mode will be set later,
1315 // so put current mode back to init state.
1317 mConOut
.TextOutMode
.Mode
= 0xFF;
1320 // If both ConOut and StdErr incorporate the same Text Out device,
1321 // their MaxMode and QueryData should be the intersection of both.
1323 Status
= ConSplitterTextOutAddDevice (&mConOut
, TextOut
, GraphicsOutput
, UgaDraw
);
1324 ConSplitterTextOutSetAttribute (&mConOut
.TextOut
, EFI_TEXT_ATTR (EFI_LIGHTGRAY
, EFI_BLACK
));
1326 if (FeaturePcdGet (PcdConOutUgaSupport
)) {
1328 // Get the UGA mode data of ConOut from the current mode
1330 if (GraphicsOutput
!= NULL
) {
1331 Status
= GraphicsOutput
->QueryMode (GraphicsOutput
, GraphicsOutput
->Mode
->Mode
, &SizeOfInfo
, &Info
);
1332 if (EFI_ERROR (Status
)) {
1335 ASSERT ( SizeOfInfo
<= sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
));
1337 mConOut
.UgaHorizontalResolution
= Info
->HorizontalResolution
;
1338 mConOut
.UgaVerticalResolution
= Info
->VerticalResolution
;
1339 mConOut
.UgaColorDepth
= 32;
1340 mConOut
.UgaRefreshRate
= 60;
1344 } else if (UgaDraw
!= NULL
&& FeaturePcdGet (PcdUgaConsumeSupport
)) {
1345 Status
= UgaDraw
->GetMode (
1347 &mConOut
.UgaHorizontalResolution
,
1348 &mConOut
.UgaVerticalResolution
,
1349 &mConOut
.UgaColorDepth
,
1350 &mConOut
.UgaRefreshRate
1360 Start Standard Error Consplitter on device handle.
1362 @param This Driver Binding protocol instance pointer.
1363 @param ControllerHandle Handle of device to bind driver to.
1364 @param RemainingDevicePath Optional parameter use to pick a specific child
1367 @retval EFI_SUCCESS Standard Error Consplitter is added to ControllerHandle.
1368 @retval other Standard Error Consplitter does not support this device.
1373 ConSplitterStdErrDriverBindingStart (
1374 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1375 IN EFI_HANDLE ControllerHandle
,
1376 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
1380 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
;
1383 // Start ConSplitter on ControllerHandle, and create the virtual
1384 // agrogated console device on first call Start for a StandardError handle.
1386 Status
= ConSplitterStart (
1389 mStdErr
.VirtualHandle
,
1390 &gEfiStandardErrorDeviceGuid
,
1391 &gEfiSimpleTextOutProtocolGuid
,
1394 if (EFI_ERROR (Status
)) {
1399 // When new console device is added, the new mode will be set later,
1400 // so put current mode back to init state.
1402 mStdErr
.TextOutMode
.Mode
= 0xFF;
1405 // If both ConOut and StdErr incorporate the same Text Out device,
1406 // their MaxMode and QueryData should be the intersection of both.
1408 Status
= ConSplitterTextOutAddDevice (&mStdErr
, TextOut
, NULL
, NULL
);
1409 ConSplitterTextOutSetAttribute (&mStdErr
.TextOut
, EFI_TEXT_ATTR (EFI_MAGENTA
, EFI_BLACK
));
1410 if (EFI_ERROR (Status
)) {
1414 if (mStdErr
.CurrentNumberOfConsoles
== 1) {
1415 gST
->StandardErrorHandle
= mStdErr
.VirtualHandle
;
1416 gST
->StdErr
= &mStdErr
.TextOut
;
1418 // Update the CRC32 in the EFI System Table header
1421 gBS
->CalculateCrc32 (
1422 (UINT8
*) &gST
->Hdr
,
1423 gST
->Hdr
.HeaderSize
,
1433 Stop ConSplitter on device handle by closing Console Device Guid on device handle
1434 and the console virtual handle.
1436 @param This Protocol instance pointer.
1437 @param ControllerHandle Handle of device.
1438 @param ConSplitterVirtualHandle Console virtual Handle.
1439 @param DeviceGuid The specified Console Device, such as ConInDev,
1441 @param InterfaceGuid The specified protocol to be opened.
1442 @param Interface Protocol interface returned.
1444 @retval EFI_SUCCESS Stop ConSplitter on ControllerHandle successfully.
1445 @retval other Failed to Stop ConSplitter on ControllerHandle.
1450 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1451 IN EFI_HANDLE ControllerHandle
,
1452 IN EFI_HANDLE ConSplitterVirtualHandle
,
1453 IN EFI_GUID
*DeviceGuid
,
1454 IN EFI_GUID
*InterfaceGuid
,
1460 Status
= gBS
->OpenProtocol (
1464 This
->DriverBindingHandle
,
1466 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1468 if (EFI_ERROR (Status
)) {
1472 // close the protocol refered.
1474 gBS
->CloseProtocol (
1477 This
->DriverBindingHandle
,
1478 ConSplitterVirtualHandle
1481 gBS
->CloseProtocol (
1484 This
->DriverBindingHandle
,
1493 Stop Console In ConSplitter on ControllerHandle by closing Console In Devcice GUID.
1495 @param This Driver Binding protocol instance pointer.
1496 @param ControllerHandle Handle of device to stop driver on
1497 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
1498 children is zero stop the entire bus driver.
1499 @param ChildHandleBuffer List of Child Handles to Stop.
1501 @retval EFI_SUCCESS This driver is removed ControllerHandle
1502 @retval other This driver was not removed from this device
1507 ConSplitterConInDriverBindingStop (
1508 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1509 IN EFI_HANDLE ControllerHandle
,
1510 IN UINTN NumberOfChildren
,
1511 IN EFI_HANDLE
*ChildHandleBuffer
1515 EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*TextIn
;
1516 EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*TextInEx
;
1518 if (NumberOfChildren
== 0) {
1522 Status
= gBS
->OpenProtocol (
1524 &gEfiSimpleTextInputExProtocolGuid
,
1525 (VOID
**) &TextInEx
,
1526 This
->DriverBindingHandle
,
1528 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1530 if (!EFI_ERROR (Status
)) {
1532 // If Simple Text Input Ex protocol exists,
1533 // remove device from Text Input Ex devices list.
1535 Status
= ConSplitterTextInExDeleteDevice (&mConIn
, TextInEx
);
1536 if (EFI_ERROR (Status
)) {
1542 // Close Simple Text In protocol on controller handle and virtual handle.
1544 Status
= ConSplitterStop (
1547 mConIn
.VirtualHandle
,
1548 &gEfiConsoleInDeviceGuid
,
1549 &gEfiSimpleTextInProtocolGuid
,
1552 if (EFI_ERROR (Status
)) {
1557 // Remove device from Text Input devices list.
1559 return ConSplitterTextInDeleteDevice (&mConIn
, TextIn
);
1564 Stop Simple Pointer protocol ConSplitter on ControllerHandle by closing
1565 Simple Pointer protocol.
1567 @param This Driver Binding protocol instance pointer.
1568 @param ControllerHandle Handle of device to stop driver on
1569 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
1570 children is zero stop the entire bus driver.
1571 @param ChildHandleBuffer List of Child Handles to Stop.
1573 @retval EFI_SUCCESS This driver is removed ControllerHandle
1574 @retval other This driver was not removed from this device
1579 ConSplitterSimplePointerDriverBindingStop (
1580 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1581 IN EFI_HANDLE ControllerHandle
,
1582 IN UINTN NumberOfChildren
,
1583 IN EFI_HANDLE
*ChildHandleBuffer
1587 EFI_SIMPLE_POINTER_PROTOCOL
*SimplePointer
;
1589 if (NumberOfChildren
== 0) {
1594 // Close Simple Pointer protocol on controller handle and virtual handle.
1596 Status
= ConSplitterStop (
1599 mConIn
.VirtualHandle
,
1600 &gEfiSimplePointerProtocolGuid
,
1601 &gEfiSimplePointerProtocolGuid
,
1602 (VOID
**) &SimplePointer
1604 if (EFI_ERROR (Status
)) {
1609 // Remove this device from Simple Pointer device list.
1611 return ConSplitterSimplePointerDeleteDevice (&mConIn
, SimplePointer
);
1616 Stop Absolute Pointer protocol ConSplitter on ControllerHandle by closing
1617 Absolute Pointer protocol.
1619 @param This Driver Binding protocol instance pointer.
1620 @param ControllerHandle Handle of device to stop driver on
1621 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
1622 children is zero stop the entire bus driver.
1623 @param ChildHandleBuffer List of Child Handles to Stop.
1625 @retval EFI_SUCCESS This driver is removed ControllerHandle
1626 @retval other This driver was not removed from this device
1631 ConSplitterAbsolutePointerDriverBindingStop (
1632 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1633 IN EFI_HANDLE ControllerHandle
,
1634 IN UINTN NumberOfChildren
,
1635 IN EFI_HANDLE
*ChildHandleBuffer
1639 EFI_ABSOLUTE_POINTER_PROTOCOL
*AbsolutePointer
;
1641 if (NumberOfChildren
== 0) {
1646 // Close Absolute Pointer protocol on controller handle and virtual handle.
1648 Status
= ConSplitterStop (
1651 mConIn
.VirtualHandle
,
1652 &gEfiAbsolutePointerProtocolGuid
,
1653 &gEfiAbsolutePointerProtocolGuid
,
1654 (VOID
**) &AbsolutePointer
1656 if (EFI_ERROR (Status
)) {
1661 // Remove this device from Absolute Pointer device list.
1663 return ConSplitterAbsolutePointerDeleteDevice (&mConIn
, AbsolutePointer
);
1668 Stop Console Out ConSplitter on device handle by closing Console Out Devcice GUID.
1670 @param This Driver Binding protocol instance pointer.
1671 @param ControllerHandle Handle of device to stop driver on
1672 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
1673 children is zero stop the entire bus driver.
1674 @param ChildHandleBuffer List of Child Handles to Stop.
1676 @retval EFI_SUCCESS This driver is removed ControllerHandle
1677 @retval other This driver was not removed from this device
1682 ConSplitterConOutDriverBindingStop (
1683 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1684 IN EFI_HANDLE ControllerHandle
,
1685 IN UINTN NumberOfChildren
,
1686 IN EFI_HANDLE
*ChildHandleBuffer
1690 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
;
1692 if (NumberOfChildren
== 0) {
1697 // Close Absolute Pointer protocol on controller handle and virtual handle.
1699 Status
= ConSplitterStop (
1702 mConOut
.VirtualHandle
,
1703 &gEfiConsoleOutDeviceGuid
,
1704 &gEfiSimpleTextOutProtocolGuid
,
1707 if (EFI_ERROR (Status
)) {
1712 // Remove this device from Text Out device list.
1714 return ConSplitterTextOutDeleteDevice (&mConOut
, TextOut
);
1719 Stop Standard Error ConSplitter on ControllerHandle by closing Standard Error GUID.
1721 @param This Driver Binding protocol instance pointer.
1722 @param ControllerHandle Handle of device to stop driver on
1723 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
1724 children is zero stop the entire bus driver.
1725 @param ChildHandleBuffer List of Child Handles to Stop.
1727 @retval EFI_SUCCESS This driver is removed ControllerHandle
1728 @retval other This driver was not removed from this device
1733 ConSplitterStdErrDriverBindingStop (
1734 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1735 IN EFI_HANDLE ControllerHandle
,
1736 IN UINTN NumberOfChildren
,
1737 IN EFI_HANDLE
*ChildHandleBuffer
1741 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
;
1743 if (NumberOfChildren
== 0) {
1748 // Close Standard Error Device on controller handle and virtual handle.
1750 Status
= ConSplitterStop (
1753 mStdErr
.VirtualHandle
,
1754 &gEfiStandardErrorDeviceGuid
,
1755 &gEfiSimpleTextOutProtocolGuid
,
1758 if (EFI_ERROR (Status
)) {
1762 // Delete this console error out device's data structures.
1764 Status
= ConSplitterTextOutDeleteDevice (&mStdErr
, TextOut
);
1765 if (EFI_ERROR (Status
)) {
1769 if (mStdErr
.CurrentNumberOfConsoles
== 0) {
1770 gST
->StandardErrorHandle
= NULL
;
1773 // Update the CRC32 in the EFI System Table header
1776 gBS
->CalculateCrc32 (
1777 (UINT8
*) &gST
->Hdr
,
1778 gST
->Hdr
.HeaderSize
,
1788 Take the passed in Buffer of size SizeOfCount and grow the buffer
1789 by MAX (CONSOLE_SPLITTER_CONSOLES_ALLOC_UNIT, MaxGrow) * SizeOfCount
1790 bytes. Copy the current data in Buffer to the new version of Buffer
1791 and free the old version of buffer.
1793 @param SizeOfCount Size of element in array.
1794 @param Count Current number of elements in array.
1795 @param Buffer Bigger version of passed in Buffer with all the
1798 @retval EFI_SUCCESS Buffer size has grown.
1799 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
1803 ConSplitterGrowBuffer (
1804 IN UINTN SizeOfCount
,
1806 IN OUT VOID
**Buffer
1812 // grow the buffer to new buffer size,
1813 // copy the old buffer's content to the new-size buffer,
1814 // then free the old buffer.
1816 *Count
+= CONSOLE_SPLITTER_CONSOLES_ALLOC_UNIT
;
1817 Ptr
= ReallocatePool (
1818 SizeOfCount
* ((*Count
) - CONSOLE_SPLITTER_CONSOLES_ALLOC_UNIT
),
1819 SizeOfCount
* (*Count
),
1823 return EFI_OUT_OF_RESOURCES
;
1831 Add Text Input Device in Consplitter Text Input list.
1833 @param Private Text In Splitter pointer.
1834 @param TextIn Simple Text Input protocol pointer.
1836 @retval EFI_SUCCESS Text Input Device added successfully.
1837 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
1841 ConSplitterTextInAddDevice (
1842 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
1843 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*TextIn
1849 // If the Text In List is full, enlarge it by calling ConSplitterGrowBuffer().
1851 if (Private
->CurrentNumberOfConsoles
>= Private
->TextInListCount
) {
1852 Status
= ConSplitterGrowBuffer (
1853 sizeof (EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*),
1854 &Private
->TextInListCount
,
1855 (VOID
**) &Private
->TextInList
1857 if (EFI_ERROR (Status
)) {
1858 return EFI_OUT_OF_RESOURCES
;
1862 // Add the new text-in device data structure into the Text In List.
1864 Private
->TextInList
[Private
->CurrentNumberOfConsoles
] = TextIn
;
1865 Private
->CurrentNumberOfConsoles
++;
1868 // Extra CheckEvent added to reduce the double CheckEvent().
1870 gBS
->CheckEvent (TextIn
->WaitForKey
);
1877 Remove Text Input Device from Consplitter Text Input list.
1879 @param Private Text In Splitter pointer.
1880 @param TextIn Simple Text protocol pointer.
1882 @retval EFI_SUCCESS Simple Text Device removed successfully.
1883 @retval EFI_NOT_FOUND No Simple Text Device found.
1887 ConSplitterTextInDeleteDevice (
1888 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
1889 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*TextIn
1894 // Remove the specified text-in device data structure from the Text In List,
1895 // and rearrange the remaining data structures in the Text In List.
1897 for (Index
= 0; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
1898 if (Private
->TextInList
[Index
] == TextIn
) {
1899 for (Index
= Index
; Index
< Private
->CurrentNumberOfConsoles
- 1; Index
++) {
1900 Private
->TextInList
[Index
] = Private
->TextInList
[Index
+ 1];
1903 Private
->CurrentNumberOfConsoles
--;
1908 return EFI_NOT_FOUND
;
1912 Add Text Input Ex Device in Consplitter Text Input Ex list.
1914 @param Private Text In Splitter pointer.
1915 @param TextInEx Simple Text Input Ex Input protocol pointer.
1917 @retval EFI_SUCCESS Text Input Ex Device added successfully.
1918 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
1922 ConSplitterTextInExAddDevice (
1923 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
1924 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*TextInEx
1930 // If the Text Input Ex List is full, enlarge it by calling ConSplitterGrowBuffer().
1932 if (Private
->CurrentNumberOfExConsoles
>= Private
->TextInExListCount
) {
1933 Status
= ConSplitterGrowBuffer (
1934 sizeof (EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*),
1935 &Private
->TextInExListCount
,
1936 (VOID
**) &Private
->TextInExList
1938 if (EFI_ERROR (Status
)) {
1939 return EFI_OUT_OF_RESOURCES
;
1943 // Add the new text-in device data structure into the Text Input Ex List.
1945 Private
->TextInExList
[Private
->CurrentNumberOfExConsoles
] = TextInEx
;
1946 Private
->CurrentNumberOfExConsoles
++;
1949 // Extra CheckEvent added to reduce the double CheckEvent().
1951 gBS
->CheckEvent (TextInEx
->WaitForKeyEx
);
1957 Remove Text Ex Device from Consplitter Text Input Ex list.
1959 @param Private Text In Splitter pointer.
1960 @param TextInEx Simple Text Ex protocol pointer.
1962 @retval EFI_SUCCESS Simple Text Input Ex Device removed successfully.
1963 @retval EFI_NOT_FOUND No Simple Text Input Ex Device found.
1967 ConSplitterTextInExDeleteDevice (
1968 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
1969 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*TextInEx
1974 // Remove the specified text-in device data structure from the Text Input Ex List,
1975 // and rearrange the remaining data structures in the Text In List.
1977 for (Index
= 0; Index
< Private
->CurrentNumberOfExConsoles
; Index
++) {
1978 if (Private
->TextInExList
[Index
] == TextInEx
) {
1979 for (Index
= Index
; Index
< Private
->CurrentNumberOfExConsoles
- 1; Index
++) {
1980 Private
->TextInExList
[Index
] = Private
->TextInExList
[Index
+ 1];
1983 Private
->CurrentNumberOfExConsoles
--;
1988 return EFI_NOT_FOUND
;
1993 Add Simple Pointer Device in Consplitter Simple Pointer list.
1995 @param Private Text In Splitter pointer.
1996 @param SimplePointer Simple Pointer protocol pointer.
1998 @retval EFI_SUCCESS Simple Pointer Device added successfully.
1999 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
2003 ConSplitterSimplePointerAddDevice (
2004 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
2005 IN EFI_SIMPLE_POINTER_PROTOCOL
*SimplePointer
2011 // If the Simple Pointer List is full, enlarge it by calling ConSplitterGrowBuffer().
2013 if (Private
->CurrentNumberOfPointers
>= Private
->PointerListCount
) {
2014 Status
= ConSplitterGrowBuffer (
2015 sizeof (EFI_SIMPLE_POINTER_PROTOCOL
*),
2016 &Private
->PointerListCount
,
2017 (VOID
**) &Private
->PointerList
2019 if (EFI_ERROR (Status
)) {
2020 return EFI_OUT_OF_RESOURCES
;
2024 // Add the new text-in device data structure into the Simple Pointer List.
2026 Private
->PointerList
[Private
->CurrentNumberOfPointers
] = SimplePointer
;
2027 Private
->CurrentNumberOfPointers
++;
2034 Remove Simple Pointer Device from Consplitter Simple Pointer list.
2036 @param Private Text In Splitter pointer.
2037 @param SimplePointer Simple Pointer protocol pointer.
2039 @retval EFI_SUCCESS Simple Pointer Device removed successfully.
2040 @retval EFI_NOT_FOUND No Simple Pointer Device found.
2044 ConSplitterSimplePointerDeleteDevice (
2045 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
2046 IN EFI_SIMPLE_POINTER_PROTOCOL
*SimplePointer
2051 // Remove the specified text-in device data structure from the Simple Pointer List,
2052 // and rearrange the remaining data structures in the Text In List.
2054 for (Index
= 0; Index
< Private
->CurrentNumberOfPointers
; Index
++) {
2055 if (Private
->PointerList
[Index
] == SimplePointer
) {
2056 for (Index
= Index
; Index
< Private
->CurrentNumberOfPointers
- 1; Index
++) {
2057 Private
->PointerList
[Index
] = Private
->PointerList
[Index
+ 1];
2060 Private
->CurrentNumberOfPointers
--;
2065 return EFI_NOT_FOUND
;
2070 Add Absolute Pointer Device in Consplitter Absolute Pointer list.
2072 @param Private Text In Splitter pointer.
2073 @param AbsolutePointer Absolute Pointer protocol pointer.
2075 @retval EFI_SUCCESS Absolute Pointer Device added successfully.
2076 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
2080 ConSplitterAbsolutePointerAddDevice (
2081 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
2082 IN EFI_ABSOLUTE_POINTER_PROTOCOL
*AbsolutePointer
2088 // If the Absolute Pointer List is full, enlarge it by calling ConSplitterGrowBuffer().
2090 if (Private
->CurrentNumberOfAbsolutePointers
>= Private
->AbsolutePointerListCount
) {
2091 Status
= ConSplitterGrowBuffer (
2092 sizeof (EFI_ABSOLUTE_POINTER_PROTOCOL
*),
2093 &Private
->AbsolutePointerListCount
,
2094 (VOID
**) &Private
->AbsolutePointerList
2096 if (EFI_ERROR (Status
)) {
2097 return EFI_OUT_OF_RESOURCES
;
2101 // Add the new text-in device data structure into the Absolute Pointer List.
2103 Private
->AbsolutePointerList
[Private
->CurrentNumberOfAbsolutePointers
] = AbsolutePointer
;
2104 Private
->CurrentNumberOfAbsolutePointers
++;
2111 Remove Absolute Pointer Device from Consplitter Absolute Pointer list.
2113 @param Private Text In Splitter pointer.
2114 @param AbsolutePointer Absolute Pointer protocol pointer.
2116 @retval EFI_SUCCESS Absolute Pointer Device removed successfully.
2117 @retval EFI_NOT_FOUND No Absolute Pointer Device found.
2121 ConSplitterAbsolutePointerDeleteDevice (
2122 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
2123 IN EFI_ABSOLUTE_POINTER_PROTOCOL
*AbsolutePointer
2128 // Remove the specified text-in device data structure from the Absolute Pointer List,
2129 // and rearrange the remaining data structures from the Absolute Pointer List.
2131 for (Index
= 0; Index
< Private
->CurrentNumberOfAbsolutePointers
; Index
++) {
2132 if (Private
->AbsolutePointerList
[Index
] == AbsolutePointer
) {
2133 for (Index
= Index
; Index
< Private
->CurrentNumberOfAbsolutePointers
- 1; Index
++) {
2134 Private
->AbsolutePointerList
[Index
] = Private
->AbsolutePointerList
[Index
+ 1];
2137 Private
->CurrentNumberOfAbsolutePointers
--;
2142 return EFI_NOT_FOUND
;
2146 Reallocate Text Out mode map.
2148 Allocate new buffer and copy original buffer into the new buffer.
2150 @param Private Consplitter Text Out pointer.
2152 @retval EFI_SUCCESS Buffer size has grown
2153 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
2157 ConSplitterGrowMapTable (
2158 IN TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
2164 INT32
*TextOutModeMap
;
2165 INT32
*OldTextOutModeMap
;
2169 NewSize
= Private
->TextOutListCount
* sizeof (INT32
);
2170 OldTextOutModeMap
= Private
->TextOutModeMap
;
2171 TotalSize
= NewSize
* (Private
->TextOutQueryDataCount
);
2174 // Allocate new buffer for Text Out List.
2176 TextOutModeMap
= AllocatePool (TotalSize
);
2177 if (TextOutModeMap
== NULL
) {
2178 return EFI_OUT_OF_RESOURCES
;
2181 SetMem (TextOutModeMap
, TotalSize
, 0xFF);
2182 Private
->TextOutModeMap
= TextOutModeMap
;
2185 // If TextOutList has been enlarged, need to realloc the mode map table
2186 // The mode map table is regarded as a two dimension array.
2189 // 0 ---------> TextOutListCount ----> TextOutListCount
2190 // | -------------------------------------------
2197 // -------------------------------------------
2200 if (OldTextOutModeMap
!= NULL
) {
2202 Size
= Private
->CurrentNumberOfConsoles
* sizeof (INT32
);
2204 SrcAddress
= OldTextOutModeMap
;
2207 // Copy the old data to the new one
2209 while (Index
< Private
->TextOutMode
.MaxMode
) {
2210 CopyMem (TextOutModeMap
, SrcAddress
, Size
);
2211 TextOutModeMap
+= NewSize
;
2216 // Free the old buffer
2218 FreePool (OldTextOutModeMap
);
2226 Add new device's output mode to console splitter's mode list.
2228 @param Private Text Out Splitter pointer
2229 @param TextOut Simple Text Output protocol pointer.
2231 @retval EFI_SUCCESS Device added successfully.
2232 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
2236 ConSplitterAddOutputMode (
2237 IN TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
,
2238 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
2246 MaxMode
= TextOut
->Mode
->MaxMode
;
2247 Private
->TextOutMode
.MaxMode
= MaxMode
;
2250 // Grow the buffer if query data buffer is not large enough to
2251 // hold all the mode supported by the first console.
2253 while (MaxMode
> (INT32
) Private
->TextOutQueryDataCount
) {
2254 Status
= ConSplitterGrowBuffer (
2255 sizeof (TEXT_OUT_SPLITTER_QUERY_DATA
),
2256 &Private
->TextOutQueryDataCount
,
2257 (VOID
**) &Private
->TextOutQueryData
2259 if (EFI_ERROR (Status
)) {
2260 return EFI_OUT_OF_RESOURCES
;
2264 // Allocate buffer for the output mode map
2266 Status
= ConSplitterGrowMapTable (Private
);
2267 if (EFI_ERROR (Status
)) {
2268 return EFI_OUT_OF_RESOURCES
;
2271 // As the first textout device, directly add the mode in to QueryData
2272 // and at the same time record the mapping between QueryData and TextOut.
2276 while (Mode
< MaxMode
) {
2277 Status
= TextOut
->QueryMode (
2280 &Private
->TextOutQueryData
[Mode
].Columns
,
2281 &Private
->TextOutQueryData
[Mode
].Rows
2284 // If mode 1 (80x50) is not supported, make sure mode 1 in TextOutQueryData
2287 if ((EFI_ERROR(Status
)) && (Mode
== 1)) {
2288 Private
->TextOutQueryData
[Mode
].Columns
= 0;
2289 Private
->TextOutQueryData
[Mode
].Rows
= 0;
2291 Private
->TextOutModeMap
[Index
] = Mode
;
2293 Index
+= Private
->TextOutListCount
;
2300 Reconstruct TextOutModeMap to get intersection of modes.
2302 This routine reconstruct TextOutModeMap to get the intersection
2303 of modes for all console out devices. Because EFI/UEFI spec require
2304 mode 0 is 80x25, mode 1 is 80x50, this routine will not check the
2305 intersection for mode 0 and mode 1.
2307 @param TextOutModeMap Current text out mode map, begin with the mode 80x25
2308 @param NewlyAddedMap New text out mode map, begin with the mode 80x25
2309 @param MapStepSize Mode step size for one console device
2310 @param NewMapStepSize New Mode step size for one console device
2311 @param MaxMode IN: Current max text mode, OUT: Updated max text mode.
2312 @param CurrentMode IN: Current text mode, OUT: Updated current text mode.
2316 ConSplitterGetIntersection (
2317 IN INT32
*TextOutModeMap
,
2318 IN INT32
*NewlyAddedMap
,
2319 IN UINTN MapStepSize
,
2320 IN UINTN NewMapStepSize
,
2321 IN OUT INT32
*MaxMode
,
2322 IN OUT INT32
*CurrentMode
2326 INT32
*CurrentMapEntry
;
2327 INT32
*NextMapEntry
;
2329 INT32 CurrentMaxMode
;
2333 // According to EFI/UEFI spec, mode 0 and mode 1 have been reserved
2334 // for 80x25 and 80x50 in Simple Text Out protocol, so don't make intersection
2335 // for mode 0 and mode 1, mode number starts from 2.
2338 CurrentMapEntry
= &TextOutModeMap
[MapStepSize
* 2];
2339 NextMapEntry
= CurrentMapEntry
;
2340 NewMapEntry
= &NewlyAddedMap
[NewMapStepSize
* 2];
2342 CurrentMaxMode
= *MaxMode
;
2343 Mode
= *CurrentMode
;
2345 while (Index
< CurrentMaxMode
) {
2346 if (*NewMapEntry
== -1) {
2348 // This mode is not supported any more. Remove it. Special care
2349 // must be taken as this remove will also affect current mode;
2351 if (Index
== *CurrentMode
) {
2353 } else if (Index
< *CurrentMode
) {
2358 if (CurrentMapEntry
!= NextMapEntry
) {
2359 CopyMem (NextMapEntry
, CurrentMapEntry
, MapStepSize
* sizeof (INT32
));
2362 NextMapEntry
+= MapStepSize
;
2365 CurrentMapEntry
+= MapStepSize
;
2366 NewMapEntry
+= NewMapStepSize
;
2370 *CurrentMode
= Mode
;
2376 Sync the device's output mode to console splitter's mode list.
2378 @param Private Text Out Splitter pointer.
2379 @param TextOut Simple Text Output protocol pointer.
2383 ConSplitterSyncOutputMode (
2384 IN TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
,
2385 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
2388 INT32 CurrentMaxMode
;
2391 INT32
*TextOutModeMap
;
2394 TEXT_OUT_SPLITTER_QUERY_DATA
*TextOutQueryData
;
2401 // Must make sure that current mode won't change even if mode number changes
2403 CurrentMaxMode
= Private
->TextOutMode
.MaxMode
;
2404 TextOutModeMap
= Private
->TextOutModeMap
;
2405 StepSize
= Private
->TextOutListCount
;
2406 TextOutQueryData
= Private
->TextOutQueryData
;
2409 // Query all the mode that the newly added TextOut supports
2412 MapTable
= TextOutModeMap
+ Private
->CurrentNumberOfConsoles
;
2413 while (Mode
< TextOut
->Mode
->MaxMode
) {
2414 Status
= TextOut
->QueryMode (TextOut
, Mode
, &Columns
, &Rows
);
2416 if (EFI_ERROR(Status
)) {
2419 // If mode 1 (80x50) is not supported, make sure mode 1 in TextOutQueryData
2422 MapTable
[StepSize
] = Mode
;
2423 TextOutQueryData
[Mode
].Columns
= 0;
2424 TextOutQueryData
[Mode
].Rows
= 0;
2430 // Search the intersection map and QueryData database to see if they intersects
2433 while (Index
< CurrentMaxMode
) {
2434 QueryMode
= *(TextOutModeMap
+ Index
* StepSize
);
2435 if ((TextOutQueryData
[QueryMode
].Rows
== Rows
) && (TextOutQueryData
[QueryMode
].Columns
== Columns
)) {
2436 MapTable
[Index
* StepSize
] = Mode
;
2444 // Now search the TextOutModeMap table to find the intersection of supported
2445 // mode between ConSplitter and the newly added device.
2447 ConSplitterGetIntersection (
2452 &Private
->TextOutMode
.MaxMode
,
2453 &Private
->TextOutMode
.Mode
2461 Sync output device between ConOut and StdErr output.
2463 @retval EFI_SUCCESS Sync implemented successfully.
2464 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
2468 ConSplitterGetIntersectionBetweenConOutAndStrErr (
2472 UINTN ConOutNumOfConsoles
;
2473 UINTN StdErrNumOfConsoles
;
2474 TEXT_OUT_AND_GOP_DATA
*ConOutTextOutList
;
2475 TEXT_OUT_AND_GOP_DATA
*StdErrTextOutList
;
2479 UINTN ConOutColumns
;
2481 UINTN StdErrColumns
;
2482 INT32 ConOutMaxMode
;
2483 INT32 StdErrMaxMode
;
2488 INT32
*ConOutModeMap
;
2489 INT32
*StdErrModeMap
;
2490 INT32
*ConOutMapTable
;
2491 INT32
*StdErrMapTable
;
2492 TEXT_OUT_SPLITTER_QUERY_DATA
*ConOutQueryData
;
2493 TEXT_OUT_SPLITTER_QUERY_DATA
*StdErrQueryData
;
2494 UINTN ConOutStepSize
;
2495 UINTN StdErrStepSize
;
2496 BOOLEAN FoundTheSameTextOut
;
2497 UINTN ConOutMapTableSize
;
2498 UINTN StdErrMapTableSize
;
2500 ConOutNumOfConsoles
= mConOut
.CurrentNumberOfConsoles
;
2501 StdErrNumOfConsoles
= mStdErr
.CurrentNumberOfConsoles
;
2502 ConOutTextOutList
= mConOut
.TextOutList
;
2503 StdErrTextOutList
= mStdErr
.TextOutList
;
2506 FoundTheSameTextOut
= FALSE
;
2507 while ((Indexi
< ConOutNumOfConsoles
) && (!FoundTheSameTextOut
)) {
2509 while (Indexj
< StdErrNumOfConsoles
) {
2510 if (ConOutTextOutList
->TextOut
== StdErrTextOutList
->TextOut
) {
2511 FoundTheSameTextOut
= TRUE
;
2516 StdErrTextOutList
++;
2520 ConOutTextOutList
++;
2523 if (!FoundTheSameTextOut
) {
2527 // Must make sure that current mode won't change even if mode number changes
2529 ConOutMaxMode
= mConOut
.TextOutMode
.MaxMode
;
2530 ConOutModeMap
= mConOut
.TextOutModeMap
;
2531 ConOutStepSize
= mConOut
.TextOutListCount
;
2532 ConOutQueryData
= mConOut
.TextOutQueryData
;
2534 StdErrMaxMode
= mStdErr
.TextOutMode
.MaxMode
;
2535 StdErrModeMap
= mStdErr
.TextOutModeMap
;
2536 StdErrStepSize
= mStdErr
.TextOutListCount
;
2537 StdErrQueryData
= mStdErr
.TextOutQueryData
;
2540 // Allocate the map table and set the map table's index to -1.
2542 ConOutMapTableSize
= ConOutMaxMode
* sizeof (INT32
);
2543 ConOutMapTable
= AllocateZeroPool (ConOutMapTableSize
);
2544 if (ConOutMapTable
== NULL
) {
2545 return EFI_OUT_OF_RESOURCES
;
2548 SetMem (ConOutMapTable
, ConOutMapTableSize
, 0xFF);
2550 StdErrMapTableSize
= StdErrMaxMode
* sizeof (INT32
);
2551 StdErrMapTable
= AllocateZeroPool (StdErrMapTableSize
);
2552 if (StdErrMapTable
== NULL
) {
2553 return EFI_OUT_OF_RESOURCES
;
2556 SetMem (StdErrMapTable
, StdErrMapTableSize
, 0xFF);
2559 // Find the intersection of the two set of modes. If they actually intersect, the
2560 // correponding entry in the map table is set to 1.
2563 while (Mode
< ConOutMaxMode
) {
2565 // Search the intersection map and QueryData database to see if they intersect
2568 ConOutMode
= *(ConOutModeMap
+ Mode
* ConOutStepSize
);
2569 ConOutRows
= ConOutQueryData
[ConOutMode
].Rows
;
2570 ConOutColumns
= ConOutQueryData
[ConOutMode
].Columns
;
2571 while (Index
< StdErrMaxMode
) {
2572 StdErrMode
= *(StdErrModeMap
+ Index
* StdErrStepSize
);
2573 StdErrRows
= StdErrQueryData
[StdErrMode
].Rows
;
2574 StdErrColumns
= StdErrQueryData
[StdErrMode
].Columns
;
2575 if ((StdErrRows
== ConOutRows
) && (StdErrColumns
== ConOutColumns
)) {
2576 ConOutMapTable
[Mode
] = 1;
2577 StdErrMapTable
[Index
] = 1;
2587 // Now search the TextOutModeMap table to find the intersection of supported
2588 // mode between ConSplitter and the newly added device.
2590 ConSplitterGetIntersection (
2593 mConOut
.TextOutListCount
,
2595 &(mConOut
.TextOutMode
.MaxMode
),
2596 &(mConOut
.TextOutMode
.Mode
)
2599 if (mConOut
.TextOutMode
.Mode
< 0) {
2600 mConOut
.TextOut
.SetMode (&(mConOut
.TextOut
), 0);
2603 ConSplitterGetIntersection (
2606 mStdErr
.TextOutListCount
,
2608 &(mStdErr
.TextOutMode
.MaxMode
),
2609 &(mStdErr
.TextOutMode
.Mode
)
2612 if (mStdErr
.TextOutMode
.Mode
< 0) {
2613 mStdErr
.TextOut
.SetMode (&(mStdErr
.TextOut
), 0);
2616 FreePool (ConOutMapTable
);
2617 FreePool (StdErrMapTable
);
2624 Add Grahpics Output modes into Consplitter Text Out list.
2626 @param Private Text Out Splitter pointer.
2627 @param GraphicsOutput Graphics Output protocol pointer.
2628 @param UgaDraw UGA Draw protocol pointer.
2630 @retval EFI_SUCCESS Output mode added successfully.
2631 @retval other Failed to add output mode.
2635 ConSplitterAddGraphicsOutputMode (
2636 IN TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
,
2637 IN EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
,
2638 IN EFI_UGA_DRAW_PROTOCOL
*UgaDraw
2644 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*Mode
;
2646 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*Info
;
2647 EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE
*CurrentGraphicsOutputMode
;
2648 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*ModeBuffer
;
2649 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*MatchedMode
;
2652 BOOLEAN AlreadyExist
;
2653 UINT32 UgaHorizontalResolution
;
2654 UINT32 UgaVerticalResolution
;
2655 UINT32 UgaColorDepth
;
2656 UINT32 UgaRefreshRate
;
2658 ASSERT (GraphicsOutput
!= NULL
|| UgaDraw
!= NULL
);
2660 CurrentGraphicsOutputMode
= Private
->GraphicsOutput
.Mode
;
2665 if (Private
->CurrentNumberOfUgaDraw
!= 0) {
2667 // If any UGA device has already been added, then there is no need to
2668 // calculate intersection of display mode of different GOP/UGA device,
2669 // since only one display mode will be exported (i.e. user-defined mode)
2674 if (GraphicsOutput
!= NULL
) {
2675 if (Private
->CurrentNumberOfGraphicsOutput
== 0) {
2677 // This is the first Graphics Output device added
2679 CurrentGraphicsOutputMode
->MaxMode
= GraphicsOutput
->Mode
->MaxMode
;
2680 CurrentGraphicsOutputMode
->Mode
= GraphicsOutput
->Mode
->Mode
;
2681 CopyMem (CurrentGraphicsOutputMode
->Info
, GraphicsOutput
->Mode
->Info
, GraphicsOutput
->Mode
->SizeOfInfo
);
2682 CurrentGraphicsOutputMode
->SizeOfInfo
= GraphicsOutput
->Mode
->SizeOfInfo
;
2683 CurrentGraphicsOutputMode
->FrameBufferBase
= GraphicsOutput
->Mode
->FrameBufferBase
;
2684 CurrentGraphicsOutputMode
->FrameBufferSize
= GraphicsOutput
->Mode
->FrameBufferSize
;
2687 // Allocate resource for the private mode buffer
2689 ModeBuffer
= AllocatePool (sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
) * GraphicsOutput
->Mode
->MaxMode
);
2690 if (ModeBuffer
== NULL
) {
2691 return EFI_OUT_OF_RESOURCES
;
2693 FreePool (Private
->GraphicsOutputModeBuffer
);
2694 Private
->GraphicsOutputModeBuffer
= ModeBuffer
;
2697 // Store all supported display modes to the private mode buffer
2700 for (Index
= 0; Index
< GraphicsOutput
->Mode
->MaxMode
; Index
++) {
2702 // The Info buffer would be allocated by callee
2704 Status
= GraphicsOutput
->QueryMode (GraphicsOutput
, (UINT32
) Index
, &SizeOfInfo
, &Info
);
2705 if (EFI_ERROR (Status
)) {
2708 ASSERT ( SizeOfInfo
<= sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
));
2709 CopyMem (Mode
, Info
, SizeOfInfo
);
2715 // Check intersection of display mode
2717 ModeBuffer
= AllocatePool (sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
) * CurrentGraphicsOutputMode
->MaxMode
);
2718 if (ModeBuffer
== NULL
) {
2719 return EFI_OUT_OF_RESOURCES
;
2722 MatchedMode
= ModeBuffer
;
2723 Mode
= &Private
->GraphicsOutputModeBuffer
[0];
2724 for (Index
= 0; Index
< CurrentGraphicsOutputMode
->MaxMode
; Index
++) {
2727 for (NumberIndex
= 0; NumberIndex
< GraphicsOutput
->Mode
->MaxMode
; NumberIndex
++) {
2729 // The Info buffer would be allocated by callee
2731 Status
= GraphicsOutput
->QueryMode (GraphicsOutput
, (UINT32
) NumberIndex
, &SizeOfInfo
, &Info
);
2732 if (EFI_ERROR (Status
)) {
2735 if ((Info
->HorizontalResolution
== Mode
->HorizontalResolution
) &&
2736 (Info
->VerticalResolution
== Mode
->VerticalResolution
)) {
2738 // If GOP device supports one mode in current mode buffer,
2739 // it will be added into matched mode buffer
2749 AlreadyExist
= FALSE
;
2752 // Check if GOP mode has been in the mode buffer, ModeBuffer = MatchedMode at begin.
2754 for (Info
= ModeBuffer
; Info
< MatchedMode
; Info
++) {
2755 if ((Info
->HorizontalResolution
== Mode
->HorizontalResolution
) &&
2756 (Info
->VerticalResolution
== Mode
->VerticalResolution
)) {
2757 AlreadyExist
= TRUE
;
2762 if (!AlreadyExist
) {
2763 CopyMem (MatchedMode
, Mode
, sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
));
2766 // Physical frame buffer is no longer available, change PixelFormat to PixelBltOnly
2768 MatchedMode
->Version
= 0;
2769 MatchedMode
->PixelFormat
= PixelBltOnly
;
2770 ZeroMem (&MatchedMode
->PixelInformation
, sizeof (EFI_PIXEL_BITMASK
));
2780 // Drop the old mode buffer, assign it to a new one
2782 FreePool (Private
->GraphicsOutputModeBuffer
);
2783 Private
->GraphicsOutputModeBuffer
= ModeBuffer
;
2786 // Physical frame buffer is no longer available when there are more than one physical GOP devices
2788 CurrentGraphicsOutputMode
->MaxMode
= (UINT32
) (((UINTN
) MatchedMode
- (UINTN
) ModeBuffer
) / sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
));
2789 CurrentGraphicsOutputMode
->Info
->PixelFormat
= PixelBltOnly
;
2790 ZeroMem (&CurrentGraphicsOutputMode
->Info
->PixelInformation
, sizeof (EFI_PIXEL_BITMASK
));
2791 CurrentGraphicsOutputMode
->SizeOfInfo
= sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
);
2792 CurrentGraphicsOutputMode
->FrameBufferBase
= (EFI_PHYSICAL_ADDRESS
) (UINTN
) NULL
;
2793 CurrentGraphicsOutputMode
->FrameBufferSize
= 0;
2797 // Graphics console driver can ensure the same mode for all GOP devices
2799 for (Index
= 0; Index
< CurrentGraphicsOutputMode
->MaxMode
; Index
++) {
2800 Mode
= &Private
->GraphicsOutputModeBuffer
[Index
];
2801 if ((Mode
->HorizontalResolution
== GraphicsOutput
->Mode
->Info
->HorizontalResolution
) &&
2802 (Mode
->VerticalResolution
== GraphicsOutput
->Mode
->Info
->VerticalResolution
)) {
2803 CurrentIndex
= Index
;
2807 if (Index
>= CurrentGraphicsOutputMode
->MaxMode
) {
2809 // if user defined mode is not found, set to default mode 800x600
2811 for (Index
= 0; Index
< CurrentGraphicsOutputMode
->MaxMode
; Index
++) {
2812 Mode
= &Private
->GraphicsOutputModeBuffer
[Index
];
2813 if ((Mode
->HorizontalResolution
== 800) && (Mode
->VerticalResolution
== 600)) {
2814 CurrentIndex
= Index
;
2819 } else if (UgaDraw
!= NULL
&& FeaturePcdGet (PcdUgaConsumeSupport
)) {
2821 // Graphics console driver can ensure the same mode for all GOP devices
2822 // so we can get the current mode from this video device
2826 &UgaHorizontalResolution
,
2827 &UgaVerticalResolution
,
2832 CurrentGraphicsOutputMode
->MaxMode
= 1;
2833 Info
= CurrentGraphicsOutputMode
->Info
;
2835 Info
->HorizontalResolution
= UgaHorizontalResolution
;
2836 Info
->VerticalResolution
= UgaVerticalResolution
;
2837 Info
->PixelFormat
= PixelBltOnly
;
2838 Info
->PixelsPerScanLine
= UgaHorizontalResolution
;
2839 CurrentGraphicsOutputMode
->SizeOfInfo
= sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
);
2840 CurrentGraphicsOutputMode
->FrameBufferBase
= (EFI_PHYSICAL_ADDRESS
) (UINTN
) NULL
;
2841 CurrentGraphicsOutputMode
->FrameBufferSize
= 0;
2844 // Update the private mode buffer
2846 CopyMem (&Private
->GraphicsOutputModeBuffer
[0], Info
, sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
));
2849 // Only mode 0 is available to be set
2856 if (GraphicsOutput
!= NULL
) {
2857 Private
->CurrentNumberOfGraphicsOutput
++;
2859 if (UgaDraw
!= NULL
&& FeaturePcdGet (PcdUgaConsumeSupport
)) {
2860 Private
->CurrentNumberOfUgaDraw
++;
2864 // Force GraphicsOutput mode to be set,
2865 // regardless whether the console is in EfiConsoleControlScreenGraphics or EfiConsoleControlScreenText mode
2867 Private
->HardwareNeedsStarting
= TRUE
;
2869 // Current mode number may need update now, so set it to an invalid mode number
2871 CurrentGraphicsOutputMode
->Mode
= 0xffff;
2873 // Graphics console can ensure all GOP devices have the same mode which can be taken as current mode.
2875 Status
= Private
->GraphicsOutput
.SetMode (&Private
->GraphicsOutput
, (UINT32
) CurrentIndex
);
2876 if (EFI_ERROR(Status
)) {
2878 // If user defined mode is not valid for display device, set to the default mode 800x600.
2880 (Private
->GraphicsOutputModeBuffer
[0]).HorizontalResolution
= 800;
2881 (Private
->GraphicsOutputModeBuffer
[0]).VerticalResolution
= 600;
2882 Status
= Private
->GraphicsOutput
.SetMode (&Private
->GraphicsOutput
, 0);
2889 Set the current console out mode.
2891 This routine will get the current console mode information (column, row)
2892 from ConsoleOutMode variable and set it; if the variable does not exist,
2893 set to user defined console mode.
2895 @param Private Consplitter Text Out pointer.
2899 ConsplitterSetConsoleOutMode (
2900 IN TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
2910 CONSOLE_OUT_MODE ModeInfo
;
2911 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
;
2915 TextOut
= &Private
->TextOut
;
2916 MaxMode
= (UINTN
) (TextOut
->Mode
->MaxMode
);
2918 ModeInfo
.Column
= PcdGet32 (PcdConOutColumn
);
2919 ModeInfo
.Row
= PcdGet32 (PcdConOutRow
);
2922 // To find the prefer mode and basic mode from Text Out mode list
2924 for (Mode
= 0; Mode
< MaxMode
; Mode
++) {
2925 Status
= TextOut
->QueryMode (TextOut
, Mode
, &Col
, &Row
);
2926 if (!EFI_ERROR(Status
)) {
2927 if (Col
== ModeInfo
.Column
&& Row
== ModeInfo
.Row
) {
2930 if (Col
== 80 && Row
== 25) {
2937 // Set prefer mode to Text Out devices.
2939 Status
= TextOut
->SetMode (TextOut
, PreferMode
);
2940 if (EFI_ERROR(Status
)) {
2942 // if current mode setting is failed, default 80x25 mode will be set.
2944 Status
= TextOut
->SetMode (TextOut
, BaseMode
);
2945 ASSERT(!EFI_ERROR(Status
));
2947 PcdSet32 (PcdConOutColumn
, 80);
2948 PcdSet32 (PcdConOutRow
, 25);
2956 Add Text Output Device in Consplitter Text Output list.
2958 @param Private Text Out Splitter pointer.
2959 @param TextOut Simple Text Output protocol pointer.
2960 @param GraphicsOutput Graphics Output protocol pointer.
2961 @param UgaDraw UGA Draw protocol pointer.
2963 @retval EFI_SUCCESS Text Output Device added successfully.
2964 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
2968 ConSplitterTextOutAddDevice (
2969 IN TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
,
2970 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
,
2971 IN EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
,
2972 IN EFI_UGA_DRAW_PROTOCOL
*UgaDraw
2976 UINTN CurrentNumOfConsoles
;
2979 UINT32 UgaHorizontalResolution
;
2980 UINT32 UgaVerticalResolution
;
2981 UINT32 UgaColorDepth
;
2982 UINT32 UgaRefreshRate
;
2983 TEXT_OUT_AND_GOP_DATA
*TextAndGop
;
2985 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*Info
;
2987 Status
= EFI_SUCCESS
;
2988 CurrentNumOfConsoles
= Private
->CurrentNumberOfConsoles
;
2991 // If the Text Out List is full, enlarge it by calling ConSplitterGrowBuffer().
2993 while (CurrentNumOfConsoles
>= Private
->TextOutListCount
) {
2994 Status
= ConSplitterGrowBuffer (
2995 sizeof (TEXT_OUT_AND_GOP_DATA
),
2996 &Private
->TextOutListCount
,
2997 (VOID
**) &Private
->TextOutList
2999 if (EFI_ERROR (Status
)) {
3000 return EFI_OUT_OF_RESOURCES
;
3003 // Also need to reallocate the TextOutModeMap table
3005 Status
= ConSplitterGrowMapTable (Private
);
3006 if (EFI_ERROR (Status
)) {
3007 return EFI_OUT_OF_RESOURCES
;
3011 TextAndGop
= &Private
->TextOutList
[CurrentNumOfConsoles
];
3013 TextAndGop
->TextOut
= TextOut
;
3014 TextAndGop
->GraphicsOutput
= GraphicsOutput
;
3015 TextAndGop
->UgaDraw
= UgaDraw
;
3017 if ((GraphicsOutput
== NULL
) && (UgaDraw
== NULL
)) {
3019 // If No GOP/UGA device then use the ConOut device
3021 TextAndGop
->TextOutEnabled
= TRUE
;
3024 // If GOP/UGA device use ConOut device only used if screen is in Text mode
3026 TextAndGop
->TextOutEnabled
= (BOOLEAN
) (Private
->ConsoleOutputMode
== EfiConsoleControlScreenText
);
3029 if (CurrentNumOfConsoles
== 0) {
3031 // Add the first device's output mode to console splitter's mode list
3033 Status
= ConSplitterAddOutputMode (Private
, TextOut
);
3035 ConSplitterSyncOutputMode (Private
, TextOut
);
3038 Private
->CurrentNumberOfConsoles
++;
3041 // Scan both TextOutList, for the intersection TextOut device
3042 // maybe both ConOut and StdErr incorporate the same Text Out
3043 // device in them, thus the output of both should be synced.
3045 ConSplitterGetIntersectionBetweenConOutAndStrErr ();
3047 CurrentMode
= Private
->TextOutMode
.Mode
;
3048 MaxMode
= Private
->TextOutMode
.MaxMode
;
3049 ASSERT (MaxMode
>= 1);
3051 if (FeaturePcdGet (PcdConOutGopSupport
)) {
3053 // If GOP is produced by Consplitter, this device display mode will be added into Graphics Ouput modes.
3055 if ((GraphicsOutput
!= NULL
) || (UgaDraw
!= NULL
&& FeaturePcdGet (PcdUgaConsumeSupport
))) {
3056 ConSplitterAddGraphicsOutputMode (Private
, GraphicsOutput
, UgaDraw
);
3060 if (FeaturePcdGet (PcdConOutUgaSupport
)) {
3061 UgaHorizontalResolution
= 800;
3062 UgaVerticalResolution
= 600;
3064 UgaRefreshRate
= 60;
3066 Status
= EFI_DEVICE_ERROR
;
3068 // If UGA is produced by Consplitter
3070 if (GraphicsOutput
!= NULL
) {
3071 Status
= GraphicsOutput
->QueryMode (GraphicsOutput
, GraphicsOutput
->Mode
->Mode
, &SizeOfInfo
, &Info
);
3072 if (EFI_ERROR (Status
)) {
3075 ASSERT ( SizeOfInfo
<= sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
));
3077 UgaHorizontalResolution
= Info
->HorizontalResolution
;
3078 UgaVerticalResolution
= Info
->VerticalResolution
;
3082 } else if (UgaDraw
!= NULL
&& FeaturePcdGet (PcdUgaConsumeSupport
)) {
3083 Status
= UgaDraw
->GetMode (
3085 &UgaHorizontalResolution
,
3086 &UgaVerticalResolution
,
3093 // Set UGA Draw mode,
3094 // if GetMode is failed, set to 800x600 mode
3096 Status
= ConSpliterUgaDrawSetMode (
3098 UgaHorizontalResolution
,
3099 UgaVerticalResolution
,
3105 if (Private
->ConsoleOutputMode
== EfiConsoleControlScreenGraphics
&& GraphicsOutput
!= NULL
) {
3107 // We just added a new GOP or UGA device in graphics mode
3109 if (FeaturePcdGet (PcdConOutGopSupport
)) {
3111 // Sync display output on new device based on GOP settings.
3113 DevNullGopSync (Private
, TextAndGop
->GraphicsOutput
, TextAndGop
->UgaDraw
);
3114 } else if (FeaturePcdGet (PcdConOutUgaSupport
)) {
3116 // Sync display output on new device based on UGA settings.
3118 DevNullUgaSync (Private
, TextAndGop
->GraphicsOutput
, TextAndGop
->UgaDraw
);
3120 } else if ((CurrentMode
>= 0) && ((GraphicsOutput
!= NULL
) || (UgaDraw
!= NULL
)) && (CurrentMode
< Private
->TextOutMode
.MaxMode
)) {
3122 // The new console supports the same mode of the current console so sync up
3124 DevNullSyncStdOut (Private
);
3127 // If ConOut, then set the mode to Mode #0 which us 80 x 25
3129 Private
->TextOut
.SetMode (&Private
->TextOut
, 0);
3133 // After adding new console device, all existing console devices should be
3134 // synced to the current shared mode.
3136 ConsplitterSetConsoleOutMode (Private
);
3143 Remove Text Out Device in Consplitter Text Out list.
3145 @param Private Text Out Splitter pointer.
3146 @param TextOut Simple Text Output Pointer protocol pointer.
3148 @retval EFI_SUCCESS Text Out Device removed successfully.
3149 @retval EFI_NOT_FOUND No Text Out Device found.
3153 ConSplitterTextOutDeleteDevice (
3154 IN TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
,
3155 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
3159 UINTN CurrentNumOfConsoles
;
3160 TEXT_OUT_AND_GOP_DATA
*TextOutList
;
3164 // Remove the specified text-out device data structure from the Text out List,
3165 // and rearrange the remaining data structures in the Text out List.
3167 CurrentNumOfConsoles
= Private
->CurrentNumberOfConsoles
;
3168 Index
= (INT32
) CurrentNumOfConsoles
- 1;
3169 TextOutList
= Private
->TextOutList
;
3170 while (Index
>= 0) {
3171 if (TextOutList
->TextOut
== TextOut
) {
3172 CopyMem (TextOutList
, TextOutList
+ 1, sizeof (TEXT_OUT_AND_GOP_DATA
) * Index
);
3173 CurrentNumOfConsoles
--;
3174 if (TextOutList
->UgaDraw
!= NULL
&& FeaturePcdGet (PcdUgaConsumeSupport
)) {
3175 Private
->CurrentNumberOfUgaDraw
--;
3177 if (TextOutList
->GraphicsOutput
!= NULL
) {
3178 Private
->CurrentNumberOfGraphicsOutput
--;
3187 // The specified TextOut is not managed by the ConSplitter driver
3190 return EFI_NOT_FOUND
;
3193 if (CurrentNumOfConsoles
== 0) {
3195 // If the number of consoles is zero clear the Dev NULL device
3197 Private
->CurrentNumberOfConsoles
= 0;
3198 Private
->TextOutMode
.MaxMode
= 1;
3199 Private
->TextOutQueryData
[0].Columns
= 80;
3200 Private
->TextOutQueryData
[0].Rows
= 25;
3201 DevNullTextOutSetMode (Private
, 0);
3206 // Max Mode is realy an intersection of the QueryMode command to all
3207 // devices. So we must copy the QueryMode of the first device to
3211 Private
->TextOutQueryData
,
3212 Private
->TextOutQueryDataCount
* sizeof (TEXT_OUT_SPLITTER_QUERY_DATA
)
3215 FreePool (Private
->TextOutModeMap
);
3216 Private
->TextOutModeMap
= NULL
;
3217 TextOutList
= Private
->TextOutList
;
3220 // Add the first TextOut to the QueryData array and ModeMap table
3222 Status
= ConSplitterAddOutputMode (Private
, TextOutList
->TextOut
);
3225 // Now add one by one
3228 Private
->CurrentNumberOfConsoles
= 1;
3230 while ((UINTN
) Index
< CurrentNumOfConsoles
) {
3231 ConSplitterSyncOutputMode (Private
, TextOutList
->TextOut
);
3233 Private
->CurrentNumberOfConsoles
++;
3237 ConSplitterGetIntersectionBetweenConOutAndStrErr ();
3244 Reset the input device and optionaly run diagnostics
3246 @param This Protocol instance pointer.
3247 @param ExtendedVerification Driver may perform diagnostics on reset.
3249 @retval EFI_SUCCESS The device was reset.
3250 @retval EFI_DEVICE_ERROR The device is not functioning properly and could
3256 ConSplitterTextInReset (
3257 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*This
,
3258 IN BOOLEAN ExtendedVerification
3262 EFI_STATUS ReturnStatus
;
3263 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3266 Private
= TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
3268 Private
->KeyEventSignalState
= FALSE
;
3271 // return the worst status met
3273 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
3274 Status
= Private
->TextInList
[Index
]->Reset (
3275 Private
->TextInList
[Index
],
3276 ExtendedVerification
3278 if (EFI_ERROR (Status
)) {
3279 ReturnStatus
= Status
;
3283 return ReturnStatus
;
3288 Reads the next keystroke from the input device. The WaitForKey Event can
3289 be used to test for existance of a keystroke via WaitForEvent () call.
3291 @param Private Protocol instance pointer.
3292 @param Key Driver may perform diagnostics on reset.
3294 @retval EFI_SUCCESS The keystroke information was returned.
3295 @retval EFI_NOT_READY There was no keystroke data availiable.
3296 @retval EFI_DEVICE_ERROR The keydtroke information was not returned due
3302 ConSplitterTextInPrivateReadKeyStroke (
3303 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
3304 OUT EFI_INPUT_KEY
*Key
3309 EFI_INPUT_KEY CurrentKey
;
3311 Key
->UnicodeChar
= 0;
3312 Key
->ScanCode
= SCAN_NULL
;
3315 // if no physical console input device exists, return EFI_NOT_READY;
3316 // if any physical console input device has key input,
3317 // return the key and EFI_SUCCESS.
3319 for (Index
= 0; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
3320 Status
= Private
->TextInList
[Index
]->ReadKeyStroke (
3321 Private
->TextInList
[Index
],
3324 if (!EFI_ERROR (Status
)) {
3330 return EFI_NOT_READY
;
3334 Return TRUE if StdIn is locked. The ConIn device on the virtual handle is
3335 the only device locked.
3337 @retval TRUE StdIn locked
3338 @retval FALSE StdIn working normally
3342 ConSpliterConssoleControlStdInLocked (
3346 return mConIn
.PasswordEnabled
;
3351 Record and check key sequence on StdIn.
3353 This timer event will fire when StdIn is locked. It will record the key sequence
3354 on StdIn and also check to see if it matches the password. Any error in the
3355 password will cause the check to reset. As long as a mConIn.PasswordEnabled is
3356 TRUE, the StdIn splitter will not report any input.
3358 @param Event The Event this notify function registered to.
3359 @param Context Pointer to the context data registerd to the
3364 ConSpliterConsoleControlLockStdInEvent (
3371 CHAR16 BackSpaceString
[2];
3372 CHAR16 SpaceString
[2];
3375 Status
= ConSplitterTextInPrivateReadKeyStroke (&mConIn
, &Key
);
3376 if (!EFI_ERROR (Status
)) {
3378 // If key read successfully
3380 if ((Key
.UnicodeChar
== CHAR_CARRIAGE_RETURN
) && (Key
.ScanCode
== SCAN_NULL
)) {
3382 // If it's an ENTER, match password
3384 mConIn
.PwdAttempt
[mConIn
.PwdIndex
] = CHAR_NULL
;
3385 if (StrCmp (mConIn
.Password
, mConIn
.PwdAttempt
) != 0) {
3387 // Password not match
3389 ConSplitterTextOutOutputString (&mConOut
.TextOut
, (CHAR16
*) L
"\n\rPassword not correct\n\r");
3390 mConIn
.PwdIndex
= 0;
3393 // Key matches password sequence
3395 gBS
->SetTimer (mConIn
.LockEvent
, TimerPeriodic
, 0);
3396 mConIn
.PasswordEnabled
= FALSE
;
3397 Status
= EFI_NOT_READY
;
3399 } else if ((Key
.UnicodeChar
== CHAR_BACKSPACE
) && (Key
.ScanCode
== SCAN_NULL
)) {
3403 if (mConIn
.PwdIndex
> 0) {
3404 BackSpaceString
[0] = CHAR_BACKSPACE
;
3405 BackSpaceString
[1] = 0;
3407 SpaceString
[0] = L
' ';
3410 ConSplitterTextOutOutputString (&mConOut
.TextOut
, BackSpaceString
);
3411 ConSplitterTextOutOutputString (&mConOut
.TextOut
, SpaceString
);
3412 ConSplitterTextOutOutputString (&mConOut
.TextOut
, BackSpaceString
);
3416 } else if ((Key
.ScanCode
== SCAN_NULL
) && (Key
.UnicodeChar
>= 32)) {
3418 // If it's not an ENTER, neigher a function key, nor a CTRL-X or ALT-X, record the input,
3419 // value 32 stands for a Blank Space key.
3421 if (mConIn
.PwdIndex
< (MAX_STD_IN_PASSWORD
- 1)) {
3422 if (mConIn
.PwdIndex
== 0) {
3423 ConSplitterTextOutOutputString (&mConOut
.TextOut
, (CHAR16
*) L
"\n\r");
3426 ConSplitterTextOutOutputString (&mConOut
.TextOut
, (CHAR16
*) L
"*");
3427 mConIn
.PwdAttempt
[mConIn
.PwdIndex
] = Key
.UnicodeChar
;
3432 } while (!EFI_ERROR (Status
));
3437 If Password is NULL or the Password is too big, then return an error. If the
3438 Password is valid, then store the password, lock StdIn and arm the periodic timer.
3440 @param This Console Control protocol pointer.
3441 @param Password The password input.
3443 @retval EFI_SUCCESS Lock the StdIn device.
3444 @retval EFI_INVALID_PARAMETER Password is NULL.
3445 @retval EFI_OUT_OF_RESOURCES Buffer allocation to store the password fails.
3450 ConSpliterConsoleControlLockStdIn (
3451 IN EFI_CONSOLE_CONTROL_PROTOCOL
*This
,
3455 if (Password
== NULL
) {
3456 return EFI_INVALID_PARAMETER
;
3459 if (StrLen (Password
) >= MAX_STD_IN_PASSWORD
) {
3461 // Currently have a max password size
3463 return EFI_OUT_OF_RESOURCES
;
3466 // Save the password, initialize state variables and arm event timer
3468 StrCpy (mConIn
.Password
, Password
);
3469 mConIn
.PasswordEnabled
= TRUE
;
3470 mConIn
.PwdIndex
= 0;
3472 // Lock Timer Periodic is 25ms.
3474 gBS
->SetTimer (mConIn
.LockEvent
, TimerPeriodic
, 10000 * 25);
3481 Reads the next keystroke from the input device. The WaitForKey Event can
3482 be used to test for existance of a keystroke via WaitForEvent () call.
3483 If the ConIn is password locked make it look like no keystroke is availible
3485 @param This Protocol instance pointer.
3486 @param Key Driver may perform diagnostics on reset.
3488 @retval EFI_SUCCESS The keystroke information was returned.
3489 @retval EFI_NOT_READY There was no keystroke data availiable.
3490 @retval EFI_DEVICE_ERROR The keydtroke information was not returned due
3496 ConSplitterTextInReadKeyStroke (
3497 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*This
,
3498 OUT EFI_INPUT_KEY
*Key
3501 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3503 Private
= TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
3504 if (Private
->PasswordEnabled
) {
3506 // If StdIn Locked return not ready
3508 return EFI_NOT_READY
;
3511 Private
->KeyEventSignalState
= FALSE
;
3513 return ConSplitterTextInPrivateReadKeyStroke (Private
, Key
);
3518 This event aggregates all the events of the ConIn devices in the spliter.
3520 If the ConIn is password locked then return.
3521 If any events of physical ConIn devices are signaled, signal the ConIn
3522 spliter event. This will cause the calling code to call
3523 ConSplitterTextInReadKeyStroke ().
3525 @param Event The Event assoicated with callback.
3526 @param Context Context registered when Event was created.
3531 ConSplitterTextInWaitForKey (
3537 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3540 Private
= (TEXT_IN_SPLITTER_PRIVATE_DATA
*) Context
;
3542 if (Private
->PasswordEnabled
) {
3544 // If StdIn Locked return not ready
3549 if (Private
->KeyEventSignalState
) {
3551 // If KeyEventSignalState is flagged before, and not cleared by Reset() or ReadKeyStroke()
3553 gBS
->SignalEvent (Event
);
3558 // If any physical console input device has key input, signal the event.
3560 for (Index
= 0; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
3561 Status
= gBS
->CheckEvent (Private
->TextInList
[Index
]->WaitForKey
);
3562 if (!EFI_ERROR (Status
)) {
3563 gBS
->SignalEvent (Event
);
3564 Private
->KeyEventSignalState
= TRUE
;
3572 Test if the key has been registered on input device.
3574 @param RegsiteredData A pointer to a buffer that is filled in with the
3575 keystroke state data for the key that was
3577 @param InputData A pointer to a buffer that is filled in with the
3578 keystroke state data for the key that was
3581 @retval TRUE Key be pressed matches a registered key.
3582 @retval FLASE Match failed.
3587 IN EFI_KEY_DATA
*RegsiteredData
,
3588 IN EFI_KEY_DATA
*InputData
3591 ASSERT (RegsiteredData
!= NULL
&& InputData
!= NULL
);
3593 if ((RegsiteredData
->Key
.ScanCode
!= InputData
->Key
.ScanCode
) ||
3594 (RegsiteredData
->Key
.UnicodeChar
!= InputData
->Key
.UnicodeChar
)) {
3599 // Assume KeyShiftState/KeyToggleState = 0 in Registered key data means these state could be ignored.
3601 if (RegsiteredData
->KeyState
.KeyShiftState
!= 0 &&
3602 RegsiteredData
->KeyState
.KeyShiftState
!= InputData
->KeyState
.KeyShiftState
) {
3605 if (RegsiteredData
->KeyState
.KeyToggleState
!= 0 &&
3606 RegsiteredData
->KeyState
.KeyToggleState
!= InputData
->KeyState
.KeyToggleState
) {
3616 Reset the input device and optionaly run diagnostics
3618 @param This Protocol instance pointer.
3619 @param ExtendedVerification Driver may perform diagnostics on reset.
3621 @retval EFI_SUCCESS The device was reset.
3622 @retval EFI_DEVICE_ERROR The device is not functioning properly and could
3628 ConSplitterTextInResetEx (
3629 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*This
,
3630 IN BOOLEAN ExtendedVerification
3634 EFI_STATUS ReturnStatus
;
3635 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3638 Private
= TEXT_IN_EX_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
3640 Private
->KeyEventSignalState
= FALSE
;
3643 // return the worst status met
3645 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfExConsoles
; Index
++) {
3646 Status
= Private
->TextInExList
[Index
]->Reset (
3647 Private
->TextInExList
[Index
],
3648 ExtendedVerification
3650 if (EFI_ERROR (Status
)) {
3651 ReturnStatus
= Status
;
3655 return ReturnStatus
;
3661 Reads the next keystroke from the input device. The WaitForKey Event can
3662 be used to test for existance of a keystroke via WaitForEvent () call.
3664 @param This Protocol instance pointer.
3665 @param KeyData A pointer to a buffer that is filled in with the
3666 keystroke state data for the key that was
3669 @retval EFI_SUCCESS The keystroke information was returned.
3670 @retval EFI_NOT_READY There was no keystroke data availiable.
3671 @retval EFI_DEVICE_ERROR The keystroke information was not returned due
3673 @retval EFI_INVALID_PARAMETER KeyData is NULL.
3678 ConSplitterTextInReadKeyStrokeEx (
3679 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*This
,
3680 OUT EFI_KEY_DATA
*KeyData
3683 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3686 EFI_KEY_DATA CurrentKeyData
;
3689 if (KeyData
== NULL
) {
3690 return EFI_INVALID_PARAMETER
;
3693 Private
= TEXT_IN_EX_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
3694 if (Private
->PasswordEnabled
) {
3696 // If StdIn Locked return not ready
3698 return EFI_NOT_READY
;
3701 Private
->KeyEventSignalState
= FALSE
;
3703 KeyData
->Key
.UnicodeChar
= 0;
3704 KeyData
->Key
.ScanCode
= SCAN_NULL
;
3707 // if no physical console input device exists, return EFI_NOT_READY;
3708 // if any physical console input device has key input,
3709 // return the key and EFI_SUCCESS.
3711 for (Index
= 0; Index
< Private
->CurrentNumberOfExConsoles
; Index
++) {
3712 Status
= Private
->TextInExList
[Index
]->ReadKeyStrokeEx (
3713 Private
->TextInExList
[Index
],
3716 if (!EFI_ERROR (Status
)) {
3717 CopyMem (KeyData
, &CurrentKeyData
, sizeof (CurrentKeyData
));
3722 return EFI_NOT_READY
;
3727 Set certain state for the input device.
3729 @param This Protocol instance pointer.
3730 @param KeyToggleState A pointer to the EFI_KEY_TOGGLE_STATE to set the
3731 state for the input device.
3733 @retval EFI_SUCCESS The device state was set successfully.
3734 @retval EFI_DEVICE_ERROR The device is not functioning correctly and
3735 could not have the setting adjusted.
3736 @retval EFI_UNSUPPORTED The device does not have the ability to set its
3738 @retval EFI_INVALID_PARAMETER KeyToggleState is NULL.
3743 ConSplitterTextInSetState (
3744 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*This
,
3745 IN EFI_KEY_TOGGLE_STATE
*KeyToggleState
3748 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3752 if (KeyToggleState
== NULL
) {
3753 return EFI_INVALID_PARAMETER
;
3756 Private
= TEXT_IN_EX_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
3759 // if no physical console input device exists, return EFI_SUCCESS;
3760 // otherwise return the status of setting state of physical console input device
3762 for (Index
= 0; Index
< Private
->CurrentNumberOfExConsoles
; Index
++) {
3763 Status
= Private
->TextInExList
[Index
]->SetState (
3764 Private
->TextInExList
[Index
],
3767 if (EFI_ERROR (Status
)) {
3778 Register a notification function for a particular keystroke for the input device.
3780 @param This Protocol instance pointer.
3781 @param KeyData A pointer to a buffer that is filled in with the
3782 keystroke information data for the key that was
3784 @param KeyNotificationFunction Points to the function to be called when the key
3785 sequence is typed specified by KeyData.
3786 @param NotifyHandle Points to the unique handle assigned to the
3787 registered notification.
3789 @retval EFI_SUCCESS The notification function was registered
3791 @retval EFI_OUT_OF_RESOURCES Unable to allocate resources for necesssary data
3793 @retval EFI_INVALID_PARAMETER KeyData or KeyNotificationFunction or NotifyHandle is NULL.
3798 ConSplitterTextInRegisterKeyNotify (
3799 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*This
,
3800 IN EFI_KEY_DATA
*KeyData
,
3801 IN EFI_KEY_NOTIFY_FUNCTION KeyNotificationFunction
,
3802 OUT EFI_HANDLE
*NotifyHandle
3805 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3808 TEXT_IN_EX_SPLITTER_NOTIFY
*NewNotify
;
3810 TEXT_IN_EX_SPLITTER_NOTIFY
*CurrentNotify
;
3813 if (KeyData
== NULL
|| NotifyHandle
== NULL
|| KeyNotificationFunction
== NULL
) {
3814 return EFI_INVALID_PARAMETER
;
3817 Private
= TEXT_IN_EX_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
3820 // If no physical console input device exists,
3821 // return EFI_SUCCESS directly.
3823 if (Private
->CurrentNumberOfExConsoles
<= 0) {
3828 // Return EFI_SUCCESS if the (KeyData, NotificationFunction) is already registered.
3830 for (Link
= Private
->NotifyList
.ForwardLink
; Link
!= &Private
->NotifyList
; Link
= Link
->ForwardLink
) {
3831 CurrentNotify
= TEXT_IN_EX_SPLITTER_NOTIFY_FROM_THIS (Link
);
3832 if (IsKeyRegistered (&CurrentNotify
->KeyData
, KeyData
)) {
3833 if (CurrentNotify
->KeyNotificationFn
== KeyNotificationFunction
) {
3834 *NotifyHandle
= CurrentNotify
->NotifyHandle
;
3841 // Allocate resource to save the notification function
3843 NewNotify
= (TEXT_IN_EX_SPLITTER_NOTIFY
*) AllocateZeroPool (sizeof (TEXT_IN_EX_SPLITTER_NOTIFY
));
3844 if (NewNotify
== NULL
) {
3845 return EFI_OUT_OF_RESOURCES
;
3847 NewNotify
->NotifyHandleList
= (EFI_HANDLE
*) AllocateZeroPool (sizeof (EFI_HANDLE
) * Private
->CurrentNumberOfExConsoles
);
3848 if (NewNotify
->NotifyHandleList
== NULL
) {
3849 gBS
->FreePool (NewNotify
);
3850 return EFI_OUT_OF_RESOURCES
;
3852 NewNotify
->Signature
= TEXT_IN_EX_SPLITTER_NOTIFY_SIGNATURE
;
3853 NewNotify
->KeyNotificationFn
= KeyNotificationFunction
;
3854 NewNotify
->NotifyHandle
= (EFI_HANDLE
) NewNotify
;
3855 CopyMem (&NewNotify
->KeyData
, KeyData
, sizeof (KeyData
));
3858 // Return the wrong status of registering key notify of
3859 // physical console input device if meet problems
3861 for (Index
= 0; Index
< Private
->CurrentNumberOfExConsoles
; Index
++) {
3862 Status
= Private
->TextInExList
[Index
]->RegisterKeyNotify (
3863 Private
->TextInExList
[Index
],
3865 KeyNotificationFunction
,
3866 &NewNotify
->NotifyHandleList
[Index
]
3868 if (EFI_ERROR (Status
)) {
3869 gBS
->FreePool (NewNotify
->NotifyHandleList
);
3870 gBS
->FreePool (NewNotify
);
3875 InsertTailList (&mConIn
.NotifyList
, &NewNotify
->NotifyEntry
);
3877 *NotifyHandle
= NewNotify
->NotifyHandle
;
3885 Remove a registered notification function from a particular keystroke.
3887 @param This Protocol instance pointer.
3888 @param NotificationHandle The handle of the notification function being
3891 @retval EFI_SUCCESS The notification function was unregistered
3893 @retval EFI_INVALID_PARAMETER The NotificationHandle is invalid.
3894 @retval EFI_NOT_FOUND Can not find the matching entry in database.
3899 ConSplitterTextInUnregisterKeyNotify (
3900 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*This
,
3901 IN EFI_HANDLE NotificationHandle
3904 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3907 TEXT_IN_EX_SPLITTER_NOTIFY
*CurrentNotify
;
3910 if (NotificationHandle
== NULL
) {
3911 return EFI_INVALID_PARAMETER
;
3914 if (((TEXT_IN_EX_SPLITTER_NOTIFY
*) NotificationHandle
)->Signature
!= TEXT_IN_EX_SPLITTER_NOTIFY_SIGNATURE
) {
3915 return EFI_INVALID_PARAMETER
;
3918 Private
= TEXT_IN_EX_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
3921 // if no physical console input device exists,
3922 // return EFI_SUCCESS directly.
3924 if (Private
->CurrentNumberOfExConsoles
<= 0) {
3928 for (Link
= Private
->NotifyList
.ForwardLink
; Link
!= &Private
->NotifyList
; Link
= Link
->ForwardLink
) {
3929 CurrentNotify
= TEXT_IN_EX_SPLITTER_NOTIFY_FROM_THIS (Link
);
3930 if (CurrentNotify
->NotifyHandle
== NotificationHandle
) {
3931 for (Index
= 0; Index
< Private
->CurrentNumberOfExConsoles
; Index
++) {
3932 Status
= Private
->TextInExList
[Index
]->UnregisterKeyNotify (
3933 Private
->TextInExList
[Index
],
3934 CurrentNotify
->NotifyHandleList
[Index
]
3936 if (EFI_ERROR (Status
)) {
3940 RemoveEntryList (&CurrentNotify
->NotifyEntry
);
3942 gBS
->FreePool (CurrentNotify
->NotifyHandleList
);
3943 gBS
->FreePool (CurrentNotify
);
3948 return EFI_NOT_FOUND
;
3954 Reset the input device and optionaly run diagnostics
3956 @param This Protocol instance pointer.
3957 @param ExtendedVerification Driver may perform diagnostics on reset.
3959 @retval EFI_SUCCESS The device was reset.
3960 @retval EFI_DEVICE_ERROR The device is not functioning properly and could
3966 ConSplitterSimplePointerReset (
3967 IN EFI_SIMPLE_POINTER_PROTOCOL
*This
,
3968 IN BOOLEAN ExtendedVerification
3972 EFI_STATUS ReturnStatus
;
3973 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3976 Private
= TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_SIMPLE_POINTER_THIS (This
);
3978 Private
->InputEventSignalState
= FALSE
;
3980 if (Private
->CurrentNumberOfPointers
== 0) {
3984 // return the worst status met
3986 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfPointers
; Index
++) {
3987 Status
= Private
->PointerList
[Index
]->Reset (
3988 Private
->PointerList
[Index
],
3989 ExtendedVerification
3991 if (EFI_ERROR (Status
)) {
3992 ReturnStatus
= Status
;
3996 return ReturnStatus
;
4001 Reads the next keystroke from the input device. The WaitForKey Event can
4002 be used to test for existance of a keystroke via WaitForEvent () call.
4004 @param Private Protocol instance pointer.
4005 @param State The state information of simple pointer device.
4007 @retval EFI_SUCCESS The keystroke information was returned.
4008 @retval EFI_NOT_READY There was no keystroke data availiable.
4009 @retval EFI_DEVICE_ERROR The keydtroke information was not returned due
4015 ConSplitterSimplePointerPrivateGetState (
4016 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
4017 IN OUT EFI_SIMPLE_POINTER_STATE
*State
4021 EFI_STATUS ReturnStatus
;
4023 EFI_SIMPLE_POINTER_STATE CurrentState
;
4025 State
->RelativeMovementX
= 0;
4026 State
->RelativeMovementY
= 0;
4027 State
->RelativeMovementZ
= 0;
4028 State
->LeftButton
= FALSE
;
4029 State
->RightButton
= FALSE
;
4032 // if no physical console input device exists, return EFI_NOT_READY;
4033 // if any physical console input device has key input,
4034 // return the key and EFI_SUCCESS.
4036 ReturnStatus
= EFI_NOT_READY
;
4037 for (Index
= 0; Index
< Private
->CurrentNumberOfPointers
; Index
++) {
4039 Status
= Private
->PointerList
[Index
]->GetState (
4040 Private
->PointerList
[Index
],
4043 if (!EFI_ERROR (Status
)) {
4044 if (ReturnStatus
== EFI_NOT_READY
) {
4045 ReturnStatus
= EFI_SUCCESS
;
4048 if (CurrentState
.LeftButton
) {
4049 State
->LeftButton
= TRUE
;
4052 if (CurrentState
.RightButton
) {
4053 State
->RightButton
= TRUE
;
4056 if (CurrentState
.RelativeMovementX
!= 0 && Private
->PointerList
[Index
]->Mode
->ResolutionX
!= 0) {
4057 State
->RelativeMovementX
+= (CurrentState
.RelativeMovementX
* (INT32
) Private
->SimplePointerMode
.ResolutionX
) / (INT32
) Private
->PointerList
[Index
]->Mode
->ResolutionX
;
4060 if (CurrentState
.RelativeMovementY
!= 0 && Private
->PointerList
[Index
]->Mode
->ResolutionY
!= 0) {
4061 State
->RelativeMovementY
+= (CurrentState
.RelativeMovementY
* (INT32
) Private
->SimplePointerMode
.ResolutionY
) / (INT32
) Private
->PointerList
[Index
]->Mode
->ResolutionY
;
4064 if (CurrentState
.RelativeMovementZ
!= 0 && Private
->PointerList
[Index
]->Mode
->ResolutionZ
!= 0) {
4065 State
->RelativeMovementZ
+= (CurrentState
.RelativeMovementZ
* (INT32
) Private
->SimplePointerMode
.ResolutionZ
) / (INT32
) Private
->PointerList
[Index
]->Mode
->ResolutionZ
;
4067 } else if (Status
== EFI_DEVICE_ERROR
) {
4068 ReturnStatus
= EFI_DEVICE_ERROR
;
4072 return ReturnStatus
;
4077 Reads the next keystroke from the input device. The WaitForKey Event can
4078 be used to test for existance of a keystroke via WaitForEvent () call.
4079 If the ConIn is password locked make it look like no keystroke is availible
4081 @param This A pointer to protocol instance.
4082 @param State A pointer to state information on the pointer device
4084 @retval EFI_SUCCESS The keystroke information was returned in State.
4085 @retval EFI_NOT_READY There was no keystroke data availiable.
4086 @retval EFI_DEVICE_ERROR The keydtroke information was not returned due
4092 ConSplitterSimplePointerGetState (
4093 IN EFI_SIMPLE_POINTER_PROTOCOL
*This
,
4094 IN OUT EFI_SIMPLE_POINTER_STATE
*State
4097 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
4099 Private
= TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_SIMPLE_POINTER_THIS (This
);
4100 if (Private
->PasswordEnabled
) {
4102 // If StdIn Locked return not ready
4104 return EFI_NOT_READY
;
4107 Private
->InputEventSignalState
= FALSE
;
4109 return ConSplitterSimplePointerPrivateGetState (Private
, State
);
4114 This event agregates all the events of the ConIn devices in the spliter.
4115 If the ConIn is password locked then return.
4116 If any events of physical ConIn devices are signaled, signal the ConIn
4117 spliter event. This will cause the calling code to call
4118 ConSplitterTextInReadKeyStroke ().
4120 @param Event The Event assoicated with callback.
4121 @param Context Context registered when Event was created.
4126 ConSplitterSimplePointerWaitForInput (
4132 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
4135 Private
= (TEXT_IN_SPLITTER_PRIVATE_DATA
*) Context
;
4136 if (Private
->PasswordEnabled
) {
4138 // If StdIn Locked return not ready
4144 // if InputEventSignalState is flagged before, and not cleared by Reset() or ReadKeyStroke()
4146 if (Private
->InputEventSignalState
) {
4147 gBS
->SignalEvent (Event
);
4151 // if any physical console input device has key input, signal the event.
4153 for (Index
= 0; Index
< Private
->CurrentNumberOfPointers
; Index
++) {
4154 Status
= gBS
->CheckEvent (Private
->PointerList
[Index
]->WaitForInput
);
4155 if (!EFI_ERROR (Status
)) {
4156 gBS
->SignalEvent (Event
);
4157 Private
->InputEventSignalState
= TRUE
;
4163 Resets the pointer device hardware.
4165 @param This Protocol instance pointer.
4166 @param ExtendedVerification Driver may perform diagnostics on reset.
4168 @retval EFI_SUCCESS The device was reset.
4169 @retval EFI_DEVICE_ERROR The device is not functioning correctly and
4175 ConSplitterAbsolutePointerReset (
4176 IN EFI_ABSOLUTE_POINTER_PROTOCOL
*This
,
4177 IN BOOLEAN ExtendedVerification
4181 EFI_STATUS ReturnStatus
;
4182 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
4185 Private
= TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_ABSOLUTE_POINTER_THIS (This
);
4187 Private
->AbsoluteInputEventSignalState
= FALSE
;
4189 if (Private
->CurrentNumberOfAbsolutePointers
== 0) {
4193 // return the worst status met
4195 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfAbsolutePointers
; Index
++) {
4196 Status
= Private
->AbsolutePointerList
[Index
]->Reset (
4197 Private
->AbsolutePointerList
[Index
],
4198 ExtendedVerification
4200 if (EFI_ERROR (Status
)) {
4201 ReturnStatus
= Status
;
4205 return ReturnStatus
;
4210 Retrieves the current state of a pointer device.
4212 @param This Protocol instance pointer.
4213 @param State A pointer to the state information on the
4216 @retval EFI_SUCCESS The state of the pointer device was returned in
4218 @retval EFI_NOT_READY The state of the pointer device has not changed
4219 since the last call to GetState().
4220 @retval EFI_DEVICE_ERROR A device error occurred while attempting to
4221 retrieve the pointer device's current state.
4226 ConSplitterAbsolutePointerGetState (
4227 IN EFI_ABSOLUTE_POINTER_PROTOCOL
*This
,
4228 IN OUT EFI_ABSOLUTE_POINTER_STATE
*State
4231 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
4233 EFI_STATUS ReturnStatus
;
4235 EFI_ABSOLUTE_POINTER_STATE CurrentState
;
4238 Private
= TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_ABSOLUTE_POINTER_THIS (This
);
4239 if (Private
->PasswordEnabled
) {
4241 // If StdIn Locked return not ready
4243 return EFI_NOT_READY
;
4246 Private
->AbsoluteInputEventSignalState
= FALSE
;
4248 State
->CurrentX
= 0;
4249 State
->CurrentY
= 0;
4250 State
->CurrentZ
= 0;
4251 State
->ActiveButtons
= 0;
4254 // if no physical pointer device exists, return EFI_NOT_READY;
4255 // if any physical pointer device has changed state,
4256 // return the state and EFI_SUCCESS.
4258 ReturnStatus
= EFI_NOT_READY
;
4259 for (Index
= 0; Index
< Private
->CurrentNumberOfAbsolutePointers
; Index
++) {
4261 Status
= Private
->AbsolutePointerList
[Index
]->GetState (
4262 Private
->AbsolutePointerList
[Index
],
4265 if (!EFI_ERROR (Status
)) {
4266 if (ReturnStatus
== EFI_NOT_READY
) {
4267 ReturnStatus
= EFI_SUCCESS
;
4270 State
->ActiveButtons
= CurrentState
.ActiveButtons
;
4272 if (!(Private
->AbsolutePointerMode
.AbsoluteMinX
== 0 && Private
->AbsolutePointerMode
.AbsoluteMaxX
== 0)) {
4273 State
->CurrentX
= CurrentState
.CurrentX
;
4275 if (!(Private
->AbsolutePointerMode
.AbsoluteMinY
== 0 && Private
->AbsolutePointerMode
.AbsoluteMaxY
== 0)) {
4276 State
->CurrentY
= CurrentState
.CurrentY
;
4278 if (!(Private
->AbsolutePointerMode
.AbsoluteMinZ
== 0 && Private
->AbsolutePointerMode
.AbsoluteMaxZ
== 0)) {
4279 State
->CurrentZ
= CurrentState
.CurrentZ
;
4282 } else if (Status
== EFI_DEVICE_ERROR
) {
4283 ReturnStatus
= EFI_DEVICE_ERROR
;
4287 return ReturnStatus
;
4292 This event agregates all the events of the pointer devices in the splitter.
4293 If the ConIn is password locked then return.
4294 If any events of physical pointer devices are signaled, signal the pointer
4295 splitter event. This will cause the calling code to call
4296 ConSplitterAbsolutePointerGetState ().
4298 @param Event The Event assoicated with callback.
4299 @param Context Context registered when Event was created.
4304 ConSplitterAbsolutePointerWaitForInput (
4310 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
4313 Private
= (TEXT_IN_SPLITTER_PRIVATE_DATA
*) Context
;
4314 if (Private
->PasswordEnabled
) {
4316 // If StdIn Locked return not ready
4322 // if AbsoluteInputEventSignalState is flagged before,
4323 // and not cleared by Reset() or GetState(), signal it
4325 if (Private
->AbsoluteInputEventSignalState
) {
4326 gBS
->SignalEvent (Event
);
4330 // if any physical console input device has key input, signal the event.
4332 for (Index
= 0; Index
< Private
->CurrentNumberOfAbsolutePointers
; Index
++) {
4333 Status
= gBS
->CheckEvent (Private
->AbsolutePointerList
[Index
]->WaitForInput
);
4334 if (!EFI_ERROR (Status
)) {
4335 gBS
->SignalEvent (Event
);
4336 Private
->AbsoluteInputEventSignalState
= TRUE
;
4343 Reset the text output device hardware and optionaly run diagnostics
4345 @param This Protocol instance pointer.
4346 @param ExtendedVerification Driver may perform more exhaustive verfication
4347 operation of the device during reset.
4349 @retval EFI_SUCCESS The text output device was reset.
4350 @retval EFI_DEVICE_ERROR The text output device is not functioning
4351 correctly and could not be reset.
4356 ConSplitterTextOutReset (
4357 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4358 IN BOOLEAN ExtendedVerification
4362 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4364 EFI_STATUS ReturnStatus
;
4366 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4369 // return the worst status met
4371 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
4373 if (Private
->TextOutList
[Index
].TextOutEnabled
) {
4375 Status
= Private
->TextOutList
[Index
].TextOut
->Reset (
4376 Private
->TextOutList
[Index
].TextOut
,
4377 ExtendedVerification
4379 if (EFI_ERROR (Status
)) {
4380 ReturnStatus
= Status
;
4385 This
->SetAttribute (This
, EFI_TEXT_ATTR (This
->Mode
->Attribute
& 0x0F, EFI_BLACK
));
4387 Status
= DevNullTextOutSetMode (Private
, 0);
4388 if (EFI_ERROR (Status
)) {
4389 ReturnStatus
= Status
;
4392 return ReturnStatus
;
4397 Write a Unicode string to the output device.
4399 @param This Protocol instance pointer.
4400 @param WString The NULL-terminated Unicode string to be
4401 displayed on the output device(s). All output
4402 devices must also support the Unicode drawing
4403 defined in this file.
4405 @retval EFI_SUCCESS The string was output to the device.
4406 @retval EFI_DEVICE_ERROR The device reported an error while attempting to
4408 @retval EFI_UNSUPPORTED The output device's mode is not currently in a
4410 @retval EFI_WARN_UNKNOWN_GLYPH This warning code indicates that some of the
4411 characters in the Unicode string could not be
4412 rendered and were skipped.
4417 ConSplitterTextOutOutputString (
4418 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4423 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4425 UINTN BackSpaceCount
;
4426 EFI_STATUS ReturnStatus
;
4427 CHAR16
*TargetString
;
4429 This
->SetAttribute (This
, This
->Mode
->Attribute
);
4431 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4434 for (TargetString
= WString
; *TargetString
!= L
'\0'; TargetString
++) {
4435 if (*TargetString
== CHAR_BACKSPACE
) {
4441 if (BackSpaceCount
== 0) {
4442 TargetString
= WString
;
4444 TargetString
= AllocatePool (sizeof (CHAR16
) * (StrLen (WString
) + BackSpaceCount
+ 1));
4445 ASSERT (TargetString
!= NULL
);
4447 StrCpy (TargetString
, WString
);
4450 // return the worst status met
4452 Status
= DevNullTextOutOutputString (Private
, TargetString
);
4453 if (EFI_ERROR (Status
)) {
4454 ReturnStatus
= Status
;
4457 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
4459 if (Private
->TextOutList
[Index
].TextOutEnabled
) {
4460 Status
= Private
->TextOutList
[Index
].TextOut
->OutputString (
4461 Private
->TextOutList
[Index
].TextOut
,
4464 if (EFI_ERROR (Status
)) {
4465 ReturnStatus
= Status
;
4470 if (BackSpaceCount
> 0) {
4471 FreePool (TargetString
);
4474 return ReturnStatus
;
4479 Verifies that all characters in a Unicode string can be output to the
4482 @param This Protocol instance pointer.
4483 @param WString The NULL-terminated Unicode string to be
4484 examined for the output device(s).
4486 @retval EFI_SUCCESS The device(s) are capable of rendering the
4488 @retval EFI_UNSUPPORTED Some of the characters in the Unicode string
4489 cannot be rendered by one or more of the output
4490 devices mapped by the EFI handle.
4495 ConSplitterTextOutTestString (
4496 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4501 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4503 EFI_STATUS ReturnStatus
;
4505 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4508 // return the worst status met
4510 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
4511 if (Private
->TextOutList
[Index
].TextOutEnabled
) {
4512 Status
= Private
->TextOutList
[Index
].TextOut
->TestString (
4513 Private
->TextOutList
[Index
].TextOut
,
4516 if (EFI_ERROR (Status
)) {
4517 ReturnStatus
= Status
;
4522 // There is no DevNullTextOutTestString () since a Unicode buffer would
4523 // always return EFI_SUCCESS.
4524 // ReturnStatus will be EFI_SUCCESS if no consoles are present
4526 return ReturnStatus
;
4531 Returns information for an available text mode that the output device(s)
4534 @param This Protocol instance pointer.
4535 @param ModeNumber The mode number to return information on.
4536 @param Columns Returns the columns of the text output device
4537 for the requested ModeNumber.
4538 @param Rows Returns the rows of the text output device
4539 for the requested ModeNumber.
4541 @retval EFI_SUCCESS The requested mode information was returned.
4542 @retval EFI_DEVICE_ERROR The device had an error and could not complete
4544 @retval EFI_UNSUPPORTED The mode number was not valid.
4549 ConSplitterTextOutQueryMode (
4550 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4551 IN UINTN ModeNumber
,
4556 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4558 INT32
*TextOutModeMap
;
4560 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4563 // Check whether param ModeNumber is valid.
4564 // ModeNumber should be within range 0 ~ MaxMode - 1.
4566 if ( (ModeNumber
> (UINTN
)(((UINT32
)-1)>>1)) ) {
4567 return EFI_UNSUPPORTED
;
4570 if ((INT32
) ModeNumber
>= This
->Mode
->MaxMode
) {
4571 return EFI_UNSUPPORTED
;
4575 // We get the available mode from mode intersection map if it's available
4577 if (Private
->TextOutModeMap
!= NULL
) {
4578 TextOutModeMap
= Private
->TextOutModeMap
+ Private
->TextOutListCount
* ModeNumber
;
4579 CurrentMode
= (UINTN
)(*TextOutModeMap
);
4580 *Columns
= Private
->TextOutQueryData
[CurrentMode
].Columns
;
4581 *Rows
= Private
->TextOutQueryData
[CurrentMode
].Rows
;
4583 *Columns
= Private
->TextOutQueryData
[ModeNumber
].Columns
;
4584 *Rows
= Private
->TextOutQueryData
[ModeNumber
].Rows
;
4587 if (*Columns
<= 0 && *Rows
<= 0) {
4588 return EFI_UNSUPPORTED
;
4597 Sets the output device(s) to a specified mode.
4599 @param This Protocol instance pointer.
4600 @param ModeNumber The mode number to set.
4602 @retval EFI_SUCCESS The requested text mode was set.
4603 @retval EFI_DEVICE_ERROR The device had an error and could not complete
4605 @retval EFI_UNSUPPORTED The mode number was not valid.
4610 ConSplitterTextOutSetMode (
4611 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4616 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4618 INT32
*TextOutModeMap
;
4619 EFI_STATUS ReturnStatus
;
4621 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4624 // Check whether param ModeNumber is valid.
4625 // ModeNumber should be within range 0 ~ MaxMode - 1.
4627 if ( (ModeNumber
> (UINTN
)(((UINT32
)-1)>>1)) ) {
4628 return EFI_UNSUPPORTED
;
4631 if ((INT32
) ModeNumber
>= This
->Mode
->MaxMode
) {
4632 return EFI_UNSUPPORTED
;
4635 // If the mode is being set to the curent mode, then just clear the screen and return.
4637 if (Private
->TextOutMode
.Mode
== (INT32
) ModeNumber
) {
4638 return ConSplitterTextOutClearScreen (This
);
4641 // return the worst status met
4643 TextOutModeMap
= Private
->TextOutModeMap
+ Private
->TextOutListCount
* ModeNumber
;
4644 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
4646 if (Private
->TextOutList
[Index
].TextOutEnabled
) {
4647 Status
= Private
->TextOutList
[Index
].TextOut
->SetMode (
4648 Private
->TextOutList
[Index
].TextOut
,
4649 TextOutModeMap
[Index
]
4652 // If this console device is based on a GOP or UGA device, then sync up the bitmap from
4653 // the GOP/UGA splitter and reclear the text portion of the display in the new mode.
4655 if ((Private
->TextOutList
[Index
].GraphicsOutput
!= NULL
) || (Private
->TextOutList
[Index
].UgaDraw
!= NULL
)) {
4656 Private
->TextOutList
[Index
].TextOut
->ClearScreen (Private
->TextOutList
[Index
].TextOut
);
4659 if (EFI_ERROR (Status
)) {
4660 ReturnStatus
= Status
;
4665 // The DevNull Console will support any possible mode as it allocates memory
4667 Status
= DevNullTextOutSetMode (Private
, ModeNumber
);
4668 if (EFI_ERROR (Status
)) {
4669 ReturnStatus
= Status
;
4672 return ReturnStatus
;
4677 Sets the background and foreground colors for the OutputString () and
4678 ClearScreen () functions.
4680 @param This Protocol instance pointer.
4681 @param Attribute The attribute to set. Bits 0..3 are the
4682 foreground color, and bits 4..6 are the
4683 background color. All other bits are undefined
4684 and must be zero. The valid Attributes are
4685 defined in this file.
4687 @retval EFI_SUCCESS The attribute was set.
4688 @retval EFI_DEVICE_ERROR The device had an error and could not complete
4690 @retval EFI_UNSUPPORTED The attribute requested is not defined.
4695 ConSplitterTextOutSetAttribute (
4696 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4701 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4703 EFI_STATUS ReturnStatus
;
4705 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4708 // Check whether param Attribute is valid.
4710 if ( (Attribute
> (UINTN
)(((UINT32
)-1)>>1)) ) {
4711 return EFI_UNSUPPORTED
;
4715 // return the worst status met
4717 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
4719 if (Private
->TextOutList
[Index
].TextOutEnabled
) {
4720 Status
= Private
->TextOutList
[Index
].TextOut
->SetAttribute (
4721 Private
->TextOutList
[Index
].TextOut
,
4724 if (EFI_ERROR (Status
)) {
4725 ReturnStatus
= Status
;
4730 Private
->TextOutMode
.Attribute
= (INT32
) Attribute
;
4732 return ReturnStatus
;
4737 Clears the output device(s) display to the currently selected background
4740 @param This Protocol instance pointer.
4742 @retval EFI_SUCCESS The operation completed successfully.
4743 @retval EFI_DEVICE_ERROR The device had an error and could not complete
4745 @retval EFI_UNSUPPORTED The output device is not in a valid text mode.
4750 ConSplitterTextOutClearScreen (
4751 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
4755 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4757 EFI_STATUS ReturnStatus
;
4759 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4762 // return the worst status met
4764 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
4766 if (Private
->TextOutList
[Index
].TextOutEnabled
) {
4767 Status
= Private
->TextOutList
[Index
].TextOut
->ClearScreen (Private
->TextOutList
[Index
].TextOut
);
4768 if (EFI_ERROR (Status
)) {
4769 ReturnStatus
= Status
;
4774 Status
= DevNullTextOutClearScreen (Private
);
4775 if (EFI_ERROR (Status
)) {
4776 ReturnStatus
= Status
;
4779 return ReturnStatus
;
4784 Sets the current coordinates of the cursor position
4786 @param This Protocol instance pointer.
4787 @param Column The column position to set the cursor to. Must be
4788 greater than or equal to zero and less than the
4789 number of columns by QueryMode ().
4790 @param Row The row position to set the cursor to. Must be
4791 greater than or equal to zero and less than the
4792 number of rows by QueryMode ().
4794 @retval EFI_SUCCESS The operation completed successfully.
4795 @retval EFI_DEVICE_ERROR The device had an error and could not complete
4797 @retval EFI_UNSUPPORTED The output device is not in a valid text mode,
4798 or the cursor position is invalid for the
4804 ConSplitterTextOutSetCursorPosition (
4805 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4811 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4813 EFI_STATUS ReturnStatus
;
4816 INT32
*TextOutModeMap
;
4820 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4821 TextOutModeMap
= NULL
;
4822 ModeNumber
= Private
->TextOutMode
.Mode
;
4825 // Get current MaxColumn and MaxRow from intersection map
4827 if (Private
->TextOutModeMap
!= NULL
) {
4828 TextOutModeMap
= Private
->TextOutModeMap
+ Private
->TextOutListCount
* ModeNumber
;
4829 CurrentMode
= *TextOutModeMap
;
4831 CurrentMode
= ModeNumber
;
4834 MaxColumn
= Private
->TextOutQueryData
[CurrentMode
].Columns
;
4835 MaxRow
= Private
->TextOutQueryData
[CurrentMode
].Rows
;
4837 if (Column
>= MaxColumn
|| Row
>= MaxRow
) {
4838 return EFI_UNSUPPORTED
;
4841 // return the worst status met
4843 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
4845 if (Private
->TextOutList
[Index
].TextOutEnabled
) {
4846 Status
= Private
->TextOutList
[Index
].TextOut
->SetCursorPosition (
4847 Private
->TextOutList
[Index
].TextOut
,
4851 if (EFI_ERROR (Status
)) {
4852 ReturnStatus
= Status
;
4857 DevNullTextOutSetCursorPosition (Private
, Column
, Row
);
4859 return ReturnStatus
;
4864 Makes the cursor visible or invisible
4866 @param This Protocol instance pointer.
4867 @param Visible If TRUE, the cursor is set to be visible. If
4868 FALSE, the cursor is set to be invisible.
4870 @retval EFI_SUCCESS The operation completed successfully.
4871 @retval EFI_DEVICE_ERROR The device had an error and could not complete
4872 the request, or the device does not support
4873 changing the cursor mode.
4874 @retval EFI_UNSUPPORTED The output device is not in a valid text mode.
4879 ConSplitterTextOutEnableCursor (
4880 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4885 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4887 EFI_STATUS ReturnStatus
;
4889 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
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
->EnableCursor (
4898 Private
->TextOutList
[Index
].TextOut
,
4901 if (EFI_ERROR (Status
)) {
4902 ReturnStatus
= Status
;
4907 DevNullTextOutEnableCursor (Private
, Visible
);
4909 return ReturnStatus
;