1 /* SPDX-License-Identifier: BSD-2-Clause */
2 /*
3  * Copyright (c) 2014, Linaro Limited
4  */
5 
6 #ifndef TEESMC_OPTEED_H
7 #define TEESMC_OPTEED_H
8 
9 /*
10  * This file specify SMC function IDs used when returning from TEE to the
11  * secure monitor.
12  *
13  * All SMC Function IDs indicates SMC32 Calling Convention but will carry
14  * full 64 bit values in the argument registers if invoked from Aarch64
15  * mode. This violates the SMC Calling Convention, but since this
16  * convention only coveres API towards Normwal World it's something that
17  * only concerns the OP-TEE Dispatcher in ARM Trusted Firmware and OP-TEE
18  * OS at Secure EL1.
19  */
20 
21 /*
22  * Issued when returning from initial entry.
23  *
24  * Register usage:
25  * r0/x0	SMC Function ID, TEESMC_OPTEED_RETURN_ENTRY_DONE
26  * r1/x1	Pointer to entry vector
27  */
28 #define TEESMC_OPTEED_FUNCID_RETURN_ENTRY_DONE		0
29 #define TEESMC_OPTEED_RETURN_ENTRY_DONE \
30 	TEESMC_OPTEED_RV(TEESMC_OPTEED_FUNCID_RETURN_ENTRY_DONE)
31 
32 
33 
34 /*
35  * Issued when returning from "cpu_on" vector
36  *
37  * Register usage:
38  * r0/x0	SMC Function ID, TEESMC_OPTEED_RETURN_ON_DONE
39  * r1/x1	0 on success and anything else to indicate error condition
40  */
41 #define TEESMC_OPTEED_FUNCID_RETURN_ON_DONE		1
42 #define TEESMC_OPTEED_RETURN_ON_DONE \
43 	TEESMC_OPTEED_RV(TEESMC_OPTEED_FUNCID_RETURN_ON_DONE)
44 
45 /*
46  * Issued when returning from "cpu_off" vector
47  *
48  * Register usage:
49  * r0/x0	SMC Function ID, TEESMC_OPTEED_RETURN_OFF_DONE
50  * r1/x1	0 on success and anything else to indicate error condition
51  */
52 #define TEESMC_OPTEED_FUNCID_RETURN_OFF_DONE		2
53 #define TEESMC_OPTEED_RETURN_OFF_DONE \
54 	TEESMC_OPTEED_RV(TEESMC_OPTEED_FUNCID_RETURN_OFF_DONE)
55 
56 /*
57  * Issued when returning from "cpu_suspend" vector
58  *
59  * Register usage:
60  * r0/x0	SMC Function ID, TEESMC_OPTEED_RETURN_SUSPEND_DONE
61  * r1/x1	0 on success and anything else to indicate error condition
62  */
63 #define TEESMC_OPTEED_FUNCID_RETURN_SUSPEND_DONE	3
64 #define TEESMC_OPTEED_RETURN_SUSPEND_DONE \
65 	TEESMC_OPTEED_RV(TEESMC_OPTEED_FUNCID_RETURN_SUSPEND_DONE)
66 
67 /*
68  * Issued when returning from "cpu_resume" vector
69  *
70  * Register usage:
71  * r0/x0	SMC Function ID, TEESMC_OPTEED_RETURN_RESUME_DONE
72  * r1/x1	0 on success and anything else to indicate error condition
73  */
74 #define TEESMC_OPTEED_FUNCID_RETURN_RESUME_DONE		4
75 #define TEESMC_OPTEED_RETURN_RESUME_DONE \
76 	TEESMC_OPTEED_RV(TEESMC_OPTEED_FUNCID_RETURN_RESUME_DONE)
77 
78 /*
79  * Issued when returning from "std_smc" or "fast_smc" vector
80  *
81  * Register usage:
82  * r0/x0	SMC Function ID, TEESMC_OPTEED_RETURN_CALL_DONE
83  * r1-4/x1-4	Return value 0-3 which will passed to normal world in
84  *		r0-3/x0-3
85  */
86 #define TEESMC_OPTEED_FUNCID_RETURN_CALL_DONE		5
87 #define TEESMC_OPTEED_RETURN_CALL_DONE \
88 	TEESMC_OPTEED_RV(TEESMC_OPTEED_FUNCID_RETURN_CALL_DONE)
89 
90 /*
91  * Issued when returning from "fiq" vector
92  *
93  * Register usage:
94  * r0/x0	SMC Function ID, TEESMC_OPTEED_RETURN_FIQ_DONE
95  */
96 #define TEESMC_OPTEED_FUNCID_RETURN_FIQ_DONE		6
97 #define TEESMC_OPTEED_RETURN_FIQ_DONE \
98 	TEESMC_OPTEED_RV(TEESMC_OPTEED_FUNCID_RETURN_FIQ_DONE)
99 
100 /*
101  * Issued when returning from "system_off" vector
102  *
103  * Register usage:
104  * r0/x0	SMC Function ID, TEESMC_OPTEED_RETURN_SYSTEM_OFF_DONE
105  */
106 #define TEESMC_OPTEED_FUNCID_RETURN_SYSTEM_OFF_DONE	7
107 #define TEESMC_OPTEED_RETURN_SYSTEM_OFF_DONE \
108 	TEESMC_OPTEED_RV(TEESMC_OPTEED_FUNCID_RETURN_SYSTEM_OFF_DONE)
109 
110 /*
111  * Issued when returning from "system_reset" vector
112  *
113  * Register usage:
114  * r0/x0	SMC Function ID, TEESMC_OPTEED_RETURN_SYSTEM_RESET_DONE
115  */
116 #define TEESMC_OPTEED_FUNCID_RETURN_SYSTEM_RESET_DONE	8
117 #define TEESMC_OPTEED_RETURN_SYSTEM_RESET_DONE \
118 	TEESMC_OPTEED_RV(TEESMC_OPTEED_FUNCID_RETURN_SYSTEM_RESET_DONE)
119 
120 #endif /*TEESMC_OPTEED_H*/
121