1 | Partition Manager |
---|
2 | ################# |
---|
3 | |
---|
4 | .. index:: partitions |
---|
5 | |
---|
6 | Introduction |
---|
7 | ============ |
---|
8 | |
---|
9 | The partition manager provides facilities to |
---|
10 | dynamically allocate memory in fixed-size units. The directives |
---|
11 | provided by the partition manager are: |
---|
12 | |
---|
13 | - ``rtems.partition_create`` - Create a partition |
---|
14 | |
---|
15 | - ``rtems.partition_ident`` - Get ID of a partition |
---|
16 | |
---|
17 | - ``rtems.partition_delete`` - Delete a partition |
---|
18 | |
---|
19 | - ``rtems.partition_get_buffer`` - Get buffer from a partition |
---|
20 | |
---|
21 | - ``rtems.partition_return_buffer`` - Return buffer to a partition |
---|
22 | |
---|
23 | Background |
---|
24 | ========== |
---|
25 | |
---|
26 | Partition Manager Definitions |
---|
27 | ----------------------------- |
---|
28 | .. index:: partition, definition |
---|
29 | |
---|
30 | A partition is a physically contiguous memory area |
---|
31 | divided into fixed-size buffers that can be dynamically |
---|
32 | allocated and deallocated... index:: buffers, definition |
---|
33 | |
---|
34 | Partitions are managed and maintained as a list of |
---|
35 | buffers. Buffers are obtained from the front of the partitionâs |
---|
36 | free buffer chain and returned to the rear of the same chain. |
---|
37 | When a buffer is on the free buffer chain, RTEMS uses two |
---|
38 | pointers of memory from each buffer as the free buffer chain. |
---|
39 | When a buffer is allocated, the entire buffer is available for application use. |
---|
40 | Therefore, modifying memory that is outside of an allocated |
---|
41 | buffer could destroy the free buffer chain or the contents of an |
---|
42 | adjacent allocated buffer. |
---|
43 | |
---|
44 | Building a Partition Attribute Set |
---|
45 | ---------------------------------- |
---|
46 | .. index:: partition attribute set, building |
---|
47 | |
---|
48 | In general, an attribute set is built by a bitwise OR |
---|
49 | of the desired attribute components. The set of valid partition |
---|
50 | attributes is provided in the following table: |
---|
51 | |
---|
52 | - ``RTEMS.LOCAL`` - local partition (default) |
---|
53 | |
---|
54 | - ``RTEMS.GLOBAL`` - global partition |
---|
55 | |
---|
56 | Attribute values are specifically designed to be |
---|
57 | mutually exclusive, therefore bitwise OR and addition operations |
---|
58 | are equivalent as long as each attribute appears exactly once in |
---|
59 | the component list. An attribute listed as a default is not |
---|
60 | required to appear in the attribute list, although it is a good |
---|
61 | programming practice to specify default attributes. If all |
---|
62 | defaults are desired, the attribute``RTEMS.DEFAULT_ATTRIBUTES`` should be |
---|
63 | specified on this call. The attribute_set parameter should be``RTEMS.GLOBAL`` to indicate that the partition |
---|
64 | is to be known globally. |
---|
65 | |
---|
66 | Operations |
---|
67 | ========== |
---|
68 | |
---|
69 | Creating a Partition |
---|
70 | -------------------- |
---|
71 | |
---|
72 | The ``rtems.partition_create`` directive creates a partition |
---|
73 | with a user-specified name. The partitionâs name, starting |
---|
74 | address, length and buffer size are all specified to the``rtems.partition_create`` directive. |
---|
75 | RTEMS allocates a Partition Control |
---|
76 | Block (PTCB) from the PTCB free list. This data structure is |
---|
77 | used by RTEMS to manage the newly created partition. The number |
---|
78 | of buffers in the partition is calculated based upon the |
---|
79 | specified partition length and buffer size. If successful,the |
---|
80 | unique partition ID is returned to the calling task. |
---|
81 | |
---|
82 | Obtaining Partition IDs |
---|
83 | ----------------------- |
---|
84 | |
---|
85 | When a partition is created, RTEMS generates a unique |
---|
86 | partition ID and assigned it to the created partition until it |
---|
87 | is deleted. The partition ID may be obtained by either of two |
---|
88 | methods. First, as the result of an invocation of the``rtems.partition_create`` directive, the partition |
---|
89 | ID is stored in a user provided location. Second, the partition |
---|
90 | ID may be obtained later using the ``rtems.partition_ident`` |
---|
91 | directive. The partition ID is used by other partition manager directives |
---|
92 | to access this partition. |
---|
93 | |
---|
94 | Acquiring a Buffer |
---|
95 | ------------------ |
---|
96 | |
---|
97 | A buffer can be obtained by calling the``rtems.partition_get_buffer`` directive. |
---|
98 | If a buffer is available, then |
---|
99 | it is returned immediately with a successful return code. |
---|
100 | Otherwise, an unsuccessful return code is returned immediately |
---|
101 | to the caller. Tasks cannot block to wait for a buffer to |
---|
102 | become available. |
---|
103 | |
---|
104 | Releasing a Buffer |
---|
105 | ------------------ |
---|
106 | |
---|
107 | Buffers are returned to a partitionâs free buffer |
---|
108 | chain with the ``rtems.partition_return_buffer`` directive. This |
---|
109 | directive returns an error status code if the returned buffer |
---|
110 | was not previously allocated from this partition. |
---|
111 | |
---|
112 | Deleting a Partition |
---|
113 | -------------------- |
---|
114 | |
---|
115 | The ``rtems.partition_delete`` directive allows a partition to |
---|
116 | be removed and returned to RTEMS. When a partition is deleted, |
---|
117 | the PTCB for that partition is returned to the PTCB free list. |
---|
118 | A partition with buffers still allocated cannot be deleted. Any |
---|
119 | task attempting to do so will be returned an error status code. |
---|
120 | |
---|
121 | Directives |
---|
122 | ========== |
---|
123 | |
---|
124 | This section details the partition managerâs |
---|
125 | directives. A subsection is dedicated to each of this managerâs |
---|
126 | directives and describes the calling sequence, related |
---|
127 | constants, usage, and status codes. |
---|
128 | |
---|
129 | PARTITION_CREATE - Create a partition |
---|
130 | ------------------------------------- |
---|
131 | .. index:: create a partition |
---|
132 | |
---|
133 | **CALLING SEQUENCE:** |
---|
134 | |
---|
135 | .. code:: c |
---|
136 | |
---|
137 | procedure Partition_Create ( |
---|
138 | Name : in RTEMS.Name; |
---|
139 | Starting_Address : in RTEMS.Address; |
---|
140 | Length : in RTEMS.Unsigned32; |
---|
141 | Buffer_Size : in RTEMS.Unsigned32; |
---|
142 | Attribute_Set : in RTEMS.Attribute; |
---|
143 | ID : out RTEMS.ID; |
---|
144 | Result : out RTEMS.Status_Codes |
---|
145 | ); |
---|
146 | |
---|
147 | **DIRECTIVE STATUS CODES:** |
---|
148 | |
---|
149 | ``RTEMS.SUCCESSFUL`` - partition created successfully |
---|
150 | ``RTEMS.INVALID_NAME`` - invalid partition name |
---|
151 | ``RTEMS.TOO_MANY`` - too many partitions created |
---|
152 | ``RTEMS.INVALID_ADDRESS`` - address not on four byte boundary |
---|
153 | ``RTEMS.INVALID_ADDRESS`` - ``starting_address`` is NULL |
---|
154 | ``RTEMS.INVALID_ADDRESS`` - ``id`` is NULL |
---|
155 | ``RTEMS.INVALID_SIZE`` - length or buffer size is 0 |
---|
156 | ``RTEMS.INVALID_SIZE`` - length is less than the buffer size |
---|
157 | ``RTEMS.INVALID_SIZE`` - buffer size not a multiple of 4 |
---|
158 | ``RTEMS.MP_NOT_CONFIGURED`` - multiprocessing not configured |
---|
159 | ``RTEMS.TOO_MANY`` - too many global objects |
---|
160 | |
---|
161 | **DESCRIPTION:** |
---|
162 | |
---|
163 | This directive creates a partition of fixed size |
---|
164 | buffers from a physically contiguous memory space which starts |
---|
165 | at starting_address and is length bytes in size. Each allocated |
---|
166 | buffer is to be of ``buffer_size`` in bytes. The assigned |
---|
167 | partition id is returned in ``id``. This partition id is used to |
---|
168 | access the partition with other partition related directives. |
---|
169 | For control and maintenance of the partition, RTEMS allocates a |
---|
170 | PTCB from the local PTCB free pool and initializes it. |
---|
171 | |
---|
172 | **NOTES:** |
---|
173 | |
---|
174 | This directive will not cause the calling task to be |
---|
175 | preempted. |
---|
176 | |
---|
177 | The ``starting_address`` must be properly aligned for the |
---|
178 | target architecture. |
---|
179 | |
---|
180 | The ``buffer_size`` parameter must be a multiple of |
---|
181 | the CPU alignment factor. Additionally, ``buffer_size`` |
---|
182 | must be large enough to hold two pointers on the target |
---|
183 | architecture. This is required for RTEMS to manage the |
---|
184 | buffers when they are free. |
---|
185 | |
---|
186 | Memory from the partition is not used by RTEMS to |
---|
187 | store the Partition Control Block. |
---|
188 | |
---|
189 | The following partition attribute constants are |
---|
190 | defined by RTEMS: |
---|
191 | |
---|
192 | - ``RTEMS.LOCAL`` - local partition (default) |
---|
193 | |
---|
194 | - ``RTEMS.GLOBAL`` - global partition |
---|
195 | |
---|
196 | The PTCB for a global partition is allocated on the |
---|
197 | local node. The memory space used for the partition must reside |
---|
198 | in shared memory. Partitions should not be made global unless |
---|
199 | remote tasks must interact with the partition. This is to avoid |
---|
200 | the overhead incurred by the creation of a global partition. |
---|
201 | When a global partition is created, the partitionâs name and id |
---|
202 | must be transmitted to every node in the system for insertion in |
---|
203 | the local copy of the global object table. |
---|
204 | |
---|
205 | The total number of global objects, including |
---|
206 | partitions, is limited by the maximum_global_objects field in |
---|
207 | the Configuration Table. |
---|
208 | |
---|
209 | PARTITION_IDENT - Get ID of a partition |
---|
210 | --------------------------------------- |
---|
211 | .. index:: get ID of a partition |
---|
212 | .. index:: obtain ID of a partition |
---|
213 | |
---|
214 | **CALLING SEQUENCE:** |
---|
215 | |
---|
216 | .. code:: c |
---|
217 | |
---|
218 | procedure Partition_Ident ( |
---|
219 | Name : in RTEMS.Name; |
---|
220 | Node : in RTEMS.Unsigned32; |
---|
221 | ID : out RTEMS.ID; |
---|
222 | Result : out RTEMS.Status_Codes |
---|
223 | ); |
---|
224 | |
---|
225 | **DIRECTIVE STATUS CODES:** |
---|
226 | |
---|
227 | ``RTEMS.SUCCESSFUL`` - partition identified successfully |
---|
228 | ``RTEMS.INVALID_ADDRESS`` - ``id`` is NULL |
---|
229 | ``RTEMS.INVALID_NAME`` - partition name not found |
---|
230 | ``RTEMS.INVALID_NODE`` - invalid node id |
---|
231 | |
---|
232 | **DESCRIPTION:** |
---|
233 | |
---|
234 | This directive obtains the partition id associated |
---|
235 | with the partition name. If the partition name is not unique, |
---|
236 | then the partition id will match one of the partitions with that |
---|
237 | name. However, this partition id is not guaranteed to |
---|
238 | correspond to the desired partition. The partition id is used |
---|
239 | with other partition related directives to access the partition. |
---|
240 | |
---|
241 | **NOTES:** |
---|
242 | |
---|
243 | This directive will not cause the running task to be |
---|
244 | preempted. |
---|
245 | |
---|
246 | If node is ``RTEMS.SEARCH_ALL_NODES``, all nodes are searched |
---|
247 | with the local node being searched first. All other nodes are |
---|
248 | searched with the lowest numbered node searched first. |
---|
249 | |
---|
250 | If node is a valid node number which does not |
---|
251 | represent the local node, then only the partitions exported by |
---|
252 | the designated node are searched. |
---|
253 | |
---|
254 | This directive does not generate activity on remote |
---|
255 | nodes. It accesses only the local copy of the global object |
---|
256 | table. |
---|
257 | |
---|
258 | PARTITION_DELETE - Delete a partition |
---|
259 | ------------------------------------- |
---|
260 | .. index:: delete a partition |
---|
261 | |
---|
262 | **CALLING SEQUENCE:** |
---|
263 | |
---|
264 | .. code:: c |
---|
265 | |
---|
266 | procedure Partition_Delete ( |
---|
267 | ID : in RTEMS.ID; |
---|
268 | Result : out RTEMS.Status_Codes |
---|
269 | ); |
---|
270 | |
---|
271 | **DIRECTIVE STATUS CODES:** |
---|
272 | |
---|
273 | ``RTEMS.SUCCESSFUL`` - partition deleted successfully |
---|
274 | ``RTEMS.INVALID_ID`` - invalid partition id |
---|
275 | ``RTEMS.RESOURCE_IN_USE`` - buffers still in use |
---|
276 | ``RTEMS.ILLEGAL_ON_REMOTE_OBJECT`` - cannot delete remote partition |
---|
277 | |
---|
278 | **DESCRIPTION:** |
---|
279 | |
---|
280 | This directive deletes the partition specified by id. |
---|
281 | The partition cannot be deleted if any of its buffers are still |
---|
282 | allocated. The PTCB for the deleted partition is reclaimed by |
---|
283 | RTEMS. |
---|
284 | |
---|
285 | **NOTES:** |
---|
286 | |
---|
287 | This directive will not cause the calling task to be |
---|
288 | preempted. |
---|
289 | |
---|
290 | The calling task does not have to be the task that |
---|
291 | created the partition. Any local task that knows the partition |
---|
292 | id can delete the partition. |
---|
293 | |
---|
294 | When a global partition is deleted, the partition id |
---|
295 | must be transmitted to every node in the system for deletion |
---|
296 | from the local copy of the global object table. |
---|
297 | |
---|
298 | The partition must reside on the local node, even if |
---|
299 | the partition was created with the ``RTEMS.GLOBAL`` option. |
---|
300 | |
---|
301 | PARTITION_GET_BUFFER - Get buffer from a partition |
---|
302 | -------------------------------------------------- |
---|
303 | .. index:: get buffer from partition |
---|
304 | .. index:: obtain buffer from partition |
---|
305 | |
---|
306 | **CALLING SEQUENCE:** |
---|
307 | |
---|
308 | .. code:: c |
---|
309 | |
---|
310 | procedure Partition_Get_Buffer ( |
---|
311 | ID : in RTEMS.ID; |
---|
312 | Buffer : out RTEMS.Address; |
---|
313 | Result : out RTEMS.Status_Codes |
---|
314 | ); |
---|
315 | |
---|
316 | **DIRECTIVE STATUS CODES:** |
---|
317 | |
---|
318 | ``RTEMS.SUCCESSFUL`` - buffer obtained successfully |
---|
319 | ``RTEMS.INVALID_ADDRESS`` - ``buffer`` is NULL |
---|
320 | ``RTEMS.INVALID_ID`` - invalid partition id |
---|
321 | ``RTEMS.UNSATISFIED`` - all buffers are allocated |
---|
322 | |
---|
323 | **DESCRIPTION:** |
---|
324 | |
---|
325 | This directive allows a buffer to be obtained from |
---|
326 | the partition specified in id. The address of the allocated |
---|
327 | buffer is returned in buffer. |
---|
328 | |
---|
329 | **NOTES:** |
---|
330 | |
---|
331 | This directive will not cause the running task to be |
---|
332 | preempted. |
---|
333 | |
---|
334 | All buffers begin on a four byte boundary. |
---|
335 | |
---|
336 | A task cannot wait on a buffer to become available. |
---|
337 | |
---|
338 | Getting a buffer from a global partition which does |
---|
339 | not reside on the local node will generate a request telling the |
---|
340 | remote node to allocate a buffer from the specified partition. |
---|
341 | |
---|
342 | PARTITION_RETURN_BUFFER - Return buffer to a partition |
---|
343 | ------------------------------------------------------ |
---|
344 | .. index:: return buffer to partitition |
---|
345 | |
---|
346 | **CALLING SEQUENCE:** |
---|
347 | |
---|
348 | .. code:: c |
---|
349 | |
---|
350 | procedure Partition_Return_Buffer ( |
---|
351 | ID : in RTEMS.ID; |
---|
352 | Buffer : in RTEMS.Address; |
---|
353 | Result : out RTEMS.Status_Codes |
---|
354 | ); |
---|
355 | |
---|
356 | **DIRECTIVE STATUS CODES:** |
---|
357 | |
---|
358 | ``RTEMS.SUCCESSFUL`` - buffer returned successfully |
---|
359 | ``RTEMS.INVALID_ADDRESS`` - ``buffer`` is NULL |
---|
360 | ``RTEMS.INVALID_ID`` - invalid partition id |
---|
361 | ``RTEMS.INVALID_ADDRESS`` - buffer address not in partition |
---|
362 | |
---|
363 | **DESCRIPTION:** |
---|
364 | |
---|
365 | This directive returns the buffer specified by buffer |
---|
366 | to the partition specified by id. |
---|
367 | |
---|
368 | **NOTES:** |
---|
369 | |
---|
370 | This directive will not cause the running task to be |
---|
371 | preempted. |
---|
372 | |
---|
373 | Returning a buffer to a global partition which does |
---|
374 | not reside on the local node will generate a request telling the |
---|
375 | remote node to return the buffer to the specified partition. |
---|
376 | |
---|
377 | Returning a buffer multiple times is an error. It will corrupt the internal |
---|
378 | state of the partition. |
---|
379 | |
---|
380 | .. COMMENT: COPYRIGHT (c) 1988-2002. |
---|
381 | |
---|
382 | .. COMMENT: On-Line Applications Research Corporation (OAR). |
---|
383 | |
---|
384 | .. COMMENT: All rights reserved. |
---|
385 | |
---|