Booting the kernel

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
desjardins

Booting the kernel

Post by desjardins »

Ive been playing around with writing an OS and started by making a very simple boot loader (enter PM, write some stuff). Now that I understand its basics I want to move on to the kernel. I wrote a simple assembly wrapper that calls an empty c function and included the multiboot stuff so that GRUB can boot it.

What im a bit confused on is how I should create disk images for testing under bochs, or even for real booting. Some sites demonstrate loading a kernel by writing a boot loader and performing raw disk i/o, other create a dos/ext floppy disk.

Grub can read dos/ext, so should I just be creating a ext/dos disk, copy my kernel.bin onto it and tell grub to load it. What about when I want to implement my own filesystem? If the system is starting off a ext/dos disk, how will I be able to create my own filesystem implementation?

If the best choice is to go with GRUB + ext/dos, how would I create an image that works under bochs? I know how to create a simple HD image and write an MBR to it, but not how to create an image, format with an FS, install GRUB + kernel.

My development environment is FreeBSD.
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:Booting the kernel

Post by Pype.Clicker »

well, you can perfectly have a *second* disk image (either a hard disk or another floppy) that will contain data with the filesystem of your choice.
B.E

Re:Booting the kernel

Post by B.E »

I Would perform raw disk i/o, because you have control over what filesystem your os runs in, you'll have to learn raw disk i/o when it come to running a program on your os and learning raw disk i/o is interresting.
mystran

Re:Booting the kernel

Post by mystran »

I would imagine that it would be possible to write a filesystem driver for GRUB that understand you own filesystem. In fact, I'd imagine it wouldn't be that hard, because it would only need to be able to locate the file.

That said, I have not checked how this is done, so I might be completely wrong, and it might be the worst possible horror.
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:Booting the kernel

Post by Pype.Clicker »

as a final move, you may also format your floppy with your native FS, keeping space for GRUB on it and give GRUB a list of sector where your kernel (and other modules) are found on your system. This is unfortunately very ugly and need constant attention when you touch kernel files (etc), but it works (and it's how Lilo worked for ages)
desjardins

Re:Booting the kernel

Post by desjardins »

What I was looking into trying was my own boot loader. I made a simple one that starts up and enters protected mode. Now I just need to figure out how to read in a number of sectors off the disk and begin executing it.

I did come across some code that was similar,but they linked some assembly and c into the boot loader and the c code performed the IO.

Does anyone know of a tutorial or reference on how to load the sectors using raw i/o? Or am I better off using the bios to load the sectors...
Post Reply