From 0b02cbac466992423caa450f9659b18d251a4158 Mon Sep 17 00:00:00 2001
From: =?utf8?q?Duje=20Mihanovi=C4=87?= <duje.mihanovic@skole.hr>
Date: Sat, 12 Mar 2022 13:28:35 +0100
Subject: [PATCH] Fix keyboard interrupts

---
 boot/x86/boot.s                      | 2 +-
 kernel/arch/x86/irq/sample_handler.c | 3 +++
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/boot/x86/boot.s b/boot/x86/boot.s
index 572ef74..a7fe3c3 100644
--- a/boot/x86/boot.s
+++ b/boot/x86/boot.s
@@ -15,7 +15,7 @@ KERNEL_OFFSET equ 1000h ; where we will load our kernel
 	jc reset_error ; halt if controller reset fails
 
 	mov ah, 2 ; instruct BIOS's interrupt 13h to read sectors
-	mov al, 10 ; load 10 sectors, might be excessive (for now) but it's still good to do so
+	mov al, 30 ; load 30 sectors, might be excessive (for now) but it's still good to do so
 	xor ch, ch ; read from 1st cylinder
 	mov cl, 2 ; start reading from 2nd sector, right after the boot sector
 	xor dh, dh ; read from 1st head
diff --git a/kernel/arch/x86/irq/sample_handler.c b/kernel/arch/x86/irq/sample_handler.c
index c8bddfe..d9bd8f9 100644
--- a/kernel/arch/x86/irq/sample_handler.c
+++ b/kernel/arch/x86/irq/sample_handler.c
@@ -1,5 +1,6 @@
 #include <tty.h>
 #include <irq/i8259a.h>
+#include <io.h>
 #include <stdint.h>
 
 typedef uint32_t uword_t;
@@ -17,6 +18,7 @@ void keyb_handler(struct interrupt_frame *frame)
 {
 	pic_send_eoi(1);
 	kprint("Got a keyboard interrupt!\n", 0);
+	inb(0x60);
 }
 
 
@@ -26,5 +28,6 @@ void double_fault(struct abort_frame *frame)
 	*(volatile char *) (0xb8000) = ":";
 	*(volatile char *) (0xb8002) = "(";
 	asm volatile ("cli; hlt");
+	while(1);
 }
 
-- 
2.39.5