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