Xyris  0.5
IDT Namespace Reference

Data Structures

struct  Gate
 
union  Offset
 
struct  Segment
 

Enumerations

enum  GateType : uint8_t {
  TASK_GATE = 0x5, INTERRUPT_GATE_16_BIT = 0x6, TRAP_GATE_16_BIT = 0x7, INTERRUPT_GATE_32_BIT = 0xE,
  TRAP_GATE_32_BIT = 0xF
}
 

Functions

void setGate (int n, uint32_t handler)
 
void init ()
 

Variables

struct Gate idt [ARCH_IDT_MAX_ENTRIES]
 
struct Registers::IDTR idtr
 

Enumeration Type Documentation

◆ GateType

enum IDT::GateType : uint8_t
Enumerator
TASK_GATE 
INTERRUPT_GATE_16_BIT 
TRAP_GATE_16_BIT 
INTERRUPT_GATE_32_BIT 
TRAP_GATE_32_BIT 

Definition at line 18 of file idt.hpp.

18  : uint8_t
19 {
20  TASK_GATE = 0x5,
22  TRAP_GATE_16_BIT = 0x7,
24  TRAP_GATE_32_BIT = 0xF,
25 };

Function Documentation

◆ init()

void IDT::init ( )

Calls the lidt instruction and installs the IDT onto the CPU.

Definition at line 41 of file idt.cpp.

42 {
43  // Update the IDT table
44  idtr.size = sizeof(idt) - 1;
45  idtr.base = (uint32_t)&idt;
46  // Load the IDT table into the IDT register
47  asm volatile(
48  "lidt (%0)"
49  :
50  : "r"(&idtr)
51  : "memory");
52 }
+ Here is the caller graph for this function:

◆ setGate()

void IDT::setGate ( int  n,
uint32_t  handler 
)

Sets the handler function (via address) for a specific IDT.

Parameters
nIDT index
handlerHandler address

Definition at line 21 of file idt.cpp.

22 {
23  struct Gate* gate = &idt[n];
24  union Offset offset = { .value = handler_addr };
25  gate->offset_low = offset.section.low;
26  gate->selector = {
27  .privilege = 0,
28  .table = 0,
29  .index = 1,
30  };
31  gate->reserved = 0;
32  gate->flags = {
33  .type = INTERRUPT_GATE_32_BIT,
34  .offset = 0,
35  .privilege = 0,
36  .present = 1,
37  };
38  gate->offset_high = offset.section.high;
39 }
+ Here is the caller graph for this function:

Variable Documentation

◆ idt

struct Gate IDT::idt[ARCH_IDT_MAX_ENTRIES]

Definition at line 18 of file idt.cpp.

◆ idtr

struct Registers::IDTR IDT::idtr

Definition at line 19 of file idt.cpp.

IDT::INTERRUPT_GATE_16_BIT
@ INTERRUPT_GATE_16_BIT
Definition: idt.hpp:21
IDT::INTERRUPT_GATE_32_BIT
@ INTERRUPT_GATE_32_BIT
Definition: idt.hpp:23
IDT::idt
struct Gate idt[ARCH_IDT_MAX_ENTRIES]
Definition: idt.cpp:18
IDT::TRAP_GATE_32_BIT
@ TRAP_GATE_32_BIT
Definition: idt.hpp:24
IDT::TASK_GATE
@ TASK_GATE
Definition: idt.hpp:20
IDT::TRAP_GATE_16_BIT
@ TRAP_GATE_16_BIT
Definition: idt.hpp:22
IDT::Gate::offset_low
uint16_t offset_low
Definition: idt.hpp:44
IDT::idtr
struct Registers::IDTR idtr
Definition: idt.cpp:19