blob: d79c9a19c574eea1c371a1d0f4bad8b11c700dd2 (
plain)
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
|
; Cheers to wiki.osdev.org for this quick starter. It really helped me
; get a prototype off the ground quickly without pissing around
; Declare constants used for creating a multiboot header.
MBALIGN equ 1<<0 ; align loaded modules on page boundaries
MEMINFO equ 1<<1 ; Ask for memory map
FLAGS equ MBALIGN | MEMINFO
MAGIC equ 0x1BADB002
CHECKSUM equ -(MAGIC + FLAGS)
; Standard mutliboot header so GRUB and other bootloaders can boot the kernel
section .multiboot
align 4
dd MAGIC
dd FLAGS
dd CHECKSUM
; Init our very own 16K stack
section .bootstrap_stack
align 4
stack_bottom:
times 16384 db 0
stack_top:
section .text
global _start
global _kernel_exit
_start:
; Functions in external objects
extern kernel_main
extern console_print_string
extern console_set_color
; Set stack up ready for C
mov esp, stack_top
push eax
push ebx
call kernel_main
; Let the user know that kernel_main() exited
push 0x0A
call console_set_color ; Reset text colour
push exitmain
call console_print_string
; Wake us not from our slumber
cli
_kernel_exit:
.hang:
hlt
jmp .hang
exitmain db 10,"boot: kernel_main() exited",0
|