Merge branch 'master' of git://github.com/illumos/illumos-gate
[unleashed.git] / usr / src / grub / grub-0.97 / docs / boot.S
blobb0e167f83c16982b884f9d0404eff4e537290dcf
1 /* boot.S - bootstrap the kernel */
2 /* Copyright (C) 1999, 2001  Free Software Foundation, Inc.
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 2 of the License, or
7    (at your option) any later version.
8  
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, write to the Free Software
16    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
18 #define ASM     1
19 #include <multiboot.h>
20         
21         .text
23         .globl  start, _start
24 start:
25 _start:
26         jmp     multiboot_entry
28         /* Align 32 bits boundary.  */
29         .align  4
30         
31         /* Multiboot header.  */
32 multiboot_header:
33         /* magic */
34         .long   MULTIBOOT_HEADER_MAGIC
35         /* flags */
36         .long   MULTIBOOT_HEADER_FLAGS
37         /* checksum */
38         .long   -(MULTIBOOT_HEADER_MAGIC + MULTIBOOT_HEADER_FLAGS)
39 #ifndef __ELF__
40         /* header_addr */
41         .long   multiboot_header
42         /* load_addr */
43         .long   _start
44         /* load_end_addr */
45         .long   _edata
46         /* bss_end_addr */
47         .long   _end
48         /* entry_addr */
49         .long   multiboot_entry
50 #endif /* ! __ELF__ */
52 multiboot_entry:
53         /* Initialize the stack pointer.  */
54         movl    $(stack + STACK_SIZE), %esp
56         /* Reset EFLAGS.  */
57         pushl   $0
58         popf
60         /* Push the pointer to the Multiboot information structure.  */
61         pushl   %ebx
62         /* Push the magic value.  */
63         pushl   %eax
65         /* Now enter the C main function...  */
66         call    EXT_C(cmain)
68         /* Halt.  */
69         pushl   $halt_message
70         call    EXT_C(printf)
71         
72 loop:   hlt
73         jmp     loop
75 halt_message:
76         .asciz  "Halted."
78         /* Our stack area.  */
79         .comm   stack, STACK_SIZE
80