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
9 /************* Include Files ****************/
10 #include <unistd.h>
11 #include <string.h>
12 #include "cc_pal_types.h"
13 #include "cc_pal_dma.h"
14
15
16 /**
17 * @brief Initializes contiguous memory pool required for CC_PalDmaContigBufferAllocate() and CC_PalDmaContigBufferFree(). Our
18 * implementation is to mmap 0x10000000 and call to bpool(), for use of bget() in CC_PalDmaContigBufferAllocate(),
19 * and brel() in CC_PalDmaContigBufferFree().
20 *
21 * @param[in] buffSize - buffer size in Bytes
22 * @param[in] physBuffAddr - physical start address of the memory to map
23 *
24 * @return Returns a non-zero value in case of failure
25 */
CC_PalDmaInit(uint32_t buffSize,CCDmaAddr_t physBuffAddr)26 uint32_t CC_PalDmaInit(uint32_t buffSize,
27 CCDmaAddr_t physBuffAddr)
28 {
29 buffSize = buffSize; // to remove compilation warnings
30 physBuffAddr = physBuffAddr;
31
32 return 0;
33 }
34
35 /**
36 * @brief free system resources created in PD_PAL_DmaInit()
37 *
38 * @param[in] buffSize - buffer size in Bytes
39 *
40 * @return void
41 */
CC_PalDmaTerminate(void)42 void CC_PalDmaTerminate(void)
43 {
44 return;
45 }
46
47 #ifndef CC_IOT
48 /**
49 * @brief Maps a given buffer of any type. Returns the list of DMA-able blocks that the buffer maps to.
50 *
51 * @param[in] pDataBuffer - Address of the buffer to map
52 * @param[in] buffSize - Buffer size in bytes
53 * @param[in] copyDirection - Copy direction of the buffer. Can be TO_DEVICE, FROM_DEVICE or BI_DIRECTION
54 * @param[in/out] numOfBlocks - maximum numOfBlocks to fill, as output the actual number
55 * @param[out] pDmaBlockList - List of DMA-able blocks that the buffer maps to
56 * @param[out] dmaBuffHandle - A handle to the mapped buffer private resources
57 *
58 * @return Returns a non-zero value in case of failure
59 */
CC_PalDmaBufferMap(uint8_t * pDataBuffer,uint32_t buffSize,CCPalDmaBufferDirection_t copyDirection,uint32_t * pNumOfBlocks,CCPalDmaBlockInfo_t * pDmaBlockList,CC_PalDmaBufferHandle * dmaBuffHandle)60 uint32_t CC_PalDmaBufferMap(uint8_t *pDataBuffer,
61 uint32_t buffSize,
62 CCPalDmaBufferDirection_t copyDirection,
63 uint32_t *pNumOfBlocks,
64 CCPalDmaBlockInfo_t *pDmaBlockList,
65 CC_PalDmaBufferHandle *dmaBuffHandle)
66 {
67
68 return (-1);
69 }
70
71 /**
72 * @brief Unmaps a given buffer, and frees its associated resources, if exist
73 *
74 * @param[in] pDataBuffer - Address of the buffer to map
75 * @param[in] buffSize - Buffer size in bytes
76 * @param[in] copyDirection - Copy direction of the buffer. Can be TO_DEVICE, FROM_DEVICE or BI_DIRECTION
77 * @param[in] numOfBlocks - Number of DMA-able blocks that the buffer maps to
78 * @param[in] pDmaBlockList - List of DMA-able blocks that the buffer maps to
79 * @param[in] dmaBuffHandle - A handle to the mapped buffer private resources
80 *
81 * @return Returns a non-zero value in case of failure
82 */
CC_PalDmaBufferUnmap(uint8_t * pDataBuffer,uint32_t buffSize,CCPalDmaBufferDirection_t copyDirection,uint32_t numOfBlocks,CCPalDmaBlockInfo_t * pDmaBlockList,CC_PalDmaBufferHandle dmaBuffHandle)83 uint32_t CC_PalDmaBufferUnmap(uint8_t *pDataBuffer,
84 uint32_t buffSize,
85 CCPalDmaBufferDirection_t copyDirection,
86 uint32_t numOfBlocks,
87 CCPalDmaBlockInfo_t *pDmaBlockList,
88 CC_PalDmaBufferHandle dmaBuffHandle)
89 {
90 return (-1);
91 }
92
93
94
95 /**
96 * @brief Allocates a DMA-contiguous buffer, and returns both its physical and virtual addresses
97 *
98 *
99 * @param[in] buffSize - Buffer size in bytes
100 * @param[out] ppVirtBuffAddr - Virtual address of the allocated buffer
101 *
102 * @return Returns a non-zero value in case of failure
103 */
CC_PalDmaContigBufferAllocate(uint32_t buffSize,uint8_t ** ppVirtBuffAddr)104 uint32_t CC_PalDmaContigBufferAllocate(uint32_t buffSize,
105 uint8_t **ppVirtBuffAddr)
106 {
107 return (-1);
108 }
109
110
111
112 /**
113 * @brief free resources previuosly allocated by CC_PalDmaContigBufferAllocate
114 *
115 *
116 * @param[in] buffSize - buffer size in Bytes
117 * @param[in] pVirtBuffAddr - virtual address of the buffer to free
118 *
119 * @return success/fail
120 */
CC_PalDmaContigBufferFree(uint32_t buffSize,uint8_t * pVirtBuffAddr)121 uint32_t CC_PalDmaContigBufferFree(uint32_t buffSize,
122 uint8_t *pVirtBuffAddr)
123 {
124 return (-1);
125 }
126
127
128 /**
129 * @brief Returns TRUE if the buffer is guaranteed to be a single contiguous DMA block, and FALSE otherwise.
130 *
131 *
132 * @param[in] pDataBuffer - User buffer address
133 * @param[in] buffSize - User buffer size
134 *
135 * @return Returns TRUE if the buffer is guaranteed to be a single contiguous DMA block, and FALSE otherwise.
136 */
CC_PalIsDmaBufferContiguous(uint8_t * pDataBuffer,uint32_t buffSize)137 uint32_t CC_PalIsDmaBufferContiguous(uint8_t *pDataBuffer,
138 uint32_t buffSize)
139 {
140 return (-1);
141 }
142
143 #endif
144