mirror of
https://github.com/acidanthera/audk.git
synced 2025-07-22 21:24:35 +02:00
ArmPkg/ArmDmaLib: add support for fixed host-to-device DMA offset
Some devices, such as the Raspberry Pi3, have a fixed offset between memory addresses as seen by the host and as seen by the other bus masters. So add a new PCD that allows this fixed offset to be recorded, and to be used when returning device addresses from the DmaLib mapping routines. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Tested-by: Ryan Harkin <ryan.harkin@linaro.org> Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>
This commit is contained in:
parent
df8c2668d7
commit
bfe34275a9
@ -134,6 +134,14 @@
|
|||||||
gArmTokenSpaceGuid.PcdFdSize|0|UINT32|0x0000002C
|
gArmTokenSpaceGuid.PcdFdSize|0|UINT32|0x0000002C
|
||||||
gArmTokenSpaceGuid.PcdFvSize|0|UINT32|0x0000002E
|
gArmTokenSpaceGuid.PcdFvSize|0|UINT32|0x0000002E
|
||||||
|
|
||||||
|
#
|
||||||
|
# Value to add to a host address to obtain a device address, using
|
||||||
|
# unsigned 64-bit integer arithmetic on both ARM and AArch64. This
|
||||||
|
# means we can rely on truncation on overflow to specify negative
|
||||||
|
# offsets.
|
||||||
|
#
|
||||||
|
gArmTokenSpaceGuid.PcdArmDmaDeviceOffset|0x0|UINT64|0x0000044
|
||||||
|
|
||||||
[PcdsFixedAtBuild.common, PcdsPatchableInModule.common]
|
[PcdsFixedAtBuild.common, PcdsPatchableInModule.common]
|
||||||
gArmTokenSpaceGuid.PcdFdBaseAddress|0|UINT64|0x0000002B
|
gArmTokenSpaceGuid.PcdFdBaseAddress|0|UINT64|0x0000002B
|
||||||
gArmTokenSpaceGuid.PcdFvBaseAddress|0|UINT64|0x0000002D
|
gArmTokenSpaceGuid.PcdFvBaseAddress|0|UINT64|0x0000002D
|
||||||
|
@ -37,6 +37,15 @@ typedef struct {
|
|||||||
|
|
||||||
STATIC EFI_CPU_ARCH_PROTOCOL *mCpu;
|
STATIC EFI_CPU_ARCH_PROTOCOL *mCpu;
|
||||||
|
|
||||||
|
STATIC
|
||||||
|
PHYSICAL_ADDRESS
|
||||||
|
HostToDeviceAddress (
|
||||||
|
IN PHYSICAL_ADDRESS HostAddress
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return HostAddress + PcdGet64 (PcdArmDmaDeviceOffset);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Provides the DMA controller-specific addresses needed to access system memory.
|
Provides the DMA controller-specific addresses needed to access system memory.
|
||||||
|
|
||||||
@ -80,7 +89,14 @@ DmaMap (
|
|||||||
return EFI_INVALID_PARAMETER;
|
return EFI_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
*DeviceAddress = ConvertToPhysicalAddress (HostAddress);
|
//
|
||||||
|
// The debug implementation of UncachedMemoryAllocationLib in ArmPkg returns
|
||||||
|
// a virtual uncached alias, and unmaps the cached ID mapping of the buffer,
|
||||||
|
// in order to catch inadvertent references to the cached mapping.
|
||||||
|
// Since HostToDeviceAddress () expects ID mapped input addresses, convert
|
||||||
|
// the host address to an ID mapped address first.
|
||||||
|
//
|
||||||
|
*DeviceAddress = HostToDeviceAddress (ConvertToPhysicalAddress (HostAddress));
|
||||||
|
|
||||||
// Remember range so we can flush on the other side
|
// Remember range so we can flush on the other side
|
||||||
Map = AllocatePool (sizeof (MAP_INFO_INSTANCE));
|
Map = AllocatePool (sizeof (MAP_INFO_INSTANCE));
|
||||||
@ -126,7 +142,7 @@ DmaMap (
|
|||||||
CopyMem (Buffer, HostAddress, *NumberOfBytes);
|
CopyMem (Buffer, HostAddress, *NumberOfBytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
*DeviceAddress = ConvertToPhysicalAddress ((UINTN)Buffer);
|
*DeviceAddress = HostToDeviceAddress (ConvertToPhysicalAddress ((UINTN)Buffer));
|
||||||
Map->BufferAddress = Buffer;
|
Map->BufferAddress = Buffer;
|
||||||
} else {
|
} else {
|
||||||
Map->DoubleBuffer = FALSE;
|
Map->DoubleBuffer = FALSE;
|
||||||
|
@ -44,6 +44,7 @@
|
|||||||
[Guids]
|
[Guids]
|
||||||
|
|
||||||
[Pcd]
|
[Pcd]
|
||||||
|
gArmTokenSpaceGuid.PcdArmDmaDeviceOffset
|
||||||
|
|
||||||
[Depex]
|
[Depex]
|
||||||
gEfiCpuArchProtocolGuid
|
gEfiCpuArchProtocolGuid
|
||||||
|
Loading…
x
Reference in New Issue
Block a user