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?
TSS
Re: TSS
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.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?
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.
-
- Member
- Posts: 134
- Joined: Sun Oct 24, 2004 11:00 pm
- Location: North Dakota, where the buffalo roam
Re: TSS
Actually, I found that the simplest approach was to only have 1 tss and do most of the task switching manually.Hery Sasta wrote: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.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?
How can you make TSS?? Read intel manuals.
-
- Member
- Posts: 144
- Joined: Tue Oct 26, 2004 11:00 pm
- Location: Australia
Re: TSS
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.
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
--- Albert Einstein
Re: TSS
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
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
http://sourceforge.net/projects/jeko - Jeko Operating System
-
- Member
- Posts: 132
- Joined: Wed Nov 03, 2004 12:00 am
- Location: Austria
- Contact:
Re: TSS
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!!
setjmp and longjmp only used for software based task switching!!
-
- Member
- Posts: 134
- Joined: Sun Oct 24, 2004 11:00 pm
- Location: North Dakota, where the buffalo roam
Re: TSS
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.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
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.