1 | /* SPDX-License-Identifier: BSD-2-Clause */ |
---|
2 | |
---|
3 | /** |
---|
4 | * @file |
---|
5 | * |
---|
6 | * @ingroup RTEMSImplClassicDPMem |
---|
7 | * |
---|
8 | * @brief This header file defines the Dual-Ported Memory Manager API. |
---|
9 | */ |
---|
10 | |
---|
11 | /* |
---|
12 | * Copyright (C) 2020, 2021 embedded brains GmbH & Co. KG |
---|
13 | * Copyright (C) 1988, 2008 On-Line Applications Research Corporation (OAR) |
---|
14 | * |
---|
15 | * Redistribution and use in source and binary forms, with or without |
---|
16 | * modification, are permitted provided that the following conditions |
---|
17 | * are met: |
---|
18 | * 1. Redistributions of source code must retain the above copyright |
---|
19 | * notice, this list of conditions and the following disclaimer. |
---|
20 | * 2. Redistributions in binary form must reproduce the above copyright |
---|
21 | * notice, this list of conditions and the following disclaimer in the |
---|
22 | * documentation and/or other materials provided with the distribution. |
---|
23 | * |
---|
24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
---|
25 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
---|
26 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
---|
27 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
---|
28 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
---|
29 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
---|
30 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
---|
31 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
---|
32 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
---|
33 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
---|
34 | * POSSIBILITY OF SUCH DAMAGE. |
---|
35 | */ |
---|
36 | |
---|
37 | /* |
---|
38 | * This file is part of the RTEMS quality process and was automatically |
---|
39 | * generated. If you find something that needs to be fixed or |
---|
40 | * worded better please post a report or patch to an RTEMS mailing list |
---|
41 | * or raise a bug report: |
---|
42 | * |
---|
43 | * https://www.rtems.org/bugs.html |
---|
44 | * |
---|
45 | * For information on updating and regenerating please refer to the How-To |
---|
46 | * section in the Software Requirements Engineering chapter of the |
---|
47 | * RTEMS Software Engineering manual. The manual is provided as a part of |
---|
48 | * a release. For development sources please refer to the online |
---|
49 | * documentation at: |
---|
50 | * |
---|
51 | * https://docs.rtems.org |
---|
52 | */ |
---|
53 | |
---|
54 | /* Generated from spec:/rtems/dpmem/if/header */ |
---|
55 | |
---|
56 | #ifndef _RTEMS_RTEMS_DPMEM_H |
---|
57 | #define _RTEMS_RTEMS_DPMEM_H |
---|
58 | |
---|
59 | #include <stdint.h> |
---|
60 | #include <rtems/rtems/status.h> |
---|
61 | #include <rtems/rtems/types.h> |
---|
62 | |
---|
63 | #ifdef __cplusplus |
---|
64 | extern "C" { |
---|
65 | #endif |
---|
66 | |
---|
67 | /* Generated from spec:/rtems/dpmem/if/group */ |
---|
68 | |
---|
69 | /** |
---|
70 | * @defgroup RTEMSAPIClassicDPMem Dual-Ported Memory Manager |
---|
71 | * |
---|
72 | * @ingroup RTEMSAPIClassic |
---|
73 | * |
---|
74 | * @brief The Dual-Ported Memory Manager provides a mechanism for converting |
---|
75 | * addresses between internal and external representations for multiple |
---|
76 | * dual-ported memory areas (DPMA). |
---|
77 | */ |
---|
78 | |
---|
79 | /* Generated from spec:/rtems/dpmem/if/create */ |
---|
80 | |
---|
81 | /** |
---|
82 | * @ingroup RTEMSAPIClassicDPMem |
---|
83 | * |
---|
84 | * @brief Creates a port. |
---|
85 | * |
---|
86 | * @param name is the object name of the port. |
---|
87 | * |
---|
88 | * @param internal_start is the internal start address of the memory area. |
---|
89 | * |
---|
90 | * @param external_start is the external start address of the memory area. |
---|
91 | * |
---|
92 | * @param length is the length in bytes of the memory area. |
---|
93 | * |
---|
94 | * @param[out] id is the pointer to an ::rtems_id object. When the directive |
---|
95 | * call is successful, the identifier of the created port will be stored in |
---|
96 | * this object. |
---|
97 | * |
---|
98 | * This directive creates a port which resides on the local node. The port has |
---|
99 | * the user-defined object name specified in ``name``. The assigned object |
---|
100 | * identifier is returned in ``id``. This identifier is used to access the |
---|
101 | * port with other dual-ported memory port related directives. |
---|
102 | * |
---|
103 | * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. |
---|
104 | * |
---|
105 | * @retval ::RTEMS_INVALID_NAME The ``name`` parameter was invalid. |
---|
106 | * |
---|
107 | * @retval ::RTEMS_INVALID_ADDRESS The ``id`` parameter was NULL. |
---|
108 | * |
---|
109 | * @retval ::RTEMS_INVALID_ADDRESS The ``internal_start`` parameter was not |
---|
110 | * properly aligned. |
---|
111 | * |
---|
112 | * @retval ::RTEMS_INVALID_ADDRESS The ``external_start`` parameter was not |
---|
113 | * properly aligned. |
---|
114 | * |
---|
115 | * @retval ::RTEMS_TOO_MANY There was no inactive object available to create a |
---|
116 | * port. The number of port available to the application is configured |
---|
117 | * through the @ref CONFIGURE_MAXIMUM_PORTS application configuration option. |
---|
118 | * |
---|
119 | * @par Notes |
---|
120 | * @parblock |
---|
121 | * The ``internal_start`` and ``external_start`` parameters must be on a |
---|
122 | * boundary defined by the target processor architecture. |
---|
123 | * |
---|
124 | * For control and maintenance of the port, RTEMS allocates a DPCB from the |
---|
125 | * local DPCB free pool and initializes it. |
---|
126 | * @endparblock |
---|
127 | * |
---|
128 | * @par Constraints |
---|
129 | * @parblock |
---|
130 | * The following constraints apply to this directive: |
---|
131 | * |
---|
132 | * * The directive may be called from within device driver initialization |
---|
133 | * context. |
---|
134 | * |
---|
135 | * * The directive may be called from within task context. |
---|
136 | * |
---|
137 | * * The directive may obtain and release the object allocator mutex. This may |
---|
138 | * cause the calling task to be preempted. |
---|
139 | * |
---|
140 | * * The number of ports available to the application is configured through the |
---|
141 | * @ref CONFIGURE_MAXIMUM_PORTS application configuration option. |
---|
142 | * |
---|
143 | * * Where the object class corresponding to the directive is configured to use |
---|
144 | * unlimited objects, the directive may allocate memory from the RTEMS |
---|
145 | * Workspace. |
---|
146 | * @endparblock |
---|
147 | */ |
---|
148 | rtems_status_code rtems_port_create( |
---|
149 | rtems_name name, |
---|
150 | void *internal_start, |
---|
151 | void *external_start, |
---|
152 | uint32_t length, |
---|
153 | rtems_id *id |
---|
154 | ); |
---|
155 | |
---|
156 | /* Generated from spec:/rtems/dpmem/if/ident */ |
---|
157 | |
---|
158 | /** |
---|
159 | * @ingroup RTEMSAPIClassicDPMem |
---|
160 | * |
---|
161 | * @brief Identifies a port by the object name. |
---|
162 | * |
---|
163 | * @param name is the object name to look up. |
---|
164 | * |
---|
165 | * @param[out] id is the pointer to an ::rtems_id object. When the directive |
---|
166 | * call is successful, the object identifier of an object with the specified |
---|
167 | * name will be stored in this object. |
---|
168 | * |
---|
169 | * This directive obtains a port identifier associated with the port name |
---|
170 | * specified in ``name``. |
---|
171 | * |
---|
172 | * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. |
---|
173 | * |
---|
174 | * @retval ::RTEMS_INVALID_ADDRESS The ``id`` parameter was NULL. |
---|
175 | * |
---|
176 | * @retval ::RTEMS_INVALID_NAME The ``name`` parameter was 0. |
---|
177 | * |
---|
178 | * @retval ::RTEMS_INVALID_NAME There was no object with the specified name on |
---|
179 | * the local node. |
---|
180 | * |
---|
181 | * @par Notes |
---|
182 | * @parblock |
---|
183 | * If the port name is not unique, then the port identifier will match the |
---|
184 | * first port with that name in the search order. However, this port |
---|
185 | * identifier is not guaranteed to correspond to the desired port. |
---|
186 | * |
---|
187 | * The objects are searched from lowest to the highest index. Only the local |
---|
188 | * node is searched. |
---|
189 | * |
---|
190 | * The port identifier is used with other dual-ported memory related directives |
---|
191 | * to access the port. |
---|
192 | * @endparblock |
---|
193 | * |
---|
194 | * @par Constraints |
---|
195 | * @parblock |
---|
196 | * The following constraints apply to this directive: |
---|
197 | * |
---|
198 | * * The directive may be called from within any runtime context. |
---|
199 | * |
---|
200 | * * The directive will not cause the calling task to be preempted. |
---|
201 | * @endparblock |
---|
202 | */ |
---|
203 | rtems_status_code rtems_port_ident( rtems_name name, rtems_id *id ); |
---|
204 | |
---|
205 | /* Generated from spec:/rtems/dpmem/if/delete */ |
---|
206 | |
---|
207 | /** |
---|
208 | * @ingroup RTEMSAPIClassicDPMem |
---|
209 | * |
---|
210 | * @brief Deletes the port. |
---|
211 | * |
---|
212 | * @param id is the port identifier. |
---|
213 | * |
---|
214 | * This directive deletes the port specified by ``id``. |
---|
215 | * |
---|
216 | * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. |
---|
217 | * |
---|
218 | * @retval ::RTEMS_INVALID_ID There was no port associated with the identifier |
---|
219 | * specified by ``id``. |
---|
220 | * |
---|
221 | * @par Notes |
---|
222 | * The DPCB for the deleted port is reclaimed by RTEMS. |
---|
223 | * |
---|
224 | * @par Constraints |
---|
225 | * @parblock |
---|
226 | * The following constraints apply to this directive: |
---|
227 | * |
---|
228 | * * The directive may be called from within device driver initialization |
---|
229 | * context. |
---|
230 | * |
---|
231 | * * The directive may be called from within task context. |
---|
232 | * |
---|
233 | * * The directive may obtain and release the object allocator mutex. This may |
---|
234 | * cause the calling task to be preempted. |
---|
235 | * |
---|
236 | * * The calling task does not have to be the task that created the object. |
---|
237 | * Any local task that knows the object identifier can delete the object. |
---|
238 | * |
---|
239 | * * Where the object class corresponding to the directive is configured to use |
---|
240 | * unlimited objects, the directive may free memory to the RTEMS Workspace. |
---|
241 | * @endparblock |
---|
242 | */ |
---|
243 | rtems_status_code rtems_port_delete( rtems_id id ); |
---|
244 | |
---|
245 | /* Generated from spec:/rtems/dpmem/if/external-to-internal */ |
---|
246 | |
---|
247 | /** |
---|
248 | * @ingroup RTEMSAPIClassicDPMem |
---|
249 | * |
---|
250 | * @brief Converts the external address to the internal address. |
---|
251 | * |
---|
252 | * @param id is the port identifier. |
---|
253 | * |
---|
254 | * @param external is the external address to convert. |
---|
255 | * |
---|
256 | * @param[out] internal is the pointer to a ``void`` pointer object. When the |
---|
257 | * directive call is successful, the external address associated with the |
---|
258 | * internal address will be stored in this object. |
---|
259 | * |
---|
260 | * This directive converts a dual-ported memory address from external to |
---|
261 | * internal representation for the specified port. If the given external |
---|
262 | * address is invalid for the specified port, then the internal address is set |
---|
263 | * to the given external address. |
---|
264 | * |
---|
265 | * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. |
---|
266 | * |
---|
267 | * @retval ::RTEMS_INVALID_NAME The ``id`` parameter was invalid. |
---|
268 | * |
---|
269 | * @retval ::RTEMS_INVALID_ADDRESS The ``internal`` parameter was NULL. |
---|
270 | * |
---|
271 | * @par Constraints |
---|
272 | * @parblock |
---|
273 | * The following constraints apply to this directive: |
---|
274 | * |
---|
275 | * * The directive may be called from within interrupt context. |
---|
276 | * |
---|
277 | * * The directive may be called from within device driver initialization |
---|
278 | * context. |
---|
279 | * |
---|
280 | * * The directive may be called from within task context. |
---|
281 | * |
---|
282 | * * The directive will not cause the calling task to be preempted. |
---|
283 | * @endparblock |
---|
284 | */ |
---|
285 | rtems_status_code rtems_port_external_to_internal( |
---|
286 | rtems_id id, |
---|
287 | void *external, |
---|
288 | void **internal |
---|
289 | ); |
---|
290 | |
---|
291 | /* Generated from spec:/rtems/dpmem/if/internal-to-external */ |
---|
292 | |
---|
293 | /** |
---|
294 | * @ingroup RTEMSAPIClassicDPMem |
---|
295 | * |
---|
296 | * @brief Converts the internal address to the external address. |
---|
297 | * |
---|
298 | * @param id is the port identifier. |
---|
299 | * |
---|
300 | * @param internal is the internal address to convert. |
---|
301 | * |
---|
302 | * @param[out] external is the pointer to a ``void`` pointer object. When the |
---|
303 | * directive call is successful, the external address associated with the |
---|
304 | * internal address will be stored in this object. |
---|
305 | * |
---|
306 | * This directive converts a dual-ported memory address from internal to |
---|
307 | * external representation so that it can be passed to owner of the DPMA |
---|
308 | * represented by the specified port. If the given internal address is an |
---|
309 | * invalid dual-ported address, then the external address is set to the given |
---|
310 | * internal address. |
---|
311 | * |
---|
312 | * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. |
---|
313 | * |
---|
314 | * @retval ::RTEMS_INVALID_NAME The ``id`` parameter was invalid. |
---|
315 | * |
---|
316 | * @retval ::RTEMS_INVALID_ADDRESS The ``external`` parameter was NULL. |
---|
317 | * |
---|
318 | * @par Constraints |
---|
319 | * @parblock |
---|
320 | * The following constraints apply to this directive: |
---|
321 | * |
---|
322 | * * The directive may be called from within interrupt context. |
---|
323 | * |
---|
324 | * * The directive may be called from within device driver initialization |
---|
325 | * context. |
---|
326 | * |
---|
327 | * * The directive may be called from within task context. |
---|
328 | * |
---|
329 | * * The directive will not cause the calling task to be preempted. |
---|
330 | * @endparblock |
---|
331 | */ |
---|
332 | rtems_status_code rtems_port_internal_to_external( |
---|
333 | rtems_id id, |
---|
334 | void *internal, |
---|
335 | void **external |
---|
336 | ); |
---|
337 | |
---|
338 | #ifdef __cplusplus |
---|
339 | } |
---|
340 | #endif |
---|
341 | |
---|
342 | #endif /* _RTEMS_RTEMS_DPMEM_H */ |
---|