source: rtems/cpukit/score/inline/rtems/score/prioritybitmap.inl @ 9b4422a2

4.115
Last change on this file since 9b4422a2 was 9b4422a2, checked in by Joel Sherrill <joel.sherrill@…>, on 05/03/12 at 15:09:24

Remove All CVS Id Strings Possible Using a Script

Script does what is expected and tries to do it as
smartly as possible.

+ remove occurrences of two blank comment lines

next to each other after Id string line removed.

+ remove entire comment blocks which only exited to

contain CVS Ids

+ If the processing left a blank line at the top of

a file, it was removed.

  • Property mode set to 100644
File size: 4.6 KB
Line 
1/**
2 *  @file  rtems/score/prioritybitmap.inl
3 *
4 *  This file contains the static inline implementation of all inlined
5 *  routines in the Priority Handler bit map implementation
6 */
7
8/*
9 *  COPYRIGHT (c) 1989-2010.
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
17#ifndef _RTEMS_SCORE_PRIORITYBITMAP_H
18# error "Never use <rtems/score/prioritybitmap.inl> directly; include <rtems/score/prioritybitmap.h> instead."
19#endif
20
21#ifndef _RTEMS_SCORE_PRIORITYBITMAP_INL
22#define _RTEMS_SCORE_PRIORITYBITMAP_INL
23
24/**
25 *  @addtogroup ScorePriority
26 *  @{
27 */
28
29#include <rtems/score/bitfield.h>
30
31/**
32 *  This function returns the major portion of the_priority.
33 */
34
35RTEMS_INLINE_ROUTINE Priority_bit_map_Control   _Priority_Major (
36  Priority_Control the_priority
37)
38{
39  return (Priority_bit_map_Control)( the_priority / 16 );
40}
41
42/**
43 *  This function returns the minor portion of the_priority.
44 */
45
46RTEMS_INLINE_ROUTINE Priority_bit_map_Control   _Priority_Minor (
47  Priority_Control the_priority
48)
49{
50  return (Priority_bit_map_Control)( the_priority % 16 );
51}
52
53#if ( CPU_USE_GENERIC_BITFIELD_CODE == TRUE )
54 
55/**
56 *  This function returns the mask associated with the major or minor
57 *  number passed to it.
58 */
59 
60RTEMS_INLINE_ROUTINE Priority_bit_map_Control   _Priority_Mask (
61  uint32_t   bit_number
62)
63{
64  return (Priority_bit_map_Control)(0x8000u >> bit_number);
65}
66 
67/**
68 *  This function returns the mask bit inverted.
69 */
70 
71RTEMS_INLINE_ROUTINE Priority_bit_map_Control   _Priority_Mask_invert (
72  uint32_t   mask
73)
74{
75  return (Priority_bit_map_Control)(~mask);
76}
77
78 
79/**
80 *  This function translates the bit numbers returned by the bit scan
81 *  of a priority bit field into something suitable for use as
82 *  a major or minor component of a priority.
83 */
84 
85RTEMS_INLINE_ROUTINE uint32_t   _Priority_Bits_index (
86  uint32_t   bit_number
87)
88{
89  return bit_number;
90}
91
92#endif
93
94/**
95 * Priority Queue implemented by bit map
96 */
97
98/**
99 *  This routine performs the initialization necessary for this handler.
100 */
101
102RTEMS_INLINE_ROUTINE void _Priority_bit_map_Handler_initialization( void )
103{
104  int index;
105
106  _Priority_Major_bit_map = 0;
107  for ( index=0 ; index <16 ; index++ )
108     _Priority_Bit_map[ index ] = 0;
109}
110
111/**
112 *  This routine uses the_priority_map to update the priority
113 *  bit maps to indicate that a thread has been readied.
114 */
115
116RTEMS_INLINE_ROUTINE void _Priority_bit_map_Add (
117  Priority_bit_map_Information *the_priority_map
118)
119{
120  *the_priority_map->minor |= the_priority_map->ready_minor;
121  _Priority_Major_bit_map  |= the_priority_map->ready_major;
122}
123
124/**
125 *  This routine uses the_priority_map to update the priority
126 *  bit maps to indicate that a thread has been removed from the
127 *  ready state.
128 */
129
130RTEMS_INLINE_ROUTINE void _Priority_bit_map_Remove (
131  Priority_bit_map_Information *the_priority_map
132)
133{
134  *the_priority_map->minor &= the_priority_map->block_minor;
135  if ( *the_priority_map->minor == 0 )
136    _Priority_Major_bit_map &= the_priority_map->block_major;
137}
138
139/**
140 *  This function returns the priority of the highest priority
141 *  ready thread.
142 */
143
144RTEMS_INLINE_ROUTINE Priority_Control _Priority_bit_map_Get_highest( void )
145{
146  Priority_bit_map_Control minor;
147  Priority_bit_map_Control major;
148
149  _Bitfield_Find_first_bit( _Priority_Major_bit_map, major );
150  _Bitfield_Find_first_bit( _Priority_Bit_map[major], minor );
151
152  return (_Priority_Bits_index( major ) << 4) +
153          _Priority_Bits_index( minor );
154}
155
156/**
157 *  This routine initializes the_priority_map so that it
158 *  contains the information necessary to manage a thread
159 *  at new_priority.
160 */
161
162RTEMS_INLINE_ROUTINE void _Priority_bit_map_Initialize_information(
163  Priority_bit_map_Information *the_priority_map,
164  Priority_Control      new_priority
165)
166{
167  Priority_bit_map_Control major;
168  Priority_bit_map_Control minor;
169  Priority_bit_map_Control mask;
170
171  major = _Priority_Major( new_priority );
172  minor = _Priority_Minor( new_priority );
173
174  the_priority_map->minor =
175    &_Priority_Bit_map[ _Priority_Bits_index(major) ];
176
177  mask = _Priority_Mask( major );
178  the_priority_map->ready_major = mask;
179  /* Add _Priority_Mask_invert to non-generic bitfield then change this code. */
180  the_priority_map->block_major = (Priority_bit_map_Control)(~((uint32_t)mask));
181
182  mask = _Priority_Mask( minor );
183  the_priority_map->ready_minor = mask;
184  /* Add _Priority_Mask_invert to non-generic bitfield then change this code. */
185  the_priority_map->block_minor = (Priority_bit_map_Control)(~((uint32_t)mask));
186}
187
188/**@}*/
189
190#endif
191/* end of include file */
Note: See TracBrowser for help on using the repository browser.