2 Console Splitter Driver. Any Handle that attached 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 system function well during none console
19 Copyright (c) 2006 - 2019, 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
,
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
,
111 // Uga Draw Protocol Private Data template
113 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UGA_DRAW_PROTOCOL mUgaDrawProtocolTemplate
= {
114 ConSplitterUgaDrawGetMode
,
115 ConSplitterUgaDrawSetMode
,
116 ConSplitterUgaDrawBlt
120 // Graphics Output Protocol Private Data template
122 GLOBAL_REMOVE_IF_UNREFERENCED EFI_GRAPHICS_OUTPUT_PROTOCOL mGraphicsOutputProtocolTemplate
= {
123 ConSplitterGraphicsOutputQueryMode
,
124 ConSplitterGraphicsOutputSetMode
,
125 ConSplitterGraphicsOutputBlt
,
130 // Text Out Splitter Private Data template
132 GLOBAL_REMOVE_IF_UNREFERENCED TEXT_OUT_SPLITTER_PRIVATE_DATA mConOut
= {
133 TEXT_OUT_SPLITTER_PRIVATE_DATA_SIGNATURE
,
136 ConSplitterTextOutReset
,
137 ConSplitterTextOutOutputString
,
138 ConSplitterTextOutTestString
,
139 ConSplitterTextOutQueryMode
,
140 ConSplitterTextOutSetMode
,
141 ConSplitterTextOutSetAttribute
,
142 ConSplitterTextOutClearScreen
,
143 ConSplitterTextOutSetCursorPosition
,
144 ConSplitterTextOutEnableCursor
,
145 (EFI_SIMPLE_TEXT_OUTPUT_MODE
*)NULL
172 (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*)NULL
,
177 (TEXT_OUT_AND_GOP_DATA
*)NULL
,
179 (TEXT_OUT_SPLITTER_QUERY_DATA
*)NULL
,
186 // Standard Error Text Out Splitter Data Template
188 GLOBAL_REMOVE_IF_UNREFERENCED TEXT_OUT_SPLITTER_PRIVATE_DATA mStdErr
= {
189 TEXT_OUT_SPLITTER_PRIVATE_DATA_SIGNATURE
,
192 ConSplitterTextOutReset
,
193 ConSplitterTextOutOutputString
,
194 ConSplitterTextOutTestString
,
195 ConSplitterTextOutQueryMode
,
196 ConSplitterTextOutSetMode
,
197 ConSplitterTextOutSetAttribute
,
198 ConSplitterTextOutClearScreen
,
199 ConSplitterTextOutSetCursorPosition
,
200 ConSplitterTextOutEnableCursor
,
201 (EFI_SIMPLE_TEXT_OUTPUT_MODE
*)NULL
228 (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*)NULL
,
233 (TEXT_OUT_AND_GOP_DATA
*)NULL
,
235 (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
))
323 // There is toggle state change, sync to other console input devices.
325 for (Index
= 0; Index
< mConIn
.CurrentNumberOfExConsoles
; Index
++) {
326 mConIn
.TextInExList
[Index
]->SetState (
327 mConIn
.TextInExList
[Index
],
328 &KeyData
->KeyState
.KeyToggleState
332 mConIn
.PhysicalKeyToggleState
= KeyData
->KeyState
.KeyToggleState
;
333 DEBUG ((DEBUG_INFO
, "Current toggle state is 0x%02x\n", mConIn
.PhysicalKeyToggleState
));
340 Initialization for toggle state sync.
342 @param Private Text In Splitter pointer.
346 ToggleStateSyncInitialization (
347 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
350 EFI_KEY_DATA KeyData
;
354 // Initialize PhysicalKeyToggleState that will be synced to new console
355 // input device to turn on physical TextInEx partial key report for
356 // toggle state sync.
358 Private
->PhysicalKeyToggleState
= KEY_STATE_VALID_EXPOSED
;
361 // Initialize VirtualKeyStateExported to let the virtual TextInEx not report
362 // the partial key even though the physical TextInEx turns on the partial
363 // key report. The virtual TextInEx will report the partial key after it is
364 // required by calling SetState(X | KEY_STATE_VALID_EXPOSED) explicitly.
366 Private
->VirtualKeyStateExported
= FALSE
;
369 // Register key notify for toggle state sync.
371 KeyData
.Key
.ScanCode
= SCAN_NULL
;
372 KeyData
.Key
.UnicodeChar
= CHAR_NULL
;
373 KeyData
.KeyState
.KeyShiftState
= 0;
374 KeyData
.KeyState
.KeyToggleState
= 0;
375 Private
->TextInEx
.RegisterKeyNotify (
378 ToggleStateSyncKeyNotify
,
384 Re-initialization for toggle state sync.
386 @param Private Text In Splitter pointer.
390 ToggleStateSyncReInitialization (
391 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
397 // Reinitialize PhysicalKeyToggleState that will be synced to new console
398 // input device to turn on physical TextInEx partial key report for
399 // toggle state sync.
401 Private
->PhysicalKeyToggleState
= KEY_STATE_VALID_EXPOSED
;
404 // Reinitialize VirtualKeyStateExported to let the virtual TextInEx not report
405 // the partial key even though the physical TextInEx turns on the partial
406 // key report. The virtual TextInEx will report the partial key after it is
407 // required by calling SetState(X | KEY_STATE_VALID_EXPOSED) explicitly.
409 Private
->VirtualKeyStateExported
= FALSE
;
411 for (Index
= 0; Index
< Private
->CurrentNumberOfExConsoles
; Index
++) {
412 Private
->TextInExList
[Index
]->SetState (
413 Private
->TextInExList
[Index
],
414 &Private
->PhysicalKeyToggleState
420 The Entry Point for module ConSplitter. The user code starts with this function.
422 Installs driver module protocols and. Creates virtual device handles for ConIn,
423 ConOut, and StdErr. Installs Simple Text In protocol, Simple Text In Ex protocol,
424 Simple Pointer protocol, Absolute Pointer protocol on those virtual handlers.
425 Installs Graphics Output protocol and/or UGA Draw protocol if needed.
427 @param[in] ImageHandle The firmware allocated handle for the EFI image.
428 @param[in] SystemTable A pointer to the EFI System Table.
430 @retval EFI_SUCCESS The entry point is executed successfully.
431 @retval other Some error occurs when executing this entry point.
436 ConSplitterDriverEntry (
437 IN EFI_HANDLE ImageHandle
,
438 IN EFI_SYSTEM_TABLE
*SystemTable
444 // Install driver model protocol(s).
446 Status
= EfiLibInstallDriverBindingComponentName2 (
449 &gConSplitterConInDriverBinding
,
451 &gConSplitterConInComponentName
,
452 &gConSplitterConInComponentName2
454 ASSERT_EFI_ERROR (Status
);
456 Status
= EfiLibInstallDriverBindingComponentName2 (
459 &gConSplitterSimplePointerDriverBinding
,
461 &gConSplitterSimplePointerComponentName
,
462 &gConSplitterSimplePointerComponentName2
464 ASSERT_EFI_ERROR (Status
);
466 Status
= EfiLibInstallDriverBindingComponentName2 (
469 &gConSplitterAbsolutePointerDriverBinding
,
471 &gConSplitterAbsolutePointerComponentName
,
472 &gConSplitterAbsolutePointerComponentName2
474 ASSERT_EFI_ERROR (Status
);
476 Status
= EfiLibInstallDriverBindingComponentName2 (
479 &gConSplitterConOutDriverBinding
,
481 &gConSplitterConOutComponentName
,
482 &gConSplitterConOutComponentName2
484 ASSERT_EFI_ERROR (Status
);
486 Status
= EfiLibInstallDriverBindingComponentName2 (
489 &gConSplitterStdErrDriverBinding
,
491 &gConSplitterStdErrComponentName
,
492 &gConSplitterStdErrComponentName2
494 ASSERT_EFI_ERROR (Status
);
497 // Either Graphics Output protocol or UGA Draw protocol must be supported.
500 FeaturePcdGet (PcdConOutGopSupport
) ||
501 FeaturePcdGet (PcdConOutUgaSupport
)
505 // The driver creates virtual handles for ConIn, ConOut, StdErr.
506 // The virtual handles will always exist even if no console exist in the
507 // system. This is need to support hotplug devices like USB.
510 // Create virtual device handle for ConIn Splitter
512 Status
= ConSplitterTextInConstructor (&mConIn
);
513 if (!EFI_ERROR (Status
)) {
514 Status
= gBS
->InstallMultipleProtocolInterfaces (
515 &mConIn
.VirtualHandle
,
516 &gEfiSimpleTextInProtocolGuid
,
518 &gEfiSimpleTextInputExProtocolGuid
,
520 &gEfiSimplePointerProtocolGuid
,
521 &mConIn
.SimplePointer
,
522 &gEfiAbsolutePointerProtocolGuid
,
523 &mConIn
.AbsolutePointer
,
526 if (!EFI_ERROR (Status
)) {
528 // Update the EFI System Table with new virtual console
529 // and update the pointer to Simple Text Input protocol.
531 gST
->ConsoleInHandle
= mConIn
.VirtualHandle
;
532 gST
->ConIn
= &mConIn
.TextIn
;
537 // Create virtual device handle for ConOut Splitter
539 Status
= ConSplitterTextOutConstructor (&mConOut
);
540 if (!EFI_ERROR (Status
)) {
541 Status
= gBS
->InstallMultipleProtocolInterfaces (
542 &mConOut
.VirtualHandle
,
543 &gEfiSimpleTextOutProtocolGuid
,
547 if (!EFI_ERROR (Status
)) {
549 // Update the EFI System Table with new virtual console
550 // and Update the pointer to Text Output protocol.
552 gST
->ConsoleOutHandle
= mConOut
.VirtualHandle
;
553 gST
->ConOut
= &mConOut
.TextOut
;
558 // Create virtual device handle for StdErr Splitter
560 Status
= ConSplitterTextOutConstructor (&mStdErr
);
561 if (!EFI_ERROR (Status
)) {
562 Status
= gBS
->InstallMultipleProtocolInterfaces (
563 &mStdErr
.VirtualHandle
,
564 &gEfiSimpleTextOutProtocolGuid
,
568 if (!EFI_ERROR (Status
)) {
570 // Update the EFI System Table with new virtual console
571 // and update the pointer to Text Output protocol.
573 gST
->StandardErrorHandle
= mStdErr
.VirtualHandle
;
574 gST
->StdErr
= &mStdErr
.TextOut
;
579 // Update the CRC32 in the EFI System Table header
582 gBS
->CalculateCrc32 (
592 Construct console input devices' private data.
594 @param ConInPrivate A pointer to the TEXT_IN_SPLITTER_PRIVATE_DATA
597 @retval EFI_OUT_OF_RESOURCES Out of resources.
598 @retval EFI_SUCCESS Text Input Device's private data has been constructed.
599 @retval other Failed to construct private data.
603 ConSplitterTextInConstructor (
604 TEXT_IN_SPLITTER_PRIVATE_DATA
*ConInPrivate
608 UINTN TextInExListCount
;
611 // Allocate buffer for Simple Text Input device
613 Status
= ConSplitterGrowBuffer (
614 sizeof (EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*),
615 &ConInPrivate
->TextInListCount
,
616 (VOID
**)&ConInPrivate
->TextInList
618 if (EFI_ERROR (Status
)) {
619 return EFI_OUT_OF_RESOURCES
;
623 // Create Event to wait for a key
625 Status
= gBS
->CreateEvent (
628 ConSplitterTextInWaitForKey
,
630 &ConInPrivate
->TextIn
.WaitForKey
632 ASSERT_EFI_ERROR (Status
);
635 // Allocate buffer for KeyQueue
637 TextInExListCount
= ConInPrivate
->TextInExListCount
;
638 Status
= ConSplitterGrowBuffer (
639 sizeof (EFI_KEY_DATA
),
641 (VOID
**)&ConInPrivate
->KeyQueue
643 if (EFI_ERROR (Status
)) {
644 return EFI_OUT_OF_RESOURCES
;
648 // Allocate buffer for Simple Text Input Ex device
650 Status
= ConSplitterGrowBuffer (
651 sizeof (EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*),
652 &ConInPrivate
->TextInExListCount
,
653 (VOID
**)&ConInPrivate
->TextInExList
655 if (EFI_ERROR (Status
)) {
656 return EFI_OUT_OF_RESOURCES
;
660 // Create Event to wait for a key Ex
662 Status
= gBS
->CreateEvent (
665 ConSplitterTextInWaitForKey
,
667 &ConInPrivate
->TextInEx
.WaitForKeyEx
669 ASSERT_EFI_ERROR (Status
);
671 InitializeListHead (&ConInPrivate
->NotifyList
);
673 ToggleStateSyncInitialization (ConInPrivate
);
675 ConInPrivate
->AbsolutePointer
.Mode
= &ConInPrivate
->AbsolutePointerMode
;
677 // Allocate buffer for Absolute Pointer device
679 Status
= ConSplitterGrowBuffer (
680 sizeof (EFI_ABSOLUTE_POINTER_PROTOCOL
*),
681 &ConInPrivate
->AbsolutePointerListCount
,
682 (VOID
**)&ConInPrivate
->AbsolutePointerList
684 if (EFI_ERROR (Status
)) {
685 return EFI_OUT_OF_RESOURCES
;
689 // Create Event to wait for device input for Absolute pointer device
691 Status
= gBS
->CreateEvent (
694 ConSplitterAbsolutePointerWaitForInput
,
696 &ConInPrivate
->AbsolutePointer
.WaitForInput
698 ASSERT_EFI_ERROR (Status
);
700 ConInPrivate
->SimplePointer
.Mode
= &ConInPrivate
->SimplePointerMode
;
702 // Allocate buffer for Simple Pointer device
704 Status
= ConSplitterGrowBuffer (
705 sizeof (EFI_SIMPLE_POINTER_PROTOCOL
*),
706 &ConInPrivate
->PointerListCount
,
707 (VOID
**)&ConInPrivate
->PointerList
709 if (EFI_ERROR (Status
)) {
710 return EFI_OUT_OF_RESOURCES
;
714 // Create Event to wait for device input for Simple pointer device
716 Status
= gBS
->CreateEvent (
719 ConSplitterSimplePointerWaitForInput
,
721 &ConInPrivate
->SimplePointer
.WaitForInput
723 ASSERT_EFI_ERROR (Status
);
725 // Create Event to signal ConIn connection request
727 Status
= gBS
->CreateEventEx (
730 EfiEventEmptyFunction
,
732 &gConnectConInEventGuid
,
733 &ConInPrivate
->ConnectConInEvent
740 Construct console output devices' private data.
742 @param ConOutPrivate A pointer to the TEXT_OUT_SPLITTER_PRIVATE_DATA
745 @retval EFI_OUT_OF_RESOURCES Out of resources.
746 @retval EFI_SUCCESS Text Input Devcie's private data has been constructed.
750 ConSplitterTextOutConstructor (
751 TEXT_OUT_SPLITTER_PRIVATE_DATA
*ConOutPrivate
755 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*Info
;
758 // Copy protocols template
760 if (FeaturePcdGet (PcdConOutUgaSupport
)) {
761 CopyMem (&ConOutPrivate
->UgaDraw
, &mUgaDrawProtocolTemplate
, sizeof (EFI_UGA_DRAW_PROTOCOL
));
764 if (FeaturePcdGet (PcdConOutGopSupport
)) {
765 CopyMem (&ConOutPrivate
->GraphicsOutput
, &mGraphicsOutputProtocolTemplate
, sizeof (EFI_GRAPHICS_OUTPUT_PROTOCOL
));
769 // Initialize console output splitter's private data.
771 ConOutPrivate
->TextOut
.Mode
= &ConOutPrivate
->TextOutMode
;
774 // When new console device is added, the new mode will be set later,
775 // so put current mode back to init state.
777 ConOutPrivate
->TextOutMode
.Mode
= 0xFF;
779 // Allocate buffer for Console Out device
781 Status
= ConSplitterGrowBuffer (
782 sizeof (TEXT_OUT_AND_GOP_DATA
),
783 &ConOutPrivate
->TextOutListCount
,
784 (VOID
**)&ConOutPrivate
->TextOutList
786 if (EFI_ERROR (Status
)) {
787 return EFI_OUT_OF_RESOURCES
;
791 // Allocate buffer for Text Out query data
793 Status
= ConSplitterGrowBuffer (
794 sizeof (TEXT_OUT_SPLITTER_QUERY_DATA
),
795 &ConOutPrivate
->TextOutQueryDataCount
,
796 (VOID
**)&ConOutPrivate
->TextOutQueryData
798 if (EFI_ERROR (Status
)) {
799 return EFI_OUT_OF_RESOURCES
;
803 // Setup the default console to 80 x 25 and mode to 0
805 ConOutPrivate
->TextOutQueryData
[0].Columns
= 80;
806 ConOutPrivate
->TextOutQueryData
[0].Rows
= 25;
807 TextOutSetMode (ConOutPrivate
, 0);
809 if (FeaturePcdGet (PcdConOutUgaSupport
)) {
811 // Setup the UgaDraw to 800 x 600 x 32 bits per pixel, 60Hz.
813 ConSplitterUgaDrawSetMode (&ConOutPrivate
->UgaDraw
, 800, 600, 32, 60);
816 if (FeaturePcdGet (PcdConOutGopSupport
)) {
818 // Setup resource for mode information in Graphics Output Protocol interface
820 if ((ConOutPrivate
->GraphicsOutput
.Mode
= AllocateZeroPool (sizeof (EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE
))) == NULL
) {
821 return EFI_OUT_OF_RESOURCES
;
824 if ((ConOutPrivate
->GraphicsOutput
.Mode
->Info
= AllocateZeroPool (sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
))) == NULL
) {
825 return EFI_OUT_OF_RESOURCES
;
829 // Setup the DevNullGraphicsOutput to 800 x 600 x 32 bits per pixel
830 // DevNull will be updated to user-defined mode after driver has started.
832 if ((ConOutPrivate
->GraphicsOutputModeBuffer
= AllocateZeroPool (sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
))) == NULL
) {
833 return EFI_OUT_OF_RESOURCES
;
836 Info
= &ConOutPrivate
->GraphicsOutputModeBuffer
[0];
838 Info
->HorizontalResolution
= 800;
839 Info
->VerticalResolution
= 600;
840 Info
->PixelFormat
= PixelBltOnly
;
841 Info
->PixelsPerScanLine
= 800;
842 CopyMem (ConOutPrivate
->GraphicsOutput
.Mode
->Info
, Info
, sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
));
843 ConOutPrivate
->GraphicsOutput
.Mode
->SizeOfInfo
= sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
);
846 // Initialize the following items, theset items remain unchanged in GraphicsOutput->SetMode()
847 // GraphicsOutputMode->FrameBufferBase, GraphicsOutputMode->FrameBufferSize
849 ConOutPrivate
->GraphicsOutput
.Mode
->FrameBufferBase
= (EFI_PHYSICAL_ADDRESS
)(UINTN
)NULL
;
850 ConOutPrivate
->GraphicsOutput
.Mode
->FrameBufferSize
= 0;
852 ConOutPrivate
->GraphicsOutput
.Mode
->MaxMode
= 1;
854 // Initial current mode to unknown state, and then set to mode 0
856 ConOutPrivate
->GraphicsOutput
.Mode
->Mode
= 0xffff;
857 ConOutPrivate
->GraphicsOutput
.SetMode (&ConOutPrivate
->GraphicsOutput
, 0);
864 Test to see if the specified protocol could be supported on the specified device.
866 @param This Driver Binding protocol pointer.
867 @param ControllerHandle Handle of device to test.
868 @param Guid The specified protocol.
870 @retval EFI_SUCCESS The specified protocol is supported on this device.
871 @retval EFI_UNSUPPORTED The specified protocol attempts to be installed on virtual handle.
872 @retval other Failed to open specified protocol on this device.
876 ConSplitterSupported (
877 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
878 IN EFI_HANDLE ControllerHandle
,
886 // Make sure the Console Splitter does not attempt to attach to itself
888 if ((ControllerHandle
== mConIn
.VirtualHandle
) ||
889 (ControllerHandle
== mConOut
.VirtualHandle
) ||
890 (ControllerHandle
== mStdErr
.VirtualHandle
)
893 return EFI_UNSUPPORTED
;
897 // Check to see whether the specific protocol could be opened BY_DRIVER
899 Status
= gBS
->OpenProtocol (
903 This
->DriverBindingHandle
,
905 EFI_OPEN_PROTOCOL_BY_DRIVER
908 if (EFI_ERROR (Status
)) {
915 This
->DriverBindingHandle
,
923 Test to see if Console In Device could be supported on the Controller.
925 @param This Driver Binding protocol instance pointer.
926 @param ControllerHandle Handle of device to test.
927 @param RemainingDevicePath Optional parameter use to pick a specific child
930 @retval EFI_SUCCESS This driver supports this device.
931 @retval other This driver does not support this device.
936 ConSplitterConInDriverBindingSupported (
937 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
938 IN EFI_HANDLE ControllerHandle
,
939 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
942 return ConSplitterSupported (
945 &gEfiConsoleInDeviceGuid
950 Test to see if Simple Pointer protocol could be supported on the Controller.
952 @param This Driver Binding protocol instance pointer.
953 @param ControllerHandle Handle of device to test.
954 @param RemainingDevicePath Optional parameter use to pick a specific child
957 @retval EFI_SUCCESS This driver supports this device.
958 @retval other This driver does not support this device.
963 ConSplitterSimplePointerDriverBindingSupported (
964 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
965 IN EFI_HANDLE ControllerHandle
,
966 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
969 return ConSplitterSupported (
972 &gEfiSimplePointerProtocolGuid
977 Test to see if Absolute Pointer protocol could be supported on the Controller.
979 @param This Driver Binding protocol instance pointer.
980 @param ControllerHandle Handle of device to test.
981 @param RemainingDevicePath Optional parameter use to pick a specific child
984 @retval EFI_SUCCESS This driver supports this device.
985 @retval other This driver does not support this device.
990 ConSplitterAbsolutePointerDriverBindingSupported (
991 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
992 IN EFI_HANDLE ControllerHandle
,
993 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
996 return ConSplitterSupported (
999 &gEfiAbsolutePointerProtocolGuid
1004 Test to see if Console Out Device could be supported on the Controller.
1006 @param This Driver Binding protocol instance pointer.
1007 @param ControllerHandle Handle of device to test.
1008 @param RemainingDevicePath Optional parameter use to pick a specific child
1011 @retval EFI_SUCCESS This driver supports this device.
1012 @retval other This driver does not support this device.
1017 ConSplitterConOutDriverBindingSupported (
1018 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1019 IN EFI_HANDLE ControllerHandle
,
1020 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
1023 return ConSplitterSupported (
1026 &gEfiConsoleOutDeviceGuid
1031 Test to see if Standard Error Device could be supported on the Controller.
1033 @param This Driver Binding protocol instance pointer.
1034 @param ControllerHandle Handle of device to test.
1035 @param RemainingDevicePath Optional parameter use to pick a specific child
1038 @retval EFI_SUCCESS This driver supports this device.
1039 @retval other This driver does not support this device.
1044 ConSplitterStdErrDriverBindingSupported (
1045 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1046 IN EFI_HANDLE ControllerHandle
,
1047 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
1050 return ConSplitterSupported (
1053 &gEfiStandardErrorDeviceGuid
1058 Start ConSplitter on devcie handle by opening Console Device Guid on device handle
1059 and the console virtual handle. And Get the console interface on controller handle.
1061 @param This Driver Binding protocol instance pointer.
1062 @param ControllerHandle Handle of device.
1063 @param ConSplitterVirtualHandle Console virtual Handle.
1064 @param DeviceGuid The specified Console Device, such as ConInDev,
1066 @param InterfaceGuid The specified protocol to be opened.
1067 @param Interface Protocol interface returned.
1069 @retval EFI_SUCCESS This driver supports this device.
1070 @retval other Failed to open the specified Console Device Guid
1071 or specified protocol.
1076 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1077 IN EFI_HANDLE ControllerHandle
,
1078 IN EFI_HANDLE ConSplitterVirtualHandle
,
1079 IN EFI_GUID
*DeviceGuid
,
1080 IN EFI_GUID
*InterfaceGuid
,
1081 OUT VOID
**Interface
1088 // Check to see whether the ControllerHandle has the DeviceGuid on it.
1090 Status
= gBS
->OpenProtocol (
1094 This
->DriverBindingHandle
,
1096 EFI_OPEN_PROTOCOL_BY_DRIVER
1098 if (EFI_ERROR (Status
)) {
1103 // Open the Parent Handle for the child.
1105 Status
= gBS
->OpenProtocol (
1109 This
->DriverBindingHandle
,
1110 ConSplitterVirtualHandle
,
1111 EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
1113 if (EFI_ERROR (Status
)) {
1118 // Open InterfaceGuid on the virtual handle.
1120 Status
= gBS
->OpenProtocol (
1124 This
->DriverBindingHandle
,
1125 ConSplitterVirtualHandle
,
1126 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1129 if (!EFI_ERROR (Status
)) {
1134 // close the DeviceGuid on ConSplitter VirtualHandle.
1136 gBS
->CloseProtocol (
1139 This
->DriverBindingHandle
,
1140 ConSplitterVirtualHandle
1145 // close the DeviceGuid on ControllerHandle.
1147 gBS
->CloseProtocol (
1150 This
->DriverBindingHandle
,
1158 Start Console In Consplitter on device handle.
1160 @param This Driver Binding protocol instance pointer.
1161 @param ControllerHandle Handle of device to bind driver to.
1162 @param RemainingDevicePath Optional parameter use to pick a specific child
1165 @retval EFI_SUCCESS Console In Consplitter is added to ControllerHandle.
1166 @retval other Console In Consplitter does not support this device.
1171 ConSplitterConInDriverBindingStart (
1172 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1173 IN EFI_HANDLE ControllerHandle
,
1174 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
1178 EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*TextIn
;
1179 EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*TextInEx
;
1182 // Start ConSplitter on ControllerHandle, and create the virtual
1183 // aggregated console device on first call Start for a SimpleTextIn handle.
1185 Status
= ConSplitterStart (
1188 mConIn
.VirtualHandle
,
1189 &gEfiConsoleInDeviceGuid
,
1190 &gEfiSimpleTextInProtocolGuid
,
1193 if (EFI_ERROR (Status
)) {
1198 // Add this device into Text In devices list.
1200 Status
= ConSplitterTextInAddDevice (&mConIn
, TextIn
);
1201 if (EFI_ERROR (Status
)) {
1205 Status
= gBS
->OpenProtocol (
1207 &gEfiSimpleTextInputExProtocolGuid
,
1209 This
->DriverBindingHandle
,
1210 mConIn
.VirtualHandle
,
1211 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1213 if (!EFI_ERROR (Status
)) {
1215 // If Simple Text Input Ex protocol exists,
1216 // add this device into Text In Ex devices list.
1218 Status
= ConSplitterTextInExAddDevice (&mConIn
, TextInEx
);
1225 Start Simple Pointer Consplitter on device handle.
1227 @param This Driver Binding protocol instance pointer.
1228 @param ControllerHandle Handle of device to bind driver to.
1229 @param RemainingDevicePath Optional parameter use to pick a specific child
1232 @retval EFI_SUCCESS Simple Pointer Consplitter is added to ControllerHandle.
1233 @retval other Simple Pointer Consplitter does not support this device.
1238 ConSplitterSimplePointerDriverBindingStart (
1239 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1240 IN EFI_HANDLE ControllerHandle
,
1241 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
1245 EFI_SIMPLE_POINTER_PROTOCOL
*SimplePointer
;
1248 // Start ConSplitter on ControllerHandle, and create the virtual
1249 // aggregated console device on first call Start for a SimplePointer handle.
1251 Status
= ConSplitterStart (
1254 mConIn
.VirtualHandle
,
1255 &gEfiSimplePointerProtocolGuid
,
1256 &gEfiSimplePointerProtocolGuid
,
1257 (VOID
**)&SimplePointer
1259 if (EFI_ERROR (Status
)) {
1264 // Add this devcie into Simple Pointer devices list.
1266 return ConSplitterSimplePointerAddDevice (&mConIn
, SimplePointer
);
1270 Start Absolute Pointer Consplitter on device handle.
1272 @param This Driver Binding protocol instance pointer.
1273 @param ControllerHandle Handle of device to bind driver to.
1274 @param RemainingDevicePath Optional parameter use to pick a specific child
1277 @retval EFI_SUCCESS Absolute Pointer Consplitter is added to ControllerHandle.
1278 @retval other Absolute Pointer Consplitter does not support this device.
1283 ConSplitterAbsolutePointerDriverBindingStart (
1284 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1285 IN EFI_HANDLE ControllerHandle
,
1286 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
1290 EFI_ABSOLUTE_POINTER_PROTOCOL
*AbsolutePointer
;
1293 // Start ConSplitter on ControllerHandle, and create the virtual
1294 // aggregated console device on first call Start for a AbsolutePointer handle.
1296 Status
= ConSplitterStart (
1299 mConIn
.VirtualHandle
,
1300 &gEfiAbsolutePointerProtocolGuid
,
1301 &gEfiAbsolutePointerProtocolGuid
,
1302 (VOID
**)&AbsolutePointer
1305 if (EFI_ERROR (Status
)) {
1310 // Add this devcie into Absolute Pointer devices list.
1312 return ConSplitterAbsolutePointerAddDevice (&mConIn
, AbsolutePointer
);
1316 Start Console Out Consplitter on device handle.
1318 @param This Driver Binding protocol instance pointer.
1319 @param ControllerHandle Handle of device to bind driver to.
1320 @param RemainingDevicePath Optional parameter use to pick a specific child
1323 @retval EFI_SUCCESS Console Out Consplitter is added to ControllerHandle.
1324 @retval other Console Out Consplitter does not support this device.
1329 ConSplitterConOutDriverBindingStart (
1330 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1331 IN EFI_HANDLE ControllerHandle
,
1332 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
1336 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
;
1337 EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
;
1338 EFI_UGA_DRAW_PROTOCOL
*UgaDraw
;
1340 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*Info
;
1343 // Start ConSplitter on ControllerHandle, and create the virtual
1344 // aggregated console device on first call Start for a ConsoleOut handle.
1346 Status
= ConSplitterStart (
1349 mConOut
.VirtualHandle
,
1350 &gEfiConsoleOutDeviceGuid
,
1351 &gEfiSimpleTextOutProtocolGuid
,
1354 if (EFI_ERROR (Status
)) {
1358 GraphicsOutput
= NULL
;
1361 // Try to Open Graphics Output protocol
1363 Status
= gBS
->OpenProtocol (
1365 &gEfiGraphicsOutputProtocolGuid
,
1366 (VOID
**)&GraphicsOutput
,
1367 This
->DriverBindingHandle
,
1368 mConOut
.VirtualHandle
,
1369 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1372 if (EFI_ERROR (Status
) && FeaturePcdGet (PcdUgaConsumeSupport
)) {
1374 // Open UGA DRAW protocol
1378 &gEfiUgaDrawProtocolGuid
,
1380 This
->DriverBindingHandle
,
1381 mConOut
.VirtualHandle
,
1382 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1387 // When new console device is added, the new mode will be set later,
1388 // so put current mode back to init state.
1390 mConOut
.TextOutMode
.Mode
= 0xFF;
1393 // If both ConOut and StdErr incorporate the same Text Out device,
1394 // their MaxMode and QueryData should be the intersection of both.
1396 Status
= ConSplitterTextOutAddDevice (&mConOut
, TextOut
, GraphicsOutput
, UgaDraw
);
1397 ConSplitterTextOutSetAttribute (&mConOut
.TextOut
, EFI_TEXT_ATTR (EFI_LIGHTGRAY
, EFI_BLACK
));
1399 if (FeaturePcdGet (PcdConOutUgaSupport
)) {
1401 // Get the UGA mode data of ConOut from the current mode
1403 if (GraphicsOutput
!= NULL
) {
1404 Status
= GraphicsOutput
->QueryMode (GraphicsOutput
, GraphicsOutput
->Mode
->Mode
, &SizeOfInfo
, &Info
);
1405 if (EFI_ERROR (Status
)) {
1409 ASSERT (SizeOfInfo
<= sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
));
1411 mConOut
.UgaHorizontalResolution
= Info
->HorizontalResolution
;
1412 mConOut
.UgaVerticalResolution
= Info
->VerticalResolution
;
1413 mConOut
.UgaColorDepth
= 32;
1414 mConOut
.UgaRefreshRate
= 60;
1417 } else if (UgaDraw
!= NULL
) {
1418 Status
= UgaDraw
->GetMode (
1420 &mConOut
.UgaHorizontalResolution
,
1421 &mConOut
.UgaVerticalResolution
,
1422 &mConOut
.UgaColorDepth
,
1423 &mConOut
.UgaRefreshRate
1432 Start Standard Error Consplitter on device handle.
1434 @param This Driver Binding protocol instance pointer.
1435 @param ControllerHandle Handle of device to bind driver to.
1436 @param RemainingDevicePath Optional parameter use to pick a specific child
1439 @retval EFI_SUCCESS Standard Error Consplitter is added to ControllerHandle.
1440 @retval other Standard Error Consplitter does not support this device.
1445 ConSplitterStdErrDriverBindingStart (
1446 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1447 IN EFI_HANDLE ControllerHandle
,
1448 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
1452 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
;
1455 // Start ConSplitter on ControllerHandle, and create the virtual
1456 // aggregated console device on first call Start for a StandardError handle.
1458 Status
= ConSplitterStart (
1461 mStdErr
.VirtualHandle
,
1462 &gEfiStandardErrorDeviceGuid
,
1463 &gEfiSimpleTextOutProtocolGuid
,
1466 if (EFI_ERROR (Status
)) {
1471 // When new console device is added, the new mode will be set later,
1472 // so put current mode back to init state.
1474 mStdErr
.TextOutMode
.Mode
= 0xFF;
1477 // If both ConOut and StdErr incorporate the same Text Out device,
1478 // their MaxMode and QueryData should be the intersection of both.
1480 Status
= ConSplitterTextOutAddDevice (&mStdErr
, TextOut
, NULL
, NULL
);
1481 ConSplitterTextOutSetAttribute (&mStdErr
.TextOut
, EFI_TEXT_ATTR (EFI_LIGHTGRAY
, EFI_BLACK
));
1487 Stop ConSplitter on device handle by closing Console Device Guid on device handle
1488 and the console virtual handle.
1490 @param This Protocol instance pointer.
1491 @param ControllerHandle Handle of device.
1492 @param ConSplitterVirtualHandle Console virtual Handle.
1493 @param DeviceGuid The specified Console Device, such as ConInDev,
1495 @param InterfaceGuid The specified protocol to be opened.
1496 @param Interface Protocol interface returned.
1498 @retval EFI_SUCCESS Stop ConSplitter on ControllerHandle successfully.
1499 @retval other Failed to Stop ConSplitter on ControllerHandle.
1504 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1505 IN EFI_HANDLE ControllerHandle
,
1506 IN EFI_HANDLE ConSplitterVirtualHandle
,
1507 IN EFI_GUID
*DeviceGuid
,
1508 IN EFI_GUID
*InterfaceGuid
,
1514 Status
= gBS
->OpenProtocol (
1518 This
->DriverBindingHandle
,
1520 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1522 if (EFI_ERROR (Status
)) {
1527 // close the protocol referred.
1529 gBS
->CloseProtocol (
1532 This
->DriverBindingHandle
,
1533 ConSplitterVirtualHandle
1536 gBS
->CloseProtocol (
1539 This
->DriverBindingHandle
,
1547 Stop Console In ConSplitter on ControllerHandle by closing Console In Device GUID.
1549 @param This Driver Binding protocol instance pointer.
1550 @param ControllerHandle Handle of device to stop driver on
1551 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
1552 children is zero stop the entire bus driver.
1553 @param ChildHandleBuffer List of Child Handles to Stop.
1555 @retval EFI_SUCCESS This driver is removed ControllerHandle
1556 @retval other This driver was not removed from this device
1561 ConSplitterConInDriverBindingStop (
1562 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1563 IN EFI_HANDLE ControllerHandle
,
1564 IN UINTN NumberOfChildren
,
1565 IN EFI_HANDLE
*ChildHandleBuffer
1569 EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*TextIn
;
1570 EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*TextInEx
;
1572 if (NumberOfChildren
== 0) {
1576 Status
= gBS
->OpenProtocol (
1578 &gEfiSimpleTextInputExProtocolGuid
,
1580 This
->DriverBindingHandle
,
1582 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1584 if (!EFI_ERROR (Status
)) {
1586 // If Simple Text Input Ex protocol exists,
1587 // remove device from Text Input Ex devices list.
1589 Status
= ConSplitterTextInExDeleteDevice (&mConIn
, TextInEx
);
1590 if (EFI_ERROR (Status
)) {
1596 // Close Simple Text In protocol on controller handle and virtual handle.
1598 Status
= ConSplitterStop (
1601 mConIn
.VirtualHandle
,
1602 &gEfiConsoleInDeviceGuid
,
1603 &gEfiSimpleTextInProtocolGuid
,
1606 if (EFI_ERROR (Status
)) {
1611 // Remove device from Text Input devices list.
1613 return ConSplitterTextInDeleteDevice (&mConIn
, TextIn
);
1617 Stop Simple Pointer protocol ConSplitter on ControllerHandle by closing
1618 Simple Pointer protocol.
1620 @param This Driver Binding protocol instance pointer.
1621 @param ControllerHandle Handle of device to stop driver on
1622 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
1623 children is zero stop the entire bus driver.
1624 @param ChildHandleBuffer List of Child Handles to Stop.
1626 @retval EFI_SUCCESS This driver is removed ControllerHandle
1627 @retval other This driver was not removed from this device
1632 ConSplitterSimplePointerDriverBindingStop (
1633 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1634 IN EFI_HANDLE ControllerHandle
,
1635 IN UINTN NumberOfChildren
,
1636 IN EFI_HANDLE
*ChildHandleBuffer
1640 EFI_SIMPLE_POINTER_PROTOCOL
*SimplePointer
;
1642 if (NumberOfChildren
== 0) {
1647 // Close Simple Pointer protocol on controller handle and virtual handle.
1649 Status
= ConSplitterStop (
1652 mConIn
.VirtualHandle
,
1653 &gEfiSimplePointerProtocolGuid
,
1654 &gEfiSimplePointerProtocolGuid
,
1655 (VOID
**)&SimplePointer
1657 if (EFI_ERROR (Status
)) {
1662 // Remove this device from Simple Pointer device list.
1664 return ConSplitterSimplePointerDeleteDevice (&mConIn
, SimplePointer
);
1668 Stop Absolute Pointer protocol ConSplitter on ControllerHandle by closing
1669 Absolute Pointer protocol.
1671 @param This Driver Binding protocol instance pointer.
1672 @param ControllerHandle Handle of device to stop driver on
1673 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
1674 children is zero stop the entire bus driver.
1675 @param ChildHandleBuffer List of Child Handles to Stop.
1677 @retval EFI_SUCCESS This driver is removed ControllerHandle
1678 @retval other This driver was not removed from this device
1683 ConSplitterAbsolutePointerDriverBindingStop (
1684 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1685 IN EFI_HANDLE ControllerHandle
,
1686 IN UINTN NumberOfChildren
,
1687 IN EFI_HANDLE
*ChildHandleBuffer
1691 EFI_ABSOLUTE_POINTER_PROTOCOL
*AbsolutePointer
;
1693 if (NumberOfChildren
== 0) {
1698 // Close Absolute Pointer protocol on controller handle and virtual handle.
1700 Status
= ConSplitterStop (
1703 mConIn
.VirtualHandle
,
1704 &gEfiAbsolutePointerProtocolGuid
,
1705 &gEfiAbsolutePointerProtocolGuid
,
1706 (VOID
**)&AbsolutePointer
1708 if (EFI_ERROR (Status
)) {
1713 // Remove this device from Absolute Pointer device list.
1715 return ConSplitterAbsolutePointerDeleteDevice (&mConIn
, AbsolutePointer
);
1719 Stop Console Out ConSplitter on device handle by closing Console Out Devcie 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
);
1769 Stop Standard Error ConSplitter on ControllerHandle by closing Standard Error GUID.
1771 @param This Driver Binding protocol instance pointer.
1772 @param ControllerHandle Handle of device to stop driver on
1773 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
1774 children is zero stop the entire bus driver.
1775 @param ChildHandleBuffer List of Child Handles to Stop.
1777 @retval EFI_SUCCESS This driver is removed ControllerHandle
1778 @retval other This driver was not removed from this device
1783 ConSplitterStdErrDriverBindingStop (
1784 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1785 IN EFI_HANDLE ControllerHandle
,
1786 IN UINTN NumberOfChildren
,
1787 IN EFI_HANDLE
*ChildHandleBuffer
1791 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
;
1793 if (NumberOfChildren
== 0) {
1798 // Close Standard Error Device on controller handle and virtual handle.
1800 Status
= ConSplitterStop (
1803 mStdErr
.VirtualHandle
,
1804 &gEfiStandardErrorDeviceGuid
,
1805 &gEfiSimpleTextOutProtocolGuid
,
1808 if (EFI_ERROR (Status
)) {
1813 // Delete this console error out device's data structures.
1815 return ConSplitterTextOutDeleteDevice (&mStdErr
, TextOut
);
1819 Take the passed in Buffer of size ElementSize and grow the buffer
1820 by CONSOLE_SPLITTER_ALLOC_UNIT * ElementSize bytes.
1821 Copy the current data in Buffer to the new version of Buffer and
1822 free the old version of buffer.
1824 @param ElementSize Size of element in array.
1825 @param Count Current number of elements in array.
1826 @param Buffer Bigger version of passed in Buffer with all the
1829 @retval EFI_SUCCESS Buffer size has grown.
1830 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
1834 ConSplitterGrowBuffer (
1835 IN UINTN ElementSize
,
1836 IN OUT UINTN
*Count
,
1837 IN OUT VOID
**Buffer
1843 // grow the buffer to new buffer size,
1844 // copy the old buffer's content to the new-size buffer,
1845 // then free the old buffer.
1847 Ptr
= ReallocatePool (
1848 ElementSize
* (*Count
),
1849 ElementSize
* ((*Count
) + CONSOLE_SPLITTER_ALLOC_UNIT
),
1853 return EFI_OUT_OF_RESOURCES
;
1856 *Count
+= CONSOLE_SPLITTER_ALLOC_UNIT
;
1862 Add Text Input Device in Consplitter Text Input list.
1864 @param Private Text In Splitter pointer.
1865 @param TextIn Simple Text Input protocol pointer.
1867 @retval EFI_SUCCESS Text Input Device added successfully.
1868 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
1872 ConSplitterTextInAddDevice (
1873 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
1874 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*TextIn
1880 // If the Text In List is full, enlarge it by calling ConSplitterGrowBuffer().
1882 if (Private
->CurrentNumberOfConsoles
>= Private
->TextInListCount
) {
1883 Status
= ConSplitterGrowBuffer (
1884 sizeof (EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*),
1885 &Private
->TextInListCount
,
1886 (VOID
**)&Private
->TextInList
1888 if (EFI_ERROR (Status
)) {
1889 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
);
1908 Remove Text Input Device from Consplitter Text Input list.
1910 @param Private Text In Splitter pointer.
1911 @param TextIn Simple Text protocol pointer.
1913 @retval EFI_SUCCESS Simple Text Device removed successfully.
1914 @retval EFI_NOT_FOUND No Simple Text Device found.
1918 ConSplitterTextInDeleteDevice (
1919 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
1920 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
]
2027 // Add the new text-in device data structure into the Text Input Ex List.
2029 Private
->TextInExList
[Private
->CurrentNumberOfExConsoles
] = TextInEx
;
2030 Private
->CurrentNumberOfExConsoles
++;
2033 // Sync current toggle state to this new console input device.
2035 TextInEx
->SetState (TextInEx
, &Private
->PhysicalKeyToggleState
);
2038 // Extra CheckEvent added to reduce the double CheckEvent().
2040 gBS
->CheckEvent (TextInEx
->WaitForKeyEx
);
2046 Remove Text Ex Device from Consplitter Text Input Ex list.
2048 @param Private Text In Splitter pointer.
2049 @param TextInEx Simple Text Ex protocol pointer.
2051 @retval EFI_SUCCESS Simple Text Input Ex Device removed successfully.
2052 @retval EFI_NOT_FOUND No Simple Text Input Ex Device found.
2056 ConSplitterTextInExDeleteDevice (
2057 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
2058 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*TextInEx
2064 // Remove the specified text-in device data structure from the Text Input Ex List,
2065 // and rearrange the remaining data structures in the Text In List.
2067 for (Index
= 0; Index
< Private
->CurrentNumberOfExConsoles
; Index
++) {
2068 if (Private
->TextInExList
[Index
] == TextInEx
) {
2069 for ( ; Index
< Private
->CurrentNumberOfExConsoles
- 1; Index
++) {
2070 Private
->TextInExList
[Index
] = Private
->TextInExList
[Index
+ 1];
2073 Private
->CurrentNumberOfExConsoles
--;
2078 return EFI_NOT_FOUND
;
2082 Add Simple Pointer Device in Consplitter Simple Pointer list.
2084 @param Private Text In Splitter pointer.
2085 @param SimplePointer Simple Pointer protocol pointer.
2087 @retval EFI_SUCCESS Simple Pointer Device added successfully.
2088 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
2092 ConSplitterSimplePointerAddDevice (
2093 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
2094 IN EFI_SIMPLE_POINTER_PROTOCOL
*SimplePointer
2100 // If the Simple Pointer List is full, enlarge it by calling ConSplitterGrowBuffer().
2102 if (Private
->CurrentNumberOfPointers
>= Private
->PointerListCount
) {
2103 Status
= ConSplitterGrowBuffer (
2104 sizeof (EFI_SIMPLE_POINTER_PROTOCOL
*),
2105 &Private
->PointerListCount
,
2106 (VOID
**)&Private
->PointerList
2108 if (EFI_ERROR (Status
)) {
2109 return EFI_OUT_OF_RESOURCES
;
2114 // Add the new text-in device data structure into the Simple Pointer List.
2116 Private
->PointerList
[Private
->CurrentNumberOfPointers
] = SimplePointer
;
2117 Private
->CurrentNumberOfPointers
++;
2123 Remove Simple Pointer Device from Consplitter Simple Pointer list.
2125 @param Private Text In Splitter pointer.
2126 @param SimplePointer Simple Pointer protocol pointer.
2128 @retval EFI_SUCCESS Simple Pointer Device removed successfully.
2129 @retval EFI_NOT_FOUND No Simple Pointer Device found.
2133 ConSplitterSimplePointerDeleteDevice (
2134 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
2135 IN EFI_SIMPLE_POINTER_PROTOCOL
*SimplePointer
2141 // Remove the specified text-in device data structure from the Simple Pointer List,
2142 // and rearrange the remaining data structures in the Text In List.
2144 for (Index
= 0; Index
< Private
->CurrentNumberOfPointers
; Index
++) {
2145 if (Private
->PointerList
[Index
] == SimplePointer
) {
2146 for ( ; Index
< Private
->CurrentNumberOfPointers
- 1; Index
++) {
2147 Private
->PointerList
[Index
] = Private
->PointerList
[Index
+ 1];
2150 Private
->CurrentNumberOfPointers
--;
2155 return EFI_NOT_FOUND
;
2159 Add Absolute Pointer Device in Consplitter Absolute Pointer list.
2161 @param Private Text In Splitter pointer.
2162 @param AbsolutePointer Absolute Pointer protocol pointer.
2164 @retval EFI_SUCCESS Absolute Pointer Device added successfully.
2165 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
2169 ConSplitterAbsolutePointerAddDevice (
2170 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
2171 IN EFI_ABSOLUTE_POINTER_PROTOCOL
*AbsolutePointer
2177 // If the Absolute Pointer List is full, enlarge it by calling ConSplitterGrowBuffer().
2179 if (Private
->CurrentNumberOfAbsolutePointers
>= Private
->AbsolutePointerListCount
) {
2180 Status
= ConSplitterGrowBuffer (
2181 sizeof (EFI_ABSOLUTE_POINTER_PROTOCOL
*),
2182 &Private
->AbsolutePointerListCount
,
2183 (VOID
**)&Private
->AbsolutePointerList
2185 if (EFI_ERROR (Status
)) {
2186 return EFI_OUT_OF_RESOURCES
;
2191 // Add the new text-in device data structure into the Absolute Pointer List.
2193 Private
->AbsolutePointerList
[Private
->CurrentNumberOfAbsolutePointers
] = AbsolutePointer
;
2194 Private
->CurrentNumberOfAbsolutePointers
++;
2200 Remove Absolute Pointer Device from Consplitter Absolute Pointer list.
2202 @param Private Text In Splitter pointer.
2203 @param AbsolutePointer Absolute Pointer protocol pointer.
2205 @retval EFI_SUCCESS Absolute Pointer Device removed successfully.
2206 @retval EFI_NOT_FOUND No Absolute Pointer Device found.
2210 ConSplitterAbsolutePointerDeleteDevice (
2211 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
2212 IN EFI_ABSOLUTE_POINTER_PROTOCOL
*AbsolutePointer
2218 // Remove the specified text-in device data structure from the Absolute Pointer List,
2219 // and rearrange the remaining data structures from the Absolute Pointer List.
2221 for (Index
= 0; Index
< Private
->CurrentNumberOfAbsolutePointers
; Index
++) {
2222 if (Private
->AbsolutePointerList
[Index
] == AbsolutePointer
) {
2223 for ( ; Index
< Private
->CurrentNumberOfAbsolutePointers
- 1; Index
++) {
2224 Private
->AbsolutePointerList
[Index
] = Private
->AbsolutePointerList
[Index
+ 1];
2227 Private
->CurrentNumberOfAbsolutePointers
--;
2232 return EFI_NOT_FOUND
;
2236 Reallocate Text Out mode map.
2238 Allocate new buffer and copy original buffer into the new buffer.
2240 @param Private Consplitter Text Out pointer.
2242 @retval EFI_SUCCESS Buffer size has grown
2243 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
2247 ConSplitterGrowMapTable (
2248 IN TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
2254 INT32
*TextOutModeMap
;
2255 INT32
*OldTextOutModeMap
;
2261 NewSize
= Private
->TextOutListCount
* sizeof (INT32
);
2262 OldTextOutModeMap
= Private
->TextOutModeMap
;
2263 TotalSize
= NewSize
* (Private
->TextOutQueryDataCount
);
2266 // Allocate new buffer for Text Out List.
2268 TextOutModeMap
= AllocatePool (TotalSize
);
2269 if (TextOutModeMap
== NULL
) {
2270 return EFI_OUT_OF_RESOURCES
;
2273 SetMem (TextOutModeMap
, TotalSize
, 0xFF);
2274 Private
->TextOutModeMap
= TextOutModeMap
;
2277 // If TextOutList has been enlarged, need to realloc the mode map table
2278 // The mode map table is regarded as a two dimension array.
2281 // 0 ---------> TextOutListCount ----> TextOutListCount
2282 // | -------------------------------------------
2289 // -------------------------------------------
2292 if (OldTextOutModeMap
!= NULL
) {
2293 Size
= Private
->CurrentNumberOfConsoles
* sizeof (INT32
);
2295 SrcAddress
= OldTextOutModeMap
;
2296 NewStepSize
= NewSize
/ sizeof (INT32
);
2297 // If Private->CurrentNumberOfConsoles is not zero and OldTextOutModeMap
2298 // is not NULL, it indicates that the original TextOutModeMap is not enough
2299 // for the new console devices and has been enlarged by CONSOLE_SPLITTER_ALLOC_UNIT columns.
2301 OldStepSize
= NewStepSize
- CONSOLE_SPLITTER_ALLOC_UNIT
;
2304 // Copy the old data to the new one
2306 while (Index
< Private
->TextOutMode
.MaxMode
) {
2307 CopyMem (TextOutModeMap
, SrcAddress
, Size
);
2309 // Go to next row of new TextOutModeMap.
2311 TextOutModeMap
+= NewStepSize
;
2313 // Go to next row of old TextOutModeMap.
2315 SrcAddress
+= OldStepSize
;
2320 // Free the old buffer
2322 FreePool (OldTextOutModeMap
);
2329 Add new device's output mode to console splitter's mode list.
2331 @param Private Text Out Splitter pointer
2332 @param TextOut Simple Text Output protocol pointer.
2334 @retval EFI_SUCCESS Device added successfully.
2335 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
2339 ConSplitterAddOutputMode (
2340 IN TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
,
2341 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
2349 MaxMode
= TextOut
->Mode
->MaxMode
;
2350 Private
->TextOutMode
.MaxMode
= MaxMode
;
2353 // Grow the buffer if query data buffer is not large enough to
2354 // hold all the mode supported by the first console.
2356 while (MaxMode
> (INT32
)Private
->TextOutQueryDataCount
) {
2357 Status
= ConSplitterGrowBuffer (
2358 sizeof (TEXT_OUT_SPLITTER_QUERY_DATA
),
2359 &Private
->TextOutQueryDataCount
,
2360 (VOID
**)&Private
->TextOutQueryData
2362 if (EFI_ERROR (Status
)) {
2363 return EFI_OUT_OF_RESOURCES
;
2368 // Allocate buffer for the output mode map
2370 Status
= ConSplitterGrowMapTable (Private
);
2371 if (EFI_ERROR (Status
)) {
2372 return EFI_OUT_OF_RESOURCES
;
2376 // As the first textout device, directly add the mode in to QueryData
2377 // and at the same time record the mapping between QueryData and TextOut.
2381 while (Mode
< MaxMode
) {
2382 Status
= TextOut
->QueryMode (
2385 &Private
->TextOutQueryData
[Mode
].Columns
,
2386 &Private
->TextOutQueryData
[Mode
].Rows
2389 // If mode 1 (80x50) is not supported, make sure mode 1 in TextOutQueryData
2392 if ((EFI_ERROR (Status
)) && (Mode
== 1)) {
2393 Private
->TextOutQueryData
[Mode
].Columns
= 0;
2394 Private
->TextOutQueryData
[Mode
].Rows
= 0;
2397 Private
->TextOutModeMap
[Index
] = Mode
;
2399 Index
+= Private
->TextOutListCount
;
2406 Reconstruct TextOutModeMap to get intersection of modes.
2408 This routine reconstruct TextOutModeMap to get the intersection
2409 of modes for all console out devices. Because EFI/UEFI spec require
2410 mode 0 is 80x25, mode 1 is 80x50, this routine will not check the
2411 intersection for mode 0 and mode 1.
2413 @param TextOutModeMap Current text out mode map, begin with the mode 80x25
2414 @param NewlyAddedMap New text out mode map, begin with the mode 80x25
2415 @param MapStepSize Mode step size for one console device
2416 @param NewMapStepSize New Mode step size for one console device
2417 @param MaxMode IN: Current max text mode, OUT: Updated max text mode.
2418 @param CurrentMode IN: Current text mode, OUT: Updated current text mode.
2422 ConSplitterGetIntersection (
2423 IN INT32
*TextOutModeMap
,
2424 IN INT32
*NewlyAddedMap
,
2425 IN UINTN MapStepSize
,
2426 IN UINTN NewMapStepSize
,
2427 IN OUT INT32
*MaxMode
,
2428 IN OUT INT32
*CurrentMode
2432 INT32
*CurrentMapEntry
;
2433 INT32
*NextMapEntry
;
2435 INT32 CurrentMaxMode
;
2439 // According to EFI/UEFI spec, mode 0 and mode 1 have been reserved
2440 // for 80x25 and 80x50 in Simple Text Out protocol, so don't make intersection
2441 // for mode 0 and mode 1, mode number starts from 2.
2444 CurrentMapEntry
= &TextOutModeMap
[MapStepSize
* 2];
2445 NextMapEntry
= CurrentMapEntry
;
2446 NewMapEntry
= &NewlyAddedMap
[NewMapStepSize
* 2];
2448 CurrentMaxMode
= *MaxMode
;
2449 Mode
= *CurrentMode
;
2451 while (Index
< CurrentMaxMode
) {
2452 if (*NewMapEntry
== -1) {
2454 // This mode is not supported any more. Remove it. Special care
2455 // must be taken as this remove will also affect current mode;
2457 if (Index
== *CurrentMode
) {
2459 } else if (Index
< *CurrentMode
) {
2465 if (CurrentMapEntry
!= NextMapEntry
) {
2466 CopyMem (NextMapEntry
, CurrentMapEntry
, MapStepSize
* sizeof (INT32
));
2469 NextMapEntry
+= MapStepSize
;
2472 CurrentMapEntry
+= MapStepSize
;
2473 NewMapEntry
+= NewMapStepSize
;
2477 *CurrentMode
= Mode
;
2483 Sync the device's output mode to console splitter's mode list.
2485 @param Private Text Out Splitter pointer.
2486 @param TextOut Simple Text Output protocol pointer.
2490 ConSplitterSyncOutputMode (
2491 IN TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
,
2492 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
2495 INT32 CurrentMaxMode
;
2498 INT32
*TextOutModeMap
;
2501 TEXT_OUT_SPLITTER_QUERY_DATA
*TextOutQueryData
;
2508 // Must make sure that current mode won't change even if mode number changes
2510 CurrentMaxMode
= Private
->TextOutMode
.MaxMode
;
2511 TextOutModeMap
= Private
->TextOutModeMap
;
2512 StepSize
= Private
->TextOutListCount
;
2513 TextOutQueryData
= Private
->TextOutQueryData
;
2516 // Query all the mode that the newly added TextOut supports
2519 MapTable
= TextOutModeMap
+ Private
->CurrentNumberOfConsoles
;
2520 while (Mode
< TextOut
->Mode
->MaxMode
) {
2521 Status
= TextOut
->QueryMode (TextOut
, Mode
, &Columns
, &Rows
);
2523 if (EFI_ERROR (Status
)) {
2526 // If mode 1 (80x50) is not supported, make sure mode 1 in TextOutQueryData
2529 MapTable
[StepSize
] = Mode
;
2530 TextOutQueryData
[Mode
].Columns
= 0;
2531 TextOutQueryData
[Mode
].Rows
= 0;
2539 // Search the intersection map and QueryData database to see if they intersects
2542 while (Index
< CurrentMaxMode
) {
2543 QueryMode
= *(TextOutModeMap
+ Index
* StepSize
);
2544 if ((TextOutQueryData
[QueryMode
].Rows
== Rows
) && (TextOutQueryData
[QueryMode
].Columns
== Columns
)) {
2545 MapTable
[Index
* StepSize
] = Mode
;
2556 // Now search the TextOutModeMap table to find the intersection of supported
2557 // mode between ConSplitter and the newly added device.
2559 ConSplitterGetIntersection (
2564 &Private
->TextOutMode
.MaxMode
,
2565 &Private
->TextOutMode
.Mode
2572 Sync output device between ConOut and StdErr output.
2574 @retval EFI_SUCCESS Sync implemented successfully.
2575 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
2579 ConSplitterGetIntersectionBetweenConOutAndStrErr (
2583 UINTN ConOutNumOfConsoles
;
2584 UINTN StdErrNumOfConsoles
;
2585 TEXT_OUT_AND_GOP_DATA
*ConOutTextOutList
;
2586 TEXT_OUT_AND_GOP_DATA
*StdErrTextOutList
;
2590 UINTN ConOutColumns
;
2592 UINTN StdErrColumns
;
2593 INT32 ConOutMaxMode
;
2594 INT32 StdErrMaxMode
;
2599 INT32
*ConOutModeMap
;
2600 INT32
*StdErrModeMap
;
2601 INT32
*ConOutMapTable
;
2602 INT32
*StdErrMapTable
;
2603 TEXT_OUT_SPLITTER_QUERY_DATA
*ConOutQueryData
;
2604 TEXT_OUT_SPLITTER_QUERY_DATA
*StdErrQueryData
;
2605 UINTN ConOutStepSize
;
2606 UINTN StdErrStepSize
;
2607 BOOLEAN FoundTheSameTextOut
;
2608 UINTN ConOutMapTableSize
;
2609 UINTN StdErrMapTableSize
;
2611 ConOutNumOfConsoles
= mConOut
.CurrentNumberOfConsoles
;
2612 StdErrNumOfConsoles
= mStdErr
.CurrentNumberOfConsoles
;
2613 ConOutTextOutList
= mConOut
.TextOutList
;
2614 StdErrTextOutList
= mStdErr
.TextOutList
;
2617 FoundTheSameTextOut
= FALSE
;
2618 while ((Indexi
< ConOutNumOfConsoles
) && (!FoundTheSameTextOut
)) {
2620 while (Indexj
< StdErrNumOfConsoles
) {
2621 if (ConOutTextOutList
->TextOut
== StdErrTextOutList
->TextOut
) {
2622 FoundTheSameTextOut
= TRUE
;
2627 StdErrTextOutList
++;
2631 ConOutTextOutList
++;
2634 if (!FoundTheSameTextOut
) {
2639 // Must make sure that current mode won't change even if mode number changes
2641 ConOutMaxMode
= mConOut
.TextOutMode
.MaxMode
;
2642 ConOutModeMap
= mConOut
.TextOutModeMap
;
2643 ConOutStepSize
= mConOut
.TextOutListCount
;
2644 ConOutQueryData
= mConOut
.TextOutQueryData
;
2646 StdErrMaxMode
= mStdErr
.TextOutMode
.MaxMode
;
2647 StdErrModeMap
= mStdErr
.TextOutModeMap
;
2648 StdErrStepSize
= mStdErr
.TextOutListCount
;
2649 StdErrQueryData
= mStdErr
.TextOutQueryData
;
2652 // Allocate the map table and set the map table's index to -1.
2654 ConOutMapTableSize
= ConOutMaxMode
* sizeof (INT32
);
2655 ConOutMapTable
= AllocateZeroPool (ConOutMapTableSize
);
2656 if (ConOutMapTable
== NULL
) {
2657 return EFI_OUT_OF_RESOURCES
;
2660 SetMem (ConOutMapTable
, ConOutMapTableSize
, 0xFF);
2662 StdErrMapTableSize
= StdErrMaxMode
* sizeof (INT32
);
2663 StdErrMapTable
= AllocateZeroPool (StdErrMapTableSize
);
2664 if (StdErrMapTable
== NULL
) {
2665 return EFI_OUT_OF_RESOURCES
;
2668 SetMem (StdErrMapTable
, StdErrMapTableSize
, 0xFF);
2671 // Find the intersection of the two set of modes. If they actually intersect, the
2672 // corresponding entry in the map table is set to 1.
2675 while (Mode
< ConOutMaxMode
) {
2677 // Search the intersection map and QueryData database to see if they intersect
2680 ConOutMode
= *(ConOutModeMap
+ Mode
* ConOutStepSize
);
2681 ConOutRows
= ConOutQueryData
[ConOutMode
].Rows
;
2682 ConOutColumns
= ConOutQueryData
[ConOutMode
].Columns
;
2683 while (Index
< StdErrMaxMode
) {
2684 StdErrMode
= *(StdErrModeMap
+ Index
* StdErrStepSize
);
2685 StdErrRows
= StdErrQueryData
[StdErrMode
].Rows
;
2686 StdErrColumns
= StdErrQueryData
[StdErrMode
].Columns
;
2687 if ((StdErrRows
== ConOutRows
) && (StdErrColumns
== ConOutColumns
)) {
2688 ConOutMapTable
[Mode
] = 1;
2689 StdErrMapTable
[Index
] = 1;
2700 // Now search the TextOutModeMap table to find the intersection of supported
2701 // mode between ConSplitter and the newly added device.
2703 ConSplitterGetIntersection (
2706 mConOut
.TextOutListCount
,
2708 &(mConOut
.TextOutMode
.MaxMode
),
2709 &(mConOut
.TextOutMode
.Mode
)
2712 if (mConOut
.TextOutMode
.Mode
< 0) {
2713 mConOut
.TextOut
.SetMode (&(mConOut
.TextOut
), 0);
2716 ConSplitterGetIntersection (
2719 mStdErr
.TextOutListCount
,
2721 &(mStdErr
.TextOutMode
.MaxMode
),
2722 &(mStdErr
.TextOutMode
.Mode
)
2725 if (mStdErr
.TextOutMode
.Mode
< 0) {
2726 mStdErr
.TextOut
.SetMode (&(mStdErr
.TextOut
), 0);
2729 FreePool (ConOutMapTable
);
2730 FreePool (StdErrMapTable
);
2736 Add Graphics Output modes into Consplitter Text Out list.
2738 @param Private Text Out Splitter pointer.
2739 @param GraphicsOutput Graphics Output protocol pointer.
2740 @param UgaDraw UGA Draw protocol pointer.
2742 @retval EFI_SUCCESS Output mode added successfully.
2743 @retval other Failed to add output mode.
2747 ConSplitterAddGraphicsOutputMode (
2748 IN TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
,
2749 IN EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
,
2750 IN EFI_UGA_DRAW_PROTOCOL
*UgaDraw
2756 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*Mode
;
2758 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*Info
;
2759 EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE
*CurrentGraphicsOutputMode
;
2760 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*ModeBuffer
;
2761 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*MatchedMode
;
2764 BOOLEAN AlreadyExist
;
2765 UINT32 UgaHorizontalResolution
;
2766 UINT32 UgaVerticalResolution
;
2767 UINT32 UgaColorDepth
;
2768 UINT32 UgaRefreshRate
;
2770 ASSERT (GraphicsOutput
!= NULL
|| UgaDraw
!= NULL
);
2772 CurrentGraphicsOutputMode
= Private
->GraphicsOutput
.Mode
;
2776 Status
= EFI_SUCCESS
;
2778 if (Private
->CurrentNumberOfUgaDraw
!= 0) {
2780 // If any UGA device has already been added, then there is no need to
2781 // calculate intersection of display mode of different GOP/UGA device,
2782 // since only one display mode will be exported (i.e. user-defined mode)
2787 if (GraphicsOutput
!= NULL
) {
2788 if (Private
->CurrentNumberOfGraphicsOutput
== 0) {
2790 // This is the first Graphics Output device added
2792 CurrentGraphicsOutputMode
->MaxMode
= GraphicsOutput
->Mode
->MaxMode
;
2793 CurrentGraphicsOutputMode
->Mode
= GraphicsOutput
->Mode
->Mode
;
2794 CopyMem (CurrentGraphicsOutputMode
->Info
, GraphicsOutput
->Mode
->Info
, GraphicsOutput
->Mode
->SizeOfInfo
);
2795 CurrentGraphicsOutputMode
->SizeOfInfo
= GraphicsOutput
->Mode
->SizeOfInfo
;
2796 CurrentGraphicsOutputMode
->FrameBufferBase
= GraphicsOutput
->Mode
->FrameBufferBase
;
2797 CurrentGraphicsOutputMode
->FrameBufferSize
= GraphicsOutput
->Mode
->FrameBufferSize
;
2800 // Allocate resource for the private mode buffer
2802 ModeBuffer
= AllocatePool (sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
) * GraphicsOutput
->Mode
->MaxMode
);
2803 if (ModeBuffer
== NULL
) {
2804 return EFI_OUT_OF_RESOURCES
;
2807 FreePool (Private
->GraphicsOutputModeBuffer
);
2808 Private
->GraphicsOutputModeBuffer
= ModeBuffer
;
2811 // Store all supported display modes to the private mode buffer
2814 for (Index
= 0; Index
< GraphicsOutput
->Mode
->MaxMode
; Index
++) {
2816 // The Info buffer would be allocated by callee
2818 Status
= GraphicsOutput
->QueryMode (GraphicsOutput
, (UINT32
)Index
, &SizeOfInfo
, &Info
);
2819 if (EFI_ERROR (Status
)) {
2823 ASSERT (SizeOfInfo
<= sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
));
2824 CopyMem (Mode
, Info
, SizeOfInfo
);
2830 // Check intersection of display mode
2832 ModeBuffer
= AllocatePool (sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
) * CurrentGraphicsOutputMode
->MaxMode
);
2833 if (ModeBuffer
== NULL
) {
2834 return EFI_OUT_OF_RESOURCES
;
2837 MatchedMode
= ModeBuffer
;
2838 Mode
= &Private
->GraphicsOutputModeBuffer
[0];
2839 for (Index
= 0; Index
< CurrentGraphicsOutputMode
->MaxMode
; Index
++) {
2842 for (NumberIndex
= 0; NumberIndex
< GraphicsOutput
->Mode
->MaxMode
; NumberIndex
++) {
2844 // The Info buffer would be allocated by callee
2846 Status
= GraphicsOutput
->QueryMode (GraphicsOutput
, (UINT32
)NumberIndex
, &SizeOfInfo
, &Info
);
2847 if (EFI_ERROR (Status
)) {
2851 if ((Info
->HorizontalResolution
== Mode
->HorizontalResolution
) &&
2852 (Info
->VerticalResolution
== Mode
->VerticalResolution
))
2855 // If GOP device supports one mode in current mode buffer,
2856 // it will be added into matched mode buffer
2867 AlreadyExist
= FALSE
;
2870 // Check if GOP mode has been in the mode buffer, ModeBuffer = MatchedMode at begin.
2872 for (Info
= ModeBuffer
; Info
< MatchedMode
; Info
++) {
2873 if ((Info
->HorizontalResolution
== Mode
->HorizontalResolution
) &&
2874 (Info
->VerticalResolution
== Mode
->VerticalResolution
))
2876 AlreadyExist
= TRUE
;
2881 if (!AlreadyExist
) {
2882 CopyMem (MatchedMode
, Mode
, sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
));
2885 // Physical frame buffer is no longer available, change PixelFormat to PixelBltOnly
2887 MatchedMode
->Version
= 0;
2888 MatchedMode
->PixelFormat
= PixelBltOnly
;
2889 ZeroMem (&MatchedMode
->PixelInformation
, sizeof (EFI_PIXEL_BITMASK
));
2899 // Drop the old mode buffer, assign it to a new one
2901 FreePool (Private
->GraphicsOutputModeBuffer
);
2902 Private
->GraphicsOutputModeBuffer
= ModeBuffer
;
2905 // Physical frame buffer is no longer available when there are more than one physical GOP devices
2907 CurrentGraphicsOutputMode
->MaxMode
= (UINT32
)(((UINTN
)MatchedMode
- (UINTN
)ModeBuffer
) / sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
));
2908 CurrentGraphicsOutputMode
->Info
->PixelFormat
= PixelBltOnly
;
2909 ZeroMem (&CurrentGraphicsOutputMode
->Info
->PixelInformation
, sizeof (EFI_PIXEL_BITMASK
));
2910 CurrentGraphicsOutputMode
->SizeOfInfo
= sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
);
2911 CurrentGraphicsOutputMode
->FrameBufferBase
= (EFI_PHYSICAL_ADDRESS
)(UINTN
)NULL
;
2912 CurrentGraphicsOutputMode
->FrameBufferSize
= 0;
2916 // Graphics console driver can ensure the same mode for all GOP devices
2918 for (Index
= 0; Index
< CurrentGraphicsOutputMode
->MaxMode
; Index
++) {
2919 Mode
= &Private
->GraphicsOutputModeBuffer
[Index
];
2920 if ((Mode
->HorizontalResolution
== GraphicsOutput
->Mode
->Info
->HorizontalResolution
) &&
2921 (Mode
->VerticalResolution
== GraphicsOutput
->Mode
->Info
->VerticalResolution
))
2923 CurrentIndex
= Index
;
2928 if (Index
>= CurrentGraphicsOutputMode
->MaxMode
) {
2930 // if user defined mode is not found, set to default mode 800x600
2932 for (Index
= 0; Index
< CurrentGraphicsOutputMode
->MaxMode
; Index
++) {
2933 Mode
= &Private
->GraphicsOutputModeBuffer
[Index
];
2934 if ((Mode
->HorizontalResolution
== 800) && (Mode
->VerticalResolution
== 600)) {
2935 CurrentIndex
= Index
;
2940 } else if (UgaDraw
!= NULL
) {
2942 // Graphics console driver can ensure the same mode for all GOP devices
2943 // so we can get the current mode from this video device
2947 &UgaHorizontalResolution
,
2948 &UgaVerticalResolution
,
2953 CurrentGraphicsOutputMode
->MaxMode
= 1;
2954 Info
= CurrentGraphicsOutputMode
->Info
;
2956 Info
->HorizontalResolution
= UgaHorizontalResolution
;
2957 Info
->VerticalResolution
= UgaVerticalResolution
;
2958 Info
->PixelFormat
= PixelBltOnly
;
2959 Info
->PixelsPerScanLine
= UgaHorizontalResolution
;
2960 CurrentGraphicsOutputMode
->SizeOfInfo
= sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
);
2961 CurrentGraphicsOutputMode
->FrameBufferBase
= (EFI_PHYSICAL_ADDRESS
)(UINTN
)NULL
;
2962 CurrentGraphicsOutputMode
->FrameBufferSize
= 0;
2965 // Update the private mode buffer
2967 CopyMem (&Private
->GraphicsOutputModeBuffer
[0], Info
, sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
));
2970 // Only mode 0 is available to be set
2977 if (GraphicsOutput
!= NULL
) {
2978 Private
->CurrentNumberOfGraphicsOutput
++;
2981 if (UgaDraw
!= NULL
) {
2982 Private
->CurrentNumberOfUgaDraw
++;
2986 // Force GraphicsOutput mode to be set,
2989 Mode
= &Private
->GraphicsOutputModeBuffer
[CurrentIndex
];
2990 if ((GraphicsOutput
!= NULL
) &&
2991 (Mode
->HorizontalResolution
== CurrentGraphicsOutputMode
->Info
->HorizontalResolution
) &&
2992 (Mode
->VerticalResolution
== CurrentGraphicsOutputMode
->Info
->VerticalResolution
))
2994 CurrentGraphicsOutputMode
->Mode
= (UINT32
)CurrentIndex
;
2995 if ((Mode
->HorizontalResolution
!= GraphicsOutput
->Mode
->Info
->HorizontalResolution
) ||
2996 (Mode
->VerticalResolution
!= GraphicsOutput
->Mode
->Info
->VerticalResolution
))
2999 // If all existing video device has been set to common mode, only set new GOP device to
3002 for (NumberIndex
= 0; NumberIndex
< GraphicsOutput
->Mode
->MaxMode
; NumberIndex
++) {
3003 Status
= GraphicsOutput
->QueryMode (GraphicsOutput
, (UINT32
)NumberIndex
, &SizeOfInfo
, &Info
);
3004 if (EFI_ERROR (Status
)) {
3008 if ((Info
->HorizontalResolution
== Mode
->HorizontalResolution
) && (Info
->VerticalResolution
== Mode
->VerticalResolution
)) {
3016 Status
= GraphicsOutput
->SetMode (GraphicsOutput
, (UINT32
)NumberIndex
);
3020 // Current mode number may need update now, so set it to an invalid mode number
3022 CurrentGraphicsOutputMode
->Mode
= 0xffff;
3024 // Graphics console can ensure all GOP devices have the same mode which can be taken as current mode.
3026 Status
= Private
->GraphicsOutput
.SetMode (&Private
->GraphicsOutput
, (UINT32
)CurrentIndex
);
3027 if (EFI_ERROR (Status
)) {
3029 // If user defined mode is not valid for display device, set to the default mode 800x600.
3031 (Private
->GraphicsOutputModeBuffer
[0]).HorizontalResolution
= 800;
3032 (Private
->GraphicsOutputModeBuffer
[0]).VerticalResolution
= 600;
3033 Status
= Private
->GraphicsOutput
.SetMode (&Private
->GraphicsOutput
, 0);
3041 Set the current console out mode.
3043 This routine will get the current console mode information (column, row)
3044 from ConsoleOutMode variable and set it; if the variable does not exist,
3045 set to user defined console mode.
3047 @param Private Consplitter Text Out pointer.
3051 ConsplitterSetConsoleOutMode (
3052 IN TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
3062 CONSOLE_OUT_MODE ModeInfo
;
3063 CONSOLE_OUT_MODE MaxModeInfo
;
3064 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
;
3068 TextOut
= &Private
->TextOut
;
3069 MaxMode
= (UINTN
)(TextOut
->Mode
->MaxMode
);
3071 MaxModeInfo
.Column
= 0;
3072 MaxModeInfo
.Row
= 0;
3073 ModeInfo
.Column
= PcdGet32 (PcdConOutColumn
);
3074 ModeInfo
.Row
= PcdGet32 (PcdConOutRow
);
3077 // To find the prefer mode and basic mode from Text Out mode list
3079 for (Mode
= 0; Mode
< MaxMode
; Mode
++) {
3080 Status
= TextOut
->QueryMode (TextOut
, Mode
, &Col
, &Row
);
3081 if (!EFI_ERROR (Status
)) {
3082 if ((ModeInfo
.Column
!= 0) && (ModeInfo
.Row
!= 0)) {
3084 // Use user defined column and row
3086 if ((Col
== ModeInfo
.Column
) && (Row
== ModeInfo
.Row
)) {
3091 // If user sets PcdConOutColumn or PcdConOutRow to 0,
3092 // find and set the highest text mode.
3094 if ((Col
>= MaxModeInfo
.Column
) && (Row
>= MaxModeInfo
.Row
)) {
3095 MaxModeInfo
.Column
= Col
;
3096 MaxModeInfo
.Row
= Row
;
3101 if ((Col
== 80) && (Row
== 25)) {
3108 // Set prefer mode to Text Out devices.
3110 Status
= TextOut
->SetMode (TextOut
, PreferMode
);
3111 if (EFI_ERROR (Status
)) {
3113 // if current mode setting is failed, default 80x25 mode will be set.
3115 Status
= TextOut
->SetMode (TextOut
, BaseMode
);
3116 ASSERT (!EFI_ERROR (Status
));
3118 Status
= PcdSet32S (PcdConOutColumn
, 80);
3119 ASSERT (!EFI_ERROR (Status
));
3120 Status
= PcdSet32S (PcdConOutRow
, 25);
3121 ASSERT (!EFI_ERROR (Status
));
3128 Add Text Output Device in Consplitter Text Output list.
3130 @param Private Text Out Splitter pointer.
3131 @param TextOut Simple Text Output protocol pointer.
3132 @param GraphicsOutput Graphics Output protocol pointer.
3133 @param UgaDraw UGA Draw protocol pointer.
3135 @retval EFI_SUCCESS Text Output Device added successfully.
3136 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
3140 ConSplitterTextOutAddDevice (
3141 IN TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
,
3142 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
,
3143 IN EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
,
3144 IN EFI_UGA_DRAW_PROTOCOL
*UgaDraw
3148 UINTN CurrentNumOfConsoles
;
3150 UINT32 UgaHorizontalResolution
;
3151 UINT32 UgaVerticalResolution
;
3152 UINT32 UgaColorDepth
;
3153 UINT32 UgaRefreshRate
;
3154 TEXT_OUT_AND_GOP_DATA
*TextAndGop
;
3156 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*Info
;
3157 EFI_STATUS DeviceStatus
;
3159 Status
= EFI_SUCCESS
;
3160 CurrentNumOfConsoles
= Private
->CurrentNumberOfConsoles
;
3161 Private
->AddingConOutDevice
= TRUE
;
3164 // If the Text Out List is full, enlarge it by calling ConSplitterGrowBuffer().
3166 while (CurrentNumOfConsoles
>= Private
->TextOutListCount
) {
3167 Status
= ConSplitterGrowBuffer (
3168 sizeof (TEXT_OUT_AND_GOP_DATA
),
3169 &Private
->TextOutListCount
,
3170 (VOID
**)&Private
->TextOutList
3172 if (EFI_ERROR (Status
)) {
3173 return EFI_OUT_OF_RESOURCES
;
3177 // Also need to reallocate the TextOutModeMap table
3179 Status
= ConSplitterGrowMapTable (Private
);
3180 if (EFI_ERROR (Status
)) {
3181 return EFI_OUT_OF_RESOURCES
;
3185 TextAndGop
= &Private
->TextOutList
[CurrentNumOfConsoles
];
3187 TextAndGop
->TextOut
= TextOut
;
3188 TextAndGop
->GraphicsOutput
= GraphicsOutput
;
3189 TextAndGop
->UgaDraw
= UgaDraw
;
3191 if (CurrentNumOfConsoles
== 0) {
3193 // Add the first device's output mode to console splitter's mode list
3195 Status
= ConSplitterAddOutputMode (Private
, TextOut
);
3197 ConSplitterSyncOutputMode (Private
, TextOut
);
3200 Private
->CurrentNumberOfConsoles
++;
3203 // Scan both TextOutList, for the intersection TextOut device
3204 // maybe both ConOut and StdErr incorporate the same Text Out
3205 // device in them, thus the output of both should be synced.
3207 ConSplitterGetIntersectionBetweenConOutAndStrErr ();
3209 MaxMode
= Private
->TextOutMode
.MaxMode
;
3210 ASSERT (MaxMode
>= 1);
3212 DeviceStatus
= EFI_DEVICE_ERROR
;
3213 Status
= EFI_DEVICE_ERROR
;
3216 // This device display mode will be added into Graphics Ouput modes.
3218 if ((GraphicsOutput
!= NULL
) || (UgaDraw
!= NULL
)) {
3219 DeviceStatus
= ConSplitterAddGraphicsOutputMode (Private
, GraphicsOutput
, UgaDraw
);
3222 if (FeaturePcdGet (PcdConOutUgaSupport
)) {
3224 // If UGA is produced by Consplitter
3226 if (GraphicsOutput
!= NULL
) {
3227 Status
= GraphicsOutput
->QueryMode (GraphicsOutput
, GraphicsOutput
->Mode
->Mode
, &SizeOfInfo
, &Info
);
3228 if (EFI_ERROR (Status
)) {
3232 ASSERT (SizeOfInfo
<= sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
));
3234 UgaHorizontalResolution
= Info
->HorizontalResolution
;
3235 UgaVerticalResolution
= Info
->VerticalResolution
;
3238 } else if (UgaDraw
!= NULL
) {
3239 Status
= UgaDraw
->GetMode (
3241 &UgaHorizontalResolution
,
3242 &UgaVerticalResolution
,
3246 if (!EFI_ERROR (Status
) && EFI_ERROR (DeviceStatus
)) {
3248 // if GetMode is successfully and UGA device hasn't been set, set it
3250 Status
= ConSplitterUgaDrawSetMode (
3252 UgaHorizontalResolution
,
3253 UgaVerticalResolution
,
3260 // If GetMode/SetMode is failed, set to 800x600 mode
3262 if (EFI_ERROR (Status
)) {
3263 Status
= ConSplitterUgaDrawSetMode (
3274 if (((!EFI_ERROR (DeviceStatus
)) || (!EFI_ERROR (Status
))) &&
3275 ((Private
->CurrentNumberOfGraphicsOutput
+ Private
->CurrentNumberOfUgaDraw
) == 1))
3277 if (!FeaturePcdGet (PcdConOutGopSupport
)) {
3279 // If Graphics Outpurt protocol not supported, UGA Draw protocol is installed
3280 // on the virtual handle.
3282 Status
= gBS
->InstallMultipleProtocolInterfaces (
3283 &mConOut
.VirtualHandle
,
3284 &gEfiUgaDrawProtocolGuid
,
3288 } else if (!FeaturePcdGet (PcdConOutUgaSupport
)) {
3290 // If UGA Draw protocol not supported, Graphics Output Protocol is installed
3291 // on virtual handle.
3293 Status
= gBS
->InstallMultipleProtocolInterfaces (
3294 &mConOut
.VirtualHandle
,
3295 &gEfiGraphicsOutputProtocolGuid
,
3296 &mConOut
.GraphicsOutput
,
3301 // Boot Graphics Output protocol and UGA Draw protocol are supported,
3302 // both they will be installed on virtual handle.
3304 Status
= gBS
->InstallMultipleProtocolInterfaces (
3305 &mConOut
.VirtualHandle
,
3306 &gEfiGraphicsOutputProtocolGuid
,
3307 &mConOut
.GraphicsOutput
,
3308 &gEfiUgaDrawProtocolGuid
,
3316 // After adding new console device, all existing console devices should be
3317 // synced to the current shared mode.
3319 ConsplitterSetConsoleOutMode (Private
);
3321 Private
->AddingConOutDevice
= FALSE
;
3327 Remove Text Out Device in Consplitter Text Out list.
3329 @param Private Text Out Splitter pointer.
3330 @param TextOut Simple Text Output Pointer protocol pointer.
3332 @retval EFI_SUCCESS Text Out Device removed successfully.
3333 @retval EFI_NOT_FOUND No Text Out Device found.
3337 ConSplitterTextOutDeleteDevice (
3338 IN TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
,
3339 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
3343 UINTN CurrentNumOfConsoles
;
3344 TEXT_OUT_AND_GOP_DATA
*TextOutList
;
3348 // Remove the specified text-out device data structure from the Text out List,
3349 // and rearrange the remaining data structures in the Text out List.
3351 CurrentNumOfConsoles
= Private
->CurrentNumberOfConsoles
;
3352 Index
= (INT32
)CurrentNumOfConsoles
- 1;
3353 TextOutList
= Private
->TextOutList
;
3354 while (Index
>= 0) {
3355 if (TextOutList
->TextOut
== TextOut
) {
3356 if (TextOutList
->UgaDraw
!= NULL
) {
3357 Private
->CurrentNumberOfUgaDraw
--;
3360 if (TextOutList
->GraphicsOutput
!= NULL
) {
3361 Private
->CurrentNumberOfGraphicsOutput
--;
3364 CopyMem (TextOutList
, TextOutList
+ 1, sizeof (TEXT_OUT_AND_GOP_DATA
) * Index
);
3365 CurrentNumOfConsoles
--;
3374 // The specified TextOut is not managed by the ConSplitter driver
3377 return EFI_NOT_FOUND
;
3380 if ((Private
->CurrentNumberOfGraphicsOutput
== 0) && (Private
->CurrentNumberOfUgaDraw
== 0)) {
3382 // If there is not any physical GOP and UGA device in system,
3383 // Consplitter GOP or UGA protocol will be uninstalled
3385 if (!FeaturePcdGet (PcdConOutGopSupport
)) {
3386 Status
= gBS
->UninstallProtocolInterface (
3387 Private
->VirtualHandle
,
3388 &gEfiUgaDrawProtocolGuid
,
3391 } else if (!FeaturePcdGet (PcdConOutUgaSupport
)) {
3392 Status
= gBS
->UninstallProtocolInterface (
3393 Private
->VirtualHandle
,
3394 &gEfiGraphicsOutputProtocolGuid
,
3395 &Private
->GraphicsOutput
3398 Status
= gBS
->UninstallMultipleProtocolInterfaces (
3399 Private
->VirtualHandle
,
3400 &gEfiUgaDrawProtocolGuid
,
3402 &gEfiGraphicsOutputProtocolGuid
,
3403 &Private
->GraphicsOutput
,
3409 if (CurrentNumOfConsoles
== 0) {
3411 // If the number of consoles is zero, reset all parameters
3413 Private
->CurrentNumberOfConsoles
= 0;
3414 Private
->TextOutMode
.MaxMode
= 1;
3415 Private
->TextOutQueryData
[0].Columns
= 80;
3416 Private
->TextOutQueryData
[0].Rows
= 25;
3417 TextOutSetMode (Private
, 0);
3423 // Max Mode is really an intersection of the QueryMode command to all
3424 // devices. So we must copy the QueryMode of the first device to
3428 Private
->TextOutQueryData
,
3429 Private
->TextOutQueryDataCount
* sizeof (TEXT_OUT_SPLITTER_QUERY_DATA
)
3432 FreePool (Private
->TextOutModeMap
);
3433 Private
->TextOutModeMap
= NULL
;
3434 TextOutList
= Private
->TextOutList
;
3437 // Add the first TextOut to the QueryData array and ModeMap table
3439 Status
= ConSplitterAddOutputMode (Private
, TextOutList
->TextOut
);
3442 // Now add one by one
3445 Private
->CurrentNumberOfConsoles
= 1;
3447 while ((UINTN
)Index
< CurrentNumOfConsoles
) {
3448 ConSplitterSyncOutputMode (Private
, TextOutList
->TextOut
);
3450 Private
->CurrentNumberOfConsoles
++;
3454 ConSplitterGetIntersectionBetweenConOutAndStrErr ();
3460 Reset the input device and optionally run diagnostics
3462 @param This Protocol instance pointer.
3463 @param ExtendedVerification Driver may perform diagnostics on reset.
3465 @retval EFI_SUCCESS The device was reset.
3466 @retval EFI_DEVICE_ERROR The device is not functioning properly and could
3472 ConSplitterTextInReset (
3473 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*This
,
3474 IN BOOLEAN ExtendedVerification
3478 EFI_STATUS ReturnStatus
;
3479 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3482 Private
= TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
3484 Private
->KeyEventSignalState
= FALSE
;
3487 // return the worst status met
3489 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
3490 Status
= Private
->TextInList
[Index
]->Reset (
3491 Private
->TextInList
[Index
],
3492 ExtendedVerification
3494 if (EFI_ERROR (Status
)) {
3495 ReturnStatus
= Status
;
3499 if (!EFI_ERROR (ReturnStatus
)) {
3500 ToggleStateSyncReInitialization (Private
);
3502 // Empty the key queue.
3504 Private
->CurrentNumberOfKeys
= 0;
3507 return ReturnStatus
;
3511 Dequeue the saved key from internal key queue.
3513 @param Private Protocol instance pointer.
3514 @param KeyData A pointer to a buffer that is filled in with the
3515 keystroke state data for the key that was
3517 @retval EFI_NOT_FOUND Queue is empty.
3518 @retval EFI_SUCCESS First key is dequeued and returned.
3521 ConSplitterTextInExDequeueKey (
3522 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
3523 OUT EFI_KEY_DATA
*KeyData
3526 if (Private
->CurrentNumberOfKeys
== 0) {
3527 return EFI_NOT_FOUND
;
3531 // Return the first saved key.
3533 CopyMem (KeyData
, &Private
->KeyQueue
[0], sizeof (EFI_KEY_DATA
));
3534 Private
->CurrentNumberOfKeys
--;
3536 &Private
->KeyQueue
[0],
3537 &Private
->KeyQueue
[1],
3538 Private
->CurrentNumberOfKeys
* sizeof (EFI_KEY_DATA
)
3544 Reads the next keystroke from the input device. The WaitForKey Event can
3545 be used to test for existence of a keystroke via WaitForEvent () call.
3547 @param Private Protocol instance pointer.
3548 @param Key Driver may perform diagnostics on reset.
3550 @retval EFI_SUCCESS The keystroke information was returned.
3551 @retval EFI_NOT_READY There was no keystroke data availiable.
3552 @retval EFI_DEVICE_ERROR The keydtroke information was not returned due
3558 ConSplitterTextInPrivateReadKeyStroke (
3559 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
3560 OUT EFI_INPUT_KEY
*Key
3565 EFI_KEY_DATA KeyData
;
3568 // Return the first saved non-NULL key.
3571 Status
= ConSplitterTextInExDequeueKey (Private
, &KeyData
);
3572 if (EFI_ERROR (Status
)) {
3576 if ((KeyData
.Key
.ScanCode
!= CHAR_NULL
) || (KeyData
.Key
.UnicodeChar
!= SCAN_NULL
)) {
3577 CopyMem (Key
, &KeyData
.Key
, sizeof (EFI_INPUT_KEY
));
3582 Key
->UnicodeChar
= 0;
3583 Key
->ScanCode
= SCAN_NULL
;
3586 // if no physical console input device exists, return EFI_NOT_READY;
3587 // if any physical console input device has key input,
3588 // return the key and EFI_SUCCESS.
3590 for (Index
= 0; Index
< Private
->CurrentNumberOfConsoles
;) {
3591 Status
= Private
->TextInList
[Index
]->ReadKeyStroke (
3592 Private
->TextInList
[Index
],
3595 if (!EFI_ERROR (Status
)) {
3597 // If it is not partial keystorke, return the key. Otherwise, continue
3598 // to read key from THIS physical console input device.
3600 if ((KeyData
.Key
.ScanCode
!= CHAR_NULL
) || (KeyData
.Key
.UnicodeChar
!= SCAN_NULL
)) {
3601 CopyMem (Key
, &KeyData
.Key
, sizeof (EFI_INPUT_KEY
));
3606 // Continue to read key from NEXT physical console input device.
3612 return EFI_NOT_READY
;
3616 Reads the next keystroke from the input device. The WaitForKey Event can
3617 be used to test for existence of a keystroke via WaitForEvent () call.
3619 @param This Protocol instance pointer.
3620 @param Key Driver may perform diagnostics on reset.
3622 @retval EFI_SUCCESS The keystroke information was returned.
3623 @retval EFI_NOT_READY There was no keystroke data availiable.
3624 @retval EFI_DEVICE_ERROR The keydtroke information was not returned due
3630 ConSplitterTextInReadKeyStroke (
3631 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*This
,
3632 OUT EFI_INPUT_KEY
*Key
3635 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3637 Private
= TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
3639 Private
->KeyEventSignalState
= FALSE
;
3642 // Signal ConnectConIn event on first call in Lazy ConIn mode
3644 if (!mConInIsConnect
&& PcdGetBool (PcdConInConnectOnDemand
)) {
3645 DEBUG ((DEBUG_INFO
, "Connect ConIn in first ReadKeyStoke in Lazy ConIn mode.\n"));
3646 gBS
->SignalEvent (Private
->ConnectConInEvent
);
3647 mConInIsConnect
= TRUE
;
3650 return ConSplitterTextInPrivateReadKeyStroke (Private
, Key
);
3654 This event aggregates all the events of the ConIn devices in the spliter.
3656 If any events of physical ConIn devices are signaled, signal the ConIn
3657 spliter event. This will cause the calling code to call
3658 ConSplitterTextInReadKeyStroke ().
3660 @param Event The Event associated with callback.
3661 @param Context Context registered when Event was created.
3666 ConSplitterTextInWaitForKey (
3672 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3675 Private
= (TEXT_IN_SPLITTER_PRIVATE_DATA
*)Context
;
3677 if (Private
->KeyEventSignalState
) {
3679 // If KeyEventSignalState is flagged before, and not cleared by Reset() or ReadKeyStroke()
3681 gBS
->SignalEvent (Event
);
3686 // If any physical console input device has key input, signal the event.
3688 for (Index
= 0; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
3689 Status
= gBS
->CheckEvent (Private
->TextInList
[Index
]->WaitForKey
);
3690 if (!EFI_ERROR (Status
)) {
3691 gBS
->SignalEvent (Event
);
3692 Private
->KeyEventSignalState
= TRUE
;
3698 Test if the key has been registered on input device.
3700 @param RegsiteredData A pointer to a buffer that is filled in with the
3701 keystroke state data for the key that was
3703 @param InputData A pointer to a buffer that is filled in with the
3704 keystroke state data for the key that was
3707 @retval TRUE Key be pressed matches a registered key.
3708 @retval FALSE Match failed.
3713 IN EFI_KEY_DATA
*RegsiteredData
,
3714 IN EFI_KEY_DATA
*InputData
3717 ASSERT (RegsiteredData
!= NULL
&& InputData
!= NULL
);
3719 if ((RegsiteredData
->Key
.ScanCode
!= InputData
->Key
.ScanCode
) ||
3720 (RegsiteredData
->Key
.UnicodeChar
!= InputData
->Key
.UnicodeChar
))
3726 // Assume KeyShiftState/KeyToggleState = 0 in Registered key data means these state could be ignored.
3728 if ((RegsiteredData
->KeyState
.KeyShiftState
!= 0) &&
3729 (RegsiteredData
->KeyState
.KeyShiftState
!= InputData
->KeyState
.KeyShiftState
))
3734 if ((RegsiteredData
->KeyState
.KeyToggleState
!= 0) &&
3735 (RegsiteredData
->KeyState
.KeyToggleState
!= InputData
->KeyState
.KeyToggleState
))
3744 Reset the input device and optionally run diagnostics
3746 @param This Protocol instance pointer.
3747 @param ExtendedVerification Driver may perform diagnostics on reset.
3749 @retval EFI_SUCCESS The device was reset.
3750 @retval EFI_DEVICE_ERROR The device is not functioning properly and could
3756 ConSplitterTextInResetEx (
3757 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*This
,
3758 IN BOOLEAN ExtendedVerification
3762 EFI_STATUS ReturnStatus
;
3763 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3766 Private
= TEXT_IN_EX_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
3768 Private
->KeyEventSignalState
= FALSE
;
3771 // return the worst status met
3773 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfExConsoles
; Index
++) {
3774 Status
= Private
->TextInExList
[Index
]->Reset (
3775 Private
->TextInExList
[Index
],
3776 ExtendedVerification
3778 if (EFI_ERROR (Status
)) {
3779 ReturnStatus
= Status
;
3783 if (!EFI_ERROR (ReturnStatus
)) {
3784 ToggleStateSyncReInitialization (Private
);
3786 // Empty the key queue.
3788 Private
->CurrentNumberOfKeys
= 0;
3791 return ReturnStatus
;
3795 Reads the next keystroke from the input device. The WaitForKey Event can
3796 be used to test for existence of a keystroke via WaitForEvent () call.
3798 @param This Protocol instance pointer.
3799 @param KeyData A pointer to a buffer that is filled in with the
3800 keystroke state data for the key that was
3803 @retval EFI_SUCCESS The keystroke information was returned.
3804 @retval EFI_NOT_READY There was no keystroke data availiable.
3805 @retval EFI_DEVICE_ERROR The keystroke information was not returned due
3807 @retval EFI_INVALID_PARAMETER KeyData is NULL.
3812 ConSplitterTextInReadKeyStrokeEx (
3813 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*This
,
3814 OUT EFI_KEY_DATA
*KeyData
3817 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3820 EFI_KEY_STATE KeyState
;
3821 EFI_KEY_DATA CurrentKeyData
;
3823 if (KeyData
== NULL
) {
3824 return EFI_INVALID_PARAMETER
;
3827 Private
= TEXT_IN_EX_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
3829 Private
->KeyEventSignalState
= FALSE
;
3832 // Signal ConnectConIn event on first call in Lazy ConIn mode
3834 if (!mConInIsConnect
&& PcdGetBool (PcdConInConnectOnDemand
)) {
3835 DEBUG ((DEBUG_INFO
, "Connect ConIn in first ReadKeyStoke in Lazy ConIn mode.\n"));
3836 gBS
->SignalEvent (Private
->ConnectConInEvent
);
3837 mConInIsConnect
= TRUE
;
3841 // Return the first saved key.
3843 Status
= ConSplitterTextInExDequeueKey (Private
, KeyData
);
3844 if (!EFI_ERROR (Status
)) {
3848 ASSERT (Private
->CurrentNumberOfKeys
== 0);
3850 ZeroMem (&KeyState
, sizeof (KeyState
));
3853 // Iterate through all physical consoles to get key state.
3854 // Some physical consoles may return valid key.
3855 // Queue the valid keys.
3857 for (Index
= 0; Index
< Private
->CurrentNumberOfExConsoles
; Index
++) {
3858 ZeroMem (&CurrentKeyData
, sizeof (EFI_KEY_DATA
));
3859 Status
= Private
->TextInExList
[Index
]->ReadKeyStrokeEx (
3860 Private
->TextInExList
[Index
],
3863 if (EFI_ERROR (Status
) && (Status
!= EFI_NOT_READY
)) {
3868 // Consolidate the key state from all physical consoles.
3870 if ((CurrentKeyData
.KeyState
.KeyShiftState
& EFI_SHIFT_STATE_VALID
) != 0) {
3871 KeyState
.KeyShiftState
|= CurrentKeyData
.KeyState
.KeyShiftState
;
3874 if ((CurrentKeyData
.KeyState
.KeyToggleState
& EFI_TOGGLE_STATE_VALID
) != 0) {
3875 KeyState
.KeyToggleState
|= CurrentKeyData
.KeyState
.KeyToggleState
;
3878 if (!EFI_ERROR (Status
)) {
3880 // If virtual KeyState has been required to be exposed, or it is not
3881 // partial keystorke, queue the key.
3882 // It's possible that user presses at multiple keyboards at the same moment,
3883 // Private->KeyQueue[] are the storage to save all the keys.
3885 if ((Private
->VirtualKeyStateExported
) ||
3886 (CurrentKeyData
.Key
.ScanCode
!= CHAR_NULL
) ||
3887 (CurrentKeyData
.Key
.UnicodeChar
!= SCAN_NULL
))
3890 &Private
->KeyQueue
[Private
->CurrentNumberOfKeys
],
3892 sizeof (EFI_KEY_DATA
)
3894 Private
->CurrentNumberOfKeys
++;
3900 // Consolidate the key state for all keys in Private->KeyQueue[]
3902 for (Index
= 0; Index
< Private
->CurrentNumberOfKeys
; Index
++) {
3903 CopyMem (&Private
->KeyQueue
[Index
].KeyState
, &KeyState
, sizeof (EFI_KEY_STATE
));
3907 // Return the first saved key.
3909 Status
= ConSplitterTextInExDequeueKey (Private
, KeyData
);
3910 if (!EFI_ERROR (Status
)) {
3915 // Always return the key state even there is no key pressed.
3917 ZeroMem (&KeyData
->Key
, sizeof (KeyData
->Key
));
3918 CopyMem (&KeyData
->KeyState
, &KeyState
, sizeof (KeyData
->KeyState
));
3919 return EFI_NOT_READY
;
3923 Set certain state for the input device.
3925 @param This Protocol instance pointer.
3926 @param KeyToggleState A pointer to the EFI_KEY_TOGGLE_STATE to set the
3927 state for the input device.
3929 @retval EFI_SUCCESS The device state was set successfully.
3930 @retval EFI_DEVICE_ERROR The device is not functioning correctly and
3931 could not have the setting adjusted.
3932 @retval EFI_UNSUPPORTED The device does not have the ability to set its
3934 @retval EFI_INVALID_PARAMETER KeyToggleState is NULL.
3939 ConSplitterTextInSetState (
3940 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*This
,
3941 IN EFI_KEY_TOGGLE_STATE
*KeyToggleState
3944 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3947 EFI_KEY_TOGGLE_STATE PhysicalKeyToggleState
;
3949 if (KeyToggleState
== NULL
) {
3950 return EFI_INVALID_PARAMETER
;
3953 Private
= TEXT_IN_EX_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
3956 // Always turn on physical TextInEx partial key report for
3957 // toggle state sync.
3959 PhysicalKeyToggleState
= *KeyToggleState
| EFI_KEY_STATE_EXPOSED
;
3962 // if no physical console input device exists, return EFI_SUCCESS;
3963 // otherwise return the status of setting state of physical console input device
3965 for (Index
= 0; Index
< Private
->CurrentNumberOfExConsoles
; Index
++) {
3966 Status
= Private
->TextInExList
[Index
]->SetState (
3967 Private
->TextInExList
[Index
],
3968 &PhysicalKeyToggleState
3970 if (EFI_ERROR (Status
)) {
3976 // Record the physical KeyToggleState.
3978 Private
->PhysicalKeyToggleState
= PhysicalKeyToggleState
;
3980 // Get if virtual KeyState has been required to be exposed.
3982 Private
->VirtualKeyStateExported
= (((*KeyToggleState
) & EFI_KEY_STATE_EXPOSED
) != 0);
3988 Register a notification function for a particular keystroke for the input device.
3990 @param This Protocol instance pointer.
3991 @param KeyData A pointer to a buffer that is filled in with
3992 the keystroke information for the key that was
3993 pressed. If KeyData.Key, KeyData.KeyState.KeyToggleState
3994 and KeyData.KeyState.KeyShiftState are 0, then any incomplete
3995 keystroke will trigger a notification of the KeyNotificationFunction.
3996 @param KeyNotificationFunction Points to the function to be called when the key
3997 sequence is typed specified by KeyData. This notification function
3998 should be called at <=TPL_CALLBACK.
3999 @param NotifyHandle Points to the unique handle assigned to the
4000 registered notification.
4002 @retval EFI_SUCCESS The notification function was registered
4004 @retval EFI_OUT_OF_RESOURCES Unable to allocate resources for necessary data
4006 @retval EFI_INVALID_PARAMETER KeyData or KeyNotificationFunction or NotifyHandle is NULL.
4011 ConSplitterTextInRegisterKeyNotify (
4012 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*This
,
4013 IN EFI_KEY_DATA
*KeyData
,
4014 IN EFI_KEY_NOTIFY_FUNCTION KeyNotificationFunction
,
4015 OUT VOID
**NotifyHandle
4018 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
4021 TEXT_IN_EX_SPLITTER_NOTIFY
*NewNotify
;
4023 TEXT_IN_EX_SPLITTER_NOTIFY
*CurrentNotify
;
4025 if ((KeyData
== NULL
) || (NotifyHandle
== NULL
) || (KeyNotificationFunction
== NULL
)) {
4026 return EFI_INVALID_PARAMETER
;
4029 Private
= TEXT_IN_EX_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4032 // Return EFI_SUCCESS if the (KeyData, NotificationFunction) is already registered.
4034 for (Link
= Private
->NotifyList
.ForwardLink
; Link
!= &Private
->NotifyList
; Link
= Link
->ForwardLink
) {
4035 CurrentNotify
= TEXT_IN_EX_SPLITTER_NOTIFY_FROM_THIS (Link
);
4036 if (IsKeyRegistered (&CurrentNotify
->KeyData
, KeyData
)) {
4037 if (CurrentNotify
->KeyNotificationFn
== KeyNotificationFunction
) {
4038 *NotifyHandle
= CurrentNotify
;
4045 // Allocate resource to save the notification function
4047 NewNotify
= (TEXT_IN_EX_SPLITTER_NOTIFY
*)AllocateZeroPool (sizeof (TEXT_IN_EX_SPLITTER_NOTIFY
));
4048 if (NewNotify
== NULL
) {
4049 return EFI_OUT_OF_RESOURCES
;
4052 NewNotify
->NotifyHandleList
= (VOID
**)AllocateZeroPool (sizeof (VOID
*) * Private
->TextInExListCount
);
4053 if (NewNotify
->NotifyHandleList
== NULL
) {
4054 gBS
->FreePool (NewNotify
);
4055 return EFI_OUT_OF_RESOURCES
;
4058 NewNotify
->Signature
= TEXT_IN_EX_SPLITTER_NOTIFY_SIGNATURE
;
4059 NewNotify
->KeyNotificationFn
= KeyNotificationFunction
;
4060 CopyMem (&NewNotify
->KeyData
, KeyData
, sizeof (EFI_KEY_DATA
));
4063 // Return the wrong status of registering key notify of
4064 // physical console input device if meet problems
4066 for (Index
= 0; Index
< Private
->CurrentNumberOfExConsoles
; Index
++) {
4067 Status
= Private
->TextInExList
[Index
]->RegisterKeyNotify (
4068 Private
->TextInExList
[Index
],
4070 KeyNotificationFunction
,
4071 &NewNotify
->NotifyHandleList
[Index
]
4073 if (EFI_ERROR (Status
)) {
4075 // Un-register the key notify on all physical console input devices
4077 while (Index
-- != 0) {
4078 Private
->TextInExList
[Index
]->UnregisterKeyNotify (
4079 Private
->TextInExList
[Index
],
4080 NewNotify
->NotifyHandleList
[Index
]
4084 gBS
->FreePool (NewNotify
->NotifyHandleList
);
4085 gBS
->FreePool (NewNotify
);
4090 InsertTailList (&Private
->NotifyList
, &NewNotify
->NotifyEntry
);
4092 *NotifyHandle
= NewNotify
;
4098 Remove a registered notification function from a particular keystroke.
4100 @param This Protocol instance pointer.
4101 @param NotificationHandle The handle of the notification function being
4104 @retval EFI_SUCCESS The notification function was unregistered
4106 @retval EFI_INVALID_PARAMETER The NotificationHandle is invalid.
4111 ConSplitterTextInUnregisterKeyNotify (
4112 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*This
,
4113 IN VOID
*NotificationHandle
4116 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
4118 TEXT_IN_EX_SPLITTER_NOTIFY
*CurrentNotify
;
4121 if (NotificationHandle
== NULL
) {
4122 return EFI_INVALID_PARAMETER
;
4125 Private
= TEXT_IN_EX_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4127 for (Link
= Private
->NotifyList
.ForwardLink
; Link
!= &Private
->NotifyList
; Link
= Link
->ForwardLink
) {
4128 CurrentNotify
= TEXT_IN_EX_SPLITTER_NOTIFY_FROM_THIS (Link
);
4129 if (CurrentNotify
== NotificationHandle
) {
4130 for (Index
= 0; Index
< Private
->CurrentNumberOfExConsoles
; Index
++) {
4131 Private
->TextInExList
[Index
]->UnregisterKeyNotify (
4132 Private
->TextInExList
[Index
],
4133 CurrentNotify
->NotifyHandleList
[Index
]
4137 RemoveEntryList (&CurrentNotify
->NotifyEntry
);
4139 gBS
->FreePool (CurrentNotify
->NotifyHandleList
);
4140 gBS
->FreePool (CurrentNotify
);
4146 // NotificationHandle is not found in database
4148 return EFI_INVALID_PARAMETER
;
4152 Reset the input device and optionally run diagnostics
4154 @param This Protocol instance pointer.
4155 @param ExtendedVerification Driver may perform diagnostics on reset.
4157 @retval EFI_SUCCESS The device was reset.
4158 @retval EFI_DEVICE_ERROR The device is not functioning properly and could
4164 ConSplitterSimplePointerReset (
4165 IN EFI_SIMPLE_POINTER_PROTOCOL
*This
,
4166 IN BOOLEAN ExtendedVerification
4170 EFI_STATUS ReturnStatus
;
4171 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
4174 Private
= TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_SIMPLE_POINTER_THIS (This
);
4176 Private
->InputEventSignalState
= FALSE
;
4178 if (Private
->CurrentNumberOfPointers
== 0) {
4183 // return the worst status met
4185 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfPointers
; Index
++) {
4186 Status
= Private
->PointerList
[Index
]->Reset (
4187 Private
->PointerList
[Index
],
4188 ExtendedVerification
4190 if (EFI_ERROR (Status
)) {
4191 ReturnStatus
= Status
;
4195 return ReturnStatus
;
4199 Reads the next keystroke from the input device. The WaitForKey Event can
4200 be used to test for existence of a keystroke via WaitForEvent () call.
4202 @param Private Protocol instance pointer.
4203 @param State The state information of simple pointer device.
4205 @retval EFI_SUCCESS The keystroke information was returned.
4206 @retval EFI_NOT_READY There was no keystroke data availiable.
4207 @retval EFI_DEVICE_ERROR The keydtroke information was not returned due
4213 ConSplitterSimplePointerPrivateGetState (
4214 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
4215 IN OUT EFI_SIMPLE_POINTER_STATE
*State
4219 EFI_STATUS ReturnStatus
;
4221 EFI_SIMPLE_POINTER_STATE CurrentState
;
4223 State
->RelativeMovementX
= 0;
4224 State
->RelativeMovementY
= 0;
4225 State
->RelativeMovementZ
= 0;
4226 State
->LeftButton
= FALSE
;
4227 State
->RightButton
= FALSE
;
4230 // if no physical console input device exists, return EFI_NOT_READY;
4231 // if any physical console input device has key input,
4232 // return the key and EFI_SUCCESS.
4234 ReturnStatus
= EFI_NOT_READY
;
4235 for (Index
= 0; Index
< Private
->CurrentNumberOfPointers
; Index
++) {
4236 Status
= Private
->PointerList
[Index
]->GetState (
4237 Private
->PointerList
[Index
],
4240 if (!EFI_ERROR (Status
)) {
4241 if (ReturnStatus
== EFI_NOT_READY
) {
4242 ReturnStatus
= EFI_SUCCESS
;
4245 if (CurrentState
.LeftButton
) {
4246 State
->LeftButton
= TRUE
;
4249 if (CurrentState
.RightButton
) {
4250 State
->RightButton
= TRUE
;
4253 if ((CurrentState
.RelativeMovementX
!= 0) && (Private
->PointerList
[Index
]->Mode
->ResolutionX
!= 0)) {
4254 State
->RelativeMovementX
+= (CurrentState
.RelativeMovementX
* (INT32
)Private
->SimplePointerMode
.ResolutionX
) / (INT32
)Private
->PointerList
[Index
]->Mode
->ResolutionX
;
4257 if ((CurrentState
.RelativeMovementY
!= 0) && (Private
->PointerList
[Index
]->Mode
->ResolutionY
!= 0)) {
4258 State
->RelativeMovementY
+= (CurrentState
.RelativeMovementY
* (INT32
)Private
->SimplePointerMode
.ResolutionY
) / (INT32
)Private
->PointerList
[Index
]->Mode
->ResolutionY
;
4261 if ((CurrentState
.RelativeMovementZ
!= 0) && (Private
->PointerList
[Index
]->Mode
->ResolutionZ
!= 0)) {
4262 State
->RelativeMovementZ
+= (CurrentState
.RelativeMovementZ
* (INT32
)Private
->SimplePointerMode
.ResolutionZ
) / (INT32
)Private
->PointerList
[Index
]->Mode
->ResolutionZ
;
4264 } else if (Status
== EFI_DEVICE_ERROR
) {
4265 ReturnStatus
= EFI_DEVICE_ERROR
;
4269 return ReturnStatus
;
4273 Reads the next keystroke from the input device. The WaitForKey Event can
4274 be used to test for existance of a keystroke via WaitForEvent () call.
4276 @param This A pointer to protocol instance.
4277 @param State A pointer to state information on the pointer device
4279 @retval EFI_SUCCESS The keystroke information was returned in State.
4280 @retval EFI_NOT_READY There was no keystroke data availiable.
4281 @retval EFI_DEVICE_ERROR The keydtroke information was not returned due
4287 ConSplitterSimplePointerGetState (
4288 IN EFI_SIMPLE_POINTER_PROTOCOL
*This
,
4289 IN OUT EFI_SIMPLE_POINTER_STATE
*State
4292 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
4294 Private
= TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_SIMPLE_POINTER_THIS (This
);
4296 Private
->InputEventSignalState
= FALSE
;
4298 return ConSplitterSimplePointerPrivateGetState (Private
, State
);
4302 This event aggregates all the events of the ConIn devices in the spliter.
4303 If any events of physical ConIn devices are signaled, signal the ConIn
4304 spliter event. This will cause the calling code to call
4305 ConSplitterTextInReadKeyStroke ().
4307 @param Event The Event associated with callback.
4308 @param Context Context registered when Event was created.
4313 ConSplitterSimplePointerWaitForInput (
4319 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
4322 Private
= (TEXT_IN_SPLITTER_PRIVATE_DATA
*)Context
;
4325 // if InputEventSignalState is flagged before, and not cleared by Reset() or ReadKeyStroke()
4327 if (Private
->InputEventSignalState
) {
4328 gBS
->SignalEvent (Event
);
4333 // if any physical console input device has key input, signal the event.
4335 for (Index
= 0; Index
< Private
->CurrentNumberOfPointers
; Index
++) {
4336 Status
= gBS
->CheckEvent (Private
->PointerList
[Index
]->WaitForInput
);
4337 if (!EFI_ERROR (Status
)) {
4338 gBS
->SignalEvent (Event
);
4339 Private
->InputEventSignalState
= TRUE
;
4345 Resets the pointer device hardware.
4347 @param This Protocol instance pointer.
4348 @param ExtendedVerification Driver may perform diagnostics on reset.
4350 @retval EFI_SUCCESS The device was reset.
4351 @retval EFI_DEVICE_ERROR The device is not functioning correctly and
4357 ConSplitterAbsolutePointerReset (
4358 IN EFI_ABSOLUTE_POINTER_PROTOCOL
*This
,
4359 IN BOOLEAN ExtendedVerification
4363 EFI_STATUS ReturnStatus
;
4364 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
4367 Private
= TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_ABSOLUTE_POINTER_THIS (This
);
4369 Private
->AbsoluteInputEventSignalState
= FALSE
;
4371 if (Private
->CurrentNumberOfAbsolutePointers
== 0) {
4376 // return the worst status met
4378 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfAbsolutePointers
; Index
++) {
4379 Status
= Private
->AbsolutePointerList
[Index
]->Reset (
4380 Private
->AbsolutePointerList
[Index
],
4381 ExtendedVerification
4383 if (EFI_ERROR (Status
)) {
4384 ReturnStatus
= Status
;
4388 return ReturnStatus
;
4392 Retrieves the current state of a pointer device.
4394 @param This Protocol instance pointer.
4395 @param State A pointer to the state information on the
4398 @retval EFI_SUCCESS The state of the pointer device was returned in
4400 @retval EFI_NOT_READY The state of the pointer device has not changed
4401 since the last call to GetState().
4402 @retval EFI_DEVICE_ERROR A device error occurred while attempting to
4403 retrieve the pointer device's current state.
4408 ConSplitterAbsolutePointerGetState (
4409 IN EFI_ABSOLUTE_POINTER_PROTOCOL
*This
,
4410 IN OUT EFI_ABSOLUTE_POINTER_STATE
*State
4413 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
4415 EFI_STATUS ReturnStatus
;
4417 EFI_ABSOLUTE_POINTER_STATE CurrentState
;
4431 Private
= TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_ABSOLUTE_POINTER_THIS (This
);
4433 Private
->AbsoluteInputEventSignalState
= FALSE
;
4435 State
->CurrentX
= 0;
4436 State
->CurrentY
= 0;
4437 State
->CurrentZ
= 0;
4438 State
->ActiveButtons
= 0;
4440 VirtualMinX
= Private
->AbsolutePointerMode
.AbsoluteMinX
;
4441 VirtualMinY
= Private
->AbsolutePointerMode
.AbsoluteMinY
;
4442 VirtualMinZ
= Private
->AbsolutePointerMode
.AbsoluteMinZ
;
4443 VirtualMaxX
= Private
->AbsolutePointerMode
.AbsoluteMaxX
;
4444 VirtualMaxY
= Private
->AbsolutePointerMode
.AbsoluteMaxY
;
4445 VirtualMaxZ
= Private
->AbsolutePointerMode
.AbsoluteMaxZ
;
4448 // if no physical pointer device exists, return EFI_NOT_READY;
4449 // if any physical pointer device has changed state,
4450 // return the state and EFI_SUCCESS.
4452 ReturnStatus
= EFI_NOT_READY
;
4453 for (Index
= 0; Index
< Private
->CurrentNumberOfAbsolutePointers
; Index
++) {
4454 Status
= Private
->AbsolutePointerList
[Index
]->GetState (
4455 Private
->AbsolutePointerList
[Index
],
4458 if (!EFI_ERROR (Status
)) {
4459 if (ReturnStatus
== EFI_NOT_READY
) {
4460 ReturnStatus
= EFI_SUCCESS
;
4463 MinX
= Private
->AbsolutePointerList
[Index
]->Mode
->AbsoluteMinX
;
4464 MinY
= Private
->AbsolutePointerList
[Index
]->Mode
->AbsoluteMinY
;
4465 MinZ
= Private
->AbsolutePointerList
[Index
]->Mode
->AbsoluteMinZ
;
4466 MaxX
= Private
->AbsolutePointerList
[Index
]->Mode
->AbsoluteMaxX
;
4467 MaxY
= Private
->AbsolutePointerList
[Index
]->Mode
->AbsoluteMaxY
;
4468 MaxZ
= Private
->AbsolutePointerList
[Index
]->Mode
->AbsoluteMaxZ
;
4470 State
->ActiveButtons
= CurrentState
.ActiveButtons
;
4473 // Rescale to Con Splitter virtual Absolute Pointer's resolution.
4475 if (!((MinX
== 0) && (MaxX
== 0))) {
4476 State
->CurrentX
= VirtualMinX
+ DivU64x64Remainder (
4478 CurrentState
.CurrentX
,
4479 VirtualMaxX
- VirtualMinX
4486 if (!((MinY
== 0) && (MaxY
== 0))) {
4487 State
->CurrentY
= VirtualMinY
+ DivU64x64Remainder (
4489 CurrentState
.CurrentY
,
4490 VirtualMaxY
- VirtualMinY
4497 if (!((MinZ
== 0) && (MaxZ
== 0))) {
4498 State
->CurrentZ
= VirtualMinZ
+ DivU64x64Remainder (
4500 CurrentState
.CurrentZ
,
4501 VirtualMaxZ
- VirtualMinZ
4507 } else if (Status
== EFI_DEVICE_ERROR
) {
4508 ReturnStatus
= EFI_DEVICE_ERROR
;
4512 return ReturnStatus
;
4516 This event aggregates all the events of the pointer devices in the splitter.
4517 If any events of physical pointer devices are signaled, signal the pointer
4518 splitter event. This will cause the calling code to call
4519 ConSplitterAbsolutePointerGetState ().
4521 @param Event The Event associated with callback.
4522 @param Context Context registered when Event was created.
4527 ConSplitterAbsolutePointerWaitForInput (
4533 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
4536 Private
= (TEXT_IN_SPLITTER_PRIVATE_DATA
*)Context
;
4539 // if AbsoluteInputEventSignalState is flagged before,
4540 // and not cleared by Reset() or GetState(), signal it
4542 if (Private
->AbsoluteInputEventSignalState
) {
4543 gBS
->SignalEvent (Event
);
4548 // if any physical console input device has key input, signal the event.
4550 for (Index
= 0; Index
< Private
->CurrentNumberOfAbsolutePointers
; Index
++) {
4551 Status
= gBS
->CheckEvent (Private
->AbsolutePointerList
[Index
]->WaitForInput
);
4552 if (!EFI_ERROR (Status
)) {
4553 gBS
->SignalEvent (Event
);
4554 Private
->AbsoluteInputEventSignalState
= TRUE
;
4560 Reset the text output device hardware and optionally run diagnostics
4562 @param This Protocol instance pointer.
4563 @param ExtendedVerification Driver may perform more exhaustive verification
4564 operation of the device during reset.
4566 @retval EFI_SUCCESS The text output device was reset.
4567 @retval EFI_DEVICE_ERROR The text output device is not functioning
4568 correctly and could not be reset.
4573 ConSplitterTextOutReset (
4574 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4575 IN BOOLEAN ExtendedVerification
4579 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4581 EFI_STATUS ReturnStatus
;
4583 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4586 // return the worst status met
4588 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
4589 Status
= Private
->TextOutList
[Index
].TextOut
->Reset (
4590 Private
->TextOutList
[Index
].TextOut
,
4591 ExtendedVerification
4593 if (EFI_ERROR (Status
)) {
4594 ReturnStatus
= Status
;
4598 This
->SetAttribute (This
, EFI_TEXT_ATTR (This
->Mode
->Attribute
& 0x0F, EFI_BLACK
));
4601 // reset all mode parameters
4603 TextOutSetMode (Private
, 0);
4605 return ReturnStatus
;
4609 Write a Unicode string to the output device.
4611 @param This Protocol instance pointer.
4612 @param WString The NULL-terminated Unicode string to be
4613 displayed on the output device(s). All output
4614 devices must also support the Unicode drawing
4615 defined in this file.
4617 @retval EFI_SUCCESS The string was output to the device.
4618 @retval EFI_DEVICE_ERROR The device reported an error while attempting to
4620 @retval EFI_UNSUPPORTED The output device's mode is not currently in a
4622 @retval EFI_WARN_UNKNOWN_GLYPH This warning code indicates that some of the
4623 characters in the Unicode string could not be
4624 rendered and were skipped.
4629 ConSplitterTextOutOutputString (
4630 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4635 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4637 EFI_STATUS ReturnStatus
;
4641 This
->SetAttribute (This
, This
->Mode
->Attribute
);
4643 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4646 // return the worst status met
4648 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
4649 Status
= Private
->TextOutList
[Index
].TextOut
->OutputString (
4650 Private
->TextOutList
[Index
].TextOut
,
4653 if (EFI_ERROR (Status
)) {
4654 ReturnStatus
= Status
;
4658 if (Private
->CurrentNumberOfConsoles
> 0) {
4659 Private
->TextOutMode
.CursorColumn
= Private
->TextOutList
[0].TextOut
->Mode
->CursorColumn
;
4660 Private
->TextOutMode
.CursorRow
= Private
->TextOutList
[0].TextOut
->Mode
->CursorRow
;
4663 // When there is no real console devices in system,
4664 // update cursor position for the virtual device in consplitter.
4666 Private
->TextOut
.QueryMode (
4668 Private
->TextOutMode
.Mode
,
4672 for ( ; *WString
!= CHAR_NULL
; WString
++) {
4674 case CHAR_BACKSPACE
:
4675 if ((Private
->TextOutMode
.CursorColumn
== 0) && (Private
->TextOutMode
.CursorRow
> 0)) {
4676 Private
->TextOutMode
.CursorRow
--;
4677 Private
->TextOutMode
.CursorColumn
= (INT32
)(MaxColumn
- 1);
4678 } else if (Private
->TextOutMode
.CursorColumn
> 0) {
4679 Private
->TextOutMode
.CursorColumn
--;
4685 if (Private
->TextOutMode
.CursorRow
< (INT32
)(MaxRow
- 1)) {
4686 Private
->TextOutMode
.CursorRow
++;
4691 case CHAR_CARRIAGE_RETURN
:
4692 Private
->TextOutMode
.CursorColumn
= 0;
4696 if (Private
->TextOutMode
.CursorColumn
< (INT32
)(MaxColumn
- 1)) {
4697 Private
->TextOutMode
.CursorColumn
++;
4699 Private
->TextOutMode
.CursorColumn
= 0;
4700 if (Private
->TextOutMode
.CursorRow
< (INT32
)(MaxRow
- 1)) {
4701 Private
->TextOutMode
.CursorRow
++;
4710 return ReturnStatus
;
4714 Verifies that all characters in a Unicode string can be output to the
4717 @param This Protocol instance pointer.
4718 @param WString The NULL-terminated Unicode string to be
4719 examined for the output device(s).
4721 @retval EFI_SUCCESS The device(s) are capable of rendering the
4723 @retval EFI_UNSUPPORTED Some of the characters in the Unicode string
4724 cannot be rendered by one or more of the output
4725 devices mapped by the EFI handle.
4730 ConSplitterTextOutTestString (
4731 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4736 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4738 EFI_STATUS ReturnStatus
;
4740 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4743 // return the worst status met
4745 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
4746 Status
= Private
->TextOutList
[Index
].TextOut
->TestString (
4747 Private
->TextOutList
[Index
].TextOut
,
4750 if (EFI_ERROR (Status
)) {
4751 ReturnStatus
= Status
;
4756 // There is no DevNullTextOutTestString () since a Unicode buffer would
4757 // always return EFI_SUCCESS.
4758 // ReturnStatus will be EFI_SUCCESS if no consoles are present
4760 return ReturnStatus
;
4764 Returns information for an available text mode that the output device(s)
4767 @param This Protocol instance pointer.
4768 @param ModeNumber The mode number to return information on.
4769 @param Columns Returns the columns of the text output device
4770 for the requested ModeNumber.
4771 @param Rows Returns the rows of the text output device
4772 for the requested ModeNumber.
4774 @retval EFI_SUCCESS The requested mode information was returned.
4775 @retval EFI_DEVICE_ERROR The device had an error and could not complete
4777 @retval EFI_UNSUPPORTED The mode number was not valid.
4782 ConSplitterTextOutQueryMode (
4783 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4784 IN UINTN ModeNumber
,
4789 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4791 INT32
*TextOutModeMap
;
4793 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4796 // Check whether param ModeNumber is valid.
4797 // ModeNumber should be within range 0 ~ MaxMode - 1.
4799 if ((ModeNumber
> (UINTN
)(((UINT32
)-1)>>1))) {
4800 return EFI_UNSUPPORTED
;
4803 if ((INT32
)ModeNumber
>= This
->Mode
->MaxMode
) {
4804 return EFI_UNSUPPORTED
;
4808 // We get the available mode from mode intersection map if it's available
4810 if (Private
->TextOutModeMap
!= NULL
) {
4811 TextOutModeMap
= Private
->TextOutModeMap
+ Private
->TextOutListCount
* ModeNumber
;
4812 CurrentMode
= (UINTN
)(*TextOutModeMap
);
4813 *Columns
= Private
->TextOutQueryData
[CurrentMode
].Columns
;
4814 *Rows
= Private
->TextOutQueryData
[CurrentMode
].Rows
;
4816 *Columns
= Private
->TextOutQueryData
[ModeNumber
].Columns
;
4817 *Rows
= Private
->TextOutQueryData
[ModeNumber
].Rows
;
4820 if ((*Columns
<= 0) && (*Rows
<= 0)) {
4821 return EFI_UNSUPPORTED
;
4828 Sets the output device(s) to a specified mode.
4830 @param This Protocol instance pointer.
4831 @param ModeNumber The mode number to set.
4833 @retval EFI_SUCCESS The requested text mode was set.
4834 @retval EFI_DEVICE_ERROR The device had an error and could not complete
4836 @retval EFI_UNSUPPORTED The mode number was not valid.
4841 ConSplitterTextOutSetMode (
4842 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4847 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4849 INT32
*TextOutModeMap
;
4850 EFI_STATUS ReturnStatus
;
4852 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4855 // Check whether param ModeNumber is valid.
4856 // ModeNumber should be within range 0 ~ MaxMode - 1.
4858 if ((ModeNumber
> (UINTN
)(((UINT32
)-1)>>1))) {
4859 return EFI_UNSUPPORTED
;
4862 if ((INT32
)ModeNumber
>= This
->Mode
->MaxMode
) {
4863 return EFI_UNSUPPORTED
;
4867 // If the mode is being set to the curent mode, then just clear the screen and return.
4869 if (Private
->TextOutMode
.Mode
== (INT32
)ModeNumber
) {
4870 return ConSplitterTextOutClearScreen (This
);
4874 // return the worst status met
4876 TextOutModeMap
= Private
->TextOutModeMap
+ Private
->TextOutListCount
* ModeNumber
;
4877 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
4879 // While adding a console out device do not set same mode again for the same device.
4881 if ((!Private
->AddingConOutDevice
) ||
4882 (TextOutModeMap
[Index
] != Private
->TextOutList
[Index
].TextOut
->Mode
->Mode
))
4884 Status
= Private
->TextOutList
[Index
].TextOut
->SetMode (
4885 Private
->TextOutList
[Index
].TextOut
,
4886 TextOutModeMap
[Index
]
4888 if (EFI_ERROR (Status
)) {
4889 ReturnStatus
= Status
;
4895 // Set mode parameter to specified mode number
4897 TextOutSetMode (Private
, ModeNumber
);
4899 return ReturnStatus
;
4903 Sets the background and foreground colors for the OutputString () and
4904 ClearScreen () functions.
4906 @param This Protocol instance pointer.
4907 @param Attribute The attribute to set. Bits 0..3 are the
4908 foreground color, and bits 4..6 are the
4909 background color. All other bits are undefined
4910 and must be zero. The valid Attributes are
4911 defined in this file.
4913 @retval EFI_SUCCESS The attribute was set.
4914 @retval EFI_DEVICE_ERROR The device had an error and could not complete
4916 @retval EFI_UNSUPPORTED The attribute requested is not defined.
4921 ConSplitterTextOutSetAttribute (
4922 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4927 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4929 EFI_STATUS ReturnStatus
;
4931 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4934 // Check whether param Attribute is valid.
4936 if ((Attribute
| 0x7F) != 0x7F) {
4937 return EFI_UNSUPPORTED
;
4941 // return the worst status met
4943 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
4944 Status
= Private
->TextOutList
[Index
].TextOut
->SetAttribute (
4945 Private
->TextOutList
[Index
].TextOut
,
4948 if (EFI_ERROR (Status
)) {
4949 ReturnStatus
= Status
;
4953 Private
->TextOutMode
.Attribute
= (INT32
)Attribute
;
4955 return ReturnStatus
;
4959 Clears the output device(s) display to the currently selected background
4962 @param This Protocol instance pointer.
4964 @retval EFI_SUCCESS The operation completed successfully.
4965 @retval EFI_DEVICE_ERROR The device had an error and could not complete
4967 @retval EFI_UNSUPPORTED The output device is not in a valid text mode.
4972 ConSplitterTextOutClearScreen (
4973 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
4977 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4979 EFI_STATUS ReturnStatus
;
4981 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4984 // return the worst status met
4986 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
4987 Status
= Private
->TextOutList
[Index
].TextOut
->ClearScreen (Private
->TextOutList
[Index
].TextOut
);
4988 if (EFI_ERROR (Status
)) {
4989 ReturnStatus
= Status
;
4994 // No need to do extra check here as whether (Column, Row) is valid has
4995 // been checked in ConSplitterTextOutSetCursorPosition. And (0, 0) should
4996 // always be supported.
4998 Private
->TextOutMode
.CursorColumn
= 0;
4999 Private
->TextOutMode
.CursorRow
= 0;
5000 Private
->TextOutMode
.CursorVisible
= TRUE
;
5002 return ReturnStatus
;
5006 Sets the current coordinates of the cursor position
5008 @param This Protocol instance pointer.
5009 @param Column The column position to set the cursor to. Must be
5010 greater than or equal to zero and less than the
5011 number of columns by QueryMode ().
5012 @param Row The row position to set the cursor to. Must be
5013 greater than or equal to zero and less than the
5014 number of rows by QueryMode ().
5016 @retval EFI_SUCCESS The operation completed successfully.
5017 @retval EFI_DEVICE_ERROR The device had an error and could not complete
5019 @retval EFI_UNSUPPORTED The output device is not in a valid text mode,
5020 or the cursor position is invalid for the
5026 ConSplitterTextOutSetCursorPosition (
5027 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
5033 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
5035 EFI_STATUS ReturnStatus
;
5038 INT32
*TextOutModeMap
;
5042 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
5043 TextOutModeMap
= NULL
;
5044 ModeNumber
= Private
->TextOutMode
.Mode
;
5047 // Get current MaxColumn and MaxRow from intersection map
5049 if (Private
->TextOutModeMap
!= NULL
) {
5050 TextOutModeMap
= Private
->TextOutModeMap
+ Private
->TextOutListCount
* ModeNumber
;
5051 CurrentMode
= *TextOutModeMap
;
5053 CurrentMode
= ModeNumber
;
5056 MaxColumn
= Private
->TextOutQueryData
[CurrentMode
].Columns
;
5057 MaxRow
= Private
->TextOutQueryData
[CurrentMode
].Rows
;
5059 if ((Column
>= MaxColumn
) || (Row
>= MaxRow
)) {
5060 return EFI_UNSUPPORTED
;
5064 // return the worst status met
5066 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
5067 Status
= Private
->TextOutList
[Index
].TextOut
->SetCursorPosition (
5068 Private
->TextOutList
[Index
].TextOut
,
5072 if (EFI_ERROR (Status
)) {
5073 ReturnStatus
= Status
;
5078 // No need to do extra check here as whether (Column, Row) is valid has
5079 // been checked in ConSplitterTextOutSetCursorPosition. And (0, 0) should
5080 // always be supported.
5082 Private
->TextOutMode
.CursorColumn
= (INT32
)Column
;
5083 Private
->TextOutMode
.CursorRow
= (INT32
)Row
;
5085 return ReturnStatus
;
5089 Makes the cursor visible or invisible
5091 @param This Protocol instance pointer.
5092 @param Visible If TRUE, the cursor is set to be visible. If
5093 FALSE, the cursor is set to be invisible.
5095 @retval EFI_SUCCESS The operation completed successfully.
5096 @retval EFI_DEVICE_ERROR The device had an error and could not complete
5097 the request, or the device does not support
5098 changing the cursor mode.
5099 @retval EFI_UNSUPPORTED The output device is not in a valid text mode.
5104 ConSplitterTextOutEnableCursor (
5105 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
5110 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
5112 EFI_STATUS ReturnStatus
;
5114 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
5117 // return the worst status met
5119 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
5120 Status
= Private
->TextOutList
[Index
].TextOut
->EnableCursor (
5121 Private
->TextOutList
[Index
].TextOut
,
5124 if (EFI_ERROR (Status
)) {
5125 ReturnStatus
= Status
;
5129 Private
->TextOutMode
.CursorVisible
= Visible
;
5131 return ReturnStatus
;