Possibly deprecate x86-interrupt CC
This commit is contained in:
parent
8c30acfc5b
commit
e124f3c2c6
@ -4,14 +4,13 @@
|
|||||||
use lazy_static::lazy_static;
|
use lazy_static::lazy_static;
|
||||||
use x86_64::structures::idt::*;
|
use x86_64::structures::idt::*;
|
||||||
|
|
||||||
use crate::format;
|
|
||||||
|
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
pub static ref IDT: InterruptDescriptorTable = {
|
pub static ref IDT: InterruptDescriptorTable = {
|
||||||
let mut idt = InterruptDescriptorTable::new();
|
let idt = InterruptDescriptorTable::new();
|
||||||
// TODO: Re-implement this once the x86-interrupt ABI is fixed.
|
// TODO: Re-implement this once the x86-interrupt ABI is fixed.
|
||||||
|
// Alternatively: Write our own interrupt handler wrappers.
|
||||||
//idt.double_fault.set_handler_fn(double_fault);
|
//idt.double_fault.set_handler_fn(double_fault);
|
||||||
idt.page_fault.set_handler_fn(page_fault);
|
//idt.page_fault.set_handler_fn(page_fault);
|
||||||
idt
|
idt
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -20,6 +19,7 @@ lazy_static! {
|
|||||||
// crate::interrupt::double_fault(&format!("{info:#?}"));
|
// crate::interrupt::double_fault(&format!("{info:#?}"));
|
||||||
//}
|
//}
|
||||||
|
|
||||||
|
/*
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
extern "x86-interrupt" fn page_fault(info: InterruptStackFrame, errcode: PageFaultErrorCode) {
|
extern "x86-interrupt" fn page_fault(info: InterruptStackFrame, errcode: PageFaultErrorCode) {
|
||||||
if errcode.contains(PageFaultErrorCode::USER_MODE) {
|
if errcode.contains(PageFaultErrorCode::USER_MODE) {
|
||||||
@ -37,7 +37,9 @@ extern "x86-interrupt" fn page_fault(info: InterruptStackFrame, errcode: PageFau
|
|||||||
core::arch::asm! {"mov {}, cr2", out(reg) a};
|
core::arch::asm! {"mov {}, cr2", out(reg) a};
|
||||||
a
|
a
|
||||||
};
|
};
|
||||||
crate::interrupt::page_fault(addr, &format!("{info:#?}"))
|
let info_formatted = format!("{info:#?}");
|
||||||
|
crate::interrupt::page_fault(addr, info_formatted.as_str().as_ptr(), info_formatted.as_str().len())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
@ -1,11 +1,16 @@
|
|||||||
// Copyright (c) 2025 shibedrill
|
// Copyright (c) 2025 shibedrill
|
||||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
#[allow(dead_code)]
|
use core::str;
|
||||||
pub fn double_fault(info: &str) -> ! {
|
|
||||||
panic!("Double fault: {}", info);
|
#[unsafe(no_mangle)]
|
||||||
|
extern "C" fn double_fault(info: *const u8, info_len: usize) -> ! {
|
||||||
|
let info_slice = unsafe {&str::from_raw_parts(info, info_len)};
|
||||||
|
panic!("Double fault: {}", info_slice);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn page_fault(addr: usize, info: &str) -> ! {
|
#[unsafe(no_mangle)]
|
||||||
panic!("Page fault at 0x{:X}: {}", addr, info);
|
pub extern "C" fn page_fault(addr: usize, info: *const u8, info_len: usize) -> ! {
|
||||||
|
let info_slice = unsafe { &str::from_raw_parts(info, info_len) };
|
||||||
|
panic!("Page fault at 0x{:X}: {}", addr, info_slice);
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
#![no_std]
|
#![no_std]
|
||||||
#![no_main]
|
#![no_main]
|
||||||
#![feature(allocator_api)]
|
#![feature(allocator_api)]
|
||||||
#![feature(abi_x86_interrupt)]
|
#![feature(str_from_raw_parts)]
|
||||||
|
|
||||||
mod arch;
|
mod arch;
|
||||||
mod boot;
|
mod boot;
|
||||||
|
Loading…
Reference in New Issue
Block a user