]>
git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Core/Dxe/Event/tpl.c
3 Task priority (TPL) function
5 Copyright (c) 2006 - 2008, Intel Corporation
6 All rights reserved. This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
20 CoreSetInterruptState (
31 Enable - The state of enable or disable interrupt
42 gCpu
->EnableInterrupt(gCpu
);
44 gCpu
->DisableInterrupt(gCpu
);
50 // Return the highest set bit
60 Return the highest set bit
64 Number - The value to check
68 Bit position of the highest set bit
75 while ((msb
> 0) && ((Number
& (UINTN
)(1 << msb
)) == 0)) {
93 Raise the task priority level to the new level.
94 High level is implemented by disabling processor interrupts.
98 NewTpl - New task priority level
102 The previous task priority level
108 OldTpl
= gEfiCurrentTpl
;
109 ASSERT (OldTpl
<= NewTpl
);
110 ASSERT (VALID_TPL (NewTpl
));
113 // If raising to high level, disable interrupts
115 if (NewTpl
>= TPL_HIGH_LEVEL
&& OldTpl
< TPL_HIGH_LEVEL
) {
116 CoreSetInterruptState (FALSE
);
122 gEfiCurrentTpl
= NewTpl
;
138 Lowers the task priority to the previous value. If the new
139 priority unmasks events at a higher priority, they are dispatched.
143 NewTpl - New, lower, task priority
153 OldTpl
= gEfiCurrentTpl
;
154 ASSERT (NewTpl
<= OldTpl
);
155 ASSERT (VALID_TPL (NewTpl
));
158 // If lowering below HIGH_LEVEL, make sure
159 // interrupts are enabled
162 if (OldTpl
>= TPL_HIGH_LEVEL
&& NewTpl
< TPL_HIGH_LEVEL
) {
163 gEfiCurrentTpl
= TPL_HIGH_LEVEL
;
167 // Dispatch any pending events
170 while ((-2 << NewTpl
) & gEventPending
) {
171 gEfiCurrentTpl
= CoreHighestSetBit (gEventPending
);
172 if (gEfiCurrentTpl
< TPL_HIGH_LEVEL
) {
173 CoreSetInterruptState (TRUE
);
175 CoreDispatchEventNotifies (gEfiCurrentTpl
);
182 gEfiCurrentTpl
= NewTpl
;
185 // If lowering below HIGH_LEVEL, make sure
186 // interrupts are enabled
188 if (gEfiCurrentTpl
< TPL_HIGH_LEVEL
) {
189 CoreSetInterruptState (TRUE
);