简体   繁体   English

如何在 Linux 上获取中断向量号?

[英]How do I get the interrupt vector number on Linux?

When I run "cat /proc/interrupts", I can get the following:当我运行“cat /proc/interrupts”时,我可以得到以下信息:

           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

How can I get the interrupt number of "NMI" "LOC" "SPU" "PMI", etc.如何获取“NMI”“LOC”“SPU”“PMI”等中断号

On x86 NMIs are always on interrupt vector 2. The number is hard-coded just as common exceptions (division by 0, page fault, etc).在 x86 上, NMIs始终位于中断向量 2 上。该数字与常见异常(除以 0、页面错误等)一样是硬编码的。 You can find this in the CPU documentation from Intel/AMD.您可以在 Intel/AMD 的 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.如果APIC已启用(如问题中提供的转储中的情况),则可以从 APIC 的SVR寄存器中获取虚假中断的中断向量编号。 Again, see the same CPU documentation on that.同样,请参阅相同的 CPU 文档。

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).如果未启用APIC而是使用PIC ,则虚假中断将作为IRQ7 (请参阅8259A PIC 芯片规范)。 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. BIOS以 IRQ7 为中断向量0Fh的方式对 PIC 进行编程,但 Windows 和 Linux 更改此映射以避免共享相同的 IRQ 和 CPU 异常中断向量。 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.似乎无法从 PIC 查询此映射,但它是通过向 PIC 发送初始化控制字 2 ( ICW2 ) 来建立的。 Here's the relevant piece of Linux code in init_8259A() :这是init_8259A()的相关 Linux 代码:

    /* 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.那应该回答虚假中断向量部分。

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.至于LOCPMI ,我认为,这些是本地 APIC 的中断,您可以从 APIC 中找到它们的中断向量,就像上面的虚假中断一样。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM