OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [rtos/] [rtems/] [c/] [src/] [exec/] [rtems/] [include/] [rtems/] [rtems/] [region.h] - Blame information for rev 173

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 30 unneback
/*  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-1999.
16
 *  On-Line Applications Research Corporation (OAR).
17
 *
18
 *  The license and distribution terms for this file may be
19
 *  found in the file LICENSE in this distribution or at
20
 *  http://www.OARcorp.com/rtems/license.html.
21
 *
22
 *  $Id: region.h,v 1.2 2001-09-27 11:59:18 chris Exp $
23
 */
24
 
25
#ifndef __RTEMS_REGION_h
26
#define __RTEMS_REGION_h
27
 
28
#ifdef __cplusplus
29
extern "C" {
30
#endif
31
 
32
#include <rtems/score/object.h>
33
#include <rtems/score/threadq.h>
34
#include <rtems/score/heap.h>
35
#include <rtems/debug.h>
36
#include <rtems/rtems/attr.h>
37
#include <rtems/rtems/types.h>
38
 
39
/*
40
 *  The following records define the control block used to manage
41
 *  each region.
42
 */
43
 
44
typedef struct {
45
  Objects_Control       Object;
46
  Thread_queue_Control  Wait_queue;            /* waiting threads        */
47
  void                 *starting_address;      /* physical start addr    */
48
  unsigned32            length;                /* physical length(bytes) */
49
  unsigned32            page_size;             /* in bytes               */
50
  unsigned32            maximum_segment_size;  /* in bytes               */
51
  rtems_attribute       attribute_set;
52
  unsigned32            number_of_used_blocks; /* blocks allocated       */
53
  Heap_Control          Memory;
54
}  Region_Control;
55
 
56
/*
57
 *  The following defines the information control block used to
58
 *  manage this class of objects.
59
 */
60
 
61
RTEMS_EXTERN Objects_Information _Region_Information;
62
 
63
/*
64
 *  _Region_Manager_initialization
65
 *
66
 *  DESCRIPTION:
67
 *
68
 *  This routine performs the initialization necessary for this manager.
69
 */
70
 
71
void _Region_Manager_initialization(
72
  unsigned32 maximum_regions
73
);
74
 
75
/*
76
 *  rtems_region_create
77
 *
78
 *  DESCRIPTION:
79
 *
80
 *  This routine implements the rtems_region_create directive.  The
81
 *  region will have the name name.  The memory area managed by
82
 *  the region is of length bytes and starts at starting_address.
83
 *  The memory area will be divided into as many allocatable units of
84
 *  page_size bytes as possible.   The attribute_set determines which
85
 *  thread queue discipline is used by the region.  It returns the
86
 *  id of the created region in ID.
87
 */
88
 
89
rtems_status_code rtems_region_create(
90
  rtems_name          name,
91
  void               *starting_address,
92
  unsigned32          length,
93
  unsigned32          page_size,
94
  rtems_attribute  attribute_set,
95
  Objects_Id         *id
96
);
97
 
98
/*
99
 *  rtems_region_extend
100
 *
101
 *  DESCRIPTION:
102
 *
103
 *  This routine implements the rtems_region_extend directive.  The
104
 *  region will have the name name.  The memory area managed by
105
 *  the region will be attempted to be grown by length bytes using
106
 *  the memory starting at starting_address.
107
 */
108
 
109
rtems_status_code rtems_region_extend(
110
  Objects_Id          id,
111
  void               *starting_address,
112
  unsigned32          length
113
);
114
 
115
/*
116
 *  rtems_region_ident
117
 *
118
 *  DESCRIPTION:
119
 *
120
 *  This routine implements the rtems_region_ident directive.
121
 *  This directive returns the region ID associated with name.
122
 *  If more than one region is named name, then the region
123
 *  to which the ID belongs is arbitrary.
124
 */
125
 
126
rtems_status_code rtems_region_ident(
127
  rtems_name    name,
128
  Objects_Id   *id
129
);
130
 
131
/*
132
 *  rtems_region_delete
133
 *
134
 *  DESCRIPTION:
135
 *
136
 *  This routine implements the rtems_region_delete directive.  The
137
 *  region indicated by ID is deleted.
138
 */
139
 
140
rtems_status_code rtems_region_delete(
141
  Objects_Id id
142
);
143
 
144
/*
145
 *  rtems_region_get_segment
146
 *
147
 *  DESCRIPTION:
148
 *
149
 *  This routine implements the rtems_region_get_segment directive.  It
150
 *  attempts to allocate a segment from the region associated with ID.
151
 *  If a segment of the requested size can be allocated, its address
152
 *  is returned in segment.  If no segment is available, then the task
153
 *  may return immediately or block waiting for a segment with an optional
154
 *  timeout of timeout clock ticks.  Whether the task blocks or returns
155
 *  immediately is based on the no_wait option in the option_set.
156
 */
157
 
158
rtems_status_code rtems_region_get_segment(
159
  Objects_Id         id,
160
  unsigned32         size,
161
  rtems_option       option_set,
162
  rtems_interval     timeout,
163
  void              **segment
164
);
165
 
166
/*
167
 *  rtems_region_get_segment_size
168
 *
169
 *  DESCRIPTION:
170
 *
171
 *  This routine implements the rtems_region_get_segment_size directive.  It
172
 *  returns the size in bytes of the specified user memory area.
173
 */
174
 
175
rtems_status_code rtems_region_get_segment_size(
176
  Objects_Id         id,
177
  void              *segment,
178
  unsigned32        *size
179
);
180
 
181
/*
182
 *  rtems_region_return_segment
183
 *
184
 *  DESCRIPTION:
185
 *
186
 *  This routine implements the rtems_region_return_segment directive.  It
187
 *  frees the segment to the region associated with ID.  The segment must
188
 *  have been previously allocated from the same region.  If freeing the
189
 *  segment results in enough memory being available to satisfy the
190
 *  rtems_region_get_segment of the first blocked task, then that task and as
191
 *  many subsequent tasks as possible will be unblocked with their requests
192
 *  satisfied.
193
 */
194
 
195
rtems_status_code rtems_region_return_segment(
196
  Objects_Id  id,
197
  void       *segment
198
);
199
 
200
#ifndef __RTEMS_APPLICATION__
201
#include <rtems/rtems/region.inl>
202
#endif
203
#if defined(RTEMS_MULTIPROCESSING)
204
#include <rtems/rtems/regionmp.h>
205
#endif
206
 
207
/*
208
 *  _Region_Debug_Walk
209
 *
210
 *  DESCRIPTION:
211
 *
212
 *  This routine is invoked to verify the integrity of a heap associated
213
 *  with the_region.
214
 */
215
 
216
#ifdef RTEMS_DEBUG
217
 
218
#define _Region_Debug_Walk( _the_region, _source ) \
219
  do { \
220
    if ( _Debug_Is_enabled( RTEMS_DEBUG_REGION ) ) \
221
      _Heap_Walk( &(_the_region)->Memory, _source, FALSE ); \
222
  } while ( 0 )
223
 
224
#else
225
 
226
#define _Region_Debug_Walk( _the_region, _source )
227
 
228
#endif
229
 
230
#ifdef __cplusplus
231
}
232
#endif
233
 
234
#endif
235
/* end of include file */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.