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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [rtems-20020807/] [cpukit/] [score/] [inline/] [rtems/] [score/] [priority.inl] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1026 ivang
/*  priority.inl
2
 *
3
 *  This file contains the static inline implementation of all inlined
4
 *  routines in the Priority Handler.
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
 *  priority.inl,v 1.13 1999/11/17 17:50:37 joel Exp
14
 */
15
 
16
#ifndef __PRIORITY_inl
17
#define __PRIORITY_inl
18
 
19
#include 
20
 
21
/*PAGE
22
 *
23
 *  _Priority_Handler_initialization
24
 *
25
 *  DESCRIPTION:
26
 *
27
 *  This routine performs the initialization necessary for this handler.
28
 */
29
 
30
RTEMS_INLINE_ROUTINE void _Priority_Handler_initialization( void )
31
{
32
  unsigned32 index;
33
 
34
  _Priority_Major_bit_map = 0;
35
  for ( index=0 ; index <16 ; index++ )
36
     _Priority_Bit_map[ index ] = 0;
37
}
38
 
39
/*PAGE
40
 *
41
 *  _Priority_Is_valid
42
 *
43
 *  DESCRIPTION:
44
 *
45
 *  This function returns TRUE if the_priority if valid for a
46
 *  user task, and FALSE otherwise.
47
 */
48
 
49
RTEMS_INLINE_ROUTINE boolean _Priority_Is_valid (
50
  Priority_Control the_priority
51
)
52
{
53
  /*
54
   *  Since PRIORITY_MINIMUM is 0 and priorities are stored unsigned,
55
   *  then checking for less than 0 is unnecessary.
56
   */
57
 
58
  return ( the_priority <= PRIORITY_MAXIMUM );
59
}
60
 
61
/*PAGE
62
 *
63
 *  _Priority_Major
64
 *
65
 *  DESCRIPTION:
66
 *
67
 *  This function returns the major portion of the_priority.
68
 */
69
 
70
RTEMS_INLINE_ROUTINE unsigned32 _Priority_Major (
71
  Priority_Control the_priority
72
)
73
{
74
  return ( the_priority / 16 );
75
}
76
 
77
/*PAGE
78
 *
79
 *  _Priority_Minor
80
 *
81
 *  DESCRIPTION:
82
 *
83
 *  This function returns the minor portion of the_priority.
84
 */
85
 
86
RTEMS_INLINE_ROUTINE unsigned32 _Priority_Minor (
87
  Priority_Control the_priority
88
)
89
{
90
  return ( the_priority % 16 );
91
}
92
 
93
#if ( CPU_USE_GENERIC_BITFIELD_CODE == TRUE )
94
 
95
/*PAGE
96
 *
97
 *  _Priority_Mask
98
 *
99
 *  DESCRIPTION:
100
 *
101
 *  This function returns the mask associated with the major or minor
102
 *  number passed to it.
103
 */
104
 
105
RTEMS_INLINE_ROUTINE unsigned32 _Priority_Mask (
106
  unsigned32 bit_number
107
)
108
{
109
  return (0x8000 >> bit_number);
110
}
111
 
112
 
113
/*PAGE
114
 *
115
 *  _Priority_Bits_index
116
 *
117
 *  DESCRIPTION:
118
 *
119
 *  This function translates the bit numbers returned by the bit scan
120
 *  of a priority bit field into something suitable for use as
121
 *  a major or minor component of a priority.
122
 */
123
 
124
RTEMS_INLINE_ROUTINE unsigned32 _Priority_Bits_index (
125
  unsigned32 bit_number
126
)
127
{
128
  return bit_number;
129
}
130
 
131
#endif
132
 
133
/*PAGE
134
 *
135
 *  _Priority_Add_to_bit_map
136
 *
137
 *  DESCRIPTION:
138
 *
139
 *  This routine uses the_priority_map to update the priority
140
 *  bit maps to indicate that a thread has been readied.
141
 */
142
 
143
RTEMS_INLINE_ROUTINE void _Priority_Add_to_bit_map (
144
  Priority_Information *the_priority_map
145
)
146
{
147
  *the_priority_map->minor |= the_priority_map->ready_minor;
148
  _Priority_Major_bit_map  |= the_priority_map->ready_major;
149
}
150
 
151
/*PAGE
152
 *
153
 *  _Priority_Remove_from_bit_map
154
 *
155
 *  DESCRIPTION:
156
 *
157
 *  This routine uses the_priority_map to update the priority
158
 *  bit maps to indicate that a thread has been removed from the
159
 *  ready state.
160
 */
161
 
162
RTEMS_INLINE_ROUTINE void _Priority_Remove_from_bit_map (
163
  Priority_Information *the_priority_map
164
)
165
{
166
  *the_priority_map->minor &= the_priority_map->block_minor;
167
  if ( *the_priority_map->minor == 0 )
168
    _Priority_Major_bit_map &= the_priority_map->block_major;
169
}
170
 
171
/*PAGE
172
 *
173
 *  _Priority_Get_highest
174
 *
175
 *  DESCRIPTION:
176
 *
177
 *  This function returns the priority of the highest priority
178
 *  ready thread.
179
 */
180
 
181
RTEMS_INLINE_ROUTINE Priority_Control _Priority_Get_highest( void )
182
{
183
  Priority_Bit_map_control minor;
184
  Priority_Bit_map_control major;
185
 
186
  _Bitfield_Find_first_bit( _Priority_Major_bit_map, major );
187
  _Bitfield_Find_first_bit( _Priority_Bit_map[major], minor );
188
 
189
  return (_Priority_Bits_index( major ) << 4) +
190
          _Priority_Bits_index( minor );
191
}
192
 
193
/*PAGE
194
 *
195
 *  _Priority_Initialize_information
196
 *
197
 *  DESCRIPTION:
198
 *
199
 *  This routine initializes the_priority_map so that it
200
 *  contains the information necessary to manage a thread
201
 *  at new_priority.
202
 */
203
 
204
RTEMS_INLINE_ROUTINE void _Priority_Initialize_information(
205
  Priority_Information *the_priority_map,
206
  Priority_Control      new_priority
207
)
208
{
209
  Priority_Bit_map_control major;
210
  Priority_Bit_map_control minor;
211
  Priority_Bit_map_control mask;
212
 
213
  major = _Priority_Major( new_priority );
214
  minor = _Priority_Minor( new_priority );
215
 
216
  the_priority_map->minor =
217
    &_Priority_Bit_map[ _Priority_Bits_index(major) ];
218
 
219
  mask = _Priority_Mask( major );
220
  the_priority_map->ready_major = mask;
221
  the_priority_map->block_major = ~mask;
222
 
223
  mask = _Priority_Mask( minor );
224
  the_priority_map->ready_minor = mask;
225
  the_priority_map->block_minor = ~mask;
226
}
227
 
228
/*PAGE
229
 *
230
 *  _Priority_Is_group_empty
231
 *
232
 *  DESCRIPTION:
233
 *
234
 *  This function returns TRUE if the priority GROUP is empty, and
235
 *  FALSE otherwise.
236
 */
237
 
238
RTEMS_INLINE_ROUTINE boolean _Priority_Is_group_empty (
239
  Priority_Control      the_priority
240
)
241
{
242
  return the_priority == 0;
243
}
244
 
245
#endif
246
/* end of include file */

powered by: WebSVN 2.1.0

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