diff --git a/ableos/src/arch/x86_64/init.rs b/ableos/src/arch/x86_64/init.rs index bc80f9b1..ea104668 100644 --- a/ableos/src/arch/x86_64/init.rs +++ b/ableos/src/arch/x86_64/init.rs @@ -12,9 +12,8 @@ pub fn init() { } gdt::init(); - use crate::scheduler::Priority; + use crate::scheduler::Priority::High; let mut scheduler = SCHEDULER.lock(); - use Priority::*; let process_0 = scheduler.new_process(High); scheduler.add_process(process_0); drop(scheduler); diff --git a/ableos/src/kmain.rs b/ableos/src/kmain.rs index c7932629..1db66d80 100644 --- a/ableos/src/kmain.rs +++ b/ableos/src/kmain.rs @@ -57,11 +57,15 @@ pub fn kernel_main() -> ! { use crate::proto_filetable::file::FileLocations; let mut file_table = FILE_TABLE.lock(); + /* let mut new_file = File::new(FileLocations::Bin, "test".to_string(), "txt".to_string()); new_file.write_bytes(b"Hello, world!"); file_table.add_file("test", new_file); + + + let file = file_table.get_file("test"); match file { @@ -75,10 +79,29 @@ pub fn kernel_main() -> ! { } } - use crate::wasm::WasmProgram; - let ret = WasmProgram::new_from_bytes(&[0x00, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00]); - trace!("Binary Valid: {:?}", ret.validate_header()); + */ + + let mut new_file = File::new(FileLocations::Bin, "test".to_string(), "txt".to_string()); + new_file.write_bytes(&[0x00, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00]); + file_table.add_file("wasm_test", new_file); + + let file = file_table.get_file("wasm_test"); + + match file { + Some(file) => { + let file_bytes = &file.data_pointer; + + use crate::wasm::WasmProgram; + let ret = WasmProgram::new_from_bytes(file_bytes); + trace!("Binary Valid: {:?}", ret.validate_header()); + } + None => { + info!("File not found"); + } + } + + log_version_data(); sloop() } @@ -88,7 +111,6 @@ pub fn tick() { data += 1; crate::kernel_state::KERNEL_STATE.lock().update_state(); - // let mut scheduler = SCHEDULER.lock(); // scheduler.bump_exec(); @@ -106,7 +128,7 @@ pub fn cpu_socket_startup() { pub fn log_version_data() { info!("{} v{}", RELEASE_TYPE, KERNEL_VERSION); info!( - "Brand String: {:?}", + "Brand String: {}", master().unwrap().brand_string().unwrap() ); } diff --git a/ableos/src/lib.rs b/ableos/src/lib.rs index d241fa5f..5e759d12 100644 --- a/ableos/src/lib.rs +++ b/ableos/src/lib.rs @@ -12,7 +12,7 @@ exclusive_range_pattern, lang_items, naked_functions, - slice_pattern, + slice_pattern )] /// Contains architecture specific code for aarch64. @@ -88,3 +88,5 @@ pub use alias_table::*; pub mod tests; pub use tests::*; +pub mod syscalls; +pub use syscalls::*; diff --git a/ableos/src/scheduler/proc.rs b/ableos/src/scheduler/proc.rs index 53e282f8..c44e6ed6 100644 --- a/ableos/src/scheduler/proc.rs +++ b/ableos/src/scheduler/proc.rs @@ -1,10 +1,10 @@ //! Process definition and general utilities surrounding them -use super::{capabilities::Capabilities, FileAccessTypes, Priority}; +use super::{capabilities::Capabilities, Priority}; /// Process Identification #[derive(Clone, Copy, PartialEq, Debug)] - +#[repr(C)] pub struct PID(pub usize); /// A process diff --git a/ableos/src/syscalls.rs b/ableos/src/syscalls.rs new file mode 100644 index 00000000..a0d6cb5d --- /dev/null +++ b/ableos/src/syscalls.rs @@ -0,0 +1,37 @@ +use crate::proc::PID; + +#[repr(C)] +/// Signals that can be sent to a process +pub enum Signals { + /// Terminate the process + Terminate, + /// Shutdown the process and allow it to shutdown cleanly + Quit, +} + +#[repr(C)] +pub enum SystemCall { + /// Sleep the calling process for the given number of milliseconds + /// + /// # Arguments + /// + /// * `ticks` - The number of ticks to sleep for + Sleep(u64), + + /// Send a signal to a process + /// + /// # Arguments + /// + /// * `pid` - The PID of the process to send the signal to + /// * `signal` - The signal to send + SendSignal(PID, Signals), +} + +#[no_mangle] +pub extern "C" fn syscall(call: SystemCall) { + // Handle the system call + match call { + SystemCall::Sleep(ms) => todo!("Sleep for {} ms", ms), + SystemCall::SendSignal(process_id, signal) => todo!(), + } +}