From d18a31eec21faff52cb6f38d427e0e0182269399 Mon Sep 17 00:00:00 2001 From: Braiden Vasco Date: Mon, 6 Nov 2017 10:59:52 +0000 Subject: [PATCH] Improve function "pic_end_of_interrupt" --- arch/hwint.c | 7 +------ arch/pic.c | 6 ++++-- arch/pic.h | 2 +- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/arch/hwint.c b/arch/hwint.c index e18fd20..9ea3546 100644 --- a/arch/hwint.c +++ b/arch/hwint.c @@ -29,15 +29,10 @@ static hwint_handler_t handlers[INT_HWINT_COUNT] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, void hwint_handler(struct IsrRegisters regs) { - if ( - !(regs.int_no >= INT_HWINT_FIRST && - regs.int_no <= INT_HWINT_LAST) - ) { + if (!pic_end_of_interrupt(regs.int_no)) { return; } - pic_end_of_interrupt(regs.int_no); - const unsigned char hwint_no = regs.int_no - INT_HWINT_FIRST; const hwint_handler_t handler = handlers[hwint_no]; diff --git a/arch/pic.c b/arch/pic.c index 3dfa147..99c16ee 100644 --- a/arch/pic.c +++ b/arch/pic.c @@ -47,13 +47,13 @@ void pic_remap(const unsigned char new_master_irq_start, const unsigned char new outportb(SLAVE_DATA, slave_mask); } -void pic_end_of_interrupt(const unsigned char irq) +unsigned char pic_end_of_interrupt(const unsigned char irq) { const unsigned char to_master = master_irq_start <= irq && irq < master_irq_start + IRQS_COUNT; const unsigned char to_slave = slave_irq_start <= irq && irq < slave_irq_start + IRQS_COUNT; if (!(to_master || to_slave)) { - return; + return 0; } if (to_slave) { @@ -61,4 +61,6 @@ void pic_end_of_interrupt(const unsigned char irq) } outportb(MASTER_COMMAND, 0x20); + + return 1; } diff --git a/arch/pic.h b/arch/pic.h index 11f5238..7560277 100644 --- a/arch/pic.h +++ b/arch/pic.h @@ -3,6 +3,6 @@ void pic_remap(unsigned char master_irq_start, unsigned char slave_irq_start); -void pic_end_of_interrupt(unsigned char irq); +unsigned char pic_end_of_interrupt(unsigned char irq); #endif