Mercurial > selfmade-os
comparison 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 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:99db6262c157 |
---|---|
1 global loader ; making entry point visible to linker | |
2 extern kmain ; main is defined elsewhere | |
3 | |
4 ; setting up the Multiboot header - see GRUB docs for details | |
5 MODULEALIGN equ 1<<0 ; align loaded modules on page | |
6 ; boundaries | |
7 MEMINFO equ 1<<1 ; provide memory map | |
8 FLAGS equ MODULEALIGN | MEMINFO ; this is the Multiboot 'flag' field | |
9 MAGIC equ 0x1BADB002 ; 'magic number' lets bootloader find the header | |
10 CHECKSUM equ -(MAGIC + FLAGS) ; checksum required | |
11 | |
12 section .multiboot | |
13 align 4 | |
14 MultiBootHeader: | |
15 dd MAGIC | |
16 dd FLAGS | |
17 dd CHECKSUM | |
18 | |
19 ; reserve initial kernel stack space | |
20 STACKSIZE equ 0x4000 ; that's 16k. | |
21 | |
22 loader: | |
23 mov esp, stack+STACKSIZE ; set up the stack | |
24 push eax ; pass Multiboot magic number | |
25 push ebx ; pass Multiboot info structure | |
26 call kmain ; call kernel proper | |
27 cli | |
28 hang: | |
29 hlt ; halt machine should kernel return | |
30 jmp hang | |
31 | |
32 section .bss | |
33 align 32 | |
34 stack: | |
35 resb STACKSIZE ; reserve stack on a quadword boundary |