summaryrefslogtreecommitdiff
path: root/kernel/interrupts.c
diff options
context:
space:
mode:
authorMiguel <m.i@gmx.at>2018-09-09 17:28:59 +0200
committerMiguel <m.i@gmx.at>2018-09-09 17:28:59 +0200
commit4cda542d863839c5b0e026ccee297ca5ff3dd9cd (patch)
tree7b8f7734f8f982df82b5c784386232e35a7ced44 /kernel/interrupts.c
parent9a4b35fd5a32490f8f15b48f978e7b1fbfdceb2a (diff)
switched to apic/ioapic finally
Diffstat (limited to 'kernel/interrupts.c')
-rw-r--r--kernel/interrupts.c37
1 files changed, 16 insertions, 21 deletions
diff --git a/kernel/interrupts.c b/kernel/interrupts.c
index 44ab9b5..897c312 100644
--- a/kernel/interrupts.c
+++ b/kernel/interrupts.c
@@ -60,26 +60,23 @@ void interrupts_install()
uint32_t interrupt_handler(uint32_t esp, uint32_t irq)
{
-
// DO NOT WRITE INSIDE INTERRUPTS!! COZ IT ACQUIRES LOCK AND WE WILL DEADLOCK
- //klog("int: %d on 0x%x",irq,apicID());
- if(irq==0){
- asm_pit_tick();
- }
+ // klog("int: %d on 0x%x",irq,apicID());
+ if(irq==INTERRUPT_PIT_TIMER)asm_pit_tick();
// mouse and kb
- if(irq==1 || irq==12 ){
+ if(irq==INTERRUPT_KEYBOARD || irq==INTERRUPT_MOUSE){
uint32_t in=x86_inb(0x60);
- if(irq==1)keyboard_handle(in); // do this in separate thread!
+ if(irq==INTERRUPT_KEYBOARD)keyboard_handle(in); // do this in separate thread!
// TODO: mouse
// test ipi
-// apicIPI(2,170);
-// klog("0x60 in %d",in);
+ //apicIPI(15,0x81); // force cpu16 to autoschedule? just test
+ //klog("0x60 in %d",in);
}
// 0x80 - a syscall is coming in
- if(irq==128){
+ if(irq==INTERRUPT_SYSCALL){
uint32_t *stack=esp;
uint32_t eax=stack[11];
@@ -93,16 +90,14 @@ uint32_t interrupt_handler(uint32_t esp, uint32_t irq)
esp=my_scheduler(esp,2); // force scheduling of pid=2 (kernel worker)
}
- if(irq==0 || irq==129)esp=my_scheduler(esp,-1); // autoschedule
+ // schedules on APIC timer 0x8C and IPI 0x81
+ if(irq==INTERRUPT_PIT_TIMER || irq==INTERRUPT_IPI)esp=my_scheduler(esp,-1); // autoschedule
- if(irq==200){} // apic timer
- if(irq==170){
-// if(apicID()!=0)apicIPI(0,170);
- }
- if(irq==255)kpanic("Spurious Interrupt!?");
+ if(irq!=INTERRUPT_SYSCALL)apicEOI(); // ack all except software syscalls
+
+ if(irq==255)kpanic("Spurious/Unknown Interrupt!?"); // default and spurious
- if(irq!=0x81 && irq!=0x80)apicEOI();
return esp;
}
@@ -243,16 +238,16 @@ void interrupts_init(uint16_t sel)
int_install_ir(18, 0b10001110, 0x08,&exc18);
// PIT (IOAPIC)
- int_install_ir(0x90, 0b10001110, 0x08,&int0);
+ int_install_ir(0x90, 0b10001110, 0x08,&int144);
// Keyboard (IOAPIC)
- int_install_ir(0x91, 0b10001110, 0x08,&int1);
+ int_install_ir(0x91, 0b10001110, 0x08,&int145);
// Mouse (IOAPIC)
- int_install_ir(0x92, 0b10001110, 0x08,&int12);
+ int_install_ir(0x92, 0b10001110, 0x08,&int146);
// APIC Timer (LAPIC)
- int_install_ir(0x8C, 0b10001110, 0x08,&int200);
+ int_install_ir(0x8C, 0b10001110, 0x08,&int140);
// System Calls (User Software / Ring 3)
int_install_ir(0x80, 0b11101110, 0x08,&int128);