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
)) {
1340 // Start ConSplitter on ControllerHandle, and create the virtual
1341 // agrogated console device on first call Start for a StandardError handle.
1343 Status
= ConSplitterStart (
1346 mStdErr
.VirtualHandle
,
1347 &gEfiStandardErrorDeviceGuid
,
1348 &gEfiSimpleTextOutProtocolGuid
,
1351 if (EFI_ERROR (Status
)) {
1356 // When new console device is added, the new mode will be set later,
1357 // so put current mode back to init state.
1359 mStdErr
.TextOutMode
.Mode
= 0xFF;
1362 // If both ConOut and StdErr incorporate the same Text Out device,
1363 // their MaxMode and QueryData should be the intersection of both.
1365 Status
= ConSplitterTextOutAddDevice (&mStdErr
, TextOut
, NULL
, NULL
);
1366 ConSplitterTextOutSetAttribute (&mStdErr
.TextOut
, EFI_TEXT_ATTR (EFI_MAGENTA
, EFI_BLACK
));
1367 if (EFI_ERROR (Status
)) {
1371 if (mStdErr
.CurrentNumberOfConsoles
== 1) {
1372 gST
->StandardErrorHandle
= mStdErr
.VirtualHandle
;
1373 gST
->StdErr
= &mStdErr
.TextOut
;
1375 // Update the CRC32 in the EFI System Table header
1378 gBS
->CalculateCrc32 (
1379 (UINT8
*) &gST
->Hdr
,
1380 gST
->Hdr
.HeaderSize
,
1390 Stop ConSplitter on device handle by closing Console Device Guid on device handle
1391 and the console virtual handle.
1393 @param This Protocol instance pointer.
1394 @param ControllerHandle Handle of device.
1395 @param ConSplitterVirtualHandle Console virtual Handle.
1396 @param DeviceGuid The specified Console Device, such as ConInDev,
1398 @param InterfaceGuid The specified protocol to be opened.
1399 @param Interface Protocol interface returned.
1401 @retval EFI_SUCCESS Stop ConSplitter on ControllerHandle successfully.
1402 @retval other Failed to Stop ConSplitter on ControllerHandle.
1407 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1408 IN EFI_HANDLE ControllerHandle
,
1409 IN EFI_HANDLE ConSplitterVirtualHandle
,
1410 IN EFI_GUID
*DeviceGuid
,
1411 IN EFI_GUID
*InterfaceGuid
,
1417 Status
= gBS
->OpenProtocol (
1421 This
->DriverBindingHandle
,
1423 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1425 if (EFI_ERROR (Status
)) {
1429 // close the protocol refered.
1431 gBS
->CloseProtocol (
1434 This
->DriverBindingHandle
,
1435 ConSplitterVirtualHandle
1438 gBS
->CloseProtocol (
1441 This
->DriverBindingHandle
,
1450 Stop Console In ConSplitter on ControllerHandle by closing Console In Devcice GUID.
1452 @param This Driver Binding protocol instance pointer.
1453 @param ControllerHandle Handle of device to stop driver on
1454 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
1455 children is zero stop the entire bus driver.
1456 @param ChildHandleBuffer List of Child Handles to Stop.
1458 @retval EFI_SUCCESS This driver is removed ControllerHandle
1459 @retval other This driver was not removed from this device
1464 ConSplitterConInDriverBindingStop (
1465 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1466 IN EFI_HANDLE ControllerHandle
,
1467 IN UINTN NumberOfChildren
,
1468 IN EFI_HANDLE
*ChildHandleBuffer
1472 EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*TextIn
;
1473 EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*TextInEx
;
1475 if (NumberOfChildren
== 0) {
1479 Status
= gBS
->OpenProtocol (
1481 &gEfiSimpleTextInputExProtocolGuid
,
1482 (VOID
**) &TextInEx
,
1483 This
->DriverBindingHandle
,
1485 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1487 if (!EFI_ERROR (Status
)) {
1489 // If Simple Text Input Ex protocol exists,
1490 // remove device from Text Input Ex devices list.
1492 Status
= ConSplitterTextInExDeleteDevice (&mConIn
, TextInEx
);
1493 if (EFI_ERROR (Status
)) {
1499 // Close Simple Text In protocol on controller handle and virtual handle.
1501 Status
= ConSplitterStop (
1504 mConIn
.VirtualHandle
,
1505 &gEfiConsoleInDeviceGuid
,
1506 &gEfiSimpleTextInProtocolGuid
,
1509 if (EFI_ERROR (Status
)) {
1514 // Remove device from Text Input devices list.
1516 return ConSplitterTextInDeleteDevice (&mConIn
, TextIn
);
1521 Stop Simple Pointer protocol ConSplitter on ControllerHandle by closing
1522 Simple Pointer protocol.
1524 @param This Driver Binding protocol instance pointer.
1525 @param ControllerHandle Handle of device to stop driver on
1526 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
1527 children is zero stop the entire bus driver.
1528 @param ChildHandleBuffer List of Child Handles to Stop.
1530 @retval EFI_SUCCESS This driver is removed ControllerHandle
1531 @retval other This driver was not removed from this device
1536 ConSplitterSimplePointerDriverBindingStop (
1537 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1538 IN EFI_HANDLE ControllerHandle
,
1539 IN UINTN NumberOfChildren
,
1540 IN EFI_HANDLE
*ChildHandleBuffer
1544 EFI_SIMPLE_POINTER_PROTOCOL
*SimplePointer
;
1546 if (NumberOfChildren
== 0) {
1551 // Close Simple Pointer protocol on controller handle and virtual handle.
1553 Status
= ConSplitterStop (
1556 mConIn
.VirtualHandle
,
1557 &gEfiSimplePointerProtocolGuid
,
1558 &gEfiSimplePointerProtocolGuid
,
1559 (VOID
**) &SimplePointer
1561 if (EFI_ERROR (Status
)) {
1566 // Remove this device from Simple Pointer device list.
1568 return ConSplitterSimplePointerDeleteDevice (&mConIn
, SimplePointer
);
1573 Stop Absolute Pointer protocol ConSplitter on ControllerHandle by closing
1574 Absolute Pointer protocol.
1576 @param This Driver Binding protocol instance pointer.
1577 @param ControllerHandle Handle of device to stop driver on
1578 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
1579 children is zero stop the entire bus driver.
1580 @param ChildHandleBuffer List of Child Handles to Stop.
1582 @retval EFI_SUCCESS This driver is removed ControllerHandle
1583 @retval other This driver was not removed from this device
1588 ConSplitterAbsolutePointerDriverBindingStop (
1589 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1590 IN EFI_HANDLE ControllerHandle
,
1591 IN UINTN NumberOfChildren
,
1592 IN EFI_HANDLE
*ChildHandleBuffer
1596 EFI_ABSOLUTE_POINTER_PROTOCOL
*AbsolutePointer
;
1598 if (NumberOfChildren
== 0) {
1603 // Close Absolute Pointer protocol on controller handle and virtual handle.
1605 Status
= ConSplitterStop (
1608 mConIn
.VirtualHandle
,
1609 &gEfiAbsolutePointerProtocolGuid
,
1610 &gEfiAbsolutePointerProtocolGuid
,
1611 (VOID
**) &AbsolutePointer
1613 if (EFI_ERROR (Status
)) {
1618 // Remove this device from Absolute Pointer device list.
1620 return ConSplitterAbsolutePointerDeleteDevice (&mConIn
, AbsolutePointer
);
1625 Stop Console Out ConSplitter on device handle by closing Console Out Devcice GUID.
1627 @param This Driver Binding protocol instance pointer.
1628 @param ControllerHandle Handle of device to stop driver on
1629 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
1630 children is zero stop the entire bus driver.
1631 @param ChildHandleBuffer List of Child Handles to Stop.
1633 @retval EFI_SUCCESS This driver is removed ControllerHandle
1634 @retval other This driver was not removed from this device
1639 ConSplitterConOutDriverBindingStop (
1640 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1641 IN EFI_HANDLE ControllerHandle
,
1642 IN UINTN NumberOfChildren
,
1643 IN EFI_HANDLE
*ChildHandleBuffer
1647 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
;
1649 if (NumberOfChildren
== 0) {
1654 // Close Absolute Pointer protocol on controller handle and virtual handle.
1656 Status
= ConSplitterStop (
1659 mConOut
.VirtualHandle
,
1660 &gEfiConsoleOutDeviceGuid
,
1661 &gEfiSimpleTextOutProtocolGuid
,
1664 if (EFI_ERROR (Status
)) {
1669 // Remove this device from Text Out device list.
1671 return ConSplitterTextOutDeleteDevice (&mConOut
, TextOut
);
1676 Stop Standard Error ConSplitter on ControllerHandle by closing Standard Error GUID.
1678 @param This Driver Binding protocol instance pointer.
1679 @param ControllerHandle Handle of device to stop driver on
1680 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
1681 children is zero stop the entire bus driver.
1682 @param ChildHandleBuffer List of Child Handles to Stop.
1684 @retval EFI_SUCCESS This driver is removed ControllerHandle
1685 @retval other This driver was not removed from this device
1690 ConSplitterStdErrDriverBindingStop (
1691 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1692 IN EFI_HANDLE ControllerHandle
,
1693 IN UINTN NumberOfChildren
,
1694 IN EFI_HANDLE
*ChildHandleBuffer
1698 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
;
1700 if (NumberOfChildren
== 0) {
1705 // Close Standard Error Device on controller handle and virtual handle.
1707 Status
= ConSplitterStop (
1710 mStdErr
.VirtualHandle
,
1711 &gEfiStandardErrorDeviceGuid
,
1712 &gEfiSimpleTextOutProtocolGuid
,
1715 if (EFI_ERROR (Status
)) {
1719 // Delete this console error out device's data structures.
1721 Status
= ConSplitterTextOutDeleteDevice (&mStdErr
, TextOut
);
1722 if (EFI_ERROR (Status
)) {
1726 if (mStdErr
.CurrentNumberOfConsoles
== 0) {
1727 mStdErr
.VirtualHandle
= NULL
;
1729 gST
->StandardErrorHandle
= NULL
;
1732 // Update the CRC32 in the EFI System Table header
1735 gBS
->CalculateCrc32 (
1736 (UINT8
*) &gST
->Hdr
,
1737 gST
->Hdr
.HeaderSize
,
1742 // Uninstall Simple Text Output protocol from StdErr Handle.
1744 gBS
->UninstallMultipleProtocolInterfaces (
1745 mStdErr
.VirtualHandle
,
1746 &gEfiSimpleTextOutProtocolGuid
,
1757 Take the passed in Buffer of size SizeOfCount and grow the buffer
1758 by MAX (CONSOLE_SPLITTER_CONSOLES_ALLOC_UNIT, MaxGrow) * SizeOfCount
1759 bytes. Copy the current data in Buffer to the new version of Buffer
1760 and free the old version of buffer.
1762 @param SizeOfCount Size of element in array.
1763 @param Count Current number of elements in array.
1764 @param Buffer Bigger version of passed in Buffer with all the
1767 @retval EFI_SUCCESS Buffer size has grown.
1768 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
1772 ConSplitterGrowBuffer (
1773 IN UINTN SizeOfCount
,
1774 IN OUT UINTN
*Count
,
1775 IN OUT VOID
**Buffer
1781 // grow the buffer to new buffer size,
1782 // copy the old buffer's content to the new-size buffer,
1783 // then free the old buffer.
1785 *Count
+= CONSOLE_SPLITTER_CONSOLES_ALLOC_UNIT
;
1786 Ptr
= ReallocatePool (
1787 SizeOfCount
* ((*Count
) - CONSOLE_SPLITTER_CONSOLES_ALLOC_UNIT
),
1788 SizeOfCount
* (*Count
),
1792 return EFI_OUT_OF_RESOURCES
;
1800 Add Text Input Device in Consplitter Text Input list.
1802 @param Private Text In Splitter pointer.
1803 @param TextIn Simple Text Input protocol pointer.
1805 @retval EFI_SUCCESS Text Input Device added successfully.
1806 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
1810 ConSplitterTextInAddDevice (
1811 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
1812 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*TextIn
1818 // If the Text In List is full, enlarge it by calling ConSplitterGrowBuffer().
1820 if (Private
->CurrentNumberOfConsoles
>= Private
->TextInListCount
) {
1821 Status
= ConSplitterGrowBuffer (
1822 sizeof (EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*),
1823 &Private
->TextInListCount
,
1824 (VOID
**) &Private
->TextInList
1826 if (EFI_ERROR (Status
)) {
1827 return EFI_OUT_OF_RESOURCES
;
1831 // Add the new text-in device data structure into the Text In List.
1833 Private
->TextInList
[Private
->CurrentNumberOfConsoles
] = TextIn
;
1834 Private
->CurrentNumberOfConsoles
++;
1837 // Extra CheckEvent added to reduce the double CheckEvent().
1839 gBS
->CheckEvent (TextIn
->WaitForKey
);
1846 Remove Text Input Device from Consplitter Text Input list.
1848 @param Private Text In Splitter pointer.
1849 @param TextIn Simple Text protocol pointer.
1851 @retval EFI_SUCCESS Simple Text Device removed successfully.
1852 @retval EFI_NOT_FOUND No Simple Text Device found.
1856 ConSplitterTextInDeleteDevice (
1857 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
1858 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*TextIn
1863 // Remove the specified text-in device data structure from the Text In List,
1864 // and rearrange the remaining data structures in the Text In List.
1866 for (Index
= 0; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
1867 if (Private
->TextInList
[Index
] == TextIn
) {
1868 for (Index
= Index
; Index
< Private
->CurrentNumberOfConsoles
- 1; Index
++) {
1869 Private
->TextInList
[Index
] = Private
->TextInList
[Index
+ 1];
1872 Private
->CurrentNumberOfConsoles
--;
1877 return EFI_NOT_FOUND
;
1881 Add Text Input Ex Device in Consplitter Text Input Ex list.
1883 @param Private Text In Splitter pointer.
1884 @param TextInEx Simple Text Input Ex Input protocol pointer.
1886 @retval EFI_SUCCESS Text Input Ex Device added successfully.
1887 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
1891 ConSplitterTextInExAddDevice (
1892 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
1893 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*TextInEx
1899 // If the Text Input Ex List is full, enlarge it by calling ConSplitterGrowBuffer().
1901 if (Private
->CurrentNumberOfExConsoles
>= Private
->TextInExListCount
) {
1902 Status
= ConSplitterGrowBuffer (
1903 sizeof (EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*),
1904 &Private
->TextInExListCount
,
1905 (VOID
**) &Private
->TextInExList
1907 if (EFI_ERROR (Status
)) {
1908 return EFI_OUT_OF_RESOURCES
;
1912 // Add the new text-in device data structure into the Text Input Ex List.
1914 Private
->TextInExList
[Private
->CurrentNumberOfExConsoles
] = TextInEx
;
1915 Private
->CurrentNumberOfExConsoles
++;
1918 // Extra CheckEvent added to reduce the double CheckEvent().
1920 gBS
->CheckEvent (TextInEx
->WaitForKeyEx
);
1926 Remove Text Ex Device from Consplitter Text Input Ex list.
1928 @param Private Text In Splitter pointer.
1929 @param TextInEx Simple Text Ex protocol pointer.
1931 @retval EFI_SUCCESS Simple Text Input Ex Device removed successfully.
1932 @retval EFI_NOT_FOUND No Simple Text Input Ex Device found.
1936 ConSplitterTextInExDeleteDevice (
1937 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
1938 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*TextInEx
1943 // Remove the specified text-in device data structure from the Text Input Ex List,
1944 // and rearrange the remaining data structures in the Text In List.
1946 for (Index
= 0; Index
< Private
->CurrentNumberOfExConsoles
; Index
++) {
1947 if (Private
->TextInExList
[Index
] == TextInEx
) {
1948 for (Index
= Index
; Index
< Private
->CurrentNumberOfExConsoles
- 1; Index
++) {
1949 Private
->TextInExList
[Index
] = Private
->TextInExList
[Index
+ 1];
1952 Private
->CurrentNumberOfExConsoles
--;
1957 return EFI_NOT_FOUND
;
1962 Add Simple Pointer Device in Consplitter Simple Pointer list.
1964 @param Private Text In Splitter pointer.
1965 @param SimplePointer Simple Pointer protocol pointer.
1967 @retval EFI_SUCCESS Simple Pointer Device added successfully.
1968 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
1972 ConSplitterSimplePointerAddDevice (
1973 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
1974 IN EFI_SIMPLE_POINTER_PROTOCOL
*SimplePointer
1980 // If the Simple Pointer List is full, enlarge it by calling ConSplitterGrowBuffer().
1982 if (Private
->CurrentNumberOfPointers
>= Private
->PointerListCount
) {
1983 Status
= ConSplitterGrowBuffer (
1984 sizeof (EFI_SIMPLE_POINTER_PROTOCOL
*),
1985 &Private
->PointerListCount
,
1986 (VOID
**) &Private
->PointerList
1988 if (EFI_ERROR (Status
)) {
1989 return EFI_OUT_OF_RESOURCES
;
1993 // Add the new text-in device data structure into the Simple Pointer List.
1995 Private
->PointerList
[Private
->CurrentNumberOfPointers
] = SimplePointer
;
1996 Private
->CurrentNumberOfPointers
++;
2003 Remove Simple Pointer Device from Consplitter Simple Pointer list.
2005 @param Private Text In Splitter pointer.
2006 @param SimplePointer Simple Pointer protocol pointer.
2008 @retval EFI_SUCCESS Simple Pointer Device removed successfully.
2009 @retval EFI_NOT_FOUND No Simple Pointer Device found.
2013 ConSplitterSimplePointerDeleteDevice (
2014 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
2015 IN EFI_SIMPLE_POINTER_PROTOCOL
*SimplePointer
2020 // Remove the specified text-in device data structure from the Simple Pointer List,
2021 // and rearrange the remaining data structures in the Text In List.
2023 for (Index
= 0; Index
< Private
->CurrentNumberOfPointers
; Index
++) {
2024 if (Private
->PointerList
[Index
] == SimplePointer
) {
2025 for (Index
= Index
; Index
< Private
->CurrentNumberOfPointers
- 1; Index
++) {
2026 Private
->PointerList
[Index
] = Private
->PointerList
[Index
+ 1];
2029 Private
->CurrentNumberOfPointers
--;
2034 return EFI_NOT_FOUND
;
2039 Add Absolute Pointer Device in Consplitter Absolute Pointer list.
2041 @param Private Text In Splitter pointer.
2042 @param AbsolutePointer Absolute Pointer protocol pointer.
2044 @retval EFI_SUCCESS Absolute Pointer Device added successfully.
2045 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
2049 ConSplitterAbsolutePointerAddDevice (
2050 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
2051 IN EFI_ABSOLUTE_POINTER_PROTOCOL
*AbsolutePointer
2057 // If the Absolute Pointer List is full, enlarge it by calling ConSplitterGrowBuffer().
2059 if (Private
->CurrentNumberOfAbsolutePointers
>= Private
->AbsolutePointerListCount
) {
2060 Status
= ConSplitterGrowBuffer (
2061 sizeof (EFI_ABSOLUTE_POINTER_PROTOCOL
*),
2062 &Private
->AbsolutePointerListCount
,
2063 (VOID
**) &Private
->AbsolutePointerList
2065 if (EFI_ERROR (Status
)) {
2066 return EFI_OUT_OF_RESOURCES
;
2070 // Add the new text-in device data structure into the Absolute Pointer List.
2072 Private
->AbsolutePointerList
[Private
->CurrentNumberOfAbsolutePointers
] = AbsolutePointer
;
2073 Private
->CurrentNumberOfAbsolutePointers
++;
2080 Remove Absolute Pointer Device from Consplitter Absolute Pointer list.
2082 @param Private Text In Splitter pointer.
2083 @param AbsolutePointer Absolute Pointer protocol pointer.
2085 @retval EFI_SUCCESS Absolute Pointer Device removed successfully.
2086 @retval EFI_NOT_FOUND No Absolute Pointer Device found.
2090 ConSplitterAbsolutePointerDeleteDevice (
2091 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
2092 IN EFI_ABSOLUTE_POINTER_PROTOCOL
*AbsolutePointer
2097 // Remove the specified text-in device data structure from the Absolute Pointer List,
2098 // and rearrange the remaining data structures from the Absolute Pointer List.
2100 for (Index
= 0; Index
< Private
->CurrentNumberOfAbsolutePointers
; Index
++) {
2101 if (Private
->AbsolutePointerList
[Index
] == AbsolutePointer
) {
2102 for (Index
= Index
; Index
< Private
->CurrentNumberOfAbsolutePointers
- 1; Index
++) {
2103 Private
->AbsolutePointerList
[Index
] = Private
->AbsolutePointerList
[Index
+ 1];
2106 Private
->CurrentNumberOfAbsolutePointers
--;
2111 return EFI_NOT_FOUND
;
2115 Reallocate Text Out mode map.
2117 Allocate new buffer and copy original buffer into the new buffer.
2119 @param Private Consplitter Text Out pointer.
2121 @retval EFI_SUCCESS Buffer size has grown
2122 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
2126 ConSplitterGrowMapTable (
2127 IN TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
2133 INT32
*TextOutModeMap
;
2134 INT32
*OldTextOutModeMap
;
2138 NewSize
= Private
->TextOutListCount
* sizeof (INT32
);
2139 OldTextOutModeMap
= Private
->TextOutModeMap
;
2140 TotalSize
= NewSize
* (Private
->TextOutQueryDataCount
);
2143 // Allocate new buffer for Text Out List.
2145 TextOutModeMap
= AllocatePool (TotalSize
);
2146 if (TextOutModeMap
== NULL
) {
2147 return EFI_OUT_OF_RESOURCES
;
2150 SetMem (TextOutModeMap
, TotalSize
, 0xFF);
2151 Private
->TextOutModeMap
= TextOutModeMap
;
2154 // If TextOutList has been enlarged, need to realloc the mode map table
2155 // The mode map table is regarded as a two dimension array.
2158 // 0 ---------> TextOutListCount ----> TextOutListCount
2159 // | -------------------------------------------
2166 // -------------------------------------------
2169 if (OldTextOutModeMap
!= NULL
) {
2171 Size
= Private
->CurrentNumberOfConsoles
* sizeof (INT32
);
2173 SrcAddress
= OldTextOutModeMap
;
2176 // Copy the old data to the new one
2178 while (Index
< Private
->TextOutMode
.MaxMode
) {
2179 CopyMem (TextOutModeMap
, SrcAddress
, Size
);
2180 TextOutModeMap
+= NewSize
;
2185 // Free the old buffer
2187 FreePool (OldTextOutModeMap
);
2195 Add new device's output mode to console splitter's mode list.
2197 @param Private Text Out Splitter pointer
2198 @param TextOut Simple Text Output protocol pointer.
2200 @retval EFI_SUCCESS Device added successfully.
2201 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
2205 ConSplitterAddOutputMode (
2206 IN TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
,
2207 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
2215 MaxMode
= TextOut
->Mode
->MaxMode
;
2216 Private
->TextOutMode
.MaxMode
= MaxMode
;
2219 // Grow the buffer if query data buffer is not large enough to
2220 // hold all the mode supported by the first console.
2222 while (MaxMode
> (INT32
) Private
->TextOutQueryDataCount
) {
2223 Status
= ConSplitterGrowBuffer (
2224 sizeof (TEXT_OUT_SPLITTER_QUERY_DATA
),
2225 &Private
->TextOutQueryDataCount
,
2226 (VOID
**) &Private
->TextOutQueryData
2228 if (EFI_ERROR (Status
)) {
2229 return EFI_OUT_OF_RESOURCES
;
2233 // Allocate buffer for the output mode map
2235 Status
= ConSplitterGrowMapTable (Private
);
2236 if (EFI_ERROR (Status
)) {
2237 return EFI_OUT_OF_RESOURCES
;
2240 // As the first textout device, directly add the mode in to QueryData
2241 // and at the same time record the mapping between QueryData and TextOut.
2245 while (Mode
< MaxMode
) {
2246 Status
= TextOut
->QueryMode (
2249 &Private
->TextOutQueryData
[Mode
].Columns
,
2250 &Private
->TextOutQueryData
[Mode
].Rows
2253 // If mode 1 (80x50) is not supported, make sure mode 1 in TextOutQueryData
2256 if ((EFI_ERROR(Status
)) && (Mode
== 1)) {
2257 Private
->TextOutQueryData
[Mode
].Columns
= 0;
2258 Private
->TextOutQueryData
[Mode
].Rows
= 0;
2260 Private
->TextOutModeMap
[Index
] = Mode
;
2262 Index
+= Private
->TextOutListCount
;
2269 Reconstruct TextOutModeMap to get intersection of modes.
2271 This routine reconstruct TextOutModeMap to get the intersection
2272 of modes for all console out devices. Because EFI/UEFI spec require
2273 mode 0 is 80x25, mode 1 is 80x50, this routine will not check the
2274 intersection for mode 0 and mode 1.
2276 @param TextOutModeMap Current text out mode map, begin with the mode 80x25
2277 @param NewlyAddedMap New text out mode map, begin with the mode 80x25
2278 @param MapStepSize Mode step size for one console device
2279 @param NewMapStepSize New Mode step size for one console device
2280 @param MaxMode IN: Current max text mode, OUT: Updated max text mode.
2281 @param CurrentMode IN: Current text mode, OUT: Updated current text mode.
2285 ConSplitterGetIntersection (
2286 IN INT32
*TextOutModeMap
,
2287 IN INT32
*NewlyAddedMap
,
2288 IN UINTN MapStepSize
,
2289 IN UINTN NewMapStepSize
,
2290 IN OUT INT32
*MaxMode
,
2291 IN OUT INT32
*CurrentMode
2295 INT32
*CurrentMapEntry
;
2296 INT32
*NextMapEntry
;
2298 INT32 CurrentMaxMode
;
2302 // According to EFI/UEFI spec, mode 0 and mode 1 have been reserved
2303 // for 80x25 and 80x50 in Simple Text Out protocol, so don't make intersection
2304 // for mode 0 and mode 1, mode number starts from 2.
2307 CurrentMapEntry
= &TextOutModeMap
[MapStepSize
* 2];
2308 NextMapEntry
= CurrentMapEntry
;
2309 NewMapEntry
= &NewlyAddedMap
[NewMapStepSize
* 2];
2311 CurrentMaxMode
= *MaxMode
;
2312 Mode
= *CurrentMode
;
2314 while (Index
< CurrentMaxMode
) {
2315 if (*NewMapEntry
== -1) {
2317 // This mode is not supported any more. Remove it. Special care
2318 // must be taken as this remove will also affect current mode;
2320 if (Index
== *CurrentMode
) {
2322 } else if (Index
< *CurrentMode
) {
2327 if (CurrentMapEntry
!= NextMapEntry
) {
2328 CopyMem (NextMapEntry
, CurrentMapEntry
, MapStepSize
* sizeof (INT32
));
2331 NextMapEntry
+= MapStepSize
;
2334 CurrentMapEntry
+= MapStepSize
;
2335 NewMapEntry
+= NewMapStepSize
;
2339 *CurrentMode
= Mode
;
2345 Sync the device's output mode to console splitter's mode list.
2347 @param Private Text Out Splitter pointer.
2348 @param TextOut Simple Text Output protocol pointer.
2352 ConSplitterSyncOutputMode (
2353 IN TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
,
2354 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
2357 INT32 CurrentMaxMode
;
2360 INT32
*TextOutModeMap
;
2363 TEXT_OUT_SPLITTER_QUERY_DATA
*TextOutQueryData
;
2370 // Must make sure that current mode won't change even if mode number changes
2372 CurrentMaxMode
= Private
->TextOutMode
.MaxMode
;
2373 TextOutModeMap
= Private
->TextOutModeMap
;
2374 StepSize
= Private
->TextOutListCount
;
2375 TextOutQueryData
= Private
->TextOutQueryData
;
2378 // Query all the mode that the newly added TextOut supports
2381 MapTable
= TextOutModeMap
+ Private
->CurrentNumberOfConsoles
;
2382 while (Mode
< TextOut
->Mode
->MaxMode
) {
2383 Status
= TextOut
->QueryMode (TextOut
, Mode
, &Columns
, &Rows
);
2385 if (EFI_ERROR(Status
)) {
2388 // If mode 1 (80x50) is not supported, make sure mode 1 in TextOutQueryData
2391 MapTable
[StepSize
] = Mode
;
2392 TextOutQueryData
[Mode
].Columns
= 0;
2393 TextOutQueryData
[Mode
].Rows
= 0;
2399 // Search the intersection map and QueryData database to see if they intersects
2402 while (Index
< CurrentMaxMode
) {
2403 QueryMode
= *(TextOutModeMap
+ Index
* StepSize
);
2404 if ((TextOutQueryData
[QueryMode
].Rows
== Rows
) && (TextOutQueryData
[QueryMode
].Columns
== Columns
)) {
2405 MapTable
[Index
* StepSize
] = Mode
;
2413 // Now search the TextOutModeMap table to find the intersection of supported
2414 // mode between ConSplitter and the newly added device.
2416 ConSplitterGetIntersection (
2421 &Private
->TextOutMode
.MaxMode
,
2422 &Private
->TextOutMode
.Mode
2430 Sync output device between ConOut and StdErr output.
2432 @retval EFI_SUCCESS Sync implemented successfully.
2433 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
2437 ConSplitterGetIntersectionBetweenConOutAndStrErr (
2441 UINTN ConOutNumOfConsoles
;
2442 UINTN StdErrNumOfConsoles
;
2443 TEXT_OUT_AND_GOP_DATA
*ConOutTextOutList
;
2444 TEXT_OUT_AND_GOP_DATA
*StdErrTextOutList
;
2448 UINTN ConOutColumns
;
2450 UINTN StdErrColumns
;
2451 INT32 ConOutMaxMode
;
2452 INT32 StdErrMaxMode
;
2457 INT32
*ConOutModeMap
;
2458 INT32
*StdErrModeMap
;
2459 INT32
*ConOutMapTable
;
2460 INT32
*StdErrMapTable
;
2461 TEXT_OUT_SPLITTER_QUERY_DATA
*ConOutQueryData
;
2462 TEXT_OUT_SPLITTER_QUERY_DATA
*StdErrQueryData
;
2463 UINTN ConOutStepSize
;
2464 UINTN StdErrStepSize
;
2465 BOOLEAN FoundTheSameTextOut
;
2466 UINTN ConOutMapTableSize
;
2467 UINTN StdErrMapTableSize
;
2469 ConOutNumOfConsoles
= mConOut
.CurrentNumberOfConsoles
;
2470 StdErrNumOfConsoles
= mStdErr
.CurrentNumberOfConsoles
;
2471 ConOutTextOutList
= mConOut
.TextOutList
;
2472 StdErrTextOutList
= mStdErr
.TextOutList
;
2475 FoundTheSameTextOut
= FALSE
;
2476 while ((Indexi
< ConOutNumOfConsoles
) && (!FoundTheSameTextOut
)) {
2478 while (Indexj
< StdErrNumOfConsoles
) {
2479 if (ConOutTextOutList
->TextOut
== StdErrTextOutList
->TextOut
) {
2480 FoundTheSameTextOut
= TRUE
;
2485 StdErrTextOutList
++;
2489 ConOutTextOutList
++;
2492 if (!FoundTheSameTextOut
) {
2496 // Must make sure that current mode won't change even if mode number changes
2498 ConOutMaxMode
= mConOut
.TextOutMode
.MaxMode
;
2499 ConOutModeMap
= mConOut
.TextOutModeMap
;
2500 ConOutStepSize
= mConOut
.TextOutListCount
;
2501 ConOutQueryData
= mConOut
.TextOutQueryData
;
2503 StdErrMaxMode
= mStdErr
.TextOutMode
.MaxMode
;
2504 StdErrModeMap
= mStdErr
.TextOutModeMap
;
2505 StdErrStepSize
= mStdErr
.TextOutListCount
;
2506 StdErrQueryData
= mStdErr
.TextOutQueryData
;
2509 // Allocate the map table and set the map table's index to -1.
2511 ConOutMapTableSize
= ConOutMaxMode
* sizeof (INT32
);
2512 ConOutMapTable
= AllocateZeroPool (ConOutMapTableSize
);
2513 if (ConOutMapTable
== NULL
) {
2514 return EFI_OUT_OF_RESOURCES
;
2517 SetMem (ConOutMapTable
, ConOutMapTableSize
, 0xFF);
2519 StdErrMapTableSize
= StdErrMaxMode
* sizeof (INT32
);
2520 StdErrMapTable
= AllocateZeroPool (StdErrMapTableSize
);
2521 if (StdErrMapTable
== NULL
) {
2522 return EFI_OUT_OF_RESOURCES
;
2525 SetMem (StdErrMapTable
, StdErrMapTableSize
, 0xFF);
2528 // Find the intersection of the two set of modes. If they actually intersect, the
2529 // correponding entry in the map table is set to 1.
2532 while (Mode
< ConOutMaxMode
) {
2534 // Search the intersection map and QueryData database to see if they intersect
2537 ConOutMode
= *(ConOutModeMap
+ Mode
* ConOutStepSize
);
2538 ConOutRows
= ConOutQueryData
[ConOutMode
].Rows
;
2539 ConOutColumns
= ConOutQueryData
[ConOutMode
].Columns
;
2540 while (Index
< StdErrMaxMode
) {
2541 StdErrMode
= *(StdErrModeMap
+ Index
* StdErrStepSize
);
2542 StdErrRows
= StdErrQueryData
[StdErrMode
].Rows
;
2543 StdErrColumns
= StdErrQueryData
[StdErrMode
].Columns
;
2544 if ((StdErrRows
== ConOutRows
) && (StdErrColumns
== ConOutColumns
)) {
2545 ConOutMapTable
[Mode
] = 1;
2546 StdErrMapTable
[Index
] = 1;
2556 // Now search the TextOutModeMap table to find the intersection of supported
2557 // mode between ConSplitter and the newly added device.
2559 ConSplitterGetIntersection (
2562 mConOut
.TextOutListCount
,
2564 &(mConOut
.TextOutMode
.MaxMode
),
2565 &(mConOut
.TextOutMode
.Mode
)
2568 if (mConOut
.TextOutMode
.Mode
< 0) {
2569 mConOut
.TextOut
.SetMode (&(mConOut
.TextOut
), 0);
2572 ConSplitterGetIntersection (
2575 mStdErr
.TextOutListCount
,
2577 &(mStdErr
.TextOutMode
.MaxMode
),
2578 &(mStdErr
.TextOutMode
.Mode
)
2581 if (mStdErr
.TextOutMode
.Mode
< 0) {
2582 mStdErr
.TextOut
.SetMode (&(mStdErr
.TextOut
), 0);
2585 FreePool (ConOutMapTable
);
2586 FreePool (StdErrMapTable
);
2593 Add Grahpics Output modes into Consplitter Text Out list.
2595 @param Private Text Out Splitter pointer.
2596 @param GraphicsOutput Graphics Output protocol pointer.
2597 @param UgaDraw UGA Draw protocol pointer.
2599 @retval EFI_SUCCESS Output mode added successfully.
2600 @retval other Failed to add output mode.
2604 ConSplitterAddGraphicsOutputMode (
2605 IN TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
,
2606 IN EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
,
2607 IN EFI_UGA_DRAW_PROTOCOL
*UgaDraw
2613 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*Mode
;
2615 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*Info
;
2616 EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE
*CurrentGraphicsOutputMode
;
2617 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*ModeBuffer
;
2618 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*MatchedMode
;
2621 BOOLEAN AlreadyExist
;
2622 UINT32 UgaHorizontalResolution
;
2623 UINT32 UgaVerticalResolution
;
2624 UINT32 UgaColorDepth
;
2625 UINT32 UgaRefreshRate
;
2627 ASSERT (GraphicsOutput
!= NULL
|| UgaDraw
!= NULL
);
2629 CurrentGraphicsOutputMode
= Private
->GraphicsOutput
.Mode
;
2633 Status
= EFI_SUCCESS
;
2635 if (Private
->CurrentNumberOfUgaDraw
!= 0) {
2637 // If any UGA device has already been added, then there is no need to
2638 // calculate intersection of display mode of different GOP/UGA device,
2639 // since only one display mode will be exported (i.e. user-defined mode)
2644 if (GraphicsOutput
!= NULL
) {
2645 if (Private
->CurrentNumberOfGraphicsOutput
== 0) {
2647 // This is the first Graphics Output device added
2649 CurrentGraphicsOutputMode
->MaxMode
= GraphicsOutput
->Mode
->MaxMode
;
2650 CurrentGraphicsOutputMode
->Mode
= GraphicsOutput
->Mode
->Mode
;
2651 CopyMem (CurrentGraphicsOutputMode
->Info
, GraphicsOutput
->Mode
->Info
, GraphicsOutput
->Mode
->SizeOfInfo
);
2652 CurrentGraphicsOutputMode
->SizeOfInfo
= GraphicsOutput
->Mode
->SizeOfInfo
;
2653 CurrentGraphicsOutputMode
->FrameBufferBase
= GraphicsOutput
->Mode
->FrameBufferBase
;
2654 CurrentGraphicsOutputMode
->FrameBufferSize
= GraphicsOutput
->Mode
->FrameBufferSize
;
2657 // Allocate resource for the private mode buffer
2659 ModeBuffer
= AllocatePool (sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
) * GraphicsOutput
->Mode
->MaxMode
);
2660 if (ModeBuffer
== NULL
) {
2661 return EFI_OUT_OF_RESOURCES
;
2663 FreePool (Private
->GraphicsOutputModeBuffer
);
2664 Private
->GraphicsOutputModeBuffer
= ModeBuffer
;
2667 // Store all supported display modes to the private mode buffer
2670 for (Index
= 0; Index
< GraphicsOutput
->Mode
->MaxMode
; Index
++) {
2672 // The Info buffer would be allocated by callee
2674 Status
= GraphicsOutput
->QueryMode (GraphicsOutput
, (UINT32
) Index
, &SizeOfInfo
, &Info
);
2675 if (EFI_ERROR (Status
)) {
2678 ASSERT ( SizeOfInfo
<= sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
));
2679 CopyMem (Mode
, Info
, SizeOfInfo
);
2685 // Check intersection of display mode
2687 ModeBuffer
= AllocatePool (sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
) * CurrentGraphicsOutputMode
->MaxMode
);
2688 if (ModeBuffer
== NULL
) {
2689 return EFI_OUT_OF_RESOURCES
;
2692 MatchedMode
= ModeBuffer
;
2693 Mode
= &Private
->GraphicsOutputModeBuffer
[0];
2694 for (Index
= 0; Index
< CurrentGraphicsOutputMode
->MaxMode
; Index
++) {
2697 for (NumberIndex
= 0; NumberIndex
< GraphicsOutput
->Mode
->MaxMode
; NumberIndex
++) {
2699 // The Info buffer would be allocated by callee
2701 Status
= GraphicsOutput
->QueryMode (GraphicsOutput
, (UINT32
) NumberIndex
, &SizeOfInfo
, &Info
);
2702 if (EFI_ERROR (Status
)) {
2705 if ((Info
->HorizontalResolution
== Mode
->HorizontalResolution
) &&
2706 (Info
->VerticalResolution
== Mode
->VerticalResolution
)) {
2708 // If GOP device supports one mode in current mode buffer,
2709 // it will be added into matched mode buffer
2719 AlreadyExist
= FALSE
;
2722 // Check if GOP mode has been in the mode buffer, ModeBuffer = MatchedMode at begin.
2724 for (Info
= ModeBuffer
; Info
< MatchedMode
; Info
++) {
2725 if ((Info
->HorizontalResolution
== Mode
->HorizontalResolution
) &&
2726 (Info
->VerticalResolution
== Mode
->VerticalResolution
)) {
2727 AlreadyExist
= TRUE
;
2732 if (!AlreadyExist
) {
2733 CopyMem (MatchedMode
, Mode
, sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
));
2736 // Physical frame buffer is no longer available, change PixelFormat to PixelBltOnly
2738 MatchedMode
->Version
= 0;
2739 MatchedMode
->PixelFormat
= PixelBltOnly
;
2740 ZeroMem (&MatchedMode
->PixelInformation
, sizeof (EFI_PIXEL_BITMASK
));
2750 // Drop the old mode buffer, assign it to a new one
2752 FreePool (Private
->GraphicsOutputModeBuffer
);
2753 Private
->GraphicsOutputModeBuffer
= ModeBuffer
;
2756 // Physical frame buffer is no longer available when there are more than one physical GOP devices
2758 CurrentGraphicsOutputMode
->MaxMode
= (UINT32
) (((UINTN
) MatchedMode
- (UINTN
) ModeBuffer
) / sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
));
2759 CurrentGraphicsOutputMode
->Info
->PixelFormat
= PixelBltOnly
;
2760 ZeroMem (&CurrentGraphicsOutputMode
->Info
->PixelInformation
, sizeof (EFI_PIXEL_BITMASK
));
2761 CurrentGraphicsOutputMode
->SizeOfInfo
= sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
);
2762 CurrentGraphicsOutputMode
->FrameBufferBase
= (EFI_PHYSICAL_ADDRESS
) (UINTN
) NULL
;
2763 CurrentGraphicsOutputMode
->FrameBufferSize
= 0;
2767 // Graphics console driver can ensure the same mode for all GOP devices
2769 for (Index
= 0; Index
< CurrentGraphicsOutputMode
->MaxMode
; Index
++) {
2770 Mode
= &Private
->GraphicsOutputModeBuffer
[Index
];
2771 if ((Mode
->HorizontalResolution
== GraphicsOutput
->Mode
->Info
->HorizontalResolution
) &&
2772 (Mode
->VerticalResolution
== GraphicsOutput
->Mode
->Info
->VerticalResolution
)) {
2773 CurrentIndex
= Index
;
2777 if (Index
>= CurrentGraphicsOutputMode
->MaxMode
) {
2779 // if user defined mode is not found, set to default mode 800x600
2781 for (Index
= 0; Index
< CurrentGraphicsOutputMode
->MaxMode
; Index
++) {
2782 Mode
= &Private
->GraphicsOutputModeBuffer
[Index
];
2783 if ((Mode
->HorizontalResolution
== 800) && (Mode
->VerticalResolution
== 600)) {
2784 CurrentIndex
= Index
;
2789 } else if (UgaDraw
!= NULL
&& FeaturePcdGet (PcdUgaConsumeSupport
)) {
2791 // Graphics console driver can ensure the same mode for all GOP devices
2792 // so we can get the current mode from this video device
2796 &UgaHorizontalResolution
,
2797 &UgaVerticalResolution
,
2802 CurrentGraphicsOutputMode
->MaxMode
= 1;
2803 Info
= CurrentGraphicsOutputMode
->Info
;
2805 Info
->HorizontalResolution
= UgaHorizontalResolution
;
2806 Info
->VerticalResolution
= UgaVerticalResolution
;
2807 Info
->PixelFormat
= PixelBltOnly
;
2808 Info
->PixelsPerScanLine
= UgaHorizontalResolution
;
2809 CurrentGraphicsOutputMode
->SizeOfInfo
= sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
);
2810 CurrentGraphicsOutputMode
->FrameBufferBase
= (EFI_PHYSICAL_ADDRESS
) (UINTN
) NULL
;
2811 CurrentGraphicsOutputMode
->FrameBufferSize
= 0;
2814 // Update the private mode buffer
2816 CopyMem (&Private
->GraphicsOutputModeBuffer
[0], Info
, sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
));
2819 // Only mode 0 is available to be set
2826 if (GraphicsOutput
!= NULL
) {
2827 Private
->CurrentNumberOfGraphicsOutput
++;
2829 if (UgaDraw
!= NULL
&& FeaturePcdGet (PcdUgaConsumeSupport
)) {
2830 Private
->CurrentNumberOfUgaDraw
++;
2834 // Force GraphicsOutput mode to be set,
2835 // regardless whether the console is in EfiConsoleControlScreenGraphics or EfiConsoleControlScreenText mode
2837 Private
->HardwareNeedsStarting
= TRUE
;
2839 Mode
= &Private
->GraphicsOutputModeBuffer
[CurrentIndex
];
2840 if ((GraphicsOutput
!= NULL
) &&
2841 (Mode
->HorizontalResolution
== CurrentGraphicsOutputMode
->Info
->HorizontalResolution
) &&
2842 (Mode
->VerticalResolution
== CurrentGraphicsOutputMode
->Info
->VerticalResolution
)) {
2843 CurrentGraphicsOutputMode
->Mode
= (UINT32
) CurrentIndex
;
2844 if ((Mode
->HorizontalResolution
!= GraphicsOutput
->Mode
->Info
->HorizontalResolution
) ||
2845 (Mode
->VerticalResolution
!= GraphicsOutput
->Mode
->Info
->VerticalResolution
)) {
2847 // If all existing video device has been set to common mode, only set new GOP device to
2850 for (NumberIndex
= 0; NumberIndex
< GraphicsOutput
->Mode
->MaxMode
; NumberIndex
++) {
2851 Status
= GraphicsOutput
->QueryMode (GraphicsOutput
, (UINT32
) NumberIndex
, &SizeOfInfo
, &Info
);
2852 if (EFI_ERROR (Status
)) {
2855 if ((Info
->HorizontalResolution
== Mode
->HorizontalResolution
) && (Info
->VerticalResolution
== Mode
->VerticalResolution
)) {
2861 Status
= GraphicsOutput
->SetMode (GraphicsOutput
, (UINT32
) NumberIndex
);
2865 // Current mode number may need update now, so set it to an invalid mode number
2867 CurrentGraphicsOutputMode
->Mode
= 0xffff;
2869 // Graphics console can ensure all GOP devices have the same mode which can be taken as current mode.
2871 Status
= Private
->GraphicsOutput
.SetMode (&Private
->GraphicsOutput
, (UINT32
) CurrentIndex
);
2872 if (EFI_ERROR(Status
)) {
2874 // If user defined mode is not valid for display device, set to the default mode 800x600.
2876 (Private
->GraphicsOutputModeBuffer
[0]).HorizontalResolution
= 800;
2877 (Private
->GraphicsOutputModeBuffer
[0]).VerticalResolution
= 600;
2878 Status
= Private
->GraphicsOutput
.SetMode (&Private
->GraphicsOutput
, 0);
2886 Set the current console out mode.
2888 This routine will get the current console mode information (column, row)
2889 from ConsoleOutMode variable and set it; if the variable does not exist,
2890 set to user defined console mode.
2892 @param Private Consplitter Text Out pointer.
2896 ConsplitterSetConsoleOutMode (
2897 IN TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
2907 CONSOLE_OUT_MODE ModeInfo
;
2908 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
;
2912 TextOut
= &Private
->TextOut
;
2913 MaxMode
= (UINTN
) (TextOut
->Mode
->MaxMode
);
2915 ModeInfo
.Column
= PcdGet32 (PcdConOutColumn
);
2916 ModeInfo
.Row
= PcdGet32 (PcdConOutRow
);
2919 // To find the prefer mode and basic mode from Text Out mode list
2921 for (Mode
= 0; Mode
< MaxMode
; Mode
++) {
2922 Status
= TextOut
->QueryMode (TextOut
, Mode
, &Col
, &Row
);
2923 if (!EFI_ERROR(Status
)) {
2924 if (Col
== ModeInfo
.Column
&& Row
== ModeInfo
.Row
) {
2927 if (Col
== 80 && Row
== 25) {
2934 // Set prefer mode to Text Out devices.
2936 Status
= TextOut
->SetMode (TextOut
, PreferMode
);
2937 if (EFI_ERROR(Status
)) {
2939 // if current mode setting is failed, default 80x25 mode will be set.
2941 Status
= TextOut
->SetMode (TextOut
, BaseMode
);
2942 ASSERT(!EFI_ERROR(Status
));
2944 PcdSet32 (PcdConOutColumn
, 80);
2945 PcdSet32 (PcdConOutRow
, 25);
2953 Add Text Output Device in Consplitter Text Output list.
2955 @param Private Text Out Splitter pointer.
2956 @param TextOut Simple Text Output protocol pointer.
2957 @param GraphicsOutput Graphics Output protocol pointer.
2958 @param UgaDraw UGA Draw protocol pointer.
2960 @retval EFI_SUCCESS Text Output Device added successfully.
2961 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
2965 ConSplitterTextOutAddDevice (
2966 IN TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
,
2967 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
,
2968 IN EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
,
2969 IN EFI_UGA_DRAW_PROTOCOL
*UgaDraw
2973 UINTN CurrentNumOfConsoles
;
2975 UINT32 UgaHorizontalResolution
;
2976 UINT32 UgaVerticalResolution
;
2977 UINT32 UgaColorDepth
;
2978 UINT32 UgaRefreshRate
;
2979 TEXT_OUT_AND_GOP_DATA
*TextAndGop
;
2981 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*Info
;
2982 EFI_STATUS DeviceStatus
;
2984 Status
= EFI_SUCCESS
;
2985 CurrentNumOfConsoles
= Private
->CurrentNumberOfConsoles
;
2988 // If the Text Out List is full, enlarge it by calling ConSplitterGrowBuffer().
2990 while (CurrentNumOfConsoles
>= Private
->TextOutListCount
) {
2991 Status
= ConSplitterGrowBuffer (
2992 sizeof (TEXT_OUT_AND_GOP_DATA
),
2993 &Private
->TextOutListCount
,
2994 (VOID
**) &Private
->TextOutList
2996 if (EFI_ERROR (Status
)) {
2997 return EFI_OUT_OF_RESOURCES
;
3000 // Also need to reallocate the TextOutModeMap table
3002 Status
= ConSplitterGrowMapTable (Private
);
3003 if (EFI_ERROR (Status
)) {
3004 return EFI_OUT_OF_RESOURCES
;
3008 TextAndGop
= &Private
->TextOutList
[CurrentNumOfConsoles
];
3010 TextAndGop
->TextOut
= TextOut
;
3011 TextAndGop
->GraphicsOutput
= GraphicsOutput
;
3012 TextAndGop
->UgaDraw
= UgaDraw
;
3014 if (CurrentNumOfConsoles
== 0) {
3016 // Add the first device's output mode to console splitter's mode list
3018 Status
= ConSplitterAddOutputMode (Private
, TextOut
);
3020 ConSplitterSyncOutputMode (Private
, TextOut
);
3023 Private
->CurrentNumberOfConsoles
++;
3026 // Scan both TextOutList, for the intersection TextOut device
3027 // maybe both ConOut and StdErr incorporate the same Text Out
3028 // device in them, thus the output of both should be synced.
3030 ConSplitterGetIntersectionBetweenConOutAndStrErr ();
3032 MaxMode
= Private
->TextOutMode
.MaxMode
;
3033 ASSERT (MaxMode
>= 1);
3035 DeviceStatus
= EFI_DEVICE_ERROR
;
3036 if (FeaturePcdGet (PcdConOutGopSupport
)) {
3038 // If GOP is produced by Consplitter, this device display mode will be added into Graphics Ouput modes.
3040 if ((GraphicsOutput
!= NULL
) || (UgaDraw
!= NULL
&& FeaturePcdGet (PcdUgaConsumeSupport
))) {
3041 DeviceStatus
= ConSplitterAddGraphicsOutputMode (Private
, GraphicsOutput
, UgaDraw
);
3045 if (FeaturePcdGet (PcdConOutUgaSupport
)) {
3047 // If UGA is produced by Consplitter
3049 if (GraphicsOutput
!= NULL
) {
3050 Status
= GraphicsOutput
->QueryMode (GraphicsOutput
, GraphicsOutput
->Mode
->Mode
, &SizeOfInfo
, &Info
);
3051 if (EFI_ERROR (Status
)) {
3054 ASSERT ( SizeOfInfo
<= sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
));
3056 UgaHorizontalResolution
= Info
->HorizontalResolution
;
3057 UgaVerticalResolution
= Info
->VerticalResolution
;
3061 } else if (UgaDraw
!= NULL
&& FeaturePcdGet (PcdUgaConsumeSupport
)) {
3062 Status
= UgaDraw
->GetMode (
3064 &UgaHorizontalResolution
,
3065 &UgaVerticalResolution
,
3069 if (!EFI_ERROR (Status
) && EFI_ERROR (DeviceStatus
)) {
3071 // if GetMode is successfully and UGA device hasn't been set, set it
3073 Status
= ConSplitterUgaDrawSetMode (
3075 UgaHorizontalResolution
,
3076 UgaVerticalResolution
,
3082 // If GetMode/SetMode is failed, set to 800x600 mode
3084 if(EFI_ERROR (Status
)) {
3085 Status
= ConSplitterUgaDrawSetMode (
3097 // After adding new console device, all existing console devices should be
3098 // synced to the current shared mode.
3100 ConsplitterSetConsoleOutMode (Private
);
3107 Remove Text Out Device in Consplitter Text Out list.
3109 @param Private Text Out Splitter pointer.
3110 @param TextOut Simple Text Output Pointer protocol pointer.
3112 @retval EFI_SUCCESS Text Out Device removed successfully.
3113 @retval EFI_NOT_FOUND No Text Out Device found.
3117 ConSplitterTextOutDeleteDevice (
3118 IN TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
,
3119 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
3123 UINTN CurrentNumOfConsoles
;
3124 TEXT_OUT_AND_GOP_DATA
*TextOutList
;
3128 // Remove the specified text-out device data structure from the Text out List,
3129 // and rearrange the remaining data structures in the Text out List.
3131 CurrentNumOfConsoles
= Private
->CurrentNumberOfConsoles
;
3132 Index
= (INT32
) CurrentNumOfConsoles
- 1;
3133 TextOutList
= Private
->TextOutList
;
3134 while (Index
>= 0) {
3135 if (TextOutList
->TextOut
== TextOut
) {
3136 CopyMem (TextOutList
, TextOutList
+ 1, sizeof (TEXT_OUT_AND_GOP_DATA
) * Index
);
3137 CurrentNumOfConsoles
--;
3138 if (TextOutList
->UgaDraw
!= NULL
&& FeaturePcdGet (PcdUgaConsumeSupport
)) {
3139 Private
->CurrentNumberOfUgaDraw
--;
3141 if (TextOutList
->GraphicsOutput
!= NULL
) {
3142 Private
->CurrentNumberOfGraphicsOutput
--;
3151 // The specified TextOut is not managed by the ConSplitter driver
3154 return EFI_NOT_FOUND
;
3157 if (CurrentNumOfConsoles
== 0) {
3159 // If the number of consoles is zero, reset all parameters
3161 Private
->CurrentNumberOfConsoles
= 0;
3162 Private
->TextOutMode
.MaxMode
= 1;
3163 Private
->TextOutQueryData
[0].Columns
= 80;
3164 Private
->TextOutQueryData
[0].Rows
= 25;
3165 TextOutSetMode (Private
, 0);
3170 // Max Mode is realy an intersection of the QueryMode command to all
3171 // devices. So we must copy the QueryMode of the first device to
3175 Private
->TextOutQueryData
,
3176 Private
->TextOutQueryDataCount
* sizeof (TEXT_OUT_SPLITTER_QUERY_DATA
)
3179 FreePool (Private
->TextOutModeMap
);
3180 Private
->TextOutModeMap
= NULL
;
3181 TextOutList
= Private
->TextOutList
;
3184 // Add the first TextOut to the QueryData array and ModeMap table
3186 Status
= ConSplitterAddOutputMode (Private
, TextOutList
->TextOut
);
3189 // Now add one by one
3192 Private
->CurrentNumberOfConsoles
= 1;
3194 while ((UINTN
) Index
< CurrentNumOfConsoles
) {
3195 ConSplitterSyncOutputMode (Private
, TextOutList
->TextOut
);
3197 Private
->CurrentNumberOfConsoles
++;
3201 ConSplitterGetIntersectionBetweenConOutAndStrErr ();
3208 Reset the input device and optionaly run diagnostics
3210 @param This Protocol instance pointer.
3211 @param ExtendedVerification Driver may perform diagnostics on reset.
3213 @retval EFI_SUCCESS The device was reset.
3214 @retval EFI_DEVICE_ERROR The device is not functioning properly and could
3220 ConSplitterTextInReset (
3221 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*This
,
3222 IN BOOLEAN ExtendedVerification
3226 EFI_STATUS ReturnStatus
;
3227 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3230 Private
= TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
3232 Private
->KeyEventSignalState
= FALSE
;
3235 // return the worst status met
3237 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
3238 Status
= Private
->TextInList
[Index
]->Reset (
3239 Private
->TextInList
[Index
],
3240 ExtendedVerification
3242 if (EFI_ERROR (Status
)) {
3243 ReturnStatus
= Status
;
3247 return ReturnStatus
;
3252 Reads the next keystroke from the input device. The WaitForKey Event can
3253 be used to test for existance of a keystroke via WaitForEvent () call.
3255 @param Private Protocol instance pointer.
3256 @param Key Driver may perform diagnostics on reset.
3258 @retval EFI_SUCCESS The keystroke information was returned.
3259 @retval EFI_NOT_READY There was no keystroke data availiable.
3260 @retval EFI_DEVICE_ERROR The keydtroke information was not returned due
3266 ConSplitterTextInPrivateReadKeyStroke (
3267 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
3268 OUT EFI_INPUT_KEY
*Key
3273 EFI_INPUT_KEY CurrentKey
;
3275 Key
->UnicodeChar
= 0;
3276 Key
->ScanCode
= SCAN_NULL
;
3279 // if no physical console input device exists, return EFI_NOT_READY;
3280 // if any physical console input device has key input,
3281 // return the key and EFI_SUCCESS.
3283 for (Index
= 0; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
3284 Status
= Private
->TextInList
[Index
]->ReadKeyStroke (
3285 Private
->TextInList
[Index
],
3288 if (!EFI_ERROR (Status
)) {
3294 return EFI_NOT_READY
;
3299 Reads the next keystroke from the input device. The WaitForKey Event can
3300 be used to test for existance of a keystroke via WaitForEvent () call.
3302 @param This Protocol instance pointer.
3303 @param Key Driver may perform diagnostics on reset.
3305 @retval EFI_SUCCESS The keystroke information was returned.
3306 @retval EFI_NOT_READY There was no keystroke data availiable.
3307 @retval EFI_DEVICE_ERROR The keydtroke information was not returned due
3313 ConSplitterTextInReadKeyStroke (
3314 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*This
,
3315 OUT EFI_INPUT_KEY
*Key
3318 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3320 Private
= TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
3322 Private
->KeyEventSignalState
= FALSE
;
3324 return ConSplitterTextInPrivateReadKeyStroke (Private
, Key
);
3329 This event aggregates all the events of the ConIn devices in the spliter.
3331 If any events of physical ConIn devices are signaled, signal the ConIn
3332 spliter event. This will cause the calling code to call
3333 ConSplitterTextInReadKeyStroke ().
3335 @param Event The Event assoicated with callback.
3336 @param Context Context registered when Event was created.
3341 ConSplitterTextInWaitForKey (
3347 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3350 Private
= (TEXT_IN_SPLITTER_PRIVATE_DATA
*) Context
;
3352 if (Private
->KeyEventSignalState
) {
3354 // If KeyEventSignalState is flagged before, and not cleared by Reset() or ReadKeyStroke()
3356 gBS
->SignalEvent (Event
);
3361 // If any physical console input device has key input, signal the event.
3363 for (Index
= 0; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
3364 Status
= gBS
->CheckEvent (Private
->TextInList
[Index
]->WaitForKey
);
3365 if (!EFI_ERROR (Status
)) {
3366 gBS
->SignalEvent (Event
);
3367 Private
->KeyEventSignalState
= TRUE
;
3375 Test if the key has been registered on input device.
3377 @param RegsiteredData A pointer to a buffer that is filled in with the
3378 keystroke state data for the key that was
3380 @param InputData A pointer to a buffer that is filled in with the
3381 keystroke state data for the key that was
3384 @retval TRUE Key be pressed matches a registered key.
3385 @retval FLASE Match failed.
3390 IN EFI_KEY_DATA
*RegsiteredData
,
3391 IN EFI_KEY_DATA
*InputData
3394 ASSERT (RegsiteredData
!= NULL
&& InputData
!= NULL
);
3396 if ((RegsiteredData
->Key
.ScanCode
!= InputData
->Key
.ScanCode
) ||
3397 (RegsiteredData
->Key
.UnicodeChar
!= InputData
->Key
.UnicodeChar
)) {
3402 // Assume KeyShiftState/KeyToggleState = 0 in Registered key data means these state could be ignored.
3404 if (RegsiteredData
->KeyState
.KeyShiftState
!= 0 &&
3405 RegsiteredData
->KeyState
.KeyShiftState
!= InputData
->KeyState
.KeyShiftState
) {
3408 if (RegsiteredData
->KeyState
.KeyToggleState
!= 0 &&
3409 RegsiteredData
->KeyState
.KeyToggleState
!= InputData
->KeyState
.KeyToggleState
) {
3419 Reset the input device and optionaly run diagnostics
3421 @param This Protocol instance pointer.
3422 @param ExtendedVerification Driver may perform diagnostics on reset.
3424 @retval EFI_SUCCESS The device was reset.
3425 @retval EFI_DEVICE_ERROR The device is not functioning properly and could
3431 ConSplitterTextInResetEx (
3432 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*This
,
3433 IN BOOLEAN ExtendedVerification
3437 EFI_STATUS ReturnStatus
;
3438 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3441 Private
= TEXT_IN_EX_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
3443 Private
->KeyEventSignalState
= FALSE
;
3446 // return the worst status met
3448 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfExConsoles
; Index
++) {
3449 Status
= Private
->TextInExList
[Index
]->Reset (
3450 Private
->TextInExList
[Index
],
3451 ExtendedVerification
3453 if (EFI_ERROR (Status
)) {
3454 ReturnStatus
= Status
;
3458 return ReturnStatus
;
3464 Reads the next keystroke from the input device. The WaitForKey Event can
3465 be used to test for existance of a keystroke via WaitForEvent () call.
3467 @param This Protocol instance pointer.
3468 @param KeyData A pointer to a buffer that is filled in with the
3469 keystroke state data for the key that was
3472 @retval EFI_SUCCESS The keystroke information was returned.
3473 @retval EFI_NOT_READY There was no keystroke data availiable.
3474 @retval EFI_DEVICE_ERROR The keystroke information was not returned due
3476 @retval EFI_INVALID_PARAMETER KeyData is NULL.
3481 ConSplitterTextInReadKeyStrokeEx (
3482 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*This
,
3483 OUT EFI_KEY_DATA
*KeyData
3486 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3489 EFI_KEY_DATA CurrentKeyData
;
3492 if (KeyData
== NULL
) {
3493 return EFI_INVALID_PARAMETER
;
3496 Private
= TEXT_IN_EX_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
3498 Private
->KeyEventSignalState
= FALSE
;
3500 KeyData
->Key
.UnicodeChar
= 0;
3501 KeyData
->Key
.ScanCode
= SCAN_NULL
;
3504 // if no physical console input device exists, return EFI_NOT_READY;
3505 // if any physical console input device has key input,
3506 // return the key and EFI_SUCCESS.
3508 for (Index
= 0; Index
< Private
->CurrentNumberOfExConsoles
; Index
++) {
3509 Status
= Private
->TextInExList
[Index
]->ReadKeyStrokeEx (
3510 Private
->TextInExList
[Index
],
3513 if (!EFI_ERROR (Status
)) {
3514 CopyMem (KeyData
, &CurrentKeyData
, sizeof (CurrentKeyData
));
3519 return EFI_NOT_READY
;
3524 Set certain state for the input device.
3526 @param This Protocol instance pointer.
3527 @param KeyToggleState A pointer to the EFI_KEY_TOGGLE_STATE to set the
3528 state for the input device.
3530 @retval EFI_SUCCESS The device state was set successfully.
3531 @retval EFI_DEVICE_ERROR The device is not functioning correctly and
3532 could not have the setting adjusted.
3533 @retval EFI_UNSUPPORTED The device does not have the ability to set its
3535 @retval EFI_INVALID_PARAMETER KeyToggleState is NULL.
3540 ConSplitterTextInSetState (
3541 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*This
,
3542 IN EFI_KEY_TOGGLE_STATE
*KeyToggleState
3545 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3549 if (KeyToggleState
== NULL
) {
3550 return EFI_INVALID_PARAMETER
;
3553 Private
= TEXT_IN_EX_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
3556 // if no physical console input device exists, return EFI_SUCCESS;
3557 // otherwise return the status of setting state of physical console input device
3559 for (Index
= 0; Index
< Private
->CurrentNumberOfExConsoles
; Index
++) {
3560 Status
= Private
->TextInExList
[Index
]->SetState (
3561 Private
->TextInExList
[Index
],
3564 if (EFI_ERROR (Status
)) {
3575 Register a notification function for a particular keystroke for the input device.
3577 @param This Protocol instance pointer.
3578 @param KeyData A pointer to a buffer that is filled in with the
3579 keystroke information data for the key that was
3581 @param KeyNotificationFunction Points to the function to be called when the key
3582 sequence is typed specified by KeyData.
3583 @param NotifyHandle Points to the unique handle assigned to the
3584 registered notification.
3586 @retval EFI_SUCCESS The notification function was registered
3588 @retval EFI_OUT_OF_RESOURCES Unable to allocate resources for necesssary data
3590 @retval EFI_INVALID_PARAMETER KeyData or KeyNotificationFunction or NotifyHandle is NULL.
3595 ConSplitterTextInRegisterKeyNotify (
3596 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*This
,
3597 IN EFI_KEY_DATA
*KeyData
,
3598 IN EFI_KEY_NOTIFY_FUNCTION KeyNotificationFunction
,
3599 OUT EFI_HANDLE
*NotifyHandle
3602 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3605 TEXT_IN_EX_SPLITTER_NOTIFY
*NewNotify
;
3607 TEXT_IN_EX_SPLITTER_NOTIFY
*CurrentNotify
;
3610 if (KeyData
== NULL
|| NotifyHandle
== NULL
|| KeyNotificationFunction
== NULL
) {
3611 return EFI_INVALID_PARAMETER
;
3614 Private
= TEXT_IN_EX_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
3617 // If no physical console input device exists,
3618 // return EFI_SUCCESS directly.
3620 if (Private
->CurrentNumberOfExConsoles
<= 0) {
3625 // Return EFI_SUCCESS if the (KeyData, NotificationFunction) is already registered.
3627 for (Link
= Private
->NotifyList
.ForwardLink
; Link
!= &Private
->NotifyList
; Link
= Link
->ForwardLink
) {
3628 CurrentNotify
= TEXT_IN_EX_SPLITTER_NOTIFY_FROM_THIS (Link
);
3629 if (IsKeyRegistered (&CurrentNotify
->KeyData
, KeyData
)) {
3630 if (CurrentNotify
->KeyNotificationFn
== KeyNotificationFunction
) {
3631 *NotifyHandle
= CurrentNotify
->NotifyHandle
;
3638 // Allocate resource to save the notification function
3640 NewNotify
= (TEXT_IN_EX_SPLITTER_NOTIFY
*) AllocateZeroPool (sizeof (TEXT_IN_EX_SPLITTER_NOTIFY
));
3641 if (NewNotify
== NULL
) {
3642 return EFI_OUT_OF_RESOURCES
;
3644 NewNotify
->NotifyHandleList
= (EFI_HANDLE
*) AllocateZeroPool (sizeof (EFI_HANDLE
) * Private
->CurrentNumberOfExConsoles
);
3645 if (NewNotify
->NotifyHandleList
== NULL
) {
3646 gBS
->FreePool (NewNotify
);
3647 return EFI_OUT_OF_RESOURCES
;
3649 NewNotify
->Signature
= TEXT_IN_EX_SPLITTER_NOTIFY_SIGNATURE
;
3650 NewNotify
->KeyNotificationFn
= KeyNotificationFunction
;
3651 NewNotify
->NotifyHandle
= (EFI_HANDLE
) NewNotify
;
3652 CopyMem (&NewNotify
->KeyData
, KeyData
, sizeof (KeyData
));
3655 // Return the wrong status of registering key notify of
3656 // physical console input device if meet problems
3658 for (Index
= 0; Index
< Private
->CurrentNumberOfExConsoles
; Index
++) {
3659 Status
= Private
->TextInExList
[Index
]->RegisterKeyNotify (
3660 Private
->TextInExList
[Index
],
3662 KeyNotificationFunction
,
3663 &NewNotify
->NotifyHandleList
[Index
]
3665 if (EFI_ERROR (Status
)) {
3666 gBS
->FreePool (NewNotify
->NotifyHandleList
);
3667 gBS
->FreePool (NewNotify
);
3672 InsertTailList (&mConIn
.NotifyList
, &NewNotify
->NotifyEntry
);
3674 *NotifyHandle
= NewNotify
->NotifyHandle
;
3682 Remove a registered notification function from a particular keystroke.
3684 @param This Protocol instance pointer.
3685 @param NotificationHandle The handle of the notification function being
3688 @retval EFI_SUCCESS The notification function was unregistered
3690 @retval EFI_INVALID_PARAMETER The NotificationHandle is invalid.
3695 ConSplitterTextInUnregisterKeyNotify (
3696 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*This
,
3697 IN EFI_HANDLE NotificationHandle
3700 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3703 TEXT_IN_EX_SPLITTER_NOTIFY
*CurrentNotify
;
3706 if (NotificationHandle
== NULL
) {
3707 return EFI_INVALID_PARAMETER
;
3710 if (((TEXT_IN_EX_SPLITTER_NOTIFY
*) NotificationHandle
)->Signature
!= TEXT_IN_EX_SPLITTER_NOTIFY_SIGNATURE
) {
3711 return EFI_INVALID_PARAMETER
;
3714 Private
= TEXT_IN_EX_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
3717 // if no physical console input device exists,
3718 // return EFI_SUCCESS directly.
3720 if (Private
->CurrentNumberOfExConsoles
<= 0) {
3724 for (Link
= Private
->NotifyList
.ForwardLink
; Link
!= &Private
->NotifyList
; Link
= Link
->ForwardLink
) {
3725 CurrentNotify
= TEXT_IN_EX_SPLITTER_NOTIFY_FROM_THIS (Link
);
3726 if (CurrentNotify
->NotifyHandle
== NotificationHandle
) {
3727 for (Index
= 0; Index
< Private
->CurrentNumberOfExConsoles
; Index
++) {
3728 Status
= Private
->TextInExList
[Index
]->UnregisterKeyNotify (
3729 Private
->TextInExList
[Index
],
3730 CurrentNotify
->NotifyHandleList
[Index
]
3732 if (EFI_ERROR (Status
)) {
3736 RemoveEntryList (&CurrentNotify
->NotifyEntry
);
3738 gBS
->FreePool (CurrentNotify
->NotifyHandleList
);
3739 gBS
->FreePool (CurrentNotify
);
3745 // NotificationHandle is not found in database
3747 return EFI_INVALID_PARAMETER
;
3752 Reset the input device and optionaly run diagnostics
3754 @param This Protocol instance pointer.
3755 @param ExtendedVerification Driver may perform diagnostics on reset.
3757 @retval EFI_SUCCESS The device was reset.
3758 @retval EFI_DEVICE_ERROR The device is not functioning properly and could
3764 ConSplitterSimplePointerReset (
3765 IN EFI_SIMPLE_POINTER_PROTOCOL
*This
,
3766 IN BOOLEAN ExtendedVerification
3770 EFI_STATUS ReturnStatus
;
3771 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3774 Private
= TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_SIMPLE_POINTER_THIS (This
);
3776 Private
->InputEventSignalState
= FALSE
;
3778 if (Private
->CurrentNumberOfPointers
== 0) {
3782 // return the worst status met
3784 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfPointers
; Index
++) {
3785 Status
= Private
->PointerList
[Index
]->Reset (
3786 Private
->PointerList
[Index
],
3787 ExtendedVerification
3789 if (EFI_ERROR (Status
)) {
3790 ReturnStatus
= Status
;
3794 return ReturnStatus
;
3799 Reads the next keystroke from the input device. The WaitForKey Event can
3800 be used to test for existance of a keystroke via WaitForEvent () call.
3802 @param Private Protocol instance pointer.
3803 @param State The state information of simple pointer device.
3805 @retval EFI_SUCCESS The keystroke information was returned.
3806 @retval EFI_NOT_READY There was no keystroke data availiable.
3807 @retval EFI_DEVICE_ERROR The keydtroke information was not returned due
3813 ConSplitterSimplePointerPrivateGetState (
3814 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
3815 IN OUT EFI_SIMPLE_POINTER_STATE
*State
3819 EFI_STATUS ReturnStatus
;
3821 EFI_SIMPLE_POINTER_STATE CurrentState
;
3823 State
->RelativeMovementX
= 0;
3824 State
->RelativeMovementY
= 0;
3825 State
->RelativeMovementZ
= 0;
3826 State
->LeftButton
= FALSE
;
3827 State
->RightButton
= FALSE
;
3830 // if no physical console input device exists, return EFI_NOT_READY;
3831 // if any physical console input device has key input,
3832 // return the key and EFI_SUCCESS.
3834 ReturnStatus
= EFI_NOT_READY
;
3835 for (Index
= 0; Index
< Private
->CurrentNumberOfPointers
; Index
++) {
3837 Status
= Private
->PointerList
[Index
]->GetState (
3838 Private
->PointerList
[Index
],
3841 if (!EFI_ERROR (Status
)) {
3842 if (ReturnStatus
== EFI_NOT_READY
) {
3843 ReturnStatus
= EFI_SUCCESS
;
3846 if (CurrentState
.LeftButton
) {
3847 State
->LeftButton
= TRUE
;
3850 if (CurrentState
.RightButton
) {
3851 State
->RightButton
= TRUE
;
3854 if (CurrentState
.RelativeMovementX
!= 0 && Private
->PointerList
[Index
]->Mode
->ResolutionX
!= 0) {
3855 State
->RelativeMovementX
+= (CurrentState
.RelativeMovementX
* (INT32
) Private
->SimplePointerMode
.ResolutionX
) / (INT32
) Private
->PointerList
[Index
]->Mode
->ResolutionX
;
3858 if (CurrentState
.RelativeMovementY
!= 0 && Private
->PointerList
[Index
]->Mode
->ResolutionY
!= 0) {
3859 State
->RelativeMovementY
+= (CurrentState
.RelativeMovementY
* (INT32
) Private
->SimplePointerMode
.ResolutionY
) / (INT32
) Private
->PointerList
[Index
]->Mode
->ResolutionY
;
3862 if (CurrentState
.RelativeMovementZ
!= 0 && Private
->PointerList
[Index
]->Mode
->ResolutionZ
!= 0) {
3863 State
->RelativeMovementZ
+= (CurrentState
.RelativeMovementZ
* (INT32
) Private
->SimplePointerMode
.ResolutionZ
) / (INT32
) Private
->PointerList
[Index
]->Mode
->ResolutionZ
;
3865 } else if (Status
== EFI_DEVICE_ERROR
) {
3866 ReturnStatus
= EFI_DEVICE_ERROR
;
3870 return ReturnStatus
;
3875 Reads the next keystroke from the input device. The WaitForKey Event can
3876 be used to test for existance of a keystroke via WaitForEvent () call.
3878 @param This A pointer to protocol instance.
3879 @param State A pointer to state information on the pointer device
3881 @retval EFI_SUCCESS The keystroke information was returned in State.
3882 @retval EFI_NOT_READY There was no keystroke data availiable.
3883 @retval EFI_DEVICE_ERROR The keydtroke information was not returned due
3889 ConSplitterSimplePointerGetState (
3890 IN EFI_SIMPLE_POINTER_PROTOCOL
*This
,
3891 IN OUT EFI_SIMPLE_POINTER_STATE
*State
3894 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3896 Private
= TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_SIMPLE_POINTER_THIS (This
);
3898 Private
->InputEventSignalState
= FALSE
;
3900 return ConSplitterSimplePointerPrivateGetState (Private
, State
);
3905 This event agregates all the events of the ConIn devices in the spliter.
3906 If any events of physical ConIn devices are signaled, signal the ConIn
3907 spliter event. This will cause the calling code to call
3908 ConSplitterTextInReadKeyStroke ().
3910 @param Event The Event assoicated with callback.
3911 @param Context Context registered when Event was created.
3916 ConSplitterSimplePointerWaitForInput (
3922 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3925 Private
= (TEXT_IN_SPLITTER_PRIVATE_DATA
*) Context
;
3928 // if InputEventSignalState is flagged before, and not cleared by Reset() or ReadKeyStroke()
3930 if (Private
->InputEventSignalState
) {
3931 gBS
->SignalEvent (Event
);
3935 // if any physical console input device has key input, signal the event.
3937 for (Index
= 0; Index
< Private
->CurrentNumberOfPointers
; Index
++) {
3938 Status
= gBS
->CheckEvent (Private
->PointerList
[Index
]->WaitForInput
);
3939 if (!EFI_ERROR (Status
)) {
3940 gBS
->SignalEvent (Event
);
3941 Private
->InputEventSignalState
= TRUE
;
3947 Resets the pointer device hardware.
3949 @param This Protocol instance pointer.
3950 @param ExtendedVerification Driver may perform diagnostics on reset.
3952 @retval EFI_SUCCESS The device was reset.
3953 @retval EFI_DEVICE_ERROR The device is not functioning correctly and
3959 ConSplitterAbsolutePointerReset (
3960 IN EFI_ABSOLUTE_POINTER_PROTOCOL
*This
,
3961 IN BOOLEAN ExtendedVerification
3965 EFI_STATUS ReturnStatus
;
3966 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3969 Private
= TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_ABSOLUTE_POINTER_THIS (This
);
3971 Private
->AbsoluteInputEventSignalState
= FALSE
;
3973 if (Private
->CurrentNumberOfAbsolutePointers
== 0) {
3977 // return the worst status met
3979 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfAbsolutePointers
; Index
++) {
3980 Status
= Private
->AbsolutePointerList
[Index
]->Reset (
3981 Private
->AbsolutePointerList
[Index
],
3982 ExtendedVerification
3984 if (EFI_ERROR (Status
)) {
3985 ReturnStatus
= Status
;
3989 return ReturnStatus
;
3994 Retrieves the current state of a pointer device.
3996 @param This Protocol instance pointer.
3997 @param State A pointer to the state information on the
4000 @retval EFI_SUCCESS The state of the pointer device was returned in
4002 @retval EFI_NOT_READY The state of the pointer device has not changed
4003 since the last call to GetState().
4004 @retval EFI_DEVICE_ERROR A device error occurred while attempting to
4005 retrieve the pointer device's current state.
4010 ConSplitterAbsolutePointerGetState (
4011 IN EFI_ABSOLUTE_POINTER_PROTOCOL
*This
,
4012 IN OUT EFI_ABSOLUTE_POINTER_STATE
*State
4015 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
4017 EFI_STATUS ReturnStatus
;
4019 EFI_ABSOLUTE_POINTER_STATE CurrentState
;
4022 Private
= TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_ABSOLUTE_POINTER_THIS (This
);
4024 Private
->AbsoluteInputEventSignalState
= FALSE
;
4026 State
->CurrentX
= 0;
4027 State
->CurrentY
= 0;
4028 State
->CurrentZ
= 0;
4029 State
->ActiveButtons
= 0;
4032 // if no physical pointer device exists, return EFI_NOT_READY;
4033 // if any physical pointer device has changed state,
4034 // return the state and EFI_SUCCESS.
4036 ReturnStatus
= EFI_NOT_READY
;
4037 for (Index
= 0; Index
< Private
->CurrentNumberOfAbsolutePointers
; Index
++) {
4039 Status
= Private
->AbsolutePointerList
[Index
]->GetState (
4040 Private
->AbsolutePointerList
[Index
],
4043 if (!EFI_ERROR (Status
)) {
4044 if (ReturnStatus
== EFI_NOT_READY
) {
4045 ReturnStatus
= EFI_SUCCESS
;
4048 State
->ActiveButtons
= CurrentState
.ActiveButtons
;
4050 if (!(Private
->AbsolutePointerMode
.AbsoluteMinX
== 0 && Private
->AbsolutePointerMode
.AbsoluteMaxX
== 0)) {
4051 State
->CurrentX
= CurrentState
.CurrentX
;
4053 if (!(Private
->AbsolutePointerMode
.AbsoluteMinY
== 0 && Private
->AbsolutePointerMode
.AbsoluteMaxY
== 0)) {
4054 State
->CurrentY
= CurrentState
.CurrentY
;
4056 if (!(Private
->AbsolutePointerMode
.AbsoluteMinZ
== 0 && Private
->AbsolutePointerMode
.AbsoluteMaxZ
== 0)) {
4057 State
->CurrentZ
= CurrentState
.CurrentZ
;
4060 } else if (Status
== EFI_DEVICE_ERROR
) {
4061 ReturnStatus
= EFI_DEVICE_ERROR
;
4065 return ReturnStatus
;
4070 This event agregates all the events of the pointer devices in the splitter.
4071 If any events of physical pointer devices are signaled, signal the pointer
4072 splitter event. This will cause the calling code to call
4073 ConSplitterAbsolutePointerGetState ().
4075 @param Event The Event assoicated with callback.
4076 @param Context Context registered when Event was created.
4081 ConSplitterAbsolutePointerWaitForInput (
4087 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
4090 Private
= (TEXT_IN_SPLITTER_PRIVATE_DATA
*) Context
;
4093 // if AbsoluteInputEventSignalState is flagged before,
4094 // and not cleared by Reset() or GetState(), signal it
4096 if (Private
->AbsoluteInputEventSignalState
) {
4097 gBS
->SignalEvent (Event
);
4101 // if any physical console input device has key input, signal the event.
4103 for (Index
= 0; Index
< Private
->CurrentNumberOfAbsolutePointers
; Index
++) {
4104 Status
= gBS
->CheckEvent (Private
->AbsolutePointerList
[Index
]->WaitForInput
);
4105 if (!EFI_ERROR (Status
)) {
4106 gBS
->SignalEvent (Event
);
4107 Private
->AbsoluteInputEventSignalState
= TRUE
;
4114 Reset the text output device hardware and optionaly run diagnostics
4116 @param This Protocol instance pointer.
4117 @param ExtendedVerification Driver may perform more exhaustive verfication
4118 operation of the device during reset.
4120 @retval EFI_SUCCESS The text output device was reset.
4121 @retval EFI_DEVICE_ERROR The text output device is not functioning
4122 correctly and could not be reset.
4127 ConSplitterTextOutReset (
4128 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4129 IN BOOLEAN ExtendedVerification
4133 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4135 EFI_STATUS ReturnStatus
;
4137 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4140 // return the worst status met
4142 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
4143 Status
= Private
->TextOutList
[Index
].TextOut
->Reset (
4144 Private
->TextOutList
[Index
].TextOut
,
4145 ExtendedVerification
4147 if (EFI_ERROR (Status
)) {
4148 ReturnStatus
= Status
;
4152 This
->SetAttribute (This
, EFI_TEXT_ATTR (This
->Mode
->Attribute
& 0x0F, EFI_BLACK
));
4155 // reset all mode parameters
4157 TextOutSetMode (Private
, 0);
4159 return ReturnStatus
;
4164 Write a Unicode string to the output device.
4166 @param This Protocol instance pointer.
4167 @param WString The NULL-terminated Unicode string to be
4168 displayed on the output device(s). All output
4169 devices must also support the Unicode drawing
4170 defined in this file.
4172 @retval EFI_SUCCESS The string was output to the device.
4173 @retval EFI_DEVICE_ERROR The device reported an error while attempting to
4175 @retval EFI_UNSUPPORTED The output device's mode is not currently in a
4177 @retval EFI_WARN_UNKNOWN_GLYPH This warning code indicates that some of the
4178 characters in the Unicode string could not be
4179 rendered and were skipped.
4184 ConSplitterTextOutOutputString (
4185 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4190 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4192 UINTN BackSpaceCount
;
4193 EFI_STATUS ReturnStatus
;
4194 CHAR16
*TargetString
;
4196 This
->SetAttribute (This
, This
->Mode
->Attribute
);
4198 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4202 for (TargetString
= WString
; *TargetString
!= L
'\0'; TargetString
++) {
4203 if (*TargetString
== CHAR_BACKSPACE
) {
4208 if (BackSpaceCount
== 0) {
4209 TargetString
= WString
;
4211 TargetString
= AllocatePool (sizeof (CHAR16
) * (StrLen (WString
) + BackSpaceCount
+ 1));
4212 ASSERT (TargetString
!= NULL
);
4214 StrCpy (TargetString
, WString
);
4217 // return the worst status met
4219 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
4220 Status
= Private
->TextOutList
[Index
].TextOut
->OutputString (
4221 Private
->TextOutList
[Index
].TextOut
,
4224 if (EFI_ERROR (Status
)) {
4225 ReturnStatus
= Status
;
4229 if (Private
->CurrentNumberOfConsoles
> 0) {
4230 Private
->TextOutMode
.CursorColumn
= Private
->TextOutList
[0].TextOut
->Mode
->CursorColumn
;
4231 Private
->TextOutMode
.CursorRow
= Private
->TextOutList
[0].TextOut
->Mode
->CursorRow
;
4234 if (BackSpaceCount
> 0) {
4235 FreePool (TargetString
);
4238 return ReturnStatus
;
4243 Verifies that all characters in a Unicode string can be output to the
4246 @param This Protocol instance pointer.
4247 @param WString The NULL-terminated Unicode string to be
4248 examined for the output device(s).
4250 @retval EFI_SUCCESS The device(s) are capable of rendering the
4252 @retval EFI_UNSUPPORTED Some of the characters in the Unicode string
4253 cannot be rendered by one or more of the output
4254 devices mapped by the EFI handle.
4259 ConSplitterTextOutTestString (
4260 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4265 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4267 EFI_STATUS ReturnStatus
;
4269 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4272 // return the worst status met
4274 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
4275 Status
= Private
->TextOutList
[Index
].TextOut
->TestString (
4276 Private
->TextOutList
[Index
].TextOut
,
4279 if (EFI_ERROR (Status
)) {
4280 ReturnStatus
= Status
;
4284 // There is no DevNullTextOutTestString () since a Unicode buffer would
4285 // always return EFI_SUCCESS.
4286 // ReturnStatus will be EFI_SUCCESS if no consoles are present
4288 return ReturnStatus
;
4293 Returns information for an available text mode that the output device(s)
4296 @param This Protocol instance pointer.
4297 @param ModeNumber The mode number to return information on.
4298 @param Columns Returns the columns of the text output device
4299 for the requested ModeNumber.
4300 @param Rows Returns the rows of the text output device
4301 for the requested ModeNumber.
4303 @retval EFI_SUCCESS The requested mode information was returned.
4304 @retval EFI_DEVICE_ERROR The device had an error and could not complete
4306 @retval EFI_UNSUPPORTED The mode number was not valid.
4311 ConSplitterTextOutQueryMode (
4312 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4313 IN UINTN ModeNumber
,
4318 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4320 INT32
*TextOutModeMap
;
4322 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4325 // Check whether param ModeNumber is valid.
4326 // ModeNumber should be within range 0 ~ MaxMode - 1.
4328 if ( (ModeNumber
> (UINTN
)(((UINT32
)-1)>>1)) ) {
4329 return EFI_UNSUPPORTED
;
4332 if ((INT32
) ModeNumber
>= This
->Mode
->MaxMode
) {
4333 return EFI_UNSUPPORTED
;
4337 // We get the available mode from mode intersection map if it's available
4339 if (Private
->TextOutModeMap
!= NULL
) {
4340 TextOutModeMap
= Private
->TextOutModeMap
+ Private
->TextOutListCount
* ModeNumber
;
4341 CurrentMode
= (UINTN
)(*TextOutModeMap
);
4342 *Columns
= Private
->TextOutQueryData
[CurrentMode
].Columns
;
4343 *Rows
= Private
->TextOutQueryData
[CurrentMode
].Rows
;
4345 *Columns
= Private
->TextOutQueryData
[ModeNumber
].Columns
;
4346 *Rows
= Private
->TextOutQueryData
[ModeNumber
].Rows
;
4349 if (*Columns
<= 0 && *Rows
<= 0) {
4350 return EFI_UNSUPPORTED
;
4359 Sets the output device(s) to a specified mode.
4361 @param This Protocol instance pointer.
4362 @param ModeNumber The mode number to set.
4364 @retval EFI_SUCCESS The requested text mode was set.
4365 @retval EFI_DEVICE_ERROR The device had an error and could not complete
4367 @retval EFI_UNSUPPORTED The mode number was not valid.
4372 ConSplitterTextOutSetMode (
4373 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4378 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4380 INT32
*TextOutModeMap
;
4381 EFI_STATUS ReturnStatus
;
4383 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4386 // Check whether param ModeNumber is valid.
4387 // ModeNumber should be within range 0 ~ MaxMode - 1.
4389 if ( (ModeNumber
> (UINTN
)(((UINT32
)-1)>>1)) ) {
4390 return EFI_UNSUPPORTED
;
4393 if ((INT32
) ModeNumber
>= This
->Mode
->MaxMode
) {
4394 return EFI_UNSUPPORTED
;
4397 // If the mode is being set to the curent mode, then just clear the screen and return.
4399 if (Private
->TextOutMode
.Mode
== (INT32
) ModeNumber
) {
4400 return ConSplitterTextOutClearScreen (This
);
4403 // return the worst status met
4405 TextOutModeMap
= Private
->TextOutModeMap
+ Private
->TextOutListCount
* ModeNumber
;
4406 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
4407 Status
= Private
->TextOutList
[Index
].TextOut
->SetMode (
4408 Private
->TextOutList
[Index
].TextOut
,
4409 TextOutModeMap
[Index
]
4411 if (EFI_ERROR (Status
)) {
4412 ReturnStatus
= Status
;
4417 // Set mode parameter to specified mode number
4419 TextOutSetMode (Private
, ModeNumber
);
4421 return ReturnStatus
;
4426 Sets the background and foreground colors for the OutputString () and
4427 ClearScreen () functions.
4429 @param This Protocol instance pointer.
4430 @param Attribute The attribute to set. Bits 0..3 are the
4431 foreground color, and bits 4..6 are the
4432 background color. All other bits are undefined
4433 and must be zero. The valid Attributes are
4434 defined in this file.
4436 @retval EFI_SUCCESS The attribute was set.
4437 @retval EFI_DEVICE_ERROR The device had an error and could not complete
4439 @retval EFI_UNSUPPORTED The attribute requested is not defined.
4444 ConSplitterTextOutSetAttribute (
4445 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4450 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4452 EFI_STATUS ReturnStatus
;
4454 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4457 // Check whether param Attribute is valid.
4459 if ( (Attribute
> (UINTN
)(((UINT32
)-1)>>1)) ) {
4460 return EFI_UNSUPPORTED
;
4464 // return the worst status met
4466 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
4467 Status
= Private
->TextOutList
[Index
].TextOut
->SetAttribute (
4468 Private
->TextOutList
[Index
].TextOut
,
4471 if (EFI_ERROR (Status
)) {
4472 ReturnStatus
= Status
;
4476 Private
->TextOutMode
.Attribute
= (INT32
) Attribute
;
4478 return ReturnStatus
;
4483 Clears the output device(s) display to the currently selected background
4486 @param This Protocol instance pointer.
4488 @retval EFI_SUCCESS The operation completed successfully.
4489 @retval EFI_DEVICE_ERROR The device had an error and could not complete
4491 @retval EFI_UNSUPPORTED The output device is not in a valid text mode.
4496 ConSplitterTextOutClearScreen (
4497 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
4501 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4503 EFI_STATUS ReturnStatus
;
4505 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4508 // return the worst status met
4510 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
4511 Status
= Private
->TextOutList
[Index
].TextOut
->ClearScreen (Private
->TextOutList
[Index
].TextOut
);
4512 if (EFI_ERROR (Status
)) {
4513 ReturnStatus
= Status
;
4518 // No need to do extra check here as whether (Column, Row) is valid has
4519 // been checked in ConSplitterTextOutSetCursorPosition. And (0, 0) should
4520 // always be supported.
4522 Private
->TextOutMode
.CursorColumn
= 0;
4523 Private
->TextOutMode
.CursorRow
= 0;
4524 Private
->TextOutMode
.CursorVisible
= TRUE
;
4526 return ReturnStatus
;
4531 Sets the current coordinates of the cursor position
4533 @param This Protocol instance pointer.
4534 @param Column The column position to set the cursor to. Must be
4535 greater than or equal to zero and less than the
4536 number of columns by QueryMode ().
4537 @param Row The row position to set the cursor to. Must be
4538 greater than or equal to zero and less than the
4539 number of rows by QueryMode ().
4541 @retval EFI_SUCCESS The operation completed successfully.
4542 @retval EFI_DEVICE_ERROR The device had an error and could not complete
4544 @retval EFI_UNSUPPORTED The output device is not in a valid text mode,
4545 or the cursor position is invalid for the
4551 ConSplitterTextOutSetCursorPosition (
4552 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4558 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4560 EFI_STATUS ReturnStatus
;
4563 INT32
*TextOutModeMap
;
4567 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4568 TextOutModeMap
= NULL
;
4569 ModeNumber
= Private
->TextOutMode
.Mode
;
4572 // Get current MaxColumn and MaxRow from intersection map
4574 if (Private
->TextOutModeMap
!= NULL
) {
4575 TextOutModeMap
= Private
->TextOutModeMap
+ Private
->TextOutListCount
* ModeNumber
;
4576 CurrentMode
= *TextOutModeMap
;
4578 CurrentMode
= ModeNumber
;
4581 MaxColumn
= Private
->TextOutQueryData
[CurrentMode
].Columns
;
4582 MaxRow
= Private
->TextOutQueryData
[CurrentMode
].Rows
;
4584 if (Column
>= MaxColumn
|| Row
>= MaxRow
) {
4585 return EFI_UNSUPPORTED
;
4588 // return the worst status met
4590 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
4591 Status
= Private
->TextOutList
[Index
].TextOut
->SetCursorPosition (
4592 Private
->TextOutList
[Index
].TextOut
,
4596 if (EFI_ERROR (Status
)) {
4597 ReturnStatus
= Status
;
4602 // No need to do extra check here as whether (Column, Row) is valid has
4603 // been checked in ConSplitterTextOutSetCursorPosition. And (0, 0) should
4604 // always be supported.
4606 Private
->TextOutMode
.CursorColumn
= (INT32
) Column
;
4607 Private
->TextOutMode
.CursorRow
= (INT32
) Row
;
4609 return ReturnStatus
;
4614 Makes the cursor visible or invisible
4616 @param This Protocol instance pointer.
4617 @param Visible If TRUE, the cursor is set to be visible. If
4618 FALSE, the cursor is set to be invisible.
4620 @retval EFI_SUCCESS The operation completed successfully.
4621 @retval EFI_DEVICE_ERROR The device had an error and could not complete
4622 the request, or the device does not support
4623 changing the cursor mode.
4624 @retval EFI_UNSUPPORTED The output device is not in a valid text mode.
4629 ConSplitterTextOutEnableCursor (
4630 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4635 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4637 EFI_STATUS ReturnStatus
;
4639 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4642 // return the worst status met
4644 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
4645 Status
= Private
->TextOutList
[Index
].TextOut
->EnableCursor (
4646 Private
->TextOutList
[Index
].TextOut
,
4649 if (EFI_ERROR (Status
)) {
4650 ReturnStatus
= Status
;
4654 Private
->TextOutMode
.CursorVisible
= Visible
;
4656 return ReturnStatus
;