Software interruption

How can I program interruption software in C? I know that I need to write an interrupt service routine and then interrupt the processor so that the subroutine can be called, but I do not know how to do this in C. In addition, I do not know how to register this procedure with the interrupt descriptor Table. I have an x86-64 processor (AMD Turion64 X2) and I use the gcc compiler. Any help would be appreciated.

+5
source share
4 answers

The concept of interrupts is not included in the C specification (and is also processor specific). Most compilers, including GCC, allow you to write embedded assembly code (or you can, of course, link the file written in the assembly to your program). But the big problem is that ordinary operating systems (especially those that work in 64-bit mode) will not allow you to change the interrupt table. I think your best bet is to look for a simple open source OS and either install an interrupt handler from a regular program (if the OS allows it) or add code to the kernel. The reason you cannot just run a small piece of code in a processor simulator (or virtual machine) is because the processor needs quite a bit of configuration to work in 64-bit mode. And the exact datahow you modify the interrupt table depends on this setting.

+3

. , , (ring 0?)

+1

ISR - . , C.

, , ISR GIC . Linux ARM.. request_irq() ISR IRQ IRQ_DESC.

, ISR .

0

sigaction. . man 2 sigaction.

, raise kill.

-1

All Articles