#include <const.h>
#include <arch/exception.h>
#include <arch/i386.h>
#include <arch/mem.h>
#include <arch/paging.h>
#include <kernel/clock.h>
#include <kernel/console.h>
#include <kernel/floppy.h>
#include <kernel/keyboard.h>
#include <kernel/serial.h>
#include <kernel/speaker.h>
#include <kernel/syscall.h>
#include <kernel/task.h>
#include <net/rtl8139.h>
#include <arch/interrupt.h>
Go to the source code of this file.
Data Structures | |||||||||||
| struct | irq_desc | ||||||||||
| An IRQ handler pointer. More... | |||||||||||
Defines | |||||||||||
| #define | TOT_IRQ ( sizeof(irq_handler) / sizeof(irq_desc_t) ) | ||||||||||
| Total number of hardware interrupts. | |||||||||||
Typedefs | |||||||||||
| typedef irq_desc | irq_desc_t | ||||||||||
| An IRQ handler pointer. | |||||||||||
Functions | |||||||||||
| void | disable_IRQ (uint8_t IRQ) | ||||||||||
Disable an IRQ line.
| |||||||||||
| void | enable_IRQ (uint8_t IRQ) | ||||||||||
Enable an IRQ line.
| |||||||||||
| void | reprogram_PIC () | ||||||||||
Initialize the Programmable Interrupt Controllers (PICs).
| |||||||||||
| void | install_irq_handler (uint8_t irq, void *handler) | ||||||||||
Install an IRQ handler routine.
| |||||||||||
| void | unhandled_interrupt (uint8_t irq) | ||||||||||
Manage an unhandled interrupt.
| |||||||||||
| void | default_handler (irq_context_t *c) | ||||||||||
This is the default interrupt handler. It is invoked every time an interrupt occurs.
| |||||||||||
| void | setup_IDT_entry (byte i, word selector, dword offset, byte attribs, byte paramcnt) | ||||||||||
Set up an IDT entry.
| |||||||||||
| void | install_IDT () | ||||||||||
| Initialize the IDT (Interrupt Descriptor Table). | |||||||||||
Variables | |||||||||||
| volatile idt_entry_t | idt [IDT_DIM] | ||||||||||
| Interrupt Descriptor Table (IDT). | |||||||||||
| idt_reg_t | idt_ptr | ||||||||||
| Value of Interrupt Descriptor Table Register. | |||||||||||
| void | _irq_00 | ||||||||||
| void | _irq_01 | ||||||||||
| void | _irq_02 | ||||||||||
| void | _irq_03 | ||||||||||
| void | _irq_04 | ||||||||||
| void | _irq_05 | ||||||||||
| void | _irq_06 | ||||||||||
| void | _irq_07 | ||||||||||
| void | _irq_08 | ||||||||||
| void | _irq_09 | ||||||||||
| void | _irq_0A | ||||||||||
| void | _irq_0B | ||||||||||
| void | _irq_0C | ||||||||||
| void | _irq_0D | ||||||||||
| void | _irq_0E | ||||||||||
| void | _irq_0F | ||||||||||
| void | _irq_80 | ||||||||||
| void | _irq_unhand | ||||||||||
| void | _exc_00 | ||||||||||
| void | _exc_01 | ||||||||||
| void | _exc_02 | ||||||||||
| void | _exc_03 | ||||||||||
| void | _exc_04 | ||||||||||
| void | _exc_05 | ||||||||||
| void | _exc_06 | ||||||||||
| void | _exc_07 | ||||||||||
| void | _exc_08 | ||||||||||
| void | _exc_09 | ||||||||||
| void | _exc_0A | ||||||||||
| void | _exc_0B | ||||||||||
| void | _exc_0C | ||||||||||
| void | _exc_0D | ||||||||||
| void | _exc_0E | ||||||||||
| void | _exc_0F | ||||||||||
| void | _exc_unhand | ||||||||||
| irq_desc_t | irq_handler [] | ||||||||||
| A table for hardware interrupt handlers only. | |||||||||||
Definition in file interrupt.c.
|
|
Total number of hardware interrupts.
Definition at line 164 of file interrupt.c. |
|
|
An IRQ handler pointer.
|
|
|
Disable an IRQ line.
Definition at line 60 of file interrupt.c.
00061 {
00062 uint8_t mask;
00063
00064 if (IRQ > 15) return;
00065
00066 if (IRQ < 8)
00067 {
00068 // Master //
00069 mask = inportb(PORT_INT_MASK_M);
00070 mask |= 1 << IRQ;
00071 outportb(PORT_INT_MASK_M, mask);
00072 }
00073 else
00074 {
00075 // Slave //
00076 mask = inportb(PORT_INT_MASK_S);
00077 mask |= 1 << (IRQ-8);
00078 outportb(PORT_INT_MASK_S, mask);
00079 }
00080 }
|
|
|
Enable an IRQ line.
Definition at line 84 of file interrupt.c.
00085 {
00086 uint8_t mask;
00087
00088 if (IRQ > 15) return;
00089
00090 if (IRQ < 8)
00091 {
00092 // Master //
00093 mask = inportb(PORT_INT_MASK_M);
00094 mask &= ~(1 << IRQ);
00095 outportb(PORT_INT_MASK_M, mask);
00096 }
00097 else
00098 {
00099 // Slave //
00100 mask = inportb(PORT_INT_MASK_S);
00101 mask &= ~(1 << (IRQ-8));
00102 outportb(PORT_INT_MASK_S, mask);
00103 }
00104 }
|
|
|
||||||||||||
|
Install an IRQ handler routine.
Definition at line 172 of file interrupt.c.
00173 {
00174 dword IF = GET_IF();
00175
00176 if ( irq > TOT_IRQ )
00177 return;
00178
00179 disable();
00180
00181 irq_handler[irq].handler = handler;
00182 enable_IRQ(irq);
00183
00184 SET_IF(IF);
00185 return;
00186 }
|
|
|
Initialize the Programmable Interrupt Controllers (PICs).
Definition at line 113 of file interrupt.c.
00114 {
00115 // Start initialization for master & slave //
00116 outportb(PORT_8259_M, 0x11);
00117 outportb(PORT_8259_S, 0x11);
00118
00119 outportb(PORT_INT_MASK_M, 0x20); // master base vector //
00120 outportb(PORT_INT_MASK_S, 0x28); // slave base vector //
00121
00122 outportb(PORT_INT_MASK_M, 1 << 2); // IRQ2 cascade to slave //
00123 outportb(PORT_INT_MASK_S, 2); // cascade on IRQ2 //
00124
00125 // Finish 8259 initialization //
00126 outportb(PORT_INT_MASK_M, 1);
00127 outportb(PORT_INT_MASK_S, 1);
00128
00129 // Disable all IRQs for master, except the IRQ2 cascade line. //
00130 outportb(PORT_INT_MASK_M, ~(1 << 2));
00131 // Disable all IRQs for slave. //
00132 outportb(PORT_INT_MASK_S, 0xFF);
00133 }
|
|
||||||||||||||||||||||||
|
Set up an IDT entry.
Definition at line 265 of file interrupt.c.
|
|
|
Manage an unhandled interrupt.
Definition at line 190 of file interrupt.c.
00191 {
00192 set_color(LIGHT_RED);
00193 kprintf("\n\rUnhandled IRQ #%03u from task [%s] (%u)!!!", irq, get_pname(), get_pid());
00194 set_color(DEFAULT_COLOR);
00195 beep();
00196
00197 // Kill the task //
00198 if ( kill(get_pid()) == TRUE )
00199 {
00200 kprintf("\n\rTask [%s] (%u) killed!\n\r",
00201 get_pname(), get_pid()
00202 );
00203 }
00204 else
00205 kprintf("\n\rUnable to kill the task [%s] (%u)", get_pname(), get_pid());
00206 }
|
|
|
Definition at line 54 of file interrupt.c. |
|
|
Definition at line 54 of file interrupt.c. |
|
|
Definition at line 54 of file interrupt.c. |
|
|
Definition at line 54 of file interrupt.c. |
|
|
Definition at line 54 of file interrupt.c. |
|
|
Definition at line 54 of file interrupt.c. |
|
|
Definition at line 54 of file interrupt.c. |
|
|
Definition at line 54 of file interrupt.c. |
|
|
Definition at line 55 of file interrupt.c. |
|
|
Definition at line 55 of file interrupt.c. |
|
|
Definition at line 55 of file interrupt.c. |
|
|
Definition at line 55 of file interrupt.c. |
|
|
Definition at line 55 of file interrupt.c. |
|
|
Definition at line 55 of file interrupt.c. |
|
|
Definition at line 55 of file interrupt.c. |
|
|
Definition at line 55 of file interrupt.c. |
|
|
Definition at line 56 of file interrupt.c. |
|
|
Definition at line 47 of file interrupt.c. |
|
|
Definition at line 47 of file interrupt.c. |
|
|
Definition at line 47 of file interrupt.c. |
|
|
Definition at line 47 of file interrupt.c. |
|
|
Definition at line 47 of file interrupt.c. |
|
|
Definition at line 47 of file interrupt.c. |
|
|
Definition at line 47 of file interrupt.c. |
|
|
Definition at line 47 of file interrupt.c. |
|
|
Definition at line 48 of file interrupt.c. |
|
|
Definition at line 48 of file interrupt.c. |
|
|
Definition at line 48 of file interrupt.c. |
|
|
Definition at line 48 of file interrupt.c. |
|
|
Definition at line 48 of file interrupt.c. |
|
|
Definition at line 48 of file interrupt.c. |
|
|
Definition at line 48 of file interrupt.c. |
|
|
Definition at line 48 of file interrupt.c. |
|
|
Definition at line 49 of file interrupt.c. |
|
|
Definition at line 50 of file interrupt.c. |
|
|
Interrupt Descriptor Table (IDT).
Definition at line 40 of file interrupt.c. |
|
|
Value of Interrupt Descriptor Table Register.
Definition at line 43 of file interrupt.c. |
|
|
Initial value:
{
{ NULL },
{ NULL },
{ NULL },
{ NULL },
{ NULL },
{ NULL },
{ NULL },
{ NULL },
{ NULL },
{ NULL },
{ NULL },
{ NULL },
{ NULL },
{ NULL },
{ NULL },
{ NULL }
}
Definition at line 142 of file interrupt.c. |
1.2.18