Page 1 of 1

the tss...

Posted: Fri Apr 01, 2005 7:13 am
by Poseidon
How do I use the tss exactly.. do I have to fill it in myself, does the CPU do it - and if it does, how do I let the CPU fill it in..?

Thanks :)

Re:the tss...

Posted: Fri Apr 01, 2005 7:30 am
by AR
Yes and no, the CPU fills in an outgoing tasks state before loading in the new tasks state (Assuming hardware switching), but the initial values must be filled in manually.

In software switching the TSS is mostly unused with only the IOBitmap, SS0 and ESP0 being relevant.

A TSS definition looks like:

Code: Select all

struct TSS {
       unsigned short   backlink, __unused0;
       unsigned int   esp0;
       unsigned short   ss0, __unused1;
       unsigned int   esp1;
       unsigned short   ss1, __unused2;
       unsigned int   esp2;
       unsigned short   ss2, __unused3;
       unsigned int   cr3;
       unsigned int   eip;
       unsigned int   eflags;
       unsigned int   eax, ecx, edx, ebx;
       unsigned int   esp, ebp, esi, edi;
       unsigned short   es, __unused4;
       unsigned short   cs, __unused5;
       unsigned short   ss, __unused6;
       unsigned short   ds, __unused7;
       unsigned short   fs, __unused8;
       unsigned short   gs, __unused9;
       unsigned short   ldt, __unused10;
       unsigned short   trace, iobitmap;
} __attribute__((__packed__));
Before you can (far) jump to the TSS in software switching you will have to fill CR3, the segment registers, EFLAGS, EIP and ESP. The jump will cause the CPU to load all the values in, beyond that point only SS0/ESP0 and the IOBitmap need to be maintained, everything else won't be used again as the active task is changed by simply changing the register contents manually before IRETing after an interrupt.

Re:the tss...

Posted: Fri Apr 01, 2005 9:39 am
by Poseidon
what do you mean actually with jumping to the tss? how can i do that?
and restoring the registers... just push 'n pop them on the process its stack?

thanks :)

Re:the tss...

Posted: Fri Apr 01, 2005 9:54 am
by Guest
Iam not sure, because iam not at the point of adding multitasking to my kernel but i think its something like this...

jmp TSS_GDT_SELECTOR:0

get the intel docs and look @ 6.1.3. Executing a Task

Re:the tss...

Posted: Fri Apr 01, 2005 9:57 am
by Poseidon
where can i find those intel docs?

Re:the tss...

Posted: Fri Apr 01, 2005 10:31 am
by Guest

Re:the tss...

Posted: Mon Apr 04, 2005 11:30 am
by DruG5t0r3
I suggest ordering that book, it's quite usefull and more up to date than whats on the web site (oddly it should be the reverse)..

Re:the tss...

Posted: Wed Apr 06, 2005 2:53 am
by Candy
iirc exactly volume 3 was out of print permanently... I only got volume 1 + 2a/2b + optimization.

Re:the tss...

Posted: Wed Apr 06, 2005 2:59 am
by bubach
Same here, had to get it as pdf, which is a shame since i can't read it whenever i like ( can't print it either). :'(

Re:the tss...

Posted: Wed Apr 06, 2005 1:33 pm
by DruG5t0r3
Realllyy...nice to know I'm one of them that has a copy. It's a brick by the way :)