blob: eae3ed2aecdbe592873217b5b4a7fc57256188db [file] [log] [blame]
Jens Wiklanderc2888862014-08-04 15:39:58 +02001/*
Jeffrey Kardatzke7e6b09a2022-10-03 15:50:21 -07002 * Copyright (c) 2014-2023, ARM Limited and Contributors. All rights reserved.
Jens Wiklanderc2888862014-08-04 15:39:58 +02003 *
dp-armfa3cf0b2017-05-03 09:38:09 +01004 * SPDX-License-Identifier: BSD-3-Clause
Jens Wiklanderc2888862014-08-04 15:39:58 +02005 */
6
7/* Copyright (c) 2014, Linaro Limited. All rights reserved. */
8
9#ifndef TEESMC_OPTEED_H
10#define TEESMC_OPTEED_H
11
Jeffrey Kardatzke7e6b09a2022-10-03 15:50:21 -070012#include "teesmc_opteed_macros.h"
13
Jens Wiklanderc2888862014-08-04 15:39:58 +020014/*
Jeffrey Kardatzke7e6b09a2022-10-03 15:50:21 -070015 * This section specifies SMC function IDs used when returning from TEE to the
Jens Wiklanderc2888862014-08-04 15:39:58 +020016 * secure monitor.
17 *
18 * All SMC Function IDs indicates SMC32 Calling Convention but will carry
19 * full 64 bit values in the argument registers if invoked from Aarch64
20 * mode. This violates the SMC Calling Convention, but since this
Paul Beesley1fbc97b2019-01-11 18:26:51 +000021 * convention only coveres API towards Normal World it's something that
John Tsichritzis63801cd2019-07-05 14:22:12 +010022 * only concerns the OP-TEE Dispatcher in Trusted Firmware-A and OP-TEE
Jens Wiklanderc2888862014-08-04 15:39:58 +020023 * OS at Secure EL1.
24 */
25
26/*
27 * Issued when returning from initial entry.
28 *
29 * Register usage:
30 * r0/x0 SMC Function ID, TEESMC_OPTEED_RETURN_ENTRY_DONE
31 * r1/x1 Pointer to entry vector
32 */
33#define TEESMC_OPTEED_FUNCID_RETURN_ENTRY_DONE 0
34#define TEESMC_OPTEED_RETURN_ENTRY_DONE \
35 TEESMC_OPTEED_RV(TEESMC_OPTEED_FUNCID_RETURN_ENTRY_DONE)
36
37
38
39/*
40 * Issued when returning from "cpu_on" vector
41 *
42 * Register usage:
43 * r0/x0 SMC Function ID, TEESMC_OPTEED_RETURN_ON_DONE
44 * r1/x1 0 on success and anything else to indicate error condition
45 */
46#define TEESMC_OPTEED_FUNCID_RETURN_ON_DONE 1
47#define TEESMC_OPTEED_RETURN_ON_DONE \
48 TEESMC_OPTEED_RV(TEESMC_OPTEED_FUNCID_RETURN_ON_DONE)
49
50/*
51 * Issued when returning from "cpu_off" vector
52 *
53 * Register usage:
54 * r0/x0 SMC Function ID, TEESMC_OPTEED_RETURN_OFF_DONE
55 * r1/x1 0 on success and anything else to indicate error condition
56 */
57#define TEESMC_OPTEED_FUNCID_RETURN_OFF_DONE 2
58#define TEESMC_OPTEED_RETURN_OFF_DONE \
59 TEESMC_OPTEED_RV(TEESMC_OPTEED_FUNCID_RETURN_OFF_DONE)
60
61/*
62 * Issued when returning from "cpu_suspend" vector
63 *
64 * Register usage:
65 * r0/x0 SMC Function ID, TEESMC_OPTEED_RETURN_SUSPEND_DONE
66 * r1/x1 0 on success and anything else to indicate error condition
67 */
68#define TEESMC_OPTEED_FUNCID_RETURN_SUSPEND_DONE 3
69#define TEESMC_OPTEED_RETURN_SUSPEND_DONE \
70 TEESMC_OPTEED_RV(TEESMC_OPTEED_FUNCID_RETURN_SUSPEND_DONE)
71
72/*
73 * Issued when returning from "cpu_resume" vector
74 *
75 * Register usage:
76 * r0/x0 SMC Function ID, TEESMC_OPTEED_RETURN_RESUME_DONE
77 * r1/x1 0 on success and anything else to indicate error condition
78 */
79#define TEESMC_OPTEED_FUNCID_RETURN_RESUME_DONE 4
80#define TEESMC_OPTEED_RETURN_RESUME_DONE \
81 TEESMC_OPTEED_RV(TEESMC_OPTEED_FUNCID_RETURN_RESUME_DONE)
82
83/*
84 * Issued when returning from "std_smc" or "fast_smc" vector
85 *
86 * Register usage:
87 * r0/x0 SMC Function ID, TEESMC_OPTEED_RETURN_CALL_DONE
88 * r1-4/x1-4 Return value 0-3 which will passed to normal world in
89 * r0-3/x0-3
90 */
91#define TEESMC_OPTEED_FUNCID_RETURN_CALL_DONE 5
92#define TEESMC_OPTEED_RETURN_CALL_DONE \
93 TEESMC_OPTEED_RV(TEESMC_OPTEED_FUNCID_RETURN_CALL_DONE)
94
95/*
96 * Issued when returning from "fiq" vector
97 *
98 * Register usage:
99 * r0/x0 SMC Function ID, TEESMC_OPTEED_RETURN_FIQ_DONE
100 */
101#define TEESMC_OPTEED_FUNCID_RETURN_FIQ_DONE 6
102#define TEESMC_OPTEED_RETURN_FIQ_DONE \
103 TEESMC_OPTEED_RV(TEESMC_OPTEED_FUNCID_RETURN_FIQ_DONE)
104
105/*
106 * Issued when returning from "system_off" vector
107 *
108 * Register usage:
109 * r0/x0 SMC Function ID, TEESMC_OPTEED_RETURN_SYSTEM_OFF_DONE
110 */
111#define TEESMC_OPTEED_FUNCID_RETURN_SYSTEM_OFF_DONE 7
112#define TEESMC_OPTEED_RETURN_SYSTEM_OFF_DONE \
113 TEESMC_OPTEED_RV(TEESMC_OPTEED_FUNCID_RETURN_SYSTEM_OFF_DONE)
114
115/*
116 * Issued when returning from "system_reset" vector
117 *
118 * Register usage:
119 * r0/x0 SMC Function ID, TEESMC_OPTEED_RETURN_SYSTEM_RESET_DONE
120 */
121#define TEESMC_OPTEED_FUNCID_RETURN_SYSTEM_RESET_DONE 8
122#define TEESMC_OPTEED_RETURN_SYSTEM_RESET_DONE \
123 TEESMC_OPTEED_RV(TEESMC_OPTEED_FUNCID_RETURN_SYSTEM_RESET_DONE)
124
Jeffrey Kardatzke7e6b09a2022-10-03 15:50:21 -0700125/*
126 * This section specifies SMC function IDs used when the secure monitor is
127 * invoked from the non-secure world.
128 */
129
130/*
131 * Load OP-TEE image from the payload specified in the registers.
132 *
133 * WARNING: Use this cautiously as it could lead to insecure loading of the
134 * Trusted OS. Further details are in opteed.mk.
135 *
136 * Call register usage:
137 * x0 SMC Function ID, OPTEE_SMC_CALL_LOAD_IMAGE
138 * x1 Upper 32bit of a 64bit size for the payload
139 * x2 Lower 32bit of a 64bit size for the payload
140 * x3 Upper 32bit of the physical address for the payload
141 * x4 Lower 32bit of the physical address for the payload
142 *
143 * The payload consists of a optee_header struct that contains optee_image
144 * structs in a flex array, immediately following that in memory is the data
145 * referenced by the optee_image structs.
146 * Example:
147 *
148 * struct optee_header (with n images specified)
149 * image 0 data
150 * image 1 data
151 * ...
152 * image n-1 data
153 *
154 * Returns 0 on success and an error code otherwise.
155 */
156#define NSSMC_OPTEED_FUNCID_LOAD_IMAGE 2
157#define NSSMC_OPTEED_CALL_LOAD_IMAGE \
158 NSSMC_OPTEED_CALL(NSSMC_OPTEED_FUNCID_LOAD_IMAGE)
159
Jens Wiklanderc2888862014-08-04 15:39:58 +0200160#endif /*TEESMC_OPTEED_H*/