feat(idt): add idt_entry, idt and idt_r structs

This commit is contained in:
Malo Lecomte 2021-07-14 20:39:59 +02:00
parent 60800e71fd
commit 1e0e16d290

35
k/idt.h Normal file

@ -0,0 +1,35 @@
#ifndef IDT_H
#define IDT_H
#include <stdint.h>
#define IDT_NB_ENTRIES 32
#define IDT_SIZE (IDT_NB_ENTRIES * sizeof(struct idt_entry))
struct idt_entry
{
uint16_t offset_1 : 16;
uint16_t selector : 16;
uint8_t zero : 8; // unused, set to 0
uint8_t type : 3; // gate type
uint8_t size : 1;
uint8_t zero_2 : 1; // set to 0 for interrupt and trap gates
uint8_t desc_priv : 2; // Descriptor privilege
uint8_t present : 1;
uint16_t offset_2 : 16;
} __attribute__ ((packed));
struct idt
{
struct idt_entry entries[IDT_NB_ENTRIES];
};
struct idt_r
{
uint16_t limit;
uint32_t addr;
} __attribute__ ((packed));
#endif /* !IDT_H */