60 lines
1.8 KiB
Rust
60 lines
1.8 KiB
Rust
|
use crate::simulator::machine::{ExceptionType, Machine};
|
||
|
|
||
|
|
||
|
pub const SC_HALT: u8 = 0;
|
||
|
pub const SC_EXIT: u8 = 1;
|
||
|
pub const SC_EXEC: u8 = 2;
|
||
|
pub const SC_JOIN: u8 = 3;
|
||
|
pub const SC_CREATE: u8 = 4;
|
||
|
pub const SC_OPEN: u8 = 5;
|
||
|
pub const SC_READ: u8 = 6;
|
||
|
pub const SC_WRITE: u8 = 7;
|
||
|
pub const SC_SEEK: u8 = 8;
|
||
|
pub const SC_CLOSE: u8 = 9;
|
||
|
pub const SC_NEW_THREAD: u8 = 10;
|
||
|
pub const SC_YIELD: u8 = 11;
|
||
|
pub const SC_PERROR: u8 = 12;
|
||
|
pub const SC_P: u8 = 13;
|
||
|
pub const SC_V: u8 = 14;
|
||
|
pub const SC_SEM_CREATE: u8 = 15 ;
|
||
|
pub const SC_SEM_DESTROY: u8 = 16;
|
||
|
pub const SC_LOCK_CREATE: u8 = 17 ;
|
||
|
pub const SC_LOCK_DESTROY: u8 = 18 ;
|
||
|
pub const SC_LOCK_ACQUIRE: u8 = 19 ;
|
||
|
pub const SC_LOCK_RELEASE: u8 = 20 ;
|
||
|
pub const SC_COND_CREATE: u8 = 21 ;
|
||
|
pub const SC_COND_DESTROY: u8 = 22 ;
|
||
|
pub const SC_COND_WAIT: u8 = 23 ;
|
||
|
pub const SC_COND_SIGNAL: u8 = 24;
|
||
|
pub const SC_COND_BROADCAST: u8 = 25;
|
||
|
pub const SC_TTY_SEND: u8 = 26;
|
||
|
pub const SC_TTY_RECEIVE: u8 = 27;
|
||
|
pub const SC_MKDIR: u8 = 28;
|
||
|
pub const SC_RMDIR: u8 = 29;
|
||
|
pub const SC_REMOVE: u8 = 30;
|
||
|
pub const SC_FSLIST: u8 = 31;
|
||
|
pub const SC_SYS_TIME: u8 = 32 ;
|
||
|
pub const SC_MMAP: u8 = 33;
|
||
|
pub const SC_DEBUG: u8 = 34;
|
||
|
|
||
|
|
||
|
pub fn call(exception: ExceptionType, machine: &Machine) {
|
||
|
|
||
|
match exception {
|
||
|
ExceptionType::NoException => todo!(),
|
||
|
ExceptionType::SyscallException => syscall(machine),
|
||
|
ExceptionType::PagefaultException => todo!(),
|
||
|
ExceptionType::ReadOnlyException => todo!(),
|
||
|
ExceptionType::BusErrorException => todo!(),
|
||
|
ExceptionType::AddressErrorException => todo!(),
|
||
|
ExceptionType::OverflowException => todo!(),
|
||
|
ExceptionType::IllegalInstrException => todo!(),
|
||
|
ExceptionType::NumExceptionTypes => todo!(),
|
||
|
}
|
||
|
}
|
||
|
|
||
|
fn syscall(machine: &Machine) {
|
||
|
let call_type = machine.read_int_register(17);
|
||
|
|
||
|
todo!()
|
||
|
}
|