]>
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.
22 @param Enable The state of enable or disable interrupt
27 CoreSetInterruptState (
33 gCpu
->EnableInterrupt(gCpu
);
35 gCpu
->DisableInterrupt(gCpu
);
41 // Return the highest set bit
45 Return the highest set bit.
47 @param Number The value to check
49 @return Bit position of the highest set bit
60 while ((msb
> 0) && ((Number
& (UINTN
)(1 << msb
)) == 0)) {
71 Raise the task priority level to the new level.
72 High level is implemented by disabling processor interrupts.
74 @param NewTpl New task priority level
76 @return The previous task priority level
87 OldTpl
= gEfiCurrentTpl
;
88 ASSERT (OldTpl
<= NewTpl
);
89 ASSERT (VALID_TPL (NewTpl
));
92 // If raising to high level, disable interrupts
94 if (NewTpl
>= TPL_HIGH_LEVEL
&& OldTpl
< TPL_HIGH_LEVEL
) {
95 CoreSetInterruptState (FALSE
);
101 gEfiCurrentTpl
= NewTpl
;
110 Lowers the task priority to the previous value. If the new
111 priority unmasks events at a higher priority, they are dispatched.
113 @param NewTpl New, lower, task priority
124 OldTpl
= gEfiCurrentTpl
;
125 ASSERT (NewTpl
<= OldTpl
);
126 ASSERT (VALID_TPL (NewTpl
));
129 // If lowering below HIGH_LEVEL, make sure
130 // interrupts are enabled
133 if (OldTpl
>= TPL_HIGH_LEVEL
&& NewTpl
< TPL_HIGH_LEVEL
) {
134 gEfiCurrentTpl
= TPL_HIGH_LEVEL
;
138 // Dispatch any pending events
141 while ((-2 << NewTpl
) & gEventPending
) {
142 gEfiCurrentTpl
= CoreHighestSetBit (gEventPending
);
143 if (gEfiCurrentTpl
< TPL_HIGH_LEVEL
) {
144 CoreSetInterruptState (TRUE
);
146 CoreDispatchEventNotifies (gEfiCurrentTpl
);
153 gEfiCurrentTpl
= NewTpl
;
156 // If lowering below HIGH_LEVEL, make sure
157 // interrupts are enabled
159 if (gEfiCurrentTpl
< TPL_HIGH_LEVEL
) {
160 CoreSetInterruptState (TRUE
);