mirror of
https://github.com/phil-opp/blog_os.git
synced 2025-12-16 22:37:49 +00:00
Remove print_error and use normal println in exception handlers
(cherry picked from commit 9b83b2853e)
This commit is contained in:
@@ -113,29 +113,24 @@ struct ExceptionStackFrame {
|
|||||||
stack_segment: u64,
|
stack_segment: u64,
|
||||||
}
|
}
|
||||||
|
|
||||||
use vga_buffer::print_error;
|
|
||||||
|
|
||||||
extern "C" fn divide_by_zero_handler(stack_frame: *const ExceptionStackFrame) {
|
extern "C" fn divide_by_zero_handler(stack_frame: *const ExceptionStackFrame) {
|
||||||
unsafe {
|
let stack_frame = unsafe { &*stack_frame };
|
||||||
print_error(format_args!("EXCEPTION: DIVIDE BY ZERO\n{:#?}", *stack_frame));
|
println!("\nEXCEPTION: DIVIDE BY ZERO\n{:#?}", stack_frame);
|
||||||
}
|
|
||||||
loop {}
|
loop {}
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" fn breakpoint_handler(stack_frame: *const ExceptionStackFrame) {
|
extern "C" fn breakpoint_handler(stack_frame: *const ExceptionStackFrame) {
|
||||||
unsafe {
|
let stack_frame = unsafe { &*stack_frame };
|
||||||
print_error(format_args!("EXCEPTION: BREAKPOINT at {:#x}\n{:#?}",
|
println!("\nEXCEPTION: BREAKPOINT at {:#x}\n{:#?}",
|
||||||
(*stack_frame).instruction_pointer,
|
stack_frame.instruction_pointer,
|
||||||
*stack_frame));
|
stack_frame);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" fn invalid_opcode_handler(stack_frame: *const ExceptionStackFrame) {
|
extern "C" fn invalid_opcode_handler(stack_frame: *const ExceptionStackFrame) {
|
||||||
unsafe {
|
let stack_frame = unsafe { &*stack_frame };
|
||||||
print_error(format_args!("EXCEPTION: INVALID OPCODE at {:#x}\n{:#?}",
|
println!("\nEXCEPTION: INVALID OPCODE at {:#x}\n{:#?}",
|
||||||
(*stack_frame).instruction_pointer,
|
stack_frame.instruction_pointer,
|
||||||
*stack_frame));
|
stack_frame);
|
||||||
}
|
|
||||||
loop {}
|
loop {}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -150,13 +145,12 @@ bitflags! {
|
|||||||
}
|
}
|
||||||
|
|
||||||
extern "C" fn page_fault_handler(stack_frame: *const ExceptionStackFrame, error_code: u64) {
|
extern "C" fn page_fault_handler(stack_frame: *const ExceptionStackFrame, error_code: u64) {
|
||||||
|
let stack_frame = unsafe { &*stack_frame };
|
||||||
use x86::controlregs;
|
use x86::controlregs;
|
||||||
unsafe {
|
println!("\nEXCEPTION: PAGE FAULT while accessing {:#x}\nerror code: \
|
||||||
print_error(format_args!("EXCEPTION: PAGE FAULT while accessing {:#x}\nerror code: \
|
|
||||||
{:?}\n{:#?}",
|
{:?}\n{:#?}",
|
||||||
controlregs::cr2(),
|
unsafe { controlregs::cr2() },
|
||||||
PageFaultErrorCode::from_bits(error_code).unwrap(),
|
PageFaultErrorCode::from_bits(error_code).unwrap(),
|
||||||
*stack_frame));
|
stack_frame);
|
||||||
}
|
|
||||||
loop {}
|
loop {}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,18 +43,6 @@ pub fn clear_screen() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub unsafe fn print_error(fmt: fmt::Arguments) {
|
|
||||||
use core::fmt::Write;
|
|
||||||
|
|
||||||
let mut writer = Writer {
|
|
||||||
column_position: 0,
|
|
||||||
color_code: ColorCode::new(Color::Red, Color::Black),
|
|
||||||
buffer: Unique::new(0xb8000 as *mut _),
|
|
||||||
};
|
|
||||||
writer.new_line();
|
|
||||||
writer.write_fmt(fmt);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
#[derive(Debug, Clone, Copy)]
|
#[derive(Debug, Clone, Copy)]
|
||||||
#[repr(u8)]
|
#[repr(u8)]
|
||||||
|
|||||||
Reference in New Issue
Block a user