• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *    http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef _TEE_SERVICE_PUBLIC_H_
17 #define _TEE_SERVICE_PUBLIC_H_
18 
19 /**
20  * @addtogroup TeeTrusted
21  * @{
22  *
23  * @brief TEE(Trusted Excution Environment) API.
24  * Provides security capability APIs such as trusted storage, encryption and decryption,
25  * and trusted time for trusted application development.
26  *
27  * @since 12
28  */
29 
30 /**
31  * @file tee_service_public.h
32  *
33  * @brief Provides the TEE service public function for developers.
34  *
35  * @library NA
36  * @kit TEE Kit
37  * @syscap SystemCapability.Tee.TeeClient
38  * @since 12
39  * @version 1.0
40  */
41 
42 #include "tee_defines.h"
43 
44 #ifdef __cplusplus
45 extern "C" {
46 #endif
47 
48 typedef void (*func_ptr)(void);
49 
50 /**
51  * @brief Defines the size of the message queue for the TEE service
52  *
53  * @since 12
54  */
55 #define TEE_SERVICE_MSG_QUEUE_SIZE 100
56 
57 /**
58  * @brief Defines the arguments of a message.
59  *
60  * @since 12
61  */
62 typedef struct {
63     uint64_t arg0;
64     uint64_t arg1;
65     uint64_t arg2;
66     uint64_t arg3;
67     uint64_t arg4;
68     uint64_t arg5;
69     uint64_t arg6;
70     uint64_t arg7;
71 } args_t;
72 
73 /**
74  * @brief Defines the register information of TA.
75  *
76  * @since 12
77  */
78 struct reg_ta_info {
79     uint32_t taskid;
80     TEE_UUID uuid;
81     uint32_t userid;
82     /** Just for ssa, other tasks shall ignore it. */
83     bool ssa_enum_enable;
84 };
85 
86 /**
87  * @brief Defines the IPC message of TEE service.
88  *
89  * @since 12
90  */
91 typedef union {
92     args_t args_data;
93     struct reg_ta_info reg_ta;
94 } tee_service_ipc_msg;
95 
96 /**
97  * @brief Defines the IPC request message of TEE service.
98  *
99  * @since 12
100  */
101 struct tee_service_ipc_msg_req {
102     uint32_t cmd;
103     tee_service_ipc_msg msg;
104 };
105 
106 /**
107  * @brief Defines the IPC response message of TEE service.
108  *
109  * @since 12
110  */
111 typedef struct {
112     TEE_Result ret;
113     tee_service_ipc_msg msg;
114 } tee_service_ipc_msg_rsp;
115 
116 /**
117  * @brief Defines the message of the TEE service.
118  *
119  * @since 12
120  */
121 typedef struct {
122     uint32_t msg_id;
123     uint32_t sender;
124     tee_service_ipc_msg msg;
125 } tee_service_msg_t;
126 
127 /**
128  * @brief Defines the message queue for the TEE service.
129  *
130  * @since 12
131  */
132 typedef struct {
133     uint32_t in;
134     uint32_t out;
135     tee_service_msg_t msg[TEE_SERVICE_MSG_QUEUE_SIZE];
136 } tee_service_msg_queue_t;
137 
138 /**
139  * @brief Provides to send IPC synchronization messages to a specified service
140  *  and receive responses from the service.
141  *
142  * @param task_name Indicates the task name of recipient.
143  * @param snd_cmd Indicates the command ID of the send message.
144  * @param snd_msg Indicates the send message.
145  * @param ack_cmd Indicates the ID of the ack cmd to be received.
146  * @param rsp_msg Indicates the service response message.
147  *
148  * @since 12
149  * @version 1.0
150  */
151 void tee_common_ipc_proc_cmd(const char *task_name,
152                              uint32_t snd_cmd, const tee_service_ipc_msg *snd_msg,
153                              uint32_t ack_cmd, tee_service_ipc_msg_rsp *rsp_msg);
154 
155 #ifdef __cplusplus
156 }
157 #endif
158 /** @} */
159 #endif