Page 1 of 1

System Descriptor Types

Posted: Wed Jul 14, 2004 3:29 pm
by Silverhawk
Hi,
Is there anybody who can explain me the purpose of each kind of Descriptor ?

- Code / Data segment descriptor
- TSS descriptor
- Call gate descriptor
- Interrupt gate descriptor
- Trap gate descriptor
- Task gate descriptor...

How does it work ?

I've understood that under PM, it was necessary do describe the different segments used. So, I think that for Code and Data segment descriptor, I've caught the idea...

Concerning the TSS descriptor, I imagine I must fill a GDT entry with this for each task running on my system ?

But I've got some troubles with Call gate, interrupt gate, trap gate and task gate descriptors... What is their aim ?

For instance, I've read that IDT can only contain Task gate, Interrupt gate or trap gate descriptor. How to choose one among them ?
I would be inclined to use Interrupt gate... But I've seen trap gate descriptors where used in IDT ! What is the difference between them ?
And what the hell a task gate descriptor comes into an IDT ?

Thanks for your help !
Silver.

Re:System Descriptor Types

Posted: Wed Jul 14, 2004 4:05 pm
by kataklinger
Try here:

"IA-32 Intel Architecture Software Developer?s Manual Volume 3: System Programming Guide"

It explains everything

Re:System Descriptor Types

Posted: Thu Jul 15, 2004 12:22 am
by Silverhawk
OK, I'll try to find an answer in this doc...
Thanks.

Re:System Descriptor Types

Posted: Thu Jul 15, 2004 4:03 pm
by Silverhawk
So, I've read the IA32 Book 3.
But there is still something I didn't understand :
What is the difference between a trap gate and an interrupt gate ?
Why to use one rather another in the IDT ?

Re:System Descriptor Types

Posted: Thu Jul 15, 2004 11:03 pm
by Brendan
Hi,
Silverhawk wrote: So, I've read the IA32 Book 3.
But there is still something I didn't understand :
What is the difference between a trap gate and an interrupt gate ?
Why to use one rather another in the IDT ?
When an interrupt gate is used the CPU will disable interrupts when the handler is being entered (and restore them during IRETD). With a trap gate this doesn't happen.

You could *almost* simulate an interrupt gate with a trap gate using the following:

Code: Select all

intHandler:
     pushfd
     cli
     ..handle interrupt..
     popfd
     iretd
The difference is that EFLAGS would be on the stack twice, and it's possible to get another IRQ between "intHandler" and "cli". With a true interrupt gate it's impossible for another interrupt/IRQ handler to be called by the CPU before the first interrupt handler has had a chance to start.

In general I'd use trap gates for software interrupts and interrupt gates for IRQs.


Cheers,

Brendan

Re:System Descriptor Types

Posted: Fri Jul 16, 2004 2:57 am
by Silverhawk
Hi,
Thanks a lot Brendan for this explanation !
I'll sleep better :D

Bye.
Silver