mirror of
https://github.com/phil-opp/blog_os.git
synced 2025-12-16 14:27:49 +00:00
Test for new idt::set_default_handler macro of x86_64 crate
This commit is contained in:
56
Cargo.lock
generated
56
Cargo.lock
generated
@@ -33,7 +33,7 @@ dependencies = [
|
||||
"spin",
|
||||
"uart_16550",
|
||||
"volatile",
|
||||
"x86_64",
|
||||
"x86_64 0.11.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -160,6 +160,24 @@ version = "0.1.0-alpha.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5894c618ce612a3fa23881b152b608bafb8c56cfc22f434a3ba3120b40f7b587"
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "beae6331a816b1f65d04c45b078fd8e6c93e8071771f41b8163255bbd8d7c8fa"
|
||||
dependencies = [
|
||||
"unicode-xid",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "1.0.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "aa563d17ecb180e500da1cfd2b028310ac758de548efdd203e18f283af693f37"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "scopeguard"
|
||||
version = "1.1.0"
|
||||
@@ -181,6 +199,17 @@ dependencies = [
|
||||
"lock_api",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "1.0.33"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e8d5d96e8cbb005d6959f119f773bfaebb5684296108fb32600c00cde305b2cd"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"unicode-xid",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "uart_16550"
|
||||
version = "0.2.7"
|
||||
@@ -188,9 +217,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e58fc40dc1712664fc9b0a7bd8ca2f21ab49960924fb245a80a05e1e92f3dfe9"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"x86_64",
|
||||
"x86_64 0.11.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "unicode-xid"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564"
|
||||
|
||||
[[package]]
|
||||
name = "volatile"
|
||||
version = "0.2.6"
|
||||
@@ -206,3 +241,20 @@ dependencies = [
|
||||
"bit_field",
|
||||
"bitflags",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "x86_64"
|
||||
version = "0.11.1"
|
||||
dependencies = [
|
||||
"bit_field",
|
||||
"bitflags",
|
||||
"x86_64-idt-default-handler",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "x86_64-idt-default-handler"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
@@ -16,7 +16,7 @@ harness = false
|
||||
bootloader = { version = "0.9.3", features = ["map_physical_memory"]}
|
||||
volatile = "0.2.6"
|
||||
spin = "0.5.2"
|
||||
x86_64 = "0.11.0"
|
||||
x86_64 = { path = "../../x86_64" }
|
||||
uart_16550 = "0.2.0"
|
||||
pic8259_simple = "0.2.0"
|
||||
pc-keyboard = "0.5.0"
|
||||
|
||||
@@ -2,7 +2,9 @@ use crate::{gdt, hlt_loop, print, println};
|
||||
use lazy_static::lazy_static;
|
||||
use pic8259_simple::ChainedPics;
|
||||
use spin;
|
||||
use x86_64::structures::idt::{InterruptDescriptorTable, InterruptStackFrame, PageFaultErrorCode};
|
||||
use x86_64::structures::idt::{
|
||||
self, InterruptDescriptorTable, InterruptStackFrame, PageFaultErrorCode,
|
||||
};
|
||||
|
||||
pub const PIC_1_OFFSET: u8 = 32;
|
||||
pub const PIC_2_OFFSET: u8 = PIC_1_OFFSET + 8;
|
||||
@@ -30,6 +32,7 @@ pub static PICS: spin::Mutex<ChainedPics> =
|
||||
lazy_static! {
|
||||
static ref IDT: InterruptDescriptorTable = {
|
||||
let mut idt = InterruptDescriptorTable::new();
|
||||
|
||||
idt.breakpoint.set_handler_fn(breakpoint_handler);
|
||||
idt.page_fault.set_handler_fn(page_fault_handler);
|
||||
unsafe {
|
||||
@@ -37,8 +40,7 @@ lazy_static! {
|
||||
.set_handler_fn(double_fault_handler)
|
||||
.set_stack_index(gdt::DOUBLE_FAULT_IST_INDEX);
|
||||
}
|
||||
idt[InterruptIndex::Timer.as_usize()].set_handler_fn(timer_interrupt_handler);
|
||||
idt[InterruptIndex::Keyboard.as_usize()].set_handler_fn(keyboard_interrupt_handler);
|
||||
idt::set_default_handler!(&mut idt, default_handler, 32..);
|
||||
idt
|
||||
};
|
||||
}
|
||||
@@ -47,6 +49,18 @@ pub fn init_idt() {
|
||||
IDT.load();
|
||||
}
|
||||
|
||||
fn default_handler(stack_frame: &mut InterruptStackFrame, index: u8) {
|
||||
if index == 32 {
|
||||
print!("{} ", index);
|
||||
} else {
|
||||
println!("INTERRUPT {}: \n{:#?}", index, stack_frame);
|
||||
}
|
||||
|
||||
unsafe {
|
||||
PICS.lock().notify_end_of_interrupt(index);
|
||||
}
|
||||
}
|
||||
|
||||
extern "x86-interrupt" fn breakpoint_handler(stack_frame: &mut InterruptStackFrame) {
|
||||
println!("EXCEPTION: BREAKPOINT\n{:#?}", stack_frame);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user