TSS

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
Jeko
Member
Member
Posts: 500
Joined: Fri Mar 17, 2006 12:00 am
Location: Napoli, Italy

TSS

Post by Jeko »

How can I make TSSes and switch from ring0 to ring3??
Can I make only two TSSes for ring0 and ring3, or I must make a TSS for each task?
Hery
Member
Member
Posts: 65
Joined: Sat Dec 04, 2004 12:00 am

Re: TSS

Post by Hery »

MarkOS wrote:How can I make TSSes and switch from ring0 to ring3??
Can I make only two TSSes for ring0 and ring3, or I must make a TSS for each task?
I guess that it's possible to make only two TSSes, but it isn't simple. The best is to make TSS for each task (including kernel) it make switching tasks simplier. :D

How can you make TSS?? Read intel manuals.
Last edited by Hery on Thu Mar 30, 2006 12:00 am, edited 1 time in total.
rexlunae
Member
Member
Posts: 134
Joined: Sun Oct 24, 2004 11:00 pm
Location: North Dakota, where the buffalo roam

Re: TSS

Post by rexlunae »

Hery Sasta wrote:
MarkOS wrote:How can I make TSSes and switch from ring0 to ring3??
Can I make only two TSSes for ring0 and ring3, or I must make a TSS for each task?
I guess that it's possible to make only two TSSes, but it isn't simple. The best is to make TSS for each task (including kernel) it make switching tasks simplier. :D

How can you make TSS?? Read intel manuals.
Actually, I found that the simplest approach was to only have 1 tss and do most of the task switching manually.
Da_Maestro
Member
Member
Posts: 144
Joined: Tue Oct 26, 2004 11:00 pm
Location: Australia

Re: TSS

Post by Da_Maestro »

To switch between ring3 and ring0 you need a minimum of one TSS to hold the pointers to each rings' stacks.

Essentially you can do task switching however you like, but you should stick to using a single TSS for each task rather than a global TSS. This makes task switching much faster especially on newer processors.

Switching between rings is easy. To switch from ring0 to ring3 you can just jump to a code sector with a GPL of 3. To do the reverse you have to jump though a call gate that points to a code sector with GPL 0.
Two things are infinite: The universe and human stupidity. But I'm not quite sure about the universe.
--- Albert Einstein
User avatar
Jeko
Member
Member
Posts: 500
Joined: Fri Mar 17, 2006 12:00 am
Location: Napoli, Italy

Re: TSS

Post by Jeko »

how can i do manually task switching?
I have two function in my OS, longjmp and setjmp. longjmp load registers and jump to eip
setjmp save registers.
but before the initialization of multitasking i must switch from ring0 to ring3
Rewriting virtual memory manager - Working on ELF support - Working on Device Drivers Handling

http://sourceforge.net/projects/jeko - Jeko Operating System
blackcatcoder
Member
Member
Posts: 132
Joined: Wed Nov 03, 2004 12:00 am
Location: Austria
Contact:

Re: TSS

Post by blackcatcoder »

if you are going to use , you will have to set up an gdt entry per tss, and then jump to gdt entry!!!


setjmp and longjmp only used for software based task switching!!
rexlunae
Member
Member
Posts: 134
Joined: Sun Oct 24, 2004 11:00 pm
Location: North Dakota, where the buffalo roam

Re: TSS

Post by rexlunae »

MarkOS wrote:how can i do manually task switching?
I have two function in my OS, longjmp and setjmp. longjmp load registers and jump to eip
setjmp save registers.
but before the initialization of multitasking i must switch from ring0 to ring3
How you do it depends on how your program multitasks. For my OS, switching tasks basicly involved just changing cr3 (the page directory pointer) and moving the stack (actually by moving the ebp register, then returning). This happens in the kernel, so the registers of the userland task were already backed up when we enterred kernel mode.

With this approach, the only thing the tss actually does is tell the processor what to load into the stack registers (ss and esp) when we go from priv 3 to priv 0. The tss is in a part of memory that is mapped per process, so when the process changes, it changes as well. However, the tss is always in the same place, so there is only one tss entry in the GDT.
Post Reply