From nobody Tue Apr 30 02:02:46 2024 Delivered-To: importer@patchew.org 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+85966+1787277+3901457@groups.io; arc=fail (BodyHash is different from the expected one); dmarc=fail(p=none dis=none) header.from=arm.com Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1642865238399979.4485897039862; Sat, 22 Jan 2022 07:27:18 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id niT5YY1788612xXjemM3JlPP; Sat, 22 Jan 2022 07:27:18 -0800 X-Received: from EUR05-VI1-obe.outbound.protection.outlook.com (EUR05-VI1-obe.outbound.protection.outlook.com [40.107.21.61]) by mx.groups.io with SMTP id smtpd.web12.9533.1642865235863397682 for ; Sat, 22 Jan 2022 07:27:17 -0800 X-Received: from DB6P18901CA0012.EURP189.PROD.OUTLOOK.COM (2603:10a6:4:16::22) by HE1PR08MB2859.eurprd08.prod.outlook.com (2603:10a6:7:2d::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4888.11; Sat, 22 Jan 2022 15:27:00 +0000 X-Received: from DB5EUR03FT030.eop-EUR03.prod.protection.outlook.com (2603:10a6:4:16:cafe::d9) by DB6P18901CA0012.outlook.office365.com (2603:10a6:4:16::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4909.7 via Frontend Transport; Sat, 22 Jan 2022 15:27:00 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dmarc=pass action=none header.from=arm.com; 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+85966+1787277+3901457@groups.io; helo=mail02.groups.io; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; X-Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by DB5EUR03FT030.mail.protection.outlook.com (10.152.20.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4909.7 via Frontend Transport; Sat, 22 Jan 2022 15:27:00 +0000 X-Received: ("Tessian outbound 2877e54fe176:v113"); Sat, 22 Jan 2022 15:27:00 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 8ea25af44757dadf X-CR-MTA-TID: 64aa7808 X-Received: from 28f8e27a7a95.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id DA1EC1C9-E4A5-4556-95F4-AF35819103A7.1; Sat, 22 Jan 2022 15:26:49 +0000 X-Received: from EUR02-AM5-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 28f8e27a7a95.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Sat, 22 Jan 2022 15:26:49 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=A/pOba8b6f5IocdFhpTkEb+5+NWhDZRER7xUN3ZOUHB9Kiem8WLlkE+PrIU7HIfmGetW/cJGHp3Ww6ayowLtFHwuPNliEqbl/VQHpTEmWZUUNXv4G5TTto6z8UCDx2sADULSIbcxrdO/I0jZHmeuHqygYsVNMFbTcpoPXqKbQ5ZPpr/S3zR01ecZePshBFBodUDIjhS3jdyvQki8jKW26GwI6eNSjDI4T8/wnjmBd2GtCDCMWtXPaCN+Z9wpZ7BSFuuGisGd9dX/IcrnO0pEGouAuJcy95GQwah2TK15OqfXRwZzVDKiolEz3D/H2GcjdNursNMjzYpnqr6pZaWAqw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=5idstx8XstY8xi9FLKvYHW9bPM6wWd25KLGyNphZstw=; b=OQTmYolDHj+NIRgL29IFynHN5LoektHgY+nCxhnNeYqv1FBne8BbgPuws8rnjHkn33+YxE/OnalYvpheRxpcW7z4msWFUb+e3MCAyUuqBTsyQoL3jZXem8Iu0wCOpsO72dpYBt03b832Ws8dIZVjbjszO8pe4YD+mQJJS1dIp1w/5LE1incnNSza7x72IIW62I/jyevEgOcuWHNM9pqChduJWDgT0Bcps3vt0MDqx0TP9UxiCpEmfh7aCWiUbeJ5ae/AAmMbvNtBE6aOO6EkMJ1e907StylWMTzNpbQT3QZB+1Grm3GFLdBAStzklWA9edUtbnG14Twy9D6yKIq34A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; X-Received: from PA4PR08MB5902.eurprd08.prod.outlook.com (2603:10a6:102:e0::10) by AM0PR08MB4579.eurprd08.prod.outlook.com (2603:10a6:208:108::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4909.12; Sat, 22 Jan 2022 15:26:42 +0000 X-Received: from PA4PR08MB5902.eurprd08.prod.outlook.com ([fe80::edb5:a2ea:773e:cb8]) by PA4PR08MB5902.eurprd08.prod.outlook.com ([fe80::edb5:a2ea:773e:cb8%7]) with mapi id 15.20.4909.014; Sat, 22 Jan 2022 15:26:42 +0000 From: "Khasim Mohammed" To: devel@edk2.groups.io Cc: nd@arm.com, sami.mujawar@arm.com, pierre.gondois@arm.com, Khasim Syed Mohammed Subject: [edk2-devel] [PATCH v6 1/4] Silicon/ARM/NeoverseN1Soc: Port PCI Segment Library Date: Sat, 22 Jan 2022 20:56:12 +0530 Message-Id: <20220122152615.17366-2-khasim.mohammed@arm.com> In-Reply-To: <20220122152615.17366-1-khasim.mohammed@arm.com> References: <20220122152615.17366-1-khasim.mohammed@arm.com> X-ClientProxiedBy: PN0PR01CA0017.INDPRD01.PROD.OUTLOOK.COM (2603:1096:c01:4f::22) To PA4PR08MB5902.eurprd08.prod.outlook.com (2603:10a6:102:e0::10) MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: d2a75d1f-223e-425c-2cc1-08d9ddbba29d X-MS-TrafficTypeDiagnostic: AM0PR08MB4579:EE_|DB5EUR03FT030:EE_|HE1PR08MB2859:EE_ X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:3044;OLM:3044; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: R5RdxeoMYQdWTxlacsMCAgo+VxMirZ8uFK3j21x5k0fnbiXK6V6nsHbgbiduGu5iVJvChSodc2giyJbqBcEs3gpwyLaWq0HuJBN2P3jXP3nwl2qJ/tMzYmDLPOQ1rbjwydUXkcjTLRhkl38sPLWf2OyUZij3Pi07WKuyerKwjFbvkYORuJwGaXSycyxlYorlpx7wk4BJXAFl2BKHeOPR3VCoG/CiTrlU35WAx4B+p6nP23oS4KMkk03ikEhE0xtn7QakMgo482SruwL8bfpzoDGq/a8fatCg3z0rXLkcQAb61E7p4Kl+Dvz2+My9st2xz6lteXq3L++mC9hg1Y4zWM0RO12yoTB4RpAd89vVlaU27qmB1ST9uNuzOtBxyfxwWCEeXOazq33Mw9j+By3Q2ao/osMFwhWtMIjGanXKIwjyHZMzQStA93/3NuR3gcSXc7fT8kO00vz8EUaxoeOxe5IAonhWcmPnCxZeJ0O6s2i6bD3/4Brejth4qDcM3giHZNQq0Tpi7rEWNpfRdh6IjlgOPYG1d0GI9N65PqMtOpYBy9TZhQak+761csxdBZRiCM9fM+lH07up8FE92WMR7pkgB6YyuG9u8DdgCX8aHlTAlyCtHA+FufeMDeJBxRut4cc8kCKHiQx6D4ZaAlcX83wtR5v1nsyW7aCxhJmH0fryBQwSNpq8qLJbMv1/dG3PI/Asd9+xM4salUGnblh3kw== X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PA4PR08MB5902.eurprd08.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(6506007)(186003)(36756003)(83380400001)(6666004)(8676002)(4326008)(5660300002)(6486002)(6916009)(316002)(6512007)(26005)(19627235002)(30864003)(508600001)(52116002)(2906002)(8936002)(66476007)(38350700002)(38100700002)(66556008)(1076003)(2616005)(66946007)(86362001)(579004)(559001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB4579 Original-Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DB5EUR03FT030.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 2e31899c-619d-42a8-d49b-08d9ddbb9712 X-Microsoft-Antispam-Message-Info: 63WyMsq497dhdViKyX4hTNflPH5+ARFB+qsnyGj8RAVTrnbMXc83u1dzGhQhzH7PSqiLBiY+LLIR8npQXJE5sIaCbG1wrLFLacvH74R3uGXVyWh4nlqq/fRUcj/T+dhgU/pymC2crmRJ33TX+9ag55rctsYakr4SoQl5fw9LWFMURNDWni4mDT54nQsggVUmkXR5/yW+QTggCRYOrR+myrtSGvrxlMYqlzTnrsExEgZ3hbHK6ZPGHgQrXKoUVEXoNEwIlLyi1tQEX7vIxai2/wFeGgNnB1kicQIZ2UKJcQ1tlZBMKD6dpHCv+0nxOMgQOYffdsLyDr2UnovBK1+AoZScs1oHj7Yr8U4hp14I3gAgzR+kxYkA3Vbll0gyLNrWDcuiu4REY5twUdcYN5BJgH5fo47XIfzKYhAucSq7C6bsGtJXrymMe1Ul3IyLxcnsMtzH3/KzoTz9awbk0frWg3kl40koj9odJdzn0YZGLczGcbX5aDOQz75r+eLQDV1se8eqt+PJVZV2WPFpP7GAUNHJkxcbTBMuH7aHmCFri/VEyTqyx1IUCxY07gYxnvuoNts/BU8ymqoaC981MKxPSHYHD2/DR8At3N8qETpZKrB73UqGghJ8OUa5BTO24y+iHqmXOeOiVxXFloJS4gMBqaUnhreO1N9RXuVZchwe2e/9WFl5F6HWGxe06hRfu8hXI9q5dh/61penpypRYjHS2JVV6KYMi8MyMsfqk1KekbiWJXJ7QrVmWPAscM6yE8KxGz+NGd4eFERhMFBVMOw5LA== X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jan 2022 15:27:00.6468 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d2a75d1f-223e-425c-2cc1-08d9ddbba29d X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d;Ip=[63.35.35.123];Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: DB5EUR03FT030.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR08MB2859 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,khasim.mohammed@arm.com X-Gm-Message-State: aXj7eLnfH4U84K5Wgn1bCEcxx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1642865238; bh=qbV7rC857833xU9/NFO6JhXQKdGkH30CEzw6ubl30xo=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=UMB0Nyl3+JUTONIv+9aFtAt+gU5qc9XZewQ9SutXRzHCpVRBGmmqO7z5mFRcYORNoqp 4pu/gZxuCZhyfhltkln3ENfrD5Cq3sXOo7YMKbllg4P4vGzFZt0BhWUHs3JeygjyoJlFL BZlFcDbmK5bRwhjEyCkBr3bc6/MHXqMMMas= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1642865238977100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The BasePCISegment Library in MdePkg doesn't allow configuring multiple segments required for PCIe and CCIX root port enumeration. Therefore, a custom PCI Segment library is adapted from SynQuacerPciSegmentLib and ported for N1Sdp. In addition to this, the hardware has few other limitations which affects the access to the PCIe root port: 1. ECAM space is not contiguous, root port ECAM (BDF =3D 0:0:0) is isolat= ed from rest of the downstream hierarchy ECAM space. 2. Root port ECAM space is not capable of 8bit/16bit writes. 3. A slave error is generated when host accesses the configuration space of non-available device or unimplemented function on a given bus. The description of the workarounds included for these limitations can be found in the corresponding files of this patch. Signed-off-by: Khasim Syed Mohammed Reviewed-by: Sami Mujawar --- .../Library/PciSegmentLib/PciSegmentLib.c | 1622 +++++++++++++++++ .../Library/PciSegmentLib/PciSegmentLib.inf | 38 + 2 files changed, 1660 insertions(+) create mode 100644 Silicon/ARM/NeoverseN1Soc/Library/PciSegmentLib/PciSegm= entLib.c create mode 100644 Silicon/ARM/NeoverseN1Soc/Library/PciSegmentLib/PciSegm= entLib.inf diff --git a/Silicon/ARM/NeoverseN1Soc/Library/PciSegmentLib/PciSegmentLib.= c b/Silicon/ARM/NeoverseN1Soc/Library/PciSegmentLib/PciSegmentLib.c new file mode 100644 index 0000000000..065f86df01 --- /dev/null +++ b/Silicon/ARM/NeoverseN1Soc/Library/PciSegmentLib/PciSegmentLib.c @@ -0,0 +1,1622 @@ +/** @file + PCI Segment Library for N1SDP SoC with multiple RCs + + Having two distinct root complexes is not supported by the standard + set of PciLib/PciExpressLib/PciSegmentLib, this PciSegmentLib + reimplements the functionality to support multiple root ports on + different segment numbers. + + On the NeoverseN1Soc, a slave error is generated when host accesses the + configuration space of non-available device or unimplemented function on= a + given bus. So this library introduces a workaround using IsBdfValid(), + to return 0xFFFFFFFF for all such access. + + In addition to this, the hardware has two other limitations which affect + access to the PCIe root port: + 1. ECAM space is not contiguous, root port ECAM (BDF =3D 0:0:0) is iso= lated + from rest of the downstream hierarchy ECAM space. + 2. Root port ECAM space is not capable of 8bit/16bit writes. + The description of the workarounds included for these limitations can + be found in the comments below. + + Copyright (c) 2007 - 2012, Intel Corporation. All rights reserved.
+ Copyright (c) 2022, ARM Limited. All rights reserved.
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include + +#include +#include +#include +#include +#include +#include + +typedef enum { + PciCfgWidthUint8 =3D 0, + PciCfgWidthUint16, + PciCfgWidthUint32, + PciCfgWidthMax +} PCI_CFG_WIDTH; + +/** + Assert the validity of a PCI Segment address. + A valid PCI Segment address should not contain 1's in bits 28..31 and 48.= .63 + + @param A The address to validate. + @param M Additional bits to assert to be zero. +**/ +#define ASSERT_INVALID_PCI_SEGMENT_ADDRESS(A,M) \ + ASSERT (((A) & (0xffff0000f0000000ULL | (M))) =3D=3D 0) + +#define BUS_OFFSET 20 +#define DEV_OFFSET 15 +#define FUNC_OFFSET 12 +#define REG_OFFSET 4096 +#define REG_NUM 0xFFF +#define SEG_OFFSET 32 + +#define EFI_PCIE_ADDRESS(bus, dev, func, reg) \ + (UINT64) ( \ + (((UINTN) bus) << BUS_OFFSET) | \ + (((UINTN) dev) << DEV_OFFSET) | \ + (((UINTN) func) << FUNC_OFFSET) | \ + (((UINTN) (reg)) < REG_OFFSET ? \ + ((UINTN) (reg)) : (UINT64) (LShiftU64 ((UINT64) (reg), 32)))) + +#define GET_PCIE_BASE_ADDRESS(Address) (Address & 0xF8000000) + +/* Root port Entry, BDF Entries Count */ +#define BDF_TABLE_ENTRY_SIZE 4 +#define BDF_TABLE_HEADER_COUNT 2 +#define BDF_TABLE_HEADER_SIZE 8 + +/* BDF table offsets for PCIe */ +#define PCIE_BDF_TABLE_OFFSET 0 +#define CCIX_BDF_TABLE_OFFSET (16 * 1024) + +#define GET_BUS_NUM(Address) (((Address) >> BUS_OFFSET) & 0x7F) +#define GET_DEV_NUM(Address) (((Address) >> DEV_OFFSET) & 0x1F) +#define GET_FUNC_NUM(Address) (((Address) >> FUNC_OFFSET) & 0x07) +#define GET_REG_NUM(Address) ((Address) & REG_NUM) +#define GET_SEG_NUM(Address) (((Address) >> SEG_OFFSET) & 0xFFFF) + +CONST STATIC UINTN mDummyConfigData =3D 0xFFFFFFFF; + +/** + Check if the requested PCI address is a valid BDF address. + + SCP performs the initial bus scan and prepares a table of valid BDF addr= esses + and shares them through non-trusted SRAM. This function validates if the= PCI + address from any PCI request falls within the table of valid entries. If= not, + this function will return 0xFFFFFFFF. This is a workaround to avoid bus = fault + that happens when accessing unavailable PCI device due to RTL bug. + + @param Address The address that encodes the PCI Bus, Device, Function a= nd + Register. + + @return The base address of PCI Express or 0xFFFFFFFF for invalid addres= s. + +**/ +STATIC +UINTN +IsBdfValid ( + IN UINTN Address + ) +{ + UINT16 Segment; + UINTN BdfCount; + UINTN BdfValue; + UINTN Count; + UINTN TableBase; + UINTN PciAddress; + + Segment =3D GET_SEG_NUM (Address); + + // Keep the Bus, Device, Function bits. Clear the rest. + PciAddress =3D Address & 0xFFFF000; + + if (Segment =3D=3D 0) { + TableBase =3D NEOVERSEN1SOC_NON_SECURE_SRAM_BASE + PCIE_BDF_TABLE_OFFS= ET; + } else if (Segment =3D=3D 1) { + TableBase =3D NEOVERSEN1SOC_NON_SECURE_SRAM_BASE + CCIX_BDF_TABLE_OFFS= ET; + } else { + ASSERT (0); + return mDummyConfigData; + } + + BdfCount =3D MmioRead32 (TableBase + BDF_TABLE_ENTRY_SIZE); + + /* Start from the second entry */ + for (Count =3D BDF_TABLE_HEADER_COUNT; + Count < (BdfCount + BDF_TABLE_HEADER_COUNT); + Count++) { + BdfValue =3D MmioRead32 (TableBase + (Count * BDF_TABLE_ENTRY_SIZE)); + if (BdfValue =3D=3D PciAddress) { + break; + } + } + + if (Count =3D=3D (BdfCount + BDF_TABLE_HEADER_COUNT)) { + return mDummyConfigData; + } else { + return PciAddress; + } +} + +/** + Get the physical address of a configuration space register. + + Implement a workaround to avoid generation of slave errors from the bus= . That + is, retrieve the PCI Express Base Address via a PCD entry, add the incom= ming + address with that base address and check whether this converted address + points to a accessible BDF. If it is not accessible, return the address + of a dummy location so that a read from it does not cause a slave error. + + In addition to this, implement a workaround for accessing the root port's + configuration space. The root port configuration space is not contiguous + with the rest of the downstream hierarchy configuration space. So determ= ine + whether the specified address is for the root port and use a different b= ase + address for it. + + @param Address The address that encodes the PCI Bus, Device, Function a= nd + Register. + + @return Physical address of the configuration register that corresponds = to the + PCI configuration register specified by input parameter 'Address= '. + +**/ +STATIC +VOID* +GetPciExpressAddress ( + IN UINTN Address + ) +{ + BOOLEAN CheckRootPort; + UINT16 Segment; + UINT8 Bus; + UINT8 Device; + UINT8 Function; + UINT16 Register; + UINTN ConfigAddress; + + Segment =3D GET_SEG_NUM (Address); + Bus =3D GET_BUS_NUM (Address); + Device =3D GET_DEV_NUM (Address); + Function =3D GET_FUNC_NUM (Address); + Register =3D GET_REG_NUM (Address); + + + CheckRootPort =3D (Bus =3D=3D 0) && (Device =3D=3D 0) && (Function =3D= =3D 0); + + if (CheckRootPort =3D=3D FALSE) { + if (IsBdfValid (Address) =3D=3D mDummyConfigData) { + return (VOID*) &mDummyConfigData; + } + } + + if (Segment =3D=3D 0) { + if (CheckRootPort =3D=3D TRUE) { + ConfigAddress =3D (UINTN) PcdGet32 (PcdPcieRootPortConfigBaseAddress= ); + } else { + ConfigAddress =3D (UINTN) PcdGet64 (PcdPcieExpressBaseAddress); + } + } else if (Segment =3D=3D 1) { + if (CheckRootPort =3D=3D TRUE) { + ConfigAddress =3D (UINTN) PcdGet32 (PcdCcixRootPortConfigBaseAddress= ); + } else { + ConfigAddress =3D (UINTN) PcdGet32 (PcdCcixExpressBaseAddress); + } + } else { + ASSERT (0); + return (VOID*) &mDummyConfigData; + } + + ConfigAddress +=3D EFI_PCIE_ADDRESS (Bus, Device, Function, Register); + return (VOID *)ConfigAddress; +} + +/** + Internal worker function to read a PCI configuration register. + + @param Address The address that encodes the PCI Bus, Device, Function + and Register. + @param Width The width of data to read + + @return The value read from the PCI configuration register. +**/ +STATIC +UINT32 +PciSegmentLibReadWorker ( + IN UINT64 Address, + IN PCI_CFG_WIDTH Width + ) +{ + UINTN PciAddress; + + PciAddress =3D (UINTN) GetPciExpressAddress ((UINTN) Address); + + switch (Width) { + case PciCfgWidthUint8: + return MmioRead8 (PciAddress); + case PciCfgWidthUint16: + return MmioRead16 (PciAddress); + case PciCfgWidthUint32: + return MmioRead32 (PciAddress); + default: + ASSERT (0); + } + + return 0; +} + +/** + Internal worker function to write to a PCI configuration register. + + @param Address The address that encodes the PCI Bus, Device, Function + and Register. + @param Width The width of data to write + @param Data The value to write. + + @return The value written to the PCI configuration register. +**/ +STATIC +UINT32 +PciSegmentLibWriteWorker ( + IN UINT64 Address, + IN PCI_CFG_WIDTH Width, + IN UINT32 Data + ) +{ + UINT8 Offset; + UINT32 WData; + UINT64 AlignedAddress; + BOOLEAN CheckRootPort; + + CheckRootPort =3D (GET_BUS_NUM (Address) =3D=3D 0) && + (GET_DEV_NUM (Address) =3D=3D 0) && + (GET_FUNC_NUM (Address) =3D=3D 0); + + // 8-bit and 16-bit writes to root port config space is not supported du= e to + // a hardware limitation. As a workaround, perform a read-update-write + // sequence on the whole 32-bit word of the root port config register su= ch + // that only the specified 8-bits of that word are updated. + + switch (Width) { + case PciCfgWidthUint8: + if (CheckRootPort =3D=3D TRUE) { + Offset =3D Address & 0x3; + AlignedAddress =3D Address & ~(0x3); + WData =3D MmioRead32 ((UINTN) GetPciExpressAddress (AlignedAddress)); + WData &=3D ~(0xFF << (8 * Offset)); + WData |=3D (Data << (8 * Offset)); + MmioWrite32 ((UINTN) GetPciExpressAddress (AlignedAddress), WData); + return Data; + } else { + MmioWrite8 ((UINTN) GetPciExpressAddress (Address), Data); + } + break; + case PciCfgWidthUint16: + if (CheckRootPort =3D=3D TRUE) { + Offset =3D Address & 0x3; + AlignedAddress =3D Address & ~(0x3); + WData =3D MmioRead32 ((UINTN) GetPciExpressAddress (AlignedAddress)); + WData &=3D ~(0xFFFF << (8 * Offset)); + WData |=3D (Data << (8 * Offset)); + MmioWrite32 ((UINTN) GetPciExpressAddress (AlignedAddress), WData); + return Data; + } else { + MmioWrite16 ((UINTN) GetPciExpressAddress (Address), Data); + } + break; + case PciCfgWidthUint32: + MmioWrite32 ((UINTN) GetPciExpressAddress (Address), Data); + break; + default: + ASSERT (0); + } + + return Data; +} + +/** + Reads an 8-bit PCI configuration register. + + Reads and returns the 8-bit PCI configuration register specified by Addr= ess. + This function must guarantee that all PCI read and write operations are + serialized. + + If any reserved bits in Address are set, then ASSERT(). + + @param Address The address that encodes the PCI Segment, Bus, + Device, Function and Register. + + @return The 8-bit PCI configuration register specified by the Address. +**/ +UINT8 +EFIAPI +PciSegmentRead8 ( + IN UINT64 Address + ) +{ + ASSERT_INVALID_PCI_SEGMENT_ADDRESS (Address, 0); + + return (UINT8) PciSegmentLibReadWorker (Address, PciCfgWidthUint8); +} + +/** + Writes an 8-bit PCI configuration register. + + Writes the 8-bit Value in the PCI configuration register specified by the + Address. This function must guarantee that all PCI read and write operat= ions + are serialized. + + If any reserved bits in Address are set, then ASSERT(). + + @param Address The address that encodes the PCI Segment, Bus, + Device, Function, and Register. + @param Value The value to write. + + @return The value written to the PCI configuration register. +**/ +UINT8 +EFIAPI +PciSegmentWrite8 ( + IN UINT64 Address, + IN UINT8 Value + ) +{ + ASSERT_INVALID_PCI_SEGMENT_ADDRESS (Address, 0); + + return (UINT8) PciSegmentLibWriteWorker (Address, PciCfgWidthUint8, Valu= e); +} + +/** + Performs a bitwise OR of an 8-bit PCI configuration register with + an 8-bit value. + + Reads the 8-bit PCI configuration register specified by Address, + performs a bitwise OR between the read result and the value specified by + OrData, and writes the result to the 8-bit PCI configuration register + specified by Address. + + The value written to the PCI configuration register is returned. + This function must guarantee that all PCI read and write operations + are serialized. + + If any reserved bits in Address are set, then ASSERT(). + + @param Address The address that encodes the PCI Segment, Bus, Device, + Function, and Register. + @param OrData The value to OR with the PCI configuration register. + + @return The value written to the PCI configuration register. +**/ +UINT8 +EFIAPI +PciSegmentOr8 ( + IN UINT64 Address, + IN UINT8 OrData + ) +{ + return PciSegmentWrite8 (Address, + (UINT8) (PciSegmentRead8 (Address) | OrData)); +} + +/** + Performs a bitwise AND of an 8-bit PCI configuration register with + an 8-bit value. + + Reads the 8-bit PCI configuration register specified by Address, + performs a bitwise AND between the read result and the value specified by + AndData, and writes the result to the 8-bit PCI configuration register + specified by Address. + + The value written to the PCI configuration register is returned. + This function must guarantee that all PCI read and write operations + are serialized. If any reserved bits in Address are set, then ASSERT(). + + @param Address The address that encodes the PCI Segment, Bus, Device, + Function, and Register. + @param AndData The value to AND with the PCI configuration register. + + @return The value written to the PCI configuration register. +**/ +UINT8 +EFIAPI +PciSegmentAnd8 ( + IN UINT64 Address, + IN UINT8 AndData + ) +{ + return PciSegmentWrite8 (Address, + (UINT8) (PciSegmentRead8 (Address) & AndData)); +} + +/** + Performs a bitwise AND of an 8-bit PCI configuration register with + an 8-bit value, followed by a bitwise OR with another 8-bit value. + + Reads the 8-bit PCI configuration register specified by Address, + performs a bitwise AND between the read result and the value specified + by AndData, performs a bitwise OR between the result of the AND operation + and the value specified by OrData, and writes the result to the 8-bit + PCI configuration register specified by Address. + + The value written to the PCI configuration register is returned. + This function must guarantee that all PCI read and write operations + are serialized. + + If any reserved bits in Address are set, then ASSERT(). + + @param Address The address that encodes the PCI Segment, Bus, Device, + Function, and Register. + @param AndData The value to AND with the PCI configuration register. + @param OrData The value to OR with the PCI configuration register. + + @return The value written to the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciSegmentAndThenOr8 ( + IN UINT64 Address, + IN UINT8 AndData, + IN UINT8 OrData + ) +{ + return PciSegmentWrite8 (Address, + (UINT8) ((PciSegmentRead8 (Address) & AndData) + | OrData)); +} + +/** + Reads a bit field of a PCI configuration register. + + Reads the bit field in an 8-bit PCI configuration register. The bit fiel= d is + specified by the StartBit and the EndBit. The value of the bit field is + returned. + + If any reserved bits in Address are set, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address The PCI configuration register to read. + @param StartBit The ordinal of the least significant bit in the bit fi= eld. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit fie= ld. + Range 0..7. + + @return The value of the bit field read from the PCI configuration regis= ter. + +**/ +UINT8 +EFIAPI +PciSegmentBitFieldRead8 ( + IN UINT64 Address, + IN UINTN StartBit, + IN UINTN EndBit + ) +{ + return BitFieldRead8 (PciSegmentRead8 (Address), StartBit, EndBit); +} + +/** + Writes a bit field to a PCI configuration register. + + Writes Value to the bit field of the PCI configuration register. The bit + field is specified by the StartBit and the EndBit. All other bits in the + destination PCI configuration register are preserved. The new value of t= he + 8-bit register is returned. + + If any reserved bits in Address are set, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + If Value is larger than the bitmask value range specified by StartBit + and EndBit, then ASSERT(). + + @param Address The PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit fi= eld. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit fie= ld. + Range 0..7. + @param Value The new value of the bit field. + + @return The value written back to the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciSegmentBitFieldWrite8 ( + IN UINT64 Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT8 Value + ) +{ + return PciSegmentWrite8 (Address, + BitFieldWrite8 (PciSegmentRead8 (Address), + StartBit, + EndBit, + Value)); +} + +/** + Reads a bit field in an 8-bit PCI configuration, performs a bitwise OR, = and + writes the result back to the bit field in the 8-bit port. + + Reads the 8-bit PCI configuration register specified by Address, perform= s a + bitwise OR between the read result and the value specified by + OrData, and writes the result to the 8-bit PCI configuration register + specified by Address. The value written to the PCI configuration registe= r is + returned. This function must guarantee that all PCI read and write opera= tions + are serialized. Extra left bits in OrData are stripped. + + If any reserved bits in Address are set, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + If OrData is larger than the bitmask value range specified by StartBit a= nd + EndBit, then ASSERT(). + + @param Address The PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit fi= eld. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit fie= ld. + Range 0..7. + @param OrData The value to OR with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciSegmentBitFieldOr8 ( + IN UINT64 Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT8 OrData + ) +{ + return PciSegmentWrite8 (Address, + BitFieldOr8 (PciSegmentRead8 (Address), + StartBit, + EndBit, + OrData)); +} + +/** + Reads a bit field in an 8-bit PCI configuration register, performs a bit= wise + AND, and writes the result back to the bit field in the 8-bit register. + + Reads the 8-bit PCI configuration register specified by Address, perform= s a + bitwise AND between the read result and the value specified by AndData, = and + writes the result to the 8-bit PCI configuration register specified by + Address. The value written to the PCI configuration register is returned. + This function must guarantee that all PCI read and write operations are + serialized. Extra left bits in AndData are stripped. + + If any reserved bits in Address are set, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + If AndData is larger than the bitmask value range specified by StartBit = and + EndBit, then ASSERT(). + + @param Address The PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit fi= eld. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit fie= ld. + Range 0..7. + @param AndData The value to AND with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciSegmentBitFieldAnd8 ( + IN UINT64 Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT8 AndData + ) +{ + return PciSegmentWrite8 (Address, + BitFieldAnd8 (PciSegmentRead8 (Address), + StartBit, + EndBit, + AndData)); +} + +/** + Reads a bit field in an 8-bit port, performs a bitwise AND followed by a + bitwise OR, and writes the result back to the bit field in the + 8-bit port. + + Reads the 8-bit PCI configuration register specified by Address, perform= s a + bitwise AND followed by a bitwise OR between the read result and + the value specified by AndData, and writes the result to the 8-bit PCI + configuration register specified by Address. The value written to the PCI + configuration register is returned. This function must guarantee that al= l PCI + read and write operations are serialized. Extra left bits in both AndDat= a and + OrData are stripped. + + If any reserved bits in Address are set, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + If AndData is larger than the bitmask value range specified by StartBit + and EndBit, then ASSERT(). + If OrData is larger than the bitmask value range specified by StartBit + and EndBit, then ASSERT(). + + @param Address The PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit fi= eld. + Range 0..7. + @param EndBit The ordinal of the most significant bit in the bit fie= ld. + Range 0..7. + @param AndData The value to AND with the PCI configuration register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the PCI configuration register. + +**/ +UINT8 +EFIAPI +PciSegmentBitFieldAndThenOr8 ( + IN UINT64 Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT8 AndData, + IN UINT8 OrData + ) +{ + return PciSegmentWrite8 (Address, + BitFieldAndThenOr8 (PciSegmentRead8 (Address), + StartBit, + EndBit, + AndData, + OrData)); +} + +/** + Reads a 16-bit PCI configuration register. + + Reads and returns the 16-bit PCI configuration register specified by Add= ress. + This function must guarantee that all PCI read and write operations + are serialized. + + If any reserved bits in Address are set, then ASSERT(). + If Address is not aligned on a 16-bit boundary, then ASSERT(). + + @param Address The address that encodes the PCI Segment, Bus, Device, + Function, and Register. + + @return The 16-bit PCI configuration register specified by Address. + +**/ +UINT16 +EFIAPI +PciSegmentRead16 ( + IN UINT64 Address + ) +{ + ASSERT_INVALID_PCI_SEGMENT_ADDRESS (Address, 1); + + return (UINT16) PciSegmentLibReadWorker (Address, PciCfgWidthUint16); +} + +/** + Writes a 16-bit PCI configuration register. + + Writes the 16-bit PCI configuration register specified by Address with t= he + value specified by Value. Value is returned. + This function must guarantee that all PCI read and write operations + are serialized. + + If any reserved bits in Address are set, then ASSERT(). + If Address is not aligned on a 16-bit boundary, then ASSERT(). + + @param Address The address that encodes the PCI Segment, Bus, Devic= e, + Function, and Register. + @param Value The value to write. + + @return The Value written is returned. + +**/ +UINT16 +EFIAPI +PciSegmentWrite16 ( + IN UINT64 Address, + IN UINT16 Value + ) +{ + ASSERT_INVALID_PCI_SEGMENT_ADDRESS (Address, 1); + + return (UINT16) PciSegmentLibWriteWorker (Address, PciCfgWidthUint16, Va= lue); +} + +/** + Performs a bitwise OR of a 16-bit PCI configuration register with + a 16-bit value. + + Reads the 16-bit PCI configuration register specified by Address, perfor= ms a + bitwise OR between the read result and the value specified by + OrData, and writes the result to the 16-bit PCI configuration register + specified by Address. The value written to the PCI configuration registe= r is + returned. This function must guarantee that all PCI read and write opera= tions + are serialized. + + If any reserved bits in Address are set, then ASSERT(). + If Address is not aligned on a 16-bit boundary, then ASSERT(). + + @param Address The address that encodes the PCI Segment, Bus, Device, + Function and Register. + @param OrData The value to OR with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciSegmentOr16 ( + IN UINT64 Address, + IN UINT16 OrData + ) +{ + return PciSegmentWrite16 (Address, + (UINT16) (PciSegmentRead16 (Address) | OrData)= ); +} + +/** + Performs a bitwise AND of a 16-bit PCI configuration register with + a 16-bit value. + + Reads the 16-bit PCI configuration register specified by Address, + performs a bitwise AND between the read result and the value specified + by AndData, and writes the result to the 16-bit PCI configuration regist= er + specified by the Address. + + The value written to the PCI configuration register is returned. + This function must guarantee that all PCI read and write operations + are serialized. + + If any reserved bits in Address are set, then ASSERT(). + If Address is not aligned on a 16-bit boundary, then ASSERT(). + + @param Address The address that encodes the PCI Segment, Bus, Device, + Function, and Register. + @param AndData The value to AND with the PCI configuration register. + + @return The value written to the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciSegmentAnd16 ( + IN UINT64 Address, + IN UINT16 AndData + ) +{ + return PciSegmentWrite16 (Address, + (UINT16) (PciSegmentRead16 (Address) & AndData= )); +} + +/** + Performs a bitwise AND of a 16-bit PCI configuration register with a 16-= bit + value, followed a bitwise OR with another 16-bit value. + + Reads the 16-bit PCI configuration register specified by Address, + performs a bitwise AND between the read result and the value specified by + AndData, performs a bitwise OR between the result of the AND operation a= nd + the value specified by OrData, and writes the result to the 16-bit PCI + configuration register specified by the Address. + + The value written to the PCI configuration register is returned. + This function must guarantee that all PCI read and write operations + are serialized. + + If any reserved bits in Address are set, then ASSERT(). + If Address is not aligned on a 16-bit boundary, then ASSERT(). + + @param Address The address that encodes the PCI Segment, Bus, Device, + Function, and Register. + @param AndData The value to AND with the PCI configuration register. + @param OrData The value to OR with the PCI configuration register. + + @return The value written to the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciSegmentAndThenOr16 ( + IN UINT64 Address, + IN UINT16 AndData, + IN UINT16 OrData + ) +{ + return PciSegmentWrite16 (Address, + (UINT16) ((PciSegmentRead16 (Address) & AndDat= a) + | OrData)); +} + +/** + Reads a bit field of a PCI configuration register. + + Reads the bit field in a 16-bit PCI configuration register. The bit fiel= d is + specified by the StartBit and the EndBit. The value of the bit field is + returned. + + If any reserved bits in Address are set, then ASSERT(). + If Address is not aligned on a 16-bit boundary, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address The PCI configuration register to read. + @param StartBit The ordinal of the least significant bit in the bit fi= eld. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit fie= ld. + Range 0..15. + + @return The value of the bit field read from the PCI configuration regis= ter. + +**/ +UINT16 +EFIAPI +PciSegmentBitFieldRead16 ( + IN UINT64 Address, + IN UINTN StartBit, + IN UINTN EndBit + ) +{ + return BitFieldRead16 (PciSegmentRead16 (Address), StartBit, EndBit); +} + +/** + Writes a bit field to a PCI configuration register. + + Writes Value to the bit field of the PCI configuration register. The bit + field is specified by the StartBit and the EndBit. All other bits in the + destination PCI configuration register are preserved. The new value of t= he + 16-bit register is returned. + + If any reserved bits in Address are set, then ASSERT(). + If Address is not aligned on a 16-bit boundary, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + If Value is larger than the bitmask value range specified by StartBit and + EndBit, then ASSERT(). + + @param Address The PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit fi= eld. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit fie= ld. + Range 0..15. + @param Value The new value of the bit field. + + @return The value written back to the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciSegmentBitFieldWrite16 ( + IN UINT64 Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT16 Value + ) +{ + return PciSegmentWrite16 (Address, + BitFieldWrite16 (PciSegmentRead16 (Address), + StartBit, + EndBit, + Value)); +} + +/** + Reads the 16-bit PCI configuration register specified by Address, + performs a bitwise OR between the read result and the value specified + by OrData, and writes the result to the 16-bit PCI configuration register + specified by the Address. + + If any reserved bits in Address are set, then ASSERT(). + If Address is not aligned on a 16-bit boundary, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + If OrData is larger than the bitmask value range specified by StartBit a= nd + EndBit, then ASSERT(). + + @param Address The PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit fi= eld. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit fie= ld. + Range 0..15. + @param OrData The value to OR with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciSegmentBitFieldOr16 ( + IN UINT64 Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT16 OrData + ) +{ + return PciSegmentWrite16 (Address, + BitFieldOr16 (PciSegmentRead16 (Address), + StartBit, + EndBit, + OrData)); +} + +/** + Reads a bit field in a 16-bit PCI configuration, performs a bitwise OR, + and writes the result back to the bit field in the 16-bit port. + + Reads the 16-bit PCI configuration register specified by Address, + performs a bitwise OR between the read result and the value specified by + OrData, and writes the result to the 16-bit PCI configuration register + specified by the Address. + + The value written to the PCI configuration register is returned. + This function must guarantee that all PCI read and write operations are + serialized. Extra left bits in OrData are stripped. + + If any reserved bits in Address are set, then ASSERT(). + If Address is not aligned on a 16-bit boundary, then ASSERT(). + If StartBit is greater than 7, then ASSERT(). + If EndBit is greater than 7, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + If AndData is larger than the bitmask value range specified by StartBit = and + EndBit, then ASSERT(). + + @param Address The address that encodes the PCI Segment, Bus, Device, + Function, and Register. + @param StartBit The ordinal of the least significant bit in the bit fi= eld. + The ordinal of the least significant bit in a byte is + bit 0. + @param EndBit The ordinal of the most significant bit in the bit fie= ld. + The ordinal of the most significant bit in a byte is b= it 7. + @param AndData The value to AND with the read value from the PCI + configuration register. + + @return The value written to the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciSegmentBitFieldAnd16 ( + IN UINT64 Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT16 AndData + ) +{ + return PciSegmentWrite16 (Address, + BitFieldAnd16 (PciSegmentRead16 (Address), + StartBit, + EndBit, + AndData)); +} + +/** + Reads a bit field in a 16-bit port, performs a bitwise AND followed by a + bitwise OR, and writes the result back to the bit field in the + 16-bit port. + + Reads the 16-bit PCI configuration register specified by Address, perfor= ms a + bitwise AND followed by a bitwise OR between the read result and + the value specified by AndData, and writes the result to the 16-bit PCI + configuration register specified by Address. The value written to the PCI + configuration register is returned. This function must guarantee that al= l PCI + read and write operations are serialized. Extra left bits in both AndDat= a and + OrData are stripped. + + If any reserved bits in Address are set, then ASSERT(). + If StartBit is greater than 15, then ASSERT(). + If EndBit is greater than 15, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + If AndData is larger than the bitmask value range specified by StartBit = and + EndBit, then ASSERT(). + If OrData is larger than the bitmask value range specified by StartBit a= nd + EndBit, then ASSERT(). + + @param Address The PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit fi= eld. + Range 0..15. + @param EndBit The ordinal of the most significant bit in the bit fie= ld. + Range 0..15. + @param AndData The value to AND with the PCI configuration register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the PCI configuration register. + +**/ +UINT16 +EFIAPI +PciSegmentBitFieldAndThenOr16 ( + IN UINT64 Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT16 AndData, + IN UINT16 OrData + ) +{ + return PciSegmentWrite16 (Address, + BitFieldAndThenOr16 (PciSegmentRead16 (Address= ), + StartBit, + EndBit, + AndData, + OrData)); +} + +/** + Reads a 32-bit PCI configuration register. + + Reads and returns the 32-bit PCI configuration register specified by Add= ress. + This function must guarantee that all PCI read and write operations + are serialized. + + If any reserved bits in Address are set, then ASSERT(). + If Address is not aligned on a 32-bit boundary, then ASSERT(). + + @param Address The address that encodes the PCI Segment, Bus, + Device, Function and Register. + + @return The 32-bit PCI configuration register specified by Address. + +**/ +UINT32 +EFIAPI +PciSegmentRead32 ( + IN UINT64 Address + ) +{ + ASSERT_INVALID_PCI_SEGMENT_ADDRESS (Address, 3); + + return PciSegmentLibReadWorker (Address, PciCfgWidthUint32); +} + +/** + Writes a 32-bit PCI configuration register. + + Writes the 32-bit PCI configuration register specified by Address with t= he + value specified by Value. Value is returned. This function must guarant= ee + that all PCI read and write operations are serialized. + + If any reserved bits in Address are set, then ASSERT(). + If Address is not aligned on a 32-bit boundary, then ASSERT(). + + @param Address The address that encodes the PCI Segment, Bus, Devic= e, + Function, and Register. + @param Value The value to write. + + @return The parameter of Value. + +**/ +UINT32 +EFIAPI +PciSegmentWrite32 ( + IN UINT64 Address, + IN UINT32 Value + ) +{ + ASSERT_INVALID_PCI_SEGMENT_ADDRESS (Address, 3); + + return PciSegmentLibWriteWorker (Address, PciCfgWidthUint32, Value); +} + +/** + Performs a bitwise OR of a 32-bit PCI configuration register with a + 32-bit value. + + Reads the 32-bit PCI configuration register specified by Address, + performs a bitwise OR between the read result and the value specified + by OrData, and writes the result to the 32-bit PCI configuration register + specified by Address. + + The value written to the PCI configuration register is returned. + This function must guarantee that all PCI read and write operations + are serialized. + + If any reserved bits in Address are set, then ASSERT(). + If Address is not aligned on a 32-bit boundary, then ASSERT(). + + @param Address The address that encodes the PCI Segment, Bus, Device, + Function, and Register. + @param OrData The value to OR with the PCI configuration register. + + @return The value written to the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciSegmentOr32 ( + IN UINT64 Address, + IN UINT32 OrData + ) +{ + return PciSegmentWrite32 (Address, PciSegmentRead32 (Address) | OrData); +} + +/** + Performs a bitwise AND of a 32-bit PCI configuration register with + a 32-bit value. + + Reads the 32-bit PCI configuration register specified by Address, + performs a bitwise AND between the read result and the value specified + by AndData, and writes the result to the 32-bit PCI configuration regist= er + specified by Address. + The value written to the PCI configuration register is returned. + This function must guarantee that all PCI read and write operations + are serialized. + + If any reserved bits in Address are set, then ASSERT(). + If Address is not aligned on a 32-bit boundary, then ASSERT(). + + @param Address The address that encodes the PCI Segment, Bus, + Device, Function and Register. + @param AndData The value to AND with the PCI configuration register. + + @return The value written to the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciSegmentAnd32 ( + IN UINT64 Address, + IN UINT32 AndData + ) +{ + return PciSegmentWrite32 (Address, PciSegmentRead32 (Address) & AndData); +} + +/** + Performs a bitwise AND of a 32-bit PCI configuration register with + a 32-bit value, followed by a bitwise OR with another 32-bit value. + + Reads the 32-bit PCI configuration register specified by Address, + performs a bitwise AND between the read result and the value specified + by AndData, performs a bitwise OR between the result of the AND operation + and the value specified by OrData, and writes the result to the 32-bit + PCI configuration register specified by Address. + + The value written to the PCI configuration register is returned. + This function must guarantee that all PCI read and write operations + are serialized. + + If any reserved bits in Address are set, then ASSERT(). + If Address is not aligned on a 32-bit boundary, then ASSERT(). + + @param Address The address that encodes the PCI Segment, Bus, Device, + Function and Register. + @param AndData The value to AND with the PCI configuration register. + @param OrData The value to OR with the PCI configuration register. + + @return The value written to the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciSegmentAndThenOr32 ( + IN UINT64 Address, + IN UINT32 AndData, + IN UINT32 OrData + ) +{ + return PciSegmentWrite32 (Address, + (PciSegmentRead32 (Address) & AndData) | OrDat= a); +} + +/** + Reads a bit field of a PCI configuration register. + + Reads the bit field in a 32-bit PCI configuration register. The bit fiel= d is + specified by the StartBit and the EndBit. The value of the bit field is + returned. + + If any reserved bits in Address are set, then ASSERT(). + If Address is not aligned on a 32-bit boundary, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + + @param Address The PCI configuration register to read. + @param StartBit The ordinal of the least significant bit in the bit fi= eld. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit fie= ld. + Range 0..31. + + @return The value of the bit field read from the PCI configuration regis= ter. + +**/ +UINT32 +EFIAPI +PciSegmentBitFieldRead32 ( + IN UINT64 Address, + IN UINTN StartBit, + IN UINTN EndBit + ) +{ + return BitFieldRead32 (PciSegmentRead32 (Address), StartBit, EndBit); +} + +/** + Writes a bit field to a PCI configuration register. + + Writes Value to the bit field of the PCI configuration register. The bit + field is specified by the StartBit and the EndBit. All other bits in the + destination PCI configuration register are preserved. The new value of t= he + 32-bit register is returned. + + If any reserved bits in Address are set, then ASSERT(). + If Address is not aligned on a 32-bit boundary, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + If Value is larger than the bitmask value range specified by StartBit + and EndBit, then ASSERT(). + + @param Address The PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit fi= eld. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit fie= ld. + Range 0..31. + @param Value The new value of the bit field. + + @return The value written back to the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciSegmentBitFieldWrite32 ( + IN UINT64 Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 Value + ) +{ + return PciSegmentWrite32 (Address, + BitFieldWrite32 (PciSegmentRead32 (Address), + StartBit, + EndBit, + Value)); +} + +/** + Reads a bit field in a 32-bit PCI configuration, performs a bitwise OR, = and + writes the result back to the bit field in the 32-bit port. + + Reads the 32-bit PCI configuration register specified by Address, perfor= ms a + bitwise OR between the read result and the value specified by + OrData, and writes the result to the 32-bit PCI configuration register + specified by Address. The value written to the PCI configuration registe= r is + returned. This function must guarantee that all PCI read and write opera= tions + are serialized. Extra left bits in OrData are stripped. + + If any reserved bits in Address are set, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + If OrData is larger than the bitmask value range specified by StartBit a= nd + EndBit, then ASSERT(). + + @param Address The PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit fi= eld. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit fie= ld. + Range 0..31. + @param OrData The value to OR with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciSegmentBitFieldOr32 ( + IN UINT64 Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 OrData + ) +{ + return PciSegmentWrite32 (Address, + BitFieldOr32 (PciSegmentRead32 (Address), + StartBit, + EndBit, + OrData)); +} + +/** + Reads a bit field in a 32-bit PCI configuration register, performs a bit= wise + AND, and writes the result back to the bit field in the 32-bit register. + + Reads the 32-bit PCI configuration register specified by Address, + performs a bitwise AND between the read result and the value specified + by AndData, and writes the result to the 32-bit PCI configuration regist= er + specified by Address. The value written to the PCI configuration register + is returned. This function must guarantee that all PCI read and write + operations are serialized. Extra left bits in AndData are stripped. + + If any reserved bits in Address are set, then ASSERT(). + If Address is not aligned on a 32-bit boundary, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + If AndData is larger than the bitmask value range specified by StartBit = and + EndBit, then ASSERT(). + + @param Address The PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit fi= eld. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit fie= ld. + Range 0..31. + @param AndData The value to AND with the PCI configuration register. + + @return The value written back to the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciSegmentBitFieldAnd32 ( + IN UINT64 Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 AndData + ) +{ + return PciSegmentWrite32 (Address, + BitFieldAnd32 (PciSegmentRead32 (Address), + StartBit, + EndBit, + AndData)); +} + +/** + Reads a bit field in a 32-bit port, performs a bitwise AND followed by a + bitwise OR, and writes the result back to the bit field in the + 32-bit port. + + Reads the 32-bit PCI configuration register specified by Address, perfor= ms a + bitwise AND followed by a bitwise OR between the read result and + the value specified by AndData, and writes the result to the 32-bit PCI + configuration register specified by Address. The value written to the PCI + configuration register is returned. This function must guarantee that al= l PCI + read and write operations are serialized. Extra left bits in both AndDat= a and + OrData are stripped. + + If any reserved bits in Address are set, then ASSERT(). + If StartBit is greater than 31, then ASSERT(). + If EndBit is greater than 31, then ASSERT(). + If EndBit is less than StartBit, then ASSERT(). + If AndData is larger than the bitmask value range specified by StartBit + and EndBit, then ASSERT(). + If OrData is larger than the bitmask value range specified by StartBit + and EndBit, then ASSERT(). + + @param Address The PCI configuration register to write. + @param StartBit The ordinal of the least significant bit in the bit fi= eld. + Range 0..31. + @param EndBit The ordinal of the most significant bit in the bit fie= ld. + Range 0..31. + @param AndData The value to AND with the PCI configuration register. + @param OrData The value to OR with the result of the AND operation. + + @return The value written back to the PCI configuration register. + +**/ +UINT32 +EFIAPI +PciSegmentBitFieldAndThenOr32 ( + IN UINT64 Address, + IN UINTN StartBit, + IN UINTN EndBit, + IN UINT32 AndData, + IN UINT32 OrData + ) +{ + return PciSegmentWrite32 ( + Address, + BitFieldAndThenOr32 (PciSegmentRead32 (Address), + StartBit, + EndBit, + AndData, + OrData)); +} + +/** + Reads a range of PCI configuration registers into a caller supplied buff= er. + + Reads the range of PCI configuration registers specified by StartAddress= and + Size into the buffer specified by Buffer. This function only allows the = PCI + configuration registers from a single PCI function to be read. Size is + returned. When possible 32-bit PCI configuration read cycles are used to= read + from StartAdress to StartAddress + Size. Due to alignment restrictions, = 8-bit + and 16-bit PCI configuration read cycles may be used at the beginning an= d the + end of the range. + + If any reserved bits in StartAddress are set, then ASSERT(). + If ((StartAddress & 0xFFF) + Size) > 0x1000, then ASSERT(). + If Size > 0 and Buffer is NULL, then ASSERT(). + + @param StartAddress The starting address that encodes the PCI Segment,= Bus, + Device, Function and Register. + @param Size The size in bytes of the transfer. + @param Buffer The pointer to a buffer receiving the data read. + + @return Size + +**/ +UINTN +EFIAPI +PciSegmentReadBuffer ( + IN UINT64 StartAddress, + IN UINTN Size, + OUT VOID *Buffer + ) +{ + UINTN ReturnValue; + + ASSERT_INVALID_PCI_SEGMENT_ADDRESS (StartAddress, 0); + + if (((StartAddress & 0xFFF) + Size) > 0x1000) { + ASSERT (0); + return 0; + } + + if (Size =3D=3D 0) { + return Size; + } + + if (Buffer =3D=3D NULL) { + ASSERT (0); + return 0; + } + + // Save Size for return + ReturnValue =3D Size; + + if ((StartAddress & BIT0) !=3D 0) { + // Read a byte if StartAddress is byte aligned + *(volatile UINT8 *)Buffer =3D PciSegmentRead8 (StartAddress); + StartAddress +=3D sizeof (UINT8); + Size -=3D sizeof (UINT8); + Buffer =3D (UINT8*)Buffer + 1; + } + + if (Size >=3D sizeof (UINT16) && (StartAddress & BIT1) !=3D 0) { + // Read a word if StartAddress is word aligned + WriteUnaligned16 (Buffer, PciSegmentRead16 (StartAddress)); + StartAddress +=3D sizeof (UINT16); + Size -=3D sizeof (UINT16); + Buffer =3D (UINT16*)Buffer + 1; + } + + while (Size >=3D sizeof (UINT32)) { + // Read as many double words as possible + WriteUnaligned32 (Buffer, PciSegmentRead32 (StartAddress)); + StartAddress +=3D sizeof (UINT32); + Size -=3D sizeof (UINT32); + Buffer =3D (UINT32*)Buffer + 1; + } + + if (Size >=3D sizeof (UINT16)) { + // Read the last remaining word if exist + WriteUnaligned16 (Buffer, PciSegmentRead16 (StartAddress)); + StartAddress +=3D sizeof (UINT16); + Size -=3D sizeof (UINT16); + Buffer =3D (UINT16*)Buffer + 1; + } + + if (Size >=3D sizeof (UINT8)) { + // Read the last remaining byte if exist + *(volatile UINT8 *)Buffer =3D PciSegmentRead8 (StartAddress); + } + + return ReturnValue; +} + +/** + Copies the data in a caller supplied buffer to a specified range of PCI + configuration space. + + Writes the range of PCI configuration registers specified by StartAddres= s and + Size from the buffer specified by Buffer. This function only allows the = PCI + configuration registers from a single PCI function to be written. Size is + returned. When possible 32-bit PCI configuration write cycles are used to + write from StartAdress to StartAddress + Size. Due to alignment restrict= ions, + 8-bit and 16-bit PCI configuration write cycles may be used at the begin= ning + and the end of the range. + + If any reserved bits in StartAddress are set, then ASSERT(). + If ((StartAddress & 0xFFF) + Size) > 0x1000, then ASSERT(). + If Size > 0 and Buffer is NULL, then ASSERT(). + + @param StartAddress The starting address that encodes the PCI Segment,= Bus, + Device, Function and Register. + @param Size The size in bytes of the transfer. + @param Buffer The pointer to a buffer containing the data to wri= te. + + @return The parameter of Size. + +**/ +UINTN +EFIAPI +PciSegmentWriteBuffer ( + IN UINT64 StartAddress, + IN UINTN Size, + IN VOID *Buffer + ) +{ + UINTN ReturnValue; + + ASSERT_INVALID_PCI_SEGMENT_ADDRESS (StartAddress, 0); + + if (((StartAddress & 0xFFF) + Size) > 0x1000) { + ASSERT (0); + return 0; + } + + if (Size =3D=3D 0) { + return Size; + } + + if (Buffer =3D=3D NULL) { + ASSERT (0); + return 0; + } + + // Save Size for return + ReturnValue =3D Size; + + if ((StartAddress & BIT0) !=3D 0) { + // Write a byte if StartAddress is byte aligned + PciSegmentWrite8 (StartAddress, *(UINT8*)Buffer); + StartAddress +=3D sizeof (UINT8); + Size -=3D sizeof (UINT8); + Buffer =3D (UINT8*)Buffer + 1; + } + + if (Size >=3D sizeof (UINT16) && (StartAddress & BIT1) !=3D 0) { + // Write a word if StartAddress is word aligned + PciSegmentWrite16 (StartAddress, ReadUnaligned16 (Buffer)); + StartAddress +=3D sizeof (UINT16); + Size -=3D sizeof (UINT16); + Buffer =3D (UINT16*)Buffer + 1; + } + + while (Size >=3D sizeof (UINT32)) { + // Write as many double words as possible + PciSegmentWrite32 (StartAddress, ReadUnaligned32 (Buffer)); + StartAddress +=3D sizeof (UINT32); + Size -=3D sizeof (UINT32); + Buffer =3D (UINT32*)Buffer + 1; + } + + if (Size >=3D sizeof (UINT16)) { + // Write the last remaining word if exist + PciSegmentWrite16 (StartAddress, ReadUnaligned16 (Buffer)); + StartAddress +=3D sizeof (UINT16); + Size -=3D sizeof (UINT16); + Buffer =3D (UINT16*)Buffer + 1; + } + + if (Size >=3D sizeof (UINT8)) { + // Write the last remaining byte if exist + PciSegmentWrite8 (StartAddress, *(UINT8*)Buffer); + } + + return ReturnValue; +} diff --git a/Silicon/ARM/NeoverseN1Soc/Library/PciSegmentLib/PciSegmentLib.= inf b/Silicon/ARM/NeoverseN1Soc/Library/PciSegmentLib/PciSegmentLib.inf new file mode 100644 index 0000000000..d67a19a1ab --- /dev/null +++ b/Silicon/ARM/NeoverseN1Soc/Library/PciSegmentLib/PciSegmentLib.inf @@ -0,0 +1,38 @@ +## @file +# PCI Segment Library for N1Sdp SoC with multiple RCs +# +# Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.
+# Copyright (c) 2022, ARM Limited. All rights reserved.
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + INF_VERSION =3D 0x0001001B + BASE_NAME =3D PciSegmentLib + FILE_GUID =3D b5ecc9c3-6b30-4f72-8a06-889b4ea8427e + MODULE_TYPE =3D BASE + VERSION_STRING =3D 1.0 + LIBRARY_CLASS =3D PciSegmentLib + +[Sources] + PciSegmentLib.c + +[Packages] + MdePkg/MdePkg.dec + Platform/ARM/N1Sdp/N1SdpPlatform.dec + Silicon/ARM/NeoverseN1Soc/NeoverseN1Soc.dec + +[LibraryClasses] + BaseLib + DebugLib + IoLib + +[FixedPcd] + gArmNeoverseN1SocTokenSpaceGuid.PcdCcixExpressBaseAddress + gArmNeoverseN1SocTokenSpaceGuid.PcdPcieExpressBaseAddress + gArmNeoverseN1SocTokenSpaceGuid.PcdCcixRootPortConfigBaseAddress + gArmNeoverseN1SocTokenSpaceGuid.PcdCcixRootPortConfigBaseSize + gArmNeoverseN1SocTokenSpaceGuid.PcdPcieRootPortConfigBaseAddress + gArmNeoverseN1SocTokenSpaceGuid.PcdPcieRootPortConfigBaseSize --=20 2.17.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 (#85966): https://edk2.groups.io/g/devel/message/85966 Mute This Topic: https://groups.io/mt/88606290/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- From nobody Tue Apr 30 02:02:46 2024 Delivered-To: importer@patchew.org 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+85967+1787277+3901457@groups.io; arc=fail (BodyHash is different from the expected one); dmarc=fail(p=none dis=none) header.from=arm.com Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1642865255452949.3135967190548; Sat, 22 Jan 2022 07:27:35 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id 7XsIYY1788612xA3AMred5Vs; Sat, 22 Jan 2022 07:27:35 -0800 X-Received: from EUR03-AM5-obe.outbound.protection.outlook.com (EUR03-AM5-obe.outbound.protection.outlook.com [40.107.3.48]) by mx.groups.io with SMTP id smtpd.web11.9519.1642865253593956214 for ; Sat, 22 Jan 2022 07:27:34 -0800 X-Received: from AM6PR10CA0070.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:209:80::47) by DBBPR08MB6281.eurprd08.prod.outlook.com (2603:10a6:10:1f6::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4909.11; Sat, 22 Jan 2022 15:27:30 +0000 X-Received: from VE1EUR03FT011.eop-EUR03.prod.protection.outlook.com (2603:10a6:209:80:cafe::ee) by AM6PR10CA0070.outlook.office365.com (2603:10a6:209:80::47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4909.10 via Frontend Transport; Sat, 22 Jan 2022 15:27:30 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dmarc=pass action=none header.from=arm.com; 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+85967+1787277+3901457@groups.io; helo=mail02.groups.io; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; X-Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by VE1EUR03FT011.mail.protection.outlook.com (10.152.18.134) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4909.7 via Frontend Transport; Sat, 22 Jan 2022 15:27:29 +0000 X-Received: ("Tessian outbound 63bb5eb69ee8:v113"); Sat, 22 Jan 2022 15:27:29 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 1b0a9b2c0da57f38 X-CR-MTA-TID: 64aa7808 X-Received: from 42c954c9feb7.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 06E67E6E-CCBD-4838-B114-92198F989F33.1; Sat, 22 Jan 2022 15:27:19 +0000 X-Received: from EUR02-AM5-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 42c954c9feb7.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Sat, 22 Jan 2022 15:27:19 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=G+HYCSLXroVCBc+8PljHoJeVOOZ6ExafZvPSz8f/Es4Xewp5iuw0qXxW82mNu0YXgskOe6/gx4fzw94rbAkxAb1UyQOzI0mBb5knZxJ9s5VXSxSf+lEH2liZ3dlslKXiyHqCWeQsKdg+9M65oItlU9STGS/iDXHfqAU0bfK6QYsA5Ei4jKZh1Qdwzj57178h1KeaPyVRWfTOx6He+Gnrq5wPtoVsopAgP3/ZGh6eF3WSH1ZIJXhcyRIrkxwbitXrwQQFlW7wJstAnpb+45H6xvkkfG+yof2wYUS7QCbi0qvaT1JKeEfT9D1hWAhZ2bxmyDtHjU9/6hXqfYY6Coi+ug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=k6YSD2mpm+JOvvUSiKBaHnOFuTZtgwatWMtPeMcvFQM=; b=Vacie04d3I2oDfhzE5Bnkpv2BWs4vS8TQ6Tc8RSpH3lT2UNRPyJZLNMhZSaU8VQALAMZ0m8BTtTwXCuBDLLHTIzR+TV6GbQ24yp/GfpSRcU3Pt8v5x8qHSUFJwRVGxrXHvvMeCBa9RuIKXa0PpRbUXn7h/Ojn3kdMY6RwQrRqRHv6buNyFPx+6nkqHeAKSgHcuQRDf1i+RD5OaosHcxMg5niiCJcxOA0KnzND8cb3b9e625XcJCoOXyinrO5vyQjEpDov7vkpV4jJU5pfaWqEWA3lHtq2hex0wmA00lqyKJ7kcvp5Yc2tlduJdCjvpOFHipIkT1wZImi/GLN6HDR+w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; X-Received: from PA4PR08MB5902.eurprd08.prod.outlook.com (2603:10a6:102:e0::10) by AM0PR08MB4579.eurprd08.prod.outlook.com (2603:10a6:208:108::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4909.12; Sat, 22 Jan 2022 15:27:16 +0000 X-Received: from PA4PR08MB5902.eurprd08.prod.outlook.com ([fe80::edb5:a2ea:773e:cb8]) by PA4PR08MB5902.eurprd08.prod.outlook.com ([fe80::edb5:a2ea:773e:cb8%7]) with mapi id 15.20.4909.014; Sat, 22 Jan 2022 15:27:16 +0000 From: "Khasim Mohammed" To: devel@edk2.groups.io Cc: nd@arm.com, sami.mujawar@arm.com, pierre.gondois@arm.com, Khasim Syed Mohammed Subject: [edk2-devel] [PATCH v6 2/4] Silicon/ARM/NeoverseN1Soc: Update PCDs to support multiple PCI root ports Date: Sat, 22 Jan 2022 20:56:13 +0530 Message-Id: <20220122152615.17366-3-khasim.mohammed@arm.com> In-Reply-To: <20220122152615.17366-1-khasim.mohammed@arm.com> References: <20220122152615.17366-1-khasim.mohammed@arm.com> X-ClientProxiedBy: PN0PR01CA0017.INDPRD01.PROD.OUTLOOK.COM (2603:1096:c01:4f::22) To PA4PR08MB5902.eurprd08.prod.outlook.com (2603:10a6:102:e0::10) MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: 15917051-4e3d-4352-a56d-08d9ddbbb40c X-MS-TrafficTypeDiagnostic: AM0PR08MB4579:EE_|VE1EUR03FT011:EE_|DBBPR08MB6281:EE_ X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:6430;OLM:6430; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: VxrorWS7SMMAPTLkntOO2T992FtRO2SAVOP7hLozNMikeKD2Ku+xiwZKga/JuJMu/X9Y9D05nNeVHxlpm+IDW56LtXUXvTbS7H84SGo7R+jIvn6H90f18Eyl9vK/NbZ/VoiprJSZqcJUut6YXmmnt/LnDmg+07D40JbDtmVtSEkxGHeLxgHtomyXfvGyhkC1a6KbTXu8EPrRsR5sfTwBrEUZTaM1HhTpYK96VksdBLK/y6IPifzK5xB+gyKjEdwhB1Ra5vpDbHDmditO3AkMNmpuELCuF7t2itmw5LXfbQjye0g5iwIQu7o4+hjPdeAsbF0spefSO+s4710BXhoHx3MephQ1zNc8x8PCyjAyBpGSO8Os3RNOcKFq+Yk+b/1G1SXesuENbKqbqruLpfa4RHTqvwtF0/72268bXCD+0K2ZkcYS/TnxIZWMnBpACPR88brvVV647Q9d9xkukQ/z1pzbdEGSoAdA9L3GcNrDK14MqXUUkV4gHXh43nA8LBOXOGfLPIPK7C26o8hm8uMkiyvZR4eU5NGKZQaliXK3aR0elgHaGExPgFcg0glgZ9kG/qC+1oYx2JWkgP/6NJiwPNA2+RVUOJ5ZaqFt+x4jm9S8z1bGaGHNo/DNXdiUQ/o8oW90paFbPGsVdTdEqTFNcj0WTAZlLVsp5A/G+hJ6TZGBD608JWpZ/Q+toj+uj8urfTEMuvicuxc9clp6CWphug== X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PA4PR08MB5902.eurprd08.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(6506007)(186003)(36756003)(83380400001)(6666004)(8676002)(4326008)(5660300002)(6486002)(6916009)(316002)(6512007)(15650500001)(26005)(19627235002)(30864003)(508600001)(52116002)(2906002)(8936002)(66476007)(38350700002)(38100700002)(66556008)(1076003)(2616005)(66946007)(86362001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB4579 Original-Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: VE1EUR03FT011.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 7d0c27ab-3794-4c2b-d3d4-08d9ddbbac01 X-Microsoft-Antispam-Message-Info: iuFsZHAfZ4rUapGCfhHUf7vmJQRQgo9jepK1UlYCHD0YsouK+b5C3wL4BUst6nD5GnPANyiFWxQrsJT9X8VL3QE24+qKPaEE1OfOsnQyiF3YDYhDSeuGdIEpfQe3zkK6v18m5VU92GHaHuE/Mtaxx/KbPVddGAQb6kqar7QyapRZfbahkXeKy4OTXekZXscpL7cCiP6XN3VkW8KhL1IzWZd2B/V9GUeWfS91PHugsDZqyAawMt5rRYYMJ1o0ymxHJon1qarK+jfZBlUafbMZMWf9k3FlY48KQNu0pjwPXED7K2leiGhdDoMKeI2DmXebyJmSL4J83fe0yCVWQxJeT1YXgfqDLeeTuJEwOgNAmnnMCWphaODeDLhzRcvzysfSks7PyP9/oig1m+LsovU0xOiNeY3bEySkVusWnAxCzdB8JdJrw6EfNRGlVF/wyx77MsHBnEQ+iCtVsMuOOXwYtBbAV9lTCPFM+Y92ETR33C7CI1l/P3MtQEyn+0qghpj8+XUqgTd+Ckx+ll1oihb+ZymiAsU5KxSgmeoqm11sqPE8Hpbbsc2oFYir1KeTaT5pTwUXrrPiukNKRoL596s9kmpwmlLkR6KmzmWFQCnZo7ew5O4IzTd1xRZH+BeNzldMfL5J+Mx01gBaGl2gGlP4oUzhSDQMs99F9/GZ2AUDg8CyO/1JwSdWwut0j/D61/RjudoGmzKzsHO3oQl28tvTef1RJ10+27laXZ+cS+4M8eCZMUsIvApWMxhMT0MPrBdqY3bFqiONKexfUdZdILjO6Q== X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jan 2022 15:27:29.7423 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 15917051-4e3d-4352-a56d-08d9ddbbb40c X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d;Ip=[63.35.35.123];Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: VE1EUR03FT011.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR08MB6281 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,khasim.mohammed@arm.com X-Gm-Message-State: e4MqGx2MJ1OFXGIQs4B8iunkx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1642865255; bh=E0XvOeD79X3e5a6gCtpuixx+/SWlFf1KbsZcT6FwRhU=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=tbj9TkvexiAud6XWFcS8rF46BxJ0NuJvUObJlqF4kQfRVGSXnGVwGuXmHaPDuE4Gzt8 rfIp88iFB2XS4T06429R6dLYvbphOk11JPYBlLAUkNGRvplH27sXYKItmkYFf+OFvVAYd 5dJnwukneKLOa7Z3G9llvYgUhdsML9A3RG8= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1642865256701100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" PCD entries are updated to remove the hardcoded assignments and to add support for multiple PCI root ports. Signed-off-by: Khasim Syed Mohammed Reviewed-by: Sami Mujawar --- .../AslTables/SsdtPci.asl | 8 +-- .../AslTables/SsdtRemotePci.asl | 4 +- .../ConfigurationManager.c | 24 +++---- .../ConfigurationManagerDxe.inf | 18 ++++-- Platform/ARM/N1Sdp/N1SdpPlatform.dec | 8 --- Platform/ARM/N1Sdp/N1SdpPlatform.dsc | 1 - .../Library/PlatformLib/PlatformLib.inf | 1 + .../Library/PlatformLib/PlatformLibMem.c | 4 +- Silicon/ARM/NeoverseN1Soc/NeoverseN1Soc.dec | 64 +++++++++++-------- 9 files changed, 71 insertions(+), 61 deletions(-) diff --git a/Platform/ARM/N1Sdp/ConfigurationManager/ConfigurationManagerDx= e/AslTables/SsdtPci.asl b/Platform/ARM/N1Sdp/ConfigurationManager/Configura= tionManagerDxe/AslTables/SsdtPci.asl index cdbd42c154..9922673d0d 100644 --- a/Platform/ARM/N1Sdp/ConfigurationManager/ConfigurationManagerDxe/AslTa= bles/SsdtPci.asl +++ b/Platform/ARM/N1Sdp/ConfigurationManager/ConfigurationManagerDxe/AslTa= bles/SsdtPci.asl @@ -80,8 +80,8 @@ DefinitionBlock("SsdtPci.aml", "SSDT", 1, "ARMLTD", "N1Sd= p", Device(PCI0) { Name (_HID, EISAID("PNP0A08")) // PCI Express Root Bridge Name (_CID, EISAID("PNP0A03")) // Compatible PCI Root Bridge - Name (_SEG, Zero) // PCI Segment Group number - Name (_BBN, Zero) // PCI Base Bus Number + Name (_SEG, FixedPcdGet32 (PcdPcieSegmentNumber)) // Segment Number + Name (_BBN, FixedPcdGet32 (PcdPcieBusBaseNumber)) // Bus Base Number Name (_CCA, 1) // Cache Coherency Attribute =20 // Root Complex 0 @@ -166,8 +166,8 @@ DefinitionBlock("SsdtPci.aml", "SSDT", 1, "ARMLTD", "N1= Sdp", Device(PCI1) { Name (_HID, EISAID("PNP0A08")) // PCI Express Root Bridge Name (_CID, EISAID("PNP0A03")) // Compatible PCI Root Bridge - Name (_SEG, 1) // PCI Segment Group number - Name (_BBN, Zero) // PCI Base Bus Number + Name (_SEG, FixedPcdGet32 (PcdCcixSegmentNumber)) // Segment Number + Name (_BBN, FixedPcdGet32 (PcdCcixBusBaseNumber)) // Bus Base Number Name (_CCA, 1) // Cache Coherency Attribute =20 // Root Complex 1 diff --git a/Platform/ARM/N1Sdp/ConfigurationManager/ConfigurationManagerDx= e/AslTables/SsdtRemotePci.asl b/Platform/ARM/N1Sdp/ConfigurationManager/Con= figurationManagerDxe/AslTables/SsdtRemotePci.asl index b6bec7c106..4c6e0c762f 100644 --- a/Platform/ARM/N1Sdp/ConfigurationManager/ConfigurationManagerDxe/AslTa= bles/SsdtRemotePci.asl +++ b/Platform/ARM/N1Sdp/ConfigurationManager/ConfigurationManagerDxe/AslTa= bles/SsdtRemotePci.asl @@ -76,8 +76,8 @@ DefinitionBlock("SsdtRemotePci.aml", "SSDT", 1, "ARMLTD",= "N1Sdp", Device(PCI2) { Name (_HID, EISAID("PNP0A08")) // PCI Express Root Bridge Name (_CID, EISAID("PNP0A03")) // Compatible PCI Root Bridge - Name (_SEG, 2) // PCI Segment Group number - Name (_BBN, Zero) // PCI Base Bus Number + Name (_SEG, FixedPcdGet32 (PcdRemotePcieSegmentNumber)) // Segment N= umber + Name (_BBN, FixedPcdGet32 (PcdRemotePcieBusBaseNumber)) // BusBase N= umber Name (_CCA, 1) // Cache Coherency Attribute =20 // Remote Root Complex 0 diff --git a/Platform/ARM/N1Sdp/ConfigurationManager/ConfigurationManagerDx= e/ConfigurationManager.c b/Platform/ARM/N1Sdp/ConfigurationManager/Configur= ationManagerDxe/ConfigurationManager.c index 9c91372c11..f50623ae3f 100644 --- a/Platform/ARM/N1Sdp/ConfigurationManager/ConfigurationManagerDxe/Confi= gurationManager.c +++ b/Platform/ARM/N1Sdp/ConfigurationManager/ConfigurationManagerDxe/Confi= gurationManager.c @@ -1047,24 +1047,24 @@ EDKII_PLATFORM_REPOSITORY_INFO N1sdpRepositoryInfo = =3D { { // PCIe ECAM { - 0x70000000, // Base Address - 0x0, // Segment Group Number - 0x0, // Start Bus Number - 17 // End Bus Number + FixedPcdGet64 (PcdPcieExpressBaseAddress), // Base Address + FixedPcdGet32 (PcdPcieSegmentNumber), // Segment Group Number + FixedPcdGet32 (PcdPcieBusMin), // Start Bus Number + FixedPcdGet32 (PcdPcieBusMax) // End Bus Number }, // CCIX ECAM { - 0x68000000, // Base Address - 0x1, // Segment Group Number - 0x0, // Start Bus Number - 17 // End Bus Number + FixedPcdGet32 (PcdCcixExpressBaseAddress), // Base Address + FixedPcdGet32 (PcdCcixSegmentNumber), // Segment Group Number + FixedPcdGet32 (PcdCcixBusMin), // Start Bus Number + FixedPcdGet32 (PcdCcixBusMax) // End Bus Number }, //Remote Chip PCIe ECAM { - 0x40070000000, // Base Address - 0x2, // Segment Group Number - 0x0, // Start Bus Number - 17 // End Bus Number + FixedPcdGet64 (PcdRemotePcieBaseAddress), // Base Address + FixedPcdGet32 (PcdRemotePcieSegmentNumber), // Segment Group = Number + FixedPcdGet32 (PcdRemotePcieBusMin), // Start Bus Numb= er + FixedPcdGet32 (PcdRemotePcieBusMax) // End Bus Number } }, =20 diff --git a/Platform/ARM/N1Sdp/ConfigurationManager/ConfigurationManagerDx= e/ConfigurationManagerDxe.inf b/Platform/ARM/N1Sdp/ConfigurationManager/Con= figurationManagerDxe/ConfigurationManagerDxe.inf index 027a4202ff..4f8e7f1302 100644 --- a/Platform/ARM/N1Sdp/ConfigurationManager/ConfigurationManagerDxe/Confi= gurationManagerDxe.inf +++ b/Platform/ARM/N1Sdp/ConfigurationManager/ConfigurationManagerDxe/Confi= gurationManagerDxe.inf @@ -76,8 +76,6 @@ gEfiMdeModulePkgTokenSpaceGuid.PcdSerialRegisterBase gEfiMdePkgTokenSpaceGuid.PcdUartDefaultBaudRate =20 - gArmN1SdpTokenSpaceGuid.PcdPcieExpressBaseAddress - gArmNeoverseN1SocTokenSpaceGuid.PcdExtMemorySpace gArmNeoverseN1SocTokenSpaceGuid.PcdDramBlock2Base =20 @@ -88,9 +86,11 @@ gArmTokenSpaceGuid.PcdSystemMemorySize =20 #PCIe + gArmNeoverseN1SocTokenSpaceGuid.PcdPcieBusBaseNumber gArmNeoverseN1SocTokenSpaceGuid.PcdPcieBusCount gArmNeoverseN1SocTokenSpaceGuid.PcdPcieBusMax gArmNeoverseN1SocTokenSpaceGuid.PcdPcieBusMin + gArmNeoverseN1SocTokenSpaceGuid.PcdPcieExpressBaseAddress gArmNeoverseN1SocTokenSpaceGuid.PcdPcieIoBase gArmNeoverseN1SocTokenSpaceGuid.PcdPcieIoMaxBase gArmNeoverseN1SocTokenSpaceGuid.PcdPcieIoSize @@ -105,8 +105,10 @@ gArmNeoverseN1SocTokenSpaceGuid.PcdPcieMmio64Translation gArmNeoverseN1SocTokenSpaceGuid.PcdPcieRootPortConfigBaseAddress gArmNeoverseN1SocTokenSpaceGuid.PcdPcieRootPortConfigBaseSize + gArmNeoverseN1SocTokenSpaceGuid.PcdPcieSegmentNumber =20 # CCIX + gArmNeoverseN1SocTokenSpaceGuid.PcdCcixBusBaseNumber gArmNeoverseN1SocTokenSpaceGuid.PcdCcixBusCount gArmNeoverseN1SocTokenSpaceGuid.PcdCcixBusMax gArmNeoverseN1SocTokenSpaceGuid.PcdCcixBusMin @@ -125,6 +127,7 @@ gArmNeoverseN1SocTokenSpaceGuid.PcdCcixMmio64Translation gArmNeoverseN1SocTokenSpaceGuid.PcdCcixRootPortConfigBaseAddress gArmNeoverseN1SocTokenSpaceGuid.PcdCcixRootPortConfigBaseSize + gArmNeoverseN1SocTokenSpaceGuid.PcdCcixSegmentNumber =20 # Coresight gArmN1SdpTokenSpaceGuid.PcdCsComponentSize @@ -158,9 +161,14 @@ gArmN1SdpTokenSpaceGuid.PcdCsTpiuMaxBase =20 # Remote PCIe - gArmN1SdpTokenSpaceGuid.PcdRemotePcieIoTranslation - gArmN1SdpTokenSpaceGuid.PcdRemotePcieMmio32Translation - gArmN1SdpTokenSpaceGuid.PcdRemotePcieMmio64Translation + gArmNeoverseN1SocTokenSpaceGuid.PcdRemotePcieBaseAddress + gArmNeoverseN1SocTokenSpaceGuid.PcdRemotePcieBusBaseNumber + gArmNeoverseN1SocTokenSpaceGuid.PcdRemotePcieBusMax + gArmNeoverseN1SocTokenSpaceGuid.PcdRemotePcieBusMin + gArmNeoverseN1SocTokenSpaceGuid.PcdRemotePcieIoTranslation + gArmNeoverseN1SocTokenSpaceGuid.PcdRemotePcieMmio32Translation + gArmNeoverseN1SocTokenSpaceGuid.PcdRemotePcieMmio64Translation + gArmNeoverseN1SocTokenSpaceGuid.PcdRemotePcieSegmentNumber =20 [Depex] TRUE diff --git a/Platform/ARM/N1Sdp/N1SdpPlatform.dec b/Platform/ARM/N1Sdp/N1Sd= pPlatform.dec index 2ab6c20dcc..16937197b8 100644 --- a/Platform/ARM/N1Sdp/N1SdpPlatform.dec +++ b/Platform/ARM/N1Sdp/N1SdpPlatform.dec @@ -34,9 +34,6 @@ gArmN1SdpTokenSpaceGuid.PcdRamDiskBase|0x88000000|UINT32|0x00000001 gArmN1SdpTokenSpaceGuid.PcdRamDiskSize|0x18000000|UINT32|0x00000002 =20 - # PCIe - gArmN1SdpTokenSpaceGuid.PcdPcieExpressBaseAddress|0x70000000|UINT32|0x00= 000007 - # External memory gArmNeoverseN1SocTokenSpaceGuid.PcdExtMemorySpace|0|UINT64|0x00000029 =20 @@ -92,8 +89,3 @@ # unmapped reserved region results in a DECERR response. # gArmN1SdpTokenSpaceGuid.PcdCsComponentSize|0x1000|UINT32|0x00000049 - - # Remote Chip PCIe - gArmN1SdpTokenSpaceGuid.PcdRemotePcieIoTranslation|0x40075200000|UINT64|= 0x0000004A - gArmN1SdpTokenSpaceGuid.PcdRemotePcieMmio32Translation|0x40000000000|UIN= T64|0x0000004B - gArmN1SdpTokenSpaceGuid.PcdRemotePcieMmio64Translation|0x40000000000|UIN= T64|0x0000004C diff --git a/Platform/ARM/N1Sdp/N1SdpPlatform.dsc b/Platform/ARM/N1Sdp/N1Sd= pPlatform.dsc index 7488bdc036..cb2049966c 100644 --- a/Platform/ARM/N1Sdp/N1SdpPlatform.dsc +++ b/Platform/ARM/N1Sdp/N1SdpPlatform.dsc @@ -127,7 +127,6 @@ gArmTokenSpaceGuid.PcdGicRedistributorsBase|0x300C0000 =20 # PCIe - gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseAddress|0x70000000 gEmbeddedTokenSpaceGuid.PcdPrePiCpuIoSize|24 gEfiMdeModulePkgTokenSpaceGuid.PcdSrIovSupport|FALSE =20 diff --git a/Silicon/ARM/NeoverseN1Soc/Library/PlatformLib/PlatformLib.inf = b/Silicon/ARM/NeoverseN1Soc/Library/PlatformLib/PlatformLib.inf index 8e2154aadf..96e590cdd8 100644 --- a/Silicon/ARM/NeoverseN1Soc/Library/PlatformLib/PlatformLib.inf +++ b/Silicon/ARM/NeoverseN1Soc/Library/PlatformLib/PlatformLib.inf @@ -43,6 +43,7 @@ gArmNeoverseN1SocTokenSpaceGuid.PcdExtMemorySpace gArmNeoverseN1SocTokenSpaceGuid.PcdPcieBusMax gArmNeoverseN1SocTokenSpaceGuid.PcdPcieBusMin + gArmNeoverseN1SocTokenSpaceGuid.PcdPcieExpressBaseAddress gArmNeoverseN1SocTokenSpaceGuid.PcdPcieMmio32Base gArmNeoverseN1SocTokenSpaceGuid.PcdPcieMmio32Size gArmNeoverseN1SocTokenSpaceGuid.PcdPcieMmio64Base diff --git a/Silicon/ARM/NeoverseN1Soc/Library/PlatformLib/PlatformLibMem.c= b/Silicon/ARM/NeoverseN1Soc/Library/PlatformLib/PlatformLibMem.c index 1c4a445c5e..339fa07b32 100644 --- a/Silicon/ARM/NeoverseN1Soc/Library/PlatformLib/PlatformLibMem.c +++ b/Silicon/ARM/NeoverseN1Soc/Library/PlatformLib/PlatformLibMem.c @@ -115,8 +115,8 @@ ArmPlatformGetVirtualMemoryMap ( VirtualMemoryTable[Index].Attributes =3D ARM_MEMORY_REGION_ATTRIBUT= E_DEVICE; =20 // PCIe ECAM Configuration Space - VirtualMemoryTable[++Index].PhysicalBase =3D PcdGet64 (PcdPciExpressBas= eAddress); - VirtualMemoryTable[Index].VirtualBase =3D PcdGet64 (PcdPciExpressBas= eAddress); + VirtualMemoryTable[++Index].PhysicalBase =3D PcdGet64 (PcdPcieExpressBa= seAddress); + VirtualMemoryTable[Index].VirtualBase =3D PcdGet64 (PcdPcieExpressBa= seAddress); VirtualMemoryTable[Index].Length =3D (FixedPcdGet32 (PcdPcieBus= Max) - FixedPcdGet32 (PcdPcieBusMi= n) + 1) * SIZE_1MB; diff --git a/Silicon/ARM/NeoverseN1Soc/NeoverseN1Soc.dec b/Silicon/ARM/Neov= erseN1Soc/NeoverseN1Soc.dec index eea2d58402..d59f25a5b9 100644 --- a/Silicon/ARM/NeoverseN1Soc/NeoverseN1Soc.dec +++ b/Silicon/ARM/NeoverseN1Soc/NeoverseN1Soc.dec @@ -29,11 +29,11 @@ gArmNeoverseN1SocTokenSpaceGuid.PcdDramBlock2Base|0|UINT64|0x00000001 =20 #PCIe - gArmNeoverseN1SocTokenSpaceGuid.PcdPcieRootPortConfigBaseAddress|0x60000= 000|UINT32|0x00000002 - gArmNeoverseN1SocTokenSpaceGuid.PcdPcieRootPortConfigBaseSize|0x00001000= |UINT32|0x00000003 - gArmNeoverseN1SocTokenSpaceGuid.PcdPcieBusCount|18|UINT32|0x00000004 - gArmNeoverseN1SocTokenSpaceGuid.PcdPcieBusMax|17|UINT32|0x00000005 - gArmNeoverseN1SocTokenSpaceGuid.PcdPcieBusMin|0|UINT32|0x00000006 + gArmNeoverseN1SocTokenSpaceGuid.PcdPcieBusBaseNumber|0|UINT32|0x00000002 + gArmNeoverseN1SocTokenSpaceGuid.PcdPcieBusCount|18|UINT32|0x00000003 + gArmNeoverseN1SocTokenSpaceGuid.PcdPcieBusMax|17|UINT32|0x00000004 + gArmNeoverseN1SocTokenSpaceGuid.PcdPcieBusMin|0|UINT32|0x00000005 + gArmNeoverseN1SocTokenSpaceGuid.PcdPcieExpressBaseAddress|0x70000000|UIN= T64|0x00000006 gArmNeoverseN1SocTokenSpaceGuid.PcdPcieIoBase|0x0|UINT32|0x00000007 gArmNeoverseN1SocTokenSpaceGuid.PcdPcieIoMaxBase|0x001FFFF|UINT32|0x0000= 0008 gArmNeoverseN1SocTokenSpaceGuid.PcdPcieIoSize|0x020000|UINT32|0x00000009 @@ -46,30 +46,40 @@ gArmNeoverseN1SocTokenSpaceGuid.PcdPcieMmio64MaxBase|0x28FFFFFFFF|UINT64= |0x00000010 gArmNeoverseN1SocTokenSpaceGuid.PcdPcieMmio64Size|0x2000000000|UINT64|0x= 00000011 gArmNeoverseN1SocTokenSpaceGuid.PcdPcieMmio64Translation|0x0|UINT64|0x00= 000012 + gArmNeoverseN1SocTokenSpaceGuid.PcdPcieRootPortConfigBaseAddress|0x60000= 000|UINT32|0x00000013 + gArmNeoverseN1SocTokenSpaceGuid.PcdPcieRootPortConfigBaseSize|0x00001000= |UINT32|0x00000014 + gArmNeoverseN1SocTokenSpaceGuid.PcdPcieSegmentNumber|0|UINT32|0x00000015 =20 # CCIX - gArmNeoverseN1SocTokenSpaceGuid.PcdCcixBusCount|18|UINT32|0x00000016 - gArmNeoverseN1SocTokenSpaceGuid.PcdCcixBusMax|17|UINT32|0x00000017 - gArmNeoverseN1SocTokenSpaceGuid.PcdCcixBusMin|0|UINT32|0x00000018 - gArmNeoverseN1SocTokenSpaceGuid.PcdCcixExpressBaseAddress|0x68000000|UIN= T32|0x00000019 - gArmNeoverseN1SocTokenSpaceGuid.PcdCcixIoBase|0x0|UINT32|0x0000001A - gArmNeoverseN1SocTokenSpaceGuid.PcdCcixIoMaxBase|0x01FFFF|UINT32|0x00000= 01B - gArmNeoverseN1SocTokenSpaceGuid.PcdCcixIoSize|0x020000|UINT32|0x0000001C - gArmNeoverseN1SocTokenSpaceGuid.PcdCcixIoTranslation|0x6D200000|UINT32|0= x00000001D - gArmNeoverseN1SocTokenSpaceGuid.PcdCcixMmio32Base|0x69200000|UINT32|0x00= 00001E - gArmNeoverseN1SocTokenSpaceGuid.PcdCcixMmio32MaxBase|0x6D1FFFFF|UINT32|0= x00000001F - gArmNeoverseN1SocTokenSpaceGuid.PcdCcixMmio32Size|0x04000000|UINT32|0x00= 000020 - gArmNeoverseN1SocTokenSpaceGuid.PcdCcixMmio32Translation|0x0|UINT32|0x00= 000021 - gArmNeoverseN1SocTokenSpaceGuid.PcdCcixMmio64Base|0x2900000000|UINT64|0x= 00000022 - gArmNeoverseN1SocTokenSpaceGuid.PcdCcixMmio64MaxBase|0x48FFFFFFFF|UINT64= |0x00000023 - gArmNeoverseN1SocTokenSpaceGuid.PcdCcixMmio64Size|0x2000000000|UINT64|0x= 00000024 - gArmNeoverseN1SocTokenSpaceGuid.PcdCcixMmio64Translation|0x0|UINT64|0x00= 000025 - gArmNeoverseN1SocTokenSpaceGuid.PcdCcixRootPortConfigBaseAddress|0x62000= 000|UINT32|0x00000026 - gArmNeoverseN1SocTokenSpaceGuid.PcdCcixRootPortConfigBaseSize|0x00001000= |UINT32|0x00000027 + gArmNeoverseN1SocTokenSpaceGuid.PcdCcixBusBaseNumber|0|UINT32|0x00000016 + gArmNeoverseN1SocTokenSpaceGuid.PcdCcixBusCount|18|UINT32|0x00000017 + gArmNeoverseN1SocTokenSpaceGuid.PcdCcixBusMax|17|UINT32|0x00000018 + gArmNeoverseN1SocTokenSpaceGuid.PcdCcixBusMin|0|UINT32|0x00000019 + gArmNeoverseN1SocTokenSpaceGuid.PcdCcixExpressBaseAddress|0x68000000|UIN= T32|0x0000001A + gArmNeoverseN1SocTokenSpaceGuid.PcdCcixIoBase|0x0|UINT32|0x0000001B + gArmNeoverseN1SocTokenSpaceGuid.PcdCcixIoMaxBase|0x00FFFFFF|UINT32|0x000= 0001C + gArmNeoverseN1SocTokenSpaceGuid.PcdCcixIoSize|0x01000000|UINT32|0x000000= 1D + gArmNeoverseN1SocTokenSpaceGuid.PcdCcixIoTranslation|0x6D200000|UINT32|0= x00000001E + gArmNeoverseN1SocTokenSpaceGuid.PcdCcixMmio32Base|0x69200000|UINT32|0x00= 00001F + gArmNeoverseN1SocTokenSpaceGuid.PcdCcixMmio32MaxBase|0x6D1FFFFF|UINT32|0= x000000020 + gArmNeoverseN1SocTokenSpaceGuid.PcdCcixMmio32Size|0x04000000|UINT32|0x00= 000021 + gArmNeoverseN1SocTokenSpaceGuid.PcdCcixMmio32Translation|0x0|UINT32|0x00= 000022 + gArmNeoverseN1SocTokenSpaceGuid.PcdCcixMmio64Base|0x2900000000|UINT64|0x= 00000023 + gArmNeoverseN1SocTokenSpaceGuid.PcdCcixMmio64MaxBase|0x48FFFFFFFF|UINT64= |0x00000024 + gArmNeoverseN1SocTokenSpaceGuid.PcdCcixMmio64Size|0x2000000000|UINT64|0x= 00000025 + gArmNeoverseN1SocTokenSpaceGuid.PcdCcixMmio64Translation|0x0|UINT64|0x00= 000026 + gArmNeoverseN1SocTokenSpaceGuid.PcdCcixRootPortConfigBaseAddress|0x62000= 000|UINT32|0x00000027 + gArmNeoverseN1SocTokenSpaceGuid.PcdCcixRootPortConfigBaseSize|0x00001000= |UINT32|0x00000028 + gArmNeoverseN1SocTokenSpaceGuid.PcdCcixSegmentNumber|1|UINT32|0x00000029 =20 - gArmNeoverseN1SocTokenSpaceGuid.PcdExtMemorySpace|0x40000000000|UINT64|0= x00000029 + gArmNeoverseN1SocTokenSpaceGuid.PcdExtMemorySpace|0x40000000000|UINT64|0= x00000030 =20 # Remote Chip PCIe - gArmNeoverseN1SocTokenSpaceGuid.PcdRemotePcieIoTranslation|0x40075200000= |UINT64|0x0000004A - gArmNeoverseN1SocTokenSpaceGuid.PcdRemotePcieMmio32Translation|0x4000000= 0000|UINT64|0x0000004B - gArmNeoverseN1SocTokenSpaceGuid.PcdRemotePcieMmio64Translation|0x4000000= 0000|UINT64|0x0000004C + gArmNeoverseN1SocTokenSpaceGuid.PcdRemotePcieBaseAddress|0x40070000000|U= INT64|0x0000004A + gArmNeoverseN1SocTokenSpaceGuid.PcdRemotePcieBusBaseNumber|0|UINT32|0x00= 00004B + gArmNeoverseN1SocTokenSpaceGuid.PcdRemotePcieBusMax|17|UINT32|0x0000004C + gArmNeoverseN1SocTokenSpaceGuid.PcdRemotePcieBusMin|0|UINT32|0x0000004D + gArmNeoverseN1SocTokenSpaceGuid.PcdRemotePcieIoTranslation|0x40075200000= |UINT64|0x0000004E + gArmNeoverseN1SocTokenSpaceGuid.PcdRemotePcieMmio32Translation|0x4000000= 0000|UINT64|0x0000004F + gArmNeoverseN1SocTokenSpaceGuid.PcdRemotePcieMmio64Translation|0x4000000= 0000|UINT64|0x00000050 + gArmNeoverseN1SocTokenSpaceGuid.PcdRemotePcieSegmentNumber|2|UINT32|0x00= 000051 --=20 2.17.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 (#85967): https://edk2.groups.io/g/devel/message/85967 Mute This Topic: https://groups.io/mt/88606299/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- From nobody Tue Apr 30 02:02:46 2024 Delivered-To: importer@patchew.org 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+85968+1787277+3901457@groups.io; arc=fail (BodyHash is different from the expected one); dmarc=fail(p=none dis=none) header.from=arm.com Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1642865275221206.88858417729602; Sat, 22 Jan 2022 07:27:55 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id E3bTYY1788612xjxXEzdMwsv; Sat, 22 Jan 2022 07:27:54 -0800 X-Received: from EUR04-VI1-obe.outbound.protection.outlook.com (EUR04-VI1-obe.outbound.protection.outlook.com [40.107.8.73]) by mx.groups.io with SMTP id smtpd.web12.9545.1642865273096655525 for ; Sat, 22 Jan 2022 07:27:53 -0800 X-Received: from DB6P192CA0019.EURP192.PROD.OUTLOOK.COM (2603:10a6:4:b8::29) by VI1PR08MB4478.eurprd08.prod.outlook.com (2603:10a6:803:f7::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4909.12; Sat, 22 Jan 2022 15:27:49 +0000 X-Received: from DB5EUR03FT012.eop-EUR03.prod.protection.outlook.com (2603:10a6:4:b8:cafe::eb) by DB6P192CA0019.outlook.office365.com (2603:10a6:4:b8::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4909.7 via Frontend Transport; Sat, 22 Jan 2022 15:27:49 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dmarc=pass action=none header.from=arm.com; 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+85968+1787277+3901457@groups.io; helo=mail02.groups.io; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; X-Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by DB5EUR03FT012.mail.protection.outlook.com (10.152.20.161) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4909.7 via Frontend Transport; Sat, 22 Jan 2022 15:27:49 +0000 X-Received: ("Tessian outbound 31aeb3346a45:v113"); Sat, 22 Jan 2022 15:27:49 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 7807d81ca32dbd67 X-CR-MTA-TID: 64aa7808 X-Received: from 6a14aef6d70e.2 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 81E9AD68-B6A9-4999-91AD-6699A78AFCAC.1; Sat, 22 Jan 2022 15:27:43 +0000 X-Received: from EUR02-AM5-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 6a14aef6d70e.2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Sat, 22 Jan 2022 15:27:43 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RPOOnekib2VZccXReXdZwDg0PkGXxD/0Nh4BELN8567qhuBN6rgR/tapH+rBEkVHF+MarF1lK1M3DaT8NMzU/zHJbWA0PNB0p7yuJQImzmG3uE5KZLwA3Gjslz314uWgBD3FzQ0uZVSJaSp1vOpCepN9ogxAZAF0GP/5vReNps/9OW0XqAqyOc9DtqbXIPF0IIVbl083+DB9MY1HCDbz/mS/ekAO5wkyYnpeVjM83RVrq+5s52rK0X0hRbAJHx2DoIVjUP0RlbhcTOiyBgPuVX93/+Co4dCk6+ALpccLd6FX/OLBaiGuKQ80cTqbUzTONKKiJ7ptMAT5qCZP+ISSNQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=4WpQCwsXC250xwKaoG3yx7CPSPvHn7loRxEHqlGnmHw=; b=Lr9xG4dO57g+43zt5N+qMEiyxagxQpxkouc8TnrJZuYG/srWy77Gb2TdTrcWSIlPn1PmxD2LVCEXW3+xki3CSjjwnAEC3QEyjUQpzhzgSBQR1cwZuBCmM8R5NfjRI7ggTvO+abchGDn2z0a3vn7pM387XxCjgrqYND1oJECs34c4Y1AT29afnI5n5kM/VWZuLA6YL0NqeLjSwhAq+ZdNHLWRDIsOvsYyW6uIc/sgjBJIe1eU4/wM0G9RiW5RYkUBbD5tlzhSAw3fpthhk9wBSCp9lOcKFL2Aoz86cJN4+HQtiimVm2bCYLVwmiu43JkrCoNhSg+kLiCgh8R6DV+xPQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; X-Received: from PA4PR08MB5902.eurprd08.prod.outlook.com (2603:10a6:102:e0::10) by AM0PR08MB4579.eurprd08.prod.outlook.com (2603:10a6:208:108::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4909.12; Sat, 22 Jan 2022 15:27:42 +0000 X-Received: from PA4PR08MB5902.eurprd08.prod.outlook.com ([fe80::edb5:a2ea:773e:cb8]) by PA4PR08MB5902.eurprd08.prod.outlook.com ([fe80::edb5:a2ea:773e:cb8%7]) with mapi id 15.20.4909.014; Sat, 22 Jan 2022 15:27:42 +0000 From: "Khasim Mohammed" To: devel@edk2.groups.io Cc: nd@arm.com, sami.mujawar@arm.com, pierre.gondois@arm.com, Khasim Syed Mohammed Subject: [edk2-devel] [PATCH v6 3/4] Silicon/ARM/NeoverseN1Soc: Add CCIX root complex support Date: Sat, 22 Jan 2022 20:56:14 +0530 Message-Id: <20220122152615.17366-4-khasim.mohammed@arm.com> In-Reply-To: <20220122152615.17366-1-khasim.mohammed@arm.com> References: <20220122152615.17366-1-khasim.mohammed@arm.com> X-ClientProxiedBy: PN0PR01CA0017.INDPRD01.PROD.OUTLOOK.COM (2603:1096:c01:4f::22) To PA4PR08MB5902.eurprd08.prod.outlook.com (2603:10a6:102:e0::10) MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: 5d52d10a-1e54-467e-53bf-08d9ddbbbfc6 X-MS-TrafficTypeDiagnostic: AM0PR08MB4579:EE_|DB5EUR03FT012:EE_|VI1PR08MB4478:EE_ X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:2582;OLM:2582; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: P2rQTrSd3UDEDDztbjJHiELKOrSKL09pxotgaTFTBDhpE/CN5vhCEoMSTuEt1c36GuuYKkggR3QlHMs8XxDBokie0SVsD3qwJcp565A3OeLSvTAc8la/4WrCFzrzeMWL0xPJ4oxmmHLwwmBYZFGmPCVUgAPczpBU9d47htaNgUnekSwr6RRL7nlje0xm/YeJZIwAiulkPG3T5p6OE65v3x6LB3jMQLPkwPyVlVoc3ZqqTHj1QfJ2MbDs/sRhXFLjhn2LDNKgHitkt0RBQX4rm/1mKoZIqRB9HNaAGMOaoADDHKST1RlKLBL+HFhn62tWykCU5mVATyyJOIipcmKYVjkyI9G5CqdXLrgT67KSUL7FmLrolPcBbhW2YyAKcNJRNXr2QaPJzy7YCqPVAv76IBJKPz1L9nh1qxF5WrMH5C32IG7w8WLd2lXSexuSg8esZSjv0hZzuVUADC08ESK5iPtzcVU/tIlNPgriRkvL166rNIldHlI/b9VEzTPM0ZM34+hOUDkTBr7Twd2lNaWK6kpW12GYurORzYFi3c3bb4PC0imXdqDgx9fxC9OHoaICD4ogdrNm84RLtQmn+eoTY03wtuNmy/FIrziGMihp3TKGzQwPi0/QcIzcalA7kcO1pNts1fAQTFJQDWdoOsrL/qRI+uVI2t62eUjdlcogoNb7clAocP/dTXfq+tU3WZf4XQ0bObXxs3c9YV7Vfb4FQA== X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PA4PR08MB5902.eurprd08.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(6506007)(186003)(36756003)(83380400001)(6666004)(8676002)(4326008)(5660300002)(6486002)(6916009)(316002)(6512007)(26005)(19627235002)(508600001)(52116002)(2906002)(8936002)(66476007)(38350700002)(38100700002)(66556008)(1076003)(2616005)(66946007)(86362001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB4579 Original-Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DB5EUR03FT012.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 654f770a-0d4d-48a2-847f-08d9ddbbbb71 X-Microsoft-Antispam-Message-Info: ttaPNnFLJp+mCBSyob+aw+EY2zKjQCnaC6SgzWNoH9zbbjW7ZFM5w01VFo4VAh5Fmt3FlRKF2JPC6+jjvWL4WylEGOph0rSpXBqRKhbklK3UeaQDa1gyuhTquFKpLeHqFp+WfCpYLHE+T/McqDQX0kQq3tMgduhrigBxeCW9aqgsTrifJoMPStnVoamUnR84HUZocoC//u6TXZbgftyyZ6YAud2GLT5uDHtOdsnO878CWO3sJwmuM7ACyG3NxsPCZOH9RehmPKONY4KGMocy62dqQb6Rwo9WSns82jFL1BQpkJiDi3vMf3j1clIwUel8UMj2XDH1FhJLsu59wLCR/fLt5+t4nFsnpUXZ61LwBXexTRntr8VCowGrYbnR+5/cKvey0RHqFBgeARyqOH+wydRjkIu6BPOnpWiMPyG3umHTID2xRNFjk8+ALl41YqBW6nDfJa+2YJ6LXo41f0/5HfpcsPZzgK/CwvNNpbqtvsQoXUotXo7q/m6zOdt0jWbsXmR9iWnRc9MhAR0vn1Ocrwhk8LZtSa93Qc2NHW5+3br4OjBs6YJjFXLeg/UJHTWgLV0hZW21nc9LJAsq5wFlFEvPkvIG89raKcHS7QFetv3+n3EvUuWB6P+BmRJQHjYIugU+VO/LGvwpiIz28c9pT/QsyoMxAoCOQKqa0m3sN0m6iRh+KPv1Jfyy4RPZ1lzCLQXLpq2L42jHmNRybjuXmNLxuAf2YCB2b4jmlMOTaMzEGDhK5/Nz920yHU2HVmSH3YcC9eqBgnxIqh1EkZzpnQ== X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jan 2022 15:27:49.5704 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5d52d10a-1e54-467e-53bf-08d9ddbbbfc6 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d;Ip=[63.35.35.123];Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: DB5EUR03FT012.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB4478 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,khasim.mohammed@arm.com X-Gm-Message-State: 2ErbTTW1JTI4RM0T3IpO1F9rx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1642865274; bh=GcqfJNjucB1dITSHd4BHpsbp3O1vf6613OoENWOMYHM=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=xNIrjGXQWqv9ikpo8cfziSx/k+168Kv5kRas+7sUi24faVUTtqjAXpQqOeSPzwJClKI WTAsNGWOqa2FdGdAveI6Fn8hNenOW3VYC6p2o1vzofVKDzt4+4glCW81YUknCmA8x161G b9taFCxe0QvlgQhDwaCLCMWXcUPYEbRFZbI= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1642865276252100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" This patch enables CCIX root complex support by updating the root complex node info in PciHostBridge library. Signed-off-by: Khasim Syed Mohammed Reviewed-by: Sami Mujawar --- .../PciHostBridgeLib/PciHostBridgeLib.c | 71 +++++++++++++++++-- .../PciHostBridgeLib/PciHostBridgeLib.inf | 11 ++- 2 files changed, 76 insertions(+), 6 deletions(-) diff --git a/Silicon/ARM/NeoverseN1Soc/Library/PciHostBridgeLib/PciHostBrid= geLib.c b/Silicon/ARM/NeoverseN1Soc/Library/PciHostBridgeLib/PciHostBridgeL= ib.c index 9332939f63..1f38f654a8 100644 --- a/Silicon/ARM/NeoverseN1Soc/Library/PciHostBridgeLib/PciHostBridgeLib.c +++ b/Silicon/ARM/NeoverseN1Soc/Library/PciHostBridgeLib/PciHostBridgeLib.c @@ -1,7 +1,7 @@ /** @file * PCI Host Bridge Library instance for ARM Neoverse N1 platform * -* Copyright (c) 2019 - 2020, ARM Limited. All rights reserved. +* Copyright (c) 2019 - 2022, ARM Limited. All rights reserved.
* * SPDX-License-Identifier: BSD-2-Clause-Patent * @@ -16,6 +16,8 @@ #include #include =20 +#define ROOT_COMPLEX_NUM 2 + GLOBAL_REMOVE_IF_UNREFERENCED STATIC CHAR16 CONST * CONST mPciHostBridgeLibAcpiAddressSpaceTypeStr[] =3D= { L"Mem", L"I/O", L"Bus" @@ -28,7 +30,7 @@ typedef struct { } EFI_PCI_ROOT_BRIDGE_DEVICE_PATH; #pragma pack () =20 -STATIC EFI_PCI_ROOT_BRIDGE_DEVICE_PATH mEfiPciRootBridgeDevicePath[] =3D { +STATIC EFI_PCI_ROOT_BRIDGE_DEVICE_PATH mEfiPciRootBridgeDevicePath[ROOT_CO= MPLEX_NUM] =3D { // PCIe { { @@ -51,10 +53,33 @@ STATIC EFI_PCI_ROOT_BRIDGE_DEVICE_PATH mEfiPciRootBridg= eDevicePath[] =3D { 0 } } - } + }, + //CCIX + { + { + { + ACPI_DEVICE_PATH, + ACPI_DP, + { + (UINT8)sizeof (ACPI_HID_DEVICE_PATH), + (UINT8)(sizeof (ACPI_HID_DEVICE_PATH) >> 8) + } + }, + EISA_PNP_ID(0x0A09), // CCIX + 0 + }, + { + END_DEVICE_PATH_TYPE, + END_ENTIRE_DEVICE_PATH_SUBTYPE, + { + END_DEVICE_PATH_LENGTH, + 0 + } + } + }, }; =20 -STATIC PCI_ROOT_BRIDGE mPciRootBridge[] =3D { +STATIC PCI_ROOT_BRIDGE mPciRootBridge[ROOT_COMPLEX_NUM] =3D { { 0, // Segment 0, // Supports @@ -90,7 +115,43 @@ STATIC PCI_ROOT_BRIDGE mPciRootBridge[] =3D { 0 }, (EFI_DEVICE_PATH_PROTOCOL *)&mEfiPciRootBridgeDevicePath[0] - } + }, + { + 1, // Segment + 0, // Supports + 0, // Attributes + TRUE, // DmaAbove4G + FALSE, // NoExtendedConfigSpa= ce + FALSE, // ResourceAssigned + EFI_PCI_HOST_BRIDGE_COMBINE_MEM_PMEM | // AllocationAttributes + EFI_PCI_HOST_BRIDGE_MEM64_DECODE, + { + // Bus + FixedPcdGet32 (PcdCcixBusMin), + FixedPcdGet32 (PcdCcixBusMax) + }, { + // Io + FixedPcdGet64 (PcdCcixIoBase), + FixedPcdGet64 (PcdCcixIoBase) + FixedPcdGet64 (PcdCcixIoSize) - 1 + }, { + // Mem + FixedPcdGet32 (PcdCcixMmio32Base), + FixedPcdGet32 (PcdCcixMmio32Base) + FixedPcdGet32 (PcdCcixMmio32Size= ) - 1 + }, { + // MemAbove4G + FixedPcdGet64 (PcdCcixMmio64Base), + FixedPcdGet64 (PcdCcixMmio64Base) + FixedPcdGet64 (PcdCcixMmio64Size= ) - 1 + }, { + // PMem + MAX_UINT64, + 0 + }, { + // PMemAbove4G + MAX_UINT64, + 0 + }, + (EFI_DEVICE_PATH_PROTOCOL *)&mEfiPciRootBridgeDevicePath[1] + }, }; =20 /** diff --git a/Silicon/ARM/NeoverseN1Soc/Library/PciHostBridgeLib/PciHostBrid= geLib.inf b/Silicon/ARM/NeoverseN1Soc/Library/PciHostBridgeLib/PciHostBridg= eLib.inf index 3ff1c592f2..f05bc563e6 100644 --- a/Silicon/ARM/NeoverseN1Soc/Library/PciHostBridgeLib/PciHostBridgeLib.i= nf +++ b/Silicon/ARM/NeoverseN1Soc/Library/PciHostBridgeLib/PciHostBridgeLib.i= nf @@ -1,7 +1,7 @@ ## @file # PCI Host Bridge Library instance for ARM Neoverse N1 platform. # -# Copyright (c) 2019 - 2020, ARM Limited. All rights reserved. +# Copyright (c) 2019 - 2022, ARM Limited. All rights reserved.
# # SPDX-License-Identifier: BSD-2-Clause-Patent # @@ -42,6 +42,15 @@ gArmNeoverseN1SocTokenSpaceGuid.PcdPcieMmio64Base gArmNeoverseN1SocTokenSpaceGuid.PcdPcieMmio64Size =20 + gArmNeoverseN1SocTokenSpaceGuid.PcdCcixBusMin + gArmNeoverseN1SocTokenSpaceGuid.PcdCcixBusMax + gArmNeoverseN1SocTokenSpaceGuid.PcdCcixIoBase + gArmNeoverseN1SocTokenSpaceGuid.PcdCcixIoSize + gArmNeoverseN1SocTokenSpaceGuid.PcdCcixMmio32Base + gArmNeoverseN1SocTokenSpaceGuid.PcdCcixMmio32Size + gArmNeoverseN1SocTokenSpaceGuid.PcdCcixMmio64Base + gArmNeoverseN1SocTokenSpaceGuid.PcdCcixMmio64Size + [Protocols] gEfiCpuIo2ProtocolGuid =20 --=20 2.17.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 (#85968): https://edk2.groups.io/g/devel/message/85968 Mute This Topic: https://groups.io/mt/88606314/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- From nobody Tue Apr 30 02:02:46 2024 Delivered-To: importer@patchew.org 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+85969+1787277+3901457@groups.io; arc=fail (BodyHash is different from the expected one); dmarc=fail(p=none dis=none) header.from=arm.com Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1642865314988490.91920689023857; Sat, 22 Jan 2022 07:28:34 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id 3KPvYY1788612xkGij1BTgfQ; Sat, 22 Jan 2022 07:28:34 -0800 X-Received: from EUR03-VE1-obe.outbound.protection.outlook.com (EUR03-VE1-obe.outbound.protection.outlook.com [40.107.5.57]) by mx.groups.io with SMTP id smtpd.web11.9531.1642865313087038724 for ; Sat, 22 Jan 2022 07:28:34 -0800 X-Received: from DB6PR0501CA0026.eurprd05.prod.outlook.com (2603:10a6:4:67::12) by VI1PR08MB2638.eurprd08.prod.outlook.com (2603:10a6:802:1f::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4909.13; Sat, 22 Jan 2022 15:28:13 +0000 X-Received: from DB5EUR03FT035.eop-EUR03.prod.protection.outlook.com (2603:10a6:4:67:cafe::33) by DB6PR0501CA0026.outlook.office365.com (2603:10a6:4:67::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4909.14 via Frontend Transport; Sat, 22 Jan 2022 15:28:13 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dmarc=pass action=none header.from=arm.com; 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+85969+1787277+3901457@groups.io; helo=mail02.groups.io; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; X-Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by DB5EUR03FT035.mail.protection.outlook.com (10.152.20.65) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4909.7 via Frontend Transport; Sat, 22 Jan 2022 15:28:13 +0000 X-Received: ("Tessian outbound 31aeb3346a45:v113"); Sat, 22 Jan 2022 15:28:13 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 2255ed9c9689573e X-CR-MTA-TID: 64aa7808 X-Received: from b094a5f2f82d.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 768FBED6-6B45-4276-96F7-6113098A995F.1; Sat, 22 Jan 2022 15:28:02 +0000 X-Received: from EUR02-AM5-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id b094a5f2f82d.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Sat, 22 Jan 2022 15:28:02 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gNZPO1Ysh4RPSBrN7fxbM0dOJdSqWjC7B2CHSoc+Jmf8N0DePhMJBqEMwWDcZfxSCjDr7s8yzlSxlrV2pPCtmBAxscxSlH/XI+yhpphaxKgHz1FkGUxzLmtVnelI3xwqs6FrizeHolAqU5uV/ylWMIRIkEJQjYwvEQA1M96Pw/cG9kctwXoBNN8Rw2vAyopPPKjZrxVPuCyD6QXEuXg1UooLYGnwteDHUqyURopH/AzcWlEGR5FQyPwEuAbHSR27LpW5Onjma+z/L7fkyBIHyQk4Snk0UdvL/YtiA9yI9FpgPxR3miW/8h3NhXGozS+nVqWkig/p79mrcCYCEIuFFg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=9dfs71mS9Oz1mB7xQRyqH1YvTUuFfXhlv7vLd7Uhwt0=; b=HnLwpnF9u0tHS8SBZxtyYxeKWK3Jk5oPR+uwsGRHua9xQwg990Sk9ffDHPzsnZ6NFX7ZnsSJRrSWPP9UStvVd+rOM3heo7MC3aUQu0vhvunuigBh09Y1Kerb/w2l9r0LYHLMRJKVSYxwX3esFqPnUZi2QpO5Wxf2kLue4gJEbYH6A9J7Z1zYzgZ6M3hPGfouD9PWsIPnoJhB4tnwlbif++CjZIQiZz5lYGuIvVmRwR3z3J2fC7ev6lreX0mNbfGz4Mz2sOTwlONCkmj8ppaDJeplfD17ns84Ql+sAY412q2ZlcxRCnpWckZUn9pWcb8HUxRYx0fLvQ8m5hrjtqXztg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; X-Received: from PA4PR08MB5902.eurprd08.prod.outlook.com (2603:10a6:102:e0::10) by AM0PR08MB4579.eurprd08.prod.outlook.com (2603:10a6:208:108::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4909.12; Sat, 22 Jan 2022 15:27:59 +0000 X-Received: from PA4PR08MB5902.eurprd08.prod.outlook.com ([fe80::edb5:a2ea:773e:cb8]) by PA4PR08MB5902.eurprd08.prod.outlook.com ([fe80::edb5:a2ea:773e:cb8%7]) with mapi id 15.20.4909.014; Sat, 22 Jan 2022 15:27:59 +0000 From: "Khasim Mohammed" To: devel@edk2.groups.io Cc: nd@arm.com, sami.mujawar@arm.com, pierre.gondois@arm.com, Khasim Syed Mohammed , Deepak Pandey Subject: [edk2-devel] [PATCH v6 4/4] Silicon/ARM/NeoverseN1Soc: Remove PciExpressLib use PciSegmentLib instead Date: Sat, 22 Jan 2022 20:56:15 +0530 Message-Id: <20220122152615.17366-5-khasim.mohammed@arm.com> In-Reply-To: <20220122152615.17366-1-khasim.mohammed@arm.com> References: <20220122152615.17366-1-khasim.mohammed@arm.com> X-ClientProxiedBy: PN0PR01CA0017.INDPRD01.PROD.OUTLOOK.COM (2603:1096:c01:4f::22) To PA4PR08MB5902.eurprd08.prod.outlook.com (2603:10a6:102:e0::10) MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: 0ea6daf4-7ef4-42e6-d43b-08d9ddbbce23 X-MS-TrafficTypeDiagnostic: AM0PR08MB4579:EE_|DB5EUR03FT035:EE_|VI1PR08MB2638:EE_ X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:8882;OLM:8882; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: 1jz8tZy6k1zlD8f0Bq2U83qPUTpE5wPCWNISfxIYEaIvLF3y6MbIZfXTf4kI84oW9TMJJTkwgERylQceZKXETPvr5M24jr9/683PynlMTz+xjQ0o7LDO9RSfBGJKyYpciwl4RpJNk4xyI+FgPP/6oHc/HP7JcwVfL0VuHzKCasDlDYpzv8cZ179pLNQMFGBxjfAHColDFu18A3Uo3AK3tBH753NUtTXFOvM1SHVfwv4AzVije5WNr1gZZ697K+Ay7xKjy7iu+JVq7d8iaKMzMWYCP2weOAqqRobtlnPLNzKBftTyuN2afzNP2XISsb8dgHBaChE9L4/rRGNRg5Ru/Jv/gHeYTkbaU/5rL/pGB5Kx/l38JQuYV9lImQbStqwuyWNU+tE5BV/DiTkLFD073wcPuv/Fbxup6A2D4Qd3GY0xB+rqY/e6XLKUyfi/K1Y/Mra4wiOfpWpmVowC0zNvxnnFn+MCFcFIdVsiPajuTbmAZRlUUhUo5RzPES9pV86wFplYrHrMDcsgfRBLnznOVxFldSERTey4Q9vrgMxQANA6hKatDNFKqC04VvwcoePAFpbAIvcASKqwB9qq8BkvJzA6n71eJ7/F6AINySGJlwKQqQAahPTwCQmDo0TcCZuZ2PwM0gEwkR7/JfNAfQW8KBalqBM3A20EnVo8q9uRia/3hTbwRehBo81xewUpmJCojHUUGcVt6mXLhpk/d5L0zg== X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PA4PR08MB5902.eurprd08.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(6506007)(54906003)(186003)(36756003)(83380400001)(6666004)(8676002)(4326008)(5660300002)(6486002)(6916009)(316002)(6512007)(26005)(19627235002)(30864003)(508600001)(52116002)(2906002)(8936002)(66476007)(38350700002)(38100700002)(66556008)(1076003)(2616005)(66946007)(86362001)(579004)(559001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB4579 Original-Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DB5EUR03FT035.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 533f9ed6-d935-41e0-aaaf-08d9ddbbc581 X-Microsoft-Antispam-Message-Info: rgUrRv61hKfg6NxZ6Ne9AOPYVrjsyafHdVuQeZp4yWgYy+Z2TXqjonu3UtKpSTXZyQNChabC5/2EuPgA/VxQk2FhEyBirGjDLDmqKnBNdfZUGc/gofFuVIvGvWFrCRa/6dDjqZGcwt0y0en9+LoJqSVgFXR6QoLbgCfSpgkFQnHwYyPxgPrA9JuA6M9FC/anMYF738xk7Kx48b+b7y9vG6sGPLcA1ZGuG8Dm4DUNC3e7OfjE6c0NjW/TX48ZuY/HT9+LG3Imrf+rfOebEm+Ix7ZgYjSBBeEBKDjXY1wiKskEtIcQiKBX2hHHdWu0EdpoedLGk1JdQ27JlM0RK2GI0AWuqoLgKS+zeQXZ8VXOTIpueuGxR32gAAAse9sqLXSLUzO16YpL8IniUxXfqO4sOCIItrWddUPzTn/WtKV2Ob4N/w6FAULf+j69bHjhh1o2STNpKYHr3FPSTcdfWsWIDDi8GRVSb1YfMusobuAgWtRCDKzGhfSxFvI1zrLrK0adS8Odsu6s3BKezyx1Uw4i11Lk3RG3lWWImLhZ9/84FzTDGvBeKKcqHJV9HPQsYKJnSYv51sgrV9WALH48oPKIaJmRLpiKh0+3efPBAFGtmMYQatacENDzZLB26IGW9JTITsVMV/909fKNbyY0QCnH7wGoz0fXRu8BqeBHg1BBK15dRa53pVjAOuLTBoFfx6ad3sSstfntgbwUUVr5clXIdLtYMPidMBRe7qpKJdBFgHm89Z6HZlbVmfoJ0ZFrjKnStngdKOz/XxeulJTUVljvSw== X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jan 2022 15:28:13.6557 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0ea6daf4-7ef4-42e6-d43b-08d9ddbbce23 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d;Ip=[63.35.35.123];Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: DB5EUR03FT035.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB2638 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,khasim.mohammed@arm.com X-Gm-Message-State: 9pBwhBBIsyrYUEEaGyoT076Ux1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1642865314; bh=L0m26wGhjH2jCd69en3Mpt1V6AEoaXqsXJzDK50ubfY=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=IyQtqhJKhJmEsr8m7yt76y+cjZ8kRbjK4tesfBs0l7TapoJAp4Ec5R5lmj/lL9lF0JI BvRMrMoTkIlX/JyLJy47YdK0qUo54HS65J+J1BqO5M9W90mTYYO2yu0ekzD4pZ0XAE+Vf WnSbu2yoifNtTb+ZNOrcm/pYV05PoFZKH+E= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1642865317350100002 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The patch removes PciExpressLib implementation for N1Sdp as: a) The PciSegmentLib implementation for N1Sdp makes MmioRead() calls instead of PciRead() which makes the PciExpressLib redundant. b) Since N1Sdp requires multiple segments to be supported, PciExpressLib and PciLib cannot be used, PciSegmentLib should be used instead as it supports multiple segments. Signed-off-by: Deepak Pandey Signed-off-by: Khasim Syed Mohammed Reviewed-by: Sami Mujawar --- Platform/ARM/N1Sdp/N1SdpPlatform.dsc | 4 +- .../PciExpressLib.c | 1589 ----------------- .../PciExpressLib.inf | 56 - 3 files changed, 1 insertion(+), 1648 deletions(-) delete mode 100644 Silicon/ARM/NeoverseN1Soc/Library/NeoverseN1SocPciExpre= ssLib/PciExpressLib.c delete mode 100644 Silicon/ARM/NeoverseN1Soc/Library/NeoverseN1SocPciExpre= ssLib/PciExpressLib.inf diff --git a/Platform/ARM/N1Sdp/N1SdpPlatform.dsc b/Platform/ARM/N1Sdp/N1Sd= pPlatform.dsc index cb2049966c..8dac1bc54c 100644 --- a/Platform/ARM/N1Sdp/N1SdpPlatform.dsc +++ b/Platform/ARM/N1Sdp/N1SdpPlatform.dsc @@ -75,9 +75,7 @@ [LibraryClasses.common.DXE_DRIVER] FdtLib|EmbeddedPkg/Library/FdtLib/FdtLib.inf PciHostBridgeLib|Silicon/ARM/NeoverseN1Soc/Library/PciHostBridgeLib/PciH= ostBridgeLib.inf - PciSegmentLib|MdePkg/Library/BasePciSegmentLibPci/BasePciSegmentLibPci.i= nf - PciLib|MdePkg/Library/BasePciLibPciExpress/BasePciLibPciExpress.inf - PciExpressLib|Silicon/ARM/NeoverseN1Soc/Library/NeoverseN1SocPciExpressL= ib/PciExpressLib.inf + PciSegmentLib|Silicon/ARM/NeoverseN1Soc/Library/PciSegmentLib/PciSegment= Lib.inf =20 [LibraryClasses.common.DXE_RUNTIME_DRIVER] BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf diff --git a/Silicon/ARM/NeoverseN1Soc/Library/NeoverseN1SocPciExpressLib/P= ciExpressLib.c b/Silicon/ARM/NeoverseN1Soc/Library/NeoverseN1SocPciExpressL= ib/PciExpressLib.c deleted file mode 100644 index bb0246b4a9..0000000000 --- a/Silicon/ARM/NeoverseN1Soc/Library/NeoverseN1SocPciExpressLib/PciExpre= ssLib.c +++ /dev/null @@ -1,1589 +0,0 @@ -/** @file - Functions in this library instance make use of MMIO functions in IoLib to - access memory mapped PCI configuration space. - - All assertions for I/O operations are handled in MMIO functions in the I= oLib - Library. - - Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
- - On the NeoverseN1Soc, a slave error is generated when host accesses the - configuration space of non-available device or unimplemented function on= a - given bus. So this library introduces a workaround using IsBdfValid(), - to return 0xFFFFFFFF for all such access. - - In addition to this, the hardware has two other limitations which affect - access to the PCIe root port: - 1. ECAM space is not contiguous, root port ECAM (BDF =3D 0:0:0) is iso= lated - from rest of the downstream hierarchy ECAM space. - 2. Root port ECAM space is not capable of 8bit/16bit writes. - The description of the workarounds included for these limitations can - be found in the comments below. - - Copyright (c) 2020, ARM Limited. All rights reserved. - - SPDX-License-Identifier: BSD-2-Clause-Patent - -**/ - - -#include - -#include -#include -#include -#include -#include -#include - -/** - Assert the validity of a PCI address. A valid PCI address should contain= 1's - only in the low 28 bits. - - @param A The address to validate. - -**/ -#define ASSERT_INVALID_PCI_ADDRESS(A) \ - ASSERT (((A) & ~0xfffffff) =3D=3D 0) - -/* Root port Entry, BDF Entries Count */ -#define BDF_TABLE_ENTRY_SIZE 4 -#define BDF_TABLE_HEADER_COUNT 2 -#define BDF_TABLE_HEADER_SIZE 8 - -/* BDF table offsets for PCIe */ -#define PCIE_BDF_TABLE_OFFSET 0 - -#define GET_BUS_NUM(Address) (((Address) >> 20) & 0x7F) -#define GET_DEV_NUM(Address) (((Address) >> 15) & 0x1F) -#define GET_FUNC_NUM(Address) (((Address) >> 12) & 0x07) -#define GET_REG_NUM(Address) ((Address) & 0xFFF) - -/** - BDF Table structure : (Header + BDF Entries) - -------------------------------------------- - [Offset 0x00] ROOT PORT ADDRESS - [Offset 0x04] BDF ENTRIES COUNT - [Offset 0x08] BDF ENTRY 0 - [Offset 0x0C] BDF ENTRY 1 - [Offset 0x10] BDF ENTRY 2 - [Offset 0x14] BDF ENTRY 3 - [Offset 0x18] BDF ENTRY 4 - ... - [Offset 0x--] BDF ENTRY N - -------------------------------------------- -**/ - -/** - Value returned for reads on configuration space of unimplemented - device functions. -**/ -STATIC UINTN mDummyConfigData =3D 0xFFFFFFFF; - -/** - Registers a PCI device so PCI configuration registers may be accessed af= ter - SetVirtualAddressMap(). - - Registers the PCI device specified by Address so all the PCI configurati= on - registers associated with that PCI device may be accessed after SetVirtu= alAddressMap() - is called. - - If Address > 0x0FFFFFFF, then ASSERT(). - - @param Address The address that encodes the PCI Bus, Device, Function a= nd - Register. - - @retval RETURN_SUCCESS The PCI device was registered for runti= me access. - @retval RETURN_UNSUPPORTED An attempt was made to call this functi= on - after ExitBootServices(). - @retval RETURN_UNSUPPORTED The resources required to access the PC= I device - at runtime could not be mapped. - @retval RETURN_OUT_OF_RESOURCES There are not enough resources availabl= e to - complete the registration. - -**/ -RETURN_STATUS -EFIAPI -PciExpressRegisterForRuntimeAccess ( - IN UINTN Address - ) -{ - ASSERT_INVALID_PCI_ADDRESS (Address); - return RETURN_UNSUPPORTED; -} - -/** - Check if the requested PCI address can be safely accessed. - - SCP performs the initial bus scan, prepares a table of valid BDF address= es - and shares them through non-trusted SRAM. This function validates if the - requested PCI address belongs to a valid BDF by checking the table of va= lid - entries. If not, this function will return false. This is a workaround to - avoid bus fault that occurs when accessing unavailable PCI device due to - hardware bug. - - @param Address The address that encodes the PCI Bus, Device, Function a= nd - Register. - - @return TRUE BDF can be accessed, valid. - @return FALSE BDF should not be accessed, invalid. - -**/ -STATIC -BOOLEAN -IsBdfValid ( - IN UINTN Address - ) -{ - UINTN BdfCount; - UINTN BdfValue; - UINTN BdfEntry; - UINTN Count; - UINTN TableBase; - UINTN ConfigBase; - - ConfigBase =3D Address & ~0xFFF; - TableBase =3D NEOVERSEN1SOC_NON_SECURE_SRAM_BASE + PCIE_BDF_TABLE_OFFSET; - BdfCount =3D MmioRead32 (TableBase + BDF_TABLE_ENTRY_SIZE); - BdfEntry =3D TableBase + BDF_TABLE_HEADER_SIZE; - - /* Skip the header & check remaining entry */ - for (Count =3D 0; Count < BdfCount; Count++, BdfEntry +=3D BDF_TABLE_ENT= RY_SIZE) { - BdfValue =3D MmioRead32 (BdfEntry); - if (BdfValue =3D=3D ConfigBase) { - return TRUE; - } - } - - return FALSE; -} - -/** - Get the physical address of a configuration space register. - - Implement a workaround to avoid generation of slave errors from the bus= . That - is, retrieve the PCI Express Base Address via a PCD entry, add the incom= ming - address with that base address and check whether this converted address - points to a accessible BDF. If it is not accessible, return the address - of a dummy location so that a read from it does not cause a slave error. - - In addition to this, implement a workaround for accessing the root port's - configuration space. The root port configuration space is not contiguous - with the rest of the downstream hierarchy configuration space. So determ= ine - whether the specified address is for the root port and use a different b= ase - address for it. - - @param Address The address that encodes the PCI Bus, Device, Function a= nd - Register. - - @return Physical address of the configuration register that corresponds = to the - PCI configuration register specified by input parameter 'Address= '. - -**/ -STATIC -VOID* -GetPciExpressAddress ( - IN UINTN Address - ) -{ - UINT8 Bus, Device, Function; - UINTN ConfigAddress; - - Bus =3D GET_BUS_NUM (Address); - Device =3D GET_DEV_NUM (Address); - Function =3D GET_FUNC_NUM (Address); - - if ((Bus =3D=3D 0) && (Device =3D=3D 0) && (Function =3D=3D 0)) { - ConfigAddress =3D PcdGet32 (PcdPcieRootPortConfigBaseAddress) + Addres= s; - } else { - ConfigAddress =3D PcdGet64 (PcdPciExpressBaseAddress) + Address; - if (!IsBdfValid(Address)) { - ConfigAddress =3D (UINTN)&mDummyConfigData; - } - } - - return (VOID *)ConfigAddress; -} - -/** - Reads an 8-bit PCI configuration register. - - Reads and returns the 8-bit PCI configuration register specified by Addr= ess. - This function must guarantee that all PCI read and write operations are - serialized. - - If Address > 0x0FFFFFFF, then ASSERT(). - - @param Address The address that encodes the PCI Bus, Device, Function a= nd - Register. - - @return The read value from the PCI configuration register. - -**/ -UINT8 -EFIAPI -PciExpressRead8 ( - IN UINTN Address - ) -{ - ASSERT_INVALID_PCI_ADDRESS (Address); - return MmioRead8 ((UINTN)GetPciExpressAddress (Address)); -} - -/** - Writes an 8-bit PCI configuration register. - - Writes the 8-bit PCI configuration register specified by Address with the - value specified by Value. Value is returned. This function must guarantee - that all PCI read and write operations are serialized. - - If Address > 0x0FFFFFFF, then ASSERT(). - - @param Address The address that encodes the PCI Bus, Device, Function a= nd - Register. - @param Value The value to write. - - @return The value written to the PCI configuration register. - -**/ -UINT8 -EFIAPI -PciExpressWrite8 ( - IN UINTN Address, - IN UINT8 Value - ) -{ - UINT8 Bus, Device, Function; - UINT8 Offset; - UINT32 Data; - - ASSERT_INVALID_PCI_ADDRESS (Address); - - Bus =3D GET_BUS_NUM (Address); - Device =3D GET_DEV_NUM (Address); - Function =3D GET_FUNC_NUM (Address); - - // - // 8-bit and 16-bit writes to root port config space is not supported du= e to - // a hardware limitation. As a workaround, perform a read-update-write - // sequence on the whole 32-bit word of the root port config register su= ch - // that only the specified 8-bits of that word are updated. - // - if ((Bus =3D=3D 0) && (Device =3D=3D 0) && (Function =3D=3D 0)) { - Offset =3D Address & 0x3; - Address &=3D 0xFFFFFFFC; - Data =3D MmioRead32 ((UINTN)GetPciExpressAddress (Address)); - Data &=3D ~(0xFF << (8 * Offset)); - Data |=3D (Value << (8 * Offset)); - MmioWrite32 ((UINTN)GetPciExpressAddress (Address), Data); - return Value; - } - - return MmioWrite8 ((UINTN)GetPciExpressAddress (Address), Value); -} - -/** - Performs a bitwise OR of an 8-bit PCI configuration register with - an 8-bit value. - - Reads the 8-bit PCI configuration register specified by Address, perform= s a - bitwise OR between the read result and the value specified by - OrData, and writes the result to the 8-bit PCI configuration register - specified by Address. The value written to the PCI configuration registe= r is - returned. This function must guarantee that all PCI read and write opera= tions - are serialized. - - If Address > 0x0FFFFFFF, then ASSERT(). - - @param Address The address that encodes the PCI Bus, Device, Function a= nd - Register. - @param OrData The value to OR with the PCI configuration register. - - @return The value written back to the PCI configuration register. - -**/ -UINT8 -EFIAPI -PciExpressOr8 ( - IN UINTN Address, - IN UINT8 OrData - ) -{ - ASSERT_INVALID_PCI_ADDRESS (Address); - return MmioOr8 ((UINTN)GetPciExpressAddress (Address), OrData); -} - -/** - Performs a bitwise AND of an 8-bit PCI configuration register with an 8-= bit - value. - - Reads the 8-bit PCI configuration register specified by Address, perform= s a - bitwise AND between the read result and the value specified by AndData, = and - writes the result to the 8-bit PCI configuration register specified by - Address. The value written to the PCI configuration register is returned. - This function must guarantee that all PCI read and write operations are - serialized. - - If Address > 0x0FFFFFFF, then ASSERT(). - - @param Address The address that encodes the PCI Bus, Device, Function a= nd - Register. - @param AndData The value to AND with the PCI configuration register. - - @return The value written back to the PCI configuration register. - -**/ -UINT8 -EFIAPI -PciExpressAnd8 ( - IN UINTN Address, - IN UINT8 AndData - ) -{ - ASSERT_INVALID_PCI_ADDRESS (Address); - return MmioAnd8 ((UINTN)GetPciExpressAddress (Address), AndData); -} - -/** - Performs a bitwise AND of an 8-bit PCI configuration register with an 8-= bit - value, followed a bitwise OR with another 8-bit value. - - Reads the 8-bit PCI configuration register specified by Address, perform= s a - bitwise AND between the read result and the value specified by AndData, - performs a bitwise OR between the result of the AND operation and - the value specified by OrData, and writes the result to the 8-bit PCI - configuration register specified by Address. The value written to the PCI - configuration register is returned. This function must guarantee that al= l PCI - read and write operations are serialized. - - If Address > 0x0FFFFFFF, then ASSERT(). - - @param Address The address that encodes the PCI Bus, Device, Function a= nd - Register. - @param AndData The value to AND with the PCI configuration register. - @param OrData The value to OR with the result of the AND operation. - - @return The value written back to the PCI configuration register. - -**/ -UINT8 -EFIAPI -PciExpressAndThenOr8 ( - IN UINTN Address, - IN UINT8 AndData, - IN UINT8 OrData - ) -{ - ASSERT_INVALID_PCI_ADDRESS (Address); - return MmioAndThenOr8 ( - (UINTN)GetPciExpressAddress (Address), - AndData, - OrData - ); -} - -/** - Reads a bit field of a PCI configuration register. - - Reads the bit field in an 8-bit PCI configuration register. The bit fiel= d is - specified by the StartBit and the EndBit. The value of the bit field is - returned. - - If Address > 0x0FFFFFFF, then ASSERT(). - If StartBit is greater than 7, then ASSERT(). - If EndBit is greater than 7, then ASSERT(). - If EndBit is less than StartBit, then ASSERT(). - - @param Address The PCI configuration register to read. - @param StartBit The ordinal of the least significant bit in the bit fi= eld. - Range 0..7. - @param EndBit The ordinal of the most significant bit in the bit fie= ld. - Range 0..7. - - @return The value of the bit field read from the PCI configuration regis= ter. - -**/ -UINT8 -EFIAPI -PciExpressBitFieldRead8 ( - IN UINTN Address, - IN UINTN StartBit, - IN UINTN EndBit - ) -{ - ASSERT_INVALID_PCI_ADDRESS (Address); - return MmioBitFieldRead8 ( - (UINTN)GetPciExpressAddress (Address), - StartBit, - EndBit - ); -} - -/** - Writes a bit field to a PCI configuration register. - - Writes Value to the bit field of the PCI configuration register. The bit - field is specified by the StartBit and the EndBit. All other bits in the - destination PCI configuration register are preserved. The new value of t= he - 8-bit register is returned. - - If Address > 0x0FFFFFFF, then ASSERT(). - If StartBit is greater than 7, then ASSERT(). - If EndBit is greater than 7, then ASSERT(). - If EndBit is less than StartBit, then ASSERT(). - If Value is larger than the bitmask value range specified by StartBit an= d EndBit, then ASSERT(). - - @param Address The PCI configuration register to write. - @param StartBit The ordinal of the least significant bit in the bit fi= eld. - Range 0..7. - @param EndBit The ordinal of the most significant bit in the bit fie= ld. - Range 0..7. - @param Value The new value of the bit field. - - @return The value written back to the PCI configuration register. - -**/ -UINT8 -EFIAPI -PciExpressBitFieldWrite8 ( - IN UINTN Address, - IN UINTN StartBit, - IN UINTN EndBit, - IN UINT8 Value - ) -{ - ASSERT_INVALID_PCI_ADDRESS (Address); - return MmioBitFieldWrite8 ( - (UINTN)GetPciExpressAddress (Address), - StartBit, - EndBit, - Value - ); -} - -/** - Reads a bit field in an 8-bit PCI configuration, performs a bitwise OR, = and - writes the result back to the bit field in the 8-bit port. - - Reads the 8-bit PCI configuration register specified by Address, perform= s a - bitwise OR between the read result and the value specified by - OrData, and writes the result to the 8-bit PCI configuration register - specified by Address. The value written to the PCI configuration registe= r is - returned. This function must guarantee that all PCI read and write opera= tions - are serialized. Extra left bits in OrData are stripped. - - If Address > 0x0FFFFFFF, then ASSERT(). - If StartBit is greater than 7, then ASSERT(). - If EndBit is greater than 7, then ASSERT(). - If EndBit is less than StartBit, then ASSERT(). - If OrData is larger than the bitmask value range specified by StartBit a= nd EndBit, then ASSERT(). - - @param Address The PCI configuration register to write. - @param StartBit The ordinal of the least significant bit in the bit fi= eld. - Range 0..7. - @param EndBit The ordinal of the most significant bit in the bit fie= ld. - Range 0..7. - @param OrData The value to OR with the PCI configuration register. - - @return The value written back to the PCI configuration register. - -**/ -UINT8 -EFIAPI -PciExpressBitFieldOr8 ( - IN UINTN Address, - IN UINTN StartBit, - IN UINTN EndBit, - IN UINT8 OrData - ) -{ - ASSERT_INVALID_PCI_ADDRESS (Address); - return MmioBitFieldOr8 ( - (UINTN)GetPciExpressAddress (Address), - StartBit, - EndBit, - OrData - ); -} - -/** - Reads a bit field in an 8-bit PCI configuration register, performs a bit= wise - AND, and writes the result back to the bit field in the 8-bit register. - - Reads the 8-bit PCI configuration register specified by Address, perform= s a - bitwise AND between the read result and the value specified by AndData, = and - writes the result to the 8-bit PCI configuration register specified by - Address. The value written to the PCI configuration register is returned. - This function must guarantee that all PCI read and write operations are - serialized. Extra left bits in AndData are stripped. - - If Address > 0x0FFFFFFF, then ASSERT(). - If StartBit is greater than 7, then ASSERT(). - If EndBit is greater than 7, then ASSERT(). - If EndBit is less than StartBit, then ASSERT(). - If AndData is larger than the bitmask value range specified by StartBit = and EndBit, then ASSERT(). - - @param Address The PCI configuration register to write. - @param StartBit The ordinal of the least significant bit in the bit fi= eld. - Range 0..7. - @param EndBit The ordinal of the most significant bit in the bit fie= ld. - Range 0..7. - @param AndData The value to AND with the PCI configuration register. - - @return The value written back to the PCI configuration register. - -**/ -UINT8 -EFIAPI -PciExpressBitFieldAnd8 ( - IN UINTN Address, - IN UINTN StartBit, - IN UINTN EndBit, - IN UINT8 AndData - ) -{ - ASSERT_INVALID_PCI_ADDRESS (Address); - return MmioBitFieldAnd8 ( - (UINTN)GetPciExpressAddress (Address), - StartBit, - EndBit, - AndData - ); -} - -/** - Reads a bit field in an 8-bit port, performs a bitwise AND followed by a - bitwise OR, and writes the result back to the bit field in the - 8-bit port. - - Reads the 8-bit PCI configuration register specified by Address, perform= s a - bitwise AND followed by a bitwise OR between the read result and - the value specified by AndData, and writes the result to the 8-bit PCI - configuration register specified by Address. The value written to the PCI - configuration register is returned. This function must guarantee that al= l PCI - read and write operations are serialized. Extra left bits in both AndDat= a and - OrData are stripped. - - If Address > 0x0FFFFFFF, then ASSERT(). - If StartBit is greater than 7, then ASSERT(). - If EndBit is greater than 7, then ASSERT(). - If EndBit is less than StartBit, then ASSERT(). - If AndData is larger than the bitmask value range specified by StartBit = and EndBit, then ASSERT(). - If OrData is larger than the bitmask value range specified by StartBit a= nd EndBit, then ASSERT(). - - @param Address The PCI configuration register to write. - @param StartBit The ordinal of the least significant bit in the bit fi= eld. - Range 0..7. - @param EndBit The ordinal of the most significant bit in the bit fie= ld. - Range 0..7. - @param AndData The value to AND with the PCI configuration register. - @param OrData The value to OR with the result of the AND operation. - - @return The value written back to the PCI configuration register. - -**/ -UINT8 -EFIAPI -PciExpressBitFieldAndThenOr8 ( - IN UINTN Address, - IN UINTN StartBit, - IN UINTN EndBit, - IN UINT8 AndData, - IN UINT8 OrData - ) -{ - ASSERT_INVALID_PCI_ADDRESS (Address); - return MmioBitFieldAndThenOr8 ( - (UINTN)GetPciExpressAddress (Address), - StartBit, - EndBit, - AndData, - OrData - ); -} - -/** - Reads a 16-bit PCI configuration register. - - Reads and returns the 16-bit PCI configuration register specified by Add= ress. - This function must guarantee that all PCI read and write operations are - serialized. - - If Address > 0x0FFFFFFF, then ASSERT(). - If Address is not aligned on a 16-bit boundary, then ASSERT(). - - @param Address The address that encodes the PCI Bus, Device, Function a= nd - Register. - - @return The read value from the PCI configuration register. - -**/ -UINT16 -EFIAPI -PciExpressRead16 ( - IN UINTN Address - ) -{ - ASSERT_INVALID_PCI_ADDRESS (Address); - return MmioRead16 ((UINTN)GetPciExpressAddress (Address)); -} - -/** - Writes a 16-bit PCI configuration register. - - Writes the 16-bit PCI configuration register specified by Address with t= he - value specified by Value. Value is returned. This function must guarantee - that all PCI read and write operations are serialized. - - If Address > 0x0FFFFFFF, then ASSERT(). - If Address is not aligned on a 16-bit boundary, then ASSERT(). - - @param Address The address that encodes the PCI Bus, Device, Function a= nd - Register. - @param Value The value to write. - - @return The value written to the PCI configuration register. - -**/ -UINT16 -EFIAPI -PciExpressWrite16 ( - IN UINTN Address, - IN UINT16 Value - ) -{ - UINT8 Bus, Device, Function; - UINT8 Offset; - UINT32 Data; - - ASSERT_INVALID_PCI_ADDRESS (Address); - - Bus =3D GET_BUS_NUM (Address); - Device =3D GET_DEV_NUM (Address); - Function =3D GET_FUNC_NUM (Address); - - // - // 8-bit and 16-bit writes to root port config space is not supported du= e to - // a hardware limitation. As a workaround, perform a read-update-write - // sequence on the whole 32-bit word of the root port config register su= ch - // that only the specified 16-bits of that word are updated. - // - if ((Bus =3D=3D 0) && (Device =3D=3D 0) && (Function =3D=3D 0)) { - Offset =3D Address & 0x3; - Address &=3D 0xFFFFFFFC; - Data =3D MmioRead32 ((UINTN)GetPciExpressAddress (Address)); - Data &=3D ~(0xFFFF << (8 * Offset)); - Data |=3D (Value << (8 * Offset)); - MmioWrite32 ((UINTN)GetPciExpressAddress (Address), Data); - return Value; - } - - return MmioWrite16 ((UINTN)GetPciExpressAddress (Address), Value); -} - -/** - Performs a bitwise OR of a 16-bit PCI configuration register with - a 16-bit value. - - Reads the 16-bit PCI configuration register specified by Address, perfor= ms a - bitwise OR between the read result and the value specified by - OrData, and writes the result to the 16-bit PCI configuration register - specified by Address. The value written to the PCI configuration registe= r is - returned. This function must guarantee that all PCI read and write opera= tions - are serialized. - - If Address > 0x0FFFFFFF, then ASSERT(). - If Address is not aligned on a 16-bit boundary, then ASSERT(). - - @param Address The address that encodes the PCI Bus, Device, Function a= nd - Register. - @param OrData The value to OR with the PCI configuration register. - - @return The value written back to the PCI configuration register. - -**/ -UINT16 -EFIAPI -PciExpressOr16 ( - IN UINTN Address, - IN UINT16 OrData - ) -{ - ASSERT_INVALID_PCI_ADDRESS (Address); - return MmioOr16 ((UINTN)GetPciExpressAddress (Address), OrData); -} - -/** - Performs a bitwise AND of a 16-bit PCI configuration register with a 16-= bit - value. - - Reads the 16-bit PCI configuration register specified by Address, perfor= ms a - bitwise AND between the read result and the value specified by AndData, = and - writes the result to the 16-bit PCI configuration register specified by - Address. The value written to the PCI configuration register is returned. - This function must guarantee that all PCI read and write operations are - serialized. - - If Address > 0x0FFFFFFF, then ASSERT(). - If Address is not aligned on a 16-bit boundary, then ASSERT(). - - @param Address The address that encodes the PCI Bus, Device, Function a= nd - Register. - @param AndData The value to AND with the PCI configuration register. - - @return The value written back to the PCI configuration register. - -**/ -UINT16 -EFIAPI -PciExpressAnd16 ( - IN UINTN Address, - IN UINT16 AndData - ) -{ - ASSERT_INVALID_PCI_ADDRESS (Address); - return MmioAnd16 ((UINTN)GetPciExpressAddress (Address), AndData); -} - -/** - Performs a bitwise AND of a 16-bit PCI configuration register with a 16-= bit - value, followed a bitwise OR with another 16-bit value. - - Reads the 16-bit PCI configuration register specified by Address, perfor= ms a - bitwise AND between the read result and the value specified by AndData, - performs a bitwise OR between the result of the AND operation and - the value specified by OrData, and writes the result to the 16-bit PCI - configuration register specified by Address. The value written to the PCI - configuration register is returned. This function must guarantee that al= l PCI - read and write operations are serialized. - - If Address > 0x0FFFFFFF, then ASSERT(). - If Address is not aligned on a 16-bit boundary, then ASSERT(). - - @param Address The address that encodes the PCI Bus, Device, Function a= nd - Register. - @param AndData The value to AND with the PCI configuration register. - @param OrData The value to OR with the result of the AND operation. - - @return The value written back to the PCI configuration register. - -**/ -UINT16 -EFIAPI -PciExpressAndThenOr16 ( - IN UINTN Address, - IN UINT16 AndData, - IN UINT16 OrData - ) -{ - ASSERT_INVALID_PCI_ADDRESS (Address); - return MmioAndThenOr16 ( - (UINTN)GetPciExpressAddress (Address), - AndData, - OrData - ); -} - -/** - Reads a bit field of a PCI configuration register. - - Reads the bit field in a 16-bit PCI configuration register. The bit fiel= d is - specified by the StartBit and the EndBit. The value of the bit field is - returned. - - If Address > 0x0FFFFFFF, then ASSERT(). - If Address is not aligned on a 16-bit boundary, then ASSERT(). - If StartBit is greater than 15, then ASSERT(). - If EndBit is greater than 15, then ASSERT(). - If EndBit is less than StartBit, then ASSERT(). - - @param Address The PCI configuration register to read. - @param StartBit The ordinal of the least significant bit in the bit fi= eld. - Range 0..15. - @param EndBit The ordinal of the most significant bit in the bit fie= ld. - Range 0..15. - - @return The value of the bit field read from the PCI configuration regis= ter. - -**/ -UINT16 -EFIAPI -PciExpressBitFieldRead16 ( - IN UINTN Address, - IN UINTN StartBit, - IN UINTN EndBit - ) -{ - ASSERT_INVALID_PCI_ADDRESS (Address); - return MmioBitFieldRead16 ( - (UINTN)GetPciExpressAddress (Address), - StartBit, - EndBit - ); -} - -/** - Writes a bit field to a PCI configuration register. - - Writes Value to the bit field of the PCI configuration register. The bit - field is specified by the StartBit and the EndBit. All other bits in the - destination PCI configuration register are preserved. The new value of t= he - 16-bit register is returned. - - If Address > 0x0FFFFFFF, then ASSERT(). - If Address is not aligned on a 16-bit boundary, then ASSERT(). - If StartBit is greater than 15, then ASSERT(). - If EndBit is greater than 15, then ASSERT(). - If EndBit is less than StartBit, then ASSERT(). - If Value is larger than the bitmask value range specified by StartBit an= d EndBit, then ASSERT(). - - @param Address The PCI configuration register to write. - @param StartBit The ordinal of the least significant bit in the bit fi= eld. - Range 0..15. - @param EndBit The ordinal of the most significant bit in the bit fie= ld. - Range 0..15. - @param Value The new value of the bit field. - - @return The value written back to the PCI configuration register. - -**/ -UINT16 -EFIAPI -PciExpressBitFieldWrite16 ( - IN UINTN Address, - IN UINTN StartBit, - IN UINTN EndBit, - IN UINT16 Value - ) -{ - ASSERT_INVALID_PCI_ADDRESS (Address); - return MmioBitFieldWrite16 ( - (UINTN)GetPciExpressAddress (Address), - StartBit, - EndBit, - Value - ); -} - -/** - Reads a bit field in a 16-bit PCI configuration, performs a bitwise OR, = and - writes the result back to the bit field in the 16-bit port. - - Reads the 16-bit PCI configuration register specified by Address, perfor= ms a - bitwise OR between the read result and the value specified by - OrData, and writes the result to the 16-bit PCI configuration register - specified by Address. The value written to the PCI configuration registe= r is - returned. This function must guarantee that all PCI read and write opera= tions - are serialized. Extra left bits in OrData are stripped. - - If Address > 0x0FFFFFFF, then ASSERT(). - If Address is not aligned on a 16-bit boundary, then ASSERT(). - If StartBit is greater than 15, then ASSERT(). - If EndBit is greater than 15, then ASSERT(). - If EndBit is less than StartBit, then ASSERT(). - If OrData is larger than the bitmask value range specified by StartBit a= nd EndBit, then ASSERT(). - - @param Address The PCI configuration register to write. - @param StartBit The ordinal of the least significant bit in the bit fi= eld. - Range 0..15. - @param EndBit The ordinal of the most significant bit in the bit fie= ld. - Range 0..15. - @param OrData The value to OR with the PCI configuration register. - - @return The value written back to the PCI configuration register. - -**/ -UINT16 -EFIAPI -PciExpressBitFieldOr16 ( - IN UINTN Address, - IN UINTN StartBit, - IN UINTN EndBit, - IN UINT16 OrData - ) -{ - ASSERT_INVALID_PCI_ADDRESS (Address); - return MmioBitFieldOr16 ( - (UINTN)GetPciExpressAddress (Address), - StartBit, - EndBit, - OrData - ); -} - -/** - Reads a bit field in a 16-bit PCI configuration register, performs a bit= wise - AND, and writes the result back to the bit field in the 16-bit register. - - Reads the 16-bit PCI configuration register specified by Address, perfor= ms a - bitwise AND between the read result and the value specified by AndData, = and - writes the result to the 16-bit PCI configuration register specified by - Address. The value written to the PCI configuration register is returned. - This function must guarantee that all PCI read and write operations are - serialized. Extra left bits in AndData are stripped. - - If Address > 0x0FFFFFFF, then ASSERT(). - If Address is not aligned on a 16-bit boundary, then ASSERT(). - If StartBit is greater than 15, then ASSERT(). - If EndBit is greater than 15, then ASSERT(). - If EndBit is less than StartBit, then ASSERT(). - If AndData is larger than the bitmask value range specified by StartBit = and EndBit, then ASSERT(). - - @param Address The PCI configuration register to write. - @param StartBit The ordinal of the least significant bit in the bit fi= eld. - Range 0..15. - @param EndBit The ordinal of the most significant bit in the bit fie= ld. - Range 0..15. - @param AndData The value to AND with the PCI configuration register. - - @return The value written back to the PCI configuration register. - -**/ -UINT16 -EFIAPI -PciExpressBitFieldAnd16 ( - IN UINTN Address, - IN UINTN StartBit, - IN UINTN EndBit, - IN UINT16 AndData - ) -{ - ASSERT_INVALID_PCI_ADDRESS (Address); - return MmioBitFieldAnd16 ( - (UINTN)GetPciExpressAddress (Address), - StartBit, - EndBit, - AndData - ); -} - -/** - Reads a bit field in a 16-bit port, performs a bitwise AND followed by a - bitwise OR, and writes the result back to the bit field in the - 16-bit port. - - Reads the 16-bit PCI configuration register specified by Address, perfor= ms a - bitwise AND followed by a bitwise OR between the read result and - the value specified by AndData, and writes the result to the 16-bit PCI - configuration register specified by Address. The value written to the PCI - configuration register is returned. This function must guarantee that al= l PCI - read and write operations are serialized. Extra left bits in both AndDat= a and - OrData are stripped. - - If Address > 0x0FFFFFFF, then ASSERT(). - If Address is not aligned on a 16-bit boundary, then ASSERT(). - If StartBit is greater than 15, then ASSERT(). - If EndBit is greater than 15, then ASSERT(). - If EndBit is less than StartBit, then ASSERT(). - If AndData is larger than the bitmask value range specified by StartBit = and EndBit, then ASSERT(). - If OrData is larger than the bitmask value range specified by StartBit a= nd EndBit, then ASSERT(). - - @param Address The PCI configuration register to write. - @param StartBit The ordinal of the least significant bit in the bit fi= eld. - Range 0..15. - @param EndBit The ordinal of the most significant bit in the bit fie= ld. - Range 0..15. - @param AndData The value to AND with the PCI configuration register. - @param OrData The value to OR with the result of the AND operation. - - @return The value written back to the PCI configuration register. - -**/ -UINT16 -EFIAPI -PciExpressBitFieldAndThenOr16 ( - IN UINTN Address, - IN UINTN StartBit, - IN UINTN EndBit, - IN UINT16 AndData, - IN UINT16 OrData - ) -{ - ASSERT_INVALID_PCI_ADDRESS (Address); - return MmioBitFieldAndThenOr16 ( - (UINTN)GetPciExpressAddress (Address), - StartBit, - EndBit, - AndData, - OrData - ); -} - -/** - Reads a 32-bit PCI configuration register. - - Reads and returns the 32-bit PCI configuration register specified by Add= ress. - This function must guarantee that all PCI read and write operations are - serialized. - - If Address > 0x0FFFFFFF, then ASSERT(). - If Address is not aligned on a 32-bit boundary, then ASSERT(). - - @param Address The address that encodes the PCI Bus, Device, Function a= nd - Register. - - @return The read value from the PCI configuration register. - -**/ -UINT32 -EFIAPI -PciExpressRead32 ( - IN UINTN Address - ) -{ - ASSERT_INVALID_PCI_ADDRESS (Address); - return MmioRead32 ((UINTN)GetPciExpressAddress (Address)); -} - -/** - Writes a 32-bit PCI configuration register. - - Writes the 32-bit PCI configuration register specified by Address with t= he - value specified by Value. Value is returned. This function must guarantee - that all PCI read and write operations are serialized. - - If Address > 0x0FFFFFFF, then ASSERT(). - If Address is not aligned on a 32-bit boundary, then ASSERT(). - - @param Address The address that encodes the PCI Bus, Device, Function a= nd - Register. - @param Value The value to write. - - @return The value written to the PCI configuration register. - -**/ -UINT32 -EFIAPI -PciExpressWrite32 ( - IN UINTN Address, - IN UINT32 Value - ) -{ - ASSERT_INVALID_PCI_ADDRESS (Address); - return MmioWrite32 ((UINTN)GetPciExpressAddress (Address), Value); -} - -/** - Performs a bitwise OR of a 32-bit PCI configuration register with - a 32-bit value. - - Reads the 32-bit PCI configuration register specified by Address, perfor= ms a - bitwise OR between the read result and the value specified by - OrData, and writes the result to the 32-bit PCI configuration register - specified by Address. The value written to the PCI configuration registe= r is - returned. This function must guarantee that all PCI read and write opera= tions - are serialized. - - If Address > 0x0FFFFFFF, then ASSERT(). - If Address is not aligned on a 32-bit boundary, then ASSERT(). - - @param Address The address that encodes the PCI Bus, Device, Function a= nd - Register. - @param OrData The value to OR with the PCI configuration register. - - @return The value written back to the PCI configuration register. - -**/ -UINT32 -EFIAPI -PciExpressOr32 ( - IN UINTN Address, - IN UINT32 OrData - ) -{ - ASSERT_INVALID_PCI_ADDRESS (Address); - return MmioOr32 ((UINTN)GetPciExpressAddress (Address), OrData); -} - -/** - Performs a bitwise AND of a 32-bit PCI configuration register with a 32-= bit - value. - - Reads the 32-bit PCI configuration register specified by Address, perfor= ms a - bitwise AND between the read result and the value specified by AndData, = and - writes the result to the 32-bit PCI configuration register specified by - Address. The value written to the PCI configuration register is returned. - This function must guarantee that all PCI read and write operations are - serialized. - - If Address > 0x0FFFFFFF, then ASSERT(). - If Address is not aligned on a 32-bit boundary, then ASSERT(). - - @param Address The address that encodes the PCI Bus, Device, Function a= nd - Register. - @param AndData The value to AND with the PCI configuration register. - - @return The value written back to the PCI configuration register. - -**/ -UINT32 -EFIAPI -PciExpressAnd32 ( - IN UINTN Address, - IN UINT32 AndData - ) -{ - ASSERT_INVALID_PCI_ADDRESS (Address); - return MmioAnd32 ((UINTN)GetPciExpressAddress (Address), AndData); -} - -/** - Performs a bitwise AND of a 32-bit PCI configuration register with a 32-= bit - value, followed a bitwise OR with another 32-bit value. - - Reads the 32-bit PCI configuration register specified by Address, perfor= ms a - bitwise AND between the read result and the value specified by AndData, - performs a bitwise OR between the result of the AND operation and - the value specified by OrData, and writes the result to the 32-bit PCI - configuration register specified by Address. The value written to the PCI - configuration register is returned. This function must guarantee that al= l PCI - read and write operations are serialized. - - If Address > 0x0FFFFFFF, then ASSERT(). - If Address is not aligned on a 32-bit boundary, then ASSERT(). - - @param Address The address that encodes the PCI Bus, Device, Function a= nd - Register. - @param AndData The value to AND with the PCI configuration register. - @param OrData The value to OR with the result of the AND operation. - - @return The value written back to the PCI configuration register. - -**/ -UINT32 -EFIAPI -PciExpressAndThenOr32 ( - IN UINTN Address, - IN UINT32 AndData, - IN UINT32 OrData - ) -{ - ASSERT_INVALID_PCI_ADDRESS (Address); - return MmioAndThenOr32 ( - (UINTN)GetPciExpressAddress (Address), - AndData, - OrData - ); -} - -/** - Reads a bit field of a PCI configuration register. - - Reads the bit field in a 32-bit PCI configuration register. The bit fiel= d is - specified by the StartBit and the EndBit. The value of the bit field is - returned. - - If Address > 0x0FFFFFFF, then ASSERT(). - If Address is not aligned on a 32-bit boundary, then ASSERT(). - If StartBit is greater than 31, then ASSERT(). - If EndBit is greater than 31, then ASSERT(). - If EndBit is less than StartBit, then ASSERT(). - - @param Address The PCI configuration register to read. - @param StartBit The ordinal of the least significant bit in the bit fi= eld. - Range 0..31. - @param EndBit The ordinal of the most significant bit in the bit fie= ld. - Range 0..31. - - @return The value of the bit field read from the PCI configuration regis= ter. - -**/ -UINT32 -EFIAPI -PciExpressBitFieldRead32 ( - IN UINTN Address, - IN UINTN StartBit, - IN UINTN EndBit - ) -{ - ASSERT_INVALID_PCI_ADDRESS (Address); - return MmioBitFieldRead32 ( - (UINTN)GetPciExpressAddress (Address), - StartBit, - EndBit - ); -} - -/** - Writes a bit field to a PCI configuration register. - - Writes Value to the bit field of the PCI configuration register. The bit - field is specified by the StartBit and the EndBit. All other bits in the - destination PCI configuration register are preserved. The new value of t= he - 32-bit register is returned. - - If Address > 0x0FFFFFFF, then ASSERT(). - If Address is not aligned on a 32-bit boundary, then ASSERT(). - If StartBit is greater than 31, then ASSERT(). - If EndBit is greater than 31, then ASSERT(). - If EndBit is less than StartBit, then ASSERT(). - If Value is larger than the bitmask value range specified by StartBit an= d EndBit, then ASSERT(). - - @param Address The PCI configuration register to write. - @param StartBit The ordinal of the least significant bit in the bit fi= eld. - Range 0..31. - @param EndBit The ordinal of the most significant bit in the bit fie= ld. - Range 0..31. - @param Value The new value of the bit field. - - @return The value written back to the PCI configuration register. - -**/ -UINT32 -EFIAPI -PciExpressBitFieldWrite32 ( - IN UINTN Address, - IN UINTN StartBit, - IN UINTN EndBit, - IN UINT32 Value - ) -{ - ASSERT_INVALID_PCI_ADDRESS (Address); - return MmioBitFieldWrite32 ( - (UINTN)GetPciExpressAddress (Address), - StartBit, - EndBit, - Value - ); -} - -/** - Reads a bit field in a 32-bit PCI configuration, performs a bitwise OR, = and - writes the result back to the bit field in the 32-bit port. - - Reads the 32-bit PCI configuration register specified by Address, perfor= ms a - bitwise OR between the read result and the value specified by - OrData, and writes the result to the 32-bit PCI configuration register - specified by Address. The value written to the PCI configuration registe= r is - returned. This function must guarantee that all PCI read and write opera= tions - are serialized. Extra left bits in OrData are stripped. - - If Address > 0x0FFFFFFF, then ASSERT(). - If Address is not aligned on a 32-bit boundary, then ASSERT(). - If StartBit is greater than 31, then ASSERT(). - If EndBit is greater than 31, then ASSERT(). - If EndBit is less than StartBit, then ASSERT(). - If OrData is larger than the bitmask value range specified by StartBit a= nd EndBit, then ASSERT(). - - @param Address The PCI configuration register to write. - @param StartBit The ordinal of the least significant bit in the bit fi= eld. - Range 0..31. - @param EndBit The ordinal of the most significant bit in the bit fie= ld. - Range 0..31. - @param OrData The value to OR with the PCI configuration register. - - @return The value written back to the PCI configuration register. - -**/ -UINT32 -EFIAPI -PciExpressBitFieldOr32 ( - IN UINTN Address, - IN UINTN StartBit, - IN UINTN EndBit, - IN UINT32 OrData - ) -{ - ASSERT_INVALID_PCI_ADDRESS (Address); - return MmioBitFieldOr32 ( - (UINTN)GetPciExpressAddress (Address), - StartBit, - EndBit, - OrData - ); -} - -/** - Reads a bit field in a 32-bit PCI configuration register, performs a bit= wise - AND, and writes the result back to the bit field in the 32-bit register. - - Reads the 32-bit PCI configuration register specified by Address, perfor= ms a - bitwise AND between the read result and the value specified by AndData, = and - writes the result to the 32-bit PCI configuration register specified by - Address. The value written to the PCI configuration register is returned. - This function must guarantee that all PCI read and write operations are - serialized. Extra left bits in AndData are stripped. - - If Address > 0x0FFFFFFF, then ASSERT(). - If Address is not aligned on a 32-bit boundary, then ASSERT(). - If StartBit is greater than 31, then ASSERT(). - If EndBit is greater than 31, then ASSERT(). - If EndBit is less than StartBit, then ASSERT(). - If AndData is larger than the bitmask value range specified by StartBit = and EndBit, then ASSERT(). - - @param Address The PCI configuration register to write. - @param StartBit The ordinal of the least significant bit in the bit fi= eld. - Range 0..31. - @param EndBit The ordinal of the most significant bit in the bit fie= ld. - Range 0..31. - @param AndData The value to AND with the PCI configuration register. - - @return The value written back to the PCI configuration register. - -**/ -UINT32 -EFIAPI -PciExpressBitFieldAnd32 ( - IN UINTN Address, - IN UINTN StartBit, - IN UINTN EndBit, - IN UINT32 AndData - ) -{ - ASSERT_INVALID_PCI_ADDRESS (Address); - return MmioBitFieldAnd32 ( - (UINTN)GetPciExpressAddress (Address), - StartBit, - EndBit, - AndData - ); -} - -/** - Reads a bit field in a 32-bit port, performs a bitwise AND followed by a - bitwise OR, and writes the result back to the bit field in the - 32-bit port. - - Reads the 32-bit PCI configuration register specified by Address, perfor= ms a - bitwise AND followed by a bitwise OR between the read result and - the value specified by AndData, and writes the result to the 32-bit PCI - configuration register specified by Address. The value written to the PCI - configuration register is returned. This function must guarantee that al= l PCI - read and write operations are serialized. Extra left bits in both AndDat= a and - OrData are stripped. - - If Address > 0x0FFFFFFF, then ASSERT(). - If Address is not aligned on a 32-bit boundary, then ASSERT(). - If StartBit is greater than 31, then ASSERT(). - If EndBit is greater than 31, then ASSERT(). - If EndBit is less than StartBit, then ASSERT(). - If AndData is larger than the bitmask value range specified by StartBit = and EndBit, then ASSERT(). - If OrData is larger than the bitmask value range specified by StartBit a= nd EndBit, then ASSERT(). - - @param Address The PCI configuration register to write. - @param StartBit The ordinal of the least significant bit in the bit fi= eld. - Range 0..31. - @param EndBit The ordinal of the most significant bit in the bit fie= ld. - Range 0..31. - @param AndData The value to AND with the PCI configuration register. - @param OrData The value to OR with the result of the AND operation. - - @return The value written back to the PCI configuration register. - -**/ -UINT32 -EFIAPI -PciExpressBitFieldAndThenOr32 ( - IN UINTN Address, - IN UINTN StartBit, - IN UINTN EndBit, - IN UINT32 AndData, - IN UINT32 OrData - ) -{ - ASSERT_INVALID_PCI_ADDRESS (Address); - return MmioBitFieldAndThenOr32 ( - (UINTN)GetPciExpressAddress (Address), - StartBit, - EndBit, - AndData, - OrData - ); -} - -/** - Reads a range of PCI configuration registers into a caller supplied buff= er. - - Reads the range of PCI configuration registers specified by StartAddress= and - Size into the buffer specified by Buffer. This function only allows the = PCI - configuration registers from a single PCI function to be read. Size is - returned. When possible 32-bit PCI configuration read cycles are used to= read - from StartAdress to StartAddress + Size. Due to alignment restrictions, = 8-bit - and 16-bit PCI configuration read cycles may be used at the beginning an= d the - end of the range. - - If StartAddress > 0x0FFFFFFF, then ASSERT(). - If ((StartAddress & 0xFFF) + Size) > 0x1000, then ASSERT(). - If Size > 0 and Buffer is NULL, then ASSERT(). - - @param StartAddress The starting address that encodes the PCI Bus, Dev= ice, - Function and Register. - @param Size The size in bytes of the transfer. - @param Buffer The pointer to a buffer receiving the data read. - - @return Size read data from StartAddress. - -**/ -UINTN -EFIAPI -PciExpressReadBuffer ( - IN UINTN StartAddress, - IN UINTN Size, - OUT VOID *Buffer - ) -{ - UINTN ReturnValue; - - ASSERT_INVALID_PCI_ADDRESS (StartAddress); - ASSERT (((StartAddress & 0xFFF) + Size) <=3D 0x1000); - - if (Size =3D=3D 0) { - return Size; - } - - ASSERT (Buffer !=3D NULL); - - // - // Save Size for return - // - ReturnValue =3D Size; - - if ((StartAddress & 1) !=3D 0) { - // - // Read a byte if StartAddress is byte aligned - // - *(volatile UINT8 *)Buffer =3D PciExpressRead8 (StartAddress); - StartAddress +=3D sizeof (UINT8); - Size -=3D sizeof (UINT8); - Buffer =3D (UINT8*)Buffer + 1; - } - - if (Size >=3D sizeof (UINT16) && (StartAddress & 2) !=3D 0) { - // - // Read a word if StartAddress is word aligned - // - WriteUnaligned16 ((UINT16 *) Buffer, (UINT16) PciExpressRead16 (StartA= ddress)); - - StartAddress +=3D sizeof (UINT16); - Size -=3D sizeof (UINT16); - Buffer =3D (UINT16*)Buffer + 1; - } - - while (Size >=3D sizeof (UINT32)) { - // - // Read as many double words as possible - // - WriteUnaligned32 ((UINT32 *) Buffer, (UINT32) PciExpressRead32 (StartA= ddress)); - - StartAddress +=3D sizeof (UINT32); - Size -=3D sizeof (UINT32); - Buffer =3D (UINT32*)Buffer + 1; - } - - if (Size >=3D sizeof (UINT16)) { - // - // Read the last remaining word if exist - // - WriteUnaligned16 ((UINT16 *) Buffer, (UINT16) PciExpressRead16 (StartA= ddress)); - StartAddress +=3D sizeof (UINT16); - Size -=3D sizeof (UINT16); - Buffer =3D (UINT16*)Buffer + 1; - } - - if (Size >=3D sizeof (UINT8)) { - // - // Read the last remaining byte if exist - // - *(volatile UINT8 *)Buffer =3D PciExpressRead8 (StartAddress); - } - - return ReturnValue; -} - -/** - Copies the data in a caller supplied buffer to a specified range of PCI - configuration space. - - Writes the range of PCI configuration registers specified by StartAddres= s and - Size from the buffer specified by Buffer. This function only allows the = PCI - configuration registers from a single PCI function to be written. Size is - returned. When possible 32-bit PCI configuration write cycles are used to - write from StartAdress to StartAddress + Size. Due to alignment restrict= ions, - 8-bit and 16-bit PCI configuration write cycles may be used at the begin= ning - and the end of the range. - - If StartAddress > 0x0FFFFFFF, then ASSERT(). - If ((StartAddress & 0xFFF) + Size) > 0x1000, then ASSERT(). - If Size > 0 and Buffer is NULL, then ASSERT(). - - @param StartAddress The starting address that encodes the PCI Bus, Dev= ice, - Function and Register. - @param Size The size in bytes of the transfer. - @param Buffer The pointer to a buffer containing the data to wri= te. - - @return Size written to StartAddress. - -**/ -UINTN -EFIAPI -PciExpressWriteBuffer ( - IN UINTN StartAddress, - IN UINTN Size, - IN VOID *Buffer - ) -{ - UINTN ReturnValue; - - ASSERT_INVALID_PCI_ADDRESS (StartAddress); - ASSERT (((StartAddress & 0xFFF) + Size) <=3D 0x1000); - - if (Size =3D=3D 0) { - return 0; - } - - ASSERT (Buffer !=3D NULL); - - // - // Save Size for return - // - ReturnValue =3D Size; - - if ((StartAddress & 1) !=3D 0) { - // - // Write a byte if StartAddress is byte aligned - // - PciExpressWrite8 (StartAddress, *(UINT8*)Buffer); - StartAddress +=3D sizeof (UINT8); - Size -=3D sizeof (UINT8); - Buffer =3D (UINT8*)Buffer + 1; - } - - if (Size >=3D sizeof (UINT16) && (StartAddress & 2) !=3D 0) { - // - // Write a word if StartAddress is word aligned - // - PciExpressWrite16 (StartAddress, ReadUnaligned16 ((UINT16*)Buffer)); - StartAddress +=3D sizeof (UINT16); - Size -=3D sizeof (UINT16); - Buffer =3D (UINT16*)Buffer + 1; - } - - while (Size >=3D sizeof (UINT32)) { - // - // Write as many double words as possible - // - PciExpressWrite32 (StartAddress, ReadUnaligned32 ((UINT32*)Buffer)); - StartAddress +=3D sizeof (UINT32); - Size -=3D sizeof (UINT32); - Buffer =3D (UINT32*)Buffer + 1; - } - - if (Size >=3D sizeof (UINT16)) { - // - // Write the last remaining word if exist - // - PciExpressWrite16 (StartAddress, ReadUnaligned16 ((UINT16*)Buffer)); - StartAddress +=3D sizeof (UINT16); - Size -=3D sizeof (UINT16); - Buffer =3D (UINT16*)Buffer + 1; - } - - if (Size >=3D sizeof (UINT8)) { - // - // Write the last remaining byte if exist - // - PciExpressWrite8 (StartAddress, *(UINT8*)Buffer); - } - - return ReturnValue; -} diff --git a/Silicon/ARM/NeoverseN1Soc/Library/NeoverseN1SocPciExpressLib/P= ciExpressLib.inf b/Silicon/ARM/NeoverseN1Soc/Library/NeoverseN1SocPciExpres= sLib/PciExpressLib.inf deleted file mode 100644 index acb6fb6219..0000000000 --- a/Silicon/ARM/NeoverseN1Soc/Library/NeoverseN1SocPciExpressLib/PciExpre= ssLib.inf +++ /dev/null @@ -1,56 +0,0 @@ -## @file -# Instance of PCI Express Library using the 256 MB PCI Express MMIO windo= w. -# -# PCI Express Library that uses the 256 MB PCI Express MMIO window to per= form -# PCI Configuration cycles. Layers on top of an I/O Library instance. -# -# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved. -# -# This library is inherited from MdePkg/Library/BasePciExpressLib. On -# NeoverseN1 SoC, with the unmodified version of this library, a slave er= ror is -# generated when host accesses the config space of a non-available device= or -# unimplemented function on a given bus. In order to resolve this for -# NeoverseN1 SoC, a modified version of the MdePkg/Library/BasePciExpress= Lib -# library is used. The modification includes a check to determine whether= the -# incoming PCI address can be safely accessed. -# -# In addition to this, the NeoverseN1 SoC has two other limitations which -# affect the access to the PCIe root port: -# 1. ECAM space is not contiguous, root port ECAM (BDF =3D 0:0:0) is is= olated -# from rest of the downstream hierarchy ECAM space. -# 2. Root port ECAM space is not capable of 8bit/16bit writes. -# This library includes workaround for these limitations as well. -# -# Copyright (c) 2020, ARM Limited. All rights reserved. -# -# SPDX-License-Identifier: BSD-2-Clause-Patent -# -## - -[Defines] - INF_VERSION =3D 0x0001001A - BASE_NAME =3D BasePciExpressLib - FILE_GUID =3D b378dd06-de7f-4e8c-8fb0-5126adfb34bf - MODULE_TYPE =3D BASE - VERSION_STRING =3D 1.0 - LIBRARY_CLASS =3D PciExpressLib - -[Sources] - PciExpressLib.c - -[Packages] - MdePkg/MdePkg.dec - Silicon/ARM/NeoverseN1Soc/NeoverseN1Soc.dec - -[FixedPcd] - gArmNeoverseN1SocTokenSpaceGuid.PcdPcieRootPortConfigBaseAddress - gArmNeoverseN1SocTokenSpaceGuid.PcdPcieRootPortConfigBaseSize - -[LibraryClasses] - BaseLib - DebugLib - IoLib - PcdLib - -[Pcd] - gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseAddress ## CONSUMES --=20 2.17.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 (#85969): https://edk2.groups.io/g/devel/message/85969 Mute This Topic: https://groups.io/mt/88606332/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-