summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortaitep <taitep@taitep.se>2025-12-24 14:06:16 +0100
committertaitep <taitep@taitep.se>2025-12-24 14:06:16 +0100
commit66c63ab63c57e8bacd580f7e69a852cf5ab5f88e (patch)
tree0a8dfc488a77930c723c937fb6c4c169f923606c
parent09d90643726d2a86952473e27b6e5d64543e41a0 (diff)
Add a default implementation for the memory device interface that just returns access faults
-rw-r--r--src/mem.rs41
1 files changed, 31 insertions, 10 deletions
diff --git a/src/mem.rs b/src/mem.rs
index 21cabec..5576905 100644
--- a/src/mem.rs
+++ b/src/mem.rs
@@ -349,17 +349,38 @@ pub struct DeviceEntry {
pub interface: Arc<dyn MemDeviceInterface>,
}
+#[allow(unused_variables)]
pub trait MemDeviceInterface {
- fn write_dword(&self, page: PageNum, offset: u16, value: DWord) -> Result<(), ExceptionType>;
- fn write_word(&self, page: PageNum, offset: u16, value: Word) -> Result<(), ExceptionType>;
- fn write_hword(&self, page: PageNum, offset: u16, value: HWord) -> Result<(), ExceptionType>;
- fn write_byte(&self, page: PageNum, offset: u16, value: Byte) -> Result<(), ExceptionType>;
+ fn write_dword(&self, page: PageNum, offset: u16, value: DWord) -> Result<(), ExceptionType> {
+ Err(ExceptionType::StoreAmoAccessFault)
+ }
+ fn write_word(&self, page: PageNum, offset: u16, value: Word) -> Result<(), ExceptionType> {
+ Err(ExceptionType::StoreAmoAccessFault)
+ }
+ fn write_hword(&self, page: PageNum, offset: u16, value: HWord) -> Result<(), ExceptionType> {
+ Err(ExceptionType::StoreAmoAccessFault)
+ }
+ fn write_byte(&self, page: PageNum, offset: u16, value: Byte) -> Result<(), ExceptionType> {
+ Err(ExceptionType::StoreAmoAccessFault)
+ }
- fn read_dword(&self, page: PageNum, offset: u16) -> Result<DWord, ExceptionType>;
- fn read_word(&self, page: PageNum, offset: u16) -> Result<Word, ExceptionType>;
- fn read_hword(&self, page: PageNum, offset: u16) -> Result<HWord, ExceptionType>;
- fn read_byte(&self, page: PageNum, offset: u16) -> Result<Byte, ExceptionType>;
+ fn read_dword(&self, page: PageNum, offset: u16) -> Result<DWord, ExceptionType> {
+ Err(ExceptionType::LoadAccessFault)
+ }
+ fn read_word(&self, page: PageNum, offset: u16) -> Result<Word, ExceptionType> {
+ Err(ExceptionType::LoadAccessFault)
+ }
+ fn read_hword(&self, page: PageNum, offset: u16) -> Result<HWord, ExceptionType> {
+ Err(ExceptionType::LoadAccessFault)
+ }
+ fn read_byte(&self, page: PageNum, offset: u16) -> Result<Byte, ExceptionType> {
+ Err(ExceptionType::LoadAccessFault)
+ }
- fn get_atomic_word(&self, page: PageNum, offset: u16) -> Result<&AtomicU32, ExceptionType>;
- fn get_atomic_dword(&self, page: PageNum, offset: u16) -> Result<&AtomicU64, ExceptionType>;
+ fn get_atomic_word(&self, page: PageNum, offset: u16) -> Result<&AtomicU32, ExceptionType> {
+ Err(ExceptionType::StoreAmoAccessFault)
+ }
+ fn get_atomic_dword(&self, page: PageNum, offset: u16) -> Result<&AtomicU64, ExceptionType> {
+ Err(ExceptionType::StoreAmoAccessFault)
+ }
}