views:

586

answers:

1

I'd like to build an embedded kernel for an x86 machine using Visual C++. I have some C and assembly code files to compile and I'd like to link them all together in a way that is compatible with a Multiboot bootloader like GRUB.

+4  A: 

OSDev has a wiki entry on Visual Studio, that may provide some insight, especially with the links to Kaushik Srenevasan's blog entries on the subject of PE kernels designed to be loaded by multiboot-based bootloaders (like GRUB).

A couple of large, broad-strokes things you should know:

  • In the multiboot header, you need to use the AOUT kludge.
  • You need to specify the /BASE:0x100000 argument to the linker, so the final binary code is based to where the bootloader is going to put it.
  • Your kernel's entry point (usually called 'kmain') needs to have __declspec(noreturn) on it, and you will need to do an __asm { hlt } instead of returning.
Alex Lyman
Copy-and-paste doesn't work here, either, but points to the mistake: it looks like "...kernels-using%5F03.html", but should be "...kernels-using_03.html".
Anonymous Coward
Alex Lyman
Ok, I sent an email to the SO Team, and they pointed out that there are other ways to make a link, so I switched it to one that works.
Alex Lyman
Great links, thanks for this info
Frank Miller