1419b0af8Sopenharmony_ci/*
2419b0af8Sopenharmony_ci * teek_client_constants.h
3419b0af8Sopenharmony_ci *
4419b0af8Sopenharmony_ci * macro declaration for libteec interface for kernel CA.
5419b0af8Sopenharmony_ci *
6419b0af8Sopenharmony_ci * Copyright (C) 2022 Huawei Technologies Co., Ltd.
7419b0af8Sopenharmony_ci *
8419b0af8Sopenharmony_ci * This software is licensed under the terms of the GNU General Public
9419b0af8Sopenharmony_ci * License version 2, as published by the Free Software Foundation, and
10419b0af8Sopenharmony_ci * may be copied, distributed, and modified under those terms.
11419b0af8Sopenharmony_ci *
12419b0af8Sopenharmony_ci * This program is distributed in the hope that it will be useful,
13419b0af8Sopenharmony_ci * but WITHOUT ANY WARRANTY; without even the implied warranty of
14419b0af8Sopenharmony_ci * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15419b0af8Sopenharmony_ci * GNU General Public License for more details.
16419b0af8Sopenharmony_ci */
17419b0af8Sopenharmony_ci
18419b0af8Sopenharmony_ci#ifndef TEEK_CLIENT_CONSTANTS_H
19419b0af8Sopenharmony_ci#define TEEK_CLIENT_CONSTANTS_H
20419b0af8Sopenharmony_ci
21419b0af8Sopenharmony_cienum global_service_cmd_id {
22419b0af8Sopenharmony_ci	GLOBAL_CMD_ID_INVALID = 0x0,
23419b0af8Sopenharmony_ci	GLOBAL_CMD_ID_BOOT_ACK = 0x1,
24419b0af8Sopenharmony_ci	GLOBAL_CMD_ID_OPEN_SESSION = 0x2,
25419b0af8Sopenharmony_ci	GLOBAL_CMD_ID_CLOSE_SESSION = 0x3,
26419b0af8Sopenharmony_ci	GLOBAL_CMD_ID_LOAD_SECURE_APP = 0x4,
27419b0af8Sopenharmony_ci	GLOBAL_CMD_ID_NEED_LOAD_APP = 0x5,
28419b0af8Sopenharmony_ci	GLOBAL_CMD_ID_REGISTER_AGENT = 0x6,
29419b0af8Sopenharmony_ci	GLOBAL_CMD_ID_UNREGISTER_AGENT = 0x7,
30419b0af8Sopenharmony_ci	GLOBAL_CMD_ID_REGISTER_NOTIFY_MEMORY = 0x8,
31419b0af8Sopenharmony_ci	GLOBAL_CMD_ID_UNREGISTER_NOTIFY_MEMORY = 0x9,
32419b0af8Sopenharmony_ci	GLOBAL_CMD_ID_INIT_CONTENT_PATH = 0xa,
33419b0af8Sopenharmony_ci	GLOBAL_CMD_ID_TERMINATE_CONTENT_PATH = 0xb,
34419b0af8Sopenharmony_ci	GLOBAL_CMD_ID_ALLOC_EXCEPTION_MEM = 0xc,
35419b0af8Sopenharmony_ci	GLOBAL_CMD_ID_TEE_TIME = 0xd,
36419b0af8Sopenharmony_ci	GLOBAL_CMD_ID_TEE_INFO = 0xe,
37419b0af8Sopenharmony_ci	GLOBAL_CMD_ID_REGISTER_LOG_MEM = 0xf,
38419b0af8Sopenharmony_ci	GLOBAL_CMD_ID_KILL_TASK = 0x10,
39419b0af8Sopenharmony_ci	GLOBAL_CMD_ID_TUI_EXCEPTION = 0x11,
40419b0af8Sopenharmony_ci	GLOBAL_CMD_ID_ADJUST_TIME = 0x12,
41419b0af8Sopenharmony_ci	GLOBAL_CMD_ID_SET_CA_HASH = 0x13,
42419b0af8Sopenharmony_ci	/* set the Android's build version */
43419b0af8Sopenharmony_ci	GLOBAL_CMD_ID_SET_BUILD_VERSION = 0x14,
44419b0af8Sopenharmony_ci	GLOBAL_CMD_ID_REGISTER_TTF_MEM = 0x15,
45419b0af8Sopenharmony_ci	/* get session key for encrypting dialog */
46419b0af8Sopenharmony_ci	GLOBAL_CMD_ID_GET_SESSION_SECURE_PARAMS = 0x16,
47419b0af8Sopenharmony_ci	GLOBAL_CMD_ID_REGISTER_MAILBOX = 0x17,
48419b0af8Sopenharmony_ci	GLOBAL_CMD_ID_REGISTER_UNUSUAL_TTF_MEM = 0x18,
49419b0af8Sopenharmony_ci	GLOBAL_CMD_ID_REGISTER_ION_MEM = 0x19,
50419b0af8Sopenharmony_ci	GLOBAL_CMD_ID_DUMP_MEMINFO = 0x1a,
51419b0af8Sopenharmony_ci	/* this cmd will be used to service no ca handle cmd */
52419b0af8Sopenharmony_ci	GLOBAL_CMD_ID_SET_SERVE_CMD = 0x1b,
53419b0af8Sopenharmony_ci	GLOBAL_CMD_ID_ADD_DYNAMIC_ION = 0x1c,
54419b0af8Sopenharmony_ci	GLOBAL_CMD_ID_DEL_DYNAMIC_ION = 0x1d,
55419b0af8Sopenharmony_ci	GLOBAL_CMD_ID_RELEASE_ION_SRV = 0x1e,
56419b0af8Sopenharmony_ci	/* this cmd for tui to get notch_size */
57419b0af8Sopenharmony_ci	GLOBAL_CMD_ID_TUI_NOTCH = 0x1f,
58419b0af8Sopenharmony_ci	GLOBAL_CMD_ID_LATE_INIT = 0x20,
59419b0af8Sopenharmony_ci	/* this cmd for tui to get information of foldable screen */
60419b0af8Sopenharmony_ci	GLOBAL_CMD_ID_TUI_FOLD = 0x21,
61419b0af8Sopenharmony_ci	GLOBAL_CMD_ID_GET_TEE_VERSION = 0x22,
62419b0af8Sopenharmony_ci#ifdef CONFIG_CMS_SIGNATURE
63419b0af8Sopenharmony_ci	GLOBAL_CMD_ID_UPDATE_TA_CRL = 0x23,
64419b0af8Sopenharmony_ci#endif
65419b0af8Sopenharmony_ci	GLOBAL_CMD_ID_REGISTER_RESMEM = 0x24,
66419b0af8Sopenharmony_ci	GLOBAL_CMD_ID_DUMP_SRV_SESS = 0x25,
67419b0af8Sopenharmony_ci	GLOBAL_CMD_ID_TRACE_ENABLE = 0x26,
68419b0af8Sopenharmony_ci#ifdef CONFIG_LIVEPATCH_ENABLE
69419b0af8Sopenharmony_ci	GLOBAL_CMD_ID_LIVEPATCH_UNLOAD = 0x27,
70419b0af8Sopenharmony_ci	GLOBAL_CMD_ID_LIVEPATCH_ENABLE = 0x28,
71419b0af8Sopenharmony_ci	GLOBAL_CMD_ID_LIVEPATCH_DISABLE = 0x29,
72419b0af8Sopenharmony_ci	GLOBAL_CMD_ID_LIVEPATCH_QUERY = 0x2a,
73419b0af8Sopenharmony_ci#endif
74419b0af8Sopenharmony_ci	GLOBAL_CMD_ID_UNKNOWN = 0x7FFFFFFE,
75419b0af8Sopenharmony_ci	GLOBAL_CMD_ID_MAX = 0x7FFFFFFF
76419b0af8Sopenharmony_ci};
77419b0af8Sopenharmony_ci
78419b0af8Sopenharmony_cienum teec_result {
79419b0af8Sopenharmony_ci	TEEC_SUCCESS = 0x0,
80419b0af8Sopenharmony_ci	TEEC_ERROR_INVALID_CMD = 0x1,
81419b0af8Sopenharmony_ci	TEEC_ERROR_SERVICE_NOT_EXIST = 0x2,
82419b0af8Sopenharmony_ci	TEEC_ERROR_SESSION_NOT_EXIST = 0x3,
83419b0af8Sopenharmony_ci	TEEC_ERROR_SESSION_MAXIMUM,
84419b0af8Sopenharmony_ci	TEEC_ERROR_REGISTER_EXIST_SERVICE,
85419b0af8Sopenharmony_ci	TEEC_ERROR_TAGET_DEAD_FATAL,
86419b0af8Sopenharmony_ci	TEEC_ERROR_READ_DATA,
87419b0af8Sopenharmony_ci	TEEC_ERROR_WRITE_DATA,
88419b0af8Sopenharmony_ci	TEEC_ERROR_TRUNCATE_OBJECT,
89419b0af8Sopenharmony_ci	TEEC_ERROR_SEEK_DATA,
90419b0af8Sopenharmony_ci	TEEC_ERROR_RENAME_OBJECT,
91419b0af8Sopenharmony_ci	TEEC_ERROR_TRUSTED_APP_LOAD_ERROR,
92419b0af8Sopenharmony_ci	TEEC_ERROR_GENERIC = 0xFFFF0000,
93419b0af8Sopenharmony_ci	TEEC_ERROR_ACCESS_DENIED = 0xFFFF0001,
94419b0af8Sopenharmony_ci	TEEC_ERROR_CANCEL = 0xFFFF0002,
95419b0af8Sopenharmony_ci	TEEC_ERROR_ACCESS_CONFLICT = 0xFFFF0003,
96419b0af8Sopenharmony_ci	TEEC_ERROR_EXCESS_DATA = 0xFFFF0004,
97419b0af8Sopenharmony_ci	TEEC_ERROR_BAD_FORMAT = 0xFFFF0005,
98419b0af8Sopenharmony_ci	TEEC_ERROR_BAD_PARAMETERS = 0xFFFF0006,
99419b0af8Sopenharmony_ci	TEEC_ERROR_BAD_STATE = 0xFFFF0007,
100419b0af8Sopenharmony_ci	TEEC_ERROR_ITEM_NOT_FOUND = 0xFFFF0008,
101419b0af8Sopenharmony_ci	TEEC_ERROR_NOT_IMPLEMENTED = 0xFFFF0009,
102419b0af8Sopenharmony_ci	TEEC_ERROR_NOT_SUPPORTED = 0xFFFF000A,
103419b0af8Sopenharmony_ci	TEEC_ERROR_NO_DATA = 0xFFFF000B,
104419b0af8Sopenharmony_ci	TEEC_ERROR_OUT_OF_MEMORY = 0xFFFF000C,
105419b0af8Sopenharmony_ci	TEEC_ERROR_BUSY = 0xFFFF000D,
106419b0af8Sopenharmony_ci	TEEC_ERROR_COMMUNICATION = 0xFFFF000E,
107419b0af8Sopenharmony_ci	TEEC_ERROR_SECURITY = 0xFFFF000F,
108419b0af8Sopenharmony_ci	TEEC_ERROR_SHORT_BUFFER = 0xFFFF0010,
109419b0af8Sopenharmony_ci	TEEC_PENDING = 0xFFFF2000,
110419b0af8Sopenharmony_ci	TEEC_PENDING2 = 0xFFFF2001,
111419b0af8Sopenharmony_ci	TEE_ERROR_TAGET_DEAD = 0xFFFF3024,
112419b0af8Sopenharmony_ci	TEE_ERROR_GT_DEAD = 0xFFFF3124,
113419b0af8Sopenharmony_ci	TEEC_ERROR_MAC_INVALID = 0xFFFF3071,
114419b0af8Sopenharmony_ci	TEEC_CLIENT_INTR = 0xFFFF4000,
115419b0af8Sopenharmony_ci	TEEC_ERROR_TUI_IN_USE = 0xFFFF7110,
116419b0af8Sopenharmony_ci	TEEC_ERROR_TUI_SWITCH_CHANNAL,
117419b0af8Sopenharmony_ci	TEEC_ERROR_TUI_CFG_DRIVER,
118419b0af8Sopenharmony_ci	TEEC_ERROR_TUI_INVALID_EVENT,
119419b0af8Sopenharmony_ci	TEEC_ERROR_TUI_POLL_EVENT,
120419b0af8Sopenharmony_ci	TEEC_ERROR_TUI_CANCELED,
121419b0af8Sopenharmony_ci	TEEC_ERROR_TUI_EXIT,
122419b0af8Sopenharmony_ci	TEEC_ERROR_TUI_NOT_AVAILABLE,
123419b0af8Sopenharmony_ci	TEEC_ERROR_SEC_FLASH_NOT_AVAILABLE,
124419b0af8Sopenharmony_ci	TEEC_ERROR_CA_AUTH_FAIL = 0xFFFFCFE5,
125419b0af8Sopenharmony_ci	TEE_ERROR_AUDIT_FAIL = 0xFFFF9112,
126419b0af8Sopenharmony_ci	TEE_ERROR_IS_DEAD = 0xFFFFABAB,
127419b0af8Sopenharmony_ci};
128419b0af8Sopenharmony_ci
129419b0af8Sopenharmony_cienum TEEC_ReturnCodeOrigin {
130419b0af8Sopenharmony_ci	TEEC_ORIGIN_API = 0x1,
131419b0af8Sopenharmony_ci	TEEC_ORIGIN_COMMS = 0x2,
132419b0af8Sopenharmony_ci	TEEC_ORIGIN_TEE = 0x3,
133419b0af8Sopenharmony_ci	TEEC_ORIGIN_TRUSTED_APP = 0x4,
134419b0af8Sopenharmony_ci};
135419b0af8Sopenharmony_ci
136419b0af8Sopenharmony_cienum TEEC_SharedMemCtl {
137419b0af8Sopenharmony_ci	TEEC_MEM_INPUT = 0x1,
138419b0af8Sopenharmony_ci	TEEC_MEM_OUTPUT = 0x2,
139419b0af8Sopenharmony_ci	TEEC_MEM_INOUT = 0x3,
140419b0af8Sopenharmony_ci};
141419b0af8Sopenharmony_ci
142419b0af8Sopenharmony_cienum TEEC_ParamType {
143419b0af8Sopenharmony_ci	TEEC_NONE = 0x0,
144419b0af8Sopenharmony_ci	TEEC_VALUE_INPUT = 0x01,
145419b0af8Sopenharmony_ci	TEEC_VALUE_OUTPUT = 0x02,
146419b0af8Sopenharmony_ci	TEEC_VALUE_INOUT = 0x03,
147419b0af8Sopenharmony_ci	TEEC_MEMREF_TEMP_INPUT = 0x05,
148419b0af8Sopenharmony_ci	TEEC_MEMREF_TEMP_OUTPUT = 0x06,
149419b0af8Sopenharmony_ci	TEEC_MEMREF_TEMP_INOUT = 0x07,
150419b0af8Sopenharmony_ci	TEEC_ION_INPUT = 0x08,
151419b0af8Sopenharmony_ci	TEEC_ION_SGLIST_INPUT = 0x09,
152419b0af8Sopenharmony_ci	TEEC_MEMREF_SHARED_INOUT = 0x0a,
153419b0af8Sopenharmony_ci	TEEC_MEMREF_WHOLE = 0xc,
154419b0af8Sopenharmony_ci	TEEC_MEMREF_PARTIAL_INPUT = 0xd,
155419b0af8Sopenharmony_ci	TEEC_MEMREF_PARTIAL_OUTPUT = 0xe,
156419b0af8Sopenharmony_ci	TEEC_MEMREF_PARTIAL_INOUT = 0xf
157419b0af8Sopenharmony_ci};
158419b0af8Sopenharmony_ci
159419b0af8Sopenharmony_cienum TEE_ParamType {
160419b0af8Sopenharmony_ci	TEE_PARAM_TYPE_NONE = 0x0,
161419b0af8Sopenharmony_ci	TEE_PARAM_TYPE_VALUE_INPUT = 0x1,
162419b0af8Sopenharmony_ci	TEE_PARAM_TYPE_VALUE_OUTPUT = 0x2,
163419b0af8Sopenharmony_ci	TEE_PARAM_TYPE_VALUE_INOUT = 0x3,
164419b0af8Sopenharmony_ci	TEE_PARAM_TYPE_MEMREF_INPUT = 0x5,
165419b0af8Sopenharmony_ci	TEE_PARAM_TYPE_MEMREF_OUTPUT = 0x6,
166419b0af8Sopenharmony_ci	TEE_PARAM_TYPE_MEMREF_INOUT = 0x7,
167419b0af8Sopenharmony_ci	TEE_PARAM_TYPE_ION_INPUT = 0x8,
168419b0af8Sopenharmony_ci	TEE_PARAM_TYPE_ION_SGLIST_INPUT = 0x9,
169419b0af8Sopenharmony_ci	TEE_PARAM_TYPE_MEMREF_SHARED_INOUT = 0x0a,
170419b0af8Sopenharmony_ci	TEE_PARAM_TYPE_RESMEM_INPUT = 0xc,
171419b0af8Sopenharmony_ci	TEE_PARAM_TYPE_RESMEM_OUTPUT = 0xd,
172419b0af8Sopenharmony_ci	TEE_PARAM_TYPE_RESMEM_INOUT = 0xe
173419b0af8Sopenharmony_ci};
174419b0af8Sopenharmony_ci
175419b0af8Sopenharmony_cienum TEEC_LoginMethod {
176419b0af8Sopenharmony_ci	TEEC_LOGIN_PUBLIC = 0x0,
177419b0af8Sopenharmony_ci	TEEC_LOGIN_USER,
178419b0af8Sopenharmony_ci	TEEC_LOGIN_GROUP,
179419b0af8Sopenharmony_ci	TEEC_LOGIN_APPLICATION = 0x4,
180419b0af8Sopenharmony_ci	TEEC_LOGIN_USER_APPLICATION = 0x5,
181419b0af8Sopenharmony_ci	TEEC_LOGIN_GROUP_APPLICATION = 0x6,
182419b0af8Sopenharmony_ci	TEEC_LOGIN_IDENTIFY = 0x7,
183419b0af8Sopenharmony_ci	TEEK_LOGIN_IDENTIFY = 0x80000001,
184419b0af8Sopenharmony_ci};
185419b0af8Sopenharmony_ci
186419b0af8Sopenharmony_ci/* Add event id's name in 'view_state[]' in same order */
187419b0af8Sopenharmony_cienum tee_event_id {
188419b0af8Sopenharmony_ci	INVOKE_CMD_START,
189419b0af8Sopenharmony_ci	INVOKE_CMD_END,
190419b0af8Sopenharmony_ci	SMC_SEND,
191419b0af8Sopenharmony_ci	SMC_DONE,
192419b0af8Sopenharmony_ci	SMC_IN,
193419b0af8Sopenharmony_ci	SMC_OUT,
194419b0af8Sopenharmony_ci	SMC_SLEEP,
195419b0af8Sopenharmony_ci	SMC_PREEMPT,
196419b0af8Sopenharmony_ci	GTASK_GET_CMD,
197419b0af8Sopenharmony_ci	GTASK_PUT_CMD,
198419b0af8Sopenharmony_ci	GTASK_REQ_TA,
199419b0af8Sopenharmony_ci	GTASK_RESP_TA,
200419b0af8Sopenharmony_ci	SPI_WAKEUP,
201419b0af8Sopenharmony_ci	SCHED_IN,
202419b0af8Sopenharmony_ci	SCHED_OUT,
203419b0af8Sopenharmony_ci	INTERRUPT_HANDLE_SPI_START,
204419b0af8Sopenharmony_ci	INTERRUPT_HANDLE_SPI_REE_RESPONSE,
205419b0af8Sopenharmony_ci	INTERRUPT_HANDLE_SPI_REE_MISS,
206419b0af8Sopenharmony_ci	INTERRUPT_HANDLE_SPI_REE_SCHEDULED,
207419b0af8Sopenharmony_ci	INTERRUPT_HANDLE_SPI_END,
208419b0af8Sopenharmony_ci	INTERRUPT_HANDLE_START,
209419b0af8Sopenharmony_ci	INTERRUPT_HANDLE_END,
210419b0af8Sopenharmony_ci	TEE_EVENT_MAX
211419b0af8Sopenharmony_ci};
212419b0af8Sopenharmony_ci
213419b0af8Sopenharmony_ci#define TZ_WQ_MAX_ACTIVE 1
214419b0af8Sopenharmony_ci#endif
215