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

4.104.114.84.95
Last change on this file since ac7d5ef0 was ac7d5ef0, checked in by Joel Sherrill <joel.sherrill@…>, on 05/11/95 at 17:39:37

Initial revision

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