1 /*
2  * Copyright (c) 2013-2016 Google Inc. All rights reserved
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining
5  * a copy of this software and associated documentation files
6  * (the "Software"), to deal in the Software without restriction,
7  * including without limitation the rights to use, copy, modify, merge,
8  * publish, distribute, sublicense, and/or sell copies of the Software,
9  * and to permit persons to whom the Software is furnished to do so,
10  * subject to the following conditions:
11  *
12  * The above copyright notice and this permission notice shall be
13  * included in all copies or substantial portions of the Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
19  * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
20  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
21  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22  */
23 #ifndef __LIB_SM_SMCALL_H
24 #define __LIB_SM_SMCALL_H
25 
26 #include <interface/smc/smc_def.h>
27 
28 #define SMC_NUM_ARGS 4
29 #define SMC_NUM_PARAMS (SMC_NUM_ARGS - 1)
30 
31 /* FC = Fast call, SC = Standard call */
32 #define SMC_SC_RESTART_LAST SMC_STDCALL_NR(SMC_ENTITY_SECURE_MONITOR, 0)
33 #define SMC_SC_LOCKED_NOP SMC_STDCALL_NR(SMC_ENTITY_SECURE_MONITOR, 1)
34 
35 /**
36  * SMC_SC_RESTART_FIQ - Re-enter trusty after it was interrupted by an fiq
37  *
38  * No arguments, no return value.
39  *
40  * Re-enter trusty after returning to ns to process an fiq. Must be called iff
41  * trusty returns SM_ERR_FIQ_INTERRUPTED.
42  *
43  * Enable by selecting api version TRUSTY_API_VERSION_RESTART_FIQ (1) or later.
44  */
45 #define SMC_SC_RESTART_FIQ SMC_STDCALL_NR(SMC_ENTITY_SECURE_MONITOR, 2)
46 
47 /**
48  * SMC_SC_NOP - Enter trusty to run pending work.
49  *
50  * No arguments.
51  *
52  * Returns SM_ERR_NOP_INTERRUPTED or SM_ERR_NOP_DONE.
53  * If SM_ERR_NOP_INTERRUPTED is returned, the call must be repeated.
54  *
55  * Enable by selecting api version TRUSTY_API_VERSION_SMP (2) or later.
56  */
57 #define SMC_SC_NOP SMC_STDCALL_NR(SMC_ENTITY_SECURE_MONITOR, 3)
58 
59 /**
60  * SMC API for supporting shared-memory based trusty-linux info exchange
61  *
62  * SMC_SC_SCHED_SHARE_REGISTER - enter trusty to establish a shared-memory
63  * region
64  * Arguments:
65  * param[0]: shared-memory client-id
66  * param[1]: shared-memory buffer-id
67  * param[2]: shared-memory block size
68  *
69  * returns:
70  * SM_ERR_INTERNAL_FAILURE on failure.
71  * 0 on success.
72  */
73 #define SMC_SC_SCHED_SHARE_REGISTER SMC_STDCALL_NR(SMC_ENTITY_SECURE_MONITOR, 4)
74 
75 /**
76  * SMC API for supporting shared-memory based trusty-linux info exchange
77  *
78  * SMC_SC_SCHED_SHARE_UNREGISTER - enter trusty to release the shared-memory
79  * region
80  * Arguments:
81  * param[0]: shared-memory client-id
82  * param[1]: shared-memory buffer-id
83  *
84  * returns:
85  * SM_ERR_INTERNAL_FAILURE on failure.
86  * 0 on success.
87  */
88 #define SMC_SC_SCHED_SHARE_UNREGISTER \
89     SMC_STDCALL_NR(SMC_ENTITY_SECURE_MONITOR, 5)
90 
91 /*
92  * Return from secure os to non-secure os with return value in r1
93  */
94 #define SMC_SC_NS_RETURN SMC_STDCALL_NR(SMC_ENTITY_SECURE_MONITOR, 0)
95 
96 #define SMC_FC_RESERVED SMC_FASTCALL_NR(SMC_ENTITY_SECURE_MONITOR, 0)
97 #define SMC_FC_FIQ_EXIT SMC_FASTCALL_NR(SMC_ENTITY_SECURE_MONITOR, 1)
98 #define SMC_FC_REQUEST_FIQ SMC_FASTCALL_NR(SMC_ENTITY_SECURE_MONITOR, 2)
99 
100 #define TRUSTY_IRQ_TYPE_NORMAL (0)
101 #define TRUSTY_IRQ_TYPE_PER_CPU (1)
102 #define TRUSTY_IRQ_TYPE_DOORBELL (2)
103 #define SMC_FC_GET_NEXT_IRQ SMC_FASTCALL_NR(SMC_ENTITY_SECURE_MONITOR, 3)
104 
105 #define SMC_FC_FIQ_ENTER SMC_FASTCALL_NR(SMC_ENTITY_SECURE_MONITOR, 4)
106 
107 #define SMC_FC64_SET_FIQ_HANDLER SMC_FASTCALL64_NR(SMC_ENTITY_SECURE_MONITOR, 5)
108 #define SMC_FC64_GET_FIQ_REGS SMC_FASTCALL64_NR(SMC_ENTITY_SECURE_MONITOR, 6)
109 
110 #define SMC_FC_CPU_SUSPEND SMC_FASTCALL_NR(SMC_ENTITY_SECURE_MONITOR, 7)
111 #define SMC_FC_CPU_RESUME SMC_FASTCALL_NR(SMC_ENTITY_SECURE_MONITOR, 8)
112 
113 #define SMC_FC_AARCH_SWITCH SMC_FASTCALL_NR(SMC_ENTITY_SECURE_MONITOR, 9)
114 #define SMC_FC_GET_VERSION_STR SMC_FASTCALL_NR(SMC_ENTITY_SECURE_MONITOR, 10)
115 
116 /**
117  * SMC_FC_API_VERSION - Find and select supported API version.
118  *
119  * @r1: Version supported by client.
120  *
121  * Returns version supported by trusty.
122  *
123  * If multiple versions are supported, the client should start by calling
124  * SMC_FC_API_VERSION with the largest version it supports. Trusty will then
125  * return a version it supports. If the client does not support the version
126  * returned by trusty and the version returned is less than the version
127  * requested, repeat the call with the largest supported version less than the
128  * last returned version.
129  *
130  * This call must be made before any calls that are affected by the api version.
131  */
132 #define TRUSTY_API_VERSION_RESTART_FIQ (1)
133 #define TRUSTY_API_VERSION_SMP (2)
134 #define TRUSTY_API_VERSION_SMP_NOP (3)
135 #define TRUSTY_API_VERSION_PHYS_MEM_OBJ (4)
136 #define TRUSTY_API_VERSION_MEM_OBJ (5)
137 #define TRUSTY_API_VERSION_CURRENT (5)
138 #define SMC_FC_API_VERSION SMC_FASTCALL_NR(SMC_ENTITY_SECURE_MONITOR, 11)
139 
140 #define SMC_FC_FIQ_RESUME SMC_FASTCALL_NR(SMC_ENTITY_SECURE_MONITOR, 12)
141 
142 /**
143  * SMC_FC_GET_SMP_MAX_CPUS - Find max number of cpus supported by Trusty.
144  *
145  * This call must be made before booting secondary cpus as Trusty
146  * may support less number of cpus and crash if execution switches to them
147  */
148 #define SMC_FC_GET_SMP_MAX_CPUS SMC_FASTCALL_NR(SMC_ENTITY_SECURE_MONITOR, 13)
149 
150 /* TRUSTED_OS entity calls */
151 #define SMC_SC_VIRTIO_GET_DESCR SMC_STDCALL_NR(SMC_ENTITY_TRUSTED_OS, 20)
152 #define SMC_SC_VIRTIO_START SMC_STDCALL_NR(SMC_ENTITY_TRUSTED_OS, 21)
153 #define SMC_SC_VIRTIO_STOP SMC_STDCALL_NR(SMC_ENTITY_TRUSTED_OS, 22)
154 
155 #define SMC_SC_VDEV_RESET SMC_STDCALL_NR(SMC_ENTITY_TRUSTED_OS, 23)
156 #define SMC_SC_VDEV_KICK_VQ SMC_STDCALL_NR(SMC_ENTITY_TRUSTED_OS, 24)
157 #define SMC_NC_VDEV_KICK_VQ SMC_STDCALL_NR(SMC_ENTITY_TRUSTED_OS, 25)
158 
159 /* Simplified (Queueless) IPC interface */
160 #define SMC_SC_CREATE_QL_TIPC_DEV SMC_STDCALL_NR(SMC_ENTITY_TRUSTED_OS, 30)
161 #define SMC_SC_SHUTDOWN_QL_TIPC_DEV SMC_STDCALL_NR(SMC_ENTITY_TRUSTED_OS, 31)
162 #define SMC_SC_HANDLE_QL_TIPC_DEV_CMD SMC_STDCALL_NR(SMC_ENTITY_TRUSTED_OS, 32)
163 #define SMC_FC_HANDLE_QL_TIPC_DEV_CMD SMC_FASTCALL_NR(SMC_ENTITY_TRUSTED_OS, 32)
164 
165 #endif /* __LIB_SM_SMCALL_H */
166