forked from koniifer/ableos
fix up wasm-sys and implement experimental futex
This commit is contained in:
parent
e43891ce9f
commit
6d31f4db29
2
ableos/Cargo.lock
generated
2
ableos/Cargo.lock
generated
|
@ -59,7 +59,7 @@ checksum = "9ea835d29036a4087793836fa931b08837ad5e957da9e23886b29586fb9b6650"
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "externc-libm"
|
name = "externc-libm"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/HaruxOS/externc-libm#ad2865a706fd46d829550ed4cdfa4126f2c81e19"
|
source = "git+ssh://root@git.ablecorp.us:20/able/externc-libm.git#0781df85c094bcd7e5ef7505e9c5cc6317eeda75"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"libm",
|
"libm",
|
||||||
]
|
]
|
||||||
|
|
|
@ -41,7 +41,7 @@ features = ["spin_no_std"]
|
||||||
version = "1.0"
|
version = "1.0"
|
||||||
|
|
||||||
[dependencies.externc-libm]
|
[dependencies.externc-libm]
|
||||||
git = "https://github.com/HaruxOS/externc-libm"
|
git = "ssh://root@git.ablecorp.us:20/able/externc-libm.git"
|
||||||
|
|
||||||
[target.'cfg(target_arch = "x86_64")'.dependencies]
|
[target.'cfg(target_arch = "x86_64")'.dependencies]
|
||||||
bootloader = { version = "0.9.8", features = ["map_physical_memory"] }
|
bootloader = { version = "0.9.8", features = ["map_physical_memory"] }
|
||||||
|
|
0
ableos/notes/mouse.md
Normal file
0
ableos/notes/mouse.md
Normal file
|
@ -1,6 +1,15 @@
|
||||||
pub enum PS2MouseButton {
|
|
||||||
LeftMB,
|
|
||||||
RightMB,
|
// TODO: Bitmasking
|
||||||
|
pub enum Mouse {
|
||||||
|
Button1,
|
||||||
|
Button2,
|
||||||
|
Button3,
|
||||||
|
Button4,
|
||||||
|
Button5,
|
||||||
|
X(i8),
|
||||||
|
Y(i8),
|
||||||
|
Wheel(i8),
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait PS2Mouse {
|
pub trait PS2Mouse {
|
||||||
|
|
66
ableos/src/experiments/futex.rs
Normal file
66
ableos/src/experiments/futex.rs
Normal file
|
@ -0,0 +1,66 @@
|
||||||
|
use core::time::Duration;
|
||||||
|
|
||||||
|
use alloc::vec::Vec;
|
||||||
|
|
||||||
|
use crate::scheduler::ThreadID;
|
||||||
|
|
||||||
|
// pub struct Duration {}
|
||||||
|
|
||||||
|
pub struct AtomicU32(u32);
|
||||||
|
|
||||||
|
impl AtomicU32 {
|
||||||
|
//if v != current value
|
||||||
|
pub fn wait(&self, _v: u32) {
|
||||||
|
todo!();
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn wait_timeout(&self, _v: u32, _timeout: Duration) -> bool {
|
||||||
|
todo!();
|
||||||
|
}
|
||||||
|
pub fn wake_single(&self) {
|
||||||
|
todo!();
|
||||||
|
}
|
||||||
|
pub fn wake_all(&self) {
|
||||||
|
todo!();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
|
||||||
|
SUPER HANDWAVEY
|
||||||
|
YOU WILL NEED LOCKING THAT I DIDNT WRITE OUT (you == zuurr#9735)
|
||||||
|
|
||||||
|
// all the red is by design
|
||||||
|
pub fn futex_wait(atom: &AtomicU32, value: usize, current_thread: ThreadID) {
|
||||||
|
let address = atomic as *const _ as usize;
|
||||||
|
let waiters = waiters_for(address); // Hold lock
|
||||||
|
waiters.add(current_thread);
|
||||||
|
if self.load() == value {
|
||||||
|
current_thread.sleep();
|
||||||
|
} else {
|
||||||
|
waiters.remove(current_thread);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn futex_wake(atom: &AtomicU32, threads_to_wake: usize) {
|
||||||
|
let address = atomic as *const _ as usize;
|
||||||
|
let waiters = waiters_for(address);
|
||||||
|
for waiting_thread in waiters.into_iter().take(threads_to_wake) {
|
||||||
|
waiting_thread.wake()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
struct FutexWaitlist {
|
||||||
|
address: u8,
|
||||||
|
data: Vec<ThreadID>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl FutexWaitlist {
|
||||||
|
pub fn remove(&mut self) {
|
||||||
|
todo!();
|
||||||
|
}
|
||||||
|
pub fn add(&mut self) {
|
||||||
|
todo!();
|
||||||
|
}
|
||||||
|
}
|
|
@ -10,5 +10,6 @@ pub mod virtual_memory;
|
||||||
pub mod kinfo;
|
pub mod kinfo;
|
||||||
pub mod mail;
|
pub mod mail;
|
||||||
|
|
||||||
|
pub mod futex;
|
||||||
pub mod info;
|
pub mod info;
|
||||||
pub const BANNER: &str = include_str!("banner.txt");
|
pub const BANNER: &str = include_str!("banner.txt");
|
||||||
|
|
|
@ -51,7 +51,7 @@ impl Externals for HostFunctions {
|
||||||
}
|
}
|
||||||
let arg: u64 = args.nth(0);
|
let arg: u64 = args.nth(0);
|
||||||
let buf = unsafe { String::from_utf8_unchecked(arg.to_le_bytes().to_vec()) };
|
let buf = unsafe { String::from_utf8_unchecked(arg.to_le_bytes().to_vec()) };
|
||||||
println!["{}", buf];
|
println!["helllooooooo{}", buf];
|
||||||
Ok(None)
|
Ok(None)
|
||||||
}
|
}
|
||||||
SysCall::CONSOLE_GET_TITLE => Ok(None),
|
SysCall::CONSOLE_GET_TITLE => Ok(None),
|
||||||
|
@ -66,6 +66,7 @@ impl ModuleImportResolver for HostFunctions {
|
||||||
"kill" => SysCall::KILL as usize,
|
"kill" => SysCall::KILL as usize,
|
||||||
"empty" => SysCall::EMPTY as usize,
|
"empty" => SysCall::EMPTY as usize,
|
||||||
"exit" => SysCall::EXIT as usize,
|
"exit" => SysCall::EXIT as usize,
|
||||||
|
"console_out" => SysCall::CONSOLE_OUT as usize,
|
||||||
_ => {
|
_ => {
|
||||||
return Err(Error::Instantiation(format!(
|
return Err(Error::Instantiation(format!(
|
||||||
"Export {} not found",
|
"Export {} not found",
|
||||||
|
@ -89,7 +90,7 @@ impl ModuleImportResolver for HostFunctions {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn evaluate() {
|
pub fn evaluate() {
|
||||||
let wasm_binary = include_bytes!("bin/rust.wasm");
|
let wasm_binary = include_bytes!("bin/console_out_test.wasm");
|
||||||
|
|
||||||
// Load wasm binary and prepare it for instantiation.
|
// Load wasm binary and prepare it for instantiation.
|
||||||
let module = wasmi::Module::from_buffer(&wasm_binary).expect("failed to load wasm");
|
let module = wasmi::Module::from_buffer(&wasm_binary).expect("failed to load wasm");
|
||||||
|
@ -99,7 +100,8 @@ pub fn evaluate() {
|
||||||
// Instantiate a module with empty imports and
|
// Instantiate a module with empty imports and
|
||||||
// assert that there is no `start` function.
|
// assert that there is no `start` function.
|
||||||
let instance = ModuleInstance::new(&module, &imports)
|
let instance = ModuleInstance::new(&module, &imports)
|
||||||
.expect("failed to instantiate wasm module")
|
// .expect("failed to instantiate wasm module")
|
||||||
|
.unwrap()
|
||||||
.assert_no_start();
|
.assert_no_start();
|
||||||
|
|
||||||
// Finally, invoke the exported function "test" with no parameters
|
// Finally, invoke the exported function "test" with no parameters
|
||||||
|
|
Loading…
Reference in a new issue