summaryrefslogtreecommitdiff
path: root/kernel/src
diff options
context:
space:
mode:
authornatrixaeria <upezu@student.kit.edu>2019-11-09 01:01:05 +0100
committernatrixaeria <upezu@student.kit.edu>2019-11-09 01:01:05 +0100
commitb7ab3752abbe2138626e85bfb32741deece256be (patch)
tree19dc60d2246a7fd2b8a43268e0035eee6afc5781 /kernel/src
parentd0ecdbef0073a5516c9b7ec56d346cf9f1febd14 (diff)
parent8602b41f192fec43fde735c9c1f99cd59040f1bb (diff)
Merge branch 'exceptions' of dennis:/var/repos/uff-os into exceptions
Diffstat (limited to 'kernel/src')
-rw-r--r--kernel/src/interrupts/exceptions.rs39
-rw-r--r--kernel/src/interrupts/table.rs1
-rw-r--r--kernel/src/lib.rs3
3 files changed, 25 insertions, 18 deletions
diff --git a/kernel/src/interrupts/exceptions.rs b/kernel/src/interrupts/exceptions.rs
index 782dd16..b6fb5a6 100644
--- a/kernel/src/interrupts/exceptions.rs
+++ b/kernel/src/interrupts/exceptions.rs
@@ -1,10 +1,12 @@
-use crate::io::vga_text::OStream;
use x86_64::structures::idt::{InterruptStackFrame, PageFaultErrorCode};
pub extern "x86-interrupt" fn breakpoint_handler(stack_frame: &mut InterruptStackFrame) {
- let mut stdout = OStream::new();
- stdout.print(b"EXCEPTION: BREAKPOINT\n");
- loop {}
+ panic!(
+ "BREAKPOINT at {:x} Flags: {:b} Stack: {:x}",
+ stack_frame.instruction_pointer.as_u64(),
+ stack_frame.cpu_flags,
+ stack_frame.stack_pointer.as_u64()
+ );
}
pub extern "x86-interrupt" fn page_fault_handler(
@@ -13,29 +15,34 @@ pub extern "x86-interrupt" fn page_fault_handler(
) {
use x86_64::registers::control::Cr2;
- let mut stdout = OStream::new();
panic!(
- "PAGE FAULT while accessing address: {:?}{:?}",
- Cr2::read(),
- error_code
+ "PAGE FAULT while accessing address: {:x}{:?}Flags: {:b} Stack: {:x}",
+ Cr2::read().as_u64(),
+ error_code,
+ stack_frame.cpu_flags,
+ stack_frame.stack_pointer.as_u64()
);
- //println!("{:#?}", stack_frame);
}
pub extern "x86-interrupt" fn segment_not_present_handler(
stack_frame: &mut InterruptStackFrame,
error_code: u64,
) {
- let mut stdout = OStream::new();
- stdout.print(b"EXCEPTION: SEGMENT NOT PRESENT\n");
- loop {}
+ panic!(
+ "SEGMENT NOT PRESENT: {:?}Flags: {:b} Stack: {:x}",
+ error_code,
+ stack_frame.cpu_flags,
+ stack_frame.stack_pointer.as_u64()
+ );
}
pub extern "x86-interrupt" fn double_fault_handler(
stack_frame: &mut InterruptStackFrame,
- _error_code: u64,
+ _error_code: u64, // code is always zero
) {
- let mut stdout = OStream::new();
- stdout.print(b"EXCEPTION: DOUBLE FAULT");
- loop {}
+ panic!(
+ "DOUBLE FAULT Flags: {:b} Stack: {:x}",
+ stack_frame.cpu_flags,
+ stack_frame.stack_pointer.as_u64()
+ );
}
diff --git a/kernel/src/interrupts/table.rs b/kernel/src/interrupts/table.rs
index d417824..9541f22 100644
--- a/kernel/src/interrupts/table.rs
+++ b/kernel/src/interrupts/table.rs
@@ -1,4 +1,3 @@
-use crate::io::vga_text::OStream;
use lazy_static::lazy_static;
use x86_64::structures::idt::InterruptDescriptorTable;
diff --git a/kernel/src/lib.rs b/kernel/src/lib.rs
index 623f2bc..d18ca6f 100644
--- a/kernel/src/lib.rs
+++ b/kernel/src/lib.rs
@@ -33,8 +33,9 @@ pub extern "C" fn _start() -> ! {
test_main();
qemu::exit_qemu(qemu::QemuExitCode::Success);
}
+ x86_64::instructions::interrupts::int3();
- let mut stdout = OStream::new();
+ let stdout = OStream::new();
stdout.clear();
panic!("panic! at the disco");