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 - 2015, Intel Corporation. All rights reserved.<BR>
20 This program and the accompanying materials
21 are licensed and made available under the terms and conditions of the BSD License
22 which accompanies this distribution. The full text of the license may be found at
23 http://opensource.org/licenses/bsd-license.php
25 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
26 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
30 #include "ConSplitter.h"
33 // Identify if ConIn is connected in PcdConInConnectOnDemand enabled mode.
34 // default not connect
36 BOOLEAN mConInIsConnect
= FALSE
;
39 // Text In Splitter Private Data template
41 GLOBAL_REMOVE_IF_UNREFERENCED TEXT_IN_SPLITTER_PRIVATE_DATA mConIn
= {
42 TEXT_IN_SPLITTER_PRIVATE_DATA_SIGNATURE
,
46 ConSplitterTextInReset
,
47 ConSplitterTextInReadKeyStroke
,
51 (EFI_SIMPLE_TEXT_INPUT_PROTOCOL
**) NULL
,
55 ConSplitterTextInResetEx
,
56 ConSplitterTextInReadKeyStrokeEx
,
58 ConSplitterTextInSetState
,
59 ConSplitterTextInRegisterKeyNotify
,
60 ConSplitterTextInUnregisterKeyNotify
63 (EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
**) NULL
,
71 ConSplitterSimplePointerReset
,
72 ConSplitterSimplePointerGetState
,
74 (EFI_SIMPLE_POINTER_MODE
*) NULL
84 (EFI_SIMPLE_POINTER_PROTOCOL
**) NULL
,
88 ConSplitterAbsolutePointerReset
,
89 ConSplitterAbsolutePointerGetState
,
91 (EFI_ABSOLUTE_POINTER_MODE
*) NULL
97 0x10000, // AbsoluteMaxX
98 0x10000, // AbsoluteMaxY
99 0x10000, // AbsoluteMaxZ
103 (EFI_ABSOLUTE_POINTER_PROTOCOL
**) NULL
,
113 // Uga Draw Protocol Private Data template
115 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UGA_DRAW_PROTOCOL mUgaDrawProtocolTemplate
= {
116 ConSplitterUgaDrawGetMode
,
117 ConSplitterUgaDrawSetMode
,
118 ConSplitterUgaDrawBlt
122 // Graphics Output Protocol Private Data template
124 GLOBAL_REMOVE_IF_UNREFERENCED EFI_GRAPHICS_OUTPUT_PROTOCOL mGraphicsOutputProtocolTemplate
= {
125 ConSplitterGraphicsOutputQueryMode
,
126 ConSplitterGraphicsOutputSetMode
,
127 ConSplitterGraphicsOutputBlt
,
133 // Text Out Splitter Private Data template
135 GLOBAL_REMOVE_IF_UNREFERENCED TEXT_OUT_SPLITTER_PRIVATE_DATA mConOut
= {
136 TEXT_OUT_SPLITTER_PRIVATE_DATA_SIGNATURE
,
139 ConSplitterTextOutReset
,
140 ConSplitterTextOutOutputString
,
141 ConSplitterTextOutTestString
,
142 ConSplitterTextOutQueryMode
,
143 ConSplitterTextOutSetMode
,
144 ConSplitterTextOutSetAttribute
,
145 ConSplitterTextOutClearScreen
,
146 ConSplitterTextOutSetCursorPosition
,
147 ConSplitterTextOutEnableCursor
,
148 (EFI_SIMPLE_TEXT_OUTPUT_MODE
*) NULL
175 (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*) NULL
,
180 (TEXT_OUT_AND_GOP_DATA
*) NULL
,
182 (TEXT_OUT_SPLITTER_QUERY_DATA
*) NULL
,
188 // Standard Error Text Out Splitter Data Template
190 GLOBAL_REMOVE_IF_UNREFERENCED TEXT_OUT_SPLITTER_PRIVATE_DATA mStdErr
= {
191 TEXT_OUT_SPLITTER_PRIVATE_DATA_SIGNATURE
,
194 ConSplitterTextOutReset
,
195 ConSplitterTextOutOutputString
,
196 ConSplitterTextOutTestString
,
197 ConSplitterTextOutQueryMode
,
198 ConSplitterTextOutSetMode
,
199 ConSplitterTextOutSetAttribute
,
200 ConSplitterTextOutClearScreen
,
201 ConSplitterTextOutSetCursorPosition
,
202 ConSplitterTextOutEnableCursor
,
203 (EFI_SIMPLE_TEXT_OUTPUT_MODE
*) NULL
230 (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*) NULL
,
235 (TEXT_OUT_AND_GOP_DATA
*) NULL
,
237 (TEXT_OUT_SPLITTER_QUERY_DATA
*) NULL
,
243 // Driver binding instance for Console Input Device
245 EFI_DRIVER_BINDING_PROTOCOL gConSplitterConInDriverBinding
= {
246 ConSplitterConInDriverBindingSupported
,
247 ConSplitterConInDriverBindingStart
,
248 ConSplitterConInDriverBindingStop
,
255 // Driver binding instance for Console Out device
257 EFI_DRIVER_BINDING_PROTOCOL gConSplitterConOutDriverBinding
= {
258 ConSplitterConOutDriverBindingSupported
,
259 ConSplitterConOutDriverBindingStart
,
260 ConSplitterConOutDriverBindingStop
,
267 // Driver binding instance for Standard Error device
269 EFI_DRIVER_BINDING_PROTOCOL gConSplitterStdErrDriverBinding
= {
270 ConSplitterStdErrDriverBindingSupported
,
271 ConSplitterStdErrDriverBindingStart
,
272 ConSplitterStdErrDriverBindingStop
,
279 // Driver binding instance for Simple Pointer protocol
281 EFI_DRIVER_BINDING_PROTOCOL gConSplitterSimplePointerDriverBinding
= {
282 ConSplitterSimplePointerDriverBindingSupported
,
283 ConSplitterSimplePointerDriverBindingStart
,
284 ConSplitterSimplePointerDriverBindingStop
,
291 // Driver binding instance for Absolute Pointer protocol
293 EFI_DRIVER_BINDING_PROTOCOL gConSplitterAbsolutePointerDriverBinding
= {
294 ConSplitterAbsolutePointerDriverBindingSupported
,
295 ConSplitterAbsolutePointerDriverBindingStart
,
296 ConSplitterAbsolutePointerDriverBindingStop
,
303 The Entry Point for module ConSplitter. The user code starts with this function.
305 Installs driver module protocols and. Creates virtual device handles for ConIn,
306 ConOut, and StdErr. Installs Simple Text In protocol, Simple Text In Ex protocol,
307 Simple Pointer protocol, Absolute Pointer protocol on those virtual handlers.
308 Installs Graphics Output protocol and/or UGA Draw protocol if needed.
310 @param[in] ImageHandle The firmware allocated handle for the EFI image.
311 @param[in] SystemTable A pointer to the EFI System Table.
313 @retval EFI_SUCCESS The entry point is executed successfully.
314 @retval other Some error occurs when executing this entry point.
319 ConSplitterDriverEntry(
320 IN EFI_HANDLE ImageHandle
,
321 IN EFI_SYSTEM_TABLE
*SystemTable
327 // Install driver model protocol(s).
329 Status
= EfiLibInstallDriverBindingComponentName2 (
332 &gConSplitterConInDriverBinding
,
334 &gConSplitterConInComponentName
,
335 &gConSplitterConInComponentName2
337 ASSERT_EFI_ERROR (Status
);
339 Status
= EfiLibInstallDriverBindingComponentName2 (
342 &gConSplitterSimplePointerDriverBinding
,
344 &gConSplitterSimplePointerComponentName
,
345 &gConSplitterSimplePointerComponentName2
347 ASSERT_EFI_ERROR (Status
);
349 Status
= EfiLibInstallDriverBindingComponentName2 (
352 &gConSplitterAbsolutePointerDriverBinding
,
354 &gConSplitterAbsolutePointerComponentName
,
355 &gConSplitterAbsolutePointerComponentName2
357 ASSERT_EFI_ERROR (Status
);
359 Status
= EfiLibInstallDriverBindingComponentName2 (
362 &gConSplitterConOutDriverBinding
,
364 &gConSplitterConOutComponentName
,
365 &gConSplitterConOutComponentName2
367 ASSERT_EFI_ERROR (Status
);
369 Status
= EfiLibInstallDriverBindingComponentName2 (
372 &gConSplitterStdErrDriverBinding
,
374 &gConSplitterStdErrComponentName
,
375 &gConSplitterStdErrComponentName2
377 ASSERT_EFI_ERROR (Status
);
380 // Either Graphics Output protocol or UGA Draw protocol must be supported.
382 ASSERT (FeaturePcdGet (PcdConOutGopSupport
) ||
383 FeaturePcdGet (PcdConOutUgaSupport
));
386 // The driver creates virtual handles for ConIn, ConOut, StdErr.
387 // The virtual handles will always exist even if no console exist in the
388 // system. This is need to support hotplug devices like USB.
391 // Create virtual device handle for ConIn Splitter
393 Status
= ConSplitterTextInConstructor (&mConIn
);
394 if (!EFI_ERROR (Status
)) {
395 Status
= gBS
->InstallMultipleProtocolInterfaces (
396 &mConIn
.VirtualHandle
,
397 &gEfiSimpleTextInProtocolGuid
,
399 &gEfiSimpleTextInputExProtocolGuid
,
401 &gEfiSimplePointerProtocolGuid
,
402 &mConIn
.SimplePointer
,
403 &gEfiAbsolutePointerProtocolGuid
,
404 &mConIn
.AbsolutePointer
,
407 if (!EFI_ERROR (Status
)) {
409 // Update the EFI System Table with new virtual console
410 // and update the pointer to Simple Text Input protocol.
412 gST
->ConsoleInHandle
= mConIn
.VirtualHandle
;
413 gST
->ConIn
= &mConIn
.TextIn
;
417 // Create virtual device handle for ConOut Splitter
419 Status
= ConSplitterTextOutConstructor (&mConOut
);
420 if (!EFI_ERROR (Status
)) {
421 Status
= gBS
->InstallMultipleProtocolInterfaces (
422 &mConOut
.VirtualHandle
,
423 &gEfiSimpleTextOutProtocolGuid
,
427 if (!EFI_ERROR (Status
)) {
429 // Update the EFI System Table with new virtual console
430 // and Update the pointer to Text Output protocol.
432 gST
->ConsoleOutHandle
= mConOut
.VirtualHandle
;
433 gST
->ConOut
= &mConOut
.TextOut
;
439 // Create virtual device handle for StdErr Splitter
441 Status
= ConSplitterTextOutConstructor (&mStdErr
);
442 if (!EFI_ERROR (Status
)) {
443 Status
= gBS
->InstallMultipleProtocolInterfaces (
444 &mStdErr
.VirtualHandle
,
445 &gEfiSimpleTextOutProtocolGuid
,
449 if (!EFI_ERROR (Status
)) {
451 // Update the EFI System Table with new virtual console
452 // and update the pointer to Text Output protocol.
454 gST
->StandardErrorHandle
= mStdErr
.VirtualHandle
;
455 gST
->StdErr
= &mStdErr
.TextOut
;
460 // Update the CRC32 in the EFI System Table header
463 gBS
->CalculateCrc32 (
474 Construct console input devices' private data.
476 @param ConInPrivate A pointer to the TEXT_IN_SPLITTER_PRIVATE_DATA
479 @retval EFI_OUT_OF_RESOURCES Out of resources.
480 @retval EFI_SUCCESS Text Input Devcie's private data has been constructed.
481 @retval other Failed to construct private data.
485 ConSplitterTextInConstructor (
486 TEXT_IN_SPLITTER_PRIVATE_DATA
*ConInPrivate
492 // Allocate buffer for Simple Text Input device
494 Status
= ConSplitterGrowBuffer (
495 sizeof (EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*),
496 &ConInPrivate
->TextInListCount
,
497 (VOID
**) &ConInPrivate
->TextInList
499 if (EFI_ERROR (Status
)) {
500 return EFI_OUT_OF_RESOURCES
;
504 // Create Event to wait for a key
506 Status
= gBS
->CreateEvent (
509 ConSplitterTextInWaitForKey
,
511 &ConInPrivate
->TextIn
.WaitForKey
513 ASSERT_EFI_ERROR (Status
);
516 // Allocate buffer for Simple Text Input Ex device
518 Status
= ConSplitterGrowBuffer (
519 sizeof (EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*),
520 &ConInPrivate
->TextInExListCount
,
521 (VOID
**) &ConInPrivate
->TextInExList
523 if (EFI_ERROR (Status
)) {
524 return EFI_OUT_OF_RESOURCES
;
527 // Create Event to wait for a key Ex
529 Status
= gBS
->CreateEvent (
532 ConSplitterTextInWaitForKey
,
534 &ConInPrivate
->TextInEx
.WaitForKeyEx
536 ASSERT_EFI_ERROR (Status
);
538 InitializeListHead (&ConInPrivate
->NotifyList
);
540 ConInPrivate
->AbsolutePointer
.Mode
= &ConInPrivate
->AbsolutePointerMode
;
542 // Allocate buffer for Absolute Pointer device
544 Status
= ConSplitterGrowBuffer (
545 sizeof (EFI_ABSOLUTE_POINTER_PROTOCOL
*),
546 &ConInPrivate
->AbsolutePointerListCount
,
547 (VOID
**) &ConInPrivate
->AbsolutePointerList
549 if (EFI_ERROR (Status
)) {
550 return EFI_OUT_OF_RESOURCES
;
553 // Create Event to wait for device input for Absolute pointer device
555 Status
= gBS
->CreateEvent (
558 ConSplitterAbsolutePointerWaitForInput
,
560 &ConInPrivate
->AbsolutePointer
.WaitForInput
562 ASSERT_EFI_ERROR (Status
);
564 ConInPrivate
->SimplePointer
.Mode
= &ConInPrivate
->SimplePointerMode
;
566 // Allocate buffer for Simple Pointer device
568 Status
= ConSplitterGrowBuffer (
569 sizeof (EFI_SIMPLE_POINTER_PROTOCOL
*),
570 &ConInPrivate
->PointerListCount
,
571 (VOID
**) &ConInPrivate
->PointerList
573 if (EFI_ERROR (Status
)) {
574 return EFI_OUT_OF_RESOURCES
;
577 // Create Event to wait for device input for Simple pointer device
579 Status
= gBS
->CreateEvent (
582 ConSplitterSimplePointerWaitForInput
,
584 &ConInPrivate
->SimplePointer
.WaitForInput
586 ASSERT_EFI_ERROR (Status
);
588 // Create Event to signal ConIn connection request
590 Status
= gBS
->CreateEventEx (
593 ConSplitterEmptyCallbackFunction
,
595 &gConnectConInEventGuid
,
596 &ConInPrivate
->ConnectConInEvent
603 Construct console output devices' private data.
605 @param ConOutPrivate A pointer to the TEXT_OUT_SPLITTER_PRIVATE_DATA
608 @retval EFI_OUT_OF_RESOURCES Out of resources.
609 @retval EFI_SUCCESS Text Input Devcie's private data has been constructed.
613 ConSplitterTextOutConstructor (
614 TEXT_OUT_SPLITTER_PRIVATE_DATA
*ConOutPrivate
618 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*Info
;
621 // Copy protocols template
623 if (FeaturePcdGet (PcdConOutUgaSupport
)) {
624 CopyMem (&ConOutPrivate
->UgaDraw
, &mUgaDrawProtocolTemplate
, sizeof (EFI_UGA_DRAW_PROTOCOL
));
626 if (FeaturePcdGet (PcdConOutGopSupport
)) {
627 CopyMem (&ConOutPrivate
->GraphicsOutput
, &mGraphicsOutputProtocolTemplate
, sizeof (EFI_GRAPHICS_OUTPUT_PROTOCOL
));
631 // Initilize console output splitter's private data.
633 ConOutPrivate
->TextOut
.Mode
= &ConOutPrivate
->TextOutMode
;
636 // When new console device is added, the new mode will be set later,
637 // so put current mode back to init state.
639 ConOutPrivate
->TextOutMode
.Mode
= 0xFF;
641 // Allocate buffer for Console Out device
643 Status
= ConSplitterGrowBuffer (
644 sizeof (TEXT_OUT_AND_GOP_DATA
),
645 &ConOutPrivate
->TextOutListCount
,
646 (VOID
**) &ConOutPrivate
->TextOutList
648 if (EFI_ERROR (Status
)) {
649 return EFI_OUT_OF_RESOURCES
;
652 // Allocate buffer for Text Out query data
654 Status
= ConSplitterGrowBuffer (
655 sizeof (TEXT_OUT_SPLITTER_QUERY_DATA
),
656 &ConOutPrivate
->TextOutQueryDataCount
,
657 (VOID
**) &ConOutPrivate
->TextOutQueryData
659 if (EFI_ERROR (Status
)) {
660 return EFI_OUT_OF_RESOURCES
;
664 // Setup the default console to 80 x 25 and mode to 0
666 ConOutPrivate
->TextOutQueryData
[0].Columns
= 80;
667 ConOutPrivate
->TextOutQueryData
[0].Rows
= 25;
668 TextOutSetMode (ConOutPrivate
, 0);
671 if (FeaturePcdGet (PcdConOutUgaSupport
)) {
673 // Setup the UgaDraw to 800 x 600 x 32 bits per pixel, 60Hz.
675 ConSplitterUgaDrawSetMode (&ConOutPrivate
->UgaDraw
, 800, 600, 32, 60);
677 if (FeaturePcdGet (PcdConOutGopSupport
)) {
679 // Setup resource for mode information in Graphics Output Protocol interface
681 if ((ConOutPrivate
->GraphicsOutput
.Mode
= AllocateZeroPool (sizeof (EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE
))) == NULL
) {
682 return EFI_OUT_OF_RESOURCES
;
684 if ((ConOutPrivate
->GraphicsOutput
.Mode
->Info
= AllocateZeroPool (sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
))) == NULL
) {
685 return EFI_OUT_OF_RESOURCES
;
688 // Setup the DevNullGraphicsOutput to 800 x 600 x 32 bits per pixel
689 // DevNull will be updated to user-defined mode after driver has started.
691 if ((ConOutPrivate
->GraphicsOutputModeBuffer
= AllocateZeroPool (sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
))) == NULL
) {
692 return EFI_OUT_OF_RESOURCES
;
694 Info
= &ConOutPrivate
->GraphicsOutputModeBuffer
[0];
696 Info
->HorizontalResolution
= 800;
697 Info
->VerticalResolution
= 600;
698 Info
->PixelFormat
= PixelBltOnly
;
699 Info
->PixelsPerScanLine
= 800;
700 CopyMem (ConOutPrivate
->GraphicsOutput
.Mode
->Info
, Info
, sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
));
701 ConOutPrivate
->GraphicsOutput
.Mode
->SizeOfInfo
= sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
);
704 // Initialize the following items, theset items remain unchanged in GraphicsOutput->SetMode()
705 // GraphicsOutputMode->FrameBufferBase, GraphicsOutputMode->FrameBufferSize
707 ConOutPrivate
->GraphicsOutput
.Mode
->FrameBufferBase
= (EFI_PHYSICAL_ADDRESS
) (UINTN
) NULL
;
708 ConOutPrivate
->GraphicsOutput
.Mode
->FrameBufferSize
= 0;
710 ConOutPrivate
->GraphicsOutput
.Mode
->MaxMode
= 1;
712 // Initial current mode to unknown state, and then set to mode 0
714 ConOutPrivate
->GraphicsOutput
.Mode
->Mode
= 0xffff;
715 ConOutPrivate
->GraphicsOutput
.SetMode (&ConOutPrivate
->GraphicsOutput
, 0);
723 Test to see if the specified protocol could be supported on the specified device.
725 @param This Driver Binding protocol pointer.
726 @param ControllerHandle Handle of device to test.
727 @param Guid The specified protocol.
729 @retval EFI_SUCCESS The specified protocol is supported on this device.
730 @retval EFI_UNSUPPORTED The specified protocol attempts to be installed on virtul handle.
731 @retval other Failed to open specified protocol on this device.
735 ConSplitterSupported (
736 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
737 IN EFI_HANDLE ControllerHandle
,
745 // Make sure the Console Splitter does not attempt to attach to itself
747 if (ControllerHandle
== mConIn
.VirtualHandle
||
748 ControllerHandle
== mConOut
.VirtualHandle
||
749 ControllerHandle
== mStdErr
.VirtualHandle
751 return EFI_UNSUPPORTED
;
755 // Check to see whether the specific protocol could be opened BY_DRIVER
757 Status
= gBS
->OpenProtocol (
761 This
->DriverBindingHandle
,
763 EFI_OPEN_PROTOCOL_BY_DRIVER
766 if (EFI_ERROR (Status
)) {
773 This
->DriverBindingHandle
,
781 Test to see if Console In Device could be supported on the Controller.
783 @param This Driver Binding protocol instance pointer.
784 @param ControllerHandle Handle of device to test.
785 @param RemainingDevicePath Optional parameter use to pick a specific child
788 @retval EFI_SUCCESS This driver supports this device.
789 @retval other This driver does not support this device.
794 ConSplitterConInDriverBindingSupported (
795 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
796 IN EFI_HANDLE ControllerHandle
,
797 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
800 return ConSplitterSupported (
803 &gEfiConsoleInDeviceGuid
808 Test to see if Simple Pointer protocol could be supported on the Controller.
810 @param This Driver Binding protocol instance pointer.
811 @param ControllerHandle Handle of device to test.
812 @param RemainingDevicePath Optional parameter use to pick a specific child
815 @retval EFI_SUCCESS This driver supports this device.
816 @retval other This driver does not support this device.
821 ConSplitterSimplePointerDriverBindingSupported (
822 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
823 IN EFI_HANDLE ControllerHandle
,
824 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
827 return ConSplitterSupported (
830 &gEfiSimplePointerProtocolGuid
835 Test to see if Absolute Pointer protocol could be supported on the Controller.
837 @param This Driver Binding protocol instance pointer.
838 @param ControllerHandle Handle of device to test.
839 @param RemainingDevicePath Optional parameter use to pick a specific child
842 @retval EFI_SUCCESS This driver supports this device.
843 @retval other This driver does not support this device.
848 ConSplitterAbsolutePointerDriverBindingSupported (
849 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
850 IN EFI_HANDLE ControllerHandle
,
851 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
854 return ConSplitterSupported (
857 &gEfiAbsolutePointerProtocolGuid
863 Test to see if Console Out Device could be supported on the Controller.
865 @param This Driver Binding protocol instance pointer.
866 @param ControllerHandle Handle of device to test.
867 @param RemainingDevicePath Optional parameter use to pick a specific child
870 @retval EFI_SUCCESS This driver supports this device.
871 @retval other This driver does not support this device.
876 ConSplitterConOutDriverBindingSupported (
877 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
878 IN EFI_HANDLE ControllerHandle
,
879 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
882 return ConSplitterSupported (
885 &gEfiConsoleOutDeviceGuid
890 Test to see if Standard Error Device could be supported on the Controller.
892 @param This Driver Binding protocol instance pointer.
893 @param ControllerHandle Handle of device to test.
894 @param RemainingDevicePath Optional parameter use to pick a specific child
897 @retval EFI_SUCCESS This driver supports this device.
898 @retval other This driver does not support this device.
903 ConSplitterStdErrDriverBindingSupported (
904 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
905 IN EFI_HANDLE ControllerHandle
,
906 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
909 return ConSplitterSupported (
912 &gEfiStandardErrorDeviceGuid
918 Start ConSplitter on devcie handle by opening Console Device Guid on device handle
919 and the console virtual handle. And Get the console interface on controller handle.
921 @param This Driver Binding protocol instance pointer.
922 @param ControllerHandle Handle of device.
923 @param ConSplitterVirtualHandle Console virtual Handle.
924 @param DeviceGuid The specified Console Device, such as ConInDev,
926 @param InterfaceGuid The specified protocol to be opened.
927 @param Interface Protocol interface returned.
929 @retval EFI_SUCCESS This driver supports this device.
930 @retval other Failed to open the specified Console Device Guid
931 or specified protocol.
936 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
937 IN EFI_HANDLE ControllerHandle
,
938 IN EFI_HANDLE ConSplitterVirtualHandle
,
939 IN EFI_GUID
*DeviceGuid
,
940 IN EFI_GUID
*InterfaceGuid
,
948 // Check to see whether the ControllerHandle has the DeviceGuid on it.
950 Status
= gBS
->OpenProtocol (
954 This
->DriverBindingHandle
,
956 EFI_OPEN_PROTOCOL_BY_DRIVER
958 if (EFI_ERROR (Status
)) {
963 // Open the Parent Handle for the child.
965 Status
= gBS
->OpenProtocol (
969 This
->DriverBindingHandle
,
970 ConSplitterVirtualHandle
,
971 EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
973 if (EFI_ERROR (Status
)) {
978 // Open InterfaceGuid on the virtul handle.
980 Status
= gBS
->OpenProtocol (
984 This
->DriverBindingHandle
,
985 ConSplitterVirtualHandle
,
986 EFI_OPEN_PROTOCOL_GET_PROTOCOL
989 if (!EFI_ERROR (Status
)) {
994 // close the DeviceGuid on ConSplitter VirtualHandle.
999 This
->DriverBindingHandle
,
1000 ConSplitterVirtualHandle
1005 // close the DeviceGuid on ControllerHandle.
1007 gBS
->CloseProtocol (
1010 This
->DriverBindingHandle
,
1019 Start Console In Consplitter on device handle.
1021 @param This Driver Binding protocol instance pointer.
1022 @param ControllerHandle Handle of device to bind driver to.
1023 @param RemainingDevicePath Optional parameter use to pick a specific child
1026 @retval EFI_SUCCESS Console In Consplitter is added to ControllerHandle.
1027 @retval other Console In Consplitter does not support this device.
1032 ConSplitterConInDriverBindingStart (
1033 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1034 IN EFI_HANDLE ControllerHandle
,
1035 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
1039 EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*TextIn
;
1040 EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*TextInEx
;
1043 // Start ConSplitter on ControllerHandle, and create the virtual
1044 // agrogated console device on first call Start for a SimpleTextIn handle.
1046 Status
= ConSplitterStart (
1049 mConIn
.VirtualHandle
,
1050 &gEfiConsoleInDeviceGuid
,
1051 &gEfiSimpleTextInProtocolGuid
,
1054 if (EFI_ERROR (Status
)) {
1059 // Add this device into Text In devices list.
1061 Status
= ConSplitterTextInAddDevice (&mConIn
, TextIn
);
1062 if (EFI_ERROR (Status
)) {
1066 Status
= gBS
->OpenProtocol (
1068 &gEfiSimpleTextInputExProtocolGuid
,
1069 (VOID
**) &TextInEx
,
1070 This
->DriverBindingHandle
,
1071 mConIn
.VirtualHandle
,
1072 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1074 if (!EFI_ERROR (Status
)) {
1076 // If Simple Text Input Ex protocol exists,
1077 // add this device into Text In Ex devices list.
1079 Status
= ConSplitterTextInExAddDevice (&mConIn
, TextInEx
);
1087 Start Simple Pointer Consplitter on device handle.
1089 @param This Driver Binding protocol instance pointer.
1090 @param ControllerHandle Handle of device to bind driver to.
1091 @param RemainingDevicePath Optional parameter use to pick a specific child
1094 @retval EFI_SUCCESS Simple Pointer Consplitter is added to ControllerHandle.
1095 @retval other Simple Pointer Consplitter does not support this device.
1100 ConSplitterSimplePointerDriverBindingStart (
1101 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1102 IN EFI_HANDLE ControllerHandle
,
1103 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
1107 EFI_SIMPLE_POINTER_PROTOCOL
*SimplePointer
;
1110 // Start ConSplitter on ControllerHandle, and create the virtual
1111 // agrogated console device on first call Start for a SimplePointer handle.
1113 Status
= ConSplitterStart (
1116 mConIn
.VirtualHandle
,
1117 &gEfiSimplePointerProtocolGuid
,
1118 &gEfiSimplePointerProtocolGuid
,
1119 (VOID
**) &SimplePointer
1121 if (EFI_ERROR (Status
)) {
1126 // Add this devcie into Simple Pointer devices list.
1128 return ConSplitterSimplePointerAddDevice (&mConIn
, SimplePointer
);
1133 Start Absolute Pointer Consplitter on device handle.
1135 @param This Driver Binding protocol instance pointer.
1136 @param ControllerHandle Handle of device to bind driver to.
1137 @param RemainingDevicePath Optional parameter use to pick a specific child
1140 @retval EFI_SUCCESS Absolute Pointer Consplitter is added to ControllerHandle.
1141 @retval other Absolute Pointer Consplitter does not support this device.
1146 ConSplitterAbsolutePointerDriverBindingStart (
1147 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1148 IN EFI_HANDLE ControllerHandle
,
1149 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
1153 EFI_ABSOLUTE_POINTER_PROTOCOL
*AbsolutePointer
;
1156 // Start ConSplitter on ControllerHandle, and create the virtual
1157 // agrogated console device on first call Start for a AbsolutePointer handle.
1159 Status
= ConSplitterStart (
1162 mConIn
.VirtualHandle
,
1163 &gEfiAbsolutePointerProtocolGuid
,
1164 &gEfiAbsolutePointerProtocolGuid
,
1165 (VOID
**) &AbsolutePointer
1168 if (EFI_ERROR (Status
)) {
1173 // Add this devcie into Absolute Pointer devices list.
1175 return ConSplitterAbsolutePointerAddDevice (&mConIn
, AbsolutePointer
);
1180 Start Console Out Consplitter on device handle.
1182 @param This Driver Binding protocol instance pointer.
1183 @param ControllerHandle Handle of device to bind driver to.
1184 @param RemainingDevicePath Optional parameter use to pick a specific child
1187 @retval EFI_SUCCESS Console Out Consplitter is added to ControllerHandle.
1188 @retval other Console Out Consplitter does not support this device.
1193 ConSplitterConOutDriverBindingStart (
1194 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1195 IN EFI_HANDLE ControllerHandle
,
1196 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
1200 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
;
1201 EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
;
1202 EFI_UGA_DRAW_PROTOCOL
*UgaDraw
;
1204 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*Info
;
1207 // Start ConSplitter on ControllerHandle, and create the virtual
1208 // agrogated console device on first call Start for a ConsoleOut handle.
1210 Status
= ConSplitterStart (
1213 mConOut
.VirtualHandle
,
1214 &gEfiConsoleOutDeviceGuid
,
1215 &gEfiSimpleTextOutProtocolGuid
,
1218 if (EFI_ERROR (Status
)) {
1222 GraphicsOutput
= NULL
;
1225 // Try to Open Graphics Output protocol
1227 Status
= gBS
->OpenProtocol (
1229 &gEfiGraphicsOutputProtocolGuid
,
1230 (VOID
**) &GraphicsOutput
,
1231 This
->DriverBindingHandle
,
1232 mConOut
.VirtualHandle
,
1233 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1236 if (EFI_ERROR (Status
) && FeaturePcdGet (PcdUgaConsumeSupport
)) {
1238 // Open UGA DRAW protocol
1242 &gEfiUgaDrawProtocolGuid
,
1244 This
->DriverBindingHandle
,
1245 mConOut
.VirtualHandle
,
1246 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1251 // When new console device is added, the new mode will be set later,
1252 // so put current mode back to init state.
1254 mConOut
.TextOutMode
.Mode
= 0xFF;
1257 // If both ConOut and StdErr incorporate the same Text Out device,
1258 // their MaxMode and QueryData should be the intersection of both.
1260 Status
= ConSplitterTextOutAddDevice (&mConOut
, TextOut
, GraphicsOutput
, UgaDraw
);
1261 ConSplitterTextOutSetAttribute (&mConOut
.TextOut
, EFI_TEXT_ATTR (EFI_LIGHTGRAY
, EFI_BLACK
));
1263 if (FeaturePcdGet (PcdConOutUgaSupport
)) {
1265 // Get the UGA mode data of ConOut from the current mode
1267 if (GraphicsOutput
!= NULL
) {
1268 Status
= GraphicsOutput
->QueryMode (GraphicsOutput
, GraphicsOutput
->Mode
->Mode
, &SizeOfInfo
, &Info
);
1269 if (EFI_ERROR (Status
)) {
1272 ASSERT ( SizeOfInfo
<= sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
));
1274 mConOut
.UgaHorizontalResolution
= Info
->HorizontalResolution
;
1275 mConOut
.UgaVerticalResolution
= Info
->VerticalResolution
;
1276 mConOut
.UgaColorDepth
= 32;
1277 mConOut
.UgaRefreshRate
= 60;
1281 } else if (UgaDraw
!= NULL
) {
1282 Status
= UgaDraw
->GetMode (
1284 &mConOut
.UgaHorizontalResolution
,
1285 &mConOut
.UgaVerticalResolution
,
1286 &mConOut
.UgaColorDepth
,
1287 &mConOut
.UgaRefreshRate
1297 Start Standard Error Consplitter on device handle.
1299 @param This Driver Binding protocol instance pointer.
1300 @param ControllerHandle Handle of device to bind driver to.
1301 @param RemainingDevicePath Optional parameter use to pick a specific child
1304 @retval EFI_SUCCESS Standard Error Consplitter is added to ControllerHandle.
1305 @retval other Standard Error Consplitter does not support this device.
1310 ConSplitterStdErrDriverBindingStart (
1311 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1312 IN EFI_HANDLE ControllerHandle
,
1313 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
1317 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
;
1320 // Start ConSplitter on ControllerHandle, and create the virtual
1321 // agrogated console device on first call Start for a StandardError handle.
1323 Status
= ConSplitterStart (
1326 mStdErr
.VirtualHandle
,
1327 &gEfiStandardErrorDeviceGuid
,
1328 &gEfiSimpleTextOutProtocolGuid
,
1331 if (EFI_ERROR (Status
)) {
1336 // When new console device is added, the new mode will be set later,
1337 // so put current mode back to init state.
1339 mStdErr
.TextOutMode
.Mode
= 0xFF;
1342 // If both ConOut and StdErr incorporate the same Text Out device,
1343 // their MaxMode and QueryData should be the intersection of both.
1345 Status
= ConSplitterTextOutAddDevice (&mStdErr
, TextOut
, NULL
, NULL
);
1346 ConSplitterTextOutSetAttribute (&mStdErr
.TextOut
, EFI_TEXT_ATTR (EFI_MAGENTA
, EFI_BLACK
));
1347 if (EFI_ERROR (Status
)) {
1356 Stop ConSplitter on device handle by closing Console Device Guid on device handle
1357 and the console virtual handle.
1359 @param This Protocol instance pointer.
1360 @param ControllerHandle Handle of device.
1361 @param ConSplitterVirtualHandle Console virtual Handle.
1362 @param DeviceGuid The specified Console Device, such as ConInDev,
1364 @param InterfaceGuid The specified protocol to be opened.
1365 @param Interface Protocol interface returned.
1367 @retval EFI_SUCCESS Stop ConSplitter on ControllerHandle successfully.
1368 @retval other Failed to Stop ConSplitter on ControllerHandle.
1373 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1374 IN EFI_HANDLE ControllerHandle
,
1375 IN EFI_HANDLE ConSplitterVirtualHandle
,
1376 IN EFI_GUID
*DeviceGuid
,
1377 IN EFI_GUID
*InterfaceGuid
,
1383 Status
= gBS
->OpenProtocol (
1387 This
->DriverBindingHandle
,
1389 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1391 if (EFI_ERROR (Status
)) {
1395 // close the protocol refered.
1397 gBS
->CloseProtocol (
1400 This
->DriverBindingHandle
,
1401 ConSplitterVirtualHandle
1404 gBS
->CloseProtocol (
1407 This
->DriverBindingHandle
,
1416 Stop Console In ConSplitter on ControllerHandle by closing Console In Devcice GUID.
1418 @param This Driver Binding protocol instance pointer.
1419 @param ControllerHandle Handle of device to stop driver on
1420 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
1421 children is zero stop the entire bus driver.
1422 @param ChildHandleBuffer List of Child Handles to Stop.
1424 @retval EFI_SUCCESS This driver is removed ControllerHandle
1425 @retval other This driver was not removed from this device
1430 ConSplitterConInDriverBindingStop (
1431 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1432 IN EFI_HANDLE ControllerHandle
,
1433 IN UINTN NumberOfChildren
,
1434 IN EFI_HANDLE
*ChildHandleBuffer
1438 EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*TextIn
;
1439 EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*TextInEx
;
1441 if (NumberOfChildren
== 0) {
1445 Status
= gBS
->OpenProtocol (
1447 &gEfiSimpleTextInputExProtocolGuid
,
1448 (VOID
**) &TextInEx
,
1449 This
->DriverBindingHandle
,
1451 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1453 if (!EFI_ERROR (Status
)) {
1455 // If Simple Text Input Ex protocol exists,
1456 // remove device from Text Input Ex devices list.
1458 Status
= ConSplitterTextInExDeleteDevice (&mConIn
, TextInEx
);
1459 if (EFI_ERROR (Status
)) {
1465 // Close Simple Text In protocol on controller handle and virtual handle.
1467 Status
= ConSplitterStop (
1470 mConIn
.VirtualHandle
,
1471 &gEfiConsoleInDeviceGuid
,
1472 &gEfiSimpleTextInProtocolGuid
,
1475 if (EFI_ERROR (Status
)) {
1480 // Remove device from Text Input devices list.
1482 return ConSplitterTextInDeleteDevice (&mConIn
, TextIn
);
1487 Stop Simple Pointer protocol ConSplitter on ControllerHandle by closing
1488 Simple Pointer protocol.
1490 @param This Driver Binding protocol instance pointer.
1491 @param ControllerHandle Handle of device to stop driver on
1492 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
1493 children is zero stop the entire bus driver.
1494 @param ChildHandleBuffer List of Child Handles to Stop.
1496 @retval EFI_SUCCESS This driver is removed ControllerHandle
1497 @retval other This driver was not removed from this device
1502 ConSplitterSimplePointerDriverBindingStop (
1503 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1504 IN EFI_HANDLE ControllerHandle
,
1505 IN UINTN NumberOfChildren
,
1506 IN EFI_HANDLE
*ChildHandleBuffer
1510 EFI_SIMPLE_POINTER_PROTOCOL
*SimplePointer
;
1512 if (NumberOfChildren
== 0) {
1517 // Close Simple Pointer protocol on controller handle and virtual handle.
1519 Status
= ConSplitterStop (
1522 mConIn
.VirtualHandle
,
1523 &gEfiSimplePointerProtocolGuid
,
1524 &gEfiSimplePointerProtocolGuid
,
1525 (VOID
**) &SimplePointer
1527 if (EFI_ERROR (Status
)) {
1532 // Remove this device from Simple Pointer device list.
1534 return ConSplitterSimplePointerDeleteDevice (&mConIn
, SimplePointer
);
1539 Stop Absolute Pointer protocol ConSplitter on ControllerHandle by closing
1540 Absolute Pointer protocol.
1542 @param This Driver Binding protocol instance pointer.
1543 @param ControllerHandle Handle of device to stop driver on
1544 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
1545 children is zero stop the entire bus driver.
1546 @param ChildHandleBuffer List of Child Handles to Stop.
1548 @retval EFI_SUCCESS This driver is removed ControllerHandle
1549 @retval other This driver was not removed from this device
1554 ConSplitterAbsolutePointerDriverBindingStop (
1555 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1556 IN EFI_HANDLE ControllerHandle
,
1557 IN UINTN NumberOfChildren
,
1558 IN EFI_HANDLE
*ChildHandleBuffer
1562 EFI_ABSOLUTE_POINTER_PROTOCOL
*AbsolutePointer
;
1564 if (NumberOfChildren
== 0) {
1569 // Close Absolute Pointer protocol on controller handle and virtual handle.
1571 Status
= ConSplitterStop (
1574 mConIn
.VirtualHandle
,
1575 &gEfiAbsolutePointerProtocolGuid
,
1576 &gEfiAbsolutePointerProtocolGuid
,
1577 (VOID
**) &AbsolutePointer
1579 if (EFI_ERROR (Status
)) {
1584 // Remove this device from Absolute Pointer device list.
1586 return ConSplitterAbsolutePointerDeleteDevice (&mConIn
, AbsolutePointer
);
1591 Stop Console Out ConSplitter on device handle by closing Console Out Devcice GUID.
1593 @param This Driver Binding protocol instance pointer.
1594 @param ControllerHandle Handle of device to stop driver on
1595 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
1596 children is zero stop the entire bus driver.
1597 @param ChildHandleBuffer List of Child Handles to Stop.
1599 @retval EFI_SUCCESS This driver is removed ControllerHandle
1600 @retval other This driver was not removed from this device
1605 ConSplitterConOutDriverBindingStop (
1606 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1607 IN EFI_HANDLE ControllerHandle
,
1608 IN UINTN NumberOfChildren
,
1609 IN EFI_HANDLE
*ChildHandleBuffer
1613 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
;
1615 if (NumberOfChildren
== 0) {
1620 // Close Absolute Pointer protocol on controller handle and virtual handle.
1622 Status
= ConSplitterStop (
1625 mConOut
.VirtualHandle
,
1626 &gEfiConsoleOutDeviceGuid
,
1627 &gEfiSimpleTextOutProtocolGuid
,
1630 if (EFI_ERROR (Status
)) {
1635 // Remove this device from Text Out device list.
1637 return ConSplitterTextOutDeleteDevice (&mConOut
, TextOut
);
1642 Stop Standard Error ConSplitter on ControllerHandle by closing Standard Error GUID.
1644 @param This Driver Binding protocol instance pointer.
1645 @param ControllerHandle Handle of device to stop driver on
1646 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
1647 children is zero stop the entire bus driver.
1648 @param ChildHandleBuffer List of Child Handles to Stop.
1650 @retval EFI_SUCCESS This driver is removed ControllerHandle
1651 @retval other This driver was not removed from this device
1656 ConSplitterStdErrDriverBindingStop (
1657 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1658 IN EFI_HANDLE ControllerHandle
,
1659 IN UINTN NumberOfChildren
,
1660 IN EFI_HANDLE
*ChildHandleBuffer
1664 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
;
1666 if (NumberOfChildren
== 0) {
1671 // Close Standard Error Device on controller handle and virtual handle.
1673 Status
= ConSplitterStop (
1676 mStdErr
.VirtualHandle
,
1677 &gEfiStandardErrorDeviceGuid
,
1678 &gEfiSimpleTextOutProtocolGuid
,
1681 if (EFI_ERROR (Status
)) {
1685 // Delete this console error out device's data structures.
1687 return ConSplitterTextOutDeleteDevice (&mStdErr
, TextOut
);
1692 Take the passed in Buffer of size ElementSize and grow the buffer
1693 by CONSOLE_SPLITTER_ALLOC_UNIT * ElementSize bytes.
1694 Copy the current data in Buffer to the new version of Buffer and
1695 free the old version of buffer.
1697 @param ElementSize Size of element in array.
1698 @param Count Current number of elements in array.
1699 @param Buffer Bigger version of passed in Buffer with all the
1702 @retval EFI_SUCCESS Buffer size has grown.
1703 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
1707 ConSplitterGrowBuffer (
1708 IN UINTN ElementSize
,
1709 IN OUT UINTN
*Count
,
1710 IN OUT VOID
**Buffer
1716 // grow the buffer to new buffer size,
1717 // copy the old buffer's content to the new-size buffer,
1718 // then free the old buffer.
1720 Ptr
= ReallocatePool (
1721 ElementSize
* (*Count
),
1722 ElementSize
* ((*Count
) + CONSOLE_SPLITTER_ALLOC_UNIT
),
1726 return EFI_OUT_OF_RESOURCES
;
1728 *Count
+= CONSOLE_SPLITTER_ALLOC_UNIT
;
1735 Add Text Input Device in Consplitter Text Input list.
1737 @param Private Text In Splitter pointer.
1738 @param TextIn Simple Text Input protocol pointer.
1740 @retval EFI_SUCCESS Text Input Device added successfully.
1741 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
1745 ConSplitterTextInAddDevice (
1746 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
1747 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*TextIn
1753 // If the Text In List is full, enlarge it by calling ConSplitterGrowBuffer().
1755 if (Private
->CurrentNumberOfConsoles
>= Private
->TextInListCount
) {
1756 Status
= ConSplitterGrowBuffer (
1757 sizeof (EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*),
1758 &Private
->TextInListCount
,
1759 (VOID
**) &Private
->TextInList
1761 if (EFI_ERROR (Status
)) {
1762 return EFI_OUT_OF_RESOURCES
;
1766 // Add the new text-in device data structure into the Text In List.
1768 Private
->TextInList
[Private
->CurrentNumberOfConsoles
] = TextIn
;
1769 Private
->CurrentNumberOfConsoles
++;
1772 // Extra CheckEvent added to reduce the double CheckEvent().
1774 gBS
->CheckEvent (TextIn
->WaitForKey
);
1781 Remove Text Input Device from Consplitter Text Input list.
1783 @param Private Text In Splitter pointer.
1784 @param TextIn Simple Text protocol pointer.
1786 @retval EFI_SUCCESS Simple Text Device removed successfully.
1787 @retval EFI_NOT_FOUND No Simple Text Device found.
1791 ConSplitterTextInDeleteDevice (
1792 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
1793 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*TextIn
1798 // Remove the specified text-in device data structure from the Text In List,
1799 // and rearrange the remaining data structures in the Text In List.
1801 for (Index
= 0; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
1802 if (Private
->TextInList
[Index
] == TextIn
) {
1803 for (; Index
< Private
->CurrentNumberOfConsoles
- 1; Index
++) {
1804 Private
->TextInList
[Index
] = Private
->TextInList
[Index
+ 1];
1807 Private
->CurrentNumberOfConsoles
--;
1812 return EFI_NOT_FOUND
;
1816 Add Text Input Ex Device in Consplitter Text Input Ex list.
1818 @param Private Text In Splitter pointer.
1819 @param TextInEx Simple Text Input Ex Input protocol pointer.
1821 @retval EFI_SUCCESS Text Input Ex Device added successfully.
1822 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
1826 ConSplitterTextInExAddDevice (
1827 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
1828 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*TextInEx
1833 TEXT_IN_EX_SPLITTER_NOTIFY
*CurrentNotify
;
1834 UINTN TextInExListCount
;
1837 // Enlarge the NotifyHandleList and the TextInExList
1839 if (Private
->CurrentNumberOfExConsoles
>= Private
->TextInExListCount
) {
1840 for (Link
= Private
->NotifyList
.ForwardLink
; Link
!= &Private
->NotifyList
; Link
= Link
->ForwardLink
) {
1841 CurrentNotify
= TEXT_IN_EX_SPLITTER_NOTIFY_FROM_THIS (Link
);
1842 TextInExListCount
= Private
->TextInExListCount
;
1844 Status
= ConSplitterGrowBuffer (
1845 sizeof (EFI_HANDLE
),
1847 (VOID
**) &CurrentNotify
->NotifyHandleList
1849 if (EFI_ERROR (Status
)) {
1850 return EFI_OUT_OF_RESOURCES
;
1853 Status
= ConSplitterGrowBuffer (
1854 sizeof (EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*),
1855 &Private
->TextInExListCount
,
1856 (VOID
**) &Private
->TextInExList
1858 if (EFI_ERROR (Status
)) {
1859 return EFI_OUT_OF_RESOURCES
;
1864 // Register the key notify in the new text-in device
1866 for (Link
= Private
->NotifyList
.ForwardLink
; Link
!= &Private
->NotifyList
; Link
= Link
->ForwardLink
) {
1867 CurrentNotify
= TEXT_IN_EX_SPLITTER_NOTIFY_FROM_THIS (Link
);
1868 Status
= TextInEx
->RegisterKeyNotify (
1870 &CurrentNotify
->KeyData
,
1871 CurrentNotify
->KeyNotificationFn
,
1872 &CurrentNotify
->NotifyHandleList
[Private
->CurrentNumberOfExConsoles
]
1874 if (EFI_ERROR (Status
)) {
1875 for (Link
= Link
->BackLink
; Link
!= &Private
->NotifyList
; Link
= Link
->BackLink
) {
1876 CurrentNotify
= TEXT_IN_EX_SPLITTER_NOTIFY_FROM_THIS (Link
);
1877 TextInEx
->UnregisterKeyNotify (
1879 CurrentNotify
->NotifyHandleList
[Private
->CurrentNumberOfExConsoles
]
1887 // Add the new text-in device data structure into the Text Input Ex List.
1889 Private
->TextInExList
[Private
->CurrentNumberOfExConsoles
] = TextInEx
;
1890 Private
->CurrentNumberOfExConsoles
++;
1893 // Extra CheckEvent added to reduce the double CheckEvent().
1895 gBS
->CheckEvent (TextInEx
->WaitForKeyEx
);
1901 Remove Text Ex Device from Consplitter Text Input Ex list.
1903 @param Private Text In Splitter pointer.
1904 @param TextInEx Simple Text Ex protocol pointer.
1906 @retval EFI_SUCCESS Simple Text Input Ex Device removed successfully.
1907 @retval EFI_NOT_FOUND No Simple Text Input Ex Device found.
1911 ConSplitterTextInExDeleteDevice (
1912 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
1913 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*TextInEx
1918 // Remove the specified text-in device data structure from the Text Input Ex List,
1919 // and rearrange the remaining data structures in the Text In List.
1921 for (Index
= 0; Index
< Private
->CurrentNumberOfExConsoles
; Index
++) {
1922 if (Private
->TextInExList
[Index
] == TextInEx
) {
1923 for (; Index
< Private
->CurrentNumberOfExConsoles
- 1; Index
++) {
1924 Private
->TextInExList
[Index
] = Private
->TextInExList
[Index
+ 1];
1927 Private
->CurrentNumberOfExConsoles
--;
1932 return EFI_NOT_FOUND
;
1937 Add Simple Pointer Device in Consplitter Simple Pointer list.
1939 @param Private Text In Splitter pointer.
1940 @param SimplePointer Simple Pointer protocol pointer.
1942 @retval EFI_SUCCESS Simple Pointer Device added successfully.
1943 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
1947 ConSplitterSimplePointerAddDevice (
1948 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
1949 IN EFI_SIMPLE_POINTER_PROTOCOL
*SimplePointer
1955 // If the Simple Pointer List is full, enlarge it by calling ConSplitterGrowBuffer().
1957 if (Private
->CurrentNumberOfPointers
>= Private
->PointerListCount
) {
1958 Status
= ConSplitterGrowBuffer (
1959 sizeof (EFI_SIMPLE_POINTER_PROTOCOL
*),
1960 &Private
->PointerListCount
,
1961 (VOID
**) &Private
->PointerList
1963 if (EFI_ERROR (Status
)) {
1964 return EFI_OUT_OF_RESOURCES
;
1968 // Add the new text-in device data structure into the Simple Pointer List.
1970 Private
->PointerList
[Private
->CurrentNumberOfPointers
] = SimplePointer
;
1971 Private
->CurrentNumberOfPointers
++;
1978 Remove Simple Pointer Device from Consplitter Simple Pointer list.
1980 @param Private Text In Splitter pointer.
1981 @param SimplePointer Simple Pointer protocol pointer.
1983 @retval EFI_SUCCESS Simple Pointer Device removed successfully.
1984 @retval EFI_NOT_FOUND No Simple Pointer Device found.
1988 ConSplitterSimplePointerDeleteDevice (
1989 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
1990 IN EFI_SIMPLE_POINTER_PROTOCOL
*SimplePointer
1995 // Remove the specified text-in device data structure from the Simple Pointer List,
1996 // and rearrange the remaining data structures in the Text In List.
1998 for (Index
= 0; Index
< Private
->CurrentNumberOfPointers
; Index
++) {
1999 if (Private
->PointerList
[Index
] == SimplePointer
) {
2000 for (; Index
< Private
->CurrentNumberOfPointers
- 1; Index
++) {
2001 Private
->PointerList
[Index
] = Private
->PointerList
[Index
+ 1];
2004 Private
->CurrentNumberOfPointers
--;
2009 return EFI_NOT_FOUND
;
2014 Add Absolute Pointer Device in Consplitter Absolute Pointer list.
2016 @param Private Text In Splitter pointer.
2017 @param AbsolutePointer Absolute Pointer protocol pointer.
2019 @retval EFI_SUCCESS Absolute Pointer Device added successfully.
2020 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
2024 ConSplitterAbsolutePointerAddDevice (
2025 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
2026 IN EFI_ABSOLUTE_POINTER_PROTOCOL
*AbsolutePointer
2032 // If the Absolute Pointer List is full, enlarge it by calling ConSplitterGrowBuffer().
2034 if (Private
->CurrentNumberOfAbsolutePointers
>= Private
->AbsolutePointerListCount
) {
2035 Status
= ConSplitterGrowBuffer (
2036 sizeof (EFI_ABSOLUTE_POINTER_PROTOCOL
*),
2037 &Private
->AbsolutePointerListCount
,
2038 (VOID
**) &Private
->AbsolutePointerList
2040 if (EFI_ERROR (Status
)) {
2041 return EFI_OUT_OF_RESOURCES
;
2045 // Add the new text-in device data structure into the Absolute Pointer List.
2047 Private
->AbsolutePointerList
[Private
->CurrentNumberOfAbsolutePointers
] = AbsolutePointer
;
2048 Private
->CurrentNumberOfAbsolutePointers
++;
2055 Remove Absolute Pointer Device from Consplitter Absolute Pointer list.
2057 @param Private Text In Splitter pointer.
2058 @param AbsolutePointer Absolute Pointer protocol pointer.
2060 @retval EFI_SUCCESS Absolute Pointer Device removed successfully.
2061 @retval EFI_NOT_FOUND No Absolute Pointer Device found.
2065 ConSplitterAbsolutePointerDeleteDevice (
2066 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
2067 IN EFI_ABSOLUTE_POINTER_PROTOCOL
*AbsolutePointer
2072 // Remove the specified text-in device data structure from the Absolute Pointer List,
2073 // and rearrange the remaining data structures from the Absolute Pointer List.
2075 for (Index
= 0; Index
< Private
->CurrentNumberOfAbsolutePointers
; Index
++) {
2076 if (Private
->AbsolutePointerList
[Index
] == AbsolutePointer
) {
2077 for (; Index
< Private
->CurrentNumberOfAbsolutePointers
- 1; Index
++) {
2078 Private
->AbsolutePointerList
[Index
] = Private
->AbsolutePointerList
[Index
+ 1];
2081 Private
->CurrentNumberOfAbsolutePointers
--;
2086 return EFI_NOT_FOUND
;
2090 Reallocate Text Out mode map.
2092 Allocate new buffer and copy original buffer into the new buffer.
2094 @param Private Consplitter Text Out pointer.
2096 @retval EFI_SUCCESS Buffer size has grown
2097 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
2101 ConSplitterGrowMapTable (
2102 IN TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
2108 INT32
*TextOutModeMap
;
2109 INT32
*OldTextOutModeMap
;
2115 NewSize
= Private
->TextOutListCount
* sizeof (INT32
);
2116 OldTextOutModeMap
= Private
->TextOutModeMap
;
2117 TotalSize
= NewSize
* (Private
->TextOutQueryDataCount
);
2120 // Allocate new buffer for Text Out List.
2122 TextOutModeMap
= AllocatePool (TotalSize
);
2123 if (TextOutModeMap
== NULL
) {
2124 return EFI_OUT_OF_RESOURCES
;
2127 SetMem (TextOutModeMap
, TotalSize
, 0xFF);
2128 Private
->TextOutModeMap
= TextOutModeMap
;
2131 // If TextOutList has been enlarged, need to realloc the mode map table
2132 // The mode map table is regarded as a two dimension array.
2135 // 0 ---------> TextOutListCount ----> TextOutListCount
2136 // | -------------------------------------------
2143 // -------------------------------------------
2146 if (OldTextOutModeMap
!= NULL
) {
2148 Size
= Private
->CurrentNumberOfConsoles
* sizeof (INT32
);
2150 SrcAddress
= OldTextOutModeMap
;
2151 NewStepSize
= NewSize
/ sizeof(INT32
);
2152 // If Private->CurrentNumberOfConsoles is not zero and OldTextOutModeMap
2153 // is not NULL, it indicates that the original TextOutModeMap is not enough
2154 // for the new console devices and has been enlarged by CONSOLE_SPLITTER_ALLOC_UNIT columns.
2156 OldStepSize
= NewStepSize
- CONSOLE_SPLITTER_ALLOC_UNIT
;
2159 // Copy the old data to the new one
2161 while (Index
< Private
->TextOutMode
.MaxMode
) {
2162 CopyMem (TextOutModeMap
, SrcAddress
, Size
);
2164 // Go to next row of new TextOutModeMap.
2166 TextOutModeMap
+= NewStepSize
;
2168 // Go to next row of old TextOutModeMap.
2170 SrcAddress
+= OldStepSize
;
2174 // Free the old buffer
2176 FreePool (OldTextOutModeMap
);
2184 Add new device's output mode to console splitter's mode list.
2186 @param Private Text Out Splitter pointer
2187 @param TextOut Simple Text Output protocol pointer.
2189 @retval EFI_SUCCESS Device added successfully.
2190 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
2194 ConSplitterAddOutputMode (
2195 IN TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
,
2196 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
2204 MaxMode
= TextOut
->Mode
->MaxMode
;
2205 Private
->TextOutMode
.MaxMode
= MaxMode
;
2208 // Grow the buffer if query data buffer is not large enough to
2209 // hold all the mode supported by the first console.
2211 while (MaxMode
> (INT32
) Private
->TextOutQueryDataCount
) {
2212 Status
= ConSplitterGrowBuffer (
2213 sizeof (TEXT_OUT_SPLITTER_QUERY_DATA
),
2214 &Private
->TextOutQueryDataCount
,
2215 (VOID
**) &Private
->TextOutQueryData
2217 if (EFI_ERROR (Status
)) {
2218 return EFI_OUT_OF_RESOURCES
;
2222 // Allocate buffer for the output mode map
2224 Status
= ConSplitterGrowMapTable (Private
);
2225 if (EFI_ERROR (Status
)) {
2226 return EFI_OUT_OF_RESOURCES
;
2229 // As the first textout device, directly add the mode in to QueryData
2230 // and at the same time record the mapping between QueryData and TextOut.
2234 while (Mode
< MaxMode
) {
2235 Status
= TextOut
->QueryMode (
2238 &Private
->TextOutQueryData
[Mode
].Columns
,
2239 &Private
->TextOutQueryData
[Mode
].Rows
2242 // If mode 1 (80x50) is not supported, make sure mode 1 in TextOutQueryData
2245 if ((EFI_ERROR(Status
)) && (Mode
== 1)) {
2246 Private
->TextOutQueryData
[Mode
].Columns
= 0;
2247 Private
->TextOutQueryData
[Mode
].Rows
= 0;
2249 Private
->TextOutModeMap
[Index
] = Mode
;
2251 Index
+= Private
->TextOutListCount
;
2258 Reconstruct TextOutModeMap to get intersection of modes.
2260 This routine reconstruct TextOutModeMap to get the intersection
2261 of modes for all console out devices. Because EFI/UEFI spec require
2262 mode 0 is 80x25, mode 1 is 80x50, this routine will not check the
2263 intersection for mode 0 and mode 1.
2265 @param TextOutModeMap Current text out mode map, begin with the mode 80x25
2266 @param NewlyAddedMap New text out mode map, begin with the mode 80x25
2267 @param MapStepSize Mode step size for one console device
2268 @param NewMapStepSize New Mode step size for one console device
2269 @param MaxMode IN: Current max text mode, OUT: Updated max text mode.
2270 @param CurrentMode IN: Current text mode, OUT: Updated current text mode.
2274 ConSplitterGetIntersection (
2275 IN INT32
*TextOutModeMap
,
2276 IN INT32
*NewlyAddedMap
,
2277 IN UINTN MapStepSize
,
2278 IN UINTN NewMapStepSize
,
2279 IN OUT INT32
*MaxMode
,
2280 IN OUT INT32
*CurrentMode
2284 INT32
*CurrentMapEntry
;
2285 INT32
*NextMapEntry
;
2287 INT32 CurrentMaxMode
;
2291 // According to EFI/UEFI spec, mode 0 and mode 1 have been reserved
2292 // for 80x25 and 80x50 in Simple Text Out protocol, so don't make intersection
2293 // for mode 0 and mode 1, mode number starts from 2.
2296 CurrentMapEntry
= &TextOutModeMap
[MapStepSize
* 2];
2297 NextMapEntry
= CurrentMapEntry
;
2298 NewMapEntry
= &NewlyAddedMap
[NewMapStepSize
* 2];
2300 CurrentMaxMode
= *MaxMode
;
2301 Mode
= *CurrentMode
;
2303 while (Index
< CurrentMaxMode
) {
2304 if (*NewMapEntry
== -1) {
2306 // This mode is not supported any more. Remove it. Special care
2307 // must be taken as this remove will also affect current mode;
2309 if (Index
== *CurrentMode
) {
2311 } else if (Index
< *CurrentMode
) {
2316 if (CurrentMapEntry
!= NextMapEntry
) {
2317 CopyMem (NextMapEntry
, CurrentMapEntry
, MapStepSize
* sizeof (INT32
));
2320 NextMapEntry
+= MapStepSize
;
2323 CurrentMapEntry
+= MapStepSize
;
2324 NewMapEntry
+= NewMapStepSize
;
2328 *CurrentMode
= Mode
;
2334 Sync the 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.
2341 ConSplitterSyncOutputMode (
2342 IN TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
,
2343 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
2346 INT32 CurrentMaxMode
;
2349 INT32
*TextOutModeMap
;
2352 TEXT_OUT_SPLITTER_QUERY_DATA
*TextOutQueryData
;
2359 // Must make sure that current mode won't change even if mode number changes
2361 CurrentMaxMode
= Private
->TextOutMode
.MaxMode
;
2362 TextOutModeMap
= Private
->TextOutModeMap
;
2363 StepSize
= Private
->TextOutListCount
;
2364 TextOutQueryData
= Private
->TextOutQueryData
;
2367 // Query all the mode that the newly added TextOut supports
2370 MapTable
= TextOutModeMap
+ Private
->CurrentNumberOfConsoles
;
2371 while (Mode
< TextOut
->Mode
->MaxMode
) {
2372 Status
= TextOut
->QueryMode (TextOut
, Mode
, &Columns
, &Rows
);
2374 if (EFI_ERROR(Status
)) {
2377 // If mode 1 (80x50) is not supported, make sure mode 1 in TextOutQueryData
2380 MapTable
[StepSize
] = Mode
;
2381 TextOutQueryData
[Mode
].Columns
= 0;
2382 TextOutQueryData
[Mode
].Rows
= 0;
2388 // Search the intersection map and QueryData database to see if they intersects
2391 while (Index
< CurrentMaxMode
) {
2392 QueryMode
= *(TextOutModeMap
+ Index
* StepSize
);
2393 if ((TextOutQueryData
[QueryMode
].Rows
== Rows
) && (TextOutQueryData
[QueryMode
].Columns
== Columns
)) {
2394 MapTable
[Index
* StepSize
] = Mode
;
2402 // Now search the TextOutModeMap table to find the intersection of supported
2403 // mode between ConSplitter and the newly added device.
2405 ConSplitterGetIntersection (
2410 &Private
->TextOutMode
.MaxMode
,
2411 &Private
->TextOutMode
.Mode
2419 Sync output device between ConOut and StdErr output.
2421 @retval EFI_SUCCESS Sync implemented successfully.
2422 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
2426 ConSplitterGetIntersectionBetweenConOutAndStrErr (
2430 UINTN ConOutNumOfConsoles
;
2431 UINTN StdErrNumOfConsoles
;
2432 TEXT_OUT_AND_GOP_DATA
*ConOutTextOutList
;
2433 TEXT_OUT_AND_GOP_DATA
*StdErrTextOutList
;
2437 UINTN ConOutColumns
;
2439 UINTN StdErrColumns
;
2440 INT32 ConOutMaxMode
;
2441 INT32 StdErrMaxMode
;
2446 INT32
*ConOutModeMap
;
2447 INT32
*StdErrModeMap
;
2448 INT32
*ConOutMapTable
;
2449 INT32
*StdErrMapTable
;
2450 TEXT_OUT_SPLITTER_QUERY_DATA
*ConOutQueryData
;
2451 TEXT_OUT_SPLITTER_QUERY_DATA
*StdErrQueryData
;
2452 UINTN ConOutStepSize
;
2453 UINTN StdErrStepSize
;
2454 BOOLEAN FoundTheSameTextOut
;
2455 UINTN ConOutMapTableSize
;
2456 UINTN StdErrMapTableSize
;
2458 ConOutNumOfConsoles
= mConOut
.CurrentNumberOfConsoles
;
2459 StdErrNumOfConsoles
= mStdErr
.CurrentNumberOfConsoles
;
2460 ConOutTextOutList
= mConOut
.TextOutList
;
2461 StdErrTextOutList
= mStdErr
.TextOutList
;
2464 FoundTheSameTextOut
= FALSE
;
2465 while ((Indexi
< ConOutNumOfConsoles
) && (!FoundTheSameTextOut
)) {
2467 while (Indexj
< StdErrNumOfConsoles
) {
2468 if (ConOutTextOutList
->TextOut
== StdErrTextOutList
->TextOut
) {
2469 FoundTheSameTextOut
= TRUE
;
2474 StdErrTextOutList
++;
2478 ConOutTextOutList
++;
2481 if (!FoundTheSameTextOut
) {
2485 // Must make sure that current mode won't change even if mode number changes
2487 ConOutMaxMode
= mConOut
.TextOutMode
.MaxMode
;
2488 ConOutModeMap
= mConOut
.TextOutModeMap
;
2489 ConOutStepSize
= mConOut
.TextOutListCount
;
2490 ConOutQueryData
= mConOut
.TextOutQueryData
;
2492 StdErrMaxMode
= mStdErr
.TextOutMode
.MaxMode
;
2493 StdErrModeMap
= mStdErr
.TextOutModeMap
;
2494 StdErrStepSize
= mStdErr
.TextOutListCount
;
2495 StdErrQueryData
= mStdErr
.TextOutQueryData
;
2498 // Allocate the map table and set the map table's index to -1.
2500 ConOutMapTableSize
= ConOutMaxMode
* sizeof (INT32
);
2501 ConOutMapTable
= AllocateZeroPool (ConOutMapTableSize
);
2502 if (ConOutMapTable
== NULL
) {
2503 return EFI_OUT_OF_RESOURCES
;
2506 SetMem (ConOutMapTable
, ConOutMapTableSize
, 0xFF);
2508 StdErrMapTableSize
= StdErrMaxMode
* sizeof (INT32
);
2509 StdErrMapTable
= AllocateZeroPool (StdErrMapTableSize
);
2510 if (StdErrMapTable
== NULL
) {
2511 return EFI_OUT_OF_RESOURCES
;
2514 SetMem (StdErrMapTable
, StdErrMapTableSize
, 0xFF);
2517 // Find the intersection of the two set of modes. If they actually intersect, the
2518 // correponding entry in the map table is set to 1.
2521 while (Mode
< ConOutMaxMode
) {
2523 // Search the intersection map and QueryData database to see if they intersect
2526 ConOutMode
= *(ConOutModeMap
+ Mode
* ConOutStepSize
);
2527 ConOutRows
= ConOutQueryData
[ConOutMode
].Rows
;
2528 ConOutColumns
= ConOutQueryData
[ConOutMode
].Columns
;
2529 while (Index
< StdErrMaxMode
) {
2530 StdErrMode
= *(StdErrModeMap
+ Index
* StdErrStepSize
);
2531 StdErrRows
= StdErrQueryData
[StdErrMode
].Rows
;
2532 StdErrColumns
= StdErrQueryData
[StdErrMode
].Columns
;
2533 if ((StdErrRows
== ConOutRows
) && (StdErrColumns
== ConOutColumns
)) {
2534 ConOutMapTable
[Mode
] = 1;
2535 StdErrMapTable
[Index
] = 1;
2545 // Now search the TextOutModeMap table to find the intersection of supported
2546 // mode between ConSplitter and the newly added device.
2548 ConSplitterGetIntersection (
2551 mConOut
.TextOutListCount
,
2553 &(mConOut
.TextOutMode
.MaxMode
),
2554 &(mConOut
.TextOutMode
.Mode
)
2557 if (mConOut
.TextOutMode
.Mode
< 0) {
2558 mConOut
.TextOut
.SetMode (&(mConOut
.TextOut
), 0);
2561 ConSplitterGetIntersection (
2564 mStdErr
.TextOutListCount
,
2566 &(mStdErr
.TextOutMode
.MaxMode
),
2567 &(mStdErr
.TextOutMode
.Mode
)
2570 if (mStdErr
.TextOutMode
.Mode
< 0) {
2571 mStdErr
.TextOut
.SetMode (&(mStdErr
.TextOut
), 0);
2574 FreePool (ConOutMapTable
);
2575 FreePool (StdErrMapTable
);
2582 Add Grahpics Output modes into Consplitter Text Out list.
2584 @param Private Text Out Splitter pointer.
2585 @param GraphicsOutput Graphics Output protocol pointer.
2586 @param UgaDraw UGA Draw protocol pointer.
2588 @retval EFI_SUCCESS Output mode added successfully.
2589 @retval other Failed to add output mode.
2593 ConSplitterAddGraphicsOutputMode (
2594 IN TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
,
2595 IN EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
,
2596 IN EFI_UGA_DRAW_PROTOCOL
*UgaDraw
2602 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*Mode
;
2604 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*Info
;
2605 EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE
*CurrentGraphicsOutputMode
;
2606 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*ModeBuffer
;
2607 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*MatchedMode
;
2610 BOOLEAN AlreadyExist
;
2611 UINT32 UgaHorizontalResolution
;
2612 UINT32 UgaVerticalResolution
;
2613 UINT32 UgaColorDepth
;
2614 UINT32 UgaRefreshRate
;
2616 ASSERT (GraphicsOutput
!= NULL
|| UgaDraw
!= NULL
);
2618 CurrentGraphicsOutputMode
= Private
->GraphicsOutput
.Mode
;
2622 Status
= EFI_SUCCESS
;
2624 if (Private
->CurrentNumberOfUgaDraw
!= 0) {
2626 // If any UGA device has already been added, then there is no need to
2627 // calculate intersection of display mode of different GOP/UGA device,
2628 // since only one display mode will be exported (i.e. user-defined mode)
2633 if (GraphicsOutput
!= NULL
) {
2634 if (Private
->CurrentNumberOfGraphicsOutput
== 0) {
2636 // This is the first Graphics Output device added
2638 CurrentGraphicsOutputMode
->MaxMode
= GraphicsOutput
->Mode
->MaxMode
;
2639 CurrentGraphicsOutputMode
->Mode
= GraphicsOutput
->Mode
->Mode
;
2640 CopyMem (CurrentGraphicsOutputMode
->Info
, GraphicsOutput
->Mode
->Info
, GraphicsOutput
->Mode
->SizeOfInfo
);
2641 CurrentGraphicsOutputMode
->SizeOfInfo
= GraphicsOutput
->Mode
->SizeOfInfo
;
2642 CurrentGraphicsOutputMode
->FrameBufferBase
= GraphicsOutput
->Mode
->FrameBufferBase
;
2643 CurrentGraphicsOutputMode
->FrameBufferSize
= GraphicsOutput
->Mode
->FrameBufferSize
;
2646 // Allocate resource for the private mode buffer
2648 ModeBuffer
= AllocatePool (sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
) * GraphicsOutput
->Mode
->MaxMode
);
2649 if (ModeBuffer
== NULL
) {
2650 return EFI_OUT_OF_RESOURCES
;
2652 FreePool (Private
->GraphicsOutputModeBuffer
);
2653 Private
->GraphicsOutputModeBuffer
= ModeBuffer
;
2656 // Store all supported display modes to the private mode buffer
2659 for (Index
= 0; Index
< GraphicsOutput
->Mode
->MaxMode
; Index
++) {
2661 // The Info buffer would be allocated by callee
2663 Status
= GraphicsOutput
->QueryMode (GraphicsOutput
, (UINT32
) Index
, &SizeOfInfo
, &Info
);
2664 if (EFI_ERROR (Status
)) {
2667 ASSERT ( SizeOfInfo
<= sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
));
2668 CopyMem (Mode
, Info
, SizeOfInfo
);
2674 // Check intersection of display mode
2676 ModeBuffer
= AllocatePool (sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
) * CurrentGraphicsOutputMode
->MaxMode
);
2677 if (ModeBuffer
== NULL
) {
2678 return EFI_OUT_OF_RESOURCES
;
2681 MatchedMode
= ModeBuffer
;
2682 Mode
= &Private
->GraphicsOutputModeBuffer
[0];
2683 for (Index
= 0; Index
< CurrentGraphicsOutputMode
->MaxMode
; Index
++) {
2686 for (NumberIndex
= 0; NumberIndex
< GraphicsOutput
->Mode
->MaxMode
; NumberIndex
++) {
2688 // The Info buffer would be allocated by callee
2690 Status
= GraphicsOutput
->QueryMode (GraphicsOutput
, (UINT32
) NumberIndex
, &SizeOfInfo
, &Info
);
2691 if (EFI_ERROR (Status
)) {
2694 if ((Info
->HorizontalResolution
== Mode
->HorizontalResolution
) &&
2695 (Info
->VerticalResolution
== Mode
->VerticalResolution
)) {
2697 // If GOP device supports one mode in current mode buffer,
2698 // it will be added into matched mode buffer
2708 AlreadyExist
= FALSE
;
2711 // Check if GOP mode has been in the mode buffer, ModeBuffer = MatchedMode at begin.
2713 for (Info
= ModeBuffer
; Info
< MatchedMode
; Info
++) {
2714 if ((Info
->HorizontalResolution
== Mode
->HorizontalResolution
) &&
2715 (Info
->VerticalResolution
== Mode
->VerticalResolution
)) {
2716 AlreadyExist
= TRUE
;
2721 if (!AlreadyExist
) {
2722 CopyMem (MatchedMode
, Mode
, sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
));
2725 // Physical frame buffer is no longer available, change PixelFormat to PixelBltOnly
2727 MatchedMode
->Version
= 0;
2728 MatchedMode
->PixelFormat
= PixelBltOnly
;
2729 ZeroMem (&MatchedMode
->PixelInformation
, sizeof (EFI_PIXEL_BITMASK
));
2739 // Drop the old mode buffer, assign it to a new one
2741 FreePool (Private
->GraphicsOutputModeBuffer
);
2742 Private
->GraphicsOutputModeBuffer
= ModeBuffer
;
2745 // Physical frame buffer is no longer available when there are more than one physical GOP devices
2747 CurrentGraphicsOutputMode
->MaxMode
= (UINT32
) (((UINTN
) MatchedMode
- (UINTN
) ModeBuffer
) / sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
));
2748 CurrentGraphicsOutputMode
->Info
->PixelFormat
= PixelBltOnly
;
2749 ZeroMem (&CurrentGraphicsOutputMode
->Info
->PixelInformation
, sizeof (EFI_PIXEL_BITMASK
));
2750 CurrentGraphicsOutputMode
->SizeOfInfo
= sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
);
2751 CurrentGraphicsOutputMode
->FrameBufferBase
= (EFI_PHYSICAL_ADDRESS
) (UINTN
) NULL
;
2752 CurrentGraphicsOutputMode
->FrameBufferSize
= 0;
2756 // Graphics console driver can ensure the same mode for all GOP devices
2758 for (Index
= 0; Index
< CurrentGraphicsOutputMode
->MaxMode
; Index
++) {
2759 Mode
= &Private
->GraphicsOutputModeBuffer
[Index
];
2760 if ((Mode
->HorizontalResolution
== GraphicsOutput
->Mode
->Info
->HorizontalResolution
) &&
2761 (Mode
->VerticalResolution
== GraphicsOutput
->Mode
->Info
->VerticalResolution
)) {
2762 CurrentIndex
= Index
;
2766 if (Index
>= CurrentGraphicsOutputMode
->MaxMode
) {
2768 // if user defined mode is not found, set to default mode 800x600
2770 for (Index
= 0; Index
< CurrentGraphicsOutputMode
->MaxMode
; Index
++) {
2771 Mode
= &Private
->GraphicsOutputModeBuffer
[Index
];
2772 if ((Mode
->HorizontalResolution
== 800) && (Mode
->VerticalResolution
== 600)) {
2773 CurrentIndex
= Index
;
2778 } else if (UgaDraw
!= NULL
) {
2780 // Graphics console driver can ensure the same mode for all GOP devices
2781 // so we can get the current mode from this video device
2785 &UgaHorizontalResolution
,
2786 &UgaVerticalResolution
,
2791 CurrentGraphicsOutputMode
->MaxMode
= 1;
2792 Info
= CurrentGraphicsOutputMode
->Info
;
2794 Info
->HorizontalResolution
= UgaHorizontalResolution
;
2795 Info
->VerticalResolution
= UgaVerticalResolution
;
2796 Info
->PixelFormat
= PixelBltOnly
;
2797 Info
->PixelsPerScanLine
= UgaHorizontalResolution
;
2798 CurrentGraphicsOutputMode
->SizeOfInfo
= sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
);
2799 CurrentGraphicsOutputMode
->FrameBufferBase
= (EFI_PHYSICAL_ADDRESS
) (UINTN
) NULL
;
2800 CurrentGraphicsOutputMode
->FrameBufferSize
= 0;
2803 // Update the private mode buffer
2805 CopyMem (&Private
->GraphicsOutputModeBuffer
[0], Info
, sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
));
2808 // Only mode 0 is available to be set
2815 if (GraphicsOutput
!= NULL
) {
2816 Private
->CurrentNumberOfGraphicsOutput
++;
2818 if (UgaDraw
!= NULL
) {
2819 Private
->CurrentNumberOfUgaDraw
++;
2823 // Force GraphicsOutput mode to be set,
2826 Mode
= &Private
->GraphicsOutputModeBuffer
[CurrentIndex
];
2827 if ((GraphicsOutput
!= NULL
) &&
2828 (Mode
->HorizontalResolution
== CurrentGraphicsOutputMode
->Info
->HorizontalResolution
) &&
2829 (Mode
->VerticalResolution
== CurrentGraphicsOutputMode
->Info
->VerticalResolution
)) {
2830 CurrentGraphicsOutputMode
->Mode
= (UINT32
) CurrentIndex
;
2831 if ((Mode
->HorizontalResolution
!= GraphicsOutput
->Mode
->Info
->HorizontalResolution
) ||
2832 (Mode
->VerticalResolution
!= GraphicsOutput
->Mode
->Info
->VerticalResolution
)) {
2834 // If all existing video device has been set to common mode, only set new GOP device to
2837 for (NumberIndex
= 0; NumberIndex
< GraphicsOutput
->Mode
->MaxMode
; NumberIndex
++) {
2838 Status
= GraphicsOutput
->QueryMode (GraphicsOutput
, (UINT32
) NumberIndex
, &SizeOfInfo
, &Info
);
2839 if (EFI_ERROR (Status
)) {
2842 if ((Info
->HorizontalResolution
== Mode
->HorizontalResolution
) && (Info
->VerticalResolution
== Mode
->VerticalResolution
)) {
2848 Status
= GraphicsOutput
->SetMode (GraphicsOutput
, (UINT32
) NumberIndex
);
2852 // Current mode number may need update now, so set it to an invalid mode number
2854 CurrentGraphicsOutputMode
->Mode
= 0xffff;
2856 // Graphics console can ensure all GOP devices have the same mode which can be taken as current mode.
2858 Status
= Private
->GraphicsOutput
.SetMode (&Private
->GraphicsOutput
, (UINT32
) CurrentIndex
);
2859 if (EFI_ERROR(Status
)) {
2861 // If user defined mode is not valid for display device, set to the default mode 800x600.
2863 (Private
->GraphicsOutputModeBuffer
[0]).HorizontalResolution
= 800;
2864 (Private
->GraphicsOutputModeBuffer
[0]).VerticalResolution
= 600;
2865 Status
= Private
->GraphicsOutput
.SetMode (&Private
->GraphicsOutput
, 0);
2873 Set the current console out mode.
2875 This routine will get the current console mode information (column, row)
2876 from ConsoleOutMode variable and set it; if the variable does not exist,
2877 set to user defined console mode.
2879 @param Private Consplitter Text Out pointer.
2883 ConsplitterSetConsoleOutMode (
2884 IN TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
2894 CONSOLE_OUT_MODE ModeInfo
;
2895 CONSOLE_OUT_MODE MaxModeInfo
;
2896 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
;
2900 TextOut
= &Private
->TextOut
;
2901 MaxMode
= (UINTN
) (TextOut
->Mode
->MaxMode
);
2903 MaxModeInfo
.Column
= 0;
2904 MaxModeInfo
.Row
= 0;
2905 ModeInfo
.Column
= PcdGet32 (PcdConOutColumn
);
2906 ModeInfo
.Row
= PcdGet32 (PcdConOutRow
);
2909 // To find the prefer mode and basic mode from Text Out mode list
2911 for (Mode
= 0; Mode
< MaxMode
; Mode
++) {
2912 Status
= TextOut
->QueryMode (TextOut
, Mode
, &Col
, &Row
);
2913 if (!EFI_ERROR(Status
)) {
2914 if ((ModeInfo
.Column
!= 0) && (ModeInfo
.Row
!= 0)) {
2916 // Use user defined column and row
2918 if (Col
== ModeInfo
.Column
&& Row
== ModeInfo
.Row
) {
2923 // If user sets PcdConOutColumn or PcdConOutRow to 0,
2924 // find and set the highest text mode.
2926 if ((Col
>= MaxModeInfo
.Column
) && (Row
>= MaxModeInfo
.Row
)) {
2927 MaxModeInfo
.Column
= Col
;
2928 MaxModeInfo
.Row
= Row
;
2932 if (Col
== 80 && Row
== 25) {
2939 // Set prefer mode to Text Out devices.
2941 Status
= TextOut
->SetMode (TextOut
, PreferMode
);
2942 if (EFI_ERROR(Status
)) {
2944 // if current mode setting is failed, default 80x25 mode will be set.
2946 Status
= TextOut
->SetMode (TextOut
, BaseMode
);
2947 ASSERT(!EFI_ERROR(Status
));
2949 Status
= PcdSet32S (PcdConOutColumn
, 80);
2950 ASSERT(!EFI_ERROR(Status
));
2951 Status
= PcdSet32S (PcdConOutRow
, 25);
2952 ASSERT(!EFI_ERROR(Status
));
2960 Add Text Output Device in Consplitter Text Output list.
2962 @param Private Text Out Splitter pointer.
2963 @param TextOut Simple Text Output protocol pointer.
2964 @param GraphicsOutput Graphics Output protocol pointer.
2965 @param UgaDraw UGA Draw protocol pointer.
2967 @retval EFI_SUCCESS Text Output Device added successfully.
2968 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
2972 ConSplitterTextOutAddDevice (
2973 IN TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
,
2974 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
,
2975 IN EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
,
2976 IN EFI_UGA_DRAW_PROTOCOL
*UgaDraw
2980 UINTN CurrentNumOfConsoles
;
2982 UINT32 UgaHorizontalResolution
;
2983 UINT32 UgaVerticalResolution
;
2984 UINT32 UgaColorDepth
;
2985 UINT32 UgaRefreshRate
;
2986 TEXT_OUT_AND_GOP_DATA
*TextAndGop
;
2988 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*Info
;
2989 EFI_STATUS DeviceStatus
;
2991 Status
= EFI_SUCCESS
;
2992 CurrentNumOfConsoles
= Private
->CurrentNumberOfConsoles
;
2995 // If the Text Out List is full, enlarge it by calling ConSplitterGrowBuffer().
2997 while (CurrentNumOfConsoles
>= Private
->TextOutListCount
) {
2998 Status
= ConSplitterGrowBuffer (
2999 sizeof (TEXT_OUT_AND_GOP_DATA
),
3000 &Private
->TextOutListCount
,
3001 (VOID
**) &Private
->TextOutList
3003 if (EFI_ERROR (Status
)) {
3004 return EFI_OUT_OF_RESOURCES
;
3007 // Also need to reallocate the TextOutModeMap table
3009 Status
= ConSplitterGrowMapTable (Private
);
3010 if (EFI_ERROR (Status
)) {
3011 return EFI_OUT_OF_RESOURCES
;
3015 TextAndGop
= &Private
->TextOutList
[CurrentNumOfConsoles
];
3017 TextAndGop
->TextOut
= TextOut
;
3018 TextAndGop
->GraphicsOutput
= GraphicsOutput
;
3019 TextAndGop
->UgaDraw
= UgaDraw
;
3021 if (CurrentNumOfConsoles
== 0) {
3023 // Add the first device's output mode to console splitter's mode list
3025 Status
= ConSplitterAddOutputMode (Private
, TextOut
);
3027 ConSplitterSyncOutputMode (Private
, TextOut
);
3030 Private
->CurrentNumberOfConsoles
++;
3033 // Scan both TextOutList, for the intersection TextOut device
3034 // maybe both ConOut and StdErr incorporate the same Text Out
3035 // device in them, thus the output of both should be synced.
3037 ConSplitterGetIntersectionBetweenConOutAndStrErr ();
3039 MaxMode
= Private
->TextOutMode
.MaxMode
;
3040 ASSERT (MaxMode
>= 1);
3042 DeviceStatus
= EFI_DEVICE_ERROR
;
3043 Status
= EFI_DEVICE_ERROR
;
3046 // This device display mode will be added into Graphics Ouput modes.
3048 if ((GraphicsOutput
!= NULL
) || (UgaDraw
!= NULL
)) {
3049 DeviceStatus
= ConSplitterAddGraphicsOutputMode (Private
, GraphicsOutput
, UgaDraw
);
3052 if (FeaturePcdGet (PcdConOutUgaSupport
)) {
3054 // If UGA is produced by Consplitter
3056 if (GraphicsOutput
!= NULL
) {
3057 Status
= GraphicsOutput
->QueryMode (GraphicsOutput
, GraphicsOutput
->Mode
->Mode
, &SizeOfInfo
, &Info
);
3058 if (EFI_ERROR (Status
)) {
3061 ASSERT ( SizeOfInfo
<= sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
));
3063 UgaHorizontalResolution
= Info
->HorizontalResolution
;
3064 UgaVerticalResolution
= Info
->VerticalResolution
;
3068 } else if (UgaDraw
!= NULL
) {
3069 Status
= UgaDraw
->GetMode (
3071 &UgaHorizontalResolution
,
3072 &UgaVerticalResolution
,
3076 if (!EFI_ERROR (Status
) && EFI_ERROR (DeviceStatus
)) {
3078 // if GetMode is successfully and UGA device hasn't been set, set it
3080 Status
= ConSplitterUgaDrawSetMode (
3082 UgaHorizontalResolution
,
3083 UgaVerticalResolution
,
3089 // If GetMode/SetMode is failed, set to 800x600 mode
3091 if(EFI_ERROR (Status
)) {
3092 Status
= ConSplitterUgaDrawSetMode (
3103 if (((!EFI_ERROR (DeviceStatus
)) || (!EFI_ERROR (Status
))) &&
3104 ((Private
->CurrentNumberOfGraphicsOutput
+ Private
->CurrentNumberOfUgaDraw
) == 1)) {
3105 if (!FeaturePcdGet (PcdConOutGopSupport
)) {
3107 // If Graphics Outpurt protocol not supported, UGA Draw protocol is installed
3108 // on the virtual handle.
3110 Status
= gBS
->InstallMultipleProtocolInterfaces (
3111 &mConOut
.VirtualHandle
,
3112 &gEfiUgaDrawProtocolGuid
,
3116 } else if (!FeaturePcdGet (PcdConOutUgaSupport
)) {
3118 // If UGA Draw protocol not supported, Graphics Output Protocol is installed
3119 // on virtual handle.
3121 Status
= gBS
->InstallMultipleProtocolInterfaces (
3122 &mConOut
.VirtualHandle
,
3123 &gEfiGraphicsOutputProtocolGuid
,
3124 &mConOut
.GraphicsOutput
,
3129 // Boot Graphics Output protocol and UGA Draw protocol are supported,
3130 // both they will be installed on virtual handle.
3132 Status
= gBS
->InstallMultipleProtocolInterfaces (
3133 &mConOut
.VirtualHandle
,
3134 &gEfiGraphicsOutputProtocolGuid
,
3135 &mConOut
.GraphicsOutput
,
3136 &gEfiUgaDrawProtocolGuid
,
3144 // After adding new console device, all existing console devices should be
3145 // synced to the current shared mode.
3147 ConsplitterSetConsoleOutMode (Private
);
3154 Remove Text Out Device in Consplitter Text Out list.
3156 @param Private Text Out Splitter pointer.
3157 @param TextOut Simple Text Output Pointer protocol pointer.
3159 @retval EFI_SUCCESS Text Out Device removed successfully.
3160 @retval EFI_NOT_FOUND No Text Out Device found.
3164 ConSplitterTextOutDeleteDevice (
3165 IN TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
,
3166 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
3170 UINTN CurrentNumOfConsoles
;
3171 TEXT_OUT_AND_GOP_DATA
*TextOutList
;
3175 // Remove the specified text-out device data structure from the Text out List,
3176 // and rearrange the remaining data structures in the Text out List.
3178 CurrentNumOfConsoles
= Private
->CurrentNumberOfConsoles
;
3179 Index
= (INT32
) CurrentNumOfConsoles
- 1;
3180 TextOutList
= Private
->TextOutList
;
3181 while (Index
>= 0) {
3182 if (TextOutList
->TextOut
== TextOut
) {
3183 if (TextOutList
->UgaDraw
!= NULL
) {
3184 Private
->CurrentNumberOfUgaDraw
--;
3186 if (TextOutList
->GraphicsOutput
!= NULL
) {
3187 Private
->CurrentNumberOfGraphicsOutput
--;
3189 CopyMem (TextOutList
, TextOutList
+ 1, sizeof (TEXT_OUT_AND_GOP_DATA
) * Index
);
3190 CurrentNumOfConsoles
--;
3198 // The specified TextOut is not managed by the ConSplitter driver
3201 return EFI_NOT_FOUND
;
3204 if ((Private
->CurrentNumberOfGraphicsOutput
== 0) && (Private
->CurrentNumberOfUgaDraw
== 0)) {
3206 // If there is not any physical GOP and UGA device in system,
3207 // Consplitter GOP or UGA protocol will be uninstalled
3209 if (!FeaturePcdGet (PcdConOutGopSupport
)) {
3210 Status
= gBS
->UninstallProtocolInterface (
3211 Private
->VirtualHandle
,
3212 &gEfiUgaDrawProtocolGuid
,
3215 } else if (!FeaturePcdGet (PcdConOutUgaSupport
)) {
3216 Status
= gBS
->UninstallProtocolInterface (
3217 Private
->VirtualHandle
,
3218 &gEfiGraphicsOutputProtocolGuid
,
3219 &Private
->GraphicsOutput
3222 Status
= gBS
->UninstallMultipleProtocolInterfaces (
3223 Private
->VirtualHandle
,
3224 &gEfiUgaDrawProtocolGuid
,
3226 &gEfiGraphicsOutputProtocolGuid
,
3227 &Private
->GraphicsOutput
,
3233 if (CurrentNumOfConsoles
== 0) {
3235 // If the number of consoles is zero, reset all parameters
3237 Private
->CurrentNumberOfConsoles
= 0;
3238 Private
->TextOutMode
.MaxMode
= 1;
3239 Private
->TextOutQueryData
[0].Columns
= 80;
3240 Private
->TextOutQueryData
[0].Rows
= 25;
3241 TextOutSetMode (Private
, 0);
3246 // Max Mode is realy an intersection of the QueryMode command to all
3247 // devices. So we must copy the QueryMode of the first device to
3251 Private
->TextOutQueryData
,
3252 Private
->TextOutQueryDataCount
* sizeof (TEXT_OUT_SPLITTER_QUERY_DATA
)
3255 FreePool (Private
->TextOutModeMap
);
3256 Private
->TextOutModeMap
= NULL
;
3257 TextOutList
= Private
->TextOutList
;
3260 // Add the first TextOut to the QueryData array and ModeMap table
3262 Status
= ConSplitterAddOutputMode (Private
, TextOutList
->TextOut
);
3265 // Now add one by one
3268 Private
->CurrentNumberOfConsoles
= 1;
3270 while ((UINTN
) Index
< CurrentNumOfConsoles
) {
3271 ConSplitterSyncOutputMode (Private
, TextOutList
->TextOut
);
3273 Private
->CurrentNumberOfConsoles
++;
3277 ConSplitterGetIntersectionBetweenConOutAndStrErr ();
3284 Reset the input device and optionaly run diagnostics
3286 @param This Protocol instance pointer.
3287 @param ExtendedVerification Driver may perform diagnostics on reset.
3289 @retval EFI_SUCCESS The device was reset.
3290 @retval EFI_DEVICE_ERROR The device is not functioning properly and could
3296 ConSplitterTextInReset (
3297 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*This
,
3298 IN BOOLEAN ExtendedVerification
3302 EFI_STATUS ReturnStatus
;
3303 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3306 Private
= TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
3308 Private
->KeyEventSignalState
= FALSE
;
3311 // return the worst status met
3313 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
3314 Status
= Private
->TextInList
[Index
]->Reset (
3315 Private
->TextInList
[Index
],
3316 ExtendedVerification
3318 if (EFI_ERROR (Status
)) {
3319 ReturnStatus
= Status
;
3323 return ReturnStatus
;
3328 Reads the next keystroke from the input device. The WaitForKey Event can
3329 be used to test for existance of a keystroke via WaitForEvent () call.
3331 @param Private Protocol instance pointer.
3332 @param Key Driver may perform diagnostics on reset.
3334 @retval EFI_SUCCESS The keystroke information was returned.
3335 @retval EFI_NOT_READY There was no keystroke data availiable.
3336 @retval EFI_DEVICE_ERROR The keydtroke information was not returned due
3342 ConSplitterTextInPrivateReadKeyStroke (
3343 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
3344 OUT EFI_INPUT_KEY
*Key
3349 EFI_INPUT_KEY CurrentKey
;
3351 Key
->UnicodeChar
= 0;
3352 Key
->ScanCode
= SCAN_NULL
;
3355 // if no physical console input device exists, return EFI_NOT_READY;
3356 // if any physical console input device has key input,
3357 // return the key and EFI_SUCCESS.
3359 for (Index
= 0; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
3360 Status
= Private
->TextInList
[Index
]->ReadKeyStroke (
3361 Private
->TextInList
[Index
],
3364 if (!EFI_ERROR (Status
)) {
3370 return EFI_NOT_READY
;
3376 Reads the next keystroke from the input device. The WaitForKey Event can
3377 be used to test for existance of a keystroke via WaitForEvent () call.
3379 @param This Protocol instance pointer.
3380 @param Key Driver may perform diagnostics on reset.
3382 @retval EFI_SUCCESS The keystroke information was returned.
3383 @retval EFI_NOT_READY There was no keystroke data availiable.
3384 @retval EFI_DEVICE_ERROR The keydtroke information was not returned due
3390 ConSplitterTextInReadKeyStroke (
3391 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*This
,
3392 OUT EFI_INPUT_KEY
*Key
3395 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3397 Private
= TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
3399 Private
->KeyEventSignalState
= FALSE
;
3402 // Signal ConnectConIn event on first call in Lazy ConIn mode
3404 if (!mConInIsConnect
&& PcdGetBool (PcdConInConnectOnDemand
)) {
3405 DEBUG ((EFI_D_INFO
, "Connect ConIn in first ReadKeyStoke in Lazy ConIn mode.\n"));
3406 gBS
->SignalEvent (Private
->ConnectConInEvent
);
3407 mConInIsConnect
= TRUE
;
3410 return ConSplitterTextInPrivateReadKeyStroke (Private
, Key
);
3415 This event aggregates all the events of the ConIn devices in the spliter.
3417 If any events of physical ConIn devices are signaled, signal the ConIn
3418 spliter event. This will cause the calling code to call
3419 ConSplitterTextInReadKeyStroke ().
3421 @param Event The Event assoicated with callback.
3422 @param Context Context registered when Event was created.
3427 ConSplitterTextInWaitForKey (
3433 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3436 Private
= (TEXT_IN_SPLITTER_PRIVATE_DATA
*) Context
;
3438 if (Private
->KeyEventSignalState
) {
3440 // If KeyEventSignalState is flagged before, and not cleared by Reset() or ReadKeyStroke()
3442 gBS
->SignalEvent (Event
);
3447 // If any physical console input device has key input, signal the event.
3449 for (Index
= 0; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
3450 Status
= gBS
->CheckEvent (Private
->TextInList
[Index
]->WaitForKey
);
3451 if (!EFI_ERROR (Status
)) {
3452 gBS
->SignalEvent (Event
);
3453 Private
->KeyEventSignalState
= TRUE
;
3461 Test if the key has been registered on input device.
3463 @param RegsiteredData A pointer to a buffer that is filled in with the
3464 keystroke state data for the key that was
3466 @param InputData A pointer to a buffer that is filled in with the
3467 keystroke state data for the key that was
3470 @retval TRUE Key be pressed matches a registered key.
3471 @retval FLASE Match failed.
3476 IN EFI_KEY_DATA
*RegsiteredData
,
3477 IN EFI_KEY_DATA
*InputData
3480 ASSERT (RegsiteredData
!= NULL
&& InputData
!= NULL
);
3482 if ((RegsiteredData
->Key
.ScanCode
!= InputData
->Key
.ScanCode
) ||
3483 (RegsiteredData
->Key
.UnicodeChar
!= InputData
->Key
.UnicodeChar
)) {
3488 // Assume KeyShiftState/KeyToggleState = 0 in Registered key data means these state could be ignored.
3490 if (RegsiteredData
->KeyState
.KeyShiftState
!= 0 &&
3491 RegsiteredData
->KeyState
.KeyShiftState
!= InputData
->KeyState
.KeyShiftState
) {
3494 if (RegsiteredData
->KeyState
.KeyToggleState
!= 0 &&
3495 RegsiteredData
->KeyState
.KeyToggleState
!= InputData
->KeyState
.KeyToggleState
) {
3505 Reset the input device and optionaly run diagnostics
3507 @param This Protocol instance pointer.
3508 @param ExtendedVerification Driver may perform diagnostics on reset.
3510 @retval EFI_SUCCESS The device was reset.
3511 @retval EFI_DEVICE_ERROR The device is not functioning properly and could
3517 ConSplitterTextInResetEx (
3518 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*This
,
3519 IN BOOLEAN ExtendedVerification
3523 EFI_STATUS ReturnStatus
;
3524 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3527 Private
= TEXT_IN_EX_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
3529 Private
->KeyEventSignalState
= FALSE
;
3532 // return the worst status met
3534 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfExConsoles
; Index
++) {
3535 Status
= Private
->TextInExList
[Index
]->Reset (
3536 Private
->TextInExList
[Index
],
3537 ExtendedVerification
3539 if (EFI_ERROR (Status
)) {
3540 ReturnStatus
= Status
;
3544 return ReturnStatus
;
3550 Reads the next keystroke from the input device. The WaitForKey Event can
3551 be used to test for existance of a keystroke via WaitForEvent () call.
3553 @param This Protocol instance pointer.
3554 @param KeyData A pointer to a buffer that is filled in with the
3555 keystroke state data for the key that was
3558 @retval EFI_SUCCESS The keystroke information was returned.
3559 @retval EFI_NOT_READY There was no keystroke data availiable.
3560 @retval EFI_DEVICE_ERROR The keystroke information was not returned due
3562 @retval EFI_INVALID_PARAMETER KeyData is NULL.
3567 ConSplitterTextInReadKeyStrokeEx (
3568 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*This
,
3569 OUT EFI_KEY_DATA
*KeyData
3572 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3575 EFI_KEY_DATA CurrentKeyData
;
3578 if (KeyData
== NULL
) {
3579 return EFI_INVALID_PARAMETER
;
3582 Private
= TEXT_IN_EX_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
3584 Private
->KeyEventSignalState
= FALSE
;
3586 KeyData
->Key
.UnicodeChar
= 0;
3587 KeyData
->Key
.ScanCode
= SCAN_NULL
;
3590 // Signal ConnectConIn event on first call in Lazy ConIn mode
3592 if (!mConInIsConnect
&& PcdGetBool (PcdConInConnectOnDemand
)) {
3593 DEBUG ((EFI_D_INFO
, "Connect ConIn in first ReadKeyStoke in Lazy ConIn mode.\n"));
3594 gBS
->SignalEvent (Private
->ConnectConInEvent
);
3595 mConInIsConnect
= TRUE
;
3599 // if no physical console input device exists, return EFI_NOT_READY;
3600 // if any physical console input device has key input,
3601 // return the key and EFI_SUCCESS.
3603 for (Index
= 0; Index
< Private
->CurrentNumberOfExConsoles
; Index
++) {
3604 Status
= Private
->TextInExList
[Index
]->ReadKeyStrokeEx (
3605 Private
->TextInExList
[Index
],
3608 if (!EFI_ERROR (Status
)) {
3609 CopyMem (KeyData
, &CurrentKeyData
, sizeof (CurrentKeyData
));
3614 return EFI_NOT_READY
;
3619 Set certain state for the input device.
3621 @param This Protocol instance pointer.
3622 @param KeyToggleState A pointer to the EFI_KEY_TOGGLE_STATE to set the
3623 state for the input device.
3625 @retval EFI_SUCCESS The device state was set successfully.
3626 @retval EFI_DEVICE_ERROR The device is not functioning correctly and
3627 could not have the setting adjusted.
3628 @retval EFI_UNSUPPORTED The device does not have the ability to set its
3630 @retval EFI_INVALID_PARAMETER KeyToggleState is NULL.
3635 ConSplitterTextInSetState (
3636 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*This
,
3637 IN EFI_KEY_TOGGLE_STATE
*KeyToggleState
3640 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3644 if (KeyToggleState
== NULL
) {
3645 return EFI_INVALID_PARAMETER
;
3648 Private
= TEXT_IN_EX_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
3651 // if no physical console input device exists, return EFI_SUCCESS;
3652 // otherwise return the status of setting state of physical console input device
3654 for (Index
= 0; Index
< Private
->CurrentNumberOfExConsoles
; Index
++) {
3655 Status
= Private
->TextInExList
[Index
]->SetState (
3656 Private
->TextInExList
[Index
],
3659 if (EFI_ERROR (Status
)) {
3670 Register a notification function for a particular keystroke for the input device.
3672 @param This Protocol instance pointer.
3673 @param KeyData A pointer to a buffer that is filled in with the
3674 keystroke information data for the key that was
3676 @param KeyNotificationFunction Points to the function to be called when the key
3677 sequence is typed specified by KeyData.
3678 @param NotifyHandle Points to the unique handle assigned to the
3679 registered notification.
3681 @retval EFI_SUCCESS The notification function was registered
3683 @retval EFI_OUT_OF_RESOURCES Unable to allocate resources for necesssary data
3685 @retval EFI_INVALID_PARAMETER KeyData or KeyNotificationFunction or NotifyHandle is NULL.
3690 ConSplitterTextInRegisterKeyNotify (
3691 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*This
,
3692 IN EFI_KEY_DATA
*KeyData
,
3693 IN EFI_KEY_NOTIFY_FUNCTION KeyNotificationFunction
,
3694 OUT VOID
**NotifyHandle
3697 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3700 TEXT_IN_EX_SPLITTER_NOTIFY
*NewNotify
;
3702 TEXT_IN_EX_SPLITTER_NOTIFY
*CurrentNotify
;
3705 if (KeyData
== NULL
|| NotifyHandle
== NULL
|| KeyNotificationFunction
== NULL
) {
3706 return EFI_INVALID_PARAMETER
;
3709 Private
= TEXT_IN_EX_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
3712 // Return EFI_SUCCESS if the (KeyData, NotificationFunction) is already registered.
3714 for (Link
= Private
->NotifyList
.ForwardLink
; Link
!= &Private
->NotifyList
; Link
= Link
->ForwardLink
) {
3715 CurrentNotify
= TEXT_IN_EX_SPLITTER_NOTIFY_FROM_THIS (Link
);
3716 if (IsKeyRegistered (&CurrentNotify
->KeyData
, KeyData
)) {
3717 if (CurrentNotify
->KeyNotificationFn
== KeyNotificationFunction
) {
3718 *NotifyHandle
= CurrentNotify
;
3725 // Allocate resource to save the notification function
3727 NewNotify
= (TEXT_IN_EX_SPLITTER_NOTIFY
*) AllocateZeroPool (sizeof (TEXT_IN_EX_SPLITTER_NOTIFY
));
3728 if (NewNotify
== NULL
) {
3729 return EFI_OUT_OF_RESOURCES
;
3731 NewNotify
->NotifyHandleList
= (EFI_HANDLE
*) AllocateZeroPool (sizeof (EFI_HANDLE
) * Private
->TextInExListCount
);
3732 if (NewNotify
->NotifyHandleList
== NULL
) {
3733 gBS
->FreePool (NewNotify
);
3734 return EFI_OUT_OF_RESOURCES
;
3736 NewNotify
->Signature
= TEXT_IN_EX_SPLITTER_NOTIFY_SIGNATURE
;
3737 NewNotify
->KeyNotificationFn
= KeyNotificationFunction
;
3738 CopyMem (&NewNotify
->KeyData
, KeyData
, sizeof (EFI_KEY_DATA
));
3741 // Return the wrong status of registering key notify of
3742 // physical console input device if meet problems
3744 for (Index
= 0; Index
< Private
->CurrentNumberOfExConsoles
; Index
++) {
3745 Status
= Private
->TextInExList
[Index
]->RegisterKeyNotify (
3746 Private
->TextInExList
[Index
],
3748 KeyNotificationFunction
,
3749 &NewNotify
->NotifyHandleList
[Index
]
3751 if (EFI_ERROR (Status
)) {
3753 // Un-register the key notify on all physical console input devices
3755 while (Index
-- != 0) {
3756 Private
->TextInExList
[Index
]->UnregisterKeyNotify (
3757 Private
->TextInExList
[Index
],
3758 NewNotify
->NotifyHandleList
[Index
]
3761 gBS
->FreePool (NewNotify
->NotifyHandleList
);
3762 gBS
->FreePool (NewNotify
);
3767 InsertTailList (&mConIn
.NotifyList
, &NewNotify
->NotifyEntry
);
3769 *NotifyHandle
= NewNotify
;
3777 Remove a registered notification function from a particular keystroke.
3779 @param This Protocol instance pointer.
3780 @param NotificationHandle The handle of the notification function being
3783 @retval EFI_SUCCESS The notification function was unregistered
3785 @retval EFI_INVALID_PARAMETER The NotificationHandle is invalid.
3790 ConSplitterTextInUnregisterKeyNotify (
3791 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*This
,
3792 IN VOID
*NotificationHandle
3795 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3797 TEXT_IN_EX_SPLITTER_NOTIFY
*CurrentNotify
;
3800 if (NotificationHandle
== NULL
) {
3801 return EFI_INVALID_PARAMETER
;
3804 Private
= TEXT_IN_EX_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
3806 for (Link
= Private
->NotifyList
.ForwardLink
; Link
!= &Private
->NotifyList
; Link
= Link
->ForwardLink
) {
3807 CurrentNotify
= TEXT_IN_EX_SPLITTER_NOTIFY_FROM_THIS (Link
);
3808 if (CurrentNotify
== NotificationHandle
) {
3809 for (Index
= 0; Index
< Private
->CurrentNumberOfExConsoles
; Index
++) {
3810 Private
->TextInExList
[Index
]->UnregisterKeyNotify (
3811 Private
->TextInExList
[Index
],
3812 CurrentNotify
->NotifyHandleList
[Index
]
3815 RemoveEntryList (&CurrentNotify
->NotifyEntry
);
3817 gBS
->FreePool (CurrentNotify
->NotifyHandleList
);
3818 gBS
->FreePool (CurrentNotify
);
3824 // NotificationHandle is not found in database
3826 return EFI_INVALID_PARAMETER
;
3831 Reset the input device and optionaly run diagnostics
3833 @param This Protocol instance pointer.
3834 @param ExtendedVerification Driver may perform diagnostics on reset.
3836 @retval EFI_SUCCESS The device was reset.
3837 @retval EFI_DEVICE_ERROR The device is not functioning properly and could
3843 ConSplitterSimplePointerReset (
3844 IN EFI_SIMPLE_POINTER_PROTOCOL
*This
,
3845 IN BOOLEAN ExtendedVerification
3849 EFI_STATUS ReturnStatus
;
3850 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3853 Private
= TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_SIMPLE_POINTER_THIS (This
);
3855 Private
->InputEventSignalState
= FALSE
;
3857 if (Private
->CurrentNumberOfPointers
== 0) {
3861 // return the worst status met
3863 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfPointers
; Index
++) {
3864 Status
= Private
->PointerList
[Index
]->Reset (
3865 Private
->PointerList
[Index
],
3866 ExtendedVerification
3868 if (EFI_ERROR (Status
)) {
3869 ReturnStatus
= Status
;
3873 return ReturnStatus
;
3878 Reads the next keystroke from the input device. The WaitForKey Event can
3879 be used to test for existance of a keystroke via WaitForEvent () call.
3881 @param Private Protocol instance pointer.
3882 @param State The state information of simple pointer device.
3884 @retval EFI_SUCCESS The keystroke information was returned.
3885 @retval EFI_NOT_READY There was no keystroke data availiable.
3886 @retval EFI_DEVICE_ERROR The keydtroke information was not returned due
3892 ConSplitterSimplePointerPrivateGetState (
3893 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
3894 IN OUT EFI_SIMPLE_POINTER_STATE
*State
3898 EFI_STATUS ReturnStatus
;
3900 EFI_SIMPLE_POINTER_STATE CurrentState
;
3902 State
->RelativeMovementX
= 0;
3903 State
->RelativeMovementY
= 0;
3904 State
->RelativeMovementZ
= 0;
3905 State
->LeftButton
= FALSE
;
3906 State
->RightButton
= FALSE
;
3909 // if no physical console input device exists, return EFI_NOT_READY;
3910 // if any physical console input device has key input,
3911 // return the key and EFI_SUCCESS.
3913 ReturnStatus
= EFI_NOT_READY
;
3914 for (Index
= 0; Index
< Private
->CurrentNumberOfPointers
; Index
++) {
3916 Status
= Private
->PointerList
[Index
]->GetState (
3917 Private
->PointerList
[Index
],
3920 if (!EFI_ERROR (Status
)) {
3921 if (ReturnStatus
== EFI_NOT_READY
) {
3922 ReturnStatus
= EFI_SUCCESS
;
3925 if (CurrentState
.LeftButton
) {
3926 State
->LeftButton
= TRUE
;
3929 if (CurrentState
.RightButton
) {
3930 State
->RightButton
= TRUE
;
3933 if (CurrentState
.RelativeMovementX
!= 0 && Private
->PointerList
[Index
]->Mode
->ResolutionX
!= 0) {
3934 State
->RelativeMovementX
+= (CurrentState
.RelativeMovementX
* (INT32
) Private
->SimplePointerMode
.ResolutionX
) / (INT32
) Private
->PointerList
[Index
]->Mode
->ResolutionX
;
3937 if (CurrentState
.RelativeMovementY
!= 0 && Private
->PointerList
[Index
]->Mode
->ResolutionY
!= 0) {
3938 State
->RelativeMovementY
+= (CurrentState
.RelativeMovementY
* (INT32
) Private
->SimplePointerMode
.ResolutionY
) / (INT32
) Private
->PointerList
[Index
]->Mode
->ResolutionY
;
3941 if (CurrentState
.RelativeMovementZ
!= 0 && Private
->PointerList
[Index
]->Mode
->ResolutionZ
!= 0) {
3942 State
->RelativeMovementZ
+= (CurrentState
.RelativeMovementZ
* (INT32
) Private
->SimplePointerMode
.ResolutionZ
) / (INT32
) Private
->PointerList
[Index
]->Mode
->ResolutionZ
;
3944 } else if (Status
== EFI_DEVICE_ERROR
) {
3945 ReturnStatus
= EFI_DEVICE_ERROR
;
3949 return ReturnStatus
;
3954 Reads the next keystroke from the input device. The WaitForKey Event can
3955 be used to test for existance of a keystroke via WaitForEvent () call.
3957 @param This A pointer to protocol instance.
3958 @param State A pointer to state information on the pointer device
3960 @retval EFI_SUCCESS The keystroke information was returned in State.
3961 @retval EFI_NOT_READY There was no keystroke data availiable.
3962 @retval EFI_DEVICE_ERROR The keydtroke information was not returned due
3968 ConSplitterSimplePointerGetState (
3969 IN EFI_SIMPLE_POINTER_PROTOCOL
*This
,
3970 IN OUT EFI_SIMPLE_POINTER_STATE
*State
3973 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3975 Private
= TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_SIMPLE_POINTER_THIS (This
);
3977 Private
->InputEventSignalState
= FALSE
;
3979 return ConSplitterSimplePointerPrivateGetState (Private
, State
);
3984 This event agregates all the events of the ConIn devices in the spliter.
3985 If any events of physical ConIn devices are signaled, signal the ConIn
3986 spliter event. This will cause the calling code to call
3987 ConSplitterTextInReadKeyStroke ().
3989 @param Event The Event assoicated with callback.
3990 @param Context Context registered when Event was created.
3995 ConSplitterSimplePointerWaitForInput (
4001 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
4004 Private
= (TEXT_IN_SPLITTER_PRIVATE_DATA
*) Context
;
4007 // if InputEventSignalState is flagged before, and not cleared by Reset() or ReadKeyStroke()
4009 if (Private
->InputEventSignalState
) {
4010 gBS
->SignalEvent (Event
);
4014 // if any physical console input device has key input, signal the event.
4016 for (Index
= 0; Index
< Private
->CurrentNumberOfPointers
; Index
++) {
4017 Status
= gBS
->CheckEvent (Private
->PointerList
[Index
]->WaitForInput
);
4018 if (!EFI_ERROR (Status
)) {
4019 gBS
->SignalEvent (Event
);
4020 Private
->InputEventSignalState
= TRUE
;
4026 Resets the pointer device hardware.
4028 @param This Protocol instance pointer.
4029 @param ExtendedVerification Driver may perform diagnostics on reset.
4031 @retval EFI_SUCCESS The device was reset.
4032 @retval EFI_DEVICE_ERROR The device is not functioning correctly and
4038 ConSplitterAbsolutePointerReset (
4039 IN EFI_ABSOLUTE_POINTER_PROTOCOL
*This
,
4040 IN BOOLEAN ExtendedVerification
4044 EFI_STATUS ReturnStatus
;
4045 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
4048 Private
= TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_ABSOLUTE_POINTER_THIS (This
);
4050 Private
->AbsoluteInputEventSignalState
= FALSE
;
4052 if (Private
->CurrentNumberOfAbsolutePointers
== 0) {
4056 // return the worst status met
4058 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfAbsolutePointers
; Index
++) {
4059 Status
= Private
->AbsolutePointerList
[Index
]->Reset (
4060 Private
->AbsolutePointerList
[Index
],
4061 ExtendedVerification
4063 if (EFI_ERROR (Status
)) {
4064 ReturnStatus
= Status
;
4068 return ReturnStatus
;
4073 Retrieves the current state of a pointer device.
4075 @param This Protocol instance pointer.
4076 @param State A pointer to the state information on the
4079 @retval EFI_SUCCESS The state of the pointer device was returned in
4081 @retval EFI_NOT_READY The state of the pointer device has not changed
4082 since the last call to GetState().
4083 @retval EFI_DEVICE_ERROR A device error occurred while attempting to
4084 retrieve the pointer device's current state.
4089 ConSplitterAbsolutePointerGetState (
4090 IN EFI_ABSOLUTE_POINTER_PROTOCOL
*This
,
4091 IN OUT EFI_ABSOLUTE_POINTER_STATE
*State
4094 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
4096 EFI_STATUS ReturnStatus
;
4098 EFI_ABSOLUTE_POINTER_STATE CurrentState
;
4101 Private
= TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_ABSOLUTE_POINTER_THIS (This
);
4103 Private
->AbsoluteInputEventSignalState
= FALSE
;
4105 State
->CurrentX
= 0;
4106 State
->CurrentY
= 0;
4107 State
->CurrentZ
= 0;
4108 State
->ActiveButtons
= 0;
4111 // if no physical pointer device exists, return EFI_NOT_READY;
4112 // if any physical pointer device has changed state,
4113 // return the state and EFI_SUCCESS.
4115 ReturnStatus
= EFI_NOT_READY
;
4116 for (Index
= 0; Index
< Private
->CurrentNumberOfAbsolutePointers
; Index
++) {
4118 Status
= Private
->AbsolutePointerList
[Index
]->GetState (
4119 Private
->AbsolutePointerList
[Index
],
4122 if (!EFI_ERROR (Status
)) {
4123 if (ReturnStatus
== EFI_NOT_READY
) {
4124 ReturnStatus
= EFI_SUCCESS
;
4127 State
->ActiveButtons
= CurrentState
.ActiveButtons
;
4129 if (!(Private
->AbsolutePointerMode
.AbsoluteMinX
== 0 && Private
->AbsolutePointerMode
.AbsoluteMaxX
== 0)) {
4130 State
->CurrentX
= CurrentState
.CurrentX
;
4132 if (!(Private
->AbsolutePointerMode
.AbsoluteMinY
== 0 && Private
->AbsolutePointerMode
.AbsoluteMaxY
== 0)) {
4133 State
->CurrentY
= CurrentState
.CurrentY
;
4135 if (!(Private
->AbsolutePointerMode
.AbsoluteMinZ
== 0 && Private
->AbsolutePointerMode
.AbsoluteMaxZ
== 0)) {
4136 State
->CurrentZ
= CurrentState
.CurrentZ
;
4139 } else if (Status
== EFI_DEVICE_ERROR
) {
4140 ReturnStatus
= EFI_DEVICE_ERROR
;
4144 return ReturnStatus
;
4149 This event agregates all the events of the pointer devices in the splitter.
4150 If any events of physical pointer devices are signaled, signal the pointer
4151 splitter event. This will cause the calling code to call
4152 ConSplitterAbsolutePointerGetState ().
4154 @param Event The Event assoicated with callback.
4155 @param Context Context registered when Event was created.
4160 ConSplitterAbsolutePointerWaitForInput (
4166 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
4169 Private
= (TEXT_IN_SPLITTER_PRIVATE_DATA
*) Context
;
4172 // if AbsoluteInputEventSignalState is flagged before,
4173 // and not cleared by Reset() or GetState(), signal it
4175 if (Private
->AbsoluteInputEventSignalState
) {
4176 gBS
->SignalEvent (Event
);
4180 // if any physical console input device has key input, signal the event.
4182 for (Index
= 0; Index
< Private
->CurrentNumberOfAbsolutePointers
; Index
++) {
4183 Status
= gBS
->CheckEvent (Private
->AbsolutePointerList
[Index
]->WaitForInput
);
4184 if (!EFI_ERROR (Status
)) {
4185 gBS
->SignalEvent (Event
);
4186 Private
->AbsoluteInputEventSignalState
= TRUE
;
4193 Reset the text output device hardware and optionaly run diagnostics
4195 @param This Protocol instance pointer.
4196 @param ExtendedVerification Driver may perform more exhaustive verfication
4197 operation of the device during reset.
4199 @retval EFI_SUCCESS The text output device was reset.
4200 @retval EFI_DEVICE_ERROR The text output device is not functioning
4201 correctly and could not be reset.
4206 ConSplitterTextOutReset (
4207 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4208 IN BOOLEAN ExtendedVerification
4212 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4214 EFI_STATUS ReturnStatus
;
4216 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4219 // return the worst status met
4221 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
4222 Status
= Private
->TextOutList
[Index
].TextOut
->Reset (
4223 Private
->TextOutList
[Index
].TextOut
,
4224 ExtendedVerification
4226 if (EFI_ERROR (Status
)) {
4227 ReturnStatus
= Status
;
4231 This
->SetAttribute (This
, EFI_TEXT_ATTR (This
->Mode
->Attribute
& 0x0F, EFI_BLACK
));
4234 // reset all mode parameters
4236 TextOutSetMode (Private
, 0);
4238 return ReturnStatus
;
4243 Write a Unicode string to the output device.
4245 @param This Protocol instance pointer.
4246 @param WString The NULL-terminated Unicode string to be
4247 displayed on the output device(s). All output
4248 devices must also support the Unicode drawing
4249 defined in this file.
4251 @retval EFI_SUCCESS The string was output to the device.
4252 @retval EFI_DEVICE_ERROR The device reported an error while attempting to
4254 @retval EFI_UNSUPPORTED The output device's mode is not currently in a
4256 @retval EFI_WARN_UNKNOWN_GLYPH This warning code indicates that some of the
4257 characters in the Unicode string could not be
4258 rendered and were skipped.
4263 ConSplitterTextOutOutputString (
4264 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4269 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4271 EFI_STATUS ReturnStatus
;
4275 This
->SetAttribute (This
, This
->Mode
->Attribute
);
4277 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4280 // return the worst status met
4282 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
4283 Status
= Private
->TextOutList
[Index
].TextOut
->OutputString (
4284 Private
->TextOutList
[Index
].TextOut
,
4287 if (EFI_ERROR (Status
)) {
4288 ReturnStatus
= Status
;
4292 if (Private
->CurrentNumberOfConsoles
> 0) {
4293 Private
->TextOutMode
.CursorColumn
= Private
->TextOutList
[0].TextOut
->Mode
->CursorColumn
;
4294 Private
->TextOutMode
.CursorRow
= Private
->TextOutList
[0].TextOut
->Mode
->CursorRow
;
4297 // When there is no real console devices in system,
4298 // update cursor position for the virtual device in consplitter.
4300 Private
->TextOut
.QueryMode (
4302 Private
->TextOutMode
.Mode
,
4306 for (; *WString
!= CHAR_NULL
; WString
++) {
4308 case CHAR_BACKSPACE
:
4309 if (Private
->TextOutMode
.CursorColumn
== 0 && Private
->TextOutMode
.CursorRow
> 0) {
4310 Private
->TextOutMode
.CursorRow
--;
4311 Private
->TextOutMode
.CursorColumn
= (INT32
) (MaxColumn
- 1);
4312 } else if (Private
->TextOutMode
.CursorColumn
> 0) {
4313 Private
->TextOutMode
.CursorColumn
--;
4318 if (Private
->TextOutMode
.CursorRow
< (INT32
) (MaxRow
- 1)) {
4319 Private
->TextOutMode
.CursorRow
++;
4323 case CHAR_CARRIAGE_RETURN
:
4324 Private
->TextOutMode
.CursorColumn
= 0;
4328 if (Private
->TextOutMode
.CursorColumn
< (INT32
) (MaxColumn
- 1)) {
4329 Private
->TextOutMode
.CursorColumn
++;
4331 Private
->TextOutMode
.CursorColumn
= 0;
4332 if (Private
->TextOutMode
.CursorRow
< (INT32
) (MaxRow
- 1)) {
4333 Private
->TextOutMode
.CursorRow
++;
4341 return ReturnStatus
;
4346 Verifies that all characters in a Unicode string can be output to the
4349 @param This Protocol instance pointer.
4350 @param WString The NULL-terminated Unicode string to be
4351 examined for the output device(s).
4353 @retval EFI_SUCCESS The device(s) are capable of rendering the
4355 @retval EFI_UNSUPPORTED Some of the characters in the Unicode string
4356 cannot be rendered by one or more of the output
4357 devices mapped by the EFI handle.
4362 ConSplitterTextOutTestString (
4363 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4368 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4370 EFI_STATUS ReturnStatus
;
4372 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4375 // return the worst status met
4377 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
4378 Status
= Private
->TextOutList
[Index
].TextOut
->TestString (
4379 Private
->TextOutList
[Index
].TextOut
,
4382 if (EFI_ERROR (Status
)) {
4383 ReturnStatus
= Status
;
4387 // There is no DevNullTextOutTestString () since a Unicode buffer would
4388 // always return EFI_SUCCESS.
4389 // ReturnStatus will be EFI_SUCCESS if no consoles are present
4391 return ReturnStatus
;
4396 Returns information for an available text mode that the output device(s)
4399 @param This Protocol instance pointer.
4400 @param ModeNumber The mode number to return information on.
4401 @param Columns Returns the columns of the text output device
4402 for the requested ModeNumber.
4403 @param Rows Returns the rows of the text output device
4404 for the requested ModeNumber.
4406 @retval EFI_SUCCESS The requested mode information was returned.
4407 @retval EFI_DEVICE_ERROR The device had an error and could not complete
4409 @retval EFI_UNSUPPORTED The mode number was not valid.
4414 ConSplitterTextOutQueryMode (
4415 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4416 IN UINTN ModeNumber
,
4421 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4423 INT32
*TextOutModeMap
;
4425 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4428 // Check whether param ModeNumber is valid.
4429 // ModeNumber should be within range 0 ~ MaxMode - 1.
4431 if ( (ModeNumber
> (UINTN
)(((UINT32
)-1)>>1)) ) {
4432 return EFI_UNSUPPORTED
;
4435 if ((INT32
) ModeNumber
>= This
->Mode
->MaxMode
) {
4436 return EFI_UNSUPPORTED
;
4440 // We get the available mode from mode intersection map if it's available
4442 if (Private
->TextOutModeMap
!= NULL
) {
4443 TextOutModeMap
= Private
->TextOutModeMap
+ Private
->TextOutListCount
* ModeNumber
;
4444 CurrentMode
= (UINTN
)(*TextOutModeMap
);
4445 *Columns
= Private
->TextOutQueryData
[CurrentMode
].Columns
;
4446 *Rows
= Private
->TextOutQueryData
[CurrentMode
].Rows
;
4448 *Columns
= Private
->TextOutQueryData
[ModeNumber
].Columns
;
4449 *Rows
= Private
->TextOutQueryData
[ModeNumber
].Rows
;
4452 if (*Columns
<= 0 && *Rows
<= 0) {
4453 return EFI_UNSUPPORTED
;
4462 Sets the output device(s) to a specified mode.
4464 @param This Protocol instance pointer.
4465 @param ModeNumber The mode number to set.
4467 @retval EFI_SUCCESS The requested text mode was set.
4468 @retval EFI_DEVICE_ERROR The device had an error and could not complete
4470 @retval EFI_UNSUPPORTED The mode number was not valid.
4475 ConSplitterTextOutSetMode (
4476 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4481 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4483 INT32
*TextOutModeMap
;
4484 EFI_STATUS ReturnStatus
;
4486 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4489 // Check whether param ModeNumber is valid.
4490 // ModeNumber should be within range 0 ~ MaxMode - 1.
4492 if ( (ModeNumber
> (UINTN
)(((UINT32
)-1)>>1)) ) {
4493 return EFI_UNSUPPORTED
;
4496 if ((INT32
) ModeNumber
>= This
->Mode
->MaxMode
) {
4497 return EFI_UNSUPPORTED
;
4500 // If the mode is being set to the curent mode, then just clear the screen and return.
4502 if (Private
->TextOutMode
.Mode
== (INT32
) ModeNumber
) {
4503 return ConSplitterTextOutClearScreen (This
);
4506 // return the worst status met
4508 TextOutModeMap
= Private
->TextOutModeMap
+ Private
->TextOutListCount
* ModeNumber
;
4509 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
4510 Status
= Private
->TextOutList
[Index
].TextOut
->SetMode (
4511 Private
->TextOutList
[Index
].TextOut
,
4512 TextOutModeMap
[Index
]
4514 if (EFI_ERROR (Status
)) {
4515 ReturnStatus
= Status
;
4520 // Set mode parameter to specified mode number
4522 TextOutSetMode (Private
, ModeNumber
);
4524 return ReturnStatus
;
4529 Sets the background and foreground colors for the OutputString () and
4530 ClearScreen () functions.
4532 @param This Protocol instance pointer.
4533 @param Attribute The attribute to set. Bits 0..3 are the
4534 foreground color, and bits 4..6 are the
4535 background color. All other bits are undefined
4536 and must be zero. The valid Attributes are
4537 defined in this file.
4539 @retval EFI_SUCCESS The attribute was set.
4540 @retval EFI_DEVICE_ERROR The device had an error and could not complete
4542 @retval EFI_UNSUPPORTED The attribute requested is not defined.
4547 ConSplitterTextOutSetAttribute (
4548 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4553 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4555 EFI_STATUS ReturnStatus
;
4557 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4560 // Check whether param Attribute is valid.
4562 if ((Attribute
| 0x7F) != 0x7F) {
4563 return EFI_UNSUPPORTED
;
4567 // return the worst status met
4569 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
4570 Status
= Private
->TextOutList
[Index
].TextOut
->SetAttribute (
4571 Private
->TextOutList
[Index
].TextOut
,
4574 if (EFI_ERROR (Status
)) {
4575 ReturnStatus
= Status
;
4579 Private
->TextOutMode
.Attribute
= (INT32
) Attribute
;
4581 return ReturnStatus
;
4586 Clears the output device(s) display to the currently selected background
4589 @param This Protocol instance pointer.
4591 @retval EFI_SUCCESS The operation completed successfully.
4592 @retval EFI_DEVICE_ERROR The device had an error and could not complete
4594 @retval EFI_UNSUPPORTED The output device is not in a valid text mode.
4599 ConSplitterTextOutClearScreen (
4600 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
4604 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4606 EFI_STATUS ReturnStatus
;
4608 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4611 // return the worst status met
4613 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
4614 Status
= Private
->TextOutList
[Index
].TextOut
->ClearScreen (Private
->TextOutList
[Index
].TextOut
);
4615 if (EFI_ERROR (Status
)) {
4616 ReturnStatus
= Status
;
4621 // No need to do extra check here as whether (Column, Row) is valid has
4622 // been checked in ConSplitterTextOutSetCursorPosition. And (0, 0) should
4623 // always be supported.
4625 Private
->TextOutMode
.CursorColumn
= 0;
4626 Private
->TextOutMode
.CursorRow
= 0;
4627 Private
->TextOutMode
.CursorVisible
= TRUE
;
4629 return ReturnStatus
;
4634 Sets the current coordinates of the cursor position
4636 @param This Protocol instance pointer.
4637 @param Column The column position to set the cursor to. Must be
4638 greater than or equal to zero and less than the
4639 number of columns by QueryMode ().
4640 @param Row The row position to set the cursor to. Must be
4641 greater than or equal to zero and less than the
4642 number of rows by QueryMode ().
4644 @retval EFI_SUCCESS The operation completed successfully.
4645 @retval EFI_DEVICE_ERROR The device had an error and could not complete
4647 @retval EFI_UNSUPPORTED The output device is not in a valid text mode,
4648 or the cursor position is invalid for the
4654 ConSplitterTextOutSetCursorPosition (
4655 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4661 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4663 EFI_STATUS ReturnStatus
;
4666 INT32
*TextOutModeMap
;
4670 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4671 TextOutModeMap
= NULL
;
4672 ModeNumber
= Private
->TextOutMode
.Mode
;
4675 // Get current MaxColumn and MaxRow from intersection map
4677 if (Private
->TextOutModeMap
!= NULL
) {
4678 TextOutModeMap
= Private
->TextOutModeMap
+ Private
->TextOutListCount
* ModeNumber
;
4679 CurrentMode
= *TextOutModeMap
;
4681 CurrentMode
= ModeNumber
;
4684 MaxColumn
= Private
->TextOutQueryData
[CurrentMode
].Columns
;
4685 MaxRow
= Private
->TextOutQueryData
[CurrentMode
].Rows
;
4687 if (Column
>= MaxColumn
|| Row
>= MaxRow
) {
4688 return EFI_UNSUPPORTED
;
4691 // return the worst status met
4693 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
4694 Status
= Private
->TextOutList
[Index
].TextOut
->SetCursorPosition (
4695 Private
->TextOutList
[Index
].TextOut
,
4699 if (EFI_ERROR (Status
)) {
4700 ReturnStatus
= Status
;
4705 // No need to do extra check here as whether (Column, Row) is valid has
4706 // been checked in ConSplitterTextOutSetCursorPosition. And (0, 0) should
4707 // always be supported.
4709 Private
->TextOutMode
.CursorColumn
= (INT32
) Column
;
4710 Private
->TextOutMode
.CursorRow
= (INT32
) Row
;
4712 return ReturnStatus
;
4717 Makes the cursor visible or invisible
4719 @param This Protocol instance pointer.
4720 @param Visible If TRUE, the cursor is set to be visible. If
4721 FALSE, the cursor is set to be invisible.
4723 @retval EFI_SUCCESS The operation completed successfully.
4724 @retval EFI_DEVICE_ERROR The device had an error and could not complete
4725 the request, or the device does not support
4726 changing the cursor mode.
4727 @retval EFI_UNSUPPORTED The output device is not in a valid text mode.
4732 ConSplitterTextOutEnableCursor (
4733 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4738 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4740 EFI_STATUS ReturnStatus
;
4742 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4745 // return the worst status met
4747 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
4748 Status
= Private
->TextOutList
[Index
].TextOut
->EnableCursor (
4749 Private
->TextOutList
[Index
].TextOut
,
4752 if (EFI_ERROR (Status
)) {
4753 ReturnStatus
= Status
;
4757 Private
->TextOutMode
.CursorVisible
= Visible
;
4759 return ReturnStatus
;
4764 An empty function to pass error checking of CreateEventEx ().
4766 @param Event Event whose notification function is being invoked.
4767 @param Context Pointer to the notification function's context,
4768 which is implementation-dependent.
4773 ConSplitterEmptyCallbackFunction (