This is an automated email from the ASF dual-hosted git repository. yuanz pushed a commit to branch no-std in repository https://gitbox.apache.org/repos/asf/incubator-teaclave-trustzone-sdk.git
commit 601259c419e81c882e979e5a4afa1361ef2ccc5e Author: Sumit Garg <[email protected]> AuthorDate: Mon Nov 27 14:27:49 2023 +0530 examples: random-rs: Switch to use #![no_std] While at it drop redundant Cargo.lock Signed-off-by: Sumit Garg <[email protected]> --- examples/random-rs/proto/Cargo.toml | 2 +- examples/random-rs/proto/src/lib.rs | 2 + examples/random-rs/ta/Cargo.lock | 105 ------------------------------------ examples/random-rs/ta/Cargo.toml | 7 ++- examples/random-rs/ta/src/main.rs | 5 ++ examples/random-rs/ta/ta_static.rs | 14 +++-- 6 files changed, 20 insertions(+), 115 deletions(-) diff --git a/examples/random-rs/proto/Cargo.toml b/examples/random-rs/proto/Cargo.toml index a12d1c0..284c8d4 100644 --- a/examples/random-rs/proto/Cargo.toml +++ b/examples/random-rs/proto/Cargo.toml @@ -27,4 +27,4 @@ edition = "2018" [dependencies] [build_dependencies] -uuid = { version = "0.8" } +uuid = { version = "1.6.1", default-features = false } diff --git a/examples/random-rs/proto/src/lib.rs b/examples/random-rs/proto/src/lib.rs index bf668da..aaca807 100644 --- a/examples/random-rs/proto/src/lib.rs +++ b/examples/random-rs/proto/src/lib.rs @@ -15,6 +15,8 @@ // specific language governing permissions and limitations // under the License. +#![no_std] + pub enum Command { RandomGenerator, Unknown, diff --git a/examples/random-rs/ta/Cargo.lock b/examples/random-rs/ta/Cargo.lock deleted file mode 100644 index 7657d4a..0000000 --- a/examples/random-rs/ta/Cargo.lock +++ /dev/null @@ -1,105 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -version = 3 - -[[package]] -name = "bitflags" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12" - -[[package]] -name = "hex" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "805026a5d0141ffc30abb3be3173848ad46a1b1664fe632428479619a3644d77" - -[[package]] -name = "libc" -version = "0.2.99" - -[[package]] -name = "optee-utee" -version = "0.2.0" -dependencies = [ - "bitflags", - "hex", - "libc", - "optee-utee-macros", - "optee-utee-sys", - "uuid", -] - -[[package]] -name = "optee-utee-macros" -version = "0.2.0" -dependencies = [ - "quote", - "syn", -] - -[[package]] -name = "optee-utee-sys" -version = "0.2.0" -dependencies = [ - "libc", -] - -[[package]] -name = "proc-macro2" -version = "0.4.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d317f9caece796be1980837fd5cb3dfec5613ebdb04ad0956deea83ce168915" -dependencies = [ - "unicode-xid", -] - -[[package]] -name = "proto" -version = "0.2.0" -dependencies = [ - "uuid", -] - -[[package]] -name = "quote" -version = "0.6.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cdd8e04bd9c52e0342b406469d494fcb033be4bdbe5c606016defbb1681411e1" -dependencies = [ - "proc-macro2", -] - -[[package]] -name = "syn" -version = "0.15.29" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1825685f977249735d510a242a6727b46efe914bb67e38d30c071b1b72b1d5c2" -dependencies = [ - "proc-macro2", - "quote", - "unicode-xid", -] - -[[package]] -name = "ta" -version = "0.2.0" -dependencies = [ - "libc", - "optee-utee", - "optee-utee-sys", - "proto", - "uuid", -] - -[[package]] -name = "unicode-xid" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" - -[[package]] -name = "uuid" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7" diff --git a/examples/random-rs/ta/Cargo.toml b/examples/random-rs/ta/Cargo.toml index 6a75dbb..a1f89c2 100644 --- a/examples/random-rs/ta/Cargo.toml +++ b/examples/random-rs/ta/Cargo.toml @@ -25,13 +25,12 @@ description = "An example of Rust OP-TEE TrustZone SDK." edition = "2018" [dependencies] -libc = { path = "../../../rust/libc" } proto = { path = "../proto" } -optee-utee-sys = { path = "../../../optee-utee/optee-utee-sys" } -optee-utee = { path = "../../../optee-utee" } +optee-utee-sys = { path = "../../../optee-utee/optee-utee-sys", default-features = false } +optee-utee = { path = "../../../optee-utee", default-features = false } [build_dependencies] -uuid = { version = "0.8" } +uuid = { version = "1.6.1", default-features = false } proto = { path = "../proto" } [profile.release] diff --git a/examples/random-rs/ta/src/main.rs b/examples/random-rs/ta/src/main.rs index 110a03a..92ec673 100644 --- a/examples/random-rs/ta/src/main.rs +++ b/examples/random-rs/ta/src/main.rs @@ -15,8 +15,13 @@ // specific language governing permissions and limitations // under the License. +#![no_std] #![no_main] +#![feature(c_size_t)] +extern crate alloc; + +use alloc::vec; use optee_utee::{ ta_close_session, ta_create, ta_destroy, ta_invoke_command, ta_open_session, trace_println, }; diff --git a/examples/random-rs/ta/ta_static.rs b/examples/random-rs/ta/ta_static.rs index b31f8c3..53ca210 100644 --- a/examples/random-rs/ta/ta_static.rs +++ b/examples/random-rs/ta/ta_static.rs @@ -15,8 +15,12 @@ // specific language governing permissions and limitations // under the License. +use core::ffi::*; +use core::mem; +use core::primitive::u64; + #[no_mangle] -pub static mut trace_level: libc::c_int = TRACE_LEVEL; +pub static mut trace_level: c_int = TRACE_LEVEL; #[no_mangle] pub static trace_ext_prefix: &[u8] = TRACE_EXT_PREFIX; @@ -27,7 +31,7 @@ pub static ta_head: optee_utee_sys::ta_head = optee_utee_sys::ta_head { uuid: TA_UUID, stack_size: TA_STACK_SIZE + TA_FRAMEWORK_STACK_SIZE, flags: TA_FLAGS, - depr_entry: std::u64::MAX, + depr_entry: u64::MAX, }; #[no_mangle] @@ -35,13 +39,13 @@ pub static ta_head: optee_utee_sys::ta_head = optee_utee_sys::ta_head { pub static ta_heap: [u8; TA_DATA_SIZE as usize] = [0; TA_DATA_SIZE as usize]; #[no_mangle] -pub static ta_heap_size: libc::size_t = std::mem::size_of::<u8>() * TA_DATA_SIZE as usize; +pub static ta_heap_size: c_size_t = mem::size_of::<u8>() * TA_DATA_SIZE as usize; static FLAG_BOOL: bool = (TA_FLAGS & optee_utee_sys::TA_FLAG_SINGLE_INSTANCE) != 0; static FLAG_MULTI: bool = (TA_FLAGS & optee_utee_sys::TA_FLAG_MULTI_SESSION) != 0; static FLAG_INSTANCE: bool = (TA_FLAGS & optee_utee_sys::TA_FLAG_INSTANCE_KEEP_ALIVE) != 0; #[no_mangle] -pub static ta_num_props: libc::size_t = 9; +pub static ta_num_props: c_size_t = 9; #[no_mangle] pub static ta_props: [optee_utee_sys::user_ta_property; 9] = [ @@ -93,6 +97,6 @@ pub static ta_props: [optee_utee_sys::user_ta_property; 9] = [ ]; #[no_mangle] -pub unsafe extern "C" fn tahead_get_trace_level() -> libc::c_int { +pub unsafe extern "C" fn tahead_get_trace_level() -> c_int { return trace_level; } --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
