-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkernel.asm
53 lines (39 loc) · 796 Bytes
/
kernel.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
bits 32
section .text
;multiboot specifications i.e multiboot header
align 4
dd 0x1BADB002 ;magic
dd 0x00 ;flags
dd - (0x1BADB002 + 0x00) ;checksum. m+f+c should be zero
global start
global keyboard_handler
global read_from_port
global write_to_port
global load_idt
extern main_kernel
extern keyboard_handler_main
read_from_port:
mov edx, [esp+4]
in al,dx
ret
write_to_port:
mov edx,[esp+4]
mov al, [esp+4+4]
out dx,al
ret
load_idt:
mov edx,[esp+4]
lidt [edx]
sti
ret
keyboard_handler:
call keyboard_handler_main
iretd
start:
cli ;block all interrupts
mov esp, stack_space
call main_kernel
hlt
section .bss
resb 8192 ; 8KB for stack
stack_space: