Page 1 of 1

Sharing Data Between Loader & Kernel

Posted: Mon Aug 17, 2009 10:44 am
by Abunada
Hi guys,

I just wanted to ask is their a way to include C header files into assembly language sources, I use the GNU Assembler (AT&T syntax) to assemble my loader and GCC to compile my kernel. The reason I am asking, is that I've had troubles sharing data between my loader and my kernel (BTW I don't use the multi-boot specification). What I do typically is set up a memory location that the loader can write to, which can be read later by the kernel. As my loader grew in functionality, the amount of information sent and received between my kernel and my loader increased, it has become really cumbersome to manage all these offsets. What I'd like is to do is declare these offsets in a single loader.h file and include it into both my loader (Assembly) and my kernel sources (C Sources).

Cheers
Abdullah

Re: Sharing Data Between BIOS & Kernel

Posted: Mon Aug 17, 2009 11:02 am
by NickJohnson
I'm not quite sure what this has to do with the BIOS, but it's possible to use the C preprocessor on things other than C, as long as they don't use the #, /*, */, or // symbols for anything, along with some other little things, mostly having to do with whitespace and quotes. I think you can just do something like this, although I haven't tried it:

header.h

Code: Select all

#define ADDRESS 0x1000
assembly.s

Code: Select all

#include "header.h"

function:
    mov edi, ADDRESS
    ...

    ret
Then run something like "cpp -x assembler-with-cpp assembly.s" before assembling.

Hope this helps/works!

Re: Sharing Data Between BIOS & Kernel

Posted: Mon Aug 17, 2009 11:07 am
by Abunada
So the command "cpp -x assembler-with-cpp assembly.s" simply runs the C pre-processor on the file. Sounds like its going to work. Thanks a lot, I am off to try it. Oh and sorry what I meant was loader instead of BIOS :oops:

Cheers