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 - 2010, Intel Corporation. All rights reserved.<BR>
20 This program and the accompanying materials
21 are licensed and made available under the terms and conditions of the BSD License
22 which accompanies this distribution. The full text of the license may be found at
23 http://opensource.org/licenses/bsd-license.php
25 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
26 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
30 #include "ConSplitter.h"
33 // 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 ConSplitterUgaDrawGetMode
,
111 ConSplitterUgaDrawSetMode
,
112 ConSplitterUgaDrawBlt
116 // Graphics Output Protocol Private Data template
118 GLOBAL_REMOVE_IF_UNREFERENCED EFI_GRAPHICS_OUTPUT_PROTOCOL mGraphicsOutputProtocolTemplate
= {
119 ConSplitterGraphicsOutputQueryMode
,
120 ConSplitterGraphicsOutputSetMode
,
121 ConSplitterGraphicsOutputBlt
,
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.
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 ConIn Splitter
389 Status
= ConSplitterTextInConstructor (&mConIn
);
390 if (!EFI_ERROR (Status
)) {
391 Status
= gBS
->InstallMultipleProtocolInterfaces (
392 &mConIn
.VirtualHandle
,
393 &gEfiSimpleTextInProtocolGuid
,
395 &gEfiSimpleTextInputExProtocolGuid
,
397 &gEfiSimplePointerProtocolGuid
,
398 &mConIn
.SimplePointer
,
399 &gEfiAbsolutePointerProtocolGuid
,
400 &mConIn
.AbsolutePointer
,
403 if (!EFI_ERROR (Status
)) {
405 // Update the EFI System Table with new virtual console
406 // and update the pointer to Simple Text Input protocol.
408 gST
->ConsoleInHandle
= mConIn
.VirtualHandle
;
409 gST
->ConIn
= &mConIn
.TextIn
;
413 // Create virtual device handle for ConOut Splitter
415 Status
= ConSplitterTextOutConstructor (&mConOut
);
416 if (!EFI_ERROR (Status
)) {
417 if (!FeaturePcdGet (PcdConOutGopSupport
)) {
419 // If Graphics Outpurt protocol not supported, UGA Draw protocol is installed
420 // on the virtual handle.
422 Status
= gBS
->InstallMultipleProtocolInterfaces (
423 &mConOut
.VirtualHandle
,
424 &gEfiSimpleTextOutProtocolGuid
,
426 &gEfiUgaDrawProtocolGuid
,
430 } else if (!FeaturePcdGet (PcdConOutUgaSupport
)) {
432 // If UGA Draw protocol not supported, Graphics Output Protocol is installed
433 // on virtual handle.
435 Status
= gBS
->InstallMultipleProtocolInterfaces (
436 &mConOut
.VirtualHandle
,
437 &gEfiSimpleTextOutProtocolGuid
,
439 &gEfiGraphicsOutputProtocolGuid
,
440 &mConOut
.GraphicsOutput
,
445 // Boot Graphics Output protocol and UGA Draw protocol are supported,
446 // both they will be installed on virtual handle.
448 Status
= gBS
->InstallMultipleProtocolInterfaces (
449 &mConOut
.VirtualHandle
,
450 &gEfiSimpleTextOutProtocolGuid
,
452 &gEfiGraphicsOutputProtocolGuid
,
453 &mConOut
.GraphicsOutput
,
454 &gEfiUgaDrawProtocolGuid
,
460 if (!EFI_ERROR (Status
)) {
462 // Update the EFI System Table with new virtual console
463 // and Update the pointer to Text Output protocol.
465 gST
->ConsoleOutHandle
= mConOut
.VirtualHandle
;
466 gST
->ConOut
= &mConOut
.TextOut
;
471 // Update the CRC32 in the EFI System Table header
474 gBS
->CalculateCrc32 (
485 Construct console input devices' private data.
487 @param ConInPrivate A pointer to the TEXT_IN_SPLITTER_PRIVATE_DATA
490 @retval EFI_OUT_OF_RESOURCES Out of resources.
491 @retval EFI_SUCCESS Text Input Devcie's private data has been constructed.
492 @retval other Failed to construct private data.
496 ConSplitterTextInConstructor (
497 TEXT_IN_SPLITTER_PRIVATE_DATA
*ConInPrivate
503 // Allocate buffer for Simple Text Input device
505 Status
= ConSplitterGrowBuffer (
506 sizeof (EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*),
507 &ConInPrivate
->TextInListCount
,
508 (VOID
**) &ConInPrivate
->TextInList
510 if (EFI_ERROR (Status
)) {
511 return EFI_OUT_OF_RESOURCES
;
515 // Create Event to wait for a key
517 Status
= gBS
->CreateEvent (
520 ConSplitterTextInWaitForKey
,
522 &ConInPrivate
->TextIn
.WaitForKey
524 ASSERT_EFI_ERROR (Status
);
527 // Allocate buffer for Simple Text Input Ex device
529 Status
= ConSplitterGrowBuffer (
530 sizeof (EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*),
531 &ConInPrivate
->TextInExListCount
,
532 (VOID
**) &ConInPrivate
->TextInExList
534 if (EFI_ERROR (Status
)) {
535 return EFI_OUT_OF_RESOURCES
;
538 // Create Event to wait for a key Ex
540 Status
= gBS
->CreateEvent (
543 ConSplitterTextInWaitForKey
,
545 &ConInPrivate
->TextInEx
.WaitForKeyEx
547 ASSERT_EFI_ERROR (Status
);
549 InitializeListHead (&ConInPrivate
->NotifyList
);
551 ConInPrivate
->AbsolutePointer
.Mode
= &ConInPrivate
->AbsolutePointerMode
;
553 // Allocate buffer for Absolute Pointer device
555 Status
= ConSplitterGrowBuffer (
556 sizeof (EFI_ABSOLUTE_POINTER_PROTOCOL
*),
557 &ConInPrivate
->AbsolutePointerListCount
,
558 (VOID
**) &ConInPrivate
->AbsolutePointerList
560 if (EFI_ERROR (Status
)) {
561 return EFI_OUT_OF_RESOURCES
;
564 // Create Event to wait for device input for Absolute pointer device
566 Status
= gBS
->CreateEvent (
569 ConSplitterAbsolutePointerWaitForInput
,
571 &ConInPrivate
->AbsolutePointer
.WaitForInput
573 ASSERT_EFI_ERROR (Status
);
575 ConInPrivate
->SimplePointer
.Mode
= &ConInPrivate
->SimplePointerMode
;
577 // Allocate buffer for Simple Pointer device
579 Status
= ConSplitterGrowBuffer (
580 sizeof (EFI_SIMPLE_POINTER_PROTOCOL
*),
581 &ConInPrivate
->PointerListCount
,
582 (VOID
**) &ConInPrivate
->PointerList
584 if (EFI_ERROR (Status
)) {
585 return EFI_OUT_OF_RESOURCES
;
588 // Create Event to wait for device input for Simple pointer device
590 Status
= gBS
->CreateEvent (
593 ConSplitterSimplePointerWaitForInput
,
595 &ConInPrivate
->SimplePointer
.WaitForInput
602 Construct console output devices' private data.
604 @param ConOutPrivate A pointer to the TEXT_OUT_SPLITTER_PRIVATE_DATA
607 @retval EFI_OUT_OF_RESOURCES Out of resources.
608 @retval EFI_SUCCESS Text Input Devcie's private data has been constructed.
612 ConSplitterTextOutConstructor (
613 TEXT_OUT_SPLITTER_PRIVATE_DATA
*ConOutPrivate
617 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*Info
;
620 // Copy protocols template
622 if (FeaturePcdGet (PcdConOutUgaSupport
)) {
623 CopyMem (&ConOutPrivate
->UgaDraw
, &mUgaDrawProtocolTemplate
, sizeof (EFI_UGA_DRAW_PROTOCOL
));
625 if (FeaturePcdGet (PcdConOutGopSupport
)) {
626 CopyMem (&ConOutPrivate
->GraphicsOutput
, &mGraphicsOutputProtocolTemplate
, sizeof (EFI_GRAPHICS_OUTPUT_PROTOCOL
));
630 // Initilize console output splitter's private data.
632 ConOutPrivate
->TextOut
.Mode
= &ConOutPrivate
->TextOutMode
;
635 // When new console device is added, the new mode will be set later,
636 // so put current mode back to init state.
638 ConOutPrivate
->TextOutMode
.Mode
= 0xFF;
640 // Allocate buffer for Console Out device
642 Status
= ConSplitterGrowBuffer (
643 sizeof (TEXT_OUT_AND_GOP_DATA
),
644 &ConOutPrivate
->TextOutListCount
,
645 (VOID
**) &ConOutPrivate
->TextOutList
647 if (EFI_ERROR (Status
)) {
648 return EFI_OUT_OF_RESOURCES
;
651 // Allocate buffer for Text Out query data
653 Status
= ConSplitterGrowBuffer (
654 sizeof (TEXT_OUT_SPLITTER_QUERY_DATA
),
655 &ConOutPrivate
->TextOutQueryDataCount
,
656 (VOID
**) &ConOutPrivate
->TextOutQueryData
658 if (EFI_ERROR (Status
)) {
659 return EFI_OUT_OF_RESOURCES
;
663 // Setup the default console to 80 x 25 and mode to 0
665 ConOutPrivate
->TextOutQueryData
[0].Columns
= 80;
666 ConOutPrivate
->TextOutQueryData
[0].Rows
= 25;
667 TextOutSetMode (ConOutPrivate
, 0);
670 if (FeaturePcdGet (PcdConOutUgaSupport
)) {
672 // Setup the UgaDraw to 800 x 600 x 32 bits per pixel, 60Hz.
674 ConSplitterUgaDrawSetMode (&ConOutPrivate
->UgaDraw
, 800, 600, 32, 60);
676 if (FeaturePcdGet (PcdConOutGopSupport
)) {
678 // Setup resource for mode information in Graphics Output Protocol interface
680 if ((ConOutPrivate
->GraphicsOutput
.Mode
= AllocateZeroPool (sizeof (EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE
))) == NULL
) {
681 return EFI_OUT_OF_RESOURCES
;
683 if ((ConOutPrivate
->GraphicsOutput
.Mode
->Info
= AllocateZeroPool (sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
))) == NULL
) {
684 return EFI_OUT_OF_RESOURCES
;
687 // Setup the DevNullGraphicsOutput to 800 x 600 x 32 bits per pixel
688 // DevNull will be updated to user-defined mode after driver has started.
690 if ((ConOutPrivate
->GraphicsOutputModeBuffer
= AllocateZeroPool (sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
))) == NULL
) {
691 return EFI_OUT_OF_RESOURCES
;
693 Info
= &ConOutPrivate
->GraphicsOutputModeBuffer
[0];
695 Info
->HorizontalResolution
= 800;
696 Info
->VerticalResolution
= 600;
697 Info
->PixelFormat
= PixelBltOnly
;
698 Info
->PixelsPerScanLine
= 800;
699 CopyMem (ConOutPrivate
->GraphicsOutput
.Mode
->Info
, Info
, sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
));
700 ConOutPrivate
->GraphicsOutput
.Mode
->SizeOfInfo
= sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
);
703 // Initialize the following items, theset items remain unchanged in GraphicsOutput->SetMode()
704 // GraphicsOutputMode->FrameBufferBase, GraphicsOutputMode->FrameBufferSize
706 ConOutPrivate
->GraphicsOutput
.Mode
->FrameBufferBase
= (EFI_PHYSICAL_ADDRESS
) (UINTN
) NULL
;
707 ConOutPrivate
->GraphicsOutput
.Mode
->FrameBufferSize
= 0;
709 ConOutPrivate
->GraphicsOutput
.Mode
->MaxMode
= 1;
711 // Initial current mode to unknown state, and then set to mode 0
713 ConOutPrivate
->GraphicsOutput
.Mode
->Mode
= 0xffff;
714 ConOutPrivate
->GraphicsOutput
.SetMode (&ConOutPrivate
->GraphicsOutput
, 0);
722 Test to see if the specified protocol could be supported on the specified device.
724 @param This Driver Binding protocol pointer.
725 @param ControllerHandle Handle of device to test.
726 @param Guid The specified protocol.
728 @retval EFI_SUCCESS The specified protocol is supported on this device.
729 @retval EFI_UNSUPPORTED The specified protocol attempts to be installed on virtul handle.
730 @retval other Failed to open specified protocol on this device.
734 ConSplitterSupported (
735 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
736 IN EFI_HANDLE ControllerHandle
,
744 // Make sure the Console Splitter does not attempt to attach to itself
746 if (ControllerHandle
== mConIn
.VirtualHandle
||
747 ControllerHandle
== mConOut
.VirtualHandle
||
748 ControllerHandle
== mStdErr
.VirtualHandle
750 return EFI_UNSUPPORTED
;
754 // Check to see whether the specific protocol could be opened BY_DRIVER
756 Status
= gBS
->OpenProtocol (
760 This
->DriverBindingHandle
,
762 EFI_OPEN_PROTOCOL_BY_DRIVER
765 if (EFI_ERROR (Status
)) {
772 This
->DriverBindingHandle
,
780 Test to see if Console In Device could be supported on the Controller.
782 @param This Driver Binding protocol instance pointer.
783 @param ControllerHandle Handle of device to test.
784 @param RemainingDevicePath Optional parameter use to pick a specific child
787 @retval EFI_SUCCESS This driver supports this device.
788 @retval other This driver does not support this device.
793 ConSplitterConInDriverBindingSupported (
794 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
795 IN EFI_HANDLE ControllerHandle
,
796 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
799 return ConSplitterSupported (
802 &gEfiConsoleInDeviceGuid
807 Test to see if Simple Pointer protocol could be supported on the Controller.
809 @param This Driver Binding protocol instance pointer.
810 @param ControllerHandle Handle of device to test.
811 @param RemainingDevicePath Optional parameter use to pick a specific child
814 @retval EFI_SUCCESS This driver supports this device.
815 @retval other This driver does not support this device.
820 ConSplitterSimplePointerDriverBindingSupported (
821 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
822 IN EFI_HANDLE ControllerHandle
,
823 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
826 return ConSplitterSupported (
829 &gEfiSimplePointerProtocolGuid
834 Test to see if Absolute Pointer protocol could be supported on the Controller.
836 @param This Driver Binding protocol instance pointer.
837 @param ControllerHandle Handle of device to test.
838 @param RemainingDevicePath Optional parameter use to pick a specific child
841 @retval EFI_SUCCESS This driver supports this device.
842 @retval other This driver does not support this device.
847 ConSplitterAbsolutePointerDriverBindingSupported (
848 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
849 IN EFI_HANDLE ControllerHandle
,
850 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
853 return ConSplitterSupported (
856 &gEfiAbsolutePointerProtocolGuid
862 Test to see if Console Out Device could be supported on the Controller.
864 @param This Driver Binding protocol instance pointer.
865 @param ControllerHandle Handle of device to test.
866 @param RemainingDevicePath Optional parameter use to pick a specific child
869 @retval EFI_SUCCESS This driver supports this device.
870 @retval other This driver does not support this device.
875 ConSplitterConOutDriverBindingSupported (
876 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
877 IN EFI_HANDLE ControllerHandle
,
878 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
881 return ConSplitterSupported (
884 &gEfiConsoleOutDeviceGuid
889 Test to see if Standard Error Device could be supported on the Controller.
891 @param This Driver Binding protocol instance pointer.
892 @param ControllerHandle Handle of device to test.
893 @param RemainingDevicePath Optional parameter use to pick a specific child
896 @retval EFI_SUCCESS This driver supports this device.
897 @retval other This driver does not support this device.
902 ConSplitterStdErrDriverBindingSupported (
903 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
904 IN EFI_HANDLE ControllerHandle
,
905 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
908 return ConSplitterSupported (
911 &gEfiStandardErrorDeviceGuid
917 Start ConSplitter on devcie handle by opening Console Device Guid on device handle
918 and the console virtual handle. And Get the console interface on controller handle.
920 @param This Driver Binding protocol instance pointer.
921 @param ControllerHandle Handle of device.
922 @param ConSplitterVirtualHandle Console virtual Handle.
923 @param DeviceGuid The specified Console Device, such as ConInDev,
925 @param InterfaceGuid The specified protocol to be opened.
926 @param Interface Protocol interface returned.
928 @retval EFI_SUCCESS This driver supports this device.
929 @retval other Failed to open the specified Console Device Guid
930 or specified protocol.
935 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
936 IN EFI_HANDLE ControllerHandle
,
937 IN EFI_HANDLE ConSplitterVirtualHandle
,
938 IN EFI_GUID
*DeviceGuid
,
939 IN EFI_GUID
*InterfaceGuid
,
947 // Check to see whether the ControllerHandle has the DeviceGuid on it.
949 Status
= gBS
->OpenProtocol (
953 This
->DriverBindingHandle
,
955 EFI_OPEN_PROTOCOL_BY_DRIVER
957 if (EFI_ERROR (Status
)) {
962 // Open the Parent Handle for the child.
964 Status
= gBS
->OpenProtocol (
968 This
->DriverBindingHandle
,
969 ConSplitterVirtualHandle
,
970 EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
972 if (EFI_ERROR (Status
)) {
977 // Open InterfaceGuid on the virtul handle.
979 Status
= gBS
->OpenProtocol (
983 This
->DriverBindingHandle
,
984 ConSplitterVirtualHandle
,
985 EFI_OPEN_PROTOCOL_GET_PROTOCOL
988 if (!EFI_ERROR (Status
)) {
993 // close the DeviceGuid on ConSplitter VirtualHandle.
998 This
->DriverBindingHandle
,
999 ConSplitterVirtualHandle
1004 // close the DeviceGuid on ControllerHandle.
1006 gBS
->CloseProtocol (
1009 This
->DriverBindingHandle
,
1018 Start Console In Consplitter on device handle.
1020 @param This Driver Binding protocol instance pointer.
1021 @param ControllerHandle Handle of device to bind driver to.
1022 @param RemainingDevicePath Optional parameter use to pick a specific child
1025 @retval EFI_SUCCESS Console In Consplitter is added to ControllerHandle.
1026 @retval other Console In Consplitter does not support this device.
1031 ConSplitterConInDriverBindingStart (
1032 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1033 IN EFI_HANDLE ControllerHandle
,
1034 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
1038 EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*TextIn
;
1039 EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*TextInEx
;
1042 // Start ConSplitter on ControllerHandle, and create the virtual
1043 // agrogated console device on first call Start for a SimpleTextIn handle.
1045 Status
= ConSplitterStart (
1048 mConIn
.VirtualHandle
,
1049 &gEfiConsoleInDeviceGuid
,
1050 &gEfiSimpleTextInProtocolGuid
,
1053 if (EFI_ERROR (Status
)) {
1058 // Add this device into Text In devices list.
1060 Status
= ConSplitterTextInAddDevice (&mConIn
, TextIn
);
1061 if (EFI_ERROR (Status
)) {
1065 Status
= gBS
->OpenProtocol (
1067 &gEfiSimpleTextInputExProtocolGuid
,
1068 (VOID
**) &TextInEx
,
1069 This
->DriverBindingHandle
,
1070 mConIn
.VirtualHandle
,
1071 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1073 if (!EFI_ERROR (Status
)) {
1075 // If Simple Text Input Ex protocol exists,
1076 // add this device into Text In Ex devices list.
1078 Status
= ConSplitterTextInExAddDevice (&mConIn
, TextInEx
);
1086 Start Simple Pointer Consplitter on device handle.
1088 @param This Driver Binding protocol instance pointer.
1089 @param ControllerHandle Handle of device to bind driver to.
1090 @param RemainingDevicePath Optional parameter use to pick a specific child
1093 @retval EFI_SUCCESS Simple Pointer Consplitter is added to ControllerHandle.
1094 @retval other Simple Pointer Consplitter does not support this device.
1099 ConSplitterSimplePointerDriverBindingStart (
1100 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1101 IN EFI_HANDLE ControllerHandle
,
1102 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
1106 EFI_SIMPLE_POINTER_PROTOCOL
*SimplePointer
;
1109 // Start ConSplitter on ControllerHandle, and create the virtual
1110 // agrogated console device on first call Start for a SimplePointer handle.
1112 Status
= ConSplitterStart (
1115 mConIn
.VirtualHandle
,
1116 &gEfiSimplePointerProtocolGuid
,
1117 &gEfiSimplePointerProtocolGuid
,
1118 (VOID
**) &SimplePointer
1120 if (EFI_ERROR (Status
)) {
1125 // Add this devcie into Simple Pointer devices list.
1127 return ConSplitterSimplePointerAddDevice (&mConIn
, SimplePointer
);
1132 Start Absolute Pointer Consplitter on device handle.
1134 @param This Driver Binding protocol instance pointer.
1135 @param ControllerHandle Handle of device to bind driver to.
1136 @param RemainingDevicePath Optional parameter use to pick a specific child
1139 @retval EFI_SUCCESS Absolute Pointer Consplitter is added to ControllerHandle.
1140 @retval other Absolute Pointer Consplitter does not support this device.
1145 ConSplitterAbsolutePointerDriverBindingStart (
1146 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1147 IN EFI_HANDLE ControllerHandle
,
1148 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
1152 EFI_ABSOLUTE_POINTER_PROTOCOL
*AbsolutePointer
;
1155 // Start ConSplitter on ControllerHandle, and create the virtual
1156 // agrogated console device on first call Start for a AbsolutePointer handle.
1158 Status
= ConSplitterStart (
1161 mConIn
.VirtualHandle
,
1162 &gEfiAbsolutePointerProtocolGuid
,
1163 &gEfiAbsolutePointerProtocolGuid
,
1164 (VOID
**) &AbsolutePointer
1167 if (EFI_ERROR (Status
)) {
1172 // Add this devcie into Absolute Pointer devices list.
1174 return ConSplitterAbsolutePointerAddDevice (&mConIn
, AbsolutePointer
);
1179 Start Console Out Consplitter on device handle.
1181 @param This Driver Binding protocol instance pointer.
1182 @param ControllerHandle Handle of device to bind driver to.
1183 @param RemainingDevicePath Optional parameter use to pick a specific child
1186 @retval EFI_SUCCESS Console Out Consplitter is added to ControllerHandle.
1187 @retval other Console Out Consplitter does not support this device.
1192 ConSplitterConOutDriverBindingStart (
1193 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1194 IN EFI_HANDLE ControllerHandle
,
1195 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
1199 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
;
1200 EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
;
1201 EFI_UGA_DRAW_PROTOCOL
*UgaDraw
;
1203 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*Info
;
1206 // Start ConSplitter on ControllerHandle, and create the virtual
1207 // agrogated console device on first call Start for a ConsoleOut handle.
1209 Status
= ConSplitterStart (
1212 mConOut
.VirtualHandle
,
1213 &gEfiConsoleOutDeviceGuid
,
1214 &gEfiSimpleTextOutProtocolGuid
,
1217 if (EFI_ERROR (Status
)) {
1221 GraphicsOutput
= NULL
;
1224 // Try to Open Graphics Output protocol
1226 Status
= gBS
->OpenProtocol (
1228 &gEfiGraphicsOutputProtocolGuid
,
1229 (VOID
**) &GraphicsOutput
,
1230 This
->DriverBindingHandle
,
1231 mConOut
.VirtualHandle
,
1232 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1235 if (EFI_ERROR (Status
) && FeaturePcdGet (PcdUgaConsumeSupport
)) {
1237 // Open UGA DRAW protocol
1241 &gEfiUgaDrawProtocolGuid
,
1243 This
->DriverBindingHandle
,
1244 mConOut
.VirtualHandle
,
1245 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1250 // When new console device is added, the new mode will be set later,
1251 // so put current mode back to init state.
1253 mConOut
.TextOutMode
.Mode
= 0xFF;
1256 // If both ConOut and StdErr incorporate the same Text Out device,
1257 // their MaxMode and QueryData should be the intersection of both.
1259 Status
= ConSplitterTextOutAddDevice (&mConOut
, TextOut
, GraphicsOutput
, UgaDraw
);
1260 ConSplitterTextOutSetAttribute (&mConOut
.TextOut
, EFI_TEXT_ATTR (EFI_LIGHTGRAY
, EFI_BLACK
));
1262 if (FeaturePcdGet (PcdConOutUgaSupport
)) {
1264 // Get the UGA mode data of ConOut from the current mode
1266 if (GraphicsOutput
!= NULL
) {
1267 Status
= GraphicsOutput
->QueryMode (GraphicsOutput
, GraphicsOutput
->Mode
->Mode
, &SizeOfInfo
, &Info
);
1268 if (EFI_ERROR (Status
)) {
1271 ASSERT ( SizeOfInfo
<= sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
));
1273 mConOut
.UgaHorizontalResolution
= Info
->HorizontalResolution
;
1274 mConOut
.UgaVerticalResolution
= Info
->VerticalResolution
;
1275 mConOut
.UgaColorDepth
= 32;
1276 mConOut
.UgaRefreshRate
= 60;
1280 } else if (UgaDraw
!= NULL
&& FeaturePcdGet (PcdUgaConsumeSupport
)) {
1281 Status
= UgaDraw
->GetMode (
1283 &mConOut
.UgaHorizontalResolution
,
1284 &mConOut
.UgaVerticalResolution
,
1285 &mConOut
.UgaColorDepth
,
1286 &mConOut
.UgaRefreshRate
1296 Start Standard Error Consplitter on device handle.
1298 @param This Driver Binding protocol instance pointer.
1299 @param ControllerHandle Handle of device to bind driver to.
1300 @param RemainingDevicePath Optional parameter use to pick a specific child
1303 @retval EFI_SUCCESS Standard Error Consplitter is added to ControllerHandle.
1304 @retval other Standard Error Consplitter does not support this device.
1309 ConSplitterStdErrDriverBindingStart (
1310 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1311 IN EFI_HANDLE ControllerHandle
,
1312 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
1316 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
;
1318 if (mStdErr
.CurrentNumberOfConsoles
== 0) {
1320 // Construct console output devices' private data
1322 Status
= ConSplitterTextOutConstructor (&mStdErr
);
1323 if (!EFI_ERROR (Status
)) {
1325 // Create virtual device handle for StdErr Splitter
1327 Status
= gBS
->InstallMultipleProtocolInterfaces (
1328 &mStdErr
.VirtualHandle
,
1329 &gEfiSimpleTextOutProtocolGuid
,
1334 if (EFI_ERROR (Status
)) {
1341 // Start ConSplitter on ControllerHandle, and create the virtual
1342 // agrogated console device on first call Start for a StandardError handle.
1344 Status
= ConSplitterStart (
1347 mStdErr
.VirtualHandle
,
1348 &gEfiStandardErrorDeviceGuid
,
1349 &gEfiSimpleTextOutProtocolGuid
,
1352 if (EFI_ERROR (Status
)) {
1357 // When new console device is added, the new mode will be set later,
1358 // so put current mode back to init state.
1360 mStdErr
.TextOutMode
.Mode
= 0xFF;
1363 // If both ConOut and StdErr incorporate the same Text Out device,
1364 // their MaxMode and QueryData should be the intersection of both.
1366 Status
= ConSplitterTextOutAddDevice (&mStdErr
, TextOut
, NULL
, NULL
);
1367 ConSplitterTextOutSetAttribute (&mStdErr
.TextOut
, EFI_TEXT_ATTR (EFI_MAGENTA
, EFI_BLACK
));
1368 if (EFI_ERROR (Status
)) {
1372 if (mStdErr
.CurrentNumberOfConsoles
== 1) {
1373 gST
->StandardErrorHandle
= mStdErr
.VirtualHandle
;
1374 gST
->StdErr
= &mStdErr
.TextOut
;
1376 // Update the CRC32 in the EFI System Table header
1379 gBS
->CalculateCrc32 (
1380 (UINT8
*) &gST
->Hdr
,
1381 gST
->Hdr
.HeaderSize
,
1391 Stop ConSplitter on device handle by closing Console Device Guid on device handle
1392 and the console virtual handle.
1394 @param This Protocol instance pointer.
1395 @param ControllerHandle Handle of device.
1396 @param ConSplitterVirtualHandle Console virtual Handle.
1397 @param DeviceGuid The specified Console Device, such as ConInDev,
1399 @param InterfaceGuid The specified protocol to be opened.
1400 @param Interface Protocol interface returned.
1402 @retval EFI_SUCCESS Stop ConSplitter on ControllerHandle successfully.
1403 @retval other Failed to Stop ConSplitter on ControllerHandle.
1408 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1409 IN EFI_HANDLE ControllerHandle
,
1410 IN EFI_HANDLE ConSplitterVirtualHandle
,
1411 IN EFI_GUID
*DeviceGuid
,
1412 IN EFI_GUID
*InterfaceGuid
,
1418 Status
= gBS
->OpenProtocol (
1422 This
->DriverBindingHandle
,
1424 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1426 if (EFI_ERROR (Status
)) {
1430 // close the protocol refered.
1432 gBS
->CloseProtocol (
1435 This
->DriverBindingHandle
,
1436 ConSplitterVirtualHandle
1439 gBS
->CloseProtocol (
1442 This
->DriverBindingHandle
,
1451 Stop Console In ConSplitter on ControllerHandle by closing Console In Devcice GUID.
1453 @param This Driver Binding protocol instance pointer.
1454 @param ControllerHandle Handle of device to stop driver on
1455 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
1456 children is zero stop the entire bus driver.
1457 @param ChildHandleBuffer List of Child Handles to Stop.
1459 @retval EFI_SUCCESS This driver is removed ControllerHandle
1460 @retval other This driver was not removed from this device
1465 ConSplitterConInDriverBindingStop (
1466 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1467 IN EFI_HANDLE ControllerHandle
,
1468 IN UINTN NumberOfChildren
,
1469 IN EFI_HANDLE
*ChildHandleBuffer
1473 EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*TextIn
;
1474 EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*TextInEx
;
1476 if (NumberOfChildren
== 0) {
1480 Status
= gBS
->OpenProtocol (
1482 &gEfiSimpleTextInputExProtocolGuid
,
1483 (VOID
**) &TextInEx
,
1484 This
->DriverBindingHandle
,
1486 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1488 if (!EFI_ERROR (Status
)) {
1490 // If Simple Text Input Ex protocol exists,
1491 // remove device from Text Input Ex devices list.
1493 Status
= ConSplitterTextInExDeleteDevice (&mConIn
, TextInEx
);
1494 if (EFI_ERROR (Status
)) {
1500 // Close Simple Text In protocol on controller handle and virtual handle.
1502 Status
= ConSplitterStop (
1505 mConIn
.VirtualHandle
,
1506 &gEfiConsoleInDeviceGuid
,
1507 &gEfiSimpleTextInProtocolGuid
,
1510 if (EFI_ERROR (Status
)) {
1515 // Remove device from Text Input devices list.
1517 return ConSplitterTextInDeleteDevice (&mConIn
, TextIn
);
1522 Stop Simple Pointer protocol ConSplitter on ControllerHandle by closing
1523 Simple Pointer protocol.
1525 @param This Driver Binding protocol instance pointer.
1526 @param ControllerHandle Handle of device to stop driver on
1527 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
1528 children is zero stop the entire bus driver.
1529 @param ChildHandleBuffer List of Child Handles to Stop.
1531 @retval EFI_SUCCESS This driver is removed ControllerHandle
1532 @retval other This driver was not removed from this device
1537 ConSplitterSimplePointerDriverBindingStop (
1538 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1539 IN EFI_HANDLE ControllerHandle
,
1540 IN UINTN NumberOfChildren
,
1541 IN EFI_HANDLE
*ChildHandleBuffer
1545 EFI_SIMPLE_POINTER_PROTOCOL
*SimplePointer
;
1547 if (NumberOfChildren
== 0) {
1552 // Close Simple Pointer protocol on controller handle and virtual handle.
1554 Status
= ConSplitterStop (
1557 mConIn
.VirtualHandle
,
1558 &gEfiSimplePointerProtocolGuid
,
1559 &gEfiSimplePointerProtocolGuid
,
1560 (VOID
**) &SimplePointer
1562 if (EFI_ERROR (Status
)) {
1567 // Remove this device from Simple Pointer device list.
1569 return ConSplitterSimplePointerDeleteDevice (&mConIn
, SimplePointer
);
1574 Stop Absolute Pointer protocol ConSplitter on ControllerHandle by closing
1575 Absolute Pointer protocol.
1577 @param This Driver Binding protocol instance pointer.
1578 @param ControllerHandle Handle of device to stop driver on
1579 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
1580 children is zero stop the entire bus driver.
1581 @param ChildHandleBuffer List of Child Handles to Stop.
1583 @retval EFI_SUCCESS This driver is removed ControllerHandle
1584 @retval other This driver was not removed from this device
1589 ConSplitterAbsolutePointerDriverBindingStop (
1590 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1591 IN EFI_HANDLE ControllerHandle
,
1592 IN UINTN NumberOfChildren
,
1593 IN EFI_HANDLE
*ChildHandleBuffer
1597 EFI_ABSOLUTE_POINTER_PROTOCOL
*AbsolutePointer
;
1599 if (NumberOfChildren
== 0) {
1604 // Close Absolute Pointer protocol on controller handle and virtual handle.
1606 Status
= ConSplitterStop (
1609 mConIn
.VirtualHandle
,
1610 &gEfiAbsolutePointerProtocolGuid
,
1611 &gEfiAbsolutePointerProtocolGuid
,
1612 (VOID
**) &AbsolutePointer
1614 if (EFI_ERROR (Status
)) {
1619 // Remove this device from Absolute Pointer device list.
1621 return ConSplitterAbsolutePointerDeleteDevice (&mConIn
, AbsolutePointer
);
1626 Stop Console Out ConSplitter on device handle by closing Console Out Devcice GUID.
1628 @param This Driver Binding protocol instance pointer.
1629 @param ControllerHandle Handle of device to stop driver on
1630 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
1631 children is zero stop the entire bus driver.
1632 @param ChildHandleBuffer List of Child Handles to Stop.
1634 @retval EFI_SUCCESS This driver is removed ControllerHandle
1635 @retval other This driver was not removed from this device
1640 ConSplitterConOutDriverBindingStop (
1641 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1642 IN EFI_HANDLE ControllerHandle
,
1643 IN UINTN NumberOfChildren
,
1644 IN EFI_HANDLE
*ChildHandleBuffer
1648 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
;
1650 if (NumberOfChildren
== 0) {
1655 // Close Absolute Pointer protocol on controller handle and virtual handle.
1657 Status
= ConSplitterStop (
1660 mConOut
.VirtualHandle
,
1661 &gEfiConsoleOutDeviceGuid
,
1662 &gEfiSimpleTextOutProtocolGuid
,
1665 if (EFI_ERROR (Status
)) {
1670 // Remove this device from Text Out device list.
1672 return ConSplitterTextOutDeleteDevice (&mConOut
, TextOut
);
1677 Stop Standard Error ConSplitter on ControllerHandle by closing Standard Error GUID.
1679 @param This Driver Binding protocol instance pointer.
1680 @param ControllerHandle Handle of device to stop driver on
1681 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
1682 children is zero stop the entire bus driver.
1683 @param ChildHandleBuffer List of Child Handles to Stop.
1685 @retval EFI_SUCCESS This driver is removed ControllerHandle
1686 @retval other This driver was not removed from this device
1691 ConSplitterStdErrDriverBindingStop (
1692 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1693 IN EFI_HANDLE ControllerHandle
,
1694 IN UINTN NumberOfChildren
,
1695 IN EFI_HANDLE
*ChildHandleBuffer
1699 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
;
1701 if (NumberOfChildren
== 0) {
1706 // Close Standard Error Device on controller handle and virtual handle.
1708 Status
= ConSplitterStop (
1711 mStdErr
.VirtualHandle
,
1712 &gEfiStandardErrorDeviceGuid
,
1713 &gEfiSimpleTextOutProtocolGuid
,
1716 if (EFI_ERROR (Status
)) {
1720 // Delete this console error out device's data structures.
1722 Status
= ConSplitterTextOutDeleteDevice (&mStdErr
, TextOut
);
1723 if (EFI_ERROR (Status
)) {
1727 if (mStdErr
.CurrentNumberOfConsoles
== 0) {
1728 mStdErr
.VirtualHandle
= NULL
;
1730 gST
->StandardErrorHandle
= NULL
;
1733 // Update the CRC32 in the EFI System Table header
1736 gBS
->CalculateCrc32 (
1737 (UINT8
*) &gST
->Hdr
,
1738 gST
->Hdr
.HeaderSize
,
1743 // Uninstall Simple Text Output protocol from StdErr Handle.
1745 gBS
->UninstallMultipleProtocolInterfaces (
1746 mStdErr
.VirtualHandle
,
1747 &gEfiSimpleTextOutProtocolGuid
,
1758 Take the passed in Buffer of size SizeOfCount and grow the buffer
1759 by MAX (CONSOLE_SPLITTER_CONSOLES_ALLOC_UNIT, MaxGrow) * SizeOfCount
1760 bytes. Copy the current data in Buffer to the new version of Buffer
1761 and free the old version of buffer.
1763 @param SizeOfCount Size of element in array.
1764 @param Count Current number of elements in array.
1765 @param Buffer Bigger version of passed in Buffer with all the
1768 @retval EFI_SUCCESS Buffer size has grown.
1769 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
1773 ConSplitterGrowBuffer (
1774 IN UINTN SizeOfCount
,
1775 IN OUT UINTN
*Count
,
1776 IN OUT VOID
**Buffer
1782 // grow the buffer to new buffer size,
1783 // copy the old buffer's content to the new-size buffer,
1784 // then free the old buffer.
1786 *Count
+= CONSOLE_SPLITTER_CONSOLES_ALLOC_UNIT
;
1787 Ptr
= ReallocatePool (
1788 SizeOfCount
* ((*Count
) - CONSOLE_SPLITTER_CONSOLES_ALLOC_UNIT
),
1789 SizeOfCount
* (*Count
),
1793 return EFI_OUT_OF_RESOURCES
;
1801 Add Text Input Device in Consplitter Text Input list.
1803 @param Private Text In Splitter pointer.
1804 @param TextIn Simple Text Input protocol pointer.
1806 @retval EFI_SUCCESS Text Input Device added successfully.
1807 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
1811 ConSplitterTextInAddDevice (
1812 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
1813 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*TextIn
1819 // If the Text In List is full, enlarge it by calling ConSplitterGrowBuffer().
1821 if (Private
->CurrentNumberOfConsoles
>= Private
->TextInListCount
) {
1822 Status
= ConSplitterGrowBuffer (
1823 sizeof (EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*),
1824 &Private
->TextInListCount
,
1825 (VOID
**) &Private
->TextInList
1827 if (EFI_ERROR (Status
)) {
1828 return EFI_OUT_OF_RESOURCES
;
1832 // Add the new text-in device data structure into the Text In List.
1834 Private
->TextInList
[Private
->CurrentNumberOfConsoles
] = TextIn
;
1835 Private
->CurrentNumberOfConsoles
++;
1838 // Extra CheckEvent added to reduce the double CheckEvent().
1840 gBS
->CheckEvent (TextIn
->WaitForKey
);
1847 Remove Text Input Device from Consplitter Text Input list.
1849 @param Private Text In Splitter pointer.
1850 @param TextIn Simple Text protocol pointer.
1852 @retval EFI_SUCCESS Simple Text Device removed successfully.
1853 @retval EFI_NOT_FOUND No Simple Text Device found.
1857 ConSplitterTextInDeleteDevice (
1858 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
1859 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*TextIn
1864 // Remove the specified text-in device data structure from the Text In List,
1865 // and rearrange the remaining data structures in the Text In List.
1867 for (Index
= 0; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
1868 if (Private
->TextInList
[Index
] == TextIn
) {
1869 for (Index
= Index
; Index
< Private
->CurrentNumberOfConsoles
- 1; Index
++) {
1870 Private
->TextInList
[Index
] = Private
->TextInList
[Index
+ 1];
1873 Private
->CurrentNumberOfConsoles
--;
1878 return EFI_NOT_FOUND
;
1882 Add Text Input Ex Device in Consplitter Text Input Ex list.
1884 @param Private Text In Splitter pointer.
1885 @param TextInEx Simple Text Input Ex Input protocol pointer.
1887 @retval EFI_SUCCESS Text Input Ex Device added successfully.
1888 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
1892 ConSplitterTextInExAddDevice (
1893 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
1894 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*TextInEx
1900 // If the Text Input Ex List is full, enlarge it by calling ConSplitterGrowBuffer().
1902 if (Private
->CurrentNumberOfExConsoles
>= Private
->TextInExListCount
) {
1903 Status
= ConSplitterGrowBuffer (
1904 sizeof (EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*),
1905 &Private
->TextInExListCount
,
1906 (VOID
**) &Private
->TextInExList
1908 if (EFI_ERROR (Status
)) {
1909 return EFI_OUT_OF_RESOURCES
;
1913 // Add the new text-in device data structure into the Text Input Ex List.
1915 Private
->TextInExList
[Private
->CurrentNumberOfExConsoles
] = TextInEx
;
1916 Private
->CurrentNumberOfExConsoles
++;
1919 // Extra CheckEvent added to reduce the double CheckEvent().
1921 gBS
->CheckEvent (TextInEx
->WaitForKeyEx
);
1927 Remove Text Ex Device from Consplitter Text Input Ex list.
1929 @param Private Text In Splitter pointer.
1930 @param TextInEx Simple Text Ex protocol pointer.
1932 @retval EFI_SUCCESS Simple Text Input Ex Device removed successfully.
1933 @retval EFI_NOT_FOUND No Simple Text Input Ex Device found.
1937 ConSplitterTextInExDeleteDevice (
1938 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
1939 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*TextInEx
1944 // Remove the specified text-in device data structure from the Text Input Ex List,
1945 // and rearrange the remaining data structures in the Text In List.
1947 for (Index
= 0; Index
< Private
->CurrentNumberOfExConsoles
; Index
++) {
1948 if (Private
->TextInExList
[Index
] == TextInEx
) {
1949 for (Index
= Index
; Index
< Private
->CurrentNumberOfExConsoles
- 1; Index
++) {
1950 Private
->TextInExList
[Index
] = Private
->TextInExList
[Index
+ 1];
1953 Private
->CurrentNumberOfExConsoles
--;
1958 return EFI_NOT_FOUND
;
1963 Add Simple Pointer Device in Consplitter Simple Pointer list.
1965 @param Private Text In Splitter pointer.
1966 @param SimplePointer Simple Pointer protocol pointer.
1968 @retval EFI_SUCCESS Simple Pointer Device added successfully.
1969 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
1973 ConSplitterSimplePointerAddDevice (
1974 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
1975 IN EFI_SIMPLE_POINTER_PROTOCOL
*SimplePointer
1981 // If the Simple Pointer List is full, enlarge it by calling ConSplitterGrowBuffer().
1983 if (Private
->CurrentNumberOfPointers
>= Private
->PointerListCount
) {
1984 Status
= ConSplitterGrowBuffer (
1985 sizeof (EFI_SIMPLE_POINTER_PROTOCOL
*),
1986 &Private
->PointerListCount
,
1987 (VOID
**) &Private
->PointerList
1989 if (EFI_ERROR (Status
)) {
1990 return EFI_OUT_OF_RESOURCES
;
1994 // Add the new text-in device data structure into the Simple Pointer List.
1996 Private
->PointerList
[Private
->CurrentNumberOfPointers
] = SimplePointer
;
1997 Private
->CurrentNumberOfPointers
++;
2004 Remove Simple Pointer Device from Consplitter Simple Pointer list.
2006 @param Private Text In Splitter pointer.
2007 @param SimplePointer Simple Pointer protocol pointer.
2009 @retval EFI_SUCCESS Simple Pointer Device removed successfully.
2010 @retval EFI_NOT_FOUND No Simple Pointer Device found.
2014 ConSplitterSimplePointerDeleteDevice (
2015 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
2016 IN EFI_SIMPLE_POINTER_PROTOCOL
*SimplePointer
2021 // Remove the specified text-in device data structure from the Simple Pointer List,
2022 // and rearrange the remaining data structures in the Text In List.
2024 for (Index
= 0; Index
< Private
->CurrentNumberOfPointers
; Index
++) {
2025 if (Private
->PointerList
[Index
] == SimplePointer
) {
2026 for (Index
= Index
; Index
< Private
->CurrentNumberOfPointers
- 1; Index
++) {
2027 Private
->PointerList
[Index
] = Private
->PointerList
[Index
+ 1];
2030 Private
->CurrentNumberOfPointers
--;
2035 return EFI_NOT_FOUND
;
2040 Add Absolute Pointer Device in Consplitter Absolute Pointer list.
2042 @param Private Text In Splitter pointer.
2043 @param AbsolutePointer Absolute Pointer protocol pointer.
2045 @retval EFI_SUCCESS Absolute Pointer Device added successfully.
2046 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
2050 ConSplitterAbsolutePointerAddDevice (
2051 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
2052 IN EFI_ABSOLUTE_POINTER_PROTOCOL
*AbsolutePointer
2058 // If the Absolute Pointer List is full, enlarge it by calling ConSplitterGrowBuffer().
2060 if (Private
->CurrentNumberOfAbsolutePointers
>= Private
->AbsolutePointerListCount
) {
2061 Status
= ConSplitterGrowBuffer (
2062 sizeof (EFI_ABSOLUTE_POINTER_PROTOCOL
*),
2063 &Private
->AbsolutePointerListCount
,
2064 (VOID
**) &Private
->AbsolutePointerList
2066 if (EFI_ERROR (Status
)) {
2067 return EFI_OUT_OF_RESOURCES
;
2071 // Add the new text-in device data structure into the Absolute Pointer List.
2073 Private
->AbsolutePointerList
[Private
->CurrentNumberOfAbsolutePointers
] = AbsolutePointer
;
2074 Private
->CurrentNumberOfAbsolutePointers
++;
2081 Remove Absolute Pointer Device from Consplitter Absolute Pointer list.
2083 @param Private Text In Splitter pointer.
2084 @param AbsolutePointer Absolute Pointer protocol pointer.
2086 @retval EFI_SUCCESS Absolute Pointer Device removed successfully.
2087 @retval EFI_NOT_FOUND No Absolute Pointer Device found.
2091 ConSplitterAbsolutePointerDeleteDevice (
2092 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
2093 IN EFI_ABSOLUTE_POINTER_PROTOCOL
*AbsolutePointer
2098 // Remove the specified text-in device data structure from the Absolute Pointer List,
2099 // and rearrange the remaining data structures from the Absolute Pointer List.
2101 for (Index
= 0; Index
< Private
->CurrentNumberOfAbsolutePointers
; Index
++) {
2102 if (Private
->AbsolutePointerList
[Index
] == AbsolutePointer
) {
2103 for (Index
= Index
; Index
< Private
->CurrentNumberOfAbsolutePointers
- 1; Index
++) {
2104 Private
->AbsolutePointerList
[Index
] = Private
->AbsolutePointerList
[Index
+ 1];
2107 Private
->CurrentNumberOfAbsolutePointers
--;
2112 return EFI_NOT_FOUND
;
2116 Reallocate Text Out mode map.
2118 Allocate new buffer and copy original buffer into the new buffer.
2120 @param Private Consplitter Text Out pointer.
2122 @retval EFI_SUCCESS Buffer size has grown
2123 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
2127 ConSplitterGrowMapTable (
2128 IN TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
2134 INT32
*TextOutModeMap
;
2135 INT32
*OldTextOutModeMap
;
2139 NewSize
= Private
->TextOutListCount
* sizeof (INT32
);
2140 OldTextOutModeMap
= Private
->TextOutModeMap
;
2141 TotalSize
= NewSize
* (Private
->TextOutQueryDataCount
);
2144 // Allocate new buffer for Text Out List.
2146 TextOutModeMap
= AllocatePool (TotalSize
);
2147 if (TextOutModeMap
== NULL
) {
2148 return EFI_OUT_OF_RESOURCES
;
2151 SetMem (TextOutModeMap
, TotalSize
, 0xFF);
2152 Private
->TextOutModeMap
= TextOutModeMap
;
2155 // If TextOutList has been enlarged, need to realloc the mode map table
2156 // The mode map table is regarded as a two dimension array.
2159 // 0 ---------> TextOutListCount ----> TextOutListCount
2160 // | -------------------------------------------
2167 // -------------------------------------------
2170 if (OldTextOutModeMap
!= NULL
) {
2172 Size
= Private
->CurrentNumberOfConsoles
* sizeof (INT32
);
2174 SrcAddress
= OldTextOutModeMap
;
2177 // Copy the old data to the new one
2179 while (Index
< Private
->TextOutMode
.MaxMode
) {
2180 CopyMem (TextOutModeMap
, SrcAddress
, Size
);
2181 TextOutModeMap
+= NewSize
;
2186 // Free the old buffer
2188 FreePool (OldTextOutModeMap
);
2196 Add new device's output mode to console splitter's mode list.
2198 @param Private Text Out Splitter pointer
2199 @param TextOut Simple Text Output protocol pointer.
2201 @retval EFI_SUCCESS Device added successfully.
2202 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
2206 ConSplitterAddOutputMode (
2207 IN TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
,
2208 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
2216 MaxMode
= TextOut
->Mode
->MaxMode
;
2217 Private
->TextOutMode
.MaxMode
= MaxMode
;
2220 // Grow the buffer if query data buffer is not large enough to
2221 // hold all the mode supported by the first console.
2223 while (MaxMode
> (INT32
) Private
->TextOutQueryDataCount
) {
2224 Status
= ConSplitterGrowBuffer (
2225 sizeof (TEXT_OUT_SPLITTER_QUERY_DATA
),
2226 &Private
->TextOutQueryDataCount
,
2227 (VOID
**) &Private
->TextOutQueryData
2229 if (EFI_ERROR (Status
)) {
2230 return EFI_OUT_OF_RESOURCES
;
2234 // Allocate buffer for the output mode map
2236 Status
= ConSplitterGrowMapTable (Private
);
2237 if (EFI_ERROR (Status
)) {
2238 return EFI_OUT_OF_RESOURCES
;
2241 // As the first textout device, directly add the mode in to QueryData
2242 // and at the same time record the mapping between QueryData and TextOut.
2246 while (Mode
< MaxMode
) {
2247 Status
= TextOut
->QueryMode (
2250 &Private
->TextOutQueryData
[Mode
].Columns
,
2251 &Private
->TextOutQueryData
[Mode
].Rows
2254 // If mode 1 (80x50) is not supported, make sure mode 1 in TextOutQueryData
2257 if ((EFI_ERROR(Status
)) && (Mode
== 1)) {
2258 Private
->TextOutQueryData
[Mode
].Columns
= 0;
2259 Private
->TextOutQueryData
[Mode
].Rows
= 0;
2261 Private
->TextOutModeMap
[Index
] = Mode
;
2263 Index
+= Private
->TextOutListCount
;
2270 Reconstruct TextOutModeMap to get intersection of modes.
2272 This routine reconstruct TextOutModeMap to get the intersection
2273 of modes for all console out devices. Because EFI/UEFI spec require
2274 mode 0 is 80x25, mode 1 is 80x50, this routine will not check the
2275 intersection for mode 0 and mode 1.
2277 @param TextOutModeMap Current text out mode map, begin with the mode 80x25
2278 @param NewlyAddedMap New text out mode map, begin with the mode 80x25
2279 @param MapStepSize Mode step size for one console device
2280 @param NewMapStepSize New Mode step size for one console device
2281 @param MaxMode IN: Current max text mode, OUT: Updated max text mode.
2282 @param CurrentMode IN: Current text mode, OUT: Updated current text mode.
2286 ConSplitterGetIntersection (
2287 IN INT32
*TextOutModeMap
,
2288 IN INT32
*NewlyAddedMap
,
2289 IN UINTN MapStepSize
,
2290 IN UINTN NewMapStepSize
,
2291 IN OUT INT32
*MaxMode
,
2292 IN OUT INT32
*CurrentMode
2296 INT32
*CurrentMapEntry
;
2297 INT32
*NextMapEntry
;
2299 INT32 CurrentMaxMode
;
2303 // According to EFI/UEFI spec, mode 0 and mode 1 have been reserved
2304 // for 80x25 and 80x50 in Simple Text Out protocol, so don't make intersection
2305 // for mode 0 and mode 1, mode number starts from 2.
2308 CurrentMapEntry
= &TextOutModeMap
[MapStepSize
* 2];
2309 NextMapEntry
= CurrentMapEntry
;
2310 NewMapEntry
= &NewlyAddedMap
[NewMapStepSize
* 2];
2312 CurrentMaxMode
= *MaxMode
;
2313 Mode
= *CurrentMode
;
2315 while (Index
< CurrentMaxMode
) {
2316 if (*NewMapEntry
== -1) {
2318 // This mode is not supported any more. Remove it. Special care
2319 // must be taken as this remove will also affect current mode;
2321 if (Index
== *CurrentMode
) {
2323 } else if (Index
< *CurrentMode
) {
2328 if (CurrentMapEntry
!= NextMapEntry
) {
2329 CopyMem (NextMapEntry
, CurrentMapEntry
, MapStepSize
* sizeof (INT32
));
2332 NextMapEntry
+= MapStepSize
;
2335 CurrentMapEntry
+= MapStepSize
;
2336 NewMapEntry
+= NewMapStepSize
;
2340 *CurrentMode
= Mode
;
2346 Sync the device's output mode to console splitter's mode list.
2348 @param Private Text Out Splitter pointer.
2349 @param TextOut Simple Text Output protocol pointer.
2353 ConSplitterSyncOutputMode (
2354 IN TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
,
2355 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
2358 INT32 CurrentMaxMode
;
2361 INT32
*TextOutModeMap
;
2364 TEXT_OUT_SPLITTER_QUERY_DATA
*TextOutQueryData
;
2371 // Must make sure that current mode won't change even if mode number changes
2373 CurrentMaxMode
= Private
->TextOutMode
.MaxMode
;
2374 TextOutModeMap
= Private
->TextOutModeMap
;
2375 StepSize
= Private
->TextOutListCount
;
2376 TextOutQueryData
= Private
->TextOutQueryData
;
2379 // Query all the mode that the newly added TextOut supports
2382 MapTable
= TextOutModeMap
+ Private
->CurrentNumberOfConsoles
;
2383 while (Mode
< TextOut
->Mode
->MaxMode
) {
2384 Status
= TextOut
->QueryMode (TextOut
, Mode
, &Columns
, &Rows
);
2386 if (EFI_ERROR(Status
)) {
2389 // If mode 1 (80x50) is not supported, make sure mode 1 in TextOutQueryData
2392 MapTable
[StepSize
] = Mode
;
2393 TextOutQueryData
[Mode
].Columns
= 0;
2394 TextOutQueryData
[Mode
].Rows
= 0;
2400 // Search the intersection map and QueryData database to see if they intersects
2403 while (Index
< CurrentMaxMode
) {
2404 QueryMode
= *(TextOutModeMap
+ Index
* StepSize
);
2405 if ((TextOutQueryData
[QueryMode
].Rows
== Rows
) && (TextOutQueryData
[QueryMode
].Columns
== Columns
)) {
2406 MapTable
[Index
* StepSize
] = Mode
;
2414 // Now search the TextOutModeMap table to find the intersection of supported
2415 // mode between ConSplitter and the newly added device.
2417 ConSplitterGetIntersection (
2422 &Private
->TextOutMode
.MaxMode
,
2423 &Private
->TextOutMode
.Mode
2431 Sync output device between ConOut and StdErr output.
2433 @retval EFI_SUCCESS Sync implemented successfully.
2434 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
2438 ConSplitterGetIntersectionBetweenConOutAndStrErr (
2442 UINTN ConOutNumOfConsoles
;
2443 UINTN StdErrNumOfConsoles
;
2444 TEXT_OUT_AND_GOP_DATA
*ConOutTextOutList
;
2445 TEXT_OUT_AND_GOP_DATA
*StdErrTextOutList
;
2449 UINTN ConOutColumns
;
2451 UINTN StdErrColumns
;
2452 INT32 ConOutMaxMode
;
2453 INT32 StdErrMaxMode
;
2458 INT32
*ConOutModeMap
;
2459 INT32
*StdErrModeMap
;
2460 INT32
*ConOutMapTable
;
2461 INT32
*StdErrMapTable
;
2462 TEXT_OUT_SPLITTER_QUERY_DATA
*ConOutQueryData
;
2463 TEXT_OUT_SPLITTER_QUERY_DATA
*StdErrQueryData
;
2464 UINTN ConOutStepSize
;
2465 UINTN StdErrStepSize
;
2466 BOOLEAN FoundTheSameTextOut
;
2467 UINTN ConOutMapTableSize
;
2468 UINTN StdErrMapTableSize
;
2470 ConOutNumOfConsoles
= mConOut
.CurrentNumberOfConsoles
;
2471 StdErrNumOfConsoles
= mStdErr
.CurrentNumberOfConsoles
;
2472 ConOutTextOutList
= mConOut
.TextOutList
;
2473 StdErrTextOutList
= mStdErr
.TextOutList
;
2476 FoundTheSameTextOut
= FALSE
;
2477 while ((Indexi
< ConOutNumOfConsoles
) && (!FoundTheSameTextOut
)) {
2479 while (Indexj
< StdErrNumOfConsoles
) {
2480 if (ConOutTextOutList
->TextOut
== StdErrTextOutList
->TextOut
) {
2481 FoundTheSameTextOut
= TRUE
;
2486 StdErrTextOutList
++;
2490 ConOutTextOutList
++;
2493 if (!FoundTheSameTextOut
) {
2497 // Must make sure that current mode won't change even if mode number changes
2499 ConOutMaxMode
= mConOut
.TextOutMode
.MaxMode
;
2500 ConOutModeMap
= mConOut
.TextOutModeMap
;
2501 ConOutStepSize
= mConOut
.TextOutListCount
;
2502 ConOutQueryData
= mConOut
.TextOutQueryData
;
2504 StdErrMaxMode
= mStdErr
.TextOutMode
.MaxMode
;
2505 StdErrModeMap
= mStdErr
.TextOutModeMap
;
2506 StdErrStepSize
= mStdErr
.TextOutListCount
;
2507 StdErrQueryData
= mStdErr
.TextOutQueryData
;
2510 // Allocate the map table and set the map table's index to -1.
2512 ConOutMapTableSize
= ConOutMaxMode
* sizeof (INT32
);
2513 ConOutMapTable
= AllocateZeroPool (ConOutMapTableSize
);
2514 if (ConOutMapTable
== NULL
) {
2515 return EFI_OUT_OF_RESOURCES
;
2518 SetMem (ConOutMapTable
, ConOutMapTableSize
, 0xFF);
2520 StdErrMapTableSize
= StdErrMaxMode
* sizeof (INT32
);
2521 StdErrMapTable
= AllocateZeroPool (StdErrMapTableSize
);
2522 if (StdErrMapTable
== NULL
) {
2523 return EFI_OUT_OF_RESOURCES
;
2526 SetMem (StdErrMapTable
, StdErrMapTableSize
, 0xFF);
2529 // Find the intersection of the two set of modes. If they actually intersect, the
2530 // correponding entry in the map table is set to 1.
2533 while (Mode
< ConOutMaxMode
) {
2535 // Search the intersection map and QueryData database to see if they intersect
2538 ConOutMode
= *(ConOutModeMap
+ Mode
* ConOutStepSize
);
2539 ConOutRows
= ConOutQueryData
[ConOutMode
].Rows
;
2540 ConOutColumns
= ConOutQueryData
[ConOutMode
].Columns
;
2541 while (Index
< StdErrMaxMode
) {
2542 StdErrMode
= *(StdErrModeMap
+ Index
* StdErrStepSize
);
2543 StdErrRows
= StdErrQueryData
[StdErrMode
].Rows
;
2544 StdErrColumns
= StdErrQueryData
[StdErrMode
].Columns
;
2545 if ((StdErrRows
== ConOutRows
) && (StdErrColumns
== ConOutColumns
)) {
2546 ConOutMapTable
[Mode
] = 1;
2547 StdErrMapTable
[Index
] = 1;
2557 // Now search the TextOutModeMap table to find the intersection of supported
2558 // mode between ConSplitter and the newly added device.
2560 ConSplitterGetIntersection (
2563 mConOut
.TextOutListCount
,
2565 &(mConOut
.TextOutMode
.MaxMode
),
2566 &(mConOut
.TextOutMode
.Mode
)
2569 if (mConOut
.TextOutMode
.Mode
< 0) {
2570 mConOut
.TextOut
.SetMode (&(mConOut
.TextOut
), 0);
2573 ConSplitterGetIntersection (
2576 mStdErr
.TextOutListCount
,
2578 &(mStdErr
.TextOutMode
.MaxMode
),
2579 &(mStdErr
.TextOutMode
.Mode
)
2582 if (mStdErr
.TextOutMode
.Mode
< 0) {
2583 mStdErr
.TextOut
.SetMode (&(mStdErr
.TextOut
), 0);
2586 FreePool (ConOutMapTable
);
2587 FreePool (StdErrMapTable
);
2594 Add Grahpics Output modes into Consplitter Text Out list.
2596 @param Private Text Out Splitter pointer.
2597 @param GraphicsOutput Graphics Output protocol pointer.
2598 @param UgaDraw UGA Draw protocol pointer.
2600 @retval EFI_SUCCESS Output mode added successfully.
2601 @retval other Failed to add output mode.
2605 ConSplitterAddGraphicsOutputMode (
2606 IN TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
,
2607 IN EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
,
2608 IN EFI_UGA_DRAW_PROTOCOL
*UgaDraw
2614 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*Mode
;
2616 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*Info
;
2617 EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE
*CurrentGraphicsOutputMode
;
2618 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*ModeBuffer
;
2619 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*MatchedMode
;
2622 BOOLEAN AlreadyExist
;
2623 UINT32 UgaHorizontalResolution
;
2624 UINT32 UgaVerticalResolution
;
2625 UINT32 UgaColorDepth
;
2626 UINT32 UgaRefreshRate
;
2628 ASSERT (GraphicsOutput
!= NULL
|| UgaDraw
!= NULL
);
2630 CurrentGraphicsOutputMode
= Private
->GraphicsOutput
.Mode
;
2634 Status
= EFI_SUCCESS
;
2636 if (Private
->CurrentNumberOfUgaDraw
!= 0) {
2638 // If any UGA device has already been added, then there is no need to
2639 // calculate intersection of display mode of different GOP/UGA device,
2640 // since only one display mode will be exported (i.e. user-defined mode)
2645 if (GraphicsOutput
!= NULL
) {
2646 if (Private
->CurrentNumberOfGraphicsOutput
== 0) {
2648 // This is the first Graphics Output device added
2650 CurrentGraphicsOutputMode
->MaxMode
= GraphicsOutput
->Mode
->MaxMode
;
2651 CurrentGraphicsOutputMode
->Mode
= GraphicsOutput
->Mode
->Mode
;
2652 CopyMem (CurrentGraphicsOutputMode
->Info
, GraphicsOutput
->Mode
->Info
, GraphicsOutput
->Mode
->SizeOfInfo
);
2653 CurrentGraphicsOutputMode
->SizeOfInfo
= GraphicsOutput
->Mode
->SizeOfInfo
;
2654 CurrentGraphicsOutputMode
->FrameBufferBase
= GraphicsOutput
->Mode
->FrameBufferBase
;
2655 CurrentGraphicsOutputMode
->FrameBufferSize
= GraphicsOutput
->Mode
->FrameBufferSize
;
2658 // Allocate resource for the private mode buffer
2660 ModeBuffer
= AllocatePool (sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
) * GraphicsOutput
->Mode
->MaxMode
);
2661 if (ModeBuffer
== NULL
) {
2662 return EFI_OUT_OF_RESOURCES
;
2664 FreePool (Private
->GraphicsOutputModeBuffer
);
2665 Private
->GraphicsOutputModeBuffer
= ModeBuffer
;
2668 // Store all supported display modes to the private mode buffer
2671 for (Index
= 0; Index
< GraphicsOutput
->Mode
->MaxMode
; Index
++) {
2673 // The Info buffer would be allocated by callee
2675 Status
= GraphicsOutput
->QueryMode (GraphicsOutput
, (UINT32
) Index
, &SizeOfInfo
, &Info
);
2676 if (EFI_ERROR (Status
)) {
2679 ASSERT ( SizeOfInfo
<= sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
));
2680 CopyMem (Mode
, Info
, SizeOfInfo
);
2686 // Check intersection of display mode
2688 ModeBuffer
= AllocatePool (sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
) * CurrentGraphicsOutputMode
->MaxMode
);
2689 if (ModeBuffer
== NULL
) {
2690 return EFI_OUT_OF_RESOURCES
;
2693 MatchedMode
= ModeBuffer
;
2694 Mode
= &Private
->GraphicsOutputModeBuffer
[0];
2695 for (Index
= 0; Index
< CurrentGraphicsOutputMode
->MaxMode
; Index
++) {
2698 for (NumberIndex
= 0; NumberIndex
< GraphicsOutput
->Mode
->MaxMode
; NumberIndex
++) {
2700 // The Info buffer would be allocated by callee
2702 Status
= GraphicsOutput
->QueryMode (GraphicsOutput
, (UINT32
) NumberIndex
, &SizeOfInfo
, &Info
);
2703 if (EFI_ERROR (Status
)) {
2706 if ((Info
->HorizontalResolution
== Mode
->HorizontalResolution
) &&
2707 (Info
->VerticalResolution
== Mode
->VerticalResolution
)) {
2709 // If GOP device supports one mode in current mode buffer,
2710 // it will be added into matched mode buffer
2720 AlreadyExist
= FALSE
;
2723 // Check if GOP mode has been in the mode buffer, ModeBuffer = MatchedMode at begin.
2725 for (Info
= ModeBuffer
; Info
< MatchedMode
; Info
++) {
2726 if ((Info
->HorizontalResolution
== Mode
->HorizontalResolution
) &&
2727 (Info
->VerticalResolution
== Mode
->VerticalResolution
)) {
2728 AlreadyExist
= TRUE
;
2733 if (!AlreadyExist
) {
2734 CopyMem (MatchedMode
, Mode
, sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
));
2737 // Physical frame buffer is no longer available, change PixelFormat to PixelBltOnly
2739 MatchedMode
->Version
= 0;
2740 MatchedMode
->PixelFormat
= PixelBltOnly
;
2741 ZeroMem (&MatchedMode
->PixelInformation
, sizeof (EFI_PIXEL_BITMASK
));
2751 // Drop the old mode buffer, assign it to a new one
2753 FreePool (Private
->GraphicsOutputModeBuffer
);
2754 Private
->GraphicsOutputModeBuffer
= ModeBuffer
;
2757 // Physical frame buffer is no longer available when there are more than one physical GOP devices
2759 CurrentGraphicsOutputMode
->MaxMode
= (UINT32
) (((UINTN
) MatchedMode
- (UINTN
) ModeBuffer
) / sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
));
2760 CurrentGraphicsOutputMode
->Info
->PixelFormat
= PixelBltOnly
;
2761 ZeroMem (&CurrentGraphicsOutputMode
->Info
->PixelInformation
, sizeof (EFI_PIXEL_BITMASK
));
2762 CurrentGraphicsOutputMode
->SizeOfInfo
= sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
);
2763 CurrentGraphicsOutputMode
->FrameBufferBase
= (EFI_PHYSICAL_ADDRESS
) (UINTN
) NULL
;
2764 CurrentGraphicsOutputMode
->FrameBufferSize
= 0;
2768 // Graphics console driver can ensure the same mode for all GOP devices
2770 for (Index
= 0; Index
< CurrentGraphicsOutputMode
->MaxMode
; Index
++) {
2771 Mode
= &Private
->GraphicsOutputModeBuffer
[Index
];
2772 if ((Mode
->HorizontalResolution
== GraphicsOutput
->Mode
->Info
->HorizontalResolution
) &&
2773 (Mode
->VerticalResolution
== GraphicsOutput
->Mode
->Info
->VerticalResolution
)) {
2774 CurrentIndex
= Index
;
2778 if (Index
>= CurrentGraphicsOutputMode
->MaxMode
) {
2780 // if user defined mode is not found, set to default mode 800x600
2782 for (Index
= 0; Index
< CurrentGraphicsOutputMode
->MaxMode
; Index
++) {
2783 Mode
= &Private
->GraphicsOutputModeBuffer
[Index
];
2784 if ((Mode
->HorizontalResolution
== 800) && (Mode
->VerticalResolution
== 600)) {
2785 CurrentIndex
= Index
;
2790 } else if (UgaDraw
!= NULL
&& FeaturePcdGet (PcdUgaConsumeSupport
)) {
2792 // Graphics console driver can ensure the same mode for all GOP devices
2793 // so we can get the current mode from this video device
2797 &UgaHorizontalResolution
,
2798 &UgaVerticalResolution
,
2803 CurrentGraphicsOutputMode
->MaxMode
= 1;
2804 Info
= CurrentGraphicsOutputMode
->Info
;
2806 Info
->HorizontalResolution
= UgaHorizontalResolution
;
2807 Info
->VerticalResolution
= UgaVerticalResolution
;
2808 Info
->PixelFormat
= PixelBltOnly
;
2809 Info
->PixelsPerScanLine
= UgaHorizontalResolution
;
2810 CurrentGraphicsOutputMode
->SizeOfInfo
= sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
);
2811 CurrentGraphicsOutputMode
->FrameBufferBase
= (EFI_PHYSICAL_ADDRESS
) (UINTN
) NULL
;
2812 CurrentGraphicsOutputMode
->FrameBufferSize
= 0;
2815 // Update the private mode buffer
2817 CopyMem (&Private
->GraphicsOutputModeBuffer
[0], Info
, sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
));
2820 // Only mode 0 is available to be set
2827 if (GraphicsOutput
!= NULL
) {
2828 Private
->CurrentNumberOfGraphicsOutput
++;
2830 if (UgaDraw
!= NULL
&& FeaturePcdGet (PcdUgaConsumeSupport
)) {
2831 Private
->CurrentNumberOfUgaDraw
++;
2835 // Force GraphicsOutput mode to be set,
2836 // regardless whether the console is in EfiConsoleControlScreenGraphics or EfiConsoleControlScreenText mode
2838 Private
->HardwareNeedsStarting
= TRUE
;
2840 Mode
= &Private
->GraphicsOutputModeBuffer
[CurrentIndex
];
2841 if ((GraphicsOutput
!= NULL
) &&
2842 (Mode
->HorizontalResolution
== CurrentGraphicsOutputMode
->Info
->HorizontalResolution
) &&
2843 (Mode
->VerticalResolution
== CurrentGraphicsOutputMode
->Info
->VerticalResolution
)) {
2844 CurrentGraphicsOutputMode
->Mode
= (UINT32
) CurrentIndex
;
2845 if ((Mode
->HorizontalResolution
!= GraphicsOutput
->Mode
->Info
->HorizontalResolution
) ||
2846 (Mode
->VerticalResolution
!= GraphicsOutput
->Mode
->Info
->VerticalResolution
)) {
2848 // If all existing video device has been set to common mode, only set new GOP device to
2851 for (NumberIndex
= 0; NumberIndex
< GraphicsOutput
->Mode
->MaxMode
; NumberIndex
++) {
2852 Status
= GraphicsOutput
->QueryMode (GraphicsOutput
, (UINT32
) NumberIndex
, &SizeOfInfo
, &Info
);
2853 if (EFI_ERROR (Status
)) {
2856 if ((Info
->HorizontalResolution
== Mode
->HorizontalResolution
) && (Info
->VerticalResolution
== Mode
->VerticalResolution
)) {
2862 Status
= GraphicsOutput
->SetMode (GraphicsOutput
, (UINT32
) NumberIndex
);
2866 // Current mode number may need update now, so set it to an invalid mode number
2868 CurrentGraphicsOutputMode
->Mode
= 0xffff;
2870 // Graphics console can ensure all GOP devices have the same mode which can be taken as current mode.
2872 Status
= Private
->GraphicsOutput
.SetMode (&Private
->GraphicsOutput
, (UINT32
) CurrentIndex
);
2873 if (EFI_ERROR(Status
)) {
2875 // If user defined mode is not valid for display device, set to the default mode 800x600.
2877 (Private
->GraphicsOutputModeBuffer
[0]).HorizontalResolution
= 800;
2878 (Private
->GraphicsOutputModeBuffer
[0]).VerticalResolution
= 600;
2879 Status
= Private
->GraphicsOutput
.SetMode (&Private
->GraphicsOutput
, 0);
2887 Set the current console out mode.
2889 This routine will get the current console mode information (column, row)
2890 from ConsoleOutMode variable and set it; if the variable does not exist,
2891 set to user defined console mode.
2893 @param Private Consplitter Text Out pointer.
2897 ConsplitterSetConsoleOutMode (
2898 IN TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
2908 CONSOLE_OUT_MODE ModeInfo
;
2909 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
;
2913 TextOut
= &Private
->TextOut
;
2914 MaxMode
= (UINTN
) (TextOut
->Mode
->MaxMode
);
2916 ModeInfo
.Column
= PcdGet32 (PcdConOutColumn
);
2917 ModeInfo
.Row
= PcdGet32 (PcdConOutRow
);
2920 // To find the prefer mode and basic mode from Text Out mode list
2922 for (Mode
= 0; Mode
< MaxMode
; Mode
++) {
2923 Status
= TextOut
->QueryMode (TextOut
, Mode
, &Col
, &Row
);
2924 if (!EFI_ERROR(Status
)) {
2925 if (Col
== ModeInfo
.Column
&& Row
== ModeInfo
.Row
) {
2928 if (Col
== 80 && Row
== 25) {
2935 // Set prefer mode to Text Out devices.
2937 Status
= TextOut
->SetMode (TextOut
, PreferMode
);
2938 if (EFI_ERROR(Status
)) {
2940 // if current mode setting is failed, default 80x25 mode will be set.
2942 Status
= TextOut
->SetMode (TextOut
, BaseMode
);
2943 ASSERT(!EFI_ERROR(Status
));
2945 PcdSet32 (PcdConOutColumn
, 80);
2946 PcdSet32 (PcdConOutRow
, 25);
2954 Add Text Output Device in Consplitter Text Output list.
2956 @param Private Text Out Splitter pointer.
2957 @param TextOut Simple Text Output protocol pointer.
2958 @param GraphicsOutput Graphics Output protocol pointer.
2959 @param UgaDraw UGA Draw protocol pointer.
2961 @retval EFI_SUCCESS Text Output Device added successfully.
2962 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
2966 ConSplitterTextOutAddDevice (
2967 IN TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
,
2968 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
,
2969 IN EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
,
2970 IN EFI_UGA_DRAW_PROTOCOL
*UgaDraw
2974 UINTN CurrentNumOfConsoles
;
2976 UINT32 UgaHorizontalResolution
;
2977 UINT32 UgaVerticalResolution
;
2978 UINT32 UgaColorDepth
;
2979 UINT32 UgaRefreshRate
;
2980 TEXT_OUT_AND_GOP_DATA
*TextAndGop
;
2982 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*Info
;
2983 EFI_STATUS DeviceStatus
;
2985 Status
= EFI_SUCCESS
;
2986 CurrentNumOfConsoles
= Private
->CurrentNumberOfConsoles
;
2989 // If the Text Out List is full, enlarge it by calling ConSplitterGrowBuffer().
2991 while (CurrentNumOfConsoles
>= Private
->TextOutListCount
) {
2992 Status
= ConSplitterGrowBuffer (
2993 sizeof (TEXT_OUT_AND_GOP_DATA
),
2994 &Private
->TextOutListCount
,
2995 (VOID
**) &Private
->TextOutList
2997 if (EFI_ERROR (Status
)) {
2998 return EFI_OUT_OF_RESOURCES
;
3001 // Also need to reallocate the TextOutModeMap table
3003 Status
= ConSplitterGrowMapTable (Private
);
3004 if (EFI_ERROR (Status
)) {
3005 return EFI_OUT_OF_RESOURCES
;
3009 TextAndGop
= &Private
->TextOutList
[CurrentNumOfConsoles
];
3011 TextAndGop
->TextOut
= TextOut
;
3012 TextAndGop
->GraphicsOutput
= GraphicsOutput
;
3013 TextAndGop
->UgaDraw
= UgaDraw
;
3015 if (CurrentNumOfConsoles
== 0) {
3017 // Add the first device's output mode to console splitter's mode list
3019 Status
= ConSplitterAddOutputMode (Private
, TextOut
);
3021 ConSplitterSyncOutputMode (Private
, TextOut
);
3024 Private
->CurrentNumberOfConsoles
++;
3027 // Scan both TextOutList, for the intersection TextOut device
3028 // maybe both ConOut and StdErr incorporate the same Text Out
3029 // device in them, thus the output of both should be synced.
3031 ConSplitterGetIntersectionBetweenConOutAndStrErr ();
3033 MaxMode
= Private
->TextOutMode
.MaxMode
;
3034 ASSERT (MaxMode
>= 1);
3036 DeviceStatus
= EFI_DEVICE_ERROR
;
3037 if (FeaturePcdGet (PcdConOutGopSupport
)) {
3039 // If GOP is produced by Consplitter, this device display mode will be added into Graphics Ouput modes.
3041 if ((GraphicsOutput
!= NULL
) || (UgaDraw
!= NULL
&& FeaturePcdGet (PcdUgaConsumeSupport
))) {
3042 DeviceStatus
= ConSplitterAddGraphicsOutputMode (Private
, GraphicsOutput
, UgaDraw
);
3046 if (FeaturePcdGet (PcdConOutUgaSupport
)) {
3048 // If UGA is produced by Consplitter
3050 if (GraphicsOutput
!= NULL
) {
3051 Status
= GraphicsOutput
->QueryMode (GraphicsOutput
, GraphicsOutput
->Mode
->Mode
, &SizeOfInfo
, &Info
);
3052 if (EFI_ERROR (Status
)) {
3055 ASSERT ( SizeOfInfo
<= sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
));
3057 UgaHorizontalResolution
= Info
->HorizontalResolution
;
3058 UgaVerticalResolution
= Info
->VerticalResolution
;
3062 } else if (UgaDraw
!= NULL
&& FeaturePcdGet (PcdUgaConsumeSupport
)) {
3063 Status
= UgaDraw
->GetMode (
3065 &UgaHorizontalResolution
,
3066 &UgaVerticalResolution
,
3070 if (!EFI_ERROR (Status
) && EFI_ERROR (DeviceStatus
)) {
3072 // if GetMode is successfully and UGA device hasn't been set, set it
3074 Status
= ConSplitterUgaDrawSetMode (
3076 UgaHorizontalResolution
,
3077 UgaVerticalResolution
,
3083 // If GetMode/SetMode is failed, set to 800x600 mode
3085 if(EFI_ERROR (Status
)) {
3086 Status
= ConSplitterUgaDrawSetMode (
3098 // After adding new console device, all existing console devices should be
3099 // synced to the current shared mode.
3101 ConsplitterSetConsoleOutMode (Private
);
3108 Remove Text Out Device in Consplitter Text Out list.
3110 @param Private Text Out Splitter pointer.
3111 @param TextOut Simple Text Output Pointer protocol pointer.
3113 @retval EFI_SUCCESS Text Out Device removed successfully.
3114 @retval EFI_NOT_FOUND No Text Out Device found.
3118 ConSplitterTextOutDeleteDevice (
3119 IN TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
,
3120 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
3124 UINTN CurrentNumOfConsoles
;
3125 TEXT_OUT_AND_GOP_DATA
*TextOutList
;
3129 // Remove the specified text-out device data structure from the Text out List,
3130 // and rearrange the remaining data structures in the Text out List.
3132 CurrentNumOfConsoles
= Private
->CurrentNumberOfConsoles
;
3133 Index
= (INT32
) CurrentNumOfConsoles
- 1;
3134 TextOutList
= Private
->TextOutList
;
3135 while (Index
>= 0) {
3136 if (TextOutList
->TextOut
== TextOut
) {
3137 CopyMem (TextOutList
, TextOutList
+ 1, sizeof (TEXT_OUT_AND_GOP_DATA
) * Index
);
3138 CurrentNumOfConsoles
--;
3139 if (TextOutList
->UgaDraw
!= NULL
&& FeaturePcdGet (PcdUgaConsumeSupport
)) {
3140 Private
->CurrentNumberOfUgaDraw
--;
3142 if (TextOutList
->GraphicsOutput
!= NULL
) {
3143 Private
->CurrentNumberOfGraphicsOutput
--;
3152 // The specified TextOut is not managed by the ConSplitter driver
3155 return EFI_NOT_FOUND
;
3158 if (CurrentNumOfConsoles
== 0) {
3160 // If the number of consoles is zero, reset all parameters
3162 Private
->CurrentNumberOfConsoles
= 0;
3163 Private
->TextOutMode
.MaxMode
= 1;
3164 Private
->TextOutQueryData
[0].Columns
= 80;
3165 Private
->TextOutQueryData
[0].Rows
= 25;
3166 TextOutSetMode (Private
, 0);
3171 // Max Mode is realy an intersection of the QueryMode command to all
3172 // devices. So we must copy the QueryMode of the first device to
3176 Private
->TextOutQueryData
,
3177 Private
->TextOutQueryDataCount
* sizeof (TEXT_OUT_SPLITTER_QUERY_DATA
)
3180 FreePool (Private
->TextOutModeMap
);
3181 Private
->TextOutModeMap
= NULL
;
3182 TextOutList
= Private
->TextOutList
;
3185 // Add the first TextOut to the QueryData array and ModeMap table
3187 Status
= ConSplitterAddOutputMode (Private
, TextOutList
->TextOut
);
3190 // Now add one by one
3193 Private
->CurrentNumberOfConsoles
= 1;
3195 while ((UINTN
) Index
< CurrentNumOfConsoles
) {
3196 ConSplitterSyncOutputMode (Private
, TextOutList
->TextOut
);
3198 Private
->CurrentNumberOfConsoles
++;
3202 ConSplitterGetIntersectionBetweenConOutAndStrErr ();
3209 Reset the input device and optionaly run diagnostics
3211 @param This Protocol instance pointer.
3212 @param ExtendedVerification Driver may perform diagnostics on reset.
3214 @retval EFI_SUCCESS The device was reset.
3215 @retval EFI_DEVICE_ERROR The device is not functioning properly and could
3221 ConSplitterTextInReset (
3222 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*This
,
3223 IN BOOLEAN ExtendedVerification
3227 EFI_STATUS ReturnStatus
;
3228 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3231 Private
= TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
3233 Private
->KeyEventSignalState
= FALSE
;
3236 // return the worst status met
3238 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
3239 Status
= Private
->TextInList
[Index
]->Reset (
3240 Private
->TextInList
[Index
],
3241 ExtendedVerification
3243 if (EFI_ERROR (Status
)) {
3244 ReturnStatus
= Status
;
3248 return ReturnStatus
;
3253 Reads the next keystroke from the input device. The WaitForKey Event can
3254 be used to test for existance of a keystroke via WaitForEvent () call.
3256 @param Private Protocol instance pointer.
3257 @param Key Driver may perform diagnostics on reset.
3259 @retval EFI_SUCCESS The keystroke information was returned.
3260 @retval EFI_NOT_READY There was no keystroke data availiable.
3261 @retval EFI_DEVICE_ERROR The keydtroke information was not returned due
3267 ConSplitterTextInPrivateReadKeyStroke (
3268 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
3269 OUT EFI_INPUT_KEY
*Key
3274 EFI_INPUT_KEY CurrentKey
;
3276 Key
->UnicodeChar
= 0;
3277 Key
->ScanCode
= SCAN_NULL
;
3280 // if no physical console input device exists, return EFI_NOT_READY;
3281 // if any physical console input device has key input,
3282 // return the key and EFI_SUCCESS.
3284 for (Index
= 0; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
3285 Status
= Private
->TextInList
[Index
]->ReadKeyStroke (
3286 Private
->TextInList
[Index
],
3289 if (!EFI_ERROR (Status
)) {
3295 return EFI_NOT_READY
;
3300 Reads the next keystroke from the input device. The WaitForKey Event can
3301 be used to test for existance of a keystroke via WaitForEvent () call.
3303 @param This Protocol instance pointer.
3304 @param Key Driver may perform diagnostics on reset.
3306 @retval EFI_SUCCESS The keystroke information was returned.
3307 @retval EFI_NOT_READY There was no keystroke data availiable.
3308 @retval EFI_DEVICE_ERROR The keydtroke information was not returned due
3314 ConSplitterTextInReadKeyStroke (
3315 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*This
,
3316 OUT EFI_INPUT_KEY
*Key
3319 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3321 Private
= TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
3323 Private
->KeyEventSignalState
= FALSE
;
3325 return ConSplitterTextInPrivateReadKeyStroke (Private
, Key
);
3330 This event aggregates all the events of the ConIn devices in the spliter.
3332 If any events of physical ConIn devices are signaled, signal the ConIn
3333 spliter event. This will cause the calling code to call
3334 ConSplitterTextInReadKeyStroke ().
3336 @param Event The Event assoicated with callback.
3337 @param Context Context registered when Event was created.
3342 ConSplitterTextInWaitForKey (
3348 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3351 Private
= (TEXT_IN_SPLITTER_PRIVATE_DATA
*) Context
;
3353 if (Private
->KeyEventSignalState
) {
3355 // If KeyEventSignalState is flagged before, and not cleared by Reset() or ReadKeyStroke()
3357 gBS
->SignalEvent (Event
);
3362 // If any physical console input device has key input, signal the event.
3364 for (Index
= 0; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
3365 Status
= gBS
->CheckEvent (Private
->TextInList
[Index
]->WaitForKey
);
3366 if (!EFI_ERROR (Status
)) {
3367 gBS
->SignalEvent (Event
);
3368 Private
->KeyEventSignalState
= TRUE
;
3376 Test if the key has been registered on input device.
3378 @param RegsiteredData A pointer to a buffer that is filled in with the
3379 keystroke state data for the key that was
3381 @param InputData A pointer to a buffer that is filled in with the
3382 keystroke state data for the key that was
3385 @retval TRUE Key be pressed matches a registered key.
3386 @retval FLASE Match failed.
3391 IN EFI_KEY_DATA
*RegsiteredData
,
3392 IN EFI_KEY_DATA
*InputData
3395 ASSERT (RegsiteredData
!= NULL
&& InputData
!= NULL
);
3397 if ((RegsiteredData
->Key
.ScanCode
!= InputData
->Key
.ScanCode
) ||
3398 (RegsiteredData
->Key
.UnicodeChar
!= InputData
->Key
.UnicodeChar
)) {
3403 // Assume KeyShiftState/KeyToggleState = 0 in Registered key data means these state could be ignored.
3405 if (RegsiteredData
->KeyState
.KeyShiftState
!= 0 &&
3406 RegsiteredData
->KeyState
.KeyShiftState
!= InputData
->KeyState
.KeyShiftState
) {
3409 if (RegsiteredData
->KeyState
.KeyToggleState
!= 0 &&
3410 RegsiteredData
->KeyState
.KeyToggleState
!= InputData
->KeyState
.KeyToggleState
) {
3420 Reset the input device and optionaly run diagnostics
3422 @param This Protocol instance pointer.
3423 @param ExtendedVerification Driver may perform diagnostics on reset.
3425 @retval EFI_SUCCESS The device was reset.
3426 @retval EFI_DEVICE_ERROR The device is not functioning properly and could
3432 ConSplitterTextInResetEx (
3433 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*This
,
3434 IN BOOLEAN ExtendedVerification
3438 EFI_STATUS ReturnStatus
;
3439 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3442 Private
= TEXT_IN_EX_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
3444 Private
->KeyEventSignalState
= FALSE
;
3447 // return the worst status met
3449 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfExConsoles
; Index
++) {
3450 Status
= Private
->TextInExList
[Index
]->Reset (
3451 Private
->TextInExList
[Index
],
3452 ExtendedVerification
3454 if (EFI_ERROR (Status
)) {
3455 ReturnStatus
= Status
;
3459 return ReturnStatus
;
3465 Reads the next keystroke from the input device. The WaitForKey Event can
3466 be used to test for existance of a keystroke via WaitForEvent () call.
3468 @param This Protocol instance pointer.
3469 @param KeyData A pointer to a buffer that is filled in with the
3470 keystroke state data for the key that was
3473 @retval EFI_SUCCESS The keystroke information was returned.
3474 @retval EFI_NOT_READY There was no keystroke data availiable.
3475 @retval EFI_DEVICE_ERROR The keystroke information was not returned due
3477 @retval EFI_INVALID_PARAMETER KeyData is NULL.
3482 ConSplitterTextInReadKeyStrokeEx (
3483 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*This
,
3484 OUT EFI_KEY_DATA
*KeyData
3487 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3490 EFI_KEY_DATA CurrentKeyData
;
3493 if (KeyData
== NULL
) {
3494 return EFI_INVALID_PARAMETER
;
3497 Private
= TEXT_IN_EX_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
3499 Private
->KeyEventSignalState
= FALSE
;
3501 KeyData
->Key
.UnicodeChar
= 0;
3502 KeyData
->Key
.ScanCode
= SCAN_NULL
;
3505 // if no physical console input device exists, return EFI_NOT_READY;
3506 // if any physical console input device has key input,
3507 // return the key and EFI_SUCCESS.
3509 for (Index
= 0; Index
< Private
->CurrentNumberOfExConsoles
; Index
++) {
3510 Status
= Private
->TextInExList
[Index
]->ReadKeyStrokeEx (
3511 Private
->TextInExList
[Index
],
3514 if (!EFI_ERROR (Status
)) {
3515 CopyMem (KeyData
, &CurrentKeyData
, sizeof (CurrentKeyData
));
3520 return EFI_NOT_READY
;
3525 Set certain state for the input device.
3527 @param This Protocol instance pointer.
3528 @param KeyToggleState A pointer to the EFI_KEY_TOGGLE_STATE to set the
3529 state for the input device.
3531 @retval EFI_SUCCESS The device state was set successfully.
3532 @retval EFI_DEVICE_ERROR The device is not functioning correctly and
3533 could not have the setting adjusted.
3534 @retval EFI_UNSUPPORTED The device does not have the ability to set its
3536 @retval EFI_INVALID_PARAMETER KeyToggleState is NULL.
3541 ConSplitterTextInSetState (
3542 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*This
,
3543 IN EFI_KEY_TOGGLE_STATE
*KeyToggleState
3546 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3550 if (KeyToggleState
== NULL
) {
3551 return EFI_INVALID_PARAMETER
;
3554 Private
= TEXT_IN_EX_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
3557 // if no physical console input device exists, return EFI_SUCCESS;
3558 // otherwise return the status of setting state of physical console input device
3560 for (Index
= 0; Index
< Private
->CurrentNumberOfExConsoles
; Index
++) {
3561 Status
= Private
->TextInExList
[Index
]->SetState (
3562 Private
->TextInExList
[Index
],
3565 if (EFI_ERROR (Status
)) {
3576 Register a notification function for a particular keystroke for the input device.
3578 @param This Protocol instance pointer.
3579 @param KeyData A pointer to a buffer that is filled in with the
3580 keystroke information data for the key that was
3582 @param KeyNotificationFunction Points to the function to be called when the key
3583 sequence is typed specified by KeyData.
3584 @param NotifyHandle Points to the unique handle assigned to the
3585 registered notification.
3587 @retval EFI_SUCCESS The notification function was registered
3589 @retval EFI_OUT_OF_RESOURCES Unable to allocate resources for necesssary data
3591 @retval EFI_INVALID_PARAMETER KeyData or KeyNotificationFunction or NotifyHandle is NULL.
3596 ConSplitterTextInRegisterKeyNotify (
3597 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*This
,
3598 IN EFI_KEY_DATA
*KeyData
,
3599 IN EFI_KEY_NOTIFY_FUNCTION KeyNotificationFunction
,
3600 OUT EFI_HANDLE
*NotifyHandle
3603 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3606 TEXT_IN_EX_SPLITTER_NOTIFY
*NewNotify
;
3608 TEXT_IN_EX_SPLITTER_NOTIFY
*CurrentNotify
;
3611 if (KeyData
== NULL
|| NotifyHandle
== NULL
|| KeyNotificationFunction
== NULL
) {
3612 return EFI_INVALID_PARAMETER
;
3615 Private
= TEXT_IN_EX_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
3618 // If no physical console input device exists,
3619 // return EFI_SUCCESS directly.
3621 if (Private
->CurrentNumberOfExConsoles
<= 0) {
3626 // Return EFI_SUCCESS if the (KeyData, NotificationFunction) is already registered.
3628 for (Link
= Private
->NotifyList
.ForwardLink
; Link
!= &Private
->NotifyList
; Link
= Link
->ForwardLink
) {
3629 CurrentNotify
= TEXT_IN_EX_SPLITTER_NOTIFY_FROM_THIS (Link
);
3630 if (IsKeyRegistered (&CurrentNotify
->KeyData
, KeyData
)) {
3631 if (CurrentNotify
->KeyNotificationFn
== KeyNotificationFunction
) {
3632 *NotifyHandle
= CurrentNotify
->NotifyHandle
;
3639 // Allocate resource to save the notification function
3641 NewNotify
= (TEXT_IN_EX_SPLITTER_NOTIFY
*) AllocateZeroPool (sizeof (TEXT_IN_EX_SPLITTER_NOTIFY
));
3642 if (NewNotify
== NULL
) {
3643 return EFI_OUT_OF_RESOURCES
;
3645 NewNotify
->NotifyHandleList
= (EFI_HANDLE
*) AllocateZeroPool (sizeof (EFI_HANDLE
) * Private
->CurrentNumberOfExConsoles
);
3646 if (NewNotify
->NotifyHandleList
== NULL
) {
3647 gBS
->FreePool (NewNotify
);
3648 return EFI_OUT_OF_RESOURCES
;
3650 NewNotify
->Signature
= TEXT_IN_EX_SPLITTER_NOTIFY_SIGNATURE
;
3651 NewNotify
->KeyNotificationFn
= KeyNotificationFunction
;
3652 NewNotify
->NotifyHandle
= (EFI_HANDLE
) NewNotify
;
3653 CopyMem (&NewNotify
->KeyData
, KeyData
, sizeof (KeyData
));
3656 // Return the wrong status of registering key notify of
3657 // physical console input device if meet problems
3659 for (Index
= 0; Index
< Private
->CurrentNumberOfExConsoles
; Index
++) {
3660 Status
= Private
->TextInExList
[Index
]->RegisterKeyNotify (
3661 Private
->TextInExList
[Index
],
3663 KeyNotificationFunction
,
3664 &NewNotify
->NotifyHandleList
[Index
]
3666 if (EFI_ERROR (Status
)) {
3667 gBS
->FreePool (NewNotify
->NotifyHandleList
);
3668 gBS
->FreePool (NewNotify
);
3673 InsertTailList (&mConIn
.NotifyList
, &NewNotify
->NotifyEntry
);
3675 *NotifyHandle
= NewNotify
->NotifyHandle
;
3683 Remove a registered notification function from a particular keystroke.
3685 @param This Protocol instance pointer.
3686 @param NotificationHandle The handle of the notification function being
3689 @retval EFI_SUCCESS The notification function was unregistered
3691 @retval EFI_INVALID_PARAMETER The NotificationHandle is invalid.
3696 ConSplitterTextInUnregisterKeyNotify (
3697 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*This
,
3698 IN EFI_HANDLE NotificationHandle
3701 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3704 TEXT_IN_EX_SPLITTER_NOTIFY
*CurrentNotify
;
3707 if (NotificationHandle
== NULL
) {
3708 return EFI_INVALID_PARAMETER
;
3711 if (((TEXT_IN_EX_SPLITTER_NOTIFY
*) NotificationHandle
)->Signature
!= TEXT_IN_EX_SPLITTER_NOTIFY_SIGNATURE
) {
3712 return EFI_INVALID_PARAMETER
;
3715 Private
= TEXT_IN_EX_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
3718 // if no physical console input device exists,
3719 // return EFI_SUCCESS directly.
3721 if (Private
->CurrentNumberOfExConsoles
<= 0) {
3725 for (Link
= Private
->NotifyList
.ForwardLink
; Link
!= &Private
->NotifyList
; Link
= Link
->ForwardLink
) {
3726 CurrentNotify
= TEXT_IN_EX_SPLITTER_NOTIFY_FROM_THIS (Link
);
3727 if (CurrentNotify
->NotifyHandle
== NotificationHandle
) {
3728 for (Index
= 0; Index
< Private
->CurrentNumberOfExConsoles
; Index
++) {
3729 Status
= Private
->TextInExList
[Index
]->UnregisterKeyNotify (
3730 Private
->TextInExList
[Index
],
3731 CurrentNotify
->NotifyHandleList
[Index
]
3733 if (EFI_ERROR (Status
)) {
3737 RemoveEntryList (&CurrentNotify
->NotifyEntry
);
3739 gBS
->FreePool (CurrentNotify
->NotifyHandleList
);
3740 gBS
->FreePool (CurrentNotify
);
3746 // NotificationHandle is not found in database
3748 return EFI_INVALID_PARAMETER
;
3753 Reset the input device and optionaly run diagnostics
3755 @param This Protocol instance pointer.
3756 @param ExtendedVerification Driver may perform diagnostics on reset.
3758 @retval EFI_SUCCESS The device was reset.
3759 @retval EFI_DEVICE_ERROR The device is not functioning properly and could
3765 ConSplitterSimplePointerReset (
3766 IN EFI_SIMPLE_POINTER_PROTOCOL
*This
,
3767 IN BOOLEAN ExtendedVerification
3771 EFI_STATUS ReturnStatus
;
3772 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3775 Private
= TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_SIMPLE_POINTER_THIS (This
);
3777 Private
->InputEventSignalState
= FALSE
;
3779 if (Private
->CurrentNumberOfPointers
== 0) {
3783 // return the worst status met
3785 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfPointers
; Index
++) {
3786 Status
= Private
->PointerList
[Index
]->Reset (
3787 Private
->PointerList
[Index
],
3788 ExtendedVerification
3790 if (EFI_ERROR (Status
)) {
3791 ReturnStatus
= Status
;
3795 return ReturnStatus
;
3800 Reads the next keystroke from the input device. The WaitForKey Event can
3801 be used to test for existance of a keystroke via WaitForEvent () call.
3803 @param Private Protocol instance pointer.
3804 @param State The state information of simple pointer device.
3806 @retval EFI_SUCCESS The keystroke information was returned.
3807 @retval EFI_NOT_READY There was no keystroke data availiable.
3808 @retval EFI_DEVICE_ERROR The keydtroke information was not returned due
3814 ConSplitterSimplePointerPrivateGetState (
3815 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
3816 IN OUT EFI_SIMPLE_POINTER_STATE
*State
3820 EFI_STATUS ReturnStatus
;
3822 EFI_SIMPLE_POINTER_STATE CurrentState
;
3824 State
->RelativeMovementX
= 0;
3825 State
->RelativeMovementY
= 0;
3826 State
->RelativeMovementZ
= 0;
3827 State
->LeftButton
= FALSE
;
3828 State
->RightButton
= FALSE
;
3831 // if no physical console input device exists, return EFI_NOT_READY;
3832 // if any physical console input device has key input,
3833 // return the key and EFI_SUCCESS.
3835 ReturnStatus
= EFI_NOT_READY
;
3836 for (Index
= 0; Index
< Private
->CurrentNumberOfPointers
; Index
++) {
3838 Status
= Private
->PointerList
[Index
]->GetState (
3839 Private
->PointerList
[Index
],
3842 if (!EFI_ERROR (Status
)) {
3843 if (ReturnStatus
== EFI_NOT_READY
) {
3844 ReturnStatus
= EFI_SUCCESS
;
3847 if (CurrentState
.LeftButton
) {
3848 State
->LeftButton
= TRUE
;
3851 if (CurrentState
.RightButton
) {
3852 State
->RightButton
= TRUE
;
3855 if (CurrentState
.RelativeMovementX
!= 0 && Private
->PointerList
[Index
]->Mode
->ResolutionX
!= 0) {
3856 State
->RelativeMovementX
+= (CurrentState
.RelativeMovementX
* (INT32
) Private
->SimplePointerMode
.ResolutionX
) / (INT32
) Private
->PointerList
[Index
]->Mode
->ResolutionX
;
3859 if (CurrentState
.RelativeMovementY
!= 0 && Private
->PointerList
[Index
]->Mode
->ResolutionY
!= 0) {
3860 State
->RelativeMovementY
+= (CurrentState
.RelativeMovementY
* (INT32
) Private
->SimplePointerMode
.ResolutionY
) / (INT32
) Private
->PointerList
[Index
]->Mode
->ResolutionY
;
3863 if (CurrentState
.RelativeMovementZ
!= 0 && Private
->PointerList
[Index
]->Mode
->ResolutionZ
!= 0) {
3864 State
->RelativeMovementZ
+= (CurrentState
.RelativeMovementZ
* (INT32
) Private
->SimplePointerMode
.ResolutionZ
) / (INT32
) Private
->PointerList
[Index
]->Mode
->ResolutionZ
;
3866 } else if (Status
== EFI_DEVICE_ERROR
) {
3867 ReturnStatus
= EFI_DEVICE_ERROR
;
3871 return ReturnStatus
;
3876 Reads the next keystroke from the input device. The WaitForKey Event can
3877 be used to test for existance of a keystroke via WaitForEvent () call.
3879 @param This A pointer to protocol instance.
3880 @param State A pointer to state information on the pointer device
3882 @retval EFI_SUCCESS The keystroke information was returned in State.
3883 @retval EFI_NOT_READY There was no keystroke data availiable.
3884 @retval EFI_DEVICE_ERROR The keydtroke information was not returned due
3890 ConSplitterSimplePointerGetState (
3891 IN EFI_SIMPLE_POINTER_PROTOCOL
*This
,
3892 IN OUT EFI_SIMPLE_POINTER_STATE
*State
3895 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3897 Private
= TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_SIMPLE_POINTER_THIS (This
);
3899 Private
->InputEventSignalState
= FALSE
;
3901 return ConSplitterSimplePointerPrivateGetState (Private
, State
);
3906 This event agregates all the events of the ConIn devices in the spliter.
3907 If any events of physical ConIn devices are signaled, signal the ConIn
3908 spliter event. This will cause the calling code to call
3909 ConSplitterTextInReadKeyStroke ().
3911 @param Event The Event assoicated with callback.
3912 @param Context Context registered when Event was created.
3917 ConSplitterSimplePointerWaitForInput (
3923 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3926 Private
= (TEXT_IN_SPLITTER_PRIVATE_DATA
*) Context
;
3929 // if InputEventSignalState is flagged before, and not cleared by Reset() or ReadKeyStroke()
3931 if (Private
->InputEventSignalState
) {
3932 gBS
->SignalEvent (Event
);
3936 // if any physical console input device has key input, signal the event.
3938 for (Index
= 0; Index
< Private
->CurrentNumberOfPointers
; Index
++) {
3939 Status
= gBS
->CheckEvent (Private
->PointerList
[Index
]->WaitForInput
);
3940 if (!EFI_ERROR (Status
)) {
3941 gBS
->SignalEvent (Event
);
3942 Private
->InputEventSignalState
= TRUE
;
3948 Resets the pointer device hardware.
3950 @param This Protocol instance pointer.
3951 @param ExtendedVerification Driver may perform diagnostics on reset.
3953 @retval EFI_SUCCESS The device was reset.
3954 @retval EFI_DEVICE_ERROR The device is not functioning correctly and
3960 ConSplitterAbsolutePointerReset (
3961 IN EFI_ABSOLUTE_POINTER_PROTOCOL
*This
,
3962 IN BOOLEAN ExtendedVerification
3966 EFI_STATUS ReturnStatus
;
3967 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3970 Private
= TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_ABSOLUTE_POINTER_THIS (This
);
3972 Private
->AbsoluteInputEventSignalState
= FALSE
;
3974 if (Private
->CurrentNumberOfAbsolutePointers
== 0) {
3978 // return the worst status met
3980 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfAbsolutePointers
; Index
++) {
3981 Status
= Private
->AbsolutePointerList
[Index
]->Reset (
3982 Private
->AbsolutePointerList
[Index
],
3983 ExtendedVerification
3985 if (EFI_ERROR (Status
)) {
3986 ReturnStatus
= Status
;
3990 return ReturnStatus
;
3995 Retrieves the current state of a pointer device.
3997 @param This Protocol instance pointer.
3998 @param State A pointer to the state information on the
4001 @retval EFI_SUCCESS The state of the pointer device was returned in
4003 @retval EFI_NOT_READY The state of the pointer device has not changed
4004 since the last call to GetState().
4005 @retval EFI_DEVICE_ERROR A device error occurred while attempting to
4006 retrieve the pointer device's current state.
4011 ConSplitterAbsolutePointerGetState (
4012 IN EFI_ABSOLUTE_POINTER_PROTOCOL
*This
,
4013 IN OUT EFI_ABSOLUTE_POINTER_STATE
*State
4016 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
4018 EFI_STATUS ReturnStatus
;
4020 EFI_ABSOLUTE_POINTER_STATE CurrentState
;
4023 Private
= TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_ABSOLUTE_POINTER_THIS (This
);
4025 Private
->AbsoluteInputEventSignalState
= FALSE
;
4027 State
->CurrentX
= 0;
4028 State
->CurrentY
= 0;
4029 State
->CurrentZ
= 0;
4030 State
->ActiveButtons
= 0;
4033 // if no physical pointer device exists, return EFI_NOT_READY;
4034 // if any physical pointer device has changed state,
4035 // return the state and EFI_SUCCESS.
4037 ReturnStatus
= EFI_NOT_READY
;
4038 for (Index
= 0; Index
< Private
->CurrentNumberOfAbsolutePointers
; Index
++) {
4040 Status
= Private
->AbsolutePointerList
[Index
]->GetState (
4041 Private
->AbsolutePointerList
[Index
],
4044 if (!EFI_ERROR (Status
)) {
4045 if (ReturnStatus
== EFI_NOT_READY
) {
4046 ReturnStatus
= EFI_SUCCESS
;
4049 State
->ActiveButtons
= CurrentState
.ActiveButtons
;
4051 if (!(Private
->AbsolutePointerMode
.AbsoluteMinX
== 0 && Private
->AbsolutePointerMode
.AbsoluteMaxX
== 0)) {
4052 State
->CurrentX
= CurrentState
.CurrentX
;
4054 if (!(Private
->AbsolutePointerMode
.AbsoluteMinY
== 0 && Private
->AbsolutePointerMode
.AbsoluteMaxY
== 0)) {
4055 State
->CurrentY
= CurrentState
.CurrentY
;
4057 if (!(Private
->AbsolutePointerMode
.AbsoluteMinZ
== 0 && Private
->AbsolutePointerMode
.AbsoluteMaxZ
== 0)) {
4058 State
->CurrentZ
= CurrentState
.CurrentZ
;
4061 } else if (Status
== EFI_DEVICE_ERROR
) {
4062 ReturnStatus
= EFI_DEVICE_ERROR
;
4066 return ReturnStatus
;
4071 This event agregates all the events of the pointer devices in the splitter.
4072 If any events of physical pointer devices are signaled, signal the pointer
4073 splitter event. This will cause the calling code to call
4074 ConSplitterAbsolutePointerGetState ().
4076 @param Event The Event assoicated with callback.
4077 @param Context Context registered when Event was created.
4082 ConSplitterAbsolutePointerWaitForInput (
4088 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
4091 Private
= (TEXT_IN_SPLITTER_PRIVATE_DATA
*) Context
;
4094 // if AbsoluteInputEventSignalState is flagged before,
4095 // and not cleared by Reset() or GetState(), signal it
4097 if (Private
->AbsoluteInputEventSignalState
) {
4098 gBS
->SignalEvent (Event
);
4102 // if any physical console input device has key input, signal the event.
4104 for (Index
= 0; Index
< Private
->CurrentNumberOfAbsolutePointers
; Index
++) {
4105 Status
= gBS
->CheckEvent (Private
->AbsolutePointerList
[Index
]->WaitForInput
);
4106 if (!EFI_ERROR (Status
)) {
4107 gBS
->SignalEvent (Event
);
4108 Private
->AbsoluteInputEventSignalState
= TRUE
;
4115 Reset the text output device hardware and optionaly run diagnostics
4117 @param This Protocol instance pointer.
4118 @param ExtendedVerification Driver may perform more exhaustive verfication
4119 operation of the device during reset.
4121 @retval EFI_SUCCESS The text output device was reset.
4122 @retval EFI_DEVICE_ERROR The text output device is not functioning
4123 correctly and could not be reset.
4128 ConSplitterTextOutReset (
4129 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4130 IN BOOLEAN ExtendedVerification
4134 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4136 EFI_STATUS ReturnStatus
;
4138 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4141 // return the worst status met
4143 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
4144 Status
= Private
->TextOutList
[Index
].TextOut
->Reset (
4145 Private
->TextOutList
[Index
].TextOut
,
4146 ExtendedVerification
4148 if (EFI_ERROR (Status
)) {
4149 ReturnStatus
= Status
;
4153 This
->SetAttribute (This
, EFI_TEXT_ATTR (This
->Mode
->Attribute
& 0x0F, EFI_BLACK
));
4156 // reset all mode parameters
4158 TextOutSetMode (Private
, 0);
4160 return ReturnStatus
;
4165 Write a Unicode string to the output device.
4167 @param This Protocol instance pointer.
4168 @param WString The NULL-terminated Unicode string to be
4169 displayed on the output device(s). All output
4170 devices must also support the Unicode drawing
4171 defined in this file.
4173 @retval EFI_SUCCESS The string was output to the device.
4174 @retval EFI_DEVICE_ERROR The device reported an error while attempting to
4176 @retval EFI_UNSUPPORTED The output device's mode is not currently in a
4178 @retval EFI_WARN_UNKNOWN_GLYPH This warning code indicates that some of the
4179 characters in the Unicode string could not be
4180 rendered and were skipped.
4185 ConSplitterTextOutOutputString (
4186 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4191 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4193 UINTN BackSpaceCount
;
4194 EFI_STATUS ReturnStatus
;
4195 CHAR16
*TargetString
;
4197 This
->SetAttribute (This
, This
->Mode
->Attribute
);
4199 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4203 for (TargetString
= WString
; *TargetString
!= L
'\0'; TargetString
++) {
4204 if (*TargetString
== CHAR_BACKSPACE
) {
4209 if (BackSpaceCount
== 0) {
4210 TargetString
= WString
;
4212 TargetString
= AllocatePool (sizeof (CHAR16
) * (StrLen (WString
) + BackSpaceCount
+ 1));
4213 ASSERT (TargetString
!= NULL
);
4215 StrCpy (TargetString
, WString
);
4218 // return the worst status met
4220 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
4221 Status
= Private
->TextOutList
[Index
].TextOut
->OutputString (
4222 Private
->TextOutList
[Index
].TextOut
,
4225 if (EFI_ERROR (Status
)) {
4226 ReturnStatus
= Status
;
4230 if (Private
->CurrentNumberOfConsoles
> 0) {
4231 Private
->TextOutMode
.CursorColumn
= Private
->TextOutList
[0].TextOut
->Mode
->CursorColumn
;
4232 Private
->TextOutMode
.CursorRow
= Private
->TextOutList
[0].TextOut
->Mode
->CursorRow
;
4235 if (BackSpaceCount
> 0) {
4236 FreePool (TargetString
);
4239 return ReturnStatus
;
4244 Verifies that all characters in a Unicode string can be output to the
4247 @param This Protocol instance pointer.
4248 @param WString The NULL-terminated Unicode string to be
4249 examined for the output device(s).
4251 @retval EFI_SUCCESS The device(s) are capable of rendering the
4253 @retval EFI_UNSUPPORTED Some of the characters in the Unicode string
4254 cannot be rendered by one or more of the output
4255 devices mapped by the EFI handle.
4260 ConSplitterTextOutTestString (
4261 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4266 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4268 EFI_STATUS ReturnStatus
;
4270 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4273 // return the worst status met
4275 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
4276 Status
= Private
->TextOutList
[Index
].TextOut
->TestString (
4277 Private
->TextOutList
[Index
].TextOut
,
4280 if (EFI_ERROR (Status
)) {
4281 ReturnStatus
= Status
;
4285 // There is no DevNullTextOutTestString () since a Unicode buffer would
4286 // always return EFI_SUCCESS.
4287 // ReturnStatus will be EFI_SUCCESS if no consoles are present
4289 return ReturnStatus
;
4294 Returns information for an available text mode that the output device(s)
4297 @param This Protocol instance pointer.
4298 @param ModeNumber The mode number to return information on.
4299 @param Columns Returns the columns of the text output device
4300 for the requested ModeNumber.
4301 @param Rows Returns the rows of the text output device
4302 for the requested ModeNumber.
4304 @retval EFI_SUCCESS The requested mode information was returned.
4305 @retval EFI_DEVICE_ERROR The device had an error and could not complete
4307 @retval EFI_UNSUPPORTED The mode number was not valid.
4312 ConSplitterTextOutQueryMode (
4313 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4314 IN UINTN ModeNumber
,
4319 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4321 INT32
*TextOutModeMap
;
4323 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4326 // Check whether param ModeNumber is valid.
4327 // ModeNumber should be within range 0 ~ MaxMode - 1.
4329 if ( (ModeNumber
> (UINTN
)(((UINT32
)-1)>>1)) ) {
4330 return EFI_UNSUPPORTED
;
4333 if ((INT32
) ModeNumber
>= This
->Mode
->MaxMode
) {
4334 return EFI_UNSUPPORTED
;
4338 // We get the available mode from mode intersection map if it's available
4340 if (Private
->TextOutModeMap
!= NULL
) {
4341 TextOutModeMap
= Private
->TextOutModeMap
+ Private
->TextOutListCount
* ModeNumber
;
4342 CurrentMode
= (UINTN
)(*TextOutModeMap
);
4343 *Columns
= Private
->TextOutQueryData
[CurrentMode
].Columns
;
4344 *Rows
= Private
->TextOutQueryData
[CurrentMode
].Rows
;
4346 *Columns
= Private
->TextOutQueryData
[ModeNumber
].Columns
;
4347 *Rows
= Private
->TextOutQueryData
[ModeNumber
].Rows
;
4350 if (*Columns
<= 0 && *Rows
<= 0) {
4351 return EFI_UNSUPPORTED
;
4360 Sets the output device(s) to a specified mode.
4362 @param This Protocol instance pointer.
4363 @param ModeNumber The mode number to set.
4365 @retval EFI_SUCCESS The requested text mode was set.
4366 @retval EFI_DEVICE_ERROR The device had an error and could not complete
4368 @retval EFI_UNSUPPORTED The mode number was not valid.
4373 ConSplitterTextOutSetMode (
4374 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4379 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4381 INT32
*TextOutModeMap
;
4382 EFI_STATUS ReturnStatus
;
4384 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4387 // Check whether param ModeNumber is valid.
4388 // ModeNumber should be within range 0 ~ MaxMode - 1.
4390 if ( (ModeNumber
> (UINTN
)(((UINT32
)-1)>>1)) ) {
4391 return EFI_UNSUPPORTED
;
4394 if ((INT32
) ModeNumber
>= This
->Mode
->MaxMode
) {
4395 return EFI_UNSUPPORTED
;
4398 // If the mode is being set to the curent mode, then just clear the screen and return.
4400 if (Private
->TextOutMode
.Mode
== (INT32
) ModeNumber
) {
4401 return ConSplitterTextOutClearScreen (This
);
4404 // return the worst status met
4406 TextOutModeMap
= Private
->TextOutModeMap
+ Private
->TextOutListCount
* ModeNumber
;
4407 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
4408 Status
= Private
->TextOutList
[Index
].TextOut
->SetMode (
4409 Private
->TextOutList
[Index
].TextOut
,
4410 TextOutModeMap
[Index
]
4412 if (EFI_ERROR (Status
)) {
4413 ReturnStatus
= Status
;
4418 // Set mode parameter to specified mode number
4420 TextOutSetMode (Private
, ModeNumber
);
4422 return ReturnStatus
;
4427 Sets the background and foreground colors for the OutputString () and
4428 ClearScreen () functions.
4430 @param This Protocol instance pointer.
4431 @param Attribute The attribute to set. Bits 0..3 are the
4432 foreground color, and bits 4..6 are the
4433 background color. All other bits are undefined
4434 and must be zero. The valid Attributes are
4435 defined in this file.
4437 @retval EFI_SUCCESS The attribute was set.
4438 @retval EFI_DEVICE_ERROR The device had an error and could not complete
4440 @retval EFI_UNSUPPORTED The attribute requested is not defined.
4445 ConSplitterTextOutSetAttribute (
4446 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4451 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4453 EFI_STATUS ReturnStatus
;
4455 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4458 // Check whether param Attribute is valid.
4460 if ( (Attribute
> (UINTN
)(((UINT32
)-1)>>1)) ) {
4461 return EFI_UNSUPPORTED
;
4465 // return the worst status met
4467 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
4468 Status
= Private
->TextOutList
[Index
].TextOut
->SetAttribute (
4469 Private
->TextOutList
[Index
].TextOut
,
4472 if (EFI_ERROR (Status
)) {
4473 ReturnStatus
= Status
;
4477 Private
->TextOutMode
.Attribute
= (INT32
) Attribute
;
4479 return ReturnStatus
;
4484 Clears the output device(s) display to the currently selected background
4487 @param This Protocol instance pointer.
4489 @retval EFI_SUCCESS The operation completed successfully.
4490 @retval EFI_DEVICE_ERROR The device had an error and could not complete
4492 @retval EFI_UNSUPPORTED The output device is not in a valid text mode.
4497 ConSplitterTextOutClearScreen (
4498 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
4502 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4504 EFI_STATUS ReturnStatus
;
4506 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4509 // return the worst status met
4511 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
4512 Status
= Private
->TextOutList
[Index
].TextOut
->ClearScreen (Private
->TextOutList
[Index
].TextOut
);
4513 if (EFI_ERROR (Status
)) {
4514 ReturnStatus
= Status
;
4519 // No need to do extra check here as whether (Column, Row) is valid has
4520 // been checked in ConSplitterTextOutSetCursorPosition. And (0, 0) should
4521 // always be supported.
4523 Private
->TextOutMode
.CursorColumn
= 0;
4524 Private
->TextOutMode
.CursorRow
= 0;
4525 Private
->TextOutMode
.CursorVisible
= TRUE
;
4527 return ReturnStatus
;
4532 Sets the current coordinates of the cursor position
4534 @param This Protocol instance pointer.
4535 @param Column The column position to set the cursor to. Must be
4536 greater than or equal to zero and less than the
4537 number of columns by QueryMode ().
4538 @param Row The row position to set the cursor to. Must be
4539 greater than or equal to zero and less than the
4540 number of rows by QueryMode ().
4542 @retval EFI_SUCCESS The operation completed successfully.
4543 @retval EFI_DEVICE_ERROR The device had an error and could not complete
4545 @retval EFI_UNSUPPORTED The output device is not in a valid text mode,
4546 or the cursor position is invalid for the
4552 ConSplitterTextOutSetCursorPosition (
4553 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4559 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4561 EFI_STATUS ReturnStatus
;
4564 INT32
*TextOutModeMap
;
4568 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4569 TextOutModeMap
= NULL
;
4570 ModeNumber
= Private
->TextOutMode
.Mode
;
4573 // Get current MaxColumn and MaxRow from intersection map
4575 if (Private
->TextOutModeMap
!= NULL
) {
4576 TextOutModeMap
= Private
->TextOutModeMap
+ Private
->TextOutListCount
* ModeNumber
;
4577 CurrentMode
= *TextOutModeMap
;
4579 CurrentMode
= ModeNumber
;
4582 MaxColumn
= Private
->TextOutQueryData
[CurrentMode
].Columns
;
4583 MaxRow
= Private
->TextOutQueryData
[CurrentMode
].Rows
;
4585 if (Column
>= MaxColumn
|| Row
>= MaxRow
) {
4586 return EFI_UNSUPPORTED
;
4589 // return the worst status met
4591 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
4592 Status
= Private
->TextOutList
[Index
].TextOut
->SetCursorPosition (
4593 Private
->TextOutList
[Index
].TextOut
,
4597 if (EFI_ERROR (Status
)) {
4598 ReturnStatus
= Status
;
4603 // No need to do extra check here as whether (Column, Row) is valid has
4604 // been checked in ConSplitterTextOutSetCursorPosition. And (0, 0) should
4605 // always be supported.
4607 Private
->TextOutMode
.CursorColumn
= (INT32
) Column
;
4608 Private
->TextOutMode
.CursorRow
= (INT32
) Row
;
4610 return ReturnStatus
;
4615 Makes the cursor visible or invisible
4617 @param This Protocol instance pointer.
4618 @param Visible If TRUE, the cursor is set to be visible. If
4619 FALSE, the cursor is set to be invisible.
4621 @retval EFI_SUCCESS The operation completed successfully.
4622 @retval EFI_DEVICE_ERROR The device had an error and could not complete
4623 the request, or the device does not support
4624 changing the cursor mode.
4625 @retval EFI_UNSUPPORTED The output device is not in a valid text mode.
4630 ConSplitterTextOutEnableCursor (
4631 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4636 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4638 EFI_STATUS ReturnStatus
;
4640 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4643 // return the worst status met
4645 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
4646 Status
= Private
->TextOutList
[Index
].TextOut
->EnableCursor (
4647 Private
->TextOutList
[Index
].TextOut
,
4650 if (EFI_ERROR (Status
)) {
4651 ReturnStatus
= Status
;
4655 Private
->TextOutMode
.CursorVisible
= Visible
;
4657 return ReturnStatus
;