public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH 0/5] Change "dh" to support dump from GUID and "decode" parameter
@ 2017-01-09  9:30 Ruiyu Ni
  2017-01-09  9:30 ` [PATCH 1/5] ShellPkg/HandleParsingLib: Rename global variables Ruiyu Ni
                   ` (5 more replies)
  0 siblings, 6 replies; 12+ messages in thread
From: Ruiyu Ni @ 2017-01-09  9:30 UTC (permalink / raw)
  To: edk2-devel

Change "dh" to support dump from GUID and "decode" parameter

Chen A Chen (2):
  ShellPkg/HandleParsingLib: Add new API GetAllMappingGuids
  ShellPkg/Dh: Fix coding style issues

Ruiyu Ni (3):
  ShellPkg/HandleParsingLib: Rename global variables
  ShellPkg/HandleParsingLib: Return NULL name for unknown GUID
  ShellPkg/dh: Support dump from GUID and "decode" parameter

 ShellPkg/Include/Library/HandleParsingLib.h        |  21 +-
 .../UefiHandleParsingLib/UefiHandleParsingLib.c    | 130 ++++--
 .../UefiHandleParsingLib/UefiHandleParsingLib.uni  |   4 +-
 ShellPkg/Library/UefiShellDriver1CommandsLib/Dh.c  | 458 +++++++++++++++------
 .../UefiShellDriver1CommandsLib.uni                |   9 +-
 5 files changed, 446 insertions(+), 176 deletions(-)

-- 
2.9.0.windows.1



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

* [PATCH 1/5] ShellPkg/HandleParsingLib: Rename global variables
  2017-01-09  9:30 [PATCH 0/5] Change "dh" to support dump from GUID and "decode" parameter Ruiyu Ni
@ 2017-01-09  9:30 ` Ruiyu Ni
  2017-01-09  9:30 ` [PATCH 2/5] ShellPkg/HandleParsingLib: Return NULL name for unknown GUID Ruiyu Ni
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 12+ messages in thread
From: Ruiyu Ni @ 2017-01-09  9:30 UTC (permalink / raw)
  To: edk2-devel; +Cc: Jaben Carsey

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Jaben Carsey <jaben.carsey@intel.com>
---
 .../UefiHandleParsingLib/UefiHandleParsingLib.c    | 36 +++++++++++-----------
 1 file changed, 18 insertions(+), 18 deletions(-)

diff --git a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c
index 28a582f..1049dea 100644
--- a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c
+++ b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c
@@ -1,7 +1,7 @@
 /** @file
   Provides interface to advanced shell functionality for parsing both handle and protocol database.
 
-  Copyright (c) 2010 - 2016, Intel Corporation. All rights reserved.<BR>
+  Copyright (c) 2010 - 2017, Intel Corporation. All rights reserved.<BR>
   (C) Copyright 2013-2015 Hewlett-Packard Development Company, L.P.<BR>
   (C) Copyright 2015-2016 Hewlett Packard Enterprise Development LP<BR>
   This program and the accompanying materials
@@ -19,8 +19,8 @@
 
 EFI_HANDLE        mHandleParsingHiiHandle = NULL;
 HANDLE_INDEX_LIST mHandleList = {{{NULL,NULL},0,0},0};
-GUID_INFO_BLOCK   *GuidList;
-UINTN             GuidListCount;
+GUID_INFO_BLOCK   *mGuidList;
+UINTN             mGuidListCount;
 /**
   Function to translate the EFI_MEMORY_TYPE into a string.
 
@@ -98,8 +98,8 @@ HandleParsingLibConstructor (
   IN EFI_SYSTEM_TABLE  *SystemTable
   )
 {
-  GuidListCount = 0;
-  GuidList      = NULL;
+  mGuidListCount = 0;
+  mGuidList      = NULL;
 
   //
   // Do nothing with mHandleParsingHiiHandle.  Initialize HII as needed.
@@ -137,11 +137,11 @@ HandleParsingLibDestructor (
 {
   UINTN                 LoopCount;
 
-  for (LoopCount = 0; GuidList != NULL && LoopCount < GuidListCount; LoopCount++) {
-    SHELL_FREE_NON_NULL(GuidList[LoopCount].GuidId);
+  for (LoopCount = 0; mGuidList != NULL && LoopCount < mGuidListCount; LoopCount++) {
+    SHELL_FREE_NON_NULL(mGuidList[LoopCount].GuidId);
   }
 
-  SHELL_FREE_NON_NULL(GuidList);
+  SHELL_FREE_NON_NULL(mGuidList);
   if (mHandleParsingHiiHandle != NULL) {
     HiiRemovePackages(mHandleParsingHiiHandle);
   }
@@ -1838,7 +1838,7 @@ InternalShellGetNodeFromGuid(
 
   ASSERT(Guid != NULL);
 
-  for (LoopCount = 0, ListWalker = GuidList; GuidList != NULL && LoopCount < GuidListCount; LoopCount++, ListWalker++) {
+  for (LoopCount = 0, ListWalker = mGuidList; mGuidList != NULL && LoopCount < mGuidListCount; LoopCount++, ListWalker++) {
     if (CompareGuid(ListWalker->GuidId, Guid)) {
       return (ListWalker);
     }
@@ -1881,18 +1881,18 @@ InsertNewGuidNameMapping(
   ASSERT(Guid   != NULL);
   ASSERT(NameID != 0);
 
-  GuidList = ReallocatePool(GuidListCount * sizeof(GUID_INFO_BLOCK), GuidListCount+1 * sizeof(GUID_INFO_BLOCK), GuidList);
-  if (GuidList == NULL) {
-    GuidListCount = 0;
+  mGuidList = ReallocatePool(mGuidListCount * sizeof(GUID_INFO_BLOCK), mGuidListCount+1 * sizeof(GUID_INFO_BLOCK), mGuidList);
+  if (mGuidList == NULL) {
+    mGuidListCount = 0;
     return (EFI_OUT_OF_RESOURCES);
   }
-  GuidListCount++;
+  mGuidListCount++;
 
-  GuidList[GuidListCount - 1].GuidId   = AllocateCopyPool(sizeof(EFI_GUID), Guid);
-  GuidList[GuidListCount - 1].StringId = NameID;
-  GuidList[GuidListCount - 1].DumpInfo = DumpFunc;
+  mGuidList[mGuidListCount - 1].GuidId   = AllocateCopyPool(sizeof(EFI_GUID), Guid);
+  mGuidList[mGuidListCount - 1].StringId = NameID;
+  mGuidList[mGuidListCount - 1].DumpInfo = DumpFunc;
 
-  if (GuidList[GuidListCount - 1].GuidId == NULL) {
+  if (mGuidList[mGuidListCount - 1].GuidId == NULL) {
     return (EFI_OUT_OF_RESOURCES);
   }
 
@@ -2061,7 +2061,7 @@ GetGuidFromStringName(
     }
   }
 
-  for (LoopCount = 0, ListWalker = GuidList; GuidList != NULL && LoopCount < GuidListCount; LoopCount++, ListWalker++) {
+  for (LoopCount = 0, ListWalker = mGuidList; mGuidList != NULL && LoopCount < mGuidListCount; LoopCount++, ListWalker++) {
     String = HiiGetString(mHandleParsingHiiHandle, ListWalker->StringId, Lang);
     if (Name != NULL && String != NULL && StringNoCaseCompare (&Name, &String) == 0) {
       *Guid = ListWalker->GuidId;
-- 
2.9.0.windows.1



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

* [PATCH 2/5] ShellPkg/HandleParsingLib: Return NULL name for unknown GUID
  2017-01-09  9:30 [PATCH 0/5] Change "dh" to support dump from GUID and "decode" parameter Ruiyu Ni
  2017-01-09  9:30 ` [PATCH 1/5] ShellPkg/HandleParsingLib: Rename global variables Ruiyu Ni
@ 2017-01-09  9:30 ` Ruiyu Ni
  2017-01-09  9:30 ` [PATCH 3/5] ShellPkg/HandleParsingLib: Add new API GetAllMappingGuids Ruiyu Ni
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 12+ messages in thread
From: Ruiyu Ni @ 2017-01-09  9:30 UTC (permalink / raw)
  To: edk2-devel; +Cc: Jaben Carsey

GetStringNameFromGuid() returns NULL for unknown GUID, instead of
returning "UnknownDevice".
The behavior change matches ShellProtocol.GetGuidName().

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Jaben Carsey <jaben.carsey@intel.com>
---
 .../UefiHandleParsingLib/UefiHandleParsingLib.c    | 42 +++++++++++-----------
 .../UefiHandleParsingLib/UefiHandleParsingLib.uni  |  4 +--
 ShellPkg/Library/UefiShellDriver1CommandsLib/Dh.c  | 20 ++++++-----
 3 files changed, 34 insertions(+), 32 deletions(-)

diff --git a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c
index 1049dea..780c458 100644
--- a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c
+++ b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c
@@ -933,25 +933,22 @@ AdapterInformationDumpInformation (
       } else {
 
         GuidStr = GetStringNameFromGuid (&InfoTypesBuffer[GuidIndex], NULL);
+        if (GuidStr == NULL) {
+          TempRetVal = CatSPrint (RetVal, TempStr, L"UnknownInfoType");
+          SHELL_FREE_NON_NULL (RetVal);
+          RetVal = TempRetVal;
 
-        if (GuidStr != NULL) {
-          if (StrCmp(GuidStr, L"UnknownDevice") == 0) {
-            TempRetVal = CatSPrint (RetVal, TempStr, L"UnknownInfoType");
-            SHELL_FREE_NON_NULL (RetVal);
-            RetVal = TempRetVal;
-
-            SHELL_FREE_NON_NULL (TempStr);
-            SHELL_FREE_NON_NULL(GuidStr);
-            //
-            // So that we never have to pass this UnknownInfoType to the parsing function "GetInformation" service of AIP
-            //
-            continue;
-          } else {
-            TempRetVal = CatSPrint (RetVal, TempStr, GuidStr);
-            SHELL_FREE_NON_NULL (RetVal);
-            RetVal = TempRetVal;
-            SHELL_FREE_NON_NULL(GuidStr);
-          }
+          SHELL_FREE_NON_NULL (TempStr);
+          SHELL_FREE_NON_NULL(GuidStr);
+          //
+          // So that we never have to pass this UnknownInfoType to the parsing function "GetInformation" service of AIP
+          //
+          continue;
+        } else {
+          TempRetVal = CatSPrint (RetVal, TempStr, GuidStr);
+          SHELL_FREE_NON_NULL (RetVal);
+          RetVal = TempRetVal;
+          SHELL_FREE_NON_NULL(GuidStr);
         }
       }
 
@@ -1500,7 +1497,7 @@ STATIC CONST GUID_INFO_BLOCK mGuidStringListNT[] = {
   {STRING_TOKEN(STR_WINNT_THUNK),           (EFI_GUID*)&WinNtThunkProtocolGuid,               NULL},
   {STRING_TOKEN(STR_WINNT_DRIVER_IO),       (EFI_GUID*)&WinNtIoProtocolGuid,                  NULL},
   {STRING_TOKEN(STR_WINNT_SERIAL_PORT),     (EFI_GUID*)&WinNtSerialPortGuid,                  NULL},
-  {STRING_TOKEN(STR_UNKNOWN_DEVICE),        NULL,                                             NULL},
+  {0,                                       NULL,                                             NULL},
 };
 
 STATIC CONST GUID_INFO_BLOCK mGuidStringList[] = {
@@ -1816,7 +1813,7 @@ STATIC CONST GUID_INFO_BLOCK mGuidStringList[] = {
 //
 // terminator
 //
-  {STRING_TOKEN(STR_UNKNOWN_DEVICE),        NULL,                                             NULL},
+  {0,                                       NULL,                                             NULL},
 };
 
 /**
@@ -1964,7 +1961,10 @@ GetStringNameFromGuid(
   HandleParsingHiiInit();
 
   Id = InternalShellGetNodeFromGuid(Guid);
-  return (HiiGetString(mHandleParsingHiiHandle, Id==NULL?STRING_TOKEN(STR_UNKNOWN_DEVICE):Id->StringId, Lang));
+  if (Id == NULL) {
+    return NULL;
+  }
+  return HiiGetString (mHandleParsingHiiHandle, Id->StringId, Lang);
 }
 
 /**
diff --git a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.uni b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.uni
index aa6663d..0d51627 100644
--- a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.uni
+++ b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.uni
@@ -1,6 +1,6 @@
 // /**
 //
-// Copyright (c) 2010 - 2015, Intel Corporation. All rights reserved. <BR>
+// Copyright (c) 2010 - 2017, Intel Corporation. All rights reserved. <BR>
 // (C) Copyright 2013-2015 Hewlett-Packard Development Company, L.P.<BR>
 // (C) Copyright 2015-2016 Hewlett Packard Enterprise Development LP<BR>
 // This program and the accompanying materials
@@ -159,8 +159,6 @@
 #string STR_WINNT_DRIVER_IO       #language en-US "WinNTDriverIO"
 #string STR_WINNT_SERIAL_PORT     #language en-US "WinNTSerialPort"
 
-#string STR_UNKNOWN_DEVICE        #language en-US "UnknownDevice"
-
 // deprecated protocols
 #string STR_SHELL_INTERFACE       #language en-US "ShellInterface"
 #string STR_SHELL_ENV             #language en-US "ShellEnvironment"
diff --git a/ShellPkg/Library/UefiShellDriver1CommandsLib/Dh.c b/ShellPkg/Library/UefiShellDriver1CommandsLib/Dh.c
index e07304c..0ac49e1 100644
--- a/ShellPkg/Library/UefiShellDriver1CommandsLib/Dh.c
+++ b/ShellPkg/Library/UefiShellDriver1CommandsLib/Dh.c
@@ -2,7 +2,7 @@
   Main file for Dh shell Driver1 function.
 
   (C) Copyright 2014-2015 Hewlett-Packard Development Company, L.P.<BR>
-  Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.<BR>
+  Copyright (c) 2010 - 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
@@ -153,6 +153,7 @@ GetProtocolInfoString(
   CHAR16                    *RetVal;
   UINTN                     Size;
   CHAR16                    *Temp;
+  CHAR16                    GuidStr[40];
 
   ProtocolGuidArray = NULL;
   RetVal            = NULL;
@@ -166,16 +167,19 @@ GetProtocolInfoString(
   if (!EFI_ERROR (Status)) {
     for (ProtocolIndex = 0; ProtocolIndex < ArrayCount; ProtocolIndex++) {
       Temp = GetStringNameFromGuid(ProtocolGuidArray[ProtocolIndex], Language);
-      if (Temp != NULL) {
-        ASSERT((RetVal == NULL && Size == 0) || (RetVal != NULL));
-        if (Size != 0) {
-          StrnCatGrow(&RetVal, &Size, Separator, 0);
-        }
-        StrnCatGrow(&RetVal, &Size, L"%H", 0);
+      ASSERT((RetVal == NULL && Size == 0) || (RetVal != NULL));
+      if (Size != 0) {
+        StrnCatGrow(&RetVal, &Size, Separator, 0);
+      }
+      StrnCatGrow(&RetVal, &Size, L"%H", 0);
+      if (Temp == NULL) {
+        UnicodeSPrint (GuidStr, sizeof (GuidStr), L"%g", ProtocolGuidArray[ProtocolIndex]);
+        StrnCatGrow (&RetVal, &Size, GuidStr, 0);
+      } else {
         StrnCatGrow(&RetVal, &Size, Temp, 0);
-        StrnCatGrow(&RetVal, &Size, L"%N", 0);
         FreePool(Temp);
       }
+      StrnCatGrow(&RetVal, &Size, L"%N", 0);
       if (ExtraInfo) {
         Temp = GetProtocolInformationDump(TheHandle, ProtocolGuidArray[ProtocolIndex], Verbose);
         if (Temp != NULL) {
-- 
2.9.0.windows.1



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

* [PATCH 3/5] ShellPkg/HandleParsingLib: Add new API GetAllMappingGuids
  2017-01-09  9:30 [PATCH 0/5] Change "dh" to support dump from GUID and "decode" parameter Ruiyu Ni
  2017-01-09  9:30 ` [PATCH 1/5] ShellPkg/HandleParsingLib: Rename global variables Ruiyu Ni
  2017-01-09  9:30 ` [PATCH 2/5] ShellPkg/HandleParsingLib: Return NULL name for unknown GUID Ruiyu Ni
@ 2017-01-09  9:30 ` Ruiyu Ni
  2017-01-09  9:30 ` [PATCH 4/5] ShellPkg/Dh: Fix coding style issues Ruiyu Ni
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 12+ messages in thread
From: Ruiyu Ni @ 2017-01-09  9:30 UTC (permalink / raw)
  To: edk2-devel; +Cc: Chen A Chen

From: Chen A Chen <chen.a.chen@intel.com>

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Signed-off-by: Chen A Chen <chen.a.chen@intel.com>
---
 ShellPkg/Include/Library/HandleParsingLib.h        | 21 ++++++++-
 .../UefiHandleParsingLib/UefiHandleParsingLib.c    | 52 ++++++++++++++++++++++
 2 files changed, 72 insertions(+), 1 deletion(-)

diff --git a/ShellPkg/Include/Library/HandleParsingLib.h b/ShellPkg/Include/Library/HandleParsingLib.h
index 79dcc9c..b02cf4f 100644
--- a/ShellPkg/Include/Library/HandleParsingLib.h
+++ b/ShellPkg/Include/Library/HandleParsingLib.h
@@ -1,7 +1,7 @@
 /** @file
   Provides interface to advanced shell functionality for parsing both handle and protocol database.
 
-  Copyright (c) 2010 - 2015, Intel Corporation. All rights reserved.<BR>
+  Copyright (c) 2010 - 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
@@ -388,4 +388,23 @@ GetHandleListByProtocolList (
   IN CONST EFI_GUID **ProtocolGuids
   );
 
+
+/**
+  Return all supported GUIDs.
+
+  @param[out]     Guids  The buffer to return all supported GUIDs.
+  @param[in out]  Count  On input, the count of GUIDs the buffer can hold,
+                         On output, the count of GUIDs to return.
+
+  @retval EFI_INVALID_PARAMETER Count is NULL.
+  @retval EFI_BUFFER_TOO_SMALL  Buffer is not enough to hold all GUIDs.
+  @retval EFI_SUCCESS           GUIDs are returned successfully.
+**/
+EFI_STATUS
+EFIAPI
+GetAllMappingGuids (
+  OUT EFI_GUID *Guids,
+  IN OUT UINTN *Count
+  );
+
 #endif // __HANDLE_PARSING_LIB__
diff --git a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c
index 780c458..b4cd1b3 100644
--- a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c
+++ b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c
@@ -3079,3 +3079,55 @@ GetHandleListByProtocolList (
 
   return (HandleList);
 }
+
+/**
+  Return all supported GUIDs.
+
+  @param[out]     Guids  The buffer to return all supported GUIDs.
+  @param[in, out] Count  On input, the count of GUIDs the buffer can hold,
+                         On output, the count of GUIDs to return.
+
+  @retval EFI_INVALID_PARAMETER Count is NULL.
+  @retval EFI_BUFFER_TOO_SMALL  Buffer is not enough to hold all GUIDs.
+  @retval EFI_SUCCESS           GUIDs are returned successfully.
+**/
+EFI_STATUS
+EFIAPI
+GetAllMappingGuids (
+  OUT EFI_GUID *Guids,
+  IN OUT UINTN *Count
+  )
+{
+  UINTN GuidCount;
+  UINTN NtGuidCount
+  UINTN Index;
+
+  if (Count == NULL) {
+    return EFI_INVALID_PARAMETER;
+  }
+
+  NtGuidCount = 0;
+  if (PcdGetBool (PcdShellIncludeNtGuids)) {
+    NtGuidCount = ARRAY_SIZE (mGuidStringListNT) - 1;
+  }
+  GuidCount   = ARRAY_SIZE (mGuidStringList) - 1;
+
+  if (*Count < NtGuidCount + GuidCount + mGuidListCount) {
+    *Count = NtGuidCount + GuidCount + mGuidListCount;
+    return EFI_BUFFER_TOO_SMALL;
+  }
+
+  for (Index = 0; Index < NtGuidCount; Index++) {
+    CopyGuid (&Guids[Index], mGuidStringListNT[Index].GuidId);
+  }
+
+  for (Index = 0; Index < GuidCount; Index++) {
+    CopyGuid (&Guids[NtGuidCount + Index], mGuidStringList[Index].GuidId);
+  }
+
+  for (Index = 0; Index < mGuidListCount; Index++) {
+    CopyGuid (&Guids[NtGuidCount + GuidCount + Index], mGuidList[Index].GuidId);
+  }
+
+  return EFI_SUCCESS;
+}
-- 
2.9.0.windows.1



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

* [PATCH 4/5] ShellPkg/Dh: Fix coding style issues
  2017-01-09  9:30 [PATCH 0/5] Change "dh" to support dump from GUID and "decode" parameter Ruiyu Ni
                   ` (2 preceding siblings ...)
  2017-01-09  9:30 ` [PATCH 3/5] ShellPkg/HandleParsingLib: Add new API GetAllMappingGuids Ruiyu Ni
@ 2017-01-09  9:30 ` Ruiyu Ni
  2017-01-09 15:36   ` Carsey, Jaben
  2017-01-09  9:30 ` [PATCH 5/5] ShellPkg/dh: Support dump from GUID and "decode" parameter Ruiyu Ni
  2017-01-09 15:40 ` [PATCH 0/5] Change "dh" to support " Carsey, Jaben
  5 siblings, 1 reply; 12+ messages in thread
From: Ruiyu Ni @ 2017-01-09  9:30 UTC (permalink / raw)
  To: edk2-devel; +Cc: Chen A Chen, Jaben Carsey

From: Chen A Chen <chen.a.chen@intel.com>

The change doesn't impact the functionality.

Contributed-under: TianoCore Contribution Agreement 1.0
Cc: Jaben Carsey <jaben.carsey@intel.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Signed-off-by: Chen A Chen <chen.a.chen@intel.com>
---
 ShellPkg/Library/UefiShellDriver1CommandsLib/Dh.c | 119 ++++++++++------------
 1 file changed, 54 insertions(+), 65 deletions(-)

diff --git a/ShellPkg/Library/UefiShellDriver1CommandsLib/Dh.c b/ShellPkg/Library/UefiShellDriver1CommandsLib/Dh.c
index 0ac49e1..2773842 100644
--- a/ShellPkg/Library/UefiShellDriver1CommandsLib/Dh.c
+++ b/ShellPkg/Library/UefiShellDriver1CommandsLib/Dh.c
@@ -642,11 +642,8 @@ DisplayDriverModelHandle (
   @param[in] DriverInfo       TRUE to show all info about the handle.
   @param[in] Multiple         TRUE indicates more than  will be output,
                               FALSE for a single one.
-
-  @retval SHELL_SUCCESS           The operation was successful.
-  @retval SHELL_INVALID_PARAMETER ProtocolName was NULL or invalid.
 **/
-SHELL_STATUS
+VOID
 DoDhByHandle(
   IN CONST EFI_HANDLE TheHandle,
   IN CONST BOOLEAN    Verbose,
@@ -656,10 +653,8 @@ DoDhByHandle(
   IN CONST BOOLEAN    Multiple
   )
 {
-  CHAR16              *ProtocolInfoString;
-  SHELL_STATUS        ShellStatus;
+  CHAR16 *ProtocolInfoString;
 
-  ShellStatus         = SHELL_SUCCESS;
   ProtocolInfoString  = NULL;
 
   if (!Sfo) {
@@ -672,7 +667,8 @@ DoDhByHandle(
         STRING_TOKEN (STR_DH_OUTPUT),
         gShellDriver1HiiHandle,
         ConvertHandleToHandleIndex(TheHandle),
-        ProtocolInfoString==NULL?L"":ProtocolInfoString);
+        ProtocolInfoString==NULL?L"":ProtocolInfoString
+      );
     } else {
       ProtocolInfoString = GetProtocolInfoString(TheHandle, Language, L"\r\n", Verbose, TRUE);
       ShellPrintHiiEx(
@@ -683,7 +679,8 @@ DoDhByHandle(
         gShellDriver1HiiHandle,
         ConvertHandleToHandleIndex(TheHandle),
         TheHandle,
-        ProtocolInfoString==NULL?L"":ProtocolInfoString);
+        ProtocolInfoString==NULL?L"":ProtocolInfoString
+      );
     }
 
     if (DriverInfo) {
@@ -702,16 +699,13 @@ DoDhByHandle(
         L"ControllerName",
         ConvertHandleToHandleIndex(TheHandle),
         L"DevPath",
-        ProtocolInfoString==NULL?L"":ProtocolInfoString);
-
-
+        ProtocolInfoString==NULL?L"":ProtocolInfoString
+      );
   }
 
-
   if (ProtocolInfoString != NULL) {
     FreePool(ProtocolInfoString);
   }
-  return (ShellStatus);
 }
 
 /**
@@ -723,8 +717,8 @@ DoDhByHandle(
   @param[in] Language         Language string per UEFI specification.
   @param[in] DriverInfo       TRUE to show all info about the handle.
 
-  @retval SHELL_SUCCESS           The operation was successful.
-  @retval SHELL_INVALID_PARAMETER ProtocolName was NULL or invalid.
+  @retval SHELL_SUCCESS       The operation was successful.
+  @retval SHELL_ABORTED       The operation was aborted.
 **/
 SHELL_STATUS
 DoDhForHandleList(
@@ -740,15 +734,8 @@ DoDhForHandleList(
 
   ShellStatus       = SHELL_SUCCESS;
 
-  for (HandleWalker = HandleList ; HandleWalker != NULL && *HandleWalker != NULL && ShellStatus == SHELL_SUCCESS; HandleWalker++) {
-    ShellStatus = DoDhByHandle(
-          *HandleWalker,
-          Verbose,
-          Sfo,
-          Language,
-          DriverInfo,
-          TRUE
-         );
+  for ( HandleWalker = HandleList; HandleWalker != NULL && *HandleWalker != NULL; HandleWalker++ ) {
+    DoDhByHandle (*HandleWalker, Verbose, Sfo, Language, DriverInfo, TRUE);
     if (ShellGetExecutionBreakFlag ()) {
       ShellStatus = SHELL_ABORTED;
       break;
@@ -862,10 +849,10 @@ ShellCommandRunDh (
   SHELL_STATUS        ShellStatus;
   CHAR8               *Language;
   CONST CHAR16        *Lang;
-  CONST CHAR16        *Temp2;
-  BOOLEAN             SfoMode;
-  BOOLEAN             FlagD;
-  BOOLEAN             Verbose;
+  CONST CHAR16        *RawValue;
+  BOOLEAN             SfoFlag;
+  BOOLEAN             DriverFlag;
+  BOOLEAN             VerboseFlag;
   UINT64              Intermediate;
 
   ShellStatus         = SHELL_SUCCESS;
@@ -900,30 +887,32 @@ ShellCommandRunDh (
       return (SHELL_INVALID_PARAMETER);
     }
 
-    Lang = ShellCommandLineGetValue(Package, L"-l");
-    if (Lang != NULL) {
-      Language = AllocateZeroPool(StrSize(Lang));
-      AsciiSPrint(Language, StrSize(Lang), "%S", Lang);
-    } else if (!ShellCommandLineGetFlag(Package, L"-l")){
+    if (ShellCommandLineGetFlag(Package, L"-l")) {
+      Lang = ShellCommandLineGetValue(Package, L"-l");
+      if (Lang != NULL) {
+        Language = AllocateZeroPool(StrSize(Lang));
+        AsciiSPrint(Language, StrSize(Lang), "%S", Lang);
+      } else {
+        ASSERT(Language == NULL);
+        ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN(STR_GEN_NO_VALUE), gShellDriver1HiiHandle, L"dh", L"-l");
+        ShellCommandLineFreeVarList(Package);
+        return (SHELL_INVALID_PARAMETER);
+      }
+    } else {
       Language = AllocateZeroPool(10);
       AsciiSPrint(Language, 10, "en-us");
-    } else {
-      ASSERT(Language == NULL);
-      ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_VALUE), gShellDriver1HiiHandle, L"dh",  L"-l");  
-      ShellCommandLineFreeVarList (Package);
-      return (SHELL_INVALID_PARAMETER);
     }
 
-    SfoMode = ShellCommandLineGetFlag(Package, L"-sfo");
-    FlagD   = ShellCommandLineGetFlag(Package, L"-d");
-    Verbose = (BOOLEAN)(ShellCommandLineGetFlag(Package, L"-v") || ShellCommandLineGetFlag(Package, L"-verbose"));
+    SfoFlag     = ShellCommandLineGetFlag (Package, L"-sfo");
+    DriverFlag  = ShellCommandLineGetFlag (Package, L"-d");
+    VerboseFlag = (BOOLEAN)(ShellCommandLineGetFlag (Package, L"-v") || ShellCommandLineGetFlag (Package, L"-verbose"));
 
-    if (ShellCommandLineGetFlag(Package, L"-p")) {
-      if (ShellCommandLineGetCount(Package) > 1) {
-        ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDriver1HiiHandle, L"dh");  
+    if (ShellCommandLineGetFlag (Package, L"-p")) {
+      if (ShellCommandLineGetCount (Package) > 1) {
+        ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDriver1HiiHandle, L"dh");
         ShellStatus = SHELL_INVALID_PARAMETER;
       } else if (ShellCommandLineGetValue(Package, L"-p") == NULL) {
-        ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_VALUE), gShellDriver1HiiHandle, L"dh",  L"-p");  
+        ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_VALUE), gShellDriver1HiiHandle, L"dh",  L"-p");
         ShellStatus = SHELL_INVALID_PARAMETER;
       } else {
         //
@@ -931,41 +920,41 @@ ShellCommandRunDh (
         //
         ShellStatus = DoDhByProtocol(
           ShellCommandLineGetValue(Package, L"-p"),
-          Verbose,
-          SfoMode,
-          Lang==NULL?NULL:Language,
-          FlagD
-         );
+          VerboseFlag,
+          SfoFlag,
+          Language,
+          DriverFlag
+        );
       }
     } else {
-      Temp2 = ShellCommandLineGetRawValue(Package, 1);
-      if (Temp2 == NULL) {
+      RawValue = ShellCommandLineGetRawValue(Package, 1);
+      if (RawValue == NULL) {
         //
         // Print everything
         //
         ShellStatus = DoDhForAll(
-          SfoMode,
-          Verbose,
-          Lang==NULL?NULL:Language,
-          FlagD
+          SfoFlag,
+          VerboseFlag,
+          Language,
+          DriverFlag
          );
       } else {
-        Status = ShellConvertStringToUint64(Temp2, &Intermediate, TRUE, FALSE);
+        Status = ShellConvertStringToUint64(RawValue, &Intermediate, TRUE, FALSE);
         if (EFI_ERROR(Status) || ConvertHandleIndexToHandle((UINTN)Intermediate) == NULL) {
-          ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_INV_HANDLE), gShellDriver1HiiHandle, L"dh", Temp2);  
+          ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_INV_HANDLE), gShellDriver1HiiHandle, L"dh", RawValue);
           ShellStatus = SHELL_INVALID_PARAMETER;
         } else {
           //
           // print 1 handle
           //
-          ShellStatus = DoDhByHandle(
+          DoDhByHandle(
             ConvertHandleIndexToHandle((UINTN)Intermediate),
-            Verbose,
-            SfoMode,
-            Lang==NULL?NULL:Language,
-            FlagD,
+            VerboseFlag,
+            SfoFlag,
+            Language,
+            DriverFlag,
             FALSE
-           );
+          );
         }
       }
     }
-- 
2.9.0.windows.1



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

* [PATCH 5/5] ShellPkg/dh: Support dump from GUID and "decode" parameter
  2017-01-09  9:30 [PATCH 0/5] Change "dh" to support dump from GUID and "decode" parameter Ruiyu Ni
                   ` (3 preceding siblings ...)
  2017-01-09  9:30 ` [PATCH 4/5] ShellPkg/Dh: Fix coding style issues Ruiyu Ni
@ 2017-01-09  9:30 ` Ruiyu Ni
  2017-01-09 15:40 ` [PATCH 0/5] Change "dh" to support " Carsey, Jaben
  5 siblings, 0 replies; 12+ messages in thread
From: Ruiyu Ni @ 2017-01-09  9:30 UTC (permalink / raw)
  To: edk2-devel; +Cc: Jaben Carsey, Chen A Chen

To follow Shell spec 2.2, change "dh" to support dump from
protocol GUID and support "decode" parameter to dump the
GUID/name mapping.

Contributed-under: TianoCore Contribution Agreement 1.0
Cc: Jaben Carsey <jaben.carsey@intel.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Signed-off-by: Chen A Chen <chen.a.chen@intel.com>
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
---
 ShellPkg/Library/UefiShellDriver1CommandsLib/Dh.c  | 367 ++++++++++++++++-----
 .../UefiShellDriver1CommandsLib.uni                |   9 +-
 2 files changed, 292 insertions(+), 84 deletions(-)

diff --git a/ShellPkg/Library/UefiShellDriver1CommandsLib/Dh.c b/ShellPkg/Library/UefiShellDriver1CommandsLib/Dh.c
index 2773842..d17a29d 100644
--- a/ShellPkg/Library/UefiShellDriver1CommandsLib/Dh.c
+++ b/ShellPkg/Library/UefiShellDriver1CommandsLib/Dh.c
@@ -41,6 +41,137 @@ STATIC CONST EFI_GUID *UefiDriverModelProtocolsGuidArray[] = {
   NULL
 };
 
+UINTN mGuidDataLen[] = {8, 4, 4, 4, 12};
+/**
+  Function to determine if the string can convert to a GUID.
+  The string must be restricted as "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" format.
+
+  @param[in]  String  The string to test.
+
+  @retval     TRUE    The string can convert to a GUID.
+  @retval     FALSE   The string can't convert to a GUID.
+**/
+BOOLEAN
+IsValidGuidString(
+  IN CONST CHAR16 *String
+  )
+{
+  CONST CHAR16  *Walker;
+  CONST CHAR16  *PrevWalker;
+  UINTN         Index;
+
+  if (String == NULL) {
+    return FALSE;
+  }
+
+  Walker      = String;
+  PrevWalker  = String;
+  Index       = 0;
+
+  while (Walker != NULL && *Walker != CHAR_NULL) {
+    if ( (*Walker >= '0' && *Walker <= '9') ||
+         (*Walker >= 'a' && *Walker <= 'f') ||
+         (*Walker >= 'A' && *Walker <= 'F')
+       ) {
+      Walker++;
+    } else {
+      if (*Walker == L'-' && (UINTN)(Walker - PrevWalker) == mGuidDataLen[Index]) {
+        Walker++;
+        PrevWalker = Walker;
+        Index++;
+      } else {
+        return FALSE;
+      }
+    }
+  }
+
+  if ((UINTN)(Walker - PrevWalker) == mGuidDataLen[Index]) {
+    return TRUE;
+  } else {
+    return FALSE;
+  }
+}
+
+/**
+  Convert a hex-character to decimal value.
+
+  This internal function only deal with Unicode character
+  which maps to a valid hexadecimal ASII character, i.e.
+  L'0' to L'9', L'a' to L'f' or L'A' to L'F'. For other
+  Unicode character, the value returned does not make sense.
+
+  @param[in]  Char      The character to convert.
+
+  @retval               The numerical value converted.
+**/
+UINTN
+HexCharToDecimal(
+  IN CHAR16 Char
+  )
+{
+  if (Char >= '0' && Char <= '9') {
+    return Char - L'0';
+  } else if (Char >= 'a' && Char <= 'f') {
+    return Char - L'a' + 10;
+  } else {
+    return Char - L'A' + 10;
+  }
+}
+
+/**
+  Function try to convert a string to GUID format.
+
+  @param[in]    String    The string will be converted.
+  @param[out]   Guid      Save the result convert from string.
+
+  @retval EFI_SUCCESS     The string was successfully converted to a GUID.
+  @retval EFI_UNSUPPORTED The input string is not in registry format.
+**/
+EFI_STATUS
+ConvertStrToGuid(
+  IN  CONST CHAR16 *String,
+  OUT GUID *Guid
+  )
+{
+  CONST CHAR16  *Walker;
+  UINT8         TempValue;
+  UINTN         Index;
+
+  if (String == NULL || !IsValidGuidString (String)) {
+    return EFI_UNSUPPORTED;
+  }
+
+  Index = 0;
+
+  Walker = String;
+  Guid->Data1 = (UINT32)StrHexToUint64 (Walker);
+
+  Walker += 9;
+  Guid->Data2 = (UINT16)StrHexToUint64 (Walker);
+
+  Walker += 5;
+  Guid->Data3 = (UINT16)StrHexToUint64 (Walker);
+
+  Walker += 5;
+  while (Walker != NULL && *Walker != CHAR_NULL) {
+    if (*Walker == L'-') {
+      Walker++;
+    } else {
+      TempValue = (UINT8)HexCharToDecimal (*Walker);
+      TempValue = (UINT8)LShiftU64 (TempValue, 4);
+      Walker++;
+
+      TempValue += (UINT8)HexCharToDecimal (*Walker);
+      Walker++;
+
+      Guid->Data4[Index] = TempValue;
+      Index++;
+    }
+  }
+
+  return EFI_SUCCESS;
+}
+
 /**
   Get the name of a driver by it's handle.
 
@@ -733,8 +864,7 @@ DoDhForHandleList(
   SHELL_STATUS      ShellStatus;
 
   ShellStatus       = SHELL_SUCCESS;
-
-  for ( HandleWalker = HandleList; HandleWalker != NULL && *HandleWalker != NULL; HandleWalker++ ) {
+  for (HandleWalker = HandleList; HandleWalker != NULL && *HandleWalker != NULL; HandleWalker++) {
     DoDhByHandle (*HandleWalker, Verbose, Sfo, Language, DriverInfo, TRUE);
     if (ShellGetExecutionBreakFlag ()) {
       ShellStatus = SHELL_ABORTED;
@@ -745,89 +875,166 @@ DoDhForHandleList(
 }
 
 /**
-  Display information for all handles.
+  Display information for a GUID of protocol.
 
-  @param[in] Sfo              TRUE to output in standard format output (spec).
+  @param[in] Guid             The pointer to the name of the protocol.
   @param[in] Verbose          TRUE for extra info, FALSE otherwise.
+  @param[in] Sfo              TRUE to output in standard format output (spec).
   @param[in] Language         Language string per UEFI specification.
   @param[in] DriverInfo       TRUE to show all info about the handle.
 
   @retval SHELL_SUCCESS           The operation was successful.
+  @retval SHELL_NOT_FOUND         The GUID was not found.
   @retval SHELL_INVALID_PARAMETER ProtocolName was NULL or invalid.
 **/
 SHELL_STATUS
-DoDhForAll(
-  IN CONST BOOLEAN  Sfo,
+DoDhByProtocolGuid(
+  IN CONST GUID     *Guid,
   IN CONST BOOLEAN  Verbose,
+  IN CONST BOOLEAN  Sfo,
   IN CONST CHAR8    *Language,
   IN CONST BOOLEAN  DriverInfo
   )
 {
-  EFI_HANDLE    *HandleList;
+  CHAR16        *Name;
   SHELL_STATUS  ShellStatus;
+  EFI_HANDLE    *HandleList;
 
-  HandleList = GetHandleListByProtocol(NULL);
-
-  ShellStatus = DoDhForHandleList(
-    HandleList,
-    Verbose,
-    Sfo,
-    Language,
-    DriverInfo);
-
-  FreePool(HandleList);
+  if (!Sfo) {
+    if (Guid == NULL) {
+      ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DH_OUTPUT_ALL_HEADER), gShellDriver1HiiHandle);
+    } else {
+      Name = GetStringNameFromGuid (Guid, NULL);
+      if (Name == NULL) {
+        ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DH_OUTPUT_GUID_HEADER), gShellDriver1HiiHandle, Guid);
+      } else {
+        ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DH_OUTPUT_NAME_HEADER), gShellDriver1HiiHandle, Name);
+      }
+    }
+  }
+  HandleList = GetHandleListByProtocol(Guid);
+  ShellStatus = DoDhForHandleList(HandleList, Verbose, Sfo, Language, DriverInfo);
+  SHELL_FREE_NON_NULL(HandleList);
 
-  return (ShellStatus);
+  return ShellStatus;
 }
 
 /**
-  Display information for all handles which have a specific protocol.
+  Function to determine use which method to print information.
+  If Protocol is NULL, The function will print all information.
 
-  @param[in] ProtocolName     The pointer to the name of the protocol.
+  @param[in] Protocol         The pointer to the name or GUID of protocol or NULL.
   @param[in] Verbose          TRUE for extra info, FALSE otherwise.
   @param[in] Sfo              TRUE to output in standard format output (spec).
   @param[in] Language         Language string per UEFI specification.
   @param[in] DriverInfo       TRUE to show all info about the handle.
 
-  @retval SHELL_SUCCESS           The operation was successful.
-  @retval SHELL_INVALID_PARAMETER ProtocolName was NULL or invalid.
+  @retval SHELL_SUCCESS             The operation was successful.
+  @retval SHELL_NOT_FOUND           The protocol was not found.
+  @retval SHELL_INVALID_PARAMETER   Protocol is invalid parameter.
 **/
 SHELL_STATUS
-DoDhByProtocol(
-  IN CONST CHAR16   *ProtocolName,
+DoDhByProtocol (
+  IN CONST CHAR16   *Protocol,
   IN CONST BOOLEAN  Verbose,
   IN CONST BOOLEAN  Sfo,
   IN CONST CHAR8    *Language,
   IN CONST BOOLEAN  DriverInfo
   )
 {
-  EFI_GUID      *Guid;
+  EFI_GUID      Guid;
+  EFI_GUID      *GuidPtr;
   EFI_STATUS    Status;
-  EFI_HANDLE    *HandleList;
-  SHELL_STATUS  ShellStatus;
 
-  if (ProtocolName == NULL) {
-    return (SHELL_INVALID_PARAMETER);
-  }
+  if (Protocol == NULL) {
+    return DoDhByProtocolGuid (NULL, Verbose, Sfo, Language, DriverInfo);
+  } else {
+    Status = ConvertStrToGuid (Protocol, &Guid);
+    if (!EFI_ERROR (Status)) {
+      GuidPtr = &Guid;
+    } else {
+      //
+      // Protocol is a Name, convert it to GUID
+      //
+      Status = GetGuidFromStringName (Protocol, Language, &GuidPtr);
+      if (EFI_ERROR(Status)) {
+        ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DH_NO_NAME_FOUND), gShellDriver1HiiHandle, Protocol);
+        return (SHELL_NOT_FOUND);
+      }
+    }
 
-  Status = GetGuidFromStringName(ProtocolName, Language, &Guid);
-  if (EFI_ERROR(Status)) {
-    ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_DH_NO_GUID_FOUND), gShellDriver1HiiHandle, ProtocolName);
-    return (SHELL_INVALID_PARAMETER);
+    return DoDhByProtocolGuid (GuidPtr, Verbose, Sfo, Language, DriverInfo);
   }
+}
 
-  HandleList = GetHandleListByProtocol(Guid);
+/**
+  Function to display decode information by Protocol.
+  The parameter Protocol is either a GUID or the name of protocol.
+  If the parameter Protocol is NULL, the function will print all
+  decode information.
 
-  ShellStatus = DoDhForHandleList(
-    HandleList,
-    Verbose,
-    Sfo,
-    Language,
-    DriverInfo);
+  @param[in] Protocol         The pointer to the name or GUID of protocol.
+  @param[in] Language         Language string per UEFI specification.
 
-  SHELL_FREE_NON_NULL(HandleList);
+  @retval SHELL_SUCCESS           The operation was successful.
+  @retval SHELL_OUT_OT_RESOURCES  A memory allocation failed.
+**/
+SHELL_STATUS
+DoDecodeByProtocol(
+  IN CONST CHAR16 *Protocol,
+  IN CONST CHAR8  *Language
+  )
+{
+  EFI_STATUS    Status;
+  EFI_GUID      *Guids;
+  EFI_GUID      Guid;
+  UINTN         Counts;
+  UINTN         Index;
+  CHAR16        *Name;
+
+  if (Protocol == NULL) {
+    Counts = 0;
+    Status = GetAllMappingGuids (NULL, &Counts);
+    if (Status == EFI_BUFFER_TOO_SMALL) {
+      Guids = AllocatePool (Counts * sizeof(EFI_GUID));
+      if (Guids == NULL) {
+        return SHELL_OUT_OF_RESOURCES;
+      }
 
-  return (ShellStatus);
+      Status = GetAllMappingGuids (Guids, &Counts);
+      if (Status == EFI_SUCCESS) {
+        for (Index = 0; Index < Counts; Index++) {
+          Name = GetStringNameFromGuid (&Guids[Index], Language);
+          if (Name != NULL) {
+            ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DH_OUTPUT_DECODE), gShellDriver1HiiHandle, Name, &Guids[Index]);
+          } else {
+            ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DH_NO_GUID_FOUND), gShellDriver1HiiHandle, &Guids[Index]);
+          }
+          SHELL_FREE_NON_NULL (Name);
+        }
+      }
+      FreePool (Guids);
+    }
+  } else {
+    if (ConvertStrToGuid (Protocol, &Guid) == EFI_SUCCESS) {
+      Name = GetStringNameFromGuid (&Guid, Language);
+      if (Name != NULL) {
+        ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DH_OUTPUT_DECODE), gShellDriver1HiiHandle, Name, &Guid);
+      } else {
+        ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DH_NO_GUID_FOUND), gShellDriver1HiiHandle, &Guid);
+      }
+      SHELL_FREE_NON_NULL(Name);
+    } else {
+      Status = GetGuidFromStringName (Protocol, Language, &Guids);
+      if (Status == EFI_SUCCESS) {
+        ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DH_OUTPUT_DECODE), gShellDriver1HiiHandle, Protocol, Guids);
+      } else {
+        ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DH_NO_NAME_FOUND), gShellDriver1HiiHandle, Protocol);
+      }
+    }
+  }
+
+  return SHELL_SUCCESS;
 }
 
 /**
@@ -850,10 +1057,12 @@ ShellCommandRunDh (
   CHAR8               *Language;
   CONST CHAR16        *Lang;
   CONST CHAR16        *RawValue;
+  CONST CHAR16        *ProtocolVal;
   BOOLEAN             SfoFlag;
   BOOLEAN             DriverFlag;
   BOOLEAN             VerboseFlag;
   UINT64              Intermediate;
+  EFI_HANDLE          Handle;
 
   ShellStatus         = SHELL_SUCCESS;
   Status              = EFI_SUCCESS;
@@ -906,60 +1115,54 @@ ShellCommandRunDh (
     SfoFlag     = ShellCommandLineGetFlag (Package, L"-sfo");
     DriverFlag  = ShellCommandLineGetFlag (Package, L"-d");
     VerboseFlag = (BOOLEAN)(ShellCommandLineGetFlag (Package, L"-v") || ShellCommandLineGetFlag (Package, L"-verbose"));
+    RawValue    = ShellCommandLineGetRawValue (Package, 1);
+    ProtocolVal = ShellCommandLineGetValue (Package, L"-p");
 
-    if (ShellCommandLineGetFlag (Package, L"-p")) {
-      if (ShellCommandLineGetCount (Package) > 1) {
-        ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDriver1HiiHandle, L"dh");
-        ShellStatus = SHELL_INVALID_PARAMETER;
-      } else if (ShellCommandLineGetValue(Package, L"-p") == NULL) {
-        ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_VALUE), gShellDriver1HiiHandle, L"dh",  L"-p");
+    if (RawValue == NULL) {
+      if (ShellCommandLineGetFlag (Package, L"-p") && (ProtocolVal == NULL)) {
+        ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_VALUE), gShellDriver1HiiHandle, L"dh", L"-p");
         ShellStatus = SHELL_INVALID_PARAMETER;
       } else {
         //
-        // print by protocol
+        // Print information by protocol, The ProtocolVal maybe is name or GUID or NULL.
         //
-        ShellStatus = DoDhByProtocol(
-          ShellCommandLineGetValue(Package, L"-p"),
-          VerboseFlag,
-          SfoFlag,
-          Language,
-          DriverFlag
-        );
+        ShellStatus = DoDhByProtocol (ProtocolVal, VerboseFlag, SfoFlag, Language, DriverFlag);
       }
-    } else {
-      RawValue = ShellCommandLineGetRawValue(Package, 1);
-      if (RawValue == NULL) {
+    } else if ((RawValue != NULL) &&
+               (gUnicodeCollation->StriColl(gUnicodeCollation, L"decode", (CHAR16 *) RawValue) == 0)) {
+      if (ShellCommandLineGetFlag (Package, L"-p") && (ProtocolVal == NULL)) {
+        ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_VALUE), gShellDriver1HiiHandle, L"dh", L"-p");
+        ShellStatus = SHELL_INVALID_PARAMETER;
+      } else {
         //
-        // Print everything
+        // Print decode informatino by protocol.
         //
-        ShellStatus = DoDhForAll(
-          SfoFlag,
-          VerboseFlag,
-          Language,
-          DriverFlag
-         );
+        ShellStatus = DoDecodeByProtocol (ProtocolVal, Language);
+      }
+    } else {
+      if (ShellCommandLineGetFlag (Package, L"-p")) {
+        ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDriver1HiiHandle, L"dh");
+        ShellStatus = SHELL_INVALID_PARAMETER;
       } else {
-        Status = ShellConvertStringToUint64(RawValue, &Intermediate, TRUE, FALSE);
-        if (EFI_ERROR(Status) || ConvertHandleIndexToHandle((UINTN)Intermediate) == NULL) {
-          ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_INV_HANDLE), gShellDriver1HiiHandle, L"dh", RawValue);
+        Status = ShellConvertStringToUint64 (RawValue, &Intermediate, TRUE, FALSE);
+        if (EFI_ERROR(Status)) {
+          ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_INV_HANDLE), gShellDriver1HiiHandle, L"dh", RawValue);
           ShellStatus = SHELL_INVALID_PARAMETER;
         } else {
-          //
-          // print 1 handle
-          //
-          DoDhByHandle(
-            ConvertHandleIndexToHandle((UINTN)Intermediate),
-            VerboseFlag,
-            SfoFlag,
-            Language,
-            DriverFlag,
-            FALSE
-          );
+          Handle = ConvertHandleIndexToHandle ((UINTN) Intermediate);
+          if (Handle == NULL) {
+            ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_INV_HANDLE), gShellDriver1HiiHandle, L"dh", RawValue);
+            ShellStatus = SHELL_INVALID_PARAMETER;
+          } else {
+            //
+            // Print information by handle.
+            //
+            DoDhByHandle (Handle, VerboseFlag, SfoFlag, Language, DriverFlag, FALSE);
+          }
         }
       }
     }
 
-
     ShellCommandLineFreeVarList (Package);
     SHELL_FREE_NON_NULL(Language);
   }
diff --git a/ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDriver1CommandsLib.uni b/ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDriver1CommandsLib.uni
index ac520e2..52156d5 100644
--- a/ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDriver1CommandsLib.uni
+++ b/ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDriver1CommandsLib.uni
@@ -2,7 +2,7 @@
 //
 // (C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>
 // (C) Copyright 2012-2015 Hewlett-Packard Development Company, L.P.<BR>
-// Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.<BR>
+// Copyright (c) 2010 - 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
@@ -98,9 +98,14 @@
 #string STR_DRIVERS_ITEM_LINE     #language en-US "%H%3x%N %08x %1c %1c %1c %3d %3d %-35s %s\r\n"
 #string STR_DRIVERS_ITEM_LINE_SFO #language en-US "DriversInfo,"%x","%x","%c","%c","%c","%d","%d","%s","%s"\r\n"
 
-#string STR_DH_NO_GUID_FOUND      #language en-US "Protocol ID '%s' could not be identified.\r\n"
+#string STR_DH_OUTPUT_DECODE      #language en-US "%s: %g\r\n"
+#string STR_DH_NO_NAME_FOUND      #language en-US "Protocol Name '%s' could not be identified.\r\n"
+#string STR_DH_NO_GUID_FOUND      #language en-US "Protocol GUID '%g' could not be identified.\r\n"
 #string STR_DH_SFO_OUTPUT         #language en-US "%s, %s, %H%02x%N, %s, &s\r\n"
 #string STR_DH_OUTPUT             #language en-US "%H%02x%N: %s\r\n"
+#string STR_DH_OUTPUT_ALL_HEADER  #language en-US "Handle dump\r\n"
+#string STR_DH_OUTPUT_GUID_HEADER #language en-US "Handle dump by protocol '%g'\r\n"
+#string STR_DH_OUTPUT_NAME_HEADER #language en-US "Handle dump by protocol '%s'\r\n"
 #string STR_DH_OUTPUT_SINGLE      #language en-US "%H%02x%N: %x\r\n%s"
 #string STR_DH_OUTPUT_SFO         #language en-US "%s, %s, %s, %H%02x%N, %s, %s\r\n"
 #string STR_DH_OUTPUT_DRIVER1     #language en-US "   Controller Name    : %B%s%N\r\n"
-- 
2.9.0.windows.1



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

* Re: [PATCH 4/5] ShellPkg/Dh: Fix coding style issues
  2017-01-09  9:30 ` [PATCH 4/5] ShellPkg/Dh: Fix coding style issues Ruiyu Ni
@ 2017-01-09 15:36   ` Carsey, Jaben
  2017-01-10  2:24     ` Ni, Ruiyu
  0 siblings, 1 reply; 12+ messages in thread
From: Carsey, Jaben @ 2017-01-09 15:36 UTC (permalink / raw)
  To: Ni, Ruiyu, edk2-devel@lists.01.org; +Cc: Chen, Chen A, Carsey, Jaben

One question inline.

> -----Original Message-----
> From: Ni, Ruiyu
> Sent: Monday, January 9, 2017 1:31 AM
> To: edk2-devel@lists.01.org
> Cc: Chen, Chen A <chen.a.chen@intel.com>; Carsey, Jaben
> <jaben.carsey@intel.com>
> Subject: [PATCH 4/5] ShellPkg/Dh: Fix coding style issues
> Importance: High
> 
> From: Chen A Chen <chen.a.chen@intel.com>
> 
> The change doesn't impact the functionality.
> 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Cc: Jaben Carsey <jaben.carsey@intel.com>
> Cc: Ruiyu Ni <ruiyu.ni@intel.com>
> Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
> Signed-off-by: Chen A Chen <chen.a.chen@intel.com>
> ---
>  ShellPkg/Library/UefiShellDriver1CommandsLib/Dh.c | 119 ++++++++++----------
> --
>  1 file changed, 54 insertions(+), 65 deletions(-)
> 
> diff --git a/ShellPkg/Library/UefiShellDriver1CommandsLib/Dh.c
> b/ShellPkg/Library/UefiShellDriver1CommandsLib/Dh.c
> index 0ac49e1..2773842 100644
> --- a/ShellPkg/Library/UefiShellDriver1CommandsLib/Dh.c
> +++ b/ShellPkg/Library/UefiShellDriver1CommandsLib/Dh.c
> @@ -642,11 +642,8 @@ DisplayDriverModelHandle (
>    @param[in] DriverInfo       TRUE to show all info about the handle.
>    @param[in] Multiple         TRUE indicates more than  will be output,
>                                FALSE for a single one.
> -
> -  @retval SHELL_SUCCESS           The operation was successful.
> -  @retval SHELL_INVALID_PARAMETER ProtocolName was NULL or invalid.
>  **/
> -SHELL_STATUS
> +VOID

Is there a reason to change the function to VOID and not add a check for the return from the DisplayDriverModelHandle function?

>  DoDhByHandle(
>    IN CONST EFI_HANDLE TheHandle,
>    IN CONST BOOLEAN    Verbose,
> @@ -656,10 +653,8 @@ DoDhByHandle(
>    IN CONST BOOLEAN    Multiple
>    )
>  {
> -  CHAR16              *ProtocolInfoString;
> -  SHELL_STATUS        ShellStatus;
> +  CHAR16 *ProtocolInfoString;
> 
> -  ShellStatus         = SHELL_SUCCESS;
>    ProtocolInfoString  = NULL;
> 
>    if (!Sfo) {
> @@ -672,7 +667,8 @@ DoDhByHandle(
>          STRING_TOKEN (STR_DH_OUTPUT),
>          gShellDriver1HiiHandle,
>          ConvertHandleToHandleIndex(TheHandle),
> -        ProtocolInfoString==NULL?L"":ProtocolInfoString);
> +        ProtocolInfoString==NULL?L"":ProtocolInfoString
> +      );
>      } else {
>        ProtocolInfoString = GetProtocolInfoString(TheHandle, Language, L"\r\n",
> Verbose, TRUE);
>        ShellPrintHiiEx(
> @@ -683,7 +679,8 @@ DoDhByHandle(
>          gShellDriver1HiiHandle,
>          ConvertHandleToHandleIndex(TheHandle),
>          TheHandle,
> -        ProtocolInfoString==NULL?L"":ProtocolInfoString);
> +        ProtocolInfoString==NULL?L"":ProtocolInfoString
> +      );
>      }
> 
>      if (DriverInfo) {
> @@ -702,16 +699,13 @@ DoDhByHandle(
>          L"ControllerName",
>          ConvertHandleToHandleIndex(TheHandle),
>          L"DevPath",
> -        ProtocolInfoString==NULL?L"":ProtocolInfoString);
> -
> -
> +        ProtocolInfoString==NULL?L"":ProtocolInfoString
> +      );
>    }
> 
> -
>    if (ProtocolInfoString != NULL) {
>      FreePool(ProtocolInfoString);
>    }
> -  return (ShellStatus);
>  }
> 
>  /**
> @@ -723,8 +717,8 @@ DoDhByHandle(
>    @param[in] Language         Language string per UEFI specification.
>    @param[in] DriverInfo       TRUE to show all info about the handle.
> 
> -  @retval SHELL_SUCCESS           The operation was successful.
> -  @retval SHELL_INVALID_PARAMETER ProtocolName was NULL or invalid.
> +  @retval SHELL_SUCCESS       The operation was successful.
> +  @retval SHELL_ABORTED       The operation was aborted.
>  **/
>  SHELL_STATUS
>  DoDhForHandleList(
> @@ -740,15 +734,8 @@ DoDhForHandleList(
> 
>    ShellStatus       = SHELL_SUCCESS;
> 
> -  for (HandleWalker = HandleList ; HandleWalker != NULL && *HandleWalker !=
> NULL && ShellStatus == SHELL_SUCCESS; HandleWalker++) {
> -    ShellStatus = DoDhByHandle(
> -          *HandleWalker,
> -          Verbose,
> -          Sfo,
> -          Language,
> -          DriverInfo,
> -          TRUE
> -         );
> +  for ( HandleWalker = HandleList; HandleWalker != NULL && *HandleWalker !=
> NULL; HandleWalker++ ) {
> +    DoDhByHandle (*HandleWalker, Verbose, Sfo, Language, DriverInfo, TRUE);
>      if (ShellGetExecutionBreakFlag ()) {
>        ShellStatus = SHELL_ABORTED;
>        break;
> @@ -862,10 +849,10 @@ ShellCommandRunDh (
>    SHELL_STATUS        ShellStatus;
>    CHAR8               *Language;
>    CONST CHAR16        *Lang;
> -  CONST CHAR16        *Temp2;
> -  BOOLEAN             SfoMode;
> -  BOOLEAN             FlagD;
> -  BOOLEAN             Verbose;
> +  CONST CHAR16        *RawValue;
> +  BOOLEAN             SfoFlag;
> +  BOOLEAN             DriverFlag;
> +  BOOLEAN             VerboseFlag;
>    UINT64              Intermediate;
> 
>    ShellStatus         = SHELL_SUCCESS;
> @@ -900,30 +887,32 @@ ShellCommandRunDh (
>        return (SHELL_INVALID_PARAMETER);
>      }
> 
> -    Lang = ShellCommandLineGetValue(Package, L"-l");
> -    if (Lang != NULL) {
> -      Language = AllocateZeroPool(StrSize(Lang));
> -      AsciiSPrint(Language, StrSize(Lang), "%S", Lang);
> -    } else if (!ShellCommandLineGetFlag(Package, L"-l")){
> +    if (ShellCommandLineGetFlag(Package, L"-l")) {
> +      Lang = ShellCommandLineGetValue(Package, L"-l");
> +      if (Lang != NULL) {
> +        Language = AllocateZeroPool(StrSize(Lang));
> +        AsciiSPrint(Language, StrSize(Lang), "%S", Lang);
> +      } else {
> +        ASSERT(Language == NULL);
> +        ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN(STR_GEN_NO_VALUE),
> gShellDriver1HiiHandle, L"dh", L"-l");
> +        ShellCommandLineFreeVarList(Package);
> +        return (SHELL_INVALID_PARAMETER);
> +      }
> +    } else {
>        Language = AllocateZeroPool(10);
>        AsciiSPrint(Language, 10, "en-us");
> -    } else {
> -      ASSERT(Language == NULL);
> -      ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_VALUE),
> gShellDriver1HiiHandle, L"dh",  L"-l");
> -      ShellCommandLineFreeVarList (Package);
> -      return (SHELL_INVALID_PARAMETER);
>      }
> 
> -    SfoMode = ShellCommandLineGetFlag(Package, L"-sfo");
> -    FlagD   = ShellCommandLineGetFlag(Package, L"-d");
> -    Verbose = (BOOLEAN)(ShellCommandLineGetFlag(Package, L"-v") ||
> ShellCommandLineGetFlag(Package, L"-verbose"));
> +    SfoFlag     = ShellCommandLineGetFlag (Package, L"-sfo");
> +    DriverFlag  = ShellCommandLineGetFlag (Package, L"-d");
> +    VerboseFlag = (BOOLEAN)(ShellCommandLineGetFlag (Package, L"-v") ||
> ShellCommandLineGetFlag (Package, L"-verbose"));
> 
> -    if (ShellCommandLineGetFlag(Package, L"-p")) {
> -      if (ShellCommandLineGetCount(Package) > 1) {
> -        ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY),
> gShellDriver1HiiHandle, L"dh");
> +    if (ShellCommandLineGetFlag (Package, L"-p")) {
> +      if (ShellCommandLineGetCount (Package) > 1) {
> +        ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY),
> gShellDriver1HiiHandle, L"dh");
>          ShellStatus = SHELL_INVALID_PARAMETER;
>        } else if (ShellCommandLineGetValue(Package, L"-p") == NULL) {
> -        ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_VALUE),
> gShellDriver1HiiHandle, L"dh",  L"-p");
> +        ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_VALUE),
> gShellDriver1HiiHandle, L"dh",  L"-p");
>          ShellStatus = SHELL_INVALID_PARAMETER;
>        } else {
>          //
> @@ -931,41 +920,41 @@ ShellCommandRunDh (
>          //
>          ShellStatus = DoDhByProtocol(
>            ShellCommandLineGetValue(Package, L"-p"),
> -          Verbose,
> -          SfoMode,
> -          Lang==NULL?NULL:Language,
> -          FlagD
> -         );
> +          VerboseFlag,
> +          SfoFlag,
> +          Language,
> +          DriverFlag
> +        );
>        }
>      } else {
> -      Temp2 = ShellCommandLineGetRawValue(Package, 1);
> -      if (Temp2 == NULL) {
> +      RawValue = ShellCommandLineGetRawValue(Package, 1);
> +      if (RawValue == NULL) {
>          //
>          // Print everything
>          //
>          ShellStatus = DoDhForAll(
> -          SfoMode,
> -          Verbose,
> -          Lang==NULL?NULL:Language,
> -          FlagD
> +          SfoFlag,
> +          VerboseFlag,
> +          Language,
> +          DriverFlag
>           );
>        } else {
> -        Status = ShellConvertStringToUint64(Temp2, &Intermediate, TRUE, FALSE);
> +        Status = ShellConvertStringToUint64(RawValue, &Intermediate, TRUE,
> FALSE);
>          if (EFI_ERROR(Status) ||
> ConvertHandleIndexToHandle((UINTN)Intermediate) == NULL) {
> -          ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_INV_HANDLE),
> gShellDriver1HiiHandle, L"dh", Temp2);
> +          ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_INV_HANDLE),
> gShellDriver1HiiHandle, L"dh", RawValue);
>            ShellStatus = SHELL_INVALID_PARAMETER;
>          } else {
>            //
>            // print 1 handle
>            //
> -          ShellStatus = DoDhByHandle(
> +          DoDhByHandle(
>              ConvertHandleIndexToHandle((UINTN)Intermediate),
> -            Verbose,
> -            SfoMode,
> -            Lang==NULL?NULL:Language,
> -            FlagD,
> +            VerboseFlag,
> +            SfoFlag,
> +            Language,
> +            DriverFlag,
>              FALSE
> -           );
> +          );
>          }
>        }
>      }
> --
> 2.9.0.windows.1



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

* Re: [PATCH 0/5] Change "dh" to support dump from GUID and "decode" parameter
  2017-01-09  9:30 [PATCH 0/5] Change "dh" to support dump from GUID and "decode" parameter Ruiyu Ni
                   ` (4 preceding siblings ...)
  2017-01-09  9:30 ` [PATCH 5/5] ShellPkg/dh: Support dump from GUID and "decode" parameter Ruiyu Ni
@ 2017-01-09 15:40 ` Carsey, Jaben
  2017-01-10  2:23   ` Ni, Ruiyu
  5 siblings, 1 reply; 12+ messages in thread
From: Carsey, Jaben @ 2017-01-09 15:40 UTC (permalink / raw)
  To: Ni, Ruiyu, edk2-devel@lists.01.org, Kinney, Michael D; +Cc: Carsey, Jaben

Looks good.

Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>

I had one inline question.

I would also propose that the String to GUID conversion be placed in a shared library.  Maybe even baselib with the other string functions? 

Mike, do you have any thoughts on StringToGuid conversion?

> -----Original Message-----
> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Ruiyu
> Ni
> Sent: Monday, January 9, 2017 1:31 AM
> To: edk2-devel@lists.01.org
> Subject: [edk2] [PATCH 0/5] Change "dh" to support dump from GUID and
> "decode" parameter
> Importance: High
> 
> Change "dh" to support dump from GUID and "decode" parameter
> 
> Chen A Chen (2):
>   ShellPkg/HandleParsingLib: Add new API GetAllMappingGuids
>   ShellPkg/Dh: Fix coding style issues
> 
> Ruiyu Ni (3):
>   ShellPkg/HandleParsingLib: Rename global variables
>   ShellPkg/HandleParsingLib: Return NULL name for unknown GUID
>   ShellPkg/dh: Support dump from GUID and "decode" parameter
> 
>  ShellPkg/Include/Library/HandleParsingLib.h        |  21 +-
>  .../UefiHandleParsingLib/UefiHandleParsingLib.c    | 130 ++++--
>  .../UefiHandleParsingLib/UefiHandleParsingLib.uni  |   4 +-
>  ShellPkg/Library/UefiShellDriver1CommandsLib/Dh.c  | 458 +++++++++++++++--
> ----
>  .../UefiShellDriver1CommandsLib.uni                |   9 +-
>  5 files changed, 446 insertions(+), 176 deletions(-)
> 
> --
> 2.9.0.windows.1
> 
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel


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

* Re: [PATCH 0/5] Change "dh" to support dump from GUID and "decode" parameter
  2017-01-09 15:40 ` [PATCH 0/5] Change "dh" to support " Carsey, Jaben
@ 2017-01-10  2:23   ` Ni, Ruiyu
  2017-01-10 21:43     ` Carsey, Jaben
  0 siblings, 1 reply; 12+ messages in thread
From: Ni, Ruiyu @ 2017-01-10  2:23 UTC (permalink / raw)
  To: Carsey, Jaben, edk2-devel@lists.01.org, Kinney, Michael D; +Cc: Wu, Hao A

Jaben,
Yes we will add the API to convert string to GUID. After the library API is added, the local implementation will be removed.

Thanks/Ray

> -----Original Message-----
> From: Carsey, Jaben
> Sent: Monday, January 9, 2017 11:41 PM
> To: Ni, Ruiyu <ruiyu.ni@intel.com>; edk2-devel@lists.01.org; Kinney, Michael
> D <michael.d.kinney@intel.com>
> Cc: Carsey, Jaben <jaben.carsey@intel.com>
> Subject: RE: [edk2] [PATCH 0/5] Change "dh" to support dump from GUID
> and "decode" parameter
> 
> Looks good.
> 
> Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
> 
> I had one inline question.
> 
> I would also propose that the String to GUID conversion be placed in a shared
> library.  Maybe even baselib with the other string functions?
> 
> Mike, do you have any thoughts on StringToGuid conversion?
> 
> > -----Original Message-----
> > From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of
> > Ruiyu Ni
> > Sent: Monday, January 9, 2017 1:31 AM
> > To: edk2-devel@lists.01.org
> > Subject: [edk2] [PATCH 0/5] Change "dh" to support dump from GUID and
> > "decode" parameter
> > Importance: High
> >
> > Change "dh" to support dump from GUID and "decode" parameter
> >
> > Chen A Chen (2):
> >   ShellPkg/HandleParsingLib: Add new API GetAllMappingGuids
> >   ShellPkg/Dh: Fix coding style issues
> >
> > Ruiyu Ni (3):
> >   ShellPkg/HandleParsingLib: Rename global variables
> >   ShellPkg/HandleParsingLib: Return NULL name for unknown GUID
> >   ShellPkg/dh: Support dump from GUID and "decode" parameter
> >
> >  ShellPkg/Include/Library/HandleParsingLib.h        |  21 +-
> >  .../UefiHandleParsingLib/UefiHandleParsingLib.c    | 130 ++++--
> >  .../UefiHandleParsingLib/UefiHandleParsingLib.uni  |   4 +-
> >  ShellPkg/Library/UefiShellDriver1CommandsLib/Dh.c  | 458
> > +++++++++++++++--
> > ----
> >  .../UefiShellDriver1CommandsLib.uni                |   9 +-
> >  5 files changed, 446 insertions(+), 176 deletions(-)
> >
> > --
> > 2.9.0.windows.1
> >
> > _______________________________________________
> > edk2-devel mailing list
> > edk2-devel@lists.01.org
> > https://lists.01.org/mailman/listinfo/edk2-devel


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

* Re: [PATCH 4/5] ShellPkg/Dh: Fix coding style issues
  2017-01-09 15:36   ` Carsey, Jaben
@ 2017-01-10  2:24     ` Ni, Ruiyu
  2017-01-10 16:20       ` Carsey, Jaben
  0 siblings, 1 reply; 12+ messages in thread
From: Ni, Ruiyu @ 2017-01-10  2:24 UTC (permalink / raw)
  To: Carsey, Jaben, edk2-devel@lists.01.org; +Cc: Chen, Chen A

DisplayDriverModelHandle() always return SUCCESS so we change the return type to VOID.

Thanks/Ray

> -----Original Message-----
> From: Carsey, Jaben
> Sent: Monday, January 9, 2017 11:37 PM
> To: Ni, Ruiyu <ruiyu.ni@intel.com>; edk2-devel@lists.01.org
> Cc: Chen, Chen A <chen.a.chen@intel.com>; Carsey, Jaben
> <jaben.carsey@intel.com>
> Subject: RE: [PATCH 4/5] ShellPkg/Dh: Fix coding style issues
> 
> One question inline.
> 
> > -----Original Message-----
> > From: Ni, Ruiyu
> > Sent: Monday, January 9, 2017 1:31 AM
> > To: edk2-devel@lists.01.org
> > Cc: Chen, Chen A <chen.a.chen@intel.com>; Carsey, Jaben
> > <jaben.carsey@intel.com>
> > Subject: [PATCH 4/5] ShellPkg/Dh: Fix coding style issues
> > Importance: High
> >
> > From: Chen A Chen <chen.a.chen@intel.com>
> >
> > The change doesn't impact the functionality.
> >
> > Contributed-under: TianoCore Contribution Agreement 1.0
> > Cc: Jaben Carsey <jaben.carsey@intel.com>
> > Cc: Ruiyu Ni <ruiyu.ni@intel.com>
> > Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
> > Signed-off-by: Chen A Chen <chen.a.chen@intel.com>
> > ---
> >  ShellPkg/Library/UefiShellDriver1CommandsLib/Dh.c | 119
> > ++++++++++----------
> > --
> >  1 file changed, 54 insertions(+), 65 deletions(-)
> >
> > diff --git a/ShellPkg/Library/UefiShellDriver1CommandsLib/Dh.c
> > b/ShellPkg/Library/UefiShellDriver1CommandsLib/Dh.c
> > index 0ac49e1..2773842 100644
> > --- a/ShellPkg/Library/UefiShellDriver1CommandsLib/Dh.c
> > +++ b/ShellPkg/Library/UefiShellDriver1CommandsLib/Dh.c
> > @@ -642,11 +642,8 @@ DisplayDriverModelHandle (
> >    @param[in] DriverInfo       TRUE to show all info about the handle.
> >    @param[in] Multiple         TRUE indicates more than  will be output,
> >                                FALSE for a single one.
> > -
> > -  @retval SHELL_SUCCESS           The operation was successful.
> > -  @retval SHELL_INVALID_PARAMETER ProtocolName was NULL or invalid.
> >  **/
> > -SHELL_STATUS
> > +VOID
> 
> Is there a reason to change the function to VOID and not add a check for the
> return from the DisplayDriverModelHandle function?
> 
> >  DoDhByHandle(
> >    IN CONST EFI_HANDLE TheHandle,
> >    IN CONST BOOLEAN    Verbose,
> > @@ -656,10 +653,8 @@ DoDhByHandle(
> >    IN CONST BOOLEAN    Multiple
> >    )
> >  {
> > -  CHAR16              *ProtocolInfoString;
> > -  SHELL_STATUS        ShellStatus;
> > +  CHAR16 *ProtocolInfoString;
> >
> > -  ShellStatus         = SHELL_SUCCESS;
> >    ProtocolInfoString  = NULL;
> >
> >    if (!Sfo) {
> > @@ -672,7 +667,8 @@ DoDhByHandle(
> >          STRING_TOKEN (STR_DH_OUTPUT),
> >          gShellDriver1HiiHandle,
> >          ConvertHandleToHandleIndex(TheHandle),
> > -        ProtocolInfoString==NULL?L"":ProtocolInfoString);
> > +        ProtocolInfoString==NULL?L"":ProtocolInfoString
> > +      );
> >      } else {
> >        ProtocolInfoString = GetProtocolInfoString(TheHandle, Language,
> > L"\r\n", Verbose, TRUE);
> >        ShellPrintHiiEx(
> > @@ -683,7 +679,8 @@ DoDhByHandle(
> >          gShellDriver1HiiHandle,
> >          ConvertHandleToHandleIndex(TheHandle),
> >          TheHandle,
> > -        ProtocolInfoString==NULL?L"":ProtocolInfoString);
> > +        ProtocolInfoString==NULL?L"":ProtocolInfoString
> > +      );
> >      }
> >
> >      if (DriverInfo) {
> > @@ -702,16 +699,13 @@ DoDhByHandle(
> >          L"ControllerName",
> >          ConvertHandleToHandleIndex(TheHandle),
> >          L"DevPath",
> > -        ProtocolInfoString==NULL?L"":ProtocolInfoString);
> > -
> > -
> > +        ProtocolInfoString==NULL?L"":ProtocolInfoString
> > +      );
> >    }
> >
> > -
> >    if (ProtocolInfoString != NULL) {
> >      FreePool(ProtocolInfoString);
> >    }
> > -  return (ShellStatus);
> >  }
> >
> >  /**
> > @@ -723,8 +717,8 @@ DoDhByHandle(
> >    @param[in] Language         Language string per UEFI specification.
> >    @param[in] DriverInfo       TRUE to show all info about the handle.
> >
> > -  @retval SHELL_SUCCESS           The operation was successful.
> > -  @retval SHELL_INVALID_PARAMETER ProtocolName was NULL or invalid.
> > +  @retval SHELL_SUCCESS       The operation was successful.
> > +  @retval SHELL_ABORTED       The operation was aborted.
> >  **/
> >  SHELL_STATUS
> >  DoDhForHandleList(
> > @@ -740,15 +734,8 @@ DoDhForHandleList(
> >
> >    ShellStatus       = SHELL_SUCCESS;
> >
> > -  for (HandleWalker = HandleList ; HandleWalker != NULL &&
> > *HandleWalker != NULL && ShellStatus == SHELL_SUCCESS;
> HandleWalker++) {
> > -    ShellStatus = DoDhByHandle(
> > -          *HandleWalker,
> > -          Verbose,
> > -          Sfo,
> > -          Language,
> > -          DriverInfo,
> > -          TRUE
> > -         );
> > +  for ( HandleWalker = HandleList; HandleWalker != NULL &&
> > + *HandleWalker !=
> > NULL; HandleWalker++ ) {
> > +    DoDhByHandle (*HandleWalker, Verbose, Sfo, Language, DriverInfo,
> > + TRUE);
> >      if (ShellGetExecutionBreakFlag ()) {
> >        ShellStatus = SHELL_ABORTED;
> >        break;
> > @@ -862,10 +849,10 @@ ShellCommandRunDh (
> >    SHELL_STATUS        ShellStatus;
> >    CHAR8               *Language;
> >    CONST CHAR16        *Lang;
> > -  CONST CHAR16        *Temp2;
> > -  BOOLEAN             SfoMode;
> > -  BOOLEAN             FlagD;
> > -  BOOLEAN             Verbose;
> > +  CONST CHAR16        *RawValue;
> > +  BOOLEAN             SfoFlag;
> > +  BOOLEAN             DriverFlag;
> > +  BOOLEAN             VerboseFlag;
> >    UINT64              Intermediate;
> >
> >    ShellStatus         = SHELL_SUCCESS;
> > @@ -900,30 +887,32 @@ ShellCommandRunDh (
> >        return (SHELL_INVALID_PARAMETER);
> >      }
> >
> > -    Lang = ShellCommandLineGetValue(Package, L"-l");
> > -    if (Lang != NULL) {
> > -      Language = AllocateZeroPool(StrSize(Lang));
> > -      AsciiSPrint(Language, StrSize(Lang), "%S", Lang);
> > -    } else if (!ShellCommandLineGetFlag(Package, L"-l")){
> > +    if (ShellCommandLineGetFlag(Package, L"-l")) {
> > +      Lang = ShellCommandLineGetValue(Package, L"-l");
> > +      if (Lang != NULL) {
> > +        Language = AllocateZeroPool(StrSize(Lang));
> > +        AsciiSPrint(Language, StrSize(Lang), "%S", Lang);
> > +      } else {
> > +        ASSERT(Language == NULL);
> > +        ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN(STR_GEN_NO_VALUE),
> > gShellDriver1HiiHandle, L"dh", L"-l");
> > +        ShellCommandLineFreeVarList(Package);
> > +        return (SHELL_INVALID_PARAMETER);
> > +      }
> > +    } else {
> >        Language = AllocateZeroPool(10);
> >        AsciiSPrint(Language, 10, "en-us");
> > -    } else {
> > -      ASSERT(Language == NULL);
> > -      ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_VALUE),
> > gShellDriver1HiiHandle, L"dh",  L"-l");
> > -      ShellCommandLineFreeVarList (Package);
> > -      return (SHELL_INVALID_PARAMETER);
> >      }
> >
> > -    SfoMode = ShellCommandLineGetFlag(Package, L"-sfo");
> > -    FlagD   = ShellCommandLineGetFlag(Package, L"-d");
> > -    Verbose = (BOOLEAN)(ShellCommandLineGetFlag(Package, L"-v") ||
> > ShellCommandLineGetFlag(Package, L"-verbose"));
> > +    SfoFlag     = ShellCommandLineGetFlag (Package, L"-sfo");
> > +    DriverFlag  = ShellCommandLineGetFlag (Package, L"-d");
> > +    VerboseFlag = (BOOLEAN)(ShellCommandLineGetFlag (Package, L"-v")
> > + ||
> > ShellCommandLineGetFlag (Package, L"-verbose"));
> >
> > -    if (ShellCommandLineGetFlag(Package, L"-p")) {
> > -      if (ShellCommandLineGetCount(Package) > 1) {
> > -        ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY),
> > gShellDriver1HiiHandle, L"dh");
> > +    if (ShellCommandLineGetFlag (Package, L"-p")) {
> > +      if (ShellCommandLineGetCount (Package) > 1) {
> > +        ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN
> > + (STR_GEN_TOO_MANY),
> > gShellDriver1HiiHandle, L"dh");
> >          ShellStatus = SHELL_INVALID_PARAMETER;
> >        } else if (ShellCommandLineGetValue(Package, L"-p") == NULL) {
> > -        ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_VALUE),
> > gShellDriver1HiiHandle, L"dh",  L"-p");
> > +        ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN
> > + (STR_GEN_NO_VALUE),
> > gShellDriver1HiiHandle, L"dh",  L"-p");
> >          ShellStatus = SHELL_INVALID_PARAMETER;
> >        } else {
> >          //
> > @@ -931,41 +920,41 @@ ShellCommandRunDh (
> >          //
> >          ShellStatus = DoDhByProtocol(
> >            ShellCommandLineGetValue(Package, L"-p"),
> > -          Verbose,
> > -          SfoMode,
> > -          Lang==NULL?NULL:Language,
> > -          FlagD
> > -         );
> > +          VerboseFlag,
> > +          SfoFlag,
> > +          Language,
> > +          DriverFlag
> > +        );
> >        }
> >      } else {
> > -      Temp2 = ShellCommandLineGetRawValue(Package, 1);
> > -      if (Temp2 == NULL) {
> > +      RawValue = ShellCommandLineGetRawValue(Package, 1);
> > +      if (RawValue == NULL) {
> >          //
> >          // Print everything
> >          //
> >          ShellStatus = DoDhForAll(
> > -          SfoMode,
> > -          Verbose,
> > -          Lang==NULL?NULL:Language,
> > -          FlagD
> > +          SfoFlag,
> > +          VerboseFlag,
> > +          Language,
> > +          DriverFlag
> >           );
> >        } else {
> > -        Status = ShellConvertStringToUint64(Temp2, &Intermediate, TRUE,
> FALSE);
> > +        Status = ShellConvertStringToUint64(RawValue, &Intermediate,
> > + TRUE,
> > FALSE);
> >          if (EFI_ERROR(Status) ||
> > ConvertHandleIndexToHandle((UINTN)Intermediate) == NULL) {
> > -          ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_INV_HANDLE),
> > gShellDriver1HiiHandle, L"dh", Temp2);
> > +          ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN
> > + (STR_GEN_INV_HANDLE),
> > gShellDriver1HiiHandle, L"dh", RawValue);
> >            ShellStatus = SHELL_INVALID_PARAMETER;
> >          } else {
> >            //
> >            // print 1 handle
> >            //
> > -          ShellStatus = DoDhByHandle(
> > +          DoDhByHandle(
> >              ConvertHandleIndexToHandle((UINTN)Intermediate),
> > -            Verbose,
> > -            SfoMode,
> > -            Lang==NULL?NULL:Language,
> > -            FlagD,
> > +            VerboseFlag,
> > +            SfoFlag,
> > +            Language,
> > +            DriverFlag,
> >              FALSE
> > -           );
> > +          );
> >          }
> >        }
> >      }
> > --
> > 2.9.0.windows.1



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

* Re: [PATCH 4/5] ShellPkg/Dh: Fix coding style issues
  2017-01-10  2:24     ` Ni, Ruiyu
@ 2017-01-10 16:20       ` Carsey, Jaben
  0 siblings, 0 replies; 12+ messages in thread
From: Carsey, Jaben @ 2017-01-10 16:20 UTC (permalink / raw)
  To: Ni, Ruiyu, edk2-devel@lists.01.org; +Cc: Chen, Chen A, Carsey, Jaben

Oh.

Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>

> -----Original Message-----
> From: Ni, Ruiyu
> Sent: Monday, January 09, 2017 6:25 PM
> To: Carsey, Jaben <jaben.carsey@intel.com>; edk2-devel@lists.01.org
> Cc: Chen, Chen A <chen.a.chen@intel.com>
> Subject: RE: [PATCH 4/5] ShellPkg/Dh: Fix coding style issues
> Importance: High
> 
> DisplayDriverModelHandle() always return SUCCESS so we change the return
> type to VOID.
> 
> Thanks/Ray
> 
> > -----Original Message-----
> > From: Carsey, Jaben
> > Sent: Monday, January 9, 2017 11:37 PM
> > To: Ni, Ruiyu <ruiyu.ni@intel.com>; edk2-devel@lists.01.org
> > Cc: Chen, Chen A <chen.a.chen@intel.com>; Carsey, Jaben
> > <jaben.carsey@intel.com>
> > Subject: RE: [PATCH 4/5] ShellPkg/Dh: Fix coding style issues
> >
> > One question inline.
> >
> > > -----Original Message-----
> > > From: Ni, Ruiyu
> > > Sent: Monday, January 9, 2017 1:31 AM
> > > To: edk2-devel@lists.01.org
> > > Cc: Chen, Chen A <chen.a.chen@intel.com>; Carsey, Jaben
> > > <jaben.carsey@intel.com>
> > > Subject: [PATCH 4/5] ShellPkg/Dh: Fix coding style issues
> > > Importance: High
> > >
> > > From: Chen A Chen <chen.a.chen@intel.com>
> > >
> > > The change doesn't impact the functionality.
> > >
> > > Contributed-under: TianoCore Contribution Agreement 1.0
> > > Cc: Jaben Carsey <jaben.carsey@intel.com>
> > > Cc: Ruiyu Ni <ruiyu.ni@intel.com>
> > > Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
> > > Signed-off-by: Chen A Chen <chen.a.chen@intel.com>
> > > ---
> > >  ShellPkg/Library/UefiShellDriver1CommandsLib/Dh.c | 119
> > > ++++++++++----------
> > > --
> > >  1 file changed, 54 insertions(+), 65 deletions(-)
> > >
> > > diff --git a/ShellPkg/Library/UefiShellDriver1CommandsLib/Dh.c
> > > b/ShellPkg/Library/UefiShellDriver1CommandsLib/Dh.c
> > > index 0ac49e1..2773842 100644
> > > --- a/ShellPkg/Library/UefiShellDriver1CommandsLib/Dh.c
> > > +++ b/ShellPkg/Library/UefiShellDriver1CommandsLib/Dh.c
> > > @@ -642,11 +642,8 @@ DisplayDriverModelHandle (
> > >    @param[in] DriverInfo       TRUE to show all info about the handle.
> > >    @param[in] Multiple         TRUE indicates more than  will be output,
> > >                                FALSE for a single one.
> > > -
> > > -  @retval SHELL_SUCCESS           The operation was successful.
> > > -  @retval SHELL_INVALID_PARAMETER ProtocolName was NULL or
> invalid.
> > >  **/
> > > -SHELL_STATUS
> > > +VOID
> >
> > Is there a reason to change the function to VOID and not add a check for
> the
> > return from the DisplayDriverModelHandle function?
> >
> > >  DoDhByHandle(
> > >    IN CONST EFI_HANDLE TheHandle,
> > >    IN CONST BOOLEAN    Verbose,
> > > @@ -656,10 +653,8 @@ DoDhByHandle(
> > >    IN CONST BOOLEAN    Multiple
> > >    )
> > >  {
> > > -  CHAR16              *ProtocolInfoString;
> > > -  SHELL_STATUS        ShellStatus;
> > > +  CHAR16 *ProtocolInfoString;
> > >
> > > -  ShellStatus         = SHELL_SUCCESS;
> > >    ProtocolInfoString  = NULL;
> > >
> > >    if (!Sfo) {
> > > @@ -672,7 +667,8 @@ DoDhByHandle(
> > >          STRING_TOKEN (STR_DH_OUTPUT),
> > >          gShellDriver1HiiHandle,
> > >          ConvertHandleToHandleIndex(TheHandle),
> > > -        ProtocolInfoString==NULL?L"":ProtocolInfoString);
> > > +        ProtocolInfoString==NULL?L"":ProtocolInfoString
> > > +      );
> > >      } else {
> > >        ProtocolInfoString = GetProtocolInfoString(TheHandle, Language,
> > > L"\r\n", Verbose, TRUE);
> > >        ShellPrintHiiEx(
> > > @@ -683,7 +679,8 @@ DoDhByHandle(
> > >          gShellDriver1HiiHandle,
> > >          ConvertHandleToHandleIndex(TheHandle),
> > >          TheHandle,
> > > -        ProtocolInfoString==NULL?L"":ProtocolInfoString);
> > > +        ProtocolInfoString==NULL?L"":ProtocolInfoString
> > > +      );
> > >      }
> > >
> > >      if (DriverInfo) {
> > > @@ -702,16 +699,13 @@ DoDhByHandle(
> > >          L"ControllerName",
> > >          ConvertHandleToHandleIndex(TheHandle),
> > >          L"DevPath",
> > > -        ProtocolInfoString==NULL?L"":ProtocolInfoString);
> > > -
> > > -
> > > +        ProtocolInfoString==NULL?L"":ProtocolInfoString
> > > +      );
> > >    }
> > >
> > > -
> > >    if (ProtocolInfoString != NULL) {
> > >      FreePool(ProtocolInfoString);
> > >    }
> > > -  return (ShellStatus);
> > >  }
> > >
> > >  /**
> > > @@ -723,8 +717,8 @@ DoDhByHandle(
> > >    @param[in] Language         Language string per UEFI specification.
> > >    @param[in] DriverInfo       TRUE to show all info about the handle.
> > >
> > > -  @retval SHELL_SUCCESS           The operation was successful.
> > > -  @retval SHELL_INVALID_PARAMETER ProtocolName was NULL or
> invalid.
> > > +  @retval SHELL_SUCCESS       The operation was successful.
> > > +  @retval SHELL_ABORTED       The operation was aborted.
> > >  **/
> > >  SHELL_STATUS
> > >  DoDhForHandleList(
> > > @@ -740,15 +734,8 @@ DoDhForHandleList(
> > >
> > >    ShellStatus       = SHELL_SUCCESS;
> > >
> > > -  for (HandleWalker = HandleList ; HandleWalker != NULL &&
> > > *HandleWalker != NULL && ShellStatus == SHELL_SUCCESS;
> > HandleWalker++) {
> > > -    ShellStatus = DoDhByHandle(
> > > -          *HandleWalker,
> > > -          Verbose,
> > > -          Sfo,
> > > -          Language,
> > > -          DriverInfo,
> > > -          TRUE
> > > -         );
> > > +  for ( HandleWalker = HandleList; HandleWalker != NULL &&
> > > + *HandleWalker !=
> > > NULL; HandleWalker++ ) {
> > > +    DoDhByHandle (*HandleWalker, Verbose, Sfo, Language, DriverInfo,
> > > + TRUE);
> > >      if (ShellGetExecutionBreakFlag ()) {
> > >        ShellStatus = SHELL_ABORTED;
> > >        break;
> > > @@ -862,10 +849,10 @@ ShellCommandRunDh (
> > >    SHELL_STATUS        ShellStatus;
> > >    CHAR8               *Language;
> > >    CONST CHAR16        *Lang;
> > > -  CONST CHAR16        *Temp2;
> > > -  BOOLEAN             SfoMode;
> > > -  BOOLEAN             FlagD;
> > > -  BOOLEAN             Verbose;
> > > +  CONST CHAR16        *RawValue;
> > > +  BOOLEAN             SfoFlag;
> > > +  BOOLEAN             DriverFlag;
> > > +  BOOLEAN             VerboseFlag;
> > >    UINT64              Intermediate;
> > >
> > >    ShellStatus         = SHELL_SUCCESS;
> > > @@ -900,30 +887,32 @@ ShellCommandRunDh (
> > >        return (SHELL_INVALID_PARAMETER);
> > >      }
> > >
> > > -    Lang = ShellCommandLineGetValue(Package, L"-l");
> > > -    if (Lang != NULL) {
> > > -      Language = AllocateZeroPool(StrSize(Lang));
> > > -      AsciiSPrint(Language, StrSize(Lang), "%S", Lang);
> > > -    } else if (!ShellCommandLineGetFlag(Package, L"-l")){
> > > +    if (ShellCommandLineGetFlag(Package, L"-l")) {
> > > +      Lang = ShellCommandLineGetValue(Package, L"-l");
> > > +      if (Lang != NULL) {
> > > +        Language = AllocateZeroPool(StrSize(Lang));
> > > +        AsciiSPrint(Language, StrSize(Lang), "%S", Lang);
> > > +      } else {
> > > +        ASSERT(Language == NULL);
> > > +        ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN(STR_GEN_NO_VALUE),
> > > gShellDriver1HiiHandle, L"dh", L"-l");
> > > +        ShellCommandLineFreeVarList(Package);
> > > +        return (SHELL_INVALID_PARAMETER);
> > > +      }
> > > +    } else {
> > >        Language = AllocateZeroPool(10);
> > >        AsciiSPrint(Language, 10, "en-us");
> > > -    } else {
> > > -      ASSERT(Language == NULL);
> > > -      ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_VALUE),
> > > gShellDriver1HiiHandle, L"dh",  L"-l");
> > > -      ShellCommandLineFreeVarList (Package);
> > > -      return (SHELL_INVALID_PARAMETER);
> > >      }
> > >
> > > -    SfoMode = ShellCommandLineGetFlag(Package, L"-sfo");
> > > -    FlagD   = ShellCommandLineGetFlag(Package, L"-d");
> > > -    Verbose = (BOOLEAN)(ShellCommandLineGetFlag(Package, L"-v") ||
> > > ShellCommandLineGetFlag(Package, L"-verbose"));
> > > +    SfoFlag     = ShellCommandLineGetFlag (Package, L"-sfo");
> > > +    DriverFlag  = ShellCommandLineGetFlag (Package, L"-d");
> > > +    VerboseFlag = (BOOLEAN)(ShellCommandLineGetFlag (Package, L"-
> v")
> > > + ||
> > > ShellCommandLineGetFlag (Package, L"-verbose"));
> > >
> > > -    if (ShellCommandLineGetFlag(Package, L"-p")) {
> > > -      if (ShellCommandLineGetCount(Package) > 1) {
> > > -        ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN
> (STR_GEN_TOO_MANY),
> > > gShellDriver1HiiHandle, L"dh");
> > > +    if (ShellCommandLineGetFlag (Package, L"-p")) {
> > > +      if (ShellCommandLineGetCount (Package) > 1) {
> > > +        ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN
> > > + (STR_GEN_TOO_MANY),
> > > gShellDriver1HiiHandle, L"dh");
> > >          ShellStatus = SHELL_INVALID_PARAMETER;
> > >        } else if (ShellCommandLineGetValue(Package, L"-p") == NULL) {
> > > -        ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_VALUE),
> > > gShellDriver1HiiHandle, L"dh",  L"-p");
> > > +        ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN
> > > + (STR_GEN_NO_VALUE),
> > > gShellDriver1HiiHandle, L"dh",  L"-p");
> > >          ShellStatus = SHELL_INVALID_PARAMETER;
> > >        } else {
> > >          //
> > > @@ -931,41 +920,41 @@ ShellCommandRunDh (
> > >          //
> > >          ShellStatus = DoDhByProtocol(
> > >            ShellCommandLineGetValue(Package, L"-p"),
> > > -          Verbose,
> > > -          SfoMode,
> > > -          Lang==NULL?NULL:Language,
> > > -          FlagD
> > > -         );
> > > +          VerboseFlag,
> > > +          SfoFlag,
> > > +          Language,
> > > +          DriverFlag
> > > +        );
> > >        }
> > >      } else {
> > > -      Temp2 = ShellCommandLineGetRawValue(Package, 1);
> > > -      if (Temp2 == NULL) {
> > > +      RawValue = ShellCommandLineGetRawValue(Package, 1);
> > > +      if (RawValue == NULL) {
> > >          //
> > >          // Print everything
> > >          //
> > >          ShellStatus = DoDhForAll(
> > > -          SfoMode,
> > > -          Verbose,
> > > -          Lang==NULL?NULL:Language,
> > > -          FlagD
> > > +          SfoFlag,
> > > +          VerboseFlag,
> > > +          Language,
> > > +          DriverFlag
> > >           );
> > >        } else {
> > > -        Status = ShellConvertStringToUint64(Temp2, &Intermediate, TRUE,
> > FALSE);
> > > +        Status = ShellConvertStringToUint64(RawValue, &Intermediate,
> > > + TRUE,
> > > FALSE);
> > >          if (EFI_ERROR(Status) ||
> > > ConvertHandleIndexToHandle((UINTN)Intermediate) == NULL) {
> > > -          ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN
> (STR_GEN_INV_HANDLE),
> > > gShellDriver1HiiHandle, L"dh", Temp2);
> > > +          ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN
> > > + (STR_GEN_INV_HANDLE),
> > > gShellDriver1HiiHandle, L"dh", RawValue);
> > >            ShellStatus = SHELL_INVALID_PARAMETER;
> > >          } else {
> > >            //
> > >            // print 1 handle
> > >            //
> > > -          ShellStatus = DoDhByHandle(
> > > +          DoDhByHandle(
> > >              ConvertHandleIndexToHandle((UINTN)Intermediate),
> > > -            Verbose,
> > > -            SfoMode,
> > > -            Lang==NULL?NULL:Language,
> > > -            FlagD,
> > > +            VerboseFlag,
> > > +            SfoFlag,
> > > +            Language,
> > > +            DriverFlag,
> > >              FALSE
> > > -           );
> > > +          );
> > >          }
> > >        }
> > >      }
> > > --
> > > 2.9.0.windows.1



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

* Re: [PATCH 0/5] Change "dh" to support dump from GUID and "decode" parameter
  2017-01-10  2:23   ` Ni, Ruiyu
@ 2017-01-10 21:43     ` Carsey, Jaben
  0 siblings, 0 replies; 12+ messages in thread
From: Carsey, Jaben @ 2017-01-10 21:43 UTC (permalink / raw)
  To: Ni, Ruiyu, edk2-devel@lists.01.org, Kinney, Michael D
  Cc: Wu, Hao A, Carsey, Jaben

Sounds good.

> -----Original Message-----
> From: Ni, Ruiyu
> Sent: Monday, January 09, 2017 6:24 PM
> To: Carsey, Jaben <jaben.carsey@intel.com>; edk2-devel@lists.01.org;
> Kinney, Michael D <michael.d.kinney@intel.com>
> Cc: Wu, Hao A <hao.a.wu@intel.com>
> Subject: RE: [edk2] [PATCH 0/5] Change "dh" to support dump from GUID
> and "decode" parameter
> Importance: High
> 
> Jaben,
> Yes we will add the API to convert string to GUID. After the library API is
> added, the local implementation will be removed.
> 
> Thanks/Ray
> 
> > -----Original Message-----
> > From: Carsey, Jaben
> > Sent: Monday, January 9, 2017 11:41 PM
> > To: Ni, Ruiyu <ruiyu.ni@intel.com>; edk2-devel@lists.01.org; Kinney,
> Michael
> > D <michael.d.kinney@intel.com>
> > Cc: Carsey, Jaben <jaben.carsey@intel.com>
> > Subject: RE: [edk2] [PATCH 0/5] Change "dh" to support dump from GUID
> > and "decode" parameter
> >
> > Looks good.
> >
> > Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
> >
> > I had one inline question.
> >
> > I would also propose that the String to GUID conversion be placed in a
> shared
> > library.  Maybe even baselib with the other string functions?
> >
> > Mike, do you have any thoughts on StringToGuid conversion?
> >
> > > -----Original Message-----
> > > From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of
> > > Ruiyu Ni
> > > Sent: Monday, January 9, 2017 1:31 AM
> > > To: edk2-devel@lists.01.org
> > > Subject: [edk2] [PATCH 0/5] Change "dh" to support dump from GUID
> and
> > > "decode" parameter
> > > Importance: High
> > >
> > > Change "dh" to support dump from GUID and "decode" parameter
> > >
> > > Chen A Chen (2):
> > >   ShellPkg/HandleParsingLib: Add new API GetAllMappingGuids
> > >   ShellPkg/Dh: Fix coding style issues
> > >
> > > Ruiyu Ni (3):
> > >   ShellPkg/HandleParsingLib: Rename global variables
> > >   ShellPkg/HandleParsingLib: Return NULL name for unknown GUID
> > >   ShellPkg/dh: Support dump from GUID and "decode" parameter
> > >
> > >  ShellPkg/Include/Library/HandleParsingLib.h        |  21 +-
> > >  .../UefiHandleParsingLib/UefiHandleParsingLib.c    | 130 ++++--
> > >  .../UefiHandleParsingLib/UefiHandleParsingLib.uni  |   4 +-
> > >  ShellPkg/Library/UefiShellDriver1CommandsLib/Dh.c  | 458
> > > +++++++++++++++--
> > > ----
> > >  .../UefiShellDriver1CommandsLib.uni                |   9 +-
> > >  5 files changed, 446 insertions(+), 176 deletions(-)
> > >
> > > --
> > > 2.9.0.windows.1
> > >
> > > _______________________________________________
> > > edk2-devel mailing list
> > > edk2-devel@lists.01.org
> > > https://lists.01.org/mailman/listinfo/edk2-devel


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

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

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-01-09  9:30 [PATCH 0/5] Change "dh" to support dump from GUID and "decode" parameter Ruiyu Ni
2017-01-09  9:30 ` [PATCH 1/5] ShellPkg/HandleParsingLib: Rename global variables Ruiyu Ni
2017-01-09  9:30 ` [PATCH 2/5] ShellPkg/HandleParsingLib: Return NULL name for unknown GUID Ruiyu Ni
2017-01-09  9:30 ` [PATCH 3/5] ShellPkg/HandleParsingLib: Add new API GetAllMappingGuids Ruiyu Ni
2017-01-09  9:30 ` [PATCH 4/5] ShellPkg/Dh: Fix coding style issues Ruiyu Ni
2017-01-09 15:36   ` Carsey, Jaben
2017-01-10  2:24     ` Ni, Ruiyu
2017-01-10 16:20       ` Carsey, Jaben
2017-01-09  9:30 ` [PATCH 5/5] ShellPkg/dh: Support dump from GUID and "decode" parameter Ruiyu Ni
2017-01-09 15:40 ` [PATCH 0/5] Change "dh" to support " Carsey, Jaben
2017-01-10  2:23   ` Ni, Ruiyu
2017-01-10 21:43     ` Carsey, Jaben

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