forked from mischief/goose
-
Notifications
You must be signed in to change notification settings - Fork 0
/
loader.s
64 lines (48 loc) · 1.04 KB
/
loader.s
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
;
; Adapted from osdev.org's Bare Bones tutorial http://wiki.osdev.org/Bare_Bones
;
global loader
global magic
global mbd
; Go compatibility
global __go_register_gc_roots
global __go_runtime_error
global __unsafe_get_addr
extern go.kernel.Kmain
; Multiboot stuff
MODULEALIGN equ 1<<0
MEMINFO equ 1<<1
FLAGS equ MODULEALIGN | MEMINFO
MAGIC equ 0x1BADB002
CHECKSUM equ -(MAGIC + FLAGS)
section .text
align 4
dd MAGIC
dd FLAGS
dd CHECKSUM
STACKSIZE equ 0x4000 ; Define our stack size at 16k
loader:
mov esp, stack + STACKSIZE ; Setup stack pointer
mov [magic], eax
mov [mbd], ebx
call go.kernel.Kmain ; Jump to Go's kernel.Kmain
cli
.hang:
hlt
jmp .hang
__unsafe_get_addr: ; Allows us to convert int -> ptr in go
push ebp
mov ebp,esp
mov eax, [ebp+8]
mov esp,ebp
pop ebp
ret
; Go compatibility - noop'd
__go_runtime_error:
__go_register_gc_roots:
ret
section .bss
align 4
stack: resb STACKSIZE ; Reserve 16k for stack
magic: resd 1
mbd: resd 1