• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2022 Huawei Technologies Co., Ltd.
3  * Licensed under the Mulan PSL v2.
4  * You can use this software according to the terms and conditions of the Mulan PSL v2.
5  * You may obtain a copy of Mulan PSL v2 at:
6  *     http://license.coscl.org.cn/MulanPSL2
7  * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
8  * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
9  * PURPOSE.
10  * See the Mulan PSL v2 for more details.
11  */
12 
13 #ifndef TEED_TEE_H
14 #define TEED_TEE_H
15 
16 /*
17  * SMC function IDs that TEE uses to signal various forms of completions
18  * to the secure payload dispatcher.
19  */
20 #define TEE_ENTRY_DONE            0xf2000000
21 #define TEE_ON_DONE               0xf2000001
22 #define TEE_OFF_DONE              0xf2000002
23 #define TEE_SUSPEND_DONE          0xf2000003
24 #define TEE_RESUME_DONE           0xf2000004
25 #define TEE_PREEMPTED             0xf2000005
26 #define TEE_ABORT_DONE            0xf2000007
27 #define TEE_SYSTEM_OFF_DONE       0xf2000008
28 #define TEE_SYSTEM_RESET_DONE     0xf2000009
29 
30 /*
31  * Function identifiers to handle S-EL1 interrupt through the synchronous
32  * handling model. If the TEE was previously interrupted then control has to
33  * be returned to the TEED after handling the interrupt else execution can
34  * remain in the TEE.
35  */
36 #define TEE_HANDLED_S_EL1_INTR    0xf2000006
37 
38 /* SMC function ID that TEE uses to request service from secure monitor */
39 #define TEE_GET_ARGS              0xf2001000
40 
41 /*
42  * Identifiers for various TEE services. Corresponding function IDs (whether
43  * fast or yielding) are generated by macros defined below
44  */
45 #define TEE_ADD                              0x2000
46 #define TEE_SUB                              0x2001
47 #define TEE_MUL                              0x2002
48 #define TEE_DIV                              0x2003
49 #define TEE_HANDLE_SEL1_INTR_AND_RETURN      0x2004
50 
51 /*
52  * Identify a TEE service from function ID filtering the last 16 bits from the
53  * SMC function ID
54  */
55 #define TEE_BARE_FID(fid)  ((fid) & 0xffffu)
56 
57 /*
58  * Generate function IDs for TEE services to be used in SMC calls, by
59  * appropriately setting bit 31 to differentiate yielding and fast SMC calls
60  */
61 #define TEE_YIELD_FID(fid) ((TEE_BARE_FID(fid) | 0x72000000u))
62 #define TEE_FAST_FID(fid)  ((TEE_BARE_FID(fid) | 0x72000000u) | (1u << 31))
63 
64 /* SMC function ID to request a previously preempted yielding smc */
65 #define TEE_FID_RESUME     TEE_YIELD_FID(0x3000u)
66 /*
67  * SMC function ID to request abortion of a previously preempted yielding SMC. A
68  * fast SMC is used so that the TEE abort handler does not have to be
69  * reentrant.
70  */
71 #define TEE_FID_ABORT       TEE_FAST_FID(0x3001u)
72 
73 /*
74  * Total number of function IDs implemented for services offered to NS clients.
75  * The function IDs are defined above
76  */
77 #define TEE_NUM_FID         0x5
78 
79 /* TEE implementation version numbers */
80 #define TEE_VERSION_MAJOR   0x0 /* Major version */
81 #define TEE_VERSION_MINOR   0x1 /* Minor version */
82 
83 #endif /* TEE_H */
84