]>
git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Core/Dxe/Event/Tpl.c
2 Task priority (TPL) functions.
4 Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
15 @param Enable The state of enable or disable interrupt
19 CoreSetInterruptState (
30 gCpu
->DisableInterrupt (gCpu
);
33 if (gSmmBase2
== NULL
) {
34 gCpu
->EnableInterrupt (gCpu
);
37 Status
= gSmmBase2
->InSmm (gSmmBase2
, &InSmm
);
38 if (!EFI_ERROR (Status
) && !InSmm
) {
39 gCpu
->EnableInterrupt(gCpu
);
45 Raise the task priority level to the new level.
46 High level is implemented by disabling processor interrupts.
48 @param NewTpl New task priority level
50 @return The previous task priority level
61 OldTpl
= gEfiCurrentTpl
;
62 if (OldTpl
> NewTpl
) {
63 DEBUG ((EFI_D_ERROR
, "FATAL ERROR - RaiseTpl with OldTpl(0x%x) > NewTpl(0x%x)\n", OldTpl
, NewTpl
));
66 ASSERT (VALID_TPL (NewTpl
));
69 // If raising to high level, disable interrupts
71 if (NewTpl
>= TPL_HIGH_LEVEL
&& OldTpl
< TPL_HIGH_LEVEL
) {
72 CoreSetInterruptState (FALSE
);
78 gEfiCurrentTpl
= NewTpl
;
87 Lowers the task priority to the previous value. If the new
88 priority unmasks events at a higher priority, they are dispatched.
90 @param NewTpl New, lower, task priority
102 OldTpl
= gEfiCurrentTpl
;
103 if (NewTpl
> OldTpl
) {
104 DEBUG ((EFI_D_ERROR
, "FATAL ERROR - RestoreTpl with NewTpl(0x%x) > OldTpl(0x%x)\n", NewTpl
, OldTpl
));
107 ASSERT (VALID_TPL (NewTpl
));
110 // If lowering below HIGH_LEVEL, make sure
111 // interrupts are enabled
114 if (OldTpl
>= TPL_HIGH_LEVEL
&& NewTpl
< TPL_HIGH_LEVEL
) {
115 gEfiCurrentTpl
= TPL_HIGH_LEVEL
;
119 // Dispatch any pending events
121 while (gEventPending
!= 0) {
122 PendingTpl
= (UINTN
) HighBitSet64 (gEventPending
);
123 if (PendingTpl
<= NewTpl
) {
127 gEfiCurrentTpl
= PendingTpl
;
128 if (gEfiCurrentTpl
< TPL_HIGH_LEVEL
) {
129 CoreSetInterruptState (TRUE
);
131 CoreDispatchEventNotifies (gEfiCurrentTpl
);
138 gEfiCurrentTpl
= NewTpl
;
141 // If lowering below HIGH_LEVEL, make sure
142 // interrupts are enabled
144 if (gEfiCurrentTpl
< TPL_HIGH_LEVEL
) {
145 CoreSetInterruptState (TRUE
);