1 /*
2 * Copyright (c) 2022, Arm Limited. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 *
6 */
7
8 /**
9 * \file dma350_lib_unprivileged.h
10 *
11 * \brief Library functions for DMA350 Direct Access Memory
12 * Functions:
13 * 1. Memory copy from non-privileged mode
14 * 2. Memory move from non-privileged mode
15 */
16
17 #ifndef __DMA350_LIB_UNPRIVILEGED_H__
18 #define __DMA350_LIB_UNPRIVILEGED_H__
19
20 #include "dma350_lib.h"
21
22 #include <stdint.h>
23
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27
28 /**
29 * \brief Clear a status bit of the dma channel
30 *
31 * \param[in] channel DMA350 channel number
32 *
33 * \return Result of the operation \ref dma350_lib_error_t
34 *
35 * \note This function can be called from non-privileged level.
36 */
37 enum dma350_lib_error_t dma350_clear_done_irq_unpriv(uint8_t channel);
38
39 /**
40 * \brief Copy a specified number of bytes from one memory to another
41 *
42 * \param[in] channel DMA350 channel number
43 * \param[in] src Source address, where to copy from
44 * \param[in] des Destination address, where to copy to
45 * \param[in] size Number of bytes to copy
46 * \param[in] exec_type Execution type \ref dma350_lib_exec_type_t
47 *
48 * \return Result of the operation \ref dma350_lib_error_t
49 *
50 * \note This function can be called from non-privileged level.
51 */
52 enum dma350_lib_error_t dma350_memcpy_unpriv(uint8_t channel, const void* src,
53 void* des, uint32_t size,
54 enum dma350_lib_exec_type_t exec_type);
55
56 /**
57 * \brief Copy a specified number of bytes from one memory to another
58 * or overlap on same memory.
59 *
60 * \param[in] channel DMA350 channel number
61 * \param[in] src Source address, where to move from
62 * \param[in] des Destination address, where to move to
63 * \param[in] size Number of bytes to move
64 * \param[in] exec_type Execution type \ref dma350_lib_exec_type_t
65 *
66 * \return Result of the operation \ref dma350_lib_error_t
67 *
68 * \note This function can be called from non-privileged level.
69 */
70 enum dma350_lib_error_t dma350_memmove_unpriv(uint8_t channel, const void* src,
71 void* des, uint32_t size,
72 enum dma350_lib_exec_type_t exec_type);
73
74
75 /**
76 * \brief 2D Copy from canvas (area within a source bitmap) to within a
77 * destination bitmap, while applying various possible transformations.
78 * If the destination size is larger than the source, the source image
79 * will be wrapped (repeated).
80 *
81 * \param[in] channel DMA350 channel number
82 * \param[in] src Source address, top left corner
83 * \param[in] des Destination address, top left corner
84 * \param[in] src_width Source width
85 * \param[in] src_height Source height
86 * \param[in] src_line_width Source line width
87 * \param[in] des_width Destination width
88 * \param[in] des_height Destination height
89 * \param[in] des_line_width Destination line width
90 * \param[in] pixelsize Size of a pixel as in \ref dma350_ch_transize_t
91 * \param[in] transform Transform type as in \ref dma350_lib_transform_t
92 * \param[in] exec_type Execution type as in \ref dma350_lib_exec_type_t
93 *
94 * \return Result of the operation \ref dma350_lib_error_t
95 *
96 * \note Destination width and height denote the area which will be filled at
97 * the destination address. The copy always starts from the top left
98 * corner of the source. If the requested destination size does not match
99 * the source, the resulting image will be repeated / cropped.
100 * This function can be called from non-privileged level.
101 */
102 enum dma350_lib_error_t dma350_draw_from_canvas_unpriv(uint8_t channel,
103 const void* src, void* des,
104 uint32_t src_width, uint16_t src_height,
105 uint16_t src_line_width,
106 uint32_t des_width, uint16_t des_height,
107 uint16_t des_line_width,
108 enum dma350_ch_transize_t pixelsize,
109 enum dma350_lib_transform_t transform,
110 enum dma350_lib_exec_type_t exec_type);
111
112 /**
113 * \brief 2D Copy from a bitmap to within a destination bitmap, while applying
114 * various possible transformations.
115 *
116 * \param[in] channel DMA350 channel number
117 * \param[in] src Source address, top left corner
118 * \param[in] des Destination address, top left corner
119 * \param[in] src_width Source width
120 * \param[in] src_height Source height
121 * \param[in] des_width Destination width
122 * \param[in] des_height Destination height
123 * \param[in] des_line_width Destination line width
124 * \param[in] pixelsize Size of a pixel as in \ref dma350_ch_transize_t
125 * \param[in] transform Transform type as in \ref dma350_lib_transform_t
126 * \param[in] exec_type Execution type as in \ref dma350_lib_exec_type_t
127 *
128 * \return Result of the operation \ref dma350_lib_error_t
129 *
130 * \note Destination width and height denote the area which will be filled at
131 * the destination address. The copy always starts from the top left
132 * corner of the source. If the requested destination size does not match
133 * the source, the resulting image will be repeated / cropped.
134 * This function can be called from non-privileged level.
135 */
136 __STATIC_INLINE
137 enum dma350_lib_error_t dma350_draw_from_bitmap_unpriv(uint8_t channel,
138 const void* src, void* des,
139 uint32_t src_width, uint16_t src_height,
140 uint32_t des_width, uint16_t des_height,
141 uint16_t des_line_width,
142 enum dma350_ch_transize_t pixelsize,
143 enum dma350_lib_transform_t transform,
144 enum dma350_lib_exec_type_t exec_type);
145
146 /**
147 * \brief 2D Copy a source bitmap to a destination bitmap, while applying
148 * various possible transformations.
149 *
150 * \param[in] channel DMA350 channel number
151 * \param[in] src Source address, top left corner
152 * \param[in] des Destination address, top left corner
153 * \param[in] width Width
154 * \param[in] height Height
155 * \param[in] pixelsize Size of a pixel as in \ref dma350_ch_transize_t
156 * \param[in] transform Transform type as in \ref dma350_lib_transform_t
157 * \param[in] exec_type Execution type as in \ref dma350_lib_exec_type_t
158 *
159 * \return Result of the operation \ref dma350_lib_error_t
160 *
161 * \note Destination width and height are calculated from source size and
162 * requested transform type.
163 * This function can be called from non-privileged level.
164 */
165 __STATIC_INLINE
166 enum dma350_lib_error_t dma350_2d_copy_unpriv(uint8_t channel,
167 const void* src, void* des,
168 uint32_t width, uint16_t height,
169 enum dma350_ch_transize_t pixelsize,
170 enum dma350_lib_transform_t transform,
171 enum dma350_lib_exec_type_t exec_type);
172
173 /**
174 * \brief Get the status of the dma channel
175 *
176 * \param[in] channel DMA350 channel number
177 * \param[out] status DMA350 channel status
178 *
179 * \return Result of the operation \ref dma350_lib_error_t
180 *
181 * \note This function can be called from non-privileged level.
182 */
183 enum dma350_lib_error_t dma350_ch_get_status_unpriv(uint8_t channel,
184 union dma350_ch_status_t *status);
185
186 __STATIC_INLINE
dma350_draw_from_bitmap_unpriv(uint8_t channel,const void * src,void * des,uint32_t src_width,uint16_t src_height,uint32_t des_width,uint16_t des_height,uint16_t des_line_width,enum dma350_ch_transize_t pixelsize,enum dma350_lib_transform_t transform,enum dma350_lib_exec_type_t exec_type)187 enum dma350_lib_error_t dma350_draw_from_bitmap_unpriv(uint8_t channel,
188 const void* src, void* des,
189 uint32_t src_width, uint16_t src_height,
190 uint32_t des_width, uint16_t des_height,
191 uint16_t des_line_width,
192 enum dma350_ch_transize_t pixelsize,
193 enum dma350_lib_transform_t transform,
194 enum dma350_lib_exec_type_t exec_type)
195 {
196 return dma350_draw_from_canvas_unpriv(channel, src, des,
197 src_width, src_height, src_width,
198 des_width, des_height, des_line_width,
199 pixelsize, transform, exec_type);
200 }
201
202 __STATIC_INLINE
dma350_2d_copy_unpriv(uint8_t channel,const void * src,void * des,uint32_t width,uint16_t height,enum dma350_ch_transize_t pixelsize,enum dma350_lib_transform_t transform,enum dma350_lib_exec_type_t exec_type)203 enum dma350_lib_error_t dma350_2d_copy_unpriv(uint8_t channel,
204 const void* src, void* des,
205 uint32_t width, uint16_t height,
206 enum dma350_ch_transize_t pixelsize,
207 enum dma350_lib_transform_t transform,
208 enum dma350_lib_exec_type_t exec_type)
209 {
210 return dma350_draw_from_canvas_unpriv(channel, src, des,
211 width, height, width,
212 width, height, width,
213 pixelsize, transform, exec_type);
214 }
215
216 #ifdef __cplusplus
217 }
218 #endif
219 #endif /*__DMA350_LIB_UNPRIVILEGED_H__ */
220