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 core::ffi::*;
19 use core::mem;
20 use core::primitive::u64;
21 
22 #[no_mangle]
23 pub static mut trace_level: c_int = TRACE_LEVEL;
24 
25 #[no_mangle]
26 pub static trace_ext_prefix: &[u8] = TRACE_EXT_PREFIX;
27 
28 #[no_mangle]
29 #[link_section = ".ta_head"]
30 pub static ta_head: optee_utee_sys::ta_head = optee_utee_sys::ta_head {
31     uuid: TA_UUID,
32     stack_size: TA_STACK_SIZE + TA_FRAMEWORK_STACK_SIZE,
33     flags: TA_FLAGS,
34     depr_entry: u64::MAX,
35 };
36 
37 #[no_mangle]
38 #[link_section = ".bss"]
39 pub static ta_heap: [u8; TA_DATA_SIZE as usize] = [0; TA_DATA_SIZE as usize];
40 
41 #[no_mangle]
42 pub static ta_heap_size: c_size_t = mem::size_of::<u8>() * TA_DATA_SIZE as usize;
43 static FLAG_BOOL: bool = (TA_FLAGS & optee_utee_sys::TA_FLAG_SINGLE_INSTANCE) != 0;
44 static FLAG_MULTI: bool = (TA_FLAGS & optee_utee_sys::TA_FLAG_MULTI_SESSION) != 0;
45 static FLAG_INSTANCE: bool = (TA_FLAGS & optee_utee_sys::TA_FLAG_INSTANCE_KEEP_ALIVE) != 0;
46 
47 #[no_mangle]
48 pub static ta_num_props: c_size_t = 9;
49 
50 #[no_mangle]
51 pub static ta_props: [optee_utee_sys::user_ta_property; 9] = [
52     optee_utee_sys::user_ta_property {
53         name: optee_utee_sys::TA_PROP_STR_SINGLE_INSTANCE,
54         prop_type: optee_utee_sys::user_ta_prop_type::USER_TA_PROP_TYPE_BOOL,
55         value: &FLAG_BOOL as *const bool as *mut _,
56     },
57     optee_utee_sys::user_ta_property {
58         name: optee_utee_sys::TA_PROP_STR_MULTI_SESSION,
59         prop_type: optee_utee_sys::user_ta_prop_type::USER_TA_PROP_TYPE_BOOL,
60         value: &FLAG_MULTI as *const bool as *mut _,
61     },
62     optee_utee_sys::user_ta_property {
63         name: optee_utee_sys::TA_PROP_STR_KEEP_ALIVE,
64         prop_type: optee_utee_sys::user_ta_prop_type::USER_TA_PROP_TYPE_BOOL,
65         value: &FLAG_INSTANCE as *const bool as *mut _,
66     },
67     optee_utee_sys::user_ta_property {
68         name: optee_utee_sys::TA_PROP_STR_DATA_SIZE,
69         prop_type: optee_utee_sys::user_ta_prop_type::USER_TA_PROP_TYPE_U32,
70         value: &TA_DATA_SIZE as *const u32 as *mut _,
71     },
72     optee_utee_sys::user_ta_property {
73         name: optee_utee_sys::TA_PROP_STR_STACK_SIZE,
74         prop_type: optee_utee_sys::user_ta_prop_type::USER_TA_PROP_TYPE_U32,
75         value: &TA_STACK_SIZE as *const u32 as *mut _,
76     },
77     optee_utee_sys::user_ta_property {
78         name: optee_utee_sys::TA_PROP_STR_VERSION,
79         prop_type: optee_utee_sys::user_ta_prop_type::USER_TA_PROP_TYPE_STRING,
80         value: TA_VERSION as *const [u8] as *mut _,
81     },
82     optee_utee_sys::user_ta_property {
83         name: optee_utee_sys::TA_PROP_STR_DESCRIPTION,
84         prop_type: optee_utee_sys::user_ta_prop_type::USER_TA_PROP_TYPE_STRING,
85         value: TA_DESCRIPTION as *const [u8] as *mut _,
86     },
87     optee_utee_sys::user_ta_property {
88         name: "gp.ta.description\0".as_ptr(),
89         prop_type: optee_utee_sys::user_ta_prop_type::USER_TA_PROP_TYPE_STRING,
90         value: EXT_PROP_VALUE_1 as *const [u8] as *mut _,
91     },
92     optee_utee_sys::user_ta_property {
93         name: "gp.ta.version\0".as_ptr(),
94         prop_type: optee_utee_sys::user_ta_prop_type::USER_TA_PROP_TYPE_U32,
95         value: &EXT_PROP_VALUE_2 as *const u32 as *mut _,
96     },
97 ];
98 
99 #[no_mangle]
tahead_get_trace_level() -> c_int100 pub unsafe extern "C" fn tahead_get_trace_level() -> c_int {
101     return trace_level;
102 }
103