Anonymous user
Interrupt Descriptor Table: Difference between revisions
→Structure
[unchecked revision] | [unchecked revision] |
Line 22:
== Structure ==
The table contains 8-byte Gate entries. Each entry has a complex structure:
<pre>
Line 45:
The bit fields mean:
{| {{wikitable}}
|+<b>IDT entry, Interrupt Gates</b>
! Name
! Bit
! Full Name
! Description
! Offset
| 48..63 || Offset || Higher part of the offset.
|-
! P
| 47 || Present || can be set to <b>0</b> for unused interrupts or for [[Paging]].
|-
!
| 45,46 || Descriptor Privilege Level || Gate call protection. Specifies which [[Privileg Level]] the calling [[Descriptor]] minimum should have. So hardware and CPU interrupts can be protected from beeing called out of userspace.
* 0: highest (kernel);
* 3: lowest (user applications).
|-
! S
| 44 || Storage Segment || <b>= 0</b> for interrupt gates.
▲|
|-
! Typ
| 40..43 || Gate Type || Possible IDT gate types :
{| {{wikitable}}
| 0b0101=0x5 || [[#I386 Task Gate|Task gate]]
|-
| 0b0110=0x6 || 16-bit [[#I386 Interrupt Gate|interrupt gate]]▼
▲| 16-bit [[#I386 Interrupt Gate|interrupt gate]]
|-
| 0b0111=0x7 || 16-bit [[#I386 Trap Gate|trap gate]]
| 16-bit [[#I386 Trap Gate|trap gate]]▼
|-
|-
| 0b1111=0xF || 32-bit [[#I386 Trap Gate|trap gate]]
|}
|-
! 0
| 32..40 || Reserved || Have to be <b>0</b>.
|-
! Selector
| 16..31 || Selector || [[Selector]] of the interrupt function.
|-
! Offset
| 0..15 || Offset || Lower part of the interrupt function's offset address.
|}
The Interrupt Gate is used to specify an [[Interrupt Service Routines|interrupt service routine]]. When you do <tt>[[INT]] 50</tt> in assembly, running in protected mode, the CPU looks up the 50th entry (located at 50 * 8) in the IDT. Then the Interrupt Gates selector and offset value is loaded. The selector and offset is used to call the interrupt service routine. When the <tt>[[IRET]]</tt> instruction is read, it returns. If running in 32 bit mode and the specified selector is a 16 bit selector, then the CPU will go in 16 bit protected mode after calling the interrupt service routine. To return you need to do <tt>O32 IRET</tt>, else the CPU doesn't know that it should do a 32 bit return (reading 32 bit offset of the [[stack]] instead of 16 bit).
|