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
628 Construct console output devices' private data.
630 @param ConOutPrivate A pointer to the TEXT_OUT_SPLITTER_PRIVATE_DATA
633 @retval EFI_OUT_OF_RESOURCES Out of resources.
634 @retval EFI_SUCCESS Text Input Devcie's private data has been constructed.
638 ConSplitterTextOutConstructor (
639 TEXT_OUT_SPLITTER_PRIVATE_DATA
*ConOutPrivate
643 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*Info
;
646 // Copy protocols template
648 if (FeaturePcdGet (PcdConOutUgaSupport
)) {
649 CopyMem (&ConOutPrivate
->UgaDraw
, &mUgaDrawProtocolTemplate
, sizeof (EFI_UGA_DRAW_PROTOCOL
));
651 if (FeaturePcdGet (PcdConOutGopSupport
)) {
652 CopyMem (&ConOutPrivate
->GraphicsOutput
, &mGraphicsOutputProtocolTemplate
, sizeof (EFI_GRAPHICS_OUTPUT_PROTOCOL
));
656 // Initilize console output splitter's private data.
658 ConOutPrivate
->TextOut
.Mode
= &ConOutPrivate
->TextOutMode
;
661 // When new console device is added, the new mode will be set later,
662 // so put current mode back to init state.
664 ConOutPrivate
->TextOutMode
.Mode
= 0xFF;
666 // Allocate buffer for Console Out device
668 Status
= ConSplitterGrowBuffer (
669 sizeof (TEXT_OUT_AND_GOP_DATA
),
670 &ConOutPrivate
->TextOutListCount
,
671 (VOID
**) &ConOutPrivate
->TextOutList
673 if (EFI_ERROR (Status
)) {
674 return EFI_OUT_OF_RESOURCES
;
677 // Allocate buffer for Text Out query data
679 Status
= ConSplitterGrowBuffer (
680 sizeof (TEXT_OUT_SPLITTER_QUERY_DATA
),
681 &ConOutPrivate
->TextOutQueryDataCount
,
682 (VOID
**) &ConOutPrivate
->TextOutQueryData
684 if (EFI_ERROR (Status
)) {
685 return EFI_OUT_OF_RESOURCES
;
689 // Setup the default console to 80 x 25 and mode to 0
691 ConOutPrivate
->TextOutQueryData
[0].Columns
= 80;
692 ConOutPrivate
->TextOutQueryData
[0].Rows
= 25;
693 TextOutSetMode (ConOutPrivate
, 0);
696 if (FeaturePcdGet (PcdConOutUgaSupport
)) {
698 // Setup the UgaDraw to 800 x 600 x 32 bits per pixel, 60Hz.
700 ConSplitterUgaDrawSetMode (&ConOutPrivate
->UgaDraw
, 800, 600, 32, 60);
702 if (FeaturePcdGet (PcdConOutGopSupport
)) {
704 // Setup resource for mode information in Graphics Output Protocol interface
706 if ((ConOutPrivate
->GraphicsOutput
.Mode
= AllocateZeroPool (sizeof (EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE
))) == NULL
) {
707 return EFI_OUT_OF_RESOURCES
;
709 if ((ConOutPrivate
->GraphicsOutput
.Mode
->Info
= AllocateZeroPool (sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
))) == NULL
) {
710 return EFI_OUT_OF_RESOURCES
;
713 // Setup the DevNullGraphicsOutput to 800 x 600 x 32 bits per pixel
714 // DevNull will be updated to user-defined mode after driver has started.
716 if ((ConOutPrivate
->GraphicsOutputModeBuffer
= AllocateZeroPool (sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
))) == NULL
) {
717 return EFI_OUT_OF_RESOURCES
;
719 Info
= &ConOutPrivate
->GraphicsOutputModeBuffer
[0];
721 Info
->HorizontalResolution
= 800;
722 Info
->VerticalResolution
= 600;
723 Info
->PixelFormat
= PixelBltOnly
;
724 Info
->PixelsPerScanLine
= 800;
725 CopyMem (ConOutPrivate
->GraphicsOutput
.Mode
->Info
, Info
, sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
));
726 ConOutPrivate
->GraphicsOutput
.Mode
->SizeOfInfo
= sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
);
729 // Initialize the following items, theset items remain unchanged in GraphicsOutput->SetMode()
730 // GraphicsOutputMode->FrameBufferBase, GraphicsOutputMode->FrameBufferSize
732 ConOutPrivate
->GraphicsOutput
.Mode
->FrameBufferBase
= (EFI_PHYSICAL_ADDRESS
) (UINTN
) NULL
;
733 ConOutPrivate
->GraphicsOutput
.Mode
->FrameBufferSize
= 0;
735 ConOutPrivate
->GraphicsOutput
.Mode
->MaxMode
= 1;
737 // Initial current mode to unknown state, and then set to mode 0
739 ConOutPrivate
->GraphicsOutput
.Mode
->Mode
= 0xffff;
740 ConOutPrivate
->GraphicsOutput
.SetMode (&ConOutPrivate
->GraphicsOutput
, 0);
748 Test to see if the specified protocol could be supported on the specified device.
750 @param This Driver Binding protocol pointer.
751 @param ControllerHandle Handle of device to test.
752 @param Guid The specified protocol.
754 @retval EFI_SUCCESS The specified protocol is supported on this device.
755 @retval EFI_UNSUPPORTED The specified protocol attempts to be installed on virtul handle.
756 @retval other Failed to open specified protocol on this device.
760 ConSplitterSupported (
761 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
762 IN EFI_HANDLE ControllerHandle
,
770 // Make sure the Console Splitter does not attempt to attach to itself
772 if (ControllerHandle
== mConIn
.VirtualHandle
||
773 ControllerHandle
== mConOut
.VirtualHandle
||
774 ControllerHandle
== mStdErr
.VirtualHandle
776 return EFI_UNSUPPORTED
;
780 // Check to see whether the specific protocol could be opened BY_DRIVER
782 Status
= gBS
->OpenProtocol (
786 This
->DriverBindingHandle
,
788 EFI_OPEN_PROTOCOL_BY_DRIVER
791 if (EFI_ERROR (Status
)) {
798 This
->DriverBindingHandle
,
806 Test to see if Console In Device could be supported on the Controller.
808 @param This Driver Binding protocol instance pointer.
809 @param ControllerHandle Handle of device to test.
810 @param RemainingDevicePath Optional parameter use to pick a specific child
813 @retval EFI_SUCCESS This driver supports this device.
814 @retval other This driver does not support this device.
819 ConSplitterConInDriverBindingSupported (
820 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
821 IN EFI_HANDLE ControllerHandle
,
822 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
825 return ConSplitterSupported (
828 &gEfiConsoleInDeviceGuid
833 Test to see if Simple Pointer protocol could be supported on the Controller.
835 @param This Driver Binding protocol instance pointer.
836 @param ControllerHandle Handle of device to test.
837 @param RemainingDevicePath Optional parameter use to pick a specific child
840 @retval EFI_SUCCESS This driver supports this device.
841 @retval other This driver does not support this device.
846 ConSplitterSimplePointerDriverBindingSupported (
847 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
848 IN EFI_HANDLE ControllerHandle
,
849 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
852 return ConSplitterSupported (
855 &gEfiSimplePointerProtocolGuid
860 Test to see if Absolute Pointer protocol could be supported on the Controller.
862 @param This Driver Binding protocol instance pointer.
863 @param ControllerHandle Handle of device to test.
864 @param RemainingDevicePath Optional parameter use to pick a specific child
867 @retval EFI_SUCCESS This driver supports this device.
868 @retval other This driver does not support this device.
873 ConSplitterAbsolutePointerDriverBindingSupported (
874 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
875 IN EFI_HANDLE ControllerHandle
,
876 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
879 return ConSplitterSupported (
882 &gEfiAbsolutePointerProtocolGuid
888 Test to see if Console Out Device could be supported on the Controller.
890 @param This Driver Binding protocol instance pointer.
891 @param ControllerHandle Handle of device to test.
892 @param RemainingDevicePath Optional parameter use to pick a specific child
895 @retval EFI_SUCCESS This driver supports this device.
896 @retval other This driver does not support this device.
901 ConSplitterConOutDriverBindingSupported (
902 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
903 IN EFI_HANDLE ControllerHandle
,
904 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
907 return ConSplitterSupported (
910 &gEfiConsoleOutDeviceGuid
915 Test to see if Standard Error Device could be supported on the Controller.
917 @param This Driver Binding protocol instance pointer.
918 @param ControllerHandle Handle of device to test.
919 @param RemainingDevicePath Optional parameter use to pick a specific child
922 @retval EFI_SUCCESS This driver supports this device.
923 @retval other This driver does not support this device.
928 ConSplitterStdErrDriverBindingSupported (
929 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
930 IN EFI_HANDLE ControllerHandle
,
931 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
934 return ConSplitterSupported (
937 &gEfiStandardErrorDeviceGuid
943 Start ConSplitter on devcie handle by opening Console Device Guid on device handle
944 and the console virtual handle. And Get the console interface on controller handle.
946 @param This Driver Binding protocol instance pointer.
947 @param ControllerHandle Handle of device.
948 @param ConSplitterVirtualHandle Console virtual Handle.
949 @param DeviceGuid The specified Console Device, such as ConInDev,
951 @param InterfaceGuid The specified protocol to be opened.
952 @param Interface Protocol interface returned.
954 @retval EFI_SUCCESS This driver supports this device.
955 @retval other Failed to open the specified Console Device Guid
956 or specified protocol.
961 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
962 IN EFI_HANDLE ControllerHandle
,
963 IN EFI_HANDLE ConSplitterVirtualHandle
,
964 IN EFI_GUID
*DeviceGuid
,
965 IN EFI_GUID
*InterfaceGuid
,
973 // Check to see whether the ControllerHandle has the DeviceGuid on it.
975 Status
= gBS
->OpenProtocol (
979 This
->DriverBindingHandle
,
981 EFI_OPEN_PROTOCOL_BY_DRIVER
983 if (EFI_ERROR (Status
)) {
988 // Open the Parent Handle for the child.
990 Status
= gBS
->OpenProtocol (
994 This
->DriverBindingHandle
,
995 ConSplitterVirtualHandle
,
996 EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
998 if (EFI_ERROR (Status
)) {
1003 // Open InterfaceGuid on the virtul handle.
1005 Status
= gBS
->OpenProtocol (
1009 This
->DriverBindingHandle
,
1010 ConSplitterVirtualHandle
,
1011 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1014 if (!EFI_ERROR (Status
)) {
1019 // close the DeviceGuid on ConSplitter VirtualHandle.
1021 gBS
->CloseProtocol (
1024 This
->DriverBindingHandle
,
1025 ConSplitterVirtualHandle
1030 // close the DeviceGuid on ControllerHandle.
1032 gBS
->CloseProtocol (
1035 This
->DriverBindingHandle
,
1044 Start Console In Consplitter on device handle.
1046 @param This Driver Binding protocol instance pointer.
1047 @param ControllerHandle Handle of device to bind driver to.
1048 @param RemainingDevicePath Optional parameter use to pick a specific child
1051 @retval EFI_SUCCESS Console In Consplitter is added to ControllerHandle.
1052 @retval other Console In Consplitter does not support this device.
1057 ConSplitterConInDriverBindingStart (
1058 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1059 IN EFI_HANDLE ControllerHandle
,
1060 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
1064 EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*TextIn
;
1065 EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*TextInEx
;
1068 // Start ConSplitter on ControllerHandle, and create the virtual
1069 // agrogated console device on first call Start for a SimpleTextIn handle.
1071 Status
= ConSplitterStart (
1074 mConIn
.VirtualHandle
,
1075 &gEfiConsoleInDeviceGuid
,
1076 &gEfiSimpleTextInProtocolGuid
,
1079 if (EFI_ERROR (Status
)) {
1084 // Add this device into Text In devices list.
1086 Status
= ConSplitterTextInAddDevice (&mConIn
, TextIn
);
1087 if (EFI_ERROR (Status
)) {
1091 Status
= gBS
->OpenProtocol (
1093 &gEfiSimpleTextInputExProtocolGuid
,
1094 (VOID
**) &TextInEx
,
1095 This
->DriverBindingHandle
,
1096 mConIn
.VirtualHandle
,
1097 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1099 if (!EFI_ERROR (Status
)) {
1101 // If Simple Text Input Ex protocol exists,
1102 // add this device into Text In Ex devices list.
1104 Status
= ConSplitterTextInExAddDevice (&mConIn
, TextInEx
);
1112 Start Simple Pointer Consplitter on device handle.
1114 @param This Driver Binding protocol instance pointer.
1115 @param ControllerHandle Handle of device to bind driver to.
1116 @param RemainingDevicePath Optional parameter use to pick a specific child
1119 @retval EFI_SUCCESS Simple Pointer Consplitter is added to ControllerHandle.
1120 @retval other Simple Pointer Consplitter does not support this device.
1125 ConSplitterSimplePointerDriverBindingStart (
1126 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1127 IN EFI_HANDLE ControllerHandle
,
1128 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
1132 EFI_SIMPLE_POINTER_PROTOCOL
*SimplePointer
;
1135 // Start ConSplitter on ControllerHandle, and create the virtual
1136 // agrogated console device on first call Start for a SimplePointer handle.
1138 Status
= ConSplitterStart (
1141 mConIn
.VirtualHandle
,
1142 &gEfiSimplePointerProtocolGuid
,
1143 &gEfiSimplePointerProtocolGuid
,
1144 (VOID
**) &SimplePointer
1146 if (EFI_ERROR (Status
)) {
1151 // Add this devcie into Simple Pointer devices list.
1153 return ConSplitterSimplePointerAddDevice (&mConIn
, SimplePointer
);
1158 Start Absolute Pointer Consplitter on device handle.
1160 @param This Driver Binding protocol instance pointer.
1161 @param ControllerHandle Handle of device to bind driver to.
1162 @param RemainingDevicePath Optional parameter use to pick a specific child
1165 @retval EFI_SUCCESS Absolute Pointer Consplitter is added to ControllerHandle.
1166 @retval other Absolute Pointer Consplitter does not support this device.
1171 ConSplitterAbsolutePointerDriverBindingStart (
1172 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1173 IN EFI_HANDLE ControllerHandle
,
1174 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
1178 EFI_ABSOLUTE_POINTER_PROTOCOL
*AbsolutePointer
;
1181 // Start ConSplitter on ControllerHandle, and create the virtual
1182 // agrogated console device on first call Start for a AbsolutePointer handle.
1184 Status
= ConSplitterStart (
1187 mConIn
.VirtualHandle
,
1188 &gEfiAbsolutePointerProtocolGuid
,
1189 &gEfiAbsolutePointerProtocolGuid
,
1190 (VOID
**) &AbsolutePointer
1193 if (EFI_ERROR (Status
)) {
1198 // Add this devcie into Absolute Pointer devices list.
1200 return ConSplitterAbsolutePointerAddDevice (&mConIn
, AbsolutePointer
);
1205 Start Console Out Consplitter on device handle.
1207 @param This Driver Binding protocol instance pointer.
1208 @param ControllerHandle Handle of device to bind driver to.
1209 @param RemainingDevicePath Optional parameter use to pick a specific child
1212 @retval EFI_SUCCESS Console Out Consplitter is added to ControllerHandle.
1213 @retval other Console Out Consplitter does not support this device.
1218 ConSplitterConOutDriverBindingStart (
1219 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1220 IN EFI_HANDLE ControllerHandle
,
1221 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
1225 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
;
1226 EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
;
1227 EFI_UGA_DRAW_PROTOCOL
*UgaDraw
;
1229 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*Info
;
1232 // Start ConSplitter on ControllerHandle, and create the virtual
1233 // agrogated console device on first call Start for a ConsoleOut handle.
1235 Status
= ConSplitterStart (
1238 mConOut
.VirtualHandle
,
1239 &gEfiConsoleOutDeviceGuid
,
1240 &gEfiSimpleTextOutProtocolGuid
,
1243 if (EFI_ERROR (Status
)) {
1247 GraphicsOutput
= NULL
;
1250 // Try to Open Graphics Output protocol
1252 Status
= gBS
->OpenProtocol (
1254 &gEfiGraphicsOutputProtocolGuid
,
1255 (VOID
**) &GraphicsOutput
,
1256 This
->DriverBindingHandle
,
1257 mConOut
.VirtualHandle
,
1258 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1261 if (EFI_ERROR (Status
) && FeaturePcdGet (PcdUgaConsumeSupport
)) {
1263 // Open UGA DRAW protocol
1267 &gEfiUgaDrawProtocolGuid
,
1269 This
->DriverBindingHandle
,
1270 mConOut
.VirtualHandle
,
1271 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1276 // When new console device is added, the new mode will be set later,
1277 // so put current mode back to init state.
1279 mConOut
.TextOutMode
.Mode
= 0xFF;
1282 // If both ConOut and StdErr incorporate the same Text Out device,
1283 // their MaxMode and QueryData should be the intersection of both.
1285 Status
= ConSplitterTextOutAddDevice (&mConOut
, TextOut
, GraphicsOutput
, UgaDraw
);
1286 ConSplitterTextOutSetAttribute (&mConOut
.TextOut
, EFI_TEXT_ATTR (EFI_LIGHTGRAY
, EFI_BLACK
));
1288 if (FeaturePcdGet (PcdConOutUgaSupport
)) {
1290 // Get the UGA mode data of ConOut from the current mode
1292 if (GraphicsOutput
!= NULL
) {
1293 Status
= GraphicsOutput
->QueryMode (GraphicsOutput
, GraphicsOutput
->Mode
->Mode
, &SizeOfInfo
, &Info
);
1294 if (EFI_ERROR (Status
)) {
1297 ASSERT ( SizeOfInfo
<= sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
));
1299 mConOut
.UgaHorizontalResolution
= Info
->HorizontalResolution
;
1300 mConOut
.UgaVerticalResolution
= Info
->VerticalResolution
;
1301 mConOut
.UgaColorDepth
= 32;
1302 mConOut
.UgaRefreshRate
= 60;
1306 } else if (UgaDraw
!= NULL
&& FeaturePcdGet (PcdUgaConsumeSupport
)) {
1307 Status
= UgaDraw
->GetMode (
1309 &mConOut
.UgaHorizontalResolution
,
1310 &mConOut
.UgaVerticalResolution
,
1311 &mConOut
.UgaColorDepth
,
1312 &mConOut
.UgaRefreshRate
1322 Start Standard Error Consplitter on device handle.
1324 @param This Driver Binding protocol instance pointer.
1325 @param ControllerHandle Handle of device to bind driver to.
1326 @param RemainingDevicePath Optional parameter use to pick a specific child
1329 @retval EFI_SUCCESS Standard Error Consplitter is added to ControllerHandle.
1330 @retval other Standard Error Consplitter does not support this device.
1335 ConSplitterStdErrDriverBindingStart (
1336 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1337 IN EFI_HANDLE ControllerHandle
,
1338 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
1342 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
;
1345 // Start ConSplitter on ControllerHandle, and create the virtual
1346 // agrogated console device on first call Start for a StandardError handle.
1348 Status
= ConSplitterStart (
1351 mStdErr
.VirtualHandle
,
1352 &gEfiStandardErrorDeviceGuid
,
1353 &gEfiSimpleTextOutProtocolGuid
,
1356 if (EFI_ERROR (Status
)) {
1361 // When new console device is added, the new mode will be set later,
1362 // so put current mode back to init state.
1364 mStdErr
.TextOutMode
.Mode
= 0xFF;
1367 // If both ConOut and StdErr incorporate the same Text Out device,
1368 // their MaxMode and QueryData should be the intersection of both.
1370 Status
= ConSplitterTextOutAddDevice (&mStdErr
, TextOut
, NULL
, NULL
);
1371 ConSplitterTextOutSetAttribute (&mStdErr
.TextOut
, EFI_TEXT_ATTR (EFI_MAGENTA
, EFI_BLACK
));
1372 if (EFI_ERROR (Status
)) {
1381 Stop ConSplitter on device handle by closing Console Device Guid on device handle
1382 and the console virtual handle.
1384 @param This Protocol instance pointer.
1385 @param ControllerHandle Handle of device.
1386 @param ConSplitterVirtualHandle Console virtual Handle.
1387 @param DeviceGuid The specified Console Device, such as ConInDev,
1389 @param InterfaceGuid The specified protocol to be opened.
1390 @param Interface Protocol interface returned.
1392 @retval EFI_SUCCESS Stop ConSplitter on ControllerHandle successfully.
1393 @retval other Failed to Stop ConSplitter on ControllerHandle.
1398 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1399 IN EFI_HANDLE ControllerHandle
,
1400 IN EFI_HANDLE ConSplitterVirtualHandle
,
1401 IN EFI_GUID
*DeviceGuid
,
1402 IN EFI_GUID
*InterfaceGuid
,
1408 Status
= gBS
->OpenProtocol (
1412 This
->DriverBindingHandle
,
1414 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1416 if (EFI_ERROR (Status
)) {
1420 // close the protocol refered.
1422 gBS
->CloseProtocol (
1425 This
->DriverBindingHandle
,
1426 ConSplitterVirtualHandle
1429 gBS
->CloseProtocol (
1432 This
->DriverBindingHandle
,
1441 Stop Console In ConSplitter on ControllerHandle by closing Console In Devcice GUID.
1443 @param This Driver Binding protocol instance pointer.
1444 @param ControllerHandle Handle of device to stop driver on
1445 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
1446 children is zero stop the entire bus driver.
1447 @param ChildHandleBuffer List of Child Handles to Stop.
1449 @retval EFI_SUCCESS This driver is removed ControllerHandle
1450 @retval other This driver was not removed from this device
1455 ConSplitterConInDriverBindingStop (
1456 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1457 IN EFI_HANDLE ControllerHandle
,
1458 IN UINTN NumberOfChildren
,
1459 IN EFI_HANDLE
*ChildHandleBuffer
1463 EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*TextIn
;
1464 EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*TextInEx
;
1466 if (NumberOfChildren
== 0) {
1470 Status
= gBS
->OpenProtocol (
1472 &gEfiSimpleTextInputExProtocolGuid
,
1473 (VOID
**) &TextInEx
,
1474 This
->DriverBindingHandle
,
1476 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1478 if (!EFI_ERROR (Status
)) {
1480 // If Simple Text Input Ex protocol exists,
1481 // remove device from Text Input Ex devices list.
1483 Status
= ConSplitterTextInExDeleteDevice (&mConIn
, TextInEx
);
1484 if (EFI_ERROR (Status
)) {
1490 // Close Simple Text In protocol on controller handle and virtual handle.
1492 Status
= ConSplitterStop (
1495 mConIn
.VirtualHandle
,
1496 &gEfiConsoleInDeviceGuid
,
1497 &gEfiSimpleTextInProtocolGuid
,
1500 if (EFI_ERROR (Status
)) {
1505 // Remove device from Text Input devices list.
1507 return ConSplitterTextInDeleteDevice (&mConIn
, TextIn
);
1512 Stop Simple Pointer protocol ConSplitter on ControllerHandle by closing
1513 Simple Pointer protocol.
1515 @param This Driver Binding protocol instance pointer.
1516 @param ControllerHandle Handle of device to stop driver on
1517 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
1518 children is zero stop the entire bus driver.
1519 @param ChildHandleBuffer List of Child Handles to Stop.
1521 @retval EFI_SUCCESS This driver is removed ControllerHandle
1522 @retval other This driver was not removed from this device
1527 ConSplitterSimplePointerDriverBindingStop (
1528 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1529 IN EFI_HANDLE ControllerHandle
,
1530 IN UINTN NumberOfChildren
,
1531 IN EFI_HANDLE
*ChildHandleBuffer
1535 EFI_SIMPLE_POINTER_PROTOCOL
*SimplePointer
;
1537 if (NumberOfChildren
== 0) {
1542 // Close Simple Pointer protocol on controller handle and virtual handle.
1544 Status
= ConSplitterStop (
1547 mConIn
.VirtualHandle
,
1548 &gEfiSimplePointerProtocolGuid
,
1549 &gEfiSimplePointerProtocolGuid
,
1550 (VOID
**) &SimplePointer
1552 if (EFI_ERROR (Status
)) {
1557 // Remove this device from Simple Pointer device list.
1559 return ConSplitterSimplePointerDeleteDevice (&mConIn
, SimplePointer
);
1564 Stop Absolute Pointer protocol ConSplitter on ControllerHandle by closing
1565 Absolute Pointer protocol.
1567 @param This Driver Binding protocol instance pointer.
1568 @param ControllerHandle Handle of device to stop driver on
1569 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
1570 children is zero stop the entire bus driver.
1571 @param ChildHandleBuffer List of Child Handles to Stop.
1573 @retval EFI_SUCCESS This driver is removed ControllerHandle
1574 @retval other This driver was not removed from this device
1579 ConSplitterAbsolutePointerDriverBindingStop (
1580 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1581 IN EFI_HANDLE ControllerHandle
,
1582 IN UINTN NumberOfChildren
,
1583 IN EFI_HANDLE
*ChildHandleBuffer
1587 EFI_ABSOLUTE_POINTER_PROTOCOL
*AbsolutePointer
;
1589 if (NumberOfChildren
== 0) {
1594 // Close Absolute Pointer protocol on controller handle and virtual handle.
1596 Status
= ConSplitterStop (
1599 mConIn
.VirtualHandle
,
1600 &gEfiAbsolutePointerProtocolGuid
,
1601 &gEfiAbsolutePointerProtocolGuid
,
1602 (VOID
**) &AbsolutePointer
1604 if (EFI_ERROR (Status
)) {
1609 // Remove this device from Absolute Pointer device list.
1611 return ConSplitterAbsolutePointerDeleteDevice (&mConIn
, AbsolutePointer
);
1616 Stop Console Out ConSplitter on device handle by closing Console Out Devcice GUID.
1618 @param This Driver Binding protocol instance pointer.
1619 @param ControllerHandle Handle of device to stop driver on
1620 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
1621 children is zero stop the entire bus driver.
1622 @param ChildHandleBuffer List of Child Handles to Stop.
1624 @retval EFI_SUCCESS This driver is removed ControllerHandle
1625 @retval other This driver was not removed from this device
1630 ConSplitterConOutDriverBindingStop (
1631 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1632 IN EFI_HANDLE ControllerHandle
,
1633 IN UINTN NumberOfChildren
,
1634 IN EFI_HANDLE
*ChildHandleBuffer
1638 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
;
1640 if (NumberOfChildren
== 0) {
1645 // Close Absolute Pointer protocol on controller handle and virtual handle.
1647 Status
= ConSplitterStop (
1650 mConOut
.VirtualHandle
,
1651 &gEfiConsoleOutDeviceGuid
,
1652 &gEfiSimpleTextOutProtocolGuid
,
1655 if (EFI_ERROR (Status
)) {
1660 // Remove this device from Text Out device list.
1662 return ConSplitterTextOutDeleteDevice (&mConOut
, TextOut
);
1667 Stop Standard Error ConSplitter on ControllerHandle by closing Standard Error GUID.
1669 @param This Driver Binding protocol instance pointer.
1670 @param ControllerHandle Handle of device to stop driver on
1671 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
1672 children is zero stop the entire bus driver.
1673 @param ChildHandleBuffer List of Child Handles to Stop.
1675 @retval EFI_SUCCESS This driver is removed ControllerHandle
1676 @retval other This driver was not removed from this device
1681 ConSplitterStdErrDriverBindingStop (
1682 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1683 IN EFI_HANDLE ControllerHandle
,
1684 IN UINTN NumberOfChildren
,
1685 IN EFI_HANDLE
*ChildHandleBuffer
1689 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
;
1691 if (NumberOfChildren
== 0) {
1696 // Close Standard Error Device on controller handle and virtual handle.
1698 Status
= ConSplitterStop (
1701 mStdErr
.VirtualHandle
,
1702 &gEfiStandardErrorDeviceGuid
,
1703 &gEfiSimpleTextOutProtocolGuid
,
1706 if (EFI_ERROR (Status
)) {
1710 // Delete this console error out device's data structures.
1712 return ConSplitterTextOutDeleteDevice (&mStdErr
, TextOut
);
1717 Take the passed in Buffer of size ElementSize and grow the buffer
1718 by CONSOLE_SPLITTER_ALLOC_UNIT * ElementSize bytes.
1719 Copy the current data in Buffer to the new version of Buffer and
1720 free the old version of buffer.
1722 @param ElementSize Size of element in array.
1723 @param Count Current number of elements in array.
1724 @param Buffer Bigger version of passed in Buffer with all the
1727 @retval EFI_SUCCESS Buffer size has grown.
1728 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
1732 ConSplitterGrowBuffer (
1733 IN UINTN ElementSize
,
1734 IN OUT UINTN
*Count
,
1735 IN OUT VOID
**Buffer
1741 // grow the buffer to new buffer size,
1742 // copy the old buffer's content to the new-size buffer,
1743 // then free the old buffer.
1745 Ptr
= ReallocatePool (
1746 ElementSize
* (*Count
),
1747 ElementSize
* ((*Count
) + CONSOLE_SPLITTER_ALLOC_UNIT
),
1751 return EFI_OUT_OF_RESOURCES
;
1753 *Count
+= CONSOLE_SPLITTER_ALLOC_UNIT
;
1760 Add Text Input Device in Consplitter Text Input list.
1762 @param Private Text In Splitter pointer.
1763 @param TextIn Simple Text Input protocol pointer.
1765 @retval EFI_SUCCESS Text Input Device added successfully.
1766 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
1770 ConSplitterTextInAddDevice (
1771 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
1772 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*TextIn
1778 // If the Text In List is full, enlarge it by calling ConSplitterGrowBuffer().
1780 if (Private
->CurrentNumberOfConsoles
>= Private
->TextInListCount
) {
1781 Status
= ConSplitterGrowBuffer (
1782 sizeof (EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*),
1783 &Private
->TextInListCount
,
1784 (VOID
**) &Private
->TextInList
1786 if (EFI_ERROR (Status
)) {
1787 return EFI_OUT_OF_RESOURCES
;
1791 // Add the new text-in device data structure into the Text In List.
1793 Private
->TextInList
[Private
->CurrentNumberOfConsoles
] = TextIn
;
1794 Private
->CurrentNumberOfConsoles
++;
1797 // Extra CheckEvent added to reduce the double CheckEvent().
1799 gBS
->CheckEvent (TextIn
->WaitForKey
);
1806 Remove Text Input Device from Consplitter Text Input list.
1808 @param Private Text In Splitter pointer.
1809 @param TextIn Simple Text protocol pointer.
1811 @retval EFI_SUCCESS Simple Text Device removed successfully.
1812 @retval EFI_NOT_FOUND No Simple Text Device found.
1816 ConSplitterTextInDeleteDevice (
1817 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
1818 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*TextIn
1823 // Remove the specified text-in device data structure from the Text In List,
1824 // and rearrange the remaining data structures in the Text In List.
1826 for (Index
= 0; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
1827 if (Private
->TextInList
[Index
] == TextIn
) {
1828 for (; Index
< Private
->CurrentNumberOfConsoles
- 1; Index
++) {
1829 Private
->TextInList
[Index
] = Private
->TextInList
[Index
+ 1];
1832 Private
->CurrentNumberOfConsoles
--;
1837 return EFI_NOT_FOUND
;
1841 Add Text Input Ex Device in Consplitter Text Input Ex list.
1843 @param Private Text In Splitter pointer.
1844 @param TextInEx Simple Text Input Ex Input protocol pointer.
1846 @retval EFI_SUCCESS Text Input Ex Device added successfully.
1847 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
1851 ConSplitterTextInExAddDevice (
1852 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
1853 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*TextInEx
1858 TEXT_IN_EX_SPLITTER_NOTIFY
*CurrentNotify
;
1859 UINTN TextInExListCount
;
1862 // Enlarge the NotifyHandleList and the TextInExList
1864 if (Private
->CurrentNumberOfExConsoles
>= Private
->TextInExListCount
) {
1865 for (Link
= Private
->NotifyList
.ForwardLink
; Link
!= &Private
->NotifyList
; Link
= Link
->ForwardLink
) {
1866 CurrentNotify
= TEXT_IN_EX_SPLITTER_NOTIFY_FROM_THIS (Link
);
1867 TextInExListCount
= Private
->TextInExListCount
;
1869 Status
= ConSplitterGrowBuffer (
1870 sizeof (EFI_HANDLE
),
1872 (VOID
**) &CurrentNotify
->NotifyHandleList
1874 if (EFI_ERROR (Status
)) {
1875 return EFI_OUT_OF_RESOURCES
;
1878 Status
= ConSplitterGrowBuffer (
1879 sizeof (EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*),
1880 &Private
->TextInExListCount
,
1881 (VOID
**) &Private
->TextInExList
1883 if (EFI_ERROR (Status
)) {
1884 return EFI_OUT_OF_RESOURCES
;
1889 // Register the key notify in the new text-in device
1891 for (Link
= Private
->NotifyList
.ForwardLink
; Link
!= &Private
->NotifyList
; Link
= Link
->ForwardLink
) {
1892 CurrentNotify
= TEXT_IN_EX_SPLITTER_NOTIFY_FROM_THIS (Link
);
1893 Status
= TextInEx
->RegisterKeyNotify (
1895 &CurrentNotify
->KeyData
,
1896 CurrentNotify
->KeyNotificationFn
,
1897 &CurrentNotify
->NotifyHandleList
[Private
->CurrentNumberOfExConsoles
]
1899 if (EFI_ERROR (Status
)) {
1900 for (Link
= Link
->BackLink
; Link
!= &Private
->NotifyList
; Link
= Link
->BackLink
) {
1901 CurrentNotify
= TEXT_IN_EX_SPLITTER_NOTIFY_FROM_THIS (Link
);
1902 TextInEx
->UnregisterKeyNotify (
1904 CurrentNotify
->NotifyHandleList
[Private
->CurrentNumberOfExConsoles
]
1912 // Add the new text-in device data structure into the Text Input Ex List.
1914 Private
->TextInExList
[Private
->CurrentNumberOfExConsoles
] = TextInEx
;
1915 Private
->CurrentNumberOfExConsoles
++;
1918 // Extra CheckEvent added to reduce the double CheckEvent().
1920 gBS
->CheckEvent (TextInEx
->WaitForKeyEx
);
1926 Remove Text Ex Device from Consplitter Text Input Ex list.
1928 @param Private Text In Splitter pointer.
1929 @param TextInEx Simple Text Ex protocol pointer.
1931 @retval EFI_SUCCESS Simple Text Input Ex Device removed successfully.
1932 @retval EFI_NOT_FOUND No Simple Text Input Ex Device found.
1936 ConSplitterTextInExDeleteDevice (
1937 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
1938 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*TextInEx
1943 // Remove the specified text-in device data structure from the Text Input Ex List,
1944 // and rearrange the remaining data structures in the Text In List.
1946 for (Index
= 0; Index
< Private
->CurrentNumberOfExConsoles
; Index
++) {
1947 if (Private
->TextInExList
[Index
] == TextInEx
) {
1948 for (; Index
< Private
->CurrentNumberOfExConsoles
- 1; Index
++) {
1949 Private
->TextInExList
[Index
] = Private
->TextInExList
[Index
+ 1];
1952 Private
->CurrentNumberOfExConsoles
--;
1957 return EFI_NOT_FOUND
;
1962 Add Simple Pointer Device in Consplitter Simple Pointer list.
1964 @param Private Text In Splitter pointer.
1965 @param SimplePointer Simple Pointer protocol pointer.
1967 @retval EFI_SUCCESS Simple Pointer Device added successfully.
1968 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
1972 ConSplitterSimplePointerAddDevice (
1973 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
1974 IN EFI_SIMPLE_POINTER_PROTOCOL
*SimplePointer
1980 // If the Simple Pointer List is full, enlarge it by calling ConSplitterGrowBuffer().
1982 if (Private
->CurrentNumberOfPointers
>= Private
->PointerListCount
) {
1983 Status
= ConSplitterGrowBuffer (
1984 sizeof (EFI_SIMPLE_POINTER_PROTOCOL
*),
1985 &Private
->PointerListCount
,
1986 (VOID
**) &Private
->PointerList
1988 if (EFI_ERROR (Status
)) {
1989 return EFI_OUT_OF_RESOURCES
;
1993 // Add the new text-in device data structure into the Simple Pointer List.
1995 Private
->PointerList
[Private
->CurrentNumberOfPointers
] = SimplePointer
;
1996 Private
->CurrentNumberOfPointers
++;
2003 Remove Simple Pointer Device from Consplitter Simple Pointer list.
2005 @param Private Text In Splitter pointer.
2006 @param SimplePointer Simple Pointer protocol pointer.
2008 @retval EFI_SUCCESS Simple Pointer Device removed successfully.
2009 @retval EFI_NOT_FOUND No Simple Pointer Device found.
2013 ConSplitterSimplePointerDeleteDevice (
2014 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
2015 IN EFI_SIMPLE_POINTER_PROTOCOL
*SimplePointer
2020 // Remove the specified text-in device data structure from the Simple Pointer List,
2021 // and rearrange the remaining data structures in the Text In List.
2023 for (Index
= 0; Index
< Private
->CurrentNumberOfPointers
; Index
++) {
2024 if (Private
->PointerList
[Index
] == SimplePointer
) {
2025 for (; Index
< Private
->CurrentNumberOfPointers
- 1; Index
++) {
2026 Private
->PointerList
[Index
] = Private
->PointerList
[Index
+ 1];
2029 Private
->CurrentNumberOfPointers
--;
2034 return EFI_NOT_FOUND
;
2039 Add Absolute Pointer Device in Consplitter Absolute Pointer list.
2041 @param Private Text In Splitter pointer.
2042 @param AbsolutePointer Absolute Pointer protocol pointer.
2044 @retval EFI_SUCCESS Absolute Pointer Device added successfully.
2045 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
2049 ConSplitterAbsolutePointerAddDevice (
2050 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
2051 IN EFI_ABSOLUTE_POINTER_PROTOCOL
*AbsolutePointer
2057 // If the Absolute Pointer List is full, enlarge it by calling ConSplitterGrowBuffer().
2059 if (Private
->CurrentNumberOfAbsolutePointers
>= Private
->AbsolutePointerListCount
) {
2060 Status
= ConSplitterGrowBuffer (
2061 sizeof (EFI_ABSOLUTE_POINTER_PROTOCOL
*),
2062 &Private
->AbsolutePointerListCount
,
2063 (VOID
**) &Private
->AbsolutePointerList
2065 if (EFI_ERROR (Status
)) {
2066 return EFI_OUT_OF_RESOURCES
;
2070 // Add the new text-in device data structure into the Absolute Pointer List.
2072 Private
->AbsolutePointerList
[Private
->CurrentNumberOfAbsolutePointers
] = AbsolutePointer
;
2073 Private
->CurrentNumberOfAbsolutePointers
++;
2080 Remove Absolute Pointer Device from Consplitter Absolute Pointer list.
2082 @param Private Text In Splitter pointer.
2083 @param AbsolutePointer Absolute Pointer protocol pointer.
2085 @retval EFI_SUCCESS Absolute Pointer Device removed successfully.
2086 @retval EFI_NOT_FOUND No Absolute Pointer Device found.
2090 ConSplitterAbsolutePointerDeleteDevice (
2091 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
2092 IN EFI_ABSOLUTE_POINTER_PROTOCOL
*AbsolutePointer
2097 // Remove the specified text-in device data structure from the Absolute Pointer List,
2098 // and rearrange the remaining data structures from the Absolute Pointer List.
2100 for (Index
= 0; Index
< Private
->CurrentNumberOfAbsolutePointers
; Index
++) {
2101 if (Private
->AbsolutePointerList
[Index
] == AbsolutePointer
) {
2102 for (; Index
< Private
->CurrentNumberOfAbsolutePointers
- 1; Index
++) {
2103 Private
->AbsolutePointerList
[Index
] = Private
->AbsolutePointerList
[Index
+ 1];
2106 Private
->CurrentNumberOfAbsolutePointers
--;
2111 return EFI_NOT_FOUND
;
2115 Reallocate Text Out mode map.
2117 Allocate new buffer and copy original buffer into the new buffer.
2119 @param Private Consplitter Text Out pointer.
2121 @retval EFI_SUCCESS Buffer size has grown
2122 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
2126 ConSplitterGrowMapTable (
2127 IN TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
2133 INT32
*TextOutModeMap
;
2134 INT32
*OldTextOutModeMap
;
2138 NewSize
= Private
->TextOutListCount
* sizeof (INT32
);
2139 OldTextOutModeMap
= Private
->TextOutModeMap
;
2140 TotalSize
= NewSize
* (Private
->TextOutQueryDataCount
);
2143 // Allocate new buffer for Text Out List.
2145 TextOutModeMap
= AllocatePool (TotalSize
);
2146 if (TextOutModeMap
== NULL
) {
2147 return EFI_OUT_OF_RESOURCES
;
2150 SetMem (TextOutModeMap
, TotalSize
, 0xFF);
2151 Private
->TextOutModeMap
= TextOutModeMap
;
2154 // If TextOutList has been enlarged, need to realloc the mode map table
2155 // The mode map table is regarded as a two dimension array.
2158 // 0 ---------> TextOutListCount ----> TextOutListCount
2159 // | -------------------------------------------
2166 // -------------------------------------------
2169 if (OldTextOutModeMap
!= NULL
) {
2171 Size
= Private
->CurrentNumberOfConsoles
* sizeof (INT32
);
2173 SrcAddress
= OldTextOutModeMap
;
2176 // Copy the old data to the new one
2178 while (Index
< Private
->TextOutMode
.MaxMode
) {
2179 CopyMem (TextOutModeMap
, SrcAddress
, Size
);
2180 TextOutModeMap
+= NewSize
;
2185 // Free the old buffer
2187 FreePool (OldTextOutModeMap
);
2195 Add new device's output mode to console splitter's mode list.
2197 @param Private Text Out Splitter pointer
2198 @param TextOut Simple Text Output protocol pointer.
2200 @retval EFI_SUCCESS Device added successfully.
2201 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
2205 ConSplitterAddOutputMode (
2206 IN TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
,
2207 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
2215 MaxMode
= TextOut
->Mode
->MaxMode
;
2216 Private
->TextOutMode
.MaxMode
= MaxMode
;
2219 // Grow the buffer if query data buffer is not large enough to
2220 // hold all the mode supported by the first console.
2222 while (MaxMode
> (INT32
) Private
->TextOutQueryDataCount
) {
2223 Status
= ConSplitterGrowBuffer (
2224 sizeof (TEXT_OUT_SPLITTER_QUERY_DATA
),
2225 &Private
->TextOutQueryDataCount
,
2226 (VOID
**) &Private
->TextOutQueryData
2228 if (EFI_ERROR (Status
)) {
2229 return EFI_OUT_OF_RESOURCES
;
2233 // Allocate buffer for the output mode map
2235 Status
= ConSplitterGrowMapTable (Private
);
2236 if (EFI_ERROR (Status
)) {
2237 return EFI_OUT_OF_RESOURCES
;
2240 // As the first textout device, directly add the mode in to QueryData
2241 // and at the same time record the mapping between QueryData and TextOut.
2245 while (Mode
< MaxMode
) {
2246 Status
= TextOut
->QueryMode (
2249 &Private
->TextOutQueryData
[Mode
].Columns
,
2250 &Private
->TextOutQueryData
[Mode
].Rows
2253 // If mode 1 (80x50) is not supported, make sure mode 1 in TextOutQueryData
2256 if ((EFI_ERROR(Status
)) && (Mode
== 1)) {
2257 Private
->TextOutQueryData
[Mode
].Columns
= 0;
2258 Private
->TextOutQueryData
[Mode
].Rows
= 0;
2260 Private
->TextOutModeMap
[Index
] = Mode
;
2262 Index
+= Private
->TextOutListCount
;
2269 Reconstruct TextOutModeMap to get intersection of modes.
2271 This routine reconstruct TextOutModeMap to get the intersection
2272 of modes for all console out devices. Because EFI/UEFI spec require
2273 mode 0 is 80x25, mode 1 is 80x50, this routine will not check the
2274 intersection for mode 0 and mode 1.
2276 @param TextOutModeMap Current text out mode map, begin with the mode 80x25
2277 @param NewlyAddedMap New text out mode map, begin with the mode 80x25
2278 @param MapStepSize Mode step size for one console device
2279 @param NewMapStepSize New Mode step size for one console device
2280 @param MaxMode IN: Current max text mode, OUT: Updated max text mode.
2281 @param CurrentMode IN: Current text mode, OUT: Updated current text mode.
2285 ConSplitterGetIntersection (
2286 IN INT32
*TextOutModeMap
,
2287 IN INT32
*NewlyAddedMap
,
2288 IN UINTN MapStepSize
,
2289 IN UINTN NewMapStepSize
,
2290 IN OUT INT32
*MaxMode
,
2291 IN OUT INT32
*CurrentMode
2295 INT32
*CurrentMapEntry
;
2296 INT32
*NextMapEntry
;
2298 INT32 CurrentMaxMode
;
2302 // According to EFI/UEFI spec, mode 0 and mode 1 have been reserved
2303 // for 80x25 and 80x50 in Simple Text Out protocol, so don't make intersection
2304 // for mode 0 and mode 1, mode number starts from 2.
2307 CurrentMapEntry
= &TextOutModeMap
[MapStepSize
* 2];
2308 NextMapEntry
= CurrentMapEntry
;
2309 NewMapEntry
= &NewlyAddedMap
[NewMapStepSize
* 2];
2311 CurrentMaxMode
= *MaxMode
;
2312 Mode
= *CurrentMode
;
2314 while (Index
< CurrentMaxMode
) {
2315 if (*NewMapEntry
== -1) {
2317 // This mode is not supported any more. Remove it. Special care
2318 // must be taken as this remove will also affect current mode;
2320 if (Index
== *CurrentMode
) {
2322 } else if (Index
< *CurrentMode
) {
2327 if (CurrentMapEntry
!= NextMapEntry
) {
2328 CopyMem (NextMapEntry
, CurrentMapEntry
, MapStepSize
* sizeof (INT32
));
2331 NextMapEntry
+= MapStepSize
;
2334 CurrentMapEntry
+= MapStepSize
;
2335 NewMapEntry
+= NewMapStepSize
;
2339 *CurrentMode
= Mode
;
2345 Sync the device's output mode to console splitter's mode list.
2347 @param Private Text Out Splitter pointer.
2348 @param TextOut Simple Text Output protocol pointer.
2352 ConSplitterSyncOutputMode (
2353 IN TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
,
2354 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
2357 INT32 CurrentMaxMode
;
2360 INT32
*TextOutModeMap
;
2363 TEXT_OUT_SPLITTER_QUERY_DATA
*TextOutQueryData
;
2370 // Must make sure that current mode won't change even if mode number changes
2372 CurrentMaxMode
= Private
->TextOutMode
.MaxMode
;
2373 TextOutModeMap
= Private
->TextOutModeMap
;
2374 StepSize
= Private
->TextOutListCount
;
2375 TextOutQueryData
= Private
->TextOutQueryData
;
2378 // Query all the mode that the newly added TextOut supports
2381 MapTable
= TextOutModeMap
+ Private
->CurrentNumberOfConsoles
;
2382 while (Mode
< TextOut
->Mode
->MaxMode
) {
2383 Status
= TextOut
->QueryMode (TextOut
, Mode
, &Columns
, &Rows
);
2385 if (EFI_ERROR(Status
)) {
2388 // If mode 1 (80x50) is not supported, make sure mode 1 in TextOutQueryData
2391 MapTable
[StepSize
] = Mode
;
2392 TextOutQueryData
[Mode
].Columns
= 0;
2393 TextOutQueryData
[Mode
].Rows
= 0;
2399 // Search the intersection map and QueryData database to see if they intersects
2402 while (Index
< CurrentMaxMode
) {
2403 QueryMode
= *(TextOutModeMap
+ Index
* StepSize
);
2404 if ((TextOutQueryData
[QueryMode
].Rows
== Rows
) && (TextOutQueryData
[QueryMode
].Columns
== Columns
)) {
2405 MapTable
[Index
* StepSize
] = Mode
;
2413 // Now search the TextOutModeMap table to find the intersection of supported
2414 // mode between ConSplitter and the newly added device.
2416 ConSplitterGetIntersection (
2421 &Private
->TextOutMode
.MaxMode
,
2422 &Private
->TextOutMode
.Mode
2430 Sync output device between ConOut and StdErr output.
2432 @retval EFI_SUCCESS Sync implemented successfully.
2433 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
2437 ConSplitterGetIntersectionBetweenConOutAndStrErr (
2441 UINTN ConOutNumOfConsoles
;
2442 UINTN StdErrNumOfConsoles
;
2443 TEXT_OUT_AND_GOP_DATA
*ConOutTextOutList
;
2444 TEXT_OUT_AND_GOP_DATA
*StdErrTextOutList
;
2448 UINTN ConOutColumns
;
2450 UINTN StdErrColumns
;
2451 INT32 ConOutMaxMode
;
2452 INT32 StdErrMaxMode
;
2457 INT32
*ConOutModeMap
;
2458 INT32
*StdErrModeMap
;
2459 INT32
*ConOutMapTable
;
2460 INT32
*StdErrMapTable
;
2461 TEXT_OUT_SPLITTER_QUERY_DATA
*ConOutQueryData
;
2462 TEXT_OUT_SPLITTER_QUERY_DATA
*StdErrQueryData
;
2463 UINTN ConOutStepSize
;
2464 UINTN StdErrStepSize
;
2465 BOOLEAN FoundTheSameTextOut
;
2466 UINTN ConOutMapTableSize
;
2467 UINTN StdErrMapTableSize
;
2469 ConOutNumOfConsoles
= mConOut
.CurrentNumberOfConsoles
;
2470 StdErrNumOfConsoles
= mStdErr
.CurrentNumberOfConsoles
;
2471 ConOutTextOutList
= mConOut
.TextOutList
;
2472 StdErrTextOutList
= mStdErr
.TextOutList
;
2475 FoundTheSameTextOut
= FALSE
;
2476 while ((Indexi
< ConOutNumOfConsoles
) && (!FoundTheSameTextOut
)) {
2478 while (Indexj
< StdErrNumOfConsoles
) {
2479 if (ConOutTextOutList
->TextOut
== StdErrTextOutList
->TextOut
) {
2480 FoundTheSameTextOut
= TRUE
;
2485 StdErrTextOutList
++;
2489 ConOutTextOutList
++;
2492 if (!FoundTheSameTextOut
) {
2496 // Must make sure that current mode won't change even if mode number changes
2498 ConOutMaxMode
= mConOut
.TextOutMode
.MaxMode
;
2499 ConOutModeMap
= mConOut
.TextOutModeMap
;
2500 ConOutStepSize
= mConOut
.TextOutListCount
;
2501 ConOutQueryData
= mConOut
.TextOutQueryData
;
2503 StdErrMaxMode
= mStdErr
.TextOutMode
.MaxMode
;
2504 StdErrModeMap
= mStdErr
.TextOutModeMap
;
2505 StdErrStepSize
= mStdErr
.TextOutListCount
;
2506 StdErrQueryData
= mStdErr
.TextOutQueryData
;
2509 // Allocate the map table and set the map table's index to -1.
2511 ConOutMapTableSize
= ConOutMaxMode
* sizeof (INT32
);
2512 ConOutMapTable
= AllocateZeroPool (ConOutMapTableSize
);
2513 if (ConOutMapTable
== NULL
) {
2514 return EFI_OUT_OF_RESOURCES
;
2517 SetMem (ConOutMapTable
, ConOutMapTableSize
, 0xFF);
2519 StdErrMapTableSize
= StdErrMaxMode
* sizeof (INT32
);
2520 StdErrMapTable
= AllocateZeroPool (StdErrMapTableSize
);
2521 if (StdErrMapTable
== NULL
) {
2522 return EFI_OUT_OF_RESOURCES
;
2525 SetMem (StdErrMapTable
, StdErrMapTableSize
, 0xFF);
2528 // Find the intersection of the two set of modes. If they actually intersect, the
2529 // correponding entry in the map table is set to 1.
2532 while (Mode
< ConOutMaxMode
) {
2534 // Search the intersection map and QueryData database to see if they intersect
2537 ConOutMode
= *(ConOutModeMap
+ Mode
* ConOutStepSize
);
2538 ConOutRows
= ConOutQueryData
[ConOutMode
].Rows
;
2539 ConOutColumns
= ConOutQueryData
[ConOutMode
].Columns
;
2540 while (Index
< StdErrMaxMode
) {
2541 StdErrMode
= *(StdErrModeMap
+ Index
* StdErrStepSize
);
2542 StdErrRows
= StdErrQueryData
[StdErrMode
].Rows
;
2543 StdErrColumns
= StdErrQueryData
[StdErrMode
].Columns
;
2544 if ((StdErrRows
== ConOutRows
) && (StdErrColumns
== ConOutColumns
)) {
2545 ConOutMapTable
[Mode
] = 1;
2546 StdErrMapTable
[Index
] = 1;
2556 // Now search the TextOutModeMap table to find the intersection of supported
2557 // mode between ConSplitter and the newly added device.
2559 ConSplitterGetIntersection (
2562 mConOut
.TextOutListCount
,
2564 &(mConOut
.TextOutMode
.MaxMode
),
2565 &(mConOut
.TextOutMode
.Mode
)
2568 if (mConOut
.TextOutMode
.Mode
< 0) {
2569 mConOut
.TextOut
.SetMode (&(mConOut
.TextOut
), 0);
2572 ConSplitterGetIntersection (
2575 mStdErr
.TextOutListCount
,
2577 &(mStdErr
.TextOutMode
.MaxMode
),
2578 &(mStdErr
.TextOutMode
.Mode
)
2581 if (mStdErr
.TextOutMode
.Mode
< 0) {
2582 mStdErr
.TextOut
.SetMode (&(mStdErr
.TextOut
), 0);
2585 FreePool (ConOutMapTable
);
2586 FreePool (StdErrMapTable
);
2593 Add Grahpics Output modes into Consplitter Text Out list.
2595 @param Private Text Out Splitter pointer.
2596 @param GraphicsOutput Graphics Output protocol pointer.
2597 @param UgaDraw UGA Draw protocol pointer.
2599 @retval EFI_SUCCESS Output mode added successfully.
2600 @retval other Failed to add output mode.
2604 ConSplitterAddGraphicsOutputMode (
2605 IN TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
,
2606 IN EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
,
2607 IN EFI_UGA_DRAW_PROTOCOL
*UgaDraw
2613 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*Mode
;
2615 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*Info
;
2616 EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE
*CurrentGraphicsOutputMode
;
2617 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*ModeBuffer
;
2618 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*MatchedMode
;
2621 BOOLEAN AlreadyExist
;
2622 UINT32 UgaHorizontalResolution
;
2623 UINT32 UgaVerticalResolution
;
2624 UINT32 UgaColorDepth
;
2625 UINT32 UgaRefreshRate
;
2627 ASSERT (GraphicsOutput
!= NULL
|| UgaDraw
!= NULL
);
2629 CurrentGraphicsOutputMode
= Private
->GraphicsOutput
.Mode
;
2633 Status
= EFI_SUCCESS
;
2635 if (Private
->CurrentNumberOfUgaDraw
!= 0) {
2637 // If any UGA device has already been added, then there is no need to
2638 // calculate intersection of display mode of different GOP/UGA device,
2639 // since only one display mode will be exported (i.e. user-defined mode)
2644 if (GraphicsOutput
!= NULL
) {
2645 if (Private
->CurrentNumberOfGraphicsOutput
== 0) {
2647 // This is the first Graphics Output device added
2649 CurrentGraphicsOutputMode
->MaxMode
= GraphicsOutput
->Mode
->MaxMode
;
2650 CurrentGraphicsOutputMode
->Mode
= GraphicsOutput
->Mode
->Mode
;
2651 CopyMem (CurrentGraphicsOutputMode
->Info
, GraphicsOutput
->Mode
->Info
, GraphicsOutput
->Mode
->SizeOfInfo
);
2652 CurrentGraphicsOutputMode
->SizeOfInfo
= GraphicsOutput
->Mode
->SizeOfInfo
;
2653 CurrentGraphicsOutputMode
->FrameBufferBase
= GraphicsOutput
->Mode
->FrameBufferBase
;
2654 CurrentGraphicsOutputMode
->FrameBufferSize
= GraphicsOutput
->Mode
->FrameBufferSize
;
2657 // Allocate resource for the private mode buffer
2659 ModeBuffer
= AllocatePool (sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
) * GraphicsOutput
->Mode
->MaxMode
);
2660 if (ModeBuffer
== NULL
) {
2661 return EFI_OUT_OF_RESOURCES
;
2663 FreePool (Private
->GraphicsOutputModeBuffer
);
2664 Private
->GraphicsOutputModeBuffer
= ModeBuffer
;
2667 // Store all supported display modes to the private mode buffer
2670 for (Index
= 0; Index
< GraphicsOutput
->Mode
->MaxMode
; Index
++) {
2672 // The Info buffer would be allocated by callee
2674 Status
= GraphicsOutput
->QueryMode (GraphicsOutput
, (UINT32
) Index
, &SizeOfInfo
, &Info
);
2675 if (EFI_ERROR (Status
)) {
2678 ASSERT ( SizeOfInfo
<= sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
));
2679 CopyMem (Mode
, Info
, SizeOfInfo
);
2685 // Check intersection of display mode
2687 ModeBuffer
= AllocatePool (sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
) * CurrentGraphicsOutputMode
->MaxMode
);
2688 if (ModeBuffer
== NULL
) {
2689 return EFI_OUT_OF_RESOURCES
;
2692 MatchedMode
= ModeBuffer
;
2693 Mode
= &Private
->GraphicsOutputModeBuffer
[0];
2694 for (Index
= 0; Index
< CurrentGraphicsOutputMode
->MaxMode
; Index
++) {
2697 for (NumberIndex
= 0; NumberIndex
< GraphicsOutput
->Mode
->MaxMode
; NumberIndex
++) {
2699 // The Info buffer would be allocated by callee
2701 Status
= GraphicsOutput
->QueryMode (GraphicsOutput
, (UINT32
) NumberIndex
, &SizeOfInfo
, &Info
);
2702 if (EFI_ERROR (Status
)) {
2705 if ((Info
->HorizontalResolution
== Mode
->HorizontalResolution
) &&
2706 (Info
->VerticalResolution
== Mode
->VerticalResolution
)) {
2708 // If GOP device supports one mode in current mode buffer,
2709 // it will be added into matched mode buffer
2719 AlreadyExist
= FALSE
;
2722 // Check if GOP mode has been in the mode buffer, ModeBuffer = MatchedMode at begin.
2724 for (Info
= ModeBuffer
; Info
< MatchedMode
; Info
++) {
2725 if ((Info
->HorizontalResolution
== Mode
->HorizontalResolution
) &&
2726 (Info
->VerticalResolution
== Mode
->VerticalResolution
)) {
2727 AlreadyExist
= TRUE
;
2732 if (!AlreadyExist
) {
2733 CopyMem (MatchedMode
, Mode
, sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
));
2736 // Physical frame buffer is no longer available, change PixelFormat to PixelBltOnly
2738 MatchedMode
->Version
= 0;
2739 MatchedMode
->PixelFormat
= PixelBltOnly
;
2740 ZeroMem (&MatchedMode
->PixelInformation
, sizeof (EFI_PIXEL_BITMASK
));
2750 // Drop the old mode buffer, assign it to a new one
2752 FreePool (Private
->GraphicsOutputModeBuffer
);
2753 Private
->GraphicsOutputModeBuffer
= ModeBuffer
;
2756 // Physical frame buffer is no longer available when there are more than one physical GOP devices
2758 CurrentGraphicsOutputMode
->MaxMode
= (UINT32
) (((UINTN
) MatchedMode
- (UINTN
) ModeBuffer
) / sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
));
2759 CurrentGraphicsOutputMode
->Info
->PixelFormat
= PixelBltOnly
;
2760 ZeroMem (&CurrentGraphicsOutputMode
->Info
->PixelInformation
, sizeof (EFI_PIXEL_BITMASK
));
2761 CurrentGraphicsOutputMode
->SizeOfInfo
= sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
);
2762 CurrentGraphicsOutputMode
->FrameBufferBase
= (EFI_PHYSICAL_ADDRESS
) (UINTN
) NULL
;
2763 CurrentGraphicsOutputMode
->FrameBufferSize
= 0;
2767 // Graphics console driver can ensure the same mode for all GOP devices
2769 for (Index
= 0; Index
< CurrentGraphicsOutputMode
->MaxMode
; Index
++) {
2770 Mode
= &Private
->GraphicsOutputModeBuffer
[Index
];
2771 if ((Mode
->HorizontalResolution
== GraphicsOutput
->Mode
->Info
->HorizontalResolution
) &&
2772 (Mode
->VerticalResolution
== GraphicsOutput
->Mode
->Info
->VerticalResolution
)) {
2773 CurrentIndex
= Index
;
2777 if (Index
>= CurrentGraphicsOutputMode
->MaxMode
) {
2779 // if user defined mode is not found, set to default mode 800x600
2781 for (Index
= 0; Index
< CurrentGraphicsOutputMode
->MaxMode
; Index
++) {
2782 Mode
= &Private
->GraphicsOutputModeBuffer
[Index
];
2783 if ((Mode
->HorizontalResolution
== 800) && (Mode
->VerticalResolution
== 600)) {
2784 CurrentIndex
= Index
;
2789 } else if (UgaDraw
!= NULL
&& FeaturePcdGet (PcdUgaConsumeSupport
)) {
2791 // Graphics console driver can ensure the same mode for all GOP devices
2792 // so we can get the current mode from this video device
2796 &UgaHorizontalResolution
,
2797 &UgaVerticalResolution
,
2802 CurrentGraphicsOutputMode
->MaxMode
= 1;
2803 Info
= CurrentGraphicsOutputMode
->Info
;
2805 Info
->HorizontalResolution
= UgaHorizontalResolution
;
2806 Info
->VerticalResolution
= UgaVerticalResolution
;
2807 Info
->PixelFormat
= PixelBltOnly
;
2808 Info
->PixelsPerScanLine
= UgaHorizontalResolution
;
2809 CurrentGraphicsOutputMode
->SizeOfInfo
= sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
);
2810 CurrentGraphicsOutputMode
->FrameBufferBase
= (EFI_PHYSICAL_ADDRESS
) (UINTN
) NULL
;
2811 CurrentGraphicsOutputMode
->FrameBufferSize
= 0;
2814 // Update the private mode buffer
2816 CopyMem (&Private
->GraphicsOutputModeBuffer
[0], Info
, sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
));
2819 // Only mode 0 is available to be set
2826 if (GraphicsOutput
!= NULL
) {
2827 Private
->CurrentNumberOfGraphicsOutput
++;
2829 if (UgaDraw
!= NULL
&& FeaturePcdGet (PcdUgaConsumeSupport
)) {
2830 Private
->CurrentNumberOfUgaDraw
++;
2834 // Force GraphicsOutput mode to be set,
2837 Mode
= &Private
->GraphicsOutputModeBuffer
[CurrentIndex
];
2838 if ((GraphicsOutput
!= NULL
) &&
2839 (Mode
->HorizontalResolution
== CurrentGraphicsOutputMode
->Info
->HorizontalResolution
) &&
2840 (Mode
->VerticalResolution
== CurrentGraphicsOutputMode
->Info
->VerticalResolution
)) {
2841 CurrentGraphicsOutputMode
->Mode
= (UINT32
) CurrentIndex
;
2842 if ((Mode
->HorizontalResolution
!= GraphicsOutput
->Mode
->Info
->HorizontalResolution
) ||
2843 (Mode
->VerticalResolution
!= GraphicsOutput
->Mode
->Info
->VerticalResolution
)) {
2845 // If all existing video device has been set to common mode, only set new GOP device to
2848 for (NumberIndex
= 0; NumberIndex
< GraphicsOutput
->Mode
->MaxMode
; NumberIndex
++) {
2849 Status
= GraphicsOutput
->QueryMode (GraphicsOutput
, (UINT32
) NumberIndex
, &SizeOfInfo
, &Info
);
2850 if (EFI_ERROR (Status
)) {
2853 if ((Info
->HorizontalResolution
== Mode
->HorizontalResolution
) && (Info
->VerticalResolution
== Mode
->VerticalResolution
)) {
2859 Status
= GraphicsOutput
->SetMode (GraphicsOutput
, (UINT32
) NumberIndex
);
2863 // Current mode number may need update now, so set it to an invalid mode number
2865 CurrentGraphicsOutputMode
->Mode
= 0xffff;
2867 // Graphics console can ensure all GOP devices have the same mode which can be taken as current mode.
2869 Status
= Private
->GraphicsOutput
.SetMode (&Private
->GraphicsOutput
, (UINT32
) CurrentIndex
);
2870 if (EFI_ERROR(Status
)) {
2872 // If user defined mode is not valid for display device, set to the default mode 800x600.
2874 (Private
->GraphicsOutputModeBuffer
[0]).HorizontalResolution
= 800;
2875 (Private
->GraphicsOutputModeBuffer
[0]).VerticalResolution
= 600;
2876 Status
= Private
->GraphicsOutput
.SetMode (&Private
->GraphicsOutput
, 0);
2884 Set the current console out mode.
2886 This routine will get the current console mode information (column, row)
2887 from ConsoleOutMode variable and set it; if the variable does not exist,
2888 set to user defined console mode.
2890 @param Private Consplitter Text Out pointer.
2894 ConsplitterSetConsoleOutMode (
2895 IN TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
2905 CONSOLE_OUT_MODE ModeInfo
;
2906 CONSOLE_OUT_MODE MaxModeInfo
;
2907 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
;
2911 TextOut
= &Private
->TextOut
;
2912 MaxMode
= (UINTN
) (TextOut
->Mode
->MaxMode
);
2914 MaxModeInfo
.Column
= 0;
2915 MaxModeInfo
.Row
= 0;
2916 ModeInfo
.Column
= PcdGet32 (PcdConOutColumn
);
2917 ModeInfo
.Row
= PcdGet32 (PcdConOutRow
);
2920 // To find the prefer mode and basic mode from Text Out mode list
2922 for (Mode
= 0; Mode
< MaxMode
; Mode
++) {
2923 Status
= TextOut
->QueryMode (TextOut
, Mode
, &Col
, &Row
);
2924 if (!EFI_ERROR(Status
)) {
2925 if ((ModeInfo
.Column
!= 0) && (ModeInfo
.Row
!= 0)) {
2927 // Use user defined column and row
2929 if (Col
== ModeInfo
.Column
&& Row
== ModeInfo
.Row
) {
2934 // If user sets PcdConOutColumn or PcdConOutRow to 0,
2935 // find and set the highest text mode.
2937 if ((Col
>= MaxModeInfo
.Column
) && (Row
>= MaxModeInfo
.Row
)) {
2938 MaxModeInfo
.Column
= Col
;
2939 MaxModeInfo
.Row
= Row
;
2943 if (Col
== 80 && Row
== 25) {
2950 // Set prefer mode to Text Out devices.
2952 Status
= TextOut
->SetMode (TextOut
, PreferMode
);
2953 if (EFI_ERROR(Status
)) {
2955 // if current mode setting is failed, default 80x25 mode will be set.
2957 Status
= TextOut
->SetMode (TextOut
, BaseMode
);
2958 ASSERT(!EFI_ERROR(Status
));
2960 PcdSet32 (PcdConOutColumn
, 80);
2961 PcdSet32 (PcdConOutRow
, 25);
2969 Add Text Output Device in Consplitter Text Output list.
2971 @param Private Text Out Splitter pointer.
2972 @param TextOut Simple Text Output protocol pointer.
2973 @param GraphicsOutput Graphics Output protocol pointer.
2974 @param UgaDraw UGA Draw protocol pointer.
2976 @retval EFI_SUCCESS Text Output Device added successfully.
2977 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
2981 ConSplitterTextOutAddDevice (
2982 IN TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
,
2983 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
,
2984 IN EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
,
2985 IN EFI_UGA_DRAW_PROTOCOL
*UgaDraw
2989 UINTN CurrentNumOfConsoles
;
2991 UINT32 UgaHorizontalResolution
;
2992 UINT32 UgaVerticalResolution
;
2993 UINT32 UgaColorDepth
;
2994 UINT32 UgaRefreshRate
;
2995 TEXT_OUT_AND_GOP_DATA
*TextAndGop
;
2997 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*Info
;
2998 EFI_STATUS DeviceStatus
;
3000 Status
= EFI_SUCCESS
;
3001 CurrentNumOfConsoles
= Private
->CurrentNumberOfConsoles
;
3004 // If the Text Out List is full, enlarge it by calling ConSplitterGrowBuffer().
3006 while (CurrentNumOfConsoles
>= Private
->TextOutListCount
) {
3007 Status
= ConSplitterGrowBuffer (
3008 sizeof (TEXT_OUT_AND_GOP_DATA
),
3009 &Private
->TextOutListCount
,
3010 (VOID
**) &Private
->TextOutList
3012 if (EFI_ERROR (Status
)) {
3013 return EFI_OUT_OF_RESOURCES
;
3016 // Also need to reallocate the TextOutModeMap table
3018 Status
= ConSplitterGrowMapTable (Private
);
3019 if (EFI_ERROR (Status
)) {
3020 return EFI_OUT_OF_RESOURCES
;
3024 TextAndGop
= &Private
->TextOutList
[CurrentNumOfConsoles
];
3026 TextAndGop
->TextOut
= TextOut
;
3027 TextAndGop
->GraphicsOutput
= GraphicsOutput
;
3028 TextAndGop
->UgaDraw
= UgaDraw
;
3030 if (CurrentNumOfConsoles
== 0) {
3032 // Add the first device's output mode to console splitter's mode list
3034 Status
= ConSplitterAddOutputMode (Private
, TextOut
);
3036 ConSplitterSyncOutputMode (Private
, TextOut
);
3039 Private
->CurrentNumberOfConsoles
++;
3042 // Scan both TextOutList, for the intersection TextOut device
3043 // maybe both ConOut and StdErr incorporate the same Text Out
3044 // device in them, thus the output of both should be synced.
3046 ConSplitterGetIntersectionBetweenConOutAndStrErr ();
3048 MaxMode
= Private
->TextOutMode
.MaxMode
;
3049 ASSERT (MaxMode
>= 1);
3051 DeviceStatus
= EFI_DEVICE_ERROR
;
3052 if (FeaturePcdGet (PcdConOutGopSupport
)) {
3054 // If GOP is produced by Consplitter, this device display mode will be added into Graphics Ouput modes.
3056 if ((GraphicsOutput
!= NULL
) || (UgaDraw
!= NULL
&& FeaturePcdGet (PcdUgaConsumeSupport
))) {
3057 DeviceStatus
= ConSplitterAddGraphicsOutputMode (Private
, GraphicsOutput
, UgaDraw
);
3061 if (FeaturePcdGet (PcdConOutUgaSupport
)) {
3063 // If UGA is produced by Consplitter
3065 if (GraphicsOutput
!= NULL
) {
3066 Status
= GraphicsOutput
->QueryMode (GraphicsOutput
, GraphicsOutput
->Mode
->Mode
, &SizeOfInfo
, &Info
);
3067 if (EFI_ERROR (Status
)) {
3070 ASSERT ( SizeOfInfo
<= sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
));
3072 UgaHorizontalResolution
= Info
->HorizontalResolution
;
3073 UgaVerticalResolution
= Info
->VerticalResolution
;
3077 } else if (UgaDraw
!= NULL
&& FeaturePcdGet (PcdUgaConsumeSupport
)) {
3078 Status
= UgaDraw
->GetMode (
3080 &UgaHorizontalResolution
,
3081 &UgaVerticalResolution
,
3085 if (!EFI_ERROR (Status
) && EFI_ERROR (DeviceStatus
)) {
3087 // if GetMode is successfully and UGA device hasn't been set, set it
3089 Status
= ConSplitterUgaDrawSetMode (
3091 UgaHorizontalResolution
,
3092 UgaVerticalResolution
,
3098 // If GetMode/SetMode is failed, set to 800x600 mode
3100 if(EFI_ERROR (Status
)) {
3101 Status
= ConSplitterUgaDrawSetMode (
3113 // After adding new console device, all existing console devices should be
3114 // synced to the current shared mode.
3116 ConsplitterSetConsoleOutMode (Private
);
3123 Remove Text Out Device in Consplitter Text Out list.
3125 @param Private Text Out Splitter pointer.
3126 @param TextOut Simple Text Output Pointer protocol pointer.
3128 @retval EFI_SUCCESS Text Out Device removed successfully.
3129 @retval EFI_NOT_FOUND No Text Out Device found.
3133 ConSplitterTextOutDeleteDevice (
3134 IN TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
,
3135 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
3139 UINTN CurrentNumOfConsoles
;
3140 TEXT_OUT_AND_GOP_DATA
*TextOutList
;
3144 // Remove the specified text-out device data structure from the Text out List,
3145 // and rearrange the remaining data structures in the Text out List.
3147 CurrentNumOfConsoles
= Private
->CurrentNumberOfConsoles
;
3148 Index
= (INT32
) CurrentNumOfConsoles
- 1;
3149 TextOutList
= Private
->TextOutList
;
3150 while (Index
>= 0) {
3151 if (TextOutList
->TextOut
== TextOut
) {
3152 if (TextOutList
->UgaDraw
!= NULL
&& FeaturePcdGet (PcdUgaConsumeSupport
)) {
3153 Private
->CurrentNumberOfUgaDraw
--;
3155 if (TextOutList
->GraphicsOutput
!= NULL
) {
3156 Private
->CurrentNumberOfGraphicsOutput
--;
3158 CopyMem (TextOutList
, TextOutList
+ 1, sizeof (TEXT_OUT_AND_GOP_DATA
) * Index
);
3159 CurrentNumOfConsoles
--;
3167 // The specified TextOut is not managed by the ConSplitter driver
3170 return EFI_NOT_FOUND
;
3173 if (CurrentNumOfConsoles
== 0) {
3175 // If the number of consoles is zero, reset all parameters
3177 Private
->CurrentNumberOfConsoles
= 0;
3178 Private
->TextOutMode
.MaxMode
= 1;
3179 Private
->TextOutQueryData
[0].Columns
= 80;
3180 Private
->TextOutQueryData
[0].Rows
= 25;
3181 TextOutSetMode (Private
, 0);
3186 // Max Mode is realy an intersection of the QueryMode command to all
3187 // devices. So we must copy the QueryMode of the first device to
3191 Private
->TextOutQueryData
,
3192 Private
->TextOutQueryDataCount
* sizeof (TEXT_OUT_SPLITTER_QUERY_DATA
)
3195 FreePool (Private
->TextOutModeMap
);
3196 Private
->TextOutModeMap
= NULL
;
3197 TextOutList
= Private
->TextOutList
;
3200 // Add the first TextOut to the QueryData array and ModeMap table
3202 Status
= ConSplitterAddOutputMode (Private
, TextOutList
->TextOut
);
3205 // Now add one by one
3208 Private
->CurrentNumberOfConsoles
= 1;
3210 while ((UINTN
) Index
< CurrentNumOfConsoles
) {
3211 ConSplitterSyncOutputMode (Private
, TextOutList
->TextOut
);
3213 Private
->CurrentNumberOfConsoles
++;
3217 ConSplitterGetIntersectionBetweenConOutAndStrErr ();
3224 Reset the input device and optionaly run diagnostics
3226 @param This Protocol instance pointer.
3227 @param ExtendedVerification Driver may perform diagnostics on reset.
3229 @retval EFI_SUCCESS The device was reset.
3230 @retval EFI_DEVICE_ERROR The device is not functioning properly and could
3236 ConSplitterTextInReset (
3237 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*This
,
3238 IN BOOLEAN ExtendedVerification
3242 EFI_STATUS ReturnStatus
;
3243 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3246 Private
= TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
3248 Private
->KeyEventSignalState
= FALSE
;
3251 // return the worst status met
3253 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
3254 Status
= Private
->TextInList
[Index
]->Reset (
3255 Private
->TextInList
[Index
],
3256 ExtendedVerification
3258 if (EFI_ERROR (Status
)) {
3259 ReturnStatus
= Status
;
3263 return ReturnStatus
;
3268 Reads the next keystroke from the input device. The WaitForKey Event can
3269 be used to test for existance of a keystroke via WaitForEvent () call.
3271 @param Private Protocol instance pointer.
3272 @param Key Driver may perform diagnostics on reset.
3274 @retval EFI_SUCCESS The keystroke information was returned.
3275 @retval EFI_NOT_READY There was no keystroke data availiable.
3276 @retval EFI_DEVICE_ERROR The keydtroke information was not returned due
3282 ConSplitterTextInPrivateReadKeyStroke (
3283 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
3284 OUT EFI_INPUT_KEY
*Key
3289 EFI_INPUT_KEY CurrentKey
;
3291 Key
->UnicodeChar
= 0;
3292 Key
->ScanCode
= SCAN_NULL
;
3295 // if no physical console input device exists, return EFI_NOT_READY;
3296 // if any physical console input device has key input,
3297 // return the key and EFI_SUCCESS.
3299 for (Index
= 0; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
3300 Status
= Private
->TextInList
[Index
]->ReadKeyStroke (
3301 Private
->TextInList
[Index
],
3304 if (!EFI_ERROR (Status
)) {
3310 return EFI_NOT_READY
;
3314 Connect the specific Usb device which match the short form device path,
3315 and whose bus is determined by Host Controller.
3317 @param DevicePath A short-form device path that starts with the first
3318 element being a USB WWID or a USB Class device
3321 @return EFI_INVALID_PARAMETER DevicePath is NULL pointer.
3322 DevicePath is not a USB device path.
3324 @return EFI_SUCCESS Success to connect USB device
3325 @return EFI_NOT_FOUND Fail to find handle for USB controller to connect.
3330 ConSplitterConnectUsbShortFormDevicePath (
3331 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
3335 EFI_HANDLE
*Handles
;
3338 EFI_PCI_IO_PROTOCOL
*PciIo
;
3340 BOOLEAN AtLeastOneConnected
;
3343 // Check the passed in parameters
3345 if (DevicePath
== NULL
) {
3346 return EFI_INVALID_PARAMETER
;
3349 if ((DevicePathType (DevicePath
) != MESSAGING_DEVICE_PATH
) ||
3350 ((DevicePathSubType (DevicePath
) != MSG_USB_CLASS_DP
) && (DevicePathSubType (DevicePath
) != MSG_USB_WWID_DP
))
3352 return EFI_INVALID_PARAMETER
;
3356 // Find the usb host controller firstly, then connect with the remaining device path
3358 AtLeastOneConnected
= FALSE
;
3359 Status
= gBS
->LocateHandleBuffer (
3361 &gEfiPciIoProtocolGuid
,
3366 for (Index
= 0; Index
< HandleCount
; Index
++) {
3367 Status
= gBS
->HandleProtocol (
3369 &gEfiPciIoProtocolGuid
,
3372 if (!EFI_ERROR (Status
)) {
3374 // Check whether the Pci device is the wanted usb host controller
3376 Status
= PciIo
->Pci
.Read (PciIo
, EfiPciIoWidthUint8
, 0x09, 3, &Class
);
3377 if (!EFI_ERROR (Status
) &&
3378 ((PCI_CLASS_SERIAL
== Class
[2]) && (PCI_CLASS_SERIAL_USB
== Class
[1]))
3380 Status
= gBS
->ConnectController (
3386 if (!EFI_ERROR(Status
)) {
3387 AtLeastOneConnected
= TRUE
;
3393 return AtLeastOneConnected
? EFI_SUCCESS
: EFI_NOT_FOUND
;
3398 This function will create all handles associate with every device
3399 path node. If the handle associate with one device path node can not
3400 be created successfully, then still give one chance to do the dispatch,
3401 which load the missing drivers if possible.
3403 @param DevicePathToConnect The device path which will be connected, it CANNOT be
3404 a multi-instance device path
3405 @param MatchingHandle Return the controller handle closest to the DevicePathToConnect
3407 @retval EFI_INVALID_PARAMETER DevicePathToConnect is NULL.
3408 @retval EFI_NOT_FOUND Failed to create all handles associate with every device path node.
3409 @retval EFI_SUCCESS Successful to create all handles associate with every device path node.
3414 ConSplitterConnectDevicePath (
3415 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePathToConnect
,
3416 OUT EFI_HANDLE
*MatchingHandle OPTIONAL
3420 EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
;
3422 EFI_HANDLE PreviousHandle
;
3424 if (DevicePathToConnect
== NULL
) {
3425 return EFI_INVALID_PARAMETER
;
3429 // Start the real work of connect with RemainingDevicePath
3431 PreviousHandle
= NULL
;
3434 // Find the handle that best matches the Device Path. If it is only a
3435 // partial match the remaining part of the device path is returned in
3436 // RemainingDevicePath.
3438 RemainingDevicePath
= DevicePathToConnect
;
3439 Status
= gBS
->LocateDevicePath (&gEfiDevicePathProtocolGuid
, &RemainingDevicePath
, &Handle
);
3440 if (!EFI_ERROR (Status
)) {
3441 if (Handle
== PreviousHandle
) {
3443 // If no forward progress is made try invoking the Dispatcher.
3444 // A new FV may have been added to the system an new drivers
3445 // may now be found.
3446 // Status == EFI_SUCCESS means a driver was dispatched
3447 // Status == EFI_NOT_FOUND means no new drivers were dispatched
3449 Status
= gDS
->Dispatch ();
3452 if (!EFI_ERROR (Status
)) {
3453 PreviousHandle
= Handle
;
3455 // Connect all drivers that apply to Handle and RemainingDevicePath,
3456 // the Recursive flag is FALSE so only one level will be expanded.
3458 // Do not check the connect status here, if the connect controller fail,
3459 // then still give the chance to do dispatch, because partial
3460 // RemainingDevicepath may be in the new FV
3462 // 1. If the connect fail, RemainingDevicepath and handle will not
3463 // change, so next time will do the dispatch, then dispatch's status
3465 // 2. If the connect success, the RemainingDevicepath and handle will
3466 // change, then avoid the dispatch, we have chance to continue the
3469 gBS
->ConnectController (Handle
, NULL
, RemainingDevicePath
, FALSE
);
3470 if (MatchingHandle
!= NULL
) {
3471 *MatchingHandle
= Handle
;
3476 // Loop until RemainingDevicePath is an empty device path
3478 } while (!EFI_ERROR (Status
) && !IsDevicePathEnd (RemainingDevicePath
));
3480 ASSERT (EFI_ERROR (Status
) || IsDevicePathEnd (RemainingDevicePath
));
3487 Connect to all ConIn device which is in the ConIn variable.
3489 @param DevicePath A short-form device path that starts with the first
3490 element being a USB WWID or a USB Class device
3493 @return EFI_INVALID_PARAMETER DevicePath is NULL pointer.
3494 DevicePath is not a USB device path.
3496 @return EFI_SUCCESS Success to connect USB device
3497 @return EFI_NOT_FOUND Fail to find handle for USB controller to connect.
3502 ConSplitterConnectConInDevicePath (
3506 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
3507 EFI_DEVICE_PATH_PROTOCOL
*DevicePathInst
;
3508 EFI_DEVICE_PATH_PROTOCOL
*CopyDevicePath
;
3510 EFI_DEVICE_PATH_PROTOCOL
*Next
;
3512 DevicePath
= GetEfiGlobalVariable (L
"ConIn");
3515 // Check the passed in parameters
3517 if (DevicePath
== NULL
) {
3518 return EFI_NOT_FOUND
;
3521 CopyDevicePath
= DevicePath
;
3523 DevicePathInst
= GetNextDevicePathInstance (&DevicePath
, &Size
);
3524 while (DevicePathInst
!= NULL
) {
3526 Next
= DevicePathInst
;
3527 while (!IsDevicePathEndType (Next
)) {
3528 Next
= NextDevicePathNode (Next
);
3531 SetDevicePathEndNode (Next
);
3534 // Connect the USB console
3535 // USB console device path is a short-form device path that
3536 // starts with the first element being a USB WWID
3537 // or a USB Class device path
3539 if ((DevicePathType (DevicePathInst
) == MESSAGING_DEVICE_PATH
) &&
3540 ((DevicePathSubType (DevicePathInst
) == MSG_USB_CLASS_DP
)
3541 || (DevicePathSubType (DevicePathInst
) == MSG_USB_WWID_DP
)
3543 ConSplitterConnectUsbShortFormDevicePath (DevicePathInst
);
3545 ConSplitterConnectDevicePath (DevicePathInst
, NULL
);
3547 DevicePathInst
= GetNextDevicePathInstance (&DevicePath
, &Size
);
3555 Reads the next keystroke from the input device. The WaitForKey Event can
3556 be used to test for existance of a keystroke via WaitForEvent () call.
3558 @param This Protocol instance pointer.
3559 @param Key Driver may perform diagnostics on reset.
3561 @retval EFI_SUCCESS The keystroke information was returned.
3562 @retval EFI_NOT_READY There was no keystroke data availiable.
3563 @retval EFI_DEVICE_ERROR The keydtroke information was not returned due
3569 ConSplitterTextInReadKeyStroke (
3570 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*This
,
3571 OUT EFI_INPUT_KEY
*Key
3574 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3576 Private
= TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
3578 Private
->KeyEventSignalState
= FALSE
;
3581 // Connect ConIn when first call in Lazy ConIn mode
3583 if (!mConInIsConnect
&& PcdGetBool (PcdConInConnectOnDemand
)) {
3584 DEBUG ((EFI_D_INFO
, "Connect ConIn in first ReadKeyStoke in Lazy ConIn mode.\n"));
3585 ConSplitterConnectConInDevicePath ();
3586 mConInIsConnect
= TRUE
;
3589 return ConSplitterTextInPrivateReadKeyStroke (Private
, Key
);
3594 This event aggregates all the events of the ConIn devices in the spliter.
3596 If any events of physical ConIn devices are signaled, signal the ConIn
3597 spliter event. This will cause the calling code to call
3598 ConSplitterTextInReadKeyStroke ().
3600 @param Event The Event assoicated with callback.
3601 @param Context Context registered when Event was created.
3606 ConSplitterTextInWaitForKey (
3612 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3615 Private
= (TEXT_IN_SPLITTER_PRIVATE_DATA
*) Context
;
3617 if (Private
->KeyEventSignalState
) {
3619 // If KeyEventSignalState is flagged before, and not cleared by Reset() or ReadKeyStroke()
3621 gBS
->SignalEvent (Event
);
3626 // If any physical console input device has key input, signal the event.
3628 for (Index
= 0; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
3629 Status
= gBS
->CheckEvent (Private
->TextInList
[Index
]->WaitForKey
);
3630 if (!EFI_ERROR (Status
)) {
3631 gBS
->SignalEvent (Event
);
3632 Private
->KeyEventSignalState
= TRUE
;
3640 Test if the key has been registered on input device.
3642 @param RegsiteredData A pointer to a buffer that is filled in with the
3643 keystroke state data for the key that was
3645 @param InputData A pointer to a buffer that is filled in with the
3646 keystroke state data for the key that was
3649 @retval TRUE Key be pressed matches a registered key.
3650 @retval FLASE Match failed.
3655 IN EFI_KEY_DATA
*RegsiteredData
,
3656 IN EFI_KEY_DATA
*InputData
3659 ASSERT (RegsiteredData
!= NULL
&& InputData
!= NULL
);
3661 if ((RegsiteredData
->Key
.ScanCode
!= InputData
->Key
.ScanCode
) ||
3662 (RegsiteredData
->Key
.UnicodeChar
!= InputData
->Key
.UnicodeChar
)) {
3667 // Assume KeyShiftState/KeyToggleState = 0 in Registered key data means these state could be ignored.
3669 if (RegsiteredData
->KeyState
.KeyShiftState
!= 0 &&
3670 RegsiteredData
->KeyState
.KeyShiftState
!= InputData
->KeyState
.KeyShiftState
) {
3673 if (RegsiteredData
->KeyState
.KeyToggleState
!= 0 &&
3674 RegsiteredData
->KeyState
.KeyToggleState
!= InputData
->KeyState
.KeyToggleState
) {
3684 Reset the input device and optionaly run diagnostics
3686 @param This Protocol instance pointer.
3687 @param ExtendedVerification Driver may perform diagnostics on reset.
3689 @retval EFI_SUCCESS The device was reset.
3690 @retval EFI_DEVICE_ERROR The device is not functioning properly and could
3696 ConSplitterTextInResetEx (
3697 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*This
,
3698 IN BOOLEAN ExtendedVerification
3702 EFI_STATUS ReturnStatus
;
3703 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3706 Private
= TEXT_IN_EX_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
3708 Private
->KeyEventSignalState
= FALSE
;
3711 // return the worst status met
3713 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfExConsoles
; Index
++) {
3714 Status
= Private
->TextInExList
[Index
]->Reset (
3715 Private
->TextInExList
[Index
],
3716 ExtendedVerification
3718 if (EFI_ERROR (Status
)) {
3719 ReturnStatus
= Status
;
3723 return ReturnStatus
;
3729 Reads the next keystroke from the input device. The WaitForKey Event can
3730 be used to test for existance of a keystroke via WaitForEvent () call.
3732 @param This Protocol instance pointer.
3733 @param KeyData A pointer to a buffer that is filled in with the
3734 keystroke state data for the key that was
3737 @retval EFI_SUCCESS The keystroke information was returned.
3738 @retval EFI_NOT_READY There was no keystroke data availiable.
3739 @retval EFI_DEVICE_ERROR The keystroke information was not returned due
3741 @retval EFI_INVALID_PARAMETER KeyData is NULL.
3746 ConSplitterTextInReadKeyStrokeEx (
3747 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*This
,
3748 OUT EFI_KEY_DATA
*KeyData
3751 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3754 EFI_KEY_DATA CurrentKeyData
;
3757 if (KeyData
== NULL
) {
3758 return EFI_INVALID_PARAMETER
;
3762 // Connect ConIn when first call in Lazy ConIn mode
3764 if (!mConInIsConnect
&& PcdGetBool (PcdConInConnectOnDemand
)) {
3765 DEBUG ((EFI_D_INFO
, "Connect ConIn in first ReadKeyStoke in Lazy ConIn mode.\n"));
3766 ConSplitterConnectConInDevicePath ();
3767 mConInIsConnect
= TRUE
;
3770 Private
= TEXT_IN_EX_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
3772 Private
->KeyEventSignalState
= FALSE
;
3774 KeyData
->Key
.UnicodeChar
= 0;
3775 KeyData
->Key
.ScanCode
= SCAN_NULL
;
3778 // if no physical console input device exists, return EFI_NOT_READY;
3779 // if any physical console input device has key input,
3780 // return the key and EFI_SUCCESS.
3782 for (Index
= 0; Index
< Private
->CurrentNumberOfExConsoles
; Index
++) {
3783 Status
= Private
->TextInExList
[Index
]->ReadKeyStrokeEx (
3784 Private
->TextInExList
[Index
],
3787 if (!EFI_ERROR (Status
)) {
3788 CopyMem (KeyData
, &CurrentKeyData
, sizeof (CurrentKeyData
));
3793 return EFI_NOT_READY
;
3798 Set certain state for the input device.
3800 @param This Protocol instance pointer.
3801 @param KeyToggleState A pointer to the EFI_KEY_TOGGLE_STATE to set the
3802 state for the input device.
3804 @retval EFI_SUCCESS The device state was set successfully.
3805 @retval EFI_DEVICE_ERROR The device is not functioning correctly and
3806 could not have the setting adjusted.
3807 @retval EFI_UNSUPPORTED The device does not have the ability to set its
3809 @retval EFI_INVALID_PARAMETER KeyToggleState is NULL.
3814 ConSplitterTextInSetState (
3815 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*This
,
3816 IN EFI_KEY_TOGGLE_STATE
*KeyToggleState
3819 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3823 if (KeyToggleState
== NULL
) {
3824 return EFI_INVALID_PARAMETER
;
3827 Private
= TEXT_IN_EX_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
3830 // if no physical console input device exists, return EFI_SUCCESS;
3831 // otherwise return the status of setting state of physical console input device
3833 for (Index
= 0; Index
< Private
->CurrentNumberOfExConsoles
; Index
++) {
3834 Status
= Private
->TextInExList
[Index
]->SetState (
3835 Private
->TextInExList
[Index
],
3838 if (EFI_ERROR (Status
)) {
3849 Register a notification function for a particular keystroke for the input device.
3851 @param This Protocol instance pointer.
3852 @param KeyData A pointer to a buffer that is filled in with the
3853 keystroke information data for the key that was
3855 @param KeyNotificationFunction Points to the function to be called when the key
3856 sequence is typed specified by KeyData.
3857 @param NotifyHandle Points to the unique handle assigned to the
3858 registered notification.
3860 @retval EFI_SUCCESS The notification function was registered
3862 @retval EFI_OUT_OF_RESOURCES Unable to allocate resources for necesssary data
3864 @retval EFI_INVALID_PARAMETER KeyData or KeyNotificationFunction or NotifyHandle is NULL.
3869 ConSplitterTextInRegisterKeyNotify (
3870 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*This
,
3871 IN EFI_KEY_DATA
*KeyData
,
3872 IN EFI_KEY_NOTIFY_FUNCTION KeyNotificationFunction
,
3873 OUT VOID
**NotifyHandle
3876 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3879 TEXT_IN_EX_SPLITTER_NOTIFY
*NewNotify
;
3881 TEXT_IN_EX_SPLITTER_NOTIFY
*CurrentNotify
;
3884 if (KeyData
== NULL
|| NotifyHandle
== NULL
|| KeyNotificationFunction
== NULL
) {
3885 return EFI_INVALID_PARAMETER
;
3888 Private
= TEXT_IN_EX_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
3891 // Return EFI_SUCCESS if the (KeyData, NotificationFunction) is already registered.
3893 for (Link
= Private
->NotifyList
.ForwardLink
; Link
!= &Private
->NotifyList
; Link
= Link
->ForwardLink
) {
3894 CurrentNotify
= TEXT_IN_EX_SPLITTER_NOTIFY_FROM_THIS (Link
);
3895 if (IsKeyRegistered (&CurrentNotify
->KeyData
, KeyData
)) {
3896 if (CurrentNotify
->KeyNotificationFn
== KeyNotificationFunction
) {
3897 *NotifyHandle
= CurrentNotify
;
3904 // Allocate resource to save the notification function
3906 NewNotify
= (TEXT_IN_EX_SPLITTER_NOTIFY
*) AllocateZeroPool (sizeof (TEXT_IN_EX_SPLITTER_NOTIFY
));
3907 if (NewNotify
== NULL
) {
3908 return EFI_OUT_OF_RESOURCES
;
3910 NewNotify
->NotifyHandleList
= (EFI_HANDLE
*) AllocateZeroPool (sizeof (EFI_HANDLE
) * Private
->TextInExListCount
);
3911 if (NewNotify
->NotifyHandleList
== NULL
) {
3912 gBS
->FreePool (NewNotify
);
3913 return EFI_OUT_OF_RESOURCES
;
3915 NewNotify
->Signature
= TEXT_IN_EX_SPLITTER_NOTIFY_SIGNATURE
;
3916 NewNotify
->KeyNotificationFn
= KeyNotificationFunction
;
3917 CopyMem (&NewNotify
->KeyData
, KeyData
, sizeof (EFI_KEY_DATA
));
3920 // Return the wrong status of registering key notify of
3921 // physical console input device if meet problems
3923 for (Index
= 0; Index
< Private
->CurrentNumberOfExConsoles
; Index
++) {
3924 Status
= Private
->TextInExList
[Index
]->RegisterKeyNotify (
3925 Private
->TextInExList
[Index
],
3927 KeyNotificationFunction
,
3928 &NewNotify
->NotifyHandleList
[Index
]
3930 if (EFI_ERROR (Status
)) {
3932 // Un-register the key notify on all physical console input devices
3934 while (Index
-- != 0) {
3935 Private
->TextInExList
[Index
]->UnregisterKeyNotify (
3936 Private
->TextInExList
[Index
],
3937 NewNotify
->NotifyHandleList
[Index
]
3940 gBS
->FreePool (NewNotify
->NotifyHandleList
);
3941 gBS
->FreePool (NewNotify
);
3946 InsertTailList (&mConIn
.NotifyList
, &NewNotify
->NotifyEntry
);
3948 *NotifyHandle
= NewNotify
;
3956 Remove a registered notification function from a particular keystroke.
3958 @param This Protocol instance pointer.
3959 @param NotificationHandle The handle of the notification function being
3962 @retval EFI_SUCCESS The notification function was unregistered
3964 @retval EFI_INVALID_PARAMETER The NotificationHandle is invalid.
3969 ConSplitterTextInUnregisterKeyNotify (
3970 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*This
,
3971 IN VOID
*NotificationHandle
3974 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3976 TEXT_IN_EX_SPLITTER_NOTIFY
*CurrentNotify
;
3979 if (NotificationHandle
== NULL
) {
3980 return EFI_INVALID_PARAMETER
;
3983 Private
= TEXT_IN_EX_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
3985 for (Link
= Private
->NotifyList
.ForwardLink
; Link
!= &Private
->NotifyList
; Link
= Link
->ForwardLink
) {
3986 CurrentNotify
= TEXT_IN_EX_SPLITTER_NOTIFY_FROM_THIS (Link
);
3987 if (CurrentNotify
== NotificationHandle
) {
3988 for (Index
= 0; Index
< Private
->CurrentNumberOfExConsoles
; Index
++) {
3989 Private
->TextInExList
[Index
]->UnregisterKeyNotify (
3990 Private
->TextInExList
[Index
],
3991 CurrentNotify
->NotifyHandleList
[Index
]
3994 RemoveEntryList (&CurrentNotify
->NotifyEntry
);
3996 gBS
->FreePool (CurrentNotify
->NotifyHandleList
);
3997 gBS
->FreePool (CurrentNotify
);
4003 // NotificationHandle is not found in database
4005 return EFI_INVALID_PARAMETER
;
4010 Reset the input device and optionaly run diagnostics
4012 @param This Protocol instance pointer.
4013 @param ExtendedVerification Driver may perform diagnostics on reset.
4015 @retval EFI_SUCCESS The device was reset.
4016 @retval EFI_DEVICE_ERROR The device is not functioning properly and could
4022 ConSplitterSimplePointerReset (
4023 IN EFI_SIMPLE_POINTER_PROTOCOL
*This
,
4024 IN BOOLEAN ExtendedVerification
4028 EFI_STATUS ReturnStatus
;
4029 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
4032 Private
= TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_SIMPLE_POINTER_THIS (This
);
4034 Private
->InputEventSignalState
= FALSE
;
4036 if (Private
->CurrentNumberOfPointers
== 0) {
4040 // return the worst status met
4042 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfPointers
; Index
++) {
4043 Status
= Private
->PointerList
[Index
]->Reset (
4044 Private
->PointerList
[Index
],
4045 ExtendedVerification
4047 if (EFI_ERROR (Status
)) {
4048 ReturnStatus
= Status
;
4052 return ReturnStatus
;
4057 Reads the next keystroke from the input device. The WaitForKey Event can
4058 be used to test for existance of a keystroke via WaitForEvent () call.
4060 @param Private Protocol instance pointer.
4061 @param State The state information of simple pointer device.
4063 @retval EFI_SUCCESS The keystroke information was returned.
4064 @retval EFI_NOT_READY There was no keystroke data availiable.
4065 @retval EFI_DEVICE_ERROR The keydtroke information was not returned due
4071 ConSplitterSimplePointerPrivateGetState (
4072 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
4073 IN OUT EFI_SIMPLE_POINTER_STATE
*State
4077 EFI_STATUS ReturnStatus
;
4079 EFI_SIMPLE_POINTER_STATE CurrentState
;
4081 State
->RelativeMovementX
= 0;
4082 State
->RelativeMovementY
= 0;
4083 State
->RelativeMovementZ
= 0;
4084 State
->LeftButton
= FALSE
;
4085 State
->RightButton
= FALSE
;
4088 // if no physical console input device exists, return EFI_NOT_READY;
4089 // if any physical console input device has key input,
4090 // return the key and EFI_SUCCESS.
4092 ReturnStatus
= EFI_NOT_READY
;
4093 for (Index
= 0; Index
< Private
->CurrentNumberOfPointers
; Index
++) {
4095 Status
= Private
->PointerList
[Index
]->GetState (
4096 Private
->PointerList
[Index
],
4099 if (!EFI_ERROR (Status
)) {
4100 if (ReturnStatus
== EFI_NOT_READY
) {
4101 ReturnStatus
= EFI_SUCCESS
;
4104 if (CurrentState
.LeftButton
) {
4105 State
->LeftButton
= TRUE
;
4108 if (CurrentState
.RightButton
) {
4109 State
->RightButton
= TRUE
;
4112 if (CurrentState
.RelativeMovementX
!= 0 && Private
->PointerList
[Index
]->Mode
->ResolutionX
!= 0) {
4113 State
->RelativeMovementX
+= (CurrentState
.RelativeMovementX
* (INT32
) Private
->SimplePointerMode
.ResolutionX
) / (INT32
) Private
->PointerList
[Index
]->Mode
->ResolutionX
;
4116 if (CurrentState
.RelativeMovementY
!= 0 && Private
->PointerList
[Index
]->Mode
->ResolutionY
!= 0) {
4117 State
->RelativeMovementY
+= (CurrentState
.RelativeMovementY
* (INT32
) Private
->SimplePointerMode
.ResolutionY
) / (INT32
) Private
->PointerList
[Index
]->Mode
->ResolutionY
;
4120 if (CurrentState
.RelativeMovementZ
!= 0 && Private
->PointerList
[Index
]->Mode
->ResolutionZ
!= 0) {
4121 State
->RelativeMovementZ
+= (CurrentState
.RelativeMovementZ
* (INT32
) Private
->SimplePointerMode
.ResolutionZ
) / (INT32
) Private
->PointerList
[Index
]->Mode
->ResolutionZ
;
4123 } else if (Status
== EFI_DEVICE_ERROR
) {
4124 ReturnStatus
= EFI_DEVICE_ERROR
;
4128 return ReturnStatus
;
4133 Reads the next keystroke from the input device. The WaitForKey Event can
4134 be used to test for existance of a keystroke via WaitForEvent () call.
4136 @param This A pointer to protocol instance.
4137 @param State A pointer to state information on the pointer device
4139 @retval EFI_SUCCESS The keystroke information was returned in State.
4140 @retval EFI_NOT_READY There was no keystroke data availiable.
4141 @retval EFI_DEVICE_ERROR The keydtroke information was not returned due
4147 ConSplitterSimplePointerGetState (
4148 IN EFI_SIMPLE_POINTER_PROTOCOL
*This
,
4149 IN OUT EFI_SIMPLE_POINTER_STATE
*State
4152 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
4154 Private
= TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_SIMPLE_POINTER_THIS (This
);
4156 Private
->InputEventSignalState
= FALSE
;
4158 return ConSplitterSimplePointerPrivateGetState (Private
, State
);
4163 This event agregates all the events of the ConIn devices in the spliter.
4164 If any events of physical ConIn devices are signaled, signal the ConIn
4165 spliter event. This will cause the calling code to call
4166 ConSplitterTextInReadKeyStroke ().
4168 @param Event The Event assoicated with callback.
4169 @param Context Context registered when Event was created.
4174 ConSplitterSimplePointerWaitForInput (
4180 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
4183 Private
= (TEXT_IN_SPLITTER_PRIVATE_DATA
*) Context
;
4186 // if InputEventSignalState is flagged before, and not cleared by Reset() or ReadKeyStroke()
4188 if (Private
->InputEventSignalState
) {
4189 gBS
->SignalEvent (Event
);
4193 // if any physical console input device has key input, signal the event.
4195 for (Index
= 0; Index
< Private
->CurrentNumberOfPointers
; Index
++) {
4196 Status
= gBS
->CheckEvent (Private
->PointerList
[Index
]->WaitForInput
);
4197 if (!EFI_ERROR (Status
)) {
4198 gBS
->SignalEvent (Event
);
4199 Private
->InputEventSignalState
= TRUE
;
4205 Resets the pointer device hardware.
4207 @param This Protocol instance pointer.
4208 @param ExtendedVerification Driver may perform diagnostics on reset.
4210 @retval EFI_SUCCESS The device was reset.
4211 @retval EFI_DEVICE_ERROR The device is not functioning correctly and
4217 ConSplitterAbsolutePointerReset (
4218 IN EFI_ABSOLUTE_POINTER_PROTOCOL
*This
,
4219 IN BOOLEAN ExtendedVerification
4223 EFI_STATUS ReturnStatus
;
4224 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
4227 Private
= TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_ABSOLUTE_POINTER_THIS (This
);
4229 Private
->AbsoluteInputEventSignalState
= FALSE
;
4231 if (Private
->CurrentNumberOfAbsolutePointers
== 0) {
4235 // return the worst status met
4237 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfAbsolutePointers
; Index
++) {
4238 Status
= Private
->AbsolutePointerList
[Index
]->Reset (
4239 Private
->AbsolutePointerList
[Index
],
4240 ExtendedVerification
4242 if (EFI_ERROR (Status
)) {
4243 ReturnStatus
= Status
;
4247 return ReturnStatus
;
4252 Retrieves the current state of a pointer device.
4254 @param This Protocol instance pointer.
4255 @param State A pointer to the state information on the
4258 @retval EFI_SUCCESS The state of the pointer device was returned in
4260 @retval EFI_NOT_READY The state of the pointer device has not changed
4261 since the last call to GetState().
4262 @retval EFI_DEVICE_ERROR A device error occurred while attempting to
4263 retrieve the pointer device's current state.
4268 ConSplitterAbsolutePointerGetState (
4269 IN EFI_ABSOLUTE_POINTER_PROTOCOL
*This
,
4270 IN OUT EFI_ABSOLUTE_POINTER_STATE
*State
4273 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
4275 EFI_STATUS ReturnStatus
;
4277 EFI_ABSOLUTE_POINTER_STATE CurrentState
;
4280 Private
= TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_ABSOLUTE_POINTER_THIS (This
);
4282 Private
->AbsoluteInputEventSignalState
= FALSE
;
4284 State
->CurrentX
= 0;
4285 State
->CurrentY
= 0;
4286 State
->CurrentZ
= 0;
4287 State
->ActiveButtons
= 0;
4290 // if no physical pointer device exists, return EFI_NOT_READY;
4291 // if any physical pointer device has changed state,
4292 // return the state and EFI_SUCCESS.
4294 ReturnStatus
= EFI_NOT_READY
;
4295 for (Index
= 0; Index
< Private
->CurrentNumberOfAbsolutePointers
; Index
++) {
4297 Status
= Private
->AbsolutePointerList
[Index
]->GetState (
4298 Private
->AbsolutePointerList
[Index
],
4301 if (!EFI_ERROR (Status
)) {
4302 if (ReturnStatus
== EFI_NOT_READY
) {
4303 ReturnStatus
= EFI_SUCCESS
;
4306 State
->ActiveButtons
= CurrentState
.ActiveButtons
;
4308 if (!(Private
->AbsolutePointerMode
.AbsoluteMinX
== 0 && Private
->AbsolutePointerMode
.AbsoluteMaxX
== 0)) {
4309 State
->CurrentX
= CurrentState
.CurrentX
;
4311 if (!(Private
->AbsolutePointerMode
.AbsoluteMinY
== 0 && Private
->AbsolutePointerMode
.AbsoluteMaxY
== 0)) {
4312 State
->CurrentY
= CurrentState
.CurrentY
;
4314 if (!(Private
->AbsolutePointerMode
.AbsoluteMinZ
== 0 && Private
->AbsolutePointerMode
.AbsoluteMaxZ
== 0)) {
4315 State
->CurrentZ
= CurrentState
.CurrentZ
;
4318 } else if (Status
== EFI_DEVICE_ERROR
) {
4319 ReturnStatus
= EFI_DEVICE_ERROR
;
4323 return ReturnStatus
;
4328 This event agregates all the events of the pointer devices in the splitter.
4329 If any events of physical pointer devices are signaled, signal the pointer
4330 splitter event. This will cause the calling code to call
4331 ConSplitterAbsolutePointerGetState ().
4333 @param Event The Event assoicated with callback.
4334 @param Context Context registered when Event was created.
4339 ConSplitterAbsolutePointerWaitForInput (
4345 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
4348 Private
= (TEXT_IN_SPLITTER_PRIVATE_DATA
*) Context
;
4351 // if AbsoluteInputEventSignalState is flagged before,
4352 // and not cleared by Reset() or GetState(), signal it
4354 if (Private
->AbsoluteInputEventSignalState
) {
4355 gBS
->SignalEvent (Event
);
4359 // if any physical console input device has key input, signal the event.
4361 for (Index
= 0; Index
< Private
->CurrentNumberOfAbsolutePointers
; Index
++) {
4362 Status
= gBS
->CheckEvent (Private
->AbsolutePointerList
[Index
]->WaitForInput
);
4363 if (!EFI_ERROR (Status
)) {
4364 gBS
->SignalEvent (Event
);
4365 Private
->AbsoluteInputEventSignalState
= TRUE
;
4372 Reset the text output device hardware and optionaly run diagnostics
4374 @param This Protocol instance pointer.
4375 @param ExtendedVerification Driver may perform more exhaustive verfication
4376 operation of the device during reset.
4378 @retval EFI_SUCCESS The text output device was reset.
4379 @retval EFI_DEVICE_ERROR The text output device is not functioning
4380 correctly and could not be reset.
4385 ConSplitterTextOutReset (
4386 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4387 IN BOOLEAN ExtendedVerification
4391 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4393 EFI_STATUS ReturnStatus
;
4395 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4398 // return the worst status met
4400 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
4401 Status
= Private
->TextOutList
[Index
].TextOut
->Reset (
4402 Private
->TextOutList
[Index
].TextOut
,
4403 ExtendedVerification
4405 if (EFI_ERROR (Status
)) {
4406 ReturnStatus
= Status
;
4410 This
->SetAttribute (This
, EFI_TEXT_ATTR (This
->Mode
->Attribute
& 0x0F, EFI_BLACK
));
4413 // reset all mode parameters
4415 TextOutSetMode (Private
, 0);
4417 return ReturnStatus
;
4422 Write a Unicode string to the output device.
4424 @param This Protocol instance pointer.
4425 @param WString The NULL-terminated Unicode string to be
4426 displayed on the output device(s). All output
4427 devices must also support the Unicode drawing
4428 defined in this file.
4430 @retval EFI_SUCCESS The string was output to the device.
4431 @retval EFI_DEVICE_ERROR The device reported an error while attempting to
4433 @retval EFI_UNSUPPORTED The output device's mode is not currently in a
4435 @retval EFI_WARN_UNKNOWN_GLYPH This warning code indicates that some of the
4436 characters in the Unicode string could not be
4437 rendered and were skipped.
4442 ConSplitterTextOutOutputString (
4443 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4448 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4450 EFI_STATUS ReturnStatus
;
4454 This
->SetAttribute (This
, This
->Mode
->Attribute
);
4456 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4459 // return the worst status met
4461 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
4462 Status
= Private
->TextOutList
[Index
].TextOut
->OutputString (
4463 Private
->TextOutList
[Index
].TextOut
,
4466 if (EFI_ERROR (Status
)) {
4467 ReturnStatus
= Status
;
4471 if (Private
->CurrentNumberOfConsoles
> 0) {
4472 Private
->TextOutMode
.CursorColumn
= Private
->TextOutList
[0].TextOut
->Mode
->CursorColumn
;
4473 Private
->TextOutMode
.CursorRow
= Private
->TextOutList
[0].TextOut
->Mode
->CursorRow
;
4476 // When there is no real console devices in system,
4477 // update cursor position for the virtual device in consplitter.
4479 Private
->TextOut
.QueryMode (
4481 Private
->TextOutMode
.Mode
,
4485 for (; *WString
!= CHAR_NULL
; WString
++) {
4487 case CHAR_BACKSPACE
:
4488 if (Private
->TextOutMode
.CursorColumn
== 0 && Private
->TextOutMode
.CursorRow
> 0) {
4489 Private
->TextOutMode
.CursorRow
--;
4490 Private
->TextOutMode
.CursorColumn
= (INT32
) (MaxColumn
- 1);
4491 } else if (Private
->TextOutMode
.CursorColumn
> 0) {
4492 Private
->TextOutMode
.CursorColumn
--;
4497 if (Private
->TextOutMode
.CursorRow
< (INT32
) (MaxRow
- 1)) {
4498 Private
->TextOutMode
.CursorRow
++;
4502 case CHAR_CARRIAGE_RETURN
:
4503 Private
->TextOutMode
.CursorColumn
= 0;
4507 if (Private
->TextOutMode
.CursorColumn
< (INT32
) (MaxColumn
- 1)) {
4508 Private
->TextOutMode
.CursorColumn
++;
4510 Private
->TextOutMode
.CursorColumn
= 0;
4511 if (Private
->TextOutMode
.CursorRow
< (INT32
) (MaxRow
- 1)) {
4512 Private
->TextOutMode
.CursorRow
++;
4520 return ReturnStatus
;
4525 Verifies that all characters in a Unicode string can be output to the
4528 @param This Protocol instance pointer.
4529 @param WString The NULL-terminated Unicode string to be
4530 examined for the output device(s).
4532 @retval EFI_SUCCESS The device(s) are capable of rendering the
4534 @retval EFI_UNSUPPORTED Some of the characters in the Unicode string
4535 cannot be rendered by one or more of the output
4536 devices mapped by the EFI handle.
4541 ConSplitterTextOutTestString (
4542 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4547 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4549 EFI_STATUS ReturnStatus
;
4551 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4554 // return the worst status met
4556 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
4557 Status
= Private
->TextOutList
[Index
].TextOut
->TestString (
4558 Private
->TextOutList
[Index
].TextOut
,
4561 if (EFI_ERROR (Status
)) {
4562 ReturnStatus
= Status
;
4566 // There is no DevNullTextOutTestString () since a Unicode buffer would
4567 // always return EFI_SUCCESS.
4568 // ReturnStatus will be EFI_SUCCESS if no consoles are present
4570 return ReturnStatus
;
4575 Returns information for an available text mode that the output device(s)
4578 @param This Protocol instance pointer.
4579 @param ModeNumber The mode number to return information on.
4580 @param Columns Returns the columns of the text output device
4581 for the requested ModeNumber.
4582 @param Rows Returns the rows of the text output device
4583 for the requested ModeNumber.
4585 @retval EFI_SUCCESS The requested mode information was returned.
4586 @retval EFI_DEVICE_ERROR The device had an error and could not complete
4588 @retval EFI_UNSUPPORTED The mode number was not valid.
4593 ConSplitterTextOutQueryMode (
4594 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4595 IN UINTN ModeNumber
,
4600 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4602 INT32
*TextOutModeMap
;
4604 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4607 // Check whether param ModeNumber is valid.
4608 // ModeNumber should be within range 0 ~ MaxMode - 1.
4610 if ( (ModeNumber
> (UINTN
)(((UINT32
)-1)>>1)) ) {
4611 return EFI_UNSUPPORTED
;
4614 if ((INT32
) ModeNumber
>= This
->Mode
->MaxMode
) {
4615 return EFI_UNSUPPORTED
;
4619 // We get the available mode from mode intersection map if it's available
4621 if (Private
->TextOutModeMap
!= NULL
) {
4622 TextOutModeMap
= Private
->TextOutModeMap
+ Private
->TextOutListCount
* ModeNumber
;
4623 CurrentMode
= (UINTN
)(*TextOutModeMap
);
4624 *Columns
= Private
->TextOutQueryData
[CurrentMode
].Columns
;
4625 *Rows
= Private
->TextOutQueryData
[CurrentMode
].Rows
;
4627 *Columns
= Private
->TextOutQueryData
[ModeNumber
].Columns
;
4628 *Rows
= Private
->TextOutQueryData
[ModeNumber
].Rows
;
4631 if (*Columns
<= 0 && *Rows
<= 0) {
4632 return EFI_UNSUPPORTED
;
4641 Sets the output device(s) to a specified mode.
4643 @param This Protocol instance pointer.
4644 @param ModeNumber The mode number to set.
4646 @retval EFI_SUCCESS The requested text mode was set.
4647 @retval EFI_DEVICE_ERROR The device had an error and could not complete
4649 @retval EFI_UNSUPPORTED The mode number was not valid.
4654 ConSplitterTextOutSetMode (
4655 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4660 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4662 INT32
*TextOutModeMap
;
4663 EFI_STATUS ReturnStatus
;
4665 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4668 // Check whether param ModeNumber is valid.
4669 // ModeNumber should be within range 0 ~ MaxMode - 1.
4671 if ( (ModeNumber
> (UINTN
)(((UINT32
)-1)>>1)) ) {
4672 return EFI_UNSUPPORTED
;
4675 if ((INT32
) ModeNumber
>= This
->Mode
->MaxMode
) {
4676 return EFI_UNSUPPORTED
;
4679 // If the mode is being set to the curent mode, then just clear the screen and return.
4681 if (Private
->TextOutMode
.Mode
== (INT32
) ModeNumber
) {
4682 return ConSplitterTextOutClearScreen (This
);
4685 // return the worst status met
4687 TextOutModeMap
= Private
->TextOutModeMap
+ Private
->TextOutListCount
* ModeNumber
;
4688 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
4689 Status
= Private
->TextOutList
[Index
].TextOut
->SetMode (
4690 Private
->TextOutList
[Index
].TextOut
,
4691 TextOutModeMap
[Index
]
4693 if (EFI_ERROR (Status
)) {
4694 ReturnStatus
= Status
;
4699 // Set mode parameter to specified mode number
4701 TextOutSetMode (Private
, ModeNumber
);
4703 return ReturnStatus
;
4708 Sets the background and foreground colors for the OutputString () and
4709 ClearScreen () functions.
4711 @param This Protocol instance pointer.
4712 @param Attribute The attribute to set. Bits 0..3 are the
4713 foreground color, and bits 4..6 are the
4714 background color. All other bits are undefined
4715 and must be zero. The valid Attributes are
4716 defined in this file.
4718 @retval EFI_SUCCESS The attribute was set.
4719 @retval EFI_DEVICE_ERROR The device had an error and could not complete
4721 @retval EFI_UNSUPPORTED The attribute requested is not defined.
4726 ConSplitterTextOutSetAttribute (
4727 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4732 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4734 EFI_STATUS ReturnStatus
;
4736 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4739 // Check whether param Attribute is valid.
4741 if ( (Attribute
> (UINTN
)(((UINT32
)-1)>>1)) ) {
4742 return EFI_UNSUPPORTED
;
4746 // return the worst status met
4748 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
4749 Status
= Private
->TextOutList
[Index
].TextOut
->SetAttribute (
4750 Private
->TextOutList
[Index
].TextOut
,
4753 if (EFI_ERROR (Status
)) {
4754 ReturnStatus
= Status
;
4758 Private
->TextOutMode
.Attribute
= (INT32
) Attribute
;
4760 return ReturnStatus
;
4765 Clears the output device(s) display to the currently selected background
4768 @param This Protocol instance pointer.
4770 @retval EFI_SUCCESS The operation completed successfully.
4771 @retval EFI_DEVICE_ERROR The device had an error and could not complete
4773 @retval EFI_UNSUPPORTED The output device is not in a valid text mode.
4778 ConSplitterTextOutClearScreen (
4779 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
4783 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4785 EFI_STATUS ReturnStatus
;
4787 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4790 // return the worst status met
4792 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
4793 Status
= Private
->TextOutList
[Index
].TextOut
->ClearScreen (Private
->TextOutList
[Index
].TextOut
);
4794 if (EFI_ERROR (Status
)) {
4795 ReturnStatus
= Status
;
4800 // No need to do extra check here as whether (Column, Row) is valid has
4801 // been checked in ConSplitterTextOutSetCursorPosition. And (0, 0) should
4802 // always be supported.
4804 Private
->TextOutMode
.CursorColumn
= 0;
4805 Private
->TextOutMode
.CursorRow
= 0;
4806 Private
->TextOutMode
.CursorVisible
= TRUE
;
4808 return ReturnStatus
;
4813 Sets the current coordinates of the cursor position
4815 @param This Protocol instance pointer.
4816 @param Column The column position to set the cursor to. Must be
4817 greater than or equal to zero and less than the
4818 number of columns by QueryMode ().
4819 @param Row The row position to set the cursor to. Must be
4820 greater than or equal to zero and less than the
4821 number of rows by QueryMode ().
4823 @retval EFI_SUCCESS The operation completed successfully.
4824 @retval EFI_DEVICE_ERROR The device had an error and could not complete
4826 @retval EFI_UNSUPPORTED The output device is not in a valid text mode,
4827 or the cursor position is invalid for the
4833 ConSplitterTextOutSetCursorPosition (
4834 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4840 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4842 EFI_STATUS ReturnStatus
;
4845 INT32
*TextOutModeMap
;
4849 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4850 TextOutModeMap
= NULL
;
4851 ModeNumber
= Private
->TextOutMode
.Mode
;
4854 // Get current MaxColumn and MaxRow from intersection map
4856 if (Private
->TextOutModeMap
!= NULL
) {
4857 TextOutModeMap
= Private
->TextOutModeMap
+ Private
->TextOutListCount
* ModeNumber
;
4858 CurrentMode
= *TextOutModeMap
;
4860 CurrentMode
= ModeNumber
;
4863 MaxColumn
= Private
->TextOutQueryData
[CurrentMode
].Columns
;
4864 MaxRow
= Private
->TextOutQueryData
[CurrentMode
].Rows
;
4866 if (Column
>= MaxColumn
|| Row
>= MaxRow
) {
4867 return EFI_UNSUPPORTED
;
4870 // return the worst status met
4872 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
4873 Status
= Private
->TextOutList
[Index
].TextOut
->SetCursorPosition (
4874 Private
->TextOutList
[Index
].TextOut
,
4878 if (EFI_ERROR (Status
)) {
4879 ReturnStatus
= Status
;
4884 // No need to do extra check here as whether (Column, Row) is valid has
4885 // been checked in ConSplitterTextOutSetCursorPosition. And (0, 0) should
4886 // always be supported.
4888 Private
->TextOutMode
.CursorColumn
= (INT32
) Column
;
4889 Private
->TextOutMode
.CursorRow
= (INT32
) Row
;
4891 return ReturnStatus
;
4896 Makes the cursor visible or invisible
4898 @param This Protocol instance pointer.
4899 @param Visible If TRUE, the cursor is set to be visible. If
4900 FALSE, the cursor is set to be invisible.
4902 @retval EFI_SUCCESS The operation completed successfully.
4903 @retval EFI_DEVICE_ERROR The device had an error and could not complete
4904 the request, or the device does not support
4905 changing the cursor mode.
4906 @retval EFI_UNSUPPORTED The output device is not in a valid text mode.
4911 ConSplitterTextOutEnableCursor (
4912 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4917 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4919 EFI_STATUS ReturnStatus
;
4921 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4924 // return the worst status met
4926 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
4927 Status
= Private
->TextOutList
[Index
].TextOut
->EnableCursor (
4928 Private
->TextOutList
[Index
].TextOut
,
4931 if (EFI_ERROR (Status
)) {
4932 ReturnStatus
= Status
;
4936 Private
->TextOutMode
.CursorVisible
= Visible
;
4938 return ReturnStatus
;