So, first post. Anyway, I have already followed this (excellent) tutorial:
http://www.osdever.net/tutorials/view/brans-kernel-development-tutorialI have made some modifications though, I can't grub to find the kernel following it exactly. I used the Bare_Bones tutorial on the wiki for my ASM loader.
Anyway, I have an automated bash script to assemble, compile, link, write to floppy image, print the kernel location then boot it with qemu.
I use this code to get the size:
Code:
FILENAME=kernel.bin
FILESIZE=$(stat -c%b "$FILENAME")
echo
echo
echo "Use [kernel 200 + $FILESIZE]"
echo "Then [boot]"
.
Usually it will display 200+32.
However, when I use grub via
Code:
kernel 200+32
boot
It will load the kernel, however the whole (virtual) system will hang on "boot". However, sometimes it will boot just fine and print the two lines. (I only followed the tutorial up to the GDT part).
Following some experimenting, I found that there is still some data before 200+32. Here's the VERY VERY odd part: when the first command I run in the grub> prompt is loading the kernel, booting will hang. However, when I run something else before loading, for example "help", it loads and boots just fine.
I used
ftp://alpha.gnu.org/gnu/grub/grub-0.97-i386-pc.tar.gz as mentioned in the wiki, then used the stage1 and stage2 files. I would use my own,(ubuntu 10.4LTS) but it appears I have GRUB2, and that apparently doesn't have stage1 and 2. I use qemu.
Now, why this extremely odd behaviour? It is reproducible 99.9% of the time.
EDIT: Great, now I cannot accurately reproduce it. at all. It seems COMPLETELY random.