2 handles console redirection from boot manager
4 Copyright (c) 2004 - 2015, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15 #include "BootMaint.h"
19 Function compares a device path data structure to that of all the nodes of a
20 second device path instance.
22 @param Multi A pointer to a multi-instance device path data
24 @param Single A pointer to a single-instance device path data
27 @retval TRUE If the Single device path is contained within Multi device path.
28 @retval FALSE The Single device path is not match within Multi device path.
33 IN EFI_DEVICE_PATH_PROTOCOL
*Multi
,
34 IN EFI_DEVICE_PATH_PROTOCOL
*Single
37 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
38 EFI_DEVICE_PATH_PROTOCOL
*DevicePathInst
;
41 if (Multi
== NULL
|| Single
== NULL
) {
46 DevicePathInst
= GetNextDevicePathInstance (&DevicePath
, &Size
);
49 // Search for the match of 'Single' in 'Multi'
51 while (DevicePathInst
!= NULL
) {
53 // If the single device path is found in multiple device paths,
56 if (CompareMem (Single
, DevicePathInst
, Size
) == 0) {
57 FreePool (DevicePathInst
);
61 FreePool (DevicePathInst
);
62 DevicePathInst
= GetNextDevicePathInstance (&DevicePath
, &Size
);
69 Check whether the device path node is ISA Serial Node.
71 @param Acpi Device path node to be checked
73 @retval TRUE It's ISA Serial Node.
74 @retval FALSE It's NOT ISA Serial Node.
79 IN ACPI_HID_DEVICE_PATH
*Acpi
83 (DevicePathType (Acpi
) == ACPI_DEVICE_PATH
) &&
84 (DevicePathSubType (Acpi
) == ACPI_DP
) &&
85 (ReadUnaligned32 (&Acpi
->HID
) == EISA_PNP_ID (0x0501))
90 Update Com Ports attributes from DevicePath
92 @param DevicePath DevicePath that contains Com ports
94 @retval EFI_SUCCESS The update is successful.
98 UpdateComAttributeFromVariable (
99 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
103 Update the multi-instance device path of Terminal Device based on
104 the global TerminalMenu. If ChangeTernimal is TRUE, the terminal
105 device path in the Terminal Device in TerminalMenu is also updated.
107 @param DevicePath The multi-instance device path.
108 @param ChangeTerminal TRUE, then device path in the Terminal Device
109 in TerminalMenu is also updated; FALSE, no update.
111 @return EFI_SUCCESS The function completes successfully.
115 ChangeTerminalDevicePath (
116 IN OUT EFI_DEVICE_PATH_PROTOCOL
*DevicePath
,
117 IN BOOLEAN ChangeTerminal
120 EFI_DEVICE_PATH_PROTOCOL
*Node
;
121 EFI_DEVICE_PATH_PROTOCOL
*Node1
;
122 ACPI_HID_DEVICE_PATH
*Acpi
;
123 UART_DEVICE_PATH
*Uart
;
124 UART_DEVICE_PATH
*Uart1
;
126 BM_TERMINAL_CONTEXT
*NewTerminalContext
;
127 BM_MENU_ENTRY
*NewMenuEntry
;
130 Node
= NextDevicePathNode (Node
);
132 while (!IsDevicePathEnd (Node
)) {
133 Acpi
= (ACPI_HID_DEVICE_PATH
*) Node
;
134 if (IsIsaSerialNode (Acpi
)) {
135 CopyMem (&Com
, &Acpi
->UID
, sizeof (UINT32
));
138 NewMenuEntry
= BOpt_GetMenuEntry (&TerminalMenu
, Com
);
140 NewTerminalContext
= (BM_TERMINAL_CONTEXT
*) NewMenuEntry
->VariableContext
;
141 if ((DevicePathType (Node
) == MESSAGING_DEVICE_PATH
) && (DevicePathSubType (Node
) == MSG_UART_DP
)) {
142 Uart
= (UART_DEVICE_PATH
*) Node
;
145 &NewTerminalContext
->BaudRate
,
151 &NewTerminalContext
->DataBits
,
157 &NewTerminalContext
->Parity
,
163 &NewTerminalContext
->StopBits
,
167 // Change the device path in the ComPort
169 if (ChangeTerminal
) {
170 Node1
= NewTerminalContext
->DevicePath
;
171 Node1
= NextDevicePathNode (Node1
);
172 while (!IsDevicePathEnd (Node1
)) {
173 if ((DevicePathType (Node1
) == MESSAGING_DEVICE_PATH
) && (DevicePathSubType (Node1
) == MSG_UART_DP
)) {
174 Uart1
= (UART_DEVICE_PATH
*) Node1
;
177 &NewTerminalContext
->BaudRate
,
183 &NewTerminalContext
->DataBits
,
189 &NewTerminalContext
->Parity
,
195 &NewTerminalContext
->StopBits
,
203 Node1
= NextDevicePathNode (Node1
);
212 Node
= NextDevicePathNode (Node
);
220 Update the device path that describing a terminal device
221 based on the new BaudRate, Data Bits, parity and Stop Bits
224 @param DevicePath terminal device's path
228 ChangeVariableDevicePath (
229 IN OUT EFI_DEVICE_PATH_PROTOCOL
*DevicePath
232 EFI_DEVICE_PATH_PROTOCOL
*Node
;
233 ACPI_HID_DEVICE_PATH
*Acpi
;
234 UART_DEVICE_PATH
*Uart
;
236 BM_TERMINAL_CONTEXT
*NewTerminalContext
;
237 BM_MENU_ENTRY
*NewMenuEntry
;
240 Node
= NextDevicePathNode (Node
);
242 while (!IsDevicePathEnd (Node
)) {
243 Acpi
= (ACPI_HID_DEVICE_PATH
*) Node
;
244 if (IsIsaSerialNode (Acpi
)) {
245 CopyMem (&Com
, &Acpi
->UID
, sizeof (UINT32
));
248 if ((DevicePathType (Node
) == MESSAGING_DEVICE_PATH
) && (DevicePathSubType (Node
) == MSG_UART_DP
)) {
249 NewMenuEntry
= BOpt_GetMenuEntry (
253 ASSERT (NewMenuEntry
!= NULL
);
254 NewTerminalContext
= (BM_TERMINAL_CONTEXT
*) NewMenuEntry
->VariableContext
;
255 Uart
= (UART_DEVICE_PATH
*) Node
;
258 &NewTerminalContext
->BaudRate
,
264 &NewTerminalContext
->DataBits
,
270 &NewTerminalContext
->Parity
,
276 &NewTerminalContext
->StopBits
,
281 Node
= NextDevicePathNode (Node
);
286 Retrieve ACPI UID of UART from device path
288 @param Handle The handle for the UART device.
289 @param AcpiUid The ACPI UID on output.
291 @retval TRUE Find valid UID from device path
292 @retval FALSE Can't find
297 IN EFI_HANDLE Handle
,
298 IN OUT UINT32
*AcpiUid
302 ACPI_HID_DEVICE_PATH
*Acpi
;
303 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
305 Status
= gBS
->HandleProtocol (
307 &gEfiDevicePathProtocolGuid
,
308 (VOID
**) &DevicePath
310 if (EFI_ERROR (Status
)) {
315 for (; !IsDevicePathEnd (DevicePath
); DevicePath
= NextDevicePathNode (DevicePath
)) {
316 if ((DevicePathType (DevicePath
) == MESSAGING_DEVICE_PATH
) && (DevicePathSubType (DevicePath
) == MSG_UART_DP
)) {
320 // Acpi points to the node before the Uart node
322 Acpi
= (ACPI_HID_DEVICE_PATH
*) DevicePath
;
325 if ((Acpi
!= NULL
) && IsIsaSerialNode (Acpi
)) {
326 if (AcpiUid
!= NULL
) {
327 CopyMem (AcpiUid
, &Acpi
->UID
, sizeof (UINT32
));
336 Sort Uart handles array with Acpi->UID from low to high.
338 @param Handles EFI_SERIAL_IO_PROTOCOL handle buffer
339 @param NoHandles EFI_SERIAL_IO_PROTOCOL handle count
343 IN EFI_HANDLE
*Handles
,
353 EFI_HANDLE TempHandle
;
355 for (Index1
= 0; Index1
< NoHandles
-1; Index1
++) {
356 if (!RetrieveUartUid (Handles
[Index1
], &AcpiUid1
)) {
359 TempHandle
= Handles
[Index1
];
361 TempAcpiUid
= AcpiUid1
;
363 for (Index2
= Index1
+1; Index2
< NoHandles
; Index2
++) {
364 if (!RetrieveUartUid (Handles
[Index2
], &AcpiUid2
)) {
367 if (AcpiUid2
< TempAcpiUid
) {
368 TempAcpiUid
= AcpiUid2
;
369 TempHandle
= Handles
[Index2
];
373 Handles
[Position
] = Handles
[Index1
];
374 Handles
[Index1
] = TempHandle
;
379 Test whether DevicePath is a valid Terminal
382 @param DevicePath DevicePath to be checked
383 @param Termi If DevicePath is valid Terminal, terminal type is returned.
384 @param Com If DevicePath is valid Terminal, Com Port type is returned.
386 @retval TRUE If DevicePath point to a Terminal.
387 @retval FALSE If DevicePath does not point to a Terminal.
391 IsTerminalDevicePath (
392 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
,
393 OUT TYPE_OF_TERMINAL
*Termi
,
398 Build a list containing all serial devices.
401 @retval EFI_SUCCESS The function complete successfully.
402 @retval EFI_UNSUPPORTED No serial ports present.
415 ACPI_HID_DEVICE_PATH
*Acpi
;
416 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
417 EFI_SERIAL_IO_PROTOCOL
*SerialIo
;
418 EFI_DEVICE_PATH_PROTOCOL
*Node
;
419 EFI_DEVICE_PATH_PROTOCOL
*OutDevicePath
;
420 EFI_DEVICE_PATH_PROTOCOL
*InpDevicePath
;
421 EFI_DEVICE_PATH_PROTOCOL
*ErrDevicePath
;
422 BM_MENU_ENTRY
*NewMenuEntry
;
423 BM_TERMINAL_CONTEXT
*NewTerminalContext
;
424 EFI_DEVICE_PATH_PROTOCOL
*NewDevicePath
;
425 VENDOR_DEVICE_PATH Vendor
;
428 // Get all handles that have SerialIo protocol installed
430 InitializeListHead (&TerminalMenu
.Head
);
431 TerminalMenu
.MenuNumber
= 0;
432 Status
= gBS
->LocateHandleBuffer (
434 &gEfiSerialIoProtocolGuid
,
439 if (EFI_ERROR (Status
)) {
441 // No serial ports present
443 return EFI_UNSUPPORTED
;
447 // Sort Uart handles array with Acpi->UID from low to high
448 // then Terminal menu can be built from low Acpi->UID to high Acpi->UID
450 SortedUartHandle (Handles
, NoHandles
);
452 for (Index
= 0; Index
< NoHandles
; Index
++) {
454 // Check to see whether the handle has DevicePath Protocol installed
456 gBS
->HandleProtocol (
458 &gEfiDevicePathProtocolGuid
,
459 (VOID
**) &DevicePath
463 for (Node
= DevicePath
; !IsDevicePathEnd (Node
); Node
= NextDevicePathNode (Node
)) {
464 if ((DevicePathType (Node
) == MESSAGING_DEVICE_PATH
) && (DevicePathSubType (Node
) == MSG_UART_DP
)) {
468 // Acpi points to the node before Uart node
470 Acpi
= (ACPI_HID_DEVICE_PATH
*) Node
;
473 if ((Acpi
!= NULL
) && IsIsaSerialNode (Acpi
)) {
474 NewMenuEntry
= BOpt_CreateMenuEntry (BM_TERMINAL_CONTEXT_SELECT
);
475 if (NewMenuEntry
== NULL
) {
477 return EFI_OUT_OF_RESOURCES
;
480 NewTerminalContext
= (BM_TERMINAL_CONTEXT
*) NewMenuEntry
->VariableContext
;
481 CopyMem (&NewMenuEntry
->OptionNumber
, &Acpi
->UID
, sizeof (UINT32
));
482 NewTerminalContext
->DevicePath
= DuplicateDevicePath (DevicePath
);
484 // BugBug: I have no choice, calling EfiLibStrFromDatahub will hang the system!
485 // coz' the misc data for each platform is not correct, actually it's the device path stored in
486 // datahub which is not completed, so a searching for end of device path will enter a
489 NewMenuEntry
->DisplayString
= EfiLibStrFromDatahub (DevicePath
);
490 if (NULL
== NewMenuEntry
->DisplayString
) {
491 NewMenuEntry
->DisplayString
= UiDevicePathToStr (DevicePath
);
494 NewMenuEntry
->HelpString
= NULL
;
496 gBS
->HandleProtocol (
498 &gEfiSerialIoProtocolGuid
,
503 &NewTerminalContext
->BaudRate
,
504 &SerialIo
->Mode
->BaudRate
,
509 &NewTerminalContext
->DataBits
,
510 &SerialIo
->Mode
->DataBits
,
515 &NewTerminalContext
->Parity
,
516 &SerialIo
->Mode
->Parity
,
521 &NewTerminalContext
->StopBits
,
522 &SerialIo
->Mode
->StopBits
,
525 InsertTailList (&TerminalMenu
.Head
, &NewMenuEntry
->Link
);
526 TerminalMenu
.MenuNumber
++;
529 if (Handles
!= NULL
) {
534 // Get L"ConOut", L"ConIn" and L"ErrOut" from the Var
536 OutDevicePath
= GetEfiGlobalVariable (L
"ConOut");
537 InpDevicePath
= GetEfiGlobalVariable (L
"ConIn");
538 ErrDevicePath
= GetEfiGlobalVariable (L
"ErrOut");
539 if (OutDevicePath
!= NULL
) {
540 UpdateComAttributeFromVariable (OutDevicePath
);
543 if (InpDevicePath
!= NULL
) {
544 UpdateComAttributeFromVariable (InpDevicePath
);
547 if (ErrDevicePath
!= NULL
) {
548 UpdateComAttributeFromVariable (ErrDevicePath
);
551 for (Index
= 0; Index
< TerminalMenu
.MenuNumber
; Index
++) {
552 NewMenuEntry
= BOpt_GetMenuEntry (&TerminalMenu
, Index
);
553 if (NULL
== NewMenuEntry
) {
554 return EFI_NOT_FOUND
;
557 NewTerminalContext
= (BM_TERMINAL_CONTEXT
*) NewMenuEntry
->VariableContext
;
559 NewTerminalContext
->TerminalType
= 0;
560 NewTerminalContext
->IsConIn
= FALSE
;
561 NewTerminalContext
->IsConOut
= FALSE
;
562 NewTerminalContext
->IsStdErr
= FALSE
;
564 Vendor
.Header
.Type
= MESSAGING_DEVICE_PATH
;
565 Vendor
.Header
.SubType
= MSG_VENDOR_DP
;
567 for (Index2
= 0; Index2
< (sizeof (TerminalTypeGuid
) / sizeof (TerminalTypeGuid
[0])); Index2
++) {
568 CopyMem (&Vendor
.Guid
, &TerminalTypeGuid
[Index2
], sizeof (EFI_GUID
));
569 SetDevicePathNodeLength (&Vendor
.Header
, sizeof (VENDOR_DEVICE_PATH
));
570 NewDevicePath
= AppendDevicePathNode (
571 NewTerminalContext
->DevicePath
,
572 (EFI_DEVICE_PATH_PROTOCOL
*) &Vendor
574 if (NewMenuEntry
->HelpString
!= NULL
) {
575 FreePool (NewMenuEntry
->HelpString
);
578 // NewMenuEntry->HelpString = UiDevicePathToStr (NewDevicePath);
579 // NewMenuEntry->DisplayString = NewMenuEntry->HelpString;
581 NewMenuEntry
->HelpString
= NULL
;
583 if (MatchDevicePaths (OutDevicePath
, NewDevicePath
)) {
584 NewTerminalContext
->IsConOut
= TRUE
;
585 NewTerminalContext
->TerminalType
= (UINT8
) Index2
;
588 if (MatchDevicePaths (InpDevicePath
, NewDevicePath
)) {
589 NewTerminalContext
->IsConIn
= TRUE
;
590 NewTerminalContext
->TerminalType
= (UINT8
) Index2
;
593 if (MatchDevicePaths (ErrDevicePath
, NewDevicePath
)) {
594 NewTerminalContext
->IsStdErr
= TRUE
;
595 NewTerminalContext
->TerminalType
= (UINT8
) Index2
;
604 Update Com Ports attributes from DevicePath
606 @param DevicePath DevicePath that contains Com ports
608 @retval EFI_SUCCESS The update is successful.
609 @retval EFI_NOT_FOUND Can not find specific menu entry
612 UpdateComAttributeFromVariable (
613 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
616 EFI_DEVICE_PATH_PROTOCOL
*Node
;
617 EFI_DEVICE_PATH_PROTOCOL
*SerialNode
;
618 ACPI_HID_DEVICE_PATH
*Acpi
;
619 UART_DEVICE_PATH
*Uart
;
620 UART_DEVICE_PATH
*Uart1
;
621 UINTN TerminalNumber
;
622 BM_MENU_ENTRY
*NewMenuEntry
;
623 BM_TERMINAL_CONTEXT
*NewTerminalContext
;
627 Node
= NextDevicePathNode (Node
);
629 for (Index
= 0; Index
< TerminalMenu
.MenuNumber
; Index
++) {
630 while (!IsDevicePathEnd (Node
)) {
631 Acpi
= (ACPI_HID_DEVICE_PATH
*) Node
;
632 if (IsIsaSerialNode (Acpi
)) {
633 CopyMem (&TerminalNumber
, &Acpi
->UID
, sizeof (UINT32
));
636 if ((DevicePathType (Node
) == MESSAGING_DEVICE_PATH
) && (DevicePathSubType (Node
) == MSG_UART_DP
)) {
637 Uart
= (UART_DEVICE_PATH
*) Node
;
638 NewMenuEntry
= BOpt_GetMenuEntry (&TerminalMenu
, TerminalNumber
);
639 if (NULL
== NewMenuEntry
) {
640 return EFI_NOT_FOUND
;
643 NewTerminalContext
= (BM_TERMINAL_CONTEXT
*) NewMenuEntry
->VariableContext
;
645 &NewTerminalContext
->BaudRate
,
651 &NewTerminalContext
->DataBits
,
657 &NewTerminalContext
->Parity
,
663 &NewTerminalContext
->StopBits
,
668 SerialNode
= NewTerminalContext
->DevicePath
;
669 SerialNode
= NextDevicePathNode (SerialNode
);
670 while (!IsDevicePathEnd (SerialNode
)) {
671 if ((DevicePathType (SerialNode
) == MESSAGING_DEVICE_PATH
) && (DevicePathSubType (SerialNode
) == MSG_UART_DP
)) {
673 // Update following device paths according to
674 // previous acquired uart attributes
676 Uart1
= (UART_DEVICE_PATH
*) SerialNode
;
679 &NewTerminalContext
->BaudRate
,
685 &NewTerminalContext
->DataBits
,
690 &NewTerminalContext
->Parity
,
695 &NewTerminalContext
->StopBits
,
702 SerialNode
= NextDevicePathNode (SerialNode
);
709 Node
= NextDevicePathNode (Node
);
720 Build up Console Menu based on types passed in. The type can
721 be BM_CONSOLE_IN_CONTEXT_SELECT, BM_CONSOLE_OUT_CONTEXT_SELECT
722 and BM_CONSOLE_ERR_CONTEXT_SELECT.
724 @param ConsoleMenuType Can be BM_CONSOLE_IN_CONTEXT_SELECT, BM_CONSOLE_OUT_CONTEXT_SELECT
725 and BM_CONSOLE_ERR_CONTEXT_SELECT.
727 @retval EFI_UNSUPPORTED The type passed in is not in the 3 types defined.
728 @retval EFI_NOT_FOUND If the EFI Variable defined in UEFI spec with name "ConOutDev",
729 "ConInDev" or "ConErrDev" doesn't exists.
730 @retval EFI_OUT_OF_RESOURCES Not enough resource to complete the operations.
731 @retval EFI_SUCCESS Function completes successfully.
736 IN UINTN ConsoleMenuType
739 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
740 EFI_DEVICE_PATH_PROTOCOL
*AllDevicePath
;
741 EFI_DEVICE_PATH_PROTOCOL
*MultiDevicePath
;
742 EFI_DEVICE_PATH_PROTOCOL
*DevicePathInst
;
747 BM_MENU_ENTRY
*NewMenuEntry
;
748 BM_CONSOLE_CONTEXT
*NewConsoleContext
;
749 TYPE_OF_TERMINAL Terminal
;
751 BM_MENU_OPTION
*ConsoleMenu
;
754 AllDevicePath
= NULL
;
756 switch (ConsoleMenuType
) {
757 case BM_CONSOLE_IN_CONTEXT_SELECT
:
758 ConsoleMenu
= &ConsoleInpMenu
;
759 DevicePath
= GetEfiGlobalVariable (L
"ConIn");
760 AllDevicePath
= GetEfiGlobalVariable (L
"ConInDev");
763 case BM_CONSOLE_OUT_CONTEXT_SELECT
:
764 ConsoleMenu
= &ConsoleOutMenu
;
765 DevicePath
= GetEfiGlobalVariable (L
"ConOut");
766 AllDevicePath
= GetEfiGlobalVariable (L
"ConOutDev");
769 case BM_CONSOLE_ERR_CONTEXT_SELECT
:
770 ConsoleMenu
= &ConsoleErrMenu
;
771 DevicePath
= GetEfiGlobalVariable (L
"ErrOut");
772 AllDevicePath
= GetEfiGlobalVariable (L
"ErrOutDev");
776 return EFI_UNSUPPORTED
;
779 if (NULL
== AllDevicePath
) {
780 return EFI_NOT_FOUND
;
783 InitializeListHead (&ConsoleMenu
->Head
);
785 AllCount
= EfiDevicePathInstanceCount (AllDevicePath
);
786 ConsoleMenu
->MenuNumber
= 0;
788 // Following is menu building up for Console Devices selected.
790 MultiDevicePath
= AllDevicePath
;
792 for (Index
= 0; Index
< AllCount
; Index
++) {
793 DevicePathInst
= GetNextDevicePathInstance (&MultiDevicePath
, &Size
);
795 NewMenuEntry
= BOpt_CreateMenuEntry (BM_CONSOLE_CONTEXT_SELECT
);
796 if (NULL
== NewMenuEntry
) {
797 return EFI_OUT_OF_RESOURCES
;
800 NewConsoleContext
= (BM_CONSOLE_CONTEXT
*) NewMenuEntry
->VariableContext
;
801 NewMenuEntry
->OptionNumber
= Index2
;
803 NewConsoleContext
->DevicePath
= DuplicateDevicePath (DevicePathInst
);
804 ASSERT (NewConsoleContext
->DevicePath
!= NULL
);
805 NewMenuEntry
->DisplayString
= EfiLibStrFromDatahub (NewConsoleContext
->DevicePath
);
806 if (NULL
== NewMenuEntry
->DisplayString
) {
807 NewMenuEntry
->DisplayString
= UiDevicePathToStr (NewConsoleContext
->DevicePath
);
810 NewConsoleContext
->IsTerminal
= IsTerminalDevicePath (
811 NewConsoleContext
->DevicePath
,
816 NewConsoleContext
->IsActive
= MatchDevicePaths (
818 NewConsoleContext
->DevicePath
821 if (NewConsoleContext
->IsTerminal
) {
822 BOpt_DestroyMenuEntry (NewMenuEntry
);
825 ConsoleMenu
->MenuNumber
++;
826 InsertTailList (&ConsoleMenu
->Head
, &NewMenuEntry
->Link
);
834 Build up ConsoleOutMenu, ConsoleInpMenu and ConsoleErrMenu
836 @retval EFI_SUCCESS The function always complete successfully.
844 GetConsoleMenu (BM_CONSOLE_IN_CONTEXT_SELECT
);
845 GetConsoleMenu (BM_CONSOLE_OUT_CONTEXT_SELECT
);
846 GetConsoleMenu (BM_CONSOLE_ERR_CONTEXT_SELECT
);
851 Free ConsoleOutMenu, ConsoleInpMenu and ConsoleErrMenu
853 @retval EFI_SUCCESS The function always complete successfully.
860 BOpt_FreeMenu (&ConsoleOutMenu
);
861 BOpt_FreeMenu (&ConsoleInpMenu
);
862 BOpt_FreeMenu (&ConsoleErrMenu
);
863 BOpt_FreeMenu (&TerminalMenu
);
868 Test whether DevicePath is a valid Terminal
871 @param DevicePath DevicePath to be checked
872 @param Termi If DevicePath is valid Terminal, terminal type is returned.
873 @param Com If DevicePath is valid Terminal, Com Port type is returned.
875 @retval TRUE If DevicePath point to a Terminal.
876 @retval FALSE If DevicePath does not point to a Terminal.
880 IsTerminalDevicePath (
881 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
,
882 OUT TYPE_OF_TERMINAL
*Termi
,
887 EFI_DEVICE_PATH_PROTOCOL
*Node
;
888 VENDOR_DEVICE_PATH
*Vendor
;
889 UART_DEVICE_PATH
*Uart
;
890 ACPI_HID_DEVICE_PATH
*Acpi
;
897 for (Node
= DevicePath
; !IsDevicePathEnd (Node
); Node
= NextDevicePathNode (Node
)) {
899 // Vendor points to the node before the End node
901 Vendor
= (VENDOR_DEVICE_PATH
*) Node
;
903 if ((DevicePathType (Node
) == MESSAGING_DEVICE_PATH
) && (DevicePathSubType (Node
) == MSG_UART_DP
)) {
904 Uart
= (UART_DEVICE_PATH
*) Node
;
909 // Acpi points to the node before the UART node
911 Acpi
= (ACPI_HID_DEVICE_PATH
*) Node
;
915 if (Vendor
== NULL
||
916 DevicePathType (Vendor
) != MESSAGING_DEVICE_PATH
||
917 DevicePathSubType (Vendor
) != MSG_VENDOR_DP
||
923 // There are four kinds of Terminal types
924 // check to see whether this devicepath
925 // is one of that type
927 if (CompareGuid (&Vendor
->Guid
, &TerminalTypeGuid
[0])) {
928 *Termi
= TerminalTypePcAnsi
;
931 if (CompareGuid (&Vendor
->Guid
, &TerminalTypeGuid
[1])) {
932 *Termi
= TerminalTypeVt100
;
935 if (CompareGuid (&Vendor
->Guid
, &TerminalTypeGuid
[2])) {
936 *Termi
= TerminalTypeVt100Plus
;
939 if (CompareGuid (&Vendor
->Guid
, &TerminalTypeGuid
[3])) {
940 *Termi
= TerminalTypeVtUtf8
;
943 if (CompareGuid (&Vendor
->Guid
, &TerminalTypeGuid
[4])) {
944 *Termi
= TerminalTypeTtyTerm
;
958 if ((Acpi
!= NULL
) && IsIsaSerialNode (Acpi
)) {
959 CopyMem (Com
, &Acpi
->UID
, sizeof (UINT32
));
968 Get mode number according to column and row
970 @param CallbackData The BMM context data.
974 IN BMM_CALLBACK_DATA
*CallbackData
984 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*ConOut
;
986 ConOut
= gST
->ConOut
;
987 MaxMode
= (UINTN
) (ConOut
->Mode
->MaxMode
);
989 CurrentCol
= PcdGet32 (PcdSetupConOutColumn
);
990 CurrentRow
= PcdGet32 (PcdSetupConOutRow
);
991 for (Mode
= 0; Mode
< MaxMode
; Mode
++) {
992 Status
= ConOut
->QueryMode (ConOut
, Mode
, &Col
, &Row
);
993 if (!EFI_ERROR(Status
)) {
994 if (CurrentCol
== Col
&& CurrentRow
== Row
) {
995 CallbackData
->BmmFakeNvData
.ConsoleOutMode
= (UINT16
) Mode
;