]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ShellPkg: elevate DumpHex() from Debug1-internal to generic-internal
authorLaszlo Ersek <lersek@redhat.com>
Thu, 21 Jan 2016 18:40:40 +0000 (18:40 +0000)
committerlersek <lersek@Edk2>
Thu, 21 Jan 2016 18:40:40 +0000 (18:40 +0000)
The UEFI Shell specification classifies shell commands into various shell
levels / profiles.

Currently the DumpHex() internal function is only used by commands that
belong to the Debug1 profile exclusively (i.e., they are not required to
be present in other than Debug1 profiles):
- SMBIOSVIEW
- PCI
- DMPSTORE
- DMEM
- DBLK

In the next patch, we'd like to call DumpHex() from BCFG as well. However,
BCFG is not only required to be present in the Debug1 profile; the
Install1 profile contains BCFG as well. For this reason, move DumpHex()
from UefiShellDebug1CommandsLib to the more generic UefiShellCommandLib,
which "Provides interface to shell internal functions for shell commands".
The matching header file is "ShellPkg/Include/Library/ShellCommandLib.h".

Cc: Jaben Carsey <jaben.carsey@intel.com>
Cc: Ryan Harkin <ryan.harkin@linaro.org>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@19717 6f19259b-4bc3-4df7-8a09-765794883524

ShellPkg/Include/Library/ShellCommandLib.h
ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c
ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.inf
ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.c
ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.h
ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.inf

index 53a56ae5e465d4a1f322af077c2f9aba81fdb050..0dd66c2fbc3a725787f11a27c59d5b18521a48a5 100644 (file)
@@ -685,4 +685,20 @@ FreeBufferList (
   IN BUFFER_LIST *List\r
   );\r
 \r
+/**\r
+  Function printing hex output to the console.\r
+\r
+  @param[in] Indent       Number of spaces to indent.\r
+  @param[in] Offset       Offset to start with.\r
+  @param[in] DataSize     Length of data.\r
+  @param[in] UserData     Pointer to some data.\r
+**/\r
+VOID\r
+DumpHex (\r
+  IN UINTN        Indent,\r
+  IN UINTN        Offset,\r
+  IN UINTN        DataSize,\r
+  IN VOID         *UserData\r
+  );\r
+\r
 #endif //_SHELL_COMMAND_LIB_\r
index ceda7ab81e38c38ce9f34a39e79ac0445855ae0f..92a88d18a065b95b98631e91061418792fe13c0c 100644 (file)
@@ -29,6 +29,25 @@ STATIC UINTN                              mFsMaxCount = 0;
 STATIC UINTN                              mBlkMaxCount = 0;\r
 STATIC BUFFER_LIST                        mFileHandleList;\r
 \r
+STATIC CONST CHAR8 Hex[] = {\r
+  '0',\r
+  '1',\r
+  '2',\r
+  '3',\r
+  '4',\r
+  '5',\r
+  '6',\r
+  '7',\r
+  '8',\r
+  '9',\r
+  'A',\r
+  'B',\r
+  'C',\r
+  'D',\r
+  'E',\r
+  'F'\r
+};\r
+\r
 // global variables required by library class.\r
 EFI_UNICODE_COLLATION_PROTOCOL    *gUnicodeCollation            = NULL;\r
 SHELL_MAP_LIST                    gShellMapList;\r
@@ -1673,3 +1692,53 @@ FreeBufferList (
   }\r
 }\r
 \r
+/**\r
+  Dump some hexadecimal data to the screen.\r
+\r
+  @param[in] Indent     How many spaces to indent the output.\r
+  @param[in] Offset     The offset of the printing.\r
+  @param[in] DataSize   The size in bytes of UserData.\r
+  @param[in] UserData   The data to print out.\r
+**/\r
+VOID\r
+DumpHex (\r
+  IN UINTN        Indent,\r
+  IN UINTN        Offset,\r
+  IN UINTN        DataSize,\r
+  IN VOID         *UserData\r
+  )\r
+{\r
+  UINT8 *Data;\r
+\r
+  CHAR8 Val[50];\r
+\r
+  CHAR8 Str[20];\r
+\r
+  UINT8 TempByte;\r
+  UINTN Size;\r
+  UINTN Index;\r
+\r
+  Data = UserData;\r
+  while (DataSize != 0) {\r
+    Size = 16;\r
+    if (Size > DataSize) {\r
+      Size = DataSize;\r
+    }\r
+\r
+    for (Index = 0; Index < Size; Index += 1) {\r
+      TempByte            = Data[Index];\r
+      Val[Index * 3 + 0]  = Hex[TempByte >> 4];\r
+      Val[Index * 3 + 1]  = Hex[TempByte & 0xF];\r
+      Val[Index * 3 + 2]  = (CHAR8) ((Index == 7) ? '-' : ' ');\r
+      Str[Index]          = (CHAR8) ((TempByte < ' ' || TempByte > 'z') ? '.' : TempByte);\r
+    }\r
+\r
+    Val[Index * 3]  = 0;\r
+    Str[Index]      = 0;\r
+    ShellPrintEx(-1, -1, L"%*a%08X: %-48a *%a*\r\n", Indent, "", Offset, Val, Str);\r
+\r
+    Data += Size;\r
+    Offset += Size;\r
+    DataSize -= Size;\r
+  }\r
+}\r
index 1de52991bf4efe6d982a6f28acc92aeae5ec5b10..e111e8d56f46a1b4978814f6ab1a7361ff0a7642 100644 (file)
@@ -18,7 +18,7 @@
   BASE_NAME                      = UefiShellCommandLib\r
   FILE_GUID                      = 5C12F31F-EBAC-466e-A400-FCA8C9EA3A05\r
   MODULE_TYPE                    = UEFI_DRIVER\r
-  VERSION_STRING                 = 1.0\r
+  VERSION_STRING                 = 1.1\r
   LIBRARY_CLASS                  = ShellCommandLib|UEFI_APPLICATION UEFI_DRIVER DXE_RUNTIME_DRIVER\r
   CONSTRUCTOR                    = ShellCommandLibConstructor\r
   DESTRUCTOR                     = ShellCommandLibDestructor\r
index 5f8f8a9dd95991bfb896f7bbbdb6e5dce0881ff0..1814564c12db16cdc900875717aebf6829810c6f 100644 (file)
@@ -113,76 +113,6 @@ UefiShellDebug1CommandsLibDestructor (
   return (EFI_SUCCESS);\r
 }\r
 \r
-STATIC CONST CHAR8 Hex[] = {\r
-  '0',\r
-  '1',\r
-  '2',\r
-  '3',\r
-  '4',\r
-  '5',\r
-  '6',\r
-  '7',\r
-  '8',\r
-  '9',\r
-  'A',\r
-  'B',\r
-  'C',\r
-  'D',\r
-  'E',\r
-  'F'\r
-};\r
-\r
-/**\r
-  Dump some hexadecimal data to the screen.\r
-\r
-  @param[in] Indent     How many spaces to indent the output.\r
-  @param[in] Offset     The offset of the printing.\r
-  @param[in] DataSize   The size in bytes of UserData.\r
-  @param[in] UserData   The data to print out.\r
-**/\r
-VOID\r
-DumpHex (\r
-  IN UINTN        Indent,\r
-  IN UINTN        Offset,\r
-  IN UINTN        DataSize,\r
-  IN VOID         *UserData\r
-  )\r
-{\r
-  UINT8 *Data;\r
-\r
-  CHAR8 Val[50];\r
-\r
-  CHAR8 Str[20];\r
-\r
-  UINT8 TempByte;\r
-  UINTN Size;\r
-  UINTN Index;\r
-\r
-  Data = UserData;\r
-  while (DataSize != 0) {\r
-    Size = 16;\r
-    if (Size > DataSize) {\r
-      Size = DataSize;\r
-    }\r
-\r
-    for (Index = 0; Index < Size; Index += 1) {\r
-      TempByte            = Data[Index];\r
-      Val[Index * 3 + 0]  = Hex[TempByte >> 4];\r
-      Val[Index * 3 + 1]  = Hex[TempByte & 0xF];\r
-      Val[Index * 3 + 2]  = (CHAR8) ((Index == 7) ? '-' : ' ');\r
-      Str[Index]          = (CHAR8) ((TempByte < ' ' || TempByte > 'z') ? '.' : TempByte);\r
-    }\r
-\r
-    Val[Index * 3]  = 0;\r
-    Str[Index]      = 0;\r
-    ShellPrintEx(-1, -1, L"%*a%08X: %-48a *%a*\r\n", Indent, "", Offset, Val, Str);\r
-\r
-    Data += Size;\r
-    Offset += Size;\r
-    DataSize -= Size;\r
-  }\r
-}\r
-\r
 /**\r
   Convert a Unicode character to upper case only if\r
   it maps to a valid small-case ASCII character.\r
index ec15155a0793f63695c745fa9b3353961b0e46ba..6e018a6a8165e84d6fa282c2f985353d56e4a7c8 100644 (file)
 \r
 extern        EFI_HANDLE                        gShellDebug1HiiHandle;\r
 \r
-/**\r
-  Function printing hex output to the console.\r
-\r
-  @param[in] Indent       Number of spaces to indent.\r
-  @param[in] Offset       Offset to start with.\r
-  @param[in] DataSize     Length of data.\r
-  @param[in] UserData     Pointer to some data.\r
-**/\r
-VOID\r
-DumpHex (\r
-  IN UINTN        Indent,\r
-  IN UINTN        Offset,\r
-  IN UINTN        DataSize,\r
-  IN VOID         *UserData\r
-  );\r
-\r
 /**\r
   Function returns a system configuration table that is stored in the\r
   EFI System Table based on the provided GUID.\r
index cfbf001bcb2512458c8ae5c982b3f080e2f81b06..8104b9a1d5dc834f281d4231cbd0f68362710c79 100644 (file)
@@ -17,7 +17,7 @@
   BASE_NAME                      = UefiShellDebug1CommandsLib\r
   FILE_GUID                      = 90330D51-A99B-4cc8-A2EB-AE22542A3F45\r
   MODULE_TYPE                    = UEFI_APPLICATION\r
-  VERSION_STRING                 = 1.1\r
+  VERSION_STRING                 = 1.2\r
   LIBRARY_CLASS                  = NULL|UEFI_APPLICATION UEFI_DRIVER\r
   CONSTRUCTOR                    = UefiShellDebug1CommandsLibConstructor\r
   DESTRUCTOR                     = UefiShellDebug1CommandsLibDestructor\r