1 | /* priority.inl |
---|
2 | * |
---|
3 | * This file contains the macro implementation of all inlined routines |
---|
4 | * in the Priority Handler. |
---|
5 | * |
---|
6 | * COPYRIGHT (c) 1989-1997. |
---|
7 | * On-Line Applications Research Corporation (OAR). |
---|
8 | * Copyright assigned to U.S. Government, 1994. |
---|
9 | * |
---|
10 | * The license and distribution terms for this file may in |
---|
11 | * the file LICENSE in this distribution or at |
---|
12 | * http://www.OARcorp.com/rtems/license.html. |
---|
13 | * |
---|
14 | * $Id$ |
---|
15 | */ |
---|
16 | |
---|
17 | #ifndef __PRIORITY_inl |
---|
18 | #define __PRIORITY_inl |
---|
19 | |
---|
20 | #include <rtems/score/bitfield.h> |
---|
21 | |
---|
22 | /*PAGE |
---|
23 | * |
---|
24 | * _Priority_Handler_initialization |
---|
25 | * |
---|
26 | */ |
---|
27 | |
---|
28 | #define _Priority_Handler_initialization() \ |
---|
29 | { \ |
---|
30 | unsigned32 index; \ |
---|
31 | \ |
---|
32 | _Priority_Major_bit_map = 0; \ |
---|
33 | for ( index=0 ; index <16 ; index++ ) \ |
---|
34 | _Priority_Bit_map[ index ] = 0; \ |
---|
35 | } |
---|
36 | |
---|
37 | /*PAGE |
---|
38 | * |
---|
39 | * _Priority_Is_valid |
---|
40 | * |
---|
41 | */ |
---|
42 | |
---|
43 | /* |
---|
44 | * Since PRIORITY_MINIMUM is 0 and priorities are stored unsigned, |
---|
45 | * then checking for less than 0 is unnecessary. |
---|
46 | */ |
---|
47 | |
---|
48 | #define _Priority_Is_valid( _the_priority ) \ |
---|
49 | ( (_the_priority) <= PRIORITY_MAXIMUM ) |
---|
50 | |
---|
51 | /*PAGE |
---|
52 | * |
---|
53 | * _Priority_Major |
---|
54 | * |
---|
55 | */ |
---|
56 | |
---|
57 | #define _Priority_Major( _the_priority ) ( (_the_priority) / 16 ) |
---|
58 | |
---|
59 | /*PAGE |
---|
60 | * |
---|
61 | * _Priority_Minor |
---|
62 | * |
---|
63 | */ |
---|
64 | |
---|
65 | #define _Priority_Minor( _the_priority ) ( (_the_priority) % 16 ) |
---|
66 | |
---|
67 | #if ( CPU_USE_GENERIC_BITFIELD_CODE == TRUE ) |
---|
68 | |
---|
69 | /*PAGE |
---|
70 | * |
---|
71 | * _Priority_Mask |
---|
72 | * |
---|
73 | */ |
---|
74 | |
---|
75 | #define _Priority_Mask( _bit_number ) \ |
---|
76 | (0x8000 >> _bit_number) |
---|
77 | |
---|
78 | /*PAGE |
---|
79 | * |
---|
80 | * _Priority_Bits_index |
---|
81 | * |
---|
82 | */ |
---|
83 | |
---|
84 | #define _Priority_Bits_index( _bit_number ) \ |
---|
85 | (_bit_number) |
---|
86 | |
---|
87 | #endif |
---|
88 | |
---|
89 | /*PAGE |
---|
90 | * |
---|
91 | * _Priority_Add_to_bit_map |
---|
92 | * |
---|
93 | */ |
---|
94 | |
---|
95 | #define _Priority_Add_to_bit_map( _the_priority_map ) \ |
---|
96 | { \ |
---|
97 | *(_the_priority_map)->minor |= (_the_priority_map)->ready_minor; \ |
---|
98 | _Priority_Major_bit_map |= (_the_priority_map)->ready_major; \ |
---|
99 | } |
---|
100 | |
---|
101 | /*PAGE |
---|
102 | * |
---|
103 | * _Priority_Remove_from_bit_map |
---|
104 | * |
---|
105 | */ |
---|
106 | |
---|
107 | #define _Priority_Remove_from_bit_map( _the_priority_map ) \ |
---|
108 | { \ |
---|
109 | *(_the_priority_map)->minor &= (_the_priority_map)->block_minor; \ |
---|
110 | if ( *(_the_priority_map)->minor == 0 ) \ |
---|
111 | _Priority_Major_bit_map &= (_the_priority_map)->block_major; \ |
---|
112 | } |
---|
113 | |
---|
114 | /*PAGE |
---|
115 | * |
---|
116 | * _Priority_Get_highest |
---|
117 | * |
---|
118 | */ |
---|
119 | |
---|
120 | #define _Priority_Get_highest( _high_priority ) \ |
---|
121 | { \ |
---|
122 | Priority_Bit_map_control minor; \ |
---|
123 | Priority_Bit_map_control major; \ |
---|
124 | \ |
---|
125 | _Bitfield_Find_first_bit( _Priority_Major_bit_map, major ); \ |
---|
126 | _Bitfield_Find_first_bit( _Priority_Bit_map[major], minor ); \ |
---|
127 | \ |
---|
128 | (_high_priority) = (_Priority_Bits_index( major ) * 16) + \ |
---|
129 | _Priority_Bits_index( minor ); \ |
---|
130 | } |
---|
131 | |
---|
132 | /*PAGE |
---|
133 | * |
---|
134 | * _Priority_Initialize_information |
---|
135 | * |
---|
136 | */ |
---|
137 | |
---|
138 | #define _Priority_Initialize_information( \ |
---|
139 | _the_priority_map, _new_priority ) \ |
---|
140 | { \ |
---|
141 | Priority_Bit_map_control _major; \ |
---|
142 | Priority_Bit_map_control _minor; \ |
---|
143 | Priority_Bit_map_control _mask; \ |
---|
144 | \ |
---|
145 | _major = _Priority_Major( (_new_priority) ); \ |
---|
146 | _minor = _Priority_Minor( (_new_priority) ); \ |
---|
147 | \ |
---|
148 | (_the_priority_map)->minor = \ |
---|
149 | &_Priority_Bit_map[ _Priority_Bits_index(_major) ]; \ |
---|
150 | \ |
---|
151 | _mask = _Priority_Mask( _major ); \ |
---|
152 | (_the_priority_map)->ready_major = _mask; \ |
---|
153 | (_the_priority_map)->block_major = ~_mask; \ |
---|
154 | \ |
---|
155 | _mask = _Priority_Mask( _minor ); \ |
---|
156 | (_the_priority_map)->ready_minor = _mask; \ |
---|
157 | (_the_priority_map)->block_minor = ~_mask; \ |
---|
158 | } |
---|
159 | |
---|
160 | /*PAGE |
---|
161 | * |
---|
162 | * _Priority_Is_group_empty |
---|
163 | * |
---|
164 | */ |
---|
165 | |
---|
166 | #define _Priority_Is_group_empty ( _the_priority ) \ |
---|
167 | ( (_the_priority) == 0 ) |
---|
168 | |
---|
169 | #endif |
---|
170 | /* end of include file */ |
---|