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
;
2246 TEXT_OUT_SPLITTER_QUERY_DATA
*TextOutQueryData
;
2252 // Must make sure that current mode won't change even if mode number changes
2254 CurrentMaxMode
= Private
->TextOutMode
.MaxMode
;
2255 TextOutModeMap
= Private
->TextOutModeMap
;
2256 StepSize
= Private
->TextOutListCount
;
2257 TextOutQueryData
= Private
->TextOutQueryData
;
2260 // Query all the mode that the newly added TextOut supports
2263 MapTable
= TextOutModeMap
+ Private
->CurrentNumberOfConsoles
;
2264 while (Mode
< TextOut
->Mode
->MaxMode
) {
2265 TextOut
->QueryMode (TextOut
, Mode
, &Columns
, &Rows
);
2268 // Search the QueryData database to see if they intersects
2271 while (Index
< CurrentMaxMode
) {
2272 if ((TextOutQueryData
[Index
].Rows
== Rows
) && (TextOutQueryData
[Index
].Columns
== Columns
)) {
2273 MapTable
[Index
* StepSize
] = Mode
;
2283 // Now search the TextOutModeMap table to find the intersection of supported
2284 // mode between ConSplitter and the newly added device.
2286 ConSplitterGetIntersection (
2291 &Private
->TextOutMode
.MaxMode
,
2292 &Private
->TextOutMode
.Mode
2300 ConSplitterGetIntersectionBetweenConOutAndStrErr (
2305 Routine Description:
2312 EFI_OUT_OF_RESOURCES
2316 UINTN ConOutNumOfConsoles
;
2317 UINTN StdErrNumOfConsoles
;
2318 TEXT_OUT_AND_GOP_DATA
*ConOutTextOutList
;
2319 TEXT_OUT_AND_GOP_DATA
*StdErrTextOutList
;
2324 INT32 ConOutMaxMode
;
2325 INT32 StdErrMaxMode
;
2328 INT32
*ConOutModeMap
;
2329 INT32
*StdErrModeMap
;
2330 INT32
*ConOutMapTable
;
2331 INT32
*StdErrMapTable
;
2332 TEXT_OUT_SPLITTER_QUERY_DATA
*ConOutQueryData
;
2333 TEXT_OUT_SPLITTER_QUERY_DATA
*StdErrQueryData
;
2334 BOOLEAN FoundTheSameTextOut
;
2335 UINTN ConOutMapTableSize
;
2336 UINTN StdErrMapTableSize
;
2338 ConOutNumOfConsoles
= mConOut
.CurrentNumberOfConsoles
;
2339 StdErrNumOfConsoles
= mStdErr
.CurrentNumberOfConsoles
;
2340 ConOutTextOutList
= mConOut
.TextOutList
;
2341 StdErrTextOutList
= mStdErr
.TextOutList
;
2344 FoundTheSameTextOut
= FALSE
;
2345 while ((Indexi
< ConOutNumOfConsoles
) && (!FoundTheSameTextOut
)) {
2347 while (Indexj
< StdErrNumOfConsoles
) {
2348 if (ConOutTextOutList
->TextOut
== StdErrTextOutList
->TextOut
) {
2349 FoundTheSameTextOut
= TRUE
;
2354 StdErrTextOutList
++;
2358 ConOutTextOutList
++;
2361 if (!FoundTheSameTextOut
) {
2365 // Must make sure that current mode won't change even if mode number changes
2367 ConOutMaxMode
= mConOut
.TextOutMode
.MaxMode
;
2368 ConOutModeMap
= mConOut
.TextOutModeMap
;
2369 ConOutQueryData
= mConOut
.TextOutQueryData
;
2371 StdErrMaxMode
= mStdErr
.TextOutMode
.MaxMode
;
2372 StdErrModeMap
= mStdErr
.TextOutModeMap
;
2373 StdErrQueryData
= mStdErr
.TextOutQueryData
;
2376 // Allocate the map table and set the map table's index to -1.
2378 ConOutMapTableSize
= ConOutMaxMode
* sizeof (INT32
);
2379 ConOutMapTable
= AllocateZeroPool (ConOutMapTableSize
);
2380 if (ConOutMapTable
== NULL
) {
2381 return EFI_OUT_OF_RESOURCES
;
2384 SetMem (ConOutMapTable
, ConOutMapTableSize
, 0xFF);
2386 StdErrMapTableSize
= StdErrMaxMode
* sizeof (INT32
);
2387 StdErrMapTable
= AllocateZeroPool (StdErrMapTableSize
);
2388 if (StdErrMapTable
== NULL
) {
2389 return EFI_OUT_OF_RESOURCES
;
2392 SetMem (StdErrMapTable
, StdErrMapTableSize
, 0xFF);
2395 // Find the intersection of the two set of modes. If they actually intersect, the
2396 // correponding entry in the map table is set to 1.
2399 while (Mode
< ConOutMaxMode
) {
2401 // Search the other's QueryData database to see if they intersect
2404 Rows
= ConOutQueryData
[Mode
].Rows
;
2405 Columns
= ConOutQueryData
[Mode
].Columns
;
2406 while (Index
< StdErrMaxMode
) {
2407 if ((StdErrQueryData
[Index
].Rows
== Rows
) && (StdErrQueryData
[Index
].Columns
== Columns
)) {
2408 ConOutMapTable
[Mode
] = 1;
2409 StdErrMapTable
[Index
] = 1;
2419 // Now search the TextOutModeMap table to find the intersection of supported
2420 // mode between ConSplitter and the newly added device.
2422 ConSplitterGetIntersection (
2425 mConOut
.TextOutListCount
,
2427 &(mConOut
.TextOutMode
.MaxMode
),
2428 &(mConOut
.TextOutMode
.Mode
)
2430 if (mConOut
.TextOutMode
.Mode
< 0) {
2431 mConOut
.TextOut
.SetMode (&(mConOut
.TextOut
), 0);
2434 ConSplitterGetIntersection (
2437 mStdErr
.TextOutListCount
,
2439 &(mStdErr
.TextOutMode
.MaxMode
),
2440 &(mStdErr
.TextOutMode
.Mode
)
2442 if (mStdErr
.TextOutMode
.Mode
< 0) {
2443 mStdErr
.TextOut
.SetMode (&(mStdErr
.TextOut
), 0);
2446 FreePool (ConOutMapTable
);
2447 FreePool (StdErrMapTable
);
2454 ConSplitterAddGraphicsOutputMode (
2455 IN TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
,
2456 IN EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
,
2457 IN EFI_UGA_DRAW_PROTOCOL
*UgaDraw
2461 Routine Description:
2473 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*Mode
;
2475 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*Info
;
2476 EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE
*CurrentGraphicsOutputMode
;
2477 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*ModeBuffer
;
2478 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*MatchedMode
;
2481 BOOLEAN AlreadyExist
;
2483 if ((GraphicsOutput
== NULL
) && (UgaDraw
== NULL
)) {
2484 return EFI_UNSUPPORTED
;
2487 CurrentGraphicsOutputMode
= Private
->GraphicsOutput
.Mode
;
2491 if (Private
->CurrentNumberOfUgaDraw
!= 0) {
2493 // If any UGA device has already been added, then there is no need to
2494 // calculate intersection of display mode of different GOP/UGA device,
2495 // since only one display mode will be exported (i.e. user-defined mode)
2500 if (GraphicsOutput
!= NULL
) {
2501 if (Private
->CurrentNumberOfGraphicsOutput
== 0) {
2503 // This is the first Graphics Output device added
2505 CurrentGraphicsOutputMode
->MaxMode
= GraphicsOutput
->Mode
->MaxMode
;
2506 CurrentGraphicsOutputMode
->Mode
= GraphicsOutput
->Mode
->Mode
;
2507 CopyMem (CurrentGraphicsOutputMode
->Info
, GraphicsOutput
->Mode
->Info
, GraphicsOutput
->Mode
->SizeOfInfo
);
2508 CurrentGraphicsOutputMode
->SizeOfInfo
= GraphicsOutput
->Mode
->SizeOfInfo
;
2509 CurrentGraphicsOutputMode
->FrameBufferBase
= GraphicsOutput
->Mode
->FrameBufferBase
;
2510 CurrentGraphicsOutputMode
->FrameBufferSize
= GraphicsOutput
->Mode
->FrameBufferSize
;
2513 // Allocate resource for the private mode buffer
2515 ModeBuffer
= AllocatePool (GraphicsOutput
->Mode
->SizeOfInfo
* GraphicsOutput
->Mode
->MaxMode
);
2516 if (ModeBuffer
== NULL
) {
2517 return EFI_OUT_OF_RESOURCES
;
2519 FreePool (Private
->GraphicsOutputModeBuffer
);
2520 Private
->GraphicsOutputModeBuffer
= ModeBuffer
;
2523 // Store all supported display modes to the private mode buffer
2526 for (Index
= 0; Index
< GraphicsOutput
->Mode
->MaxMode
; Index
++) {
2527 Status
= GraphicsOutput
->QueryMode (GraphicsOutput
, (UINT32
) Index
, &SizeOfInfo
, &Info
);
2528 if (EFI_ERROR (Status
)) {
2531 CopyMem (Mode
, Info
, SizeOfInfo
);
2537 // Check intersection of display mode
2539 ModeBuffer
= AllocatePool (sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
) * CurrentGraphicsOutputMode
->MaxMode
);
2540 if (ModeBuffer
== NULL
) {
2541 return EFI_OUT_OF_RESOURCES
;
2544 MatchedMode
= ModeBuffer
;
2545 Mode
= &Private
->GraphicsOutputModeBuffer
[0];
2546 for (Index
= 0; Index
< CurrentGraphicsOutputMode
->MaxMode
; Index
++) {
2549 for (NumberIndex
= 0; NumberIndex
< GraphicsOutput
->Mode
->MaxMode
; NumberIndex
++) {
2550 Status
= GraphicsOutput
->QueryMode (GraphicsOutput
, (UINT32
) NumberIndex
, &SizeOfInfo
, &Info
);
2551 if (EFI_ERROR (Status
)) {
2554 if ((Info
->HorizontalResolution
== Mode
->HorizontalResolution
) &&
2555 (Info
->VerticalResolution
== Mode
->VerticalResolution
)) {
2564 AlreadyExist
= FALSE
;
2566 for (Info
= ModeBuffer
; Info
< MatchedMode
; Info
++) {
2567 if ((Info
->HorizontalResolution
== Mode
->HorizontalResolution
) &&
2568 (Info
->VerticalResolution
== Mode
->VerticalResolution
)) {
2569 AlreadyExist
= TRUE
;
2574 if (!AlreadyExist
) {
2575 CopyMem (MatchedMode
, Mode
, sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
));
2578 // Physical frame buffer is no longer available, change PixelFormat to PixelBltOnly
2580 MatchedMode
->Version
= 0;
2581 MatchedMode
->PixelFormat
= PixelBltOnly
;
2582 ZeroMem (&MatchedMode
->PixelInformation
, sizeof (EFI_PIXEL_BITMASK
));
2592 // Drop the old mode buffer, assign it to a new one
2594 FreePool (Private
->GraphicsOutputModeBuffer
);
2595 Private
->GraphicsOutputModeBuffer
= ModeBuffer
;
2598 // Physical frame buffer is no longer available when there are more than one physical GOP devices
2600 CurrentGraphicsOutputMode
->MaxMode
= (UINT32
) (((UINTN
) MatchedMode
- (UINTN
) ModeBuffer
) / sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
));
2601 CurrentGraphicsOutputMode
->Info
->PixelFormat
= PixelBltOnly
;
2602 ZeroMem (&CurrentGraphicsOutputMode
->Info
->PixelInformation
, sizeof (EFI_PIXEL_BITMASK
));
2603 CurrentGraphicsOutputMode
->SizeOfInfo
= sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
);
2604 CurrentGraphicsOutputMode
->FrameBufferBase
= (EFI_PHYSICAL_ADDRESS
) NULL
;
2605 CurrentGraphicsOutputMode
->FrameBufferSize
= 0;
2609 // Select a prefered Display mode 800x600
2611 for (Index
= 0; Index
< CurrentGraphicsOutputMode
->MaxMode
; Index
++) {
2612 Mode
= &Private
->GraphicsOutputModeBuffer
[Index
];
2613 if ((Mode
->HorizontalResolution
== 800) && (Mode
->VerticalResolution
== 600)) {
2618 // Prefered mode is not found, set to mode 0
2620 if (Index
>= CurrentGraphicsOutputMode
->MaxMode
) {
2625 if (UgaDraw
!= NULL
) {
2627 // For UGA device, it's inconvenient to retrieve all the supported display modes.
2628 // To simplify the implementation, only add one resolution(800x600, 32bit color depth) as defined in UEFI spec
2630 CurrentGraphicsOutputMode
->MaxMode
= 1;
2631 Info
= CurrentGraphicsOutputMode
->Info
;
2633 Info
->HorizontalResolution
= 800;
2634 Info
->VerticalResolution
= 600;
2635 Info
->PixelFormat
= PixelBltOnly
;
2636 Info
->PixelsPerScanLine
= 800;
2637 CurrentGraphicsOutputMode
->SizeOfInfo
= sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
);
2638 CurrentGraphicsOutputMode
->FrameBufferBase
= (EFI_PHYSICAL_ADDRESS
) NULL
;
2639 CurrentGraphicsOutputMode
->FrameBufferSize
= 0;
2642 // Update the private mode buffer
2644 CopyMem (&Private
->GraphicsOutputModeBuffer
[0], Info
, sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
));
2647 // Only mode 0 is available to be set
2654 if (GraphicsOutput
!= NULL
) {
2655 Private
->CurrentNumberOfGraphicsOutput
++;
2657 if (UgaDraw
!= NULL
) {
2658 Private
->CurrentNumberOfUgaDraw
++;
2662 // Force GraphicsOutput mode to be set,
2663 // regardless whether the console is in EfiConsoleControlScreenGraphics or EfiConsoleControlScreenText mode
2665 Private
->HardwareNeedsStarting
= TRUE
;
2667 // Current mode number may need update now, so set it to an invalid mode number
2669 Status
= Private
->GraphicsOutput
.SetMode (&Private
->GraphicsOutput
, (UINT32
) Index
);
2675 ConSplitterTextOutAddDevice (
2676 IN TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
,
2677 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
,
2678 IN EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
,
2679 IN EFI_UGA_DRAW_PROTOCOL
*UgaDraw
2683 Routine Description:
2694 UINTN CurrentNumOfConsoles
;
2697 TEXT_OUT_AND_GOP_DATA
*TextAndGop
;
2699 Status
= EFI_SUCCESS
;
2700 CurrentNumOfConsoles
= Private
->CurrentNumberOfConsoles
;
2703 // If the Text Out List is full, enlarge it by calling growbuffer().
2705 while (CurrentNumOfConsoles
>= Private
->TextOutListCount
) {
2706 Status
= ConSplitterGrowBuffer (
2707 sizeof (TEXT_OUT_AND_GOP_DATA
),
2708 &Private
->TextOutListCount
,
2709 (VOID
**) &Private
->TextOutList
2711 if (EFI_ERROR (Status
)) {
2712 return EFI_OUT_OF_RESOURCES
;
2715 // Also need to reallocate the TextOutModeMap table
2717 Status
= ConSplitterGrowMapTable (Private
);
2718 if (EFI_ERROR (Status
)) {
2719 return EFI_OUT_OF_RESOURCES
;
2723 TextAndGop
= &Private
->TextOutList
[CurrentNumOfConsoles
];
2725 TextAndGop
->TextOut
= TextOut
;
2726 TextAndGop
->GraphicsOutput
= GraphicsOutput
;
2727 TextAndGop
->UgaDraw
= UgaDraw
;
2729 if ((GraphicsOutput
== NULL
) && (UgaDraw
== NULL
)) {
2731 // If No UGA device then use the ConOut device
2733 TextAndGop
->TextOutEnabled
= TRUE
;
2736 // If UGA device use ConOut device only used if UGA screen is in Text mode
2738 TextAndGop
->TextOutEnabled
= (BOOLEAN
) (Private
->ConsoleOutputMode
== EfiConsoleControlScreenText
);
2741 if (CurrentNumOfConsoles
== 0) {
2743 // Add the first device's output mode to console splitter's mode list
2745 Status
= ConSplitterAddOutputMode (Private
, TextOut
);
2747 ConSplitterSyncOutputMode (Private
, TextOut
);
2750 Private
->CurrentNumberOfConsoles
++;
2753 // Scan both TextOutList, for the intersection TextOut device
2754 // maybe both ConOut and StdErr incorporate the same Text Out
2755 // device in them, thus the output of both should be synced.
2757 ConSplitterGetIntersectionBetweenConOutAndStrErr ();
2759 CurrentMode
= Private
->TextOutMode
.Mode
;
2760 MaxMode
= Private
->TextOutMode
.MaxMode
;
2761 ASSERT (MaxMode
>= 1);
2763 if (FeaturePcdGet (PcdConOutGopSupport
)) {
2764 if ((GraphicsOutput
!= NULL
) || (UgaDraw
!= NULL
)) {
2765 ConSplitterAddGraphicsOutputMode (Private
, GraphicsOutput
, UgaDraw
);
2769 if (Private
->ConsoleOutputMode
== EfiConsoleControlScreenGraphics
&& GraphicsOutput
!= NULL
) {
2771 // We just added a new UGA device in graphics mode
2773 if (FeaturePcdGet (PcdConOutGopSupport
)) {
2774 DevNullGopSync (Private
, TextAndGop
->GraphicsOutput
, TextAndGop
->UgaDraw
);
2775 } else if (FeaturePcdGet (PcdConOutUgaSupport
)) {
2776 DevNullUgaSync (Private
, TextAndGop
->GraphicsOutput
, TextAndGop
->UgaDraw
);
2778 } else if ((CurrentMode
>= 0) && ((GraphicsOutput
!= NULL
) || (UgaDraw
!= NULL
)) && (CurrentMode
< Private
->TextOutMode
.MaxMode
)) {
2780 // The new console supports the same mode of the current console so sync up
2782 DevNullSyncStdOut (Private
);
2785 // If ConOut, then set the mode to Mode #0 which us 80 x 25
2787 Private
->TextOut
.SetMode (&Private
->TextOut
, 0);
2794 ConSplitterTextOutDeleteDevice (
2795 IN TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
,
2796 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
2800 Routine Description:
2811 UINTN CurrentNumOfConsoles
;
2812 TEXT_OUT_AND_GOP_DATA
*TextOutList
;
2816 // Remove the specified text-out device data structure from the Text out List,
2817 // and rearrange the remaining data structures in the Text out List.
2819 CurrentNumOfConsoles
= Private
->CurrentNumberOfConsoles
;
2820 Index
= (INT32
) CurrentNumOfConsoles
- 1;
2821 TextOutList
= Private
->TextOutList
;
2822 while (Index
>= 0) {
2823 if (TextOutList
->TextOut
== TextOut
) {
2824 CopyMem (TextOutList
, TextOutList
+ 1, sizeof (TEXT_OUT_AND_GOP_DATA
) * Index
);
2825 CurrentNumOfConsoles
--;
2826 if (FeaturePcdGet (PcdConOutGopSupport
)) {
2827 if (TextOutList
->UgaDraw
!= NULL
) {
2828 Private
->CurrentNumberOfUgaDraw
--;
2830 if (TextOutList
->GraphicsOutput
!= NULL
) {
2831 Private
->CurrentNumberOfGraphicsOutput
--;
2841 // The specified TextOut is not managed by the ConSplitter driver
2844 return EFI_NOT_FOUND
;
2847 if (CurrentNumOfConsoles
== 0) {
2849 // If the number of consoles is zero clear the Dev NULL device
2851 Private
->CurrentNumberOfConsoles
= 0;
2852 Private
->TextOutMode
.MaxMode
= 1;
2853 Private
->TextOutQueryData
[0].Columns
= 80;
2854 Private
->TextOutQueryData
[0].Rows
= 25;
2855 DevNullTextOutSetMode (Private
, 0);
2860 // Max Mode is realy an intersection of the QueryMode command to all
2861 // devices. So we must copy the QueryMode of the first device to
2865 Private
->TextOutQueryData
,
2866 Private
->TextOutQueryDataCount
* sizeof (TEXT_OUT_SPLITTER_QUERY_DATA
)
2869 FreePool (Private
->TextOutModeMap
);
2870 Private
->TextOutModeMap
= NULL
;
2871 TextOutList
= Private
->TextOutList
;
2874 // Add the first TextOut to the QueryData array and ModeMap table
2876 Status
= ConSplitterAddOutputMode (Private
, TextOutList
->TextOut
);
2879 // Now add one by one
2882 Private
->CurrentNumberOfConsoles
= 1;
2884 while ((UINTN
) Index
< CurrentNumOfConsoles
) {
2885 ConSplitterSyncOutputMode (Private
, TextOutList
->TextOut
);
2887 Private
->CurrentNumberOfConsoles
++;
2891 ConSplitterGetIntersectionBetweenConOutAndStrErr ();
2896 // ConSplitter TextIn member functions
2900 ConSplitterTextInReset (
2901 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*This
,
2902 IN BOOLEAN ExtendedVerification
2906 Routine Description:
2907 Reset the input device and optionaly run diagnostics
2910 This - Protocol instance pointer.
2911 ExtendedVerification - Driver may perform diagnostics on reset.
2914 EFI_SUCCESS - The device was reset.
2915 EFI_DEVICE_ERROR - The device is not functioning properly and could
2921 EFI_STATUS ReturnStatus
;
2922 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
2925 Private
= TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
2927 Private
->KeyEventSignalState
= FALSE
;
2930 // return the worst status met
2932 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
2933 Status
= Private
->TextInList
[Index
]->Reset (
2934 Private
->TextInList
[Index
],
2935 ExtendedVerification
2937 if (EFI_ERROR (Status
)) {
2938 ReturnStatus
= Status
;
2942 return ReturnStatus
;
2947 ConSplitterTextInPrivateReadKeyStroke (
2948 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
2949 OUT EFI_INPUT_KEY
*Key
2953 Routine Description:
2954 Reads the next keystroke from the input device. The WaitForKey Event can
2955 be used to test for existance of a keystroke via WaitForEvent () call.
2958 This - Protocol instance pointer.
2959 Key - Driver may perform diagnostics on reset.
2962 EFI_SUCCESS - The keystroke information was returned.
2963 EFI_NOT_READY - There was no keystroke data availiable.
2964 EFI_DEVICE_ERROR - The keydtroke information was not returned due to
2971 EFI_INPUT_KEY CurrentKey
;
2973 Key
->UnicodeChar
= 0;
2974 Key
->ScanCode
= SCAN_NULL
;
2977 // if no physical console input device exists, return EFI_NOT_READY;
2978 // if any physical console input device has key input,
2979 // return the key and EFI_SUCCESS.
2981 for (Index
= 0; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
2982 Status
= Private
->TextInList
[Index
]->ReadKeyStroke (
2983 Private
->TextInList
[Index
],
2986 if (!EFI_ERROR (Status
)) {
2992 return EFI_NOT_READY
;
2996 ConSpliterConssoleControlStdInLocked (
3001 Routine Description:
3002 Return TRUE if StdIn is locked. The ConIn device on the virtual handle is
3003 the only device locked.
3010 FALSE - StdIn working normally
3014 return mConIn
.PasswordEnabled
;
3019 ConSpliterConsoleControlLockStdInEvent (
3025 Routine Description:
3026 This timer event will fire when StdIn is locked. It will check the key
3027 sequence on StdIn to see if it matches the password. Any error in the
3028 password will cause the check to reset. As long a mConIn.PasswordEnabled is
3029 TRUE the StdIn splitter will not report any input.
3032 (Standard EFI_EVENT_NOTIFY)
3041 CHAR16 BackSpaceString
[2];
3042 CHAR16 SpaceString
[2];
3045 Status
= ConSplitterTextInPrivateReadKeyStroke (&mConIn
, &Key
);
3046 if (!EFI_ERROR (Status
)) {
3048 // if it's an ENTER, match password
3050 if ((Key
.UnicodeChar
== CHAR_CARRIAGE_RETURN
) && (Key
.ScanCode
== SCAN_NULL
)) {
3051 mConIn
.PwdAttempt
[mConIn
.PwdIndex
] = CHAR_NULL
;
3052 if (StrCmp (mConIn
.Password
, mConIn
.PwdAttempt
)) {
3054 // Password not match
3056 ConSplitterTextOutOutputString (&mConOut
.TextOut
, (CHAR16
*) L
"\n\rPassword not correct\n\r");
3057 mConIn
.PwdIndex
= 0;
3060 // Key matches password sequence
3062 gBS
->SetTimer (mConIn
.LockEvent
, TimerPeriodic
, 0);
3063 mConIn
.PasswordEnabled
= FALSE
;
3064 Status
= EFI_NOT_READY
;
3066 } else if ((Key
.UnicodeChar
== CHAR_BACKSPACE
) && (Key
.ScanCode
== SCAN_NULL
)) {
3070 if (mConIn
.PwdIndex
> 0) {
3071 BackSpaceString
[0] = CHAR_BACKSPACE
;
3072 BackSpaceString
[1] = 0;
3074 SpaceString
[0] = ' ';
3077 ConSplitterTextOutOutputString (&mConOut
.TextOut
, BackSpaceString
);
3078 ConSplitterTextOutOutputString (&mConOut
.TextOut
, SpaceString
);
3079 ConSplitterTextOutOutputString (&mConOut
.TextOut
, BackSpaceString
);
3083 } else if ((Key
.ScanCode
== SCAN_NULL
) && (Key
.UnicodeChar
>= 32)) {
3085 // If it's not an ENTER, neigher a function key, nor a CTRL-X or ALT-X, record the input
3087 if (mConIn
.PwdIndex
< (MAX_STD_IN_PASSWORD
- 1)) {
3088 if (mConIn
.PwdIndex
== 0) {
3089 ConSplitterTextOutOutputString (&mConOut
.TextOut
, (CHAR16
*) L
"\n\r");
3092 ConSplitterTextOutOutputString (&mConOut
.TextOut
, (CHAR16
*) L
"*");
3093 mConIn
.PwdAttempt
[mConIn
.PwdIndex
] = Key
.UnicodeChar
;
3098 } while (!EFI_ERROR (Status
));
3103 ConSpliterConsoleControlLockStdIn (
3104 IN EFI_CONSOLE_CONTROL_PROTOCOL
*This
,
3109 Routine Description:
3110 If Password is NULL unlock the password state variable and set the event
3111 timer. If the Password is too big return an error. If the Password is valid
3112 Copy the Password and enable state variable and then arm the periodic timer
3117 EFI_SUCCESS - Lock the StdIn device
3118 EFI_INVALID_PARAMETER - Password is NULL
3119 EFI_OUT_OF_RESOURCES - Buffer allocation to store the password fails
3123 if (Password
== NULL
) {
3124 return EFI_INVALID_PARAMETER
;
3127 if (StrLen (Password
) >= MAX_STD_IN_PASSWORD
) {
3129 // Currently have a max password size
3131 return EFI_OUT_OF_RESOURCES
;
3134 // Save the password, initialize state variables and arm event timer
3136 StrCpy (mConIn
.Password
, Password
);
3137 mConIn
.PasswordEnabled
= TRUE
;
3138 mConIn
.PwdIndex
= 0;
3139 gBS
->SetTimer (mConIn
.LockEvent
, TimerPeriodic
, (10000 * 25));
3146 ConSplitterTextInReadKeyStroke (
3147 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*This
,
3148 OUT EFI_INPUT_KEY
*Key
3152 Routine Description:
3153 Reads the next keystroke from the input device. The WaitForKey Event can
3154 be used to test for existance of a keystroke via WaitForEvent () call.
3155 If the ConIn is password locked make it look like no keystroke is availible
3158 This - Protocol instance pointer.
3159 Key - Driver may perform diagnostics on reset.
3162 EFI_SUCCESS - The keystroke information was returned.
3163 EFI_NOT_READY - There was no keystroke data availiable.
3164 EFI_DEVICE_ERROR - The keydtroke information was not returned due to
3169 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3171 Private
= TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
3172 if (Private
->PasswordEnabled
) {
3174 // If StdIn Locked return not ready
3176 return EFI_NOT_READY
;
3179 Private
->KeyEventSignalState
= FALSE
;
3181 return ConSplitterTextInPrivateReadKeyStroke (Private
, Key
);
3186 ConSplitterTextInWaitForKey (
3192 Routine Description:
3193 This event agregates all the events of the ConIn devices in the spliter.
3194 If the ConIn is password locked then return.
3195 If any events of physical ConIn devices are signaled, signal the ConIn
3196 spliter event. This will cause the calling code to call
3197 ConSplitterTextInReadKeyStroke ().
3200 Event - The Event assoicated with callback.
3201 Context - Context registered when Event was created.
3209 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3212 Private
= (TEXT_IN_SPLITTER_PRIVATE_DATA
*) Context
;
3213 if (Private
->PasswordEnabled
) {
3215 // If StdIn Locked return not ready
3221 // if KeyEventSignalState is flagged before, and not cleared by Reset() or ReadKeyStroke()
3223 if (Private
->KeyEventSignalState
) {
3224 gBS
->SignalEvent (Event
);
3228 // if any physical console input device has key input, signal the event.
3230 for (Index
= 0; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
3231 Status
= gBS
->CheckEvent (Private
->TextInList
[Index
]->WaitForKey
);
3232 if (!EFI_ERROR (Status
)) {
3233 gBS
->SignalEvent (Event
);
3234 Private
->KeyEventSignalState
= TRUE
;
3243 IN EFI_KEY_DATA
*RegsiteredData
,
3244 IN EFI_KEY_DATA
*InputData
3248 Routine Description:
3252 RegsiteredData - A pointer to a buffer that is filled in with the keystroke
3253 state data for the key that was registered.
3254 InputData - A pointer to a buffer that is filled in with the keystroke
3255 state data for the key that was pressed.
3258 TRUE - Key be pressed matches a registered key.
3259 FLASE - Match failed.
3263 ASSERT (RegsiteredData
!= NULL
&& InputData
!= NULL
);
3265 if ((RegsiteredData
->Key
.ScanCode
!= InputData
->Key
.ScanCode
) ||
3266 (RegsiteredData
->Key
.UnicodeChar
!= InputData
->Key
.UnicodeChar
)) {
3271 // Assume KeyShiftState/KeyToggleState = 0 in Registered key data means these state could be ignored.
3273 if (RegsiteredData
->KeyState
.KeyShiftState
!= 0 &&
3274 RegsiteredData
->KeyState
.KeyShiftState
!= InputData
->KeyState
.KeyShiftState
) {
3277 if (RegsiteredData
->KeyState
.KeyToggleState
!= 0 &&
3278 RegsiteredData
->KeyState
.KeyToggleState
!= InputData
->KeyState
.KeyToggleState
) {
3287 // Simple Text Input Ex protocol functions
3292 ConSplitterTextInResetEx (
3293 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*This
,
3294 IN BOOLEAN ExtendedVerification
3298 Routine Description:
3299 Reset the input device and optionaly run diagnostics
3302 This - Protocol instance pointer.
3303 ExtendedVerification - Driver may perform diagnostics on reset.
3306 EFI_SUCCESS - The device was reset.
3307 EFI_DEVICE_ERROR - The device is not functioning properly and could
3313 EFI_STATUS ReturnStatus
;
3314 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3317 Private
= TEXT_IN_EX_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
3319 Private
->KeyEventSignalState
= FALSE
;
3322 // return the worst status met
3324 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfExConsoles
; Index
++) {
3325 Status
= Private
->TextInExList
[Index
]->Reset (
3326 Private
->TextInExList
[Index
],
3327 ExtendedVerification
3329 if (EFI_ERROR (Status
)) {
3330 ReturnStatus
= Status
;
3334 return ReturnStatus
;
3340 ConSplitterTextInReadKeyStrokeEx (
3341 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*This
,
3342 OUT EFI_KEY_DATA
*KeyData
3346 Routine Description:
3347 Reads the next keystroke from the input device. The WaitForKey Event can
3348 be used to test for existance of a keystroke via WaitForEvent () call.
3351 This - Protocol instance pointer.
3352 KeyData - A pointer to a buffer that is filled in with the keystroke
3353 state data for the key that was pressed.
3356 EFI_SUCCESS - The keystroke information was returned.
3357 EFI_NOT_READY - There was no keystroke data availiable.
3358 EFI_DEVICE_ERROR - The keystroke information was not returned due to
3360 EFI_INVALID_PARAMETER - KeyData is NULL.
3364 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3367 EFI_KEY_DATA CurrentKeyData
;
3370 if (KeyData
== NULL
) {
3371 return EFI_INVALID_PARAMETER
;
3374 Private
= TEXT_IN_EX_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
3375 if (Private
->PasswordEnabled
) {
3377 // If StdIn Locked return not ready
3379 return EFI_NOT_READY
;
3382 Private
->KeyEventSignalState
= FALSE
;
3384 KeyData
->Key
.UnicodeChar
= 0;
3385 KeyData
->Key
.ScanCode
= SCAN_NULL
;
3388 // if no physical console input device exists, return EFI_NOT_READY;
3389 // if any physical console input device has key input,
3390 // return the key and EFI_SUCCESS.
3392 for (Index
= 0; Index
< Private
->CurrentNumberOfExConsoles
; Index
++) {
3393 Status
= Private
->TextInExList
[Index
]->ReadKeyStrokeEx (
3394 Private
->TextInExList
[Index
],
3397 if (!EFI_ERROR (Status
)) {
3398 CopyMem (KeyData
, &CurrentKeyData
, sizeof (CurrentKeyData
));
3403 return EFI_NOT_READY
;
3408 ConSplitterTextInSetState (
3409 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*This
,
3410 IN EFI_KEY_TOGGLE_STATE
*KeyToggleState
3414 Routine Description:
3415 Set certain state for the input device.
3418 This - Protocol instance pointer.
3419 KeyToggleState - A pointer to the EFI_KEY_TOGGLE_STATE to set the
3420 state for the input device.
3423 EFI_SUCCESS - The device state was set successfully.
3424 EFI_DEVICE_ERROR - The device is not functioning correctly and could
3425 not have the setting adjusted.
3426 EFI_UNSUPPORTED - The device does not have the ability to set its state.
3427 EFI_INVALID_PARAMETER - KeyToggleState is NULL.
3431 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3435 if (KeyToggleState
== NULL
) {
3436 return EFI_INVALID_PARAMETER
;
3439 Private
= TEXT_IN_EX_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
3442 // if no physical console input device exists, return EFI_SUCCESS;
3443 // otherwise return the status of setting state of physical console input device
3445 for (Index
= 0; Index
< Private
->CurrentNumberOfExConsoles
; Index
++) {
3446 Status
= Private
->TextInExList
[Index
]->SetState (
3447 Private
->TextInExList
[Index
],
3450 if (EFI_ERROR (Status
)) {
3461 ConSplitterTextInRegisterKeyNotify (
3462 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*This
,
3463 IN EFI_KEY_DATA
*KeyData
,
3464 IN EFI_KEY_NOTIFY_FUNCTION KeyNotificationFunction
,
3465 OUT EFI_HANDLE
*NotifyHandle
3469 Routine Description:
3470 Register a notification function for a particular keystroke for the input device.
3473 This - Protocol instance pointer.
3474 KeyData - A pointer to a buffer that is filled in with the keystroke
3475 information data for the key that was pressed.
3476 KeyNotificationFunction - Points to the function to be called when the key
3477 sequence is typed specified by KeyData.
3478 NotifyHandle - Points to the unique handle assigned to the registered notification.
3481 EFI_SUCCESS - The notification function was registered successfully.
3482 EFI_OUT_OF_RESOURCES - Unable to allocate resources for necesssary data structures.
3483 EFI_INVALID_PARAMETER - KeyData or NotifyHandle is NULL.
3487 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3490 TEXT_IN_EX_SPLITTER_NOTIFY
*NewNotify
;
3492 TEXT_IN_EX_SPLITTER_NOTIFY
*CurrentNotify
;
3495 if (KeyData
== NULL
|| NotifyHandle
== NULL
|| KeyNotificationFunction
== NULL
) {
3496 return EFI_INVALID_PARAMETER
;
3499 Private
= TEXT_IN_EX_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
3502 // if no physical console input device exists,
3503 // return EFI_SUCCESS directly.
3505 if (Private
->CurrentNumberOfExConsoles
<= 0) {
3510 // Return EFI_SUCCESS if the (KeyData, NotificationFunction) is already registered.
3512 for (Link
= Private
->NotifyList
.ForwardLink
; Link
!= &Private
->NotifyList
; Link
= Link
->ForwardLink
) {
3513 CurrentNotify
= CR (
3515 TEXT_IN_EX_SPLITTER_NOTIFY
,
3517 TEXT_IN_EX_SPLITTER_NOTIFY_SIGNATURE
3519 if (IsKeyRegistered (&CurrentNotify
->KeyData
, KeyData
)) {
3520 if (CurrentNotify
->KeyNotificationFn
== KeyNotificationFunction
) {
3521 *NotifyHandle
= CurrentNotify
->NotifyHandle
;
3528 // Allocate resource to save the notification function
3530 NewNotify
= (TEXT_IN_EX_SPLITTER_NOTIFY
*) AllocateZeroPool (sizeof (TEXT_IN_EX_SPLITTER_NOTIFY
));
3531 if (NewNotify
== NULL
) {
3532 return EFI_OUT_OF_RESOURCES
;
3534 NewNotify
->NotifyHandleList
= (EFI_HANDLE
*) AllocateZeroPool (sizeof (EFI_HANDLE
) * Private
->CurrentNumberOfExConsoles
);
3535 if (NewNotify
->NotifyHandleList
== NULL
) {
3536 gBS
->FreePool (NewNotify
);
3537 return EFI_OUT_OF_RESOURCES
;
3539 NewNotify
->Signature
= TEXT_IN_EX_SPLITTER_NOTIFY_SIGNATURE
;
3540 NewNotify
->KeyNotificationFn
= KeyNotificationFunction
;
3541 CopyMem (&NewNotify
->KeyData
, KeyData
, sizeof (KeyData
));
3544 // Return the wrong status of registering key notify of
3545 // physical console input device if meet problems
3547 for (Index
= 0; Index
< Private
->CurrentNumberOfExConsoles
; Index
++) {
3548 Status
= Private
->TextInExList
[Index
]->RegisterKeyNotify (
3549 Private
->TextInExList
[Index
],
3551 KeyNotificationFunction
,
3552 &NewNotify
->NotifyHandleList
[Index
]
3554 if (EFI_ERROR (Status
)) {
3555 gBS
->FreePool (NewNotify
->NotifyHandleList
);
3556 gBS
->FreePool (NewNotify
);
3562 // Use gSimpleTextInExNotifyGuid to get a valid EFI_HANDLE
3564 Status
= gBS
->InstallMultipleProtocolInterfaces (
3565 &NewNotify
->NotifyHandle
,
3566 &gSimpleTextInExNotifyGuid
,
3570 ASSERT_EFI_ERROR (Status
);
3572 InsertTailList (&mConIn
.NotifyList
, &NewNotify
->NotifyEntry
);
3574 *NotifyHandle
= NewNotify
->NotifyHandle
;
3582 ConSplitterTextInUnregisterKeyNotify (
3583 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*This
,
3584 IN EFI_HANDLE NotificationHandle
3588 Routine Description:
3589 Remove a registered notification function from a particular keystroke.
3592 This - Protocol instance pointer.
3593 NotificationHandle - The handle of the notification function being unregistered.
3596 EFI_SUCCESS - The notification function was unregistered successfully.
3597 EFI_INVALID_PARAMETER - The NotificationHandle is invalid.
3598 EFI_NOT_FOUND - Can not find the matching entry in database.
3602 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3605 TEXT_IN_EX_SPLITTER_NOTIFY
*CurrentNotify
;
3608 if (NotificationHandle
== NULL
) {
3609 return EFI_INVALID_PARAMETER
;
3612 Status
= gBS
->OpenProtocol (
3614 &gSimpleTextInExNotifyGuid
,
3618 EFI_OPEN_PROTOCOL_TEST_PROTOCOL
3620 if (EFI_ERROR (Status
)) {
3621 return EFI_INVALID_PARAMETER
;
3624 Private
= TEXT_IN_EX_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
3627 // if no physical console input device exists,
3628 // return EFI_SUCCESS directly.
3630 if (Private
->CurrentNumberOfExConsoles
<= 0) {
3634 for (Link
= Private
->NotifyList
.ForwardLink
; Link
!= &Private
->NotifyList
; Link
= Link
->ForwardLink
) {
3635 CurrentNotify
= CR (Link
, TEXT_IN_EX_SPLITTER_NOTIFY
, NotifyEntry
, TEXT_IN_EX_SPLITTER_NOTIFY_SIGNATURE
);
3636 if (CurrentNotify
->NotifyHandle
== NotificationHandle
) {
3637 for (Index
= 0; Index
< Private
->CurrentNumberOfExConsoles
; Index
++) {
3638 Status
= Private
->TextInExList
[Index
]->UnregisterKeyNotify (
3639 Private
->TextInExList
[Index
],
3640 CurrentNotify
->NotifyHandleList
[Index
]
3642 if (EFI_ERROR (Status
)) {
3646 RemoveEntryList (&CurrentNotify
->NotifyEntry
);
3647 Status
= gBS
->UninstallMultipleProtocolInterfaces (
3648 CurrentNotify
->NotifyHandle
,
3649 &gSimpleTextInExNotifyGuid
,
3653 ASSERT_EFI_ERROR (Status
);
3654 gBS
->FreePool (CurrentNotify
->NotifyHandleList
);
3655 gBS
->FreePool (CurrentNotify
);
3660 return EFI_NOT_FOUND
;
3666 ConSplitterSimplePointerReset (
3667 IN EFI_SIMPLE_POINTER_PROTOCOL
*This
,
3668 IN BOOLEAN ExtendedVerification
3672 Routine Description:
3673 Reset the input device and optionaly run diagnostics
3676 This - Protocol instance pointer.
3677 ExtendedVerification - Driver may perform diagnostics on reset.
3680 EFI_SUCCESS - The device was reset.
3681 EFI_DEVICE_ERROR - The device is not functioning properly and could
3687 EFI_STATUS ReturnStatus
;
3688 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3691 Private
= TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_SIMPLE_POINTER_THIS (This
);
3693 Private
->InputEventSignalState
= FALSE
;
3695 if (Private
->CurrentNumberOfPointers
== 0) {
3699 // return the worst status met
3701 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfPointers
; Index
++) {
3702 Status
= Private
->PointerList
[Index
]->Reset (
3703 Private
->PointerList
[Index
],
3704 ExtendedVerification
3706 if (EFI_ERROR (Status
)) {
3707 ReturnStatus
= Status
;
3711 return ReturnStatus
;
3717 ConSplitterSimplePointerPrivateGetState (
3718 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
3719 IN OUT EFI_SIMPLE_POINTER_STATE
*State
3723 Routine Description:
3724 Reads the next keystroke from the input device. The WaitForKey Event can
3725 be used to test for existance of a keystroke via WaitForEvent () call.
3728 This - Protocol instance pointer.
3732 EFI_SUCCESS - The keystroke information was returned.
3733 EFI_NOT_READY - There was no keystroke data availiable.
3734 EFI_DEVICE_ERROR - The keydtroke information was not returned due to
3740 EFI_STATUS ReturnStatus
;
3742 EFI_SIMPLE_POINTER_STATE CurrentState
;
3744 State
->RelativeMovementX
= 0;
3745 State
->RelativeMovementY
= 0;
3746 State
->RelativeMovementZ
= 0;
3747 State
->LeftButton
= FALSE
;
3748 State
->RightButton
= FALSE
;
3751 // if no physical console input device exists, return EFI_NOT_READY;
3752 // if any physical console input device has key input,
3753 // return the key and EFI_SUCCESS.
3755 ReturnStatus
= EFI_NOT_READY
;
3756 for (Index
= 0; Index
< Private
->CurrentNumberOfPointers
; Index
++) {
3758 Status
= Private
->PointerList
[Index
]->GetState (
3759 Private
->PointerList
[Index
],
3762 if (!EFI_ERROR (Status
)) {
3763 if (ReturnStatus
== EFI_NOT_READY
) {
3764 ReturnStatus
= EFI_SUCCESS
;
3767 if (CurrentState
.LeftButton
) {
3768 State
->LeftButton
= TRUE
;
3771 if (CurrentState
.RightButton
) {
3772 State
->RightButton
= TRUE
;
3775 if (CurrentState
.RelativeMovementX
!= 0 && Private
->PointerList
[Index
]->Mode
->ResolutionX
!= 0) {
3776 State
->RelativeMovementX
+= (CurrentState
.RelativeMovementX
* (INT32
) Private
->SimplePointerMode
.ResolutionX
) / (INT32
) Private
->PointerList
[Index
]->Mode
->ResolutionX
;
3779 if (CurrentState
.RelativeMovementY
!= 0 && Private
->PointerList
[Index
]->Mode
->ResolutionY
!= 0) {
3780 State
->RelativeMovementY
+= (CurrentState
.RelativeMovementY
* (INT32
) Private
->SimplePointerMode
.ResolutionY
) / (INT32
) Private
->PointerList
[Index
]->Mode
->ResolutionY
;
3783 if (CurrentState
.RelativeMovementZ
!= 0 && Private
->PointerList
[Index
]->Mode
->ResolutionZ
!= 0) {
3784 State
->RelativeMovementZ
+= (CurrentState
.RelativeMovementZ
* (INT32
) Private
->SimplePointerMode
.ResolutionZ
) / (INT32
) Private
->PointerList
[Index
]->Mode
->ResolutionZ
;
3786 } else if (Status
== EFI_DEVICE_ERROR
) {
3787 ReturnStatus
= EFI_DEVICE_ERROR
;
3791 return ReturnStatus
;
3796 ConSplitterSimplePointerGetState (
3797 IN EFI_SIMPLE_POINTER_PROTOCOL
*This
,
3798 IN OUT EFI_SIMPLE_POINTER_STATE
*State
3802 Routine Description:
3803 Reads the next keystroke from the input device. The WaitForKey Event can
3804 be used to test for existance of a keystroke via WaitForEvent () call.
3805 If the ConIn is password locked make it look like no keystroke is availible
3808 This - Protocol instance pointer.
3812 EFI_SUCCESS - The keystroke information was returned.
3813 EFI_NOT_READY - There was no keystroke data availiable.
3814 EFI_DEVICE_ERROR - The keydtroke information was not returned due to
3819 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3821 Private
= TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_SIMPLE_POINTER_THIS (This
);
3822 if (Private
->PasswordEnabled
) {
3824 // If StdIn Locked return not ready
3826 return EFI_NOT_READY
;
3829 Private
->InputEventSignalState
= FALSE
;
3831 return ConSplitterSimplePointerPrivateGetState (Private
, State
);
3836 ConSplitterSimplePointerWaitForInput (
3842 Routine Description:
3843 This event agregates all the events of the ConIn devices in the spliter.
3844 If the ConIn is password locked then return.
3845 If any events of physical ConIn devices are signaled, signal the ConIn
3846 spliter event. This will cause the calling code to call
3847 ConSplitterTextInReadKeyStroke ().
3850 Event - The Event assoicated with callback.
3851 Context - Context registered when Event was created.
3859 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3862 Private
= (TEXT_IN_SPLITTER_PRIVATE_DATA
*) Context
;
3863 if (Private
->PasswordEnabled
) {
3865 // If StdIn Locked return not ready
3871 // if InputEventSignalState is flagged before, and not cleared by Reset() or ReadKeyStroke()
3873 if (Private
->InputEventSignalState
) {
3874 gBS
->SignalEvent (Event
);
3878 // if any physical console input device has key input, signal the event.
3880 for (Index
= 0; Index
< Private
->CurrentNumberOfPointers
; Index
++) {
3881 Status
= gBS
->CheckEvent (Private
->PointerList
[Index
]->WaitForInput
);
3882 if (!EFI_ERROR (Status
)) {
3883 gBS
->SignalEvent (Event
);
3884 Private
->InputEventSignalState
= TRUE
;
3890 // Absolute Pointer Protocol functions
3895 ConSplitterAbsolutePointerReset (
3896 IN EFI_ABSOLUTE_POINTER_PROTOCOL
*This
,
3897 IN BOOLEAN ExtendedVerification
3901 Routine Description:
3902 Resets the pointer device hardware.
3905 This - Protocol instance pointer.
3906 ExtendedVerification - Driver may perform diagnostics on reset.
3909 EFI_SUCCESS - The device was reset.
3910 EFI_DEVICE_ERROR - The device is not functioning correctly and could
3916 EFI_STATUS ReturnStatus
;
3917 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3920 Private
= TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_ABSOLUTE_POINTER_THIS (This
);
3922 Private
->AbsoluteInputEventSignalState
= FALSE
;
3924 if (Private
->CurrentNumberOfAbsolutePointers
== 0) {
3928 // return the worst status met
3930 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfAbsolutePointers
; Index
++) {
3931 Status
= Private
->AbsolutePointerList
[Index
]->Reset (
3932 Private
->AbsolutePointerList
[Index
],
3933 ExtendedVerification
3935 if (EFI_ERROR (Status
)) {
3936 ReturnStatus
= Status
;
3940 return ReturnStatus
;
3945 ConSplitterAbsolutePointerGetState (
3946 IN EFI_ABSOLUTE_POINTER_PROTOCOL
*This
,
3947 IN OUT EFI_ABSOLUTE_POINTER_STATE
*State
3951 Routine Description:
3952 Retrieves the current state of a pointer device.
3955 This - Protocol instance pointer.
3956 State - A pointer to the state information on the pointer device.
3959 EFI_SUCCESS - The state of the pointer device was returned in State..
3960 EFI_NOT_READY - The state of the pointer device has not changed since the last call to
3962 EFI_DEVICE_ERROR - A device error occurred while attempting to retrieve the pointer
3963 device's current state.
3966 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3968 EFI_STATUS ReturnStatus
;
3970 EFI_ABSOLUTE_POINTER_STATE CurrentState
;
3973 Private
= TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_ABSOLUTE_POINTER_THIS (This
);
3974 if (Private
->PasswordEnabled
) {
3976 // If StdIn Locked return not ready
3978 return EFI_NOT_READY
;
3981 Private
->AbsoluteInputEventSignalState
= FALSE
;
3983 State
->CurrentX
= 0;
3984 State
->CurrentY
= 0;
3985 State
->CurrentZ
= 0;
3986 State
->ActiveButtons
= 0;
3989 // if no physical pointer device exists, return EFI_NOT_READY;
3990 // if any physical pointer device has changed state,
3991 // return the state and EFI_SUCCESS.
3993 ReturnStatus
= EFI_NOT_READY
;
3994 for (Index
= 0; Index
< Private
->CurrentNumberOfAbsolutePointers
; Index
++) {
3996 Status
= Private
->AbsolutePointerList
[Index
]->GetState (
3997 Private
->AbsolutePointerList
[Index
],
4000 if (!EFI_ERROR (Status
)) {
4001 if (ReturnStatus
== EFI_NOT_READY
) {
4002 ReturnStatus
= EFI_SUCCESS
;
4005 State
->ActiveButtons
= CurrentState
.ActiveButtons
;
4007 if (!(Private
->AbsolutePointerMode
.AbsoluteMinX
== 0 && Private
->AbsolutePointerMode
.AbsoluteMaxX
== 0)) {
4008 State
->CurrentX
= CurrentState
.CurrentX
;
4010 if (!(Private
->AbsolutePointerMode
.AbsoluteMinY
== 0 && Private
->AbsolutePointerMode
.AbsoluteMaxY
== 0)) {
4011 State
->CurrentY
= CurrentState
.CurrentY
;
4013 if (!(Private
->AbsolutePointerMode
.AbsoluteMinZ
== 0 && Private
->AbsolutePointerMode
.AbsoluteMaxZ
== 0)) {
4014 State
->CurrentZ
= CurrentState
.CurrentZ
;
4017 } else if (Status
== EFI_DEVICE_ERROR
) {
4018 ReturnStatus
= EFI_DEVICE_ERROR
;
4022 return ReturnStatus
;
4027 ConSplitterAbsolutePointerWaitForInput (
4033 Routine Description:
4034 This event agregates all the events of the pointer devices in the splitter.
4035 If the ConIn is password locked then return.
4036 If any events of physical pointer devices are signaled, signal the pointer
4037 splitter event. This will cause the calling code to call
4038 ConSplitterAbsolutePointerGetState ().
4041 Event - The Event assoicated with callback.
4042 Context - Context registered when Event was created.
4050 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
4053 Private
= (TEXT_IN_SPLITTER_PRIVATE_DATA
*) Context
;
4054 if (Private
->PasswordEnabled
) {
4056 // If StdIn Locked return not ready
4062 // if AbsoluteInputEventSignalState is flagged before,
4063 // and not cleared by Reset() or GetState(), signal it
4065 if (Private
->AbsoluteInputEventSignalState
) {
4066 gBS
->SignalEvent (Event
);
4070 // if any physical console input device has key input, signal the event.
4072 for (Index
= 0; Index
< Private
->CurrentNumberOfAbsolutePointers
; Index
++) {
4073 Status
= gBS
->CheckEvent (Private
->AbsolutePointerList
[Index
]->WaitForInput
);
4074 if (!EFI_ERROR (Status
)) {
4075 gBS
->SignalEvent (Event
);
4076 Private
->AbsoluteInputEventSignalState
= TRUE
;
4083 ConSplitterTextOutReset (
4084 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4085 IN BOOLEAN ExtendedVerification
4089 Routine Description:
4090 Reset the text output device hardware and optionaly run diagnostics
4093 This - Protocol instance pointer.
4094 ExtendedVerification - Driver may perform more exhaustive verfication
4095 operation of the device during reset.
4098 EFI_SUCCESS - The text output device was reset.
4099 EFI_DEVICE_ERROR - The text output device is not functioning correctly and
4105 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4107 EFI_STATUS ReturnStatus
;
4109 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4112 // return the worst status met
4114 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
4116 if (Private
->TextOutList
[Index
].TextOutEnabled
) {
4118 Status
= Private
->TextOutList
[Index
].TextOut
->Reset (
4119 Private
->TextOutList
[Index
].TextOut
,
4120 ExtendedVerification
4122 if (EFI_ERROR (Status
)) {
4123 ReturnStatus
= Status
;
4128 This
->SetAttribute (This
, EFI_TEXT_ATTR (This
->Mode
->Attribute
& 0x0F, EFI_BACKGROUND_BLACK
));
4130 Status
= DevNullTextOutSetMode (Private
, 0);
4131 if (EFI_ERROR (Status
)) {
4132 ReturnStatus
= Status
;
4135 return ReturnStatus
;
4140 ConSplitterTextOutOutputString (
4141 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4146 Routine Description:
4147 Write a Unicode string to the output device.
4150 This - Protocol instance pointer.
4151 String - The NULL-terminated Unicode string to be displayed on the output
4152 device(s). All output devices must also support the Unicode
4153 drawing defined in this file.
4156 EFI_SUCCESS - The string was output to the device.
4157 EFI_DEVICE_ERROR - The device reported an error while attempting to output
4159 EFI_UNSUPPORTED - The output device's mode is not currently in a
4161 EFI_WARN_UNKNOWN_GLYPH - This warning code indicates that some of the
4162 characters in the Unicode string could not be
4163 rendered and were skipped.
4168 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4170 UINTN BackSpaceCount
;
4171 EFI_STATUS ReturnStatus
;
4172 CHAR16
*TargetString
;
4174 This
->SetAttribute (This
, This
->Mode
->Attribute
);
4176 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4179 for (TargetString
= WString
; *TargetString
; TargetString
++) {
4180 if (*TargetString
== CHAR_BACKSPACE
) {
4186 if (BackSpaceCount
== 0) {
4187 TargetString
= WString
;
4189 TargetString
= AllocatePool (sizeof (CHAR16
) * (StrLen (WString
) + BackSpaceCount
+ 1));
4190 StrCpy (TargetString
, WString
);
4193 // return the worst status met
4195 Status
= DevNullTextOutOutputString (Private
, TargetString
);
4196 if (EFI_ERROR (Status
)) {
4197 ReturnStatus
= Status
;
4200 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
4202 if (Private
->TextOutList
[Index
].TextOutEnabled
) {
4203 Status
= Private
->TextOutList
[Index
].TextOut
->OutputString (
4204 Private
->TextOutList
[Index
].TextOut
,
4207 if (EFI_ERROR (Status
)) {
4208 ReturnStatus
= Status
;
4213 if (BackSpaceCount
) {
4214 FreePool (TargetString
);
4217 return ReturnStatus
;
4222 ConSplitterTextOutTestString (
4223 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4228 Routine Description:
4229 Verifies that all characters in a Unicode string can be output to the
4233 This - Protocol instance pointer.
4234 String - The NULL-terminated Unicode string to be examined for the output
4238 EFI_SUCCESS - The device(s) are capable of rendering the output string.
4239 EFI_UNSUPPORTED - Some of the characters in the Unicode string cannot be
4240 rendered by one or more of the output devices mapped
4246 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4248 EFI_STATUS ReturnStatus
;
4250 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4253 // return the worst status met
4255 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
4256 if (Private
->TextOutList
[Index
].TextOutEnabled
) {
4257 Status
= Private
->TextOutList
[Index
].TextOut
->TestString (
4258 Private
->TextOutList
[Index
].TextOut
,
4261 if (EFI_ERROR (Status
)) {
4262 ReturnStatus
= Status
;
4267 // There is no DevNullTextOutTestString () since a Unicode buffer would
4268 // always return EFI_SUCCESS.
4269 // ReturnStatus will be EFI_SUCCESS if no consoles are present
4271 return ReturnStatus
;
4276 ConSplitterTextOutQueryMode (
4277 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4278 IN UINTN ModeNumber
,
4284 Routine Description:
4285 Returns information for an available text mode that the output device(s)
4289 This - Protocol instance pointer.
4290 ModeNumber - The mode number to return information on.
4291 Columns, Rows - Returns the geometry of the text output device for the
4292 requested ModeNumber.
4295 EFI_SUCCESS - The requested mode information was returned.
4296 EFI_DEVICE_ERROR - The device had an error and could not
4297 complete the request.
4298 EFI_UNSUPPORTED - The mode number was not valid.
4302 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4304 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4307 // Check whether param ModeNumber is valid.
4308 // ModeNumber should be within range 0 ~ MaxMode - 1.
4310 if ( (ModeNumber
> (UINTN
)(((UINT32
)-1)>>1)) ) {
4311 return EFI_UNSUPPORTED
;
4314 if ((INT32
) ModeNumber
>= This
->Mode
->MaxMode
) {
4315 return EFI_UNSUPPORTED
;
4318 *Columns
= Private
->TextOutQueryData
[ModeNumber
].Columns
;
4319 *Rows
= Private
->TextOutQueryData
[ModeNumber
].Rows
;
4321 if (*Columns
<= 0 && *Rows
<= 0) {
4322 return EFI_UNSUPPORTED
;
4331 ConSplitterTextOutSetMode (
4332 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4337 Routine Description:
4338 Sets the output device(s) to a specified mode.
4341 This - Protocol instance pointer.
4342 ModeNumber - The mode number to set.
4345 EFI_SUCCESS - The requested text mode was set.
4346 EFI_DEVICE_ERROR - The device had an error and
4347 could not complete the request.
4348 EFI_UNSUPPORTED - The mode number was not valid.
4353 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4355 INT32
*TextOutModeMap
;
4356 EFI_STATUS ReturnStatus
;
4358 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4361 // Check whether param ModeNumber is valid.
4362 // ModeNumber should be within range 0 ~ MaxMode - 1.
4364 if ( (ModeNumber
> (UINTN
)(((UINT32
)-1)>>1)) ) {
4365 return EFI_UNSUPPORTED
;
4368 if ((INT32
) ModeNumber
>= This
->Mode
->MaxMode
) {
4369 return EFI_UNSUPPORTED
;
4372 // If the mode is being set to the curent mode, then just clear the screen and return.
4374 if (Private
->TextOutMode
.Mode
== (INT32
) ModeNumber
) {
4375 return ConSplitterTextOutClearScreen (This
);
4378 // return the worst status met
4380 TextOutModeMap
= Private
->TextOutModeMap
+ Private
->TextOutListCount
* ModeNumber
;
4381 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
4383 if (Private
->TextOutList
[Index
].TextOutEnabled
) {
4384 Status
= Private
->TextOutList
[Index
].TextOut
->SetMode (
4385 Private
->TextOutList
[Index
].TextOut
,
4386 TextOutModeMap
[Index
]
4389 // If this console device is based on a UGA device, then sync up the bitmap from
4390 // the UGA splitter and reclear the text portion of the display in the new mode.
4392 if ((Private
->TextOutList
[Index
].GraphicsOutput
!= NULL
) || (Private
->TextOutList
[Index
].UgaDraw
!= NULL
)) {
4393 Private
->TextOutList
[Index
].TextOut
->ClearScreen (Private
->TextOutList
[Index
].TextOut
);
4396 if (EFI_ERROR (Status
)) {
4397 ReturnStatus
= Status
;
4402 // The DevNull Console will support any possible mode as it allocates memory
4404 Status
= DevNullTextOutSetMode (Private
, ModeNumber
);
4405 if (EFI_ERROR (Status
)) {
4406 ReturnStatus
= Status
;
4409 return ReturnStatus
;
4414 ConSplitterTextOutSetAttribute (
4415 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4420 Routine Description:
4421 Sets the background and foreground colors for the OutputString () and
4422 ClearScreen () functions.
4425 This - Protocol instance pointer.
4426 Attribute - The attribute to set. Bits 0..3 are the foreground color, and
4427 bits 4..6 are the background color. All other bits are undefined
4428 and must be zero. The valid Attributes are defined in this file.
4431 EFI_SUCCESS - The attribute was set.
4432 EFI_DEVICE_ERROR - The device had an error and
4433 could not complete the request.
4434 EFI_UNSUPPORTED - The attribute requested is not defined.
4439 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4441 EFI_STATUS ReturnStatus
;
4443 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4446 // Check whether param Attribute is valid.
4448 if ( (Attribute
> (UINTN
)(((UINT32
)-1)>>1)) ) {
4449 return EFI_UNSUPPORTED
;
4453 // return the worst status met
4455 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
4457 if (Private
->TextOutList
[Index
].TextOutEnabled
) {
4458 Status
= Private
->TextOutList
[Index
].TextOut
->SetAttribute (
4459 Private
->TextOutList
[Index
].TextOut
,
4462 if (EFI_ERROR (Status
)) {
4463 ReturnStatus
= Status
;
4468 Private
->TextOutMode
.Attribute
= (INT32
) Attribute
;
4470 return ReturnStatus
;
4475 ConSplitterTextOutClearScreen (
4476 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
4480 Routine Description:
4481 Clears the output device(s) display to the currently selected background
4485 This - Protocol instance pointer.
4488 EFI_SUCCESS - The operation completed successfully.
4489 EFI_DEVICE_ERROR - The device had an error and
4490 could not complete the request.
4491 EFI_UNSUPPORTED - The output device is not in a valid text mode.
4496 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4498 EFI_STATUS ReturnStatus
;
4500 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4503 // return the worst status met
4505 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
4507 if (Private
->TextOutList
[Index
].TextOutEnabled
) {
4508 Status
= Private
->TextOutList
[Index
].TextOut
->ClearScreen (Private
->TextOutList
[Index
].TextOut
);
4509 if (EFI_ERROR (Status
)) {
4510 ReturnStatus
= Status
;
4515 Status
= DevNullTextOutClearScreen (Private
);
4516 if (EFI_ERROR (Status
)) {
4517 ReturnStatus
= Status
;
4520 return ReturnStatus
;
4525 ConSplitterTextOutSetCursorPosition (
4526 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4532 Routine Description:
4533 Sets the current coordinates of the cursor position
4536 This - Protocol instance pointer.
4537 Column, Row - the position to set the cursor to. Must be greater than or
4538 equal to zero and less than the number of columns and rows
4542 EFI_SUCCESS - The operation completed successfully.
4543 EFI_DEVICE_ERROR - The device had an error and
4544 could not complete the request.
4545 EFI_UNSUPPORTED - The output device is not in a valid text mode, or the
4546 cursor position is invalid for the current mode.
4551 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4553 EFI_STATUS ReturnStatus
;
4556 INT32
*TextOutModeMap
;
4560 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4561 TextOutModeMap
= NULL
;
4562 ModeNumber
= Private
->TextOutMode
.Mode
;
4565 // Get current MaxColumn and MaxRow from intersection map
4567 if (Private
->TextOutModeMap
!= NULL
) {
4568 TextOutModeMap
= Private
->TextOutModeMap
+ Private
->TextOutListCount
* ModeNumber
;
4569 CurrentMode
= *TextOutModeMap
;
4571 CurrentMode
= ModeNumber
;
4574 MaxColumn
= Private
->TextOutQueryData
[CurrentMode
].Columns
;
4575 MaxRow
= Private
->TextOutQueryData
[CurrentMode
].Rows
;
4577 if (Column
>= MaxColumn
|| Row
>= MaxRow
) {
4578 return EFI_UNSUPPORTED
;
4581 // return the worst status met
4583 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
4585 if (Private
->TextOutList
[Index
].TextOutEnabled
) {
4586 Status
= Private
->TextOutList
[Index
].TextOut
->SetCursorPosition (
4587 Private
->TextOutList
[Index
].TextOut
,
4591 if (EFI_ERROR (Status
)) {
4592 ReturnStatus
= Status
;
4597 DevNullTextOutSetCursorPosition (Private
, Column
, Row
);
4599 return ReturnStatus
;
4604 ConSplitterTextOutEnableCursor (
4605 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4610 Routine Description:
4611 Makes the cursor visible or invisible
4614 This - Protocol instance pointer.
4615 Visible - If TRUE, the cursor is set to be visible. If FALSE, the cursor is
4616 set to be invisible.
4619 EFI_SUCCESS - The operation completed successfully.
4620 EFI_DEVICE_ERROR - The device had an error and could not complete the
4621 request, or the device does not support changing
4623 EFI_UNSUPPORTED - The output device is not in a valid text mode.
4628 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4630 EFI_STATUS ReturnStatus
;
4632 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4635 // return the worst status met
4637 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
4639 if (Private
->TextOutList
[Index
].TextOutEnabled
) {
4640 Status
= Private
->TextOutList
[Index
].TextOut
->EnableCursor (
4641 Private
->TextOutList
[Index
].TextOut
,
4644 if (EFI_ERROR (Status
)) {
4645 ReturnStatus
= Status
;
4650 DevNullTextOutEnableCursor (Private
, Visible
);
4652 return ReturnStatus
;