WKern
Loading...
Searching...
No Matches
idt.c File Reference
#include <global.h>
#include <idt/idtirq.h>
#include <io/kio.h>
#include <mem/kmem.h>
#include <types/nums.h>
#include <utils/util.h>

Go to the source code of this file.

Functions

struct IdtPtr idt_ptrn __attribute__ ((aligned(16)))
void IdtSetGate (u8 num, u32 base, u16 sel, u8 flags)
 Set an IDT gate (entry) at given index.
void IdtLoad (void)
void debug_print_idt_entry (int i)
 Debug function to print an IDT entry's handler address.
void AllIdt ()
 Initialize and load the Interrupt Descriptor Table (IDT)

Variables

struct IdtEntry idt [IDT_ENTRIES]

Function Documentation

◆ __attribute__()

struct IdtPtr idt_ptrn __attribute__ ( (aligned(16)) )

IDT pointer structure, aligned to 16 bytes

◆ AllIdt()

void AllIdt ( )

Initialize and load the Interrupt Descriptor Table (IDT)

  • Installs GDT
  • Remaps PIC interrupts
  • Masks all IRQs, then unmasks IRQ 0 and 1
  • Sets IDT gates for IRQ0 and IRQ1 handlers
  • Loads the IDT and enables interrupts
  • Starts the PIT timer at a base frequency

< Install the Global Descriptor Table (GDT)

< Remap the PIC (Programmable Interrupt Controller)

< Mask all IRQs for safety

< Unmask IRQ1 (keyboard)

< Unmask IRQ0 (timer)

< Clear the IDT entries

< Set IDT limit

< Set IDT base address

< Set IRQ0 handler

< Set IRQ1 handler

< Disable CPU interrupts during setup

< Reload the GDT

< Load the new IDT

< Re-enable CPU interrupts

< Initialize PIT with base frequency (e.g., 1193182 Hz)

Definition at line 73 of file idt.c.

◆ debug_print_idt_entry()

void debug_print_idt_entry ( int i)

Debug function to print an IDT entry's handler address.

Parameters
iIndex of the IDT entry to print

Definition at line 56 of file idt.c.

◆ IdtLoad()

void IdtLoad ( void )
extern

External assembly function to load the IDT

◆ IdtSetGate()

void IdtSetGate ( u8 num,
u32 base,
u16 sel,
u8 flags )

Set an IDT gate (entry) at given index.

Parameters
numIndex of the IDT entry to set
baseAddress of the interrupt handler function
selCode segment selector in GDT
flagsFlags controlling gate type and privileges

Definition at line 40 of file idt.c.

Variable Documentation

◆ idt

struct IdtEntry idt[IDT_ENTRIES]

Interrupt Descriptor Table entries

Definition at line 27 of file idt.c.