diff options
author | Andreas Baumann <mail@andreasbaumann.cc> | 2017-06-01 17:06:27 +0200 |
---|---|---|
committer | Andreas Baumann <mail@andreasbaumann.cc> | 2017-06-01 17:06:27 +0200 |
commit | 2b35cdf00f87f004bc8a001623f7cf1bd7a5d440 (patch) | |
tree | adba3565e0af3d132781ff68b891d32e68d7d85a | |
parent | c211385dfe0915bcbd04b319b98e0e8753f11d46 (diff) | |
download | abaos-2b35cdf00f87f004bc8a001623f7cf1bd7a5d440.tar.gz abaos-2b35cdf00f87f004bc8a001623f7cf1bd7a5d440.tar.bz2 |
made global interrupt object a local static one
-rw-r--r-- | src/interrupts.c | 10 | ||||
-rw-r--r-- | src/interrupts.h | 2 | ||||
-rw-r--r-- | src/kernel.c | 1 |
3 files changed, 7 insertions, 6 deletions
diff --git a/src/interrupts.c b/src/interrupts.c index feb3aab..b522ced 100644 --- a/src/interrupts.c +++ b/src/interrupts.c @@ -59,7 +59,7 @@ // must be global: when called via assembly code we loose the context // of the interrupt handler structure -interrupt_t interrupt; +static interrupt_t *active_interrupt; void interrupts_init( interrupt_t *interrupt ) { @@ -121,6 +121,8 @@ void interrupts_init( interrupt_t *interrupt ) interrupt->idt_pointer.base = (uint32_t)interrupt->descriptor_table; interrupts_load_idt( &interrupt->idt_pointer ); + + active_interrupt = interrupt; } void interrupts_register_interrupt( interrupt_t *interrupts, @@ -165,7 +167,7 @@ uint32_t interrupts_interrupt_keyboard( uint32_t esp ) uint32_t interrupts_handle_interrupt( uint8_t interrupt_no, uint32_t esp ) { - interrupt_handler_t handler = interrupt.interrupt_handler[interrupt_no]; + interrupt_handler_t handler = active_interrupt->interrupt_handler[interrupt_no]; if( handler == NULL ) { kernel_panic( "Unhandled interrupt 0x%X with ESP 0x%X\n", interrupt_no, esp ); @@ -176,9 +178,9 @@ uint32_t interrupts_handle_interrupt( uint8_t interrupt_no, uint32_t 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( &interrupt.PIC_master_control, OCW2_EOI ); + port8_write( &active_interrupt->PIC_master_control, OCW2_EOI ); } else { - port8_write( &interrupt.PIC_slave_control, OCW2_EOI ); + port8_write( &active_interrupt->PIC_slave_control, OCW2_EOI ); } } diff --git a/src/interrupts.h b/src/interrupts.h index 64f1b43..547e7c2 100644 --- a/src/interrupts.h +++ b/src/interrupts.h @@ -57,8 +57,6 @@ typedef struct { port8_t PIC_slave_data; } interrupt_t; -extern interrupt_t interrupt; - void interrupts_enable( void ); void interrupts_disable( void ); void interrupts_init( interrupt_t *interrupt ); diff --git a/src/kernel.c b/src/kernel.c index 8759f18..eba75ba 100644 --- a/src/kernel.c +++ b/src/kernel.c @@ -32,6 +32,7 @@ void entry( void ) printf( "Kernel code and data is at 0x%X, kernel stack at 0x%X\n", 0x8400, 0x90000 ); puts( "Initializing interrupts" ); + interrupt_t interrupt; interrupts_init( &interrupt ); // exit point in case of kernel panic, do this as soon as |