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