[−][src]Struct riscv_emu_rust::mmu::Mmu
Emulates Memory Management Unit. It holds the Main memory and peripheral devices, maps address to them, and accesses them depending on address. It also manages virtual-physical address translation and memoty protection. It may also be said Bus. @TODO: Memory protection is not implemented yet. We should support.
Implementations
impl Mmu
[src]
pub fn new(xlen: Xlen, terminal: Box<dyn Terminal>) -> Self
[src]
pub fn update_xlen(&mut self, xlen: Xlen)
[src]
pub fn init_memory(&mut self, capacity: u64)
[src]
pub fn init_disk(&mut self, data: Vec<u8>)
[src]
Initializes Virtio block disk. This method is expected to be called only once.
Arguments
data
Filesystem binary content
pub fn init_dtb(&mut self, data: Vec<u8>)
[src]
pub fn tick(&mut self, mip: &mut u64)
[src]
Runs one cycle of MMU and peripheral devices.
pub fn update_addressing_mode(&mut self, new_addressing_mode: AddressingMode)
[src]
pub fn update_privilege_mode(&mut self, mode: PrivilegeMode)
[src]
pub fn update_ppn(&mut self, ppn: u64)
[src]
pub fn fetch_word(&mut self, v_address: u64) -> Result<u32, Trap>
[src]
Fetches instruction four bytes. This method takes virtual address and translates into physical address inside.
Arguments
v_address
Virtual address
pub fn load(&mut self, v_address: u64) -> Result<u8, Trap>
[src]
Loads an byte. This method takes virtual address and translates into physical address inside.
Arguments
v_address
Virtual address
pub fn load_halfword(&mut self, v_address: u64) -> Result<u16, Trap>
[src]
Loads two bytes. This method takes virtual address and translates into physical address inside.
Arguments
v_address
Virtual address
pub fn load_word(&mut self, v_address: u64) -> Result<u32, Trap>
[src]
Loads four bytes. This method takes virtual address and translates into physical address inside.
Arguments
v_address
Virtual address
pub fn load_doubleword(&mut self, v_address: u64) -> Result<u64, Trap>
[src]
Loads eight bytes. This method takes virtual address and translates into physical address inside.
Arguments
v_address
Virtual address
pub fn store(&mut self, v_address: u64, value: u8) -> Result<(), Trap>
[src]
Store an byte. This method takes virtual address and translates into physical address inside.
Arguments
v_address
Virtual addressvalue
pub fn store_halfword(&mut self, v_address: u64, value: u16) -> Result<(), Trap>
[src]
Stores two bytes. This method takes virtual address and translates into physical address inside.
Arguments
v_address
Virtual addressvalue
data written
pub fn store_word(&mut self, v_address: u64, value: u32) -> Result<(), Trap>
[src]
Stores four bytes. This method takes virtual address and translates into physical address inside.
Arguments
v_address
Virtual addressvalue
data written
pub fn store_doubleword(
&mut self,
v_address: u64,
value: u64
) -> Result<(), Trap>
[src]
&mut self,
v_address: u64,
value: u64
) -> Result<(), Trap>
Stores eight bytes. This method takes virtual address and translates into physical address inside.
Arguments
v_address
Virtual addressvalue
data written
pub fn load_word_raw(&mut self, p_address: u64) -> u32
[src]
Loads four bytes from main memory or peripheral devices depending on physical address.
Arguments
p_address
Physical address
pub fn store_raw(&mut self, p_address: u64, value: u8)
[src]
Stores a byte to main memory or peripheral devices depending on physical address.
Arguments
p_address
Physical addressvalue
data written
pub fn validate_address(&mut self, v_address: u64) -> Result<bool, ()>
[src]
Checks if passed virtual address is valid (pointing a certain device) or not. This method can return page fault trap.
Arguments
v_address
Virtual address
pub fn get_clint(&self) -> &Clint
[src]
Returns immutable reference to Clint
.
pub fn get_mut_clint(&mut self) -> &mut Clint
[src]
Returns mutable reference to Clint
.
pub fn get_mut_uart(&mut self) -> &mut Uart
[src]
Returns mutable reference to Uart
.
Auto Trait Implementations
impl !RefUnwindSafe for Mmu
impl !Send for Mmu
impl !Sync for Mmu
impl Unpin for Mmu
impl !UnwindSafe for Mmu
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,