How do I make a kernel file I can load?
|As with all things, you can do it several ways. You
can tell GCC to output a flat binary file with no
relocations, headers or any other information. I assume
this is what you want.
GCC -c my_kernel.c LD my_kernel.o -o kernel.bin -oformat binary -Ttext 0x100000
The "-c" GCC switch tells GCC to only compile to an object file and not run the link process.
Running LD with "-oformat binary" tells the linker you want your output file to be plain, no relocations, no header information, just a straight flat binary image.
"-Ttext 0x100000" tells linker you want your "text" (code segment) address to be at 1mb memory mark.
You have to of course, load your binary file image into the correct offset for it to run properly since all its relocations have been statically linked already.
Help! when I load my kernel my machine resets!
|Yes. DJGPP outputs 32bit protected mode code. When
your PC boots up it is in what is known as Real Mode, you
have to switch your machine into Protected Mode, THEN
jump to your kernel image.
How you do this is up to you. You can alter your bootsector code to load your file, switch to protected mode and jump to your kernel image (if you have enough room for the code in your bootsector!) or you can write a stub program and stick that on to the front of your kernel image (assuming it gets loaded below 1mb memory mark) OR you can write a stub program, load it in under 1mb memory mark and have that program load in your kernel image.