Added shutdown system call
This commit is contained in:
@ -230,7 +230,13 @@ impl Machine {
|
||||
|
||||
self.set_status(MachineStatus::SystemMode);
|
||||
// Handle the interruption
|
||||
exception::call(exception, self); // todo: return error if the syscall code is invalid
|
||||
match exception::call(exception, self) {
|
||||
Ok(MachineOk::Shutdown) => {
|
||||
self.set_status(MachineStatus::UserMode);
|
||||
return Ok(MachineOk::Shutdown);
|
||||
}
|
||||
_ => ()
|
||||
} // todo: return error if the syscall code is invalid
|
||||
self.set_status(MachineStatus::UserMode);
|
||||
Ok(MachineOk::Ok)
|
||||
}
|
||||
@ -243,7 +249,8 @@ impl Machine {
|
||||
pub fn run(&mut self) {
|
||||
loop {
|
||||
match self.one_instruction() {
|
||||
Ok(_) => println!("hello"),
|
||||
Ok(MachineOk::Ok) => println!("hello"),
|
||||
Ok(MachineOk::Shutdown) => break,
|
||||
Err(e) => { if e.to_string().contains("System") { break; } panic!("FATAL at pc {} -> {}", self.pc, e) }
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user