source: rtems/cpukit/rtems/include/rtems/rtems/region.h @ a112364

4.115
Last change on this file since a112364 was a112364, checked in by Sebastian Huber <sebastian.huber@…>, on 07/24/13 at 15:30:26

score: Create threadq implementation header

Move implementation specific parts of tqdata.h, threadq.h and
threadq.inl into new header file threadqimpl.h. The threadq.h contains
now only the application visible API.

Delete tqdata.h.

  • Property mode set to 100644
File size: 9.7 KB
Line 
1/**
2 * @file rtems/rtems/region.h
3 *
4 * @defgroup ClassicRegion Regions
5 *
6 * @ingroup ClassicRTEMS
7 * @brief Region Manager
8 *
9 * This include file contains all the constants and structures associated
10 * with the Region Manager. This manager provides facilities to dynamically
11 * allocate memory in variable sized units which are returned as segments.
12 *
13 * Directives provided are:
14 *
15 * - create a region
16 * - get an ID of a region
17 * - delete a region
18 * - get a segment from a region
19 * - return a segment to a region
20 */
21
22/* COPYRIGHT (c) 1989-2009.
23 * On-Line Applications Research Corporation (OAR).
24 *
25 * The license and distribution terms for this file may be
26 * found in the file LICENSE in this distribution or at
27 * http://www.rtems.com/license/LICENSE.
28 */
29
30#ifndef _RTEMS_RTEMS_REGION_H
31#define _RTEMS_RTEMS_REGION_H
32
33#include <rtems/rtems/attr.h>
34#include <rtems/rtems/options.h>
35#include <rtems/rtems/status.h>
36#include <rtems/rtems/types.h>
37#include <rtems/score/heap.h>
38#include <rtems/score/threadq.h>
39
40#ifdef __cplusplus
41extern "C" {
42#endif
43
44/**
45 *  @defgroup ClassicRegion Regions
46 *
47 *  @ingroup ClassicRTEMS
48 *
49 *  This encapsulates functionality which XXX
50 */
51/**@{*/
52
53/**
54 *  The following records define the control block used to manage
55 *  each region.
56 */
57
58typedef struct {
59  Objects_Control       Object;
60  Thread_queue_Control  Wait_queue;            /* waiting threads        */
61  void                 *starting_address;      /* physical start addr    */
62  uintptr_t             length;                /* physical length(bytes) */
63  uintptr_t             page_size;             /* in bytes               */
64  uintptr_t             maximum_segment_size;  /* in bytes               */
65  rtems_attribute       attribute_set;
66  uint32_t              number_of_used_blocks; /* blocks allocated       */
67  Heap_Control          Memory;
68}  Region_Control;
69
70/**
71 *  @brief rtems_region_create
72 *
73 *  Region Manager
74 *
75 *  This routine implements the rtems_region_create directive.  The
76 *  region will have the name name.  The memory area managed by
77 *  the region is of length bytes and starts at starting_address.
78 *  The memory area will be divided into as many allocatable units of
79 *  page_size bytes as possible.   The attribute_set determines which
80 *  thread queue discipline is used by the region.  It returns the
81 *  id of the created region in ID.
82 */
83rtems_status_code rtems_region_create(
84  rtems_name          name,
85  void               *starting_address,
86  uintptr_t           length,
87  uintptr_t           page_size,
88  rtems_attribute     attribute_set,
89  rtems_id           *id
90);
91
92/**
93 * @brief RTEMS Extend Region
94 *
95 * This routine implements the rtems_region_extend directive. The
96 * region will have the name name. The memory area managed by
97 * the region will be attempted to be grown by length bytes using
98 * the memory starting at starting_address.
99 *
100 * @param[in] id is the id of region to grow
101 * @param[in] starting_address starting address of memory area for extension
102 * @param[in] length is the physical length in bytes to grow the region
103 *
104 * @retval This method returns RTEMS_SUCCESSFUL if there was not an
105 *         error. Otherwise, a status code is returned indicating the
106 *         source of the error.
107 */
108rtems_status_code rtems_region_extend(
109  rtems_id            id,
110  void               *starting_address,
111  uintptr_t           length
112);
113
114/**
115 * @brief RTEMS Region Name to Id
116 *
117 * This routine implements the rtems_region_ident directive.
118 * This directive returns the region ID associated with name.
119 * If more than one region is named name, then the region
120 * to which the ID belongs is arbitrary.
121 *
122 * @param[in] name is the user defined region name
123 * @param[in] id is the pointer to region id
124 *
125 * @retval This method returns RTEMS_SUCCESSFUL if there was not an
126 *         error. Otherwise, a status code is returned indicating the
127 *         source of the error. If successful, the id will
128 *         be filled in with the region id.
129 */
130rtems_status_code rtems_region_ident(
131  rtems_name    name,
132  rtems_id     *id
133);
134
135/**
136 * @brief RTEMS Get Region Information
137 *
138 * This routine implements the rtems_region_get_information directive.
139 * This directive returns information about the heap associated with
140 * this region.
141 *
142 * @param[in] id is the region id
143 * @param[in] the_info is the pointer to region information block
144 *
145 * @retval RTEMS_SUCCESSFUL if successful or error code if unsuccessful and
146 * *id filled with the region information block
147 */
148rtems_status_code rtems_region_get_information(
149  rtems_id                id,
150  Heap_Information_block *the_info
151);
152
153/**
154 * @brief RTEMS Get Region Free Information
155 *
156 * This routine implements the rtems_region_get_free_information directive.
157 * This directive returns information about the free blocks in the
158 * heap associated with this region. Information about the used blocks
159 * will be returned as zero.
160 *
161 * @param[in] id is the region id
162 * @param[in] the_info is the pointer to region information block
163 *
164 * @retval This method returns RTEMS_SUCCESSFUL if there was not an
165 *         error. Otherwise, a status code is returned indicating the
166 *         source of the error. If successful, the the_info will
167 *         be filled in with the region information block.
168 */
169rtems_status_code rtems_region_get_free_information(
170  rtems_id                id,
171  Heap_Information_block *the_info
172);
173
174/**
175 * @brief RTEMS Delete Region
176 *
177 * This routine implements the rtems_region_delete directive. The
178 * region indicated by ID is deleted, provided that none of its segments are
179 * still allocated.
180 *
181 * @param[in] id is the region id
182 *
183 * @retval This method returns RTEMS_SUCCESSFUL if there was not an
184 *         error. Otherwise, a status code is returned indicating the
185 *         source of the error.
186 */
187rtems_status_code rtems_region_delete(
188  rtems_id   id
189);
190
191/**
192 * @brief RTEMS Get Region Segment
193 *
194 * This routine implements the rtems_region_get_segment directive. It
195 * attempts to allocate a segment from the region associated with @a id.
196 * If a segment of the requested @a size size can be allocated, its address
197 * is returned in @a segment. If no segment is available, then the task
198 * may return immediately or block waiting for a segment with an optional
199 * timeout of @a timeout clock ticks. Whether the task blocks or returns
200 * immediately is based on the no_wait option in the @a option_set.
201 *
202 * @param[in] id is the region id
203 * @param[in] size is the segment size in bytes
204 * @param[in] option_set is the wait option
205 * @param[in] timeout is the number of ticks to wait (0 means wait forever)
206 * @param[in] segment is the pointer to segment address
207 *
208 * @retval This method returns RTEMS_SUCCESSFUL if there was not an
209 *         error. Otherwise, a status code is returned indicating the
210 *         source of the error. If successful, the segment will
211 *         be filled in with the segment address.
212 */
213rtems_status_code rtems_region_get_segment(
214  rtems_id           id,
215  uintptr_t          size,
216  rtems_option       option_set,
217  rtems_interval     timeout,
218  void             **segment
219);
220
221/**
222 * @brief RTEMS Get Region Segment Size
223 *
224 * This routine implements the rtems_region_get_segment_size directive. It
225 * returns the size in bytes of the specified user memory area.
226 *
227 * @param[in] id is the region id
228 * @param[in] segment is the segment address
229 * @param[in] size is the pointer to segment size in bytes
230 *
231 * @retval This method returns RTEMS_SUCCESSFUL if there was not an
232 *         error. Otherwise, a status code is returned indicating the
233 *         source of the error. If successful, the size will
234 *         be filled in with the segment size in bytes.
235 */
236rtems_status_code rtems_region_get_segment_size(
237  rtems_id           id,
238  void              *segment,
239  uintptr_t         *size
240);
241
242/**
243 * @brief RTEMS Return Region Segment
244 *
245 * This routine implements the rtems_region_return_segment directive. It
246 * frees the segment to the region associated with ID. The segment must
247 * have been previously allocated from the same region. If freeing the
248 * segment results in enough memory being available to satisfy the
249 * rtems_region_get_segment of the first blocked task, then that task and as
250 * many subsequent tasks as possible will be unblocked with their requests
251 * satisfied.
252 *
253 * @param[in] id is the region id
254 * @param[in] segment is the pointer to segment address
255 *
256 * @retval RTEMS_SUCCESSFUL if successful or error code if unsuccessful
257 */
258rtems_status_code rtems_region_return_segment(
259  rtems_id    id,
260  void       *segment
261);
262
263/**
264 * @brief Resize RTEMS Region Segment
265 *
266 * This routine implements the rtems_region_resize_segment directive. It
267 * tries to resize segment in the region associated with 'id' to the new size
268 * 'size' in place. The first 'size' or old size bytes of the segment
269 * (whatever is less) are guaranteed to remain unmodified. The segment must
270 * have been previously allocated from the same region. If resizing the
271 * segment results in enough memory being available to satisfy the
272 * rtems_region_get_segment of the first blocked task, then that task and as
273 * many subsequent tasks as possible will be unblocked with their requests
274 * satisfied.
275 *
276 * @param[in] id is the region id
277 * @param[in] segment is the pointer to segment address
278 * @param[in] size is the new required size
279 * @retval RTEMS_SUCCESSFUL if operation successful, RTEMS_UNSATISFIED if the
280 *         the segment can't be resized in place or any other code at failure
281 *
282 * @note On RTEMS_SUCCESSFUL or RTEMS_UNSATISFIED exit it returns into the
283 *       'old_size' the old size in bytes of the user memory area of the
284 *       specified segment.
285 */
286rtems_status_code rtems_region_resize_segment(
287  rtems_id    id,
288  void       *segment,
289  uintptr_t   size,
290  uintptr_t  *old_size
291);
292
293/**@}*/
294
295#ifdef __cplusplus
296}
297#endif
298
299#endif
300/* end of include file */
Note: See TracBrowser for help on using the repository browser.