1*c835e5a3SBalint Dobszay /* SPDX-License-Identifier: GPL-2.0-only */ 2*c835e5a3SBalint Dobszay /* 3*c835e5a3SBalint Dobszay * Copyright (c) 2023, Arm Limited 4*c835e5a3SBalint Dobszay */ 5*c835e5a3SBalint Dobszay 6*c835e5a3SBalint Dobszay #ifndef TSTEE_PRIVATE_H 7*c835e5a3SBalint Dobszay #define TSTEE_PRIVATE_H 8*c835e5a3SBalint Dobszay 9*c835e5a3SBalint Dobszay #include <linux/arm_ffa.h> 10*c835e5a3SBalint Dobszay #include <linux/bitops.h> 11*c835e5a3SBalint Dobszay #include <linux/tee_core.h> 12*c835e5a3SBalint Dobszay #include <linux/types.h> 13*c835e5a3SBalint Dobszay #include <linux/uuid.h> 14*c835e5a3SBalint Dobszay #include <linux/xarray.h> 15*c835e5a3SBalint Dobszay 16*c835e5a3SBalint Dobszay /* 17*c835e5a3SBalint Dobszay * The description of the ABI implemented in this file is available at 18*c835e5a3SBalint Dobszay * https://trusted-services.readthedocs.io/en/v1.0.0/developer/service-access-protocols.html#abi 19*c835e5a3SBalint Dobszay */ 20*c835e5a3SBalint Dobszay 21*c835e5a3SBalint Dobszay /* UUID of this protocol */ 22*c835e5a3SBalint Dobszay #define TS_RPC_UUID UUID_INIT(0xbdcd76d7, 0x825e, 0x4751, \ 23*c835e5a3SBalint Dobszay 0x96, 0x3b, 0x86, 0xd4, 0xf8, 0x49, 0x43, 0xac) 24*c835e5a3SBalint Dobszay 25*c835e5a3SBalint Dobszay /* Protocol version*/ 26*c835e5a3SBalint Dobszay #define TS_RPC_PROTOCOL_VERSION (1) 27*c835e5a3SBalint Dobszay 28*c835e5a3SBalint Dobszay /* Status codes */ 29*c835e5a3SBalint Dobszay #define TS_RPC_OK (0) 30*c835e5a3SBalint Dobszay 31*c835e5a3SBalint Dobszay /* RPC control register */ 32*c835e5a3SBalint Dobszay #define TS_RPC_CTRL_REG (0) 33*c835e5a3SBalint Dobszay #define OPCODE_MASK GENMASK(15, 0) 34*c835e5a3SBalint Dobszay #define IFACE_ID_MASK GENMASK(23, 16) 35*c835e5a3SBalint Dobszay #define TS_RPC_CTRL_OPCODE(x) ((u16)(FIELD_GET(OPCODE_MASK, (x)))) 36*c835e5a3SBalint Dobszay #define TS_RPC_CTRL_IFACE_ID(x) ((u8)(FIELD_GET(IFACE_ID_MASK, (x)))) 37*c835e5a3SBalint Dobszay #define TS_RPC_CTRL_PACK_IFACE_OPCODE(i, o) \ 38*c835e5a3SBalint Dobszay (FIELD_PREP(IFACE_ID_MASK, (i)) | FIELD_PREP(OPCODE_MASK, (o))) 39*c835e5a3SBalint Dobszay #define TS_RPC_CTRL_SAP_RC BIT(30) 40*c835e5a3SBalint Dobszay #define TS_RPC_CTRL_SAP_ERR BIT(31) 41*c835e5a3SBalint Dobszay 42*c835e5a3SBalint Dobszay /* Interface ID for RPC management operations */ 43*c835e5a3SBalint Dobszay #define TS_RPC_MGMT_IFACE_ID (0xff) 44*c835e5a3SBalint Dobszay 45*c835e5a3SBalint Dobszay /* Management calls */ 46*c835e5a3SBalint Dobszay #define TS_RPC_OP_GET_VERSION (0x0000) 47*c835e5a3SBalint Dobszay #define TS_RPC_GET_VERSION_RESP (1) 48*c835e5a3SBalint Dobszay 49*c835e5a3SBalint Dobszay #define TS_RPC_OP_RETRIEVE_MEM (0x0001) 50*c835e5a3SBalint Dobszay #define TS_RPC_RETRIEVE_MEM_HANDLE_LSW (1) 51*c835e5a3SBalint Dobszay #define TS_RPC_RETRIEVE_MEM_HANDLE_MSW (2) 52*c835e5a3SBalint Dobszay #define TS_RPC_RETRIEVE_MEM_TAG_LSW (3) 53*c835e5a3SBalint Dobszay #define TS_RPC_RETRIEVE_MEM_TAG_MSW (4) 54*c835e5a3SBalint Dobszay #define TS_RPC_RETRIEVE_MEM_RPC_STATUS (1) 55*c835e5a3SBalint Dobszay 56*c835e5a3SBalint Dobszay #define TS_RPC_OP_RELINQ_MEM (0x0002) 57*c835e5a3SBalint Dobszay #define TS_RPC_RELINQ_MEM_HANDLE_LSW (1) 58*c835e5a3SBalint Dobszay #define TS_RPC_RELINQ_MEM_HANDLE_MSW (2) 59*c835e5a3SBalint Dobszay #define TS_RPC_RELINQ_MEM_RPC_STATUS (1) 60*c835e5a3SBalint Dobszay 61*c835e5a3SBalint Dobszay #define TS_RPC_OP_SERVICE_INFO (0x0003) 62*c835e5a3SBalint Dobszay #define TS_RPC_SERVICE_INFO_UUID0 (1) 63*c835e5a3SBalint Dobszay #define TS_RPC_SERVICE_INFO_UUID1 (2) 64*c835e5a3SBalint Dobszay #define TS_RPC_SERVICE_INFO_UUID2 (3) 65*c835e5a3SBalint Dobszay #define TS_RPC_SERVICE_INFO_UUID3 (4) 66*c835e5a3SBalint Dobszay #define TS_RPC_SERVICE_INFO_RPC_STATUS (1) 67*c835e5a3SBalint Dobszay #define TS_RPC_SERVICE_INFO_IFACE (2) 68*c835e5a3SBalint Dobszay 69*c835e5a3SBalint Dobszay /* Service call */ 70*c835e5a3SBalint Dobszay #define TS_RPC_SERVICE_MEM_HANDLE_LSW (1) 71*c835e5a3SBalint Dobszay #define TS_RPC_SERVICE_MEM_HANDLE_MSW (2) 72*c835e5a3SBalint Dobszay #define TS_RPC_SERVICE_REQ_LEN (3) 73*c835e5a3SBalint Dobszay #define TS_RPC_SERVICE_CLIENT_ID (4) 74*c835e5a3SBalint Dobszay #define TS_RPC_SERVICE_RPC_STATUS (1) 75*c835e5a3SBalint Dobszay #define TS_RPC_SERVICE_STATUS (2) 76*c835e5a3SBalint Dobszay #define TS_RPC_SERVICE_RESP_LEN (3) 77*c835e5a3SBalint Dobszay 78*c835e5a3SBalint Dobszay struct tstee { 79*c835e5a3SBalint Dobszay struct ffa_device *ffa_dev; 80*c835e5a3SBalint Dobszay struct tee_device *teedev; 81*c835e5a3SBalint Dobszay struct tee_shm_pool *pool; 82*c835e5a3SBalint Dobszay }; 83*c835e5a3SBalint Dobszay 84*c835e5a3SBalint Dobszay struct ts_session { 85*c835e5a3SBalint Dobszay u8 iface_id; 86*c835e5a3SBalint Dobszay }; 87*c835e5a3SBalint Dobszay 88*c835e5a3SBalint Dobszay struct ts_context_data { 89*c835e5a3SBalint Dobszay struct xarray sess_list; 90*c835e5a3SBalint Dobszay }; 91*c835e5a3SBalint Dobszay 92*c835e5a3SBalint Dobszay #endif /* TSTEE_PRIVATE_H */ 93