xref: /titanic_52/usr/src/grub/grub-0.97/docs/boot.S (revision 69112edd987c28fa551d4f8d9362a84a45365f17)
1/* boot.S - bootstrap the kernel */
2/* 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	/* Align 32 bits boundary.  */
29	.align	4
30
31	/* Multiboot header.  */
32multiboot_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__ */
51
52multiboot_entry:
53	/* Initialize the stack pointer.  */
54	movl	$(stack + STACK_SIZE), %esp
55
56	/* Reset EFLAGS.  */
57	pushl	$0
58	popf
59
60	/* Push the pointer to the Multiboot information structure.  */
61	pushl	%ebx
62	/* Push the magic value.  */
63	pushl	%eax
64
65	/* Now enter the C main function...  */
66	call	EXT_C(cmain)
67
68	/* Halt.  */
69	pushl	$halt_message
70	call	EXT_C(printf)
71
72loop:	hlt
73	jmp	loop
74
75halt_message:
76	.asciz	"Halted."
77
78	/* Our stack area.  */
79	.comm	stack, STACK_SIZE
80