From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 192.55.52.136, mailfrom: jaben.carsey@intel.com) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by groups.io with SMTP; Wed, 12 Jun 2019 13:57:42 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 12 Jun 2019 13:57:41 -0700 X-ExtLoop1: 1 Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by orsmga005.jf.intel.com with ESMTP; 12 Jun 2019 13:57:40 -0700 Received: from fmsmsx101.amr.corp.intel.com (10.18.124.199) by FMSMSX103.amr.corp.intel.com (10.18.124.201) with Microsoft SMTP Server (TLS) id 14.3.408.0; Wed, 12 Jun 2019 13:57:39 -0700 Received: from fmsmsx103.amr.corp.intel.com ([169.254.2.74]) by fmsmsx101.amr.corp.intel.com ([169.254.1.33]) with mapi id 14.03.0415.000; Wed, 12 Jun 2019 13:57:39 -0700 From: "Carsey, Jaben" To: "devel@edk2.groups.io" , "krzysztof.koch@arm.com" CC: "Ni, Ray" , "Gao, Zhichao" , "Kinney, Michael D" , "Gao, Liming" , "Sami.Mujawar@arm.com" , "Matteo.Carlini@arm.com" , "Stephanie.Hughes-Fitt@arm.com" , "nd@arm.com" Subject: Re: [edk2-devel] [PATCH v1 2/2] ShellPkg: acpiview: Update SRAT parser to ACPI 6.3 Thread-Topic: [edk2-devel] [PATCH v1 2/2] ShellPkg: acpiview: Update SRAT parser to ACPI 6.3 Thread-Index: AQHVIT8yPNUveN5MqUmOf/D49WMgIKaYgC4w Date: Wed, 12 Jun 2019 20:57:38 +0000 Message-ID: References: <20190612141046.30168-1-krzysztof.koch@arm.com> <20190612141046.30168-3-krzysztof.koch@arm.com> In-Reply-To: <20190612141046.30168-3-krzysztof.koch@arm.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiYjYyYjY0OWItMzI1Zi00YjIzLTk5YmItN2ZkNGExZDNkZDIwIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiTEduaWVJRXVzZTN4QTN1WEdxVlwvcmdMOG1GOHRONTc1TExTYzd0QnB1RVQxRjVEejdvQnpsY3QwMnFabVZBbkIifQ== x-ctpclassification: CTP_NT dlp-product: dlpe-windows dlp-version: 11.0.600.7 dlp-reaction: no-action x-originating-ip: [10.1.200.108] MIME-Version: 1.0 Return-Path: jaben.carsey@intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Jaben Carsey I don't have access to a platform with ACPI 6.3 to do a test. Can someone= do a test and respond with tested-by if possible? > -----Original Message----- > From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf Of > Krzysztof Koch > Sent: Wednesday, June 12, 2019 7:11 AM > To: devel@edk2.groups.io > Cc: Carsey, Jaben ; Ni, Ray ; > Gao, Zhichao ; Kinney, Michael D > ; Gao, Liming ; > Sami.Mujawar@arm.com; Matteo.Carlini@arm.com; Stephanie.Hughes- > Fitt@arm.com; nd@arm.com > Subject: [edk2-devel] [PATCH v1 2/2] ShellPkg: acpiview: Update SRAT par= ser > to ACPI 6.3 > Importance: High >=20 > Add support for parsing revision 3 of System Resource Affinity Table > (SRAT). >=20 > Decode and dump the new Generic Initiator Affinity Structure. >=20 > Validate the Device Handle Type field inside the Generic Initiator > Affinity Structure. >=20 > Signed-off-by: Krzysztof Koch > --- >=20 > Changes can be seen at: > https://github.com/KrzysztofKoch1/edk2/tree/582_acpiview_6_3_srat_v1 >=20 > Notes: > v1: > - dump and validate the Generic Initiator Affinity Struct [Krzysztof= ] >=20 > 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(-) >=20 > diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c > b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c > index > b5965507b498b9fa9bc4d3124b2285f509004c4f..60523936732f901317ee93d03f > e06df1403f3695 100644 > --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c > +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c > @@ -1,7 +1,7 @@ > /** @file > ACPI parser >=20 > - 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 > **/ >=20 > @@ -401,6 +401,39 @@ Dump8Chars ( > ); > } >=20 > +/** > + 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 !=3D 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. >=20 > diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h > b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h > index > 7657892d9fd2e2e14c6578611ff0cf1b6f6cd750..5b23ab6fa9bd2f87e034728787 > 2685a2f74622f3 100644 > --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h > +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h > @@ -184,6 +184,22 @@ Dump8Chars ( > IN UINT8* Ptr > ); >=20 > +/** > + 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. >=20 > diff --git > a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Srat/SratParser.c > b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Srat/SratParser.c > index > 075ff2a141a82b522e8aaedb7ad79249aaf5eaac..8c268a11454d13c9e278691d6 > 19a580c4c14c08e 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 >=20 > - 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 >=20 > @par Reference(s): > - - ACPI 6.2 Specification - Errata A, September 2017 > + - ACPI 6.3 Specification - January 2019 > **/ >=20 > #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; >=20 > /** > @@ -34,6 +35,51 @@ ValidateSratReserved ( > IN VOID* Context > ); >=20 > +/** > + This function validates the Device Handle Type field in the Generic I= nitiator > + 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. >=20 > @@ -90,6 +136,41 @@ STATIC CONST ACPI_PARSER > SratGicITSAffinityParser[] =3D { > {L"ITS Id", 4, 8, L"0x%x", NULL, NULL, NULL, NULL}, > }; >=20 > +/** > + An ACPI_PARSER array describing the Generic Initiator Affinity Struct= ure > +**/ > +STATIC CONST ACPI_PARSER SratGenericInitiatorAffinityParser[] =3D { > + {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[] =3D { > + {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[] =3D { > + {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 ( > } > } >=20 > +/** > + This function validates the Device Handle Type field in the Generic I= nitiator > + 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 =3D *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 =3D=3D NULL) { > + IncrementErrorCount (); > + Print (L"\nERROR: Device Handle Type read incorrectly.\n"); > + return; > + } > + > + Print (L"\n"); > + > + if (*SratDeviceHandleType =3D=3D 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 =3D=3D EFI_ACPI_6_3_PCI_DEVICE_HANDL= E) { > + 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. >=20 > @@ -211,6 +434,7 @@ ParseAcpiSrat ( > UINT8* ResourcePtr; > UINT32 GicCAffinityIndex; > UINT32 GicITSAffinityIndex; > + UINT32 GenericInitiatorAffinityIndex; > UINT32 MemoryAffinityIndex; > UINT32 ApicSapicAffinityIndex; > UINT32 X2ApicAffinityIndex; > @@ -218,6 +442,7 @@ ParseAcpiSrat ( >=20 > GicCAffinityIndex =3D 0; > GicITSAffinityIndex =3D 0; > + GenericInitiatorAffinityIndex =3D 0; > MemoryAffinityIndex =3D 0; > ApicSapicAffinityIndex =3D 0; > X2ApicAffinityIndex =3D 0; > @@ -247,7 +472,7 @@ ParseAcpiSrat ( > ); >=20 > 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; >=20 > - 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; >=20 > - 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; >=20 > - 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; >=20 > - 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)' >=20 >=20 >=20 >=20