Sharing Data Between Loader & 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
Abunada
Posts: 17
Joined: Mon Jun 08, 2009 4:36 am

Sharing Data Between Loader & Kernel

Post 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
Last edited by Abunada on Mon Aug 17, 2009 11:09 am, edited 1 time in total.
User avatar
NickJohnson
Member
Member
Posts: 1249
Joined: Tue Mar 24, 2009 8:11 pm
Location: Sunnyvale, California

Re: Sharing Data Between BIOS & Kernel

Post 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!
Abunada
Posts: 17
Joined: Mon Jun 08, 2009 4:36 am

Re: Sharing Data Between BIOS & Kernel

Post 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
Post Reply