feat: made more definitions constant and did some more minor

improvements
This commit is contained in:
2021-01-29 20:25:37 +01:00
parent d7f0e8dd36
commit 5a1caef5b1
13 changed files with 114 additions and 30 deletions

View File

@@ -9,6 +9,8 @@
#include <libc/libc.h>
#include <drivers/ports.h>
#define PIC_END_OF_INTERRUPT 0x20
isr_t interrupt_handlers[256];
void isr_install() {
@@ -133,11 +135,11 @@ void register_interrupt_handler(u8 n, isr_t handler) {
void irq_handler(registers_t r) {
/* After every interrupt we need to send an EOI to the PICs
* or they will not send another interrupt again */
if (r.int_no >= 40) port_byte_out(0xA0, 0x20); /* slave */
port_byte_out(0x20, 0x20); /* master */
if (r.int_no >= 40) port_byte_out(PORT_PIC_SLAVE_COMMAND, PIC_END_OF_INTERRUPT); /* slave */
port_byte_out(PORT_PIC_MASTER_COMMAND, PIC_END_OF_INTERRUPT); /* master */
/* Handle the interrupt in a more modular way */
if (interrupt_handlers[r.int_no] != 0) {
if (interrupt_handlers[r.int_no] != NULL) {
isr_t handler = interrupt_handlers[r.int_no];
handler(r);
}