WKern
Loading...
Searching...
No Matches
idtirq.h File Reference
#include <global.h>
#include <types/nums.h>

Go to the source code of this file.

Data Structures

struct  IdtEntry
struct  GdtEntry
struct  GdtPtr
struct  IdtPtr

Macros

#define KERNEL_CODE_SEGMENT   0x08
#define IDT_ENTRIES   256
#define PIT_FREQ   119
#define SendEOI   Outb(0x20, 0x20)

Functions

void SetupIdt (void)
void IdtInit (void)
void IdtSetGate (u8 num, u32 base, u16 sel, u8 flags)
 Set an IDT gate (entry) at given index.
void MaskAllIrqs (void)
 Mask all IRQs.
void UnmaskIrq (u8 irq)
 Unmask an IRQ.
void DebugPrintIdtEntry (int i)
void AllIdt ()
 Initialize and load the Interrupt Descriptor Table (IDT)
void _picr (void)
void GdtInstall ()
 Initialize and load the Global Descriptor Table (GDT)
void GdtFlush (u32)
void GdtSetGate (int num, u32 base, u32 limit, u8 access, u8 gran)
 Set a GDT entry (descriptor)
void MsSleep (unsigned int milliseconds)
void PitInit (u32 freq)
void Irq0HandlerC (void)
void Irq0Handler (void)
void GoodHandler (void)
void Irq1Handler (void)
void VirtnetIrqHandler ()
void VirtnetHandler (void)

Variables

struct IdtEntry PKG
struct IdtPtr idt_ptrn
struct IdtEntry idt [IDT_ENTRIES]

Macro Definition Documentation

◆ IDT_ENTRIES

#define IDT_ENTRIES   256

Definition at line 92 of file idtirq.h.

◆ KERNEL_CODE_SEGMENT

#define KERNEL_CODE_SEGMENT   0x08

Definition at line 24 of file idtirq.h.

◆ PIT_FREQ

#define PIT_FREQ   119

Definition at line 107 of file idtirq.h.

◆ SendEOI

#define SendEOI   Outb(0x20, 0x20)

Definition at line 108 of file idtirq.h.

Function Documentation

◆ _picr()

void _picr ( void )
extern

◆ 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.

◆ DebugPrintIdtEntry()

void DebugPrintIdtEntry ( int i)

◆ GdtFlush()

void GdtFlush ( u32 )
extern

◆ GdtInstall()

void GdtInstall ( )

Initialize and load the Global Descriptor Table (GDT)

  • Sets up three GDT entries:
    • Null segment
    • Code segment (executable, readable)
    • Data segment (read/write)
  • Loads the GDT register with the new table

Definition at line 56 of file gdt.c.

◆ GdtSetGate()

void GdtSetGate ( int num,
u32 base,
u32 limit,
u8 access,
u8 gran )

Set a GDT entry (descriptor)

Parameters
numIndex of the GDT entry to set
baseBase address for the segment
limitLimit of the segment
accessAccess flags (e.g., executable, readable)
granGranularity and size flags

Definition at line 35 of file gdt.c.

◆ GoodHandler()

void GoodHandler ( void )
extern

◆ IdtInit()

void IdtInit ( void )

◆ 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.

◆ Irq0Handler()

void Irq0Handler ( void )
extern

◆ Irq0HandlerC()

void Irq0HandlerC ( void )

Definition at line 24 of file irq0.c.

◆ Irq1Handler()

void Irq1Handler ( void )
extern

◆ MaskAllIrqs()

void MaskAllIrqs ( void )

Mask all IRQs.

Definition at line 26 of file masker.c.

◆ MsSleep()

void MsSleep ( unsigned int milliseconds)

Definition at line 29 of file irq0.c.

◆ PitInit()

void PitInit ( u32 freq)

Definition at line 32 of file pit.c.

◆ SetupIdt()

void SetupIdt ( void )

◆ UnmaskIrq()

void UnmaskIrq ( u8 irq)

Unmask an IRQ.

Parameters
irq- IRQ NUmber to Unmask

Definition at line 34 of file masker.c.

◆ VirtnetHandler()

void VirtnetHandler ( void )
extern

◆ VirtnetIrqHandler()

void VirtnetIrqHandler ( )

Definition at line 11 of file virtnetirq.c.

Variable Documentation

◆ idt

struct IdtEntry idt[IDT_ENTRIES]
extern

Interrupt Descriptor Table entries

Definition at line 27 of file idt.c.

◆ idt_ptrn

struct IdtPtr idt_ptrn
extern

◆ PKG

struct GdtPtr PKG