This commit is contained in:
Elfein Landers 2022-02-03 19:37:04 -08:00
commit 1710e1b79f
5 changed files with 70 additions and 10 deletions

View file

@ -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);

View file

@ -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()
);
}

View file

@ -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::*;

View file

@ -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

37
ableos/src/syscalls.rs Normal file
View file

@ -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!(),
}
}