Add: IDT implementation without ISRs

This commit is contained in:
xamidev
2024-07-14 16:58:35 +02:00
parent 007018790a
commit da6cb6c86d
10 changed files with 76 additions and 1 deletions

42
idt.c Normal file
View File

@@ -0,0 +1,42 @@
#include "idt.h"
#include "system.h"
struct idt_entry
{
unsigned short base_lo;
unsigned short sel;
unsigned char always0;
unsigned char flags;
unsigned short base_hi;
} __attribute__((packed));
struct idt_ptr
{
unsigned short limit;
unsigned int base;
} __attribute__((packed));
struct idt_entry idt[256];
struct idt_ptr idtp;
extern void idt_load();
void idt_set_gate(unsigned char num, unsigned long base, unsigned short sel, unsigned char flags)
{
idt[num].base_lo = (base & 0xFFFF);
idt[num].base_hi = (base >> 16) & 0xFFFF;
idt[num].sel = sel;
idt[num].always0 = 0;
idt[num].flags = flags;
}
void idt_install()
{
idtp.limit = (sizeof (struct idt_entry)*256) - 1;
idtp.base = (unsigned int)&idt;
memset(&idt, 0, sizeof(struct idt_entry)*256);
idt_load();
}