tstee_private.h 2.5 KB

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