From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by mx.groups.io with SMTP id smtpd.web12.5220.1594362415842483969 for ; Thu, 09 Jul 2020 23:26:56 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@intel.onmicrosoft.com header.s=selector2-intel-onmicrosoft-com header.b=VU5BlZmn; spf=pass (domain: intel.com, ip: 134.134.136.20, mailfrom: zhichao.gao@intel.com) IronPort-SDR: D65BT8c7kVdTc6XHyLfVV8LI7o1qyDDCiM2oY1gn0bfAKcqeeKBOCFUZCn8tQ7nLcZ7MxI9v1a ZuBNqIDIloWA== X-IronPort-AV: E=McAfee;i="6000,8403,9677"; a="136363272" X-IronPort-AV: E=Sophos;i="5.75,334,1589266800"; d="scan'208";a="136363272" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Jul 2020 23:26:55 -0700 IronPort-SDR: F2o+52EawMg+4JLFHOrbTMHIVL+hJFUFKxHervRSDnTq+12DzYsV5WOTjHKvGQiY8sUb+mEx/5 GX76yFNHDKjQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,334,1589266800"; d="scan'208";a="458188292" Received: from orsmsx602.amr.corp.intel.com ([10.22.229.15]) by orsmga005.jf.intel.com with ESMTP; 09 Jul 2020 23:26:55 -0700 Received: from orsmsx602.amr.corp.intel.com (10.22.229.15) by ORSMSX602.amr.corp.intel.com (10.22.229.15) 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:26:54 -0700 Received: from ORSEDG002.ED.cps.intel.com (10.7.248.5) by orsmsx602.amr.corp.intel.com (10.22.229.15) 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:26:54 -0700 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (104.47.59.176) by edgegateway.intel.com (134.134.137.101) with Microsoft SMTP Server (TLS) id 14.3.439.0; Thu, 9 Jul 2020 23:26:53 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=P37qH7g1ILkWkoX31sxg0X1RpTvTZW9dxYYu7znQg2S8jCkJCPqT8jd+euwo/7pFaZ+fhUvgvthLtnJ5EHmOfFo0Waq6AW5ojfNRyl6Wpy7YuKgqYjFDye1F9aEBpnU0ezXBmnlFkmGXDKUefAnSweL0zgeZQZd36rIsWtffRptUymHQdtroohy4E2aeSJ1Bydnt/jtb2vGx7lOktyVDhqcEabhmSvf1xdIBT/u2XrGWoD0Id54YxviA5VCxJn3GeUO5vZOqTDi+y4eSEyJF7Df2oIqvf5bujsJC18CY0vPfE1j+xq76Mr/TIpiiJwQ571uFAXu4EHobcQXEGF3o2g== 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=ArY8puqT3p3W0cSwHcbAJNxljPfQDH4d267qyXt4asQ=; b=bxRNtCEBj1cRDux6QnXPZ/UBsGKeWHZvSvrhHl8V09Oxm7MJzyC9f/m+M1ck4hkAiQRaM41av+FL1UbJzgOndHt1R801hFYd7cD0ZbFk6ecLhmpbh8Fl5Vo9M6Uq+9/AEdjXxi2KSYusMVpoPRD2Q5HOHWHRhfxVz8UCwcLC8JqEs6YDD/O1d8mr7G0zxUjqduVW85VWxCkUU5BDNfey/ckaBrUh02NtVrsdH6XcrYBeVwCjJa6AnxKjsKWduYQMzCTof+GsX8eO2kb/kfCy5rKW82/EkANpr859SA6SzviZT5YXS47o1MZKpfKs/OCFmLqmfF/jLDqIVFtRi3xVAg== 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=ArY8puqT3p3W0cSwHcbAJNxljPfQDH4d267qyXt4asQ=; b=VU5BlZmndaWOVDblN6zjpb/feoBxg1dKcWdbhgcF99L3tAth/LkeV2RVdofzO4sOTzX+pVLmKst5beqecLMNb1AvFcaiKYftAzPkxVoJZP8NfrxiLcOtd9dtAGTY1T5uxPcxDehoLgV14InxEBowVhuQ/DS6ir6xKYRma6dcipA= Received: from DM6PR11MB4425.namprd11.prod.outlook.com (2603:10b6:5:1d9::31) by DM6PR11MB3977.namprd11.prod.outlook.com (2603:10b6:5:5::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.20; Fri, 10 Jul 2020 06:26:49 +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:26:49 +0000 From: "Gao, Zhichao" To: Tomas Pilar , "devel@edk2.groups.io" CC: "Sami.Mujawar@arm.com" , "nd@arm.com" , "Ni, Ray" Subject: Re: [PATCH 4/8] ShellPkg/AcpiView: Create a logging facility Thread-Topic: [PATCH 4/8] ShellPkg/AcpiView: Create a logging facility Thread-Index: AQHWTiju6ESL7vB/dUW35hvsSwdFkqkAaBCg Date: Fri, 10 Jul 2020 06:26:49 +0000 Message-ID: References: <20200629152008.685-1-Tomas.Pilar@arm.com> <20200629152008.685-5-Tomas.Pilar@arm.com> In-Reply-To: <20200629152008.685-5-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: arm.com; dkim=none (message not signed) header.d=none;arm.com; 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: 30fd04d6-8035-41b8-f785-08d8249a3a25 x-ms-traffictypediagnostic: DM6PR11MB3977: 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: /FOei8r39dZQy4fzu/SOZjKwm6W+7b+o4s+H8Ifwp5tnnNmGhWLa3pncJDRZywtfn92UBHlHmv5DlcRBqFkrDDi0MNq05iYvI34WFvCcEL2uuy25fnRsdqDr+Bi/N9kV1BFrl2Gy26kTls3FwCesE7FPo4VEDHN07NdN2MSAtK2CAbHDut9PPLx4g1m3U8oozCAkicB1y0miyWOjXP1sIPPc605aQXqb85uESA0BI2PQVetcx6aREBCQsK+/WZZ76L4XFbodqsc9tCodVcWDhBhiY9dSEmATddvegwXy7ZTOCJs7Jj8oGVg2Mn62NUXDIzhMbc7nCa6uV7SVkuIBal92ipQ0XphqFH8B2OCLmdVSwEMcMqnJGZqwFtNNMKEl 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)(396003)(376002)(136003)(39860400002)(346002)(366004)(478600001)(66946007)(76116006)(5660300002)(110136005)(316002)(66446008)(66476007)(66556008)(64756008)(52536014)(6506007)(53546011)(186003)(8936002)(71200400001)(2906002)(30864003)(8676002)(86362001)(55016002)(4326008)(33656002)(107886003)(9686003)(7696005)(19627235002)(83380400001)(54906003)(26005)(403724002);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata: 6b6sC8THpWwIDA51GClupT/OGvPN8WSNaKp2DhSsZfNcjaYYR39PAifhJAUBSbiglAZdoQ2lra/LsbHfZEG1XcK32fRz+H9Dh3Ehnu7SIZfuGFt/bb0N8oziduIJf98hmytg5dajepW8ry7N+eVlVHX46ja5afrOi+fgfaMNO7k2tv6iI/KHJdOdi19yrbmEsS0tT6/05FnvrR6zpYmBfPT7W+G+OoQr6dEYt73OnRxyywuhuBx/vG7L4mdnfzcycDQ1B71xZ9VGtXNqasGqpFAT4gli3J24bVFnpG016lw6HYjk9yXIxNfwxM1bKxAkBlIOj+uJ2H2HqHc/tYYfAaimsEVce/IJKypgFY0Gqoe26e1JLyDBpGxr1hN8QsTQuRTrCCrRG9i7mv2mm3kh60DsR4d0Jbceny1ucCTDlqUB0MGfm0bIH8XWAq1b/DRMite+HlBGpqSGAgOUb7V9avmkvUxeqZ1VJ+e1K4joohKtQ/puHRP+U+5c+XXL0wd2 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: 30fd04d6-8035-41b8-f785-08d8249a3a25 X-MS-Exchange-CrossTenant-originalarrivaltime: 10 Jul 2020 06:26:49.0816 (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: 0KSUx6XNyDwJQ70gmTL50qCNwaXxrt5Qtp5wcHBaw7RwrjjCwyUuAjKFzmpAfJo2BPrMjAhkPTLRs+Yq/O7AJg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR11MB3977 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 See below. > -----Original Message----- > From: Tomas Pilar > 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: [PATCH 4/8] ShellPkg/AcpiView: Create a logging facility >=20 > Extract error and warning logging into separate methods. Fold highlightin= g and > other output properties into the logging methods. >=20 > Cc: Ray Ni > Cc: Zhichao Gao > Signed-off-by: Tomas Pilar > --- > .../UefiShellAcpiViewCommandLib/AcpiParser.c | 5 +- > .../UefiShellAcpiViewCommandLib/AcpiViewLog.c | 230 > +++++++++++++++++ .../UefiShellAcpiViewCommandLib/AcpiViewLog.h | 233 > ++++++++++++++++++ > .../UefiShellAcpiViewCommandLib.inf | 2 + > 4 files changed, 466 insertions(+), 4 deletions(-) create mode 100644 > ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiViewLog.c > create mode 100644 > ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiViewLog.h >=20 > diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c > b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c > index 7017fa93efae..b88594cf3865 100644 > --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c > +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c > @@ -11,13 +11,10 @@ > #include "AcpiParser.h" > #include "AcpiView.h" > #include "AcpiViewConfig.h" > +#include "AcpiViewLog.h" >=20 > STATIC UINT32 gIndent; >=20 > -// Publicly accessible error and warning counters. > -UINT32 mTableErrorCount; > -UINT32 mTableWarningCount; > - > STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo; >=20 > /** > diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiViewLog.c > b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiViewLog.c > new file mode 100644 > index 000000000000..9b9aaa855fdc > --- /dev/null > +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiViewLog.c > @@ -0,0 +1,230 @@ > +/** @file > + 'acpiview' logging and output facility > + > + Copyright (c) 2020, ARM Limited. All rights reserved.
> + SPDX-License-Identifier: BSD-2-Clause-Patent **/ > + > +#include "AcpiViewLog.h" > +#include "AcpiViewConfig.h" > +#include "AcpiParser.h" > +#include > + > +static CHAR16 mOutputBuffer [MAX_OUTPUT_SIZE] =3D { 0 }; > + > +// String descriptions of error types > +static const CHAR16* mErrorTypeDesc [ACPI_ERROR_MAX] =3D { > + L"Not an error", ///< ACPI_ERROR_NONE > + L"Generic", ///< ACPI_ERROR_GENERIC > + L"Checksum", ///< ACPI_ERROR_CSUM > + L"Parsing", ///< ACPI_ERROR_PARSE > + L"Length", ///< ACPI_ERROR_LENGTH > + L"Value", ///< ACPI_ERROR_VALUE > + L"Cross-check", ///< ACPI_ERROR_CROSS > +}; > + > +// Publicly accessible error and warning counters. > +UINT32 mTableErrorCount; > +UINT32 mTableWarningCount; > + > +/** > + Change the attributes of the standard output console > + to change the colour of the text according to the given > + severity of a log message. > + > + @param[in] Severity The severity of the log message that is b= eing > + annotated with changed colour text. > + @param[in] OriginalAttribute The current attributes of ConOut that wil= l be > modified. > +**/ > +static > +VOID > +EFIAPI > +ApplyColor ( > + IN ACPI_LOG_SEVERITY Severity, > + IN UINTN OriginalAttribute > + ) > +{ > + if (!mConfig.ColourHighlighting) { > + return; > + } > + > + // Strip the foreground colour > + UINTN NewAttribute =3D OriginalAttribute & 0xF0; > + > + // Add specific foreground colour based on severity switch > + (Severity) { case ACPI_DEBUG: > + NewAttribute |=3D EFI_DARKGRAY; > + break; > + case ACPI_HIGHLIGHT: > + NewAttribute |=3D EFI_LIGHTBLUE; > + break; > + case ACPI_GOOD: > + NewAttribute |=3D EFI_GREEN; > + break; > + case ACPI_ITEM: > + case ACPI_WARN: > + NewAttribute |=3D EFI_YELLOW; > + break; > + case ACPI_BAD: > + case ACPI_ERROR: > + case ACPI_FATAL: > + NewAttribute |=3D EFI_RED; > + break; > + case ACPI_INFO: > + default: > + NewAttribute |=3D OriginalAttribute; > + break; > + } > + > + gST->ConOut->SetAttribute (gST->ConOut, NewAttribute); } > + > +/** > + Restore ConOut text attributes. > + > + @param[in] OriginalAttribute The attribute set that will be restored. > +**/ > +static > +VOID > +EFIAPI > +RestoreColor( > + IN UINTN OriginalAttribute > + ) > +{ > + gST->ConOut->SetAttribute (gST->ConOut, OriginalAttribute); } > + > +/** > + Formats and prints an ascii string to screen. > + > + @param[in] Format String that will be formatted and printed. > + @param[in] Marker The marker for variable parameters to be formatted. > +**/ > +static > +VOID > +EFIAPI > +AcpiViewVSOutput ( > + IN const CHAR16 *Format, > + IN VA_LIST Marker > + ) > +{ > + UnicodeVSPrint (mOutputBuffer, sizeof(mOutputBuffer), Format, > +Marker); > + gST->ConOut->OutputString(gST->ConOut, mOutputBuffer); } > + > +/** > + Formats and prints and ascii string to screen. > + > + @param[in] Format String that will be formatted and printed. > + @param[in] ... A variable number of parameters that will be formatt= ed. > +**/ > +VOID > +EFIAPI > +AcpiViewOutput ( > + IN const CHAR16 *Format, > + IN ... > +) Please align the ')'. > +{ > + VA_LIST Marker; > + VA_START (Marker, Format); > + > + AcpiViewVSOutput (Format, Marker); > + > + VA_END (Marker); > +} > + > + > +/** > + Prints the base file name given a full file path. > + > + @param[in] FullName Fully qualified file path **/ VOID EFIAPI > +PrintFileName ( > + IN const CHAR8* FullName > + ) > +{ > + const CHAR8* Cursor; > + UINTN Size; > + > + Cursor =3D FullName; > + Size =3D 0; > + > + // Find the end point of the string. > + while (*Cursor && Cursor < FullName + MAX_OUTPUT_SIZE) > + Cursor++; > + > + // Find the rightmost path separator. > + while (*Cursor !=3D '\\' && *Cursor !=3D '/' && Cursor > FullName) { > + Cursor--; > + Size++; > + } > + > + // Print base file name. > + AcpiViewOutput (L"%.*a", Size - 1, Cursor + 1); } > + > +/** > + AcpiView output and logging function. Will log the event to > + configured output (currently screen) and annotate with colour > + and extra metadata. > + > + @param[in] FileName The full filename of the source file where th= is > + event occured. > + @param[in] FunctionName The name of the function where this event occ= ured. > + @param[in] LineNumber The line number in the source code where this= event > + occured. > + @param[in] Severity The severity of the event that occured. > + @param[in] Format The format of the string describing the event= . > + @param[in] ... The variable number of parameters that will f= ormat the > + string supplied in Format. > +**/ > +VOID > +EFIAPI > +AcpiViewLog ( > + IN const CHAR8 *FileName, > + IN const CHAR8 *FunctionName, > + IN UINTN LineNumber, > + IN ACPI_ERROR_TYPE Error, > + IN ACPI_LOG_SEVERITY Severity, > + IN const CHAR16 *Format, > + ...) Align the ')' in the next line. > +{ > + VA_LIST Marker; > + UINTN OriginalAttribute; > + > + OriginalAttribute =3D gST->ConOut->Mode->Attribute; ApplyColor > + (Severity, OriginalAttribute); VA_START (Marker, Format); > + > + switch (Severity) { > + case ACPI_FATAL: > + AcpiViewOutput (L"FATAL "); > + break; > + case ACPI_ERROR: > + AcpiViewOutput (L"ERROR[%s] ", mErrorTypeDesc[Error]); > + mTableErrorCount++; > + break; > + case ACPI_WARN: > + AcpiViewOutput (L"WARN "); > + mTableWarningCount++; > + break; > + default: > + break; > + } > + > + if (Severity >=3D ACPI_WARN) { > + AcpiViewOutput (L"("); > + PrintFileName (FileName); > + AcpiViewOutput (L":%d) ", LineNumber); } > + > + AcpiViewVSOutput (Format, Marker); > + AcpiViewOutput (L"\n"); > + > + VA_END (Marker); > + RestoreColor (OriginalAttribute); > +} > + > diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiViewLog.h > b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiViewLog.h > new file mode 100644 > index 000000000000..77049cd8eec2 > --- /dev/null > +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiViewLog.h > @@ -0,0 +1,233 @@ > +/** @file > + Header file for 'acpiview' logging and output facility > + > + Copyright (c) 2020, ARM Limited. All rights reserved.
> + SPDX-License-Identifier: BSD-2-Clause-Patent **/ > + > +#ifndef ACPI_VIEW_LOG_H_ > +#define ACPI_VIEW_LOG_H_ > + > +#include > + > +/* > + Categories of errors that can be logged by AcpiView. > +*/ > +typedef enum { > + ACPI_ERROR_NONE, ///< Not an error > + ACPI_ERROR_GENERIC, ///< An unspecified error > + ACPI_ERROR_CSUM, ///< A checksum was invalid > + ACPI_ERROR_PARSE, ///< Failed to parse item > + ACPI_ERROR_LENGTH, ///< Size of a thing is incorrect > + ACPI_ERROR_VALUE, ///< The value of a field was incorrect > + ACPI_ERROR_CROSS, ///< A constraint on multiple items was violat= ed > + ACPI_ERROR_MAX > +} ACPI_ERROR_TYPE; > + > +/* > + Different severities of events that can be logged. > +*/ > +typedef enum { > + ACPI_DEBUG, ///< Will not be shown unless specified on command l= ine > + ACPI_INFO, ///< Standard output > + ACPI_GOOD, ///< Unspecified good outcome, green colour > + ACPI_BAD, ///< Unspecified bad outcome, red colour > + ACPI_ITEM, ///< Used when describing multiple items > + ACPI_HIGHLIGHT, ///< A new context or section has been entered > + ACPI_WARN, ///< An unusual event happened > + ACPI_ERROR, ///< Acpi table is not conformant > + ACPI_FATAL ///< This will abort program execution. > +} ACPI_LOG_SEVERITY; > + > +// Publicly accessible error and warning counters. > +extern UINT32 mTableErrorCount; > +extern UINT32 mTableWarningCount; > + > +/** > + AcpiView output and logging function. Will log the event to > + configured output (currently screen) and annotate with colour > + and extra metadata. > + > + @param[in] FileName The full filename of the source file where th= is > + event occured. > + @param[in] FunctionName The name of the function where this event occ= ured. > + @param[in] LineNumber The line number in the source code where this= event > + occured. > + @param[in] Severity The severity of the event that occured. > + @param[in] Error The type of the erorr reported. May be > ACPI_ERROR_NONE if the event > + is not an error. > + @param[in] Format The format of the string describing the event= . > + @param[in] ... The variable number of parameters that will f= ormat the > + string supplied in Format. > +**/ > +VOID > +EFIAPI > +AcpiViewLog ( > + IN const CHAR8 *FileName, > + IN const CHAR8 *FunctionName, > + IN UINTN LineNumber, > + IN ACPI_ERROR_TYPE Error, > + IN ACPI_LOG_SEVERITY Severity, > + IN const CHAR16 *Format, > + ... > + ); Align the parameter Format with other parameters. > + > +/** > + Formats and prints and ascii string to screen. > + > + @param[in] Format String that will be formatted and printed. > + @param[in] ... A variable number of parameters that will be formatt= ed. > +**/ > +VOID > +EFIAPI > +AcpiViewOutput ( > + IN const CHAR16 *Format, > + IN ... > + ); > + > +/** > + Check that a buffer has not been overrun by a member. Can be invoked > + using the BufferOverrun macro that fills in local source metadata > + (first three parameters) for logging purposes. > + > + @param[in] FileName Source file where this invocation is made > + @param[in] FunctionName Name of the local symbol > + @param[in] LineNumber Source line number of the local call > + @param[in] ItemDescription User friendly name for the member being > checked > + @param[in] Position Memory address of the member > + @param[in] Length Length of the member > + @param[in] Buffer Memory address of the buffer where member r= esides > + @param[in] BufferSize Size of the buffer where member resides > + > + @retval TRUE Buffer was overrun > + @retval FALSE Buffer is safe > +**/ > +static > +inline > +BOOLEAN > +EFIAPI > +MemberIntegrityInternal ( > + IN const CHAR8 *FileName, > + IN const CHAR8 *FunctionName, > + IN UINTN LineNumber, > + IN const CHAR8 *ItemDescription, > + IN UINTN Offset, > + IN UINTN Length, > + IN VOID *Buffer, > + IN UINTN BufferSize) > +{ > + if (Length =3D=3D 0) { > + AcpiViewLog ( > + FileName, > + FunctionName, > + LineNumber, > + ACPI_ERROR_LENGTH, > + ACPI_ERROR, > + L"%a at %p in buffer %p+%x has zero size!", > + ItemDescription, > + (UINT8 *)Buffer + Offset, > + Buffer, > + BufferSize); > + return TRUE; > + } > + > + if (Offset + Length > BufferSize) { > + AcpiViewLog ( > + FileName, > + FunctionName, > + LineNumber, > + ACPI_ERROR_LENGTH, > + ACPI_ERROR, > + L"%a %p+%x overruns buffer %p+%x", > + ItemDescription, > + (UINT8 *) Buffer + Offset, > + Length, > + Buffer, > + BufferSize); > + } > + > + return (Offset + Length > BufferSize); } > + > +// Determine if a member located at Offset into a Buffer lies entirely > +// within the BufferSize given the member size is Length // Evaluates > +to TRUE and logs error if buffer is overrun or if Length is zero > +#define AssertMemberIntegrity(Offset, Length, Buffer, BufferSize) \ > + MemberIntegrityInternal (__FILE__, __func__, __LINE__, #Length, > +Offset, Length, Buffer, BufferSize) > + > + > +/** > + Checks that a boolean constraint evaluates correctly. Can be invoked > + using the CheckConstraint macro that fills in the source code metadata= . > + > + @param[in] FileName Source file where this invocation is made > + @param[in] FunctionName Name of the local symbol > + @param[in] LineNumber Source line number of the local call > + @param[in] ConstraintText The Source code of the constraint > + @param[in] Specification The specification that imposes the constrai= nt > + @param[in] Constraint The actual constraint > + @ > + > + @retval TRUE Constraint is violated > + @retval FALSE Constraint is not violated > +**/ > +static > +inline > +BOOLEAN > +EFIAPI > +CheckConstraintInternal ( > + IN const CHAR8 *FileName, > + IN const CHAR8 *FunctionName, > + IN UINTN LineNumber, > + IN const CHAR8 *ConstraintText, > + IN const CHAR16 *Specification, > + IN BOOLEAN Constraint, > + IN ACPI_LOG_SEVERITY Severity > +) > +{ > + if (!Constraint) { > + AcpiViewLog ( > + FileName, > + FunctionName, > + LineNumber, > + Severity =3D=3D ACPI_ERROR ? ACPI_ERROR_VALUE : ACPI_ERROR_NONE, > + Severity, > + L"(%a) Constraint was violated: %a", > + Specification, > + ConstraintText); > + } > + > + // Return TRUE if constraint was violated > + return !Constraint; > +} For this two inline functions: Refer to CCS_2_1 Section 5.1.9: Do not use the in-line assembler. Refer to CCS_2_1 Section 5.3.7: include file shall not generate the code or= define data variables. Thanks, Zhichao > + > +// Evaluates to TRUE and logs error if a constraint is violated // > +Constraint internally cast to BOOLEAN using !!(Constraint) #define > +AssertConstraint(Specification, Constraint) \ > + CheckConstraintInternal ( \ > + __FILE__, __func__, __LINE__, #Constraint, Specification, > +!!(Constraint), ACPI_ERROR) > + > +// Evaluates to TRUE and logs error if a constraint is violated #define > +WarnConstraint(Specification, Constraint) \ > + CheckConstraintInternal ( \ > + __FILE__, __func__, __LINE__, #Constraint, Specification, > +Constraint, ACPI_WARN) > + > + > +// Maximum string size that can be printed #define MAX_OUTPUT_SIZE 256 > + > +#define _AcpiLog(...) AcpiViewLog(__FILE__, __func__, __LINE__, > +__VA_ARGS__) > + > +// Generic Loging macro, needs severity and formatted string #define > +AcpiLog(Severity, ...) _AcpiLog(ACPI_ERROR_NONE, Severity, __VA_ARGS__) > + > +// Log undecorated text, needs formatted string #define AcpiInfo(...) > +_AcpiLog(ACPI_ERROR_NONE, ACPI_INFO, __VA_ARGS__) > + > +// Log error and increment counter, needs error type and formatted > +string #define AcpiError(Error, ...) _AcpiLog(Error, ACPI_ERROR, > +__VA_ARGS__) > + > +// Log a FATAL error, needs formatted string #define AcpiFatal(...) > +_AcpiLog(ACPI_ERROR_GENERIC, ACPI_FATAL, __VA_ARGS__) > + > +#endif // ACPI_VIEW_LOG_H_ > diff --git > a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLi > b.inf > b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLi > b.inf > index 91459f9ec632..e0586cbccec2 100644 > --- > a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLi > b.inf > +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewComm > +++ andLib.inf > @@ -27,6 +27,8 @@ [Sources.common] > AcpiView.h > AcpiViewConfig.c > AcpiViewConfig.h > + AcpiViewLog.h > + AcpiViewLog.c > Parsers/Bgrt/BgrtParser.c > Parsers/Dbg2/Dbg2Parser.c > Parsers/Dsdt/DsdtParser.c > -- > 2.24.1.windows.2 >=20