audk/MdeModulePkg
Heyi Guo 74d0a339b8 MdeModulePkg/PciHostBridgeDxe: Add support for address translation
PCI address translation is necessary for some non-x86 platforms. On
such platforms, address value (denoted as "device address" or "address
in PCI view") set to PCI BAR registers in configuration space might be
different from the address which is used by CPU to access the
registers in memory BAR or IO BAR spaces (denoted as "host address" or
"address in CPU view"). The difference between the two addresses is
called "Address Translation Offset" or simply "translation", and can
be represented by "Address Translation Offset" in ACPI QWORD Address
Space Descriptor (Offset 0x1E). However UEFI and ACPI differs on the
definitions of QWORD Address Space Descriptor, and we will follow UEFI
definition on UEFI protocols, such as PCI root bridge IO protocol and
PCI IO protocol. In UEFI 2.7, "Address Translation Offset" is "Offset
to apply to the Starting address to convert it to a PCI address". This
means:

1. Translation = device address - host address.

2. PciRootBridgeIo->Configuration should return CPU view address, as
well as PciIo->GetBarAttributes.

Summary of addresses used in protocol interfaces and internal
implementations:

1. *Only* the following protocol interfaces assume Address is Device
   Address:
(1). PciHostBridgeResourceAllocation.GetProposedResources()
     Otherwise PCI bus driver cannot set correct address into PCI
     BARs.
(2). PciRootBridgeIo.Mem.Read() and PciRootBridgeIo.Mem.Write()
(3). PciRootBridgeIo.CopyMem()
UEFI and PI spec have clear statements for all other protocol
interfaces about the address type.

2. Library interfaces and internal implementation:
(1). Base and Limit in PCI_ROOT_BRIDGE_APERTURE are device address.
     It is easy to check whether the address is below 4G or above 4G.
(2). Addresses in PCI_ROOT_BRIDGE_INSTANCE.ResAllocNode are host
     address, for they are allocated from GCD.
(3). Address passed to PciHostBridgeResourceConflict is host address,
     for it comes from PCI_ROOT_BRIDGE_INSTANCE.ResAllocNode.

RESTRICTION: to simplify the situation, we require the alignment of
Translation must be larger than any BAR alignment in the same root
bridge, so that resource allocation alignment can be applied to both
device address and host address.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Heyi Guo <heyi.guo@linaro.org>
Signed-off-by: Yi Li <phoenix.liyi@huawei.com>
Reviewed-by: Ni Ruiyu <ruiyu.ni@intel.com>
Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
2018-03-15 08:26:05 +00:00
..
Application MdeModulePkg: Fix misuses of AllocateCopyPool 2017-11-08 17:13:03 +08:00
Bus MdeModulePkg/PciHostBridgeDxe: Add support for address translation 2018-03-15 08:26:05 +00:00
Core MdeModulePkg/PiSmmCore: fix mem alloc issues in heap guard 2018-03-14 16:15:27 +08:00
Include MdeModulePkg/PciHostBridgeLib.h: add address Translation 2018-03-15 08:26:05 +00:00
Library MdeModulePkg LockBoxLib: Support LOCK_BOX_ATTRIBUTE_RESTORE_IN_S3_ONLY 2018-03-08 21:33:48 +08:00
Logo MdeModulePkg/Logo.idf: Remove incorrect comments. 2018-02-28 15:30:23 +08:00
Universal MdeModulePkg/Mtftp4Dxe: Fix the incorrect return status. 2018-03-13 16:55:18 +08:00
MdeModulePkg.dec MdeModulePkg: Add S3SmmInitDone definition 2018-03-03 14:20:34 +08:00
MdeModulePkg.dsc MdeModulePkg/DxeCapsuleLibFmp: Use BmpSupportLib 2018-02-11 16:05:15 -08:00
MdeModulePkg.uni MdeModulePkg/ResetSystemPei: Add reset notifications in PEI 2018-02-09 15:30:01 +08:00
MdeModulePkgExtra.uni MdeModulePkg: Convert all .uni files to utf-8 2015-12-15 04:56:23 +00:00