-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathloader.s
More file actions
31 lines (25 loc) · 1.25 KB
/
Copy pathloader.s
File metadata and controls
31 lines (25 loc) · 1.25 KB
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
global loader ; the entry symbol for ELF
extern kmain
extern idt_register_kbd
MAGIC_NUMBER equ 0x1BADB002 ; define the magic number constant
FLAGS equ 0x0 ; multiboot flags
CHECKSUM equ -MAGIC_NUMBER ; calculate checksum
; (magic num + checksum + flags should = 0)
KERNEL_STACK_SIZE equ 4096 ; size of stack (bytes)
section .bss
align 4
kernel_stack: ; label points to beginning of memory
resb KERNEL_STACK_SIZE ; reserve stack for kernel
section .text: ; start of the text (code) section
align 4 ; the code must be 4 byte aligned
dd MAGIC_NUMBER ; write the magic number to the machine code,
dd FLAGS ; the flags,
dd CHECKSUM ; and the checksum
loader: ; define loader label (entry point in linker script)
mov eax, 0xCAFEBABE ; place number 0xCAFEBABE in the register eax
mov esp, kernel_stack + KERNEL_STACK_SIZE
; point esp to start of stack
call kmain ; call kmain
call idt_register_kbd ; register the keyboard
.loop:
jmp .loop ; loop