source: rtems/cpukit/rtems/include/rtems/rtems/region.h @ 6f1384c

4.104.114.84.95
Last change on this file since 6f1384c was 6f1384c, checked in by Joel Sherrill <joel.sherrill@…>, on 05/21/07 at 23:19:36

Split Classic API data instantiation into individual files. This reduces the size of the BSS section when an optional manageer stub is used. Some tests showed about a 600 byte reduction in BSS size. Also eliminated the variables _RTEMS_tasks_User_initialization_tasks and _RTEMS_tasks_Number_of_initialization_tasks because they were only used in one place after initialized. It was a waste of space.

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