From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from EUR03-AM5-obe.outbound.protection.outlook.com (EUR03-AM5-obe.outbound.protection.outlook.com [40.107.3.69]) by mx.groups.io with SMTP id smtpd.web11.1917.1590086690211404137 for ; Thu, 21 May 2020 11:44:50 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@armh.onmicrosoft.com header.s=selector2-armh-onmicrosoft-com header.b=p+iIo7Vt; spf=pass (domain: arm.com, ip: 40.107.3.69, mailfrom: tomas.pilar@arm.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=hxcGxfNvnVywABc9aAl37AEvOtIrBb93AV9GF5QaKmk=; b=p+iIo7VtBd54V5kw/vhEDsl8Ib7USTWVlasRfkzRibdgjUpRfiF1bUs1B76VE3VrE+iWDXf+qvzt4zGIZV3o75suyCpOZlU2tdHXwvMX9Da+Ztbyzgpb1rznG+v1JVJmSGWSp1J/lYwn4yHYWT42VCQdz5xF04T5gAWdoSoWvC8= Received: from AM6P193CA0126.EURP193.PROD.OUTLOOK.COM (2603:10a6:209:85::31) by AM4PR0802MB2372.eurprd08.prod.outlook.com (2603:10a6:200:60::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3021.24; Thu, 21 May 2020 18:44:47 +0000 Received: from VE1EUR03FT025.eop-EUR03.prod.protection.outlook.com (2603:10a6:209:85:cafe::fa) by AM6P193CA0126.outlook.office365.com (2603:10a6:209:85::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3021.23 via Frontend Transport; Thu, 21 May 2020 18:44:47 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; edk2.groups.io; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;edk2.groups.io; dmarc=bestguesspass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by VE1EUR03FT025.mail.protection.outlook.com (10.152.18.74) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3021.23 via Frontend Transport; Thu, 21 May 2020 18:44:46 +0000 Received: ("Tessian outbound 14e212f6ce41:v57"); Thu, 21 May 2020 18:44:46 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: af47a69c476f7064 X-CR-MTA-TID: 64aa7808 Received: from 9bf7c922be3e.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id A9F2304F-D0BD-432C-9067-1FFE6D542828.1; Thu, 21 May 2020 18:44:41 +0000 Received: from EUR04-DB3-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 9bf7c922be3e.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 21 May 2020 18:44:41 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=REu4wemXrHpy0FBjUOgT9wANAnS29NSiJSHxVDFju4sJ5dNQESsfmOcLL+eJuU5HH/18Z9jlajV3hrsZnTwuXWisRv7DSwNVDWHVav/qXc7YIGmf+c9LU/aZhzIyVkUyBc7BMMPrQGzumJJhtHlF7NY/yCAvDwDz8fWDg+KE6xb04i78i5zFBf/Q83pJ98JuQExK4xvQCvhtTygb0c+g1JNqoVZRgq++NV1cBxlffdjnDuOeXdIEOFqhwPYCA32M+QIWf7U/oilG0xIDAaOaC8rj86/kQKUvg0ARLDDRVFkWBLztLT0WukmiL9kAIC5IWwHWT8tgtOlDDSxLE5em7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=hxcGxfNvnVywABc9aAl37AEvOtIrBb93AV9GF5QaKmk=; b=DsZTBUFgcDSvo6AEkRaZL43lnjX+vOoyX3L+IfTztfDDpHii4NMXCNnoHDMXrA33Pf2IDUZj7GUotfGzVw7bprAa5BFifs+XiRO3NvZqIXfALFI1qUN5eew8LUICxCihox5Ze20FNB+QqFceKM6cPJxbSn+LkhK78JEq1I0xR1Y10kDlW6d7vhuXvTP3UwNMeVKiZTklG6L+QJ61qY0NPlPHLmpj66YMOeopDkCMHaCuaExpcrB0/4sgmMQGZQl0oIIr7MwoviAjQuqlc3IofR2JK7vYSKP13sv4nAj0msfLiBicUNSkTF9ZRGgIXNx/YTzIw5Vigm1EVcaHoNir4w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 40.67.248.234) smtp.rcpttodomain=edk2.groups.io smtp.mailfrom=arm.com; dmarc=bestguesspass action=none header.from=arm.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=hxcGxfNvnVywABc9aAl37AEvOtIrBb93AV9GF5QaKmk=; b=p+iIo7VtBd54V5kw/vhEDsl8Ib7USTWVlasRfkzRibdgjUpRfiF1bUs1B76VE3VrE+iWDXf+qvzt4zGIZV3o75suyCpOZlU2tdHXwvMX9Da+Ztbyzgpb1rznG+v1JVJmSGWSp1J/lYwn4yHYWT42VCQdz5xF04T5gAWdoSoWvC8= Received: from AM3PR05CA0147.eurprd05.prod.outlook.com (2603:10a6:207:3::25) by DB6PR0802MB2358.eurprd08.prod.outlook.com (2603:10a6:4:89::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3021.23; Thu, 21 May 2020 18:44:39 +0000 Received: from AM5EUR03FT059.eop-EUR03.prod.protection.outlook.com (2603:10a6:207:3:cafe::87) by AM3PR05CA0147.outlook.office365.com (2603:10a6:207:3::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3021.24 via Frontend Transport; Thu, 21 May 2020 18:44:39 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 40.67.248.234) smtp.mailfrom=arm.com; edk2.groups.io; dkim=none (message not signed) header.d=none;edk2.groups.io; dmarc=bestguesspass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 40.67.248.234 as permitted sender) receiver=protection.outlook.com; client-ip=40.67.248.234; helo=nebula.arm.com; Received: from nebula.arm.com (40.67.248.234) by AM5EUR03FT059.mail.protection.outlook.com (10.152.17.193) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.3021.23 via Frontend Transport; Thu, 21 May 2020 18:44:39 +0000 Received: from AZ-NEU-EX04.Arm.com (10.251.24.32) by AZ-NEU-EX03.Arm.com (10.251.24.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1415.2; Thu, 21 May 2020 18:44:38 +0000 Received: from localhost.localdomain (10.57.25.130) by mail.arm.com (10.251.24.32) with Microsoft SMTP Server id 15.1.1415.2 via Frontend Transport; Thu, 21 May 2020 18:44:38 +0000 From: "Tomas Pilar (tpilar)" To: CC: , Ray Ni , Zhichao Gao Subject: [PATCH v2 2/6] ShellPkg/AcpiView: Refactor configuration Date: Thu, 21 May 2020 19:44:17 +0100 Message-ID: <20200521184421.2222-3-Tomas.Pilar@arm.com> X-Mailer: git-send-email 2.24.1.windows.2 In-Reply-To: <20200521184421.2222-1-Tomas.Pilar@arm.com> References: <20200521184421.2222-1-Tomas.Pilar@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report-Untrusted: CIP:40.67.248.234;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:nebula.arm.com;PTR:InfoDomainNonexistent;CAT:NONE;SFTY:;SFS:(4636009)(376002)(396003)(346002)(136003)(39860400002)(46966005)(82740400003)(19627235002)(54906003)(47076004)(70206006)(36756003)(2906002)(316002)(8936002)(8676002)(70586007)(6916009)(186003)(356005)(81166007)(426003)(5660300002)(26005)(478600001)(2616005)(4326008)(30864003)(86362001)(1076003)(6666004)(336012)(82310400002);DIR:OUT;SFP:1101; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 48de11a0-dc0b-4578-fd24-08d7fdb70902 X-MS-TrafficTypeDiagnostic: DB6PR0802MB2358:|AM4PR0802MB2372: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:5236;OLM:5236; X-Forefront-PRVS: 041032FF37 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: pO1mycDzcP/pqhMobGpUC4nWSqf2hlGT69AZC8WqZ2Zdj11NDdEmZ/yb/kskSUde6vx6Z/0z3yOhuBTvX6tJfRshUhb8mKmD/37tq1kPpK2UqA9MtszuKNLp7QqX7urRPIethWFhM++RnQEGZGYyqGppEyawIswZ/8ACNjhvFD5h5SLhEpFsrzVvS/SqcK1tEDbj3RdLeY3xnsC4HhrYXHQ4LPJcYtZ36Zs4YtQcQfFmFwFlARjzMhG54E0wo6oBZQtb5lUrBD6Su98ZyCj8YvlVQUtrow7Jt5Pm0dRaQf6nuwijrHOgkE/5R1TwjWudZZ2zPCzC0Yw7vU72r4dFVH5NOsFVBjRu8ZFWnZqkhNgPePIvW9WIbg5ETB5CQ1D06XBgd0z5TXX0YG7W9zuo3w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR0802MB2358 Return-Path: Tomas.Pilar@arm.com X-MS-Exchange-Transport-CrossTenantHeadersStripped: VE1EUR03FT025.eop-EUR03.prod.protection.outlook.com X-Forefront-Antispam-Report: CIP:63.35.35.123;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:64aa7808-outbound-1.mta.getcheckrecipient.com;PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com;CAT:NONE;SFTY:;SFS:(4636009)(346002)(396003)(376002)(136003)(39860400002)(46966005)(36906005)(316002)(54906003)(4326008)(19627235002)(5660300002)(30864003)(2906002)(36756003)(70586007)(426003)(1076003)(186003)(336012)(6666004)(70206006)(26005)(82310400002)(2616005)(81166007)(8936002)(8676002)(478600001)(86362001)(47076004)(82740400003)(6916009)(107886003);DIR:OUT;SFP:1101; X-MS-Office365-Filtering-Correlation-Id-Prvs: 5da3b13d-20ff-48ea-98f0-08d7fdb70470 X-Forefront-PRVS: 041032FF37 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: LY8/yHPq6t2LJhjkI1ohyS5IBRNKtQF3hoGCQzwLLUgjDLS5eyLo+JnEpPmq5X3fDLId/zWq0hNVX4vbmjdbk7RTj7bDCv9vICX7tiMHFP7Xl6jWQhZpvO4mOolB06MbMrlb2Rl1Fpru3aWBiKmk1cRsDB9Fs85LIP+QY/wMtbGcl7EZ5CQHbc5BkIlAR6XBQwcmoWTq0OzR8ZsDm4nyGYzDXoKsBU400hNZ1M7BRS+luLjTG9SCkPt781CkNWO1eNvQ22lgRLlL8Xlw2vVXeJgtzk7G5c1Q+5S3iJ1o049nlRE+C/z1hwNpyiVH9IhKYDGljan/DXc/HVMFHBEVvDdVtSRhdZEKJfVFzlbT0IEB6NzY5qodUFpp2GLb0GKZL9O8VDkbFwVnTv/KGatfIQ== X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 May 2020 18:44:46.6868 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 48de11a0-dc0b-4578-fd24-08d7fdb70902 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d;Ip=[63.35.35.123];Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM4PR0802MB2372 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain A new file and header (AcpiViewConfig.[ch]) is created that houses the user configuration. This declutters the core code and improves modularity of the design. The module level symbols for verbosity, table selection, and highlighting are refactored into the new file. Cc: Ray Ni Cc: Zhichao Gao Signed-off-by: Tomas Pilar --- ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c = | 1 + ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiTableParser.c = | 1 + ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c = | 237 +++++++++---------------------------------------------------------= - ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.h = | 95 --------------------------- ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiViewConfig.c = | 246 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++= ++++ ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiViewConfig.h = | 177 ++++++++++++++++++++++++++++++++++++++++++++++++++ ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Gtdt/GtdtParser.c = | 1 + ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Iort/IortParser.c = | 1 + ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Madt/MadtParser.c = | 1 + ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pptt/PpttParser.c = | 1 + ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Srat/SratParser.c = | 1 + ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.i= nf | 32 ++++----- 12 files changed, 479 insertions(+), 315 deletions(-) diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c b/Sh= ellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c index 3f12a33050a4..02f6d771c7e1 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c @@ -10,6 +10,7 @@ #include #include "AcpiParser.h" #include "AcpiView.h" +#include "AcpiViewConfig.h" =20 STATIC UINT32 gIndent; STATIC UINT32 mTableErrorCount; diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiTableParser.c= b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiTableParser.c index d5b9eee52323..4b618f131eac 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiTableParser.c +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiTableParser.c @@ -17,6 +17,7 @@ #include "AcpiParser.h" #include "AcpiTableParser.h" #include "AcpiView.h" +#include "AcpiViewConfig.h" =20 #if defined(MDE_CPU_ARM) || defined (MDE_CPU_AARCH64) #include "Arm/SbbrValidator.h" diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c b/Shel= lPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c index f1a95b7b8f03..2f7395c23bce 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c @@ -20,6 +20,7 @@ #include "AcpiParser.h" #include "AcpiTableParser.h" #include "AcpiView.h" +#include "AcpiViewConfig.h" #include "UefiShellAcpiViewCommandLib.h" =20 #if defined(MDE_CPU_ARM) || defined (MDE_CPU_AARCH64) @@ -28,17 +29,8 @@ =20 EFI_HII_HANDLE gShellAcpiViewHiiHandle =3D NULL; =20 -// Report variables -STATIC UINT32 mSelectedAcpiTable; -STATIC CONST CHAR16* mSelectedAcpiTableName; -STATIC BOOLEAN mSelectedAcpiTableFound; -STATIC EREPORT_OPTION mReportType; STATIC UINT32 mTableCount; STATIC UINT32 mBinTableCount; -STATIC BOOLEAN mConsistencyCheck; -STATIC BOOLEAN mColourHighlighting; -STATIC BOOLEAN mMandatoryTableValidate; -STATIC UINTN mMandatoryTableSpec; =20 /** An array of acpiview command line parameters. @@ -53,142 +45,6 @@ STATIC CONST SHELL_PARAM_ITEM ParamList[] =3D { {NULL, TypeMax} }; =20 -/** - This function returns the colour highlighting status. - - @retval TRUE if colour highlighting is enabled. -**/ -BOOLEAN -GetColourHighlighting ( - VOID - ) -{ - return mColourHighlighting; -} - -/** - This function sets the colour highlighting status. - - @param Highlight The Highlight status. - -**/ -VOID -SetColourHighlighting ( - BOOLEAN Highlight - ) -{ - mColourHighlighting =3D Highlight; -} - -/** - This function returns the consistency checking status. - - @retval TRUE if consistency checking is enabled. -**/ -BOOLEAN -GetConsistencyChecking ( - VOID - ) -{ - return mConsistencyCheck; -} - -/** - This function sets the consistency checking status. - - @param ConsistencyChecking The consistency checking status. - -**/ -VOID -SetConsistencyChecking ( - BOOLEAN ConsistencyChecking - ) -{ - mConsistencyCheck =3D ConsistencyChecking; -} - -/** - This function returns the ACPI table requirements validation flag. - - @retval TRUE if check for mandatory table presence should be performed. -**/ -BOOLEAN -GetMandatoryTableValidate ( - VOID - ) -{ - return mMandatoryTableValidate; -} - -/** - This function sets the ACPI table requirements validation flag. - - @param Validate Enable/Disable ACPI table requirements validation. -**/ -VOID -SetMandatoryTableValidate ( - BOOLEAN Validate - ) -{ - mMandatoryTableValidate =3D Validate; -} - -/** - This function returns the identifier of specification to validate ACPI t= able - requirements against. - - @return ID of specification listing mandatory tables. -**/ -UINTN -GetMandatoryTableSpec ( - VOID - ) -{ - return mMandatoryTableSpec; -} - -/** - This function sets the identifier of specification to validate ACPI tabl= e - requirements against. - - @param Spec ID of specification listing mandatory tables. -**/ -VOID -SetMandatoryTableSpec ( - UINTN Spec - ) -{ - mMandatoryTableSpec =3D Spec; -} - -/** - This function returns the report options. - - @retval Returns the report option. -**/ -STATIC -EREPORT_OPTION -GetReportOption ( - VOID - ) -{ - return mReportType; -} - -/** - This function returns the selected ACPI table. - - @retval Returns signature of the selected ACPI table. -**/ -STATIC -UINT32 -GetSelectedAcpiTable ( - VOID - ) -{ - return mSelectedAcpiTable; -} - /** This function dumps the ACPI table to a file. =20 @@ -205,19 +61,21 @@ DumpAcpiTableToFile ( IN CONST UINTN Length ) { - EFI_STATUS Status; - CHAR16 FileNameBuffer[MAX_FILE_NAME_LEN]; - SHELL_FILE_HANDLE DumpFileHandle; - UINTN TransferBytes; + EFI_STATUS Status; + CHAR16 FileNameBuffer[MAX_FILE_NAME_LEN]; + SHELL_FILE_HANDLE DumpFileHandle; + UINTN TransferBytes; + SELECTED_ACPI_TABLE SelectedTable; =20 DumpFileHandle =3D NULL; TransferBytes =3D Length; + GetSelectedAcpiTable (&SelectedTable); =20 UnicodeSPrint ( FileNameBuffer, sizeof (FileNameBuffer), L".\\%s%04d.bin", - mSelectedAcpiTableName, + SelectedTable.Name, mBinTableCount++ ); =20 @@ -273,10 +131,11 @@ ProcessTableReportOptions ( IN CONST UINT32 Length ) { - UINTN OriginalAttribute; - UINT8* SignaturePtr; - BOOLEAN Log; - BOOLEAN HighLight; + UINTN OriginalAttribute; + UINT8 *SignaturePtr; + BOOLEAN Log; + BOOLEAN HighLight; + SELECTED_ACPI_TABLE SelectedTable; =20 // // set local variables to suppress incorrect compiler/analyzer warnings @@ -285,15 +144,16 @@ ProcessTableReportOptions ( SignaturePtr =3D (UINT8*)(UINTN)&Signature; Log =3D FALSE; HighLight =3D GetColourHighlighting (); + GetSelectedAcpiTable (&SelectedTable); =20 switch (GetReportOption ()) { case ReportAll: Log =3D TRUE; break; case ReportSelected: - if (Signature =3D=3D GetSelectedAcpiTable ()) { + if (Signature =3D=3D SelectedTable.Type) { Log =3D TRUE; - mSelectedAcpiTableFound =3D TRUE; + SelectedTable.Found =3D TRUE; } break; case ReportTableList: @@ -321,8 +181,8 @@ ProcessTableReportOptions ( ); break; case ReportDumpBinFile: - if (Signature =3D=3D GetSelectedAcpiTable ()) { - mSelectedAcpiTableFound =3D TRUE; + if (Signature =3D=3D SelectedTable.Type) { + SelectedTable.Found =3D TRUE; DumpAcpiTableToFile (TablePtr, Length); } break; @@ -356,37 +216,7 @@ ProcessTableReportOptions ( return Log; } =20 -/** - This function converts a string to ACPI table signature. - - @param [in] Str Pointer to the string to be converted to the - ACPI table signature. =20 - @retval The ACPI table signature. -**/ -STATIC -UINT32 -ConvertStrToAcpiSignature ( - IN CONST CHAR16* Str - ) -{ - UINT8 Index; - CHAR8 Ptr[4]; - - ZeroMem (Ptr, sizeof (Ptr)); - Index =3D 0; - - // Convert to Upper case and convert to ASCII - while ((Index < 4) && (Str[Index] !=3D 0)) { - if (Str[Index] >=3D L'a' && Str[Index] <=3D L'z') { - Ptr[Index] =3D (CHAR8)(Str[Index] - (L'a' - L'A')); - } else { - Ptr[Index] =3D (CHAR8)Str[Index]; - } - Index++; - } - return *(UINT32*)Ptr; -} =20 /** This function iterates the configuration table entries in the @@ -417,6 +247,7 @@ AcpiView ( UINT8 RsdpRevision; PARSE_ACPI_TABLE_PROC RsdpParserProc; BOOLEAN Trace; + SELECTED_ACPI_TABLE SelectedTable; =20 // // set local variables to suppress incorrect compiler/analyzer warnings @@ -428,6 +259,9 @@ AcpiView ( ResetErrorCount (); ResetWarningCount (); =20 + // Retrieve the user selection of ACPI table to process + GetSelectedAcpiTable (&SelectedTable); + // Search the table for an entry that matches the ACPI Table Guid FoundAcpiTable =3D FALSE; for (Index =3D 0; Index < SystemTable->NumberOfTableEntries; Index++) { @@ -496,7 +330,7 @@ AcpiView ( if (ReportTableList !=3D ReportOption) { if (((ReportSelected =3D=3D ReportOption) || (ReportDumpBinFile =3D=3D ReportOption)) && - (!mSelectedAcpiTableFound)) { + (!SelectedTable.Found)) { Print (L"\nRequested ACPI Table not found.\n"); } else if (GetConsistencyChecking () && (ReportDumpBinFile !=3D ReportOption)) { @@ -554,17 +388,12 @@ ShellCommandRunAcpiView ( CHAR16* ProblemParam; SHELL_FILE_HANDLE TmpDumpFileHandle; CONST CHAR16* MandatoryTableSpecStr; + CONST CHAR16 *SelectedTableName; =20 // Set Defaults - mReportType =3D ReportAll; mTableCount =3D 0; mBinTableCount =3D 0; - mSelectedAcpiTable =3D 0; - mSelectedAcpiTableName =3D NULL; - mSelectedAcpiTableFound =3D FALSE; - mConsistencyCheck =3D TRUE; - mMandatoryTableValidate =3D FALSE; - mMandatoryTableSpec =3D 0; + AcpiConfigSetDefaults (); =20 ShellStatus =3D SHELL_SUCCESS; Package =3D NULL; @@ -671,25 +500,23 @@ ShellCommandRunAcpiView ( } =20 if (ShellCommandLineGetFlag (Package, L"-l")) { - mReportType =3D ReportTableList; + SetReportOption (ReportTableList); } else { - mSelectedAcpiTableName =3D ShellCommandLineGetValue (Package, L"-s= "); - if (mSelectedAcpiTableName !=3D NULL) { - mSelectedAcpiTable =3D (UINT32)ConvertStrToAcpiSignature ( - mSelectedAcpiTableName - ); - mReportType =3D ReportSelected; + SelectedTableName =3D ShellCommandLineGetValue (Package, L"-s"); + if (SelectedTableName !=3D NULL) { + SelectAcpiTable (SelectedTableName); + SetReportOption (ReportSelected); =20 if (ShellCommandLineGetFlag (Package, L"-d")) { // Create a temporary file to check if the media is writable. CHAR16 FileNameBuffer[MAX_FILE_NAME_LEN]; - mReportType =3D ReportDumpBinFile; + SetReportOption (ReportDumpBinFile); =20 UnicodeSPrint ( FileNameBuffer, sizeof (FileNameBuffer), L".\\%s%04d.tmp", - mSelectedAcpiTableName, + SelectedTableName, mBinTableCount ); =20 diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.h b/Shel= lPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.h index be65564c86a6..92d64a88814d 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.h +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.h @@ -23,17 +23,6 @@ **/ #define RSDP_LENGTH_OFFSET 20 =20 -/** - The EREPORT_OPTION enum describes ACPI table Reporting options. -**/ -typedef enum ReportOption { - ReportAll, ///< Report All tables. - ReportSelected, ///< Report Selected table. - ReportTableList, ///< Report List of tables. - ReportDumpBinFile, ///< Dump selected table to a file. - ReportMax, -} EREPORT_OPTION; - /** This function resets the ACPI table error counter to Zero. **/ @@ -70,90 +59,6 @@ GetWarningCount ( VOID ); =20 -/** - This function returns the colour highlighting status. - - @retval TRUE if colour highlighting is enabled. -**/ -BOOLEAN -GetColourHighlighting ( - VOID - ); - -/** - This function sets the colour highlighting status. - - @param Highlight The Highlight status. - -**/ -VOID -SetColourHighlighting ( - BOOLEAN Highlight - ); - -/** - This function returns the consistency checking status. - - @retval TRUE if consistency checking is enabled. -**/ -BOOLEAN -GetConsistencyChecking ( - VOID - ); - -/** - This function sets the consistency checking status. - - @param ConsistencyChecking The consistency checking status. - -**/ -VOID -SetConsistencyChecking ( - BOOLEAN ConsistencyChecking - ); - -/** - This function returns the ACPI table requirements validation flag. - - @retval TRUE if check for mandatory table presence should be performed. -**/ -BOOLEAN -GetMandatoryTableValidate ( - VOID - ); - -/** - This function sets the ACPI table requirements validation flag. - - @param Validate Enable/Disable ACPI table requirements validation. -**/ -VOID -SetMandatoryTableValidate ( - BOOLEAN Validate - ); - -/** - This function returns the identifier of specification to validate ACPI t= able - requirements against. - - @return ID of specification listing mandatory tables. -**/ -UINTN -GetMandatoryTableSpec ( - VOID - ); - -/** - This function sets the identifier of specification to validate ACPI tabl= e - requirements against. - - @param Spec ID of specification listing mandatory tables. -**/ -VOID -SetMandatoryTableSpec ( - UINTN Spec - ); - /** This function processes the table reporting options for the ACPI table. =20 diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiViewConfig.c = b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiViewConfig.c new file mode 100644 index 000000000000..6f6d1a9d52c1 --- /dev/null +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiViewConfig.c @@ -0,0 +1,246 @@ +/** @file + State and accessors for 'acpiview' configuration. + + Copyright (c) 2016 - 2020, ARM Limited. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +#include +#include + +#include "AcpiViewConfig.h" + +// Report variables +STATIC BOOLEAN mConsistencyCheck; +STATIC BOOLEAN mColourHighlighting; +STATIC EREPORT_OPTION mReportType; +STATIC BOOLEAN mMandatoryTableValidate; +STATIC UINTN mMandatoryTableSpec; + +// User selection of which ACPI table should be checked +SELECTED_ACPI_TABLE mSelectedAcpiTable; + +/** + Reset the AcpiView user configuration to defaults +**/ +VOID +EFIAPI +AcpiConfigSetDefaults ( + VOID + ) +{ + mReportType =3D ReportAll; + mSelectedAcpiTable.Type =3D 0; + mSelectedAcpiTable.Name =3D NULL; + mSelectedAcpiTable.Found =3D FALSE; + mConsistencyCheck =3D TRUE; + mMandatoryTableValidate =3D FALSE; + mMandatoryTableSpec =3D 0; +} + +/** + This function converts a string to ACPI table signature. + + @param [in] Str Pointer to the string to be converted to the + ACPI table signature. + + @retval The ACPI table signature. +**/ +STATIC +UINT32 +ConvertStrToAcpiSignature ( + IN CONST CHAR16 *Str + ) +{ + UINT8 Index; + CHAR8 Ptr[4]; + + ZeroMem (Ptr, sizeof (Ptr)); + Index =3D 0; + + // Convert to Upper case and convert to ASCII + while ((Index < 4) && (Str[Index] !=3D 0)) { + if (Str[Index] >=3D L'a' && Str[Index] <=3D L'z') { + Ptr[Index] =3D (CHAR8)(Str[Index] - (L'a' - L'A')); + } else { + Ptr[Index] =3D (CHAR8)Str[Index]; + } + Index++; + } + return *(UINT32 *) Ptr; +} + +/** + This function selects an ACPI table in current context. + The string name of the table is converted into UINT32 + table signature. + + @param [in] TableName The name of the ACPI table to select. +**/ +VOID +EFIAPI +SelectAcpiTable ( + IN CONST CHAR16 *TableName + ) +{ + ASSERT (TableName !=3D NULL); + + mSelectedAcpiTable.Name =3D TableName; + mSelectedAcpiTable.Type =3D ConvertStrToAcpiSignature (mSelectedAcpiTabl= e.Name); +} + +/** + This function returns the selected ACPI table. + + @param [out] SelectedAcpiTable Pointer that will contain the returned st= ruct. +**/ +VOID +EFIAPI +GetSelectedAcpiTable ( + OUT SELECTED_ACPI_TABLE *SelectedAcpiTable + ) +{ + *SelectedAcpiTable =3D mSelectedAcpiTable; +} + +/** + This function returns the colour highlighting status. + + @retval TRUE Colour highlighting is enabled. +**/ +BOOLEAN +EFIAPI +GetColourHighlighting ( + VOID + ) +{ + return mColourHighlighting; +} + +/** + This function sets the colour highlighting status. + + @param [in] Highlight The highlight status. +**/ +VOID +EFIAPI +SetColourHighlighting ( + BOOLEAN Highlight + ) +{ + mColourHighlighting =3D Highlight; +} + +/** + This function returns the consistency checking status. + + @retval TRUE Consistency checking is enabled. +**/ +BOOLEAN +EFIAPI +GetConsistencyChecking ( + VOID + ) +{ + return mConsistencyCheck; +} + +/** + This function sets the consistency checking status. + + @param [in] ConsistencyChecking The consistency checking status. +**/ +VOID +EFIAPI +SetConsistencyChecking ( + BOOLEAN ConsistencyChecking + ) +{ + mConsistencyCheck =3D ConsistencyChecking; +} + +/** + This function returns the report options. + + @return The current report option. +**/ +EREPORT_OPTION +EFIAPI +GetReportOption ( + VOID + ) +{ + return mReportType; +} + +/** + This function sets the report options. + + @param [in] ReportType The report option to set. +**/ +VOID +EFIAPI +SetReportOption ( + EREPORT_OPTION ReportType + ) +{ + mReportType =3D ReportType; +} + +/** + This function returns the ACPI table requirements validation flag. + + @retval TRUE Check for mandatory table presence should be performed. +**/ +BOOLEAN +EFIAPI +GetMandatoryTableValidate ( + VOID + ) +{ + return mMandatoryTableValidate; +} + +/** + This function sets the ACPI table requirements validation flag. + + @param [in] Validate Enable/Disable ACPI table requirements validation. +**/ +VOID +EFIAPI +SetMandatoryTableValidate ( + BOOLEAN Validate + ) +{ + mMandatoryTableValidate =3D Validate; +} + +/** + This function returns the identifier of specification to validate ACPI t= able + requirements against. + + @return ID of specification listing mandatory tables. +**/ +UINTN +EFIAPI +GetMandatoryTableSpec ( + VOID + ) +{ + return mMandatoryTableSpec; +} + +/** + This function sets the identifier of specification to validate ACPI tabl= e + requirements against. + + @param [in] Spec ID of specification listing mandatory tables. +**/ +VOID +EFIAPI +SetMandatoryTableSpec ( + UINTN Spec + ) +{ + mMandatoryTableSpec =3D Spec; +} diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiViewConfig.h = b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiViewConfig.h new file mode 100644 index 000000000000..fc99624e41dc --- /dev/null +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiViewConfig.h @@ -0,0 +1,177 @@ +/** @file + Header file for 'acpiview' configuration. + + Copyright (c) 2016 - 2020, ARM Limited. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +#ifndef ACPI_VIEW_CONFIG_H_ +#define ACPI_VIEW_CONFIG_H_ + +/** + This function returns the colour highlighting status. + + @retval TRUE Colour highlighting is enabled. +**/ +BOOLEAN +EFIAPI +GetColourHighlighting ( + VOID + ); + +/** + This function sets the colour highlighting status. + + @param [in] Highlight The highlight status. +**/ +VOID +EFIAPI +SetColourHighlighting ( + BOOLEAN Highlight + ); + +/** + This function returns the consistency checking status. + + @retval TRUE Consistency checking is enabled. +**/ +BOOLEAN +EFIAPI +GetConsistencyChecking ( + VOID + ); + +/** + This function sets the consistency checking status. + + @param [in] ConsistencyChecking The consistency checking status. +**/ +VOID +EFIAPI +SetConsistencyChecking ( + BOOLEAN ConsistencyChecking + ); + +/** + This function returns the ACPI table requirements validation flag. + + @retval TRUE Check for mandatory table presence should be performed. +**/ +BOOLEAN +EFIAPI +GetMandatoryTableValidate ( + VOID + ); + +/** + This function sets the ACPI table requirements validation flag. + + @param [in] Validate Enable/Disable ACPI table requirements validation. +**/ +VOID +EFIAPI +SetMandatoryTableValidate ( + BOOLEAN Validate + ); + +/** + This function returns the identifier of specification to validate ACPI t= able + requirements against. + + @return ID of specification listing mandatory tables. +**/ +UINTN +EFIAPI +GetMandatoryTableSpec ( + VOID + ); + +/** + This function sets the identifier of specification to validate ACPI tabl= e + requirements against. + + @param [in] Spec ID of specification listing mandatory tables. +**/ +VOID +EFIAPI +SetMandatoryTableSpec ( + UINTN Spec + ); + +/** + The EREPORT_OPTION enum describes ACPI table Reporting options. +**/ +typedef enum { + ReportAll, ///< Report All tables. + ReportSelected, ///< Report Selected table. + ReportTableList, ///< Report List of tables. + ReportDumpBinFile, ///< Dump selected table to a file. + ReportMax, +} EREPORT_OPTION; + +/** + This function returns the report options. + + @return The current report option. +**/ +EREPORT_OPTION +EFIAPI +GetReportOption ( + VOID + ); + +/** + This function sets the report options. + + @param [in] ReportType The report option to set. +**/ +VOID +EFIAPI +SetReportOption ( + EREPORT_OPTION ReportType + ); + +/** + A structure holding the user selection detailing which + ACPI table is to be examined by the AcpiView code. +**/ +typedef struct { + UINT32 Type; ///< 32bit signature of the selected ACPI t= able. + CONST CHAR16* Name; ///< User friendly name of the selected ACP= I table. + BOOLEAN Found; ///< The selected table has been found in t= he system. +} SELECTED_ACPI_TABLE; + +/** + This function returns the selected ACPI table. + + @param [out] SelectedAcpiTable Pointer that will contain the returned st= ruct. +**/ +VOID +EFIAPI +GetSelectedAcpiTable ( + OUT SELECTED_ACPI_TABLE* SelectedAcpiTable + ); + +/** + This function selects an ACPI table in current context. + The string name of the table is converted into UINT32 + table signature. + + @param [in] TableName The name of the ACPI table to select. +**/ +VOID +EFIAPI +SelectAcpiTable ( + CONST CHAR16* TableName + ); + +/** + Reset the AcpiView user configuration to defaults. +**/ +VOID +EFIAPI +AcpiConfigSetDefaults ( + VOID + ); + +#endif // ACPI_VIEW_CONFIG_H_ diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Gtdt/Gtdt= Parser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Gtdt/GtdtPa= rser.c index bdd30ff45c61..d02fc4929d6f 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Gtdt/GtdtParser.= c +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Gtdt/GtdtParser.= c @@ -12,6 +12,7 @@ #include #include "AcpiParser.h" #include "AcpiTableParser.h" +#include "AcpiViewConfig.h" =20 // "The number of GT Block Timers must be less than or equal to 8" #define GT_BLOCK_TIMER_COUNT_MAX 8 diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Iort/Iort= Parser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Iort/IortPa= rser.c index 9a006a01448b..f7447947b230 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Iort/IortParser.= c +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Iort/IortParser.= c @@ -13,6 +13,7 @@ #include #include "AcpiParser.h" #include "AcpiTableParser.h" +#include "AcpiViewConfig.h" =20 // Local variables STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo; diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Madt/Madt= Parser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Madt/MadtPa= rser.c index f85d2b36532c..15aa2392b60c 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Madt/MadtParser.= c +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Madt/MadtParser.= c @@ -15,6 +15,7 @@ #include #include "AcpiParser.h" #include "AcpiTableParser.h" +#include "AcpiViewConfig.h" #include "MadtParser.h" =20 // Local Variables diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pptt/Pptt= Parser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pptt/PpttPa= rser.c index 0db272c16af0..acd2b81bb325 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pptt/PpttParser.= c +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pptt/PpttParser.= c @@ -13,6 +13,7 @@ #include #include "AcpiParser.h" #include "AcpiView.h" +#include "AcpiViewConfig.h" #include "PpttParser.h" =20 // Local variables diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Srat/Srat= Parser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Srat/SratPa= rser.c index 6f66be68cc0b..b9b67820b89f 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Srat/SratParser.= c +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Srat/SratParser.= c @@ -13,6 +13,7 @@ #include #include "AcpiParser.h" #include "AcpiTableParser.h" +#include "AcpiViewConfig.h" =20 // Local Variables STATIC CONST UINT8* SratRAType; diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiView= CommandLib.inf b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpi= ViewCommandLib.inf index d21ecd40a8cf..92de2391b09f 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommand= Lib.inf +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommand= Lib.inf @@ -19,15 +19,14 @@ [Defines] DESTRUCTOR =3D UefiShellAcpiViewCommandLibDestructor =20 [Sources.common] - UefiShellAcpiViewCommandLib.uni - UefiShellAcpiViewCommandLib.c - UefiShellAcpiViewCommandLib.h - AcpiParser.h - AcpiTableParser.h - AcpiView.h AcpiParser.c + AcpiParser.h AcpiTableParser.c + AcpiTableParser.h AcpiView.c + AcpiView.h + AcpiViewConfig.c + AcpiViewConfig.h Parsers/Bgrt/BgrtParser.c Parsers/Dbg2/Dbg2Parser.c Parsers/Dsdt/DsdtParser.c @@ -36,40 +35,43 @@ [Sources.common] Parsers/Gtdt/GtdtParser.c Parsers/Iort/IortParser.c Parsers/Madt/MadtParser.c + Parsers/Madt/MadtParser.h Parsers/Mcfg/McfgParser.c Parsers/Pptt/PpttParser.c + Parsers/Pptt/PpttParser.h Parsers/Rsdp/RsdpParser.c Parsers/Slit/SlitParser.c Parsers/Spcr/SpcrParser.c Parsers/Srat/SratParser.c Parsers/Ssdt/SsdtParser.c Parsers/Xsdt/XsdtParser.c - Parsers/Madt/MadtParser.h - Parsers/Pptt/PpttParser.h + UefiShellAcpiViewCommandLib.c + UefiShellAcpiViewCommandLib.h + UefiShellAcpiViewCommandLib.uni =20 [Sources.ARM, Sources.AARCH64] Arm/SbbrValidator.h Arm/SbbrValidator.c =20 [Packages] + MdeModulePkg/MdeModulePkg.dec MdePkg/MdePkg.dec ShellPkg/ShellPkg.dec - MdeModulePkg/MdeModulePkg.dec =20 [LibraryClasses] - MemoryAllocationLib BaseLib BaseMemoryLib DebugLib + FileHandleLib + HiiLib + MemoryAllocationLib + PcdLib + PrintLib ShellCommandLib ShellLib + UefiBootServicesTableLib UefiLib UefiRuntimeServicesTableLib - UefiBootServicesTableLib - PcdLib - HiiLib - PrintLib - FileHandleLib =20 =20 [FixedPcd] --=20 2.24.1.windows.2