From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from EUR01-HE1-obe.outbound.protection.outlook.com (EUR01-HE1-obe.outbound.protection.outlook.com [40.107.13.74]) by mx.groups.io with SMTP id smtpd.web12.19699.1599737899494845095 for ; Thu, 10 Sep 2020 04:38:20 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@armh.onmicrosoft.com header.s=selector2-armh-onmicrosoft-com header.b=vqxMOZKl; spf=pass (domain: arm.com, ip: 40.107.13.74, mailfrom: sami.mujawar@arm.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Ja9xHtQTOMdstyc09y8KZKHvp4wshJ3a0vcIjRQQgwc=; b=vqxMOZKllQueoxnWvep6MAGXhkEea8iUwoZk05UC5T2JKBEtMKexKzwAGN2woBy+udZ57D/TFKMoxpbyv1dR+5SxMFOZbczEiBe7uUGekuae6tg48ZP9x72DadSrGKlkHQXw0Y0514q2KkTBwDMlpzOwM0MiP51+lKWBhH3K3sY= Received: from DBBPR09CA0043.eurprd09.prod.outlook.com (2603:10a6:10:d4::31) by HE1PR0801MB2010.eurprd08.prod.outlook.com (2603:10a6:3:4b::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3370.16; Thu, 10 Sep 2020 11:38:14 +0000 Received: from DB5EUR03FT061.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:d4:cafe::30) by DBBPR09CA0043.outlook.office365.com (2603:10a6:10:d4::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3370.16 via Frontend Transport; Thu, 10 Sep 2020 11:38:14 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; edk2.groups.io; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;edk2.groups.io; dmarc=bestguesspass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by DB5EUR03FT061.mail.protection.outlook.com (10.152.21.234) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3370.16 via Frontend Transport; Thu, 10 Sep 2020 11:38:14 +0000 Received: ("Tessian outbound 34b830c8a0ef:v64"); Thu, 10 Sep 2020 11:38:14 +0000 X-CR-MTA-TID: 64aa7808 Received: from 1592087f8f1e.2 by 64aa7808-outbound-1.mta.getcheckrecipient.com id F4DFFFDA-DF14-4237-A3D7-AAD690659C72.1; Thu, 10 Sep 2020 11:38:09 +0000 Received: from EUR04-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 1592087f8f1e.2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 10 Sep 2020 11:38:09 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ivkOBB0SbyRs6cbkE7rgTzkpQx3DAB/uQorwUtaqrqI7Lzh38hm3LbiOC5ewy7NuMuQlH8g+0jYWB3QCmNqeI4NeJ0TGBLHHj4vHRNEZtVndf4fuCUSyMgRmAhotOsp8s90U6r+a40niXJoRZO0/MMgOaEpAG8y55K8eDANYrwjYNQbLlkO3CJaP8qiMpXDJUlgh07JbakrJMlDrOdEz1kb5SwiIOmEzZ5F2DLVkJxnlcVb3pDcO1KLR7chRVML77rOujo4LvzatPf6yO/yXt8fbnFXBCYDogbcUc9wiiXs6TwTWQWcvpxSmUwRj5BfBfQd7B4PixGfD0pjemoAkrg== 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=Ja9xHtQTOMdstyc09y8KZKHvp4wshJ3a0vcIjRQQgwc=; b=izgG++lvEi7eMKiB9Xx0D0HvsbUSY84iFZG9d9cc+bRZbpo8Zs35j5YPQTEd05MT3L9RHb+0c7c8WliBozdyqzHZYZuLCfERnKl217QaD0nUZdvbiK/ZBN5eBjLNo3t1bY0W5PcYE/JaDgT2mOmGuVWPCa3b6dmRvYqxbktSwtF4GG57cv+CBG2wdKS14Dhvl/EhAEDaIE5iyXHnupL7OScZyu8QpSw75IFcPlphqBOOyozPNwt0JhV9qcwGOjheitozFYLg+5oFFgLKgVskP56jW2AmyLLKOBu2Gy+hjEmy5Ste2RUNe4hqjH9j8c9z1ff0Hzg5Qf5Xuj9gmWXSZg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Ja9xHtQTOMdstyc09y8KZKHvp4wshJ3a0vcIjRQQgwc=; b=vqxMOZKllQueoxnWvep6MAGXhkEea8iUwoZk05UC5T2JKBEtMKexKzwAGN2woBy+udZ57D/TFKMoxpbyv1dR+5SxMFOZbczEiBe7uUGekuae6tg48ZP9x72DadSrGKlkHQXw0Y0514q2KkTBwDMlpzOwM0MiP51+lKWBhH3K3sY= Received: from DB7PR08MB3097.eurprd08.prod.outlook.com (2603:10a6:5:1d::27) by DBBPR08MB4346.eurprd08.prod.outlook.com (2603:10a6:10:ca::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3370.16; Thu, 10 Sep 2020 11:38:06 +0000 Received: from DB7PR08MB3097.eurprd08.prod.outlook.com ([fe80::3015:4e8d:a337:51f2]) by DB7PR08MB3097.eurprd08.prod.outlook.com ([fe80::3015:4e8d:a337:51f2%5]) with mapi id 15.20.3348.019; Thu, 10 Sep 2020 11:38:05 +0000 From: "Sami Mujawar" To: "zhichao.gao@intel.com" , "devel@edk2.groups.io" CC: "ray.ni@intel.com" , Sami Mujawar , Marc Moisson-Franckhauser , Guillaume Letellier , Matteo Carlini , Ben Adderson , nd Subject: Re: [PATCH v1 1/1] ShellPkg/AcpiView: PCCT Parser Thread-Topic: [PATCH v1 1/1] ShellPkg/AcpiView: PCCT Parser Thread-Index: AQHWegCtvvE8qOXMX0q07xPPuLG2Yqlh2X1Q Date: Thu, 10 Sep 2020 11:38:05 +0000 Message-ID: References: <20200824102303.38968-1-sami.mujawar@arm.com> In-Reply-To: <20200824102303.38968-1-sami.mujawar@arm.com> Accept-Language: en-GB, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ts-tracking-id: EA8A200C6422724BB1F88A6C529F58C2.0 x-checkrecipientchecked: true Authentication-Results-Original: intel.com; dkim=none (message not signed) header.d=none;intel.com; dmarc=none action=none header.from=arm.com; x-originating-ip: [217.44.29.82] x-ms-publictraffictype: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 3da50067-79f3-47e9-0912-08d8557e00fa x-ms-traffictypediagnostic: DBBPR08MB4346:|HE1PR0801MB2010: x-ms-exchange-transport-forked: True X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true nodisclaimer: true x-ms-oob-tlc-oobclassifiers: OLM:9508;OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: oBCNxiyIoS9LKGfL9XVBeX/JNECrWtdsbe9IUcOw3JNNFa0SeghrZx+rwNr30edh+CajpUtaGc6HQlBiasCHs3AL3iPwiGHf2XJIbKm0qxaz5/Vn39HFSF8Z3djh3RPvQah3cwPy9qXiktfrptS0BBsUrxUXs+1xluyj62t2Q8+oWSnbosFecy/dPLApdDEsTHmpSc0HdTpJYiNhzQkGqJgK+lJ/Oe0kVlIXll0T4/Ee2tEI7uM6eOeBQ0DHvZTCOR+g3t2c8NNx4v3TE61ZsFGIZqaRZKox0Fy8lXPekqPD/tS5vhPFQ+WAL2myrKeyjErc6FqCp/QZyXEF2EX0DlGHRxeEkokBrSFHb2niZZ1AojKhQlldcUiPShH8b7UgTAdsQKn7DulWVBZFm1aO+g== X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DB7PR08MB3097.eurprd08.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(376002)(346002)(396003)(39860400002)(366004)(136003)(66946007)(30864003)(55016002)(478600001)(4326008)(64756008)(66446008)(66476007)(316002)(71200400001)(66556008)(54906003)(9686003)(966005)(110136005)(8936002)(53546011)(52536014)(6506007)(33656002)(7696005)(5660300002)(86362001)(76116006)(8676002)(19627235002)(2906002)(83380400001)(26005)(186003)(579004);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata: 2Err6ZGOXObVk1ta/Mz1qS7EJPKlNxNkivER0k8Ytn8ng2xPys8DKTSrjUgEv++GSi9ZP1VuSQUmSQckLaorq5LR0QB8htGJZvvvVHX1JOMwd2GP6lapvd5gmk+E03l6tMpmGKlnFm1AcxVJ4e6w2RfCdw93tCpVysk+pIc/q+DtkdznjBaDa5M+8o8jgDx7XWR/A76i+yyAtu6qUYzaDsNtnIC+OAlq/vGNu7mhYWzXqL9yd12RfXgEgbLP+l7y3pEV8h8TzJ/g54L5VggI4tEFrP7RQtjEsxPGgSEdsuGiRJ+6OAgCwEmWsFQPQTczcAlPSnwa3b8qqKvE+nbCKd1UT/o5M+AsZ21Ojfyug6PZ6/rUQMcR+dcVRpEXCoOj1m8mM/o18mViorOrwGjXGjH/9Pe6YhBbetzKNctQgKVU6hQ28S4EZAy4BesiaGdxWl4QFmHq8y7K3KleZ2M5mY4FS4pEWkNyXAnPNaDuqTpHDyfsxkyDJUaWqSLXVAhQ4cO7Qq6iW03foTa0S4fXAdqAl0+svJqkD2Mi2T44B6V8tYAByl4tNnARWeKcNgY2wV6q2GkNYHLttlgFtSM0g1+vwvjPytMwyJ5lYwijBWatIDc9njvLhMKm04ibz55uuOhPDBKe5VdqZSlLJEn+ww== MIME-Version: 1.0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR08MB4346 Original-Authentication-Results: intel.com; dkim=none (message not signed) header.d=none;intel.com; dmarc=none action=none header.from=arm.com; Return-Path: Sami.Mujawar@arm.com X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DB5EUR03FT061.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 916b770a-d133-4159-420a-08d8557dfbfb X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: xyz7BhmMyPiCkhjaJ24jQQ3V1LmWWkvKq1ytOtRgOZ93y3UWzNNrKINkqCmosiJtkI0RA/de+DkDs1ueBdbGDXW8QQdla1eUmQC93MAP26vfjwJpd4jh5kfhR0QKdp1vn0xhVqN5JvwMbMvhUlCkx0SD3MBtNf+qvH5GlzBKpaEbCJGH3W0D9Mgr/gnkg1WrtvsUXHk31yUa/uIKNZcTMCi69RcipJJcgJMAso/7DnZdxEO5+C5ok/bk9S4UPt2GtoWiwyf+UQDEvuJrnTmLPiw0wHD2ZgUVjLjyEuSrGZk/GF8Gc41CG30mLmu9dbkf19G2zmPmO5mFcLZwfmcqFZVtjJdOgmlxNvSnQtGT9Qdb2ZGNZNSnNr9YvD57bk5a0eQEWIjOXBtqUeZf1u07xA3jPP4+DdHE3TqNiRnKxL9RuH1Ysr9IXxpHOLe4557IxoIfEYm6Ij6xwKciRhCvAcsFKvEiic3irYHN4SxrOyE= X-Forefront-Antispam-Report: CIP:63.35.35.123;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:64aa7808-outbound-1.mta.getcheckrecipient.com;PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com;CAT:NONE;SFS:(4636009)(396003)(376002)(39860400002)(346002)(136003)(46966005)(82740400003)(5660300002)(8676002)(54906003)(110136005)(55016002)(8936002)(966005)(26005)(30864003)(53546011)(9686003)(6506007)(316002)(86362001)(70586007)(70206006)(7696005)(47076004)(4326008)(52536014)(19627235002)(478600001)(33656002)(2906002)(336012)(82310400003)(356005)(83380400001)(81166007)(186003);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Sep 2020 11:38:14.2772 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3da50067-79f3-47e9-0912-08d8557e00fa X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d;Ip=[63.35.35.123];Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: DB5EUR03FT061.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR0801MB2010 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hi Zhichao, Would it be possible for you to provide feedback for this patch, please? Regards, Sami Mujawar -----Original Message----- From: Sami Mujawar =20 Sent: 24 August 2020 11:23 AM To: devel@edk2.groups.io Cc: Sami Mujawar ; ray.ni@intel.com; zhichao.gao@inte= l.com; Marc Moisson-Franckhauser ; Guill= aume Letellier ; Matteo Carlini ; Ben Adderson ; nd Subject: [PATCH v1 1/1] ShellPkg/AcpiView: PCCT Parser From: Marc Moisson-Franckhauser Create a new parser for the PCCT Table. The PCCT Table is used to describe how the OSPM can communicate with entities outside the platform. It describes which memory spaces correspond to which entity as well as a few of the needed information to handle the communications. This new PCCT parser dumps the values and names of the table fields. It also performs some validation on the table's fields. Signed-off-by: Marc Moisson-Franckhauser Signed-off-by: Sami Mujawar --- The changes can be seen at: https://github.com/samimujawar/edk2/tree/840_pcct_parser_v1 ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h = | 24 +- ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiTableParser.h = | 4 +- ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pcct/PcctParser.c = | 494 ++++++++++++++++++++ ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pcct/PcctParser.h = | 33 ++ ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.c= | 4 +- ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.i= nf | 4 +- 6 files changed, 558 insertions(+), 5 deletions(-) diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h b/Sh= ellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h index f81ccac7e118378aa185db4b625e5bcd75f78347..051fdf807abb1067a264c136364= bb6d145b38dab 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h @@ -1,7 +1,7 @@ /** @file Header file for ACPI parser =20 - Copyright (c) 2016 - 2020, ARM Limited. All rights reserved. + Copyright (c) 2016 - 2020, Arm Limited. All rights reserved. SPDX-License-Identifier: BSD-2-Clause-Patent **/ =20 @@ -671,6 +671,28 @@ ParseAcpiMcfg ( ); =20 /** + This function parses the ACPI PCCT table including its sub-structures + of type 0 through 4. + When trace is enabled this function parses the PCCT table and + traces the ACPI table fields. + + This function also performs validation of the ACPI table fields. + + @param [in] Trace If TRUE, trace the ACPI fields. + @param [in] Ptr Pointer to the start of the buffer. + @param [in] AcpiTableLength Length of the ACPI table. + @param [in] AcpiTableRevision Revision of the ACPI table. +**/ +VOID +EFIAPI +ParseAcpiPcct ( + IN BOOLEAN Trace, + IN UINT8* Ptr, + IN UINT32 AcpiTableLength, + IN UINT8 AcpiTableRevision + ); + +/** This function parses the ACPI PPTT table. When trace is enabled this function parses the PPTT table and traces the ACPI table fields. diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiTableParser.h= b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiTableParser.h index 4f92596b90a6ee422d8d0959881015ffd3de4da0..19265d0b763f8a810759a2cef09= ce2cc2d7bec03 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiTableParser.h +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiTableParser.h @@ -1,7 +1,7 @@ /** @file Header file for ACPI table parser =20 - Copyright (c) 2016 - 2018, ARM Limited. All rights reserved. + Copyright (c) 2016 - 2020, Arm Limited. All rights reserved. SPDX-License-Identifier: BSD-2-Clause-Patent **/ =20 @@ -11,7 +11,7 @@ /** The maximum number of ACPI table parsers. */ -#define MAX_ACPI_TABLE_PARSERS 16 +#define MAX_ACPI_TABLE_PARSERS 17 =20 /** An invalid/NULL signature value. */ diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pcct/Pcct= Parser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pcct/PcctPa= rser.c new file mode 100644 index 0000000000000000000000000000000000000000..526cb7b79aa7aa6eee09824600b= 6c7eac0ab67e2 --- /dev/null +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pcct/PcctParser.= c @@ -0,0 +1,494 @@ +/** @file + PCCT table parser + + Copyright (c) 2020, Arm Limited. + SPDX-License-Identifier: BSD-2-Clause-Patent + + @par Reference(s): + - ACPI 6.3 Specification - January 2019 +**/ + +#include +#include +#include "AcpiParser.h" +#include "AcpiView.h" +#include "AcpiViewConfig.h" +#include "PcctParser.h" + +// Local variables +STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo; + +STATIC UINT8* PccSubspaceLength; +STATIC UINT8* PccSubspaceType; + +/** + This function validates the length coded on 4 bytes of a shared memory r= ange + + @param [in] Ptr Pointer to the start of the field data. + @param [in] Context Pointer to context specific information e.g. this + could be a pointer to the ACPI table header. +**/ +STATIC +VOID +EFIAPI +ValidateRangeLength4 ( + IN UINT8* Ptr, + IN VOID* Context + ) +{ + if (*(UINT32*)Ptr < MIN_EXT_PCC_SUBSPACE_MEM_RANGE_LEN) { + IncrementErrorCount (); + Print ( + L"\nError: Shared memory range length is too short.\n" + L"Length is %u when it should be greater than or equal to %u", + *(UINT32*)Ptr, + MIN_EXT_PCC_SUBSPACE_MEM_RANGE_LEN + ); + } +} + +/** + This function validates the length coded on 8 bytes of a shared memory r= ange + + @param [in] Ptr Pointer to the start of the field data. + @param [in] Context Pointer to context specific information e.g. this + could be a pointer to the ACPI table header. +**/ +STATIC +VOID +EFIAPI +ValidateRangeLength8 ( + IN UINT8* Ptr, + IN VOID* Context + ) +{ + if (*(UINT64*)Ptr <=3D MIN_MEMORY_RANGE_LENGTH) { + IncrementErrorCount (); + Print ( + L"\nError: Shared memory range length is too short.\n" + L"Length is %u when it should be greater than %u", + *(UINT64*)Ptr, + MIN_MEMORY_RANGE_LENGTH + ); + } +} + +/** + This function validates address space for type 0 structure. + + @param [in] Ptr Pointer to the start of the field data. + @param [in] Context Pointer to context specific information e.g. this + could be a pointer to the ACPI table header. +**/ +STATIC +VOID +EFIAPI +ValidatePccType0Gas ( + IN UINT8* Ptr, + IN VOID* Context + ) +{ + switch (*(UINT8*)Ptr) { +#if !(defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64)) + case EFI_ACPI_6_3_SYSTEM_IO: +#endif //if not (defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64)) + case EFI_ACPI_6_3_SYSTEM_MEMORY: + return; + default: + IncrementErrorCount (); + Print (L"\nError: Invalid address space"); + } +} + +/** + This function validates address space for structures of types other than= 0. + + @param [in] Ptr Pointer to the start of the field data. + @param [in] Context Pointer to context specific information e.g. this + could be a pointer to the ACPI table header. +**/ +STATIC +VOID +EFIAPI +ValidatePccGas ( + IN UINT8* Ptr, + IN VOID* Context + ) +{ + switch (*(UINT8*)Ptr) { +#if !(defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64)) + case EFI_ACPI_6_3_SYSTEM_IO: +#endif //if not (defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64)) + case EFI_ACPI_6_3_FUNCTIONAL_FIXED_HARDWARE: + case EFI_ACPI_6_3_SYSTEM_MEMORY: + return; + default: + IncrementErrorCount (); + Print (L"\nError: Invalid address space"); + } +} + +/** + An ACPI_PARSER array describing the ACPI PCCT Table. +*/ +STATIC CONST ACPI_PARSER PcctParser[] =3D { + PARSE_ACPI_HEADER (&AcpiHdrInfo), + {L"Flags", 4, 36, NULL, NULL, NULL, NULL, NULL}, + {L"Reserved", 8, 40, NULL, NULL, NULL, NULL, NULL} +}; + +/** + An ACPI_PARSER array describing the platform communications channel subs= pace + structure header. +*/ +STATIC CONST ACPI_PARSER PccSubspaceHeaderParser[] =3D { + PCC_SUBSPACE_HEADER () + // ... Type Specific Fields ... +}; + +/** + An ACPI_PARSER array describing the Generic Communications Subspace - Ty= pe 0 +*/ +STATIC CONST ACPI_PARSER PccSubspaceType0Parser[] =3D { + PCC_SUBSPACE_HEADER (), + {L"Reserved", 6, 2, L"%x %x %x %x %x %x", Dump6Chars, NULL, NULL, NULL}, + {L"Base Address", 8, 8, L"0x%lx", NULL, NULL, NULL, NULL}, + {L"Memory Range Length", 8, 16, L"0x%lx", NULL, NULL, ValidateRangeLengt= h8, + NULL}, + {L"Doorbell Register", 12, 24, NULL, DumpGas, NULL, ValidatePccType0Gas, + NULL}, + {L"Doorbell Preserve", 8, 36, L"0x%lx", NULL, NULL, NULL, NULL}, + {L"Doorbell Write", 8, 44, L"0x%lx", NULL, NULL, NULL, NULL}, + {L"Nominal Latency", 4, 52, L"%u", NULL, NULL, NULL, NULL}, + {L"Maximum Periodic Access Rate", 4, 56, L"%u", NULL, NULL, NULL, NULL}, + {L"Minimum Request Turnaround Time", 2, 60, L"%u", NULL, NULL, NULL, NUL= L} +}; + +/** + An ACPI_PARSER array describing the HW-Reduced Communications Subspace + - Type 1 +*/ +STATIC CONST ACPI_PARSER PccSubspaceType1Parser[] =3D { + PCC_SUBSPACE_HEADER (), + {L"Platform Interrupt", 4, 2, L"0x%x", NULL, NULL, NULL, NULL}, + {L"Platform Interrupt Flags", 1, 6, L"0x%x", NULL, NULL, NULL, NULL}, + {L"Reserved", 1, 7, L"0x%x", NULL, NULL, NULL, NULL}, + {L"Base Address", 8, 8, L"0x%lx", NULL, NULL, NULL, NULL}, + {L"Memory Range Length", 8, 16, L"0x%lx", NULL, NULL, ValidateRangeLengt= h8, + NULL}, + {L"Doorbell Register", 12, 24, NULL, DumpGas, NULL, + ValidatePccGas, NULL}, + {L"Doorbell Preserve", 8, 36, L"0x%lx", NULL, NULL, NULL, NULL}, + {L"Doorbell Write", 8, 44, L"0x%lx", NULL, NULL, NULL, NULL}, + {L"Nominal Latency", 4, 52, L"%u", NULL, NULL, NULL, NULL}, + {L"Maximum Periodic Access Rate", 4, 56, L"%u", NULL, NULL, NULL, NULL}, + {L"Minimum Request Turnaround Time", 2, 60, L"%u", NULL, NULL, NULL, NUL= L} +}; + +/** + An ACPI_PARSER array describing the HW-Reduced Communications Subspace + - Type 2 +*/ +STATIC CONST ACPI_PARSER PccSubspaceType2Parser[] =3D { + PCC_SUBSPACE_HEADER (), + {L"Platform Interrupt", 4, 2, L"0x%x", NULL, NULL, NULL, NULL}, + {L"Platform Interrupt Flags", 1, 6, L"0x%x", NULL, NULL, NULL, NULL}, + {L"Reserved", 1, 7, L"0x%x", NULL, NULL, NULL, NULL}, + {L"Base Address", 8, 8, L"0x%lx", NULL, NULL, NULL, NULL}, + {L"Memory Range Length", 8, 16, L"0x%lx", NULL, NULL, ValidateRangeLengt= h8, + NULL}, + {L"Doorbell Register", 12, 24, NULL, DumpGas, NULL, + ValidatePccGas, NULL}, + {L"Doorbell Preserve", 8, 36, L"0x%lx", NULL, NULL, NULL, NULL}, + {L"Doorbell Write", 8, 44, L"0x%lx", NULL, NULL, NULL, NULL}, + {L"Nominal Latency", 4, 52, L"%u", NULL, NULL, NULL, NULL}, + {L"Maximum Periodic Access Rate", 4, 56, L"%u", NULL, NULL, NULL, NULL}, + {L"Minimum Request Turnaround Time", 2, 60, L"%u", NULL, NULL, NULL, NUL= L}, + {L"Platform Interrupt Ack Register", 12, 62, NULL, DumpGas, NULL, + ValidatePccGas, NULL}, + {L"Platform Interrupt Ack Preserve", 8, 74, L"0x%lx", NULL, NULL, NULL, = NULL}, + {L"Platform Interrupt Ack Write", 8, 82, L"0x%lx", NULL, NULL, + NULL, NULL}, +}; + +/** + An ACPI_PARSER array describing the Extended PCC Subspaces - Type 3/4 +*/ +STATIC CONST ACPI_PARSER PccSubspaceType3Parser[] =3D { + PCC_SUBSPACE_HEADER (), + {L"Platform Interrupt", 4, 2, L"0x%x", NULL, NULL, NULL, NULL}, + {L"Platform Interrupt Flags", 1, 6, L"0x%x", NULL, NULL, NULL, NULL}, + {L"Reserved", 1, 7, L"0x%x", NULL, NULL, NULL, NULL}, + {L"Base Address", 8, 8, L"0x%lx", NULL, NULL, NULL, NULL}, + {L"Memory Range Length", 4, 16, L"0x%x", NULL, NULL, ValidateRangeLength= 4, + NULL}, + {L"Doorbell Register", 12, 20, NULL, DumpGas, NULL, + ValidatePccGas, NULL}, + {L"Doorbell Preserve", 8, 32, L"0x%lx", NULL, NULL, NULL, NULL}, + {L"Doorbell Write", 8, 40, L"0x%lx", NULL, NULL, NULL, NULL}, + {L"Nominal Latency", 4, 48, L"%u", NULL, NULL, NULL, NULL}, + {L"Maximum Periodic Access Rate", 4, 52, L"%u", NULL, NULL, NULL, NULL}, + {L"Minimum Request Turnaround Time", 4, 56, L"%u", NULL, NULL, NULL, NUL= L}, + {L"Platform Interrupt Ack Register", 12, 60, NULL, DumpGas, NULL, + ValidatePccGas, NULL}, + {L"Platform Interrupt Ack Preserve", 8, 72, L"0x%lx", NULL, NULL, NULL, = NULL}, + {L"Platform Interrupt Ack Set", 8, 80, L"0x%lx", NULL, NULL, NULL, NULL}= , + {L"Reserved", 8, 88, L"0x%lx", NULL, NULL, NULL, NULL}, + {L"Cmd Complete Check Reg Addr", 12, 96, NULL, DumpGas, NULL, + ValidatePccGas, NULL}, + {L"Cmd Complete Check Mask", 8, 108, L"0x%lx", NULL, NULL, NULL, NULL}, + {L"Cmd Update Reg Addr", 12, 116, NULL, DumpGas, NULL, + ValidatePccGas, NULL}, + {L"Cmd Update Preserve mask", 8, 128, L"0x%lx", NULL, NULL, NULL, NULL}, + {L"Cmd Update Set mask", 8, 136, L"0x%lx", NULL, NULL, NULL, NULL}, + {L"Error Status Register", 12, 144, NULL, DumpGas, NULL, + ValidatePccGas, NULL}, + {L"Error Status Mask", 8, 156, L"0x%lx", NULL, NULL, NULL, NULL}, +}; + +/** + This function parses the PCC Subspace type 0. + + @param [in] Ptr Pointer to the start of Subspace Structure. + @param [in] Length Length of the Subspace Structure. +**/ +STATIC +VOID +DumpPccSubspaceType0 ( + IN UINT8* Ptr, + IN UINT8 Length + ) +{ + ParseAcpi ( + TRUE, + 2, + "Subspace Type 0", + Ptr, + Length, + PARSER_PARAMS (PccSubspaceType0Parser) + ); +} + +/** + This function parses the PCC Subspace type 1. + + @param [in] Ptr Pointer to the start of the Subspace Structure. + @param [in] Length Length of the Subspace Structure. +**/ +STATIC +VOID +DumpPccSubspaceType1 ( + IN UINT8* Ptr, + IN UINT8 Length + ) +{ + ParseAcpi ( + TRUE, + 2, + "Subspace Type 1", + Ptr, + Length, + PARSER_PARAMS (PccSubspaceType1Parser) + ); +} + +/** + This function parses the PCC Subspace type 2. + + @param [in] Ptr Pointer to the start of the Subspace Structure. + @param [in] Length Length of the Subspace Structure. +**/ +STATIC +VOID +DumpPccSubspaceType2 ( + IN UINT8* Ptr, + IN UINT8 Length + ) +{ + ParseAcpi ( + TRUE, + 2, + "Subspace Type 2", + Ptr, + Length, + PARSER_PARAMS (PccSubspaceType2Parser) + ); +} + +/** + This function parses the PCC Subspace type 3. + + @param [in] Ptr Pointer to the start of the Subspace Structure. + @param [in] Length Length of the Subspace Structure. +**/ +STATIC +VOID +DumpPccSubspaceType3 ( + IN UINT8* Ptr, + IN UINT8 Length + ) +{ + ParseAcpi ( + TRUE, + 2, + "Subspace Type 3", + Ptr, + Length, + PARSER_PARAMS (PccSubspaceType3Parser) + ); +} + +/** + This function parses the PCC Subspace type 4. + + @param [in] Ptr Pointer to the start of the Subspace Structure. + @param [in] Length Length of the Subspace Structure. +**/ +STATIC +VOID +DumpPccSubspaceType4 ( + IN UINT8* Ptr, + IN UINT8 Length + ) +{ + ParseAcpi ( + TRUE, + 2, + "Subspace Type 4", + Ptr, + Length, + PARSER_PARAMS (PccSubspaceType3Parser) + ); +} + +/** + This function parses the ACPI PCCT table including its sub-structures + of type 0 through 4. + When trace is enabled this function parses the PCCT table and + traces the ACPI table fields. + + This function also performs validation of the ACPI table fields. + + @param [in] Trace If TRUE, trace the ACPI fields. + @param [in] Ptr Pointer to the start of the buffer. + @param [in] AcpiTableLength Length of the ACPI table. + @param [in] AcpiTableRevision Revision of the ACPI table. +**/ +VOID +EFIAPI +ParseAcpiPcct ( + IN BOOLEAN Trace, + IN UINT8* Ptr, + IN UINT32 AcpiTableLength, + IN UINT8 AcpiTableRevision + ) +{ + UINT32 Offset; + UINT8* PccSubspacePtr; + UINTN SubspaceCount; + + if (!Trace) { + return; + } + + Offset =3D ParseAcpi ( + TRUE, + 0, + "PCCT", + Ptr, + AcpiTableLength, + PARSER_PARAMS (PcctParser) + ); + + PccSubspacePtr =3D Ptr + Offset; + + SubspaceCount =3D 0; + while (Offset < AcpiTableLength) { + // Parse common structure header to obtain Type and Length. + ParseAcpi ( + FALSE, + 0, + NULL, + PccSubspacePtr, + AcpiTableLength - Offset, + PARSER_PARAMS (PccSubspaceHeaderParser) + ); + + // Check if the values used to control the parsing logic have been + // successfully read. + if ((PccSubspaceType =3D=3D NULL) || + (PccSubspaceLength =3D=3D NULL)) { + IncrementErrorCount (); + Print ( + L"ERROR: Insufficient remaining table buffer length to read the " = \ + L"structure header. Length =3D %u.\n", + AcpiTableLength - Offset + ); + return; + } + + // Validate Structure length + if ((*PccSubspaceLength =3D=3D 0) || + ((Offset + (*PccSubspaceLength)) > AcpiTableLength)) { + IncrementErrorCount (); + Print ( + L"ERROR: Invalid Structure length. " \ + L"Length =3D %u. Offset =3D %u. AcpiTableLength =3D %u.\n", + *PccSubspaceLength, + Offset, + AcpiTableLength + ); + return; + } + + switch (*PccSubspaceType) { + case EFI_ACPI_6_3_PCCT_SUBSPACE_TYPE_GENERIC: + DumpPccSubspaceType0 ( + PccSubspacePtr, + *PccSubspaceLength + ); + break; + case EFI_ACPI_6_3_PCCT_SUBSPACE_TYPE_1_HW_REDUCED_COMMUNICATIONS: + DumpPccSubspaceType1 ( + PccSubspacePtr, + *PccSubspaceLength + ); + break; + case EFI_ACPI_6_3_PCCT_SUBSPACE_TYPE_2_HW_REDUCED_COMMUNICATIONS: + DumpPccSubspaceType2 ( + PccSubspacePtr, + *PccSubspaceLength + ); + break; + case EFI_ACPI_6_3_PCCT_SUBSPACE_TYPE_3_EXTENDED_PCC: + DumpPccSubspaceType3 ( + PccSubspacePtr, + *PccSubspaceLength + ); + break; + case EFI_ACPI_6_3_PCCT_SUBSPACE_TYPE_4_EXTENDED_PCC: + DumpPccSubspaceType4 ( + PccSubspacePtr, + *PccSubspaceLength + ); + break; + default: + IncrementErrorCount (); + Print ( + L"ERROR: Unknown PCC subspace structure:" + L" Type =3D %u, Length =3D %u\n", + PccSubspaceType, + *PccSubspaceLength + ); + } + + PccSubspacePtr +=3D *PccSubspaceLength; + Offset +=3D *PccSubspaceLength; + SubspaceCount++; + } // while + + if (SubspaceCount > MAX_PCC_SUBSPACES) { + IncrementErrorCount (); + Print (L"ERROR: Too many PCC subspaces."); + } +} diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pcct/Pcct= Parser.h b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pcct/PcctPa= rser.h new file mode 100644 index 0000000000000000000000000000000000000000..278dc83c5de8860cbb2b1e2b2e2= 77aa7c6c58698 --- /dev/null +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pcct/PcctParser.= h @@ -0,0 +1,33 @@ +/** @file + Header file for PCCT parser + + Copyright (c) 2020, Arm Limited. + SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +#ifndef PCCT_PARSER_H_ +#define PCCT_PARSER_H_ + +/** + Minimum value for the 'length' field in subspaces of types 0, 1 and 2. +*/ +#define MIN_MEMORY_RANGE_LENGTH 8 + +/** + Minimum value for the 'length' field in subspaces of types 3 and 4. +*/ +#define MIN_EXT_PCC_SUBSPACE_MEM_RANGE_LEN 16 + +/** + Maximum number of PCC subspaces. +*/ +#define MAX_PCC_SUBSPACES 256 + +/** + Parser for the header of any type of PCC subspace. +*/ +#define PCC_SUBSPACE_HEADER() = \ + {L"Type", 1, 0, L"0x%x", NULL, (VOID**)&PccSubspaceType, NULL, NULL}, = \ + {L"Length", 1, 1, L"%u", NULL, (VOID**)&PccSubspaceLength, NULL, NULL} + +#endif // PCCT_PARSER_H_ diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiView= CommandLib.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiVi= ewCommandLib.c index d2f26ff89f12e596702281c38ab0de3729aa68e4..feb80661cddc420670edb2d8c7a= 570b0a89272d8 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommand= Lib.c +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommand= Lib.c @@ -1,7 +1,7 @@ /** @file Main file for 'acpiview' Shell command function. =20 - Copyright (c) 2016 - 2020, ARM Limited. All rights reserved.
+ Copyright (c) 2016 - 2020, Arm Limited. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent **/ =20 @@ -57,6 +57,8 @@ ACPI_TABLE_PARSER ParserList[] =3D { {EFI_ACPI_6_2_MULTIPLE_APIC_DESCRIPTION_TABLE_SIGNATURE, ParseAcpiMadt}, {EFI_ACPI_6_2_PCI_EXPRESS_MEMORY_MAPPED_CONFIGURATION_SPACE_BASE_ADDRESS= _DESCRIPTION_TABLE_SIGNATURE, ParseAcpiMcfg}, + {EFI_ACPI_6_2_PLATFORM_COMMUNICATIONS_CHANNEL_TABLE_SIGNATURE, + ParseAcpiPcct}, {EFI_ACPI_6_2_PROCESSOR_PROPERTIES_TOPOLOGY_TABLE_STRUCTURE_SIGNATURE, ParseAcpiPptt}, {RSDP_TABLE_INFO, ParseAcpiRsdp}, diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiView= CommandLib.inf b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpi= ViewCommandLib.inf index 91459f9ec632635ee453c5ef46f67445cd9eee0c..efa9c8784a6670e5a4f500e0ae5= 59a4938852f95 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommand= Lib.inf +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommand= Lib.inf @@ -1,7 +1,7 @@ ## @file # Provides Shell 'acpiview' command functions # -# Copyright (c) 2016 - 2020, ARM Limited. All rights reserved.
+# Copyright (c) 2016 - 2020, Arm Limited. All rights reserved.
# # SPDX-License-Identifier: BSD-2-Clause-Patent # @@ -37,6 +37,8 @@ [Sources.common] Parsers/Madt/MadtParser.c Parsers/Madt/MadtParser.h Parsers/Mcfg/McfgParser.c + Parsers/Pcct/PcctParser.c + Parsers/Pcct/PcctParser.h Parsers/Pptt/PpttParser.c Parsers/Pptt/PpttParser.h Parsers/Rsdp/RsdpParser.c --=20 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'