flat assembler
Message board for the users of flat assembler.

Index > High Level Languages > Accessing C main function?

Author
Thread Post new topic Reply to topic
rhyno_dagreat



Joined: 31 Jul 2006
Posts: 487
Location: Maryland, Unol Daleithiau
rhyno_dagreat 14 Mar 2007, 20:28
Hey, I'm trying to write an OS in a mix between FASM/C and was wondering if there's a way I can call my C main function from my bootloader in FASM (I'm using ld to link everything and am using ELF .o output files).

Thanks!

-Ryan
Post 14 Mar 2007, 20:28
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 14 Mar 2007, 20:38
so bootloader is in FASM. Bootloader should execute main() function of your kernel.

Where is your OS kernel stored? In what format? On what filesystem?
Post 14 Mar 2007, 20:38
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3175
Location: Denmark
f0dder 14 Mar 2007, 23:27
Piece of advice: don't call your kernel entry "main". Main is for C programs linked with libc, OS kernels generally don't (and shouldn't, imho) link against libc.

How do you call your entrypoint, though? Grab a copy of the ELF specs Smile
Post 14 Mar 2007, 23:27
View user's profile Send private message Visit poster's website Reply with quote
rhyno_dagreat



Joined: 31 Jul 2006
Posts: 487
Location: Maryland, Unol Daleithiau
rhyno_dagreat 15 Mar 2007, 21:37
Right now I'm not using a filesystem on it. I'm moreso focused on getting interrupts going before I worry about the HD. I want to compile everything to a flat binary right now. Now if I need to have a filesystem, I need to learn how to do filesystem programming (and if there are any good resources, please tell me if necessary right now).

Thanks, and my apologies if I make no sense, I have my obnoxious sister behind me.
Post 15 Mar 2007, 21:37
View user's profile Send private message Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3175
Location: Denmark
f0dder 15 Mar 2007, 23:06
Don't do a flat binary, using a proper file format (PE or ELF) for the kernel has a lot of advantages. And the difference in code for loading a raw kernel or a PE kernel is very small - I posted mine in some other topic.
Post 15 Mar 2007, 23:06
View user's profile Send private message Visit poster's website Reply with quote
rhyno_dagreat



Joined: 31 Jul 2006
Posts: 487
Location: Maryland, Unol Daleithiau
rhyno_dagreat 15 Mar 2007, 23:11
f0dder - For this to happen, I would need a filesystem. Do you know a good filesystem I could use and some docs explaining it?
Post 15 Mar 2007, 23:11
View user's profile Send private message Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3175
Location: Denmark
f0dder 15 Mar 2007, 23:17
Nah, you don't necessarily need a filesystem, there's plenty of ways you can load your kernel:

*) etherboot with NBI format kernel - super fast load, and really great if you have a NIC with flash memory. I do (or did, considering how long it is since I worked on my kernel) this when testing with my dedicated testbox with an intel eepro100 card.

*) transfer across serial cable - slow. Did this before getting the eepro.

*) put the kernel on a (no-filesystem) floppy right after the bootsector and read in directly.

*) load your kernel from DOS (and use FAT filesystem or whatever). Feels somewhat "dirty", but means you can focus on writing your kernel, instead of getting it loaded Wink.

*) iirc bochs has some "load kernel" hack mainly meant for linux, but which could be used for other stuff as well.
Post 15 Mar 2007, 23:17
View user's profile Send private message Visit poster's website Reply with quote
rhyno_dagreat



Joined: 31 Jul 2006
Posts: 487
Location: Maryland, Unol Daleithiau
rhyno_dagreat 15 Mar 2007, 23:19
Cool, thanks.
Post 15 Mar 2007, 23:19
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.