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:
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