diff options
author | Andreas Baumann <mail@andreasbaumann.cc> | 2017-06-01 17:17:03 +0200 |
---|---|---|
committer | Andreas Baumann <mail@andreasbaumann.cc> | 2017-06-01 17:17:03 +0200 |
commit | 15a2290a168fa9de80256bb7cefe13384ae3e58b (patch) | |
tree | 0bec8904a1073fbad1dcb4f0f92f01b68cd072b9 /src/interrupts.c | |
parent | 2b35cdf00f87f004bc8a001623f7cf1bd7a5d440 (diff) | |
download | abaos-15a2290a168fa9de80256bb7cefe13384ae3e58b.tar.gz abaos-15a2290a168fa9de80256bb7cefe13384ae3e58b.tar.bz2 |
interrupt handlers take the manager as context now
Diffstat (limited to 'src/interrupts.c')
-rw-r--r-- | src/interrupts.c | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/src/interrupts.c b/src/interrupts.c index b522ced..07a7e55 100644 --- a/src/interrupts.c +++ b/src/interrupts.c @@ -141,7 +141,7 @@ void interrupts_register_interrupt( interrupt_t *interrupts, interrupts->interrupt_handler[interrupt_no] = handler; } -uint32_t interrupts_exception_division_by_zero( uint32_t esp ) +uint32_t interrupts_exception_division_by_zero( interrupt_t *interrupt, uint32_t esp ) { // TODO: caused by kernel code or user land code? or a task we can kill? // For now, the kernel has no task management, so we panic @@ -151,36 +151,49 @@ uint32_t interrupts_exception_division_by_zero( uint32_t esp ) } static int pit_counter = 0; -uint32_t interrupts_interrupt_PIT( uint32_t esp ) +uint32_t interrupts_interrupt_PIT( interrupt_t *interrupt, uint32_t esp ) { pit_counter++; printf( "PIT PIT PIT PIT PIT PIT PIT %d", pit_counter ); return esp; } -uint32_t interrupts_interrupt_keyboard( uint32_t esp ) +uint32_t interrupts_interrupt_keyboard( interrupt_t *interrupt, uint32_t esp ) { puts( "KBD KBD KBD KBD KBD KBD KBD" ); + +int y = 0; +int x = 12 / y; +printf( "Hex number is 0x%X and string is '%s'\n", x, "abaos" ); return esp; } -uint32_t interrupts_handle_interrupt( uint8_t interrupt_no, uint32_t esp ) +uint32_t interrupts_handle_static_interrupt( uint8_t interrupt_no, uint32_t esp ) +{ + if( active_interrupt == NULL ) { + kernel_panic( "No active interrupt handler!" ); + } + + return interrupts_handle_interrupt( active_interrupt, interrupt_no, esp ); +} + +uint32_t interrupts_handle_interrupt( interrupt_t *interrupt, uint8_t interrupt_no, uint32_t esp ) { - interrupt_handler_t handler = active_interrupt->interrupt_handler[interrupt_no]; + interrupt_handler_t handler = interrupt->interrupt_handler[interrupt_no]; if( handler == NULL ) { kernel_panic( "Unhandled interrupt 0x%X with ESP 0x%X\n", interrupt_no, esp ); } - uint32_t new_esp = handler( esp ); + uint32_t new_esp = handler( interrupt, esp ); // send ACK to PIC for hardware interrups if( interrupt_no >= IRQ_BASE && interrupt_no <= IRQ_BASE + 16 ) { if( interrupt_no < IRQ_BASE + 8 ) { - port8_write( &active_interrupt->PIC_master_control, OCW2_EOI ); + port8_write( &interrupt->PIC_master_control, OCW2_EOI ); } else { - port8_write( &active_interrupt->PIC_slave_control, OCW2_EOI ); + port8_write( &interrupt->PIC_slave_control, OCW2_EOI ); } } |