键盘中断

发布于 2024-09-09 10:06:03 字数 150 浏览 11 评论 0原文

我正在研究低级设备驱动程序的东西。我对中断和 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

木森分化 2024-09-16 10:06:03

是这样的。在您的计算机中,有一个称为 (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.

不美如何 2024-09-16 10:06:03

简单的答案是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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文