1 | /** |
---|
2 | * @file rtems/rtems/part.h |
---|
3 | * |
---|
4 | * @defgroup ClassicPart Partitions |
---|
5 | * |
---|
6 | * @ingroup ClassicRTEMS |
---|
7 | * @brief Partition Manager |
---|
8 | * |
---|
9 | * This include file contains all the constants and structures associated |
---|
10 | * with the Partition Manager. This manager provides facilities to |
---|
11 | * dynamically allocate memory in fixed-sized units which are returned |
---|
12 | * as buffers. |
---|
13 | * |
---|
14 | * Directives provided are: |
---|
15 | * |
---|
16 | * - create a partition |
---|
17 | * - get an ID of a partition |
---|
18 | * - delete a partition |
---|
19 | * - get a buffer from a partition |
---|
20 | * - return a buffer to a partition |
---|
21 | */ |
---|
22 | |
---|
23 | /* COPYRIGHT (c) 1989-2008. |
---|
24 | * On-Line Applications Research Corporation (OAR). |
---|
25 | * |
---|
26 | * The license and distribution terms for this file may be |
---|
27 | * found in the file LICENSE in this distribution or at |
---|
28 | * http://www.rtems.org/license/LICENSE. |
---|
29 | */ |
---|
30 | |
---|
31 | #ifndef _RTEMS_RTEMS_PART_H |
---|
32 | #define _RTEMS_RTEMS_PART_H |
---|
33 | |
---|
34 | #include <rtems/rtems/attr.h> |
---|
35 | #include <rtems/rtems/status.h> |
---|
36 | #include <rtems/rtems/types.h> |
---|
37 | #include <rtems/score/isrlock.h> |
---|
38 | |
---|
39 | #ifdef __cplusplus |
---|
40 | extern "C" { |
---|
41 | #endif |
---|
42 | |
---|
43 | /** |
---|
44 | * @defgroup ClassicPart Partitions |
---|
45 | * |
---|
46 | * @ingroup ClassicRTEMS |
---|
47 | * |
---|
48 | * This encapsulates functionality related to the |
---|
49 | * Classic API Partition Manager. |
---|
50 | */ |
---|
51 | /**@{*/ |
---|
52 | |
---|
53 | /** |
---|
54 | * The following defines the control block used to manage each partition. |
---|
55 | */ |
---|
56 | typedef struct { |
---|
57 | /** This field is the object management portion of a Partition instance. */ |
---|
58 | Objects_Control Object; |
---|
59 | /** This field is the lock of the Partition. */ |
---|
60 | ISR_LOCK_MEMBER( Lock ) |
---|
61 | /** This field is the physical starting address of the Partition. */ |
---|
62 | void *starting_address; |
---|
63 | /** This field is the size of the Partition in bytes. */ |
---|
64 | intptr_t length; |
---|
65 | /** This field is the size of each buffer in bytes */ |
---|
66 | uint32_t buffer_size; |
---|
67 | /** This field is the attribute set provided at create time. */ |
---|
68 | rtems_attribute attribute_set; |
---|
69 | /** This field is the of allocated buffers. */ |
---|
70 | uint32_t number_of_used_blocks; |
---|
71 | /** This field is the chain used to manage unallocated buffers. */ |
---|
72 | Chain_Control Memory; |
---|
73 | } Partition_Control; |
---|
74 | |
---|
75 | /** |
---|
76 | * @brief RTEMS Partition Create |
---|
77 | * |
---|
78 | * Partition Manager |
---|
79 | * |
---|
80 | * This routine implements the rtems_partition_create directive. The |
---|
81 | * partition will have the name name. The memory area managed by |
---|
82 | * the partition is of length bytes and starts at starting_address. |
---|
83 | * The memory area will be divided into as many buffers of |
---|
84 | * buffer_size bytes as possible. The attribute_set determines if |
---|
85 | * the partition is global or local. It returns the id of the |
---|
86 | * created partition in ID. |
---|
87 | */ |
---|
88 | rtems_status_code rtems_partition_create( |
---|
89 | rtems_name name, |
---|
90 | void *starting_address, |
---|
91 | uint32_t length, |
---|
92 | uint32_t buffer_size, |
---|
93 | rtems_attribute attribute_set, |
---|
94 | rtems_id *id |
---|
95 | ); |
---|
96 | |
---|
97 | /** |
---|
98 | * @brief RTEMS Partition Ident |
---|
99 | * |
---|
100 | * This routine implements the rtems_partition_ident directive. |
---|
101 | * This directive returns the partition ID associated with name. |
---|
102 | * If more than one partition is named name, then the partition |
---|
103 | * to which the ID belongs is arbitrary. node indicates the |
---|
104 | * extent of the search for the ID of the partition named name. |
---|
105 | * The search can be limited to a particular node or allowed to |
---|
106 | * encompass all nodes. |
---|
107 | * |
---|
108 | * @param[in] name is the user defined partition name |
---|
109 | * @param[in] node is(are) the node(s) to be searched |
---|
110 | * @param[in] id is the pointer to partition id |
---|
111 | * |
---|
112 | * @retval RTEMS_SUCCESSFUL if successful or error code if unsuccessful and |
---|
113 | * *id filled in with the partition id |
---|
114 | */ |
---|
115 | rtems_status_code rtems_partition_ident( |
---|
116 | rtems_name name, |
---|
117 | uint32_t node, |
---|
118 | rtems_id *id |
---|
119 | ); |
---|
120 | |
---|
121 | /** |
---|
122 | * @brief RTEMS Delete Partition |
---|
123 | * |
---|
124 | * This routine implements the rtems_partition_delete directive. The |
---|
125 | * partition indicated by ID is deleted, provided that none of its buffers |
---|
126 | * are still allocated. |
---|
127 | * |
---|
128 | * @param[in] id is the partition id |
---|
129 | * |
---|
130 | * @retval This method returns RTEMS_SUCCESSFUL if there was not an |
---|
131 | * error. Otherwise, a status code is returned indicating the |
---|
132 | * source of the error. |
---|
133 | */ |
---|
134 | rtems_status_code rtems_partition_delete( |
---|
135 | rtems_id id |
---|
136 | ); |
---|
137 | |
---|
138 | /** |
---|
139 | * @brief RTEMS Get Partition Buffer |
---|
140 | * |
---|
141 | * This routine implements the rtems_partition_get_buffer directive. It |
---|
142 | * attempts to allocate a buffer from the partition associated with ID. |
---|
143 | * If a buffer is allocated, its address is returned in buffer. |
---|
144 | * |
---|
145 | * @param[in] id is the partition id |
---|
146 | * @param[out] buffer is the pointer to buffer address |
---|
147 | * |
---|
148 | * @retval RTEMS_SUCCESSFUL if successful or error code if unsuccessful |
---|
149 | */ |
---|
150 | rtems_status_code rtems_partition_get_buffer( |
---|
151 | rtems_id id, |
---|
152 | void **buffer |
---|
153 | ); |
---|
154 | |
---|
155 | /** |
---|
156 | * @brief rtems_partition_return_buffer |
---|
157 | * |
---|
158 | * This routine implements the rtems_partition_return_buffer directive. It |
---|
159 | * frees the buffer to the partition associated with ID. The buffer must |
---|
160 | * have been previously allocated from the same partition. |
---|
161 | */ |
---|
162 | rtems_status_code rtems_partition_return_buffer( |
---|
163 | rtems_id id, |
---|
164 | void *buffer |
---|
165 | ); |
---|
166 | |
---|
167 | /**@}*/ |
---|
168 | |
---|
169 | #ifdef __cplusplus |
---|
170 | } |
---|
171 | #endif |
---|
172 | |
---|
173 | #endif |
---|
174 | /* end of include file */ |
---|