Hi,
I've been able to create a bootloader using the "Hello World" bootloader tutorial on osdever.net, however, I can't figure out how to make the bootloader load the kernel. I want to write the kernel in C++, but obviously I can't assemble it all into the bootload.bin file that will go on the first 512 bytes of the floppy cause it won't all fit in 512 bytes . So my questions are:
1. How do I compile C++ code into .bin (or whatever I need)?
2. How do I put that on the floppy and start it from the bootloader?
Thanks.
Need help getting past bootload.asm
Re: Need help getting past bootload.asm
You will need to either compile your kernel in to flat binary format, or use something more structured like ELF. For the latter, your boot loader needs to know how to relocate executable files.ubergeek wrote: 1. How do I compile C++ code into .bin (or whatever I need)?
Using C++, compile all your objects as usual and then link with a linker script. A good example of this is shown at http://www.osdever.net/bkerndev/index.php (only thing you will find is that you need an .rodata section along with the data section). Although Bran's tutorial is C, I would recommend at least reading through all the sections before you attempt a C++ kernel.
Another thing you will eventually need is a section for *.ctors and *.dtors. When you write your C++ kernel, you will have to write run time support for global and static constructors and destructors, new and delete operators, rtti, exceptions etc... Once you have a good memory manager in your kernel, the constructors and destructors, new and delete are pretty easy to implement. Even using C++, you will probably find that your memory manager ends up being 'C-Style'.
I would suggest using GRUB here (you will find heaps of information on this in the wiki, on osdever and around the web). This will switch to protected mode, read from the disk, relocate your kernel and load any modules you require.2. How do I put that on the floppy and start it from the bootloader?
If you want to roll your own boot loader, you will have to do all this yourself. For reading from a FAT12 floppy disk, I learned this from BOS, which has a very easy-to-understand boot loader.
The general idea with that is that your FAT12-reading code goes in the 512 byte boot sector. It loads a second-stage loader from the disk which can then be any size (up to the size of a real-mode segment). That then sets up the machine properly and loads your kernel.
HTH
Adam
Re: Need help getting past bootload.asm
I concur. A good bootloader is like a miniature operating system in itself. Start with GRUB, then make your own bootloader later if you really want.AJ wrote:I would suggest using GRUB
Also GRUB is really easy to use.
But then that's me; I'm using tcc to do all my compiling and linking.
-
- Member
- Posts: 199
- Joined: Fri Jul 13, 2007 6:37 am
- Location: Stuttgart/Germany
- Contact:
Re: Need help getting past bootload.asm
Read here:ubergeek wrote:1. How do I compile C++ code into .bin (or whatever I need)?
http://www.google.es/url?sa=t&ct=res&cd ... QvQNdDpspg