news 2026/9/5 3:30:17

HalEndSystemInterrupt为什么能调用KiDispatchInterrupt因为HalRequestSoftwareInterrupt设置PCR[PcHal.DpcPending]为1

作者头像

张小明

前端开发工程师

1.2k 24
文章封面图
HalEndSystemInterrupt为什么能调用KiDispatchInterrupt因为HalRequestSoftwareInterrupt设置PCR[PcHal.DpcPending]为1

hal!HalEndSystemInterrupt函数为什么能调用nt!KiDispatchInterrupt函数因为hal!HalRequestSoftwareInterrupt最后设置PCR[PcHal.DpcPending]为1

第一部分:

HeiNewIrql equ [esp + 4]
HeiVector equ [esp + 8]

cPublicProc _HalEndSystemInterrupt ,2
cPublicFpo 2, 0
xor ecx,ecx
mov cl, byte ptr HeiNewIrql ; get new IRQL
mov cl, _HalpIRQLtoTPR[ecx] ; get corresponding TPR value

mov dword ptr APIC[LU_EOI], 0 ; send EOI to APIC local unit
APICFIX edx

cmp cl, DPC_VECTOR ; Is new irql < DPC?
jc short es10 ; Yes, go check for pending DPC

es05: mov dword ptr APIC[LU_TPR], ecx ; Set new Priority

;
; We have to ensure that the requested priority is set before
; we return. The caller is counting on it.
;
mov edx, dword ptr APIC[LU_TPR]
CHECKTPR ecx, edx
stdRET _HalEndSystemInterrupt

es10: cmp PCR[PcHal.DpcPending], 0 ; Is a DPC pending?
mov PCR[PcHal.ShortDpc], 0 ; Clear short dpc flag
jz short es05 ; No, eoi

mov dword ptr APIC[LU_TPR], DPC_VECTOR ; lower to DPC level
APICFIX edx

push ebx ; Save EBX (used by KiDispatchInterrupt)
push ecx ; Save OldIrql
cPublicFpo 2, 2

sti

es20: mov PCR[PcHal.DpcPending], 0 ; Clear pending flag

stdCall _KiDispatchInterrupt ; Dispatch interrupt //这里调用了_KiDispatchInterrupt

cli

pop ecx
pop ebx
jmp short es05

stdENDP _HalEndSystemInterrupt

第二部分:

F:\srv03rtm>grep "DpcPending" -nr F:\srv03rtm\base\hals |grep -v "inary"
F:\srv03rtm\base\hals/halmps/i386/mpswint.asm:132:; DpcPending flag - whomever set ShortDpc will check the flag
F:\srv03rtm\base\hals/halmps/i386/mpswint.asm:136:rsi10: mov PCR[PcHal.DpcPending], 1
F:\srv03rtm\base\hals/halmps/i386/mpsysint.asm:121:es10: cmp PCR[PcHal.DpcPending], 0 ; Is a DPC pending?
F:\srv03rtm\base\hals/halmps/i386/mpsysint.asm:134:es20: mov PCR[PcHal.DpcPending], 0 ; Clear pending flag

参考:

cPublicFastCall HalRequestSoftwareInterrupt ,1
cPublicFpo 0,0

cmp cl, PCR[PcHal.ShortDpc]
je short rsi10

xor eax, eax
mov al, cl ; get irql

;
; In an APIC based system the TPR is the IDTEntry
;

xor ecx, ecx
mov cl, _HalpIRQLtoTPR[eax] ; get IDTEntry for IRQL

;
; Build the ICR Command - Fixed Delivery to Self, IDTEntry == al
;

or ecx, (DELIVER_FIXED OR ICR_SELF)

;
; Make sure the ICR is available
;

pushfd ; save interrupt mode
cli ; disable interrupt
STALL_WHILE_APIC_BUSY

;
; Now write the command to the Memory Mapped Register
;

mov dword ptr APIC[LU_INT_CMD_LOW], ecx

;
; We have to wait for the request to be delivered.
; If we don't wait here, then we will return to the caller
; before the request has been issued.
;
STALL_WHILE_APIC_BUSY

popfd ; restore original interrupt mode
fstRET HalRequestSoftwareInterrupt

;
; Requesting a DPC interrupt when ShortDpc is set. Just set the
; DpcPending flag - whomever set ShortDpc will check the flag
; at the proper time
;

rsi10: mov PCR[PcHal.DpcPending], 1这里!!!
fstRET HalRequestSoftwareInterrupt

参考:

版权声明: 本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!
网站建设 2026/9/4 19:14:20

水利工程前沿国际期刊精选

期刊名称: 当代水电科技ISSN印刷版: 3060-8767研究领域: 工程技术 水利工程 电力能源 出版模式: 开放获取&#xff08;OA&#xff09;出版周期: 2-3个月出刊检索版面要求: 5000字符/3版期刊收录: 知网CNKI 出版社: 新加坡✥聚知刊期刊名称: 水电水利ISSN印刷版: 2529-782…

作者头像 李华
网站建设 2026/9/5 2:04:48

25 万亿美元超级风口下,中国智造如何执掌机器人时代

当摩根士丹利在《机器人年鉴》中抛出 “2050 年全球机器人硬件销售额将达 25 万亿美元” 的预测时&#xff0c;一个足以重塑全球产业格局的超级风口已然成型。从 2025 年的约 1000 亿美元到 25 万亿美元的指数级跨越&#xff0c;不仅意味着机器人将从工业车间、物流仓库走向千家…

作者头像 李华
网站建设 2026/9/4 20:10:05

【游戏AI突破性进展】:基于GNN的群体Agent协同决策模型实战解析

第一章&#xff1a;游戏 AI Agent 的行为决策 在现代电子游戏中&#xff0c;AI Agent 的行为决策是实现智能角色互动的核心机制。一个高效的行为决策系统能够让非玩家角色&#xff08;NPC&#xff09;根据环境状态、玩家行为和任务目标做出合理反应&#xff0c;从而提升游戏的沉…

作者头像 李华
网站建设 2026/9/5 14:16:57

中国汽车、无人机、机器人行业近十年

中国汽车、无人机、机器人行业近十年(2015-2025)发展复盘与2030年全景预测 一、核心基础数据:人口与技术双轮驱动,三大行业协同扩容 近十年,中国机动车驾照量、汽车保有量的持续增长与低空经济、智能制造政策的密集落地,共同构成三大行业发展的核心支撑。人口结构变化(…

作者头像 李华
网站建设 2026/9/4 14:06:29

激光雷达与摄像头不同步?深度解析多传感器时间同步校准难题

第一章&#xff1a;自动驾驶传感器Agent校准的挑战与意义在自动驾驶系统中&#xff0c;传感器Agent&#xff08;如激光雷达、摄像头、毫米波雷达等&#xff09;是环境感知的核心组件。这些传感器需高度协同工作&#xff0c;以提供准确、一致的环境数据。然而&#xff0c;由于制…

作者头像 李华