summaryrefslogtreecommitdiff
path: root/kernel
diff options
context:
space:
mode:
authornatrixaeria <upezu@student.kit.edu>2019-11-15 20:03:47 +0100
committernatrixaeria <upezu@student.kit.edu>2019-11-15 20:03:47 +0100
commitc6e0e13db0ba0442018645a1184be50e1ec968e0 (patch)
tree5e505f7ed135de40cab2488339fb62c6a279f5d5 /kernel
parentfe488737784da2196b84dbc22b658bf12a5f58f9 (diff)
parent4953b122d995696bc0b656b1c70c57ba5e96bcfd (diff)
Merge branch 'master' of dennis:/var/repos/uff-os
Diffstat (limited to 'kernel')
-rw-r--r--kernel/src/interrupts/idt.rs16
-rw-r--r--kernel/src/interrupts/interrupts.rs8
-rw-r--r--kernel/src/interrupts/mod.rs18
3 files changed, 34 insertions, 8 deletions
diff --git a/kernel/src/interrupts/idt.rs b/kernel/src/interrupts/idt.rs
index e85ef5a..87f16c0 100644
--- a/kernel/src/interrupts/idt.rs
+++ b/kernel/src/interrupts/idt.rs
@@ -1,3 +1,4 @@
+use super::{exceptions, gdt, interrupts, Interrupts};
use lazy_static::lazy_static;
use x86_64::structures::idt::InterruptDescriptorTable;
@@ -5,19 +6,20 @@ lazy_static! {
static ref IDT: InterruptDescriptorTable = {
let mut idt = InterruptDescriptorTable::new();
idt.breakpoint
- .set_handler_fn(super::exceptions::breakpoint_handler);
+ .set_handler_fn(exceptions::breakpoint_handler);
idt.segment_not_present
- .set_handler_fn(super::exceptions::segment_not_present_handler);
+ .set_handler_fn(exceptions::segment_not_present_handler);
idt.general_protection_fault
- .set_handler_fn(super::exceptions::general_protection_fault_handler);
+ .set_handler_fn(exceptions::general_protection_fault_handler);
unsafe {
idt.double_fault
- .set_handler_fn(super::exceptions::double_fault_handler)
- .set_stack_index(super::gdt::DOUBLE_FAULT_IST_INDEX);
+ .set_handler_fn(exceptions::double_fault_handler)
+ .set_stack_index(gdt::DOUBLE_FAULT_IST_INDEX);
idt.page_fault
- .set_handler_fn(super::exceptions::page_fault_handler)
- .set_stack_index(super::gdt::PAGE_FAULT_IST_INDEX);
+ .set_handler_fn(exceptions::page_fault_handler)
+ .set_stack_index(gdt::PAGE_FAULT_IST_INDEX);
}
+ idt[Interrupts::Timer.as_usize()].set_handler_fn(interrupts::timer_handler);
idt
};
diff --git a/kernel/src/interrupts/interrupts.rs b/kernel/src/interrupts/interrupts.rs
new file mode 100644
index 0000000..6296375
--- /dev/null
+++ b/kernel/src/interrupts/interrupts.rs
@@ -0,0 +1,8 @@
+use super::Interrupts;
+use crate::io::qemu;
+use x86_64::structures::idt::{InterruptStackFrame, PageFaultErrorCode};
+
+pub extern "x86-interrupt" fn timer_handler(stack_frame: &mut InterruptStackFrame) {
+ panic!("Timer interrupt recieved\n\n")
+ // notify End of interrupt
+}
diff --git a/kernel/src/interrupts/mod.rs b/kernel/src/interrupts/mod.rs
index 609fb6d..bc313b8 100644
--- a/kernel/src/interrupts/mod.rs
+++ b/kernel/src/interrupts/mod.rs
@@ -2,8 +2,11 @@ pub mod apic;
pub mod exceptions;
pub mod gdt;
pub mod idt;
+pub mod interrupts;
-#[repr(usize)]
+const INT_OFFSET: u8 = 32;
+
+#[repr(u8)]
#[derive(PartialEq, Clone, Copy)]
pub enum Interrupts {
None,
@@ -12,4 +15,17 @@ pub enum Interrupts {
NotPresent,
Breakpoint,
GeneralProtectionFault,
+
+ Timer = INT_OFFSET,
+ Keyboard = INT_OFFSET + 1,
+}
+
+impl Interrupts {
+ fn as_u8(self) -> u8 {
+ self as u8
+ }
+
+ fn as_usize(self) -> usize {
+ usize::from(self.as_u8())
+ }
}