From 1d6d91964f621ccc2ee295b949bc5c91bd2651fc Mon Sep 17 00:00:00 2001 From: Able Date: Fri, 7 Apr 2023 16:42:28 -0500 Subject: [PATCH] Create a core library for ableOS --- .vscode/settings.json | 3 +++ Cargo.lock | 7 +++++++ Cargo.toml | 1 + libraries/os_core/Cargo.toml | 8 ++++++++ libraries/os_core/src/lib.rs | 26 ++++++++++++++++++++++++++ programs/wasm_syscall_test/Cargo.toml | 1 + programs/wasm_syscall_test/src/main.rs | 10 ++-------- programs/xml_tests/src/main.rs | 2 +- 8 files changed, 49 insertions(+), 9 deletions(-) create mode 100644 .vscode/settings.json create mode 100644 libraries/os_core/Cargo.toml create mode 100644 libraries/os_core/src/lib.rs diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..4d9636b --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "rust-analyzer.showUnlinkedFileNotification": false +} \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index e43073c..09ef62d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -246,6 +246,10 @@ version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "86f0b0d4bf799edbc74508c1e8bf170ff5f41238e5f8225603ca7caaae2b7860" +[[package]] +name = "os_core" +version = "0.1.0" + [[package]] name = "pc_beeper_driver" version = "0.1.0" @@ -486,6 +490,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm_syscall_test" version = "0.1.0" +dependencies = [ + "os_core", +] [[package]] name = "wat2wasm" diff --git a/Cargo.toml b/Cargo.toml index 8af3783..621912c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,6 +22,7 @@ members = [ "libraries/xml", "libraries/locale-maxima", "libraries/messaging", + "libraries/os_core", "libraries/process", "libraries/std", "libraries/table", diff --git a/libraries/os_core/Cargo.toml b/libraries/os_core/Cargo.toml new file mode 100644 index 0000000..8456399 --- /dev/null +++ b/libraries/os_core/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "os_core" +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/libraries/os_core/src/lib.rs b/libraries/os_core/src/lib.rs new file mode 100644 index 0000000..b26d894 --- /dev/null +++ b/libraries/os_core/src/lib.rs @@ -0,0 +1,26 @@ +#![no_std] + +type Handle = i64; + +#[repr(C)] +pub struct OSString { + pub address: i32, + pub length: i32, +} + +extern "C" { + pub fn create_object(string: OSString) -> Result; + pub fn read_object_attribute(handle: Handle, string: OSString) -> Result; + pub fn set_object_attribute(handle: Handle, string: OSString, value: OSString) -> Result<()>; +} + +#[repr(C)] +pub enum ExternErrors { + None = 0, +} + +#[repr(C)] +pub struct Result { + pub ok: T, + pub err: ExternErrors, +} diff --git a/programs/wasm_syscall_test/Cargo.toml b/programs/wasm_syscall_test/Cargo.toml index 3ed3ac9..b0effcd 100644 --- a/programs/wasm_syscall_test/Cargo.toml +++ b/programs/wasm_syscall_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] +os_core = { path = "../../libraries/os_core" } diff --git a/programs/wasm_syscall_test/src/main.rs b/programs/wasm_syscall_test/src/main.rs index 22ea59c..08a820e 100644 --- a/programs/wasm_syscall_test/src/main.rs +++ b/programs/wasm_syscall_test/src/main.rs @@ -1,16 +1,10 @@ #![no_std] #![no_main] +use os_core::*; #[no_mangle] fn _start() { - unsafe { - let abc = read_mem_addr(13); - } -} - -extern "C" { - fn read_mem_addr(address: usize) -> u64; - + unsafe { create_object("") } } #[panic_handler] diff --git a/programs/xml_tests/src/main.rs b/programs/xml_tests/src/main.rs index 7c9823c..173f61b 100644 --- a/programs/xml_tests/src/main.rs +++ b/programs/xml_tests/src/main.rs @@ -2,6 +2,6 @@ use xml; fn main() { let root = xml::XMLElement::new("name"); - println!("{:?}", root.to_bin().unwrap()); + // println!("{:?}", root.to_bin().unwrap()); println!("{}", root.to_string()); }