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(feature = "std")]
19 use std::os::raw::*;
20 #[cfg(not(feature = "std"))]
21 use core::ffi::*;
22 use super::tee_api_types::*;
23 use super::utee_syscalls::*;
24 use super::utee_types::*;
25
26 pub const TA_FLAG_SINGLE_INSTANCE: u32 = 1 << 2;
27 pub const TA_FLAG_MULTI_SESSION: u32 = 1 << 3;
28 pub const TA_FLAG_INSTANCE_KEEP_ALIVE: u32 = 1 << 4;
29 pub const TA_FLAG_SECURE_DATA_PATH: u32 = 1 << 5;
30 pub const TA_FLAG_REMAP_SUPPORT: u32 = 1 << 6;
31 pub const TA_FLAG_CACHE_MAINTENANCE: u32 = 1 << 7;
32
33 pub const TA_FLAG_EXEC_DDR: u32 = 0;
34 pub const TA_FLAG_USER_MODE: u32 = 0;
35 #[repr(C)]
36 pub struct ta_head {
37 pub uuid: TEE_UUID,
38 pub stack_size: u32,
39 pub flags: u32,
40 pub depr_entry: u64,
41 }
42
43 extern "C" {
__utee_entry(func: c_ulong, session_id: c_ulong, up: *mut utee_params, cmd_id: c_ulong) -> TEE_Result44 pub fn __utee_entry(func: c_ulong, session_id: c_ulong, up: *mut utee_params, cmd_id: c_ulong) -> TEE_Result;
45 }
46
47 #[no_mangle]
__ta_entry(func: c_ulong, session_id: c_ulong, up: *mut utee_params, cmd_id: c_ulong) -> !48 pub fn __ta_entry(func: c_ulong, session_id: c_ulong, up: *mut utee_params, cmd_id: c_ulong) -> ! {
49 let res: u32 = unsafe { __utee_entry(func, session_id, up, cmd_id) };
50
51 unsafe { _utee_return(res.into()) };
52 }
53
54 unsafe impl Sync for ta_head {}
55
56 pub const TA_PROP_STR_SINGLE_INSTANCE: *const c_uchar = "gpd.ta.singleInstance\0".as_ptr();
57 pub const TA_PROP_STR_MULTI_SESSION: *const c_uchar = "gpd.ta.multiSession\0".as_ptr();
58 pub const TA_PROP_STR_KEEP_ALIVE: *const c_uchar = "gpd.ta.instanceKeepAlive\0".as_ptr();
59 pub const TA_PROP_STR_DATA_SIZE: *const c_uchar = "gpd.ta.dataSize\0".as_ptr();
60 pub const TA_PROP_STR_STACK_SIZE: *const c_uchar = "gpd.ta.stackSize\0".as_ptr();
61 pub const TA_PROP_STR_VERSION: *const c_uchar = "gpd.ta.version\0".as_ptr();
62 pub const TA_PROP_STR_DESCRIPTION: *const c_uchar = "gpd.ta.description\0".as_ptr();
63 pub const TA_PROP_STR_UNSAFE_PARAM: *const c_uchar = "op-tee.unsafe_param\0".as_ptr();
64 pub const TA_PROP_STR_REMAP: *const c_uchar = "op-tee.remap\0".as_ptr();
65 pub const TA_PROP_STR_CACHE_SYNC: *const c_uchar = "op-tee.cache_sync\0".as_ptr();
66
67 #[repr(C)]
68 pub enum user_ta_prop_type {
69 USER_TA_PROP_TYPE_BOOL,
70 USER_TA_PROP_TYPE_U32,
71 USER_TA_PROP_TYPE_UUID,
72 USER_TA_PROP_TYPE_IDENTITY,
73 USER_TA_PROP_TYPE_STRING,
74 USER_TA_PROP_TYPE_BINARY_BLOCK,
75 }
76
77 #[repr(C)]
78 pub struct user_ta_property {
79 pub name: *const c_uchar,
80 pub prop_type: user_ta_prop_type,
81 pub value: *mut c_void,
82 }
83
84 unsafe impl Sync for user_ta_property {}
85