From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by mx.groups.io with SMTP id smtpd.web11.5391.1594363358898025893 for ; Thu, 09 Jul 2020 23:42:39 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@intel.onmicrosoft.com header.s=selector2-intel-onmicrosoft-com header.b=eClvMGKS; spf=pass (domain: intel.com, ip: 192.55.52.88, mailfrom: zhichao.gao@intel.com) IronPort-SDR: G8fxofRHs5O7SFS4ANzT7iazEaACNp6Z9EEM4T5NzzZ0PR1yEhdMEcCNALUCOVcv9mheysmMFx yL2deuWZCJ/g== X-IronPort-AV: E=McAfee;i="6000,8403,9677"; a="166250430" X-IronPort-AV: E=Sophos;i="5.75,334,1589266800"; d="scan'208";a="166250430" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Jul 2020 23:42:37 -0700 IronPort-SDR: ETi6ZfbtEFqHYrD7uWupuTP1Cl+3ubDXBK/8E/B4wTRbvz2963w0xffBL6zSzIG8TQGbOobvMv gT7QH5+Z5nGA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,334,1589266800"; d="scan'208";a="284415428" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by orsmga006.jf.intel.com with ESMTP; 09 Jul 2020 23:42:31 -0700 Received: from fmsmsx609.amr.corp.intel.com (10.18.126.89) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.439.0; Thu, 9 Jul 2020 23:42:31 -0700 Received: from fmsmsx609.amr.corp.intel.com (10.18.126.89) by fmsmsx609.amr.corp.intel.com (10.18.126.89) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Thu, 9 Jul 2020 23:42:30 -0700 Received: from FMSEDG001.ED.cps.intel.com (10.1.192.133) by fmsmsx609.amr.corp.intel.com (10.18.126.89) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.1713.5 via Frontend Transport; Thu, 9 Jul 2020 23:42:30 -0700 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (104.47.66.47) by edgegateway.intel.com (192.55.55.68) with Microsoft SMTP Server (TLS) id 14.3.439.0; Thu, 9 Jul 2020 23:42:30 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ciKNIrKi9iDpPJhXo7Cklt0iguhhe4RSIOIsmdcbdQ5O64TfjposIUR60POIzv/sM2tzj5E7fqWY/1famqSvdGibBGgxpV/WcUn4oW6LmuQG1DBYoOJFydLh/q2WxO4xh3wGNS7Oruvf6UbD1pFYGBIRe5oUNXNCidJ2xkC3+OeGKhDbnFA4+Q2fIz+mGEoAi6pwXk+9RFkfbhjxIs5FCLygAo2Q6i1I9njL8gmGXanFcW7eH/6G3bj9lmq1QC/6ri6+Yjbp2AaXcTbH5uKttNVJeOwg/4lP5dqzqIbt5JPhWqrMPY9bVg0SAYcEAMnTAzOKiTDZJWMknpDwFnA+RQ== 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=6Ll6FpmkOEuB8oN78m/O2zm76vTNgWQomC6hyKwD/CI=; b=WwWU3M2OdPBIwE3lpe/a5BHvaXrzQqY+wgy5pPZ2TzTqUUhzIyoFnpWb+Ip7M3ISHjZcSBksCh+1cSWoI23XFCAtf4UOQbGl4HDys1yZYwSUigrLkLdrAUEwDB/MPPPWJzhI8GF26Wju9xdRNP//nK7BRY1kWPQu/dAaX6Q3YZ7AIOHgbCg7oItVXDkSHBmPbfQiqS8wVbijpwl8IvtvN9KxBSl2H8bccjNuKSWA5yE2cCvBImC5l/wI9voRhePVH/zentjFm/6VTufPMHlmNmAvzP4oj593L5/jhVg0fJ5VWefx0gt/MNLu5AK6Cnp7dBUyrMMqDuBZfIwFD+dGDw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=6Ll6FpmkOEuB8oN78m/O2zm76vTNgWQomC6hyKwD/CI=; b=eClvMGKSvuqiIB+tZtEjZ1V8bMvHTfULtyD39Au3fWdkNmYhk9EzDmNs8KhlS8ec8yczwvqgwNrr3bNlYrUuM6RCLa6yyPVs5SrCSmbzqtowCTNNyPKjOxyQ0gWn92MZV1x/3sMkCPUigOsLWx+Xdqxf7T7DnqOiR9RkAktjCuU= Received: from DM6PR11MB4425.namprd11.prod.outlook.com (2603:10b6:5:1d9::31) by DM6PR11MB2681.namprd11.prod.outlook.com (2603:10b6:5:bd::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.23; Fri, 10 Jul 2020 06:42:28 +0000 Received: from DM6PR11MB4425.namprd11.prod.outlook.com ([fe80::ad34:e1fc:2e7b:d124]) by DM6PR11MB4425.namprd11.prod.outlook.com ([fe80::ad34:e1fc:2e7b:d124%3]) with mapi id 15.20.3174.023; Fri, 10 Jul 2020 06:42:28 +0000 From: "Gao, Zhichao" To: "devel@edk2.groups.io" , "Tomas.Pilar@arm.com" CC: "Sami.Mujawar@arm.com" , "nd@arm.com" , "Ni, Ray" Subject: Re: [edk2-devel] [PATCH 8/8] ShellPkg/AcpiView: Refactor table parsers Thread-Topic: [edk2-devel] [PATCH 8/8] ShellPkg/AcpiView: Refactor table parsers Thread-Index: AQHWTiju8HY2KzofZ0GEb40DMMUNzakAanjQ Date: Fri, 10 Jul 2020 06:42:28 +0000 Message-ID: References: <20200629152008.685-1-Tomas.Pilar@arm.com> <20200629152008.685-9-Tomas.Pilar@arm.com> In-Reply-To: <20200629152008.685-9-Tomas.Pilar@arm.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-reaction: no-action dlp-version: 11.2.0.6 authentication-results: edk2.groups.io; dkim=none (message not signed) header.d=none;edk2.groups.io; dmarc=none action=none header.from=intel.com; x-originating-ip: [192.102.204.38] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 6ed668c1-3089-4724-3c11-08d8249c6a0a x-ms-traffictypediagnostic: DM6PR11MB2681: x-ld-processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:10000; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 9NSY8xym6wo7u5g1N6FRdDms9/Ap5IZ3AxlXatURHdO1BftSgLVlPUT1YJUgo++aDB4WR+GZ3vBhVTe2wirNE+MTXa/Rex+7uUSUvRtIPOqGJjoeJ68/ZJRV9MXIrOs7sxPJPm4HecMbpd46VrEt6/wPZhh5SWC4qgYFSS5lFTAEdyixJ6KAtD+pWpvxbx0VID/yrIu1bYidUIJ1kkegvZnsiLtrTZNREboVYr2EDkv+99LdMWANEJihL//w5s/vkrGkn+HYL0CySj8RWpkLfa07e+2kpPku568o/Sr7d4CGsEJ0tLrxQOAUJ1Z6mpZ2xGxMb5vJFyM0dF6gFTjcQ6Irg6o0YCVZ7TVQmrET26OH96BxgbJ48PbJV5cHpLQPK/a+P1FFhXZVjdw/Pa6VGA== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR11MB4425.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:(4636009)(376002)(39860400002)(346002)(366004)(396003)(136003)(316002)(71200400001)(66446008)(64756008)(66556008)(66476007)(54906003)(110136005)(107886003)(76116006)(66946007)(83380400001)(966005)(2906002)(7696005)(9686003)(33656002)(86362001)(478600001)(6506007)(26005)(53546011)(8936002)(19627235002)(8676002)(186003)(55016002)(30864003)(5660300002)(4326008)(52536014)(559001)(579004);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata: 2oeSPB20Zph9unB8Pt6MuAZ9WmSocXyAuNf8EXvBgwTpxKlitlxwdSPvxyrU1ysyZBz8edTm3sNN7XTgLWdFb3dVIAKuGCDu69cd9if1vAeX+eHPbYUvzt7M92oWlB95PdGpndoKg3YtIbRa9h5pHlMBRw40EJFlgJVltANaUmZKPRMlAWvyx2m0jXwSSuefp4e/NNF769VK/FCJJaFcbXaxT+OMLYMewqFnnXTF1iU64T/McSxevb69EnB+CkRYndeQ5zwkZXVXanOT5/TnXfvH7S4YzoxAtDlIxbNgx4NDskksheijRAOh6ONwDZZpf+gD+tuUDQa3BT9lqgpaR3S5E2fOqNB/rMK6aRdvjIxxztQX9uChirUOmNJYkaYRP7pLJNWNTvM5Qk95Up6xCGtG0SNR7hlrFL9tTn6R5+23Y+GMsrlGEZB4hYIoMvJ+OTb5O1q95CYaQ0oycsKqZ9Zrqt7gxMFglIXg3IK48jLZRj9iIfgGGtk517Y8Pnei MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: DM6PR11MB4425.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6ed668c1-3089-4724-3c11-08d8249c6a0a X-MS-Exchange-CrossTenant-originalarrivaltime: 10 Jul 2020 06:42:28.3809 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: 0WPrHPN+970YySVNRmHLJjdU8y3IPAU1RebU4NN8t1KwkQkhAFk3RVMAUsg9xUmcF4L1gx3i7UePwxWWjTrtlg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR11MB2681 Return-Path: zhichao.gao@intel.com X-OriginatorOrg: intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable It is highly unrecommended to initializes the local variable at its declara= tion like below. I didn't find the rule in the CCS 2.1 spec. But most of th= e edk2 code never do like this. There are serval places like below, I just = point out one example. UINT16 NameSpaceStrLen =3D *(UINT16 *) Ptr; For function ParseAcpiRsdp: ProcessAcpiTable ((VOID *) *XsdtAddress); Causing a warning and build failure with IA32 arch. I think the correct st= atement should be: ProcessAcpiTable ((VOID *)(UINTN)*XsdtAddress); Thanks, Zhichao > -----Original Message----- > From: devel@edk2.groups.io On Behalf Of Tomas Pil= ar > (tpilar) > Sent: Monday, June 29, 2020 11:20 PM > To: devel@edk2.groups.io > Cc: Sami.Mujawar@arm.com; nd@arm.com; Ni, Ray ; Gao, > Zhichao > Subject: [edk2-devel] [PATCH 8/8] ShellPkg/AcpiView: Refactor table pars= ers >=20 > The tests for checking specific constraints and checking > for buffer overflows have been simplified to use a standard > set of templates defined in the logging facility. >=20 > This regularises some of the error handling and makes > it easier to write more tests like this in the future. >=20 > Cc: Ray Ni > Cc: Zhichao Gao > Signed-off-by: Tomas Pilar > --- > .../UefiShellAcpiViewCommandLib/AcpiParser.c | 25 --- > .../UefiShellAcpiViewCommandLib/AcpiParser.h | 18 -- > .../Arm/SbbrValidator.c | 65 +++--- > .../Parsers/Dbg2/Dbg2Parser.c | 118 +++------- > .../Parsers/Fadt/FadtParser.c | 48 ++-- > .../Parsers/Gtdt/GtdtParser.c | 84 ++----- > .../Parsers/Iort/IortParser.c | 207 +++++++----------- > .../Parsers/Madt/MadtParser.c | 99 +++------ > .../Parsers/Mcfg/McfgParser.c | 11 +- > .../Parsers/Pptt/PpttParser.c | 165 +++----------- > .../Parsers/Rsdp/RsdpParser.c | 42 +--- > .../Parsers/Slit/SlitParser.c | 122 ++++------- > .../Parsers/Spcr/SpcrParser.c | 31 +-- > .../Parsers/Srat/SratParser.c | 188 +++++----------- > .../Parsers/Xsdt/XsdtParser.c | 92 ++------ > 15 files changed, 375 insertions(+), 940 deletions(-) >=20 > diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c > b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c > index 9bbf724dfdfe..58599442d210 100644 > --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c > +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c > @@ -24,31 +24,6 @@ STATIC CONST ACPI_PARSER AcpiHeaderParser[] =3D { > PARSE_ACPI_HEADER (&AcpiHdrInfo) > }; >=20 > -/** > - This function increments the ACPI table error counter. > -**/ > -VOID > -EFIAPI > -IncrementErrorCount ( > - VOID > - ) > -{ > - mTableErrorCount++; > -} > - > -/** > - This function increments the ACPI table warning counter. > -**/ > -VOID > -EFIAPI > -IncrementWarningCount ( > - VOID > - ) > -{ > - mTableWarningCount++; > -} > - > - > /** > This function verifies the ACPI table checksum. >=20 > diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h > b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h > index bd3cdb774fb5..cdae433fef3b 100644 > --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h > +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h > @@ -18,24 +18,6 @@ > /// that allows us to process the log options. > #define RSDP_TABLE_INFO SIGNATURE_32('R', 'S', 'D', 'P') >=20 > -/** > - This function increments the ACPI table error counter. > -**/ > -VOID > -EFIAPI > -IncrementErrorCount ( > - VOID > - ); > - > -/** > - This function increments the ACPI table warning counter. > -**/ > -VOID > -EFIAPI > -IncrementWarningCount ( > - VOID > - ); > - > /** > This function verifies the ACPI table checksum. >=20 > diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Arm/SbbrValida= tor.c > b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Arm/SbbrValidator.c > index d3284417fa5f..ba80a5ab3b40 100644 > --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Arm/SbbrValidator.c > +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Arm/SbbrValidator.c > @@ -18,15 +18,16 @@ > #include > #include > #include "AcpiParser.h" > +#include "AcpiViewLog.h" > #include "Arm/SbbrValidator.h" >=20 > /** > SBBR specification version strings > **/ > -STATIC CONST CHAR8* ArmSbbrVersions[ArmSbbrVersionMax] =3D { > - "1.0", // ArmSbbrVersion_1_0 > - "1.1", // ArmSbbrVersion_1_1 > - "1.2" // ArmSbbrVersion_1_2 > +STATIC CONST CHAR16* ArmSbbrVersions[ArmSbbrVersionMax] =3D { > + L"SBBR-v1.0", // ArmSbbrVersion_1_0 > + L"SBBR-v1.1", // ArmSbbrVersion_1_1 > + L"SBBR-v1.2" // ArmSbbrVersion_1_2 > }; >=20 > /** > @@ -96,6 +97,16 @@ STATIC ACPI_TABLE_COUNTER ArmSbbrTableCounts[] =3D { >=20 > {EFI_ACPI_6_3_PROCESSOR_PROPERTIES_TOPOLOGY_TABLE_STRUCTURE_SIGN > ATURE, 0} > }; >=20 > +STATIC_ASSERT ( > + ARRAY_SIZE (ArmSbbr10Mandatory) <=3D ARRAY_SIZE (ArmSbbrTableCounts), > + "Incompatible mandatory array tables"); > +STATIC_ASSERT ( > + ARRAY_SIZE (ArmSbbr11Mandatory) <=3D ARRAY_SIZE (ArmSbbrTableCounts), > + "Incompatible mandatory array tables"); > +STATIC_ASSERT ( > + ARRAY_SIZE (ArmSbbr12Mandatory) <=3D ARRAY_SIZE (ArmSbbrTableCounts), > + "Incompatible mandatory array tables"); > + > /** > Reset the platform ACPI table instance count for all SBBR-mandatory t= ables. > **/ > @@ -160,7 +171,6 @@ ArmSbbrReqsValidate ( > UINT32 Table; > UINT32 Index; > UINT32 MandatoryTable; > - CONST UINT8* SignaturePtr; > BOOLEAN IsArmSbbrViolated; >=20 > if (Version >=3D ArmSbbrVersionMax) { > @@ -172,51 +182,30 @@ ArmSbbrReqsValidate ( > // Go through the list of mandatory tables for the input SBBR version > for (Table =3D 0; Table < ArmSbbrReqs[Version].TableCount; Table++) { > MandatoryTable =3D ArmSbbrReqs[Version].Tables[Table]; > - SignaturePtr =3D (CONST UINT8*)(UINTN)&MandatoryTable; >=20 > // Locate the instance count for the table with the given signature > - Index =3D 0; > - while ((Index < ARRAY_SIZE (ArmSbbrTableCounts)) && > - (ArmSbbrTableCounts[Index].Signature !=3D MandatoryTable)) { > - Index++; > - } > - > - if (Index >=3D ARRAY_SIZE (ArmSbbrTableCounts)) { > - IncrementErrorCount (); > - Print ( > - L"\nERROR: SBBR v%a: Mandatory %c%c%c%c table's instance count = not " \ > - L"found\n", > - ArmSbbrVersions[Version], > - SignaturePtr[0], > - SignaturePtr[1], > - SignaturePtr[2], > - SignaturePtr[3] > - ); > - return EFI_UNSUPPORTED; > + for (Index =3D 0; Index < ARRAY_SIZE (ArmSbbrTableCounts); Index++)= { > + if (ArmSbbrTableCounts[Index].Signature =3D=3D MandatoryTable) { > + break; > + } > } >=20 > if (ArmSbbrTableCounts[Index].Count =3D=3D 0) { > IsArmSbbrViolated =3D TRUE; > - IncrementErrorCount (); > - Print ( > - L"\nERROR: SBBR v%a: Mandatory %c%c%c%c table is missing", > + AcpiError ( > + ACPI_ERROR_CROSS, > + L"(%a) Mandatory %4a table is missing", > ArmSbbrVersions[Version], > - SignaturePtr[0], > - SignaturePtr[1], > - SignaturePtr[2], > - SignaturePtr[3] > - ); > + MandatoryTable); > } > } >=20 > if (!IsArmSbbrViolated) { > - Print ( > - L"\nINFO: SBBR v%a: All mandatory ACPI tables are installed", > - ArmSbbrVersions[Version] > - ); > + AcpiLog ( > + ACPI_GOOD, > + L"(%a): Mandatory ACPI tables present", > + ArmSbbrVersions[Version]); > } >=20 > - Print (L"\n"); > - > return IsArmSbbrViolated ? EFI_NOT_FOUND : EFI_SUCCESS; > } > diff --git > a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Dbg2/Dbg2Parser.c > b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Dbg2/Dbg2Parser.c > index dd69ed6992ba..933ad92312e1 100644 > --- > a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Dbg2/Dbg2Parser.c > +++ > b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Dbg2/Dbg2Parser.c > @@ -10,6 +10,7 @@ >=20 > #include > #include > +#include > #include "AcpiParser.h" > #include "AcpiTableParser.h" > #include "AcpiViewLog.h" > @@ -42,17 +43,10 @@ ValidateNameSpaceStrLen ( > IN VOID* Context > ) > { > - UINT16 NameSpaceStrLen; > + UINT16 NameSpaceStrLen =3D *(UINT16 *) Ptr; >=20 > - NameSpaceStrLen =3D *(UINT16*)Ptr; > - > - if (NameSpaceStrLen < 2) { > - IncrementErrorCount (); > - Print ( > - L"\nERROR: NamespaceString Length =3D %d. If no Namespace device = exists, " > \ > - L"NamespaceString[] must contain a period '.'", > - NameSpaceStrLen > - ); > + if (AssertConstraint (L"ACPI", NameSpaceStrLen > 1)) { > + AcpiInfo (L"With no namespace, NamespaceString[] must be a period '= .'"); > } > } >=20 > @@ -133,76 +127,51 @@ DumpDbgDeviceInfo ( > (OEMDataOffset =3D=3D NULL) || > (BaseAddrRegOffset =3D=3D NULL) || > (AddrSizeOffset =3D=3D NULL)) { > - IncrementErrorCount (); > - Print ( > - L"ERROR: Insufficient Debug Device Information Structure length. = " \ > - L"Length =3D %d.\n", > - Length > - ); > + AcpiError (ACPI_ERROR_PARSE, L"Failed to parse DbgDevInfo Structure= "); > return; > } >=20 > // GAS > - Index =3D 0; > Offset =3D *BaseAddrRegOffset; > - while ((Index++ < *GasCount) && > - (Offset < Length)) { > - PrintFieldName (4, L"BaseAddressRegister"); > - Offset +=3D (UINT16)DumpGasStruct ( > - Ptr + Offset, > - 4, > - Length - Offset > - ); > + for (Index =3D 0; Index < *GasCount; Index++) { > + if (AssertMemberIntegrity (Offset, 1, Ptr, Length)) { > + break; > + } > + > + PrintFieldName (4, L"BaseAddressRegister[%d]", Index); > + Offset +=3D (UINT16)DumpGasStruct (Ptr + Offset, 4, Length - Offset= ); > } >=20 > // Make sure the array of address sizes corresponding to each GAS fit= in the > // Debug Device Information structure > - if ((*AddrSizeOffset + (*GasCount * sizeof (UINT32))) > Length) { > - IncrementErrorCount (); > - Print ( > - L"ERROR: Invalid GAS count. GasCount =3D %d. RemainingBufferLengt= h =3D %d. " > \ > - L"Parsing of the Debug Device Information structure aborted.\n"= , > - *GasCount, > - Length - *AddrSizeOffset > - ); > + if (AssertMemberIntegrity ( > + *AddrSizeOffset, *GasCount * sizeof (UINT32), Ptr, Length)) { > return; > } >=20 > // Address Size > Index =3D 0; > Offset =3D *AddrSizeOffset; > - while ((Index++ < *GasCount) && > - (Offset < Length)) { > - PrintFieldName (4, L"Address Size"); > - Print (L"0x%x\n", *((UINT32*)(Ptr + Offset))); > + for (Index =3D 0; Index < *GasCount; Index++) { > + if (AssertMemberIntegrity (Offset, 1, Ptr, Length)) { > + break; > + } > + PrintFieldName (4, L"Address Size[%d]", Index); > + AcpiInfo (L"0x%x", ReadUnaligned32 ((CONST UINT32 *)(Ptr + Offset))= ); > Offset +=3D sizeof (UINT32); > } >=20 > // NameSpace String > - Index =3D 0; > - Offset =3D *NameSpaceStringOffset; > PrintFieldName (4, L"NameSpace String"); > - while ((Index++ < *NameSpaceStringLength) && > - (Offset < Length)) { > - Print (L"%c", *(Ptr + Offset)); > - Offset++; > + if (!AssertMemberIntegrity ( > + *NameSpaceStringOffset, *NameSpaceStringLength, Ptr, Length)) { > + AcpiInfo (L"%-.*a", *NameSpaceStringLength - 1, Ptr + > *NameSpaceStringOffset); > } > - Print (L"\n"); >=20 > // OEM Data > if (*OEMDataOffset !=3D 0) { > - Index =3D 0; > - Offset =3D *OEMDataOffset; > - PrintFieldName (4, L"OEM Data"); > - while ((Index++ < *OEMDataLength) && > - (Offset < Length)) { > - Print (L"%x ", *(Ptr + Offset)); > - if ((Index & 7) =3D=3D 0) { > - Print (L"\n%-*s ", OUTPUT_FIELD_COLUMN_WIDTH, L""); > - } > - Offset++; > - } > - Print (L"\n"); > + AcpiInfo (L"OEM Data"); > + DumpRaw (Ptr + *OEMDataOffset, *OEMDataLength); > } > } >=20 > @@ -245,13 +214,8 @@ ParseAcpiDbg2 ( >=20 > // Check if the values used to control the parsing logic have been > // successfully read. > - if ((OffsetDbgDeviceInfo =3D=3D NULL) || > - (NumberDbgDeviceInfo =3D=3D NULL)) { > - IncrementErrorCount (); > - Print ( > - L"ERROR: Insufficient table length. AcpiTableLength =3D %d\n", > - AcpiTableLength > - ); > + if ((OffsetDbgDeviceInfo =3D=3D NULL) || (NumberDbgDeviceInfo =3D=3D = NULL)) { > + AcpiError (ACPI_ERROR_PARSE, L"Failed to parse DbgDevInfo array"); > return; > } >=20 > @@ -259,7 +223,6 @@ ParseAcpiDbg2 ( > Index =3D 0; >=20 > while (Index++ < *NumberDbgDeviceInfo) { > - > // Parse the Debug Device Information Structure header to obtain Le= ngth > ParseAcpi ( > FALSE, > @@ -273,31 +236,20 @@ ParseAcpiDbg2 ( > // Check if the values used to control the parsing logic have been > // successfully read. > if (DbgDevInfoLen =3D=3D NULL) { > - IncrementErrorCount (); > - Print ( > - L"ERROR: Insufficient remaining table buffer length to read the= " \ > - L"Debug Device Information structure's 'Length' field. " \ > - L"RemainingTableBufferLength =3D %d.\n", > - AcpiTableLength - Offset > - ); > + AcpiError (ACPI_ERROR_PARSE, L"Failed to parse DbgDevInfoLen"); > return; > } >=20 > // Validate Debug Device Information Structure length > - if ((*DbgDevInfoLen =3D=3D 0) || > - ((Offset + (*DbgDevInfoLen)) > AcpiTableLength)) { > - IncrementErrorCount (); > - Print ( > - L"ERROR: Invalid Debug Device Information Structure length. " \ > - L"Length =3D %d. Offset =3D %d. AcpiTableLength =3D %d.\n", > - *DbgDevInfoLen, > - Offset, > - AcpiTableLength > - ); > + if (AssertConstraint (L"ACPI", *DbgDevInfoLen > 0)) { > + return; > + } > + > + if (AssertMemberIntegrity (Offset, *DbgDevInfoLen, Ptr, AcpiTableLe= ngth)) { > return; > } >=20 > - DumpDbgDeviceInfo (Ptr + Offset, (*DbgDevInfoLen)); > - Offset +=3D (*DbgDevInfoLen); > + DumpDbgDeviceInfo (Ptr + Offset, *DbgDevInfoLen); > + Offset +=3D *DbgDevInfoLen; > } > } > diff --git > a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Fadt/FadtParser.c > b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Fadt/FadtParser.c > index 4734864dfdcf..7349784ee067 100644 > --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Fadt/FadtPars= er.c > +++ > b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Fadt/FadtParser.c > @@ -69,12 +69,8 @@ ValidateFirmwareCtrl ( > ) > { > #if defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64) > - if (*(UINT32*)Ptr !=3D 0) { > - IncrementErrorCount (); > - Print ( > - L"\nERROR: Firmware Control must be zero for ARM platforms." > - ); > - } > + UINT32 FirmwareControl =3D *(UINT32 *) Ptr; > + AssertConstraint (L"ARM", FirmwareControl =3D=3D 0); > #endif > } >=20 > @@ -94,12 +90,8 @@ ValidateXFirmwareCtrl ( > ) > { > #if defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64) > - if (*(UINT64*)Ptr !=3D 0) { > - IncrementErrorCount (); > - Print ( > - L"\nERROR: X Firmware Control must be zero for ARM platforms." > - ); > - } > + UINT32 XFirmwareControl =3D *(UINT32 *) Ptr; > + AssertConstraint (L"ARM", XFirmwareControl =3D=3D 0); > #endif > } >=20 > @@ -119,12 +111,8 @@ ValidateFlags ( > ) > { > #if defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64) > - if (((*(UINT32*)Ptr) & HW_REDUCED_ACPI) =3D=3D 0) { > - IncrementErrorCount (); > - Print ( > - L"\nERROR: HW_REDUCED_ACPI flag must be set for ARM platforms." > - ); > - } > + UINT32 Flags =3D *(UINT32 *) Ptr; > + AssertConstraint (L"ARM", Flags & HW_REDUCED_ACPI); > #endif > } >=20 > @@ -232,15 +220,13 @@ ParseAcpiFadt ( >=20 > if (Trace) { > if (FadtMinorRevision !=3D NULL) { > - Print (L"\nSummary:\n"); > + AcpiInfo (L"Summary:"); > PrintFieldName (2, L"FADT Version"); > - Print (L"%d.%d\n", *AcpiHdrInfo.Revision, *FadtMinorRevision); > + AcpiInfo (L"%d.%d", *AcpiHdrInfo.Revision, *FadtMinorRevision); > } >=20 > - if (*GetAcpiXsdtHeaderInfo ()->OemTableId !=3D *AcpiHdrInfo.OemTabl= eId) { > - IncrementErrorCount (); > - Print (L"ERROR: OEM Table Id does not match with RSDT/XSDT.\n"); > - } > + AssertConstraint ( > + L"ACPI", *GetAcpiXsdtHeaderInfo ()->OemTableId =3D=3D > *AcpiHdrInfo.OemTableId); > } >=20 > // If X_FIRMWARE_CTRL is not zero then use X_FIRMWARE_CTRL and ignore > @@ -257,9 +243,9 @@ ParseAcpiFadt ( > if ((Trace) && > (Flags !=3D NULL) && > ((*Flags & EFI_ACPI_6_3_HW_REDUCED_ACPI) !=3D > EFI_ACPI_6_3_HW_REDUCED_ACPI)) { > - IncrementErrorCount (); > - Print (L"ERROR: No FACS table found, " > - L"both X_FIRMWARE_CTRL and FIRMWARE_CTRL are zero.\n"); > + AcpiError ( > + ACPI_ERROR_CROSS, > + L"No FACS table found, X_FIRMWARE_CTRL and FIRMWARE_CTRL are > zero"); > } > } >=20 > @@ -283,9 +269,7 @@ ParseAcpiFadt ( >=20 > Status =3D GetParser (FacsSignature, &FacsParserProc); > if (EFI_ERROR (Status)) { > - Print ( > - L"ERROR: No registered parser found for FACS.\n" > - ); > + AcpiFatal (L"No registered parser found for FACS"); > return; > } >=20 > @@ -309,8 +293,8 @@ ParseAcpiFadt ( > // The DSDT Table is mandatory for ARM systems > // as the CPU information MUST be presented in > // the DSDT. > - IncrementErrorCount (); > - Print (L"ERROR: Both X_DSDT and DSDT are invalid.\n"); > + AcpiError ( > + ACPI_ERROR_CROSS, L"(ARM) One of X_DSDT or DSDT must be valid!"= ); > } > #endif > return; > diff --git > a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Gtdt/GtdtParser.c > b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Gtdt/GtdtParser.c > index d02fc4929d6f..c6b782152c63 100644 > --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Gtdt/GtdtPars= er.c > +++ > b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Gtdt/GtdtParser.c > @@ -13,6 +13,7 @@ > #include "AcpiParser.h" > #include "AcpiTableParser.h" > #include "AcpiViewConfig.h" > +#include "AcpiViewLog.h" >=20 > // "The number of GT Block Timers must be less than or equal to 8" > #define GT_BLOCK_TIMER_COUNT_MAX 8 > @@ -41,18 +42,8 @@ ValidateGtBlockTimerCount ( > IN VOID* Context > ) > { > - UINT32 BlockTimerCount; > - > - BlockTimerCount =3D *(UINT32*)Ptr; > - > - if (BlockTimerCount > GT_BLOCK_TIMER_COUNT_MAX) { > - IncrementErrorCount (); > - Print ( > - L"\nERROR: Timer Count =3D %d. Max Timer Count is %d.", > - BlockTimerCount, > - GT_BLOCK_TIMER_COUNT_MAX > - ); > - } > + UINT32 BlockTimerCount =3D *(UINT32*)Ptr; > + AssertConstraint (L"ACPI", BlockTimerCount < > GT_BLOCK_TIMER_COUNT_MAX); > } >=20 > /** > @@ -70,18 +61,8 @@ ValidateGtFrameNumber ( > IN VOID* Context > ) > { > - UINT8 FrameNumber; > - > - FrameNumber =3D *(UINT8*)Ptr; > - > - if (FrameNumber >=3D GT_BLOCK_TIMER_COUNT_MAX) { > - IncrementErrorCount (); > - Print ( > - L"\nERROR: GT Frame Number =3D %d. GT Frame Number must be in ran= ge 0- > %d.", > - FrameNumber, > - GT_BLOCK_TIMER_COUNT_MAX - 1 > - ); > - } > + UINT8 GTFrameNumber =3D *Ptr; > + AssertConstraint (L"ACPI", GTFrameNumber < > GT_BLOCK_TIMER_COUNT_MAX); > } >=20 > /** > @@ -194,11 +175,7 @@ DumpGTBlock ( > // successfully read. > if ((GtBlockTimerCount =3D=3D NULL) || > (GtBlockTimerOffset =3D=3D NULL)) { > - IncrementErrorCount (); > - Print ( > - L"ERROR: Insufficient GT Block Structure length. Length =3D %d.\n= ", > - Length > - ); > + AcpiError (ACPI_ERROR_PARSE, L"Failed to parse GT Block Structure")= ; > return; > } >=20 > @@ -270,7 +247,6 @@ ParseAcpiGtdt ( > { > UINT32 Index; > UINT32 Offset; > - UINT8* TimerPtr; >=20 > if (!Trace) { > return; > @@ -287,17 +263,11 @@ ParseAcpiGtdt ( >=20 > // Check if the values used to control the parsing logic have been > // successfully read. > - if ((GtdtPlatformTimerCount =3D=3D NULL) || > - (GtdtPlatformTimerOffset =3D=3D NULL)) { > - IncrementErrorCount (); > - Print ( > - L"ERROR: Insufficient table length. AcpiTableLength =3D %d.\n", > - AcpiTableLength > - ); > + if ((GtdtPlatformTimerCount =3D=3D NULL) || (GtdtPlatformTimerOffset = = =3D=3D NULL)) { > + AcpiError (ACPI_ERROR_PARSE, L"Corrupt Platform Timer Table"); > return; > } >=20 > - TimerPtr =3D Ptr + *GtdtPlatformTimerOffset; > Offset =3D *GtdtPlatformTimerOffset; > Index =3D 0; >=20 > @@ -310,55 +280,35 @@ ParseAcpiGtdt ( > FALSE, > 0, > NULL, > - TimerPtr, > + Ptr + Offset, > AcpiTableLength - Offset, > PARSER_PARAMS (GtPlatformTimerHeaderParser) > ); >=20 > // Check if the values used to control the parsing logic have been > // successfully read. > - if ((PlatformTimerType =3D=3D NULL) || > - (PlatformTimerLength =3D=3D NULL)) { > - IncrementErrorCount (); > - Print ( > - L"ERROR: Insufficient remaining table buffer length to read the= " \ > - L"Platform Timer Structure header. Length =3D %d.\n", > - AcpiTableLength - Offset > - ); > + if ((PlatformTimerType =3D=3D NULL) || (PlatformTimerLength =3D=3D = NULL)) { > + AcpiError (ACPI_ERROR_PARSE, L"Corrupt Platform Timer Structure")= ; > return; > } >=20 > // Validate Platform Timer Structure length > - if ((*PlatformTimerLength =3D=3D 0) || > - ((Offset + (*PlatformTimerLength)) > AcpiTableLength)) { > - IncrementErrorCount (); > - Print ( > - L"ERROR: Invalid Platform Timer Structure length. " \ > - L"Length =3D %d. Offset =3D %d. AcpiTableLength =3D %d.\n", > - *PlatformTimerLength, > - Offset, > - AcpiTableLength > - ); > + if (AssertMemberIntegrity(Offset, *PlatformTimerLength, Ptr, > AcpiTableLength)) { > return; > } >=20 > switch (*PlatformTimerType) { > case EFI_ACPI_6_3_GTDT_GT_BLOCK: > - DumpGTBlock (TimerPtr, *PlatformTimerLength); > + DumpGTBlock (Ptr + Offset, *PlatformTimerLength); > break; > case EFI_ACPI_6_3_GTDT_SBSA_GENERIC_WATCHDOG: > - DumpWatchdogTimer (TimerPtr, *PlatformTimerLength); > + DumpWatchdogTimer (Ptr + Offset, *PlatformTimerLength); > break; > default: > - IncrementErrorCount (); > - Print ( > - L"ERROR: Invalid Platform Timer Type =3D %d\n", > - *PlatformTimerType > - ); > - break; > - } // switch > + AcpiError ( > + ACPI_ERROR_VALUE, L"Platform Timer Type %d", *PlatformTimerTy= pe); > + } >=20 > - TimerPtr +=3D *PlatformTimerLength; > Offset +=3D *PlatformTimerLength; > } // while > } > diff --git > a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Iort/IortParser.c > b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Iort/IortParser.c > index 356f355939aa..96227853c6ca 100644 > --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Iort/IortPars= er.c > +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Iort/IortPars= er.c > @@ -11,6 +11,7 @@ > #include > #include > #include > +#include > #include "AcpiParser.h" > #include "AcpiTableParser.h" > #include "AcpiViewConfig.h" > @@ -49,10 +50,8 @@ ValidateItsIdMappingCount ( > IN VOID* Context > ) > { > - if (*(UINT32*)Ptr !=3D 0) { > - IncrementErrorCount (); > - Print (L"\nERROR: IORT ID Mapping count must be zero."); > - } > + UINT32 ItsNodeIdMapping =3D *(UINT32 *) Ptr; > + AssertConstraint (L"ACPI", ItsNodeIdMapping =3D=3D 0); > } >=20 > /** > @@ -71,10 +70,8 @@ ValidatePmcgIdMappingCount ( > IN VOID* Context > ) > { > - if (*(UINT32*)Ptr > 1) { > - IncrementErrorCount (); > - Print (L"\nERROR: IORT ID Mapping count must not be greater than 1.= "); > - } > + UINT32 PmcgNodeIdMapping =3D *(UINT32 *) Ptr; > + AssertConstraint (L"ACPI", PmcgNodeIdMapping <=3D 1); > } >=20 > /** > @@ -92,10 +89,8 @@ ValidateItsIdArrayReference ( > IN VOID* Context > ) > { > - if (*(UINT32*)Ptr !=3D 0) { > - IncrementErrorCount (); > - Print (L"\nERROR: IORT ID Mapping offset must be zero."); > - } > + UINT32 ItsNodeMappingArrayOffset =3D *(UINT32 *) Ptr; > + AssertConstraint (L"ACPI", ItsNodeMappingArrayOffset =3D=3D 0); > } >=20 > /** > @@ -268,28 +263,21 @@ DumpIortNodeIdMappings ( > { > UINT32 Index; > UINT32 Offset; > - CHAR8 Buffer[40]; // Used for AsciiName param of ParseAcpi >=20 > - Index =3D 0; > Offset =3D 0; > + for (Index =3D 0; Index < MappingCount; Index++) { > + if (AssertMemberIntegrity(Offset, 1, Ptr, Length)) { > + return; > + } >=20 > - while ((Index < MappingCount) && > - (Offset < Length)) { > - AsciiSPrint ( > - Buffer, > - sizeof (Buffer), > - "ID Mapping [%d]", > - Index > - ); > + AcpiLog (ACPI_ITEM, L" ID Mapping[%d] (+0x%x)", Index, Offset); > Offset +=3D ParseAcpi ( > - TRUE, > - 4, > - Buffer, > - Ptr + Offset, > - Length - Offset, > - PARSER_PARAMS (IortNodeIdMappingParser) > - ); > - Index++; > + TRUE, > + 4, > + NULL, > + Ptr + Offset, > + Length - Offset, > + PARSER_PARAMS (IortNodeIdMappingParser)); > } > } >=20 > @@ -313,7 +301,6 @@ DumpIortNodeSmmuV1V2 ( > { > UINT32 Index; > UINT32 Offset; > - CHAR8 Buffer[50]; // Used for AsciiName param of ParseAcpi >=20 > ParseAcpi ( > TRUE, > @@ -330,56 +317,41 @@ DumpIortNodeSmmuV1V2 ( > (InterruptContextOffset =3D=3D NULL) || > (PmuInterruptCount =3D=3D NULL) || > (PmuInterruptOffset =3D=3D NULL)) { > - IncrementErrorCount (); > - Print ( > - L"ERROR: Insufficient SMMUv1/2 node length. Length =3D %d\n", > - Length > - ); > + AcpiError (ACPI_ERROR_PARSE, L"Failed to parse the SMMUv1/2 node"); > return; > } >=20 > Offset =3D *InterruptContextOffset; > - Index =3D 0; > + for (Index =3D 0; Index < *InterruptContextCount; Index++) { > + if (AssertMemberIntegrity(Offset, 1, Ptr, Length)) { > + break; > + } >=20 > - while ((Index < *InterruptContextCount) && > - (Offset < Length)) { > - AsciiSPrint ( > - Buffer, > - sizeof (Buffer), > - "Context Interrupts Array [%d]", > - Index > - ); > + AcpiLog ( > + ACPI_ITEM, L" Context Interrupts Array[%d] (+0x%x)", Index, Of= fset); > Offset +=3D ParseAcpi ( > - TRUE, > - 4, > - Buffer, > - Ptr + Offset, > - Length - Offset, > - PARSER_PARAMS (InterruptArrayParser) > - ); > - Index++; > + TRUE, > + 4, > + NULL, > + Ptr + Offset, > + Length - Offset, > + PARSER_PARAMS (InterruptArrayParser)); > } >=20 > Offset =3D *PmuInterruptOffset; > - Index =3D 0; > + for(Index =3D 0; Index < *PmuInterruptCount; Index++) { > + if (AssertMemberIntegrity(Offset, 1, Ptr, Length)){ > + break; > + } >=20 > - while ((Index < *PmuInterruptCount) && > - (Offset < Length)) { > - AsciiSPrint ( > - Buffer, > - sizeof (Buffer), > - "PMU Interrupts Array [%d]", > - Index > - ); > + AcpiLog (ACPI_ITEM, L" PMU Interrupts Array[%d] (+0x%x)", Index,= Offset); > Offset +=3D ParseAcpi ( > - TRUE, > - 4, > - Buffer, > - Ptr + Offset, > - Length - Offset, > - PARSER_PARAMS (InterruptArrayParser) > - ); > - Index++; > + TRUE, > + 4, > + NULL, > + Ptr + Offset, > + Length - Offset, > + PARSER_PARAMS (InterruptArrayParser)); > } >=20 > DumpIortNodeIdMappings ( > @@ -438,7 +410,6 @@ DumpIortNodeIts ( > { > UINT32 Offset; > UINT32 Index; > - CHAR8 Buffer[80]; // Used for AsciiName param of ParseAcpi >=20 > Offset =3D ParseAcpi ( > TRUE, > @@ -452,32 +423,26 @@ DumpIortNodeIts ( > // Check if the values used to control the parsing logic have been > // successfully read. > if (ItsCount =3D=3D NULL) { > - IncrementErrorCount (); > - Print ( > - L"ERROR: Insufficient ITS group length. Length =3D %d.\n", > - Length > - ); > + AcpiError (ACPI_ERROR_PARSE, L"Failed to parse ITS node"); > return; > } >=20 > Index =3D 0; >=20 > - while ((Index < *ItsCount) && > - (Offset < Length)) { > - AsciiSPrint ( > - Buffer, > - sizeof (Buffer), > - "GIC ITS Identifier Array [%d]", > - Index > - ); > + for (Index =3D 0; Index < *ItsCount; Index++) { > + if (AssertMemberIntegrity(Offset, 1, Ptr, Length)) { > + return; > + } > + > + AcpiLog ( > + ACPI_ITEM, L" GIC ITS Identifier Array[%d] (+0x%x)", Index, Of= fset); > Offset +=3D ParseAcpi ( > - TRUE, > - 4, > - Buffer, > - Ptr + Offset, > - Length - Offset, > - PARSER_PARAMS (ItsIdParser) > - ); > + TRUE, > + 4, > + NULL, > + Ptr + Offset, > + Length - Offset, > + PARSER_PARAMS (ItsIdParser)); > Index++; > } >=20 > @@ -516,13 +481,10 @@ DumpIortNodeNamedComponent ( >=20 > // Estimate the Device Name length > PrintFieldName (2, L"Device Object Name"); > - > - while ((*(Ptr + Offset) !=3D 0) && > - (Offset < Length)) { > - Print (L"%c", *(Ptr + Offset)); > - Offset++; > - } > - Print (L"\n"); > + AcpiInfo ( > + L"%.*a", > + AsciiStrnLenS ((CONST CHAR8 *)Ptr + Offset, Length - Offset), > + Ptr + Offset); >=20 > DumpIortNodeIdMappings ( > Ptr + MappingOffset, > @@ -629,7 +591,6 @@ ParseAcpiIort ( > { > UINT32 Offset; > UINT32 Index; > - UINT8* NodePtr; >=20 > if (!Trace) { > return; > @@ -648,16 +609,11 @@ ParseAcpiIort ( > // successfully read. > if ((IortNodeCount =3D=3D NULL) || > (IortNodeOffset =3D=3D NULL)) { > - IncrementErrorCount (); > - Print ( > - L"ERROR: Insufficient table length. AcpiTableLength =3D %d.\n", > - AcpiTableLength > - ); > + AcpiError (ACPI_ERROR_PARSE, L"Failed to parse IORT Node."); > return; > } >=20 > Offset =3D *IortNodeOffset; > - NodePtr =3D Ptr + Offset; > Index =3D 0; >=20 > // Parse the specified number of IORT nodes or the IORT table buffer = length. > @@ -669,7 +625,7 @@ ParseAcpiIort ( > FALSE, > 0, > "IORT Node Header", > - NodePtr, > + Ptr + Offset, > AcpiTableLength - Offset, > PARSER_PARAMS (IortNodeHeaderParser) > ); > @@ -680,42 +636,28 @@ ParseAcpiIort ( > (IortNodeLength =3D=3D NULL) || > (IortIdMappingCount =3D=3D NULL) || > (IortIdMappingOffset =3D=3D NULL)) { > - IncrementErrorCount (); > - Print ( > - L"ERROR: Insufficient remaining table buffer length to read the= " \ > - L"IORT node header. Length =3D %d.\n", > - AcpiTableLength - Offset > - ); > + AcpiError (ACPI_ERROR_PARSE, L"Failed ot parse the IORT node head= er"); > return; > } >=20 > - // Validate IORT Node length > - if ((*IortNodeLength =3D=3D 0) || > - ((Offset + (*IortNodeLength)) > AcpiTableLength)) { > - IncrementErrorCount (); > - Print ( > - L"ERROR: Invalid IORT Node length. " \ > - L"Length =3D %d. Offset =3D %d. AcpiTableLength =3D %d.\n", > - *IortNodeLength, > - Offset, > - AcpiTableLength > - ); > + // Protect against buffer overrun > + if (AssertMemberIntegrity (Offset, *IortNodeLength, Ptr, AcpiTableL= ength)) { > return; > } >=20 > PrintFieldName (2, L"* Node Offset *"); > - Print (L"0x%x\n", Offset); > + AcpiInfo (L"0x%x", Offset); >=20 > switch (*IortNodeType) { > case EFI_ACPI_IORT_TYPE_ITS_GROUP: > DumpIortNodeIts ( > - NodePtr, > + Ptr + Offset, > *IortNodeLength > ); > break; > case EFI_ACPI_IORT_TYPE_NAMED_COMP: > DumpIortNodeNamedComponent ( > - NodePtr, > + Ptr + Offset, > *IortNodeLength, > *IortIdMappingCount, > *IortIdMappingOffset > @@ -723,7 +665,7 @@ ParseAcpiIort ( > break; > case EFI_ACPI_IORT_TYPE_ROOT_COMPLEX: > DumpIortNodeRootComplex ( > - NodePtr, > + Ptr + Offset, > *IortNodeLength, > *IortIdMappingCount, > *IortIdMappingOffset > @@ -731,7 +673,7 @@ ParseAcpiIort ( > break; > case EFI_ACPI_IORT_TYPE_SMMUv1v2: > DumpIortNodeSmmuV1V2 ( > - NodePtr, > + Ptr + Offset, > *IortNodeLength, > *IortIdMappingCount, > *IortIdMappingOffset > @@ -739,7 +681,7 @@ ParseAcpiIort ( > break; > case EFI_ACPI_IORT_TYPE_SMMUv3: > DumpIortNodeSmmuV3 ( > - NodePtr, > + Ptr + Offset, > *IortNodeLength, > *IortIdMappingCount, > *IortIdMappingOffset > @@ -747,7 +689,7 @@ ParseAcpiIort ( > break; > case EFI_ACPI_IORT_TYPE_PMCG: > DumpIortNodePmcg ( > - NodePtr, > + Ptr + Offset, > *IortNodeLength, > *IortIdMappingCount, > *IortIdMappingOffset > @@ -755,11 +697,10 @@ ParseAcpiIort ( > break; >=20 > default: > - IncrementErrorCount (); > - Print (L"ERROR: Unsupported IORT Node type =3D %d\n", *IortNode= Type); > + AcpiError ( > + ACPI_ERROR_VALUE, L"Unsupported IORT Node type =3D %d", > *IortNodeType); > } // switch >=20 > - NodePtr +=3D (*IortNodeLength); > Offset +=3D (*IortNodeLength); > } // while > } > diff --git > a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Madt/MadtParser.c > b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Madt/MadtParser.c > index 15aa2392b60c..67bbf369ee1a 100644 > --- > a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Madt/MadtParser.c > +++ > b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Madt/MadtParser.c > @@ -17,6 +17,7 @@ > #include "AcpiTableParser.h" > #include "AcpiViewConfig.h" > #include "MadtParser.h" > +#include "AcpiViewLog.h" >=20 > // Local Variables > STATIC CONST UINT8* MadtInterruptControllerType; > @@ -38,12 +39,8 @@ ValidateGICDSystemVectorBase ( > IN VOID* Context > ) > { > - if (*(UINT32*)Ptr !=3D 0) { > - IncrementErrorCount (); > - Print ( > - L"\nERROR: System Vector Base must be zero." > - ); > - } > + UINT32 GicdSystemVectorBase =3D *(UINT32 *) Ptr; > + AssertConstraint (L"ACPI", GicdSystemVectorBase =3D=3D 0); > } >=20 > /** > @@ -63,36 +60,20 @@ ValidateSpeOverflowInterrupt ( > { > UINT16 SpeOverflowInterrupt; >=20 > - SpeOverflowInterrupt =3D *(UINT16*)Ptr; > + SpeOverflowInterrupt =3D *(UINT16 *) Ptr; >=20 > // SPE not supported by this processor > if (SpeOverflowInterrupt =3D=3D 0) { > return; > } >=20 > - if ((SpeOverflowInterrupt < ARM_PPI_ID_MIN) || > - ((SpeOverflowInterrupt > ARM_PPI_ID_MAX) && > - (SpeOverflowInterrupt < ARM_PPI_ID_EXTENDED_MIN)) || > - (SpeOverflowInterrupt > ARM_PPI_ID_EXTENDED_MAX)) { > - IncrementErrorCount (); > - Print ( > - L"\nERROR: SPE Overflow Interrupt ID of %d is not in the allowed = PPI ID " > - L"ranges of %d-%d or %d-%d (for GICv3.1 or later).", > - SpeOverflowInterrupt, > - ARM_PPI_ID_MIN, > - ARM_PPI_ID_MAX, > - ARM_PPI_ID_EXTENDED_MIN, > - ARM_PPI_ID_EXTENDED_MAX > - ); > - } else if (SpeOverflowInterrupt !=3D ARM_PPI_ID_PMBIRQ) { > - IncrementWarningCount(); > - Print ( > - L"\nWARNING: SPE Overflow Interrupt ID of %d is not compliant wit= h SBSA " > - L"Level 3 PPI ID assignment: %d.", > - SpeOverflowInterrupt, > - ARM_PPI_ID_PMBIRQ > - ); > - } > + AssertConstraint (L"ACPI", SpeOverflowInterrupt > ARM_PPI_ID_MIN); > + AssertConstraint ( > + L"ACPI", > + (SpeOverflowInterrupt < ARM_PPI_ID_MAX) || > + (SpeOverflowInterrupt > ARM_PPI_ID_EXTENDED_MIN)); > + AssertConstraint (L"ACPI", SpeOverflowInterrupt < > ARM_PPI_ID_EXTENDED_MAX); > + WarnConstraint (L"SBSA", SpeOverflowInterrupt =3D=3D ARM_PPI_ID_PMBIR= Q); > } >=20 > /** > @@ -231,7 +212,6 @@ ParseAcpiMadt ( > ) > { > UINT32 Offset; > - UINT8* InterruptContollerPtr; > UINT32 GICDCount; >=20 > GICDCount =3D 0; > @@ -248,7 +228,6 @@ ParseAcpiMadt ( > AcpiTableLength, > PARSER_PARAMS (MadtParser) > ); > - InterruptContollerPtr =3D Ptr + Offset; >=20 > while (Offset < AcpiTableLength) { > // Parse Interrupt Controller Structure to obtain Length. > @@ -256,7 +235,7 @@ ParseAcpiMadt ( > FALSE, > 0, > NULL, > - InterruptContollerPtr, > + Ptr + Offset, > AcpiTableLength - Offset, > PARSER_PARAMS (MadtInterruptControllerHeaderParser) > ); > @@ -265,26 +244,14 @@ ParseAcpiMadt ( > // successfully read. > if ((MadtInterruptControllerType =3D=3D NULL) || > (MadtInterruptControllerLength =3D=3D NULL)) { > - IncrementErrorCount (); > - Print ( > - L"ERROR: Insufficient remaining table buffer length to read the= " \ > - L"Interrupt Controller Structure header. Length =3D %d.\n", > - AcpiTableLength - Offset > - ); > + AcpiError ( > + ACPI_ERROR_PARSE, > + L"Failed to read the Interrupt Controller Structure header"); > return; > } >=20 > - // Validate Interrupt Controller Structure length > - if ((*MadtInterruptControllerLength =3D=3D 0) || > - ((Offset + (*MadtInterruptControllerLength)) > AcpiTableLength)= ) { > - IncrementErrorCount (); > - Print ( > - L"ERROR: Invalid Interrupt Controller Structure length. " \ > - L"Length =3D %d. Offset =3D %d. AcpiTableLength =3D %d.\n", > - *MadtInterruptControllerLength, > - Offset, > - AcpiTableLength > - ); > + if (AssertMemberIntegrity ( > + Offset, *MadtInterruptControllerLength, Ptr, AcpiTableLength)= ) { > return; > } >=20 > @@ -294,7 +261,7 @@ ParseAcpiMadt ( > TRUE, > 2, > "GICC", > - InterruptContollerPtr, > + Ptr + Offset, > *MadtInterruptControllerLength, > PARSER_PARAMS (GicCParser) > ); > @@ -303,18 +270,16 @@ ParseAcpiMadt ( >=20 > case EFI_ACPI_6_3_GICD: { > if (++GICDCount > 1) { > - IncrementErrorCount (); > - Print ( > - L"ERROR: Only one GICD must be present," > - L" GICDCount =3D %d\n", > - GICDCount > - ); > + AcpiError ( > + ACPI_ERROR_CROSS, > + L"Only one GICD must be present (now %d)", > + GICDCount); > } > ParseAcpi ( > TRUE, > 2, > "GICD", > - InterruptContollerPtr, > + Ptr + Offset, > *MadtInterruptControllerLength, > PARSER_PARAMS (GicDParser) > ); > @@ -326,7 +291,7 @@ ParseAcpiMadt ( > TRUE, > 2, > "GIC MSI Frame", > - InterruptContollerPtr, > + Ptr + Offset, > *MadtInterruptControllerLength, > PARSER_PARAMS (GicMSIFrameParser) > ); > @@ -338,7 +303,7 @@ ParseAcpiMadt ( > TRUE, > 2, > "GICR", > - InterruptContollerPtr, > + Ptr + Offset, > *MadtInterruptControllerLength, > PARSER_PARAMS (GicRParser) > ); > @@ -350,7 +315,7 @@ ParseAcpiMadt ( > TRUE, > 2, > "GIC ITS", > - InterruptContollerPtr, > + Ptr + Offset, > *MadtInterruptControllerLength, > PARSER_PARAMS (GicITSParser) > ); > @@ -358,17 +323,13 @@ ParseAcpiMadt ( > } >=20 > default: { > - IncrementErrorCount (); > - Print ( > - L"ERROR: Unknown Interrupt Controller Structure," > - L" Type =3D %d, Length =3D %d\n", > - *MadtInterruptControllerType, > - *MadtInterruptControllerLength > - ); > + AcpiError ( > + ACPI_ERROR_VALUE, > + L"Interrupt Controller Structure Type =3D %d", > + *MadtInterruptControllerType); > } > } // switch >=20 > - InterruptContollerPtr +=3D *MadtInterruptControllerLength; > Offset +=3D *MadtInterruptControllerLength; > } // while > } > diff --git > a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Mcfg/McfgParser.c > b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Mcfg/McfgParser.c > index 9da4d60e8497..7a7eaa374acf 100644 > --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Mcfg/McfgPars= er.c > +++ > b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Mcfg/McfgParser.c > @@ -12,6 +12,7 @@ > #include > #include "AcpiParser.h" > #include "AcpiTableParser.h" > +#include "AcpiViewLog.h" >=20 > // Local variables > STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo; > @@ -57,8 +58,6 @@ ParseAcpiMcfg ( > ) > { > UINT32 Offset; > - UINT32 PciCfgOffset; > - UINT8* PciCfgSpacePtr; >=20 > if (!Trace) { > return; > @@ -73,18 +72,14 @@ ParseAcpiMcfg ( > PARSER_PARAMS (McfgParser) > ); >=20 > - PciCfgSpacePtr =3D Ptr + Offset; > - > while (Offset < AcpiTableLength) { > - PciCfgOffset =3D ParseAcpi ( > + Offset +=3D ParseAcpi ( > TRUE, > 2, > "PCI Configuration Space", > - PciCfgSpacePtr, > + Ptr + Offset, > (AcpiTableLength - Offset), > PARSER_PARAMS (PciCfgSpaceBaseAddrParser) > ); > - PciCfgSpacePtr +=3D PciCfgOffset; > - Offset +=3D PciCfgOffset; > } > } > diff --git > a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pptt/PpttParser.c > b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pptt/PpttParser.c > index 97a5203efb5f..3afb4e103ea9 100644 > --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pptt/PpttPars= er.c > +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pptt/PpttPars= er.c > @@ -14,6 +14,7 @@ > #include "AcpiParser.h" > #include "AcpiView.h" > #include "AcpiViewConfig.h" > +#include "AcpiViewLog.h" > #include "PpttParser.h" > #include "AcpiViewLog.h" >=20 > @@ -39,38 +40,20 @@ ValidateCacheNumberOfSets ( > IN VOID* Context > ) > { > - UINT32 NumberOfSets; > - NumberOfSets =3D *(UINT32*)Ptr; > + UINT32 CacheNumberOfSets =3D *(UINT32*) Ptr; >=20 > - if (NumberOfSets =3D=3D 0) { > - IncrementErrorCount (); > - Print (L"\nERROR: Cache number of sets must be greater than 0"); > - return; > - } > + AssertConstraint (L"ACPI", CacheNumberOfSets !=3D 0); >=20 > #if defined(MDE_CPU_ARM) || defined (MDE_CPU_AARCH64) > - if (NumberOfSets > PPTT_ARM_CCIDX_CACHE_NUMBER_OF_SETS_MAX) { > - IncrementErrorCount (); > - Print ( > - L"\nERROR: When ARMv8.3-CCIDX is implemented the maximum cache > number of " > - L"sets must be less than or equal to %d", > - PPTT_ARM_CCIDX_CACHE_NUMBER_OF_SETS_MAX > - ); > + if (AssertConstraint ( > + L"ARMv8.3-CCIDX", > + CacheNumberOfSets < > PPTT_ARM_CCIDX_CACHE_NUMBER_OF_SETS_MAX)) { > return; > } >=20 > - if (NumberOfSets > PPTT_ARM_CACHE_NUMBER_OF_SETS_MAX) { > - IncrementWarningCount (); > - Print ( > - L"\nWARNING: Without ARMv8.3-CCIDX, the maximum cache number of > sets " > - L"must be less than or equal to %d. Ignore this message if " > - L"ARMv8.3-CCIDX is implemented", > - PPTT_ARM_CACHE_NUMBER_OF_SETS_MAX > - ); > - return; > - } > + WarnConstraint ( > + L"No-ARMv8.3-CCIDX", CacheNumberOfSets < > PPTT_ARM_CACHE_NUMBER_OF_SETS_MAX); > #endif > - > } >=20 > /** > @@ -89,14 +72,8 @@ ValidateCacheAssociativity ( > IN VOID* Context > ) > { > - UINT8 Associativity; > - Associativity =3D *(UINT8*)Ptr; > - > - if (Associativity =3D=3D 0) { > - IncrementErrorCount (); > - Print (L"\nERROR: Cache associativity must be greater than 0"); > - return; > - } > + UINT8 CacheAssociativity =3D *Ptr; > + AssertConstraint (L"ACPI", CacheAssociativity !=3D 0); > } >=20 > /** > @@ -120,25 +97,14 @@ ValidateCacheLineSize ( > // LineSize, bits [2:0] > // (Log2(Number of bytes in cache line)) - 4. >=20 > - UINT16 LineSize; > - LineSize =3D *(UINT16*)Ptr; > - > - if ((LineSize < PPTT_ARM_CACHE_LINE_SIZE_MIN) || > - (LineSize > PPTT_ARM_CACHE_LINE_SIZE_MAX)) { > - IncrementErrorCount (); > - Print ( > - L"\nERROR: The cache line size must be between %d and %d bytes" > - L" on ARM Platforms.", > - PPTT_ARM_CACHE_LINE_SIZE_MIN, > - PPTT_ARM_CACHE_LINE_SIZE_MAX > - ); > - return; > - } > + UINT16 CacheLineSize =3D *(UINT16 *) Ptr; >=20 > - if ((LineSize & (LineSize - 1)) !=3D 0) { > - IncrementErrorCount (); > - Print (L"\nERROR: The cache line size is not a power of 2."); > - } > + AssertConstraint ( > + L"ARM", > + (CacheLineSize >=3D PPTT_ARM_CACHE_LINE_SIZE_MIN && > + CacheLineSize <=3D PPTT_ARM_CACHE_LINE_SIZE_MAX)); > + > + AssertConstraint (L"ARM", BitFieldCountOnes32 (CacheLineSize, 0, 15) = = =3D=3D 1); > #endif > } >=20 > @@ -160,17 +126,8 @@ ValidateCacheAttributes ( > // Reference: Advanced Configuration and Power Interface (ACPI) Speci= fication > // Version 6.2 Errata A, September 2017 > // Table 5-153: Cache Type Structure > - UINT8 Attributes; > - Attributes =3D *(UINT8*)Ptr; > - > - if ((Attributes & 0xE0) !=3D 0) { > - IncrementErrorCount (); > - Print ( > - L"\nERROR: Attributes bits [7:5] are reserved and must be zero.", > - Attributes > - ); > - return; > - } > + UINT8 Attributes =3D *(UINT8 *) Ptr; > + AssertConstraint (L"ACPI", BitFieldCountOnes32 (Attributes, 5, 7) =3D= = =3D 0); > } >=20 > /** > @@ -255,7 +212,6 @@ DumpProcessorHierarchyNodeStructure ( > { > UINT32 Offset; > UINT32 Index; > - CHAR16 Buffer[OUTPUT_FIELD_COLUMN_WIDTH]; >=20 > Offset =3D ParseAcpi ( > TRUE, > @@ -268,48 +224,22 @@ DumpProcessorHierarchyNodeStructure ( >=20 > // Check if the values used to control the parsing logic have been > // successfully read. > - if (NumberOfPrivateResources =3D=3D NULL) { > - IncrementErrorCount (); > - Print ( > - L"ERROR: Insufficient Processor Hierarchy Node length. Length =3D= %d.\n", > - Length > - ); > - return; > - } > - > - // Make sure the Private Resource array lies inside this structure > - if (Offset + (*NumberOfPrivateResources * sizeof (UINT32)) > Length) = { > - IncrementErrorCount (); > - Print ( > - L"ERROR: Invalid Number of Private Resources. " \ > - L"PrivateResourceCount =3D %d. RemainingBufferLength =3D %d. " = \ > - L"Parsing of this structure aborted.\n", > - *NumberOfPrivateResources, > - Length - Offset > - ); > + if(NumberOfPrivateResources =3D=3D NULL) { > + AcpiError (ACPI_ERROR_PARSE, L"Failed to parse processor hierarchy"= ); > return; > } >=20 > - Index =3D 0; > - > // Parse the specified number of private resource references or the P= rocessor > // Hierarchy Node length. Whichever is minimum. > - while (Index < *NumberOfPrivateResources) { > - UnicodeSPrint ( > - Buffer, > - sizeof (Buffer), > - L"Private resources [%d]", > - Index > - ); > + for (Index =3D 0; Index < *NumberOfPrivateResources; Index++) { > + if (AssertMemberIntegrity (Offset, sizeof (UINT32), Ptr, Length)) { > + return; > + } >=20 > - PrintFieldName (4, Buffer); > - Print ( > - L"0x%x\n", > - *((UINT32*)(Ptr + Offset)) > - ); > + PrintFieldName (4, L"Private resources [%d]", Index); > + AcpiInfo (L"0x%x", *(UINT32 *) (Ptr + Offset)); >=20 > Offset +=3D sizeof (UINT32); > - Index++; > } > } >=20 > @@ -386,7 +316,6 @@ ParseAcpiPptt ( > ) > { > UINT32 Offset; > - UINT8* ProcessorTopologyStructurePtr; >=20 > if (!Trace) { > return; > @@ -401,15 +330,13 @@ ParseAcpiPptt ( > PARSER_PARAMS (PpttParser) > ); >=20 > - ProcessorTopologyStructurePtr =3D Ptr + Offset; > - > while (Offset < AcpiTableLength) { > // Parse Processor Hierarchy Node Structure to obtain Type and Leng= th. > ParseAcpi ( > FALSE, > 0, > NULL, > - ProcessorTopologyStructurePtr, > + Ptr + Offset, > AcpiTableLength - Offset, > PARSER_PARAMS (ProcessorTopologyStructureHeaderParser) > ); > @@ -418,62 +345,42 @@ ParseAcpiPptt ( > // successfully read. > if ((ProcessorTopologyStructureType =3D=3D NULL) || > (ProcessorTopologyStructureLength =3D=3D NULL)) { > - IncrementErrorCount (); > - Print ( > - L"ERROR: Insufficient remaining table buffer length to read the= " \ > - L"processor topology structure header. Length =3D %d.\n", > - AcpiTableLength - Offset > - ); > + AcpiError (ACPI_ERROR_PARSE, L"Failed to parse processor topology= "); > return; > } >=20 > // Validate Processor Topology Structure length > - if ((*ProcessorTopologyStructureLength =3D=3D 0) || > - ((Offset + (*ProcessorTopologyStructureLength)) > AcpiTableLeng= th)) { > - IncrementErrorCount (); > - Print ( > - L"ERROR: Invalid Processor Topology Structure length. " \ > - L"Length =3D %d. Offset =3D %d. AcpiTableLength =3D %d.\n", > - *ProcessorTopologyStructureLength, > - Offset, > - AcpiTableLength > - ); > + if (AssertMemberIntegrity ( > + Offset, *ProcessorTopologyStructureLength, Ptr, AcpiTableLeng= th)) { > return; > } >=20 > PrintFieldName (2, L"* Structure Offset *"); > - Print (L"0x%x\n", Offset); > + AcpiInfo (L"0x%x", Offset); >=20 > switch (*ProcessorTopologyStructureType) { > case EFI_ACPI_6_2_PPTT_TYPE_PROCESSOR: > DumpProcessorHierarchyNodeStructure ( > - ProcessorTopologyStructurePtr, > + Ptr + Offset, > *ProcessorTopologyStructureLength > ); > break; > case EFI_ACPI_6_2_PPTT_TYPE_CACHE: > DumpCacheTypeStructure ( > - ProcessorTopologyStructurePtr, > + Ptr + Offset, > *ProcessorTopologyStructureLength > ); > break; > case EFI_ACPI_6_2_PPTT_TYPE_ID: > DumpIDStructure ( > - ProcessorTopologyStructurePtr, > + Ptr + Offset, > *ProcessorTopologyStructureLength > ); > break; > default: > - IncrementErrorCount (); > - Print ( > - L"ERROR: Unknown processor topology structure:" > - L" Type =3D %d, Length =3D %d\n", > - *ProcessorTopologyStructureType, > - *ProcessorTopologyStructureLength > - ); > + AcpiError (ACPI_ERROR_VALUE, L"Unknown processor topology struc= ture"); > } >=20 > - ProcessorTopologyStructurePtr +=3D *ProcessorTopologyStructureLengt= h; > Offset +=3D *ProcessorTopologyStructureLength; > } // while > } > diff --git > a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Rsdp/RsdpParser.c > b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Rsdp/RsdpParser.c > index f4a8732a7db7..b71b59d86ee1 100644 > --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Rsdp/RsdpPars= er.c > +++ > b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Rsdp/RsdpParser.c > @@ -11,6 +11,7 @@ > #include > #include "AcpiParser.h" > #include "AcpiTableParser.h" > +#include "AcpiViewLog.h" >=20 > // Local Variables > STATIC CONST UINT64* XsdtAddress; > @@ -36,17 +37,8 @@ ValidateRsdtAddress ( > // Root System Description Pointer (RSDP), ACPI ? 5.2.5. > // - Within the RSDP, the RsdtAddress field must be null (zero) and= the > // XsdtAddresss MUST be a valid, non-null, 64-bit value. > - UINT32 RsdtAddr; > - > - RsdtAddr =3D *(UINT32*)Ptr; > - > - if (RsdtAddr !=3D 0) { > - IncrementErrorCount (); > - Print ( > - L"\nERROR: Rsdt Address =3D 0x%p. This must be NULL on ARM Platfo= rms.", > - RsdtAddr > - ); > - } > + UINT32 RsdtAddr =3D *(UINT32 *) Ptr; > + AssertConstraint (L"ARM", RsdtAddr =3D=3D 0); > #endif > } >=20 > @@ -71,17 +63,8 @@ ValidateXsdtAddress ( > // Root System Description Pointer (RSDP), ACPI ? 5.2.5. > // - Within the RSDP, the RsdtAddress field must be null (zero) and= the > // XsdtAddresss MUST be a valid, non-null, 64-bit value. > - UINT64 XsdtAddr; > - > - XsdtAddr =3D *(UINT64*)Ptr; > - > - if (XsdtAddr =3D=3D 0) { > - IncrementErrorCount (); > - Print ( > - L"\nERROR: Xsdt Address =3D 0x%p. This must not be NULL on ARM Pl= atforms.", > - XsdtAddr > - ); > - } > + UINT64 XsdtAddr =3D *(UINT64 *) Ptr; > + AssertConstraint (L"ARM", XsdtAddr !=3D 0); > #endif > } >=20 > @@ -141,12 +124,7 @@ ParseAcpiRsdp ( > // Check if the values used to control the parsing logic have been > // successfully read. > if (XsdtAddress =3D=3D NULL) { > - IncrementErrorCount (); > - Print ( > - L"ERROR: Insufficient table length. AcpiTableLength =3D %d." \ > - L"RSDP parsing aborted.\n", > - AcpiTableLength > - ); > + AcpiError (ACPI_ERROR_PARSE, L"Failed to parse the RSDP table"); > return; > } >=20 > @@ -154,11 +132,11 @@ ParseAcpiRsdp ( > // and does not parse the RSDT table. Platforms provide the > // RSDT to enable compatibility with ACPI 1.0 operating systems. > // Therefore the RSDT should not be used on ARM platforms. > - if ((*XsdtAddress) =3D=3D 0) { > - IncrementErrorCount (); > - Print (L"ERROR: XSDT Pointer is not set. RSDP parsing aborted.\n"); > + if (*XsdtAddress =3D=3D 0) { > + AcpiError ( > + ACPI_ERROR_VALUE, L"XSDT Pointer is not set. RSDP parsing aborted= ."); > return; > } >=20 > - ProcessAcpiTable ((UINT8*)(UINTN)(*XsdtAddress)); > + ProcessAcpiTable ((VOID *) *XsdtAddress); > } > diff --git > a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Slit/SlitParser.c > b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Slit/SlitParser.c > index cedfc8a71849..2cd051e72502 100644 > --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Slit/SlitPars= er.c > +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Slit/SlitPars= er.c > @@ -28,11 +28,6 @@ STATIC CONST ACPI_PARSER SlitParser[] =3D { > (VOID**)&SlitSystemLocalityCount, NULL, NULL} > }; >=20 > -/** > - Macro to get the value of a System Locality > -**/ > -#define SLIT_ELEMENT(Ptr, i, j) *(Ptr + (i * LocalityCount) + j) > - > /** > This function parses the ACPI SLIT table. > When trace is enabled this function parses the SLIT table and > @@ -58,11 +53,11 @@ ParseAcpiSlit ( > ) > { > UINT32 Offset; > - UINT32 Count; > - UINT32 Index; > + UINT32 Index1; > + UINT32 Index2; > UINT32 LocalityCount; > - UINT8* LocalityPtr; > - CHAR16 Buffer[80]; // Used for AsciiName param of ParseAcpi > + CHAR16 Buffer[256]; > + UINTN StrLen; >=20 > if (!Trace) { > return; > @@ -80,11 +75,7 @@ ParseAcpiSlit ( > // Check if the values used to control the parsing logic have been > // successfully read. > if (SlitSystemLocalityCount =3D=3D NULL) { > - IncrementErrorCount (); > - Print ( > - L"ERROR: Insufficient table length. AcpiTableLength =3D %d.\n", > - AcpiTableLength > - ); > + AcpiError (ACPI_ERROR_PARSE, L"Failed to parse the SLIT table"); > return; > } >=20 > @@ -100,89 +91,64 @@ ParseAcpiSlit ( > =3D 65535 > =3D MAX_UINT16 > */ > - if (*SlitSystemLocalityCount > MAX_UINT16) { > - IncrementErrorCount (); > - Print ( > - L"ERROR: The Number of System Localities provided can't be repres= ented " \ > - L"in the SLIT table. SlitSystemLocalityCount =3D %ld. " \ > - L"MaxLocalityCountAllowed =3D %d.\n", > - *SlitSystemLocalityCount, > - MAX_UINT16 > - ); > + if (AssertConstraint (L"ACPI", *SlitSystemLocalityCount <=3D MAX_UINT= 16)) { > return; > } >=20 > - LocalityCount =3D (UINT32)*SlitSystemLocalityCount; > + LocalityCount =3D (UINT32) *SlitSystemLocalityCount; >=20 > // Make sure system localities fit in the table buffer provided > - if (Offset + (LocalityCount * LocalityCount) > AcpiTableLength) { > - IncrementErrorCount (); > - Print ( > - L"ERROR: Invalid Number of System Localities. " \ > - L"SlitSystemLocalityCount =3D %ld. AcpiTableLength =3D %d.\n", > - *SlitSystemLocalityCount, > - AcpiTableLength > - ); > + if (AssertMemberIntegrity ( > + Offset, (LocalityCount * LocalityCount), Ptr, AcpiTableLength))= { > return; > } >=20 > - LocalityPtr =3D Ptr + Offset; > - > // We only print the Localities if the count is less than 16 > // If the locality count is more than 16 then refer to the > // raw data dump. > if (LocalityCount < 16) { > - UnicodeSPrint ( > - Buffer, > - sizeof (Buffer), > - L"Entry[0x%lx][0x%lx]", > - LocalityCount, > - LocalityCount > - ); > - PrintFieldName (0, Buffer); > - Print (L"\n"); > - Print (L" "); > - for (Index =3D 0; Index < LocalityCount; Index++) { > - Print (L" (%3d) ", Index); > + PrintFieldName (0, L"Entry[0x%lx][0x%lx]", LocalityCount, LocalityC= ount); > + AcpiInfo (L""); > + UnicodeSPrint (Buffer, sizeof (Buffer), L" "); > + for (Index1 =3D 0; Index1 < LocalityCount; Index1++) { > + StrLen =3D StrnLenS (Buffer, sizeof (Buffer)); > + UnicodeSPrint ( > + Buffer + StrLen, sizeof (Buffer) - StrLen, L" (%3d) ", Index1); > } > - Print (L"\n"); > - for (Count =3D 0; Count< LocalityCount; Count++) { > - Print (L" (%3d) ", Count); > - for (Index =3D 0; Index < LocalityCount; Index++) { > - Print (L" %3d ", SLIT_ELEMENT (LocalityPtr, Count, Index)); > + AcpiInfo (L"%s", Buffer); > + for (Index1 =3D 0; Index1 < LocalityCount; Index1++) { > + UnicodeSPrint (Buffer, sizeof (Buffer), L" (%3d) ", Index1); > + for (Index2 =3D 0; Index2 < LocalityCount; Index2++) { > + StrLen =3D StrnLenS (Buffer, sizeof (Buffer)); > + UnicodeSPrint ( > + Buffer + StrLen, > + sizeof (Buffer) - StrLen, > + L" %3d ", > + *(Ptr + Offset + Index1 * LocalityCount + Index2)); > } > - Print (L"\n"); > + AcpiInfo (L"%s", Buffer); > } > } >=20 > // Validate > - for (Count =3D 0; Count < LocalityCount; Count++) { > - for (Index =3D 0; Index < LocalityCount; Index++) { > - // Element[x][x] must be equal to 10 > - if ((Count =3D=3D Index) && (SLIT_ELEMENT (LocalityPtr, Count,Ind= ex) !=3D 10)) { > - IncrementErrorCount (); > - Print ( > - L"ERROR: Diagonal Element[0x%lx][0x%lx] (%3d)." > - L" Normalized Value is not 10\n", > - Count, > - Index, > - SLIT_ELEMENT (LocalityPtr, Count, Index) > - ); > - } > + for (Index1 =3D 0; Index1 < LocalityCount; Index1++) { > + // Element[x][x] must be equal to 10 > + if (*(Ptr + Offset + Index1 * LocalityCount + Index2) !=3D 10) { > + AcpiError ( > + ACPI_ERROR_VALUE, L"SLIT Element[%d][%d] !=3D 10", Index1, Inde= x1); > + } > + for (Index2 =3D 0; Index2 < Index1; Index2++) { > // Element[i][j] must be equal to Element[j][i] > - if (SLIT_ELEMENT (LocalityPtr, Count, Index) !=3D > - SLIT_ELEMENT (LocalityPtr, Index, Count)) { > - IncrementErrorCount (); > - Print ( > - L"ERROR: Relative distances for Element[0x%lx][0x%lx] (%3d) a= nd \n" > - L"Element[0x%lx][0x%lx] (%3d) do not match.\n", > - Count, > - Index, > - SLIT_ELEMENT (LocalityPtr, Count, Index), > - Index, > - Count, > - SLIT_ELEMENT (LocalityPtr, Index, Count) > - ); > + if ( > + *(Ptr + Offset + Index1 * LocalityCount + Index2) !=3D > + *(Ptr + Offset + Index2 * LocalityCount + Index1)) { > + AcpiError ( > + ACPI_ERROR_VALUE, > + L"SLIT Element[%d][%d] !=3D SLIT Element[%d][%d]", > + Index1, > + Index2, > + Index2, > + Index1); > } > } > } > diff --git > a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Spcr/SpcrParser.c > b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Spcr/SpcrParser.c > index 3b06b05dee8c..bc3c12e720f2 100644 > --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Spcr/SpcrPars= er.c > +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Spcr/SpcrPars= er.c > @@ -14,6 +14,7 @@ > #include > #include "AcpiParser.h" > #include "AcpiTableParser.h" > +#include "AcpiViewLog.h" >=20 > // Local variables > STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo; > @@ -34,18 +35,11 @@ ValidateInterruptType ( > ) > { > #if defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64) > - UINT8 InterruptType; > - > - InterruptType =3D *Ptr; > - > - if (InterruptType !=3D > - > EFI_ACPI_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_INTERRUPT_TYPE_GI > C) { > - IncrementErrorCount (); > - Print ( > - L"\nERROR: InterruptType =3D %d. This must be 8 on ARM Platforms"= , > - InterruptType > - ); > - } > + UINT8 InterruptType =3D *Ptr; > + AssertConstraint ( > + L"ARM", > + InterruptType =3D=3D > + > EFI_ACPI_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_INTERRUPT_TYPE_GI > C); > #endif > } >=20 > @@ -65,17 +59,8 @@ ValidateIrq ( > ) > { > #if defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64) > - UINT8 Irq; > - > - Irq =3D *Ptr; > - > - if (Irq !=3D 0) { > - IncrementErrorCount (); > - Print ( > - L"\nERROR: Irq =3D %d. This must be zero on ARM Platforms\n", > - Irq > - ); > - } > + UINT8 Irq =3D *Ptr; > + AssertConstraint (L"ARM", Irq =3D=3D 0); > #endif > } >=20 > diff --git > a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Srat/SratParser.c > b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Srat/SratParser.c > index 568a0400bf07..eafc7e7942a3 100644 > --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Srat/SratPars= er.c > +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Srat/SratPars= er.c > @@ -37,10 +37,8 @@ ValidateSratReserved ( > IN VOID* Context > ) > { > - if (*(UINT32*)Ptr !=3D 1) { > - IncrementErrorCount (); > - Print (L"\nERROR: Reserved should be 1 for backward compatibility.\= n"); > - } > + UINT32 Reserved =3D *(UINT32 *) Ptr; > + AssertConstraint (L"Backwards-Compatibility", Reserved =3D=3D 1); > } >=20 > /** > @@ -59,18 +57,8 @@ ValidateSratDeviceHandleType ( > IN VOID* Context > ) > { > - UINT8 DeviceHandleType; > - > - DeviceHandleType =3D *Ptr; > - > - if (DeviceHandleType > EFI_ACPI_6_3_PCI_DEVICE_HANDLE) { > - IncrementErrorCount (); > - Print ( > - L"\nERROR: Invalid Device Handle Type: %d. Must be between 0 and = %d.", > - DeviceHandleType, > - EFI_ACPI_6_3_PCI_DEVICE_HANDLE > - ); > - } > + UINT8 DeviceHandleType =3D *Ptr; > + AssertConstraint (L"ACPI", DeviceHandleType < > EFI_ACPI_6_3_PCI_DEVICE_HANDLE); > } >=20 > /** > @@ -87,9 +75,9 @@ DumpSratPciBdfNumber ( > IN UINT8* Ptr > ) > { > - CHAR16 Buffer[OUTPUT_FIELD_COLUMN_WIDTH]; > - > - Print (L"\n"); > + UINT16 Bus; > + UINT16 Device; > + UINT16 Function; >=20 > /* > The PCI BDF Number subfields are printed in the order specified in = the ACPI > @@ -102,43 +90,13 @@ DumpSratPciBdfNumber ( > +-----+------+------+ > */ >=20 > + Bus =3D BitFieldRead16(*(UINT16 *) Ptr, 0, 7); > + Device =3D BitFieldRead16(*(UINT16 *) Ptr, 8, 10); > + Function =3D BitFieldRead16(*(UINT16 *) Ptr, 11, 15); > + > // Print PCI Bus Number (Bits 7:0 of Byte 2) > - UnicodeSPrint ( > - Buffer, > - sizeof (Buffer), > - L"PCI Bus Number" > - ); > - PrintFieldName (4, Buffer); > - Print ( > - L"0x%x\n", > - *Ptr > - ); > - > - Ptr++; > - > - // Print PCI Device Number (Bits 7:3 of Byte 3) > - UnicodeSPrint ( > - Buffer, > - sizeof (Buffer), > - L"PCI Device Number" > - ); > - PrintFieldName (4, Buffer); > - Print ( > - L"0x%x\n", > - (*Ptr & (BIT7 | BIT6 | BIT5 | BIT4 | BIT3)) >> 3 > - ); > - > - // PCI Function Number (Bits 2:0 of Byte 3) > - UnicodeSPrint ( > - Buffer, > - sizeof (Buffer), > - L"PCI Function Number" > - ); > - PrintFieldName (4, Buffer); > - Print ( > - L"0x%x\n", > - *Ptr & (BIT2 | BIT1 | BIT0) > - ); > + PrintFieldName (4, L"PCI Bus:Device.Function"); > + AcpiInfo (L"%4X:%2X.%d", Bus, Device, Function); > } >=20 > /** > @@ -176,8 +134,7 @@ DumpSratDeviceHandle ( > ) > { > if (SratDeviceHandleType =3D=3D NULL) { > - IncrementErrorCount (); > - Print (L"\nERROR: Device Handle Type read incorrectly.\n"); > + AcpiError (ACPI_ERROR_PARSE, L"Failed to parse Device Handle"); > return; > } >=20 > @@ -222,7 +179,7 @@ DumpSratApicProximity ( >=20 > ProximityDomain =3D Ptr[0] | (Ptr[1] << 8) | (Ptr[2] << 16); >=20 > - Print (Format, ProximityDomain); > + AcpiInfo ((CHAR16 *)Format, ProximityDomain); > } >=20 > /** > @@ -360,7 +317,6 @@ ParseAcpiSrat ( > ) > { > UINT32 Offset; > - UINT8* ResourcePtr; > UINT32 GicCAffinityIndex; > UINT32 GicITSAffinityIndex; > UINT32 GenericInitiatorAffinityIndex; > @@ -389,155 +345,113 @@ ParseAcpiSrat ( > PARSER_PARAMS (SratParser) > ); >=20 > - ResourcePtr =3D Ptr + Offset; > - > while (Offset < AcpiTableLength) { > ParseAcpi ( > FALSE, > 0, > NULL, > - ResourcePtr, > + Ptr + Offset, > AcpiTableLength - Offset, > PARSER_PARAMS (SratResourceAllocationParser) > ); >=20 > // Check if the values used to control the parsing logic have been > // successfully read. > - if ((SratRAType =3D=3D NULL) || > - (SratRALength =3D=3D NULL)) { > - IncrementErrorCount (); > - Print ( > - L"ERROR: Insufficient remaining table buffer length to read the= " \ > - L"Static Resource Allocation structure header. Length =3D %d.= \n", > - AcpiTableLength - Offset > - ); > + if ((SratRAType =3D=3D NULL) || (SratRALength =3D=3D NULL)) { > + AcpiError (ACPI_ERROR_PARSE, L"Failed to parse SRAT header"); > return; > } >=20 > // Validate Static Resource Allocation Structure length > - if ((*SratRALength =3D=3D 0) || > - ((Offset + (*SratRALength)) > AcpiTableLength)) { > - IncrementErrorCount (); > - Print ( > - L"ERROR: Invalid Static Resource Allocation Structure length. "= \ > - L"Length =3D %d. Offset =3D %d. AcpiTableLength =3D %d.\n", > - *SratRALength, > - Offset, > - AcpiTableLength > - ); > + if (AssertMemberIntegrity(Offset, *SratRALength, Ptr, AcpiTableLeng= th)) { > return; > } >=20 > switch (*SratRAType) { > case EFI_ACPI_6_3_GICC_AFFINITY: > - AsciiSPrint ( > - Buffer, > - sizeof (Buffer), > - "GICC Affinity Structure [%d]", > - GicCAffinityIndex++ > - ); > + AcpiLog ( > + ACPI_ITEM, L"GICC Affinity Structure [%d]", GicCAffinityIndex= ++); > ParseAcpi ( > TRUE, > 2, > Buffer, > - ResourcePtr, > + Ptr + Offset, > *SratRALength, > - PARSER_PARAMS (SratGicCAffinityParser) > - ); > + PARSER_PARAMS (SratGicCAffinityParser)); > break; >=20 > case EFI_ACPI_6_3_GIC_ITS_AFFINITY: > - AsciiSPrint ( > - Buffer, > - sizeof (Buffer), > - "GIC ITS Affinity Structure [%d]", > - GicITSAffinityIndex++ > - ); > + AcpiLog ( > + ACPI_ITEM, L"GIC ITS Affinity Structure [%d]", GicITSAffinity= Index++); > ParseAcpi ( > TRUE, > 2, > Buffer, > - ResourcePtr, > + Ptr + Offset, > *SratRALength, > - PARSER_PARAMS (SratGicITSAffinityParser) > - ); > + PARSER_PARAMS (SratGicITSAffinityParser)); > break; >=20 > case EFI_ACPI_6_3_GENERIC_INITIATOR_AFFINITY: > - AsciiSPrint ( > - Buffer, > - sizeof (Buffer), > - "Generic Initiator Affinity Structure [%d]", > - GenericInitiatorAffinityIndex++ > - ); > + AcpiLog ( > + ACPI_ITEM, > + L"Generic Initiator Affinity Structure [%d]", > + GenericInitiatorAffinityIndex++); > ParseAcpi ( > TRUE, > 2, > Buffer, > - ResourcePtr, > + Ptr + Offset, > *SratRALength, > - PARSER_PARAMS (SratGenericInitiatorAffinityParser) > - ); > + PARSER_PARAMS (SratGenericInitiatorAffinityParser)); > break; >=20 > case EFI_ACPI_6_3_MEMORY_AFFINITY: > - AsciiSPrint ( > - Buffer, > - sizeof (Buffer), > - "Memory Affinity Structure [%d]", > - MemoryAffinityIndex++ > - ); > + AcpiLog ( > + ACPI_ITEM, L"Memory Affinity Structure [%d]", MemoryAffinityI= ndex++); > ParseAcpi ( > TRUE, > 2, > Buffer, > - ResourcePtr, > + Ptr + Offset, > *SratRALength, > - PARSER_PARAMS (SratMemAffinityParser) > - ); > + PARSER_PARAMS (SratMemAffinityParser)); > break; >=20 > case EFI_ACPI_6_3_PROCESSOR_LOCAL_APIC_SAPIC_AFFINITY: > - AsciiSPrint ( > - Buffer, > - sizeof (Buffer), > - "APIC/SAPIC Affinity Structure [%d]", > - ApicSapicAffinityIndex++ > - ); > + AcpiLog ( > + ACPI_ITEM, > + L"APIC/SAPIC Affinity Structure [%d]", > + ApicSapicAffinityIndex++); > ParseAcpi ( > TRUE, > 2, > Buffer, > - ResourcePtr, > + Ptr + Offset, > *SratRALength, > - PARSER_PARAMS (SratApciSapicAffinityParser) > - ); > + PARSER_PARAMS (SratApciSapicAffinityParser)); > break; >=20 > case EFI_ACPI_6_3_PROCESSOR_LOCAL_X2APIC_AFFINITY: > - AsciiSPrint ( > - Buffer, > - sizeof (Buffer), > - "X2APIC Affinity Structure [%d]", > - X2ApicAffinityIndex++ > - ); > + AcpiLog ( > + ACPI_ITEM, L"X2APIC Affinity Structure [%d]", X2ApicAffinityI= ndex++); > ParseAcpi ( > TRUE, > 2, > Buffer, > - ResourcePtr, > + Ptr + Offset, > *SratRALength, > - PARSER_PARAMS (SratX2ApciAffinityParser) > - ); > + PARSER_PARAMS (SratX2ApciAffinityParser)); > break; >=20 > default: > - IncrementErrorCount (); > - Print (L"ERROR: Unknown SRAT Affinity type =3D 0x%x\n", *SratRA= Type); > + AcpiError ( > + ACPI_ERROR_VALUE, > + L"Unknown SRAT Affinity type =3D 0x%x\n", > + *SratRAType); > break; > } >=20 > - ResourcePtr +=3D (*SratRALength); > Offset +=3D (*SratRALength); > } > } > diff --git > a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Xsdt/XsdtParser.c > b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Xsdt/XsdtParser.c > index 771c4f322b8e..564e231a627a 100644 > --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Xsdt/XsdtPars= er.c > +++ > b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Xsdt/XsdtParser.c > @@ -55,87 +55,43 @@ ParseAcpiXsdt ( > IN UINT8 AcpiTableRevision > ) > { > - UINT32 Offset; > UINT32 TableOffset; > - UINT64* TablePointer; > + UINT64** TablePointer; > UINTN EntryIndex; > - CHAR16 Buffer[32]; >=20 > - Offset =3D ParseAcpi ( > - Trace, > - 0, > - "XSDT", > - Ptr, > - AcpiTableLength, > - PARSER_PARAMS (XsdtParser) > - ); > - > - TableOffset =3D Offset; > + TableOffset =3D ParseAcpi ( > + Trace, 0, "XSDT", Ptr, AcpiTableLength, PARSER_PARAMS (XsdtParser))= ; >=20 > + EntryIndex =3D 0; > if (Trace) { > - EntryIndex =3D 0; > - TablePointer =3D (UINT64*)(Ptr + TableOffset); > - while (Offset < AcpiTableLength) { > + for (TablePointer =3D (UINT64 **)(Ptr + TableOffset); > + (UINT8 *) TablePointer < Ptr + AcpiTableLength; > + TablePointer++) { > + > CONST UINT32* Signature; > CONST UINT32* Length; > CONST UINT8* Revision; >=20 > - if ((UINT64*)(UINTN)(*TablePointer) !=3D NULL) { > - UINT8* SignaturePtr; > - > - ParseAcpiHeader ( > - (UINT8*)(UINTN)(*TablePointer), > - &Signature, > - &Length, > - &Revision > - ); > - > - SignaturePtr =3D (UINT8*)Signature; > - > - UnicodeSPrint ( > - Buffer, > - sizeof (Buffer), > - L"Entry[%d] - %c%c%c%c", > - EntryIndex++, > - SignaturePtr[0], > - SignaturePtr[1], > - SignaturePtr[2], > - SignaturePtr[3] > - ); > + if (*TablePointer !=3D NULL) { > + ParseAcpiHeader (*TablePointer, &Signature, &Length, &Revision)= ; > + PrintFieldName (2, L"Entry[%d] - %.4a", EntryIndex++, Signature= ); > + AcpiInfo (L"0x%lx", *TablePointer); > } else { > - UnicodeSPrint ( > - Buffer, > - sizeof (Buffer), > - L"Entry[%d]", > - EntryIndex++ > - ); > - } > - > - PrintFieldName (2, Buffer); > - Print (L"0x%lx\n", *TablePointer); > - > - // Validate the table pointers are not NULL > - if ((UINT64*)(UINTN)(*TablePointer) =3D=3D NULL) { > - IncrementErrorCount (); > - Print ( > - L"ERROR: Invalid table entry at 0x%lx, table address is 0x%lx= \n", > - TablePointer, > - *TablePointer > - ); > + PrintFieldName (2, L"Entry[%d]", EntryIndex++); > + AcpiInfo (L"NULL"); > + AcpiError (ACPI_ERROR_VALUE, L"Invalid table entry"); > } > - Offset +=3D sizeof (UINT64); > - TablePointer++; > - } // while > + } > } >=20 > // Process the tables > - Offset =3D TableOffset; > - TablePointer =3D (UINT64*)(Ptr + TableOffset); > - while (Offset < AcpiTableLength) { > - if ((UINT64*)(UINTN)(*TablePointer) !=3D NULL) { > - ProcessAcpiTable ((UINT8*)(UINTN)(*TablePointer)); > + for (TablePointer =3D (UINT64 **)(Ptr + TableOffset); > + (UINT8 *) TablePointer < Ptr + AcpiTableLength; > + TablePointer++) { > + > + if (*TablePointer !=3D NULL) { > + ProcessAcpiTable (*TablePointer); > } > - Offset +=3D sizeof (UINT64); > - TablePointer++; > - } // while > + > + } > } > -- > 2.24.1.windows.2 >=20 >=20 >=20 >=20