StuBS
InterruptContext Struct Reference

Preserved interrupt context. More...

#include <handler.h>

Public Attributes

uintptr_t eax
 scratch register EAX
 
uintptr_t ecx
 scratch register ECX
 
uintptr_t edx
 scratch register EDX
 
uintptr_t error_code
 Error Code.
 
uintptr_t ip
 Instruction Pointer (at interrupt)
 
uintptr_t cs: 16
 Code segment (in case of a ring switch it is the segment of the user mode)
 
uintptr_t __pad0__: 0
 Alignment (due to 16 bit code segment)
 
uintptr_t flags
 Status flags register.
 
uintptr_t sp
 Stack pointer (at interrupt)
 
uintptr_t ss: 16
 Stack segment (in case of a ring switch it is the segment of the user mode)
 
uintptr_t __pad1__: 0
 Alignment (due to 16 bit stack segment)
 

Detailed Description

Preserved interrupt context.

After an interrupt was triggered, the core first saves the basic context (current code- & stack segment, instruction & stack pointer and the status flags register) and looks up the handling function for the vector using the IDT. In StuBS for each vector an own interrupt_entry_VECTOR function (written in assembly in interrupt/handler.asm) was registered during boot by kernel_init(), which all save the scratch registers on the stack before calling the C++ function interrupt_handler(). The high-level handler gets a pointer to the part of the stack which corresponds to the InterruptContext structure as second parameter. After returning from the high-level handler, the previous state is restored from this context (scratch register in assembly and basic context while executing iret) so it can continue transparently at the previous position.


The documentation for this struct was generated from the following file: