the 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
Poseidon

the tss...

Post 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 :)
AR

Re:the tss...

Post 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.
Poseidon

Re:the tss...

Post 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 :)
Guest

Re:the tss...

Post 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
Poseidon

Re:the tss...

Post by Poseidon »

where can i find those intel docs?
DruG5t0r3

Re:the tss...

Post 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)..
User avatar
Candy
Member
Member
Posts: 3883
Joined: Tue Oct 17, 2006 11:33 pm
Location: Eindhoven

Re:the tss...

Post by Candy »

iirc exactly volume 3 was out of print permanently... I only got volume 1 + 2a/2b + optimization.
User avatar
bubach
Member
Member
Posts: 1224
Joined: Sat Oct 23, 2004 11:00 pm
Location: Sweden
Contact:

Re:the tss...

Post 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). :'(
"Simplicity is the ultimate sophistication."
http://bos.asmhackers.net/ - GitHub
DruG5t0r3

Re:the tss...

Post by DruG5t0r3 »

Realllyy...nice to know I'm one of them that has a copy. It's a brick by the way :)
Post Reply