Working basics
This commit is contained in:
commit
ed1241341b
3 changed files with 59 additions and 0 deletions
39
arch/i386/boot.S
Executable file
39
arch/i386/boot.S
Executable file
|
@ -0,0 +1,39 @@
|
||||||
|
# Constants for multiboot
|
||||||
|
.set ALIGN, 1<<0 # align on page boundaries
|
||||||
|
.set MEMINFO, 1<<1 # memory map
|
||||||
|
.set FLAGS, ALIGN | MEMINFO # for multiboot 'flag' field
|
||||||
|
.set MAGIC, 0x1BADB002 # magic number for bootloader
|
||||||
|
.set CHECKSUM, -(MAGIC + FLAGS) # checksum to prove we're multiboot
|
||||||
|
|
||||||
|
# Declare header for multiboot
|
||||||
|
.section .multiboot
|
||||||
|
.align 4
|
||||||
|
.long MAGIC
|
||||||
|
.long FLAGS
|
||||||
|
.long CHECKSUM
|
||||||
|
|
||||||
|
# Reserve stack for initial thread
|
||||||
|
.section .bss
|
||||||
|
.align 16
|
||||||
|
stack_bottom:
|
||||||
|
.skip 16384 # 16K
|
||||||
|
stack_top:
|
||||||
|
|
||||||
|
# Kernel entry
|
||||||
|
.section .text
|
||||||
|
.global _start
|
||||||
|
.type _start, @function
|
||||||
|
_start:
|
||||||
|
movl $stack_top, %esp
|
||||||
|
|
||||||
|
# Call global constructors
|
||||||
|
call _init
|
||||||
|
|
||||||
|
# Start kernel
|
||||||
|
call kern_main
|
||||||
|
|
||||||
|
# Hang if kernel returns
|
||||||
|
cli
|
||||||
|
1: hlt
|
||||||
|
jmp 1b
|
||||||
|
.size _start, . - _start
|
13
arch/i386/crti.S
Executable file
13
arch/i386/crti.S
Executable file
|
@ -0,0 +1,13 @@
|
||||||
|
.section .init
|
||||||
|
.global _init
|
||||||
|
.type _init, @function
|
||||||
|
_init:
|
||||||
|
push %ebp
|
||||||
|
movl %esp, %ebp
|
||||||
|
|
||||||
|
.section .fini
|
||||||
|
.global _fini
|
||||||
|
.type _fini, @function
|
||||||
|
_fini:
|
||||||
|
push %ebp
|
||||||
|
movl %esp, %ebp
|
7
arch/i386/crtn.S
Executable file
7
arch/i386/crtn.S
Executable file
|
@ -0,0 +1,7 @@
|
||||||
|
.section .init
|
||||||
|
popl %ebp
|
||||||
|
ret
|
||||||
|
|
||||||
|
.section .fini
|
||||||
|
popl %ebp
|
||||||
|
ret
|
Loading…
Reference in a new issue