2 handles console redirection from boot manager
4 Copyright (c) 2004 - 2008, Intel Corporation. <BR>
5 All rights reserved. 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 Update Com Ports attributes from DevicePath
20 @param DevicePath DevicePath that contains Com ports
22 @retval EFI_SUCCESS The update is successful.
26 UpdateComAttributeFromVariable (
27 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
31 Update the multi-instance device path of Terminal Device based on
32 the global TerminalMenu. If ChangeTernimal is TRUE, the terminal
33 device path in the Terminal Device in TerminalMenu is also updated.
35 @param DevicePath The multi-instance device path.
36 @param ChangeTerminal TRUE, then device path in the Terminal Device
37 in TerminalMenu is also updated; FALSE, no update.
39 @return EFI_SUCCESS The function completes successfully.
43 ChangeTerminalDevicePath (
44 IN OUT EFI_DEVICE_PATH_PROTOCOL
*DevicePath
,
45 IN BOOLEAN ChangeTerminal
48 EFI_DEVICE_PATH_PROTOCOL
*Node
;
49 EFI_DEVICE_PATH_PROTOCOL
*Node1
;
50 ACPI_HID_DEVICE_PATH
*Acpi
;
51 UART_DEVICE_PATH
*Uart
;
52 UART_DEVICE_PATH
*Uart1
;
55 BM_TERMINAL_CONTEXT
*NewTerminalContext
;
56 BM_MENU_ENTRY
*NewMenuEntry
;
58 Match
= EISA_PNP_ID (0x0501);
60 Node
= NextDevicePathNode (Node
);
62 while (!IsDevicePathEnd (Node
)) {
63 if ((DevicePathType (Node
) == ACPI_DEVICE_PATH
) && (DevicePathSubType (Node
) == ACPI_DP
)) {
64 Acpi
= (ACPI_HID_DEVICE_PATH
*) Node
;
65 if (CompareMem (&Acpi
->HID
, &Match
, sizeof (UINT32
)) == 0) {
66 CopyMem (&Com
, &Acpi
->UID
, sizeof (UINT32
));
70 NewMenuEntry
= BOpt_GetMenuEntry (&TerminalMenu
, Com
);
72 NewTerminalContext
= (BM_TERMINAL_CONTEXT
*) NewMenuEntry
->VariableContext
;
73 if ((DevicePathType (Node
) == MESSAGING_DEVICE_PATH
) && (DevicePathSubType (Node
) == MSG_UART_DP
)) {
74 Uart
= (UART_DEVICE_PATH
*) Node
;
77 &NewTerminalContext
->BaudRate
,
83 &NewTerminalContext
->DataBits
,
89 &NewTerminalContext
->Parity
,
95 &NewTerminalContext
->StopBits
,
99 // Change the device path in the ComPort
101 if (ChangeTerminal
) {
102 Node1
= NewTerminalContext
->DevicePath
;
103 Node1
= NextDevicePathNode (Node1
);
104 while (!IsDevicePathEnd (Node1
)) {
105 if ((DevicePathType (Node1
) == MESSAGING_DEVICE_PATH
) && (DevicePathSubType (Node1
) == MSG_UART_DP
)) {
106 Uart1
= (UART_DEVICE_PATH
*) Node1
;
109 &NewTerminalContext
->BaudRate
,
115 &NewTerminalContext
->DataBits
,
121 &NewTerminalContext
->Parity
,
127 &NewTerminalContext
->StopBits
,
135 Node1
= NextDevicePathNode (Node1
);
144 Node
= NextDevicePathNode (Node
);
152 Update the device path that describing a terminal device
153 based on the new BaudRate, Data Bits, parity and Stop Bits
156 @param DevicePath terminal device's path
160 ChangeVariableDevicePath (
161 IN OUT EFI_DEVICE_PATH_PROTOCOL
*DevicePath
164 EFI_DEVICE_PATH_PROTOCOL
*Node
;
165 ACPI_HID_DEVICE_PATH
*Acpi
;
166 UART_DEVICE_PATH
*Uart
;
169 BM_TERMINAL_CONTEXT
*NewTerminalContext
;
170 BM_MENU_ENTRY
*NewMenuEntry
;
172 Match
= EISA_PNP_ID (0x0501);
174 Node
= NextDevicePathNode (Node
);
176 while (!IsDevicePathEnd (Node
)) {
177 if ((DevicePathType (Node
) == ACPI_DEVICE_PATH
) && (DevicePathSubType (Node
) == ACPI_DP
)) {
178 Acpi
= (ACPI_HID_DEVICE_PATH
*) Node
;
179 if (CompareMem (&Acpi
->HID
, &Match
, sizeof (UINT32
)) == 0) {
180 CopyMem (&Com
, &Acpi
->UID
, sizeof (UINT32
));
184 if ((DevicePathType (Node
) == MESSAGING_DEVICE_PATH
) && (DevicePathSubType (Node
) == MSG_UART_DP
)) {
185 NewMenuEntry
= BOpt_GetMenuEntry (
189 ASSERT (NewMenuEntry
!= NULL
);
190 NewTerminalContext
= (BM_TERMINAL_CONTEXT
*) NewMenuEntry
->VariableContext
;
191 Uart
= (UART_DEVICE_PATH
*) Node
;
194 &NewTerminalContext
->BaudRate
,
200 &NewTerminalContext
->DataBits
,
206 &NewTerminalContext
->Parity
,
212 &NewTerminalContext
->StopBits
,
217 Node
= NextDevicePathNode (Node
);
222 Retrieve ACPI UID of UART from device path
224 @param Handle The handle for the UART device.
225 @param AcpiUid The ACPI UID on output.
227 @retval TRUE Find valid UID from device path
228 @retval FALSE Can't find
233 IN EFI_HANDLE Handle
,
234 IN OUT UINT32
*AcpiUid
239 ACPI_HID_DEVICE_PATH
*Acpi
;
240 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
242 gBS
->HandleProtocol (
244 &gEfiDevicePathProtocolGuid
,
245 (VOID
**) &DevicePath
247 Ptr
= (UINT8
*) DevicePath
;
249 while (*Ptr
!= END_DEVICE_PATH_TYPE
) {
253 Ptr
= Ptr
- sizeof (UART_DEVICE_PATH
) - sizeof (ACPI_HID_DEVICE_PATH
);
254 Acpi
= (ACPI_HID_DEVICE_PATH
*) Ptr
;
255 Match
= EISA_PNP_ID (0x0501);
257 if (CompareMem (&Acpi
->HID
, &Match
, sizeof (UINT32
)) == 0) {
258 if (AcpiUid
!= NULL
) {
259 *AcpiUid
= Acpi
->UID
;
268 Sort Uart handles array with Acpi->UID from low to high.
270 @param Handles EFI_SERIAL_IO_PROTOCOL handle buffer
271 @param NoHandles EFI_SERIAL_IO_PROTOCOL handle count
275 IN EFI_HANDLE
*Handles
,
285 EFI_HANDLE TempHandle
;
287 for (Index1
= 0; Index1
< NoHandles
-1; Index1
++) {
288 if (!RetrieveUartUid (Handles
[Index1
], &AcpiUid1
)) {
291 TempHandle
= Handles
[Index1
];
293 TempAcpiUid
= AcpiUid1
;
295 for (Index2
= Index1
+1; Index2
< NoHandles
; Index2
++) {
296 if (!RetrieveUartUid (Handles
[Index2
], &AcpiUid2
)) {
299 if (AcpiUid2
< TempAcpiUid
) {
300 TempAcpiUid
= AcpiUid2
;
301 TempHandle
= Handles
[Index2
];
305 Handles
[Position
] = Handles
[Index1
];
306 Handles
[Index1
] = TempHandle
;
311 Test whether DevicePath is a valid Terminal
314 @param DevicePath DevicePath to be checked
315 @param Termi If DevicePath is valid Terminal, terminal type is returned.
316 @param Com If DevicePath is valid Terminal, Com Port type is returned.
318 @retval TRUE If DevicePath point to a Terminal.
319 @retval FALSE If DevicePath does not point to a Terminal.
323 IsTerminalDevicePath (
324 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
,
325 OUT TYPE_OF_TERMINAL
*Termi
,
330 Build a list containing all serial devices.
333 @retval EFI_SUCCESS The function complete successfully.
334 @retval EFI_UNSUPPORTED No serial ports present.
348 ACPI_HID_DEVICE_PATH
*Acpi
;
349 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
351 EFI_SERIAL_IO_PROTOCOL
*SerialIo
;
352 EFI_DEVICE_PATH_PROTOCOL
*OutDevicePath
;
353 EFI_DEVICE_PATH_PROTOCOL
*InpDevicePath
;
354 EFI_DEVICE_PATH_PROTOCOL
*ErrDevicePath
;
355 BM_MENU_ENTRY
*NewMenuEntry
;
356 BM_TERMINAL_CONTEXT
*NewTerminalContext
;
357 EFI_DEVICE_PATH_PROTOCOL
*NewDevicePath
;
358 VENDOR_DEVICE_PATH Vendor
;
360 // Get all handles that have SerialIo protocol installed
362 InitializeListHead (&TerminalMenu
.Head
);
363 TerminalMenu
.MenuNumber
= 0;
364 Status
= gBS
->LocateHandleBuffer (
366 &gEfiSerialIoProtocolGuid
,
371 if (EFI_ERROR (Status
)) {
373 // No serial ports present
375 return EFI_UNSUPPORTED
;
379 // Sort Uart handles array with Acpi->UID from low to high
380 // then Terminal menu can be built from low Acpi->UID to high Acpi->UID
382 SortedUartHandle (Handles
, NoHandles
);
384 for (Index
= 0; Index
< NoHandles
; Index
++) {
386 // Check to see whether the handle has DevicePath Protocol installed
388 gBS
->HandleProtocol (
390 &gEfiDevicePathProtocolGuid
,
391 (VOID
**) &DevicePath
393 Ptr
= (UINT8
*) DevicePath
;
394 while (*Ptr
!= END_DEVICE_PATH_TYPE
) {
398 Ptr
= Ptr
- sizeof (UART_DEVICE_PATH
) - sizeof (ACPI_HID_DEVICE_PATH
);
399 Acpi
= (ACPI_HID_DEVICE_PATH
*) Ptr
;
400 Match
= EISA_PNP_ID (0x0501);
402 if (CompareMem (&Acpi
->HID
, &Match
, sizeof (UINT32
)) == 0) {
403 NewMenuEntry
= BOpt_CreateMenuEntry (BM_TERMINAL_CONTEXT_SELECT
);
404 if (NewMenuEntry
== NULL
) {
406 return EFI_OUT_OF_RESOURCES
;
409 NewTerminalContext
= (BM_TERMINAL_CONTEXT
*) NewMenuEntry
->VariableContext
;
410 CopyMem (&NewMenuEntry
->OptionNumber
, &Acpi
->UID
, sizeof (UINT32
));
411 NewTerminalContext
->DevicePath
= DuplicateDevicePath (DevicePath
);
413 // BugBug: I have no choice, calling EfiLibStrFromDatahub will hang the system!
414 // coz' the misc data for each platform is not correct, actually it's the device path stored in
415 // datahub which is not completed, so a searching for end of device path will enter a
418 NewMenuEntry
->DisplayString
= EfiLibStrFromDatahub (DevicePath
);
419 if (NULL
== NewMenuEntry
->DisplayString
) {
420 NewMenuEntry
->DisplayString
= DevicePathToStr (DevicePath
);
423 NewMenuEntry
->HelpString
= NULL
;
425 gBS
->HandleProtocol (
427 &gEfiSerialIoProtocolGuid
,
432 &NewTerminalContext
->BaudRate
,
433 &SerialIo
->Mode
->BaudRate
,
438 &NewTerminalContext
->DataBits
,
439 &SerialIo
->Mode
->DataBits
,
444 &NewTerminalContext
->Parity
,
445 &SerialIo
->Mode
->Parity
,
450 &NewTerminalContext
->StopBits
,
451 &SerialIo
->Mode
->StopBits
,
454 InsertTailList (&TerminalMenu
.Head
, &NewMenuEntry
->Link
);
455 TerminalMenu
.MenuNumber
++;
458 if (Handles
!= NULL
) {
463 // Get L"ConOut", L"ConIn" and L"ErrOut" from the Var
465 OutDevicePath
= EfiLibGetVariable (L
"ConOut", &gEfiGlobalVariableGuid
);
466 InpDevicePath
= EfiLibGetVariable (L
"ConIn", &gEfiGlobalVariableGuid
);
467 ErrDevicePath
= EfiLibGetVariable (L
"ErrOut", &gEfiGlobalVariableGuid
);
468 if (OutDevicePath
!= NULL
) {
469 UpdateComAttributeFromVariable (OutDevicePath
);
472 if (InpDevicePath
!= NULL
) {
473 UpdateComAttributeFromVariable (InpDevicePath
);
476 if (ErrDevicePath
!= NULL
) {
477 UpdateComAttributeFromVariable (ErrDevicePath
);
480 for (Index
= 0; Index
< TerminalMenu
.MenuNumber
; Index
++) {
481 NewMenuEntry
= BOpt_GetMenuEntry (&TerminalMenu
, Index
);
482 if (NULL
== NewMenuEntry
) {
483 return EFI_NOT_FOUND
;
486 NewTerminalContext
= (BM_TERMINAL_CONTEXT
*) NewMenuEntry
->VariableContext
;
488 NewTerminalContext
->TerminalType
= 0;
489 NewTerminalContext
->IsConIn
= FALSE
;
490 NewTerminalContext
->IsConOut
= FALSE
;
491 NewTerminalContext
->IsStdErr
= FALSE
;
493 Vendor
.Header
.Type
= MESSAGING_DEVICE_PATH
;
494 Vendor
.Header
.SubType
= MSG_VENDOR_DP
;
496 for (Index2
= 0; Index2
< 4; Index2
++) {
497 CopyMem (&Vendor
.Guid
, &TerminalTypeGuid
[Index2
], sizeof (EFI_GUID
));
498 SetDevicePathNodeLength (&Vendor
.Header
, sizeof (VENDOR_DEVICE_PATH
));
499 NewDevicePath
= AppendDevicePathNode (
500 NewTerminalContext
->DevicePath
,
501 (EFI_DEVICE_PATH_PROTOCOL
*) &Vendor
503 if (NewMenuEntry
->HelpString
!= NULL
) {
504 FreePool (NewMenuEntry
->HelpString
);
507 // NewMenuEntry->HelpString = DevicePathToStr (NewDevicePath);
508 // NewMenuEntry->DisplayString = NewMenuEntry->HelpString;
510 NewMenuEntry
->HelpString
= NULL
;
512 if (BdsLibMatchDevicePaths (OutDevicePath
, NewDevicePath
)) {
513 NewTerminalContext
->IsConOut
= TRUE
;
514 NewTerminalContext
->TerminalType
= (UINT8
) Index2
;
517 if (BdsLibMatchDevicePaths (InpDevicePath
, NewDevicePath
)) {
518 NewTerminalContext
->IsConIn
= TRUE
;
519 NewTerminalContext
->TerminalType
= (UINT8
) Index2
;
522 if (BdsLibMatchDevicePaths (ErrDevicePath
, NewDevicePath
)) {
523 NewTerminalContext
->IsStdErr
= TRUE
;
524 NewTerminalContext
->TerminalType
= (UINT8
) Index2
;
533 Update Com Ports attributes from DevicePath
535 @param DevicePath DevicePath that contains Com ports
537 @retval EFI_SUCCESS The update is successful.
538 @retval EFI_NOT_FOUND Can not find specific menu entry
541 UpdateComAttributeFromVariable (
542 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
545 EFI_DEVICE_PATH_PROTOCOL
*Node
;
546 EFI_DEVICE_PATH_PROTOCOL
*SerialNode
;
547 ACPI_HID_DEVICE_PATH
*Acpi
;
548 UART_DEVICE_PATH
*Uart
;
549 UART_DEVICE_PATH
*Uart1
;
551 UINTN TerminalNumber
;
552 BM_MENU_ENTRY
*NewMenuEntry
;
553 BM_TERMINAL_CONTEXT
*NewTerminalContext
;
556 Match
= EISA_PNP_ID (0x0501);
558 Node
= NextDevicePathNode (Node
);
560 for (Index
= 0; Index
< TerminalMenu
.MenuNumber
; Index
++) {
561 while (!IsDevicePathEnd (Node
)) {
562 if ((DevicePathType (Node
) == ACPI_DEVICE_PATH
) && (DevicePathSubType (Node
) == ACPI_DP
)) {
563 Acpi
= (ACPI_HID_DEVICE_PATH
*) Node
;
564 if (CompareMem (&Acpi
->HID
, &Match
, sizeof (UINT32
)) == 0) {
565 CopyMem (&TerminalNumber
, &Acpi
->UID
, sizeof (UINT32
));
569 if ((DevicePathType (Node
) == MESSAGING_DEVICE_PATH
) && (DevicePathSubType (Node
) == MSG_UART_DP
)) {
570 Uart
= (UART_DEVICE_PATH
*) Node
;
571 NewMenuEntry
= BOpt_GetMenuEntry (&TerminalMenu
, TerminalNumber
);
572 if (NULL
== NewMenuEntry
) {
573 return EFI_NOT_FOUND
;
576 NewTerminalContext
= (BM_TERMINAL_CONTEXT
*) NewMenuEntry
->VariableContext
;
578 &NewTerminalContext
->BaudRate
,
584 &NewTerminalContext
->DataBits
,
590 &NewTerminalContext
->Parity
,
596 &NewTerminalContext
->StopBits
,
601 SerialNode
= NewTerminalContext
->DevicePath
;
602 SerialNode
= NextDevicePathNode (SerialNode
);
603 while (!IsDevicePathEnd (SerialNode
)) {
604 if ((DevicePathType (SerialNode
) == MESSAGING_DEVICE_PATH
) && (DevicePathSubType (SerialNode
) == MSG_UART_DP
)) {
606 // Update following device paths according to
607 // previous acquired uart attributes
609 Uart1
= (UART_DEVICE_PATH
*) SerialNode
;
612 &NewTerminalContext
->BaudRate
,
618 &NewTerminalContext
->DataBits
,
623 &NewTerminalContext
->Parity
,
628 &NewTerminalContext
->StopBits
,
635 SerialNode
= NextDevicePathNode (SerialNode
);
642 Node
= NextDevicePathNode (Node
);
653 Build up Console Menu based on types passed in. The type can
654 be BM_CONSOLE_IN_CONTEXT_SELECT, BM_CONSOLE_OUT_CONTEXT_SELECT
655 and BM_CONSOLE_ERR_CONTEXT_SELECT.
657 @param ConsoleMenuType Can be BM_CONSOLE_IN_CONTEXT_SELECT, BM_CONSOLE_OUT_CONTEXT_SELECT
658 and BM_CONSOLE_ERR_CONTEXT_SELECT.
660 @retval EFI_UNSUPPORTED The type passed in is not in the 3 types defined.
661 @retval EFI_NOT_FOUND If the EFI Variable defined in UEFI spec with name "ConOutDev",
662 "ConInDev" or "ConErrDev" doesn't exists.
663 @retval EFI_OUT_OF_RESOURCES Not enough resource to complete the operations.
664 @retval EFI_SUCCESS Function completes successfully.
669 IN UINTN ConsoleMenuType
672 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
673 EFI_DEVICE_PATH_PROTOCOL
*AllDevicePath
;
674 EFI_DEVICE_PATH_PROTOCOL
*MultiDevicePath
;
675 EFI_DEVICE_PATH_PROTOCOL
*DevicePathInst
;
680 BM_MENU_ENTRY
*NewMenuEntry
;
681 BM_CONSOLE_CONTEXT
*NewConsoleContext
;
682 TYPE_OF_TERMINAL Terminal
;
684 BM_MENU_OPTION
*ConsoleMenu
;
687 AllDevicePath
= NULL
;
689 switch (ConsoleMenuType
) {
690 case BM_CONSOLE_IN_CONTEXT_SELECT
:
691 ConsoleMenu
= &ConsoleInpMenu
;
692 DevicePath
= EfiLibGetVariable (
694 &gEfiGlobalVariableGuid
697 AllDevicePath
= EfiLibGetVariable (
699 &gEfiGlobalVariableGuid
703 case BM_CONSOLE_OUT_CONTEXT_SELECT
:
704 ConsoleMenu
= &ConsoleOutMenu
;
705 DevicePath
= EfiLibGetVariable (
707 &gEfiGlobalVariableGuid
710 AllDevicePath
= EfiLibGetVariable (
712 &gEfiGlobalVariableGuid
716 case BM_CONSOLE_ERR_CONTEXT_SELECT
:
717 ConsoleMenu
= &ConsoleErrMenu
;
718 DevicePath
= EfiLibGetVariable (
720 &gEfiGlobalVariableGuid
723 AllDevicePath
= EfiLibGetVariable (
725 &gEfiGlobalVariableGuid
730 return EFI_UNSUPPORTED
;
733 if (NULL
== AllDevicePath
) {
734 return EFI_NOT_FOUND
;
737 InitializeListHead (&ConsoleMenu
->Head
);
739 AllCount
= EfiDevicePathInstanceCount (AllDevicePath
);
740 ConsoleMenu
->MenuNumber
= 0;
742 // Following is menu building up for Console Devices selected.
744 MultiDevicePath
= AllDevicePath
;
746 for (Index
= 0; Index
< AllCount
; Index
++) {
747 DevicePathInst
= GetNextDevicePathInstance (&MultiDevicePath
, &Size
);
749 NewMenuEntry
= BOpt_CreateMenuEntry (BM_CONSOLE_CONTEXT_SELECT
);
750 if (NULL
== NewMenuEntry
) {
751 return EFI_OUT_OF_RESOURCES
;
754 NewConsoleContext
= (BM_CONSOLE_CONTEXT
*) NewMenuEntry
->VariableContext
;
755 NewMenuEntry
->OptionNumber
= Index2
;
757 NewConsoleContext
->DevicePath
= DuplicateDevicePath (DevicePathInst
);
758 NewMenuEntry
->DisplayString
= EfiLibStrFromDatahub (NewConsoleContext
->DevicePath
);
759 if (NULL
== NewMenuEntry
->DisplayString
) {
760 NewMenuEntry
->DisplayString
= DevicePathToStr (NewConsoleContext
->DevicePath
);
763 NewConsoleContext
->IsTerminal
= IsTerminalDevicePath (
764 NewConsoleContext
->DevicePath
,
769 NewConsoleContext
->IsActive
= BdsLibMatchDevicePaths (
771 NewConsoleContext
->DevicePath
774 if (NewConsoleContext
->IsTerminal
) {
775 BOpt_DestroyMenuEntry (NewMenuEntry
);
778 ConsoleMenu
->MenuNumber
++;
779 InsertTailList (&ConsoleMenu
->Head
, &NewMenuEntry
->Link
);
787 Build up ConsoleOutMenu, ConsoleInpMenu and ConsoleErrMenu
789 @retval EFI_SUCCESS The function always complete successfully.
797 GetConsoleMenu (BM_CONSOLE_IN_CONTEXT_SELECT
);
798 GetConsoleMenu (BM_CONSOLE_OUT_CONTEXT_SELECT
);
799 GetConsoleMenu (BM_CONSOLE_ERR_CONTEXT_SELECT
);
804 Free ConsoleOutMenu, ConsoleInpMenu and ConsoleErrMenu
806 @retval EFI_SUCCESS The function always complete successfully.
813 BOpt_FreeMenu (&ConsoleOutMenu
);
814 BOpt_FreeMenu (&ConsoleInpMenu
);
815 BOpt_FreeMenu (&ConsoleErrMenu
);
816 BOpt_FreeMenu (&TerminalMenu
);
821 Test whether DevicePath is a valid Terminal
824 @param DevicePath DevicePath to be checked
825 @param Termi If DevicePath is valid Terminal, terminal type is returned.
826 @param Com If DevicePath is valid Terminal, Com Port type is returned.
828 @retval TRUE If DevicePath point to a Terminal.
829 @retval FALSE If DevicePath does not point to a Terminal.
833 IsTerminalDevicePath (
834 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
,
835 OUT TYPE_OF_TERMINAL
*Termi
,
841 VENDOR_DEVICE_PATH
*Vendor
;
842 ACPI_HID_DEVICE_PATH
*Acpi
;
849 // Parse the Device Path, should be change later!!!
851 Ptr
= (UINT8
*) DevicePath
;
852 while (*Ptr
!= END_DEVICE_PATH_TYPE
) {
856 Ptr
= Ptr
- sizeof (VENDOR_DEVICE_PATH
);
857 Vendor
= (VENDOR_DEVICE_PATH
*) Ptr
;
860 // There are four kinds of Terminal types
861 // check to see whether this devicepath
862 // is one of that type
864 CopyMem (&TempGuid
, &Vendor
->Guid
, sizeof (EFI_GUID
));
866 if (CompareGuid (&TempGuid
, &TerminalTypeGuid
[0])) {
870 if (CompareGuid (&TempGuid
, &TerminalTypeGuid
[1])) {
874 if (CompareGuid (&TempGuid
, &TerminalTypeGuid
[2])) {
875 *Termi
= VT_100_PLUS
;
878 if (CompareGuid (&TempGuid
, &TerminalTypeGuid
[3])) {
892 Ptr
= Ptr
- sizeof (UART_DEVICE_PATH
) - sizeof (ACPI_HID_DEVICE_PATH
);
893 Acpi
= (ACPI_HID_DEVICE_PATH
*) Ptr
;
894 Match
= EISA_PNP_ID (0x0501);
895 if (CompareMem (&Acpi
->HID
, &Match
, sizeof (UINT32
)) == 0) {
896 CopyMem (Com
, &Acpi
->UID
, sizeof (UINT32
));
905 Get mode number according to column and row
907 @param CallbackData The BMM context data.
911 IN BMM_CALLBACK_DATA
*CallbackData
921 CONSOLE_OUT_MODE
*ModeInfo
;
922 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*ConOut
;
924 ConOut
= gST
->ConOut
;
925 MaxMode
= (UINTN
) (ConOut
->Mode
->MaxMode
);
926 ModeInfo
= EfiLibGetVariable (VAR_CON_OUT_MODE
, &gEfiGenericPlatformVariableGuid
);
928 if (ModeInfo
!= NULL
) {
929 CurrentCol
= ModeInfo
->Column
;
930 CurrentRow
= ModeInfo
->Row
;
931 for (Mode
= 0; Mode
< MaxMode
; Mode
++) {
932 Status
= ConOut
->QueryMode (ConOut
, Mode
, &Col
, &Row
);
933 if (!EFI_ERROR(Status
)) {
934 if (CurrentCol
== Col
&& CurrentRow
== Row
) {
935 CallbackData
->BmmFakeNvData
.ConsoleOutMode
= (UINT16
) Mode
;