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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [rtems/] [c/] [src/] [exec/] [rtems/] [inline/] [rtems/] [rtems/] [part.inl] - Blame information for rev 593

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 30 unneback
/*  part.inl
2
 *
3
 *  This file contains the macro implementation of all inlined routines
4
 *  in the Partition Manager.
5
 *
6
 *  COPYRIGHT (c) 1989-1999.
7
 *  On-Line Applications Research Corporation (OAR).
8
 *
9
 *  The license and distribution terms for this file may be
10
 *  found in the file LICENSE in this distribution or at
11
 *  http://www.OARcorp.com/rtems/license.html.
12
 *
13
 *  $Id: part.inl,v 1.2 2001-09-27 11:59:18 chris Exp $
14
 */
15
 
16
#ifndef __PARTITION_inl
17
#define __PARTITION_inl
18
 
19
/*PAGE
20
 *
21
 *  _Partition_Allocate_buffer
22
 *
23
 *  DESCRIPTION:
24
 *
25
 *  This function attempts to allocate a buffer from the_partition.
26
 *  If successful, it returns the address of the allocated buffer.
27
 *  Otherwise, it returns NULL.
28
 */
29
 
30
RTEMS_INLINE_ROUTINE void *_Partition_Allocate_buffer (
31
   Partition_Control *the_partition
32
)
33
{
34
  return _Chain_Get( &the_partition->Memory );
35
}
36
 
37
/*PAGE
38
 *
39
 *  _Partition_Free_buffer
40
 *
41
 *  DESCRIPTION:
42
 *
43
 *  This routine frees the_buffer to the_partition.
44
 */
45
 
46
RTEMS_INLINE_ROUTINE void _Partition_Free_buffer (
47
  Partition_Control *the_partition,
48
  Chain_Node        *the_buffer
49
)
50
{
51
  _Chain_Append( &the_partition->Memory, the_buffer );
52
}
53
 
54
/*PAGE
55
 *
56
 *  _Partition_Is_buffer_on_boundary
57
 *
58
 *  DESCRIPTION:
59
 *
60
 *  This function returns TRUE if the_buffer is on a valid buffer
61
 *  boundary for the_partition, and FALSE otherwise.
62
 */
63
 
64
RTEMS_INLINE_ROUTINE boolean _Partition_Is_buffer_on_boundary (
65
  void              *the_buffer,
66
  Partition_Control *the_partition
67
)
68
{
69
  unsigned32   offset;
70
 
71
  offset = (unsigned32) _Addresses_Subtract(
72
    the_buffer,
73
    the_partition->starting_address
74
  );
75
 
76
  return ((offset % the_partition->buffer_size) == 0);
77
}
78
 
79
/*PAGE
80
 *
81
 *  _Partition_Is_buffer_valid
82
 *
83
 *  DESCRIPTION:
84
 *
85
 *  This function returns TRUE if the_buffer is a valid buffer from
86
 *  the_partition, otherwise FALSE is returned.
87
 */
88
 
89
RTEMS_INLINE_ROUTINE boolean _Partition_Is_buffer_valid (
90
   Chain_Node        *the_buffer,
91
   Partition_Control *the_partition
92
)
93
{
94
  void *starting;
95
  void *ending;
96
 
97
  starting = the_partition->starting_address;
98
  ending   = _Addresses_Add_offset( starting, the_partition->length );
99
 
100
  return (
101
    _Addresses_Is_in_range( the_buffer, starting, ending ) &&
102
    _Partition_Is_buffer_on_boundary( the_buffer, the_partition )
103
  );
104
}
105
 
106
/*PAGE
107
 *
108
 *  _Partition_Is_buffer_size_aligned
109
 *
110
 *  DESCRIPTION:
111
 *
112
 *  This function returns TRUE if the use of the specified buffer_size
113
 *  will result in the allocation of buffers whose first byte is
114
 *  properly aligned, and FALSE otherwise.
115
 */
116
 
117
RTEMS_INLINE_ROUTINE boolean _Partition_Is_buffer_size_aligned (
118
   unsigned32 buffer_size
119
)
120
{
121
  return ((buffer_size % CPU_PARTITION_ALIGNMENT) == 0);
122
}
123
 
124
/*PAGE
125
 *
126
 *  _Partition_Allocate
127
 *
128
 *  DESCRIPTION:
129
 *
130
 *  This function allocates a partition control block from
131
 *  the inactive chain of free partition control blocks.
132
 */
133
 
134
RTEMS_INLINE_ROUTINE Partition_Control *_Partition_Allocate ( void )
135
{
136
  return (Partition_Control *) _Objects_Allocate( &_Partition_Information );
137
}
138
 
139
/*PAGE
140
 *
141
 *  _Partition_Free
142
 *
143
 *  DESCRIPTION:
144
 *
145
 *  This routine frees a partition control block to the
146
 *  inactive chain of free partition control blocks.
147
 */
148
 
149
RTEMS_INLINE_ROUTINE void _Partition_Free (
150
   Partition_Control *the_partition
151
)
152
{
153
  _Objects_Free( &_Partition_Information, &the_partition->Object );
154
}
155
 
156
/*PAGE
157
 *
158
 *  _Partition_Get
159
 *
160
 *  DESCRIPTION:
161
 *
162
 *  This function maps partition IDs to partition control blocks.
163
 *  If ID corresponds to a local partition, then it returns
164
 *  the_partition control pointer which maps to ID and location
165
 *  is set to OBJECTS_LOCAL.  If the partition ID is global and
166
 *  resides on a remote node, then location is set to OBJECTS_REMOTE,
167
 *  and the_partition is undefined.  Otherwise, location is set
168
 *  to OBJECTS_ERROR and the_partition is undefined.
169
 */
170
 
171
RTEMS_INLINE_ROUTINE Partition_Control *_Partition_Get (
172
  Objects_Id         id,
173
  Objects_Locations *location
174
)
175
{
176
  return (Partition_Control *)
177
    _Objects_Get( &_Partition_Information, id, location );
178
}
179
 
180
/*PAGE
181
 *
182
 *  _Partition_Is_null
183
 *
184
 *  DESCRIPTION:
185
 *
186
 *  This function returns TRUE if the_partition is NULL
187
 *  and FALSE otherwise.
188
 */
189
 
190
RTEMS_INLINE_ROUTINE boolean _Partition_Is_null (
191
   Partition_Control *the_partition
192
)
193
{
194
   return ( the_partition == NULL  );
195
}
196
 
197
#endif
198
/* end of include file */

powered by: WebSVN 2.1.0

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