Tasks

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
enrico_granata
Posts: 21
Joined: Tue Jul 24, 2007 1:19 am

Tasks

Post by enrico_granata »

I am developing an OS in C++/C/ASM starting from Bran's tutorial
I can allocate and free memory correctly, read the keyboard, write on screen and reboot by pressing CTRL+ALT+DEL (as in Bran's tutorial I am making segmentation transparent so linear and physical addresses match)
The thing is I now would like to add some user programs to the OS. I'd like to start out with something simpe like single-tasking and no memory protection. I was thinking to build pure binary images of processes and somehow launch them. What I don't understand is if I should locate them at a fixed address or let the linker make out the addresses it wants and expect everything to work when I load the image and jump to it

Thanks for any help,
Enrico
Computer science: all about things that "should" work
jnc100
Member
Member
Posts: 775
Joined: Mon Apr 09, 2007 12:10 pm
Location: London, UK
Contact:

Post by jnc100 »

On each platform you can use ld on, it contains a built in linker script which locates the sections at certain predefined values. Generally, you want user programs to be loaded at such a point in virtual memory where they don't overlap your kernel. For example, if you're using a higher half kernel, locating your process' text section at 1MB is fine. The exact values are up to you, but I suggest you define a default linker script for your userland programs now.

The other issue to think about is file formats. I suggest you read the relevant wiki articles to see what makes sense for you. In general I wouldn't recommend flat binary unless you extend it somehow with your own section tables and entry address defined.

Regards,
John.
enrico_granata
Posts: 21
Joined: Tue Jul 24, 2007 1:19 am

Post by enrico_granata »

Thanks
I get your point about not using binary format, but I am choosing it (at the moment) to keep it really simple. If I use some custom format I assume I should do relocations of addresses built into the image to the real location where it's loaded, which is something I'd rather deal with later
The thing I was thinking of doing is more like this:

Code: Select all

#define USER_PROGRAM 0x<something>

void* program = (void*)USER_PROGRAM;
read_file("filename",program); // store the contents of filename at program

function_pointer* usermain = (function_pointer*)program;
usermain();

Computer science: all about things that "should" work
Post Reply