source: rtems-docs/c-user/partition/directives.rst @ 346bbe6

Last change on this file since 346bbe6 was 346bbe6, checked in by Sebastian Huber <sebastian.huber@…>, on 12/01/20 at 15:50:01

c-user: Clarify rtems_partition_delete()

Move the PTCB sentence to the notes to be in line with
rtems_partition_create().

Update #3993.

  • Property mode set to 100644
File size: 13.3 KB
Line 
1.. SPDX-License-Identifier: CC-BY-SA-4.0
2
3.. Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de)
4.. Copyright (C) 1988, 2008 On-Line Applications Research Corporation (OAR)
5
6.. This file is part of the RTEMS quality process and was automatically
7.. generated.  If you find something that needs to be fixed or
8.. worded better please post a report or patch to an RTEMS mailing list
9.. or raise a bug report:
10..
11.. https://docs.rtems.org/branches/master/user/support/bugs.html
12..
13.. For information on updating and regenerating please refer to:
14..
15.. https://docs.rtems.org/branches/master/eng/req/howto.html
16
17.. _PartitionManagerDirectives:
18
19Directives
20==========
21
22This section details the directives of the Partition Manager. A subsection is
23dedicated to each of this manager's directives and lists the calling sequence,
24parameters, description, return values, and notes of the directive.
25
26.. Generated from spec:/rtems/part/if/create
27
28.. raw:: latex
29
30    \clearpage
31
32.. index:: rtems_partition_create()
33.. index:: create a partition
34
35.. _InterfaceRtemsPartitionCreate:
36
37rtems_partition_create()
38------------------------
39
40Creates a partition.
41
42.. rubric:: CALLING SEQUENCE:
43
44.. code-block:: c
45
46    rtems_status_code rtems_partition_create(
47      rtems_name      name,
48      void           *starting_address,
49      uintptr_t       length,
50      size_t          buffer_size,
51      rtems_attribute attribute_set,
52      rtems_id       *id
53    );
54
55.. rubric:: PARAMETERS:
56
57``name``
58    This parameter is the name of the partition.
59
60``starting_address``
61    This parameter is the starting address of the buffer area used by the
62    partition.
63
64``length``
65    This parameter is the length in bytes of the buffer area used by the
66    partition.
67
68``buffer_size``
69    This parameter is the size in bytes of a buffer managed by the partition.
70
71``attribute_set``
72    This parameter is the attribute set of the partition.
73
74``id``
75    This parameter is the pointer to an object identifier variable.  The
76    identifier of the created partition object will be stored in this variable,
77    in case of a successful operation.
78
79.. rubric:: DESCRIPTION:
80
81This directive creates a partition of fixed size buffers from a physically
82contiguous memory space which starts at ``starting_address`` and is ``length``
83bytes in size.  Each allocated buffer is to be of ``buffer_size`` in bytes.
84The assigned object identifier is returned in ``id``.  This identifier is used
85to access the partition with other partition related directives.
86
87The **attribute set** specified in ``attribute_set`` is built through a
88*bitwise or* of the attribute constants described below.  Attributes not
89mentioned below are not evaluated by this directive and have no effect.
90
91The partition can have **local** or **global** scope in a multiprocessing
92network (this attribute does not refer to SMP systems).
93
94* A **local** scope is the default and can be emphasized through the use of the
95  :c:macro:`RTEMS_LOCAL` attribute.  A local partition can be only used by the
96  node which created it.
97
98* A **global** scope is established if the :c:macro:`RTEMS_GLOBAL` attribute is
99  set.  The memory space used for the partition must reside in shared memory.
100  Setting the global attribute in a single node system has no effect.
101
102.. rubric:: RETURN VALUES:
103
104:c:macro:`RTEMS_SUCCESSFUL`
105    The requested operation was successful.
106
107:c:macro:`RTEMS_INVALID_NAME`
108    The partition name was invalid.
109
110:c:macro:`RTEMS_INVALID_ADDRESS`
111    The ``id`` parameter was `NULL
112    <https://en.cppreference.com/w/c/types/NULL>`_.
113
114:c:macro:`RTEMS_INVALID_SIZE`
115    The ``length`` parameter was 0.
116
117:c:macro:`RTEMS_INVALID_SIZE`
118    The ``buffer_size`` parameter was 0.
119
120:c:macro:`RTEMS_INVALID_SIZE`
121    The ``length`` parameter was less than the ``buffer_size`` parameter.
122
123:c:macro:`RTEMS_INVALID_SIZE`
124    The ``buffer_size`` parameter was not an integral multiple of the pointer
125    size.
126
127:c:macro:`RTEMS_INVALID_SIZE`
128    The ``buffer_size`` parameter was less than two times the pointer size.
129
130:c:macro:`RTEMS_INVALID_ADDRESS`
131    The ``starting_address`` parameter was not on a pointer size boundary.
132
133:c:macro:`RTEMS_TOO_MANY`
134    There was no inactive object available to create a new partition.  The
135    number of partitions available to the application is configured through the
136    :ref:`CONFIGURE_MAXIMUM_PARTITIONS` configuration option.
137
138.. rubric:: NOTES:
139
140This directive may cause the calling task to be preempted due to an obtain and
141release of the object allocator mutex.
142
143The partition buffer area specified by the ``starting_address`` must be
144properly aligned.  It must be possible to directly store target architecture
145pointers and also the user data.  For example, if the user data contains some
146long double or vector data types, the partition buffer area and the buffer size
147must take the alignment of these types into account which is usually larger
148than the pointer alignment.  A cache line alignment may be also a factor.  Use
149:c:macro:`RTEMS_PARTITION_ALIGNMENT` to specify the minimum alignment of a
150partition buffer type.
151
152The ``buffer_size`` parameter must be an integral multiple of the pointer size
153on the target architecture.  Additionally, ``buffer_size`` must be large enough
154to hold two pointers on the target architecture.  This is required for RTEMS to
155manage the buffers when they are free.
156
157For control and maintenance of the partition, RTEMS allocates a :term:`PTCB`
158from the local PTCB free pool and initializes it. Memory from the partition
159buffer area is not used by RTEMS to store the PTCB.
160
161The PTCB for a global partition is allocated on the local node.  Partitions
162should not be made global unless remote tasks must interact with the partition.
163This is to avoid the overhead incurred by the creation of a global partition.
164When a global partition is created, the partition's name and identifier must be
165transmitted to every node in the system for insertion in the local copy of the
166global object table.
167
168The total number of global objects, including partitions, is limited by the
169value of the :ref:`CONFIGURE_MP_MAXIMUM_GLOBAL_OBJECTS` application
170configuration option.
171
172.. Generated from spec:/rtems/part/if/ident
173
174.. raw:: latex
175
176    \clearpage
177
178.. index:: rtems_partition_ident()
179.. index:: get ID of a partition
180.. index:: obtain ID of a partition
181
182.. _InterfaceRtemsPartitionIdent:
183
184rtems_partition_ident()
185-----------------------
186
187Identifies a partition by the object name.
188
189.. rubric:: CALLING SEQUENCE:
190
191.. code-block:: c
192
193    rtems_status_code rtems_partition_ident(
194      rtems_name name,
195      uint32_t   node,
196      rtems_id  *id
197    );
198
199.. rubric:: PARAMETERS:
200
201``name``
202    This parameter is the object name to look up.
203
204``node``
205    This parameter is the node or node set to search for a matching object.
206
207``id``
208    This parameter is the pointer to an object identifier variable.  The object
209    identifier of an object with the specified name will be stored in this
210    variable, in case of a successful operation.
211
212.. rubric:: DESCRIPTION:
213
214This directive obtains a partition identifier associated with the partition
215name specified in ``name``.
216
217The node to search is specified in ``node``.  It shall be
218
219* a valid node number,
220
221* the constant :c:macro:`RTEMS_SEARCH_ALL_NODES` to search in all nodes,
222
223* the constant :c:macro:`RTEMS_SEARCH_LOCAL_NODE` to search in the local node
224  only, or
225
226* the constant :c:macro:`RTEMS_SEARCH_OTHER_NODES` to search in all nodes
227  except the local node.
228
229.. rubric:: RETURN VALUES:
230
231:c:macro:`RTEMS_SUCCESSFUL`
232    The requested operation was successful.
233
234:c:macro:`RTEMS_INVALID_ADDRESS`
235    The ``id`` parameter was `NULL
236    <https://en.cppreference.com/w/c/types/NULL>`_.
237
238:c:macro:`RTEMS_INVALID_NAME`
239    The ``name`` parameter was 0.
240
241:c:macro:`RTEMS_INVALID_NAME`
242    There was no object with the specified name on the specified nodes.
243
244:c:macro:`RTEMS_INVALID_NODE`
245    In multiprocessing configurations, the specified node was invalid.
246
247.. rubric:: NOTES:
248
249If the partition name is not unique, then the partition identifier will match
250the first partition with that name in the search order.  However, this
251partition identifier is not guaranteed to correspond to the desired partition.
252The partition identifier is used with other partition related directives to
253access the partition.
254
255If node is :c:macro:`RTEMS_SEARCH_ALL_NODES`, all nodes are searched with the
256local node being searched first.  All other nodes are searched with the lowest
257numbered node searched first.
258
259If node is a valid node number which does not represent the local node, then
260only the partitions exported by the designated node are searched.
261
262This directive does not generate activity on remote nodes.  It accesses only
263the local copy of the global object table.
264
265.. Generated from spec:/rtems/part/if/delete
266
267.. raw:: latex
268
269    \clearpage
270
271.. index:: rtems_partition_delete()
272.. index:: delete a partition
273
274.. _InterfaceRtemsPartitionDelete:
275
276rtems_partition_delete()
277------------------------
278
279Deletes the partition.
280
281.. rubric:: CALLING SEQUENCE:
282
283.. code-block:: c
284
285    rtems_status_code rtems_partition_delete( rtems_id id );
286
287.. rubric:: PARAMETERS:
288
289``id``
290    This parameter is the partition identifier.
291
292.. rubric:: DESCRIPTION:
293
294This directive deletes the partition specified by the ``id`` parameter.  The
295partition cannot be deleted if any of its buffers are still allocated.
296
297.. rubric:: RETURN VALUES:
298
299:c:macro:`RTEMS_SUCCESSFUL`
300    The requested operation was successful.
301
302:c:macro:`RTEMS_INVALID_ID`
303    There was no partition with the specified identifier.
304
305:c:macro:`RTEMS_ILLEGAL_ON_REMOTE_OBJECT`
306    The partition resided on a remote node.
307
308:c:macro:`RTEMS_RESOURCE_IN_USE`
309    There were buffers of the partition still in use.
310
311.. rubric:: NOTES:
312
313This directive may cause the calling task to be preempted due to an obtain and
314release of the object allocator mutex.
315
316The :term:`PTCB` for the deleted partition is reclaimed by RTEMS.
317
318The calling task does not have to be the task that created the partition. Any
319local task that knows the partition identifier can delete the partition.
320
321When a global partition is deleted, the partition identifier must be
322transmitted to every node in the system for deletion from the local copy of the
323global object table.
324
325The partition must reside on the local node, even if the partition was created
326with the :c:macro:`RTEMS_GLOBAL` attribute.
327
328.. Generated from spec:/rtems/part/if/get-buffer
329
330.. raw:: latex
331
332    \clearpage
333
334.. index:: rtems_partition_get_buffer()
335.. index:: get buffer from partition
336.. index:: obtain buffer from partition
337
338.. _InterfaceRtemsPartitionGetBuffer:
339
340rtems_partition_get_buffer()
341----------------------------
342
343Tries to get a buffer from the partition.
344
345.. rubric:: CALLING SEQUENCE:
346
347.. code-block:: c
348
349    rtems_status_code rtems_partition_get_buffer( rtems_id id, void **buffer );
350
351.. rubric:: PARAMETERS:
352
353``id``
354    This parameter is the partition identifier.
355
356``buffer``
357    This parameter is the pointer to a buffer pointer variable.  The pointer to
358    the allocated buffer will be stored in this variable, in case of a
359    successful operation.
360
361.. rubric:: DESCRIPTION:
362
363This directive allows a buffer to be obtained from the partition specified in
364the ``id`` parameter.  The address of the allocated buffer is returned through
365the ``buffer`` parameter.
366
367.. rubric:: RETURN VALUES:
368
369:c:macro:`RTEMS_SUCCESSFUL`
370    The requested operation was successful.
371
372:c:macro:`RTEMS_INVALID_ID`
373    There was no partition with the specified identifier.
374
375:c:macro:`RTEMS_INVALID_ADDRESS`
376    The ``buffer`` parameter was `NULL
377    <https://en.cppreference.com/w/c/types/NULL>`_.
378
379:c:macro:`RTEMS_UNSATISFIED`
380    There was no free buffer available to allocate and return.
381
382.. rubric:: NOTES:
383
384This directive will not cause the running task to be preempted.
385
386The buffer start alignment is determined by the memory area and buffer size
387used to create the partition.
388
389A task cannot wait on a buffer to become available.
390
391Getting a buffer from a global partition which does not reside on the local
392node will generate a request telling the remote node to allocate a buffer from
393the partition.
394
395.. Generated from spec:/rtems/part/if/return-buffer
396
397.. raw:: latex
398
399    \clearpage
400
401.. index:: rtems_partition_return_buffer()
402.. index:: return buffer to partition
403
404.. _InterfaceRtemsPartitionReturnBuffer:
405
406rtems_partition_return_buffer()
407-------------------------------
408
409Returns the buffer to the partition.
410
411.. rubric:: CALLING SEQUENCE:
412
413.. code-block:: c
414
415    rtems_status_code rtems_partition_return_buffer( rtems_id id, void *buffer );
416
417.. rubric:: PARAMETERS:
418
419``id``
420    This parameter is the partition identifier.
421
422``buffer``
423    This parameter is the pointer to the buffer to return.
424
425.. rubric:: DESCRIPTION:
426
427This directive returns the buffer specified by ``buffer`` to the partition
428specified by ``id``.
429
430.. rubric:: RETURN VALUES:
431
432:c:macro:`RTEMS_SUCCESSFUL`
433    The requested operation was successful.
434
435:c:macro:`RTEMS_INVALID_ID`
436    There was no partition with the specified identifier.
437
438:c:macro:`RTEMS_INVALID_ADDRESS`
439    The buffer referenced by ``buffer`` was not in the partition.
440
441.. rubric:: NOTES:
442
443This directive will not cause the running task to be preempted.
444
445Returning a buffer to a global partition which does not reside on the local
446node will generate a request telling the remote node to return the buffer to
447the partition.
448
449Returning a buffer multiple times is an error.  It will corrupt the internal
450state of the partition.
Note: See TracBrowser for help on using the repository browser.