STATIC UINT32 mTableCount;\r
STATIC UINT32 mBinTableCount;\r
\r
-/**\r
- An array of acpiview command line parameters.\r
-**/\r
-STATIC CONST SHELL_PARAM_ITEM ParamList[] = {\r
- {L"-q", TypeFlag},\r
- {L"-d", TypeFlag},\r
- {L"-h", TypeFlag},\r
- {L"-l", TypeFlag},\r
- {L"-s", TypeValue},\r
- {L"-r", TypeValue},\r
- {NULL, TypeMax}\r
-};\r
-\r
/**\r
This function dumps the ACPI table to a file.\r
\r
Returns EFI_UNSUPPORTED if the RSDP version is less than 2.\r
Returns EFI_SUCCESS if successful.\r
**/\r
-STATIC\r
EFI_STATUS\r
EFIAPI\r
AcpiView (\r
}\r
return EFI_SUCCESS;\r
}\r
-\r
-/**\r
- Function for 'acpiview' 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
-ShellCommandRunAcpiView (\r
- IN EFI_HANDLE ImageHandle,\r
- IN EFI_SYSTEM_TABLE* SystemTable\r
- )\r
-{\r
- EFI_STATUS Status;\r
- SHELL_STATUS ShellStatus;\r
- LIST_ENTRY* Package;\r
- CHAR16* ProblemParam;\r
- SHELL_FILE_HANDLE TmpDumpFileHandle;\r
- CONST CHAR16* MandatoryTableSpecStr;\r
- CONST CHAR16 *SelectedTableName;\r
-\r
- // Set configuration defaults\r
- AcpiConfigSetDefaults ();\r
-\r
- ShellStatus = SHELL_SUCCESS;\r
- Package = NULL;\r
- TmpDumpFileHandle = NULL;\r
-\r
- Status = ShellCommandLineParse (ParamList, &Package, &ProblemParam, TRUE);\r
- if (EFI_ERROR (Status)) {\r
- if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {\r
- ShellPrintHiiEx (\r
- -1,\r
- -1,\r
- NULL,\r
- STRING_TOKEN (STR_GEN_PROBLEM),\r
- gShellAcpiViewHiiHandle,\r
- L"acpiview",\r
- ProblemParam\r
- );\r
- FreePool (ProblemParam);\r
- } else {\r
- Print (L"acpiview: Error processing input parameter(s)\n");\r
- }\r
- ShellStatus = SHELL_INVALID_PARAMETER;\r
- } else {\r
- if (ShellCommandLineGetCount (Package) > 1) {\r
- ShellPrintHiiEx (\r
- -1,\r
- -1,\r
- NULL,\r
- STRING_TOKEN (STR_GEN_TOO_MANY),\r
- gShellAcpiViewHiiHandle,\r
- L"acpiview"\r
- );\r
- ShellStatus = SHELL_INVALID_PARAMETER;\r
- } else if (ShellCommandLineGetFlag (Package, L"-?")) {\r
- ShellPrintHiiEx (\r
- -1,\r
- -1,\r
- NULL,\r
- STRING_TOKEN (STR_GET_HELP_ACPIVIEW),\r
- gShellAcpiViewHiiHandle,\r
- L"acpiview"\r
- );\r
- } else if (ShellCommandLineGetFlag (Package, L"-s") &&\r
- ShellCommandLineGetValue (Package, L"-s") == NULL) {\r
- ShellPrintHiiEx (\r
- -1,\r
- -1,\r
- NULL,\r
- STRING_TOKEN (STR_GEN_NO_VALUE),\r
- gShellAcpiViewHiiHandle,\r
- L"acpiview",\r
- L"-s"\r
- );\r
- ShellStatus = SHELL_INVALID_PARAMETER;\r
- } else if (ShellCommandLineGetFlag (Package, L"-r") &&\r
- ShellCommandLineGetValue (Package, L"-r") == NULL) {\r
- ShellPrintHiiEx (\r
- -1,\r
- -1,\r
- NULL,\r
- STRING_TOKEN (STR_GEN_NO_VALUE),\r
- gShellAcpiViewHiiHandle,\r
- L"acpiview",\r
- L"-r"\r
- );\r
- ShellStatus = SHELL_INVALID_PARAMETER;\r
- } else if ((ShellCommandLineGetFlag (Package, L"-s") &&\r
- ShellCommandLineGetFlag (Package, L"-l"))) {\r
- ShellPrintHiiEx (\r
- -1,\r
- -1,\r
- NULL,\r
- STRING_TOKEN (STR_GEN_TOO_MANY),\r
- gShellAcpiViewHiiHandle,\r
- L"acpiview"\r
- );\r
- ShellStatus = SHELL_INVALID_PARAMETER;\r
- } else if (ShellCommandLineGetFlag (Package, L"-d") &&\r
- !ShellCommandLineGetFlag (Package, L"-s")) {\r
- ShellPrintHiiEx (\r
- -1,\r
- -1,\r
- NULL,\r
- STRING_TOKEN (STR_GEN_MISSING_OPTION),\r
- gShellAcpiViewHiiHandle,\r
- L"acpiview",\r
- L"-s",\r
- L"-d"\r
- );\r
- ShellStatus = SHELL_INVALID_PARAMETER;\r
- } else {\r
- // Turn on colour highlighting if requested\r
- SetColourHighlighting (ShellCommandLineGetFlag (Package, L"-h"));\r
-\r
- // Surpress consistency checking if requested\r
- SetConsistencyChecking (!ShellCommandLineGetFlag (Package, L"-q"));\r
-\r
- // Evaluate the parameters for mandatory ACPI table presence checks\r
- SetMandatoryTableValidate (ShellCommandLineGetFlag (Package, L"-r"));\r
- MandatoryTableSpecStr = ShellCommandLineGetValue (Package, L"-r");\r
-\r
- if (MandatoryTableSpecStr != NULL) {\r
- SetMandatoryTableSpec (ShellHexStrToUintn (MandatoryTableSpecStr));\r
- }\r
-\r
- if (ShellCommandLineGetFlag (Package, L"-l")) {\r
- SetReportOption (ReportTableList);\r
- } else {\r
- SelectedTableName = ShellCommandLineGetValue (Package, L"-s");\r
- if (SelectedTableName != NULL) {\r
- SelectAcpiTable (SelectedTableName);\r
- SetReportOption (ReportSelected);\r
-\r
- if (ShellCommandLineGetFlag (Package, L"-d")) {\r
- // Create a temporary file to check if the media is writable.\r
- CHAR16 FileNameBuffer[MAX_FILE_NAME_LEN];\r
- SetReportOption (ReportDumpBinFile);\r
-\r
- UnicodeSPrint (\r
- FileNameBuffer,\r
- sizeof (FileNameBuffer),\r
- L".\\%s%04d.tmp",\r
- SelectedTableName,\r
- mBinTableCount\r
- );\r
-\r
- Status = ShellOpenFileByName (\r
- FileNameBuffer,\r
- &TmpDumpFileHandle,\r
- EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE |\r
- EFI_FILE_MODE_CREATE,\r
- 0\r
- );\r
-\r
- if (EFI_ERROR (Status)) {\r
- ShellStatus = SHELL_INVALID_PARAMETER;\r
- TmpDumpFileHandle = NULL;\r
- ShellPrintHiiEx (\r
- -1,\r
- -1,\r
- NULL,\r
- STRING_TOKEN (STR_GEN_READONLY_MEDIA),\r
- gShellAcpiViewHiiHandle,\r
- L"acpiview"\r
- );\r
- goto Done;\r
- }\r
- // Delete Temporary file.\r
- ShellDeleteFile (&TmpDumpFileHandle);\r
- } // -d\r
- } // -s\r
- }\r
-\r
- // Parse ACPI Table information\r
- Status = AcpiView (SystemTable);\r
- if (EFI_ERROR (Status)) {\r
- ShellStatus = SHELL_NOT_FOUND;\r
- }\r
- }\r
- }\r
-\r
-Done:\r
- if (Package != NULL) {\r
- ShellCommandLineFreeVarList (Package);\r
- }\r
- return ShellStatus;\r
-}\r
\r
@param [in] Signature The ACPI table Signature.\r
@param [in] TablePtr Pointer to the ACPI table data.\r
- @param [in] Length The length fo the ACPI table.\r
+ @param [in] Length The length of the ACPI table.\r
\r
@retval Returns TRUE if the ACPI table should be traced.\r
**/\r
IN CONST UINT32 Length\r
);\r
\r
+/**\r
+ This function iterates the configuration table entries in the\r
+ system table, retrieves the RSDP pointer and starts parsing the ACPI tables.\r
+\r
+ @param [in] SystemTable Pointer to the EFI system table.\r
+\r
+ @retval EFI_NOT_FOUND The RSDP pointer was not found.\r
+ @retval EFI_UNSUPPORTED The RSDP version was less than 2.\r
+ @retval EFI_SUCCESS The command was successful.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+AcpiView (\r
+ IN EFI_SYSTEM_TABLE* SystemTable\r
+ );\r
+\r
#endif // ACPIVIEW_H_\r
/** @file\r
Main file for 'acpiview' Shell command function.\r
\r
- Copyright (c) 2016 - 2019, ARM Limited. All rights reserved.<BR>\r
+ Copyright (c) 2016 - 2020, ARM Limited. All rights reserved.<BR>\r
SPDX-License-Identifier: BSD-2-Clause-Patent\r
**/\r
\r
#include <Guid/ShellLibHiiGuid.h>\r
#include <IndustryStandard/Acpi.h>\r
+\r
+#include <Library/BaseMemoryLib.h>\r
#include <Library/HiiLib.h>\r
+#include <Library/MemoryAllocationLib.h>\r
+#include <Library/PrintLib.h>\r
#include <Library/ShellCommandLib.h>\r
-#include <Library/UefiLib.h>\r
+#include <Library/ShellLib.h>\r
#include <Library/UefiBootServicesTableLib.h>\r
+#include <Library/UefiLib.h>\r
#include <Uefi.h>\r
+\r
#include "AcpiParser.h"\r
#include "AcpiTableParser.h"\r
#include "AcpiView.h"\r
+#include "AcpiViewConfig.h"\r
#include "UefiShellAcpiViewCommandLib.h"\r
\r
CONST CHAR16 gShellAcpiViewFileName[] = L"ShellCommand";\r
\r
+/**\r
+ An array of acpiview command line parameters.\r
+**/\r
+STATIC CONST SHELL_PARAM_ITEM ParamList[] = {\r
+ {L"-q", TypeFlag},\r
+ {L"-d", TypeFlag},\r
+ {L"-h", TypeFlag},\r
+ {L"-l", TypeFlag},\r
+ {L"-s", TypeValue},\r
+ {L"-r", TypeValue},\r
+ {NULL, TypeMax}\r
+};\r
+\r
/**\r
A list of available table parsers.\r
*/\r
return gShellAcpiViewFileName;\r
}\r
\r
+/**\r
+ Function for 'acpiview' 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
+ @retval SHELL_INVALID_PARAMETER The command line invocation could not be parsed\r
+ @retval SHELL_NOT_FOUND The command failed\r
+ @retval SHELL_SUCCESS The command was successful\r
+**/\r
+SHELL_STATUS\r
+EFIAPI\r
+ShellCommandRunAcpiView (\r
+ IN EFI_HANDLE ImageHandle,\r
+ IN EFI_SYSTEM_TABLE* SystemTable\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ SHELL_STATUS ShellStatus;\r
+ LIST_ENTRY* Package;\r
+ CHAR16* ProblemParam;\r
+ SHELL_FILE_HANDLE TmpDumpFileHandle;\r
+ CONST CHAR16* MandatoryTableSpecStr;\r
+ CONST CHAR16* SelectedTableName;\r
+\r
+ // Set configuration defaults\r
+ AcpiConfigSetDefaults ();\r
+\r
+ ShellStatus = SHELL_SUCCESS;\r
+ Package = NULL;\r
+ TmpDumpFileHandle = NULL;\r
+\r
+ Status = ShellCommandLineParse (ParamList, &Package, &ProblemParam, TRUE);\r
+ if (EFI_ERROR (Status)) {\r
+ if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {\r
+ ShellPrintHiiEx (\r
+ -1,\r
+ -1,\r
+ NULL,\r
+ STRING_TOKEN (STR_GEN_PROBLEM),\r
+ gShellAcpiViewHiiHandle,\r
+ L"acpiview",\r
+ ProblemParam\r
+ );\r
+ FreePool (ProblemParam);\r
+ } else {\r
+ Print (L"acpiview: Error processing input parameter(s)\n");\r
+ }\r
+ ShellStatus = SHELL_INVALID_PARAMETER;\r
+ } else {\r
+ if (ShellCommandLineGetCount (Package) > 1) {\r
+ ShellPrintHiiEx (\r
+ -1,\r
+ -1,\r
+ NULL,\r
+ STRING_TOKEN (STR_GEN_TOO_MANY),\r
+ gShellAcpiViewHiiHandle,\r
+ L"acpiview"\r
+ );\r
+ ShellStatus = SHELL_INVALID_PARAMETER;\r
+ } else if (ShellCommandLineGetFlag (Package, L"-?")) {\r
+ ShellPrintHiiEx (\r
+ -1,\r
+ -1,\r
+ NULL,\r
+ STRING_TOKEN (STR_GET_HELP_ACPIVIEW),\r
+ gShellAcpiViewHiiHandle,\r
+ L"acpiview"\r
+ );\r
+ } else if (ShellCommandLineGetFlag (Package, L"-s") &&\r
+ ShellCommandLineGetValue (Package, L"-s") == NULL) {\r
+ ShellPrintHiiEx (\r
+ -1,\r
+ -1,\r
+ NULL,\r
+ STRING_TOKEN (STR_GEN_NO_VALUE),\r
+ gShellAcpiViewHiiHandle,\r
+ L"acpiview",\r
+ L"-s"\r
+ );\r
+ ShellStatus = SHELL_INVALID_PARAMETER;\r
+ } else if (ShellCommandLineGetFlag (Package, L"-r") &&\r
+ ShellCommandLineGetValue (Package, L"-r") == NULL) {\r
+ ShellPrintHiiEx (\r
+ -1,\r
+ -1,\r
+ NULL,\r
+ STRING_TOKEN (STR_GEN_NO_VALUE),\r
+ gShellAcpiViewHiiHandle,\r
+ L"acpiview",\r
+ L"-r"\r
+ );\r
+ ShellStatus = SHELL_INVALID_PARAMETER;\r
+ } else if ((ShellCommandLineGetFlag (Package, L"-s") &&\r
+ ShellCommandLineGetFlag (Package, L"-l"))) {\r
+ ShellPrintHiiEx (\r
+ -1,\r
+ -1,\r
+ NULL,\r
+ STRING_TOKEN (STR_GEN_TOO_MANY),\r
+ gShellAcpiViewHiiHandle,\r
+ L"acpiview"\r
+ );\r
+ ShellStatus = SHELL_INVALID_PARAMETER;\r
+ } else if (ShellCommandLineGetFlag (Package, L"-d") &&\r
+ !ShellCommandLineGetFlag (Package, L"-s")) {\r
+ ShellPrintHiiEx (\r
+ -1,\r
+ -1,\r
+ NULL,\r
+ STRING_TOKEN (STR_GEN_MISSING_OPTION),\r
+ gShellAcpiViewHiiHandle,\r
+ L"acpiview",\r
+ L"-s",\r
+ L"-d"\r
+ );\r
+ ShellStatus = SHELL_INVALID_PARAMETER;\r
+ } else {\r
+ // Turn on colour highlighting if requested\r
+ SetColourHighlighting (ShellCommandLineGetFlag (Package, L"-h"));\r
+\r
+ // Surpress consistency checking if requested\r
+ SetConsistencyChecking (!ShellCommandLineGetFlag (Package, L"-q"));\r
+\r
+ // Evaluate the parameters for mandatory ACPI table presence checks\r
+ SetMandatoryTableValidate (ShellCommandLineGetFlag (Package, L"-r"));\r
+ MandatoryTableSpecStr = ShellCommandLineGetValue (Package, L"-r");\r
+\r
+ if (MandatoryTableSpecStr != NULL) {\r
+ SetMandatoryTableSpec (ShellHexStrToUintn (MandatoryTableSpecStr));\r
+ }\r
+\r
+ if (ShellCommandLineGetFlag (Package, L"-l")) {\r
+ SetReportOption (ReportTableList);\r
+ } else {\r
+ SelectedTableName = ShellCommandLineGetValue (Package, L"-s");\r
+ if (SelectedTableName != NULL) {\r
+ SelectAcpiTable (SelectedTableName);\r
+ SetReportOption (ReportSelected);\r
+\r
+ if (ShellCommandLineGetFlag (Package, L"-d")) {\r
+ // Create a temporary file to check if the media is writable.\r
+ CHAR16 FileNameBuffer[MAX_FILE_NAME_LEN];\r
+ SetReportOption (ReportDumpBinFile);\r
+\r
+ UnicodeSPrint (\r
+ FileNameBuffer,\r
+ sizeof (FileNameBuffer),\r
+ L".\\%s0000.tmp",\r
+ SelectedTableName\r
+ );\r
+\r
+ Status = ShellOpenFileByName (\r
+ FileNameBuffer,\r
+ &TmpDumpFileHandle,\r
+ EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE |\r
+ EFI_FILE_MODE_CREATE,\r
+ 0\r
+ );\r
+\r
+ if (EFI_ERROR (Status)) {\r
+ ShellStatus = SHELL_INVALID_PARAMETER;\r
+ TmpDumpFileHandle = NULL;\r
+ ShellPrintHiiEx (\r
+ -1,\r
+ -1,\r
+ NULL,\r
+ STRING_TOKEN (STR_GEN_READONLY_MEDIA),\r
+ gShellAcpiViewHiiHandle,\r
+ L"acpiview"\r
+ );\r
+ goto Done;\r
+ }\r
+ // Delete Temporary file.\r
+ ShellDeleteFile (&TmpDumpFileHandle);\r
+ } // -d\r
+ } // -s\r
+ }\r
+\r
+ // Parse ACPI Table information\r
+ Status = AcpiView (SystemTable);\r
+ if (EFI_ERROR (Status)) {\r
+ ShellStatus = SHELL_NOT_FOUND;\r
+ }\r
+ }\r
+ }\r
+\r
+Done:\r
+ if (Package != NULL) {\r
+ ShellCommandLineFreeVarList (Package);\r
+ }\r
+ return ShellStatus;\r
+}\r
+\r
/**\r
Constructor for the Shell AcpiView Command library.\r
\r
/** @file\r
Header file for 'acpiview' Shell command functions.\r
\r
- Copyright (c) 2016 - 2017, ARM Limited. All rights reserved.<BR>\r
+ Copyright (c) 2016 - 2020, ARM Limited. All rights reserved.<BR>\r
SPDX-License-Identifier: BSD-2-Clause-Patent\r
**/\r
\r
/**\r
Function for 'acpiview' 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
+ @param[in] ImageHandle Handle to the Image (NULL if internal).\r
+ @param[in] SystemTable Pointer to the System Table (NULL if internal).\r
+\r
+ @retval SHELL_INVALID_PARAMETER The command line invocation could not be parsed\r
+ @retval SHELL_NOT_FOUND The command failed\r
+ @retval SHELL_SUCCESS The command was successful\r
**/\r
SHELL_STATUS\r
EFIAPI\r