forked from Rativel/BurritOS
Remove useless libc, elf and ucontext, add comments to exceptions
improve propagation of errors in raise_exception
This commit is contained in:
@@ -4,41 +4,109 @@ use crate::simulator::{machine::{ExceptionType, Machine}, error::{MachineOk, Mac
|
||||
|
||||
use super::system::System;
|
||||
|
||||
|
||||
/// The halt system call. Stops Burritos.
|
||||
pub const SC_SHUTDOWN: u8 = 0;
|
||||
/// The exit system call
|
||||
///
|
||||
/// Ends the calling thread
|
||||
pub const SC_EXIT: u8 = 1;
|
||||
/// The exec system call
|
||||
///
|
||||
/// Creates a new process (thread+address space)
|
||||
pub const SC_EXEC: u8 = 2;
|
||||
/// The join system call
|
||||
///
|
||||
/// Wait for the thread idThread to finish
|
||||
pub const SC_JOIN: u8 = 3;
|
||||
/// The create system call
|
||||
///
|
||||
/// Create a new file in nachos file system
|
||||
pub const SC_CREATE: u8 = 4;
|
||||
/// The open system call
|
||||
///
|
||||
/// Opens a file and returns an openfile identifier
|
||||
pub const SC_OPEN: u8 = 5;
|
||||
/// The read system call
|
||||
///
|
||||
/// Read in a file or the console
|
||||
pub const SC_READ: u8 = 6;
|
||||
/// The write system call
|
||||
///
|
||||
/// Write in a file or at the console
|
||||
pub const SC_WRITE: u8 = 7;
|
||||
/// Seek to a given position in an opened file
|
||||
pub const SC_SEEK: u8 = 8;
|
||||
/// The close system call
|
||||
///
|
||||
/// Close a file
|
||||
pub const SC_CLOSE: u8 = 9;
|
||||
/// The newThread system call
|
||||
///
|
||||
/// Create a new thread in the same address space
|
||||
pub const SC_NEW_THREAD: u8 = 10;
|
||||
pub const SC_YIELD: u8 = 11;
|
||||
/// The Yield System call
|
||||
///
|
||||
/// Relinquish the CPU if any other thread is runnable
|
||||
pub const SC_YIELD: u8 = 11;
|
||||
/// the PError system call
|
||||
///
|
||||
/// print the last error message
|
||||
pub const SC_PERROR: u8 = 12;
|
||||
/// carry out P() on the semaphore
|
||||
pub const SC_P: u8 = 13;
|
||||
/// carry out V() on the semaphore
|
||||
pub const SC_V: u8 = 14;
|
||||
pub const SC_SEM_CREATE: u8 = 15 ;
|
||||
/// create a semaphore and add it in g_objects_addrs
|
||||
pub const SC_SEM_CREATE: u8 = 15;
|
||||
/// destroy the semaphore corresponding to the id
|
||||
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 ;
|
||||
/// create a lock and add it to g_object_addrs
|
||||
pub const SC_LOCK_CREATE: u8 = 17;
|
||||
/// destroy the lock corresponding to the id
|
||||
pub const SC_LOCK_DESTROY: u8 = 18;
|
||||
/// carry out acquire() on the lock
|
||||
pub const SC_LOCK_ACQUIRE: u8 = 19;
|
||||
/// carry out release() on the lock
|
||||
pub const SC_LOCK_RELEASE: u8 = 20;
|
||||
/// create a condition variable and add it to g_object_addrs
|
||||
pub const SC_COND_CREATE: u8 = 21;
|
||||
/// destroy the condition variable corresponding to the id
|
||||
pub const SC_COND_DESTROY: u8 = 22;
|
||||
/// carry out wait() on the condition
|
||||
pub const SC_COND_WAIT: u8 = 23;
|
||||
/// carry out signal() on the condition
|
||||
pub const SC_COND_SIGNAL: u8 = 24;
|
||||
/// carry out broadcast() on the condition
|
||||
pub const SC_COND_BROADCAST: u8 = 25;
|
||||
/// the TtySend system call
|
||||
///
|
||||
/// Sends some char by the serial line emulated
|
||||
pub const SC_TTY_SEND: u8 = 26;
|
||||
/// the TtyReceive system call
|
||||
///
|
||||
/// read some char on the serial line
|
||||
pub const SC_TTY_RECEIVE: u8 = 27;
|
||||
/// the Mkdir system call
|
||||
///
|
||||
/// make a new directory in the file system
|
||||
pub const SC_MKDIR: u8 = 28;
|
||||
/// the Rmdir system call
|
||||
///
|
||||
/// remove a directory from the file system
|
||||
pub const SC_RMDIR: u8 = 29;
|
||||
/// The Remove system call
|
||||
///
|
||||
/// Remove a file from the file system
|
||||
pub const SC_REMOVE: u8 = 30;
|
||||
/// The FSList system call
|
||||
///
|
||||
/// Lists all the file and directories in the filesystem
|
||||
pub const SC_FSLIST: u8 = 31;
|
||||
pub const SC_SYS_TIME: u8 = 32 ;
|
||||
// The systime system call. Gets the system time
|
||||
pub const SC_SYS_TIME: u8 = 32;
|
||||
/// Map a file in memory
|
||||
pub const SC_MMAP: u8 = 33;
|
||||
/// Behaviour undefined and currently unused
|
||||
pub const SC_DEBUG: u8 = 34;
|
||||
|
||||
pub const CONSOLE_OUTPUT: u8 = 1;
|
||||
@@ -47,15 +115,15 @@ pub const CONSOLE_OUTPUT: u8 = 1;
|
||||
pub fn call(exception: &ExceptionType, machine: &mut Machine, system: &mut System) -> Result<MachineOk, MachineError> {
|
||||
|
||||
match exception {
|
||||
ExceptionType::NoException => todo!(),
|
||||
ExceptionType::NoException => Err("No Exception no yet implemented")?,
|
||||
ExceptionType::SyscallException => syscall(machine, system),
|
||||
ExceptionType::PagefaultException => todo!(),
|
||||
ExceptionType::ReadOnlyException => todo!(),
|
||||
ExceptionType::BusErrorException => todo!(),
|
||||
ExceptionType::AddressErrorException => todo!(),
|
||||
ExceptionType::OverflowException => todo!(),
|
||||
ExceptionType::IllegalInstrException => todo!(),
|
||||
ExceptionType::NumExceptionTypes => todo!(),
|
||||
ExceptionType::PagefaultException => Err("Page Fault Exception not yet implemented")?,
|
||||
ExceptionType::ReadOnlyException => Err("Read Only Exception not yet implemented")?,
|
||||
ExceptionType::BusErrorException => Err("Bus Error Exception not yet implemented")?,
|
||||
ExceptionType::AddressErrorException => Err("AddressErrorException not yet implemented")?,
|
||||
ExceptionType::OverflowException => Err("OverflowException not yet implemented")?,
|
||||
ExceptionType::IllegalInstrException => Err("IllegalInstrException not yet implemented")?,
|
||||
ExceptionType::NumExceptionTypes => Err("NumExceptionTypes not yet implemented")?,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,11 +160,10 @@ fn syscall(machine: &mut Machine, system: &mut System) -> Result<MachineOk, Mach
|
||||
|
||||
if f as u8 == CONSOLE_OUTPUT {
|
||||
println!("{}", buffer); // todo replace with console driver in the future
|
||||
Ok(MachineOk::Ok)
|
||||
} else {
|
||||
todo!("SC_WRITE to file is not yet implemented")
|
||||
Err("SC_WRITE to file is not yet implemented")?
|
||||
}
|
||||
|
||||
Ok(MachineOk::Ok)
|
||||
},
|
||||
SC_SEEK => todo!(),
|
||||
SC_CLOSE => todo!(),
|
||||
|
||||
Reference in New Issue
Block a user