]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/SmbiosView.c
add comments to function declarations and definitions and updated to match coding...
[mirror_edk2.git] / ShellPkg / Library / UefiShellDebug1CommandsLib / SmbiosView / SmbiosView.c
index b9ff013d602c36cbc43f418c5527564e6d8d65e0..b280306695fcb18474bbad176bca4c7a33d892cd 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Tools of clarify the content of the smbios table.\r
 \r
-  Copyright (c) 2005 - 2010, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2005 - 2011, Intel Corporation. All rights reserved.<BR>\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
   which accompanies this distribution.  The full text of the license may be found at\r
@@ -14,7 +14,7 @@
 \r
 #include "../UefiShellDebug1CommandsLib.h"\r
 #include "LibSmbiosView.h"\r
-#include "smbiosview.h"\r
+#include "SmbiosView.h"\r
 #include "PrintInfo.h"\r
 #include "QueryTable.h"\r
 \r
@@ -32,6 +32,12 @@ STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
   {NULL, TypeMax}\r
   };\r
 \r
+/**\r
+  Function for 'smbiosview' command.\r
+\r
+  @param[in] ImageHandle  Handle to the Image (NULL if Internal).\r
+  @param[in] SystemTable  Pointer to the System Table (NULL if Internal).\r
+**/\r
 SHELL_STATUS\r
 EFIAPI\r
 ShellCommandRunSmbiosView (\r
@@ -52,7 +58,7 @@ ShellCommandRunSmbiosView (
   Package             = NULL;\r
   ShellStatus         = SHELL_SUCCESS;\r
 \r
-  Status = ShellCommandLineParse (EmptyParamList, &Package, &ProblemParam, TRUE);\r
+  Status = ShellCommandLineParse (ParamList, &Package, &ProblemParam, TRUE);\r
   if (EFI_ERROR(Status)) {\r
     if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {\r
       ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, ProblemParam);\r
@@ -65,11 +71,27 @@ ShellCommandRunSmbiosView (
     if (ShellCommandLineGetCount(Package) > 1) {\r
       ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDebug1HiiHandle);\r
       ShellStatus = SHELL_INVALID_PARAMETER;\r
+    } else if (ShellCommandLineGetFlag(Package, L"-t") && ShellCommandLineGetValue(Package, L"-t") == NULL) {\r
+      ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_VALUE), gShellDebug1HiiHandle, L"-t");\r
+      ShellStatus = SHELL_INVALID_PARAMETER;\r
+    } else if (ShellCommandLineGetFlag(Package, L"-h") && ShellCommandLineGetValue(Package, L"-h") == NULL) {\r
+      ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_VALUE), gShellDebug1HiiHandle, L"-h");\r
+      ShellStatus = SHELL_INVALID_PARAMETER;\r
+    } else if (\r
+        (ShellCommandLineGetFlag(Package, L"-t") && ShellCommandLineGetFlag(Package, L"-h")) ||\r
+        (ShellCommandLineGetFlag(Package, L"-t") && ShellCommandLineGetFlag(Package, L"-s")) ||\r
+        (ShellCommandLineGetFlag(Package, L"-t") && ShellCommandLineGetFlag(Package, L"-a")) ||\r
+        (ShellCommandLineGetFlag(Package, L"-h") && ShellCommandLineGetFlag(Package, L"-s")) ||\r
+        (ShellCommandLineGetFlag(Package, L"-h") && ShellCommandLineGetFlag(Package, L"-a")) ||\r
+        (ShellCommandLineGetFlag(Package, L"-s") && ShellCommandLineGetFlag(Package, L"-a"))\r
+      ) {\r
+      ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDebug1HiiHandle);\r
+      ShellStatus = SHELL_INVALID_PARAMETER;\r
     } else {\r
 \r
       //\r
       // Init Lib\r
-      //\r
+      \r
       Status = LibSmbiosInit ();\r
       if (EFI_ERROR (Status)) {\r
         ShellStatus = SHELL_NOT_FOUND;\r
@@ -181,7 +203,7 @@ SMBiosView (
   // structure table head.\r
   //\r
 \r
-  SMBIOS_STRUCTURE_POINTER  pStruct;\r
+  SMBIOS_STRUCTURE_POINTER  SmbiosStruct;\r
   SMBIOS_STRUCTURE_TABLE    *SMBiosTable;\r
 \r
   SMBiosTable = NULL;\r
@@ -253,14 +275,14 @@ SMBiosView (
         break;\r
       }\r
       Offset      = (UINT16) (Offset + Length);\r
-      pStruct.Raw = Buffer;\r
+      SmbiosStruct.Raw = Buffer;\r
 \r
       //\r
       // if QueryType==Random, print this structure.\r
       // if QueryType!=Random, but Hdr->Type==QueryType, also print it.\r
       // only if QueryType != Random and Hdr->Type != QueryType, skiped it.\r
       //\r
-      if (QueryType != STRUCTURE_TYPE_RANDOM && pStruct.Hdr->Type != QueryType) {\r
+      if (QueryType != STRUCTURE_TYPE_RANDOM && SmbiosStruct.Hdr->Type != QueryType) {\r
         continue;\r
       }\r
 \r
@@ -268,8 +290,8 @@ SMBiosView (
       ShellPrintHiiEx(-1,-1,NULL,\r
         STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_TYPE_HANDLE_DUMP_STRUCT),\r
         gShellDebug1HiiHandle,\r
-        pStruct.Hdr->Type,\r
-        pStruct.Hdr->Handle\r
+        SmbiosStruct.Hdr->Type,\r
+        SmbiosStruct.Hdr->Handle\r
        );\r
       ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_INDEX_LENGTH), gShellDebug1HiiHandle, Index, Length);\r
       //\r
@@ -296,12 +318,12 @@ SMBiosView (
         //\r
         // check structure legality\r
         //\r
-        SmbiosCheckStructure (&pStruct);\r
+        SmbiosCheckStructure (&SmbiosStruct);\r
 \r
         //\r
         // Print structure information\r
         //\r
-        SmbiosPrintStructure (&pStruct, gShowType);\r
+        SmbiosPrintStructure (&SmbiosStruct, gShowType);\r
         ShellPrintEx(-1,-1,L"\n");\r
 \r
 /*\r
@@ -347,9 +369,9 @@ InitSmbiosTableStatistics (
   UINT16                    Offset;\r
   UINT16                    Index;\r
 \r
-  SMBIOS_STRUCTURE_POINTER  pStruct;\r
+  SMBIOS_STRUCTURE_POINTER  SmbiosStruct;\r
   SMBIOS_STRUCTURE_TABLE    *SMBiosTable;\r
-  STRUCTURE_STATISTICS      *pStatistics;\r
+  STRUCTURE_STATISTICS      *StatisticsPointer;\r
 \r
   SMBiosTable = NULL;\r
   LibSmbiosGetEPS (&SMBiosTable);\r
@@ -370,7 +392,7 @@ InitSmbiosTableStatistics (
     mStatisticsTable = NULL;\r
   }\r
 \r
-  mStatisticsTable = (STRUCTURE_STATISTICS *) AllocatePool (SMBiosTable->NumberOfSmbiosStructures * sizeof (STRUCTURE_STATISTICS));\r
+  mStatisticsTable = (STRUCTURE_STATISTICS *) AllocateZeroPool (SMBiosTable->NumberOfSmbiosStructures * sizeof (STRUCTURE_STATISTICS));\r
 \r
   if (mStatisticsTable == NULL) {\r
     ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_OUT_OF_MEM), gShellDebug1HiiHandle);\r
@@ -378,7 +400,7 @@ InitSmbiosTableStatistics (
   }\r
 \r
   Offset      = 0;\r
-  pStatistics = mStatisticsTable;\r
+  StatisticsPointer = mStatisticsTable;\r
 \r
   //\r
   // search from the first one\r
@@ -399,19 +421,19 @@ InitSmbiosTableStatistics (
       break;\r
     }\r
 \r
-    pStruct.Raw = Buffer;\r
+    SmbiosStruct.Raw = Buffer;\r
     Offset      = (UINT16) (Offset + Length);\r
 \r
     //\r
     // general statistics\r
     //\r
-    pStatistics->Index  = Index;\r
-    pStatistics->Type   = pStruct.Hdr->Type;\r
-    pStatistics->Handle = pStruct.Hdr->Handle;\r
-    pStatistics->Length = Length;\r
-    pStatistics->Addr   = Offset;\r
+    StatisticsPointer->Index  = Index;\r
+    StatisticsPointer->Type   = SmbiosStruct.Hdr->Type;\r
+    StatisticsPointer->Handle = SmbiosStruct.Hdr->Handle;\r
+    StatisticsPointer->Length = Length;\r
+    StatisticsPointer->Addr   = Offset;\r
 \r
-    pStatistics         = &mStatisticsTable[Index];\r
+    StatisticsPointer         = &mStatisticsTable[Index];\r
   }\r
 \r
   return EFI_SUCCESS;\r
@@ -432,7 +454,7 @@ DisplayStatisticsTable (
 {\r
   UINTN                   Index;\r
   UINTN                   Num;\r
-  STRUCTURE_STATISTICS    *pStatistics;\r
+  STRUCTURE_STATISTICS    *StatisticsPointer;\r
   SMBIOS_STRUCTURE_TABLE  *SMBiosTable;\r
 \r
   SMBiosTable = NULL;\r
@@ -461,22 +483,22 @@ DisplayStatisticsTable (
   }\r
 \r
   ShellPrintEx(-1,-1,L"============================================================\n");\r
-  pStatistics = &mStatisticsTable[0];\r
+  StatisticsPointer = &mStatisticsTable[0];\r
   Num         = SMBiosTable->NumberOfSmbiosStructures;\r
   //\r
   // display statistics table content\r
   //\r
   for (Index = 1; Index <= Num; Index++) {\r
-    ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_INDEX), gShellDebug1HiiHandle, pStatistics->Index);\r
-    ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_TYPE), gShellDebug1HiiHandle, pStatistics->Type);\r
-    ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_HANDLE), gShellDebug1HiiHandle, pStatistics->Handle);\r
+    ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_INDEX), gShellDebug1HiiHandle, StatisticsPointer->Index);\r
+    ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_TYPE), gShellDebug1HiiHandle, StatisticsPointer->Type);\r
+    ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_HANDLE), gShellDebug1HiiHandle, StatisticsPointer->Handle);\r
     if (Option >= SHOW_DETAIL) {\r
-      ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_OFFSET), gShellDebug1HiiHandle, pStatistics->Addr);\r
-      ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_LENGTH), gShellDebug1HiiHandle, pStatistics->Length);\r
+      ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_OFFSET), gShellDebug1HiiHandle, StatisticsPointer->Addr);\r
+      ShellPrintHiiEx(-1,-1,NULL,STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_LENGTH), gShellDebug1HiiHandle, StatisticsPointer->Length);\r
     }\r
 \r
     ShellPrintEx(-1,-1,L"\n");\r
-    pStatistics = &mStatisticsTable[Index];\r
+    StatisticsPointer = &mStatisticsTable[Index];\r
 /*\r
     //\r
     // Display 20 lines and wait for a page break\r