From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from EUR02-AM5-obe.outbound.protection.outlook.com (EUR02-AM5-obe.outbound.protection.outlook.com [40.107.0.79]) by mx.groups.io with SMTP id smtpd.web11.192141.1598264632363332909 for ; Mon, 24 Aug 2020 03:23:53 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@armh.onmicrosoft.com header.s=selector2-armh-onmicrosoft-com header.b=yOE926gq; spf=pass (domain: arm.com, ip: 40.107.0.79, 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=YdF2MdqjVD+p6tVYmwTtVj6XNgKAJkLTYw30rDoWSh8=; b=yOE926gq8b3qNLG/UnqsHtI1m31W0rAD8nUl1sN9G8ylQ+gYTQNKoJGflCQ+ia89klVZdAXbsoNo6VDfhNou/+uaWFLQUwYgJMCKPISJxr5DnpOCPHpyEFjc/EqbLghYJaJF/7mr++W733akVSowd8Y3M+2eVI7qxIsiZiX+x20= Received: from DB8PR03CA0014.eurprd03.prod.outlook.com (2603:10a6:10:be::27) by VE1PR08MB4878.eurprd08.prod.outlook.com (2603:10a6:802:a7::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3305.26; Mon, 24 Aug 2020 10:23:48 +0000 Received: from DB5EUR03FT042.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:be::4) by DB8PR03CA0014.outlook.office365.com (2603:10a6:10:be::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3305.24 via Frontend Transport; Mon, 24 Aug 2020 10:23:48 +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 DB5EUR03FT042.mail.protection.outlook.com (10.152.21.123) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3305.24 via Frontend Transport; Mon, 24 Aug 2020 10:23:48 +0000 Received: ("Tessian outbound 7161e0c2a082:v64"); Mon, 24 Aug 2020 10:23:48 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: c53751ab3fb825e0 X-CR-MTA-TID: 64aa7808 Received: from 021172c56710.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 3D317003-FCAA-44F9-A8E7-23D58771B7A5.1; Mon, 24 Aug 2020 10:23:42 +0000 Received: from EUR04-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 021172c56710.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Mon, 24 Aug 2020 10:23:42 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LVHHvv5TmJnYL7DhPCgoD3MpDHJ9IrRv0EzJjzB25IM4ncbMBg7APW7kl6vl8dW8bhs91lLOjf4J0uWlydbiHMSIGojhlD60SOTkCq6cJWKIw6CgvNmhYwya9hyNnWqZcGkiseLwnEUL9J8XUIRH9F2tuwzepYQpXPp3Tdv3Ifk0MzZDgsvsX/Y4e8phZ4enQ2i/tLn87g3B6oz6DzG6O4nQlw/dWt5lMH86CqafZkPDe22APjSgfh8GLDYzV4v9MXdvL6/ZgI7W+ce+T54+9xCxwRHsnn7OdtuLlPy6ldiAzMvYTzIi4VLu+B7T71Ztm0AsqX3SCr9Fdq9pHYiFXw== 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=YdF2MdqjVD+p6tVYmwTtVj6XNgKAJkLTYw30rDoWSh8=; b=CEhm2uK69mp2LHOapddli44nG5iwYmoLnBwfIsUoT7m/EgtfttsK2gunpJ22J/9j13gOubEh3ArpRjiuprNdtgE3p/wXLK0bPqDMWpFBvFV0kXp3t6kjrljSY60dHYlmUOwKZFC/wLCeLxTZLNQuVv26advAHVi1aBuMjh/3QIVVbVlIrKx3LqtrvxoECXh4XZ9X5QBFsghyElrqKo+fBDq5wxmEtwIYYCL6Z8OHOE0QPo+WuH5ss3wxgPFdZtea0MdEU+cqCpU3e7oE1RXkyDRPFz7drd2eHCIWoaUNgekZfx25o/ZAAOfgsWlE2gGPGxJ9u4ZenpODMfYNfp7G7w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 40.67.248.234) smtp.rcpttodomain=edk2.groups.io smtp.mailfrom=arm.com; dmarc=bestguesspass action=none header.from=arm.com; dkim=none (message not signed); 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=YdF2MdqjVD+p6tVYmwTtVj6XNgKAJkLTYw30rDoWSh8=; b=yOE926gq8b3qNLG/UnqsHtI1m31W0rAD8nUl1sN9G8ylQ+gYTQNKoJGflCQ+ia89klVZdAXbsoNo6VDfhNou/+uaWFLQUwYgJMCKPISJxr5DnpOCPHpyEFjc/EqbLghYJaJF/7mr++W733akVSowd8Y3M+2eVI7qxIsiZiX+x20= Received: from MR2P264CA0009.FRAP264.PROD.OUTLOOK.COM (2603:10a6:500:1::21) by AM6PR08MB3125.eurprd08.prod.outlook.com (2603:10a6:209:46::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3305.25; Mon, 24 Aug 2020 10:23:40 +0000 Received: from VE1EUR03FT063.eop-EUR03.prod.protection.outlook.com (2603:10a6:500:1:cafe::a2) by MR2P264CA0009.outlook.office365.com (2603:10a6:500:1::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3305.25 via Frontend Transport; Mon, 24 Aug 2020 10:23:40 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 40.67.248.234) smtp.mailfrom=arm.com; edk2.groups.io; dkim=none (message not signed) header.d=none;edk2.groups.io; dmarc=bestguesspass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 40.67.248.234 as permitted sender) receiver=protection.outlook.com; client-ip=40.67.248.234; helo=nebula.arm.com; Received: from nebula.arm.com (40.67.248.234) by VE1EUR03FT063.mail.protection.outlook.com (10.152.18.236) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.3305.24 via Frontend Transport; Mon, 24 Aug 2020 10:23:39 +0000 Received: from AZ-NEU-EX03.Arm.com (10.251.24.31) by AZ-NEU-EX03.Arm.com (10.251.24.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2044.4; Mon, 24 Aug 2020 10:23:04 +0000 Received: from E107187.Arm.com (10.57.43.233) by mail.arm.com (10.251.24.31) with Microsoft SMTP Server id 15.1.2044.4 via Frontend Transport; Mon, 24 Aug 2020 10:23:04 +0000 From: "Sami Mujawar" To: CC: Sami Mujawar , , , , , , , Subject: [PATCH v1 1/1] ShellPkg/AcpiView: PCCT Parser Date: Mon, 24 Aug 2020 11:23:03 +0100 Message-ID: <20200824102303.38968-1-sami.mujawar@arm.com> X-Mailer: git-send-email 2.11.0.windows.3 MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-Office365-Filtering-HT: Tenant X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: fc1422eb-5e78-473b-f902-08d84817ca0c X-MS-TrafficTypeDiagnostic: AM6PR08MB3125:|VE1PR08MB4878: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:10000;OLM:10000; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: mn56KjEEIt9c7fvohADNjgvqf8VeIaxhzPjqMl++Z2YAu8lRpYu8OGlU+0F1dff98o4GSsKwLERNMwo2s2RJMkQ5yiphod93Fe3BJlbB1OPkA8onMVgihPTPHqwBYDUvS0EwXWZlZvIlQ/7+EZWnCRCGMDV+Bc6IyGEK9T1vjk+Esmy/Wb964fYzuxQf1fEgAotmlauMZu9kyoMymK+yQHXvbLpU6+2jjoc2JoqI7Vf3RsyPZdDRdqhKi0gF/k9lGwfQtvw8bjnUezq7tOpYi/jYfZywIBGjnhmtrBANgWrGFwF4P3Ap4mOkpK2RpIq3DAp5d/7nrqdlqRgnxKbfiiiTLOha+KpcoXZDJMO3S3MkIBQSZZP/oRhmL/E5R/nqp3AFAa0Obo6O3hivc+Z47QTitVpqTJDcwFQRsAPkWqqDL4/DKHUjj7lIilpndiqDe5BNPgTn5AzhTQb/pIVQooGji5I0phWDVfSliAK3C9g= X-Forefront-Antispam-Report-Untrusted: CIP:40.67.248.234;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:nebula.arm.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(4636009)(136003)(376002)(39860400002)(346002)(396003)(46966005)(186003)(81166007)(26005)(8936002)(82740400003)(7696005)(47076004)(36756003)(8676002)(5660300002)(966005)(2906002)(83380400001)(426003)(70586007)(356005)(19627235002)(336012)(1076003)(478600001)(82310400002)(30864003)(4326008)(86362001)(70206006)(2616005)(6916009)(54906003)(316002)(44832011);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB3125 Return-Path: Sami.Mujawar@arm.com X-MS-Exchange-Transport-CrossTenantHeadersStripped: DB5EUR03FT042.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 05f372a7-ab85-4d92-a405-08d84817c509 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: rimB6UVVIU3V7694TVtNH01ZbXZt1OcNtTr1f/hsCbc1bMOBQq/yv7MalYgPlj40iT5FxBKR61OXjXMvyoffaoDoBcTBX4Z/hHaeIpmDtNfu34ZLE0b3HtJ1Hap+6uUtIbaX5lH4aRJnzFVfs+WH0wcLX0a74u508zhUfJuGlIzw8KVEUdAgeRL0jynZXETFYc1vfwG3DyMu8sZUPT0OPNt2oiL+aQmd5WJ5IAoVgXBbAh/HgH+I+Idzb876w4Hu5h2W6oGgUNin2W257v6Sspf0ODYsLgwyxRC3/Zbw/mZMP0aaHLSd4Qhs4uzzipGQfPhHiRNsZ46aYAk5BKaBa0JzJzeKMJo1r9dpBOxHO+T3bKVSCKFeDRPDM7lDNRb3WYAX88fcmwQiyyS/IoF5cvZGlFXKuR4u97OyevAhs+QuE6GZ6Rx8xeiaSr08COt+pQ65OQ+6bvlhUp2VoTPoo0b164+MQYgv+W65n2DrZAE= 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)(39860400002)(346002)(136003)(376002)(396003)(46966005)(2616005)(1076003)(83380400001)(8936002)(81166007)(5660300002)(336012)(6916009)(186003)(86362001)(82310400002)(44832011)(316002)(4326008)(82740400003)(2906002)(7696005)(70206006)(26005)(8676002)(54906003)(19627235002)(966005)(36756003)(426003)(47076004)(70586007)(478600001)(30864003);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Aug 2020 10:23:48.4140 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: fc1422eb-5e78-473b-f902-08d84817ca0c 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: DB5EUR03FT042.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR08MB4878 Content-Type: text/plain 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.inf | 4 +- 6 files changed, 558 insertions(+), 5 deletions(-) diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h index f81ccac7e118378aa185db4b625e5bcd75f78347..051fdf807abb1067a264c136364bb6d145b38dab 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h @@ -1,7 +1,7 @@ /** @file Header file for ACPI parser - 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 **/ @@ -671,6 +671,28 @@ ParseAcpiMcfg ( ); /** + 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..19265d0b763f8a810759a2cef09ce2cc2d7bec03 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiTableParser.h +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiTableParser.h @@ -1,7 +1,7 @@ /** @file Header file for ACPI table parser - 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 **/ @@ -11,7 +11,7 @@ /** The maximum number of ACPI table parsers. */ -#define MAX_ACPI_TABLE_PARSERS 16 +#define MAX_ACPI_TABLE_PARSERS 17 /** An invalid/NULL signature value. */ diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pcct/PcctParser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pcct/PcctParser.c new file mode 100644 index 0000000000000000000000000000000000000000..526cb7b79aa7aa6eee09824600b6c7eac0ab67e2 --- /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 range + + @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 range + + @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 <= 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[] = { + 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 subspace + structure header. +*/ +STATIC CONST ACPI_PARSER PccSubspaceHeaderParser[] = { + PCC_SUBSPACE_HEADER () + // ... Type Specific Fields ... +}; + +/** + An ACPI_PARSER array describing the Generic Communications Subspace - Type 0 +*/ +STATIC CONST ACPI_PARSER PccSubspaceType0Parser[] = { + 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, ValidateRangeLength8, + 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, NULL} +}; + +/** + An ACPI_PARSER array describing the HW-Reduced Communications Subspace + - Type 1 +*/ +STATIC CONST ACPI_PARSER PccSubspaceType1Parser[] = { + 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, ValidateRangeLength8, + 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, NULL} +}; + +/** + An ACPI_PARSER array describing the HW-Reduced Communications Subspace + - Type 2 +*/ +STATIC CONST ACPI_PARSER PccSubspaceType2Parser[] = { + 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, ValidateRangeLength8, + 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, NULL}, + {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[] = { + 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, ValidateRangeLength4, + 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, NULL}, + {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 = ParseAcpi ( + TRUE, + 0, + "PCCT", + Ptr, + AcpiTableLength, + PARSER_PARAMS (PcctParser) + ); + + PccSubspacePtr = Ptr + Offset; + + SubspaceCount = 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 == NULL) || + (PccSubspaceLength == NULL)) { + IncrementErrorCount (); + Print ( + L"ERROR: Insufficient remaining table buffer length to read the " \ + L"structure header. Length = %u.\n", + AcpiTableLength - Offset + ); + return; + } + + // Validate Structure length + if ((*PccSubspaceLength == 0) || + ((Offset + (*PccSubspaceLength)) > AcpiTableLength)) { + IncrementErrorCount (); + Print ( + L"ERROR: Invalid Structure length. " \ + L"Length = %u. Offset = %u. AcpiTableLength = %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 = %u, Length = %u\n", + PccSubspaceType, + *PccSubspaceLength + ); + } + + PccSubspacePtr += *PccSubspaceLength; + Offset += *PccSubspaceLength; + SubspaceCount++; + } // while + + if (SubspaceCount > MAX_PCC_SUBSPACES) { + IncrementErrorCount (); + Print (L"ERROR: Too many PCC subspaces."); + } +} diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pcct/PcctParser.h b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pcct/PcctParser.h new file mode 100644 index 0000000000000000000000000000000000000000..278dc83c5de8860cbb2b1e2b2e277aa7c6c58698 --- /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/UefiShellAcpiViewCommandLib.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.c index d2f26ff89f12e596702281c38ab0de3729aa68e4..feb80661cddc420670edb2d8c7a570b0a89272d8 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.c +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.c @@ -1,7 +1,7 @@ /** @file Main file for 'acpiview' Shell command function. - 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 **/ @@ -57,6 +57,8 @@ ACPI_TABLE_PARSER ParserList[] = { {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/UefiShellAcpiViewCommandLib.inf b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.inf index 91459f9ec632635ee453c5ef46f67445cd9eee0c..efa9c8784a6670e5a4f500e0ae559a4938852f95 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.inf +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.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 -- 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'