From 0614070cfc2d8906b6deaeea47464c265552b7e2 Mon Sep 17 00:00:00 2001 From: Adrien Bourmault Date: Mon, 1 Apr 2019 23:51:48 +0200 Subject: [PATCH] idt stuff --- kaleid/include/kernel/cpu.h | 22 ++++++++++++++++++++++ kaleid/kernel/cpu/idt.c | 20 ++++++++++++-------- 2 files changed, 34 insertions(+), 8 deletions(-) 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) +{ + }