[−][src]Struct riscv_emu_rust::Emulator
RISC-V emulator. It emulates RISC-V CPU and peripheral devices.
Sample code to run the emulator.
// Creates an emulator with arbitary terminal let mut emulator = Emulator::new(Box::new(DefaultTerminal::new())); // Set up program content binary emulator.setup_program(program_content); // Set up Filesystem content binary emulator.setup_filesystem(fs_content); // Go! emulator.run();
Implementations
impl Emulator
[src]
pub fn new(terminal: Box<dyn Terminal>) -> Self
[src]
Creates a new Emulator
. Terminal
is internally used for transferring input/output data to/from Emulator
.
Arguments
terminal
pub fn run(&mut self)
[src]
Runs program set by setup_program()
. Calls run_test()
if the program
is riscv-tests
.
Otherwise calls run_program()
.
pub fn run_program(&mut self)
[src]
Runs program set by setup_program()
. The emulator won't stop forever.
pub fn run_test(&mut self)
[src]
Method for running riscv-tests
program.
The differences from run_program()
are
- Disassembles every instruction and dumps to terminal
- The emulator stops when the test finishes
- Displays the result message (pass/fail) to terminal
pub fn tick(&mut self)
[src]
Runs CPU one cycle
pub fn setup_program(&mut self, data: Vec<u8>)
[src]
Sets up program run by the program. This method analyzes the passed content and configure CPU properly. If the passed contend doesn't seem ELF file, it panics. This method is expected to be called only once.
Arguments
data
Program binary
pub fn setup_filesystem(&mut self, content: Vec<u8>)
[src]
Sets up filesystem. Use this method if program (e.g. Linux) uses filesystem. This method is expected to be called up to only once.
Arguments
content
File system content binary
pub fn setup_dtb(&mut self, content: Vec<u8>)
[src]
Sets up device tree. The emulator has default device tree configuration. If you want to override it, use this method. This method is expected to to be called up to only once.
Arguments
content
DTB content binary
pub fn update_xlen(&mut self, xlen: Xlen)
[src]
pub fn get_mut_terminal(&mut self) -> &mut Box<dyn Terminal>
[src]
Returns mutable reference to Terminal
.
pub fn get_cpu(&self) -> &Cpu
[src]
Returns immutable reference to Cpu
.
pub fn get_mut_cpu(&mut self) -> &mut Cpu
[src]
Returns mutable reference to Cpu
.
Auto Trait Implementations
impl !RefUnwindSafe for Emulator
impl !Send for Emulator
impl !Sync for Emulator
impl Unpin for Emulator
impl !UnwindSafe for Emulator
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>,