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