GRUB Kernel Loading
Posted: Fri Feb 18, 2011 6:30 pm
I am new to the forums and kernel development. I am currently a student at the University of Maryland, and am taking a class on OS development where we are adding on to a pre-existing kernel GeekOS. I am having alot of fun in this class right now, but I would like to start writing one from scratch, because I'm really interested and I think it would be alot of fun.
I have been going over the bare bones basic kernel tutorial, and I'm getting the kernel to load properly, but when I attempt to boot the kernel nothing happens.
Here is Makefile which basically does everything in the wiki automatically
Also here is my kernel.c source code
when I launch qemu with the floppy image, Grub starts up and after I type
grub> kernel 200+18 I get...
[Multiboot-elf, <0x100000:0x1014:0x4000>,shtab=0x106140,entry=0x10000c]
grub> boot
nothing happens after the boot command. I have an extern Kernel_Main in the loader.s file so it should be being called and the fact that the kernel 200+18 command is properly working tells me that there is nothing wrong with my loader anyway.
ok i got some questions. first can anyone tell me what they think the problem could be? Shouldn't this code be displaying the letter A in the qemu terminal. Second in the tutorial, the author said that everything has to be written in the kernel.c file, but I know that there has to be a way to compile and link seperate files into a flat binary file, does anyone know how to do this?
Any Help is greatly appreciated!
I have been going over the bare bones basic kernel tutorial, and I'm getting the kernel to load properly, but when I attempt to boot the kernel nothing happens.
Here is Makefile which basically does everything in the wiki automatically
Code: Select all
#
.PHONY: all clean run
NASM = nasm
CC = gcc
LD = ld
FLAGS = -nostdlib -nostartfiles -nodefaultlibs
OPT_FLAGS = -Wall -O2
KERNEL_SOURCE = ../src/kernel.c
MULTIBOOT_SOURCE = ../src/loader.s
LINK_SCRIPT = linker.ld
all: loader.o kernel.o kernel.bin fd.img
loader.o: $(MULTIBOOT_SOURCE)
$(NASM) -f elf $< -o $@
kernel.o: $(KERNEL_SOURCE)
$(CC) -c $< -o $@ $(FLAGS) $(OPT_FLAGS)
kernel.bin: loader.o kernel.o
$(LD) -T $(LINK_SCRIPT) $< kernel.o -o $@
fd.img:
cat stage1 stage2 pad kernel.bin > fd.img
clean:
rm -r -f *~ *.o
run:
qemu -vga std -fda fd.img
Code: Select all
/*
* NoobOS by xfelix
*/
void Kernel_Main(void* mb, int mn) {
unsigned char* vram = (unsigned char*)0xB8000;
vram[0] = 0x41;
vram[1] = 0x07;
}
grub> kernel 200+18 I get...
[Multiboot-elf, <0x100000:0x1014:0x4000>,shtab=0x106140,entry=0x10000c]
grub> boot
nothing happens after the boot command. I have an extern Kernel_Main in the loader.s file so it should be being called and the fact that the kernel 200+18 command is properly working tells me that there is nothing wrong with my loader anyway.
ok i got some questions. first can anyone tell me what they think the problem could be? Shouldn't this code be displaying the letter A in the qemu terminal. Second in the tutorial, the author said that everything has to be written in the kernel.c file, but I know that there has to be a way to compile and link seperate files into a flat binary file, does anyone know how to do this?
Any Help is greatly appreciated!