summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--kernel/cpu/idt.c18
-rw-r--r--kernel/cpu/idt.h2
-rw-r--r--kernel/drivers/mouse.c15
3 files changed, 15 insertions, 20 deletions
diff --git a/kernel/cpu/idt.c b/kernel/cpu/idt.c
index a1f78f9..7ad0be1 100644
--- a/kernel/cpu/idt.c
+++ b/kernel/cpu/idt.c
@@ -171,7 +171,7 @@ void pic_remap(int offset) {
outb(SLAVE_PIC_DATA_PORT, a2);
}
-void irq_set_mask(unsigned char irq_line) {
+void irq_set_mask(u8 irq_line) {
u16 port;
u8 value;
port = (irq_line < 8) ? MASTER_PIC_DATA_PORT : SLAVE_PIC_DATA_PORT;
@@ -182,14 +182,14 @@ void irq_set_mask(unsigned char irq_line) {
outb(port, value);
}
-void IRQ_clear_mask(unsigned char IRQline) {
+void irq_clear_mask(u8 irq_line) {
u16 port;
u8 value;
- port = (IRQline < 8) ? MASTER_PIC_DATA_PORT : SLAVE_PIC_DATA_PORT;
- if (IRQline >= 8) {
- IRQline -= 8;
+ port = (irq_line < 8) ? MASTER_PIC_DATA_PORT : SLAVE_PIC_DATA_PORT;
+ if (irq_line >= 8) {
+ irq_line -= 8;
}
- value = inb(port) & ~(1 << IRQline);
+ value = inb(port) & ~(1 << irq_line);
outb(port, value);
}
@@ -259,8 +259,8 @@ void install_handler(interrupt_handler handler_function, u16 type_attribute,
format_descriptor((u32)isr_list[entry], KERNEL_CODE_SEGMENT_OFFSET,
type_attribute, &IDT_Entry[entry]);
list_of_handlers[entry] = (interrupt_handler)handler_function;
- if (entry >= 0x20 && entry < 0x20 + 0xA) {
- IRQ_clear_mask(entry - 0x20);
+ if (entry >= 0x20 && entry <= 0x30) {
+ irq_clear_mask(entry - 0x20);
}
}
@@ -268,7 +268,7 @@ void idt_init(void) {
memset(list_of_handlers, 0, sizeof(void *) * 256);
pic_remap(0x20);
- for (int i = 0; i < 16; i++) {
+ for (int i = 0; i < 0x10; i++) {
irq_set_mask(i);
}
diff --git a/kernel/cpu/idt.h b/kernel/cpu/idt.h
index d866659..06e63ba 100644
--- a/kernel/cpu/idt.h
+++ b/kernel/cpu/idt.h
@@ -326,4 +326,6 @@ __attribute__((no_caller_saved_registers)) void EOI(unsigned char irq);
typedef void (*interrupt_handler)(reg_t *);
void install_handler(interrupt_handler handler_function, u16 type_attribute,
u8 entry);
+void irq_set_mask(u8 irq_line);
+void irq_clear_mask(u8 irq_line);
#endif
diff --git a/kernel/drivers/mouse.c b/kernel/drivers/mouse.c
index f9c3d0e..0eb6df6 100644
--- a/kernel/drivers/mouse.c
+++ b/kernel/drivers/mouse.c
@@ -41,19 +41,14 @@ void add_mouse(void) {
ringbuffer_init(mouse_inode->internal_object, 4096);
}
-void what(registers_t *r) {
- EOI(0xe);
-}
-
void int_mouse(reg_t *r) {
(void)r;
- EOI(12);
switch (mouse_cycle) {
case 0:
mouse_u8[0] = inb(0x60);
if (!(mouse_u8[0] & (1 << 3))) {
mouse_cycle = 0;
- return;
+ break;
}
mouse_cycle++;
break;
@@ -74,6 +69,7 @@ void int_mouse(reg_t *r) {
ringbuffer_write(rb, (u8 *)&e, sizeof(e));
break;
}
+ EOI(0xC);
}
void mouse_wait(u8 a_type) {
@@ -137,9 +133,6 @@ void install_mouse(void) {
mouse_read(); // Acknowledge
install_handler((interrupt_handler)int_mouse, INT_32_INTERRUPT_GATE(0x3),
- 12 + 0x20);
- install_handler((interrupt_handler)what, INT_32_INTERRUPT_GATE(0x3),
- 0xe + 0x20);
- install_handler((interrupt_handler)what, INT_32_INTERRUPT_GATE(0x3),
- 0xf + 0x20);
+ 0x2C);
+ irq_clear_mask(0x2);
}