1
0
Fork 0
forked from AbleOS/ableos

metadata and peek/poke

This commit is contained in:
Able 2022-02-23 10:06:27 -06:00
parent 64d6e1e166
commit ab3110923e
5 changed files with 135 additions and 5 deletions

View file

@ -50,11 +50,13 @@ pub fn afetch() {
disable(); disable();
let tick_time = TICK.load(Relaxed); let tick_time = TICK.load(Relaxed);
println!("OS: AbleOS"); println!(
println!("Host: {}", kstate.hostname); "OS: AbleOS
println!("Kernel: AKern-{}-v{}", RELEASE_TYPE, KERNEL_VERSION); Host: {}
println!("Uptime: {}", tick_time); Kernel: AKern-{}-v{}
Uptime: {}",
kstate.hostname, RELEASE_TYPE, KERNEL_VERSION, tick_time
);
enable(); enable();
drop(kstate); drop(kstate);
} }
@ -77,5 +79,18 @@ fn engine_construction() -> Engine {
engine.register_fn("afetch", afetch); engine.register_fn("afetch", afetch);
engine.register_fn("set_hostname", set_hostname); engine.register_fn("set_hostname", set_hostname);
engine.register_fn("shutdown", shutdown); engine.register_fn("shutdown", shutdown);
engine.register_fn("peek", peek_memory);
engine.register_fn("poke", poke_memory);
engine 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 }
}

75
userland/wasm_pk_data/Cargo.lock generated Normal file
View file

@ -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",
]

View file

@ -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"]

View file

@ -0,0 +1,3 @@
name = "bruh"
version = [1233, 123, 123]
authors = ["John Doe", "Jane Doe"]

View file

@ -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<String>,
}