Interrupt Service Routine.
More...
|
#define | IS_EXCEPTION(intr) ((intr) <= 0x1F) |
| whether the given interrupt vector is an exception
|
|
#define | IS_IRQ(intr) ((intr) >= 0x20 && intr <= 0x2F) |
| whether the given interrupt vector is an IRQ
|
|
#define | IS_SYSCALL(intr) ((intr) == 0x30) |
| whether the given interrupt vector is the syscall
|
|
#define | ISR_EXCEPTION(ex) (0x00 + (ex)) |
| the interrupt vector for an exception
|
|
#define | ISR_IRQ(irq) (0x20 + (irq)) |
| the interrupt vector for an IRQ
|
|
#define | ISR_SYSCALL 0x30 |
| the interrupt vector for the syscall
|
|
|
static isr_handler_t | handlers [IDT_ENTRIES] = {0} |
| a table that associates interrupt vectors with handlers
|
|
static void * | syscalls [SYSCALL_NUMBER] = {0} |
| a table that associates syscall IDs with handlers
|
|
Interrupt Service Routine.
An ISR is responsible for handling IRQs, exceptions and syscalls. Here only one common ISR is used, isr_handle_interrupt. It dispatches interrupts to handlers (isr_handler_t) registered by isr_register_handler.
- See also
- isr_asm.S
-
http://www.lowlevel.eu/wiki/Teil_5_-_Interrupts
-
http://www.lowlevel.eu/wiki/ISR
-
http://wiki.osdev.org/Exceptions
typedef uint32_t(* isr_syscall_t) (uint32_t ebx, uint32_t ecx, uint32_t edx, uint32_t esi, uint32_t edi, cpu_state_t **cpu) |
Handles a specific syscall.
Is registered with isr_register_syscall(). Unused parameters may be omitted because isr_register_syscall() works with void*. The parameters' and return value's types may differ from uint32_t, as long as they are not larger than 4 bytes (e.g. structs).
- Parameters
-
ebx | the syscall's 1st parameter |
ecx | the syscall's 2nd parameter |
edx | the syscall's 3rd parameter |
esi | the syscall's 4th parameter |
edi | the syscall's 5th parameter |
cpu | A reference to the CPU state / stack pointer. (This is a pointer to a pointer, so we can switch tasks from within a syscall!) |
- Returns
- The syscall's return value. void is not allowed as type.
Definition at line 106 of file isr.h.
Dumps a CPU state.
The dump is logged.
- Parameters
-
Definition at line 123 of file isr.c.
uint8_t isr_enable_interrupts |
( |
uint8_t |
enable | ) |
|
Enables or disables interrupts.
Only acts if necessary.
- Parameters
-
enable | the new interrupt flag |
- Returns
- interrupt flag before calling isr_enable_interrupts()
Definition at line 42 of file isr.c.
uint8_t isr_get_interrupts |
( |
| ) |
|
Returns whether interrupts are enabled or disabled.
- Returns
- interrupt flag
Definition at line 55 of file isr.c.
Handles all interrupts.
This function is called whenever an interrupt is fired. It distinguishes which action to perform (call a handler, panic etc.) and, for IRQs, notifies the PIC that this interrupt has been handled.
- Parameters
-
cpu | cpu has two functions here - as a pointer (CPU state) and as a value (ESP):
cpu points to the CPU state and is the ESP pushed in isr_asm.S (the former stack pointer which points to the current task's CPU state, beginning with GS). |
- Returns
- The pointer returned by this function is a (possibly new) ESP if we want to switch tasks (then we need to make sure that ESP points to a valid CPU state).
If we don't want to switch tasks, we just return the ESP unchanged.
- See also
- isr_common in isr_asm.S
Definition at line 102 of file isr.c.
Handles all syscalls.
Calls a syscall handler if registered.
- Parameters
-
- Returns
- the new CPU state (if a task switch is desired)
Definition at line 139 of file isr.c.
Registers a handler to call whenever a given interrupt is fired.
- Parameters
-
intr | the interrupt vector that will be handled |
handler | the function to call |
Definition at line 66 of file isr.c.
void isr_register_syscall |
( |
size_t |
id, |
|
|
void * |
syscall |
|
) |
| |
Registers a syscall handler to call whenever a specified syscall is requested.
- Parameters
-
id | the ID of the syscall that will be handled |
syscall | the function to call (this should be an isr_syscall_t but parameters can be omitted if desired, so we pass a void*) |
Definition at line 80 of file isr.c.