-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathboot.s
40 lines (34 loc) · 1.12 KB
/
boot.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
# build instructions i686-elf-as boot.s -o boot.o
# the multiboot header constants.
.set ALIGN, 1<<0 # align loaded modules on page boundaries
.set MEMINFO, 1<<1 # provide memory map
.set FLAGS, ALIGN | MEMINFO # this is the Multiboot 'flag' field
.set MAGIC, 0x1BADB002 # 'magic number' lets bootloader find the header
.set CHECKSUM, -(MAGIC + FLAGS) # checksum of above, to prove we are multiboot
# this has to be in the 1st 8KiB os the kernel file
.section .multiboot
.align 4
.long MAGIC
.long FLAGS
.long CHECKSUM
# The stack on x86 must be 16-byte aligned according to the
# System V ABI standard and de-facto extensions.
# stack initialization and alignment
.section .bss
.align 16
stack_bottom:
.skip 16384 # 16 KiB
stack_top:
# starting the actual program settings for some linker magic
.section .text
.global _start
.type _start, @function
_start:
mov $stack_top, %esp
call kernel_main
cli
1: hlt
jmp 1b
# Set the size of the _start symbol to the current location '.' minus its start.
# This is useful when debugging or when you implement call tracing.
.size _start, . - _start