TianoCore EDK2 master
Loading...
Searching...
No Matches
NestedInterruptTplLib.h File Reference

Go to the source code of this file.

Data Structures

struct  NESTED_INTERRUPT_STATE
 

Functions

EFI_TPL EFIAPI NestedInterruptRaiseTPL (VOID)
 
VOID EFIAPI NestedInterruptRestoreTPL (IN EFI_TPL InterruptedTPL, IN OUT EFI_SYSTEM_CONTEXT SystemContext, IN OUT NESTED_INTERRUPT_STATE *IsrState)
 

Detailed Description

Handle raising and lowering TPL from within nested interrupt handlers.

Allows interrupt handlers to safely raise and lower the TPL to dispatch event notifications, correctly allowing for nested interrupts to occur without risking stack exhaustion.

Copyright (C) 2022, Fen Systems Ltd.

SPDX-License-Identifier: BSD-2-Clause-Patent

Definition in file NestedInterruptTplLib.h.

Function Documentation

◆ NestedInterruptRaiseTPL()

EFI_TPL EFIAPI NestedInterruptRaiseTPL ( VOID  )

Raise the task priority level to TPL_HIGH_LEVEL.

Parameters
None.
Returns
The task priority level at which the interrupt occurred.

Definition at line 29 of file Tpl.c.

◆ NestedInterruptRestoreTPL()

VOID EFIAPI NestedInterruptRestoreTPL ( IN EFI_TPL  InterruptedTPL,
IN OUT EFI_SYSTEM_CONTEXT  SystemContext,
IN OUT NESTED_INTERRUPT_STATE IsrState 
)

Lower the task priority back to the value at which the interrupt occurred.

This is unfortunately messy. UEFI requires us to support nested interrupts, but provides no way for an interrupt handler to call RestoreTPL() without implicitly re-enabling interrupts. In a virtual machine, it is possible for a large burst of interrupts to arrive. We must prevent such a burst from leading to stack exhaustion, while continuing to allow nested interrupts to occur.

Since nested interrupts are permitted, an interrupt handler may be invoked as an inner interrupt handler while an outer instance of the same interrupt handler is still inside its call to RestoreTPL().

To avoid stack exhaustion, this call may therefore (when provably safe to do so) defer the actual TPL lowering to be performed by an outer instance of the same interrupt handler.

Parameters
InterruptedTPLThe task priority level at which the interrupt occurred, as previously returned from NestedInterruptRaiseTPL().
SystemContextA pointer to the system context when the interrupt occurred.
IsrStateA pointer to the state shared between all invocations of the nested interrupt handler.

Definition at line 93 of file Tpl.c.