Interrupt Service Routines: Difference between revisions
Jump to navigation
Jump to search
[unchecked revision] | [unchecked revision] |
Content deleted Content added
m addcat x86 |
note that in long mode you need to use iretq rather than iret |
||
Line 7: | Line 7: | ||
For the system to know which interrupt service routine to call when a certain interrupt occurs, offsets to the ISRs are stored in the [[IDT|Interrupt Descriptor Table]] when you're in [[Protected mode]], or in the [[Interrupt Vector Table]] when you're in [[Real Mode]]. |
For the system to know which interrupt service routine to call when a certain interrupt occurs, offsets to the ISRs are stored in the [[IDT|Interrupt Descriptor Table]] when you're in [[Protected mode]], or in the [[Interrupt Vector Table]] when you're in [[Real Mode]]. |
||
An ISR is called directly by the CPU, and the protocol for calling an ISR differs from calling e.g. a C function. Most importantly, an ISR has to end with the <tt>iret</tt> opcode, whereas usual C functions end with <tt>ret</tt> or <tt>retf</tt>. The obvious but nevertheless wrong solution leads to one of the most "popular" triple-fault errors among OS programmers. |
An ISR is called directly by the CPU, and the protocol for calling an ISR differs from calling e.g. a C function. Most importantly, an ISR has to end with the <tt>iret</tt> opcode (or <tt>iretq</tt> in long mode—yes, even when using intel syntax), whereas usual C functions end with <tt>ret</tt> or <tt>retf</tt>. The obvious but nevertheless wrong solution leads to one of the most "popular" triple-fault errors among OS programmers. |
||
== The Problem == |
== The Problem == |