]>
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
);
40 Raise the task priority level to the new level.
41 High level is implemented by disabling processor interrupts.
43 @param NewTpl New task priority level
45 @return The previous task priority level
56 OldTpl
= gEfiCurrentTpl
;
57 ASSERT (OldTpl
<= NewTpl
);
58 ASSERT (VALID_TPL (NewTpl
));
61 // If raising to high level, disable interrupts
63 if (NewTpl
>= TPL_HIGH_LEVEL
&& OldTpl
< TPL_HIGH_LEVEL
) {
64 CoreSetInterruptState (FALSE
);
70 gEfiCurrentTpl
= NewTpl
;
79 Lowers the task priority to the previous value. If the new
80 priority unmasks events at a higher priority, they are dispatched.
82 @param NewTpl New, lower, task priority
93 OldTpl
= gEfiCurrentTpl
;
94 ASSERT (NewTpl
<= OldTpl
);
95 ASSERT (VALID_TPL (NewTpl
));
98 // If lowering below HIGH_LEVEL, make sure
99 // interrupts are enabled
102 if (OldTpl
>= TPL_HIGH_LEVEL
&& NewTpl
< TPL_HIGH_LEVEL
) {
103 gEfiCurrentTpl
= TPL_HIGH_LEVEL
;
107 // Dispatch any pending events
109 while (((-2 << NewTpl
) & gEventPending
) != 0) {
110 gEfiCurrentTpl
= HighBitSet64 (gEventPending
);
111 if (gEfiCurrentTpl
< TPL_HIGH_LEVEL
) {
112 CoreSetInterruptState (TRUE
);
114 CoreDispatchEventNotifies (gEfiCurrentTpl
);
121 gEfiCurrentTpl
= NewTpl
;
124 // If lowering below HIGH_LEVEL, make sure
125 // interrupts are enabled
127 if (gEfiCurrentTpl
< TPL_HIGH_LEVEL
) {
128 CoreSetInterruptState (TRUE
);