blob: 94e9b006f4b6d6ed085e2713bae90f72040bd7c2 [file] [log] [blame]
Zhen Kong0e63d132017-03-07 19:01:55 -08001#ifndef _UAPI_QSEECOM_H_
2#define _UAPI_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 */
18struct 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 */
32struct 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 */
44struct 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 */
57struct 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 */
73struct 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 */
89struct 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
98struct 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 */
108struct 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 */
117struct 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
123struct 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
131enum 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
139struct qseecom_create_key_req {
140 unsigned char hash32[QSEECOM_HASH_SIZE];
141 enum qseecom_key_management_usage_type usage;
142};
143
144struct 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
150struct 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 */
162struct 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 */
171struct 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 */
183struct 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
191enum 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 */
205struct 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
211struct qseecom_qteec_req {
212 void *req_ptr;
213 uint32_t req_len;
214 void *resp_ptr;
215 uint32_t resp_len;
216};
217
218struct 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
226struct qseecom_sg_entry {
227 uint32_t phys_addr;
228 uint32_t len;
229};
230
231struct 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
244struct 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
260struct 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
267struct 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
278struct file;
279
Zhen Kong0e63d132017-03-07 19:01:55 -0800280
281#define QSEECOM_IOC_MAGIC 0x97
282
283
284#define QSEECOM_IOCTL_REGISTER_LISTENER_REQ \
285 _IOWR(QSEECOM_IOC_MAGIC, 1, struct qseecom_register_listener_req)
286
287#define QSEECOM_IOCTL_UNREGISTER_LISTENER_REQ \
288 _IO(QSEECOM_IOC_MAGIC, 2)
289
290#define QSEECOM_IOCTL_SEND_CMD_REQ \
291 _IOWR(QSEECOM_IOC_MAGIC, 3, struct qseecom_send_cmd_req)
292
293#define QSEECOM_IOCTL_SEND_MODFD_CMD_REQ \
294 _IOWR(QSEECOM_IOC_MAGIC, 4, struct qseecom_send_modfd_cmd_req)
295
296#define QSEECOM_IOCTL_RECEIVE_REQ \
297 _IO(QSEECOM_IOC_MAGIC, 5)
298
299#define QSEECOM_IOCTL_SEND_RESP_REQ \
300 _IO(QSEECOM_IOC_MAGIC, 6)
301
302#define QSEECOM_IOCTL_LOAD_APP_REQ \
303 _IOWR(QSEECOM_IOC_MAGIC, 7, struct qseecom_load_img_req)
304
305#define QSEECOM_IOCTL_SET_MEM_PARAM_REQ \
306 _IOWR(QSEECOM_IOC_MAGIC, 8, struct qseecom_set_sb_mem_param_req)
307
308#define QSEECOM_IOCTL_UNLOAD_APP_REQ \
309 _IO(QSEECOM_IOC_MAGIC, 9)
310
311#define QSEECOM_IOCTL_GET_QSEOS_VERSION_REQ \
312 _IOWR(QSEECOM_IOC_MAGIC, 10, struct qseecom_qseos_version_req)
313
314#define QSEECOM_IOCTL_PERF_ENABLE_REQ \
315 _IO(QSEECOM_IOC_MAGIC, 11)
316
317#define QSEECOM_IOCTL_PERF_DISABLE_REQ \
318 _IO(QSEECOM_IOC_MAGIC, 12)
319
320#define QSEECOM_IOCTL_LOAD_EXTERNAL_ELF_REQ \
321 _IOWR(QSEECOM_IOC_MAGIC, 13, struct qseecom_load_img_req)
322
323#define QSEECOM_IOCTL_UNLOAD_EXTERNAL_ELF_REQ \
324 _IO(QSEECOM_IOC_MAGIC, 14)
325
326#define QSEECOM_IOCTL_APP_LOADED_QUERY_REQ \
327 _IOWR(QSEECOM_IOC_MAGIC, 15, struct qseecom_qseos_app_load_query)
328
329#define QSEECOM_IOCTL_SEND_CMD_SERVICE_REQ \
330 _IOWR(QSEECOM_IOC_MAGIC, 16, struct qseecom_send_svc_cmd_req)
331
332#define QSEECOM_IOCTL_CREATE_KEY_REQ \
333 _IOWR(QSEECOM_IOC_MAGIC, 17, struct qseecom_create_key_req)
334
335#define QSEECOM_IOCTL_WIPE_KEY_REQ \
336 _IOWR(QSEECOM_IOC_MAGIC, 18, struct qseecom_wipe_key_req)
337
338#define QSEECOM_IOCTL_SAVE_PARTITION_HASH_REQ \
339 _IOWR(QSEECOM_IOC_MAGIC, 19, struct qseecom_save_partition_hash_req)
340
341#define QSEECOM_IOCTL_IS_ES_ACTIVATED_REQ \
342 _IOWR(QSEECOM_IOC_MAGIC, 20, struct qseecom_is_es_activated_req)
343
344#define QSEECOM_IOCTL_SEND_MODFD_RESP \
345 _IOWR(QSEECOM_IOC_MAGIC, 21, struct qseecom_send_modfd_listener_resp)
346
347#define QSEECOM_IOCTL_SET_BUS_SCALING_REQ \
348 _IOWR(QSEECOM_IOC_MAGIC, 23, int)
349
350#define QSEECOM_IOCTL_UPDATE_KEY_USER_INFO_REQ \
351 _IOWR(QSEECOM_IOC_MAGIC, 24, struct qseecom_update_key_userinfo_req)
352
353#define QSEECOM_QTEEC_IOCTL_OPEN_SESSION_REQ \
354 _IOWR(QSEECOM_IOC_MAGIC, 30, struct qseecom_qteec_modfd_req)
355
356#define QSEECOM_QTEEC_IOCTL_CLOSE_SESSION_REQ \
357 _IOWR(QSEECOM_IOC_MAGIC, 31, struct qseecom_qteec_req)
358
359#define QSEECOM_QTEEC_IOCTL_INVOKE_MODFD_CMD_REQ \
360 _IOWR(QSEECOM_IOC_MAGIC, 32, struct qseecom_qteec_modfd_req)
361
362#define QSEECOM_QTEEC_IOCTL_REQUEST_CANCELLATION_REQ \
363 _IOWR(QSEECOM_IOC_MAGIC, 33, struct qseecom_qteec_modfd_req)
364
365#define QSEECOM_IOCTL_MDTP_CIPHER_DIP_REQ \
366 _IOWR(QSEECOM_IOC_MAGIC, 34, struct qseecom_mdtp_cipher_dip_req)
367
368#define QSEECOM_IOCTL_SEND_MODFD_CMD_64_REQ \
369 _IOWR(QSEECOM_IOC_MAGIC, 35, struct qseecom_send_modfd_cmd_req)
370
371#define QSEECOM_IOCTL_SEND_MODFD_RESP_64 \
372 _IOWR(QSEECOM_IOC_MAGIC, 36, struct qseecom_send_modfd_listener_resp)
373
374#define QSEECOM_IOCTL_GET_CE_PIPE_INFO \
375 _IOWR(QSEECOM_IOC_MAGIC, 40, struct qseecom_ce_info_req)
376
377#define QSEECOM_IOCTL_FREE_CE_PIPE_INFO \
378 _IOWR(QSEECOM_IOC_MAGIC, 41, struct qseecom_ce_info_req)
379
380#define QSEECOM_IOCTL_QUERY_CE_PIPE_INFO \
381 _IOWR(QSEECOM_IOC_MAGIC, 42, struct qseecom_ce_info_req)
382
383
384#endif /* _UAPI_QSEECOM_H_ */