Add a default implementation for the memory device interface that just returns access faults

This commit is contained in:
2025-12-24 14:06:16 +01:00
parent 09d9064372
commit 66c63ab63c

View File

@@ -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)
}
}