public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH] MdeModulePkg/BootMaintenanceManagerUiLib: Support NT32 terminals
@ 2017-01-09  2:18 Ruiyu Ni
  2017-01-09  9:32 ` Ni, Ruiyu
  2017-01-10  6:37 ` Gao, Liming
  0 siblings, 2 replies; 3+ messages in thread
From: Ruiyu Ni @ 2017-01-09  2:18 UTC (permalink / raw)
  To: edk2-devel; +Cc: Dandan Bi, Liming Gao

The patch enhances Boot Maintenance Manager to recognize
the terminal consoles in NT32 platform.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Dandan Bi <danda.bi@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
---
 .../BootMaintenanceManagerUiLib/ConsoleOption.c    | 213 ++++++---------------
 1 file changed, 59 insertions(+), 154 deletions(-)

diff --git a/MdeModulePkg/Library/BootMaintenanceManagerUiLib/ConsoleOption.c b/MdeModulePkg/Library/BootMaintenanceManagerUiLib/ConsoleOption.c
index a145a77..11b77a6 100644
--- a/MdeModulePkg/Library/BootMaintenanceManagerUiLib/ConsoleOption.c
+++ b/MdeModulePkg/Library/BootMaintenanceManagerUiLib/ConsoleOption.c
@@ -1,7 +1,7 @@
 /** @file
 handles console redirection from boot manager
 
-Copyright (c) 2004 - 2015, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2004 - 2017, Intel Corporation. All rights reserved.<BR>
 This program and the accompanying materials
 are licensed and made available under the terms and conditions of the BSD License
 which accompanies this distribution.  The full text of the license may be found at
@@ -379,8 +379,6 @@ SortedUartHandle (
 
 
   @param DevicePath      DevicePath to be checked
-  @param Termi           If DevicePath is valid Terminal, terminal type is returned.
-  @param Com             If DevicePath is valid Terminal, Com Port type is returned.
 
   @retval  TRUE         If DevicePath point to a Terminal.
   @retval  FALSE        If DevicePath does not point to a Terminal.
@@ -388,9 +386,7 @@ SortedUartHandle (
 **/
 BOOLEAN
 IsTerminalDevicePath (
-  IN  EFI_DEVICE_PATH_PROTOCOL *DevicePath,
-  OUT TYPE_OF_TERMINAL         *Termi,
-  OUT UINTN                    *Com
+  IN  EFI_DEVICE_PATH_PROTOCOL *DevicePath
   );
 
 /**
@@ -411,10 +407,8 @@ LocateSerialIo (
   UINTN                     NoHandles;
   EFI_HANDLE                *Handles;
   EFI_STATUS                Status;
-  ACPI_HID_DEVICE_PATH      *Acpi;
   EFI_DEVICE_PATH_PROTOCOL  *DevicePath;
   EFI_SERIAL_IO_PROTOCOL    *SerialIo;
-  EFI_DEVICE_PATH_PROTOCOL  *Node;
   EFI_DEVICE_PATH_PROTOCOL  *OutDevicePath;
   EFI_DEVICE_PATH_PROTOCOL  *InpDevicePath;
   EFI_DEVICE_PATH_PROTOCOL  *ErrDevicePath;
@@ -458,76 +452,63 @@ LocateSerialIo (
           (VOID **) &DevicePath
           );
 
-    Acpi = NULL;
-    for (Node = DevicePath; !IsDevicePathEnd (Node); Node = NextDevicePathNode (Node)) {
-      if ((DevicePathType (Node) == MESSAGING_DEVICE_PATH) && (DevicePathSubType (Node) == MSG_UART_DP)) {
-        break;
-      }
-      //
-      // Acpi points to the node before Uart node
-      //
-      Acpi = (ACPI_HID_DEVICE_PATH *) Node;
+    NewMenuEntry = BOpt_CreateMenuEntry (BM_TERMINAL_CONTEXT_SELECT);
+    if (NewMenuEntry == NULL) {
+      FreePool (Handles);
+      return EFI_OUT_OF_RESOURCES;
     }
 
-    if ((Acpi != NULL) && IsIsaSerialNode (Acpi)) {
-      NewMenuEntry = BOpt_CreateMenuEntry (BM_TERMINAL_CONTEXT_SELECT);
-      if (NewMenuEntry == NULL) {
-        FreePool (Handles);
-        return EFI_OUT_OF_RESOURCES;
-      }
+    NewTerminalContext = (BM_TERMINAL_CONTEXT *) NewMenuEntry->VariableContext;
+    NewMenuEntry->OptionNumber = TerminalMenu.MenuNumber;
+    NewTerminalContext->DevicePath = DuplicateDevicePath (DevicePath);
+    //
+    // BugBug: I have no choice, calling EfiLibStrFromDatahub will hang the system!
+    // coz' the misc data for each platform is not correct, actually it's the device path stored in
+    // datahub which is not completed, so a searching for end of device path will enter a
+    // dead-loop.
+    //
+    NewMenuEntry->DisplayString = EfiLibStrFromDatahub (DevicePath);
+    if (NULL == NewMenuEntry->DisplayString) {
+      NewMenuEntry->DisplayString = UiDevicePathToStr (DevicePath);
+    }
 
-      NewTerminalContext = (BM_TERMINAL_CONTEXT *) NewMenuEntry->VariableContext;
-      CopyMem (&NewMenuEntry->OptionNumber, &Acpi->UID, sizeof (UINT32));
-      NewTerminalContext->DevicePath = DuplicateDevicePath (DevicePath);
-      //
-      // BugBug: I have no choice, calling EfiLibStrFromDatahub will hang the system!
-      // coz' the misc data for each platform is not correct, actually it's the device path stored in
-      // datahub which is not completed, so a searching for end of device path will enter a
-      // dead-loop.
-      //
-      NewMenuEntry->DisplayString = EfiLibStrFromDatahub (DevicePath);
-      if (NULL == NewMenuEntry->DisplayString) {
-        NewMenuEntry->DisplayString = UiDevicePathToStr (DevicePath);
-      }
+    NewMenuEntry->HelpString = NULL;
 
-      NewMenuEntry->HelpString = NULL;
+    NewMenuEntry->DisplayStringToken = HiiSetString (mBmmCallbackInfo->BmmHiiHandle, 0, NewMenuEntry->DisplayString, NULL);
 
-      NewMenuEntry->DisplayStringToken = HiiSetString (mBmmCallbackInfo->BmmHiiHandle, 0, NewMenuEntry->DisplayString, NULL);
+    NewMenuEntry->HelpStringToken = NewMenuEntry->DisplayStringToken;
 
-      NewMenuEntry->HelpStringToken = NewMenuEntry->DisplayStringToken;
-
-      gBS->HandleProtocol (
-            Handles[Index],
-            &gEfiSerialIoProtocolGuid,
-            (VOID **) &SerialIo
-            );
+    gBS->HandleProtocol (
+          Handles[Index],
+          &gEfiSerialIoProtocolGuid,
+          (VOID **) &SerialIo
+          );
 
-      CopyMem (
-        &NewTerminalContext->BaudRate,
-        &SerialIo->Mode->BaudRate,
-        sizeof (UINT64)
-        );
+    CopyMem (
+      &NewTerminalContext->BaudRate,
+      &SerialIo->Mode->BaudRate,
+      sizeof (UINT64)
+      );
 
-      CopyMem (
-        &NewTerminalContext->DataBits,
-        &SerialIo->Mode->DataBits,
-        sizeof (UINT8)
-        );
+    CopyMem (
+      &NewTerminalContext->DataBits,
+      &SerialIo->Mode->DataBits,
+      sizeof (UINT8)
+      );
 
-      CopyMem (
-        &NewTerminalContext->Parity,
-        &SerialIo->Mode->Parity,
-        sizeof (UINT8)
-        );
+    CopyMem (
+      &NewTerminalContext->Parity,
+      &SerialIo->Mode->Parity,
+      sizeof (UINT8)
+      );
 
-      CopyMem (
-        &NewTerminalContext->StopBits,
-        &SerialIo->Mode->StopBits,
-        sizeof (UINT8)
-        );
-      InsertTailList (&TerminalMenu.Head, &NewMenuEntry->Link);
-      TerminalMenu.MenuNumber++;
-    }
+    CopyMem (
+      &NewTerminalContext->StopBits,
+      &SerialIo->Mode->StopBits,
+      sizeof (UINT8)
+      );
+    InsertTailList (&TerminalMenu.Head, &NewMenuEntry->Link);
+    TerminalMenu.MenuNumber++;
   }
   if (Handles != NULL) {
     FreePool (Handles);
@@ -753,8 +734,6 @@ GetConsoleMenu (
   UINTN                     Index2;
   BM_MENU_ENTRY             *NewMenuEntry;
   BM_CONSOLE_CONTEXT        *NewConsoleContext;
-  TYPE_OF_TERMINAL          Terminal;
-  UINTN                     Com;
   BM_MENU_OPTION            *ConsoleMenu;
 
   DevicePath    = NULL;
@@ -822,11 +801,7 @@ GetConsoleMenu (
       NewMenuEntry->HelpStringToken = HiiSetString (mBmmCallbackInfo->BmmHiiHandle, 0, NewMenuEntry->HelpString, NULL);
     }
 
-    NewConsoleContext->IsTerminal = IsTerminalDevicePath (
-                                      NewConsoleContext->DevicePath,
-                                      &Terminal,
-                                      &Com
-                                      );
+    NewConsoleContext->IsTerminal = IsTerminalDevicePath (NewConsoleContext->DevicePath);
 
     NewConsoleContext->IsActive = MatchDevicePaths (
                                     DevicePath,
@@ -884,8 +859,6 @@ FreeAllConsoles (
 
 
   @param DevicePath      DevicePath to be checked
-  @param Termi           If DevicePath is valid Terminal, terminal type is returned.
-  @param Com             If DevicePath is valid Terminal, Com Port type is returned.
 
   @retval  TRUE         If DevicePath point to a Terminal.
   @retval  FALSE        If DevicePath does not point to a Terminal.
@@ -893,90 +866,22 @@ FreeAllConsoles (
 **/
 BOOLEAN
 IsTerminalDevicePath (
-  IN  EFI_DEVICE_PATH_PROTOCOL *DevicePath,
-  OUT TYPE_OF_TERMINAL         *Termi,
-  OUT UINTN                    *Com
+  IN  EFI_DEVICE_PATH_PROTOCOL *DevicePath
   )
 {
-  BOOLEAN                   IsTerminal;
+  EFI_STATUS                Status;
   EFI_DEVICE_PATH_PROTOCOL  *Node;
-  VENDOR_DEVICE_PATH        *Vendor;
-  UART_DEVICE_PATH          *Uart;
-  ACPI_HID_DEVICE_PATH      *Acpi;
-
-  IsTerminal = FALSE;
-
-  Uart   = NULL;
-  Vendor = NULL;
-  Acpi   = NULL;
-  for (Node = DevicePath; !IsDevicePathEnd (Node); Node = NextDevicePathNode (Node)) {
-    //
-    // Vendor points to the node before the End node
-    //
-    Vendor = (VENDOR_DEVICE_PATH *) Node;
-
-    if ((DevicePathType (Node) == MESSAGING_DEVICE_PATH) && (DevicePathSubType (Node) == MSG_UART_DP)) {
-      Uart = (UART_DEVICE_PATH *) Node;
-    }
-
-    if (Uart == NULL) {
-      //
-      // Acpi points to the node before the UART node
-      //
-      Acpi = (ACPI_HID_DEVICE_PATH *) Node;
-    }
-  }
-
-  if (Vendor == NULL ||
-      DevicePathType (Vendor) != MESSAGING_DEVICE_PATH ||
-      DevicePathSubType (Vendor) != MSG_VENDOR_DP ||
-      Uart == NULL) {
-    return FALSE;
-  }
+  EFI_HANDLE                SerialHandle;
 
-  //
-  // There are four kinds of Terminal types
-  // check to see whether this devicepath
-  // is one of that type
-  //
-  if (CompareGuid (&Vendor->Guid, &TerminalTypeGuid[0])) {
-    *Termi      = TerminalTypePcAnsi;
-    IsTerminal  = TRUE;
-  } else {
-    if (CompareGuid (&Vendor->Guid, &TerminalTypeGuid[1])) {
-      *Termi      = TerminalTypeVt100;
-      IsTerminal  = TRUE;
-    } else {
-      if (CompareGuid (&Vendor->Guid, &TerminalTypeGuid[2])) {
-        *Termi      = TerminalTypeVt100Plus;
-        IsTerminal  = TRUE;
-      } else {
-        if (CompareGuid (&Vendor->Guid, &TerminalTypeGuid[3])) {
-          *Termi      = TerminalTypeVtUtf8;
-          IsTerminal  = TRUE;
-        } else {
-          if (CompareGuid (&Vendor->Guid, &TerminalTypeGuid[4])) {
-            *Termi      = TerminalTypeTtyTerm;
-            IsTerminal  = TRUE;
-          } else {
-            IsTerminal = FALSE;
-          }
-        }
-      }
-    }
-  }
-
-  if (!IsTerminal) {
-    return FALSE;
-  }
-
-  if ((Acpi != NULL) && IsIsaSerialNode (Acpi)) {
-    CopyMem (Com, &Acpi->UID, sizeof (UINT32));
-  } else {
+  Node = DevicePath;
+  Status = gBS->LocateDevicePath (&gEfiSerialIoProtocolGuid, &Node, &SerialHandle);
+  if (EFI_ERROR (Status)) {
     return FALSE;
   }
 
-  return TRUE;
+  return (BOOLEAN) (
+           (DevicePathType (Node) == MESSAGING_DEVICE_PATH) &&
+           (DevicePathSubType (Node) == MSG_VENDOR_DP));
 }
 
 /**
-- 
2.9.0.windows.1



^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-01-10  6:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-01-09  2:18 [PATCH] MdeModulePkg/BootMaintenanceManagerUiLib: Support NT32 terminals Ruiyu Ni
2017-01-09  9:32 ` Ni, Ruiyu
2017-01-10  6:37 ` Gao, Liming

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox