From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web08.50787.1643733861979501804 for ; Tue, 01 Feb 2022 08:44:22 -0800 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: arm.com, ip: 217.140.110.172, mailfrom: pierre.gondois@arm.com) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 9677F113E; Tue, 1 Feb 2022 08:44:21 -0800 (PST) Received: from e126645.home (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 3FD3A3F40C; Tue, 1 Feb 2022 08:44:20 -0800 (PST) From: "PierreGondois" To: devel@edk2.groups.io Cc: Ard Biesheuvel , Sami Mujawar , Pierre Gondois Subject: [PATCH v4 3/9] DynamicTablesPkg: AmlLib: AmlAddPrtEntry() to handle GSI Date: Tue, 1 Feb 2022 17:44:16 +0100 Message-Id: <20220201164422.781784-4-Pierre.Gondois@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220201164422.781784-1-Pierre.Gondois@arm.com> References: <20220201164422.781784-1-Pierre.Gondois@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Pierre Gondois In ACPI 6.4, s6.2.13, _PRT objects describing PCI legacy interrupts can be defined following 2 models. In the first model, _PRT entries reference link devices. Link devices then describe interrupts. This allows to dynamically modify interrupts through _SRS and _PRS objects and to choose exactly the interrupt type (level/edge triggered, active high/low). In the second model, interrupt numbers are described in the _PRT entry. The interrupt type is then assumed by the OS. AmlAddPrtEntry() currently only handles the first model. Make changes to also handle the second model. Signed-off-by: Pierre Gondois --- Notes: v4: - New patch (to handle GSI description in _PRT). [Pierre] .../Common/AmlLib/CodeGen/AmlCodeGen.c | 89 ++++++++++++------- 1 file changed, 55 insertions(+), 34 deletions(-) diff --git a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c = b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c index d245848ce3fa..2d55db97c7bf 100644 --- a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c +++ b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c @@ -1,7 +1,7 @@ /** @file AML Code Generation. =20 - Copyright (c) 2020 - 2021, Arm Limited. All rights reserved.
+ Copyright (c) 2020 - 2022, Arm Limited. All rights reserved.
=20 SPDX-License-Identifier: BSD-2-Clause-Patent **/ @@ -881,6 +881,9 @@ AmlCodeGenNameResourceTemplate ( // interrupt, so let it to index 0. } =20 + The 2 models described in ACPI 6.4, s6.2.13 "_PRT (PCI Routing Table)"= can + be generated by this function. The example above matches the first mod= el. + The package is added at the tail of the list of the input _PRT node name: Name (_PRT, Package () { @@ -901,8 +904,10 @@ AmlCodeGenNameResourceTemplate ( @param [in] Pin PCI pin number of the device (0-INTA ... 3= -INTD). Must be between 0-3. @param [in] LinkName Link Name, i.e. device in the AML NameSpac= e - describing the interrupt used. - The input string is copied. + describing the interrupt used. The input s= tring + is copied. + If NULL, generate 0 in the 'Source' field = (cf. + second model, using GSIV). @param [in] SourceIndex Source index or GSIV. @param [in] PrtNameNode Prt Named node to add the object to .... =20 @@ -930,7 +935,6 @@ AmlAddPrtEntry ( AML_DATA_NODE *DataNode; =20 if ((Pin > 3) || - (LinkName =3D=3D NULL) || (PrtNameNode =3D=3D NULL) || (AmlGetNodeType ((AML_NODE_HANDLE)PrtNameNode) !=3D EAmlNodeObject= ) || (!AmlNodeHasOpCode (PrtNameNode, AML_NAME_OP, 0)) = || @@ -999,41 +1003,58 @@ AmlAddPrtEntry ( =20 NewElementNode =3D NULL; =20 - Status =3D ConvertAslNameToAmlName (LinkName, &AmlNameString); - if (EFI_ERROR (Status)) { - ASSERT (0); - goto error_handler; - } + if (LinkName !=3D NULL) { + Status =3D ConvertAslNameToAmlName (LinkName, &AmlNameString); + if (EFI_ERROR (Status)) { + ASSERT_EFI_ERROR (Status); + goto error_handler; + } =20 - Status =3D AmlGetNameStringSize (AmlNameString, &AmlNameStringSize); - if (EFI_ERROR (Status)) { - ASSERT (0); - goto error_handler; - } + Status =3D AmlGetNameStringSize (AmlNameString, &AmlNameStringSize); + if (EFI_ERROR (Status)) { + ASSERT_EFI_ERROR (Status); + goto error_handler; + } =20 - Status =3D AmlCreateDataNode ( - EAmlNodeDataTypeNameString, - (UINT8 *)AmlNameString, - AmlNameStringSize, - &DataNode - ); - if (EFI_ERROR (Status)) { - ASSERT (0); - goto error_handler; - } + Status =3D AmlCreateDataNode ( + EAmlNodeDataTypeNameString, + (UINT8 *)AmlNameString, + AmlNameStringSize, + &DataNode + ); + if (EFI_ERROR (Status)) { + ASSERT_EFI_ERROR (Status); + goto error_handler; + } =20 - // AmlNameString will be freed before returning. + // AmlNameString will be freed be fore returning. =20 - Status =3D AmlVarListAddTail ( - (AML_NODE_HANDLE)PackageNode, - (AML_NODE_HANDLE)DataNode - ); - if (EFI_ERROR (Status)) { - ASSERT (0); - goto error_handler; - } + Status =3D AmlVarListAddTail ( + (AML_NODE_HANDLE)PackageNode, + (AML_NODE_HANDLE)DataNode + ); + if (EFI_ERROR (Status)) { + ASSERT_EFI_ERROR (Status); + goto error_handler; + } + + DataNode =3D NULL; + } else { + Status =3D AmlCodeGenInteger (0, &NewElementNode); + if (EFI_ERROR (Status)) { + ASSERT_EFI_ERROR (Status); + goto error_handler; + } =20 - DataNode =3D NULL; + Status =3D AmlVarListAddTail ( + (AML_NODE_HANDLE)PackageNode, + (AML_NODE_HANDLE)NewElementNode + ); + if (EFI_ERROR (Status)) { + ASSERT_EFI_ERROR (Status); + goto error_handler; + } + } =20 Status =3D AmlCodeGenInteger (SourceIndex, &NewElementNode); if (EFI_ERROR (Status)) { --=20 2.25.1