如何在Linux上获得中断向量号? [英] How do I get the interrupt vector number on Linux?

查看:741
本文介绍了如何在Linux上获得中断向量号?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我运行"cat/proc/interrupts"时,我可以得到以下信息:

When I run "cat /proc/interrupts", I can get the following:

           CPU0       CPU1
  0:        253       1878   IO-APIC-edge      timer
  1:          3          0   IO-APIC-edge      i8042
  7:          1          0   IO-APIC-edge      parport0
  8:          0          1   IO-APIC-edge      rtc0
  9:          0          0   IO-APIC-fasteoi   acpi
 12:          1          3   IO-APIC-edge      i8042
 16:     681584         60   IO-APIC-fasteoi   uhci_hcd:usb3, nvidia
 17:          0          0   IO-APIC-fasteoi   uhci_hcd:usb4, uhci_hcd:usb7
 18:          0          0   IO-APIC-fasteoi   uhci_hcd:usb8
 22:          2          1   IO-APIC-fasteoi   ehci_hcd:usb1, uhci_hcd:usb5
 23:         17         17   IO-APIC-fasteoi   ehci_hcd:usb2, uhci_hcd:usb6
 44:     146232     472747   PCI-MSI-edge      ahci
 45:        118        115   PCI-MSI-edge      snd_hda_intel
 46:   10038650        842   PCI-MSI-edge      eth1
NMI:      44479      43798   Non-maskable interrupts
LOC:   19025635   29426776   Local timer interrupts
SPU:          0          0   Spurious interrupts
PMI:      44479      43798   Performance monitoring interrupts
IWI:          0          0   IRQ work interrupts
RES: 3442001789 3442627214   Rescheduling interrupts
CAL:       1406       1438   Function call interrupts
TLB:     781318     792403   TLB shootdowns
TRM:          0          0   Thermal event interrupts
THR:          0          0   Threshold APIC interrupts
MCE:          0          0   Machine check exceptions
MCP:       2063       2063   Machine check polls
ERR:          0
MIS:          0

如何获取"NMI","LOC","SPU","PMI"等的中断号.

How can I get the interrupt number of "NMI" "LOC" "SPU" "PMI", etc.

推荐答案

在x86 NMIs上始终位于中断向量2上.该数字与常见异常一样硬编码(除以0,页面错误等).您可以在Intel/AMD的CPU文档中找到它.

On x86 NMIs are always on interrupt vector 2. The number is hard-coded just as common exceptions (division by 0, page fault, etc). You can find this in the CPU documentation from Intel/AMD.

如果启用了APIC(就像问题中介绍的转储一样),则可以从APIC的SVR寄存器中获得虚假中断"的中断向量号.再次,请参见相同的CPU文档.

If the APIC is enabled (as is the case in the dump presented in the question), Spurious Interrupt's interrupt vector number can be obtained from APIC's SVR register. Again, see the same CPU documentation on that.

如果未启用APIC而使用了PIC,则杂散中断将作为IRQ7传递(有关此信息,请参见8259A PIC芯片规格). BIOS以使IRQ7为中断向量0Fh的方式对PIC进行编程,但是Windows和Linux更改了此映射,以避免为IRQ和CPU异常共享相同的中断向量.似乎无法从PIC查询此映射,而是通过将初始化控制字2(ICW2)发送到PIC来建立的.这是 init_8259A() 中的相关Linux代码:

If the APIC isn't enabled and instead the PIC is being used, then Spurious Interrupts are delivered as IRQ7 (see the 8259A PIC chip spec for that). The BIOS programs the PIC in such a way that IRQ7 is interrupt vector 0Fh, but Windows and Linux change this mapping to avoid sharing the same interrupt vectors for IRQs and CPU exceptions. It seems like this mapping can't be queried from the PIC, but it's established via sending the Initialization Control Word 2 (ICW2) to the PIC. Here's the relevant piece of Linux code in init_8259A():

    /* ICW2: 8259A-1 IR0-7 mapped to 0x30-0x37 on x86-64,
       to 0x20-0x27 on i386 */
    outb_pic(IRQ0_VECTOR, PIC_MASTER_IMR);

这应该回答虚假中断"向量部分.

That should answer the Spurious Interrupt vector part.

对于LOCPMI,我认为它们是本地APIC的中断,您可以从APIC中找到它们的中断向量,就像上面的虚假中断"一样.

As for LOC and PMI, I think, these are local APIC's interrupts and you can find their interrupt vectors from the APIC just like with the Spurious Interrupt above.

这篇关于如何在Linux上获得中断向量号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆