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 Function creates a device path data structure that identically matches the
19 device path passed in.
22 @param DevPath A pointer to a device path data structure.
24 @return The new copy of DevPath is created to identically match the input.
25 @retval NULL Otherwise, NULL is returned.
28 EFI_DEVICE_PATH_PROTOCOL
*
29 DevicePathInstanceDup (
30 IN EFI_DEVICE_PATH_PROTOCOL
*DevPath
34 Update Com Ports attributes from DevicePath
37 @param DevicePath DevicePath that contains Com ports
39 @retval EFI_SUCCESS The update is successful.
43 UpdateComAttributeFromVariable (
44 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
48 Update the multi-instance device path of Terminal Device based on
49 the global TerminalMenu. If ChangeTernimal is TRUE, the terminal
50 device path in the Terminal Device in TerminalMenu is also updated.
52 @param DevicePath The multi-instance device path.
53 @param ChangeTerminal TRUE, then device path in the Terminal Device
54 in TerminalMenu is also updated; FALSE, no update.
56 @return EFI_SUCCESS The function completes successfully.
60 ChangeTerminalDevicePath (
61 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
,
62 IN BOOLEAN ChangeTerminal
65 EFI_DEVICE_PATH_PROTOCOL
*Node
;
66 EFI_DEVICE_PATH_PROTOCOL
*Node1
;
67 ACPI_HID_DEVICE_PATH
*Acpi
;
68 UART_DEVICE_PATH
*Uart
;
69 UART_DEVICE_PATH
*Uart1
;
72 BM_TERMINAL_CONTEXT
*NewTerminalContext
;
73 BM_MENU_ENTRY
*NewMenuEntry
;
75 Match
= EISA_PNP_ID (0x0501);
77 Node
= NextDevicePathNode (Node
);
79 while (!IsDevicePathEnd (Node
)) {
80 if ((DevicePathType (Node
) == ACPI_DEVICE_PATH
) && (DevicePathSubType (Node
) == ACPI_DP
)) {
81 Acpi
= (ACPI_HID_DEVICE_PATH
*) Node
;
82 if (CompareMem (&Acpi
->HID
, &Match
, sizeof (UINT32
)) == 0) {
83 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
179 ChangeVariableDevicePath (
180 IN OUT EFI_DEVICE_PATH_PROTOCOL
*DevicePath
183 EFI_DEVICE_PATH_PROTOCOL
*Node
;
184 ACPI_HID_DEVICE_PATH
*Acpi
;
185 UART_DEVICE_PATH
*Uart
;
188 BM_TERMINAL_CONTEXT
*NewTerminalContext
;
189 BM_MENU_ENTRY
*NewMenuEntry
;
191 Match
= EISA_PNP_ID (0x0501);
193 Node
= NextDevicePathNode (Node
);
195 while (!IsDevicePathEnd (Node
)) {
196 if ((DevicePathType (Node
) == ACPI_DEVICE_PATH
) && (DevicePathSubType (Node
) == ACPI_DP
)) {
197 Acpi
= (ACPI_HID_DEVICE_PATH
*) Node
;
198 if (CompareMem (&Acpi
->HID
, &Match
, sizeof (UINT32
)) == 0) {
199 CopyMem (&Com
, &Acpi
->UID
, sizeof (UINT32
));
203 if ((DevicePathType (Node
) == MESSAGING_DEVICE_PATH
) && (DevicePathSubType (Node
) == MSG_UART_DP
)) {
204 NewMenuEntry
= BOpt_GetMenuEntry (
208 ASSERT (NewMenuEntry
!= NULL
);
209 NewTerminalContext
= (BM_TERMINAL_CONTEXT
*) NewMenuEntry
->VariableContext
;
210 Uart
= (UART_DEVICE_PATH
*) Node
;
213 &NewTerminalContext
->BaudRate
,
219 &NewTerminalContext
->DataBits
,
225 &NewTerminalContext
->Parity
,
231 &NewTerminalContext
->StopBits
,
236 Node
= NextDevicePathNode (Node
);
243 Retrieve ACPI UID of UART from device path
246 @param Handle The handle for the UART device.
247 @param AcpiUid The ACPI UID on output.
249 @retval TRUE Find valid UID from device path
250 @retval FALSE Can't find
255 IN EFI_HANDLE Handle
,
256 IN OUT UINT32
*AcpiUid
261 ACPI_HID_DEVICE_PATH
*Acpi
;
262 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
264 gBS
->HandleProtocol (
266 &gEfiDevicePathProtocolGuid
,
267 (VOID
**) &DevicePath
269 Ptr
= (UINT8
*) DevicePath
;
271 while (*Ptr
!= END_DEVICE_PATH_TYPE
) {
275 Ptr
= Ptr
- sizeof (UART_DEVICE_PATH
) - sizeof (ACPI_HID_DEVICE_PATH
);
276 Acpi
= (ACPI_HID_DEVICE_PATH
*) Ptr
;
277 Match
= EISA_PNP_ID (0x0501);
279 if (CompareMem (&Acpi
->HID
, &Match
, sizeof (UINT32
)) == 0) {
280 if (AcpiUid
!= NULL
) {
281 *AcpiUid
= Acpi
->UID
;
290 Sort Uart handles array with Acpi->UID from low to high
293 @param Handles EFI_SERIAL_IO_PROTOCOL handle buffer
294 @param NoHandles EFI_SERIAL_IO_PROTOCOL handle count
301 IN EFI_HANDLE
*Handles
,
311 EFI_HANDLE TempHandle
;
313 for (Index1
= 0; Index1
< NoHandles
-1; Index1
++) {
314 if (!RetrieveUartUid (Handles
[Index1
], &AcpiUid1
)) {
317 TempHandle
= Handles
[Index1
];
319 TempAcpiUid
= AcpiUid1
;
321 for (Index2
= Index1
+1; Index2
< NoHandles
; Index2
++) {
322 if (!RetrieveUartUid (Handles
[Index2
], &AcpiUid2
)) {
325 if (AcpiUid2
< TempAcpiUid
) {
326 TempAcpiUid
= AcpiUid2
;
327 TempHandle
= Handles
[Index2
];
331 Handles
[Position
] = Handles
[Index1
];
332 Handles
[Index1
] = TempHandle
;
337 Test whether DevicePath is a valid Terminal
340 @param DevicePath DevicePath to be checked
341 @param Termi If DevicePath is valid Terminal, terminal type is returned.
342 @param Com If DevicePath is valid Terminal, Com Port type is returned.
344 @retval TRUE If DevicePath point to a Terminal.
345 @retval FALSE If DevicePath does not point to a Terminal.
349 IsTerminalDevicePath (
350 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
,
351 OUT TYPE_OF_TERMINAL
*Termi
,
356 Build a list containing all serial devices
359 @param VOID EDES_TODO: Add parameter description
361 @return EDES_TODO: Add description for return value
375 ACPI_HID_DEVICE_PATH
*Acpi
;
376 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
378 EFI_SERIAL_IO_PROTOCOL
*SerialIo
;
379 EFI_DEVICE_PATH_PROTOCOL
*OutDevicePath
;
380 EFI_DEVICE_PATH_PROTOCOL
*InpDevicePath
;
381 EFI_DEVICE_PATH_PROTOCOL
*ErrDevicePath
;
382 BM_MENU_ENTRY
*NewMenuEntry
;
383 BM_TERMINAL_CONTEXT
*NewTerminalContext
;
384 EFI_DEVICE_PATH_PROTOCOL
*NewDevicePath
;
385 VENDOR_DEVICE_PATH Vendor
;
387 // Get all handles that have SerialIo protocol installed
389 InitializeListHead (&TerminalMenu
.Head
);
390 TerminalMenu
.MenuNumber
= 0;
391 Status
= gBS
->LocateHandleBuffer (
393 &gEfiSerialIoProtocolGuid
,
398 if (EFI_ERROR (Status
)) {
400 // No serial ports present
402 return EFI_UNSUPPORTED
;
406 // Sort Uart handles array with Acpi->UID from low to high
407 // then Terminal menu can be built from low Acpi->UID to high Acpi->UID
409 SortedUartHandle (Handles
, NoHandles
);
411 for (Index
= 0; Index
< NoHandles
; Index
++) {
413 // Check to see whether the handle has DevicePath Protocol installed
415 gBS
->HandleProtocol (
417 &gEfiDevicePathProtocolGuid
,
418 (VOID
**) &DevicePath
420 Ptr
= (UINT8
*) DevicePath
;
421 while (*Ptr
!= END_DEVICE_PATH_TYPE
) {
425 Ptr
= Ptr
- sizeof (UART_DEVICE_PATH
) - sizeof (ACPI_HID_DEVICE_PATH
);
426 Acpi
= (ACPI_HID_DEVICE_PATH
*) Ptr
;
427 Match
= EISA_PNP_ID (0x0501);
429 if (CompareMem (&Acpi
->HID
, &Match
, sizeof (UINT32
)) == 0) {
430 NewMenuEntry
= BOpt_CreateMenuEntry (BM_TERMINAL_CONTEXT_SELECT
);
431 if (NewMenuEntry
== NULL
) {
432 SafeFreePool (Handles
);
433 return EFI_OUT_OF_RESOURCES
;
436 NewTerminalContext
= (BM_TERMINAL_CONTEXT
*) NewMenuEntry
->VariableContext
;
437 CopyMem (&NewMenuEntry
->OptionNumber
, &Acpi
->UID
, sizeof (UINT32
));
438 NewTerminalContext
->DevicePath
= DevicePathInstanceDup (DevicePath
);
440 // BugBug: I have no choice, calling EfiLibStrFromDatahub will hang the system!
441 // coz' the misc data for each platform is not correct, actually it's the device path stored in
442 // datahub which is not completed, so a searching for end of device path will enter a
445 NewMenuEntry
->DisplayString
= EfiLibStrFromDatahub (DevicePath
);
446 if (NULL
== NewMenuEntry
->DisplayString
) {
447 NewMenuEntry
->DisplayString
= DevicePathToStr (DevicePath
);
450 NewMenuEntry
->HelpString
= NULL
;
452 gBS
->HandleProtocol (
454 &gEfiSerialIoProtocolGuid
,
459 &NewTerminalContext
->BaudRate
,
460 &SerialIo
->Mode
->BaudRate
,
465 &NewTerminalContext
->DataBits
,
466 &SerialIo
->Mode
->DataBits
,
471 &NewTerminalContext
->Parity
,
472 &SerialIo
->Mode
->Parity
,
477 &NewTerminalContext
->StopBits
,
478 &SerialIo
->Mode
->StopBits
,
481 InsertTailList (&TerminalMenu
.Head
, &NewMenuEntry
->Link
);
482 TerminalMenu
.MenuNumber
++;
485 SafeFreePool (Handles
);
488 // Get L"ConOut", L"ConIn" and L"ErrOut" from the Var
490 OutDevicePath
= EfiLibGetVariable (L
"ConOut", &gEfiGlobalVariableGuid
);
491 InpDevicePath
= EfiLibGetVariable (L
"ConIn", &gEfiGlobalVariableGuid
);
492 ErrDevicePath
= EfiLibGetVariable (L
"ErrOut", &gEfiGlobalVariableGuid
);
493 if (OutDevicePath
!= NULL
) {
494 UpdateComAttributeFromVariable (OutDevicePath
);
497 if (InpDevicePath
!= NULL
) {
498 UpdateComAttributeFromVariable (InpDevicePath
);
501 if (ErrDevicePath
!= NULL
) {
502 UpdateComAttributeFromVariable (ErrDevicePath
);
505 for (Index
= 0; Index
< TerminalMenu
.MenuNumber
; Index
++) {
506 NewMenuEntry
= BOpt_GetMenuEntry (&TerminalMenu
, Index
);
507 if (NULL
== NewMenuEntry
) {
508 return EFI_NOT_FOUND
;
511 NewTerminalContext
= (BM_TERMINAL_CONTEXT
*) NewMenuEntry
->VariableContext
;
513 NewTerminalContext
->TerminalType
= 0;
514 NewTerminalContext
->IsConIn
= FALSE
;
515 NewTerminalContext
->IsConOut
= FALSE
;
516 NewTerminalContext
->IsStdErr
= FALSE
;
518 Vendor
.Header
.Type
= MESSAGING_DEVICE_PATH
;
519 Vendor
.Header
.SubType
= MSG_VENDOR_DP
;
521 for (Index2
= 0; Index2
< 4; Index2
++) {
522 CopyMem (&Vendor
.Guid
, &TerminalTypeGuid
[Index2
], sizeof (EFI_GUID
));
523 SetDevicePathNodeLength (&Vendor
.Header
, sizeof (VENDOR_DEVICE_PATH
));
524 NewDevicePath
= AppendDevicePathNode (
525 NewTerminalContext
->DevicePath
,
526 (EFI_DEVICE_PATH_PROTOCOL
*) &Vendor
528 SafeFreePool (NewMenuEntry
->HelpString
);
530 // NewMenuEntry->HelpString = DevicePathToStr (NewDevicePath);
531 // NewMenuEntry->DisplayString = NewMenuEntry->HelpString;
533 NewMenuEntry
->HelpString
= NULL
;
535 if (BdsLibMatchDevicePaths (OutDevicePath
, NewDevicePath
)) {
536 NewTerminalContext
->IsConOut
= TRUE
;
537 NewTerminalContext
->TerminalType
= (UINT8
) Index2
;
540 if (BdsLibMatchDevicePaths (InpDevicePath
, NewDevicePath
)) {
541 NewTerminalContext
->IsConIn
= TRUE
;
542 NewTerminalContext
->TerminalType
= (UINT8
) Index2
;
545 if (BdsLibMatchDevicePaths (ErrDevicePath
, NewDevicePath
)) {
546 NewTerminalContext
->IsStdErr
= TRUE
;
547 NewTerminalContext
->TerminalType
= (UINT8
) Index2
;
556 Update Com Ports attributes from DevicePath
559 @param DevicePath DevicePath that contains Com ports
561 @retval EFI_SUCCESS The update is successful.
565 UpdateComAttributeFromVariable (
566 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
569 EFI_DEVICE_PATH_PROTOCOL
*Node
;
570 EFI_DEVICE_PATH_PROTOCOL
*SerialNode
;
571 ACPI_HID_DEVICE_PATH
*Acpi
;
572 UART_DEVICE_PATH
*Uart
;
573 UART_DEVICE_PATH
*Uart1
;
575 UINTN TerminalNumber
;
576 BM_MENU_ENTRY
*NewMenuEntry
;
577 BM_TERMINAL_CONTEXT
*NewTerminalContext
;
580 Match
= EISA_PNP_ID (0x0501);
582 Node
= NextDevicePathNode (Node
);
584 for (Index
= 0; Index
< TerminalMenu
.MenuNumber
; Index
++) {
585 while (!IsDevicePathEnd (Node
)) {
586 if ((DevicePathType (Node
) == ACPI_DEVICE_PATH
) && (DevicePathSubType (Node
) == ACPI_DP
)) {
587 Acpi
= (ACPI_HID_DEVICE_PATH
*) Node
;
588 if (CompareMem (&Acpi
->HID
, &Match
, sizeof (UINT32
)) == 0) {
589 CopyMem (&TerminalNumber
, &Acpi
->UID
, sizeof (UINT32
));
593 if ((DevicePathType (Node
) == MESSAGING_DEVICE_PATH
) && (DevicePathSubType (Node
) == MSG_UART_DP
)) {
594 Uart
= (UART_DEVICE_PATH
*) Node
;
595 NewMenuEntry
= BOpt_GetMenuEntry (&TerminalMenu
, TerminalNumber
);
596 if (NULL
== NewMenuEntry
) {
597 return EFI_NOT_FOUND
;
600 NewTerminalContext
= (BM_TERMINAL_CONTEXT
*) NewMenuEntry
->VariableContext
;
602 &NewTerminalContext
->BaudRate
,
608 &NewTerminalContext
->DataBits
,
614 &NewTerminalContext
->Parity
,
620 &NewTerminalContext
->StopBits
,
625 SerialNode
= NewTerminalContext
->DevicePath
;
626 SerialNode
= NextDevicePathNode (SerialNode
);
627 while (!IsDevicePathEnd (SerialNode
)) {
628 if ((DevicePathType (SerialNode
) == MESSAGING_DEVICE_PATH
) && (DevicePathSubType (SerialNode
) == MSG_UART_DP
)) {
630 // Update following device paths according to
631 // previous acquired uart attributes
633 Uart1
= (UART_DEVICE_PATH
*) SerialNode
;
636 &NewTerminalContext
->BaudRate
,
642 &NewTerminalContext
->DataBits
,
647 &NewTerminalContext
->Parity
,
652 &NewTerminalContext
->StopBits
,
659 SerialNode
= NextDevicePathNode (SerialNode
);
666 Node
= NextDevicePathNode (Node
);
677 Function creates a device path data structure that identically matches the
678 device path passed in.
681 @param DevPath A pointer to a device path data structure.
683 @return The new copy of DevPath is created to identically match the input.
684 @retval NULL Otherwise, NULL is returned.
687 EFI_DEVICE_PATH_PROTOCOL
*
688 DevicePathInstanceDup (
689 IN EFI_DEVICE_PATH_PROTOCOL
*DevPath
692 EFI_DEVICE_PATH_PROTOCOL
*NewDevPath
;
693 EFI_DEVICE_PATH_PROTOCOL
*DevicePathInst
;
694 EFI_DEVICE_PATH_PROTOCOL
*Temp
;
699 // get the size of an instance from the input
702 DevicePathInst
= GetNextDevicePathInstance (&Temp
, &Size
);
705 // Make a copy and set proper end type
709 NewDevPath
= AllocateZeroPool (Size
);
710 ASSERT (NewDevPath
!= NULL
);
713 if (NewDevPath
!= NULL
) {
714 CopyMem (NewDevPath
, DevicePathInst
, Size
);
715 Ptr
= (UINT8
*) NewDevPath
;
716 Ptr
+= Size
- sizeof (EFI_DEVICE_PATH_PROTOCOL
);
717 Temp
= (EFI_DEVICE_PATH_PROTOCOL
*) Ptr
;
718 SetDevicePathEndNode (Temp
);
725 Build up Console Menu based on types passed in. The type can
726 be BM_CONSOLE_IN_CONTEXT_SELECT, BM_CONSOLE_OUT_CONTEXT_SELECT
727 and BM_CONSOLE_ERR_CONTEXT_SELECT.
729 @param ConsoleMenuType Can be BM_CONSOLE_IN_CONTEXT_SELECT, BM_CONSOLE_OUT_CONTEXT_SELECT
730 and BM_CONSOLE_ERR_CONTEXT_SELECT.
732 @retval EFI_UNSUPPORTED The type passed in is not in the 3 types defined.
733 @retval EFI_NOT_FOUND If the EFI Variable defined in UEFI spec with name "ConOutDev",
734 "ConInDev" or "ConErrDev" doesn't exists.
735 @retval EFI_OUT_OF_RESOURCES Not enough resource to complete the operations.
736 @retval EFI_SUCCESS Function completes successfully.
741 IN UINTN ConsoleMenuType
744 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
745 EFI_DEVICE_PATH_PROTOCOL
*AllDevicePath
;
746 EFI_DEVICE_PATH_PROTOCOL
*MultiDevicePath
;
747 EFI_DEVICE_PATH_PROTOCOL
*DevicePathInst
;
752 BM_MENU_ENTRY
*NewMenuEntry
;
753 BM_CONSOLE_CONTEXT
*NewConsoleContext
;
754 TYPE_OF_TERMINAL Terminal
;
756 BM_MENU_OPTION
*ConsoleMenu
;
759 AllDevicePath
= NULL
;
761 switch (ConsoleMenuType
) {
762 case BM_CONSOLE_IN_CONTEXT_SELECT
:
763 ConsoleMenu
= &ConsoleInpMenu
;
764 DevicePath
= EfiLibGetVariable (
766 &gEfiGlobalVariableGuid
769 AllDevicePath
= EfiLibGetVariable (
771 &gEfiGlobalVariableGuid
775 case BM_CONSOLE_OUT_CONTEXT_SELECT
:
776 ConsoleMenu
= &ConsoleOutMenu
;
777 DevicePath
= EfiLibGetVariable (
779 &gEfiGlobalVariableGuid
782 AllDevicePath
= EfiLibGetVariable (
784 &gEfiGlobalVariableGuid
788 case BM_CONSOLE_ERR_CONTEXT_SELECT
:
789 ConsoleMenu
= &ConsoleErrMenu
;
790 DevicePath
= EfiLibGetVariable (
792 &gEfiGlobalVariableGuid
795 AllDevicePath
= EfiLibGetVariable (
797 &gEfiGlobalVariableGuid
802 return EFI_UNSUPPORTED
;
805 if (NULL
== AllDevicePath
) {
806 return EFI_NOT_FOUND
;
809 InitializeListHead (&ConsoleMenu
->Head
);
811 AllCount
= EfiDevicePathInstanceCount (AllDevicePath
);
812 ConsoleMenu
->MenuNumber
= 0;
814 // Following is menu building up for Console Devices selected.
816 MultiDevicePath
= AllDevicePath
;
818 for (Index
= 0; Index
< AllCount
; Index
++) {
819 DevicePathInst
= GetNextDevicePathInstance (&MultiDevicePath
, &Size
);
821 NewMenuEntry
= BOpt_CreateMenuEntry (BM_CONSOLE_CONTEXT_SELECT
);
822 if (NULL
== NewMenuEntry
) {
823 return EFI_OUT_OF_RESOURCES
;
826 NewConsoleContext
= (BM_CONSOLE_CONTEXT
*) NewMenuEntry
->VariableContext
;
827 NewMenuEntry
->OptionNumber
= Index2
;
829 NewConsoleContext
->DevicePath
= DevicePathInstanceDup (DevicePathInst
);
830 NewMenuEntry
->DisplayString
= EfiLibStrFromDatahub (NewConsoleContext
->DevicePath
);
831 if (NULL
== NewMenuEntry
->DisplayString
) {
832 NewMenuEntry
->DisplayString
= DevicePathToStr (NewConsoleContext
->DevicePath
);
835 NewConsoleContext
->IsTerminal
= IsTerminalDevicePath (
836 NewConsoleContext
->DevicePath
,
841 NewConsoleContext
->IsActive
= BdsLibMatchDevicePaths (
843 NewConsoleContext
->DevicePath
846 if (NewConsoleContext
->IsTerminal
) {
847 BOpt_DestroyMenuEntry (NewMenuEntry
);
850 ConsoleMenu
->MenuNumber
++;
851 InsertTailList (&ConsoleMenu
->Head
, &NewMenuEntry
->Link
);
859 Build up ConsoleOutMenu, ConsoleInpMenu and ConsoleErrMenu
864 @retval EFI_SUCCESS The function always complete successfully.
872 GetConsoleMenu (BM_CONSOLE_IN_CONTEXT_SELECT
);
873 GetConsoleMenu (BM_CONSOLE_OUT_CONTEXT_SELECT
);
874 GetConsoleMenu (BM_CONSOLE_ERR_CONTEXT_SELECT
);
879 Free ConsoleOutMenu, ConsoleInpMenu and ConsoleErrMenu
882 @param VOID EDES_TODO: Add parameter description
884 @retval EFI_SUCCESS The function always complete successfully.
891 BOpt_FreeMenu (&ConsoleOutMenu
);
892 BOpt_FreeMenu (&ConsoleInpMenu
);
893 BOpt_FreeMenu (&ConsoleErrMenu
);
894 BOpt_FreeMenu (&TerminalMenu
);
899 Test whether DevicePath is a valid Terminal
902 @param DevicePath DevicePath to be checked
903 @param Termi If DevicePath is valid Terminal, terminal type is returned.
904 @param Com If DevicePath is valid Terminal, Com Port type is returned.
906 @retval TRUE If DevicePath point to a Terminal.
907 @retval FALSE If DevicePath does not point to a Terminal.
911 IsTerminalDevicePath (
912 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
,
913 OUT TYPE_OF_TERMINAL
*Termi
,
919 VENDOR_DEVICE_PATH
*Vendor
;
920 ACPI_HID_DEVICE_PATH
*Acpi
;
927 // Parse the Device Path, should be change later!!!
929 Ptr
= (UINT8
*) DevicePath
;
930 while (*Ptr
!= END_DEVICE_PATH_TYPE
) {
934 Ptr
= Ptr
- sizeof (VENDOR_DEVICE_PATH
);
935 Vendor
= (VENDOR_DEVICE_PATH
*) Ptr
;
938 // There are four kinds of Terminal types
939 // check to see whether this devicepath
940 // is one of that type
942 CopyMem (&TempGuid
, &Vendor
->Guid
, sizeof (EFI_GUID
));
944 if (CompareGuid (&TempGuid
, &TerminalTypeGuid
[0])) {
948 if (CompareGuid (&TempGuid
, &TerminalTypeGuid
[1])) {
952 if (CompareGuid (&TempGuid
, &TerminalTypeGuid
[2])) {
953 *Termi
= VT_100_PLUS
;
956 if (CompareGuid (&TempGuid
, &TerminalTypeGuid
[3])) {
970 Ptr
= Ptr
- sizeof (UART_DEVICE_PATH
) - sizeof (ACPI_HID_DEVICE_PATH
);
971 Acpi
= (ACPI_HID_DEVICE_PATH
*) Ptr
;
972 Match
= EISA_PNP_ID (0x0501);
973 if (CompareMem (&Acpi
->HID
, &Match
, sizeof (UINT32
)) == 0) {
974 CopyMem (Com
, &Acpi
->UID
, sizeof (UINT32
));
983 Get mode number according to column and row
986 @param CallbackData The BMM context data.
993 IN BMM_CALLBACK_DATA
*CallbackData
1003 CONSOLE_OUT_MODE
*ModeInfo
;
1004 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*ConOut
;
1006 ConOut
= gST
->ConOut
;
1007 MaxMode
= (UINTN
) (ConOut
->Mode
->MaxMode
);
1008 ModeInfo
= EfiLibGetVariable (VarConOutMode
, &gEfiGenericPlatformVariableGuid
);
1010 if (ModeInfo
!= NULL
) {
1011 CurrentCol
= ModeInfo
->Column
;
1012 CurrentRow
= ModeInfo
->Row
;
1013 for (Mode
= 0; Mode
< MaxMode
; Mode
++) {
1014 Status
= ConOut
->QueryMode (ConOut
, Mode
, &Col
, &Row
);
1015 if (!EFI_ERROR(Status
)) {
1016 if (CurrentCol
== Col
&& CurrentRow
== Row
) {
1017 CallbackData
->BmmFakeNvData
.ConsoleOutMode
= (UINT16
) Mode
;
1023 SafeFreePool (ModeInfo
);