From a9643bf9d2f14e1ed8680ba6c1802bc876000540 Mon Sep 17 00:00:00 2001 From: Able Date: Wed, 5 Apr 2023 14:04:10 -0500 Subject: [PATCH] provide a simple wasm executable for ableOS --- Cargo.lock | 4 ++++ Cargo.toml | 1 + libraries/xml/src/lib.rs | 1 + programs/wasm_syscall_test/.cargo/config.toml | 6 ++++++ programs/wasm_syscall_test/Cargo.toml | 8 ++++++++ programs/wasm_syscall_test/src/main.rs | 18 ++++++++++++++++++ 6 files changed, 38 insertions(+) create mode 100644 programs/wasm_syscall_test/.cargo/config.toml create mode 100644 programs/wasm_syscall_test/Cargo.toml create mode 100644 programs/wasm_syscall_test/src/main.rs diff --git a/Cargo.lock b/Cargo.lock index db77dbf..7935391 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -492,6 +492,10 @@ version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" +[[package]] +name = "wasm_syscall_test" +version = "0.1.0" + [[package]] name = "wat2wasm" version = "0.1.0" diff --git a/Cargo.toml b/Cargo.toml index 7d433dc..8af3783 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -37,6 +37,7 @@ members = [ "programs/shell", "programs/table_view", "programs/undelete", + "programs/wasm_syscall_test", "programs/wat2wasm", "programs/xml_tests", diff --git a/libraries/xml/src/lib.rs b/libraries/xml/src/lib.rs index 2c33d7a..78922cc 100644 --- a/libraries/xml/src/lib.rs +++ b/libraries/xml/src/lib.rs @@ -9,6 +9,7 @@ use alloc::string::{String, ToString}; use alloc::vec::Vec; use serde::{Deserialize, Serialize}; + #[derive(PartialEq, Clone, Debug, Serialize, Deserialize)] pub struct Attribute { diff --git a/programs/wasm_syscall_test/.cargo/config.toml b/programs/wasm_syscall_test/.cargo/config.toml new file mode 100644 index 0000000..7a6e571 --- /dev/null +++ b/programs/wasm_syscall_test/.cargo/config.toml @@ -0,0 +1,6 @@ +# [unstable] +# build-std = ["core", "compiler_builtins", "alloc"] +# build-std-features = ["compiler-builtins-mem"] + +[build] +target = "wasm32-unknown-unknown" diff --git a/programs/wasm_syscall_test/Cargo.toml b/programs/wasm_syscall_test/Cargo.toml new file mode 100644 index 0000000..3ed3ac9 --- /dev/null +++ b/programs/wasm_syscall_test/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "wasm_syscall_test" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/programs/wasm_syscall_test/src/main.rs b/programs/wasm_syscall_test/src/main.rs new file mode 100644 index 0000000..9062361 --- /dev/null +++ b/programs/wasm_syscall_test/src/main.rs @@ -0,0 +1,18 @@ +#![no_std] +#![no_main] + +fn _start() { + unsafe { + let abc = read_mem_addr(13); + } +} + +extern "C" { + fn read_mem_addr(address: usize) -> u64; + +} + +#[panic_handler] +fn panic(info: &core::panic::PanicInfo) -> ! { + loop {} +}