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 (TEXT_OUT_GOP_MODE
*) NULL
,
177 ConSpliterConsoleControlGetMode
,
178 ConSpliterConsoleControlSetMode
,
179 ConSpliterConsoleControlLockStdIn
183 (TEXT_OUT_AND_GOP_DATA
*) NULL
,
185 (TEXT_OUT_SPLITTER_QUERY_DATA
*) NULL
,
189 EfiConsoleControlScreenText
,
196 STATIC TEXT_OUT_SPLITTER_PRIVATE_DATA mStdErr
= {
197 TEXT_OUT_SPLITTER_PRIVATE_DATA_SIGNATURE
,
200 ConSplitterTextOutReset
,
201 ConSplitterTextOutOutputString
,
202 ConSplitterTextOutTestString
,
203 ConSplitterTextOutQueryMode
,
204 ConSplitterTextOutSetMode
,
205 ConSplitterTextOutSetAttribute
,
206 ConSplitterTextOutClearScreen
,
207 ConSplitterTextOutSetCursorPosition
,
208 ConSplitterTextOutEnableCursor
,
209 (EFI_SIMPLE_TEXT_OUTPUT_MODE
*) NULL
228 (EFI_UGA_PIXEL
*) NULL
,
235 (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*) NULL
,
236 (TEXT_OUT_GOP_MODE
*) NULL
,
240 ConSpliterConsoleControlGetMode
,
241 ConSpliterConsoleControlSetMode
,
242 ConSpliterConsoleControlLockStdIn
246 (TEXT_OUT_AND_GOP_DATA
*) NULL
,
248 (TEXT_OUT_SPLITTER_QUERY_DATA
*) NULL
,
252 EfiConsoleControlScreenText
,
259 EFI_DRIVER_BINDING_PROTOCOL gConSplitterConInDriverBinding
= {
260 ConSplitterConInDriverBindingSupported
,
261 ConSplitterConInDriverBindingStart
,
262 ConSplitterConInDriverBindingStop
,
268 EFI_DRIVER_BINDING_PROTOCOL gConSplitterSimplePointerDriverBinding
= {
269 ConSplitterSimplePointerDriverBindingSupported
,
270 ConSplitterSimplePointerDriverBindingStart
,
271 ConSplitterSimplePointerDriverBindingStop
,
278 // Driver binding instance for Absolute Pointer protocol
280 EFI_DRIVER_BINDING_PROTOCOL gConSplitterAbsolutePointerDriverBinding
= {
281 ConSplitterAbsolutePointerDriverBindingSupported
,
282 ConSplitterAbsolutePointerDriverBindingStart
,
283 ConSplitterAbsolutePointerDriverBindingStop
,
289 EFI_DRIVER_BINDING_PROTOCOL gConSplitterConOutDriverBinding
= {
290 ConSplitterConOutDriverBindingSupported
,
291 ConSplitterConOutDriverBindingStart
,
292 ConSplitterConOutDriverBindingStop
,
298 EFI_DRIVER_BINDING_PROTOCOL gConSplitterStdErrDriverBinding
= {
299 ConSplitterStdErrDriverBindingSupported
,
300 ConSplitterStdErrDriverBindingStart
,
301 ConSplitterStdErrDriverBindingStop
,
308 The user Entry Point for module ConSplitter. The user code starts with this function.
310 @param[in] ImageHandle The firmware allocated handle for the EFI image.
311 @param[in] SystemTable A pointer to the EFI System Table.
313 @retval EFI_SUCCESS The entry point is executed successfully.
314 @retval other Some error occurs when executing this entry point.
319 InitializeConSplitter(
320 IN EFI_HANDLE ImageHandle
,
321 IN EFI_SYSTEM_TABLE
*SystemTable
327 // Install driver model protocol(s).
329 Status
= EfiLibInstallDriverBindingComponentName2 (
332 &gConSplitterConInDriverBinding
,
334 &gConSplitterConInComponentName
,
335 &gConSplitterConInComponentName2
337 ASSERT_EFI_ERROR (Status
);
339 Status
= EfiLibInstallDriverBindingComponentName2 (
342 &gConSplitterSimplePointerDriverBinding
,
344 &gConSplitterSimplePointerComponentName
,
345 &gConSplitterSimplePointerComponentName2
347 ASSERT_EFI_ERROR (Status
);
349 Status
= EfiLibInstallDriverBindingComponentName2 (
352 &gConSplitterAbsolutePointerDriverBinding
,
354 &gConSplitterAbsolutePointerComponentName
,
355 &gConSplitterAbsolutePointerComponentName2
357 ASSERT_EFI_ERROR (Status
);
359 Status
= EfiLibInstallDriverBindingComponentName2 (
362 &gConSplitterConOutDriverBinding
,
364 &gConSplitterConOutComponentName
,
365 &gConSplitterConOutComponentName2
367 ASSERT_EFI_ERROR (Status
);
369 Status
= EfiLibInstallDriverBindingComponentName2 (
372 &gConSplitterStdErrDriverBinding
,
374 &gConSplitterStdErrComponentName
,
375 &gConSplitterStdErrComponentName2
377 ASSERT_EFI_ERROR (Status
);
381 // Call the original Entry Point
383 Status
= ConSplitterDriverEntry (ImageHandle
, SystemTable
);
391 ConSplitterDriverEntry (
392 IN EFI_HANDLE ImageHandle
,
393 IN EFI_SYSTEM_TABLE
*SystemTable
398 Intialize a virtual console device to act as an agrigator of physical console
402 ImageHandle - (Standard EFI Image entry - EFI_IMAGE_ENTRY_POINT)
403 SystemTable - (Standard EFI Image entry - EFI_IMAGE_ENTRY_POINT)
411 ASSERT (FeaturePcdGet (PcdConOutGopSupport
) ||
412 FeaturePcdGet (PcdConOutUgaSupport
));
414 // The driver creates virtual handles for ConIn, ConOut, and StdErr.
415 // The virtual handles will always exist even if no console exist in the
416 // system. This is need to support hotplug devices like USB.
419 // Create virtual device handle for StdErr Splitter
421 Status
= ConSplitterTextOutConstructor (&mStdErr
);
422 if (!EFI_ERROR (Status
)) {
423 Status
= gBS
->InstallMultipleProtocolInterfaces (
424 &mStdErr
.VirtualHandle
,
425 &gEfiSimpleTextOutProtocolGuid
,
427 &gEfiPrimaryStandardErrorDeviceGuid
,
433 // Create virtual device handle for ConIn Splitter
435 Status
= ConSplitterTextInConstructor (&mConIn
);
436 if (!EFI_ERROR (Status
)) {
437 Status
= gBS
->InstallMultipleProtocolInterfaces (
438 &mConIn
.VirtualHandle
,
439 &gEfiSimpleTextInProtocolGuid
,
441 &gEfiSimpleTextInputExProtocolGuid
,
443 &gEfiSimplePointerProtocolGuid
,
444 &mConIn
.SimplePointer
,
445 &gEfiAbsolutePointerProtocolGuid
,
446 &mConIn
.AbsolutePointer
,
447 &gEfiPrimaryConsoleInDeviceGuid
,
451 if (!EFI_ERROR (Status
)) {
453 // Update the EFI System Table with new virtual console
455 gST
->ConsoleInHandle
= mConIn
.VirtualHandle
;
456 gST
->ConIn
= &mConIn
.TextIn
;
460 // Create virtual device handle for ConOut Splitter
462 Status
= ConSplitterTextOutConstructor (&mConOut
);
463 if (!EFI_ERROR (Status
)) {
464 if (!FeaturePcdGet (PcdConOutGopSupport
)) {
466 // In EFI mode, UGA Draw protocol is installed
468 Status
= gBS
->InstallMultipleProtocolInterfaces (
469 &mConOut
.VirtualHandle
,
470 &gEfiSimpleTextOutProtocolGuid
,
472 &gEfiUgaDrawProtocolGuid
,
474 &gEfiConsoleControlProtocolGuid
,
475 &mConOut
.ConsoleControl
,
476 &gEfiPrimaryConsoleOutDeviceGuid
,
480 } else if (!FeaturePcdGet (PcdConOutUgaSupport
)) {
482 // In UEFI mode, Graphics Output Protocol is installed on virtual handle.
484 Status
= gBS
->InstallMultipleProtocolInterfaces (
485 &mConOut
.VirtualHandle
,
486 &gEfiSimpleTextOutProtocolGuid
,
488 &gEfiGraphicsOutputProtocolGuid
,
489 &mConOut
.GraphicsOutput
,
490 &gEfiConsoleControlProtocolGuid
,
491 &mConOut
.ConsoleControl
,
492 &gEfiPrimaryConsoleOutDeviceGuid
,
498 // In EFI and UEFI comptible mode, Graphics Output Protocol and UGA are
499 // installed on virtual handle.
501 Status
= gBS
->InstallMultipleProtocolInterfaces (
502 &mConOut
.VirtualHandle
,
503 &gEfiSimpleTextOutProtocolGuid
,
505 &gEfiGraphicsOutputProtocolGuid
,
506 &mConOut
.GraphicsOutput
,
507 &gEfiUgaDrawProtocolGuid
,
509 &gEfiConsoleControlProtocolGuid
,
510 &mConOut
.ConsoleControl
,
511 &gEfiPrimaryConsoleOutDeviceGuid
,
517 if (!EFI_ERROR (Status
)) {
519 // Update the EFI System Table with new virtual console
521 gST
->ConsoleOutHandle
= mConOut
.VirtualHandle
;
522 gST
->ConOut
= &mConOut
.TextOut
;
527 // Update the CRC32 in the EFI System Table header
530 gBS
->CalculateCrc32 (
540 ConSplitterTextInConstructor (
541 TEXT_IN_SPLITTER_PRIVATE_DATA
*ConInPrivate
547 Construct the ConSplitter.
551 ConInPrivate - A pointer to the TEXT_IN_SPLITTER_PRIVATE_DATA structure.
554 EFI_OUT_OF_RESOURCES - Out of resources.
561 // Initilize console input splitter's private data.
563 Status
= ConSplitterGrowBuffer (
564 sizeof (EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*),
565 &ConInPrivate
->TextInListCount
,
566 (VOID
**) &ConInPrivate
->TextInList
568 if (EFI_ERROR (Status
)) {
569 return EFI_OUT_OF_RESOURCES
;
572 // Create Event to support locking StdIn Device
574 Status
= gBS
->CreateEvent (
575 EVT_TIMER
| EVT_NOTIFY_SIGNAL
,
577 ConSpliterConsoleControlLockStdInEvent
,
579 &ConInPrivate
->LockEvent
581 ASSERT_EFI_ERROR (Status
);
583 Status
= gBS
->CreateEvent (
586 ConSplitterTextInWaitForKey
,
588 &ConInPrivate
->TextIn
.WaitForKey
590 ASSERT_EFI_ERROR (Status
);
593 // Buffer for Simple Text Input Ex Protocol
595 Status
= ConSplitterGrowBuffer (
596 sizeof (EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*),
597 &ConInPrivate
->TextInExListCount
,
598 (VOID
**) &ConInPrivate
->TextInExList
600 if (EFI_ERROR (Status
)) {
601 return EFI_OUT_OF_RESOURCES
;
604 Status
= gBS
->CreateEvent (
607 ConSplitterTextInWaitForKey
,
609 &ConInPrivate
->TextInEx
.WaitForKeyEx
611 ASSERT_EFI_ERROR (Status
);
613 InitializeListHead (&ConInPrivate
->NotifyList
);
616 // Allocate Buffer and Create Event for Absolute Pointer and Simple Pointer Protocols
618 ConInPrivate
->AbsolutePointer
.Mode
= &ConInPrivate
->AbsolutePointerMode
;
620 Status
= ConSplitterGrowBuffer (
621 sizeof (EFI_ABSOLUTE_POINTER_PROTOCOL
*),
622 &ConInPrivate
->AbsolutePointerListCount
,
623 (VOID
**) &ConInPrivate
->AbsolutePointerList
625 if (EFI_ERROR (Status
)) {
626 return EFI_OUT_OF_RESOURCES
;
629 Status
= gBS
->CreateEvent (
632 ConSplitterAbsolutePointerWaitForInput
,
634 &ConInPrivate
->AbsolutePointer
.WaitForInput
636 ASSERT_EFI_ERROR (Status
);
638 ConInPrivate
->SimplePointer
.Mode
= &ConInPrivate
->SimplePointerMode
;
640 Status
= ConSplitterGrowBuffer (
641 sizeof (EFI_SIMPLE_POINTER_PROTOCOL
*),
642 &ConInPrivate
->PointerListCount
,
643 (VOID
**) &ConInPrivate
->PointerList
645 if (EFI_ERROR (Status
)) {
646 return EFI_OUT_OF_RESOURCES
;
649 Status
= gBS
->CreateEvent (
652 ConSplitterSimplePointerWaitForInput
,
654 &ConInPrivate
->SimplePointer
.WaitForInput
661 ConSplitterTextOutConstructor (
662 TEXT_OUT_SPLITTER_PRIVATE_DATA
*ConOutPrivate
668 // Copy protocols template
670 if (FeaturePcdGet (PcdConOutUgaSupport
)) {
671 CopyMem (&ConOutPrivate
->UgaDraw
, &gUgaDrawProtocolTemplate
, sizeof (EFI_UGA_DRAW_PROTOCOL
));
674 if (FeaturePcdGet (PcdConOutGopSupport
)) {
675 CopyMem (&ConOutPrivate
->GraphicsOutput
, &gGraphicsOutputProtocolTemplate
, sizeof (EFI_GRAPHICS_OUTPUT_PROTOCOL
));
679 // Initilize console output splitter's private data.
681 ConOutPrivate
->TextOut
.Mode
= &ConOutPrivate
->TextOutMode
;
683 Status
= ConSplitterGrowBuffer (
684 sizeof (TEXT_OUT_AND_GOP_DATA
),
685 &ConOutPrivate
->TextOutListCount
,
686 (VOID
**) &ConOutPrivate
->TextOutList
688 if (EFI_ERROR (Status
)) {
689 return EFI_OUT_OF_RESOURCES
;
692 Status
= ConSplitterGrowBuffer (
693 sizeof (TEXT_OUT_SPLITTER_QUERY_DATA
),
694 &ConOutPrivate
->TextOutQueryDataCount
,
695 (VOID
**) &ConOutPrivate
->TextOutQueryData
697 if (EFI_ERROR (Status
)) {
698 return EFI_OUT_OF_RESOURCES
;
701 // Setup the DevNullTextOut console to 80 x 25
703 ConOutPrivate
->TextOutQueryData
[0].Columns
= 80;
704 ConOutPrivate
->TextOutQueryData
[0].Rows
= 25;
705 DevNullTextOutSetMode (ConOutPrivate
, 0);
707 if (FeaturePcdGet (PcdConOutUgaSupport
)) {
709 // Setup the DevNullUgaDraw to 800 x 600 x 32 bits per pixel
711 ConSpliterUgaDrawSetMode (&ConOutPrivate
->UgaDraw
, 800, 600, 32, 60);
713 if (FeaturePcdGet (PcdConOutGopSupport
)) {
715 // Setup resource for mode information in Graphics Output Protocol interface
717 if ((ConOutPrivate
->GraphicsOutput
.Mode
= AllocateZeroPool (sizeof (EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE
))) == NULL
) {
718 return EFI_OUT_OF_RESOURCES
;
720 if ((ConOutPrivate
->GraphicsOutput
.Mode
->Info
= AllocateZeroPool (sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
))) == NULL
) {
721 return EFI_OUT_OF_RESOURCES
;
724 // Setup the DevNullGraphicsOutput to 800 x 600 x 32 bits per pixel
726 if ((ConOutPrivate
->GraphicsOutputModeBuffer
= AllocateZeroPool (sizeof (TEXT_OUT_GOP_MODE
))) == NULL
) {
727 return EFI_OUT_OF_RESOURCES
;
729 ConOutPrivate
->GraphicsOutputModeBuffer
[0].HorizontalResolution
= 800;
730 ConOutPrivate
->GraphicsOutputModeBuffer
[0].VerticalResolution
= 600;
733 // Initialize the following items, theset items remain unchanged in GraphicsOutput->SetMode()
734 // GraphicsOutputMode->Info->Version, GraphicsOutputMode->Info->PixelFormat
735 // GraphicsOutputMode->SizeOfInfo, GraphicsOutputMode->FrameBufferBase, GraphicsOutputMode->FrameBufferSize
737 ConOutPrivate
->GraphicsOutput
.Mode
->Info
->Version
= 0;
738 ConOutPrivate
->GraphicsOutput
.Mode
->Info
->PixelFormat
= PixelBltOnly
;
739 ConOutPrivate
->GraphicsOutput
.Mode
->SizeOfInfo
= sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
);
740 ConOutPrivate
->GraphicsOutput
.Mode
->FrameBufferBase
= (EFI_PHYSICAL_ADDRESS
) NULL
;
741 ConOutPrivate
->GraphicsOutput
.Mode
->FrameBufferSize
= 0;
743 ConOutPrivate
->GraphicsOutput
.Mode
->MaxMode
= 1;
745 // Initial current mode to unknow state, and then set to mode 0
747 ConOutPrivate
->GraphicsOutput
.Mode
->Mode
= 0xffff;
748 ConOutPrivate
->GraphicsOutput
.SetMode (&ConOutPrivate
->GraphicsOutput
, 0);
756 ConSplitterSupported (
757 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
758 IN EFI_HANDLE ControllerHandle
,
764 Generic Supported Check
767 This - Pointer to protocol.
768 ControllerHandle - Controller Handle.
773 EFI_UNSUPPORTED - unsupported.
774 EFI_SUCCESS - operation is OK.
782 // Make sure the Console Splitter does not attempt to attach to itself
784 if (ControllerHandle
== mConIn
.VirtualHandle
) {
785 return EFI_UNSUPPORTED
;
788 if (ControllerHandle
== mConOut
.VirtualHandle
) {
789 return EFI_UNSUPPORTED
;
792 if (ControllerHandle
== mStdErr
.VirtualHandle
) {
793 return EFI_UNSUPPORTED
;
796 // Check to see whether the handle has the ConsoleInDevice GUID on it
798 Status
= gBS
->OpenProtocol (
802 This
->DriverBindingHandle
,
804 EFI_OPEN_PROTOCOL_BY_DRIVER
807 if (EFI_ERROR (Status
)) {
814 This
->DriverBindingHandle
,
823 ConSplitterConInDriverBindingSupported (
824 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
825 IN EFI_HANDLE ControllerHandle
,
826 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
831 Console In Supported Check
834 This - Pointer to protocol.
835 ControllerHandle - Controller handle.
836 RemainingDevicePath - Remaining device path.
844 return ConSplitterSupported (
847 &gEfiConsoleInDeviceGuid
853 ConSplitterSimplePointerDriverBindingSupported (
854 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
855 IN EFI_HANDLE ControllerHandle
,
856 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
861 Standard Error Supported Check
864 This - Pointer to protocol.
865 ControllerHandle - Controller handle.
866 RemainingDevicePath - Remaining device path.
874 return ConSplitterSupported (
877 &gEfiSimplePointerProtocolGuid
883 ConSplitterAbsolutePointerDriverBindingSupported (
884 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
885 IN EFI_HANDLE ControllerHandle
,
886 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
891 Absolute Pointer Supported Check
894 This - Pointer to protocol.
895 ControllerHandle - Controller handle.
896 RemainingDevicePath - Remaining device path.
904 return ConSplitterSupported (
907 &gEfiAbsolutePointerProtocolGuid
913 ConSplitterConOutDriverBindingSupported (
914 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
915 IN EFI_HANDLE ControllerHandle
,
916 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
921 Console Out Supported Check
924 This - Pointer to protocol.
925 ControllerHandle - Controller handle.
926 RemainingDevicePath - Remaining device path.
934 return ConSplitterSupported (
937 &gEfiConsoleOutDeviceGuid
943 ConSplitterStdErrDriverBindingSupported (
944 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
945 IN EFI_HANDLE ControllerHandle
,
946 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
951 Standard Error Supported Check
954 This - Pointer to protocol.
955 ControllerHandle - Controller handle.
956 RemainingDevicePath - Remaining device path.
964 return ConSplitterSupported (
967 &gEfiStandardErrorDeviceGuid
975 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
976 IN EFI_HANDLE ControllerHandle
,
977 IN EFI_HANDLE ConSplitterVirtualHandle
,
978 IN EFI_GUID
*DeviceGuid
,
979 IN EFI_GUID
*InterfaceGuid
,
985 Start ConSplitter on ControllerHandle, and create the virtual
986 agrogated console device on first call Start for a SimpleTextIn handle.
989 (Standard DriverBinding Protocol Start() function)
992 EFI_ERROR if a SimpleTextIn protocol is not started.
1000 // Check to see whether the handle has the ConsoleInDevice GUID on it
1002 Status
= gBS
->OpenProtocol (
1006 This
->DriverBindingHandle
,
1008 EFI_OPEN_PROTOCOL_BY_DRIVER
1010 if (EFI_ERROR (Status
)) {
1014 Status
= gBS
->OpenProtocol (
1018 This
->DriverBindingHandle
,
1019 ConSplitterVirtualHandle
,
1020 EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
1022 if (EFI_ERROR (Status
)) {
1026 return gBS
->OpenProtocol (
1030 This
->DriverBindingHandle
,
1031 ConSplitterVirtualHandle
,
1032 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1038 ConSplitterConInDriverBindingStart (
1039 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1040 IN EFI_HANDLE ControllerHandle
,
1041 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
1045 Routine Description:
1046 Start ConSplitter on ControllerHandle, and create the virtual
1047 agrogated console device on first call Start for a SimpleTextIn handle.
1050 This - Pointer to protocol.
1051 ControllerHandle - Controller handle.
1052 RemainingDevicePath - Remaining device path.
1057 EFI_ERROR if a SimpleTextIn protocol is not started.
1062 EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*TextIn
;
1063 EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*TextInEx
;
1066 // Start ConSplitter on ControllerHandle, and create the virtual
1067 // agrogated console device on first call Start for a SimpleTextIn handle.
1069 Status
= ConSplitterStart (
1072 mConIn
.VirtualHandle
,
1073 &gEfiConsoleInDeviceGuid
,
1074 &gEfiSimpleTextInProtocolGuid
,
1077 if (EFI_ERROR (Status
)) {
1081 Status
= ConSplitterTextInAddDevice (&mConIn
, TextIn
);
1082 if (EFI_ERROR (Status
)) {
1086 Status
= gBS
->OpenProtocol (
1088 &gEfiSimpleTextInputExProtocolGuid
,
1089 (VOID
**) &TextInEx
,
1090 This
->DriverBindingHandle
,
1091 mConIn
.VirtualHandle
,
1092 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1094 if (EFI_ERROR (Status
)) {
1098 Status
= ConSplitterTextInExAddDevice (&mConIn
, TextInEx
);
1105 ConSplitterSimplePointerDriverBindingStart (
1106 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1107 IN EFI_HANDLE ControllerHandle
,
1108 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
1112 Routine Description:
1113 Start ConSplitter on ControllerHandle, and create the virtual
1114 agrogated console device on first call Start for a SimpleTextIn handle.
1117 This - Pointer to protocol.
1118 ControllerHandle - Controller handle.
1119 RemainingDevicePath - Remaining device path.
1123 EFI_ERROR if a SimpleTextIn protocol is not started.
1128 EFI_SIMPLE_POINTER_PROTOCOL
*SimplePointer
;
1130 Status
= ConSplitterStart (
1133 mConIn
.VirtualHandle
,
1134 &gEfiSimplePointerProtocolGuid
,
1135 &gEfiSimplePointerProtocolGuid
,
1136 (VOID
**) &SimplePointer
1138 if (EFI_ERROR (Status
)) {
1142 return ConSplitterSimplePointerAddDevice (&mConIn
, SimplePointer
);
1147 ConSplitterAbsolutePointerDriverBindingStart (
1148 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1149 IN EFI_HANDLE ControllerHandle
,
1150 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
1154 Routine Description:
1155 Start ConSplitter on ControllerHandle, and create the virtual
1156 agrogated console device on first call Start for a ConIn handle.
1159 This - Pointer to protocol.
1160 ControllerHandle - Controller handle.
1161 RemainingDevicePath - Remaining device path.
1165 EFI_ERROR if a AbsolutePointer protocol is not started.
1170 EFI_ABSOLUTE_POINTER_PROTOCOL
*AbsolutePointer
;
1172 Status
= ConSplitterStart (
1175 mConIn
.VirtualHandle
,
1176 &gEfiAbsolutePointerProtocolGuid
,
1177 &gEfiAbsolutePointerProtocolGuid
,
1178 (VOID
**) &AbsolutePointer
1181 if (EFI_ERROR (Status
)) {
1185 return ConSplitterAbsolutePointerAddDevice (&mConIn
, AbsolutePointer
);
1190 ConSplitterConOutDriverBindingStart (
1191 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1192 IN EFI_HANDLE ControllerHandle
,
1193 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
1197 Routine Description:
1198 Start ConSplitter on ControllerHandle, and create the virtual
1199 agrogated console device on first call Start for a SimpleTextIn handle.
1202 This - Pointer to protocol.
1203 ControllerHandle - Controller handle.
1204 RemainingDevicePath - Remaining device path.
1207 EFI_ERROR if a SimpleTextIn protocol is not started.
1212 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
;
1213 EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
;
1214 EFI_UGA_DRAW_PROTOCOL
*UgaDraw
;
1216 Status
= ConSplitterStart (
1219 mConOut
.VirtualHandle
,
1220 &gEfiConsoleOutDeviceGuid
,
1221 &gEfiSimpleTextOutProtocolGuid
,
1224 if (EFI_ERROR (Status
)) {
1228 // Try to Open Graphics Output protocol
1230 Status
= gBS
->OpenProtocol (
1232 &gEfiGraphicsOutputProtocolGuid
,
1233 (VOID
**) &GraphicsOutput
,
1234 This
->DriverBindingHandle
,
1235 mConOut
.VirtualHandle
,
1236 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1238 if (EFI_ERROR (Status
)) {
1239 GraphicsOutput
= NULL
;
1242 // Open UGA_DRAW protocol
1244 Status
= gBS
->OpenProtocol (
1246 &gEfiUgaDrawProtocolGuid
,
1248 This
->DriverBindingHandle
,
1249 mConOut
.VirtualHandle
,
1250 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1252 if (EFI_ERROR (Status
)) {
1256 // If both ConOut and StdErr incorporate the same Text Out device,
1257 // their MaxMode and QueryData should be the intersection of both.
1259 Status
= ConSplitterTextOutAddDevice (&mConOut
, TextOut
, GraphicsOutput
, UgaDraw
);
1260 ConSplitterTextOutSetAttribute (&mConOut
.TextOut
, EFI_TEXT_ATTR (EFI_LIGHTGRAY
, EFI_BLACK
));
1262 if (FeaturePcdGet (PcdConOutUgaSupport
)) {
1264 // Match the UGA mode data of ConOut with the current mode
1266 if (UgaDraw
!= NULL
) {
1269 &mConOut
.UgaHorizontalResolution
,
1270 &mConOut
.UgaVerticalResolution
,
1271 &mConOut
.UgaColorDepth
,
1272 &mConOut
.UgaRefreshRate
1281 ConSplitterStdErrDriverBindingStart (
1282 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1283 IN EFI_HANDLE ControllerHandle
,
1284 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
1288 Routine Description:
1289 Start ConSplitter on ControllerHandle, and create the virtual
1290 agrogated console device on first call Start for a SimpleTextIn handle.
1293 This - Pointer to protocol.
1294 ControllerHandle - Controller handle.
1295 RemainingDevicePath - Remaining device path.
1298 EFI_ERROR if a SimpleTextIn protocol is not started.
1303 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
;
1305 Status
= ConSplitterStart (
1308 mStdErr
.VirtualHandle
,
1309 &gEfiStandardErrorDeviceGuid
,
1310 &gEfiSimpleTextOutProtocolGuid
,
1313 if (EFI_ERROR (Status
)) {
1317 // If both ConOut and StdErr incorporate the same Text Out device,
1318 // their MaxMode and QueryData should be the intersection of both.
1320 Status
= ConSplitterTextOutAddDevice (&mStdErr
, TextOut
, NULL
, NULL
);
1321 ConSplitterTextOutSetAttribute (&mStdErr
.TextOut
, EFI_TEXT_ATTR (EFI_MAGENTA
, EFI_BLACK
));
1322 if (EFI_ERROR (Status
)) {
1326 if (mStdErr
.CurrentNumberOfConsoles
== 1) {
1327 gST
->StandardErrorHandle
= mStdErr
.VirtualHandle
;
1328 gST
->StdErr
= &mStdErr
.TextOut
;
1330 // Update the CRC32 in the EFI System Table header
1333 gBS
->CalculateCrc32 (
1334 (UINT8
*) &gST
->Hdr
,
1335 gST
->Hdr
.HeaderSize
,
1347 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1348 IN EFI_HANDLE ControllerHandle
,
1349 IN EFI_HANDLE ConSplitterVirtualHandle
,
1350 IN EFI_GUID
*DeviceGuid
,
1351 IN EFI_GUID
*InterfaceGuid
,
1356 Routine Description:
1359 (Standard DriverBinding Protocol Stop() function)
1369 Status
= gBS
->OpenProtocol (
1373 This
->DriverBindingHandle
,
1375 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1377 if (EFI_ERROR (Status
)) {
1381 // close the protocol refered.
1383 gBS
->CloseProtocol (
1386 This
->DriverBindingHandle
,
1387 ConSplitterVirtualHandle
1389 gBS
->CloseProtocol (
1392 This
->DriverBindingHandle
,
1401 ConSplitterConInDriverBindingStop (
1402 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1403 IN EFI_HANDLE ControllerHandle
,
1404 IN UINTN NumberOfChildren
,
1405 IN EFI_HANDLE
*ChildHandleBuffer
1409 Routine Description:
1412 (Standard DriverBinding Protocol Stop() function)
1421 EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*TextIn
;
1423 EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*TextInEx
;
1424 if (NumberOfChildren
== 0) {
1428 Status
= gBS
->OpenProtocol (
1430 &gEfiSimpleTextInputExProtocolGuid
,
1431 (VOID
**) &TextInEx
,
1432 This
->DriverBindingHandle
,
1434 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1436 if (EFI_ERROR (Status
)) {
1440 Status
= ConSplitterTextInExDeleteDevice (&mConIn
, TextInEx
);
1441 if (EFI_ERROR (Status
)) {
1446 Status
= ConSplitterStop (
1449 mConIn
.VirtualHandle
,
1450 &gEfiConsoleInDeviceGuid
,
1451 &gEfiSimpleTextInProtocolGuid
,
1454 if (EFI_ERROR (Status
)) {
1458 // Delete this console input device's data structures.
1460 return ConSplitterTextInDeleteDevice (&mConIn
, TextIn
);
1465 ConSplitterSimplePointerDriverBindingStop (
1466 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1467 IN EFI_HANDLE ControllerHandle
,
1468 IN UINTN NumberOfChildren
,
1469 IN EFI_HANDLE
*ChildHandleBuffer
1473 Routine Description:
1476 (Standard DriverBinding Protocol Stop() function)
1485 EFI_SIMPLE_POINTER_PROTOCOL
*SimplePointer
;
1487 if (NumberOfChildren
== 0) {
1491 Status
= ConSplitterStop (
1494 mConIn
.VirtualHandle
,
1495 &gEfiSimplePointerProtocolGuid
,
1496 &gEfiSimplePointerProtocolGuid
,
1497 (VOID
**) &SimplePointer
1499 if (EFI_ERROR (Status
)) {
1503 // Delete this console input device's data structures.
1505 return ConSplitterSimplePointerDeleteDevice (&mConIn
, SimplePointer
);
1510 ConSplitterAbsolutePointerDriverBindingStop (
1511 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1512 IN EFI_HANDLE ControllerHandle
,
1513 IN UINTN NumberOfChildren
,
1514 IN EFI_HANDLE
*ChildHandleBuffer
1518 Routine Description:
1521 (Standard DriverBinding Protocol Stop() function)
1530 EFI_ABSOLUTE_POINTER_PROTOCOL
*AbsolutePointer
;
1532 if (NumberOfChildren
== 0) {
1536 Status
= ConSplitterStop (
1539 mConIn
.VirtualHandle
,
1540 &gEfiAbsolutePointerProtocolGuid
,
1541 &gEfiAbsolutePointerProtocolGuid
,
1542 (VOID
**) &AbsolutePointer
1544 if (EFI_ERROR (Status
)) {
1548 // Delete this console input device's data structures.
1550 return ConSplitterAbsolutePointerDeleteDevice (&mConIn
, AbsolutePointer
);
1555 ConSplitterConOutDriverBindingStop (
1556 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1557 IN EFI_HANDLE ControllerHandle
,
1558 IN UINTN NumberOfChildren
,
1559 IN EFI_HANDLE
*ChildHandleBuffer
1563 Routine Description:
1566 (Standard DriverBinding Protocol Stop() function)
1575 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
;
1577 if (NumberOfChildren
== 0) {
1581 Status
= ConSplitterStop (
1584 mConOut
.VirtualHandle
,
1585 &gEfiConsoleOutDeviceGuid
,
1586 &gEfiSimpleTextOutProtocolGuid
,
1589 if (EFI_ERROR (Status
)) {
1594 // Delete this console output device's data structures.
1596 return ConSplitterTextOutDeleteDevice (&mConOut
, TextOut
);
1601 ConSplitterStdErrDriverBindingStop (
1602 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1603 IN EFI_HANDLE ControllerHandle
,
1604 IN UINTN NumberOfChildren
,
1605 IN EFI_HANDLE
*ChildHandleBuffer
1609 Routine Description:
1612 (Standard DriverBinding Protocol Stop() function)
1616 EFI_SUCCESS - Complete successfully.
1621 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
;
1623 if (NumberOfChildren
== 0) {
1627 Status
= ConSplitterStop (
1630 mStdErr
.VirtualHandle
,
1631 &gEfiStandardErrorDeviceGuid
,
1632 &gEfiSimpleTextOutProtocolGuid
,
1635 if (EFI_ERROR (Status
)) {
1639 // Delete this console error out device's data structures.
1641 Status
= ConSplitterTextOutDeleteDevice (&mStdErr
, TextOut
);
1642 if (EFI_ERROR (Status
)) {
1646 if (mStdErr
.CurrentNumberOfConsoles
== 0) {
1647 gST
->StandardErrorHandle
= NULL
;
1650 // Update the CRC32 in the EFI System Table header
1653 gBS
->CalculateCrc32 (
1654 (UINT8
*) &gST
->Hdr
,
1655 gST
->Hdr
.HeaderSize
,
1664 ConSplitterGrowBuffer (
1665 IN UINTN SizeOfCount
,
1667 IN OUT VOID
**Buffer
1671 Routine Description:
1672 Take the passed in Buffer of size SizeOfCount and grow the buffer
1673 by MAX (CONSOLE_SPLITTER_CONSOLES_ALLOC_UNIT, MaxGrow) * SizeOfCount
1674 bytes. Copy the current data in Buffer to the new version of Buffer
1675 and free the old version of buffer.
1679 SizeOfCount - Size of element in array
1680 Count - Current number of elements in array
1681 Buffer - Bigger version of passed in Buffer with all the data
1684 EFI_SUCCESS - Buffer size has grown
1685 EFI_OUT_OF_RESOURCES - Could not grow the buffer size
1696 // grow the buffer to new buffer size,
1697 // copy the old buffer's content to the new-size buffer,
1698 // then free the old buffer.
1700 OldSize
= *Count
* SizeOfCount
;
1701 *Count
+= CONSOLE_SPLITTER_CONSOLES_ALLOC_UNIT
;
1702 NewSize
= *Count
* SizeOfCount
;
1704 Ptr
= AllocateZeroPool (NewSize
);
1706 return EFI_OUT_OF_RESOURCES
;
1709 CopyMem (Ptr
, *Buffer
, OldSize
);
1711 if (*Buffer
!= NULL
) {
1721 ConSplitterTextInAddDevice (
1722 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
1723 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*TextIn
1727 Routine Description:
1734 EFI_OUT_OF_RESOURCES
1741 // If the Text In List is full, enlarge it by calling growbuffer().
1743 if (Private
->CurrentNumberOfConsoles
>= Private
->TextInListCount
) {
1744 Status
= ConSplitterGrowBuffer (
1745 sizeof (EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*),
1746 &Private
->TextInListCount
,
1747 (VOID
**) &Private
->TextInList
1749 if (EFI_ERROR (Status
)) {
1750 return EFI_OUT_OF_RESOURCES
;
1754 // Add the new text-in device data structure into the Text In List.
1756 Private
->TextInList
[Private
->CurrentNumberOfConsoles
] = TextIn
;
1757 Private
->CurrentNumberOfConsoles
++;
1760 // Extra CheckEvent added to reduce the double CheckEvent() in UI.c
1762 gBS
->CheckEvent (TextIn
->WaitForKey
);
1768 ConSplitterTextInDeleteDevice (
1769 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
1770 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*TextIn
1774 Routine Description:
1787 // Remove the specified text-in device data structure from the Text In List,
1788 // and rearrange the remaining data structures in the Text In List.
1790 for (Index
= 0; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
1791 if (Private
->TextInList
[Index
] == TextIn
) {
1792 for (Index
= Index
; Index
< Private
->CurrentNumberOfConsoles
- 1; Index
++) {
1793 Private
->TextInList
[Index
] = Private
->TextInList
[Index
+ 1];
1796 Private
->CurrentNumberOfConsoles
--;
1801 return EFI_NOT_FOUND
;
1805 ConSplitterTextInExAddDevice (
1806 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
1807 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*TextInEx
1813 // If the TextInEx List is full, enlarge it by calling growbuffer().
1815 if (Private
->CurrentNumberOfExConsoles
>= Private
->TextInExListCount
) {
1816 Status
= ConSplitterGrowBuffer (
1817 sizeof (EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*),
1818 &Private
->TextInExListCount
,
1819 (VOID
**) &Private
->TextInExList
1821 if (EFI_ERROR (Status
)) {
1822 return EFI_OUT_OF_RESOURCES
;
1826 // Add the new text-in device data structure into the Text In List.
1828 Private
->TextInExList
[Private
->CurrentNumberOfExConsoles
] = TextInEx
;
1829 Private
->CurrentNumberOfExConsoles
++;
1832 // Extra CheckEvent added to reduce the double CheckEvent() in UI.c
1834 gBS
->CheckEvent (TextInEx
->WaitForKeyEx
);
1840 ConSplitterTextInExDeleteDevice (
1841 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
1842 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*TextInEx
1847 // Remove the specified text-in device data structure from the Text In List,
1848 // and rearrange the remaining data structures in the Text In List.
1850 for (Index
= 0; Index
< Private
->CurrentNumberOfExConsoles
; Index
++) {
1851 if (Private
->TextInExList
[Index
] == TextInEx
) {
1852 for (Index
= Index
; Index
< Private
->CurrentNumberOfExConsoles
- 1; Index
++) {
1853 Private
->TextInExList
[Index
] = Private
->TextInExList
[Index
+ 1];
1856 Private
->CurrentNumberOfExConsoles
--;
1861 return EFI_NOT_FOUND
;
1865 ConSplitterSimplePointerAddDevice (
1866 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
1867 IN EFI_SIMPLE_POINTER_PROTOCOL
*SimplePointer
1871 Routine Description:
1877 EFI_OUT_OF_RESOURCES
1885 // If the Text In List is full, enlarge it by calling growbuffer().
1887 if (Private
->CurrentNumberOfPointers
>= Private
->PointerListCount
) {
1888 Status
= ConSplitterGrowBuffer (
1889 sizeof (EFI_SIMPLE_POINTER_PROTOCOL
*),
1890 &Private
->PointerListCount
,
1891 (VOID
**) &Private
->PointerList
1893 if (EFI_ERROR (Status
)) {
1894 return EFI_OUT_OF_RESOURCES
;
1898 // Add the new text-in device data structure into the Text In List.
1900 Private
->PointerList
[Private
->CurrentNumberOfPointers
] = SimplePointer
;
1901 Private
->CurrentNumberOfPointers
++;
1906 ConSplitterSimplePointerDeleteDevice (
1907 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
1908 IN EFI_SIMPLE_POINTER_PROTOCOL
*SimplePointer
1912 Routine Description:
1924 // Remove the specified text-in device data structure from the Text In List,
1925 // and rearrange the remaining data structures in the Text In List.
1927 for (Index
= 0; Index
< Private
->CurrentNumberOfPointers
; Index
++) {
1928 if (Private
->PointerList
[Index
] == SimplePointer
) {
1929 for (Index
= Index
; Index
< Private
->CurrentNumberOfPointers
- 1; Index
++) {
1930 Private
->PointerList
[Index
] = Private
->PointerList
[Index
+ 1];
1933 Private
->CurrentNumberOfPointers
--;
1938 return EFI_NOT_FOUND
;
1942 ConSplitterAbsolutePointerAddDevice (
1943 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
1944 IN EFI_ABSOLUTE_POINTER_PROTOCOL
*AbsolutePointer
1948 Routine Description:
1954 EFI_OUT_OF_RESOURCES
1962 // If the Absolute Pointer List is full, enlarge it by calling growbuffer().
1964 if (Private
->CurrentNumberOfAbsolutePointers
>= Private
->AbsolutePointerListCount
) {
1965 Status
= ConSplitterGrowBuffer (
1966 sizeof (EFI_ABSOLUTE_POINTER_PROTOCOL
*),
1967 &Private
->AbsolutePointerListCount
,
1968 (VOID
**) &Private
->AbsolutePointerList
1970 if (EFI_ERROR (Status
)) {
1971 return EFI_OUT_OF_RESOURCES
;
1975 // Add the new text-in device data structure into the Text In List.
1977 Private
->AbsolutePointerList
[Private
->CurrentNumberOfAbsolutePointers
] = AbsolutePointer
;
1978 Private
->CurrentNumberOfAbsolutePointers
++;
1983 ConSplitterAbsolutePointerDeleteDevice (
1984 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
1985 IN EFI_ABSOLUTE_POINTER_PROTOCOL
*AbsolutePointer
1989 Routine Description:
2001 // Remove the specified text-in device data structure from the Text In List,
2002 // and rearrange the remaining data structures in the Text In List.
2004 for (Index
= 0; Index
< Private
->CurrentNumberOfAbsolutePointers
; Index
++) {
2005 if (Private
->AbsolutePointerList
[Index
] == AbsolutePointer
) {
2006 for (Index
= Index
; Index
< Private
->CurrentNumberOfAbsolutePointers
- 1; Index
++) {
2007 Private
->AbsolutePointerList
[Index
] = Private
->AbsolutePointerList
[Index
+ 1];
2010 Private
->CurrentNumberOfAbsolutePointers
--;
2015 return EFI_NOT_FOUND
;
2020 ConSplitterGrowMapTable (
2021 IN TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
2025 Routine Description:
2038 INT32
*TextOutModeMap
;
2039 INT32
*OldTextOutModeMap
;
2043 NewSize
= Private
->TextOutListCount
* sizeof (INT32
);
2044 OldTextOutModeMap
= Private
->TextOutModeMap
;
2045 TotalSize
= NewSize
* Private
->TextOutQueryDataCount
;
2047 TextOutModeMap
= AllocateZeroPool (TotalSize
);
2048 if (TextOutModeMap
== NULL
) {
2049 return EFI_OUT_OF_RESOURCES
;
2052 SetMem (TextOutModeMap
, TotalSize
, 0xFF);
2053 Private
->TextOutModeMap
= TextOutModeMap
;
2056 // If TextOutList has been enlarged, need to realloc the mode map table
2057 // The mode map table is regarded as a two dimension array.
2060 // 0 ---------> TextOutListCount ----> TextOutListCount
2061 // | -------------------------------------------
2068 // -------------------------------------------
2071 if (OldTextOutModeMap
!= NULL
) {
2073 Size
= Private
->CurrentNumberOfConsoles
* sizeof (INT32
);
2075 SrcAddress
= OldTextOutModeMap
;
2078 // Copy the old data to the new one
2080 while (Index
< Private
->TextOutMode
.MaxMode
) {
2081 CopyMem (TextOutModeMap
, SrcAddress
, Size
);
2082 TextOutModeMap
+= NewSize
;
2087 // Free the old buffer
2089 FreePool (OldTextOutModeMap
);
2097 ConSplitterAddOutputMode (
2098 IN TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
,
2099 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
2103 Routine Description:
2118 MaxMode
= TextOut
->Mode
->MaxMode
;
2119 Private
->TextOutMode
.MaxMode
= MaxMode
;
2122 // Grow the buffer if query data buffer is not large enough to
2123 // hold all the mode supported by the first console.
2125 while (MaxMode
> (INT32
) Private
->TextOutQueryDataCount
) {
2126 Status
= ConSplitterGrowBuffer (
2127 sizeof (TEXT_OUT_SPLITTER_QUERY_DATA
),
2128 &Private
->TextOutQueryDataCount
,
2129 (VOID
**) &Private
->TextOutQueryData
2131 if (EFI_ERROR (Status
)) {
2132 return EFI_OUT_OF_RESOURCES
;
2136 // Allocate buffer for the output mode map
2138 Status
= ConSplitterGrowMapTable (Private
);
2139 if (EFI_ERROR (Status
)) {
2140 return EFI_OUT_OF_RESOURCES
;
2143 // As the first textout device, directly add the mode in to QueryData
2144 // and at the same time record the mapping between QueryData and TextOut.
2148 while (Mode
< MaxMode
) {
2149 TextOut
->QueryMode (
2152 &Private
->TextOutQueryData
[Mode
].Columns
,
2153 &Private
->TextOutQueryData
[Mode
].Rows
2155 Private
->TextOutModeMap
[Index
] = Mode
;
2157 Index
+= Private
->TextOutListCount
;
2165 ConSplitterGetIntersection (
2166 IN INT32
*TextOutModeMap
,
2167 IN INT32
*NewlyAddedMap
,
2168 IN UINTN MapStepSize
,
2169 IN UINTN NewMapStepSize
,
2171 OUT INT32
*CurrentMode
2175 INT32
*CurrentMapEntry
;
2176 INT32
*NextMapEntry
;
2177 INT32 CurrentMaxMode
;
2181 CurrentMapEntry
= TextOutModeMap
;
2182 NextMapEntry
= TextOutModeMap
;
2183 CurrentMaxMode
= *MaxMode
;
2184 Mode
= *CurrentMode
;
2186 while (Index
< CurrentMaxMode
) {
2187 if (*NewlyAddedMap
== -1) {
2189 // This mode is not supported any more. Remove it. Special care
2190 // must be taken as this remove will also affect current mode;
2192 if (Index
== *CurrentMode
) {
2194 } else if (Index
< *CurrentMode
) {
2199 if (CurrentMapEntry
!= NextMapEntry
) {
2200 CopyMem (NextMapEntry
, CurrentMapEntry
, MapStepSize
* sizeof (INT32
));
2203 NextMapEntry
+= MapStepSize
;
2206 CurrentMapEntry
+= MapStepSize
;
2207 NewlyAddedMap
+= NewMapStepSize
;
2211 *CurrentMode
= Mode
;
2218 ConSplitterSyncOutputMode (
2219 IN TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
,
2220 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
2224 Routine Description:
2227 Private - Private data structure.
2228 TextOut - Text Out Protocol.
2235 INT32 CurrentMaxMode
;
2238 INT32
*TextOutModeMap
;
2240 TEXT_OUT_SPLITTER_QUERY_DATA
*TextOutQueryData
;
2246 // Must make sure that current mode won't change even if mode number changes
2248 CurrentMaxMode
= Private
->TextOutMode
.MaxMode
;
2249 TextOutModeMap
= Private
->TextOutModeMap
;
2250 StepSize
= Private
->TextOutListCount
;
2251 TextOutQueryData
= Private
->TextOutQueryData
;
2254 // Query all the mode that the newly added TextOut supports
2257 MapTable
= TextOutModeMap
+ Private
->CurrentNumberOfConsoles
;
2258 while (Mode
< TextOut
->Mode
->MaxMode
) {
2259 TextOut
->QueryMode (TextOut
, Mode
, &Columns
, &Rows
);
2262 // Search the QueryData database to see if they intersects
2265 while (Index
< CurrentMaxMode
) {
2266 if ((TextOutQueryData
[Index
].Rows
== Rows
) && (TextOutQueryData
[Index
].Columns
== Columns
)) {
2267 MapTable
[Index
* StepSize
] = Mode
;
2277 // Now search the TextOutModeMap table to find the intersection of supported
2278 // mode between ConSplitter and the newly added device.
2280 ConSplitterGetIntersection (
2285 &Private
->TextOutMode
.MaxMode
,
2286 &Private
->TextOutMode
.Mode
2294 ConSplitterGetIntersectionBetweenConOutAndStrErr (
2299 Routine Description:
2306 EFI_OUT_OF_RESOURCES
2310 UINTN ConOutNumOfConsoles
;
2311 UINTN StdErrNumOfConsoles
;
2312 TEXT_OUT_AND_GOP_DATA
*ConOutTextOutList
;
2313 TEXT_OUT_AND_GOP_DATA
*StdErrTextOutList
;
2318 INT32 ConOutMaxMode
;
2319 INT32 StdErrMaxMode
;
2322 INT32
*ConOutModeMap
;
2323 INT32
*StdErrModeMap
;
2324 INT32
*ConOutMapTable
;
2325 INT32
*StdErrMapTable
;
2326 TEXT_OUT_SPLITTER_QUERY_DATA
*ConOutQueryData
;
2327 TEXT_OUT_SPLITTER_QUERY_DATA
*StdErrQueryData
;
2328 BOOLEAN FoundTheSameTextOut
;
2329 UINTN ConOutMapTableSize
;
2330 UINTN StdErrMapTableSize
;
2332 ConOutNumOfConsoles
= mConOut
.CurrentNumberOfConsoles
;
2333 StdErrNumOfConsoles
= mStdErr
.CurrentNumberOfConsoles
;
2334 ConOutTextOutList
= mConOut
.TextOutList
;
2335 StdErrTextOutList
= mStdErr
.TextOutList
;
2338 FoundTheSameTextOut
= FALSE
;
2339 while ((Indexi
< ConOutNumOfConsoles
) && (!FoundTheSameTextOut
)) {
2341 while (Indexj
< StdErrNumOfConsoles
) {
2342 if (ConOutTextOutList
->TextOut
== StdErrTextOutList
->TextOut
) {
2343 FoundTheSameTextOut
= TRUE
;
2348 StdErrTextOutList
++;
2352 ConOutTextOutList
++;
2355 if (!FoundTheSameTextOut
) {
2359 // Must make sure that current mode won't change even if mode number changes
2361 ConOutMaxMode
= mConOut
.TextOutMode
.MaxMode
;
2362 ConOutModeMap
= mConOut
.TextOutModeMap
;
2363 ConOutQueryData
= mConOut
.TextOutQueryData
;
2365 StdErrMaxMode
= mStdErr
.TextOutMode
.MaxMode
;
2366 StdErrModeMap
= mStdErr
.TextOutModeMap
;
2367 StdErrQueryData
= mStdErr
.TextOutQueryData
;
2370 // Allocate the map table and set the map table's index to -1.
2372 ConOutMapTableSize
= ConOutMaxMode
* sizeof (INT32
);
2373 ConOutMapTable
= AllocateZeroPool (ConOutMapTableSize
);
2374 if (ConOutMapTable
== NULL
) {
2375 return EFI_OUT_OF_RESOURCES
;
2378 SetMem (ConOutMapTable
, ConOutMapTableSize
, 0xFF);
2380 StdErrMapTableSize
= StdErrMaxMode
* sizeof (INT32
);
2381 StdErrMapTable
= AllocateZeroPool (StdErrMapTableSize
);
2382 if (StdErrMapTable
== NULL
) {
2383 return EFI_OUT_OF_RESOURCES
;
2386 SetMem (StdErrMapTable
, StdErrMapTableSize
, 0xFF);
2389 // Find the intersection of the two set of modes. If they actually intersect, the
2390 // correponding entry in the map table is set to 1.
2393 while (Mode
< ConOutMaxMode
) {
2395 // Search the other's QueryData database to see if they intersect
2398 Rows
= ConOutQueryData
[Mode
].Rows
;
2399 Columns
= ConOutQueryData
[Mode
].Columns
;
2400 while (Index
< StdErrMaxMode
) {
2401 if ((StdErrQueryData
[Index
].Rows
== Rows
) && (StdErrQueryData
[Index
].Columns
== Columns
)) {
2402 ConOutMapTable
[Mode
] = 1;
2403 StdErrMapTable
[Index
] = 1;
2413 // Now search the TextOutModeMap table to find the intersection of supported
2414 // mode between ConSplitter and the newly added device.
2416 ConSplitterGetIntersection (
2419 mConOut
.TextOutListCount
,
2421 &(mConOut
.TextOutMode
.MaxMode
),
2422 &(mConOut
.TextOutMode
.Mode
)
2424 if (mConOut
.TextOutMode
.Mode
< 0) {
2425 mConOut
.TextOut
.SetMode (&(mConOut
.TextOut
), 0);
2428 ConSplitterGetIntersection (
2431 mStdErr
.TextOutListCount
,
2433 &(mStdErr
.TextOutMode
.MaxMode
),
2434 &(mStdErr
.TextOutMode
.Mode
)
2436 if (mStdErr
.TextOutMode
.Mode
< 0) {
2437 mStdErr
.TextOut
.SetMode (&(mStdErr
.TextOut
), 0);
2440 FreePool (ConOutMapTable
);
2441 FreePool (StdErrMapTable
);
2448 ConSplitterAddGraphicsOutputMode (
2449 IN TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
,
2450 IN EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
,
2451 IN EFI_UGA_DRAW_PROTOCOL
*UgaDraw
2455 Routine Description:
2467 TEXT_OUT_GOP_MODE
*Mode
;
2469 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*Info
;
2470 EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE
*CurrentGraphicsOutputMode
;
2471 TEXT_OUT_GOP_MODE
*ModeBuffer
;
2472 TEXT_OUT_GOP_MODE
*MatchedMode
;
2476 if ((GraphicsOutput
== NULL
) && (UgaDraw
== NULL
)) {
2477 return EFI_UNSUPPORTED
;
2480 CurrentGraphicsOutputMode
= Private
->GraphicsOutput
.Mode
;
2482 if (GraphicsOutput
!= NULL
) {
2483 if (Private
->CurrentNumberOfGraphicsOutput
== 0) {
2485 // This is the first Graphics Output device added
2487 CurrentGraphicsOutputMode
->MaxMode
= GraphicsOutput
->Mode
->MaxMode
;
2488 CurrentGraphicsOutputMode
->Mode
= GraphicsOutput
->Mode
->Mode
;
2489 CopyMem (CurrentGraphicsOutputMode
->Info
, GraphicsOutput
->Mode
->Info
, GraphicsOutput
->Mode
->SizeOfInfo
);
2490 CurrentGraphicsOutputMode
->SizeOfInfo
= GraphicsOutput
->Mode
->SizeOfInfo
;
2491 CurrentGraphicsOutputMode
->FrameBufferBase
= GraphicsOutput
->Mode
->FrameBufferBase
;
2492 CurrentGraphicsOutputMode
->FrameBufferSize
= GraphicsOutput
->Mode
->FrameBufferSize
;
2495 // Allocate resource for the private mode buffer
2497 ModeBuffer
= AllocatePool (sizeof (TEXT_OUT_GOP_MODE
) * GraphicsOutput
->Mode
->MaxMode
);
2498 if (ModeBuffer
== NULL
) {
2499 return EFI_OUT_OF_RESOURCES
;
2501 FreePool (Private
->GraphicsOutputModeBuffer
);
2502 Private
->GraphicsOutputModeBuffer
= ModeBuffer
;
2505 // Store all supported display modes to the private mode buffer
2508 for (Index
= 0; Index
< GraphicsOutput
->Mode
->MaxMode
; Index
++) {
2509 Status
= GraphicsOutput
->QueryMode (GraphicsOutput
, (UINT32
) Index
, &SizeOfInfo
, &Info
);
2510 if (EFI_ERROR (Status
)) {
2513 Mode
->HorizontalResolution
= Info
->HorizontalResolution
;
2514 Mode
->VerticalResolution
= Info
->VerticalResolution
;
2520 // Check intersection of display mode
2522 ModeBuffer
= AllocatePool (sizeof (TEXT_OUT_GOP_MODE
) * CurrentGraphicsOutputMode
->MaxMode
);
2523 if (ModeBuffer
== NULL
) {
2524 return EFI_OUT_OF_RESOURCES
;
2527 MatchedMode
= ModeBuffer
;
2528 Mode
= &Private
->GraphicsOutputModeBuffer
[0];
2529 for (Index
= 0; Index
< CurrentGraphicsOutputMode
->MaxMode
; Index
++) {
2532 for (NumberIndex
= 0; NumberIndex
< GraphicsOutput
->Mode
->MaxMode
; NumberIndex
++) {
2533 Status
= GraphicsOutput
->QueryMode (GraphicsOutput
, (UINT32
) NumberIndex
, &SizeOfInfo
, &Info
);
2534 if (EFI_ERROR (Status
)) {
2537 if ((Info
->HorizontalResolution
== Mode
->HorizontalResolution
) &&
2538 (Info
->VerticalResolution
== Mode
->VerticalResolution
)){
2547 CopyMem (MatchedMode
, Mode
, sizeof (TEXT_OUT_GOP_MODE
));
2555 // Drop the old mode buffer, assign it to a new one
2557 FreePool (Private
->GraphicsOutputModeBuffer
);
2558 Private
->GraphicsOutputModeBuffer
= ModeBuffer
;
2561 // Physical frame buffer is no longer available when there are more than one physical GOP devices
2563 CurrentGraphicsOutputMode
->MaxMode
= (UINT32
) (((UINTN
) MatchedMode
- (UINTN
) ModeBuffer
) / sizeof (TEXT_OUT_GOP_MODE
));
2564 CurrentGraphicsOutputMode
->Info
->PixelFormat
= PixelBltOnly
;
2565 ZeroMem (&CurrentGraphicsOutputMode
->Info
->PixelInformation
, sizeof (EFI_PIXEL_BITMASK
));
2566 CurrentGraphicsOutputMode
->SizeOfInfo
= sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
);
2567 CurrentGraphicsOutputMode
->FrameBufferBase
= (EFI_PHYSICAL_ADDRESS
) NULL
;
2568 CurrentGraphicsOutputMode
->FrameBufferSize
= 0;
2572 // Select a prefered Display mode 800x600
2574 for (Index
= 0; Index
< CurrentGraphicsOutputMode
->MaxMode
; Index
++) {
2575 Mode
= &Private
->GraphicsOutputModeBuffer
[Index
];
2576 if ((Mode
->HorizontalResolution
== 800) && (Mode
->VerticalResolution
== 600)) {
2581 // Prefered mode is not found, set to mode 0
2583 if (Index
>= CurrentGraphicsOutputMode
->MaxMode
) {
2588 // Current mode number may need update now, so set it to an invalide mode number
2590 CurrentGraphicsOutputMode
->Mode
= 0xffff;
2593 // For UGA device, it's inconvenient to retrieve all the supported display modes.
2594 // To simplify the implementation, only add one resolution(800x600, 32bit color depth) as defined in UEFI spec
2596 CurrentGraphicsOutputMode
->MaxMode
= 1;
2597 CurrentGraphicsOutputMode
->Info
->Version
= 0;
2598 CurrentGraphicsOutputMode
->Info
->HorizontalResolution
= 800;
2599 CurrentGraphicsOutputMode
->Info
->VerticalResolution
= 600;
2600 CurrentGraphicsOutputMode
->Info
->PixelFormat
= PixelBltOnly
;
2601 CurrentGraphicsOutputMode
->Info
->PixelsPerScanLine
= 800;
2602 CurrentGraphicsOutputMode
->SizeOfInfo
= sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
);
2603 CurrentGraphicsOutputMode
->FrameBufferBase
= (EFI_PHYSICAL_ADDRESS
) NULL
;
2604 CurrentGraphicsOutputMode
->FrameBufferSize
= 0;
2607 // Update the private mode buffer
2609 ModeBuffer
= &Private
->GraphicsOutputModeBuffer
[0];
2610 ModeBuffer
->HorizontalResolution
= 800;
2611 ModeBuffer
->VerticalResolution
= 600;
2614 // Current mode is unknow now, set it to an invalid mode number 0xffff
2616 CurrentGraphicsOutputMode
->Mode
= 0xffff;
2621 // Force GraphicsOutput mode to be set,
2622 // regardless whether the console is in EfiConsoleControlScreenGraphics or EfiConsoleControlScreenText mode
2624 Private
->HardwareNeedsStarting
= TRUE
;
2625 Status
= Private
->GraphicsOutput
.SetMode (&Private
->GraphicsOutput
, (UINT32
) Index
);
2627 Private
->CurrentNumberOfGraphicsOutput
++;
2633 ConSplitterTextOutAddDevice (
2634 IN TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
,
2635 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
,
2636 IN EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
,
2637 IN EFI_UGA_DRAW_PROTOCOL
*UgaDraw
2641 Routine Description:
2652 UINTN CurrentNumOfConsoles
;
2655 TEXT_OUT_AND_GOP_DATA
*TextAndGop
;
2657 Status
= EFI_SUCCESS
;
2658 CurrentNumOfConsoles
= Private
->CurrentNumberOfConsoles
;
2661 // If the Text Out List is full, enlarge it by calling growbuffer().
2663 while (CurrentNumOfConsoles
>= Private
->TextOutListCount
) {
2664 Status
= ConSplitterGrowBuffer (
2665 sizeof (TEXT_OUT_AND_GOP_DATA
),
2666 &Private
->TextOutListCount
,
2667 (VOID
**) &Private
->TextOutList
2669 if (EFI_ERROR (Status
)) {
2670 return EFI_OUT_OF_RESOURCES
;
2673 // Also need to reallocate the TextOutModeMap table
2675 Status
= ConSplitterGrowMapTable (Private
);
2676 if (EFI_ERROR (Status
)) {
2677 return EFI_OUT_OF_RESOURCES
;
2681 TextAndGop
= &Private
->TextOutList
[CurrentNumOfConsoles
];
2683 TextAndGop
->TextOut
= TextOut
;
2684 TextAndGop
->GraphicsOutput
= GraphicsOutput
;
2685 TextAndGop
->UgaDraw
= UgaDraw
;
2687 if ((GraphicsOutput
== NULL
) && (UgaDraw
== NULL
)) {
2689 // If No UGA device then use the ConOut device
2691 TextAndGop
->TextOutEnabled
= TRUE
;
2694 // If UGA device use ConOut device only used if UGA screen is in Text mode
2696 TextAndGop
->TextOutEnabled
= (BOOLEAN
) (Private
->ConsoleOutputMode
== EfiConsoleControlScreenText
);
2699 if (CurrentNumOfConsoles
== 0) {
2701 // Add the first device's output mode to console splitter's mode list
2703 Status
= ConSplitterAddOutputMode (Private
, TextOut
);
2705 ConSplitterSyncOutputMode (Private
, TextOut
);
2708 Private
->CurrentNumberOfConsoles
++;
2711 // Scan both TextOutList, for the intersection TextOut device
2712 // maybe both ConOut and StdErr incorporate the same Text Out
2713 // device in them, thus the output of both should be synced.
2715 ConSplitterGetIntersectionBetweenConOutAndStrErr ();
2717 CurrentMode
= Private
->TextOutMode
.Mode
;
2718 MaxMode
= Private
->TextOutMode
.MaxMode
;
2719 ASSERT (MaxMode
>= 1);
2721 if (FeaturePcdGet (PcdConOutGopSupport
)) {
2722 if ((GraphicsOutput
!= NULL
) || (UgaDraw
!= NULL
)) {
2723 ConSplitterAddGraphicsOutputMode (Private
, GraphicsOutput
, UgaDraw
);
2727 if (Private
->ConsoleOutputMode
== EfiConsoleControlScreenGraphics
&& GraphicsOutput
!= NULL
) {
2729 // We just added a new UGA device in graphics mode
2731 if (FeaturePcdGet (PcdConOutGopSupport
)) {
2732 DevNullGopSync (Private
, TextAndGop
->GraphicsOutput
, TextAndGop
->UgaDraw
);
2733 } else if (FeaturePcdGet (PcdConOutUgaSupport
)) {
2734 DevNullUgaSync (Private
, TextAndGop
->GraphicsOutput
, TextAndGop
->UgaDraw
);
2736 } else if ((CurrentMode
>= 0) && ((GraphicsOutput
!= NULL
) || (UgaDraw
!= NULL
)) && (CurrentMode
< Private
->TextOutMode
.MaxMode
)) {
2738 // The new console supports the same mode of the current console so sync up
2740 DevNullSyncGopStdOut (Private
);
2743 // If ConOut, then set the mode to Mode #0 which us 80 x 25
2745 Private
->TextOut
.SetMode (&Private
->TextOut
, 0);
2752 ConSplitterTextOutDeleteDevice (
2753 IN TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
,
2754 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*TextOut
2758 Routine Description:
2769 UINTN CurrentNumOfConsoles
;
2770 TEXT_OUT_AND_GOP_DATA
*TextOutList
;
2774 // Remove the specified text-out device data structure from the Text out List,
2775 // and rearrange the remaining data structures in the Text out List.
2777 CurrentNumOfConsoles
= Private
->CurrentNumberOfConsoles
;
2778 Index
= (INT32
) CurrentNumOfConsoles
- 1;
2779 TextOutList
= Private
->TextOutList
;
2780 while (Index
>= 0) {
2781 if (TextOutList
->TextOut
== TextOut
) {
2782 CopyMem (TextOutList
, TextOutList
+ 1, sizeof (TEXT_OUT_AND_GOP_DATA
) * Index
);
2783 CurrentNumOfConsoles
--;
2791 // The specified TextOut is not managed by the ConSplitter driver
2794 return EFI_NOT_FOUND
;
2797 if (CurrentNumOfConsoles
== 0) {
2799 // If the number of consoles is zero clear the Dev NULL device
2801 Private
->CurrentNumberOfConsoles
= 0;
2802 Private
->TextOutMode
.MaxMode
= 1;
2803 Private
->TextOutQueryData
[0].Columns
= 80;
2804 Private
->TextOutQueryData
[0].Rows
= 25;
2805 DevNullTextOutSetMode (Private
, 0);
2810 // Max Mode is realy an intersection of the QueryMode command to all
2811 // devices. So we must copy the QueryMode of the first device to
2815 Private
->TextOutQueryData
,
2816 Private
->TextOutQueryDataCount
* sizeof (TEXT_OUT_SPLITTER_QUERY_DATA
)
2819 FreePool (Private
->TextOutModeMap
);
2820 Private
->TextOutModeMap
= NULL
;
2821 TextOutList
= Private
->TextOutList
;
2824 // Add the first TextOut to the QueryData array and ModeMap table
2826 Status
= ConSplitterAddOutputMode (Private
, TextOutList
->TextOut
);
2829 // Now add one by one
2832 Private
->CurrentNumberOfConsoles
= 1;
2834 while ((UINTN
) Index
< CurrentNumOfConsoles
) {
2835 ConSplitterSyncOutputMode (Private
, TextOutList
->TextOut
);
2837 Private
->CurrentNumberOfConsoles
++;
2841 ConSplitterGetIntersectionBetweenConOutAndStrErr ();
2846 // ConSplitter TextIn member functions
2850 ConSplitterTextInReset (
2851 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*This
,
2852 IN BOOLEAN ExtendedVerification
2856 Routine Description:
2857 Reset the input device and optionaly run diagnostics
2860 This - Protocol instance pointer.
2861 ExtendedVerification - Driver may perform diagnostics on reset.
2864 EFI_SUCCESS - The device was reset.
2865 EFI_DEVICE_ERROR - The device is not functioning properly and could
2871 EFI_STATUS ReturnStatus
;
2872 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
2875 Private
= TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
2877 Private
->KeyEventSignalState
= FALSE
;
2880 // return the worst status met
2882 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
2883 Status
= Private
->TextInList
[Index
]->Reset (
2884 Private
->TextInList
[Index
],
2885 ExtendedVerification
2887 if (EFI_ERROR (Status
)) {
2888 ReturnStatus
= Status
;
2892 return ReturnStatus
;
2897 ConSplitterTextInPrivateReadKeyStroke (
2898 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
2899 OUT EFI_INPUT_KEY
*Key
2903 Routine Description:
2904 Reads the next keystroke from the input device. The WaitForKey Event can
2905 be used to test for existance of a keystroke via WaitForEvent () call.
2908 This - Protocol instance pointer.
2909 Key - Driver may perform diagnostics on reset.
2912 EFI_SUCCESS - The keystroke information was returned.
2913 EFI_NOT_READY - There was no keystroke data availiable.
2914 EFI_DEVICE_ERROR - The keydtroke information was not returned due to
2921 EFI_INPUT_KEY CurrentKey
;
2923 Key
->UnicodeChar
= 0;
2924 Key
->ScanCode
= SCAN_NULL
;
2927 // if no physical console input device exists, return EFI_NOT_READY;
2928 // if any physical console input device has key input,
2929 // return the key and EFI_SUCCESS.
2931 for (Index
= 0; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
2932 Status
= Private
->TextInList
[Index
]->ReadKeyStroke (
2933 Private
->TextInList
[Index
],
2936 if (!EFI_ERROR (Status
)) {
2942 return EFI_NOT_READY
;
2946 ConSpliterConssoleControlStdInLocked (
2951 Routine Description:
2952 Return TRUE if StdIn is locked. The ConIn device on the virtual handle is
2953 the only device locked.
2960 FALSE - StdIn working normally
2964 return mConIn
.PasswordEnabled
;
2969 ConSpliterConsoleControlLockStdInEvent (
2975 Routine Description:
2976 This timer event will fire when StdIn is locked. It will check the key
2977 sequence on StdIn to see if it matches the password. Any error in the
2978 password will cause the check to reset. As long a mConIn.PasswordEnabled is
2979 TRUE the StdIn splitter will not report any input.
2982 (Standard EFI_EVENT_NOTIFY)
2991 CHAR16 BackSpaceString
[2];
2992 CHAR16 SpaceString
[2];
2995 Status
= ConSplitterTextInPrivateReadKeyStroke (&mConIn
, &Key
);
2996 if (!EFI_ERROR (Status
)) {
2998 // if it's an ENTER, match password
3000 if ((Key
.UnicodeChar
== CHAR_CARRIAGE_RETURN
) && (Key
.ScanCode
== SCAN_NULL
)) {
3001 mConIn
.PwdAttempt
[mConIn
.PwdIndex
] = CHAR_NULL
;
3002 if (StrCmp (mConIn
.Password
, mConIn
.PwdAttempt
)) {
3004 // Password not match
3006 ConSplitterTextOutOutputString (&mConOut
.TextOut
, (CHAR16
*) L
"\n\rPassword not correct\n\r");
3007 mConIn
.PwdIndex
= 0;
3010 // Key matches password sequence
3012 gBS
->SetTimer (mConIn
.LockEvent
, TimerPeriodic
, 0);
3013 mConIn
.PasswordEnabled
= FALSE
;
3014 Status
= EFI_NOT_READY
;
3016 } else if ((Key
.UnicodeChar
== CHAR_BACKSPACE
) && (Key
.ScanCode
== SCAN_NULL
)) {
3020 if (mConIn
.PwdIndex
> 0) {
3021 BackSpaceString
[0] = CHAR_BACKSPACE
;
3022 BackSpaceString
[1] = 0;
3024 SpaceString
[0] = ' ';
3027 ConSplitterTextOutOutputString (&mConOut
.TextOut
, BackSpaceString
);
3028 ConSplitterTextOutOutputString (&mConOut
.TextOut
, SpaceString
);
3029 ConSplitterTextOutOutputString (&mConOut
.TextOut
, BackSpaceString
);
3033 } else if ((Key
.ScanCode
== SCAN_NULL
) && (Key
.UnicodeChar
>= 32)) {
3035 // If it's not an ENTER, neigher a function key, nor a CTRL-X or ALT-X, record the input
3037 if (mConIn
.PwdIndex
< (MAX_STD_IN_PASSWORD
- 1)) {
3038 if (mConIn
.PwdIndex
== 0) {
3039 ConSplitterTextOutOutputString (&mConOut
.TextOut
, (CHAR16
*) L
"\n\r");
3042 ConSplitterTextOutOutputString (&mConOut
.TextOut
, (CHAR16
*) L
"*");
3043 mConIn
.PwdAttempt
[mConIn
.PwdIndex
] = Key
.UnicodeChar
;
3048 } while (!EFI_ERROR (Status
));
3053 ConSpliterConsoleControlLockStdIn (
3054 IN EFI_CONSOLE_CONTROL_PROTOCOL
*This
,
3059 Routine Description:
3060 If Password is NULL unlock the password state variable and set the event
3061 timer. If the Password is too big return an error. If the Password is valid
3062 Copy the Password and enable state variable and then arm the periodic timer
3067 EFI_SUCCESS - Lock the StdIn device
3068 EFI_INVALID_PARAMETER - Password is NULL
3069 EFI_OUT_OF_RESOURCES - Buffer allocation to store the password fails
3073 if (Password
== NULL
) {
3074 return EFI_INVALID_PARAMETER
;
3077 if (StrLen (Password
) >= MAX_STD_IN_PASSWORD
) {
3079 // Currently have a max password size
3081 return EFI_OUT_OF_RESOURCES
;
3084 // Save the password, initialize state variables and arm event timer
3086 StrCpy (mConIn
.Password
, Password
);
3087 mConIn
.PasswordEnabled
= TRUE
;
3088 mConIn
.PwdIndex
= 0;
3089 gBS
->SetTimer (mConIn
.LockEvent
, TimerPeriodic
, (10000 * 25));
3096 ConSplitterTextInReadKeyStroke (
3097 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*This
,
3098 OUT EFI_INPUT_KEY
*Key
3102 Routine Description:
3103 Reads the next keystroke from the input device. The WaitForKey Event can
3104 be used to test for existance of a keystroke via WaitForEvent () call.
3105 If the ConIn is password locked make it look like no keystroke is availible
3108 This - Protocol instance pointer.
3109 Key - Driver may perform diagnostics on reset.
3112 EFI_SUCCESS - The keystroke information was returned.
3113 EFI_NOT_READY - There was no keystroke data availiable.
3114 EFI_DEVICE_ERROR - The keydtroke information was not returned due to
3119 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3121 Private
= TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
3122 if (Private
->PasswordEnabled
) {
3124 // If StdIn Locked return not ready
3126 return EFI_NOT_READY
;
3129 Private
->KeyEventSignalState
= FALSE
;
3131 return ConSplitterTextInPrivateReadKeyStroke (Private
, Key
);
3136 ConSplitterTextInWaitForKey (
3142 Routine Description:
3143 This event agregates all the events of the ConIn devices in the spliter.
3144 If the ConIn is password locked then return.
3145 If any events of physical ConIn devices are signaled, signal the ConIn
3146 spliter event. This will cause the calling code to call
3147 ConSplitterTextInReadKeyStroke ().
3150 Event - The Event assoicated with callback.
3151 Context - Context registered when Event was created.
3159 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3162 Private
= (TEXT_IN_SPLITTER_PRIVATE_DATA
*) Context
;
3163 if (Private
->PasswordEnabled
) {
3165 // If StdIn Locked return not ready
3171 // if KeyEventSignalState is flagged before, and not cleared by Reset() or ReadKeyStroke()
3173 if (Private
->KeyEventSignalState
) {
3174 gBS
->SignalEvent (Event
);
3178 // if any physical console input device has key input, signal the event.
3180 for (Index
= 0; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
3181 Status
= gBS
->CheckEvent (Private
->TextInList
[Index
]->WaitForKey
);
3182 if (!EFI_ERROR (Status
)) {
3183 gBS
->SignalEvent (Event
);
3184 Private
->KeyEventSignalState
= TRUE
;
3193 IN EFI_KEY_DATA
*RegsiteredData
,
3194 IN EFI_KEY_DATA
*InputData
3198 Routine Description:
3202 RegsiteredData - A pointer to a buffer that is filled in with the keystroke
3203 state data for the key that was registered.
3204 InputData - A pointer to a buffer that is filled in with the keystroke
3205 state data for the key that was pressed.
3208 TRUE - Key be pressed matches a registered key.
3209 FLASE - Match failed.
3213 ASSERT (RegsiteredData
!= NULL
&& InputData
!= NULL
);
3215 if ((RegsiteredData
->Key
.ScanCode
!= InputData
->Key
.ScanCode
) ||
3216 (RegsiteredData
->Key
.UnicodeChar
!= InputData
->Key
.UnicodeChar
)) {
3221 // Assume KeyShiftState/KeyToggleState = 0 in Registered key data means these state could be ignored.
3223 if (RegsiteredData
->KeyState
.KeyShiftState
!= 0 &&
3224 RegsiteredData
->KeyState
.KeyShiftState
!= InputData
->KeyState
.KeyShiftState
) {
3227 if (RegsiteredData
->KeyState
.KeyToggleState
!= 0 &&
3228 RegsiteredData
->KeyState
.KeyToggleState
!= InputData
->KeyState
.KeyToggleState
) {
3237 // Simple Text Input Ex protocol functions
3242 ConSplitterTextInResetEx (
3243 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*This
,
3244 IN BOOLEAN ExtendedVerification
3248 Routine Description:
3249 Reset the input device and optionaly run diagnostics
3252 This - Protocol instance pointer.
3253 ExtendedVerification - Driver may perform diagnostics on reset.
3256 EFI_SUCCESS - The device was reset.
3257 EFI_DEVICE_ERROR - The device is not functioning properly and could
3263 EFI_STATUS ReturnStatus
;
3264 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3267 Private
= TEXT_IN_EX_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
3269 Private
->KeyEventSignalState
= FALSE
;
3272 // return the worst status met
3274 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfExConsoles
; Index
++) {
3275 Status
= Private
->TextInExList
[Index
]->Reset (
3276 Private
->TextInExList
[Index
],
3277 ExtendedVerification
3279 if (EFI_ERROR (Status
)) {
3280 ReturnStatus
= Status
;
3284 return ReturnStatus
;
3290 ConSplitterTextInReadKeyStrokeEx (
3291 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*This
,
3292 OUT EFI_KEY_DATA
*KeyData
3296 Routine Description:
3297 Reads the next keystroke from the input device. The WaitForKey Event can
3298 be used to test for existance of a keystroke via WaitForEvent () call.
3301 This - Protocol instance pointer.
3302 KeyData - A pointer to a buffer that is filled in with the keystroke
3303 state data for the key that was pressed.
3306 EFI_SUCCESS - The keystroke information was returned.
3307 EFI_NOT_READY - There was no keystroke data availiable.
3308 EFI_DEVICE_ERROR - The keystroke information was not returned due to
3310 EFI_INVALID_PARAMETER - KeyData is NULL.
3314 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3317 EFI_KEY_DATA CurrentKeyData
;
3320 if (KeyData
== NULL
) {
3321 return EFI_INVALID_PARAMETER
;
3324 Private
= TEXT_IN_EX_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
3325 if (Private
->PasswordEnabled
) {
3327 // If StdIn Locked return not ready
3329 return EFI_NOT_READY
;
3332 Private
->KeyEventSignalState
= FALSE
;
3334 KeyData
->Key
.UnicodeChar
= 0;
3335 KeyData
->Key
.ScanCode
= SCAN_NULL
;
3338 // if no physical console input device exists, return EFI_NOT_READY;
3339 // if any physical console input device has key input,
3340 // return the key and EFI_SUCCESS.
3342 for (Index
= 0; Index
< Private
->CurrentNumberOfExConsoles
; Index
++) {
3343 Status
= Private
->TextInExList
[Index
]->ReadKeyStrokeEx (
3344 Private
->TextInExList
[Index
],
3347 if (!EFI_ERROR (Status
)) {
3348 CopyMem (KeyData
, &CurrentKeyData
, sizeof (CurrentKeyData
));
3353 return EFI_NOT_READY
;
3358 ConSplitterTextInSetState (
3359 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*This
,
3360 IN EFI_KEY_TOGGLE_STATE
*KeyToggleState
3364 Routine Description:
3365 Set certain state for the input device.
3368 This - Protocol instance pointer.
3369 KeyToggleState - A pointer to the EFI_KEY_TOGGLE_STATE to set the
3370 state for the input device.
3373 EFI_SUCCESS - The device state was set successfully.
3374 EFI_DEVICE_ERROR - The device is not functioning correctly and could
3375 not have the setting adjusted.
3376 EFI_UNSUPPORTED - The device does not have the ability to set its state.
3377 EFI_INVALID_PARAMETER - KeyToggleState is NULL.
3381 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3385 if (KeyToggleState
== NULL
) {
3386 return EFI_INVALID_PARAMETER
;
3389 Private
= TEXT_IN_EX_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
3392 // if no physical console input device exists, return EFI_SUCCESS;
3393 // otherwise return the status of setting state of physical console input device
3395 for (Index
= 0; Index
< Private
->CurrentNumberOfExConsoles
; Index
++) {
3396 Status
= Private
->TextInExList
[Index
]->SetState (
3397 Private
->TextInExList
[Index
],
3400 if (EFI_ERROR (Status
)) {
3411 ConSplitterTextInRegisterKeyNotify (
3412 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*This
,
3413 IN EFI_KEY_DATA
*KeyData
,
3414 IN EFI_KEY_NOTIFY_FUNCTION KeyNotificationFunction
,
3415 OUT EFI_HANDLE
*NotifyHandle
3419 Routine Description:
3420 Register a notification function for a particular keystroke for the input device.
3423 This - Protocol instance pointer.
3424 KeyData - A pointer to a buffer that is filled in with the keystroke
3425 information data for the key that was pressed.
3426 KeyNotificationFunction - Points to the function to be called when the key
3427 sequence is typed specified by KeyData.
3428 NotifyHandle - Points to the unique handle assigned to the registered notification.
3431 EFI_SUCCESS - The notification function was registered successfully.
3432 EFI_OUT_OF_RESOURCES - Unable to allocate resources for necesssary data structures.
3433 EFI_INVALID_PARAMETER - KeyData or NotifyHandle is NULL.
3437 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3440 TEXT_IN_EX_SPLITTER_NOTIFY
*NewNotify
;
3442 TEXT_IN_EX_SPLITTER_NOTIFY
*CurrentNotify
;
3445 if (KeyData
== NULL
|| NotifyHandle
== NULL
|| KeyNotificationFunction
== NULL
) {
3446 return EFI_INVALID_PARAMETER
;
3449 Private
= TEXT_IN_EX_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
3452 // if no physical console input device exists,
3453 // return EFI_SUCCESS directly.
3455 if (Private
->CurrentNumberOfExConsoles
<= 0) {
3460 // Return EFI_SUCCESS if the (KeyData, NotificationFunction) is already registered.
3462 for (Link
= Private
->NotifyList
.ForwardLink
; Link
!= &Private
->NotifyList
; Link
= Link
->ForwardLink
) {
3463 CurrentNotify
= CR (
3465 TEXT_IN_EX_SPLITTER_NOTIFY
,
3467 TEXT_IN_EX_SPLITTER_NOTIFY_SIGNATURE
3469 if (IsKeyRegistered (&CurrentNotify
->KeyData
, KeyData
)) {
3470 if (CurrentNotify
->KeyNotificationFn
== KeyNotificationFunction
) {
3471 *NotifyHandle
= CurrentNotify
->NotifyHandle
;
3478 // Allocate resource to save the notification function
3480 NewNotify
= (TEXT_IN_EX_SPLITTER_NOTIFY
*) AllocateZeroPool (sizeof (TEXT_IN_EX_SPLITTER_NOTIFY
));
3481 if (NewNotify
== NULL
) {
3482 return EFI_OUT_OF_RESOURCES
;
3484 NewNotify
->NotifyHandleList
= (EFI_HANDLE
*) AllocateZeroPool (sizeof (EFI_HANDLE
) * Private
->CurrentNumberOfExConsoles
);
3485 if (NewNotify
->NotifyHandleList
== NULL
) {
3486 gBS
->FreePool (NewNotify
);
3487 return EFI_OUT_OF_RESOURCES
;
3489 NewNotify
->Signature
= TEXT_IN_EX_SPLITTER_NOTIFY_SIGNATURE
;
3490 NewNotify
->KeyNotificationFn
= KeyNotificationFunction
;
3491 CopyMem (&NewNotify
->KeyData
, KeyData
, sizeof (KeyData
));
3494 // Return the wrong status of registering key notify of
3495 // physical console input device if meet problems
3497 for (Index
= 0; Index
< Private
->CurrentNumberOfExConsoles
; Index
++) {
3498 Status
= Private
->TextInExList
[Index
]->RegisterKeyNotify (
3499 Private
->TextInExList
[Index
],
3501 KeyNotificationFunction
,
3502 &NewNotify
->NotifyHandleList
[Index
]
3504 if (EFI_ERROR (Status
)) {
3505 gBS
->FreePool (NewNotify
->NotifyHandleList
);
3506 gBS
->FreePool (NewNotify
);
3512 // Use gSimpleTextInExNotifyGuid to get a valid EFI_HANDLE
3514 Status
= gBS
->InstallMultipleProtocolInterfaces (
3515 &NewNotify
->NotifyHandle
,
3516 &gSimpleTextInExNotifyGuid
,
3520 ASSERT_EFI_ERROR (Status
);
3522 InsertTailList (&mConIn
.NotifyList
, &NewNotify
->NotifyEntry
);
3524 *NotifyHandle
= NewNotify
->NotifyHandle
;
3532 ConSplitterTextInUnregisterKeyNotify (
3533 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL
*This
,
3534 IN EFI_HANDLE NotificationHandle
3538 Routine Description:
3539 Remove a registered notification function from a particular keystroke.
3542 This - Protocol instance pointer.
3543 NotificationHandle - The handle of the notification function being unregistered.
3546 EFI_SUCCESS - The notification function was unregistered successfully.
3547 EFI_INVALID_PARAMETER - The NotificationHandle is invalid.
3548 EFI_NOT_FOUND - Can not find the matching entry in database.
3552 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3555 TEXT_IN_EX_SPLITTER_NOTIFY
*CurrentNotify
;
3558 if (NotificationHandle
== NULL
) {
3559 return EFI_INVALID_PARAMETER
;
3562 Status
= gBS
->OpenProtocol (
3564 &gSimpleTextInExNotifyGuid
,
3568 EFI_OPEN_PROTOCOL_TEST_PROTOCOL
3570 if (EFI_ERROR (Status
)) {
3571 return EFI_INVALID_PARAMETER
;
3574 Private
= TEXT_IN_EX_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
3577 // if no physical console input device exists,
3578 // return EFI_SUCCESS directly.
3580 if (Private
->CurrentNumberOfExConsoles
<= 0) {
3584 for (Link
= Private
->NotifyList
.ForwardLink
; Link
!= &Private
->NotifyList
; Link
= Link
->ForwardLink
) {
3585 CurrentNotify
= CR (Link
, TEXT_IN_EX_SPLITTER_NOTIFY
, NotifyEntry
, TEXT_IN_EX_SPLITTER_NOTIFY_SIGNATURE
);
3586 if (CurrentNotify
->NotifyHandle
== NotificationHandle
) {
3587 for (Index
= 0; Index
< Private
->CurrentNumberOfExConsoles
; Index
++) {
3588 Status
= Private
->TextInExList
[Index
]->UnregisterKeyNotify (
3589 Private
->TextInExList
[Index
],
3590 CurrentNotify
->NotifyHandleList
[Index
]
3592 if (EFI_ERROR (Status
)) {
3596 RemoveEntryList (&CurrentNotify
->NotifyEntry
);
3597 Status
= gBS
->UninstallMultipleProtocolInterfaces (
3598 CurrentNotify
->NotifyHandle
,
3599 &gSimpleTextInExNotifyGuid
,
3603 ASSERT_EFI_ERROR (Status
);
3604 gBS
->FreePool (CurrentNotify
->NotifyHandleList
);
3605 gBS
->FreePool (CurrentNotify
);
3610 return EFI_NOT_FOUND
;
3616 ConSplitterSimplePointerReset (
3617 IN EFI_SIMPLE_POINTER_PROTOCOL
*This
,
3618 IN BOOLEAN ExtendedVerification
3622 Routine Description:
3623 Reset the input device and optionaly run diagnostics
3626 This - Protocol instance pointer.
3627 ExtendedVerification - Driver may perform diagnostics on reset.
3630 EFI_SUCCESS - The device was reset.
3631 EFI_DEVICE_ERROR - The device is not functioning properly and could
3637 EFI_STATUS ReturnStatus
;
3638 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3641 Private
= TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_SIMPLE_POINTER_THIS (This
);
3643 Private
->InputEventSignalState
= FALSE
;
3645 if (Private
->CurrentNumberOfPointers
== 0) {
3649 // return the worst status met
3651 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfPointers
; Index
++) {
3652 Status
= Private
->PointerList
[Index
]->Reset (
3653 Private
->PointerList
[Index
],
3654 ExtendedVerification
3656 if (EFI_ERROR (Status
)) {
3657 ReturnStatus
= Status
;
3661 return ReturnStatus
;
3667 ConSplitterSimplePointerPrivateGetState (
3668 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
3669 IN OUT EFI_SIMPLE_POINTER_STATE
*State
3673 Routine Description:
3674 Reads the next keystroke from the input device. The WaitForKey Event can
3675 be used to test for existance of a keystroke via WaitForEvent () call.
3678 This - Protocol instance pointer.
3682 EFI_SUCCESS - The keystroke information was returned.
3683 EFI_NOT_READY - There was no keystroke data availiable.
3684 EFI_DEVICE_ERROR - The keydtroke information was not returned due to
3690 EFI_STATUS ReturnStatus
;
3692 EFI_SIMPLE_POINTER_STATE CurrentState
;
3694 State
->RelativeMovementX
= 0;
3695 State
->RelativeMovementY
= 0;
3696 State
->RelativeMovementZ
= 0;
3697 State
->LeftButton
= FALSE
;
3698 State
->RightButton
= FALSE
;
3701 // if no physical console input device exists, return EFI_NOT_READY;
3702 // if any physical console input device has key input,
3703 // return the key and EFI_SUCCESS.
3705 ReturnStatus
= EFI_NOT_READY
;
3706 for (Index
= 0; Index
< Private
->CurrentNumberOfPointers
; Index
++) {
3708 Status
= Private
->PointerList
[Index
]->GetState (
3709 Private
->PointerList
[Index
],
3712 if (!EFI_ERROR (Status
)) {
3713 if (ReturnStatus
== EFI_NOT_READY
) {
3714 ReturnStatus
= EFI_SUCCESS
;
3717 if (CurrentState
.LeftButton
) {
3718 State
->LeftButton
= TRUE
;
3721 if (CurrentState
.RightButton
) {
3722 State
->RightButton
= TRUE
;
3725 if (CurrentState
.RelativeMovementX
!= 0 && Private
->PointerList
[Index
]->Mode
->ResolutionX
!= 0) {
3726 State
->RelativeMovementX
+= (CurrentState
.RelativeMovementX
* (INT32
) Private
->SimplePointerMode
.ResolutionX
) / (INT32
) Private
->PointerList
[Index
]->Mode
->ResolutionX
;
3729 if (CurrentState
.RelativeMovementY
!= 0 && Private
->PointerList
[Index
]->Mode
->ResolutionY
!= 0) {
3730 State
->RelativeMovementY
+= (CurrentState
.RelativeMovementY
* (INT32
) Private
->SimplePointerMode
.ResolutionY
) / (INT32
) Private
->PointerList
[Index
]->Mode
->ResolutionY
;
3733 if (CurrentState
.RelativeMovementZ
!= 0 && Private
->PointerList
[Index
]->Mode
->ResolutionZ
!= 0) {
3734 State
->RelativeMovementZ
+= (CurrentState
.RelativeMovementZ
* (INT32
) Private
->SimplePointerMode
.ResolutionZ
) / (INT32
) Private
->PointerList
[Index
]->Mode
->ResolutionZ
;
3736 } else if (Status
== EFI_DEVICE_ERROR
) {
3737 ReturnStatus
= EFI_DEVICE_ERROR
;
3741 return ReturnStatus
;
3746 ConSplitterSimplePointerGetState (
3747 IN EFI_SIMPLE_POINTER_PROTOCOL
*This
,
3748 IN OUT EFI_SIMPLE_POINTER_STATE
*State
3752 Routine Description:
3753 Reads the next keystroke from the input device. The WaitForKey Event can
3754 be used to test for existance of a keystroke via WaitForEvent () call.
3755 If the ConIn is password locked make it look like no keystroke is availible
3758 This - Protocol instance pointer.
3762 EFI_SUCCESS - The keystroke information was returned.
3763 EFI_NOT_READY - There was no keystroke data availiable.
3764 EFI_DEVICE_ERROR - The keydtroke information was not returned due to
3769 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3771 Private
= TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_SIMPLE_POINTER_THIS (This
);
3772 if (Private
->PasswordEnabled
) {
3774 // If StdIn Locked return not ready
3776 return EFI_NOT_READY
;
3779 Private
->InputEventSignalState
= FALSE
;
3781 return ConSplitterSimplePointerPrivateGetState (Private
, State
);
3786 ConSplitterSimplePointerWaitForInput (
3792 Routine Description:
3793 This event agregates all the events of the ConIn devices in the spliter.
3794 If the ConIn is password locked then return.
3795 If any events of physical ConIn devices are signaled, signal the ConIn
3796 spliter event. This will cause the calling code to call
3797 ConSplitterTextInReadKeyStroke ().
3800 Event - The Event assoicated with callback.
3801 Context - Context registered when Event was created.
3809 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3812 Private
= (TEXT_IN_SPLITTER_PRIVATE_DATA
*) Context
;
3813 if (Private
->PasswordEnabled
) {
3815 // If StdIn Locked return not ready
3821 // if InputEventSignalState is flagged before, and not cleared by Reset() or ReadKeyStroke()
3823 if (Private
->InputEventSignalState
) {
3824 gBS
->SignalEvent (Event
);
3828 // if any physical console input device has key input, signal the event.
3830 for (Index
= 0; Index
< Private
->CurrentNumberOfPointers
; Index
++) {
3831 Status
= gBS
->CheckEvent (Private
->PointerList
[Index
]->WaitForInput
);
3832 if (!EFI_ERROR (Status
)) {
3833 gBS
->SignalEvent (Event
);
3834 Private
->InputEventSignalState
= TRUE
;
3840 // Absolute Pointer Protocol functions
3845 ConSplitterAbsolutePointerReset (
3846 IN EFI_ABSOLUTE_POINTER_PROTOCOL
*This
,
3847 IN BOOLEAN ExtendedVerification
3851 Routine Description:
3852 Resets the pointer device hardware.
3855 This - Protocol instance pointer.
3856 ExtendedVerification - Driver may perform diagnostics on reset.
3859 EFI_SUCCESS - The device was reset.
3860 EFI_DEVICE_ERROR - The device is not functioning correctly and could
3866 EFI_STATUS ReturnStatus
;
3867 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3870 Private
= TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_ABSOLUTE_POINTER_THIS (This
);
3872 Private
->AbsoluteInputEventSignalState
= FALSE
;
3874 if (Private
->CurrentNumberOfAbsolutePointers
== 0) {
3878 // return the worst status met
3880 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfAbsolutePointers
; Index
++) {
3881 Status
= Private
->AbsolutePointerList
[Index
]->Reset (
3882 Private
->AbsolutePointerList
[Index
],
3883 ExtendedVerification
3885 if (EFI_ERROR (Status
)) {
3886 ReturnStatus
= Status
;
3890 return ReturnStatus
;
3895 ConSplitterAbsolutePointerGetState (
3896 IN EFI_ABSOLUTE_POINTER_PROTOCOL
*This
,
3897 IN OUT EFI_ABSOLUTE_POINTER_STATE
*State
3901 Routine Description:
3902 Retrieves the current state of a pointer device.
3905 This - Protocol instance pointer.
3906 State - A pointer to the state information on the pointer device.
3909 EFI_SUCCESS - The state of the pointer device was returned in State..
3910 EFI_NOT_READY - The state of the pointer device has not changed since the last call to
3912 EFI_DEVICE_ERROR - A device error occurred while attempting to retrieve the pointer
3913 device's current state.
3916 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
3918 EFI_STATUS ReturnStatus
;
3920 EFI_ABSOLUTE_POINTER_STATE CurrentState
;
3923 Private
= TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_ABSOLUTE_POINTER_THIS (This
);
3924 if (Private
->PasswordEnabled
) {
3926 // If StdIn Locked return not ready
3928 return EFI_NOT_READY
;
3931 Private
->AbsoluteInputEventSignalState
= FALSE
;
3933 State
->CurrentX
= 0;
3934 State
->CurrentY
= 0;
3935 State
->CurrentZ
= 0;
3936 State
->ActiveButtons
= 0;
3939 // if no physical pointer device exists, return EFI_NOT_READY;
3940 // if any physical pointer device has changed state,
3941 // return the state and EFI_SUCCESS.
3943 ReturnStatus
= EFI_NOT_READY
;
3944 for (Index
= 0; Index
< Private
->CurrentNumberOfAbsolutePointers
; Index
++) {
3946 Status
= Private
->AbsolutePointerList
[Index
]->GetState (
3947 Private
->AbsolutePointerList
[Index
],
3950 if (!EFI_ERROR (Status
)) {
3951 if (ReturnStatus
== EFI_NOT_READY
) {
3952 ReturnStatus
= EFI_SUCCESS
;
3955 State
->ActiveButtons
= CurrentState
.ActiveButtons
;
3957 if (!(Private
->AbsolutePointerMode
.AbsoluteMinX
== 0 && Private
->AbsolutePointerMode
.AbsoluteMaxX
== 0)) {
3958 State
->CurrentX
= CurrentState
.CurrentX
;
3960 if (!(Private
->AbsolutePointerMode
.AbsoluteMinY
== 0 && Private
->AbsolutePointerMode
.AbsoluteMaxY
== 0)) {
3961 State
->CurrentY
= CurrentState
.CurrentY
;
3963 if (!(Private
->AbsolutePointerMode
.AbsoluteMinZ
== 0 && Private
->AbsolutePointerMode
.AbsoluteMaxZ
== 0)) {
3964 State
->CurrentZ
= CurrentState
.CurrentZ
;
3967 } else if (Status
== EFI_DEVICE_ERROR
) {
3968 ReturnStatus
= EFI_DEVICE_ERROR
;
3972 return ReturnStatus
;
3977 ConSplitterAbsolutePointerWaitForInput (
3983 Routine Description:
3984 This event agregates all the events of the pointer devices in the splitter.
3985 If the ConIn is password locked then return.
3986 If any events of physical pointer devices are signaled, signal the pointer
3987 splitter event. This will cause the calling code to call
3988 ConSplitterAbsolutePointerGetState ().
3991 Event - The Event assoicated with callback.
3992 Context - Context registered when Event was created.
4000 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
4003 Private
= (TEXT_IN_SPLITTER_PRIVATE_DATA
*) Context
;
4004 if (Private
->PasswordEnabled
) {
4006 // If StdIn Locked return not ready
4012 // if AbsoluteInputEventSignalState is flagged before,
4013 // and not cleared by Reset() or GetState(), signal it
4015 if (Private
->AbsoluteInputEventSignalState
) {
4016 gBS
->SignalEvent (Event
);
4020 // if any physical console input device has key input, signal the event.
4022 for (Index
= 0; Index
< Private
->CurrentNumberOfAbsolutePointers
; Index
++) {
4023 Status
= gBS
->CheckEvent (Private
->AbsolutePointerList
[Index
]->WaitForInput
);
4024 if (!EFI_ERROR (Status
)) {
4025 gBS
->SignalEvent (Event
);
4026 Private
->AbsoluteInputEventSignalState
= TRUE
;
4033 ConSplitterTextOutReset (
4034 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4035 IN BOOLEAN ExtendedVerification
4039 Routine Description:
4040 Reset the text output device hardware and optionaly run diagnostics
4043 This - Protocol instance pointer.
4044 ExtendedVerification - Driver may perform more exhaustive verfication
4045 operation of the device during reset.
4048 EFI_SUCCESS - The text output device was reset.
4049 EFI_DEVICE_ERROR - The text output device is not functioning correctly and
4055 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4057 EFI_STATUS ReturnStatus
;
4059 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4062 // return the worst status met
4064 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
4066 if (Private
->TextOutList
[Index
].TextOutEnabled
) {
4068 Status
= Private
->TextOutList
[Index
].TextOut
->Reset (
4069 Private
->TextOutList
[Index
].TextOut
,
4070 ExtendedVerification
4072 if (EFI_ERROR (Status
)) {
4073 ReturnStatus
= Status
;
4078 This
->SetAttribute (This
, EFI_TEXT_ATTR (This
->Mode
->Attribute
& 0x0F, EFI_BACKGROUND_BLACK
));
4080 Status
= DevNullTextOutSetMode (Private
, 0);
4081 if (EFI_ERROR (Status
)) {
4082 ReturnStatus
= Status
;
4085 return ReturnStatus
;
4090 ConSplitterTextOutOutputString (
4091 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4096 Routine Description:
4097 Write a Unicode string to the output device.
4100 This - Protocol instance pointer.
4101 String - The NULL-terminated Unicode string to be displayed on the output
4102 device(s). All output devices must also support the Unicode
4103 drawing defined in this file.
4106 EFI_SUCCESS - The string was output to the device.
4107 EFI_DEVICE_ERROR - The device reported an error while attempting to output
4109 EFI_UNSUPPORTED - The output device's mode is not currently in a
4111 EFI_WARN_UNKNOWN_GLYPH - This warning code indicates that some of the
4112 characters in the Unicode string could not be
4113 rendered and were skipped.
4118 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4120 UINTN BackSpaceCount
;
4121 EFI_STATUS ReturnStatus
;
4122 CHAR16
*TargetString
;
4124 This
->SetAttribute (This
, This
->Mode
->Attribute
);
4126 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4129 for (TargetString
= WString
; *TargetString
; TargetString
++) {
4130 if (*TargetString
== CHAR_BACKSPACE
) {
4136 if (BackSpaceCount
== 0) {
4137 TargetString
= WString
;
4139 TargetString
= AllocatePool (sizeof (CHAR16
) * (StrLen (WString
) + BackSpaceCount
+ 1));
4140 StrCpy (TargetString
, WString
);
4143 // return the worst status met
4145 Status
= DevNullTextOutOutputString (Private
, TargetString
);
4146 if (EFI_ERROR (Status
)) {
4147 ReturnStatus
= Status
;
4150 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
4152 if (Private
->TextOutList
[Index
].TextOutEnabled
) {
4153 Status
= Private
->TextOutList
[Index
].TextOut
->OutputString (
4154 Private
->TextOutList
[Index
].TextOut
,
4157 if (EFI_ERROR (Status
)) {
4158 ReturnStatus
= Status
;
4163 if (BackSpaceCount
) {
4164 FreePool (TargetString
);
4167 return ReturnStatus
;
4172 ConSplitterTextOutTestString (
4173 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4178 Routine Description:
4179 Verifies that all characters in a Unicode string can be output to the
4183 This - Protocol instance pointer.
4184 String - The NULL-terminated Unicode string to be examined for the output
4188 EFI_SUCCESS - The device(s) are capable of rendering the output string.
4189 EFI_UNSUPPORTED - Some of the characters in the Unicode string cannot be
4190 rendered by one or more of the output devices mapped
4196 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4198 EFI_STATUS ReturnStatus
;
4200 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4203 // return the worst status met
4205 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
4206 if (Private
->TextOutList
[Index
].TextOutEnabled
) {
4207 Status
= Private
->TextOutList
[Index
].TextOut
->TestString (
4208 Private
->TextOutList
[Index
].TextOut
,
4211 if (EFI_ERROR (Status
)) {
4212 ReturnStatus
= Status
;
4217 // There is no DevNullTextOutTestString () since a Unicode buffer would
4218 // always return EFI_SUCCESS.
4219 // ReturnStatus will be EFI_SUCCESS if no consoles are present
4221 return ReturnStatus
;
4226 ConSplitterTextOutQueryMode (
4227 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4228 IN UINTN ModeNumber
,
4234 Routine Description:
4235 Returns information for an available text mode that the output device(s)
4239 This - Protocol instance pointer.
4240 ModeNumber - The mode number to return information on.
4241 Columns, Rows - Returns the geometry of the text output device for the
4242 requested ModeNumber.
4245 EFI_SUCCESS - The requested mode information was returned.
4246 EFI_DEVICE_ERROR - The device had an error and could not
4247 complete the request.
4248 EFI_UNSUPPORTED - The mode number was not valid.
4252 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4254 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4257 // Check whether param ModeNumber is valid.
4258 // ModeNumber should be within range 0 ~ MaxMode - 1.
4260 if ( (ModeNumber
> (UINTN
)(((UINT32
)-1)>>1)) ) {
4261 return EFI_UNSUPPORTED
;
4264 if ((INT32
) ModeNumber
>= This
->Mode
->MaxMode
) {
4265 return EFI_UNSUPPORTED
;
4268 *Columns
= Private
->TextOutQueryData
[ModeNumber
].Columns
;
4269 *Rows
= Private
->TextOutQueryData
[ModeNumber
].Rows
;
4271 if (*Columns
<= 0 && *Rows
<= 0) {
4272 return EFI_UNSUPPORTED
;
4281 ConSplitterTextOutSetMode (
4282 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4287 Routine Description:
4288 Sets the output device(s) to a specified mode.
4291 This - Protocol instance pointer.
4292 ModeNumber - The mode number to set.
4295 EFI_SUCCESS - The requested text mode was set.
4296 EFI_DEVICE_ERROR - The device had an error and
4297 could not complete the request.
4298 EFI_UNSUPPORTED - The mode number was not valid.
4303 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4305 INT32
*TextOutModeMap
;
4306 EFI_STATUS ReturnStatus
;
4308 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4311 // Check whether param ModeNumber is valid.
4312 // ModeNumber should be within range 0 ~ MaxMode - 1.
4314 if ( (ModeNumber
> (UINTN
)(((UINT32
)-1)>>1)) ) {
4315 return EFI_UNSUPPORTED
;
4318 if ((INT32
) ModeNumber
>= This
->Mode
->MaxMode
) {
4319 return EFI_UNSUPPORTED
;
4322 // If the mode is being set to the curent mode, then just clear the screen and return.
4324 if (Private
->TextOutMode
.Mode
== (INT32
) ModeNumber
) {
4325 return ConSplitterTextOutClearScreen (This
);
4328 // return the worst status met
4330 TextOutModeMap
= Private
->TextOutModeMap
+ Private
->TextOutListCount
* ModeNumber
;
4331 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
4333 if (Private
->TextOutList
[Index
].TextOutEnabled
) {
4334 Status
= Private
->TextOutList
[Index
].TextOut
->SetMode (
4335 Private
->TextOutList
[Index
].TextOut
,
4336 TextOutModeMap
[Index
]
4339 // If this console device is based on a UGA device, then sync up the bitmap from
4340 // the UGA splitter and reclear the text portion of the display in the new mode.
4342 if ((Private
->TextOutList
[Index
].GraphicsOutput
!= NULL
) || (Private
->TextOutList
[Index
].UgaDraw
!= NULL
)) {
4343 Private
->TextOutList
[Index
].TextOut
->ClearScreen (Private
->TextOutList
[Index
].TextOut
);
4346 if (EFI_ERROR (Status
)) {
4347 ReturnStatus
= Status
;
4352 // The DevNull Console will support any possible mode as it allocates memory
4354 Status
= DevNullTextOutSetMode (Private
, ModeNumber
);
4355 if (EFI_ERROR (Status
)) {
4356 ReturnStatus
= Status
;
4359 return ReturnStatus
;
4364 ConSplitterTextOutSetAttribute (
4365 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4370 Routine Description:
4371 Sets the background and foreground colors for the OutputString () and
4372 ClearScreen () functions.
4375 This - Protocol instance pointer.
4376 Attribute - The attribute to set. Bits 0..3 are the foreground color, and
4377 bits 4..6 are the background color. All other bits are undefined
4378 and must be zero. The valid Attributes are defined in this file.
4381 EFI_SUCCESS - The attribute was set.
4382 EFI_DEVICE_ERROR - The device had an error and
4383 could not complete the request.
4384 EFI_UNSUPPORTED - The attribute requested is not defined.
4389 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4391 EFI_STATUS ReturnStatus
;
4393 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4396 // Check whether param Attribute is valid.
4398 if ( (Attribute
> (UINTN
)(((UINT32
)-1)>>1)) ) {
4399 return EFI_UNSUPPORTED
;
4403 // return the worst status met
4405 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
4407 if (Private
->TextOutList
[Index
].TextOutEnabled
) {
4408 Status
= Private
->TextOutList
[Index
].TextOut
->SetAttribute (
4409 Private
->TextOutList
[Index
].TextOut
,
4412 if (EFI_ERROR (Status
)) {
4413 ReturnStatus
= Status
;
4418 Private
->TextOutMode
.Attribute
= (INT32
) Attribute
;
4420 return ReturnStatus
;
4425 ConSplitterTextOutClearScreen (
4426 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
4430 Routine Description:
4431 Clears the output device(s) display to the currently selected background
4435 This - Protocol instance pointer.
4438 EFI_SUCCESS - The operation completed successfully.
4439 EFI_DEVICE_ERROR - The device had an error and
4440 could not complete the request.
4441 EFI_UNSUPPORTED - The output device is not in a valid text mode.
4446 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4448 EFI_STATUS ReturnStatus
;
4450 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
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
->ClearScreen (Private
->TextOutList
[Index
].TextOut
);
4459 if (EFI_ERROR (Status
)) {
4460 ReturnStatus
= Status
;
4465 Status
= DevNullTextOutClearScreen (Private
);
4466 if (EFI_ERROR (Status
)) {
4467 ReturnStatus
= Status
;
4470 return ReturnStatus
;
4475 ConSplitterTextOutSetCursorPosition (
4476 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4482 Routine Description:
4483 Sets the current coordinates of the cursor position
4486 This - Protocol instance pointer.
4487 Column, Row - the position to set the cursor to. Must be greater than or
4488 equal to zero and less than the number of columns and rows
4492 EFI_SUCCESS - The operation completed successfully.
4493 EFI_DEVICE_ERROR - The device had an error and
4494 could not complete the request.
4495 EFI_UNSUPPORTED - The output device is not in a valid text mode, or the
4496 cursor position is invalid for the current mode.
4501 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4503 EFI_STATUS ReturnStatus
;
4506 INT32
*TextOutModeMap
;
4510 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4511 TextOutModeMap
= NULL
;
4512 ModeNumber
= Private
->TextOutMode
.Mode
;
4515 // Get current MaxColumn and MaxRow from intersection map
4517 if (Private
->TextOutModeMap
!= NULL
) {
4518 TextOutModeMap
= Private
->TextOutModeMap
+ Private
->TextOutListCount
* ModeNumber
;
4519 CurrentMode
= *TextOutModeMap
;
4521 CurrentMode
= ModeNumber
;
4524 MaxColumn
= Private
->TextOutQueryData
[CurrentMode
].Columns
;
4525 MaxRow
= Private
->TextOutQueryData
[CurrentMode
].Rows
;
4527 if (Column
>= MaxColumn
|| Row
>= MaxRow
) {
4528 return EFI_UNSUPPORTED
;
4531 // return the worst status met
4533 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
4535 if (Private
->TextOutList
[Index
].TextOutEnabled
) {
4536 Status
= Private
->TextOutList
[Index
].TextOut
->SetCursorPosition (
4537 Private
->TextOutList
[Index
].TextOut
,
4541 if (EFI_ERROR (Status
)) {
4542 ReturnStatus
= Status
;
4547 DevNullTextOutSetCursorPosition (Private
, Column
, Row
);
4549 return ReturnStatus
;
4554 ConSplitterTextOutEnableCursor (
4555 IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*This
,
4560 Routine Description:
4561 Makes the cursor visible or invisible
4564 This - Protocol instance pointer.
4565 Visible - If TRUE, the cursor is set to be visible. If FALSE, the cursor is
4566 set to be invisible.
4569 EFI_SUCCESS - The operation completed successfully.
4570 EFI_DEVICE_ERROR - The device had an error and could not complete the
4571 request, or the device does not support changing
4573 EFI_UNSUPPORTED - The output device is not in a valid text mode.
4578 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
4580 EFI_STATUS ReturnStatus
;
4582 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
4585 // return the worst status met
4587 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
4589 if (Private
->TextOutList
[Index
].TextOutEnabled
) {
4590 Status
= Private
->TextOutList
[Index
].TextOut
->EnableCursor (
4591 Private
->TextOutList
[Index
].TextOut
,
4594 if (EFI_ERROR (Status
)) {
4595 ReturnStatus
= Status
;
4600 DevNullTextOutEnableCursor (Private
, Visible
);
4602 return ReturnStatus
;