summaryrefslogtreecommitdiff
path: root/kernel/boot.s
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/boot.s')
-rw-r--r--kernel/boot.s34
1 files changed, 31 insertions, 3 deletions
diff --git a/kernel/boot.s b/kernel/boot.s
index be68109..e41c0b2 100644
--- a/kernel/boot.s
+++ b/kernel/boot.s
@@ -1,5 +1,7 @@
global kboot
+global register_isr
extern kmain
+extern timer_init
; Multiboot header
section .mboothdr
@@ -15,6 +17,7 @@ kboot:
cli
call flush_gdt
call flush_idt
+ call timer_init
call kmain
cli
hlt
@@ -80,13 +83,22 @@ idtp:
int_handler:
iret
+irq_handler:
+ iret
+
flush_idt:
push ebp
mov ebp, esp
- mov ecx, 256
+ mov ecx, 0
mov edx, idt
.loop:
mov eax, int_handler
+ cmp ecx, 0x20
+ jl .skip
+ cmp ecx, 0x2f
+ jg .skip
+ mov eax, irq_handler
+.skip:
mov [edx], ax
mov word [edx+2], 0x08
mov byte [edx+4], 0
@@ -94,8 +106,9 @@ flush_idt:
shr eax, 16
mov [edx+6], ax
add edx, 8
- dec ecx
- jz .end
+ inc ecx
+ cmp ecx, 256
+ je .end
jmp .loop
.end:
lidt [idtp]
@@ -104,6 +117,21 @@ flush_idt:
pop ebp
ret
+; void register_isr(uint8_t n, void *handler);
+register_isr:
+ push ebp
+ mov ebp, esp
+ mov edx, [ebp+8]
+ shl edx, 3
+ add edx, idt
+ mov eax, [ebp+12]
+ mov [edx], ax
+ add edx, 6
+ shr eax, 16
+ mov [edx], ax
+ pop ebp
+ ret
+
pic_init:
push ebp
mov ebp, esp