58 lines
1.1 KiB
C
58 lines
1.1 KiB
C
#include "types.h"
|
|
|
|
|
|
struct cpu_reg_state {
|
|
u32 eax;
|
|
u32 ecx;
|
|
u32 edx;
|
|
u32 ebx;
|
|
|
|
u32 esp;
|
|
u32 ebp;
|
|
u32 esi;
|
|
u32 edi;
|
|
|
|
u16 ds;
|
|
u16 es;
|
|
u16 fs;
|
|
u16 gs;
|
|
|
|
u32 eflags;
|
|
}__attribute__((packed));
|
|
|
|
// Populated by the interrupt handler itself
|
|
struct stack_state {
|
|
u32 error_code; // 8 10 11 12 13 14 17 <= ony interrupts that actually use the error code
|
|
u32 eip;
|
|
u16 cs;
|
|
u32 eflags;
|
|
};
|
|
|
|
#define IDT_SIZE 256
|
|
|
|
struct IDT_Entry {
|
|
u16 offset_low; // offset bits 0..15
|
|
u16 selector; // code segment in either gdt or ldt
|
|
u8 zero; // not used always 0
|
|
/* 7 0
|
|
* +---+---+---+---+---+---+---+---+
|
|
* | P | DPL | S | GateType |
|
|
* +---+---+---+---+---+---+---+---+
|
|
*/
|
|
u8 type_attrs; // format specified above
|
|
u16 offset_high;// offset bits 16..31
|
|
}__attribute__((packed));
|
|
|
|
struct IDT_PTR {
|
|
u16 limit;
|
|
u32 address;
|
|
}__attribute__((packed));
|
|
|
|
struct IDT_Entry IDT[IDT_SIZE];
|
|
struct IDT_PTR idt_ptr;
|
|
|
|
void load_idt();
|
|
void init_idt();
|
|
void setup_idt_entry(u32 t_idx, u32 base, u16 sel, u8 type_attrs);
|
|
//void interrupt_handler(struct cpu_reg_state, struct stack_state, u32);
|