From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=pass header.i=@armh.onmicrosoft.com header.s=selector2-armh-onmicrosoft-com header.b=kSgXGw+O; spf=pass (domain: arm.com, ip: 40.107.0.77, mailfrom: krzysztof.koch@arm.com) Received: from EUR02-AM5-obe.outbound.protection.outlook.com (EUR02-AM5-obe.outbound.protection.outlook.com [40.107.0.77]) by groups.io with SMTP; Wed, 12 Jun 2019 09:52:11 -0700 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=pkI2IHu8zv38CMlQNz2oaK5OxIblZfgMCwbSw8sxdfw=; b=kSgXGw+O9Yg7P5vGpxCH3PhJVl5AwH8iu9wEmZ7LYZpV+6/ERnWJgErItilE9ukhe0ZdJq5B5y/q0e19x6JbW/UBiQMvEcLCDGaDYmTiC0Yr7pAFrwVuwarBNW/jCQFX1BcP0w8abNK+lGLAk8y+2BPLygBevILtoVk4vwGbEik= Received: from VI1PR0801CA0088.eurprd08.prod.outlook.com (2603:10a6:800:7d::32) by DB6PR08MB2773.eurprd08.prod.outlook.com (2603:10a6:6:20::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1987.11; Wed, 12 Jun 2019 16:52:04 +0000 Received: from VE1EUR03FT055.eop-EUR03.prod.protection.outlook.com (2a01:111:f400:7e09::204) by VI1PR0801CA0088.outlook.office365.com (2603:10a6:800:7d::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.1965.12 via Frontend Transport; Wed, 12 Jun 2019 16:52:04 +0000 Authentication-Results: spf=temperror (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=temperror action=none header.from=arm.com; Received-SPF: TempError (protection.outlook.com: error in processing during lookup of arm.com: DNS Timeout) Received: from nebula.arm.com (40.67.248.234) by VE1EUR03FT055.mail.protection.outlook.com (10.152.19.158) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.20.1987.11 via Frontend Transport; Wed, 12 Jun 2019 16:52:02 +0000 Received: from AZ-NEU-EX04.Arm.com (10.251.24.32) 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; Wed, 12 Jun 2019 14:10:54 +0000 Received: from E119924.Arm.com (10.1.199.124) by mail.arm.com (10.251.24.32) with Microsoft SMTP Server id 15.1.1415.2 via Frontend Transport; Wed, 12 Jun 2019 14:10:53 +0000 From: "Krzysztof Koch" To: CC: , , , , , , , , Subject: [PATCH v1 2/2] ShellPkg: acpiview: Update SRAT parser to ACPI 6.3 Date: Wed, 12 Jun 2019 15:10:46 +0100 Message-ID: <20190612141046.30168-3-krzysztof.koch@arm.com> X-Mailer: git-send-email 2.16.2.windows.1 In-Reply-To: <20190612141046.30168-1-krzysztof.koch@arm.com> References: <20190612141046.30168-1-krzysztof.koch@arm.com> Return-Path: Krzysztof.Koch@arm.com MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:40.67.248.234;IPV:NLI;CTRY:US;EFV:NLI;SFV:NSPM;SFS:(10009020)(376002)(346002)(39860400002)(136003)(396003)(2980300002)(189003)(199004)(50466002)(48376002)(8936002)(72206003)(2906002)(478600001)(356004)(86362001)(6666004)(966005)(19627235002)(54906003)(50226002)(2351001)(316002)(16586007)(1076003)(4326008)(70586007)(6916009)(70206006)(5660300002)(426003)(6306002)(486006)(36756003)(63370400001)(53936002)(63350400001)(30864003)(126002)(446003)(476003)(2616005)(14444005)(11346002)(68736007)(44832011)(336012)(76176011)(305945005)(47776003)(186003)(51416003)(81156014)(77096007)(26005)(15650500001)(8676002)(81166006)(53416004)(7696005);DIR:OUT;SFP:1101;SCL:1;SRVR:DB6PR08MB2773;H:nebula.arm.com;FPR:;SPF:TempError;LANG:en;PTR:InfoDomainNonexistent;MX:1;A:1; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d884707e-334b-460d-13ee-08d6ef564b5e X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600148)(711020)(4605104)(1401327)(2017052603328);SRVR:DB6PR08MB2773; X-MS-TrafficTypeDiagnostic: DB6PR08MB2773: X-MS-Exchange-PUrlCount: 1 NoDisclaimer: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7219; X-Forefront-PRVS: 0066D63CE6 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Message-Info: h6o/INpCNKzVWectdi2XN+fUpWwJj/BSHja66/IO4/XzwKiDadKem2L2NgmpMokc9N57F4nk02mcskLOhBRNIHPouoSBrtsdK7aAlgi6LOFvOZopWu4dKznVrcE9cb82JJlRhuKD1uvVffDYInWmT2+uoJLH8Eq6wvarchVNyCJtYD32Gv7Wy874r+Stf4j09KwXuy+ScRk6LHpkLZKtOpdvJyA6do+EPmOT9KnsMFfiPY5vxJVGC8TVP0NAr4jspdEEL5NCn6hyemqt8RY7OSdEip2Cs96BY59rb3ieUi0YiHxJndDJZWTMI8+6KjykgHwhbJjQ2drYoHtkki5VNgTzZh1+OhR2LaADavW/UinPmRau+CNwbUowKyAtmZqknrqIUsPuKTlbbOLVmi16vmqAf4lJ9nM7+h+tbty1EVI= X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jun 2019 16:52:02.8134 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d884707e-334b-460d-13ee-08d6ef564b5e X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d;Ip=[40.67.248.234];Helo=[nebula.arm.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR08MB2773 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 --- Changes can be seen at: https://github.com/KrzysztofKoch1/edk2/tree/582_acpiview_6_3_srat_v1 Notes: v1: - dump and validate the Generic Initiator Affinity Struct [Krzysztof] ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c | 35 ++- ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h | 16 ++ ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Srat/SratParser.c | 256 +++++++++++++++++++- 3 files changed, 299 insertions(+), 8 deletions(-) diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c index b5965507b498b9fa9bc4d3124b2285f509004c4f..60523936732f901317ee93d03fe06df1403f3695 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c @@ -1,7 +1,7 @@ /** @file ACPI parser - Copyright (c) 2016 - 2018, ARM Limited. All rights reserved. + Copyright (c) 2016 - 2019, ARM Limited. All rights reserved. SPDX-License-Identifier: BSD-2-Clause-Patent **/ @@ -401,6 +401,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 7657892d9fd2e2e14c6578611ff0cf1b6f6cd750..5b23ab6fa9bd2f87e0347287872685a2f74622f3 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 075ff2a141a82b522e8aaedb7ad79249aaf5eaac..8c268a11454d13c9e278691d619a580c4c14c08e 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Srat/SratParser.c +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Srat/SratParser.c @@ -1,11 +1,11 @@ /** @file SRAT table parser - Copyright (c) 2016 - 2018, ARM Limited. All rights reserved. + Copyright (c) 2016 - 2019, ARM Limited. All rights reserved. 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; /** @@ -34,6 +35,51 @@ ValidateSratReserved ( IN VOID* Context ); +/** + 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. @@ -90,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%x", 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. **/ @@ -159,6 +240,148 @@ ValidateSratReserved ( } } +/** + 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. @@ -211,6 +434,7 @@ ParseAcpiSrat ( UINT8* ResourcePtr; UINT32 GicCAffinityIndex; UINT32 GicITSAffinityIndex; + UINT32 GenericInitiatorAffinityIndex; UINT32 MemoryAffinityIndex; UINT32 ApicSapicAffinityIndex; UINT32 X2ApicAffinityIndex; @@ -218,6 +442,7 @@ ParseAcpiSrat ( GicCAffinityIndex = 0; GicITSAffinityIndex = 0; + GenericInitiatorAffinityIndex = 0; MemoryAffinityIndex = 0; ApicSapicAffinityIndex = 0; X2ApicAffinityIndex = 0; @@ -247,7 +472,7 @@ ParseAcpiSrat ( ); switch (*SratRAType) { - case EFI_ACPI_6_2_GICC_AFFINITY: + case EFI_ACPI_6_3_GICC_AFFINITY: AsciiSPrint ( Buffer, sizeof (Buffer), @@ -264,7 +489,7 @@ ParseAcpiSrat ( ); break; - case EFI_ACPI_6_2_GIC_ITS_AFFINITY: + case EFI_ACPI_6_3_GIC_ITS_AFFINITY: AsciiSPrint ( Buffer, sizeof (Buffer), @@ -281,7 +506,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), @@ -298,7 +540,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), @@ -315,7 +557,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)'