optee_utee/
lib.rs

1// Licensed to the Apache Software Foundation (ASF) under one
2// or more contributor license agreements.  See the NOTICE file
3// distributed with this work for additional information
4// regarding copyright ownership.  The ASF licenses this file
5// to you under the Apache License, Version 2.0 (the
6// "License"); you may not use this file except in compliance
7// with the License.  You may obtain a copy of the License at
8//
9//   http://www.apache.org/licenses/LICENSE-2.0
10//
11// Unless required by applicable law or agreed to in writing,
12// software distributed under the License is distributed on an
13// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14// KIND, either express or implied.  See the License for the
15// specific language governing permissions and limitations
16// under the License.
17
18#![cfg_attr(not(feature = "std"), no_std)]
19#![cfg_attr(doc, doc = concat!(
20    env!("CARGO_PKG_DESCRIPTION"),
21    "\n",
22    "## Feature flags\n",
23    document_features::document_features!(),
24))]
25
26// Requires `alloc`.
27#[macro_use]
28extern crate alloc;
29
30#[cfg(not(feature = "std"))]
31use libc_alloc::LibcAlloc;
32
33#[cfg(not(feature = "std"))]
34#[global_allocator]
35static ALLOCATOR: LibcAlloc = LibcAlloc;
36
37#[cfg(all(not(feature = "std"), not(feature = "no_panic_handler")))]
38#[panic_handler]
39fn panic(_info: &core::panic::PanicInfo) -> ! {
40    unsafe {
41        optee_utee_sys::TEE_Panic(0);
42    }
43    loop {}
44}
45
46// Stubs for unwinding symbols required by the precompiled sysroot when not using
47// `-Z build-std`. These are never actually called because we compile with
48// `-C panic=abort`, but the linker requires the symbols to be present.
49#[cfg(all(not(feature = "std"), feature = "unwind_stubs"))]
50mod unwind_stubs {
51    #[unsafe(no_mangle)]
52    extern "C" fn _Unwind_Resume() -> ! {
53        loop {}
54    }
55
56    #[unsafe(no_mangle)]
57    extern "C" fn rust_eh_personality() {}
58}
59
60pub use self::arithmetical::*;
61pub use self::crypto_op::*;
62pub use self::error::{Error, ErrorKind, Result};
63pub use self::extension::*;
64pub use self::identity::{Identity, LoginType};
65pub use self::object::*;
66pub use self::parameter::{
67    ParamType, ParamTypes, Parameter, Parameters, RawParamType, RawParamTypes, RawParams,
68};
69pub use self::ta_session::{TaSession, TaSessionBuilder};
70pub use self::tee_parameter::{ParamIndex, TeeParams};
71pub use self::time::*;
72pub use self::uuid::*;
73pub use optee_utee_macros::{
74    ta_close_session, ta_create, ta_destroy, ta_invoke_command, ta_open_session,
75};
76
77pub mod trace;
78#[macro_use]
79mod macros;
80pub mod arithmetical;
81pub mod crypto_op;
82mod error;
83pub mod extension;
84pub mod identity;
85pub mod net;
86pub mod object;
87mod parameter;
88pub mod property;
89mod ta_session;
90mod tee_parameter;
91pub mod time;
92pub mod uuid;