k-chow/k/events/idt.h
Julien CLEMENT 5064efa101 feat(pit): add pit isr, empty handler and unmasked pit irq
Signed-off-by: Julien CLEMENT <julien.clement@epita.fr>
2021-07-26 11:17:52 +02:00

56 lines
1.1 KiB
C

#ifndef IDT_H
#define IDT_H
#include <stdint.h>
#include "gdt.h"
#include "isr.h"
#define IDT_RESERVED_ENTRIES 32
#define IDT_NB_ENTRIES 34
#define IDT_SIZE (IDT_NB_ENTRIES * sizeof(struct idt_entry))
#define INTERRUPT_TYPE 0x6
#define TRAP_TYPE 0x7
#define PIT_INT_VECTOR 32
#define KEYBOARD_INT_VECTOR 33
struct idt_entry
{
uint16_t offset_1 : 16;
struct segment_selector selector;
uint8_t zero_1 : 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));
struct idt_entry_descriptor
{
uint32_t offset;
struct segment_selector selector;
char type;
};
void init_idt(void);
void interrupt_handler(struct isr_param *isr_param);
#endif /* !IDT_H */