stdlibc: ~several fixes
[meinos.git] / kernel2 / crt0.asm
blob7db1e9c90ae574ac6a461445453c2222771699dc
1 ; meinOS - A unix-like x86 microkernel operating system
2 ; Copyright (C) 2008 Janosch Gräf <janosch.graef@gmx.net>
4 ; This program is free software: you can redistribute it and/or modify
5 ; it under the terms of the GNU General Public License as published by
6 ; the Free Software Foundation, either version 3 of the License, or
7 ; (at your option) any later version.
9 ; This program is distributed in the hope that it will be useful,
10 ; but WITHOUT ANY WARRANTY; without even the implied warranty of
11 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 ; GNU General Public License for more details.
14 ; You should have received a copy of the GNU General Public License
15 ; along with this program. If not, see <http://www.gnu.org/licenses/>.
17 global _start
18 global init_stack
19 global init_stacksize
20 extern main
22 ; setting up the Multiboot header - see GRUB docs for details
23 ; Flags:
24 ; ModuleAlign: false
25 ; MemoryMap: true
26 ; VideoMode: true
28 MST_FLAGS equ 0000000000000000b
29 OPT_FLAGS equ 0000000000000110b
30 FLAGS equ (MST_FLAGS<<16)|OPT_FLAGS
31 MAGIC equ 0x1BADB002 ; 'magic number' lets bootloader find the header
32 CHECKSUM equ -(MAGIC + FLAGS) ; checksum required
33 ; Video Info
34 VIDEOMODE equ 0 ; Textmode
35 VIDEOWIDTH equ 80 ; 80 Cols
36 VIDEOHEIGHT equ 25 ; 25 Lines
37 VIDEODEPTH equ 0 ; Depth
38 ; reserve initial kernel stack space
39 STACKSIZE equ 4*1024
41 section .text
42 align 4
44 MultiBootHeader:
45 dd MAGIC ; Magic number
46 dd FLAGS ; Flags
47 dd CHECKSUM ; Checksum
48 times 5 dd 0 ; unused fields
49 dd VIDEOMODE ; Videomode
50 dd VIDEOWIDTH ; Videowidth
51 dd VIDEOHEIGHT ; Videoheight
52 dd VIDEODEPTH ; Videodepth
54 _start:
55 mov esp, init_stack+STACKSIZE-4 ; set up the stack
57 push eax ; pass Multiboot magic number
58 push ebx ; pass Multiboot info structure
59 call main ; call kernel function
60 add esp,8
62 cli ; halt machine should kernel return
63 hlt
65 init_stacksize dd STACKSIZE
67 section .bss
68 align 4
70 init_stack:
71 resb STACKSIZE