GRUB Problem... again!

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
Mastermind

GRUB Problem... again!

Post by Mastermind »

I'm trying to switch to using GRUB to boot up my OS. I've got it installed on my floppy disk. I cannot load my OS from it. I figured that this may be because my OS is not "multiboot compliant." What is "multiboot compliance" and how can I make my OS compliant? Is there a solution?

The OS runs fine from my current loader, so it cannot be a programming error...

??? ??? ??? ???
Parabola1

Re:GRUB Problem... again!

Post by Parabola1 »

Just did this today for myself. :)

Here are a few links to help you.

The big multiboot specification: http://www.mcc.ac.uk/grub/multiboot_toc.html

The "quickstart" guide to grub and multiboot: http://osdev.neopages.net/tutorials/grub.php

That last link was the most helpful. Just compile your kernel as an ELF executable and use the "simple multiboot header" there.

What I did is create a simple multiboot ASM file with:

Code: Select all

MULTIBOOT_PAGE_ALIGN    equ     1<<0
MULTIBOOT_MEMORY_INFO   equ     1<<1

MULTIBOOT_HEADER_MAGIC  equ     0x1BADB002
MULTIBOOT_HEADER_FLAGS  equ     MULTIBOOT_PAGE_ALIGN | MULTIBOOT_MEMORY_INFO
CHECKSUM equ -(MULTIBOOT_HEADER_MAGIC + MULTIBOOT_HEADER_FLAGS)

    ; The Multiboot header (in NASM syntax)
        align 4
        dd MULTIBOOT_HEADER_MAGIC
        dd MULTIBOOT_HEADER_FLAGS
        dd CHECKSUM
and then used my build script to build and link it:

Code: Select all

#!/bin/bash

nasm -f elf -o bin/mbhead.o code/mbhead.s
gcc -fno-builtin -c code/kernel.c -o bin/kernel.o
ld -o kernel.bin --oformat elf32-i386 -Ttext 0x100000 -e kernel bin/mbhead.o bin/kernel.o
and voila! (I think). While grub seems to like the kernel, and it seems to be booting, the catch is that since my kernel currently consists of a "while (1) do;", i'm not sure what is actually happening yet. :-D

Good luck!
Mastermind

GRUB Problem... solved!

Post by Mastermind »

:) :) Cool! Got it working! Thanks!!! :) :)
Post Reply