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

Go to the source code of this file.

Data Structures

struct  IDT_ENTRY
 

Macros

#define NUM_IDT_ENTRIES   0x78
 
#define SYSTEM_TIMER_VECTOR   0x68
 

Typedefs

typedef VOID(* DEBUG_PROC) (VOID)
 
typedef VOID(EFIAPI * CALLBACK_FUNC) ()
 

Functions

VOID CommonIdtEntry (VOID)
 
BOOLEAN FxStorSupport (VOID)
 
VOID Vect2Desc (IA32_IDT_GATE_DESCRIPTOR *DestDesc, VOID(*Vector)(VOID))
 
EFI_STATUS PlInitializeDebugSupportDriver (VOID)
 
EFI_STATUS EFIAPI PlUnloadDebugSupportDriver (IN EFI_HANDLE ImageHandle)
 
EFI_STATUS EFIAPI GetMaximumProcessorIndex (IN EFI_DEBUG_SUPPORT_PROTOCOL *This, OUT UINTN *MaxProcessorIndex)
 
EFI_STATUS EFIAPI RegisterPeriodicCallback (IN EFI_DEBUG_SUPPORT_PROTOCOL *This, IN UINTN ProcessorIndex, IN EFI_PERIODIC_CALLBACK PeriodicCallback)
 
EFI_STATUS EFIAPI RegisterExceptionCallback (IN EFI_DEBUG_SUPPORT_PROTOCOL *This, IN UINTN ProcessorIndex, IN EFI_EXCEPTION_CALLBACK ExceptionCallback, IN EFI_EXCEPTION_TYPE ExceptionType)
 
EFI_STATUS EFIAPI InvalidateInstructionCache (IN EFI_DEBUG_SUPPORT_PROTOCOL *This, IN UINTN ProcessorIndex, IN VOID *Start, IN UINT64 Length)
 
VOID CreateEntryStub (IN EFI_EXCEPTION_TYPE ExceptionType, OUT VOID **Stub)
 
UINTN GetInterruptHandleFromIdt (IN IA32_IDT_GATE_DESCRIPTOR *IdtGateDecriptor)
 
EFI_STATUS ManageIdtEntryTable (CALLBACK_FUNC NewCallback, EFI_EXCEPTION_TYPE ExceptionType)
 
VOID HookEntry (IN EFI_EXCEPTION_TYPE ExceptionType, IN CALLBACK_FUNC NewCallback)
 
VOID UnhookEntry (IN EFI_EXCEPTION_TYPE ExceptionType)
 

Variables

UINT8 InterruptEntryStub []
 
UINT32 StubSize
 
VOID(* OrigVector )(VOID)
 
IDT_ENTRYIdtEntryTable
 
IA32_IDT_GATE_DESCRIPTOR NullDesc
 

Detailed Description

Generic debug support macros, typedefs and prototypes for IA32/x64.

Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent

Definition in file DebugSupport.h.

Macro Definition Documentation

◆ NUM_IDT_ENTRIES

#define NUM_IDT_ENTRIES   0x78

Definition at line 24 of file DebugSupport.h.

◆ SYSTEM_TIMER_VECTOR

#define SYSTEM_TIMER_VECTOR   0x68

Definition at line 25 of file DebugSupport.h.

Typedef Documentation

◆ CALLBACK_FUNC

typedef VOID(EFIAPI * CALLBACK_FUNC) ()

Definition at line 34 of file DebugSupport.h.

◆ DEBUG_PROC

typedef VOID(* DEBUG_PROC) (VOID)

Definition at line 28 of file DebugSupport.h.

Function Documentation

◆ CommonIdtEntry()

VOID CommonIdtEntry ( VOID  )

Generic IDT entry.

◆ CreateEntryStub()

VOID CreateEntryStub ( IN EFI_EXCEPTION_TYPE  ExceptionType,
OUT VOID **  Stub 
)

Allocate pool for a new IDT entry stub.

Copy the generic stub into the new buffer and fixup the vector number and jump target address.

Parameters
ExceptionTypeThis is the exception type that the new stub will be created for.
StubOn successful exit, *Stub contains the newly allocated entry stub.

Definition at line 52 of file PlDebugSupportIa32.c.

◆ FxStorSupport()

BOOLEAN FxStorSupport ( VOID  )

Check whether FXSTOR is supported

Return values
TRUEFXSTOR is supported.
FALSEFXSTOR is not supported.

◆ GetInterruptHandleFromIdt()

UINTN GetInterruptHandleFromIdt ( IN IA32_IDT_GATE_DESCRIPTOR *  IdtGateDecriptor)

Get Interrupt Handle from IDT Gate Descriptor.

Parameters
IdtGateDecriptorIDT Gate Descriptor.
Returns
Interrupt Handle stored in IDT Gate Descriptor.

Get Interrupt Handle from IDT Gate Descriptor.

Parameters
IdtGateDescriptorIDT Gate Descriptor.
Returns
Interrupt Handle stored in IDT Gate Descriptor.

Definition at line 24 of file PlDebugSupportIa32.c.

◆ GetMaximumProcessorIndex()

EFI_STATUS EFIAPI GetMaximumProcessorIndex ( IN EFI_DEBUG_SUPPORT_PROTOCOL This,
OUT UINTN MaxProcessorIndex 
)

Returns the maximum value that may be used for the ProcessorIndex parameter in RegisterPeriodicCallback() and RegisterExceptionCallback().

Hard coded to support only 1 processor for now.

Parameters
ThisA pointer to the EFI_DEBUG_SUPPORT_PROTOCOL instance.
MaxProcessorIndexPointer to a caller-allocated UINTN in which the maximum supported processor index is returned. Always 0 returned.
Return values
EFI_SUCCESSAlways returned with **MaxProcessorIndex set to 0.

Definition at line 164 of file PlDebugSupport.c.

◆ HookEntry()

VOID HookEntry ( IN EFI_EXCEPTION_TYPE  ExceptionType,
IN CALLBACK_FUNC  NewCallback 
)

Creates a nes entry stub. Then saves the current IDT entry and replaces it with an interrupt gate for the new entry point. The IdtEntryTable is updated with the new registered function.

This code executes in boot services context. The stub entry executes in interrupt context.

Parameters
ExceptionTypeSpecifies which vector to hook.
NewCallbackA pointer to the new function to be registered.

Definition at line 73 of file PlDebugSupport.c.

◆ InvalidateInstructionCache()

EFI_STATUS EFIAPI InvalidateInstructionCache ( IN EFI_DEBUG_SUPPORT_PROTOCOL This,
IN UINTN  ProcessorIndex,
IN VOID *  Start,
IN UINT64  Length 
)

Invalidates processor instruction cache for a memory range. Subsequent execution in this range causes a fresh memory fetch to retrieve code to be executed.

Parameters
ThisA pointer to the EFI_DEBUG_SUPPORT_PROTOCOL instance.
ProcessorIndexSpecifies which processor's instruction cache is to be invalidated.
StartSpecifies the physical base of the memory range to be invalidated.
LengthSpecifies the minimum number of bytes in the processor's instruction cache to invalidate.
Return values
EFI_SUCCESSAlways returned.

Definition at line 242 of file PlDebugSupport.c.

◆ ManageIdtEntryTable()

EFI_STATUS ManageIdtEntryTable ( CALLBACK_FUNC  NewCallback,
EFI_EXCEPTION_TYPE  ExceptionType 
)

This is the main worker function that manages the state of the interrupt handlers. It both installs and uninstalls interrupt handlers based on the value of NewCallback. If NewCallback is NULL, then uninstall is indicated. If NewCallback is non-NULL, then install is indicated.

Parameters
NewCallbackIf non-NULL, NewCallback specifies the new handler to register. If NULL, specifies that the previously registered handler should be uninstalled.
ExceptionTypeIndicates which entry to manage.
Return values
EFI_SUCCESSProcess is ok.
EFI_INVALID_PARAMETERRequested uninstalling a handler from a vector that has no handler registered for it
EFI_ALREADY_STARTEDRequested install to a vector that already has a handler registered.
othersPossible return values are passed through from UnHookEntry and HookEntry.

This is the main worker function that manages the state of the interrupt handlers. It both installs and uninstalls interrupt handlers based on the value of NewCallback. If NewCallback is NULL, then uninstall is indicated. If NewCallback is non-NULL, then install is indicated.

Parameters
NewCallbackIf non-NULL, NewCallback specifies the new handler to register. If NULL, specifies that the previously registered handler should be uninstalled.
ExceptionTypeIndicates which entry to manage.
Return values
EFI_SUCCESSInstalling or Uninstalling operation is ok.
EFI_INVALID_PARAMETERRequested uninstalling a handler from a vector that has no handler registered for it
EFI_ALREADY_STARTEDRequested install to a vector that already has a handler registered.

Definition at line 105 of file PlDebugSupportIa32.c.

◆ PlInitializeDebugSupportDriver()

EFI_STATUS PlInitializeDebugSupportDriver ( VOID  )

Initializes driver's handler registration database.

This code executes in boot services context Must be public because it's referenced from DebugSupport.c

Return values
EFI_UNSUPPORTEDIf IA32 processor does not support FXSTOR/FXRSTOR instructions, the context save will fail, so these processor's are not supported.
EFI_OUT_OF_RESOURCESFails to allocate memory.
EFI_SUCCESSInitializes successfully.

Initializes driver's handler registration database.

This code executes in boot services context. Must be public because it's referenced from DebugSupport.c

Return values
EFI_UNSUPPORTEDIf IA32/x64 processor does not support FXSTOR/FXRSTOR instructions, the context save will fail, so these processors are not supported.
EFI_OUT_OF_RESOURCESFails to allocate memory.
EFI_SUCCESSInitializes successfully.

Definition at line 325 of file PlDebugSupport.c.

◆ PlUnloadDebugSupportDriver()

EFI_STATUS EFIAPI PlUnloadDebugSupportDriver ( IN EFI_HANDLE  ImageHandle)

This is the callback that is written to the LoadedImage protocol instance on the image handle. It uninstalls all registered handlers and frees all entry stub memory.

Parameters
ImageHandleThe firmware allocated handle for the EFI image.
Return values
EFI_SUCCESSAlways.

This is the callback that is written to the Loaded Image protocol instance on the image handle. It uninstalls all registered handlers and frees all entry stub memory.

Parameters
ImageHandleThe firmware allocated handle for the EFI image.
Return values
EFI_SUCCESSAlways.

Definition at line 291 of file PlDebugSupport.c.

◆ RegisterExceptionCallback()

EFI_STATUS EFIAPI RegisterExceptionCallback ( IN EFI_DEBUG_SUPPORT_PROTOCOL This,
IN UINTN  ProcessorIndex,
IN EFI_EXCEPTION_CALLBACK  ExceptionCallback,
IN EFI_EXCEPTION_TYPE  ExceptionType 
)

Registers a function to be called when a given processor exception occurs.

This code executes in boot services context.

Parameters
ThisA pointer to the EFI_DEBUG_SUPPORT_PROTOCOL instance.
ProcessorIndexSpecifies which processor the callback function applies to.
ExceptionCallbackA pointer to a function of type EXCEPTION_CALLBACK that is called when the processor exception specified by ExceptionType occurs.
ExceptionTypeSpecifies which processor exception to hook.
Return values
EFI_SUCCESSThe function completed successfully.
EFI_ALREADY_STARTEDNon-NULL PeriodicCallback parameter when a callback function was previously registered.
EFI_OUT_OF_RESOURCESSystem has insufficient memory resources to register new callback function.

Definition at line 217 of file PlDebugSupport.c.

◆ RegisterPeriodicCallback()

EFI_STATUS EFIAPI RegisterPeriodicCallback ( IN EFI_DEBUG_SUPPORT_PROTOCOL This,
IN UINTN  ProcessorIndex,
IN EFI_PERIODIC_CALLBACK  PeriodicCallback 
)

Registers a function to be called back periodically in interrupt context.

Parameters
ThisA pointer to the EFI_DEBUG_SUPPORT_PROTOCOL instance.
ProcessorIndexSpecifies which processor the callback function applies to.
PeriodicCallbackA pointer to a function of type PERIODIC_CALLBACK that is the main periodic entry point of the debug agent.
Return values
EFI_SUCCESSThe function completed successfully.
EFI_ALREADY_STARTEDNon-NULL PeriodicCallback parameter when a callback function was previously registered.
EFI_OUT_OF_RESOURCESSystem has insufficient memory resources to register new callback function.

Definition at line 189 of file PlDebugSupport.c.

◆ UnhookEntry()

VOID UnhookEntry ( IN EFI_EXCEPTION_TYPE  ExceptionType)

Undoes HookEntry. This code executes in boot services context.

Parameters
ExceptionTypeSpecifies which entry to unhook

Definition at line 125 of file PlDebugSupport.c.

◆ Vect2Desc()

VOID Vect2Desc ( IA32_IDT_GATE_DESCRIPTOR *  DestDesc,
VOID(*)(VOID)  Vector 
)

Encodes an IDT descriptor with the given physical address.

Parameters
DestDescThe IDT descriptor address.
VecotrThe interrupt vector entry.

Variable Documentation

◆ IdtEntryTable

IDT_ENTRY* IdtEntryTable
extern

Definition at line 14 of file PlDebugSupport.c.

◆ NullDesc

IA32_IDT_GATE_DESCRIPTOR NullDesc
extern

Definition at line 11 of file PlDebugSupportIa32.c.