972
edits
[unchecked revision] | [unchecked revision] |
Revolution (talk | contribs) (Change section names to refer to Protected and Long Mode instead of CPU generations.) |
m (Bot: Replace deprecated source tag with syntaxhighlight) |
||
(5 intermediate revisions by 5 users not shown) | |||
Line 1:
The '''Interrupt Descriptor Table''' ('''IDT''') is a binary data structure specific to the [[IA32_Architecture_Family|IA-32]] and [[X86-64|x86-64]] architectures. It is the
The
Before you implement the
== 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 '''
{| class="wikitable"
Line 31:
For more information, see '''Section 2.4.3: IDTR Interrupt Descriptor Table Register''' and '''Figure 2-6: Memory Management Registers''' of the Intel Software Developer Manual, Volume 3-A.
==
=== Table ===
{|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:
<
struct InterruptDescriptor32 {
uint16_t offset_1; // offset bits 0..15
Line 106:
uint16_t offset_2; // offset bits 16..31
};
</syntaxhighlight>
Example ''type_attributes'' values that people are likely to use (assuming DPL is 0):
Line 113:
* '''Task Gate: 0x85''' (p=1, dpl=0b00, type=0b0101 => type_attributes=0b1000_0101='''0x85''')
==
=== Table ===
{|class="wikitable"
Line 190:
C Struct:
<
struct InterruptDescriptor64 {
uint16_t offset_1; // offset bits 0..15
Line 200:
uint32_t zero; // reserved
};
</syntaxhighlight>
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
=== Trap Gate ===
|