diff --git a/kaleid/include/kernel/cpu.h b/kaleid/include/kernel/cpu.h index 29ebc8f..b157c3e 100644 --- a/kaleid/include/kernel/cpu.h +++ b/kaleid/include/kernel/cpu.h @@ -31,6 +31,11 @@ // -------------------------------------------------------------------------- // +typedef struct IdtDescriptor_t IdtDescriptor_t; +typedef struct IdtEntry_t IdtEntry_t; + +// -------------------------------------------------------------------------- // +// // CPU features masks enum { FEAT_ECX_SSE3 = 1 << 0, @@ -92,6 +97,23 @@ enum { FEAT_EDX_PBE = 1 << 31 }; +typedef struct IdtDescriptor_t +{ + ushort limit; + ulong base; +} __attribute__((packed)); + +typedef struct IdtEntry_t +{ + ushort baseLow; + ushort selector; + uchar reservedIst; + uchar flags; + ushort baseMiddle; + uint baseHigh; + uint reserved; +} __attribute__((packed)); + // -------------------------------------------------------------------------- // #endif diff --git a/kaleid/kernel/cpu/idt.c b/kaleid/kernel/cpu/idt.c index 469796c..2b76398 100644 --- a/kaleid/kernel/cpu/idt.c +++ b/kaleid/kernel/cpu/idt.c @@ -23,16 +23,20 @@ //----------------------------------------------------------------------------// +idtp + // // Registers the new idt in the idtr register. // -static inline void lidt(void* idtAddr, ushort size) +static inline void lidt(IdtDescriptor_t idtDesc) { - // The IDTR register structure that will be sent - struct { - ushort length; - void* base; - } __attribute__((packed)) IDTR = { size, idtAddr }; - - asm volatile( "lidt %0" : : "m"(IDTR) ); + asm volatile( "lidt %0" : : "m"(idtDesc) ); +} + +// +// Initializes the IDT +// +error_t CpuInitIdt(void) +{ + }