I decided to make a simple C kernel (hobbyist reasons).
The code I used for both the bootloader and the kernel is available at:
http://code.google.com/p/onyxkernel/wiki/FirstStep
I compile it like this:
Code: Select all
gcc -m32 -ffreestanding -fno-builtin -nostdlib -c *.c
nasm -f elf loader.asm -o loader.o
ld -Ttext 0x1000 -melf_i386 -o kernel.bin loader.o main.o video.o
nasm -f bin boot.asm -o boot.bin
cat boot.bin kernel.bin /dev/zero | dd iflag=fullblock bs=512 count=2880 of=floppy.img
But, the OS fails to run. I've tested it in VBox and Bochs. In VBox the cursor just freezes and the code fails to execute (the OS doesn't print anything). In Bochs, the emulator gets stuck in a kind of loop, where it fails with "3rd exception with no resolution" and then resets, only to have to same thing happen again. I've tried various different methods of compiling my kernel, but none of them seem to work. One thing I've also tried to to use QEMU to emulate my OS,
but I am running it inside a linux VirtualBox guest (which might affect the results). When I run the kernel (which uses the QEMU bootloader) using the -kernel parameter it fails with
Code: Select all
qemu: fatal: Trying to execute code outside RAM or ROM at 0x000a0000
When I try and run the actual floppy image, it becomes stuck trying to load my floppy image, writing "pflash_write: Unimplemented flash cmd sequence" to the console.