Re: [edk2] [PATCH edk2-platforms 07/12] Hisilicon: add PciHostBridgeLib
On 21 March 2018 at 01:03, Heyi Guowrote: > This is to prepare for switching to generic PciHostBridge, and > PciHostBridgeLib is needed by PciHostBridge driver. > > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Heyi Guo > Cc: Ard Biesheuvel > Cc: Leif Lindholm > Cc: Michael D Kinney > --- > Platform/Hisilicon/Library/PciHostBridgeLib/PciHostBridgeLib.inf | 51 > Platform/Hisilicon/Library/PciHostBridgeLib/PciHostBridgeLib.c | 304 > > 2 files changed, 355 insertions(+) > > diff --git a/Platform/Hisilicon/Library/PciHostBridgeLib/PciHostBridgeLib.inf > b/Platform/Hisilicon/Library/PciHostBridgeLib/PciHostBridgeLib.inf > new file mode 100644 > index ..dd451cff332c > --- /dev/null > +++ b/Platform/Hisilicon/Library/PciHostBridgeLib/PciHostBridgeLib.inf > @@ -0,0 +1,51 @@ > +## @file > +# PCI Host Bridge Library instance for Hisilicon D0x > +# > +# Copyright (c) 2018, Hisilicon Limited. All rights reserved. > +# Copyright (c) 2017 - 2018, Linaro Ltd. All rights reserved. > +# > +# This program and the accompanying materials are licensed and made > available > +# under the terms and conditions of the BSD License which accompanies this > +# distribution. The full text of the license may be found at > +# http://opensource.org/licenses/bsd-license.php > +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, > +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR > +# IMPLIED. > +# > +# > +## > + > +[Defines] > + INF_VERSION= 0x0001000A > + BASE_NAME = PciHostBridgeLib > + FILE_GUID = e5c91e8a-0b2b-11e8-9533-286ed489ee9b > + MODULE_TYPE= DXE_DRIVER > + VERSION_STRING = 1.0 > + LIBRARY_CLASS = PciHostBridgeLib|DXE_DRIVER > + > +# > +# The following information is for reference only and not required by the > build > +# tools. > +# > +# VALID_ARCHITECTURES = AARCH64 ARM > +# > + > +[Sources] > + PciHostBridgeLib.c > + > +[Packages] > + MdeModulePkg/MdeModulePkg.dec > + MdePkg/MdePkg.dec > + Silicon/Hisilicon/HisiPkg.dec > + > +[LibraryClasses] > + BaseLib > + BaseMemoryLib > + DebugLib > + DevicePathLib > + MemoryAllocationLib > + OemMiscLib > + > +[Pcd] > + gHisiTokenSpaceGuid.PcdPcieRootBridgeMask > + gHisiTokenSpaceGuid.PcdPcieRootBridgeMask2P > diff --git a/Platform/Hisilicon/Library/PciHostBridgeLib/PciHostBridgeLib.c > b/Platform/Hisilicon/Library/PciHostBridgeLib/PciHostBridgeLib.c > new file mode 100644 > index ..6aff5cdd3d76 > --- /dev/null > +++ b/Platform/Hisilicon/Library/PciHostBridgeLib/PciHostBridgeLib.c > @@ -0,0 +1,304 @@ > +/** @file > + PCI Host Bridge Library instance for Hisilicon D0x > + > + Copyright (c) 2018, Hisilicon Limited. All rights reserved. > + Copyright (c) 2017 - 2018, Linaro Ltd. All rights reserved. > + > + This program and the accompanying materials are licensed and made available > + under the terms and conditions of the BSD License which accompanies this > + distribution. The full text of the license may be found at > + http://opensource.org/licenses/bsd-license.php. > + > + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, > WITHOUT > + WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. > + > +**/ > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +#include > +#include > + > + > +#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 = { > + { > +{ > + ACPI_DEVICE_PATH, > + ACPI_DP, > + { > +(UINT8) (sizeof(ACPI_HID_DEVICE_PATH)), > +(UINT8) ((sizeof(ACPI_HID_DEVICE_PATH)) >> 8) > + } > +}, > +EISA_PNP_ID(0x0A03), // PCI > +0 > + }, { > +END_DEVICE_PATH_TYPE, > +END_ENTIRE_DEVICE_PATH_SUBTYPE, > +{ > + END_DEVICE_PATH_LENGTH, > + 0 > +} > + } > +}; > + > +STATIC PCI_ROOT_BRIDGE mRootBridgeTemplate = { > + 0, // Segment > + 0, // Supports > + 0, // Attributes > + TRUE, // DmaAbove4G > + FALSE, // NoExtendedConfigSpace > + FALSE, // ResourceAssigned > + EFI_PCI_HOST_BRIDGE_COMBINE_MEM_PMEM | // AllocationAttributes > + EFI_PCI_HOST_BRIDGE_MEM64_DECODE, > + { > +// Bus > +0, > +0 > + },
[edk2] [PATCH edk2-platforms 07/12] Hisilicon: add PciHostBridgeLib
This is to prepare for switching to generic PciHostBridge, and PciHostBridgeLib is needed by PciHostBridge driver. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Heyi GuoCc: Ard Biesheuvel Cc: Leif Lindholm Cc: Michael D Kinney --- Platform/Hisilicon/Library/PciHostBridgeLib/PciHostBridgeLib.inf | 51 Platform/Hisilicon/Library/PciHostBridgeLib/PciHostBridgeLib.c | 304 2 files changed, 355 insertions(+) diff --git a/Platform/Hisilicon/Library/PciHostBridgeLib/PciHostBridgeLib.inf b/Platform/Hisilicon/Library/PciHostBridgeLib/PciHostBridgeLib.inf new file mode 100644 index ..dd451cff332c --- /dev/null +++ b/Platform/Hisilicon/Library/PciHostBridgeLib/PciHostBridgeLib.inf @@ -0,0 +1,51 @@ +## @file +# PCI Host Bridge Library instance for Hisilicon D0x +# +# Copyright (c) 2018, Hisilicon Limited. All rights reserved. +# Copyright (c) 2017 - 2018, Linaro Ltd. All rights reserved. +# +# This program and the accompanying materials are licensed and made available +# under the terms and conditions of the BSD License which accompanies this +# distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR +# IMPLIED. +# +# +## + +[Defines] + INF_VERSION= 0x0001000A + BASE_NAME = PciHostBridgeLib + FILE_GUID = e5c91e8a-0b2b-11e8-9533-286ed489ee9b + MODULE_TYPE= DXE_DRIVER + VERSION_STRING = 1.0 + LIBRARY_CLASS = PciHostBridgeLib|DXE_DRIVER + +# +# The following information is for reference only and not required by the build +# tools. +# +# VALID_ARCHITECTURES = AARCH64 ARM +# + +[Sources] + PciHostBridgeLib.c + +[Packages] + MdeModulePkg/MdeModulePkg.dec + MdePkg/MdePkg.dec + Silicon/Hisilicon/HisiPkg.dec + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + DevicePathLib + MemoryAllocationLib + OemMiscLib + +[Pcd] + gHisiTokenSpaceGuid.PcdPcieRootBridgeMask + gHisiTokenSpaceGuid.PcdPcieRootBridgeMask2P diff --git a/Platform/Hisilicon/Library/PciHostBridgeLib/PciHostBridgeLib.c b/Platform/Hisilicon/Library/PciHostBridgeLib/PciHostBridgeLib.c new file mode 100644 index ..6aff5cdd3d76 --- /dev/null +++ b/Platform/Hisilicon/Library/PciHostBridgeLib/PciHostBridgeLib.c @@ -0,0 +1,304 @@ +/** @file + PCI Host Bridge Library instance for Hisilicon D0x + + Copyright (c) 2018, Hisilicon Limited. All rights reserved. + Copyright (c) 2017 - 2018, Linaro Ltd. All rights reserved. + + This program and the accompanying materials are licensed and made available + under the terms and conditions of the BSD License which accompanies this + distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php. + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT + WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + + +#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 = { + { +{ + ACPI_DEVICE_PATH, + ACPI_DP, + { +(UINT8) (sizeof(ACPI_HID_DEVICE_PATH)), +(UINT8) ((sizeof(ACPI_HID_DEVICE_PATH)) >> 8) + } +}, +EISA_PNP_ID(0x0A03), // PCI +0 + }, { +END_DEVICE_PATH_TYPE, +END_ENTIRE_DEVICE_PATH_SUBTYPE, +{ + END_DEVICE_PATH_LENGTH, + 0 +} + } +}; + +STATIC PCI_ROOT_BRIDGE mRootBridgeTemplate = { + 0, // Segment + 0, // Supports + 0, // Attributes + TRUE, // DmaAbove4G + FALSE, // NoExtendedConfigSpace + FALSE, // ResourceAssigned + EFI_PCI_HOST_BRIDGE_COMBINE_MEM_PMEM | // AllocationAttributes + EFI_PCI_HOST_BRIDGE_MEM64_DECODE, + { +// Bus +0, +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 *) +}; + +STATIC +EFI_STATUS +ConstructRootBridge ( +PCI_ROOT_BRIDGE