summaryrefslogtreecommitdiff
path: root/src/exceptions.rs
diff options
context:
space:
mode:
authortaitep <taitep@taitep.se>2025-12-31 13:16:32 +0100
committertaitep <taitep@taitep.se>2025-12-31 13:16:32 +0100
commit21a8479ce99f54012150cc948ed7e5bb066c61e0 (patch)
tree49c5e5fa8736f7990016e410f2714d6e1b0db8ee /src/exceptions.rs
parent09fe12f5165d582c7b83537e38ef8e5d85716f8b (diff)
Make MMIO devices not have control of the address of exceptions
Diffstat (limited to 'src/exceptions.rs')
-rw-r--r--src/exceptions.rs12
1 files changed, 9 insertions, 3 deletions
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,