You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
78 lines
2.2 KiB
78 lines
2.2 KiB
#ifndef KERNEL_CPU_IDT_H
|
|
#define KERNEL_CPU_IDT_H
|
|
|
|
#include "types.h"
|
|
|
|
typedef struct registers
|
|
{
|
|
uint32_t ds; // Data segment selector
|
|
uint32_t edi, esi, ebp, esp, ebx, edx, ecx, eax; // Pushed by pusha.
|
|
uint32_t int_no, err_code; // Interrupt number and error code (if applicable)
|
|
uint32_t eip, cs, eflags, useresp, ss; // Pushed by the processor automatically.
|
|
} registers_t;
|
|
|
|
void isr_handler(registers_t);
|
|
|
|
// A struct describing an interrupt gate.
|
|
struct idt_entry_struct
|
|
{
|
|
uint16_t base_lo; // The lower 16 bits of the address to jump to when this interrupt fires.
|
|
uint16_t sel; // Kernel segment selector.
|
|
uint8_t always0; // This must always be zero.
|
|
uint8_t flags; // More flags. See documentation.
|
|
uint16_t base_hi; // The upper 16 bits of the address to jump to.
|
|
} __attribute__((packed));
|
|
typedef struct idt_entry_struct idt_entry_t;
|
|
|
|
// A struct describing a pointer to an array of interrupt handlers.
|
|
// This is in a format suitable for giving to 'lidt'.
|
|
struct idt_ptr_struct {
|
|
uint16_t limit;
|
|
uint32_t base; // The address of the first element in our idt_entry_t array.
|
|
} __attribute__((packed));
|
|
typedef struct idt_ptr_struct idt_ptr_t;
|
|
|
|
extern void idt_flush(uint32_t);
|
|
|
|
static void init_idt();
|
|
static void idt_set_gate(uint8_t, uint32_t, uint16_t, uint8_t);
|
|
|
|
idt_entry_t idt_entries[256];
|
|
idt_ptr_t idt_ptr;
|
|
|
|
// References to ASM ISR handlers
|
|
extern void isr0();
|
|
extern void isr1();
|
|
extern void isr2();
|
|
extern void isr3();
|
|
extern void isr4();
|
|
extern void isr5();
|
|
extern void isr6();
|
|
extern void isr7();
|
|
extern void isr8();
|
|
extern void isr9();
|
|
extern void isr10();
|
|
extern void isr11();
|
|
extern void isr12();
|
|
extern void isr13();
|
|
extern void isr14();
|
|
extern void isr15();
|
|
extern void isr16();
|
|
extern void isr17();
|
|
extern void isr18();
|
|
extern void isr19();
|
|
extern void isr20();
|
|
extern void isr21();
|
|
extern void isr22();
|
|
extern void isr23();
|
|
extern void isr24();
|
|
extern void isr25();
|
|
extern void isr26();
|
|
extern void isr27();
|
|
extern void isr28();
|
|
extern void isr29();
|
|
extern void isr30();
|
|
extern void isr31();
|
|
|
|
#endif //KERNEL_CPU_IDT_H
|