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 - 2012, 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 if (!FeaturePcdGet (PcdConOutGopSupport
)) {
423 // If Graphics Outpurt protocol not supported, UGA Draw protocol is installed
424 // on the virtual handle.
426 Status
= gBS
->InstallMultipleProtocolInterfaces (
427 &mConOut
.VirtualHandle
,
428 &gEfiSimpleTextOutProtocolGuid
,
430 &gEfiUgaDrawProtocolGuid
,
434 } else if (!FeaturePcdGet (PcdConOutUgaSupport
)) {
436 // If UGA Draw protocol not supported, Graphics Output Protocol is installed
437 // on virtual handle.
439 Status
= gBS
->InstallMultipleProtocolInterfaces (
440 &mConOut
.VirtualHandle
,
441 &gEfiSimpleTextOutProtocolGuid
,
443 &gEfiGraphicsOutputProtocolGuid
,
444 &mConOut
.GraphicsOutput
,
449 // Boot Graphics Output protocol and UGA Draw protocol are supported,
450 // both they will be installed on virtual handle.
452 Status
= gBS
->InstallMultipleProtocolInterfaces (
453 &mConOut
.VirtualHandle
,
454 &gEfiSimpleTextOutProtocolGuid
,
456 &gEfiGraphicsOutputProtocolGuid
,
457 &mConOut
.GraphicsOutput
,
458 &gEfiUgaDrawProtocolGuid
,
464 if (!EFI_ERROR (Status
)) {
466 // Update the EFI System Table with new virtual console
467 // and Update the pointer to Text Output protocol.
469 gST
->ConsoleOutHandle
= mConOut
.VirtualHandle
;
470 gST
->ConOut
= &mConOut
.TextOut
;
476 // Create virtual device handle for StdErr Splitter
478 Status
= ConSplitterTextOutConstructor (&mStdErr
);
479 if (!EFI_ERROR (Status
)) {
480 Status
= gBS
->InstallMultipleProtocolInterfaces (
481 &mStdErr
.VirtualHandle
,
482 &gEfiSimpleTextOutProtocolGuid
,
486 if (!EFI_ERROR (Status
)) {
488 // Update the EFI System Table with new virtual console
489 // and update the pointer to Text Output protocol.
491 gST
->StandardErrorHandle
= mStdErr
.VirtualHandle
;
492 gST
->StdErr
= &mStdErr
.TextOut
;
497 // Update the CRC32 in the EFI System Table header
500 gBS
->CalculateCrc32 (
511 Construct console input devices' private data.
513 @param ConInPrivate A pointer to the TEXT_IN_SPLITTER_PRIVATE_DATA
516 @retval EFI_OUT_OF_RESOURCES Out of resources.
517 @retval EFI_SUCCESS Text Input Devcie's private data has been constructed.
518 @retval other Failed to construct private data.
522 ConSplitterTextInConstructor (
523 TEXT_IN_SPLITTER_PRIVATE_DATA
*ConInPrivate
529 // Allocate buffer for Simple Text Input device
531 Status
= ConSplitterGrowBuffer (
532 sizeof (EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*),
533 &ConInPrivate
->TextInListCount
,
534 (VOID
**) &ConInPrivate
->TextInList
536 if (EFI_ERROR (Status
)) {
537 return EFI_OUT_OF_RESOURCES
;
541 // Create Event to wait for a key
543 Status
= gBS
->CreateEvent (
546 ConSplitterTextInWaitForKey
,
548 &ConInPrivate
->TextIn
.WaitForKey
550 ASSERT_EFI_ERROR (Status
);
553 // Allocate buffer for Simple Text Input Ex device
555 Status
= ConSplitterGrowBuffer (
556 sizeof (EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*),
557 &ConInPrivate
->TextInExListCount
,
558 (VOID
**) &ConInPrivate
->TextInExList
560 if (EFI_ERROR (Status
)) {
561 return EFI_OUT_OF_RESOURCES
;
564 // Create Event to wait for a key Ex
566 Status
= gBS
->CreateEvent (
569 ConSplitterTextInWaitForKey
,
571 &ConInPrivate
->TextInEx
.WaitForKeyEx
573 ASSERT_EFI_ERROR (Status
);
575 InitializeListHead (&ConInPrivate
->NotifyList
);
577 ConInPrivate
->AbsolutePointer
.Mode
= &ConInPrivate
->AbsolutePointerMode
;
579 // Allocate buffer for Absolute Pointer device
581 Status
= ConSplitterGrowBuffer (
582 sizeof (EFI_ABSOLUTE_POINTER_PROTOCOL
*),
583 &ConInPrivate
->AbsolutePointerListCount
,
584 (VOID
**) &ConInPrivate
->AbsolutePointerList
586 if (EFI_ERROR (Status
)) {
587 return EFI_OUT_OF_RESOURCES
;
590 // Create Event to wait for device input for Absolute pointer device
592 Status
= gBS
->CreateEvent (
595 ConSplitterAbsolutePointerWaitForInput
,
597 &ConInPrivate
->AbsolutePointer
.WaitForInput
599 ASSERT_EFI_ERROR (Status
);
601 ConInPrivate
->SimplePointer
.Mode
= &ConInPrivate
->SimplePointerMode
;
603 // Allocate buffer for Simple Pointer device
605 Status
= ConSplitterGrowBuffer (
606 sizeof (EFI_SIMPLE_POINTER_PROTOCOL
*),
607 &ConInPrivate
->PointerListCount
,
608 (VOID
**) &ConInPrivate
->PointerList
610 if (EFI_ERROR (Status
)) {
611 return EFI_OUT_OF_RESOURCES
;
614 // Create Event to wait for device input for Simple pointer device
616 Status
= gBS
->CreateEvent (
619 ConSplitterSimplePointerWaitForInput
,
621 &ConInPrivate
->SimplePointer
.WaitForInput
623 ASSERT_EFI_ERROR (Status
);
625 // Create Event to signal ConIn connection request
627 Status
= gBS
->CreateEventEx (
630 ConSplitterEmptyCallbackFunction
,
632 &gConnectConInEventGuid
,
633 &ConInPrivate
->ConnectConIn
640 Construct console output devices' private data.
642 @param ConOutPrivate A pointer to the TEXT_OUT_SPLITTER_PRIVATE_DATA
645 @retval EFI_OUT_OF_RESOURCES Out of resources.
646 @retval EFI_SUCCESS Text Input Devcie's private data has been constructed.
650 ConSplitterTextOutConstructor (
651 TEXT_OUT_SPLITTER_PRIVATE_DATA
*ConOutPrivate
655 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*Info
;
658 // Copy protocols template
660 if (FeaturePcdGet (PcdConOutUgaSupport
)) {
661 CopyMem (&ConOutPrivate
->UgaDraw
, &mUgaDrawProtocolTemplate
, sizeof (EFI_UGA_DRAW_PROTOCOL
));
663 if (FeaturePcdGet (PcdConOutGopSupport
)) {
664 CopyMem (&ConOutPrivate
->GraphicsOutput
, &mGraphicsOutputProtocolTemplate
, sizeof (EFI_GRAPHICS_OUTPUT_PROTOCOL
));
668 // Initilize console output splitter's private data.
670 ConOutPrivate
->TextOut
.Mode
= &ConOutPrivate
->TextOutMode
;
673 // When new console device is added, the new mode will be set later,
674 // so put current mode back to init state.
676 ConOutPrivate
->TextOutMode
.Mode
= 0xFF;
678 // Allocate buffer for Console Out device
680 Status
= ConSplitterGrowBuffer (
681 sizeof (TEXT_OUT_AND_GOP_DATA
),
682 &ConOutPrivate
->TextOutListCount
,
683 (VOID
**) &ConOutPrivate
->TextOutList
685 if (EFI_ERROR (Status
)) {
686 return EFI_OUT_OF_RESOURCES
;
689 // Allocate buffer for Text Out query data
691 Status
= ConSplitterGrowBuffer (
692 sizeof (TEXT_OUT_SPLITTER_QUERY_DATA
),
693 &ConOutPrivate
->TextOutQueryDataCount
,
694 (VOID
**) &ConOutPrivate
->TextOutQueryData
696 if (EFI_ERROR (Status
)) {
697 return EFI_OUT_OF_RESOURCES
;
701 // Setup the default console to 80 x 25 and mode to 0
703 ConOutPrivate
->TextOutQueryData
[0].Columns
= 80;
704 ConOutPrivate
->TextOutQueryData
[0].Rows
= 25;
705 TextOutSetMode (ConOutPrivate
, 0);
708 if (FeaturePcdGet (PcdConOutUgaSupport
)) {
710 // Setup the UgaDraw to 800 x 600 x 32 bits per pixel, 60Hz.
712 ConSplitterUgaDrawSetMode (&ConOutPrivate
->UgaDraw
, 800, 600, 32, 60);
714 if (FeaturePcdGet (PcdConOutGopSupport
)) {
716 // Setup resource for mode information in Graphics Output Protocol interface
718 if ((ConOutPrivate
->GraphicsOutput
.Mode
= AllocateZeroPool (sizeof (EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE
))) == NULL
) {
719 return EFI_OUT_OF_RESOURCES
;
721 if ((ConOutPrivate
->GraphicsOutput
.Mode
->Info
= AllocateZeroPool (sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
))) == NULL
) {
722 return EFI_OUT_OF_RESOURCES
;
725 // Setup the DevNullGraphicsOutput to 800 x 600 x 32 bits per pixel
726 // DevNull will be updated to user-defined mode after driver has started.
728 if ((ConOutPrivate
->GraphicsOutputModeBuffer
= AllocateZeroPool (sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
))) == NULL
) {
729 return EFI_OUT_OF_RESOURCES
;
731 Info
= &ConOutPrivate
->GraphicsOutputModeBuffer
[0];
733 Info
->HorizontalResolution
= 800;
734 Info
->VerticalResolution
= 600;
735 Info
->PixelFormat
= PixelBltOnly
;
736 Info
->PixelsPerScanLine
= 800;
737 CopyMem (ConOutPrivate
->GraphicsOutput
.Mode
->Info
, Info
, sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
));
738 ConOutPrivate
->GraphicsOutput
.Mode
->SizeOfInfo
= sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
);
741 // Initialize the following items, theset items remain unchanged in GraphicsOutput->SetMode()
742 // GraphicsOutputMode->FrameBufferBase, GraphicsOutputMode->FrameBufferSize
744 ConOutPrivate
->GraphicsOutput
.Mode
->FrameBufferBase
= (EFI_PHYSICAL_ADDRESS
) (UINTN
) NULL
;
745 ConOutPrivate
->GraphicsOutput
.Mode
->FrameBufferSize
= 0;
747 ConOutPrivate
->GraphicsOutput
.Mode
->MaxMode
= 1;
749 // Initial current mode to unknown state, and then set to mode 0
751 ConOutPrivate
->GraphicsOutput
.Mode
->Mode
= 0xffff;
752 ConOutPrivate
->GraphicsOutput
.SetMode (&ConOutPrivate
->GraphicsOutput
, 0);
760 Test to see if the specified protocol could be supported on the specified device.
762 @param This Driver Binding protocol pointer.
763 @param ControllerHandle Handle of device to test.
764 @param Guid The specified protocol.
766 @retval EFI_SUCCESS The specified protocol is supported on this device.
767 @retval EFI_UNSUPPORTED The specified protocol attempts to be installed on virtul handle.
768 @retval other Failed to open specified protocol on this device.
772 ConSplitterSupported (
773 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
774 IN EFI_HANDLE ControllerHandle
,
782 // Make sure the Console Splitter does not attempt to attach to itself
784 if (ControllerHandle
== mConIn
.VirtualHandle
||
785 ControllerHandle
== mConOut
.VirtualHandle
||
786 ControllerHandle
== mStdErr
.VirtualHandle
788 return EFI_UNSUPPORTED
;
792 // Check to see whether the specific protocol could be opened BY_DRIVER
794 Status
= gBS
->OpenProtocol (
798 This
->DriverBindingHandle
,
800 EFI_OPEN_PROTOCOL_BY_DRIVER
803 if (EFI_ERROR (Status
)) {
810 This
->DriverBindingHandle
,
818 Test to see if Console In Device could be supported on the Controller.
820 @param This Driver Binding protocol instance pointer.
821 @param ControllerHandle Handle of device to test.
822 @param RemainingDevicePath Optional parameter use to pick a specific child
825 @retval EFI_SUCCESS This driver supports this device.
826 @retval other This driver does not support this device.
831 ConSplitterConInDriverBindingSupported (
832 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
833 IN EFI_HANDLE ControllerHandle
,
834 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
837 return ConSplitterSupported (
840 &gEfiConsoleInDeviceGuid
845 Test to see if Simple Pointer protocol could be supported on the Controller.
847 @param This Driver Binding protocol instance pointer.
848 @param ControllerHandle Handle of device to test.
849 @param RemainingDevicePath Optional parameter use to pick a specific child
852 @retval EFI_SUCCESS This driver supports this device.
853 @retval other This driver does not support this device.
858 ConSplitterSimplePointerDriverBindingSupported (
859 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
860 IN EFI_HANDLE ControllerHandle
,
861 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
864 return ConSplitterSupported (
867 &gEfiSimplePointerProtocolGuid
872 Test to see if Absolute Pointer protocol could be supported on the Controller.
874 @param This Driver Binding protocol instance pointer.
875 @param ControllerHandle Handle of device to test.
876 @param RemainingDevicePath Optional parameter use to pick a specific child
879 @retval EFI_SUCCESS This driver supports this device.
880 @retval other This driver does not support this device.
885 ConSplitterAbsolutePointerDriverBindingSupported (
886 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
887 IN EFI_HANDLE ControllerHandle
,
888 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
891 return ConSplitterSupported (
894 &gEfiAbsolutePointerProtocolGuid
900 Test to see if Console Out Device could be supported on the Controller.
902 @param This Driver Binding protocol instance pointer.
903 @param ControllerHandle Handle of device to test.
904 @param RemainingDevicePath Optional parameter use to pick a specific child
907 @retval EFI_SUCCESS This driver supports this device.
908 @retval other This driver does not support this device.
913 ConSplitterConOutDriverBindingSupported (
914 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
915 IN EFI_HANDLE ControllerHandle
,
916 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
919 return ConSplitterSupported (
922 &gEfiConsoleOutDeviceGuid
927 Test to see if Standard Error Device could be supported on the Controller.
929 @param This Driver Binding protocol instance pointer.
930 @param ControllerHandle Handle of device to test.
931 @param RemainingDevicePath Optional parameter use to pick a specific child
934 @retval EFI_SUCCESS This driver supports this device.
935 @retval other This driver does not support this device.
940 ConSplitterStdErrDriverBindingSupported (
941 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
942 IN EFI_HANDLE ControllerHandle
,
943 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
946 return ConSplitterSupported (
949 &gEfiStandardErrorDeviceGuid
955 Start ConSplitter on devcie handle by opening Console Device Guid on device handle
956 and the console virtual handle. And Get the console interface on controller handle.
958 @param This Driver Binding protocol instance pointer.
959 @param ControllerHandle Handle of device.
960 @param ConSplitterVirtualHandle Console virtual Handle.
961 @param DeviceGuid The specified Console Device, such as ConInDev,
963 @param InterfaceGuid The specified protocol to be opened.
964 @param Interface Protocol interface returned.
966 @retval EFI_SUCCESS This driver supports this device.
967 @retval other Failed to open the specified Console Device Guid
968 or specified protocol.
973 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
974 IN EFI_HANDLE ControllerHandle
,
975 IN EFI_HANDLE ConSplitterVirtualHandle
,
976 IN EFI_GUID
*DeviceGuid
,
977 IN EFI_GUID
*InterfaceGuid
,
985 // Check to see whether the ControllerHandle has the DeviceGuid on it.
987 Status
= gBS
->OpenProtocol (
991 This
->DriverBindingHandle
,
993 EFI_OPEN_PROTOCOL_BY_DRIVER
995 if (EFI_ERROR (Status
)) {
1000 // Open the Parent Handle for the child.
1002 Status
= gBS
->OpenProtocol (
1006 This
->DriverBindingHandle
,
1007 ConSplitterVirtualHandle
,
1008 EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
1010 if (EFI_ERROR (Status
)) {
1015 // Open InterfaceGuid on the virtul handle.
1017 Status
= gBS
->OpenProtocol (
1021 This
->DriverBindingHandle
,
1022 ConSplitterVirtualHandle
,
1023 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1026 if (!EFI_ERROR (Status
)) {
1031 // close the DeviceGuid on ConSplitter VirtualHandle.
1033 gBS
->CloseProtocol (
1036 This
->DriverBindingHandle
,
1037 ConSplitterVirtualHandle
1042 // close the DeviceGuid on ControllerHandle.
1044 gBS
->CloseProtocol (
1047 This
->DriverBindingHandle
,
1056 Start Console In Consplitter on device handle.
1058 @param This Driver Binding protocol instance pointer.
1059 @param ControllerHandle Handle of device to bind driver to.
1060 @param RemainingDevicePath Optional parameter use to pick a specific child
1063 @retval EFI_SUCCESS Console In Consplitter is added to ControllerHandle.
1064 @retval other Console In Consplitter does not support this device.
1069 ConSplitterConInDriverBindingStart (
1070 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1071 IN EFI_HANDLE ControllerHandle
,
1072 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
1076 EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*TextIn
;
1077 EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*TextInEx
;
1080 // Start ConSplitter on ControllerHandle, and create the virtual
1081 // agrogated console device on first call Start for a SimpleTextIn handle.
1083 Status
= ConSplitterStart (
1086 mConIn
.VirtualHandle
,
1087 &gEfiConsoleInDeviceGuid
,
1088 &gEfiSimpleTextInProtocolGuid
,
1091 if (EFI_ERROR (Status
)) {
1096 // Add this device into Text In devices list.
1098 Status
= ConSplitterTextInAddDevice (&mConIn
, TextIn
);
1099 if (EFI_ERROR (Status
)) {
1103 Status
= gBS
->OpenProtocol (
1105 &gEfiSimpleTextInputExProtocolGuid
,
1106 (VOID
**) &TextInEx
,
1107 This
->DriverBindingHandle
,
1108 mConIn
.VirtualHandle
,
1109 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1111 if (!EFI_ERROR (Status
)) {
1113 // If Simple Text Input Ex protocol exists,
1114 // add this device into Text In Ex devices list.
1116 Status
= ConSplitterTextInExAddDevice (&mConIn
, TextInEx
);
1124 Start Simple Pointer Consplitter on device handle.
1126 @param This Driver Binding protocol instance pointer.
1127 @param ControllerHandle Handle of device to bind driver to.
1128 @param RemainingDevicePath Optional parameter use to pick a specific child
1131 @retval EFI_SUCCESS Simple Pointer Consplitter is added to ControllerHandle.
1132 @retval other Simple Pointer Consplitter does not support this device.
1137 ConSplitterSimplePointerDriverBindingStart (
1138 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1139 IN EFI_HANDLE ControllerHandle
,
1140 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
1144 EFI_SIMPLE_POINTER_PROTOCOL
*SimplePointer
;
1147 // Start ConSplitter on ControllerHandle, and create the virtual
1148 // agrogated console device on first call Start for a SimplePointer handle.
1150 Status
= ConSplitterStart (
1153 mConIn
.VirtualHandle
,
1154 &gEfiSimplePointerProtocolGuid
,
1155 &gEfiSimplePointerProtocolGuid
,
1156 (VOID
**) &SimplePointer
1158 if (EFI_ERROR (Status
)) {
1163 // Add this devcie into Simple Pointer devices list.
1165 return ConSplitterSimplePointerAddDevice (&mConIn
, SimplePointer
);
1170 Start Absolute Pointer Consplitter on device handle.
1172 @param This Driver Binding protocol instance pointer.
1173 @param ControllerHandle Handle of device to bind driver to.
1174 @param RemainingDevicePath Optional parameter use to pick a specific child
1177 @retval EFI_SUCCESS Absolute Pointer Consplitter is added to ControllerHandle.
1178 @retval other Absolute Pointer Consplitter does not support this device.
1183 ConSplitterAbsolutePointerDriverBindingStart (
1184 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1185 IN EFI_HANDLE ControllerHandle
,
1186 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
1190 EFI_ABSOLUTE_POINTER_PROTOCOL
*AbsolutePointer
;
1193 // Start ConSplitter on ControllerHandle, and create the virtual
1194 // agrogated console device on first call Start for a AbsolutePointer handle.
1196 Status
= ConSplitterStart (
1199 mConIn
.VirtualHandle
,
1200 &gEfiAbsolutePointerProtocolGuid
,
1201 &gEfiAbsolutePointerProtocolGuid
,
1202 (VOID
**) &AbsolutePointer
1205 if (EFI_ERROR (Status
)) {
1210 // Add this devcie into Absolute Pointer devices list.
1212 return ConSplitterAbsolutePointerAddDevice (&mConIn
, AbsolutePointer
);
1217 Start Console Out Consplitter on device handle.
1219 @param This Driver Binding protocol instance pointer.
1220 @param ControllerHandle Handle of device to bind driver to.
1221 @param RemainingDevicePath Optional parameter use to pick a specific child
1224 @retval EFI_SUCCESS Console Out Consplitter is added to ControllerHandle.
1225 @retval other Console Out Consplitter does not support this device.
1230 ConSplitterConOutDriverBindingStart (
1231 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1232 IN EFI_HANDLE ControllerHandle
,
1233 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
1237 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
;
1238 EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
;
1239 EFI_UGA_DRAW_PROTOCOL
*UgaDraw
;
1241 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*Info
;
1244 // Start ConSplitter on ControllerHandle, and create the virtual
1245 // agrogated console device on first call Start for a ConsoleOut handle.
1247 Status
= ConSplitterStart (
1250 mConOut
.VirtualHandle
,
1251 &gEfiConsoleOutDeviceGuid
,
1252 &gEfiSimpleTextOutProtocolGuid
,
1255 if (EFI_ERROR (Status
)) {
1259 GraphicsOutput
= NULL
;
1262 // Try to Open Graphics Output protocol
1264 Status
= gBS
->OpenProtocol (
1266 &gEfiGraphicsOutputProtocolGuid
,
1267 (VOID
**) &GraphicsOutput
,
1268 This
->DriverBindingHandle
,
1269 mConOut
.VirtualHandle
,
1270 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1273 if (EFI_ERROR (Status
) && FeaturePcdGet (PcdUgaConsumeSupport
)) {
1275 // Open UGA DRAW protocol
1279 &gEfiUgaDrawProtocolGuid
,
1281 This
->DriverBindingHandle
,
1282 mConOut
.VirtualHandle
,
1283 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1288 // When new console device is added, the new mode will be set later,
1289 // so put current mode back to init state.
1291 mConOut
.TextOutMode
.Mode
= 0xFF;
1294 // If both ConOut and StdErr incorporate the same Text Out device,
1295 // their MaxMode and QueryData should be the intersection of both.
1297 Status
= ConSplitterTextOutAddDevice (&mConOut
, TextOut
, GraphicsOutput
, UgaDraw
);
1298 ConSplitterTextOutSetAttribute (&mConOut
.TextOut
, EFI_TEXT_ATTR (EFI_LIGHTGRAY
, EFI_BLACK
));
1300 if (FeaturePcdGet (PcdConOutUgaSupport
)) {
1302 // Get the UGA mode data of ConOut from the current mode
1304 if (GraphicsOutput
!= NULL
) {
1305 Status
= GraphicsOutput
->QueryMode (GraphicsOutput
, GraphicsOutput
->Mode
->Mode
, &SizeOfInfo
, &Info
);
1306 if (EFI_ERROR (Status
)) {
1309 ASSERT ( SizeOfInfo
<= sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
));
1311 mConOut
.UgaHorizontalResolution
= Info
->HorizontalResolution
;
1312 mConOut
.UgaVerticalResolution
= Info
->VerticalResolution
;
1313 mConOut
.UgaColorDepth
= 32;
1314 mConOut
.UgaRefreshRate
= 60;
1318 } else if (UgaDraw
!= NULL
&& FeaturePcdGet (PcdUgaConsumeSupport
)) {
1319 Status
= UgaDraw
->GetMode (
1321 &mConOut
.UgaHorizontalResolution
,
1322 &mConOut
.UgaVerticalResolution
,
1323 &mConOut
.UgaColorDepth
,
1324 &mConOut
.UgaRefreshRate
1334 Start Standard Error Consplitter on device handle.
1336 @param This Driver Binding protocol instance pointer.
1337 @param ControllerHandle Handle of device to bind driver to.
1338 @param RemainingDevicePath Optional parameter use to pick a specific child
1341 @retval EFI_SUCCESS Standard Error Consplitter is added to ControllerHandle.
1342 @retval other Standard Error Consplitter does not support this device.
1347 ConSplitterStdErrDriverBindingStart (
1348 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1349 IN EFI_HANDLE ControllerHandle
,
1350 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
1354 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
;
1357 // Start ConSplitter on ControllerHandle, and create the virtual
1358 // agrogated console device on first call Start for a StandardError handle.
1360 Status
= ConSplitterStart (
1363 mStdErr
.VirtualHandle
,
1364 &gEfiStandardErrorDeviceGuid
,
1365 &gEfiSimpleTextOutProtocolGuid
,
1368 if (EFI_ERROR (Status
)) {
1373 // When new console device is added, the new mode will be set later,
1374 // so put current mode back to init state.
1376 mStdErr
.TextOutMode
.Mode
= 0xFF;
1379 // If both ConOut and StdErr incorporate the same Text Out device,
1380 // their MaxMode and QueryData should be the intersection of both.
1382 Status
= ConSplitterTextOutAddDevice (&mStdErr
, TextOut
, NULL
, NULL
);
1383 ConSplitterTextOutSetAttribute (&mStdErr
.TextOut
, EFI_TEXT_ATTR (EFI_MAGENTA
, EFI_BLACK
));
1384 if (EFI_ERROR (Status
)) {
1393 Stop ConSplitter on device handle by closing Console Device Guid on device handle
1394 and the console virtual handle.
1396 @param This Protocol instance pointer.
1397 @param ControllerHandle Handle of device.
1398 @param ConSplitterVirtualHandle Console virtual Handle.
1399 @param DeviceGuid The specified Console Device, such as ConInDev,
1401 @param InterfaceGuid The specified protocol to be opened.
1402 @param Interface Protocol interface returned.
1404 @retval EFI_SUCCESS Stop ConSplitter on ControllerHandle successfully.
1405 @retval other Failed to Stop ConSplitter on ControllerHandle.
1410 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1411 IN EFI_HANDLE ControllerHandle
,
1412 IN EFI_HANDLE ConSplitterVirtualHandle
,
1413 IN EFI_GUID
*DeviceGuid
,
1414 IN EFI_GUID
*InterfaceGuid
,
1420 Status
= gBS
->OpenProtocol (
1424 This
->DriverBindingHandle
,
1426 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1428 if (EFI_ERROR (Status
)) {
1432 // close the protocol refered.
1434 gBS
->CloseProtocol (
1437 This
->DriverBindingHandle
,
1438 ConSplitterVirtualHandle
1441 gBS
->CloseProtocol (
1444 This
->DriverBindingHandle
,
1453 Stop Console In ConSplitter on ControllerHandle by closing Console In Devcice GUID.
1455 @param This Driver Binding protocol instance pointer.
1456 @param ControllerHandle Handle of device to stop driver on
1457 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
1458 children is zero stop the entire bus driver.
1459 @param ChildHandleBuffer List of Child Handles to Stop.
1461 @retval EFI_SUCCESS This driver is removed ControllerHandle
1462 @retval other This driver was not removed from this device
1467 ConSplitterConInDriverBindingStop (
1468 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1469 IN EFI_HANDLE ControllerHandle
,
1470 IN UINTN NumberOfChildren
,
1471 IN EFI_HANDLE
*ChildHandleBuffer
1475 EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*TextIn
;
1476 EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*TextInEx
;
1478 if (NumberOfChildren
== 0) {
1482 Status
= gBS
->OpenProtocol (
1484 &gEfiSimpleTextInputExProtocolGuid
,
1485 (VOID
**) &TextInEx
,
1486 This
->DriverBindingHandle
,
1488 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1490 if (!EFI_ERROR (Status
)) {
1492 // If Simple Text Input Ex protocol exists,
1493 // remove device from Text Input Ex devices list.
1495 Status
= ConSplitterTextInExDeleteDevice (&mConIn
, TextInEx
);
1496 if (EFI_ERROR (Status
)) {
1502 // Close Simple Text In protocol on controller handle and virtual handle.
1504 Status
= ConSplitterStop (
1507 mConIn
.VirtualHandle
,
1508 &gEfiConsoleInDeviceGuid
,
1509 &gEfiSimpleTextInProtocolGuid
,
1512 if (EFI_ERROR (Status
)) {
1517 // Remove device from Text Input devices list.
1519 return ConSplitterTextInDeleteDevice (&mConIn
, TextIn
);
1524 Stop Simple Pointer protocol ConSplitter on ControllerHandle by closing
1525 Simple Pointer protocol.
1527 @param This Driver Binding protocol instance pointer.
1528 @param ControllerHandle Handle of device to stop driver on
1529 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
1530 children is zero stop the entire bus driver.
1531 @param ChildHandleBuffer List of Child Handles to Stop.
1533 @retval EFI_SUCCESS This driver is removed ControllerHandle
1534 @retval other This driver was not removed from this device
1539 ConSplitterSimplePointerDriverBindingStop (
1540 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1541 IN EFI_HANDLE ControllerHandle
,
1542 IN UINTN NumberOfChildren
,
1543 IN EFI_HANDLE
*ChildHandleBuffer
1547 EFI_SIMPLE_POINTER_PROTOCOL
*SimplePointer
;
1549 if (NumberOfChildren
== 0) {
1554 // Close Simple Pointer protocol on controller handle and virtual handle.
1556 Status
= ConSplitterStop (
1559 mConIn
.VirtualHandle
,
1560 &gEfiSimplePointerProtocolGuid
,
1561 &gEfiSimplePointerProtocolGuid
,
1562 (VOID
**) &SimplePointer
1564 if (EFI_ERROR (Status
)) {
1569 // Remove this device from Simple Pointer device list.
1571 return ConSplitterSimplePointerDeleteDevice (&mConIn
, SimplePointer
);
1576 Stop Absolute Pointer protocol ConSplitter on ControllerHandle by closing
1577 Absolute Pointer protocol.
1579 @param This Driver Binding protocol instance pointer.
1580 @param ControllerHandle Handle of device to stop driver on
1581 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
1582 children is zero stop the entire bus driver.
1583 @param ChildHandleBuffer List of Child Handles to Stop.
1585 @retval EFI_SUCCESS This driver is removed ControllerHandle
1586 @retval other This driver was not removed from this device
1591 ConSplitterAbsolutePointerDriverBindingStop (
1592 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1593 IN EFI_HANDLE ControllerHandle
,
1594 IN UINTN NumberOfChildren
,
1595 IN EFI_HANDLE
*ChildHandleBuffer
1599 EFI_ABSOLUTE_POINTER_PROTOCOL
*AbsolutePointer
;
1601 if (NumberOfChildren
== 0) {
1606 // Close Absolute Pointer protocol on controller handle and virtual handle.
1608 Status
= ConSplitterStop (
1611 mConIn
.VirtualHandle
,
1612 &gEfiAbsolutePointerProtocolGuid
,
1613 &gEfiAbsolutePointerProtocolGuid
,
1614 (VOID
**) &AbsolutePointer
1616 if (EFI_ERROR (Status
)) {
1621 // Remove this device from Absolute Pointer device list.
1623 return ConSplitterAbsolutePointerDeleteDevice (&mConIn
, AbsolutePointer
);
1628 Stop Console Out ConSplitter on device handle by closing Console Out Devcice GUID.
1630 @param This Driver Binding protocol instance pointer.
1631 @param ControllerHandle Handle of device to stop driver on
1632 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
1633 children is zero stop the entire bus driver.
1634 @param ChildHandleBuffer List of Child Handles to Stop.
1636 @retval EFI_SUCCESS This driver is removed ControllerHandle
1637 @retval other This driver was not removed from this device
1642 ConSplitterConOutDriverBindingStop (
1643 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1644 IN EFI_HANDLE ControllerHandle
,
1645 IN UINTN NumberOfChildren
,
1646 IN EFI_HANDLE
*ChildHandleBuffer
1650 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
;
1652 if (NumberOfChildren
== 0) {
1657 // Close Absolute Pointer protocol on controller handle and virtual handle.
1659 Status
= ConSplitterStop (
1662 mConOut
.VirtualHandle
,
1663 &gEfiConsoleOutDeviceGuid
,
1664 &gEfiSimpleTextOutProtocolGuid
,
1667 if (EFI_ERROR (Status
)) {
1672 // Remove this device from Text Out device list.
1674 return ConSplitterTextOutDeleteDevice (&mConOut
, TextOut
);
1679 Stop Standard Error ConSplitter on ControllerHandle by closing Standard Error GUID.
1681 @param This Driver Binding protocol instance pointer.
1682 @param ControllerHandle Handle of device to stop driver on
1683 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
1684 children is zero stop the entire bus driver.
1685 @param ChildHandleBuffer List of Child Handles to Stop.
1687 @retval EFI_SUCCESS This driver is removed ControllerHandle
1688 @retval other This driver was not removed from this device
1693 ConSplitterStdErrDriverBindingStop (
1694 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1695 IN EFI_HANDLE ControllerHandle
,
1696 IN UINTN NumberOfChildren
,
1697 IN EFI_HANDLE
*ChildHandleBuffer
1701 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
;
1703 if (NumberOfChildren
== 0) {
1708 // Close Standard Error Device on controller handle and virtual handle.
1710 Status
= ConSplitterStop (
1713 mStdErr
.VirtualHandle
,
1714 &gEfiStandardErrorDeviceGuid
,
1715 &gEfiSimpleTextOutProtocolGuid
,
1718 if (EFI_ERROR (Status
)) {
1722 // Delete this console error out device's data structures.
1724 return ConSplitterTextOutDeleteDevice (&mStdErr
, TextOut
);
1729 Take the passed in Buffer of size ElementSize and grow the buffer
1730 by CONSOLE_SPLITTER_ALLOC_UNIT * ElementSize bytes.
1731 Copy the current data in Buffer to the new version of Buffer and
1732 free the old version of buffer.
1734 @param ElementSize Size of element in array.
1735 @param Count Current number of elements in array.
1736 @param Buffer Bigger version of passed in Buffer with all the
1739 @retval EFI_SUCCESS Buffer size has grown.
1740 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
1744 ConSplitterGrowBuffer (
1745 IN UINTN ElementSize
,
1746 IN OUT UINTN
*Count
,
1747 IN OUT VOID
**Buffer
1753 // grow the buffer to new buffer size,
1754 // copy the old buffer's content to the new-size buffer,
1755 // then free the old buffer.
1757 Ptr
= ReallocatePool (
1758 ElementSize
* (*Count
),
1759 ElementSize
* ((*Count
) + CONSOLE_SPLITTER_ALLOC_UNIT
),
1763 return EFI_OUT_OF_RESOURCES
;
1765 *Count
+= CONSOLE_SPLITTER_ALLOC_UNIT
;
1772 Add Text Input Device in Consplitter Text Input list.
1774 @param Private Text In Splitter pointer.
1775 @param TextIn Simple Text Input protocol pointer.
1777 @retval EFI_SUCCESS Text Input Device added successfully.
1778 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
1782 ConSplitterTextInAddDevice (
1783 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
1784 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*TextIn
1790 // If the Text In List is full, enlarge it by calling ConSplitterGrowBuffer().
1792 if (Private
->CurrentNumberOfConsoles
>= Private
->TextInListCount
) {
1793 Status
= ConSplitterGrowBuffer (
1794 sizeof (EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*),
1795 &Private
->TextInListCount
,
1796 (VOID
**) &Private
->TextInList
1798 if (EFI_ERROR (Status
)) {
1799 return EFI_OUT_OF_RESOURCES
;
1803 // Add the new text-in device data structure into the Text In List.
1805 Private
->TextInList
[Private
->CurrentNumberOfConsoles
] = TextIn
;
1806 Private
->CurrentNumberOfConsoles
++;
1809 // Extra CheckEvent added to reduce the double CheckEvent().
1811 gBS
->CheckEvent (TextIn
->WaitForKey
);
1818 Remove Text Input Device from Consplitter Text Input list.
1820 @param Private Text In Splitter pointer.
1821 @param TextIn Simple Text protocol pointer.
1823 @retval EFI_SUCCESS Simple Text Device removed successfully.
1824 @retval EFI_NOT_FOUND No Simple Text Device found.
1828 ConSplitterTextInDeleteDevice (
1829 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
1830 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*TextIn
1835 // Remove the specified text-in device data structure from the Text In List,
1836 // and rearrange the remaining data structures in the Text In List.
1838 for (Index
= 0; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
1839 if (Private
->TextInList
[Index
] == TextIn
) {
1840 for (; Index
< Private
->CurrentNumberOfConsoles
- 1; Index
++) {
1841 Private
->TextInList
[Index
] = Private
->TextInList
[Index
+ 1];
1844 Private
->CurrentNumberOfConsoles
--;
1849 return EFI_NOT_FOUND
;
1853 Add Text Input Ex Device in Consplitter Text Input Ex list.
1855 @param Private Text In Splitter pointer.
1856 @param TextInEx Simple Text Input Ex Input protocol pointer.
1858 @retval EFI_SUCCESS Text Input Ex Device added successfully.
1859 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
1863 ConSplitterTextInExAddDevice (
1864 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
1865 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*TextInEx
1870 TEXT_IN_EX_SPLITTER_NOTIFY
*CurrentNotify
;
1871 UINTN TextInExListCount
;
1874 // Enlarge the NotifyHandleList and the TextInExList
1876 if (Private
->CurrentNumberOfExConsoles
>= Private
->TextInExListCount
) {
1877 for (Link
= Private
->NotifyList
.ForwardLink
; Link
!= &Private
->NotifyList
; Link
= Link
->ForwardLink
) {
1878 CurrentNotify
= TEXT_IN_EX_SPLITTER_NOTIFY_FROM_THIS (Link
);
1879 TextInExListCount
= Private
->TextInExListCount
;
1881 Status
= ConSplitterGrowBuffer (
1882 sizeof (EFI_HANDLE
),
1884 (VOID
**) &CurrentNotify
->NotifyHandleList
1886 if (EFI_ERROR (Status
)) {
1887 return EFI_OUT_OF_RESOURCES
;
1890 Status
= ConSplitterGrowBuffer (
1891 sizeof (EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*),
1892 &Private
->TextInExListCount
,
1893 (VOID
**) &Private
->TextInExList
1895 if (EFI_ERROR (Status
)) {
1896 return EFI_OUT_OF_RESOURCES
;
1901 // Register the key notify in the new text-in device
1903 for (Link
= Private
->NotifyList
.ForwardLink
; Link
!= &Private
->NotifyList
; Link
= Link
->ForwardLink
) {
1904 CurrentNotify
= TEXT_IN_EX_SPLITTER_NOTIFY_FROM_THIS (Link
);
1905 Status
= TextInEx
->RegisterKeyNotify (
1907 &CurrentNotify
->KeyData
,
1908 CurrentNotify
->KeyNotificationFn
,
1909 &CurrentNotify
->NotifyHandleList
[Private
->CurrentNumberOfExConsoles
]
1911 if (EFI_ERROR (Status
)) {
1912 for (Link
= Link
->BackLink
; Link
!= &Private
->NotifyList
; Link
= Link
->BackLink
) {
1913 CurrentNotify
= TEXT_IN_EX_SPLITTER_NOTIFY_FROM_THIS (Link
);
1914 TextInEx
->UnregisterKeyNotify (
1916 CurrentNotify
->NotifyHandleList
[Private
->CurrentNumberOfExConsoles
]
1924 // Add the new text-in device data structure into the Text Input Ex List.
1926 Private
->TextInExList
[Private
->CurrentNumberOfExConsoles
] = TextInEx
;
1927 Private
->CurrentNumberOfExConsoles
++;
1930 // Extra CheckEvent added to reduce the double CheckEvent().
1932 gBS
->CheckEvent (TextInEx
->WaitForKeyEx
);
1938 Remove Text Ex Device from Consplitter Text Input Ex list.
1940 @param Private Text In Splitter pointer.
1941 @param TextInEx Simple Text Ex protocol pointer.
1943 @retval EFI_SUCCESS Simple Text Input Ex Device removed successfully.
1944 @retval EFI_NOT_FOUND No Simple Text Input Ex Device found.
1948 ConSplitterTextInExDeleteDevice (
1949 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
1950 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*TextInEx
1955 // Remove the specified text-in device data structure from the Text Input Ex List,
1956 // and rearrange the remaining data structures in the Text In List.
1958 for (Index
= 0; Index
< Private
->CurrentNumberOfExConsoles
; Index
++) {
1959 if (Private
->TextInExList
[Index
] == TextInEx
) {
1960 for (; Index
< Private
->CurrentNumberOfExConsoles
- 1; Index
++) {
1961 Private
->TextInExList
[Index
] = Private
->TextInExList
[Index
+ 1];
1964 Private
->CurrentNumberOfExConsoles
--;
1969 return EFI_NOT_FOUND
;
1974 Add Simple Pointer Device in Consplitter Simple Pointer list.
1976 @param Private Text In Splitter pointer.
1977 @param SimplePointer Simple Pointer protocol pointer.
1979 @retval EFI_SUCCESS Simple Pointer Device added successfully.
1980 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
1984 ConSplitterSimplePointerAddDevice (
1985 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
1986 IN EFI_SIMPLE_POINTER_PROTOCOL
*SimplePointer
1992 // If the Simple Pointer List is full, enlarge it by calling ConSplitterGrowBuffer().
1994 if (Private
->CurrentNumberOfPointers
>= Private
->PointerListCount
) {
1995 Status
= ConSplitterGrowBuffer (
1996 sizeof (EFI_SIMPLE_POINTER_PROTOCOL
*),
1997 &Private
->PointerListCount
,
1998 (VOID
**) &Private
->PointerList
2000 if (EFI_ERROR (Status
)) {
2001 return EFI_OUT_OF_RESOURCES
;
2005 // Add the new text-in device data structure into the Simple Pointer List.
2007 Private
->PointerList
[Private
->CurrentNumberOfPointers
] = SimplePointer
;
2008 Private
->CurrentNumberOfPointers
++;
2015 Remove Simple Pointer Device from Consplitter Simple Pointer list.
2017 @param Private Text In Splitter pointer.
2018 @param SimplePointer Simple Pointer protocol pointer.
2020 @retval EFI_SUCCESS Simple Pointer Device removed successfully.
2021 @retval EFI_NOT_FOUND No Simple Pointer Device found.
2025 ConSplitterSimplePointerDeleteDevice (
2026 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
2027 IN EFI_SIMPLE_POINTER_PROTOCOL
*SimplePointer
2032 // Remove the specified text-in device data structure from the Simple Pointer List,
2033 // and rearrange the remaining data structures in the Text In List.
2035 for (Index
= 0; Index
< Private
->CurrentNumberOfPointers
; Index
++) {
2036 if (Private
->PointerList
[Index
] == SimplePointer
) {
2037 for (; Index
< Private
->CurrentNumberOfPointers
- 1; Index
++) {
2038 Private
->PointerList
[Index
] = Private
->PointerList
[Index
+ 1];
2041 Private
->CurrentNumberOfPointers
--;
2046 return EFI_NOT_FOUND
;
2051 Add Absolute Pointer Device in Consplitter Absolute Pointer list.
2053 @param Private Text In Splitter pointer.
2054 @param AbsolutePointer Absolute Pointer protocol pointer.
2056 @retval EFI_SUCCESS Absolute Pointer Device added successfully.
2057 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
2061 ConSplitterAbsolutePointerAddDevice (
2062 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
2063 IN EFI_ABSOLUTE_POINTER_PROTOCOL
*AbsolutePointer
2069 // If the Absolute Pointer List is full, enlarge it by calling ConSplitterGrowBuffer().
2071 if (Private
->CurrentNumberOfAbsolutePointers
>= Private
->AbsolutePointerListCount
) {
2072 Status
= ConSplitterGrowBuffer (
2073 sizeof (EFI_ABSOLUTE_POINTER_PROTOCOL
*),
2074 &Private
->AbsolutePointerListCount
,
2075 (VOID
**) &Private
->AbsolutePointerList
2077 if (EFI_ERROR (Status
)) {
2078 return EFI_OUT_OF_RESOURCES
;
2082 // Add the new text-in device data structure into the Absolute Pointer List.
2084 Private
->AbsolutePointerList
[Private
->CurrentNumberOfAbsolutePointers
] = AbsolutePointer
;
2085 Private
->CurrentNumberOfAbsolutePointers
++;
2092 Remove Absolute Pointer Device from Consplitter Absolute Pointer list.
2094 @param Private Text In Splitter pointer.
2095 @param AbsolutePointer Absolute Pointer protocol pointer.
2097 @retval EFI_SUCCESS Absolute Pointer Device removed successfully.
2098 @retval EFI_NOT_FOUND No Absolute Pointer Device found.
2102 ConSplitterAbsolutePointerDeleteDevice (
2103 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
2104 IN EFI_ABSOLUTE_POINTER_PROTOCOL
*AbsolutePointer
2109 // Remove the specified text-in device data structure from the Absolute Pointer List,
2110 // and rearrange the remaining data structures from the Absolute Pointer List.
2112 for (Index
= 0; Index
< Private
->CurrentNumberOfAbsolutePointers
; Index
++) {
2113 if (Private
->AbsolutePointerList
[Index
] == AbsolutePointer
) {
2114 for (; Index
< Private
->CurrentNumberOfAbsolutePointers
- 1; Index
++) {
2115 Private
->AbsolutePointerList
[Index
] = Private
->AbsolutePointerList
[Index
+ 1];
2118 Private
->CurrentNumberOfAbsolutePointers
--;
2123 return EFI_NOT_FOUND
;
2127 Reallocate Text Out mode map.
2129 Allocate new buffer and copy original buffer into the new buffer.
2131 @param Private Consplitter Text Out pointer.
2133 @retval EFI_SUCCESS Buffer size has grown
2134 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
2138 ConSplitterGrowMapTable (
2139 IN TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
2145 INT32
*TextOutModeMap
;
2146 INT32
*OldTextOutModeMap
;
2150 NewSize
= Private
->TextOutListCount
* sizeof (INT32
);
2151 OldTextOutModeMap
= Private
->TextOutModeMap
;
2152 TotalSize
= NewSize
* (Private
->TextOutQueryDataCount
);
2155 // Allocate new buffer for Text Out List.
2157 TextOutModeMap
= AllocatePool (TotalSize
);
2158 if (TextOutModeMap
== NULL
) {
2159 return EFI_OUT_OF_RESOURCES
;
2162 SetMem (TextOutModeMap
, TotalSize
, 0xFF);
2163 Private
->TextOutModeMap
= TextOutModeMap
;
2166 // If TextOutList has been enlarged, need to realloc the mode map table
2167 // The mode map table is regarded as a two dimension array.
2170 // 0 ---------> TextOutListCount ----> TextOutListCount
2171 // | -------------------------------------------
2178 // -------------------------------------------
2181 if (OldTextOutModeMap
!= NULL
) {
2183 Size
= Private
->CurrentNumberOfConsoles
* sizeof (INT32
);
2185 SrcAddress
= OldTextOutModeMap
;
2188 // Copy the old data to the new one
2190 while (Index
< Private
->TextOutMode
.MaxMode
) {
2191 CopyMem (TextOutModeMap
, SrcAddress
, Size
);
2192 TextOutModeMap
+= NewSize
;
2197 // Free the old buffer
2199 FreePool (OldTextOutModeMap
);
2207 Add new device's output mode to console splitter's mode list.
2209 @param Private Text Out Splitter pointer
2210 @param TextOut Simple Text Output protocol pointer.
2212 @retval EFI_SUCCESS Device added successfully.
2213 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
2217 ConSplitterAddOutputMode (
2218 IN TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
,
2219 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
2227 MaxMode
= TextOut
->Mode
->MaxMode
;
2228 Private
->TextOutMode
.MaxMode
= MaxMode
;
2231 // Grow the buffer if query data buffer is not large enough to
2232 // hold all the mode supported by the first console.
2234 while (MaxMode
> (INT32
) Private
->TextOutQueryDataCount
) {
2235 Status
= ConSplitterGrowBuffer (
2236 sizeof (TEXT_OUT_SPLITTER_QUERY_DATA
),
2237 &Private
->TextOutQueryDataCount
,
2238 (VOID
**) &Private
->TextOutQueryData
2240 if (EFI_ERROR (Status
)) {
2241 return EFI_OUT_OF_RESOURCES
;
2245 // Allocate buffer for the output mode map
2247 Status
= ConSplitterGrowMapTable (Private
);
2248 if (EFI_ERROR (Status
)) {
2249 return EFI_OUT_OF_RESOURCES
;
2252 // As the first textout device, directly add the mode in to QueryData
2253 // and at the same time record the mapping between QueryData and TextOut.
2257 while (Mode
< MaxMode
) {
2258 Status
= TextOut
->QueryMode (
2261 &Private
->TextOutQueryData
[Mode
].Columns
,
2262 &Private
->TextOutQueryData
[Mode
].Rows
2265 // If mode 1 (80x50) is not supported, make sure mode 1 in TextOutQueryData
2268 if ((EFI_ERROR(Status
)) && (Mode
== 1)) {
2269 Private
->TextOutQueryData
[Mode
].Columns
= 0;
2270 Private
->TextOutQueryData
[Mode
].Rows
= 0;
2272 Private
->TextOutModeMap
[Index
] = Mode
;
2274 Index
+= Private
->TextOutListCount
;
2281 Reconstruct TextOutModeMap to get intersection of modes.
2283 This routine reconstruct TextOutModeMap to get the intersection
2284 of modes for all console out devices. Because EFI/UEFI spec require
2285 mode 0 is 80x25, mode 1 is 80x50, this routine will not check the
2286 intersection for mode 0 and mode 1.
2288 @param TextOutModeMap Current text out mode map, begin with the mode 80x25
2289 @param NewlyAddedMap New text out mode map, begin with the mode 80x25
2290 @param MapStepSize Mode step size for one console device
2291 @param NewMapStepSize New Mode step size for one console device
2292 @param MaxMode IN: Current max text mode, OUT: Updated max text mode.
2293 @param CurrentMode IN: Current text mode, OUT: Updated current text mode.
2297 ConSplitterGetIntersection (
2298 IN INT32
*TextOutModeMap
,
2299 IN INT32
*NewlyAddedMap
,
2300 IN UINTN MapStepSize
,
2301 IN UINTN NewMapStepSize
,
2302 IN OUT INT32
*MaxMode
,
2303 IN OUT INT32
*CurrentMode
2307 INT32
*CurrentMapEntry
;
2308 INT32
*NextMapEntry
;
2310 INT32 CurrentMaxMode
;
2314 // According to EFI/UEFI spec, mode 0 and mode 1 have been reserved
2315 // for 80x25 and 80x50 in Simple Text Out protocol, so don't make intersection
2316 // for mode 0 and mode 1, mode number starts from 2.
2319 CurrentMapEntry
= &TextOutModeMap
[MapStepSize
* 2];
2320 NextMapEntry
= CurrentMapEntry
;
2321 NewMapEntry
= &NewlyAddedMap
[NewMapStepSize
* 2];
2323 CurrentMaxMode
= *MaxMode
;
2324 Mode
= *CurrentMode
;
2326 while (Index
< CurrentMaxMode
) {
2327 if (*NewMapEntry
== -1) {
2329 // This mode is not supported any more. Remove it. Special care
2330 // must be taken as this remove will also affect current mode;
2332 if (Index
== *CurrentMode
) {
2334 } else if (Index
< *CurrentMode
) {
2339 if (CurrentMapEntry
!= NextMapEntry
) {
2340 CopyMem (NextMapEntry
, CurrentMapEntry
, MapStepSize
* sizeof (INT32
));
2343 NextMapEntry
+= MapStepSize
;
2346 CurrentMapEntry
+= MapStepSize
;
2347 NewMapEntry
+= NewMapStepSize
;
2351 *CurrentMode
= Mode
;
2357 Sync the device's output mode to console splitter's mode list.
2359 @param Private Text Out Splitter pointer.
2360 @param TextOut Simple Text Output protocol pointer.
2364 ConSplitterSyncOutputMode (
2365 IN TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
,
2366 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
2369 INT32 CurrentMaxMode
;
2372 INT32
*TextOutModeMap
;
2375 TEXT_OUT_SPLITTER_QUERY_DATA
*TextOutQueryData
;
2382 // Must make sure that current mode won't change even if mode number changes
2384 CurrentMaxMode
= Private
->TextOutMode
.MaxMode
;
2385 TextOutModeMap
= Private
->TextOutModeMap
;
2386 StepSize
= Private
->TextOutListCount
;
2387 TextOutQueryData
= Private
->TextOutQueryData
;
2390 // Query all the mode that the newly added TextOut supports
2393 MapTable
= TextOutModeMap
+ Private
->CurrentNumberOfConsoles
;
2394 while (Mode
< TextOut
->Mode
->MaxMode
) {
2395 Status
= TextOut
->QueryMode (TextOut
, Mode
, &Columns
, &Rows
);
2397 if (EFI_ERROR(Status
)) {
2400 // If mode 1 (80x50) is not supported, make sure mode 1 in TextOutQueryData
2403 MapTable
[StepSize
] = Mode
;
2404 TextOutQueryData
[Mode
].Columns
= 0;
2405 TextOutQueryData
[Mode
].Rows
= 0;
2411 // Search the intersection map and QueryData database to see if they intersects
2414 while (Index
< CurrentMaxMode
) {
2415 QueryMode
= *(TextOutModeMap
+ Index
* StepSize
);
2416 if ((TextOutQueryData
[QueryMode
].Rows
== Rows
) && (TextOutQueryData
[QueryMode
].Columns
== Columns
)) {
2417 MapTable
[Index
* StepSize
] = Mode
;
2425 // Now search the TextOutModeMap table to find the intersection of supported
2426 // mode between ConSplitter and the newly added device.
2428 ConSplitterGetIntersection (
2433 &Private
->TextOutMode
.MaxMode
,
2434 &Private
->TextOutMode
.Mode
2442 Sync output device between ConOut and StdErr output.
2444 @retval EFI_SUCCESS Sync implemented successfully.
2445 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
2449 ConSplitterGetIntersectionBetweenConOutAndStrErr (
2453 UINTN ConOutNumOfConsoles
;
2454 UINTN StdErrNumOfConsoles
;
2455 TEXT_OUT_AND_GOP_DATA
*ConOutTextOutList
;
2456 TEXT_OUT_AND_GOP_DATA
*StdErrTextOutList
;
2460 UINTN ConOutColumns
;
2462 UINTN StdErrColumns
;
2463 INT32 ConOutMaxMode
;
2464 INT32 StdErrMaxMode
;
2469 INT32
*ConOutModeMap
;
2470 INT32
*StdErrModeMap
;
2471 INT32
*ConOutMapTable
;
2472 INT32
*StdErrMapTable
;
2473 TEXT_OUT_SPLITTER_QUERY_DATA
*ConOutQueryData
;
2474 TEXT_OUT_SPLITTER_QUERY_DATA
*StdErrQueryData
;
2475 UINTN ConOutStepSize
;
2476 UINTN StdErrStepSize
;
2477 BOOLEAN FoundTheSameTextOut
;
2478 UINTN ConOutMapTableSize
;
2479 UINTN StdErrMapTableSize
;
2481 ConOutNumOfConsoles
= mConOut
.CurrentNumberOfConsoles
;
2482 StdErrNumOfConsoles
= mStdErr
.CurrentNumberOfConsoles
;
2483 ConOutTextOutList
= mConOut
.TextOutList
;
2484 StdErrTextOutList
= mStdErr
.TextOutList
;
2487 FoundTheSameTextOut
= FALSE
;
2488 while ((Indexi
< ConOutNumOfConsoles
) && (!FoundTheSameTextOut
)) {
2490 while (Indexj
< StdErrNumOfConsoles
) {
2491 if (ConOutTextOutList
->TextOut
== StdErrTextOutList
->TextOut
) {
2492 FoundTheSameTextOut
= TRUE
;
2497 StdErrTextOutList
++;
2501 ConOutTextOutList
++;
2504 if (!FoundTheSameTextOut
) {
2508 // Must make sure that current mode won't change even if mode number changes
2510 ConOutMaxMode
= mConOut
.TextOutMode
.MaxMode
;
2511 ConOutModeMap
= mConOut
.TextOutModeMap
;
2512 ConOutStepSize
= mConOut
.TextOutListCount
;
2513 ConOutQueryData
= mConOut
.TextOutQueryData
;
2515 StdErrMaxMode
= mStdErr
.TextOutMode
.MaxMode
;
2516 StdErrModeMap
= mStdErr
.TextOutModeMap
;
2517 StdErrStepSize
= mStdErr
.TextOutListCount
;
2518 StdErrQueryData
= mStdErr
.TextOutQueryData
;
2521 // Allocate the map table and set the map table's index to -1.
2523 ConOutMapTableSize
= ConOutMaxMode
* sizeof (INT32
);
2524 ConOutMapTable
= AllocateZeroPool (ConOutMapTableSize
);
2525 if (ConOutMapTable
== NULL
) {
2526 return EFI_OUT_OF_RESOURCES
;
2529 SetMem (ConOutMapTable
, ConOutMapTableSize
, 0xFF);
2531 StdErrMapTableSize
= StdErrMaxMode
* sizeof (INT32
);
2532 StdErrMapTable
= AllocateZeroPool (StdErrMapTableSize
);
2533 if (StdErrMapTable
== NULL
) {
2534 return EFI_OUT_OF_RESOURCES
;
2537 SetMem (StdErrMapTable
, StdErrMapTableSize
, 0xFF);
2540 // Find the intersection of the two set of modes. If they actually intersect, the
2541 // correponding entry in the map table is set to 1.
2544 while (Mode
< ConOutMaxMode
) {
2546 // Search the intersection map and QueryData database to see if they intersect
2549 ConOutMode
= *(ConOutModeMap
+ Mode
* ConOutStepSize
);
2550 ConOutRows
= ConOutQueryData
[ConOutMode
].Rows
;
2551 ConOutColumns
= ConOutQueryData
[ConOutMode
].Columns
;
2552 while (Index
< StdErrMaxMode
) {
2553 StdErrMode
= *(StdErrModeMap
+ Index
* StdErrStepSize
);
2554 StdErrRows
= StdErrQueryData
[StdErrMode
].Rows
;
2555 StdErrColumns
= StdErrQueryData
[StdErrMode
].Columns
;
2556 if ((StdErrRows
== ConOutRows
) && (StdErrColumns
== ConOutColumns
)) {
2557 ConOutMapTable
[Mode
] = 1;
2558 StdErrMapTable
[Index
] = 1;
2568 // Now search the TextOutModeMap table to find the intersection of supported
2569 // mode between ConSplitter and the newly added device.
2571 ConSplitterGetIntersection (
2574 mConOut
.TextOutListCount
,
2576 &(mConOut
.TextOutMode
.MaxMode
),
2577 &(mConOut
.TextOutMode
.Mode
)
2580 if (mConOut
.TextOutMode
.Mode
< 0) {
2581 mConOut
.TextOut
.SetMode (&(mConOut
.TextOut
), 0);
2584 ConSplitterGetIntersection (
2587 mStdErr
.TextOutListCount
,
2589 &(mStdErr
.TextOutMode
.MaxMode
),
2590 &(mStdErr
.TextOutMode
.Mode
)
2593 if (mStdErr
.TextOutMode
.Mode
< 0) {
2594 mStdErr
.TextOut
.SetMode (&(mStdErr
.TextOut
), 0);
2597 FreePool (ConOutMapTable
);
2598 FreePool (StdErrMapTable
);
2605 Add Grahpics Output modes into Consplitter Text Out list.
2607 @param Private Text Out Splitter pointer.
2608 @param GraphicsOutput Graphics Output protocol pointer.
2609 @param UgaDraw UGA Draw protocol pointer.
2611 @retval EFI_SUCCESS Output mode added successfully.
2612 @retval other Failed to add output mode.
2616 ConSplitterAddGraphicsOutputMode (
2617 IN TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
,
2618 IN EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
,
2619 IN EFI_UGA_DRAW_PROTOCOL
*UgaDraw
2625 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*Mode
;
2627 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*Info
;
2628 EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE
*CurrentGraphicsOutputMode
;
2629 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*ModeBuffer
;
2630 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*MatchedMode
;
2633 BOOLEAN AlreadyExist
;
2634 UINT32 UgaHorizontalResolution
;
2635 UINT32 UgaVerticalResolution
;
2636 UINT32 UgaColorDepth
;
2637 UINT32 UgaRefreshRate
;
2639 ASSERT (GraphicsOutput
!= NULL
|| UgaDraw
!= NULL
);
2641 CurrentGraphicsOutputMode
= Private
->GraphicsOutput
.Mode
;
2645 Status
= EFI_SUCCESS
;
2647 if (Private
->CurrentNumberOfUgaDraw
!= 0) {
2649 // If any UGA device has already been added, then there is no need to
2650 // calculate intersection of display mode of different GOP/UGA device,
2651 // since only one display mode will be exported (i.e. user-defined mode)
2656 if (GraphicsOutput
!= NULL
) {
2657 if (Private
->CurrentNumberOfGraphicsOutput
== 0) {
2659 // This is the first Graphics Output device added
2661 CurrentGraphicsOutputMode
->MaxMode
= GraphicsOutput
->Mode
->MaxMode
;
2662 CurrentGraphicsOutputMode
->Mode
= GraphicsOutput
->Mode
->Mode
;
2663 CopyMem (CurrentGraphicsOutputMode
->Info
, GraphicsOutput
->Mode
->Info
, GraphicsOutput
->Mode
->SizeOfInfo
);
2664 CurrentGraphicsOutputMode
->SizeOfInfo
= GraphicsOutput
->Mode
->SizeOfInfo
;
2665 CurrentGraphicsOutputMode
->FrameBufferBase
= GraphicsOutput
->Mode
->FrameBufferBase
;
2666 CurrentGraphicsOutputMode
->FrameBufferSize
= GraphicsOutput
->Mode
->FrameBufferSize
;
2669 // Allocate resource for the private mode buffer
2671 ModeBuffer
= AllocatePool (sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
) * GraphicsOutput
->Mode
->MaxMode
);
2672 if (ModeBuffer
== NULL
) {
2673 return EFI_OUT_OF_RESOURCES
;
2675 FreePool (Private
->GraphicsOutputModeBuffer
);
2676 Private
->GraphicsOutputModeBuffer
= ModeBuffer
;
2679 // Store all supported display modes to the private mode buffer
2682 for (Index
= 0; Index
< GraphicsOutput
->Mode
->MaxMode
; Index
++) {
2684 // The Info buffer would be allocated by callee
2686 Status
= GraphicsOutput
->QueryMode (GraphicsOutput
, (UINT32
) Index
, &SizeOfInfo
, &Info
);
2687 if (EFI_ERROR (Status
)) {
2690 ASSERT ( SizeOfInfo
<= sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
));
2691 CopyMem (Mode
, Info
, SizeOfInfo
);
2697 // Check intersection of display mode
2699 ModeBuffer
= AllocatePool (sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
) * CurrentGraphicsOutputMode
->MaxMode
);
2700 if (ModeBuffer
== NULL
) {
2701 return EFI_OUT_OF_RESOURCES
;
2704 MatchedMode
= ModeBuffer
;
2705 Mode
= &Private
->GraphicsOutputModeBuffer
[0];
2706 for (Index
= 0; Index
< CurrentGraphicsOutputMode
->MaxMode
; Index
++) {
2709 for (NumberIndex
= 0; NumberIndex
< GraphicsOutput
->Mode
->MaxMode
; NumberIndex
++) {
2711 // The Info buffer would be allocated by callee
2713 Status
= GraphicsOutput
->QueryMode (GraphicsOutput
, (UINT32
) NumberIndex
, &SizeOfInfo
, &Info
);
2714 if (EFI_ERROR (Status
)) {
2717 if ((Info
->HorizontalResolution
== Mode
->HorizontalResolution
) &&
2718 (Info
->VerticalResolution
== Mode
->VerticalResolution
)) {
2720 // If GOP device supports one mode in current mode buffer,
2721 // it will be added into matched mode buffer
2731 AlreadyExist
= FALSE
;
2734 // Check if GOP mode has been in the mode buffer, ModeBuffer = MatchedMode at begin.
2736 for (Info
= ModeBuffer
; Info
< MatchedMode
; Info
++) {
2737 if ((Info
->HorizontalResolution
== Mode
->HorizontalResolution
) &&
2738 (Info
->VerticalResolution
== Mode
->VerticalResolution
)) {
2739 AlreadyExist
= TRUE
;
2744 if (!AlreadyExist
) {
2745 CopyMem (MatchedMode
, Mode
, sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
));
2748 // Physical frame buffer is no longer available, change PixelFormat to PixelBltOnly
2750 MatchedMode
->Version
= 0;
2751 MatchedMode
->PixelFormat
= PixelBltOnly
;
2752 ZeroMem (&MatchedMode
->PixelInformation
, sizeof (EFI_PIXEL_BITMASK
));
2762 // Drop the old mode buffer, assign it to a new one
2764 FreePool (Private
->GraphicsOutputModeBuffer
);
2765 Private
->GraphicsOutputModeBuffer
= ModeBuffer
;
2768 // Physical frame buffer is no longer available when there are more than one physical GOP devices
2770 CurrentGraphicsOutputMode
->MaxMode
= (UINT32
) (((UINTN
) MatchedMode
- (UINTN
) ModeBuffer
) / sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
));
2771 CurrentGraphicsOutputMode
->Info
->PixelFormat
= PixelBltOnly
;
2772 ZeroMem (&CurrentGraphicsOutputMode
->Info
->PixelInformation
, sizeof (EFI_PIXEL_BITMASK
));
2773 CurrentGraphicsOutputMode
->SizeOfInfo
= sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
);
2774 CurrentGraphicsOutputMode
->FrameBufferBase
= (EFI_PHYSICAL_ADDRESS
) (UINTN
) NULL
;
2775 CurrentGraphicsOutputMode
->FrameBufferSize
= 0;
2779 // Graphics console driver can ensure the same mode for all GOP devices
2781 for (Index
= 0; Index
< CurrentGraphicsOutputMode
->MaxMode
; Index
++) {
2782 Mode
= &Private
->GraphicsOutputModeBuffer
[Index
];
2783 if ((Mode
->HorizontalResolution
== GraphicsOutput
->Mode
->Info
->HorizontalResolution
) &&
2784 (Mode
->VerticalResolution
== GraphicsOutput
->Mode
->Info
->VerticalResolution
)) {
2785 CurrentIndex
= Index
;
2789 if (Index
>= CurrentGraphicsOutputMode
->MaxMode
) {
2791 // if user defined mode is not found, set to default mode 800x600
2793 for (Index
= 0; Index
< CurrentGraphicsOutputMode
->MaxMode
; Index
++) {
2794 Mode
= &Private
->GraphicsOutputModeBuffer
[Index
];
2795 if ((Mode
->HorizontalResolution
== 800) && (Mode
->VerticalResolution
== 600)) {
2796 CurrentIndex
= Index
;
2801 } else if (UgaDraw
!= NULL
&& FeaturePcdGet (PcdUgaConsumeSupport
)) {
2803 // Graphics console driver can ensure the same mode for all GOP devices
2804 // so we can get the current mode from this video device
2808 &UgaHorizontalResolution
,
2809 &UgaVerticalResolution
,
2814 CurrentGraphicsOutputMode
->MaxMode
= 1;
2815 Info
= CurrentGraphicsOutputMode
->Info
;
2817 Info
->HorizontalResolution
= UgaHorizontalResolution
;
2818 Info
->VerticalResolution
= UgaVerticalResolution
;
2819 Info
->PixelFormat
= PixelBltOnly
;
2820 Info
->PixelsPerScanLine
= UgaHorizontalResolution
;
2821 CurrentGraphicsOutputMode
->SizeOfInfo
= sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
);
2822 CurrentGraphicsOutputMode
->FrameBufferBase
= (EFI_PHYSICAL_ADDRESS
) (UINTN
) NULL
;
2823 CurrentGraphicsOutputMode
->FrameBufferSize
= 0;
2826 // Update the private mode buffer
2828 CopyMem (&Private
->GraphicsOutputModeBuffer
[0], Info
, sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
));
2831 // Only mode 0 is available to be set
2838 if (GraphicsOutput
!= NULL
) {
2839 Private
->CurrentNumberOfGraphicsOutput
++;
2841 if (UgaDraw
!= NULL
&& FeaturePcdGet (PcdUgaConsumeSupport
)) {
2842 Private
->CurrentNumberOfUgaDraw
++;
2846 // Force GraphicsOutput mode to be set,
2849 Mode
= &Private
->GraphicsOutputModeBuffer
[CurrentIndex
];
2850 if ((GraphicsOutput
!= NULL
) &&
2851 (Mode
->HorizontalResolution
== CurrentGraphicsOutputMode
->Info
->HorizontalResolution
) &&
2852 (Mode
->VerticalResolution
== CurrentGraphicsOutputMode
->Info
->VerticalResolution
)) {
2853 CurrentGraphicsOutputMode
->Mode
= (UINT32
) CurrentIndex
;
2854 if ((Mode
->HorizontalResolution
!= GraphicsOutput
->Mode
->Info
->HorizontalResolution
) ||
2855 (Mode
->VerticalResolution
!= GraphicsOutput
->Mode
->Info
->VerticalResolution
)) {
2857 // If all existing video device has been set to common mode, only set new GOP device to
2860 for (NumberIndex
= 0; NumberIndex
< GraphicsOutput
->Mode
->MaxMode
; NumberIndex
++) {
2861 Status
= GraphicsOutput
->QueryMode (GraphicsOutput
, (UINT32
) NumberIndex
, &SizeOfInfo
, &Info
);
2862 if (EFI_ERROR (Status
)) {
2865 if ((Info
->HorizontalResolution
== Mode
->HorizontalResolution
) && (Info
->VerticalResolution
== Mode
->VerticalResolution
)) {
2871 Status
= GraphicsOutput
->SetMode (GraphicsOutput
, (UINT32
) NumberIndex
);
2875 // Current mode number may need update now, so set it to an invalid mode number
2877 CurrentGraphicsOutputMode
->Mode
= 0xffff;
2879 // Graphics console can ensure all GOP devices have the same mode which can be taken as current mode.
2881 Status
= Private
->GraphicsOutput
.SetMode (&Private
->GraphicsOutput
, (UINT32
) CurrentIndex
);
2882 if (EFI_ERROR(Status
)) {
2884 // If user defined mode is not valid for display device, set to the default mode 800x600.
2886 (Private
->GraphicsOutputModeBuffer
[0]).HorizontalResolution
= 800;
2887 (Private
->GraphicsOutputModeBuffer
[0]).VerticalResolution
= 600;
2888 Status
= Private
->GraphicsOutput
.SetMode (&Private
->GraphicsOutput
, 0);
2896 Set the current console out mode.
2898 This routine will get the current console mode information (column, row)
2899 from ConsoleOutMode variable and set it; if the variable does not exist,
2900 set to user defined console mode.
2902 @param Private Consplitter Text Out pointer.
2906 ConsplitterSetConsoleOutMode (
2907 IN TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
2917 CONSOLE_OUT_MODE ModeInfo
;
2918 CONSOLE_OUT_MODE MaxModeInfo
;
2919 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
;
2923 TextOut
= &Private
->TextOut
;
2924 MaxMode
= (UINTN
) (TextOut
->Mode
->MaxMode
);
2926 MaxModeInfo
.Column
= 0;
2927 MaxModeInfo
.Row
= 0;
2928 ModeInfo
.Column
= PcdGet32 (PcdConOutColumn
);
2929 ModeInfo
.Row
= PcdGet32 (PcdConOutRow
);
2932 // To find the prefer mode and basic mode from Text Out mode list
2934 for (Mode
= 0; Mode
< MaxMode
; Mode
++) {
2935 Status
= TextOut
->QueryMode (TextOut
, Mode
, &Col
, &Row
);
2936 if (!EFI_ERROR(Status
)) {
2937 if ((ModeInfo
.Column
!= 0) && (ModeInfo
.Row
!= 0)) {
2939 // Use user defined column and row
2941 if (Col
== ModeInfo
.Column
&& Row
== ModeInfo
.Row
) {
2946 // If user sets PcdConOutColumn or PcdConOutRow to 0,
2947 // find and set the highest text mode.
2949 if ((Col
>= MaxModeInfo
.Column
) && (Row
>= MaxModeInfo
.Row
)) {
2950 MaxModeInfo
.Column
= Col
;
2951 MaxModeInfo
.Row
= Row
;
2955 if (Col
== 80 && Row
== 25) {
2962 // Set prefer mode to Text Out devices.
2964 Status
= TextOut
->SetMode (TextOut
, PreferMode
);
2965 if (EFI_ERROR(Status
)) {
2967 // if current mode setting is failed, default 80x25 mode will be set.
2969 Status
= TextOut
->SetMode (TextOut
, BaseMode
);
2970 ASSERT(!EFI_ERROR(Status
));
2972 PcdSet32 (PcdConOutColumn
, 80);
2973 PcdSet32 (PcdConOutRow
, 25);
2981 Add Text Output Device in Consplitter Text Output list.
2983 @param Private Text Out Splitter pointer.
2984 @param TextOut Simple Text Output protocol pointer.
2985 @param GraphicsOutput Graphics Output protocol pointer.
2986 @param UgaDraw UGA Draw protocol pointer.
2988 @retval EFI_SUCCESS Text Output Device added successfully.
2989 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
2993 ConSplitterTextOutAddDevice (
2994 IN TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
,
2995 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
,
2996 IN EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
,
2997 IN EFI_UGA_DRAW_PROTOCOL
*UgaDraw
3001 UINTN CurrentNumOfConsoles
;
3003 UINT32 UgaHorizontalResolution
;
3004 UINT32 UgaVerticalResolution
;
3005 UINT32 UgaColorDepth
;
3006 UINT32 UgaRefreshRate
;
3007 TEXT_OUT_AND_GOP_DATA
*TextAndGop
;
3009 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*Info
;
3010 EFI_STATUS DeviceStatus
;
3012 Status
= EFI_SUCCESS
;
3013 CurrentNumOfConsoles
= Private
->CurrentNumberOfConsoles
;
3016 // If the Text Out List is full, enlarge it by calling ConSplitterGrowBuffer().
3018 while (CurrentNumOfConsoles
>= Private
->TextOutListCount
) {
3019 Status
= ConSplitterGrowBuffer (
3020 sizeof (TEXT_OUT_AND_GOP_DATA
),
3021 &Private
->TextOutListCount
,
3022 (VOID
**) &Private
->TextOutList
3024 if (EFI_ERROR (Status
)) {
3025 return EFI_OUT_OF_RESOURCES
;
3028 // Also need to reallocate the TextOutModeMap table
3030 Status
= ConSplitterGrowMapTable (Private
);
3031 if (EFI_ERROR (Status
)) {
3032 return EFI_OUT_OF_RESOURCES
;
3036 TextAndGop
= &Private
->TextOutList
[CurrentNumOfConsoles
];
3038 TextAndGop
->TextOut
= TextOut
;
3039 TextAndGop
->GraphicsOutput
= GraphicsOutput
;
3040 TextAndGop
->UgaDraw
= UgaDraw
;
3042 if (CurrentNumOfConsoles
== 0) {
3044 // Add the first device's output mode to console splitter's mode list
3046 Status
= ConSplitterAddOutputMode (Private
, TextOut
);
3048 ConSplitterSyncOutputMode (Private
, TextOut
);
3051 Private
->CurrentNumberOfConsoles
++;
3054 // Scan both TextOutList, for the intersection TextOut device
3055 // maybe both ConOut and StdErr incorporate the same Text Out
3056 // device in them, thus the output of both should be synced.
3058 ConSplitterGetIntersectionBetweenConOutAndStrErr ();
3060 MaxMode
= Private
->TextOutMode
.MaxMode
;
3061 ASSERT (MaxMode
>= 1);
3063 DeviceStatus
= EFI_DEVICE_ERROR
;
3064 if (FeaturePcdGet (PcdConOutGopSupport
)) {
3066 // If GOP is produced by Consplitter, this device display mode will be added into Graphics Ouput modes.
3068 if ((GraphicsOutput
!= NULL
) || (UgaDraw
!= NULL
&& FeaturePcdGet (PcdUgaConsumeSupport
))) {
3069 DeviceStatus
= ConSplitterAddGraphicsOutputMode (Private
, GraphicsOutput
, UgaDraw
);
3073 if (FeaturePcdGet (PcdConOutUgaSupport
)) {
3075 // If UGA is produced by Consplitter
3077 if (GraphicsOutput
!= NULL
) {
3078 Status
= GraphicsOutput
->QueryMode (GraphicsOutput
, GraphicsOutput
->Mode
->Mode
, &SizeOfInfo
, &Info
);
3079 if (EFI_ERROR (Status
)) {
3082 ASSERT ( SizeOfInfo
<= sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
));
3084 UgaHorizontalResolution
= Info
->HorizontalResolution
;
3085 UgaVerticalResolution
= Info
->VerticalResolution
;
3089 } else if (UgaDraw
!= NULL
&& FeaturePcdGet (PcdUgaConsumeSupport
)) {
3090 Status
= UgaDraw
->GetMode (
3092 &UgaHorizontalResolution
,
3093 &UgaVerticalResolution
,
3097 if (!EFI_ERROR (Status
) && EFI_ERROR (DeviceStatus
)) {
3099 // if GetMode is successfully and UGA device hasn't been set, set it
3101 Status
= ConSplitterUgaDrawSetMode (
3103 UgaHorizontalResolution
,
3104 UgaVerticalResolution
,
3110 // If GetMode/SetMode is failed, set to 800x600 mode
3112 if(EFI_ERROR (Status
)) {
3113 Status
= ConSplitterUgaDrawSetMode (
3125 // After adding new console device, all existing console devices should be
3126 // synced to the current shared mode.
3128 ConsplitterSetConsoleOutMode (Private
);
3135 Remove Text Out Device in Consplitter Text Out list.
3137 @param Private Text Out Splitter pointer.
3138 @param TextOut Simple Text Output Pointer protocol pointer.
3140 @retval EFI_SUCCESS Text Out Device removed successfully.
3141 @retval EFI_NOT_FOUND No Text Out Device found.
3145 ConSplitterTextOutDeleteDevice (
3146 IN TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
,
3147 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
3151 UINTN CurrentNumOfConsoles
;
3152 TEXT_OUT_AND_GOP_DATA
*TextOutList
;
3156 // Remove the specified text-out device data structure from the Text out List,
3157 // and rearrange the remaining data structures in the Text out List.
3159 CurrentNumOfConsoles
= Private
->CurrentNumberOfConsoles
;
3160 Index
= (INT32
) CurrentNumOfConsoles
- 1;
3161 TextOutList
= Private
->TextOutList
;
3162 while (Index
>= 0) {
3163 if (TextOutList
->TextOut
== TextOut
) {
3164 if (TextOutList
->UgaDraw
!= NULL
&& FeaturePcdGet (PcdUgaConsumeSupport
)) {
3165 Private
->CurrentNumberOfUgaDraw
--;
3167 if (TextOutList
->GraphicsOutput
!= NULL
) {
3168 Private
->CurrentNumberOfGraphicsOutput
--;
3170 CopyMem (TextOutList
, TextOutList
+ 1, sizeof (TEXT_OUT_AND_GOP_DATA
) * Index
);
3171 CurrentNumOfConsoles
--;
3179 // The specified TextOut is not managed by the ConSplitter driver
3182 return EFI_NOT_FOUND
;
3185 if (CurrentNumOfConsoles
== 0) {
3187 // If the number of consoles is zero, reset all parameters
3189 Private
->CurrentNumberOfConsoles
= 0;
3190 Private
->TextOutMode
.MaxMode
= 1;
3191 Private
->TextOutQueryData
[0].Columns
= 80;
3192 Private
->TextOutQueryData
[0].Rows
= 25;
3193 TextOutSetMode (Private
, 0);
3198 // Max Mode is realy an intersection of the QueryMode command to all
3199 // devices. So we must copy the QueryMode of the first device to
3203 Private
->TextOutQueryData
,
3204 Private
->TextOutQueryDataCount
* sizeof (TEXT_OUT_SPLITTER_QUERY_DATA
)
3207 FreePool (Private
->TextOutModeMap
);
3208 Private
->TextOutModeMap
= NULL
;
3209 TextOutList
= Private
->TextOutList
;
3212 // Add the first TextOut to the QueryData array and ModeMap table
3214 Status
= ConSplitterAddOutputMode (Private
, TextOutList
->TextOut
);
3217 // Now add one by one
3220 Private
->CurrentNumberOfConsoles
= 1;
3222 while ((UINTN
) Index
< CurrentNumOfConsoles
) {
3223 ConSplitterSyncOutputMode (Private
, TextOutList
->TextOut
);
3225 Private
->CurrentNumberOfConsoles
++;
3229 ConSplitterGetIntersectionBetweenConOutAndStrErr ();
3236 Reset the input device and optionaly run diagnostics
3238 @param This Protocol instance pointer.
3239 @param ExtendedVerification Driver may perform diagnostics on reset.
3241 @retval EFI_SUCCESS The device was reset.
3242 @retval EFI_DEVICE_ERROR The device is not functioning properly and could
3248 ConSplitterTextInReset (
3249 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*This
,
3250 IN BOOLEAN ExtendedVerification
3254 EFI_STATUS ReturnStatus
;
3255 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3258 Private
= TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
3260 Private
->KeyEventSignalState
= FALSE
;
3263 // return the worst status met
3265 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
3266 Status
= Private
->TextInList
[Index
]->Reset (
3267 Private
->TextInList
[Index
],
3268 ExtendedVerification
3270 if (EFI_ERROR (Status
)) {
3271 ReturnStatus
= Status
;
3275 return ReturnStatus
;
3280 Reads the next keystroke from the input device. The WaitForKey Event can
3281 be used to test for existance of a keystroke via WaitForEvent () call.
3283 @param Private Protocol instance pointer.
3284 @param Key Driver may perform diagnostics on reset.
3286 @retval EFI_SUCCESS The keystroke information was returned.
3287 @retval EFI_NOT_READY There was no keystroke data availiable.
3288 @retval EFI_DEVICE_ERROR The keydtroke information was not returned due
3294 ConSplitterTextInPrivateReadKeyStroke (
3295 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
3296 OUT EFI_INPUT_KEY
*Key
3301 EFI_INPUT_KEY CurrentKey
;
3303 Key
->UnicodeChar
= 0;
3304 Key
->ScanCode
= SCAN_NULL
;
3307 // if no physical console input device exists, return EFI_NOT_READY;
3308 // if any physical console input device has key input,
3309 // return the key and EFI_SUCCESS.
3311 for (Index
= 0; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
3312 Status
= Private
->TextInList
[Index
]->ReadKeyStroke (
3313 Private
->TextInList
[Index
],
3316 if (!EFI_ERROR (Status
)) {
3322 return EFI_NOT_READY
;
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 This 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 ConSplitterTextInReadKeyStroke (
3343 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*This
,
3344 OUT EFI_INPUT_KEY
*Key
3347 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3349 Private
= TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
3351 Private
->KeyEventSignalState
= FALSE
;
3354 // Signal ConnectConIn event on first call in Lazy ConIn mode
3356 if (!mConInIsConnect
&& PcdGetBool (PcdConInConnectOnDemand
)) {
3357 DEBUG ((EFI_D_INFO
, "Connect ConIn in first ReadKeyStoke in Lazy ConIn mode.\n"));
3358 gBS
->SignalEvent (Private
->ConnectConIn
);
3359 mConInIsConnect
= TRUE
;
3362 return ConSplitterTextInPrivateReadKeyStroke (Private
, Key
);
3367 This event aggregates all the events of the ConIn devices in the spliter.
3369 If any events of physical ConIn devices are signaled, signal the ConIn
3370 spliter event. This will cause the calling code to call
3371 ConSplitterTextInReadKeyStroke ().
3373 @param Event The Event assoicated with callback.
3374 @param Context Context registered when Event was created.
3379 ConSplitterTextInWaitForKey (
3385 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3388 Private
= (TEXT_IN_SPLITTER_PRIVATE_DATA
*) Context
;
3390 if (Private
->KeyEventSignalState
) {
3392 // If KeyEventSignalState is flagged before, and not cleared by Reset() or ReadKeyStroke()
3394 gBS
->SignalEvent (Event
);
3399 // If any physical console input device has key input, signal the event.
3401 for (Index
= 0; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
3402 Status
= gBS
->CheckEvent (Private
->TextInList
[Index
]->WaitForKey
);
3403 if (!EFI_ERROR (Status
)) {
3404 gBS
->SignalEvent (Event
);
3405 Private
->KeyEventSignalState
= TRUE
;
3413 Test if the key has been registered on input device.
3415 @param RegsiteredData A pointer to a buffer that is filled in with the
3416 keystroke state data for the key that was
3418 @param InputData A pointer to a buffer that is filled in with the
3419 keystroke state data for the key that was
3422 @retval TRUE Key be pressed matches a registered key.
3423 @retval FLASE Match failed.
3428 IN EFI_KEY_DATA
*RegsiteredData
,
3429 IN EFI_KEY_DATA
*InputData
3432 ASSERT (RegsiteredData
!= NULL
&& InputData
!= NULL
);
3434 if ((RegsiteredData
->Key
.ScanCode
!= InputData
->Key
.ScanCode
) ||
3435 (RegsiteredData
->Key
.UnicodeChar
!= InputData
->Key
.UnicodeChar
)) {
3440 // Assume KeyShiftState/KeyToggleState = 0 in Registered key data means these state could be ignored.
3442 if (RegsiteredData
->KeyState
.KeyShiftState
!= 0 &&
3443 RegsiteredData
->KeyState
.KeyShiftState
!= InputData
->KeyState
.KeyShiftState
) {
3446 if (RegsiteredData
->KeyState
.KeyToggleState
!= 0 &&
3447 RegsiteredData
->KeyState
.KeyToggleState
!= InputData
->KeyState
.KeyToggleState
) {
3457 Reset the input device and optionaly run diagnostics
3459 @param This Protocol instance pointer.
3460 @param ExtendedVerification Driver may perform diagnostics on reset.
3462 @retval EFI_SUCCESS The device was reset.
3463 @retval EFI_DEVICE_ERROR The device is not functioning properly and could
3469 ConSplitterTextInResetEx (
3470 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*This
,
3471 IN BOOLEAN ExtendedVerification
3475 EFI_STATUS ReturnStatus
;
3476 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3479 Private
= TEXT_IN_EX_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
3481 Private
->KeyEventSignalState
= FALSE
;
3484 // return the worst status met
3486 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfExConsoles
; Index
++) {
3487 Status
= Private
->TextInExList
[Index
]->Reset (
3488 Private
->TextInExList
[Index
],
3489 ExtendedVerification
3491 if (EFI_ERROR (Status
)) {
3492 ReturnStatus
= Status
;
3496 return ReturnStatus
;
3502 Reads the next keystroke from the input device. The WaitForKey Event can
3503 be used to test for existance of a keystroke via WaitForEvent () call.
3505 @param This Protocol instance pointer.
3506 @param KeyData A pointer to a buffer that is filled in with the
3507 keystroke state data for the key that was
3510 @retval EFI_SUCCESS The keystroke information was returned.
3511 @retval EFI_NOT_READY There was no keystroke data availiable.
3512 @retval EFI_DEVICE_ERROR The keystroke information was not returned due
3514 @retval EFI_INVALID_PARAMETER KeyData is NULL.
3519 ConSplitterTextInReadKeyStrokeEx (
3520 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*This
,
3521 OUT EFI_KEY_DATA
*KeyData
3524 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3527 EFI_KEY_DATA CurrentKeyData
;
3530 if (KeyData
== NULL
) {
3531 return EFI_INVALID_PARAMETER
;
3534 Private
= TEXT_IN_EX_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
3536 Private
->KeyEventSignalState
= FALSE
;
3538 KeyData
->Key
.UnicodeChar
= 0;
3539 KeyData
->Key
.ScanCode
= SCAN_NULL
;
3542 // Signal ConnectConIn event on first call in Lazy ConIn mode
3544 if (!mConInIsConnect
&& PcdGetBool (PcdConInConnectOnDemand
)) {
3545 DEBUG ((EFI_D_INFO
, "Connect ConIn in first ReadKeyStoke in Lazy ConIn mode.\n"));
3546 gBS
->SignalEvent (Private
->ConnectConIn
);
3547 mConInIsConnect
= TRUE
;
3551 // if no physical console input device exists, return EFI_NOT_READY;
3552 // if any physical console input device has key input,
3553 // return the key and EFI_SUCCESS.
3555 for (Index
= 0; Index
< Private
->CurrentNumberOfExConsoles
; Index
++) {
3556 Status
= Private
->TextInExList
[Index
]->ReadKeyStrokeEx (
3557 Private
->TextInExList
[Index
],
3560 if (!EFI_ERROR (Status
)) {
3561 CopyMem (KeyData
, &CurrentKeyData
, sizeof (CurrentKeyData
));
3566 return EFI_NOT_READY
;
3571 Set certain state for the input device.
3573 @param This Protocol instance pointer.
3574 @param KeyToggleState A pointer to the EFI_KEY_TOGGLE_STATE to set the
3575 state for the input device.
3577 @retval EFI_SUCCESS The device state was set successfully.
3578 @retval EFI_DEVICE_ERROR The device is not functioning correctly and
3579 could not have the setting adjusted.
3580 @retval EFI_UNSUPPORTED The device does not have the ability to set its
3582 @retval EFI_INVALID_PARAMETER KeyToggleState is NULL.
3587 ConSplitterTextInSetState (
3588 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*This
,
3589 IN EFI_KEY_TOGGLE_STATE
*KeyToggleState
3592 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3596 if (KeyToggleState
== NULL
) {
3597 return EFI_INVALID_PARAMETER
;
3600 Private
= TEXT_IN_EX_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
3603 // if no physical console input device exists, return EFI_SUCCESS;
3604 // otherwise return the status of setting state of physical console input device
3606 for (Index
= 0; Index
< Private
->CurrentNumberOfExConsoles
; Index
++) {
3607 Status
= Private
->TextInExList
[Index
]->SetState (
3608 Private
->TextInExList
[Index
],
3611 if (EFI_ERROR (Status
)) {
3622 Register a notification function for a particular keystroke for the input device.
3624 @param This Protocol instance pointer.
3625 @param KeyData A pointer to a buffer that is filled in with the
3626 keystroke information data for the key that was
3628 @param KeyNotificationFunction Points to the function to be called when the key
3629 sequence is typed specified by KeyData.
3630 @param NotifyHandle Points to the unique handle assigned to the
3631 registered notification.
3633 @retval EFI_SUCCESS The notification function was registered
3635 @retval EFI_OUT_OF_RESOURCES Unable to allocate resources for necesssary data
3637 @retval EFI_INVALID_PARAMETER KeyData or KeyNotificationFunction or NotifyHandle is NULL.
3642 ConSplitterTextInRegisterKeyNotify (
3643 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*This
,
3644 IN EFI_KEY_DATA
*KeyData
,
3645 IN EFI_KEY_NOTIFY_FUNCTION KeyNotificationFunction
,
3646 OUT VOID
**NotifyHandle
3649 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3652 TEXT_IN_EX_SPLITTER_NOTIFY
*NewNotify
;
3654 TEXT_IN_EX_SPLITTER_NOTIFY
*CurrentNotify
;
3657 if (KeyData
== NULL
|| NotifyHandle
== NULL
|| KeyNotificationFunction
== NULL
) {
3658 return EFI_INVALID_PARAMETER
;
3661 Private
= TEXT_IN_EX_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
3664 // Return EFI_SUCCESS if the (KeyData, NotificationFunction) is already registered.
3666 for (Link
= Private
->NotifyList
.ForwardLink
; Link
!= &Private
->NotifyList
; Link
= Link
->ForwardLink
) {
3667 CurrentNotify
= TEXT_IN_EX_SPLITTER_NOTIFY_FROM_THIS (Link
);
3668 if (IsKeyRegistered (&CurrentNotify
->KeyData
, KeyData
)) {
3669 if (CurrentNotify
->KeyNotificationFn
== KeyNotificationFunction
) {
3670 *NotifyHandle
= CurrentNotify
;
3677 // Allocate resource to save the notification function
3679 NewNotify
= (TEXT_IN_EX_SPLITTER_NOTIFY
*) AllocateZeroPool (sizeof (TEXT_IN_EX_SPLITTER_NOTIFY
));
3680 if (NewNotify
== NULL
) {
3681 return EFI_OUT_OF_RESOURCES
;
3683 NewNotify
->NotifyHandleList
= (EFI_HANDLE
*) AllocateZeroPool (sizeof (EFI_HANDLE
) * Private
->TextInExListCount
);
3684 if (NewNotify
->NotifyHandleList
== NULL
) {
3685 gBS
->FreePool (NewNotify
);
3686 return EFI_OUT_OF_RESOURCES
;
3688 NewNotify
->Signature
= TEXT_IN_EX_SPLITTER_NOTIFY_SIGNATURE
;
3689 NewNotify
->KeyNotificationFn
= KeyNotificationFunction
;
3690 CopyMem (&NewNotify
->KeyData
, KeyData
, sizeof (EFI_KEY_DATA
));
3693 // Return the wrong status of registering key notify of
3694 // physical console input device if meet problems
3696 for (Index
= 0; Index
< Private
->CurrentNumberOfExConsoles
; Index
++) {
3697 Status
= Private
->TextInExList
[Index
]->RegisterKeyNotify (
3698 Private
->TextInExList
[Index
],
3700 KeyNotificationFunction
,
3701 &NewNotify
->NotifyHandleList
[Index
]
3703 if (EFI_ERROR (Status
)) {
3705 // Un-register the key notify on all physical console input devices
3707 while (Index
-- != 0) {
3708 Private
->TextInExList
[Index
]->UnregisterKeyNotify (
3709 Private
->TextInExList
[Index
],
3710 NewNotify
->NotifyHandleList
[Index
]
3713 gBS
->FreePool (NewNotify
->NotifyHandleList
);
3714 gBS
->FreePool (NewNotify
);
3719 InsertTailList (&mConIn
.NotifyList
, &NewNotify
->NotifyEntry
);
3721 *NotifyHandle
= NewNotify
;
3729 Remove a registered notification function from a particular keystroke.
3731 @param This Protocol instance pointer.
3732 @param NotificationHandle The handle of the notification function being
3735 @retval EFI_SUCCESS The notification function was unregistered
3737 @retval EFI_INVALID_PARAMETER The NotificationHandle is invalid.
3742 ConSplitterTextInUnregisterKeyNotify (
3743 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*This
,
3744 IN VOID
*NotificationHandle
3747 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3749 TEXT_IN_EX_SPLITTER_NOTIFY
*CurrentNotify
;
3752 if (NotificationHandle
== NULL
) {
3753 return EFI_INVALID_PARAMETER
;
3756 Private
= TEXT_IN_EX_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
3758 for (Link
= Private
->NotifyList
.ForwardLink
; Link
!= &Private
->NotifyList
; Link
= Link
->ForwardLink
) {
3759 CurrentNotify
= TEXT_IN_EX_SPLITTER_NOTIFY_FROM_THIS (Link
);
3760 if (CurrentNotify
== NotificationHandle
) {
3761 for (Index
= 0; Index
< Private
->CurrentNumberOfExConsoles
; Index
++) {
3762 Private
->TextInExList
[Index
]->UnregisterKeyNotify (
3763 Private
->TextInExList
[Index
],
3764 CurrentNotify
->NotifyHandleList
[Index
]
3767 RemoveEntryList (&CurrentNotify
->NotifyEntry
);
3769 gBS
->FreePool (CurrentNotify
->NotifyHandleList
);
3770 gBS
->FreePool (CurrentNotify
);
3776 // NotificationHandle is not found in database
3778 return EFI_INVALID_PARAMETER
;
3783 Reset the input device and optionaly run diagnostics
3785 @param This Protocol instance pointer.
3786 @param ExtendedVerification Driver may perform diagnostics on reset.
3788 @retval EFI_SUCCESS The device was reset.
3789 @retval EFI_DEVICE_ERROR The device is not functioning properly and could
3795 ConSplitterSimplePointerReset (
3796 IN EFI_SIMPLE_POINTER_PROTOCOL
*This
,
3797 IN BOOLEAN ExtendedVerification
3801 EFI_STATUS ReturnStatus
;
3802 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3805 Private
= TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_SIMPLE_POINTER_THIS (This
);
3807 Private
->InputEventSignalState
= FALSE
;
3809 if (Private
->CurrentNumberOfPointers
== 0) {
3813 // return the worst status met
3815 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfPointers
; Index
++) {
3816 Status
= Private
->PointerList
[Index
]->Reset (
3817 Private
->PointerList
[Index
],
3818 ExtendedVerification
3820 if (EFI_ERROR (Status
)) {
3821 ReturnStatus
= Status
;
3825 return ReturnStatus
;
3830 Reads the next keystroke from the input device. The WaitForKey Event can
3831 be used to test for existance of a keystroke via WaitForEvent () call.
3833 @param Private Protocol instance pointer.
3834 @param State The state information of simple pointer device.
3836 @retval EFI_SUCCESS The keystroke information was returned.
3837 @retval EFI_NOT_READY There was no keystroke data availiable.
3838 @retval EFI_DEVICE_ERROR The keydtroke information was not returned due
3844 ConSplitterSimplePointerPrivateGetState (
3845 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
3846 IN OUT EFI_SIMPLE_POINTER_STATE
*State
3850 EFI_STATUS ReturnStatus
;
3852 EFI_SIMPLE_POINTER_STATE CurrentState
;
3854 State
->RelativeMovementX
= 0;
3855 State
->RelativeMovementY
= 0;
3856 State
->RelativeMovementZ
= 0;
3857 State
->LeftButton
= FALSE
;
3858 State
->RightButton
= FALSE
;
3861 // if no physical console input device exists, return EFI_NOT_READY;
3862 // if any physical console input device has key input,
3863 // return the key and EFI_SUCCESS.
3865 ReturnStatus
= EFI_NOT_READY
;
3866 for (Index
= 0; Index
< Private
->CurrentNumberOfPointers
; Index
++) {
3868 Status
= Private
->PointerList
[Index
]->GetState (
3869 Private
->PointerList
[Index
],
3872 if (!EFI_ERROR (Status
)) {
3873 if (ReturnStatus
== EFI_NOT_READY
) {
3874 ReturnStatus
= EFI_SUCCESS
;
3877 if (CurrentState
.LeftButton
) {
3878 State
->LeftButton
= TRUE
;
3881 if (CurrentState
.RightButton
) {
3882 State
->RightButton
= TRUE
;
3885 if (CurrentState
.RelativeMovementX
!= 0 && Private
->PointerList
[Index
]->Mode
->ResolutionX
!= 0) {
3886 State
->RelativeMovementX
+= (CurrentState
.RelativeMovementX
* (INT32
) Private
->SimplePointerMode
.ResolutionX
) / (INT32
) Private
->PointerList
[Index
]->Mode
->ResolutionX
;
3889 if (CurrentState
.RelativeMovementY
!= 0 && Private
->PointerList
[Index
]->Mode
->ResolutionY
!= 0) {
3890 State
->RelativeMovementY
+= (CurrentState
.RelativeMovementY
* (INT32
) Private
->SimplePointerMode
.ResolutionY
) / (INT32
) Private
->PointerList
[Index
]->Mode
->ResolutionY
;
3893 if (CurrentState
.RelativeMovementZ
!= 0 && Private
->PointerList
[Index
]->Mode
->ResolutionZ
!= 0) {
3894 State
->RelativeMovementZ
+= (CurrentState
.RelativeMovementZ
* (INT32
) Private
->SimplePointerMode
.ResolutionZ
) / (INT32
) Private
->PointerList
[Index
]->Mode
->ResolutionZ
;
3896 } else if (Status
== EFI_DEVICE_ERROR
) {
3897 ReturnStatus
= EFI_DEVICE_ERROR
;
3901 return ReturnStatus
;
3906 Reads the next keystroke from the input device. The WaitForKey Event can
3907 be used to test for existance of a keystroke via WaitForEvent () call.
3909 @param This A pointer to protocol instance.
3910 @param State A pointer to state information on the pointer device
3912 @retval EFI_SUCCESS The keystroke information was returned in State.
3913 @retval EFI_NOT_READY There was no keystroke data availiable.
3914 @retval EFI_DEVICE_ERROR The keydtroke information was not returned due
3920 ConSplitterSimplePointerGetState (
3921 IN EFI_SIMPLE_POINTER_PROTOCOL
*This
,
3922 IN OUT EFI_SIMPLE_POINTER_STATE
*State
3925 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3927 Private
= TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_SIMPLE_POINTER_THIS (This
);
3929 Private
->InputEventSignalState
= FALSE
;
3931 return ConSplitterSimplePointerPrivateGetState (Private
, State
);
3936 This event agregates all the events of the ConIn devices in the spliter.
3937 If any events of physical ConIn devices are signaled, signal the ConIn
3938 spliter event. This will cause the calling code to call
3939 ConSplitterTextInReadKeyStroke ().
3941 @param Event The Event assoicated with callback.
3942 @param Context Context registered when Event was created.
3947 ConSplitterSimplePointerWaitForInput (
3953 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3956 Private
= (TEXT_IN_SPLITTER_PRIVATE_DATA
*) Context
;
3959 // if InputEventSignalState is flagged before, and not cleared by Reset() or ReadKeyStroke()
3961 if (Private
->InputEventSignalState
) {
3962 gBS
->SignalEvent (Event
);
3966 // if any physical console input device has key input, signal the event.
3968 for (Index
= 0; Index
< Private
->CurrentNumberOfPointers
; Index
++) {
3969 Status
= gBS
->CheckEvent (Private
->PointerList
[Index
]->WaitForInput
);
3970 if (!EFI_ERROR (Status
)) {
3971 gBS
->SignalEvent (Event
);
3972 Private
->InputEventSignalState
= TRUE
;
3978 Resets the pointer device hardware.
3980 @param This Protocol instance pointer.
3981 @param ExtendedVerification Driver may perform diagnostics on reset.
3983 @retval EFI_SUCCESS The device was reset.
3984 @retval EFI_DEVICE_ERROR The device is not functioning correctly and
3990 ConSplitterAbsolutePointerReset (
3991 IN EFI_ABSOLUTE_POINTER_PROTOCOL
*This
,
3992 IN BOOLEAN ExtendedVerification
3996 EFI_STATUS ReturnStatus
;
3997 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
4000 Private
= TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_ABSOLUTE_POINTER_THIS (This
);
4002 Private
->AbsoluteInputEventSignalState
= FALSE
;
4004 if (Private
->CurrentNumberOfAbsolutePointers
== 0) {
4008 // return the worst status met
4010 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfAbsolutePointers
; Index
++) {
4011 Status
= Private
->AbsolutePointerList
[Index
]->Reset (
4012 Private
->AbsolutePointerList
[Index
],
4013 ExtendedVerification
4015 if (EFI_ERROR (Status
)) {
4016 ReturnStatus
= Status
;
4020 return ReturnStatus
;
4025 Retrieves the current state of a pointer device.
4027 @param This Protocol instance pointer.
4028 @param State A pointer to the state information on the
4031 @retval EFI_SUCCESS The state of the pointer device was returned in
4033 @retval EFI_NOT_READY The state of the pointer device has not changed
4034 since the last call to GetState().
4035 @retval EFI_DEVICE_ERROR A device error occurred while attempting to
4036 retrieve the pointer device's current state.
4041 ConSplitterAbsolutePointerGetState (
4042 IN EFI_ABSOLUTE_POINTER_PROTOCOL
*This
,
4043 IN OUT EFI_ABSOLUTE_POINTER_STATE
*State
4046 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
4048 EFI_STATUS ReturnStatus
;
4050 EFI_ABSOLUTE_POINTER_STATE CurrentState
;
4053 Private
= TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_ABSOLUTE_POINTER_THIS (This
);
4055 Private
->AbsoluteInputEventSignalState
= FALSE
;
4057 State
->CurrentX
= 0;
4058 State
->CurrentY
= 0;
4059 State
->CurrentZ
= 0;
4060 State
->ActiveButtons
= 0;
4063 // if no physical pointer device exists, return EFI_NOT_READY;
4064 // if any physical pointer device has changed state,
4065 // return the state and EFI_SUCCESS.
4067 ReturnStatus
= EFI_NOT_READY
;
4068 for (Index
= 0; Index
< Private
->CurrentNumberOfAbsolutePointers
; Index
++) {
4070 Status
= Private
->AbsolutePointerList
[Index
]->GetState (
4071 Private
->AbsolutePointerList
[Index
],
4074 if (!EFI_ERROR (Status
)) {
4075 if (ReturnStatus
== EFI_NOT_READY
) {
4076 ReturnStatus
= EFI_SUCCESS
;
4079 State
->ActiveButtons
= CurrentState
.ActiveButtons
;
4081 if (!(Private
->AbsolutePointerMode
.AbsoluteMinX
== 0 && Private
->AbsolutePointerMode
.AbsoluteMaxX
== 0)) {
4082 State
->CurrentX
= CurrentState
.CurrentX
;
4084 if (!(Private
->AbsolutePointerMode
.AbsoluteMinY
== 0 && Private
->AbsolutePointerMode
.AbsoluteMaxY
== 0)) {
4085 State
->CurrentY
= CurrentState
.CurrentY
;
4087 if (!(Private
->AbsolutePointerMode
.AbsoluteMinZ
== 0 && Private
->AbsolutePointerMode
.AbsoluteMaxZ
== 0)) {
4088 State
->CurrentZ
= CurrentState
.CurrentZ
;
4091 } else if (Status
== EFI_DEVICE_ERROR
) {
4092 ReturnStatus
= EFI_DEVICE_ERROR
;
4096 return ReturnStatus
;
4101 This event agregates all the events of the pointer devices in the splitter.
4102 If any events of physical pointer devices are signaled, signal the pointer
4103 splitter event. This will cause the calling code to call
4104 ConSplitterAbsolutePointerGetState ().
4106 @param Event The Event assoicated with callback.
4107 @param Context Context registered when Event was created.
4112 ConSplitterAbsolutePointerWaitForInput (
4118 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
4121 Private
= (TEXT_IN_SPLITTER_PRIVATE_DATA
*) Context
;
4124 // if AbsoluteInputEventSignalState is flagged before,
4125 // and not cleared by Reset() or GetState(), signal it
4127 if (Private
->AbsoluteInputEventSignalState
) {
4128 gBS
->SignalEvent (Event
);
4132 // if any physical console input device has key input, signal the event.
4134 for (Index
= 0; Index
< Private
->CurrentNumberOfAbsolutePointers
; Index
++) {
4135 Status
= gBS
->CheckEvent (Private
->AbsolutePointerList
[Index
]->WaitForInput
);
4136 if (!EFI_ERROR (Status
)) {
4137 gBS
->SignalEvent (Event
);
4138 Private
->AbsoluteInputEventSignalState
= TRUE
;
4145 Reset the text output device hardware and optionaly run diagnostics
4147 @param This Protocol instance pointer.
4148 @param ExtendedVerification Driver may perform more exhaustive verfication
4149 operation of the device during reset.
4151 @retval EFI_SUCCESS The text output device was reset.
4152 @retval EFI_DEVICE_ERROR The text output device is not functioning
4153 correctly and could not be reset.
4158 ConSplitterTextOutReset (
4159 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4160 IN BOOLEAN ExtendedVerification
4164 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4166 EFI_STATUS ReturnStatus
;
4168 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4171 // return the worst status met
4173 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
4174 Status
= Private
->TextOutList
[Index
].TextOut
->Reset (
4175 Private
->TextOutList
[Index
].TextOut
,
4176 ExtendedVerification
4178 if (EFI_ERROR (Status
)) {
4179 ReturnStatus
= Status
;
4183 This
->SetAttribute (This
, EFI_TEXT_ATTR (This
->Mode
->Attribute
& 0x0F, EFI_BLACK
));
4186 // reset all mode parameters
4188 TextOutSetMode (Private
, 0);
4190 return ReturnStatus
;
4195 Write a Unicode string to the output device.
4197 @param This Protocol instance pointer.
4198 @param WString The NULL-terminated Unicode string to be
4199 displayed on the output device(s). All output
4200 devices must also support the Unicode drawing
4201 defined in this file.
4203 @retval EFI_SUCCESS The string was output to the device.
4204 @retval EFI_DEVICE_ERROR The device reported an error while attempting to
4206 @retval EFI_UNSUPPORTED The output device's mode is not currently in a
4208 @retval EFI_WARN_UNKNOWN_GLYPH This warning code indicates that some of the
4209 characters in the Unicode string could not be
4210 rendered and were skipped.
4215 ConSplitterTextOutOutputString (
4216 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4221 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4223 EFI_STATUS ReturnStatus
;
4227 This
->SetAttribute (This
, This
->Mode
->Attribute
);
4229 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4232 // return the worst status met
4234 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
4235 Status
= Private
->TextOutList
[Index
].TextOut
->OutputString (
4236 Private
->TextOutList
[Index
].TextOut
,
4239 if (EFI_ERROR (Status
)) {
4240 ReturnStatus
= Status
;
4244 if (Private
->CurrentNumberOfConsoles
> 0) {
4245 Private
->TextOutMode
.CursorColumn
= Private
->TextOutList
[0].TextOut
->Mode
->CursorColumn
;
4246 Private
->TextOutMode
.CursorRow
= Private
->TextOutList
[0].TextOut
->Mode
->CursorRow
;
4249 // When there is no real console devices in system,
4250 // update cursor position for the virtual device in consplitter.
4252 Private
->TextOut
.QueryMode (
4254 Private
->TextOutMode
.Mode
,
4258 for (; *WString
!= CHAR_NULL
; WString
++) {
4260 case CHAR_BACKSPACE
:
4261 if (Private
->TextOutMode
.CursorColumn
== 0 && Private
->TextOutMode
.CursorRow
> 0) {
4262 Private
->TextOutMode
.CursorRow
--;
4263 Private
->TextOutMode
.CursorColumn
= (INT32
) (MaxColumn
- 1);
4264 } else if (Private
->TextOutMode
.CursorColumn
> 0) {
4265 Private
->TextOutMode
.CursorColumn
--;
4270 if (Private
->TextOutMode
.CursorRow
< (INT32
) (MaxRow
- 1)) {
4271 Private
->TextOutMode
.CursorRow
++;
4275 case CHAR_CARRIAGE_RETURN
:
4276 Private
->TextOutMode
.CursorColumn
= 0;
4280 if (Private
->TextOutMode
.CursorColumn
< (INT32
) (MaxColumn
- 1)) {
4281 Private
->TextOutMode
.CursorColumn
++;
4283 Private
->TextOutMode
.CursorColumn
= 0;
4284 if (Private
->TextOutMode
.CursorRow
< (INT32
) (MaxRow
- 1)) {
4285 Private
->TextOutMode
.CursorRow
++;
4293 return ReturnStatus
;
4298 Verifies that all characters in a Unicode string can be output to the
4301 @param This Protocol instance pointer.
4302 @param WString The NULL-terminated Unicode string to be
4303 examined for the output device(s).
4305 @retval EFI_SUCCESS The device(s) are capable of rendering the
4307 @retval EFI_UNSUPPORTED Some of the characters in the Unicode string
4308 cannot be rendered by one or more of the output
4309 devices mapped by the EFI handle.
4314 ConSplitterTextOutTestString (
4315 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4320 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4322 EFI_STATUS ReturnStatus
;
4324 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4327 // return the worst status met
4329 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
4330 Status
= Private
->TextOutList
[Index
].TextOut
->TestString (
4331 Private
->TextOutList
[Index
].TextOut
,
4334 if (EFI_ERROR (Status
)) {
4335 ReturnStatus
= Status
;
4339 // There is no DevNullTextOutTestString () since a Unicode buffer would
4340 // always return EFI_SUCCESS.
4341 // ReturnStatus will be EFI_SUCCESS if no consoles are present
4343 return ReturnStatus
;
4348 Returns information for an available text mode that the output device(s)
4351 @param This Protocol instance pointer.
4352 @param ModeNumber The mode number to return information on.
4353 @param Columns Returns the columns of the text output device
4354 for the requested ModeNumber.
4355 @param Rows Returns the rows of the text output device
4356 for the requested ModeNumber.
4358 @retval EFI_SUCCESS The requested mode information was returned.
4359 @retval EFI_DEVICE_ERROR The device had an error and could not complete
4361 @retval EFI_UNSUPPORTED The mode number was not valid.
4366 ConSplitterTextOutQueryMode (
4367 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4368 IN UINTN ModeNumber
,
4373 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4375 INT32
*TextOutModeMap
;
4377 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4380 // Check whether param ModeNumber is valid.
4381 // ModeNumber should be within range 0 ~ MaxMode - 1.
4383 if ( (ModeNumber
> (UINTN
)(((UINT32
)-1)>>1)) ) {
4384 return EFI_UNSUPPORTED
;
4387 if ((INT32
) ModeNumber
>= This
->Mode
->MaxMode
) {
4388 return EFI_UNSUPPORTED
;
4392 // We get the available mode from mode intersection map if it's available
4394 if (Private
->TextOutModeMap
!= NULL
) {
4395 TextOutModeMap
= Private
->TextOutModeMap
+ Private
->TextOutListCount
* ModeNumber
;
4396 CurrentMode
= (UINTN
)(*TextOutModeMap
);
4397 *Columns
= Private
->TextOutQueryData
[CurrentMode
].Columns
;
4398 *Rows
= Private
->TextOutQueryData
[CurrentMode
].Rows
;
4400 *Columns
= Private
->TextOutQueryData
[ModeNumber
].Columns
;
4401 *Rows
= Private
->TextOutQueryData
[ModeNumber
].Rows
;
4404 if (*Columns
<= 0 && *Rows
<= 0) {
4405 return EFI_UNSUPPORTED
;
4414 Sets the output device(s) to a specified mode.
4416 @param This Protocol instance pointer.
4417 @param ModeNumber The mode number to set.
4419 @retval EFI_SUCCESS The requested text mode was set.
4420 @retval EFI_DEVICE_ERROR The device had an error and could not complete
4422 @retval EFI_UNSUPPORTED The mode number was not valid.
4427 ConSplitterTextOutSetMode (
4428 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4433 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4435 INT32
*TextOutModeMap
;
4436 EFI_STATUS ReturnStatus
;
4438 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4441 // Check whether param ModeNumber is valid.
4442 // ModeNumber should be within range 0 ~ MaxMode - 1.
4444 if ( (ModeNumber
> (UINTN
)(((UINT32
)-1)>>1)) ) {
4445 return EFI_UNSUPPORTED
;
4448 if ((INT32
) ModeNumber
>= This
->Mode
->MaxMode
) {
4449 return EFI_UNSUPPORTED
;
4452 // If the mode is being set to the curent mode, then just clear the screen and return.
4454 if (Private
->TextOutMode
.Mode
== (INT32
) ModeNumber
) {
4455 return ConSplitterTextOutClearScreen (This
);
4458 // return the worst status met
4460 TextOutModeMap
= Private
->TextOutModeMap
+ Private
->TextOutListCount
* ModeNumber
;
4461 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
4462 Status
= Private
->TextOutList
[Index
].TextOut
->SetMode (
4463 Private
->TextOutList
[Index
].TextOut
,
4464 TextOutModeMap
[Index
]
4466 if (EFI_ERROR (Status
)) {
4467 ReturnStatus
= Status
;
4472 // Set mode parameter to specified mode number
4474 TextOutSetMode (Private
, ModeNumber
);
4476 return ReturnStatus
;
4481 Sets the background and foreground colors for the OutputString () and
4482 ClearScreen () functions.
4484 @param This Protocol instance pointer.
4485 @param Attribute The attribute to set. Bits 0..3 are the
4486 foreground color, and bits 4..6 are the
4487 background color. All other bits are undefined
4488 and must be zero. The valid Attributes are
4489 defined in this file.
4491 @retval EFI_SUCCESS The attribute was set.
4492 @retval EFI_DEVICE_ERROR The device had an error and could not complete
4494 @retval EFI_UNSUPPORTED The attribute requested is not defined.
4499 ConSplitterTextOutSetAttribute (
4500 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4505 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4507 EFI_STATUS ReturnStatus
;
4509 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4512 // Check whether param Attribute is valid.
4514 if ( (Attribute
> (UINTN
)(((UINT32
)-1)>>1)) ) {
4515 return EFI_UNSUPPORTED
;
4519 // return the worst status met
4521 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
4522 Status
= Private
->TextOutList
[Index
].TextOut
->SetAttribute (
4523 Private
->TextOutList
[Index
].TextOut
,
4526 if (EFI_ERROR (Status
)) {
4527 ReturnStatus
= Status
;
4531 Private
->TextOutMode
.Attribute
= (INT32
) Attribute
;
4533 return ReturnStatus
;
4538 Clears the output device(s) display to the currently selected background
4541 @param This Protocol instance pointer.
4543 @retval EFI_SUCCESS The operation completed successfully.
4544 @retval EFI_DEVICE_ERROR The device had an error and could not complete
4546 @retval EFI_UNSUPPORTED The output device is not in a valid text mode.
4551 ConSplitterTextOutClearScreen (
4552 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
4556 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4558 EFI_STATUS ReturnStatus
;
4560 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4563 // return the worst status met
4565 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
4566 Status
= Private
->TextOutList
[Index
].TextOut
->ClearScreen (Private
->TextOutList
[Index
].TextOut
);
4567 if (EFI_ERROR (Status
)) {
4568 ReturnStatus
= Status
;
4573 // No need to do extra check here as whether (Column, Row) is valid has
4574 // been checked in ConSplitterTextOutSetCursorPosition. And (0, 0) should
4575 // always be supported.
4577 Private
->TextOutMode
.CursorColumn
= 0;
4578 Private
->TextOutMode
.CursorRow
= 0;
4579 Private
->TextOutMode
.CursorVisible
= TRUE
;
4581 return ReturnStatus
;
4586 Sets the current coordinates of the cursor position
4588 @param This Protocol instance pointer.
4589 @param Column The column position to set the cursor to. Must be
4590 greater than or equal to zero and less than the
4591 number of columns by QueryMode ().
4592 @param Row The row position to set the cursor to. Must be
4593 greater than or equal to zero and less than the
4594 number of rows by QueryMode ().
4596 @retval EFI_SUCCESS The operation completed successfully.
4597 @retval EFI_DEVICE_ERROR The device had an error and could not complete
4599 @retval EFI_UNSUPPORTED The output device is not in a valid text mode,
4600 or the cursor position is invalid for the
4606 ConSplitterTextOutSetCursorPosition (
4607 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4613 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4615 EFI_STATUS ReturnStatus
;
4618 INT32
*TextOutModeMap
;
4622 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4623 TextOutModeMap
= NULL
;
4624 ModeNumber
= Private
->TextOutMode
.Mode
;
4627 // Get current MaxColumn and MaxRow from intersection map
4629 if (Private
->TextOutModeMap
!= NULL
) {
4630 TextOutModeMap
= Private
->TextOutModeMap
+ Private
->TextOutListCount
* ModeNumber
;
4631 CurrentMode
= *TextOutModeMap
;
4633 CurrentMode
= ModeNumber
;
4636 MaxColumn
= Private
->TextOutQueryData
[CurrentMode
].Columns
;
4637 MaxRow
= Private
->TextOutQueryData
[CurrentMode
].Rows
;
4639 if (Column
>= MaxColumn
|| Row
>= MaxRow
) {
4640 return EFI_UNSUPPORTED
;
4643 // return the worst status met
4645 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
4646 Status
= Private
->TextOutList
[Index
].TextOut
->SetCursorPosition (
4647 Private
->TextOutList
[Index
].TextOut
,
4651 if (EFI_ERROR (Status
)) {
4652 ReturnStatus
= Status
;
4657 // No need to do extra check here as whether (Column, Row) is valid has
4658 // been checked in ConSplitterTextOutSetCursorPosition. And (0, 0) should
4659 // always be supported.
4661 Private
->TextOutMode
.CursorColumn
= (INT32
) Column
;
4662 Private
->TextOutMode
.CursorRow
= (INT32
) Row
;
4664 return ReturnStatus
;
4669 Makes the cursor visible or invisible
4671 @param This Protocol instance pointer.
4672 @param Visible If TRUE, the cursor is set to be visible. If
4673 FALSE, the cursor is set to be invisible.
4675 @retval EFI_SUCCESS The operation completed successfully.
4676 @retval EFI_DEVICE_ERROR The device had an error and could not complete
4677 the request, or the device does not support
4678 changing the cursor mode.
4679 @retval EFI_UNSUPPORTED The output device is not in a valid text mode.
4684 ConSplitterTextOutEnableCursor (
4685 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4690 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4692 EFI_STATUS ReturnStatus
;
4694 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4697 // return the worst status met
4699 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
4700 Status
= Private
->TextOutList
[Index
].TextOut
->EnableCursor (
4701 Private
->TextOutList
[Index
].TextOut
,
4704 if (EFI_ERROR (Status
)) {
4705 ReturnStatus
= Status
;
4709 Private
->TextOutMode
.CursorVisible
= Visible
;
4711 return ReturnStatus
;
4716 An empty function to pass error checking of CreateEventEx ().
4718 @param Event Event whose notification function is being invoked.
4719 @param Context Pointer to the notification function's context,
4720 which is implementation-dependent.
4725 ConSplitterEmptyCallbackFunction (