summaryrefslogtreecommitdiff
path: root/kernel/interrupts.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/interrupts.c')
-rw-r--r--kernel/interrupts.c65
1 files changed, 8 insertions, 57 deletions
diff --git a/kernel/interrupts.c b/kernel/interrupts.c
index 61a03e2..b7cdd74 100644
--- a/kernel/interrupts.c
+++ b/kernel/interrupts.c
@@ -50,7 +50,9 @@ static void int_install_ir(int irq, uint16_t flags, uint16_t sel, void *addr)
idt[irq].sel=sel;
}
-/** register an interrupt handler for given irq number */
+/**
+ * Register an interrupt handler for given irq number.
+ */
void interrupt_register(uint32_t irq, uint32_t func_addr)
{
if(irq<128||irq>160)kpanic("irq number out of range!");
@@ -65,14 +67,12 @@ void interrupt_register(uint32_t irq, uint32_t func_addr)
uint32_t interrupt_handler(uint32_t esp, uint32_t irq)
{
uint32_t cpu=smp_get(SMP_APIC_ID);
-
- if(handlers[irq]!=0)
+
+ if(handlers[irq]!=0)// kb,mouse,e1000,pit,...
{
uint32_t (*f)(uint32_t esp)=handlers[irq];
esp=f(esp);
- scheduler_wake_worker(esp);
- apic_eoi();
- esp=scheduler_run(esp,-1);
+ apic_eoi();
return esp;
}
@@ -93,8 +93,9 @@ uint32_t interrupt_handler(uint32_t esp, uint32_t irq)
return esp;
}
- if(irq==INTERRUPT_SYSCALL) // do not EOI
+ if(irq==INTERRUPT_SYSCALL)
{
+ apic_eoi();
uint32_t *stack;
stack=esp;
task_syscall(stack[11],stack[8],stack[10],stack[9]); //eax,ebx,ecx,edx
@@ -104,56 +105,6 @@ uint32_t interrupt_handler(uint32_t esp, uint32_t irq)
}
kpanic("unhandled interrupt %d",irq);
-
- /*
- if(handlers[irq]!=0)
- {
- //uint32_t (*f)(uint32_t esp)=handlers[irq];
- //esp=f(esp);
- apic_eoi();
- }
-
- else if(irq!=INTERRUPT_SYSCALL&&irq!=INTERRUPT_IPI&&irq!=INTERRUPT_APIC_TIMER)
- {
- kpanic("unhandled interrupt %d",irq);
- }
-
- // process IRQ
- switch(irq)
- {
- case INTERRUPT_SYSCALL:
- stack=esp;
- // task_syscall(stack[11],stack[8],stack[10],stack[9]); //eax,ebx,ecx,edx
- break;
-
-
- case INTERRUPT_APIC_TIMER: // frequency is configured in smp.c (100hz)
- esp=scheduler_run(esp,-1);
- apic_eoi();
- break;
-
- case INTERRUPT_IPI: // inter process interrupt
- esp=scheduler_run(esp,-1);
- apic_eoi();
- break;
-
- case 255: // default or spurious
- kpanic("Spurious/Unknown Interrupt!?");
- break;
- }
-
- // reschedule to kernel worker on these
- if(irq==INTERRUPT_SYSCALL||irq==INTERRUPT_KEYBOARD||irq==INTERRUPT_MOUSE)
- {
- // scheduler_wake_worker(esp);
- esp=scheduler_run(esp,-1);
- }
-
- // Ack all to LAPIC, except software syscalls
-
- return esp;
-
- */
}
/**