Added general failure case in raise exception and removed break in main loop for system exceptions
This commit is contained in:
parent
69f91170f6
commit
3685bb6590
@ -227,7 +227,6 @@ impl Machine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn raise_exception(&mut self, exception: ExceptionType, address : u64, system: &mut System) -> Result<MachineOk, MachineError>{
|
pub fn raise_exception(&mut self, exception: ExceptionType, address : u64, system: &mut System) -> Result<MachineOk, MachineError>{
|
||||||
|
|
||||||
self.set_status(MachineStatus::SystemMode);
|
self.set_status(MachineStatus::SystemMode);
|
||||||
// Handle the interruption
|
// Handle the interruption
|
||||||
match exception::call(exception, self, system) {
|
match exception::call(exception, self, system) {
|
||||||
@ -235,7 +234,7 @@ impl Machine {
|
|||||||
self.set_status(MachineStatus::UserMode);
|
self.set_status(MachineStatus::UserMode);
|
||||||
return Ok(MachineOk::Shutdown);
|
return Ok(MachineOk::Shutdown);
|
||||||
}
|
}
|
||||||
_ => ()
|
_ => Err(format!("Syscall {:?} invalid or not implemented", exception))?
|
||||||
} // todo: return error if the syscall code is invalid
|
} // todo: return error if the syscall code is invalid
|
||||||
self.set_status(MachineStatus::UserMode);
|
self.set_status(MachineStatus::UserMode);
|
||||||
Ok(MachineOk::Ok)
|
Ok(MachineOk::Ok)
|
||||||
@ -251,7 +250,7 @@ impl Machine {
|
|||||||
match self.one_instruction(system) {
|
match self.one_instruction(system) {
|
||||||
Ok(MachineOk::Ok) => println!("hello"),
|
Ok(MachineOk::Ok) => println!("hello"),
|
||||||
Ok(MachineOk::Shutdown) => break,
|
Ok(MachineOk::Shutdown) => break,
|
||||||
Err(e) => { if e.to_string().contains("System") { break; } panic!("FATAL at pc {} -> {}", self.pc, e) }
|
Err(e) => panic!("FATAL at pc {} -> {}", self.pc, e)
|
||||||
}
|
}
|
||||||
self.write_int_register(0, 0); // In case an instruction write on register 0
|
self.write_int_register(0, 0); // In case an instruction write on register 0
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user