Page 1 of 1
TSS
Posted: Thu Mar 30, 2006 12:00 am
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?
Re: TSS
Posted: Thu Mar 30, 2006 12:00 am
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.
How can you make TSS?? Read intel manuals.
Re: TSS
Posted: Thu Mar 30, 2006 12:00 am
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.
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.
Re: TSS
Posted: Thu Mar 30, 2006 12:00 am
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.
Re: TSS
Posted: Fri Mar 31, 2006 12:00 am
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
Re: TSS
Posted: Fri Mar 31, 2006 12:00 am
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!!
Re: TSS
Posted: Fri Mar 31, 2006 12:00 am
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.