annotate 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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
99db6262c157 initial commit with code from http://wiki.osdev.org/Bare_bones
meillo@marmaro.de
parents:
diff changeset
1 global loader ; making entry point visible to linker
99db6262c157 initial commit with code from http://wiki.osdev.org/Bare_bones
meillo@marmaro.de
parents:
diff changeset
2 extern kmain ; main is defined elsewhere
99db6262c157 initial commit with code from http://wiki.osdev.org/Bare_bones
meillo@marmaro.de
parents:
diff changeset
3
99db6262c157 initial commit with code from http://wiki.osdev.org/Bare_bones
meillo@marmaro.de
parents:
diff changeset
4 ; setting up the Multiboot header - see GRUB docs for details
99db6262c157 initial commit with code from http://wiki.osdev.org/Bare_bones
meillo@marmaro.de
parents:
diff changeset
5 MODULEALIGN equ 1<<0 ; align loaded modules on page
99db6262c157 initial commit with code from http://wiki.osdev.org/Bare_bones
meillo@marmaro.de
parents:
diff changeset
6 ; boundaries
99db6262c157 initial commit with code from http://wiki.osdev.org/Bare_bones
meillo@marmaro.de
parents:
diff changeset
7 MEMINFO equ 1<<1 ; provide memory map
99db6262c157 initial commit with code from http://wiki.osdev.org/Bare_bones
meillo@marmaro.de
parents:
diff changeset
8 FLAGS equ MODULEALIGN | MEMINFO ; this is the Multiboot 'flag' field
99db6262c157 initial commit with code from http://wiki.osdev.org/Bare_bones
meillo@marmaro.de
parents:
diff changeset
9 MAGIC equ 0x1BADB002 ; 'magic number' lets bootloader find the header
99db6262c157 initial commit with code from http://wiki.osdev.org/Bare_bones
meillo@marmaro.de
parents:
diff changeset
10 CHECKSUM equ -(MAGIC + FLAGS) ; checksum required
99db6262c157 initial commit with code from http://wiki.osdev.org/Bare_bones
meillo@marmaro.de
parents:
diff changeset
11
99db6262c157 initial commit with code from http://wiki.osdev.org/Bare_bones
meillo@marmaro.de
parents:
diff changeset
12 section .multiboot
99db6262c157 initial commit with code from http://wiki.osdev.org/Bare_bones
meillo@marmaro.de
parents:
diff changeset
13 align 4
99db6262c157 initial commit with code from http://wiki.osdev.org/Bare_bones
meillo@marmaro.de
parents:
diff changeset
14 MultiBootHeader:
99db6262c157 initial commit with code from http://wiki.osdev.org/Bare_bones
meillo@marmaro.de
parents:
diff changeset
15 dd MAGIC
99db6262c157 initial commit with code from http://wiki.osdev.org/Bare_bones
meillo@marmaro.de
parents:
diff changeset
16 dd FLAGS
99db6262c157 initial commit with code from http://wiki.osdev.org/Bare_bones
meillo@marmaro.de
parents:
diff changeset
17 dd CHECKSUM
99db6262c157 initial commit with code from http://wiki.osdev.org/Bare_bones
meillo@marmaro.de
parents:
diff changeset
18
99db6262c157 initial commit with code from http://wiki.osdev.org/Bare_bones
meillo@marmaro.de
parents:
diff changeset
19 ; reserve initial kernel stack space
99db6262c157 initial commit with code from http://wiki.osdev.org/Bare_bones
meillo@marmaro.de
parents:
diff changeset
20 STACKSIZE equ 0x4000 ; that's 16k.
99db6262c157 initial commit with code from http://wiki.osdev.org/Bare_bones
meillo@marmaro.de
parents:
diff changeset
21
99db6262c157 initial commit with code from http://wiki.osdev.org/Bare_bones
meillo@marmaro.de
parents:
diff changeset
22 loader:
99db6262c157 initial commit with code from http://wiki.osdev.org/Bare_bones
meillo@marmaro.de
parents:
diff changeset
23 mov esp, stack+STACKSIZE ; set up the stack
99db6262c157 initial commit with code from http://wiki.osdev.org/Bare_bones
meillo@marmaro.de
parents:
diff changeset
24 push eax ; pass Multiboot magic number
99db6262c157 initial commit with code from http://wiki.osdev.org/Bare_bones
meillo@marmaro.de
parents:
diff changeset
25 push ebx ; pass Multiboot info structure
99db6262c157 initial commit with code from http://wiki.osdev.org/Bare_bones
meillo@marmaro.de
parents:
diff changeset
26 call kmain ; call kernel proper
99db6262c157 initial commit with code from http://wiki.osdev.org/Bare_bones
meillo@marmaro.de
parents:
diff changeset
27 cli
99db6262c157 initial commit with code from http://wiki.osdev.org/Bare_bones
meillo@marmaro.de
parents:
diff changeset
28 hang:
99db6262c157 initial commit with code from http://wiki.osdev.org/Bare_bones
meillo@marmaro.de
parents:
diff changeset
29 hlt ; halt machine should kernel return
99db6262c157 initial commit with code from http://wiki.osdev.org/Bare_bones
meillo@marmaro.de
parents:
diff changeset
30 jmp hang
99db6262c157 initial commit with code from http://wiki.osdev.org/Bare_bones
meillo@marmaro.de
parents:
diff changeset
31
99db6262c157 initial commit with code from http://wiki.osdev.org/Bare_bones
meillo@marmaro.de
parents:
diff changeset
32 section .bss
99db6262c157 initial commit with code from http://wiki.osdev.org/Bare_bones
meillo@marmaro.de
parents:
diff changeset
33 align 32
99db6262c157 initial commit with code from http://wiki.osdev.org/Bare_bones
meillo@marmaro.de
parents:
diff changeset
34 stack:
99db6262c157 initial commit with code from http://wiki.osdev.org/Bare_bones
meillo@marmaro.de
parents:
diff changeset
35 resb STACKSIZE ; reserve stack on a quadword boundary