Initial commit
This commit is contained in:
23
kernel/cpu/idt.c
Normal file
23
kernel/cpu/idt.c
Normal file
@@ -0,0 +1,23 @@
|
||||
//
|
||||
// Created by rick on 8/18/19.
|
||||
//
|
||||
|
||||
#include "idt.h"
|
||||
|
||||
idt_gate_t idt[IDT_REGISTERS];
|
||||
idt_register_t idt_reg;
|
||||
|
||||
void set_idt_gate(int n, u32 handler) {
|
||||
idt[n].low_offset = handler & 0xffff;
|
||||
idt[n].sel = KERNEL_CS;
|
||||
idt[n].always0 = 0;
|
||||
idt[n].flags = 0x8E;
|
||||
idt[n].high_offset = handler >> 16 & 0xFFFF;
|
||||
}
|
||||
|
||||
void set_idt() {
|
||||
idt_reg.base = (u32) &idt;
|
||||
idt_reg.limit = IDT_REGISTERS * sizeof(idt_gate_t) - 1;
|
||||
|
||||
__asm__ __volatile__("lidtl (%0)" : : "r" (&idt_reg));
|
||||
}
|
||||
Reference in New Issue
Block a user