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.2717.1591861591195287594 for ; Thu, 11 Jun 2020 00:46:31 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@intel.onmicrosoft.com header.s=selector2-intel-onmicrosoft-com header.b=kRhDBXfP; spf=pass (domain: intel.com, ip: 134.134.136.20, mailfrom: zhichao.gao@intel.com) IronPort-SDR: MkWQND7C5ZabAtZy6vOzXphS7IaGZ2bo2iln2FfvrAEvnAKoKhSoZ+VpXBQ1m7BTYdtOiu0Gap fWaCz6gpvmng== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Jun 2020 00:46:30 -0700 IronPort-SDR: r4QFwQ62YDYazTp1DwjH5t3WJct/qnHrRRc+Uyrv4h0sug2RAEAcMReBGyMVG5hdl2cAhMqX22 /7KsbDNXOlvQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,499,1583222400"; d="scan'208";a="350109330" Received: from fmsmsx107.amr.corp.intel.com ([10.18.124.205]) by orsmga001.jf.intel.com with ESMTP; 11 Jun 2020 00:46:30 -0700 Received: from fmsmsx122.amr.corp.intel.com (10.18.125.37) by fmsmsx107.amr.corp.intel.com (10.18.124.205) with Microsoft SMTP Server (TLS) id 14.3.439.0; Thu, 11 Jun 2020 00:46:30 -0700 Received: from FMSEDG001.ED.cps.intel.com (10.1.192.133) by fmsmsx122.amr.corp.intel.com (10.18.125.37) with Microsoft SMTP Server (TLS) id 14.3.439.0; Thu, 11 Jun 2020 00:46:29 -0700 Received: from NAM04-CO1-obe.outbound.protection.outlook.com (104.47.45.59) by edgegateway.intel.com (192.55.55.68) with Microsoft SMTP Server (TLS) id 14.3.439.0; Thu, 11 Jun 2020 00:46:28 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=biCxvo/oLhqDxm08sALO8980HwdVmdF61aXHgH/RyfDBwwAKDWTvOVri1ARDi5pG5rcEmPFd6gdmyqwsZQJiOobEqJqV2M5Kz1fUqZ20+qZPLGvafM4l5RM5pERQtUht22MLKaQkgnBW1hxP937r2j1oDVylbI7FNmYcz0TXG/vcaFFSeYmD8lEen1yv32q9pNGaxQZvp4ayXT5tHT62NxeuGvUkD/hfUffoVPYzxAFbclF+Q4xxXeSo+3OCthjbwZS1ppzvdISBkHkWsZ7toR/BYQWvLRthkVmg9ITM3R4gPldVFBn32wx9W0Vibx/7yjRQRTuKb6Bp9Y89Q2XLTQ== 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=UBcfDMT5supovWk/Yz9iN2iOsF9YADxEW9NKEWu5GA8=; b=e9hCBe+RBkaDOr986b5V/aWZPEXAWa95X/dUt91ZZ2TLVWsPp8s6GV7m66+DMt20wAUmUI48tWSRxgCZAKoHja11TpjLfE8C5L2KB+IdwRcVXs0ARD18BjLaCPPKvZ9FrF3oLogSTTLB996X140NXFWcYzixve7FSX8Rmz6gmvQYhVAHSvGCSKpjY0yVCiu3tgtfRfTVpE9IDemSc17hG6zN8KiK5zTJC1MDTHnKc+pCrl982SBS+e/INpPgmEVat/P5n2CPx22+1EyaIMXxDkreL4o50zpb8AJWzd+saldA3+5uEo7HiwQYG40LKKpBJo4WyWBx8z9VzVgr5fRSEQ== 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=UBcfDMT5supovWk/Yz9iN2iOsF9YADxEW9NKEWu5GA8=; b=kRhDBXfPR2S8T+aYIl5AHv9/ymDWGoQO84Fy039Znxwx7NaUypVcMu9THI7SMsJDCwafjvoG95VjOKnYmt36DCIlU75lnXI1c0F6IJMh4eDfeYKmklcUTUOsjAOVrlJDb3KJZN0+qSKowPxQLzQpTWDu/qUghYr/doE8HTNkCLs= Received: from DM6PR11MB4425.namprd11.prod.outlook.com (2603:10b6:5:1d9::31) by DM6PR11MB4706.namprd11.prod.outlook.com (2603:10b6:5:2a5::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3088.18; Thu, 11 Jun 2020 07:46:27 +0000 Received: from DM6PR11MB4425.namprd11.prod.outlook.com ([fe80::615a:17b0:aa95:be1]) by DM6PR11MB4425.namprd11.prod.outlook.com ([fe80::615a:17b0:aa95:be1%3]) with mapi id 15.20.3066.023; Thu, 11 Jun 2020 07:46:25 +0000 From: "Gao, Zhichao" To: Krzysztof Koch , "devel@edk2.groups.io" CC: "Ni, Ray" , "Sami.Mujawar@arm.com" , "Laura.Moretta@arm.comMatteo.Carlini@arm.com" , "nd@arm.com" Subject: Re: [PATCH v1 4/6] ShellPkg: acpiview: Make GTDT parsing logic data driven Thread-Topic: [PATCH v1 4/6] ShellPkg: acpiview: Make GTDT parsing logic data driven Thread-Index: AQHWIvRrXGLFCMaoBk6x2/Hd22hZLKjTQpig Date: Thu, 11 Jun 2020 07:46:25 +0000 Message-ID: References: <20200505154604.9848-1-krzysztof.koch@arm.com> <20200505154604.9848-5-krzysztof.koch@arm.com> In-Reply-To: <20200505154604.9848-5-krzysztof.koch@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: 0dcf931c-f24a-4265-5158-08d80ddb8b39 x-ms-traffictypediagnostic: DM6PR11MB4706: 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-forefront-prvs: 0431F981D8 x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: pYqWxjF0pTvcSOv5SedhetD19eoERiozOctAt53UByStWtcNuEUphDpSGQJ6CqyGhNEjgxvpqGZiEKWWPRVjlbFAN/fwutVnaSZC9GeU7hpVw1gW5dmzPJN+8362jWwVTcV9SNQTr9VNlgoFSx77GIcAmlRHhfyDqRUMiJMPUxADPgwsnLvZ9zem19yw2UUIRaxj0FVq4WkHwLH8PA1z2J2sxvRjWQstYwa+tRE+/Q235U2/lEDJUbbdQ9vE3kGgy39k/gCCzwbbJIW0N2jC9MgPmjdbMLPtxui0vgf3BPsB/639TRgmr9WdclEuoQJp8AnkmoWcgMScPB7Drv9tvQ== 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:(346002)(39860400002)(366004)(376002)(136003)(396003)(9686003)(8676002)(5660300002)(316002)(55016002)(6506007)(7696005)(52536014)(4326008)(66946007)(66476007)(76116006)(53546011)(83380400001)(8936002)(186003)(54906003)(71200400001)(110136005)(478600001)(86362001)(66556008)(26005)(66446008)(33656002)(64756008)(2906002);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata: VkbAD2YtfoaHJzIsXfbzQJComNMT8refFHk3FADLwRt2g9KMeaphplToPLHE76YD4UR2hhP8ZoTaeD3BASxWe80L5dbP843U0JQ2h3rwwwzFj6/dNKntbr1rt9f6k2YNXm+JNPwvUWpgmvjguvAkjOgWDwXtWYrIGT6yqN7v+Z7QEp+iwnEXU/rfh3dmJ5ZI8jWa7ZcznTYwLAObX3peSAo3DAv+R1f68KQowwnzghpruyNBWz94dL8yaweuF7271D9qN/e9RSjB+rYBtrR/fqSUqKd6lh8Zb/24OD1Jes7z63pi5K6ztyu0Ilt88OScqLITa7DV2FIMZg52Acc1Eo27cGZBTeO6LCAumWPW8ksEYD7pvMa8kpkCne60JEA7d2bh0AOvjxmlqp5y1Hfstcu2Q7UYtcgxvWfHQNzCbQOlW7NVIf+PgEiJgRmX9VtNx/lWB0Bbo6XkWmF5wKeZttFCfkuuS4LHm34ggcjHcbbUvcoBW/xb6Bv2K3ICsmHF MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: 0dcf931c-f24a-4265-5158-08d80ddb8b39 X-MS-Exchange-CrossTenant-originalarrivaltime: 11 Jun 2020 07:46:25.6754 (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: DhQmhdssQUA2v3BW38N7t6valFK6rMmCbuIpdtz2aSh7+N/UtuLwWC73J6bXKahpEcaamGMrr7QxzdkTH7mcyA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR11MB4706 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 > -----Original Message----- > From: Krzysztof Koch > Sent: Tuesday, May 5, 2020 11:46 PM > To: devel@edk2.groups.io > Cc: Ni, Ray ; Gao, Zhichao ; > Sami.Mujawar@arm.com; Laura.Moretta@arm.comMatteo.Carlini@arm.com; > nd@arm.com > Subject: [PATCH v1 4/6] ShellPkg: acpiview: Make GTDT parsing logic data = driven >=20 > Replace the switch statement in the main parser loop with a table-driven > approach. Use the ParseAcpiStruct () method to resolve how each Platform = Timer > Structure given should be parsed. >=20 > Enumerate all structures found in the Generic Timer Description Table > (GTDT) on a per-type basis. Print the offset from the start of the table = for each > structure. >=20 > Consolidate all metadata about each Platform Timer Structure. > Define an array of ACPI_STRUCT_INFO structures to store the name, instanc= e > count, architecture support and handling information. Use this array to c= onstruct > the ACPI_STRUCT_DATABASE for GTDT. >=20 > Count the number of instances of each Platform Timer Structure type. > Optionally report these counts after GTDT table parsing is finished. >=20 > Modify DumpGTBlock () funtion signature so that it matches that of > ACPI_STRUCT_PARSER_FUNC. This way, the function can be used in the > ParseAcpiStruct () call. >=20 > Remove the definition of the DumpWatchdogTimer (). Its only purpose was t= o call > ParseAcpi () and now this process is streamlined. >=20 > References: > - ACPI 6.3 Specification - January 2019, Section 5.2.24 >=20 > Signed-off-by: Krzysztof Koch > --- >=20 > Notes: > v1: > - Make GTDT parsing logic data driven [Krzysztof] >=20 > ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Gtdt/GtdtParser.c | > 123 ++++++++++++-------- > 1 file changed, 77 insertions(+), 46 deletions(-) >=20 > diff --git > a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Gtdt/GtdtParser.c > b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Gtdt/GtdtParser.c > index > bdd30ff45c61142c071ead63a27babab8998721b..9a9f8fda442081507768b1540f0 > b9b3c6c254329 100644 > --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Gtdt/GtdtParse= r.c > +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Gtdt/GtdtPars > +++ er.c > @@ -9,13 +9,20 @@ > **/ >=20 > #include > +#include > #include > #include "AcpiParser.h" > #include "AcpiTableParser.h" > +#include "AcpiView.h" >=20 > // "The number of GT Block Timers must be less than or equal to 8" > #define GT_BLOCK_TIMER_COUNT_MAX 8 >=20 > +/** > + Handler for each Platform Timer Structure type **/ STATIC > +ACPI_STRUCT_INFO GtdtStructs[]; It is illegal for most of the compilers to declare an array without size. F= or VS, it would cause a build error. Two method to solve: 1. define the array without handler field initialization. Update the field = at the beginning of the parser function 2. put the required function declaration before the array definition. Same in the patch #5 & #6. Thanks, Zhichao > + > // Local variables > STATIC CONST UINT32* GtdtPlatformTimerCount; STATIC CONST UINT32* > GtdtPlatformTimerOffset; @@ -167,23 +174,35 @@ STATIC CONST > ACPI_PARSER SBSAGenericWatchdogParser[] =3D { > /** > This function parses the Platform GT Block. >=20 > - @param [in] Ptr Pointer to the start of the GT Block data. > - @param [in] Length Length of the GT Block structure. > + @param [in] Ptr Pointer to the start of structure's buffer. > + @param [in] Length Length of the buffer. > + @param [in] OptArg0 First optional argument (Not used). > + @param [in] OptArg1 Second optional argument (Not used). > **/ > STATIC > VOID > DumpGTBlock ( > - IN UINT8* Ptr, > - IN UINT16 Length > + IN UINT8* Ptr, > + IN UINT32 Length, > + IN CONST VOID* OptArg0 OPTIONAL, > + IN CONST VOID* OptArg1 OPTIONAL > ) > { > UINT32 Index; > UINT32 Offset; > + CHAR8 Buffer[80]; > + > + PrintAcpiStructName ( > + GtdtStructs[EFI_ACPI_6_3_GTDT_GT_BLOCK].Name, > + GtdtStructs[EFI_ACPI_6_3_GTDT_GT_BLOCK].Count, > + sizeof (Buffer), > + Buffer > + ); >=20 > ParseAcpi ( > TRUE, > 2, > - "GT Block", > + Buffer, > Ptr, > Length, > PARSER_PARAMS (GtBlockParser) > @@ -195,7 +214,8 @@ DumpGTBlock ( > (GtBlockTimerOffset =3D=3D NULL)) { > IncrementErrorCount (); > Print ( > - L"ERROR: Insufficient GT Block Structure length. Length =3D %d.\n"= , > + L"ERROR: Insufficient %a Structure length. Length =3D %d.\n", > + GtdtStructs[EFI_ACPI_6_3_GTDT_GT_BLOCK].Name, > Length > ); > return; > @@ -206,41 +226,47 @@ DumpGTBlock ( >=20 > // Parse the specified number of GT Block Timer Structures or the GT B= lock > // Structure buffer length. Whichever is minimum. > - while ((Index++ < *GtBlockTimerCount) && > + while ((Index < *GtBlockTimerCount) && > (Offset < Length)) { > + PrintAcpiStructName ("GT Block Timer", Index, sizeof (Buffer), > + Buffer); > Offset +=3D ParseAcpi ( > TRUE, > - 2, > - "GT Block Timer", > + 4, > + Buffer, > Ptr + Offset, > Length - Offset, > PARSER_PARAMS (GtBlockTimerParser) > ); > + Index++; > } > } >=20 > /** > - This function parses the Platform Watchdog timer. > - > - @param [in] Ptr Pointer to the start of the watchdog timer data. > - @param [in] Length Length of the watchdog timer structure. > + Information about each Platform Timer Structure type. > **/ > -STATIC > -VOID > -DumpWatchdogTimer ( > - IN UINT8* Ptr, > - IN UINT16 Length > - ) > -{ > - ParseAcpi ( > - TRUE, > - 2, > +STATIC ACPI_STRUCT_INFO GtdtStructs[] =3D { > + ADD_ACPI_STRUCT_INFO_FUNC ( > + "GT Block", > + EFI_ACPI_6_3_GTDT_GT_BLOCK, > + ARCH_COMPAT_ARM | ARCH_COMPAT_AARCH64, > + DumpGTBlock > + ), > + ADD_ACPI_STRUCT_INFO_ARRAY ( > "SBSA Generic Watchdog", > - Ptr, > - Length, > - PARSER_PARAMS (SBSAGenericWatchdogParser) > - ); > -} > + EFI_ACPI_6_3_GTDT_SBSA_GENERIC_WATCHDOG, > + ARCH_COMPAT_ARM | ARCH_COMPAT_AARCH64, > + SBSAGenericWatchdogParser > + ) > +}; > + > +/** > + GTDT structure database > +**/ > +STATIC ACPI_STRUCT_DATABASE GtdtDatabase =3D { > + "Platform Timer Structure", > + GtdtStructs, > + ARRAY_SIZE (GtdtStructs) > +}; >=20 > /** > This function parses the ACPI GTDT table. > @@ -275,6 +301,8 @@ ParseAcpiGtdt ( > return; > } >=20 > + ResetAcpiStructCounts (&GtdtDatabase); > + > ParseAcpi ( > TRUE, > 0, > @@ -321,7 +349,8 @@ ParseAcpiGtdt ( > IncrementErrorCount (); > Print ( > L"ERROR: Insufficient remaining table buffer length to read the = " \ > - L"Platform Timer Structure header. Length =3D %d.\n", > + L"%a header. Length =3D %d.\n", > + GtdtDatabase.Name, > AcpiTableLength - Offset > ); > return; > @@ -332,8 +361,9 @@ ParseAcpiGtdt ( > ((Offset + (*PlatformTimerLength)) > AcpiTableLength)) { > IncrementErrorCount (); > Print ( > - L"ERROR: Invalid Platform Timer Structure length. " \ > - L"Length =3D %d. Offset =3D %d. AcpiTableLength =3D %d.\n", > + L"ERROR: Invalid %a length. Length =3D %d. Offset =3D %d. " \ > + L"AcpiTableLength =3D %d.\n", > + GtdtDatabase.Name, > *PlatformTimerLength, > Offset, > AcpiTableLength > @@ -341,23 +371,24 @@ ParseAcpiGtdt ( > return; > } >=20 > - switch (*PlatformTimerType) { > - case EFI_ACPI_6_3_GTDT_GT_BLOCK: > - DumpGTBlock (TimerPtr, *PlatformTimerLength); > - break; > - case EFI_ACPI_6_3_GTDT_SBSA_GENERIC_WATCHDOG: > - DumpWatchdogTimer (TimerPtr, *PlatformTimerLength); > - break; > - default: > - IncrementErrorCount (); > - Print ( > - L"ERROR: Invalid Platform Timer Type =3D %d\n", > - *PlatformTimerType > - ); > - break; > - } // switch > + // Parse the Platform Timer Structure > + ParseAcpiStruct ( > + 2, > + TimerPtr, > + &GtdtDatabase, > + Offset, > + *PlatformTimerType, > + *PlatformTimerLength, > + NULL, > + NULL > + ); >=20 > TimerPtr +=3D *PlatformTimerLength; > Offset +=3D *PlatformTimerLength; > } // while > + > + // Report and validate Platform Timer Type Structure counts if > + (GetConsistencyChecking ()) { > + ValidateAcpiStructCounts (&GtdtDatabase); } > } > -- > 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'