From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (EUR04-VI1-obe.outbound.protection.outlook.com [40.107.8.57]) by mx.groups.io with SMTP id smtpd.web11.13266.1573569602221986997 for ; Tue, 12 Nov 2019 06:40:03 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@armh.onmicrosoft.com header.s=selector2-armh-onmicrosoft-com header.b=70QDWHT5; spf=pass (domain: arm.com, ip: 40.107.8.57, 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=1uUgQ2OyB5e/xn2MBzFBCF9Qkf4bCp50HN/caT1tVPo=; b=70QDWHT5v65cSrRaTbnF6WzRuvjDJMwxsV0IxKJsTj/9vjZPki+lYKWSKk2SDgrThas4NTThb6+URM4UlP3z/TMviiVFDkWCJqxdRzn4luZ/E4SJr21vBI4Rtt8ImZ74gdR3/k/nalHZBifWSoEqx2K070FX8+RoienPRlUGh1c= Received: from HE1PR0802CA0004.eurprd08.prod.outlook.com (2603:10a6:3:bd::14) by AM0PR08MB3987.eurprd08.prod.outlook.com (2603:10a6:208:134::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2430.22; Tue, 12 Nov 2019 14:39:59 +0000 Received: from VE1EUR03FT033.eop-EUR03.prod.protection.outlook.com (2a01:111:f400:7e09::203) by HE1PR0802CA0004.outlook.office365.com (2603:10a6:3:bd::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2430.20 via Frontend Transport; Tue, 12 Nov 2019 14:39:59 +0000 Authentication-Results: spf=fail (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=none action=none header.from=arm.com; Received-SPF: Fail (protection.outlook.com: domain of arm.com does not designate 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 VE1EUR03FT033.mail.protection.outlook.com (10.152.18.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2430.21 via Frontend Transport; Tue, 12 Nov 2019 14:39:58 +0000 Received: ("Tessian outbound 0cf06bf5c60e:v33"); Tue, 12 Nov 2019 14:39:58 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 40cd7746bc4b2a09 X-CR-MTA-TID: 64aa7808 Received: from 3442123b51b0.1 (cr-mta-lb-1.cr-mta-net [104.47.6.57]) by 64aa7808-outbound-1.mta.getcheckrecipient.com id 8B4CE15B-18E3-4D16-8DF8-44997B05ECB2.1; Tue, 12 Nov 2019 14:39:52 +0000 Received: from EUR02-VE1-obe.outbound.protection.outlook.com (mail-ve1eur02lp2057.outbound.protection.outlook.com [104.47.6.57]) by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 3442123b51b0.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384); Tue, 12 Nov 2019 14:39:52 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ulk1mQsffmPjMCbMaAJnDxSIm/FlMwdkcONrgwGd4QGjvkO/pRyYY//pr1tTksx4bYR8F862tcMmdNKma9btYhSDmgmkxjiSmEKsHlGUbO0vN5fOuGCTvzX8es+AAplz7GBw6AfO5s36Y9C30zftx1Lu8R/IwFU+q0kNWbF1fBtqr8mIbxlDzTw9omf2Okh3r58KBI+IQ29ueDUNi4zK2ViXgNOck9UxFlMBbjd2H14kYZrQTL9iVbZY66trD6UhYDqs3e680bfXh9O/pPF1+cgBtGFd3DwdMJtcX2hUF9NGpz2xYQGJV7TjEgzWstbaGKo8jEvPVs0JEaD1uFz8SA== 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=1uUgQ2OyB5e/xn2MBzFBCF9Qkf4bCp50HN/caT1tVPo=; b=U6wHgYKFan5c2pyguEZxcY7+WJzNhWp+Cdiyl++SnYfax8od7RW6mWauqrxkUULl1HdffFUeCDXGdkWFFQy2zbKDrfgEcXNRvt/SgeuLVtRrFLCO/HAVSLhFLckjtRrjG+KFNcTJBAUDzsYqzXAcyPdxXrsNF9rTJLGAc8/6rrXiz5rmGuwfqeuE354dUd6W+2ZyMkeZIx9etFpfrMZbGm5QCSL9x+rrnhZxPIOwMk+k2w8EZguziUXjSWMf784TKFjhBihjIm1aDn3kZsfrL0mWNcChWhipC8cSQ3eUD07pkEjDZ/fRlL6oRU4YG+1EFGfCtOcqtl7E7am+ToAjhQ== 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=1uUgQ2OyB5e/xn2MBzFBCF9Qkf4bCp50HN/caT1tVPo=; b=70QDWHT5v65cSrRaTbnF6WzRuvjDJMwxsV0IxKJsTj/9vjZPki+lYKWSKk2SDgrThas4NTThb6+URM4UlP3z/TMviiVFDkWCJqxdRzn4luZ/E4SJr21vBI4Rtt8ImZ74gdR3/k/nalHZBifWSoEqx2K070FX8+RoienPRlUGh1c= Received: from VI1PR08CA0209.eurprd08.prod.outlook.com (2603:10a6:802:15::18) by VI1PR0801MB2127.eurprd08.prod.outlook.com (2603:10a6:800:50::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2430.20; Tue, 12 Nov 2019 14:39:50 +0000 Received: from VE1EUR03FT043.eop-EUR03.prod.protection.outlook.com (2a01:111:f400:7e09::202) by VI1PR08CA0209.outlook.office365.com (2603:10a6:802:15::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2430.24 via Frontend Transport; Tue, 12 Nov 2019 14:39:50 +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 VE1EUR03FT043.mail.protection.outlook.com (10.152.19.122) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.20.2430.21 via Frontend Transport; Tue, 12 Nov 2019 14:39:49 +0000 Received: from AZ-NEU-EX03.Arm.com (10.251.24.31) by AZ-NEU-EX04.Arm.com (10.251.24.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1415.2; Tue, 12 Nov 2019 14:39:44 +0000 Received: from E119924.Arm.com (10.1.30.21) by mail.arm.com (10.251.24.31) with Microsoft SMTP Server id 15.1.1415.2 via Frontend Transport; Tue, 12 Nov 2019 14:39:43 +0000 From: "Krzysztof Koch" To: CC: , , , , Subject: [PATCH v2 1/1] ShellPkg: acpiview: Update SRAT parser to ACPI 6.3 Date: Tue, 12 Nov 2019 14:39:37 +0000 Message-ID: <20191112143937.68588-1-krzysztof.koch@arm.com> X-Mailer: git-send-email 2.16.2.windows.1 MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report-Untrusted: CIP:40.67.248.234;IPV:NLI;CTRY:IE;EFV:NLI;SFV:NSPM;SFS:(10009020)(4636009)(396003)(136003)(39860400002)(376002)(346002)(189003)(199004)(305945005)(53416004)(5660300002)(54906003)(50226002)(106002)(2906002)(14444005)(86362001)(8936002)(48376002)(81156014)(81166006)(36756003)(861006)(8676002)(6306002)(15974865002)(356004)(4326008)(6916009)(6666004)(50466002)(236005)(606006)(478600001)(2351001)(19627235002)(15650500001)(126002)(476003)(26005)(336012)(426003)(2616005)(486006)(47776003)(966005)(30864003)(44832011)(16586007)(733005)(316002)(70586007)(7696005)(186003)(70206006)(1076003)(51416003);DIR:OUT;SFP:1101;SCL:1;SRVR:VI1PR0801MB2127;H:nebula.arm.com;FPR:;SPF:Pass;LANG:en;PTR:InfoDomainNonexistent;MX:1;A:1; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ee3e7250-9cc3-4e39-c2f5-08d7677e3152 X-MS-TrafficTypeDiagnostic: VI1PR0801MB2127:|AM0PR08MB3987: X-MS-Exchange-PUrlCount: 8 X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true X-MS-Oob-TLC-OOBClassifiers: OLM:8273;OLM:8273; X-Forefront-PRVS: 021975AE46 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: +fWN1Ph+uu7Xuhe1loj1cToTUbODfycmCxSMndud+6Y2tcKgvwHejgbKikevY6/oncTYPurNne5JcDIAQUOL2vU35aWpi7dLZcs3zg6JRQs4nFRdmZuV9aCiQI+ywHtk/dk43Jfr8TaDVJv9goCc1E8DFhSfs9Ik4P2XjfQ1tewS4KHxLbojH9JZLOt76zqzKf/x/RFvaOzPwzuc8odM83IAiRAUwJ6UqAjr/xoBnmyQ85Hb9zIIeB5FkLB0eNEBcr1Od9GnIQ8Kut4ofGu9Steg66KJUnCMdK7yszUTPZ9zxeb6Mmo11+UMw+vodkI+pfGeTkB4FteJPK1P0lsUOREqZ6zDm+saIwROeKjU4A3XLJt61FCg6++yZtcIj/Ulq/ZIwVl9sD2Lyk7QksMWwTTPlCIQjPzve1s+V8x+qHPQ+hbyAhl5YXkdmDVrqTWnumRSsp82dpEIhvXB3v58q8JxXowZuwrWlScNUQOxemI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0801MB2127 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: VE1EUR03FT033.eop-EUR03.prod.protection.outlook.com X-Forefront-Antispam-Report: CIP:63.35.35.123;IPV:CAL;SCL:-1;CTRY:IE;EFV:NLI;SFV:NSPM;SFS:(10009020)(4636009)(39860400002)(346002)(396003)(376002)(136003)(1110001)(339900001)(199004)(189003)(26826003)(6916009)(70206006)(186003)(15974865002)(54906003)(14444005)(16586007)(26005)(733005)(7696005)(51416003)(2616005)(476003)(126002)(19627235002)(336012)(861006)(4326008)(426003)(70586007)(966005)(305945005)(478600001)(606006)(50226002)(6666004)(15650500001)(47776003)(5660300002)(44832011)(1076003)(2906002)(30864003)(486006)(53416004)(2351001)(81166006)(81156014)(105606002)(76130400001)(8936002)(8676002)(36906005)(86362001)(36756003)(50466002)(48376002)(236005)(6306002)(316002)(22756006);DIR:OUT;SFP:1101;SCL:1;SRVR:AM0PR08MB3987;H:64aa7808-outbound-1.mta.getcheckrecipient.com;FPR:;SPF:Fail;LANG:en;PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com;A:1;MX:1; X-MS-Office365-Filtering-Correlation-Id-Prvs: 3d1b80c3-8c22-4965-bd46-08d7677e2c1d NoDisclaimer: True X-Forefront-PRVS: 021975AE46 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: b5y02e/sSVRt6pDYNtvTn2xvTwulox+rx7niKpCgoGsQthdDX0X59PHBJVyxrbLtDEWDKYJ5uME2NOTy0dud/AlOcnA50YoLecVvLsgo0+cFC+tcXktgy5zoke3E215uG2JZGQUB+CXn1XlGM9D7SiD2TYstKMzSFwoTUx2+aCVBp/F/9qkWcWC2C/iHiFsJTjYLMSY73QPAO2wZT+H0EzVyfL3ElcgUMHXiT4d7IrYwLBztEKv25H583z0/fS5pZSedIyjUanVcdByjZ+7Qu877XjAjk7A05TdW/2CXPF+yfk+VxgaXB+cNcGvhJNe7jelQVTmASRwSWSxXw+qFCJ1G90v9ElFw8pMvBk8hCVieE/Z+WyHKDlYtxDZNUsfpdeAenmVglBU92s3TMapHyitkvXFrYP26U1Mc3B6zl70Mon9dH9QLJIb+77BNYR8fpZv92FVsehYei9d7TjHVoL3GC8yUuA7i8ni6wysKdaY= X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Nov 2019 14:39:58.5801 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ee3e7250-9cc3-4e39-c2f5-08d7677e3152 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: AM0PR08MB3987 Content-Type: text/plain Add support for parsing revision 3 of System Resource Affinity Table (SRAT). Decode and dump the new Generic Initiator Affinity Structure. Validate the Device Handle Type field inside the Generic Initiator Affinity Structure. Signed-off-by: Krzysztof Koch --- The changes can be seen at https://github.com/KrzysztofKoch1/edk2/tree/582_acpiview_6_3_srat_v2 Notes: v2: - rebase on latest master [Krzysztof] Readme.md | 4 +- ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c | 33 +++ ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h | 16 + ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Srat/SratParser.c | 313 ++++++++++++++++++-- 4 files changed, 343 insertions(+), 23 deletions(-) diff --git a/Readme.md b/Readme.md index acbcca88d3c62d392e6f94b1ad7de2d8627e3a38..594f16b20756ab78987fef4feac2e439743d5b4a 100644 --- a/Readme.md +++ b/Readme.md @@ -17,7 +17,7 @@ for the UEFI and PI specifications from www.uefi.org. Windows VS2019 - edk2-ci + master @@ -34,7 +34,7 @@ for the UEFI and PI specifications from www.uefi.org. Ubuntu GCC - edk2-ci + master diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c index a569c3c55406ab58536834e56ce9701f7edeffee..2b2ecb93cef9ee28b752e7bf2d920b059dbf7d6b 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c @@ -405,6 +405,39 @@ Dump8Chars ( ); } +/** + This function traces 12 characters which can be optionally + formated using the format string if specified. + + If no format string is specified the Format must be NULL. + + @param [in] Format Optional format string for tracing the data. + @param [in] Ptr Pointer to the start of the buffer. +**/ +VOID +EFIAPI +Dump12Chars ( + IN CONST CHAR16* Format OPTIONAL, + IN UINT8* Ptr + ) +{ + Print ( + (Format != NULL) ? Format : L"%c%c%c%c%c%c%c%c%c%c%c%c", + Ptr[0], + Ptr[1], + Ptr[2], + Ptr[3], + Ptr[4], + Ptr[5], + Ptr[6], + Ptr[7], + Ptr[8], + Ptr[9], + Ptr[10], + Ptr[11] + ); +} + /** This function indents and prints the ACPI table Field Name. diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h index 20ca358bddfa5953bfb1d1bebaebbf3079eaba01..0dc721bd2cc59538432d4a9cab6c21728cc77d33 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h @@ -184,6 +184,22 @@ Dump8Chars ( IN UINT8* Ptr ); +/** + This function traces 12 characters which can be optionally + formated using the format string if specified. + + If no format string is specified the Format must be NULL. + + @param [in] Format Optional format string for tracing the data. + @param [in] Ptr Pointer to the start of the buffer. +**/ +VOID +EFIAPI +Dump12Chars ( + IN CONST CHAR16* Format OPTIONAL, + IN UINT8* Ptr + ); + /** This function indents and prints the ACPI table Field Name. diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Srat/SratParser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Srat/SratParser.c index a8aa420487bb6bf29fc38221d0b221573c64b8b3..d60476eb748e022f45d231e24c32b2b53e29bbd7 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Srat/SratParser.c +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Srat/SratParser.c @@ -5,7 +5,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent @par Reference(s): - - ACPI 6.2 Specification - Errata A, September 2017 + - ACPI 6.3 Specification - January 2019 **/ #include @@ -17,6 +17,7 @@ // Local Variables STATIC CONST UINT8* SratRAType; STATIC CONST UINT8* SratRALength; +STATIC CONST UINT8* SratDeviceHandleType; STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo; /** @@ -32,13 +33,52 @@ EFIAPI ValidateSratReserved ( IN UINT8* Ptr, IN VOID* Context - ) -{ - if (*(UINT32*)Ptr != 1) { - IncrementErrorCount (); - Print (L"\nERROR: Reserved should be 1 for backward compatibility.\n"); - } -} + ); + +/** + This function validates the Device Handle Type field in the Generic Initiator + Affinity 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 +ValidateSratDeviceHandleType ( + IN UINT8* Ptr, + IN VOID* Context + ); + +/** + This function traces the Device Handle field inside Generic Initiator + Affinity Structure. + + @param [in] Format Format string for tracing the data. + @param [in] Ptr Pointer to the start of the buffer. +**/ +STATIC +VOID +EFIAPI +DumpSratDeviceHandle ( + IN CONST CHAR16* Format, + IN UINT8* Ptr + ); + +/** + This function traces the PCI BDF Number field inside Device Handle - PCI + + @param [in] Format Format string for tracing the data. + @param [in] Ptr Pointer to the start of the buffer. +**/ +STATIC +VOID +EFIAPI +DumpSratPciBdfNumber ( + IN CONST CHAR16* Format, + IN UINT8* Ptr + ); /** This function traces the APIC Proximity Domain field. @@ -52,14 +92,7 @@ EFIAPI DumpSratApicProximity ( IN CONST CHAR16* Format, IN UINT8* Ptr - ) -{ - UINT32 ProximityDomain; - - ProximityDomain = Ptr[0] | (Ptr[1] << 8) | (Ptr[2] << 16); - - Print (Format, ProximityDomain); -} + ); /** An ACPI_PARSER array describing the SRAT Table. @@ -103,6 +136,41 @@ STATIC CONST ACPI_PARSER SratGicITSAffinityParser[] = { {L"ITS Id", 4, 8, L"0x%x", NULL, NULL, NULL, NULL}, }; +/** + An ACPI_PARSER array describing the Generic Initiator Affinity Structure +**/ +STATIC CONST ACPI_PARSER SratGenericInitiatorAffinityParser[] = { + {L"Type", 1, 0, L"0x%x", NULL, NULL, NULL, NULL}, + {L"Length", 1, 1, L"0x%x", NULL, NULL, NULL, NULL}, + + {L"Reserved", 1, 2, L"0x%x", NULL, NULL, NULL, NULL}, + {L"Device Handle Type", 1, 3, L"%d", NULL, (VOID**)&SratDeviceHandleType, + ValidateSratDeviceHandleType, NULL}, + {L"Proximity Domain", 4, 4, L"0x%x", NULL, NULL, NULL, NULL}, + {L"Device Handle", 16, 8, L"%s", DumpSratDeviceHandle, NULL, NULL, NULL}, + {L"Flags", 4, 24, L"0x%x", NULL, NULL, NULL, NULL}, + {L"Reserved", 4, 28, L"0x%x", NULL, NULL, NULL, NULL} +}; + +/** + An ACPI_PARSER array describing the Device Handle - ACPI +**/ +STATIC CONST ACPI_PARSER SratDeviceHandleAcpiParser[] = { + {L"ACPI_HID", 8, 0, L"0x%lx", NULL, NULL, NULL, NULL}, + {L"ACPI_UID", 4, 8, L"0x%x", NULL, NULL, NULL, NULL}, + {L"Reserved", 4, 12, L"0x%x", NULL, NULL, NULL, NULL} +}; + +/** + An ACPI_PARSER array describing the Device Handle - PCI +**/ +STATIC CONST ACPI_PARSER SratDeviceHandlePciParser[] = { + {L"PCI Segment", 2, 0, L"0x%x", NULL, NULL, NULL, NULL}, + {L"PCI BDF Number", 2, 2, NULL, DumpSratPciBdfNumber, NULL, NULL, NULL}, + {L"Reserved", 12, 4, L"%x %x %x %x - %x %x %x %x - %x %x %x %x", Dump12Chars, + NULL, NULL, NULL} +}; + /** An ACPI_PARSER array describing the Memory Affinity structure. **/ @@ -152,6 +220,190 @@ STATIC CONST ACPI_PARSER SratX2ApciAffinityParser[] = { {L"Reserved", 4, 20, L"0x%x", NULL, NULL, NULL, NULL} }; +/** + This function validates the Reserved field in the SRAT table header. + + @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 +ValidateSratReserved ( + IN UINT8* Ptr, + IN VOID* Context + ) +{ + if (*(UINT32*)Ptr != 1) { + IncrementErrorCount (); + Print (L"\nERROR: Reserved should be 1 for backward compatibility.\n"); + } +} + +/** + This function validates the Device Handle Type field in the Generic Initiator + Affinity 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 +ValidateSratDeviceHandleType ( + IN UINT8* Ptr, + IN VOID* Context + ) +{ + UINT8 DeviceHandleType; + + DeviceHandleType = *Ptr; + + if (DeviceHandleType > EFI_ACPI_6_3_PCI_DEVICE_HANDLE) { + IncrementErrorCount (); + Print ( + L"\nERROR: Invalid Device Handle Type: %d. Must be between 0 and %d.", + DeviceHandleType, + EFI_ACPI_6_3_PCI_DEVICE_HANDLE + ); + } +} + +/** + This function traces the Device Handle field inside Generic Initiator + Affinity Structure. + + @param [in] Format Format string for tracing the data. + @param [in] Ptr Pointer to the start of the buffer. +**/ +STATIC +VOID +EFIAPI +DumpSratDeviceHandle ( + IN CONST CHAR16* Format, + IN UINT8* Ptr + ) +{ + if (SratDeviceHandleType == NULL) { + IncrementErrorCount (); + Print (L"\nERROR: Device Handle Type read incorrectly.\n"); + return; + } + + Print (L"\n"); + + if (*SratDeviceHandleType == EFI_ACPI_6_3_ACPI_DEVICE_HANDLE) { + ParseAcpi ( + TRUE, + 2, + NULL, + Ptr, + sizeof (EFI_ACPI_6_3_DEVICE_HANDLE_ACPI), + PARSER_PARAMS (SratDeviceHandleAcpiParser) + ); + } else if (*SratDeviceHandleType == EFI_ACPI_6_3_PCI_DEVICE_HANDLE) { + ParseAcpi ( + TRUE, + 2, + NULL, + Ptr, + sizeof (EFI_ACPI_6_3_DEVICE_HANDLE_PCI), + PARSER_PARAMS (SratDeviceHandlePciParser) + ); + } +} + +/** + This function traces the PCI BDF Number field inside Device Handle - PCI + + @param [in] Format Format string for tracing the data. + @param [in] Ptr Pointer to the start of the buffer. +**/ +STATIC +VOID +EFIAPI +DumpSratPciBdfNumber ( + IN CONST CHAR16* Format, + IN UINT8* Ptr + ) +{ + CHAR16 Buffer[OUTPUT_FIELD_COLUMN_WIDTH]; + + Print (L"\n"); + + /* + The PCI BDF Number subfields are printed in the order specified in the ACPI + specification. The format of the 16-bit PCI BDF Number field is as follows: + + +-----+------+------+ + |DEV | FUNC | BUS | + +-----+------+------+ + |15:11| 10:8 | 7:0 | + +-----+------+------+ + */ + + // Print PCI Bus Number (Bits 7:0 of Byte 2) + UnicodeSPrint ( + Buffer, + sizeof (Buffer), + L"PCI Bus Number" + ); + PrintFieldName (4, Buffer); + Print ( + L"0x%x\n", + *Ptr + ); + + Ptr++; + + // Print PCI Device Number (Bits 7:3 of Byte 3) + UnicodeSPrint ( + Buffer, + sizeof (Buffer), + L"PCI Device Number" + ); + PrintFieldName (4, Buffer); + Print ( + L"0x%x\n", + (*Ptr & (BIT7 | BIT6 | BIT5 | BIT4 | BIT3)) >> 3 + ); + + // PCI Function Number (Bits 2:0 of Byte 3) + UnicodeSPrint ( + Buffer, + sizeof (Buffer), + L"PCI Function Number" + ); + PrintFieldName (4, Buffer); + Print ( + L"0x%x\n", + *Ptr & (BIT2 | BIT1 | BIT0) + ); +} + +/** + This function traces the APIC Proximity Domain field. + + @param [in] Format Format string for tracing the data. + @param [in] Ptr Pointer to the start of the buffer. +**/ +STATIC +VOID +EFIAPI +DumpSratApicProximity ( + IN CONST CHAR16* Format, + IN UINT8* Ptr + ) +{ + UINT32 ProximityDomain; + + ProximityDomain = Ptr[0] | (Ptr[1] << 8) | (Ptr[2] << 16); + + Print (Format, ProximityDomain); +} + /** This function parses the ACPI SRAT table. When trace is enabled this function parses the SRAT table and @@ -183,6 +435,7 @@ ParseAcpiSrat ( UINT8* ResourcePtr; UINT32 GicCAffinityIndex; UINT32 GicITSAffinityIndex; + UINT32 GenericInitiatorAffinityIndex; UINT32 MemoryAffinityIndex; UINT32 ApicSapicAffinityIndex; UINT32 X2ApicAffinityIndex; @@ -190,6 +443,7 @@ ParseAcpiSrat ( GicCAffinityIndex = 0; GicITSAffinityIndex = 0; + GenericInitiatorAffinityIndex = 0; MemoryAffinityIndex = 0; ApicSapicAffinityIndex = 0; X2ApicAffinityIndex = 0; @@ -232,7 +486,7 @@ ParseAcpiSrat ( } switch (*SratRAType) { - case EFI_ACPI_6_2_GICC_AFFINITY: + case EFI_ACPI_6_3_GICC_AFFINITY: AsciiSPrint ( Buffer, sizeof (Buffer), @@ -249,7 +503,7 @@ ParseAcpiSrat ( ); break; - case EFI_ACPI_6_2_GIC_ITS_AFFINITY: + case EFI_ACPI_6_3_GIC_ITS_AFFINITY: AsciiSPrint ( Buffer, sizeof (Buffer), @@ -266,7 +520,24 @@ ParseAcpiSrat ( ); break; - case EFI_ACPI_6_2_MEMORY_AFFINITY: + case EFI_ACPI_6_3_GENERIC_INITIATOR_AFFINITY: + AsciiSPrint ( + Buffer, + sizeof (Buffer), + "Generic Initiator Affinity Structure [%d]", + GenericInitiatorAffinityIndex++ + ); + ParseAcpi ( + TRUE, + 2, + Buffer, + ResourcePtr, + *SratRALength, + PARSER_PARAMS (SratGenericInitiatorAffinityParser) + ); + break; + + case EFI_ACPI_6_3_MEMORY_AFFINITY: AsciiSPrint ( Buffer, sizeof (Buffer), @@ -283,7 +554,7 @@ ParseAcpiSrat ( ); break; - case EFI_ACPI_6_2_PROCESSOR_LOCAL_APIC_SAPIC_AFFINITY: + case EFI_ACPI_6_3_PROCESSOR_LOCAL_APIC_SAPIC_AFFINITY: AsciiSPrint ( Buffer, sizeof (Buffer), @@ -300,7 +571,7 @@ ParseAcpiSrat ( ); break; - case EFI_ACPI_6_2_PROCESSOR_LOCAL_X2APIC_AFFINITY: + case EFI_ACPI_6_3_PROCESSOR_LOCAL_X2APIC_AFFINITY: AsciiSPrint ( Buffer, sizeof (Buffer), -- 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'