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