键盘中断
我正在研究低级设备驱动程序的东西。我对中断和 IRQ 感到困惑。挂钩键盘的示例驱动程序代码表明键盘中断是 0x31,但我关于微处理器的书说它是 0x09。打开“设备管理器 -> 键盘 -> 资源”时,显示 IRQ 为 1。有人能澄清一下吗?
谢谢, 桑吉耶夫
I am studying low-level device driver stuff. I am confused between interrupts and IRQ. A sample driver code that hooks keyboard suggests keyboard interrupt is 0x31 but my book on microprocessor says it is 0x09. On opening 'Device Manager->Keyboards->Resources', it shows IRQ is 1. Can anyone clarify this?
Thanks,
Sanjeev
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
是这样的。在您的计算机中,有一个称为 (A)PIC 的单元。该单元从某些外围设备(例如 PS2 键盘)获取输入,并在 CPU 上引发中断。现代系统中有两个 APIC。一个称为主设备,另一个称为从设备,每个设备都有 8 条 IRQ 线。当您按下键盘上的按键时,APIC 在线路 1 (IRQ 1) 上收到一个信号,然后导致 CPU 上发生中断。
APIC 可以进行编程,因此即使它在第 1 行收到信号,也不会在 CPU 上引发中断 9(尽管奇怪的是,如果您不对其进行编程,这实际上是默认设置),因为这会与某些 CPU 内部发生冲突中断,因此您通常将其编程到其他地方。在你的情况下,它似乎将其转换为中断 0x31,这听起来可能是正确的(它添加了 IRQ + 0x30)。
我强烈不相信它被映射到中断 9,因为这会与处理器的双故障异常中断冲突,本书可能只提到默认设置。
It's like this. In your computer you have a unit called the (A)PIC. This unit takes input from some of your perpipheral devices, like the PS2 keyboard, and raises an interrupt on the CPU. In a modern system there are two APICs. One is called the primary and the other one is called the slave and each hold 8 IRQ lines. When you press a key on the keyboard the APIC gets a signal on line 1 (IRQ 1) which then causes an interrupt to occur on the CPU.
The APIC can be programmed so even if it recieves a signal on line 1 it will not raise interrupt 9 on the CPU (even though weirdly this actually is the default if you do not program it) because that would conflict with some of the CPUs internal interrupts so you usually program it to go somewhere else. In your case it seems like it translates it to interrupt 0x31 which sounds like it could be correct (it adds IRQ + 0x30).
I strongly don't believe it is mapped to interrupt 9 because that would conflict with the Double Fault exception interrupt for the processor, the book probably just mention the default setting.
简单的答案是IRQ(中断请求)是由系统映射到中断的硬件输入。对于键盘,IRQ1 映射到中断 9。
令人高兴的答案是,在这种情况下,中断 31h 显然是一个错误或拼写错误。
中断请求
The simple answer is that an IRQ (Interrupt ReQuest) is a hardware input which is mapped by the system to an interrupt. In the case of the keyboard IRQ1 is mapped to interrupt 9.
The happy answer is that interrupt 31h in this context is obviously an error or typo.
Interrupt request