Print PhysAddr
This commit is contained in:
@@ -1,8 +1,8 @@
|
|||||||
use crate::{gdt, print, println};
|
use crate::{gdt, hlt_loop, print, println};
|
||||||
use lazy_static::lazy_static;
|
use lazy_static::lazy_static;
|
||||||
use pic8259::ChainedPics;
|
use pic8259::ChainedPics;
|
||||||
use spin;
|
use spin;
|
||||||
use x86_64::structures::idt::{InterruptDescriptorTable, InterruptStackFrame};
|
use x86_64::structures::idt::{InterruptDescriptorTable, InterruptStackFrame, PageFaultErrorCode};
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy)]
|
#[derive(Debug, Clone, Copy)]
|
||||||
#[repr(u8)]
|
#[repr(u8)]
|
||||||
@@ -22,6 +22,7 @@ lazy_static! {
|
|||||||
}
|
}
|
||||||
idt[InterruptIndex::Timer.as_usize()].set_handler_fn(timer_interrupt_handler);
|
idt[InterruptIndex::Timer.as_usize()].set_handler_fn(timer_interrupt_handler);
|
||||||
idt[InterruptIndex::Keyboard.as_usize()].set_handler_fn(keyboard_interrupt_handler);
|
idt[InterruptIndex::Keyboard.as_usize()].set_handler_fn(keyboard_interrupt_handler);
|
||||||
|
idt.page_fault.set_handler_fn(page_fault_handler);
|
||||||
|
|
||||||
idt
|
idt
|
||||||
};
|
};
|
||||||
@@ -91,6 +92,19 @@ extern "x86-interrupt" fn keyboard_interrupt_handler(_stack_frame: InterruptStac
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern "x86-interrupt" fn page_fault_handler(
|
||||||
|
stack_frame: InterruptStackFrame,
|
||||||
|
error_code: PageFaultErrorCode,
|
||||||
|
) {
|
||||||
|
use x86_64::registers::control::Cr2;
|
||||||
|
|
||||||
|
println!("EXCEPTION: PAGE FAULT");
|
||||||
|
println!("Accessed Address: {:?}", Cr2::read());
|
||||||
|
println!("Error Code: {:?}", error_code);
|
||||||
|
println!("{:?}", stack_frame);
|
||||||
|
hlt_loop();
|
||||||
|
}
|
||||||
|
|
||||||
#[test_case]
|
#[test_case]
|
||||||
fn test_breakpoint_exception() {
|
fn test_breakpoint_exception() {
|
||||||
// invoke a breakpoint exception
|
// invoke a breakpoint exception
|
||||||
|
|||||||
@@ -13,6 +13,14 @@ pub extern "C" fn _start() -> ! {
|
|||||||
|
|
||||||
amix::init();
|
amix::init();
|
||||||
|
|
||||||
|
use x86_64::registers::control::Cr3;
|
||||||
|
|
||||||
|
let (level_4_page_table, _) = Cr3::read();
|
||||||
|
println!(
|
||||||
|
"Level 4 page table at: {:?}",
|
||||||
|
level_4_page_table.start_address()
|
||||||
|
);
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
test_main();
|
test_main();
|
||||||
|
|
||||||
|
|||||||
@@ -129,7 +129,7 @@ impl fmt::Write for Writer {
|
|||||||
lazy_static! {
|
lazy_static! {
|
||||||
pub static ref WRITER: Mutex<Writer> = Mutex::new(Writer {
|
pub static ref WRITER: Mutex<Writer> = Mutex::new(Writer {
|
||||||
column_position: 0,
|
column_position: 0,
|
||||||
color_code: ColorCode::new(Color::White, Color::Black),
|
color_code: ColorCode::new(Color::LightGray, Color::Black),
|
||||||
buffer: unsafe { &mut *(0xb8000 as *mut Buffer) },
|
buffer: unsafe { &mut *(0xb8000 as *mut Buffer) },
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user