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

KiRequestDispatchInterrupt宏定义和nt!KiIpiServiceRoutine函数到hal!HalRequestSoftwareInterrupt

KiRequestDispatchInterrupt宏定义和nt!KiIpiServiceRoutine函数到hal!HalRequestSoftwareInterrupt


#define KiRequestDispatchInterrupt(Processor) \
if (KeGetCurrentProcessorNumber() != Processor) { \
KiIpiSend(AFFINITY_MASK(Processor), IPI_DPC); \
}


相应的:
#define KiRequestApcInterrupt(Processor) \
if (KeGetCurrentProcessorNumber() == Processor) { \
KiRequestSoftwareInterrupt(APC_LEVEL); \
} else { \
KiIpiSend(AFFINITY_MASK(Processor), IPI_APC); \
}
相应的:

VOID
KiIpiSend (
IN KAFFINITY TargetSet,
IN KIPI_REQUEST Request
)
{

#if !defined(NT_UP)

PKPRCB NextPrcb;
ULONG Processor;
KAFFINITY SummarySet;

ASSERT(KeGetCurrentIrql() >= DISPATCH_LEVEL);

//
// Loop through the target set of processors and merge the request into
// the request summary of the target processors.
//
// N.B. It is guaranteed that there is at least one bit set in the target
// set.
//

ASSERT(TargetSet != 0);

SummarySet = TargetSet;
BitScanForward64(&Processor, SummarySet);
do {
NextPrcb = KiProcessorBlock[Processor];
InterlockedOr64((LONG64 volatile *)&NextPrcb->RequestSummary, Request);
SummarySet ^= AFFINITY_MASK(Processor);
} while (BitScanForward64(&Processor, SummarySet) != FALSE);

//
// Request interprocessor interrupts on the target set of processors.
//

HalRequestIpi(TargetSet);

#else

UNREFERENCED_PARAMETER(TargetSet);
UNREFERENCED_PARAMETER(Request);

#endif

return;
}


VOID
HalRequestIpi (
IN KAFFINITY Affinity
)
{

ULONG flags;
KAFFINITY Self;

//
// If the target set of processors is the complete set of processors,
// then use the broadcast capability of the APIC. Otherwise, send the
// IPI to the individual processors.
//

Self = KeGetCurrentPrcb()->SetMember;
if ((Affinity | Self) == HalpActiveProcessors) {
flags = HalpDisableInterrupts();
HalpStallWhileApicBusy();
if ((Affinity & Self) != 0) {
LOCAL_APIC(LU_INT_CMD_LOW) = APIC_BROADCAST_INCL;

} else {
LOCAL_APIC(LU_INT_CMD_LOW) = APIC_BROADCAST_EXCL;
}

HalpStallWhileApicBusy();
HalpRestoreInterrupts(flags);

} else {
HalpSendIpi(Affinity, APIC_IPI);
}

return;
}

VOID
FASTCALL
HalpSendIpi (
IN KAFFINITY Affinity,
IN ULONG Command
)
{
ULONG flags;

//
// Disable interrupts and call the appropriate routine.
//
// BUGBUG the compiler generates terrible code for this,
// most likely because of the inline _asm{} block generated
// by HalpDisableInterrupts().
//
// Ideally we could talk the x86 compiler team into giving
// us an intrinsic like the AMD64 compiler's __getcallerseflags()
//

flags = HalpDisableInterrupts();
HalpIpiRoutine(Affinity,Command);
HalpRestoreInterrupts(flags);
}

0: kd> g
Breakpoint 16 hit
eax=00000001 ebx=00000102 ecx=00000002 edx=00000000 esi=f7737120 edi=00000000
eip=804ee4f8 esp=f78e6ca0 ebp=f78e6cc4 iopl=0 nv up ei pl nz na po nc
cs=0008 ss=0010 ds=0023 es=0023 fs=0030 gs=0000 efl=00000202
hal!HalRequestSoftwareInterrupt:
804ee4f8 643a0d95000000 cmp cl,byte ptr fs:[95h] fs:0030:00000095=00
1: kd> kc 2
#
00 hal!HalRequestSoftwareInterrupt
01 nt!KiIpiServiceRoutine


cPublicProc _KiIpiServiceRoutine, 2

ifndef NT_UP

cPublicFpo 2, 3
push ebx ; save nonvolatile registers
push esi ;
push edi ;

xor ebx, ebx ; set exchange value
xor edi, edi
mov esi, PCR[PcPrcb] ; get current processor block address

xchg dword ptr [esi].PbRequestSummary, ebx
xchg dword ptr [esi].PbSignalDone, edi
;
; Check for freeze request or synchronous request.
;

test bl, IPI_FREEZE + IPI_SYNCH_REQUEST ; test for freeze or packet
jnz short isr50 ; if nz, freeze or synch request

;
; For RequestSummary's other then IPI_FREEZE set return to TRUE
;

mov bh, 1 ; set return value

;
; Check for Packet ready.
;
; If a packet is ready, then get the address of the requested function
; and call the function passing the address of the packet address as a
; parameter.
;

isr10: mov edx, edi ; copy request pack address
and edx, NOT 1 ; Clear point to point bit
jz short isr20 ; if z set, no packet ready
push [edx].PbCurrentPacket + 8 ; push parameters on stack
push [edx].PbCurrentPacket + 4 ;
push [edx].PbCurrentPacket + 0 ;
push edi ; push source processor block address
mov eax, [edx].PbWorkerRoutine ; get worker routine address
mov edx, [esp + 16 + 4*4] ; get current trap frame address
mov [esi].PbIpiFrame, edx ; save current trap frame address
call eax ; call worker routine
mov bh, 1 ; set return value

;
; Check for APC interrupt request.
;

isr20: test bl, IPI_APC ; check if APC interrupt requested
jz short isr30 ; if z, APC interrupt not requested

mov ecx, APC_LEVEL ; request APC interrupt
fstCall HalRequestSoftwareInterrupt ;

;
; Check for DPC interrupt request.
;

isr30: test bl, IPI_DPC ; check if DPC interrupt requested
jz short isr40 ; if z, DPC interrupt not requested

mov ecx, DISPATCH_LEVEL ; request DPC interrupt
fstCall HalRequestSoftwareInterrupt ;

isr40: mov al, bh ; return status
pop edi ; restore nonvolatile registers
pop esi ;
pop ebx ;

stdRET _KiIpiServiceRoutine

http://www.rkmt.cn/news/127270.html

相关文章:

  • 括号匹配问题
  • (Open-AutoGLM性能优化秘籍):提升酒店数据抓取效率的7种方法
  • 回归测试策略与范围界定:构建可持续的软件质量防线‌
  • 2025-2026 北京继承律师服务品质排行榜推荐:实战案例验证与权威机构口碑名单 - 老周说教育
  • 【技术内幕】Open-AutoGLM如何实现毫秒级外卖订单生成?
  • Open-AutoGLM快递路径预测黑科技(基于时空图神经网络的大模型应用)
  • (最新)2025年有哪些免费降AI率工具?亲测2个靠谱平台,AI率降到15%以内! - 还在做实验的师兄
  • 使用toaster开源库实现警告toast样式
  • SSM校外实习管理平台6tu82(程序+源码+数据库+调试部署+开发环境)带论文文档1万字以上,文末可获取,系统界面在最后面
  • NMN如何选择?2025 NMN权威榜:抗衰力与成分透明度双维PK,十大品牌谁登顶? - 资讯焦点
  • 伺服驱动器中DSP与FPGA高效协同架构解析
  • ELK日志分析平台从零搭建到生产实践
  • 深圳到北京、天津、石家庄、唐山搬家公司排行榜,附搬家费用明细 - 物流人
  • android studio2025.2.2汉化重大bug(附解决方案)
  • 光伏板清关.轮胎反倾销清关.床垫清关.高尔夫球车清关 - 资讯焦点
  • 【Open-AutoGLM酒店比价实战】:揭秘AI驱动的实时价格监控系统核心技术
  • 禁止过分投入2:夏日大排档 /Love Too Easily 2 Summer Pocha Build.20586137(6.9G) 免安装中文版游戏资源分享及攻略教程
  • 【Open-AutoGLM外卖自动下单揭秘】:如何用AI模型实现全自动订餐?
  • 轮回修仙传 v1.0.11.27.1 免安装中文版下载及使用方法
  • 【Open-AutoGLM物流同步实战指南】:掌握高效信息同步的5大核心技术
  • 【TextIn大模型加速器 + 火山引擎】基于 TextIn 与火山引擎豆包大模型的智能文档解析工作流构建与实践
  • 从零撸个工业级 shared_ptr?我花了半个月,现在手把手教你!
  • 网络 游戏服务器该怎么维护?
  • C++为什么推荐使用 make_shared 而不是 new 构造 shared_ptr?
  • 2025宏观分享:各地经济目标深度拆解与区域分化全景
  • 从Reactor到网络库:10天打造生产级C++高性能网络库
  • AI也会三思而后答?揭秘Self-RAG智能检索术
  • 成都到广州、深圳、东莞、佛山搬家公司专业度排行榜,附搬家费用明细 - 物流人
  • stm32入门篇2 - 实践
  • 时代变迁下的中年职场危机:曾经的红利时代已逝,集体被淘汰的警钟为谁而鸣?