TianoCore EDK2 master
Loading...
Searching...
No Matches
PlDebugSupport.c File Reference
#include "DebugSupport.h"

Go to the source code of this file.

Functions

VOID ReadIdtGateDescriptor (IN EFI_EXCEPTION_TYPE Vector, OUT IA32_IDT_GATE_DESCRIPTOR *IdtGateDescriptor)
 
VOID WriteIdtGateDescriptor (EFI_EXCEPTION_TYPE Vector, IA32_IDT_GATE_DESCRIPTOR *IdtGateDescriptor)
 
VOID HookEntry (IN EFI_EXCEPTION_TYPE ExceptionType, IN CALLBACK_FUNC NewCallback)
 
VOID UnhookEntry (IN EFI_EXCEPTION_TYPE ExceptionType)
 
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 InterruptDistrubutionHub (EFI_EXCEPTION_TYPE ExceptionType, EFI_SYSTEM_CONTEXT_IA32 *ContextRecord)
 
EFI_STATUS EFIAPI PlUnloadDebugSupportDriver (IN EFI_HANDLE ImageHandle)
 
EFI_STATUS PlInitializeDebugSupportDriver (VOID)
 

Variables

IDT_ENTRYIdtEntryTable = NULL
 

Detailed Description

IA32/x64 generic functions to support Debug Support protocol.

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

Definition in file PlDebugSupport.c.

Function Documentation

◆ 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.

◆ InterruptDistrubutionHub()

VOID InterruptDistrubutionHub ( EFI_EXCEPTION_TYPE  ExceptionType,
EFI_SYSTEM_CONTEXT_IA32 ContextRecord 
)

Common piece of code that invokes the registered handlers.

This code executes in exception context so no efi calls are allowed. This code is called from assembly file.

Parameters
ExceptionTypeException type
ContextRecordSystem context

Definition at line 264 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.

◆ 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/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 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.

◆ ReadIdtGateDescriptor()

VOID ReadIdtGateDescriptor ( IN EFI_EXCEPTION_TYPE  Vector,
OUT IA32_IDT_GATE_DESCRIPTOR *  IdtGateDescriptor 
)

Read IDT Gate Descriptor from IDT Table.

Parameters
VectorSpecifies vector number.
IdtGateDescriptorPointer to IDT Gate Descriptor read from IDT Table.

Definition at line 24 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.

◆ WriteIdtGateDescriptor()

VOID WriteIdtGateDescriptor ( EFI_EXCEPTION_TYPE  Vector,
IA32_IDT_GATE_DESCRIPTOR *  IdtGateDescriptor 
)

Write IDT Gate Descriptor into IDT Table.

Parameters
VectorSpecifies vector number.
IdtGateDescriptorPointer to IDT Gate Descriptor written into IDT Table.

Definition at line 46 of file PlDebugSupport.c.

Variable Documentation

◆ IdtEntryTable

IDT_ENTRY* IdtEntryTable = NULL

Definition at line 14 of file PlDebugSupport.c.