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 - 2009, Intel Corporation. <BR>
20 All rights reserved. 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 // Text In Splitter Private Data template
35 GLOBAL_REMOVE_IF_UNREFERENCED TEXT_IN_SPLITTER_PRIVATE_DATA mConIn
= {
36 TEXT_IN_SPLITTER_PRIVATE_DATA_SIGNATURE
,
40 ConSplitterTextInReset
,
41 ConSplitterTextInReadKeyStroke
,
45 (EFI_SIMPLE_TEXT_INPUT_PROTOCOL
**) NULL
,
49 ConSplitterTextInResetEx
,
50 ConSplitterTextInReadKeyStrokeEx
,
52 ConSplitterTextInSetState
,
53 ConSplitterTextInRegisterKeyNotify
,
54 ConSplitterTextInUnregisterKeyNotify
57 (EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
**) NULL
,
65 ConSplitterSimplePointerReset
,
66 ConSplitterSimplePointerGetState
,
68 (EFI_SIMPLE_POINTER_MODE
*) NULL
78 (EFI_SIMPLE_POINTER_PROTOCOL
**) NULL
,
82 ConSplitterAbsolutePointerReset
,
83 ConSplitterAbsolutePointerGetState
,
85 (EFI_ABSOLUTE_POINTER_MODE
*) NULL
91 0x10000, // AbsoluteMaxX
92 0x10000, // AbsoluteMaxY
93 0x10000, // AbsoluteMaxZ
97 (EFI_ABSOLUTE_POINTER_PROTOCOL
**) NULL
,
107 // Uga Draw Protocol Private Data template
109 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UGA_DRAW_PROTOCOL mUgaDrawProtocolTemplate
= {
110 ConSpliterUgaDrawGetMode
,
111 ConSpliterUgaDrawSetMode
,
116 // Graphics Output Protocol Private Data template
118 GLOBAL_REMOVE_IF_UNREFERENCED EFI_GRAPHICS_OUTPUT_PROTOCOL mGraphicsOutputProtocolTemplate
= {
119 ConSpliterGraphicsOutputQueryMode
,
120 ConSpliterGraphicsOutputSetMode
,
121 ConSpliterGraphicsOutputBlt
,
127 // Text Out Splitter Private Data template
129 GLOBAL_REMOVE_IF_UNREFERENCED TEXT_OUT_SPLITTER_PRIVATE_DATA mConOut
= {
130 TEXT_OUT_SPLITTER_PRIVATE_DATA_SIGNATURE
,
133 ConSplitterTextOutReset
,
134 ConSplitterTextOutOutputString
,
135 ConSplitterTextOutTestString
,
136 ConSplitterTextOutQueryMode
,
137 ConSplitterTextOutSetMode
,
138 ConSplitterTextOutSetAttribute
,
139 ConSplitterTextOutClearScreen
,
140 ConSplitterTextOutSetCursorPosition
,
141 ConSplitterTextOutEnableCursor
,
142 (EFI_SIMPLE_TEXT_OUTPUT_MODE
*) NULL
169 (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*) NULL
,
175 (TEXT_OUT_AND_GOP_DATA
*) NULL
,
177 (TEXT_OUT_SPLITTER_QUERY_DATA
*) NULL
,
183 // Standard Error Text Out Splitter Data Template
185 GLOBAL_REMOVE_IF_UNREFERENCED TEXT_OUT_SPLITTER_PRIVATE_DATA mStdErr
= {
186 TEXT_OUT_SPLITTER_PRIVATE_DATA_SIGNATURE
,
189 ConSplitterTextOutReset
,
190 ConSplitterTextOutOutputString
,
191 ConSplitterTextOutTestString
,
192 ConSplitterTextOutQueryMode
,
193 ConSplitterTextOutSetMode
,
194 ConSplitterTextOutSetAttribute
,
195 ConSplitterTextOutClearScreen
,
196 ConSplitterTextOutSetCursorPosition
,
197 ConSplitterTextOutEnableCursor
,
198 (EFI_SIMPLE_TEXT_OUTPUT_MODE
*) NULL
225 (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*) NULL
,
231 (TEXT_OUT_AND_GOP_DATA
*) NULL
,
233 (TEXT_OUT_SPLITTER_QUERY_DATA
*) NULL
,
239 // Driver binding instance for Console Input Device
241 EFI_DRIVER_BINDING_PROTOCOL gConSplitterConInDriverBinding
= {
242 ConSplitterConInDriverBindingSupported
,
243 ConSplitterConInDriverBindingStart
,
244 ConSplitterConInDriverBindingStop
,
251 // Driver binding instance for Console Out device
253 EFI_DRIVER_BINDING_PROTOCOL gConSplitterConOutDriverBinding
= {
254 ConSplitterConOutDriverBindingSupported
,
255 ConSplitterConOutDriverBindingStart
,
256 ConSplitterConOutDriverBindingStop
,
263 // Driver binding instance for Standard Error device
265 EFI_DRIVER_BINDING_PROTOCOL gConSplitterStdErrDriverBinding
= {
266 ConSplitterStdErrDriverBindingSupported
,
267 ConSplitterStdErrDriverBindingStart
,
268 ConSplitterStdErrDriverBindingStop
,
275 // Driver binding instance for Simple Pointer protocol
277 EFI_DRIVER_BINDING_PROTOCOL gConSplitterSimplePointerDriverBinding
= {
278 ConSplitterSimplePointerDriverBindingSupported
,
279 ConSplitterSimplePointerDriverBindingStart
,
280 ConSplitterSimplePointerDriverBindingStop
,
287 // Driver binding instance for Absolute Pointer protocol
289 EFI_DRIVER_BINDING_PROTOCOL gConSplitterAbsolutePointerDriverBinding
= {
290 ConSplitterAbsolutePointerDriverBindingSupported
,
291 ConSplitterAbsolutePointerDriverBindingStart
,
292 ConSplitterAbsolutePointerDriverBindingStop
,
299 The Entry Point for module ConSplitter. The user code starts with this function.
301 Installs driver module protocols and. Creates virtual device handles for ConIn,
302 ConOut, and StdErr. Installs Simple Text In protocol, Simple Text In Ex protocol,
303 Simple Pointer protocol, Absolute Pointer protocol on those virtual handlers.
304 Installs Graphics Output protocol and/or UGA Draw protocol if needed.
306 @param[in] ImageHandle The firmware allocated handle for the EFI image.
307 @param[in] SystemTable A pointer to the EFI System Table.
309 @retval EFI_SUCCESS The entry point is executed successfully.
310 @retval other Some error occurs when executing this entry point.
315 ConSplitterDriverEntry(
316 IN EFI_HANDLE ImageHandle
,
317 IN EFI_SYSTEM_TABLE
*SystemTable
323 // Install driver model protocol(s).
325 Status
= EfiLibInstallDriverBindingComponentName2 (
328 &gConSplitterConInDriverBinding
,
330 &gConSplitterConInComponentName
,
331 &gConSplitterConInComponentName2
333 ASSERT_EFI_ERROR (Status
);
335 Status
= EfiLibInstallDriverBindingComponentName2 (
338 &gConSplitterSimplePointerDriverBinding
,
340 &gConSplitterSimplePointerComponentName
,
341 &gConSplitterSimplePointerComponentName2
343 ASSERT_EFI_ERROR (Status
);
345 Status
= EfiLibInstallDriverBindingComponentName2 (
348 &gConSplitterAbsolutePointerDriverBinding
,
350 &gConSplitterAbsolutePointerComponentName
,
351 &gConSplitterAbsolutePointerComponentName2
353 ASSERT_EFI_ERROR (Status
);
355 Status
= EfiLibInstallDriverBindingComponentName2 (
358 &gConSplitterConOutDriverBinding
,
360 &gConSplitterConOutComponentName
,
361 &gConSplitterConOutComponentName2
363 ASSERT_EFI_ERROR (Status
);
365 Status
= EfiLibInstallDriverBindingComponentName2 (
368 &gConSplitterStdErrDriverBinding
,
370 &gConSplitterStdErrComponentName
,
371 &gConSplitterStdErrComponentName2
373 ASSERT_EFI_ERROR (Status
);
376 // Either Graphics Output protocol or UGA Draw protocol must be supported.
378 ASSERT (FeaturePcdGet (PcdConOutGopSupport
) ||
379 FeaturePcdGet (PcdConOutUgaSupport
));
382 // The driver creates virtual handles for ConIn, ConOut, and StdErr.
383 // The virtual handles will always exist even if no console exist in the
384 // system. This is need to support hotplug devices like USB.
387 // Create virtual device handle for StdErr Splitter
389 Status
= ConSplitterTextOutConstructor (&mStdErr
);
390 if (!EFI_ERROR (Status
)) {
391 Status
= gBS
->InstallMultipleProtocolInterfaces (
392 &mStdErr
.VirtualHandle
,
393 &gEfiSimpleTextOutProtocolGuid
,
399 // Create virtual device handle for ConIn Splitter
401 Status
= ConSplitterTextInConstructor (&mConIn
);
402 if (!EFI_ERROR (Status
)) {
403 Status
= gBS
->InstallMultipleProtocolInterfaces (
404 &mConIn
.VirtualHandle
,
405 &gEfiSimpleTextInProtocolGuid
,
407 &gEfiSimpleTextInputExProtocolGuid
,
409 &gEfiSimplePointerProtocolGuid
,
410 &mConIn
.SimplePointer
,
411 &gEfiAbsolutePointerProtocolGuid
,
412 &mConIn
.AbsolutePointer
,
415 if (!EFI_ERROR (Status
)) {
417 // Update the EFI System Table with new virtual console
418 // and update the pointer to Simple Text Input protocol.
420 gST
->ConsoleInHandle
= mConIn
.VirtualHandle
;
421 gST
->ConIn
= &mConIn
.TextIn
;
425 // Create virtual device handle for ConOut Splitter
427 Status
= ConSplitterTextOutConstructor (&mConOut
);
428 if (!EFI_ERROR (Status
)) {
429 if (!FeaturePcdGet (PcdConOutGopSupport
)) {
431 // If Graphics Outpurt protocol not supported, UGA Draw protocol is installed
432 // on the virtual handle.
434 Status
= gBS
->InstallMultipleProtocolInterfaces (
435 &mConOut
.VirtualHandle
,
436 &gEfiSimpleTextOutProtocolGuid
,
438 &gEfiUgaDrawProtocolGuid
,
442 } else if (!FeaturePcdGet (PcdConOutUgaSupport
)) {
444 // If UGA Draw protocol not supported, Graphics Output Protocol is installed
445 // on virtual handle.
447 Status
= gBS
->InstallMultipleProtocolInterfaces (
448 &mConOut
.VirtualHandle
,
449 &gEfiSimpleTextOutProtocolGuid
,
451 &gEfiGraphicsOutputProtocolGuid
,
452 &mConOut
.GraphicsOutput
,
457 // Boot Graphics Output protocol and UGA Draw protocol are supported,
458 // both they will be installed on virtual handle.
460 Status
= gBS
->InstallMultipleProtocolInterfaces (
461 &mConOut
.VirtualHandle
,
462 &gEfiSimpleTextOutProtocolGuid
,
464 &gEfiGraphicsOutputProtocolGuid
,
465 &mConOut
.GraphicsOutput
,
466 &gEfiUgaDrawProtocolGuid
,
472 if (!EFI_ERROR (Status
)) {
474 // Update the EFI System Table with new virtual console
475 // and Update the pointer to Text Output protocol.
477 gST
->ConsoleOutHandle
= mConOut
.VirtualHandle
;
478 gST
->ConOut
= &mConOut
.TextOut
;
483 // Update the CRC32 in the EFI System Table header
486 gBS
->CalculateCrc32 (
497 Construct console input devices' private data.
499 @param ConInPrivate A pointer to the TEXT_IN_SPLITTER_PRIVATE_DATA
502 @retval EFI_OUT_OF_RESOURCES Out of resources.
503 @retval EFI_SUCCESS Text Input Devcie's private data has been constructed.
504 @retval other Failed to construct private data.
508 ConSplitterTextInConstructor (
509 TEXT_IN_SPLITTER_PRIVATE_DATA
*ConInPrivate
515 // Allocate buffer for Simple Text Input device
517 Status
= ConSplitterGrowBuffer (
518 sizeof (EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*),
519 &ConInPrivate
->TextInListCount
,
520 (VOID
**) &ConInPrivate
->TextInList
522 if (EFI_ERROR (Status
)) {
523 return EFI_OUT_OF_RESOURCES
;
527 // Create Event to wait for a key
529 Status
= gBS
->CreateEvent (
532 ConSplitterTextInWaitForKey
,
534 &ConInPrivate
->TextIn
.WaitForKey
536 ASSERT_EFI_ERROR (Status
);
539 // Allocate buffer for Simple Text Input Ex device
541 Status
= ConSplitterGrowBuffer (
542 sizeof (EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*),
543 &ConInPrivate
->TextInExListCount
,
544 (VOID
**) &ConInPrivate
->TextInExList
546 if (EFI_ERROR (Status
)) {
547 return EFI_OUT_OF_RESOURCES
;
550 // Create Event to wait for a key Ex
552 Status
= gBS
->CreateEvent (
555 ConSplitterTextInWaitForKey
,
557 &ConInPrivate
->TextInEx
.WaitForKeyEx
559 ASSERT_EFI_ERROR (Status
);
561 InitializeListHead (&ConInPrivate
->NotifyList
);
563 ConInPrivate
->AbsolutePointer
.Mode
= &ConInPrivate
->AbsolutePointerMode
;
565 // Allocate buffer for Absolute Pointer device
567 Status
= ConSplitterGrowBuffer (
568 sizeof (EFI_ABSOLUTE_POINTER_PROTOCOL
*),
569 &ConInPrivate
->AbsolutePointerListCount
,
570 (VOID
**) &ConInPrivate
->AbsolutePointerList
572 if (EFI_ERROR (Status
)) {
573 return EFI_OUT_OF_RESOURCES
;
576 // Create Event to wait for device input for Absolute pointer device
578 Status
= gBS
->CreateEvent (
581 ConSplitterAbsolutePointerWaitForInput
,
583 &ConInPrivate
->AbsolutePointer
.WaitForInput
585 ASSERT_EFI_ERROR (Status
);
587 ConInPrivate
->SimplePointer
.Mode
= &ConInPrivate
->SimplePointerMode
;
589 // Allocate buffer for Simple Pointer device
591 Status
= ConSplitterGrowBuffer (
592 sizeof (EFI_SIMPLE_POINTER_PROTOCOL
*),
593 &ConInPrivate
->PointerListCount
,
594 (VOID
**) &ConInPrivate
->PointerList
596 if (EFI_ERROR (Status
)) {
597 return EFI_OUT_OF_RESOURCES
;
600 // Create Event to wait for device input for Simple pointer device
602 Status
= gBS
->CreateEvent (
605 ConSplitterSimplePointerWaitForInput
,
607 &ConInPrivate
->SimplePointer
.WaitForInput
614 Construct console output devices' private data.
616 @param ConOutPrivate A pointer to the TEXT_OUT_SPLITTER_PRIVATE_DATA
619 @retval EFI_OUT_OF_RESOURCES Out of resources.
620 @retval EFI_SUCCESS Text Input Devcie's private data has been constructed.
624 ConSplitterTextOutConstructor (
625 TEXT_OUT_SPLITTER_PRIVATE_DATA
*ConOutPrivate
629 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*Info
;
632 // Copy protocols template
634 if (FeaturePcdGet (PcdConOutUgaSupport
)) {
635 CopyMem (&ConOutPrivate
->UgaDraw
, &mUgaDrawProtocolTemplate
, sizeof (EFI_UGA_DRAW_PROTOCOL
));
637 if (FeaturePcdGet (PcdConOutGopSupport
)) {
638 CopyMem (&ConOutPrivate
->GraphicsOutput
, &mGraphicsOutputProtocolTemplate
, sizeof (EFI_GRAPHICS_OUTPUT_PROTOCOL
));
642 // Initilize console output splitter's private data.
644 ConOutPrivate
->TextOut
.Mode
= &ConOutPrivate
->TextOutMode
;
647 // When new console device is added, the new mode will be set later,
648 // so put current mode back to init state.
650 ConOutPrivate
->TextOutMode
.Mode
= 0xFF;
652 // Allocate buffer for Console Out device
654 Status
= ConSplitterGrowBuffer (
655 sizeof (TEXT_OUT_AND_GOP_DATA
),
656 &ConOutPrivate
->TextOutListCount
,
657 (VOID
**) &ConOutPrivate
->TextOutList
659 if (EFI_ERROR (Status
)) {
660 return EFI_OUT_OF_RESOURCES
;
663 // Allocate buffer for Text Out query data
665 Status
= ConSplitterGrowBuffer (
666 sizeof (TEXT_OUT_SPLITTER_QUERY_DATA
),
667 &ConOutPrivate
->TextOutQueryDataCount
,
668 (VOID
**) &ConOutPrivate
->TextOutQueryData
670 if (EFI_ERROR (Status
)) {
671 return EFI_OUT_OF_RESOURCES
;
675 // Setup the default console to 80 x 25 and mode to 0
677 ConOutPrivate
->TextOutQueryData
[0].Columns
= 80;
678 ConOutPrivate
->TextOutQueryData
[0].Rows
= 25;
679 TextOutSetMode (ConOutPrivate
, 0);
682 if (FeaturePcdGet (PcdConOutUgaSupport
)) {
684 // Setup the UgaDraw to 800 x 600 x 32 bits per pixel, 60Hz.
686 ConSpliterUgaDrawSetMode (&ConOutPrivate
->UgaDraw
, 800, 600, 32, 60);
688 if (FeaturePcdGet (PcdConOutGopSupport
)) {
690 // Setup resource for mode information in Graphics Output Protocol interface
692 if ((ConOutPrivate
->GraphicsOutput
.Mode
= AllocateZeroPool (sizeof (EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE
))) == NULL
) {
693 return EFI_OUT_OF_RESOURCES
;
695 if ((ConOutPrivate
->GraphicsOutput
.Mode
->Info
= AllocateZeroPool (sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
))) == NULL
) {
696 return EFI_OUT_OF_RESOURCES
;
699 // Setup the DevNullGraphicsOutput to 800 x 600 x 32 bits per pixel
700 // DevNull will be updated to user-defined mode after driver has started.
702 if ((ConOutPrivate
->GraphicsOutputModeBuffer
= AllocateZeroPool (sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
))) == NULL
) {
703 return EFI_OUT_OF_RESOURCES
;
705 Info
= &ConOutPrivate
->GraphicsOutputModeBuffer
[0];
707 Info
->HorizontalResolution
= 800;
708 Info
->VerticalResolution
= 600;
709 Info
->PixelFormat
= PixelBltOnly
;
710 Info
->PixelsPerScanLine
= 800;
711 CopyMem (ConOutPrivate
->GraphicsOutput
.Mode
->Info
, Info
, sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
));
712 ConOutPrivate
->GraphicsOutput
.Mode
->SizeOfInfo
= sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
);
715 // Initialize the following items, theset items remain unchanged in GraphicsOutput->SetMode()
716 // GraphicsOutputMode->FrameBufferBase, GraphicsOutputMode->FrameBufferSize
718 ConOutPrivate
->GraphicsOutput
.Mode
->FrameBufferBase
= (EFI_PHYSICAL_ADDRESS
) (UINTN
) NULL
;
719 ConOutPrivate
->GraphicsOutput
.Mode
->FrameBufferSize
= 0;
721 ConOutPrivate
->GraphicsOutput
.Mode
->MaxMode
= 1;
723 // Initial current mode to unknown state, and then set to mode 0
725 ConOutPrivate
->GraphicsOutput
.Mode
->Mode
= 0xffff;
726 ConOutPrivate
->GraphicsOutput
.SetMode (&ConOutPrivate
->GraphicsOutput
, 0);
734 Test to see if the specified protocol could be supported on the specified device.
736 @param This Driver Binding protocol pointer.
737 @param ControllerHandle Handle of device to test.
738 @param Guid The specified protocol.
740 @retval EFI_SUCCESS The specified protocol is supported on this device.
741 @retval EFI_UNSUPPORTED The specified protocol attempts to be installed on virtul handle.
742 @retval other Failed to open specified protocol on this device.
746 ConSplitterSupported (
747 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
748 IN EFI_HANDLE ControllerHandle
,
756 // Make sure the Console Splitter does not attempt to attach to itself
758 if (ControllerHandle
== mConIn
.VirtualHandle
||
759 ControllerHandle
== mConOut
.VirtualHandle
||
760 ControllerHandle
== mStdErr
.VirtualHandle
762 return EFI_UNSUPPORTED
;
766 // Check to see whether the specific protocol could be opened BY_DRIVER
768 Status
= gBS
->OpenProtocol (
772 This
->DriverBindingHandle
,
774 EFI_OPEN_PROTOCOL_BY_DRIVER
777 if (EFI_ERROR (Status
)) {
784 This
->DriverBindingHandle
,
792 Test to see if Console In Device could be supported on the Controller.
794 @param This Driver Binding protocol instance pointer.
795 @param ControllerHandle Handle of device to test.
796 @param RemainingDevicePath Optional parameter use to pick a specific child
799 @retval EFI_SUCCESS This driver supports this device.
800 @retval other This driver does not support this device.
805 ConSplitterConInDriverBindingSupported (
806 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
807 IN EFI_HANDLE ControllerHandle
,
808 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
811 return ConSplitterSupported (
814 &gEfiConsoleInDeviceGuid
819 Test to see if Simple Pointer protocol could be supported on the Controller.
821 @param This Driver Binding protocol instance pointer.
822 @param ControllerHandle Handle of device to test.
823 @param RemainingDevicePath Optional parameter use to pick a specific child
826 @retval EFI_SUCCESS This driver supports this device.
827 @retval other This driver does not support this device.
832 ConSplitterSimplePointerDriverBindingSupported (
833 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
834 IN EFI_HANDLE ControllerHandle
,
835 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
838 return ConSplitterSupported (
841 &gEfiSimplePointerProtocolGuid
846 Test to see if Absolute Pointer protocol could be supported on the Controller.
848 @param This Driver Binding protocol instance pointer.
849 @param ControllerHandle Handle of device to test.
850 @param RemainingDevicePath Optional parameter use to pick a specific child
853 @retval EFI_SUCCESS This driver supports this device.
854 @retval other This driver does not support this device.
859 ConSplitterAbsolutePointerDriverBindingSupported (
860 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
861 IN EFI_HANDLE ControllerHandle
,
862 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
865 return ConSplitterSupported (
868 &gEfiAbsolutePointerProtocolGuid
874 Test to see if Console Out Device could be supported on the Controller.
876 @param This Driver Binding protocol instance pointer.
877 @param ControllerHandle Handle of device to test.
878 @param RemainingDevicePath Optional parameter use to pick a specific child
881 @retval EFI_SUCCESS This driver supports this device.
882 @retval other This driver does not support this device.
887 ConSplitterConOutDriverBindingSupported (
888 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
889 IN EFI_HANDLE ControllerHandle
,
890 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
893 return ConSplitterSupported (
896 &gEfiConsoleOutDeviceGuid
901 Test to see if Standard Error Device could be supported on the Controller.
903 @param This Driver Binding protocol instance pointer.
904 @param ControllerHandle Handle of device to test.
905 @param RemainingDevicePath Optional parameter use to pick a specific child
908 @retval EFI_SUCCESS This driver supports this device.
909 @retval other This driver does not support this device.
914 ConSplitterStdErrDriverBindingSupported (
915 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
916 IN EFI_HANDLE ControllerHandle
,
917 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
920 return ConSplitterSupported (
923 &gEfiStandardErrorDeviceGuid
929 Start ConSplitter on devcie handle by opening Console Device Guid on device handle
930 and the console virtual handle. And Get the console interface on controller handle.
932 @param This Driver Binding protocol instance pointer.
933 @param ControllerHandle Handle of device.
934 @param ConSplitterVirtualHandle Console virtual Handle.
935 @param DeviceGuid The specified Console Device, such as ConInDev,
937 @param InterfaceGuid The specified protocol to be opened.
938 @param Interface Protocol interface returned.
940 @retval EFI_SUCCESS This driver supports this device.
941 @retval other Failed to open the specified Console Device Guid
942 or specified protocol.
947 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
948 IN EFI_HANDLE ControllerHandle
,
949 IN EFI_HANDLE ConSplitterVirtualHandle
,
950 IN EFI_GUID
*DeviceGuid
,
951 IN EFI_GUID
*InterfaceGuid
,
959 // Check to see whether the ControllerHandle has the DeviceGuid on it.
961 Status
= gBS
->OpenProtocol (
965 This
->DriverBindingHandle
,
967 EFI_OPEN_PROTOCOL_BY_DRIVER
969 if (EFI_ERROR (Status
)) {
974 // Create virtual handle and open DeviceGuid on the virtul handle.
976 Status
= gBS
->OpenProtocol (
980 This
->DriverBindingHandle
,
981 ConSplitterVirtualHandle
,
982 EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
984 if (EFI_ERROR (Status
)) {
989 // Open InterfaceGuid on the virtul handle.
991 Status
= gBS
->OpenProtocol (
995 This
->DriverBindingHandle
,
996 ConSplitterVirtualHandle
,
997 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1000 if (!EFI_ERROR (Status
)) {
1005 // close the DeviceGuid on ConSplitter VirtualHandle.
1007 gBS
->CloseProtocol (
1010 This
->DriverBindingHandle
,
1011 ConSplitterVirtualHandle
1016 // close the DeviceGuid on ControllerHandle.
1018 gBS
->CloseProtocol (
1021 This
->DriverBindingHandle
,
1030 Start Console In Consplitter on device handle.
1032 @param This Driver Binding protocol instance pointer.
1033 @param ControllerHandle Handle of device to bind driver to.
1034 @param RemainingDevicePath Optional parameter use to pick a specific child
1037 @retval EFI_SUCCESS Console In Consplitter is added to ControllerHandle.
1038 @retval other Console In Consplitter does not support this device.
1043 ConSplitterConInDriverBindingStart (
1044 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1045 IN EFI_HANDLE ControllerHandle
,
1046 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
1050 EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*TextIn
;
1051 EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*TextInEx
;
1054 // Start ConSplitter on ControllerHandle, and create the virtual
1055 // agrogated console device on first call Start for a SimpleTextIn handle.
1057 Status
= ConSplitterStart (
1060 mConIn
.VirtualHandle
,
1061 &gEfiConsoleInDeviceGuid
,
1062 &gEfiSimpleTextInProtocolGuid
,
1065 if (EFI_ERROR (Status
)) {
1070 // Add this device into Text In devices list.
1072 Status
= ConSplitterTextInAddDevice (&mConIn
, TextIn
);
1073 if (EFI_ERROR (Status
)) {
1077 Status
= gBS
->OpenProtocol (
1079 &gEfiSimpleTextInputExProtocolGuid
,
1080 (VOID
**) &TextInEx
,
1081 This
->DriverBindingHandle
,
1082 mConIn
.VirtualHandle
,
1083 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1085 if (!EFI_ERROR (Status
)) {
1087 // If Simple Text Input Ex protocol exists,
1088 // add this device into Text In Ex devices list.
1090 Status
= ConSplitterTextInExAddDevice (&mConIn
, TextInEx
);
1098 Start Simple Pointer Consplitter on device handle.
1100 @param This Driver Binding protocol instance pointer.
1101 @param ControllerHandle Handle of device to bind driver to.
1102 @param RemainingDevicePath Optional parameter use to pick a specific child
1105 @retval EFI_SUCCESS Simple Pointer Consplitter is added to ControllerHandle.
1106 @retval other Simple Pointer Consplitter does not support this device.
1111 ConSplitterSimplePointerDriverBindingStart (
1112 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1113 IN EFI_HANDLE ControllerHandle
,
1114 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
1118 EFI_SIMPLE_POINTER_PROTOCOL
*SimplePointer
;
1121 // Start ConSplitter on ControllerHandle, and create the virtual
1122 // agrogated console device on first call Start for a SimplePointer handle.
1124 Status
= ConSplitterStart (
1127 mConIn
.VirtualHandle
,
1128 &gEfiSimplePointerProtocolGuid
,
1129 &gEfiSimplePointerProtocolGuid
,
1130 (VOID
**) &SimplePointer
1132 if (EFI_ERROR (Status
)) {
1137 // Add this devcie into Simple Pointer devices list.
1139 return ConSplitterSimplePointerAddDevice (&mConIn
, SimplePointer
);
1144 Start Absolute Pointer Consplitter on device handle.
1146 @param This Driver Binding protocol instance pointer.
1147 @param ControllerHandle Handle of device to bind driver to.
1148 @param RemainingDevicePath Optional parameter use to pick a specific child
1151 @retval EFI_SUCCESS Absolute Pointer Consplitter is added to ControllerHandle.
1152 @retval other Absolute Pointer Consplitter does not support this device.
1157 ConSplitterAbsolutePointerDriverBindingStart (
1158 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1159 IN EFI_HANDLE ControllerHandle
,
1160 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
1164 EFI_ABSOLUTE_POINTER_PROTOCOL
*AbsolutePointer
;
1167 // Start ConSplitter on ControllerHandle, and create the virtual
1168 // agrogated console device on first call Start for a AbsolutePointer handle.
1170 Status
= ConSplitterStart (
1173 mConIn
.VirtualHandle
,
1174 &gEfiAbsolutePointerProtocolGuid
,
1175 &gEfiAbsolutePointerProtocolGuid
,
1176 (VOID
**) &AbsolutePointer
1179 if (EFI_ERROR (Status
)) {
1184 // Add this devcie into Absolute Pointer devices list.
1186 return ConSplitterAbsolutePointerAddDevice (&mConIn
, AbsolutePointer
);
1191 Start Console Out Consplitter on device handle.
1193 @param This Driver Binding protocol instance pointer.
1194 @param ControllerHandle Handle of device to bind driver to.
1195 @param RemainingDevicePath Optional parameter use to pick a specific child
1198 @retval EFI_SUCCESS Console Out Consplitter is added to ControllerHandle.
1199 @retval other Console Out Consplitter does not support this device.
1204 ConSplitterConOutDriverBindingStart (
1205 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1206 IN EFI_HANDLE ControllerHandle
,
1207 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
1211 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
;
1212 EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
;
1213 EFI_UGA_DRAW_PROTOCOL
*UgaDraw
;
1215 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*Info
;
1218 // Start ConSplitter on ControllerHandle, and create the virtual
1219 // agrogated console device on first call Start for a ConsoleOut handle.
1221 Status
= ConSplitterStart (
1224 mConOut
.VirtualHandle
,
1225 &gEfiConsoleOutDeviceGuid
,
1226 &gEfiSimpleTextOutProtocolGuid
,
1229 if (EFI_ERROR (Status
)) {
1233 GraphicsOutput
= NULL
;
1236 // Try to Open Graphics Output protocol
1238 Status
= gBS
->OpenProtocol (
1240 &gEfiGraphicsOutputProtocolGuid
,
1241 (VOID
**) &GraphicsOutput
,
1242 This
->DriverBindingHandle
,
1243 mConOut
.VirtualHandle
,
1244 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1247 if (EFI_ERROR (Status
) && FeaturePcdGet (PcdUgaConsumeSupport
)) {
1249 // Open UGA DRAW protocol
1253 &gEfiUgaDrawProtocolGuid
,
1255 This
->DriverBindingHandle
,
1256 mConOut
.VirtualHandle
,
1257 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1262 // When new console device is added, the new mode will be set later,
1263 // so put current mode back to init state.
1265 mConOut
.TextOutMode
.Mode
= 0xFF;
1268 // If both ConOut and StdErr incorporate the same Text Out device,
1269 // their MaxMode and QueryData should be the intersection of both.
1271 Status
= ConSplitterTextOutAddDevice (&mConOut
, TextOut
, GraphicsOutput
, UgaDraw
);
1272 ConSplitterTextOutSetAttribute (&mConOut
.TextOut
, EFI_TEXT_ATTR (EFI_LIGHTGRAY
, EFI_BLACK
));
1274 if (FeaturePcdGet (PcdConOutUgaSupport
)) {
1276 // Get the UGA mode data of ConOut from the current mode
1278 if (GraphicsOutput
!= NULL
) {
1279 Status
= GraphicsOutput
->QueryMode (GraphicsOutput
, GraphicsOutput
->Mode
->Mode
, &SizeOfInfo
, &Info
);
1280 if (EFI_ERROR (Status
)) {
1283 ASSERT ( SizeOfInfo
<= sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
));
1285 mConOut
.UgaHorizontalResolution
= Info
->HorizontalResolution
;
1286 mConOut
.UgaVerticalResolution
= Info
->VerticalResolution
;
1287 mConOut
.UgaColorDepth
= 32;
1288 mConOut
.UgaRefreshRate
= 60;
1292 } else if (UgaDraw
!= NULL
&& FeaturePcdGet (PcdUgaConsumeSupport
)) {
1293 Status
= UgaDraw
->GetMode (
1295 &mConOut
.UgaHorizontalResolution
,
1296 &mConOut
.UgaVerticalResolution
,
1297 &mConOut
.UgaColorDepth
,
1298 &mConOut
.UgaRefreshRate
1308 Start Standard Error Consplitter on device handle.
1310 @param This Driver Binding protocol instance pointer.
1311 @param ControllerHandle Handle of device to bind driver to.
1312 @param RemainingDevicePath Optional parameter use to pick a specific child
1315 @retval EFI_SUCCESS Standard Error Consplitter is added to ControllerHandle.
1316 @retval other Standard Error Consplitter does not support this device.
1321 ConSplitterStdErrDriverBindingStart (
1322 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1323 IN EFI_HANDLE ControllerHandle
,
1324 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
1328 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
;
1331 // Start ConSplitter on ControllerHandle, and create the virtual
1332 // agrogated console device on first call Start for a StandardError handle.
1334 Status
= ConSplitterStart (
1337 mStdErr
.VirtualHandle
,
1338 &gEfiStandardErrorDeviceGuid
,
1339 &gEfiSimpleTextOutProtocolGuid
,
1342 if (EFI_ERROR (Status
)) {
1347 // When new console device is added, the new mode will be set later,
1348 // so put current mode back to init state.
1350 mStdErr
.TextOutMode
.Mode
= 0xFF;
1353 // If both ConOut and StdErr incorporate the same Text Out device,
1354 // their MaxMode and QueryData should be the intersection of both.
1356 Status
= ConSplitterTextOutAddDevice (&mStdErr
, TextOut
, NULL
, NULL
);
1357 ConSplitterTextOutSetAttribute (&mStdErr
.TextOut
, EFI_TEXT_ATTR (EFI_MAGENTA
, EFI_BLACK
));
1358 if (EFI_ERROR (Status
)) {
1362 if (mStdErr
.CurrentNumberOfConsoles
== 1) {
1363 gST
->StandardErrorHandle
= mStdErr
.VirtualHandle
;
1364 gST
->StdErr
= &mStdErr
.TextOut
;
1366 // Update the CRC32 in the EFI System Table header
1369 gBS
->CalculateCrc32 (
1370 (UINT8
*) &gST
->Hdr
,
1371 gST
->Hdr
.HeaderSize
,
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 Status
= ConSplitterTextOutDeleteDevice (&mStdErr
, TextOut
);
1713 if (EFI_ERROR (Status
)) {
1717 if (mStdErr
.CurrentNumberOfConsoles
== 0) {
1718 gST
->StandardErrorHandle
= NULL
;
1721 // Update the CRC32 in the EFI System Table header
1724 gBS
->CalculateCrc32 (
1725 (UINT8
*) &gST
->Hdr
,
1726 gST
->Hdr
.HeaderSize
,
1736 Take the passed in Buffer of size SizeOfCount and grow the buffer
1737 by MAX (CONSOLE_SPLITTER_CONSOLES_ALLOC_UNIT, MaxGrow) * SizeOfCount
1738 bytes. Copy the current data in Buffer to the new version of Buffer
1739 and free the old version of buffer.
1741 @param SizeOfCount Size of element in array.
1742 @param Count Current number of elements in array.
1743 @param Buffer Bigger version of passed in Buffer with all the
1746 @retval EFI_SUCCESS Buffer size has grown.
1747 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
1751 ConSplitterGrowBuffer (
1752 IN UINTN SizeOfCount
,
1754 IN OUT VOID
**Buffer
1760 // grow the buffer to new buffer size,
1761 // copy the old buffer's content to the new-size buffer,
1762 // then free the old buffer.
1764 *Count
+= CONSOLE_SPLITTER_CONSOLES_ALLOC_UNIT
;
1765 Ptr
= ReallocatePool (
1766 SizeOfCount
* ((*Count
) - CONSOLE_SPLITTER_CONSOLES_ALLOC_UNIT
),
1767 SizeOfCount
* (*Count
),
1771 return EFI_OUT_OF_RESOURCES
;
1779 Add Text Input Device in Consplitter Text Input list.
1781 @param Private Text In Splitter pointer.
1782 @param TextIn Simple Text Input protocol pointer.
1784 @retval EFI_SUCCESS Text Input Device added successfully.
1785 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
1789 ConSplitterTextInAddDevice (
1790 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
1791 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*TextIn
1797 // If the Text In List is full, enlarge it by calling ConSplitterGrowBuffer().
1799 if (Private
->CurrentNumberOfConsoles
>= Private
->TextInListCount
) {
1800 Status
= ConSplitterGrowBuffer (
1801 sizeof (EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*),
1802 &Private
->TextInListCount
,
1803 (VOID
**) &Private
->TextInList
1805 if (EFI_ERROR (Status
)) {
1806 return EFI_OUT_OF_RESOURCES
;
1810 // Add the new text-in device data structure into the Text In List.
1812 Private
->TextInList
[Private
->CurrentNumberOfConsoles
] = TextIn
;
1813 Private
->CurrentNumberOfConsoles
++;
1816 // Extra CheckEvent added to reduce the double CheckEvent().
1818 gBS
->CheckEvent (TextIn
->WaitForKey
);
1825 Remove Text Input Device from Consplitter Text Input list.
1827 @param Private Text In Splitter pointer.
1828 @param TextIn Simple Text protocol pointer.
1830 @retval EFI_SUCCESS Simple Text Device removed successfully.
1831 @retval EFI_NOT_FOUND No Simple Text Device found.
1835 ConSplitterTextInDeleteDevice (
1836 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
1837 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*TextIn
1842 // Remove the specified text-in device data structure from the Text In List,
1843 // and rearrange the remaining data structures in the Text In List.
1845 for (Index
= 0; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
1846 if (Private
->TextInList
[Index
] == TextIn
) {
1847 for (Index
= Index
; Index
< Private
->CurrentNumberOfConsoles
- 1; Index
++) {
1848 Private
->TextInList
[Index
] = Private
->TextInList
[Index
+ 1];
1851 Private
->CurrentNumberOfConsoles
--;
1856 return EFI_NOT_FOUND
;
1860 Add Text Input Ex Device in Consplitter Text Input Ex list.
1862 @param Private Text In Splitter pointer.
1863 @param TextInEx Simple Text Input Ex Input protocol pointer.
1865 @retval EFI_SUCCESS Text Input Ex Device added successfully.
1866 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
1870 ConSplitterTextInExAddDevice (
1871 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
1872 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*TextInEx
1878 // If the Text Input Ex List is full, enlarge it by calling ConSplitterGrowBuffer().
1880 if (Private
->CurrentNumberOfExConsoles
>= Private
->TextInExListCount
) {
1881 Status
= ConSplitterGrowBuffer (
1882 sizeof (EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*),
1883 &Private
->TextInExListCount
,
1884 (VOID
**) &Private
->TextInExList
1886 if (EFI_ERROR (Status
)) {
1887 return EFI_OUT_OF_RESOURCES
;
1891 // Add the new text-in device data structure into the Text Input Ex List.
1893 Private
->TextInExList
[Private
->CurrentNumberOfExConsoles
] = TextInEx
;
1894 Private
->CurrentNumberOfExConsoles
++;
1897 // Extra CheckEvent added to reduce the double CheckEvent().
1899 gBS
->CheckEvent (TextInEx
->WaitForKeyEx
);
1905 Remove Text Ex Device from Consplitter Text Input Ex list.
1907 @param Private Text In Splitter pointer.
1908 @param TextInEx Simple Text Ex protocol pointer.
1910 @retval EFI_SUCCESS Simple Text Input Ex Device removed successfully.
1911 @retval EFI_NOT_FOUND No Simple Text Input Ex Device found.
1915 ConSplitterTextInExDeleteDevice (
1916 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
1917 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*TextInEx
1922 // Remove the specified text-in device data structure from the Text Input Ex List,
1923 // and rearrange the remaining data structures in the Text In List.
1925 for (Index
= 0; Index
< Private
->CurrentNumberOfExConsoles
; Index
++) {
1926 if (Private
->TextInExList
[Index
] == TextInEx
) {
1927 for (Index
= Index
; Index
< Private
->CurrentNumberOfExConsoles
- 1; Index
++) {
1928 Private
->TextInExList
[Index
] = Private
->TextInExList
[Index
+ 1];
1931 Private
->CurrentNumberOfExConsoles
--;
1936 return EFI_NOT_FOUND
;
1941 Add Simple Pointer Device in Consplitter Simple Pointer list.
1943 @param Private Text In Splitter pointer.
1944 @param SimplePointer Simple Pointer protocol pointer.
1946 @retval EFI_SUCCESS Simple Pointer Device added successfully.
1947 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
1951 ConSplitterSimplePointerAddDevice (
1952 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
1953 IN EFI_SIMPLE_POINTER_PROTOCOL
*SimplePointer
1959 // If the Simple Pointer List is full, enlarge it by calling ConSplitterGrowBuffer().
1961 if (Private
->CurrentNumberOfPointers
>= Private
->PointerListCount
) {
1962 Status
= ConSplitterGrowBuffer (
1963 sizeof (EFI_SIMPLE_POINTER_PROTOCOL
*),
1964 &Private
->PointerListCount
,
1965 (VOID
**) &Private
->PointerList
1967 if (EFI_ERROR (Status
)) {
1968 return EFI_OUT_OF_RESOURCES
;
1972 // Add the new text-in device data structure into the Simple Pointer List.
1974 Private
->PointerList
[Private
->CurrentNumberOfPointers
] = SimplePointer
;
1975 Private
->CurrentNumberOfPointers
++;
1982 Remove Simple Pointer Device from Consplitter Simple Pointer list.
1984 @param Private Text In Splitter pointer.
1985 @param SimplePointer Simple Pointer protocol pointer.
1987 @retval EFI_SUCCESS Simple Pointer Device removed successfully.
1988 @retval EFI_NOT_FOUND No Simple Pointer Device found.
1992 ConSplitterSimplePointerDeleteDevice (
1993 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
1994 IN EFI_SIMPLE_POINTER_PROTOCOL
*SimplePointer
1999 // Remove the specified text-in device data structure from the Simple Pointer List,
2000 // and rearrange the remaining data structures in the Text In List.
2002 for (Index
= 0; Index
< Private
->CurrentNumberOfPointers
; Index
++) {
2003 if (Private
->PointerList
[Index
] == SimplePointer
) {
2004 for (Index
= Index
; Index
< Private
->CurrentNumberOfPointers
- 1; Index
++) {
2005 Private
->PointerList
[Index
] = Private
->PointerList
[Index
+ 1];
2008 Private
->CurrentNumberOfPointers
--;
2013 return EFI_NOT_FOUND
;
2018 Add Absolute Pointer Device in Consplitter Absolute Pointer list.
2020 @param Private Text In Splitter pointer.
2021 @param AbsolutePointer Absolute Pointer protocol pointer.
2023 @retval EFI_SUCCESS Absolute Pointer Device added successfully.
2024 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
2028 ConSplitterAbsolutePointerAddDevice (
2029 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
2030 IN EFI_ABSOLUTE_POINTER_PROTOCOL
*AbsolutePointer
2036 // If the Absolute Pointer List is full, enlarge it by calling ConSplitterGrowBuffer().
2038 if (Private
->CurrentNumberOfAbsolutePointers
>= Private
->AbsolutePointerListCount
) {
2039 Status
= ConSplitterGrowBuffer (
2040 sizeof (EFI_ABSOLUTE_POINTER_PROTOCOL
*),
2041 &Private
->AbsolutePointerListCount
,
2042 (VOID
**) &Private
->AbsolutePointerList
2044 if (EFI_ERROR (Status
)) {
2045 return EFI_OUT_OF_RESOURCES
;
2049 // Add the new text-in device data structure into the Absolute Pointer List.
2051 Private
->AbsolutePointerList
[Private
->CurrentNumberOfAbsolutePointers
] = AbsolutePointer
;
2052 Private
->CurrentNumberOfAbsolutePointers
++;
2059 Remove Absolute Pointer Device from Consplitter Absolute Pointer list.
2061 @param Private Text In Splitter pointer.
2062 @param AbsolutePointer Absolute Pointer protocol pointer.
2064 @retval EFI_SUCCESS Absolute Pointer Device removed successfully.
2065 @retval EFI_NOT_FOUND No Absolute Pointer Device found.
2069 ConSplitterAbsolutePointerDeleteDevice (
2070 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
2071 IN EFI_ABSOLUTE_POINTER_PROTOCOL
*AbsolutePointer
2076 // Remove the specified text-in device data structure from the Absolute Pointer List,
2077 // and rearrange the remaining data structures from the Absolute Pointer List.
2079 for (Index
= 0; Index
< Private
->CurrentNumberOfAbsolutePointers
; Index
++) {
2080 if (Private
->AbsolutePointerList
[Index
] == AbsolutePointer
) {
2081 for (Index
= Index
; Index
< Private
->CurrentNumberOfAbsolutePointers
- 1; Index
++) {
2082 Private
->AbsolutePointerList
[Index
] = Private
->AbsolutePointerList
[Index
+ 1];
2085 Private
->CurrentNumberOfAbsolutePointers
--;
2090 return EFI_NOT_FOUND
;
2094 Reallocate Text Out mode map.
2096 Allocate new buffer and copy original buffer into the new buffer.
2098 @param Private Consplitter Text Out pointer.
2100 @retval EFI_SUCCESS Buffer size has grown
2101 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
2105 ConSplitterGrowMapTable (
2106 IN TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
2112 INT32
*TextOutModeMap
;
2113 INT32
*OldTextOutModeMap
;
2117 NewSize
= Private
->TextOutListCount
* sizeof (INT32
);
2118 OldTextOutModeMap
= Private
->TextOutModeMap
;
2119 TotalSize
= NewSize
* (Private
->TextOutQueryDataCount
);
2122 // Allocate new buffer for Text Out List.
2124 TextOutModeMap
= AllocatePool (TotalSize
);
2125 if (TextOutModeMap
== NULL
) {
2126 return EFI_OUT_OF_RESOURCES
;
2129 SetMem (TextOutModeMap
, TotalSize
, 0xFF);
2130 Private
->TextOutModeMap
= TextOutModeMap
;
2133 // If TextOutList has been enlarged, need to realloc the mode map table
2134 // The mode map table is regarded as a two dimension array.
2137 // 0 ---------> TextOutListCount ----> TextOutListCount
2138 // | -------------------------------------------
2145 // -------------------------------------------
2148 if (OldTextOutModeMap
!= NULL
) {
2150 Size
= Private
->CurrentNumberOfConsoles
* sizeof (INT32
);
2152 SrcAddress
= OldTextOutModeMap
;
2155 // Copy the old data to the new one
2157 while (Index
< Private
->TextOutMode
.MaxMode
) {
2158 CopyMem (TextOutModeMap
, SrcAddress
, Size
);
2159 TextOutModeMap
+= NewSize
;
2164 // Free the old buffer
2166 FreePool (OldTextOutModeMap
);
2174 Add new device's output mode to console splitter's mode list.
2176 @param Private Text Out Splitter pointer
2177 @param TextOut Simple Text Output protocol pointer.
2179 @retval EFI_SUCCESS Device added successfully.
2180 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
2184 ConSplitterAddOutputMode (
2185 IN TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
,
2186 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
2194 MaxMode
= TextOut
->Mode
->MaxMode
;
2195 Private
->TextOutMode
.MaxMode
= MaxMode
;
2198 // Grow the buffer if query data buffer is not large enough to
2199 // hold all the mode supported by the first console.
2201 while (MaxMode
> (INT32
) Private
->TextOutQueryDataCount
) {
2202 Status
= ConSplitterGrowBuffer (
2203 sizeof (TEXT_OUT_SPLITTER_QUERY_DATA
),
2204 &Private
->TextOutQueryDataCount
,
2205 (VOID
**) &Private
->TextOutQueryData
2207 if (EFI_ERROR (Status
)) {
2208 return EFI_OUT_OF_RESOURCES
;
2212 // Allocate buffer for the output mode map
2214 Status
= ConSplitterGrowMapTable (Private
);
2215 if (EFI_ERROR (Status
)) {
2216 return EFI_OUT_OF_RESOURCES
;
2219 // As the first textout device, directly add the mode in to QueryData
2220 // and at the same time record the mapping between QueryData and TextOut.
2224 while (Mode
< MaxMode
) {
2225 Status
= TextOut
->QueryMode (
2228 &Private
->TextOutQueryData
[Mode
].Columns
,
2229 &Private
->TextOutQueryData
[Mode
].Rows
2232 // If mode 1 (80x50) is not supported, make sure mode 1 in TextOutQueryData
2235 if ((EFI_ERROR(Status
)) && (Mode
== 1)) {
2236 Private
->TextOutQueryData
[Mode
].Columns
= 0;
2237 Private
->TextOutQueryData
[Mode
].Rows
= 0;
2239 Private
->TextOutModeMap
[Index
] = Mode
;
2241 Index
+= Private
->TextOutListCount
;
2248 Reconstruct TextOutModeMap to get intersection of modes.
2250 This routine reconstruct TextOutModeMap to get the intersection
2251 of modes for all console out devices. Because EFI/UEFI spec require
2252 mode 0 is 80x25, mode 1 is 80x50, this routine will not check the
2253 intersection for mode 0 and mode 1.
2255 @param TextOutModeMap Current text out mode map, begin with the mode 80x25
2256 @param NewlyAddedMap New text out mode map, begin with the mode 80x25
2257 @param MapStepSize Mode step size for one console device
2258 @param NewMapStepSize New Mode step size for one console device
2259 @param MaxMode IN: Current max text mode, OUT: Updated max text mode.
2260 @param CurrentMode IN: Current text mode, OUT: Updated current text mode.
2264 ConSplitterGetIntersection (
2265 IN INT32
*TextOutModeMap
,
2266 IN INT32
*NewlyAddedMap
,
2267 IN UINTN MapStepSize
,
2268 IN UINTN NewMapStepSize
,
2269 IN OUT INT32
*MaxMode
,
2270 IN OUT INT32
*CurrentMode
2274 INT32
*CurrentMapEntry
;
2275 INT32
*NextMapEntry
;
2277 INT32 CurrentMaxMode
;
2281 // According to EFI/UEFI spec, mode 0 and mode 1 have been reserved
2282 // for 80x25 and 80x50 in Simple Text Out protocol, so don't make intersection
2283 // for mode 0 and mode 1, mode number starts from 2.
2286 CurrentMapEntry
= &TextOutModeMap
[MapStepSize
* 2];
2287 NextMapEntry
= CurrentMapEntry
;
2288 NewMapEntry
= &NewlyAddedMap
[NewMapStepSize
* 2];
2290 CurrentMaxMode
= *MaxMode
;
2291 Mode
= *CurrentMode
;
2293 while (Index
< CurrentMaxMode
) {
2294 if (*NewMapEntry
== -1) {
2296 // This mode is not supported any more. Remove it. Special care
2297 // must be taken as this remove will also affect current mode;
2299 if (Index
== *CurrentMode
) {
2301 } else if (Index
< *CurrentMode
) {
2306 if (CurrentMapEntry
!= NextMapEntry
) {
2307 CopyMem (NextMapEntry
, CurrentMapEntry
, MapStepSize
* sizeof (INT32
));
2310 NextMapEntry
+= MapStepSize
;
2313 CurrentMapEntry
+= MapStepSize
;
2314 NewMapEntry
+= NewMapStepSize
;
2318 *CurrentMode
= Mode
;
2324 Sync the device's output mode to console splitter's mode list.
2326 @param Private Text Out Splitter pointer.
2327 @param TextOut Simple Text Output protocol pointer.
2331 ConSplitterSyncOutputMode (
2332 IN TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
,
2333 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
2336 INT32 CurrentMaxMode
;
2339 INT32
*TextOutModeMap
;
2342 TEXT_OUT_SPLITTER_QUERY_DATA
*TextOutQueryData
;
2349 // Must make sure that current mode won't change even if mode number changes
2351 CurrentMaxMode
= Private
->TextOutMode
.MaxMode
;
2352 TextOutModeMap
= Private
->TextOutModeMap
;
2353 StepSize
= Private
->TextOutListCount
;
2354 TextOutQueryData
= Private
->TextOutQueryData
;
2357 // Query all the mode that the newly added TextOut supports
2360 MapTable
= TextOutModeMap
+ Private
->CurrentNumberOfConsoles
;
2361 while (Mode
< TextOut
->Mode
->MaxMode
) {
2362 Status
= TextOut
->QueryMode (TextOut
, Mode
, &Columns
, &Rows
);
2364 if (EFI_ERROR(Status
)) {
2367 // If mode 1 (80x50) is not supported, make sure mode 1 in TextOutQueryData
2370 MapTable
[StepSize
] = Mode
;
2371 TextOutQueryData
[Mode
].Columns
= 0;
2372 TextOutQueryData
[Mode
].Rows
= 0;
2378 // Search the intersection map and QueryData database to see if they intersects
2381 while (Index
< CurrentMaxMode
) {
2382 QueryMode
= *(TextOutModeMap
+ Index
* StepSize
);
2383 if ((TextOutQueryData
[QueryMode
].Rows
== Rows
) && (TextOutQueryData
[QueryMode
].Columns
== Columns
)) {
2384 MapTable
[Index
* StepSize
] = Mode
;
2392 // Now search the TextOutModeMap table to find the intersection of supported
2393 // mode between ConSplitter and the newly added device.
2395 ConSplitterGetIntersection (
2400 &Private
->TextOutMode
.MaxMode
,
2401 &Private
->TextOutMode
.Mode
2409 Sync output device between ConOut and StdErr output.
2411 @retval EFI_SUCCESS Sync implemented successfully.
2412 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
2416 ConSplitterGetIntersectionBetweenConOutAndStrErr (
2420 UINTN ConOutNumOfConsoles
;
2421 UINTN StdErrNumOfConsoles
;
2422 TEXT_OUT_AND_GOP_DATA
*ConOutTextOutList
;
2423 TEXT_OUT_AND_GOP_DATA
*StdErrTextOutList
;
2427 UINTN ConOutColumns
;
2429 UINTN StdErrColumns
;
2430 INT32 ConOutMaxMode
;
2431 INT32 StdErrMaxMode
;
2436 INT32
*ConOutModeMap
;
2437 INT32
*StdErrModeMap
;
2438 INT32
*ConOutMapTable
;
2439 INT32
*StdErrMapTable
;
2440 TEXT_OUT_SPLITTER_QUERY_DATA
*ConOutQueryData
;
2441 TEXT_OUT_SPLITTER_QUERY_DATA
*StdErrQueryData
;
2442 UINTN ConOutStepSize
;
2443 UINTN StdErrStepSize
;
2444 BOOLEAN FoundTheSameTextOut
;
2445 UINTN ConOutMapTableSize
;
2446 UINTN StdErrMapTableSize
;
2448 ConOutNumOfConsoles
= mConOut
.CurrentNumberOfConsoles
;
2449 StdErrNumOfConsoles
= mStdErr
.CurrentNumberOfConsoles
;
2450 ConOutTextOutList
= mConOut
.TextOutList
;
2451 StdErrTextOutList
= mStdErr
.TextOutList
;
2454 FoundTheSameTextOut
= FALSE
;
2455 while ((Indexi
< ConOutNumOfConsoles
) && (!FoundTheSameTextOut
)) {
2457 while (Indexj
< StdErrNumOfConsoles
) {
2458 if (ConOutTextOutList
->TextOut
== StdErrTextOutList
->TextOut
) {
2459 FoundTheSameTextOut
= TRUE
;
2464 StdErrTextOutList
++;
2468 ConOutTextOutList
++;
2471 if (!FoundTheSameTextOut
) {
2475 // Must make sure that current mode won't change even if mode number changes
2477 ConOutMaxMode
= mConOut
.TextOutMode
.MaxMode
;
2478 ConOutModeMap
= mConOut
.TextOutModeMap
;
2479 ConOutStepSize
= mConOut
.TextOutListCount
;
2480 ConOutQueryData
= mConOut
.TextOutQueryData
;
2482 StdErrMaxMode
= mStdErr
.TextOutMode
.MaxMode
;
2483 StdErrModeMap
= mStdErr
.TextOutModeMap
;
2484 StdErrStepSize
= mStdErr
.TextOutListCount
;
2485 StdErrQueryData
= mStdErr
.TextOutQueryData
;
2488 // Allocate the map table and set the map table's index to -1.
2490 ConOutMapTableSize
= ConOutMaxMode
* sizeof (INT32
);
2491 ConOutMapTable
= AllocateZeroPool (ConOutMapTableSize
);
2492 if (ConOutMapTable
== NULL
) {
2493 return EFI_OUT_OF_RESOURCES
;
2496 SetMem (ConOutMapTable
, ConOutMapTableSize
, 0xFF);
2498 StdErrMapTableSize
= StdErrMaxMode
* sizeof (INT32
);
2499 StdErrMapTable
= AllocateZeroPool (StdErrMapTableSize
);
2500 if (StdErrMapTable
== NULL
) {
2501 return EFI_OUT_OF_RESOURCES
;
2504 SetMem (StdErrMapTable
, StdErrMapTableSize
, 0xFF);
2507 // Find the intersection of the two set of modes. If they actually intersect, the
2508 // correponding entry in the map table is set to 1.
2511 while (Mode
< ConOutMaxMode
) {
2513 // Search the intersection map and QueryData database to see if they intersect
2516 ConOutMode
= *(ConOutModeMap
+ Mode
* ConOutStepSize
);
2517 ConOutRows
= ConOutQueryData
[ConOutMode
].Rows
;
2518 ConOutColumns
= ConOutQueryData
[ConOutMode
].Columns
;
2519 while (Index
< StdErrMaxMode
) {
2520 StdErrMode
= *(StdErrModeMap
+ Index
* StdErrStepSize
);
2521 StdErrRows
= StdErrQueryData
[StdErrMode
].Rows
;
2522 StdErrColumns
= StdErrQueryData
[StdErrMode
].Columns
;
2523 if ((StdErrRows
== ConOutRows
) && (StdErrColumns
== ConOutColumns
)) {
2524 ConOutMapTable
[Mode
] = 1;
2525 StdErrMapTable
[Index
] = 1;
2535 // Now search the TextOutModeMap table to find the intersection of supported
2536 // mode between ConSplitter and the newly added device.
2538 ConSplitterGetIntersection (
2541 mConOut
.TextOutListCount
,
2543 &(mConOut
.TextOutMode
.MaxMode
),
2544 &(mConOut
.TextOutMode
.Mode
)
2547 if (mConOut
.TextOutMode
.Mode
< 0) {
2548 mConOut
.TextOut
.SetMode (&(mConOut
.TextOut
), 0);
2551 ConSplitterGetIntersection (
2554 mStdErr
.TextOutListCount
,
2556 &(mStdErr
.TextOutMode
.MaxMode
),
2557 &(mStdErr
.TextOutMode
.Mode
)
2560 if (mStdErr
.TextOutMode
.Mode
< 0) {
2561 mStdErr
.TextOut
.SetMode (&(mStdErr
.TextOut
), 0);
2564 FreePool (ConOutMapTable
);
2565 FreePool (StdErrMapTable
);
2572 Add Grahpics Output modes into Consplitter Text Out list.
2574 @param Private Text Out Splitter pointer.
2575 @param GraphicsOutput Graphics Output protocol pointer.
2576 @param UgaDraw UGA Draw protocol pointer.
2578 @retval EFI_SUCCESS Output mode added successfully.
2579 @retval other Failed to add output mode.
2583 ConSplitterAddGraphicsOutputMode (
2584 IN TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
,
2585 IN EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
,
2586 IN EFI_UGA_DRAW_PROTOCOL
*UgaDraw
2592 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*Mode
;
2594 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*Info
;
2595 EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE
*CurrentGraphicsOutputMode
;
2596 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*ModeBuffer
;
2597 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*MatchedMode
;
2600 BOOLEAN AlreadyExist
;
2601 UINT32 UgaHorizontalResolution
;
2602 UINT32 UgaVerticalResolution
;
2603 UINT32 UgaColorDepth
;
2604 UINT32 UgaRefreshRate
;
2606 ASSERT (GraphicsOutput
!= NULL
|| UgaDraw
!= NULL
);
2608 CurrentGraphicsOutputMode
= Private
->GraphicsOutput
.Mode
;
2613 if (Private
->CurrentNumberOfUgaDraw
!= 0) {
2615 // If any UGA device has already been added, then there is no need to
2616 // calculate intersection of display mode of different GOP/UGA device,
2617 // since only one display mode will be exported (i.e. user-defined mode)
2622 if (GraphicsOutput
!= NULL
) {
2623 if (Private
->CurrentNumberOfGraphicsOutput
== 0) {
2625 // This is the first Graphics Output device added
2627 CurrentGraphicsOutputMode
->MaxMode
= GraphicsOutput
->Mode
->MaxMode
;
2628 CurrentGraphicsOutputMode
->Mode
= GraphicsOutput
->Mode
->Mode
;
2629 CopyMem (CurrentGraphicsOutputMode
->Info
, GraphicsOutput
->Mode
->Info
, GraphicsOutput
->Mode
->SizeOfInfo
);
2630 CurrentGraphicsOutputMode
->SizeOfInfo
= GraphicsOutput
->Mode
->SizeOfInfo
;
2631 CurrentGraphicsOutputMode
->FrameBufferBase
= GraphicsOutput
->Mode
->FrameBufferBase
;
2632 CurrentGraphicsOutputMode
->FrameBufferSize
= GraphicsOutput
->Mode
->FrameBufferSize
;
2635 // Allocate resource for the private mode buffer
2637 ModeBuffer
= AllocatePool (sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
) * GraphicsOutput
->Mode
->MaxMode
);
2638 if (ModeBuffer
== NULL
) {
2639 return EFI_OUT_OF_RESOURCES
;
2641 FreePool (Private
->GraphicsOutputModeBuffer
);
2642 Private
->GraphicsOutputModeBuffer
= ModeBuffer
;
2645 // Store all supported display modes to the private mode buffer
2648 for (Index
= 0; Index
< GraphicsOutput
->Mode
->MaxMode
; Index
++) {
2650 // The Info buffer would be allocated by callee
2652 Status
= GraphicsOutput
->QueryMode (GraphicsOutput
, (UINT32
) Index
, &SizeOfInfo
, &Info
);
2653 if (EFI_ERROR (Status
)) {
2656 ASSERT ( SizeOfInfo
<= sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
));
2657 CopyMem (Mode
, Info
, SizeOfInfo
);
2663 // Check intersection of display mode
2665 ModeBuffer
= AllocatePool (sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
) * CurrentGraphicsOutputMode
->MaxMode
);
2666 if (ModeBuffer
== NULL
) {
2667 return EFI_OUT_OF_RESOURCES
;
2670 MatchedMode
= ModeBuffer
;
2671 Mode
= &Private
->GraphicsOutputModeBuffer
[0];
2672 for (Index
= 0; Index
< CurrentGraphicsOutputMode
->MaxMode
; Index
++) {
2675 for (NumberIndex
= 0; NumberIndex
< GraphicsOutput
->Mode
->MaxMode
; NumberIndex
++) {
2677 // The Info buffer would be allocated by callee
2679 Status
= GraphicsOutput
->QueryMode (GraphicsOutput
, (UINT32
) NumberIndex
, &SizeOfInfo
, &Info
);
2680 if (EFI_ERROR (Status
)) {
2683 if ((Info
->HorizontalResolution
== Mode
->HorizontalResolution
) &&
2684 (Info
->VerticalResolution
== Mode
->VerticalResolution
)) {
2686 // If GOP device supports one mode in current mode buffer,
2687 // it will be added into matched mode buffer
2697 AlreadyExist
= FALSE
;
2700 // Check if GOP mode has been in the mode buffer, ModeBuffer = MatchedMode at begin.
2702 for (Info
= ModeBuffer
; Info
< MatchedMode
; Info
++) {
2703 if ((Info
->HorizontalResolution
== Mode
->HorizontalResolution
) &&
2704 (Info
->VerticalResolution
== Mode
->VerticalResolution
)) {
2705 AlreadyExist
= TRUE
;
2710 if (!AlreadyExist
) {
2711 CopyMem (MatchedMode
, Mode
, sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
));
2714 // Physical frame buffer is no longer available, change PixelFormat to PixelBltOnly
2716 MatchedMode
->Version
= 0;
2717 MatchedMode
->PixelFormat
= PixelBltOnly
;
2718 ZeroMem (&MatchedMode
->PixelInformation
, sizeof (EFI_PIXEL_BITMASK
));
2728 // Drop the old mode buffer, assign it to a new one
2730 FreePool (Private
->GraphicsOutputModeBuffer
);
2731 Private
->GraphicsOutputModeBuffer
= ModeBuffer
;
2734 // Physical frame buffer is no longer available when there are more than one physical GOP devices
2736 CurrentGraphicsOutputMode
->MaxMode
= (UINT32
) (((UINTN
) MatchedMode
- (UINTN
) ModeBuffer
) / sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
));
2737 CurrentGraphicsOutputMode
->Info
->PixelFormat
= PixelBltOnly
;
2738 ZeroMem (&CurrentGraphicsOutputMode
->Info
->PixelInformation
, sizeof (EFI_PIXEL_BITMASK
));
2739 CurrentGraphicsOutputMode
->SizeOfInfo
= sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
);
2740 CurrentGraphicsOutputMode
->FrameBufferBase
= (EFI_PHYSICAL_ADDRESS
) (UINTN
) NULL
;
2741 CurrentGraphicsOutputMode
->FrameBufferSize
= 0;
2745 // Graphics console driver can ensure the same mode for all GOP devices
2747 for (Index
= 0; Index
< CurrentGraphicsOutputMode
->MaxMode
; Index
++) {
2748 Mode
= &Private
->GraphicsOutputModeBuffer
[Index
];
2749 if ((Mode
->HorizontalResolution
== GraphicsOutput
->Mode
->Info
->HorizontalResolution
) &&
2750 (Mode
->VerticalResolution
== GraphicsOutput
->Mode
->Info
->VerticalResolution
)) {
2751 CurrentIndex
= Index
;
2755 if (Index
>= CurrentGraphicsOutputMode
->MaxMode
) {
2757 // if user defined mode is not found, set to default mode 800x600
2759 for (Index
= 0; Index
< CurrentGraphicsOutputMode
->MaxMode
; Index
++) {
2760 Mode
= &Private
->GraphicsOutputModeBuffer
[Index
];
2761 if ((Mode
->HorizontalResolution
== 800) && (Mode
->VerticalResolution
== 600)) {
2762 CurrentIndex
= Index
;
2767 } else if (UgaDraw
!= NULL
&& FeaturePcdGet (PcdUgaConsumeSupport
)) {
2769 // Graphics console driver can ensure the same mode for all GOP devices
2770 // so we can get the current mode from this video device
2774 &UgaHorizontalResolution
,
2775 &UgaVerticalResolution
,
2780 CurrentGraphicsOutputMode
->MaxMode
= 1;
2781 Info
= CurrentGraphicsOutputMode
->Info
;
2783 Info
->HorizontalResolution
= UgaHorizontalResolution
;
2784 Info
->VerticalResolution
= UgaVerticalResolution
;
2785 Info
->PixelFormat
= PixelBltOnly
;
2786 Info
->PixelsPerScanLine
= UgaHorizontalResolution
;
2787 CurrentGraphicsOutputMode
->SizeOfInfo
= sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
);
2788 CurrentGraphicsOutputMode
->FrameBufferBase
= (EFI_PHYSICAL_ADDRESS
) (UINTN
) NULL
;
2789 CurrentGraphicsOutputMode
->FrameBufferSize
= 0;
2792 // Update the private mode buffer
2794 CopyMem (&Private
->GraphicsOutputModeBuffer
[0], Info
, sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
));
2797 // Only mode 0 is available to be set
2804 if (GraphicsOutput
!= NULL
) {
2805 Private
->CurrentNumberOfGraphicsOutput
++;
2807 if (UgaDraw
!= NULL
&& FeaturePcdGet (PcdUgaConsumeSupport
)) {
2808 Private
->CurrentNumberOfUgaDraw
++;
2812 // Force GraphicsOutput mode to be set,
2813 // regardless whether the console is in EfiConsoleControlScreenGraphics or EfiConsoleControlScreenText mode
2815 Private
->HardwareNeedsStarting
= TRUE
;
2817 // Current mode number may need update now, so set it to an invalid mode number
2819 CurrentGraphicsOutputMode
->Mode
= 0xffff;
2821 // Graphics console can ensure all GOP devices have the same mode which can be taken as current mode.
2823 Status
= Private
->GraphicsOutput
.SetMode (&Private
->GraphicsOutput
, (UINT32
) CurrentIndex
);
2824 if (EFI_ERROR(Status
)) {
2826 // If user defined mode is not valid for display device, set to the default mode 800x600.
2828 (Private
->GraphicsOutputModeBuffer
[0]).HorizontalResolution
= 800;
2829 (Private
->GraphicsOutputModeBuffer
[0]).VerticalResolution
= 600;
2830 Status
= Private
->GraphicsOutput
.SetMode (&Private
->GraphicsOutput
, 0);
2837 Set the current console out mode.
2839 This routine will get the current console mode information (column, row)
2840 from ConsoleOutMode variable and set it; if the variable does not exist,
2841 set to user defined console mode.
2843 @param Private Consplitter Text Out pointer.
2847 ConsplitterSetConsoleOutMode (
2848 IN TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
2858 CONSOLE_OUT_MODE ModeInfo
;
2859 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
;
2863 TextOut
= &Private
->TextOut
;
2864 MaxMode
= (UINTN
) (TextOut
->Mode
->MaxMode
);
2866 ModeInfo
.Column
= PcdGet32 (PcdConOutColumn
);
2867 ModeInfo
.Row
= PcdGet32 (PcdConOutRow
);
2870 // To find the prefer mode and basic mode from Text Out mode list
2872 for (Mode
= 0; Mode
< MaxMode
; Mode
++) {
2873 Status
= TextOut
->QueryMode (TextOut
, Mode
, &Col
, &Row
);
2874 if (!EFI_ERROR(Status
)) {
2875 if (Col
== ModeInfo
.Column
&& Row
== ModeInfo
.Row
) {
2878 if (Col
== 80 && Row
== 25) {
2885 // Set prefer mode to Text Out devices.
2887 Status
= TextOut
->SetMode (TextOut
, PreferMode
);
2888 if (EFI_ERROR(Status
)) {
2890 // if current mode setting is failed, default 80x25 mode will be set.
2892 Status
= TextOut
->SetMode (TextOut
, BaseMode
);
2893 ASSERT(!EFI_ERROR(Status
));
2895 PcdSet32 (PcdConOutColumn
, 80);
2896 PcdSet32 (PcdConOutRow
, 25);
2904 Add Text Output Device in Consplitter Text Output list.
2906 @param Private Text Out Splitter pointer.
2907 @param TextOut Simple Text Output protocol pointer.
2908 @param GraphicsOutput Graphics Output protocol pointer.
2909 @param UgaDraw UGA Draw protocol pointer.
2911 @retval EFI_SUCCESS Text Output Device added successfully.
2912 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
2916 ConSplitterTextOutAddDevice (
2917 IN TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
,
2918 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
,
2919 IN EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
,
2920 IN EFI_UGA_DRAW_PROTOCOL
*UgaDraw
2924 UINTN CurrentNumOfConsoles
;
2926 UINT32 UgaHorizontalResolution
;
2927 UINT32 UgaVerticalResolution
;
2928 UINT32 UgaColorDepth
;
2929 UINT32 UgaRefreshRate
;
2930 TEXT_OUT_AND_GOP_DATA
*TextAndGop
;
2932 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*Info
;
2934 Status
= EFI_SUCCESS
;
2935 CurrentNumOfConsoles
= Private
->CurrentNumberOfConsoles
;
2938 // If the Text Out List is full, enlarge it by calling ConSplitterGrowBuffer().
2940 while (CurrentNumOfConsoles
>= Private
->TextOutListCount
) {
2941 Status
= ConSplitterGrowBuffer (
2942 sizeof (TEXT_OUT_AND_GOP_DATA
),
2943 &Private
->TextOutListCount
,
2944 (VOID
**) &Private
->TextOutList
2946 if (EFI_ERROR (Status
)) {
2947 return EFI_OUT_OF_RESOURCES
;
2950 // Also need to reallocate the TextOutModeMap table
2952 Status
= ConSplitterGrowMapTable (Private
);
2953 if (EFI_ERROR (Status
)) {
2954 return EFI_OUT_OF_RESOURCES
;
2958 TextAndGop
= &Private
->TextOutList
[CurrentNumOfConsoles
];
2960 TextAndGop
->TextOut
= TextOut
;
2961 TextAndGop
->GraphicsOutput
= GraphicsOutput
;
2962 TextAndGop
->UgaDraw
= UgaDraw
;
2964 if (CurrentNumOfConsoles
== 0) {
2966 // Add the first device's output mode to console splitter's mode list
2968 Status
= ConSplitterAddOutputMode (Private
, TextOut
);
2970 ConSplitterSyncOutputMode (Private
, TextOut
);
2973 Private
->CurrentNumberOfConsoles
++;
2976 // Scan both TextOutList, for the intersection TextOut device
2977 // maybe both ConOut and StdErr incorporate the same Text Out
2978 // device in them, thus the output of both should be synced.
2980 ConSplitterGetIntersectionBetweenConOutAndStrErr ();
2982 MaxMode
= Private
->TextOutMode
.MaxMode
;
2983 ASSERT (MaxMode
>= 1);
2985 if (FeaturePcdGet (PcdConOutGopSupport
)) {
2987 // If GOP is produced by Consplitter, this device display mode will be added into Graphics Ouput modes.
2989 if ((GraphicsOutput
!= NULL
) || (UgaDraw
!= NULL
&& FeaturePcdGet (PcdUgaConsumeSupport
))) {
2990 ConSplitterAddGraphicsOutputMode (Private
, GraphicsOutput
, UgaDraw
);
2994 if (FeaturePcdGet (PcdConOutUgaSupport
)) {
2995 UgaHorizontalResolution
= 800;
2996 UgaVerticalResolution
= 600;
2998 UgaRefreshRate
= 60;
3000 Status
= EFI_DEVICE_ERROR
;
3002 // If UGA is produced by Consplitter
3004 if (GraphicsOutput
!= NULL
) {
3005 Status
= GraphicsOutput
->QueryMode (GraphicsOutput
, GraphicsOutput
->Mode
->Mode
, &SizeOfInfo
, &Info
);
3006 if (EFI_ERROR (Status
)) {
3009 ASSERT ( SizeOfInfo
<= sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
));
3011 UgaHorizontalResolution
= Info
->HorizontalResolution
;
3012 UgaVerticalResolution
= Info
->VerticalResolution
;
3016 } else if (UgaDraw
!= NULL
&& FeaturePcdGet (PcdUgaConsumeSupport
)) {
3017 Status
= UgaDraw
->GetMode (
3019 &UgaHorizontalResolution
,
3020 &UgaVerticalResolution
,
3027 // Set UGA Draw mode,
3028 // if GetMode is failed, set to 800x600 mode
3030 Status
= ConSpliterUgaDrawSetMode (
3032 UgaHorizontalResolution
,
3033 UgaVerticalResolution
,
3040 // If ConOut, then set the mode to Mode #0 which us 80 x 25
3042 Private
->TextOut
.SetMode (&Private
->TextOut
, 0);
3045 // After adding new console device, all existing console devices should be
3046 // synced to the current shared mode.
3048 ConsplitterSetConsoleOutMode (Private
);
3055 Remove Text Out Device in Consplitter Text Out list.
3057 @param Private Text Out Splitter pointer.
3058 @param TextOut Simple Text Output Pointer protocol pointer.
3060 @retval EFI_SUCCESS Text Out Device removed successfully.
3061 @retval EFI_NOT_FOUND No Text Out Device found.
3065 ConSplitterTextOutDeleteDevice (
3066 IN TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
,
3067 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
3071 UINTN CurrentNumOfConsoles
;
3072 TEXT_OUT_AND_GOP_DATA
*TextOutList
;
3076 // Remove the specified text-out device data structure from the Text out List,
3077 // and rearrange the remaining data structures in the Text out List.
3079 CurrentNumOfConsoles
= Private
->CurrentNumberOfConsoles
;
3080 Index
= (INT32
) CurrentNumOfConsoles
- 1;
3081 TextOutList
= Private
->TextOutList
;
3082 while (Index
>= 0) {
3083 if (TextOutList
->TextOut
== TextOut
) {
3084 CopyMem (TextOutList
, TextOutList
+ 1, sizeof (TEXT_OUT_AND_GOP_DATA
) * Index
);
3085 CurrentNumOfConsoles
--;
3086 if (TextOutList
->UgaDraw
!= NULL
&& FeaturePcdGet (PcdUgaConsumeSupport
)) {
3087 Private
->CurrentNumberOfUgaDraw
--;
3089 if (TextOutList
->GraphicsOutput
!= NULL
) {
3090 Private
->CurrentNumberOfGraphicsOutput
--;
3099 // The specified TextOut is not managed by the ConSplitter driver
3102 return EFI_NOT_FOUND
;
3105 if (CurrentNumOfConsoles
== 0) {
3107 // If the number of consoles is zero, reset all parameters
3109 Private
->CurrentNumberOfConsoles
= 0;
3110 Private
->TextOutMode
.MaxMode
= 1;
3111 Private
->TextOutQueryData
[0].Columns
= 80;
3112 Private
->TextOutQueryData
[0].Rows
= 25;
3113 TextOutSetMode (Private
, 0);
3118 // Max Mode is realy an intersection of the QueryMode command to all
3119 // devices. So we must copy the QueryMode of the first device to
3123 Private
->TextOutQueryData
,
3124 Private
->TextOutQueryDataCount
* sizeof (TEXT_OUT_SPLITTER_QUERY_DATA
)
3127 FreePool (Private
->TextOutModeMap
);
3128 Private
->TextOutModeMap
= NULL
;
3129 TextOutList
= Private
->TextOutList
;
3132 // Add the first TextOut to the QueryData array and ModeMap table
3134 Status
= ConSplitterAddOutputMode (Private
, TextOutList
->TextOut
);
3137 // Now add one by one
3140 Private
->CurrentNumberOfConsoles
= 1;
3142 while ((UINTN
) Index
< CurrentNumOfConsoles
) {
3143 ConSplitterSyncOutputMode (Private
, TextOutList
->TextOut
);
3145 Private
->CurrentNumberOfConsoles
++;
3149 ConSplitterGetIntersectionBetweenConOutAndStrErr ();
3156 Reset the input device and optionaly run diagnostics
3158 @param This Protocol instance pointer.
3159 @param ExtendedVerification Driver may perform diagnostics on reset.
3161 @retval EFI_SUCCESS The device was reset.
3162 @retval EFI_DEVICE_ERROR The device is not functioning properly and could
3168 ConSplitterTextInReset (
3169 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*This
,
3170 IN BOOLEAN ExtendedVerification
3174 EFI_STATUS ReturnStatus
;
3175 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3178 Private
= TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
3180 Private
->KeyEventSignalState
= FALSE
;
3183 // return the worst status met
3185 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
3186 Status
= Private
->TextInList
[Index
]->Reset (
3187 Private
->TextInList
[Index
],
3188 ExtendedVerification
3190 if (EFI_ERROR (Status
)) {
3191 ReturnStatus
= Status
;
3195 return ReturnStatus
;
3200 Reads the next keystroke from the input device. The WaitForKey Event can
3201 be used to test for existance of a keystroke via WaitForEvent () call.
3203 @param Private Protocol instance pointer.
3204 @param Key Driver may perform diagnostics on reset.
3206 @retval EFI_SUCCESS The keystroke information was returned.
3207 @retval EFI_NOT_READY There was no keystroke data availiable.
3208 @retval EFI_DEVICE_ERROR The keydtroke information was not returned due
3214 ConSplitterTextInPrivateReadKeyStroke (
3215 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
3216 OUT EFI_INPUT_KEY
*Key
3221 EFI_INPUT_KEY CurrentKey
;
3223 Key
->UnicodeChar
= 0;
3224 Key
->ScanCode
= SCAN_NULL
;
3227 // if no physical console input device exists, return EFI_NOT_READY;
3228 // if any physical console input device has key input,
3229 // return the key and EFI_SUCCESS.
3231 for (Index
= 0; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
3232 Status
= Private
->TextInList
[Index
]->ReadKeyStroke (
3233 Private
->TextInList
[Index
],
3236 if (!EFI_ERROR (Status
)) {
3242 return EFI_NOT_READY
;
3247 Reads the next keystroke from the input device. The WaitForKey Event can
3248 be used to test for existance of a keystroke via WaitForEvent () call.
3250 @param This Protocol instance pointer.
3251 @param Key Driver may perform diagnostics on reset.
3253 @retval EFI_SUCCESS The keystroke information was returned.
3254 @retval EFI_NOT_READY There was no keystroke data availiable.
3255 @retval EFI_DEVICE_ERROR The keydtroke information was not returned due
3261 ConSplitterTextInReadKeyStroke (
3262 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*This
,
3263 OUT EFI_INPUT_KEY
*Key
3266 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3268 Private
= TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
3270 Private
->KeyEventSignalState
= FALSE
;
3272 return ConSplitterTextInPrivateReadKeyStroke (Private
, Key
);
3277 This event aggregates all the events of the ConIn devices in the spliter.
3279 If any events of physical ConIn devices are signaled, signal the ConIn
3280 spliter event. This will cause the calling code to call
3281 ConSplitterTextInReadKeyStroke ().
3283 @param Event The Event assoicated with callback.
3284 @param Context Context registered when Event was created.
3289 ConSplitterTextInWaitForKey (
3295 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3298 Private
= (TEXT_IN_SPLITTER_PRIVATE_DATA
*) Context
;
3300 if (Private
->KeyEventSignalState
) {
3302 // If KeyEventSignalState is flagged before, and not cleared by Reset() or ReadKeyStroke()
3304 gBS
->SignalEvent (Event
);
3309 // If any physical console input device has key input, signal the event.
3311 for (Index
= 0; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
3312 Status
= gBS
->CheckEvent (Private
->TextInList
[Index
]->WaitForKey
);
3313 if (!EFI_ERROR (Status
)) {
3314 gBS
->SignalEvent (Event
);
3315 Private
->KeyEventSignalState
= TRUE
;
3323 Test if the key has been registered on input device.
3325 @param RegsiteredData A pointer to a buffer that is filled in with the
3326 keystroke state data for the key that was
3328 @param InputData A pointer to a buffer that is filled in with the
3329 keystroke state data for the key that was
3332 @retval TRUE Key be pressed matches a registered key.
3333 @retval FLASE Match failed.
3338 IN EFI_KEY_DATA
*RegsiteredData
,
3339 IN EFI_KEY_DATA
*InputData
3342 ASSERT (RegsiteredData
!= NULL
&& InputData
!= NULL
);
3344 if ((RegsiteredData
->Key
.ScanCode
!= InputData
->Key
.ScanCode
) ||
3345 (RegsiteredData
->Key
.UnicodeChar
!= InputData
->Key
.UnicodeChar
)) {
3350 // Assume KeyShiftState/KeyToggleState = 0 in Registered key data means these state could be ignored.
3352 if (RegsiteredData
->KeyState
.KeyShiftState
!= 0 &&
3353 RegsiteredData
->KeyState
.KeyShiftState
!= InputData
->KeyState
.KeyShiftState
) {
3356 if (RegsiteredData
->KeyState
.KeyToggleState
!= 0 &&
3357 RegsiteredData
->KeyState
.KeyToggleState
!= InputData
->KeyState
.KeyToggleState
) {
3367 Reset the input device and optionaly run diagnostics
3369 @param This Protocol instance pointer.
3370 @param ExtendedVerification Driver may perform diagnostics on reset.
3372 @retval EFI_SUCCESS The device was reset.
3373 @retval EFI_DEVICE_ERROR The device is not functioning properly and could
3379 ConSplitterTextInResetEx (
3380 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*This
,
3381 IN BOOLEAN ExtendedVerification
3385 EFI_STATUS ReturnStatus
;
3386 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3389 Private
= TEXT_IN_EX_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
3391 Private
->KeyEventSignalState
= FALSE
;
3394 // return the worst status met
3396 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfExConsoles
; Index
++) {
3397 Status
= Private
->TextInExList
[Index
]->Reset (
3398 Private
->TextInExList
[Index
],
3399 ExtendedVerification
3401 if (EFI_ERROR (Status
)) {
3402 ReturnStatus
= Status
;
3406 return ReturnStatus
;
3412 Reads the next keystroke from the input device. The WaitForKey Event can
3413 be used to test for existance of a keystroke via WaitForEvent () call.
3415 @param This Protocol instance pointer.
3416 @param KeyData A pointer to a buffer that is filled in with the
3417 keystroke state data for the key that was
3420 @retval EFI_SUCCESS The keystroke information was returned.
3421 @retval EFI_NOT_READY There was no keystroke data availiable.
3422 @retval EFI_DEVICE_ERROR The keystroke information was not returned due
3424 @retval EFI_INVALID_PARAMETER KeyData is NULL.
3429 ConSplitterTextInReadKeyStrokeEx (
3430 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*This
,
3431 OUT EFI_KEY_DATA
*KeyData
3434 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3437 EFI_KEY_DATA CurrentKeyData
;
3440 if (KeyData
== NULL
) {
3441 return EFI_INVALID_PARAMETER
;
3444 Private
= TEXT_IN_EX_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
3446 Private
->KeyEventSignalState
= FALSE
;
3448 KeyData
->Key
.UnicodeChar
= 0;
3449 KeyData
->Key
.ScanCode
= SCAN_NULL
;
3452 // if no physical console input device exists, return EFI_NOT_READY;
3453 // if any physical console input device has key input,
3454 // return the key and EFI_SUCCESS.
3456 for (Index
= 0; Index
< Private
->CurrentNumberOfExConsoles
; Index
++) {
3457 Status
= Private
->TextInExList
[Index
]->ReadKeyStrokeEx (
3458 Private
->TextInExList
[Index
],
3461 if (!EFI_ERROR (Status
)) {
3462 CopyMem (KeyData
, &CurrentKeyData
, sizeof (CurrentKeyData
));
3467 return EFI_NOT_READY
;
3472 Set certain state for the input device.
3474 @param This Protocol instance pointer.
3475 @param KeyToggleState A pointer to the EFI_KEY_TOGGLE_STATE to set the
3476 state for the input device.
3478 @retval EFI_SUCCESS The device state was set successfully.
3479 @retval EFI_DEVICE_ERROR The device is not functioning correctly and
3480 could not have the setting adjusted.
3481 @retval EFI_UNSUPPORTED The device does not have the ability to set its
3483 @retval EFI_INVALID_PARAMETER KeyToggleState is NULL.
3488 ConSplitterTextInSetState (
3489 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*This
,
3490 IN EFI_KEY_TOGGLE_STATE
*KeyToggleState
3493 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3497 if (KeyToggleState
== NULL
) {
3498 return EFI_INVALID_PARAMETER
;
3501 Private
= TEXT_IN_EX_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
3504 // if no physical console input device exists, return EFI_SUCCESS;
3505 // otherwise return the status of setting state of physical console input device
3507 for (Index
= 0; Index
< Private
->CurrentNumberOfExConsoles
; Index
++) {
3508 Status
= Private
->TextInExList
[Index
]->SetState (
3509 Private
->TextInExList
[Index
],
3512 if (EFI_ERROR (Status
)) {
3523 Register a notification function for a particular keystroke for the input device.
3525 @param This Protocol instance pointer.
3526 @param KeyData A pointer to a buffer that is filled in with the
3527 keystroke information data for the key that was
3529 @param KeyNotificationFunction Points to the function to be called when the key
3530 sequence is typed specified by KeyData.
3531 @param NotifyHandle Points to the unique handle assigned to the
3532 registered notification.
3534 @retval EFI_SUCCESS The notification function was registered
3536 @retval EFI_OUT_OF_RESOURCES Unable to allocate resources for necesssary data
3538 @retval EFI_INVALID_PARAMETER KeyData or KeyNotificationFunction or NotifyHandle is NULL.
3543 ConSplitterTextInRegisterKeyNotify (
3544 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*This
,
3545 IN EFI_KEY_DATA
*KeyData
,
3546 IN EFI_KEY_NOTIFY_FUNCTION KeyNotificationFunction
,
3547 OUT EFI_HANDLE
*NotifyHandle
3550 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3553 TEXT_IN_EX_SPLITTER_NOTIFY
*NewNotify
;
3555 TEXT_IN_EX_SPLITTER_NOTIFY
*CurrentNotify
;
3558 if (KeyData
== NULL
|| NotifyHandle
== NULL
|| KeyNotificationFunction
== NULL
) {
3559 return EFI_INVALID_PARAMETER
;
3562 Private
= TEXT_IN_EX_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
3565 // If no physical console input device exists,
3566 // return EFI_SUCCESS directly.
3568 if (Private
->CurrentNumberOfExConsoles
<= 0) {
3573 // Return EFI_SUCCESS if the (KeyData, NotificationFunction) is already registered.
3575 for (Link
= Private
->NotifyList
.ForwardLink
; Link
!= &Private
->NotifyList
; Link
= Link
->ForwardLink
) {
3576 CurrentNotify
= TEXT_IN_EX_SPLITTER_NOTIFY_FROM_THIS (Link
);
3577 if (IsKeyRegistered (&CurrentNotify
->KeyData
, KeyData
)) {
3578 if (CurrentNotify
->KeyNotificationFn
== KeyNotificationFunction
) {
3579 *NotifyHandle
= CurrentNotify
->NotifyHandle
;
3586 // Allocate resource to save the notification function
3588 NewNotify
= (TEXT_IN_EX_SPLITTER_NOTIFY
*) AllocateZeroPool (sizeof (TEXT_IN_EX_SPLITTER_NOTIFY
));
3589 if (NewNotify
== NULL
) {
3590 return EFI_OUT_OF_RESOURCES
;
3592 NewNotify
->NotifyHandleList
= (EFI_HANDLE
*) AllocateZeroPool (sizeof (EFI_HANDLE
) * Private
->CurrentNumberOfExConsoles
);
3593 if (NewNotify
->NotifyHandleList
== NULL
) {
3594 gBS
->FreePool (NewNotify
);
3595 return EFI_OUT_OF_RESOURCES
;
3597 NewNotify
->Signature
= TEXT_IN_EX_SPLITTER_NOTIFY_SIGNATURE
;
3598 NewNotify
->KeyNotificationFn
= KeyNotificationFunction
;
3599 NewNotify
->NotifyHandle
= (EFI_HANDLE
) NewNotify
;
3600 CopyMem (&NewNotify
->KeyData
, KeyData
, sizeof (KeyData
));
3603 // Return the wrong status of registering key notify of
3604 // physical console input device if meet problems
3606 for (Index
= 0; Index
< Private
->CurrentNumberOfExConsoles
; Index
++) {
3607 Status
= Private
->TextInExList
[Index
]->RegisterKeyNotify (
3608 Private
->TextInExList
[Index
],
3610 KeyNotificationFunction
,
3611 &NewNotify
->NotifyHandleList
[Index
]
3613 if (EFI_ERROR (Status
)) {
3614 gBS
->FreePool (NewNotify
->NotifyHandleList
);
3615 gBS
->FreePool (NewNotify
);
3620 InsertTailList (&mConIn
.NotifyList
, &NewNotify
->NotifyEntry
);
3622 *NotifyHandle
= NewNotify
->NotifyHandle
;
3630 Remove a registered notification function from a particular keystroke.
3632 @param This Protocol instance pointer.
3633 @param NotificationHandle The handle of the notification function being
3636 @retval EFI_SUCCESS The notification function was unregistered
3638 @retval EFI_INVALID_PARAMETER The NotificationHandle is invalid.
3639 @retval EFI_NOT_FOUND Can not find the matching entry in database.
3644 ConSplitterTextInUnregisterKeyNotify (
3645 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*This
,
3646 IN EFI_HANDLE NotificationHandle
3649 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3652 TEXT_IN_EX_SPLITTER_NOTIFY
*CurrentNotify
;
3655 if (NotificationHandle
== NULL
) {
3656 return EFI_INVALID_PARAMETER
;
3659 if (((TEXT_IN_EX_SPLITTER_NOTIFY
*) NotificationHandle
)->Signature
!= TEXT_IN_EX_SPLITTER_NOTIFY_SIGNATURE
) {
3660 return EFI_INVALID_PARAMETER
;
3663 Private
= TEXT_IN_EX_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
3666 // if no physical console input device exists,
3667 // return EFI_SUCCESS directly.
3669 if (Private
->CurrentNumberOfExConsoles
<= 0) {
3673 for (Link
= Private
->NotifyList
.ForwardLink
; Link
!= &Private
->NotifyList
; Link
= Link
->ForwardLink
) {
3674 CurrentNotify
= TEXT_IN_EX_SPLITTER_NOTIFY_FROM_THIS (Link
);
3675 if (CurrentNotify
->NotifyHandle
== NotificationHandle
) {
3676 for (Index
= 0; Index
< Private
->CurrentNumberOfExConsoles
; Index
++) {
3677 Status
= Private
->TextInExList
[Index
]->UnregisterKeyNotify (
3678 Private
->TextInExList
[Index
],
3679 CurrentNotify
->NotifyHandleList
[Index
]
3681 if (EFI_ERROR (Status
)) {
3685 RemoveEntryList (&CurrentNotify
->NotifyEntry
);
3687 gBS
->FreePool (CurrentNotify
->NotifyHandleList
);
3688 gBS
->FreePool (CurrentNotify
);
3693 return EFI_NOT_FOUND
;
3699 Reset the input device and optionaly run diagnostics
3701 @param This Protocol instance pointer.
3702 @param ExtendedVerification Driver may perform diagnostics on reset.
3704 @retval EFI_SUCCESS The device was reset.
3705 @retval EFI_DEVICE_ERROR The device is not functioning properly and could
3711 ConSplitterSimplePointerReset (
3712 IN EFI_SIMPLE_POINTER_PROTOCOL
*This
,
3713 IN BOOLEAN ExtendedVerification
3717 EFI_STATUS ReturnStatus
;
3718 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3721 Private
= TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_SIMPLE_POINTER_THIS (This
);
3723 Private
->InputEventSignalState
= FALSE
;
3725 if (Private
->CurrentNumberOfPointers
== 0) {
3729 // return the worst status met
3731 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfPointers
; Index
++) {
3732 Status
= Private
->PointerList
[Index
]->Reset (
3733 Private
->PointerList
[Index
],
3734 ExtendedVerification
3736 if (EFI_ERROR (Status
)) {
3737 ReturnStatus
= Status
;
3741 return ReturnStatus
;
3746 Reads the next keystroke from the input device. The WaitForKey Event can
3747 be used to test for existance of a keystroke via WaitForEvent () call.
3749 @param Private Protocol instance pointer.
3750 @param State The state information of simple pointer device.
3752 @retval EFI_SUCCESS The keystroke information was returned.
3753 @retval EFI_NOT_READY There was no keystroke data availiable.
3754 @retval EFI_DEVICE_ERROR The keydtroke information was not returned due
3760 ConSplitterSimplePointerPrivateGetState (
3761 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
3762 IN OUT EFI_SIMPLE_POINTER_STATE
*State
3766 EFI_STATUS ReturnStatus
;
3768 EFI_SIMPLE_POINTER_STATE CurrentState
;
3770 State
->RelativeMovementX
= 0;
3771 State
->RelativeMovementY
= 0;
3772 State
->RelativeMovementZ
= 0;
3773 State
->LeftButton
= FALSE
;
3774 State
->RightButton
= FALSE
;
3777 // if no physical console input device exists, return EFI_NOT_READY;
3778 // if any physical console input device has key input,
3779 // return the key and EFI_SUCCESS.
3781 ReturnStatus
= EFI_NOT_READY
;
3782 for (Index
= 0; Index
< Private
->CurrentNumberOfPointers
; Index
++) {
3784 Status
= Private
->PointerList
[Index
]->GetState (
3785 Private
->PointerList
[Index
],
3788 if (!EFI_ERROR (Status
)) {
3789 if (ReturnStatus
== EFI_NOT_READY
) {
3790 ReturnStatus
= EFI_SUCCESS
;
3793 if (CurrentState
.LeftButton
) {
3794 State
->LeftButton
= TRUE
;
3797 if (CurrentState
.RightButton
) {
3798 State
->RightButton
= TRUE
;
3801 if (CurrentState
.RelativeMovementX
!= 0 && Private
->PointerList
[Index
]->Mode
->ResolutionX
!= 0) {
3802 State
->RelativeMovementX
+= (CurrentState
.RelativeMovementX
* (INT32
) Private
->SimplePointerMode
.ResolutionX
) / (INT32
) Private
->PointerList
[Index
]->Mode
->ResolutionX
;
3805 if (CurrentState
.RelativeMovementY
!= 0 && Private
->PointerList
[Index
]->Mode
->ResolutionY
!= 0) {
3806 State
->RelativeMovementY
+= (CurrentState
.RelativeMovementY
* (INT32
) Private
->SimplePointerMode
.ResolutionY
) / (INT32
) Private
->PointerList
[Index
]->Mode
->ResolutionY
;
3809 if (CurrentState
.RelativeMovementZ
!= 0 && Private
->PointerList
[Index
]->Mode
->ResolutionZ
!= 0) {
3810 State
->RelativeMovementZ
+= (CurrentState
.RelativeMovementZ
* (INT32
) Private
->SimplePointerMode
.ResolutionZ
) / (INT32
) Private
->PointerList
[Index
]->Mode
->ResolutionZ
;
3812 } else if (Status
== EFI_DEVICE_ERROR
) {
3813 ReturnStatus
= EFI_DEVICE_ERROR
;
3817 return ReturnStatus
;
3822 Reads the next keystroke from the input device. The WaitForKey Event can
3823 be used to test for existance of a keystroke via WaitForEvent () call.
3825 @param This A pointer to protocol instance.
3826 @param State A pointer to state information on the pointer device
3828 @retval EFI_SUCCESS The keystroke information was returned in State.
3829 @retval EFI_NOT_READY There was no keystroke data availiable.
3830 @retval EFI_DEVICE_ERROR The keydtroke information was not returned due
3836 ConSplitterSimplePointerGetState (
3837 IN EFI_SIMPLE_POINTER_PROTOCOL
*This
,
3838 IN OUT EFI_SIMPLE_POINTER_STATE
*State
3841 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3843 Private
= TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_SIMPLE_POINTER_THIS (This
);
3845 Private
->InputEventSignalState
= FALSE
;
3847 return ConSplitterSimplePointerPrivateGetState (Private
, State
);
3852 This event agregates all the events of the ConIn devices in the spliter.
3853 If any events of physical ConIn devices are signaled, signal the ConIn
3854 spliter event. This will cause the calling code to call
3855 ConSplitterTextInReadKeyStroke ().
3857 @param Event The Event assoicated with callback.
3858 @param Context Context registered when Event was created.
3863 ConSplitterSimplePointerWaitForInput (
3869 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3872 Private
= (TEXT_IN_SPLITTER_PRIVATE_DATA
*) Context
;
3875 // if InputEventSignalState is flagged before, and not cleared by Reset() or ReadKeyStroke()
3877 if (Private
->InputEventSignalState
) {
3878 gBS
->SignalEvent (Event
);
3882 // if any physical console input device has key input, signal the event.
3884 for (Index
= 0; Index
< Private
->CurrentNumberOfPointers
; Index
++) {
3885 Status
= gBS
->CheckEvent (Private
->PointerList
[Index
]->WaitForInput
);
3886 if (!EFI_ERROR (Status
)) {
3887 gBS
->SignalEvent (Event
);
3888 Private
->InputEventSignalState
= TRUE
;
3894 Resets the pointer device hardware.
3896 @param This Protocol instance pointer.
3897 @param ExtendedVerification Driver may perform diagnostics on reset.
3899 @retval EFI_SUCCESS The device was reset.
3900 @retval EFI_DEVICE_ERROR The device is not functioning correctly and
3906 ConSplitterAbsolutePointerReset (
3907 IN EFI_ABSOLUTE_POINTER_PROTOCOL
*This
,
3908 IN BOOLEAN ExtendedVerification
3912 EFI_STATUS ReturnStatus
;
3913 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3916 Private
= TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_ABSOLUTE_POINTER_THIS (This
);
3918 Private
->AbsoluteInputEventSignalState
= FALSE
;
3920 if (Private
->CurrentNumberOfAbsolutePointers
== 0) {
3924 // return the worst status met
3926 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfAbsolutePointers
; Index
++) {
3927 Status
= Private
->AbsolutePointerList
[Index
]->Reset (
3928 Private
->AbsolutePointerList
[Index
],
3929 ExtendedVerification
3931 if (EFI_ERROR (Status
)) {
3932 ReturnStatus
= Status
;
3936 return ReturnStatus
;
3941 Retrieves the current state of a pointer device.
3943 @param This Protocol instance pointer.
3944 @param State A pointer to the state information on the
3947 @retval EFI_SUCCESS The state of the pointer device was returned in
3949 @retval EFI_NOT_READY The state of the pointer device has not changed
3950 since the last call to GetState().
3951 @retval EFI_DEVICE_ERROR A device error occurred while attempting to
3952 retrieve the pointer device's current state.
3957 ConSplitterAbsolutePointerGetState (
3958 IN EFI_ABSOLUTE_POINTER_PROTOCOL
*This
,
3959 IN OUT EFI_ABSOLUTE_POINTER_STATE
*State
3962 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3964 EFI_STATUS ReturnStatus
;
3966 EFI_ABSOLUTE_POINTER_STATE CurrentState
;
3969 Private
= TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_ABSOLUTE_POINTER_THIS (This
);
3971 Private
->AbsoluteInputEventSignalState
= FALSE
;
3973 State
->CurrentX
= 0;
3974 State
->CurrentY
= 0;
3975 State
->CurrentZ
= 0;
3976 State
->ActiveButtons
= 0;
3979 // if no physical pointer device exists, return EFI_NOT_READY;
3980 // if any physical pointer device has changed state,
3981 // return the state and EFI_SUCCESS.
3983 ReturnStatus
= EFI_NOT_READY
;
3984 for (Index
= 0; Index
< Private
->CurrentNumberOfAbsolutePointers
; Index
++) {
3986 Status
= Private
->AbsolutePointerList
[Index
]->GetState (
3987 Private
->AbsolutePointerList
[Index
],
3990 if (!EFI_ERROR (Status
)) {
3991 if (ReturnStatus
== EFI_NOT_READY
) {
3992 ReturnStatus
= EFI_SUCCESS
;
3995 State
->ActiveButtons
= CurrentState
.ActiveButtons
;
3997 if (!(Private
->AbsolutePointerMode
.AbsoluteMinX
== 0 && Private
->AbsolutePointerMode
.AbsoluteMaxX
== 0)) {
3998 State
->CurrentX
= CurrentState
.CurrentX
;
4000 if (!(Private
->AbsolutePointerMode
.AbsoluteMinY
== 0 && Private
->AbsolutePointerMode
.AbsoluteMaxY
== 0)) {
4001 State
->CurrentY
= CurrentState
.CurrentY
;
4003 if (!(Private
->AbsolutePointerMode
.AbsoluteMinZ
== 0 && Private
->AbsolutePointerMode
.AbsoluteMaxZ
== 0)) {
4004 State
->CurrentZ
= CurrentState
.CurrentZ
;
4007 } else if (Status
== EFI_DEVICE_ERROR
) {
4008 ReturnStatus
= EFI_DEVICE_ERROR
;
4012 return ReturnStatus
;
4017 This event agregates all the events of the pointer devices in the splitter.
4018 If any events of physical pointer devices are signaled, signal the pointer
4019 splitter event. This will cause the calling code to call
4020 ConSplitterAbsolutePointerGetState ().
4022 @param Event The Event assoicated with callback.
4023 @param Context Context registered when Event was created.
4028 ConSplitterAbsolutePointerWaitForInput (
4034 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
4037 Private
= (TEXT_IN_SPLITTER_PRIVATE_DATA
*) Context
;
4040 // if AbsoluteInputEventSignalState is flagged before,
4041 // and not cleared by Reset() or GetState(), signal it
4043 if (Private
->AbsoluteInputEventSignalState
) {
4044 gBS
->SignalEvent (Event
);
4048 // if any physical console input device has key input, signal the event.
4050 for (Index
= 0; Index
< Private
->CurrentNumberOfAbsolutePointers
; Index
++) {
4051 Status
= gBS
->CheckEvent (Private
->AbsolutePointerList
[Index
]->WaitForInput
);
4052 if (!EFI_ERROR (Status
)) {
4053 gBS
->SignalEvent (Event
);
4054 Private
->AbsoluteInputEventSignalState
= TRUE
;
4061 Reset the text output device hardware and optionaly run diagnostics
4063 @param This Protocol instance pointer.
4064 @param ExtendedVerification Driver may perform more exhaustive verfication
4065 operation of the device during reset.
4067 @retval EFI_SUCCESS The text output device was reset.
4068 @retval EFI_DEVICE_ERROR The text output device is not functioning
4069 correctly and could not be reset.
4074 ConSplitterTextOutReset (
4075 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4076 IN BOOLEAN ExtendedVerification
4080 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4082 EFI_STATUS ReturnStatus
;
4084 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4087 // return the worst status met
4089 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
4090 Status
= Private
->TextOutList
[Index
].TextOut
->Reset (
4091 Private
->TextOutList
[Index
].TextOut
,
4092 ExtendedVerification
4094 if (EFI_ERROR (Status
)) {
4095 ReturnStatus
= Status
;
4099 This
->SetAttribute (This
, EFI_TEXT_ATTR (This
->Mode
->Attribute
& 0x0F, EFI_BLACK
));
4102 // reset all mode parameters
4104 TextOutSetMode (Private
, 0);
4106 return ReturnStatus
;
4111 Write a Unicode string to the output device.
4113 @param This Protocol instance pointer.
4114 @param WString The NULL-terminated Unicode string to be
4115 displayed on the output device(s). All output
4116 devices must also support the Unicode drawing
4117 defined in this file.
4119 @retval EFI_SUCCESS The string was output to the device.
4120 @retval EFI_DEVICE_ERROR The device reported an error while attempting to
4122 @retval EFI_UNSUPPORTED The output device's mode is not currently in a
4124 @retval EFI_WARN_UNKNOWN_GLYPH This warning code indicates that some of the
4125 characters in the Unicode string could not be
4126 rendered and were skipped.
4131 ConSplitterTextOutOutputString (
4132 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4137 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4139 UINTN BackSpaceCount
;
4140 EFI_STATUS ReturnStatus
;
4141 CHAR16
*TargetString
;
4143 This
->SetAttribute (This
, This
->Mode
->Attribute
);
4145 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4148 for (TargetString
= WString
; *TargetString
!= L
'\0'; TargetString
++) {
4149 if (*TargetString
== L
'a' && *(TargetString
+ 1) == L
'b' && *(TargetString
+ 2) == L
'c') {
4150 ;// CpuBreakpoint ();
4153 if (*TargetString
== CHAR_BACKSPACE
) {
4159 if (BackSpaceCount
== 0) {
4160 TargetString
= WString
;
4162 TargetString
= AllocatePool (sizeof (CHAR16
) * (StrLen (WString
) + BackSpaceCount
+ 1));
4163 ASSERT (TargetString
!= NULL
);
4165 StrCpy (TargetString
, WString
);
4168 // return the worst status met
4170 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
4171 Status
= Private
->TextOutList
[Index
].TextOut
->OutputString (
4172 Private
->TextOutList
[Index
].TextOut
,
4175 if (EFI_ERROR (Status
)) {
4176 ReturnStatus
= Status
;
4180 if (Private
->CurrentNumberOfConsoles
> 0) {
4181 Private
->TextOutMode
.CursorColumn
= Private
->TextOutList
[0].TextOut
->Mode
->CursorColumn
;
4182 Private
->TextOutMode
.CursorRow
= Private
->TextOutList
[0].TextOut
->Mode
->CursorRow
;
4185 if (BackSpaceCount
> 0) {
4186 FreePool (TargetString
);
4189 return ReturnStatus
;
4194 Verifies that all characters in a Unicode string can be output to the
4197 @param This Protocol instance pointer.
4198 @param WString The NULL-terminated Unicode string to be
4199 examined for the output device(s).
4201 @retval EFI_SUCCESS The device(s) are capable of rendering the
4203 @retval EFI_UNSUPPORTED Some of the characters in the Unicode string
4204 cannot be rendered by one or more of the output
4205 devices mapped by the EFI handle.
4210 ConSplitterTextOutTestString (
4211 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4216 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4218 EFI_STATUS ReturnStatus
;
4220 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4223 // return the worst status met
4225 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
4226 Status
= Private
->TextOutList
[Index
].TextOut
->TestString (
4227 Private
->TextOutList
[Index
].TextOut
,
4230 if (EFI_ERROR (Status
)) {
4231 ReturnStatus
= Status
;
4235 // There is no DevNullTextOutTestString () since a Unicode buffer would
4236 // always return EFI_SUCCESS.
4237 // ReturnStatus will be EFI_SUCCESS if no consoles are present
4239 return ReturnStatus
;
4244 Returns information for an available text mode that the output device(s)
4247 @param This Protocol instance pointer.
4248 @param ModeNumber The mode number to return information on.
4249 @param Columns Returns the columns of the text output device
4250 for the requested ModeNumber.
4251 @param Rows Returns the rows of the text output device
4252 for the requested ModeNumber.
4254 @retval EFI_SUCCESS The requested mode information was returned.
4255 @retval EFI_DEVICE_ERROR The device had an error and could not complete
4257 @retval EFI_UNSUPPORTED The mode number was not valid.
4262 ConSplitterTextOutQueryMode (
4263 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4264 IN UINTN ModeNumber
,
4269 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4271 INT32
*TextOutModeMap
;
4273 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4276 // Check whether param ModeNumber is valid.
4277 // ModeNumber should be within range 0 ~ MaxMode - 1.
4279 if ( (ModeNumber
> (UINTN
)(((UINT32
)-1)>>1)) ) {
4280 return EFI_UNSUPPORTED
;
4283 if ((INT32
) ModeNumber
>= This
->Mode
->MaxMode
) {
4284 return EFI_UNSUPPORTED
;
4288 // We get the available mode from mode intersection map if it's available
4290 if (Private
->TextOutModeMap
!= NULL
) {
4291 TextOutModeMap
= Private
->TextOutModeMap
+ Private
->TextOutListCount
* ModeNumber
;
4292 CurrentMode
= (UINTN
)(*TextOutModeMap
);
4293 *Columns
= Private
->TextOutQueryData
[CurrentMode
].Columns
;
4294 *Rows
= Private
->TextOutQueryData
[CurrentMode
].Rows
;
4296 *Columns
= Private
->TextOutQueryData
[ModeNumber
].Columns
;
4297 *Rows
= Private
->TextOutQueryData
[ModeNumber
].Rows
;
4300 if (*Columns
<= 0 && *Rows
<= 0) {
4301 return EFI_UNSUPPORTED
;
4310 Sets the output device(s) to a specified mode.
4312 @param This Protocol instance pointer.
4313 @param ModeNumber The mode number to set.
4315 @retval EFI_SUCCESS The requested text mode was set.
4316 @retval EFI_DEVICE_ERROR The device had an error and could not complete
4318 @retval EFI_UNSUPPORTED The mode number was not valid.
4323 ConSplitterTextOutSetMode (
4324 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4329 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4331 INT32
*TextOutModeMap
;
4332 EFI_STATUS ReturnStatus
;
4334 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4337 // Check whether param ModeNumber is valid.
4338 // ModeNumber should be within range 0 ~ MaxMode - 1.
4340 if ( (ModeNumber
> (UINTN
)(((UINT32
)-1)>>1)) ) {
4341 return EFI_UNSUPPORTED
;
4344 if ((INT32
) ModeNumber
>= This
->Mode
->MaxMode
) {
4345 return EFI_UNSUPPORTED
;
4348 // If the mode is being set to the curent mode, then just clear the screen and return.
4350 if (Private
->TextOutMode
.Mode
== (INT32
) ModeNumber
) {
4351 return ConSplitterTextOutClearScreen (This
);
4354 // return the worst status met
4356 TextOutModeMap
= Private
->TextOutModeMap
+ Private
->TextOutListCount
* ModeNumber
;
4357 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
4358 Status
= Private
->TextOutList
[Index
].TextOut
->SetMode (
4359 Private
->TextOutList
[Index
].TextOut
,
4360 TextOutModeMap
[Index
]
4363 // If this console device is based on a GOP or UGA device, then sync up the bitmap from
4364 // the GOP/UGA splitter and reclear the text portion of the display in the new mode.
4366 if ((Private
->TextOutList
[Index
].GraphicsOutput
!= NULL
) || (Private
->TextOutList
[Index
].UgaDraw
!= NULL
)) {
4367 Private
->TextOutList
[Index
].TextOut
->ClearScreen (Private
->TextOutList
[Index
].TextOut
);
4370 if (EFI_ERROR (Status
)) {
4371 ReturnStatus
= Status
;
4376 // Set mode parameter to specified mode number
4378 TextOutSetMode (Private
, ModeNumber
);
4380 return ReturnStatus
;
4385 Sets the background and foreground colors for the OutputString () and
4386 ClearScreen () functions.
4388 @param This Protocol instance pointer.
4389 @param Attribute The attribute to set. Bits 0..3 are the
4390 foreground color, and bits 4..6 are the
4391 background color. All other bits are undefined
4392 and must be zero. The valid Attributes are
4393 defined in this file.
4395 @retval EFI_SUCCESS The attribute was set.
4396 @retval EFI_DEVICE_ERROR The device had an error and could not complete
4398 @retval EFI_UNSUPPORTED The attribute requested is not defined.
4403 ConSplitterTextOutSetAttribute (
4404 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4409 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4411 EFI_STATUS ReturnStatus
;
4413 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4416 // Check whether param Attribute is valid.
4418 if ( (Attribute
> (UINTN
)(((UINT32
)-1)>>1)) ) {
4419 return EFI_UNSUPPORTED
;
4423 // return the worst status met
4425 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
4426 Status
= Private
->TextOutList
[Index
].TextOut
->SetAttribute (
4427 Private
->TextOutList
[Index
].TextOut
,
4430 if (EFI_ERROR (Status
)) {
4431 ReturnStatus
= Status
;
4435 Private
->TextOutMode
.Attribute
= (INT32
) Attribute
;
4437 return ReturnStatus
;
4442 Clears the output device(s) display to the currently selected background
4445 @param This Protocol instance pointer.
4447 @retval EFI_SUCCESS The operation completed successfully.
4448 @retval EFI_DEVICE_ERROR The device had an error and could not complete
4450 @retval EFI_UNSUPPORTED The output device is not in a valid text mode.
4455 ConSplitterTextOutClearScreen (
4456 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
4460 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4462 EFI_STATUS ReturnStatus
;
4464 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4467 // return the worst status met
4469 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
4470 Status
= Private
->TextOutList
[Index
].TextOut
->ClearScreen (Private
->TextOutList
[Index
].TextOut
);
4471 if (EFI_ERROR (Status
)) {
4472 ReturnStatus
= Status
;
4477 // No need to do extra check here as whether (Column, Row) is valid has
4478 // been checked in ConSplitterTextOutSetCursorPosition. And (0, 0) should
4479 // always be supported.
4481 Private
->TextOutMode
.CursorColumn
= 0;
4482 Private
->TextOutMode
.CursorRow
= 0;
4483 Private
->TextOutMode
.CursorVisible
= TRUE
;
4485 return ReturnStatus
;
4490 Sets the current coordinates of the cursor position
4492 @param This Protocol instance pointer.
4493 @param Column The column position to set the cursor to. Must be
4494 greater than or equal to zero and less than the
4495 number of columns by QueryMode ().
4496 @param Row The row position to set the cursor to. Must be
4497 greater than or equal to zero and less than the
4498 number of rows by QueryMode ().
4500 @retval EFI_SUCCESS The operation completed successfully.
4501 @retval EFI_DEVICE_ERROR The device had an error and could not complete
4503 @retval EFI_UNSUPPORTED The output device is not in a valid text mode,
4504 or the cursor position is invalid for the
4510 ConSplitterTextOutSetCursorPosition (
4511 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4517 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4519 EFI_STATUS ReturnStatus
;
4522 INT32
*TextOutModeMap
;
4526 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4527 TextOutModeMap
= NULL
;
4528 ModeNumber
= Private
->TextOutMode
.Mode
;
4531 // Get current MaxColumn and MaxRow from intersection map
4533 if (Private
->TextOutModeMap
!= NULL
) {
4534 TextOutModeMap
= Private
->TextOutModeMap
+ Private
->TextOutListCount
* ModeNumber
;
4535 CurrentMode
= *TextOutModeMap
;
4537 CurrentMode
= ModeNumber
;
4540 MaxColumn
= Private
->TextOutQueryData
[CurrentMode
].Columns
;
4541 MaxRow
= Private
->TextOutQueryData
[CurrentMode
].Rows
;
4543 if (Column
>= MaxColumn
|| Row
>= MaxRow
) {
4544 return EFI_UNSUPPORTED
;
4547 // return the worst status met
4549 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
4550 Status
= Private
->TextOutList
[Index
].TextOut
->SetCursorPosition (
4551 Private
->TextOutList
[Index
].TextOut
,
4555 if (EFI_ERROR (Status
)) {
4556 ReturnStatus
= Status
;
4561 // No need to do extra check here as whether (Column, Row) is valid has
4562 // been checked in ConSplitterTextOutSetCursorPosition. And (0, 0) should
4563 // always be supported.
4565 Private
->TextOutMode
.CursorColumn
= (INT32
) Column
;
4566 Private
->TextOutMode
.CursorRow
= (INT32
) Row
;
4568 return ReturnStatus
;
4573 Makes the cursor visible or invisible
4575 @param This Protocol instance pointer.
4576 @param Visible If TRUE, the cursor is set to be visible. If
4577 FALSE, the cursor is set to be invisible.
4579 @retval EFI_SUCCESS The operation completed successfully.
4580 @retval EFI_DEVICE_ERROR The device had an error and could not complete
4581 the request, or the device does not support
4582 changing the cursor mode.
4583 @retval EFI_UNSUPPORTED The output device is not in a valid text mode.
4588 ConSplitterTextOutEnableCursor (
4589 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4594 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4596 EFI_STATUS ReturnStatus
;
4598 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4601 // return the worst status met
4603 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
4604 Status
= Private
->TextOutList
[Index
].TextOut
->EnableCursor (
4605 Private
->TextOutList
[Index
].TextOut
,
4608 if (EFI_ERROR (Status
)) {
4609 ReturnStatus
= Status
;
4613 Private
->TextOutMode
.CursorVisible
= Visible
;
4615 return ReturnStatus
;