From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (NAM12-MW2-obe.outbound.protection.outlook.com [40.107.244.126]) by mx.groups.io with SMTP id smtpd.web10.9746.1637167821741099374 for ; Wed, 17 Nov 2021 08:50:21 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@os.amperecomputing.com header.s=selector2 header.b=Br4wIb9v; spf=pass (domain: os.amperecomputing.com, ip: 40.107.244.126, mailfrom: nhi@os.amperecomputing.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ddTUwUlN4NVUES/DFCwNaqwILLA/r5Vgk9z7tHqtEdeT7VO+Th8JpAPP0FBWuXVf/eR+tjIlzHtS0jd2DI+7TWzzFnfXW70M8CpyY744EbDJ1LhnfD676/j7yRL4WrhlxYKViunSFo1vSxX5JnBrtu7NwE01scrh77pdIEW1R4kzLGJcTJpBFIP8d8Q4M8JnYEihZNa8owGpVK2ZtwwSRlXdBjqpZgNikxq/DrzN5+dzKkAYrJj6W8ejICWPrfbA3DjuqVBHynVAlKoVG7xYFFlU+OdlUS7cuCUcGWOqAHBvQs629Xt2zs3VJO7YOik+VIcwqBJ7aXSwvwBwxiXrlQ== 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=Sz4XJDfSLrk2dbtDQNnXqblZna7OXZrdjwDmj8Dy2Io=; b=G/u3rzHUln99WQIyK6ADzJ9i7LsfiFxCoeIZWYBLJBugQz/Y0yv149ANtaD8hRUWEiczDar8JmkztcQlLvQboICaEwtoOn3IysAWUytG7ekJJBAalL+JK8tuQju9W2YPiogu3SE7QuUBB45ByiBF4/tLYoGJ9rUHC3nKZpxfpP92fcwiletTaabI9j+YkDh8ObGdUXYUjaOVWZmBuvTP2TW0JQAVQHCZuvrKK/fywAXReKtSc+KmL7Ytw9iQECLeoriQ+iXZRwgjhololWamXfaQfJk1uxbiIxrtIAlgSQBAAnHZNQOuAyK0LX4ZjGrz283Bq7qtoLTtBq2q/7tsRQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=os.amperecomputing.com; dmarc=pass action=none header.from=os.amperecomputing.com; dkim=pass header.d=os.amperecomputing.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=os.amperecomputing.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Sz4XJDfSLrk2dbtDQNnXqblZna7OXZrdjwDmj8Dy2Io=; b=Br4wIb9vcjUcmSVo911i+SIJDl//IeFuYPQba8cQUBYpg/TGUeii5YU1HGC6k4+JBbN59IrSyEOGucc56/g3R1ubKI6Z39GHjJNBJqaFsMRYcbY0/JotmNS69Wi4zxYXoHvSm2yz30G/1HGRMItG8ZSURVscLSYIVzs7Fotf4m4= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=os.amperecomputing.com; Received: from PH0PR01MB7287.prod.exchangelabs.com (2603:10b6:510:10a::21) by PH0PR01MB6454.prod.exchangelabs.com (2603:10b6:510:1b::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4713.20; Wed, 17 Nov 2021 16:50:20 +0000 Received: from PH0PR01MB7287.prod.exchangelabs.com ([fe80::254c:9533:7f35:aee]) by PH0PR01MB7287.prod.exchangelabs.com ([fe80::254c:9533:7f35:aee%4]) with mapi id 15.20.4713.019; Wed, 17 Nov 2021 16:50:20 +0000 From: "Nhi Pham" To: devel@edk2.groups.io CC: patches@amperecomputing.com, nhi@os.amperecomputing.com, vunguyen@os.amperecomputing.com, Thang Nguyen , Chuong Tran , Phong Vo , Leif Lindholm , Michael D Kinney , Ard Biesheuvel , Nate DeSimone Subject: [edk2-platforms][PATCH v5 14/30] AmpereAltraPkg: Add PciHostBridgeLib library instance Date: Wed, 17 Nov 2021 23:47:11 +0700 Message-ID: <20211117164727.10922-15-nhi@os.amperecomputing.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211117164727.10922-1-nhi@os.amperecomputing.com> References: <20211117164727.10922-1-nhi@os.amperecomputing.com> X-ClientProxiedBy: HKAPR04CA0001.apcprd04.prod.outlook.com (2603:1096:203:d0::11) To PH0PR01MB7287.prod.exchangelabs.com (2603:10b6:510:10a::21) Return-Path: nhi@os.amperecomputing.com MIME-Version: 1.0 Received: from sw004.amperecomputing.com (118.69.219.201) by HKAPR04CA0001.apcprd04.prod.outlook.com (2603:1096:203:d0::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4713.21 via Frontend Transport; Wed, 17 Nov 2021 16:50:17 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b965a43d-a991-41ce-1f14-08d9a9ea5750 X-MS-TrafficTypeDiagnostic: PH0PR01MB6454: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:660; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: G245O9bOSvJMMdWv68fEDtWACCCGYTYhHhpOjpdz+DSxIuo3/WuW1r+PpiCaYnJahw4seS0Cu+P3j63G1Mwy9SdbsKP9JQJ9Y0RDh4FwGKpsCRAimiu20ku4Q0U06DLgGRLNzCsTTFYaKc/QDObG1Q8tUDN4LGVKQ4/NsK32mSVcQu5k6fU0L3BGojeSZnjBOGki0yRmnviHXIxfSqHQ2TmdK7Aye8JzTsclNgpdOi7FC67FyZ1XWiSS+mA1aho2K0AZ4xrK736E4iahvyDJI4H4idfR3byScJMCyMoUjeAEkgsOWzcHczAHK8hAIRz76DBAQmMrZtPQReClADvraDbKnMiYr368nsypYVRWRRsDyryamIE+/aByoRZWhd65mWrAT87fRts/gvaay22MKbFLsbmLbguRJRcfPMiZ2Br8kAzOqTVdVK4ubLqe5X5KJz1WVIqTIM/DxdsqKnMHfWa2xwOB3dYuogOMbnHM/2FQplouUHE+m/AZgItdfg1pXAeCTLJJofLZivqzUwMDW/GZIx2qY5GopH2WylFyxu5TLfcZD88lq0EvN6GMhDH1lgt929raCf/SXUeDr7aLCDcct5Bis4we4MLzdWImU2PGpIAPV60UphNUaIqpD90+1h3PyDMXmKqvBLABFe4QxHU2haSusWeRCPVGQQeaP2fIYbj7FLz8kLvdoOZHl9erUNKN9YCO4uyPzE5D8c1Owg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PH0PR01MB7287.prod.exchangelabs.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(6666004)(8936002)(66476007)(52116002)(186003)(86362001)(2906002)(1076003)(83380400001)(54906003)(4326008)(66556008)(26005)(38100700002)(38350700002)(19627235002)(30864003)(6506007)(6916009)(6486002)(2616005)(956004)(5660300002)(6512007)(316002)(8676002)(66946007)(508600001);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?ACmQNPG+4UvzdITjZlU2wlbDGnMXQ9lv+5UsX4t6Qqu2LymrFMWbvYm4Bj4y?= =?us-ascii?Q?7wVADtFwB243+RdKjpLSD0C0FrRfWr6Gv3FK1F2QT9iU+MAElIBNzqX0Soof?= =?us-ascii?Q?DUjEWc3ROvQn3e1XvaiaC4e2SsZyC7FwiHX9jAd+t1OyEX/ddrf/lCLXoALK?= =?us-ascii?Q?Ng8nf/vhn/xGzsfRWFtbhrKGnIT2XGvUtYD6YwZ0EYLm3Q7NC8sf7M89AN9X?= =?us-ascii?Q?wa46AWVWTo/DMwJIiEgf2VlqbUP0orYXPm9vP3hhJa20hMdY9CYT5RKPfgkz?= =?us-ascii?Q?8MrWtCGeMDfCFCxAQcWFrZDS0M6xvqDQgsOUMUuxhmVVSza85+IyBpnTBq+w?= =?us-ascii?Q?3O6x8HMS3LbhWDSiiFak2oWU1Lh7YSRGHhSUf2J/2ZqbhVcyTRbEWw+lyyEV?= =?us-ascii?Q?JeYPpsO4fb78vqWnDCcQ3ErJjyb4rZPNrYWAbUG3Cbnoz8kyM0WhS9ehRBSa?= =?us-ascii?Q?FJkmzgJpEhuT9FXJkNotwjujD6qVeoGhBmuvwLNnEERGNJorymfwKXRe2svO?= =?us-ascii?Q?LtzpA51W2qzoc+dp6MKvWoDz69TAntAHPP7bxUzs+kL/hi5GUXG9DktMgn+h?= =?us-ascii?Q?/IakRAym2xqDfT4lEabCNFUZtAwwCypLnoqq4nFbPY7PUvpsVV7iGXP3xuqO?= =?us-ascii?Q?z+Eb4uEZWLH8Gs/sWDD3Vkn0txj61StZrIA9TF2+MhVO38bXBI1yHW5r5iWm?= =?us-ascii?Q?APcKoMRWJAvs/9XrjUEPhIGuw5sX6zg7CcUPp3dXGoDah/iv9dEuSwGcErs9?= =?us-ascii?Q?6m5TE4gRFu2qitoG6rxN0zFKGmUpr1F2MrZeIQm6Y0FT8tyjkyiJTtNixDPK?= =?us-ascii?Q?JJLfBt5HhAGrj1yXwDjdNUn8Z82Rvi/p0sXQKAGju/R3evnUU6hUPtDv1kce?= =?us-ascii?Q?zXXLL5vLE13iy/T4d/bXXtmInRlB76qxLsTOoUFygaWFBuizEMCfizkAGDEp?= =?us-ascii?Q?ALp3+6G9U6/mDDIXWi+PMhXfhOTYUGoSRd2F9/zjaRABr9knm3jtAKrMmxOr?= =?us-ascii?Q?GJP8haf6mMzPv+zmb9NVoVtn+tVyjBH7bco9hC0hEMRosqQO5aaT7lR+P2X8?= =?us-ascii?Q?95RUHYO4SO3kM4Ns9jh52rX/gSyKaqsrWjGztwzlGraL3RWKSRNSws4Ykrv8?= =?us-ascii?Q?sjYjWCv7bpym45qI1QfEA8QFx2h2a0VVNvDtoqpIalFKhUL2swqFQOKG1vXK?= =?us-ascii?Q?Pqh20Tyickyh8U/9YvsquMWHmg3q1IXiXX3cG9Hj6ZY741zXKgjF9SIi5+PV?= =?us-ascii?Q?xoudN6m0IFraKAjzx1IQPEnzxwkMsv1+BvVRwIofYbQ22R0biLztntvYdL75?= =?us-ascii?Q?0vtI0JJBcNRn2zWG0h52fsxHfHISokVQNpKNTprg4FrMAwj5L+CCARGplh5z?= =?us-ascii?Q?jUFQ4qwkBIQ+HQZO7DBuIy6gFp5EjbnmSwU2gDLd82HMtGn39RXmtyw62TrA?= =?us-ascii?Q?oGaya/TTLxYQBM144SMpkxeQsAazJWRqTWdbanD+Ugh+EQdakKpqKfcFigtt?= =?us-ascii?Q?Ov9VKGYoTXVvd5Tq37keMr1ocZxuCmzL3Nd2HsGPRn2TVoknvq0sArZm3Tmb?= =?us-ascii?Q?sTwzN3OtFKpIYMQ4GmuEaBuVpAcG9REjHLH5uEa0HfQkAOavES2NxW2LdiQQ?= =?us-ascii?Q?V8VeTj/8SbjiuErW6Jweb79VdBFiHvdyTYhIcP6UG4R5qhkjfUxdVhDNwRMu?= =?us-ascii?Q?C6zFgF0hWqgHm1cJDBhcc3+DlU0=3D?= X-OriginatorOrg: os.amperecomputing.com X-MS-Exchange-CrossTenant-Network-Message-Id: b965a43d-a991-41ce-1f14-08d9a9ea5750 X-MS-Exchange-CrossTenant-AuthSource: PH0PR01MB7287.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Nov 2021 16:50:20.5251 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3bc2b170-fd94-476d-b0ce-4229bdc904a7 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: vbU3II/TgexX0ZA67S1lNGeLzij278gfWqC9IddgA3Py+kT8GQxhP0zBTlKByN/jiGToZJEYCPj9t26vq0S/QgkWfOXYNcFuV2HzswgPGOU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR01MB6454 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain From: Vu Nguyen Provides the number of supported RootBridges and the resource allocated for each RootBridge. These information are essential to the HostBridge driver to initialize the PCIe subsystem. Cc: Thang Nguyen Cc: Chuong Tran Cc: Phong Vo Cc: Leif Lindholm Cc: Michael D Kinney Cc: Ard Biesheuvel Cc: Nate DeSimone Signed-off-by: Nhi Pham Reviewed-by: Leif Lindholm --- Silicon/Ampere/AmpereAltraPkg/AmpereAltraPkg.dsc.inc = | 1 + Silicon/Ampere/AmpereAltraPkg/Library/PciHostBridgeLib/PciHostBridgeLib.in= f | 39 +++ Silicon/Ampere/AmpereAltraPkg/Include/Platform/Ac01.h = | 5 + Silicon/Ampere/AmpereAltraPkg/Library/PciHostBridgeLib/PciHostBridgeLib.c = | 256 ++++++++++++++++++++ 4 files changed, 301 insertions(+) diff --git a/Silicon/Ampere/AmpereAltraPkg/AmpereAltraPkg.dsc.inc b/Silicon= /Ampere/AmpereAltraPkg/AmpereAltraPkg.dsc.inc index b08bdd82177e..e13777934173 100644 --- a/Silicon/Ampere/AmpereAltraPkg/AmpereAltraPkg.dsc.inc +++ b/Silicon/Ampere/AmpereAltraPkg/AmpereAltraPkg.dsc.inc @@ -225,6 +225,7 @@ [LibraryClasses.common.DXE_DRIVER] SecurityManagementLib|MdeModulePkg/Library/DxeSecurityManagementLib/DxeS= ecurityManagementLib.inf PerformanceLib|MdeModulePkg/Library/DxePerformanceLib/DxePerformanceLib.= inf MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAll= ocationLib.inf + PciHostBridgeLib|Silicon/Ampere/AmpereAltraPkg/Library/PciHostBridgeLib/= PciHostBridgeLib.inf =20 [LibraryClasses.common.UEFI_APPLICATION] UefiDecompressLib|MdePkg/Library/BaseUefiDecompressLib/BaseUefiTianoCust= omDecompressLib.inf diff --git a/Silicon/Ampere/AmpereAltraPkg/Library/PciHostBridgeLib/PciHost= BridgeLib.inf b/Silicon/Ampere/AmpereAltraPkg/Library/PciHostBridgeLib/PciH= ostBridgeLib.inf new file mode 100644 index 000000000000..fdc7ea8862dc --- /dev/null +++ b/Silicon/Ampere/AmpereAltraPkg/Library/PciHostBridgeLib/PciHostBridgeL= ib.inf @@ -0,0 +1,39 @@ +## @file +# +# Copyright (c) 2021, Ampere Computing LLC. All rights reserved.
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + INF_VERSION =3D 0x0001001B + BASE_NAME =3D PciHostBridgeLib + FILE_GUID =3D 9D0522E5-B5FD-4E3F-9D10-52AE221FA314 + MODULE_TYPE =3D DXE_DRIVER + VERSION_STRING =3D 1.0 + LIBRARY_CLASS =3D PciHostBridgeLib|DXE_DRIVER + +[Sources] + PciHostBridgeLib.c + +[Packages] + MdeModulePkg/MdeModulePkg.dec + MdePkg/MdePkg.dec + Silicon/Ampere/AmpereAltraPkg/AmpereAltraPkg.dec + +[LibraryClasses] + BaseMemoryLib + DebugLib + DevicePathLib + HobLib + MemoryAllocationLib + +[Guids] + gRootComplexInfoHobGuid + +[Protocols] + gEfiCpuIo2ProtocolGuid ## CONSUMES + +[Depex] + gEfiCpuIo2ProtocolGuid diff --git a/Silicon/Ampere/AmpereAltraPkg/Include/Platform/Ac01.h b/Silico= n/Ampere/AmpereAltraPkg/Include/Platform/Ac01.h index f3e6b4041737..132c0d6d6cac 100644 --- a/Silicon/Ampere/AmpereAltraPkg/Include/Platform/Ac01.h +++ b/Silicon/Ampere/AmpereAltraPkg/Include/Platform/Ac01.h @@ -239,6 +239,11 @@ // #define AC01_PCIE_MAX_RCS_PER_SOCKET 8 =20 +// +// The size of IO space +// +#define AC01_PCIE_IO_SIZE 0x2000 + // // The base address of {TCU, CSR, MMCONFIG} Registers // diff --git a/Silicon/Ampere/AmpereAltraPkg/Library/PciHostBridgeLib/PciHost= BridgeLib.c b/Silicon/Ampere/AmpereAltraPkg/Library/PciHostBridgeLib/PciHos= tBridgeLib.c new file mode 100644 index 000000000000..cf0f0ee32147 --- /dev/null +++ b/Silicon/Ampere/AmpereAltraPkg/Library/PciHostBridgeLib/PciHostBridgeL= ib.c @@ -0,0 +1,256 @@ +/** @file + PCI Host Bridge Library instance for Ampere Altra-based platforms. + + Copyright (c) 2021, Ampere Computing LLC. All rights reserved.
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +GLOBAL_REMOVE_IF_UNREFERENCED +STATIC CHAR16 CONST * CONST mPciHostBridgeLibAcpiAddressSpaceTypeStr[] =3D= { + L"Mem", L"I/O", L"Bus" +}; + +#pragma pack(1) +typedef struct { + ACPI_HID_DEVICE_PATH AcpiDevicePath; + EFI_DEVICE_PATH_PROTOCOL EndDevicePath; +} EFI_PCI_ROOT_BRIDGE_DEVICE_PATH; +#pragma pack () + +STATIC EFI_PCI_ROOT_BRIDGE_DEVICE_PATH mEfiPciRootBridgeDevicePath =3D { + { + { + ACPI_DEVICE_PATH, + ACPI_DP, + { + (UINT8)(sizeof (ACPI_HID_DEVICE_PATH)), + (UINT8)((sizeof (ACPI_HID_DEVICE_PATH)) >> 8) + } + }, + EISA_PNP_ID (0x0A08), // PCIe + 0 + }, { + END_DEVICE_PATH_TYPE, + END_ENTIRE_DEVICE_PATH_SUBTYPE, + { + END_DEVICE_PATH_LENGTH, + 0 + } + } +}; + +STATIC PCI_ROOT_BRIDGE mRootBridgeTemplate =3D { + 0, // Segment + 0, // Supports + 0, // Attributes + TRUE, // DmaAbove4G + FALSE, // NoExtendedConfigSpace + FALSE, // ResourceAssigned + EFI_PCI_HOST_BRIDGE_MEM64_DECODE, + { + // Bus + 0, + 0xFF, + 0 + }, { + // Io + 0, + 0, + 0 + }, { + // Mem + MAX_UINT64, + 0, + 0 + }, { + // MemAbove4G + MAX_UINT64, + 0, + 0 + }, { + // PMem + MAX_UINT64, + 0, + 0 + }, { + // PMemAbove4G + MAX_UINT64, + 0, + 0 + }, + (EFI_DEVICE_PATH_PROTOCOL *)&mEfiPciRootBridgeDevicePath +}; + +/** + Return all the root bridge instances in an array. + + @param Count Return the count of root bridge instances. + + @return All the root bridge instances in an array. + The array should be passed into PciHostBridgeFreeRootBridges() + when it's not used. +**/ +PCI_ROOT_BRIDGE * +EFIAPI +PciHostBridgeGetRootBridges ( + UINTN *Count + ) +{ + AC01_ROOT_COMPLEX *RootComplex; + AC01_ROOT_COMPLEX *RootComplexList; + EFI_PCI_ROOT_BRIDGE_DEVICE_PATH *DevicePath; + PCI_ROOT_BRIDGE *RootBridge; + PCI_ROOT_BRIDGE *RootBridges; + UINT8 Index; + UINT8 RootBridgeCount =3D 0; + VOID *Hob; + + Hob =3D GetFirstGuidHob (&gRootComplexInfoHobGuid); + if (Hob =3D=3D NULL) { + return NULL; + } + + RootComplexList =3D (AC01_ROOT_COMPLEX *)GET_GUID_HOB_DATA (Hob); + + RootBridges =3D AllocatePool (AC01_PCIE_MAX_ROOT_COMPLEX * sizeof (PCI_R= OOT_BRIDGE)); + if (RootBridges =3D=3D NULL) { + DEBUG ((DEBUG_ERROR, "%a: Failed to allocate RootBridges\n", __FUNCTIO= N__)); + return NULL; + } + + for (Index =3D 0; Index < AC01_PCIE_MAX_ROOT_COMPLEX; Index++) { + RootComplex =3D &RootComplexList[Index]; + if (!RootComplex->Active) { + continue; + } + RootBridge =3D &RootBridges[RootBridgeCount]; + CopyMem (RootBridge, &mRootBridgeTemplate, sizeof (PCI_ROOT_BRIDGE)); + + if (RootComplex->Mmio32Base !=3D 0) { + RootBridge->Mem.Base =3D RootComplex->Mmio32Base; + RootBridge->Mem.Limit =3D RootComplex->Mmio32Base + RootComplex->Mmi= o32Size - 1; + RootBridge->PMem.Base =3D RootBridge->Mem.Base; + RootBridge->PMem.Limit =3D RootBridge->Mem.Limit; + RootBridge->Io.Base =3D RootComplex->Mmio32Base + RootComplex->Mmio3= 2Size - AC01_PCIE_IO_SIZE; + RootBridge->Io.Limit =3D RootBridge->Mem.Limit; + } + + if (RootComplex->MmioBase !=3D 0) { + RootBridge->PMemAbove4G.Base =3D RootComplex->MmioBase; + RootBridge->PMemAbove4G.Limit =3D RootComplex->MmioBase + RootComple= x->MmioSize - 1; + } + + RootBridge->Segment =3D RootComplex->Logical; + + DevicePath =3D AllocateCopyPool ( + sizeof (EFI_PCI_ROOT_BRIDGE_DEVICE_PATH), + (VOID *)&mEfiPciRootBridgeDevicePath + ); + if (DevicePath =3D=3D NULL) { + DEBUG ((DEBUG_ERROR, "%a: Failed to allocate device path\n", __FUNCT= ION__)); + return NULL; + } + + // + // Embedded the Root Complex Index into the DevicePath + // This will be used later by the platform NotifyPhase() + // + DevicePath->AcpiDevicePath.UID =3D Index; + + RootBridge->DevicePath =3D (EFI_DEVICE_PATH_PROTOCOL *)DevicePath; + RootBridgeCount++; + } + + *Count =3D RootBridgeCount; + return RootBridges; +} + +/** + Free the root bridge instances array returned from PciHostBridgeGetRootB= ridges(). + + @param Bridges The root bridge instances array. + @param Count The count of the array. +**/ +VOID +EFIAPI +PciHostBridgeFreeRootBridges ( + PCI_ROOT_BRIDGE *Bridges, + UINTN Count + ) +{ + // + // Unsupported + // +} + +/** + Inform the platform that the resource conflict happens. + + @param HostBridgeHandle Handle of the Host Bridge. + @param Configuration Pointer to PCI I/O and PCI memory resource + descriptors. The Configuration contains the reso= urces + for all the root bridges. The resource for each = root + bridge is terminated with END descriptor and an + additional END is appended indicating the end of= the + entire resources. The resource descriptor field + values follow the description in + EFI_PCI_HOST_BRIDGE_RESOUrce_ALLOCATION_PROTOCOL + .SubmitResources(). +**/ +VOID +EFIAPI +PciHostBridgeResourceConflict ( + EFI_HANDLE HostBridgeHandle, + VOID *Configuration + ) +{ + EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *Descriptor; + UINTN RootBridgeIndex; + DEBUG ((DEBUG_ERROR, "PciHostBridge: Resource conflict happens!\n")); + + RootBridgeIndex =3D 0; + Descriptor =3D (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *)Configuration; + while (Descriptor->Desc =3D=3D ACPI_ADDRESS_SPACE_DESCRIPTOR) { + DEBUG ((DEBUG_ERROR, "RootBridge[%d]:\n", RootBridgeIndex++)); + for (; Descriptor->Desc =3D=3D ACPI_ADDRESS_SPACE_DESCRIPTOR; Descript= or++) { + ASSERT (Descriptor->ResType < + (sizeof (mPciHostBridgeLibAcpiAddressSpaceTypeStr) / + sizeof (mPciHostBridgeLibAcpiAddressSpaceTypeStr[0]) + ) + ); + DEBUG ((DEBUG_ERROR, " %s: Length/Alignment =3D 0x%lx / 0x%lx\n", + mPciHostBridgeLibAcpiAddressSpaceTypeStr[Descriptor->ResType= ], + Descriptor->AddrLen, Descriptor->AddrRangeMax + )); + if (Descriptor->ResType =3D=3D ACPI_ADDRESS_SPACE_TYPE_MEM) { + DEBUG ((DEBUG_ERROR, " Granularity/SpecificFlag =3D %ld / %02x= %s\n", + Descriptor->AddrSpaceGranularity, Descriptor->SpecificFlag= , + ((Descriptor->SpecificFlag & + EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_FLAG_CACHEABLE_PREFETC= HABLE + ) !=3D 0) ? L" (Prefetchable)" : L"" + )); + } + } + // + // Skip the END descriptor for root bridge + // + ASSERT (Descriptor->Desc =3D=3D ACPI_END_TAG_DESCRIPTOR); + Descriptor =3D (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *)( + (EFI_ACPI_END_TAG_DESCRIPTOR *)Descriptor + 1 + ); + } +} --=20 2.17.1