Refactor architecture-specific page fault handling

This commit is contained in:
YanWQ-monad
2024-07-23 10:09:02 +08:00
committed by Tate, Hongliang Tian
parent c5009e38f1
commit 2a6733579d
9 changed files with 190 additions and 174 deletions

View File

@ -196,7 +196,7 @@ impl UserContextApiInternal for UserContext {
///
/// But there exists some vector which are special. Vector 1 can be both fault or trap and vector 2 is interrupt.
/// So here we also define FaultOrTrap and Interrupt
#[derive(PartialEq, Eq, Debug)]
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
pub enum CpuExceptionType {
/// CPU faults. Faults can be corrected, and the program may continue as if nothing happened.
Fault,
@ -213,7 +213,7 @@ pub enum CpuExceptionType {
}
/// CPU exception.
#[derive(Debug, Eq, PartialEq)]
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
pub struct CpuException {
/// The ID of the CPU exception.
pub number: u16,
@ -323,6 +323,13 @@ impl CpuException {
}
}
impl CpuExceptionInfo {
/// Get corresponding CPU exception
pub fn cpu_exception(&self) -> CpuException {
EXCEPTION_LIST[self.id]
}
}
impl UserContextApi for UserContext {
fn trap_number(&self) -> usize {
self.user_context.trap_num