1 #ifndef _QSEECOM_H_ 2 #define _QSEECOM_H_ 3 4 #include <linux/types.h> 5 #include <linux/ioctl.h> 6 7 #define MAX_ION_FD 4 8 #define MAX_APP_NAME_SIZE 64 9 #define QSEECOM_HASH_SIZE 32 10 /* 11 * struct qseecom_register_listener_req - 12 * for register listener ioctl request 13 * @listener_id - service id (shared between userspace and QSE) 14 * @ifd_data_fd - ion handle 15 * @virt_sb_base - shared buffer base in user space 16 * @sb_size - shared buffer size 17 */ 18 struct qseecom_register_listener_req { 19 uint32_t listener_id; /* in */ 20 int32_t ifd_data_fd; /* in */ 21 void *virt_sb_base; /* in */ 22 uint32_t sb_size; /* in */ 23 }; 24 25 /* 26 * struct qseecom_send_cmd_req - for send command ioctl request 27 * @cmd_req_len - command buffer length 28 * @cmd_req_buf - command buffer 29 * @resp_len - response buffer length 30 * @resp_buf - response buffer 31 */ 32 struct qseecom_send_cmd_req { 33 void *cmd_req_buf; /* in */ 34 unsigned int cmd_req_len; /* in */ 35 void *resp_buf; /* in/out */ 36 unsigned int resp_len; /* in/out */ 37 }; 38 39 /* 40 * struct qseecom_ion_fd_info - ion fd handle data information 41 * @fd - ion handle to some memory allocated in user space 42 * @cmd_buf_offset - command buffer offset 43 */ 44 struct qseecom_ion_fd_info { 45 int32_t fd; 46 uint32_t cmd_buf_offset; 47 }; 48 /* 49 * struct qseecom_send_modfd_cmd_req - for send command ioctl request 50 * @cmd_req_len - command buffer length 51 * @cmd_req_buf - command buffer 52 * @resp_len - response buffer length 53 * @resp_buf - response buffer 54 * @ifd_data_fd - ion handle to memory allocated in user space 55 * @cmd_buf_offset - command buffer offset 56 */ 57 struct qseecom_send_modfd_cmd_req { 58 void *cmd_req_buf; /* in */ 59 unsigned int cmd_req_len; /* in */ 60 void *resp_buf; /* in/out */ 61 unsigned int resp_len; /* in/out */ 62 struct qseecom_ion_fd_info ifd_data[MAX_ION_FD]; 63 }; 64 65 /* 66 * struct qseecom_listener_send_resp_req - signal to continue the send_cmd req. 67 * Used as a trigger from HLOS service to notify QSEECOM that it's done with its 68 * operation and provide the response for QSEECOM can continue the incomplete 69 * command execution 70 * @resp_len - Length of the response 71 * @resp_buf - Response buffer where the response of the cmd should go. 72 */ 73 struct qseecom_send_resp_req { 74 void *resp_buf; /* in */ 75 unsigned int resp_len; /* in */ 76 }; 77 78 /* 79 * struct qseecom_load_img_data - for sending image length information and 80 * ion file descriptor to the qseecom driver. ion file descriptor is used 81 * for retrieving the ion file handle and in turn the physical address of 82 * the image location. 83 * @mdt_len - Length of the .mdt file in bytes. 84 * @img_len - Length of the .mdt + .b00 +..+.bxx images files in bytes 85 * @ion_fd - Ion file descriptor used when allocating memory. 86 * @img_name - Name of the image. 87 * @app_arch - Architecture of the image, i.e. 32bit or 64bit app 88 */ 89 struct qseecom_load_img_req { 90 uint32_t mdt_len; /* in */ 91 uint32_t img_len; /* in */ 92 int32_t ifd_data_fd; /* in */ 93 char img_name[MAX_APP_NAME_SIZE]; /* in */ 94 uint32_t app_arch; /* in */ 95 uint32_t app_id; /* out*/ 96 }; 97 98 struct qseecom_set_sb_mem_param_req { 99 int32_t ifd_data_fd; /* in */ 100 void *virt_sb_base; /* in */ 101 uint32_t sb_len; /* in */ 102 }; 103 104 /* 105 * struct qseecom_qseos_version_req - get qseos version 106 * @qseos_version - version number 107 */ 108 struct qseecom_qseos_version_req { 109 unsigned int qseos_version; /* in */ 110 }; 111 112 /* 113 * struct qseecom_qseos_app_load_query - verify if app is loaded in qsee 114 * @app_name[MAX_APP_NAME_SIZE]- name of the app. 115 * @app_id - app id. 116 */ 117 struct qseecom_qseos_app_load_query { 118 char app_name[MAX_APP_NAME_SIZE]; /* in */ 119 uint32_t app_id; /* out */ 120 uint32_t app_arch; 121 }; 122 123 struct qseecom_send_svc_cmd_req { 124 uint32_t cmd_id; 125 void *cmd_req_buf; /* in */ 126 unsigned int cmd_req_len; /* in */ 127 void *resp_buf; /* in/out */ 128 unsigned int resp_len; /* in/out */ 129 }; 130 131 enum qseecom_key_management_usage_type { 132 QSEOS_KM_USAGE_DISK_ENCRYPTION = 0x01, 133 QSEOS_KM_USAGE_FILE_ENCRYPTION = 0x02, 134 QSEOS_KM_USAGE_UFS_ICE_DISK_ENCRYPTION = 0x03, 135 QSEOS_KM_USAGE_SDCC_ICE_DISK_ENCRYPTION = 0x04, 136 QSEOS_KM_USAGE_MAX 137 }; 138 139 struct qseecom_create_key_req { 140 unsigned char hash32[QSEECOM_HASH_SIZE]; 141 enum qseecom_key_management_usage_type usage; 142 }; 143 144 struct qseecom_wipe_key_req { 145 enum qseecom_key_management_usage_type usage; 146 int wipe_key_flag;/* 1->remove key from storage(alone with clear key) */ 147 /* 0->do not remove from storage (clear key) */ 148 }; 149 150 struct qseecom_update_key_userinfo_req { 151 unsigned char current_hash32[QSEECOM_HASH_SIZE]; 152 unsigned char new_hash32[QSEECOM_HASH_SIZE]; 153 enum qseecom_key_management_usage_type usage; 154 }; 155 156 #define SHA256_DIGEST_LENGTH (256/8) 157 /* 158 * struct qseecom_save_partition_hash_req 159 * @partition_id - partition id. 160 * @hash[SHA256_DIGEST_LENGTH] - sha256 digest. 161 */ 162 struct qseecom_save_partition_hash_req { 163 int partition_id; /* in */ 164 char digest[SHA256_DIGEST_LENGTH]; /* in */ 165 }; 166 167 /* 168 * struct qseecom_is_es_activated_req 169 * @is_activated - 1=true , 0=false 170 */ 171 struct qseecom_is_es_activated_req { 172 int is_activated; /* out */ 173 }; 174 175 /* 176 * struct qseecom_mdtp_cipher_dip_req 177 * @in_buf - input buffer 178 * @in_buf_size - input buffer size 179 * @out_buf - output buffer 180 * @out_buf_size - output buffer size 181 * @direction - 0=encrypt, 1=decrypt 182 */ 183 struct qseecom_mdtp_cipher_dip_req { 184 uint8_t *in_buf; 185 uint32_t in_buf_size; 186 uint8_t *out_buf; 187 uint32_t out_buf_size; 188 uint32_t direction; 189 }; 190 191 enum qseecom_bandwidth_request_mode { 192 INACTIVE = 0, 193 LOW, 194 MEDIUM, 195 HIGH, 196 }; 197 198 /* 199 * struct qseecom_send_modfd_resp - for send command ioctl request 200 * @req_len - command buffer length 201 * @req_buf - command buffer 202 * @ifd_data_fd - ion handle to memory allocated in user space 203 * @cmd_buf_offset - command buffer offset 204 */ 205 struct qseecom_send_modfd_listener_resp { 206 void *resp_buf_ptr; /* in */ 207 unsigned int resp_len; /* in */ 208 struct qseecom_ion_fd_info ifd_data[MAX_ION_FD]; /* in */ 209 }; 210 211 struct qseecom_qteec_req { 212 void *req_ptr; 213 uint32_t req_len; 214 void *resp_ptr; 215 uint32_t resp_len; 216 }; 217 218 struct qseecom_qteec_modfd_req { 219 void *req_ptr; 220 uint32_t req_len; 221 void *resp_ptr; 222 uint32_t resp_len; 223 struct qseecom_ion_fd_info ifd_data[MAX_ION_FD]; 224 }; 225 226 struct qseecom_sg_entry { 227 uint32_t phys_addr; 228 uint32_t len; 229 }; 230 231 struct qseecom_sg_entry_64bit { 232 uint64_t phys_addr; 233 uint32_t len; 234 } __attribute__ ((packed)); 235 236 /* 237 * sg list buf format version 238 * 1: Legacy format to support only 512 SG list entries 239 * 2: new format to support > 512 entries 240 */ 241 #define QSEECOM_SG_LIST_BUF_FORMAT_VERSION_1 1 242 #define QSEECOM_SG_LIST_BUF_FORMAT_VERSION_2 2 243 244 struct qseecom_sg_list_buf_hdr_64bit { 245 struct qseecom_sg_entry_64bit blank_entry; /* must be all 0 */ 246 uint32_t version; /* sg list buf format version */ 247 uint64_t new_buf_phys_addr; /* PA of new buffer */ 248 uint32_t nents_total; /* Total number of SG entries */ 249 } __attribute__ ((packed)); 250 251 #define QSEECOM_SG_LIST_BUF_HDR_SZ_64BIT \ 252 sizeof(struct qseecom_sg_list_buf_hdr_64bit) 253 254 #define MAX_CE_PIPE_PAIR_PER_UNIT 3 255 #define INVALID_CE_INFO_UNIT_NUM 0xffffffff 256 257 #define CE_PIPE_PAIR_USE_TYPE_FDE 0 258 #define CE_PIPE_PAIR_USE_TYPE_PFE 1 259 260 struct qseecom_ce_pipe_entry { 261 int valid; 262 unsigned int ce_num; 263 unsigned int ce_pipe_pair; 264 }; 265 266 #define MAX_CE_INFO_HANDLE_SIZE 32 267 struct qseecom_ce_info_req { 268 unsigned char handle[MAX_CE_INFO_HANDLE_SIZE]; 269 unsigned int usage; 270 unsigned int unit_num; 271 unsigned int num_ce_pipe_entries; 272 struct qseecom_ce_pipe_entry ce_pipe_entry[MAX_CE_PIPE_PAIR_PER_UNIT]; 273 }; 274 275 #define SG_ENTRY_SZ sizeof(struct qseecom_sg_entry) 276 #define SG_ENTRY_SZ_64BIT sizeof(struct qseecom_sg_entry_64bit) 277 278 struct file; 279 280 extern long qseecom_ioctl(struct file *file, 281 unsigned cmd, unsigned long arg); 282 283 #define QSEECOM_IOC_MAGIC 0x97 284 285 286 #define QSEECOM_IOCTL_REGISTER_LISTENER_REQ \ 287 _IOWR(QSEECOM_IOC_MAGIC, 1, struct qseecom_register_listener_req) 288 289 #define QSEECOM_IOCTL_UNREGISTER_LISTENER_REQ \ 290 _IO(QSEECOM_IOC_MAGIC, 2) 291 292 #define QSEECOM_IOCTL_SEND_CMD_REQ \ 293 _IOWR(QSEECOM_IOC_MAGIC, 3, struct qseecom_send_cmd_req) 294 295 #define QSEECOM_IOCTL_SEND_MODFD_CMD_REQ \ 296 _IOWR(QSEECOM_IOC_MAGIC, 4, struct qseecom_send_modfd_cmd_req) 297 298 #define QSEECOM_IOCTL_RECEIVE_REQ \ 299 _IO(QSEECOM_IOC_MAGIC, 5) 300 301 #define QSEECOM_IOCTL_SEND_RESP_REQ \ 302 _IO(QSEECOM_IOC_MAGIC, 6) 303 304 #define QSEECOM_IOCTL_LOAD_APP_REQ \ 305 _IOWR(QSEECOM_IOC_MAGIC, 7, struct qseecom_load_img_req) 306 307 #define QSEECOM_IOCTL_SET_MEM_PARAM_REQ \ 308 _IOWR(QSEECOM_IOC_MAGIC, 8, struct qseecom_set_sb_mem_param_req) 309 310 #define QSEECOM_IOCTL_UNLOAD_APP_REQ \ 311 _IO(QSEECOM_IOC_MAGIC, 9) 312 313 #define QSEECOM_IOCTL_GET_QSEOS_VERSION_REQ \ 314 _IOWR(QSEECOM_IOC_MAGIC, 10, struct qseecom_qseos_version_req) 315 316 #define QSEECOM_IOCTL_PERF_ENABLE_REQ \ 317 _IO(QSEECOM_IOC_MAGIC, 11) 318 319 #define QSEECOM_IOCTL_PERF_DISABLE_REQ \ 320 _IO(QSEECOM_IOC_MAGIC, 12) 321 322 #define QSEECOM_IOCTL_LOAD_EXTERNAL_ELF_REQ \ 323 _IOWR(QSEECOM_IOC_MAGIC, 13, struct qseecom_load_img_req) 324 325 #define QSEECOM_IOCTL_UNLOAD_EXTERNAL_ELF_REQ \ 326 _IO(QSEECOM_IOC_MAGIC, 14) 327 328 #define QSEECOM_IOCTL_APP_LOADED_QUERY_REQ \ 329 _IOWR(QSEECOM_IOC_MAGIC, 15, struct qseecom_qseos_app_load_query) 330 331 #define QSEECOM_IOCTL_SEND_CMD_SERVICE_REQ \ 332 _IOWR(QSEECOM_IOC_MAGIC, 16, struct qseecom_send_svc_cmd_req) 333 334 #define QSEECOM_IOCTL_CREATE_KEY_REQ \ 335 _IOWR(QSEECOM_IOC_MAGIC, 17, struct qseecom_create_key_req) 336 337 #define QSEECOM_IOCTL_WIPE_KEY_REQ \ 338 _IOWR(QSEECOM_IOC_MAGIC, 18, struct qseecom_wipe_key_req) 339 340 #define QSEECOM_IOCTL_SAVE_PARTITION_HASH_REQ \ 341 _IOWR(QSEECOM_IOC_MAGIC, 19, struct qseecom_save_partition_hash_req) 342 343 #define QSEECOM_IOCTL_IS_ES_ACTIVATED_REQ \ 344 _IOWR(QSEECOM_IOC_MAGIC, 20, struct qseecom_is_es_activated_req) 345 346 #define QSEECOM_IOCTL_SEND_MODFD_RESP \ 347 _IOWR(QSEECOM_IOC_MAGIC, 21, struct qseecom_send_modfd_listener_resp) 348 349 #define QSEECOM_IOCTL_SET_BUS_SCALING_REQ \ 350 _IOWR(QSEECOM_IOC_MAGIC, 23, int) 351 352 #define QSEECOM_IOCTL_UPDATE_KEY_USER_INFO_REQ \ 353 _IOWR(QSEECOM_IOC_MAGIC, 24, struct qseecom_update_key_userinfo_req) 354 355 #define QSEECOM_QTEEC_IOCTL_OPEN_SESSION_REQ \ 356 _IOWR(QSEECOM_IOC_MAGIC, 30, struct qseecom_qteec_modfd_req) 357 358 #define QSEECOM_QTEEC_IOCTL_CLOSE_SESSION_REQ \ 359 _IOWR(QSEECOM_IOC_MAGIC, 31, struct qseecom_qteec_req) 360 361 #define QSEECOM_QTEEC_IOCTL_INVOKE_MODFD_CMD_REQ \ 362 _IOWR(QSEECOM_IOC_MAGIC, 32, struct qseecom_qteec_modfd_req) 363 364 #define QSEECOM_QTEEC_IOCTL_REQUEST_CANCELLATION_REQ \ 365 _IOWR(QSEECOM_IOC_MAGIC, 33, struct qseecom_qteec_modfd_req) 366 367 #define QSEECOM_IOCTL_MDTP_CIPHER_DIP_REQ \ 368 _IOWR(QSEECOM_IOC_MAGIC, 34, struct qseecom_mdtp_cipher_dip_req) 369 370 #define QSEECOM_IOCTL_SEND_MODFD_CMD_64_REQ \ 371 _IOWR(QSEECOM_IOC_MAGIC, 35, struct qseecom_send_modfd_cmd_req) 372 373 #define QSEECOM_IOCTL_SEND_MODFD_RESP_64 \ 374 _IOWR(QSEECOM_IOC_MAGIC, 36, struct qseecom_send_modfd_listener_resp) 375 376 #define QSEECOM_IOCTL_GET_CE_PIPE_INFO \ 377 _IOWR(QSEECOM_IOC_MAGIC, 40, struct qseecom_ce_info_req) 378 379 #define QSEECOM_IOCTL_FREE_CE_PIPE_INFO \ 380 _IOWR(QSEECOM_IOC_MAGIC, 41, struct qseecom_ce_info_req) 381 382 #define QSEECOM_IOCTL_QUERY_CE_PIPE_INFO \ 383 _IOWR(QSEECOM_IOC_MAGIC, 42, struct qseecom_ce_info_req) 384 385 386 #endif /* _QSEECOM_H_ */ 387