13UINTN mSavedDebugRegisters[6];
14IA32_IDT_GATE_DESCRIPTOR mIdtEntryTable[33];
15BOOLEAN mSkipBreakpoint =
FALSE;
16BOOLEAN mSmmDebugIdtInitFlag =
FALSE;
17BOOLEAN mApicTimerRestore =
FALSE;
20UINTN mApicTimerDivisor;
23CHAR8 mWarningMsgIgnoreSmmEntryBreak[] =
"Ignore smmentrybreak setting for SMI issued during DXE debugging!\r\n";
52 IN DEBUG_PORT_HANDLE Handle,
53 OUT UINT8 *BreakSymbol
74 UINT64 *MailboxLocation;
78 if (GuidHob ==
NULL) {
82 MailboxLocation = (UINT64 *)(GET_GUID_HOB_DATA (GuidHob));
101 return mMailboxPointer;
180 IN VOID *Context OPTIONAL,
185 UINT64 DebugPortHandle;
186 IA32_IDT_GATE_DESCRIPTOR IdtEntry[33];
187 IA32_DESCRIPTOR IdtDescriptor;
188 IA32_DESCRIPTOR *Ia32Idtr;
190 IA32_DESCRIPTOR Idtr;
191 UINT16 IdtEntryCount;
193 UINT64 *MailboxLocation;
194 UINT32 DebugTimerFrequency;
197 case DEBUG_AGENT_INIT_SMM:
201 Status =
gSmst->SmmInstallConfigurationTable (
203 &gEfiVectorHandoffTableGuid,
204 (VOID *)&mVectorHandoffInfoDebugAgent[0],
207 if (EFI_ERROR (Status)) {
208 DEBUG ((DEBUG_ERROR,
"DebugAgent: Cannot install configuration table for persisted vector handoff info!\n"));
209 if (Context !=
NULL) {
210 *(BOOLEAN *)Context =
FALSE;
222 mMailboxPointer = Mailbox;
223 if (Context !=
NULL) {
224 *(BOOLEAN *)Context =
TRUE;
234 if (Mailbox !=
NULL) {
235 mMailboxPointer = Mailbox;
236 if (Context !=
NULL) {
237 *(BOOLEAN *)Context =
TRUE;
247 Mailbox = &mLocalMailbox;
252 CopyMem (&IdtEntry, (VOID *)IdtDescriptor.Base, 33 * sizeof (IA32_IDT_GATE_DESCRIPTOR));
265 mMailboxPointer = Mailbox;
289 CopyMem ((VOID *)IdtDescriptor.Base, &IdtEntry, 33 * sizeof (IA32_IDT_GATE_DESCRIPTOR));
291 if (Context !=
NULL) {
292 *(BOOLEAN *)Context =
TRUE;
297 case DEBUG_AGENT_INIT_ENTER_SMI:
299 if (!mSmmDebugIdtInitFlag) {
305 mSmmDebugIdtInitFlag =
TRUE;
314 if (!mPeriodicMode || (mTimerCycle == 0)) {
315 mApicTimerRestore =
TRUE;
320 if (
GetDebugFlag (DEBUG_AGENT_FLAG_AGENT_IN_PROGRESS) == 1) {
325 mSkipBreakpoint =
TRUE;
328 if (
GetDebugFlag (DEBUG_AGENT_FLAG_BREAK_ON_NEXT_SMI) == 1) {
329 if (mSkipBreakpoint) {
334 (DEBUG_PORT_HANDLE)(
UINTN)Mailbox->DebugPortHandle,
335 (UINT8 *)mWarningMsgIgnoreSmmEntryBreak,
348 case DEBUG_AGENT_INIT_EXIT_SMI:
353 mSkipBreakpoint =
FALSE;
358 if (mApicTimerRestore) {
360 mApicTimerRestore =
FALSE;
365 case DEBUG_AGENT_INIT_THUNK_PEI_IA32TOX64:
366 if (Context ==
NULL) {
367 DEBUG ((DEBUG_ERROR,
"DebugAgent: Input parameter Context cannot be NULL!\n"));
370 Ia32Idtr = (IA32_DESCRIPTOR *)Context;
372 MailboxLocation = (UINT64 *)((
UINTN)Ia32IdtEntry[DEBUG_MAILBOX_VECTOR].Bits.
OffsetLow +
373 ((
UINTN)Ia32IdtEntry[DEBUG_MAILBOX_VECTOR].Bits.OffsetHigh << 16));
380 IdtEntryCount = (UINT16)((Idtr.Limit + 1) /
sizeof (IA32_IDT_GATE_DESCRIPTOR));
381 if (IdtEntryCount < 33) {
382 Idtr.Limit = (UINT16)(
sizeof (IA32_IDT_GATE_DESCRIPTOR) * 33 - 1);
383 Idtr.Base = (
UINTN)&mIdtEntryTable;
384 ZeroMem (&mIdtEntryTable, Idtr.Limit + 1);
393 UpdateMailboxContent (mMailboxPointer, DEBUG_MAILBOX_DEBUG_TIMER_FREQUENCY, DebugTimerFrequency);
410 DEBUG ((DEBUG_ERROR,
"Debug Agent: The InitFlag value is not allowed!\n"));
VOID *EFIAPI GetFirstGuidHob(IN CONST EFI_GUID *Guid)
UINTN EFIAPI AsciiStrLen(IN CONST CHAR8 *String)
VOID EFIAPI CpuDeadLoop(VOID)
VOID EFIAPI EnableInterrupts(VOID)
VOID EFIAPI CpuBreakpoint(VOID)
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
VOID *EFIAPI ZeroMem(OUT VOID *Buffer, IN UINTN Length)
VOID UpdateMailboxContent(IN DEBUG_AGENT_MAILBOX *Mailbox, IN UINTN Index, IN UINT64 Value)
UINT32 GetDebugFlag(IN UINT64 FlagMask)
BOOLEAN IsHostAttached(VOID)
VOID VerifyMailboxChecksum(IN DEBUG_AGENT_MAILBOX *Mailbox)
VOID SetDebugFlag(IN UINT64 FlagMask, IN UINT32 FlagValue)
VOID FindAndReportModuleImageInfo(IN UINTN AlignSize)
VOID TriggerSoftInterrupt(IN UINT32 Signature)
VOID InitializeDebugIdt(VOID)
VOID(EFIAPI * DEBUG_AGENT_CONTINUE)(IN VOID *Context)
BOOLEAN EFIAPI SaveAndSetDebugTimerInterrupt(IN BOOLEAN EnableStatus)
DEBUG_PORT_HANDLE EFIAPI DebugPortInitialize(IN VOID *Context, IN DEBUG_PORT_CONTINUE Function)
UINTN EFIAPI DebugPortWriteBuffer(IN DEBUG_PORT_HANDLE Handle, IN UINT8 *Buffer, IN UINTN NumberOfBytes)
UINT32 InitializeDebugTimer(OUT UINT32 *TimerFrequency, IN BOOLEAN DumpFlag)
UINTN EFIAPI AsmWriteDr1(UINTN Dr1)
UINTN EFIAPI AsmReadDr1(VOID)
UINTN EFIAPI AsmReadDr0(VOID)
UINTN EFIAPI AsmWriteDr7(UINTN Dr7)
UINTN EFIAPI AsmWriteDr3(UINTN Dr3)
UINTN EFIAPI AsmReadDr2(VOID)
UINTN EFIAPI AsmWriteDr2(UINTN Dr2)
UINTN EFIAPI AsmWriteDr0(UINTN Dr0)
UINTN EFIAPI AsmReadDr3(VOID)
UINTN EFIAPI AsmReadDr6(VOID)
UINTN EFIAPI AsmWriteDr6(UINTN Dr6)
UINTN EFIAPI AsmReadDr7(VOID)
VOID EFIAPI InitializeLocalApicSoftwareEnable(IN BOOLEAN Enable)
VOID EFIAPI GetApicTimerState(OUT UINTN *DivideValue OPTIONAL, OUT BOOLEAN *PeriodicMode OPTIONAL, OUT UINT8 *Vector OPTIONAL)
UINT32 EFIAPI GetApicTimerInitCount(VOID)
VOID EFIAPI InitializeApicTimer(IN UINTN DivideValue, IN UINT32 InitCount, IN BOOLEAN PeriodicMode, IN UINT8 Vector)
#define DEBUG(Expression)
EFI_SMM_SYSTEM_TABLE2 * gSmst
VOID SaveDebugRegister(VOID)
DEBUG_AGENT_MAILBOX * GetMailboxFromHob(VOID)
DEBUG_AGENT_MAILBOX * GetMailboxPointer(VOID)
BOOLEAN MultiProcessorDebugSupport(VOID)
VOID RestoreDebugRegister(VOID)
VOID EFIAPI InitializeDebugAgent(IN UINT32 InitFlag, IN VOID *Context OPTIONAL, IN DEBUG_AGENT_CONTINUE Function OPTIONAL)
DEBUG_PORT_HANDLE GetDebugPortHandle(VOID)
EFI_STATUS DebugReadBreakSymbol(IN DEBUG_PORT_HANDLE Handle, OUT UINT8 *BreakSymbol)
EFI_STATUS EFIAPI EfiGetSystemConfigurationTable(IN EFI_GUID *TableGuid, OUT VOID **Table)
VOID EFIAPI AsmReadIdtr(OUT IA32_DESCRIPTOR *Idtr)
VOID EFIAPI AsmWriteIdtr(IN CONST IA32_DESCRIPTOR *Idtr)
UINT32 OffsetLow
Offset bits 15..0.