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 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_IN_PROTOCOL
**) NULL
,
48 ConSplitterSimplePointerReset
,
49 ConSplitterSimplePointerGetState
,
51 (EFI_SIMPLE_POINTER_MODE
*) NULL
61 (EFI_SIMPLE_POINTER_PROTOCOL
**) NULL
,
66 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
67 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
68 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
69 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
73 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
74 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
75 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
76 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
84 STATIC TEXT_OUT_SPLITTER_PRIVATE_DATA mConOut
= {
85 TEXT_OUT_SPLITTER_PRIVATE_DATA_SIGNATURE
,
88 ConSplitterTextOutReset
,
89 ConSplitterTextOutOutputString
,
90 ConSplitterTextOutTestString
,
91 ConSplitterTextOutQueryMode
,
92 ConSplitterTextOutSetMode
,
93 ConSplitterTextOutSetAttribute
,
94 ConSplitterTextOutClearScreen
,
95 ConSplitterTextOutSetCursorPosition
,
96 ConSplitterTextOutEnableCursor
,
97 (EFI_SIMPLE_TEXT_OUTPUT_MODE
*) NULL
107 #if (EFI_SPECIFICATION_VERSION < 0x00020000)
109 ConSpliterUgaDrawGetMode
,
110 ConSpliterUgaDrawSetMode
,
117 (EFI_UGA_PIXEL
*) NULL
,
120 ConSpliterGraphicsOutputQueryMode
,
121 ConSpliterGraphicsOutputSetMode
,
122 ConSpliterGraphicsOutputBlt
,
125 (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*) NULL
,
126 (TEXT_OUT_GOP_MODE
*) NULL
,
131 ConSpliterConsoleControlGetMode
,
132 ConSpliterConsoleControlSetMode
,
133 ConSpliterConsoleControlLockStdIn
137 (TEXT_OUT_AND_GOP_DATA
*) NULL
,
139 (TEXT_OUT_SPLITTER_QUERY_DATA
*) NULL
,
143 EfiConsoleControlScreenText
,
150 STATIC TEXT_OUT_SPLITTER_PRIVATE_DATA mStdErr
= {
151 TEXT_OUT_SPLITTER_PRIVATE_DATA_SIGNATURE
,
154 ConSplitterTextOutReset
,
155 ConSplitterTextOutOutputString
,
156 ConSplitterTextOutTestString
,
157 ConSplitterTextOutQueryMode
,
158 ConSplitterTextOutSetMode
,
159 ConSplitterTextOutSetAttribute
,
160 ConSplitterTextOutClearScreen
,
161 ConSplitterTextOutSetCursorPosition
,
162 ConSplitterTextOutEnableCursor
,
163 (EFI_SIMPLE_TEXT_OUTPUT_MODE
*) NULL
173 #if (EFI_SPECIFICATION_VERSION < 0x00020000)
175 ConSpliterUgaDrawGetMode
,
176 ConSpliterUgaDrawSetMode
,
183 (EFI_UGA_PIXEL
*) NULL
,
186 ConSpliterGraphicsOutputQueryMode
,
187 ConSpliterGraphicsOutputSetMode
,
188 ConSpliterGraphicsOutputBlt
,
191 (EFI_GRAPHICS_OUTPUT_BLT_PIXEL
*) NULL
,
192 (TEXT_OUT_GOP_MODE
*) NULL
,
197 ConSpliterConsoleControlGetMode
,
198 ConSpliterConsoleControlSetMode
,
199 ConSpliterConsoleControlLockStdIn
203 (TEXT_OUT_AND_GOP_DATA
*) NULL
,
205 (TEXT_OUT_SPLITTER_QUERY_DATA
*) NULL
,
209 EfiConsoleControlScreenText
,
216 EFI_DRIVER_BINDING_PROTOCOL gConSplitterConInDriverBinding
= {
217 ConSplitterConInDriverBindingSupported
,
218 ConSplitterConInDriverBindingStart
,
219 ConSplitterConInDriverBindingStop
,
225 EFI_DRIVER_BINDING_PROTOCOL gConSplitterSimplePointerDriverBinding
= {
226 ConSplitterSimplePointerDriverBindingSupported
,
227 ConSplitterSimplePointerDriverBindingStart
,
228 ConSplitterSimplePointerDriverBindingStop
,
234 EFI_DRIVER_BINDING_PROTOCOL gConSplitterConOutDriverBinding
= {
235 ConSplitterConOutDriverBindingSupported
,
236 ConSplitterConOutDriverBindingStart
,
237 ConSplitterConOutDriverBindingStop
,
243 EFI_DRIVER_BINDING_PROTOCOL gConSplitterStdErrDriverBinding
= {
244 ConSplitterStdErrDriverBindingSupported
,
245 ConSplitterStdErrDriverBindingStart
,
246 ConSplitterStdErrDriverBindingStop
,
254 ConSplitterDriverEntry (
255 IN EFI_HANDLE ImageHandle
,
256 IN EFI_SYSTEM_TABLE
*SystemTable
261 Intialize a virtual console device to act as an agrigator of physical console
265 ImageHandle - (Standard EFI Image entry - EFI_IMAGE_ENTRY_POINT)
266 SystemTable - (Standard EFI Image entry - EFI_IMAGE_ENTRY_POINT)
275 // The driver creates virtual handles for ConIn, ConOut, and StdErr.
276 // The virtual handles will always exist even if no console exist in the
277 // system. This is need to support hotplug devices like USB.
280 // Create virtual device handle for StdErr Splitter
282 Status
= ConSplitterTextOutConstructor (&mStdErr
);
283 if (!EFI_ERROR (Status
)) {
284 Status
= gBS
->InstallMultipleProtocolInterfaces (
285 &mStdErr
.VirtualHandle
,
286 &gEfiSimpleTextOutProtocolGuid
,
288 &gEfiPrimaryStandardErrorDeviceGuid
,
294 // Create virtual device handle for ConIn Splitter
296 Status
= ConSplitterTextInConstructor (&mConIn
);
297 if (!EFI_ERROR (Status
)) {
298 Status
= gBS
->InstallMultipleProtocolInterfaces (
299 &mConIn
.VirtualHandle
,
300 &gEfiSimpleTextInProtocolGuid
,
302 &gEfiSimplePointerProtocolGuid
,
303 &mConIn
.SimplePointer
,
304 &gEfiPrimaryConsoleInDeviceGuid
,
308 if (!EFI_ERROR (Status
)) {
310 // Update the EFI System Table with new virtual console
312 gST
->ConsoleInHandle
= mConIn
.VirtualHandle
;
313 gST
->ConIn
= &mConIn
.TextIn
;
317 // Create virtual device handle for ConOut Splitter
319 Status
= ConSplitterTextOutConstructor (&mConOut
);
320 if (!EFI_ERROR (Status
)) {
321 #if (EFI_SPECIFICATION_VERSION < 0x00020000)
323 // In EFI mode, UGA Draw protocol is installed
325 Status
= gBS
->InstallMultipleProtocolInterfaces (
326 &mConOut
.VirtualHandle
,
327 &gEfiSimpleTextOutProtocolGuid
,
329 &gEfiUgaDrawProtocolGuid
,
331 &gEfiConsoleControlProtocolGuid
,
332 &mConOut
.ConsoleControl
,
333 &gEfiPrimaryConsoleOutDeviceGuid
,
339 // In UEFI mode, Graphics Output Protocol is installed on virtual handle.
341 Status
= gBS
->InstallMultipleProtocolInterfaces (
342 &mConOut
.VirtualHandle
,
343 &gEfiSimpleTextOutProtocolGuid
,
345 &gEfiGraphicsOutputProtocolGuid
,
346 &mConOut
.GraphicsOutput
,
347 &gEfiConsoleControlProtocolGuid
,
348 &mConOut
.ConsoleControl
,
349 &gEfiPrimaryConsoleOutDeviceGuid
,
355 if (!EFI_ERROR (Status
)) {
357 // Update the EFI System Table with new virtual console
359 gST
->ConsoleOutHandle
= mConOut
.VirtualHandle
;
360 gST
->ConOut
= &mConOut
.TextOut
;
365 // Update the CRC32 in the EFI System Table header
368 gBS
->CalculateCrc32 (
378 ConSplitterTextInConstructor (
379 TEXT_IN_SPLITTER_PRIVATE_DATA
*ConInPrivate
385 Construct the ConSplitter.
389 ConInPrivate - A pointer to the TEXT_IN_SPLITTER_PRIVATE_DATA structure.
392 EFI_OUT_OF_RESOURCES - Out of resources.
399 // Initilize console input splitter's private data.
401 Status
= ConSplitterGrowBuffer (
402 sizeof (EFI_SIMPLE_TEXT_IN_PROTOCOL
*),
403 &ConInPrivate
->TextInListCount
,
404 (VOID
**) &ConInPrivate
->TextInList
406 if (EFI_ERROR (Status
)) {
407 return EFI_OUT_OF_RESOURCES
;
410 // Create Event to support locking StdIn Device
412 Status
= gBS
->CreateEvent (
413 EFI_EVENT_TIMER
| EFI_EVENT_NOTIFY_SIGNAL
,
415 ConSpliterConsoleControlLockStdInEvent
,
417 &ConInPrivate
->LockEvent
419 ASSERT_EFI_ERROR (Status
);
421 Status
= gBS
->CreateEvent (
422 EFI_EVENT_NOTIFY_WAIT
,
424 ConSplitterTextInWaitForKey
,
426 &ConInPrivate
->TextIn
.WaitForKey
428 ASSERT_EFI_ERROR (Status
);
430 ConInPrivate
->SimplePointer
.Mode
= &ConInPrivate
->SimplePointerMode
;
432 Status
= ConSplitterGrowBuffer (
433 sizeof (EFI_SIMPLE_POINTER_PROTOCOL
*),
434 &ConInPrivate
->PointerListCount
,
435 (VOID
**) &ConInPrivate
->PointerList
437 if (EFI_ERROR (Status
)) {
438 return EFI_OUT_OF_RESOURCES
;
441 Status
= gBS
->CreateEvent (
442 EFI_EVENT_NOTIFY_WAIT
,
444 ConSplitterSimplePointerWaitForInput
,
446 &ConInPrivate
->SimplePointer
.WaitForInput
453 ConSplitterTextOutConstructor (
454 TEXT_OUT_SPLITTER_PRIVATE_DATA
*ConOutPrivate
460 // Initilize console output splitter's private data.
462 ConOutPrivate
->TextOut
.Mode
= &ConOutPrivate
->TextOutMode
;
464 Status
= ConSplitterGrowBuffer (
465 sizeof (TEXT_OUT_AND_GOP_DATA
),
466 &ConOutPrivate
->TextOutListCount
,
467 (VOID
**) &ConOutPrivate
->TextOutList
469 if (EFI_ERROR (Status
)) {
470 return EFI_OUT_OF_RESOURCES
;
473 Status
= ConSplitterGrowBuffer (
474 sizeof (TEXT_OUT_SPLITTER_QUERY_DATA
),
475 &ConOutPrivate
->TextOutQueryDataCount
,
476 (VOID
**) &ConOutPrivate
->TextOutQueryData
478 if (EFI_ERROR (Status
)) {
479 return EFI_OUT_OF_RESOURCES
;
482 // Setup the DevNullTextOut console to 80 x 25
484 ConOutPrivate
->TextOutQueryData
[0].Columns
= 80;
485 ConOutPrivate
->TextOutQueryData
[0].Rows
= 25;
486 DevNullTextOutSetMode (ConOutPrivate
, 0);
488 #if (EFI_SPECIFICATION_VERSION < 0x00020000)
490 // Setup the DevNullUgaDraw to 800 x 600 x 32 bits per pixel
492 ConSpliterUgaDrawSetMode (&ConOutPrivate
->UgaDraw
, 800, 600, 32, 60);
495 // Setup resource for mode information in Graphics Output Protocol interface
497 if ((ConOutPrivate
->GraphicsOutput
.Mode
= AllocateZeroPool (sizeof (EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE
))) == NULL
) {
498 return EFI_OUT_OF_RESOURCES
;
500 if ((ConOutPrivate
->GraphicsOutput
.Mode
->Info
= AllocateZeroPool (sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
))) == NULL
) {
501 return EFI_OUT_OF_RESOURCES
;
504 // Setup the DevNullGraphicsOutput to 800 x 600 x 32 bits per pixel
506 if ((ConOutPrivate
->GraphicsOutputModeBuffer
= AllocateZeroPool (sizeof (TEXT_OUT_GOP_MODE
))) == NULL
) {
507 return EFI_OUT_OF_RESOURCES
;
509 ConOutPrivate
->GraphicsOutputModeBuffer
[0].HorizontalResolution
= 800;
510 ConOutPrivate
->GraphicsOutputModeBuffer
[0].VerticalResolution
= 600;
513 // Initialize the following items, theset items remain unchanged in GraphicsOutput->SetMode()
514 // GraphicsOutputMode->Info->Version, GraphicsOutputMode->Info->PixelFormat
515 // GraphicsOutputMode->SizeOfInfo, GraphicsOutputMode->FrameBufferBase, GraphicsOutputMode->FrameBufferSize
517 ConOutPrivate
->GraphicsOutput
.Mode
->Info
->Version
= 0;
518 ConOutPrivate
->GraphicsOutput
.Mode
->Info
->PixelFormat
= PixelBltOnly
;
519 ConOutPrivate
->GraphicsOutput
.Mode
->SizeOfInfo
= sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
);
520 ConOutPrivate
->GraphicsOutput
.Mode
->FrameBufferBase
= (EFI_PHYSICAL_ADDRESS
) NULL
;
521 ConOutPrivate
->GraphicsOutput
.Mode
->FrameBufferSize
= 0;
523 ConOutPrivate
->GraphicsOutput
.Mode
->MaxMode
= 1;
525 // Initial current mode to unknow state, and then set to mode 0
527 ConOutPrivate
->GraphicsOutput
.Mode
->Mode
= 0xffff;
528 ConOutPrivate
->GraphicsOutput
.SetMode (&ConOutPrivate
->GraphicsOutput
, 0);
536 ConSplitterSupported (
537 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
538 IN EFI_HANDLE ControllerHandle
,
544 Generic Supported Check
547 This - Pointer to protocol.
548 ControllerHandle - Controller Handle.
553 EFI_UNSUPPORTED - unsupported.
554 EFI_SUCCESS - operation is OK.
562 // Make sure the Console Splitter does not attempt to attach to itself
564 if (ControllerHandle
== mConIn
.VirtualHandle
) {
565 return EFI_UNSUPPORTED
;
568 if (ControllerHandle
== mConOut
.VirtualHandle
) {
569 return EFI_UNSUPPORTED
;
572 if (ControllerHandle
== mStdErr
.VirtualHandle
) {
573 return EFI_UNSUPPORTED
;
576 // Check to see whether the handle has the ConsoleInDevice GUID on it
578 Status
= gBS
->OpenProtocol (
582 This
->DriverBindingHandle
,
584 EFI_OPEN_PROTOCOL_BY_DRIVER
587 if (EFI_ERROR (Status
)) {
594 This
->DriverBindingHandle
,
603 ConSplitterConInDriverBindingSupported (
604 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
605 IN EFI_HANDLE ControllerHandle
,
606 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
611 Console In Supported Check
614 This - Pointer to protocol.
615 ControllerHandle - Controller handle.
616 RemainingDevicePath - Remaining device path.
624 return ConSplitterSupported (
627 &gEfiConsoleInDeviceGuid
633 ConSplitterSimplePointerDriverBindingSupported (
634 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
635 IN EFI_HANDLE ControllerHandle
,
636 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
641 Standard Error Supported Check
644 This - Pointer to protocol.
645 ControllerHandle - Controller handle.
646 RemainingDevicePath - Remaining device path.
654 return ConSplitterSupported (
657 &gEfiSimplePointerProtocolGuid
663 ConSplitterConOutDriverBindingSupported (
664 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
665 IN EFI_HANDLE ControllerHandle
,
666 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
671 Console Out Supported Check
674 This - Pointer to protocol.
675 ControllerHandle - Controller handle.
676 RemainingDevicePath - Remaining device path.
684 return ConSplitterSupported (
687 &gEfiConsoleOutDeviceGuid
693 ConSplitterStdErrDriverBindingSupported (
694 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
695 IN EFI_HANDLE ControllerHandle
,
696 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
701 Standard Error Supported Check
704 This - Pointer to protocol.
705 ControllerHandle - Controller handle.
706 RemainingDevicePath - Remaining device path.
714 return ConSplitterSupported (
717 &gEfiStandardErrorDeviceGuid
725 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
726 IN EFI_HANDLE ControllerHandle
,
727 IN EFI_HANDLE ConSplitterVirtualHandle
,
728 IN EFI_GUID
*DeviceGuid
,
729 IN EFI_GUID
*InterfaceGuid
,
735 Start ConSplitter on ControllerHandle, and create the virtual
736 agrogated console device on first call Start for a SimpleTextIn handle.
739 (Standard DriverBinding Protocol Start() function)
742 EFI_ERROR if a SimpleTextIn protocol is not started.
750 // Check to see whether the handle has the ConsoleInDevice GUID on it
752 Status
= gBS
->OpenProtocol (
756 This
->DriverBindingHandle
,
758 EFI_OPEN_PROTOCOL_BY_DRIVER
760 if (EFI_ERROR (Status
)) {
764 Status
= gBS
->OpenProtocol (
768 This
->DriverBindingHandle
,
769 ConSplitterVirtualHandle
,
770 EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
772 if (EFI_ERROR (Status
)) {
776 return gBS
->OpenProtocol (
780 This
->DriverBindingHandle
,
781 ConSplitterVirtualHandle
,
782 EFI_OPEN_PROTOCOL_GET_PROTOCOL
788 ConSplitterConInDriverBindingStart (
789 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
790 IN EFI_HANDLE ControllerHandle
,
791 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
796 Start ConSplitter on ControllerHandle, and create the virtual
797 agrogated console device on first call Start for a SimpleTextIn handle.
800 This - Pointer to protocol.
801 ControllerHandle - Controller handle.
802 RemainingDevicePath - Remaining device path.
807 EFI_ERROR if a SimpleTextIn protocol is not started.
812 EFI_SIMPLE_TEXT_IN_PROTOCOL
*TextIn
;
815 // Start ConSplitter on ControllerHandle, and create the virtual
816 // agrogated console device on first call Start for a SimpleTextIn handle.
818 Status
= ConSplitterStart (
821 mConIn
.VirtualHandle
,
822 &gEfiConsoleInDeviceGuid
,
823 &gEfiSimpleTextInProtocolGuid
,
826 if (EFI_ERROR (Status
)) {
830 return ConSplitterTextInAddDevice (&mConIn
, TextIn
);
835 ConSplitterSimplePointerDriverBindingStart (
836 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
837 IN EFI_HANDLE ControllerHandle
,
838 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
843 Start ConSplitter on ControllerHandle, and create the virtual
844 agrogated console device on first call Start for a SimpleTextIn handle.
847 This - Pointer to protocol.
848 ControllerHandle - Controller handle.
849 RemainingDevicePath - Remaining device path.
853 EFI_ERROR if a SimpleTextIn protocol is not started.
858 EFI_SIMPLE_POINTER_PROTOCOL
*SimplePointer
;
860 Status
= ConSplitterStart (
863 mConIn
.VirtualHandle
,
864 &gEfiSimplePointerProtocolGuid
,
865 &gEfiSimplePointerProtocolGuid
,
866 (VOID
**) &SimplePointer
868 if (EFI_ERROR (Status
)) {
872 return ConSplitterSimplePointerAddDevice (&mConIn
, SimplePointer
);
877 ConSplitterConOutDriverBindingStart (
878 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
879 IN EFI_HANDLE ControllerHandle
,
880 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
885 Start ConSplitter on ControllerHandle, and create the virtual
886 agrogated console device on first call Start for a SimpleTextIn handle.
889 This - Pointer to protocol.
890 ControllerHandle - Controller handle.
891 RemainingDevicePath - Remaining device path.
894 EFI_ERROR if a SimpleTextIn protocol is not started.
899 EFI_SIMPLE_TEXT_OUT_PROTOCOL
*TextOut
;
900 EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
;
901 EFI_UGA_DRAW_PROTOCOL
*UgaDraw
;
903 Status
= ConSplitterStart (
906 mConOut
.VirtualHandle
,
907 &gEfiConsoleOutDeviceGuid
,
908 &gEfiSimpleTextOutProtocolGuid
,
911 if (EFI_ERROR (Status
)) {
915 // Try to Open Graphics Output protocol
917 Status
= gBS
->OpenProtocol (
919 &gEfiGraphicsOutputProtocolGuid
,
920 (VOID
**) &GraphicsOutput
,
921 This
->DriverBindingHandle
,
922 mConOut
.VirtualHandle
,
923 EFI_OPEN_PROTOCOL_GET_PROTOCOL
925 if (EFI_ERROR (Status
)) {
926 GraphicsOutput
= NULL
;
929 // Open UGA_DRAW protocol
931 Status
= gBS
->OpenProtocol (
933 &gEfiUgaDrawProtocolGuid
,
935 This
->DriverBindingHandle
,
936 mConOut
.VirtualHandle
,
937 EFI_OPEN_PROTOCOL_GET_PROTOCOL
939 if (EFI_ERROR (Status
)) {
943 // If both ConOut and StdErr incorporate the same Text Out device,
944 // their MaxMode and QueryData should be the intersection of both.
946 Status
= ConSplitterTextOutAddDevice (&mConOut
, TextOut
, GraphicsOutput
, UgaDraw
);
947 ConSplitterTextOutSetAttribute (&mConOut
.TextOut
, EFI_TEXT_ATTR (EFI_LIGHTGRAY
, EFI_BLACK
));
949 #if (EFI_SPECIFICATION_VERSION < 0x00020000)
951 // Match the UGA mode data of ConOut with the current mode
953 if (UgaDraw
!= NULL
) {
956 &mConOut
.UgaHorizontalResolution
,
957 &mConOut
.UgaVerticalResolution
,
958 &mConOut
.UgaColorDepth
,
959 &mConOut
.UgaRefreshRate
969 ConSplitterStdErrDriverBindingStart (
970 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
971 IN EFI_HANDLE ControllerHandle
,
972 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
977 Start ConSplitter on ControllerHandle, and create the virtual
978 agrogated console device on first call Start for a SimpleTextIn handle.
981 This - Pointer to protocol.
982 ControllerHandle - Controller handle.
983 RemainingDevicePath - Remaining device path.
986 EFI_ERROR if a SimpleTextIn protocol is not started.
991 EFI_SIMPLE_TEXT_OUT_PROTOCOL
*TextOut
;
993 Status
= ConSplitterStart (
996 mStdErr
.VirtualHandle
,
997 &gEfiStandardErrorDeviceGuid
,
998 &gEfiSimpleTextOutProtocolGuid
,
1001 if (EFI_ERROR (Status
)) {
1005 // If both ConOut and StdErr incorporate the same Text Out device,
1006 // their MaxMode and QueryData should be the intersection of both.
1008 Status
= ConSplitterTextOutAddDevice (&mStdErr
, TextOut
, NULL
, NULL
);
1009 ConSplitterTextOutSetAttribute (&mStdErr
.TextOut
, EFI_TEXT_ATTR (EFI_MAGENTA
, EFI_BLACK
));
1010 if (EFI_ERROR (Status
)) {
1014 if (mStdErr
.CurrentNumberOfConsoles
== 1) {
1015 gST
->StandardErrorHandle
= mStdErr
.VirtualHandle
;
1016 gST
->StdErr
= &mStdErr
.TextOut
;
1018 // Update the CRC32 in the EFI System Table header
1021 gBS
->CalculateCrc32 (
1022 (UINT8
*) &gST
->Hdr
,
1023 gST
->Hdr
.HeaderSize
,
1035 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1036 IN EFI_HANDLE ControllerHandle
,
1037 IN EFI_HANDLE ConSplitterVirtualHandle
,
1038 IN EFI_GUID
*DeviceGuid
,
1039 IN EFI_GUID
*InterfaceGuid
,
1044 Routine Description:
1047 (Standard DriverBinding Protocol Stop() function)
1057 Status
= gBS
->OpenProtocol (
1061 This
->DriverBindingHandle
,
1063 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1065 if (EFI_ERROR (Status
)) {
1069 // close the protocol refered.
1071 gBS
->CloseProtocol (
1074 This
->DriverBindingHandle
,
1075 ConSplitterVirtualHandle
1077 gBS
->CloseProtocol (
1080 This
->DriverBindingHandle
,
1089 ConSplitterConInDriverBindingStop (
1090 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1091 IN EFI_HANDLE ControllerHandle
,
1092 IN UINTN NumberOfChildren
,
1093 IN EFI_HANDLE
*ChildHandleBuffer
1097 Routine Description:
1100 (Standard DriverBinding Protocol Stop() function)
1109 EFI_SIMPLE_TEXT_IN_PROTOCOL
*TextIn
;
1111 if (NumberOfChildren
== 0) {
1115 Status
= ConSplitterStop (
1118 mConIn
.VirtualHandle
,
1119 &gEfiConsoleInDeviceGuid
,
1120 &gEfiSimpleTextInProtocolGuid
,
1123 if (EFI_ERROR (Status
)) {
1127 // Delete this console input device's data structures.
1129 return ConSplitterTextInDeleteDevice (&mConIn
, TextIn
);
1134 ConSplitterSimplePointerDriverBindingStop (
1135 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1136 IN EFI_HANDLE ControllerHandle
,
1137 IN UINTN NumberOfChildren
,
1138 IN EFI_HANDLE
*ChildHandleBuffer
1142 Routine Description:
1145 (Standard DriverBinding Protocol Stop() function)
1154 EFI_SIMPLE_POINTER_PROTOCOL
*SimplePointer
;
1156 if (NumberOfChildren
== 0) {
1160 Status
= ConSplitterStop (
1163 mConIn
.VirtualHandle
,
1164 &gEfiSimplePointerProtocolGuid
,
1165 &gEfiSimplePointerProtocolGuid
,
1166 (VOID
**) &SimplePointer
1168 if (EFI_ERROR (Status
)) {
1172 // Delete this console input device's data structures.
1174 return ConSplitterSimplePointerDeleteDevice (&mConIn
, SimplePointer
);
1179 ConSplitterConOutDriverBindingStop (
1180 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1181 IN EFI_HANDLE ControllerHandle
,
1182 IN UINTN NumberOfChildren
,
1183 IN EFI_HANDLE
*ChildHandleBuffer
1187 Routine Description:
1190 (Standard DriverBinding Protocol Stop() function)
1199 EFI_SIMPLE_TEXT_OUT_PROTOCOL
*TextOut
;
1201 if (NumberOfChildren
== 0) {
1205 Status
= ConSplitterStop (
1208 mConOut
.VirtualHandle
,
1209 &gEfiConsoleOutDeviceGuid
,
1210 &gEfiSimpleTextOutProtocolGuid
,
1213 if (EFI_ERROR (Status
)) {
1218 // Delete this console output device's data structures.
1220 return ConSplitterTextOutDeleteDevice (&mConOut
, TextOut
);
1225 ConSplitterStdErrDriverBindingStop (
1226 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
1227 IN EFI_HANDLE ControllerHandle
,
1228 IN UINTN NumberOfChildren
,
1229 IN EFI_HANDLE
*ChildHandleBuffer
1233 Routine Description:
1236 (Standard DriverBinding Protocol Stop() function)
1240 EFI_SUCCESS - Complete successfully.
1245 EFI_SIMPLE_TEXT_OUT_PROTOCOL
*TextOut
;
1247 if (NumberOfChildren
== 0) {
1251 Status
= ConSplitterStop (
1254 mStdErr
.VirtualHandle
,
1255 &gEfiStandardErrorDeviceGuid
,
1256 &gEfiSimpleTextOutProtocolGuid
,
1259 if (EFI_ERROR (Status
)) {
1263 // Delete this console error out device's data structures.
1265 Status
= ConSplitterTextOutDeleteDevice (&mStdErr
, TextOut
);
1266 if (EFI_ERROR (Status
)) {
1270 if (mStdErr
.CurrentNumberOfConsoles
== 0) {
1271 gST
->StandardErrorHandle
= NULL
;
1274 // Update the CRC32 in the EFI System Table header
1277 gBS
->CalculateCrc32 (
1278 (UINT8
*) &gST
->Hdr
,
1279 gST
->Hdr
.HeaderSize
,
1288 ConSplitterGrowBuffer (
1289 IN UINTN SizeOfCount
,
1291 IN OUT VOID
**Buffer
1295 Routine Description:
1296 Take the passed in Buffer of size SizeOfCount and grow the buffer
1297 by MAX (CONSOLE_SPLITTER_CONSOLES_ALLOC_UNIT, MaxGrow) * SizeOfCount
1298 bytes. Copy the current data in Buffer to the new version of Buffer
1299 and free the old version of buffer.
1303 SizeOfCount - Size of element in array
1304 Count - Current number of elements in array
1305 Buffer - Bigger version of passed in Buffer with all the data
1308 EFI_SUCCESS - Buffer size has grown
1309 EFI_OUT_OF_RESOURCES - Could not grow the buffer size
1320 // grow the buffer to new buffer size,
1321 // copy the old buffer's content to the new-size buffer,
1322 // then free the old buffer.
1324 OldSize
= *Count
* SizeOfCount
;
1325 *Count
+= CONSOLE_SPLITTER_CONSOLES_ALLOC_UNIT
;
1326 NewSize
= *Count
* SizeOfCount
;
1328 Ptr
= AllocateZeroPool (NewSize
);
1330 return EFI_OUT_OF_RESOURCES
;
1333 CopyMem (Ptr
, *Buffer
, OldSize
);
1335 if (*Buffer
!= NULL
) {
1336 gBS
->FreePool (*Buffer
);
1345 ConSplitterTextInAddDevice (
1346 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
1347 IN EFI_SIMPLE_TEXT_IN_PROTOCOL
*TextIn
1351 Routine Description:
1358 EFI_OUT_OF_RESOURCES
1365 // If the Text In List is full, enlarge it by calling growbuffer().
1367 if (Private
->CurrentNumberOfConsoles
>= Private
->TextInListCount
) {
1368 Status
= ConSplitterGrowBuffer (
1369 sizeof (EFI_SIMPLE_TEXT_IN_PROTOCOL
*),
1370 &Private
->TextInListCount
,
1371 (VOID
**) &Private
->TextInList
1373 if (EFI_ERROR (Status
)) {
1374 return EFI_OUT_OF_RESOURCES
;
1378 // Add the new text-in device data structure into the Text In List.
1380 Private
->TextInList
[Private
->CurrentNumberOfConsoles
] = TextIn
;
1381 Private
->CurrentNumberOfConsoles
++;
1384 // Extra CheckEvent added to reduce the double CheckEvent() in UI.c
1386 gBS
->CheckEvent (TextIn
->WaitForKey
);
1392 ConSplitterTextInDeleteDevice (
1393 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
1394 IN EFI_SIMPLE_TEXT_IN_PROTOCOL
*TextIn
1398 Routine Description:
1411 // Remove the specified text-in device data structure from the Text In List,
1412 // and rearrange the remaining data structures in the Text In List.
1414 for (Index
= 0; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
1415 if (Private
->TextInList
[Index
] == TextIn
) {
1416 for (Index
= Index
; Index
< Private
->CurrentNumberOfConsoles
- 1; Index
++) {
1417 Private
->TextInList
[Index
] = Private
->TextInList
[Index
+ 1];
1420 Private
->CurrentNumberOfConsoles
--;
1425 return EFI_NOT_FOUND
;
1429 ConSplitterSimplePointerAddDevice (
1430 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
1431 IN EFI_SIMPLE_POINTER_PROTOCOL
*SimplePointer
1435 Routine Description:
1441 EFI_OUT_OF_RESOURCES
1449 // If the Text In List is full, enlarge it by calling growbuffer().
1451 if (Private
->CurrentNumberOfPointers
>= Private
->PointerListCount
) {
1452 Status
= ConSplitterGrowBuffer (
1453 sizeof (EFI_SIMPLE_POINTER_PROTOCOL
*),
1454 &Private
->PointerListCount
,
1455 (VOID
**) &Private
->PointerList
1457 if (EFI_ERROR (Status
)) {
1458 return EFI_OUT_OF_RESOURCES
;
1462 // Add the new text-in device data structure into the Text In List.
1464 Private
->PointerList
[Private
->CurrentNumberOfPointers
] = SimplePointer
;
1465 Private
->CurrentNumberOfPointers
++;
1470 ConSplitterSimplePointerDeleteDevice (
1471 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
1472 IN EFI_SIMPLE_POINTER_PROTOCOL
*SimplePointer
1476 Routine Description:
1488 // Remove the specified text-in device data structure from the Text In List,
1489 // and rearrange the remaining data structures in the Text In List.
1491 for (Index
= 0; Index
< Private
->CurrentNumberOfPointers
; Index
++) {
1492 if (Private
->PointerList
[Index
] == SimplePointer
) {
1493 for (Index
= Index
; Index
< Private
->CurrentNumberOfPointers
- 1; Index
++) {
1494 Private
->PointerList
[Index
] = Private
->PointerList
[Index
+ 1];
1497 Private
->CurrentNumberOfPointers
--;
1502 return EFI_NOT_FOUND
;
1507 ConSplitterGrowMapTable (
1508 IN TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
1512 Routine Description:
1525 INT32
*TextOutModeMap
;
1526 INT32
*OldTextOutModeMap
;
1530 NewSize
= Private
->TextOutListCount
* sizeof (INT32
);
1531 OldTextOutModeMap
= Private
->TextOutModeMap
;
1532 TotalSize
= NewSize
* Private
->TextOutQueryDataCount
;
1534 TextOutModeMap
= AllocateZeroPool (TotalSize
);
1535 if (TextOutModeMap
== NULL
) {
1536 return EFI_OUT_OF_RESOURCES
;
1539 SetMem (TextOutModeMap
, TotalSize
, 0xFF);
1540 Private
->TextOutModeMap
= TextOutModeMap
;
1543 // If TextOutList has been enlarged, need to realloc the mode map table
1544 // The mode map table is regarded as a two dimension array.
1547 // 0 ---------> TextOutListCount ----> TextOutListCount
1548 // | -------------------------------------------
1555 // -------------------------------------------
1558 if (OldTextOutModeMap
!= NULL
) {
1560 Size
= Private
->CurrentNumberOfConsoles
* sizeof (INT32
);
1562 SrcAddress
= OldTextOutModeMap
;
1565 // Copy the old data to the new one
1567 while (Index
< Private
->TextOutMode
.MaxMode
) {
1568 CopyMem (TextOutModeMap
, SrcAddress
, Size
);
1569 TextOutModeMap
+= NewSize
;
1574 // Free the old buffer
1576 gBS
->FreePool (OldTextOutModeMap
);
1584 ConSplitterAddOutputMode (
1585 IN TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
,
1586 IN EFI_SIMPLE_TEXT_OUT_PROTOCOL
*TextOut
1590 Routine Description:
1605 MaxMode
= TextOut
->Mode
->MaxMode
;
1606 Private
->TextOutMode
.MaxMode
= MaxMode
;
1609 // Grow the buffer if query data buffer is not large enough to
1610 // hold all the mode supported by the first console.
1612 while (MaxMode
> (INT32
) Private
->TextOutQueryDataCount
) {
1613 Status
= ConSplitterGrowBuffer (
1614 sizeof (TEXT_OUT_SPLITTER_QUERY_DATA
),
1615 &Private
->TextOutQueryDataCount
,
1616 (VOID
**) &Private
->TextOutQueryData
1618 if (EFI_ERROR (Status
)) {
1619 return EFI_OUT_OF_RESOURCES
;
1623 // Allocate buffer for the output mode map
1625 Status
= ConSplitterGrowMapTable (Private
);
1626 if (EFI_ERROR (Status
)) {
1627 return EFI_OUT_OF_RESOURCES
;
1630 // As the first textout device, directly add the mode in to QueryData
1631 // and at the same time record the mapping between QueryData and TextOut.
1635 while (Mode
< MaxMode
) {
1636 TextOut
->QueryMode (
1639 &Private
->TextOutQueryData
[Mode
].Columns
,
1640 &Private
->TextOutQueryData
[Mode
].Rows
1642 Private
->TextOutModeMap
[Index
] = Mode
;
1644 Index
+= Private
->TextOutListCount
;
1652 ConSplitterGetIntersection (
1653 IN INT32
*TextOutModeMap
,
1654 IN INT32
*NewlyAddedMap
,
1655 IN UINTN MapStepSize
,
1656 IN UINTN NewMapStepSize
,
1658 OUT INT32
*CurrentMode
1662 INT32
*CurrentMapEntry
;
1663 INT32
*NextMapEntry
;
1664 INT32 CurrentMaxMode
;
1668 CurrentMapEntry
= TextOutModeMap
;
1669 NextMapEntry
= TextOutModeMap
;
1670 CurrentMaxMode
= *MaxMode
;
1671 Mode
= *CurrentMode
;
1673 while (Index
< CurrentMaxMode
) {
1674 if (*NewlyAddedMap
== -1) {
1676 // This mode is not supported any more. Remove it. Special care
1677 // must be taken as this remove will also affect current mode;
1679 if (Index
== *CurrentMode
) {
1681 } else if (Index
< *CurrentMode
) {
1686 if (CurrentMapEntry
!= NextMapEntry
) {
1687 CopyMem (NextMapEntry
, CurrentMapEntry
, MapStepSize
* sizeof (INT32
));
1690 NextMapEntry
+= MapStepSize
;
1693 CurrentMapEntry
+= MapStepSize
;
1694 NewlyAddedMap
+= NewMapStepSize
;
1698 *CurrentMode
= Mode
;
1705 ConSplitterSyncOutputMode (
1706 IN TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
,
1707 IN EFI_SIMPLE_TEXT_OUT_PROTOCOL
*TextOut
1711 Routine Description:
1714 Private - Private data structure.
1715 TextOut - Text Out Protocol.
1722 INT32 CurrentMaxMode
;
1725 INT32
*TextOutModeMap
;
1727 TEXT_OUT_SPLITTER_QUERY_DATA
*TextOutQueryData
;
1733 // Must make sure that current mode won't change even if mode number changes
1735 CurrentMaxMode
= Private
->TextOutMode
.MaxMode
;
1736 TextOutModeMap
= Private
->TextOutModeMap
;
1737 StepSize
= Private
->TextOutListCount
;
1738 TextOutQueryData
= Private
->TextOutQueryData
;
1741 // Query all the mode that the newly added TextOut supports
1744 MapTable
= TextOutModeMap
+ Private
->CurrentNumberOfConsoles
;
1745 while (Mode
< TextOut
->Mode
->MaxMode
) {
1746 TextOut
->QueryMode (TextOut
, Mode
, &Columns
, &Rows
);
1749 // Search the QueryData database to see if they intersects
1752 while (Index
< CurrentMaxMode
) {
1753 if ((TextOutQueryData
[Index
].Rows
== Rows
) && (TextOutQueryData
[Index
].Columns
== Columns
)) {
1754 MapTable
[Index
* StepSize
] = Mode
;
1764 // Now search the TextOutModeMap table to find the intersection of supported
1765 // mode between ConSplitter and the newly added device.
1767 ConSplitterGetIntersection (
1772 &Private
->TextOutMode
.MaxMode
,
1773 &Private
->TextOutMode
.Mode
1781 ConSplitterGetIntersectionBetweenConOutAndStrErr (
1786 Routine Description:
1793 EFI_OUT_OF_RESOURCES
1797 UINTN ConOutNumOfConsoles
;
1798 UINTN StdErrNumOfConsoles
;
1799 TEXT_OUT_AND_GOP_DATA
*ConOutTextOutList
;
1800 TEXT_OUT_AND_GOP_DATA
*StdErrTextOutList
;
1805 INT32 ConOutMaxMode
;
1806 INT32 StdErrMaxMode
;
1809 INT32
*ConOutModeMap
;
1810 INT32
*StdErrModeMap
;
1811 INT32
*ConOutMapTable
;
1812 INT32
*StdErrMapTable
;
1813 TEXT_OUT_SPLITTER_QUERY_DATA
*ConOutQueryData
;
1814 TEXT_OUT_SPLITTER_QUERY_DATA
*StdErrQueryData
;
1815 BOOLEAN FoundTheSameTextOut
;
1816 UINTN ConOutMapTableSize
;
1817 UINTN StdErrMapTableSize
;
1819 ConOutNumOfConsoles
= mConOut
.CurrentNumberOfConsoles
;
1820 StdErrNumOfConsoles
= mStdErr
.CurrentNumberOfConsoles
;
1821 ConOutTextOutList
= mConOut
.TextOutList
;
1822 StdErrTextOutList
= mStdErr
.TextOutList
;
1825 FoundTheSameTextOut
= FALSE
;
1826 while ((Indexi
< ConOutNumOfConsoles
) && (!FoundTheSameTextOut
)) {
1828 while (Indexj
< StdErrNumOfConsoles
) {
1829 if (ConOutTextOutList
->TextOut
== StdErrTextOutList
->TextOut
) {
1830 FoundTheSameTextOut
= TRUE
;
1835 StdErrTextOutList
++;
1839 ConOutTextOutList
++;
1842 if (!FoundTheSameTextOut
) {
1846 // Must make sure that current mode won't change even if mode number changes
1848 ConOutMaxMode
= mConOut
.TextOutMode
.MaxMode
;
1849 ConOutModeMap
= mConOut
.TextOutModeMap
;
1850 ConOutQueryData
= mConOut
.TextOutQueryData
;
1852 StdErrMaxMode
= mStdErr
.TextOutMode
.MaxMode
;
1853 StdErrModeMap
= mStdErr
.TextOutModeMap
;
1854 StdErrQueryData
= mStdErr
.TextOutQueryData
;
1857 // Allocate the map table and set the map table's index to -1.
1859 ConOutMapTableSize
= ConOutMaxMode
* sizeof (INT32
);
1860 ConOutMapTable
= AllocateZeroPool (ConOutMapTableSize
);
1861 if (ConOutMapTable
== NULL
) {
1862 return EFI_OUT_OF_RESOURCES
;
1865 SetMem (ConOutMapTable
, ConOutMapTableSize
, 0xFF);
1867 StdErrMapTableSize
= StdErrMaxMode
* sizeof (INT32
);
1868 StdErrMapTable
= AllocateZeroPool (StdErrMapTableSize
);
1869 if (StdErrMapTable
== NULL
) {
1870 return EFI_OUT_OF_RESOURCES
;
1873 SetMem (StdErrMapTable
, StdErrMapTableSize
, 0xFF);
1876 // Find the intersection of the two set of modes. If they actually intersect, the
1877 // correponding entry in the map table is set to 1.
1880 while (Mode
< ConOutMaxMode
) {
1882 // Search the other's QueryData database to see if they intersect
1885 Rows
= ConOutQueryData
[Mode
].Rows
;
1886 Columns
= ConOutQueryData
[Mode
].Columns
;
1887 while (Index
< StdErrMaxMode
) {
1888 if ((StdErrQueryData
[Index
].Rows
== Rows
) && (StdErrQueryData
[Index
].Columns
== Columns
)) {
1889 ConOutMapTable
[Mode
] = 1;
1890 StdErrMapTable
[Index
] = 1;
1900 // Now search the TextOutModeMap table to find the intersection of supported
1901 // mode between ConSplitter and the newly added device.
1903 ConSplitterGetIntersection (
1906 mConOut
.TextOutListCount
,
1908 &(mConOut
.TextOutMode
.MaxMode
),
1909 &(mConOut
.TextOutMode
.Mode
)
1911 if (mConOut
.TextOutMode
.Mode
< 0) {
1912 mConOut
.TextOut
.SetMode (&(mConOut
.TextOut
), 0);
1915 ConSplitterGetIntersection (
1918 mStdErr
.TextOutListCount
,
1920 &(mStdErr
.TextOutMode
.MaxMode
),
1921 &(mStdErr
.TextOutMode
.Mode
)
1923 if (mStdErr
.TextOutMode
.Mode
< 0) {
1924 mStdErr
.TextOut
.SetMode (&(mStdErr
.TextOut
), 0);
1927 gBS
->FreePool (ConOutMapTable
);
1928 gBS
->FreePool (StdErrMapTable
);
1933 #if (EFI_SPECIFICATION_VERSION >= 0x00020000)
1936 ConSplitterAddGraphicsOutputMode (
1937 IN TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
,
1938 IN EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
,
1939 IN EFI_UGA_DRAW_PROTOCOL
*UgaDraw
1943 Routine Description:
1955 TEXT_OUT_GOP_MODE
*Mode
;
1957 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*Info
;
1958 EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE
*CurrentGraphicsOutputMode
;
1959 TEXT_OUT_GOP_MODE
*ModeBuffer
;
1960 TEXT_OUT_GOP_MODE
*MatchedMode
;
1964 if ((GraphicsOutput
== NULL
) && (UgaDraw
== NULL
)) {
1965 return EFI_UNSUPPORTED
;
1968 CurrentGraphicsOutputMode
= Private
->GraphicsOutput
.Mode
;
1970 if (GraphicsOutput
!= NULL
) {
1971 if (Private
->CurrentNumberOfGraphicsOutput
== 0) {
1973 // This is the first Graphics Output device added
1975 CurrentGraphicsOutputMode
->MaxMode
= GraphicsOutput
->Mode
->MaxMode
;
1976 CurrentGraphicsOutputMode
->Mode
= GraphicsOutput
->Mode
->Mode
;
1977 CopyMem (CurrentGraphicsOutputMode
->Info
, GraphicsOutput
->Mode
->Info
, GraphicsOutput
->Mode
->SizeOfInfo
);
1978 CurrentGraphicsOutputMode
->SizeOfInfo
= GraphicsOutput
->Mode
->SizeOfInfo
;
1979 CurrentGraphicsOutputMode
->FrameBufferBase
= GraphicsOutput
->Mode
->FrameBufferBase
;
1980 CurrentGraphicsOutputMode
->FrameBufferSize
= GraphicsOutput
->Mode
->FrameBufferSize
;
1983 // Allocate resource for the private mode buffer
1985 ModeBuffer
= AllocatePool (sizeof (TEXT_OUT_GOP_MODE
) * GraphicsOutput
->Mode
->MaxMode
);
1986 if (ModeBuffer
== NULL
) {
1987 return EFI_OUT_OF_RESOURCES
;
1989 gBS
->FreePool (Private
->GraphicsOutputModeBuffer
);
1990 Private
->GraphicsOutputModeBuffer
= ModeBuffer
;
1993 // Store all supported display modes to the private mode buffer
1996 for (Index
= 0; Index
< GraphicsOutput
->Mode
->MaxMode
; Index
++) {
1997 Status
= GraphicsOutput
->QueryMode (GraphicsOutput
, (UINT32
) Index
, &SizeOfInfo
, &Info
);
1998 if (EFI_ERROR (Status
)) {
2001 Mode
->HorizontalResolution
= Info
->HorizontalResolution
;
2002 Mode
->VerticalResolution
= Info
->VerticalResolution
;
2004 gBS
->FreePool (Info
);
2008 // Check intersection of display mode
2010 ModeBuffer
= AllocatePool (sizeof (TEXT_OUT_GOP_MODE
) * CurrentGraphicsOutputMode
->MaxMode
);
2011 if (ModeBuffer
== NULL
) {
2012 return EFI_OUT_OF_RESOURCES
;
2015 MatchedMode
= ModeBuffer
;
2016 Mode
= &Private
->GraphicsOutputModeBuffer
[0];
2017 for (Index
= 0; Index
< CurrentGraphicsOutputMode
->MaxMode
; Index
++) {
2020 for (NumberIndex
= 0; NumberIndex
< GraphicsOutput
->Mode
->MaxMode
; NumberIndex
++) {
2021 Status
= GraphicsOutput
->QueryMode (GraphicsOutput
, (UINT32
) NumberIndex
, &SizeOfInfo
, &Info
);
2022 if (EFI_ERROR (Status
)) {
2025 if ((Info
->HorizontalResolution
== Mode
->HorizontalResolution
) &&
2026 (Info
->VerticalResolution
== Mode
->VerticalResolution
)){
2028 gBS
->FreePool (Info
);
2031 gBS
->FreePool (Info
);
2035 CopyMem (MatchedMode
, Mode
, sizeof (TEXT_OUT_GOP_MODE
));
2043 // Drop the old mode buffer, assign it to a new one
2045 gBS
->FreePool (Private
->GraphicsOutputModeBuffer
);
2046 Private
->GraphicsOutputModeBuffer
= ModeBuffer
;
2049 // Physical frame buffer is no longer available when there are more than one physical GOP devices
2051 CurrentGraphicsOutputMode
->MaxMode
= (UINT32
) (((UINTN
) MatchedMode
- (UINTN
) ModeBuffer
) / sizeof (TEXT_OUT_GOP_MODE
));
2052 CurrentGraphicsOutputMode
->Info
->PixelFormat
= PixelBltOnly
;
2053 ZeroMem (&CurrentGraphicsOutputMode
->Info
->PixelInformation
, sizeof (EFI_PIXEL_BITMASK
));
2054 CurrentGraphicsOutputMode
->SizeOfInfo
= sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
);
2055 CurrentGraphicsOutputMode
->FrameBufferBase
= (EFI_PHYSICAL_ADDRESS
) NULL
;
2056 CurrentGraphicsOutputMode
->FrameBufferSize
= 0;
2060 // Select a prefered Display mode 800x600
2062 for (Index
= 0; Index
< CurrentGraphicsOutputMode
->MaxMode
; Index
++) {
2063 Mode
= &Private
->GraphicsOutputModeBuffer
[Index
];
2064 if ((Mode
->HorizontalResolution
== 800) && (Mode
->VerticalResolution
== 600)) {
2069 // Prefered mode is not found, set to mode 0
2071 if (Index
>= CurrentGraphicsOutputMode
->MaxMode
) {
2076 // Current mode number may need update now, so set it to an invalide mode number
2078 CurrentGraphicsOutputMode
->Mode
= 0xffff;
2081 // For UGA device, it's inconvenient to retrieve all the supported display modes.
2082 // To simplify the implementation, only add one resolution(800x600, 32bit color depth) as defined in UEFI spec
2084 CurrentGraphicsOutputMode
->MaxMode
= 1;
2085 CurrentGraphicsOutputMode
->Info
->Version
= 0;
2086 CurrentGraphicsOutputMode
->Info
->HorizontalResolution
= 800;
2087 CurrentGraphicsOutputMode
->Info
->VerticalResolution
= 600;
2088 CurrentGraphicsOutputMode
->Info
->PixelFormat
= PixelBltOnly
;
2089 CurrentGraphicsOutputMode
->Info
->PixelsPerScanLine
= 800;
2090 CurrentGraphicsOutputMode
->SizeOfInfo
= sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
);
2091 CurrentGraphicsOutputMode
->FrameBufferBase
= (EFI_PHYSICAL_ADDRESS
) NULL
;
2092 CurrentGraphicsOutputMode
->FrameBufferSize
= 0;
2095 // Update the private mode buffer
2097 ModeBuffer
= &Private
->GraphicsOutputModeBuffer
[0];
2098 ModeBuffer
->HorizontalResolution
= 800;
2099 ModeBuffer
->VerticalResolution
= 600;
2102 // Current mode is unknow now, set it to an invalid mode number 0xffff
2104 CurrentGraphicsOutputMode
->Mode
= 0xffff;
2109 // Force GraphicsOutput mode to be set,
2110 // regardless whether the console is in EfiConsoleControlScreenGraphics or EfiConsoleControlScreenText mode
2112 Private
->HardwareNeedsStarting
= TRUE
;
2113 Status
= Private
->GraphicsOutput
.SetMode (&Private
->GraphicsOutput
, (UINT32
) Index
);
2115 Private
->CurrentNumberOfGraphicsOutput
++;
2122 ConSplitterTextOutAddDevice (
2123 IN TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
,
2124 IN EFI_SIMPLE_TEXT_OUT_PROTOCOL
*TextOut
,
2125 IN EFI_GRAPHICS_OUTPUT_PROTOCOL
*GraphicsOutput
,
2126 IN EFI_UGA_DRAW_PROTOCOL
*UgaDraw
2130 Routine Description:
2141 UINTN CurrentNumOfConsoles
;
2144 TEXT_OUT_AND_GOP_DATA
*TextAndGop
;
2146 Status
= EFI_SUCCESS
;
2147 CurrentNumOfConsoles
= Private
->CurrentNumberOfConsoles
;
2150 // If the Text Out List is full, enlarge it by calling growbuffer().
2152 while (CurrentNumOfConsoles
>= Private
->TextOutListCount
) {
2153 Status
= ConSplitterGrowBuffer (
2154 sizeof (TEXT_OUT_AND_GOP_DATA
),
2155 &Private
->TextOutListCount
,
2156 (VOID
**) &Private
->TextOutList
2158 if (EFI_ERROR (Status
)) {
2159 return EFI_OUT_OF_RESOURCES
;
2162 // Also need to reallocate the TextOutModeMap table
2164 Status
= ConSplitterGrowMapTable (Private
);
2165 if (EFI_ERROR (Status
)) {
2166 return EFI_OUT_OF_RESOURCES
;
2170 TextAndGop
= &Private
->TextOutList
[CurrentNumOfConsoles
];
2172 TextAndGop
->TextOut
= TextOut
;
2173 TextAndGop
->GraphicsOutput
= GraphicsOutput
;
2174 TextAndGop
->UgaDraw
= UgaDraw
;
2176 if ((GraphicsOutput
== NULL
) && (UgaDraw
== NULL
)) {
2178 // If No UGA device then use the ConOut device
2180 TextAndGop
->TextOutEnabled
= TRUE
;
2183 // If UGA device use ConOut device only used if UGA screen is in Text mode
2185 TextAndGop
->TextOutEnabled
= (BOOLEAN
) (Private
->ConsoleOutputMode
== EfiConsoleControlScreenText
);
2188 if (CurrentNumOfConsoles
== 0) {
2190 // Add the first device's output mode to console splitter's mode list
2192 Status
= ConSplitterAddOutputMode (Private
, TextOut
);
2194 ConSplitterSyncOutputMode (Private
, TextOut
);
2197 Private
->CurrentNumberOfConsoles
++;
2200 // Scan both TextOutList, for the intersection TextOut device
2201 // maybe both ConOut and StdErr incorporate the same Text Out
2202 // device in them, thus the output of both should be synced.
2204 ConSplitterGetIntersectionBetweenConOutAndStrErr ();
2206 CurrentMode
= Private
->TextOutMode
.Mode
;
2207 MaxMode
= Private
->TextOutMode
.MaxMode
;
2208 ASSERT (MaxMode
>= 1);
2210 #if (EFI_SPECIFICATION_VERSION >= 0x00020000)
2211 if ((GraphicsOutput
!= NULL
) || (UgaDraw
!= NULL
)) {
2212 ConSplitterAddGraphicsOutputMode (Private
, GraphicsOutput
, UgaDraw
);
2216 if (Private
->ConsoleOutputMode
== EfiConsoleControlScreenGraphics
&& GraphicsOutput
!= NULL
) {
2218 // We just added a new UGA device in graphics mode
2220 #if (EFI_SPECIFICATION_VERSION >= 0x00020000)
2221 DevNullGopSync (Private
, GraphicsOutput
, UgaDraw
);
2223 DevNullUgaSync (Private
, UgaDraw
);
2225 } else if ((CurrentMode
>= 0) && ((GraphicsOutput
!= NULL
) || (UgaDraw
!= NULL
)) && (CurrentMode
< Private
->TextOutMode
.MaxMode
)) {
2227 // The new console supports the same mode of the current console so sync up
2229 DevNullSyncGopStdOut (Private
);
2232 // If ConOut, then set the mode to Mode #0 which us 80 x 25
2234 Private
->TextOut
.SetMode (&Private
->TextOut
, 0);
2241 ConSplitterTextOutDeleteDevice (
2242 IN TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
,
2243 IN EFI_SIMPLE_TEXT_OUT_PROTOCOL
*TextOut
2247 Routine Description:
2258 UINTN CurrentNumOfConsoles
;
2259 TEXT_OUT_AND_GOP_DATA
*TextOutList
;
2263 // Remove the specified text-out device data structure from the Text out List,
2264 // and rearrange the remaining data structures in the Text out List.
2266 CurrentNumOfConsoles
= Private
->CurrentNumberOfConsoles
;
2267 Index
= (INT32
) CurrentNumOfConsoles
- 1;
2268 TextOutList
= Private
->TextOutList
;
2269 while (Index
>= 0) {
2270 if (TextOutList
->TextOut
== TextOut
) {
2271 CopyMem (TextOutList
, TextOutList
+ 1, sizeof (TEXT_OUT_AND_GOP_DATA
) * Index
);
2272 CurrentNumOfConsoles
--;
2280 // The specified TextOut is not managed by the ConSplitter driver
2283 return EFI_NOT_FOUND
;
2286 if (CurrentNumOfConsoles
== 0) {
2288 // If the number of consoles is zero clear the Dev NULL device
2290 Private
->CurrentNumberOfConsoles
= 0;
2291 Private
->TextOutMode
.MaxMode
= 1;
2292 Private
->TextOutQueryData
[0].Columns
= 80;
2293 Private
->TextOutQueryData
[0].Rows
= 25;
2294 DevNullTextOutSetMode (Private
, 0);
2299 // Max Mode is realy an intersection of the QueryMode command to all
2300 // devices. So we must copy the QueryMode of the first device to
2304 Private
->TextOutQueryData
,
2305 Private
->TextOutQueryDataCount
* sizeof (TEXT_OUT_SPLITTER_QUERY_DATA
)
2308 gBS
->FreePool (Private
->TextOutModeMap
);
2309 Private
->TextOutModeMap
= NULL
;
2310 TextOutList
= Private
->TextOutList
;
2313 // Add the first TextOut to the QueryData array and ModeMap table
2315 Status
= ConSplitterAddOutputMode (Private
, TextOutList
->TextOut
);
2318 // Now add one by one
2321 Private
->CurrentNumberOfConsoles
= 1;
2323 while ((UINTN
) Index
< CurrentNumOfConsoles
) {
2324 ConSplitterSyncOutputMode (Private
, TextOutList
->TextOut
);
2326 Private
->CurrentNumberOfConsoles
++;
2330 ConSplitterGetIntersectionBetweenConOutAndStrErr ();
2335 // ConSplitter TextIn member functions
2339 ConSplitterTextInReset (
2340 IN EFI_SIMPLE_TEXT_IN_PROTOCOL
*This
,
2341 IN BOOLEAN ExtendedVerification
2345 Routine Description:
2346 Reset the input device and optionaly run diagnostics
2349 This - Protocol instance pointer.
2350 ExtendedVerification - Driver may perform diagnostics on reset.
2353 EFI_SUCCESS - The device was reset.
2354 EFI_DEVICE_ERROR - The device is not functioning properly and could
2360 EFI_STATUS ReturnStatus
;
2361 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
2364 Private
= TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
2366 Private
->KeyEventSignalState
= FALSE
;
2369 // return the worst status met
2371 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
2372 Status
= Private
->TextInList
[Index
]->Reset (
2373 Private
->TextInList
[Index
],
2374 ExtendedVerification
2376 if (EFI_ERROR (Status
)) {
2377 ReturnStatus
= Status
;
2381 return ReturnStatus
;
2386 ConSplitterTextInPrivateReadKeyStroke (
2387 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
2388 OUT EFI_INPUT_KEY
*Key
2392 Routine Description:
2393 Reads the next keystroke from the input device. The WaitForKey Event can
2394 be used to test for existance of a keystroke via WaitForEvent () call.
2397 This - Protocol instance pointer.
2398 Key - Driver may perform diagnostics on reset.
2401 EFI_SUCCESS - The keystroke information was returned.
2402 EFI_NOT_READY - There was no keystroke data availiable.
2403 EFI_DEVICE_ERROR - The keydtroke information was not returned due to
2410 EFI_INPUT_KEY CurrentKey
;
2412 Key
->UnicodeChar
= 0;
2413 Key
->ScanCode
= SCAN_NULL
;
2416 // if no physical console input device exists, return EFI_NOT_READY;
2417 // if any physical console input device has key input,
2418 // return the key and EFI_SUCCESS.
2420 for (Index
= 0; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
2421 Status
= Private
->TextInList
[Index
]->ReadKeyStroke (
2422 Private
->TextInList
[Index
],
2425 if (!EFI_ERROR (Status
)) {
2431 return EFI_NOT_READY
;
2435 ConSpliterConssoleControlStdInLocked (
2440 Routine Description:
2441 Return TRUE if StdIn is locked. The ConIn device on the virtual handle is
2442 the only device locked.
2449 FALSE - StdIn working normally
2453 return mConIn
.PasswordEnabled
;
2458 ConSpliterConsoleControlLockStdInEvent (
2464 Routine Description:
2465 This timer event will fire when StdIn is locked. It will check the key
2466 sequence on StdIn to see if it matches the password. Any error in the
2467 password will cause the check to reset. As long a mConIn.PasswordEnabled is
2468 TRUE the StdIn splitter will not report any input.
2471 (Standard EFI_EVENT_NOTIFY)
2480 CHAR16 BackSpaceString
[2];
2481 CHAR16 SpaceString
[2];
2484 Status
= ConSplitterTextInPrivateReadKeyStroke (&mConIn
, &Key
);
2485 if (!EFI_ERROR (Status
)) {
2487 // if it's an ENTER, match password
2489 if ((Key
.UnicodeChar
== CHAR_CARRIAGE_RETURN
) && (Key
.ScanCode
== SCAN_NULL
)) {
2490 mConIn
.PwdAttempt
[mConIn
.PwdIndex
] = CHAR_NULL
;
2491 if (StrCmp (mConIn
.Password
, mConIn
.PwdAttempt
)) {
2493 // Password not match
2495 ConSplitterTextOutOutputString (&mConOut
.TextOut
, (CHAR16
*) L
"\n\rPassword not correct\n\r");
2496 mConIn
.PwdIndex
= 0;
2499 // Key matches password sequence
2501 gBS
->SetTimer (mConIn
.LockEvent
, TimerPeriodic
, 0);
2502 mConIn
.PasswordEnabled
= FALSE
;
2503 Status
= EFI_NOT_READY
;
2505 } else if ((Key
.UnicodeChar
== CHAR_BACKSPACE
) && (Key
.ScanCode
== SCAN_NULL
)) {
2509 if (mConIn
.PwdIndex
> 0) {
2510 BackSpaceString
[0] = CHAR_BACKSPACE
;
2511 BackSpaceString
[1] = 0;
2513 SpaceString
[0] = ' ';
2516 ConSplitterTextOutOutputString (&mConOut
.TextOut
, BackSpaceString
);
2517 ConSplitterTextOutOutputString (&mConOut
.TextOut
, SpaceString
);
2518 ConSplitterTextOutOutputString (&mConOut
.TextOut
, BackSpaceString
);
2522 } else if ((Key
.ScanCode
== SCAN_NULL
) && (Key
.UnicodeChar
>= 32)) {
2524 // If it's not an ENTER, neigher a function key, nor a CTRL-X or ALT-X, record the input
2526 if (mConIn
.PwdIndex
< (MAX_STD_IN_PASSWORD
- 1)) {
2527 if (mConIn
.PwdIndex
== 0) {
2528 ConSplitterTextOutOutputString (&mConOut
.TextOut
, (CHAR16
*) L
"\n\r");
2531 ConSplitterTextOutOutputString (&mConOut
.TextOut
, (CHAR16
*) L
"*");
2532 mConIn
.PwdAttempt
[mConIn
.PwdIndex
] = Key
.UnicodeChar
;
2537 } while (!EFI_ERROR (Status
));
2542 ConSpliterConsoleControlLockStdIn (
2543 IN EFI_CONSOLE_CONTROL_PROTOCOL
*This
,
2548 Routine Description:
2549 If Password is NULL unlock the password state variable and set the event
2550 timer. If the Password is too big return an error. If the Password is valid
2551 Copy the Password and enable state variable and then arm the periodic timer
2556 EFI_SUCCESS - Lock the StdIn device
2557 EFI_INVALID_PARAMETER - Password is NULL
2558 EFI_OUT_OF_RESOURCES - Buffer allocation to store the password fails
2562 if (Password
== NULL
) {
2563 return EFI_INVALID_PARAMETER
;
2566 if (StrLen (Password
) >= MAX_STD_IN_PASSWORD
) {
2568 // Currently have a max password size
2570 return EFI_OUT_OF_RESOURCES
;
2573 // Save the password, initialize state variables and arm event timer
2575 StrCpy (mConIn
.Password
, Password
);
2576 mConIn
.PasswordEnabled
= TRUE
;
2577 mConIn
.PwdIndex
= 0;
2578 gBS
->SetTimer (mConIn
.LockEvent
, TimerPeriodic
, (10000 * 25));
2585 ConSplitterTextInReadKeyStroke (
2586 IN EFI_SIMPLE_TEXT_IN_PROTOCOL
*This
,
2587 OUT EFI_INPUT_KEY
*Key
2591 Routine Description:
2592 Reads the next keystroke from the input device. The WaitForKey Event can
2593 be used to test for existance of a keystroke via WaitForEvent () call.
2594 If the ConIn is password locked make it look like no keystroke is availible
2597 This - Protocol instance pointer.
2598 Key - Driver may perform diagnostics on reset.
2601 EFI_SUCCESS - The keystroke information was returned.
2602 EFI_NOT_READY - There was no keystroke data availiable.
2603 EFI_DEVICE_ERROR - The keydtroke information was not returned due to
2608 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
2610 Private
= TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
2611 if (Private
->PasswordEnabled
) {
2613 // If StdIn Locked return not ready
2615 return EFI_NOT_READY
;
2618 Private
->KeyEventSignalState
= FALSE
;
2620 return ConSplitterTextInPrivateReadKeyStroke (Private
, Key
);
2625 ConSplitterTextInWaitForKey (
2631 Routine Description:
2632 This event agregates all the events of the ConIn devices in the spliter.
2633 If the ConIn is password locked then return.
2634 If any events of physical ConIn devices are signaled, signal the ConIn
2635 spliter event. This will cause the calling code to call
2636 ConSplitterTextInReadKeyStroke ().
2639 Event - The Event assoicated with callback.
2640 Context - Context registered when Event was created.
2648 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
2651 Private
= (TEXT_IN_SPLITTER_PRIVATE_DATA
*) Context
;
2652 if (Private
->PasswordEnabled
) {
2654 // If StdIn Locked return not ready
2660 // if KeyEventSignalState is flagged before, and not cleared by Reset() or ReadKeyStroke()
2662 if (Private
->KeyEventSignalState
) {
2663 gBS
->SignalEvent (Event
);
2667 // if any physical console input device has key input, signal the event.
2669 for (Index
= 0; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
2670 Status
= gBS
->CheckEvent (Private
->TextInList
[Index
]->WaitForKey
);
2671 if (!EFI_ERROR (Status
)) {
2672 gBS
->SignalEvent (Event
);
2673 Private
->KeyEventSignalState
= TRUE
;
2680 ConSplitterSimplePointerReset (
2681 IN EFI_SIMPLE_POINTER_PROTOCOL
*This
,
2682 IN BOOLEAN ExtendedVerification
2686 Routine Description:
2687 Reset the input device and optionaly run diagnostics
2690 This - Protocol instance pointer.
2691 ExtendedVerification - Driver may perform diagnostics on reset.
2694 EFI_SUCCESS - The device was reset.
2695 EFI_DEVICE_ERROR - The device is not functioning properly and could
2701 EFI_STATUS ReturnStatus
;
2702 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
2705 Private
= TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_SIMPLE_POINTER_THIS (This
);
2707 Private
->InputEventSignalState
= FALSE
;
2709 if (Private
->CurrentNumberOfPointers
== 0) {
2713 // return the worst status met
2715 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfPointers
; Index
++) {
2716 Status
= Private
->PointerList
[Index
]->Reset (
2717 Private
->PointerList
[Index
],
2718 ExtendedVerification
2720 if (EFI_ERROR (Status
)) {
2721 ReturnStatus
= Status
;
2725 return ReturnStatus
;
2731 ConSplitterSimplePointerPrivateGetState (
2732 IN TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
,
2733 IN OUT EFI_SIMPLE_POINTER_STATE
*State
2737 Routine Description:
2738 Reads the next keystroke from the input device. The WaitForKey Event can
2739 be used to test for existance of a keystroke via WaitForEvent () call.
2742 This - Protocol instance pointer.
2746 EFI_SUCCESS - The keystroke information was returned.
2747 EFI_NOT_READY - There was no keystroke data availiable.
2748 EFI_DEVICE_ERROR - The keydtroke information was not returned due to
2754 EFI_STATUS ReturnStatus
;
2756 EFI_SIMPLE_POINTER_STATE CurrentState
;
2758 State
->RelativeMovementX
= 0;
2759 State
->RelativeMovementY
= 0;
2760 State
->RelativeMovementZ
= 0;
2761 State
->LeftButton
= FALSE
;
2762 State
->RightButton
= FALSE
;
2765 // if no physical console input device exists, return EFI_NOT_READY;
2766 // if any physical console input device has key input,
2767 // return the key and EFI_SUCCESS.
2769 ReturnStatus
= EFI_NOT_READY
;
2770 for (Index
= 0; Index
< Private
->CurrentNumberOfPointers
; Index
++) {
2772 Status
= Private
->PointerList
[Index
]->GetState (
2773 Private
->PointerList
[Index
],
2776 if (!EFI_ERROR (Status
)) {
2777 if (ReturnStatus
== EFI_NOT_READY
) {
2778 ReturnStatus
= EFI_SUCCESS
;
2781 if (CurrentState
.LeftButton
) {
2782 State
->LeftButton
= TRUE
;
2785 if (CurrentState
.RightButton
) {
2786 State
->RightButton
= TRUE
;
2789 if (CurrentState
.RelativeMovementX
!= 0 && Private
->PointerList
[Index
]->Mode
->ResolutionX
!= 0) {
2790 State
->RelativeMovementX
+= (CurrentState
.RelativeMovementX
* (INT32
) Private
->SimplePointerMode
.ResolutionX
) / (INT32
) Private
->PointerList
[Index
]->Mode
->ResolutionX
;
2793 if (CurrentState
.RelativeMovementY
!= 0 && Private
->PointerList
[Index
]->Mode
->ResolutionY
!= 0) {
2794 State
->RelativeMovementY
+= (CurrentState
.RelativeMovementY
* (INT32
) Private
->SimplePointerMode
.ResolutionY
) / (INT32
) Private
->PointerList
[Index
]->Mode
->ResolutionY
;
2797 if (CurrentState
.RelativeMovementZ
!= 0 && Private
->PointerList
[Index
]->Mode
->ResolutionZ
!= 0) {
2798 State
->RelativeMovementZ
+= (CurrentState
.RelativeMovementZ
* (INT32
) Private
->SimplePointerMode
.ResolutionZ
) / (INT32
) Private
->PointerList
[Index
]->Mode
->ResolutionZ
;
2800 } else if (Status
== EFI_DEVICE_ERROR
) {
2801 ReturnStatus
= EFI_DEVICE_ERROR
;
2805 return ReturnStatus
;
2810 ConSplitterSimplePointerGetState (
2811 IN EFI_SIMPLE_POINTER_PROTOCOL
*This
,
2812 IN OUT EFI_SIMPLE_POINTER_STATE
*State
2816 Routine Description:
2817 Reads the next keystroke from the input device. The WaitForKey Event can
2818 be used to test for existance of a keystroke via WaitForEvent () call.
2819 If the ConIn is password locked make it look like no keystroke is availible
2822 This - Protocol instance pointer.
2826 EFI_SUCCESS - The keystroke information was returned.
2827 EFI_NOT_READY - There was no keystroke data availiable.
2828 EFI_DEVICE_ERROR - The keydtroke information was not returned due to
2833 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
2835 Private
= TEXT_IN_SPLITTER_PRIVATE_DATA_FROM_SIMPLE_POINTER_THIS (This
);
2836 if (Private
->PasswordEnabled
) {
2838 // If StdIn Locked return not ready
2840 return EFI_NOT_READY
;
2843 Private
->InputEventSignalState
= FALSE
;
2845 return ConSplitterSimplePointerPrivateGetState (Private
, State
);
2850 ConSplitterSimplePointerWaitForInput (
2856 Routine Description:
2857 This event agregates all the events of the ConIn devices in the spliter.
2858 If the ConIn is password locked then return.
2859 If any events of physical ConIn devices are signaled, signal the ConIn
2860 spliter event. This will cause the calling code to call
2861 ConSplitterTextInReadKeyStroke ().
2864 Event - The Event assoicated with callback.
2865 Context - Context registered when Event was created.
2873 TEXT_IN_SPLITTER_PRIVATE_DATA
*Private
;
2876 Private
= (TEXT_IN_SPLITTER_PRIVATE_DATA
*) Context
;
2877 if (Private
->PasswordEnabled
) {
2879 // If StdIn Locked return not ready
2885 // if InputEventSignalState is flagged before, and not cleared by Reset() or ReadKeyStroke()
2887 if (Private
->InputEventSignalState
) {
2888 gBS
->SignalEvent (Event
);
2892 // if any physical console input device has key input, signal the event.
2894 for (Index
= 0; Index
< Private
->CurrentNumberOfPointers
; Index
++) {
2895 Status
= gBS
->CheckEvent (Private
->PointerList
[Index
]->WaitForInput
);
2896 if (!EFI_ERROR (Status
)) {
2897 gBS
->SignalEvent (Event
);
2898 Private
->InputEventSignalState
= TRUE
;
2905 ConSplitterTextOutReset (
2906 IN EFI_SIMPLE_TEXT_OUT_PROTOCOL
*This
,
2907 IN BOOLEAN ExtendedVerification
2911 Routine Description:
2912 Reset the text output device hardware and optionaly run diagnostics
2915 This - Protocol instance pointer.
2916 ExtendedVerification - Driver may perform more exhaustive verfication
2917 operation of the device during reset.
2920 EFI_SUCCESS - The text output device was reset.
2921 EFI_DEVICE_ERROR - The text output device is not functioning correctly and
2927 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
2929 EFI_STATUS ReturnStatus
;
2931 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
2934 // return the worst status met
2936 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
2938 if (Private
->TextOutList
[Index
].TextOutEnabled
) {
2940 Status
= Private
->TextOutList
[Index
].TextOut
->Reset (
2941 Private
->TextOutList
[Index
].TextOut
,
2942 ExtendedVerification
2944 if (EFI_ERROR (Status
)) {
2945 ReturnStatus
= Status
;
2950 This
->SetAttribute (This
, EFI_TEXT_ATTR (This
->Mode
->Attribute
& 0x0F, EFI_BACKGROUND_BLACK
));
2952 Status
= DevNullTextOutSetMode (Private
, 0);
2953 if (EFI_ERROR (Status
)) {
2954 ReturnStatus
= Status
;
2957 return ReturnStatus
;
2962 ConSplitterTextOutOutputString (
2963 IN EFI_SIMPLE_TEXT_OUT_PROTOCOL
*This
,
2968 Routine Description:
2969 Write a Unicode string to the output device.
2972 This - Protocol instance pointer.
2973 String - The NULL-terminated Unicode string to be displayed on the output
2974 device(s). All output devices must also support the Unicode
2975 drawing defined in this file.
2978 EFI_SUCCESS - The string was output to the device.
2979 EFI_DEVICE_ERROR - The device reported an error while attempting to output
2981 EFI_UNSUPPORTED - The output device's mode is not currently in a
2983 EFI_WARN_UNKNOWN_GLYPH - This warning code indicates that some of the
2984 characters in the Unicode string could not be
2985 rendered and were skipped.
2990 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
2992 UINTN BackSpaceCount
;
2993 EFI_STATUS ReturnStatus
;
2994 CHAR16
*TargetString
;
2996 This
->SetAttribute (This
, This
->Mode
->Attribute
);
2998 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
3001 for (TargetString
= WString
; *TargetString
; TargetString
++) {
3002 if (*TargetString
== CHAR_BACKSPACE
) {
3008 if (BackSpaceCount
== 0) {
3009 TargetString
= WString
;
3011 TargetString
= AllocatePool (sizeof (CHAR16
) * (StrLen (WString
) + BackSpaceCount
+ 1));
3012 StrCpy (TargetString
, WString
);
3015 // return the worst status met
3017 Status
= DevNullTextOutOutputString (Private
, TargetString
);
3018 if (EFI_ERROR (Status
)) {
3019 ReturnStatus
= Status
;
3022 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
3024 if (Private
->TextOutList
[Index
].TextOutEnabled
) {
3025 Status
= Private
->TextOutList
[Index
].TextOut
->OutputString (
3026 Private
->TextOutList
[Index
].TextOut
,
3029 if (EFI_ERROR (Status
)) {
3030 ReturnStatus
= Status
;
3035 if (BackSpaceCount
) {
3036 gBS
->FreePool (TargetString
);
3039 return ReturnStatus
;
3044 ConSplitterTextOutTestString (
3045 IN EFI_SIMPLE_TEXT_OUT_PROTOCOL
*This
,
3050 Routine Description:
3051 Verifies that all characters in a Unicode string can be output to the
3055 This - Protocol instance pointer.
3056 String - The NULL-terminated Unicode string to be examined for the output
3060 EFI_SUCCESS - The device(s) are capable of rendering the output string.
3061 EFI_UNSUPPORTED - Some of the characters in the Unicode string cannot be
3062 rendered by one or more of the output devices mapped
3068 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
3070 EFI_STATUS ReturnStatus
;
3072 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
3075 // return the worst status met
3077 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
3078 if (Private
->TextOutList
[Index
].TextOutEnabled
) {
3079 Status
= Private
->TextOutList
[Index
].TextOut
->TestString (
3080 Private
->TextOutList
[Index
].TextOut
,
3083 if (EFI_ERROR (Status
)) {
3084 ReturnStatus
= Status
;
3089 // There is no DevNullTextOutTestString () since a Unicode buffer would
3090 // always return EFI_SUCCESS.
3091 // ReturnStatus will be EFI_SUCCESS if no consoles are present
3093 return ReturnStatus
;
3098 ConSplitterTextOutQueryMode (
3099 IN EFI_SIMPLE_TEXT_OUT_PROTOCOL
*This
,
3100 IN UINTN ModeNumber
,
3106 Routine Description:
3107 Returns information for an available text mode that the output device(s)
3111 This - Protocol instance pointer.
3112 ModeNumber - The mode number to return information on.
3113 Columns, Rows - Returns the geometry of the text output device for the
3114 requested ModeNumber.
3117 EFI_SUCCESS - The requested mode information was returned.
3118 EFI_DEVICE_ERROR - The device had an error and could not
3119 complete the request.
3120 EFI_UNSUPPORTED - The mode number was not valid.
3124 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
3126 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
3129 // Check whether param ModeNumber is valid.
3130 // ModeNumber should be within range 0 ~ MaxMode - 1.
3132 if ( (ModeNumber
> (UINTN
)(((UINT32
)-1)>>1)) ) {
3133 return EFI_UNSUPPORTED
;
3136 if ((INT32
) ModeNumber
>= This
->Mode
->MaxMode
) {
3137 return EFI_UNSUPPORTED
;
3140 *Columns
= Private
->TextOutQueryData
[ModeNumber
].Columns
;
3141 *Rows
= Private
->TextOutQueryData
[ModeNumber
].Rows
;
3143 if (*Columns
<= 0 && *Rows
<= 0) {
3144 return EFI_UNSUPPORTED
;
3153 ConSplitterTextOutSetMode (
3154 IN EFI_SIMPLE_TEXT_OUT_PROTOCOL
*This
,
3159 Routine Description:
3160 Sets the output device(s) to a specified mode.
3163 This - Protocol instance pointer.
3164 ModeNumber - The mode number to set.
3167 EFI_SUCCESS - The requested text mode was set.
3168 EFI_DEVICE_ERROR - The device had an error and
3169 could not complete the request.
3170 EFI_UNSUPPORTED - The mode number was not valid.
3175 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
3177 INT32
*TextOutModeMap
;
3178 EFI_STATUS ReturnStatus
;
3180 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
3183 // Check whether param ModeNumber is valid.
3184 // ModeNumber should be within range 0 ~ MaxMode - 1.
3186 if ( (ModeNumber
> (UINTN
)(((UINT32
)-1)>>1)) ) {
3187 return EFI_UNSUPPORTED
;
3190 if ((INT32
) ModeNumber
>= This
->Mode
->MaxMode
) {
3191 return EFI_UNSUPPORTED
;
3194 // If the mode is being set to the curent mode, then just clear the screen and return.
3196 if (Private
->TextOutMode
.Mode
== (INT32
) ModeNumber
) {
3197 return ConSplitterTextOutClearScreen (This
);
3200 // return the worst status met
3202 TextOutModeMap
= Private
->TextOutModeMap
+ Private
->TextOutListCount
* ModeNumber
;
3203 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
3205 if (Private
->TextOutList
[Index
].TextOutEnabled
) {
3206 Status
= Private
->TextOutList
[Index
].TextOut
->SetMode (
3207 Private
->TextOutList
[Index
].TextOut
,
3208 TextOutModeMap
[Index
]
3211 // If this console device is based on a UGA device, then sync up the bitmap from
3212 // the UGA splitter and reclear the text portion of the display in the new mode.
3214 if ((Private
->TextOutList
[Index
].GraphicsOutput
!= NULL
) || (Private
->TextOutList
[Index
].UgaDraw
!= NULL
)) {
3215 Private
->TextOutList
[Index
].TextOut
->ClearScreen (Private
->TextOutList
[Index
].TextOut
);
3218 if (EFI_ERROR (Status
)) {
3219 ReturnStatus
= Status
;
3224 // The DevNull Console will support any possible mode as it allocates memory
3226 Status
= DevNullTextOutSetMode (Private
, ModeNumber
);
3227 if (EFI_ERROR (Status
)) {
3228 ReturnStatus
= Status
;
3231 return ReturnStatus
;
3236 ConSplitterTextOutSetAttribute (
3237 IN EFI_SIMPLE_TEXT_OUT_PROTOCOL
*This
,
3242 Routine Description:
3243 Sets the background and foreground colors for the OutputString () and
3244 ClearScreen () functions.
3247 This - Protocol instance pointer.
3248 Attribute - The attribute to set. Bits 0..3 are the foreground color, and
3249 bits 4..6 are the background color. All other bits are undefined
3250 and must be zero. The valid Attributes are defined in this file.
3253 EFI_SUCCESS - The attribute was set.
3254 EFI_DEVICE_ERROR - The device had an error and
3255 could not complete the request.
3256 EFI_UNSUPPORTED - The attribute requested is not defined.
3261 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
3263 EFI_STATUS ReturnStatus
;
3265 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
3268 // Check whether param Attribute is valid.
3270 if ( (Attribute
> (UINTN
)(((UINT32
)-1)>>1)) ) {
3271 return EFI_UNSUPPORTED
;
3275 // return the worst status met
3277 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
3279 if (Private
->TextOutList
[Index
].TextOutEnabled
) {
3280 Status
= Private
->TextOutList
[Index
].TextOut
->SetAttribute (
3281 Private
->TextOutList
[Index
].TextOut
,
3284 if (EFI_ERROR (Status
)) {
3285 ReturnStatus
= Status
;
3290 Private
->TextOutMode
.Attribute
= (INT32
) Attribute
;
3292 return ReturnStatus
;
3297 ConSplitterTextOutClearScreen (
3298 IN EFI_SIMPLE_TEXT_OUT_PROTOCOL
*This
3302 Routine Description:
3303 Clears the output device(s) display to the currently selected background
3307 This - Protocol instance pointer.
3310 EFI_SUCCESS - The operation completed successfully.
3311 EFI_DEVICE_ERROR - The device had an error and
3312 could not complete the request.
3313 EFI_UNSUPPORTED - The output device is not in a valid text mode.
3318 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
3320 EFI_STATUS ReturnStatus
;
3322 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
3325 // return the worst status met
3327 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
3329 if (Private
->TextOutList
[Index
].TextOutEnabled
) {
3330 Status
= Private
->TextOutList
[Index
].TextOut
->ClearScreen (Private
->TextOutList
[Index
].TextOut
);
3331 if (EFI_ERROR (Status
)) {
3332 ReturnStatus
= Status
;
3337 Status
= DevNullTextOutClearScreen (Private
);
3338 if (EFI_ERROR (Status
)) {
3339 ReturnStatus
= Status
;
3342 return ReturnStatus
;
3347 ConSplitterTextOutSetCursorPosition (
3348 IN EFI_SIMPLE_TEXT_OUT_PROTOCOL
*This
,
3354 Routine Description:
3355 Sets the current coordinates of the cursor position
3358 This - Protocol instance pointer.
3359 Column, Row - the position to set the cursor to. Must be greater than or
3360 equal to zero and less than the number of columns and rows
3364 EFI_SUCCESS - The operation completed successfully.
3365 EFI_DEVICE_ERROR - The device had an error and
3366 could not complete the request.
3367 EFI_UNSUPPORTED - The output device is not in a valid text mode, or the
3368 cursor position is invalid for the current mode.
3373 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
3375 EFI_STATUS ReturnStatus
;
3379 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
3381 MaxColumn
= Private
->TextOutQueryData
[Private
->TextOutMode
.Mode
].Columns
;
3382 MaxRow
= Private
->TextOutQueryData
[Private
->TextOutMode
.Mode
].Rows
;
3384 if (Column
>= MaxColumn
|| Row
>= MaxRow
) {
3385 return EFI_UNSUPPORTED
;
3388 // return the worst status met
3390 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
3392 if (Private
->TextOutList
[Index
].TextOutEnabled
) {
3393 Status
= Private
->TextOutList
[Index
].TextOut
->SetCursorPosition (
3394 Private
->TextOutList
[Index
].TextOut
,
3398 if (EFI_ERROR (Status
)) {
3399 ReturnStatus
= Status
;
3404 DevNullTextOutSetCursorPosition (Private
, Column
, Row
);
3406 return ReturnStatus
;
3411 ConSplitterTextOutEnableCursor (
3412 IN EFI_SIMPLE_TEXT_OUT_PROTOCOL
*This
,
3417 Routine Description:
3418 Makes the cursor visible or invisible
3421 This - Protocol instance pointer.
3422 Visible - If TRUE, the cursor is set to be visible. If FALSE, the cursor is
3423 set to be invisible.
3426 EFI_SUCCESS - The operation completed successfully.
3427 EFI_DEVICE_ERROR - The device had an error and could not complete the
3428 request, or the device does not support changing
3430 EFI_UNSUPPORTED - The output device is not in a valid text mode.
3435 TEXT_OUT_SPLITTER_PRIVATE_DATA
*Private
;
3437 EFI_STATUS ReturnStatus
;
3439 Private
= TEXT_OUT_SPLITTER_PRIVATE_DATA_FROM_THIS (This
);
3442 // return the worst status met
3444 for (Index
= 0, ReturnStatus
= EFI_SUCCESS
; Index
< Private
->CurrentNumberOfConsoles
; Index
++) {
3446 if (Private
->TextOutList
[Index
].TextOutEnabled
) {
3447 Status
= Private
->TextOutList
[Index
].TextOut
->EnableCursor (
3448 Private
->TextOutList
[Index
].TextOut
,
3451 if (EFI_ERROR (Status
)) {
3452 ReturnStatus
= Status
;
3457 DevNullTextOutEnableCursor (Private
, Visible
);
3459 return ReturnStatus
;