source: rtems/cpukit/rtems/include/rtems/rtems/region.h @ 9b3f187

4.104.114.84.95
Last change on this file since 9b3f187 was 9b3f187, checked in by Joel Sherrill <joel.sherrill@…>, on 11/29/04 at 22:45:43

2004-11-29 Joel Sherrill <joel@…>

  • libcsupport/src/mallocfreespace.c, rtems/Makefile.am, rtems/include/rtems/rtems/region.h, score/Makefile.am, score/include/rtems/score/heap.h, score/src/heapgetinfo.c: Add capability to return information about just the free blocks in a region or heap. Also changed the semantics of free space available to be the largest block of memory that can be allocated.
  • rtems/src/regiongetfreeinfo.c, score/src/heapgetfreeinfo.c: New files. : score/include/rtems/score/object.h, score/src/objectinitializeinformation.c: Remove warning.
  • Property mode set to 100644
File size: 6.7 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-1999.
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_REGION_h
29#define __RTEMS_REGION_h
30
31#ifdef __cplusplus
32extern "C" {
33#endif
34
35#include <stddef.h>
36
37#include <rtems/score/object.h>
38#include <rtems/score/threadq.h>
39#include <rtems/score/heap.h>
40#include <rtems/debug.h>
41#include <rtems/rtems/attr.h>
42#include <rtems/rtems/types.h>
43
44/*
45 *  The following records define the control block used to manage
46 *  each region.
47 */
48
49typedef struct {
50  Objects_Control       Object;
51  Thread_queue_Control  Wait_queue;            /* waiting threads        */
52  void                 *starting_address;      /* physical start addr    */
53  uint32_t              length;                /* physical length(bytes) */
54  uint32_t              page_size;             /* in bytes               */
55  uint32_t              maximum_segment_size;  /* in bytes               */
56  rtems_attribute       attribute_set;
57  uint32_t              number_of_used_blocks; /* blocks allocated       */
58  Heap_Control          Memory;
59}  Region_Control;
60
61/*
62 *  The following defines the information control block used to
63 *  manage this class of objects.
64 */
65
66RTEMS_EXTERN Objects_Information _Region_Information;
67
68/*
69 *  _Region_Manager_initialization
70 *
71 *  DESCRIPTION:
72 *
73 *  This routine performs the initialization necessary for this manager.
74 */
75
76void _Region_Manager_initialization(
77  uint32_t   maximum_regions
78);
79
80/*
81 *  rtems_region_create
82 *
83 *  DESCRIPTION:
84 *
85 *  This routine implements the rtems_region_create directive.  The
86 *  region will have the name name.  The memory area managed by
87 *  the region is of length bytes and starts at starting_address.
88 *  The memory area will be divided into as many allocatable units of
89 *  page_size bytes as possible.   The attribute_set determines which
90 *  thread queue discipline is used by the region.  It returns the
91 *  id of the created region in ID.
92 */
93
94rtems_status_code rtems_region_create(
95  rtems_name          name,
96  void               *starting_address,
97  uint32_t            length,
98  uint32_t            page_size,
99  rtems_attribute  attribute_set,
100  Objects_Id         *id
101);
102
103/*
104 *  rtems_region_extend
105 *
106 *  DESCRIPTION:
107 *
108 *  This routine implements the rtems_region_extend directive.  The
109 *  region will have the name name.  The memory area managed by
110 *  the region will be attempted to be grown by length bytes using
111 *  the memory starting at starting_address.
112 */
113
114rtems_status_code rtems_region_extend(
115  Objects_Id          id,
116  void               *starting_address,
117  uint32_t            length
118);
119
120/*
121 *  rtems_region_ident
122 *
123 *  DESCRIPTION:
124 *
125 *  This routine implements the rtems_region_ident directive.
126 *  This directive returns the region ID associated with name.
127 *  If more than one region is named name, then the region
128 *  to which the ID belongs is arbitrary.
129 */
130
131rtems_status_code rtems_region_ident(
132  rtems_name    name,
133  Objects_Id   *id
134);
135
136/*
137 *  rtems_region_get_information
138 *
139 *  DESCRIPTION:
140 *
141 *  This routine implements the rtems_region_get_information directive.
142 *  This directive returns information about the heap associated with
143 *  this region.
144 */
145
146rtems_status_code rtems_region_get_information(
147  Objects_Id              id,
148  Heap_Information_block *the_info
149);
150
151/*
152 *  rtems_region_get_free_information
153 *
154 *  DESCRIPTION:
155 *
156 *  This routine implements the rtems_region_get_free_information directive.
157 *  This directive returns information about the free blocks in the
158 *  heap associated with this region.
159 */
160
161rtems_status_code rtems_region_get_free_information(
162  Objects_Id              id,
163  Heap_Information_block *the_info
164);
165
166/*
167 *  rtems_region_delete
168 *
169 *  DESCRIPTION:
170 *
171 *  This routine implements the rtems_region_delete directive.  The
172 *  region indicated by ID is deleted.
173 */
174
175rtems_status_code rtems_region_delete(
176  Objects_Id id
177);
178
179/*
180 *  rtems_region_get_segment
181 *
182 *  DESCRIPTION:
183 *
184 *  This routine implements the rtems_region_get_segment directive.  It
185 *  attempts to allocate a segment from the region associated with ID.
186 *  If a segment of the requested size can be allocated, its address
187 *  is returned in segment.  If no segment is available, then the task
188 *  may return immediately or block waiting for a segment with an optional
189 *  timeout of timeout clock ticks.  Whether the task blocks or returns
190 *  immediately is based on the no_wait option in the option_set.
191 */
192
193rtems_status_code rtems_region_get_segment(
194  Objects_Id         id,
195  uint32_t           size,
196  rtems_option       option_set,
197  rtems_interval     timeout,
198  void              **segment
199);
200
201/*
202 *  rtems_region_get_segment_size
203 *
204 *  DESCRIPTION:
205 *
206 *  This routine implements the rtems_region_get_segment_size directive.  It
207 *  returns the size in bytes of the specified user memory area.
208 */
209
210rtems_status_code rtems_region_get_segment_size(
211  Objects_Id         id,
212  void              *segment,
213  size_t            *size
214);
215
216/*
217 *  rtems_region_return_segment
218 *
219 *  DESCRIPTION:
220 *
221 *  This routine implements the rtems_region_return_segment directive.  It
222 *  frees the segment to the region associated with ID.  The segment must
223 *  have been previously allocated from the same region.  If freeing the
224 *  segment results in enough memory being available to satisfy the
225 *  rtems_region_get_segment of the first blocked task, then that task and as
226 *  many subsequent tasks as possible will be unblocked with their requests
227 *  satisfied.
228 */
229
230rtems_status_code rtems_region_return_segment(
231  Objects_Id  id,
232  void       *segment
233);
234
235#ifndef __RTEMS_APPLICATION__
236#include <rtems/rtems/region.inl>
237#endif
238#if defined(RTEMS_MULTIPROCESSING)
239#include <rtems/rtems/regionmp.h>
240#endif
241
242/*
243 *  _Region_Debug_Walk
244 *
245 *  DESCRIPTION:
246 *
247 *  This routine is invoked to verify the integrity of a heap associated
248 *  with the_region.
249 */
250
251#ifdef RTEMS_DEBUG
252
253#define _Region_Debug_Walk( _the_region, _source ) \
254  do { \
255    if ( _Debug_Is_enabled( RTEMS_DEBUG_REGION ) ) \
256      _Heap_Walk( &(_the_region)->Memory, _source, FALSE ); \
257  } while ( 0 )
258
259#else
260
261#define _Region_Debug_Walk( _the_region, _source )
262
263#endif
264
265#ifdef __cplusplus
266}
267#endif
268
269#endif
270/* end of include file */
Note: See TracBrowser for help on using the repository browser.