rk/include/idt.h

43 lines
870 B
C
Raw Normal View History

#ifndef RK_IDT_H_
#define RK_IDT_H_
2024-05-21 22:07:04 -04:00
#include <stdint.h>
#define GDT_SEGMENT_SELECTOR(i, p) ((i << 3) | p)
#define LDT_SEGMENT_SELECTOR(i, p) ((i << 3) | 0x04 | p)
#define IDT_ENTRY_COUNT 256
struct idt_entry {
uint16_t offset_lo;
uint16_t seg_select;
uint8_t reserved;
uint8_t attributes;
uint16_t offset_hi;
} __attribute__ ((packed));
struct idtr {
uint16_t size;
uint32_t base;
} __attribute__ ((packed));
enum IDT_ATTRIBUTES {
TASK_GATE = 0x05,
INT_GATE_16 = 0x06,
TRAP_GATE_16 = 0x07,
INT_GATE_32 = 0x0E,
TRAP_GATE_32 = 0x0F,
INT_RING0 = 0x00,
INT_RING1 = 0x20,
INT_RING2 = 0x40,
INT_RING3 = 0x60,
INT_PRESENT = 0x80,
};
void encode_idt_entry(struct idt_entry idt[], int i, uint32_t offset, uint16_t segment_selector, uint8_t attributes);
void flush_idt(uint32_t idt_pointer);
#endif