13IA32_IDT_GATE_DESCRIPTOR mIdtEntryTable[33];
14BOOLEAN mDxeCoreFlag =
FALSE;
15BOOLEAN mMultiProcessorDebugSupport =
FALSE;
16VOID *mSavedIdtTable =
NULL;
17UINTN mSaveIdtTableSize = 0;
18BOOLEAN mDebugAgentInitialized =
FALSE;
19BOOLEAN mSkipBreakpoint =
FALSE;
33 return mMultiProcessorDebugSupport;
51 BOOLEAN DebugTimerInterruptState;
62 if ((GuidHob !=
NULL) && !mDxeCoreFlag) {
75 Status =
gBS->InstallConfigurationTable (&gEfiVectorHandoffTableGuid, (VOID *)&mVectorHandoffInfoDebugAgent[0]);
76 if (EFI_ERROR (Status)) {
77 DEBUG ((DEBUG_ERROR,
"DebugAgent: Cannot install configuration table for persisted vector handoff info!\n"));
88 Status =
gBS->AllocatePages (
94 if (EFI_ERROR (Status)) {
95 DEBUG ((DEBUG_ERROR,
"DebugAgent: Cannot install configuration table for mailbox!\n"));
108 CopyMem (NewMailbox + 1, (VOID *)(
UINTN)Mailbox->DebugPortHandle,
PcdGet16 (PcdDebugPortHandleBufferSize));
113 mMailboxPointer = NewMailbox;
117 Status =
gBS->InstallConfigurationTable (&gEfiDebugAgentGuid, (VOID *)mMailboxPointer);
118 if (EFI_ERROR (Status)) {
119 DEBUG ((DEBUG_ERROR,
"DebugAgent: Failed to install configuration for mailbox!\n"));
187 UINT64 *MailboxLocation;
191 if (GuidHob ==
NULL) {
195 MailboxLocation = (UINT64 *)(GET_GUID_HOB_DATA (GuidHob));
216 return mMailboxPointer;
248 IA32_DESCRIPTOR Idtr;
249 UINT16 IdtEntryCount;
250 UINT64 DebugPortHandle;
251 UINT32 DebugTimerFrequency;
253 if (mMultiProcessorDebugSupport) {
267 IdtEntryCount = (UINT16)((Idtr.Limit + 1) /
sizeof (IA32_IDT_GATE_DESCRIPTOR));
268 if (IdtEntryCount < 33) {
269 ZeroMem (&mIdtEntryTable,
sizeof (IA32_IDT_GATE_DESCRIPTOR) * 33);
273 CopyMem (&mIdtEntryTable, (VOID *)Idtr.Base, Idtr.Limit + 1);
277 Idtr.Limit = (UINT16)(
sizeof (IA32_IDT_GATE_DESCRIPTOR) * 33 - 1);
278 Idtr.Base = (
UINTN)&mIdtEntryTable;
290 if (mMailboxPointer ==
NULL) {
291 if (Mailbox !=
NULL) {
300 mMailboxPointer = &mMailbox;
307 UpdateMailboxContent (mMailboxPointer, DEBUG_MAILBOX_DEBUG_TIMER_FREQUENCY, DebugTimerFrequency);
314 if (Mailbox ==
NULL) {
353 IN VOID *Context OPTIONAL,
357 UINT64 *MailboxLocation;
359 BOOLEAN InterruptStatus;
361 IA32_DESCRIPTOR IdtDescriptor;
362 IA32_DESCRIPTOR *Ia32Idtr;
364 BOOLEAN PeriodicMode;
367 if (InitFlag == DEBUG_AGENT_INIT_DXE_AP) {
374 if (!PeriodicMode || (TimerCycle == 0)) {
399 MailboxLocation =
NULL;
402 case DEBUG_AGENT_INIT_DXE_LOAD:
407 DEBUG ((DEBUG_INFO,
"Debug Agent: The former agent will be overwritten by the new one!\n"));
410 mMultiProcessorDebugSupport =
TRUE;
415 mSaveIdtTableSize = IdtDescriptor.Limit + 1;
416 mSavedIdtTable =
AllocateCopyPool (mSaveIdtTableSize, (VOID *)IdtDescriptor.Base);
421 if (Mailbox ==
NULL) {
447 mDebugAgentInitialized =
TRUE;
454 case DEBUG_AGENT_INIT_DXE_UNLOAD:
455 if (mDebugAgentInitialized) {
467 IdtDescriptor.Limit = (UINT16)(mSaveIdtTableSize - 1);
468 CopyMem ((VOID *)IdtDescriptor.Base, mSavedIdtTable, mSaveIdtTableSize);
471 mDebugAgentInitialized =
FALSE;
484 case DEBUG_AGENT_INIT_DXE_CORE:
486 mMultiProcessorDebugSupport =
TRUE;
507 case DEBUG_AGENT_INIT_S3:
509 if (Context !=
NULL) {
510 Ia32Idtr = (IA32_DESCRIPTOR *)Context;
512 MailboxLocation = (UINT64 *)((
UINTN)Ia32IdtEntry[DEBUG_MAILBOX_VECTOR].Bits.
OffsetLow +
513 ((
UINTN)Ia32IdtEntry[DEBUG_MAILBOX_VECTOR].Bits.OffsetHigh << 16));
521 mMailboxPointer = Mailbox;
531 if (
GetDebugFlag (DEBUG_AGENT_FLAG_BREAK_BOOT_SCRIPT) == 1) {
545 DEBUG ((DEBUG_ERROR,
"Debug Agent: The InitFlag value is not allowed!\n"));
VOID *EFIAPI GetFirstGuidHob(IN CONST EFI_GUID *Guid)
VOID *EFIAPI GetNextGuidHob(IN CONST EFI_GUID *Guid, IN CONST VOID *HobStart)
VOID *EFIAPI GetHobList(VOID)
BOOLEAN EFIAPI SetInterruptState(IN BOOLEAN InterruptState)
BOOLEAN EFIAPI SaveAndDisableInterrupts(VOID)
VOID EFIAPI CpuDeadLoop(VOID)
VOID EFIAPI EnableInterrupts(VOID)
VOID EFIAPI DisableInterrupts(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)
BOOLEAN IsDebugAgentInitialzed(VOID)
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)
VOID ReleaseMpSpinLock(IN OUT SPIN_LOCK *MpSpinLock)
VOID AcquireMpSpinLock(IN OUT SPIN_LOCK *MpSpinLock)
UINT32 InitializeDebugTimer(OUT UINT32 *TimerFrequency, IN BOOLEAN DumpFlag)
VOID SetupDebugAgentEnvironment(IN DEBUG_AGENT_MAILBOX *Mailbox)
DEBUG_AGENT_MAILBOX * GetMailboxFromHob(IN VOID *HobStart)
DEBUG_AGENT_MAILBOX * GetMailboxPointer(VOID)
BOOLEAN MultiProcessorDebugSupport(VOID)
VOID InternalConstructorWorker(VOID)
RETURN_STATUS EFIAPI DxeDebugAgentLibConstructor(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
VOID EFIAPI InitializeDebugAgent(IN UINT32 InitFlag, IN VOID *Context OPTIONAL, IN DEBUG_AGENT_CONTINUE Function OPTIONAL)
DEBUG_PORT_HANDLE GetDebugPortHandle(VOID)
DEBUG_AGENT_MAILBOX * GetMailboxFromConfigurationTable(VOID)
VOID InstallSerialIo(VOID)
VOID EFIAPI FreePool(IN VOID *Buffer)
VOID *EFIAPI AllocateCopyPool(IN UINTN AllocationSize, IN CONST VOID *Buffer)
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)
#define DEBUG(Expression)
#define PcdGet16(TokenName)
SPIN_LOCK *EFIAPI InitializeSpinLock(OUT SPIN_LOCK *SpinLock)
UINT64 EFI_PHYSICAL_ADDRESS
#define EFI_SIZE_TO_PAGES(Size)
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)
SPIN_LOCK MpContextSpinLock
Lock for writing MP context.
SPIN_LOCK MailboxSpinLock
Lock for accessing mail box.
UINT32 DebugTimerInitCount
Record BSP's init timer count.
SPIN_LOCK DebugPortSpinLock
Lock for access debug port.
UINT32 BreakAtCpuIndex
Processor index value of the current breaking CPU.
UINT32 OffsetLow
Offset bits 15..0.