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

4.104.114.95
Last change on this file since f9293df was f9293df, checked in by Joel Sherrill <joel.sherrill@…>, on 04/18/08 at 20:08:08

2008-04-18 Joel Sherrill <joel.sherrill@…>

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