From 957b031689658c1ff67ea8a8a04640be9bec2d7d Mon Sep 17 00:00:00 2001 From: Franklin Wei Date: Sun, 1 Feb 2015 16:40:00 -0500 Subject: a lot of kernel work --- kernel/include/gdt.h | 4 ++-- kernel/include/idt.h | 23 +++++++++++++++++++++++ kernel/include/irq.h | 21 +++++++++++++++++++++ kernel/include/isr.h | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 92 insertions(+), 2 deletions(-) create mode 100644 kernel/include/idt.h create mode 100644 kernel/include/irq.h create mode 100644 kernel/include/isr.h (limited to 'kernel/include') diff --git a/kernel/include/gdt.h b/kernel/include/gdt.h index e93c92a..4cf7c4f 100644 --- a/kernel/include/gdt.h +++ b/kernel/include/gdt.h @@ -10,7 +10,7 @@ struct gdt_entry { } __attribute__((packed)); struct gdt_ptr { - uint8_t limit; + uint16_t limit; uint32_t base; } __attribute__((packed)); @@ -18,6 +18,6 @@ struct gdt_entry gdt[3]; struct gdt_ptr gp; /* assembly */ -extern void gdt_flush(struct gdt_ptr*); +extern void gdt_flush(uint32_t); void gdt_init(void); diff --git a/kernel/include/idt.h b/kernel/include/idt.h new file mode 100644 index 0000000..8041025 --- /dev/null +++ b/kernel/include/idt.h @@ -0,0 +1,23 @@ +#include + +struct idt_entry { + uint16_t base_lo; + uint16_t sel; + uint8_t zero; + uint8_t flags; + uint16_t base_hi; +} __attribute__((packed)); + +struct idt_ptr { + uint16_t limit; + uint32_t base; +}; + +struct idt_entry idt[0x100]; +struct idt_ptr idt_pt; + +void idt_init(void); + +extern void idt_flush(uint32_t); + +void idt_set_gate(uint8_t idx, uint32_t base, uint16_t sel, uint8_t flags); diff --git a/kernel/include/irq.h b/kernel/include/irq.h new file mode 100644 index 0000000..1dcbc17 --- /dev/null +++ b/kernel/include/irq.h @@ -0,0 +1,21 @@ +extern void _irq0(void); +extern void _irq1(void); +extern void _irq2(void); +extern void _irq3(void); +extern void _irq4(void); +extern void _irq5(void); +extern void _irq6(void); +extern void _irq7(void); +extern void _irq8(void); +extern void _irq9(void); +extern void _irq10(void); +extern void _irq11(void); +extern void _irq12(void); +extern void _irq13(void); +extern void _irq14(void); +extern void _irq15(void); + +struct regs_t; + +void irq_set_handler(int irq, void (*handler)(struct regs_t*)); +void irq_init(void); diff --git a/kernel/include/isr.h b/kernel/include/isr.h new file mode 100644 index 0000000..d3543af --- /dev/null +++ b/kernel/include/isr.h @@ -0,0 +1,46 @@ +#include + +/* these are all implemented in isr-as.S */ +extern void _isr0(void); +extern void _isr1(void); +extern void _isr2(void); +extern void _isr3(void); +extern void _isr4(void); +extern void _isr5(void); +extern void _isr6(void); +extern void _isr7(void); +extern void _isr8(void); +extern void _isr9(void); +extern void _isr10(void); +extern void _isr11(void); +extern void _isr12(void); +extern void _isr13(void); +extern void _isr14(void); +extern void _isr15(void); +extern void _isr16(void); +extern void _isr17(void); +extern void _isr18(void); +extern void _isr19(void); +extern void _isr20(void); +extern void _isr21(void); +extern void _isr22(void); +extern void _isr23(void); +extern void _isr24(void); +extern void _isr25(void); +extern void _isr26(void); +extern void _isr27(void); +extern void _isr28(void); +extern void _isr29(void); +extern void _isr30(void); +extern void _isr31(void); + +/* installs all the ISR's */ +void isr_init(void); + +/* This defines what the stack looks like after an ISR was running */ +struct regs_t { + uint32_t gs, fs, es, ds; /* pushed the segs last */ + uint32_t edi, esi, ebp, esp, ebx, edx, ecx, eax; /* pushed by 'pusha' */ + uint32_t int_no, err_code; /* our 'push byte #' and ecodes do this */ + uint32_t eip, cs, eflags, useresp, ss; /* pushed by the processor automatically */ +}; -- cgit v1.1