]>
git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Core/Dxe/Event/Tpl.c
2 Task priority (TPL) functions.
4 Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
5 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 (
36 gCpu
->DisableInterrupt (gCpu
);
39 if (gSmmBase2
== NULL
) {
40 gCpu
->EnableInterrupt (gCpu
);
43 Status
= gSmmBase2
->InSmm (gSmmBase2
, &InSmm
);
44 if (!EFI_ERROR (Status
) && !InSmm
) {
45 gCpu
->EnableInterrupt(gCpu
);
51 Raise the task priority level to the new level.
52 High level is implemented by disabling processor interrupts.
54 @param NewTpl New task priority level
56 @return The previous task priority level
67 OldTpl
= gEfiCurrentTpl
;
68 ASSERT (OldTpl
<= NewTpl
);
69 ASSERT (VALID_TPL (NewTpl
));
72 // If raising to high level, disable interrupts
74 if (NewTpl
>= TPL_HIGH_LEVEL
&& OldTpl
< TPL_HIGH_LEVEL
) {
75 CoreSetInterruptState (FALSE
);
81 gEfiCurrentTpl
= NewTpl
;
90 Lowers the task priority to the previous value. If the new
91 priority unmasks events at a higher priority, they are dispatched.
93 @param NewTpl New, lower, task priority
104 OldTpl
= gEfiCurrentTpl
;
105 ASSERT (NewTpl
<= OldTpl
);
106 ASSERT (VALID_TPL (NewTpl
));
109 // If lowering below HIGH_LEVEL, make sure
110 // interrupts are enabled
113 if (OldTpl
>= TPL_HIGH_LEVEL
&& NewTpl
< TPL_HIGH_LEVEL
) {
114 gEfiCurrentTpl
= TPL_HIGH_LEVEL
;
118 // Dispatch any pending events
120 while (((-2 << NewTpl
) & gEventPending
) != 0) {
121 gEfiCurrentTpl
= (UINTN
) HighBitSet64 (gEventPending
);
122 if (gEfiCurrentTpl
< TPL_HIGH_LEVEL
) {
123 CoreSetInterruptState (TRUE
);
125 CoreDispatchEventNotifies (gEfiCurrentTpl
);
132 gEfiCurrentTpl
= NewTpl
;
135 // If lowering below HIGH_LEVEL, make sure
136 // interrupts are enabled
138 if (gEfiCurrentTpl
< TPL_HIGH_LEVEL
) {
139 CoreSetInterruptState (TRUE
);