2 Console Splitter Driver. Any Handle that attatched console I/O protocols
3 (Console In device, Console Out device, Console Error device, Simple Pointer
4 protocol, Absolute Pointer protocol) can be bound by this driver.
6 So far it works like any other driver by opening a SimpleTextIn and/or
7 SimpleTextOut protocol with EFI_OPEN_PROTOCOL_BY_DRIVER attributes. The big
8 difference is this driver does not layer a protocol on the passed in
9 handle, or construct a child handle like a standard device or bus driver.
10 This driver produces three virtual handles as children, one for console input
11 splitter, one for console output splitter and one for error output splitter.
12 These 3 virtual handles would be installed on gST.
14 Each virtual handle, that supports the Console I/O protocol, will be produced
15 in the driver entry point. The virtual handle are added on driver entry and
16 never removed. Such design ensures sytem function well during none console
19 Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
20 (C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>
21 This program and the accompanying materials
22 are licensed and made available under the terms and conditions of the BSD License
23 which accompanies this distribution. The full text of the license may be found at
24 http://opensource.org/licenses/bsd-license.php
26 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
27 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
31 #include "ConSplitter.h"
34 // Identify if ConIn is connected in PcdConInConnectOnDemand enabled mode.
35 // default not connect
37 BOOLEAN mConInIsConnect
= FALSE
;
40 // Text In Splitter Private Data template
42 GLOBAL_REMOVE_IF_UNREFERENCED TEXT_IN_SPLITTER_PRIVATE_DATA mConIn
= {
43 TEXT_IN_SPLITTER_PRIVATE_DATA_SIGNATURE
,
47 ConSplitterTextInReset
,
48 ConSplitterTextInReadKeyStroke
,
52 (EFI_SIMPLE_TEXT_INPUT_PROTOCOL
**) NULL
,
56 ConSplitterTextInResetEx
,
57 ConSplitterTextInReadKeyStrokeEx
,
59 ConSplitterTextInSetState
,
60 ConSplitterTextInRegisterKeyNotify
,
61 ConSplitterTextInUnregisterKeyNotify
64 (EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
**) NULL
,
70 (EFI_KEY_DATA
*) NULL
,
76 ConSplitterSimplePointerReset
,
77 ConSplitterSimplePointerGetState
,
79 (EFI_SIMPLE_POINTER_MODE
*) NULL
89 (EFI_SIMPLE_POINTER_PROTOCOL
**) NULL
,
93 ConSplitterAbsolutePointerReset
,
94 ConSplitterAbsolutePointerGetState
,
96 (EFI_ABSOLUTE_POINTER_MODE
*) NULL
102 0x10000, // AbsoluteMaxX
103 0x10000, // AbsoluteMaxY
104 0x10000, // AbsoluteMaxZ
108 (EFI_ABSOLUTE_POINTER_PROTOCOL
**) NULL
,
118 // Uga Draw Protocol Private Data template
120 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UGA_DRAW_PROTOCOL mUgaDrawProtocolTemplate
= {
121 ConSplitterUgaDrawGetMode
,
122 ConSplitterUgaDrawSetMode
,
123 ConSplitterUgaDrawBlt
127 // Graphics Output Protocol Private Data template
129 GLOBAL_REMOVE_IF_UNREFERENCED EFI_GRAPHICS_OUTPUT_PROTOCOL mGraphicsOutputProtocolTemplate
= {
130 ConSplitterGraphicsOutputQueryMode
,
131 ConSplitterGraphicsOutputSetMode
,
132 ConSplitterGraphicsOutputBlt
,
138 // Text Out Splitter Private Data template
140 GLOBAL_REMOVE_IF_UNREFERENCED TEXT_OUT_SPLITTER_PRIVATE_DATA mConOut
= {
141 TEXT_OUT_SPLITTER_PRIVATE_DATA_SIGNATURE
,
144 ConSplitterTextOutReset
,
145 ConSplitterTextOutOutputString
,
146 ConSplitterTextOutTestString
,
147 ConSplitterTextOutQueryMode
,
148 ConSplitterTextOutSetMode
,
149 ConSplitterTextOutSetAttribute
,
150 ConSplitterTextOutClearScreen
,
151 ConSplitterTextOutSetCursorPosition
,
152 ConSplitterTextOutEnableCursor
,
153 (EFI_SIMPLE_TEXT_OUTPUT_MODE
*) NULL
180 (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*) NULL
,
185 (TEXT_OUT_AND_GOP_DATA
*) NULL
,
187 (TEXT_OUT_SPLITTER_QUERY_DATA
*) NULL
,
193 // Standard Error Text Out Splitter Data Template
195 GLOBAL_REMOVE_IF_UNREFERENCED TEXT_OUT_SPLITTER_PRIVATE_DATA mStdErr
= {
196 TEXT_OUT_SPLITTER_PRIVATE_DATA_SIGNATURE
,
199 ConSplitterTextOutReset
,
200 ConSplitterTextOutOutputString
,
201 ConSplitterTextOutTestString
,
202 ConSplitterTextOutQueryMode
,
203 ConSplitterTextOutSetMode
,
204 ConSplitterTextOutSetAttribute
,
205 ConSplitterTextOutClearScreen
,
206 ConSplitterTextOutSetCursorPosition
,
207 ConSplitterTextOutEnableCursor
,
208 (EFI_SIMPLE_TEXT_OUTPUT_MODE
*) NULL
235 (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*) NULL
,
240 (TEXT_OUT_AND_GOP_DATA
*) NULL
,
242 (TEXT_OUT_SPLITTER_QUERY_DATA
*) NULL
,
248 // Driver binding instance for Console Input Device
250 EFI_DRIVER_BINDING_PROTOCOL gConSplitterConInDriverBinding
= {
251 ConSplitterConInDriverBindingSupported
,
252 ConSplitterConInDriverBindingStart
,
253 ConSplitterConInDriverBindingStop
,
260 // Driver binding instance for Console Out device
262 EFI_DRIVER_BINDING_PROTOCOL gConSplitterConOutDriverBinding
= {
263 ConSplitterConOutDriverBindingSupported
,
264 ConSplitterConOutDriverBindingStart
,
265 ConSplitterConOutDriverBindingStop
,
272 // Driver binding instance for Standard Error device
274 EFI_DRIVER_BINDING_PROTOCOL gConSplitterStdErrDriverBinding
= {
275 ConSplitterStdErrDriverBindingSupported
,
276 ConSplitterStdErrDriverBindingStart
,
277 ConSplitterStdErrDriverBindingStop
,
284 // Driver binding instance for Simple Pointer protocol
286 EFI_DRIVER_BINDING_PROTOCOL gConSplitterSimplePointerDriverBinding
= {
287 ConSplitterSimplePointerDriverBindingSupported
,
288 ConSplitterSimplePointerDriverBindingStart
,
289 ConSplitterSimplePointerDriverBindingStop
,
296 // Driver binding instance for Absolute Pointer protocol
298 EFI_DRIVER_BINDING_PROTOCOL gConSplitterAbsolutePointerDriverBinding
= {
299 ConSplitterAbsolutePointerDriverBindingSupported
,
300 ConSplitterAbsolutePointerDriverBindingStart
,
301 ConSplitterAbsolutePointerDriverBindingStop
,
308 Key notify for toggle state sync.
310 @param KeyData A pointer to a buffer that is filled in with
311 the keystroke information for the key that was
314 @retval EFI_SUCCESS Toggle state sync successfully.
319 ToggleStateSyncKeyNotify (
320 IN EFI_KEY_DATA
*KeyData
325 if (((KeyData
->KeyState
.KeyToggleState
& KEY_STATE_VALID_EXPOSED
) == KEY_STATE_VALID_EXPOSED
) &&
326 (KeyData
->KeyState
.KeyToggleState
!= mConIn
.PhysicalKeyToggleState
)) {
328 // There is toggle state change, sync to other console input devices.
330 for (Index
= 0; Index
< mConIn
.CurrentNumberOfExConsoles
; Index
++) {
331 mConIn
.TextInExList
[Index
]->SetState (
332 mConIn
.TextInExList
[Index
],
333 &KeyData
->KeyState
.KeyToggleState
336 mConIn
.PhysicalKeyToggleState
= KeyData
->KeyState
.KeyToggleState
;
337 DEBUG ((EFI_D_INFO
, "Current toggle state is 0x%02x\n", mConIn
.PhysicalKeyToggleState
));
344 Initialization for toggle state sync.
346 @param Private Text In Splitter pointer.
350 ToggleStateSyncInitialization (
351 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
354 EFI_KEY_DATA KeyData
;
358 // Initialize PhysicalKeyToggleState that will be synced to new console
359 // input device to turn on physical TextInEx partial key report for
360 // toggle state sync.
362 Private
->PhysicalKeyToggleState
= KEY_STATE_VALID_EXPOSED
;
365 // Initialize VirtualKeyStateExported to let the virtual TextInEx not report
366 // the partial key even though the physical TextInEx turns on the partial
367 // key report. The virtual TextInEx will report the partial key after it is
368 // required by calling SetState(X | KEY_STATE_VALID_EXPOSED) explicitly.
370 Private
->VirtualKeyStateExported
= FALSE
;
373 // Register key notify for toggle state sync.
375 KeyData
.Key
.ScanCode
= SCAN_NULL
;
376 KeyData
.Key
.UnicodeChar
= CHAR_NULL
;
377 KeyData
.KeyState
.KeyShiftState
= 0;
378 KeyData
.KeyState
.KeyToggleState
= 0;
379 Private
->TextInEx
.RegisterKeyNotify (
382 ToggleStateSyncKeyNotify
,
388 Reinitialization for toggle state sync.
390 @param Private Text In Splitter pointer.
394 ToggleStateSyncReInitialization (
395 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
401 // Reinitialize PhysicalKeyToggleState that will be synced to new console
402 // input device to turn on physical TextInEx partial key report for
403 // toggle state sync.
405 Private
->PhysicalKeyToggleState
= KEY_STATE_VALID_EXPOSED
;
408 // Reinitialize VirtualKeyStateExported to let the virtual TextInEx not report
409 // the partial key even though the physical TextInEx turns on the partial
410 // key report. The virtual TextInEx will report the partial key after it is
411 // required by calling SetState(X | KEY_STATE_VALID_EXPOSED) explicitly.
413 Private
->VirtualKeyStateExported
= FALSE
;
415 for (Index
= 0; Index
< Private
->CurrentNumberOfExConsoles
; Index
++) {
416 Private
->TextInExList
[Index
]->SetState (
417 Private
->TextInExList
[Index
],
418 &Private
->PhysicalKeyToggleState
424 The Entry Point for module ConSplitter. The user code starts with this function.
426 Installs driver module protocols and. Creates virtual device handles for ConIn,
427 ConOut, and StdErr. Installs Simple Text In protocol, Simple Text In Ex protocol,
428 Simple Pointer protocol, Absolute Pointer protocol on those virtual handlers.
429 Installs Graphics Output protocol and/or UGA Draw protocol if needed.
431 @param[in] ImageHandle The firmware allocated handle for the EFI image.
432 @param[in] SystemTable A pointer to the EFI System Table.
434 @retval EFI_SUCCESS The entry point is executed successfully.
435 @retval other Some error occurs when executing this entry point.
440 ConSplitterDriverEntry(
441 IN EFI_HANDLE ImageHandle
,
442 IN EFI_SYSTEM_TABLE
*SystemTable
448 // Install driver model protocol(s).
450 Status
= EfiLibInstallDriverBindingComponentName2 (
453 &gConSplitterConInDriverBinding
,
455 &gConSplitterConInComponentName
,
456 &gConSplitterConInComponentName2
458 ASSERT_EFI_ERROR (Status
);
460 Status
= EfiLibInstallDriverBindingComponentName2 (
463 &gConSplitterSimplePointerDriverBinding
,
465 &gConSplitterSimplePointerComponentName
,
466 &gConSplitterSimplePointerComponentName2
468 ASSERT_EFI_ERROR (Status
);
470 Status
= EfiLibInstallDriverBindingComponentName2 (
473 &gConSplitterAbsolutePointerDriverBinding
,
475 &gConSplitterAbsolutePointerComponentName
,
476 &gConSplitterAbsolutePointerComponentName2
478 ASSERT_EFI_ERROR (Status
);
480 Status
= EfiLibInstallDriverBindingComponentName2 (
483 &gConSplitterConOutDriverBinding
,
485 &gConSplitterConOutComponentName
,
486 &gConSplitterConOutComponentName2
488 ASSERT_EFI_ERROR (Status
);
490 Status
= EfiLibInstallDriverBindingComponentName2 (
493 &gConSplitterStdErrDriverBinding
,
495 &gConSplitterStdErrComponentName
,
496 &gConSplitterStdErrComponentName2
498 ASSERT_EFI_ERROR (Status
);
501 // Either Graphics Output protocol or UGA Draw protocol must be supported.
503 ASSERT (FeaturePcdGet (PcdConOutGopSupport
) ||
504 FeaturePcdGet (PcdConOutUgaSupport
));
507 // The driver creates virtual handles for ConIn, ConOut, StdErr.
508 // The virtual handles will always exist even if no console exist in the
509 // system. This is need to support hotplug devices like USB.
512 // Create virtual device handle for ConIn Splitter
514 Status
= ConSplitterTextInConstructor (&mConIn
);
515 if (!EFI_ERROR (Status
)) {
516 Status
= gBS
->InstallMultipleProtocolInterfaces (
517 &mConIn
.VirtualHandle
,
518 &gEfiSimpleTextInProtocolGuid
,
520 &gEfiSimpleTextInputExProtocolGuid
,
522 &gEfiSimplePointerProtocolGuid
,
523 &mConIn
.SimplePointer
,
524 &gEfiAbsolutePointerProtocolGuid
,
525 &mConIn
.AbsolutePointer
,
528 if (!EFI_ERROR (Status
)) {
530 // Update the EFI System Table with new virtual console
531 // and update the pointer to Simple Text Input protocol.
533 gST
->ConsoleInHandle
= mConIn
.VirtualHandle
;
534 gST
->ConIn
= &mConIn
.TextIn
;
538 // Create virtual device handle for ConOut Splitter
540 Status
= ConSplitterTextOutConstructor (&mConOut
);
541 if (!EFI_ERROR (Status
)) {
542 Status
= gBS
->InstallMultipleProtocolInterfaces (
543 &mConOut
.VirtualHandle
,
544 &gEfiSimpleTextOutProtocolGuid
,
548 if (!EFI_ERROR (Status
)) {
550 // Update the EFI System Table with new virtual console
551 // and Update the pointer to Text Output protocol.
553 gST
->ConsoleOutHandle
= mConOut
.VirtualHandle
;
554 gST
->ConOut
= &mConOut
.TextOut
;
560 // Create virtual device handle for StdErr Splitter
562 Status
= ConSplitterTextOutConstructor (&mStdErr
);
563 if (!EFI_ERROR (Status
)) {
564 Status
= gBS
->InstallMultipleProtocolInterfaces (
565 &mStdErr
.VirtualHandle
,
566 &gEfiSimpleTextOutProtocolGuid
,
570 if (!EFI_ERROR (Status
)) {
572 // Update the EFI System Table with new virtual console
573 // and update the pointer to Text Output protocol.
575 gST
->StandardErrorHandle
= mStdErr
.VirtualHandle
;
576 gST
->StdErr
= &mStdErr
.TextOut
;
581 // Update the CRC32 in the EFI System Table header
584 gBS
->CalculateCrc32 (
595 Construct console input devices' private data.
597 @param ConInPrivate A pointer to the TEXT_IN_SPLITTER_PRIVATE_DATA
600 @retval EFI_OUT_OF_RESOURCES Out of resources.
601 @retval EFI_SUCCESS Text Input Devcie's private data has been constructed.
602 @retval other Failed to construct private data.
606 ConSplitterTextInConstructor (
607 TEXT_IN_SPLITTER_PRIVATE_DATA
*ConInPrivate
611 UINTN TextInExListCount
;
614 // Allocate buffer for Simple Text Input device
616 Status
= ConSplitterGrowBuffer (
617 sizeof (EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*),
618 &ConInPrivate
->TextInListCount
,
619 (VOID
**) &ConInPrivate
->TextInList
621 if (EFI_ERROR (Status
)) {
622 return EFI_OUT_OF_RESOURCES
;
626 // Create Event to wait for a key
628 Status
= gBS
->CreateEvent (
631 ConSplitterTextInWaitForKey
,
633 &ConInPrivate
->TextIn
.WaitForKey
635 ASSERT_EFI_ERROR (Status
);
638 // Allocate buffer for KeyQueue
640 TextInExListCount
= ConInPrivate
->TextInExListCount
;
641 Status
= ConSplitterGrowBuffer (
642 sizeof (EFI_KEY_DATA
),
644 (VOID
**) &ConInPrivate
->KeyQueue
646 if (EFI_ERROR (Status
)) {
647 return EFI_OUT_OF_RESOURCES
;
651 // Allocate buffer for Simple Text Input Ex device
653 Status
= ConSplitterGrowBuffer (
654 sizeof (EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*),
655 &ConInPrivate
->TextInExListCount
,
656 (VOID
**) &ConInPrivate
->TextInExList
658 if (EFI_ERROR (Status
)) {
659 return EFI_OUT_OF_RESOURCES
;
662 // Create Event to wait for a key Ex
664 Status
= gBS
->CreateEvent (
667 ConSplitterTextInWaitForKey
,
669 &ConInPrivate
->TextInEx
.WaitForKeyEx
671 ASSERT_EFI_ERROR (Status
);
673 InitializeListHead (&ConInPrivate
->NotifyList
);
675 ToggleStateSyncInitialization (ConInPrivate
);
677 ConInPrivate
->AbsolutePointer
.Mode
= &ConInPrivate
->AbsolutePointerMode
;
679 // Allocate buffer for Absolute Pointer device
681 Status
= ConSplitterGrowBuffer (
682 sizeof (EFI_ABSOLUTE_POINTER_PROTOCOL
*),
683 &ConInPrivate
->AbsolutePointerListCount
,
684 (VOID
**) &ConInPrivate
->AbsolutePointerList
686 if (EFI_ERROR (Status
)) {
687 return EFI_OUT_OF_RESOURCES
;
690 // Create Event to wait for device input for Absolute pointer device
692 Status
= gBS
->CreateEvent (
695 ConSplitterAbsolutePointerWaitForInput
,
697 &ConInPrivate
->AbsolutePointer
.WaitForInput
699 ASSERT_EFI_ERROR (Status
);
701 ConInPrivate
->SimplePointer
.Mode
= &ConInPrivate
->SimplePointerMode
;
703 // Allocate buffer for Simple Pointer device
705 Status
= ConSplitterGrowBuffer (
706 sizeof (EFI_SIMPLE_POINTER_PROTOCOL
*),
707 &ConInPrivate
->PointerListCount
,
708 (VOID
**) &ConInPrivate
->PointerList
710 if (EFI_ERROR (Status
)) {
711 return EFI_OUT_OF_RESOURCES
;
714 // Create Event to wait for device input for Simple pointer device
716 Status
= gBS
->CreateEvent (
719 ConSplitterSimplePointerWaitForInput
,
721 &ConInPrivate
->SimplePointer
.WaitForInput
723 ASSERT_EFI_ERROR (Status
);
725 // Create Event to signal ConIn connection request
727 Status
= gBS
->CreateEventEx (
730 EfiEventEmptyFunction
,
732 &gConnectConInEventGuid
,
733 &ConInPrivate
->ConnectConInEvent
740 Construct console output devices' private data.
742 @param ConOutPrivate A pointer to the TEXT_OUT_SPLITTER_PRIVATE_DATA
745 @retval EFI_OUT_OF_RESOURCES Out of resources.
746 @retval EFI_SUCCESS Text Input Devcie's private data has been constructed.
750 ConSplitterTextOutConstructor (
751 TEXT_OUT_SPLITTER_PRIVATE_DATA
*ConOutPrivate
755 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*Info
;
758 // Copy protocols template
760 if (FeaturePcdGet (PcdConOutUgaSupport
)) {
761 CopyMem (&ConOutPrivate
->UgaDraw
, &mUgaDrawProtocolTemplate
, sizeof (EFI_UGA_DRAW_PROTOCOL
));
763 if (FeaturePcdGet (PcdConOutGopSupport
)) {
764 CopyMem (&ConOutPrivate
->GraphicsOutput
, &mGraphicsOutputProtocolTemplate
, sizeof (EFI_GRAPHICS_OUTPUT_PROTOCOL
));
768 // Initilize console output splitter's private data.
770 ConOutPrivate
->TextOut
.Mode
= &ConOutPrivate
->TextOutMode
;
773 // When new console device is added, the new mode will be set later,
774 // so put current mode back to init state.
776 ConOutPrivate
->TextOutMode
.Mode
= 0xFF;
778 // Allocate buffer for Console Out device
780 Status
= ConSplitterGrowBuffer (
781 sizeof (TEXT_OUT_AND_GOP_DATA
),
782 &ConOutPrivate
->TextOutListCount
,
783 (VOID
**) &ConOutPrivate
->TextOutList
785 if (EFI_ERROR (Status
)) {
786 return EFI_OUT_OF_RESOURCES
;
789 // Allocate buffer for Text Out query data
791 Status
= ConSplitterGrowBuffer (
792 sizeof (TEXT_OUT_SPLITTER_QUERY_DATA
),
793 &ConOutPrivate
->TextOutQueryDataCount
,
794 (VOID
**) &ConOutPrivate
->TextOutQueryData
796 if (EFI_ERROR (Status
)) {
797 return EFI_OUT_OF_RESOURCES
;
801 // Setup the default console to 80 x 25 and mode to 0
803 ConOutPrivate
->TextOutQueryData
[0].Columns
= 80;
804 ConOutPrivate
->TextOutQueryData
[0].Rows
= 25;
805 TextOutSetMode (ConOutPrivate
, 0);
808 if (FeaturePcdGet (PcdConOutUgaSupport
)) {
810 // Setup the UgaDraw to 800 x 600 x 32 bits per pixel, 60Hz.
812 ConSplitterUgaDrawSetMode (&ConOutPrivate
->UgaDraw
, 800, 600, 32, 60);
814 if (FeaturePcdGet (PcdConOutGopSupport
)) {
816 // Setup resource for mode information in Graphics Output Protocol interface
818 if ((ConOutPrivate
->GraphicsOutput
.Mode
= AllocateZeroPool (sizeof (EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE
))) == NULL
) {
819 return EFI_OUT_OF_RESOURCES
;
821 if ((ConOutPrivate
->GraphicsOutput
.Mode
->Info
= AllocateZeroPool (sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
))) == NULL
) {
822 return EFI_OUT_OF_RESOURCES
;
825 // Setup the DevNullGraphicsOutput to 800 x 600 x 32 bits per pixel
826 // DevNull will be updated to user-defined mode after driver has started.
828 if ((ConOutPrivate
->GraphicsOutputModeBuffer
= AllocateZeroPool (sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
))) == NULL
) {
829 return EFI_OUT_OF_RESOURCES
;
831 Info
= &ConOutPrivate
->GraphicsOutputModeBuffer
[0];
833 Info
->HorizontalResolution
= 800;
834 Info
->VerticalResolution
= 600;
835 Info
->PixelFormat
= PixelBltOnly
;
836 Info
->PixelsPerScanLine
= 800;
837 CopyMem (ConOutPrivate
->GraphicsOutput
.Mode
->Info
, Info
, sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
));
838 ConOutPrivate
->GraphicsOutput
.Mode
->SizeOfInfo
= sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
);
841 // Initialize the following items, theset items remain unchanged in GraphicsOutput->SetMode()
842 // GraphicsOutputMode->FrameBufferBase, GraphicsOutputMode->FrameBufferSize
844 ConOutPrivate
->GraphicsOutput
.Mode
->FrameBufferBase
= (EFI_PHYSICAL_ADDRESS
) (UINTN
) NULL
;
845 ConOutPrivate
->GraphicsOutput
.Mode
->FrameBufferSize
= 0;
847 ConOutPrivate
->GraphicsOutput
.Mode
->MaxMode
= 1;
849 // Initial current mode to unknown state, and then set to mode 0
851 ConOutPrivate
->GraphicsOutput
.Mode
->Mode
= 0xffff;
852 ConOutPrivate
->GraphicsOutput
.SetMode (&ConOutPrivate
->GraphicsOutput
, 0);
860 Test to see if the specified protocol could be supported on the specified device.
862 @param This Driver Binding protocol pointer.
863 @param ControllerHandle Handle of device to test.
864 @param Guid The specified protocol.
866 @retval EFI_SUCCESS The specified protocol is supported on this device.
867 @retval EFI_UNSUPPORTED The specified protocol attempts to be installed on virtul handle.
868 @retval other Failed to open specified protocol on this device.
872 ConSplitterSupported (
873 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
874 IN EFI_HANDLE ControllerHandle
,
882 // Make sure the Console Splitter does not attempt to attach to itself
884 if (ControllerHandle
== mConIn
.VirtualHandle
||
885 ControllerHandle
== mConOut
.VirtualHandle
||
886 ControllerHandle
== mStdErr
.VirtualHandle
888 return EFI_UNSUPPORTED
;
892 // Check to see whether the specific protocol could be opened BY_DRIVER
894 Status
= gBS
->OpenProtocol (
898 This
->DriverBindingHandle
,
900 EFI_OPEN_PROTOCOL_BY_DRIVER
903 if (EFI_ERROR (Status
)) {
910 This
->DriverBindingHandle
,
918 Test to see if Console In Device could be supported on the Controller.
920 @param This Driver Binding protocol instance pointer.
921 @param ControllerHandle Handle of device to test.
922 @param RemainingDevicePath Optional parameter use to pick a specific child
925 @retval EFI_SUCCESS This driver supports this device.
926 @retval other This driver does not support this device.
931 ConSplitterConInDriverBindingSupported (
932 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
933 IN EFI_HANDLE ControllerHandle
,
934 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
937 return ConSplitterSupported (
940 &gEfiConsoleInDeviceGuid
945 Test to see if Simple Pointer protocol could be supported on the Controller.
947 @param This Driver Binding protocol instance pointer.
948 @param ControllerHandle Handle of device to test.
949 @param RemainingDevicePath Optional parameter use to pick a specific child
952 @retval EFI_SUCCESS This driver supports this device.
953 @retval other This driver does not support this device.
958 ConSplitterSimplePointerDriverBindingSupported (
959 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
960 IN EFI_HANDLE ControllerHandle
,
961 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
964 return ConSplitterSupported (
967 &gEfiSimplePointerProtocolGuid
972 Test to see if Absolute Pointer protocol could be supported on the Controller.
974 @param This Driver Binding protocol instance pointer.
975 @param ControllerHandle Handle of device to test.
976 @param RemainingDevicePath Optional parameter use to pick a specific child
979 @retval EFI_SUCCESS This driver supports this device.
980 @retval other This driver does not support this device.
985 ConSplitterAbsolutePointerDriverBindingSupported (
986 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
987 IN EFI_HANDLE ControllerHandle
,
988 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
991 return ConSplitterSupported (
994 &gEfiAbsolutePointerProtocolGuid
1000 Test to see if Console Out Device could be supported on the Controller.
1002 @param This Driver Binding protocol instance pointer.
1003 @param ControllerHandle Handle of device to test.
1004 @param RemainingDevicePath Optional parameter use to pick a specific child
1007 @retval EFI_SUCCESS This driver supports this device.
1008 @retval other This driver does not support this device.
1013 ConSplitterConOutDriverBindingSupported (
1014 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1015 IN EFI_HANDLE ControllerHandle
,
1016 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
1019 return ConSplitterSupported (
1022 &gEfiConsoleOutDeviceGuid
1027 Test to see if Standard Error Device could be supported on the Controller.
1029 @param This Driver Binding protocol instance pointer.
1030 @param ControllerHandle Handle of device to test.
1031 @param RemainingDevicePath Optional parameter use to pick a specific child
1034 @retval EFI_SUCCESS This driver supports this device.
1035 @retval other This driver does not support this device.
1040 ConSplitterStdErrDriverBindingSupported (
1041 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1042 IN EFI_HANDLE ControllerHandle
,
1043 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
1046 return ConSplitterSupported (
1049 &gEfiStandardErrorDeviceGuid
1055 Start ConSplitter on devcie handle by opening Console Device Guid on device handle
1056 and the console virtual handle. And Get the console interface on controller handle.
1058 @param This Driver Binding protocol instance pointer.
1059 @param ControllerHandle Handle of device.
1060 @param ConSplitterVirtualHandle Console virtual Handle.
1061 @param DeviceGuid The specified Console Device, such as ConInDev,
1063 @param InterfaceGuid The specified protocol to be opened.
1064 @param Interface Protocol interface returned.
1066 @retval EFI_SUCCESS This driver supports this device.
1067 @retval other Failed to open the specified Console Device Guid
1068 or specified protocol.
1073 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1074 IN EFI_HANDLE ControllerHandle
,
1075 IN EFI_HANDLE ConSplitterVirtualHandle
,
1076 IN EFI_GUID
*DeviceGuid
,
1077 IN EFI_GUID
*InterfaceGuid
,
1078 OUT VOID
**Interface
1085 // Check to see whether the ControllerHandle has the DeviceGuid on it.
1087 Status
= gBS
->OpenProtocol (
1091 This
->DriverBindingHandle
,
1093 EFI_OPEN_PROTOCOL_BY_DRIVER
1095 if (EFI_ERROR (Status
)) {
1100 // Open the Parent Handle for the child.
1102 Status
= gBS
->OpenProtocol (
1106 This
->DriverBindingHandle
,
1107 ConSplitterVirtualHandle
,
1108 EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
1110 if (EFI_ERROR (Status
)) {
1115 // Open InterfaceGuid on the virtul handle.
1117 Status
= gBS
->OpenProtocol (
1121 This
->DriverBindingHandle
,
1122 ConSplitterVirtualHandle
,
1123 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1126 if (!EFI_ERROR (Status
)) {
1131 // close the DeviceGuid on ConSplitter VirtualHandle.
1133 gBS
->CloseProtocol (
1136 This
->DriverBindingHandle
,
1137 ConSplitterVirtualHandle
1142 // close the DeviceGuid on ControllerHandle.
1144 gBS
->CloseProtocol (
1147 This
->DriverBindingHandle
,
1156 Start Console In Consplitter on device handle.
1158 @param This Driver Binding protocol instance pointer.
1159 @param ControllerHandle Handle of device to bind driver to.
1160 @param RemainingDevicePath Optional parameter use to pick a specific child
1163 @retval EFI_SUCCESS Console In Consplitter is added to ControllerHandle.
1164 @retval other Console In Consplitter does not support this device.
1169 ConSplitterConInDriverBindingStart (
1170 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1171 IN EFI_HANDLE ControllerHandle
,
1172 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
1176 EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*TextIn
;
1177 EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*TextInEx
;
1180 // Start ConSplitter on ControllerHandle, and create the virtual
1181 // agrogated console device on first call Start for a SimpleTextIn handle.
1183 Status
= ConSplitterStart (
1186 mConIn
.VirtualHandle
,
1187 &gEfiConsoleInDeviceGuid
,
1188 &gEfiSimpleTextInProtocolGuid
,
1191 if (EFI_ERROR (Status
)) {
1196 // Add this device into Text In devices list.
1198 Status
= ConSplitterTextInAddDevice (&mConIn
, TextIn
);
1199 if (EFI_ERROR (Status
)) {
1203 Status
= gBS
->OpenProtocol (
1205 &gEfiSimpleTextInputExProtocolGuid
,
1206 (VOID
**) &TextInEx
,
1207 This
->DriverBindingHandle
,
1208 mConIn
.VirtualHandle
,
1209 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1211 if (!EFI_ERROR (Status
)) {
1213 // If Simple Text Input Ex protocol exists,
1214 // add this device into Text In Ex devices list.
1216 Status
= ConSplitterTextInExAddDevice (&mConIn
, TextInEx
);
1224 Start Simple Pointer Consplitter on device handle.
1226 @param This Driver Binding protocol instance pointer.
1227 @param ControllerHandle Handle of device to bind driver to.
1228 @param RemainingDevicePath Optional parameter use to pick a specific child
1231 @retval EFI_SUCCESS Simple Pointer Consplitter is added to ControllerHandle.
1232 @retval other Simple Pointer Consplitter does not support this device.
1237 ConSplitterSimplePointerDriverBindingStart (
1238 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1239 IN EFI_HANDLE ControllerHandle
,
1240 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
1244 EFI_SIMPLE_POINTER_PROTOCOL
*SimplePointer
;
1247 // Start ConSplitter on ControllerHandle, and create the virtual
1248 // agrogated console device on first call Start for a SimplePointer handle.
1250 Status
= ConSplitterStart (
1253 mConIn
.VirtualHandle
,
1254 &gEfiSimplePointerProtocolGuid
,
1255 &gEfiSimplePointerProtocolGuid
,
1256 (VOID
**) &SimplePointer
1258 if (EFI_ERROR (Status
)) {
1263 // Add this devcie into Simple Pointer devices list.
1265 return ConSplitterSimplePointerAddDevice (&mConIn
, SimplePointer
);
1270 Start Absolute Pointer Consplitter on device handle.
1272 @param This Driver Binding protocol instance pointer.
1273 @param ControllerHandle Handle of device to bind driver to.
1274 @param RemainingDevicePath Optional parameter use to pick a specific child
1277 @retval EFI_SUCCESS Absolute Pointer Consplitter is added to ControllerHandle.
1278 @retval other Absolute Pointer Consplitter does not support this device.
1283 ConSplitterAbsolutePointerDriverBindingStart (
1284 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1285 IN EFI_HANDLE ControllerHandle
,
1286 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
1290 EFI_ABSOLUTE_POINTER_PROTOCOL
*AbsolutePointer
;
1293 // Start ConSplitter on ControllerHandle, and create the virtual
1294 // agrogated console device on first call Start for a AbsolutePointer handle.
1296 Status
= ConSplitterStart (
1299 mConIn
.VirtualHandle
,
1300 &gEfiAbsolutePointerProtocolGuid
,
1301 &gEfiAbsolutePointerProtocolGuid
,
1302 (VOID
**) &AbsolutePointer
1305 if (EFI_ERROR (Status
)) {
1310 // Add this devcie into Absolute Pointer devices list.
1312 return ConSplitterAbsolutePointerAddDevice (&mConIn
, AbsolutePointer
);
1317 Start Console Out Consplitter on device handle.
1319 @param This Driver Binding protocol instance pointer.
1320 @param ControllerHandle Handle of device to bind driver to.
1321 @param RemainingDevicePath Optional parameter use to pick a specific child
1324 @retval EFI_SUCCESS Console Out Consplitter is added to ControllerHandle.
1325 @retval other Console Out Consplitter does not support this device.
1330 ConSplitterConOutDriverBindingStart (
1331 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1332 IN EFI_HANDLE ControllerHandle
,
1333 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
1337 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
;
1338 EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
;
1339 EFI_UGA_DRAW_PROTOCOL
*UgaDraw
;
1341 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*Info
;
1344 // Start ConSplitter on ControllerHandle, and create the virtual
1345 // agrogated console device on first call Start for a ConsoleOut handle.
1347 Status
= ConSplitterStart (
1350 mConOut
.VirtualHandle
,
1351 &gEfiConsoleOutDeviceGuid
,
1352 &gEfiSimpleTextOutProtocolGuid
,
1355 if (EFI_ERROR (Status
)) {
1359 GraphicsOutput
= NULL
;
1362 // Try to Open Graphics Output protocol
1364 Status
= gBS
->OpenProtocol (
1366 &gEfiGraphicsOutputProtocolGuid
,
1367 (VOID
**) &GraphicsOutput
,
1368 This
->DriverBindingHandle
,
1369 mConOut
.VirtualHandle
,
1370 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1373 if (EFI_ERROR (Status
) && FeaturePcdGet (PcdUgaConsumeSupport
)) {
1375 // Open UGA DRAW protocol
1379 &gEfiUgaDrawProtocolGuid
,
1381 This
->DriverBindingHandle
,
1382 mConOut
.VirtualHandle
,
1383 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1388 // When new console device is added, the new mode will be set later,
1389 // so put current mode back to init state.
1391 mConOut
.TextOutMode
.Mode
= 0xFF;
1394 // If both ConOut and StdErr incorporate the same Text Out device,
1395 // their MaxMode and QueryData should be the intersection of both.
1397 Status
= ConSplitterTextOutAddDevice (&mConOut
, TextOut
, GraphicsOutput
, UgaDraw
);
1398 ConSplitterTextOutSetAttribute (&mConOut
.TextOut
, EFI_TEXT_ATTR (EFI_LIGHTGRAY
, EFI_BLACK
));
1400 if (FeaturePcdGet (PcdConOutUgaSupport
)) {
1402 // Get the UGA mode data of ConOut from the current mode
1404 if (GraphicsOutput
!= NULL
) {
1405 Status
= GraphicsOutput
->QueryMode (GraphicsOutput
, GraphicsOutput
->Mode
->Mode
, &SizeOfInfo
, &Info
);
1406 if (EFI_ERROR (Status
)) {
1409 ASSERT ( SizeOfInfo
<= sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
));
1411 mConOut
.UgaHorizontalResolution
= Info
->HorizontalResolution
;
1412 mConOut
.UgaVerticalResolution
= Info
->VerticalResolution
;
1413 mConOut
.UgaColorDepth
= 32;
1414 mConOut
.UgaRefreshRate
= 60;
1418 } else if (UgaDraw
!= NULL
) {
1419 Status
= UgaDraw
->GetMode (
1421 &mConOut
.UgaHorizontalResolution
,
1422 &mConOut
.UgaVerticalResolution
,
1423 &mConOut
.UgaColorDepth
,
1424 &mConOut
.UgaRefreshRate
1434 Start Standard Error Consplitter on device handle.
1436 @param This Driver Binding protocol instance pointer.
1437 @param ControllerHandle Handle of device to bind driver to.
1438 @param RemainingDevicePath Optional parameter use to pick a specific child
1441 @retval EFI_SUCCESS Standard Error Consplitter is added to ControllerHandle.
1442 @retval other Standard Error Consplitter does not support this device.
1447 ConSplitterStdErrDriverBindingStart (
1448 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1449 IN EFI_HANDLE ControllerHandle
,
1450 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
1454 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
;
1457 // Start ConSplitter on ControllerHandle, and create the virtual
1458 // agrogated console device on first call Start for a StandardError handle.
1460 Status
= ConSplitterStart (
1463 mStdErr
.VirtualHandle
,
1464 &gEfiStandardErrorDeviceGuid
,
1465 &gEfiSimpleTextOutProtocolGuid
,
1468 if (EFI_ERROR (Status
)) {
1473 // When new console device is added, the new mode will be set later,
1474 // so put current mode back to init state.
1476 mStdErr
.TextOutMode
.Mode
= 0xFF;
1479 // If both ConOut and StdErr incorporate the same Text Out device,
1480 // their MaxMode and QueryData should be the intersection of both.
1482 Status
= ConSplitterTextOutAddDevice (&mStdErr
, TextOut
, NULL
, NULL
);
1483 ConSplitterTextOutSetAttribute (&mStdErr
.TextOut
, EFI_TEXT_ATTR (EFI_MAGENTA
, EFI_BLACK
));
1490 Stop ConSplitter on device handle by closing Console Device Guid on device handle
1491 and the console virtual handle.
1493 @param This Protocol instance pointer.
1494 @param ControllerHandle Handle of device.
1495 @param ConSplitterVirtualHandle Console virtual Handle.
1496 @param DeviceGuid The specified Console Device, such as ConInDev,
1498 @param InterfaceGuid The specified protocol to be opened.
1499 @param Interface Protocol interface returned.
1501 @retval EFI_SUCCESS Stop ConSplitter on ControllerHandle successfully.
1502 @retval other Failed to Stop ConSplitter on ControllerHandle.
1507 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1508 IN EFI_HANDLE ControllerHandle
,
1509 IN EFI_HANDLE ConSplitterVirtualHandle
,
1510 IN EFI_GUID
*DeviceGuid
,
1511 IN EFI_GUID
*InterfaceGuid
,
1517 Status
= gBS
->OpenProtocol (
1521 This
->DriverBindingHandle
,
1523 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1525 if (EFI_ERROR (Status
)) {
1529 // close the protocol refered.
1531 gBS
->CloseProtocol (
1534 This
->DriverBindingHandle
,
1535 ConSplitterVirtualHandle
1538 gBS
->CloseProtocol (
1541 This
->DriverBindingHandle
,
1550 Stop Console In ConSplitter on ControllerHandle by closing Console In Devcice GUID.
1552 @param This Driver Binding protocol instance pointer.
1553 @param ControllerHandle Handle of device to stop driver on
1554 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
1555 children is zero stop the entire bus driver.
1556 @param ChildHandleBuffer List of Child Handles to Stop.
1558 @retval EFI_SUCCESS This driver is removed ControllerHandle
1559 @retval other This driver was not removed from this device
1564 ConSplitterConInDriverBindingStop (
1565 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1566 IN EFI_HANDLE ControllerHandle
,
1567 IN UINTN NumberOfChildren
,
1568 IN EFI_HANDLE
*ChildHandleBuffer
1572 EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*TextIn
;
1573 EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*TextInEx
;
1575 if (NumberOfChildren
== 0) {
1579 Status
= gBS
->OpenProtocol (
1581 &gEfiSimpleTextInputExProtocolGuid
,
1582 (VOID
**) &TextInEx
,
1583 This
->DriverBindingHandle
,
1585 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1587 if (!EFI_ERROR (Status
)) {
1589 // If Simple Text Input Ex protocol exists,
1590 // remove device from Text Input Ex devices list.
1592 Status
= ConSplitterTextInExDeleteDevice (&mConIn
, TextInEx
);
1593 if (EFI_ERROR (Status
)) {
1599 // Close Simple Text In protocol on controller handle and virtual handle.
1601 Status
= ConSplitterStop (
1604 mConIn
.VirtualHandle
,
1605 &gEfiConsoleInDeviceGuid
,
1606 &gEfiSimpleTextInProtocolGuid
,
1609 if (EFI_ERROR (Status
)) {
1614 // Remove device from Text Input devices list.
1616 return ConSplitterTextInDeleteDevice (&mConIn
, TextIn
);
1621 Stop Simple Pointer protocol ConSplitter on ControllerHandle by closing
1622 Simple Pointer protocol.
1624 @param This Driver Binding protocol instance pointer.
1625 @param ControllerHandle Handle of device to stop driver on
1626 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
1627 children is zero stop the entire bus driver.
1628 @param ChildHandleBuffer List of Child Handles to Stop.
1630 @retval EFI_SUCCESS This driver is removed ControllerHandle
1631 @retval other This driver was not removed from this device
1636 ConSplitterSimplePointerDriverBindingStop (
1637 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1638 IN EFI_HANDLE ControllerHandle
,
1639 IN UINTN NumberOfChildren
,
1640 IN EFI_HANDLE
*ChildHandleBuffer
1644 EFI_SIMPLE_POINTER_PROTOCOL
*SimplePointer
;
1646 if (NumberOfChildren
== 0) {
1651 // Close Simple Pointer protocol on controller handle and virtual handle.
1653 Status
= ConSplitterStop (
1656 mConIn
.VirtualHandle
,
1657 &gEfiSimplePointerProtocolGuid
,
1658 &gEfiSimplePointerProtocolGuid
,
1659 (VOID
**) &SimplePointer
1661 if (EFI_ERROR (Status
)) {
1666 // Remove this device from Simple Pointer device list.
1668 return ConSplitterSimplePointerDeleteDevice (&mConIn
, SimplePointer
);
1673 Stop Absolute Pointer protocol ConSplitter on ControllerHandle by closing
1674 Absolute Pointer protocol.
1676 @param This Driver Binding protocol instance pointer.
1677 @param ControllerHandle Handle of device to stop driver on
1678 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
1679 children is zero stop the entire bus driver.
1680 @param ChildHandleBuffer List of Child Handles to Stop.
1682 @retval EFI_SUCCESS This driver is removed ControllerHandle
1683 @retval other This driver was not removed from this device
1688 ConSplitterAbsolutePointerDriverBindingStop (
1689 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1690 IN EFI_HANDLE ControllerHandle
,
1691 IN UINTN NumberOfChildren
,
1692 IN EFI_HANDLE
*ChildHandleBuffer
1696 EFI_ABSOLUTE_POINTER_PROTOCOL
*AbsolutePointer
;
1698 if (NumberOfChildren
== 0) {
1703 // Close Absolute Pointer protocol on controller handle and virtual handle.
1705 Status
= ConSplitterStop (
1708 mConIn
.VirtualHandle
,
1709 &gEfiAbsolutePointerProtocolGuid
,
1710 &gEfiAbsolutePointerProtocolGuid
,
1711 (VOID
**) &AbsolutePointer
1713 if (EFI_ERROR (Status
)) {
1718 // Remove this device from Absolute Pointer device list.
1720 return ConSplitterAbsolutePointerDeleteDevice (&mConIn
, AbsolutePointer
);
1725 Stop Console Out ConSplitter on device handle by closing Console Out Devcice GUID.
1727 @param This Driver Binding protocol instance pointer.
1728 @param ControllerHandle Handle of device to stop driver on
1729 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
1730 children is zero stop the entire bus driver.
1731 @param ChildHandleBuffer List of Child Handles to Stop.
1733 @retval EFI_SUCCESS This driver is removed ControllerHandle
1734 @retval other This driver was not removed from this device
1739 ConSplitterConOutDriverBindingStop (
1740 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1741 IN EFI_HANDLE ControllerHandle
,
1742 IN UINTN NumberOfChildren
,
1743 IN EFI_HANDLE
*ChildHandleBuffer
1747 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
;
1749 if (NumberOfChildren
== 0) {
1754 // Close Absolute Pointer protocol on controller handle and virtual handle.
1756 Status
= ConSplitterStop (
1759 mConOut
.VirtualHandle
,
1760 &gEfiConsoleOutDeviceGuid
,
1761 &gEfiSimpleTextOutProtocolGuid
,
1764 if (EFI_ERROR (Status
)) {
1769 // Remove this device from Text Out device list.
1771 return ConSplitterTextOutDeleteDevice (&mConOut
, TextOut
);
1776 Stop Standard Error ConSplitter on ControllerHandle by closing Standard Error GUID.
1778 @param This Driver Binding protocol instance pointer.
1779 @param ControllerHandle Handle of device to stop driver on
1780 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
1781 children is zero stop the entire bus driver.
1782 @param ChildHandleBuffer List of Child Handles to Stop.
1784 @retval EFI_SUCCESS This driver is removed ControllerHandle
1785 @retval other This driver was not removed from this device
1790 ConSplitterStdErrDriverBindingStop (
1791 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1792 IN EFI_HANDLE ControllerHandle
,
1793 IN UINTN NumberOfChildren
,
1794 IN EFI_HANDLE
*ChildHandleBuffer
1798 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
;
1800 if (NumberOfChildren
== 0) {
1805 // Close Standard Error Device on controller handle and virtual handle.
1807 Status
= ConSplitterStop (
1810 mStdErr
.VirtualHandle
,
1811 &gEfiStandardErrorDeviceGuid
,
1812 &gEfiSimpleTextOutProtocolGuid
,
1815 if (EFI_ERROR (Status
)) {
1819 // Delete this console error out device's data structures.
1821 return ConSplitterTextOutDeleteDevice (&mStdErr
, TextOut
);
1826 Take the passed in Buffer of size ElementSize and grow the buffer
1827 by CONSOLE_SPLITTER_ALLOC_UNIT * ElementSize bytes.
1828 Copy the current data in Buffer to the new version of Buffer and
1829 free the old version of buffer.
1831 @param ElementSize Size of element in array.
1832 @param Count Current number of elements in array.
1833 @param Buffer Bigger version of passed in Buffer with all the
1836 @retval EFI_SUCCESS Buffer size has grown.
1837 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
1841 ConSplitterGrowBuffer (
1842 IN UINTN ElementSize
,
1843 IN OUT UINTN
*Count
,
1844 IN OUT VOID
**Buffer
1850 // grow the buffer to new buffer size,
1851 // copy the old buffer's content to the new-size buffer,
1852 // then free the old buffer.
1854 Ptr
= ReallocatePool (
1855 ElementSize
* (*Count
),
1856 ElementSize
* ((*Count
) + CONSOLE_SPLITTER_ALLOC_UNIT
),
1860 return EFI_OUT_OF_RESOURCES
;
1862 *Count
+= CONSOLE_SPLITTER_ALLOC_UNIT
;
1869 Add Text Input Device in Consplitter Text Input list.
1871 @param Private Text In Splitter pointer.
1872 @param TextIn Simple Text Input protocol pointer.
1874 @retval EFI_SUCCESS Text Input Device added successfully.
1875 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
1879 ConSplitterTextInAddDevice (
1880 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
1881 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*TextIn
1887 // If the Text In List is full, enlarge it by calling ConSplitterGrowBuffer().
1889 if (Private
->CurrentNumberOfConsoles
>= Private
->TextInListCount
) {
1890 Status
= ConSplitterGrowBuffer (
1891 sizeof (EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*),
1892 &Private
->TextInListCount
,
1893 (VOID
**) &Private
->TextInList
1895 if (EFI_ERROR (Status
)) {
1896 return EFI_OUT_OF_RESOURCES
;
1900 // Add the new text-in device data structure into the Text In List.
1902 Private
->TextInList
[Private
->CurrentNumberOfConsoles
] = TextIn
;
1903 Private
->CurrentNumberOfConsoles
++;
1906 // Extra CheckEvent added to reduce the double CheckEvent().
1908 gBS
->CheckEvent (TextIn
->WaitForKey
);
1915 Remove Text Input Device from Consplitter Text Input list.
1917 @param Private Text In Splitter pointer.
1918 @param TextIn Simple Text protocol pointer.
1920 @retval EFI_SUCCESS Simple Text Device removed successfully.
1921 @retval EFI_NOT_FOUND No Simple Text Device found.
1925 ConSplitterTextInDeleteDevice (
1926 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
1927 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*TextIn
1932 // Remove the specified text-in device data structure from the Text In List,
1933 // and rearrange the remaining data structures in the Text In List.
1935 for (Index
= 0; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
1936 if (Private
->TextInList
[Index
] == TextIn
) {
1937 for (; Index
< Private
->CurrentNumberOfConsoles
- 1; Index
++) {
1938 Private
->TextInList
[Index
] = Private
->TextInList
[Index
+ 1];
1941 Private
->CurrentNumberOfConsoles
--;
1946 return EFI_NOT_FOUND
;
1950 Add Text Input Ex Device in Consplitter Text Input Ex list.
1952 @param Private Text In Splitter pointer.
1953 @param TextInEx Simple Text Input Ex Input protocol pointer.
1955 @retval EFI_SUCCESS Text Input Ex Device added successfully.
1956 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
1960 ConSplitterTextInExAddDevice (
1961 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
1962 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*TextInEx
1967 TEXT_IN_EX_SPLITTER_NOTIFY
*CurrentNotify
;
1968 UINTN TextInExListCount
;
1971 // Enlarge the NotifyHandleList and the TextInExList
1973 if (Private
->CurrentNumberOfExConsoles
>= Private
->TextInExListCount
) {
1974 for (Link
= Private
->NotifyList
.ForwardLink
; Link
!= &Private
->NotifyList
; Link
= Link
->ForwardLink
) {
1975 CurrentNotify
= TEXT_IN_EX_SPLITTER_NOTIFY_FROM_THIS (Link
);
1976 TextInExListCount
= Private
->TextInExListCount
;
1978 Status
= ConSplitterGrowBuffer (
1979 sizeof (EFI_HANDLE
),
1981 (VOID
**) &CurrentNotify
->NotifyHandleList
1983 if (EFI_ERROR (Status
)) {
1984 return EFI_OUT_OF_RESOURCES
;
1988 TextInExListCount
= Private
->TextInExListCount
;
1989 Status
= ConSplitterGrowBuffer (
1990 sizeof (EFI_KEY_DATA
),
1992 (VOID
**) &Private
->KeyQueue
1994 if (EFI_ERROR (Status
)) {
1995 return EFI_OUT_OF_RESOURCES
;
1998 Status
= ConSplitterGrowBuffer (
1999 sizeof (EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*),
2000 &Private
->TextInExListCount
,
2001 (VOID
**) &Private
->TextInExList
2003 if (EFI_ERROR (Status
)) {
2004 return EFI_OUT_OF_RESOURCES
;
2009 // Register the key notify in the new text-in device
2011 for (Link
= Private
->NotifyList
.ForwardLink
; Link
!= &Private
->NotifyList
; Link
= Link
->ForwardLink
) {
2012 CurrentNotify
= TEXT_IN_EX_SPLITTER_NOTIFY_FROM_THIS (Link
);
2013 Status
= TextInEx
->RegisterKeyNotify (
2015 &CurrentNotify
->KeyData
,
2016 CurrentNotify
->KeyNotificationFn
,
2017 &CurrentNotify
->NotifyHandleList
[Private
->CurrentNumberOfExConsoles
]
2019 if (EFI_ERROR (Status
)) {
2020 for (Link
= Link
->BackLink
; Link
!= &Private
->NotifyList
; Link
= Link
->BackLink
) {
2021 CurrentNotify
= TEXT_IN_EX_SPLITTER_NOTIFY_FROM_THIS (Link
);
2022 TextInEx
->UnregisterKeyNotify (
2024 CurrentNotify
->NotifyHandleList
[Private
->CurrentNumberOfExConsoles
]
2032 // Add the new text-in device data structure into the Text Input Ex List.
2034 Private
->TextInExList
[Private
->CurrentNumberOfExConsoles
] = TextInEx
;
2035 Private
->CurrentNumberOfExConsoles
++;
2038 // Sync current toggle state to this new console input device.
2040 TextInEx
->SetState (TextInEx
, &Private
->PhysicalKeyToggleState
);
2043 // Extra CheckEvent added to reduce the double CheckEvent().
2045 gBS
->CheckEvent (TextInEx
->WaitForKeyEx
);
2051 Remove Text Ex Device from Consplitter Text Input Ex list.
2053 @param Private Text In Splitter pointer.
2054 @param TextInEx Simple Text Ex protocol pointer.
2056 @retval EFI_SUCCESS Simple Text Input Ex Device removed successfully.
2057 @retval EFI_NOT_FOUND No Simple Text Input Ex Device found.
2061 ConSplitterTextInExDeleteDevice (
2062 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
2063 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*TextInEx
2068 // Remove the specified text-in device data structure from the Text Input Ex List,
2069 // and rearrange the remaining data structures in the Text In List.
2071 for (Index
= 0; Index
< Private
->CurrentNumberOfExConsoles
; Index
++) {
2072 if (Private
->TextInExList
[Index
] == TextInEx
) {
2073 for (; Index
< Private
->CurrentNumberOfExConsoles
- 1; Index
++) {
2074 Private
->TextInExList
[Index
] = Private
->TextInExList
[Index
+ 1];
2077 Private
->CurrentNumberOfExConsoles
--;
2082 return EFI_NOT_FOUND
;
2087 Add Simple Pointer Device in Consplitter Simple Pointer list.
2089 @param Private Text In Splitter pointer.
2090 @param SimplePointer Simple Pointer protocol pointer.
2092 @retval EFI_SUCCESS Simple Pointer Device added successfully.
2093 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
2097 ConSplitterSimplePointerAddDevice (
2098 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
2099 IN EFI_SIMPLE_POINTER_PROTOCOL
*SimplePointer
2105 // If the Simple Pointer List is full, enlarge it by calling ConSplitterGrowBuffer().
2107 if (Private
->CurrentNumberOfPointers
>= Private
->PointerListCount
) {
2108 Status
= ConSplitterGrowBuffer (
2109 sizeof (EFI_SIMPLE_POINTER_PROTOCOL
*),
2110 &Private
->PointerListCount
,
2111 (VOID
**) &Private
->PointerList
2113 if (EFI_ERROR (Status
)) {
2114 return EFI_OUT_OF_RESOURCES
;
2118 // Add the new text-in device data structure into the Simple Pointer List.
2120 Private
->PointerList
[Private
->CurrentNumberOfPointers
] = SimplePointer
;
2121 Private
->CurrentNumberOfPointers
++;
2128 Remove Simple Pointer Device from Consplitter Simple Pointer list.
2130 @param Private Text In Splitter pointer.
2131 @param SimplePointer Simple Pointer protocol pointer.
2133 @retval EFI_SUCCESS Simple Pointer Device removed successfully.
2134 @retval EFI_NOT_FOUND No Simple Pointer Device found.
2138 ConSplitterSimplePointerDeleteDevice (
2139 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
2140 IN EFI_SIMPLE_POINTER_PROTOCOL
*SimplePointer
2145 // Remove the specified text-in device data structure from the Simple Pointer List,
2146 // and rearrange the remaining data structures in the Text In List.
2148 for (Index
= 0; Index
< Private
->CurrentNumberOfPointers
; Index
++) {
2149 if (Private
->PointerList
[Index
] == SimplePointer
) {
2150 for (; Index
< Private
->CurrentNumberOfPointers
- 1; Index
++) {
2151 Private
->PointerList
[Index
] = Private
->PointerList
[Index
+ 1];
2154 Private
->CurrentNumberOfPointers
--;
2159 return EFI_NOT_FOUND
;
2164 Add Absolute Pointer Device in Consplitter Absolute Pointer list.
2166 @param Private Text In Splitter pointer.
2167 @param AbsolutePointer Absolute Pointer protocol pointer.
2169 @retval EFI_SUCCESS Absolute Pointer Device added successfully.
2170 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
2174 ConSplitterAbsolutePointerAddDevice (
2175 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
2176 IN EFI_ABSOLUTE_POINTER_PROTOCOL
*AbsolutePointer
2182 // If the Absolute Pointer List is full, enlarge it by calling ConSplitterGrowBuffer().
2184 if (Private
->CurrentNumberOfAbsolutePointers
>= Private
->AbsolutePointerListCount
) {
2185 Status
= ConSplitterGrowBuffer (
2186 sizeof (EFI_ABSOLUTE_POINTER_PROTOCOL
*),
2187 &Private
->AbsolutePointerListCount
,
2188 (VOID
**) &Private
->AbsolutePointerList
2190 if (EFI_ERROR (Status
)) {
2191 return EFI_OUT_OF_RESOURCES
;
2195 // Add the new text-in device data structure into the Absolute Pointer List.
2197 Private
->AbsolutePointerList
[Private
->CurrentNumberOfAbsolutePointers
] = AbsolutePointer
;
2198 Private
->CurrentNumberOfAbsolutePointers
++;
2205 Remove Absolute Pointer Device from Consplitter Absolute Pointer list.
2207 @param Private Text In Splitter pointer.
2208 @param AbsolutePointer Absolute Pointer protocol pointer.
2210 @retval EFI_SUCCESS Absolute Pointer Device removed successfully.
2211 @retval EFI_NOT_FOUND No Absolute Pointer Device found.
2215 ConSplitterAbsolutePointerDeleteDevice (
2216 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
2217 IN EFI_ABSOLUTE_POINTER_PROTOCOL
*AbsolutePointer
2222 // Remove the specified text-in device data structure from the Absolute Pointer List,
2223 // and rearrange the remaining data structures from the Absolute Pointer List.
2225 for (Index
= 0; Index
< Private
->CurrentNumberOfAbsolutePointers
; Index
++) {
2226 if (Private
->AbsolutePointerList
[Index
] == AbsolutePointer
) {
2227 for (; Index
< Private
->CurrentNumberOfAbsolutePointers
- 1; Index
++) {
2228 Private
->AbsolutePointerList
[Index
] = Private
->AbsolutePointerList
[Index
+ 1];
2231 Private
->CurrentNumberOfAbsolutePointers
--;
2236 return EFI_NOT_FOUND
;
2240 Reallocate Text Out mode map.
2242 Allocate new buffer and copy original buffer into the new buffer.
2244 @param Private Consplitter Text Out pointer.
2246 @retval EFI_SUCCESS Buffer size has grown
2247 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
2251 ConSplitterGrowMapTable (
2252 IN TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
2258 INT32
*TextOutModeMap
;
2259 INT32
*OldTextOutModeMap
;
2265 NewSize
= Private
->TextOutListCount
* sizeof (INT32
);
2266 OldTextOutModeMap
= Private
->TextOutModeMap
;
2267 TotalSize
= NewSize
* (Private
->TextOutQueryDataCount
);
2270 // Allocate new buffer for Text Out List.
2272 TextOutModeMap
= AllocatePool (TotalSize
);
2273 if (TextOutModeMap
== NULL
) {
2274 return EFI_OUT_OF_RESOURCES
;
2277 SetMem (TextOutModeMap
, TotalSize
, 0xFF);
2278 Private
->TextOutModeMap
= TextOutModeMap
;
2281 // If TextOutList has been enlarged, need to realloc the mode map table
2282 // The mode map table is regarded as a two dimension array.
2285 // 0 ---------> TextOutListCount ----> TextOutListCount
2286 // | -------------------------------------------
2293 // -------------------------------------------
2296 if (OldTextOutModeMap
!= NULL
) {
2298 Size
= Private
->CurrentNumberOfConsoles
* sizeof (INT32
);
2300 SrcAddress
= OldTextOutModeMap
;
2301 NewStepSize
= NewSize
/ sizeof(INT32
);
2302 // If Private->CurrentNumberOfConsoles is not zero and OldTextOutModeMap
2303 // is not NULL, it indicates that the original TextOutModeMap is not enough
2304 // for the new console devices and has been enlarged by CONSOLE_SPLITTER_ALLOC_UNIT columns.
2306 OldStepSize
= NewStepSize
- CONSOLE_SPLITTER_ALLOC_UNIT
;
2309 // Copy the old data to the new one
2311 while (Index
< Private
->TextOutMode
.MaxMode
) {
2312 CopyMem (TextOutModeMap
, SrcAddress
, Size
);
2314 // Go to next row of new TextOutModeMap.
2316 TextOutModeMap
+= NewStepSize
;
2318 // Go to next row of old TextOutModeMap.
2320 SrcAddress
+= OldStepSize
;
2324 // Free the old buffer
2326 FreePool (OldTextOutModeMap
);
2334 Add new device's output mode to console splitter's mode list.
2336 @param Private Text Out Splitter pointer
2337 @param TextOut Simple Text Output protocol pointer.
2339 @retval EFI_SUCCESS Device added successfully.
2340 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
2344 ConSplitterAddOutputMode (
2345 IN TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
,
2346 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
2354 MaxMode
= TextOut
->Mode
->MaxMode
;
2355 Private
->TextOutMode
.MaxMode
= MaxMode
;
2358 // Grow the buffer if query data buffer is not large enough to
2359 // hold all the mode supported by the first console.
2361 while (MaxMode
> (INT32
) Private
->TextOutQueryDataCount
) {
2362 Status
= ConSplitterGrowBuffer (
2363 sizeof (TEXT_OUT_SPLITTER_QUERY_DATA
),
2364 &Private
->TextOutQueryDataCount
,
2365 (VOID
**) &Private
->TextOutQueryData
2367 if (EFI_ERROR (Status
)) {
2368 return EFI_OUT_OF_RESOURCES
;
2372 // Allocate buffer for the output mode map
2374 Status
= ConSplitterGrowMapTable (Private
);
2375 if (EFI_ERROR (Status
)) {
2376 return EFI_OUT_OF_RESOURCES
;
2379 // As the first textout device, directly add the mode in to QueryData
2380 // and at the same time record the mapping between QueryData and TextOut.
2384 while (Mode
< MaxMode
) {
2385 Status
= TextOut
->QueryMode (
2388 &Private
->TextOutQueryData
[Mode
].Columns
,
2389 &Private
->TextOutQueryData
[Mode
].Rows
2392 // If mode 1 (80x50) is not supported, make sure mode 1 in TextOutQueryData
2395 if ((EFI_ERROR(Status
)) && (Mode
== 1)) {
2396 Private
->TextOutQueryData
[Mode
].Columns
= 0;
2397 Private
->TextOutQueryData
[Mode
].Rows
= 0;
2399 Private
->TextOutModeMap
[Index
] = Mode
;
2401 Index
+= Private
->TextOutListCount
;
2408 Reconstruct TextOutModeMap to get intersection of modes.
2410 This routine reconstruct TextOutModeMap to get the intersection
2411 of modes for all console out devices. Because EFI/UEFI spec require
2412 mode 0 is 80x25, mode 1 is 80x50, this routine will not check the
2413 intersection for mode 0 and mode 1.
2415 @param TextOutModeMap Current text out mode map, begin with the mode 80x25
2416 @param NewlyAddedMap New text out mode map, begin with the mode 80x25
2417 @param MapStepSize Mode step size for one console device
2418 @param NewMapStepSize New Mode step size for one console device
2419 @param MaxMode IN: Current max text mode, OUT: Updated max text mode.
2420 @param CurrentMode IN: Current text mode, OUT: Updated current text mode.
2424 ConSplitterGetIntersection (
2425 IN INT32
*TextOutModeMap
,
2426 IN INT32
*NewlyAddedMap
,
2427 IN UINTN MapStepSize
,
2428 IN UINTN NewMapStepSize
,
2429 IN OUT INT32
*MaxMode
,
2430 IN OUT INT32
*CurrentMode
2434 INT32
*CurrentMapEntry
;
2435 INT32
*NextMapEntry
;
2437 INT32 CurrentMaxMode
;
2441 // According to EFI/UEFI spec, mode 0 and mode 1 have been reserved
2442 // for 80x25 and 80x50 in Simple Text Out protocol, so don't make intersection
2443 // for mode 0 and mode 1, mode number starts from 2.
2446 CurrentMapEntry
= &TextOutModeMap
[MapStepSize
* 2];
2447 NextMapEntry
= CurrentMapEntry
;
2448 NewMapEntry
= &NewlyAddedMap
[NewMapStepSize
* 2];
2450 CurrentMaxMode
= *MaxMode
;
2451 Mode
= *CurrentMode
;
2453 while (Index
< CurrentMaxMode
) {
2454 if (*NewMapEntry
== -1) {
2456 // This mode is not supported any more. Remove it. Special care
2457 // must be taken as this remove will also affect current mode;
2459 if (Index
== *CurrentMode
) {
2461 } else if (Index
< *CurrentMode
) {
2466 if (CurrentMapEntry
!= NextMapEntry
) {
2467 CopyMem (NextMapEntry
, CurrentMapEntry
, MapStepSize
* sizeof (INT32
));
2470 NextMapEntry
+= MapStepSize
;
2473 CurrentMapEntry
+= MapStepSize
;
2474 NewMapEntry
+= NewMapStepSize
;
2478 *CurrentMode
= Mode
;
2484 Sync the device's output mode to console splitter's mode list.
2486 @param Private Text Out Splitter pointer.
2487 @param TextOut Simple Text Output protocol pointer.
2491 ConSplitterSyncOutputMode (
2492 IN TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
,
2493 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
2496 INT32 CurrentMaxMode
;
2499 INT32
*TextOutModeMap
;
2502 TEXT_OUT_SPLITTER_QUERY_DATA
*TextOutQueryData
;
2509 // Must make sure that current mode won't change even if mode number changes
2511 CurrentMaxMode
= Private
->TextOutMode
.MaxMode
;
2512 TextOutModeMap
= Private
->TextOutModeMap
;
2513 StepSize
= Private
->TextOutListCount
;
2514 TextOutQueryData
= Private
->TextOutQueryData
;
2517 // Query all the mode that the newly added TextOut supports
2520 MapTable
= TextOutModeMap
+ Private
->CurrentNumberOfConsoles
;
2521 while (Mode
< TextOut
->Mode
->MaxMode
) {
2522 Status
= TextOut
->QueryMode (TextOut
, Mode
, &Columns
, &Rows
);
2524 if (EFI_ERROR(Status
)) {
2527 // If mode 1 (80x50) is not supported, make sure mode 1 in TextOutQueryData
2530 MapTable
[StepSize
] = Mode
;
2531 TextOutQueryData
[Mode
].Columns
= 0;
2532 TextOutQueryData
[Mode
].Rows
= 0;
2538 // Search the intersection map and QueryData database to see if they intersects
2541 while (Index
< CurrentMaxMode
) {
2542 QueryMode
= *(TextOutModeMap
+ Index
* StepSize
);
2543 if ((TextOutQueryData
[QueryMode
].Rows
== Rows
) && (TextOutQueryData
[QueryMode
].Columns
== Columns
)) {
2544 MapTable
[Index
* StepSize
] = Mode
;
2552 // Now search the TextOutModeMap table to find the intersection of supported
2553 // mode between ConSplitter and the newly added device.
2555 ConSplitterGetIntersection (
2560 &Private
->TextOutMode
.MaxMode
,
2561 &Private
->TextOutMode
.Mode
2569 Sync output device between ConOut and StdErr output.
2571 @retval EFI_SUCCESS Sync implemented successfully.
2572 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
2576 ConSplitterGetIntersectionBetweenConOutAndStrErr (
2580 UINTN ConOutNumOfConsoles
;
2581 UINTN StdErrNumOfConsoles
;
2582 TEXT_OUT_AND_GOP_DATA
*ConOutTextOutList
;
2583 TEXT_OUT_AND_GOP_DATA
*StdErrTextOutList
;
2587 UINTN ConOutColumns
;
2589 UINTN StdErrColumns
;
2590 INT32 ConOutMaxMode
;
2591 INT32 StdErrMaxMode
;
2596 INT32
*ConOutModeMap
;
2597 INT32
*StdErrModeMap
;
2598 INT32
*ConOutMapTable
;
2599 INT32
*StdErrMapTable
;
2600 TEXT_OUT_SPLITTER_QUERY_DATA
*ConOutQueryData
;
2601 TEXT_OUT_SPLITTER_QUERY_DATA
*StdErrQueryData
;
2602 UINTN ConOutStepSize
;
2603 UINTN StdErrStepSize
;
2604 BOOLEAN FoundTheSameTextOut
;
2605 UINTN ConOutMapTableSize
;
2606 UINTN StdErrMapTableSize
;
2608 ConOutNumOfConsoles
= mConOut
.CurrentNumberOfConsoles
;
2609 StdErrNumOfConsoles
= mStdErr
.CurrentNumberOfConsoles
;
2610 ConOutTextOutList
= mConOut
.TextOutList
;
2611 StdErrTextOutList
= mStdErr
.TextOutList
;
2614 FoundTheSameTextOut
= FALSE
;
2615 while ((Indexi
< ConOutNumOfConsoles
) && (!FoundTheSameTextOut
)) {
2617 while (Indexj
< StdErrNumOfConsoles
) {
2618 if (ConOutTextOutList
->TextOut
== StdErrTextOutList
->TextOut
) {
2619 FoundTheSameTextOut
= TRUE
;
2624 StdErrTextOutList
++;
2628 ConOutTextOutList
++;
2631 if (!FoundTheSameTextOut
) {
2635 // Must make sure that current mode won't change even if mode number changes
2637 ConOutMaxMode
= mConOut
.TextOutMode
.MaxMode
;
2638 ConOutModeMap
= mConOut
.TextOutModeMap
;
2639 ConOutStepSize
= mConOut
.TextOutListCount
;
2640 ConOutQueryData
= mConOut
.TextOutQueryData
;
2642 StdErrMaxMode
= mStdErr
.TextOutMode
.MaxMode
;
2643 StdErrModeMap
= mStdErr
.TextOutModeMap
;
2644 StdErrStepSize
= mStdErr
.TextOutListCount
;
2645 StdErrQueryData
= mStdErr
.TextOutQueryData
;
2648 // Allocate the map table and set the map table's index to -1.
2650 ConOutMapTableSize
= ConOutMaxMode
* sizeof (INT32
);
2651 ConOutMapTable
= AllocateZeroPool (ConOutMapTableSize
);
2652 if (ConOutMapTable
== NULL
) {
2653 return EFI_OUT_OF_RESOURCES
;
2656 SetMem (ConOutMapTable
, ConOutMapTableSize
, 0xFF);
2658 StdErrMapTableSize
= StdErrMaxMode
* sizeof (INT32
);
2659 StdErrMapTable
= AllocateZeroPool (StdErrMapTableSize
);
2660 if (StdErrMapTable
== NULL
) {
2661 return EFI_OUT_OF_RESOURCES
;
2664 SetMem (StdErrMapTable
, StdErrMapTableSize
, 0xFF);
2667 // Find the intersection of the two set of modes. If they actually intersect, the
2668 // corresponding entry in the map table is set to 1.
2671 while (Mode
< ConOutMaxMode
) {
2673 // Search the intersection map and QueryData database to see if they intersect
2676 ConOutMode
= *(ConOutModeMap
+ Mode
* ConOutStepSize
);
2677 ConOutRows
= ConOutQueryData
[ConOutMode
].Rows
;
2678 ConOutColumns
= ConOutQueryData
[ConOutMode
].Columns
;
2679 while (Index
< StdErrMaxMode
) {
2680 StdErrMode
= *(StdErrModeMap
+ Index
* StdErrStepSize
);
2681 StdErrRows
= StdErrQueryData
[StdErrMode
].Rows
;
2682 StdErrColumns
= StdErrQueryData
[StdErrMode
].Columns
;
2683 if ((StdErrRows
== ConOutRows
) && (StdErrColumns
== ConOutColumns
)) {
2684 ConOutMapTable
[Mode
] = 1;
2685 StdErrMapTable
[Index
] = 1;
2695 // Now search the TextOutModeMap table to find the intersection of supported
2696 // mode between ConSplitter and the newly added device.
2698 ConSplitterGetIntersection (
2701 mConOut
.TextOutListCount
,
2703 &(mConOut
.TextOutMode
.MaxMode
),
2704 &(mConOut
.TextOutMode
.Mode
)
2707 if (mConOut
.TextOutMode
.Mode
< 0) {
2708 mConOut
.TextOut
.SetMode (&(mConOut
.TextOut
), 0);
2711 ConSplitterGetIntersection (
2714 mStdErr
.TextOutListCount
,
2716 &(mStdErr
.TextOutMode
.MaxMode
),
2717 &(mStdErr
.TextOutMode
.Mode
)
2720 if (mStdErr
.TextOutMode
.Mode
< 0) {
2721 mStdErr
.TextOut
.SetMode (&(mStdErr
.TextOut
), 0);
2724 FreePool (ConOutMapTable
);
2725 FreePool (StdErrMapTable
);
2732 Add Grahpics Output modes into Consplitter Text Out list.
2734 @param Private Text Out Splitter pointer.
2735 @param GraphicsOutput Graphics Output protocol pointer.
2736 @param UgaDraw UGA Draw protocol pointer.
2738 @retval EFI_SUCCESS Output mode added successfully.
2739 @retval other Failed to add output mode.
2743 ConSplitterAddGraphicsOutputMode (
2744 IN TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
,
2745 IN EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
,
2746 IN EFI_UGA_DRAW_PROTOCOL
*UgaDraw
2752 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*Mode
;
2754 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*Info
;
2755 EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE
*CurrentGraphicsOutputMode
;
2756 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*ModeBuffer
;
2757 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*MatchedMode
;
2760 BOOLEAN AlreadyExist
;
2761 UINT32 UgaHorizontalResolution
;
2762 UINT32 UgaVerticalResolution
;
2763 UINT32 UgaColorDepth
;
2764 UINT32 UgaRefreshRate
;
2766 ASSERT (GraphicsOutput
!= NULL
|| UgaDraw
!= NULL
);
2768 CurrentGraphicsOutputMode
= Private
->GraphicsOutput
.Mode
;
2772 Status
= EFI_SUCCESS
;
2774 if (Private
->CurrentNumberOfUgaDraw
!= 0) {
2776 // If any UGA device has already been added, then there is no need to
2777 // calculate intersection of display mode of different GOP/UGA device,
2778 // since only one display mode will be exported (i.e. user-defined mode)
2783 if (GraphicsOutput
!= NULL
) {
2784 if (Private
->CurrentNumberOfGraphicsOutput
== 0) {
2786 // This is the first Graphics Output device added
2788 CurrentGraphicsOutputMode
->MaxMode
= GraphicsOutput
->Mode
->MaxMode
;
2789 CurrentGraphicsOutputMode
->Mode
= GraphicsOutput
->Mode
->Mode
;
2790 CopyMem (CurrentGraphicsOutputMode
->Info
, GraphicsOutput
->Mode
->Info
, GraphicsOutput
->Mode
->SizeOfInfo
);
2791 CurrentGraphicsOutputMode
->SizeOfInfo
= GraphicsOutput
->Mode
->SizeOfInfo
;
2792 CurrentGraphicsOutputMode
->FrameBufferBase
= GraphicsOutput
->Mode
->FrameBufferBase
;
2793 CurrentGraphicsOutputMode
->FrameBufferSize
= GraphicsOutput
->Mode
->FrameBufferSize
;
2796 // Allocate resource for the private mode buffer
2798 ModeBuffer
= AllocatePool (sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
) * GraphicsOutput
->Mode
->MaxMode
);
2799 if (ModeBuffer
== NULL
) {
2800 return EFI_OUT_OF_RESOURCES
;
2802 FreePool (Private
->GraphicsOutputModeBuffer
);
2803 Private
->GraphicsOutputModeBuffer
= ModeBuffer
;
2806 // Store all supported display modes to the private mode buffer
2809 for (Index
= 0; Index
< GraphicsOutput
->Mode
->MaxMode
; Index
++) {
2811 // The Info buffer would be allocated by callee
2813 Status
= GraphicsOutput
->QueryMode (GraphicsOutput
, (UINT32
) Index
, &SizeOfInfo
, &Info
);
2814 if (EFI_ERROR (Status
)) {
2817 ASSERT ( SizeOfInfo
<= sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
));
2818 CopyMem (Mode
, Info
, SizeOfInfo
);
2824 // Check intersection of display mode
2826 ModeBuffer
= AllocatePool (sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
) * CurrentGraphicsOutputMode
->MaxMode
);
2827 if (ModeBuffer
== NULL
) {
2828 return EFI_OUT_OF_RESOURCES
;
2831 MatchedMode
= ModeBuffer
;
2832 Mode
= &Private
->GraphicsOutputModeBuffer
[0];
2833 for (Index
= 0; Index
< CurrentGraphicsOutputMode
->MaxMode
; Index
++) {
2836 for (NumberIndex
= 0; NumberIndex
< GraphicsOutput
->Mode
->MaxMode
; NumberIndex
++) {
2838 // The Info buffer would be allocated by callee
2840 Status
= GraphicsOutput
->QueryMode (GraphicsOutput
, (UINT32
) NumberIndex
, &SizeOfInfo
, &Info
);
2841 if (EFI_ERROR (Status
)) {
2844 if ((Info
->HorizontalResolution
== Mode
->HorizontalResolution
) &&
2845 (Info
->VerticalResolution
== Mode
->VerticalResolution
)) {
2847 // If GOP device supports one mode in current mode buffer,
2848 // it will be added into matched mode buffer
2858 AlreadyExist
= FALSE
;
2861 // Check if GOP mode has been in the mode buffer, ModeBuffer = MatchedMode at begin.
2863 for (Info
= ModeBuffer
; Info
< MatchedMode
; Info
++) {
2864 if ((Info
->HorizontalResolution
== Mode
->HorizontalResolution
) &&
2865 (Info
->VerticalResolution
== Mode
->VerticalResolution
)) {
2866 AlreadyExist
= TRUE
;
2871 if (!AlreadyExist
) {
2872 CopyMem (MatchedMode
, Mode
, sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
));
2875 // Physical frame buffer is no longer available, change PixelFormat to PixelBltOnly
2877 MatchedMode
->Version
= 0;
2878 MatchedMode
->PixelFormat
= PixelBltOnly
;
2879 ZeroMem (&MatchedMode
->PixelInformation
, sizeof (EFI_PIXEL_BITMASK
));
2889 // Drop the old mode buffer, assign it to a new one
2891 FreePool (Private
->GraphicsOutputModeBuffer
);
2892 Private
->GraphicsOutputModeBuffer
= ModeBuffer
;
2895 // Physical frame buffer is no longer available when there are more than one physical GOP devices
2897 CurrentGraphicsOutputMode
->MaxMode
= (UINT32
) (((UINTN
) MatchedMode
- (UINTN
) ModeBuffer
) / sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
));
2898 CurrentGraphicsOutputMode
->Info
->PixelFormat
= PixelBltOnly
;
2899 ZeroMem (&CurrentGraphicsOutputMode
->Info
->PixelInformation
, sizeof (EFI_PIXEL_BITMASK
));
2900 CurrentGraphicsOutputMode
->SizeOfInfo
= sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
);
2901 CurrentGraphicsOutputMode
->FrameBufferBase
= (EFI_PHYSICAL_ADDRESS
) (UINTN
) NULL
;
2902 CurrentGraphicsOutputMode
->FrameBufferSize
= 0;
2906 // Graphics console driver can ensure the same mode for all GOP devices
2908 for (Index
= 0; Index
< CurrentGraphicsOutputMode
->MaxMode
; Index
++) {
2909 Mode
= &Private
->GraphicsOutputModeBuffer
[Index
];
2910 if ((Mode
->HorizontalResolution
== GraphicsOutput
->Mode
->Info
->HorizontalResolution
) &&
2911 (Mode
->VerticalResolution
== GraphicsOutput
->Mode
->Info
->VerticalResolution
)) {
2912 CurrentIndex
= Index
;
2916 if (Index
>= CurrentGraphicsOutputMode
->MaxMode
) {
2918 // if user defined mode is not found, set to default mode 800x600
2920 for (Index
= 0; Index
< CurrentGraphicsOutputMode
->MaxMode
; Index
++) {
2921 Mode
= &Private
->GraphicsOutputModeBuffer
[Index
];
2922 if ((Mode
->HorizontalResolution
== 800) && (Mode
->VerticalResolution
== 600)) {
2923 CurrentIndex
= Index
;
2928 } else if (UgaDraw
!= NULL
) {
2930 // Graphics console driver can ensure the same mode for all GOP devices
2931 // so we can get the current mode from this video device
2935 &UgaHorizontalResolution
,
2936 &UgaVerticalResolution
,
2941 CurrentGraphicsOutputMode
->MaxMode
= 1;
2942 Info
= CurrentGraphicsOutputMode
->Info
;
2944 Info
->HorizontalResolution
= UgaHorizontalResolution
;
2945 Info
->VerticalResolution
= UgaVerticalResolution
;
2946 Info
->PixelFormat
= PixelBltOnly
;
2947 Info
->PixelsPerScanLine
= UgaHorizontalResolution
;
2948 CurrentGraphicsOutputMode
->SizeOfInfo
= sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
);
2949 CurrentGraphicsOutputMode
->FrameBufferBase
= (EFI_PHYSICAL_ADDRESS
) (UINTN
) NULL
;
2950 CurrentGraphicsOutputMode
->FrameBufferSize
= 0;
2953 // Update the private mode buffer
2955 CopyMem (&Private
->GraphicsOutputModeBuffer
[0], Info
, sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
));
2958 // Only mode 0 is available to be set
2965 if (GraphicsOutput
!= NULL
) {
2966 Private
->CurrentNumberOfGraphicsOutput
++;
2968 if (UgaDraw
!= NULL
) {
2969 Private
->CurrentNumberOfUgaDraw
++;
2973 // Force GraphicsOutput mode to be set,
2976 Mode
= &Private
->GraphicsOutputModeBuffer
[CurrentIndex
];
2977 if ((GraphicsOutput
!= NULL
) &&
2978 (Mode
->HorizontalResolution
== CurrentGraphicsOutputMode
->Info
->HorizontalResolution
) &&
2979 (Mode
->VerticalResolution
== CurrentGraphicsOutputMode
->Info
->VerticalResolution
)) {
2980 CurrentGraphicsOutputMode
->Mode
= (UINT32
) CurrentIndex
;
2981 if ((Mode
->HorizontalResolution
!= GraphicsOutput
->Mode
->Info
->HorizontalResolution
) ||
2982 (Mode
->VerticalResolution
!= GraphicsOutput
->Mode
->Info
->VerticalResolution
)) {
2984 // If all existing video device has been set to common mode, only set new GOP device to
2987 for (NumberIndex
= 0; NumberIndex
< GraphicsOutput
->Mode
->MaxMode
; NumberIndex
++) {
2988 Status
= GraphicsOutput
->QueryMode (GraphicsOutput
, (UINT32
) NumberIndex
, &SizeOfInfo
, &Info
);
2989 if (EFI_ERROR (Status
)) {
2992 if ((Info
->HorizontalResolution
== Mode
->HorizontalResolution
) && (Info
->VerticalResolution
== Mode
->VerticalResolution
)) {
2998 Status
= GraphicsOutput
->SetMode (GraphicsOutput
, (UINT32
) NumberIndex
);
3002 // Current mode number may need update now, so set it to an invalid mode number
3004 CurrentGraphicsOutputMode
->Mode
= 0xffff;
3006 // Graphics console can ensure all GOP devices have the same mode which can be taken as current mode.
3008 Status
= Private
->GraphicsOutput
.SetMode (&Private
->GraphicsOutput
, (UINT32
) CurrentIndex
);
3009 if (EFI_ERROR(Status
)) {
3011 // If user defined mode is not valid for display device, set to the default mode 800x600.
3013 (Private
->GraphicsOutputModeBuffer
[0]).HorizontalResolution
= 800;
3014 (Private
->GraphicsOutputModeBuffer
[0]).VerticalResolution
= 600;
3015 Status
= Private
->GraphicsOutput
.SetMode (&Private
->GraphicsOutput
, 0);
3023 Set the current console out mode.
3025 This routine will get the current console mode information (column, row)
3026 from ConsoleOutMode variable and set it; if the variable does not exist,
3027 set to user defined console mode.
3029 @param Private Consplitter Text Out pointer.
3033 ConsplitterSetConsoleOutMode (
3034 IN TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
3044 CONSOLE_OUT_MODE ModeInfo
;
3045 CONSOLE_OUT_MODE MaxModeInfo
;
3046 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
;
3050 TextOut
= &Private
->TextOut
;
3051 MaxMode
= (UINTN
) (TextOut
->Mode
->MaxMode
);
3053 MaxModeInfo
.Column
= 0;
3054 MaxModeInfo
.Row
= 0;
3055 ModeInfo
.Column
= PcdGet32 (PcdConOutColumn
);
3056 ModeInfo
.Row
= PcdGet32 (PcdConOutRow
);
3059 // To find the prefer mode and basic mode from Text Out mode list
3061 for (Mode
= 0; Mode
< MaxMode
; Mode
++) {
3062 Status
= TextOut
->QueryMode (TextOut
, Mode
, &Col
, &Row
);
3063 if (!EFI_ERROR(Status
)) {
3064 if ((ModeInfo
.Column
!= 0) && (ModeInfo
.Row
!= 0)) {
3066 // Use user defined column and row
3068 if (Col
== ModeInfo
.Column
&& Row
== ModeInfo
.Row
) {
3073 // If user sets PcdConOutColumn or PcdConOutRow to 0,
3074 // find and set the highest text mode.
3076 if ((Col
>= MaxModeInfo
.Column
) && (Row
>= MaxModeInfo
.Row
)) {
3077 MaxModeInfo
.Column
= Col
;
3078 MaxModeInfo
.Row
= Row
;
3082 if (Col
== 80 && Row
== 25) {
3089 // Set prefer mode to Text Out devices.
3091 Status
= TextOut
->SetMode (TextOut
, PreferMode
);
3092 if (EFI_ERROR(Status
)) {
3094 // if current mode setting is failed, default 80x25 mode will be set.
3096 Status
= TextOut
->SetMode (TextOut
, BaseMode
);
3097 ASSERT(!EFI_ERROR(Status
));
3099 Status
= PcdSet32S (PcdConOutColumn
, 80);
3100 ASSERT(!EFI_ERROR(Status
));
3101 Status
= PcdSet32S (PcdConOutRow
, 25);
3102 ASSERT(!EFI_ERROR(Status
));
3110 Add Text Output Device in Consplitter Text Output list.
3112 @param Private Text Out Splitter pointer.
3113 @param TextOut Simple Text Output protocol pointer.
3114 @param GraphicsOutput Graphics Output protocol pointer.
3115 @param UgaDraw UGA Draw protocol pointer.
3117 @retval EFI_SUCCESS Text Output Device added successfully.
3118 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
3122 ConSplitterTextOutAddDevice (
3123 IN TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
,
3124 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
,
3125 IN EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
,
3126 IN EFI_UGA_DRAW_PROTOCOL
*UgaDraw
3130 UINTN CurrentNumOfConsoles
;
3132 UINT32 UgaHorizontalResolution
;
3133 UINT32 UgaVerticalResolution
;
3134 UINT32 UgaColorDepth
;
3135 UINT32 UgaRefreshRate
;
3136 TEXT_OUT_AND_GOP_DATA
*TextAndGop
;
3138 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*Info
;
3139 EFI_STATUS DeviceStatus
;
3141 Status
= EFI_SUCCESS
;
3142 CurrentNumOfConsoles
= Private
->CurrentNumberOfConsoles
;
3145 // If the Text Out List is full, enlarge it by calling ConSplitterGrowBuffer().
3147 while (CurrentNumOfConsoles
>= Private
->TextOutListCount
) {
3148 Status
= ConSplitterGrowBuffer (
3149 sizeof (TEXT_OUT_AND_GOP_DATA
),
3150 &Private
->TextOutListCount
,
3151 (VOID
**) &Private
->TextOutList
3153 if (EFI_ERROR (Status
)) {
3154 return EFI_OUT_OF_RESOURCES
;
3157 // Also need to reallocate the TextOutModeMap table
3159 Status
= ConSplitterGrowMapTable (Private
);
3160 if (EFI_ERROR (Status
)) {
3161 return EFI_OUT_OF_RESOURCES
;
3165 TextAndGop
= &Private
->TextOutList
[CurrentNumOfConsoles
];
3167 TextAndGop
->TextOut
= TextOut
;
3168 TextAndGop
->GraphicsOutput
= GraphicsOutput
;
3169 TextAndGop
->UgaDraw
= UgaDraw
;
3171 if (CurrentNumOfConsoles
== 0) {
3173 // Add the first device's output mode to console splitter's mode list
3175 Status
= ConSplitterAddOutputMode (Private
, TextOut
);
3177 ConSplitterSyncOutputMode (Private
, TextOut
);
3180 Private
->CurrentNumberOfConsoles
++;
3183 // Scan both TextOutList, for the intersection TextOut device
3184 // maybe both ConOut and StdErr incorporate the same Text Out
3185 // device in them, thus the output of both should be synced.
3187 ConSplitterGetIntersectionBetweenConOutAndStrErr ();
3189 MaxMode
= Private
->TextOutMode
.MaxMode
;
3190 ASSERT (MaxMode
>= 1);
3192 DeviceStatus
= EFI_DEVICE_ERROR
;
3193 Status
= EFI_DEVICE_ERROR
;
3196 // This device display mode will be added into Graphics Ouput modes.
3198 if ((GraphicsOutput
!= NULL
) || (UgaDraw
!= NULL
)) {
3199 DeviceStatus
= ConSplitterAddGraphicsOutputMode (Private
, GraphicsOutput
, UgaDraw
);
3202 if (FeaturePcdGet (PcdConOutUgaSupport
)) {
3204 // If UGA is produced by Consplitter
3206 if (GraphicsOutput
!= NULL
) {
3207 Status
= GraphicsOutput
->QueryMode (GraphicsOutput
, GraphicsOutput
->Mode
->Mode
, &SizeOfInfo
, &Info
);
3208 if (EFI_ERROR (Status
)) {
3211 ASSERT ( SizeOfInfo
<= sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
));
3213 UgaHorizontalResolution
= Info
->HorizontalResolution
;
3214 UgaVerticalResolution
= Info
->VerticalResolution
;
3218 } else if (UgaDraw
!= NULL
) {
3219 Status
= UgaDraw
->GetMode (
3221 &UgaHorizontalResolution
,
3222 &UgaVerticalResolution
,
3226 if (!EFI_ERROR (Status
) && EFI_ERROR (DeviceStatus
)) {
3228 // if GetMode is successfully and UGA device hasn't been set, set it
3230 Status
= ConSplitterUgaDrawSetMode (
3232 UgaHorizontalResolution
,
3233 UgaVerticalResolution
,
3239 // If GetMode/SetMode is failed, set to 800x600 mode
3241 if(EFI_ERROR (Status
)) {
3242 Status
= ConSplitterUgaDrawSetMode (
3253 if (((!EFI_ERROR (DeviceStatus
)) || (!EFI_ERROR (Status
))) &&
3254 ((Private
->CurrentNumberOfGraphicsOutput
+ Private
->CurrentNumberOfUgaDraw
) == 1)) {
3255 if (!FeaturePcdGet (PcdConOutGopSupport
)) {
3257 // If Graphics Outpurt protocol not supported, UGA Draw protocol is installed
3258 // on the virtual handle.
3260 Status
= gBS
->InstallMultipleProtocolInterfaces (
3261 &mConOut
.VirtualHandle
,
3262 &gEfiUgaDrawProtocolGuid
,
3266 } else if (!FeaturePcdGet (PcdConOutUgaSupport
)) {
3268 // If UGA Draw protocol not supported, Graphics Output Protocol is installed
3269 // on virtual handle.
3271 Status
= gBS
->InstallMultipleProtocolInterfaces (
3272 &mConOut
.VirtualHandle
,
3273 &gEfiGraphicsOutputProtocolGuid
,
3274 &mConOut
.GraphicsOutput
,
3279 // Boot Graphics Output protocol and UGA Draw protocol are supported,
3280 // both they will be installed on virtual handle.
3282 Status
= gBS
->InstallMultipleProtocolInterfaces (
3283 &mConOut
.VirtualHandle
,
3284 &gEfiGraphicsOutputProtocolGuid
,
3285 &mConOut
.GraphicsOutput
,
3286 &gEfiUgaDrawProtocolGuid
,
3294 // After adding new console device, all existing console devices should be
3295 // synced to the current shared mode.
3297 ConsplitterSetConsoleOutMode (Private
);
3304 Remove Text Out Device in Consplitter Text Out list.
3306 @param Private Text Out Splitter pointer.
3307 @param TextOut Simple Text Output Pointer protocol pointer.
3309 @retval EFI_SUCCESS Text Out Device removed successfully.
3310 @retval EFI_NOT_FOUND No Text Out Device found.
3314 ConSplitterTextOutDeleteDevice (
3315 IN TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
,
3316 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
3320 UINTN CurrentNumOfConsoles
;
3321 TEXT_OUT_AND_GOP_DATA
*TextOutList
;
3325 // Remove the specified text-out device data structure from the Text out List,
3326 // and rearrange the remaining data structures in the Text out List.
3328 CurrentNumOfConsoles
= Private
->CurrentNumberOfConsoles
;
3329 Index
= (INT32
) CurrentNumOfConsoles
- 1;
3330 TextOutList
= Private
->TextOutList
;
3331 while (Index
>= 0) {
3332 if (TextOutList
->TextOut
== TextOut
) {
3333 if (TextOutList
->UgaDraw
!= NULL
) {
3334 Private
->CurrentNumberOfUgaDraw
--;
3336 if (TextOutList
->GraphicsOutput
!= NULL
) {
3337 Private
->CurrentNumberOfGraphicsOutput
--;
3339 CopyMem (TextOutList
, TextOutList
+ 1, sizeof (TEXT_OUT_AND_GOP_DATA
) * Index
);
3340 CurrentNumOfConsoles
--;
3348 // The specified TextOut is not managed by the ConSplitter driver
3351 return EFI_NOT_FOUND
;
3354 if ((Private
->CurrentNumberOfGraphicsOutput
== 0) && (Private
->CurrentNumberOfUgaDraw
== 0)) {
3356 // If there is not any physical GOP and UGA device in system,
3357 // Consplitter GOP or UGA protocol will be uninstalled
3359 if (!FeaturePcdGet (PcdConOutGopSupport
)) {
3360 Status
= gBS
->UninstallProtocolInterface (
3361 Private
->VirtualHandle
,
3362 &gEfiUgaDrawProtocolGuid
,
3365 } else if (!FeaturePcdGet (PcdConOutUgaSupport
)) {
3366 Status
= gBS
->UninstallProtocolInterface (
3367 Private
->VirtualHandle
,
3368 &gEfiGraphicsOutputProtocolGuid
,
3369 &Private
->GraphicsOutput
3372 Status
= gBS
->UninstallMultipleProtocolInterfaces (
3373 Private
->VirtualHandle
,
3374 &gEfiUgaDrawProtocolGuid
,
3376 &gEfiGraphicsOutputProtocolGuid
,
3377 &Private
->GraphicsOutput
,
3383 if (CurrentNumOfConsoles
== 0) {
3385 // If the number of consoles is zero, reset all parameters
3387 Private
->CurrentNumberOfConsoles
= 0;
3388 Private
->TextOutMode
.MaxMode
= 1;
3389 Private
->TextOutQueryData
[0].Columns
= 80;
3390 Private
->TextOutQueryData
[0].Rows
= 25;
3391 TextOutSetMode (Private
, 0);
3396 // Max Mode is realy an intersection of the QueryMode command to all
3397 // devices. So we must copy the QueryMode of the first device to
3401 Private
->TextOutQueryData
,
3402 Private
->TextOutQueryDataCount
* sizeof (TEXT_OUT_SPLITTER_QUERY_DATA
)
3405 FreePool (Private
->TextOutModeMap
);
3406 Private
->TextOutModeMap
= NULL
;
3407 TextOutList
= Private
->TextOutList
;
3410 // Add the first TextOut to the QueryData array and ModeMap table
3412 Status
= ConSplitterAddOutputMode (Private
, TextOutList
->TextOut
);
3415 // Now add one by one
3418 Private
->CurrentNumberOfConsoles
= 1;
3420 while ((UINTN
) Index
< CurrentNumOfConsoles
) {
3421 ConSplitterSyncOutputMode (Private
, TextOutList
->TextOut
);
3423 Private
->CurrentNumberOfConsoles
++;
3427 ConSplitterGetIntersectionBetweenConOutAndStrErr ();
3434 Reset the input device and optionaly run diagnostics
3436 @param This Protocol instance pointer.
3437 @param ExtendedVerification Driver may perform diagnostics on reset.
3439 @retval EFI_SUCCESS The device was reset.
3440 @retval EFI_DEVICE_ERROR The device is not functioning properly and could
3446 ConSplitterTextInReset (
3447 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*This
,
3448 IN BOOLEAN ExtendedVerification
3452 EFI_STATUS ReturnStatus
;
3453 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3456 Private
= TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
3458 Private
->KeyEventSignalState
= FALSE
;
3461 // return the worst status met
3463 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
3464 Status
= Private
->TextInList
[Index
]->Reset (
3465 Private
->TextInList
[Index
],
3466 ExtendedVerification
3468 if (EFI_ERROR (Status
)) {
3469 ReturnStatus
= Status
;
3473 if (!EFI_ERROR (ReturnStatus
)) {
3474 ToggleStateSyncReInitialization (Private
);
3476 // Empty the key queue.
3478 Private
->CurrentNumberOfKeys
= 0;
3481 return ReturnStatus
;
3485 Dequeue the saved key from internal key queue.
3487 @param Private Protocol instance pointer.
3488 @param KeyData A pointer to a buffer that is filled in with the
3489 keystroke state data for the key that was
3491 @retval EFI_NOT_FOUND Queue is empty.
3492 @retval EFI_SUCCESS First key is dequeued and returned.
3495 ConSplitterTextInExDequeueKey (
3496 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
3497 OUT EFI_KEY_DATA
*KeyData
3500 if (Private
->CurrentNumberOfKeys
== 0) {
3501 return EFI_NOT_FOUND
;
3504 // Return the first saved key.
3506 CopyMem (KeyData
, &Private
->KeyQueue
[0], sizeof (EFI_KEY_DATA
));
3507 Private
->CurrentNumberOfKeys
--;
3509 &Private
->KeyQueue
[0],
3510 &Private
->KeyQueue
[1],
3511 Private
->CurrentNumberOfKeys
* sizeof (EFI_KEY_DATA
)
3517 Reads the next keystroke from the input device. The WaitForKey Event can
3518 be used to test for existance of a keystroke via WaitForEvent () call.
3520 @param Private Protocol instance pointer.
3521 @param Key Driver may perform diagnostics on reset.
3523 @retval EFI_SUCCESS The keystroke information was returned.
3524 @retval EFI_NOT_READY There was no keystroke data availiable.
3525 @retval EFI_DEVICE_ERROR The keydtroke information was not returned due
3531 ConSplitterTextInPrivateReadKeyStroke (
3532 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
3533 OUT EFI_INPUT_KEY
*Key
3538 EFI_KEY_DATA KeyData
;
3541 // Return the first saved non-NULL key.
3544 Status
= ConSplitterTextInExDequeueKey (Private
, &KeyData
);
3545 if (EFI_ERROR (Status
)) {
3548 if ((KeyData
.Key
.ScanCode
!= CHAR_NULL
) || (KeyData
.Key
.UnicodeChar
!= SCAN_NULL
)) {
3549 CopyMem (Key
, &KeyData
.Key
, sizeof (EFI_INPUT_KEY
));
3554 Key
->UnicodeChar
= 0;
3555 Key
->ScanCode
= SCAN_NULL
;
3558 // if no physical console input device exists, return EFI_NOT_READY;
3559 // if any physical console input device has key input,
3560 // return the key and EFI_SUCCESS.
3562 for (Index
= 0; Index
< Private
->CurrentNumberOfConsoles
;) {
3563 Status
= Private
->TextInList
[Index
]->ReadKeyStroke (
3564 Private
->TextInList
[Index
],
3567 if (!EFI_ERROR (Status
)) {
3569 // If it is not partial keystorke, return the key. Otherwise, continue
3570 // to read key from THIS physical console input device.
3572 if ((KeyData
.Key
.ScanCode
!= CHAR_NULL
) || (KeyData
.Key
.UnicodeChar
!= SCAN_NULL
)) {
3573 CopyMem (Key
, &KeyData
.Key
, sizeof (EFI_INPUT_KEY
));
3578 // Continue to read key from NEXT physical console input device.
3584 return EFI_NOT_READY
;
3590 Reads the next keystroke from the input device. The WaitForKey Event can
3591 be used to test for existance of a keystroke via WaitForEvent () call.
3593 @param This Protocol instance pointer.
3594 @param Key Driver may perform diagnostics on reset.
3596 @retval EFI_SUCCESS The keystroke information was returned.
3597 @retval EFI_NOT_READY There was no keystroke data availiable.
3598 @retval EFI_DEVICE_ERROR The keydtroke information was not returned due
3604 ConSplitterTextInReadKeyStroke (
3605 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*This
,
3606 OUT EFI_INPUT_KEY
*Key
3609 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3611 Private
= TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
3613 Private
->KeyEventSignalState
= FALSE
;
3616 // Signal ConnectConIn event on first call in Lazy ConIn mode
3618 if (!mConInIsConnect
&& PcdGetBool (PcdConInConnectOnDemand
)) {
3619 DEBUG ((EFI_D_INFO
, "Connect ConIn in first ReadKeyStoke in Lazy ConIn mode.\n"));
3620 gBS
->SignalEvent (Private
->ConnectConInEvent
);
3621 mConInIsConnect
= TRUE
;
3624 return ConSplitterTextInPrivateReadKeyStroke (Private
, Key
);
3629 This event aggregates all the events of the ConIn devices in the spliter.
3631 If any events of physical ConIn devices are signaled, signal the ConIn
3632 spliter event. This will cause the calling code to call
3633 ConSplitterTextInReadKeyStroke ().
3635 @param Event The Event assoicated with callback.
3636 @param Context Context registered when Event was created.
3641 ConSplitterTextInWaitForKey (
3647 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3650 Private
= (TEXT_IN_SPLITTER_PRIVATE_DATA
*) Context
;
3652 if (Private
->KeyEventSignalState
) {
3654 // If KeyEventSignalState is flagged before, and not cleared by Reset() or ReadKeyStroke()
3656 gBS
->SignalEvent (Event
);
3661 // If any physical console input device has key input, signal the event.
3663 for (Index
= 0; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
3664 Status
= gBS
->CheckEvent (Private
->TextInList
[Index
]->WaitForKey
);
3665 if (!EFI_ERROR (Status
)) {
3666 gBS
->SignalEvent (Event
);
3667 Private
->KeyEventSignalState
= TRUE
;
3675 Test if the key has been registered on input device.
3677 @param RegsiteredData A pointer to a buffer that is filled in with the
3678 keystroke state data for the key that was
3680 @param InputData A pointer to a buffer that is filled in with the
3681 keystroke state data for the key that was
3684 @retval TRUE Key be pressed matches a registered key.
3685 @retval FLASE Match failed.
3690 IN EFI_KEY_DATA
*RegsiteredData
,
3691 IN EFI_KEY_DATA
*InputData
3694 ASSERT (RegsiteredData
!= NULL
&& InputData
!= NULL
);
3696 if ((RegsiteredData
->Key
.ScanCode
!= InputData
->Key
.ScanCode
) ||
3697 (RegsiteredData
->Key
.UnicodeChar
!= InputData
->Key
.UnicodeChar
)) {
3702 // Assume KeyShiftState/KeyToggleState = 0 in Registered key data means these state could be ignored.
3704 if (RegsiteredData
->KeyState
.KeyShiftState
!= 0 &&
3705 RegsiteredData
->KeyState
.KeyShiftState
!= InputData
->KeyState
.KeyShiftState
) {
3708 if (RegsiteredData
->KeyState
.KeyToggleState
!= 0 &&
3709 RegsiteredData
->KeyState
.KeyToggleState
!= InputData
->KeyState
.KeyToggleState
) {
3719 Reset the input device and optionaly run diagnostics
3721 @param This Protocol instance pointer.
3722 @param ExtendedVerification Driver may perform diagnostics on reset.
3724 @retval EFI_SUCCESS The device was reset.
3725 @retval EFI_DEVICE_ERROR The device is not functioning properly and could
3731 ConSplitterTextInResetEx (
3732 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*This
,
3733 IN BOOLEAN ExtendedVerification
3737 EFI_STATUS ReturnStatus
;
3738 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3741 Private
= TEXT_IN_EX_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
3743 Private
->KeyEventSignalState
= FALSE
;
3746 // return the worst status met
3748 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfExConsoles
; Index
++) {
3749 Status
= Private
->TextInExList
[Index
]->Reset (
3750 Private
->TextInExList
[Index
],
3751 ExtendedVerification
3753 if (EFI_ERROR (Status
)) {
3754 ReturnStatus
= Status
;
3758 if (!EFI_ERROR (ReturnStatus
)) {
3759 ToggleStateSyncReInitialization (Private
);
3761 // Empty the key queue.
3763 Private
->CurrentNumberOfKeys
= 0;
3766 return ReturnStatus
;
3772 Reads the next keystroke from the input device. The WaitForKey Event can
3773 be used to test for existance of a keystroke via WaitForEvent () call.
3775 @param This Protocol instance pointer.
3776 @param KeyData A pointer to a buffer that is filled in with the
3777 keystroke state data for the key that was
3780 @retval EFI_SUCCESS The keystroke information was returned.
3781 @retval EFI_NOT_READY There was no keystroke data availiable.
3782 @retval EFI_DEVICE_ERROR The keystroke information was not returned due
3784 @retval EFI_INVALID_PARAMETER KeyData is NULL.
3789 ConSplitterTextInReadKeyStrokeEx (
3790 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*This
,
3791 OUT EFI_KEY_DATA
*KeyData
3794 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3797 EFI_KEY_STATE KeyState
;
3798 EFI_KEY_DATA CurrentKeyData
;
3801 if (KeyData
== NULL
) {
3802 return EFI_INVALID_PARAMETER
;
3805 Private
= TEXT_IN_EX_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
3807 Private
->KeyEventSignalState
= FALSE
;
3810 // Signal ConnectConIn event on first call in Lazy ConIn mode
3812 if (!mConInIsConnect
&& PcdGetBool (PcdConInConnectOnDemand
)) {
3813 DEBUG ((EFI_D_INFO
, "Connect ConIn in first ReadKeyStoke in Lazy ConIn mode.\n"));
3814 gBS
->SignalEvent (Private
->ConnectConInEvent
);
3815 mConInIsConnect
= TRUE
;
3819 // Return the first saved key.
3821 Status
= ConSplitterTextInExDequeueKey (Private
, KeyData
);
3822 if (!EFI_ERROR (Status
)) {
3825 ASSERT (Private
->CurrentNumberOfKeys
== 0);
3827 ZeroMem (&KeyState
, sizeof (KeyState
));
3830 // Iterate through all physical consoles to get key state.
3831 // Some physical consoles may return valid key.
3832 // Queue the valid keys.
3834 for (Index
= 0; Index
< Private
->CurrentNumberOfExConsoles
; Index
++) {
3835 ZeroMem (&CurrentKeyData
, sizeof (EFI_KEY_DATA
));
3836 Status
= Private
->TextInExList
[Index
]->ReadKeyStrokeEx (
3837 Private
->TextInExList
[Index
],
3840 if (EFI_ERROR (Status
) && (Status
!= EFI_NOT_READY
)) {
3845 // Consolidate the key state from all physical consoles.
3847 if ((CurrentKeyData
.KeyState
.KeyShiftState
& EFI_SHIFT_STATE_VALID
) != 0) {
3848 KeyState
.KeyShiftState
|= CurrentKeyData
.KeyState
.KeyShiftState
;
3850 if ((CurrentKeyData
.KeyState
.KeyToggleState
& EFI_TOGGLE_STATE_VALID
) != 0) {
3851 KeyState
.KeyToggleState
|= CurrentKeyData
.KeyState
.KeyToggleState
;
3854 if (!EFI_ERROR (Status
)) {
3856 // If virtual KeyState has been required to be exposed, or it is not
3857 // partial keystorke, queue the key.
3858 // It's possible that user presses at multiple keyboards at the same moment,
3859 // Private->KeyQueue[] are the storage to save all the keys.
3861 if ((Private
->VirtualKeyStateExported
) ||
3862 (CurrentKeyData
.Key
.ScanCode
!= CHAR_NULL
) ||
3863 (CurrentKeyData
.Key
.UnicodeChar
!= SCAN_NULL
)) {
3865 &Private
->KeyQueue
[Private
->CurrentNumberOfKeys
],
3867 sizeof (EFI_KEY_DATA
)
3869 Private
->CurrentNumberOfKeys
++;
3875 // Consolidate the key state for all keys in Private->KeyQueue[]
3877 for (Index
= 0; Index
< Private
->CurrentNumberOfKeys
; Index
++) {
3878 CopyMem (&Private
->KeyQueue
[Index
].KeyState
, &KeyState
, sizeof (EFI_KEY_STATE
));
3882 // Return the first saved key.
3884 Status
= ConSplitterTextInExDequeueKey (Private
, KeyData
);
3885 if (!EFI_ERROR (Status
)) {
3890 // Always return the key state even there is no key pressed.
3892 ZeroMem (&KeyData
->Key
, sizeof (KeyData
->Key
));
3893 CopyMem (&KeyData
->KeyState
, &KeyState
, sizeof (KeyData
->KeyState
));
3894 return EFI_NOT_READY
;
3899 Set certain state for the input device.
3901 @param This Protocol instance pointer.
3902 @param KeyToggleState A pointer to the EFI_KEY_TOGGLE_STATE to set the
3903 state for the input device.
3905 @retval EFI_SUCCESS The device state was set successfully.
3906 @retval EFI_DEVICE_ERROR The device is not functioning correctly and
3907 could not have the setting adjusted.
3908 @retval EFI_UNSUPPORTED The device does not have the ability to set its
3910 @retval EFI_INVALID_PARAMETER KeyToggleState is NULL.
3915 ConSplitterTextInSetState (
3916 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*This
,
3917 IN EFI_KEY_TOGGLE_STATE
*KeyToggleState
3920 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3923 EFI_KEY_TOGGLE_STATE PhysicalKeyToggleState
;
3925 if (KeyToggleState
== NULL
) {
3926 return EFI_INVALID_PARAMETER
;
3929 Private
= TEXT_IN_EX_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
3932 // Always turn on physical TextInEx partial key report for
3933 // toggle state sync.
3935 PhysicalKeyToggleState
= *KeyToggleState
| EFI_KEY_STATE_EXPOSED
;
3938 // if no physical console input device exists, return EFI_SUCCESS;
3939 // otherwise return the status of setting state of physical console input device
3941 for (Index
= 0; Index
< Private
->CurrentNumberOfExConsoles
; Index
++) {
3942 Status
= Private
->TextInExList
[Index
]->SetState (
3943 Private
->TextInExList
[Index
],
3944 &PhysicalKeyToggleState
3946 if (EFI_ERROR (Status
)) {
3952 // Record the physical KeyToggleState.
3954 Private
->PhysicalKeyToggleState
= PhysicalKeyToggleState
;
3956 // Get if virtual KeyState has been required to be exposed.
3958 Private
->VirtualKeyStateExported
= (((*KeyToggleState
) & EFI_KEY_STATE_EXPOSED
) != 0);
3966 Register a notification function for a particular keystroke for the input device.
3968 @param This Protocol instance pointer.
3969 @param KeyData A pointer to a buffer that is filled in with
3970 the keystroke information for the key that was
3971 pressed. If KeyData.Key, KeyData.KeyState.KeyToggleState
3972 and KeyData.KeyState.KeyShiftState are 0, then any incomplete
3973 keystroke will trigger a notification of the KeyNotificationFunction.
3974 @param KeyNotificationFunction Points to the function to be called when the key
3975 sequence is typed specified by KeyData. This notification function
3976 should be called at <=TPL_CALLBACK.
3977 @param NotifyHandle Points to the unique handle assigned to the
3978 registered notification.
3980 @retval EFI_SUCCESS The notification function was registered
3982 @retval EFI_OUT_OF_RESOURCES Unable to allocate resources for necesssary data
3984 @retval EFI_INVALID_PARAMETER KeyData or KeyNotificationFunction or NotifyHandle is NULL.
3989 ConSplitterTextInRegisterKeyNotify (
3990 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*This
,
3991 IN EFI_KEY_DATA
*KeyData
,
3992 IN EFI_KEY_NOTIFY_FUNCTION KeyNotificationFunction
,
3993 OUT VOID
**NotifyHandle
3996 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3999 TEXT_IN_EX_SPLITTER_NOTIFY
*NewNotify
;
4001 TEXT_IN_EX_SPLITTER_NOTIFY
*CurrentNotify
;
4004 if (KeyData
== NULL
|| NotifyHandle
== NULL
|| KeyNotificationFunction
== NULL
) {
4005 return EFI_INVALID_PARAMETER
;
4008 Private
= TEXT_IN_EX_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4011 // Return EFI_SUCCESS if the (KeyData, NotificationFunction) is already registered.
4013 for (Link
= Private
->NotifyList
.ForwardLink
; Link
!= &Private
->NotifyList
; Link
= Link
->ForwardLink
) {
4014 CurrentNotify
= TEXT_IN_EX_SPLITTER_NOTIFY_FROM_THIS (Link
);
4015 if (IsKeyRegistered (&CurrentNotify
->KeyData
, KeyData
)) {
4016 if (CurrentNotify
->KeyNotificationFn
== KeyNotificationFunction
) {
4017 *NotifyHandle
= CurrentNotify
;
4024 // Allocate resource to save the notification function
4026 NewNotify
= (TEXT_IN_EX_SPLITTER_NOTIFY
*) AllocateZeroPool (sizeof (TEXT_IN_EX_SPLITTER_NOTIFY
));
4027 if (NewNotify
== NULL
) {
4028 return EFI_OUT_OF_RESOURCES
;
4030 NewNotify
->NotifyHandleList
= (EFI_HANDLE
*) AllocateZeroPool (sizeof (EFI_HANDLE
) * Private
->TextInExListCount
);
4031 if (NewNotify
->NotifyHandleList
== NULL
) {
4032 gBS
->FreePool (NewNotify
);
4033 return EFI_OUT_OF_RESOURCES
;
4035 NewNotify
->Signature
= TEXT_IN_EX_SPLITTER_NOTIFY_SIGNATURE
;
4036 NewNotify
->KeyNotificationFn
= KeyNotificationFunction
;
4037 CopyMem (&NewNotify
->KeyData
, KeyData
, sizeof (EFI_KEY_DATA
));
4040 // Return the wrong status of registering key notify of
4041 // physical console input device if meet problems
4043 for (Index
= 0; Index
< Private
->CurrentNumberOfExConsoles
; Index
++) {
4044 Status
= Private
->TextInExList
[Index
]->RegisterKeyNotify (
4045 Private
->TextInExList
[Index
],
4047 KeyNotificationFunction
,
4048 &NewNotify
->NotifyHandleList
[Index
]
4050 if (EFI_ERROR (Status
)) {
4052 // Un-register the key notify on all physical console input devices
4054 while (Index
-- != 0) {
4055 Private
->TextInExList
[Index
]->UnregisterKeyNotify (
4056 Private
->TextInExList
[Index
],
4057 NewNotify
->NotifyHandleList
[Index
]
4060 gBS
->FreePool (NewNotify
->NotifyHandleList
);
4061 gBS
->FreePool (NewNotify
);
4066 InsertTailList (&Private
->NotifyList
, &NewNotify
->NotifyEntry
);
4068 *NotifyHandle
= NewNotify
;
4076 Remove a registered notification function from a particular keystroke.
4078 @param This Protocol instance pointer.
4079 @param NotificationHandle The handle of the notification function being
4082 @retval EFI_SUCCESS The notification function was unregistered
4084 @retval EFI_INVALID_PARAMETER The NotificationHandle is invalid.
4089 ConSplitterTextInUnregisterKeyNotify (
4090 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*This
,
4091 IN VOID
*NotificationHandle
4094 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
4096 TEXT_IN_EX_SPLITTER_NOTIFY
*CurrentNotify
;
4099 if (NotificationHandle
== NULL
) {
4100 return EFI_INVALID_PARAMETER
;
4103 Private
= TEXT_IN_EX_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4105 for (Link
= Private
->NotifyList
.ForwardLink
; Link
!= &Private
->NotifyList
; Link
= Link
->ForwardLink
) {
4106 CurrentNotify
= TEXT_IN_EX_SPLITTER_NOTIFY_FROM_THIS (Link
);
4107 if (CurrentNotify
== NotificationHandle
) {
4108 for (Index
= 0; Index
< Private
->CurrentNumberOfExConsoles
; Index
++) {
4109 Private
->TextInExList
[Index
]->UnregisterKeyNotify (
4110 Private
->TextInExList
[Index
],
4111 CurrentNotify
->NotifyHandleList
[Index
]
4114 RemoveEntryList (&CurrentNotify
->NotifyEntry
);
4116 gBS
->FreePool (CurrentNotify
->NotifyHandleList
);
4117 gBS
->FreePool (CurrentNotify
);
4123 // NotificationHandle is not found in database
4125 return EFI_INVALID_PARAMETER
;
4130 Reset the input device and optionaly run diagnostics
4132 @param This Protocol instance pointer.
4133 @param ExtendedVerification Driver may perform diagnostics on reset.
4135 @retval EFI_SUCCESS The device was reset.
4136 @retval EFI_DEVICE_ERROR The device is not functioning properly and could
4142 ConSplitterSimplePointerReset (
4143 IN EFI_SIMPLE_POINTER_PROTOCOL
*This
,
4144 IN BOOLEAN ExtendedVerification
4148 EFI_STATUS ReturnStatus
;
4149 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
4152 Private
= TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_SIMPLE_POINTER_THIS (This
);
4154 Private
->InputEventSignalState
= FALSE
;
4156 if (Private
->CurrentNumberOfPointers
== 0) {
4160 // return the worst status met
4162 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfPointers
; Index
++) {
4163 Status
= Private
->PointerList
[Index
]->Reset (
4164 Private
->PointerList
[Index
],
4165 ExtendedVerification
4167 if (EFI_ERROR (Status
)) {
4168 ReturnStatus
= Status
;
4172 return ReturnStatus
;
4177 Reads the next keystroke from the input device. The WaitForKey Event can
4178 be used to test for existance of a keystroke via WaitForEvent () call.
4180 @param Private Protocol instance pointer.
4181 @param State The state information of simple pointer device.
4183 @retval EFI_SUCCESS The keystroke information was returned.
4184 @retval EFI_NOT_READY There was no keystroke data availiable.
4185 @retval EFI_DEVICE_ERROR The keydtroke information was not returned due
4191 ConSplitterSimplePointerPrivateGetState (
4192 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
4193 IN OUT EFI_SIMPLE_POINTER_STATE
*State
4197 EFI_STATUS ReturnStatus
;
4199 EFI_SIMPLE_POINTER_STATE CurrentState
;
4201 State
->RelativeMovementX
= 0;
4202 State
->RelativeMovementY
= 0;
4203 State
->RelativeMovementZ
= 0;
4204 State
->LeftButton
= FALSE
;
4205 State
->RightButton
= FALSE
;
4208 // if no physical console input device exists, return EFI_NOT_READY;
4209 // if any physical console input device has key input,
4210 // return the key and EFI_SUCCESS.
4212 ReturnStatus
= EFI_NOT_READY
;
4213 for (Index
= 0; Index
< Private
->CurrentNumberOfPointers
; Index
++) {
4215 Status
= Private
->PointerList
[Index
]->GetState (
4216 Private
->PointerList
[Index
],
4219 if (!EFI_ERROR (Status
)) {
4220 if (ReturnStatus
== EFI_NOT_READY
) {
4221 ReturnStatus
= EFI_SUCCESS
;
4224 if (CurrentState
.LeftButton
) {
4225 State
->LeftButton
= TRUE
;
4228 if (CurrentState
.RightButton
) {
4229 State
->RightButton
= TRUE
;
4232 if (CurrentState
.RelativeMovementX
!= 0 && Private
->PointerList
[Index
]->Mode
->ResolutionX
!= 0) {
4233 State
->RelativeMovementX
+= (CurrentState
.RelativeMovementX
* (INT32
) Private
->SimplePointerMode
.ResolutionX
) / (INT32
) Private
->PointerList
[Index
]->Mode
->ResolutionX
;
4236 if (CurrentState
.RelativeMovementY
!= 0 && Private
->PointerList
[Index
]->Mode
->ResolutionY
!= 0) {
4237 State
->RelativeMovementY
+= (CurrentState
.RelativeMovementY
* (INT32
) Private
->SimplePointerMode
.ResolutionY
) / (INT32
) Private
->PointerList
[Index
]->Mode
->ResolutionY
;
4240 if (CurrentState
.RelativeMovementZ
!= 0 && Private
->PointerList
[Index
]->Mode
->ResolutionZ
!= 0) {
4241 State
->RelativeMovementZ
+= (CurrentState
.RelativeMovementZ
* (INT32
) Private
->SimplePointerMode
.ResolutionZ
) / (INT32
) Private
->PointerList
[Index
]->Mode
->ResolutionZ
;
4243 } else if (Status
== EFI_DEVICE_ERROR
) {
4244 ReturnStatus
= EFI_DEVICE_ERROR
;
4248 return ReturnStatus
;
4253 Reads the next keystroke from the input device. The WaitForKey Event can
4254 be used to test for existance of a keystroke via WaitForEvent () call.
4256 @param This A pointer to protocol instance.
4257 @param State A pointer to state information on the pointer device
4259 @retval EFI_SUCCESS The keystroke information was returned in State.
4260 @retval EFI_NOT_READY There was no keystroke data availiable.
4261 @retval EFI_DEVICE_ERROR The keydtroke information was not returned due
4267 ConSplitterSimplePointerGetState (
4268 IN EFI_SIMPLE_POINTER_PROTOCOL
*This
,
4269 IN OUT EFI_SIMPLE_POINTER_STATE
*State
4272 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
4274 Private
= TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_SIMPLE_POINTER_THIS (This
);
4276 Private
->InputEventSignalState
= FALSE
;
4278 return ConSplitterSimplePointerPrivateGetState (Private
, State
);
4283 This event agregates all the events of the ConIn devices in the spliter.
4284 If any events of physical ConIn devices are signaled, signal the ConIn
4285 spliter event. This will cause the calling code to call
4286 ConSplitterTextInReadKeyStroke ().
4288 @param Event The Event assoicated with callback.
4289 @param Context Context registered when Event was created.
4294 ConSplitterSimplePointerWaitForInput (
4300 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
4303 Private
= (TEXT_IN_SPLITTER_PRIVATE_DATA
*) Context
;
4306 // if InputEventSignalState is flagged before, and not cleared by Reset() or ReadKeyStroke()
4308 if (Private
->InputEventSignalState
) {
4309 gBS
->SignalEvent (Event
);
4313 // if any physical console input device has key input, signal the event.
4315 for (Index
= 0; Index
< Private
->CurrentNumberOfPointers
; Index
++) {
4316 Status
= gBS
->CheckEvent (Private
->PointerList
[Index
]->WaitForInput
);
4317 if (!EFI_ERROR (Status
)) {
4318 gBS
->SignalEvent (Event
);
4319 Private
->InputEventSignalState
= TRUE
;
4325 Resets the pointer device hardware.
4327 @param This Protocol instance pointer.
4328 @param ExtendedVerification Driver may perform diagnostics on reset.
4330 @retval EFI_SUCCESS The device was reset.
4331 @retval EFI_DEVICE_ERROR The device is not functioning correctly and
4337 ConSplitterAbsolutePointerReset (
4338 IN EFI_ABSOLUTE_POINTER_PROTOCOL
*This
,
4339 IN BOOLEAN ExtendedVerification
4343 EFI_STATUS ReturnStatus
;
4344 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
4347 Private
= TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_ABSOLUTE_POINTER_THIS (This
);
4349 Private
->AbsoluteInputEventSignalState
= FALSE
;
4351 if (Private
->CurrentNumberOfAbsolutePointers
== 0) {
4355 // return the worst status met
4357 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfAbsolutePointers
; Index
++) {
4358 Status
= Private
->AbsolutePointerList
[Index
]->Reset (
4359 Private
->AbsolutePointerList
[Index
],
4360 ExtendedVerification
4362 if (EFI_ERROR (Status
)) {
4363 ReturnStatus
= Status
;
4367 return ReturnStatus
;
4372 Retrieves the current state of a pointer device.
4374 @param This Protocol instance pointer.
4375 @param State A pointer to the state information on the
4378 @retval EFI_SUCCESS The state of the pointer device was returned in
4380 @retval EFI_NOT_READY The state of the pointer device has not changed
4381 since the last call to GetState().
4382 @retval EFI_DEVICE_ERROR A device error occurred while attempting to
4383 retrieve the pointer device's current state.
4388 ConSplitterAbsolutePointerGetState (
4389 IN EFI_ABSOLUTE_POINTER_PROTOCOL
*This
,
4390 IN OUT EFI_ABSOLUTE_POINTER_STATE
*State
4393 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
4395 EFI_STATUS ReturnStatus
;
4397 EFI_ABSOLUTE_POINTER_STATE CurrentState
;
4411 Private
= TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_ABSOLUTE_POINTER_THIS (This
);
4413 Private
->AbsoluteInputEventSignalState
= FALSE
;
4415 State
->CurrentX
= 0;
4416 State
->CurrentY
= 0;
4417 State
->CurrentZ
= 0;
4418 State
->ActiveButtons
= 0;
4420 VirtualMinX
= Private
->AbsolutePointerMode
.AbsoluteMinX
;
4421 VirtualMinY
= Private
->AbsolutePointerMode
.AbsoluteMinY
;
4422 VirtualMinZ
= Private
->AbsolutePointerMode
.AbsoluteMinZ
;
4423 VirtualMaxX
= Private
->AbsolutePointerMode
.AbsoluteMaxX
;
4424 VirtualMaxY
= Private
->AbsolutePointerMode
.AbsoluteMaxY
;
4425 VirtualMaxZ
= Private
->AbsolutePointerMode
.AbsoluteMaxZ
;
4428 // if no physical pointer device exists, return EFI_NOT_READY;
4429 // if any physical pointer device has changed state,
4430 // return the state and EFI_SUCCESS.
4432 ReturnStatus
= EFI_NOT_READY
;
4433 for (Index
= 0; Index
< Private
->CurrentNumberOfAbsolutePointers
; Index
++) {
4435 Status
= Private
->AbsolutePointerList
[Index
]->GetState (
4436 Private
->AbsolutePointerList
[Index
],
4439 if (!EFI_ERROR (Status
)) {
4440 if (ReturnStatus
== EFI_NOT_READY
) {
4441 ReturnStatus
= EFI_SUCCESS
;
4444 MinX
= Private
->AbsolutePointerList
[Index
]->Mode
->AbsoluteMinX
;
4445 MinY
= Private
->AbsolutePointerList
[Index
]->Mode
->AbsoluteMinY
;
4446 MinZ
= Private
->AbsolutePointerList
[Index
]->Mode
->AbsoluteMinZ
;
4447 MaxX
= Private
->AbsolutePointerList
[Index
]->Mode
->AbsoluteMaxX
;
4448 MaxY
= Private
->AbsolutePointerList
[Index
]->Mode
->AbsoluteMaxY
;
4449 MaxZ
= Private
->AbsolutePointerList
[Index
]->Mode
->AbsoluteMaxZ
;
4451 State
->ActiveButtons
= CurrentState
.ActiveButtons
;
4454 // Rescale to Con Splitter virtual Absolute Pointer's resolution.
4456 if (!(MinX
== 0 && MaxX
== 0)) {
4457 State
->CurrentX
= VirtualMinX
+ DivU64x64Remainder (
4459 CurrentState
.CurrentX
,
4460 VirtualMaxX
- VirtualMinX
4466 if (!(MinY
== 0 && MaxY
== 0)) {
4467 State
->CurrentY
= VirtualMinY
+ DivU64x64Remainder (
4469 CurrentState
.CurrentY
,
4470 VirtualMaxY
- VirtualMinY
4476 if (!(MinZ
== 0 && MaxZ
== 0)) {
4477 State
->CurrentZ
= VirtualMinZ
+ DivU64x64Remainder (
4479 CurrentState
.CurrentZ
,
4480 VirtualMaxZ
- VirtualMinZ
4487 } else if (Status
== EFI_DEVICE_ERROR
) {
4488 ReturnStatus
= EFI_DEVICE_ERROR
;
4492 return ReturnStatus
;
4497 This event agregates all the events of the pointer devices in the splitter.
4498 If any events of physical pointer devices are signaled, signal the pointer
4499 splitter event. This will cause the calling code to call
4500 ConSplitterAbsolutePointerGetState ().
4502 @param Event The Event assoicated with callback.
4503 @param Context Context registered when Event was created.
4508 ConSplitterAbsolutePointerWaitForInput (
4514 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
4517 Private
= (TEXT_IN_SPLITTER_PRIVATE_DATA
*) Context
;
4520 // if AbsoluteInputEventSignalState is flagged before,
4521 // and not cleared by Reset() or GetState(), signal it
4523 if (Private
->AbsoluteInputEventSignalState
) {
4524 gBS
->SignalEvent (Event
);
4528 // if any physical console input device has key input, signal the event.
4530 for (Index
= 0; Index
< Private
->CurrentNumberOfAbsolutePointers
; Index
++) {
4531 Status
= gBS
->CheckEvent (Private
->AbsolutePointerList
[Index
]->WaitForInput
);
4532 if (!EFI_ERROR (Status
)) {
4533 gBS
->SignalEvent (Event
);
4534 Private
->AbsoluteInputEventSignalState
= TRUE
;
4541 Reset the text output device hardware and optionaly run diagnostics
4543 @param This Protocol instance pointer.
4544 @param ExtendedVerification Driver may perform more exhaustive verfication
4545 operation of the device during reset.
4547 @retval EFI_SUCCESS The text output device was reset.
4548 @retval EFI_DEVICE_ERROR The text output device is not functioning
4549 correctly and could not be reset.
4554 ConSplitterTextOutReset (
4555 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4556 IN BOOLEAN ExtendedVerification
4560 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4562 EFI_STATUS ReturnStatus
;
4564 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4567 // return the worst status met
4569 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
4570 Status
= Private
->TextOutList
[Index
].TextOut
->Reset (
4571 Private
->TextOutList
[Index
].TextOut
,
4572 ExtendedVerification
4574 if (EFI_ERROR (Status
)) {
4575 ReturnStatus
= Status
;
4579 This
->SetAttribute (This
, EFI_TEXT_ATTR (This
->Mode
->Attribute
& 0x0F, EFI_BLACK
));
4582 // reset all mode parameters
4584 TextOutSetMode (Private
, 0);
4586 return ReturnStatus
;
4591 Write a Unicode string to the output device.
4593 @param This Protocol instance pointer.
4594 @param WString The NULL-terminated Unicode string to be
4595 displayed on the output device(s). All output
4596 devices must also support the Unicode drawing
4597 defined in this file.
4599 @retval EFI_SUCCESS The string was output to the device.
4600 @retval EFI_DEVICE_ERROR The device reported an error while attempting to
4602 @retval EFI_UNSUPPORTED The output device's mode is not currently in a
4604 @retval EFI_WARN_UNKNOWN_GLYPH This warning code indicates that some of the
4605 characters in the Unicode string could not be
4606 rendered and were skipped.
4611 ConSplitterTextOutOutputString (
4612 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4617 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4619 EFI_STATUS ReturnStatus
;
4623 This
->SetAttribute (This
, This
->Mode
->Attribute
);
4625 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4628 // return the worst status met
4630 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
4631 Status
= Private
->TextOutList
[Index
].TextOut
->OutputString (
4632 Private
->TextOutList
[Index
].TextOut
,
4635 if (EFI_ERROR (Status
)) {
4636 ReturnStatus
= Status
;
4640 if (Private
->CurrentNumberOfConsoles
> 0) {
4641 Private
->TextOutMode
.CursorColumn
= Private
->TextOutList
[0].TextOut
->Mode
->CursorColumn
;
4642 Private
->TextOutMode
.CursorRow
= Private
->TextOutList
[0].TextOut
->Mode
->CursorRow
;
4645 // When there is no real console devices in system,
4646 // update cursor position for the virtual device in consplitter.
4648 Private
->TextOut
.QueryMode (
4650 Private
->TextOutMode
.Mode
,
4654 for (; *WString
!= CHAR_NULL
; WString
++) {
4656 case CHAR_BACKSPACE
:
4657 if (Private
->TextOutMode
.CursorColumn
== 0 && Private
->TextOutMode
.CursorRow
> 0) {
4658 Private
->TextOutMode
.CursorRow
--;
4659 Private
->TextOutMode
.CursorColumn
= (INT32
) (MaxColumn
- 1);
4660 } else if (Private
->TextOutMode
.CursorColumn
> 0) {
4661 Private
->TextOutMode
.CursorColumn
--;
4666 if (Private
->TextOutMode
.CursorRow
< (INT32
) (MaxRow
- 1)) {
4667 Private
->TextOutMode
.CursorRow
++;
4671 case CHAR_CARRIAGE_RETURN
:
4672 Private
->TextOutMode
.CursorColumn
= 0;
4676 if (Private
->TextOutMode
.CursorColumn
< (INT32
) (MaxColumn
- 1)) {
4677 Private
->TextOutMode
.CursorColumn
++;
4679 Private
->TextOutMode
.CursorColumn
= 0;
4680 if (Private
->TextOutMode
.CursorRow
< (INT32
) (MaxRow
- 1)) {
4681 Private
->TextOutMode
.CursorRow
++;
4689 return ReturnStatus
;
4694 Verifies that all characters in a Unicode string can be output to the
4697 @param This Protocol instance pointer.
4698 @param WString The NULL-terminated Unicode string to be
4699 examined for the output device(s).
4701 @retval EFI_SUCCESS The device(s) are capable of rendering the
4703 @retval EFI_UNSUPPORTED Some of the characters in the Unicode string
4704 cannot be rendered by one or more of the output
4705 devices mapped by the EFI handle.
4710 ConSplitterTextOutTestString (
4711 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4716 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4718 EFI_STATUS ReturnStatus
;
4720 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4723 // return the worst status met
4725 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
4726 Status
= Private
->TextOutList
[Index
].TextOut
->TestString (
4727 Private
->TextOutList
[Index
].TextOut
,
4730 if (EFI_ERROR (Status
)) {
4731 ReturnStatus
= Status
;
4735 // There is no DevNullTextOutTestString () since a Unicode buffer would
4736 // always return EFI_SUCCESS.
4737 // ReturnStatus will be EFI_SUCCESS if no consoles are present
4739 return ReturnStatus
;
4744 Returns information for an available text mode that the output device(s)
4747 @param This Protocol instance pointer.
4748 @param ModeNumber The mode number to return information on.
4749 @param Columns Returns the columns of the text output device
4750 for the requested ModeNumber.
4751 @param Rows Returns the rows of the text output device
4752 for the requested ModeNumber.
4754 @retval EFI_SUCCESS The requested mode information was returned.
4755 @retval EFI_DEVICE_ERROR The device had an error and could not complete
4757 @retval EFI_UNSUPPORTED The mode number was not valid.
4762 ConSplitterTextOutQueryMode (
4763 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4764 IN UINTN ModeNumber
,
4769 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4771 INT32
*TextOutModeMap
;
4773 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4776 // Check whether param ModeNumber is valid.
4777 // ModeNumber should be within range 0 ~ MaxMode - 1.
4779 if ( (ModeNumber
> (UINTN
)(((UINT32
)-1)>>1)) ) {
4780 return EFI_UNSUPPORTED
;
4783 if ((INT32
) ModeNumber
>= This
->Mode
->MaxMode
) {
4784 return EFI_UNSUPPORTED
;
4788 // We get the available mode from mode intersection map if it's available
4790 if (Private
->TextOutModeMap
!= NULL
) {
4791 TextOutModeMap
= Private
->TextOutModeMap
+ Private
->TextOutListCount
* ModeNumber
;
4792 CurrentMode
= (UINTN
)(*TextOutModeMap
);
4793 *Columns
= Private
->TextOutQueryData
[CurrentMode
].Columns
;
4794 *Rows
= Private
->TextOutQueryData
[CurrentMode
].Rows
;
4796 *Columns
= Private
->TextOutQueryData
[ModeNumber
].Columns
;
4797 *Rows
= Private
->TextOutQueryData
[ModeNumber
].Rows
;
4800 if (*Columns
<= 0 && *Rows
<= 0) {
4801 return EFI_UNSUPPORTED
;
4810 Sets the output device(s) to a specified mode.
4812 @param This Protocol instance pointer.
4813 @param ModeNumber The mode number to set.
4815 @retval EFI_SUCCESS The requested text mode was set.
4816 @retval EFI_DEVICE_ERROR The device had an error and could not complete
4818 @retval EFI_UNSUPPORTED The mode number was not valid.
4823 ConSplitterTextOutSetMode (
4824 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4829 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4831 INT32
*TextOutModeMap
;
4832 EFI_STATUS ReturnStatus
;
4834 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4837 // Check whether param ModeNumber is valid.
4838 // ModeNumber should be within range 0 ~ MaxMode - 1.
4840 if ( (ModeNumber
> (UINTN
)(((UINT32
)-1)>>1)) ) {
4841 return EFI_UNSUPPORTED
;
4844 if ((INT32
) ModeNumber
>= This
->Mode
->MaxMode
) {
4845 return EFI_UNSUPPORTED
;
4848 // If the mode is being set to the curent mode, then just clear the screen and return.
4850 if (Private
->TextOutMode
.Mode
== (INT32
) ModeNumber
) {
4851 return ConSplitterTextOutClearScreen (This
);
4854 // return the worst status met
4856 TextOutModeMap
= Private
->TextOutModeMap
+ Private
->TextOutListCount
* ModeNumber
;
4857 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
4858 Status
= Private
->TextOutList
[Index
].TextOut
->SetMode (
4859 Private
->TextOutList
[Index
].TextOut
,
4860 TextOutModeMap
[Index
]
4862 if (EFI_ERROR (Status
)) {
4863 ReturnStatus
= Status
;
4868 // Set mode parameter to specified mode number
4870 TextOutSetMode (Private
, ModeNumber
);
4872 return ReturnStatus
;
4877 Sets the background and foreground colors for the OutputString () and
4878 ClearScreen () functions.
4880 @param This Protocol instance pointer.
4881 @param Attribute The attribute to set. Bits 0..3 are the
4882 foreground color, and bits 4..6 are the
4883 background color. All other bits are undefined
4884 and must be zero. The valid Attributes are
4885 defined in this file.
4887 @retval EFI_SUCCESS The attribute was set.
4888 @retval EFI_DEVICE_ERROR The device had an error and could not complete
4890 @retval EFI_UNSUPPORTED The attribute requested is not defined.
4895 ConSplitterTextOutSetAttribute (
4896 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4901 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4903 EFI_STATUS ReturnStatus
;
4905 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4908 // Check whether param Attribute is valid.
4910 if ((Attribute
| 0x7F) != 0x7F) {
4911 return EFI_UNSUPPORTED
;
4915 // return the worst status met
4917 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
4918 Status
= Private
->TextOutList
[Index
].TextOut
->SetAttribute (
4919 Private
->TextOutList
[Index
].TextOut
,
4922 if (EFI_ERROR (Status
)) {
4923 ReturnStatus
= Status
;
4927 Private
->TextOutMode
.Attribute
= (INT32
) Attribute
;
4929 return ReturnStatus
;
4934 Clears the output device(s) display to the currently selected background
4937 @param This Protocol instance pointer.
4939 @retval EFI_SUCCESS The operation completed successfully.
4940 @retval EFI_DEVICE_ERROR The device had an error and could not complete
4942 @retval EFI_UNSUPPORTED The output device is not in a valid text mode.
4947 ConSplitterTextOutClearScreen (
4948 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
4952 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4954 EFI_STATUS ReturnStatus
;
4956 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4959 // return the worst status met
4961 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
4962 Status
= Private
->TextOutList
[Index
].TextOut
->ClearScreen (Private
->TextOutList
[Index
].TextOut
);
4963 if (EFI_ERROR (Status
)) {
4964 ReturnStatus
= Status
;
4969 // No need to do extra check here as whether (Column, Row) is valid has
4970 // been checked in ConSplitterTextOutSetCursorPosition. And (0, 0) should
4971 // always be supported.
4973 Private
->TextOutMode
.CursorColumn
= 0;
4974 Private
->TextOutMode
.CursorRow
= 0;
4975 Private
->TextOutMode
.CursorVisible
= TRUE
;
4977 return ReturnStatus
;
4982 Sets the current coordinates of the cursor position
4984 @param This Protocol instance pointer.
4985 @param Column The column position to set the cursor to. Must be
4986 greater than or equal to zero and less than the
4987 number of columns by QueryMode ().
4988 @param Row The row position to set the cursor to. Must be
4989 greater than or equal to zero and less than the
4990 number of rows by QueryMode ().
4992 @retval EFI_SUCCESS The operation completed successfully.
4993 @retval EFI_DEVICE_ERROR The device had an error and could not complete
4995 @retval EFI_UNSUPPORTED The output device is not in a valid text mode,
4996 or the cursor position is invalid for the
5002 ConSplitterTextOutSetCursorPosition (
5003 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
5009 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
5011 EFI_STATUS ReturnStatus
;
5014 INT32
*TextOutModeMap
;
5018 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
5019 TextOutModeMap
= NULL
;
5020 ModeNumber
= Private
->TextOutMode
.Mode
;
5023 // Get current MaxColumn and MaxRow from intersection map
5025 if (Private
->TextOutModeMap
!= NULL
) {
5026 TextOutModeMap
= Private
->TextOutModeMap
+ Private
->TextOutListCount
* ModeNumber
;
5027 CurrentMode
= *TextOutModeMap
;
5029 CurrentMode
= ModeNumber
;
5032 MaxColumn
= Private
->TextOutQueryData
[CurrentMode
].Columns
;
5033 MaxRow
= Private
->TextOutQueryData
[CurrentMode
].Rows
;
5035 if (Column
>= MaxColumn
|| Row
>= MaxRow
) {
5036 return EFI_UNSUPPORTED
;
5039 // return the worst status met
5041 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
5042 Status
= Private
->TextOutList
[Index
].TextOut
->SetCursorPosition (
5043 Private
->TextOutList
[Index
].TextOut
,
5047 if (EFI_ERROR (Status
)) {
5048 ReturnStatus
= Status
;
5053 // No need to do extra check here as whether (Column, Row) is valid has
5054 // been checked in ConSplitterTextOutSetCursorPosition. And (0, 0) should
5055 // always be supported.
5057 Private
->TextOutMode
.CursorColumn
= (INT32
) Column
;
5058 Private
->TextOutMode
.CursorRow
= (INT32
) Row
;
5060 return ReturnStatus
;
5065 Makes the cursor visible or invisible
5067 @param This Protocol instance pointer.
5068 @param Visible If TRUE, the cursor is set to be visible. If
5069 FALSE, the cursor is set to be invisible.
5071 @retval EFI_SUCCESS The operation completed successfully.
5072 @retval EFI_DEVICE_ERROR The device had an error and could not complete
5073 the request, or the device does not support
5074 changing the cursor mode.
5075 @retval EFI_UNSUPPORTED The output device is not in a valid text mode.
5080 ConSplitterTextOutEnableCursor (
5081 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
5086 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
5088 EFI_STATUS ReturnStatus
;
5090 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
5093 // return the worst status met
5095 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
5096 Status
= Private
->TextOutList
[Index
].TextOut
->EnableCursor (
5097 Private
->TextOutList
[Index
].TextOut
,
5100 if (EFI_ERROR (Status
)) {
5101 ReturnStatus
= Status
;
5105 Private
->TextOutMode
.CursorVisible
= Visible
;
5107 return ReturnStatus
;