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