2 handles console redirection from boot manager
4 Copyright (c) 2004 - 2010, 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"
18 Check whether the device path node is ISA Serial Node.
20 @param Acpi Device path node to be checked
22 @retval TRUE It's ISA Serial Node.
23 @retval FALSE It's NOT ISA Serial Node.
28 IN ACPI_HID_DEVICE_PATH
*Acpi
32 (DevicePathType (Acpi
) == ACPI_DEVICE_PATH
) &&
33 (DevicePathSubType (Acpi
) == ACPI_DP
) &&
34 (ReadUnaligned32 (&Acpi
->HID
) == EISA_PNP_ID (0x0501))
39 Update Com Ports attributes from DevicePath
41 @param DevicePath DevicePath that contains Com ports
43 @retval EFI_SUCCESS The update is successful.
47 UpdateComAttributeFromVariable (
48 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
52 Update the multi-instance device path of Terminal Device based on
53 the global TerminalMenu. If ChangeTernimal is TRUE, the terminal
54 device path in the Terminal Device in TerminalMenu is also updated.
56 @param DevicePath The multi-instance device path.
57 @param ChangeTerminal TRUE, then device path in the Terminal Device
58 in TerminalMenu is also updated; FALSE, no update.
60 @return EFI_SUCCESS The function completes successfully.
64 ChangeTerminalDevicePath (
65 IN OUT EFI_DEVICE_PATH_PROTOCOL
*DevicePath
,
66 IN BOOLEAN ChangeTerminal
69 EFI_DEVICE_PATH_PROTOCOL
*Node
;
70 EFI_DEVICE_PATH_PROTOCOL
*Node1
;
71 ACPI_HID_DEVICE_PATH
*Acpi
;
72 UART_DEVICE_PATH
*Uart
;
73 UART_DEVICE_PATH
*Uart1
;
75 BM_TERMINAL_CONTEXT
*NewTerminalContext
;
76 BM_MENU_ENTRY
*NewMenuEntry
;
79 Node
= NextDevicePathNode (Node
);
81 while (!IsDevicePathEnd (Node
)) {
82 Acpi
= (ACPI_HID_DEVICE_PATH
*) Node
;
83 if (IsIsaSerialNode (Acpi
)) {
84 CopyMem (&Com
, &Acpi
->UID
, sizeof (UINT32
));
87 NewMenuEntry
= BOpt_GetMenuEntry (&TerminalMenu
, Com
);
89 NewTerminalContext
= (BM_TERMINAL_CONTEXT
*) NewMenuEntry
->VariableContext
;
90 if ((DevicePathType (Node
) == MESSAGING_DEVICE_PATH
) && (DevicePathSubType (Node
) == MSG_UART_DP
)) {
91 Uart
= (UART_DEVICE_PATH
*) Node
;
94 &NewTerminalContext
->BaudRate
,
100 &NewTerminalContext
->DataBits
,
106 &NewTerminalContext
->Parity
,
112 &NewTerminalContext
->StopBits
,
116 // Change the device path in the ComPort
118 if (ChangeTerminal
) {
119 Node1
= NewTerminalContext
->DevicePath
;
120 Node1
= NextDevicePathNode (Node1
);
121 while (!IsDevicePathEnd (Node1
)) {
122 if ((DevicePathType (Node1
) == MESSAGING_DEVICE_PATH
) && (DevicePathSubType (Node1
) == MSG_UART_DP
)) {
123 Uart1
= (UART_DEVICE_PATH
*) Node1
;
126 &NewTerminalContext
->BaudRate
,
132 &NewTerminalContext
->DataBits
,
138 &NewTerminalContext
->Parity
,
144 &NewTerminalContext
->StopBits
,
152 Node1
= NextDevicePathNode (Node1
);
161 Node
= NextDevicePathNode (Node
);
169 Update the device path that describing a terminal device
170 based on the new BaudRate, Data Bits, parity and Stop Bits
173 @param DevicePath terminal device's path
177 ChangeVariableDevicePath (
178 IN OUT EFI_DEVICE_PATH_PROTOCOL
*DevicePath
181 EFI_DEVICE_PATH_PROTOCOL
*Node
;
182 ACPI_HID_DEVICE_PATH
*Acpi
;
183 UART_DEVICE_PATH
*Uart
;
185 BM_TERMINAL_CONTEXT
*NewTerminalContext
;
186 BM_MENU_ENTRY
*NewMenuEntry
;
189 Node
= NextDevicePathNode (Node
);
191 while (!IsDevicePathEnd (Node
)) {
192 Acpi
= (ACPI_HID_DEVICE_PATH
*) Node
;
193 if (IsIsaSerialNode (Acpi
)) {
194 CopyMem (&Com
, &Acpi
->UID
, sizeof (UINT32
));
197 if ((DevicePathType (Node
) == MESSAGING_DEVICE_PATH
) && (DevicePathSubType (Node
) == MSG_UART_DP
)) {
198 NewMenuEntry
= BOpt_GetMenuEntry (
202 ASSERT (NewMenuEntry
!= NULL
);
203 NewTerminalContext
= (BM_TERMINAL_CONTEXT
*) NewMenuEntry
->VariableContext
;
204 Uart
= (UART_DEVICE_PATH
*) Node
;
207 &NewTerminalContext
->BaudRate
,
213 &NewTerminalContext
->DataBits
,
219 &NewTerminalContext
->Parity
,
225 &NewTerminalContext
->StopBits
,
230 Node
= NextDevicePathNode (Node
);
235 Retrieve ACPI UID of UART from device path
237 @param Handle The handle for the UART device.
238 @param AcpiUid The ACPI UID on output.
240 @retval TRUE Find valid UID from device path
241 @retval FALSE Can't find
246 IN EFI_HANDLE Handle
,
247 IN OUT UINT32
*AcpiUid
251 ACPI_HID_DEVICE_PATH
*Acpi
;
252 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
254 Status
= gBS
->HandleProtocol (
256 &gEfiDevicePathProtocolGuid
,
257 (VOID
**) &DevicePath
259 if (EFI_ERROR (Status
)) {
264 for (; !IsDevicePathEnd (DevicePath
); DevicePath
= NextDevicePathNode (DevicePath
)) {
265 if ((DevicePathType (DevicePath
) == MESSAGING_DEVICE_PATH
) && (DevicePathSubType (DevicePath
) == MSG_UART_DP
)) {
269 // Acpi points to the node before the Uart node
271 Acpi
= (ACPI_HID_DEVICE_PATH
*) DevicePath
;
274 if ((Acpi
!= NULL
) && IsIsaSerialNode (Acpi
)) {
275 if (AcpiUid
!= NULL
) {
276 CopyMem (AcpiUid
, &Acpi
->UID
, sizeof (UINT32
));
285 Sort Uart handles array with Acpi->UID from low to high.
287 @param Handles EFI_SERIAL_IO_PROTOCOL handle buffer
288 @param NoHandles EFI_SERIAL_IO_PROTOCOL handle count
292 IN EFI_HANDLE
*Handles
,
302 EFI_HANDLE TempHandle
;
304 for (Index1
= 0; Index1
< NoHandles
-1; Index1
++) {
305 if (!RetrieveUartUid (Handles
[Index1
], &AcpiUid1
)) {
308 TempHandle
= Handles
[Index1
];
310 TempAcpiUid
= AcpiUid1
;
312 for (Index2
= Index1
+1; Index2
< NoHandles
; Index2
++) {
313 if (!RetrieveUartUid (Handles
[Index2
], &AcpiUid2
)) {
316 if (AcpiUid2
< TempAcpiUid
) {
317 TempAcpiUid
= AcpiUid2
;
318 TempHandle
= Handles
[Index2
];
322 Handles
[Position
] = Handles
[Index1
];
323 Handles
[Index1
] = TempHandle
;
328 Test whether DevicePath is a valid Terminal
331 @param DevicePath DevicePath to be checked
332 @param Termi If DevicePath is valid Terminal, terminal type is returned.
333 @param Com If DevicePath is valid Terminal, Com Port type is returned.
335 @retval TRUE If DevicePath point to a Terminal.
336 @retval FALSE If DevicePath does not point to a Terminal.
340 IsTerminalDevicePath (
341 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
,
342 OUT TYPE_OF_TERMINAL
*Termi
,
347 Build a list containing all serial devices.
350 @retval EFI_SUCCESS The function complete successfully.
351 @retval EFI_UNSUPPORTED No serial ports present.
364 ACPI_HID_DEVICE_PATH
*Acpi
;
365 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
366 EFI_SERIAL_IO_PROTOCOL
*SerialIo
;
367 EFI_DEVICE_PATH_PROTOCOL
*Node
;
368 EFI_DEVICE_PATH_PROTOCOL
*OutDevicePath
;
369 EFI_DEVICE_PATH_PROTOCOL
*InpDevicePath
;
370 EFI_DEVICE_PATH_PROTOCOL
*ErrDevicePath
;
371 BM_MENU_ENTRY
*NewMenuEntry
;
372 BM_TERMINAL_CONTEXT
*NewTerminalContext
;
373 EFI_DEVICE_PATH_PROTOCOL
*NewDevicePath
;
374 VENDOR_DEVICE_PATH Vendor
;
376 // Get all handles that have SerialIo protocol installed
378 InitializeListHead (&TerminalMenu
.Head
);
379 TerminalMenu
.MenuNumber
= 0;
380 Status
= gBS
->LocateHandleBuffer (
382 &gEfiSerialIoProtocolGuid
,
387 if (EFI_ERROR (Status
)) {
389 // No serial ports present
391 return EFI_UNSUPPORTED
;
395 // Sort Uart handles array with Acpi->UID from low to high
396 // then Terminal menu can be built from low Acpi->UID to high Acpi->UID
398 SortedUartHandle (Handles
, NoHandles
);
400 for (Index
= 0; Index
< NoHandles
; Index
++) {
402 // Check to see whether the handle has DevicePath Protocol installed
404 gBS
->HandleProtocol (
406 &gEfiDevicePathProtocolGuid
,
407 (VOID
**) &DevicePath
411 for (Node
= DevicePath
; !IsDevicePathEnd (Node
); Node
= NextDevicePathNode (Node
)) {
412 if ((DevicePathType (Node
) == MESSAGING_DEVICE_PATH
) && (DevicePathSubType (Node
) == MSG_UART_DP
)) {
416 // Acpi points to the node before Uart node
418 Acpi
= (ACPI_HID_DEVICE_PATH
*) Node
;
421 if ((Acpi
!= NULL
) && IsIsaSerialNode (Acpi
)) {
422 NewMenuEntry
= BOpt_CreateMenuEntry (BM_TERMINAL_CONTEXT_SELECT
);
423 if (NewMenuEntry
== NULL
) {
425 return EFI_OUT_OF_RESOURCES
;
428 NewTerminalContext
= (BM_TERMINAL_CONTEXT
*) NewMenuEntry
->VariableContext
;
429 CopyMem (&NewMenuEntry
->OptionNumber
, &Acpi
->UID
, sizeof (UINT32
));
430 NewTerminalContext
->DevicePath
= DuplicateDevicePath (DevicePath
);
432 // BugBug: I have no choice, calling EfiLibStrFromDatahub will hang the system!
433 // coz' the misc data for each platform is not correct, actually it's the device path stored in
434 // datahub which is not completed, so a searching for end of device path will enter a
437 NewMenuEntry
->DisplayString
= EfiLibStrFromDatahub (DevicePath
);
438 if (NULL
== NewMenuEntry
->DisplayString
) {
439 NewMenuEntry
->DisplayString
= DevicePathToStr (DevicePath
);
442 NewMenuEntry
->HelpString
= NULL
;
444 gBS
->HandleProtocol (
446 &gEfiSerialIoProtocolGuid
,
451 &NewTerminalContext
->BaudRate
,
452 &SerialIo
->Mode
->BaudRate
,
457 &NewTerminalContext
->DataBits
,
458 &SerialIo
->Mode
->DataBits
,
463 &NewTerminalContext
->Parity
,
464 &SerialIo
->Mode
->Parity
,
469 &NewTerminalContext
->StopBits
,
470 &SerialIo
->Mode
->StopBits
,
473 InsertTailList (&TerminalMenu
.Head
, &NewMenuEntry
->Link
);
474 TerminalMenu
.MenuNumber
++;
477 if (Handles
!= NULL
) {
482 // Get L"ConOut", L"ConIn" and L"ErrOut" from the Var
484 OutDevicePath
= EfiLibGetVariable (L
"ConOut", &gEfiGlobalVariableGuid
);
485 InpDevicePath
= EfiLibGetVariable (L
"ConIn", &gEfiGlobalVariableGuid
);
486 ErrDevicePath
= EfiLibGetVariable (L
"ErrOut", &gEfiGlobalVariableGuid
);
487 if (OutDevicePath
!= NULL
) {
488 UpdateComAttributeFromVariable (OutDevicePath
);
491 if (InpDevicePath
!= NULL
) {
492 UpdateComAttributeFromVariable (InpDevicePath
);
495 if (ErrDevicePath
!= NULL
) {
496 UpdateComAttributeFromVariable (ErrDevicePath
);
499 for (Index
= 0; Index
< TerminalMenu
.MenuNumber
; Index
++) {
500 NewMenuEntry
= BOpt_GetMenuEntry (&TerminalMenu
, Index
);
501 if (NULL
== NewMenuEntry
) {
502 return EFI_NOT_FOUND
;
505 NewTerminalContext
= (BM_TERMINAL_CONTEXT
*) NewMenuEntry
->VariableContext
;
507 NewTerminalContext
->TerminalType
= 0;
508 NewTerminalContext
->IsConIn
= FALSE
;
509 NewTerminalContext
->IsConOut
= FALSE
;
510 NewTerminalContext
->IsStdErr
= FALSE
;
512 Vendor
.Header
.Type
= MESSAGING_DEVICE_PATH
;
513 Vendor
.Header
.SubType
= MSG_VENDOR_DP
;
515 for (Index2
= 0; Index2
< 4; Index2
++) {
516 CopyMem (&Vendor
.Guid
, &TerminalTypeGuid
[Index2
], sizeof (EFI_GUID
));
517 SetDevicePathNodeLength (&Vendor
.Header
, sizeof (VENDOR_DEVICE_PATH
));
518 NewDevicePath
= AppendDevicePathNode (
519 NewTerminalContext
->DevicePath
,
520 (EFI_DEVICE_PATH_PROTOCOL
*) &Vendor
522 if (NewMenuEntry
->HelpString
!= NULL
) {
523 FreePool (NewMenuEntry
->HelpString
);
526 // NewMenuEntry->HelpString = DevicePathToStr (NewDevicePath);
527 // NewMenuEntry->DisplayString = NewMenuEntry->HelpString;
529 NewMenuEntry
->HelpString
= NULL
;
531 if (BdsLibMatchDevicePaths (OutDevicePath
, NewDevicePath
)) {
532 NewTerminalContext
->IsConOut
= TRUE
;
533 NewTerminalContext
->TerminalType
= (UINT8
) Index2
;
536 if (BdsLibMatchDevicePaths (InpDevicePath
, NewDevicePath
)) {
537 NewTerminalContext
->IsConIn
= TRUE
;
538 NewTerminalContext
->TerminalType
= (UINT8
) Index2
;
541 if (BdsLibMatchDevicePaths (ErrDevicePath
, NewDevicePath
)) {
542 NewTerminalContext
->IsStdErr
= TRUE
;
543 NewTerminalContext
->TerminalType
= (UINT8
) Index2
;
552 Update Com Ports attributes from DevicePath
554 @param DevicePath DevicePath that contains Com ports
556 @retval EFI_SUCCESS The update is successful.
557 @retval EFI_NOT_FOUND Can not find specific menu entry
560 UpdateComAttributeFromVariable (
561 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
564 EFI_DEVICE_PATH_PROTOCOL
*Node
;
565 EFI_DEVICE_PATH_PROTOCOL
*SerialNode
;
566 ACPI_HID_DEVICE_PATH
*Acpi
;
567 UART_DEVICE_PATH
*Uart
;
568 UART_DEVICE_PATH
*Uart1
;
569 UINTN TerminalNumber
;
570 BM_MENU_ENTRY
*NewMenuEntry
;
571 BM_TERMINAL_CONTEXT
*NewTerminalContext
;
575 Node
= NextDevicePathNode (Node
);
577 for (Index
= 0; Index
< TerminalMenu
.MenuNumber
; Index
++) {
578 while (!IsDevicePathEnd (Node
)) {
579 Acpi
= (ACPI_HID_DEVICE_PATH
*) Node
;
580 if (IsIsaSerialNode (Acpi
)) {
581 CopyMem (&TerminalNumber
, &Acpi
->UID
, sizeof (UINT32
));
584 if ((DevicePathType (Node
) == MESSAGING_DEVICE_PATH
) && (DevicePathSubType (Node
) == MSG_UART_DP
)) {
585 Uart
= (UART_DEVICE_PATH
*) Node
;
586 NewMenuEntry
= BOpt_GetMenuEntry (&TerminalMenu
, TerminalNumber
);
587 if (NULL
== NewMenuEntry
) {
588 return EFI_NOT_FOUND
;
591 NewTerminalContext
= (BM_TERMINAL_CONTEXT
*) NewMenuEntry
->VariableContext
;
593 &NewTerminalContext
->BaudRate
,
599 &NewTerminalContext
->DataBits
,
605 &NewTerminalContext
->Parity
,
611 &NewTerminalContext
->StopBits
,
616 SerialNode
= NewTerminalContext
->DevicePath
;
617 SerialNode
= NextDevicePathNode (SerialNode
);
618 while (!IsDevicePathEnd (SerialNode
)) {
619 if ((DevicePathType (SerialNode
) == MESSAGING_DEVICE_PATH
) && (DevicePathSubType (SerialNode
) == MSG_UART_DP
)) {
621 // Update following device paths according to
622 // previous acquired uart attributes
624 Uart1
= (UART_DEVICE_PATH
*) SerialNode
;
627 &NewTerminalContext
->BaudRate
,
633 &NewTerminalContext
->DataBits
,
638 &NewTerminalContext
->Parity
,
643 &NewTerminalContext
->StopBits
,
650 SerialNode
= NextDevicePathNode (SerialNode
);
657 Node
= NextDevicePathNode (Node
);
668 Build up Console Menu based on types passed in. The type can
669 be BM_CONSOLE_IN_CONTEXT_SELECT, BM_CONSOLE_OUT_CONTEXT_SELECT
670 and BM_CONSOLE_ERR_CONTEXT_SELECT.
672 @param ConsoleMenuType Can be BM_CONSOLE_IN_CONTEXT_SELECT, BM_CONSOLE_OUT_CONTEXT_SELECT
673 and BM_CONSOLE_ERR_CONTEXT_SELECT.
675 @retval EFI_UNSUPPORTED The type passed in is not in the 3 types defined.
676 @retval EFI_NOT_FOUND If the EFI Variable defined in UEFI spec with name "ConOutDev",
677 "ConInDev" or "ConErrDev" doesn't exists.
678 @retval EFI_OUT_OF_RESOURCES Not enough resource to complete the operations.
679 @retval EFI_SUCCESS Function completes successfully.
684 IN UINTN ConsoleMenuType
687 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
688 EFI_DEVICE_PATH_PROTOCOL
*AllDevicePath
;
689 EFI_DEVICE_PATH_PROTOCOL
*MultiDevicePath
;
690 EFI_DEVICE_PATH_PROTOCOL
*DevicePathInst
;
695 BM_MENU_ENTRY
*NewMenuEntry
;
696 BM_CONSOLE_CONTEXT
*NewConsoleContext
;
697 TYPE_OF_TERMINAL Terminal
;
699 BM_MENU_OPTION
*ConsoleMenu
;
702 AllDevicePath
= NULL
;
704 switch (ConsoleMenuType
) {
705 case BM_CONSOLE_IN_CONTEXT_SELECT
:
706 ConsoleMenu
= &ConsoleInpMenu
;
707 DevicePath
= EfiLibGetVariable (
709 &gEfiGlobalVariableGuid
712 AllDevicePath
= EfiLibGetVariable (
714 &gEfiGlobalVariableGuid
718 case BM_CONSOLE_OUT_CONTEXT_SELECT
:
719 ConsoleMenu
= &ConsoleOutMenu
;
720 DevicePath
= EfiLibGetVariable (
722 &gEfiGlobalVariableGuid
725 AllDevicePath
= EfiLibGetVariable (
727 &gEfiGlobalVariableGuid
731 case BM_CONSOLE_ERR_CONTEXT_SELECT
:
732 ConsoleMenu
= &ConsoleErrMenu
;
733 DevicePath
= EfiLibGetVariable (
735 &gEfiGlobalVariableGuid
738 AllDevicePath
= EfiLibGetVariable (
740 &gEfiGlobalVariableGuid
745 return EFI_UNSUPPORTED
;
748 if (NULL
== AllDevicePath
) {
749 return EFI_NOT_FOUND
;
752 InitializeListHead (&ConsoleMenu
->Head
);
754 AllCount
= EfiDevicePathInstanceCount (AllDevicePath
);
755 ConsoleMenu
->MenuNumber
= 0;
757 // Following is menu building up for Console Devices selected.
759 MultiDevicePath
= AllDevicePath
;
761 for (Index
= 0; Index
< AllCount
; Index
++) {
762 DevicePathInst
= GetNextDevicePathInstance (&MultiDevicePath
, &Size
);
764 NewMenuEntry
= BOpt_CreateMenuEntry (BM_CONSOLE_CONTEXT_SELECT
);
765 if (NULL
== NewMenuEntry
) {
766 return EFI_OUT_OF_RESOURCES
;
769 NewConsoleContext
= (BM_CONSOLE_CONTEXT
*) NewMenuEntry
->VariableContext
;
770 NewMenuEntry
->OptionNumber
= Index2
;
772 NewConsoleContext
->DevicePath
= DuplicateDevicePath (DevicePathInst
);
773 ASSERT (NewConsoleContext
->DevicePath
!= NULL
);
774 NewMenuEntry
->DisplayString
= EfiLibStrFromDatahub (NewConsoleContext
->DevicePath
);
775 if (NULL
== NewMenuEntry
->DisplayString
) {
776 NewMenuEntry
->DisplayString
= DevicePathToStr (NewConsoleContext
->DevicePath
);
779 NewConsoleContext
->IsTerminal
= IsTerminalDevicePath (
780 NewConsoleContext
->DevicePath
,
785 NewConsoleContext
->IsActive
= BdsLibMatchDevicePaths (
787 NewConsoleContext
->DevicePath
790 if (NewConsoleContext
->IsTerminal
) {
791 BOpt_DestroyMenuEntry (NewMenuEntry
);
794 ConsoleMenu
->MenuNumber
++;
795 InsertTailList (&ConsoleMenu
->Head
, &NewMenuEntry
->Link
);
803 Build up ConsoleOutMenu, ConsoleInpMenu and ConsoleErrMenu
805 @retval EFI_SUCCESS The function always complete successfully.
813 GetConsoleMenu (BM_CONSOLE_IN_CONTEXT_SELECT
);
814 GetConsoleMenu (BM_CONSOLE_OUT_CONTEXT_SELECT
);
815 GetConsoleMenu (BM_CONSOLE_ERR_CONTEXT_SELECT
);
820 Free ConsoleOutMenu, ConsoleInpMenu and ConsoleErrMenu
822 @retval EFI_SUCCESS The function always complete successfully.
829 BOpt_FreeMenu (&ConsoleOutMenu
);
830 BOpt_FreeMenu (&ConsoleInpMenu
);
831 BOpt_FreeMenu (&ConsoleErrMenu
);
832 BOpt_FreeMenu (&TerminalMenu
);
837 Test whether DevicePath is a valid Terminal
840 @param DevicePath DevicePath to be checked
841 @param Termi If DevicePath is valid Terminal, terminal type is returned.
842 @param Com If DevicePath is valid Terminal, Com Port type is returned.
844 @retval TRUE If DevicePath point to a Terminal.
845 @retval FALSE If DevicePath does not point to a Terminal.
849 IsTerminalDevicePath (
850 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
,
851 OUT TYPE_OF_TERMINAL
*Termi
,
856 EFI_DEVICE_PATH_PROTOCOL
*Node
;
857 VENDOR_DEVICE_PATH
*Vendor
;
858 UART_DEVICE_PATH
*Uart
;
859 ACPI_HID_DEVICE_PATH
*Acpi
;
866 for (Node
= DevicePath
; !IsDevicePathEnd (Node
); Node
= NextDevicePathNode (Node
)) {
868 // Vendor points to the node before the End node
870 Vendor
= (VENDOR_DEVICE_PATH
*) Node
;
872 if ((DevicePathType (Node
) == MESSAGING_DEVICE_PATH
) && (DevicePathSubType (Node
) == MSG_UART_DP
)) {
873 Uart
= (UART_DEVICE_PATH
*) Node
;
878 // Acpi points to the node before the UART node
880 Acpi
= (ACPI_HID_DEVICE_PATH
*) Node
;
884 if (Vendor
== NULL
||
885 DevicePathType (Vendor
) != MESSAGING_DEVICE_PATH
||
886 DevicePathSubType (Vendor
) != MSG_VENDOR_DP
||
892 // There are four kinds of Terminal types
893 // check to see whether this devicepath
894 // is one of that type
896 if (CompareGuid (&Vendor
->Guid
, &TerminalTypeGuid
[0])) {
897 *Termi
= TerminalTypePcAnsi
;
900 if (CompareGuid (&Vendor
->Guid
, &TerminalTypeGuid
[1])) {
901 *Termi
= TerminalTypeVt100
;
904 if (CompareGuid (&Vendor
->Guid
, &TerminalTypeGuid
[2])) {
905 *Termi
= TerminalTypeVt100Plus
;
908 if (CompareGuid (&Vendor
->Guid
, &TerminalTypeGuid
[3])) {
909 *Termi
= TerminalTypeVtUtf8
;
922 if ((Acpi
!= NULL
) && IsIsaSerialNode (Acpi
)) {
923 CopyMem (Com
, &Acpi
->UID
, sizeof (UINT32
));
932 Get mode number according to column and row
934 @param CallbackData The BMM context data.
938 IN BMM_CALLBACK_DATA
*CallbackData
948 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*ConOut
;
950 ConOut
= gST
->ConOut
;
951 MaxMode
= (UINTN
) (ConOut
->Mode
->MaxMode
);
953 CurrentCol
= PcdGet32 (PcdConOutColumn
);
954 CurrentRow
= PcdGet32 (PcdConOutRow
);
955 for (Mode
= 0; Mode
< MaxMode
; Mode
++) {
956 Status
= ConOut
->QueryMode (ConOut
, Mode
, &Col
, &Row
);
957 if (!EFI_ERROR(Status
)) {
958 if (CurrentCol
== Col
&& CurrentRow
== Row
) {
959 CallbackData
->BmmFakeNvData
.ConsoleOutMode
= (UINT16
) Mode
;