xref: /titanic_41/usr/src/grub/grub-0.97/docs/boot.S.texi (revision bdb9230ac765cb7af3fc1f4119caf2c5720dceb3)
1/* @r{boot.S - bootstrap the kernel} */
2/* @r{Copyright (C) 1999, 2001  Free Software Foundation, Inc.
3
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.
13
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.} */
17
18#define ASM     1
19#include <multiboot.h>
20
21        .text
22
23        .globl  start, _start
24start:
25_start:
26        jmp     multiboot_entry
27
28        /* @r{Align 32 bits boundary.} */
29        .align  4
30
31        /* @r{Multiboot header.} */
32multiboot_header:
33        /* @r{magic} */
34        .long   MULTIBOOT_HEADER_MAGIC
35        /* @r{flags} */
36        .long   MULTIBOOT_HEADER_FLAGS
37        /* @r{checksum} */
38        .long   -(MULTIBOOT_HEADER_MAGIC + MULTIBOOT_HEADER_FLAGS)
39#ifndef __ELF__
40        /* @r{header_addr} */
41        .long   multiboot_header
42        /* @r{load_addr} */
43        .long   _start
44        /* @r{load_end_addr} */
45        .long   _edata
46        /* @r{bss_end_addr} */
47        .long   _end
48        /* @r{entry_addr} */
49        .long   multiboot_entry
50#endif /* @r{! __ELF__} */
51
52multiboot_entry:
53        /* @r{Initialize the stack pointer.} */
54        movl    $(stack + STACK_SIZE), %esp
55
56        /* @r{Reset EFLAGS.} */
57        pushl   $0
58        popf
59
60        /* @r{Push the pointer to the Multiboot information structure.} */
61        pushl   %ebx
62        /* @r{Push the magic value.} */
63        pushl   %eax
64
65        /* @r{Now enter the C main function...} */
66        call    EXT_C(cmain)
67
68        /* @r{Halt.} */
69        pushl   $halt_message
70        call    EXT_C(printf)
71
72loop:   hlt
73        jmp     loop
74
75halt_message:
76        .asciz  "Halted."
77
78        /* @r{Our stack area.} */
79        .comm   stack, STACK_SIZE
80