2 Console Splitter Driver. Any Handle that attatched
3 EFI_CONSOLE_IDENTIFIER_PROTOCOL can be bound by this driver.
5 So far it works like any other driver by opening a SimpleTextIn and/or
6 SimpleTextOut protocol with EFI_OPEN_PROTOCOL_BY_DRIVER attributes. The big
7 difference is this driver does not layer a protocol on the passed in
8 handle, or construct a child handle like a standard device or bus driver.
9 This driver produces three virtual handles as children, one for console input
10 splitter, one for console output splitter and one for error output splitter.
11 EFI_CONSOLE_SPLIT_PROTOCOL will be attatched onto each virtual handle to
12 identify the splitter type.
14 Each virtual handle, that supports both the EFI_CONSOLE_SPLIT_PROTOCOL
15 and Console I/O protocol, will be produced in the driver entry point.
16 The virtual handle are added on driver entry and never removed.
17 Such design ensures sytem function well during none console device situation.
19 Copyright (c) 2006 - 2007 Intel Corporation. <BR>
20 All rights reserved. This program and the accompanying materials
21 are licensed and made available under the terms and conditions of the BSD License
22 which accompanies this distribution. The full text of the license may be found at
23 http://opensource.org/licenses/bsd-license.php
25 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
26 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
30 #include "ConSplitter.h"
35 STATIC TEXT_IN_SPLITTER_PRIVATE_DATA mConIn
= {
36 TEXT_IN_SPLITTER_PRIVATE_DATA_SIGNATURE
,
39 ConSplitterTextInReset
,
40 ConSplitterTextInReadKeyStroke
,
44 (EFI_SIMPLE_TEXT_INPUT_PROTOCOL
**) NULL
,
47 ConSplitterTextInResetEx
,
48 ConSplitterTextInReadKeyStrokeEx
,
50 ConSplitterTextInSetState
,
51 ConSplitterTextInRegisterKeyNotify
,
52 ConSplitterTextInUnregisterKeyNotify
55 (EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
**) NULL
,
58 (struct _LIST_ENTRY
*) NULL
,
59 (struct _LIST_ENTRY
*) NULL
63 ConSplitterSimplePointerReset
,
64 ConSplitterSimplePointerGetState
,
66 (EFI_SIMPLE_POINTER_MODE
*) NULL
76 (EFI_SIMPLE_POINTER_PROTOCOL
**) NULL
,
80 ConSplitterAbsolutePointerReset
,
81 ConSplitterAbsolutePointerGetState
,
83 (EFI_ABSOLUTE_POINTER_MODE
*) NULL
90 0x10000, //AbsoluteMaxX
91 0x10000, //AbsoluteMaxY
92 0x10000, //AbsoluteMaxZ
96 (EFI_ABSOLUTE_POINTER_PROTOCOL
**) NULL
,
102 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
103 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
104 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
105 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
109 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
110 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
111 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
112 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
120 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UGA_DRAW_PROTOCOL gUgaDrawProtocolTemplate
= {
121 ConSpliterUgaDrawGetMode
,
122 ConSpliterUgaDrawSetMode
,
126 GLOBAL_REMOVE_IF_UNREFERENCED EFI_GRAPHICS_OUTPUT_PROTOCOL gGraphicsOutputProtocolTemplate
= {
127 ConSpliterGraphicsOutputQueryMode
,
128 ConSpliterGraphicsOutputSetMode
,
129 ConSpliterGraphicsOutputBlt
,
133 STATIC TEXT_OUT_SPLITTER_PRIVATE_DATA mConOut
= {
134 TEXT_OUT_SPLITTER_PRIVATE_DATA_SIGNATURE
,
137 ConSplitterTextOutReset
,
138 ConSplitterTextOutOutputString
,
139 ConSplitterTextOutTestString
,
140 ConSplitterTextOutQueryMode
,
141 ConSplitterTextOutSetMode
,
142 ConSplitterTextOutSetAttribute
,
143 ConSplitterTextOutClearScreen
,
144 ConSplitterTextOutSetCursorPosition
,
145 ConSplitterTextOutEnableCursor
,
146 (EFI_SIMPLE_TEXT_OUTPUT_MODE
*) NULL
165 (EFI_UGA_PIXEL
*) NULL
,
172 (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*) NULL
,
173 (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*) NULL
,
178 ConSpliterConsoleControlGetMode
,
179 ConSpliterConsoleControlSetMode
,
180 ConSpliterConsoleControlLockStdIn
184 (TEXT_OUT_AND_GOP_DATA
*) NULL
,
186 (TEXT_OUT_SPLITTER_QUERY_DATA
*) NULL
,
190 EfiConsoleControlScreenText
,
197 STATIC TEXT_OUT_SPLITTER_PRIVATE_DATA mStdErr
= {
198 TEXT_OUT_SPLITTER_PRIVATE_DATA_SIGNATURE
,
201 ConSplitterTextOutReset
,
202 ConSplitterTextOutOutputString
,
203 ConSplitterTextOutTestString
,
204 ConSplitterTextOutQueryMode
,
205 ConSplitterTextOutSetMode
,
206 ConSplitterTextOutSetAttribute
,
207 ConSplitterTextOutClearScreen
,
208 ConSplitterTextOutSetCursorPosition
,
209 ConSplitterTextOutEnableCursor
,
210 (EFI_SIMPLE_TEXT_OUTPUT_MODE
*) NULL
229 (EFI_UGA_PIXEL
*) NULL
,
236 (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*) NULL
,
237 (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*) NULL
,
242 ConSpliterConsoleControlGetMode
,
243 ConSpliterConsoleControlSetMode
,
244 ConSpliterConsoleControlLockStdIn
248 (TEXT_OUT_AND_GOP_DATA
*) NULL
,
250 (TEXT_OUT_SPLITTER_QUERY_DATA
*) NULL
,
254 EfiConsoleControlScreenText
,
261 EFI_DRIVER_BINDING_PROTOCOL gConSplitterConInDriverBinding
= {
262 ConSplitterConInDriverBindingSupported
,
263 ConSplitterConInDriverBindingStart
,
264 ConSplitterConInDriverBindingStop
,
270 EFI_DRIVER_BINDING_PROTOCOL gConSplitterSimplePointerDriverBinding
= {
271 ConSplitterSimplePointerDriverBindingSupported
,
272 ConSplitterSimplePointerDriverBindingStart
,
273 ConSplitterSimplePointerDriverBindingStop
,
280 // Driver binding instance for Absolute Pointer protocol
282 EFI_DRIVER_BINDING_PROTOCOL gConSplitterAbsolutePointerDriverBinding
= {
283 ConSplitterAbsolutePointerDriverBindingSupported
,
284 ConSplitterAbsolutePointerDriverBindingStart
,
285 ConSplitterAbsolutePointerDriverBindingStop
,
291 EFI_DRIVER_BINDING_PROTOCOL gConSplitterConOutDriverBinding
= {
292 ConSplitterConOutDriverBindingSupported
,
293 ConSplitterConOutDriverBindingStart
,
294 ConSplitterConOutDriverBindingStop
,
300 EFI_DRIVER_BINDING_PROTOCOL gConSplitterStdErrDriverBinding
= {
301 ConSplitterStdErrDriverBindingSupported
,
302 ConSplitterStdErrDriverBindingStart
,
303 ConSplitterStdErrDriverBindingStop
,
310 The user Entry Point for module ConSplitter. The user code starts with this function.
312 @param[in] ImageHandle The firmware allocated handle for the EFI image.
313 @param[in] SystemTable A pointer to the EFI System Table.
315 @retval EFI_SUCCESS The entry point is executed successfully.
316 @retval other Some error occurs when executing this entry point.
321 InitializeConSplitter(
322 IN EFI_HANDLE ImageHandle
,
323 IN EFI_SYSTEM_TABLE
*SystemTable
329 // Install driver model protocol(s).
331 Status
= EfiLibInstallDriverBindingComponentName2 (
334 &gConSplitterConInDriverBinding
,
336 &gConSplitterConInComponentName
,
337 &gConSplitterConInComponentName2
339 ASSERT_EFI_ERROR (Status
);
341 Status
= EfiLibInstallDriverBindingComponentName2 (
344 &gConSplitterSimplePointerDriverBinding
,
346 &gConSplitterSimplePointerComponentName
,
347 &gConSplitterSimplePointerComponentName2
349 ASSERT_EFI_ERROR (Status
);
351 Status
= EfiLibInstallDriverBindingComponentName2 (
354 &gConSplitterAbsolutePointerDriverBinding
,
356 &gConSplitterAbsolutePointerComponentName
,
357 &gConSplitterAbsolutePointerComponentName2
359 ASSERT_EFI_ERROR (Status
);
361 Status
= EfiLibInstallDriverBindingComponentName2 (
364 &gConSplitterConOutDriverBinding
,
366 &gConSplitterConOutComponentName
,
367 &gConSplitterConOutComponentName2
369 ASSERT_EFI_ERROR (Status
);
371 Status
= EfiLibInstallDriverBindingComponentName2 (
374 &gConSplitterStdErrDriverBinding
,
376 &gConSplitterStdErrComponentName
,
377 &gConSplitterStdErrComponentName2
379 ASSERT_EFI_ERROR (Status
);
383 // Call the original Entry Point
385 Status
= ConSplitterDriverEntry (ImageHandle
, SystemTable
);
393 ConSplitterDriverEntry (
394 IN EFI_HANDLE ImageHandle
,
395 IN EFI_SYSTEM_TABLE
*SystemTable
400 Intialize a virtual console device to act as an agrigator of physical console
404 ImageHandle - (Standard EFI Image entry - EFI_IMAGE_ENTRY_POINT)
405 SystemTable - (Standard EFI Image entry - EFI_IMAGE_ENTRY_POINT)
413 ASSERT (FeaturePcdGet (PcdConOutGopSupport
) ||
414 FeaturePcdGet (PcdConOutUgaSupport
));
416 // The driver creates virtual handles for ConIn, ConOut, and StdErr.
417 // The virtual handles will always exist even if no console exist in the
418 // system. This is need to support hotplug devices like USB.
421 // Create virtual device handle for StdErr Splitter
423 Status
= ConSplitterTextOutConstructor (&mStdErr
);
424 if (!EFI_ERROR (Status
)) {
425 Status
= gBS
->InstallMultipleProtocolInterfaces (
426 &mStdErr
.VirtualHandle
,
427 &gEfiSimpleTextOutProtocolGuid
,
429 &gEfiPrimaryStandardErrorDeviceGuid
,
435 // Create virtual device handle for ConIn Splitter
437 Status
= ConSplitterTextInConstructor (&mConIn
);
438 if (!EFI_ERROR (Status
)) {
439 Status
= gBS
->InstallMultipleProtocolInterfaces (
440 &mConIn
.VirtualHandle
,
441 &gEfiSimpleTextInProtocolGuid
,
443 &gEfiSimpleTextInputExProtocolGuid
,
445 &gEfiSimplePointerProtocolGuid
,
446 &mConIn
.SimplePointer
,
447 &gEfiAbsolutePointerProtocolGuid
,
448 &mConIn
.AbsolutePointer
,
449 &gEfiPrimaryConsoleInDeviceGuid
,
453 if (!EFI_ERROR (Status
)) {
455 // Update the EFI System Table with new virtual console
457 gST
->ConsoleInHandle
= mConIn
.VirtualHandle
;
458 gST
->ConIn
= &mConIn
.TextIn
;
462 // Create virtual device handle for ConOut Splitter
464 Status
= ConSplitterTextOutConstructor (&mConOut
);
465 if (!EFI_ERROR (Status
)) {
466 if (!FeaturePcdGet (PcdConOutGopSupport
)) {
468 // In EFI mode, UGA Draw protocol is installed
470 Status
= gBS
->InstallMultipleProtocolInterfaces (
471 &mConOut
.VirtualHandle
,
472 &gEfiSimpleTextOutProtocolGuid
,
474 &gEfiUgaDrawProtocolGuid
,
476 &gEfiConsoleControlProtocolGuid
,
477 &mConOut
.ConsoleControl
,
478 &gEfiPrimaryConsoleOutDeviceGuid
,
482 } else if (!FeaturePcdGet (PcdConOutUgaSupport
)) {
484 // In UEFI mode, Graphics Output Protocol is installed on virtual handle.
486 Status
= gBS
->InstallMultipleProtocolInterfaces (
487 &mConOut
.VirtualHandle
,
488 &gEfiSimpleTextOutProtocolGuid
,
490 &gEfiGraphicsOutputProtocolGuid
,
491 &mConOut
.GraphicsOutput
,
492 &gEfiConsoleControlProtocolGuid
,
493 &mConOut
.ConsoleControl
,
494 &gEfiPrimaryConsoleOutDeviceGuid
,
500 // In EFI and UEFI comptible mode, Graphics Output Protocol and UGA are
501 // installed on virtual handle.
503 Status
= gBS
->InstallMultipleProtocolInterfaces (
504 &mConOut
.VirtualHandle
,
505 &gEfiSimpleTextOutProtocolGuid
,
507 &gEfiGraphicsOutputProtocolGuid
,
508 &mConOut
.GraphicsOutput
,
509 &gEfiUgaDrawProtocolGuid
,
511 &gEfiConsoleControlProtocolGuid
,
512 &mConOut
.ConsoleControl
,
513 &gEfiPrimaryConsoleOutDeviceGuid
,
519 if (!EFI_ERROR (Status
)) {
521 // Update the EFI System Table with new virtual console
523 gST
->ConsoleOutHandle
= mConOut
.VirtualHandle
;
524 gST
->ConOut
= &mConOut
.TextOut
;
529 // Update the CRC32 in the EFI System Table header
532 gBS
->CalculateCrc32 (
542 ConSplitterTextInConstructor (
543 TEXT_IN_SPLITTER_PRIVATE_DATA
*ConInPrivate
549 Construct the ConSplitter.
553 ConInPrivate - A pointer to the TEXT_IN_SPLITTER_PRIVATE_DATA structure.
556 EFI_OUT_OF_RESOURCES - Out of resources.
563 // Initilize console input splitter's private data.
565 Status
= ConSplitterGrowBuffer (
566 sizeof (EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*),
567 &ConInPrivate
->TextInListCount
,
568 (VOID
**) &ConInPrivate
->TextInList
570 if (EFI_ERROR (Status
)) {
571 return EFI_OUT_OF_RESOURCES
;
574 // Create Event to support locking StdIn Device
576 Status
= gBS
->CreateEvent (
577 EVT_TIMER
| EVT_NOTIFY_SIGNAL
,
579 ConSpliterConsoleControlLockStdInEvent
,
581 &ConInPrivate
->LockEvent
583 ASSERT_EFI_ERROR (Status
);
585 Status
= gBS
->CreateEvent (
588 ConSplitterTextInWaitForKey
,
590 &ConInPrivate
->TextIn
.WaitForKey
592 ASSERT_EFI_ERROR (Status
);
595 // Buffer for Simple Text Input Ex Protocol
597 Status
= ConSplitterGrowBuffer (
598 sizeof (EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*),
599 &ConInPrivate
->TextInExListCount
,
600 (VOID
**) &ConInPrivate
->TextInExList
602 if (EFI_ERROR (Status
)) {
603 return EFI_OUT_OF_RESOURCES
;
606 Status
= gBS
->CreateEvent (
609 ConSplitterTextInWaitForKey
,
611 &ConInPrivate
->TextInEx
.WaitForKeyEx
613 ASSERT_EFI_ERROR (Status
);
615 InitializeListHead (&ConInPrivate
->NotifyList
);
618 // Allocate Buffer and Create Event for Absolute Pointer and Simple Pointer Protocols
620 ConInPrivate
->AbsolutePointer
.Mode
= &ConInPrivate
->AbsolutePointerMode
;
622 Status
= ConSplitterGrowBuffer (
623 sizeof (EFI_ABSOLUTE_POINTER_PROTOCOL
*),
624 &ConInPrivate
->AbsolutePointerListCount
,
625 (VOID
**) &ConInPrivate
->AbsolutePointerList
627 if (EFI_ERROR (Status
)) {
628 return EFI_OUT_OF_RESOURCES
;
631 Status
= gBS
->CreateEvent (
634 ConSplitterAbsolutePointerWaitForInput
,
636 &ConInPrivate
->AbsolutePointer
.WaitForInput
638 ASSERT_EFI_ERROR (Status
);
640 ConInPrivate
->SimplePointer
.Mode
= &ConInPrivate
->SimplePointerMode
;
642 Status
= ConSplitterGrowBuffer (
643 sizeof (EFI_SIMPLE_POINTER_PROTOCOL
*),
644 &ConInPrivate
->PointerListCount
,
645 (VOID
**) &ConInPrivate
->PointerList
647 if (EFI_ERROR (Status
)) {
648 return EFI_OUT_OF_RESOURCES
;
651 Status
= gBS
->CreateEvent (
654 ConSplitterSimplePointerWaitForInput
,
656 &ConInPrivate
->SimplePointer
.WaitForInput
663 ConSplitterTextOutConstructor (
664 TEXT_OUT_SPLITTER_PRIVATE_DATA
*ConOutPrivate
668 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*Info
;
671 // Copy protocols template
673 if (FeaturePcdGet (PcdConOutUgaSupport
)) {
674 CopyMem (&ConOutPrivate
->UgaDraw
, &gUgaDrawProtocolTemplate
, sizeof (EFI_UGA_DRAW_PROTOCOL
));
677 if (FeaturePcdGet (PcdConOutGopSupport
)) {
678 CopyMem (&ConOutPrivate
->GraphicsOutput
, &gGraphicsOutputProtocolTemplate
, sizeof (EFI_GRAPHICS_OUTPUT_PROTOCOL
));
682 // Initilize console output splitter's private data.
684 ConOutPrivate
->TextOut
.Mode
= &ConOutPrivate
->TextOutMode
;
686 Status
= ConSplitterGrowBuffer (
687 sizeof (TEXT_OUT_AND_GOP_DATA
),
688 &ConOutPrivate
->TextOutListCount
,
689 (VOID
**) &ConOutPrivate
->TextOutList
691 if (EFI_ERROR (Status
)) {
692 return EFI_OUT_OF_RESOURCES
;
695 Status
= ConSplitterGrowBuffer (
696 sizeof (TEXT_OUT_SPLITTER_QUERY_DATA
),
697 &ConOutPrivate
->TextOutQueryDataCount
,
698 (VOID
**) &ConOutPrivate
->TextOutQueryData
700 if (EFI_ERROR (Status
)) {
701 return EFI_OUT_OF_RESOURCES
;
704 // Setup the DevNullTextOut console to 80 x 25
706 ConOutPrivate
->TextOutQueryData
[0].Columns
= 80;
707 ConOutPrivate
->TextOutQueryData
[0].Rows
= 25;
708 DevNullTextOutSetMode (ConOutPrivate
, 0);
710 if (FeaturePcdGet (PcdConOutUgaSupport
)) {
712 // Setup the DevNullUgaDraw to 800 x 600 x 32 bits per pixel
714 ConSpliterUgaDrawSetMode (&ConOutPrivate
->UgaDraw
, 800, 600, 32, 60);
716 if (FeaturePcdGet (PcdConOutGopSupport
)) {
718 // Setup resource for mode information in Graphics Output Protocol interface
720 if ((ConOutPrivate
->GraphicsOutput
.Mode
= AllocateZeroPool (sizeof (EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE
))) == NULL
) {
721 return EFI_OUT_OF_RESOURCES
;
723 if ((ConOutPrivate
->GraphicsOutput
.Mode
->Info
= AllocateZeroPool (sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
))) == NULL
) {
724 return EFI_OUT_OF_RESOURCES
;
727 // Setup the DevNullGraphicsOutput to 800 x 600 x 32 bits per pixel
728 // DevNull will be updated to user-defined mode after driver has started.
730 if ((ConOutPrivate
->GraphicsOutputModeBuffer
= AllocateZeroPool (sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
))) == NULL
) {
731 return EFI_OUT_OF_RESOURCES
;
733 Info
= &ConOutPrivate
->GraphicsOutputModeBuffer
[0];
735 Info
->HorizontalResolution
= 800;
736 Info
->VerticalResolution
= 600;
737 Info
->PixelFormat
= PixelBltOnly
;
738 Info
->PixelsPerScanLine
= 800;
739 CopyMem (ConOutPrivate
->GraphicsOutput
.Mode
->Info
, Info
, sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
));
740 ConOutPrivate
->GraphicsOutput
.Mode
->SizeOfInfo
= sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
);
743 // Initialize the following items, theset items remain unchanged in GraphicsOutput->SetMode()
744 // GraphicsOutputMode->FrameBufferBase, GraphicsOutputMode->FrameBufferSize
746 ConOutPrivate
->GraphicsOutput
.Mode
->FrameBufferBase
= (EFI_PHYSICAL_ADDRESS
) NULL
;
747 ConOutPrivate
->GraphicsOutput
.Mode
->FrameBufferSize
= 0;
749 ConOutPrivate
->GraphicsOutput
.Mode
->MaxMode
= 1;
751 // Initial current mode to unknow state, and then set to mode 0
753 ConOutPrivate
->GraphicsOutput
.Mode
->Mode
= 0xffff;
754 ConOutPrivate
->GraphicsOutput
.SetMode (&ConOutPrivate
->GraphicsOutput
, 0);
762 ConSplitterSupported (
763 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
764 IN EFI_HANDLE ControllerHandle
,
770 Generic Supported Check
773 This - Pointer to protocol.
774 ControllerHandle - Controller Handle.
779 EFI_UNSUPPORTED - unsupported.
780 EFI_SUCCESS - operation is OK.
788 // Make sure the Console Splitter does not attempt to attach to itself
790 if (ControllerHandle
== mConIn
.VirtualHandle
) {
791 return EFI_UNSUPPORTED
;
794 if (ControllerHandle
== mConOut
.VirtualHandle
) {
795 return EFI_UNSUPPORTED
;
798 if (ControllerHandle
== mStdErr
.VirtualHandle
) {
799 return EFI_UNSUPPORTED
;
802 // Check to see whether the handle has the ConsoleInDevice GUID on it
804 Status
= gBS
->OpenProtocol (
808 This
->DriverBindingHandle
,
810 EFI_OPEN_PROTOCOL_BY_DRIVER
813 if (EFI_ERROR (Status
)) {
820 This
->DriverBindingHandle
,
829 ConSplitterConInDriverBindingSupported (
830 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
831 IN EFI_HANDLE ControllerHandle
,
832 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
837 Console In Supported Check
840 This - Pointer to protocol.
841 ControllerHandle - Controller handle.
842 RemainingDevicePath - Remaining device path.
850 return ConSplitterSupported (
853 &gEfiConsoleInDeviceGuid
859 ConSplitterSimplePointerDriverBindingSupported (
860 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
861 IN EFI_HANDLE ControllerHandle
,
862 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
867 Standard Error Supported Check
870 This - Pointer to protocol.
871 ControllerHandle - Controller handle.
872 RemainingDevicePath - Remaining device path.
880 return ConSplitterSupported (
883 &gEfiSimplePointerProtocolGuid
889 ConSplitterAbsolutePointerDriverBindingSupported (
890 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
891 IN EFI_HANDLE ControllerHandle
,
892 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
897 Absolute Pointer Supported Check
900 This - Pointer to protocol.
901 ControllerHandle - Controller handle.
902 RemainingDevicePath - Remaining device path.
910 return ConSplitterSupported (
913 &gEfiAbsolutePointerProtocolGuid
919 ConSplitterConOutDriverBindingSupported (
920 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
921 IN EFI_HANDLE ControllerHandle
,
922 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
927 Console Out Supported Check
930 This - Pointer to protocol.
931 ControllerHandle - Controller handle.
932 RemainingDevicePath - Remaining device path.
940 return ConSplitterSupported (
943 &gEfiConsoleOutDeviceGuid
949 ConSplitterStdErrDriverBindingSupported (
950 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
951 IN EFI_HANDLE ControllerHandle
,
952 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
957 Standard Error Supported Check
960 This - Pointer to protocol.
961 ControllerHandle - Controller handle.
962 RemainingDevicePath - Remaining device path.
970 return ConSplitterSupported (
973 &gEfiStandardErrorDeviceGuid
981 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
982 IN EFI_HANDLE ControllerHandle
,
983 IN EFI_HANDLE ConSplitterVirtualHandle
,
984 IN EFI_GUID
*DeviceGuid
,
985 IN EFI_GUID
*InterfaceGuid
,
991 Start ConSplitter on ControllerHandle, and create the virtual
992 agrogated console device on first call Start for a SimpleTextIn handle.
995 (Standard DriverBinding Protocol Start() function)
998 EFI_ERROR if a SimpleTextIn protocol is not started.
1006 // Check to see whether the handle has the ConsoleInDevice GUID on it
1008 Status
= gBS
->OpenProtocol (
1012 This
->DriverBindingHandle
,
1014 EFI_OPEN_PROTOCOL_BY_DRIVER
1016 if (EFI_ERROR (Status
)) {
1020 Status
= gBS
->OpenProtocol (
1024 This
->DriverBindingHandle
,
1025 ConSplitterVirtualHandle
,
1026 EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
1028 if (EFI_ERROR (Status
)) {
1032 return gBS
->OpenProtocol (
1036 This
->DriverBindingHandle
,
1037 ConSplitterVirtualHandle
,
1038 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1044 ConSplitterConInDriverBindingStart (
1045 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1046 IN EFI_HANDLE ControllerHandle
,
1047 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
1051 Routine Description:
1052 Start ConSplitter on ControllerHandle, and create the virtual
1053 agrogated console device on first call Start for a SimpleTextIn handle.
1056 This - Pointer to protocol.
1057 ControllerHandle - Controller handle.
1058 RemainingDevicePath - Remaining device path.
1063 EFI_ERROR if a SimpleTextIn protocol is not started.
1068 EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*TextIn
;
1069 EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*TextInEx
;
1072 // Start ConSplitter on ControllerHandle, and create the virtual
1073 // agrogated console device on first call Start for a SimpleTextIn handle.
1075 Status
= ConSplitterStart (
1078 mConIn
.VirtualHandle
,
1079 &gEfiConsoleInDeviceGuid
,
1080 &gEfiSimpleTextInProtocolGuid
,
1083 if (EFI_ERROR (Status
)) {
1087 Status
= ConSplitterTextInAddDevice (&mConIn
, TextIn
);
1088 if (EFI_ERROR (Status
)) {
1092 Status
= gBS
->OpenProtocol (
1094 &gEfiSimpleTextInputExProtocolGuid
,
1095 (VOID
**) &TextInEx
,
1096 This
->DriverBindingHandle
,
1097 mConIn
.VirtualHandle
,
1098 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1100 if (EFI_ERROR (Status
)) {
1104 Status
= ConSplitterTextInExAddDevice (&mConIn
, TextInEx
);
1111 ConSplitterSimplePointerDriverBindingStart (
1112 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1113 IN EFI_HANDLE ControllerHandle
,
1114 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
1118 Routine Description:
1119 Start ConSplitter on ControllerHandle, and create the virtual
1120 agrogated console device on first call Start for a SimpleTextIn handle.
1123 This - Pointer to protocol.
1124 ControllerHandle - Controller handle.
1125 RemainingDevicePath - Remaining device path.
1129 EFI_ERROR if a SimpleTextIn protocol is not started.
1134 EFI_SIMPLE_POINTER_PROTOCOL
*SimplePointer
;
1136 Status
= ConSplitterStart (
1139 mConIn
.VirtualHandle
,
1140 &gEfiSimplePointerProtocolGuid
,
1141 &gEfiSimplePointerProtocolGuid
,
1142 (VOID
**) &SimplePointer
1144 if (EFI_ERROR (Status
)) {
1148 return ConSplitterSimplePointerAddDevice (&mConIn
, SimplePointer
);
1153 ConSplitterAbsolutePointerDriverBindingStart (
1154 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1155 IN EFI_HANDLE ControllerHandle
,
1156 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
1160 Routine Description:
1161 Start ConSplitter on ControllerHandle, and create the virtual
1162 agrogated console device on first call Start for a ConIn handle.
1165 This - Pointer to protocol.
1166 ControllerHandle - Controller handle.
1167 RemainingDevicePath - Remaining device path.
1171 EFI_ERROR if a AbsolutePointer protocol is not started.
1176 EFI_ABSOLUTE_POINTER_PROTOCOL
*AbsolutePointer
;
1178 Status
= ConSplitterStart (
1181 mConIn
.VirtualHandle
,
1182 &gEfiAbsolutePointerProtocolGuid
,
1183 &gEfiAbsolutePointerProtocolGuid
,
1184 (VOID
**) &AbsolutePointer
1187 if (EFI_ERROR (Status
)) {
1191 return ConSplitterAbsolutePointerAddDevice (&mConIn
, AbsolutePointer
);
1196 ConSplitterConOutDriverBindingStart (
1197 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1198 IN EFI_HANDLE ControllerHandle
,
1199 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
1203 Routine Description:
1204 Start ConSplitter on ControllerHandle, and create the virtual
1205 agrogated console device on first call Start for a SimpleTextIn handle.
1208 This - Pointer to protocol.
1209 ControllerHandle - Controller handle.
1210 RemainingDevicePath - Remaining device path.
1213 EFI_ERROR if a SimpleTextIn protocol is not started.
1218 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
;
1219 EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
;
1220 EFI_UGA_DRAW_PROTOCOL
*UgaDraw
;
1222 Status
= ConSplitterStart (
1225 mConOut
.VirtualHandle
,
1226 &gEfiConsoleOutDeviceGuid
,
1227 &gEfiSimpleTextOutProtocolGuid
,
1230 if (EFI_ERROR (Status
)) {
1234 // Try to Open Graphics Output protocol
1236 Status
= gBS
->OpenProtocol (
1238 &gEfiGraphicsOutputProtocolGuid
,
1239 (VOID
**) &GraphicsOutput
,
1240 This
->DriverBindingHandle
,
1241 mConOut
.VirtualHandle
,
1242 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1244 if (EFI_ERROR (Status
)) {
1245 GraphicsOutput
= NULL
;
1248 // Open UGA_DRAW protocol
1250 Status
= gBS
->OpenProtocol (
1252 &gEfiUgaDrawProtocolGuid
,
1254 This
->DriverBindingHandle
,
1255 mConOut
.VirtualHandle
,
1256 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1258 if (EFI_ERROR (Status
)) {
1262 // If both ConOut and StdErr incorporate the same Text Out device,
1263 // their MaxMode and QueryData should be the intersection of both.
1265 Status
= ConSplitterTextOutAddDevice (&mConOut
, TextOut
, GraphicsOutput
, UgaDraw
);
1266 ConSplitterTextOutSetAttribute (&mConOut
.TextOut
, EFI_TEXT_ATTR (EFI_LIGHTGRAY
, EFI_BLACK
));
1268 if (FeaturePcdGet (PcdConOutUgaSupport
)) {
1270 // Match the UGA mode data of ConOut with the current mode
1272 if (UgaDraw
!= NULL
) {
1275 &mConOut
.UgaHorizontalResolution
,
1276 &mConOut
.UgaVerticalResolution
,
1277 &mConOut
.UgaColorDepth
,
1278 &mConOut
.UgaRefreshRate
1287 ConSplitterStdErrDriverBindingStart (
1288 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1289 IN EFI_HANDLE ControllerHandle
,
1290 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
1294 Routine Description:
1295 Start ConSplitter on ControllerHandle, and create the virtual
1296 agrogated console device on first call Start for a SimpleTextIn handle.
1299 This - Pointer to protocol.
1300 ControllerHandle - Controller handle.
1301 RemainingDevicePath - Remaining device path.
1304 EFI_ERROR if a SimpleTextIn protocol is not started.
1309 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
;
1311 Status
= ConSplitterStart (
1314 mStdErr
.VirtualHandle
,
1315 &gEfiStandardErrorDeviceGuid
,
1316 &gEfiSimpleTextOutProtocolGuid
,
1319 if (EFI_ERROR (Status
)) {
1323 // If both ConOut and StdErr incorporate the same Text Out device,
1324 // their MaxMode and QueryData should be the intersection of both.
1326 Status
= ConSplitterTextOutAddDevice (&mStdErr
, TextOut
, NULL
, NULL
);
1327 ConSplitterTextOutSetAttribute (&mStdErr
.TextOut
, EFI_TEXT_ATTR (EFI_MAGENTA
, EFI_BLACK
));
1328 if (EFI_ERROR (Status
)) {
1332 if (mStdErr
.CurrentNumberOfConsoles
== 1) {
1333 gST
->StandardErrorHandle
= mStdErr
.VirtualHandle
;
1334 gST
->StdErr
= &mStdErr
.TextOut
;
1336 // Update the CRC32 in the EFI System Table header
1339 gBS
->CalculateCrc32 (
1340 (UINT8
*) &gST
->Hdr
,
1341 gST
->Hdr
.HeaderSize
,
1353 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1354 IN EFI_HANDLE ControllerHandle
,
1355 IN EFI_HANDLE ConSplitterVirtualHandle
,
1356 IN EFI_GUID
*DeviceGuid
,
1357 IN EFI_GUID
*InterfaceGuid
,
1362 Routine Description:
1365 (Standard DriverBinding Protocol Stop() function)
1375 Status
= gBS
->OpenProtocol (
1379 This
->DriverBindingHandle
,
1381 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1383 if (EFI_ERROR (Status
)) {
1387 // close the protocol refered.
1389 gBS
->CloseProtocol (
1392 This
->DriverBindingHandle
,
1393 ConSplitterVirtualHandle
1395 gBS
->CloseProtocol (
1398 This
->DriverBindingHandle
,
1407 ConSplitterConInDriverBindingStop (
1408 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1409 IN EFI_HANDLE ControllerHandle
,
1410 IN UINTN NumberOfChildren
,
1411 IN EFI_HANDLE
*ChildHandleBuffer
1415 Routine Description:
1418 (Standard DriverBinding Protocol Stop() function)
1427 EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*TextIn
;
1429 EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*TextInEx
;
1430 if (NumberOfChildren
== 0) {
1434 Status
= gBS
->OpenProtocol (
1436 &gEfiSimpleTextInputExProtocolGuid
,
1437 (VOID
**) &TextInEx
,
1438 This
->DriverBindingHandle
,
1440 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1442 if (EFI_ERROR (Status
)) {
1446 Status
= ConSplitterTextInExDeleteDevice (&mConIn
, TextInEx
);
1447 if (EFI_ERROR (Status
)) {
1452 Status
= ConSplitterStop (
1455 mConIn
.VirtualHandle
,
1456 &gEfiConsoleInDeviceGuid
,
1457 &gEfiSimpleTextInProtocolGuid
,
1460 if (EFI_ERROR (Status
)) {
1464 // Delete this console input device's data structures.
1466 return ConSplitterTextInDeleteDevice (&mConIn
, TextIn
);
1471 ConSplitterSimplePointerDriverBindingStop (
1472 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1473 IN EFI_HANDLE ControllerHandle
,
1474 IN UINTN NumberOfChildren
,
1475 IN EFI_HANDLE
*ChildHandleBuffer
1479 Routine Description:
1482 (Standard DriverBinding Protocol Stop() function)
1491 EFI_SIMPLE_POINTER_PROTOCOL
*SimplePointer
;
1493 if (NumberOfChildren
== 0) {
1497 Status
= ConSplitterStop (
1500 mConIn
.VirtualHandle
,
1501 &gEfiSimplePointerProtocolGuid
,
1502 &gEfiSimplePointerProtocolGuid
,
1503 (VOID
**) &SimplePointer
1505 if (EFI_ERROR (Status
)) {
1509 // Delete this console input device's data structures.
1511 return ConSplitterSimplePointerDeleteDevice (&mConIn
, SimplePointer
);
1516 ConSplitterAbsolutePointerDriverBindingStop (
1517 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1518 IN EFI_HANDLE ControllerHandle
,
1519 IN UINTN NumberOfChildren
,
1520 IN EFI_HANDLE
*ChildHandleBuffer
1524 Routine Description:
1527 (Standard DriverBinding Protocol Stop() function)
1536 EFI_ABSOLUTE_POINTER_PROTOCOL
*AbsolutePointer
;
1538 if (NumberOfChildren
== 0) {
1542 Status
= ConSplitterStop (
1545 mConIn
.VirtualHandle
,
1546 &gEfiAbsolutePointerProtocolGuid
,
1547 &gEfiAbsolutePointerProtocolGuid
,
1548 (VOID
**) &AbsolutePointer
1550 if (EFI_ERROR (Status
)) {
1554 // Delete this console input device's data structures.
1556 return ConSplitterAbsolutePointerDeleteDevice (&mConIn
, AbsolutePointer
);
1561 ConSplitterConOutDriverBindingStop (
1562 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1563 IN EFI_HANDLE ControllerHandle
,
1564 IN UINTN NumberOfChildren
,
1565 IN EFI_HANDLE
*ChildHandleBuffer
1569 Routine Description:
1572 (Standard DriverBinding Protocol Stop() function)
1581 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
;
1583 if (NumberOfChildren
== 0) {
1587 Status
= ConSplitterStop (
1590 mConOut
.VirtualHandle
,
1591 &gEfiConsoleOutDeviceGuid
,
1592 &gEfiSimpleTextOutProtocolGuid
,
1595 if (EFI_ERROR (Status
)) {
1600 // Delete this console output device's data structures.
1602 return ConSplitterTextOutDeleteDevice (&mConOut
, TextOut
);
1607 ConSplitterStdErrDriverBindingStop (
1608 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1609 IN EFI_HANDLE ControllerHandle
,
1610 IN UINTN NumberOfChildren
,
1611 IN EFI_HANDLE
*ChildHandleBuffer
1615 Routine Description:
1618 (Standard DriverBinding Protocol Stop() function)
1622 EFI_SUCCESS - Complete successfully.
1627 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
;
1629 if (NumberOfChildren
== 0) {
1633 Status
= ConSplitterStop (
1636 mStdErr
.VirtualHandle
,
1637 &gEfiStandardErrorDeviceGuid
,
1638 &gEfiSimpleTextOutProtocolGuid
,
1641 if (EFI_ERROR (Status
)) {
1645 // Delete this console error out device's data structures.
1647 Status
= ConSplitterTextOutDeleteDevice (&mStdErr
, TextOut
);
1648 if (EFI_ERROR (Status
)) {
1652 if (mStdErr
.CurrentNumberOfConsoles
== 0) {
1653 gST
->StandardErrorHandle
= NULL
;
1656 // Update the CRC32 in the EFI System Table header
1659 gBS
->CalculateCrc32 (
1660 (UINT8
*) &gST
->Hdr
,
1661 gST
->Hdr
.HeaderSize
,
1670 ConSplitterGrowBuffer (
1671 IN UINTN SizeOfCount
,
1673 IN OUT VOID
**Buffer
1677 Routine Description:
1678 Take the passed in Buffer of size SizeOfCount and grow the buffer
1679 by MAX (CONSOLE_SPLITTER_CONSOLES_ALLOC_UNIT, MaxGrow) * SizeOfCount
1680 bytes. Copy the current data in Buffer to the new version of Buffer
1681 and free the old version of buffer.
1685 SizeOfCount - Size of element in array
1686 Count - Current number of elements in array
1687 Buffer - Bigger version of passed in Buffer with all the data
1690 EFI_SUCCESS - Buffer size has grown
1691 EFI_OUT_OF_RESOURCES - Could not grow the buffer size
1702 // grow the buffer to new buffer size,
1703 // copy the old buffer's content to the new-size buffer,
1704 // then free the old buffer.
1706 OldSize
= *Count
* SizeOfCount
;
1707 *Count
+= CONSOLE_SPLITTER_CONSOLES_ALLOC_UNIT
;
1708 NewSize
= *Count
* SizeOfCount
;
1710 Ptr
= AllocateZeroPool (NewSize
);
1712 return EFI_OUT_OF_RESOURCES
;
1715 CopyMem (Ptr
, *Buffer
, OldSize
);
1717 if (*Buffer
!= NULL
) {
1727 ConSplitterTextInAddDevice (
1728 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
1729 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*TextIn
1733 Routine Description:
1740 EFI_OUT_OF_RESOURCES
1747 // If the Text In List is full, enlarge it by calling growbuffer().
1749 if (Private
->CurrentNumberOfConsoles
>= Private
->TextInListCount
) {
1750 Status
= ConSplitterGrowBuffer (
1751 sizeof (EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*),
1752 &Private
->TextInListCount
,
1753 (VOID
**) &Private
->TextInList
1755 if (EFI_ERROR (Status
)) {
1756 return EFI_OUT_OF_RESOURCES
;
1760 // Add the new text-in device data structure into the Text In List.
1762 Private
->TextInList
[Private
->CurrentNumberOfConsoles
] = TextIn
;
1763 Private
->CurrentNumberOfConsoles
++;
1766 // Extra CheckEvent added to reduce the double CheckEvent() in UI.c
1768 gBS
->CheckEvent (TextIn
->WaitForKey
);
1774 ConSplitterTextInDeleteDevice (
1775 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
1776 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*TextIn
1780 Routine Description:
1793 // Remove the specified text-in device data structure from the Text In List,
1794 // and rearrange the remaining data structures in the Text In List.
1796 for (Index
= 0; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
1797 if (Private
->TextInList
[Index
] == TextIn
) {
1798 for (Index
= Index
; Index
< Private
->CurrentNumberOfConsoles
- 1; Index
++) {
1799 Private
->TextInList
[Index
] = Private
->TextInList
[Index
+ 1];
1802 Private
->CurrentNumberOfConsoles
--;
1807 return EFI_NOT_FOUND
;
1811 ConSplitterTextInExAddDevice (
1812 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
1813 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*TextInEx
1819 // If the TextInEx List is full, enlarge it by calling growbuffer().
1821 if (Private
->CurrentNumberOfExConsoles
>= Private
->TextInExListCount
) {
1822 Status
= ConSplitterGrowBuffer (
1823 sizeof (EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*),
1824 &Private
->TextInExListCount
,
1825 (VOID
**) &Private
->TextInExList
1827 if (EFI_ERROR (Status
)) {
1828 return EFI_OUT_OF_RESOURCES
;
1832 // Add the new text-in device data structure into the Text In List.
1834 Private
->TextInExList
[Private
->CurrentNumberOfExConsoles
] = TextInEx
;
1835 Private
->CurrentNumberOfExConsoles
++;
1838 // Extra CheckEvent added to reduce the double CheckEvent() in UI.c
1840 gBS
->CheckEvent (TextInEx
->WaitForKeyEx
);
1846 ConSplitterTextInExDeleteDevice (
1847 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
1848 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*TextInEx
1853 // Remove the specified text-in device data structure from the Text In List,
1854 // and rearrange the remaining data structures in the Text In List.
1856 for (Index
= 0; Index
< Private
->CurrentNumberOfExConsoles
; Index
++) {
1857 if (Private
->TextInExList
[Index
] == TextInEx
) {
1858 for (Index
= Index
; Index
< Private
->CurrentNumberOfExConsoles
- 1; Index
++) {
1859 Private
->TextInExList
[Index
] = Private
->TextInExList
[Index
+ 1];
1862 Private
->CurrentNumberOfExConsoles
--;
1867 return EFI_NOT_FOUND
;
1871 ConSplitterSimplePointerAddDevice (
1872 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
1873 IN EFI_SIMPLE_POINTER_PROTOCOL
*SimplePointer
1877 Routine Description:
1883 EFI_OUT_OF_RESOURCES
1891 // If the Text In List is full, enlarge it by calling growbuffer().
1893 if (Private
->CurrentNumberOfPointers
>= Private
->PointerListCount
) {
1894 Status
= ConSplitterGrowBuffer (
1895 sizeof (EFI_SIMPLE_POINTER_PROTOCOL
*),
1896 &Private
->PointerListCount
,
1897 (VOID
**) &Private
->PointerList
1899 if (EFI_ERROR (Status
)) {
1900 return EFI_OUT_OF_RESOURCES
;
1904 // Add the new text-in device data structure into the Text In List.
1906 Private
->PointerList
[Private
->CurrentNumberOfPointers
] = SimplePointer
;
1907 Private
->CurrentNumberOfPointers
++;
1912 ConSplitterSimplePointerDeleteDevice (
1913 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
1914 IN EFI_SIMPLE_POINTER_PROTOCOL
*SimplePointer
1918 Routine Description:
1930 // Remove the specified text-in device data structure from the Text In List,
1931 // and rearrange the remaining data structures in the Text In List.
1933 for (Index
= 0; Index
< Private
->CurrentNumberOfPointers
; Index
++) {
1934 if (Private
->PointerList
[Index
] == SimplePointer
) {
1935 for (Index
= Index
; Index
< Private
->CurrentNumberOfPointers
- 1; Index
++) {
1936 Private
->PointerList
[Index
] = Private
->PointerList
[Index
+ 1];
1939 Private
->CurrentNumberOfPointers
--;
1944 return EFI_NOT_FOUND
;
1948 ConSplitterAbsolutePointerAddDevice (
1949 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
1950 IN EFI_ABSOLUTE_POINTER_PROTOCOL
*AbsolutePointer
1954 Routine Description:
1960 EFI_OUT_OF_RESOURCES
1968 // If the Absolute Pointer List is full, enlarge it by calling growbuffer().
1970 if (Private
->CurrentNumberOfAbsolutePointers
>= Private
->AbsolutePointerListCount
) {
1971 Status
= ConSplitterGrowBuffer (
1972 sizeof (EFI_ABSOLUTE_POINTER_PROTOCOL
*),
1973 &Private
->AbsolutePointerListCount
,
1974 (VOID
**) &Private
->AbsolutePointerList
1976 if (EFI_ERROR (Status
)) {
1977 return EFI_OUT_OF_RESOURCES
;
1981 // Add the new text-in device data structure into the Text In List.
1983 Private
->AbsolutePointerList
[Private
->CurrentNumberOfAbsolutePointers
] = AbsolutePointer
;
1984 Private
->CurrentNumberOfAbsolutePointers
++;
1989 ConSplitterAbsolutePointerDeleteDevice (
1990 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
1991 IN EFI_ABSOLUTE_POINTER_PROTOCOL
*AbsolutePointer
1995 Routine Description:
2007 // Remove the specified text-in device data structure from the Text In List,
2008 // and rearrange the remaining data structures in the Text In List.
2010 for (Index
= 0; Index
< Private
->CurrentNumberOfAbsolutePointers
; Index
++) {
2011 if (Private
->AbsolutePointerList
[Index
] == AbsolutePointer
) {
2012 for (Index
= Index
; Index
< Private
->CurrentNumberOfAbsolutePointers
- 1; Index
++) {
2013 Private
->AbsolutePointerList
[Index
] = Private
->AbsolutePointerList
[Index
+ 1];
2016 Private
->CurrentNumberOfAbsolutePointers
--;
2021 return EFI_NOT_FOUND
;
2026 ConSplitterGrowMapTable (
2027 IN TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
2031 Routine Description:
2044 INT32
*TextOutModeMap
;
2045 INT32
*OldTextOutModeMap
;
2049 NewSize
= Private
->TextOutListCount
* sizeof (INT32
);
2050 OldTextOutModeMap
= Private
->TextOutModeMap
;
2051 TotalSize
= NewSize
* Private
->TextOutQueryDataCount
;
2053 TextOutModeMap
= AllocateZeroPool (TotalSize
);
2054 if (TextOutModeMap
== NULL
) {
2055 return EFI_OUT_OF_RESOURCES
;
2058 SetMem (TextOutModeMap
, TotalSize
, 0xFF);
2059 Private
->TextOutModeMap
= TextOutModeMap
;
2062 // If TextOutList has been enlarged, need to realloc the mode map table
2063 // The mode map table is regarded as a two dimension array.
2066 // 0 ---------> TextOutListCount ----> TextOutListCount
2067 // | -------------------------------------------
2074 // -------------------------------------------
2077 if (OldTextOutModeMap
!= NULL
) {
2079 Size
= Private
->CurrentNumberOfConsoles
* sizeof (INT32
);
2081 SrcAddress
= OldTextOutModeMap
;
2084 // Copy the old data to the new one
2086 while (Index
< Private
->TextOutMode
.MaxMode
) {
2087 CopyMem (TextOutModeMap
, SrcAddress
, Size
);
2088 TextOutModeMap
+= NewSize
;
2093 // Free the old buffer
2095 FreePool (OldTextOutModeMap
);
2103 ConSplitterAddOutputMode (
2104 IN TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
,
2105 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
2109 Routine Description:
2124 MaxMode
= TextOut
->Mode
->MaxMode
;
2125 Private
->TextOutMode
.MaxMode
= MaxMode
;
2128 // Grow the buffer if query data buffer is not large enough to
2129 // hold all the mode supported by the first console.
2131 while (MaxMode
> (INT32
) Private
->TextOutQueryDataCount
) {
2132 Status
= ConSplitterGrowBuffer (
2133 sizeof (TEXT_OUT_SPLITTER_QUERY_DATA
),
2134 &Private
->TextOutQueryDataCount
,
2135 (VOID
**) &Private
->TextOutQueryData
2137 if (EFI_ERROR (Status
)) {
2138 return EFI_OUT_OF_RESOURCES
;
2142 // Allocate buffer for the output mode map
2144 Status
= ConSplitterGrowMapTable (Private
);
2145 if (EFI_ERROR (Status
)) {
2146 return EFI_OUT_OF_RESOURCES
;
2149 // As the first textout device, directly add the mode in to QueryData
2150 // and at the same time record the mapping between QueryData and TextOut.
2154 while (Mode
< MaxMode
) {
2155 TextOut
->QueryMode (
2158 &Private
->TextOutQueryData
[Mode
].Columns
,
2159 &Private
->TextOutQueryData
[Mode
].Rows
2161 Private
->TextOutModeMap
[Index
] = Mode
;
2163 Index
+= Private
->TextOutListCount
;
2171 ConSplitterGetIntersection (
2172 IN INT32
*TextOutModeMap
,
2173 IN INT32
*NewlyAddedMap
,
2174 IN UINTN MapStepSize
,
2175 IN UINTN NewMapStepSize
,
2177 OUT INT32
*CurrentMode
2181 INT32
*CurrentMapEntry
;
2182 INT32
*NextMapEntry
;
2183 INT32 CurrentMaxMode
;
2187 CurrentMapEntry
= TextOutModeMap
;
2188 NextMapEntry
= TextOutModeMap
;
2189 CurrentMaxMode
= *MaxMode
;
2190 Mode
= *CurrentMode
;
2192 while (Index
< CurrentMaxMode
) {
2193 if (*NewlyAddedMap
== -1) {
2195 // This mode is not supported any more. Remove it. Special care
2196 // must be taken as this remove will also affect current mode;
2198 if (Index
== *CurrentMode
) {
2200 } else if (Index
< *CurrentMode
) {
2205 if (CurrentMapEntry
!= NextMapEntry
) {
2206 CopyMem (NextMapEntry
, CurrentMapEntry
, MapStepSize
* sizeof (INT32
));
2209 NextMapEntry
+= MapStepSize
;
2212 CurrentMapEntry
+= MapStepSize
;
2213 NewlyAddedMap
+= NewMapStepSize
;
2217 *CurrentMode
= Mode
;
2224 ConSplitterSyncOutputMode (
2225 IN TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
,
2226 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
2230 Routine Description:
2233 Private - Private data structure.
2234 TextOut - Text Out Protocol.
2241 INT32 CurrentMaxMode
;
2244 INT32
*TextOutModeMap
;
2247 TEXT_OUT_SPLITTER_QUERY_DATA
*TextOutQueryData
;
2253 // Must make sure that current mode won't change even if mode number changes
2255 CurrentMaxMode
= Private
->TextOutMode
.MaxMode
;
2256 TextOutModeMap
= Private
->TextOutModeMap
;
2257 StepSize
= Private
->TextOutListCount
;
2258 TextOutQueryData
= Private
->TextOutQueryData
;
2261 // Query all the mode that the newly added TextOut supports
2264 MapTable
= TextOutModeMap
+ Private
->CurrentNumberOfConsoles
;
2265 while (Mode
< TextOut
->Mode
->MaxMode
) {
2266 TextOut
->QueryMode (TextOut
, Mode
, &Columns
, &Rows
);
2267 MapTable
[StepSize
] = Mode
;
2270 // Search the intersection map and QueryData database to see if they intersects
2273 while (Index
< CurrentMaxMode
) {
2274 QueryMode
= *(TextOutModeMap
+ Index
* StepSize
);
2275 if ((TextOutQueryData
[QueryMode
].Rows
== Rows
) && (TextOutQueryData
[QueryMode
].Columns
== Columns
)) {
2276 MapTable
[Index
* StepSize
] = Mode
;
2286 // Now search the TextOutModeMap table to find the intersection of supported
2287 // mode between ConSplitter and the newly added device.
2289 ConSplitterGetIntersection (
2294 &Private
->TextOutMode
.MaxMode
,
2295 &Private
->TextOutMode
.Mode
2303 ConSplitterGetIntersectionBetweenConOutAndStrErr (
2308 Routine Description:
2315 EFI_OUT_OF_RESOURCES
2319 UINTN ConOutNumOfConsoles
;
2320 UINTN StdErrNumOfConsoles
;
2321 TEXT_OUT_AND_GOP_DATA
*ConOutTextOutList
;
2322 TEXT_OUT_AND_GOP_DATA
*StdErrTextOutList
;
2326 UINTN ConOutColumns
;
2328 UINTN StdErrColumns
;
2329 INT32 ConOutMaxMode
;
2330 INT32 StdErrMaxMode
;
2335 INT32
*ConOutModeMap
;
2336 INT32
*StdErrModeMap
;
2337 INT32
*ConOutMapTable
;
2338 INT32
*StdErrMapTable
;
2339 TEXT_OUT_SPLITTER_QUERY_DATA
*ConOutQueryData
;
2340 TEXT_OUT_SPLITTER_QUERY_DATA
*StdErrQueryData
;
2341 UINTN ConOutStepSize
;
2342 UINTN StdErrStepSize
;
2343 BOOLEAN FoundTheSameTextOut
;
2344 UINTN ConOutMapTableSize
;
2345 UINTN StdErrMapTableSize
;
2347 ConOutNumOfConsoles
= mConOut
.CurrentNumberOfConsoles
;
2348 StdErrNumOfConsoles
= mStdErr
.CurrentNumberOfConsoles
;
2349 ConOutTextOutList
= mConOut
.TextOutList
;
2350 StdErrTextOutList
= mStdErr
.TextOutList
;
2353 FoundTheSameTextOut
= FALSE
;
2354 while ((Indexi
< ConOutNumOfConsoles
) && (!FoundTheSameTextOut
)) {
2356 while (Indexj
< StdErrNumOfConsoles
) {
2357 if (ConOutTextOutList
->TextOut
== StdErrTextOutList
->TextOut
) {
2358 FoundTheSameTextOut
= TRUE
;
2363 StdErrTextOutList
++;
2367 ConOutTextOutList
++;
2370 if (!FoundTheSameTextOut
) {
2374 // Must make sure that current mode won't change even if mode number changes
2376 ConOutMaxMode
= mConOut
.TextOutMode
.MaxMode
;
2377 ConOutModeMap
= mConOut
.TextOutModeMap
;
2378 ConOutStepSize
= mConOut
.TextOutListCount
;
2379 ConOutQueryData
= mConOut
.TextOutQueryData
;
2381 StdErrMaxMode
= mStdErr
.TextOutMode
.MaxMode
;
2382 StdErrModeMap
= mStdErr
.TextOutModeMap
;
2383 StdErrStepSize
= mStdErr
.TextOutListCount
;
2384 StdErrQueryData
= mStdErr
.TextOutQueryData
;
2387 // Allocate the map table and set the map table's index to -1.
2389 ConOutMapTableSize
= ConOutMaxMode
* sizeof (INT32
);
2390 ConOutMapTable
= AllocateZeroPool (ConOutMapTableSize
);
2391 if (ConOutMapTable
== NULL
) {
2392 return EFI_OUT_OF_RESOURCES
;
2395 SetMem (ConOutMapTable
, ConOutMapTableSize
, 0xFF);
2397 StdErrMapTableSize
= StdErrMaxMode
* sizeof (INT32
);
2398 StdErrMapTable
= AllocateZeroPool (StdErrMapTableSize
);
2399 if (StdErrMapTable
== NULL
) {
2400 return EFI_OUT_OF_RESOURCES
;
2403 SetMem (StdErrMapTable
, StdErrMapTableSize
, 0xFF);
2406 // Find the intersection of the two set of modes. If they actually intersect, the
2407 // correponding entry in the map table is set to 1.
2410 while (Mode
< ConOutMaxMode
) {
2412 // Search the intersection map and QueryData database to see if they intersect
2415 ConOutMode
= *(ConOutModeMap
+ Mode
* ConOutStepSize
);
2416 ConOutRows
= ConOutQueryData
[ConOutMode
].Rows
;
2417 ConOutColumns
= ConOutQueryData
[ConOutMode
].Columns
;
2418 while (Index
< StdErrMaxMode
) {
2419 StdErrMode
= *(StdErrModeMap
+ Index
* StdErrStepSize
);
2420 StdErrRows
= StdErrQueryData
[StdErrMode
].Rows
;
2421 StdErrColumns
= StdErrQueryData
[StdErrMode
].Columns
;
2422 if ((StdErrRows
== ConOutRows
) && (StdErrColumns
== ConOutColumns
)) {
2423 ConOutMapTable
[Mode
] = 1;
2424 StdErrMapTable
[Index
] = 1;
2434 // Now search the TextOutModeMap table to find the intersection of supported
2435 // mode between ConSplitter and the newly added device.
2437 ConSplitterGetIntersection (
2440 mConOut
.TextOutListCount
,
2442 &(mConOut
.TextOutMode
.MaxMode
),
2443 &(mConOut
.TextOutMode
.Mode
)
2445 if (mConOut
.TextOutMode
.Mode
< 0) {
2446 mConOut
.TextOut
.SetMode (&(mConOut
.TextOut
), 0);
2449 ConSplitterGetIntersection (
2452 mStdErr
.TextOutListCount
,
2454 &(mStdErr
.TextOutMode
.MaxMode
),
2455 &(mStdErr
.TextOutMode
.Mode
)
2457 if (mStdErr
.TextOutMode
.Mode
< 0) {
2458 mStdErr
.TextOut
.SetMode (&(mStdErr
.TextOut
), 0);
2461 FreePool (ConOutMapTable
);
2462 FreePool (StdErrMapTable
);
2469 ConSplitterAddGraphicsOutputMode (
2470 IN TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
,
2471 IN EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
,
2472 IN EFI_UGA_DRAW_PROTOCOL
*UgaDraw
2476 Routine Description:
2489 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*Mode
;
2491 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*Info
;
2492 EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE
*CurrentGraphicsOutputMode
;
2493 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*ModeBuffer
;
2494 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*MatchedMode
;
2497 BOOLEAN AlreadyExist
;
2498 UINT32 UgaHorizontalResolution
;
2499 UINT32 UgaVerticalResolution
;
2500 UINT32 UgaColorDepth
;
2501 UINT32 UgaRefreshRate
;
2503 if ((GraphicsOutput
== NULL
) && (UgaDraw
== NULL
)) {
2504 return EFI_UNSUPPORTED
;
2507 CurrentGraphicsOutputMode
= Private
->GraphicsOutput
.Mode
;
2512 if (Private
->CurrentNumberOfUgaDraw
!= 0) {
2514 // If any UGA device has already been added, then there is no need to
2515 // calculate intersection of display mode of different GOP/UGA device,
2516 // since only one display mode will be exported (i.e. user-defined mode)
2521 if (GraphicsOutput
!= NULL
) {
2522 if (Private
->CurrentNumberOfGraphicsOutput
== 0) {
2524 // This is the first Graphics Output device added
2526 CurrentGraphicsOutputMode
->MaxMode
= GraphicsOutput
->Mode
->MaxMode
;
2527 CurrentGraphicsOutputMode
->Mode
= GraphicsOutput
->Mode
->Mode
;
2528 CopyMem (CurrentGraphicsOutputMode
->Info
, GraphicsOutput
->Mode
->Info
, GraphicsOutput
->Mode
->SizeOfInfo
);
2529 CurrentGraphicsOutputMode
->SizeOfInfo
= GraphicsOutput
->Mode
->SizeOfInfo
;
2530 CurrentGraphicsOutputMode
->FrameBufferBase
= GraphicsOutput
->Mode
->FrameBufferBase
;
2531 CurrentGraphicsOutputMode
->FrameBufferSize
= GraphicsOutput
->Mode
->FrameBufferSize
;
2534 // Allocate resource for the private mode buffer
2536 ModeBuffer
= AllocatePool (GraphicsOutput
->Mode
->SizeOfInfo
* GraphicsOutput
->Mode
->MaxMode
);
2537 if (ModeBuffer
== NULL
) {
2538 return EFI_OUT_OF_RESOURCES
;
2540 FreePool (Private
->GraphicsOutputModeBuffer
);
2541 Private
->GraphicsOutputModeBuffer
= ModeBuffer
;
2544 // Store all supported display modes to the private mode buffer
2547 for (Index
= 0; Index
< GraphicsOutput
->Mode
->MaxMode
; Index
++) {
2548 Status
= GraphicsOutput
->QueryMode (GraphicsOutput
, (UINT32
) Index
, &SizeOfInfo
, &Info
);
2549 if (EFI_ERROR (Status
)) {
2552 CopyMem (Mode
, Info
, SizeOfInfo
);
2558 // Check intersection of display mode
2560 ModeBuffer
= AllocatePool (sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
) * CurrentGraphicsOutputMode
->MaxMode
);
2561 if (ModeBuffer
== NULL
) {
2562 return EFI_OUT_OF_RESOURCES
;
2565 MatchedMode
= ModeBuffer
;
2566 Mode
= &Private
->GraphicsOutputModeBuffer
[0];
2567 for (Index
= 0; Index
< CurrentGraphicsOutputMode
->MaxMode
; Index
++) {
2570 for (NumberIndex
= 0; NumberIndex
< GraphicsOutput
->Mode
->MaxMode
; NumberIndex
++) {
2571 Status
= GraphicsOutput
->QueryMode (GraphicsOutput
, (UINT32
) NumberIndex
, &SizeOfInfo
, &Info
);
2572 if (EFI_ERROR (Status
)) {
2575 if ((Info
->HorizontalResolution
== Mode
->HorizontalResolution
) &&
2576 (Info
->VerticalResolution
== Mode
->VerticalResolution
)) {
2585 AlreadyExist
= FALSE
;
2587 for (Info
= ModeBuffer
; Info
< MatchedMode
; Info
++) {
2588 if ((Info
->HorizontalResolution
== Mode
->HorizontalResolution
) &&
2589 (Info
->VerticalResolution
== Mode
->VerticalResolution
)) {
2590 AlreadyExist
= TRUE
;
2595 if (!AlreadyExist
) {
2596 CopyMem (MatchedMode
, Mode
, sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
));
2599 // Physical frame buffer is no longer available, change PixelFormat to PixelBltOnly
2601 MatchedMode
->Version
= 0;
2602 MatchedMode
->PixelFormat
= PixelBltOnly
;
2603 ZeroMem (&MatchedMode
->PixelInformation
, sizeof (EFI_PIXEL_BITMASK
));
2613 // Drop the old mode buffer, assign it to a new one
2615 FreePool (Private
->GraphicsOutputModeBuffer
);
2616 Private
->GraphicsOutputModeBuffer
= ModeBuffer
;
2619 // Physical frame buffer is no longer available when there are more than one physical GOP devices
2621 CurrentGraphicsOutputMode
->MaxMode
= (UINT32
) (((UINTN
) MatchedMode
- (UINTN
) ModeBuffer
) / sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
));
2622 CurrentGraphicsOutputMode
->Info
->PixelFormat
= PixelBltOnly
;
2623 ZeroMem (&CurrentGraphicsOutputMode
->Info
->PixelInformation
, sizeof (EFI_PIXEL_BITMASK
));
2624 CurrentGraphicsOutputMode
->SizeOfInfo
= sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
);
2625 CurrentGraphicsOutputMode
->FrameBufferBase
= (EFI_PHYSICAL_ADDRESS
) NULL
;
2626 CurrentGraphicsOutputMode
->FrameBufferSize
= 0;
2630 // Graphics console driver can ensure the same mode for all GOP devices
2632 for (Index
= 0; Index
< CurrentGraphicsOutputMode
->MaxMode
; Index
++) {
2633 Mode
= &Private
->GraphicsOutputModeBuffer
[Index
];
2634 if ((Mode
->HorizontalResolution
== GraphicsOutput
->Mode
->Info
->HorizontalResolution
) &&
2635 (Mode
->VerticalResolution
== GraphicsOutput
->Mode
->Info
->VerticalResolution
)) {
2636 CurrentIndex
= Index
;
2640 if (Index
>= CurrentGraphicsOutputMode
->MaxMode
) {
2642 // if user defined mode is not found, set to default mode 800x600
2644 for (Index
= 0; Index
< CurrentGraphicsOutputMode
->MaxMode
; Index
++) {
2645 Mode
= &Private
->GraphicsOutputModeBuffer
[Index
];
2646 if ((Mode
->HorizontalResolution
== 800) && (Mode
->VerticalResolution
== 600)) {
2647 CurrentIndex
= Index
;
2653 if (UgaDraw
!= NULL
) {
2655 // Graphics console driver can ensure the same mode for all GOP devices
2656 // so we can get the current mode from this video device
2660 &UgaHorizontalResolution
,
2661 &UgaVerticalResolution
,
2666 CurrentGraphicsOutputMode
->MaxMode
= 1;
2667 Info
= CurrentGraphicsOutputMode
->Info
;
2669 Info
->HorizontalResolution
= UgaHorizontalResolution
;
2670 Info
->VerticalResolution
= UgaVerticalResolution
;
2671 Info
->PixelFormat
= PixelBltOnly
;
2672 Info
->PixelsPerScanLine
= UgaHorizontalResolution
;
2673 CurrentGraphicsOutputMode
->SizeOfInfo
= sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
);
2674 CurrentGraphicsOutputMode
->FrameBufferBase
= (EFI_PHYSICAL_ADDRESS
) NULL
;
2675 CurrentGraphicsOutputMode
->FrameBufferSize
= 0;
2678 // Update the private mode buffer
2680 CopyMem (&Private
->GraphicsOutputModeBuffer
[0], Info
, sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
));
2683 // Only mode 0 is available to be set
2690 if (GraphicsOutput
!= NULL
) {
2691 Private
->CurrentNumberOfGraphicsOutput
++;
2693 if (UgaDraw
!= NULL
) {
2694 Private
->CurrentNumberOfUgaDraw
++;
2698 // Force GraphicsOutput mode to be set,
2699 // regardless whether the console is in EfiConsoleControlScreenGraphics or EfiConsoleControlScreenText mode
2701 Private
->HardwareNeedsStarting
= TRUE
;
2703 // Current mode number may need update now, so set it to an invalid mode number
2705 CurrentGraphicsOutputMode
->Mode
= 0xffff;
2707 // Graphics console can ensure all GOP devices have the same mode which can be taken as current mode.
2709 Status
= Private
->GraphicsOutput
.SetMode (&Private
->GraphicsOutput
, (UINT32
) CurrentIndex
);
2712 // If user defined mode is not valid for UGA, set to the default mode 800x600.
2714 if (EFI_ERROR(Status
)) {
2715 (Private
->GraphicsOutputModeBuffer
[0]).HorizontalResolution
= 800;
2716 (Private
->GraphicsOutputModeBuffer
[0]).VerticalResolution
= 600;
2717 Status
= Private
->GraphicsOutput
.SetMode (&Private
->GraphicsOutput
, 0);
2724 ConSplitterTextOutAddDevice (
2725 IN TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
,
2726 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
,
2727 IN EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
,
2728 IN EFI_UGA_DRAW_PROTOCOL
*UgaDraw
2732 Routine Description:
2743 UINTN CurrentNumOfConsoles
;
2746 UINT32 UgaHorizontalResolution
;
2747 UINT32 UgaVerticalResolution
;
2748 UINT32 UgaColorDepth
;
2749 UINT32 UgaRefreshRate
;
2750 TEXT_OUT_AND_GOP_DATA
*TextAndGop
;
2752 Status
= EFI_SUCCESS
;
2753 CurrentNumOfConsoles
= Private
->CurrentNumberOfConsoles
;
2756 // If the Text Out List is full, enlarge it by calling growbuffer().
2758 while (CurrentNumOfConsoles
>= Private
->TextOutListCount
) {
2759 Status
= ConSplitterGrowBuffer (
2760 sizeof (TEXT_OUT_AND_GOP_DATA
),
2761 &Private
->TextOutListCount
,
2762 (VOID
**) &Private
->TextOutList
2764 if (EFI_ERROR (Status
)) {
2765 return EFI_OUT_OF_RESOURCES
;
2768 // Also need to reallocate the TextOutModeMap table
2770 Status
= ConSplitterGrowMapTable (Private
);
2771 if (EFI_ERROR (Status
)) {
2772 return EFI_OUT_OF_RESOURCES
;
2776 TextAndGop
= &Private
->TextOutList
[CurrentNumOfConsoles
];
2778 TextAndGop
->TextOut
= TextOut
;
2779 TextAndGop
->GraphicsOutput
= GraphicsOutput
;
2780 TextAndGop
->UgaDraw
= UgaDraw
;
2782 if ((GraphicsOutput
== NULL
) && (UgaDraw
== NULL
)) {
2784 // If No GOP/UGA device then use the ConOut device
2786 TextAndGop
->TextOutEnabled
= TRUE
;
2789 // If GOP/UGA device use ConOut device only used if screen is in Text mode
2791 TextAndGop
->TextOutEnabled
= (BOOLEAN
) (Private
->ConsoleOutputMode
== EfiConsoleControlScreenText
);
2794 if (CurrentNumOfConsoles
== 0) {
2796 // Add the first device's output mode to console splitter's mode list
2798 Status
= ConSplitterAddOutputMode (Private
, TextOut
);
2800 ConSplitterSyncOutputMode (Private
, TextOut
);
2803 Private
->CurrentNumberOfConsoles
++;
2806 // Scan both TextOutList, for the intersection TextOut device
2807 // maybe both ConOut and StdErr incorporate the same Text Out
2808 // device in them, thus the output of both should be synced.
2810 ConSplitterGetIntersectionBetweenConOutAndStrErr ();
2812 CurrentMode
= Private
->TextOutMode
.Mode
;
2813 MaxMode
= Private
->TextOutMode
.MaxMode
;
2814 ASSERT (MaxMode
>= 1);
2817 // Update DevNull mode according to current video device
2819 if (FeaturePcdGet (PcdConOutGopSupport
)) {
2820 if ((GraphicsOutput
!= NULL
) || (UgaDraw
!= NULL
)) {
2821 ConSplitterAddGraphicsOutputMode (Private
, GraphicsOutput
, UgaDraw
);
2824 if (FeaturePcdGet (PcdConOutUgaSupport
)) {
2825 if (UgaDraw
!= NULL
) {
2826 Status
= UgaDraw
->GetMode (
2828 &UgaHorizontalResolution
,
2829 &UgaVerticalResolution
,
2833 if (!EFI_ERROR (Status
)) {
2834 Status
= ConSpliterUgaDrawSetMode (
2836 UgaHorizontalResolution
,
2837 UgaVerticalResolution
,
2843 // If GetMode/SetMode is failed, set to 800x600 mode
2845 if(EFI_ERROR (Status
)) {
2846 Status
= ConSpliterUgaDrawSetMode (
2857 if (Private
->ConsoleOutputMode
== EfiConsoleControlScreenGraphics
&& GraphicsOutput
!= NULL
) {
2859 // We just added a new GOP or UGA device in graphics mode
2861 if (FeaturePcdGet (PcdConOutGopSupport
)) {
2862 DevNullGopSync (Private
, TextAndGop
->GraphicsOutput
, TextAndGop
->UgaDraw
);
2863 } else if (FeaturePcdGet (PcdConOutUgaSupport
)) {
2864 DevNullUgaSync (Private
, TextAndGop
->GraphicsOutput
, TextAndGop
->UgaDraw
);
2866 } else if ((CurrentMode
>= 0) && ((GraphicsOutput
!= NULL
) || (UgaDraw
!= NULL
)) && (CurrentMode
< Private
->TextOutMode
.MaxMode
)) {
2868 // The new console supports the same mode of the current console so sync up
2870 DevNullSyncStdOut (Private
);
2873 // If ConOut, then set the mode to Mode #0 which us 80 x 25
2875 Private
->TextOut
.SetMode (&Private
->TextOut
, 0);
2882 ConSplitterTextOutDeleteDevice (
2883 IN TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
,
2884 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
2888 Routine Description:
2899 UINTN CurrentNumOfConsoles
;
2900 TEXT_OUT_AND_GOP_DATA
*TextOutList
;
2904 // Remove the specified text-out device data structure from the Text out List,
2905 // and rearrange the remaining data structures in the Text out List.
2907 CurrentNumOfConsoles
= Private
->CurrentNumberOfConsoles
;
2908 Index
= (INT32
) CurrentNumOfConsoles
- 1;
2909 TextOutList
= Private
->TextOutList
;
2910 while (Index
>= 0) {
2911 if (TextOutList
->TextOut
== TextOut
) {
2912 CopyMem (TextOutList
, TextOutList
+ 1, sizeof (TEXT_OUT_AND_GOP_DATA
) * Index
);
2913 CurrentNumOfConsoles
--;
2914 if (TextOutList
->UgaDraw
!= NULL
) {
2915 Private
->CurrentNumberOfUgaDraw
--;
2917 if (TextOutList
->GraphicsOutput
!= NULL
) {
2918 Private
->CurrentNumberOfGraphicsOutput
--;
2927 // The specified TextOut is not managed by the ConSplitter driver
2930 return EFI_NOT_FOUND
;
2933 if (CurrentNumOfConsoles
== 0) {
2935 // If the number of consoles is zero clear the Dev NULL device
2937 Private
->CurrentNumberOfConsoles
= 0;
2938 Private
->TextOutMode
.MaxMode
= 1;
2939 Private
->TextOutQueryData
[0].Columns
= 80;
2940 Private
->TextOutQueryData
[0].Rows
= 25;
2941 DevNullTextOutSetMode (Private
, 0);
2946 // Max Mode is realy an intersection of the QueryMode command to all
2947 // devices. So we must copy the QueryMode of the first device to
2951 Private
->TextOutQueryData
,
2952 Private
->TextOutQueryDataCount
* sizeof (TEXT_OUT_SPLITTER_QUERY_DATA
)
2955 FreePool (Private
->TextOutModeMap
);
2956 Private
->TextOutModeMap
= NULL
;
2957 TextOutList
= Private
->TextOutList
;
2960 // Add the first TextOut to the QueryData array and ModeMap table
2962 Status
= ConSplitterAddOutputMode (Private
, TextOutList
->TextOut
);
2965 // Now add one by one
2968 Private
->CurrentNumberOfConsoles
= 1;
2970 while ((UINTN
) Index
< CurrentNumOfConsoles
) {
2971 ConSplitterSyncOutputMode (Private
, TextOutList
->TextOut
);
2973 Private
->CurrentNumberOfConsoles
++;
2977 ConSplitterGetIntersectionBetweenConOutAndStrErr ();
2982 // ConSplitter TextIn member functions
2986 ConSplitterTextInReset (
2987 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*This
,
2988 IN BOOLEAN ExtendedVerification
2992 Routine Description:
2993 Reset the input device and optionaly run diagnostics
2996 This - Protocol instance pointer.
2997 ExtendedVerification - Driver may perform diagnostics on reset.
3000 EFI_SUCCESS - The device was reset.
3001 EFI_DEVICE_ERROR - The device is not functioning properly and could
3007 EFI_STATUS ReturnStatus
;
3008 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3011 Private
= TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
3013 Private
->KeyEventSignalState
= FALSE
;
3016 // return the worst status met
3018 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
3019 Status
= Private
->TextInList
[Index
]->Reset (
3020 Private
->TextInList
[Index
],
3021 ExtendedVerification
3023 if (EFI_ERROR (Status
)) {
3024 ReturnStatus
= Status
;
3028 return ReturnStatus
;
3033 ConSplitterTextInPrivateReadKeyStroke (
3034 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
3035 OUT EFI_INPUT_KEY
*Key
3039 Routine Description:
3040 Reads the next keystroke from the input device. The WaitForKey Event can
3041 be used to test for existance of a keystroke via WaitForEvent () call.
3044 This - Protocol instance pointer.
3045 Key - Driver may perform diagnostics on reset.
3048 EFI_SUCCESS - The keystroke information was returned.
3049 EFI_NOT_READY - There was no keystroke data availiable.
3050 EFI_DEVICE_ERROR - The keydtroke information was not returned due to
3057 EFI_INPUT_KEY CurrentKey
;
3059 Key
->UnicodeChar
= 0;
3060 Key
->ScanCode
= SCAN_NULL
;
3063 // if no physical console input device exists, return EFI_NOT_READY;
3064 // if any physical console input device has key input,
3065 // return the key and EFI_SUCCESS.
3067 for (Index
= 0; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
3068 Status
= Private
->TextInList
[Index
]->ReadKeyStroke (
3069 Private
->TextInList
[Index
],
3072 if (!EFI_ERROR (Status
)) {
3078 return EFI_NOT_READY
;
3082 ConSpliterConssoleControlStdInLocked (
3087 Routine Description:
3088 Return TRUE if StdIn is locked. The ConIn device on the virtual handle is
3089 the only device locked.
3096 FALSE - StdIn working normally
3100 return mConIn
.PasswordEnabled
;
3105 ConSpliterConsoleControlLockStdInEvent (
3111 Routine Description:
3112 This timer event will fire when StdIn is locked. It will check the key
3113 sequence on StdIn to see if it matches the password. Any error in the
3114 password will cause the check to reset. As long a mConIn.PasswordEnabled is
3115 TRUE the StdIn splitter will not report any input.
3118 (Standard EFI_EVENT_NOTIFY)
3127 CHAR16 BackSpaceString
[2];
3128 CHAR16 SpaceString
[2];
3131 Status
= ConSplitterTextInPrivateReadKeyStroke (&mConIn
, &Key
);
3132 if (!EFI_ERROR (Status
)) {
3134 // if it's an ENTER, match password
3136 if ((Key
.UnicodeChar
== CHAR_CARRIAGE_RETURN
) && (Key
.ScanCode
== SCAN_NULL
)) {
3137 mConIn
.PwdAttempt
[mConIn
.PwdIndex
] = CHAR_NULL
;
3138 if (StrCmp (mConIn
.Password
, mConIn
.PwdAttempt
)) {
3140 // Password not match
3142 ConSplitterTextOutOutputString (&mConOut
.TextOut
, (CHAR16
*) L
"\n\rPassword not correct\n\r");
3143 mConIn
.PwdIndex
= 0;
3146 // Key matches password sequence
3148 gBS
->SetTimer (mConIn
.LockEvent
, TimerPeriodic
, 0);
3149 mConIn
.PasswordEnabled
= FALSE
;
3150 Status
= EFI_NOT_READY
;
3152 } else if ((Key
.UnicodeChar
== CHAR_BACKSPACE
) && (Key
.ScanCode
== SCAN_NULL
)) {
3156 if (mConIn
.PwdIndex
> 0) {
3157 BackSpaceString
[0] = CHAR_BACKSPACE
;
3158 BackSpaceString
[1] = 0;
3160 SpaceString
[0] = ' ';
3163 ConSplitterTextOutOutputString (&mConOut
.TextOut
, BackSpaceString
);
3164 ConSplitterTextOutOutputString (&mConOut
.TextOut
, SpaceString
);
3165 ConSplitterTextOutOutputString (&mConOut
.TextOut
, BackSpaceString
);
3169 } else if ((Key
.ScanCode
== SCAN_NULL
) && (Key
.UnicodeChar
>= 32)) {
3171 // If it's not an ENTER, neigher a function key, nor a CTRL-X or ALT-X, record the input
3173 if (mConIn
.PwdIndex
< (MAX_STD_IN_PASSWORD
- 1)) {
3174 if (mConIn
.PwdIndex
== 0) {
3175 ConSplitterTextOutOutputString (&mConOut
.TextOut
, (CHAR16
*) L
"\n\r");
3178 ConSplitterTextOutOutputString (&mConOut
.TextOut
, (CHAR16
*) L
"*");
3179 mConIn
.PwdAttempt
[mConIn
.PwdIndex
] = Key
.UnicodeChar
;
3184 } while (!EFI_ERROR (Status
));
3189 ConSpliterConsoleControlLockStdIn (
3190 IN EFI_CONSOLE_CONTROL_PROTOCOL
*This
,
3195 Routine Description:
3196 If Password is NULL unlock the password state variable and set the event
3197 timer. If the Password is too big return an error. If the Password is valid
3198 Copy the Password and enable state variable and then arm the periodic timer
3203 EFI_SUCCESS - Lock the StdIn device
3204 EFI_INVALID_PARAMETER - Password is NULL
3205 EFI_OUT_OF_RESOURCES - Buffer allocation to store the password fails
3209 if (Password
== NULL
) {
3210 return EFI_INVALID_PARAMETER
;
3213 if (StrLen (Password
) >= MAX_STD_IN_PASSWORD
) {
3215 // Currently have a max password size
3217 return EFI_OUT_OF_RESOURCES
;
3220 // Save the password, initialize state variables and arm event timer
3222 StrCpy (mConIn
.Password
, Password
);
3223 mConIn
.PasswordEnabled
= TRUE
;
3224 mConIn
.PwdIndex
= 0;
3225 gBS
->SetTimer (mConIn
.LockEvent
, TimerPeriodic
, (10000 * 25));
3232 ConSplitterTextInReadKeyStroke (
3233 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*This
,
3234 OUT EFI_INPUT_KEY
*Key
3238 Routine Description:
3239 Reads the next keystroke from the input device. The WaitForKey Event can
3240 be used to test for existance of a keystroke via WaitForEvent () call.
3241 If the ConIn is password locked make it look like no keystroke is availible
3244 This - Protocol instance pointer.
3245 Key - Driver may perform diagnostics on reset.
3248 EFI_SUCCESS - The keystroke information was returned.
3249 EFI_NOT_READY - There was no keystroke data availiable.
3250 EFI_DEVICE_ERROR - The keydtroke information was not returned due to
3255 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3257 Private
= TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
3258 if (Private
->PasswordEnabled
) {
3260 // If StdIn Locked return not ready
3262 return EFI_NOT_READY
;
3265 Private
->KeyEventSignalState
= FALSE
;
3267 return ConSplitterTextInPrivateReadKeyStroke (Private
, Key
);
3272 ConSplitterTextInWaitForKey (
3278 Routine Description:
3279 This event agregates all the events of the ConIn devices in the spliter.
3280 If the ConIn is password locked then return.
3281 If any events of physical ConIn devices are signaled, signal the ConIn
3282 spliter event. This will cause the calling code to call
3283 ConSplitterTextInReadKeyStroke ().
3286 Event - The Event assoicated with callback.
3287 Context - Context registered when Event was created.
3295 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3298 Private
= (TEXT_IN_SPLITTER_PRIVATE_DATA
*) Context
;
3299 if (Private
->PasswordEnabled
) {
3301 // If StdIn Locked return not ready
3307 // if KeyEventSignalState is flagged before, and not cleared by Reset() or ReadKeyStroke()
3309 if (Private
->KeyEventSignalState
) {
3310 gBS
->SignalEvent (Event
);
3314 // if any physical console input device has key input, signal the event.
3316 for (Index
= 0; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
3317 Status
= gBS
->CheckEvent (Private
->TextInList
[Index
]->WaitForKey
);
3318 if (!EFI_ERROR (Status
)) {
3319 gBS
->SignalEvent (Event
);
3320 Private
->KeyEventSignalState
= TRUE
;
3329 IN EFI_KEY_DATA
*RegsiteredData
,
3330 IN EFI_KEY_DATA
*InputData
3334 Routine Description:
3338 RegsiteredData - A pointer to a buffer that is filled in with the keystroke
3339 state data for the key that was registered.
3340 InputData - A pointer to a buffer that is filled in with the keystroke
3341 state data for the key that was pressed.
3344 TRUE - Key be pressed matches a registered key.
3345 FLASE - Match failed.
3349 ASSERT (RegsiteredData
!= NULL
&& InputData
!= NULL
);
3351 if ((RegsiteredData
->Key
.ScanCode
!= InputData
->Key
.ScanCode
) ||
3352 (RegsiteredData
->Key
.UnicodeChar
!= InputData
->Key
.UnicodeChar
)) {
3357 // Assume KeyShiftState/KeyToggleState = 0 in Registered key data means these state could be ignored.
3359 if (RegsiteredData
->KeyState
.KeyShiftState
!= 0 &&
3360 RegsiteredData
->KeyState
.KeyShiftState
!= InputData
->KeyState
.KeyShiftState
) {
3363 if (RegsiteredData
->KeyState
.KeyToggleState
!= 0 &&
3364 RegsiteredData
->KeyState
.KeyToggleState
!= InputData
->KeyState
.KeyToggleState
) {
3373 // Simple Text Input Ex protocol functions
3378 ConSplitterTextInResetEx (
3379 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*This
,
3380 IN BOOLEAN ExtendedVerification
3384 Routine Description:
3385 Reset the input device and optionaly run diagnostics
3388 This - Protocol instance pointer.
3389 ExtendedVerification - Driver may perform diagnostics on reset.
3392 EFI_SUCCESS - The device was reset.
3393 EFI_DEVICE_ERROR - The device is not functioning properly and could
3399 EFI_STATUS ReturnStatus
;
3400 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3403 Private
= TEXT_IN_EX_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
3405 Private
->KeyEventSignalState
= FALSE
;
3408 // return the worst status met
3410 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfExConsoles
; Index
++) {
3411 Status
= Private
->TextInExList
[Index
]->Reset (
3412 Private
->TextInExList
[Index
],
3413 ExtendedVerification
3415 if (EFI_ERROR (Status
)) {
3416 ReturnStatus
= Status
;
3420 return ReturnStatus
;
3426 ConSplitterTextInReadKeyStrokeEx (
3427 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*This
,
3428 OUT EFI_KEY_DATA
*KeyData
3432 Routine Description:
3433 Reads the next keystroke from the input device. The WaitForKey Event can
3434 be used to test for existance of a keystroke via WaitForEvent () call.
3437 This - Protocol instance pointer.
3438 KeyData - A pointer to a buffer that is filled in with the keystroke
3439 state data for the key that was pressed.
3442 EFI_SUCCESS - The keystroke information was returned.
3443 EFI_NOT_READY - There was no keystroke data availiable.
3444 EFI_DEVICE_ERROR - The keystroke information was not returned due to
3446 EFI_INVALID_PARAMETER - KeyData is NULL.
3450 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3453 EFI_KEY_DATA CurrentKeyData
;
3456 if (KeyData
== NULL
) {
3457 return EFI_INVALID_PARAMETER
;
3460 Private
= TEXT_IN_EX_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
3461 if (Private
->PasswordEnabled
) {
3463 // If StdIn Locked return not ready
3465 return EFI_NOT_READY
;
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 ConSplitterTextInSetState (
3495 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*This
,
3496 IN EFI_KEY_TOGGLE_STATE
*KeyToggleState
3500 Routine Description:
3501 Set certain state for the input device.
3504 This - Protocol instance pointer.
3505 KeyToggleState - A pointer to the EFI_KEY_TOGGLE_STATE to set the
3506 state for the input device.
3509 EFI_SUCCESS - The device state was set successfully.
3510 EFI_DEVICE_ERROR - The device is not functioning correctly and could
3511 not have the setting adjusted.
3512 EFI_UNSUPPORTED - The device does not have the ability to set its state.
3513 EFI_INVALID_PARAMETER - KeyToggleState is NULL.
3517 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3521 if (KeyToggleState
== NULL
) {
3522 return EFI_INVALID_PARAMETER
;
3525 Private
= TEXT_IN_EX_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
3528 // if no physical console input device exists, return EFI_SUCCESS;
3529 // otherwise return the status of setting state of physical console input device
3531 for (Index
= 0; Index
< Private
->CurrentNumberOfExConsoles
; Index
++) {
3532 Status
= Private
->TextInExList
[Index
]->SetState (
3533 Private
->TextInExList
[Index
],
3536 if (EFI_ERROR (Status
)) {
3547 ConSplitterTextInRegisterKeyNotify (
3548 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*This
,
3549 IN EFI_KEY_DATA
*KeyData
,
3550 IN EFI_KEY_NOTIFY_FUNCTION KeyNotificationFunction
,
3551 OUT EFI_HANDLE
*NotifyHandle
3555 Routine Description:
3556 Register a notification function for a particular keystroke for the input device.
3559 This - Protocol instance pointer.
3560 KeyData - A pointer to a buffer that is filled in with the keystroke
3561 information data for the key that was pressed.
3562 KeyNotificationFunction - Points to the function to be called when the key
3563 sequence is typed specified by KeyData.
3564 NotifyHandle - Points to the unique handle assigned to the registered notification.
3567 EFI_SUCCESS - The notification function was registered successfully.
3568 EFI_OUT_OF_RESOURCES - Unable to allocate resources for necesssary data structures.
3569 EFI_INVALID_PARAMETER - KeyData or NotifyHandle is NULL.
3573 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3576 TEXT_IN_EX_SPLITTER_NOTIFY
*NewNotify
;
3578 TEXT_IN_EX_SPLITTER_NOTIFY
*CurrentNotify
;
3581 if (KeyData
== NULL
|| NotifyHandle
== NULL
|| KeyNotificationFunction
== NULL
) {
3582 return EFI_INVALID_PARAMETER
;
3585 Private
= TEXT_IN_EX_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
3588 // if no physical console input device exists,
3589 // return EFI_SUCCESS directly.
3591 if (Private
->CurrentNumberOfExConsoles
<= 0) {
3596 // Return EFI_SUCCESS if the (KeyData, NotificationFunction) is already registered.
3598 for (Link
= Private
->NotifyList
.ForwardLink
; Link
!= &Private
->NotifyList
; Link
= Link
->ForwardLink
) {
3599 CurrentNotify
= CR (
3601 TEXT_IN_EX_SPLITTER_NOTIFY
,
3603 TEXT_IN_EX_SPLITTER_NOTIFY_SIGNATURE
3605 if (IsKeyRegistered (&CurrentNotify
->KeyData
, KeyData
)) {
3606 if (CurrentNotify
->KeyNotificationFn
== KeyNotificationFunction
) {
3607 *NotifyHandle
= CurrentNotify
->NotifyHandle
;
3614 // Allocate resource to save the notification function
3616 NewNotify
= (TEXT_IN_EX_SPLITTER_NOTIFY
*) AllocateZeroPool (sizeof (TEXT_IN_EX_SPLITTER_NOTIFY
));
3617 if (NewNotify
== NULL
) {
3618 return EFI_OUT_OF_RESOURCES
;
3620 NewNotify
->NotifyHandleList
= (EFI_HANDLE
*) AllocateZeroPool (sizeof (EFI_HANDLE
) * Private
->CurrentNumberOfExConsoles
);
3621 if (NewNotify
->NotifyHandleList
== NULL
) {
3622 gBS
->FreePool (NewNotify
);
3623 return EFI_OUT_OF_RESOURCES
;
3625 NewNotify
->Signature
= TEXT_IN_EX_SPLITTER_NOTIFY_SIGNATURE
;
3626 NewNotify
->KeyNotificationFn
= KeyNotificationFunction
;
3627 CopyMem (&NewNotify
->KeyData
, KeyData
, sizeof (KeyData
));
3630 // Return the wrong status of registering key notify of
3631 // physical console input device if meet problems
3633 for (Index
= 0; Index
< Private
->CurrentNumberOfExConsoles
; Index
++) {
3634 Status
= Private
->TextInExList
[Index
]->RegisterKeyNotify (
3635 Private
->TextInExList
[Index
],
3637 KeyNotificationFunction
,
3638 &NewNotify
->NotifyHandleList
[Index
]
3640 if (EFI_ERROR (Status
)) {
3641 gBS
->FreePool (NewNotify
->NotifyHandleList
);
3642 gBS
->FreePool (NewNotify
);
3648 // Use gSimpleTextInExNotifyGuid to get a valid EFI_HANDLE
3650 Status
= gBS
->InstallMultipleProtocolInterfaces (
3651 &NewNotify
->NotifyHandle
,
3652 &gSimpleTextInExNotifyGuid
,
3656 ASSERT_EFI_ERROR (Status
);
3658 InsertTailList (&mConIn
.NotifyList
, &NewNotify
->NotifyEntry
);
3660 *NotifyHandle
= NewNotify
->NotifyHandle
;
3668 ConSplitterTextInUnregisterKeyNotify (
3669 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*This
,
3670 IN EFI_HANDLE NotificationHandle
3674 Routine Description:
3675 Remove a registered notification function from a particular keystroke.
3678 This - Protocol instance pointer.
3679 NotificationHandle - The handle of the notification function being unregistered.
3682 EFI_SUCCESS - The notification function was unregistered successfully.
3683 EFI_INVALID_PARAMETER - The NotificationHandle is invalid.
3684 EFI_NOT_FOUND - Can not find the matching entry in database.
3688 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3691 TEXT_IN_EX_SPLITTER_NOTIFY
*CurrentNotify
;
3694 if (NotificationHandle
== NULL
) {
3695 return EFI_INVALID_PARAMETER
;
3698 Status
= gBS
->OpenProtocol (
3700 &gSimpleTextInExNotifyGuid
,
3704 EFI_OPEN_PROTOCOL_TEST_PROTOCOL
3706 if (EFI_ERROR (Status
)) {
3707 return EFI_INVALID_PARAMETER
;
3710 Private
= TEXT_IN_EX_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
3713 // if no physical console input device exists,
3714 // return EFI_SUCCESS directly.
3716 if (Private
->CurrentNumberOfExConsoles
<= 0) {
3720 for (Link
= Private
->NotifyList
.ForwardLink
; Link
!= &Private
->NotifyList
; Link
= Link
->ForwardLink
) {
3721 CurrentNotify
= CR (Link
, TEXT_IN_EX_SPLITTER_NOTIFY
, NotifyEntry
, TEXT_IN_EX_SPLITTER_NOTIFY_SIGNATURE
);
3722 if (CurrentNotify
->NotifyHandle
== NotificationHandle
) {
3723 for (Index
= 0; Index
< Private
->CurrentNumberOfExConsoles
; Index
++) {
3724 Status
= Private
->TextInExList
[Index
]->UnregisterKeyNotify (
3725 Private
->TextInExList
[Index
],
3726 CurrentNotify
->NotifyHandleList
[Index
]
3728 if (EFI_ERROR (Status
)) {
3732 RemoveEntryList (&CurrentNotify
->NotifyEntry
);
3733 Status
= gBS
->UninstallMultipleProtocolInterfaces (
3734 CurrentNotify
->NotifyHandle
,
3735 &gSimpleTextInExNotifyGuid
,
3739 ASSERT_EFI_ERROR (Status
);
3740 gBS
->FreePool (CurrentNotify
->NotifyHandleList
);
3741 gBS
->FreePool (CurrentNotify
);
3746 return EFI_NOT_FOUND
;
3752 ConSplitterSimplePointerReset (
3753 IN EFI_SIMPLE_POINTER_PROTOCOL
*This
,
3754 IN BOOLEAN ExtendedVerification
3758 Routine Description:
3759 Reset the input device and optionaly run diagnostics
3762 This - Protocol instance pointer.
3763 ExtendedVerification - Driver may perform diagnostics on reset.
3766 EFI_SUCCESS - The device was reset.
3767 EFI_DEVICE_ERROR - The device is not functioning properly and could
3773 EFI_STATUS ReturnStatus
;
3774 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3777 Private
= TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_SIMPLE_POINTER_THIS (This
);
3779 Private
->InputEventSignalState
= FALSE
;
3781 if (Private
->CurrentNumberOfPointers
== 0) {
3785 // return the worst status met
3787 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfPointers
; Index
++) {
3788 Status
= Private
->PointerList
[Index
]->Reset (
3789 Private
->PointerList
[Index
],
3790 ExtendedVerification
3792 if (EFI_ERROR (Status
)) {
3793 ReturnStatus
= Status
;
3797 return ReturnStatus
;
3803 ConSplitterSimplePointerPrivateGetState (
3804 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
3805 IN OUT EFI_SIMPLE_POINTER_STATE
*State
3809 Routine Description:
3810 Reads the next keystroke from the input device. The WaitForKey Event can
3811 be used to test for existance of a keystroke via WaitForEvent () call.
3814 This - Protocol instance pointer.
3818 EFI_SUCCESS - The keystroke information was returned.
3819 EFI_NOT_READY - There was no keystroke data availiable.
3820 EFI_DEVICE_ERROR - The keydtroke information was not returned due to
3826 EFI_STATUS ReturnStatus
;
3828 EFI_SIMPLE_POINTER_STATE CurrentState
;
3830 State
->RelativeMovementX
= 0;
3831 State
->RelativeMovementY
= 0;
3832 State
->RelativeMovementZ
= 0;
3833 State
->LeftButton
= FALSE
;
3834 State
->RightButton
= FALSE
;
3837 // if no physical console input device exists, return EFI_NOT_READY;
3838 // if any physical console input device has key input,
3839 // return the key and EFI_SUCCESS.
3841 ReturnStatus
= EFI_NOT_READY
;
3842 for (Index
= 0; Index
< Private
->CurrentNumberOfPointers
; Index
++) {
3844 Status
= Private
->PointerList
[Index
]->GetState (
3845 Private
->PointerList
[Index
],
3848 if (!EFI_ERROR (Status
)) {
3849 if (ReturnStatus
== EFI_NOT_READY
) {
3850 ReturnStatus
= EFI_SUCCESS
;
3853 if (CurrentState
.LeftButton
) {
3854 State
->LeftButton
= TRUE
;
3857 if (CurrentState
.RightButton
) {
3858 State
->RightButton
= TRUE
;
3861 if (CurrentState
.RelativeMovementX
!= 0 && Private
->PointerList
[Index
]->Mode
->ResolutionX
!= 0) {
3862 State
->RelativeMovementX
+= (CurrentState
.RelativeMovementX
* (INT32
) Private
->SimplePointerMode
.ResolutionX
) / (INT32
) Private
->PointerList
[Index
]->Mode
->ResolutionX
;
3865 if (CurrentState
.RelativeMovementY
!= 0 && Private
->PointerList
[Index
]->Mode
->ResolutionY
!= 0) {
3866 State
->RelativeMovementY
+= (CurrentState
.RelativeMovementY
* (INT32
) Private
->SimplePointerMode
.ResolutionY
) / (INT32
) Private
->PointerList
[Index
]->Mode
->ResolutionY
;
3869 if (CurrentState
.RelativeMovementZ
!= 0 && Private
->PointerList
[Index
]->Mode
->ResolutionZ
!= 0) {
3870 State
->RelativeMovementZ
+= (CurrentState
.RelativeMovementZ
* (INT32
) Private
->SimplePointerMode
.ResolutionZ
) / (INT32
) Private
->PointerList
[Index
]->Mode
->ResolutionZ
;
3872 } else if (Status
== EFI_DEVICE_ERROR
) {
3873 ReturnStatus
= EFI_DEVICE_ERROR
;
3877 return ReturnStatus
;
3882 ConSplitterSimplePointerGetState (
3883 IN EFI_SIMPLE_POINTER_PROTOCOL
*This
,
3884 IN OUT EFI_SIMPLE_POINTER_STATE
*State
3888 Routine Description:
3889 Reads the next keystroke from the input device. The WaitForKey Event can
3890 be used to test for existance of a keystroke via WaitForEvent () call.
3891 If the ConIn is password locked make it look like no keystroke is availible
3894 This - Protocol instance pointer.
3898 EFI_SUCCESS - The keystroke information was returned.
3899 EFI_NOT_READY - There was no keystroke data availiable.
3900 EFI_DEVICE_ERROR - The keydtroke information was not returned due to
3905 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3907 Private
= TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_SIMPLE_POINTER_THIS (This
);
3908 if (Private
->PasswordEnabled
) {
3910 // If StdIn Locked return not ready
3912 return EFI_NOT_READY
;
3915 Private
->InputEventSignalState
= FALSE
;
3917 return ConSplitterSimplePointerPrivateGetState (Private
, State
);
3922 ConSplitterSimplePointerWaitForInput (
3928 Routine Description:
3929 This event agregates all the events of the ConIn devices in the spliter.
3930 If the ConIn is password locked then return.
3931 If any events of physical ConIn devices are signaled, signal the ConIn
3932 spliter event. This will cause the calling code to call
3933 ConSplitterTextInReadKeyStroke ().
3936 Event - The Event assoicated with callback.
3937 Context - Context registered when Event was created.
3945 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3948 Private
= (TEXT_IN_SPLITTER_PRIVATE_DATA
*) Context
;
3949 if (Private
->PasswordEnabled
) {
3951 // If StdIn Locked return not ready
3957 // if InputEventSignalState is flagged before, and not cleared by Reset() or ReadKeyStroke()
3959 if (Private
->InputEventSignalState
) {
3960 gBS
->SignalEvent (Event
);
3964 // if any physical console input device has key input, signal the event.
3966 for (Index
= 0; Index
< Private
->CurrentNumberOfPointers
; Index
++) {
3967 Status
= gBS
->CheckEvent (Private
->PointerList
[Index
]->WaitForInput
);
3968 if (!EFI_ERROR (Status
)) {
3969 gBS
->SignalEvent (Event
);
3970 Private
->InputEventSignalState
= TRUE
;
3976 // Absolute Pointer Protocol functions
3981 ConSplitterAbsolutePointerReset (
3982 IN EFI_ABSOLUTE_POINTER_PROTOCOL
*This
,
3983 IN BOOLEAN ExtendedVerification
3987 Routine Description:
3988 Resets the pointer device hardware.
3991 This - Protocol instance pointer.
3992 ExtendedVerification - Driver may perform diagnostics on reset.
3995 EFI_SUCCESS - The device was reset.
3996 EFI_DEVICE_ERROR - The device is not functioning correctly and could
4002 EFI_STATUS ReturnStatus
;
4003 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
4006 Private
= TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_ABSOLUTE_POINTER_THIS (This
);
4008 Private
->AbsoluteInputEventSignalState
= FALSE
;
4010 if (Private
->CurrentNumberOfAbsolutePointers
== 0) {
4014 // return the worst status met
4016 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfAbsolutePointers
; Index
++) {
4017 Status
= Private
->AbsolutePointerList
[Index
]->Reset (
4018 Private
->AbsolutePointerList
[Index
],
4019 ExtendedVerification
4021 if (EFI_ERROR (Status
)) {
4022 ReturnStatus
= Status
;
4026 return ReturnStatus
;
4031 ConSplitterAbsolutePointerGetState (
4032 IN EFI_ABSOLUTE_POINTER_PROTOCOL
*This
,
4033 IN OUT EFI_ABSOLUTE_POINTER_STATE
*State
4037 Routine Description:
4038 Retrieves the current state of a pointer device.
4041 This - Protocol instance pointer.
4042 State - A pointer to the state information on the pointer device.
4045 EFI_SUCCESS - The state of the pointer device was returned in State..
4046 EFI_NOT_READY - The state of the pointer device has not changed since the last call to
4048 EFI_DEVICE_ERROR - A device error occurred while attempting to retrieve the pointer
4049 device's current state.
4052 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
4054 EFI_STATUS ReturnStatus
;
4056 EFI_ABSOLUTE_POINTER_STATE CurrentState
;
4059 Private
= TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_ABSOLUTE_POINTER_THIS (This
);
4060 if (Private
->PasswordEnabled
) {
4062 // If StdIn Locked return not ready
4064 return EFI_NOT_READY
;
4067 Private
->AbsoluteInputEventSignalState
= FALSE
;
4069 State
->CurrentX
= 0;
4070 State
->CurrentY
= 0;
4071 State
->CurrentZ
= 0;
4072 State
->ActiveButtons
= 0;
4075 // if no physical pointer device exists, return EFI_NOT_READY;
4076 // if any physical pointer device has changed state,
4077 // return the state and EFI_SUCCESS.
4079 ReturnStatus
= EFI_NOT_READY
;
4080 for (Index
= 0; Index
< Private
->CurrentNumberOfAbsolutePointers
; Index
++) {
4082 Status
= Private
->AbsolutePointerList
[Index
]->GetState (
4083 Private
->AbsolutePointerList
[Index
],
4086 if (!EFI_ERROR (Status
)) {
4087 if (ReturnStatus
== EFI_NOT_READY
) {
4088 ReturnStatus
= EFI_SUCCESS
;
4091 State
->ActiveButtons
= CurrentState
.ActiveButtons
;
4093 if (!(Private
->AbsolutePointerMode
.AbsoluteMinX
== 0 && Private
->AbsolutePointerMode
.AbsoluteMaxX
== 0)) {
4094 State
->CurrentX
= CurrentState
.CurrentX
;
4096 if (!(Private
->AbsolutePointerMode
.AbsoluteMinY
== 0 && Private
->AbsolutePointerMode
.AbsoluteMaxY
== 0)) {
4097 State
->CurrentY
= CurrentState
.CurrentY
;
4099 if (!(Private
->AbsolutePointerMode
.AbsoluteMinZ
== 0 && Private
->AbsolutePointerMode
.AbsoluteMaxZ
== 0)) {
4100 State
->CurrentZ
= CurrentState
.CurrentZ
;
4103 } else if (Status
== EFI_DEVICE_ERROR
) {
4104 ReturnStatus
= EFI_DEVICE_ERROR
;
4108 return ReturnStatus
;
4113 ConSplitterAbsolutePointerWaitForInput (
4119 Routine Description:
4120 This event agregates all the events of the pointer devices in the splitter.
4121 If the ConIn is password locked then return.
4122 If any events of physical pointer devices are signaled, signal the pointer
4123 splitter event. This will cause the calling code to call
4124 ConSplitterAbsolutePointerGetState ().
4127 Event - The Event assoicated with callback.
4128 Context - Context registered when Event was created.
4136 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
4139 Private
= (TEXT_IN_SPLITTER_PRIVATE_DATA
*) Context
;
4140 if (Private
->PasswordEnabled
) {
4142 // If StdIn Locked return not ready
4148 // if AbsoluteInputEventSignalState is flagged before,
4149 // and not cleared by Reset() or GetState(), signal it
4151 if (Private
->AbsoluteInputEventSignalState
) {
4152 gBS
->SignalEvent (Event
);
4156 // if any physical console input device has key input, signal the event.
4158 for (Index
= 0; Index
< Private
->CurrentNumberOfAbsolutePointers
; Index
++) {
4159 Status
= gBS
->CheckEvent (Private
->AbsolutePointerList
[Index
]->WaitForInput
);
4160 if (!EFI_ERROR (Status
)) {
4161 gBS
->SignalEvent (Event
);
4162 Private
->AbsoluteInputEventSignalState
= TRUE
;
4169 ConSplitterTextOutReset (
4170 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4171 IN BOOLEAN ExtendedVerification
4175 Routine Description:
4176 Reset the text output device hardware and optionaly run diagnostics
4179 This - Protocol instance pointer.
4180 ExtendedVerification - Driver may perform more exhaustive verfication
4181 operation of the device during reset.
4184 EFI_SUCCESS - The text output device was reset.
4185 EFI_DEVICE_ERROR - The text output device is not functioning correctly and
4191 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4193 EFI_STATUS ReturnStatus
;
4195 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4198 // return the worst status met
4200 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
4202 if (Private
->TextOutList
[Index
].TextOutEnabled
) {
4204 Status
= Private
->TextOutList
[Index
].TextOut
->Reset (
4205 Private
->TextOutList
[Index
].TextOut
,
4206 ExtendedVerification
4208 if (EFI_ERROR (Status
)) {
4209 ReturnStatus
= Status
;
4214 This
->SetAttribute (This
, EFI_TEXT_ATTR (This
->Mode
->Attribute
& 0x0F, EFI_BACKGROUND_BLACK
));
4216 Status
= DevNullTextOutSetMode (Private
, 0);
4217 if (EFI_ERROR (Status
)) {
4218 ReturnStatus
= Status
;
4221 return ReturnStatus
;
4226 ConSplitterTextOutOutputString (
4227 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4232 Routine Description:
4233 Write a Unicode string to the output device.
4236 This - Protocol instance pointer.
4237 String - The NULL-terminated Unicode string to be displayed on the output
4238 device(s). All output devices must also support the Unicode
4239 drawing defined in this file.
4242 EFI_SUCCESS - The string was output to the device.
4243 EFI_DEVICE_ERROR - The device reported an error while attempting to output
4245 EFI_UNSUPPORTED - The output device's mode is not currently in a
4247 EFI_WARN_UNKNOWN_GLYPH - This warning code indicates that some of the
4248 characters in the Unicode string could not be
4249 rendered and were skipped.
4254 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4256 UINTN BackSpaceCount
;
4257 EFI_STATUS ReturnStatus
;
4258 CHAR16
*TargetString
;
4260 This
->SetAttribute (This
, This
->Mode
->Attribute
);
4262 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4265 for (TargetString
= WString
; *TargetString
; TargetString
++) {
4266 if (*TargetString
== CHAR_BACKSPACE
) {
4272 if (BackSpaceCount
== 0) {
4273 TargetString
= WString
;
4275 TargetString
= AllocatePool (sizeof (CHAR16
) * (StrLen (WString
) + BackSpaceCount
+ 1));
4276 StrCpy (TargetString
, WString
);
4279 // return the worst status met
4281 Status
= DevNullTextOutOutputString (Private
, TargetString
);
4282 if (EFI_ERROR (Status
)) {
4283 ReturnStatus
= Status
;
4286 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
4288 if (Private
->TextOutList
[Index
].TextOutEnabled
) {
4289 Status
= Private
->TextOutList
[Index
].TextOut
->OutputString (
4290 Private
->TextOutList
[Index
].TextOut
,
4293 if (EFI_ERROR (Status
)) {
4294 ReturnStatus
= Status
;
4299 if (BackSpaceCount
) {
4300 FreePool (TargetString
);
4303 return ReturnStatus
;
4308 ConSplitterTextOutTestString (
4309 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4314 Routine Description:
4315 Verifies that all characters in a Unicode string can be output to the
4319 This - Protocol instance pointer.
4320 String - The NULL-terminated Unicode string to be examined for the output
4324 EFI_SUCCESS - The device(s) are capable of rendering the output string.
4325 EFI_UNSUPPORTED - Some of the characters in the Unicode string cannot be
4326 rendered by one or more of the output devices mapped
4332 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4334 EFI_STATUS ReturnStatus
;
4336 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4339 // return the worst status met
4341 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
4342 if (Private
->TextOutList
[Index
].TextOutEnabled
) {
4343 Status
= Private
->TextOutList
[Index
].TextOut
->TestString (
4344 Private
->TextOutList
[Index
].TextOut
,
4347 if (EFI_ERROR (Status
)) {
4348 ReturnStatus
= Status
;
4353 // There is no DevNullTextOutTestString () since a Unicode buffer would
4354 // always return EFI_SUCCESS.
4355 // ReturnStatus will be EFI_SUCCESS if no consoles are present
4357 return ReturnStatus
;
4362 ConSplitterTextOutQueryMode (
4363 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4364 IN UINTN ModeNumber
,
4370 Routine Description:
4371 Returns information for an available text mode that the output device(s)
4375 This - Protocol instance pointer.
4376 ModeNumber - The mode number to return information on.
4377 Columns, Rows - Returns the geometry of the text output device for the
4378 requested ModeNumber.
4381 EFI_SUCCESS - The requested mode information was returned.
4382 EFI_DEVICE_ERROR - The device had an error and could not
4383 complete the request.
4384 EFI_UNSUPPORTED - The mode number was not valid.
4388 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4390 INT32
*TextOutModeMap
;
4392 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4395 // Check whether param ModeNumber is valid.
4396 // ModeNumber should be within range 0 ~ MaxMode - 1.
4398 if ( (ModeNumber
> (UINTN
)(((UINT32
)-1)>>1)) ) {
4399 return EFI_UNSUPPORTED
;
4402 if ((INT32
) ModeNumber
>= This
->Mode
->MaxMode
) {
4403 return EFI_UNSUPPORTED
;
4407 // We get the available mode from mode intersection map if it's available
4409 if (Private
->TextOutModeMap
!= NULL
) {
4410 TextOutModeMap
= Private
->TextOutModeMap
+ Private
->TextOutListCount
* ModeNumber
;
4411 CurrentMode
= (UINTN
)(*TextOutModeMap
);
4412 *Columns
= Private
->TextOutQueryData
[CurrentMode
].Columns
;
4413 *Rows
= Private
->TextOutQueryData
[CurrentMode
].Rows
;
4415 *Columns
= Private
->TextOutQueryData
[ModeNumber
].Columns
;
4416 *Rows
= Private
->TextOutQueryData
[ModeNumber
].Rows
;
4419 if (*Columns
<= 0 && *Rows
<= 0) {
4420 return EFI_UNSUPPORTED
;
4429 ConSplitterTextOutSetMode (
4430 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4435 Routine Description:
4436 Sets the output device(s) to a specified mode.
4439 This - Protocol instance pointer.
4440 ModeNumber - The mode number to set.
4443 EFI_SUCCESS - The requested text mode was set.
4444 EFI_DEVICE_ERROR - The device had an error and
4445 could not complete the request.
4446 EFI_UNSUPPORTED - The mode number was not valid.
4451 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4453 INT32
*TextOutModeMap
;
4454 EFI_STATUS ReturnStatus
;
4456 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4459 // Check whether param ModeNumber is valid.
4460 // ModeNumber should be within range 0 ~ MaxMode - 1.
4462 if ( (ModeNumber
> (UINTN
)(((UINT32
)-1)>>1)) ) {
4463 return EFI_UNSUPPORTED
;
4466 if ((INT32
) ModeNumber
>= This
->Mode
->MaxMode
) {
4467 return EFI_UNSUPPORTED
;
4470 // If the mode is being set to the curent mode, then just clear the screen and return.
4472 if (Private
->TextOutMode
.Mode
== (INT32
) ModeNumber
) {
4473 return ConSplitterTextOutClearScreen (This
);
4476 // return the worst status met
4478 TextOutModeMap
= Private
->TextOutModeMap
+ Private
->TextOutListCount
* ModeNumber
;
4479 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
4481 if (Private
->TextOutList
[Index
].TextOutEnabled
) {
4482 Status
= Private
->TextOutList
[Index
].TextOut
->SetMode (
4483 Private
->TextOutList
[Index
].TextOut
,
4484 TextOutModeMap
[Index
]
4487 // If this console device is based on a GOP or UGA device, then sync up the bitmap from
4488 // the GOP/UGA splitter and reclear the text portion of the display in the new mode.
4490 if ((Private
->TextOutList
[Index
].GraphicsOutput
!= NULL
) || (Private
->TextOutList
[Index
].UgaDraw
!= NULL
)) {
4491 Private
->TextOutList
[Index
].TextOut
->ClearScreen (Private
->TextOutList
[Index
].TextOut
);
4494 if (EFI_ERROR (Status
)) {
4495 ReturnStatus
= Status
;
4500 // The DevNull Console will support any possible mode as it allocates memory
4502 Status
= DevNullTextOutSetMode (Private
, ModeNumber
);
4503 if (EFI_ERROR (Status
)) {
4504 ReturnStatus
= Status
;
4507 return ReturnStatus
;
4512 ConSplitterTextOutSetAttribute (
4513 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4518 Routine Description:
4519 Sets the background and foreground colors for the OutputString () and
4520 ClearScreen () functions.
4523 This - Protocol instance pointer.
4524 Attribute - The attribute to set. Bits 0..3 are the foreground color, and
4525 bits 4..6 are the background color. All other bits are undefined
4526 and must be zero. The valid Attributes are defined in this file.
4529 EFI_SUCCESS - The attribute was set.
4530 EFI_DEVICE_ERROR - The device had an error and
4531 could not complete the request.
4532 EFI_UNSUPPORTED - The attribute requested is not defined.
4537 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4539 EFI_STATUS ReturnStatus
;
4541 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4544 // Check whether param Attribute is valid.
4546 if ( (Attribute
> (UINTN
)(((UINT32
)-1)>>1)) ) {
4547 return EFI_UNSUPPORTED
;
4551 // return the worst status met
4553 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
4555 if (Private
->TextOutList
[Index
].TextOutEnabled
) {
4556 Status
= Private
->TextOutList
[Index
].TextOut
->SetAttribute (
4557 Private
->TextOutList
[Index
].TextOut
,
4560 if (EFI_ERROR (Status
)) {
4561 ReturnStatus
= Status
;
4566 Private
->TextOutMode
.Attribute
= (INT32
) Attribute
;
4568 return ReturnStatus
;
4573 ConSplitterTextOutClearScreen (
4574 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
4578 Routine Description:
4579 Clears the output device(s) display to the currently selected background
4583 This - Protocol instance pointer.
4586 EFI_SUCCESS - The operation completed successfully.
4587 EFI_DEVICE_ERROR - The device had an error and
4588 could not complete the request.
4589 EFI_UNSUPPORTED - The output device is not in a valid text mode.
4594 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4596 EFI_STATUS ReturnStatus
;
4598 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4601 // return the worst status met
4603 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
4605 if (Private
->TextOutList
[Index
].TextOutEnabled
) {
4606 Status
= Private
->TextOutList
[Index
].TextOut
->ClearScreen (Private
->TextOutList
[Index
].TextOut
);
4607 if (EFI_ERROR (Status
)) {
4608 ReturnStatus
= Status
;
4613 Status
= DevNullTextOutClearScreen (Private
);
4614 if (EFI_ERROR (Status
)) {
4615 ReturnStatus
= Status
;
4618 return ReturnStatus
;
4623 ConSplitterTextOutSetCursorPosition (
4624 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4630 Routine Description:
4631 Sets the current coordinates of the cursor position
4634 This - Protocol instance pointer.
4635 Column, Row - the position to set the cursor to. Must be greater than or
4636 equal to zero and less than the number of columns and rows
4640 EFI_SUCCESS - The operation completed successfully.
4641 EFI_DEVICE_ERROR - The device had an error and
4642 could not complete the request.
4643 EFI_UNSUPPORTED - The output device is not in a valid text mode, or the
4644 cursor position is invalid for the current mode.
4649 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4651 EFI_STATUS ReturnStatus
;
4654 INT32
*TextOutModeMap
;
4658 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4659 TextOutModeMap
= NULL
;
4660 ModeNumber
= Private
->TextOutMode
.Mode
;
4663 // Get current MaxColumn and MaxRow from intersection map
4665 if (Private
->TextOutModeMap
!= NULL
) {
4666 TextOutModeMap
= Private
->TextOutModeMap
+ Private
->TextOutListCount
* ModeNumber
;
4667 CurrentMode
= *TextOutModeMap
;
4669 CurrentMode
= ModeNumber
;
4672 MaxColumn
= Private
->TextOutQueryData
[CurrentMode
].Columns
;
4673 MaxRow
= Private
->TextOutQueryData
[CurrentMode
].Rows
;
4675 if (Column
>= MaxColumn
|| Row
>= MaxRow
) {
4676 return EFI_UNSUPPORTED
;
4679 // return the worst status met
4681 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
4683 if (Private
->TextOutList
[Index
].TextOutEnabled
) {
4684 Status
= Private
->TextOutList
[Index
].TextOut
->SetCursorPosition (
4685 Private
->TextOutList
[Index
].TextOut
,
4689 if (EFI_ERROR (Status
)) {
4690 ReturnStatus
= Status
;
4695 DevNullTextOutSetCursorPosition (Private
, Column
, Row
);
4697 return ReturnStatus
;
4702 ConSplitterTextOutEnableCursor (
4703 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4708 Routine Description:
4709 Makes the cursor visible or invisible
4712 This - Protocol instance pointer.
4713 Visible - If TRUE, the cursor is set to be visible. If FALSE, the cursor is
4714 set to be invisible.
4717 EFI_SUCCESS - The operation completed successfully.
4718 EFI_DEVICE_ERROR - The device had an error and could not complete the
4719 request, or the device does not support changing
4721 EFI_UNSUPPORTED - The output device is not in a valid text mode.
4726 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4728 EFI_STATUS ReturnStatus
;
4730 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4733 // return the worst status met
4735 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
4737 if (Private
->TextOutList
[Index
].TextOutEnabled
) {
4738 Status
= Private
->TextOutList
[Index
].TextOut
->EnableCursor (
4739 Private
->TextOutList
[Index
].TextOut
,
4742 if (EFI_ERROR (Status
)) {
4743 ReturnStatus
= Status
;
4748 DevNullTextOutEnableCursor (Private
, Visible
);
4750 return ReturnStatus
;