news 2026/6/10 19:13:41

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/6/10 13:53:32

终极指南:如何用DankDroneDownloader掌控你的大疆无人机固件

终极指南&#xff1a;如何用DankDroneDownloader掌控你的大疆无人机固件 【免费下载链接】DankDroneDownloader A Custom Firmware Download Tool for DJI Drones Written in C# 项目地址: https://gitcode.com/gh_mirrors/da/DankDroneDownloader 你是否曾经因为找不到…

作者头像 李华
网站建设 2026/6/10 13:57:29

Draw.io电子工程绘图库:5分钟学会专业电路设计

Draw.io电子工程绘图库&#xff1a;5分钟学会专业电路设计 【免费下载链接】Draw-io-ECE Custom-made draw.io-shapes - in the form of an importable library - for drawing circuits and conceptual drawings in draw.io. 项目地址: https://gitcode.com/gh_mirrors/dr/Dr…

作者头像 李华
网站建设 2026/6/9 19:42:57

软工毕设2026选题集合

文章目录&#x1f6a9; 1 前言1.1 选题注意事项1.1.1 难度怎么把控&#xff1f;1.1.2 题目名称怎么取&#xff1f;1.2 选题推荐1.2.1 起因1.2.2 核心- 如何避坑(重中之重)1.2.3 怎么办呢&#xff1f;&#x1f6a9;2 选题概览&#x1f6a9; 3 项目概览题目1 : 深度学习社交距离检…

作者头像 李华
网站建设 2026/6/9 20:49:02

NX二次开发 动态调用内部函数以启动宏为例

UF_initialize();// API调用UG的宏typedef void(*load_ufusr_f_p_t)(char* param, int* retcode, int paramLen);load_ufusr_f_p_t load_ufusr_ptr NULL;char* file_path "C:\\Program Files\\Siemens\\NX2212\\NXBIN\\libugui.dll";UF_load_library(file_path, &q…

作者头像 李华
网站建设 2026/6/10 14:13:59

【高精度气象预测实现路径】:基于Agent的多源数据融合与实时校准技术

第一章&#xff1a;气象 Agent 的预测精度在现代智能系统中&#xff0c;气象 Agent 作为环境感知与决策支持的核心组件&#xff0c;其预测精度直接影响到交通调度、农业管理及灾害预警等多个关键领域。高精度的气象预测依赖于高质量的数据输入、先进的算法模型以及实时反馈机制…

作者头像 李华