MentOS  0.8.0
The Mentoring Operating System
isr.h
Go to the documentation of this file.
1 
11 #pragma once
12 
13 #include "kernel.h"
14 
15 // TODO: see interrupt_handler_t in Linux, it is quite different.
20 typedef void (*interrupt_handler_t)(pt_regs *f);
21 
24 void isrs_init(void);
25 
28 void irq_init(void);
29 
30 /* Even if an interrupt service routine is called for exceptions and
31  * interrupts, we use two distinct methods to logically setup an ISR to
32  * handle theme. Tecnically speacking, exceptions are synchronous interrupts
33  * generated by CPU. For an exception we have an ISR. Interrupts are
34  * asynchronous events generated by PIC. Furthermore, multiple ISRs can be set
35  * for a same IRQ.
36  */
37 
43 int isr_install_handler(unsigned i, interrupt_handler_t handler, char *description);
44 
48 int isr_uninstall_handler(unsigned i);
49 
55 int irq_install_handler(unsigned i, interrupt_handler_t handler, char *description);
56 
61 int irq_uninstall_handler(unsigned i, interrupt_handler_t handler);
62 
65 extern void irq_handler(pt_regs *f);
66 
69 extern void isq_handler(pt_regs *f);
70 
71 //==== List of exceptions generated internally by the CPU ======================
72 #define DIVIDE_ERROR 0
73 #define DEBUG_EXC 1
74 #define NMI_INTERRUPT 2
75 #define BREAKPOINT 3
76 #define OVERFLOW 4
77 #define BOUND_RANGE_EXCEED 5
78 #define INVALID_OPCODE 6
79 #define DEV_NOT_AVL 7
80 #define DOUBLE_FAULT 8
81 #define COPROC_SEG_OVERRUN 9
82 #define INVALID_TSS 10
83 #define SEGMENT_NOT_PRESENT 11
84 #define STACK_SEGMENT_FAULT 12
85 #define GENERAL_PROTECTION 13
86 #define PAGE_FAULT 14
87 #define INT_RSV 15
88 #define FLOATING_POINT_ERR 16
89 #define ALIGNMENT_CHECK 17
90 #define MACHINE_CHECK 18
91 #define SIMD_FP_EXC 19
92 #define VIRT_EXC 20
93 // Reserved [21-29].
94 #define SECURITY_EXC 30
95 #define TRIPLE_FAULT 31
96 #define SYSTEM_CALL 80
97  //==============================================================================
98 
int isr_install_handler(unsigned i, interrupt_handler_t handler, char *description)
Installs an ISR to handle an interrupt.
Definition: exception.c:96
int irq_uninstall_handler(unsigned i, interrupt_handler_t handler)
Uninstall an IRQ handler.
Definition: interrupt.c:87
void irq_init(void)
For each interrupt irq_init sets a default handler which prints the rose IRQ line and stops kernel ex...
Definition: interrupt.c:57
int irq_install_handler(unsigned i, interrupt_handler_t handler, char *description)
Installs an ISR to handle an interrupt.
Definition: interrupt.c:67
void isq_handler(pt_regs *f)
Method called by CPU to handle exceptions.
void(* interrupt_handler_t)(pt_regs *f)
Interrupt handler definition.
Definition: isr.h:20
void irq_handler(pt_regs *f)
Method called by CPU to handle interrupts.
Definition: interrupt.c:111
int isr_uninstall_handler(unsigned i)
Uninstall an ISR handler.
Definition: exception.c:107
void isrs_init(void)
For each exceptions isrs_init sets a default handler which prints the rose exceptions and stops kerne...
Definition: exception.c:88
Kernel generic data structure and functions.
Interrupt stack frame.
Definition: kernel.h:24