selfmade-os
diff loader.s @ 0:99db6262c157
initial commit with code from http://wiki.osdev.org/Bare_bones
author | meillo@marmaro.de |
---|---|
date | Sun, 01 Nov 2009 23:50:00 +0100 |
parents | |
children |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/loader.s Sun Nov 01 23:50:00 2009 +0100 1.3 @@ -0,0 +1,35 @@ 1.4 +global loader ; making entry point visible to linker 1.5 +extern kmain ; main is defined elsewhere 1.6 + 1.7 +; setting up the Multiboot header - see GRUB docs for details 1.8 +MODULEALIGN equ 1<<0 ; align loaded modules on page 1.9 +; boundaries 1.10 +MEMINFO equ 1<<1 ; provide memory map 1.11 +FLAGS equ MODULEALIGN | MEMINFO ; this is the Multiboot 'flag' field 1.12 +MAGIC equ 0x1BADB002 ; 'magic number' lets bootloader find the header 1.13 +CHECKSUM equ -(MAGIC + FLAGS) ; checksum required 1.14 + 1.15 +section .multiboot 1.16 +align 4 1.17 +MultiBootHeader: 1.18 + dd MAGIC 1.19 + dd FLAGS 1.20 + dd CHECKSUM 1.21 + 1.22 +; reserve initial kernel stack space 1.23 +STACKSIZE equ 0x4000 ; that's 16k. 1.24 + 1.25 +loader: 1.26 + mov esp, stack+STACKSIZE ; set up the stack 1.27 + push eax ; pass Multiboot magic number 1.28 + push ebx ; pass Multiboot info structure 1.29 + call kmain ; call kernel proper 1.30 + cli 1.31 +hang: 1.32 + hlt ; halt machine should kernel return 1.33 + jmp hang 1.34 + 1.35 +section .bss 1.36 +align 32 1.37 +stack: 1.38 + resb STACKSIZE ; reserve stack on a quadword boundary