System Descriptor Types

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
Silverhawk

System Descriptor Types

Post 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.
User avatar
kataklinger
Member
Member
Posts: 381
Joined: Fri Nov 04, 2005 12:00 am
Location: Serbia

Re:System Descriptor Types

Post by kataklinger »

Try here:

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

It explains everything
Silverhawk

Re:System Descriptor Types

Post by Silverhawk »

OK, I'll try to find an answer in this doc...
Thanks.
Silverhawk

Re:System Descriptor Types

Post 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 ?
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Re:System Descriptor Types

Post 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
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
Silverhawk

Re:System Descriptor Types

Post by Silverhawk »

Hi,
Thanks a lot Brendan for this explanation !
I'll sleep better :D

Bye.
Silver
Post Reply