visor/include/x86/idt.h

44 lines
757 B
C
Raw Permalink Normal View History

2025-03-11 02:06:12 +01:00
#ifndef _VISOR_IDT_H_
#define _VISOR_IDT_H_
#include <stdint.h>
2025-03-11 18:46:10 +01:00
__attribute__ ((packed))
struct intdescr {
uint16_t offset0;
uint16_t seg;
uint8_t ist;
uint8_t access;
uint16_t offset1;
uint32_t offset2;
uint32_t reserved;
};
2025-03-11 02:06:12 +01:00
__attribute__ ((packed))
struct IDTR {
uint16_t limit;
2025-03-12 02:33:53 +01:00
struct intdescr *base;
2025-03-11 02:06:12 +01:00
};
static inline struct IDTR
storeidt(void)
{
struct IDTR idtr;
__asm__ ("sidt %0\n\t" : "=m"(idtr));
return idtr;
}
2025-03-11 18:46:10 +01:00
static inline void
setintdescr(struct intdescr *descr, uint64_t offset, uint16_t seg, uint8_t ist, uint8_t access)
{
descr->offset0 = offset;
descr->seg = seg;
descr->ist = ist;
descr->access = access;
descr->offset1 = offset >> 16;
descr->offset2 = offset >> 32;
descr->reserved = 0;
}
2025-03-11 02:06:12 +01:00
#endif