1 /*
2 * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7
8 /************* Include Files ****************/
9 #include "cc_pal_log.h"
10 #include "cc_pal_dma.h"
11 #include "cc_pal_memmap.h"
12 #include "cc_pal_perf.h"
13 #include "cc_address_defs.h"
14 #include <string.h>
15
16
17 /*******************************************************************************************************/
18 /******* Public functions ************************/
19 /*******************************************************************************************************/
20
21 /**
22 * @brief initialize cookies and memory used for dma operations
23 *
24 * @param[in] buffSize - buffer size in Bytes
25 * @param[in] physBuffAddr - physical start address of the memory to map
26 *
27 * @return Returns a non-zero value in case of failure
28 */
CC_PalDmaInit(uint32_t buffSize,CCDmaAddr_t physBuffAddr)29 uint32_t CC_PalDmaInit(uint32_t buffSize,
30 CCDmaAddr_t physBuffAddr)
31 {
32 CC_UNUSED_PARAM(buffSize);
33 CC_UNUSED_PARAM(physBuffAddr);
34
35 return 0;
36 }
37
38 /**
39 * @brief free system resources created in PD_PAL_DmaInit()
40 *
41 * @param[in] buffSize - buffer size in Bytes
42 *
43 * @return void
44 */
CC_PalDmaTerminate(void)45 void CC_PalDmaTerminate(void)
46 {
47 return;
48 }
49
50
51 /**
52 * @brief Maps a given buffer of any type. Returns the list of DMA-able blocks that the buffer maps to.
53 *
54 * @param[in] pDataBuffer - Address of the buffer to map
55 * @param[in] buffSize - Buffer size in bytes
56 * @param[in] copyDirection - Copy direction of the buffer. Can be TO_DEVICE, FROM_DEVICE or BI_DIRECTION
57 * @param[in/out] numOfBlocks - maximum numOfBlocks to fill, as output the actual number
58 * @param[out] pDmaBlockList - List of DMA-able blocks that the buffer maps to
59 * @param[out] dmaBuffHandle - A handle to the mapped buffer private resources
60 *
61 * @return Returns a non-zero value in case of failure
62 */
CC_PalDmaBufferMap(uint8_t * pDataBuffer,uint32_t buffSize,CCPalDmaBufferDirection_t copyDirection,uint32_t * pNumOfBlocks,CCPalDmaBlockInfo_t * pDmaBlockList,CC_PalDmaBufferHandle * dmaBuffHandle)63 uint32_t CC_PalDmaBufferMap(uint8_t *pDataBuffer,
64 uint32_t buffSize,
65 CCPalDmaBufferDirection_t copyDirection,
66 uint32_t *pNumOfBlocks,
67 CCPalDmaBlockInfo_t *pDmaBlockList,
68 CC_PalDmaBufferHandle *dmaBuffHandle)
69 {
70 CC_UNUSED_PARAM(pDataBuffer);
71 CC_UNUSED_PARAM(buffSize);
72 CC_UNUSED_PARAM(copyDirection);
73 CC_UNUSED_PARAM(pNumOfBlocks);
74 CC_UNUSED_PARAM(pDmaBlockList);
75 CC_UNUSED_PARAM(dmaBuffHandle);
76
77 return 0;
78 }
79
80 /**
81 * @brief Unmaps a given buffer, and frees its associated resources, if exist
82 *
83 * @param[in] pDataBuffer - Address of the buffer to map
84 * @param[in] buffSize - Buffer size in bytes
85 * @param[in] copyDirection - Copy direction of the buffer. Can be TO_DEVICE, FROM_DEVICE or BI_DIRECTION
86 * @param[in] numOfBlocks - Number of DMA-able blocks that the buffer maps to
87 * @param[in] pDmaBlockList - List of DMA-able blocks that the buffer maps to
88 * @param[in] dmaBuffHandle - A handle to the mapped buffer private resources
89 *
90 * @return Returns a non-zero value in case of failure
91 */
CC_PalDmaBufferUnmap(uint8_t * pDataBuffer,uint32_t buffSize,CCPalDmaBufferDirection_t copyDirection,uint32_t numOfBlocks,CCPalDmaBlockInfo_t * pDmaBlockList,CC_PalDmaBufferHandle dmaBuffHandle)92 uint32_t CC_PalDmaBufferUnmap(uint8_t *pDataBuffer,
93 uint32_t buffSize,
94 CCPalDmaBufferDirection_t copyDirection,
95 uint32_t numOfBlocks,
96 CCPalDmaBlockInfo_t *pDmaBlockList,
97 CC_PalDmaBufferHandle dmaBuffHandle)
98 {
99
100 CC_UNUSED_PARAM(pDataBuffer);
101 CC_UNUSED_PARAM(buffSize);
102 CC_UNUSED_PARAM(copyDirection);
103 CC_UNUSED_PARAM(numOfBlocks);
104 CC_UNUSED_PARAM(pDmaBlockList);
105 CC_UNUSED_PARAM(dmaBuffHandle);
106
107 return 0;
108
109 }
110
111
112
113 /**
114 * @brief Allocates a DMA-contiguous buffer, and returns both its physical and virtual addresses
115 *
116 *
117 * @param[in] buffSize - Buffer size in bytes
118 * @param[out] ppVirtBuffAddr - Virtual address of the allocated buffer
119 *
120 * @return Returns a non-zero value in case of failure
121 */
CC_PalDmaContigBufferAllocate(uint32_t buffSize,uint8_t ** ppVirtBuffAddr)122 uint32_t CC_PalDmaContigBufferAllocate(uint32_t buffSize,
123 uint8_t **ppVirtBuffAddr)
124 {
125 CC_UNUSED_PARAM(buffSize);
126 CC_UNUSED_PARAM(ppVirtBuffAddr);
127
128 return 0;
129 }
130
131
132
133 /**
134 * @brief free resources previuosly allocated by CC_PalDmaContigBufferAllocate
135 *
136 *
137 * @param[in] buffSize - buffer size in Bytes
138 * @param[in] pVirtBuffAddr - virtual address of the buffer to free
139 *
140 * @return success/fail
141 */
CC_PalDmaContigBufferFree(uint32_t buffSize,uint8_t * pVirtBuffAddr)142 uint32_t CC_PalDmaContigBufferFree(uint32_t buffSize,
143 uint8_t *pVirtBuffAddr)
144 {
145 CC_UNUSED_PARAM(buffSize);
146 CC_UNUSED_PARAM(pVirtBuffAddr);
147
148 return 0;
149 }
150
151
152
153 /**
154 * @brief release and free previously allocated buffers
155 *
156 * @param[in] pDataBuffer - User buffer address
157 * @param[in] buffSize - User buffer size
158 *
159 * @return Returns TRUE if the buffer is guaranteed to be a single contiguous DMA block, and FALSE otherwise.
160 */
CC_PalIsDmaBufferContiguous(uint8_t * pDataBuffer,uint32_t buffSize)161 uint32_t CC_PalIsDmaBufferContiguous(uint8_t *pDataBuffer,
162 uint32_t buffSize)
163 {
164 CC_UNUSED_PARAM(pDataBuffer);
165 CC_UNUSED_PARAM(buffSize);
166 return 0; // false indication
167 }
168
169