aboutsummaryrefslogtreecommitdiff
path: root/kernel/include/idt.h
diff options
context:
space:
mode:
authorAlex Auvolat <alex.auvolat@ens.fr>2014-12-01 17:24:38 +0100
committerAlex Auvolat <alex.auvolat@ens.fr>2014-12-01 17:24:38 +0100
commit0921a33fc9f3724cb36a03a24b58b0a5bfc519b1 (patch)
tree6f3db52ba8c38928749806cb2d94ca548b3b19bd /kernel/include/idt.h
parent6f11c9e5c15cc8ef936741e5ee7575b731a47e0f (diff)
downloadkogata-0921a33fc9f3724cb36a03a24b58b0a5bfc519b1.tar.gz
kogata-0921a33fc9f3724cb36a03a24b58b0a5bfc519b1.zip
Advance HH, GDT, IDT (details below)
- Implement higher-half in loader with paging (using 4Mb pages) - Add GDT installation code - Add IDT installation code (spend a loong time debugging the ISRs!) - Add CDROM generation scripts - Add scripts to launch bochs (debug) and qemu (debug)
Diffstat (limited to 'kernel/include/idt.h')
-rw-r--r--kernel/include/idt.h40
1 files changed, 40 insertions, 0 deletions
diff --git a/kernel/include/idt.h b/kernel/include/idt.h
new file mode 100644
index 0000000..5730f5e
--- /dev/null
+++ b/kernel/include/idt.h
@@ -0,0 +1,40 @@
+#pragma once
+
+/* The IDT is the system descriptor table that tells the CPU what to do when an interrupt fires.
+ There are three categories of interrupts :
+ - Exceptions ; eg page fault, divide by 0
+ - IRQ : interrupts caused by hardware
+ - System calls : when an applications asks the system to do something */
+
+#include <config.h>
+
+struct idt_entry {
+ uint16_t base_lo; //Low part of address to jump to
+ uint16_t sel; //Kernel segment selector
+ uint8_t always0;
+ uint8_t flags; //Flags
+ uint16_t base_hi; //High part of address to jump to
+} __attribute__((packed));
+typedef struct idt_entry idt_entry_t;
+
+struct idt_ptr {
+ uint16_t limit;
+ uint32_t base;
+} __attribute__((packed));
+typedef struct idt_ptr idt_ptr_t;
+
+struct registers {
+ uint32_t ds; // Data segment selector
+ uint32_t edi, esi, ebp, useless_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, esp, ss; // Pushed by the processor automatically.
+};
+typedef struct registers registers_t;
+
+typedef void (*isr_handler_t)(registers_t*);
+
+void idt_init();
+//void idt_handleIrq(int number, isr_handler_t func); //Set IRQ handler
+
+
+/* vim: set ts=4 sw=4 tw=0 noet :*/