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 - 2018, Intel Corporation. All rights reserved.<BR>
20 (C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>
21 SPDX-License-Identifier: BSD-2-Clause-Patent
25 #include "ConSplitter.h"
28 // Identify if ConIn is connected in PcdConInConnectOnDemand enabled mode.
29 // default not connect
31 BOOLEAN mConInIsConnect
= FALSE
;
34 // Text In Splitter Private Data template
36 GLOBAL_REMOVE_IF_UNREFERENCED TEXT_IN_SPLITTER_PRIVATE_DATA mConIn
= {
37 TEXT_IN_SPLITTER_PRIVATE_DATA_SIGNATURE
,
41 ConSplitterTextInReset
,
42 ConSplitterTextInReadKeyStroke
,
46 (EFI_SIMPLE_TEXT_INPUT_PROTOCOL
**) NULL
,
50 ConSplitterTextInResetEx
,
51 ConSplitterTextInReadKeyStrokeEx
,
53 ConSplitterTextInSetState
,
54 ConSplitterTextInRegisterKeyNotify
,
55 ConSplitterTextInUnregisterKeyNotify
58 (EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
**) NULL
,
64 (EFI_KEY_DATA
*) NULL
,
70 ConSplitterSimplePointerReset
,
71 ConSplitterSimplePointerGetState
,
73 (EFI_SIMPLE_POINTER_MODE
*) NULL
83 (EFI_SIMPLE_POINTER_PROTOCOL
**) NULL
,
87 ConSplitterAbsolutePointerReset
,
88 ConSplitterAbsolutePointerGetState
,
90 (EFI_ABSOLUTE_POINTER_MODE
*) NULL
96 0x10000, // AbsoluteMaxX
97 0x10000, // AbsoluteMaxY
98 0x10000, // AbsoluteMaxZ
102 (EFI_ABSOLUTE_POINTER_PROTOCOL
**) NULL
,
112 // Uga Draw Protocol Private Data template
114 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UGA_DRAW_PROTOCOL mUgaDrawProtocolTemplate
= {
115 ConSplitterUgaDrawGetMode
,
116 ConSplitterUgaDrawSetMode
,
117 ConSplitterUgaDrawBlt
121 // Graphics Output Protocol Private Data template
123 GLOBAL_REMOVE_IF_UNREFERENCED EFI_GRAPHICS_OUTPUT_PROTOCOL mGraphicsOutputProtocolTemplate
= {
124 ConSplitterGraphicsOutputQueryMode
,
125 ConSplitterGraphicsOutputSetMode
,
126 ConSplitterGraphicsOutputBlt
,
132 // Text Out Splitter Private Data template
134 GLOBAL_REMOVE_IF_UNREFERENCED TEXT_OUT_SPLITTER_PRIVATE_DATA mConOut
= {
135 TEXT_OUT_SPLITTER_PRIVATE_DATA_SIGNATURE
,
138 ConSplitterTextOutReset
,
139 ConSplitterTextOutOutputString
,
140 ConSplitterTextOutTestString
,
141 ConSplitterTextOutQueryMode
,
142 ConSplitterTextOutSetMode
,
143 ConSplitterTextOutSetAttribute
,
144 ConSplitterTextOutClearScreen
,
145 ConSplitterTextOutSetCursorPosition
,
146 ConSplitterTextOutEnableCursor
,
147 (EFI_SIMPLE_TEXT_OUTPUT_MODE
*) NULL
174 (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*) NULL
,
179 (TEXT_OUT_AND_GOP_DATA
*) NULL
,
181 (TEXT_OUT_SPLITTER_QUERY_DATA
*) NULL
,
187 // Standard Error Text Out Splitter Data Template
189 GLOBAL_REMOVE_IF_UNREFERENCED TEXT_OUT_SPLITTER_PRIVATE_DATA mStdErr
= {
190 TEXT_OUT_SPLITTER_PRIVATE_DATA_SIGNATURE
,
193 ConSplitterTextOutReset
,
194 ConSplitterTextOutOutputString
,
195 ConSplitterTextOutTestString
,
196 ConSplitterTextOutQueryMode
,
197 ConSplitterTextOutSetMode
,
198 ConSplitterTextOutSetAttribute
,
199 ConSplitterTextOutClearScreen
,
200 ConSplitterTextOutSetCursorPosition
,
201 ConSplitterTextOutEnableCursor
,
202 (EFI_SIMPLE_TEXT_OUTPUT_MODE
*) NULL
229 (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*) NULL
,
234 (TEXT_OUT_AND_GOP_DATA
*) NULL
,
236 (TEXT_OUT_SPLITTER_QUERY_DATA
*) NULL
,
242 // Driver binding instance for Console Input Device
244 EFI_DRIVER_BINDING_PROTOCOL gConSplitterConInDriverBinding
= {
245 ConSplitterConInDriverBindingSupported
,
246 ConSplitterConInDriverBindingStart
,
247 ConSplitterConInDriverBindingStop
,
254 // Driver binding instance for Console Out device
256 EFI_DRIVER_BINDING_PROTOCOL gConSplitterConOutDriverBinding
= {
257 ConSplitterConOutDriverBindingSupported
,
258 ConSplitterConOutDriverBindingStart
,
259 ConSplitterConOutDriverBindingStop
,
266 // Driver binding instance for Standard Error device
268 EFI_DRIVER_BINDING_PROTOCOL gConSplitterStdErrDriverBinding
= {
269 ConSplitterStdErrDriverBindingSupported
,
270 ConSplitterStdErrDriverBindingStart
,
271 ConSplitterStdErrDriverBindingStop
,
278 // Driver binding instance for Simple Pointer protocol
280 EFI_DRIVER_BINDING_PROTOCOL gConSplitterSimplePointerDriverBinding
= {
281 ConSplitterSimplePointerDriverBindingSupported
,
282 ConSplitterSimplePointerDriverBindingStart
,
283 ConSplitterSimplePointerDriverBindingStop
,
290 // Driver binding instance for Absolute Pointer protocol
292 EFI_DRIVER_BINDING_PROTOCOL gConSplitterAbsolutePointerDriverBinding
= {
293 ConSplitterAbsolutePointerDriverBindingSupported
,
294 ConSplitterAbsolutePointerDriverBindingStart
,
295 ConSplitterAbsolutePointerDriverBindingStop
,
302 Key notify for toggle state sync.
304 @param KeyData A pointer to a buffer that is filled in with
305 the keystroke information for the key that was
308 @retval EFI_SUCCESS Toggle state sync successfully.
313 ToggleStateSyncKeyNotify (
314 IN EFI_KEY_DATA
*KeyData
319 if (((KeyData
->KeyState
.KeyToggleState
& KEY_STATE_VALID_EXPOSED
) == KEY_STATE_VALID_EXPOSED
) &&
320 (KeyData
->KeyState
.KeyToggleState
!= mConIn
.PhysicalKeyToggleState
)) {
322 // There is toggle state change, sync to other console input devices.
324 for (Index
= 0; Index
< mConIn
.CurrentNumberOfExConsoles
; Index
++) {
325 mConIn
.TextInExList
[Index
]->SetState (
326 mConIn
.TextInExList
[Index
],
327 &KeyData
->KeyState
.KeyToggleState
330 mConIn
.PhysicalKeyToggleState
= KeyData
->KeyState
.KeyToggleState
;
331 DEBUG ((EFI_D_INFO
, "Current toggle state is 0x%02x\n", mConIn
.PhysicalKeyToggleState
));
338 Initialization for toggle state sync.
340 @param Private Text In Splitter pointer.
344 ToggleStateSyncInitialization (
345 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
348 EFI_KEY_DATA KeyData
;
352 // Initialize PhysicalKeyToggleState that will be synced to new console
353 // input device to turn on physical TextInEx partial key report for
354 // toggle state sync.
356 Private
->PhysicalKeyToggleState
= KEY_STATE_VALID_EXPOSED
;
359 // Initialize VirtualKeyStateExported to let the virtual TextInEx not report
360 // the partial key even though the physical TextInEx turns on the partial
361 // key report. The virtual TextInEx will report the partial key after it is
362 // required by calling SetState(X | KEY_STATE_VALID_EXPOSED) explicitly.
364 Private
->VirtualKeyStateExported
= FALSE
;
367 // Register key notify for toggle state sync.
369 KeyData
.Key
.ScanCode
= SCAN_NULL
;
370 KeyData
.Key
.UnicodeChar
= CHAR_NULL
;
371 KeyData
.KeyState
.KeyShiftState
= 0;
372 KeyData
.KeyState
.KeyToggleState
= 0;
373 Private
->TextInEx
.RegisterKeyNotify (
376 ToggleStateSyncKeyNotify
,
382 Reinitialization for toggle state sync.
384 @param Private Text In Splitter pointer.
388 ToggleStateSyncReInitialization (
389 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
395 // Reinitialize PhysicalKeyToggleState that will be synced to new console
396 // input device to turn on physical TextInEx partial key report for
397 // toggle state sync.
399 Private
->PhysicalKeyToggleState
= KEY_STATE_VALID_EXPOSED
;
402 // Reinitialize VirtualKeyStateExported to let the virtual TextInEx not report
403 // the partial key even though the physical TextInEx turns on the partial
404 // key report. The virtual TextInEx will report the partial key after it is
405 // required by calling SetState(X | KEY_STATE_VALID_EXPOSED) explicitly.
407 Private
->VirtualKeyStateExported
= FALSE
;
409 for (Index
= 0; Index
< Private
->CurrentNumberOfExConsoles
; Index
++) {
410 Private
->TextInExList
[Index
]->SetState (
411 Private
->TextInExList
[Index
],
412 &Private
->PhysicalKeyToggleState
418 The Entry Point for module ConSplitter. The user code starts with this function.
420 Installs driver module protocols and. Creates virtual device handles for ConIn,
421 ConOut, and StdErr. Installs Simple Text In protocol, Simple Text In Ex protocol,
422 Simple Pointer protocol, Absolute Pointer protocol on those virtual handlers.
423 Installs Graphics Output protocol and/or UGA Draw protocol if needed.
425 @param[in] ImageHandle The firmware allocated handle for the EFI image.
426 @param[in] SystemTable A pointer to the EFI System Table.
428 @retval EFI_SUCCESS The entry point is executed successfully.
429 @retval other Some error occurs when executing this entry point.
434 ConSplitterDriverEntry(
435 IN EFI_HANDLE ImageHandle
,
436 IN EFI_SYSTEM_TABLE
*SystemTable
442 // Install driver model protocol(s).
444 Status
= EfiLibInstallDriverBindingComponentName2 (
447 &gConSplitterConInDriverBinding
,
449 &gConSplitterConInComponentName
,
450 &gConSplitterConInComponentName2
452 ASSERT_EFI_ERROR (Status
);
454 Status
= EfiLibInstallDriverBindingComponentName2 (
457 &gConSplitterSimplePointerDriverBinding
,
459 &gConSplitterSimplePointerComponentName
,
460 &gConSplitterSimplePointerComponentName2
462 ASSERT_EFI_ERROR (Status
);
464 Status
= EfiLibInstallDriverBindingComponentName2 (
467 &gConSplitterAbsolutePointerDriverBinding
,
469 &gConSplitterAbsolutePointerComponentName
,
470 &gConSplitterAbsolutePointerComponentName2
472 ASSERT_EFI_ERROR (Status
);
474 Status
= EfiLibInstallDriverBindingComponentName2 (
477 &gConSplitterConOutDriverBinding
,
479 &gConSplitterConOutComponentName
,
480 &gConSplitterConOutComponentName2
482 ASSERT_EFI_ERROR (Status
);
484 Status
= EfiLibInstallDriverBindingComponentName2 (
487 &gConSplitterStdErrDriverBinding
,
489 &gConSplitterStdErrComponentName
,
490 &gConSplitterStdErrComponentName2
492 ASSERT_EFI_ERROR (Status
);
495 // Either Graphics Output protocol or UGA Draw protocol must be supported.
497 ASSERT (FeaturePcdGet (PcdConOutGopSupport
) ||
498 FeaturePcdGet (PcdConOutUgaSupport
));
501 // The driver creates virtual handles for ConIn, ConOut, StdErr.
502 // The virtual handles will always exist even if no console exist in the
503 // system. This is need to support hotplug devices like USB.
506 // Create virtual device handle for ConIn Splitter
508 Status
= ConSplitterTextInConstructor (&mConIn
);
509 if (!EFI_ERROR (Status
)) {
510 Status
= gBS
->InstallMultipleProtocolInterfaces (
511 &mConIn
.VirtualHandle
,
512 &gEfiSimpleTextInProtocolGuid
,
514 &gEfiSimpleTextInputExProtocolGuid
,
516 &gEfiSimplePointerProtocolGuid
,
517 &mConIn
.SimplePointer
,
518 &gEfiAbsolutePointerProtocolGuid
,
519 &mConIn
.AbsolutePointer
,
522 if (!EFI_ERROR (Status
)) {
524 // Update the EFI System Table with new virtual console
525 // and update the pointer to Simple Text Input protocol.
527 gST
->ConsoleInHandle
= mConIn
.VirtualHandle
;
528 gST
->ConIn
= &mConIn
.TextIn
;
532 // Create virtual device handle for ConOut Splitter
534 Status
= ConSplitterTextOutConstructor (&mConOut
);
535 if (!EFI_ERROR (Status
)) {
536 Status
= gBS
->InstallMultipleProtocolInterfaces (
537 &mConOut
.VirtualHandle
,
538 &gEfiSimpleTextOutProtocolGuid
,
542 if (!EFI_ERROR (Status
)) {
544 // Update the EFI System Table with new virtual console
545 // and Update the pointer to Text Output protocol.
547 gST
->ConsoleOutHandle
= mConOut
.VirtualHandle
;
548 gST
->ConOut
= &mConOut
.TextOut
;
554 // Create virtual device handle for StdErr Splitter
556 Status
= ConSplitterTextOutConstructor (&mStdErr
);
557 if (!EFI_ERROR (Status
)) {
558 Status
= gBS
->InstallMultipleProtocolInterfaces (
559 &mStdErr
.VirtualHandle
,
560 &gEfiSimpleTextOutProtocolGuid
,
564 if (!EFI_ERROR (Status
)) {
566 // Update the EFI System Table with new virtual console
567 // and update the pointer to Text Output protocol.
569 gST
->StandardErrorHandle
= mStdErr
.VirtualHandle
;
570 gST
->StdErr
= &mStdErr
.TextOut
;
575 // Update the CRC32 in the EFI System Table header
578 gBS
->CalculateCrc32 (
589 Construct console input devices' private data.
591 @param ConInPrivate A pointer to the TEXT_IN_SPLITTER_PRIVATE_DATA
594 @retval EFI_OUT_OF_RESOURCES Out of resources.
595 @retval EFI_SUCCESS Text Input Devcie's private data has been constructed.
596 @retval other Failed to construct private data.
600 ConSplitterTextInConstructor (
601 TEXT_IN_SPLITTER_PRIVATE_DATA
*ConInPrivate
605 UINTN TextInExListCount
;
608 // Allocate buffer for Simple Text Input device
610 Status
= ConSplitterGrowBuffer (
611 sizeof (EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*),
612 &ConInPrivate
->TextInListCount
,
613 (VOID
**) &ConInPrivate
->TextInList
615 if (EFI_ERROR (Status
)) {
616 return EFI_OUT_OF_RESOURCES
;
620 // Create Event to wait for a key
622 Status
= gBS
->CreateEvent (
625 ConSplitterTextInWaitForKey
,
627 &ConInPrivate
->TextIn
.WaitForKey
629 ASSERT_EFI_ERROR (Status
);
632 // Allocate buffer for KeyQueue
634 TextInExListCount
= ConInPrivate
->TextInExListCount
;
635 Status
= ConSplitterGrowBuffer (
636 sizeof (EFI_KEY_DATA
),
638 (VOID
**) &ConInPrivate
->KeyQueue
640 if (EFI_ERROR (Status
)) {
641 return EFI_OUT_OF_RESOURCES
;
645 // Allocate buffer for Simple Text Input Ex device
647 Status
= ConSplitterGrowBuffer (
648 sizeof (EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*),
649 &ConInPrivate
->TextInExListCount
,
650 (VOID
**) &ConInPrivate
->TextInExList
652 if (EFI_ERROR (Status
)) {
653 return EFI_OUT_OF_RESOURCES
;
656 // Create Event to wait for a key Ex
658 Status
= gBS
->CreateEvent (
661 ConSplitterTextInWaitForKey
,
663 &ConInPrivate
->TextInEx
.WaitForKeyEx
665 ASSERT_EFI_ERROR (Status
);
667 InitializeListHead (&ConInPrivate
->NotifyList
);
669 ToggleStateSyncInitialization (ConInPrivate
);
671 ConInPrivate
->AbsolutePointer
.Mode
= &ConInPrivate
->AbsolutePointerMode
;
673 // Allocate buffer for Absolute Pointer device
675 Status
= ConSplitterGrowBuffer (
676 sizeof (EFI_ABSOLUTE_POINTER_PROTOCOL
*),
677 &ConInPrivate
->AbsolutePointerListCount
,
678 (VOID
**) &ConInPrivate
->AbsolutePointerList
680 if (EFI_ERROR (Status
)) {
681 return EFI_OUT_OF_RESOURCES
;
684 // Create Event to wait for device input for Absolute pointer device
686 Status
= gBS
->CreateEvent (
689 ConSplitterAbsolutePointerWaitForInput
,
691 &ConInPrivate
->AbsolutePointer
.WaitForInput
693 ASSERT_EFI_ERROR (Status
);
695 ConInPrivate
->SimplePointer
.Mode
= &ConInPrivate
->SimplePointerMode
;
697 // Allocate buffer for Simple Pointer device
699 Status
= ConSplitterGrowBuffer (
700 sizeof (EFI_SIMPLE_POINTER_PROTOCOL
*),
701 &ConInPrivate
->PointerListCount
,
702 (VOID
**) &ConInPrivate
->PointerList
704 if (EFI_ERROR (Status
)) {
705 return EFI_OUT_OF_RESOURCES
;
708 // Create Event to wait for device input for Simple pointer device
710 Status
= gBS
->CreateEvent (
713 ConSplitterSimplePointerWaitForInput
,
715 &ConInPrivate
->SimplePointer
.WaitForInput
717 ASSERT_EFI_ERROR (Status
);
719 // Create Event to signal ConIn connection request
721 Status
= gBS
->CreateEventEx (
724 EfiEventEmptyFunction
,
726 &gConnectConInEventGuid
,
727 &ConInPrivate
->ConnectConInEvent
734 Construct console output devices' private data.
736 @param ConOutPrivate A pointer to the TEXT_OUT_SPLITTER_PRIVATE_DATA
739 @retval EFI_OUT_OF_RESOURCES Out of resources.
740 @retval EFI_SUCCESS Text Input Devcie's private data has been constructed.
744 ConSplitterTextOutConstructor (
745 TEXT_OUT_SPLITTER_PRIVATE_DATA
*ConOutPrivate
749 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*Info
;
752 // Copy protocols template
754 if (FeaturePcdGet (PcdConOutUgaSupport
)) {
755 CopyMem (&ConOutPrivate
->UgaDraw
, &mUgaDrawProtocolTemplate
, sizeof (EFI_UGA_DRAW_PROTOCOL
));
757 if (FeaturePcdGet (PcdConOutGopSupport
)) {
758 CopyMem (&ConOutPrivate
->GraphicsOutput
, &mGraphicsOutputProtocolTemplate
, sizeof (EFI_GRAPHICS_OUTPUT_PROTOCOL
));
762 // Initilize console output splitter's private data.
764 ConOutPrivate
->TextOut
.Mode
= &ConOutPrivate
->TextOutMode
;
767 // When new console device is added, the new mode will be set later,
768 // so put current mode back to init state.
770 ConOutPrivate
->TextOutMode
.Mode
= 0xFF;
772 // Allocate buffer for Console Out device
774 Status
= ConSplitterGrowBuffer (
775 sizeof (TEXT_OUT_AND_GOP_DATA
),
776 &ConOutPrivate
->TextOutListCount
,
777 (VOID
**) &ConOutPrivate
->TextOutList
779 if (EFI_ERROR (Status
)) {
780 return EFI_OUT_OF_RESOURCES
;
783 // Allocate buffer for Text Out query data
785 Status
= ConSplitterGrowBuffer (
786 sizeof (TEXT_OUT_SPLITTER_QUERY_DATA
),
787 &ConOutPrivate
->TextOutQueryDataCount
,
788 (VOID
**) &ConOutPrivate
->TextOutQueryData
790 if (EFI_ERROR (Status
)) {
791 return EFI_OUT_OF_RESOURCES
;
795 // Setup the default console to 80 x 25 and mode to 0
797 ConOutPrivate
->TextOutQueryData
[0].Columns
= 80;
798 ConOutPrivate
->TextOutQueryData
[0].Rows
= 25;
799 TextOutSetMode (ConOutPrivate
, 0);
802 if (FeaturePcdGet (PcdConOutUgaSupport
)) {
804 // Setup the UgaDraw to 800 x 600 x 32 bits per pixel, 60Hz.
806 ConSplitterUgaDrawSetMode (&ConOutPrivate
->UgaDraw
, 800, 600, 32, 60);
808 if (FeaturePcdGet (PcdConOutGopSupport
)) {
810 // Setup resource for mode information in Graphics Output Protocol interface
812 if ((ConOutPrivate
->GraphicsOutput
.Mode
= AllocateZeroPool (sizeof (EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE
))) == NULL
) {
813 return EFI_OUT_OF_RESOURCES
;
815 if ((ConOutPrivate
->GraphicsOutput
.Mode
->Info
= AllocateZeroPool (sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
))) == NULL
) {
816 return EFI_OUT_OF_RESOURCES
;
819 // Setup the DevNullGraphicsOutput to 800 x 600 x 32 bits per pixel
820 // DevNull will be updated to user-defined mode after driver has started.
822 if ((ConOutPrivate
->GraphicsOutputModeBuffer
= AllocateZeroPool (sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
))) == NULL
) {
823 return EFI_OUT_OF_RESOURCES
;
825 Info
= &ConOutPrivate
->GraphicsOutputModeBuffer
[0];
827 Info
->HorizontalResolution
= 800;
828 Info
->VerticalResolution
= 600;
829 Info
->PixelFormat
= PixelBltOnly
;
830 Info
->PixelsPerScanLine
= 800;
831 CopyMem (ConOutPrivate
->GraphicsOutput
.Mode
->Info
, Info
, sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
));
832 ConOutPrivate
->GraphicsOutput
.Mode
->SizeOfInfo
= sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
);
835 // Initialize the following items, theset items remain unchanged in GraphicsOutput->SetMode()
836 // GraphicsOutputMode->FrameBufferBase, GraphicsOutputMode->FrameBufferSize
838 ConOutPrivate
->GraphicsOutput
.Mode
->FrameBufferBase
= (EFI_PHYSICAL_ADDRESS
) (UINTN
) NULL
;
839 ConOutPrivate
->GraphicsOutput
.Mode
->FrameBufferSize
= 0;
841 ConOutPrivate
->GraphicsOutput
.Mode
->MaxMode
= 1;
843 // Initial current mode to unknown state, and then set to mode 0
845 ConOutPrivate
->GraphicsOutput
.Mode
->Mode
= 0xffff;
846 ConOutPrivate
->GraphicsOutput
.SetMode (&ConOutPrivate
->GraphicsOutput
, 0);
854 Test to see if the specified protocol could be supported on the specified device.
856 @param This Driver Binding protocol pointer.
857 @param ControllerHandle Handle of device to test.
858 @param Guid The specified protocol.
860 @retval EFI_SUCCESS The specified protocol is supported on this device.
861 @retval EFI_UNSUPPORTED The specified protocol attempts to be installed on virtul handle.
862 @retval other Failed to open specified protocol on this device.
866 ConSplitterSupported (
867 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
868 IN EFI_HANDLE ControllerHandle
,
876 // Make sure the Console Splitter does not attempt to attach to itself
878 if (ControllerHandle
== mConIn
.VirtualHandle
||
879 ControllerHandle
== mConOut
.VirtualHandle
||
880 ControllerHandle
== mStdErr
.VirtualHandle
882 return EFI_UNSUPPORTED
;
886 // Check to see whether the specific protocol could be opened BY_DRIVER
888 Status
= gBS
->OpenProtocol (
892 This
->DriverBindingHandle
,
894 EFI_OPEN_PROTOCOL_BY_DRIVER
897 if (EFI_ERROR (Status
)) {
904 This
->DriverBindingHandle
,
912 Test to see if Console In Device could be supported on the Controller.
914 @param This Driver Binding protocol instance pointer.
915 @param ControllerHandle Handle of device to test.
916 @param RemainingDevicePath Optional parameter use to pick a specific child
919 @retval EFI_SUCCESS This driver supports this device.
920 @retval other This driver does not support this device.
925 ConSplitterConInDriverBindingSupported (
926 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
927 IN EFI_HANDLE ControllerHandle
,
928 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
931 return ConSplitterSupported (
934 &gEfiConsoleInDeviceGuid
939 Test to see if Simple Pointer protocol could be supported on the Controller.
941 @param This Driver Binding protocol instance pointer.
942 @param ControllerHandle Handle of device to test.
943 @param RemainingDevicePath Optional parameter use to pick a specific child
946 @retval EFI_SUCCESS This driver supports this device.
947 @retval other This driver does not support this device.
952 ConSplitterSimplePointerDriverBindingSupported (
953 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
954 IN EFI_HANDLE ControllerHandle
,
955 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
958 return ConSplitterSupported (
961 &gEfiSimplePointerProtocolGuid
966 Test to see if Absolute Pointer protocol could be supported on the Controller.
968 @param This Driver Binding protocol instance pointer.
969 @param ControllerHandle Handle of device to test.
970 @param RemainingDevicePath Optional parameter use to pick a specific child
973 @retval EFI_SUCCESS This driver supports this device.
974 @retval other This driver does not support this device.
979 ConSplitterAbsolutePointerDriverBindingSupported (
980 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
981 IN EFI_HANDLE ControllerHandle
,
982 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
985 return ConSplitterSupported (
988 &gEfiAbsolutePointerProtocolGuid
994 Test to see if Console Out Device could be supported on the Controller.
996 @param This Driver Binding protocol instance pointer.
997 @param ControllerHandle Handle of device to test.
998 @param RemainingDevicePath Optional parameter use to pick a specific child
1001 @retval EFI_SUCCESS This driver supports this device.
1002 @retval other This driver does not support this device.
1007 ConSplitterConOutDriverBindingSupported (
1008 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1009 IN EFI_HANDLE ControllerHandle
,
1010 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
1013 return ConSplitterSupported (
1016 &gEfiConsoleOutDeviceGuid
1021 Test to see if Standard Error Device could be supported on the Controller.
1023 @param This Driver Binding protocol instance pointer.
1024 @param ControllerHandle Handle of device to test.
1025 @param RemainingDevicePath Optional parameter use to pick a specific child
1028 @retval EFI_SUCCESS This driver supports this device.
1029 @retval other This driver does not support this device.
1034 ConSplitterStdErrDriverBindingSupported (
1035 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1036 IN EFI_HANDLE ControllerHandle
,
1037 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
1040 return ConSplitterSupported (
1043 &gEfiStandardErrorDeviceGuid
1049 Start ConSplitter on devcie handle by opening Console Device Guid on device handle
1050 and the console virtual handle. And Get the console interface on controller handle.
1052 @param This Driver Binding protocol instance pointer.
1053 @param ControllerHandle Handle of device.
1054 @param ConSplitterVirtualHandle Console virtual Handle.
1055 @param DeviceGuid The specified Console Device, such as ConInDev,
1057 @param InterfaceGuid The specified protocol to be opened.
1058 @param Interface Protocol interface returned.
1060 @retval EFI_SUCCESS This driver supports this device.
1061 @retval other Failed to open the specified Console Device Guid
1062 or specified protocol.
1067 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1068 IN EFI_HANDLE ControllerHandle
,
1069 IN EFI_HANDLE ConSplitterVirtualHandle
,
1070 IN EFI_GUID
*DeviceGuid
,
1071 IN EFI_GUID
*InterfaceGuid
,
1072 OUT VOID
**Interface
1079 // Check to see whether the ControllerHandle has the DeviceGuid on it.
1081 Status
= gBS
->OpenProtocol (
1085 This
->DriverBindingHandle
,
1087 EFI_OPEN_PROTOCOL_BY_DRIVER
1089 if (EFI_ERROR (Status
)) {
1094 // Open the Parent Handle for the child.
1096 Status
= gBS
->OpenProtocol (
1100 This
->DriverBindingHandle
,
1101 ConSplitterVirtualHandle
,
1102 EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
1104 if (EFI_ERROR (Status
)) {
1109 // Open InterfaceGuid on the virtul handle.
1111 Status
= gBS
->OpenProtocol (
1115 This
->DriverBindingHandle
,
1116 ConSplitterVirtualHandle
,
1117 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1120 if (!EFI_ERROR (Status
)) {
1125 // close the DeviceGuid on ConSplitter VirtualHandle.
1127 gBS
->CloseProtocol (
1130 This
->DriverBindingHandle
,
1131 ConSplitterVirtualHandle
1136 // close the DeviceGuid on ControllerHandle.
1138 gBS
->CloseProtocol (
1141 This
->DriverBindingHandle
,
1150 Start Console In 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 Console In Consplitter is added to ControllerHandle.
1158 @retval other Console In Consplitter does not support this device.
1163 ConSplitterConInDriverBindingStart (
1164 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1165 IN EFI_HANDLE ControllerHandle
,
1166 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
1170 EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*TextIn
;
1171 EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*TextInEx
;
1174 // Start ConSplitter on ControllerHandle, and create the virtual
1175 // agrogated console device on first call Start for a SimpleTextIn handle.
1177 Status
= ConSplitterStart (
1180 mConIn
.VirtualHandle
,
1181 &gEfiConsoleInDeviceGuid
,
1182 &gEfiSimpleTextInProtocolGuid
,
1185 if (EFI_ERROR (Status
)) {
1190 // Add this device into Text In devices list.
1192 Status
= ConSplitterTextInAddDevice (&mConIn
, TextIn
);
1193 if (EFI_ERROR (Status
)) {
1197 Status
= gBS
->OpenProtocol (
1199 &gEfiSimpleTextInputExProtocolGuid
,
1200 (VOID
**) &TextInEx
,
1201 This
->DriverBindingHandle
,
1202 mConIn
.VirtualHandle
,
1203 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1205 if (!EFI_ERROR (Status
)) {
1207 // If Simple Text Input Ex protocol exists,
1208 // add this device into Text In Ex devices list.
1210 Status
= ConSplitterTextInExAddDevice (&mConIn
, TextInEx
);
1218 Start Simple Pointer Consplitter on device handle.
1220 @param This Driver Binding protocol instance pointer.
1221 @param ControllerHandle Handle of device to bind driver to.
1222 @param RemainingDevicePath Optional parameter use to pick a specific child
1225 @retval EFI_SUCCESS Simple Pointer Consplitter is added to ControllerHandle.
1226 @retval other Simple Pointer Consplitter does not support this device.
1231 ConSplitterSimplePointerDriverBindingStart (
1232 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1233 IN EFI_HANDLE ControllerHandle
,
1234 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
1238 EFI_SIMPLE_POINTER_PROTOCOL
*SimplePointer
;
1241 // Start ConSplitter on ControllerHandle, and create the virtual
1242 // agrogated console device on first call Start for a SimplePointer handle.
1244 Status
= ConSplitterStart (
1247 mConIn
.VirtualHandle
,
1248 &gEfiSimplePointerProtocolGuid
,
1249 &gEfiSimplePointerProtocolGuid
,
1250 (VOID
**) &SimplePointer
1252 if (EFI_ERROR (Status
)) {
1257 // Add this devcie into Simple Pointer devices list.
1259 return ConSplitterSimplePointerAddDevice (&mConIn
, SimplePointer
);
1264 Start Absolute Pointer Consplitter on device handle.
1266 @param This Driver Binding protocol instance pointer.
1267 @param ControllerHandle Handle of device to bind driver to.
1268 @param RemainingDevicePath Optional parameter use to pick a specific child
1271 @retval EFI_SUCCESS Absolute Pointer Consplitter is added to ControllerHandle.
1272 @retval other Absolute Pointer Consplitter does not support this device.
1277 ConSplitterAbsolutePointerDriverBindingStart (
1278 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1279 IN EFI_HANDLE ControllerHandle
,
1280 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
1284 EFI_ABSOLUTE_POINTER_PROTOCOL
*AbsolutePointer
;
1287 // Start ConSplitter on ControllerHandle, and create the virtual
1288 // agrogated console device on first call Start for a AbsolutePointer handle.
1290 Status
= ConSplitterStart (
1293 mConIn
.VirtualHandle
,
1294 &gEfiAbsolutePointerProtocolGuid
,
1295 &gEfiAbsolutePointerProtocolGuid
,
1296 (VOID
**) &AbsolutePointer
1299 if (EFI_ERROR (Status
)) {
1304 // Add this devcie into Absolute Pointer devices list.
1306 return ConSplitterAbsolutePointerAddDevice (&mConIn
, AbsolutePointer
);
1311 Start Console Out Consplitter on device handle.
1313 @param This Driver Binding protocol instance pointer.
1314 @param ControllerHandle Handle of device to bind driver to.
1315 @param RemainingDevicePath Optional parameter use to pick a specific child
1318 @retval EFI_SUCCESS Console Out Consplitter is added to ControllerHandle.
1319 @retval other Console Out Consplitter does not support this device.
1324 ConSplitterConOutDriverBindingStart (
1325 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1326 IN EFI_HANDLE ControllerHandle
,
1327 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
1331 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
;
1332 EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
;
1333 EFI_UGA_DRAW_PROTOCOL
*UgaDraw
;
1335 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*Info
;
1338 // Start ConSplitter on ControllerHandle, and create the virtual
1339 // agrogated console device on first call Start for a ConsoleOut handle.
1341 Status
= ConSplitterStart (
1344 mConOut
.VirtualHandle
,
1345 &gEfiConsoleOutDeviceGuid
,
1346 &gEfiSimpleTextOutProtocolGuid
,
1349 if (EFI_ERROR (Status
)) {
1353 GraphicsOutput
= NULL
;
1356 // Try to Open Graphics Output protocol
1358 Status
= gBS
->OpenProtocol (
1360 &gEfiGraphicsOutputProtocolGuid
,
1361 (VOID
**) &GraphicsOutput
,
1362 This
->DriverBindingHandle
,
1363 mConOut
.VirtualHandle
,
1364 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1367 if (EFI_ERROR (Status
) && FeaturePcdGet (PcdUgaConsumeSupport
)) {
1369 // Open UGA DRAW protocol
1373 &gEfiUgaDrawProtocolGuid
,
1375 This
->DriverBindingHandle
,
1376 mConOut
.VirtualHandle
,
1377 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1382 // When new console device is added, the new mode will be set later,
1383 // so put current mode back to init state.
1385 mConOut
.TextOutMode
.Mode
= 0xFF;
1388 // If both ConOut and StdErr incorporate the same Text Out device,
1389 // their MaxMode and QueryData should be the intersection of both.
1391 Status
= ConSplitterTextOutAddDevice (&mConOut
, TextOut
, GraphicsOutput
, UgaDraw
);
1392 ConSplitterTextOutSetAttribute (&mConOut
.TextOut
, EFI_TEXT_ATTR (EFI_LIGHTGRAY
, EFI_BLACK
));
1394 if (FeaturePcdGet (PcdConOutUgaSupport
)) {
1396 // Get the UGA mode data of ConOut from the current mode
1398 if (GraphicsOutput
!= NULL
) {
1399 Status
= GraphicsOutput
->QueryMode (GraphicsOutput
, GraphicsOutput
->Mode
->Mode
, &SizeOfInfo
, &Info
);
1400 if (EFI_ERROR (Status
)) {
1403 ASSERT ( SizeOfInfo
<= sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
));
1405 mConOut
.UgaHorizontalResolution
= Info
->HorizontalResolution
;
1406 mConOut
.UgaVerticalResolution
= Info
->VerticalResolution
;
1407 mConOut
.UgaColorDepth
= 32;
1408 mConOut
.UgaRefreshRate
= 60;
1412 } else if (UgaDraw
!= NULL
) {
1413 Status
= UgaDraw
->GetMode (
1415 &mConOut
.UgaHorizontalResolution
,
1416 &mConOut
.UgaVerticalResolution
,
1417 &mConOut
.UgaColorDepth
,
1418 &mConOut
.UgaRefreshRate
1428 Start Standard Error Consplitter on device handle.
1430 @param This Driver Binding protocol instance pointer.
1431 @param ControllerHandle Handle of device to bind driver to.
1432 @param RemainingDevicePath Optional parameter use to pick a specific child
1435 @retval EFI_SUCCESS Standard Error Consplitter is added to ControllerHandle.
1436 @retval other Standard Error Consplitter does not support this device.
1441 ConSplitterStdErrDriverBindingStart (
1442 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1443 IN EFI_HANDLE ControllerHandle
,
1444 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
1448 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
;
1451 // Start ConSplitter on ControllerHandle, and create the virtual
1452 // agrogated console device on first call Start for a StandardError handle.
1454 Status
= ConSplitterStart (
1457 mStdErr
.VirtualHandle
,
1458 &gEfiStandardErrorDeviceGuid
,
1459 &gEfiSimpleTextOutProtocolGuid
,
1462 if (EFI_ERROR (Status
)) {
1467 // When new console device is added, the new mode will be set later,
1468 // so put current mode back to init state.
1470 mStdErr
.TextOutMode
.Mode
= 0xFF;
1473 // If both ConOut and StdErr incorporate the same Text Out device,
1474 // their MaxMode and QueryData should be the intersection of both.
1476 Status
= ConSplitterTextOutAddDevice (&mStdErr
, TextOut
, NULL
, NULL
);
1477 ConSplitterTextOutSetAttribute (&mStdErr
.TextOut
, EFI_TEXT_ATTR (EFI_MAGENTA
, EFI_BLACK
));
1484 Stop ConSplitter on device handle by closing Console Device Guid on device handle
1485 and the console virtual handle.
1487 @param This Protocol instance pointer.
1488 @param ControllerHandle Handle of device.
1489 @param ConSplitterVirtualHandle Console virtual Handle.
1490 @param DeviceGuid The specified Console Device, such as ConInDev,
1492 @param InterfaceGuid The specified protocol to be opened.
1493 @param Interface Protocol interface returned.
1495 @retval EFI_SUCCESS Stop ConSplitter on ControllerHandle successfully.
1496 @retval other Failed to Stop ConSplitter on ControllerHandle.
1501 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1502 IN EFI_HANDLE ControllerHandle
,
1503 IN EFI_HANDLE ConSplitterVirtualHandle
,
1504 IN EFI_GUID
*DeviceGuid
,
1505 IN EFI_GUID
*InterfaceGuid
,
1511 Status
= gBS
->OpenProtocol (
1515 This
->DriverBindingHandle
,
1517 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1519 if (EFI_ERROR (Status
)) {
1523 // close the protocol refered.
1525 gBS
->CloseProtocol (
1528 This
->DriverBindingHandle
,
1529 ConSplitterVirtualHandle
1532 gBS
->CloseProtocol (
1535 This
->DriverBindingHandle
,
1544 Stop Console In ConSplitter on ControllerHandle by closing Console In Devcice GUID.
1546 @param This Driver Binding protocol instance pointer.
1547 @param ControllerHandle Handle of device to stop driver on
1548 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
1549 children is zero stop the entire bus driver.
1550 @param ChildHandleBuffer List of Child Handles to Stop.
1552 @retval EFI_SUCCESS This driver is removed ControllerHandle
1553 @retval other This driver was not removed from this device
1558 ConSplitterConInDriverBindingStop (
1559 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1560 IN EFI_HANDLE ControllerHandle
,
1561 IN UINTN NumberOfChildren
,
1562 IN EFI_HANDLE
*ChildHandleBuffer
1566 EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*TextIn
;
1567 EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*TextInEx
;
1569 if (NumberOfChildren
== 0) {
1573 Status
= gBS
->OpenProtocol (
1575 &gEfiSimpleTextInputExProtocolGuid
,
1576 (VOID
**) &TextInEx
,
1577 This
->DriverBindingHandle
,
1579 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1581 if (!EFI_ERROR (Status
)) {
1583 // If Simple Text Input Ex protocol exists,
1584 // remove device from Text Input Ex devices list.
1586 Status
= ConSplitterTextInExDeleteDevice (&mConIn
, TextInEx
);
1587 if (EFI_ERROR (Status
)) {
1593 // Close Simple Text In protocol on controller handle and virtual handle.
1595 Status
= ConSplitterStop (
1598 mConIn
.VirtualHandle
,
1599 &gEfiConsoleInDeviceGuid
,
1600 &gEfiSimpleTextInProtocolGuid
,
1603 if (EFI_ERROR (Status
)) {
1608 // Remove device from Text Input devices list.
1610 return ConSplitterTextInDeleteDevice (&mConIn
, TextIn
);
1615 Stop Simple Pointer protocol ConSplitter on ControllerHandle by closing
1616 Simple Pointer protocol.
1618 @param This Driver Binding protocol instance pointer.
1619 @param ControllerHandle Handle of device to stop driver on
1620 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
1621 children is zero stop the entire bus driver.
1622 @param ChildHandleBuffer List of Child Handles to Stop.
1624 @retval EFI_SUCCESS This driver is removed ControllerHandle
1625 @retval other This driver was not removed from this device
1630 ConSplitterSimplePointerDriverBindingStop (
1631 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1632 IN EFI_HANDLE ControllerHandle
,
1633 IN UINTN NumberOfChildren
,
1634 IN EFI_HANDLE
*ChildHandleBuffer
1638 EFI_SIMPLE_POINTER_PROTOCOL
*SimplePointer
;
1640 if (NumberOfChildren
== 0) {
1645 // Close Simple Pointer protocol on controller handle and virtual handle.
1647 Status
= ConSplitterStop (
1650 mConIn
.VirtualHandle
,
1651 &gEfiSimplePointerProtocolGuid
,
1652 &gEfiSimplePointerProtocolGuid
,
1653 (VOID
**) &SimplePointer
1655 if (EFI_ERROR (Status
)) {
1660 // Remove this device from Simple Pointer device list.
1662 return ConSplitterSimplePointerDeleteDevice (&mConIn
, SimplePointer
);
1667 Stop Absolute Pointer protocol ConSplitter on ControllerHandle by closing
1668 Absolute Pointer protocol.
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 ConSplitterAbsolutePointerDriverBindingStop (
1683 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1684 IN EFI_HANDLE ControllerHandle
,
1685 IN UINTN NumberOfChildren
,
1686 IN EFI_HANDLE
*ChildHandleBuffer
1690 EFI_ABSOLUTE_POINTER_PROTOCOL
*AbsolutePointer
;
1692 if (NumberOfChildren
== 0) {
1697 // Close Absolute Pointer protocol on controller handle and virtual handle.
1699 Status
= ConSplitterStop (
1702 mConIn
.VirtualHandle
,
1703 &gEfiAbsolutePointerProtocolGuid
,
1704 &gEfiAbsolutePointerProtocolGuid
,
1705 (VOID
**) &AbsolutePointer
1707 if (EFI_ERROR (Status
)) {
1712 // Remove this device from Absolute Pointer device list.
1714 return ConSplitterAbsolutePointerDeleteDevice (&mConIn
, AbsolutePointer
);
1719 Stop Console Out ConSplitter on device handle by closing Console Out Devcice 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 ConSplitterConOutDriverBindingStop (
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 Absolute Pointer protocol on controller handle and virtual handle.
1750 Status
= ConSplitterStop (
1753 mConOut
.VirtualHandle
,
1754 &gEfiConsoleOutDeviceGuid
,
1755 &gEfiSimpleTextOutProtocolGuid
,
1758 if (EFI_ERROR (Status
)) {
1763 // Remove this device from Text Out device list.
1765 return ConSplitterTextOutDeleteDevice (&mConOut
, TextOut
);
1770 Stop Standard Error ConSplitter on ControllerHandle by closing Standard Error GUID.
1772 @param This Driver Binding protocol instance pointer.
1773 @param ControllerHandle Handle of device to stop driver on
1774 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
1775 children is zero stop the entire bus driver.
1776 @param ChildHandleBuffer List of Child Handles to Stop.
1778 @retval EFI_SUCCESS This driver is removed ControllerHandle
1779 @retval other This driver was not removed from this device
1784 ConSplitterStdErrDriverBindingStop (
1785 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1786 IN EFI_HANDLE ControllerHandle
,
1787 IN UINTN NumberOfChildren
,
1788 IN EFI_HANDLE
*ChildHandleBuffer
1792 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
;
1794 if (NumberOfChildren
== 0) {
1799 // Close Standard Error Device on controller handle and virtual handle.
1801 Status
= ConSplitterStop (
1804 mStdErr
.VirtualHandle
,
1805 &gEfiStandardErrorDeviceGuid
,
1806 &gEfiSimpleTextOutProtocolGuid
,
1809 if (EFI_ERROR (Status
)) {
1813 // Delete this console error out device's data structures.
1815 return ConSplitterTextOutDeleteDevice (&mStdErr
, TextOut
);
1820 Take the passed in Buffer of size ElementSize and grow the buffer
1821 by CONSOLE_SPLITTER_ALLOC_UNIT * ElementSize bytes.
1822 Copy the current data in Buffer to the new version of Buffer and
1823 free the old version of buffer.
1825 @param ElementSize Size of element in array.
1826 @param Count Current number of elements in array.
1827 @param Buffer Bigger version of passed in Buffer with all the
1830 @retval EFI_SUCCESS Buffer size has grown.
1831 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
1835 ConSplitterGrowBuffer (
1836 IN UINTN ElementSize
,
1837 IN OUT UINTN
*Count
,
1838 IN OUT VOID
**Buffer
1844 // grow the buffer to new buffer size,
1845 // copy the old buffer's content to the new-size buffer,
1846 // then free the old buffer.
1848 Ptr
= ReallocatePool (
1849 ElementSize
* (*Count
),
1850 ElementSize
* ((*Count
) + CONSOLE_SPLITTER_ALLOC_UNIT
),
1854 return EFI_OUT_OF_RESOURCES
;
1856 *Count
+= CONSOLE_SPLITTER_ALLOC_UNIT
;
1863 Add Text Input Device in Consplitter Text Input list.
1865 @param Private Text In Splitter pointer.
1866 @param TextIn Simple Text Input protocol pointer.
1868 @retval EFI_SUCCESS Text Input Device added successfully.
1869 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
1873 ConSplitterTextInAddDevice (
1874 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
1875 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*TextIn
1881 // If the Text In List is full, enlarge it by calling ConSplitterGrowBuffer().
1883 if (Private
->CurrentNumberOfConsoles
>= Private
->TextInListCount
) {
1884 Status
= ConSplitterGrowBuffer (
1885 sizeof (EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*),
1886 &Private
->TextInListCount
,
1887 (VOID
**) &Private
->TextInList
1889 if (EFI_ERROR (Status
)) {
1890 return EFI_OUT_OF_RESOURCES
;
1894 // Add the new text-in device data structure into the Text In List.
1896 Private
->TextInList
[Private
->CurrentNumberOfConsoles
] = TextIn
;
1897 Private
->CurrentNumberOfConsoles
++;
1900 // Extra CheckEvent added to reduce the double CheckEvent().
1902 gBS
->CheckEvent (TextIn
->WaitForKey
);
1909 Remove Text Input Device from Consplitter Text Input list.
1911 @param Private Text In Splitter pointer.
1912 @param TextIn Simple Text protocol pointer.
1914 @retval EFI_SUCCESS Simple Text Device removed successfully.
1915 @retval EFI_NOT_FOUND No Simple Text Device found.
1919 ConSplitterTextInDeleteDevice (
1920 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
1921 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*TextIn
1926 // Remove the specified text-in device data structure from the Text In List,
1927 // and rearrange the remaining data structures in the Text In List.
1929 for (Index
= 0; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
1930 if (Private
->TextInList
[Index
] == TextIn
) {
1931 for (; Index
< Private
->CurrentNumberOfConsoles
- 1; Index
++) {
1932 Private
->TextInList
[Index
] = Private
->TextInList
[Index
+ 1];
1935 Private
->CurrentNumberOfConsoles
--;
1940 return EFI_NOT_FOUND
;
1944 Add Text Input Ex Device in Consplitter Text Input Ex list.
1946 @param Private Text In Splitter pointer.
1947 @param TextInEx Simple Text Input Ex Input protocol pointer.
1949 @retval EFI_SUCCESS Text Input Ex Device added successfully.
1950 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
1954 ConSplitterTextInExAddDevice (
1955 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
1956 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*TextInEx
1961 TEXT_IN_EX_SPLITTER_NOTIFY
*CurrentNotify
;
1962 UINTN TextInExListCount
;
1965 // Enlarge the NotifyHandleList and the TextInExList
1967 if (Private
->CurrentNumberOfExConsoles
>= Private
->TextInExListCount
) {
1968 for (Link
= Private
->NotifyList
.ForwardLink
; Link
!= &Private
->NotifyList
; Link
= Link
->ForwardLink
) {
1969 CurrentNotify
= TEXT_IN_EX_SPLITTER_NOTIFY_FROM_THIS (Link
);
1970 TextInExListCount
= Private
->TextInExListCount
;
1972 Status
= ConSplitterGrowBuffer (
1973 sizeof (EFI_HANDLE
),
1975 (VOID
**) &CurrentNotify
->NotifyHandleList
1977 if (EFI_ERROR (Status
)) {
1978 return EFI_OUT_OF_RESOURCES
;
1982 TextInExListCount
= Private
->TextInExListCount
;
1983 Status
= ConSplitterGrowBuffer (
1984 sizeof (EFI_KEY_DATA
),
1986 (VOID
**) &Private
->KeyQueue
1988 if (EFI_ERROR (Status
)) {
1989 return EFI_OUT_OF_RESOURCES
;
1992 Status
= ConSplitterGrowBuffer (
1993 sizeof (EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*),
1994 &Private
->TextInExListCount
,
1995 (VOID
**) &Private
->TextInExList
1997 if (EFI_ERROR (Status
)) {
1998 return EFI_OUT_OF_RESOURCES
;
2003 // Register the key notify in the new text-in device
2005 for (Link
= Private
->NotifyList
.ForwardLink
; Link
!= &Private
->NotifyList
; Link
= Link
->ForwardLink
) {
2006 CurrentNotify
= TEXT_IN_EX_SPLITTER_NOTIFY_FROM_THIS (Link
);
2007 Status
= TextInEx
->RegisterKeyNotify (
2009 &CurrentNotify
->KeyData
,
2010 CurrentNotify
->KeyNotificationFn
,
2011 &CurrentNotify
->NotifyHandleList
[Private
->CurrentNumberOfExConsoles
]
2013 if (EFI_ERROR (Status
)) {
2014 for (Link
= Link
->BackLink
; Link
!= &Private
->NotifyList
; Link
= Link
->BackLink
) {
2015 CurrentNotify
= TEXT_IN_EX_SPLITTER_NOTIFY_FROM_THIS (Link
);
2016 TextInEx
->UnregisterKeyNotify (
2018 CurrentNotify
->NotifyHandleList
[Private
->CurrentNumberOfExConsoles
]
2026 // Add the new text-in device data structure into the Text Input Ex List.
2028 Private
->TextInExList
[Private
->CurrentNumberOfExConsoles
] = TextInEx
;
2029 Private
->CurrentNumberOfExConsoles
++;
2032 // Sync current toggle state to this new console input device.
2034 TextInEx
->SetState (TextInEx
, &Private
->PhysicalKeyToggleState
);
2037 // Extra CheckEvent added to reduce the double CheckEvent().
2039 gBS
->CheckEvent (TextInEx
->WaitForKeyEx
);
2045 Remove Text Ex Device from Consplitter Text Input Ex list.
2047 @param Private Text In Splitter pointer.
2048 @param TextInEx Simple Text Ex protocol pointer.
2050 @retval EFI_SUCCESS Simple Text Input Ex Device removed successfully.
2051 @retval EFI_NOT_FOUND No Simple Text Input Ex Device found.
2055 ConSplitterTextInExDeleteDevice (
2056 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
2057 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*TextInEx
2062 // Remove the specified text-in device data structure from the Text Input Ex List,
2063 // and rearrange the remaining data structures in the Text In List.
2065 for (Index
= 0; Index
< Private
->CurrentNumberOfExConsoles
; Index
++) {
2066 if (Private
->TextInExList
[Index
] == TextInEx
) {
2067 for (; Index
< Private
->CurrentNumberOfExConsoles
- 1; Index
++) {
2068 Private
->TextInExList
[Index
] = Private
->TextInExList
[Index
+ 1];
2071 Private
->CurrentNumberOfExConsoles
--;
2076 return EFI_NOT_FOUND
;
2081 Add Simple Pointer Device in Consplitter Simple Pointer list.
2083 @param Private Text In Splitter pointer.
2084 @param SimplePointer Simple Pointer protocol pointer.
2086 @retval EFI_SUCCESS Simple Pointer Device added successfully.
2087 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
2091 ConSplitterSimplePointerAddDevice (
2092 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
2093 IN EFI_SIMPLE_POINTER_PROTOCOL
*SimplePointer
2099 // If the Simple Pointer List is full, enlarge it by calling ConSplitterGrowBuffer().
2101 if (Private
->CurrentNumberOfPointers
>= Private
->PointerListCount
) {
2102 Status
= ConSplitterGrowBuffer (
2103 sizeof (EFI_SIMPLE_POINTER_PROTOCOL
*),
2104 &Private
->PointerListCount
,
2105 (VOID
**) &Private
->PointerList
2107 if (EFI_ERROR (Status
)) {
2108 return EFI_OUT_OF_RESOURCES
;
2112 // Add the new text-in device data structure into the Simple Pointer List.
2114 Private
->PointerList
[Private
->CurrentNumberOfPointers
] = SimplePointer
;
2115 Private
->CurrentNumberOfPointers
++;
2122 Remove Simple Pointer Device from Consplitter Simple Pointer list.
2124 @param Private Text In Splitter pointer.
2125 @param SimplePointer Simple Pointer protocol pointer.
2127 @retval EFI_SUCCESS Simple Pointer Device removed successfully.
2128 @retval EFI_NOT_FOUND No Simple Pointer Device found.
2132 ConSplitterSimplePointerDeleteDevice (
2133 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
2134 IN EFI_SIMPLE_POINTER_PROTOCOL
*SimplePointer
2139 // Remove the specified text-in device data structure from the Simple Pointer List,
2140 // and rearrange the remaining data structures in the Text In List.
2142 for (Index
= 0; Index
< Private
->CurrentNumberOfPointers
; Index
++) {
2143 if (Private
->PointerList
[Index
] == SimplePointer
) {
2144 for (; Index
< Private
->CurrentNumberOfPointers
- 1; Index
++) {
2145 Private
->PointerList
[Index
] = Private
->PointerList
[Index
+ 1];
2148 Private
->CurrentNumberOfPointers
--;
2153 return EFI_NOT_FOUND
;
2158 Add Absolute Pointer Device in Consplitter Absolute Pointer list.
2160 @param Private Text In Splitter pointer.
2161 @param AbsolutePointer Absolute Pointer protocol pointer.
2163 @retval EFI_SUCCESS Absolute Pointer Device added successfully.
2164 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
2168 ConSplitterAbsolutePointerAddDevice (
2169 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
2170 IN EFI_ABSOLUTE_POINTER_PROTOCOL
*AbsolutePointer
2176 // If the Absolute Pointer List is full, enlarge it by calling ConSplitterGrowBuffer().
2178 if (Private
->CurrentNumberOfAbsolutePointers
>= Private
->AbsolutePointerListCount
) {
2179 Status
= ConSplitterGrowBuffer (
2180 sizeof (EFI_ABSOLUTE_POINTER_PROTOCOL
*),
2181 &Private
->AbsolutePointerListCount
,
2182 (VOID
**) &Private
->AbsolutePointerList
2184 if (EFI_ERROR (Status
)) {
2185 return EFI_OUT_OF_RESOURCES
;
2189 // Add the new text-in device data structure into the Absolute Pointer List.
2191 Private
->AbsolutePointerList
[Private
->CurrentNumberOfAbsolutePointers
] = AbsolutePointer
;
2192 Private
->CurrentNumberOfAbsolutePointers
++;
2199 Remove Absolute Pointer Device from Consplitter Absolute Pointer list.
2201 @param Private Text In Splitter pointer.
2202 @param AbsolutePointer Absolute Pointer protocol pointer.
2204 @retval EFI_SUCCESS Absolute Pointer Device removed successfully.
2205 @retval EFI_NOT_FOUND No Absolute Pointer Device found.
2209 ConSplitterAbsolutePointerDeleteDevice (
2210 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
2211 IN EFI_ABSOLUTE_POINTER_PROTOCOL
*AbsolutePointer
2216 // Remove the specified text-in device data structure from the Absolute Pointer List,
2217 // and rearrange the remaining data structures from the Absolute Pointer List.
2219 for (Index
= 0; Index
< Private
->CurrentNumberOfAbsolutePointers
; Index
++) {
2220 if (Private
->AbsolutePointerList
[Index
] == AbsolutePointer
) {
2221 for (; Index
< Private
->CurrentNumberOfAbsolutePointers
- 1; Index
++) {
2222 Private
->AbsolutePointerList
[Index
] = Private
->AbsolutePointerList
[Index
+ 1];
2225 Private
->CurrentNumberOfAbsolutePointers
--;
2230 return EFI_NOT_FOUND
;
2234 Reallocate Text Out mode map.
2236 Allocate new buffer and copy original buffer into the new buffer.
2238 @param Private Consplitter Text Out pointer.
2240 @retval EFI_SUCCESS Buffer size has grown
2241 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
2245 ConSplitterGrowMapTable (
2246 IN TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
2252 INT32
*TextOutModeMap
;
2253 INT32
*OldTextOutModeMap
;
2259 NewSize
= Private
->TextOutListCount
* sizeof (INT32
);
2260 OldTextOutModeMap
= Private
->TextOutModeMap
;
2261 TotalSize
= NewSize
* (Private
->TextOutQueryDataCount
);
2264 // Allocate new buffer for Text Out List.
2266 TextOutModeMap
= AllocatePool (TotalSize
);
2267 if (TextOutModeMap
== NULL
) {
2268 return EFI_OUT_OF_RESOURCES
;
2271 SetMem (TextOutModeMap
, TotalSize
, 0xFF);
2272 Private
->TextOutModeMap
= TextOutModeMap
;
2275 // If TextOutList has been enlarged, need to realloc the mode map table
2276 // The mode map table is regarded as a two dimension array.
2279 // 0 ---------> TextOutListCount ----> TextOutListCount
2280 // | -------------------------------------------
2287 // -------------------------------------------
2290 if (OldTextOutModeMap
!= NULL
) {
2292 Size
= Private
->CurrentNumberOfConsoles
* sizeof (INT32
);
2294 SrcAddress
= OldTextOutModeMap
;
2295 NewStepSize
= NewSize
/ sizeof(INT32
);
2296 // If Private->CurrentNumberOfConsoles is not zero and OldTextOutModeMap
2297 // is not NULL, it indicates that the original TextOutModeMap is not enough
2298 // for the new console devices and has been enlarged by CONSOLE_SPLITTER_ALLOC_UNIT columns.
2300 OldStepSize
= NewStepSize
- CONSOLE_SPLITTER_ALLOC_UNIT
;
2303 // Copy the old data to the new one
2305 while (Index
< Private
->TextOutMode
.MaxMode
) {
2306 CopyMem (TextOutModeMap
, SrcAddress
, Size
);
2308 // Go to next row of new TextOutModeMap.
2310 TextOutModeMap
+= NewStepSize
;
2312 // Go to next row of old TextOutModeMap.
2314 SrcAddress
+= OldStepSize
;
2318 // Free the old buffer
2320 FreePool (OldTextOutModeMap
);
2328 Add new device's output mode to console splitter's mode list.
2330 @param Private Text Out Splitter pointer
2331 @param TextOut Simple Text Output protocol pointer.
2333 @retval EFI_SUCCESS Device added successfully.
2334 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
2338 ConSplitterAddOutputMode (
2339 IN TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
,
2340 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
2348 MaxMode
= TextOut
->Mode
->MaxMode
;
2349 Private
->TextOutMode
.MaxMode
= MaxMode
;
2352 // Grow the buffer if query data buffer is not large enough to
2353 // hold all the mode supported by the first console.
2355 while (MaxMode
> (INT32
) Private
->TextOutQueryDataCount
) {
2356 Status
= ConSplitterGrowBuffer (
2357 sizeof (TEXT_OUT_SPLITTER_QUERY_DATA
),
2358 &Private
->TextOutQueryDataCount
,
2359 (VOID
**) &Private
->TextOutQueryData
2361 if (EFI_ERROR (Status
)) {
2362 return EFI_OUT_OF_RESOURCES
;
2366 // Allocate buffer for the output mode map
2368 Status
= ConSplitterGrowMapTable (Private
);
2369 if (EFI_ERROR (Status
)) {
2370 return EFI_OUT_OF_RESOURCES
;
2373 // As the first textout device, directly add the mode in to QueryData
2374 // and at the same time record the mapping between QueryData and TextOut.
2378 while (Mode
< MaxMode
) {
2379 Status
= TextOut
->QueryMode (
2382 &Private
->TextOutQueryData
[Mode
].Columns
,
2383 &Private
->TextOutQueryData
[Mode
].Rows
2386 // If mode 1 (80x50) is not supported, make sure mode 1 in TextOutQueryData
2389 if ((EFI_ERROR(Status
)) && (Mode
== 1)) {
2390 Private
->TextOutQueryData
[Mode
].Columns
= 0;
2391 Private
->TextOutQueryData
[Mode
].Rows
= 0;
2393 Private
->TextOutModeMap
[Index
] = Mode
;
2395 Index
+= Private
->TextOutListCount
;
2402 Reconstruct TextOutModeMap to get intersection of modes.
2404 This routine reconstruct TextOutModeMap to get the intersection
2405 of modes for all console out devices. Because EFI/UEFI spec require
2406 mode 0 is 80x25, mode 1 is 80x50, this routine will not check the
2407 intersection for mode 0 and mode 1.
2409 @param TextOutModeMap Current text out mode map, begin with the mode 80x25
2410 @param NewlyAddedMap New text out mode map, begin with the mode 80x25
2411 @param MapStepSize Mode step size for one console device
2412 @param NewMapStepSize New Mode step size for one console device
2413 @param MaxMode IN: Current max text mode, OUT: Updated max text mode.
2414 @param CurrentMode IN: Current text mode, OUT: Updated current text mode.
2418 ConSplitterGetIntersection (
2419 IN INT32
*TextOutModeMap
,
2420 IN INT32
*NewlyAddedMap
,
2421 IN UINTN MapStepSize
,
2422 IN UINTN NewMapStepSize
,
2423 IN OUT INT32
*MaxMode
,
2424 IN OUT INT32
*CurrentMode
2428 INT32
*CurrentMapEntry
;
2429 INT32
*NextMapEntry
;
2431 INT32 CurrentMaxMode
;
2435 // According to EFI/UEFI spec, mode 0 and mode 1 have been reserved
2436 // for 80x25 and 80x50 in Simple Text Out protocol, so don't make intersection
2437 // for mode 0 and mode 1, mode number starts from 2.
2440 CurrentMapEntry
= &TextOutModeMap
[MapStepSize
* 2];
2441 NextMapEntry
= CurrentMapEntry
;
2442 NewMapEntry
= &NewlyAddedMap
[NewMapStepSize
* 2];
2444 CurrentMaxMode
= *MaxMode
;
2445 Mode
= *CurrentMode
;
2447 while (Index
< CurrentMaxMode
) {
2448 if (*NewMapEntry
== -1) {
2450 // This mode is not supported any more. Remove it. Special care
2451 // must be taken as this remove will also affect current mode;
2453 if (Index
== *CurrentMode
) {
2455 } else if (Index
< *CurrentMode
) {
2460 if (CurrentMapEntry
!= NextMapEntry
) {
2461 CopyMem (NextMapEntry
, CurrentMapEntry
, MapStepSize
* sizeof (INT32
));
2464 NextMapEntry
+= MapStepSize
;
2467 CurrentMapEntry
+= MapStepSize
;
2468 NewMapEntry
+= NewMapStepSize
;
2472 *CurrentMode
= Mode
;
2478 Sync the device's output mode to console splitter's mode list.
2480 @param Private Text Out Splitter pointer.
2481 @param TextOut Simple Text Output protocol pointer.
2485 ConSplitterSyncOutputMode (
2486 IN TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
,
2487 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
2490 INT32 CurrentMaxMode
;
2493 INT32
*TextOutModeMap
;
2496 TEXT_OUT_SPLITTER_QUERY_DATA
*TextOutQueryData
;
2503 // Must make sure that current mode won't change even if mode number changes
2505 CurrentMaxMode
= Private
->TextOutMode
.MaxMode
;
2506 TextOutModeMap
= Private
->TextOutModeMap
;
2507 StepSize
= Private
->TextOutListCount
;
2508 TextOutQueryData
= Private
->TextOutQueryData
;
2511 // Query all the mode that the newly added TextOut supports
2514 MapTable
= TextOutModeMap
+ Private
->CurrentNumberOfConsoles
;
2515 while (Mode
< TextOut
->Mode
->MaxMode
) {
2516 Status
= TextOut
->QueryMode (TextOut
, Mode
, &Columns
, &Rows
);
2518 if (EFI_ERROR(Status
)) {
2521 // If mode 1 (80x50) is not supported, make sure mode 1 in TextOutQueryData
2524 MapTable
[StepSize
] = Mode
;
2525 TextOutQueryData
[Mode
].Columns
= 0;
2526 TextOutQueryData
[Mode
].Rows
= 0;
2532 // Search the intersection map and QueryData database to see if they intersects
2535 while (Index
< CurrentMaxMode
) {
2536 QueryMode
= *(TextOutModeMap
+ Index
* StepSize
);
2537 if ((TextOutQueryData
[QueryMode
].Rows
== Rows
) && (TextOutQueryData
[QueryMode
].Columns
== Columns
)) {
2538 MapTable
[Index
* StepSize
] = Mode
;
2546 // Now search the TextOutModeMap table to find the intersection of supported
2547 // mode between ConSplitter and the newly added device.
2549 ConSplitterGetIntersection (
2554 &Private
->TextOutMode
.MaxMode
,
2555 &Private
->TextOutMode
.Mode
2563 Sync output device between ConOut and StdErr output.
2565 @retval EFI_SUCCESS Sync implemented successfully.
2566 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
2570 ConSplitterGetIntersectionBetweenConOutAndStrErr (
2574 UINTN ConOutNumOfConsoles
;
2575 UINTN StdErrNumOfConsoles
;
2576 TEXT_OUT_AND_GOP_DATA
*ConOutTextOutList
;
2577 TEXT_OUT_AND_GOP_DATA
*StdErrTextOutList
;
2581 UINTN ConOutColumns
;
2583 UINTN StdErrColumns
;
2584 INT32 ConOutMaxMode
;
2585 INT32 StdErrMaxMode
;
2590 INT32
*ConOutModeMap
;
2591 INT32
*StdErrModeMap
;
2592 INT32
*ConOutMapTable
;
2593 INT32
*StdErrMapTable
;
2594 TEXT_OUT_SPLITTER_QUERY_DATA
*ConOutQueryData
;
2595 TEXT_OUT_SPLITTER_QUERY_DATA
*StdErrQueryData
;
2596 UINTN ConOutStepSize
;
2597 UINTN StdErrStepSize
;
2598 BOOLEAN FoundTheSameTextOut
;
2599 UINTN ConOutMapTableSize
;
2600 UINTN StdErrMapTableSize
;
2602 ConOutNumOfConsoles
= mConOut
.CurrentNumberOfConsoles
;
2603 StdErrNumOfConsoles
= mStdErr
.CurrentNumberOfConsoles
;
2604 ConOutTextOutList
= mConOut
.TextOutList
;
2605 StdErrTextOutList
= mStdErr
.TextOutList
;
2608 FoundTheSameTextOut
= FALSE
;
2609 while ((Indexi
< ConOutNumOfConsoles
) && (!FoundTheSameTextOut
)) {
2611 while (Indexj
< StdErrNumOfConsoles
) {
2612 if (ConOutTextOutList
->TextOut
== StdErrTextOutList
->TextOut
) {
2613 FoundTheSameTextOut
= TRUE
;
2618 StdErrTextOutList
++;
2622 ConOutTextOutList
++;
2625 if (!FoundTheSameTextOut
) {
2629 // Must make sure that current mode won't change even if mode number changes
2631 ConOutMaxMode
= mConOut
.TextOutMode
.MaxMode
;
2632 ConOutModeMap
= mConOut
.TextOutModeMap
;
2633 ConOutStepSize
= mConOut
.TextOutListCount
;
2634 ConOutQueryData
= mConOut
.TextOutQueryData
;
2636 StdErrMaxMode
= mStdErr
.TextOutMode
.MaxMode
;
2637 StdErrModeMap
= mStdErr
.TextOutModeMap
;
2638 StdErrStepSize
= mStdErr
.TextOutListCount
;
2639 StdErrQueryData
= mStdErr
.TextOutQueryData
;
2642 // Allocate the map table and set the map table's index to -1.
2644 ConOutMapTableSize
= ConOutMaxMode
* sizeof (INT32
);
2645 ConOutMapTable
= AllocateZeroPool (ConOutMapTableSize
);
2646 if (ConOutMapTable
== NULL
) {
2647 return EFI_OUT_OF_RESOURCES
;
2650 SetMem (ConOutMapTable
, ConOutMapTableSize
, 0xFF);
2652 StdErrMapTableSize
= StdErrMaxMode
* sizeof (INT32
);
2653 StdErrMapTable
= AllocateZeroPool (StdErrMapTableSize
);
2654 if (StdErrMapTable
== NULL
) {
2655 return EFI_OUT_OF_RESOURCES
;
2658 SetMem (StdErrMapTable
, StdErrMapTableSize
, 0xFF);
2661 // Find the intersection of the two set of modes. If they actually intersect, the
2662 // corresponding entry in the map table is set to 1.
2665 while (Mode
< ConOutMaxMode
) {
2667 // Search the intersection map and QueryData database to see if they intersect
2670 ConOutMode
= *(ConOutModeMap
+ Mode
* ConOutStepSize
);
2671 ConOutRows
= ConOutQueryData
[ConOutMode
].Rows
;
2672 ConOutColumns
= ConOutQueryData
[ConOutMode
].Columns
;
2673 while (Index
< StdErrMaxMode
) {
2674 StdErrMode
= *(StdErrModeMap
+ Index
* StdErrStepSize
);
2675 StdErrRows
= StdErrQueryData
[StdErrMode
].Rows
;
2676 StdErrColumns
= StdErrQueryData
[StdErrMode
].Columns
;
2677 if ((StdErrRows
== ConOutRows
) && (StdErrColumns
== ConOutColumns
)) {
2678 ConOutMapTable
[Mode
] = 1;
2679 StdErrMapTable
[Index
] = 1;
2689 // Now search the TextOutModeMap table to find the intersection of supported
2690 // mode between ConSplitter and the newly added device.
2692 ConSplitterGetIntersection (
2695 mConOut
.TextOutListCount
,
2697 &(mConOut
.TextOutMode
.MaxMode
),
2698 &(mConOut
.TextOutMode
.Mode
)
2701 if (mConOut
.TextOutMode
.Mode
< 0) {
2702 mConOut
.TextOut
.SetMode (&(mConOut
.TextOut
), 0);
2705 ConSplitterGetIntersection (
2708 mStdErr
.TextOutListCount
,
2710 &(mStdErr
.TextOutMode
.MaxMode
),
2711 &(mStdErr
.TextOutMode
.Mode
)
2714 if (mStdErr
.TextOutMode
.Mode
< 0) {
2715 mStdErr
.TextOut
.SetMode (&(mStdErr
.TextOut
), 0);
2718 FreePool (ConOutMapTable
);
2719 FreePool (StdErrMapTable
);
2726 Add Grahpics Output modes into Consplitter Text Out list.
2728 @param Private Text Out Splitter pointer.
2729 @param GraphicsOutput Graphics Output protocol pointer.
2730 @param UgaDraw UGA Draw protocol pointer.
2732 @retval EFI_SUCCESS Output mode added successfully.
2733 @retval other Failed to add output mode.
2737 ConSplitterAddGraphicsOutputMode (
2738 IN TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
,
2739 IN EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
,
2740 IN EFI_UGA_DRAW_PROTOCOL
*UgaDraw
2746 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*Mode
;
2748 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*Info
;
2749 EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE
*CurrentGraphicsOutputMode
;
2750 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*ModeBuffer
;
2751 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*MatchedMode
;
2754 BOOLEAN AlreadyExist
;
2755 UINT32 UgaHorizontalResolution
;
2756 UINT32 UgaVerticalResolution
;
2757 UINT32 UgaColorDepth
;
2758 UINT32 UgaRefreshRate
;
2760 ASSERT (GraphicsOutput
!= NULL
|| UgaDraw
!= NULL
);
2762 CurrentGraphicsOutputMode
= Private
->GraphicsOutput
.Mode
;
2766 Status
= EFI_SUCCESS
;
2768 if (Private
->CurrentNumberOfUgaDraw
!= 0) {
2770 // If any UGA device has already been added, then there is no need to
2771 // calculate intersection of display mode of different GOP/UGA device,
2772 // since only one display mode will be exported (i.e. user-defined mode)
2777 if (GraphicsOutput
!= NULL
) {
2778 if (Private
->CurrentNumberOfGraphicsOutput
== 0) {
2780 // This is the first Graphics Output device added
2782 CurrentGraphicsOutputMode
->MaxMode
= GraphicsOutput
->Mode
->MaxMode
;
2783 CurrentGraphicsOutputMode
->Mode
= GraphicsOutput
->Mode
->Mode
;
2784 CopyMem (CurrentGraphicsOutputMode
->Info
, GraphicsOutput
->Mode
->Info
, GraphicsOutput
->Mode
->SizeOfInfo
);
2785 CurrentGraphicsOutputMode
->SizeOfInfo
= GraphicsOutput
->Mode
->SizeOfInfo
;
2786 CurrentGraphicsOutputMode
->FrameBufferBase
= GraphicsOutput
->Mode
->FrameBufferBase
;
2787 CurrentGraphicsOutputMode
->FrameBufferSize
= GraphicsOutput
->Mode
->FrameBufferSize
;
2790 // Allocate resource for the private mode buffer
2792 ModeBuffer
= AllocatePool (sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
) * GraphicsOutput
->Mode
->MaxMode
);
2793 if (ModeBuffer
== NULL
) {
2794 return EFI_OUT_OF_RESOURCES
;
2796 FreePool (Private
->GraphicsOutputModeBuffer
);
2797 Private
->GraphicsOutputModeBuffer
= ModeBuffer
;
2800 // Store all supported display modes to the private mode buffer
2803 for (Index
= 0; Index
< GraphicsOutput
->Mode
->MaxMode
; Index
++) {
2805 // The Info buffer would be allocated by callee
2807 Status
= GraphicsOutput
->QueryMode (GraphicsOutput
, (UINT32
) Index
, &SizeOfInfo
, &Info
);
2808 if (EFI_ERROR (Status
)) {
2811 ASSERT ( SizeOfInfo
<= sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
));
2812 CopyMem (Mode
, Info
, SizeOfInfo
);
2818 // Check intersection of display mode
2820 ModeBuffer
= AllocatePool (sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
) * CurrentGraphicsOutputMode
->MaxMode
);
2821 if (ModeBuffer
== NULL
) {
2822 return EFI_OUT_OF_RESOURCES
;
2825 MatchedMode
= ModeBuffer
;
2826 Mode
= &Private
->GraphicsOutputModeBuffer
[0];
2827 for (Index
= 0; Index
< CurrentGraphicsOutputMode
->MaxMode
; Index
++) {
2830 for (NumberIndex
= 0; NumberIndex
< GraphicsOutput
->Mode
->MaxMode
; NumberIndex
++) {
2832 // The Info buffer would be allocated by callee
2834 Status
= GraphicsOutput
->QueryMode (GraphicsOutput
, (UINT32
) NumberIndex
, &SizeOfInfo
, &Info
);
2835 if (EFI_ERROR (Status
)) {
2838 if ((Info
->HorizontalResolution
== Mode
->HorizontalResolution
) &&
2839 (Info
->VerticalResolution
== Mode
->VerticalResolution
)) {
2841 // If GOP device supports one mode in current mode buffer,
2842 // it will be added into matched mode buffer
2852 AlreadyExist
= FALSE
;
2855 // Check if GOP mode has been in the mode buffer, ModeBuffer = MatchedMode at begin.
2857 for (Info
= ModeBuffer
; Info
< MatchedMode
; Info
++) {
2858 if ((Info
->HorizontalResolution
== Mode
->HorizontalResolution
) &&
2859 (Info
->VerticalResolution
== Mode
->VerticalResolution
)) {
2860 AlreadyExist
= TRUE
;
2865 if (!AlreadyExist
) {
2866 CopyMem (MatchedMode
, Mode
, sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
));
2869 // Physical frame buffer is no longer available, change PixelFormat to PixelBltOnly
2871 MatchedMode
->Version
= 0;
2872 MatchedMode
->PixelFormat
= PixelBltOnly
;
2873 ZeroMem (&MatchedMode
->PixelInformation
, sizeof (EFI_PIXEL_BITMASK
));
2883 // Drop the old mode buffer, assign it to a new one
2885 FreePool (Private
->GraphicsOutputModeBuffer
);
2886 Private
->GraphicsOutputModeBuffer
= ModeBuffer
;
2889 // Physical frame buffer is no longer available when there are more than one physical GOP devices
2891 CurrentGraphicsOutputMode
->MaxMode
= (UINT32
) (((UINTN
) MatchedMode
- (UINTN
) ModeBuffer
) / sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
));
2892 CurrentGraphicsOutputMode
->Info
->PixelFormat
= PixelBltOnly
;
2893 ZeroMem (&CurrentGraphicsOutputMode
->Info
->PixelInformation
, sizeof (EFI_PIXEL_BITMASK
));
2894 CurrentGraphicsOutputMode
->SizeOfInfo
= sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
);
2895 CurrentGraphicsOutputMode
->FrameBufferBase
= (EFI_PHYSICAL_ADDRESS
) (UINTN
) NULL
;
2896 CurrentGraphicsOutputMode
->FrameBufferSize
= 0;
2900 // Graphics console driver can ensure the same mode for all GOP devices
2902 for (Index
= 0; Index
< CurrentGraphicsOutputMode
->MaxMode
; Index
++) {
2903 Mode
= &Private
->GraphicsOutputModeBuffer
[Index
];
2904 if ((Mode
->HorizontalResolution
== GraphicsOutput
->Mode
->Info
->HorizontalResolution
) &&
2905 (Mode
->VerticalResolution
== GraphicsOutput
->Mode
->Info
->VerticalResolution
)) {
2906 CurrentIndex
= Index
;
2910 if (Index
>= CurrentGraphicsOutputMode
->MaxMode
) {
2912 // if user defined mode is not found, set to default mode 800x600
2914 for (Index
= 0; Index
< CurrentGraphicsOutputMode
->MaxMode
; Index
++) {
2915 Mode
= &Private
->GraphicsOutputModeBuffer
[Index
];
2916 if ((Mode
->HorizontalResolution
== 800) && (Mode
->VerticalResolution
== 600)) {
2917 CurrentIndex
= Index
;
2922 } else if (UgaDraw
!= NULL
) {
2924 // Graphics console driver can ensure the same mode for all GOP devices
2925 // so we can get the current mode from this video device
2929 &UgaHorizontalResolution
,
2930 &UgaVerticalResolution
,
2935 CurrentGraphicsOutputMode
->MaxMode
= 1;
2936 Info
= CurrentGraphicsOutputMode
->Info
;
2938 Info
->HorizontalResolution
= UgaHorizontalResolution
;
2939 Info
->VerticalResolution
= UgaVerticalResolution
;
2940 Info
->PixelFormat
= PixelBltOnly
;
2941 Info
->PixelsPerScanLine
= UgaHorizontalResolution
;
2942 CurrentGraphicsOutputMode
->SizeOfInfo
= sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
);
2943 CurrentGraphicsOutputMode
->FrameBufferBase
= (EFI_PHYSICAL_ADDRESS
) (UINTN
) NULL
;
2944 CurrentGraphicsOutputMode
->FrameBufferSize
= 0;
2947 // Update the private mode buffer
2949 CopyMem (&Private
->GraphicsOutputModeBuffer
[0], Info
, sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
));
2952 // Only mode 0 is available to be set
2959 if (GraphicsOutput
!= NULL
) {
2960 Private
->CurrentNumberOfGraphicsOutput
++;
2962 if (UgaDraw
!= NULL
) {
2963 Private
->CurrentNumberOfUgaDraw
++;
2967 // Force GraphicsOutput mode to be set,
2970 Mode
= &Private
->GraphicsOutputModeBuffer
[CurrentIndex
];
2971 if ((GraphicsOutput
!= NULL
) &&
2972 (Mode
->HorizontalResolution
== CurrentGraphicsOutputMode
->Info
->HorizontalResolution
) &&
2973 (Mode
->VerticalResolution
== CurrentGraphicsOutputMode
->Info
->VerticalResolution
)) {
2974 CurrentGraphicsOutputMode
->Mode
= (UINT32
) CurrentIndex
;
2975 if ((Mode
->HorizontalResolution
!= GraphicsOutput
->Mode
->Info
->HorizontalResolution
) ||
2976 (Mode
->VerticalResolution
!= GraphicsOutput
->Mode
->Info
->VerticalResolution
)) {
2978 // If all existing video device has been set to common mode, only set new GOP device to
2981 for (NumberIndex
= 0; NumberIndex
< GraphicsOutput
->Mode
->MaxMode
; NumberIndex
++) {
2982 Status
= GraphicsOutput
->QueryMode (GraphicsOutput
, (UINT32
) NumberIndex
, &SizeOfInfo
, &Info
);
2983 if (EFI_ERROR (Status
)) {
2986 if ((Info
->HorizontalResolution
== Mode
->HorizontalResolution
) && (Info
->VerticalResolution
== Mode
->VerticalResolution
)) {
2992 Status
= GraphicsOutput
->SetMode (GraphicsOutput
, (UINT32
) NumberIndex
);
2996 // Current mode number may need update now, so set it to an invalid mode number
2998 CurrentGraphicsOutputMode
->Mode
= 0xffff;
3000 // Graphics console can ensure all GOP devices have the same mode which can be taken as current mode.
3002 Status
= Private
->GraphicsOutput
.SetMode (&Private
->GraphicsOutput
, (UINT32
) CurrentIndex
);
3003 if (EFI_ERROR(Status
)) {
3005 // If user defined mode is not valid for display device, set to the default mode 800x600.
3007 (Private
->GraphicsOutputModeBuffer
[0]).HorizontalResolution
= 800;
3008 (Private
->GraphicsOutputModeBuffer
[0]).VerticalResolution
= 600;
3009 Status
= Private
->GraphicsOutput
.SetMode (&Private
->GraphicsOutput
, 0);
3017 Set the current console out mode.
3019 This routine will get the current console mode information (column, row)
3020 from ConsoleOutMode variable and set it; if the variable does not exist,
3021 set to user defined console mode.
3023 @param Private Consplitter Text Out pointer.
3027 ConsplitterSetConsoleOutMode (
3028 IN TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
3038 CONSOLE_OUT_MODE ModeInfo
;
3039 CONSOLE_OUT_MODE MaxModeInfo
;
3040 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
;
3044 TextOut
= &Private
->TextOut
;
3045 MaxMode
= (UINTN
) (TextOut
->Mode
->MaxMode
);
3047 MaxModeInfo
.Column
= 0;
3048 MaxModeInfo
.Row
= 0;
3049 ModeInfo
.Column
= PcdGet32 (PcdConOutColumn
);
3050 ModeInfo
.Row
= PcdGet32 (PcdConOutRow
);
3053 // To find the prefer mode and basic mode from Text Out mode list
3055 for (Mode
= 0; Mode
< MaxMode
; Mode
++) {
3056 Status
= TextOut
->QueryMode (TextOut
, Mode
, &Col
, &Row
);
3057 if (!EFI_ERROR(Status
)) {
3058 if ((ModeInfo
.Column
!= 0) && (ModeInfo
.Row
!= 0)) {
3060 // Use user defined column and row
3062 if (Col
== ModeInfo
.Column
&& Row
== ModeInfo
.Row
) {
3067 // If user sets PcdConOutColumn or PcdConOutRow to 0,
3068 // find and set the highest text mode.
3070 if ((Col
>= MaxModeInfo
.Column
) && (Row
>= MaxModeInfo
.Row
)) {
3071 MaxModeInfo
.Column
= Col
;
3072 MaxModeInfo
.Row
= Row
;
3076 if (Col
== 80 && Row
== 25) {
3083 // Set prefer mode to Text Out devices.
3085 Status
= TextOut
->SetMode (TextOut
, PreferMode
);
3086 if (EFI_ERROR(Status
)) {
3088 // if current mode setting is failed, default 80x25 mode will be set.
3090 Status
= TextOut
->SetMode (TextOut
, BaseMode
);
3091 ASSERT(!EFI_ERROR(Status
));
3093 Status
= PcdSet32S (PcdConOutColumn
, 80);
3094 ASSERT(!EFI_ERROR(Status
));
3095 Status
= PcdSet32S (PcdConOutRow
, 25);
3096 ASSERT(!EFI_ERROR(Status
));
3104 Add Text Output Device in Consplitter Text Output list.
3106 @param Private Text Out Splitter pointer.
3107 @param TextOut Simple Text Output protocol pointer.
3108 @param GraphicsOutput Graphics Output protocol pointer.
3109 @param UgaDraw UGA Draw protocol pointer.
3111 @retval EFI_SUCCESS Text Output Device added successfully.
3112 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
3116 ConSplitterTextOutAddDevice (
3117 IN TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
,
3118 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
,
3119 IN EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
,
3120 IN EFI_UGA_DRAW_PROTOCOL
*UgaDraw
3124 UINTN CurrentNumOfConsoles
;
3126 UINT32 UgaHorizontalResolution
;
3127 UINT32 UgaVerticalResolution
;
3128 UINT32 UgaColorDepth
;
3129 UINT32 UgaRefreshRate
;
3130 TEXT_OUT_AND_GOP_DATA
*TextAndGop
;
3132 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*Info
;
3133 EFI_STATUS DeviceStatus
;
3135 Status
= EFI_SUCCESS
;
3136 CurrentNumOfConsoles
= Private
->CurrentNumberOfConsoles
;
3139 // If the Text Out List is full, enlarge it by calling ConSplitterGrowBuffer().
3141 while (CurrentNumOfConsoles
>= Private
->TextOutListCount
) {
3142 Status
= ConSplitterGrowBuffer (
3143 sizeof (TEXT_OUT_AND_GOP_DATA
),
3144 &Private
->TextOutListCount
,
3145 (VOID
**) &Private
->TextOutList
3147 if (EFI_ERROR (Status
)) {
3148 return EFI_OUT_OF_RESOURCES
;
3151 // Also need to reallocate the TextOutModeMap table
3153 Status
= ConSplitterGrowMapTable (Private
);
3154 if (EFI_ERROR (Status
)) {
3155 return EFI_OUT_OF_RESOURCES
;
3159 TextAndGop
= &Private
->TextOutList
[CurrentNumOfConsoles
];
3161 TextAndGop
->TextOut
= TextOut
;
3162 TextAndGop
->GraphicsOutput
= GraphicsOutput
;
3163 TextAndGop
->UgaDraw
= UgaDraw
;
3165 if (CurrentNumOfConsoles
== 0) {
3167 // Add the first device's output mode to console splitter's mode list
3169 Status
= ConSplitterAddOutputMode (Private
, TextOut
);
3171 ConSplitterSyncOutputMode (Private
, TextOut
);
3174 Private
->CurrentNumberOfConsoles
++;
3177 // Scan both TextOutList, for the intersection TextOut device
3178 // maybe both ConOut and StdErr incorporate the same Text Out
3179 // device in them, thus the output of both should be synced.
3181 ConSplitterGetIntersectionBetweenConOutAndStrErr ();
3183 MaxMode
= Private
->TextOutMode
.MaxMode
;
3184 ASSERT (MaxMode
>= 1);
3186 DeviceStatus
= EFI_DEVICE_ERROR
;
3187 Status
= EFI_DEVICE_ERROR
;
3190 // This device display mode will be added into Graphics Ouput modes.
3192 if ((GraphicsOutput
!= NULL
) || (UgaDraw
!= NULL
)) {
3193 DeviceStatus
= ConSplitterAddGraphicsOutputMode (Private
, GraphicsOutput
, UgaDraw
);
3196 if (FeaturePcdGet (PcdConOutUgaSupport
)) {
3198 // If UGA is produced by Consplitter
3200 if (GraphicsOutput
!= NULL
) {
3201 Status
= GraphicsOutput
->QueryMode (GraphicsOutput
, GraphicsOutput
->Mode
->Mode
, &SizeOfInfo
, &Info
);
3202 if (EFI_ERROR (Status
)) {
3205 ASSERT ( SizeOfInfo
<= sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
));
3207 UgaHorizontalResolution
= Info
->HorizontalResolution
;
3208 UgaVerticalResolution
= Info
->VerticalResolution
;
3212 } else if (UgaDraw
!= NULL
) {
3213 Status
= UgaDraw
->GetMode (
3215 &UgaHorizontalResolution
,
3216 &UgaVerticalResolution
,
3220 if (!EFI_ERROR (Status
) && EFI_ERROR (DeviceStatus
)) {
3222 // if GetMode is successfully and UGA device hasn't been set, set it
3224 Status
= ConSplitterUgaDrawSetMode (
3226 UgaHorizontalResolution
,
3227 UgaVerticalResolution
,
3233 // If GetMode/SetMode is failed, set to 800x600 mode
3235 if(EFI_ERROR (Status
)) {
3236 Status
= ConSplitterUgaDrawSetMode (
3247 if (((!EFI_ERROR (DeviceStatus
)) || (!EFI_ERROR (Status
))) &&
3248 ((Private
->CurrentNumberOfGraphicsOutput
+ Private
->CurrentNumberOfUgaDraw
) == 1)) {
3249 if (!FeaturePcdGet (PcdConOutGopSupport
)) {
3251 // If Graphics Outpurt protocol not supported, UGA Draw protocol is installed
3252 // on the virtual handle.
3254 Status
= gBS
->InstallMultipleProtocolInterfaces (
3255 &mConOut
.VirtualHandle
,
3256 &gEfiUgaDrawProtocolGuid
,
3260 } else if (!FeaturePcdGet (PcdConOutUgaSupport
)) {
3262 // If UGA Draw protocol not supported, Graphics Output Protocol is installed
3263 // on virtual handle.
3265 Status
= gBS
->InstallMultipleProtocolInterfaces (
3266 &mConOut
.VirtualHandle
,
3267 &gEfiGraphicsOutputProtocolGuid
,
3268 &mConOut
.GraphicsOutput
,
3273 // Boot Graphics Output protocol and UGA Draw protocol are supported,
3274 // both they will be installed on virtual handle.
3276 Status
= gBS
->InstallMultipleProtocolInterfaces (
3277 &mConOut
.VirtualHandle
,
3278 &gEfiGraphicsOutputProtocolGuid
,
3279 &mConOut
.GraphicsOutput
,
3280 &gEfiUgaDrawProtocolGuid
,
3288 // After adding new console device, all existing console devices should be
3289 // synced to the current shared mode.
3291 ConsplitterSetConsoleOutMode (Private
);
3298 Remove Text Out Device in Consplitter Text Out list.
3300 @param Private Text Out Splitter pointer.
3301 @param TextOut Simple Text Output Pointer protocol pointer.
3303 @retval EFI_SUCCESS Text Out Device removed successfully.
3304 @retval EFI_NOT_FOUND No Text Out Device found.
3308 ConSplitterTextOutDeleteDevice (
3309 IN TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
,
3310 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
3314 UINTN CurrentNumOfConsoles
;
3315 TEXT_OUT_AND_GOP_DATA
*TextOutList
;
3319 // Remove the specified text-out device data structure from the Text out List,
3320 // and rearrange the remaining data structures in the Text out List.
3322 CurrentNumOfConsoles
= Private
->CurrentNumberOfConsoles
;
3323 Index
= (INT32
) CurrentNumOfConsoles
- 1;
3324 TextOutList
= Private
->TextOutList
;
3325 while (Index
>= 0) {
3326 if (TextOutList
->TextOut
== TextOut
) {
3327 if (TextOutList
->UgaDraw
!= NULL
) {
3328 Private
->CurrentNumberOfUgaDraw
--;
3330 if (TextOutList
->GraphicsOutput
!= NULL
) {
3331 Private
->CurrentNumberOfGraphicsOutput
--;
3333 CopyMem (TextOutList
, TextOutList
+ 1, sizeof (TEXT_OUT_AND_GOP_DATA
) * Index
);
3334 CurrentNumOfConsoles
--;
3342 // The specified TextOut is not managed by the ConSplitter driver
3345 return EFI_NOT_FOUND
;
3348 if ((Private
->CurrentNumberOfGraphicsOutput
== 0) && (Private
->CurrentNumberOfUgaDraw
== 0)) {
3350 // If there is not any physical GOP and UGA device in system,
3351 // Consplitter GOP or UGA protocol will be uninstalled
3353 if (!FeaturePcdGet (PcdConOutGopSupport
)) {
3354 Status
= gBS
->UninstallProtocolInterface (
3355 Private
->VirtualHandle
,
3356 &gEfiUgaDrawProtocolGuid
,
3359 } else if (!FeaturePcdGet (PcdConOutUgaSupport
)) {
3360 Status
= gBS
->UninstallProtocolInterface (
3361 Private
->VirtualHandle
,
3362 &gEfiGraphicsOutputProtocolGuid
,
3363 &Private
->GraphicsOutput
3366 Status
= gBS
->UninstallMultipleProtocolInterfaces (
3367 Private
->VirtualHandle
,
3368 &gEfiUgaDrawProtocolGuid
,
3370 &gEfiGraphicsOutputProtocolGuid
,
3371 &Private
->GraphicsOutput
,
3377 if (CurrentNumOfConsoles
== 0) {
3379 // If the number of consoles is zero, reset all parameters
3381 Private
->CurrentNumberOfConsoles
= 0;
3382 Private
->TextOutMode
.MaxMode
= 1;
3383 Private
->TextOutQueryData
[0].Columns
= 80;
3384 Private
->TextOutQueryData
[0].Rows
= 25;
3385 TextOutSetMode (Private
, 0);
3390 // Max Mode is realy an intersection of the QueryMode command to all
3391 // devices. So we must copy the QueryMode of the first device to
3395 Private
->TextOutQueryData
,
3396 Private
->TextOutQueryDataCount
* sizeof (TEXT_OUT_SPLITTER_QUERY_DATA
)
3399 FreePool (Private
->TextOutModeMap
);
3400 Private
->TextOutModeMap
= NULL
;
3401 TextOutList
= Private
->TextOutList
;
3404 // Add the first TextOut to the QueryData array and ModeMap table
3406 Status
= ConSplitterAddOutputMode (Private
, TextOutList
->TextOut
);
3409 // Now add one by one
3412 Private
->CurrentNumberOfConsoles
= 1;
3414 while ((UINTN
) Index
< CurrentNumOfConsoles
) {
3415 ConSplitterSyncOutputMode (Private
, TextOutList
->TextOut
);
3417 Private
->CurrentNumberOfConsoles
++;
3421 ConSplitterGetIntersectionBetweenConOutAndStrErr ();
3428 Reset the input device and optionaly run diagnostics
3430 @param This Protocol instance pointer.
3431 @param ExtendedVerification Driver may perform diagnostics on reset.
3433 @retval EFI_SUCCESS The device was reset.
3434 @retval EFI_DEVICE_ERROR The device is not functioning properly and could
3440 ConSplitterTextInReset (
3441 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*This
,
3442 IN BOOLEAN ExtendedVerification
3446 EFI_STATUS ReturnStatus
;
3447 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3450 Private
= TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
3452 Private
->KeyEventSignalState
= FALSE
;
3455 // return the worst status met
3457 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
3458 Status
= Private
->TextInList
[Index
]->Reset (
3459 Private
->TextInList
[Index
],
3460 ExtendedVerification
3462 if (EFI_ERROR (Status
)) {
3463 ReturnStatus
= Status
;
3467 if (!EFI_ERROR (ReturnStatus
)) {
3468 ToggleStateSyncReInitialization (Private
);
3470 // Empty the key queue.
3472 Private
->CurrentNumberOfKeys
= 0;
3475 return ReturnStatus
;
3479 Dequeue the saved key from internal key queue.
3481 @param Private Protocol instance pointer.
3482 @param KeyData A pointer to a buffer that is filled in with the
3483 keystroke state data for the key that was
3485 @retval EFI_NOT_FOUND Queue is empty.
3486 @retval EFI_SUCCESS First key is dequeued and returned.
3489 ConSplitterTextInExDequeueKey (
3490 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
3491 OUT EFI_KEY_DATA
*KeyData
3494 if (Private
->CurrentNumberOfKeys
== 0) {
3495 return EFI_NOT_FOUND
;
3498 // Return the first saved key.
3500 CopyMem (KeyData
, &Private
->KeyQueue
[0], sizeof (EFI_KEY_DATA
));
3501 Private
->CurrentNumberOfKeys
--;
3503 &Private
->KeyQueue
[0],
3504 &Private
->KeyQueue
[1],
3505 Private
->CurrentNumberOfKeys
* sizeof (EFI_KEY_DATA
)
3511 Reads the next keystroke from the input device. The WaitForKey Event can
3512 be used to test for existance of a keystroke via WaitForEvent () call.
3514 @param Private Protocol instance pointer.
3515 @param Key Driver may perform diagnostics on reset.
3517 @retval EFI_SUCCESS The keystroke information was returned.
3518 @retval EFI_NOT_READY There was no keystroke data availiable.
3519 @retval EFI_DEVICE_ERROR The keydtroke information was not returned due
3525 ConSplitterTextInPrivateReadKeyStroke (
3526 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
3527 OUT EFI_INPUT_KEY
*Key
3532 EFI_KEY_DATA KeyData
;
3535 // Return the first saved non-NULL key.
3538 Status
= ConSplitterTextInExDequeueKey (Private
, &KeyData
);
3539 if (EFI_ERROR (Status
)) {
3542 if ((KeyData
.Key
.ScanCode
!= CHAR_NULL
) || (KeyData
.Key
.UnicodeChar
!= SCAN_NULL
)) {
3543 CopyMem (Key
, &KeyData
.Key
, sizeof (EFI_INPUT_KEY
));
3548 Key
->UnicodeChar
= 0;
3549 Key
->ScanCode
= SCAN_NULL
;
3552 // if no physical console input device exists, return EFI_NOT_READY;
3553 // if any physical console input device has key input,
3554 // return the key and EFI_SUCCESS.
3556 for (Index
= 0; Index
< Private
->CurrentNumberOfConsoles
;) {
3557 Status
= Private
->TextInList
[Index
]->ReadKeyStroke (
3558 Private
->TextInList
[Index
],
3561 if (!EFI_ERROR (Status
)) {
3563 // If it is not partial keystorke, return the key. Otherwise, continue
3564 // to read key from THIS physical console input device.
3566 if ((KeyData
.Key
.ScanCode
!= CHAR_NULL
) || (KeyData
.Key
.UnicodeChar
!= SCAN_NULL
)) {
3567 CopyMem (Key
, &KeyData
.Key
, sizeof (EFI_INPUT_KEY
));
3572 // Continue to read key from NEXT physical console input device.
3578 return EFI_NOT_READY
;
3584 Reads the next keystroke from the input device. The WaitForKey Event can
3585 be used to test for existance of a keystroke via WaitForEvent () call.
3587 @param This Protocol instance pointer.
3588 @param Key Driver may perform diagnostics on reset.
3590 @retval EFI_SUCCESS The keystroke information was returned.
3591 @retval EFI_NOT_READY There was no keystroke data availiable.
3592 @retval EFI_DEVICE_ERROR The keydtroke information was not returned due
3598 ConSplitterTextInReadKeyStroke (
3599 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*This
,
3600 OUT EFI_INPUT_KEY
*Key
3603 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3605 Private
= TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
3607 Private
->KeyEventSignalState
= FALSE
;
3610 // Signal ConnectConIn event on first call in Lazy ConIn mode
3612 if (!mConInIsConnect
&& PcdGetBool (PcdConInConnectOnDemand
)) {
3613 DEBUG ((EFI_D_INFO
, "Connect ConIn in first ReadKeyStoke in Lazy ConIn mode.\n"));
3614 gBS
->SignalEvent (Private
->ConnectConInEvent
);
3615 mConInIsConnect
= TRUE
;
3618 return ConSplitterTextInPrivateReadKeyStroke (Private
, Key
);
3623 This event aggregates all the events of the ConIn devices in the spliter.
3625 If any events of physical ConIn devices are signaled, signal the ConIn
3626 spliter event. This will cause the calling code to call
3627 ConSplitterTextInReadKeyStroke ().
3629 @param Event The Event assoicated with callback.
3630 @param Context Context registered when Event was created.
3635 ConSplitterTextInWaitForKey (
3641 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3644 Private
= (TEXT_IN_SPLITTER_PRIVATE_DATA
*) Context
;
3646 if (Private
->KeyEventSignalState
) {
3648 // If KeyEventSignalState is flagged before, and not cleared by Reset() or ReadKeyStroke()
3650 gBS
->SignalEvent (Event
);
3655 // If any physical console input device has key input, signal the event.
3657 for (Index
= 0; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
3658 Status
= gBS
->CheckEvent (Private
->TextInList
[Index
]->WaitForKey
);
3659 if (!EFI_ERROR (Status
)) {
3660 gBS
->SignalEvent (Event
);
3661 Private
->KeyEventSignalState
= TRUE
;
3669 Test if the key has been registered on input device.
3671 @param RegsiteredData A pointer to a buffer that is filled in with the
3672 keystroke state data for the key that was
3674 @param InputData A pointer to a buffer that is filled in with the
3675 keystroke state data for the key that was
3678 @retval TRUE Key be pressed matches a registered key.
3679 @retval FLASE Match failed.
3684 IN EFI_KEY_DATA
*RegsiteredData
,
3685 IN EFI_KEY_DATA
*InputData
3688 ASSERT (RegsiteredData
!= NULL
&& InputData
!= NULL
);
3690 if ((RegsiteredData
->Key
.ScanCode
!= InputData
->Key
.ScanCode
) ||
3691 (RegsiteredData
->Key
.UnicodeChar
!= InputData
->Key
.UnicodeChar
)) {
3696 // Assume KeyShiftState/KeyToggleState = 0 in Registered key data means these state could be ignored.
3698 if (RegsiteredData
->KeyState
.KeyShiftState
!= 0 &&
3699 RegsiteredData
->KeyState
.KeyShiftState
!= InputData
->KeyState
.KeyShiftState
) {
3702 if (RegsiteredData
->KeyState
.KeyToggleState
!= 0 &&
3703 RegsiteredData
->KeyState
.KeyToggleState
!= InputData
->KeyState
.KeyToggleState
) {
3713 Reset the input device and optionaly run diagnostics
3715 @param This Protocol instance pointer.
3716 @param ExtendedVerification Driver may perform diagnostics on reset.
3718 @retval EFI_SUCCESS The device was reset.
3719 @retval EFI_DEVICE_ERROR The device is not functioning properly and could
3725 ConSplitterTextInResetEx (
3726 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*This
,
3727 IN BOOLEAN ExtendedVerification
3731 EFI_STATUS ReturnStatus
;
3732 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3735 Private
= TEXT_IN_EX_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
3737 Private
->KeyEventSignalState
= FALSE
;
3740 // return the worst status met
3742 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfExConsoles
; Index
++) {
3743 Status
= Private
->TextInExList
[Index
]->Reset (
3744 Private
->TextInExList
[Index
],
3745 ExtendedVerification
3747 if (EFI_ERROR (Status
)) {
3748 ReturnStatus
= Status
;
3752 if (!EFI_ERROR (ReturnStatus
)) {
3753 ToggleStateSyncReInitialization (Private
);
3755 // Empty the key queue.
3757 Private
->CurrentNumberOfKeys
= 0;
3760 return ReturnStatus
;
3766 Reads the next keystroke from the input device. The WaitForKey Event can
3767 be used to test for existance of a keystroke via WaitForEvent () call.
3769 @param This Protocol instance pointer.
3770 @param KeyData A pointer to a buffer that is filled in with the
3771 keystroke state data for the key that was
3774 @retval EFI_SUCCESS The keystroke information was returned.
3775 @retval EFI_NOT_READY There was no keystroke data availiable.
3776 @retval EFI_DEVICE_ERROR The keystroke information was not returned due
3778 @retval EFI_INVALID_PARAMETER KeyData is NULL.
3783 ConSplitterTextInReadKeyStrokeEx (
3784 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*This
,
3785 OUT EFI_KEY_DATA
*KeyData
3788 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3791 EFI_KEY_STATE KeyState
;
3792 EFI_KEY_DATA CurrentKeyData
;
3795 if (KeyData
== NULL
) {
3796 return EFI_INVALID_PARAMETER
;
3799 Private
= TEXT_IN_EX_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
3801 Private
->KeyEventSignalState
= FALSE
;
3804 // Signal ConnectConIn event on first call in Lazy ConIn mode
3806 if (!mConInIsConnect
&& PcdGetBool (PcdConInConnectOnDemand
)) {
3807 DEBUG ((EFI_D_INFO
, "Connect ConIn in first ReadKeyStoke in Lazy ConIn mode.\n"));
3808 gBS
->SignalEvent (Private
->ConnectConInEvent
);
3809 mConInIsConnect
= TRUE
;
3813 // Return the first saved key.
3815 Status
= ConSplitterTextInExDequeueKey (Private
, KeyData
);
3816 if (!EFI_ERROR (Status
)) {
3819 ASSERT (Private
->CurrentNumberOfKeys
== 0);
3821 ZeroMem (&KeyState
, sizeof (KeyState
));
3824 // Iterate through all physical consoles to get key state.
3825 // Some physical consoles may return valid key.
3826 // Queue the valid keys.
3828 for (Index
= 0; Index
< Private
->CurrentNumberOfExConsoles
; Index
++) {
3829 ZeroMem (&CurrentKeyData
, sizeof (EFI_KEY_DATA
));
3830 Status
= Private
->TextInExList
[Index
]->ReadKeyStrokeEx (
3831 Private
->TextInExList
[Index
],
3834 if (EFI_ERROR (Status
) && (Status
!= EFI_NOT_READY
)) {
3839 // Consolidate the key state from all physical consoles.
3841 if ((CurrentKeyData
.KeyState
.KeyShiftState
& EFI_SHIFT_STATE_VALID
) != 0) {
3842 KeyState
.KeyShiftState
|= CurrentKeyData
.KeyState
.KeyShiftState
;
3844 if ((CurrentKeyData
.KeyState
.KeyToggleState
& EFI_TOGGLE_STATE_VALID
) != 0) {
3845 KeyState
.KeyToggleState
|= CurrentKeyData
.KeyState
.KeyToggleState
;
3848 if (!EFI_ERROR (Status
)) {
3850 // If virtual KeyState has been required to be exposed, or it is not
3851 // partial keystorke, queue the key.
3852 // It's possible that user presses at multiple keyboards at the same moment,
3853 // Private->KeyQueue[] are the storage to save all the keys.
3855 if ((Private
->VirtualKeyStateExported
) ||
3856 (CurrentKeyData
.Key
.ScanCode
!= CHAR_NULL
) ||
3857 (CurrentKeyData
.Key
.UnicodeChar
!= SCAN_NULL
)) {
3859 &Private
->KeyQueue
[Private
->CurrentNumberOfKeys
],
3861 sizeof (EFI_KEY_DATA
)
3863 Private
->CurrentNumberOfKeys
++;
3869 // Consolidate the key state for all keys in Private->KeyQueue[]
3871 for (Index
= 0; Index
< Private
->CurrentNumberOfKeys
; Index
++) {
3872 CopyMem (&Private
->KeyQueue
[Index
].KeyState
, &KeyState
, sizeof (EFI_KEY_STATE
));
3876 // Return the first saved key.
3878 Status
= ConSplitterTextInExDequeueKey (Private
, KeyData
);
3879 if (!EFI_ERROR (Status
)) {
3884 // Always return the key state even there is no key pressed.
3886 ZeroMem (&KeyData
->Key
, sizeof (KeyData
->Key
));
3887 CopyMem (&KeyData
->KeyState
, &KeyState
, sizeof (KeyData
->KeyState
));
3888 return EFI_NOT_READY
;
3893 Set certain state for the input device.
3895 @param This Protocol instance pointer.
3896 @param KeyToggleState A pointer to the EFI_KEY_TOGGLE_STATE to set the
3897 state for the input device.
3899 @retval EFI_SUCCESS The device state was set successfully.
3900 @retval EFI_DEVICE_ERROR The device is not functioning correctly and
3901 could not have the setting adjusted.
3902 @retval EFI_UNSUPPORTED The device does not have the ability to set its
3904 @retval EFI_INVALID_PARAMETER KeyToggleState is NULL.
3909 ConSplitterTextInSetState (
3910 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*This
,
3911 IN EFI_KEY_TOGGLE_STATE
*KeyToggleState
3914 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3917 EFI_KEY_TOGGLE_STATE PhysicalKeyToggleState
;
3919 if (KeyToggleState
== NULL
) {
3920 return EFI_INVALID_PARAMETER
;
3923 Private
= TEXT_IN_EX_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
3926 // Always turn on physical TextInEx partial key report for
3927 // toggle state sync.
3929 PhysicalKeyToggleState
= *KeyToggleState
| EFI_KEY_STATE_EXPOSED
;
3932 // if no physical console input device exists, return EFI_SUCCESS;
3933 // otherwise return the status of setting state of physical console input device
3935 for (Index
= 0; Index
< Private
->CurrentNumberOfExConsoles
; Index
++) {
3936 Status
= Private
->TextInExList
[Index
]->SetState (
3937 Private
->TextInExList
[Index
],
3938 &PhysicalKeyToggleState
3940 if (EFI_ERROR (Status
)) {
3946 // Record the physical KeyToggleState.
3948 Private
->PhysicalKeyToggleState
= PhysicalKeyToggleState
;
3950 // Get if virtual KeyState has been required to be exposed.
3952 Private
->VirtualKeyStateExported
= (((*KeyToggleState
) & EFI_KEY_STATE_EXPOSED
) != 0);
3960 Register a notification function for a particular keystroke for the input device.
3962 @param This Protocol instance pointer.
3963 @param KeyData A pointer to a buffer that is filled in with
3964 the keystroke information for the key that was
3965 pressed. If KeyData.Key, KeyData.KeyState.KeyToggleState
3966 and KeyData.KeyState.KeyShiftState are 0, then any incomplete
3967 keystroke will trigger a notification of the KeyNotificationFunction.
3968 @param KeyNotificationFunction Points to the function to be called when the key
3969 sequence is typed specified by KeyData. This notification function
3970 should be called at <=TPL_CALLBACK.
3971 @param NotifyHandle Points to the unique handle assigned to the
3972 registered notification.
3974 @retval EFI_SUCCESS The notification function was registered
3976 @retval EFI_OUT_OF_RESOURCES Unable to allocate resources for necesssary data
3978 @retval EFI_INVALID_PARAMETER KeyData or KeyNotificationFunction or NotifyHandle is NULL.
3983 ConSplitterTextInRegisterKeyNotify (
3984 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*This
,
3985 IN EFI_KEY_DATA
*KeyData
,
3986 IN EFI_KEY_NOTIFY_FUNCTION KeyNotificationFunction
,
3987 OUT VOID
**NotifyHandle
3990 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3993 TEXT_IN_EX_SPLITTER_NOTIFY
*NewNotify
;
3995 TEXT_IN_EX_SPLITTER_NOTIFY
*CurrentNotify
;
3998 if (KeyData
== NULL
|| NotifyHandle
== NULL
|| KeyNotificationFunction
== NULL
) {
3999 return EFI_INVALID_PARAMETER
;
4002 Private
= TEXT_IN_EX_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4005 // Return EFI_SUCCESS if the (KeyData, NotificationFunction) is already registered.
4007 for (Link
= Private
->NotifyList
.ForwardLink
; Link
!= &Private
->NotifyList
; Link
= Link
->ForwardLink
) {
4008 CurrentNotify
= TEXT_IN_EX_SPLITTER_NOTIFY_FROM_THIS (Link
);
4009 if (IsKeyRegistered (&CurrentNotify
->KeyData
, KeyData
)) {
4010 if (CurrentNotify
->KeyNotificationFn
== KeyNotificationFunction
) {
4011 *NotifyHandle
= CurrentNotify
;
4018 // Allocate resource to save the notification function
4020 NewNotify
= (TEXT_IN_EX_SPLITTER_NOTIFY
*) AllocateZeroPool (sizeof (TEXT_IN_EX_SPLITTER_NOTIFY
));
4021 if (NewNotify
== NULL
) {
4022 return EFI_OUT_OF_RESOURCES
;
4024 NewNotify
->NotifyHandleList
= (EFI_HANDLE
*) AllocateZeroPool (sizeof (EFI_HANDLE
) * Private
->TextInExListCount
);
4025 if (NewNotify
->NotifyHandleList
== NULL
) {
4026 gBS
->FreePool (NewNotify
);
4027 return EFI_OUT_OF_RESOURCES
;
4029 NewNotify
->Signature
= TEXT_IN_EX_SPLITTER_NOTIFY_SIGNATURE
;
4030 NewNotify
->KeyNotificationFn
= KeyNotificationFunction
;
4031 CopyMem (&NewNotify
->KeyData
, KeyData
, sizeof (EFI_KEY_DATA
));
4034 // Return the wrong status of registering key notify of
4035 // physical console input device if meet problems
4037 for (Index
= 0; Index
< Private
->CurrentNumberOfExConsoles
; Index
++) {
4038 Status
= Private
->TextInExList
[Index
]->RegisterKeyNotify (
4039 Private
->TextInExList
[Index
],
4041 KeyNotificationFunction
,
4042 &NewNotify
->NotifyHandleList
[Index
]
4044 if (EFI_ERROR (Status
)) {
4046 // Un-register the key notify on all physical console input devices
4048 while (Index
-- != 0) {
4049 Private
->TextInExList
[Index
]->UnregisterKeyNotify (
4050 Private
->TextInExList
[Index
],
4051 NewNotify
->NotifyHandleList
[Index
]
4054 gBS
->FreePool (NewNotify
->NotifyHandleList
);
4055 gBS
->FreePool (NewNotify
);
4060 InsertTailList (&Private
->NotifyList
, &NewNotify
->NotifyEntry
);
4062 *NotifyHandle
= NewNotify
;
4070 Remove a registered notification function from a particular keystroke.
4072 @param This Protocol instance pointer.
4073 @param NotificationHandle The handle of the notification function being
4076 @retval EFI_SUCCESS The notification function was unregistered
4078 @retval EFI_INVALID_PARAMETER The NotificationHandle is invalid.
4083 ConSplitterTextInUnregisterKeyNotify (
4084 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*This
,
4085 IN VOID
*NotificationHandle
4088 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
4090 TEXT_IN_EX_SPLITTER_NOTIFY
*CurrentNotify
;
4093 if (NotificationHandle
== NULL
) {
4094 return EFI_INVALID_PARAMETER
;
4097 Private
= TEXT_IN_EX_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4099 for (Link
= Private
->NotifyList
.ForwardLink
; Link
!= &Private
->NotifyList
; Link
= Link
->ForwardLink
) {
4100 CurrentNotify
= TEXT_IN_EX_SPLITTER_NOTIFY_FROM_THIS (Link
);
4101 if (CurrentNotify
== NotificationHandle
) {
4102 for (Index
= 0; Index
< Private
->CurrentNumberOfExConsoles
; Index
++) {
4103 Private
->TextInExList
[Index
]->UnregisterKeyNotify (
4104 Private
->TextInExList
[Index
],
4105 CurrentNotify
->NotifyHandleList
[Index
]
4108 RemoveEntryList (&CurrentNotify
->NotifyEntry
);
4110 gBS
->FreePool (CurrentNotify
->NotifyHandleList
);
4111 gBS
->FreePool (CurrentNotify
);
4117 // NotificationHandle is not found in database
4119 return EFI_INVALID_PARAMETER
;
4124 Reset the input device and optionaly run diagnostics
4126 @param This Protocol instance pointer.
4127 @param ExtendedVerification Driver may perform diagnostics on reset.
4129 @retval EFI_SUCCESS The device was reset.
4130 @retval EFI_DEVICE_ERROR The device is not functioning properly and could
4136 ConSplitterSimplePointerReset (
4137 IN EFI_SIMPLE_POINTER_PROTOCOL
*This
,
4138 IN BOOLEAN ExtendedVerification
4142 EFI_STATUS ReturnStatus
;
4143 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
4146 Private
= TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_SIMPLE_POINTER_THIS (This
);
4148 Private
->InputEventSignalState
= FALSE
;
4150 if (Private
->CurrentNumberOfPointers
== 0) {
4154 // return the worst status met
4156 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfPointers
; Index
++) {
4157 Status
= Private
->PointerList
[Index
]->Reset (
4158 Private
->PointerList
[Index
],
4159 ExtendedVerification
4161 if (EFI_ERROR (Status
)) {
4162 ReturnStatus
= Status
;
4166 return ReturnStatus
;
4171 Reads the next keystroke from the input device. The WaitForKey Event can
4172 be used to test for existance of a keystroke via WaitForEvent () call.
4174 @param Private Protocol instance pointer.
4175 @param State The state information of simple pointer device.
4177 @retval EFI_SUCCESS The keystroke information was returned.
4178 @retval EFI_NOT_READY There was no keystroke data availiable.
4179 @retval EFI_DEVICE_ERROR The keydtroke information was not returned due
4185 ConSplitterSimplePointerPrivateGetState (
4186 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
4187 IN OUT EFI_SIMPLE_POINTER_STATE
*State
4191 EFI_STATUS ReturnStatus
;
4193 EFI_SIMPLE_POINTER_STATE CurrentState
;
4195 State
->RelativeMovementX
= 0;
4196 State
->RelativeMovementY
= 0;
4197 State
->RelativeMovementZ
= 0;
4198 State
->LeftButton
= FALSE
;
4199 State
->RightButton
= FALSE
;
4202 // if no physical console input device exists, return EFI_NOT_READY;
4203 // if any physical console input device has key input,
4204 // return the key and EFI_SUCCESS.
4206 ReturnStatus
= EFI_NOT_READY
;
4207 for (Index
= 0; Index
< Private
->CurrentNumberOfPointers
; Index
++) {
4209 Status
= Private
->PointerList
[Index
]->GetState (
4210 Private
->PointerList
[Index
],
4213 if (!EFI_ERROR (Status
)) {
4214 if (ReturnStatus
== EFI_NOT_READY
) {
4215 ReturnStatus
= EFI_SUCCESS
;
4218 if (CurrentState
.LeftButton
) {
4219 State
->LeftButton
= TRUE
;
4222 if (CurrentState
.RightButton
) {
4223 State
->RightButton
= TRUE
;
4226 if (CurrentState
.RelativeMovementX
!= 0 && Private
->PointerList
[Index
]->Mode
->ResolutionX
!= 0) {
4227 State
->RelativeMovementX
+= (CurrentState
.RelativeMovementX
* (INT32
) Private
->SimplePointerMode
.ResolutionX
) / (INT32
) Private
->PointerList
[Index
]->Mode
->ResolutionX
;
4230 if (CurrentState
.RelativeMovementY
!= 0 && Private
->PointerList
[Index
]->Mode
->ResolutionY
!= 0) {
4231 State
->RelativeMovementY
+= (CurrentState
.RelativeMovementY
* (INT32
) Private
->SimplePointerMode
.ResolutionY
) / (INT32
) Private
->PointerList
[Index
]->Mode
->ResolutionY
;
4234 if (CurrentState
.RelativeMovementZ
!= 0 && Private
->PointerList
[Index
]->Mode
->ResolutionZ
!= 0) {
4235 State
->RelativeMovementZ
+= (CurrentState
.RelativeMovementZ
* (INT32
) Private
->SimplePointerMode
.ResolutionZ
) / (INT32
) Private
->PointerList
[Index
]->Mode
->ResolutionZ
;
4237 } else if (Status
== EFI_DEVICE_ERROR
) {
4238 ReturnStatus
= EFI_DEVICE_ERROR
;
4242 return ReturnStatus
;
4247 Reads the next keystroke from the input device. The WaitForKey Event can
4248 be used to test for existance of a keystroke via WaitForEvent () call.
4250 @param This A pointer to protocol instance.
4251 @param State A pointer to state information on the pointer device
4253 @retval EFI_SUCCESS The keystroke information was returned in State.
4254 @retval EFI_NOT_READY There was no keystroke data availiable.
4255 @retval EFI_DEVICE_ERROR The keydtroke information was not returned due
4261 ConSplitterSimplePointerGetState (
4262 IN EFI_SIMPLE_POINTER_PROTOCOL
*This
,
4263 IN OUT EFI_SIMPLE_POINTER_STATE
*State
4266 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
4268 Private
= TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_SIMPLE_POINTER_THIS (This
);
4270 Private
->InputEventSignalState
= FALSE
;
4272 return ConSplitterSimplePointerPrivateGetState (Private
, State
);
4277 This event agregates all the events of the ConIn devices in the spliter.
4278 If any events of physical ConIn devices are signaled, signal the ConIn
4279 spliter event. This will cause the calling code to call
4280 ConSplitterTextInReadKeyStroke ().
4282 @param Event The Event assoicated with callback.
4283 @param Context Context registered when Event was created.
4288 ConSplitterSimplePointerWaitForInput (
4294 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
4297 Private
= (TEXT_IN_SPLITTER_PRIVATE_DATA
*) Context
;
4300 // if InputEventSignalState is flagged before, and not cleared by Reset() or ReadKeyStroke()
4302 if (Private
->InputEventSignalState
) {
4303 gBS
->SignalEvent (Event
);
4307 // if any physical console input device has key input, signal the event.
4309 for (Index
= 0; Index
< Private
->CurrentNumberOfPointers
; Index
++) {
4310 Status
= gBS
->CheckEvent (Private
->PointerList
[Index
]->WaitForInput
);
4311 if (!EFI_ERROR (Status
)) {
4312 gBS
->SignalEvent (Event
);
4313 Private
->InputEventSignalState
= TRUE
;
4319 Resets the pointer device hardware.
4321 @param This Protocol instance pointer.
4322 @param ExtendedVerification Driver may perform diagnostics on reset.
4324 @retval EFI_SUCCESS The device was reset.
4325 @retval EFI_DEVICE_ERROR The device is not functioning correctly and
4331 ConSplitterAbsolutePointerReset (
4332 IN EFI_ABSOLUTE_POINTER_PROTOCOL
*This
,
4333 IN BOOLEAN ExtendedVerification
4337 EFI_STATUS ReturnStatus
;
4338 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
4341 Private
= TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_ABSOLUTE_POINTER_THIS (This
);
4343 Private
->AbsoluteInputEventSignalState
= FALSE
;
4345 if (Private
->CurrentNumberOfAbsolutePointers
== 0) {
4349 // return the worst status met
4351 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfAbsolutePointers
; Index
++) {
4352 Status
= Private
->AbsolutePointerList
[Index
]->Reset (
4353 Private
->AbsolutePointerList
[Index
],
4354 ExtendedVerification
4356 if (EFI_ERROR (Status
)) {
4357 ReturnStatus
= Status
;
4361 return ReturnStatus
;
4366 Retrieves the current state of a pointer device.
4368 @param This Protocol instance pointer.
4369 @param State A pointer to the state information on the
4372 @retval EFI_SUCCESS The state of the pointer device was returned in
4374 @retval EFI_NOT_READY The state of the pointer device has not changed
4375 since the last call to GetState().
4376 @retval EFI_DEVICE_ERROR A device error occurred while attempting to
4377 retrieve the pointer device's current state.
4382 ConSplitterAbsolutePointerGetState (
4383 IN EFI_ABSOLUTE_POINTER_PROTOCOL
*This
,
4384 IN OUT EFI_ABSOLUTE_POINTER_STATE
*State
4387 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
4389 EFI_STATUS ReturnStatus
;
4391 EFI_ABSOLUTE_POINTER_STATE CurrentState
;
4405 Private
= TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_ABSOLUTE_POINTER_THIS (This
);
4407 Private
->AbsoluteInputEventSignalState
= FALSE
;
4409 State
->CurrentX
= 0;
4410 State
->CurrentY
= 0;
4411 State
->CurrentZ
= 0;
4412 State
->ActiveButtons
= 0;
4414 VirtualMinX
= Private
->AbsolutePointerMode
.AbsoluteMinX
;
4415 VirtualMinY
= Private
->AbsolutePointerMode
.AbsoluteMinY
;
4416 VirtualMinZ
= Private
->AbsolutePointerMode
.AbsoluteMinZ
;
4417 VirtualMaxX
= Private
->AbsolutePointerMode
.AbsoluteMaxX
;
4418 VirtualMaxY
= Private
->AbsolutePointerMode
.AbsoluteMaxY
;
4419 VirtualMaxZ
= Private
->AbsolutePointerMode
.AbsoluteMaxZ
;
4422 // if no physical pointer device exists, return EFI_NOT_READY;
4423 // if any physical pointer device has changed state,
4424 // return the state and EFI_SUCCESS.
4426 ReturnStatus
= EFI_NOT_READY
;
4427 for (Index
= 0; Index
< Private
->CurrentNumberOfAbsolutePointers
; Index
++) {
4429 Status
= Private
->AbsolutePointerList
[Index
]->GetState (
4430 Private
->AbsolutePointerList
[Index
],
4433 if (!EFI_ERROR (Status
)) {
4434 if (ReturnStatus
== EFI_NOT_READY
) {
4435 ReturnStatus
= EFI_SUCCESS
;
4438 MinX
= Private
->AbsolutePointerList
[Index
]->Mode
->AbsoluteMinX
;
4439 MinY
= Private
->AbsolutePointerList
[Index
]->Mode
->AbsoluteMinY
;
4440 MinZ
= Private
->AbsolutePointerList
[Index
]->Mode
->AbsoluteMinZ
;
4441 MaxX
= Private
->AbsolutePointerList
[Index
]->Mode
->AbsoluteMaxX
;
4442 MaxY
= Private
->AbsolutePointerList
[Index
]->Mode
->AbsoluteMaxY
;
4443 MaxZ
= Private
->AbsolutePointerList
[Index
]->Mode
->AbsoluteMaxZ
;
4445 State
->ActiveButtons
= CurrentState
.ActiveButtons
;
4448 // Rescale to Con Splitter virtual Absolute Pointer's resolution.
4450 if (!(MinX
== 0 && MaxX
== 0)) {
4451 State
->CurrentX
= VirtualMinX
+ DivU64x64Remainder (
4453 CurrentState
.CurrentX
,
4454 VirtualMaxX
- VirtualMinX
4460 if (!(MinY
== 0 && MaxY
== 0)) {
4461 State
->CurrentY
= VirtualMinY
+ DivU64x64Remainder (
4463 CurrentState
.CurrentY
,
4464 VirtualMaxY
- VirtualMinY
4470 if (!(MinZ
== 0 && MaxZ
== 0)) {
4471 State
->CurrentZ
= VirtualMinZ
+ DivU64x64Remainder (
4473 CurrentState
.CurrentZ
,
4474 VirtualMaxZ
- VirtualMinZ
4481 } else if (Status
== EFI_DEVICE_ERROR
) {
4482 ReturnStatus
= EFI_DEVICE_ERROR
;
4486 return ReturnStatus
;
4491 This event agregates all the events of the pointer devices in the splitter.
4492 If any events of physical pointer devices are signaled, signal the pointer
4493 splitter event. This will cause the calling code to call
4494 ConSplitterAbsolutePointerGetState ().
4496 @param Event The Event assoicated with callback.
4497 @param Context Context registered when Event was created.
4502 ConSplitterAbsolutePointerWaitForInput (
4508 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
4511 Private
= (TEXT_IN_SPLITTER_PRIVATE_DATA
*) Context
;
4514 // if AbsoluteInputEventSignalState is flagged before,
4515 // and not cleared by Reset() or GetState(), signal it
4517 if (Private
->AbsoluteInputEventSignalState
) {
4518 gBS
->SignalEvent (Event
);
4522 // if any physical console input device has key input, signal the event.
4524 for (Index
= 0; Index
< Private
->CurrentNumberOfAbsolutePointers
; Index
++) {
4525 Status
= gBS
->CheckEvent (Private
->AbsolutePointerList
[Index
]->WaitForInput
);
4526 if (!EFI_ERROR (Status
)) {
4527 gBS
->SignalEvent (Event
);
4528 Private
->AbsoluteInputEventSignalState
= TRUE
;
4535 Reset the text output device hardware and optionaly run diagnostics
4537 @param This Protocol instance pointer.
4538 @param ExtendedVerification Driver may perform more exhaustive verfication
4539 operation of the device during reset.
4541 @retval EFI_SUCCESS The text output device was reset.
4542 @retval EFI_DEVICE_ERROR The text output device is not functioning
4543 correctly and could not be reset.
4548 ConSplitterTextOutReset (
4549 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4550 IN BOOLEAN ExtendedVerification
4554 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4556 EFI_STATUS ReturnStatus
;
4558 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4561 // return the worst status met
4563 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
4564 Status
= Private
->TextOutList
[Index
].TextOut
->Reset (
4565 Private
->TextOutList
[Index
].TextOut
,
4566 ExtendedVerification
4568 if (EFI_ERROR (Status
)) {
4569 ReturnStatus
= Status
;
4573 This
->SetAttribute (This
, EFI_TEXT_ATTR (This
->Mode
->Attribute
& 0x0F, EFI_BLACK
));
4576 // reset all mode parameters
4578 TextOutSetMode (Private
, 0);
4580 return ReturnStatus
;
4585 Write a Unicode string to the output device.
4587 @param This Protocol instance pointer.
4588 @param WString The NULL-terminated Unicode string to be
4589 displayed on the output device(s). All output
4590 devices must also support the Unicode drawing
4591 defined in this file.
4593 @retval EFI_SUCCESS The string was output to the device.
4594 @retval EFI_DEVICE_ERROR The device reported an error while attempting to
4596 @retval EFI_UNSUPPORTED The output device's mode is not currently in a
4598 @retval EFI_WARN_UNKNOWN_GLYPH This warning code indicates that some of the
4599 characters in the Unicode string could not be
4600 rendered and were skipped.
4605 ConSplitterTextOutOutputString (
4606 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4611 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4613 EFI_STATUS ReturnStatus
;
4617 This
->SetAttribute (This
, This
->Mode
->Attribute
);
4619 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4622 // return the worst status met
4624 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
4625 Status
= Private
->TextOutList
[Index
].TextOut
->OutputString (
4626 Private
->TextOutList
[Index
].TextOut
,
4629 if (EFI_ERROR (Status
)) {
4630 ReturnStatus
= Status
;
4634 if (Private
->CurrentNumberOfConsoles
> 0) {
4635 Private
->TextOutMode
.CursorColumn
= Private
->TextOutList
[0].TextOut
->Mode
->CursorColumn
;
4636 Private
->TextOutMode
.CursorRow
= Private
->TextOutList
[0].TextOut
->Mode
->CursorRow
;
4639 // When there is no real console devices in system,
4640 // update cursor position for the virtual device in consplitter.
4642 Private
->TextOut
.QueryMode (
4644 Private
->TextOutMode
.Mode
,
4648 for (; *WString
!= CHAR_NULL
; WString
++) {
4650 case CHAR_BACKSPACE
:
4651 if (Private
->TextOutMode
.CursorColumn
== 0 && Private
->TextOutMode
.CursorRow
> 0) {
4652 Private
->TextOutMode
.CursorRow
--;
4653 Private
->TextOutMode
.CursorColumn
= (INT32
) (MaxColumn
- 1);
4654 } else if (Private
->TextOutMode
.CursorColumn
> 0) {
4655 Private
->TextOutMode
.CursorColumn
--;
4660 if (Private
->TextOutMode
.CursorRow
< (INT32
) (MaxRow
- 1)) {
4661 Private
->TextOutMode
.CursorRow
++;
4665 case CHAR_CARRIAGE_RETURN
:
4666 Private
->TextOutMode
.CursorColumn
= 0;
4670 if (Private
->TextOutMode
.CursorColumn
< (INT32
) (MaxColumn
- 1)) {
4671 Private
->TextOutMode
.CursorColumn
++;
4673 Private
->TextOutMode
.CursorColumn
= 0;
4674 if (Private
->TextOutMode
.CursorRow
< (INT32
) (MaxRow
- 1)) {
4675 Private
->TextOutMode
.CursorRow
++;
4683 return ReturnStatus
;
4688 Verifies that all characters in a Unicode string can be output to the
4691 @param This Protocol instance pointer.
4692 @param WString The NULL-terminated Unicode string to be
4693 examined for the output device(s).
4695 @retval EFI_SUCCESS The device(s) are capable of rendering the
4697 @retval EFI_UNSUPPORTED Some of the characters in the Unicode string
4698 cannot be rendered by one or more of the output
4699 devices mapped by the EFI handle.
4704 ConSplitterTextOutTestString (
4705 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4710 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4712 EFI_STATUS ReturnStatus
;
4714 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4717 // return the worst status met
4719 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
4720 Status
= Private
->TextOutList
[Index
].TextOut
->TestString (
4721 Private
->TextOutList
[Index
].TextOut
,
4724 if (EFI_ERROR (Status
)) {
4725 ReturnStatus
= Status
;
4729 // There is no DevNullTextOutTestString () since a Unicode buffer would
4730 // always return EFI_SUCCESS.
4731 // ReturnStatus will be EFI_SUCCESS if no consoles are present
4733 return ReturnStatus
;
4738 Returns information for an available text mode that the output device(s)
4741 @param This Protocol instance pointer.
4742 @param ModeNumber The mode number to return information on.
4743 @param Columns Returns the columns of the text output device
4744 for the requested ModeNumber.
4745 @param Rows Returns the rows of the text output device
4746 for the requested ModeNumber.
4748 @retval EFI_SUCCESS The requested mode information was returned.
4749 @retval EFI_DEVICE_ERROR The device had an error and could not complete
4751 @retval EFI_UNSUPPORTED The mode number was not valid.
4756 ConSplitterTextOutQueryMode (
4757 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4758 IN UINTN ModeNumber
,
4763 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4765 INT32
*TextOutModeMap
;
4767 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4770 // Check whether param ModeNumber is valid.
4771 // ModeNumber should be within range 0 ~ MaxMode - 1.
4773 if ( (ModeNumber
> (UINTN
)(((UINT32
)-1)>>1)) ) {
4774 return EFI_UNSUPPORTED
;
4777 if ((INT32
) ModeNumber
>= This
->Mode
->MaxMode
) {
4778 return EFI_UNSUPPORTED
;
4782 // We get the available mode from mode intersection map if it's available
4784 if (Private
->TextOutModeMap
!= NULL
) {
4785 TextOutModeMap
= Private
->TextOutModeMap
+ Private
->TextOutListCount
* ModeNumber
;
4786 CurrentMode
= (UINTN
)(*TextOutModeMap
);
4787 *Columns
= Private
->TextOutQueryData
[CurrentMode
].Columns
;
4788 *Rows
= Private
->TextOutQueryData
[CurrentMode
].Rows
;
4790 *Columns
= Private
->TextOutQueryData
[ModeNumber
].Columns
;
4791 *Rows
= Private
->TextOutQueryData
[ModeNumber
].Rows
;
4794 if (*Columns
<= 0 && *Rows
<= 0) {
4795 return EFI_UNSUPPORTED
;
4804 Sets the output device(s) to a specified mode.
4806 @param This Protocol instance pointer.
4807 @param ModeNumber The mode number to set.
4809 @retval EFI_SUCCESS The requested text mode was set.
4810 @retval EFI_DEVICE_ERROR The device had an error and could not complete
4812 @retval EFI_UNSUPPORTED The mode number was not valid.
4817 ConSplitterTextOutSetMode (
4818 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4823 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4825 INT32
*TextOutModeMap
;
4826 EFI_STATUS ReturnStatus
;
4828 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4831 // Check whether param ModeNumber is valid.
4832 // ModeNumber should be within range 0 ~ MaxMode - 1.
4834 if ( (ModeNumber
> (UINTN
)(((UINT32
)-1)>>1)) ) {
4835 return EFI_UNSUPPORTED
;
4838 if ((INT32
) ModeNumber
>= This
->Mode
->MaxMode
) {
4839 return EFI_UNSUPPORTED
;
4842 // If the mode is being set to the curent mode, then just clear the screen and return.
4844 if (Private
->TextOutMode
.Mode
== (INT32
) ModeNumber
) {
4845 return ConSplitterTextOutClearScreen (This
);
4848 // return the worst status met
4850 TextOutModeMap
= Private
->TextOutModeMap
+ Private
->TextOutListCount
* ModeNumber
;
4851 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
4852 Status
= Private
->TextOutList
[Index
].TextOut
->SetMode (
4853 Private
->TextOutList
[Index
].TextOut
,
4854 TextOutModeMap
[Index
]
4856 if (EFI_ERROR (Status
)) {
4857 ReturnStatus
= Status
;
4862 // Set mode parameter to specified mode number
4864 TextOutSetMode (Private
, ModeNumber
);
4866 return ReturnStatus
;
4871 Sets the background and foreground colors for the OutputString () and
4872 ClearScreen () functions.
4874 @param This Protocol instance pointer.
4875 @param Attribute The attribute to set. Bits 0..3 are the
4876 foreground color, and bits 4..6 are the
4877 background color. All other bits are undefined
4878 and must be zero. The valid Attributes are
4879 defined in this file.
4881 @retval EFI_SUCCESS The attribute was set.
4882 @retval EFI_DEVICE_ERROR The device had an error and could not complete
4884 @retval EFI_UNSUPPORTED The attribute requested is not defined.
4889 ConSplitterTextOutSetAttribute (
4890 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4895 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4897 EFI_STATUS ReturnStatus
;
4899 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4902 // Check whether param Attribute is valid.
4904 if ((Attribute
| 0x7F) != 0x7F) {
4905 return EFI_UNSUPPORTED
;
4909 // return the worst status met
4911 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
4912 Status
= Private
->TextOutList
[Index
].TextOut
->SetAttribute (
4913 Private
->TextOutList
[Index
].TextOut
,
4916 if (EFI_ERROR (Status
)) {
4917 ReturnStatus
= Status
;
4921 Private
->TextOutMode
.Attribute
= (INT32
) Attribute
;
4923 return ReturnStatus
;
4928 Clears the output device(s) display to the currently selected background
4931 @param This Protocol instance pointer.
4933 @retval EFI_SUCCESS The operation completed successfully.
4934 @retval EFI_DEVICE_ERROR The device had an error and could not complete
4936 @retval EFI_UNSUPPORTED The output device is not in a valid text mode.
4941 ConSplitterTextOutClearScreen (
4942 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
4946 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4948 EFI_STATUS ReturnStatus
;
4950 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4953 // return the worst status met
4955 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
4956 Status
= Private
->TextOutList
[Index
].TextOut
->ClearScreen (Private
->TextOutList
[Index
].TextOut
);
4957 if (EFI_ERROR (Status
)) {
4958 ReturnStatus
= Status
;
4963 // No need to do extra check here as whether (Column, Row) is valid has
4964 // been checked in ConSplitterTextOutSetCursorPosition. And (0, 0) should
4965 // always be supported.
4967 Private
->TextOutMode
.CursorColumn
= 0;
4968 Private
->TextOutMode
.CursorRow
= 0;
4969 Private
->TextOutMode
.CursorVisible
= TRUE
;
4971 return ReturnStatus
;
4976 Sets the current coordinates of the cursor position
4978 @param This Protocol instance pointer.
4979 @param Column The column position to set the cursor to. Must be
4980 greater than or equal to zero and less than the
4981 number of columns by QueryMode ().
4982 @param Row The row position to set the cursor to. Must be
4983 greater than or equal to zero and less than the
4984 number of rows by QueryMode ().
4986 @retval EFI_SUCCESS The operation completed successfully.
4987 @retval EFI_DEVICE_ERROR The device had an error and could not complete
4989 @retval EFI_UNSUPPORTED The output device is not in a valid text mode,
4990 or the cursor position is invalid for the
4996 ConSplitterTextOutSetCursorPosition (
4997 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
5003 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
5005 EFI_STATUS ReturnStatus
;
5008 INT32
*TextOutModeMap
;
5012 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
5013 TextOutModeMap
= NULL
;
5014 ModeNumber
= Private
->TextOutMode
.Mode
;
5017 // Get current MaxColumn and MaxRow from intersection map
5019 if (Private
->TextOutModeMap
!= NULL
) {
5020 TextOutModeMap
= Private
->TextOutModeMap
+ Private
->TextOutListCount
* ModeNumber
;
5021 CurrentMode
= *TextOutModeMap
;
5023 CurrentMode
= ModeNumber
;
5026 MaxColumn
= Private
->TextOutQueryData
[CurrentMode
].Columns
;
5027 MaxRow
= Private
->TextOutQueryData
[CurrentMode
].Rows
;
5029 if (Column
>= MaxColumn
|| Row
>= MaxRow
) {
5030 return EFI_UNSUPPORTED
;
5033 // return the worst status met
5035 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
5036 Status
= Private
->TextOutList
[Index
].TextOut
->SetCursorPosition (
5037 Private
->TextOutList
[Index
].TextOut
,
5041 if (EFI_ERROR (Status
)) {
5042 ReturnStatus
= Status
;
5047 // No need to do extra check here as whether (Column, Row) is valid has
5048 // been checked in ConSplitterTextOutSetCursorPosition. And (0, 0) should
5049 // always be supported.
5051 Private
->TextOutMode
.CursorColumn
= (INT32
) Column
;
5052 Private
->TextOutMode
.CursorRow
= (INT32
) Row
;
5054 return ReturnStatus
;
5059 Makes the cursor visible or invisible
5061 @param This Protocol instance pointer.
5062 @param Visible If TRUE, the cursor is set to be visible. If
5063 FALSE, the cursor is set to be invisible.
5065 @retval EFI_SUCCESS The operation completed successfully.
5066 @retval EFI_DEVICE_ERROR The device had an error and could not complete
5067 the request, or the device does not support
5068 changing the cursor mode.
5069 @retval EFI_UNSUPPORTED The output device is not in a valid text mode.
5074 ConSplitterTextOutEnableCursor (
5075 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
5080 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
5082 EFI_STATUS ReturnStatus
;
5084 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
5087 // return the worst status met
5089 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
5090 Status
= Private
->TextOutList
[Index
].TextOut
->EnableCursor (
5091 Private
->TextOutList
[Index
].TextOut
,
5094 if (EFI_ERROR (Status
)) {
5095 ReturnStatus
= Status
;
5099 Private
->TextOutMode
.CursorVisible
= Visible
;
5101 return ReturnStatus
;