source: rtems/cpukit/rtems/include/rtems/rtems/region.h @ 03f2154e

4.104.114.84.95
Last change on this file since 03f2154e was 03f2154e, checked in by Joel Sherrill <joel.sherrill@…>, on 04/22/97 at 17:20:27

headers updated to reflect new style copyright notice as part
of switching to the modified GNU GPL.

  • Property mode set to 100644
File size: 6.0 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-1997.
16 *  On-Line Applications Research Corporation (OAR).
17 *  Copyright assigned to U.S. Government, 1994.
18 *
19 *  The license and distribution terms for this file may in
20 *  the file LICENSE in this distribution or at
21 *  http://www.OARcorp.com/rtems/license.html.
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
62RTEMS_EXTERN 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#ifndef __RTEMS_APPLICATION__
202#include <rtems/rtems/region.inl>
203#endif
204#include <rtems/rtems/regionmp.h>
205
206/*
207 *  _Region_Debug_Walk
208 *
209 *  DESCRIPTION:
210 *
211 *  This routine is invoked to verify the integrity of a heap associated
212 *  with the_region.
213 */
214
215#ifdef RTEMS_DEBUG
216
217#define _Region_Debug_Walk( _the_region, _source ) \
218  do { \
219    if ( _Debug_Is_enabled( RTEMS_DEBUG_REGION ) ) \
220      _Heap_Walk( &(_the_region)->Memory, _source, FALSE ); \
221  } while ( 0 )
222
223#else
224
225#define _Region_Debug_Walk( _the_region, _source )
226
227#endif
228
229#ifdef __cplusplus
230}
231#endif
232
233#endif
234/* end of include file */
Note: See TracBrowser for help on using the repository browser.