Bran's Kernel - Compiles but doesn't work
Posted: Tue Mar 04, 2008 1:58 pm
Hello,
I'm just starting to look at OS development and came across the Bran tutorial and found I understood most of it. So I thought I'd set it up on my Slackware linux box and compile it so I could tinker.
I had a few problems with leading underscores and compiler warnings but these are now all fixed and the kernel compiles and links without any warning or errors. I am suspicious though as my version is 23k whereas Bran's original is 12K.
To test the kernel I found info on using GRUBs stage2_eltorito code to make a bootable CD. I put both my version of the kernel and Bran's original onto a CD image and booted it on Bochs. Bran's works as advertised but in Bochs all I get is a blank screen. So I burned the iso image onto a CDRW and booted it on a real system. Again Bran's worked as advertised but my version prints garbage on the screen.
Can anyone give me any clues as how to proceed?
I am using Slackware 11. GCC 3.4.6. NASM 0.98.39 and LD 2.15.92.0.2. My build script is included below..
#!/bin/bash
echo "cleaning old files..."
rm *.o
rm kernel.bin
echo "assembling start..."
nasm -f aout -o start.o start.asm
echo "compiling c files..."
COMPILE_FLAGS="-Wall -O -fstrength-reduce -fomit-frame-pointer -finline-functions -nostdinc -fno-builtin"
COMPILE_FLAGS2="-fleading-underscore"
gcc $COMPILE_FLAGS $COMPILE_FLAGS2 -I./include -c -o main.o main.c
gcc $COMPILE_FLAGS $COMPILE_FLAGS2 -I./include -c -o scrn.o scrn.c
gcc $COMPILE_FLAGS $COMPILE_FLAGS2 -I./include -c -o gdt.o gdt.c
gcc $COMPILE_FLAGS $COMPILE_FLAGS2 -I./include -c -o idt.o idt.c
gcc $COMPILE_FLAGS $COMPILE_FLAGS2 -I./include -c -o isrs.o isrs.c
gcc $COMPILE_FLAGS $COMPILE_FLAGS2 -I./include -c -o irq.o irq.c
gcc $COMPILE_FLAGS $COMPILE_FLAGS2 -I./include -c -o timer.o timer.c
gcc $COMPILE_FLAGS $COMPILE_FLAGS2 -I./include -c -o kb.o kb.c
echo "linking..."
ld -T link.ld -o kernel.bin start.o main.o scrn.o gdt.o idt.o isrs.o irq.o timer.o kb.o
echo "copying to iso structure..."
cp kernel.bin grubiso/iso/boot/
echo "done"
I've made minor changes to the original C files to get rid of compiler warnings. This just involved making main into an int and casting some assigns. Otherwise its as downloaded.
Thanks
Mark
I'm just starting to look at OS development and came across the Bran tutorial and found I understood most of it. So I thought I'd set it up on my Slackware linux box and compile it so I could tinker.
I had a few problems with leading underscores and compiler warnings but these are now all fixed and the kernel compiles and links without any warning or errors. I am suspicious though as my version is 23k whereas Bran's original is 12K.
To test the kernel I found info on using GRUBs stage2_eltorito code to make a bootable CD. I put both my version of the kernel and Bran's original onto a CD image and booted it on Bochs. Bran's works as advertised but in Bochs all I get is a blank screen. So I burned the iso image onto a CDRW and booted it on a real system. Again Bran's worked as advertised but my version prints garbage on the screen.
Can anyone give me any clues as how to proceed?
I am using Slackware 11. GCC 3.4.6. NASM 0.98.39 and LD 2.15.92.0.2. My build script is included below..
#!/bin/bash
echo "cleaning old files..."
rm *.o
rm kernel.bin
echo "assembling start..."
nasm -f aout -o start.o start.asm
echo "compiling c files..."
COMPILE_FLAGS="-Wall -O -fstrength-reduce -fomit-frame-pointer -finline-functions -nostdinc -fno-builtin"
COMPILE_FLAGS2="-fleading-underscore"
gcc $COMPILE_FLAGS $COMPILE_FLAGS2 -I./include -c -o main.o main.c
gcc $COMPILE_FLAGS $COMPILE_FLAGS2 -I./include -c -o scrn.o scrn.c
gcc $COMPILE_FLAGS $COMPILE_FLAGS2 -I./include -c -o gdt.o gdt.c
gcc $COMPILE_FLAGS $COMPILE_FLAGS2 -I./include -c -o idt.o idt.c
gcc $COMPILE_FLAGS $COMPILE_FLAGS2 -I./include -c -o isrs.o isrs.c
gcc $COMPILE_FLAGS $COMPILE_FLAGS2 -I./include -c -o irq.o irq.c
gcc $COMPILE_FLAGS $COMPILE_FLAGS2 -I./include -c -o timer.o timer.c
gcc $COMPILE_FLAGS $COMPILE_FLAGS2 -I./include -c -o kb.o kb.c
echo "linking..."
ld -T link.ld -o kernel.bin start.o main.o scrn.o gdt.o idt.o isrs.o irq.o timer.o kb.o
echo "copying to iso structure..."
cp kernel.bin grubiso/iso/boot/
echo "done"
I've made minor changes to the original C files to get rid of compiler warnings. This just involved making main into an int and casting some assigns. Otherwise its as downloaded.
Thanks
Mark