Add a default implementation for the memory device interface that just returns access faults
This commit is contained in:
45
src/mem.rs
45
src/mem.rs
@@ -349,17 +349,38 @@ pub struct DeviceEntry {
|
|||||||
pub interface: Arc<dyn MemDeviceInterface>,
|
pub interface: Arc<dyn MemDeviceInterface>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(unused_variables)]
|
||||||
pub trait MemDeviceInterface {
|
pub trait MemDeviceInterface {
|
||||||
fn write_dword(&self, page: PageNum, offset: u16, value: DWord) -> Result<(), ExceptionType>;
|
fn write_dword(&self, page: PageNum, offset: u16, value: DWord) -> Result<(), ExceptionType> {
|
||||||
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>;
|
}
|
||||||
fn write_byte(&self, page: PageNum, offset: u16, value: Byte) -> Result<(), ExceptionType>;
|
fn write_word(&self, page: PageNum, offset: u16, value: Word) -> 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 write_hword(&self, page: PageNum, offset: u16, value: HWord) -> Result<(), ExceptionType> {
|
||||||
fn read_hword(&self, page: PageNum, offset: u16) -> Result<HWord, ExceptionType>;
|
Err(ExceptionType::StoreAmoAccessFault)
|
||||||
fn read_byte(&self, page: PageNum, offset: u16) -> Result<Byte, ExceptionType>;
|
}
|
||||||
|
fn write_byte(&self, page: PageNum, offset: u16, value: Byte) -> Result<(), 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>;
|
}
|
||||||
|
|
||||||
|
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> {
|
||||||
|
Err(ExceptionType::StoreAmoAccessFault)
|
||||||
|
}
|
||||||
|
fn get_atomic_dword(&self, page: PageNum, offset: u16) -> Result<&AtomicU64, ExceptionType> {
|
||||||
|
Err(ExceptionType::StoreAmoAccessFault)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user