public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Gao, Liming" <liming.gao@intel.com>
To: "Ni, Ruiyu" <ruiyu.ni@intel.com>,
	"edk2-devel@lists.01.org" <edk2-devel@lists.01.org>
Cc: Dandan Bi <danda.bi@intel.com>
Subject: Re: [PATCH] MdeModulePkg/BootMaintenanceManagerUiLib: Support NT32 terminals
Date: Tue, 10 Jan 2017 06:37:41 +0000	[thread overview]
Message-ID: <4A89E2EF3DFEDB4C8BFDE51014F606A14D6CB84A@shsmsx102.ccr.corp.intel.com> (raw)
In-Reply-To: <20170109021831.116788-1-ruiyu.ni@intel.com>

Ray:
  There is other code in this library to consume HID COM value. Could you clean up them together?

Thanks
Liming
>-----Original Message-----
>From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of
>Ruiyu Ni
>Sent: Monday, January 09, 2017 10:19 AM
>To: edk2-devel@lists.01.org
>Cc: Dandan Bi <danda.bi@intel.com>; Gao, Liming <liming.gao@intel.com>
>Subject: [edk2] [PATCH] MdeModulePkg/BootMaintenanceManagerUiLib:
>Support NT32 terminals
>
>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
>
>_______________________________________________
>edk2-devel mailing list
>edk2-devel@lists.01.org
>https://lists.01.org/mailman/listinfo/edk2-devel


      parent reply	other threads:[~2017-01-10  6:37 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4A89E2EF3DFEDB4C8BFDE51014F606A14D6CB84A@shsmsx102.ccr.corp.intel.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox