What to do about userland?

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
User avatar
Jezze
Member
Member
Posts: 395
Joined: Thu Jul 26, 2007 1:53 am
Libera.chat IRC: jfu
Contact:

What to do about userland?

Post by Jezze »

Hi! I've followed and completed the Bran tutorial which was incredible! I have everything working as it shoud with a few modifications - the most notabily is I'm using the grub stage2_eltorito and run my kernel using qemu -cdrom - this ment I had to use the elf format on the nasm parts because else grub complained about not beeing able to read the binary.

After finishing the tutorial I am left with a just one questions which I can not seem to get the grip on and I am hoping someone here would like to enlighten me with their brilliance!

Question: Since I don't have a scheduler yet I just want to load a function called init() into userland. How do I setup userland and how do I load a function into it? I guess it is alot I need to do but just a hint in the right direction would be fine as well.

Thank you!
Pyrofan1
Member
Member
Posts: 234
Joined: Sun Apr 29, 2007 1:13 am

Post by Pyrofan1 »

chapter 6 in the intel manual 3 describes TSS which are used for tasks.
User avatar
AJ
Member
Member
Posts: 2646
Joined: Sun Oct 22, 2006 7:01 am
Location: Devon, UK
Contact:

Post by AJ »

Hi,

My advice would be to initially get software task switching working in your kernel. Do this by specifying test() or init() or whatever you want to call the function in your kernel, and give that as the entry point to the new thread. Once you have ring 0 --> ring 0 thread switching working, then worry about privilege level changes.

The problem is, if you only get a single ring 3 task to run with no scheduler written, you'll never get back to ring 0 again (!).

Also, before task switching works, you will need reliable memory management (the wiki and osdever.net have good resources on this).

Cheers,
Adam
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Post by JamesM »

Just to add to AJ's comment - If you try ring0->ring3 before a ring0->ring0, you'll have to write syscall code just to check your scheduler/task switch/fork works (because code in ring3 shouldnt be able to access video memory!).

JamesM
Post Reply