From 21a8479ce99f54012150cc948ed7e5bb066c61e0 Mon Sep 17 00:00:00 2001 From: taitep Date: Wed, 31 Dec 2025 13:16:32 +0100 Subject: Make MMIO devices not have control of the address of exceptions --- src/exceptions.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'src/exceptions.rs') diff --git a/src/exceptions.rs b/src/exceptions.rs index cc18839..0b92a97 100644 --- a/src/exceptions.rs +++ b/src/exceptions.rs @@ -51,6 +51,12 @@ pub enum MemoryExceptionType { PageFault, } +impl MemoryExceptionType { + pub(crate) fn with_addr(self, addr: u64) -> MemoryException { + MemoryException { type_: self, addr } + } +} + #[derive(Debug, Clone, Copy)] pub struct MemoryException { pub type_: MemoryExceptionType, @@ -58,7 +64,7 @@ pub struct MemoryException { } impl MemoryException { - pub(crate) fn to_exception_store(&self) -> Exception { + pub(crate) fn into_exception_store(self) -> Exception { Exception { type_: match self.type_ { MemoryExceptionType::AddressMisaligned => ExceptionType::StoreAmoAddressMisaligned, @@ -69,7 +75,7 @@ impl MemoryException { } } - pub(crate) fn to_exception_instr(&self) -> Exception { + pub(crate) fn into_exception_instr(self) -> Exception { Exception { type_: match self.type_ { MemoryExceptionType::AddressMisaligned => ExceptionType::InstructionAccessFault, @@ -80,7 +86,7 @@ impl MemoryException { } } - pub(crate) fn to_exception_load(&self) -> Exception { + pub(crate) fn into_exception_load(self) -> Exception { Exception { type_: match self.type_ { MemoryExceptionType::AddressMisaligned => ExceptionType::LoadAddressMisaligned, -- cgit v1.2.3