idt stuff

This commit is contained in:
Adrien Bourmault 2019-04-01 23:51:48 +02:00
parent 5d9324ab68
commit 0614070cfc
2 changed files with 34 additions and 8 deletions

View File

@ -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

View File

@ -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)
{
}