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