From b21c53fa82ec028374a17a010dbe001f774e4711 Mon Sep 17 00:00:00 2001 From: Able Date: Sat, 12 Feb 2022 03:25:02 -0600 Subject: [PATCH] minor changes --- ableos/.cargo/config.toml | 4 - ableos/Cargo.lock | 21 ++-- ableos/Cargo.toml | 24 +++-- ableos/notes/GraphicsNote.md | 3 - ableos/notes/NOTES.md | 9 -- ableos/notes/UNICODE_PRIV.md | 1 - ableos/notes/USER.md | 3 - ableos/notes/mouse.md | 0 ableos/notes/pci_tree.md | 17 ---- .../devices/{ => character_devs}/dev_null.rs | 2 + .../{ => character_devs}/dev_unicode.rs | 1 + .../devices/{ => character_devs}/dev_zero.rs | 1 + ableos/src/devices/character_devs/mod.rs | 3 + ableos/src/devices/mod.rs | 28 ++++-- ableos/src/devices/pci_inner.rs | 56 +++++++++++ ableos/src/lib.rs | 5 +- ableos/src/scheduler/mod.rs | 3 +- ableos/src/scheduler/new_sched.rs | 3 +- ableos/src/scheduler/proc.rs | 6 +- ableos/src/scratchpad.rs | 93 +++++++++++++++--- ableos/src/syscalls/file_calls.rs | 43 -------- ableos/src/syscalls/mod.rs | 27 ----- ableos/src/syscalls/time_calls.rs | 28 ------ ableos/src/wasm_jumploader/host_functions.rs | 6 +- ableos/src/wasm_jumploader/mod.rs | 11 ++- userland/aos_wasm_stress_test/Cargo.lock | 8 ++ userland/aos_wasm_stress_test/Cargo.toml | 1 + userland/aos_wasm_stress_test/src/main.rs | 12 +-- userland/root_rs/ext2.img | Bin 4194304 -> 4194304 bytes 29 files changed, 220 insertions(+), 199 deletions(-) delete mode 100644 ableos/notes/GraphicsNote.md delete mode 100644 ableos/notes/NOTES.md delete mode 100644 ableos/notes/UNICODE_PRIV.md delete mode 100644 ableos/notes/USER.md delete mode 100644 ableos/notes/mouse.md delete mode 100644 ableos/notes/pci_tree.md rename ableos/src/devices/{ => character_devs}/dev_null.rs (89%) rename ableos/src/devices/{ => character_devs}/dev_unicode.rs (97%) rename ableos/src/devices/{ => character_devs}/dev_zero.rs (95%) create mode 100644 ableos/src/devices/character_devs/mod.rs create mode 100644 ableos/src/devices/pci_inner.rs delete mode 100644 ableos/src/syscalls/file_calls.rs delete mode 100644 ableos/src/syscalls/mod.rs delete mode 100644 ableos/src/syscalls/time_calls.rs diff --git a/ableos/.cargo/config.toml b/ableos/.cargo/config.toml index 6edb0235..7c2df1cf 100644 --- a/ableos/.cargo/config.toml +++ b/ableos/.cargo/config.toml @@ -1,6 +1,3 @@ - - - [build] target = "./json_targets/x86_64-ableos.json" @@ -8,7 +5,6 @@ target = "./json_targets/x86_64-ableos.json" build-std = ["core", "compiler_builtins", "alloc"] build-std-features = ["compiler-builtins-mem"] - [target.'cfg(target_arch = "x86_64")'] rustflags = ["-C", "target-feature=+rdrnd"] runner = "bootimage runner" diff --git a/ableos/Cargo.lock b/ableos/Cargo.lock index 0bf25e41..136d4b9c 100644 --- a/ableos/Cargo.lock +++ b/ableos/Cargo.lock @@ -36,10 +36,12 @@ dependencies = [ "genfs", "hashbrown", "lazy_static", + "libwasm", "linked_list_allocator", "lliw", "log", "pc-beeper", + "pci", "pic8259", "picorand", "pretty-hex", @@ -50,7 +52,6 @@ dependencies = [ "shadeable", "smoltcp", "spin 0.5.2", - "tinypci", "uart_16550", "unicode-width", "vga", @@ -276,6 +277,11 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "33a33a362ce288760ec6a508b94caaec573ae7d3bbbd91b87aa0bad4456839db" +[[package]] +name = "libwasm" +version = "0.1.0" +source = "git+https://git.ablecorp.us/able/libwasm.git#a89b8fc701ba0196cc9cca9989d9beb93d02a317" + [[package]] name = "linked_list_allocator" version = "0.9.1" @@ -387,6 +393,14 @@ dependencies = [ "x86_64", ] +[[package]] +name = "pci" +version = "0.0.1" +source = "git+https://gitlab.com/robigalia/pci#4e2fddc61825568b1d14d09fdc669389e6c43f02" +dependencies = [ + "bitflags", +] + [[package]] name = "pic8259" version = "0.10.2" @@ -669,11 +683,6 @@ dependencies = [ "crunchy", ] -[[package]] -name = "tinypci" -version = "0.1.0" -source = "git+https://github.com/trashbyte/tinypci.git#5e1bc4cf7ae4edb8d524a5e7e71a1ace9c4850fc" - [[package]] name = "ttf-parser" version = "0.14.0" diff --git a/ableos/Cargo.toml b/ableos/Cargo.toml index d83aaa29..8decda16 100644 --- a/ableos/Cargo.toml +++ b/ableos/Cargo.toml @@ -12,16 +12,20 @@ run-args = [ "-cpu", "Broadwell-v3", + + + + + + "-serial", "stdio", "-smp", "cores=2", -"-vga", -"qxl", # An example gpu used with ableOS - # "-device", - # "virtio-gpu", + "-device", + "virtio-gpu", # An example disk used with ableOS "-device", @@ -49,9 +53,6 @@ lliw = "0.2.0" spin = "0.5.2" vga = "*" log = "*" -# tinypci = "0.1.0" - -tinypci = { git = "https://github.com/trashbyte/tinypci.git", default-features = false } pretty-hex = "0.2.1" unicode-width = "0.1.7" @@ -63,10 +64,17 @@ genfs = "0.1.0" pc-beeper = {git = "https://github.com/AbleOS/pc-beeper"} - +pci = {git="https://gitlab.com/robigalia/pci"} +libwasm = {git="https://git.ablecorp.us:443/able/libwasm.git"} acpi = "4.1.0" +# [dependencies.ockam] +# version = "0.46.0" +# no-default-features = false +# features = ["alloc"] + + [dependencies.rdrand] version = "0.8.1" default-features = false diff --git a/ableos/notes/GraphicsNote.md b/ableos/notes/GraphicsNote.md deleted file mode 100644 index 81502ebc..00000000 --- a/ableos/notes/GraphicsNote.md +++ /dev/null @@ -1,3 +0,0 @@ -wgpu - -write using wgpu and compiles to native/web diff --git a/ableos/notes/NOTES.md b/ableos/notes/NOTES.md deleted file mode 100644 index 59da4d3f..00000000 --- a/ableos/notes/NOTES.md +++ /dev/null @@ -1,9 +0,0 @@ -Don't keep piling on API shit -Good docs are a must!!!!!!!!!!!! -No Bloat -One thing One Way -Bloat makes M!nt sad -Have rust-like strings only - -# Don't -memory gun diff --git a/ableos/notes/UNICODE_PRIV.md b/ableos/notes/UNICODE_PRIV.md deleted file mode 100644 index f379d014..00000000 --- a/ableos/notes/UNICODE_PRIV.md +++ /dev/null @@ -1 +0,0 @@ -start custom unicode at E100 \ No newline at end of file diff --git a/ableos/notes/USER.md b/ableos/notes/USER.md deleted file mode 100644 index 6e755fa0..00000000 --- a/ableos/notes/USER.md +++ /dev/null @@ -1,3 +0,0 @@ -user -> execute -> file system diff --git a/ableos/notes/mouse.md b/ableos/notes/mouse.md deleted file mode 100644 index e69de29b..00000000 diff --git a/ableos/notes/pci_tree.md b/ableos/notes/pci_tree.md deleted file mode 100644 index 53383be0..00000000 --- a/ableos/notes/pci_tree.md +++ /dev/null @@ -1,17 +0,0 @@ - -VGA - - - - - - - - - -pcie - gpu - amd - ati - set_red - ssd \ No newline at end of file diff --git a/ableos/src/devices/dev_null.rs b/ableos/src/devices/character_devs/dev_null.rs similarity index 89% rename from ableos/src/devices/dev_null.rs rename to ableos/src/devices/character_devs/dev_null.rs index 50b61dbd..405fb2fa 100644 --- a/ableos/src/devices/dev_null.rs +++ b/ableos/src/devices/character_devs/dev_null.rs @@ -2,6 +2,8 @@ use alloc::string::String; use crate::character_device::CharacterDevice; +#[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub struct DevNull; impl CharacterDevice for DevNull { diff --git a/ableos/src/devices/dev_unicode.rs b/ableos/src/devices/character_devs/dev_unicode.rs similarity index 97% rename from ableos/src/devices/dev_unicode.rs rename to ableos/src/devices/character_devs/dev_unicode.rs index 908ee0af..aa25ca0f 100644 --- a/ableos/src/devices/dev_unicode.rs +++ b/ableos/src/devices/character_devs/dev_unicode.rs @@ -1,5 +1,6 @@ use crate::character_device::CharacterDevice; +#[derive(Debug)] pub struct DevUnicode { pub next_write_char: char, pub next_read_char: char, diff --git a/ableos/src/devices/dev_zero.rs b/ableos/src/devices/character_devs/dev_zero.rs similarity index 95% rename from ableos/src/devices/dev_zero.rs rename to ableos/src/devices/character_devs/dev_zero.rs index ec717d99..09a1ad44 100644 --- a/ableos/src/devices/dev_zero.rs +++ b/ableos/src/devices/character_devs/dev_zero.rs @@ -1,5 +1,6 @@ use crate::character_device::CharacterDevice; +#[derive(Debug)] pub struct DevZero; impl CharacterDevice for DevZero { diff --git a/ableos/src/devices/character_devs/mod.rs b/ableos/src/devices/character_devs/mod.rs new file mode 100644 index 00000000..061ae6e0 --- /dev/null +++ b/ableos/src/devices/character_devs/mod.rs @@ -0,0 +1,3 @@ +pub mod dev_null; +pub mod dev_unicode; +pub mod dev_zero; diff --git a/ableos/src/devices/mod.rs b/ableos/src/devices/mod.rs index d2a3836f..132c3f87 100644 --- a/ableos/src/devices/mod.rs +++ b/ableos/src/devices/mod.rs @@ -1,19 +1,20 @@ +pub mod character_devs; +pub mod pci_inner; + use alloc::{ boxed::Box, string::{String, ToString}, }; use hashbrown::HashMap; +use pci::PCIDevice; use crate::character_device::CharacterDevice; -pub mod dev_null; -pub mod dev_unicode; -pub mod dev_zero; - // FIXME: This is a hack to hold a device. +// #[derive(Debug)] pub enum Device { - CharacterDevice(Box), - // BlockDevice, + Character(Box), + Pci(PCIDevice), } unsafe impl Sync for Device {} unsafe impl Send for Device {} @@ -21,16 +22,25 @@ unsafe impl Send for Device {} pub struct DeviceTable { pub devices: HashMap, } -use self::dev_null::DevNull; +use self::character_devs::{dev_null::DevNull, dev_unicode::DevUnicode, dev_zero::DevZero}; pub use self::Device::*; impl DeviceTable { pub fn new() -> Self { let mut table: HashMap = HashMap::new(); - table.insert("null".to_string(), CharacterDevice(Box::new(DevNull))); + table.insert("null".to_string(), Character(Box::new(DevNull))); + table.insert("zero".to_string(), Character(Box::new(DevZero))); + table.insert( + "unicode".to_string(), + Character(Box::new(DevUnicode { + next_write_char: 0x00 as char, + next_read_char: 0x00 as char, + })), + ); DeviceTable { devices: table } } } lazy_static::lazy_static!( - static ref DEVICE_TABLE: DeviceTable = DeviceTable::new(); + pub static ref DEVICE_TABLE: spin::Mutex = + spin::Mutex::new(DeviceTable::new()); ); diff --git a/ableos/src/devices/pci_inner.rs b/ableos/src/devices/pci_inner.rs new file mode 100644 index 00000000..d0f5fc50 --- /dev/null +++ b/ableos/src/devices/pci_inner.rs @@ -0,0 +1,56 @@ +//! map the DeviceClass via +#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] +pub enum DeviceClass { + UnclassifiedDevice = 0, + MassStorageController = 0x01, + NetworkController = 0x02, + DisplayController = 0x03, + MultimediaController = 0x04, + MemoryController = 0x05, + BridgeDevice = 0x06, + + CommunicationController = 0x07, + GenericSystemPeripheral = 0x08, + InputDevice = 0x09, + DockingStation = 0x0a, + Processor = 0x0b, + SerialBusController = 0x0c, + WirelessController = 0x0d, + IntelligentController = 0x0e, + SatelliteCommunicationController = 0x0f, + EncryptionController = 0x10, + SignalProcessingController = 0x11, + + // 14 + // 15 + // 16 + Coprocessor = 40, + // 64 +} + +impl DeviceClass { + pub fn from_u8(val: u8) -> DeviceClass { + match val { + 0x00 => DeviceClass::UnclassifiedDevice, + 0x01 => DeviceClass::MassStorageController, + 0x02 => DeviceClass::NetworkController, + 0x03 => DeviceClass::DisplayController, + 0x04 => DeviceClass::MultimediaController, + 0x05 => DeviceClass::MemoryController, + 0x06 => DeviceClass::BridgeDevice, + 0x07 => DeviceClass::CommunicationController, + 0x08 => DeviceClass::GenericSystemPeripheral, + 0x09 => DeviceClass::InputDevice, + 0x0a => DeviceClass::DockingStation, + 0x0b => DeviceClass::Processor, + 0x0c => DeviceClass::SerialBusController, + 0x0d => DeviceClass::WirelessController, + 0x0e => DeviceClass::IntelligentController, + 0x0f => DeviceClass::SatelliteCommunicationController, + 0x10 => DeviceClass::EncryptionController, + 0x11 => DeviceClass::SignalProcessingController, + 0x40 => DeviceClass::Coprocessor, + _ => DeviceClass::UnclassifiedDevice, + } + } +} diff --git a/ableos/src/lib.rs b/ableos/src/lib.rs index 4af3ba16..76429ea6 100644 --- a/ableos/src/lib.rs +++ b/ableos/src/lib.rs @@ -32,6 +32,7 @@ pub mod arch; #[macro_use] pub mod print; +pub mod devices; pub mod wasm_jumploader; #[macro_use] @@ -89,9 +90,9 @@ pub use alias_table::*; pub mod tests; pub use tests::*; -pub mod syscalls; +/*pub mod syscalls; pub use syscalls::*; - +*/ pub mod scratchpad; pub use scratchpad::*; pub mod filesystem; diff --git a/ableos/src/scheduler/mod.rs b/ableos/src/scheduler/mod.rs index e1afdb87..cf63235e 100644 --- a/ableos/src/scheduler/mod.rs +++ b/ableos/src/scheduler/mod.rs @@ -6,7 +6,7 @@ //! The scheduler is also responsible for choosing the priority of a process. //! The scheduler is responsible for choosing which process to execute next. -use alloc::vec::Vec; +use alloc::{string::ToString, vec::Vec}; pub mod capabilities; pub mod proc; @@ -120,6 +120,7 @@ impl Scheduler { password: generate_process_pass(), capabilities: Capabilities::empty(), priority, + working_dir: "todo!()".to_string(), }; // self.free_pid.0 += 1; // self.list.push(process); diff --git a/ableos/src/scheduler/new_sched.rs b/ableos/src/scheduler/new_sched.rs index 31536bcb..1192c3ed 100644 --- a/ableos/src/scheduler/new_sched.rs +++ b/ableos/src/scheduler/new_sched.rs @@ -1,4 +1,4 @@ -use alloc::vec::Vec; +use alloc::{string::ToString, vec::Vec}; use crate::{ capabilities::Capabilities, @@ -70,6 +70,7 @@ impl Scheduler { password: generate_process_pass(), priority, capabilities: Capabilities::empty(), + working_dir: "todo!()".to_string(), }; self.free_pid.0 += 1; process diff --git a/ableos/src/scheduler/proc.rs b/ableos/src/scheduler/proc.rs index 601b6c2e..1d3955a2 100644 --- a/ableos/src/scheduler/proc.rs +++ b/ableos/src/scheduler/proc.rs @@ -1,5 +1,7 @@ //! Process definition and general utilities surrounding them +use alloc::string::String; + use super::{capabilities::Capabilities, Priority}; /// Process Identification @@ -15,11 +17,13 @@ pub struct Process { /// Process password pub password: u128, - /// pub capabilities: Capabilities, /// A process's priority pub priority: Priority, + + /// + pub working_dir: String, } impl Process {} diff --git a/ableos/src/scratchpad.rs b/ableos/src/scratchpad.rs index 42789971..58c62c77 100644 --- a/ableos/src/scratchpad.rs +++ b/ableos/src/scratchpad.rs @@ -1,27 +1,88 @@ -use alloc::{string::String, vec::Vec}; -use genfs::{Fs, OpenOptions}; - -use crate::{filesystem::FILE_SYSTEM, wasm_jumploader::interp}; +use { + crate::{ + devices::{pci_inner::DeviceClass, Device, DEVICE_TABLE}, + proc::PID, + wasm_jumploader::interp, + }, + alloc::{format, vec::Vec}, + pci::PortOps, +}; /// Experimental scratchpad for testing. pub fn scratchpad() { - let fs = &*FILE_SYSTEM.lock(); - let file = fs - .open(b"/home/able/kernel.md", OpenOptions::new().read(true)) - .unwrap(); + let mut dev_list = Vec::new(); + let bus_scan; + unsafe { + bus_scan = pci::scan_bus(&PciIO {}, pci::CSpaceAccessMethod::IO); + } + for dev in bus_scan { + dev_list.push(dev); + } - let mut file_bytes = Vec::new(); - file.read_to_end(&mut file_bytes).unwrap(); + let device_table = &mut *DEVICE_TABLE.lock(); - let string = String::from_utf8_lossy(&file_bytes); + for x in dev_list { + let device_name = format!("{:?}-{}", DeviceClass::from_u8(x.id.class), x.id.device_id); - print!("{}", string); + device_table.devices.insert(device_name, Device::Pci(x)); + } - let pci_list = tinypci::brute_force_scan(); - - for pci in pci_list { - info!("{}", pci); + for (key, _value) in device_table.devices.iter() { + debug!("{}", key); } interp(); } + +pub struct PciIO {} + +impl PortOps for PciIO { + unsafe fn read8(&self, port: u16) -> u8 { + cpuio::inb(port as u16) + } + + unsafe fn read16(&self, port: u16) -> u16 { + cpuio::inw(port as u16) + } + + unsafe fn read32(&self, port: u16) -> u32 { + cpuio::inl(port as u16) + } + + unsafe fn write8(&self, port: u16, val: u8) { + cpuio::outb(val, port as u16); + } + + unsafe fn write16(&self, port: u16, val: u16) { + cpuio::outw(val, port as u16); + } + + unsafe fn write32(&self, port: u16, val: u32) { + cpuio::outl(val, port as u16); + } +} + +/// An experimental process message format +pub struct ProcessMessage { + pub to_pid: PID, + pub from_pid: PID, + pub message: [u8; 2048], + + pub sender_time: SecondsTime, +} +// +use libwasm::syscalls::time_calls::SecondsTime; + +impl ProcessMessage { + pub fn new(to_pid: PID, from_pid: PID, message: [u8; 2048]) -> Self { + ProcessMessage { + to_pid, + from_pid, + message, + sender_time: SecondsTime { + seconds: 0, + milliseconds: 0, + }, + } + } +} diff --git a/ableos/src/syscalls/file_calls.rs b/ableos/src/syscalls/file_calls.rs deleted file mode 100644 index 653eced6..00000000 --- a/ableos/src/syscalls/file_calls.rs +++ /dev/null @@ -1,43 +0,0 @@ -//! File system related system calls. - -/// Temporary representation of a file path -pub type Path = *const u8; - -/// Remove a Directory from the filesystem -/// -/// # Arguments -/// * `full_path` - The full path of the directory to remove -/// * `force` - Whether to remove the directory even if it is not empty -#[no_mangle] -pub extern "C" fn remove_directory(path: Path, force_delete: bool) { - unimplemented!(); -} - -/// Create a new directory at the given path -/// -/// # Arguments -/// * `full_path` - The full path of the directory to create -#[no_mangle] -pub extern "C" fn create_directory(path: Path) -> FSReturns { - unimplemented!(); -} - -#[repr(C)] -/// A return used by the file related system calls -pub enum FSReturns { - /// The system call was successful - Ok, - - /// The directory can not be created - DirectoryCouldNotBeCreated, - /// The directory could not be removed - DirectoryCouldNotBeRemoved, - /// - FileCouldNotBeCreated, - /// - FileCouldNotBeRemoved, - /// The file could not be opened - FileCouldNotBeOpened, - /// - FileCouldNotBeClosed, -} diff --git a/ableos/src/syscalls/mod.rs b/ableos/src/syscalls/mod.rs deleted file mode 100644 index ee262291..00000000 --- a/ableos/src/syscalls/mod.rs +++ /dev/null @@ -1,27 +0,0 @@ -#![deny(missing_docs)] -//! The module of syscalls. - -use crate::proc::PID; - -pub mod file_calls; -pub mod time_calls; - -#[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, -} - -/// Send a signal to a process -/// -/// # Arguments -/// -/// * `pid` - The PID of the process to send the signal to -/// * `signal` - The signal to send -#[no_mangle] -pub extern "C" fn send_signal(pid: PID, signal: Signals) { - unimplemented!("send_signal"); -} diff --git a/ableos/src/syscalls/time_calls.rs b/ableos/src/syscalls/time_calls.rs deleted file mode 100644 index 4465b86f..00000000 --- a/ableos/src/syscalls/time_calls.rs +++ /dev/null @@ -1,28 +0,0 @@ -//! Time related system calls. - -use core::panic; - -/// Seconds and milliseconds since the Unix epoch. -#[repr(C)] -pub struct SecondsTime { - seconds: u64, - milliseconds: u64, -} - -/// Sleep the calling process for the given number of milliseconds -#[no_mangle] -pub extern "C" fn sleep(time: SecondsTime) { - panic!("sleep is not implemented yet"); -} - -#[no_mangle] -/// Get the current time in seconds, milliseconds -pub extern "C" fn get_time() -> SecondsTime { - panic!("get_time not implemented"); -} - -#[no_mangle] -/// Set the current time in seconds, milliseconds -pub extern "C" fn set_time(time: SecondsTime) { - panic!("set_time not implemented"); -} diff --git a/ableos/src/wasm_jumploader/host_functions.rs b/ableos/src/wasm_jumploader/host_functions.rs index df34820e..25cfa2ec 100644 --- a/ableos/src/wasm_jumploader/host_functions.rs +++ b/ableos/src/wasm_jumploader/host_functions.rs @@ -4,9 +4,7 @@ use wasmi::{ Signature, Trap, ValueType, }; -pub struct HostExternals { - // counter: usize, -} +pub struct HostExternals {} const ADD_FUNC_INDEX: usize = 0; @@ -21,7 +19,7 @@ impl Externals for HostExternals { let a: u32 = args.nth_checked(0)?; let b: u32 = args.nth_checked(1)?; let result = a + b; - + println!("SYSCALL: {} + {} = {}", a, b, result); Ok(Some(RuntimeValue::I32(result as i32))) } _ => panic!("Unimplemented function at {}", index), diff --git a/ableos/src/wasm_jumploader/mod.rs b/ableos/src/wasm_jumploader/mod.rs index c8924e24..35b47883 100644 --- a/ableos/src/wasm_jumploader/mod.rs +++ b/ableos/src/wasm_jumploader/mod.rs @@ -5,21 +5,22 @@ extern crate wasmi; use alloc::vec::Vec; use genfs::{Fs, OpenOptions}; -use wasmi::{ImportsBuilder, ModuleInstance, NopExternals}; +use wasmi::{ImportsBuilder, ModuleInstance}; use crate::{filesystem::FILE_SYSTEM, wasm_jumploader::host_functions::HostExternals}; pub fn interp() { + info!("Interpreting..."); let fs = &*FILE_SYSTEM.lock(); - + info!("Got filesystem"); let file = fs - .open(b"/home/able/test.wasm", OpenOptions::new().read(true)) + .open(b"/home/able/bins/test.wasm", OpenOptions::new().read(true)) .unwrap(); let mut wasm_binary = Vec::new(); let ret = file.read_to_end(&mut wasm_binary).unwrap(); - + info!("Binary size {}", ret); // Load wasm binary and prepare it for instantiation. let module = wasmi::Module::from_buffer(&wasm_binary).expect("failed to load wasm"); @@ -35,5 +36,5 @@ pub fn interp() { .invoke_export("start", &[], &mut HostExternals {}) .expect("failed to execute export"); - info!("collected wasm return value: {:?}", ret); + println!("collected wasm return value: {:?}", ret); } diff --git a/userland/aos_wasm_stress_test/Cargo.lock b/userland/aos_wasm_stress_test/Cargo.lock index c22b5775..d208d603 100644 --- a/userland/aos_wasm_stress_test/Cargo.lock +++ b/userland/aos_wasm_stress_test/Cargo.lock @@ -5,3 +5,11 @@ version = 3 [[package]] name = "aos_wasm_stress_test" version = "0.1.0" +dependencies = [ + "libwasm", +] + +[[package]] +name = "libwasm" +version = "0.1.0" +source = "git+https://git.ablecorp.us/able/libwasm.git#502187e8734b54df3c6cae2baf2315539a3ec49b" diff --git a/userland/aos_wasm_stress_test/Cargo.toml b/userland/aos_wasm_stress_test/Cargo.toml index b174cd4e..b43161f1 100644 --- a/userland/aos_wasm_stress_test/Cargo.toml +++ b/userland/aos_wasm_stress_test/Cargo.toml @@ -6,3 +6,4 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] +libwasm = {git="https://git.ablecorp.us:443/able/libwasm.git"} \ No newline at end of file diff --git a/userland/aos_wasm_stress_test/src/main.rs b/userland/aos_wasm_stress_test/src/main.rs index 6bf54d1b..a3fd82be 100644 --- a/userland/aos_wasm_stress_test/src/main.rs +++ b/userland/aos_wasm_stress_test/src/main.rs @@ -2,21 +2,11 @@ #![no_main] #![deny(improper_ctypes)] -#[macro_use] -mod libwasm; - #[no_mangle] fn start() -> i32 { let ret = unsafe { add(1, 2) }; - info!(b"hello"); - ret as i32 } -use core::panic::PanicInfo; - -#[panic_handler] -fn panic(_info: &PanicInfo) -> ! { - loop {} -} +use libwasm::syscalls::add; diff --git a/userland/root_rs/ext2.img b/userland/root_rs/ext2.img index 7b7d4a6225516852d3bd5663cee07da1f6b27a1d..4927e5a8558cffd4e1a8dac54f424c4ed1be2ae1 100644 GIT binary patch delta 3734 zcmd6oe{5S<702Iueo5RLCvo~KY16Gv8=!2v*}M1s@Ouqi>LzXz>e!j>G^MabN#ibI zX|g8nx^4_dLV802X*e$F1W2g=Yz%}%392O)iJ~F#4}wXcp-G@2G1N|ozp6<{Fv|DX zP90h(`v(b2=e&E~J?GqW@BO^v<>h5<8S;aW-f*f-QErsl^{y@5vT^D>WXGDV52)I_ zdR6tcm0$=iHv*xx_Mmz=(5Bofst;>MYf(L1Iz0SX>H5%hHBeOh*RBu8H2rUrFRDfL zg|+2GQ19;eN5fQGO_a*7QPHXcr324PSJiRthnWU#2aFBJji;iNcAq?640n~5$AW=@ zazp7WV;?qs_jbe7w{JI;UOsWL`$~08_7r8k8PM;fZ-V`5QSB>DkN0$UqlUdTx!Z9+ zUTnRr9uD`F-W%Vu@)`Z(-FS2S%lg!YR3p?osa3pa)Qajs{dzR<{i52rGTuNN_-VPm zTiV3UK~E1wOv z^?mp+TPt;->YxAUbxG6X)yrxA-1*Y-lfkyPYp1YQeO6rGe24#Wv+ENtcK-#_zpY8N z1ntfN7hEHzNArRgUl4@D678>HNjYFbs%X@DQyn;KFSEmTw; zz4_MfPgZNXa~!|KF3Is`puPkJHCK)!d!X?AeU9TxSGM%m^8F5Z-iG}8KjaHl^8NUY z))NS*99jstY?8{M?YePkuC^XcZ33e*{pX+9-`EIm#r!6z%&&aC|(5dL!)a?9H*?2|!Lz8-d zX7=xR5Hr6Bw5aDUzcnF@Yi*Jy}@5^ytdvHKG_*kG_AK+ zQFbEiW?+k&&n@M9FHA0#uZ(IFfnxaLsvc|)&&;x(W9fK2*~4aLBPP45z8hHmnik4z zL)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