3 Abstractions for simple OMAP DMA. The DMA functions are modeled on
4 the PCI IO protocol and follow the same rules as outlined in the UEFI specification.
5 OMAP_DMA4 structure elements are described in the OMAP35xx TRM. Currently
6 there is no PCI'less DMA protocol, if one existed it could be used to
9 Copyright (c) 2008 - 2010, Apple Inc. All rights reserved.<BR>
11 This program and the accompanying materials
12 are licensed and made available under the terms and conditions of the BSD License
13 which accompanies this distribution. The full text of the license may be found at
14 http://opensource.org/licenses/bsd-license.php
16 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
17 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
21 #ifndef __OMAP_DMA_LIB_H__
22 #define __OMAP_DMA_LIB_H__
26 /// A read operation from system memory by a bus master.
28 MapOperationBusMasterRead
,
30 /// A write operation from system memory by a bus master.
32 MapOperationBusMasterWrite
,
34 /// Provides both read and write access to system memory by both the processor and a
35 /// bus master. The buffer is coherent from both the processor's and the bus master's point of view.
37 MapOperationBusMasterCommonBuffer
,
42 // Example from DMA chapter of the OMAP35xx spec
44 UINT8 DataType
; // DMA4_CSDPi[1:0]
45 UINT8 ReadPortAccessType
; // DMA4_CSDPi[8:7]
46 UINT8 WritePortAccessType
; // DMA4_CSDPi[15:14]
47 UINT8 SourceEndiansim
; // DMA4_CSDPi[21]
48 UINT8 DestinationEndianism
; // DMA4_CSDPi[19]
49 UINT8 WriteMode
; // DMA4_CSDPi[17:16]
50 UINT8 SourcePacked
; // DMA4_CSDPi[6]
51 UINT8 DestinationPacked
; // DMA4_CSDPi[13]
52 UINT32 NumberOfElementPerFrame
; // DMA4_CENi
53 UINT32 NumberOfFramePerTransferBlock
; // DMA4_CFNi
54 UINT32 SourceStartAddress
; // DMA4_CSSAi
55 UINT32 DestinationStartAddress
; // DMA4_CDSAi
56 UINT32 SourceElementIndex
; // DMA4_CSEi
57 UINT32 SourceFrameIndex
; // DMA4_CSFi
58 UINT32 DestinationElementIndex
; // DMA4_CDEi
59 UINT32 DestinationFrameIndex
; // DMA4_CDFi
60 UINT8 ReadPortAccessMode
; // DMA4_CCRi[13:12]
61 UINT8 WritePortAccessMode
; // DMA4_CCRi[15:14]
62 UINT8 ReadPriority
; // DMA4_CCRi[6]
63 UINT8 WritePriority
; // DMA4_CCRi[23]
64 UINT8 ReadRequestNumber
; // DMA4_CCRi[4:0]
65 UINT8 WriteRequestNumber
; // DMA4_CCRi[20:19]
70 Configure OMAP DMA Channel
72 @param Channel DMA Channel to configure
73 @param Dma4 Pointer to structure used to initialize DMA registers for the Channel
75 @retval EFI_SUCCESS The range was mapped for the returned NumberOfBytes.
76 @retval EFI_INVALID_PARAMETER Channel is not valid
77 @retval EFI_DEVICE_ERROR The system hardware could not map the requested information.
88 Turn of DMA channel configured by EnableDma().
90 @param Channel DMA Channel to configure
92 @retval EFI_SUCCESS DMA hardware disabled
93 @retval EFI_INVALID_PARAMETER Channel is not valid
94 @retval EFI_DEVICE_ERROR The system hardware could not map the requested information.
105 Provides the DMA controller-specific addresses needed to access system memory.
107 Operation is relative to the DMA bus master.
109 @param Operation Indicates if the bus master is going to read or write to system memory.
110 @param HostAddress The system memory address to map to the DMA controller.
111 @param NumberOfBytes On input the number of bytes to map. On output the number of bytes
113 @param DeviceAddress The resulting map address for the bus master controller to use to
114 access the hosts HostAddress.
115 @param Mapping A resulting value to pass to Unmap().
117 @retval EFI_SUCCESS The range was mapped for the returned NumberOfBytes.
118 @retval EFI_UNSUPPORTED The HostAddress cannot be mapped as a common buffer.
119 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
120 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
121 @retval EFI_DEVICE_ERROR The system hardware could not map the requested address.
127 IN DMA_MAP_OPERATION Operation
,
128 IN VOID
*HostAddress
,
129 IN OUT UINTN
*NumberOfBytes
,
130 OUT PHYSICAL_ADDRESS
*DeviceAddress
,
138 Completes the DmaMapBusMasterRead(), DmaMapBusMasterWrite(), or DmaMapBusMasterCommonBuffer()
139 operation and releases any corresponding resources.
141 @param Mapping The mapping value returned from DmaMap*().
143 @retval EFI_SUCCESS The range was unmapped.
144 @retval EFI_DEVICE_ERROR The data was not committed to the target system memory.
155 Allocates pages that are suitable for an DmaMap() of type MapOperationBusMasterCommonBuffer.
158 @param MemoryType The type of memory to allocate, EfiBootServicesData or
159 EfiRuntimeServicesData.
160 @param Pages The number of pages to allocate.
161 @param HostAddress A pointer to store the base system memory address of the
164 @retval EFI_SUCCESS The requested memory pages were allocated.
165 @retval EFI_UNSUPPORTED Attributes is unsupported. The only legal attribute bits are
166 MEMORY_WRITE_COMBINE and MEMORY_CACHED.
167 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
168 @retval EFI_OUT_OF_RESOURCES The memory pages could not be allocated.
174 IN EFI_MEMORY_TYPE MemoryType
,
176 OUT VOID
**HostAddress
181 Frees memory that was allocated with DmaAllocateBuffer().
183 @param Pages The number of pages to free.
184 @param HostAddress The base system memory address of the allocated range.
186 @retval EFI_SUCCESS The requested memory pages were freed.
187 @retval EFI_INVALID_PARAMETER The memory range specified by HostAddress and Pages
188 was not allocated with DmaAllocateBuffer().