brintos

brintos / linux-shallow public Read only

0
0
Text · 6.1 KiB · 257735a Raw
186 lines · c
1/* SPDX-License-Identifier: BSD-2-Clause */2/*3 * Copyright (c) 2019-2021, 2023 Linaro Limited4 */5 6/*7 * This file is exported by OP-TEE and is kept in sync between secure world8 * and normal world drivers. We're using ARM FF-A 1.0 specification.9 */10 11#ifndef __OPTEE_FFA_H12#define __OPTEE_FFA_H13 14#include <linux/arm_ffa.h>15 16/*17 * Normal world sends requests with FFA_MSG_SEND_DIRECT_REQ and18 * responses are returned with FFA_MSG_SEND_DIRECT_RESP for normal19 * messages.20 *21 * All requests with FFA_MSG_SEND_DIRECT_REQ and FFA_MSG_SEND_DIRECT_RESP22 * are using the AArch32 SMC calling convention with register usage as23 * defined in FF-A specification:24 * w0:    Function ID (0x8400006F or 0x84000070)25 * w1:    Source/Destination IDs26 * w2:    Reserved (MBZ)27 * w3-w7: Implementation defined, free to be used below28 */29 30#define OPTEE_FFA_VERSION_MAJOR	131#define OPTEE_FFA_VERSION_MINOR	032 33#define OPTEE_FFA_BLOCKING_CALL(id)	(id)34#define OPTEE_FFA_YIELDING_CALL_BIT	3135#define OPTEE_FFA_YIELDING_CALL(id)	((id) | BIT(OPTEE_FFA_YIELDING_CALL_BIT))36 37/*38 * Returns the API version implemented, currently follows the FF-A version.39 * Call register usage:40 * w3:    Service ID, OPTEE_FFA_GET_API_VERSION41 * w4-w7: Not used (MBZ)42 *43 * Return register usage:44 * w3:    OPTEE_FFA_VERSION_MAJOR45 * w4:    OPTEE_FFA_VERSION_MINOR46 * w5-w7: Not used (MBZ)47 */48#define OPTEE_FFA_GET_API_VERSION	OPTEE_FFA_BLOCKING_CALL(0)49 50/*51 * Returns the revision of OP-TEE.52 *53 * Used by non-secure world to figure out which version of the Trusted OS54 * is installed. Note that the returned revision is the revision of the55 * Trusted OS, not of the API.56 *57 * Call register usage:58 * w3:    Service ID, OPTEE_FFA_GET_OS_VERSION59 * w4-w7: Unused (MBZ)60 *61 * Return register usage:62 * w3:    CFG_OPTEE_REVISION_MAJOR63 * w4:    CFG_OPTEE_REVISION_MINOR64 * w5:    TEE_IMPL_GIT_SHA1 (or zero if not supported)65 */66#define OPTEE_FFA_GET_OS_VERSION	OPTEE_FFA_BLOCKING_CALL(1)67 68/*69 * Exchange capabilities between normal world and secure world.70 *71 * Currently there are no defined capabilities. When features are added new72 * capabilities may be added.73 *74 * Call register usage:75 * w3:    Service ID, OPTEE_FFA_EXCHANGE_CAPABILITIES76 * w4-w7: Not used (MBZ)77 *78 * Return register usage:79 * w3:    Error code, 0 on success80 * w4:    Bit[7:0]:  Number of parameters needed for RPC to be supplied81 *                   as the second MSG arg struct for82 *                   OPTEE_FFA_YIELDING_CALL_WITH_ARG.83 *        Bit[31:8]: Reserved (MBZ)84 * w5:	  Bitfield of secure world capabilities OPTEE_FFA_SEC_CAP_* below,85 * w6:	  The maximum secure world notification number86 * w7:	  Not used (MBZ)87 */88/*89 * Secure world supports giving an offset into the argument shared memory90 * object, see also OPTEE_FFA_YIELDING_CALL_WITH_ARG91 */92#define OPTEE_FFA_SEC_CAP_ARG_OFFSET	BIT(0)93/* OP-TEE supports asynchronous notification via FF-A */94#define OPTEE_FFA_SEC_CAP_ASYNC_NOTIF	BIT(1)95/* OP-TEE supports probing for RPMB device if needed */96#define OPTEE_FFA_SEC_CAP_RPMB_PROBE	BIT(2)97 98#define OPTEE_FFA_EXCHANGE_CAPABILITIES OPTEE_FFA_BLOCKING_CALL(2)99 100/*101 * Unregister shared memory102 *103 * Call register usage:104 * w3:    Service ID, OPTEE_FFA_YIELDING_CALL_UNREGISTER_SHM105 * w4:    Shared memory handle, lower bits106 * w5:    Shared memory handle, higher bits107 * w6-w7: Not used (MBZ)108 *109 * Return register usage:110 * w3:    Error code, 0 on success111 * w4-w7: Note used (MBZ)112 */113#define OPTEE_FFA_UNREGISTER_SHM	OPTEE_FFA_BLOCKING_CALL(3)114 115/*116 * Inform OP-TEE that the normal world is able to receive asynchronous117 * notifications.118 *119 * Call register usage:120 * w3:    Service ID, OPTEE_FFA_ENABLE_ASYNC_NOTIF121 * w4:	  Notification value to request bottom half processing, should be122 *	  less than OPTEE_FFA_MAX_ASYNC_NOTIF_VALUE.123 * w5-w7: Not used (MBZ)124 *125 * Return register usage:126 * w3:    Error code, 0 on success127 * w4-w7: Note used (MBZ)128 */129#define OPTEE_FFA_ENABLE_ASYNC_NOTIF	OPTEE_FFA_BLOCKING_CALL(5)130 131#define OPTEE_FFA_MAX_ASYNC_NOTIF_VALUE 64132 133/*134 * Call with struct optee_msg_arg as argument in the supplied shared memory135 * with a zero internal offset and normal cached memory attributes.136 * Register usage:137 * w3:    Service ID, OPTEE_FFA_YIELDING_CALL_WITH_ARG138 * w4:    Lower 32 bits of a 64-bit Shared memory handle139 * w5:    Upper 32 bits of a 64-bit Shared memory handle140 * w6:    Offset into shared memory pointing to a struct optee_msg_arg141 *	  right after the parameters of this struct (at offset142 *	  OPTEE_MSG_GET_ARG_SIZE(num_params) follows a struct optee_msg_arg143 *	  for RPC, this struct has reserved space for the number of RPC144 *	  parameters as returned by OPTEE_FFA_EXCHANGE_CAPABILITIES.145 *	  MBZ unless the bit OPTEE_FFA_SEC_CAP_ARG_OFFSET is received with146 *	  OPTEE_FFA_EXCHANGE_CAPABILITIES.147 * w7:    Not used (MBZ)148 * Resume from RPC. Register usage:149 * w3:    Service ID, OPTEE_FFA_YIELDING_CALL_RESUME150 * w4-w6: Not used (MBZ)151 * w7:    Resume info152 *153 * Normal return (yielding call is completed). Register usage:154 * w3:    Error code, 0 on success155 * w4:    OPTEE_FFA_YIELDING_CALL_RETURN_DONE156 * w5-w7: Not used (MBZ)157 *158 * RPC interrupt return (RPC from secure world). Register usage:159 * w3:    Error code == 0160 * w4:    Any defined RPC code but OPTEE_FFA_YIELDING_CALL_RETURN_DONE161 * w5-w6: Not used (MBZ)162 * w7:    Resume info163 *164 * Possible error codes in register w3:165 * 0:                       Success166 * FFA_DENIED:              w4 isn't one of OPTEE_FFA_YIELDING_CALL_START167 *                          OPTEE_FFA_YIELDING_CALL_RESUME168 *169 * Possible error codes for OPTEE_FFA_YIELDING_CALL_START,170 * FFA_BUSY:               Number of OP-TEE OS threads exceeded,171 *                         try again later172 * FFA_DENIED:             RPC shared memory object not found173 * FFA_INVALID_PARAMETER:  Bad shared memory handle or offset into the memory174 *175 * Possible error codes for OPTEE_FFA_YIELDING_CALL_RESUME176 * FFA_INVALID_PARAMETER:  Bad resume info177 */178#define OPTEE_FFA_YIELDING_CALL_WITH_ARG	OPTEE_FFA_YIELDING_CALL(0)179#define OPTEE_FFA_YIELDING_CALL_RESUME		OPTEE_FFA_YIELDING_CALL(1)180 181#define OPTEE_FFA_YIELDING_CALL_RETURN_DONE		0182#define OPTEE_FFA_YIELDING_CALL_RETURN_RPC_CMD		1183#define OPTEE_FFA_YIELDING_CALL_RETURN_INTERRUPT	2184 185#endif /*__OPTEE_FFA_H*/186