source: rtems/c/src/exec/rtems/headers/region.h @ eb5a7e07

4.104.114.84.95
Last change on this file since eb5a7e07 was 5e9b32b, checked in by Joel Sherrill <joel.sherrill@…>, on 09/26/95 at 19:27:15

posix support initially added

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