From 528b519ce98c21049705526442cbde1672495b49 Mon Sep 17 00:00:00 2001 From: taitep Date: Fri, 26 Dec 2025 14:20:27 +0100 Subject: (BIG CHANGE) memory handling has changed, MMIO is now a 2 level page table, misaligned access supported, addresses not internally split to page and offset immediately, all load/store instructions implemented. Might still have bugs --- src/exceptions.rs | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) (limited to 'src/exceptions.rs') diff --git a/src/exceptions.rs b/src/exceptions.rs index 2929d65..7f00e5c 100644 --- a/src/exceptions.rs +++ b/src/exceptions.rs @@ -10,7 +10,7 @@ use int_enum::IntEnum; #[allow(dead_code)] #[derive(Debug, Clone, Copy, PartialEq, Eq, IntEnum)] pub enum ExceptionType { - InstructionAccessMisaligned = 0, + InstructionAddressMisaligned = 0, InstructionAccessFault = 1, IllegalInstruction = 2, Breakpoint = 3, @@ -28,3 +28,35 @@ pub enum ExceptionType { SoftwareCheck = 18, HardwareError = 19, } + +pub enum MemoryExceptionType { + AddressMisaligned, + AccessFault, + PageFault, +} + +impl MemoryExceptionType { + pub(crate) fn to_exception_store(&self) -> ExceptionType { + match self { + Self::AddressMisaligned => ExceptionType::StoreAmoAddressMisaligned, + Self::AccessFault => ExceptionType::StoreAmoAccessFault, + Self::PageFault => ExceptionType::StoreAmoPageFault, + } + } + + pub(crate) fn to_exception_instr(&self) -> ExceptionType { + match self { + Self::AddressMisaligned => ExceptionType::InstructionAddressMisaligned, + Self::AccessFault => ExceptionType::InstructionAccessFault, + Self::PageFault => ExceptionType::InstructionPageFault, + } + } + + pub(crate) fn to_exception_load(&self) -> ExceptionType { + match self { + Self::AddressMisaligned => ExceptionType::LoadAddressMisaligned, + Self::AccessFault => ExceptionType::LoadAccessFault, + Self::PageFault => ExceptionType::LoadPageFault, + } + } +} -- cgit v1.2.3