1 | /* SPDX-License-Identifier: BSD-2-Clause */ |
---|
2 | |
---|
3 | /** |
---|
4 | * @file |
---|
5 | * |
---|
6 | * @ingroup RTEMSImplClassicPartition |
---|
7 | * |
---|
8 | * @brief This header file provides the Partition Manager API. |
---|
9 | */ |
---|
10 | |
---|
11 | /* |
---|
12 | * Copyright (C) 2020, 2021 embedded brains GmbH (http://www.embedded-brains.de) |
---|
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/part/if/header */ |
---|
55 | |
---|
56 | #ifndef _RTEMS_RTEMS_PART_H |
---|
57 | #define _RTEMS_RTEMS_PART_H |
---|
58 | |
---|
59 | #include <stddef.h> |
---|
60 | #include <stdint.h> |
---|
61 | #include <rtems/rtems/attr.h> |
---|
62 | #include <rtems/rtems/status.h> |
---|
63 | #include <rtems/rtems/types.h> |
---|
64 | #include <rtems/score/cpu.h> |
---|
65 | |
---|
66 | #ifdef __cplusplus |
---|
67 | extern "C" { |
---|
68 | #endif |
---|
69 | |
---|
70 | /* Generated from spec:/rtems/part/if/group */ |
---|
71 | |
---|
72 | /** |
---|
73 | * @defgroup RTEMSAPIClassicPart Partition Manager |
---|
74 | * |
---|
75 | * @ingroup RTEMSAPIClassic |
---|
76 | * |
---|
77 | * @brief The Partition Manager provides facilities to dynamically allocate |
---|
78 | * memory in fixed-size units. |
---|
79 | */ |
---|
80 | |
---|
81 | /* Generated from spec:/rtems/part/if/alignment */ |
---|
82 | |
---|
83 | /** |
---|
84 | * @ingroup RTEMSAPIClassicPart |
---|
85 | * |
---|
86 | * @brief This constant defines the minimum alignment of a partition buffer in |
---|
87 | * bytes. |
---|
88 | * |
---|
89 | * @par Notes |
---|
90 | * Use it with RTEMS_ALIGNED() to define the alignment of partition buffer |
---|
91 | * types or statically allocated partition buffer areas. |
---|
92 | */ |
---|
93 | #define RTEMS_PARTITION_ALIGNMENT CPU_SIZEOF_POINTER |
---|
94 | |
---|
95 | /* Generated from spec:/rtems/part/if/create */ |
---|
96 | |
---|
97 | /** |
---|
98 | * @ingroup RTEMSAPIClassicPart |
---|
99 | * |
---|
100 | * @brief Creates a partition. |
---|
101 | * |
---|
102 | * @param name is the object name of the partition. |
---|
103 | * |
---|
104 | * @param starting_address is the starting address of the buffer area used by |
---|
105 | * the partition. |
---|
106 | * |
---|
107 | * @param length is the length in bytes of the buffer area used by the |
---|
108 | * partition. |
---|
109 | * |
---|
110 | * @param buffer_size is the size in bytes of a buffer managed by the |
---|
111 | * partition. |
---|
112 | * |
---|
113 | * @param attribute_set is the attribute set of the partition. |
---|
114 | * |
---|
115 | * @param[out] id is the pointer to an ::rtems_id object. When the directive |
---|
116 | * call is successful, the identifier of the created partition will be stored |
---|
117 | * in this object. |
---|
118 | * |
---|
119 | * This directive creates a partition of fixed size buffers from a physically |
---|
120 | * contiguous memory space which starts at ``starting_address`` and is |
---|
121 | * ``length`` bytes in size. Each allocated buffer is to be of ``buffer_size`` |
---|
122 | * in bytes. The partition has the user-defined object name specified in |
---|
123 | * ``name``. The assigned object identifier is returned in ``id``. This |
---|
124 | * identifier is used to access the partition with other partition related |
---|
125 | * directives. |
---|
126 | * |
---|
127 | * The **attribute set** specified in ``attribute_set`` is built through a |
---|
128 | * *bitwise or* of the attribute constants described below. Not all |
---|
129 | * combinations of attributes are allowed. Some attributes are mutually |
---|
130 | * exclusive. If mutually exclusive attributes are combined, the behaviour is |
---|
131 | * undefined. Attributes not mentioned below are not evaluated by this |
---|
132 | * directive and have no effect. Default attributes can be selected by using |
---|
133 | * the #RTEMS_DEFAULT_ATTRIBUTES constant. |
---|
134 | * |
---|
135 | * The partition has a local or global **scope** in a multiprocessing network |
---|
136 | * (this attribute does not refer to SMP systems). The scope is selected by |
---|
137 | * the mutually exclusive #RTEMS_LOCAL and #RTEMS_GLOBAL attributes. |
---|
138 | * |
---|
139 | * * A **local scope** is the default and can be emphasized through the use of |
---|
140 | * the #RTEMS_LOCAL attribute. A local partition can be only used by the |
---|
141 | * node which created it. |
---|
142 | * |
---|
143 | * * A **global scope** is established if the #RTEMS_GLOBAL attribute is set. |
---|
144 | * The memory space used for the partition must reside in shared memory. |
---|
145 | * Setting the global attribute in a single node system has no effect. |
---|
146 | * |
---|
147 | * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. |
---|
148 | * |
---|
149 | * @retval ::RTEMS_INVALID_NAME The ``name`` parameter was invalid. |
---|
150 | * |
---|
151 | * @retval ::RTEMS_INVALID_ADDRESS The ``id`` parameter was NULL. |
---|
152 | * |
---|
153 | * @retval ::RTEMS_INVALID_SIZE The ``length`` parameter was 0. |
---|
154 | * |
---|
155 | * @retval ::RTEMS_INVALID_SIZE The ``buffer_size`` parameter was 0. |
---|
156 | * |
---|
157 | * @retval ::RTEMS_INVALID_SIZE The ``length`` parameter was less than the |
---|
158 | * ``buffer_size`` parameter. |
---|
159 | * |
---|
160 | * @retval ::RTEMS_INVALID_SIZE The ``buffer_size`` parameter was not an |
---|
161 | * integral multiple of the pointer size. |
---|
162 | * |
---|
163 | * @retval ::RTEMS_INVALID_SIZE The ``buffer_size`` parameter was less than two |
---|
164 | * times the pointer size. |
---|
165 | * |
---|
166 | * @retval ::RTEMS_INVALID_ADDRESS The ``starting_address`` parameter was not |
---|
167 | * on a pointer size boundary. |
---|
168 | * |
---|
169 | * @retval ::RTEMS_TOO_MANY There was no inactive object available to create a |
---|
170 | * partition. The number of partitions available to the application is |
---|
171 | * configured through the #CONFIGURE_MAXIMUM_PARTITIONS application |
---|
172 | * configuration option. |
---|
173 | * |
---|
174 | * @retval ::RTEMS_TOO_MANY In multiprocessing configurations, there was no |
---|
175 | * inactive global object available to create a global semaphore. The number |
---|
176 | * of global objects available to the application is configured through the |
---|
177 | * #CONFIGURE_MP_MAXIMUM_GLOBAL_OBJECTS application configuration option. |
---|
178 | * |
---|
179 | * @par Notes |
---|
180 | * @parblock |
---|
181 | * The partition buffer area specified by the ``starting_address`` must be |
---|
182 | * properly aligned. It must be possible to directly store target architecture |
---|
183 | * pointers and also the user data. For example, if the user data contains |
---|
184 | * some long double or vector data types, the partition buffer area and the |
---|
185 | * buffer size must take the alignment of these types into account which is |
---|
186 | * usually larger than the pointer alignment. A cache line alignment may be |
---|
187 | * also a factor. Use #RTEMS_PARTITION_ALIGNMENT to specify the minimum |
---|
188 | * alignment of a partition buffer type. |
---|
189 | * |
---|
190 | * The ``buffer_size`` parameter must be an integral multiple of the pointer |
---|
191 | * size on the target architecture. Additionally, ``buffer_size`` must be |
---|
192 | * large enough to hold two pointers on the target architecture. This is |
---|
193 | * required for RTEMS to manage the buffers when they are free. |
---|
194 | * |
---|
195 | * For control and maintenance of the partition, RTEMS allocates a PTCB from |
---|
196 | * the local PTCB free pool and initializes it. Memory from the partition |
---|
197 | * buffer area is not used by RTEMS to store the PTCB. |
---|
198 | * |
---|
199 | * The PTCB for a global partition is allocated on the local node. Partitions |
---|
200 | * should not be made global unless remote tasks must interact with the |
---|
201 | * partition. This is to avoid the overhead incurred by the creation of a |
---|
202 | * global partition. When a global partition is created, the partition's name |
---|
203 | * and identifier must be transmitted to every node in the system for insertion |
---|
204 | * in the local copy of the global object table. |
---|
205 | * @endparblock |
---|
206 | * |
---|
207 | * @par Constraints |
---|
208 | * @parblock |
---|
209 | * The following constraints apply to this directive: |
---|
210 | * |
---|
211 | * * The directive may be called from within device driver initialization |
---|
212 | * context. |
---|
213 | * |
---|
214 | * * The directive may be called from within task context. |
---|
215 | * |
---|
216 | * * The directive may obtain and release the object allocator mutex. This may |
---|
217 | * cause the calling task to be preempted. |
---|
218 | * |
---|
219 | * * When the directive operates on a global object, the directive sends a |
---|
220 | * message to remote nodes. This may preempt the calling task. |
---|
221 | * |
---|
222 | * * The number of partitions available to the application is configured |
---|
223 | * through the #CONFIGURE_MAXIMUM_PARTITIONS application configuration |
---|
224 | * option. |
---|
225 | * |
---|
226 | * * Where the object class corresponding to the directive is configured to use |
---|
227 | * unlimited objects, the directive may allocate memory from the RTEMS |
---|
228 | * Workspace. |
---|
229 | * |
---|
230 | * * The number of global objects available to the application is configured |
---|
231 | * through the #CONFIGURE_MP_MAXIMUM_GLOBAL_OBJECTS application configuration |
---|
232 | * option. |
---|
233 | * @endparblock |
---|
234 | */ |
---|
235 | rtems_status_code rtems_partition_create( |
---|
236 | rtems_name name, |
---|
237 | void *starting_address, |
---|
238 | uintptr_t length, |
---|
239 | size_t buffer_size, |
---|
240 | rtems_attribute attribute_set, |
---|
241 | rtems_id *id |
---|
242 | ); |
---|
243 | |
---|
244 | /* Generated from spec:/rtems/part/if/ident */ |
---|
245 | |
---|
246 | /** |
---|
247 | * @ingroup RTEMSAPIClassicPart |
---|
248 | * |
---|
249 | * @brief Identifies a partition by the object name. |
---|
250 | * |
---|
251 | * @param name is the object name to look up. |
---|
252 | * |
---|
253 | * @param node is the node or node set to search for a matching object. |
---|
254 | * |
---|
255 | * @param[out] id is the pointer to an ::rtems_id object. When the directive |
---|
256 | * call is successful, the object identifier of an object with the specified |
---|
257 | * name will be stored in this object. |
---|
258 | * |
---|
259 | * This directive obtains a partition identifier associated with the partition |
---|
260 | * name specified in ``name``. |
---|
261 | * |
---|
262 | * The node to search is specified in ``node``. It shall be |
---|
263 | * |
---|
264 | * * a valid node number, |
---|
265 | * |
---|
266 | * * the constant #RTEMS_SEARCH_ALL_NODES to search in all nodes, |
---|
267 | * |
---|
268 | * * the constant #RTEMS_SEARCH_LOCAL_NODE to search in the local node only, or |
---|
269 | * |
---|
270 | * * the constant #RTEMS_SEARCH_OTHER_NODES to search in all nodes except the |
---|
271 | * local node. |
---|
272 | * |
---|
273 | * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. |
---|
274 | * |
---|
275 | * @retval ::RTEMS_INVALID_ADDRESS The ``id`` parameter was NULL. |
---|
276 | * |
---|
277 | * @retval ::RTEMS_INVALID_NAME The ``name`` parameter was 0. |
---|
278 | * |
---|
279 | * @retval ::RTEMS_INVALID_NAME There was no object with the specified name on |
---|
280 | * the specified nodes. |
---|
281 | * |
---|
282 | * @retval ::RTEMS_INVALID_NODE In multiprocessing configurations, the |
---|
283 | * specified node was invalid. |
---|
284 | * |
---|
285 | * @par Notes |
---|
286 | * @parblock |
---|
287 | * If the partition name is not unique, then the partition identifier will |
---|
288 | * match the first partition with that name in the search order. However, this |
---|
289 | * partition identifier is not guaranteed to correspond to the desired |
---|
290 | * partition. |
---|
291 | * |
---|
292 | * The objects are searched from lowest to the highest index. If ``node`` is |
---|
293 | * #RTEMS_SEARCH_ALL_NODES, all nodes are searched with the local node being |
---|
294 | * searched first. All other nodes are searched from lowest to the highest |
---|
295 | * node number. |
---|
296 | * |
---|
297 | * If node is a valid node number which does not represent the local node, then |
---|
298 | * only the partitions exported by the designated node are searched. |
---|
299 | * |
---|
300 | * This directive does not generate activity on remote nodes. It accesses only |
---|
301 | * the local copy of the global object table. |
---|
302 | * |
---|
303 | * The partition identifier is used with other partition related directives to |
---|
304 | * access the partition. |
---|
305 | * @endparblock |
---|
306 | * |
---|
307 | * @par Constraints |
---|
308 | * @parblock |
---|
309 | * The following constraints apply to this directive: |
---|
310 | * |
---|
311 | * * The directive may be called from within any runtime context. |
---|
312 | * |
---|
313 | * * The directive will not cause the calling task to be preempted. |
---|
314 | * @endparblock |
---|
315 | */ |
---|
316 | rtems_status_code rtems_partition_ident( |
---|
317 | rtems_name name, |
---|
318 | uint32_t node, |
---|
319 | rtems_id *id |
---|
320 | ); |
---|
321 | |
---|
322 | /* Generated from spec:/rtems/part/if/delete */ |
---|
323 | |
---|
324 | /** |
---|
325 | * @ingroup RTEMSAPIClassicPart |
---|
326 | * |
---|
327 | * @brief Deletes the partition. |
---|
328 | * |
---|
329 | * @param id is the partition identifier. |
---|
330 | * |
---|
331 | * This directive deletes the partition specified by ``id``. |
---|
332 | * |
---|
333 | * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. |
---|
334 | * |
---|
335 | * @retval ::RTEMS_INVALID_ID There was no partition associated with the |
---|
336 | * identifier specified by ``id``. |
---|
337 | * |
---|
338 | * @retval ::RTEMS_ILLEGAL_ON_REMOTE_OBJECT The partition resided on a remote |
---|
339 | * node. |
---|
340 | * |
---|
341 | * @retval ::RTEMS_RESOURCE_IN_USE There were buffers of the partition still in |
---|
342 | * use. |
---|
343 | * |
---|
344 | * @par Notes |
---|
345 | * @parblock |
---|
346 | * The partition cannot be deleted if any of its buffers are still allocated. |
---|
347 | * |
---|
348 | * The PTCB for the deleted partition is reclaimed by RTEMS. |
---|
349 | * |
---|
350 | * When a global partition is deleted, the partition identifier must be |
---|
351 | * transmitted to every node in the system for deletion from the local copy of |
---|
352 | * the global object table. |
---|
353 | * |
---|
354 | * The partition must reside on the local node, even if the partition was |
---|
355 | * created with the #RTEMS_GLOBAL attribute. |
---|
356 | * @endparblock |
---|
357 | * |
---|
358 | * @par Constraints |
---|
359 | * @parblock |
---|
360 | * The following constraints apply to this directive: |
---|
361 | * |
---|
362 | * * The directive may be called from within device driver initialization |
---|
363 | * context. |
---|
364 | * |
---|
365 | * * The directive may be called from within task context. |
---|
366 | * |
---|
367 | * * The directive may obtain and release the object allocator mutex. This may |
---|
368 | * cause the calling task to be preempted. |
---|
369 | * |
---|
370 | * * When the directive operates on a global object, the directive sends a |
---|
371 | * message to remote nodes. This may preempt the calling task. |
---|
372 | * |
---|
373 | * * The calling task does not have to be the task that created the object. |
---|
374 | * Any local task that knows the object identifier can delete the object. |
---|
375 | * |
---|
376 | * * Where the object class corresponding to the directive is configured to use |
---|
377 | * unlimited objects, the directive may free memory to the RTEMS Workspace. |
---|
378 | * @endparblock |
---|
379 | */ |
---|
380 | rtems_status_code rtems_partition_delete( rtems_id id ); |
---|
381 | |
---|
382 | /* Generated from spec:/rtems/part/if/get-buffer */ |
---|
383 | |
---|
384 | /** |
---|
385 | * @ingroup RTEMSAPIClassicPart |
---|
386 | * |
---|
387 | * @brief Tries to get a buffer from the partition. |
---|
388 | * |
---|
389 | * @param id is the partition identifier. |
---|
390 | * |
---|
391 | * @param[out] buffer is the pointer to a ``void`` pointer object. When the |
---|
392 | * directive call is successful, the pointer to the allocated buffer will be |
---|
393 | * stored in this object. |
---|
394 | * |
---|
395 | * This directive allows a buffer to be obtained from the partition specified |
---|
396 | * by ``id``. The address of the allocated buffer is returned through the |
---|
397 | * ``buffer`` parameter. |
---|
398 | * |
---|
399 | * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. |
---|
400 | * |
---|
401 | * @retval ::RTEMS_INVALID_ID There was no partition associated with the |
---|
402 | * identifier specified by ``id``. |
---|
403 | * |
---|
404 | * @retval ::RTEMS_INVALID_ADDRESS The ``buffer`` parameter was NULL. |
---|
405 | * |
---|
406 | * @retval ::RTEMS_UNSATISFIED There was no free buffer available to allocate |
---|
407 | * and return. |
---|
408 | * |
---|
409 | * @par Notes |
---|
410 | * @parblock |
---|
411 | * The buffer start alignment is determined by the memory area and buffer size |
---|
412 | * used to create the partition. |
---|
413 | * |
---|
414 | * A task cannot wait on a buffer to become available. |
---|
415 | * |
---|
416 | * Getting a buffer from a global partition which does not reside on the local |
---|
417 | * node will generate a request telling the remote node to allocate a buffer |
---|
418 | * from the partition. |
---|
419 | * @endparblock |
---|
420 | * |
---|
421 | * @par Constraints |
---|
422 | * @parblock |
---|
423 | * The following constraints apply to this directive: |
---|
424 | * |
---|
425 | * * When the directive operates on a local object, the directive may be called |
---|
426 | * from within interrupt context. |
---|
427 | * |
---|
428 | * * The directive may be called from within task context. |
---|
429 | * |
---|
430 | * * When the directive operates on a local object, the directive will not |
---|
431 | * cause the calling task to be preempted. |
---|
432 | * |
---|
433 | * * When the directive operates on a remote object, the directive sends a |
---|
434 | * message to the remote node and waits for a reply. This will preempt the |
---|
435 | * calling task. |
---|
436 | * @endparblock |
---|
437 | */ |
---|
438 | rtems_status_code rtems_partition_get_buffer( rtems_id id, void **buffer ); |
---|
439 | |
---|
440 | /* Generated from spec:/rtems/part/if/return-buffer */ |
---|
441 | |
---|
442 | /** |
---|
443 | * @ingroup RTEMSAPIClassicPart |
---|
444 | * |
---|
445 | * @brief Returns the buffer to the partition. |
---|
446 | * |
---|
447 | * @param id is the partition identifier. |
---|
448 | * |
---|
449 | * @param buffer is the pointer to the buffer to return. |
---|
450 | * |
---|
451 | * This directive returns the buffer specified by ``buffer`` to the partition |
---|
452 | * specified by ``id``. |
---|
453 | * |
---|
454 | * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. |
---|
455 | * |
---|
456 | * @retval ::RTEMS_INVALID_ID There was no partition associated with the |
---|
457 | * identifier specified by ``id``. |
---|
458 | * |
---|
459 | * @retval ::RTEMS_INVALID_ADDRESS The buffer referenced by ``buffer`` was not |
---|
460 | * in the partition. |
---|
461 | * |
---|
462 | * @par Notes |
---|
463 | * Returning a buffer multiple times is an error. It will corrupt the internal |
---|
464 | * state of the partition. |
---|
465 | * |
---|
466 | * @par Constraints |
---|
467 | * @parblock |
---|
468 | * The following constraints apply to this directive: |
---|
469 | * |
---|
470 | * * When the directive operates on a local object, the directive may be called |
---|
471 | * from within interrupt context. |
---|
472 | * |
---|
473 | * * The directive may be called from within task context. |
---|
474 | * |
---|
475 | * * When the directive operates on a local object, the directive will not |
---|
476 | * cause the calling task to be preempted. |
---|
477 | * |
---|
478 | * * When the directive operates on a remote object, the directive sends a |
---|
479 | * message to the remote node and waits for a reply. This will preempt the |
---|
480 | * calling task. |
---|
481 | * @endparblock |
---|
482 | */ |
---|
483 | rtems_status_code rtems_partition_return_buffer( rtems_id id, void *buffer ); |
---|
484 | |
---|
485 | #ifdef __cplusplus |
---|
486 | } |
---|
487 | #endif |
---|
488 | |
---|
489 | #endif /* _RTEMS_RTEMS_PART_H */ |
---|