Simplified boot script.
This commit is contained in:
parent
eee9b56f86
commit
c05bcbec88
80
boot.s
80
boot.s
@ -1,58 +1,32 @@
|
|||||||
global start
|
; http://wiki.osdev.org/Bare_Bones_with_NASM
|
||||||
extern kernel_main ; Allow main() to be called from the assembly code
|
MBALIGN equ 1<<0 ; align loaded modules on page boundaries
|
||||||
extern start_ctors, end_ctors, start_dtors, end_dtors
|
MEMINFO equ 1<<1 ; provide memory map
|
||||||
|
FLAGS equ MBALIGN | MEMINFO ; this is the Multiboot 'flag' field
|
||||||
MODULEALIGN equ 1<<0
|
MAGIC equ 0x1BADB002 ; 'magic number' lets bootloader find the header
|
||||||
MEMINFO equ 1<<1
|
CHECKSUM equ -(MAGIC + FLAGS) ; checksum of above, to prove we are multiboot
|
||||||
FLAGS equ MODULEALIGN | MEMINFO
|
|
||||||
MAGIC equ 0x1BADB002
|
|
||||||
CHECKSUM equ -(MAGIC + FLAGS)
|
|
||||||
|
|
||||||
section .text ; Next is the Grub Multiboot Header
|
|
||||||
|
|
||||||
|
section .multiboot
|
||||||
align 4
|
align 4
|
||||||
MultiBootHeader:
|
dd MAGIC
|
||||||
dd MAGIC
|
dd FLAGS
|
||||||
dd FLAGS
|
dd CHECKSUM
|
||||||
dd CHECKSUM
|
|
||||||
|
|
||||||
STACKSIZE equ 0x4000 ; 16 KiB if you're wondering
|
|
||||||
|
|
||||||
static_ctors_loop:
|
|
||||||
mov ebx, start_ctors
|
|
||||||
jmp .test
|
|
||||||
.body:
|
|
||||||
call [ebx]
|
|
||||||
add ebx,4
|
|
||||||
.test:
|
|
||||||
cmp ebx, end_ctors
|
|
||||||
jb .body
|
|
||||||
|
|
||||||
start:
|
|
||||||
mov esp, STACKSIZE+stack
|
|
||||||
|
|
||||||
push eax
|
|
||||||
push ebx
|
|
||||||
|
|
||||||
call kernel_main
|
|
||||||
|
|
||||||
static_dtors_loop:
|
|
||||||
mov ebx, start_dtors
|
|
||||||
jmp .test
|
|
||||||
.body:
|
|
||||||
call [ebx]
|
|
||||||
add ebx,4
|
|
||||||
.test:
|
|
||||||
cmp ebx, end_dtors
|
|
||||||
jb .body
|
|
||||||
|
|
||||||
|
|
||||||
cpuhalt:
|
|
||||||
hlt
|
|
||||||
jmp cpuhalt
|
|
||||||
|
|
||||||
section .bss
|
section .bss
|
||||||
align 32
|
align 16
|
||||||
|
stack_bottom:
|
||||||
|
resb 16384 ; 16 KiB
|
||||||
|
stack_top:
|
||||||
|
|
||||||
stack:
|
section .text
|
||||||
resb STACKSIZE
|
global _start:function (_start.end - _start)
|
||||||
|
_start:
|
||||||
|
|
||||||
|
mov esp, stack_top
|
||||||
|
|
||||||
|
extern kernel_main
|
||||||
|
call kernel_main
|
||||||
|
|
||||||
|
cli
|
||||||
|
.hang: hlt
|
||||||
|
jmp .hang
|
||||||
|
.end:
|
||||||
|
Loading…
Reference in New Issue
Block a user