From nobody Sat Feb 7 07:10:22 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+92000+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+92000+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1659245855; cv=none; d=zohomail.com; s=zohoarc; b=ExTuS1o0JT96u/T7prDdv8l7CXX+m0cVmn99bN9t/DKXf6CH5zaWRZRnwLC1CMGxTO4OhH32oOAK5t9K/uu+i8stLqP6cQoTgCgxKuL6t124f9wqRM16yKfpilCWKKdVMwRFpI/JHDLR54PdZpEZ1tJIhmiklG111XPpnn8yOck= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1659245855; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=4VZUo80MoyLFhhVQ9m+OOCUyFUrL6a+HKw4KIWJN2NU=; b=bIhKe7zxDUswGiT//x5csn5GqHl5ebmk+jz82PjoSVJX9MVlMrS7SIKe+c7TxYnKX2GNL2mxQ6J0lkPbWlWY59/VcaIO2EUliC/sVTZrChLuWvm3Jjz2r1tnsP1uj34xNgrXVbflITNRPvDRAhiCgm6B1YVCG0miOQ++0s5i5OE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+92000+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1659245855852912.7060347829695; Sat, 30 Jul 2022 22:37:35 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id mrwUYY1788612xzg8x2hXBaN; Sat, 30 Jul 2022 22:37:35 -0700 X-Received: from mail-pg1-f170.google.com (mail-pg1-f170.google.com [209.85.215.170]) by mx.groups.io with SMTP id smtpd.web10.10472.1659245854906888865 for ; Sat, 30 Jul 2022 22:37:34 -0700 X-Received: by mail-pg1-f170.google.com with SMTP id 12so7103613pga.1 for ; Sat, 30 Jul 2022 22:37:34 -0700 (PDT) X-Gm-Message-State: xRK5knoundUD00A3cc7u2n7qx1787277AA= X-Google-Smtp-Source: AGRyM1uVZyrxCFVEvH5RYun5JjVMJ/VTsy1RRCEiAhH6sUY6mAnCEaqaLAIo4QNTKOi6bXUIpH7MzA== X-Received: by 2002:a05:6a00:cc5:b0:52c:91b8:e88c with SMTP id b5-20020a056a000cc500b0052c91b8e88cmr10564507pfv.56.1659245854211; Sat, 30 Jul 2022 22:37:34 -0700 (PDT) X-Received: from MININT-0U7P5GU.redmond.corp.microsoft.com ([2001:4898:80e8:7:a09e:ed80:a0cd:1e24]) by smtp.gmail.com with ESMTPSA id x6-20020a1709029a4600b00168e83eda56sm6714524plv.3.2022.07.30.22.37.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 30 Jul 2022 22:37:33 -0700 (PDT) From: "Kun Qin" To: devel@edk2.groups.io Cc: Joe Lopez , Pierre Gondois Subject: [edk2-devel] [PATCH v3 5/6] DynamicTablesPkg: AcpiSsdtPcieLibArm: Added function to reserve ECAM space Date: Sat, 30 Jul 2022 22:37:26 -0700 Message-Id: <20220731053727.536-6-kuqin12@gmail.com> In-Reply-To: <20220731053727.536-1-kuqin12@gmail.com> References: <20220731053727.536-1-kuqin12@gmail.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,kuqin12@gmail.com Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1659245855; bh=T+Rh4gLweotUT9/dk3tueUiKwHyz+F7sQHNuTU9bSPQ=; h=Cc:Date:From:Reply-To:Subject:To; b=XQY2gBVNJAoL9GVP7/z+afyqk9fN1K+CPwcPvwA+WY/d1lhfA72o9vzVnp1E4W58UkO 81M9/eaRgO8MMYQHuQbhDox6RaqcyhZ9rY4r6p85tPoRxsus2CdgjPX9UsvCACiYwPa/5 7dtr3ULLHGIKAVzBy2wZ0tVZxtK4A6aeJCs= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1659245857493100021 Content-Type: text/plain; charset="utf-8" REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3998 Certain OSes will complain if the ECAM config space is not reserved in the ACPI namespace. This change adds a function to reserve PNP motherboard resources for a given PCI node. Co-authored-by: Joe Lopez Signed-off-by: Kun Qin Reviewed-by: Pierre Gondois Reviewed-by: Sami Mujawar --- Notes: v2: - Only create RES0 after config space checking [Pierre] =20 v3: - Updated function names and descriptions [Pierre] - Moved translation calculation to CONFIG case [Pierre] DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieGenerator.c |= 171 ++++++++++++++++++++ 1 file changed, 171 insertions(+) diff --git a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieG= enerator.c b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieG= enerator.c index ceffe2838c03..658a089c8f1f 100644 --- a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieGenerato= r.c +++ b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieGenerato= r.c @@ -616,6 +616,169 @@ GeneratePciCrs ( return Status; } =20 +/** Generate a RES0 device node to reserve PNP motherboard resources + for a given PCI node. + + @param [in] PciNode Parent PCI node handle of the generated + resource object. + @param [out] CrsNode CRS node of the AML tree to populate. + + @retval EFI_SUCCESS The function completed successfully. + @retval EFI_INVALID_PARAMETER Invalid input parameter. + @retval EFI_OUT_OF_RESOURCES Could not allocate memory. +**/ +STATIC +EFI_STATUS +EFIAPI +GenerateMotherboardDevice ( + IN AML_OBJECT_NODE_HANDLE PciNode, + OUT AML_OBJECT_NODE_HANDLE *CrsNode + ) +{ + EFI_STATUS Status; + UINT32 EisaId; + AML_OBJECT_NODE_HANDLE ResNode; + + if (CrsNode =3D=3D NULL) { + ASSERT (0); + return EFI_INVALID_PARAMETER; + } + + // ASL: Device (RES0) {} + Status =3D AmlCodeGenDevice ("RES0", PciNode, &ResNode); + if (EFI_ERROR (Status)) { + ASSERT (0); + return Status; + } + + // ASL: Name (_HID, EISAID ("PNP0C02")) + Status =3D AmlGetEisaIdFromString ("PNP0C02", &EisaId); /* PNP Motherboa= rd Resources */ + if (EFI_ERROR (Status)) { + ASSERT (0); + return Status; + } + + Status =3D AmlCodeGenNameInteger ("_HID", EisaId, ResNode, NULL); + if (EFI_ERROR (Status)) { + ASSERT (0); + return Status; + } + + // ASL: Name (_CRS, ResourceTemplate () {}) + Status =3D AmlCodeGenNameResourceTemplate ("_CRS", ResNode, CrsNode); + if (EFI_ERROR (Status)) { + ASSERT (0); + return Status; + } + + return Status; +} + +/** Reserves ECAM space for PCI config space + + @param [in] Generator The SSDT Pci generator. + @param [in] CfgMgrProtocol Pointer to the Configuration Manager + Protocol interface. + @param [in] PciInfo Pci device information. + @param [in, out] PciNode RootNode of the AML tree to populate. + + @retval EFI_SUCCESS The function completed successfully. + @retval EFI_INVALID_PARAMETER Invalid parameter. + @retval EFI_OUT_OF_RESOURCES Could not allocate memory. +**/ +STATIC +EFI_STATUS +EFIAPI +ReserveEcamSpace ( + IN ACPI_PCI_GENERATOR *Generator, + IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST CfgMgrProtoc= ol, + IN CONST CM_ARM_PCI_CONFIG_SPACE_INFO *PciInfo, + IN OUT AML_OBJECT_NODE_HANDLE PciNode + ) +{ + EFI_STATUS Status; + AML_OBJECT_NODE_HANDLE CrsNode; + BOOLEAN Translation; + UINT32 Index; + CM_ARM_OBJ_REF *RefInfo; + UINT32 RefCount; + CM_ARM_PCI_ADDRESS_MAP_INFO *AddrMapInfo; + BOOLEAN IsPosDecode; + + // Get the array of CM_ARM_OBJ_REF referencing the + // CM_ARM_PCI_ADDRESS_MAP_INFO objects. + Status =3D GetEArmObjCmRef ( + CfgMgrProtocol, + PciInfo->AddressMapToken, + &RefInfo, + &RefCount + ); + if (EFI_ERROR (Status)) { + ASSERT (0); + return Status; + } + + for (Index =3D 0; Index < RefCount; Index++) { + // Get CM_ARM_PCI_ADDRESS_MAP_INFO structures one by one. + Status =3D GetEArmObjPciAddressMapInfo ( + CfgMgrProtocol, + RefInfo[Index].ReferenceToken, + &AddrMapInfo, + NULL + ); + if (EFI_ERROR (Status)) { + ASSERT (0); + return Status; + } + + switch (AddrMapInfo->SpaceCode) { + case PCI_SS_CONFIG: + Translation =3D (AddrMapInfo->CpuAddress !=3D AddrMapInfo->PciAddr= ess); + if (AddrMapInfo->CpuAddress >=3D AddrMapInfo->PciAddress) { + IsPosDecode =3D TRUE; + } else { + IsPosDecode =3D FALSE; + } + + Status =3D GenerateMotherboardDevice (PciNode, &CrsNode); + if (EFI_ERROR (Status)) { + ASSERT (0); + break; + } + + Status =3D AmlCodeGenRdQWordMemory ( + FALSE, + IsPosDecode, + TRUE, + TRUE, + FALSE, // non-cacheable + TRUE, + 0, + AddrMapInfo->PciAddress, + AddrMapInfo->PciAddress + AddrMapInfo->AddressSize - 1, + Translation ? AddrMapInfo->CpuAddress - AddrMapInfo->Pc= iAddress : 0, + AddrMapInfo->AddressSize, + 0, + NULL, + 0, + TRUE, + CrsNode, + NULL + ); + break; + default: + break; + } // switch + + if (EFI_ERROR (Status)) { + ASSERT (0); + return Status; + } + } + + return Status; +} + /** Generate a Pci device. =20 @param [in] Generator The SSDT Pci generator. @@ -702,9 +865,17 @@ GeneratePciDevice ( return Status; } =20 + // Add the PNP Motherboard Resources Device to reserve ECAM space + Status =3D ReserveEcamSpace (Generator, CfgMgrProtocol, PciInfo, PciNode= ); + if (EFI_ERROR (Status)) { + ASSERT (0); + return Status; + } + // Add the template _OSC method. Status =3D AddOscMethod (PciInfo, PciNode); ASSERT_EFI_ERROR (Status); + return Status; } =20 --=20 2.37.1.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#92000): https://edk2.groups.io/g/devel/message/92000 Mute This Topic: https://groups.io/mt/92722843/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-