qseecom.h 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. #ifndef __QSEECOM_H_
  2. #define __QSEECOM_H_
  3. #include <linux/types.h>
  4. #include <linux/ioctl.h>
  5. #define MAX_ION_FD 4
  6. #define MAX_APP_NAME_SIZE 32
  7. #define QSEECOM_HASH_SIZE 32
  8. /*
  9. * struct qseecom_register_listener_req -
  10. * for register listener ioctl request
  11. * @listener_id - service id (shared between userspace and QSE)
  12. * @ifd_data_fd - ion handle
  13. * @virt_sb_base - shared buffer base in user space
  14. * @sb_size - shared buffer size
  15. */
  16. struct qseecom_register_listener_req {
  17. uint32_t listener_id; /* in */
  18. int32_t ifd_data_fd; /* in */
  19. uint32_t virt_sb_base; /* in */
  20. uint32_t sb_size; /* in */
  21. };
  22. /*
  23. * struct qseecom_send_cmd_req - for send command ioctl request
  24. * @cmd_req_len - command buffer length
  25. * @cmd_req_buf - command buffer
  26. * @resp_len - response buffer length
  27. * @resp_buf - response buffer
  28. */
  29. struct qseecom_send_cmd_req {
  30. void *cmd_req_buf; /* in */
  31. unsigned int cmd_req_len; /* in */
  32. void *resp_buf; /* in/out */
  33. unsigned int resp_len; /* in/out */
  34. };
  35. /*
  36. * struct qseecom_ion_fd_info - ion fd handle data information
  37. * @fd - ion handle to some memory allocated in user space
  38. * @cmd_buf_offset - command buffer offset
  39. */
  40. struct qseecom_ion_fd_info {
  41. int32_t fd;
  42. uint32_t cmd_buf_offset;
  43. };
  44. /*
  45. * struct qseecom_send_modfd_cmd_req - for send command ioctl request
  46. * @cmd_req_len - command buffer length
  47. * @cmd_req_buf - command buffer
  48. * @resp_len - response buffer length
  49. * @resp_buf - response buffer
  50. * @ifd_data_fd - ion handle to memory allocated in user space
  51. * @cmd_buf_offset - command buffer offset
  52. */
  53. struct qseecom_send_modfd_cmd_req {
  54. void *cmd_req_buf; /* in */
  55. unsigned int cmd_req_len; /* in */
  56. void *resp_buf; /* in/out */
  57. unsigned int resp_len; /* in/out */
  58. struct qseecom_ion_fd_info ifd_data[MAX_ION_FD];
  59. };
  60. /*
  61. * struct qseecom_listener_send_resp_req - signal to continue the send_cmd req.
  62. * Used as a trigger from HLOS service to notify QSEECOM that it's done with its
  63. * operation and provide the response for QSEECOM can continue the incomplete
  64. * command execution
  65. * @resp_len - Length of the response
  66. * @resp_buf - Response buffer where the response of the cmd should go.
  67. */
  68. struct qseecom_send_resp_req {
  69. void *resp_buf; /* in */
  70. unsigned int resp_len; /* in */
  71. };
  72. /*
  73. * struct qseecom_load_img_data - for sending image length information and
  74. * ion file descriptor to the qseecom driver. ion file descriptor is used
  75. * for retrieving the ion file handle and in turn the physical address of
  76. * the image location.
  77. * @mdt_len - Length of the .mdt file in bytes.
  78. * @img_len - Length of the .mdt + .b00 +..+.bxx images files in bytes
  79. * @ion_fd - Ion file descriptor used when allocating memory.
  80. * @img_name - Name of the image.
  81. */
  82. struct qseecom_load_img_req {
  83. uint32_t mdt_len; /* in */
  84. uint32_t img_len; /* in */
  85. int32_t ifd_data_fd; /* in */
  86. char img_name[MAX_APP_NAME_SIZE]; /* in */
  87. int app_id; /* out*/
  88. };
  89. struct qseecom_set_sb_mem_param_req {
  90. int32_t ifd_data_fd; /* in */
  91. uint32_t virt_sb_base; /* in */
  92. uint32_t sb_len; /* in */
  93. };
  94. /*
  95. * struct qseecom_qseos_version_req - get qseos version
  96. * @qseos_version - version number
  97. */
  98. struct qseecom_qseos_version_req {
  99. unsigned int qseos_version; /* in */
  100. };
  101. /*
  102. * struct qseecom_qseos_app_load_query - verify if app is loaded in qsee
  103. * @app_name[MAX_APP_NAME_SIZE]- name of the app.
  104. * @app_id - app id.
  105. */
  106. struct qseecom_qseos_app_load_query {
  107. char app_name[MAX_APP_NAME_SIZE]; /* in */
  108. int app_id; /* out */
  109. };
  110. struct qseecom_send_svc_cmd_req {
  111. uint32_t cmd_id;
  112. void *cmd_req_buf; /* in */
  113. unsigned int cmd_req_len; /* in */
  114. void *resp_buf; /* in/out */
  115. unsigned int resp_len; /* in/out */
  116. };
  117. enum qseecom_key_management_usage_type {
  118. QSEOS_KM_USAGE_DISK_ENCRYPTION = 0x01,
  119. QSEOS_KM_USAGE_FILE_ENCRYPTION = 0x02,
  120. QSEOS_KM_USAGE_MAX
  121. };
  122. struct qseecom_create_key_req {
  123. unsigned char hash32[QSEECOM_HASH_SIZE];
  124. enum qseecom_key_management_usage_type usage;
  125. };
  126. struct qseecom_wipe_key_req {
  127. enum qseecom_key_management_usage_type usage;
  128. int wipe_key_flag;/* 1->remove key from storage(alone with clear key) */
  129. /* 0->do not remove from storage (clear key) */
  130. };
  131. struct qseecom_update_key_userinfo_req {
  132. unsigned char current_hash32[QSEECOM_HASH_SIZE];
  133. unsigned char new_hash32[QSEECOM_HASH_SIZE];
  134. enum qseecom_key_management_usage_type usage;
  135. };
  136. #define SHA256_DIGEST_LENGTH (256/8)
  137. /*
  138. * struct qseecom_save_partition_hash_req
  139. * @partition_id - partition id.
  140. * @hash[SHA256_DIGEST_LENGTH] - sha256 digest.
  141. */
  142. struct qseecom_save_partition_hash_req {
  143. int partition_id; /* in */
  144. char digest[SHA256_DIGEST_LENGTH]; /* in */
  145. };
  146. /*
  147. * struct qseecom_is_es_activated_req
  148. * @is_activated - 1=true , 0=false
  149. */
  150. struct qseecom_is_es_activated_req {
  151. int is_activated; /* out */
  152. };
  153. enum qseecom_bandwidth_request_mode {
  154. INACTIVE = 0,
  155. LOW,
  156. MEDIUM,
  157. HIGH,
  158. };
  159. /*
  160. * struct qseecom_send_modfd_resp - for send command ioctl request
  161. * @req_len - command buffer length
  162. * @req_buf - command buffer
  163. * @ifd_data_fd - ion handle to memory allocated in user space
  164. * @cmd_buf_offset - command buffer offset
  165. */
  166. struct qseecom_send_modfd_listener_resp {
  167. void *resp_buf_ptr; /* in */
  168. unsigned int resp_len; /* in */
  169. struct qseecom_ion_fd_info ifd_data[MAX_ION_FD]; /* in */
  170. };
  171. #define QSEECOM_IOC_MAGIC 0x97
  172. #define QSEECOM_IOCTL_REGISTER_LISTENER_REQ \
  173. _IOWR(QSEECOM_IOC_MAGIC, 1, struct qseecom_register_listener_req)
  174. #define QSEECOM_IOCTL_UNREGISTER_LISTENER_REQ \
  175. _IO(QSEECOM_IOC_MAGIC, 2)
  176. #define QSEECOM_IOCTL_SEND_CMD_REQ \
  177. _IOWR(QSEECOM_IOC_MAGIC, 3, struct qseecom_send_cmd_req)
  178. #define QSEECOM_IOCTL_SEND_MODFD_CMD_REQ \
  179. _IOWR(QSEECOM_IOC_MAGIC, 4, struct qseecom_send_modfd_cmd_req)
  180. #define QSEECOM_IOCTL_RECEIVE_REQ \
  181. _IO(QSEECOM_IOC_MAGIC, 5)
  182. #define QSEECOM_IOCTL_SEND_RESP_REQ \
  183. _IO(QSEECOM_IOC_MAGIC, 6)
  184. #define QSEECOM_IOCTL_LOAD_APP_REQ \
  185. _IOWR(QSEECOM_IOC_MAGIC, 7, struct qseecom_load_img_req)
  186. #define QSEECOM_IOCTL_SET_MEM_PARAM_REQ \
  187. _IOWR(QSEECOM_IOC_MAGIC, 8, struct qseecom_set_sb_mem_param_req)
  188. #define QSEECOM_IOCTL_UNLOAD_APP_REQ \
  189. _IO(QSEECOM_IOC_MAGIC, 9)
  190. #define QSEECOM_IOCTL_GET_QSEOS_VERSION_REQ \
  191. _IOWR(QSEECOM_IOC_MAGIC, 10, struct qseecom_qseos_version_req)
  192. #define QSEECOM_IOCTL_PERF_ENABLE_REQ \
  193. _IO(QSEECOM_IOC_MAGIC, 11)
  194. #define QSEECOM_IOCTL_PERF_DISABLE_REQ \
  195. _IO(QSEECOM_IOC_MAGIC, 12)
  196. #define QSEECOM_IOCTL_LOAD_EXTERNAL_ELF_REQ \
  197. _IOWR(QSEECOM_IOC_MAGIC, 13, struct qseecom_load_img_req)
  198. #define QSEECOM_IOCTL_UNLOAD_EXTERNAL_ELF_REQ \
  199. _IO(QSEECOM_IOC_MAGIC, 14)
  200. #define QSEECOM_IOCTL_APP_LOADED_QUERY_REQ \
  201. _IOWR(QSEECOM_IOC_MAGIC, 15, struct qseecom_qseos_app_load_query)
  202. #define QSEECOM_IOCTL_SEND_CMD_SERVICE_REQ \
  203. _IOWR(QSEECOM_IOC_MAGIC, 16, struct qseecom_send_svc_cmd_req)
  204. #define QSEECOM_IOCTL_CREATE_KEY_REQ \
  205. _IOWR(QSEECOM_IOC_MAGIC, 17, struct qseecom_create_key_req)
  206. #define QSEECOM_IOCTL_WIPE_KEY_REQ \
  207. _IOWR(QSEECOM_IOC_MAGIC, 18, struct qseecom_wipe_key_req)
  208. #define QSEECOM_IOCTL_SAVE_PARTITION_HASH_REQ \
  209. _IOWR(QSEECOM_IOC_MAGIC, 19, struct qseecom_save_partition_hash_req)
  210. #define QSEECOM_IOCTL_IS_ES_ACTIVATED_REQ \
  211. _IOWR(QSEECOM_IOC_MAGIC, 20, struct qseecom_is_es_activated_req)
  212. #define QSEECOM_IOCTL_SEND_MODFD_RESP \
  213. _IOWR(QSEECOM_IOC_MAGIC, 21, struct qseecom_send_modfd_listener_resp)
  214. #define QSEECOM_IOCTL_SET_BUS_SCALING_REQ \
  215. _IOWR(QSEECOM_IOC_MAGIC, 23, int)
  216. #define QSEECOM_IOCTL_UPDATE_KEY_USER_INFO_REQ \
  217. _IOWR(QSEECOM_IOC_MAGIC, 24, struct qseecom_update_key_userinfo_req)
  218. #endif /* __QSEECOM_H_ */