UnnamedOS

Interrupt Descriptor Table. More...

+ Collaboration diagram for IDT:

Data Structures

struct  idtr_t
 the IDTR register pointing to the IDT More...
 
struct  idt_entry_t
 An entry in the IDT. More...
 

Macros

#define ISR_INIT(nr)
 shorthand for initializing an ISR More...
 
#define IDT_ENTRIES   256
 Number of entries in the IDT. More...
 

Enumerations

enum  idt_entry_type_t {
  TASK_32 = 0x5, INTR_16, TRAP_16, INTR_32 = 0xE,
  TRAP_32
}
 Different types of interrupt vectors. More...
 

Functions

static void idt_init_entry (size_t entry, uintptr_t func, uint32_t selector, idt_entry_type_t type, uint8_t st, uint8_t dpl, uint8_t pr)
 Initializes an IDT entry. More...
 
static void idt_init_entry_isr (size_t entry, void(*func)(), uint8_t dpl)
 Shorthand for initializing an ISR. More...
 
static void idt_load ()
 Loads the IDT into the IDTR register.
 
void idt_init ()
 Initializes the IDT. More...
 

Variables

static idt_entry_t idt [IDT_ENTRIES]
 The IDT itself. More...
 

Detailed Description

Interrupt Descriptor Table.

The IDT maps interrupt vectors to interrupt service routines (ISRs) to allow handling of exceptions, IRQs (Interrupt Requests) and system calls. Here all interrupt vectors are mapped to the same common interrupt handler.

See also
http://wiki.osdev.org/Interrupts
http://wiki.osdev.org/IDT
http://wiki.osdev.org/8259_PIC
http://wiki.osdev.org/Interrupt_Service_Routines
http://wiki.osdev.org/Selector

Macro Definition Documentation

#define IDT_ENTRIES   256

Number of entries in the IDT.

Only the entries 0x00-0x30 are actually used.

Definition at line 11 of file idt.h.

#define ISR_INIT (   nr)
Value:
extern void isr_intr_##nr(); \
idt_init_entry_isr((nr), &isr_intr_##nr, 0)
static void idt_init_entry_isr(size_t entry, void(*func)(), uint8_t dpl)
Shorthand for initializing an ISR.
Definition: idt.c:87

shorthand for initializing an ISR

See also
isr_intr in isr_asm.S

Definition at line 25 of file idt.c.

Enumeration Type Documentation

Different types of interrupt vectors.

Here we only use 32-bit interrupt gates.

Definition at line 35 of file idt.c.

Function Documentation

void idt_init ( )

Initializes the IDT.

Sets up all the exceptions and IRQs as kernel-only (RING0) interrupts.

Sets up 0x30 as a syscall interrupt which might be called from RING3.

Definition at line 99 of file idt.c.

+ Here is the call graph for this function:

static void idt_init_entry ( size_t  entry,
uintptr_t  func,
uint32_t  selector,
idt_entry_type_t  type,
uint8_t  st,
uint8_t  dpl,
uint8_t  pr 
)
static

Initializes an IDT entry.

Parameters
entryindex into the IDT
funcpointer to ISR
selectorcode segment of ISR, usually the kernel code segment
typeinterrupt vector type, usually a 32-bit interrupt gate
ststorage segment flag
dplmaximum allowed privilege level (0=kernel, 3=user space)
prpresent flag

Definition at line 69 of file idt.c.

+ Here is the caller graph for this function:

static void idt_init_entry_isr ( size_t  entry,
void(*)()  func,
uint8_t  dpl 
)
static

Shorthand for initializing an ISR.

Parameters
entryindex into the IDT
funcpointer to ISR
dplmaximum allowed privilege level (0=kernel, 3=user space)

Definition at line 87 of file idt.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Variable Documentation

idt_entry_t idt[IDT_ENTRIES]
static

The IDT itself.

Like the GDT, it is located inside the kernel. It is important that the IDT is always mapped into the same place in memory when using paging, otherwise interrupts lead to triple faults.

See also
vmm_init

Definition at line 57 of file idt.c.