ae851638afacf3b5c1ff91bb8b6221bee6b9a0d2
3 Copyright (c) 2006, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
18 Task priority function
26 CoreSetInterruptState (
37 Enable - The state of enable or disable interrupt
48 gCpu
->EnableInterrupt(gCpu
);
50 gCpu
->DisableInterrupt(gCpu
);
56 // Return the highest set bit
66 Return the highest set bit
70 Number - The value to check
74 Bit position of the highest set bit
81 while ((msb
> 0) && ((Number
& (UINTN
)(1 << msb
)) == 0)) {
99 Raise the task priority level to the new level.
100 High level is implemented by disabling processor interrupts.
104 NewTpl - New task priority level
108 The previous task priority level
114 OldTpl
= gEfiCurrentTpl
;
115 ASSERT (OldTpl
<= NewTpl
);
116 ASSERT (VALID_TPL (NewTpl
));
119 // If raising to high level, disable interrupts
121 if (NewTpl
>= EFI_TPL_HIGH_LEVEL
&& OldTpl
< EFI_TPL_HIGH_LEVEL
) {
122 CoreSetInterruptState (FALSE
);
128 gEfiCurrentTpl
= NewTpl
;
144 Lowers the task priority to the previous value. If the new
145 priority unmasks events at a higher priority, they are dispatched.
149 NewTpl - New, lower, task priority
159 OldTpl
= gEfiCurrentTpl
;
160 ASSERT (NewTpl
<= OldTpl
);
161 ASSERT (VALID_TPL (NewTpl
));
164 // If lowering below HIGH_LEVEL, make sure
165 // interrupts are enabled
168 if (OldTpl
>= EFI_TPL_HIGH_LEVEL
&& NewTpl
< EFI_TPL_HIGH_LEVEL
) {
169 gEfiCurrentTpl
= EFI_TPL_HIGH_LEVEL
;
173 // Dispatch any pending events
176 while ((-2 << NewTpl
) & gEventPending
) {
177 gEfiCurrentTpl
= CoreHighestSetBit (gEventPending
);
178 if (gEfiCurrentTpl
< EFI_TPL_HIGH_LEVEL
) {
179 CoreSetInterruptState (TRUE
);
181 CoreDispatchEventNotifies (gEfiCurrentTpl
);
188 gEfiCurrentTpl
= NewTpl
;
191 // If lowering below HIGH_LEVEL, make sure
192 // interrupts are enabled
194 if (gEfiCurrentTpl
< EFI_TPL_HIGH_LEVEL
) {
195 CoreSetInterruptState (TRUE
);