mirror of
https://github.com/acidanthera/audk.git
synced 2025-07-26 15:14:02 +02:00
Fix line ending issue. Update DMA Map primatives to double buffer if buffer does not start on cache line boundary. If buffer is not a multiple of a cache line only whole cache lines will be allowed in the buffer. This is part of the MAP API.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@10547 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
d744b79c0f
commit
8e7c9e030f
@ -21,6 +21,8 @@
|
|||||||
#include <Library/UefiBootServicesTableLib.h>
|
#include <Library/UefiBootServicesTableLib.h>
|
||||||
#include <Library/UncachedMemoryAllocationLib.h>
|
#include <Library/UncachedMemoryAllocationLib.h>
|
||||||
#include <Library/IoLib.h>
|
#include <Library/IoLib.h>
|
||||||
|
#include <Library/BaseMemoryLib.h>
|
||||||
|
#include <Library/ArmLib.h>
|
||||||
#include <Omap3530/Omap3530.h>
|
#include <Omap3530/Omap3530.h>
|
||||||
|
|
||||||
#include <Protocol/Cpu.h>
|
#include <Protocol/Cpu.h>
|
||||||
@ -30,11 +32,13 @@ typedef struct {
|
|||||||
EFI_PHYSICAL_ADDRESS DeviceAddress;
|
EFI_PHYSICAL_ADDRESS DeviceAddress;
|
||||||
UINTN NumberOfBytes;
|
UINTN NumberOfBytes;
|
||||||
DMA_MAP_OPERATION Operation;
|
DMA_MAP_OPERATION Operation;
|
||||||
|
BOOLEAN DoubleBuffer;
|
||||||
} MAP_INFO_INSTANCE;
|
} MAP_INFO_INSTANCE;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
EFI_CPU_ARCH_PROTOCOL *gCpu;
|
EFI_CPU_ARCH_PROTOCOL *gCpu;
|
||||||
|
UINTN gCacheAlignment = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Configure OMAP DMA Channel
|
Configure OMAP DMA Channel
|
||||||
@ -218,7 +222,9 @@ DmaMap (
|
|||||||
OUT VOID **Mapping
|
OUT VOID **Mapping
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
EFI_STATUS Status;
|
||||||
MAP_INFO_INSTANCE *Map;
|
MAP_INFO_INSTANCE *Map;
|
||||||
|
VOID *Buffer;
|
||||||
|
|
||||||
if ( HostAddress == NULL || NumberOfBytes == NULL ||
|
if ( HostAddress == NULL || NumberOfBytes == NULL ||
|
||||||
DeviceAddress == NULL || Mapping == NULL ) {
|
DeviceAddress == NULL || Mapping == NULL ) {
|
||||||
@ -240,13 +246,36 @@ DmaMap (
|
|||||||
|
|
||||||
*Mapping = Map;
|
*Mapping = Map;
|
||||||
|
|
||||||
|
if (((UINTN)HostAddress & (gCacheAlignment - 1)) != 0) {
|
||||||
|
Map->DoubleBuffer = TRUE;
|
||||||
|
Status = DmaAllocateBuffer (EfiBootServicesData, EFI_SIZE_TO_PAGES (*NumberOfBytes), &Buffer);
|
||||||
|
if (EFI_ERROR (Status)) {
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
*DeviceAddress = (PHYSICAL_ADDRESS)(UINTN)Buffer;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
Map->DoubleBuffer = FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
*NumberOfBytes &= *NumberOfBytes & ~(gCacheAlignment - 1); // Only do it on full cache lines
|
||||||
|
|
||||||
Map->HostAddress = (UINTN)HostAddress;
|
Map->HostAddress = (UINTN)HostAddress;
|
||||||
Map->DeviceAddress = *DeviceAddress;
|
Map->DeviceAddress = *DeviceAddress;
|
||||||
Map->NumberOfBytes = *NumberOfBytes;
|
Map->NumberOfBytes = *NumberOfBytes;
|
||||||
Map->Operation = Operation;
|
Map->Operation = Operation;
|
||||||
|
|
||||||
|
if (Map->DoubleBuffer) {
|
||||||
|
if (Map->Operation == MapOperationBusMasterWrite) {
|
||||||
|
CopyMem ((VOID *)(UINTN)Map->DeviceAddress, (VOID *)(UINTN)Map->HostAddress, Map->NumberOfBytes);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
// EfiCpuFlushTypeWriteBack, EfiCpuFlushTypeInvalidate
|
// EfiCpuFlushTypeWriteBack, EfiCpuFlushTypeInvalidate
|
||||||
gCpu->FlushDataCache (gCpu, (EFI_PHYSICAL_ADDRESS)(UINTN)HostAddress, *NumberOfBytes, EfiCpuFlushTypeWriteBackInvalidate);
|
if (Map->Operation == MapOperationBusMasterWrite || Map->Operation == MapOperationBusMasterRead) {
|
||||||
|
gCpu->FlushDataCache (gCpu, (EFI_PHYSICAL_ADDRESS)(UINTN)HostAddress, Map->NumberOfBytes, EfiCpuFlushTypeWriteBackInvalidate);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
@ -276,12 +305,22 @@ DmaUnmap (
|
|||||||
}
|
}
|
||||||
|
|
||||||
Map = (MAP_INFO_INSTANCE *)Mapping;
|
Map = (MAP_INFO_INSTANCE *)Mapping;
|
||||||
|
|
||||||
|
if (Map->DoubleBuffer) {
|
||||||
|
if (Map->Operation == MapOperationBusMasterRead) {
|
||||||
|
CopyMem ((VOID *)(UINTN)Map->HostAddress, (VOID *)(UINTN)Map->DeviceAddress, Map->NumberOfBytes);
|
||||||
|
}
|
||||||
|
|
||||||
|
DmaFreeBuffer (EFI_SIZE_TO_PAGES (Map->NumberOfBytes), (VOID *)(UINTN)Map->DeviceAddress);
|
||||||
|
|
||||||
|
} else {
|
||||||
if (Map->Operation == MapOperationBusMasterWrite) {
|
if (Map->Operation == MapOperationBusMasterWrite) {
|
||||||
//
|
//
|
||||||
// Make sure we read buffer from uncached memory and not the cache
|
// Make sure we read buffer from uncached memory and not the cache
|
||||||
//
|
//
|
||||||
gCpu->FlushDataCache (gCpu, Map->HostAddress, Map->NumberOfBytes, EfiCpuFlushTypeInvalidate);
|
gCpu->FlushDataCache (gCpu, Map->HostAddress, Map->NumberOfBytes, EfiCpuFlushTypeInvalidate);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
FreePool (Map);
|
FreePool (Map);
|
||||||
|
|
||||||
@ -304,7 +343,8 @@ DmaUnmap (
|
|||||||
@retval EFI_INVALID_PARAMETER One or more parameters are invalid.
|
@retval EFI_INVALID_PARAMETER One or more parameters are invalid.
|
||||||
@retval EFI_OUT_OF_RESOURCES The memory pages could not be allocated.
|
@retval EFI_OUT_OF_RESOURCES The memory pages could not be allocated.
|
||||||
|
|
||||||
**/EFI_STATUS
|
**/
|
||||||
|
EFI_STATUS
|
||||||
EFIAPI
|
EFIAPI
|
||||||
DmaAllocateBuffer (
|
DmaAllocateBuffer (
|
||||||
IN EFI_MEMORY_TYPE MemoryType,
|
IN EFI_MEMORY_TYPE MemoryType,
|
||||||
@ -373,6 +413,8 @@ OmapDmaLibConstructor (
|
|||||||
Status = gBS->LocateProtocol (&gEfiCpuArchProtocolGuid, NULL, (VOID **)&gCpu);
|
Status = gBS->LocateProtocol (&gEfiCpuArchProtocolGuid, NULL, (VOID **)&gCpu);
|
||||||
ASSERT_EFI_ERROR(Status);
|
ASSERT_EFI_ERROR(Status);
|
||||||
|
|
||||||
return EFI_SUCCESS;
|
gCacheAlignment = ArmDataCacheLineLength ();
|
||||||
|
|
||||||
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,6 +35,8 @@
|
|||||||
MemoryAllocationLib
|
MemoryAllocationLib
|
||||||
UncachedMemoryAllocationLib
|
UncachedMemoryAllocationLib
|
||||||
IoLib
|
IoLib
|
||||||
|
BaseMemoryLib
|
||||||
|
ArmLib
|
||||||
|
|
||||||
|
|
||||||
[Protocols]
|
[Protocols]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user