summaryrefslogtreecommitdiff
path: root/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c
diff options
context:
space:
mode:
authorTomas Pilar <Tomas.Pilar@arm.com>2020-06-19 12:59:54 +0100
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2020-06-30 01:39:50 +0000
commit422fe85cc3109684c81990911c79dc18d1828d96 (patch)
tree3f1b0cf5486a1ee359fda307291602a77ccf90f2 /ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c
parente46e3040fc3b39dcade8b88cdc02565ff6b26374 (diff)
downloadedk2-422fe85cc3109684c81990911c79dc18d1828d96.zip
edk2-422fe85cc3109684c81990911c79dc18d1828d96.tar.gz
edk2-422fe85cc3109684c81990911c79dc18d1828d96.tar.bz2
ShellPkg/AcpiView: Move parameter parsing
Parsing command line parameters is done in the shell command wrapper. This declutters the core code and improves modular design. Cc: Ray Ni <ray.ni@intel.com> Cc: Zhichao Gao <zhichao.gao@intel.com> Reviewed-by: Zhichao Gao <zhichao.gao@intel.com> Signed-off-by: Tomas Pilar <tomas.pilar@arm.com>
Diffstat (limited to 'ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c')
-rw-r--r--ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c205
1 files changed, 0 insertions, 205 deletions
diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c
index 4077837..e524fcb 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c
@@ -33,19 +33,6 @@ STATIC UINT32 mTableCount;
STATIC UINT32 mBinTableCount;
/**
- An array of acpiview command line parameters.
-**/
-STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
- {L"-q", TypeFlag},
- {L"-d", TypeFlag},
- {L"-h", TypeFlag},
- {L"-l", TypeFlag},
- {L"-s", TypeValue},
- {L"-r", TypeValue},
- {NULL, TypeMax}
-};
-
-/**
This function dumps the ACPI table to a file.
@param [in] Ptr Pointer to the ACPI table data.
@@ -228,7 +215,6 @@ ProcessTableReportOptions (
Returns EFI_UNSUPPORTED if the RSDP version is less than 2.
Returns EFI_SUCCESS if successful.
**/
-STATIC
EFI_STATUS
EFIAPI
AcpiView (
@@ -372,194 +358,3 @@ AcpiView (
}
return EFI_SUCCESS;
}
-
-/**
- Function for 'acpiview' command.
-
- @param[in] ImageHandle Handle to the Image (NULL if Internal).
- @param[in] SystemTable Pointer to the System Table (NULL if Internal).
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunAcpiView (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE* SystemTable
- )
-{
- EFI_STATUS Status;
- SHELL_STATUS ShellStatus;
- LIST_ENTRY* Package;
- CHAR16* ProblemParam;
- SHELL_FILE_HANDLE TmpDumpFileHandle;
- CONST CHAR16* MandatoryTableSpecStr;
- CONST CHAR16 *SelectedTableName;
-
- // Set configuration defaults
- AcpiConfigSetDefaults ();
-
- ShellStatus = SHELL_SUCCESS;
- Package = NULL;
- TmpDumpFileHandle = NULL;
-
- Status = ShellCommandLineParse (ParamList, &Package, &ProblemParam, TRUE);
- if (EFI_ERROR (Status)) {
- if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
- ShellPrintHiiEx (
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_GEN_PROBLEM),
- gShellAcpiViewHiiHandle,
- L"acpiview",
- ProblemParam
- );
- FreePool (ProblemParam);
- } else {
- Print (L"acpiview: Error processing input parameter(s)\n");
- }
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- if (ShellCommandLineGetCount (Package) > 1) {
- ShellPrintHiiEx (
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_GEN_TOO_MANY),
- gShellAcpiViewHiiHandle,
- L"acpiview"
- );
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else if (ShellCommandLineGetFlag (Package, L"-?")) {
- ShellPrintHiiEx (
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_GET_HELP_ACPIVIEW),
- gShellAcpiViewHiiHandle,
- L"acpiview"
- );
- } else if (ShellCommandLineGetFlag (Package, L"-s") &&
- ShellCommandLineGetValue (Package, L"-s") == NULL) {
- ShellPrintHiiEx (
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_GEN_NO_VALUE),
- gShellAcpiViewHiiHandle,
- L"acpiview",
- L"-s"
- );
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else if (ShellCommandLineGetFlag (Package, L"-r") &&
- ShellCommandLineGetValue (Package, L"-r") == NULL) {
- ShellPrintHiiEx (
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_GEN_NO_VALUE),
- gShellAcpiViewHiiHandle,
- L"acpiview",
- L"-r"
- );
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else if ((ShellCommandLineGetFlag (Package, L"-s") &&
- ShellCommandLineGetFlag (Package, L"-l"))) {
- ShellPrintHiiEx (
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_GEN_TOO_MANY),
- gShellAcpiViewHiiHandle,
- L"acpiview"
- );
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else if (ShellCommandLineGetFlag (Package, L"-d") &&
- !ShellCommandLineGetFlag (Package, L"-s")) {
- ShellPrintHiiEx (
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_GEN_MISSING_OPTION),
- gShellAcpiViewHiiHandle,
- L"acpiview",
- L"-s",
- L"-d"
- );
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else {
- // Turn on colour highlighting if requested
- SetColourHighlighting (ShellCommandLineGetFlag (Package, L"-h"));
-
- // Surpress consistency checking if requested
- SetConsistencyChecking (!ShellCommandLineGetFlag (Package, L"-q"));
-
- // Evaluate the parameters for mandatory ACPI table presence checks
- SetMandatoryTableValidate (ShellCommandLineGetFlag (Package, L"-r"));
- MandatoryTableSpecStr = ShellCommandLineGetValue (Package, L"-r");
-
- if (MandatoryTableSpecStr != NULL) {
- SetMandatoryTableSpec (ShellHexStrToUintn (MandatoryTableSpecStr));
- }
-
- if (ShellCommandLineGetFlag (Package, L"-l")) {
- SetReportOption (ReportTableList);
- } else {
- SelectedTableName = ShellCommandLineGetValue (Package, L"-s");
- if (SelectedTableName != NULL) {
- SelectAcpiTable (SelectedTableName);
- SetReportOption (ReportSelected);
-
- if (ShellCommandLineGetFlag (Package, L"-d")) {
- // Create a temporary file to check if the media is writable.
- CHAR16 FileNameBuffer[MAX_FILE_NAME_LEN];
- SetReportOption (ReportDumpBinFile);
-
- UnicodeSPrint (
- FileNameBuffer,
- sizeof (FileNameBuffer),
- L".\\%s%04d.tmp",
- SelectedTableName,
- mBinTableCount
- );
-
- Status = ShellOpenFileByName (
- FileNameBuffer,
- &TmpDumpFileHandle,
- EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE |
- EFI_FILE_MODE_CREATE,
- 0
- );
-
- if (EFI_ERROR (Status)) {
- ShellStatus = SHELL_INVALID_PARAMETER;
- TmpDumpFileHandle = NULL;
- ShellPrintHiiEx (
- -1,
- -1,
- NULL,
- STRING_TOKEN (STR_GEN_READONLY_MEDIA),
- gShellAcpiViewHiiHandle,
- L"acpiview"
- );
- goto Done;
- }
- // Delete Temporary file.
- ShellDeleteFile (&TmpDumpFileHandle);
- } // -d
- } // -s
- }
-
- // Parse ACPI Table information
- Status = AcpiView (SystemTable);
- if (EFI_ERROR (Status)) {
- ShellStatus = SHELL_NOT_FOUND;
- }
- }
- }
-
-Done:
- if (Package != NULL) {
- ShellCommandLineFreeVarList (Package);
- }
- return ShellStatus;
-}