IBNOS
|
Typedefs | |
typedef uint32_t(* | interrupt_callback) (uint32_t interrupt, uint32_t error, struct thread *t) |
Functions | |
uint32_t | dispatchInterrupt (uint32_t interrupt, uint32_t error, struct thread *t) |
Handle an incoming interrupt. More... | |
bool | interruptReserve (uint32_t interrupt, interrupt_callback callback) |
Request an interrupt. More... | |
void | interruptFree (uint32_t interrupt) |
Free a previously requested interrupt. More... | |
uint32_t | interrupt_0x0E (uint32_t interrupt, uint32_t error, struct thread *t) |
uint32_t | interrupt_0x07 (UNUSED uint32_t interrupt, UNUSED uint32_t error, struct thread *t) |
Coprocessor / FPU not available handler. More... | |
uint32_t | interrupt_0x10 (UNUSED uint32_t interrupt, UNUSED uint32_t error, struct thread *t) |
uint32_t | interrupt_0x80 (UNUSED uint32_t interrupt, UNUSED uint32_t error, struct thread *t) |
Interrupt which handles Syscalls. More... | |
Interrupt return values | |
#define | INTERRUPT_UNHANDLED 0 |
#define | INTERRUPT_CONTINUE_EXECUTION 1 |
#define | INTERRUPT_YIELD 2 |
#define | INTERRUPT_EXIT_THREAD 3 |
#define | INTERRUPT_EXIT_PROCESS 4 |
Interrupts are used for several purposes on x86 machines.
The first purpose is to handle software errors. When a program does something which is not allowed, like accessing an invalid memory address, or something impossible like a division by zero, an Interrupt is triggered.
The CPU looks up an entry in the interrupt descriptor table (IDT), which is defined by the OS, and then calls a function (or does a task switch depending on the flags defined inside the interrupt table).
Interrupts can also be invoked by hardware, to notify the CPU about new data like a pressed key on the keyboard. These interrupts are called IRQs and can be controlled through the Programmable Interrupt Controller.
The third way to invoke an interrupt is by using the INT opcode inside a program. This allows a programs to communicate with the kernel. In IBNOS the interrupt 0x80 is used to implement syscalls.
For more information about Interrupts and IRQs take a look at http://wiki.osdev.org/Interrupts
#define INTERRUPT_CONTINUE_EXECUTION 1 |
The interrupt was handled, continue execution
Definition at line 48 of file interrupt.h.
#define INTERRUPT_EXIT_PROCESS 4 |
Exit the current process
Definition at line 54 of file interrupt.h.
#define INTERRUPT_EXIT_THREAD 3 |
Exit the current thread
Definition at line 52 of file interrupt.h.
#define INTERRUPT_UNHANDLED 0 |
The interrupt could not be handled -> system failure / abort process
Definition at line 46 of file interrupt.h.
#define INTERRUPT_YIELD 2 |
Continue with a different task
Definition at line 50 of file interrupt.h.
typedef uint32_t(* interrupt_callback) (uint32_t interrupt, uint32_t error, struct thread *t) |
Definition at line 59 of file interrupt.h.
uint32_t dispatchInterrupt | ( | uint32_t | interrupt, |
uint32_t | error, | ||
struct thread * | t | ||
) |
Handle an incoming interrupt.
This function handles an incoming interrupt and executes a registered interrupt handler (if any).
interrupt | The interrupt which should be handled |
error | An optional error code passed by the CPU |
t | The currently running thread or NULL for kernel interrupts |
Definition at line 83 of file interrupt.c.
Coprocessor / FPU not available handler.
We use hardware task switches which do not automatically save the values of the FPU. The CPU automatically protects the FPU and raises an exception if the FPU is used for the first time after a task switch. This handler saves the content of the FPU to the last task which used the FPU so that the current task can safely alter the content.
interrupt | Always 0x07 |
error | Does not apply to this interrupt |
t | The thread which tried to use the FPU |
Definition at line 123 of file interrupt.c.
uint32_t interrupt_0x0E | ( | uint32_t | interrupt, |
uint32_t | error, | ||
struct thread * | t | ||
) |
Definition at line 153 of file interrupt.c.
Interrupt which handles Syscalls.
This function is called when a user mode program calls the interrupt 0x80. This interrupt is used to handle Syscalls and gives the user mode program the possibility to execute predefined functions in the kernel.
interrupt | Always 0x80 |
error | Does not apply to this interrupt |
t | The thread which called the syscall |
Definition at line 198 of file interrupt.c.
void interruptFree | ( | uint32_t | interrupt | ) |
Free a previously requested interrupt.
interrupt | The previously requested interrupt |
Definition at line 742 of file interrupt.c.
bool interruptReserve | ( | uint32_t | interrupt, |
interrupt_callback | callback | ||
) |
Request an interrupt.
interrupt | The interrupt you need |
callback | The function which should be called when the interrupt occurs. |
Definition at line 727 of file interrupt.c.