From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f43.google.com (mail-pj1-f43.google.com [209.85.216.43]) by mx.groups.io with SMTP id smtpd.web12.987.1660170540916901758 for ; Wed, 10 Aug 2022 15:29:01 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20210112 header.b=PaWcPSc8; spf=pass (domain: gmail.com, ip: 209.85.216.43, mailfrom: kuqin12@gmail.com) Received: by mail-pj1-f43.google.com with SMTP id 15-20020a17090a098f00b001f305b453feso3595569pjo.1 for ; Wed, 10 Aug 2022 15:29:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=GJXtjHzlIBYv4QAJUXitmljaljgvOn1WKb0r1atuDzk=; b=PaWcPSc87VZk3owhr2aPmMNE7i51R1SHQ4ydmcyJcwTj48KPXZBZ+kw96edvnogTob t+hajoxoY8N/KX+Cbg7PFs/PqpWuAt55GVppz9vl5lJ2gEBJKQvRpJjkJlt1Ok1YFxAH YWS9/kVmfjoXt8Xssfsp/5VJUWRsLjZKVaQsRaJ6jgJzmJhsH6d0pFW/Woxhlbr3K8MH vzG6U2m9GBofTiXE6bMGHiPAj6fT/XtaO12MkauBzHnmKM3z4A2qr59MbNc1KGkOhD8s 7zENzAP2BtFU5ZEJdTVi0cHppRLr99nnjYws48jV/3+Gww8zXD91RQ4Tj2V22dNVi4Ay pxIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=GJXtjHzlIBYv4QAJUXitmljaljgvOn1WKb0r1atuDzk=; b=XTtj60uJZCoRESCuhJjLF3IJNWchbYORyCpDASzO6LvvEUtBYdmAJZXun7telPZlXT ljNScXhEOHR3f4N3mFXxTdubwKAuc+flp5wxBAm4Q9BxgXbainWvLtVGsVK6/JqRwIBb +wgybJ9gLfl/63Wkk1O3ap75PMfslLhPZ+F1XY80pkc8g2EHa/qUX83fyHXVjxbKmceP 5LvNVB2UCDkRQo8h5oDmuXocjahm5tGOiJviWhaGWDm+u2uQA1fFnp/30e+FX5MA0z1o SmidN51fRZFzDQ9fu44AcE8S9Tc/XKwF4wre1Pla+eKvI04IPh0UI/WR9M64IdRAl/Ut fo+A== X-Gm-Message-State: ACgBeo2koKB/PYp00p4pnusP3L6QCJwP6Sz8EjLHFeEO/1tmXk77FyJf CRBO916qWqZD4Ea5XEjOX7dCNtYdaFE= X-Google-Smtp-Source: AA6agR4mu3vbf+ZFfq+awSkOy/aNGSu1F6j4oaiKe98NQ8B8W6OFuRZ0yKRvf+Z4QTH+u6MLeBhskg== X-Received: by 2002:a17:903:d4:b0:16d:bb31:f66 with SMTP id x20-20020a17090300d400b0016dbb310f66mr29800395plc.60.1660170540308; Wed, 10 Aug 2022 15:29:00 -0700 (PDT) Return-Path: Received: from MININT-0U7P5GU.redmond.corp.microsoft.com ([2001:4898:80e8:38:b518:f1a8:aef2:7dc4]) by smtp.gmail.com with ESMTPSA id h11-20020a170902f70b00b0016d66d49b85sm13309701plo.239.2022.08.10.15.28.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Aug 2022 15:29:00 -0700 (PDT) From: "Kun Qin" To: devel@edk2.groups.io Cc: Joe Lopez Subject: [PATCH v4 5/6] DynamicTablesPkg: AcpiSsdtPcieLibArm: Added function to reserve ECAM space Date: Wed, 10 Aug 2022 15:28:52 -0700 Message-Id: <20220810222853.1916-6-kuqin12@gmail.com> X-Mailer: git-send-email 2.37.1.windows.1 In-Reply-To: <20220810222853.1916-1-kuqin12@gmail.com> References: <20220810222853.1916-1-kuqin12@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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 --- Notes: v2: - Only create RES0 after config space checking [Pierre] =20=20=20=20 v3: - Updated function names and descriptions [Pierre] - Moved translation calculation to CONFIG case [Pierre] =20=20=20=20 v4: - Used CM_ARM_PCI_CONFIG_SPACE_INFO for ECAM region calculation [Sami, = Pierre] DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieGenerator.c |= 135 ++++++++++++++++++++ 1 file changed, 135 insertions(+) diff --git a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieG= enerator.c b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieG= enerator.c index ceffe2838c03..dd75fc27e60e 100644 --- a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieGenerato= r.c +++ b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieGenerato= r.c @@ -34,6 +34,9 @@ =0D #include "SsdtPcieGenerator.h"=0D =0D +#define PCI_MAX_DEVICE_COUNT_PER_BUS 32=0D +#define PCI_MAX_FUNCTION_COUNT_PER_DEVICE 8=0D +=0D /** ARM standard SSDT Pcie Table Generator.=0D =0D Requirements:=0D @@ -616,6 +619,130 @@ GeneratePciCrs ( return Status;=0D }=0D =0D +/** Generate a RES0 device node to reserve PNP motherboard resources=0D + for a given PCI node.=0D +=0D + @param [in] PciNode Parent PCI node handle of the generated=0D + resource object.=0D + @param [out] CrsNode CRS node of the AML tree to populate.=0D +=0D + @retval EFI_SUCCESS The function completed successfully.=0D + @retval EFI_INVALID_PARAMETER Invalid input parameter.=0D + @retval EFI_OUT_OF_RESOURCES Could not allocate memory.=0D +**/=0D +STATIC=0D +EFI_STATUS=0D +EFIAPI=0D +GenerateMotherboardDevice (=0D + IN AML_OBJECT_NODE_HANDLE PciNode,=0D + OUT AML_OBJECT_NODE_HANDLE *CrsNode=0D + )=0D +{=0D + EFI_STATUS Status;=0D + UINT32 EisaId;=0D + AML_OBJECT_NODE_HANDLE ResNode;=0D +=0D + if (CrsNode =3D=3D NULL) {=0D + ASSERT (0);=0D + return EFI_INVALID_PARAMETER;=0D + }=0D +=0D + // ASL: Device (RES0) {}=0D + Status =3D AmlCodeGenDevice ("RES0", PciNode, &ResNode);=0D + if (EFI_ERROR (Status)) {=0D + ASSERT (0);=0D + return Status;=0D + }=0D +=0D + // ASL: Name (_HID, EISAID ("PNP0C02"))=0D + Status =3D AmlGetEisaIdFromString ("PNP0C02", &EisaId); /* PNP Motherboa= rd Resources */=0D + if (EFI_ERROR (Status)) {=0D + ASSERT (0);=0D + return Status;=0D + }=0D +=0D + Status =3D AmlCodeGenNameInteger ("_HID", EisaId, ResNode, NULL);=0D + if (EFI_ERROR (Status)) {=0D + ASSERT (0);=0D + return Status;=0D + }=0D +=0D + // ASL: Name (_CRS, ResourceTemplate () {})=0D + Status =3D AmlCodeGenNameResourceTemplate ("_CRS", ResNode, CrsNode);=0D + if (EFI_ERROR (Status)) {=0D + ASSERT (0);=0D + return Status;=0D + }=0D +=0D + return Status;=0D +}=0D +=0D +/** Reserves ECAM space for PCI config space=0D +=0D + @param [in] Generator The SSDT Pci generator.=0D + @param [in] CfgMgrProtocol Pointer to the Configuration Manager=0D + Protocol interface.=0D + @param [in] PciInfo Pci device information.=0D + @param [in, out] PciNode RootNode of the AML tree to populate.= =0D +=0D + @retval EFI_SUCCESS The function completed successfully.=0D + @retval EFI_INVALID_PARAMETER Invalid parameter.=0D + @retval EFI_OUT_OF_RESOURCES Could not allocate memory.=0D +**/=0D +STATIC=0D +EFI_STATUS=0D +EFIAPI=0D +ReserveEcamSpace (=0D + IN ACPI_PCI_GENERATOR *Generator,= =0D + IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST CfgMgrProtoc= ol,=0D + IN CONST CM_ARM_PCI_CONFIG_SPACE_INFO *PciInfo,=0D + IN OUT AML_OBJECT_NODE_HANDLE PciNode=0D + )=0D +{=0D + EFI_STATUS Status;=0D + AML_OBJECT_NODE_HANDLE CrsNode;=0D + UINT64 AddressMinimum;=0D + UINT64 AddressMaximum;=0D +=0D + Status =3D GenerateMotherboardDevice (PciNode, &CrsNode);=0D + if (EFI_ERROR (Status)) {=0D + ASSERT (0);=0D + return Status;=0D + }=0D +=0D + AddressMinimum =3D PciInfo->BaseAddress + (PciInfo->StartBusNumber *=0D + PCI_MAX_DEVICE_COUNT_PER_BUS * = PCI_MAX_FUNCTION_COUNT_PER_DEVICE * SIZE_4KB);=0D + AddressMaximum =3D PciInfo->BaseAddress + ((PciInfo->EndBusNumber + 1) *= =0D + PCI_MAX_DEVICE_COUNT_PER_BUS * = PCI_MAX_FUNCTION_COUNT_PER_DEVICE * SIZE_4KB) - 1;=0D +=0D + Status =3D AmlCodeGenRdQWordMemory (=0D + FALSE,=0D + TRUE,=0D + TRUE,=0D + TRUE,=0D + FALSE, // non-cacheable=0D + TRUE,=0D + 0,=0D + AddressMinimum,=0D + AddressMaximum,=0D + 0, // no translation=0D + AddressMaximum - AddressMinimum + 1,=0D + 0,=0D + NULL,=0D + 0,=0D + TRUE,=0D + CrsNode,=0D + NULL=0D + );=0D +=0D + if (EFI_ERROR (Status)) {=0D + ASSERT (0);=0D + return Status;=0D + }=0D +=0D + return Status;=0D +}=0D +=0D /** Generate a Pci device.=0D =0D @param [in] Generator The SSDT Pci generator.=0D @@ -702,9 +829,17 @@ GeneratePciDevice ( return Status;=0D }=0D =0D + // Add the PNP Motherboard Resources Device to reserve ECAM space=0D + Status =3D ReserveEcamSpace (Generator, CfgMgrProtocol, PciInfo, PciNode= );=0D + if (EFI_ERROR (Status)) {=0D + ASSERT (0);=0D + return Status;=0D + }=0D +=0D // Add the template _OSC method.=0D Status =3D AddOscMethod (PciInfo, PciNode);=0D ASSERT_EFI_ERROR (Status);=0D +=0D return Status;=0D }=0D =0D --=20 2.37.1.windows.1