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

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

参考:

http://www.cnnetsun.cn/news/132011.html

相关文章:

  • 水利工程前沿国际期刊精选
  • 25 万亿美元超级风口下,中国智造如何执掌机器人时代
  • 【游戏AI突破性进展】:基于GNN的群体Agent协同决策模型实战解析
  • 中国汽车、无人机、机器人行业近十年
  • 【强烈推荐】大模型微调实战指南:从LLaMA Factory到Ollama,打造你的专属模型
  • 激光雷达与摄像头不同步?深度解析多传感器时间同步校准难题
  • UE5卡通渲染革命:MooaToon带你实现电影级三渲二效果
  • 如何快速掌握Stable Diffusion WebUI Forge:面向用户的完整教程
  • 17、网络基础与操作指南
  • 元宇宙中的智能体交互难题:90%开发者忽略的延迟一致性陷阱
  • Unity内置着色器完整使用指南:从入门到精通
  • MCP与Azure量子协同容错设计,揭开企业级量子应用稳定性的秘密
  • 当JS拷贝玩起了“俄罗斯套娃”:深拷贝与浅拷贝的趣味对决
  • 北京创业省钱攻略!0 元注册公司不是梦
  • 行业标杆 | 越秀地产入选「2025年度数据湖仓应用创新先锋企业」
  • 云边 Agent 延迟优化全攻略(99%工程师忽略的底层机制曝光)
  • 【物流运输Agent路线优化】:揭秘智能路径调整背后的算法黑科技
  • 终于搞懂了!React Agent的实现思路原来这么简单,核心就这3步!
  • FLORIS风电场仿真终极指南:10个核心技巧快速掌握工程尾流模型
  • 工业HMI常见故障及排查方法:黑屏、通信中断、操作无响应,新手别慌
  • 55页PDF信息系统项目管理师考神笔记
  • 工业HMI的发展趋势:智能化、一体化、移动化,新手该怎么跟上?
  • 【高频卫星信号处理突破】:3步实现Agent端低延迟响应
  • 联想拯救者BIOS隐藏功能一键解锁:3分钟搞定高级设置终极教程
  • 从功能测试到自动化转型:测试工程师的进阶之路
  • 测试与开发的协同工作模式:从对立到共生的范式演进
  • VCAM安卓虚拟相机:打造你的专属视频魔法师
  • 抢占本地生活服务市场 开源可定制的跑腿平台源码推荐
  • 【物流量子 Agent 成本优化】:揭秘降低运营开支的5大核心技术策略
  • 企业微信Webhook Java SDK:从零构建智能消息推送系统