2021-07-14 18:39:59 +00:00
|
|
|
#ifndef IDT_H
|
|
|
|
#define IDT_H
|
|
|
|
|
|
|
|
#include <stdint.h>
|
2021-07-14 19:31:58 +00:00
|
|
|
#include "gdt.h"
|
2021-07-16 00:57:13 +00:00
|
|
|
#include "isr.h"
|
2021-07-14 18:39:59 +00:00
|
|
|
|
2021-07-21 18:30:55 +00:00
|
|
|
#define IDT_RESERVED_ENTRIES 32
|
|
|
|
#define IDT_NB_ENTRIES 34
|
2021-07-14 18:39:59 +00:00
|
|
|
#define IDT_SIZE (IDT_NB_ENTRIES * sizeof(struct idt_entry))
|
|
|
|
|
2021-07-14 20:57:38 +00:00
|
|
|
#define INTERRUPT_TYPE 0x6
|
2021-07-16 00:57:13 +00:00
|
|
|
#define TRAP_TYPE 0x7
|
2021-07-14 20:57:38 +00:00
|
|
|
|
2021-07-26 07:04:30 +00:00
|
|
|
#define KEYBOARD_INT_VECTOR 33
|
|
|
|
|
2021-07-14 18:39:59 +00:00
|
|
|
struct idt_entry
|
|
|
|
{
|
|
|
|
uint16_t offset_1 : 16;
|
2021-07-14 19:31:58 +00:00
|
|
|
struct segment_selector selector;
|
2021-07-14 18:39:59 +00:00
|
|
|
|
2021-07-14 19:31:58 +00:00
|
|
|
uint8_t zero_1 : 8; // unused, set to 0
|
2021-07-14 18:39:59 +00:00
|
|
|
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));
|
|
|
|
|
2021-07-16 00:57:13 +00:00
|
|
|
struct idt_entry_descriptor
|
|
|
|
{
|
|
|
|
uint32_t offset;
|
|
|
|
struct segment_selector selector;
|
|
|
|
char type;
|
|
|
|
};
|
|
|
|
|
2021-07-14 20:57:38 +00:00
|
|
|
void init_idt(void);
|
|
|
|
|
2021-07-16 00:57:13 +00:00
|
|
|
void interrupt_handler(struct isr_param *isr_param);
|
|
|
|
|
2021-07-14 18:39:59 +00:00
|
|
|
#endif /* !IDT_H */
|