14 &mVectorHandoffInfoDebugAgent[0]
22 (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
23 &gEfiVectorHandoffInfoPpiGuid,
24 &mVectorHandoffInfoPpi
30 (EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
31 &gEfiPeiMemoryDiscoveredPpiGuid,
63 IN DEBUG_PORT_HANDLE Handle,
64 OUT UINT8 *BreakSymbol
75 Data8 = (UINT8 *)&DebugHeader;
91 if (*Data8 == DEBUG_STARTING_SYMBOL_ATTACH) {
92 *BreakSymbol = *Data8;
93 DebugAgentMsgPrint (DEBUG_AGENT_INFO,
"Debug Timer attach symbol received %x", *BreakSymbol);
97 if (*Data8 == DEBUG_STARTING_SYMBOL_NORMAL) {
100 *BreakSymbol = DebugHeader.Command;
101 DebugAgentMsgPrint (DEBUG_AGENT_INFO,
"Debug Timer break symbol received %x", *BreakSymbol);
105 if (Status == EFI_TIMEOUT) {
111 return EFI_NOT_FOUND;
123 UINTN *MailboxLocation;
130 return MailboxLocation;
141 IN VOID *MailboxLocation
161 if (GuidHob ==
NULL) {
165 return (UINT64 *)(GET_GUID_HOB_DATA (GuidHob));
179 UINT64 DebugPortHandle;
180 UINT64 *MailboxLocationInIdt;
181 UINT64 *MailboxLocationInHob;
192 if ((Mailbox->DebugFlag.Bits.CheckMailboxInHob != 1) ||
193 (Mailbox->DebugFlag.Bits.InitArch != DEBUG_ARCH_SYMBOL))
208 if ((MailboxLocationInHob != MailboxLocationInIdt) && (MailboxLocationInHob !=
NULL)) {
214 DebugPortHandle = (
UINTN)Mailbox->DebugPortHandle + ((
UINTN)(MailboxLocationInHob) - (
UINTN)MailboxLocationInIdt);
216 *MailboxLocationInHob = (UINT64)(
UINTN)Mailbox;
221 Mailbox->DebugFlag.Bits.CheckMailboxInHob = 0;
243 return (DEBUG_PORT_HANDLE)(
UINTN)(DebugAgentMailbox->DebugPortHandle);
266 BOOLEAN InterruptStatus;
269 UINT64 *MailboxLocationInHob;
293 CopyMem (NewMailbox + 1, (VOID *)(
UINTN)Mailbox->DebugPortHandle,
PcdGet16 (PcdDebugPortHandleBufferSize));
298 ASSERT (MailboxLocationInHob !=
NULL);
299 *MailboxLocationInHob = (UINT64)(
UINTN)NewMailbox;
360 IN VOID *Context OPTIONAL,
370 IA32_DESCRIPTOR *Ia32Idtr;
372 UINT64 DebugPortHandle;
373 UINT64 MailboxLocation;
374 UINT64 *MailboxLocationPointer;
376 UINT32 DebugTimerFrequency;
377 BOOLEAN CpuInterruptState;
385 case DEBUG_AGENT_INIT_PREMEM_SEC:
389 MailboxLocation = (UINT64)(
UINTN)&MailboxInStack;
390 Mailbox = &MailboxInStack;
399 SetDebugFlag (DEBUG_AGENT_FLAG_PRINT_ERROR_LEVEL, DEBUG_AGENT_ERROR);
403 SetDebugFlag (DEBUG_AGENT_FLAG_INIT_ARCH, DEBUG_ARCH_SYMBOL);
410 Phase2Context.InitFlag = InitFlag;
411 Phase2Context.Context = Context;
412 Phase2Context.Function = Function;
417 DEBUG ((DEBUG_ERROR,
"Debug Agent: Debug port initialization failed.\n"));
421 case DEBUG_AGENT_INIT_POSTMEM_SEC:
438 if (EFI_ERROR (Status)) {
439 DEBUG ((DEBUG_ERROR,
"DebugAgent: Failed to install Vector Handoff Info PPI!\n"));
447 if (DebugAgentContext !=
NULL) {
448 DebugPortHandle = (UINT64)(UINT32)(Mailbox->DebugPortHandle + DebugAgentContext->StackMigrateOffset);
451 MailboxLocation = (UINT64)(
UINTN)Mailbox;
460 MailboxLocationPointer = (UINT64 *)((
UINTN)MailboxLocationPointer + DebugAgentContext->HeapMigrateOffset);
471 if (EFI_ERROR (Status)) {
472 DEBUG ((DEBUG_ERROR,
"DebugAgent: Failed to allocate pages!\n"));
483 CopyMem (NewMailbox + 1, (VOID *)(
UINTN)Mailbox->DebugPortHandle,
PcdGet16 (PcdDebugPortHandleBufferSize));
485 MailboxLocation = (UINT64)(
UINTN)NewMailbox;
502 case DEBUG_AGENT_INIT_PEI:
503 if (Context ==
NULL) {
504 DEBUG ((DEBUG_ERROR,
"DebugAgent: Input parameter Context cannot be NULL!\n"));
512 DEBUG ((DEBUG_WARN,
"Debug Agent: It has already initialized in SEC Core!\n"));
520 if (EFI_ERROR (Status)) {
521 DEBUG ((DEBUG_ERROR,
"DebugAgent: Failed to install Vector Handoff Info PPI!\n"));
533 if (Mailbox ==
NULL) {
534 DEBUG ((DEBUG_ERROR,
"DebugAgent: Failed to allocate memory!\n"));
537 MailboxLocation = (UINT64)(
UINTN)Mailbox;
557 SetDebugFlag (DEBUG_AGENT_FLAG_INIT_ARCH, DEBUG_ARCH_SYMBOL);
563 if (EFI_ERROR (Status)) {
564 DEBUG ((DEBUG_ERROR,
"DebugAgent: Failed to register memory discovered callback function!\n"));
571 if (
GetDebugFlag (DEBUG_AGENT_FLAG_MEMORY_READY) == 0) {
572 SetDebugFlag (DEBUG_AGENT_FLAG_CHECK_MAILBOX_IN_HOB, 1);
575 Phase2Context.InitFlag = InitFlag;
576 Phase2Context.Context = Context;
577 Phase2Context.Function = Function;
584 case DEBUG_AGENT_INIT_THUNK_PEI_IA32TOX64:
585 if (Context ==
NULL) {
586 DEBUG ((DEBUG_ERROR,
"DebugAgent: Input parameter Context cannot be NULL!\n"));
589 Ia32Idtr = (IA32_DESCRIPTOR *)Context;
591 MailboxLocationPointer = (UINT64 *)((
UINTN)Ia32IdtEntry[DEBUG_MAILBOX_VECTOR].Bits.
OffsetLow +
592 ((
UINTN)Ia32IdtEntry[DEBUG_MAILBOX_VECTOR].Bits.OffsetHigh << 16));
620 DEBUG ((DEBUG_ERROR,
"Debug Agent: The InitFlag value is not allowed!\n"));
625 if (InitFlag == DEBUG_AGENT_INIT_POSTMEM_SEC) {
645 if (Function !=
NULL) {
652 if ((InitFlag == DEBUG_AGENT_INIT_PEI) && (Context !=
NULL)) {
670 IN DEBUG_PORT_HANDLE DebugPortHandle
674 UINT64 *MailboxLocation;
678 UINT64 NewDebugPortHandle;
683 BufferSize =
PcdGet16 (PcdDebugPortHandleBufferSize);
684 if ((Phase2Context->InitFlag == DEBUG_AGENT_INIT_PEI) && (BufferSize != 0)) {
687 NewDebugPortHandle = (UINT64)(
UINTN)DebugPortHandle;
697 if (Phase2Context->InitFlag == DEBUG_AGENT_INIT_PREMEM_SEC) {
719 Phase2Context->Function (Phase2Context->Context);
VOID *EFIAPI GetFirstGuidHob(IN CONST EFI_GUID *Guid)
VOID *EFIAPI BuildGuidDataHob(IN CONST EFI_GUID *Guid, IN VOID *Data, IN UINTN DataLength)
BOOLEAN EFIAPI SetInterruptState(IN BOOLEAN InterruptState)
BOOLEAN EFIAPI SaveAndDisableInterrupts(VOID)
VOID EFIAPI CpuDeadLoop(VOID)
VOID EFIAPI EnableInterrupts(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)
VOID EFIAPI DebugAgentMsgPrint(IN UINT8 ErrorLevel, IN CHAR8 *Format,...)
BOOLEAN IsHostAttached(VOID)
VOID VerifyMailboxChecksum(IN DEBUG_AGENT_MAILBOX *Mailbox)
VOID UpdateMailboxChecksum(IN DEBUG_AGENT_MAILBOX *Mailbox)
VOID SetDebugFlag(IN UINT64 FlagMask, IN UINT32 FlagValue)
VOID FindAndReportModuleImageInfo(IN UINTN AlignSize)
UINTN DebugAgentReadBuffer(IN DEBUG_PORT_HANDLE Handle, IN UINT8 *Buffer, IN UINTN NumberOfBytes, IN UINTN Timeout)
BOOLEAN IsDebugAgentInitialzed(VOID)
VOID TriggerSoftInterrupt(IN UINT32 Signature)
EFI_STATUS ReadRemainingBreakPacket(IN DEBUG_PORT_HANDLE Handle, IN OUT DEBUG_PACKET_HEADER *DebugHeader)
VOID * GetExceptionHandlerInIdtEntry(IN UINTN ExceptionNum)
VOID InitializeDebugIdt(VOID)
VOID SetExceptionHandlerInIdtEntry(IN UINTN ExceptionNum, IN VOID *ExceptionHandler)
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)
BOOLEAN EFIAPI DebugPortPollBuffer(IN DEBUG_PORT_HANDLE Handle)
UINT32 InitializeDebugTimer(OUT UINT32 *TimerFrequency, IN BOOLEAN DumpFlag)
VOID *EFIAPI AllocateZeroPool(IN UINTN AllocationSize)
VOID *EFIAPI AllocateCopyPool(IN UINTN AllocationSize, IN CONST VOID *Buffer)
EFI_STATUS EFIAPI PeiServicesNotifyPpi(IN CONST EFI_PEI_NOTIFY_DESCRIPTOR *NotifyList)
EFI_STATUS EFIAPI PeiServicesAllocatePages(IN EFI_MEMORY_TYPE MemoryType, IN UINTN Pages, OUT EFI_PHYSICAL_ADDRESS *Memory)
EFI_STATUS EFIAPI PeiServicesInstallPpi(IN CONST EFI_PEI_PPI_DESCRIPTOR *PpiList)
#define GLOBAL_REMOVE_IF_UNREFERENCED
#define ASSERT_EFI_ERROR(StatusParameter)
#define DEBUG(Expression)
#define PcdGet16(TokenName)
VOID EFIAPI InitializeDebugAgentPhase2(IN VOID *Context, IN DEBUG_PORT_HANDLE DebugPortHandle)
DEBUG_AGENT_MAILBOX * GetMailboxPointer(VOID)
UINT64 * GetMailboxLocationFromHob(VOID)
BOOLEAN MultiProcessorDebugSupport(VOID)
EFI_STATUS EFIAPI DebugAgentCallbackMemoryDiscoveredPpi(IN EFI_PEI_SERVICES **PeiServices, IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor, IN VOID *Ppi)
VOID SetLocationSavedMailboxPointerInIdtEntry(IN VOID *MailboxLocation)
VOID * GetLocationSavedMailboxPointerInIdtEntry(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)
UINT64 EFI_PHYSICAL_ADDRESS
#define EFI_SIZE_TO_PAGES(Size)
UINT32 OffsetLow
Offset bits 15..0.