1*1b8adde7SWilliam Kucharski/* boot.S - bootstrap the kernel */ 2*1b8adde7SWilliam Kucharski/* Copyright (C) 1999, 2001 Free Software Foundation, Inc. 3*1b8adde7SWilliam Kucharski 4*1b8adde7SWilliam Kucharski This program is free software; you can redistribute it and/or modify 5*1b8adde7SWilliam Kucharski it under the terms of the GNU General Public License as published by 6*1b8adde7SWilliam Kucharski the Free Software Foundation; either version 2 of the License, or 7*1b8adde7SWilliam Kucharski (at your option) any later version. 8*1b8adde7SWilliam Kucharski 9*1b8adde7SWilliam Kucharski This program is distributed in the hope that it will be useful, 10*1b8adde7SWilliam Kucharski but WITHOUT ANY WARRANTY; without even the implied warranty of 11*1b8adde7SWilliam Kucharski MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12*1b8adde7SWilliam Kucharski GNU General Public License for more details. 13*1b8adde7SWilliam Kucharski 14*1b8adde7SWilliam Kucharski You should have received a copy of the GNU General Public License 15*1b8adde7SWilliam Kucharski along with this program; if not, write to the Free Software 16*1b8adde7SWilliam Kucharski Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ 17*1b8adde7SWilliam Kucharski 18*1b8adde7SWilliam Kucharski#define ASM 1 19*1b8adde7SWilliam Kucharski#include <multiboot.h> 20*1b8adde7SWilliam Kucharski 21*1b8adde7SWilliam Kucharski .text 22*1b8adde7SWilliam Kucharski 23*1b8adde7SWilliam Kucharski .globl start, _start 24*1b8adde7SWilliam Kucharskistart: 25*1b8adde7SWilliam Kucharski_start: 26*1b8adde7SWilliam Kucharski jmp multiboot_entry 27*1b8adde7SWilliam Kucharski 28*1b8adde7SWilliam Kucharski /* Align 32 bits boundary. */ 29*1b8adde7SWilliam Kucharski .align 4 30*1b8adde7SWilliam Kucharski 31*1b8adde7SWilliam Kucharski /* Multiboot header. */ 32*1b8adde7SWilliam Kucharskimultiboot_header: 33*1b8adde7SWilliam Kucharski /* magic */ 34*1b8adde7SWilliam Kucharski .long MULTIBOOT_HEADER_MAGIC 35*1b8adde7SWilliam Kucharski /* flags */ 36*1b8adde7SWilliam Kucharski .long MULTIBOOT_HEADER_FLAGS 37*1b8adde7SWilliam Kucharski /* checksum */ 38*1b8adde7SWilliam Kucharski .long -(MULTIBOOT_HEADER_MAGIC + MULTIBOOT_HEADER_FLAGS) 39*1b8adde7SWilliam Kucharski#ifndef __ELF__ 40*1b8adde7SWilliam Kucharski /* header_addr */ 41*1b8adde7SWilliam Kucharski .long multiboot_header 42*1b8adde7SWilliam Kucharski /* load_addr */ 43*1b8adde7SWilliam Kucharski .long _start 44*1b8adde7SWilliam Kucharski /* load_end_addr */ 45*1b8adde7SWilliam Kucharski .long _edata 46*1b8adde7SWilliam Kucharski /* bss_end_addr */ 47*1b8adde7SWilliam Kucharski .long _end 48*1b8adde7SWilliam Kucharski /* entry_addr */ 49*1b8adde7SWilliam Kucharski .long multiboot_entry 50*1b8adde7SWilliam Kucharski#endif /* ! __ELF__ */ 51*1b8adde7SWilliam Kucharski 52*1b8adde7SWilliam Kucharskimultiboot_entry: 53*1b8adde7SWilliam Kucharski /* Initialize the stack pointer. */ 54*1b8adde7SWilliam Kucharski movl $(stack + STACK_SIZE), %esp 55*1b8adde7SWilliam Kucharski 56*1b8adde7SWilliam Kucharski /* Reset EFLAGS. */ 57*1b8adde7SWilliam Kucharski pushl $0 58*1b8adde7SWilliam Kucharski popf 59*1b8adde7SWilliam Kucharski 60*1b8adde7SWilliam Kucharski /* Push the pointer to the Multiboot information structure. */ 61*1b8adde7SWilliam Kucharski pushl %ebx 62*1b8adde7SWilliam Kucharski /* Push the magic value. */ 63*1b8adde7SWilliam Kucharski pushl %eax 64*1b8adde7SWilliam Kucharski 65*1b8adde7SWilliam Kucharski /* Now enter the C main function... */ 66*1b8adde7SWilliam Kucharski call EXT_C(cmain) 67*1b8adde7SWilliam Kucharski 68*1b8adde7SWilliam Kucharski /* Halt. */ 69*1b8adde7SWilliam Kucharski pushl $halt_message 70*1b8adde7SWilliam Kucharski call EXT_C(printf) 71*1b8adde7SWilliam Kucharski 72*1b8adde7SWilliam Kucharskiloop: hlt 73*1b8adde7SWilliam Kucharski jmp loop 74*1b8adde7SWilliam Kucharski 75*1b8adde7SWilliam Kucharskihalt_message: 76*1b8adde7SWilliam Kucharski .asciz "Halted." 77*1b8adde7SWilliam Kucharski 78*1b8adde7SWilliam Kucharski /* Our stack area. */ 79*1b8adde7SWilliam Kucharski .comm stack, STACK_SIZE 80*1b8adde7SWilliam Kucharski