From ab3110923ea77835493cc65c23b168ee4addf1df Mon Sep 17 00:00:00 2001 From: Able Date: Wed, 23 Feb 2022 10:06:27 -0600 Subject: [PATCH] metadata and peek/poke --- ableos/src/rhai_shell/mod.rs | 25 ++++++-- userland/wasm_pk_data/Cargo.lock | 75 ++++++++++++++++++++++ userland/wasm_pk_data/Cargo.toml | 17 +++++ userland/wasm_pk_data/assets/metadata.toml | 3 + userland/wasm_pk_data/src/lib.rs | 20 ++++++ 5 files changed, 135 insertions(+), 5 deletions(-) create mode 100644 userland/wasm_pk_data/Cargo.lock create mode 100644 userland/wasm_pk_data/Cargo.toml create mode 100644 userland/wasm_pk_data/assets/metadata.toml create mode 100644 userland/wasm_pk_data/src/lib.rs diff --git a/ableos/src/rhai_shell/mod.rs b/ableos/src/rhai_shell/mod.rs index b20fb02..8b88867 100644 --- a/ableos/src/rhai_shell/mod.rs +++ b/ableos/src/rhai_shell/mod.rs @@ -50,11 +50,13 @@ pub fn afetch() { disable(); let tick_time = TICK.load(Relaxed); - println!("OS: AbleOS"); - println!("Host: {}", kstate.hostname); - println!("Kernel: AKern-{}-v{}", RELEASE_TYPE, KERNEL_VERSION); - println!("Uptime: {}", tick_time); - + println!( + "OS: AbleOS +Host: {} +Kernel: AKern-{}-v{} +Uptime: {}", + kstate.hostname, RELEASE_TYPE, KERNEL_VERSION, tick_time + ); enable(); drop(kstate); } @@ -77,5 +79,18 @@ fn engine_construction() -> Engine { engine.register_fn("afetch", afetch); engine.register_fn("set_hostname", set_hostname); engine.register_fn("shutdown", shutdown); + engine.register_fn("peek", peek_memory); + engine.register_fn("poke", poke_memory); engine } + +/// Examine a memory pointer +pub fn peek_memory(ptr: i64) -> u8 { + let ptr: usize = ptr as usize; + unsafe { *(ptr as *const u8) } +} + +pub fn poke_memory(ptr: i64, val: u8) { + let ptr: usize = ptr as usize; + unsafe { *(ptr as *mut u8) = val } +} diff --git a/userland/wasm_pk_data/Cargo.lock b/userland/wasm_pk_data/Cargo.lock new file mode 100644 index 0000000..b44ca70 --- /dev/null +++ b/userland/wasm_pk_data/Cargo.lock @@ -0,0 +1,75 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "proc-macro2" +version = "1.0.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7342d5883fbccae1cc37a2353b09c87c9b0f3afd73f5fb9bba687a1f733b029" +dependencies = [ + "unicode-xid", +] + +[[package]] +name = "quote" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "864d3e96a899863136fc6e99f3d7cae289dafe43bf2c5ac19b70df7210c0a145" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "serde" +version = "1.0.136" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce31e24b01e1e524df96f1c2fdd054405f8d7376249a5110886fb4b658484789" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.136" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08597e7152fcd306f41838ed3e37be9eaeed2b61c42e2117266a554fab4662f9" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "syn" +version = "1.0.86" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a65b3f4ffa0092e9887669db0eae07941f023991ab58ea44da8fe8e2d511c6b" +dependencies = [ + "proc-macro2", + "quote", + "unicode-xid", +] + +[[package]] +name = "toml" +version = "0.5.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a31142970826733df8241ef35dc040ef98c679ab14d7c3e54d827099b3acecaa" +dependencies = [ + "serde", +] + +[[package]] +name = "unicode-xid" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" + +[[package]] +name = "wasm_pk_data" +version = "0.1.0" +dependencies = [ + "serde", + "toml", +] diff --git a/userland/wasm_pk_data/Cargo.toml b/userland/wasm_pk_data/Cargo.toml new file mode 100644 index 0000000..be39553 --- /dev/null +++ b/userland/wasm_pk_data/Cargo.toml @@ -0,0 +1,17 @@ +[package] +name = "wasm_pk_data" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +toml = "0.5" + + + + + +[dependencies.serde] +version = "1.0" +features = ["derive"] \ No newline at end of file diff --git a/userland/wasm_pk_data/assets/metadata.toml b/userland/wasm_pk_data/assets/metadata.toml new file mode 100644 index 0000000..b0d0eb1 --- /dev/null +++ b/userland/wasm_pk_data/assets/metadata.toml @@ -0,0 +1,3 @@ +name = "bruh" +version = [1233, 123, 123] +authors = ["John Doe", "Jane Doe"] \ No newline at end of file diff --git a/userland/wasm_pk_data/src/lib.rs b/userland/wasm_pk_data/src/lib.rs new file mode 100644 index 0000000..42adb3a --- /dev/null +++ b/userland/wasm_pk_data/src/lib.rs @@ -0,0 +1,20 @@ +#![no_std] +extern crate alloc; +use { + alloc::{string::String, vec::Vec}, + serde::Deserialize, +}; + +#[derive(Debug, Deserialize)] +pub struct Version { + pub major: u16, + pub minor: u8, + pub patch: u8, +} + +#[derive(Debug, Deserialize)] +pub struct MetaData { + pub name: String, + pub version: Version, + pub authors: Vec, +}