summaryrefslogtreecommitdiff
path: root/src/exceptions.rs
diff options
context:
space:
mode:
authortaitep <taitep@taitep.se>2025-12-26 14:20:27 +0100
committertaitep <taitep@taitep.se>2025-12-26 14:20:27 +0100
commit528b519ce98c21049705526442cbde1672495b49 (patch)
tree487714ef8a58c9610da6b97d76ecd97e58b8b921 /src/exceptions.rs
parent6d9efb7eb85af929f3d6c22111933bb58d1ea07e (diff)
(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
Diffstat (limited to 'src/exceptions.rs')
-rw-r--r--src/exceptions.rs34
1 files changed, 33 insertions, 1 deletions
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,
+ }
+ }
+}