Implement ECALL and EBREAK, the final RV64I instructions!
This commit is contained in:
@@ -13,7 +13,10 @@ use crate::{
|
||||
consts::DWord,
|
||||
core::Core,
|
||||
decode::Instruction,
|
||||
exceptions::{Exception, ExceptionType::IllegalInstruction},
|
||||
exceptions::{
|
||||
Exception,
|
||||
ExceptionType::{self, IllegalInstruction},
|
||||
},
|
||||
};
|
||||
|
||||
fn illegal(instr: Instruction) -> Result<(), Exception> {
|
||||
@@ -130,6 +133,15 @@ pub(crate) fn find_and_exec(instr: Instruction, core: &mut Core) -> Result<(), E
|
||||
}
|
||||
_ => illegal(instr),
|
||||
},
|
||||
0b11100 => match (instr.funct3(), instr.funct12(), instr.rs1(), instr.rd()) {
|
||||
(0b000, 0b000000000000, 0, 0) => {
|
||||
// TODO: When privilege modes are added, make the exception raised by ecall
|
||||
// depend on privilege mode
|
||||
Err(ExceptionType::EnvironmentCallFromMMode.with_no_value())
|
||||
}
|
||||
(0b000, 0b000000000001, 0, 0) => Err(ExceptionType::Breakpoint.with_no_value()),
|
||||
_ => illegal(instr),
|
||||
},
|
||||
_ => illegal(instr),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user