From d5a4e19231adfbe2106aeafad0b19d8319ff9059 Mon Sep 17 00:00:00 2001 From: Monadic Cat Date: Mon, 25 Apr 2022 00:32:45 -0500 Subject: [PATCH] allow specifying path of wasm executable --- ableos/src/rhai_shell/mod.rs | 3 ++- ableos/src/wasm_jumploader/host_functions.rs | 4 ++-- ableos/src/wasm_jumploader/mod.rs | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/ableos/src/rhai_shell/mod.rs b/ableos/src/rhai_shell/mod.rs index 2042142..67844cc 100644 --- a/ableos/src/rhai_shell/mod.rs +++ b/ableos/src/rhai_shell/mod.rs @@ -210,7 +210,8 @@ fn engine_construction() -> Engine { engine.register_fn("peek", peek_memory); engine.register_fn("poke", poke_memory); engine.register_fn("sloop", sloop); - engine.register_fn("wasm", interp); + engine.register_fn("wasm", |s: &str| interp(s.as_bytes())); + engine.register_fn("wasm", || interp(b"/home/able/bins/aos_test.wasm")); engine.register_fn("log_dump", log_dump); engine diff --git a/ableos/src/wasm_jumploader/host_functions.rs b/ableos/src/wasm_jumploader/host_functions.rs index 04c5055..036be2d 100644 --- a/ableos/src/wasm_jumploader/host_functions.rs +++ b/ableos/src/wasm_jumploader/host_functions.rs @@ -167,8 +167,8 @@ impl Externals for HostExternals { } GET_INPUT_INDEX => { - let input = None; - x86_64::instructions::interrupts::without_interrupts(|| KEYBUFF.lock().pop()); + let mut input = None; + input = x86_64::instructions::interrupts::without_interrupts(|| KEYBUFF.lock().pop()); if let Some(chr) = input { trace!("SYSCALL: input: {}", chr); } diff --git a/ableos/src/wasm_jumploader/mod.rs b/ableos/src/wasm_jumploader/mod.rs index 50b1fd8..d672a14 100644 --- a/ableos/src/wasm_jumploader/mod.rs +++ b/ableos/src/wasm_jumploader/mod.rs @@ -4,13 +4,13 @@ use crate::{filesystem::FILE_SYSTEM, wasm_jumploader::host_functions::HostExtern use genfs::{Fs, OpenOptions}; use wasmi::{ImportsBuilder, ModuleInstance}; -pub fn interp() { +pub fn interp(file: &[u8]) { trace!("Interpreting..."); let fs = &*FILE_SYSTEM.lock(); trace!("Got filesystem"); let file = fs .open( - b"/home/able/bins/aos_test.wasm", + file, OpenOptions::new().read(true), ) .unwrap();