Merge branch 'master' of https://git.ablecorp.us/able/ableos
This commit is contained in:
commit
1710e1b79f
|
@ -12,9 +12,8 @@ pub fn init() {
|
||||||
}
|
}
|
||||||
gdt::init();
|
gdt::init();
|
||||||
|
|
||||||
use crate::scheduler::Priority;
|
use crate::scheduler::Priority::High;
|
||||||
let mut scheduler = SCHEDULER.lock();
|
let mut scheduler = SCHEDULER.lock();
|
||||||
use Priority::*;
|
|
||||||
let process_0 = scheduler.new_process(High);
|
let process_0 = scheduler.new_process(High);
|
||||||
scheduler.add_process(process_0);
|
scheduler.add_process(process_0);
|
||||||
drop(scheduler);
|
drop(scheduler);
|
||||||
|
|
|
@ -57,11 +57,15 @@ pub fn kernel_main() -> ! {
|
||||||
use crate::proto_filetable::file::FileLocations;
|
use crate::proto_filetable::file::FileLocations;
|
||||||
|
|
||||||
let mut file_table = FILE_TABLE.lock();
|
let mut file_table = FILE_TABLE.lock();
|
||||||
|
/*
|
||||||
let mut new_file = File::new(FileLocations::Bin, "test".to_string(), "txt".to_string());
|
let mut new_file = File::new(FileLocations::Bin, "test".to_string(), "txt".to_string());
|
||||||
|
|
||||||
new_file.write_bytes(b"Hello, world!");
|
new_file.write_bytes(b"Hello, world!");
|
||||||
file_table.add_file("test", new_file);
|
file_table.add_file("test", new_file);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
let file = file_table.get_file("test");
|
let file = file_table.get_file("test");
|
||||||
|
|
||||||
match file {
|
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()
|
sloop()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,7 +111,6 @@ pub fn tick() {
|
||||||
data += 1;
|
data += 1;
|
||||||
|
|
||||||
crate::kernel_state::KERNEL_STATE.lock().update_state();
|
crate::kernel_state::KERNEL_STATE.lock().update_state();
|
||||||
|
|
||||||
// let mut scheduler = SCHEDULER.lock();
|
// let mut scheduler = SCHEDULER.lock();
|
||||||
// scheduler.bump_exec();
|
// scheduler.bump_exec();
|
||||||
|
|
||||||
|
@ -106,7 +128,7 @@ pub fn cpu_socket_startup() {
|
||||||
pub fn log_version_data() {
|
pub fn log_version_data() {
|
||||||
info!("{} v{}", RELEASE_TYPE, KERNEL_VERSION);
|
info!("{} v{}", RELEASE_TYPE, KERNEL_VERSION);
|
||||||
info!(
|
info!(
|
||||||
"Brand String: {:?}",
|
"Brand String: {}",
|
||||||
master().unwrap().brand_string().unwrap()
|
master().unwrap().brand_string().unwrap()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
exclusive_range_pattern,
|
exclusive_range_pattern,
|
||||||
lang_items,
|
lang_items,
|
||||||
naked_functions,
|
naked_functions,
|
||||||
slice_pattern,
|
slice_pattern
|
||||||
)]
|
)]
|
||||||
|
|
||||||
/// Contains architecture specific code for aarch64.
|
/// Contains architecture specific code for aarch64.
|
||||||
|
@ -88,3 +88,5 @@ pub use alias_table::*;
|
||||||
|
|
||||||
pub mod tests;
|
pub mod tests;
|
||||||
pub use tests::*;
|
pub use tests::*;
|
||||||
|
pub mod syscalls;
|
||||||
|
pub use syscalls::*;
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
//! Process definition and general utilities surrounding them
|
//! Process definition and general utilities surrounding them
|
||||||
|
|
||||||
use super::{capabilities::Capabilities, FileAccessTypes, Priority};
|
use super::{capabilities::Capabilities, Priority};
|
||||||
|
|
||||||
/// Process Identification
|
/// Process Identification
|
||||||
#[derive(Clone, Copy, PartialEq, Debug)]
|
#[derive(Clone, Copy, PartialEq, Debug)]
|
||||||
|
#[repr(C)]
|
||||||
pub struct PID(pub usize);
|
pub struct PID(pub usize);
|
||||||
|
|
||||||
/// A process
|
/// A process
|
||||||
|
|
37
ableos/src/syscalls.rs
Normal file
37
ableos/src/syscalls.rs
Normal 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!(),
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue