From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (EUR04-HE1-obe.outbound.protection.outlook.com [40.107.7.75]) by mx.groups.io with SMTP id smtpd.web11.10674.1588693584438287552 for ; Tue, 05 May 2020 08:46:25 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@armh.onmicrosoft.com header.s=selector2-armh-onmicrosoft-com header.b=6igZCpnq; spf=pass (domain: arm.com, ip: 40.107.7.75, mailfrom: krzysztof.koch@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=LTBM1SZ9Ohdht9ArrOgG/NcAkKf626gIZmNmOUQdLl4=; b=6igZCpnqbpyFQhzju/KXvv1wtMwdG3QE3jPcmryR/zZu+wxHnjxUD9QnQSF3EoVLVyCN4wmnJdTbMyLmQRjpix4QefxWK11DP+C74R1+K9JlqGvonQ1L8SmsBFHd0PPmqzzVDTvXRPIFpsx/DYvWn2kjfWPuAvNpdvP1R5ZkqJ4= Received: from DB6P192CA0018.EURP192.PROD.OUTLOOK.COM (2603:10a6:4:b8::28) by AM0SPR01MB0077.eurprd08.prod.outlook.com (2603:10a6:208:170::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2979.26; Tue, 5 May 2020 15:46:21 +0000 Received: from DB5EUR03FT034.eop-EUR03.prod.protection.outlook.com (2603:10a6:4:b8:cafe::f9) by DB6P192CA0018.outlook.office365.com (2603:10a6:4:b8::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2958.20 via Frontend Transport; Tue, 5 May 2020 15:46:21 +0000 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 DB5EUR03FT034.mail.protection.outlook.com (10.152.20.87) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2958.20 via Frontend Transport; Tue, 5 May 2020 15:46:20 +0000 Received: ("Tessian outbound b3a67fbfbb1f:v54"); Tue, 05 May 2020 15:46:20 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 38be4f80e43f7bd4 X-CR-MTA-TID: 64aa7808 Received: from 971ac25efc23.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id DD98A327-9269-40E2-8FA1-8676775BF4F5.1; Tue, 05 May 2020 15:46:15 +0000 Received: from EUR05-AM6-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 971ac25efc23.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 05 May 2020 15:46:15 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cjaRwMYJwkge4YHObF9ptiEdV5joeDdvHUG4er6ju/jZz5qGOiJ+XUW/EvlI0Eqpr+9WBb+ObjwXtxCodnTjwkwvmzfc0bfBQ1nq6X7Qizpk/iz1xfnhbFj+PA5RfOEQOwo6LdykXk5V8ZBYvzfMV2qdLvcF8cTLsTzio4oZhgwPaHd6xsAItiRdMHNkqCO8Jy4V/yGKTdc9IZwpTPC/+EB0ILzVu4cy1ozTdbAtuPHFcZ4DEH7yA+CjEjfLUosvjleSwS6161HrYidZz4sGdt4rqB+kZ0icD4yqeH4GHtPqeMqfKK/c9zgl9Yr3f29s0uQl8mUsSqIzk1Z4pGrF3w== 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=LTBM1SZ9Ohdht9ArrOgG/NcAkKf626gIZmNmOUQdLl4=; b=YtetycrQrZrCEAp2mbTybgJtILU0ijZW7tiaRFHUfhUjBZTVhl88AYNJjR2gMexCEZgC5D+9KOY3xXQ3bYinCxWq98RnjC8mhZ1s+xBoCCPaDe6KDfgagHlfgAOJPv8HMl46NLgpyLaM4hS6xaJ1QvWsobI99ep/YYpK+cBKii/UGPSiai3jqxp72YLIoNRdcCWajNpmMKcvwwRrYQiffhHX/MGVpYPXwzbC+dQ56U5CIbp2hnHOjrYl2IWyeMKcFFzq8czliey3DyeVh9tNV/YT88WTGbXgtV5jKkjzZXc4LmRRpRAM139hD9tqmmUkFr45zrE0D5WdzC7fvWoCNA== 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=LTBM1SZ9Ohdht9ArrOgG/NcAkKf626gIZmNmOUQdLl4=; b=6igZCpnqbpyFQhzju/KXvv1wtMwdG3QE3jPcmryR/zZu+wxHnjxUD9QnQSF3EoVLVyCN4wmnJdTbMyLmQRjpix4QefxWK11DP+C74R1+K9JlqGvonQ1L8SmsBFHd0PPmqzzVDTvXRPIFpsx/DYvWn2kjfWPuAvNpdvP1R5ZkqJ4= Received: from AM6P195CA0076.EURP195.PROD.OUTLOOK.COM (2603:10a6:209:86::17) by HE1PR0801MB1755.eurprd08.prod.outlook.com (2603:10a6:3:86::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2958.27; Tue, 5 May 2020 15:46:13 +0000 Received: from AM5EUR03FT033.eop-EUR03.prod.protection.outlook.com (2603:10a6:209:86:cafe::aa) by AM6P195CA0076.outlook.office365.com (2603:10a6:209:86::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2979.26 via Frontend Transport; Tue, 5 May 2020 15:46:13 +0000 Authentication-Results-Original: 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 AM5EUR03FT033.mail.protection.outlook.com (10.152.16.99) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.2958.20 via Frontend Transport; Tue, 5 May 2020 15:46:13 +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.1415.2; Tue, 5 May 2020 15:46:06 +0000 Received: from E119924.Arm.com (10.57.59.39) by mail.arm.com (10.251.24.31) with Microsoft SMTP Server id 15.1.1415.2 via Frontend Transport; Tue, 5 May 2020 15:46:06 +0000 From: "Krzysztof Koch" To: CC: , , , , Subject: [PATCH v1 2/6] ShellPkg: acpiview: Make MADT parsing logic data driven Date: Tue, 5 May 2020 16:46:00 +0100 Message-ID: <20200505154604.9848-3-krzysztof.koch@arm.com> X-Mailer: git-send-email 2.16.2.windows.1 In-Reply-To: <20200505154604.9848-1-krzysztof.koch@arm.com> References: <20200505154604.9848-1-krzysztof.koch@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-Office365-Filtering-HT: Tenant 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;SFTY:;SFS:(4636009)(39860400002)(346002)(376002)(136003)(396003)(46966005)(33430700001)(316002)(1076003)(7696005)(70206006)(426003)(81166007)(86362001)(336012)(2616005)(8676002)(26005)(54906003)(4326008)(70586007)(186003)(33440700001)(5660300002)(36756003)(47076004)(478600001)(6916009)(82740400003)(82310400002)(44832011)(8936002)(356005)(2906002)(6666004);DIR:OUT;SFP:1101; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 872973fc-6b90-41a2-1e4e-08d7f10b752c X-MS-TrafficTypeDiagnostic: HE1PR0801MB1755:|AM0SPR01MB0077: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:10000;OLM:10000; X-Forefront-PRVS: 0394259C80 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: akR7+6DtOShOPxwmSV0aN4gGU3+uKBoehTTY+Y1Gcegfc2R44PWRjWiUBfoKG4rXwjQUb0C62ka4hYRbfViIBGZnlwEWPhKcJpnH4MDeETqi6GOC8jj5FfFQBR+AlQI7n58bHXE1tfx/goEq7TvhQLfcOtiTSzQQawv2I6zLCQM7TpuEU5gaXRzpty7yAIQ1zKLS4JQpEUCSxHN848FdZKratJhDO4qsKfxa9hIFezSXlex8HruxFBh7OvdcsRTLK/bc3XhI4cpR1anQfp47/nJKAyv1vVnRqzPhOnWLhxG2iRSrIZp37aqtUqwH639Vi2GU7+6eh80Ip8Q9/YP1rtrbgke3lMxTlCXi6FC61fEyl0eHQ7xMQDQNs3p5QhGFxSoV5D7u2e8J0o+cDyqlwfYLaBPcP4or6PeUqOwG5biw5rC6K6+eqtgi0FeFZcNPTt2j/CF3fwfxm6JLG8XKRHggVTBnuo7gCG4l+c4MHw1VyBl0UIR/hfDM4/yVUgAS3pJ14W6aPWD431XycPMDWg1KAT9z48nAHOjTL8WRScLJtk6fhAjWmZVLqmAAUoz05tVN3o20nn8vvyCUzIWcew== X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR0801MB1755 Original-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; Return-Path: Krzysztof.Koch@arm.com X-MS-Exchange-Transport-CrossTenantHeadersStripped: DB5EUR03FT034.eop-EUR03.prod.protection.outlook.com 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;SFTY:;SFS:(4636009)(39860400002)(136003)(376002)(346002)(396003)(46966005)(33430700001)(8676002)(8936002)(70206006)(86362001)(70586007)(7696005)(478600001)(36756003)(54906003)(5660300002)(316002)(6666004)(2616005)(33440700001)(82310400002)(2906002)(1076003)(6916009)(82740400003)(186003)(47076004)(44832011)(426003)(336012)(81166007)(4326008)(26005);DIR:OUT;SFP:1101; X-MS-Office365-Filtering-Correlation-Id-Prvs: fc852d6f-2e34-4fb5-6356-08d7f10b7080 X-Forefront-PRVS: 0394259C80 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: h3/65TVhhMmDHOM5CKQC8i1fkMx4Zvu9aCE/IByrBvYOCc2NBZMbLaic+hmVFzb9DnMZbyQ430z7AEGot5Papk6rNZ9rPA+yj98rl2tZkNwfn+grx/5FGmUd8ToZ9x0kO2bY3aXWi9LVqNGskyRmkg0cdvC+6P/tNCPxsFmeH0kCHsy8Dx659UVKL9P3Ym7/akq2PbjIBYmCN/KOHw3TbbdxjlsjFI0HdbMHB9CnpuT41liGQ+/SJWmC6ODcB5xmaXjauxELPuRRg3uFWSWa2L1xhqaM0PPb3VHUiB2bXBE0+chxuNQFkcq3g6kaiaj8ASw9Xv8Vtr57ZXDIQ2+Q/bEyfNkYWwMNoKHG9IMi9GmgPVzLuHwjHPni8h6LUVbSM2+ggfXlWZbqzj/SzieLv3dQqRtsgheF73KDuw0UxPa1mQs1/wzIWJAqW6VPN3K3Y3kSHVw49KVE8PTxwPb1CBee6Ft9mjEACU8yc6PlvHzAvBy0aJA94wfipIHVSeR0nVvh7cNNpCLu7s4UdZWpKk/0PeI7tuEa2W9eOxp/GQrF4F7kL9ghljgTzqBg/TbA9YfmZpLWv3EFu7O2DPSKng== X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 May 2020 15:46:20.8894 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 872973fc-6b90-41a2-1e4e-08d7f10b752c 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-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0SPR01MB0077 Content-Type: text/plain Replace the switch statement in the main parser loop with a table-driven approach. Use the ParseAcpiStruct () method to resolve how each Interrupt Controller Structure given should be parsed. Enumerate all structures found in the Multiple APIC Description Table (MADT) on a per-type basis. Print the offset from the start of the table for each structure. Consolidate all metadata about each Interrupt Controller Structure. Define an array of ACPI_STRUCT_INFO structures to store the name, instance count, architecture support and handling information. Use this array to construct the ACPI_STRUCT_DATABASE for MADT. Count the number of instances of each Interrupt Controller Structure type. Optionally report these counts after MADT table parsing is finished. Validate that Advanced Programmable Interrupt Controller (APIC) structures are not present on Arm-based platforms. For Arm-based platforms, make existing GIC Distributor (GICD) instance count validation code use ACPI_STRUCT_INFO. References: - ACPI 6.3 Specification - January 2019, Section 5.2.12 Signed-off-by: Krzysztof Koch --- Notes: v1: - Make MADT parsing logic data driven [Krzysztof] ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Madt/MadtParser.c | 217 ++++++++++++-------- ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Madt/MadtParser.h | 3 +- 2 files changed, 134 insertions(+), 86 deletions(-) diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Madt/MadtParser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Madt/MadtParser.c index f85d2b36532cfc5db36fe7bef9830cccc64969cc..00898a8853f45de1f813d71fe52920185bc92e2a 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Madt/MadtParser.c +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Madt/MadtParser.c @@ -15,6 +15,7 @@ #include #include "AcpiParser.h" #include "AcpiTableParser.h" +#include "AcpiView.h" #include "MadtParser.h" // Local Variables @@ -200,6 +201,106 @@ STATIC CONST ACPI_PARSER MadtInterruptControllerHeaderParser[] = { {L"Reserved", 2, 2, NULL, NULL, NULL, NULL, NULL} }; +/** + Information about each Interrupt Controller Structure type. +**/ +STATIC ACPI_STRUCT_INFO MadtStructs[] = { + ACPI_STRUCT_INFO_PARSER_NOT_IMPLEMENTED ( + "Processor Local APIC", + EFI_ACPI_6_3_PROCESSOR_LOCAL_APIC, + ARCH_COMPAT_IA32 | ARCH_COMPAT_X64 + ), + ACPI_STRUCT_INFO_PARSER_NOT_IMPLEMENTED ( + "I/O APIC", + EFI_ACPI_6_3_IO_APIC, + ARCH_COMPAT_IA32 | ARCH_COMPAT_X64 + ), + ACPI_STRUCT_INFO_PARSER_NOT_IMPLEMENTED ( + "Interrupt Source Override", + EFI_ACPI_6_3_INTERRUPT_SOURCE_OVERRIDE, + ARCH_COMPAT_IA32 | ARCH_COMPAT_X64 + ), + ACPI_STRUCT_INFO_PARSER_NOT_IMPLEMENTED ( + "NMI Source", + EFI_ACPI_6_3_NON_MASKABLE_INTERRUPT_SOURCE, + ARCH_COMPAT_IA32 | ARCH_COMPAT_X64 + ), + ACPI_STRUCT_INFO_PARSER_NOT_IMPLEMENTED ( + "Local APIC NMI", + EFI_ACPI_6_3_LOCAL_APIC_NMI, + ARCH_COMPAT_IA32 | ARCH_COMPAT_X64 + ), + ACPI_STRUCT_INFO_PARSER_NOT_IMPLEMENTED ( + "Local APIC Address Override", + EFI_ACPI_6_3_LOCAL_APIC_ADDRESS_OVERRIDE, + ARCH_COMPAT_IA32 | ARCH_COMPAT_X64 + ), + ACPI_STRUCT_INFO_PARSER_NOT_IMPLEMENTED ( + "I/O SAPIC", + EFI_ACPI_6_3_IO_SAPIC, + ARCH_COMPAT_IA32 | ARCH_COMPAT_X64 + ), + ACPI_STRUCT_INFO_PARSER_NOT_IMPLEMENTED ( + "Local SAPIC", + EFI_ACPI_6_3_LOCAL_SAPIC, + ARCH_COMPAT_IA32 | ARCH_COMPAT_X64 + ), + ACPI_STRUCT_INFO_PARSER_NOT_IMPLEMENTED ( + "Platform Interrupt Sources", + EFI_ACPI_6_3_PLATFORM_INTERRUPT_SOURCES, + ARCH_COMPAT_IA32 | ARCH_COMPAT_X64 + ), + ACPI_STRUCT_INFO_PARSER_NOT_IMPLEMENTED ( + "Processor Local x2APIC", + EFI_ACPI_6_3_PROCESSOR_LOCAL_X2APIC, + ARCH_COMPAT_IA32 | ARCH_COMPAT_X64 + ), + ACPI_STRUCT_INFO_PARSER_NOT_IMPLEMENTED ( + "Local x2APIC NMI", + EFI_ACPI_6_3_LOCAL_X2APIC_NMI, + ARCH_COMPAT_IA32 | ARCH_COMPAT_X64 + ), + ADD_ACPI_STRUCT_INFO_ARRAY ( + "GICC", + EFI_ACPI_6_3_GIC, + ARCH_COMPAT_ARM | ARCH_COMPAT_AARCH64, + GicCParser + ), + ADD_ACPI_STRUCT_INFO_ARRAY ( + "GICD", + EFI_ACPI_6_3_GICD, + ARCH_COMPAT_ARM | ARCH_COMPAT_AARCH64, + GicDParser + ), + ADD_ACPI_STRUCT_INFO_ARRAY ( + "GIC MSI Frame", + EFI_ACPI_6_3_GIC_MSI_FRAME, + ARCH_COMPAT_ARM | ARCH_COMPAT_AARCH64, + GicMSIFrameParser + ), + ADD_ACPI_STRUCT_INFO_ARRAY ( + "GICR", + EFI_ACPI_6_3_GICR, + ARCH_COMPAT_ARM | ARCH_COMPAT_AARCH64, + GicRParser + ), + ADD_ACPI_STRUCT_INFO_ARRAY ( + "GIC ITS", + EFI_ACPI_6_3_GIC_ITS, + ARCH_COMPAT_ARM | ARCH_COMPAT_AARCH64, + GicITSParser + ) +}; + +/** + MADT structure database +**/ +STATIC ACPI_STRUCT_DATABASE MadtDatabase = { + "Interrupt Controller Structure", + MadtStructs, + ARRAY_SIZE (MadtStructs) +}; + /** This function parses the ACPI MADT table. When trace is enabled this function parses the MADT table and @@ -231,14 +332,13 @@ ParseAcpiMadt ( { UINT32 Offset; UINT8* InterruptContollerPtr; - UINT32 GICDCount; - - GICDCount = 0; if (!Trace) { return; } + ResetAcpiStructCounts (&MadtDatabase); + Offset = ParseAcpi ( TRUE, 0, @@ -267,7 +367,8 @@ ParseAcpiMadt ( IncrementErrorCount (); Print ( L"ERROR: Insufficient remaining table buffer length to read the " \ - L"Interrupt Controller Structure header. Length = %d.\n", + L"%a header. Length = %d.\n", + MadtDatabase.Name, AcpiTableLength - Offset ); return; @@ -278,8 +379,9 @@ ParseAcpiMadt ( ((Offset + (*MadtInterruptControllerLength)) > AcpiTableLength)) { IncrementErrorCount (); Print ( - L"ERROR: Invalid Interrupt Controller Structure length. " \ - L"Length = %d. Offset = %d. AcpiTableLength = %d.\n", + L"ERROR: Invalid %a length. Length = %d. Offset = %d. " \ + "AcpiTableLength = %d.\n", + MadtDatabase.Name, *MadtInterruptControllerLength, Offset, AcpiTableLength @@ -287,87 +389,32 @@ ParseAcpiMadt ( return; } - switch (*MadtInterruptControllerType) { - case EFI_ACPI_6_3_GIC: { - ParseAcpi ( - TRUE, - 2, - "GICC", - InterruptContollerPtr, - *MadtInterruptControllerLength, - PARSER_PARAMS (GicCParser) - ); - break; - } - - case EFI_ACPI_6_3_GICD: { - if (++GICDCount > 1) { - IncrementErrorCount (); - Print ( - L"ERROR: Only one GICD must be present," - L" GICDCount = %d\n", - GICDCount - ); - } - ParseAcpi ( - TRUE, - 2, - "GICD", - InterruptContollerPtr, - *MadtInterruptControllerLength, - PARSER_PARAMS (GicDParser) - ); - break; - } - - case EFI_ACPI_6_3_GIC_MSI_FRAME: { - ParseAcpi ( - TRUE, - 2, - "GIC MSI Frame", - InterruptContollerPtr, - *MadtInterruptControllerLength, - PARSER_PARAMS (GicMSIFrameParser) - ); - break; - } - - case EFI_ACPI_6_3_GICR: { - ParseAcpi ( - TRUE, - 2, - "GICR", - InterruptContollerPtr, - *MadtInterruptControllerLength, - PARSER_PARAMS (GicRParser) - ); - break; - } - - case EFI_ACPI_6_3_GIC_ITS: { - ParseAcpi ( - TRUE, - 2, - "GIC ITS", - InterruptContollerPtr, - *MadtInterruptControllerLength, - PARSER_PARAMS (GicITSParser) - ); - break; - } - - default: { - IncrementErrorCount (); - Print ( - L"ERROR: Unknown Interrupt Controller Structure," - L" Type = %d, Length = %d\n", - *MadtInterruptControllerType, - *MadtInterruptControllerLength - ); - } - } // switch + // Parse the Interrupt Controller Structure + ParseAcpiStruct ( + 2, + InterruptContollerPtr, + &MadtDatabase, + Offset, + *MadtInterruptControllerType, + *MadtInterruptControllerLength, + NULL, + NULL + ); InterruptContollerPtr += *MadtInterruptControllerLength; Offset += *MadtInterruptControllerLength; } // while + + // Report and validate Interrupt Controller Structure counts + if (GetConsistencyChecking ()) { + ValidateAcpiStructCounts (&MadtDatabase); + + if (MadtStructs[EFI_ACPI_6_3_GICD].Count > 1) { + IncrementErrorCount (); + Print ( + L"ERROR: Only one %a must be present\n", + MadtStructs[EFI_ACPI_6_3_GICD].Name + ); + } + } } diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Madt/MadtParser.h b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Madt/MadtParser.h index fbbc43e09adbdf9fea302a03a61e6dc179f06a62..25128081816459106e43ef5c98acd23dc1f910c3 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Madt/MadtParser.h +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Madt/MadtParser.h @@ -1,13 +1,14 @@ /** @file Header file for MADT table parser - Copyright (c) 2019, ARM Limited. All rights reserved. + Copyright (c) 2020, ARM Limited. All rights reserved. SPDX-License-Identifier: BSD-2-Clause-Patent @par Reference(s): - Arm Generic Interrupt Controller Architecture Specification, GIC architecture version 3 and version 4, issue E - Arm Server Base System Architecture 5.0 + - ACPI 6.3 Specification - January 2019, Section 5.2.12 **/ #ifndef MADT_PARSER_H_ -- 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'