1 /*
2  *
3  * Copyright (C) 2017 GlobalLogic
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * 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, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 #ifndef OPTEE_IPC_H
19 #define OPTEE_IPC_H
20 
21 extern "C" {
22 #include <tee_client_api.h>
23 }
24 namespace android {
25 namespace hardware {
26 namespace gatekeeper {
27 namespace V1_0 {
28 namespace optee {
29 
30 class OpteeIPC {
31 public:
32     OpteeIPC();
33     ~OpteeIPC();
34 
35     bool initialize();
36     void finalize();
37 
38     bool connect(const TEEC_UUID& uuid);
39     void disconnect();
40     bool call(uint32_t cmd,
41             const uint8_t *in,  uint32_t  in_size,
42                   uint8_t *out, uint32_t& out_size);
43 
44 private:
45     TEEC_Context ctx;
46     TEEC_Session sess;
47     bool inUse;
48 };
49 }  // namespace optee
50 }  // namespace V1_0
51 }  // namespace gatekeeper
52 }  // namespace hardware
53 }  // namespace android
54 
55 #endif /* OPTEE_IPC_H */
56