]>
git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Core/Dxe/Event/Tpl.c
2 Task priority (TPL) functions.
4 Copyright (c) 2006 - 2015, 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 if (OldTpl
> NewTpl
) {
69 DEBUG ((EFI_D_ERROR
, "FATAL ERROR - RaiseTpl with OldTpl(0x%x) > NewTpl(0x%x)\n", OldTpl
, NewTpl
));
72 ASSERT (VALID_TPL (NewTpl
));
75 // If raising to high level, disable interrupts
77 if (NewTpl
>= TPL_HIGH_LEVEL
&& OldTpl
< TPL_HIGH_LEVEL
) {
78 CoreSetInterruptState (FALSE
);
84 gEfiCurrentTpl
= NewTpl
;
93 Lowers the task priority to the previous value. If the new
94 priority unmasks events at a higher priority, they are dispatched.
96 @param NewTpl New, lower, task priority
107 OldTpl
= gEfiCurrentTpl
;
108 if (NewTpl
> OldTpl
) {
109 DEBUG ((EFI_D_ERROR
, "FATAL ERROR - RestoreTpl with NewTpl(0x%x) > OldTpl(0x%x)\n", NewTpl
, OldTpl
));
112 ASSERT (VALID_TPL (NewTpl
));
115 // If lowering below HIGH_LEVEL, make sure
116 // interrupts are enabled
119 if (OldTpl
>= TPL_HIGH_LEVEL
&& NewTpl
< TPL_HIGH_LEVEL
) {
120 gEfiCurrentTpl
= TPL_HIGH_LEVEL
;
124 // Dispatch any pending events
126 while (((-2 << NewTpl
) & gEventPending
) != 0) {
127 gEfiCurrentTpl
= (UINTN
) HighBitSet64 (gEventPending
);
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
);