hippOS/cpu/idt.h
2022-02-25 21:29:18 +02:00

31 lines
791 B
C

#ifndef _IDT_H
#define _IDT_H
#include <stddef.h>
#include <stdint.h>
#define KERNEL_CODE_SEGMENT_OFFSET 0x08
#define INTERRUPT_GATE 0x8e
// https://wiki.osdev.org/Interrupt_Descriptor_Table
struct interrupt_descriptor_32 {
uint16_t offset_1; // offset bits 0..15
uint16_t selector; // a code segment selector in GDT or LDT
uint8_t zero; // unused, set to 0
uint8_t type_attributes; // gate type, dpl, and p fields
uint16_t offset_2; // offset bits 16..31
} __attribute__((__packed__));
struct interrupt_frame_32 {
size_t ip;
size_t cs;
size_t flags;
size_t sp;
size_t ss;
} __attribute__((__packed__));
void idt_init(void);
void idt_register_handler(uint8_t interrupt, size_t address);
#endif