]>
git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Core/Dxe/Event/Tpl.c
2 Task priority (TPL) functions.
4 Copyright (c) 2006 - 2008, Intel Corporation. <BR>
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
21 @param Enable The state of enable or disable interrupt
25 CoreSetInterruptState (
31 gCpu
->EnableInterrupt(gCpu
);
33 gCpu
->DisableInterrupt(gCpu
);
39 // Return the highest set bit
43 Return the highest set bit.
45 @param Number The value to check
47 @return Bit position of the highest set bit
58 while ((Msb
> 0) && ((Number
& (UINTN
)(1 << Msb
)) == 0)) {
69 Raise the task priority level to the new level.
70 High level is implemented by disabling processor interrupts.
72 @param NewTpl New task priority level
74 @return The previous task priority level
85 OldTpl
= gEfiCurrentTpl
;
86 ASSERT (OldTpl
<= NewTpl
);
87 ASSERT (VALID_TPL (NewTpl
));
90 // If raising to high level, disable interrupts
92 if (NewTpl
>= TPL_HIGH_LEVEL
&& OldTpl
< TPL_HIGH_LEVEL
) {
93 CoreSetInterruptState (FALSE
);
99 gEfiCurrentTpl
= NewTpl
;
108 Lowers the task priority to the previous value. If the new
109 priority unmasks events at a higher priority, they are dispatched.
111 @param NewTpl New, lower, task priority
122 OldTpl
= gEfiCurrentTpl
;
123 ASSERT (NewTpl
<= OldTpl
);
124 ASSERT (VALID_TPL (NewTpl
));
127 // If lowering below HIGH_LEVEL, make sure
128 // interrupts are enabled
131 if (OldTpl
>= TPL_HIGH_LEVEL
&& NewTpl
< TPL_HIGH_LEVEL
) {
132 gEfiCurrentTpl
= TPL_HIGH_LEVEL
;
136 // Dispatch any pending events
139 while ((-2 << NewTpl
) & gEventPending
) {
140 gEfiCurrentTpl
= CoreHighestSetBit (gEventPending
);
141 if (gEfiCurrentTpl
< TPL_HIGH_LEVEL
) {
142 CoreSetInterruptState (TRUE
);
144 CoreDispatchEventNotifies (gEfiCurrentTpl
);
151 gEfiCurrentTpl
= NewTpl
;
154 // If lowering below HIGH_LEVEL, make sure
155 // interrupts are enabled
157 if (gEfiCurrentTpl
< TPL_HIGH_LEVEL
) {
158 CoreSetInterruptState (TRUE
);