cmdq_sec.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. #ifndef __CMDQ_SEC_H__
  2. #define __CMDQ_SEC_H__
  3. #include "cmdq_core.h"
  4. #if defined(CMDQ_SECURE_PATH_SUPPORT)
  5. #include "mobicore_driver_api.h"
  6. #include "cmdq_sec_iwc_common.h"
  7. #endif
  8. /**
  9. * error code for CMDQ
  10. */
  11. #define CMDQ_ERR_NULL_SEC_CTX_HANDLE (6000)
  12. #define CMDQ_ERR_SEC_CTX_SETUP (6001)
  13. #define CMDQ_ERR_SEC_CTX_TEARDOWN (6002)
  14. /**
  15. * inter-world communication state
  16. */
  17. typedef enum {
  18. IWC_INIT = 0,
  19. IWC_MOBICORE_OPENED = 1,
  20. IWC_WSM_ALLOCATED = 2,
  21. IWC_SES_OPENED = 3,
  22. IWC_SES_MSG_PACKAGED = 4,
  23. IWC_SES_TRANSACTED = 5,
  24. IWC_SES_ON_TRANSACTED = 6,
  25. IWC_END_OF_ENUM = 7,
  26. } CMDQ_IWC_STATE_ENUM;
  27. /**
  28. * CMDQ secure context struct
  29. * note it is not global data, each process has its own CMDQ sec context
  30. */
  31. typedef struct cmdqSecContextStruct {
  32. struct list_head listEntry;
  33. /* basic info */
  34. uint32_t tgid; /* tgid of process context */
  35. uint32_t referCount; /* reference count for open cmdq device node */
  36. /* iwc state */
  37. CMDQ_IWC_STATE_ENUM state;
  38. /* iwc information */
  39. void *iwcMessage; /* message buffer */
  40. #if defined(CMDQ_SECURE_PATH_SUPPORT)
  41. struct mc_uuid_t uuid; /* Universally Unique Identifier of secure tl/dr */
  42. struct mc_session_handle sessionHandle; /* session handle */
  43. #endif
  44. uint32_t openMobicoreByOther; /* true if someone has opened mobicore device in this prpocess context */
  45. } cmdqSecContextStruct, *cmdqSecContextHandle;
  46. int32_t cmdq_sec_init_allocate_resource_thread(void *data);
  47. /**
  48. * Create and destroy non-cachable shared memory,
  49. * used to share data for CMDQ driver between NWd and SWd
  50. *
  51. * Be careful that we should not disvlose any information about secure buffer address of
  52. */
  53. int32_t cmdq_sec_create_shared_memory(cmdqSecSharedMemoryHandle *pHandle, const uint32_t size);
  54. int32_t cmdq_sec_destroy_shared_memory(cmdqSecSharedMemoryHandle handle);
  55. /**
  56. * Callback to fill message buffer for secure task
  57. *
  58. * Params:
  59. * init32_t command id
  60. * void* pornter of TaskStruct
  61. * int32_t CMDQ HW thread id
  62. * void* the inter-world communication buffer
  63. * Return:
  64. * >=0 for success;
  65. */
  66. typedef int32_t(*CmdqSecFillIwcCB) (int32_t, void *, int32_t, void *);
  67. /**
  68. * Entry secure world to handle secure path jobs
  69. * .submit task
  70. * .cancel error task
  71. */
  72. int32_t cmdq_sec_exec_task_async_unlocked(TaskStruct *pTask, int32_t thread);
  73. int32_t cmdq_sec_cancel_error_task_unlocked(TaskStruct *pTask, int32_t thread,
  74. cmdqSecCancelTaskResultStruct *pResult);
  75. int32_t cmdq_sec_allocate_path_resource_unlocked(bool throwAEE);
  76. /**
  77. * secure path control
  78. */
  79. void cmdq_sec_lock_secure_path(void);
  80. void cmdq_sec_unlock_secure_path(void);
  81. void cmdqSecInitialize(void);
  82. void cmdqSecDeInitialize(void);
  83. void cmdqSecEnableProfile(const bool enable);
  84. /* function declaretion */
  85. cmdqSecContextHandle cmdq_sec_context_handle_create(uint32_t tgid);
  86. #endif /* __DDP_CMDQ_SEC_H__ */