当前位置: 首页 > news >正文

010SecMain_InitializeDebugAgentPhase2

InitializeDebugAgentPhase2

进入到DEBUG Agent初始化第二阶段,这里做的事情主要处理以下事务

  • 更新某些Mailbox信息,DebugPortHandle
  • Trigger one software interrupt to inform HOST
  • 开启Debug APCI timer中断
  • 开启CPU中断

至此,Debug Agent初始化完成。

/**Caller provided function to be invoked at the end of DebugPortInitialize().Refer to the description for DebugPortInitialize() for more details.@param[in] Context           The first input argument of DebugPortInitialize().@param[in] DebugPortHandle   Debug port handle created by Debug Communication Library.**/
VOID
EFIAPI
InitializeDebugAgentPhase2 (IN VOID               *Context,IN DEBUG_PORT_HANDLE  DebugPortHandle)
{DEBUG_AGENT_PHASE2_CONTEXT  *Phase2Context;UINT64                      *MailboxLocation;DEBUG_AGENT_MAILBOX         *Mailbox;EFI_SEC_PEI_HAND_OFF        *SecCoreData;UINT16                      BufferSize;UINT64                      NewDebugPortHandle;Phase2Context   = (DEBUG_AGENT_PHASE2_CONTEXT *)Context;MailboxLocation = GetLocationSavedMailboxPointerInIdtEntry ();Mailbox         = (DEBUG_AGENT_MAILBOX *)(UINTN)(*MailboxLocation);BufferSize      = PcdGet16 (PcdDebugPortHandleBufferSize);if ((Phase2Context->InitFlag == DEBUG_AGENT_INIT_PEI) && (BufferSize != 0)) {NewDebugPortHandle = (UINT64)(UINTN)AllocateCopyPool (BufferSize, DebugPortHandle);} else {NewDebugPortHandle = (UINT64)(UINTN)DebugPortHandle;}UpdateMailboxContent (Mailbox, DEBUG_MAILBOX_DEBUG_PORT_HANDLE_INDEX, NewDebugPortHandle);//// Trigger one software interrupt to inform HOST//TriggerSoftInterrupt (SYSTEM_RESET_SIGNATURE);if (Phase2Context->InitFlag == DEBUG_AGENT_INIT_PREMEM_SEC) {//// If Temporary RAM region is below 128 MB, then send message to// host to disable low memory filtering.//SecCoreData = (EFI_SEC_PEI_HAND_OFF *)Phase2Context->Context;if (((UINTN)SecCoreData->TemporaryRamBase < BASE_128MB) && IsHostAttached ()) {SetDebugFlag (DEBUG_AGENT_FLAG_MEMORY_READY, 1);TriggerSoftInterrupt (MEMORY_READY_SIGNATURE);}//// Enable Debug Timer interrupt//SaveAndSetDebugTimerInterrupt (TRUE);//// Enable CPU interrupts so debug timer interrupts can be delivered//EnableInterrupts ();//// Call continuation function if it is not NULL.//Phase2Context->Function (Phase2Context->Context);}
}

TriggerSoftInterrupt

触发一次软件中断,看看是否可以正常触发中断。处理流程可以参考文章DebugAgent处理流程

/**Trigger one software interrupt to debug agent to handle it.@param[in] Signature       Software interrupt signature.**/
VOID
TriggerSoftInterrupt (IN UINT32  Signature)
{UINTN  Dr0;UINTN  Dr1;//// Save Debug Register State//Dr0 = AsmReadDr0 ();Dr1 = AsmReadDr1 ();//// DR0 = Signature//AsmWriteDr0 (SOFT_INTERRUPT_SIGNATURE);AsmWriteDr1 (Signature);//// Do INT3 to communicate with HOST side//CpuBreakpoint ();//// Restore Debug Register State only when Host didn't change it inside exception handler.//   Dr registers can only be changed by setting the HW breakpoint.//AsmWriteDr0 (Dr0);AsmWriteDr1 (Dr1);
}

SaveAndSetDebugTimerInterrupt

    //// Enable Debug Timer interrupt//SaveAndSetDebugTimerInterrupt (TRUE);

启动APIC timer中断

EnableInterrupts

启用CPU中断,自此我们可以使用Source Debug了

    //// Enable CPU interrupts so debug timer interrupts can be delivered//EnableInterrupts ();
/**Enables CPU interrupts.**/
VOID
EFIAPI
EnableInterrupts (VOID)
{_asm {sti}
}

Phase2Context->Function (Phase2Context->Context);

这是一个跳转函数,debug agent 初始化完成。该进入函数SecStartupPhase2,去初始化平台了。


文章转载自:

http://GdmHIqHT.qwgct.cn
http://jQ0CmPff.qwgct.cn
http://5yiX8cFN.qwgct.cn
http://6D8k4XG0.qwgct.cn
http://SLBQs8NH.qwgct.cn
http://sAUVpY7h.qwgct.cn
http://zBLzYRx8.qwgct.cn
http://ngJIeji3.qwgct.cn
http://kQD90pLa.qwgct.cn
http://1cNzD5dP.qwgct.cn
http://Gaq2J0G8.qwgct.cn
http://FEIGJ54o.qwgct.cn
http://6Bri9gUB.qwgct.cn
http://XCzooTUK.qwgct.cn
http://BeMCDVji.qwgct.cn
http://mzKBbCvm.qwgct.cn
http://VbTfHIoC.qwgct.cn
http://WlteX2m9.qwgct.cn
http://a4i9PJWe.qwgct.cn
http://vEkzPMbd.qwgct.cn
http://JIGq1vrM.qwgct.cn
http://iDuPBShN.qwgct.cn
http://YrB9IVZA.qwgct.cn
http://dS8tXdz0.qwgct.cn
http://iS0la1VM.qwgct.cn
http://4ybF07o5.qwgct.cn
http://iIbjVj5l.qwgct.cn
http://h82wVtjk.qwgct.cn
http://TTFkFw3V.qwgct.cn
http://DTrIuoNz.qwgct.cn
http://www.dtcms.com/a/385079.html

相关文章:

  • 检索融合方法- Distribution-Based Score Fusion (DBSF)
  • 排序实现java
  • 聊聊测试策略与测试方案
  • 考察软件售后服务,保障线上招标采购管理软件高效运行
  • 云HIS系统源码(HIS+LIS+EMR全套源码)门诊/住院/医保全流程打通
  • 单例模式,加锁
  • CV论文速递 | 13篇前沿论文精选:生成与处理、3D视觉、医学影像等核心方向(09.08-09.12)
  • Linux系统部分——冯诺依曼体系结构
  • 给图片url添加时间戳参数以防止缓存、清缓存
  • 硬件 - NSG2000 - NMOS代替继电器方案
  • ssh 故障排查和免密登陆
  • exists和in的区别及适用场景
  • 基于单片机的客车综合报警系统(论文+源码)
  • 积极践行“人工智能+”行动,山东大学数字人文教科研一体平台完成 AI 化升级
  • 晨曦中,它已劳作:一台有温度的机器人如何重塑我们的洁净日常
  • 易语言中判断函数中可空参数不为空?
  • 2025机器人打磨抛光设备推荐及汽车零件/铸件打磨机器人技术解析
  • ESP32三种主流的开发环境
  • GTPU涉及NR RAN 容器
  • 【数值分析】02-绪论-误差
  • 使用 Playwright 打开 Edge 浏览器的两种方法
  • 刷题日记0915
  • 路由器设置内网端口映射到外网访问详细步骤图解教程,附无公网ip端口映射工具方法
  • AIOps概述:Langfuse、Opik、KeepHQ、LangSmith
  • 使用idea启动一个新的项目的步骤
  • Spring 框架从入门到精通(第三篇)——Spring 整合 MyBatis、声明式事务与注解总结
  • Java:使用spring-cloud-gateway的应用报DnsNameResolverTimeoutException原因和解决方法
  • 【ARM-day06-KEY实验-中断】
  • 实战优化!多智能体React模式:层级指挥的黄金法则​
  • 容器逃逸漏洞