2 Console Splitter Driver. Any Handle that attatched console I/O protocols
3 (Console In device, Console Out device, Console Error device, Simple Pointer
4 protocol, Absolute Pointer protocol) can be bound by this driver.
6 So far it works like any other driver by opening a SimpleTextIn and/or
7 SimpleTextOut protocol with EFI_OPEN_PROTOCOL_BY_DRIVER attributes. The big
8 difference is this driver does not layer a protocol on the passed in
9 handle, or construct a child handle like a standard device or bus driver.
10 This driver produces three virtual handles as children, one for console input
11 splitter, one for console output splitter and one for error output splitter.
12 These 3 virtual handles would be installed on gST.
14 Each virtual handle, that supports the Console I/O protocol, will be produced
15 in the driver entry point. The virtual handle are added on driver entry and
16 never removed. Such design ensures sytem function well during none console
19 Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>
20 This program and the accompanying materials
21 are licensed and made available under the terms and conditions of the BSD License
22 which accompanies this distribution. The full text of the license may be found at
23 http://opensource.org/licenses/bsd-license.php
25 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
26 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
30 #include "ConSplitter.h"
33 // 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
,
174 (TEXT_OUT_AND_GOP_DATA
*) NULL
,
176 (TEXT_OUT_SPLITTER_QUERY_DATA
*) NULL
,
182 // Standard Error Text Out Splitter Data Template
184 GLOBAL_REMOVE_IF_UNREFERENCED TEXT_OUT_SPLITTER_PRIVATE_DATA mStdErr
= {
185 TEXT_OUT_SPLITTER_PRIVATE_DATA_SIGNATURE
,
188 ConSplitterTextOutReset
,
189 ConSplitterTextOutOutputString
,
190 ConSplitterTextOutTestString
,
191 ConSplitterTextOutQueryMode
,
192 ConSplitterTextOutSetMode
,
193 ConSplitterTextOutSetAttribute
,
194 ConSplitterTextOutClearScreen
,
195 ConSplitterTextOutSetCursorPosition
,
196 ConSplitterTextOutEnableCursor
,
197 (EFI_SIMPLE_TEXT_OUTPUT_MODE
*) NULL
224 (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*) NULL
,
229 (TEXT_OUT_AND_GOP_DATA
*) NULL
,
231 (TEXT_OUT_SPLITTER_QUERY_DATA
*) NULL
,
237 // Driver binding instance for Console Input Device
239 EFI_DRIVER_BINDING_PROTOCOL gConSplitterConInDriverBinding
= {
240 ConSplitterConInDriverBindingSupported
,
241 ConSplitterConInDriverBindingStart
,
242 ConSplitterConInDriverBindingStop
,
249 // Driver binding instance for Console Out device
251 EFI_DRIVER_BINDING_PROTOCOL gConSplitterConOutDriverBinding
= {
252 ConSplitterConOutDriverBindingSupported
,
253 ConSplitterConOutDriverBindingStart
,
254 ConSplitterConOutDriverBindingStop
,
261 // Driver binding instance for Standard Error device
263 EFI_DRIVER_BINDING_PROTOCOL gConSplitterStdErrDriverBinding
= {
264 ConSplitterStdErrDriverBindingSupported
,
265 ConSplitterStdErrDriverBindingStart
,
266 ConSplitterStdErrDriverBindingStop
,
273 // Driver binding instance for Simple Pointer protocol
275 EFI_DRIVER_BINDING_PROTOCOL gConSplitterSimplePointerDriverBinding
= {
276 ConSplitterSimplePointerDriverBindingSupported
,
277 ConSplitterSimplePointerDriverBindingStart
,
278 ConSplitterSimplePointerDriverBindingStop
,
285 // Driver binding instance for Absolute Pointer protocol
287 EFI_DRIVER_BINDING_PROTOCOL gConSplitterAbsolutePointerDriverBinding
= {
288 ConSplitterAbsolutePointerDriverBindingSupported
,
289 ConSplitterAbsolutePointerDriverBindingStart
,
290 ConSplitterAbsolutePointerDriverBindingStop
,
297 The Entry Point for module ConSplitter. The user code starts with this function.
299 Installs driver module protocols and. Creates virtual device handles for ConIn,
300 ConOut, and StdErr. Installs Simple Text In protocol, Simple Text In Ex protocol,
301 Simple Pointer protocol, Absolute Pointer protocol on those virtual handlers.
302 Installs Graphics Output protocol and/or UGA Draw protocol if needed.
304 @param[in] ImageHandle The firmware allocated handle for the EFI image.
305 @param[in] SystemTable A pointer to the EFI System Table.
307 @retval EFI_SUCCESS The entry point is executed successfully.
308 @retval other Some error occurs when executing this entry point.
313 ConSplitterDriverEntry(
314 IN EFI_HANDLE ImageHandle
,
315 IN EFI_SYSTEM_TABLE
*SystemTable
321 // Install driver model protocol(s).
323 Status
= EfiLibInstallDriverBindingComponentName2 (
326 &gConSplitterConInDriverBinding
,
328 &gConSplitterConInComponentName
,
329 &gConSplitterConInComponentName2
331 ASSERT_EFI_ERROR (Status
);
333 Status
= EfiLibInstallDriverBindingComponentName2 (
336 &gConSplitterSimplePointerDriverBinding
,
338 &gConSplitterSimplePointerComponentName
,
339 &gConSplitterSimplePointerComponentName2
341 ASSERT_EFI_ERROR (Status
);
343 Status
= EfiLibInstallDriverBindingComponentName2 (
346 &gConSplitterAbsolutePointerDriverBinding
,
348 &gConSplitterAbsolutePointerComponentName
,
349 &gConSplitterAbsolutePointerComponentName2
351 ASSERT_EFI_ERROR (Status
);
353 Status
= EfiLibInstallDriverBindingComponentName2 (
356 &gConSplitterConOutDriverBinding
,
358 &gConSplitterConOutComponentName
,
359 &gConSplitterConOutComponentName2
361 ASSERT_EFI_ERROR (Status
);
363 Status
= EfiLibInstallDriverBindingComponentName2 (
366 &gConSplitterStdErrDriverBinding
,
368 &gConSplitterStdErrComponentName
,
369 &gConSplitterStdErrComponentName2
371 ASSERT_EFI_ERROR (Status
);
374 // Either Graphics Output protocol or UGA Draw protocol must be supported.
376 ASSERT (FeaturePcdGet (PcdConOutGopSupport
) ||
377 FeaturePcdGet (PcdConOutUgaSupport
));
380 // The driver creates virtual handles for ConIn, ConOut, StdErr.
381 // The virtual handles will always exist even if no console exist in the
382 // system. This is need to support hotplug devices like USB.
385 // Create virtual device handle for ConIn Splitter
387 Status
= ConSplitterTextInConstructor (&mConIn
);
388 if (!EFI_ERROR (Status
)) {
389 Status
= gBS
->InstallMultipleProtocolInterfaces (
390 &mConIn
.VirtualHandle
,
391 &gEfiSimpleTextInProtocolGuid
,
393 &gEfiSimpleTextInputExProtocolGuid
,
395 &gEfiSimplePointerProtocolGuid
,
396 &mConIn
.SimplePointer
,
397 &gEfiAbsolutePointerProtocolGuid
,
398 &mConIn
.AbsolutePointer
,
401 if (!EFI_ERROR (Status
)) {
403 // Update the EFI System Table with new virtual console
404 // and update the pointer to Simple Text Input protocol.
406 gST
->ConsoleInHandle
= mConIn
.VirtualHandle
;
407 gST
->ConIn
= &mConIn
.TextIn
;
411 // Create virtual device handle for ConOut Splitter
413 Status
= ConSplitterTextOutConstructor (&mConOut
);
414 if (!EFI_ERROR (Status
)) {
415 if (!FeaturePcdGet (PcdConOutGopSupport
)) {
417 // If Graphics Outpurt protocol not supported, UGA Draw protocol is installed
418 // on the virtual handle.
420 Status
= gBS
->InstallMultipleProtocolInterfaces (
421 &mConOut
.VirtualHandle
,
422 &gEfiSimpleTextOutProtocolGuid
,
424 &gEfiUgaDrawProtocolGuid
,
428 } else if (!FeaturePcdGet (PcdConOutUgaSupport
)) {
430 // If UGA Draw protocol not supported, Graphics Output Protocol is installed
431 // on virtual handle.
433 Status
= gBS
->InstallMultipleProtocolInterfaces (
434 &mConOut
.VirtualHandle
,
435 &gEfiSimpleTextOutProtocolGuid
,
437 &gEfiGraphicsOutputProtocolGuid
,
438 &mConOut
.GraphicsOutput
,
443 // Boot Graphics Output protocol and UGA Draw protocol are supported,
444 // both they will be installed on virtual handle.
446 Status
= gBS
->InstallMultipleProtocolInterfaces (
447 &mConOut
.VirtualHandle
,
448 &gEfiSimpleTextOutProtocolGuid
,
450 &gEfiGraphicsOutputProtocolGuid
,
451 &mConOut
.GraphicsOutput
,
452 &gEfiUgaDrawProtocolGuid
,
458 if (!EFI_ERROR (Status
)) {
460 // Update the EFI System Table with new virtual console
461 // and Update the pointer to Text Output protocol.
463 gST
->ConsoleOutHandle
= mConOut
.VirtualHandle
;
464 gST
->ConOut
= &mConOut
.TextOut
;
470 // Create virtual device handle for StdErr Splitter
472 Status
= ConSplitterTextOutConstructor (&mStdErr
);
473 if (!EFI_ERROR (Status
)) {
474 Status
= gBS
->InstallMultipleProtocolInterfaces (
475 &mStdErr
.VirtualHandle
,
476 &gEfiSimpleTextOutProtocolGuid
,
480 if (!EFI_ERROR (Status
)) {
482 // Update the EFI System Table with new virtual console
483 // and update the pointer to Text Output protocol.
485 gST
->StandardErrorHandle
= mStdErr
.VirtualHandle
;
486 gST
->StdErr
= &mStdErr
.TextOut
;
491 // Update the CRC32 in the EFI System Table header
494 gBS
->CalculateCrc32 (
505 Construct console input devices' private data.
507 @param ConInPrivate A pointer to the TEXT_IN_SPLITTER_PRIVATE_DATA
510 @retval EFI_OUT_OF_RESOURCES Out of resources.
511 @retval EFI_SUCCESS Text Input Devcie's private data has been constructed.
512 @retval other Failed to construct private data.
516 ConSplitterTextInConstructor (
517 TEXT_IN_SPLITTER_PRIVATE_DATA
*ConInPrivate
523 // Allocate buffer for Simple Text Input device
525 Status
= ConSplitterGrowBuffer (
526 sizeof (EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*),
527 &ConInPrivate
->TextInListCount
,
528 (VOID
**) &ConInPrivate
->TextInList
530 if (EFI_ERROR (Status
)) {
531 return EFI_OUT_OF_RESOURCES
;
535 // Create Event to wait for a key
537 Status
= gBS
->CreateEvent (
540 ConSplitterTextInWaitForKey
,
542 &ConInPrivate
->TextIn
.WaitForKey
544 ASSERT_EFI_ERROR (Status
);
547 // Allocate buffer for Simple Text Input Ex device
549 Status
= ConSplitterGrowBuffer (
550 sizeof (EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*),
551 &ConInPrivate
->TextInExListCount
,
552 (VOID
**) &ConInPrivate
->TextInExList
554 if (EFI_ERROR (Status
)) {
555 return EFI_OUT_OF_RESOURCES
;
558 // Create Event to wait for a key Ex
560 Status
= gBS
->CreateEvent (
563 ConSplitterTextInWaitForKey
,
565 &ConInPrivate
->TextInEx
.WaitForKeyEx
567 ASSERT_EFI_ERROR (Status
);
569 InitializeListHead (&ConInPrivate
->NotifyList
);
571 ConInPrivate
->AbsolutePointer
.Mode
= &ConInPrivate
->AbsolutePointerMode
;
573 // Allocate buffer for Absolute Pointer device
575 Status
= ConSplitterGrowBuffer (
576 sizeof (EFI_ABSOLUTE_POINTER_PROTOCOL
*),
577 &ConInPrivate
->AbsolutePointerListCount
,
578 (VOID
**) &ConInPrivate
->AbsolutePointerList
580 if (EFI_ERROR (Status
)) {
581 return EFI_OUT_OF_RESOURCES
;
584 // Create Event to wait for device input for Absolute pointer device
586 Status
= gBS
->CreateEvent (
589 ConSplitterAbsolutePointerWaitForInput
,
591 &ConInPrivate
->AbsolutePointer
.WaitForInput
593 ASSERT_EFI_ERROR (Status
);
595 ConInPrivate
->SimplePointer
.Mode
= &ConInPrivate
->SimplePointerMode
;
597 // Allocate buffer for Simple Pointer device
599 Status
= ConSplitterGrowBuffer (
600 sizeof (EFI_SIMPLE_POINTER_PROTOCOL
*),
601 &ConInPrivate
->PointerListCount
,
602 (VOID
**) &ConInPrivate
->PointerList
604 if (EFI_ERROR (Status
)) {
605 return EFI_OUT_OF_RESOURCES
;
608 // Create Event to wait for device input for Simple pointer device
610 Status
= gBS
->CreateEvent (
613 ConSplitterSimplePointerWaitForInput
,
615 &ConInPrivate
->SimplePointer
.WaitForInput
622 Construct console output devices' private data.
624 @param ConOutPrivate A pointer to the TEXT_OUT_SPLITTER_PRIVATE_DATA
627 @retval EFI_OUT_OF_RESOURCES Out of resources.
628 @retval EFI_SUCCESS Text Input Devcie's private data has been constructed.
632 ConSplitterTextOutConstructor (
633 TEXT_OUT_SPLITTER_PRIVATE_DATA
*ConOutPrivate
637 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*Info
;
640 // Copy protocols template
642 if (FeaturePcdGet (PcdConOutUgaSupport
)) {
643 CopyMem (&ConOutPrivate
->UgaDraw
, &mUgaDrawProtocolTemplate
, sizeof (EFI_UGA_DRAW_PROTOCOL
));
645 if (FeaturePcdGet (PcdConOutGopSupport
)) {
646 CopyMem (&ConOutPrivate
->GraphicsOutput
, &mGraphicsOutputProtocolTemplate
, sizeof (EFI_GRAPHICS_OUTPUT_PROTOCOL
));
650 // Initilize console output splitter's private data.
652 ConOutPrivate
->TextOut
.Mode
= &ConOutPrivate
->TextOutMode
;
655 // When new console device is added, the new mode will be set later,
656 // so put current mode back to init state.
658 ConOutPrivate
->TextOutMode
.Mode
= 0xFF;
660 // Allocate buffer for Console Out device
662 Status
= ConSplitterGrowBuffer (
663 sizeof (TEXT_OUT_AND_GOP_DATA
),
664 &ConOutPrivate
->TextOutListCount
,
665 (VOID
**) &ConOutPrivate
->TextOutList
667 if (EFI_ERROR (Status
)) {
668 return EFI_OUT_OF_RESOURCES
;
671 // Allocate buffer for Text Out query data
673 Status
= ConSplitterGrowBuffer (
674 sizeof (TEXT_OUT_SPLITTER_QUERY_DATA
),
675 &ConOutPrivate
->TextOutQueryDataCount
,
676 (VOID
**) &ConOutPrivate
->TextOutQueryData
678 if (EFI_ERROR (Status
)) {
679 return EFI_OUT_OF_RESOURCES
;
683 // Setup the default console to 80 x 25 and mode to 0
685 ConOutPrivate
->TextOutQueryData
[0].Columns
= 80;
686 ConOutPrivate
->TextOutQueryData
[0].Rows
= 25;
687 TextOutSetMode (ConOutPrivate
, 0);
690 if (FeaturePcdGet (PcdConOutUgaSupport
)) {
692 // Setup the UgaDraw to 800 x 600 x 32 bits per pixel, 60Hz.
694 ConSplitterUgaDrawSetMode (&ConOutPrivate
->UgaDraw
, 800, 600, 32, 60);
696 if (FeaturePcdGet (PcdConOutGopSupport
)) {
698 // Setup resource for mode information in Graphics Output Protocol interface
700 if ((ConOutPrivate
->GraphicsOutput
.Mode
= AllocateZeroPool (sizeof (EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE
))) == NULL
) {
701 return EFI_OUT_OF_RESOURCES
;
703 if ((ConOutPrivate
->GraphicsOutput
.Mode
->Info
= AllocateZeroPool (sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
))) == NULL
) {
704 return EFI_OUT_OF_RESOURCES
;
707 // Setup the DevNullGraphicsOutput to 800 x 600 x 32 bits per pixel
708 // DevNull will be updated to user-defined mode after driver has started.
710 if ((ConOutPrivate
->GraphicsOutputModeBuffer
= AllocateZeroPool (sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
))) == NULL
) {
711 return EFI_OUT_OF_RESOURCES
;
713 Info
= &ConOutPrivate
->GraphicsOutputModeBuffer
[0];
715 Info
->HorizontalResolution
= 800;
716 Info
->VerticalResolution
= 600;
717 Info
->PixelFormat
= PixelBltOnly
;
718 Info
->PixelsPerScanLine
= 800;
719 CopyMem (ConOutPrivate
->GraphicsOutput
.Mode
->Info
, Info
, sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
));
720 ConOutPrivate
->GraphicsOutput
.Mode
->SizeOfInfo
= sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
);
723 // Initialize the following items, theset items remain unchanged in GraphicsOutput->SetMode()
724 // GraphicsOutputMode->FrameBufferBase, GraphicsOutputMode->FrameBufferSize
726 ConOutPrivate
->GraphicsOutput
.Mode
->FrameBufferBase
= (EFI_PHYSICAL_ADDRESS
) (UINTN
) NULL
;
727 ConOutPrivate
->GraphicsOutput
.Mode
->FrameBufferSize
= 0;
729 ConOutPrivate
->GraphicsOutput
.Mode
->MaxMode
= 1;
731 // Initial current mode to unknown state, and then set to mode 0
733 ConOutPrivate
->GraphicsOutput
.Mode
->Mode
= 0xffff;
734 ConOutPrivate
->GraphicsOutput
.SetMode (&ConOutPrivate
->GraphicsOutput
, 0);
742 Test to see if the specified protocol could be supported on the specified device.
744 @param This Driver Binding protocol pointer.
745 @param ControllerHandle Handle of device to test.
746 @param Guid The specified protocol.
748 @retval EFI_SUCCESS The specified protocol is supported on this device.
749 @retval EFI_UNSUPPORTED The specified protocol attempts to be installed on virtul handle.
750 @retval other Failed to open specified protocol on this device.
754 ConSplitterSupported (
755 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
756 IN EFI_HANDLE ControllerHandle
,
764 // Make sure the Console Splitter does not attempt to attach to itself
766 if (ControllerHandle
== mConIn
.VirtualHandle
||
767 ControllerHandle
== mConOut
.VirtualHandle
||
768 ControllerHandle
== mStdErr
.VirtualHandle
770 return EFI_UNSUPPORTED
;
774 // Check to see whether the specific protocol could be opened BY_DRIVER
776 Status
= gBS
->OpenProtocol (
780 This
->DriverBindingHandle
,
782 EFI_OPEN_PROTOCOL_BY_DRIVER
785 if (EFI_ERROR (Status
)) {
792 This
->DriverBindingHandle
,
800 Test to see if Console In Device could be supported on the Controller.
802 @param This Driver Binding protocol instance pointer.
803 @param ControllerHandle Handle of device to test.
804 @param RemainingDevicePath Optional parameter use to pick a specific child
807 @retval EFI_SUCCESS This driver supports this device.
808 @retval other This driver does not support this device.
813 ConSplitterConInDriverBindingSupported (
814 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
815 IN EFI_HANDLE ControllerHandle
,
816 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
819 return ConSplitterSupported (
822 &gEfiConsoleInDeviceGuid
827 Test to see if Simple Pointer protocol could be supported on the Controller.
829 @param This Driver Binding protocol instance pointer.
830 @param ControllerHandle Handle of device to test.
831 @param RemainingDevicePath Optional parameter use to pick a specific child
834 @retval EFI_SUCCESS This driver supports this device.
835 @retval other This driver does not support this device.
840 ConSplitterSimplePointerDriverBindingSupported (
841 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
842 IN EFI_HANDLE ControllerHandle
,
843 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
846 return ConSplitterSupported (
849 &gEfiSimplePointerProtocolGuid
854 Test to see if Absolute Pointer protocol could be supported on the Controller.
856 @param This Driver Binding protocol instance pointer.
857 @param ControllerHandle Handle of device to test.
858 @param RemainingDevicePath Optional parameter use to pick a specific child
861 @retval EFI_SUCCESS This driver supports this device.
862 @retval other This driver does not support this device.
867 ConSplitterAbsolutePointerDriverBindingSupported (
868 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
869 IN EFI_HANDLE ControllerHandle
,
870 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
873 return ConSplitterSupported (
876 &gEfiAbsolutePointerProtocolGuid
882 Test to see if Console Out Device could be supported on the Controller.
884 @param This Driver Binding protocol instance pointer.
885 @param ControllerHandle Handle of device to test.
886 @param RemainingDevicePath Optional parameter use to pick a specific child
889 @retval EFI_SUCCESS This driver supports this device.
890 @retval other This driver does not support this device.
895 ConSplitterConOutDriverBindingSupported (
896 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
897 IN EFI_HANDLE ControllerHandle
,
898 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
901 return ConSplitterSupported (
904 &gEfiConsoleOutDeviceGuid
909 Test to see if Standard Error Device could be supported on the Controller.
911 @param This Driver Binding protocol instance pointer.
912 @param ControllerHandle Handle of device to test.
913 @param RemainingDevicePath Optional parameter use to pick a specific child
916 @retval EFI_SUCCESS This driver supports this device.
917 @retval other This driver does not support this device.
922 ConSplitterStdErrDriverBindingSupported (
923 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
924 IN EFI_HANDLE ControllerHandle
,
925 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
928 return ConSplitterSupported (
931 &gEfiStandardErrorDeviceGuid
937 Start ConSplitter on devcie handle by opening Console Device Guid on device handle
938 and the console virtual handle. And Get the console interface on controller handle.
940 @param This Driver Binding protocol instance pointer.
941 @param ControllerHandle Handle of device.
942 @param ConSplitterVirtualHandle Console virtual Handle.
943 @param DeviceGuid The specified Console Device, such as ConInDev,
945 @param InterfaceGuid The specified protocol to be opened.
946 @param Interface Protocol interface returned.
948 @retval EFI_SUCCESS This driver supports this device.
949 @retval other Failed to open the specified Console Device Guid
950 or specified protocol.
955 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
956 IN EFI_HANDLE ControllerHandle
,
957 IN EFI_HANDLE ConSplitterVirtualHandle
,
958 IN EFI_GUID
*DeviceGuid
,
959 IN EFI_GUID
*InterfaceGuid
,
967 // Check to see whether the ControllerHandle has the DeviceGuid on it.
969 Status
= gBS
->OpenProtocol (
973 This
->DriverBindingHandle
,
975 EFI_OPEN_PROTOCOL_BY_DRIVER
977 if (EFI_ERROR (Status
)) {
982 // Open the Parent Handle for the child.
984 Status
= gBS
->OpenProtocol (
988 This
->DriverBindingHandle
,
989 ConSplitterVirtualHandle
,
990 EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
992 if (EFI_ERROR (Status
)) {
997 // Open InterfaceGuid on the virtul handle.
999 Status
= gBS
->OpenProtocol (
1003 This
->DriverBindingHandle
,
1004 ConSplitterVirtualHandle
,
1005 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1008 if (!EFI_ERROR (Status
)) {
1013 // close the DeviceGuid on ConSplitter VirtualHandle.
1015 gBS
->CloseProtocol (
1018 This
->DriverBindingHandle
,
1019 ConSplitterVirtualHandle
1024 // close the DeviceGuid on ControllerHandle.
1026 gBS
->CloseProtocol (
1029 This
->DriverBindingHandle
,
1038 Start Console In Consplitter on device handle.
1040 @param This Driver Binding protocol instance pointer.
1041 @param ControllerHandle Handle of device to bind driver to.
1042 @param RemainingDevicePath Optional parameter use to pick a specific child
1045 @retval EFI_SUCCESS Console In Consplitter is added to ControllerHandle.
1046 @retval other Console In Consplitter does not support this device.
1051 ConSplitterConInDriverBindingStart (
1052 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1053 IN EFI_HANDLE ControllerHandle
,
1054 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
1058 EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*TextIn
;
1059 EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*TextInEx
;
1062 // Start ConSplitter on ControllerHandle, and create the virtual
1063 // agrogated console device on first call Start for a SimpleTextIn handle.
1065 Status
= ConSplitterStart (
1068 mConIn
.VirtualHandle
,
1069 &gEfiConsoleInDeviceGuid
,
1070 &gEfiSimpleTextInProtocolGuid
,
1073 if (EFI_ERROR (Status
)) {
1078 // Add this device into Text In devices list.
1080 Status
= ConSplitterTextInAddDevice (&mConIn
, TextIn
);
1081 if (EFI_ERROR (Status
)) {
1085 Status
= gBS
->OpenProtocol (
1087 &gEfiSimpleTextInputExProtocolGuid
,
1088 (VOID
**) &TextInEx
,
1089 This
->DriverBindingHandle
,
1090 mConIn
.VirtualHandle
,
1091 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1093 if (!EFI_ERROR (Status
)) {
1095 // If Simple Text Input Ex protocol exists,
1096 // add this device into Text In Ex devices list.
1098 Status
= ConSplitterTextInExAddDevice (&mConIn
, TextInEx
);
1106 Start Simple Pointer Consplitter on device handle.
1108 @param This Driver Binding protocol instance pointer.
1109 @param ControllerHandle Handle of device to bind driver to.
1110 @param RemainingDevicePath Optional parameter use to pick a specific child
1113 @retval EFI_SUCCESS Simple Pointer Consplitter is added to ControllerHandle.
1114 @retval other Simple Pointer Consplitter does not support this device.
1119 ConSplitterSimplePointerDriverBindingStart (
1120 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1121 IN EFI_HANDLE ControllerHandle
,
1122 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
1126 EFI_SIMPLE_POINTER_PROTOCOL
*SimplePointer
;
1129 // Start ConSplitter on ControllerHandle, and create the virtual
1130 // agrogated console device on first call Start for a SimplePointer handle.
1132 Status
= ConSplitterStart (
1135 mConIn
.VirtualHandle
,
1136 &gEfiSimplePointerProtocolGuid
,
1137 &gEfiSimplePointerProtocolGuid
,
1138 (VOID
**) &SimplePointer
1140 if (EFI_ERROR (Status
)) {
1145 // Add this devcie into Simple Pointer devices list.
1147 return ConSplitterSimplePointerAddDevice (&mConIn
, SimplePointer
);
1152 Start Absolute Pointer Consplitter on device handle.
1154 @param This Driver Binding protocol instance pointer.
1155 @param ControllerHandle Handle of device to bind driver to.
1156 @param RemainingDevicePath Optional parameter use to pick a specific child
1159 @retval EFI_SUCCESS Absolute Pointer Consplitter is added to ControllerHandle.
1160 @retval other Absolute Pointer Consplitter does not support this device.
1165 ConSplitterAbsolutePointerDriverBindingStart (
1166 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1167 IN EFI_HANDLE ControllerHandle
,
1168 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
1172 EFI_ABSOLUTE_POINTER_PROTOCOL
*AbsolutePointer
;
1175 // Start ConSplitter on ControllerHandle, and create the virtual
1176 // agrogated console device on first call Start for a AbsolutePointer handle.
1178 Status
= ConSplitterStart (
1181 mConIn
.VirtualHandle
,
1182 &gEfiAbsolutePointerProtocolGuid
,
1183 &gEfiAbsolutePointerProtocolGuid
,
1184 (VOID
**) &AbsolutePointer
1187 if (EFI_ERROR (Status
)) {
1192 // Add this devcie into Absolute Pointer devices list.
1194 return ConSplitterAbsolutePointerAddDevice (&mConIn
, AbsolutePointer
);
1199 Start Console Out Consplitter on device handle.
1201 @param This Driver Binding protocol instance pointer.
1202 @param ControllerHandle Handle of device to bind driver to.
1203 @param RemainingDevicePath Optional parameter use to pick a specific child
1206 @retval EFI_SUCCESS Console Out Consplitter is added to ControllerHandle.
1207 @retval other Console Out Consplitter does not support this device.
1212 ConSplitterConOutDriverBindingStart (
1213 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1214 IN EFI_HANDLE ControllerHandle
,
1215 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
1219 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
;
1220 EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
;
1221 EFI_UGA_DRAW_PROTOCOL
*UgaDraw
;
1223 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*Info
;
1226 // Start ConSplitter on ControllerHandle, and create the virtual
1227 // agrogated console device on first call Start for a ConsoleOut handle.
1229 Status
= ConSplitterStart (
1232 mConOut
.VirtualHandle
,
1233 &gEfiConsoleOutDeviceGuid
,
1234 &gEfiSimpleTextOutProtocolGuid
,
1237 if (EFI_ERROR (Status
)) {
1241 GraphicsOutput
= NULL
;
1244 // Try to Open Graphics Output protocol
1246 Status
= gBS
->OpenProtocol (
1248 &gEfiGraphicsOutputProtocolGuid
,
1249 (VOID
**) &GraphicsOutput
,
1250 This
->DriverBindingHandle
,
1251 mConOut
.VirtualHandle
,
1252 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1255 if (EFI_ERROR (Status
) && FeaturePcdGet (PcdUgaConsumeSupport
)) {
1257 // Open UGA DRAW protocol
1261 &gEfiUgaDrawProtocolGuid
,
1263 This
->DriverBindingHandle
,
1264 mConOut
.VirtualHandle
,
1265 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1270 // When new console device is added, the new mode will be set later,
1271 // so put current mode back to init state.
1273 mConOut
.TextOutMode
.Mode
= 0xFF;
1276 // If both ConOut and StdErr incorporate the same Text Out device,
1277 // their MaxMode and QueryData should be the intersection of both.
1279 Status
= ConSplitterTextOutAddDevice (&mConOut
, TextOut
, GraphicsOutput
, UgaDraw
);
1280 ConSplitterTextOutSetAttribute (&mConOut
.TextOut
, EFI_TEXT_ATTR (EFI_LIGHTGRAY
, EFI_BLACK
));
1282 if (FeaturePcdGet (PcdConOutUgaSupport
)) {
1284 // Get the UGA mode data of ConOut from the current mode
1286 if (GraphicsOutput
!= NULL
) {
1287 Status
= GraphicsOutput
->QueryMode (GraphicsOutput
, GraphicsOutput
->Mode
->Mode
, &SizeOfInfo
, &Info
);
1288 if (EFI_ERROR (Status
)) {
1291 ASSERT ( SizeOfInfo
<= sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
));
1293 mConOut
.UgaHorizontalResolution
= Info
->HorizontalResolution
;
1294 mConOut
.UgaVerticalResolution
= Info
->VerticalResolution
;
1295 mConOut
.UgaColorDepth
= 32;
1296 mConOut
.UgaRefreshRate
= 60;
1300 } else if (UgaDraw
!= NULL
&& FeaturePcdGet (PcdUgaConsumeSupport
)) {
1301 Status
= UgaDraw
->GetMode (
1303 &mConOut
.UgaHorizontalResolution
,
1304 &mConOut
.UgaVerticalResolution
,
1305 &mConOut
.UgaColorDepth
,
1306 &mConOut
.UgaRefreshRate
1316 Start Standard Error Consplitter on device handle.
1318 @param This Driver Binding protocol instance pointer.
1319 @param ControllerHandle Handle of device to bind driver to.
1320 @param RemainingDevicePath Optional parameter use to pick a specific child
1323 @retval EFI_SUCCESS Standard Error Consplitter is added to ControllerHandle.
1324 @retval other Standard Error Consplitter does not support this device.
1329 ConSplitterStdErrDriverBindingStart (
1330 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1331 IN EFI_HANDLE ControllerHandle
,
1332 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
1336 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
;
1339 // Start ConSplitter on ControllerHandle, and create the virtual
1340 // agrogated console device on first call Start for a StandardError handle.
1342 Status
= ConSplitterStart (
1345 mStdErr
.VirtualHandle
,
1346 &gEfiStandardErrorDeviceGuid
,
1347 &gEfiSimpleTextOutProtocolGuid
,
1350 if (EFI_ERROR (Status
)) {
1355 // When new console device is added, the new mode will be set later,
1356 // so put current mode back to init state.
1358 mStdErr
.TextOutMode
.Mode
= 0xFF;
1361 // If both ConOut and StdErr incorporate the same Text Out device,
1362 // their MaxMode and QueryData should be the intersection of both.
1364 Status
= ConSplitterTextOutAddDevice (&mStdErr
, TextOut
, NULL
, NULL
);
1365 ConSplitterTextOutSetAttribute (&mStdErr
.TextOut
, EFI_TEXT_ATTR (EFI_MAGENTA
, EFI_BLACK
));
1366 if (EFI_ERROR (Status
)) {
1375 Stop ConSplitter on device handle by closing Console Device Guid on device handle
1376 and the console virtual handle.
1378 @param This Protocol instance pointer.
1379 @param ControllerHandle Handle of device.
1380 @param ConSplitterVirtualHandle Console virtual Handle.
1381 @param DeviceGuid The specified Console Device, such as ConInDev,
1383 @param InterfaceGuid The specified protocol to be opened.
1384 @param Interface Protocol interface returned.
1386 @retval EFI_SUCCESS Stop ConSplitter on ControllerHandle successfully.
1387 @retval other Failed to Stop ConSplitter on ControllerHandle.
1392 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1393 IN EFI_HANDLE ControllerHandle
,
1394 IN EFI_HANDLE ConSplitterVirtualHandle
,
1395 IN EFI_GUID
*DeviceGuid
,
1396 IN EFI_GUID
*InterfaceGuid
,
1402 Status
= gBS
->OpenProtocol (
1406 This
->DriverBindingHandle
,
1408 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1410 if (EFI_ERROR (Status
)) {
1414 // close the protocol refered.
1416 gBS
->CloseProtocol (
1419 This
->DriverBindingHandle
,
1420 ConSplitterVirtualHandle
1423 gBS
->CloseProtocol (
1426 This
->DriverBindingHandle
,
1435 Stop Console In ConSplitter on ControllerHandle by closing Console In Devcice GUID.
1437 @param This Driver Binding protocol instance pointer.
1438 @param ControllerHandle Handle of device to stop driver on
1439 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
1440 children is zero stop the entire bus driver.
1441 @param ChildHandleBuffer List of Child Handles to Stop.
1443 @retval EFI_SUCCESS This driver is removed ControllerHandle
1444 @retval other This driver was not removed from this device
1449 ConSplitterConInDriverBindingStop (
1450 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1451 IN EFI_HANDLE ControllerHandle
,
1452 IN UINTN NumberOfChildren
,
1453 IN EFI_HANDLE
*ChildHandleBuffer
1457 EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*TextIn
;
1458 EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*TextInEx
;
1460 if (NumberOfChildren
== 0) {
1464 Status
= gBS
->OpenProtocol (
1466 &gEfiSimpleTextInputExProtocolGuid
,
1467 (VOID
**) &TextInEx
,
1468 This
->DriverBindingHandle
,
1470 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1472 if (!EFI_ERROR (Status
)) {
1474 // If Simple Text Input Ex protocol exists,
1475 // remove device from Text Input Ex devices list.
1477 Status
= ConSplitterTextInExDeleteDevice (&mConIn
, TextInEx
);
1478 if (EFI_ERROR (Status
)) {
1484 // Close Simple Text In protocol on controller handle and virtual handle.
1486 Status
= ConSplitterStop (
1489 mConIn
.VirtualHandle
,
1490 &gEfiConsoleInDeviceGuid
,
1491 &gEfiSimpleTextInProtocolGuid
,
1494 if (EFI_ERROR (Status
)) {
1499 // Remove device from Text Input devices list.
1501 return ConSplitterTextInDeleteDevice (&mConIn
, TextIn
);
1506 Stop Simple Pointer protocol ConSplitter on ControllerHandle by closing
1507 Simple Pointer protocol.
1509 @param This Driver Binding protocol instance pointer.
1510 @param ControllerHandle Handle of device to stop driver on
1511 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
1512 children is zero stop the entire bus driver.
1513 @param ChildHandleBuffer List of Child Handles to Stop.
1515 @retval EFI_SUCCESS This driver is removed ControllerHandle
1516 @retval other This driver was not removed from this device
1521 ConSplitterSimplePointerDriverBindingStop (
1522 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1523 IN EFI_HANDLE ControllerHandle
,
1524 IN UINTN NumberOfChildren
,
1525 IN EFI_HANDLE
*ChildHandleBuffer
1529 EFI_SIMPLE_POINTER_PROTOCOL
*SimplePointer
;
1531 if (NumberOfChildren
== 0) {
1536 // Close Simple Pointer protocol on controller handle and virtual handle.
1538 Status
= ConSplitterStop (
1541 mConIn
.VirtualHandle
,
1542 &gEfiSimplePointerProtocolGuid
,
1543 &gEfiSimplePointerProtocolGuid
,
1544 (VOID
**) &SimplePointer
1546 if (EFI_ERROR (Status
)) {
1551 // Remove this device from Simple Pointer device list.
1553 return ConSplitterSimplePointerDeleteDevice (&mConIn
, SimplePointer
);
1558 Stop Absolute Pointer protocol ConSplitter on ControllerHandle by closing
1559 Absolute Pointer protocol.
1561 @param This Driver Binding protocol instance pointer.
1562 @param ControllerHandle Handle of device to stop driver on
1563 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
1564 children is zero stop the entire bus driver.
1565 @param ChildHandleBuffer List of Child Handles to Stop.
1567 @retval EFI_SUCCESS This driver is removed ControllerHandle
1568 @retval other This driver was not removed from this device
1573 ConSplitterAbsolutePointerDriverBindingStop (
1574 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1575 IN EFI_HANDLE ControllerHandle
,
1576 IN UINTN NumberOfChildren
,
1577 IN EFI_HANDLE
*ChildHandleBuffer
1581 EFI_ABSOLUTE_POINTER_PROTOCOL
*AbsolutePointer
;
1583 if (NumberOfChildren
== 0) {
1588 // Close Absolute Pointer protocol on controller handle and virtual handle.
1590 Status
= ConSplitterStop (
1593 mConIn
.VirtualHandle
,
1594 &gEfiAbsolutePointerProtocolGuid
,
1595 &gEfiAbsolutePointerProtocolGuid
,
1596 (VOID
**) &AbsolutePointer
1598 if (EFI_ERROR (Status
)) {
1603 // Remove this device from Absolute Pointer device list.
1605 return ConSplitterAbsolutePointerDeleteDevice (&mConIn
, AbsolutePointer
);
1610 Stop Console Out ConSplitter on device handle by closing Console Out Devcice GUID.
1612 @param This Driver Binding protocol instance pointer.
1613 @param ControllerHandle Handle of device to stop driver on
1614 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
1615 children is zero stop the entire bus driver.
1616 @param ChildHandleBuffer List of Child Handles to Stop.
1618 @retval EFI_SUCCESS This driver is removed ControllerHandle
1619 @retval other This driver was not removed from this device
1624 ConSplitterConOutDriverBindingStop (
1625 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1626 IN EFI_HANDLE ControllerHandle
,
1627 IN UINTN NumberOfChildren
,
1628 IN EFI_HANDLE
*ChildHandleBuffer
1632 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
;
1634 if (NumberOfChildren
== 0) {
1639 // Close Absolute Pointer protocol on controller handle and virtual handle.
1641 Status
= ConSplitterStop (
1644 mConOut
.VirtualHandle
,
1645 &gEfiConsoleOutDeviceGuid
,
1646 &gEfiSimpleTextOutProtocolGuid
,
1649 if (EFI_ERROR (Status
)) {
1654 // Remove this device from Text Out device list.
1656 return ConSplitterTextOutDeleteDevice (&mConOut
, TextOut
);
1661 Stop Standard Error ConSplitter on ControllerHandle by closing Standard Error GUID.
1663 @param This Driver Binding protocol instance pointer.
1664 @param ControllerHandle Handle of device to stop driver on
1665 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
1666 children is zero stop the entire bus driver.
1667 @param ChildHandleBuffer List of Child Handles to Stop.
1669 @retval EFI_SUCCESS This driver is removed ControllerHandle
1670 @retval other This driver was not removed from this device
1675 ConSplitterStdErrDriverBindingStop (
1676 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1677 IN EFI_HANDLE ControllerHandle
,
1678 IN UINTN NumberOfChildren
,
1679 IN EFI_HANDLE
*ChildHandleBuffer
1683 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
;
1685 if (NumberOfChildren
== 0) {
1690 // Close Standard Error Device on controller handle and virtual handle.
1692 Status
= ConSplitterStop (
1695 mStdErr
.VirtualHandle
,
1696 &gEfiStandardErrorDeviceGuid
,
1697 &gEfiSimpleTextOutProtocolGuid
,
1700 if (EFI_ERROR (Status
)) {
1704 // Delete this console error out device's data structures.
1706 return ConSplitterTextOutDeleteDevice (&mStdErr
, TextOut
);
1711 Take the passed in Buffer of size SizeOfCount and grow the buffer
1712 by MAX (CONSOLE_SPLITTER_CONSOLES_ALLOC_UNIT, MaxGrow) * SizeOfCount
1713 bytes. Copy the current data in Buffer to the new version of Buffer
1714 and free the old version of buffer.
1716 @param SizeOfCount Size of element in array.
1717 @param Count Current number of elements in array.
1718 @param Buffer Bigger version of passed in Buffer with all the
1721 @retval EFI_SUCCESS Buffer size has grown.
1722 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
1726 ConSplitterGrowBuffer (
1727 IN UINTN SizeOfCount
,
1728 IN OUT UINTN
*Count
,
1729 IN OUT VOID
**Buffer
1735 // grow the buffer to new buffer size,
1736 // copy the old buffer's content to the new-size buffer,
1737 // then free the old buffer.
1739 *Count
+= CONSOLE_SPLITTER_CONSOLES_ALLOC_UNIT
;
1740 Ptr
= ReallocatePool (
1741 SizeOfCount
* ((*Count
) - CONSOLE_SPLITTER_CONSOLES_ALLOC_UNIT
),
1742 SizeOfCount
* (*Count
),
1746 return EFI_OUT_OF_RESOURCES
;
1754 Add Text Input Device in Consplitter Text Input list.
1756 @param Private Text In Splitter pointer.
1757 @param TextIn Simple Text Input protocol pointer.
1759 @retval EFI_SUCCESS Text Input Device added successfully.
1760 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
1764 ConSplitterTextInAddDevice (
1765 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
1766 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*TextIn
1772 // If the Text In List is full, enlarge it by calling ConSplitterGrowBuffer().
1774 if (Private
->CurrentNumberOfConsoles
>= Private
->TextInListCount
) {
1775 Status
= ConSplitterGrowBuffer (
1776 sizeof (EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*),
1777 &Private
->TextInListCount
,
1778 (VOID
**) &Private
->TextInList
1780 if (EFI_ERROR (Status
)) {
1781 return EFI_OUT_OF_RESOURCES
;
1785 // Add the new text-in device data structure into the Text In List.
1787 Private
->TextInList
[Private
->CurrentNumberOfConsoles
] = TextIn
;
1788 Private
->CurrentNumberOfConsoles
++;
1791 // Extra CheckEvent added to reduce the double CheckEvent().
1793 gBS
->CheckEvent (TextIn
->WaitForKey
);
1800 Remove Text Input Device from Consplitter Text Input list.
1802 @param Private Text In Splitter pointer.
1803 @param TextIn Simple Text protocol pointer.
1805 @retval EFI_SUCCESS Simple Text Device removed successfully.
1806 @retval EFI_NOT_FOUND No Simple Text Device found.
1810 ConSplitterTextInDeleteDevice (
1811 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
1812 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*TextIn
1817 // Remove the specified text-in device data structure from the Text In List,
1818 // and rearrange the remaining data structures in the Text In List.
1820 for (Index
= 0; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
1821 if (Private
->TextInList
[Index
] == TextIn
) {
1822 for (; Index
< Private
->CurrentNumberOfConsoles
- 1; Index
++) {
1823 Private
->TextInList
[Index
] = Private
->TextInList
[Index
+ 1];
1826 Private
->CurrentNumberOfConsoles
--;
1831 return EFI_NOT_FOUND
;
1835 Add Text Input Ex Device in Consplitter Text Input Ex list.
1837 @param Private Text In Splitter pointer.
1838 @param TextInEx Simple Text Input Ex Input protocol pointer.
1840 @retval EFI_SUCCESS Text Input Ex Device added successfully.
1841 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
1845 ConSplitterTextInExAddDevice (
1846 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
1847 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*TextInEx
1853 // If the Text Input Ex List is full, enlarge it by calling ConSplitterGrowBuffer().
1855 if (Private
->CurrentNumberOfExConsoles
>= Private
->TextInExListCount
) {
1856 Status
= ConSplitterGrowBuffer (
1857 sizeof (EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*),
1858 &Private
->TextInExListCount
,
1859 (VOID
**) &Private
->TextInExList
1861 if (EFI_ERROR (Status
)) {
1862 return EFI_OUT_OF_RESOURCES
;
1866 // Add the new text-in device data structure into the Text Input Ex List.
1868 Private
->TextInExList
[Private
->CurrentNumberOfExConsoles
] = TextInEx
;
1869 Private
->CurrentNumberOfExConsoles
++;
1872 // Extra CheckEvent added to reduce the double CheckEvent().
1874 gBS
->CheckEvent (TextInEx
->WaitForKeyEx
);
1880 Remove Text Ex Device from Consplitter Text Input Ex list.
1882 @param Private Text In Splitter pointer.
1883 @param TextInEx Simple Text Ex protocol pointer.
1885 @retval EFI_SUCCESS Simple Text Input Ex Device removed successfully.
1886 @retval EFI_NOT_FOUND No Simple Text Input Ex Device found.
1890 ConSplitterTextInExDeleteDevice (
1891 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
1892 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*TextInEx
1897 // Remove the specified text-in device data structure from the Text Input Ex List,
1898 // and rearrange the remaining data structures in the Text In List.
1900 for (Index
= 0; Index
< Private
->CurrentNumberOfExConsoles
; Index
++) {
1901 if (Private
->TextInExList
[Index
] == TextInEx
) {
1902 for (; Index
< Private
->CurrentNumberOfExConsoles
- 1; Index
++) {
1903 Private
->TextInExList
[Index
] = Private
->TextInExList
[Index
+ 1];
1906 Private
->CurrentNumberOfExConsoles
--;
1911 return EFI_NOT_FOUND
;
1916 Add Simple Pointer Device in Consplitter Simple Pointer list.
1918 @param Private Text In Splitter pointer.
1919 @param SimplePointer Simple Pointer protocol pointer.
1921 @retval EFI_SUCCESS Simple Pointer Device added successfully.
1922 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
1926 ConSplitterSimplePointerAddDevice (
1927 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
1928 IN EFI_SIMPLE_POINTER_PROTOCOL
*SimplePointer
1934 // If the Simple Pointer List is full, enlarge it by calling ConSplitterGrowBuffer().
1936 if (Private
->CurrentNumberOfPointers
>= Private
->PointerListCount
) {
1937 Status
= ConSplitterGrowBuffer (
1938 sizeof (EFI_SIMPLE_POINTER_PROTOCOL
*),
1939 &Private
->PointerListCount
,
1940 (VOID
**) &Private
->PointerList
1942 if (EFI_ERROR (Status
)) {
1943 return EFI_OUT_OF_RESOURCES
;
1947 // Add the new text-in device data structure into the Simple Pointer List.
1949 Private
->PointerList
[Private
->CurrentNumberOfPointers
] = SimplePointer
;
1950 Private
->CurrentNumberOfPointers
++;
1957 Remove Simple Pointer Device from Consplitter Simple Pointer list.
1959 @param Private Text In Splitter pointer.
1960 @param SimplePointer Simple Pointer protocol pointer.
1962 @retval EFI_SUCCESS Simple Pointer Device removed successfully.
1963 @retval EFI_NOT_FOUND No Simple Pointer Device found.
1967 ConSplitterSimplePointerDeleteDevice (
1968 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
1969 IN EFI_SIMPLE_POINTER_PROTOCOL
*SimplePointer
1974 // Remove the specified text-in device data structure from the Simple Pointer List,
1975 // and rearrange the remaining data structures in the Text In List.
1977 for (Index
= 0; Index
< Private
->CurrentNumberOfPointers
; Index
++) {
1978 if (Private
->PointerList
[Index
] == SimplePointer
) {
1979 for (; Index
< Private
->CurrentNumberOfPointers
- 1; Index
++) {
1980 Private
->PointerList
[Index
] = Private
->PointerList
[Index
+ 1];
1983 Private
->CurrentNumberOfPointers
--;
1988 return EFI_NOT_FOUND
;
1993 Add Absolute Pointer Device in Consplitter Absolute Pointer list.
1995 @param Private Text In Splitter pointer.
1996 @param AbsolutePointer Absolute Pointer protocol pointer.
1998 @retval EFI_SUCCESS Absolute Pointer Device added successfully.
1999 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
2003 ConSplitterAbsolutePointerAddDevice (
2004 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
2005 IN EFI_ABSOLUTE_POINTER_PROTOCOL
*AbsolutePointer
2011 // If the Absolute Pointer List is full, enlarge it by calling ConSplitterGrowBuffer().
2013 if (Private
->CurrentNumberOfAbsolutePointers
>= Private
->AbsolutePointerListCount
) {
2014 Status
= ConSplitterGrowBuffer (
2015 sizeof (EFI_ABSOLUTE_POINTER_PROTOCOL
*),
2016 &Private
->AbsolutePointerListCount
,
2017 (VOID
**) &Private
->AbsolutePointerList
2019 if (EFI_ERROR (Status
)) {
2020 return EFI_OUT_OF_RESOURCES
;
2024 // Add the new text-in device data structure into the Absolute Pointer List.
2026 Private
->AbsolutePointerList
[Private
->CurrentNumberOfAbsolutePointers
] = AbsolutePointer
;
2027 Private
->CurrentNumberOfAbsolutePointers
++;
2034 Remove Absolute Pointer Device from Consplitter Absolute Pointer list.
2036 @param Private Text In Splitter pointer.
2037 @param AbsolutePointer Absolute Pointer protocol pointer.
2039 @retval EFI_SUCCESS Absolute Pointer Device removed successfully.
2040 @retval EFI_NOT_FOUND No Absolute Pointer Device found.
2044 ConSplitterAbsolutePointerDeleteDevice (
2045 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
2046 IN EFI_ABSOLUTE_POINTER_PROTOCOL
*AbsolutePointer
2051 // Remove the specified text-in device data structure from the Absolute Pointer List,
2052 // and rearrange the remaining data structures from the Absolute Pointer List.
2054 for (Index
= 0; Index
< Private
->CurrentNumberOfAbsolutePointers
; Index
++) {
2055 if (Private
->AbsolutePointerList
[Index
] == AbsolutePointer
) {
2056 for (; Index
< Private
->CurrentNumberOfAbsolutePointers
- 1; Index
++) {
2057 Private
->AbsolutePointerList
[Index
] = Private
->AbsolutePointerList
[Index
+ 1];
2060 Private
->CurrentNumberOfAbsolutePointers
--;
2065 return EFI_NOT_FOUND
;
2069 Reallocate Text Out mode map.
2071 Allocate new buffer and copy original buffer into the new buffer.
2073 @param Private Consplitter Text Out pointer.
2075 @retval EFI_SUCCESS Buffer size has grown
2076 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
2080 ConSplitterGrowMapTable (
2081 IN TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
2087 INT32
*TextOutModeMap
;
2088 INT32
*OldTextOutModeMap
;
2092 NewSize
= Private
->TextOutListCount
* sizeof (INT32
);
2093 OldTextOutModeMap
= Private
->TextOutModeMap
;
2094 TotalSize
= NewSize
* (Private
->TextOutQueryDataCount
);
2097 // Allocate new buffer for Text Out List.
2099 TextOutModeMap
= AllocatePool (TotalSize
);
2100 if (TextOutModeMap
== NULL
) {
2101 return EFI_OUT_OF_RESOURCES
;
2104 SetMem (TextOutModeMap
, TotalSize
, 0xFF);
2105 Private
->TextOutModeMap
= TextOutModeMap
;
2108 // If TextOutList has been enlarged, need to realloc the mode map table
2109 // The mode map table is regarded as a two dimension array.
2112 // 0 ---------> TextOutListCount ----> TextOutListCount
2113 // | -------------------------------------------
2120 // -------------------------------------------
2123 if (OldTextOutModeMap
!= NULL
) {
2125 Size
= Private
->CurrentNumberOfConsoles
* sizeof (INT32
);
2127 SrcAddress
= OldTextOutModeMap
;
2130 // Copy the old data to the new one
2132 while (Index
< Private
->TextOutMode
.MaxMode
) {
2133 CopyMem (TextOutModeMap
, SrcAddress
, Size
);
2134 TextOutModeMap
+= NewSize
;
2139 // Free the old buffer
2141 FreePool (OldTextOutModeMap
);
2149 Add new device's output mode to console splitter's mode list.
2151 @param Private Text Out Splitter pointer
2152 @param TextOut Simple Text Output protocol pointer.
2154 @retval EFI_SUCCESS Device added successfully.
2155 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
2159 ConSplitterAddOutputMode (
2160 IN TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
,
2161 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
2169 MaxMode
= TextOut
->Mode
->MaxMode
;
2170 Private
->TextOutMode
.MaxMode
= MaxMode
;
2173 // Grow the buffer if query data buffer is not large enough to
2174 // hold all the mode supported by the first console.
2176 while (MaxMode
> (INT32
) Private
->TextOutQueryDataCount
) {
2177 Status
= ConSplitterGrowBuffer (
2178 sizeof (TEXT_OUT_SPLITTER_QUERY_DATA
),
2179 &Private
->TextOutQueryDataCount
,
2180 (VOID
**) &Private
->TextOutQueryData
2182 if (EFI_ERROR (Status
)) {
2183 return EFI_OUT_OF_RESOURCES
;
2187 // Allocate buffer for the output mode map
2189 Status
= ConSplitterGrowMapTable (Private
);
2190 if (EFI_ERROR (Status
)) {
2191 return EFI_OUT_OF_RESOURCES
;
2194 // As the first textout device, directly add the mode in to QueryData
2195 // and at the same time record the mapping between QueryData and TextOut.
2199 while (Mode
< MaxMode
) {
2200 Status
= TextOut
->QueryMode (
2203 &Private
->TextOutQueryData
[Mode
].Columns
,
2204 &Private
->TextOutQueryData
[Mode
].Rows
2207 // If mode 1 (80x50) is not supported, make sure mode 1 in TextOutQueryData
2210 if ((EFI_ERROR(Status
)) && (Mode
== 1)) {
2211 Private
->TextOutQueryData
[Mode
].Columns
= 0;
2212 Private
->TextOutQueryData
[Mode
].Rows
= 0;
2214 Private
->TextOutModeMap
[Index
] = Mode
;
2216 Index
+= Private
->TextOutListCount
;
2223 Reconstruct TextOutModeMap to get intersection of modes.
2225 This routine reconstruct TextOutModeMap to get the intersection
2226 of modes for all console out devices. Because EFI/UEFI spec require
2227 mode 0 is 80x25, mode 1 is 80x50, this routine will not check the
2228 intersection for mode 0 and mode 1.
2230 @param TextOutModeMap Current text out mode map, begin with the mode 80x25
2231 @param NewlyAddedMap New text out mode map, begin with the mode 80x25
2232 @param MapStepSize Mode step size for one console device
2233 @param NewMapStepSize New Mode step size for one console device
2234 @param MaxMode IN: Current max text mode, OUT: Updated max text mode.
2235 @param CurrentMode IN: Current text mode, OUT: Updated current text mode.
2239 ConSplitterGetIntersection (
2240 IN INT32
*TextOutModeMap
,
2241 IN INT32
*NewlyAddedMap
,
2242 IN UINTN MapStepSize
,
2243 IN UINTN NewMapStepSize
,
2244 IN OUT INT32
*MaxMode
,
2245 IN OUT INT32
*CurrentMode
2249 INT32
*CurrentMapEntry
;
2250 INT32
*NextMapEntry
;
2252 INT32 CurrentMaxMode
;
2256 // According to EFI/UEFI spec, mode 0 and mode 1 have been reserved
2257 // for 80x25 and 80x50 in Simple Text Out protocol, so don't make intersection
2258 // for mode 0 and mode 1, mode number starts from 2.
2261 CurrentMapEntry
= &TextOutModeMap
[MapStepSize
* 2];
2262 NextMapEntry
= CurrentMapEntry
;
2263 NewMapEntry
= &NewlyAddedMap
[NewMapStepSize
* 2];
2265 CurrentMaxMode
= *MaxMode
;
2266 Mode
= *CurrentMode
;
2268 while (Index
< CurrentMaxMode
) {
2269 if (*NewMapEntry
== -1) {
2271 // This mode is not supported any more. Remove it. Special care
2272 // must be taken as this remove will also affect current mode;
2274 if (Index
== *CurrentMode
) {
2276 } else if (Index
< *CurrentMode
) {
2281 if (CurrentMapEntry
!= NextMapEntry
) {
2282 CopyMem (NextMapEntry
, CurrentMapEntry
, MapStepSize
* sizeof (INT32
));
2285 NextMapEntry
+= MapStepSize
;
2288 CurrentMapEntry
+= MapStepSize
;
2289 NewMapEntry
+= NewMapStepSize
;
2293 *CurrentMode
= Mode
;
2299 Sync the device's output mode to console splitter's mode list.
2301 @param Private Text Out Splitter pointer.
2302 @param TextOut Simple Text Output protocol pointer.
2306 ConSplitterSyncOutputMode (
2307 IN TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
,
2308 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
2311 INT32 CurrentMaxMode
;
2314 INT32
*TextOutModeMap
;
2317 TEXT_OUT_SPLITTER_QUERY_DATA
*TextOutQueryData
;
2324 // Must make sure that current mode won't change even if mode number changes
2326 CurrentMaxMode
= Private
->TextOutMode
.MaxMode
;
2327 TextOutModeMap
= Private
->TextOutModeMap
;
2328 StepSize
= Private
->TextOutListCount
;
2329 TextOutQueryData
= Private
->TextOutQueryData
;
2332 // Query all the mode that the newly added TextOut supports
2335 MapTable
= TextOutModeMap
+ Private
->CurrentNumberOfConsoles
;
2336 while (Mode
< TextOut
->Mode
->MaxMode
) {
2337 Status
= TextOut
->QueryMode (TextOut
, Mode
, &Columns
, &Rows
);
2339 if (EFI_ERROR(Status
)) {
2342 // If mode 1 (80x50) is not supported, make sure mode 1 in TextOutQueryData
2345 MapTable
[StepSize
] = Mode
;
2346 TextOutQueryData
[Mode
].Columns
= 0;
2347 TextOutQueryData
[Mode
].Rows
= 0;
2353 // Search the intersection map and QueryData database to see if they intersects
2356 while (Index
< CurrentMaxMode
) {
2357 QueryMode
= *(TextOutModeMap
+ Index
* StepSize
);
2358 if ((TextOutQueryData
[QueryMode
].Rows
== Rows
) && (TextOutQueryData
[QueryMode
].Columns
== Columns
)) {
2359 MapTable
[Index
* StepSize
] = Mode
;
2367 // Now search the TextOutModeMap table to find the intersection of supported
2368 // mode between ConSplitter and the newly added device.
2370 ConSplitterGetIntersection (
2375 &Private
->TextOutMode
.MaxMode
,
2376 &Private
->TextOutMode
.Mode
2384 Sync output device between ConOut and StdErr output.
2386 @retval EFI_SUCCESS Sync implemented successfully.
2387 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
2391 ConSplitterGetIntersectionBetweenConOutAndStrErr (
2395 UINTN ConOutNumOfConsoles
;
2396 UINTN StdErrNumOfConsoles
;
2397 TEXT_OUT_AND_GOP_DATA
*ConOutTextOutList
;
2398 TEXT_OUT_AND_GOP_DATA
*StdErrTextOutList
;
2402 UINTN ConOutColumns
;
2404 UINTN StdErrColumns
;
2405 INT32 ConOutMaxMode
;
2406 INT32 StdErrMaxMode
;
2411 INT32
*ConOutModeMap
;
2412 INT32
*StdErrModeMap
;
2413 INT32
*ConOutMapTable
;
2414 INT32
*StdErrMapTable
;
2415 TEXT_OUT_SPLITTER_QUERY_DATA
*ConOutQueryData
;
2416 TEXT_OUT_SPLITTER_QUERY_DATA
*StdErrQueryData
;
2417 UINTN ConOutStepSize
;
2418 UINTN StdErrStepSize
;
2419 BOOLEAN FoundTheSameTextOut
;
2420 UINTN ConOutMapTableSize
;
2421 UINTN StdErrMapTableSize
;
2423 ConOutNumOfConsoles
= mConOut
.CurrentNumberOfConsoles
;
2424 StdErrNumOfConsoles
= mStdErr
.CurrentNumberOfConsoles
;
2425 ConOutTextOutList
= mConOut
.TextOutList
;
2426 StdErrTextOutList
= mStdErr
.TextOutList
;
2429 FoundTheSameTextOut
= FALSE
;
2430 while ((Indexi
< ConOutNumOfConsoles
) && (!FoundTheSameTextOut
)) {
2432 while (Indexj
< StdErrNumOfConsoles
) {
2433 if (ConOutTextOutList
->TextOut
== StdErrTextOutList
->TextOut
) {
2434 FoundTheSameTextOut
= TRUE
;
2439 StdErrTextOutList
++;
2443 ConOutTextOutList
++;
2446 if (!FoundTheSameTextOut
) {
2450 // Must make sure that current mode won't change even if mode number changes
2452 ConOutMaxMode
= mConOut
.TextOutMode
.MaxMode
;
2453 ConOutModeMap
= mConOut
.TextOutModeMap
;
2454 ConOutStepSize
= mConOut
.TextOutListCount
;
2455 ConOutQueryData
= mConOut
.TextOutQueryData
;
2457 StdErrMaxMode
= mStdErr
.TextOutMode
.MaxMode
;
2458 StdErrModeMap
= mStdErr
.TextOutModeMap
;
2459 StdErrStepSize
= mStdErr
.TextOutListCount
;
2460 StdErrQueryData
= mStdErr
.TextOutQueryData
;
2463 // Allocate the map table and set the map table's index to -1.
2465 ConOutMapTableSize
= ConOutMaxMode
* sizeof (INT32
);
2466 ConOutMapTable
= AllocateZeroPool (ConOutMapTableSize
);
2467 if (ConOutMapTable
== NULL
) {
2468 return EFI_OUT_OF_RESOURCES
;
2471 SetMem (ConOutMapTable
, ConOutMapTableSize
, 0xFF);
2473 StdErrMapTableSize
= StdErrMaxMode
* sizeof (INT32
);
2474 StdErrMapTable
= AllocateZeroPool (StdErrMapTableSize
);
2475 if (StdErrMapTable
== NULL
) {
2476 return EFI_OUT_OF_RESOURCES
;
2479 SetMem (StdErrMapTable
, StdErrMapTableSize
, 0xFF);
2482 // Find the intersection of the two set of modes. If they actually intersect, the
2483 // correponding entry in the map table is set to 1.
2486 while (Mode
< ConOutMaxMode
) {
2488 // Search the intersection map and QueryData database to see if they intersect
2491 ConOutMode
= *(ConOutModeMap
+ Mode
* ConOutStepSize
);
2492 ConOutRows
= ConOutQueryData
[ConOutMode
].Rows
;
2493 ConOutColumns
= ConOutQueryData
[ConOutMode
].Columns
;
2494 while (Index
< StdErrMaxMode
) {
2495 StdErrMode
= *(StdErrModeMap
+ Index
* StdErrStepSize
);
2496 StdErrRows
= StdErrQueryData
[StdErrMode
].Rows
;
2497 StdErrColumns
= StdErrQueryData
[StdErrMode
].Columns
;
2498 if ((StdErrRows
== ConOutRows
) && (StdErrColumns
== ConOutColumns
)) {
2499 ConOutMapTable
[Mode
] = 1;
2500 StdErrMapTable
[Index
] = 1;
2510 // Now search the TextOutModeMap table to find the intersection of supported
2511 // mode between ConSplitter and the newly added device.
2513 ConSplitterGetIntersection (
2516 mConOut
.TextOutListCount
,
2518 &(mConOut
.TextOutMode
.MaxMode
),
2519 &(mConOut
.TextOutMode
.Mode
)
2522 if (mConOut
.TextOutMode
.Mode
< 0) {
2523 mConOut
.TextOut
.SetMode (&(mConOut
.TextOut
), 0);
2526 ConSplitterGetIntersection (
2529 mStdErr
.TextOutListCount
,
2531 &(mStdErr
.TextOutMode
.MaxMode
),
2532 &(mStdErr
.TextOutMode
.Mode
)
2535 if (mStdErr
.TextOutMode
.Mode
< 0) {
2536 mStdErr
.TextOut
.SetMode (&(mStdErr
.TextOut
), 0);
2539 FreePool (ConOutMapTable
);
2540 FreePool (StdErrMapTable
);
2547 Add Grahpics Output modes into Consplitter Text Out list.
2549 @param Private Text Out Splitter pointer.
2550 @param GraphicsOutput Graphics Output protocol pointer.
2551 @param UgaDraw UGA Draw protocol pointer.
2553 @retval EFI_SUCCESS Output mode added successfully.
2554 @retval other Failed to add output mode.
2558 ConSplitterAddGraphicsOutputMode (
2559 IN TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
,
2560 IN EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
,
2561 IN EFI_UGA_DRAW_PROTOCOL
*UgaDraw
2567 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*Mode
;
2569 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*Info
;
2570 EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE
*CurrentGraphicsOutputMode
;
2571 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*ModeBuffer
;
2572 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*MatchedMode
;
2575 BOOLEAN AlreadyExist
;
2576 UINT32 UgaHorizontalResolution
;
2577 UINT32 UgaVerticalResolution
;
2578 UINT32 UgaColorDepth
;
2579 UINT32 UgaRefreshRate
;
2581 ASSERT (GraphicsOutput
!= NULL
|| UgaDraw
!= NULL
);
2583 CurrentGraphicsOutputMode
= Private
->GraphicsOutput
.Mode
;
2587 Status
= EFI_SUCCESS
;
2589 if (Private
->CurrentNumberOfUgaDraw
!= 0) {
2591 // If any UGA device has already been added, then there is no need to
2592 // calculate intersection of display mode of different GOP/UGA device,
2593 // since only one display mode will be exported (i.e. user-defined mode)
2598 if (GraphicsOutput
!= NULL
) {
2599 if (Private
->CurrentNumberOfGraphicsOutput
== 0) {
2601 // This is the first Graphics Output device added
2603 CurrentGraphicsOutputMode
->MaxMode
= GraphicsOutput
->Mode
->MaxMode
;
2604 CurrentGraphicsOutputMode
->Mode
= GraphicsOutput
->Mode
->Mode
;
2605 CopyMem (CurrentGraphicsOutputMode
->Info
, GraphicsOutput
->Mode
->Info
, GraphicsOutput
->Mode
->SizeOfInfo
);
2606 CurrentGraphicsOutputMode
->SizeOfInfo
= GraphicsOutput
->Mode
->SizeOfInfo
;
2607 CurrentGraphicsOutputMode
->FrameBufferBase
= GraphicsOutput
->Mode
->FrameBufferBase
;
2608 CurrentGraphicsOutputMode
->FrameBufferSize
= GraphicsOutput
->Mode
->FrameBufferSize
;
2611 // Allocate resource for the private mode buffer
2613 ModeBuffer
= AllocatePool (sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
) * GraphicsOutput
->Mode
->MaxMode
);
2614 if (ModeBuffer
== NULL
) {
2615 return EFI_OUT_OF_RESOURCES
;
2617 FreePool (Private
->GraphicsOutputModeBuffer
);
2618 Private
->GraphicsOutputModeBuffer
= ModeBuffer
;
2621 // Store all supported display modes to the private mode buffer
2624 for (Index
= 0; Index
< GraphicsOutput
->Mode
->MaxMode
; Index
++) {
2626 // The Info buffer would be allocated by callee
2628 Status
= GraphicsOutput
->QueryMode (GraphicsOutput
, (UINT32
) Index
, &SizeOfInfo
, &Info
);
2629 if (EFI_ERROR (Status
)) {
2632 ASSERT ( SizeOfInfo
<= sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
));
2633 CopyMem (Mode
, Info
, SizeOfInfo
);
2639 // Check intersection of display mode
2641 ModeBuffer
= AllocatePool (sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
) * CurrentGraphicsOutputMode
->MaxMode
);
2642 if (ModeBuffer
== NULL
) {
2643 return EFI_OUT_OF_RESOURCES
;
2646 MatchedMode
= ModeBuffer
;
2647 Mode
= &Private
->GraphicsOutputModeBuffer
[0];
2648 for (Index
= 0; Index
< CurrentGraphicsOutputMode
->MaxMode
; Index
++) {
2651 for (NumberIndex
= 0; NumberIndex
< GraphicsOutput
->Mode
->MaxMode
; NumberIndex
++) {
2653 // The Info buffer would be allocated by callee
2655 Status
= GraphicsOutput
->QueryMode (GraphicsOutput
, (UINT32
) NumberIndex
, &SizeOfInfo
, &Info
);
2656 if (EFI_ERROR (Status
)) {
2659 if ((Info
->HorizontalResolution
== Mode
->HorizontalResolution
) &&
2660 (Info
->VerticalResolution
== Mode
->VerticalResolution
)) {
2662 // If GOP device supports one mode in current mode buffer,
2663 // it will be added into matched mode buffer
2673 AlreadyExist
= FALSE
;
2676 // Check if GOP mode has been in the mode buffer, ModeBuffer = MatchedMode at begin.
2678 for (Info
= ModeBuffer
; Info
< MatchedMode
; Info
++) {
2679 if ((Info
->HorizontalResolution
== Mode
->HorizontalResolution
) &&
2680 (Info
->VerticalResolution
== Mode
->VerticalResolution
)) {
2681 AlreadyExist
= TRUE
;
2686 if (!AlreadyExist
) {
2687 CopyMem (MatchedMode
, Mode
, sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
));
2690 // Physical frame buffer is no longer available, change PixelFormat to PixelBltOnly
2692 MatchedMode
->Version
= 0;
2693 MatchedMode
->PixelFormat
= PixelBltOnly
;
2694 ZeroMem (&MatchedMode
->PixelInformation
, sizeof (EFI_PIXEL_BITMASK
));
2704 // Drop the old mode buffer, assign it to a new one
2706 FreePool (Private
->GraphicsOutputModeBuffer
);
2707 Private
->GraphicsOutputModeBuffer
= ModeBuffer
;
2710 // Physical frame buffer is no longer available when there are more than one physical GOP devices
2712 CurrentGraphicsOutputMode
->MaxMode
= (UINT32
) (((UINTN
) MatchedMode
- (UINTN
) ModeBuffer
) / sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
));
2713 CurrentGraphicsOutputMode
->Info
->PixelFormat
= PixelBltOnly
;
2714 ZeroMem (&CurrentGraphicsOutputMode
->Info
->PixelInformation
, sizeof (EFI_PIXEL_BITMASK
));
2715 CurrentGraphicsOutputMode
->SizeOfInfo
= sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
);
2716 CurrentGraphicsOutputMode
->FrameBufferBase
= (EFI_PHYSICAL_ADDRESS
) (UINTN
) NULL
;
2717 CurrentGraphicsOutputMode
->FrameBufferSize
= 0;
2721 // Graphics console driver can ensure the same mode for all GOP devices
2723 for (Index
= 0; Index
< CurrentGraphicsOutputMode
->MaxMode
; Index
++) {
2724 Mode
= &Private
->GraphicsOutputModeBuffer
[Index
];
2725 if ((Mode
->HorizontalResolution
== GraphicsOutput
->Mode
->Info
->HorizontalResolution
) &&
2726 (Mode
->VerticalResolution
== GraphicsOutput
->Mode
->Info
->VerticalResolution
)) {
2727 CurrentIndex
= Index
;
2731 if (Index
>= CurrentGraphicsOutputMode
->MaxMode
) {
2733 // if user defined mode is not found, set to default mode 800x600
2735 for (Index
= 0; Index
< CurrentGraphicsOutputMode
->MaxMode
; Index
++) {
2736 Mode
= &Private
->GraphicsOutputModeBuffer
[Index
];
2737 if ((Mode
->HorizontalResolution
== 800) && (Mode
->VerticalResolution
== 600)) {
2738 CurrentIndex
= Index
;
2743 } else if (UgaDraw
!= NULL
&& FeaturePcdGet (PcdUgaConsumeSupport
)) {
2745 // Graphics console driver can ensure the same mode for all GOP devices
2746 // so we can get the current mode from this video device
2750 &UgaHorizontalResolution
,
2751 &UgaVerticalResolution
,
2756 CurrentGraphicsOutputMode
->MaxMode
= 1;
2757 Info
= CurrentGraphicsOutputMode
->Info
;
2759 Info
->HorizontalResolution
= UgaHorizontalResolution
;
2760 Info
->VerticalResolution
= UgaVerticalResolution
;
2761 Info
->PixelFormat
= PixelBltOnly
;
2762 Info
->PixelsPerScanLine
= UgaHorizontalResolution
;
2763 CurrentGraphicsOutputMode
->SizeOfInfo
= sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
);
2764 CurrentGraphicsOutputMode
->FrameBufferBase
= (EFI_PHYSICAL_ADDRESS
) (UINTN
) NULL
;
2765 CurrentGraphicsOutputMode
->FrameBufferSize
= 0;
2768 // Update the private mode buffer
2770 CopyMem (&Private
->GraphicsOutputModeBuffer
[0], Info
, sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
));
2773 // Only mode 0 is available to be set
2780 if (GraphicsOutput
!= NULL
) {
2781 Private
->CurrentNumberOfGraphicsOutput
++;
2783 if (UgaDraw
!= NULL
&& FeaturePcdGet (PcdUgaConsumeSupport
)) {
2784 Private
->CurrentNumberOfUgaDraw
++;
2788 // Force GraphicsOutput mode to be set,
2791 Mode
= &Private
->GraphicsOutputModeBuffer
[CurrentIndex
];
2792 if ((GraphicsOutput
!= NULL
) &&
2793 (Mode
->HorizontalResolution
== CurrentGraphicsOutputMode
->Info
->HorizontalResolution
) &&
2794 (Mode
->VerticalResolution
== CurrentGraphicsOutputMode
->Info
->VerticalResolution
)) {
2795 CurrentGraphicsOutputMode
->Mode
= (UINT32
) CurrentIndex
;
2796 if ((Mode
->HorizontalResolution
!= GraphicsOutput
->Mode
->Info
->HorizontalResolution
) ||
2797 (Mode
->VerticalResolution
!= GraphicsOutput
->Mode
->Info
->VerticalResolution
)) {
2799 // If all existing video device has been set to common mode, only set new GOP device to
2802 for (NumberIndex
= 0; NumberIndex
< GraphicsOutput
->Mode
->MaxMode
; NumberIndex
++) {
2803 Status
= GraphicsOutput
->QueryMode (GraphicsOutput
, (UINT32
) NumberIndex
, &SizeOfInfo
, &Info
);
2804 if (EFI_ERROR (Status
)) {
2807 if ((Info
->HorizontalResolution
== Mode
->HorizontalResolution
) && (Info
->VerticalResolution
== Mode
->VerticalResolution
)) {
2813 Status
= GraphicsOutput
->SetMode (GraphicsOutput
, (UINT32
) NumberIndex
);
2817 // Current mode number may need update now, so set it to an invalid mode number
2819 CurrentGraphicsOutputMode
->Mode
= 0xffff;
2821 // Graphics console can ensure all GOP devices have the same mode which can be taken as current mode.
2823 Status
= Private
->GraphicsOutput
.SetMode (&Private
->GraphicsOutput
, (UINT32
) CurrentIndex
);
2824 if (EFI_ERROR(Status
)) {
2826 // If user defined mode is not valid for display device, set to the default mode 800x600.
2828 (Private
->GraphicsOutputModeBuffer
[0]).HorizontalResolution
= 800;
2829 (Private
->GraphicsOutputModeBuffer
[0]).VerticalResolution
= 600;
2830 Status
= Private
->GraphicsOutput
.SetMode (&Private
->GraphicsOutput
, 0);
2838 Set the current console out mode.
2840 This routine will get the current console mode information (column, row)
2841 from ConsoleOutMode variable and set it; if the variable does not exist,
2842 set to user defined console mode.
2844 @param Private Consplitter Text Out pointer.
2848 ConsplitterSetConsoleOutMode (
2849 IN TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
2859 CONSOLE_OUT_MODE ModeInfo
;
2860 CONSOLE_OUT_MODE MaxModeInfo
;
2861 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
;
2865 TextOut
= &Private
->TextOut
;
2866 MaxMode
= (UINTN
) (TextOut
->Mode
->MaxMode
);
2868 MaxModeInfo
.Column
= 0;
2869 MaxModeInfo
.Row
= 0;
2870 ModeInfo
.Column
= PcdGet32 (PcdConOutColumn
);
2871 ModeInfo
.Row
= PcdGet32 (PcdConOutRow
);
2874 // To find the prefer mode and basic mode from Text Out mode list
2876 for (Mode
= 0; Mode
< MaxMode
; Mode
++) {
2877 Status
= TextOut
->QueryMode (TextOut
, Mode
, &Col
, &Row
);
2878 if (!EFI_ERROR(Status
)) {
2879 if ((ModeInfo
.Column
!= 0) && (ModeInfo
.Row
!= 0)) {
2881 // Use user defined column and row
2883 if (Col
== ModeInfo
.Column
&& Row
== ModeInfo
.Row
) {
2888 // If user sets PcdConOutColumn or PcdConOutRow to 0,
2889 // find and set the highest text mode.
2891 if ((Col
>= MaxModeInfo
.Column
) && (Row
>= MaxModeInfo
.Row
)) {
2892 MaxModeInfo
.Column
= Col
;
2893 MaxModeInfo
.Row
= Row
;
2897 if (Col
== 80 && Row
== 25) {
2904 // Set prefer mode to Text Out devices.
2906 Status
= TextOut
->SetMode (TextOut
, PreferMode
);
2907 if (EFI_ERROR(Status
)) {
2909 // if current mode setting is failed, default 80x25 mode will be set.
2911 Status
= TextOut
->SetMode (TextOut
, BaseMode
);
2912 ASSERT(!EFI_ERROR(Status
));
2914 PcdSet32 (PcdConOutColumn
, 80);
2915 PcdSet32 (PcdConOutRow
, 25);
2923 Add Text Output Device in Consplitter Text Output list.
2925 @param Private Text Out Splitter pointer.
2926 @param TextOut Simple Text Output protocol pointer.
2927 @param GraphicsOutput Graphics Output protocol pointer.
2928 @param UgaDraw UGA Draw protocol pointer.
2930 @retval EFI_SUCCESS Text Output Device added successfully.
2931 @retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
2935 ConSplitterTextOutAddDevice (
2936 IN TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
,
2937 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
,
2938 IN EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
,
2939 IN EFI_UGA_DRAW_PROTOCOL
*UgaDraw
2943 UINTN CurrentNumOfConsoles
;
2945 UINT32 UgaHorizontalResolution
;
2946 UINT32 UgaVerticalResolution
;
2947 UINT32 UgaColorDepth
;
2948 UINT32 UgaRefreshRate
;
2949 TEXT_OUT_AND_GOP_DATA
*TextAndGop
;
2951 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*Info
;
2952 EFI_STATUS DeviceStatus
;
2954 Status
= EFI_SUCCESS
;
2955 CurrentNumOfConsoles
= Private
->CurrentNumberOfConsoles
;
2958 // If the Text Out List is full, enlarge it by calling ConSplitterGrowBuffer().
2960 while (CurrentNumOfConsoles
>= Private
->TextOutListCount
) {
2961 Status
= ConSplitterGrowBuffer (
2962 sizeof (TEXT_OUT_AND_GOP_DATA
),
2963 &Private
->TextOutListCount
,
2964 (VOID
**) &Private
->TextOutList
2966 if (EFI_ERROR (Status
)) {
2967 return EFI_OUT_OF_RESOURCES
;
2970 // Also need to reallocate the TextOutModeMap table
2972 Status
= ConSplitterGrowMapTable (Private
);
2973 if (EFI_ERROR (Status
)) {
2974 return EFI_OUT_OF_RESOURCES
;
2978 TextAndGop
= &Private
->TextOutList
[CurrentNumOfConsoles
];
2980 TextAndGop
->TextOut
= TextOut
;
2981 TextAndGop
->GraphicsOutput
= GraphicsOutput
;
2982 TextAndGop
->UgaDraw
= UgaDraw
;
2984 if (CurrentNumOfConsoles
== 0) {
2986 // Add the first device's output mode to console splitter's mode list
2988 Status
= ConSplitterAddOutputMode (Private
, TextOut
);
2990 ConSplitterSyncOutputMode (Private
, TextOut
);
2993 Private
->CurrentNumberOfConsoles
++;
2996 // Scan both TextOutList, for the intersection TextOut device
2997 // maybe both ConOut and StdErr incorporate the same Text Out
2998 // device in them, thus the output of both should be synced.
3000 ConSplitterGetIntersectionBetweenConOutAndStrErr ();
3002 MaxMode
= Private
->TextOutMode
.MaxMode
;
3003 ASSERT (MaxMode
>= 1);
3005 DeviceStatus
= EFI_DEVICE_ERROR
;
3006 if (FeaturePcdGet (PcdConOutGopSupport
)) {
3008 // If GOP is produced by Consplitter, this device display mode will be added into Graphics Ouput modes.
3010 if ((GraphicsOutput
!= NULL
) || (UgaDraw
!= NULL
&& FeaturePcdGet (PcdUgaConsumeSupport
))) {
3011 DeviceStatus
= ConSplitterAddGraphicsOutputMode (Private
, GraphicsOutput
, UgaDraw
);
3015 if (FeaturePcdGet (PcdConOutUgaSupport
)) {
3017 // If UGA is produced by Consplitter
3019 if (GraphicsOutput
!= NULL
) {
3020 Status
= GraphicsOutput
->QueryMode (GraphicsOutput
, GraphicsOutput
->Mode
->Mode
, &SizeOfInfo
, &Info
);
3021 if (EFI_ERROR (Status
)) {
3024 ASSERT ( SizeOfInfo
<= sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
));
3026 UgaHorizontalResolution
= Info
->HorizontalResolution
;
3027 UgaVerticalResolution
= Info
->VerticalResolution
;
3031 } else if (UgaDraw
!= NULL
&& FeaturePcdGet (PcdUgaConsumeSupport
)) {
3032 Status
= UgaDraw
->GetMode (
3034 &UgaHorizontalResolution
,
3035 &UgaVerticalResolution
,
3039 if (!EFI_ERROR (Status
) && EFI_ERROR (DeviceStatus
)) {
3041 // if GetMode is successfully and UGA device hasn't been set, set it
3043 Status
= ConSplitterUgaDrawSetMode (
3045 UgaHorizontalResolution
,
3046 UgaVerticalResolution
,
3052 // If GetMode/SetMode is failed, set to 800x600 mode
3054 if(EFI_ERROR (Status
)) {
3055 Status
= ConSplitterUgaDrawSetMode (
3067 // After adding new console device, all existing console devices should be
3068 // synced to the current shared mode.
3070 ConsplitterSetConsoleOutMode (Private
);
3077 Remove Text Out Device in Consplitter Text Out list.
3079 @param Private Text Out Splitter pointer.
3080 @param TextOut Simple Text Output Pointer protocol pointer.
3082 @retval EFI_SUCCESS Text Out Device removed successfully.
3083 @retval EFI_NOT_FOUND No Text Out Device found.
3087 ConSplitterTextOutDeleteDevice (
3088 IN TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
,
3089 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
3093 UINTN CurrentNumOfConsoles
;
3094 TEXT_OUT_AND_GOP_DATA
*TextOutList
;
3098 // Remove the specified text-out device data structure from the Text out List,
3099 // and rearrange the remaining data structures in the Text out List.
3101 CurrentNumOfConsoles
= Private
->CurrentNumberOfConsoles
;
3102 Index
= (INT32
) CurrentNumOfConsoles
- 1;
3103 TextOutList
= Private
->TextOutList
;
3104 while (Index
>= 0) {
3105 if (TextOutList
->TextOut
== TextOut
) {
3106 if (TextOutList
->UgaDraw
!= NULL
&& FeaturePcdGet (PcdUgaConsumeSupport
)) {
3107 Private
->CurrentNumberOfUgaDraw
--;
3109 if (TextOutList
->GraphicsOutput
!= NULL
) {
3110 Private
->CurrentNumberOfGraphicsOutput
--;
3112 CopyMem (TextOutList
, TextOutList
+ 1, sizeof (TEXT_OUT_AND_GOP_DATA
) * Index
);
3113 CurrentNumOfConsoles
--;
3121 // The specified TextOut is not managed by the ConSplitter driver
3124 return EFI_NOT_FOUND
;
3127 if (CurrentNumOfConsoles
== 0) {
3129 // If the number of consoles is zero, reset all parameters
3131 Private
->CurrentNumberOfConsoles
= 0;
3132 Private
->TextOutMode
.MaxMode
= 1;
3133 Private
->TextOutQueryData
[0].Columns
= 80;
3134 Private
->TextOutQueryData
[0].Rows
= 25;
3135 TextOutSetMode (Private
, 0);
3140 // Max Mode is realy an intersection of the QueryMode command to all
3141 // devices. So we must copy the QueryMode of the first device to
3145 Private
->TextOutQueryData
,
3146 Private
->TextOutQueryDataCount
* sizeof (TEXT_OUT_SPLITTER_QUERY_DATA
)
3149 FreePool (Private
->TextOutModeMap
);
3150 Private
->TextOutModeMap
= NULL
;
3151 TextOutList
= Private
->TextOutList
;
3154 // Add the first TextOut to the QueryData array and ModeMap table
3156 Status
= ConSplitterAddOutputMode (Private
, TextOutList
->TextOut
);
3159 // Now add one by one
3162 Private
->CurrentNumberOfConsoles
= 1;
3164 while ((UINTN
) Index
< CurrentNumOfConsoles
) {
3165 ConSplitterSyncOutputMode (Private
, TextOutList
->TextOut
);
3167 Private
->CurrentNumberOfConsoles
++;
3171 ConSplitterGetIntersectionBetweenConOutAndStrErr ();
3178 Reset the input device and optionaly run diagnostics
3180 @param This Protocol instance pointer.
3181 @param ExtendedVerification Driver may perform diagnostics on reset.
3183 @retval EFI_SUCCESS The device was reset.
3184 @retval EFI_DEVICE_ERROR The device is not functioning properly and could
3190 ConSplitterTextInReset (
3191 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*This
,
3192 IN BOOLEAN ExtendedVerification
3196 EFI_STATUS ReturnStatus
;
3197 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3200 Private
= TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
3202 Private
->KeyEventSignalState
= FALSE
;
3205 // return the worst status met
3207 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
3208 Status
= Private
->TextInList
[Index
]->Reset (
3209 Private
->TextInList
[Index
],
3210 ExtendedVerification
3212 if (EFI_ERROR (Status
)) {
3213 ReturnStatus
= Status
;
3217 return ReturnStatus
;
3222 Reads the next keystroke from the input device. The WaitForKey Event can
3223 be used to test for existance of a keystroke via WaitForEvent () call.
3225 @param Private Protocol instance pointer.
3226 @param Key Driver may perform diagnostics on reset.
3228 @retval EFI_SUCCESS The keystroke information was returned.
3229 @retval EFI_NOT_READY There was no keystroke data availiable.
3230 @retval EFI_DEVICE_ERROR The keydtroke information was not returned due
3236 ConSplitterTextInPrivateReadKeyStroke (
3237 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
3238 OUT EFI_INPUT_KEY
*Key
3243 EFI_INPUT_KEY CurrentKey
;
3245 Key
->UnicodeChar
= 0;
3246 Key
->ScanCode
= SCAN_NULL
;
3249 // if no physical console input device exists, return EFI_NOT_READY;
3250 // if any physical console input device has key input,
3251 // return the key and EFI_SUCCESS.
3253 for (Index
= 0; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
3254 Status
= Private
->TextInList
[Index
]->ReadKeyStroke (
3255 Private
->TextInList
[Index
],
3258 if (!EFI_ERROR (Status
)) {
3264 return EFI_NOT_READY
;
3269 Reads the next keystroke from the input device. The WaitForKey Event can
3270 be used to test for existance of a keystroke via WaitForEvent () call.
3272 @param This Protocol instance pointer.
3273 @param Key Driver may perform diagnostics on reset.
3275 @retval EFI_SUCCESS The keystroke information was returned.
3276 @retval EFI_NOT_READY There was no keystroke data availiable.
3277 @retval EFI_DEVICE_ERROR The keydtroke information was not returned due
3283 ConSplitterTextInReadKeyStroke (
3284 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*This
,
3285 OUT EFI_INPUT_KEY
*Key
3288 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3290 Private
= TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
3292 Private
->KeyEventSignalState
= FALSE
;
3294 return ConSplitterTextInPrivateReadKeyStroke (Private
, Key
);
3299 This event aggregates all the events of the ConIn devices in the spliter.
3301 If any events of physical ConIn devices are signaled, signal the ConIn
3302 spliter event. This will cause the calling code to call
3303 ConSplitterTextInReadKeyStroke ().
3305 @param Event The Event assoicated with callback.
3306 @param Context Context registered when Event was created.
3311 ConSplitterTextInWaitForKey (
3317 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3320 Private
= (TEXT_IN_SPLITTER_PRIVATE_DATA
*) Context
;
3322 if (Private
->KeyEventSignalState
) {
3324 // If KeyEventSignalState is flagged before, and not cleared by Reset() or ReadKeyStroke()
3326 gBS
->SignalEvent (Event
);
3331 // If any physical console input device has key input, signal the event.
3333 for (Index
= 0; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
3334 Status
= gBS
->CheckEvent (Private
->TextInList
[Index
]->WaitForKey
);
3335 if (!EFI_ERROR (Status
)) {
3336 gBS
->SignalEvent (Event
);
3337 Private
->KeyEventSignalState
= TRUE
;
3345 Test if the key has been registered on input device.
3347 @param RegsiteredData A pointer to a buffer that is filled in with the
3348 keystroke state data for the key that was
3350 @param InputData A pointer to a buffer that is filled in with the
3351 keystroke state data for the key that was
3354 @retval TRUE Key be pressed matches a registered key.
3355 @retval FLASE Match failed.
3360 IN EFI_KEY_DATA
*RegsiteredData
,
3361 IN EFI_KEY_DATA
*InputData
3364 ASSERT (RegsiteredData
!= NULL
&& InputData
!= NULL
);
3366 if ((RegsiteredData
->Key
.ScanCode
!= InputData
->Key
.ScanCode
) ||
3367 (RegsiteredData
->Key
.UnicodeChar
!= InputData
->Key
.UnicodeChar
)) {
3372 // Assume KeyShiftState/KeyToggleState = 0 in Registered key data means these state could be ignored.
3374 if (RegsiteredData
->KeyState
.KeyShiftState
!= 0 &&
3375 RegsiteredData
->KeyState
.KeyShiftState
!= InputData
->KeyState
.KeyShiftState
) {
3378 if (RegsiteredData
->KeyState
.KeyToggleState
!= 0 &&
3379 RegsiteredData
->KeyState
.KeyToggleState
!= InputData
->KeyState
.KeyToggleState
) {
3389 Reset the input device and optionaly run diagnostics
3391 @param This Protocol instance pointer.
3392 @param ExtendedVerification Driver may perform diagnostics on reset.
3394 @retval EFI_SUCCESS The device was reset.
3395 @retval EFI_DEVICE_ERROR The device is not functioning properly and could
3401 ConSplitterTextInResetEx (
3402 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*This
,
3403 IN BOOLEAN ExtendedVerification
3407 EFI_STATUS ReturnStatus
;
3408 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3411 Private
= TEXT_IN_EX_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
3413 Private
->KeyEventSignalState
= FALSE
;
3416 // return the worst status met
3418 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfExConsoles
; Index
++) {
3419 Status
= Private
->TextInExList
[Index
]->Reset (
3420 Private
->TextInExList
[Index
],
3421 ExtendedVerification
3423 if (EFI_ERROR (Status
)) {
3424 ReturnStatus
= Status
;
3428 return ReturnStatus
;
3434 Reads the next keystroke from the input device. The WaitForKey Event can
3435 be used to test for existance of a keystroke via WaitForEvent () call.
3437 @param This Protocol instance pointer.
3438 @param KeyData A pointer to a buffer that is filled in with the
3439 keystroke state data for the key that was
3442 @retval EFI_SUCCESS The keystroke information was returned.
3443 @retval EFI_NOT_READY There was no keystroke data availiable.
3444 @retval EFI_DEVICE_ERROR The keystroke information was not returned due
3446 @retval EFI_INVALID_PARAMETER KeyData is NULL.
3451 ConSplitterTextInReadKeyStrokeEx (
3452 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*This
,
3453 OUT EFI_KEY_DATA
*KeyData
3456 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3459 EFI_KEY_DATA CurrentKeyData
;
3462 if (KeyData
== NULL
) {
3463 return EFI_INVALID_PARAMETER
;
3466 Private
= TEXT_IN_EX_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
3468 Private
->KeyEventSignalState
= FALSE
;
3470 KeyData
->Key
.UnicodeChar
= 0;
3471 KeyData
->Key
.ScanCode
= SCAN_NULL
;
3474 // if no physical console input device exists, return EFI_NOT_READY;
3475 // if any physical console input device has key input,
3476 // return the key and EFI_SUCCESS.
3478 for (Index
= 0; Index
< Private
->CurrentNumberOfExConsoles
; Index
++) {
3479 Status
= Private
->TextInExList
[Index
]->ReadKeyStrokeEx (
3480 Private
->TextInExList
[Index
],
3483 if (!EFI_ERROR (Status
)) {
3484 CopyMem (KeyData
, &CurrentKeyData
, sizeof (CurrentKeyData
));
3489 return EFI_NOT_READY
;
3494 Set certain state for the input device.
3496 @param This Protocol instance pointer.
3497 @param KeyToggleState A pointer to the EFI_KEY_TOGGLE_STATE to set the
3498 state for the input device.
3500 @retval EFI_SUCCESS The device state was set successfully.
3501 @retval EFI_DEVICE_ERROR The device is not functioning correctly and
3502 could not have the setting adjusted.
3503 @retval EFI_UNSUPPORTED The device does not have the ability to set its
3505 @retval EFI_INVALID_PARAMETER KeyToggleState is NULL.
3510 ConSplitterTextInSetState (
3511 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*This
,
3512 IN EFI_KEY_TOGGLE_STATE
*KeyToggleState
3515 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3519 if (KeyToggleState
== NULL
) {
3520 return EFI_INVALID_PARAMETER
;
3523 Private
= TEXT_IN_EX_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
3526 // if no physical console input device exists, return EFI_SUCCESS;
3527 // otherwise return the status of setting state of physical console input device
3529 for (Index
= 0; Index
< Private
->CurrentNumberOfExConsoles
; Index
++) {
3530 Status
= Private
->TextInExList
[Index
]->SetState (
3531 Private
->TextInExList
[Index
],
3534 if (EFI_ERROR (Status
)) {
3545 Register a notification function for a particular keystroke for the input device.
3547 @param This Protocol instance pointer.
3548 @param KeyData A pointer to a buffer that is filled in with the
3549 keystroke information data for the key that was
3551 @param KeyNotificationFunction Points to the function to be called when the key
3552 sequence is typed specified by KeyData.
3553 @param NotifyHandle Points to the unique handle assigned to the
3554 registered notification.
3556 @retval EFI_SUCCESS The notification function was registered
3558 @retval EFI_OUT_OF_RESOURCES Unable to allocate resources for necesssary data
3560 @retval EFI_INVALID_PARAMETER KeyData or KeyNotificationFunction or NotifyHandle is NULL.
3565 ConSplitterTextInRegisterKeyNotify (
3566 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*This
,
3567 IN EFI_KEY_DATA
*KeyData
,
3568 IN EFI_KEY_NOTIFY_FUNCTION KeyNotificationFunction
,
3569 OUT EFI_HANDLE
*NotifyHandle
3572 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3575 TEXT_IN_EX_SPLITTER_NOTIFY
*NewNotify
;
3577 TEXT_IN_EX_SPLITTER_NOTIFY
*CurrentNotify
;
3580 if (KeyData
== NULL
|| NotifyHandle
== NULL
|| KeyNotificationFunction
== NULL
) {
3581 return EFI_INVALID_PARAMETER
;
3584 Private
= TEXT_IN_EX_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
3587 // If no physical console input device exists,
3588 // return EFI_SUCCESS directly.
3590 if (Private
->CurrentNumberOfExConsoles
<= 0) {
3595 // Return EFI_SUCCESS if the (KeyData, NotificationFunction) is already registered.
3597 for (Link
= Private
->NotifyList
.ForwardLink
; Link
!= &Private
->NotifyList
; Link
= Link
->ForwardLink
) {
3598 CurrentNotify
= TEXT_IN_EX_SPLITTER_NOTIFY_FROM_THIS (Link
);
3599 if (IsKeyRegistered (&CurrentNotify
->KeyData
, KeyData
)) {
3600 if (CurrentNotify
->KeyNotificationFn
== KeyNotificationFunction
) {
3601 *NotifyHandle
= CurrentNotify
->NotifyHandle
;
3608 // Allocate resource to save the notification function
3610 NewNotify
= (TEXT_IN_EX_SPLITTER_NOTIFY
*) AllocateZeroPool (sizeof (TEXT_IN_EX_SPLITTER_NOTIFY
));
3611 if (NewNotify
== NULL
) {
3612 return EFI_OUT_OF_RESOURCES
;
3614 NewNotify
->NotifyHandleList
= (EFI_HANDLE
*) AllocateZeroPool (sizeof (EFI_HANDLE
) * Private
->CurrentNumberOfExConsoles
);
3615 if (NewNotify
->NotifyHandleList
== NULL
) {
3616 gBS
->FreePool (NewNotify
);
3617 return EFI_OUT_OF_RESOURCES
;
3619 NewNotify
->Signature
= TEXT_IN_EX_SPLITTER_NOTIFY_SIGNATURE
;
3620 NewNotify
->KeyNotificationFn
= KeyNotificationFunction
;
3621 NewNotify
->NotifyHandle
= (EFI_HANDLE
) NewNotify
;
3622 CopyMem (&NewNotify
->KeyData
, KeyData
, sizeof (EFI_KEY_DATA
));
3625 // Return the wrong status of registering key notify of
3626 // physical console input device if meet problems
3628 for (Index
= 0; Index
< Private
->CurrentNumberOfExConsoles
; Index
++) {
3629 Status
= Private
->TextInExList
[Index
]->RegisterKeyNotify (
3630 Private
->TextInExList
[Index
],
3632 KeyNotificationFunction
,
3633 &NewNotify
->NotifyHandleList
[Index
]
3635 if (EFI_ERROR (Status
)) {
3636 gBS
->FreePool (NewNotify
->NotifyHandleList
);
3637 gBS
->FreePool (NewNotify
);
3642 InsertTailList (&mConIn
.NotifyList
, &NewNotify
->NotifyEntry
);
3644 *NotifyHandle
= NewNotify
->NotifyHandle
;
3652 Remove a registered notification function from a particular keystroke.
3654 @param This Protocol instance pointer.
3655 @param NotificationHandle The handle of the notification function being
3658 @retval EFI_SUCCESS The notification function was unregistered
3660 @retval EFI_INVALID_PARAMETER The NotificationHandle is invalid.
3665 ConSplitterTextInUnregisterKeyNotify (
3666 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*This
,
3667 IN EFI_HANDLE NotificationHandle
3670 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3673 TEXT_IN_EX_SPLITTER_NOTIFY
*CurrentNotify
;
3676 if (NotificationHandle
== NULL
) {
3677 return EFI_INVALID_PARAMETER
;
3680 if (((TEXT_IN_EX_SPLITTER_NOTIFY
*) NotificationHandle
)->Signature
!= TEXT_IN_EX_SPLITTER_NOTIFY_SIGNATURE
) {
3681 return EFI_INVALID_PARAMETER
;
3684 Private
= TEXT_IN_EX_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
3687 // if no physical console input device exists,
3688 // return EFI_SUCCESS directly.
3690 if (Private
->CurrentNumberOfExConsoles
<= 0) {
3694 for (Link
= Private
->NotifyList
.ForwardLink
; Link
!= &Private
->NotifyList
; Link
= Link
->ForwardLink
) {
3695 CurrentNotify
= TEXT_IN_EX_SPLITTER_NOTIFY_FROM_THIS (Link
);
3696 if (CurrentNotify
->NotifyHandle
== NotificationHandle
) {
3697 for (Index
= 0; Index
< Private
->CurrentNumberOfExConsoles
; Index
++) {
3698 Status
= Private
->TextInExList
[Index
]->UnregisterKeyNotify (
3699 Private
->TextInExList
[Index
],
3700 CurrentNotify
->NotifyHandleList
[Index
]
3702 if (EFI_ERROR (Status
)) {
3706 RemoveEntryList (&CurrentNotify
->NotifyEntry
);
3708 gBS
->FreePool (CurrentNotify
->NotifyHandleList
);
3709 gBS
->FreePool (CurrentNotify
);
3715 // NotificationHandle is not found in database
3717 return EFI_INVALID_PARAMETER
;
3722 Reset the input device and optionaly run diagnostics
3724 @param This Protocol instance pointer.
3725 @param ExtendedVerification Driver may perform diagnostics on reset.
3727 @retval EFI_SUCCESS The device was reset.
3728 @retval EFI_DEVICE_ERROR The device is not functioning properly and could
3734 ConSplitterSimplePointerReset (
3735 IN EFI_SIMPLE_POINTER_PROTOCOL
*This
,
3736 IN BOOLEAN ExtendedVerification
3740 EFI_STATUS ReturnStatus
;
3741 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3744 Private
= TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_SIMPLE_POINTER_THIS (This
);
3746 Private
->InputEventSignalState
= FALSE
;
3748 if (Private
->CurrentNumberOfPointers
== 0) {
3752 // return the worst status met
3754 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfPointers
; Index
++) {
3755 Status
= Private
->PointerList
[Index
]->Reset (
3756 Private
->PointerList
[Index
],
3757 ExtendedVerification
3759 if (EFI_ERROR (Status
)) {
3760 ReturnStatus
= Status
;
3764 return ReturnStatus
;
3769 Reads the next keystroke from the input device. The WaitForKey Event can
3770 be used to test for existance of a keystroke via WaitForEvent () call.
3772 @param Private Protocol instance pointer.
3773 @param State The state information of simple pointer device.
3775 @retval EFI_SUCCESS The keystroke information was returned.
3776 @retval EFI_NOT_READY There was no keystroke data availiable.
3777 @retval EFI_DEVICE_ERROR The keydtroke information was not returned due
3783 ConSplitterSimplePointerPrivateGetState (
3784 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
3785 IN OUT EFI_SIMPLE_POINTER_STATE
*State
3789 EFI_STATUS ReturnStatus
;
3791 EFI_SIMPLE_POINTER_STATE CurrentState
;
3793 State
->RelativeMovementX
= 0;
3794 State
->RelativeMovementY
= 0;
3795 State
->RelativeMovementZ
= 0;
3796 State
->LeftButton
= FALSE
;
3797 State
->RightButton
= FALSE
;
3800 // if no physical console input device exists, return EFI_NOT_READY;
3801 // if any physical console input device has key input,
3802 // return the key and EFI_SUCCESS.
3804 ReturnStatus
= EFI_NOT_READY
;
3805 for (Index
= 0; Index
< Private
->CurrentNumberOfPointers
; Index
++) {
3807 Status
= Private
->PointerList
[Index
]->GetState (
3808 Private
->PointerList
[Index
],
3811 if (!EFI_ERROR (Status
)) {
3812 if (ReturnStatus
== EFI_NOT_READY
) {
3813 ReturnStatus
= EFI_SUCCESS
;
3816 if (CurrentState
.LeftButton
) {
3817 State
->LeftButton
= TRUE
;
3820 if (CurrentState
.RightButton
) {
3821 State
->RightButton
= TRUE
;
3824 if (CurrentState
.RelativeMovementX
!= 0 && Private
->PointerList
[Index
]->Mode
->ResolutionX
!= 0) {
3825 State
->RelativeMovementX
+= (CurrentState
.RelativeMovementX
* (INT32
) Private
->SimplePointerMode
.ResolutionX
) / (INT32
) Private
->PointerList
[Index
]->Mode
->ResolutionX
;
3828 if (CurrentState
.RelativeMovementY
!= 0 && Private
->PointerList
[Index
]->Mode
->ResolutionY
!= 0) {
3829 State
->RelativeMovementY
+= (CurrentState
.RelativeMovementY
* (INT32
) Private
->SimplePointerMode
.ResolutionY
) / (INT32
) Private
->PointerList
[Index
]->Mode
->ResolutionY
;
3832 if (CurrentState
.RelativeMovementZ
!= 0 && Private
->PointerList
[Index
]->Mode
->ResolutionZ
!= 0) {
3833 State
->RelativeMovementZ
+= (CurrentState
.RelativeMovementZ
* (INT32
) Private
->SimplePointerMode
.ResolutionZ
) / (INT32
) Private
->PointerList
[Index
]->Mode
->ResolutionZ
;
3835 } else if (Status
== EFI_DEVICE_ERROR
) {
3836 ReturnStatus
= EFI_DEVICE_ERROR
;
3840 return ReturnStatus
;
3845 Reads the next keystroke from the input device. The WaitForKey Event can
3846 be used to test for existance of a keystroke via WaitForEvent () call.
3848 @param This A pointer to protocol instance.
3849 @param State A pointer to state information on the pointer device
3851 @retval EFI_SUCCESS The keystroke information was returned in State.
3852 @retval EFI_NOT_READY There was no keystroke data availiable.
3853 @retval EFI_DEVICE_ERROR The keydtroke information was not returned due
3859 ConSplitterSimplePointerGetState (
3860 IN EFI_SIMPLE_POINTER_PROTOCOL
*This
,
3861 IN OUT EFI_SIMPLE_POINTER_STATE
*State
3864 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3866 Private
= TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_SIMPLE_POINTER_THIS (This
);
3868 Private
->InputEventSignalState
= FALSE
;
3870 return ConSplitterSimplePointerPrivateGetState (Private
, State
);
3875 This event agregates all the events of the ConIn devices in the spliter.
3876 If any events of physical ConIn devices are signaled, signal the ConIn
3877 spliter event. This will cause the calling code to call
3878 ConSplitterTextInReadKeyStroke ().
3880 @param Event The Event assoicated with callback.
3881 @param Context Context registered when Event was created.
3886 ConSplitterSimplePointerWaitForInput (
3892 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3895 Private
= (TEXT_IN_SPLITTER_PRIVATE_DATA
*) Context
;
3898 // if InputEventSignalState is flagged before, and not cleared by Reset() or ReadKeyStroke()
3900 if (Private
->InputEventSignalState
) {
3901 gBS
->SignalEvent (Event
);
3905 // if any physical console input device has key input, signal the event.
3907 for (Index
= 0; Index
< Private
->CurrentNumberOfPointers
; Index
++) {
3908 Status
= gBS
->CheckEvent (Private
->PointerList
[Index
]->WaitForInput
);
3909 if (!EFI_ERROR (Status
)) {
3910 gBS
->SignalEvent (Event
);
3911 Private
->InputEventSignalState
= TRUE
;
3917 Resets the pointer device hardware.
3919 @param This Protocol instance pointer.
3920 @param ExtendedVerification Driver may perform diagnostics on reset.
3922 @retval EFI_SUCCESS The device was reset.
3923 @retval EFI_DEVICE_ERROR The device is not functioning correctly and
3929 ConSplitterAbsolutePointerReset (
3930 IN EFI_ABSOLUTE_POINTER_PROTOCOL
*This
,
3931 IN BOOLEAN ExtendedVerification
3935 EFI_STATUS ReturnStatus
;
3936 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3939 Private
= TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_ABSOLUTE_POINTER_THIS (This
);
3941 Private
->AbsoluteInputEventSignalState
= FALSE
;
3943 if (Private
->CurrentNumberOfAbsolutePointers
== 0) {
3947 // return the worst status met
3949 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfAbsolutePointers
; Index
++) {
3950 Status
= Private
->AbsolutePointerList
[Index
]->Reset (
3951 Private
->AbsolutePointerList
[Index
],
3952 ExtendedVerification
3954 if (EFI_ERROR (Status
)) {
3955 ReturnStatus
= Status
;
3959 return ReturnStatus
;
3964 Retrieves the current state of a pointer device.
3966 @param This Protocol instance pointer.
3967 @param State A pointer to the state information on the
3970 @retval EFI_SUCCESS The state of the pointer device was returned in
3972 @retval EFI_NOT_READY The state of the pointer device has not changed
3973 since the last call to GetState().
3974 @retval EFI_DEVICE_ERROR A device error occurred while attempting to
3975 retrieve the pointer device's current state.
3980 ConSplitterAbsolutePointerGetState (
3981 IN EFI_ABSOLUTE_POINTER_PROTOCOL
*This
,
3982 IN OUT EFI_ABSOLUTE_POINTER_STATE
*State
3985 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3987 EFI_STATUS ReturnStatus
;
3989 EFI_ABSOLUTE_POINTER_STATE CurrentState
;
3992 Private
= TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_ABSOLUTE_POINTER_THIS (This
);
3994 Private
->AbsoluteInputEventSignalState
= FALSE
;
3996 State
->CurrentX
= 0;
3997 State
->CurrentY
= 0;
3998 State
->CurrentZ
= 0;
3999 State
->ActiveButtons
= 0;
4002 // if no physical pointer device exists, return EFI_NOT_READY;
4003 // if any physical pointer device has changed state,
4004 // return the state and EFI_SUCCESS.
4006 ReturnStatus
= EFI_NOT_READY
;
4007 for (Index
= 0; Index
< Private
->CurrentNumberOfAbsolutePointers
; Index
++) {
4009 Status
= Private
->AbsolutePointerList
[Index
]->GetState (
4010 Private
->AbsolutePointerList
[Index
],
4013 if (!EFI_ERROR (Status
)) {
4014 if (ReturnStatus
== EFI_NOT_READY
) {
4015 ReturnStatus
= EFI_SUCCESS
;
4018 State
->ActiveButtons
= CurrentState
.ActiveButtons
;
4020 if (!(Private
->AbsolutePointerMode
.AbsoluteMinX
== 0 && Private
->AbsolutePointerMode
.AbsoluteMaxX
== 0)) {
4021 State
->CurrentX
= CurrentState
.CurrentX
;
4023 if (!(Private
->AbsolutePointerMode
.AbsoluteMinY
== 0 && Private
->AbsolutePointerMode
.AbsoluteMaxY
== 0)) {
4024 State
->CurrentY
= CurrentState
.CurrentY
;
4026 if (!(Private
->AbsolutePointerMode
.AbsoluteMinZ
== 0 && Private
->AbsolutePointerMode
.AbsoluteMaxZ
== 0)) {
4027 State
->CurrentZ
= CurrentState
.CurrentZ
;
4030 } else if (Status
== EFI_DEVICE_ERROR
) {
4031 ReturnStatus
= EFI_DEVICE_ERROR
;
4035 return ReturnStatus
;
4040 This event agregates all the events of the pointer devices in the splitter.
4041 If any events of physical pointer devices are signaled, signal the pointer
4042 splitter event. This will cause the calling code to call
4043 ConSplitterAbsolutePointerGetState ().
4045 @param Event The Event assoicated with callback.
4046 @param Context Context registered when Event was created.
4051 ConSplitterAbsolutePointerWaitForInput (
4057 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
4060 Private
= (TEXT_IN_SPLITTER_PRIVATE_DATA
*) Context
;
4063 // if AbsoluteInputEventSignalState is flagged before,
4064 // and not cleared by Reset() or GetState(), signal it
4066 if (Private
->AbsoluteInputEventSignalState
) {
4067 gBS
->SignalEvent (Event
);
4071 // if any physical console input device has key input, signal the event.
4073 for (Index
= 0; Index
< Private
->CurrentNumberOfAbsolutePointers
; Index
++) {
4074 Status
= gBS
->CheckEvent (Private
->AbsolutePointerList
[Index
]->WaitForInput
);
4075 if (!EFI_ERROR (Status
)) {
4076 gBS
->SignalEvent (Event
);
4077 Private
->AbsoluteInputEventSignalState
= TRUE
;
4084 Reset the text output device hardware and optionaly run diagnostics
4086 @param This Protocol instance pointer.
4087 @param ExtendedVerification Driver may perform more exhaustive verfication
4088 operation of the device during reset.
4090 @retval EFI_SUCCESS The text output device was reset.
4091 @retval EFI_DEVICE_ERROR The text output device is not functioning
4092 correctly and could not be reset.
4097 ConSplitterTextOutReset (
4098 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4099 IN BOOLEAN ExtendedVerification
4103 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4105 EFI_STATUS ReturnStatus
;
4107 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4110 // return the worst status met
4112 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
4113 Status
= Private
->TextOutList
[Index
].TextOut
->Reset (
4114 Private
->TextOutList
[Index
].TextOut
,
4115 ExtendedVerification
4117 if (EFI_ERROR (Status
)) {
4118 ReturnStatus
= Status
;
4122 This
->SetAttribute (This
, EFI_TEXT_ATTR (This
->Mode
->Attribute
& 0x0F, EFI_BLACK
));
4125 // reset all mode parameters
4127 TextOutSetMode (Private
, 0);
4129 return ReturnStatus
;
4134 Write a Unicode string to the output device.
4136 @param This Protocol instance pointer.
4137 @param WString The NULL-terminated Unicode string to be
4138 displayed on the output device(s). All output
4139 devices must also support the Unicode drawing
4140 defined in this file.
4142 @retval EFI_SUCCESS The string was output to the device.
4143 @retval EFI_DEVICE_ERROR The device reported an error while attempting to
4145 @retval EFI_UNSUPPORTED The output device's mode is not currently in a
4147 @retval EFI_WARN_UNKNOWN_GLYPH This warning code indicates that some of the
4148 characters in the Unicode string could not be
4149 rendered and were skipped.
4154 ConSplitterTextOutOutputString (
4155 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4160 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4162 EFI_STATUS ReturnStatus
;
4166 This
->SetAttribute (This
, This
->Mode
->Attribute
);
4168 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4171 // return the worst status met
4173 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
4174 Status
= Private
->TextOutList
[Index
].TextOut
->OutputString (
4175 Private
->TextOutList
[Index
].TextOut
,
4178 if (EFI_ERROR (Status
)) {
4179 ReturnStatus
= Status
;
4183 if (Private
->CurrentNumberOfConsoles
> 0) {
4184 Private
->TextOutMode
.CursorColumn
= Private
->TextOutList
[0].TextOut
->Mode
->CursorColumn
;
4185 Private
->TextOutMode
.CursorRow
= Private
->TextOutList
[0].TextOut
->Mode
->CursorRow
;
4188 // When there is no real console devices in system,
4189 // update cursor position for the virtual device in consplitter.
4191 Private
->TextOut
.QueryMode (
4193 Private
->TextOutMode
.Mode
,
4197 for (; *WString
!= CHAR_NULL
; WString
++) {
4199 case CHAR_BACKSPACE
:
4200 if (Private
->TextOutMode
.CursorColumn
== 0 && Private
->TextOutMode
.CursorRow
> 0) {
4201 Private
->TextOutMode
.CursorRow
--;
4202 Private
->TextOutMode
.CursorColumn
= (INT32
) (MaxColumn
- 1);
4203 } else if (Private
->TextOutMode
.CursorColumn
> 0) {
4204 Private
->TextOutMode
.CursorColumn
--;
4209 if (Private
->TextOutMode
.CursorRow
< (INT32
) (MaxRow
- 1)) {
4210 Private
->TextOutMode
.CursorRow
++;
4214 case CHAR_CARRIAGE_RETURN
:
4215 Private
->TextOutMode
.CursorColumn
= 0;
4219 if (Private
->TextOutMode
.CursorColumn
< (INT32
) (MaxColumn
- 1)) {
4220 Private
->TextOutMode
.CursorColumn
++;
4222 Private
->TextOutMode
.CursorColumn
= 0;
4223 if (Private
->TextOutMode
.CursorRow
< (INT32
) (MaxRow
- 1)) {
4224 Private
->TextOutMode
.CursorRow
++;
4232 return ReturnStatus
;
4237 Verifies that all characters in a Unicode string can be output to the
4240 @param This Protocol instance pointer.
4241 @param WString The NULL-terminated Unicode string to be
4242 examined for the output device(s).
4244 @retval EFI_SUCCESS The device(s) are capable of rendering the
4246 @retval EFI_UNSUPPORTED Some of the characters in the Unicode string
4247 cannot be rendered by one or more of the output
4248 devices mapped by the EFI handle.
4253 ConSplitterTextOutTestString (
4254 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4259 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4261 EFI_STATUS ReturnStatus
;
4263 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4266 // return the worst status met
4268 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
4269 Status
= Private
->TextOutList
[Index
].TextOut
->TestString (
4270 Private
->TextOutList
[Index
].TextOut
,
4273 if (EFI_ERROR (Status
)) {
4274 ReturnStatus
= Status
;
4278 // There is no DevNullTextOutTestString () since a Unicode buffer would
4279 // always return EFI_SUCCESS.
4280 // ReturnStatus will be EFI_SUCCESS if no consoles are present
4282 return ReturnStatus
;
4287 Returns information for an available text mode that the output device(s)
4290 @param This Protocol instance pointer.
4291 @param ModeNumber The mode number to return information on.
4292 @param Columns Returns the columns of the text output device
4293 for the requested ModeNumber.
4294 @param Rows Returns the rows of the text output device
4295 for the requested ModeNumber.
4297 @retval EFI_SUCCESS The requested mode information was returned.
4298 @retval EFI_DEVICE_ERROR The device had an error and could not complete
4300 @retval EFI_UNSUPPORTED The mode number was not valid.
4305 ConSplitterTextOutQueryMode (
4306 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4307 IN UINTN ModeNumber
,
4312 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4314 INT32
*TextOutModeMap
;
4316 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4319 // Check whether param ModeNumber is valid.
4320 // ModeNumber should be within range 0 ~ MaxMode - 1.
4322 if ( (ModeNumber
> (UINTN
)(((UINT32
)-1)>>1)) ) {
4323 return EFI_UNSUPPORTED
;
4326 if ((INT32
) ModeNumber
>= This
->Mode
->MaxMode
) {
4327 return EFI_UNSUPPORTED
;
4331 // We get the available mode from mode intersection map if it's available
4333 if (Private
->TextOutModeMap
!= NULL
) {
4334 TextOutModeMap
= Private
->TextOutModeMap
+ Private
->TextOutListCount
* ModeNumber
;
4335 CurrentMode
= (UINTN
)(*TextOutModeMap
);
4336 *Columns
= Private
->TextOutQueryData
[CurrentMode
].Columns
;
4337 *Rows
= Private
->TextOutQueryData
[CurrentMode
].Rows
;
4339 *Columns
= Private
->TextOutQueryData
[ModeNumber
].Columns
;
4340 *Rows
= Private
->TextOutQueryData
[ModeNumber
].Rows
;
4343 if (*Columns
<= 0 && *Rows
<= 0) {
4344 return EFI_UNSUPPORTED
;
4353 Sets the output device(s) to a specified mode.
4355 @param This Protocol instance pointer.
4356 @param ModeNumber The mode number to set.
4358 @retval EFI_SUCCESS The requested text mode was set.
4359 @retval EFI_DEVICE_ERROR The device had an error and could not complete
4361 @retval EFI_UNSUPPORTED The mode number was not valid.
4366 ConSplitterTextOutSetMode (
4367 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4372 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4374 INT32
*TextOutModeMap
;
4375 EFI_STATUS ReturnStatus
;
4377 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4380 // Check whether param ModeNumber is valid.
4381 // ModeNumber should be within range 0 ~ MaxMode - 1.
4383 if ( (ModeNumber
> (UINTN
)(((UINT32
)-1)>>1)) ) {
4384 return EFI_UNSUPPORTED
;
4387 if ((INT32
) ModeNumber
>= This
->Mode
->MaxMode
) {
4388 return EFI_UNSUPPORTED
;
4391 // If the mode is being set to the curent mode, then just clear the screen and return.
4393 if (Private
->TextOutMode
.Mode
== (INT32
) ModeNumber
) {
4394 return ConSplitterTextOutClearScreen (This
);
4397 // return the worst status met
4399 TextOutModeMap
= Private
->TextOutModeMap
+ Private
->TextOutListCount
* ModeNumber
;
4400 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
4401 Status
= Private
->TextOutList
[Index
].TextOut
->SetMode (
4402 Private
->TextOutList
[Index
].TextOut
,
4403 TextOutModeMap
[Index
]
4405 if (EFI_ERROR (Status
)) {
4406 ReturnStatus
= Status
;
4411 // Set mode parameter to specified mode number
4413 TextOutSetMode (Private
, ModeNumber
);
4415 return ReturnStatus
;
4420 Sets the background and foreground colors for the OutputString () and
4421 ClearScreen () functions.
4423 @param This Protocol instance pointer.
4424 @param Attribute The attribute to set. Bits 0..3 are the
4425 foreground color, and bits 4..6 are the
4426 background color. All other bits are undefined
4427 and must be zero. The valid Attributes are
4428 defined in this file.
4430 @retval EFI_SUCCESS The attribute was set.
4431 @retval EFI_DEVICE_ERROR The device had an error and could not complete
4433 @retval EFI_UNSUPPORTED The attribute requested is not defined.
4438 ConSplitterTextOutSetAttribute (
4439 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4444 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4446 EFI_STATUS ReturnStatus
;
4448 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4451 // Check whether param Attribute is valid.
4453 if ( (Attribute
> (UINTN
)(((UINT32
)-1)>>1)) ) {
4454 return EFI_UNSUPPORTED
;
4458 // return the worst status met
4460 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
4461 Status
= Private
->TextOutList
[Index
].TextOut
->SetAttribute (
4462 Private
->TextOutList
[Index
].TextOut
,
4465 if (EFI_ERROR (Status
)) {
4466 ReturnStatus
= Status
;
4470 Private
->TextOutMode
.Attribute
= (INT32
) Attribute
;
4472 return ReturnStatus
;
4477 Clears the output device(s) display to the currently selected background
4480 @param This Protocol instance pointer.
4482 @retval EFI_SUCCESS The operation completed successfully.
4483 @retval EFI_DEVICE_ERROR The device had an error and could not complete
4485 @retval EFI_UNSUPPORTED The output device is not in a valid text mode.
4490 ConSplitterTextOutClearScreen (
4491 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
4495 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4497 EFI_STATUS ReturnStatus
;
4499 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4502 // return the worst status met
4504 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
4505 Status
= Private
->TextOutList
[Index
].TextOut
->ClearScreen (Private
->TextOutList
[Index
].TextOut
);
4506 if (EFI_ERROR (Status
)) {
4507 ReturnStatus
= Status
;
4512 // No need to do extra check here as whether (Column, Row) is valid has
4513 // been checked in ConSplitterTextOutSetCursorPosition. And (0, 0) should
4514 // always be supported.
4516 Private
->TextOutMode
.CursorColumn
= 0;
4517 Private
->TextOutMode
.CursorRow
= 0;
4518 Private
->TextOutMode
.CursorVisible
= TRUE
;
4520 return ReturnStatus
;
4525 Sets the current coordinates of the cursor position
4527 @param This Protocol instance pointer.
4528 @param Column The column position to set the cursor to. Must be
4529 greater than or equal to zero and less than the
4530 number of columns by QueryMode ().
4531 @param Row The row position to set the cursor to. Must be
4532 greater than or equal to zero and less than the
4533 number of rows by QueryMode ().
4535 @retval EFI_SUCCESS The operation completed successfully.
4536 @retval EFI_DEVICE_ERROR The device had an error and could not complete
4538 @retval EFI_UNSUPPORTED The output device is not in a valid text mode,
4539 or the cursor position is invalid for the
4545 ConSplitterTextOutSetCursorPosition (
4546 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4552 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4554 EFI_STATUS ReturnStatus
;
4557 INT32
*TextOutModeMap
;
4561 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4562 TextOutModeMap
= NULL
;
4563 ModeNumber
= Private
->TextOutMode
.Mode
;
4566 // Get current MaxColumn and MaxRow from intersection map
4568 if (Private
->TextOutModeMap
!= NULL
) {
4569 TextOutModeMap
= Private
->TextOutModeMap
+ Private
->TextOutListCount
* ModeNumber
;
4570 CurrentMode
= *TextOutModeMap
;
4572 CurrentMode
= ModeNumber
;
4575 MaxColumn
= Private
->TextOutQueryData
[CurrentMode
].Columns
;
4576 MaxRow
= Private
->TextOutQueryData
[CurrentMode
].Rows
;
4578 if (Column
>= MaxColumn
|| Row
>= MaxRow
) {
4579 return EFI_UNSUPPORTED
;
4582 // return the worst status met
4584 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
4585 Status
= Private
->TextOutList
[Index
].TextOut
->SetCursorPosition (
4586 Private
->TextOutList
[Index
].TextOut
,
4590 if (EFI_ERROR (Status
)) {
4591 ReturnStatus
= Status
;
4596 // No need to do extra check here as whether (Column, Row) is valid has
4597 // been checked in ConSplitterTextOutSetCursorPosition. And (0, 0) should
4598 // always be supported.
4600 Private
->TextOutMode
.CursorColumn
= (INT32
) Column
;
4601 Private
->TextOutMode
.CursorRow
= (INT32
) Row
;
4603 return ReturnStatus
;
4608 Makes the cursor visible or invisible
4610 @param This Protocol instance pointer.
4611 @param Visible If TRUE, the cursor is set to be visible. If
4612 FALSE, the cursor is set to be invisible.
4614 @retval EFI_SUCCESS The operation completed successfully.
4615 @retval EFI_DEVICE_ERROR The device had an error and could not complete
4616 the request, or the device does not support
4617 changing the cursor mode.
4618 @retval EFI_UNSUPPORTED The output device is not in a valid text mode.
4623 ConSplitterTextOutEnableCursor (
4624 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4629 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4631 EFI_STATUS ReturnStatus
;
4633 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4636 // return the worst status met
4638 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
4639 Status
= Private
->TextOutList
[Index
].TextOut
->EnableCursor (
4640 Private
->TextOutList
[Index
].TextOut
,
4643 if (EFI_ERROR (Status
)) {
4644 ReturnStatus
= Status
;
4648 Private
->TextOutMode
.CursorVisible
= Visible
;
4650 return ReturnStatus
;