summaryrefslogtreecommitdiff
path: root/Omap35xxPkg/PciEmulation
diff options
context:
space:
mode:
authorandrewfish <andrewfish@6f19259b-4bc3-4df7-8a09-765794883524>2010-05-08 19:32:03 +0000
committerandrewfish <andrewfish@6f19259b-4bc3-4df7-8a09-765794883524>2010-05-08 19:32:03 +0000
commit7f814ffd44a058cb722943e827959d1fcd6c4876 (patch)
tree5eb4128cdb49f6f31fe93f8078faddf0aad374a4 /Omap35xxPkg/PciEmulation
parent6191913fb4914f380597904f2025b1deb644e772 (diff)
downloadedk2-platforms-7f814ffd44a058cb722943e827959d1fcd6c4876.tar.xz
Add a DMA lib for the OMAP. It is a combination of PCI IO (generic ARM) DMA functions and OMAP specific DMA config routines. Update PCI emulation driver to use the new library. Started converting MMCHS (SD Card) driver over to using DMA, still a work in progress. Need to verify the 22 parameters required to setup a DMA transfer.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@10469 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'Omap35xxPkg/PciEmulation')
-rw-r--r--Omap35xxPkg/PciEmulation/PciEmulation.c95
-rw-r--r--Omap35xxPkg/PciEmulation/PciEmulation.h22
-rw-r--r--Omap35xxPkg/PciEmulation/PciEmulation.inf4
3 files changed, 20 insertions, 101 deletions
diff --git a/Omap35xxPkg/PciEmulation/PciEmulation.c b/Omap35xxPkg/PciEmulation/PciEmulation.c
index b264349b99..dd5e8f7b67 100644
--- a/Omap35xxPkg/PciEmulation/PciEmulation.c
+++ b/Omap35xxPkg/PciEmulation/PciEmulation.c
@@ -13,9 +13,7 @@
**/
#include "PciEmulation.h"
-#include <Omap3530/Omap3530.h>
-EFI_CPU_ARCH_PROTOCOL *gCpu;
EMBEDDED_EXTERNAL_DEVICE *gTPS65950;
#define HOST_CONTROLLER_OPERATION_REG_SIZE 0x44
@@ -263,41 +261,18 @@ PciIoMap (
OUT VOID **Mapping
)
{
- MAP_INFO_INSTANCE *Map;
- EFI_STATUS Status;
-
- if ( HostAddress == NULL || NumberOfBytes == NULL ||
- DeviceAddress == NULL || Mapping == NULL ) {
-
- return EFI_INVALID_PARAMETER;
- }
-
-
- if (Operation >= EfiPciOperationMaximum) {
+ DMA_MAP_OPERATION DmaOperation;
+
+ if (Operation == EfiPciIoOperationBusMasterRead) {
+ DmaOperation = MapOperationBusMasterRead;
+ } else if (Operation == EfiPciIoOperationBusMasterWrite) {
+ DmaOperation = MapOperationBusMasterWrite;
+ } else if (Operation == EfiPciIoOperationBusMasterCommonBuffer) {
+ DmaOperation = MapOperationBusMasterCommonBuffer;
+ } else {
return EFI_INVALID_PARAMETER;
}
-
- *DeviceAddress = ConvertToPhysicalAddress (HostAddress);
-
- // Data cache flush (HostAddress, NumberOfBytes);
-
- // Remember range so we can flush on the other side
- Status = gBS->AllocatePool (EfiBootServicesData, sizeof (PCI_DMA_MAP), (VOID **) &Map);
- if (EFI_ERROR(Status)) {
- return EFI_OUT_OF_RESOURCES;
- }
-
- *Mapping = Map;
-
- Map->HostAddress = (UINTN)HostAddress;
- Map->DeviceAddress = *DeviceAddress;
- Map->NumberOfBytes = *NumberOfBytes;
- Map->Operation = Operation;
-
- // EfiCpuFlushTypeWriteBack, EfiCpuFlushTypeInvalidate
- gCpu->FlushDataCache (gCpu, (EFI_PHYSICAL_ADDRESS)(UINTN)HostAddress, *NumberOfBytes, EfiCpuFlushTypeWriteBackInvalidate);
-
- return EFI_SUCCESS;
+ return DmaMap (DmaOperation, HostAddress, NumberOfBytes, DeviceAddress, Mapping);
}
EFI_STATUS
@@ -306,24 +281,7 @@ PciIoUnmap (
IN VOID *Mapping
)
{
- PCI_DMA_MAP *Map;
-
- if (Mapping == NULL) {
- ASSERT (FALSE);
- return EFI_INVALID_PARAMETER;
- }
-
- Map = (PCI_DMA_MAP *)Mapping;
- if (Map->Operation == EfiPciOperationBusMasterWrite) {
- //
- // Make sure we read buffer from uncached memory and not the cache
- //
- gCpu->FlushDataCache (gCpu, Map->HostAddress, Map->NumberOfBytes, EfiCpuFlushTypeInvalidate);
- }
-
- FreePool (Map);
-
- return EFI_SUCCESS;
+ return DmaUnmap (Mapping);
}
EFI_STATUS
@@ -337,29 +295,14 @@ PciIoAllocateBuffer (
)
{
if (Attributes & EFI_PCI_ATTRIBUTE_INVALID_FOR_ALLOCATE_BUFFER) {
+ // Check this
return EFI_UNSUPPORTED;
}
- if (HostAddress == NULL) {
- return EFI_INVALID_PARAMETER;
- }
-
- //
- // The only valid memory types are EfiBootServicesData and EfiRuntimeServicesData
- //
- // We used uncached memory to keep coherency
- //
- if (MemoryType == EfiBootServicesData) {
- *HostAddress = UncachedAllocatePages (Pages);
- } else if (MemoryType != EfiRuntimeServicesData) {
- *HostAddress = UncachedAllocateRuntimePages (Pages);
- } else {
- return EFI_INVALID_PARAMETER;
- }
-
- return EFI_SUCCESS;
+ return DmaAllocateBuffer (MemoryType, Pages, HostAddress);
}
+
EFI_STATUS
PciIoFreeBuffer (
IN EFI_PCI_IO_PROTOCOL *This,
@@ -367,12 +310,7 @@ PciIoFreeBuffer (
IN VOID *HostAddress
)
{
- if (HostAddress == NULL) {
- return EFI_INVALID_PARAMETER;
- }
-
- UncachedFreePages (HostAddress, Pages);
- return EFI_SUCCESS;
+ return DmaFreeBuffer (Pages, HostAddress);
}
@@ -508,9 +446,6 @@ PciEmulationEntryPoint (
UINT8 PhysicalPorts;
UINTN Count;
- // Get the Cpu protocol for later use
- Status = gBS->LocateProtocol(&gEfiCpuArchProtocolGuid, NULL, (VOID **)&gCpu);
- ASSERT_EFI_ERROR(Status);
//Configure USB host for OMAP3530.
ConfigureUSBHost();
diff --git a/Omap35xxPkg/PciEmulation/PciEmulation.h b/Omap35xxPkg/PciEmulation/PciEmulation.h
index 6a8668786f..066a553950 100644
--- a/Omap35xxPkg/PciEmulation/PciEmulation.h
+++ b/Omap35xxPkg/PciEmulation/PciEmulation.h
@@ -28,10 +28,9 @@
#include <Library/PciLib.h>
#include <Library/UefiLib.h>
#include <Library/UefiBootServicesTableLib.h>
-#include <Library/UncachedMemoryAllocationLib.h>
+#include <Library/OmapDmaLib.h>
#include <Protocol/EmbeddedExternalDevice.h>
-#include <Protocol/Cpu.h>
#include <Protocol/DevicePath.h>
#include <Protocol/PciIo.h>
#include <Protocol/PciRootBridgeIo.h>
@@ -40,7 +39,9 @@
#include <IndustryStandard/Pci22.h>
#include <IndustryStandard/Acpi.h>
-extern EFI_CPU_ARCH_PROTOCOL *gCpu;
+#include <Omap3530/Omap3530.h>
+
+
#define EFI_RESOURCE_NONEXISTENT 0xFFFFFFFFFFFFFFFFULL
#define EFI_RESOURCE_LESS 0xFFFFFFFFFFFFFFFEULL
@@ -99,21 +100,6 @@ typedef union {
} PTR;
-typedef struct {
- EFI_PHYSICAL_ADDRESS HostAddress;
- EFI_PHYSICAL_ADDRESS DeviceAddress;
- UINTN NumberOfBytes;
- EFI_PCI_IO_PROTOCOL_OPERATION Operation;
-
-} MAP_INFO_INSTANCE;
-
-
-typedef struct {
- EFI_PHYSICAL_ADDRESS HostAddress;
- EFI_PHYSICAL_ADDRESS DeviceAddress;
- UINTN NumberOfBytes;
- EFI_PCI_IO_PROTOCOL_OPERATION Operation;
-} PCI_DMA_MAP;
EFI_STATUS
EFIAPI
diff --git a/Omap35xxPkg/PciEmulation/PciEmulation.inf b/Omap35xxPkg/PciEmulation/PciEmulation.inf
index 9035f200b4..e9da1fb4f7 100644
--- a/Omap35xxPkg/PciEmulation/PciEmulation.inf
+++ b/Omap35xxPkg/PciEmulation/PciEmulation.inf
@@ -40,19 +40,17 @@
UefiBootServicesTableLib
UefiDriverEntryPoint
UefiRuntimeServicesTableLib
- UncachedMemoryAllocationLib
IoLib
+ OmapDmaLib
[Protocols]
gEfiPciRootBridgeIoProtocolGuid
gEfiDevicePathProtocolGuid
gEfiPciHostBridgeResourceAllocationProtocolGuid
- gEfiCpuArchProtocolGuid
gEfiPciIoProtocolGuid
gEmbeddedExternalDeviceProtocolGuid
[Depex]
gEfiMetronomeArchProtocolGuid AND
- gEfiCpuArchProtocolGuid AND
gEmbeddedExternalDeviceProtocolGuid
\ No newline at end of file