From 4953b122d995696bc0b656b1c70c57ba5e96bcfd Mon Sep 17 00:00:00 2001 From: Dennis Kobert Date: Fri, 15 Nov 2019 20:02:48 +0100 Subject: Implement timer interrupt handler --- kernel/src/interrupts/mod.rs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'kernel/src/interrupts/mod.rs') diff --git a/kernel/src/interrupts/mod.rs b/kernel/src/interrupts/mod.rs index 087a59c..076c61c 100644 --- a/kernel/src/interrupts/mod.rs +++ b/kernel/src/interrupts/mod.rs @@ -1,8 +1,11 @@ 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, @@ -11,4 +14,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()) + } } -- cgit v1.2.3-54-g00ecf