Interrupt Descriptor Table: Difference between revisions

m
Bot: Replace deprecated source tag with syntaxhighlight
[unchecked revision][unchecked revision]
(→‎Gate Descriptor: Add missing IST value in diagram.)
m (Bot: Replace deprecated source tag with syntaxhighlight)
 
(9 intermediate revisions by 5 users not shown)
Line 7:
== IDTR ==
 
The location of the '''IDT''' is kept in the '''IDTR''' ('''IDT''' register). This is loaded using the '''LIDT''' assembly instruction, whose argument is a pointer to an '''IDTRIDT Descriptor''' structure:
 
{| class="wikitable"
Line 92:
* '''P:''' Present bit. Must be set ('''1''') for the descriptor to be valid.
 
For more information, see '''Section 6.11: IDT Descriptors''' and '''Figure 6-2: IDT Gate Descriptors''' of the [https://www.intel.com/content/www/us/en/architecture-and-technology/64-ia-32-architectures-software-developer-vol-3a-part-1-manual.html Intel Software Developer Manual, Volume 3-A].
 
=== Example Code ===
Line 98:
C Struct:
 
<sourcesyntaxhighlight lang="c">
struct InterruptDescriptor32 {
uint16_t offset_1; // offset bits 0..15
Line 106:
uint16_t offset_2; // offset bits 16..31
};
</syntaxhighlight>
</source>
 
Example ''type_attributes'' values that people are likely to use (assuming DPL is 0):
Line 190:
C Struct:
 
<sourcesyntaxhighlight lang="c">
struct InterruptDescriptor64 {
uint16_t offset_1; // offset bits 0..15
Line 200:
uint32_t zero; // reserved
};
</syntaxhighlight>
</source>
 
Example ''type_attributes'' values that people are likely to use (assuming DPL is 0):
Line 212:
=== Interrupt Gate ===
 
An '''Interrupt Gate''' is used to specify an '''[[Interrupt Service Routines|Interrupt Service Routine]]'''. For example, when the assembly instruction '''INT 50''' is performed while running in protected mode, the CPU looks up the 50th entry (located at 50 * 8) in the '''IDT'''. Then the Interrupt Gate's '''Selector''' and '''Offset''' values are loaded. The '''Selector''' and '''Offset''' are used to call the '''Interrupt Service Routine'''. When the '''IRET''' instruction is performed, the CPU returns from the interrupt. If the CPU was running in 32-bit mode and the specified selector is a 16-bit gate, then the CPU will go in 16-bit '''Protected Mode''' after calling the '''ISR'''. To return in this case, the '''O32 IRET''' instruction should be used, or else the CPU will not know that it should do a 32-bit return (reading 32-bit values off the [[stack]] instead of 16 bit).
 
=== Trap Gate ===