diff options
Diffstat (limited to 'kernel/src')
-rw-r--r-- | kernel/src/interrupts/exception_handlers.rs | 20 | ||||
-rw-r--r-- | kernel/src/interrupts/idt.rs | 2 | ||||
-rw-r--r-- | kernel/src/interrupts/interrupt_handlers.rs | 2 | ||||
-rw-r--r-- | kernel/src/interrupts/mod.rs | 4 |
4 files changed, 14 insertions, 14 deletions
diff --git a/kernel/src/interrupts/exception_handlers.rs b/kernel/src/interrupts/exception_handlers.rs index a3ecf9d..cd223bb 100644 --- a/kernel/src/interrupts/exception_handlers.rs +++ b/kernel/src/interrupts/exception_handlers.rs @@ -1,4 +1,4 @@ -use super::Interrupts; +use super::InterruptType; use crate::io::qemu; use x86_64::structures::idt::{InterruptStackFrame, PageFaultErrorCode}; @@ -13,21 +13,21 @@ macro_rules! exception_default { }; } -static mut expected_fault: Interrupts = Interrupts::None; +static mut expected_fault: InterruptType = InterruptType::None; -pub unsafe fn expect_fault(int: Interrupts) { - if expected_fault == Interrupts::None { +pub unsafe fn expect_fault(int: InterruptType) { + if expected_fault == InterruptType::None { expected_fault = int; } } -fn get_expected_fault() -> Interrupts { +fn get_expected_fault() -> InterruptType { unsafe { expected_fault } } pub extern "x86-interrupt" fn breakpoint_handler(stack_frame: &mut InterruptStackFrame) { match get_expected_fault() { - Interrupts::Breakpoint => qemu::exit_qemu(qemu::QemuExitCode::Success), + InterruptType::Breakpoint => qemu::exit_qemu(qemu::QemuExitCode::Success), _ => panic!( "BREAKPOINT exception thrown\n\n{}", exception_default!(stack_frame) @@ -40,7 +40,7 @@ pub extern "x86-interrupt" fn general_protection_fault_handler( error_code: u64, ) { match get_expected_fault() { - Interrupts::GeneralProtectionFault => qemu::exit_qemu(qemu::QemuExitCode::Success), + InterruptType::GeneralProtectionFault => qemu::exit_qemu(qemu::QemuExitCode::Success), _ => panic!( "GENERAL PROTECTION exception thrown\nerror code: {:x}\n{}", error_code, @@ -56,7 +56,7 @@ pub extern "x86-interrupt" fn page_fault_handler( use x86_64::registers::control::Cr2; match get_expected_fault() { - Interrupts::PageFault => qemu::exit_qemu(qemu::QemuExitCode::Success), + InterruptType::PageFault => qemu::exit_qemu(qemu::QemuExitCode::Success), _ => panic!( "PAGE FAULT while accessing address: 0x{:08x}\nerror code: {:?}(0x{:x})\n{}", Cr2::read().as_u64(), @@ -72,7 +72,7 @@ pub extern "x86-interrupt" fn segment_not_present_handler( error_code: u64, ) { match get_expected_fault() { - Interrupts::NotPresent => qemu::exit_qemu(qemu::QemuExitCode::Success), + InterruptType::NotPresent => qemu::exit_qemu(qemu::QemuExitCode::Success), _ => panic!( "SEGMENT NOT PRESENT exception\nerror code: 0x{:x}\n{}", error_code, @@ -86,7 +86,7 @@ pub extern "x86-interrupt" fn double_fault_handler( _error_code: u64, // code is always zero ) { match get_expected_fault() { - Interrupts::DoubleFault => qemu::exit_qemu(qemu::QemuExitCode::Success), + InterruptType::DoubleFault => qemu::exit_qemu(qemu::QemuExitCode::Success), _ => panic!( "DOUBLE FAULT\nthis is a fatal exception\n{}", exception_default!(stack_frame) diff --git a/kernel/src/interrupts/idt.rs b/kernel/src/interrupts/idt.rs index 4978755..eb72fb0 100644 --- a/kernel/src/interrupts/idt.rs +++ b/kernel/src/interrupts/idt.rs @@ -1,4 +1,4 @@ -use super::{exception_handlers, gdt, interrupt_handlers, Interrupts}; +use super::{exception_handlers, gdt, interrupt_handlers, InterruptType}; use lazy_static::lazy_static; use x86_64::structures::idt::InterruptDescriptorTable; diff --git a/kernel/src/interrupts/interrupt_handlers.rs b/kernel/src/interrupts/interrupt_handlers.rs index 4613a40..f05e2dc 100644 --- a/kernel/src/interrupts/interrupt_handlers.rs +++ b/kernel/src/interrupts/interrupt_handlers.rs @@ -1,4 +1,4 @@ -use super::Interrupts; +use super::InterruptType; use crate::io::qemu; use x86_64::structures::idt::{InterruptStackFrame, PageFaultErrorCode}; diff --git a/kernel/src/interrupts/mod.rs b/kernel/src/interrupts/mod.rs index 1cab595..b39eb37 100644 --- a/kernel/src/interrupts/mod.rs +++ b/kernel/src/interrupts/mod.rs @@ -8,7 +8,7 @@ const INT_OFFSET: u8 = 32; #[repr(u8)] #[derive(PartialEq, Clone, Copy)] -pub enum Interrupts { +pub enum InterruptType { None, PageFault, DoubleFault, @@ -20,7 +20,7 @@ pub enum Interrupts { Keyboard = INT_OFFSET + 1, } -impl Interrupts { +impl InterruptType { fn as_u8(self) -> u8 { self as u8 } |