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_IDT () | ||||
| Initialize the IDT (Interrupt Descriptor Table). | |||||
| void | install_irq_handler (uint8_t irq, void *handler) | ||||
Install an IRQ handler routine.
| |||||
| void | default_handler (irq_context_t *c) | ||||
This is the default interrupt handler. It is invoked every time an interrupt occurs.
| |||||
|
|
This is the default interrupt handler. It is invoked every time an interrupt occurs.
Definition at line 216 of file interrupt.c.
00217 {
00218 if ( c->IRQ < sizeof(irq_handler) )
00219 {
00220 // An hardware interrupt occurs //
00221 // Call the interrupt handler if exists //
00222 if ( irq_handler[c->IRQ].handler != NULL )
00223 {
00224 // Pointer to the handler function //
00225 int (*p)()=(void *)irq_handler[c->IRQ].handler;
00226 (*p)();
00227 }
00228 else
00229 {
00230 // Unhandled interrupt! //
00231 unhandled_interrupt(c->IRQ);
00232 }
00233 }
00234 else
00235 {
00236 // Software interrupt occurs //
00237 // (only MINIRIGHI INT is accepted) //
00238 switch ( c->IRQ )
00239 {
00240 case MINIRIGHI_INT:
00241 syscall_handler(&(c->eax), &(c->ebp));
00242 break;
00243
00244 default:
00245 unhandled_interrupt(c->IRQ);
00246 break;
00247 }
00248 return;
00249 }
00250 // Re-enable the IRQ line (master channel) //
00251 outportb(PORT_8259_M, EOI);
00252 if ( c->IRQ >= 8 )
00253 // Re-enable also the IRQ slave channel //
00254 outportb(PORT_8259_S, EOI);
00255 }
|
|
|
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 }
|
1.2.18