source: rtems/cpukit/score/inline/rtems/score/priority.inl @ 199ccde

4.104.115
Last change on this file since 199ccde was 199ccde, checked in by Chris Johns <chrisj@…>, on May 8, 2009 at 4:55:53 AM

2009-05-08 Chris Johns <chrisj@…>

  • cpukit/libblock/src/bdpart.c, libmisc/shell/main_msdosfmt.c, libmisc/shell/main_rm.c, libnetworking/libc/gethostnamadr.c, score/include/rtems/score/bitfield.h, score/inline/rtems/score/priority.inl: Remove warnings.
  • Property mode set to 100644
File size: 5.0 KB
Line 
1/**
2 *  @file  rtems/score/priority.inl
3 *
4 *  This file contains the static inline implementation of all inlined
5 *  routines in the Priority Handler.
6 */
7
8/*
9 *  COPYRIGHT (c) 1989-2004.
10 *  On-Line Applications Research Corporation (OAR).
11 *
12 *  The license and distribution terms for this file may be
13 *  found in the file LICENSE in this distribution or at
14 *  http://www.rtems.com/license/LICENSE.
15 *
16 *  $Id$
17 */
18
19#ifndef _RTEMS_SCORE_PRIORITY_H
20# error "Never use <rtems/score/priority.inl> directly; include <rtems/score/priority.h> instead."
21#endif
22
23#ifndef _RTEMS_SCORE_PRIORITY_INL
24#define _RTEMS_SCORE_PRIORITY_INL
25
26/**
27 *  @addtogroup ScorePriority
28 *  @{
29 */
30
31#include <rtems/score/bitfield.h>
32
33/**
34 *  This routine performs the initialization necessary for this handler.
35 */
36
37RTEMS_INLINE_ROUTINE void _Priority_Handler_initialization( void )
38{
39  int index;
40
41  _Priority_Major_bit_map = 0;
42  for ( index=0 ; index <16 ; index++ )
43     _Priority_Bit_map[ index ] = 0;
44}
45
46/**
47 *  This function returns true if the_priority if valid for a
48 *  user task, and false otherwise.
49 */
50
51RTEMS_INLINE_ROUTINE bool _Priority_Is_valid (
52  Priority_Control the_priority
53)
54{
55  /*
56   *  Since PRIORITY_MINIMUM is 0 and priorities are stored unsigned,
57   *  then checking for less than 0 is unnecessary.
58   */
59
60  return ( the_priority <= PRIORITY_MAXIMUM );
61}
62
63/**
64 *  This function returns the major portion of the_priority.
65 */
66
67RTEMS_INLINE_ROUTINE Priority_Bit_map_control   _Priority_Major (
68  Priority_Control the_priority
69)
70{
71  return (Priority_Bit_map_control)( the_priority / 16 );
72}
73
74/**
75 *  This function returns the minor portion of the_priority.
76 */
77
78RTEMS_INLINE_ROUTINE Priority_Bit_map_control   _Priority_Minor (
79  Priority_Control the_priority
80)
81{
82  return (Priority_Bit_map_control)( the_priority % 16 );
83}
84
85#if ( CPU_USE_GENERIC_BITFIELD_CODE == TRUE )
86 
87/**
88 *  This function returns the mask associated with the major or minor
89 *  number passed to it.
90 */
91 
92RTEMS_INLINE_ROUTINE Priority_Bit_map_control   _Priority_Mask (
93  uint32_t   bit_number
94)
95{
96  return (Priority_Bit_map_control)(0x8000u >> bit_number);
97}
98 
99/**
100 *  This function returns the mask bit inverted.
101 */
102 
103RTEMS_INLINE_ROUTINE Priority_Bit_map_control   _Priority_Mask_invert (
104  uint32_t   mask
105)
106{
107  return (Priority_Bit_map_control)(~mask);
108}
109
110 
111/**
112 *  This function translates the bit numbers returned by the bit scan
113 *  of a priority bit field into something suitable for use as
114 *  a major or minor component of a priority.
115 */
116 
117RTEMS_INLINE_ROUTINE uint32_t   _Priority_Bits_index (
118  uint32_t   bit_number
119)
120{
121  return bit_number;
122}
123
124#endif
125
126/**
127 *  This routine uses the_priority_map to update the priority
128 *  bit maps to indicate that a thread has been readied.
129 */
130
131RTEMS_INLINE_ROUTINE void _Priority_Add_to_bit_map (
132  Priority_Information *the_priority_map
133)
134{
135  *the_priority_map->minor |= the_priority_map->ready_minor;
136  _Priority_Major_bit_map  |= the_priority_map->ready_major;
137}
138
139/**
140 *  This routine uses the_priority_map to update the priority
141 *  bit maps to indicate that a thread has been removed from the
142 *  ready state.
143 */
144
145RTEMS_INLINE_ROUTINE void _Priority_Remove_from_bit_map (
146  Priority_Information *the_priority_map
147)
148{
149  *the_priority_map->minor &= the_priority_map->block_minor;
150  if ( *the_priority_map->minor == 0 )
151    _Priority_Major_bit_map &= the_priority_map->block_major;
152}
153
154/**
155 *  This function returns the priority of the highest priority
156 *  ready thread.
157 */
158
159RTEMS_INLINE_ROUTINE Priority_Control _Priority_Get_highest( void )
160{
161  Priority_Bit_map_control minor;
162  Priority_Bit_map_control major;
163
164  _Bitfield_Find_first_bit( _Priority_Major_bit_map, major );
165  _Bitfield_Find_first_bit( _Priority_Bit_map[major], minor );
166
167  return (_Priority_Bits_index( major ) << 4) +
168          _Priority_Bits_index( minor );
169}
170
171/**
172 *  This routine initializes the_priority_map so that it
173 *  contains the information necessary to manage a thread
174 *  at new_priority.
175 */
176
177RTEMS_INLINE_ROUTINE void _Priority_Initialize_information(
178  Priority_Information *the_priority_map,
179  Priority_Control      new_priority
180)
181{
182  Priority_Bit_map_control major;
183  Priority_Bit_map_control minor;
184  Priority_Bit_map_control mask;
185
186  major = _Priority_Major( new_priority );
187  minor = _Priority_Minor( new_priority );
188
189  the_priority_map->minor =
190    &_Priority_Bit_map[ _Priority_Bits_index(major) ];
191
192  mask = _Priority_Mask( major );
193  the_priority_map->ready_major = mask;
194  /* Add _Priority_Mask_invert to non-generic bitfield then change this code. */
195  the_priority_map->block_major = (Priority_Bit_map_control)(~((uint32_t)mask));
196
197  mask = _Priority_Mask( minor );
198  the_priority_map->ready_minor = mask;
199  /* Add _Priority_Mask_invert to non-generic bitfield then change this code. */
200  the_priority_map->block_minor = (Priority_Bit_map_control)(~((uint32_t)mask));
201}
202
203/**
204 *  This function returns true if the priority GROUP is empty, and
205 *  false otherwise.
206 */
207
208RTEMS_INLINE_ROUTINE bool _Priority_Is_group_empty (
209  Priority_Control      the_priority
210)
211{
212  return the_priority == 0;
213}
214
215/**@}*/
216
217#endif
218/* end of include file */
Note: See TracBrowser for help on using the repository browser.