xref: /illumos-gate/usr/src/grub/grub-0.97/docs/boot.S (revision 1b8adde7)
17c478bd9Sstevel@tonic-gate/* boot.S - bootstrap the kernel */
27c478bd9Sstevel@tonic-gate/* Copyright (C) 1999, 2001  Free Software Foundation, Inc.
37c478bd9Sstevel@tonic-gate
47c478bd9Sstevel@tonic-gate   This program is free software; you can redistribute it and/or modify
57c478bd9Sstevel@tonic-gate   it under the terms of the GNU General Public License as published by
67c478bd9Sstevel@tonic-gate   the Free Software Foundation; either version 2 of the License, or
77c478bd9Sstevel@tonic-gate   (at your option) any later version.
87c478bd9Sstevel@tonic-gate
97c478bd9Sstevel@tonic-gate   This program is distributed in the hope that it will be useful,
107c478bd9Sstevel@tonic-gate   but WITHOUT ANY WARRANTY; without even the implied warranty of
117c478bd9Sstevel@tonic-gate   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
127c478bd9Sstevel@tonic-gate   GNU General Public License for more details.
137c478bd9Sstevel@tonic-gate
147c478bd9Sstevel@tonic-gate   You should have received a copy of the GNU General Public License
157c478bd9Sstevel@tonic-gate   along with this program; if not, write to the Free Software
167c478bd9Sstevel@tonic-gate   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
177c478bd9Sstevel@tonic-gate
187c478bd9Sstevel@tonic-gate#define ASM	1
197c478bd9Sstevel@tonic-gate#include <multiboot.h>
207c478bd9Sstevel@tonic-gate
217c478bd9Sstevel@tonic-gate	.text
227c478bd9Sstevel@tonic-gate
237c478bd9Sstevel@tonic-gate	.globl	start, _start
247c478bd9Sstevel@tonic-gatestart:
257c478bd9Sstevel@tonic-gate_start:
267c478bd9Sstevel@tonic-gate	jmp	multiboot_entry
277c478bd9Sstevel@tonic-gate
287c478bd9Sstevel@tonic-gate	/* Align 32 bits boundary.  */
297c478bd9Sstevel@tonic-gate	.align	4
307c478bd9Sstevel@tonic-gate
317c478bd9Sstevel@tonic-gate	/* Multiboot header.  */
327c478bd9Sstevel@tonic-gatemultiboot_header:
337c478bd9Sstevel@tonic-gate	/* magic */
347c478bd9Sstevel@tonic-gate	.long	MULTIBOOT_HEADER_MAGIC
357c478bd9Sstevel@tonic-gate	/* flags */
367c478bd9Sstevel@tonic-gate	.long	MULTIBOOT_HEADER_FLAGS
377c478bd9Sstevel@tonic-gate	/* checksum */
387c478bd9Sstevel@tonic-gate	.long	-(MULTIBOOT_HEADER_MAGIC + MULTIBOOT_HEADER_FLAGS)
397c478bd9Sstevel@tonic-gate#ifndef __ELF__
407c478bd9Sstevel@tonic-gate	/* header_addr */
417c478bd9Sstevel@tonic-gate	.long	multiboot_header
427c478bd9Sstevel@tonic-gate	/* load_addr */
437c478bd9Sstevel@tonic-gate	.long	_start
447c478bd9Sstevel@tonic-gate	/* load_end_addr */
457c478bd9Sstevel@tonic-gate	.long	_edata
467c478bd9Sstevel@tonic-gate	/* bss_end_addr */
477c478bd9Sstevel@tonic-gate	.long	_end
487c478bd9Sstevel@tonic-gate	/* entry_addr */
497c478bd9Sstevel@tonic-gate	.long	multiboot_entry
507c478bd9Sstevel@tonic-gate#endif /* ! __ELF__ */
517c478bd9Sstevel@tonic-gate
527c478bd9Sstevel@tonic-gatemultiboot_entry:
537c478bd9Sstevel@tonic-gate	/* Initialize the stack pointer.  */
547c478bd9Sstevel@tonic-gate	movl	$(stack + STACK_SIZE), %esp
557c478bd9Sstevel@tonic-gate
567c478bd9Sstevel@tonic-gate	/* Reset EFLAGS.  */
577c478bd9Sstevel@tonic-gate	pushl	$0
587c478bd9Sstevel@tonic-gate	popf
597c478bd9Sstevel@tonic-gate
607c478bd9Sstevel@tonic-gate	/* Push the pointer to the Multiboot information structure.  */
617c478bd9Sstevel@tonic-gate	pushl	%ebx
627c478bd9Sstevel@tonic-gate	/* Push the magic value.  */
637c478bd9Sstevel@tonic-gate	pushl	%eax
647c478bd9Sstevel@tonic-gate
657c478bd9Sstevel@tonic-gate	/* Now enter the C main function...  */
667c478bd9Sstevel@tonic-gate	call	EXT_C(cmain)
677c478bd9Sstevel@tonic-gate
687c478bd9Sstevel@tonic-gate	/* Halt.  */
697c478bd9Sstevel@tonic-gate	pushl	$halt_message
707c478bd9Sstevel@tonic-gate	call	EXT_C(printf)
717c478bd9Sstevel@tonic-gate
727c478bd9Sstevel@tonic-gateloop:	hlt
737c478bd9Sstevel@tonic-gate	jmp	loop
747c478bd9Sstevel@tonic-gate
757c478bd9Sstevel@tonic-gatehalt_message:
767c478bd9Sstevel@tonic-gate	.asciz	"Halted."
777c478bd9Sstevel@tonic-gate
787c478bd9Sstevel@tonic-gate	/* Our stack area.  */
797c478bd9Sstevel@tonic-gate	.comm	stack, STACK_SIZE
807c478bd9Sstevel@tonic-gate