From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from EUR02-VE1-obe.outbound.protection.outlook.com (EUR02-VE1-obe.outbound.protection.outlook.com [40.107.2.64]) by mx.groups.io with SMTP id smtpd.web11.19967.1599737815384110718 for ; Thu, 10 Sep 2020 04:36:56 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@armh.onmicrosoft.com header.s=selector2-armh-onmicrosoft-com header.b=iV9htYWW; spf=pass (domain: arm.com, ip: 40.107.2.64, 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=tnpsI9Nl/bS8gzTVfqCy8Py6tpFNRDZ/J4jY1tQpLsk=; b=iV9htYWWpTa+PQvWZ4B8CGt+b1viL3/AXnQEuLYJhLU1lI3xBCpq7SWMHBxQXioCtyj8gs0dY0vmgyAtKdBdXK1kO3xpNvpMI3kjHefIjKvLFCyYMgoLuobKXW5Y5NpxMAD74y8mKYDDD3+82Tgi219ZI4TtAW2AX1anQUvp/Lo= Received: from AM4PR0202CA0002.eurprd02.prod.outlook.com (2603:10a6:200:89::12) by AM0PR08MB5508.eurprd08.prod.outlook.com (2603:10a6:208:186::14) 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:36:52 +0000 Received: from AM5EUR03FT034.eop-EUR03.prod.protection.outlook.com (2603:10a6:200:89:cafe::47) by AM4PR0202CA0002.outlook.office365.com (2603:10a6:200:89::12) 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:36:52 +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 AM5EUR03FT034.mail.protection.outlook.com (10.152.16.81) 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:36:52 +0000 Received: ("Tessian outbound e8cdb8c6f386:v64"); Thu, 10 Sep 2020 11:36:51 +0000 X-CR-MTA-TID: 64aa7808 Received: from e93eb8cd46e0.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 20F371A5-63B2-4A10-8977-3367AE67E3E5.1; Thu, 10 Sep 2020 11:36:46 +0000 Received: from EUR04-DB3-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id e93eb8cd46e0.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 10 Sep 2020 11:36:46 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=F4VlLCnD+zpZavs5X3hIbI7N3jpPC3V62bRAWHCLAxK5zQzNJ5h3SYBkcB4jfwacZgq99tn1k7YB4Lpa/wP43m0s7zsdZfNKf25jCDCkhIHaBHISoAwJf+3Edr+Vb9EYp945XsfmORBR1eXo5Q5qAlPBok2PEJffJtiom4kOjLiO2FfHeyiljPTQlbLFtJpsAFjytJmYaGT9V3Gpina+rO6hvExdnfkpSuYq+qKIT1BTiTPbIwhXHz2wx+6ZN7BWtNyhykqhXB9aSL7jqAAVgDopRUXR+KsIde0jBymrLlhzhJclD+yQHi6XxWZ3xzzOqCIp311h4azQIExPD+9j2g== 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=tnpsI9Nl/bS8gzTVfqCy8Py6tpFNRDZ/J4jY1tQpLsk=; b=lyJEBYyUauUhvBo+H68c+9NSTfCFWGHKp9YP0+NO6spZNObLv7sY+fyVxGH+h/joAXRmbNVgjmGs4tV0KKY5W+fPOY/SeIAJUblZ1GhLLRNRG58qxKpokCZZLoFH1TddC+ewUzRY6FKcGU2Ni77CYcpLjt6dAmhhPN8MA1LtFtbF8pHbF1kIy3Tbh3Qhhve3qD+fmyUhpVCm1sKffsHilKrUZ5he2wkxw3tQlDb2NhRGZVMKUAZfQszrWeyDqj6uARKNDEXQjAlNkovGpPU8+1BsKJOMZiaLD2G3Fie6enzQTJhg1e29hFt82KFdgpzq8ELD+euG3PmZfb7T346WAw== 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=tnpsI9Nl/bS8gzTVfqCy8Py6tpFNRDZ/J4jY1tQpLsk=; b=iV9htYWWpTa+PQvWZ4B8CGt+b1viL3/AXnQEuLYJhLU1lI3xBCpq7SWMHBxQXioCtyj8gs0dY0vmgyAtKdBdXK1kO3xpNvpMI3kjHefIjKvLFCyYMgoLuobKXW5Y5NpxMAD74y8mKYDDD3+82Tgi219ZI4TtAW2AX1anQUvp/Lo= Received: from DB7PR08MB3097.eurprd08.prod.outlook.com (2603:10a6:5:1d::27) by DB8PR08MB5355.eurprd08.prod.outlook.com (2603:10a6:10:11f::15) 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:36:44 +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:36:44 +0000 From: "Sami Mujawar" To: "zhichao.gao@intel.com" , "devel@edk2.groups.io" CC: "ray.ni@intel.com" , Marc Moisson-Franckhauser , Guillaume Letellier , Matteo Carlini , Ben Adderson , nd , Sami Mujawar Subject: Re: [PATCH v2 1/1] ShellPkg/AcpiView: HMAT Parser Thread-Topic: [PATCH v2 1/1] ShellPkg/AcpiView: HMAT Parser Thread-Index: AQHWes/sRzallutxSkKHJJqFYiFw6qlh1zAQ Date: Thu, 10 Sep 2020 11:36:44 +0000 Message-ID: References: <20200825110651.17652-1-sami.mujawar@arm.com> In-Reply-To: <20200825110651.17652-1-sami.mujawar@arm.com> Accept-Language: en-GB, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ts-tracking-id: 46A5C3E10F137C4993309B8909A2BA63.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: b8f704c5-31a3-431b-031c-08d8557dcff8 x-ms-traffictypediagnostic: DB8PR08MB5355:|AM0PR08MB5508: x-ms-exchange-transport-forked: True X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true nodisclaimer: true x-ms-oob-tlc-oobclassifiers: OLM:8882;OLM:8882; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: m2LZAFgYgEIKjueu8qFzpGLCg6ar8qgVI0N+qCvYr5BSBoUhtna/Y/1vj/5dheYZCvZt2qjI/YSqf3hUgMp6ohZgNpwjWUTZiIa1neIqAmxMEKBhR+cx5I2+Lltcx2tFmTARLHpvGFM4iP+ioV8zfAdXFRoBob8bKV0AlIbG31L5vukNYwMnl223sUT1GWyKHSTRAT5/O23vkD9M4E+o6Zxs/F/HREed/9xOEf/DqOUo6VIg7Wf2EQRgSyiV8dBm3BNgv828b8346K5lm7e5flak39W/lfjobUk3fUQkcL35VxU6XrNyyAeubZOIR56H6iePlIX0WZsdU0srRtW+CjLB3tuCvUoN29mrnfo0jpevdOQRZQRWicdd7ZG5KDnmvnBs8uobarlqBKc6kL0Yag== 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)(346002)(376002)(39860400002)(366004)(136003)(396003)(66946007)(64756008)(66446008)(76116006)(66556008)(8936002)(66476007)(30864003)(316002)(52536014)(71200400001)(33656002)(83380400001)(7696005)(45954011)(5660300002)(966005)(2906002)(54906003)(186003)(26005)(86362001)(55016002)(8676002)(478600001)(9686003)(4326008)(53546011)(110136005)(6506007)(579004)(559001);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata: UfoqWc+Pt7BeSSV1HcWjKifUvRN57ifxWpaK3atZmNUS8FUp/ltKZZqalwLy06+QUGbw0qyF5ZniqjmgOkXz04Rw7lroFUzPvISAhV0cIkSIFKBmJLRpTjsQfl7mRVOcPs+vfRqRvS2Z41kuaXAZPpz78wFf/HLWbe5LM695pqlUqqMxhG8zuTHou7BH5mi1yPQUQ0OMTVydDl30IouJBcTbKhemX6u2ehyzQboy9X9WUW6l7gZxP9RsGsYieRELw8Kh2fjpIvwGQQWTlv6Zus8kM6yeTdnOeXMrIwQCGTTptjAo//9vw7wQIljNILdEQwfwBoMq0o+bTkgI8ZChdcI0pgo/Q8EUf49FHPjAXE65WRvbXXosMveKjgWxWCk2Y12SaZKH7C+whmzVSbewrZ2+BZ6QuzB3D5nonEmONX/K24ZHYl75WlRL3pDxPvJpg0CEpOXIXL6MNMvwbpTbR1KqVLH2fQGVNOhF+6Q55gISL2bh6TAg7vzDUB39zJmxHrGONmM1MqcbdpOxsJeUOgTdnV9QPMZz7RqX1oWVhbUWRMME3xDWJPXPwpgX/SFL0KlZV2e05YzLQm3JiYZJJkMvZ0P7MgMYWdufS7Dd4SjiL7p8keYSLi7jXklzlIt73MOxrMX0IH5rgdZV3KGzig== MIME-Version: 1.0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8PR08MB5355 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: AM5EUR03FT034.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: cf858d39-916b-4b8f-8c17-08d8557dcb9a X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: FkoQWNNjBWhr+QLUCgUXAUbQvxlfMN34ZZYenuatukBfmCsV5EU2XB/j8P5sMhNRiF8LDwv3NggC2lwCv7zvlhW63BI7FZrHw+C/BZH2GonyJ+cgMogS+fUyhIJoPegpoLp3dMi6/T+WSsU7KMMoJeFQdv2L+1s5zQI8w9l5ZBT6nXbf/NeERPmhq13uPcjS10AP6uPNBN+8yYqWYI3Lr7zjNd88EWGM+ldKYqqlmG9NVJ9ZKPdbtE1C4Up8K1QLoUjJD3wSdeqFjHZX9Nh1VEHFffkbKU5rrV8+faLY7y2YgpsEsfnAN6psTrIdp97VsUR5/3qLTO0TCr8RhY/cofoM3QQ9PiMhQTmnu2pdAsvCFGv9zOnEUS9gHxVKWOoIvTxp25FzS8bL8EkRZGWUn1KNyCHrgbLXWYVVcFHz3Nl1XiP0hf5bDiXWvpC+NGkmQkki0AT3Ep0X7iSpkoZ8JV97Agisim61nNL+B8GaYhI= 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)(136003)(39860400002)(346002)(376002)(46966005)(7696005)(8676002)(5660300002)(316002)(83380400001)(45954011)(36906005)(53546011)(26005)(6506007)(356005)(55016002)(82740400003)(81166007)(47076004)(33656002)(966005)(4326008)(70586007)(70206006)(9686003)(30864003)(8936002)(54906003)(110136005)(82310400003)(336012)(478600001)(2906002)(186003)(52536014)(86362001);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Sep 2020 11:36:52.0555 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b8f704c5-31a3-431b-031c-08d8557dcff8 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: AM5EUR03FT034.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB5508 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: 25 August 2020 12:07 PM 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 v2 1/1] ShellPkg/AcpiView: HMAT Parser From: Marc Moisson-Franckhauser Add a new parser for the Heterogeneous Memory Attribute Table. The parser also validates some fields for this table. The HMAT table is used to describe the memory attributes such as memory side cache attributes and bandwidth and latency details related to memory proximity domains. The info in the HMAT table can be used by an operating system for optimisation. Signed-off-by: Marc Moisson-Franckhauser Signed-off-by: Sami Mujawar --- The changes can be seen at: https://github.com/samimujawar/edk2/tree/833_hmat_parser_v2 Notes: v2: - Fixed minor output formatting in DumpCacheAttributes() [SAMI] ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h = | 28 +- ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiTableParser.h = | 4 +- ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Hmat/HmatParser.c = | 641 ++++++++++++++++++++ ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.c= | 3 +- ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.i= nf | 3 +- ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.u= ni | 3 +- 6 files changed, 676 insertions(+), 6 deletions(-) diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h b/Sh= ellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h index f81ccac7e118378aa185db4b625e5bcd75f78347..969cc0b371852f01f30c88dc506= 374a459c9c19e 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 @@ -592,6 +592,32 @@ ParseAcpiGtdt ( ); =20 /** + This function parses the ACPI HMAT table. + When trace is enabled this function parses the HMAT table and + traces the ACPI table fields. + + This function parses the following HMAT structures: + - Memory Proximity Domain Attributes Structure (Type 0) + - System Locality Latency and Bandwidth Info Structure (Type 1) + - Memory Side Cache Info structure (Type 2) + + 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 +ParseAcpiHmat ( + IN BOOLEAN Trace, + IN UINT8* Ptr, + IN UINT32 AcpiTableLength, + IN UINT8 AcpiTableRevision + ); + +/** This function parses the ACPI IORT table. When trace is enabled this function parses the IORT table and traces the ACPI fields. diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiTableParser.h= b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiTableParser.h index 4f92596b90a6ee422d8d0959881015ffd3de4da0..f8e8b5979f3be041bbc8d17042b= 2db8e0b73f205 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 - 2018, 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 32 =20 /** An invalid/NULL signature value. */ diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Hmat/Hmat= Parser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Hmat/HmatPa= rser.c new file mode 100644 index 0000000000000000000000000000000000000000..57b93cca6ba24ed77f9dcd7bf2f= 45ba9f0cb9f26 --- /dev/null +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Hmat/HmatParser.= c @@ -0,0 +1,641 @@ +/** @file + HMAT table parser + + Copyright (c) 2020, Arm Limited. + SPDX-License-Identifier: BSD-2-Clause-Patent + + @par Reference(s): + - ACPI 6.3 Specification - January 2019 + + @par Glossary: + - MPDA - Memory Proximity Domain Attributes + - SLLBI - System Locality Latency and Bandwidth Information + - MSCI - Memory Side Cache Information + - Dom - Domain +**/ + +#include +#include +#include +#include "AcpiParser.h" +#include "AcpiView.h" + +// Maximum Memory Domain matrix print size. +#define MAX_MEMORY_DOMAIN_TARGET_PRINT_MATRIX 12 + +// Local variables +STATIC CONST UINT16* HmatStructureType; +STATIC CONST UINT32* HmatStructureLength; + +STATIC CONST UINT32* NumberInitiatorProximityDomain; +STATIC CONST UINT32* NumberTargetProximityDomain; +STATIC CONST +EFI_ACPI_6_3_HMAT_STRUCTURE_SYSTEM_LOCALITY_LATENCY_AND_BANDWIDTH_INFO_FLA= GS* +SllbiFlags; + +STATIC CONST UINT8* SllbiDataType; +STATIC CONST UINT32* NumberSMBIOSHandles; + +STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo; + +/** + Names of System Locality Latency Bandwidth Information (SLLBI) data type= s +**/ +STATIC CONST CHAR16* SllbiNames[] =3D { + L"Access %sLatency%s", + L"Read %sLatency%s", + L"Write %sLatency%s", + L"Access %sBandwidth%s", + L"Read %sBandwidth%s", + L"Write %sBandwidth%s" +}; + +/** + This function validates the Cache Attributes field. + + @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 +ValidateCacheAttributes ( + IN UINT8* Ptr, + IN VOID* Context + ) +{ + EFI_ACPI_6_3_HMAT_STRUCTURE_MEMORY_SIDE_CACHE_INFO_CACHE_ATTRIBUTES* + Attributes; + + Attributes =3D + (EFI_ACPI_6_3_HMAT_STRUCTURE_MEMORY_SIDE_CACHE_INFO_CACHE_ATTRIBUTES*)= Ptr; + + if (Attributes->TotalCacheLevels > 0x3) { + IncrementErrorCount (); + Print ( + L"\nERROR: Attributes bits [3:0] have invalid value: 0x%x", + Attributes->TotalCacheLevels + ); + } + if (Attributes->CacheLevel > 0x3) { + IncrementErrorCount (); + Print ( + L"\nERROR: Attributes bits [7:4] have invalid value: 0x%x", + Attributes->CacheLevel + ); + } + if (Attributes->CacheAssociativity > 0x2) { + IncrementErrorCount (); + Print ( + L"\nERROR: Attributes bits [11:8] have invalid value: 0x%x", + Attributes->CacheAssociativity + ); + } + if (Attributes->WritePolicy > 0x2) { + IncrementErrorCount (); + Print ( + L"\nERROR: Attributes bits [15:12] have invalid value: 0x%x", + Attributes->WritePolicy + ); + } +} + +/** + Dumps the cache attributes field + + @param [in] Format Optional format string for tracing the data. + @param [in] Ptr Pointer to the start of the buffer. +**/ +STATIC +VOID +EFIAPI +DumpCacheAttributes ( + IN CONST CHAR16* Format OPTIONAL, + IN UINT8* Ptr + ) +{ + EFI_ACPI_6_3_HMAT_STRUCTURE_MEMORY_SIDE_CACHE_INFO_CACHE_ATTRIBUTES* + Attributes; + + Attributes =3D + (EFI_ACPI_6_3_HMAT_STRUCTURE_MEMORY_SIDE_CACHE_INFO_CACHE_ATTRIBUTES*)= Ptr; + + Print (L"\n"); + PrintFieldName (4, L"Total Cache Levels"); + Print (L"%d\n", Attributes->TotalCacheLevels); + PrintFieldName (4, L"Cache Level"); + Print (L"%d\n", Attributes->CacheLevel); + PrintFieldName (4, L"Cache Associativity"); + Print (L"%d\n", Attributes->CacheAssociativity); + PrintFieldName (4, L"Write Policy"); + Print (L"%d\n", Attributes->WritePolicy); + PrintFieldName (4, L"Cache Line Size"); + Print (L"%d\n", Attributes->CacheLineSize); +} + +/** + An ACPI_PARSER array describing the ACPI HMAT Table. +*/ +STATIC CONST ACPI_PARSER HmatParser[] =3D { + PARSE_ACPI_HEADER (&AcpiHdrInfo), + {L"Reserved", 4, 36, NULL, NULL, NULL, NULL, NULL} +}; + +/** + An ACPI_PARSER array describing the HMAT structure header. +*/ +STATIC CONST ACPI_PARSER HmatStructureHeaderParser[] =3D { + {L"Type", 2, 0, NULL, NULL, (VOID**)&HmatStructureType, NULL, NULL}, + {L"Reserved", 2, 2, NULL, NULL, NULL, NULL, NULL}, + {L"Length", 4, 4, NULL, NULL, (VOID**)&HmatStructureLength, NULL, NULL} +}; + +/** + An ACPI PARSER array describing the Memory Proximity Domain Attributes + Structure - Type 0. +*/ +STATIC CONST ACPI_PARSER MemProximityDomainAttributeParser[] =3D { + {L"Type", 2, 0, L"0x%x", NULL, NULL, NULL, NULL}, + {L"Reserved", 2, 2, L"0x%x", NULL, NULL, NULL, NULL}, + {L"Length", 4, 4, L"%d", NULL, NULL, NULL, NULL}, + {L"Flags", 2, 8, L"0x%x", NULL, NULL, NULL, NULL}, + {L"Reserved", 2, 10, L"0x%x", NULL, NULL, NULL, NULL}, + {L"Proximity Dom for initiator", 4, 12, L"0x%x", NULL, NULL, NULL, NULL}= , + {L"Proximity Dom for memory", 4, 16, L"0x%x", NULL, NULL, NULL, NULL}, + {L"Reserved", 4, 20, L"0x%x", NULL, NULL, NULL, NULL}, + {L"Reserved", 8, 24, L"0x%lx", NULL, NULL, NULL, NULL}, + {L"Reserved", 8, 32, L"0x%lx", NULL, NULL, NULL, NULL} +}; + +/** + An ACPI PARSER array describing the System Locality Latency and Bandwidt= h + Information Structure - Type 1. +*/ +STATIC CONST ACPI_PARSER +SllbiParser[] =3D { + {L"Type", 2, 0, L"0x%x", NULL, NULL, NULL, NULL}, + {L"Reserved", 2, 2, L"0x%x", NULL, NULL, NULL, NULL}, + {L"Length", 4, 4, L"%d", NULL, NULL, NULL, NULL}, + {L"Flags", 1, 8, L"0x%x", NULL, (VOID**)&SllbiFlags, NULL, NULL}, + {L"Data type", 1, 9, L"0x%x", NULL, (VOID**)&SllbiDataType, NULL, NULL}, + {L"Reserved", 2, 10, L"0x%x", NULL, NULL, NULL, NULL}, + {L"Initiator Proximity Dom Count", 4, 12, L"%d", NULL, + (VOID**)&NumberInitiatorProximityDomain, NULL, NULL}, + {L"Target Proximity Dom Count", 4, 16, L"%d", NULL, + (VOID**)&NumberTargetProximityDomain, NULL, NULL}, + {L"Reserved", 4, 20, L"0x%x", NULL, NULL, NULL, NULL}, + {L"Entry Base Unit", 8, 24, L"0x%lx", NULL, NULL, NULL, NULL} + // initiator Proximity Domain list ... + // target Proximity Domain list ... + // Latency/Bandwidth matrix ... +}; + +/** + An ACPI PARSER array describing the Memory Side Cache Information + Structure - Type 2. +*/ +STATIC CONST ACPI_PARSER MemSideCacheInfoParser[] =3D { + {L"Type", 2, 0, L"0x%x", NULL, NULL, NULL, NULL}, + {L"Reserved", 2, 2, L"0x%x", NULL, NULL, NULL, NULL}, + {L"Length", 4, 4, L"%d", NULL, NULL, NULL, NULL}, + {L"Proximity Dom for memory", 4, 8, L"0x%x", NULL, NULL, NULL, NULL}, + {L"Reserved", 4, 12, L"0x%x", NULL, NULL, NULL, NULL}, + {L"Memory Side Cache Size", 8, 16, L"0x%lx", NULL, NULL, NULL, NULL}, + {L"Cache Attributes", 4, 24, NULL, DumpCacheAttributes, NULL, + ValidateCacheAttributes, NULL}, + {L"Reserved", 2, 28, L"0x%x", NULL, NULL, NULL, NULL}, + {L"SMBIOS Handle Count", 2, 30, L"%d", NULL, + (VOID**)&NumberSMBIOSHandles, NULL, NULL} + // SMBIOS handles List ... +}; + +/** + This function parses the Memory Proximity Domain Attributes + Structure (Type 0). + + @param [in] Ptr Pointer to the start of the Memory Proximity Domain + Attributes Structure data. + @param [in] Length Length of the Memory Proximity Domain Attributes + Structure. +**/ +STATIC +VOID +DumpMpda ( + IN UINT8* Ptr, + IN UINT8 Length + ) +{ + ParseAcpi ( + TRUE, + 2, + "Memory Proximity Domain Attributes Structure", + Ptr, + Length, + PARSER_PARAMS (MemProximityDomainAttributeParser) + ); +} + +/** + This function parses the System Locality Latency and Bandwidth Informati= on + Structure (Type 1). + + @param [in] Ptr Pointer to the start of the System Locality Latency = and + Bandwidth Information Structure data. + @param [in] Length Length of the System Locality Latency and Bandwidth + Information Structure. +**/ +STATIC +VOID +DumpSllbi ( + IN UINT8* Ptr, + IN UINT8 Length + ) +{ + CONST UINT32* InitiatorProximityDomainList; + CONST UINT32* TargetProximityDomainList; + CONST UINT16* LatencyBandwidthMatrix; + UINT32 Offset; + CHAR16 Buffer[OUTPUT_FIELD_COLUMN_WIDTH]; + CHAR16 SecondBuffer[OUTPUT_FIELD_COLUMN_WIDTH]; + UINT32 RequiredTableSize; + UINT32 Index; + UINT32 IndexInitiator; + UINT32 IndexTarget; + + Offset =3D ParseAcpi ( + TRUE, + 2, + "System Locality Latency and Bandwidth Information Structure"= , + Ptr, + Length, + PARSER_PARAMS (SllbiParser) + ); + + // Check if the values used to control the parsing logic have been + // successfully read. + if ((SllbiFlags =3D=3D NULL) || + (SllbiDataType =3D=3D NULL) || + (NumberInitiatorProximityDomain =3D=3D NULL) || + (NumberTargetProximityDomain =3D=3D NULL)) { + IncrementErrorCount (); + Print ( + L"ERROR: Insufficient remaining table buffer length to read the " \ + L"SLLBI structure header. Length =3D %d.\n", + Length + ); + return; + } + + RequiredTableSize =3D (*NumberInitiatorProximityDomain * sizeof (UINT32)= ) + + (*NumberTargetProximityDomain * sizeof (UINT32)) + + (*NumberInitiatorProximityDomain * + *NumberTargetProximityDomain * sizeof (UINT16)) + + Offset; + + if (RequiredTableSize > Length) { + IncrementErrorCount (); + Print ( + L"ERROR: Insufficient System Locality Latency and Bandwidth" \ + L"Information Structure length. TableLength =3D %d. " \ + L"RequiredTableLength =3D %d.\n", + Length, + RequiredTableSize + ); + return; + } + + InitiatorProximityDomainList =3D (UINT32*) (Ptr + Offset); + TargetProximityDomainList =3D InitiatorProximityDomainList + + *NumberInitiatorProximityDomain; + LatencyBandwidthMatrix =3D (UINT16*) (TargetProximityDomainList + + *NumberTargetProximityDomain); + + // Display each element of the Initiator Proximity Domain list + for (Index =3D 0; Index < *NumberInitiatorProximityDomain; Index++) { + UnicodeSPrint ( + Buffer, + sizeof (Buffer), + L"Initiator Proximity Dom [%d]", + Index + ); + + PrintFieldName (4, Buffer); + Print ( + L"0x%x\n", + InitiatorProximityDomainList[Index] + ); + } + + // Display each element of the Target Proximity Domain list + for (Index =3D 0; Index < *NumberTargetProximityDomain; Index++) { + UnicodeSPrint ( + Buffer, + sizeof (Buffer), + L"Target Proximity Dom [%d]", + Index + ); + + PrintFieldName (4, Buffer); + Print ( + L"0x%x\n", + TargetProximityDomainList[Index] + ); + } + + // Create base name depending on Data Type in this Structure + if (*SllbiDataType >=3D ARRAY_SIZE (SllbiNames)) { + IncrementErrorCount (); + Print (L"Error: Unkown Data Type. DataType =3D 0x%x.\n", *SllbiDataTyp= e); + return; + } + StrCpyS (Buffer, sizeof (Buffer), SllbiNames[*SllbiDataType]); + + // Adjust base name depending on Memory Hierarchy in this Structure + switch (SllbiFlags->MemoryHierarchy) { + case 0: { + UnicodeSPrint ( + SecondBuffer, + sizeof (SecondBuffer), + Buffer, + L"", + L"%s" + ); + break; + } + + case 1: + case 2: + case 3: { + UnicodeSPrint ( + SecondBuffer, + sizeof (SecondBuffer), + Buffer, + L"Hit ", + L"%s" + ); + break; + } + + default: { + IncrementErrorCount (); + Print ( + L"Error: Invalid Memory Hierarchy. MemoryHierarchy =3D %d.\n", + SllbiFlags->MemoryHierarchy + ); + return; + } + } // switch + + if (IndexInitiator <=3D MAX_MEMORY_DOMAIN_TARGET_PRINT_MATRIX) { + // Display the latency/bandwidth matrix as a matrix + UnicodeSPrint ( + Buffer, + sizeof (Buffer), + SecondBuffer, + L"" + ); + PrintFieldName (4, Buffer); + Print (L"\n\n Initiator ->\nTarget\n|\nV\n"); + Print (L" |"); + + for (IndexTarget =3D 0; + IndexTarget < *NumberTargetProximityDomain; + IndexTarget++) { + Print (L" %2d", IndexTarget); + } + + Print (L"\n---+"); + for (IndexTarget =3D 0; + IndexTarget < *NumberTargetProximityDomain; + IndexTarget++) { + Print (L"-------"); + } + Print (L"\n"); + + for (IndexInitiator =3D 0; + IndexInitiator < *NumberInitiatorProximityDomain; + IndexInitiator++) { + Print (L"%2d |", IndexInitiator); + for (IndexTarget =3D 0; + IndexTarget < *NumberTargetProximityDomain; + IndexTarget++) { + Print ( + L" %5d", + LatencyBandwidthMatrix[IndexInitiator * + (*NumberTargetProximityDomain + IndexTarg= et)] + ); + } // for Target + Print (L"\n"); + } // for Initiator + Print (L"\n"); + } else { + // Display the latency/bandwidth matrix as a list + UnicodeSPrint ( + Buffer, + sizeof (Buffer), + SecondBuffer, + L" [%d][%d]" + ); + for (IndexInitiator =3D 0; + IndexInitiator < *NumberInitiatorProximityDomain; + IndexInitiator++) { + for (IndexTarget =3D 0; + IndexTarget < *NumberTargetProximityDomain; + IndexTarget++) { + UnicodeSPrint ( + Buffer, + sizeof (Buffer), + SecondBuffer, + IndexInitiator, + IndexTarget + ); + + PrintFieldName (4, Buffer); + Print ( + L"%d\n", + LatencyBandwidthMatrix[IndexInitiator * + (*NumberTargetProximityDomain + IndexTarg= et)] + ); + } // for Target + } // for Initiator + } +} + +/** + This function parses the Memory Side Cache Information Structure (Type 2= ). + + @param [in] Ptr Pointer to the start of the Memory Side Cache Inform= ation + Structure data. + @param [in] Length Length of the Memory Side Cache Information Structur= e. +**/ +STATIC +VOID +DumpMsci ( + IN UINT8* Ptr, + IN UINT8 Length + ) +{ + CONST UINT16* SMBIOSHandlesList; + CHAR16 Buffer[OUTPUT_FIELD_COLUMN_WIDTH]; + UINT32 Offset; + UINT16 Index; + + Offset =3D ParseAcpi ( + TRUE, + 2, + "Memory Side Cache Information Structure", + Ptr, + Length, + PARSER_PARAMS (MemSideCacheInfoParser) + ); + + // Check if the values used to control the parsing logic have been + // successfully read. + if (NumberSMBIOSHandles =3D=3D NULL) { + IncrementErrorCount (); + Print ( + L"ERROR: Insufficient remaining table buffer length to read the " \ + L"MSCI structure header. Length =3D %d.\n", + Length + ); + return; + } + + if ((*NumberSMBIOSHandles * sizeof (UINT16)) > (Length - Offset)) { + IncrementErrorCount (); + Print ( + L"ERROR: Invalid Number of SMBIOS Handles. SMBIOSHandlesCount =3D %d= ." \ + L"RemainingBufferLength =3D %d.\n", + *NumberSMBIOSHandles, + Length - Offset + ); + return; + } + + SMBIOSHandlesList =3D (UINT16*) (Ptr + Offset); + + for (Index =3D 0; Index < *NumberSMBIOSHandles; Index++) { + UnicodeSPrint ( + Buffer, + sizeof (Buffer), + L"SMBIOS Handles [%d]", + Index + ); + + PrintFieldName (4, Buffer); + Print ( + L"0x%x\n", + SMBIOSHandlesList[Index] + ); + } +} + +/** + This function parses the ACPI HMAT table. + When trace is enabled this function parses the HMAT table and + traces the ACPI table fields. + + This function parses the following HMAT structures: + - Memory Proximity Domain Attributes Structure (Type 0) + - System Locality Latency and Bandwidth Info Structure (Type 1) + - Memory Side Cache Info structure (Type 2) + + 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 +ParseAcpiHmat ( + IN BOOLEAN Trace, + IN UINT8* Ptr, + IN UINT32 AcpiTableLength, + IN UINT8 AcpiTableRevision + ) +{ + UINT32 Offset; + UINT8* HmatStructurePtr; + + if (!Trace) { + return; + } + + Offset =3D ParseAcpi ( + Trace, + 0, + "HMAT", + Ptr, + AcpiTableLength, + PARSER_PARAMS (HmatParser) + ); + + HmatStructurePtr =3D Ptr + Offset; + + while (Offset < AcpiTableLength) { + // Parse HMAT Structure Header to obtain Type and Length. + ParseAcpi ( + FALSE, + 0, + NULL, + HmatStructurePtr, + AcpiTableLength - Offset, + PARSER_PARAMS (HmatStructureHeaderParser) + ); + + // Check if the values used to control the parsing logic have been + // successfully read. + if ((HmatStructureType =3D=3D NULL) || + (HmatStructureLength =3D=3D NULL)) { + IncrementErrorCount (); + Print ( + L"ERROR: Insufficient remaining table buffer length to read the " = \ + L"HMAT structure header. Length =3D %d.\n", + AcpiTableLength - Offset + ); + return; + } + + switch (*HmatStructureType) { + case EFI_ACPI_6_3_HMAT_TYPE_MEMORY_PROXIMITY_DOMAIN_ATTRIBUTES: { + DumpMpda ( + HmatStructurePtr, + *HmatStructureLength + ); + break; + } + + case EFI_ACPI_6_3_HMAT_TYPE_SYSTEM_LOCALITY_LATENCY_AND_BANDWIDTH_IN= FO: { + DumpSllbi ( + HmatStructurePtr, + *HmatStructureLength + ); + break; + } + + case EFI_ACPI_6_3_HMAT_TYPE_MEMORY_SIDE_CACHE_INFO: { + DumpMsci ( + HmatStructurePtr, + *HmatStructureLength + ); + break; + } + + default: { + IncrementErrorCount (); + Print ( + L"ERROR: Unknown HMAT structure:" + L" Type =3D %d, Length =3D %d\n", + *HmatStructureType, + *HmatStructureLength + ); + } + } + + HmatStructurePtr +=3D *HmatStructureLength; + Offset +=3D *HmatStructureLength; + } // while +} diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiView= CommandLib.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiVi= ewCommandLib.c index d2f26ff89f12e596702281c38ab0de3729aa68e4..c9e3054a5c413ba95e6420ce3d0= 2f0d954e99d90 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 @@ -53,6 +53,7 @@ ACPI_TABLE_PARSER ParserList[] =3D { {EFI_ACPI_6_3_FIRMWARE_ACPI_CONTROL_STRUCTURE_SIGNATURE, ParseAcpiFacs}, {EFI_ACPI_6_2_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATURE, ParseAcpiFadt}, {EFI_ACPI_6_2_GENERIC_TIMER_DESCRIPTION_TABLE_SIGNATURE, ParseAcpiGtdt}, + {EFI_ACPI_6_3_HETEROGENEOUS_MEMORY_ATTRIBUTE_TABLE_SIGNATURE, ParseAcpiH= mat}, {EFI_ACPI_6_2_IO_REMAPPING_TABLE_SIGNATURE, ParseAcpiIort}, {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, diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiView= CommandLib.inf b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpi= ViewCommandLib.inf index 91459f9ec632635ee453c5ef46f67445cd9eee0c..e970c4259c143b5b06fb1a759d5= 819e7cb93e749 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 # @@ -33,6 +33,7 @@ [Sources.common] Parsers/Facs/FacsParser.c Parsers/Fadt/FadtParser.c Parsers/Gtdt/GtdtParser.c + Parsers/Hmat/HmatParser.c Parsers/Iort/IortParser.c Parsers/Madt/MadtParser.c Parsers/Madt/MadtParser.h diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiView= CommandLib.uni b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpi= ViewCommandLib.uni index 7cd43d0518fd0a23dc547a5cab0d08b62602a113..6b0537b47a751184e8a68a6530a= a85eb28ea33ba 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommand= Lib.uni +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommand= Lib.uni @@ -1,6 +1,6 @@ // /** // -// 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 // // Module Name: @@ -84,6 +84,7 @@ " DSDT - Differentiated System Description Table\r\n" " FACP - Fixed ACPI Description Table (FADT)\r\n" " GTDT - Generic Timer Description Table\r\n" +" HMAT - Heterogeneous Memory Attributes Table\r\n" " IORT - IO Remapping Table\r\n" " MCFG - Memory Mapped Config Space Base Address Description Table\= r\n" " PPTT - Processor Properties Topology Table\r\n" --=20 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'