Page 1 of 1

GRUB Multiboot header

Posted: Mon Apr 05, 2004 11:00 pm
by bilbo
hi,
  
   I am trying to figure out how to create a kernel that GRUB will boot (written in C), and so far all that I know is that it has to be ELF and have a Multiboot header... now I really dont get the purpose of the multiboot header and or how to create one that will allow me to load a "Hello World Kernel", can someone please help me?, can someone give me an example of a hello world kernel with an operatinal Multiboot header?, Thanx everyone ;)

RE:GRUB Multiboot header

Posted: Tue Apr 06, 2004 11:00 pm
by Moose
Below is the asm code i have in my start.asm file. This is the entry point used to boot my kernel and contains the multiboot header.
It also has an include multiboot.h that is after the start.asm file below that contains some defines used in the header (a define is like dynamic variable you can declare that doesn't take up space, each define inside the code is replaced with the actual define value. So MBOOT_FLAGS define below gets replaced with 0x00000002)

This header also does not use the 'aout' kludge. I made it myself thus only works on elf. If you need an example of the aout kludge details goto http://www.mcc.ac.uk/Documentation/grub ... t_toc.html and look at the example source code.

Moose

; AcOS - start.asm
; Last Updated: 09/04/2003

; GNU General Public License
; This file is part of AcOS.

; AcOS is free software; you can redistribute it and/or modify
; it under the terms of the GNU General Public License as published by
; the Free Software Foundation; either version 2 of the License, or
; (at your option) any later version.

; AcOS is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
; GNU General Public License for more details.

; You should have received a copy of the GNU General Public License
; along with AcOS; if not, write to the Free Software
; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

; Copyright 2003 Simon Paulger

[BITS 32]
[SECTION .text]

%include "include/start.h"
%include "include/multiboot.h"

multiboot_header:
align 4, db 0 ; Align to dword boundary
dd MBOOT_MAGIC1 ; Multiboot magic header
dd MBOOT_FLAGS ; Flags information
dd 0 - (MBOOT_MAGIC1 + MBOOT_FLAGS)

_start:
start:


; AcOS - multiboot.h
; Last Updated: 02/04/2003

; GNU General Public License
; This file is part of AcOS.

; AcOS is free software; you can redistribute it and/or modify
; it under the terms of the GNU General Public License as published by
; the Free Software Foundation; either version 2 of the License, or
; (at your option) any later version.

; AcOS is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
; GNU General Public License for more details.

; You should have received a copy of the GNU General Public License
; along with AcOS; if not, write to the Free Software
; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

; Copyright 2003 Simon Paulger

; Globals

; Externs

; Defines
%define MBOOT_MAGIC1 0x1BADB002 ; 'Magic' multi-boot header
%define MBOOT_MAGIC2 0x2BADB002 ; 'Magic' multi-boot botted success response
%define MBOOT_FLAGS 0x00000002 ; Flags for multi-booting

RE:GRUB Multiboot header

Posted: Tue Apr 06, 2004 11:00 pm
by Neil Dökkalfar
Read the manual (short and easy) : http://www.gnu.org/software/grub/manual/multiboot/
There is a good example with a multiboot loader (in gas asm) and a sample helloworld kernel (in C).

RE:GRUB Multiboot header

Posted: Tue Apr 06, 2004 11:00 pm
by bilbo
Thank you... for  the reference to the multiboot example... although I have already seen it before and cannot figure out how to compile it using gcc for linux  , can anybody help me with compiling it>?