source: rtems/c/src/exec/rtems/inline/part.inl @ b1b5a7cb

4.104.114.84.95
Last change on this file since b1b5a7cb was 503dc058, checked in by Joel Sherrill <joel.sherrill@…>, on Jul 3, 1996 at 2:20:03 PM

switched from "STATIC INLINE" to "RTEMS_INLINE_ROUTINE"

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