2 Console Splitter Driver. Any Handle that attatched console I/O protocols
3 (Console In device, Console Out device, Console Error device, Simple Pointer
4 protocol, Absolute Pointer protocol) can be bound by this driver.
6 So far it works like any other driver by opening a SimpleTextIn and/or
7 SimpleTextOut protocol with EFI_OPEN_PROTOCOL_BY_DRIVER attributes. The big
8 difference is this driver does not layer a protocol on the passed in
9 handle, or construct a child handle like a standard device or bus driver.
10 This driver produces three virtual handles as children, one for console input
11 splitter, one for console output splitter and one for error output splitter.
12 These 3 virtual handles would be installed on gST.
14 Each virtual handle, that supports the Console I/O protocol, will be produced
15 in the driver entry point. The virtual handle are added on driver entry and
16 never removed. Such design ensures sytem function well during none console
19 Copyright (c) 2006 - 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
,
64 (EFI_KEY_DATA
*) NULL
,
70 ConSplitterSimplePointerReset
,
71 ConSplitterSimplePointerGetState
,
73 (EFI_SIMPLE_POINTER_MODE
*) NULL
83 (EFI_SIMPLE_POINTER_PROTOCOL
**) NULL
,
87 ConSplitterAbsolutePointerReset
,
88 ConSplitterAbsolutePointerGetState
,
90 (EFI_ABSOLUTE_POINTER_MODE
*) NULL
96 0x10000, // AbsoluteMaxX
97 0x10000, // AbsoluteMaxY
98 0x10000, // AbsoluteMaxZ
102 (EFI_ABSOLUTE_POINTER_PROTOCOL
**) NULL
,
112 // Uga Draw Protocol Private Data template
114 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UGA_DRAW_PROTOCOL mUgaDrawProtocolTemplate
= {
115 ConSplitterUgaDrawGetMode
,
116 ConSplitterUgaDrawSetMode
,
117 ConSplitterUgaDrawBlt
121 // Graphics Output Protocol Private Data template
123 GLOBAL_REMOVE_IF_UNREFERENCED EFI_GRAPHICS_OUTPUT_PROTOCOL mGraphicsOutputProtocolTemplate
= {
124 ConSplitterGraphicsOutputQueryMode
,
125 ConSplitterGraphicsOutputSetMode
,
126 ConSplitterGraphicsOutputBlt
,
132 // Text Out Splitter Private Data template
134 GLOBAL_REMOVE_IF_UNREFERENCED TEXT_OUT_SPLITTER_PRIVATE_DATA mConOut
= {
135 TEXT_OUT_SPLITTER_PRIVATE_DATA_SIGNATURE
,
138 ConSplitterTextOutReset
,
139 ConSplitterTextOutOutputString
,
140 ConSplitterTextOutTestString
,
141 ConSplitterTextOutQueryMode
,
142 ConSplitterTextOutSetMode
,
143 ConSplitterTextOutSetAttribute
,
144 ConSplitterTextOutClearScreen
,
145 ConSplitterTextOutSetCursorPosition
,
146 ConSplitterTextOutEnableCursor
,
147 (EFI_SIMPLE_TEXT_OUTPUT_MODE
*) NULL
174 (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*) NULL
,
179 (TEXT_OUT_AND_GOP_DATA
*) NULL
,
181 (TEXT_OUT_SPLITTER_QUERY_DATA
*) NULL
,
188 // Standard Error Text Out Splitter Data Template
190 GLOBAL_REMOVE_IF_UNREFERENCED TEXT_OUT_SPLITTER_PRIVATE_DATA mStdErr
= {
191 TEXT_OUT_SPLITTER_PRIVATE_DATA_SIGNATURE
,
194 ConSplitterTextOutReset
,
195 ConSplitterTextOutOutputString
,
196 ConSplitterTextOutTestString
,
197 ConSplitterTextOutQueryMode
,
198 ConSplitterTextOutSetMode
,
199 ConSplitterTextOutSetAttribute
,
200 ConSplitterTextOutClearScreen
,
201 ConSplitterTextOutSetCursorPosition
,
202 ConSplitterTextOutEnableCursor
,
203 (EFI_SIMPLE_TEXT_OUTPUT_MODE
*) NULL
230 (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*) NULL
,
235 (TEXT_OUT_AND_GOP_DATA
*) NULL
,
237 (TEXT_OUT_SPLITTER_QUERY_DATA
*) NULL
,
244 // Driver binding instance for Console Input Device
246 EFI_DRIVER_BINDING_PROTOCOL gConSplitterConInDriverBinding
= {
247 ConSplitterConInDriverBindingSupported
,
248 ConSplitterConInDriverBindingStart
,
249 ConSplitterConInDriverBindingStop
,
256 // Driver binding instance for Console Out device
258 EFI_DRIVER_BINDING_PROTOCOL gConSplitterConOutDriverBinding
= {
259 ConSplitterConOutDriverBindingSupported
,
260 ConSplitterConOutDriverBindingStart
,
261 ConSplitterConOutDriverBindingStop
,
268 // Driver binding instance for Standard Error device
270 EFI_DRIVER_BINDING_PROTOCOL gConSplitterStdErrDriverBinding
= {
271 ConSplitterStdErrDriverBindingSupported
,
272 ConSplitterStdErrDriverBindingStart
,
273 ConSplitterStdErrDriverBindingStop
,
280 // Driver binding instance for Simple Pointer protocol
282 EFI_DRIVER_BINDING_PROTOCOL gConSplitterSimplePointerDriverBinding
= {
283 ConSplitterSimplePointerDriverBindingSupported
,
284 ConSplitterSimplePointerDriverBindingStart
,
285 ConSplitterSimplePointerDriverBindingStop
,
292 // Driver binding instance for Absolute Pointer protocol
294 EFI_DRIVER_BINDING_PROTOCOL gConSplitterAbsolutePointerDriverBinding
= {
295 ConSplitterAbsolutePointerDriverBindingSupported
,
296 ConSplitterAbsolutePointerDriverBindingStart
,
297 ConSplitterAbsolutePointerDriverBindingStop
,
304 Key notify for toggle state sync.
306 @param KeyData A pointer to a buffer that is filled in with
307 the keystroke information for the key that was
310 @retval EFI_SUCCESS Toggle state sync successfully.
315 ToggleStateSyncKeyNotify (
316 IN EFI_KEY_DATA
*KeyData
321 if (((KeyData
->KeyState
.KeyToggleState
& KEY_STATE_VALID_EXPOSED
) == KEY_STATE_VALID_EXPOSED
) &&
322 (KeyData
->KeyState
.KeyToggleState
!= mConIn
.PhysicalKeyToggleState
)) {
324 // There is toggle state change, sync to other console input devices.
326 for (Index
= 0; Index
< mConIn
.CurrentNumberOfExConsoles
; Index
++) {
327 mConIn
.TextInExList
[Index
]->SetState (
328 mConIn
.TextInExList
[Index
],
329 &KeyData
->KeyState
.KeyToggleState
332 mConIn
.PhysicalKeyToggleState
= KeyData
->KeyState
.KeyToggleState
;
333 DEBUG ((EFI_D_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 Reinitialization 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.
499 ASSERT (FeaturePcdGet (PcdConOutGopSupport
) ||
500 FeaturePcdGet (PcdConOutUgaSupport
));
503 // The driver creates virtual handles for ConIn, ConOut, StdErr.
504 // The virtual handles will always exist even if no console exist in the
505 // system. This is need to support hotplug devices like USB.
508 // Create virtual device handle for ConIn Splitter
510 Status
= ConSplitterTextInConstructor (&mConIn
);
511 if (!EFI_ERROR (Status
)) {
512 Status
= gBS
->InstallMultipleProtocolInterfaces (
513 &mConIn
.VirtualHandle
,
514 &gEfiSimpleTextInProtocolGuid
,
516 &gEfiSimpleTextInputExProtocolGuid
,
518 &gEfiSimplePointerProtocolGuid
,
519 &mConIn
.SimplePointer
,
520 &gEfiAbsolutePointerProtocolGuid
,
521 &mConIn
.AbsolutePointer
,
524 if (!EFI_ERROR (Status
)) {
526 // Update the EFI System Table with new virtual console
527 // and update the pointer to Simple Text Input protocol.
529 gST
->ConsoleInHandle
= mConIn
.VirtualHandle
;
530 gST
->ConIn
= &mConIn
.TextIn
;
534 // Create virtual device handle for ConOut Splitter
536 Status
= ConSplitterTextOutConstructor (&mConOut
);
537 if (!EFI_ERROR (Status
)) {
538 Status
= gBS
->InstallMultipleProtocolInterfaces (
539 &mConOut
.VirtualHandle
,
540 &gEfiSimpleTextOutProtocolGuid
,
544 if (!EFI_ERROR (Status
)) {
546 // Update the EFI System Table with new virtual console
547 // and Update the pointer to Text Output protocol.
549 gST
->ConsoleOutHandle
= mConOut
.VirtualHandle
;
550 gST
->ConOut
= &mConOut
.TextOut
;
556 // Create virtual device handle for StdErr Splitter
558 Status
= ConSplitterTextOutConstructor (&mStdErr
);
559 if (!EFI_ERROR (Status
)) {
560 Status
= gBS
->InstallMultipleProtocolInterfaces (
561 &mStdErr
.VirtualHandle
,
562 &gEfiSimpleTextOutProtocolGuid
,
566 if (!EFI_ERROR (Status
)) {
568 // Update the EFI System Table with new virtual console
569 // and update the pointer to Text Output protocol.
571 gST
->StandardErrorHandle
= mStdErr
.VirtualHandle
;
572 gST
->StdErr
= &mStdErr
.TextOut
;
577 // Update the CRC32 in the EFI System Table header
580 gBS
->CalculateCrc32 (
591 Construct console input devices' private data.
593 @param ConInPrivate A pointer to the TEXT_IN_SPLITTER_PRIVATE_DATA
596 @retval EFI_OUT_OF_RESOURCES Out of resources.
597 @retval EFI_SUCCESS Text Input Devcie's private data has been constructed.
598 @retval other Failed to construct private data.
602 ConSplitterTextInConstructor (
603 TEXT_IN_SPLITTER_PRIVATE_DATA
*ConInPrivate
607 UINTN TextInExListCount
;
610 // Allocate buffer for Simple Text Input device
612 Status
= ConSplitterGrowBuffer (
613 sizeof (EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*),
614 &ConInPrivate
->TextInListCount
,
615 (VOID
**) &ConInPrivate
->TextInList
617 if (EFI_ERROR (Status
)) {
618 return EFI_OUT_OF_RESOURCES
;
622 // Create Event to wait for a key
624 Status
= gBS
->CreateEvent (
627 ConSplitterTextInWaitForKey
,
629 &ConInPrivate
->TextIn
.WaitForKey
631 ASSERT_EFI_ERROR (Status
);
634 // Allocate buffer for KeyQueue
636 TextInExListCount
= ConInPrivate
->TextInExListCount
;
637 Status
= ConSplitterGrowBuffer (
638 sizeof (EFI_KEY_DATA
),
640 (VOID
**) &ConInPrivate
->KeyQueue
642 if (EFI_ERROR (Status
)) {
643 return EFI_OUT_OF_RESOURCES
;
647 // Allocate buffer for Simple Text Input Ex device
649 Status
= ConSplitterGrowBuffer (
650 sizeof (EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*),
651 &ConInPrivate
->TextInExListCount
,
652 (VOID
**) &ConInPrivate
->TextInExList
654 if (EFI_ERROR (Status
)) {
655 return EFI_OUT_OF_RESOURCES
;
658 // Create Event to wait for a key Ex
660 Status
= gBS
->CreateEvent (
663 ConSplitterTextInWaitForKey
,
665 &ConInPrivate
->TextInEx
.WaitForKeyEx
667 ASSERT_EFI_ERROR (Status
);
669 InitializeListHead (&ConInPrivate
->NotifyList
);
671 ToggleStateSyncInitialization (ConInPrivate
);
673 ConInPrivate
->AbsolutePointer
.Mode
= &ConInPrivate
->AbsolutePointerMode
;
675 // Allocate buffer for Absolute Pointer device
677 Status
= ConSplitterGrowBuffer (
678 sizeof (EFI_ABSOLUTE_POINTER_PROTOCOL
*),
679 &ConInPrivate
->AbsolutePointerListCount
,
680 (VOID
**) &ConInPrivate
->AbsolutePointerList
682 if (EFI_ERROR (Status
)) {
683 return EFI_OUT_OF_RESOURCES
;
686 // Create Event to wait for device input for Absolute pointer device
688 Status
= gBS
->CreateEvent (
691 ConSplitterAbsolutePointerWaitForInput
,
693 &ConInPrivate
->AbsolutePointer
.WaitForInput
695 ASSERT_EFI_ERROR (Status
);
697 ConInPrivate
->SimplePointer
.Mode
= &ConInPrivate
->SimplePointerMode
;
699 // Allocate buffer for Simple Pointer device
701 Status
= ConSplitterGrowBuffer (
702 sizeof (EFI_SIMPLE_POINTER_PROTOCOL
*),
703 &ConInPrivate
->PointerListCount
,
704 (VOID
**) &ConInPrivate
->PointerList
706 if (EFI_ERROR (Status
)) {
707 return EFI_OUT_OF_RESOURCES
;
710 // Create Event to wait for device input for Simple pointer device
712 Status
= gBS
->CreateEvent (
715 ConSplitterSimplePointerWaitForInput
,
717 &ConInPrivate
->SimplePointer
.WaitForInput
719 ASSERT_EFI_ERROR (Status
);
721 // Create Event to signal ConIn connection request
723 Status
= gBS
->CreateEventEx (
726 EfiEventEmptyFunction
,
728 &gConnectConInEventGuid
,
729 &ConInPrivate
->ConnectConInEvent
736 Construct console output devices' private data.
738 @param ConOutPrivate A pointer to the TEXT_OUT_SPLITTER_PRIVATE_DATA
741 @retval EFI_OUT_OF_RESOURCES Out of resources.
742 @retval EFI_SUCCESS Text Input Devcie's private data has been constructed.
746 ConSplitterTextOutConstructor (
747 TEXT_OUT_SPLITTER_PRIVATE_DATA
*ConOutPrivate
751 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*Info
;
754 // Copy protocols template
756 if (FeaturePcdGet (PcdConOutUgaSupport
)) {
757 CopyMem (&ConOutPrivate
->UgaDraw
, &mUgaDrawProtocolTemplate
, sizeof (EFI_UGA_DRAW_PROTOCOL
));
759 if (FeaturePcdGet (PcdConOutGopSupport
)) {
760 CopyMem (&ConOutPrivate
->GraphicsOutput
, &mGraphicsOutputProtocolTemplate
, sizeof (EFI_GRAPHICS_OUTPUT_PROTOCOL
));
764 // Initilize console output splitter's private data.
766 ConOutPrivate
->TextOut
.Mode
= &ConOutPrivate
->TextOutMode
;
769 // When new console device is added, the new mode will be set later,
770 // so put current mode back to init state.
772 ConOutPrivate
->TextOutMode
.Mode
= 0xFF;
774 // Allocate buffer for Console Out device
776 Status
= ConSplitterGrowBuffer (
777 sizeof (TEXT_OUT_AND_GOP_DATA
),
778 &ConOutPrivate
->TextOutListCount
,
779 (VOID
**) &ConOutPrivate
->TextOutList
781 if (EFI_ERROR (Status
)) {
782 return EFI_OUT_OF_RESOURCES
;
785 // Allocate buffer for Text Out query data
787 Status
= ConSplitterGrowBuffer (
788 sizeof (TEXT_OUT_SPLITTER_QUERY_DATA
),
789 &ConOutPrivate
->TextOutQueryDataCount
,
790 (VOID
**) &ConOutPrivate
->TextOutQueryData
792 if (EFI_ERROR (Status
)) {
793 return EFI_OUT_OF_RESOURCES
;
797 // Setup the default console to 80 x 25 and mode to 0
799 ConOutPrivate
->TextOutQueryData
[0].Columns
= 80;
800 ConOutPrivate
->TextOutQueryData
[0].Rows
= 25;
801 TextOutSetMode (ConOutPrivate
, 0);
804 if (FeaturePcdGet (PcdConOutUgaSupport
)) {
806 // Setup the UgaDraw to 800 x 600 x 32 bits per pixel, 60Hz.
808 ConSplitterUgaDrawSetMode (&ConOutPrivate
->UgaDraw
, 800, 600, 32, 60);
810 if (FeaturePcdGet (PcdConOutGopSupport
)) {
812 // Setup resource for mode information in Graphics Output Protocol interface
814 if ((ConOutPrivate
->GraphicsOutput
.Mode
= AllocateZeroPool (sizeof (EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE
))) == NULL
) {
815 return EFI_OUT_OF_RESOURCES
;
817 if ((ConOutPrivate
->GraphicsOutput
.Mode
->Info
= AllocateZeroPool (sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
))) == NULL
) {
818 return EFI_OUT_OF_RESOURCES
;
821 // Setup the DevNullGraphicsOutput to 800 x 600 x 32 bits per pixel
822 // DevNull will be updated to user-defined mode after driver has started.
824 if ((ConOutPrivate
->GraphicsOutputModeBuffer
= AllocateZeroPool (sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
))) == NULL
) {
825 return EFI_OUT_OF_RESOURCES
;
827 Info
= &ConOutPrivate
->GraphicsOutputModeBuffer
[0];
829 Info
->HorizontalResolution
= 800;
830 Info
->VerticalResolution
= 600;
831 Info
->PixelFormat
= PixelBltOnly
;
832 Info
->PixelsPerScanLine
= 800;
833 CopyMem (ConOutPrivate
->GraphicsOutput
.Mode
->Info
, Info
, sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
));
834 ConOutPrivate
->GraphicsOutput
.Mode
->SizeOfInfo
= sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
);
837 // Initialize the following items, theset items remain unchanged in GraphicsOutput->SetMode()
838 // GraphicsOutputMode->FrameBufferBase, GraphicsOutputMode->FrameBufferSize
840 ConOutPrivate
->GraphicsOutput
.Mode
->FrameBufferBase
= (EFI_PHYSICAL_ADDRESS
) (UINTN
) NULL
;
841 ConOutPrivate
->GraphicsOutput
.Mode
->FrameBufferSize
= 0;
843 ConOutPrivate
->GraphicsOutput
.Mode
->MaxMode
= 1;
845 // Initial current mode to unknown state, and then set to mode 0
847 ConOutPrivate
->GraphicsOutput
.Mode
->Mode
= 0xffff;
848 ConOutPrivate
->GraphicsOutput
.SetMode (&ConOutPrivate
->GraphicsOutput
, 0);
856 Test to see if the specified protocol could be supported on the specified device.
858 @param This Driver Binding protocol pointer.
859 @param ControllerHandle Handle of device to test.
860 @param Guid The specified protocol.
862 @retval EFI_SUCCESS The specified protocol is supported on this device.
863 @retval EFI_UNSUPPORTED The specified protocol attempts to be installed on virtul handle.
864 @retval other Failed to open specified protocol on this device.
868 ConSplitterSupported (
869 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
870 IN EFI_HANDLE ControllerHandle
,
878 // Make sure the Console Splitter does not attempt to attach to itself
880 if (ControllerHandle
== mConIn
.VirtualHandle
||
881 ControllerHandle
== mConOut
.VirtualHandle
||
882 ControllerHandle
== mStdErr
.VirtualHandle
884 return EFI_UNSUPPORTED
;
888 // Check to see whether the specific protocol could be opened BY_DRIVER
890 Status
= gBS
->OpenProtocol (
894 This
->DriverBindingHandle
,
896 EFI_OPEN_PROTOCOL_BY_DRIVER
899 if (EFI_ERROR (Status
)) {
906 This
->DriverBindingHandle
,
914 Test to see if Console In Device could be supported on the Controller.
916 @param This Driver Binding protocol instance pointer.
917 @param ControllerHandle Handle of device to test.
918 @param RemainingDevicePath Optional parameter use to pick a specific child
921 @retval EFI_SUCCESS This driver supports this device.
922 @retval other This driver does not support this device.
927 ConSplitterConInDriverBindingSupported (
928 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
929 IN EFI_HANDLE ControllerHandle
,
930 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
933 return ConSplitterSupported (
936 &gEfiConsoleInDeviceGuid
941 Test to see if Simple Pointer protocol could be supported on the Controller.
943 @param This Driver Binding protocol instance pointer.
944 @param ControllerHandle Handle of device to test.
945 @param RemainingDevicePath Optional parameter use to pick a specific child
948 @retval EFI_SUCCESS This driver supports this device.
949 @retval other This driver does not support this device.
954 ConSplitterSimplePointerDriverBindingSupported (
955 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
956 IN EFI_HANDLE ControllerHandle
,
957 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
960 return ConSplitterSupported (
963 &gEfiSimplePointerProtocolGuid
968 Test to see if Absolute Pointer protocol could be supported on the Controller.
970 @param This Driver Binding protocol instance pointer.
971 @param ControllerHandle Handle of device to test.
972 @param RemainingDevicePath Optional parameter use to pick a specific child
975 @retval EFI_SUCCESS This driver supports this device.
976 @retval other This driver does not support this device.
981 ConSplitterAbsolutePointerDriverBindingSupported (
982 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
983 IN EFI_HANDLE ControllerHandle
,
984 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
987 return ConSplitterSupported (
990 &gEfiAbsolutePointerProtocolGuid
996 Test to see if Console Out Device could be supported on the Controller.
998 @param This Driver Binding protocol instance pointer.
999 @param ControllerHandle Handle of device to test.
1000 @param RemainingDevicePath Optional parameter use to pick a specific child
1003 @retval EFI_SUCCESS This driver supports this device.
1004 @retval other This driver does not support this device.
1009 ConSplitterConOutDriverBindingSupported (
1010 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1011 IN EFI_HANDLE ControllerHandle
,
1012 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
1015 return ConSplitterSupported (
1018 &gEfiConsoleOutDeviceGuid
1023 Test to see if Standard Error Device could be supported on the Controller.
1025 @param This Driver Binding protocol instance pointer.
1026 @param ControllerHandle Handle of device to test.
1027 @param RemainingDevicePath Optional parameter use to pick a specific child
1030 @retval EFI_SUCCESS This driver supports this device.
1031 @retval other This driver does not support this device.
1036 ConSplitterStdErrDriverBindingSupported (
1037 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1038 IN EFI_HANDLE ControllerHandle
,
1039 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
1042 return ConSplitterSupported (
1045 &gEfiStandardErrorDeviceGuid
1051 Start ConSplitter on devcie handle by opening Console Device Guid on device handle
1052 and the console virtual handle. And Get the console interface on controller handle.
1054 @param This Driver Binding protocol instance pointer.
1055 @param ControllerHandle Handle of device.
1056 @param ConSplitterVirtualHandle Console virtual Handle.
1057 @param DeviceGuid The specified Console Device, such as ConInDev,
1059 @param InterfaceGuid The specified protocol to be opened.
1060 @param Interface Protocol interface returned.
1062 @retval EFI_SUCCESS This driver supports this device.
1063 @retval other Failed to open the specified Console Device Guid
1064 or specified protocol.
1069 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1070 IN EFI_HANDLE ControllerHandle
,
1071 IN EFI_HANDLE ConSplitterVirtualHandle
,
1072 IN EFI_GUID
*DeviceGuid
,
1073 IN EFI_GUID
*InterfaceGuid
,
1074 OUT VOID
**Interface
1081 // Check to see whether the ControllerHandle has the DeviceGuid on it.
1083 Status
= gBS
->OpenProtocol (
1087 This
->DriverBindingHandle
,
1089 EFI_OPEN_PROTOCOL_BY_DRIVER
1091 if (EFI_ERROR (Status
)) {
1096 // Open the Parent Handle for the child.
1098 Status
= gBS
->OpenProtocol (
1102 This
->DriverBindingHandle
,
1103 ConSplitterVirtualHandle
,
1104 EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
1106 if (EFI_ERROR (Status
)) {
1111 // Open InterfaceGuid on the virtul handle.
1113 Status
= gBS
->OpenProtocol (
1117 This
->DriverBindingHandle
,
1118 ConSplitterVirtualHandle
,
1119 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1122 if (!EFI_ERROR (Status
)) {
1127 // close the DeviceGuid on ConSplitter VirtualHandle.
1129 gBS
->CloseProtocol (
1132 This
->DriverBindingHandle
,
1133 ConSplitterVirtualHandle
1138 // close the DeviceGuid on ControllerHandle.
1140 gBS
->CloseProtocol (
1143 This
->DriverBindingHandle
,
1152 Start Console In Consplitter on device handle.
1154 @param This Driver Binding protocol instance pointer.
1155 @param ControllerHandle Handle of device to bind driver to.
1156 @param RemainingDevicePath Optional parameter use to pick a specific child
1159 @retval EFI_SUCCESS Console In Consplitter is added to ControllerHandle.
1160 @retval other Console In Consplitter does not support this device.
1165 ConSplitterConInDriverBindingStart (
1166 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1167 IN EFI_HANDLE ControllerHandle
,
1168 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
1172 EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*TextIn
;
1173 EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*TextInEx
;
1176 // Start ConSplitter on ControllerHandle, and create the virtual
1177 // agrogated console device on first call Start for a SimpleTextIn handle.
1179 Status
= ConSplitterStart (
1182 mConIn
.VirtualHandle
,
1183 &gEfiConsoleInDeviceGuid
,
1184 &gEfiSimpleTextInProtocolGuid
,
1187 if (EFI_ERROR (Status
)) {
1192 // Add this device into Text In devices list.
1194 Status
= ConSplitterTextInAddDevice (&mConIn
, TextIn
);
1195 if (EFI_ERROR (Status
)) {
1199 Status
= gBS
->OpenProtocol (
1201 &gEfiSimpleTextInputExProtocolGuid
,
1202 (VOID
**) &TextInEx
,
1203 This
->DriverBindingHandle
,
1204 mConIn
.VirtualHandle
,
1205 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1207 if (!EFI_ERROR (Status
)) {
1209 // If Simple Text Input Ex protocol exists,
1210 // add this device into Text In Ex devices list.
1212 Status
= ConSplitterTextInExAddDevice (&mConIn
, TextInEx
);
1220 Start Simple Pointer Consplitter on device handle.
1222 @param This Driver Binding protocol instance pointer.
1223 @param ControllerHandle Handle of device to bind driver to.
1224 @param RemainingDevicePath Optional parameter use to pick a specific child
1227 @retval EFI_SUCCESS Simple Pointer Consplitter is added to ControllerHandle.
1228 @retval other Simple Pointer Consplitter does not support this device.
1233 ConSplitterSimplePointerDriverBindingStart (
1234 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1235 IN EFI_HANDLE ControllerHandle
,
1236 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
1240 EFI_SIMPLE_POINTER_PROTOCOL
*SimplePointer
;
1243 // Start ConSplitter on ControllerHandle, and create the virtual
1244 // agrogated console device on first call Start for a SimplePointer handle.
1246 Status
= ConSplitterStart (
1249 mConIn
.VirtualHandle
,
1250 &gEfiSimplePointerProtocolGuid
,
1251 &gEfiSimplePointerProtocolGuid
,
1252 (VOID
**) &SimplePointer
1254 if (EFI_ERROR (Status
)) {
1259 // Add this devcie into Simple Pointer devices list.
1261 return ConSplitterSimplePointerAddDevice (&mConIn
, SimplePointer
);
1266 Start Absolute Pointer Consplitter on device handle.
1268 @param This Driver Binding protocol instance pointer.
1269 @param ControllerHandle Handle of device to bind driver to.
1270 @param RemainingDevicePath Optional parameter use to pick a specific child
1273 @retval EFI_SUCCESS Absolute Pointer Consplitter is added to ControllerHandle.
1274 @retval other Absolute Pointer Consplitter does not support this device.
1279 ConSplitterAbsolutePointerDriverBindingStart (
1280 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1281 IN EFI_HANDLE ControllerHandle
,
1282 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
1286 EFI_ABSOLUTE_POINTER_PROTOCOL
*AbsolutePointer
;
1289 // Start ConSplitter on ControllerHandle, and create the virtual
1290 // agrogated console device on first call Start for a AbsolutePointer handle.
1292 Status
= ConSplitterStart (
1295 mConIn
.VirtualHandle
,
1296 &gEfiAbsolutePointerProtocolGuid
,
1297 &gEfiAbsolutePointerProtocolGuid
,
1298 (VOID
**) &AbsolutePointer
1301 if (EFI_ERROR (Status
)) {
1306 // Add this devcie into Absolute Pointer devices list.
1308 return ConSplitterAbsolutePointerAddDevice (&mConIn
, AbsolutePointer
);
1313 Start Console Out Consplitter on device handle.
1315 @param This Driver Binding protocol instance pointer.
1316 @param ControllerHandle Handle of device to bind driver to.
1317 @param RemainingDevicePath Optional parameter use to pick a specific child
1320 @retval EFI_SUCCESS Console Out Consplitter is added to ControllerHandle.
1321 @retval other Console Out Consplitter does not support this device.
1326 ConSplitterConOutDriverBindingStart (
1327 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1328 IN EFI_HANDLE ControllerHandle
,
1329 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
1333 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
;
1334 EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
;
1335 EFI_UGA_DRAW_PROTOCOL
*UgaDraw
;
1337 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*Info
;
1340 // Start ConSplitter on ControllerHandle, and create the virtual
1341 // agrogated console device on first call Start for a ConsoleOut handle.
1343 Status
= ConSplitterStart (
1346 mConOut
.VirtualHandle
,
1347 &gEfiConsoleOutDeviceGuid
,
1348 &gEfiSimpleTextOutProtocolGuid
,
1351 if (EFI_ERROR (Status
)) {
1355 GraphicsOutput
= NULL
;
1358 // Try to Open Graphics Output protocol
1360 Status
= gBS
->OpenProtocol (
1362 &gEfiGraphicsOutputProtocolGuid
,
1363 (VOID
**) &GraphicsOutput
,
1364 This
->DriverBindingHandle
,
1365 mConOut
.VirtualHandle
,
1366 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1369 if (EFI_ERROR (Status
) && FeaturePcdGet (PcdUgaConsumeSupport
)) {
1371 // Open UGA DRAW protocol
1375 &gEfiUgaDrawProtocolGuid
,
1377 This
->DriverBindingHandle
,
1378 mConOut
.VirtualHandle
,
1379 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1384 // When new console device is added, the new mode will be set later,
1385 // so put current mode back to init state.
1387 mConOut
.TextOutMode
.Mode
= 0xFF;
1390 // If both ConOut and StdErr incorporate the same Text Out device,
1391 // their MaxMode and QueryData should be the intersection of both.
1393 Status
= ConSplitterTextOutAddDevice (&mConOut
, TextOut
, GraphicsOutput
, UgaDraw
);
1394 ConSplitterTextOutSetAttribute (&mConOut
.TextOut
, EFI_TEXT_ATTR (EFI_LIGHTGRAY
, EFI_BLACK
));
1396 if (FeaturePcdGet (PcdConOutUgaSupport
)) {
1398 // Get the UGA mode data of ConOut from the current mode
1400 if (GraphicsOutput
!= NULL
) {
1401 Status
= GraphicsOutput
->QueryMode (GraphicsOutput
, GraphicsOutput
->Mode
->Mode
, &SizeOfInfo
, &Info
);
1402 if (EFI_ERROR (Status
)) {
1405 ASSERT ( SizeOfInfo
<= sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
));
1407 mConOut
.UgaHorizontalResolution
= Info
->HorizontalResolution
;
1408 mConOut
.UgaVerticalResolution
= Info
->VerticalResolution
;
1409 mConOut
.UgaColorDepth
= 32;
1410 mConOut
.UgaRefreshRate
= 60;
1414 } else if (UgaDraw
!= NULL
) {
1415 Status
= UgaDraw
->GetMode (
1417 &mConOut
.UgaHorizontalResolution
,
1418 &mConOut
.UgaVerticalResolution
,
1419 &mConOut
.UgaColorDepth
,
1420 &mConOut
.UgaRefreshRate
1430 Start Standard Error Consplitter on device handle.
1432 @param This Driver Binding protocol instance pointer.
1433 @param ControllerHandle Handle of device to bind driver to.
1434 @param RemainingDevicePath Optional parameter use to pick a specific child
1437 @retval EFI_SUCCESS Standard Error Consplitter is added to ControllerHandle.
1438 @retval other Standard Error Consplitter does not support this device.
1443 ConSplitterStdErrDriverBindingStart (
1444 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1445 IN EFI_HANDLE ControllerHandle
,
1446 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
1450 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
;
1453 // Start ConSplitter on ControllerHandle, and create the virtual
1454 // agrogated console device on first call Start for a StandardError handle.
1456 Status
= ConSplitterStart (
1459 mStdErr
.VirtualHandle
,
1460 &gEfiStandardErrorDeviceGuid
,
1461 &gEfiSimpleTextOutProtocolGuid
,
1464 if (EFI_ERROR (Status
)) {
1469 // When new console device is added, the new mode will be set later,
1470 // so put current mode back to init state.
1472 mStdErr
.TextOutMode
.Mode
= 0xFF;
1475 // If both ConOut and StdErr incorporate the same Text Out device,
1476 // their MaxMode and QueryData should be the intersection of both.
1478 Status
= ConSplitterTextOutAddDevice (&mStdErr
, TextOut
, NULL
, NULL
);
1479 ConSplitterTextOutSetAttribute (&mStdErr
.TextOut
, EFI_TEXT_ATTR (EFI_MAGENTA
, EFI_BLACK
));
1486 Stop ConSplitter on device handle by closing Console Device Guid on device handle
1487 and the console virtual handle.
1489 @param This Protocol instance pointer.
1490 @param ControllerHandle Handle of device.
1491 @param ConSplitterVirtualHandle Console virtual Handle.
1492 @param DeviceGuid The specified Console Device, such as ConInDev,
1494 @param InterfaceGuid The specified protocol to be opened.
1495 @param Interface Protocol interface returned.
1497 @retval EFI_SUCCESS Stop ConSplitter on ControllerHandle successfully.
1498 @retval other Failed to Stop ConSplitter on ControllerHandle.
1503 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1504 IN EFI_HANDLE ControllerHandle
,
1505 IN EFI_HANDLE ConSplitterVirtualHandle
,
1506 IN EFI_GUID
*DeviceGuid
,
1507 IN EFI_GUID
*InterfaceGuid
,
1513 Status
= gBS
->OpenProtocol (
1517 This
->DriverBindingHandle
,
1519 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1521 if (EFI_ERROR (Status
)) {
1525 // close the protocol refered.
1527 gBS
->CloseProtocol (
1530 This
->DriverBindingHandle
,
1531 ConSplitterVirtualHandle
1534 gBS
->CloseProtocol (
1537 This
->DriverBindingHandle
,
1546 Stop Console In ConSplitter on ControllerHandle by closing Console In Devcice GUID.
1548 @param This Driver Binding protocol instance pointer.
1549 @param ControllerHandle Handle of device to stop driver on
1550 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
1551 children is zero stop the entire bus driver.
1552 @param ChildHandleBuffer List of Child Handles to Stop.
1554 @retval EFI_SUCCESS This driver is removed ControllerHandle
1555 @retval other This driver was not removed from this device
1560 ConSplitterConInDriverBindingStop (
1561 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1562 IN EFI_HANDLE ControllerHandle
,
1563 IN UINTN NumberOfChildren
,
1564 IN EFI_HANDLE
*ChildHandleBuffer
1568 EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*TextIn
;
1569 EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*TextInEx
;
1571 if (NumberOfChildren
== 0) {
1575 Status
= gBS
->OpenProtocol (
1577 &gEfiSimpleTextInputExProtocolGuid
,
1578 (VOID
**) &TextInEx
,
1579 This
->DriverBindingHandle
,
1581 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1583 if (!EFI_ERROR (Status
)) {
1585 // If Simple Text Input Ex protocol exists,
1586 // remove device from Text Input Ex devices list.
1588 Status
= ConSplitterTextInExDeleteDevice (&mConIn
, TextInEx
);
1589 if (EFI_ERROR (Status
)) {
1595 // Close Simple Text In protocol on controller handle and virtual handle.
1597 Status
= ConSplitterStop (
1600 mConIn
.VirtualHandle
,
1601 &gEfiConsoleInDeviceGuid
,
1602 &gEfiSimpleTextInProtocolGuid
,
1605 if (EFI_ERROR (Status
)) {
1610 // Remove device from Text Input devices list.
1612 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
);
1669 Stop Absolute Pointer protocol ConSplitter on ControllerHandle by closing
1670 Absolute Pointer protocol.
1672 @param This Driver Binding protocol instance pointer.
1673 @param ControllerHandle Handle of device to stop driver on
1674 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
1675 children is zero stop the entire bus driver.
1676 @param ChildHandleBuffer List of Child Handles to Stop.
1678 @retval EFI_SUCCESS This driver is removed ControllerHandle
1679 @retval other This driver was not removed from this device
1684 ConSplitterAbsolutePointerDriverBindingStop (
1685 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1686 IN EFI_HANDLE ControllerHandle
,
1687 IN UINTN NumberOfChildren
,
1688 IN EFI_HANDLE
*ChildHandleBuffer
1692 EFI_ABSOLUTE_POINTER_PROTOCOL
*AbsolutePointer
;
1694 if (NumberOfChildren
== 0) {
1699 // Close Absolute Pointer protocol on controller handle and virtual handle.
1701 Status
= ConSplitterStop (
1704 mConIn
.VirtualHandle
,
1705 &gEfiAbsolutePointerProtocolGuid
,
1706 &gEfiAbsolutePointerProtocolGuid
,
1707 (VOID
**) &AbsolutePointer
1709 if (EFI_ERROR (Status
)) {
1714 // Remove this device from Absolute Pointer device list.
1716 return ConSplitterAbsolutePointerDeleteDevice (&mConIn
, AbsolutePointer
);
1721 Stop Console Out ConSplitter on device handle by closing Console Out Devcice GUID.
1723 @param This Driver Binding protocol instance pointer.
1724 @param ControllerHandle Handle of device to stop driver on
1725 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
1726 children is zero stop the entire bus driver.
1727 @param ChildHandleBuffer List of Child Handles to Stop.
1729 @retval EFI_SUCCESS This driver is removed ControllerHandle
1730 @retval other This driver was not removed from this device
1735 ConSplitterConOutDriverBindingStop (
1736 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1737 IN EFI_HANDLE ControllerHandle
,
1738 IN UINTN NumberOfChildren
,
1739 IN EFI_HANDLE
*ChildHandleBuffer
1743 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
;
1745 if (NumberOfChildren
== 0) {
1750 // Close Absolute Pointer protocol on controller handle and virtual handle.
1752 Status
= ConSplitterStop (
1755 mConOut
.VirtualHandle
,
1756 &gEfiConsoleOutDeviceGuid
,
1757 &gEfiSimpleTextOutProtocolGuid
,
1760 if (EFI_ERROR (Status
)) {
1765 // Remove this device from Text Out device list.
1767 return ConSplitterTextOutDeleteDevice (&mConOut
, TextOut
);
1772 Stop Standard Error ConSplitter on ControllerHandle by closing Standard Error GUID.
1774 @param This Driver Binding protocol instance pointer.
1775 @param ControllerHandle Handle of device to stop driver on
1776 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
1777 children is zero stop the entire bus driver.
1778 @param ChildHandleBuffer List of Child Handles to Stop.
1780 @retval EFI_SUCCESS This driver is removed ControllerHandle
1781 @retval other This driver was not removed from this device
1786 ConSplitterStdErrDriverBindingStop (
1787 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1788 IN EFI_HANDLE ControllerHandle
,
1789 IN UINTN NumberOfChildren
,
1790 IN EFI_HANDLE
*ChildHandleBuffer
1794 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
;
1796 if (NumberOfChildren
== 0) {
1801 // Close Standard Error Device on controller handle and virtual handle.
1803 Status
= ConSplitterStop (
1806 mStdErr
.VirtualHandle
,
1807 &gEfiStandardErrorDeviceGuid
,
1808 &gEfiSimpleTextOutProtocolGuid
,
1811 if (EFI_ERROR (Status
)) {
1815 // Delete this console error out device's data structures.
1817 return ConSplitterTextOutDeleteDevice (&mStdErr
, TextOut
);
1822 Take the passed in Buffer of size ElementSize and grow the buffer
1823 by CONSOLE_SPLITTER_ALLOC_UNIT * ElementSize bytes.
1824 Copy the current data in Buffer to the new version of Buffer and
1825 free the old version of buffer.
1827 @param ElementSize Size of element in array.
1828 @param Count Current number of elements in array.
1829 @param Buffer Bigger version of passed in Buffer with all the
1832 @retval EFI_SUCCESS Buffer size has grown.
1833 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
1837 ConSplitterGrowBuffer (
1838 IN UINTN ElementSize
,
1839 IN OUT UINTN
*Count
,
1840 IN OUT VOID
**Buffer
1846 // grow the buffer to new buffer size,
1847 // copy the old buffer's content to the new-size buffer,
1848 // then free the old buffer.
1850 Ptr
= ReallocatePool (
1851 ElementSize
* (*Count
),
1852 ElementSize
* ((*Count
) + CONSOLE_SPLITTER_ALLOC_UNIT
),
1856 return EFI_OUT_OF_RESOURCES
;
1858 *Count
+= CONSOLE_SPLITTER_ALLOC_UNIT
;
1865 Add Text Input Device in Consplitter Text Input list.
1867 @param Private Text In Splitter pointer.
1868 @param TextIn Simple Text Input protocol pointer.
1870 @retval EFI_SUCCESS Text Input Device added successfully.
1871 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
1875 ConSplitterTextInAddDevice (
1876 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
1877 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*TextIn
1883 // If the Text In List is full, enlarge it by calling ConSplitterGrowBuffer().
1885 if (Private
->CurrentNumberOfConsoles
>= Private
->TextInListCount
) {
1886 Status
= ConSplitterGrowBuffer (
1887 sizeof (EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*),
1888 &Private
->TextInListCount
,
1889 (VOID
**) &Private
->TextInList
1891 if (EFI_ERROR (Status
)) {
1892 return EFI_OUT_OF_RESOURCES
;
1896 // Add the new text-in device data structure into the Text In List.
1898 Private
->TextInList
[Private
->CurrentNumberOfConsoles
] = TextIn
;
1899 Private
->CurrentNumberOfConsoles
++;
1902 // Extra CheckEvent added to reduce the double CheckEvent().
1904 gBS
->CheckEvent (TextIn
->WaitForKey
);
1911 Remove Text Input Device from Consplitter Text Input list.
1913 @param Private Text In Splitter pointer.
1914 @param TextIn Simple Text protocol pointer.
1916 @retval EFI_SUCCESS Simple Text Device removed successfully.
1917 @retval EFI_NOT_FOUND No Simple Text Device found.
1921 ConSplitterTextInDeleteDevice (
1922 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
1923 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*TextIn
1928 // Remove the specified text-in device data structure from the Text In List,
1929 // and rearrange the remaining data structures in the Text In List.
1931 for (Index
= 0; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
1932 if (Private
->TextInList
[Index
] == TextIn
) {
1933 for (; Index
< Private
->CurrentNumberOfConsoles
- 1; Index
++) {
1934 Private
->TextInList
[Index
] = Private
->TextInList
[Index
+ 1];
1937 Private
->CurrentNumberOfConsoles
--;
1942 return EFI_NOT_FOUND
;
1946 Add Text Input Ex Device in Consplitter Text Input Ex list.
1948 @param Private Text In Splitter pointer.
1949 @param TextInEx Simple Text Input Ex Input protocol pointer.
1951 @retval EFI_SUCCESS Text Input Ex Device added successfully.
1952 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
1956 ConSplitterTextInExAddDevice (
1957 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
1958 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*TextInEx
1963 TEXT_IN_EX_SPLITTER_NOTIFY
*CurrentNotify
;
1964 UINTN TextInExListCount
;
1967 // Enlarge the NotifyHandleList and the TextInExList
1969 if (Private
->CurrentNumberOfExConsoles
>= Private
->TextInExListCount
) {
1970 for (Link
= Private
->NotifyList
.ForwardLink
; Link
!= &Private
->NotifyList
; Link
= Link
->ForwardLink
) {
1971 CurrentNotify
= TEXT_IN_EX_SPLITTER_NOTIFY_FROM_THIS (Link
);
1972 TextInExListCount
= Private
->TextInExListCount
;
1974 Status
= ConSplitterGrowBuffer (
1975 sizeof (EFI_HANDLE
),
1977 (VOID
**) &CurrentNotify
->NotifyHandleList
1979 if (EFI_ERROR (Status
)) {
1980 return EFI_OUT_OF_RESOURCES
;
1984 TextInExListCount
= Private
->TextInExListCount
;
1985 Status
= ConSplitterGrowBuffer (
1986 sizeof (EFI_KEY_DATA
),
1988 (VOID
**) &Private
->KeyQueue
1990 if (EFI_ERROR (Status
)) {
1991 return EFI_OUT_OF_RESOURCES
;
1994 Status
= ConSplitterGrowBuffer (
1995 sizeof (EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*),
1996 &Private
->TextInExListCount
,
1997 (VOID
**) &Private
->TextInExList
1999 if (EFI_ERROR (Status
)) {
2000 return EFI_OUT_OF_RESOURCES
;
2005 // Register the key notify in the new text-in device
2007 for (Link
= Private
->NotifyList
.ForwardLink
; Link
!= &Private
->NotifyList
; Link
= Link
->ForwardLink
) {
2008 CurrentNotify
= TEXT_IN_EX_SPLITTER_NOTIFY_FROM_THIS (Link
);
2009 Status
= TextInEx
->RegisterKeyNotify (
2011 &CurrentNotify
->KeyData
,
2012 CurrentNotify
->KeyNotificationFn
,
2013 &CurrentNotify
->NotifyHandleList
[Private
->CurrentNumberOfExConsoles
]
2015 if (EFI_ERROR (Status
)) {
2016 for (Link
= Link
->BackLink
; Link
!= &Private
->NotifyList
; Link
= Link
->BackLink
) {
2017 CurrentNotify
= TEXT_IN_EX_SPLITTER_NOTIFY_FROM_THIS (Link
);
2018 TextInEx
->UnregisterKeyNotify (
2020 CurrentNotify
->NotifyHandleList
[Private
->CurrentNumberOfExConsoles
]
2028 // Add the new text-in device data structure into the Text Input Ex List.
2030 Private
->TextInExList
[Private
->CurrentNumberOfExConsoles
] = TextInEx
;
2031 Private
->CurrentNumberOfExConsoles
++;
2034 // Sync current toggle state to this new console input device.
2036 TextInEx
->SetState (TextInEx
, &Private
->PhysicalKeyToggleState
);
2039 // Extra CheckEvent added to reduce the double CheckEvent().
2041 gBS
->CheckEvent (TextInEx
->WaitForKeyEx
);
2047 Remove Text Ex Device from Consplitter Text Input Ex list.
2049 @param Private Text In Splitter pointer.
2050 @param TextInEx Simple Text Ex protocol pointer.
2052 @retval EFI_SUCCESS Simple Text Input Ex Device removed successfully.
2053 @retval EFI_NOT_FOUND No Simple Text Input Ex Device found.
2057 ConSplitterTextInExDeleteDevice (
2058 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
2059 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
;
2083 Add Simple Pointer Device in Consplitter Simple Pointer list.
2085 @param Private Text In Splitter pointer.
2086 @param SimplePointer Simple Pointer protocol pointer.
2088 @retval EFI_SUCCESS Simple Pointer Device added successfully.
2089 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
2093 ConSplitterSimplePointerAddDevice (
2094 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
2095 IN EFI_SIMPLE_POINTER_PROTOCOL
*SimplePointer
2101 // If the Simple Pointer List is full, enlarge it by calling ConSplitterGrowBuffer().
2103 if (Private
->CurrentNumberOfPointers
>= Private
->PointerListCount
) {
2104 Status
= ConSplitterGrowBuffer (
2105 sizeof (EFI_SIMPLE_POINTER_PROTOCOL
*),
2106 &Private
->PointerListCount
,
2107 (VOID
**) &Private
->PointerList
2109 if (EFI_ERROR (Status
)) {
2110 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
++;
2124 Remove Simple Pointer Device from Consplitter Simple Pointer list.
2126 @param Private Text In Splitter pointer.
2127 @param SimplePointer Simple Pointer protocol pointer.
2129 @retval EFI_SUCCESS Simple Pointer Device removed successfully.
2130 @retval EFI_NOT_FOUND No Simple Pointer Device found.
2134 ConSplitterSimplePointerDeleteDevice (
2135 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
2136 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
;
2160 Add Absolute Pointer Device in Consplitter Absolute Pointer list.
2162 @param Private Text In Splitter pointer.
2163 @param AbsolutePointer Absolute Pointer protocol pointer.
2165 @retval EFI_SUCCESS Absolute Pointer Device added successfully.
2166 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
2170 ConSplitterAbsolutePointerAddDevice (
2171 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
2172 IN EFI_ABSOLUTE_POINTER_PROTOCOL
*AbsolutePointer
2178 // If the Absolute Pointer List is full, enlarge it by calling ConSplitterGrowBuffer().
2180 if (Private
->CurrentNumberOfAbsolutePointers
>= Private
->AbsolutePointerListCount
) {
2181 Status
= ConSplitterGrowBuffer (
2182 sizeof (EFI_ABSOLUTE_POINTER_PROTOCOL
*),
2183 &Private
->AbsolutePointerListCount
,
2184 (VOID
**) &Private
->AbsolutePointerList
2186 if (EFI_ERROR (Status
)) {
2187 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
++;
2201 Remove Absolute Pointer Device from Consplitter Absolute Pointer list.
2203 @param Private Text In Splitter pointer.
2204 @param AbsolutePointer Absolute Pointer protocol pointer.
2206 @retval EFI_SUCCESS Absolute Pointer Device removed successfully.
2207 @retval EFI_NOT_FOUND No Absolute Pointer Device found.
2211 ConSplitterAbsolutePointerDeleteDevice (
2212 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
2213 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
) {
2294 Size
= Private
->CurrentNumberOfConsoles
* sizeof (INT32
);
2296 SrcAddress
= OldTextOutModeMap
;
2297 NewStepSize
= NewSize
/ sizeof(INT32
);
2298 // If Private->CurrentNumberOfConsoles is not zero and OldTextOutModeMap
2299 // is not NULL, it indicates that the original TextOutModeMap is not enough
2300 // for the new console devices and has been enlarged by CONSOLE_SPLITTER_ALLOC_UNIT columns.
2302 OldStepSize
= NewStepSize
- CONSOLE_SPLITTER_ALLOC_UNIT
;
2305 // Copy the old data to the new one
2307 while (Index
< Private
->TextOutMode
.MaxMode
) {
2308 CopyMem (TextOutModeMap
, SrcAddress
, Size
);
2310 // Go to next row of new TextOutModeMap.
2312 TextOutModeMap
+= NewStepSize
;
2314 // Go to next row of old TextOutModeMap.
2316 SrcAddress
+= OldStepSize
;
2320 // Free the old buffer
2322 FreePool (OldTextOutModeMap
);
2330 Add new device's output mode to console splitter's mode list.
2332 @param Private Text Out Splitter pointer
2333 @param TextOut Simple Text Output protocol pointer.
2335 @retval EFI_SUCCESS Device added successfully.
2336 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
2340 ConSplitterAddOutputMode (
2341 IN TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
,
2342 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
2350 MaxMode
= TextOut
->Mode
->MaxMode
;
2351 Private
->TextOutMode
.MaxMode
= MaxMode
;
2354 // Grow the buffer if query data buffer is not large enough to
2355 // hold all the mode supported by the first console.
2357 while (MaxMode
> (INT32
) Private
->TextOutQueryDataCount
) {
2358 Status
= ConSplitterGrowBuffer (
2359 sizeof (TEXT_OUT_SPLITTER_QUERY_DATA
),
2360 &Private
->TextOutQueryDataCount
,
2361 (VOID
**) &Private
->TextOutQueryData
2363 if (EFI_ERROR (Status
)) {
2364 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
;
2375 // As the first textout device, directly add the mode in to QueryData
2376 // and at the same time record the mapping between QueryData and TextOut.
2380 while (Mode
< MaxMode
) {
2381 Status
= TextOut
->QueryMode (
2384 &Private
->TextOutQueryData
[Mode
].Columns
,
2385 &Private
->TextOutQueryData
[Mode
].Rows
2388 // If mode 1 (80x50) is not supported, make sure mode 1 in TextOutQueryData
2391 if ((EFI_ERROR(Status
)) && (Mode
== 1)) {
2392 Private
->TextOutQueryData
[Mode
].Columns
= 0;
2393 Private
->TextOutQueryData
[Mode
].Rows
= 0;
2395 Private
->TextOutModeMap
[Index
] = Mode
;
2397 Index
+= Private
->TextOutListCount
;
2404 Reconstruct TextOutModeMap to get intersection of modes.
2406 This routine reconstruct TextOutModeMap to get the intersection
2407 of modes for all console out devices. Because EFI/UEFI spec require
2408 mode 0 is 80x25, mode 1 is 80x50, this routine will not check the
2409 intersection for mode 0 and mode 1.
2411 @param TextOutModeMap Current text out mode map, begin with the mode 80x25
2412 @param NewlyAddedMap New text out mode map, begin with the mode 80x25
2413 @param MapStepSize Mode step size for one console device
2414 @param NewMapStepSize New Mode step size for one console device
2415 @param MaxMode IN: Current max text mode, OUT: Updated max text mode.
2416 @param CurrentMode IN: Current text mode, OUT: Updated current text mode.
2420 ConSplitterGetIntersection (
2421 IN INT32
*TextOutModeMap
,
2422 IN INT32
*NewlyAddedMap
,
2423 IN UINTN MapStepSize
,
2424 IN UINTN NewMapStepSize
,
2425 IN OUT INT32
*MaxMode
,
2426 IN OUT INT32
*CurrentMode
2430 INT32
*CurrentMapEntry
;
2431 INT32
*NextMapEntry
;
2433 INT32 CurrentMaxMode
;
2437 // According to EFI/UEFI spec, mode 0 and mode 1 have been reserved
2438 // for 80x25 and 80x50 in Simple Text Out protocol, so don't make intersection
2439 // for mode 0 and mode 1, mode number starts from 2.
2442 CurrentMapEntry
= &TextOutModeMap
[MapStepSize
* 2];
2443 NextMapEntry
= CurrentMapEntry
;
2444 NewMapEntry
= &NewlyAddedMap
[NewMapStepSize
* 2];
2446 CurrentMaxMode
= *MaxMode
;
2447 Mode
= *CurrentMode
;
2449 while (Index
< CurrentMaxMode
) {
2450 if (*NewMapEntry
== -1) {
2452 // This mode is not supported any more. Remove it. Special care
2453 // must be taken as this remove will also affect current mode;
2455 if (Index
== *CurrentMode
) {
2457 } else if (Index
< *CurrentMode
) {
2462 if (CurrentMapEntry
!= NextMapEntry
) {
2463 CopyMem (NextMapEntry
, CurrentMapEntry
, MapStepSize
* sizeof (INT32
));
2466 NextMapEntry
+= MapStepSize
;
2469 CurrentMapEntry
+= MapStepSize
;
2470 NewMapEntry
+= NewMapStepSize
;
2474 *CurrentMode
= Mode
;
2480 Sync the device's output mode to console splitter's mode list.
2482 @param Private Text Out Splitter pointer.
2483 @param TextOut Simple Text Output protocol pointer.
2487 ConSplitterSyncOutputMode (
2488 IN TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
,
2489 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
2492 INT32 CurrentMaxMode
;
2495 INT32
*TextOutModeMap
;
2498 TEXT_OUT_SPLITTER_QUERY_DATA
*TextOutQueryData
;
2505 // Must make sure that current mode won't change even if mode number changes
2507 CurrentMaxMode
= Private
->TextOutMode
.MaxMode
;
2508 TextOutModeMap
= Private
->TextOutModeMap
;
2509 StepSize
= Private
->TextOutListCount
;
2510 TextOutQueryData
= Private
->TextOutQueryData
;
2513 // Query all the mode that the newly added TextOut supports
2516 MapTable
= TextOutModeMap
+ Private
->CurrentNumberOfConsoles
;
2517 while (Mode
< TextOut
->Mode
->MaxMode
) {
2518 Status
= TextOut
->QueryMode (TextOut
, Mode
, &Columns
, &Rows
);
2520 if (EFI_ERROR(Status
)) {
2523 // If mode 1 (80x50) is not supported, make sure mode 1 in TextOutQueryData
2526 MapTable
[StepSize
] = Mode
;
2527 TextOutQueryData
[Mode
].Columns
= 0;
2528 TextOutQueryData
[Mode
].Rows
= 0;
2534 // Search the intersection map and QueryData database to see if they intersects
2537 while (Index
< CurrentMaxMode
) {
2538 QueryMode
= *(TextOutModeMap
+ Index
* StepSize
);
2539 if ((TextOutQueryData
[QueryMode
].Rows
== Rows
) && (TextOutQueryData
[QueryMode
].Columns
== Columns
)) {
2540 MapTable
[Index
* StepSize
] = Mode
;
2548 // Now search the TextOutModeMap table to find the intersection of supported
2549 // mode between ConSplitter and the newly added device.
2551 ConSplitterGetIntersection (
2556 &Private
->TextOutMode
.MaxMode
,
2557 &Private
->TextOutMode
.Mode
2565 Sync output device between ConOut and StdErr output.
2567 @retval EFI_SUCCESS Sync implemented successfully.
2568 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
2572 ConSplitterGetIntersectionBetweenConOutAndStrErr (
2576 UINTN ConOutNumOfConsoles
;
2577 UINTN StdErrNumOfConsoles
;
2578 TEXT_OUT_AND_GOP_DATA
*ConOutTextOutList
;
2579 TEXT_OUT_AND_GOP_DATA
*StdErrTextOutList
;
2583 UINTN ConOutColumns
;
2585 UINTN StdErrColumns
;
2586 INT32 ConOutMaxMode
;
2587 INT32 StdErrMaxMode
;
2592 INT32
*ConOutModeMap
;
2593 INT32
*StdErrModeMap
;
2594 INT32
*ConOutMapTable
;
2595 INT32
*StdErrMapTable
;
2596 TEXT_OUT_SPLITTER_QUERY_DATA
*ConOutQueryData
;
2597 TEXT_OUT_SPLITTER_QUERY_DATA
*StdErrQueryData
;
2598 UINTN ConOutStepSize
;
2599 UINTN StdErrStepSize
;
2600 BOOLEAN FoundTheSameTextOut
;
2601 UINTN ConOutMapTableSize
;
2602 UINTN StdErrMapTableSize
;
2604 ConOutNumOfConsoles
= mConOut
.CurrentNumberOfConsoles
;
2605 StdErrNumOfConsoles
= mStdErr
.CurrentNumberOfConsoles
;
2606 ConOutTextOutList
= mConOut
.TextOutList
;
2607 StdErrTextOutList
= mStdErr
.TextOutList
;
2610 FoundTheSameTextOut
= FALSE
;
2611 while ((Indexi
< ConOutNumOfConsoles
) && (!FoundTheSameTextOut
)) {
2613 while (Indexj
< StdErrNumOfConsoles
) {
2614 if (ConOutTextOutList
->TextOut
== StdErrTextOutList
->TextOut
) {
2615 FoundTheSameTextOut
= TRUE
;
2620 StdErrTextOutList
++;
2624 ConOutTextOutList
++;
2627 if (!FoundTheSameTextOut
) {
2631 // Must make sure that current mode won't change even if mode number changes
2633 ConOutMaxMode
= mConOut
.TextOutMode
.MaxMode
;
2634 ConOutModeMap
= mConOut
.TextOutModeMap
;
2635 ConOutStepSize
= mConOut
.TextOutListCount
;
2636 ConOutQueryData
= mConOut
.TextOutQueryData
;
2638 StdErrMaxMode
= mStdErr
.TextOutMode
.MaxMode
;
2639 StdErrModeMap
= mStdErr
.TextOutModeMap
;
2640 StdErrStepSize
= mStdErr
.TextOutListCount
;
2641 StdErrQueryData
= mStdErr
.TextOutQueryData
;
2644 // Allocate the map table and set the map table's index to -1.
2646 ConOutMapTableSize
= ConOutMaxMode
* sizeof (INT32
);
2647 ConOutMapTable
= AllocateZeroPool (ConOutMapTableSize
);
2648 if (ConOutMapTable
== NULL
) {
2649 return EFI_OUT_OF_RESOURCES
;
2652 SetMem (ConOutMapTable
, ConOutMapTableSize
, 0xFF);
2654 StdErrMapTableSize
= StdErrMaxMode
* sizeof (INT32
);
2655 StdErrMapTable
= AllocateZeroPool (StdErrMapTableSize
);
2656 if (StdErrMapTable
== NULL
) {
2657 return EFI_OUT_OF_RESOURCES
;
2660 SetMem (StdErrMapTable
, StdErrMapTableSize
, 0xFF);
2663 // Find the intersection of the two set of modes. If they actually intersect, the
2664 // corresponding entry in the map table is set to 1.
2667 while (Mode
< ConOutMaxMode
) {
2669 // Search the intersection map and QueryData database to see if they intersect
2672 ConOutMode
= *(ConOutModeMap
+ Mode
* ConOutStepSize
);
2673 ConOutRows
= ConOutQueryData
[ConOutMode
].Rows
;
2674 ConOutColumns
= ConOutQueryData
[ConOutMode
].Columns
;
2675 while (Index
< StdErrMaxMode
) {
2676 StdErrMode
= *(StdErrModeMap
+ Index
* StdErrStepSize
);
2677 StdErrRows
= StdErrQueryData
[StdErrMode
].Rows
;
2678 StdErrColumns
= StdErrQueryData
[StdErrMode
].Columns
;
2679 if ((StdErrRows
== ConOutRows
) && (StdErrColumns
== ConOutColumns
)) {
2680 ConOutMapTable
[Mode
] = 1;
2681 StdErrMapTable
[Index
] = 1;
2691 // Now search the TextOutModeMap table to find the intersection of supported
2692 // mode between ConSplitter and the newly added device.
2694 ConSplitterGetIntersection (
2697 mConOut
.TextOutListCount
,
2699 &(mConOut
.TextOutMode
.MaxMode
),
2700 &(mConOut
.TextOutMode
.Mode
)
2703 if (mConOut
.TextOutMode
.Mode
< 0) {
2704 mConOut
.TextOut
.SetMode (&(mConOut
.TextOut
), 0);
2707 ConSplitterGetIntersection (
2710 mStdErr
.TextOutListCount
,
2712 &(mStdErr
.TextOutMode
.MaxMode
),
2713 &(mStdErr
.TextOutMode
.Mode
)
2716 if (mStdErr
.TextOutMode
.Mode
< 0) {
2717 mStdErr
.TextOut
.SetMode (&(mStdErr
.TextOut
), 0);
2720 FreePool (ConOutMapTable
);
2721 FreePool (StdErrMapTable
);
2728 Add Grahpics Output modes into Consplitter Text Out list.
2730 @param Private Text Out Splitter pointer.
2731 @param GraphicsOutput Graphics Output protocol pointer.
2732 @param UgaDraw UGA Draw protocol pointer.
2734 @retval EFI_SUCCESS Output mode added successfully.
2735 @retval other Failed to add output mode.
2739 ConSplitterAddGraphicsOutputMode (
2740 IN TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
,
2741 IN EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
,
2742 IN EFI_UGA_DRAW_PROTOCOL
*UgaDraw
2748 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*Mode
;
2750 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*Info
;
2751 EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE
*CurrentGraphicsOutputMode
;
2752 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*ModeBuffer
;
2753 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*MatchedMode
;
2756 BOOLEAN AlreadyExist
;
2757 UINT32 UgaHorizontalResolution
;
2758 UINT32 UgaVerticalResolution
;
2759 UINT32 UgaColorDepth
;
2760 UINT32 UgaRefreshRate
;
2762 ASSERT (GraphicsOutput
!= NULL
|| UgaDraw
!= NULL
);
2764 CurrentGraphicsOutputMode
= Private
->GraphicsOutput
.Mode
;
2768 Status
= EFI_SUCCESS
;
2770 if (Private
->CurrentNumberOfUgaDraw
!= 0) {
2772 // If any UGA device has already been added, then there is no need to
2773 // calculate intersection of display mode of different GOP/UGA device,
2774 // since only one display mode will be exported (i.e. user-defined mode)
2779 if (GraphicsOutput
!= NULL
) {
2780 if (Private
->CurrentNumberOfGraphicsOutput
== 0) {
2782 // This is the first Graphics Output device added
2784 CurrentGraphicsOutputMode
->MaxMode
= GraphicsOutput
->Mode
->MaxMode
;
2785 CurrentGraphicsOutputMode
->Mode
= GraphicsOutput
->Mode
->Mode
;
2786 CopyMem (CurrentGraphicsOutputMode
->Info
, GraphicsOutput
->Mode
->Info
, GraphicsOutput
->Mode
->SizeOfInfo
);
2787 CurrentGraphicsOutputMode
->SizeOfInfo
= GraphicsOutput
->Mode
->SizeOfInfo
;
2788 CurrentGraphicsOutputMode
->FrameBufferBase
= GraphicsOutput
->Mode
->FrameBufferBase
;
2789 CurrentGraphicsOutputMode
->FrameBufferSize
= GraphicsOutput
->Mode
->FrameBufferSize
;
2792 // Allocate resource for the private mode buffer
2794 ModeBuffer
= AllocatePool (sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
) * GraphicsOutput
->Mode
->MaxMode
);
2795 if (ModeBuffer
== NULL
) {
2796 return EFI_OUT_OF_RESOURCES
;
2798 FreePool (Private
->GraphicsOutputModeBuffer
);
2799 Private
->GraphicsOutputModeBuffer
= ModeBuffer
;
2802 // Store all supported display modes to the private mode buffer
2805 for (Index
= 0; Index
< GraphicsOutput
->Mode
->MaxMode
; Index
++) {
2807 // The Info buffer would be allocated by callee
2809 Status
= GraphicsOutput
->QueryMode (GraphicsOutput
, (UINT32
) Index
, &SizeOfInfo
, &Info
);
2810 if (EFI_ERROR (Status
)) {
2813 ASSERT ( SizeOfInfo
<= sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
));
2814 CopyMem (Mode
, Info
, SizeOfInfo
);
2820 // Check intersection of display mode
2822 ModeBuffer
= AllocatePool (sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
) * CurrentGraphicsOutputMode
->MaxMode
);
2823 if (ModeBuffer
== NULL
) {
2824 return EFI_OUT_OF_RESOURCES
;
2827 MatchedMode
= ModeBuffer
;
2828 Mode
= &Private
->GraphicsOutputModeBuffer
[0];
2829 for (Index
= 0; Index
< CurrentGraphicsOutputMode
->MaxMode
; Index
++) {
2832 for (NumberIndex
= 0; NumberIndex
< GraphicsOutput
->Mode
->MaxMode
; NumberIndex
++) {
2834 // The Info buffer would be allocated by callee
2836 Status
= GraphicsOutput
->QueryMode (GraphicsOutput
, (UINT32
) NumberIndex
, &SizeOfInfo
, &Info
);
2837 if (EFI_ERROR (Status
)) {
2840 if ((Info
->HorizontalResolution
== Mode
->HorizontalResolution
) &&
2841 (Info
->VerticalResolution
== Mode
->VerticalResolution
)) {
2843 // If GOP device supports one mode in current mode buffer,
2844 // it will be added into matched mode buffer
2854 AlreadyExist
= FALSE
;
2857 // Check if GOP mode has been in the mode buffer, ModeBuffer = MatchedMode at begin.
2859 for (Info
= ModeBuffer
; Info
< MatchedMode
; Info
++) {
2860 if ((Info
->HorizontalResolution
== Mode
->HorizontalResolution
) &&
2861 (Info
->VerticalResolution
== Mode
->VerticalResolution
)) {
2862 AlreadyExist
= TRUE
;
2867 if (!AlreadyExist
) {
2868 CopyMem (MatchedMode
, Mode
, sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
));
2871 // Physical frame buffer is no longer available, change PixelFormat to PixelBltOnly
2873 MatchedMode
->Version
= 0;
2874 MatchedMode
->PixelFormat
= PixelBltOnly
;
2875 ZeroMem (&MatchedMode
->PixelInformation
, sizeof (EFI_PIXEL_BITMASK
));
2885 // Drop the old mode buffer, assign it to a new one
2887 FreePool (Private
->GraphicsOutputModeBuffer
);
2888 Private
->GraphicsOutputModeBuffer
= ModeBuffer
;
2891 // Physical frame buffer is no longer available when there are more than one physical GOP devices
2893 CurrentGraphicsOutputMode
->MaxMode
= (UINT32
) (((UINTN
) MatchedMode
- (UINTN
) ModeBuffer
) / sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
));
2894 CurrentGraphicsOutputMode
->Info
->PixelFormat
= PixelBltOnly
;
2895 ZeroMem (&CurrentGraphicsOutputMode
->Info
->PixelInformation
, sizeof (EFI_PIXEL_BITMASK
));
2896 CurrentGraphicsOutputMode
->SizeOfInfo
= sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
);
2897 CurrentGraphicsOutputMode
->FrameBufferBase
= (EFI_PHYSICAL_ADDRESS
) (UINTN
) NULL
;
2898 CurrentGraphicsOutputMode
->FrameBufferSize
= 0;
2902 // Graphics console driver can ensure the same mode for all GOP devices
2904 for (Index
= 0; Index
< CurrentGraphicsOutputMode
->MaxMode
; Index
++) {
2905 Mode
= &Private
->GraphicsOutputModeBuffer
[Index
];
2906 if ((Mode
->HorizontalResolution
== GraphicsOutput
->Mode
->Info
->HorizontalResolution
) &&
2907 (Mode
->VerticalResolution
== GraphicsOutput
->Mode
->Info
->VerticalResolution
)) {
2908 CurrentIndex
= Index
;
2912 if (Index
>= CurrentGraphicsOutputMode
->MaxMode
) {
2914 // if user defined mode is not found, set to default mode 800x600
2916 for (Index
= 0; Index
< CurrentGraphicsOutputMode
->MaxMode
; Index
++) {
2917 Mode
= &Private
->GraphicsOutputModeBuffer
[Index
];
2918 if ((Mode
->HorizontalResolution
== 800) && (Mode
->VerticalResolution
== 600)) {
2919 CurrentIndex
= Index
;
2924 } else if (UgaDraw
!= NULL
) {
2926 // Graphics console driver can ensure the same mode for all GOP devices
2927 // so we can get the current mode from this video device
2931 &UgaHorizontalResolution
,
2932 &UgaVerticalResolution
,
2937 CurrentGraphicsOutputMode
->MaxMode
= 1;
2938 Info
= CurrentGraphicsOutputMode
->Info
;
2940 Info
->HorizontalResolution
= UgaHorizontalResolution
;
2941 Info
->VerticalResolution
= UgaVerticalResolution
;
2942 Info
->PixelFormat
= PixelBltOnly
;
2943 Info
->PixelsPerScanLine
= UgaHorizontalResolution
;
2944 CurrentGraphicsOutputMode
->SizeOfInfo
= sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
);
2945 CurrentGraphicsOutputMode
->FrameBufferBase
= (EFI_PHYSICAL_ADDRESS
) (UINTN
) NULL
;
2946 CurrentGraphicsOutputMode
->FrameBufferSize
= 0;
2949 // Update the private mode buffer
2951 CopyMem (&Private
->GraphicsOutputModeBuffer
[0], Info
, sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
));
2954 // Only mode 0 is available to be set
2961 if (GraphicsOutput
!= NULL
) {
2962 Private
->CurrentNumberOfGraphicsOutput
++;
2964 if (UgaDraw
!= NULL
) {
2965 Private
->CurrentNumberOfUgaDraw
++;
2969 // Force GraphicsOutput mode to be set,
2972 Mode
= &Private
->GraphicsOutputModeBuffer
[CurrentIndex
];
2973 if ((GraphicsOutput
!= NULL
) &&
2974 (Mode
->HorizontalResolution
== CurrentGraphicsOutputMode
->Info
->HorizontalResolution
) &&
2975 (Mode
->VerticalResolution
== CurrentGraphicsOutputMode
->Info
->VerticalResolution
)) {
2976 CurrentGraphicsOutputMode
->Mode
= (UINT32
) CurrentIndex
;
2977 if ((Mode
->HorizontalResolution
!= GraphicsOutput
->Mode
->Info
->HorizontalResolution
) ||
2978 (Mode
->VerticalResolution
!= GraphicsOutput
->Mode
->Info
->VerticalResolution
)) {
2980 // If all existing video device has been set to common mode, only set new GOP device to
2983 for (NumberIndex
= 0; NumberIndex
< GraphicsOutput
->Mode
->MaxMode
; NumberIndex
++) {
2984 Status
= GraphicsOutput
->QueryMode (GraphicsOutput
, (UINT32
) NumberIndex
, &SizeOfInfo
, &Info
);
2985 if (EFI_ERROR (Status
)) {
2988 if ((Info
->HorizontalResolution
== Mode
->HorizontalResolution
) && (Info
->VerticalResolution
== Mode
->VerticalResolution
)) {
2994 Status
= GraphicsOutput
->SetMode (GraphicsOutput
, (UINT32
) NumberIndex
);
2998 // Current mode number may need update now, so set it to an invalid mode number
3000 CurrentGraphicsOutputMode
->Mode
= 0xffff;
3002 // Graphics console can ensure all GOP devices have the same mode which can be taken as current mode.
3004 Status
= Private
->GraphicsOutput
.SetMode (&Private
->GraphicsOutput
, (UINT32
) CurrentIndex
);
3005 if (EFI_ERROR(Status
)) {
3007 // If user defined mode is not valid for display device, set to the default mode 800x600.
3009 (Private
->GraphicsOutputModeBuffer
[0]).HorizontalResolution
= 800;
3010 (Private
->GraphicsOutputModeBuffer
[0]).VerticalResolution
= 600;
3011 Status
= Private
->GraphicsOutput
.SetMode (&Private
->GraphicsOutput
, 0);
3019 Set the current console out mode.
3021 This routine will get the current console mode information (column, row)
3022 from ConsoleOutMode variable and set it; if the variable does not exist,
3023 set to user defined console mode.
3025 @param Private Consplitter Text Out pointer.
3029 ConsplitterSetConsoleOutMode (
3030 IN TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
3040 CONSOLE_OUT_MODE ModeInfo
;
3041 CONSOLE_OUT_MODE MaxModeInfo
;
3042 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
;
3046 TextOut
= &Private
->TextOut
;
3047 MaxMode
= (UINTN
) (TextOut
->Mode
->MaxMode
);
3049 MaxModeInfo
.Column
= 0;
3050 MaxModeInfo
.Row
= 0;
3051 ModeInfo
.Column
= PcdGet32 (PcdConOutColumn
);
3052 ModeInfo
.Row
= PcdGet32 (PcdConOutRow
);
3055 // To find the prefer mode and basic mode from Text Out mode list
3057 for (Mode
= 0; Mode
< MaxMode
; Mode
++) {
3058 Status
= TextOut
->QueryMode (TextOut
, Mode
, &Col
, &Row
);
3059 if (!EFI_ERROR(Status
)) {
3060 if ((ModeInfo
.Column
!= 0) && (ModeInfo
.Row
!= 0)) {
3062 // Use user defined column and row
3064 if (Col
== ModeInfo
.Column
&& Row
== ModeInfo
.Row
) {
3069 // If user sets PcdConOutColumn or PcdConOutRow to 0,
3070 // find and set the highest text mode.
3072 if ((Col
>= MaxModeInfo
.Column
) && (Row
>= MaxModeInfo
.Row
)) {
3073 MaxModeInfo
.Column
= Col
;
3074 MaxModeInfo
.Row
= Row
;
3078 if (Col
== 80 && Row
== 25) {
3085 // Set prefer mode to Text Out devices.
3087 Status
= TextOut
->SetMode (TextOut
, PreferMode
);
3088 if (EFI_ERROR(Status
)) {
3090 // if current mode setting is failed, default 80x25 mode will be set.
3092 Status
= TextOut
->SetMode (TextOut
, BaseMode
);
3093 ASSERT(!EFI_ERROR(Status
));
3095 Status
= PcdSet32S (PcdConOutColumn
, 80);
3096 ASSERT(!EFI_ERROR(Status
));
3097 Status
= PcdSet32S (PcdConOutRow
, 25);
3098 ASSERT(!EFI_ERROR(Status
));
3106 Add Text Output Device in Consplitter Text Output list.
3108 @param Private Text Out Splitter pointer.
3109 @param TextOut Simple Text Output protocol pointer.
3110 @param GraphicsOutput Graphics Output protocol pointer.
3111 @param UgaDraw UGA Draw protocol pointer.
3113 @retval EFI_SUCCESS Text Output Device added successfully.
3114 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
3118 ConSplitterTextOutAddDevice (
3119 IN TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
,
3120 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
,
3121 IN EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
,
3122 IN EFI_UGA_DRAW_PROTOCOL
*UgaDraw
3126 UINTN CurrentNumOfConsoles
;
3128 UINT32 UgaHorizontalResolution
;
3129 UINT32 UgaVerticalResolution
;
3130 UINT32 UgaColorDepth
;
3131 UINT32 UgaRefreshRate
;
3132 TEXT_OUT_AND_GOP_DATA
*TextAndGop
;
3134 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*Info
;
3135 EFI_STATUS DeviceStatus
;
3137 Status
= EFI_SUCCESS
;
3138 CurrentNumOfConsoles
= Private
->CurrentNumberOfConsoles
;
3139 Private
->AddingConOutDevice
= TRUE
;
3142 // If the Text Out List is full, enlarge it by calling ConSplitterGrowBuffer().
3144 while (CurrentNumOfConsoles
>= Private
->TextOutListCount
) {
3145 Status
= ConSplitterGrowBuffer (
3146 sizeof (TEXT_OUT_AND_GOP_DATA
),
3147 &Private
->TextOutListCount
,
3148 (VOID
**) &Private
->TextOutList
3150 if (EFI_ERROR (Status
)) {
3151 return EFI_OUT_OF_RESOURCES
;
3154 // Also need to reallocate the TextOutModeMap table
3156 Status
= ConSplitterGrowMapTable (Private
);
3157 if (EFI_ERROR (Status
)) {
3158 return EFI_OUT_OF_RESOURCES
;
3162 TextAndGop
= &Private
->TextOutList
[CurrentNumOfConsoles
];
3164 TextAndGop
->TextOut
= TextOut
;
3165 TextAndGop
->GraphicsOutput
= GraphicsOutput
;
3166 TextAndGop
->UgaDraw
= UgaDraw
;
3168 if (CurrentNumOfConsoles
== 0) {
3170 // Add the first device's output mode to console splitter's mode list
3172 Status
= ConSplitterAddOutputMode (Private
, TextOut
);
3174 ConSplitterSyncOutputMode (Private
, TextOut
);
3177 Private
->CurrentNumberOfConsoles
++;
3180 // Scan both TextOutList, for the intersection TextOut device
3181 // maybe both ConOut and StdErr incorporate the same Text Out
3182 // device in them, thus the output of both should be synced.
3184 ConSplitterGetIntersectionBetweenConOutAndStrErr ();
3186 MaxMode
= Private
->TextOutMode
.MaxMode
;
3187 ASSERT (MaxMode
>= 1);
3189 DeviceStatus
= EFI_DEVICE_ERROR
;
3190 Status
= EFI_DEVICE_ERROR
;
3193 // This device display mode will be added into Graphics Ouput modes.
3195 if ((GraphicsOutput
!= NULL
) || (UgaDraw
!= NULL
)) {
3196 DeviceStatus
= ConSplitterAddGraphicsOutputMode (Private
, GraphicsOutput
, UgaDraw
);
3199 if (FeaturePcdGet (PcdConOutUgaSupport
)) {
3201 // If UGA is produced by Consplitter
3203 if (GraphicsOutput
!= NULL
) {
3204 Status
= GraphicsOutput
->QueryMode (GraphicsOutput
, GraphicsOutput
->Mode
->Mode
, &SizeOfInfo
, &Info
);
3205 if (EFI_ERROR (Status
)) {
3208 ASSERT ( SizeOfInfo
<= sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
));
3210 UgaHorizontalResolution
= Info
->HorizontalResolution
;
3211 UgaVerticalResolution
= Info
->VerticalResolution
;
3215 } else if (UgaDraw
!= NULL
) {
3216 Status
= UgaDraw
->GetMode (
3218 &UgaHorizontalResolution
,
3219 &UgaVerticalResolution
,
3223 if (!EFI_ERROR (Status
) && EFI_ERROR (DeviceStatus
)) {
3225 // if GetMode is successfully and UGA device hasn't been set, set it
3227 Status
= ConSplitterUgaDrawSetMode (
3229 UgaHorizontalResolution
,
3230 UgaVerticalResolution
,
3236 // If GetMode/SetMode is failed, set to 800x600 mode
3238 if(EFI_ERROR (Status
)) {
3239 Status
= ConSplitterUgaDrawSetMode (
3250 if (((!EFI_ERROR (DeviceStatus
)) || (!EFI_ERROR (Status
))) &&
3251 ((Private
->CurrentNumberOfGraphicsOutput
+ Private
->CurrentNumberOfUgaDraw
) == 1)) {
3252 if (!FeaturePcdGet (PcdConOutGopSupport
)) {
3254 // If Graphics Outpurt protocol not supported, UGA Draw protocol is installed
3255 // on the virtual handle.
3257 Status
= gBS
->InstallMultipleProtocolInterfaces (
3258 &mConOut
.VirtualHandle
,
3259 &gEfiUgaDrawProtocolGuid
,
3263 } else if (!FeaturePcdGet (PcdConOutUgaSupport
)) {
3265 // If UGA Draw protocol not supported, Graphics Output Protocol is installed
3266 // on virtual handle.
3268 Status
= gBS
->InstallMultipleProtocolInterfaces (
3269 &mConOut
.VirtualHandle
,
3270 &gEfiGraphicsOutputProtocolGuid
,
3271 &mConOut
.GraphicsOutput
,
3276 // Boot Graphics Output protocol and UGA Draw protocol are supported,
3277 // both they will be installed on virtual handle.
3279 Status
= gBS
->InstallMultipleProtocolInterfaces (
3280 &mConOut
.VirtualHandle
,
3281 &gEfiGraphicsOutputProtocolGuid
,
3282 &mConOut
.GraphicsOutput
,
3283 &gEfiUgaDrawProtocolGuid
,
3291 // After adding new console device, all existing console devices should be
3292 // synced to the current shared mode.
3294 ConsplitterSetConsoleOutMode (Private
);
3296 Private
->AddingConOutDevice
= FALSE
;
3303 Remove Text Out Device in Consplitter Text Out list.
3305 @param Private Text Out Splitter pointer.
3306 @param TextOut Simple Text Output Pointer protocol pointer.
3308 @retval EFI_SUCCESS Text Out Device removed successfully.
3309 @retval EFI_NOT_FOUND No Text Out Device found.
3313 ConSplitterTextOutDeleteDevice (
3314 IN TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
,
3315 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
3319 UINTN CurrentNumOfConsoles
;
3320 TEXT_OUT_AND_GOP_DATA
*TextOutList
;
3324 // Remove the specified text-out device data structure from the Text out List,
3325 // and rearrange the remaining data structures in the Text out List.
3327 CurrentNumOfConsoles
= Private
->CurrentNumberOfConsoles
;
3328 Index
= (INT32
) CurrentNumOfConsoles
- 1;
3329 TextOutList
= Private
->TextOutList
;
3330 while (Index
>= 0) {
3331 if (TextOutList
->TextOut
== TextOut
) {
3332 if (TextOutList
->UgaDraw
!= NULL
) {
3333 Private
->CurrentNumberOfUgaDraw
--;
3335 if (TextOutList
->GraphicsOutput
!= NULL
) {
3336 Private
->CurrentNumberOfGraphicsOutput
--;
3338 CopyMem (TextOutList
, TextOutList
+ 1, sizeof (TEXT_OUT_AND_GOP_DATA
) * Index
);
3339 CurrentNumOfConsoles
--;
3347 // The specified TextOut is not managed by the ConSplitter driver
3350 return EFI_NOT_FOUND
;
3353 if ((Private
->CurrentNumberOfGraphicsOutput
== 0) && (Private
->CurrentNumberOfUgaDraw
== 0)) {
3355 // If there is not any physical GOP and UGA device in system,
3356 // Consplitter GOP or UGA protocol will be uninstalled
3358 if (!FeaturePcdGet (PcdConOutGopSupport
)) {
3359 Status
= gBS
->UninstallProtocolInterface (
3360 Private
->VirtualHandle
,
3361 &gEfiUgaDrawProtocolGuid
,
3364 } else if (!FeaturePcdGet (PcdConOutUgaSupport
)) {
3365 Status
= gBS
->UninstallProtocolInterface (
3366 Private
->VirtualHandle
,
3367 &gEfiGraphicsOutputProtocolGuid
,
3368 &Private
->GraphicsOutput
3371 Status
= gBS
->UninstallMultipleProtocolInterfaces (
3372 Private
->VirtualHandle
,
3373 &gEfiUgaDrawProtocolGuid
,
3375 &gEfiGraphicsOutputProtocolGuid
,
3376 &Private
->GraphicsOutput
,
3382 if (CurrentNumOfConsoles
== 0) {
3384 // If the number of consoles is zero, reset all parameters
3386 Private
->CurrentNumberOfConsoles
= 0;
3387 Private
->TextOutMode
.MaxMode
= 1;
3388 Private
->TextOutQueryData
[0].Columns
= 80;
3389 Private
->TextOutQueryData
[0].Rows
= 25;
3390 TextOutSetMode (Private
, 0);
3395 // Max Mode is realy an intersection of the QueryMode command to all
3396 // devices. So we must copy the QueryMode of the first device to
3400 Private
->TextOutQueryData
,
3401 Private
->TextOutQueryDataCount
* sizeof (TEXT_OUT_SPLITTER_QUERY_DATA
)
3404 FreePool (Private
->TextOutModeMap
);
3405 Private
->TextOutModeMap
= NULL
;
3406 TextOutList
= Private
->TextOutList
;
3409 // Add the first TextOut to the QueryData array and ModeMap table
3411 Status
= ConSplitterAddOutputMode (Private
, TextOutList
->TextOut
);
3414 // Now add one by one
3417 Private
->CurrentNumberOfConsoles
= 1;
3419 while ((UINTN
) Index
< CurrentNumOfConsoles
) {
3420 ConSplitterSyncOutputMode (Private
, TextOutList
->TextOut
);
3422 Private
->CurrentNumberOfConsoles
++;
3426 ConSplitterGetIntersectionBetweenConOutAndStrErr ();
3433 Reset the input device and optionaly run diagnostics
3435 @param This Protocol instance pointer.
3436 @param ExtendedVerification Driver may perform diagnostics on reset.
3438 @retval EFI_SUCCESS The device was reset.
3439 @retval EFI_DEVICE_ERROR The device is not functioning properly and could
3445 ConSplitterTextInReset (
3446 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*This
,
3447 IN BOOLEAN ExtendedVerification
3451 EFI_STATUS ReturnStatus
;
3452 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3455 Private
= TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
3457 Private
->KeyEventSignalState
= FALSE
;
3460 // return the worst status met
3462 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
3463 Status
= Private
->TextInList
[Index
]->Reset (
3464 Private
->TextInList
[Index
],
3465 ExtendedVerification
3467 if (EFI_ERROR (Status
)) {
3468 ReturnStatus
= Status
;
3472 if (!EFI_ERROR (ReturnStatus
)) {
3473 ToggleStateSyncReInitialization (Private
);
3475 // Empty the key queue.
3477 Private
->CurrentNumberOfKeys
= 0;
3480 return ReturnStatus
;
3484 Dequeue the saved key from internal key queue.
3486 @param Private Protocol instance pointer.
3487 @param KeyData A pointer to a buffer that is filled in with the
3488 keystroke state data for the key that was
3490 @retval EFI_NOT_FOUND Queue is empty.
3491 @retval EFI_SUCCESS First key is dequeued and returned.
3494 ConSplitterTextInExDequeueKey (
3495 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
3496 OUT EFI_KEY_DATA
*KeyData
3499 if (Private
->CurrentNumberOfKeys
== 0) {
3500 return EFI_NOT_FOUND
;
3503 // Return the first saved key.
3505 CopyMem (KeyData
, &Private
->KeyQueue
[0], sizeof (EFI_KEY_DATA
));
3506 Private
->CurrentNumberOfKeys
--;
3508 &Private
->KeyQueue
[0],
3509 &Private
->KeyQueue
[1],
3510 Private
->CurrentNumberOfKeys
* sizeof (EFI_KEY_DATA
)
3516 Reads the next keystroke from the input device. The WaitForKey Event can
3517 be used to test for existance of a keystroke via WaitForEvent () call.
3519 @param Private Protocol instance pointer.
3520 @param Key Driver may perform diagnostics on reset.
3522 @retval EFI_SUCCESS The keystroke information was returned.
3523 @retval EFI_NOT_READY There was no keystroke data availiable.
3524 @retval EFI_DEVICE_ERROR The keydtroke information was not returned due
3530 ConSplitterTextInPrivateReadKeyStroke (
3531 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
3532 OUT EFI_INPUT_KEY
*Key
3537 EFI_KEY_DATA KeyData
;
3540 // Return the first saved non-NULL key.
3543 Status
= ConSplitterTextInExDequeueKey (Private
, &KeyData
);
3544 if (EFI_ERROR (Status
)) {
3547 if ((KeyData
.Key
.ScanCode
!= CHAR_NULL
) || (KeyData
.Key
.UnicodeChar
!= SCAN_NULL
)) {
3548 CopyMem (Key
, &KeyData
.Key
, sizeof (EFI_INPUT_KEY
));
3553 Key
->UnicodeChar
= 0;
3554 Key
->ScanCode
= SCAN_NULL
;
3557 // if no physical console input device exists, return EFI_NOT_READY;
3558 // if any physical console input device has key input,
3559 // return the key and EFI_SUCCESS.
3561 for (Index
= 0; Index
< Private
->CurrentNumberOfConsoles
;) {
3562 Status
= Private
->TextInList
[Index
]->ReadKeyStroke (
3563 Private
->TextInList
[Index
],
3566 if (!EFI_ERROR (Status
)) {
3568 // If it is not partial keystorke, return the key. Otherwise, continue
3569 // to read key from THIS physical console input device.
3571 if ((KeyData
.Key
.ScanCode
!= CHAR_NULL
) || (KeyData
.Key
.UnicodeChar
!= SCAN_NULL
)) {
3572 CopyMem (Key
, &KeyData
.Key
, sizeof (EFI_INPUT_KEY
));
3577 // Continue to read key from NEXT physical console input device.
3583 return EFI_NOT_READY
;
3589 Reads the next keystroke from the input device. The WaitForKey Event can
3590 be used to test for existance of a keystroke via WaitForEvent () call.
3592 @param This Protocol instance pointer.
3593 @param Key Driver may perform diagnostics on reset.
3595 @retval EFI_SUCCESS The keystroke information was returned.
3596 @retval EFI_NOT_READY There was no keystroke data availiable.
3597 @retval EFI_DEVICE_ERROR The keydtroke information was not returned due
3603 ConSplitterTextInReadKeyStroke (
3604 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*This
,
3605 OUT EFI_INPUT_KEY
*Key
3608 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3610 Private
= TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
3612 Private
->KeyEventSignalState
= FALSE
;
3615 // Signal ConnectConIn event on first call in Lazy ConIn mode
3617 if (!mConInIsConnect
&& PcdGetBool (PcdConInConnectOnDemand
)) {
3618 DEBUG ((EFI_D_INFO
, "Connect ConIn in first ReadKeyStoke in Lazy ConIn mode.\n"));
3619 gBS
->SignalEvent (Private
->ConnectConInEvent
);
3620 mConInIsConnect
= TRUE
;
3623 return ConSplitterTextInPrivateReadKeyStroke (Private
, Key
);
3628 This event aggregates all the events of the ConIn devices in the spliter.
3630 If any events of physical ConIn devices are signaled, signal the ConIn
3631 spliter event. This will cause the calling code to call
3632 ConSplitterTextInReadKeyStroke ().
3634 @param Event The Event assoicated with callback.
3635 @param Context Context registered when Event was created.
3640 ConSplitterTextInWaitForKey (
3646 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3649 Private
= (TEXT_IN_SPLITTER_PRIVATE_DATA
*) Context
;
3651 if (Private
->KeyEventSignalState
) {
3653 // If KeyEventSignalState is flagged before, and not cleared by Reset() or ReadKeyStroke()
3655 gBS
->SignalEvent (Event
);
3660 // If any physical console input device has key input, signal the event.
3662 for (Index
= 0; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
3663 Status
= gBS
->CheckEvent (Private
->TextInList
[Index
]->WaitForKey
);
3664 if (!EFI_ERROR (Status
)) {
3665 gBS
->SignalEvent (Event
);
3666 Private
->KeyEventSignalState
= TRUE
;
3674 Test if the key has been registered on input device.
3676 @param RegsiteredData A pointer to a buffer that is filled in with the
3677 keystroke state data for the key that was
3679 @param InputData A pointer to a buffer that is filled in with the
3680 keystroke state data for the key that was
3683 @retval TRUE Key be pressed matches a registered key.
3684 @retval FLASE Match failed.
3689 IN EFI_KEY_DATA
*RegsiteredData
,
3690 IN EFI_KEY_DATA
*InputData
3693 ASSERT (RegsiteredData
!= NULL
&& InputData
!= NULL
);
3695 if ((RegsiteredData
->Key
.ScanCode
!= InputData
->Key
.ScanCode
) ||
3696 (RegsiteredData
->Key
.UnicodeChar
!= InputData
->Key
.UnicodeChar
)) {
3701 // Assume KeyShiftState/KeyToggleState = 0 in Registered key data means these state could be ignored.
3703 if (RegsiteredData
->KeyState
.KeyShiftState
!= 0 &&
3704 RegsiteredData
->KeyState
.KeyShiftState
!= InputData
->KeyState
.KeyShiftState
) {
3707 if (RegsiteredData
->KeyState
.KeyToggleState
!= 0 &&
3708 RegsiteredData
->KeyState
.KeyToggleState
!= InputData
->KeyState
.KeyToggleState
) {
3718 Reset the input device and optionaly run diagnostics
3720 @param This Protocol instance pointer.
3721 @param ExtendedVerification Driver may perform diagnostics on reset.
3723 @retval EFI_SUCCESS The device was reset.
3724 @retval EFI_DEVICE_ERROR The device is not functioning properly and could
3730 ConSplitterTextInResetEx (
3731 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*This
,
3732 IN BOOLEAN ExtendedVerification
3736 EFI_STATUS ReturnStatus
;
3737 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3740 Private
= TEXT_IN_EX_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
3742 Private
->KeyEventSignalState
= FALSE
;
3745 // return the worst status met
3747 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfExConsoles
; Index
++) {
3748 Status
= Private
->TextInExList
[Index
]->Reset (
3749 Private
->TextInExList
[Index
],
3750 ExtendedVerification
3752 if (EFI_ERROR (Status
)) {
3753 ReturnStatus
= Status
;
3757 if (!EFI_ERROR (ReturnStatus
)) {
3758 ToggleStateSyncReInitialization (Private
);
3760 // Empty the key queue.
3762 Private
->CurrentNumberOfKeys
= 0;
3765 return ReturnStatus
;
3771 Reads the next keystroke from the input device. The WaitForKey Event can
3772 be used to test for existance of a keystroke via WaitForEvent () call.
3774 @param This Protocol instance pointer.
3775 @param KeyData A pointer to a buffer that is filled in with the
3776 keystroke state data for the key that was
3779 @retval EFI_SUCCESS The keystroke information was returned.
3780 @retval EFI_NOT_READY There was no keystroke data availiable.
3781 @retval EFI_DEVICE_ERROR The keystroke information was not returned due
3783 @retval EFI_INVALID_PARAMETER KeyData is NULL.
3788 ConSplitterTextInReadKeyStrokeEx (
3789 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*This
,
3790 OUT EFI_KEY_DATA
*KeyData
3793 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3796 EFI_KEY_STATE KeyState
;
3797 EFI_KEY_DATA CurrentKeyData
;
3800 if (KeyData
== NULL
) {
3801 return EFI_INVALID_PARAMETER
;
3804 Private
= TEXT_IN_EX_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
3806 Private
->KeyEventSignalState
= FALSE
;
3809 // Signal ConnectConIn event on first call in Lazy ConIn mode
3811 if (!mConInIsConnect
&& PcdGetBool (PcdConInConnectOnDemand
)) {
3812 DEBUG ((EFI_D_INFO
, "Connect ConIn in first ReadKeyStoke in Lazy ConIn mode.\n"));
3813 gBS
->SignalEvent (Private
->ConnectConInEvent
);
3814 mConInIsConnect
= TRUE
;
3818 // Return the first saved key.
3820 Status
= ConSplitterTextInExDequeueKey (Private
, KeyData
);
3821 if (!EFI_ERROR (Status
)) {
3824 ASSERT (Private
->CurrentNumberOfKeys
== 0);
3826 ZeroMem (&KeyState
, sizeof (KeyState
));
3829 // Iterate through all physical consoles to get key state.
3830 // Some physical consoles may return valid key.
3831 // Queue the valid keys.
3833 for (Index
= 0; Index
< Private
->CurrentNumberOfExConsoles
; Index
++) {
3834 ZeroMem (&CurrentKeyData
, sizeof (EFI_KEY_DATA
));
3835 Status
= Private
->TextInExList
[Index
]->ReadKeyStrokeEx (
3836 Private
->TextInExList
[Index
],
3839 if (EFI_ERROR (Status
) && (Status
!= EFI_NOT_READY
)) {
3844 // Consolidate the key state from all physical consoles.
3846 if ((CurrentKeyData
.KeyState
.KeyShiftState
& EFI_SHIFT_STATE_VALID
) != 0) {
3847 KeyState
.KeyShiftState
|= CurrentKeyData
.KeyState
.KeyShiftState
;
3849 if ((CurrentKeyData
.KeyState
.KeyToggleState
& EFI_TOGGLE_STATE_VALID
) != 0) {
3850 KeyState
.KeyToggleState
|= CurrentKeyData
.KeyState
.KeyToggleState
;
3853 if (!EFI_ERROR (Status
)) {
3855 // If virtual KeyState has been required to be exposed, or it is not
3856 // partial keystorke, queue the key.
3857 // It's possible that user presses at multiple keyboards at the same moment,
3858 // Private->KeyQueue[] are the storage to save all the keys.
3860 if ((Private
->VirtualKeyStateExported
) ||
3861 (CurrentKeyData
.Key
.ScanCode
!= CHAR_NULL
) ||
3862 (CurrentKeyData
.Key
.UnicodeChar
!= SCAN_NULL
)) {
3864 &Private
->KeyQueue
[Private
->CurrentNumberOfKeys
],
3866 sizeof (EFI_KEY_DATA
)
3868 Private
->CurrentNumberOfKeys
++;
3874 // Consolidate the key state for all keys in Private->KeyQueue[]
3876 for (Index
= 0; Index
< Private
->CurrentNumberOfKeys
; Index
++) {
3877 CopyMem (&Private
->KeyQueue
[Index
].KeyState
, &KeyState
, sizeof (EFI_KEY_STATE
));
3881 // Return the first saved key.
3883 Status
= ConSplitterTextInExDequeueKey (Private
, KeyData
);
3884 if (!EFI_ERROR (Status
)) {
3889 // Always return the key state even there is no key pressed.
3891 ZeroMem (&KeyData
->Key
, sizeof (KeyData
->Key
));
3892 CopyMem (&KeyData
->KeyState
, &KeyState
, sizeof (KeyData
->KeyState
));
3893 return EFI_NOT_READY
;
3898 Set certain state for the input device.
3900 @param This Protocol instance pointer.
3901 @param KeyToggleState A pointer to the EFI_KEY_TOGGLE_STATE to set the
3902 state for the input device.
3904 @retval EFI_SUCCESS The device state was set successfully.
3905 @retval EFI_DEVICE_ERROR The device is not functioning correctly and
3906 could not have the setting adjusted.
3907 @retval EFI_UNSUPPORTED The device does not have the ability to set its
3909 @retval EFI_INVALID_PARAMETER KeyToggleState is NULL.
3914 ConSplitterTextInSetState (
3915 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*This
,
3916 IN EFI_KEY_TOGGLE_STATE
*KeyToggleState
3919 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3922 EFI_KEY_TOGGLE_STATE PhysicalKeyToggleState
;
3924 if (KeyToggleState
== NULL
) {
3925 return EFI_INVALID_PARAMETER
;
3928 Private
= TEXT_IN_EX_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
3931 // Always turn on physical TextInEx partial key report for
3932 // toggle state sync.
3934 PhysicalKeyToggleState
= *KeyToggleState
| EFI_KEY_STATE_EXPOSED
;
3937 // if no physical console input device exists, return EFI_SUCCESS;
3938 // otherwise return the status of setting state of physical console input device
3940 for (Index
= 0; Index
< Private
->CurrentNumberOfExConsoles
; Index
++) {
3941 Status
= Private
->TextInExList
[Index
]->SetState (
3942 Private
->TextInExList
[Index
],
3943 &PhysicalKeyToggleState
3945 if (EFI_ERROR (Status
)) {
3951 // Record the physical KeyToggleState.
3953 Private
->PhysicalKeyToggleState
= PhysicalKeyToggleState
;
3955 // Get if virtual KeyState has been required to be exposed.
3957 Private
->VirtualKeyStateExported
= (((*KeyToggleState
) & EFI_KEY_STATE_EXPOSED
) != 0);
3965 Register a notification function for a particular keystroke for the input device.
3967 @param This Protocol instance pointer.
3968 @param KeyData A pointer to a buffer that is filled in with
3969 the keystroke information for the key that was
3970 pressed. If KeyData.Key, KeyData.KeyState.KeyToggleState
3971 and KeyData.KeyState.KeyShiftState are 0, then any incomplete
3972 keystroke will trigger a notification of the KeyNotificationFunction.
3973 @param KeyNotificationFunction Points to the function to be called when the key
3974 sequence is typed specified by KeyData. This notification function
3975 should be called at <=TPL_CALLBACK.
3976 @param NotifyHandle Points to the unique handle assigned to the
3977 registered notification.
3979 @retval EFI_SUCCESS The notification function was registered
3981 @retval EFI_OUT_OF_RESOURCES Unable to allocate resources for necesssary data
3983 @retval EFI_INVALID_PARAMETER KeyData or KeyNotificationFunction or NotifyHandle is NULL.
3988 ConSplitterTextInRegisterKeyNotify (
3989 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*This
,
3990 IN EFI_KEY_DATA
*KeyData
,
3991 IN EFI_KEY_NOTIFY_FUNCTION KeyNotificationFunction
,
3992 OUT VOID
**NotifyHandle
3995 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3998 TEXT_IN_EX_SPLITTER_NOTIFY
*NewNotify
;
4000 TEXT_IN_EX_SPLITTER_NOTIFY
*CurrentNotify
;
4003 if (KeyData
== NULL
|| NotifyHandle
== NULL
|| KeyNotificationFunction
== NULL
) {
4004 return EFI_INVALID_PARAMETER
;
4007 Private
= TEXT_IN_EX_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4010 // Return EFI_SUCCESS if the (KeyData, NotificationFunction) is already registered.
4012 for (Link
= Private
->NotifyList
.ForwardLink
; Link
!= &Private
->NotifyList
; Link
= Link
->ForwardLink
) {
4013 CurrentNotify
= TEXT_IN_EX_SPLITTER_NOTIFY_FROM_THIS (Link
);
4014 if (IsKeyRegistered (&CurrentNotify
->KeyData
, KeyData
)) {
4015 if (CurrentNotify
->KeyNotificationFn
== KeyNotificationFunction
) {
4016 *NotifyHandle
= CurrentNotify
;
4023 // Allocate resource to save the notification function
4025 NewNotify
= (TEXT_IN_EX_SPLITTER_NOTIFY
*) AllocateZeroPool (sizeof (TEXT_IN_EX_SPLITTER_NOTIFY
));
4026 if (NewNotify
== NULL
) {
4027 return EFI_OUT_OF_RESOURCES
;
4029 NewNotify
->NotifyHandleList
= (VOID
**) AllocateZeroPool (sizeof (VOID
*) * Private
->TextInExListCount
);
4030 if (NewNotify
->NotifyHandleList
== NULL
) {
4031 gBS
->FreePool (NewNotify
);
4032 return EFI_OUT_OF_RESOURCES
;
4034 NewNotify
->Signature
= TEXT_IN_EX_SPLITTER_NOTIFY_SIGNATURE
;
4035 NewNotify
->KeyNotificationFn
= KeyNotificationFunction
;
4036 CopyMem (&NewNotify
->KeyData
, KeyData
, sizeof (EFI_KEY_DATA
));
4039 // Return the wrong status of registering key notify of
4040 // physical console input device if meet problems
4042 for (Index
= 0; Index
< Private
->CurrentNumberOfExConsoles
; Index
++) {
4043 Status
= Private
->TextInExList
[Index
]->RegisterKeyNotify (
4044 Private
->TextInExList
[Index
],
4046 KeyNotificationFunction
,
4047 &NewNotify
->NotifyHandleList
[Index
]
4049 if (EFI_ERROR (Status
)) {
4051 // Un-register the key notify on all physical console input devices
4053 while (Index
-- != 0) {
4054 Private
->TextInExList
[Index
]->UnregisterKeyNotify (
4055 Private
->TextInExList
[Index
],
4056 NewNotify
->NotifyHandleList
[Index
]
4059 gBS
->FreePool (NewNotify
->NotifyHandleList
);
4060 gBS
->FreePool (NewNotify
);
4065 InsertTailList (&Private
->NotifyList
, &NewNotify
->NotifyEntry
);
4067 *NotifyHandle
= NewNotify
;
4075 Remove a registered notification function from a particular keystroke.
4077 @param This Protocol instance pointer.
4078 @param NotificationHandle The handle of the notification function being
4081 @retval EFI_SUCCESS The notification function was unregistered
4083 @retval EFI_INVALID_PARAMETER The NotificationHandle is invalid.
4088 ConSplitterTextInUnregisterKeyNotify (
4089 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*This
,
4090 IN VOID
*NotificationHandle
4093 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
4095 TEXT_IN_EX_SPLITTER_NOTIFY
*CurrentNotify
;
4098 if (NotificationHandle
== NULL
) {
4099 return EFI_INVALID_PARAMETER
;
4102 Private
= TEXT_IN_EX_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4104 for (Link
= Private
->NotifyList
.ForwardLink
; Link
!= &Private
->NotifyList
; Link
= Link
->ForwardLink
) {
4105 CurrentNotify
= TEXT_IN_EX_SPLITTER_NOTIFY_FROM_THIS (Link
);
4106 if (CurrentNotify
== NotificationHandle
) {
4107 for (Index
= 0; Index
< Private
->CurrentNumberOfExConsoles
; Index
++) {
4108 Private
->TextInExList
[Index
]->UnregisterKeyNotify (
4109 Private
->TextInExList
[Index
],
4110 CurrentNotify
->NotifyHandleList
[Index
]
4113 RemoveEntryList (&CurrentNotify
->NotifyEntry
);
4115 gBS
->FreePool (CurrentNotify
->NotifyHandleList
);
4116 gBS
->FreePool (CurrentNotify
);
4122 // NotificationHandle is not found in database
4124 return EFI_INVALID_PARAMETER
;
4129 Reset the input device and optionaly run diagnostics
4131 @param This Protocol instance pointer.
4132 @param ExtendedVerification Driver may perform diagnostics on reset.
4134 @retval EFI_SUCCESS The device was reset.
4135 @retval EFI_DEVICE_ERROR The device is not functioning properly and could
4141 ConSplitterSimplePointerReset (
4142 IN EFI_SIMPLE_POINTER_PROTOCOL
*This
,
4143 IN BOOLEAN ExtendedVerification
4147 EFI_STATUS ReturnStatus
;
4148 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
4151 Private
= TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_SIMPLE_POINTER_THIS (This
);
4153 Private
->InputEventSignalState
= FALSE
;
4155 if (Private
->CurrentNumberOfPointers
== 0) {
4159 // return the worst status met
4161 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfPointers
; Index
++) {
4162 Status
= Private
->PointerList
[Index
]->Reset (
4163 Private
->PointerList
[Index
],
4164 ExtendedVerification
4166 if (EFI_ERROR (Status
)) {
4167 ReturnStatus
= Status
;
4171 return ReturnStatus
;
4176 Reads the next keystroke from the input device. The WaitForKey Event can
4177 be used to test for existance of a keystroke via WaitForEvent () call.
4179 @param Private Protocol instance pointer.
4180 @param State The state information of simple pointer device.
4182 @retval EFI_SUCCESS The keystroke information was returned.
4183 @retval EFI_NOT_READY There was no keystroke data availiable.
4184 @retval EFI_DEVICE_ERROR The keydtroke information was not returned due
4190 ConSplitterSimplePointerPrivateGetState (
4191 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
4192 IN OUT EFI_SIMPLE_POINTER_STATE
*State
4196 EFI_STATUS ReturnStatus
;
4198 EFI_SIMPLE_POINTER_STATE CurrentState
;
4200 State
->RelativeMovementX
= 0;
4201 State
->RelativeMovementY
= 0;
4202 State
->RelativeMovementZ
= 0;
4203 State
->LeftButton
= FALSE
;
4204 State
->RightButton
= FALSE
;
4207 // if no physical console input device exists, return EFI_NOT_READY;
4208 // if any physical console input device has key input,
4209 // return the key and EFI_SUCCESS.
4211 ReturnStatus
= EFI_NOT_READY
;
4212 for (Index
= 0; Index
< Private
->CurrentNumberOfPointers
; Index
++) {
4214 Status
= Private
->PointerList
[Index
]->GetState (
4215 Private
->PointerList
[Index
],
4218 if (!EFI_ERROR (Status
)) {
4219 if (ReturnStatus
== EFI_NOT_READY
) {
4220 ReturnStatus
= EFI_SUCCESS
;
4223 if (CurrentState
.LeftButton
) {
4224 State
->LeftButton
= TRUE
;
4227 if (CurrentState
.RightButton
) {
4228 State
->RightButton
= TRUE
;
4231 if (CurrentState
.RelativeMovementX
!= 0 && Private
->PointerList
[Index
]->Mode
->ResolutionX
!= 0) {
4232 State
->RelativeMovementX
+= (CurrentState
.RelativeMovementX
* (INT32
) Private
->SimplePointerMode
.ResolutionX
) / (INT32
) Private
->PointerList
[Index
]->Mode
->ResolutionX
;
4235 if (CurrentState
.RelativeMovementY
!= 0 && Private
->PointerList
[Index
]->Mode
->ResolutionY
!= 0) {
4236 State
->RelativeMovementY
+= (CurrentState
.RelativeMovementY
* (INT32
) Private
->SimplePointerMode
.ResolutionY
) / (INT32
) Private
->PointerList
[Index
]->Mode
->ResolutionY
;
4239 if (CurrentState
.RelativeMovementZ
!= 0 && Private
->PointerList
[Index
]->Mode
->ResolutionZ
!= 0) {
4240 State
->RelativeMovementZ
+= (CurrentState
.RelativeMovementZ
* (INT32
) Private
->SimplePointerMode
.ResolutionZ
) / (INT32
) Private
->PointerList
[Index
]->Mode
->ResolutionZ
;
4242 } else if (Status
== EFI_DEVICE_ERROR
) {
4243 ReturnStatus
= EFI_DEVICE_ERROR
;
4247 return ReturnStatus
;
4252 Reads the next keystroke from the input device. The WaitForKey Event can
4253 be used to test for existance of a keystroke via WaitForEvent () call.
4255 @param This A pointer to protocol instance.
4256 @param State A pointer to state information on the pointer device
4258 @retval EFI_SUCCESS The keystroke information was returned in State.
4259 @retval EFI_NOT_READY There was no keystroke data availiable.
4260 @retval EFI_DEVICE_ERROR The keydtroke information was not returned due
4266 ConSplitterSimplePointerGetState (
4267 IN EFI_SIMPLE_POINTER_PROTOCOL
*This
,
4268 IN OUT EFI_SIMPLE_POINTER_STATE
*State
4271 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
4273 Private
= TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_SIMPLE_POINTER_THIS (This
);
4275 Private
->InputEventSignalState
= FALSE
;
4277 return ConSplitterSimplePointerPrivateGetState (Private
, State
);
4282 This event agregates all the events of the ConIn devices in the spliter.
4283 If any events of physical ConIn devices are signaled, signal the ConIn
4284 spliter event. This will cause the calling code to call
4285 ConSplitterTextInReadKeyStroke ().
4287 @param Event The Event assoicated with callback.
4288 @param Context Context registered when Event was created.
4293 ConSplitterSimplePointerWaitForInput (
4299 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
4302 Private
= (TEXT_IN_SPLITTER_PRIVATE_DATA
*) Context
;
4305 // if InputEventSignalState is flagged before, and not cleared by Reset() or ReadKeyStroke()
4307 if (Private
->InputEventSignalState
) {
4308 gBS
->SignalEvent (Event
);
4312 // if any physical console input device has key input, signal the event.
4314 for (Index
= 0; Index
< Private
->CurrentNumberOfPointers
; Index
++) {
4315 Status
= gBS
->CheckEvent (Private
->PointerList
[Index
]->WaitForInput
);
4316 if (!EFI_ERROR (Status
)) {
4317 gBS
->SignalEvent (Event
);
4318 Private
->InputEventSignalState
= TRUE
;
4324 Resets the pointer device hardware.
4326 @param This Protocol instance pointer.
4327 @param ExtendedVerification Driver may perform diagnostics on reset.
4329 @retval EFI_SUCCESS The device was reset.
4330 @retval EFI_DEVICE_ERROR The device is not functioning correctly and
4336 ConSplitterAbsolutePointerReset (
4337 IN EFI_ABSOLUTE_POINTER_PROTOCOL
*This
,
4338 IN BOOLEAN ExtendedVerification
4342 EFI_STATUS ReturnStatus
;
4343 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
4346 Private
= TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_ABSOLUTE_POINTER_THIS (This
);
4348 Private
->AbsoluteInputEventSignalState
= FALSE
;
4350 if (Private
->CurrentNumberOfAbsolutePointers
== 0) {
4354 // return the worst status met
4356 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfAbsolutePointers
; Index
++) {
4357 Status
= Private
->AbsolutePointerList
[Index
]->Reset (
4358 Private
->AbsolutePointerList
[Index
],
4359 ExtendedVerification
4361 if (EFI_ERROR (Status
)) {
4362 ReturnStatus
= Status
;
4366 return ReturnStatus
;
4371 Retrieves the current state of a pointer device.
4373 @param This Protocol instance pointer.
4374 @param State A pointer to the state information on the
4377 @retval EFI_SUCCESS The state of the pointer device was returned in
4379 @retval EFI_NOT_READY The state of the pointer device has not changed
4380 since the last call to GetState().
4381 @retval EFI_DEVICE_ERROR A device error occurred while attempting to
4382 retrieve the pointer device's current state.
4387 ConSplitterAbsolutePointerGetState (
4388 IN EFI_ABSOLUTE_POINTER_PROTOCOL
*This
,
4389 IN OUT EFI_ABSOLUTE_POINTER_STATE
*State
4392 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
4394 EFI_STATUS ReturnStatus
;
4396 EFI_ABSOLUTE_POINTER_STATE CurrentState
;
4410 Private
= TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_ABSOLUTE_POINTER_THIS (This
);
4412 Private
->AbsoluteInputEventSignalState
= FALSE
;
4414 State
->CurrentX
= 0;
4415 State
->CurrentY
= 0;
4416 State
->CurrentZ
= 0;
4417 State
->ActiveButtons
= 0;
4419 VirtualMinX
= Private
->AbsolutePointerMode
.AbsoluteMinX
;
4420 VirtualMinY
= Private
->AbsolutePointerMode
.AbsoluteMinY
;
4421 VirtualMinZ
= Private
->AbsolutePointerMode
.AbsoluteMinZ
;
4422 VirtualMaxX
= Private
->AbsolutePointerMode
.AbsoluteMaxX
;
4423 VirtualMaxY
= Private
->AbsolutePointerMode
.AbsoluteMaxY
;
4424 VirtualMaxZ
= Private
->AbsolutePointerMode
.AbsoluteMaxZ
;
4427 // if no physical pointer device exists, return EFI_NOT_READY;
4428 // if any physical pointer device has changed state,
4429 // return the state and EFI_SUCCESS.
4431 ReturnStatus
= EFI_NOT_READY
;
4432 for (Index
= 0; Index
< Private
->CurrentNumberOfAbsolutePointers
; Index
++) {
4434 Status
= Private
->AbsolutePointerList
[Index
]->GetState (
4435 Private
->AbsolutePointerList
[Index
],
4438 if (!EFI_ERROR (Status
)) {
4439 if (ReturnStatus
== EFI_NOT_READY
) {
4440 ReturnStatus
= EFI_SUCCESS
;
4443 MinX
= Private
->AbsolutePointerList
[Index
]->Mode
->AbsoluteMinX
;
4444 MinY
= Private
->AbsolutePointerList
[Index
]->Mode
->AbsoluteMinY
;
4445 MinZ
= Private
->AbsolutePointerList
[Index
]->Mode
->AbsoluteMinZ
;
4446 MaxX
= Private
->AbsolutePointerList
[Index
]->Mode
->AbsoluteMaxX
;
4447 MaxY
= Private
->AbsolutePointerList
[Index
]->Mode
->AbsoluteMaxY
;
4448 MaxZ
= Private
->AbsolutePointerList
[Index
]->Mode
->AbsoluteMaxZ
;
4450 State
->ActiveButtons
= CurrentState
.ActiveButtons
;
4453 // Rescale to Con Splitter virtual Absolute Pointer's resolution.
4455 if (!(MinX
== 0 && MaxX
== 0)) {
4456 State
->CurrentX
= VirtualMinX
+ DivU64x64Remainder (
4458 CurrentState
.CurrentX
,
4459 VirtualMaxX
- VirtualMinX
4465 if (!(MinY
== 0 && MaxY
== 0)) {
4466 State
->CurrentY
= VirtualMinY
+ DivU64x64Remainder (
4468 CurrentState
.CurrentY
,
4469 VirtualMaxY
- VirtualMinY
4475 if (!(MinZ
== 0 && MaxZ
== 0)) {
4476 State
->CurrentZ
= VirtualMinZ
+ DivU64x64Remainder (
4478 CurrentState
.CurrentZ
,
4479 VirtualMaxZ
- VirtualMinZ
4486 } else if (Status
== EFI_DEVICE_ERROR
) {
4487 ReturnStatus
= EFI_DEVICE_ERROR
;
4491 return ReturnStatus
;
4496 This event agregates all the events of the pointer devices in the splitter.
4497 If any events of physical pointer devices are signaled, signal the pointer
4498 splitter event. This will cause the calling code to call
4499 ConSplitterAbsolutePointerGetState ().
4501 @param Event The Event assoicated with callback.
4502 @param Context Context registered when Event was created.
4507 ConSplitterAbsolutePointerWaitForInput (
4513 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
4516 Private
= (TEXT_IN_SPLITTER_PRIVATE_DATA
*) Context
;
4519 // if AbsoluteInputEventSignalState is flagged before,
4520 // and not cleared by Reset() or GetState(), signal it
4522 if (Private
->AbsoluteInputEventSignalState
) {
4523 gBS
->SignalEvent (Event
);
4527 // if any physical console input device has key input, signal the event.
4529 for (Index
= 0; Index
< Private
->CurrentNumberOfAbsolutePointers
; Index
++) {
4530 Status
= gBS
->CheckEvent (Private
->AbsolutePointerList
[Index
]->WaitForInput
);
4531 if (!EFI_ERROR (Status
)) {
4532 gBS
->SignalEvent (Event
);
4533 Private
->AbsoluteInputEventSignalState
= TRUE
;
4540 Reset the text output device hardware and optionaly run diagnostics
4542 @param This Protocol instance pointer.
4543 @param ExtendedVerification Driver may perform more exhaustive verfication
4544 operation of the device during reset.
4546 @retval EFI_SUCCESS The text output device was reset.
4547 @retval EFI_DEVICE_ERROR The text output device is not functioning
4548 correctly and could not be reset.
4553 ConSplitterTextOutReset (
4554 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4555 IN BOOLEAN ExtendedVerification
4559 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4561 EFI_STATUS ReturnStatus
;
4563 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4566 // return the worst status met
4568 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
4569 Status
= Private
->TextOutList
[Index
].TextOut
->Reset (
4570 Private
->TextOutList
[Index
].TextOut
,
4571 ExtendedVerification
4573 if (EFI_ERROR (Status
)) {
4574 ReturnStatus
= Status
;
4578 This
->SetAttribute (This
, EFI_TEXT_ATTR (This
->Mode
->Attribute
& 0x0F, EFI_BLACK
));
4581 // reset all mode parameters
4583 TextOutSetMode (Private
, 0);
4585 return ReturnStatus
;
4590 Write a Unicode string to the output device.
4592 @param This Protocol instance pointer.
4593 @param WString The NULL-terminated Unicode string to be
4594 displayed on the output device(s). All output
4595 devices must also support the Unicode drawing
4596 defined in this file.
4598 @retval EFI_SUCCESS The string was output to the device.
4599 @retval EFI_DEVICE_ERROR The device reported an error while attempting to
4601 @retval EFI_UNSUPPORTED The output device's mode is not currently in a
4603 @retval EFI_WARN_UNKNOWN_GLYPH This warning code indicates that some of the
4604 characters in the Unicode string could not be
4605 rendered and were skipped.
4610 ConSplitterTextOutOutputString (
4611 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4616 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4618 EFI_STATUS ReturnStatus
;
4622 This
->SetAttribute (This
, This
->Mode
->Attribute
);
4624 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4627 // return the worst status met
4629 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
4630 Status
= Private
->TextOutList
[Index
].TextOut
->OutputString (
4631 Private
->TextOutList
[Index
].TextOut
,
4634 if (EFI_ERROR (Status
)) {
4635 ReturnStatus
= Status
;
4639 if (Private
->CurrentNumberOfConsoles
> 0) {
4640 Private
->TextOutMode
.CursorColumn
= Private
->TextOutList
[0].TextOut
->Mode
->CursorColumn
;
4641 Private
->TextOutMode
.CursorRow
= Private
->TextOutList
[0].TextOut
->Mode
->CursorRow
;
4644 // When there is no real console devices in system,
4645 // update cursor position for the virtual device in consplitter.
4647 Private
->TextOut
.QueryMode (
4649 Private
->TextOutMode
.Mode
,
4653 for (; *WString
!= CHAR_NULL
; WString
++) {
4655 case CHAR_BACKSPACE
:
4656 if (Private
->TextOutMode
.CursorColumn
== 0 && Private
->TextOutMode
.CursorRow
> 0) {
4657 Private
->TextOutMode
.CursorRow
--;
4658 Private
->TextOutMode
.CursorColumn
= (INT32
) (MaxColumn
- 1);
4659 } else if (Private
->TextOutMode
.CursorColumn
> 0) {
4660 Private
->TextOutMode
.CursorColumn
--;
4665 if (Private
->TextOutMode
.CursorRow
< (INT32
) (MaxRow
- 1)) {
4666 Private
->TextOutMode
.CursorRow
++;
4670 case CHAR_CARRIAGE_RETURN
:
4671 Private
->TextOutMode
.CursorColumn
= 0;
4675 if (Private
->TextOutMode
.CursorColumn
< (INT32
) (MaxColumn
- 1)) {
4676 Private
->TextOutMode
.CursorColumn
++;
4678 Private
->TextOutMode
.CursorColumn
= 0;
4679 if (Private
->TextOutMode
.CursorRow
< (INT32
) (MaxRow
- 1)) {
4680 Private
->TextOutMode
.CursorRow
++;
4688 return ReturnStatus
;
4693 Verifies that all characters in a Unicode string can be output to the
4696 @param This Protocol instance pointer.
4697 @param WString The NULL-terminated Unicode string to be
4698 examined for the output device(s).
4700 @retval EFI_SUCCESS The device(s) are capable of rendering the
4702 @retval EFI_UNSUPPORTED Some of the characters in the Unicode string
4703 cannot be rendered by one or more of the output
4704 devices mapped by the EFI handle.
4709 ConSplitterTextOutTestString (
4710 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4715 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4717 EFI_STATUS ReturnStatus
;
4719 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4722 // return the worst status met
4724 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
4725 Status
= Private
->TextOutList
[Index
].TextOut
->TestString (
4726 Private
->TextOutList
[Index
].TextOut
,
4729 if (EFI_ERROR (Status
)) {
4730 ReturnStatus
= Status
;
4734 // There is no DevNullTextOutTestString () since a Unicode buffer would
4735 // always return EFI_SUCCESS.
4736 // ReturnStatus will be EFI_SUCCESS if no consoles are present
4738 return ReturnStatus
;
4743 Returns information for an available text mode that the output device(s)
4746 @param This Protocol instance pointer.
4747 @param ModeNumber The mode number to return information on.
4748 @param Columns Returns the columns of the text output device
4749 for the requested ModeNumber.
4750 @param Rows Returns the rows of the text output device
4751 for the requested ModeNumber.
4753 @retval EFI_SUCCESS The requested mode information was returned.
4754 @retval EFI_DEVICE_ERROR The device had an error and could not complete
4756 @retval EFI_UNSUPPORTED The mode number was not valid.
4761 ConSplitterTextOutQueryMode (
4762 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4763 IN UINTN ModeNumber
,
4768 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4770 INT32
*TextOutModeMap
;
4772 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4775 // Check whether param ModeNumber is valid.
4776 // ModeNumber should be within range 0 ~ MaxMode - 1.
4778 if ( (ModeNumber
> (UINTN
)(((UINT32
)-1)>>1)) ) {
4779 return EFI_UNSUPPORTED
;
4782 if ((INT32
) ModeNumber
>= This
->Mode
->MaxMode
) {
4783 return EFI_UNSUPPORTED
;
4787 // We get the available mode from mode intersection map if it's available
4789 if (Private
->TextOutModeMap
!= NULL
) {
4790 TextOutModeMap
= Private
->TextOutModeMap
+ Private
->TextOutListCount
* ModeNumber
;
4791 CurrentMode
= (UINTN
)(*TextOutModeMap
);
4792 *Columns
= Private
->TextOutQueryData
[CurrentMode
].Columns
;
4793 *Rows
= Private
->TextOutQueryData
[CurrentMode
].Rows
;
4795 *Columns
= Private
->TextOutQueryData
[ModeNumber
].Columns
;
4796 *Rows
= Private
->TextOutQueryData
[ModeNumber
].Rows
;
4799 if (*Columns
<= 0 && *Rows
<= 0) {
4800 return EFI_UNSUPPORTED
;
4809 Sets the output device(s) to a specified mode.
4811 @param This Protocol instance pointer.
4812 @param ModeNumber The mode number to set.
4814 @retval EFI_SUCCESS The requested text mode was set.
4815 @retval EFI_DEVICE_ERROR The device had an error and could not complete
4817 @retval EFI_UNSUPPORTED The mode number was not valid.
4822 ConSplitterTextOutSetMode (
4823 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4828 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4830 INT32
*TextOutModeMap
;
4831 EFI_STATUS ReturnStatus
;
4833 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4836 // Check whether param ModeNumber is valid.
4837 // ModeNumber should be within range 0 ~ MaxMode - 1.
4839 if ( (ModeNumber
> (UINTN
)(((UINT32
)-1)>>1)) ) {
4840 return EFI_UNSUPPORTED
;
4843 if ((INT32
) ModeNumber
>= This
->Mode
->MaxMode
) {
4844 return EFI_UNSUPPORTED
;
4847 // If the mode is being set to the curent mode, then just clear the screen and return.
4849 if (Private
->TextOutMode
.Mode
== (INT32
) ModeNumber
) {
4850 return ConSplitterTextOutClearScreen (This
);
4853 // return the worst status met
4855 TextOutModeMap
= Private
->TextOutModeMap
+ Private
->TextOutListCount
* ModeNumber
;
4856 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
4858 // While adding a console out device do not set same mode again for the same device.
4860 if ((!Private
->AddingConOutDevice
) ||
4861 (TextOutModeMap
[Index
] != Private
->TextOutList
[Index
].TextOut
->Mode
->Mode
)) {
4862 Status
= Private
->TextOutList
[Index
].TextOut
->SetMode (
4863 Private
->TextOutList
[Index
].TextOut
,
4864 TextOutModeMap
[Index
]
4866 if (EFI_ERROR (Status
)) {
4867 ReturnStatus
= Status
;
4873 // Set mode parameter to specified mode number
4875 TextOutSetMode (Private
, ModeNumber
);
4877 return ReturnStatus
;
4882 Sets the background and foreground colors for the OutputString () and
4883 ClearScreen () functions.
4885 @param This Protocol instance pointer.
4886 @param Attribute The attribute to set. Bits 0..3 are the
4887 foreground color, and bits 4..6 are the
4888 background color. All other bits are undefined
4889 and must be zero. The valid Attributes are
4890 defined in this file.
4892 @retval EFI_SUCCESS The attribute was set.
4893 @retval EFI_DEVICE_ERROR The device had an error and could not complete
4895 @retval EFI_UNSUPPORTED The attribute requested is not defined.
4900 ConSplitterTextOutSetAttribute (
4901 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4906 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4908 EFI_STATUS ReturnStatus
;
4910 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4913 // Check whether param Attribute is valid.
4915 if ((Attribute
| 0x7F) != 0x7F) {
4916 return EFI_UNSUPPORTED
;
4920 // return the worst status met
4922 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
4923 Status
= Private
->TextOutList
[Index
].TextOut
->SetAttribute (
4924 Private
->TextOutList
[Index
].TextOut
,
4927 if (EFI_ERROR (Status
)) {
4928 ReturnStatus
= Status
;
4932 Private
->TextOutMode
.Attribute
= (INT32
) Attribute
;
4934 return ReturnStatus
;
4939 Clears the output device(s) display to the currently selected background
4942 @param This Protocol instance pointer.
4944 @retval EFI_SUCCESS The operation completed successfully.
4945 @retval EFI_DEVICE_ERROR The device had an error and could not complete
4947 @retval EFI_UNSUPPORTED The output device is not in a valid text mode.
4952 ConSplitterTextOutClearScreen (
4953 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
4957 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4959 EFI_STATUS ReturnStatus
;
4961 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4964 // return the worst status met
4966 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
4967 Status
= Private
->TextOutList
[Index
].TextOut
->ClearScreen (Private
->TextOutList
[Index
].TextOut
);
4968 if (EFI_ERROR (Status
)) {
4969 ReturnStatus
= Status
;
4974 // No need to do extra check here as whether (Column, Row) is valid has
4975 // been checked in ConSplitterTextOutSetCursorPosition. And (0, 0) should
4976 // always be supported.
4978 Private
->TextOutMode
.CursorColumn
= 0;
4979 Private
->TextOutMode
.CursorRow
= 0;
4980 Private
->TextOutMode
.CursorVisible
= TRUE
;
4982 return ReturnStatus
;
4987 Sets the current coordinates of the cursor position
4989 @param This Protocol instance pointer.
4990 @param Column The column position to set the cursor to. Must be
4991 greater than or equal to zero and less than the
4992 number of columns by QueryMode ().
4993 @param Row The row position to set the cursor to. Must be
4994 greater than or equal to zero and less than the
4995 number of rows by QueryMode ().
4997 @retval EFI_SUCCESS The operation completed successfully.
4998 @retval EFI_DEVICE_ERROR The device had an error and could not complete
5000 @retval EFI_UNSUPPORTED The output device is not in a valid text mode,
5001 or the cursor position is invalid for the
5007 ConSplitterTextOutSetCursorPosition (
5008 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
5014 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
5016 EFI_STATUS ReturnStatus
;
5019 INT32
*TextOutModeMap
;
5023 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
5024 TextOutModeMap
= NULL
;
5025 ModeNumber
= Private
->TextOutMode
.Mode
;
5028 // Get current MaxColumn and MaxRow from intersection map
5030 if (Private
->TextOutModeMap
!= NULL
) {
5031 TextOutModeMap
= Private
->TextOutModeMap
+ Private
->TextOutListCount
* ModeNumber
;
5032 CurrentMode
= *TextOutModeMap
;
5034 CurrentMode
= ModeNumber
;
5037 MaxColumn
= Private
->TextOutQueryData
[CurrentMode
].Columns
;
5038 MaxRow
= Private
->TextOutQueryData
[CurrentMode
].Rows
;
5040 if (Column
>= MaxColumn
|| Row
>= MaxRow
) {
5041 return EFI_UNSUPPORTED
;
5044 // return the worst status met
5046 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
5047 Status
= Private
->TextOutList
[Index
].TextOut
->SetCursorPosition (
5048 Private
->TextOutList
[Index
].TextOut
,
5052 if (EFI_ERROR (Status
)) {
5053 ReturnStatus
= Status
;
5058 // No need to do extra check here as whether (Column, Row) is valid has
5059 // been checked in ConSplitterTextOutSetCursorPosition. And (0, 0) should
5060 // always be supported.
5062 Private
->TextOutMode
.CursorColumn
= (INT32
) Column
;
5063 Private
->TextOutMode
.CursorRow
= (INT32
) Row
;
5065 return ReturnStatus
;
5070 Makes the cursor visible or invisible
5072 @param This Protocol instance pointer.
5073 @param Visible If TRUE, the cursor is set to be visible. If
5074 FALSE, the cursor is set to be invisible.
5076 @retval EFI_SUCCESS The operation completed successfully.
5077 @retval EFI_DEVICE_ERROR The device had an error and could not complete
5078 the request, or the device does not support
5079 changing the cursor mode.
5080 @retval EFI_UNSUPPORTED The output device is not in a valid text mode.
5085 ConSplitterTextOutEnableCursor (
5086 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
5091 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
5093 EFI_STATUS ReturnStatus
;
5095 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
5098 // return the worst status met
5100 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
5101 Status
= Private
->TextOutList
[Index
].TextOut
->EnableCursor (
5102 Private
->TextOutList
[Index
].TextOut
,
5105 if (EFI_ERROR (Status
)) {
5106 ReturnStatus
= Status
;
5110 Private
->TextOutMode
.CursorVisible
= Visible
;
5112 return ReturnStatus
;