166 lines
3.6 KiB
C
166 lines
3.6 KiB
C
#ifndef _KALKERN_BASE_H
|
|
#include <kernel/base.h>
|
|
#endif
|
|
|
|
#ifndef _KALKERN_IDT_H
|
|
#define _KALKERN_IDT_H
|
|
|
|
typedef struct IdtDescriptor_t IdtDescriptor_t;
|
|
typedef struct IdtEntry_t IdtEntry_t;
|
|
typedef struct IdtPtr_t IdtPtr_t;
|
|
typedef struct IRQList_t IRQList_t;
|
|
typedef struct ISRFrame_t ISRFrame_t;
|
|
|
|
// -------------------------------------------------------------------------- //
|
|
|
|
#define interrupt(n) asm volatile ("int %0" : : "N" (n) : "cc", "memory")
|
|
|
|
// -------------------------------------------------------------------------- //
|
|
|
|
struct IdtDescriptor_t {
|
|
ushort limit;
|
|
ulong base;
|
|
} __attribute__((packed)) ;
|
|
|
|
struct IdtEntry_t
|
|
{
|
|
ushort baseLow;
|
|
ushort selector;
|
|
uchar reservedIst;
|
|
uchar flags;
|
|
ushort baseMid;
|
|
uint baseHigh;
|
|
uint reserved;
|
|
} __attribute__((packed));
|
|
|
|
struct IdtPtr_t
|
|
{
|
|
ushort limit;
|
|
void *base;
|
|
} __attribute__((packed));
|
|
|
|
struct IRQList_t
|
|
{
|
|
uchar n; //number of entries in the list
|
|
|
|
struct entry {
|
|
void (*isr)(ISRFrame_t *regs);
|
|
uchar irq;
|
|
uchar flags;
|
|
} entry[224];
|
|
};
|
|
|
|
typedef struct
|
|
{
|
|
|
|
} __attribute__((__packed__)) cpu_state_t;
|
|
|
|
static char *IsrExceptions[32] = {
|
|
"Divide Error Fault",
|
|
"Debug Exception Trap",
|
|
"Non-maskable Interrupt",
|
|
"Breakpoint Trap",
|
|
"Overflow Trap",
|
|
"Bound Range Exceeded Fault",
|
|
"Invalid Opcode Fault",
|
|
"Device Not Available or No Math Coprocessor Fault",
|
|
"Double Fault Abort",
|
|
"Coprocessor Segment Overrun Fault (Legacy)",
|
|
"Invalid TSS Fault",
|
|
"Segment Not Present Fault",
|
|
"Stack Segment fault",
|
|
"General Protection Fault",
|
|
"Page Fault",
|
|
"Intel Reserved",
|
|
"x87 FPU Floating Point or Math Fault",
|
|
"Alignment Check Fault",
|
|
"Machine Check Abort",
|
|
"SIMD Floating Point Fault",
|
|
"Virtualization Exception Fault",
|
|
"Intel Reserved",
|
|
"Intel Reserved",
|
|
"Intel Reserved",
|
|
"Intel Reserved",
|
|
"Intel Reserved",
|
|
"Intel Reserved",
|
|
"Intel Reserved",
|
|
"Intel Reserved",
|
|
"Intel Reserved",
|
|
"Security Exception",
|
|
"Intel Reserved"
|
|
};
|
|
|
|
// -------------------------------------------------------------------------- //
|
|
|
|
void IdtRegisterIrq(void (*isr)(ISRFrame_t *regs), uchar irq, uchar flags);
|
|
void IdtSetup(void);
|
|
void IdtSetGate(uchar rank, ulong base, ushort selector, uchar flags);
|
|
void IdtExceptionHandler(ISRFrame_t *regs);
|
|
static void EnablePIC(void);
|
|
void SendEOItoPIC(uchar isr);
|
|
|
|
extern void IdtInit();
|
|
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();
|
|
extern void isr32();
|
|
extern void isr33();
|
|
extern void isr34();
|
|
extern void isr35();
|
|
extern void isr36();
|
|
extern void isr37();
|
|
extern void isr38();
|
|
extern void isr39();
|
|
extern void isr40();
|
|
extern void isr41();
|
|
extern void isr42();
|
|
extern void isr43();
|
|
extern void isr44();
|
|
extern void isr45();
|
|
extern void isr46();
|
|
extern void isr47();
|
|
extern void isr48();
|
|
extern void isr49();
|
|
extern void isr50();
|
|
extern void isr51();
|
|
extern void isr52();
|
|
extern void isr53();
|
|
extern void isr54();
|
|
extern void isr55();
|
|
extern void isr56();
|
|
extern void isr57();
|
|
extern void isr58();
|
|
extern void isr59();
|
|
extern void isr60();
|
|
|
|
#endif
|