1 /****************************************************************************
2  ****************************************************************************
3  ***
4  ***   This header was automatically generated from a Linux kernel header
5  ***   of the same name, to make information necessary for userspace to
6  ***   call into the kernel available to libc.  It contains only constants,
7  ***   structures, and macros generated from the original header, and thus,
8  ***   contains no copyrightable information.
9  ***
10  ***   To edit the content of this header, modify the corresponding
11  ***   source file (e.g. under external/kernel-headers/original/) then
12  ***   run bionic/libc/kernel/tools/update_all.py
13  ***
14  ***   Any manual change here will be lost the next time this script will
15  ***   be run. You've been warned!
16  ***
17  ****************************************************************************
18  ****************************************************************************/
19 #ifndef _QSEECOM_H_
20 #define _QSEECOM_H_
21 #include <linux/types.h>
22 #include <linux/ioctl.h>
23 #define MAX_ION_FD 4
24 #define MAX_APP_NAME_SIZE 64
25 #define QSEECOM_HASH_SIZE 32
26 #define QSEECOM_TA_ION_ALLOCATE_DELAY 50
27 #define QSEECOM_TA_ION_ALLOCATE_MAX_ATTEMP 20
28 struct qseecom_register_listener_req {
29   uint32_t listener_id;
30   int32_t ifd_data_fd;
31   void * virt_sb_base;
32   uint32_t sb_size;
33 };
34 struct qseecom_send_cmd_req {
35   void * cmd_req_buf;
36   unsigned int cmd_req_len;
37   void * resp_buf;
38   unsigned int resp_len;
39 };
40 struct qseecom_ion_fd_info {
41   int32_t fd;
42   uint32_t cmd_buf_offset;
43 };
44 struct qseecom_send_modfd_cmd_req {
45   void * cmd_req_buf;
46   unsigned int cmd_req_len;
47   void * resp_buf;
48   unsigned int resp_len;
49   struct qseecom_ion_fd_info ifd_data[MAX_ION_FD];
50 };
51 struct qseecom_send_resp_req {
52   void * resp_buf;
53   unsigned int resp_len;
54 };
55 struct qseecom_load_img_req {
56   uint32_t mdt_len;
57   uint32_t img_len;
58   int32_t ifd_data_fd;
59   char img_name[MAX_APP_NAME_SIZE];
60   uint32_t app_arch;
61   uint32_t app_id;
62 };
63 struct qseecom_set_sb_mem_param_req {
64   int32_t ifd_data_fd;
65   void * virt_sb_base;
66   uint32_t sb_len;
67 };
68 struct qseecom_qseos_version_req {
69   unsigned int qseos_version;
70 };
71 struct qseecom_qseos_app_load_query {
72   char app_name[MAX_APP_NAME_SIZE];
73   uint32_t app_id;
74   uint32_t app_arch;
75 };
76 struct qseecom_send_svc_cmd_req {
77   uint32_t cmd_id;
78   void * cmd_req_buf;
79   unsigned int cmd_req_len;
80   void * resp_buf;
81   unsigned int resp_len;
82 };
83 enum qseecom_key_management_usage_type {
84   QSEOS_KM_USAGE_DISK_ENCRYPTION = 0x01,
85   QSEOS_KM_USAGE_FILE_ENCRYPTION = 0x02,
86   QSEOS_KM_USAGE_UFS_ICE_DISK_ENCRYPTION = 0x03,
87   QSEOS_KM_USAGE_SDCC_ICE_DISK_ENCRYPTION = 0x04,
88   QSEOS_KM_USAGE_MAX
89 };
90 struct qseecom_create_key_req {
91   unsigned char hash32[QSEECOM_HASH_SIZE];
92   enum qseecom_key_management_usage_type usage;
93 };
94 struct qseecom_wipe_key_req {
95   enum qseecom_key_management_usage_type usage;
96   int wipe_key_flag;
97 };
98 struct qseecom_update_key_userinfo_req {
99   unsigned char current_hash32[QSEECOM_HASH_SIZE];
100   unsigned char new_hash32[QSEECOM_HASH_SIZE];
101   enum qseecom_key_management_usage_type usage;
102 };
103 #define SHA256_DIGEST_LENGTH (256 / 8)
104 struct qseecom_save_partition_hash_req {
105   int partition_id;
106   char digest[SHA256_DIGEST_LENGTH];
107 };
108 struct qseecom_is_es_activated_req {
109   int is_activated;
110 };
111 struct qseecom_mdtp_cipher_dip_req {
112   uint8_t * in_buf;
113   uint32_t in_buf_size;
114   uint8_t * out_buf;
115   uint32_t out_buf_size;
116   uint32_t direction;
117 };
118 enum qseecom_bandwidth_request_mode {
119   INACTIVE = 0,
120   LOW,
121   MEDIUM,
122   HIGH,
123 };
124 struct qseecom_send_modfd_listener_resp {
125   void * resp_buf_ptr;
126   unsigned int resp_len;
127   struct qseecom_ion_fd_info ifd_data[MAX_ION_FD];
128 };
129 struct qseecom_qteec_req {
130   void * req_ptr;
131   uint32_t req_len;
132   void * resp_ptr;
133   uint32_t resp_len;
134 };
135 struct qseecom_qteec_modfd_req {
136   void * req_ptr;
137   uint32_t req_len;
138   void * resp_ptr;
139   uint32_t resp_len;
140   struct qseecom_ion_fd_info ifd_data[MAX_ION_FD];
141 };
142 struct qseecom_sg_entry {
143   uint32_t phys_addr;
144   uint32_t len;
145 };
146 struct qseecom_sg_entry_64bit {
147   uint64_t phys_addr;
148   uint32_t len;
149 } __attribute__((packed));
150 #define QSEECOM_SG_LIST_BUF_FORMAT_VERSION_1 1
151 #define QSEECOM_SG_LIST_BUF_FORMAT_VERSION_2 2
152 struct qseecom_sg_list_buf_hdr_64bit {
153   struct qseecom_sg_entry_64bit blank_entry;
154   uint32_t version;
155   uint64_t new_buf_phys_addr;
156   uint32_t nents_total;
157 } __attribute__((packed));
158 #define QSEECOM_SG_LIST_BUF_HDR_SZ_64BIT sizeof(struct qseecom_sg_list_buf_hdr_64bit)
159 #define MAX_CE_PIPE_PAIR_PER_UNIT 3
160 #define INVALID_CE_INFO_UNIT_NUM 0xffffffff
161 #define CE_PIPE_PAIR_USE_TYPE_FDE 0
162 #define CE_PIPE_PAIR_USE_TYPE_PFE 1
163 struct qseecom_ce_pipe_entry {
164   int valid;
165   unsigned int ce_num;
166   unsigned int ce_pipe_pair;
167 };
168 #define MAX_CE_INFO_HANDLE_SIZE 32
169 struct qseecom_ce_info_req {
170   unsigned char handle[MAX_CE_INFO_HANDLE_SIZE];
171   unsigned int usage;
172   unsigned int unit_num;
173   unsigned int num_ce_pipe_entries;
174   struct qseecom_ce_pipe_entry ce_pipe_entry[MAX_CE_PIPE_PAIR_PER_UNIT];
175 };
176 #define SG_ENTRY_SZ sizeof(struct qseecom_sg_entry)
177 #define SG_ENTRY_SZ_64BIT sizeof(struct qseecom_sg_entry_64bit)
178 struct file;
179 #define QSEECOM_IOC_MAGIC 0x97
180 #define QSEECOM_IOCTL_REGISTER_LISTENER_REQ _IOWR(QSEECOM_IOC_MAGIC, 1, struct qseecom_register_listener_req)
181 #define QSEECOM_IOCTL_UNREGISTER_LISTENER_REQ _IO(QSEECOM_IOC_MAGIC, 2)
182 #define QSEECOM_IOCTL_SEND_CMD_REQ _IOWR(QSEECOM_IOC_MAGIC, 3, struct qseecom_send_cmd_req)
183 #define QSEECOM_IOCTL_SEND_MODFD_CMD_REQ _IOWR(QSEECOM_IOC_MAGIC, 4, struct qseecom_send_modfd_cmd_req)
184 #define QSEECOM_IOCTL_RECEIVE_REQ _IO(QSEECOM_IOC_MAGIC, 5)
185 #define QSEECOM_IOCTL_SEND_RESP_REQ _IO(QSEECOM_IOC_MAGIC, 6)
186 #define QSEECOM_IOCTL_LOAD_APP_REQ _IOWR(QSEECOM_IOC_MAGIC, 7, struct qseecom_load_img_req)
187 #define QSEECOM_IOCTL_SET_MEM_PARAM_REQ _IOWR(QSEECOM_IOC_MAGIC, 8, struct qseecom_set_sb_mem_param_req)
188 #define QSEECOM_IOCTL_UNLOAD_APP_REQ _IO(QSEECOM_IOC_MAGIC, 9)
189 #define QSEECOM_IOCTL_GET_QSEOS_VERSION_REQ _IOWR(QSEECOM_IOC_MAGIC, 10, struct qseecom_qseos_version_req)
190 #define QSEECOM_IOCTL_PERF_ENABLE_REQ _IO(QSEECOM_IOC_MAGIC, 11)
191 #define QSEECOM_IOCTL_PERF_DISABLE_REQ _IO(QSEECOM_IOC_MAGIC, 12)
192 #define QSEECOM_IOCTL_LOAD_EXTERNAL_ELF_REQ _IOWR(QSEECOM_IOC_MAGIC, 13, struct qseecom_load_img_req)
193 #define QSEECOM_IOCTL_UNLOAD_EXTERNAL_ELF_REQ _IO(QSEECOM_IOC_MAGIC, 14)
194 #define QSEECOM_IOCTL_APP_LOADED_QUERY_REQ _IOWR(QSEECOM_IOC_MAGIC, 15, struct qseecom_qseos_app_load_query)
195 #define QSEECOM_IOCTL_SEND_CMD_SERVICE_REQ _IOWR(QSEECOM_IOC_MAGIC, 16, struct qseecom_send_svc_cmd_req)
196 #define QSEECOM_IOCTL_CREATE_KEY_REQ _IOWR(QSEECOM_IOC_MAGIC, 17, struct qseecom_create_key_req)
197 #define QSEECOM_IOCTL_WIPE_KEY_REQ _IOWR(QSEECOM_IOC_MAGIC, 18, struct qseecom_wipe_key_req)
198 #define QSEECOM_IOCTL_SAVE_PARTITION_HASH_REQ _IOWR(QSEECOM_IOC_MAGIC, 19, struct qseecom_save_partition_hash_req)
199 #define QSEECOM_IOCTL_IS_ES_ACTIVATED_REQ _IOWR(QSEECOM_IOC_MAGIC, 20, struct qseecom_is_es_activated_req)
200 #define QSEECOM_IOCTL_SEND_MODFD_RESP _IOWR(QSEECOM_IOC_MAGIC, 21, struct qseecom_send_modfd_listener_resp)
201 #define QSEECOM_IOCTL_SET_BUS_SCALING_REQ _IOWR(QSEECOM_IOC_MAGIC, 23, int)
202 #define QSEECOM_IOCTL_UPDATE_KEY_USER_INFO_REQ _IOWR(QSEECOM_IOC_MAGIC, 24, struct qseecom_update_key_userinfo_req)
203 #define QSEECOM_QTEEC_IOCTL_OPEN_SESSION_REQ _IOWR(QSEECOM_IOC_MAGIC, 30, struct qseecom_qteec_modfd_req)
204 #define QSEECOM_QTEEC_IOCTL_CLOSE_SESSION_REQ _IOWR(QSEECOM_IOC_MAGIC, 31, struct qseecom_qteec_req)
205 #define QSEECOM_QTEEC_IOCTL_INVOKE_MODFD_CMD_REQ _IOWR(QSEECOM_IOC_MAGIC, 32, struct qseecom_qteec_modfd_req)
206 #define QSEECOM_QTEEC_IOCTL_REQUEST_CANCELLATION_REQ _IOWR(QSEECOM_IOC_MAGIC, 33, struct qseecom_qteec_modfd_req)
207 #define QSEECOM_IOCTL_MDTP_CIPHER_DIP_REQ _IOWR(QSEECOM_IOC_MAGIC, 34, struct qseecom_mdtp_cipher_dip_req)
208 #define QSEECOM_IOCTL_SEND_MODFD_CMD_64_REQ _IOWR(QSEECOM_IOC_MAGIC, 35, struct qseecom_send_modfd_cmd_req)
209 #define QSEECOM_IOCTL_SEND_MODFD_RESP_64 _IOWR(QSEECOM_IOC_MAGIC, 36, struct qseecom_send_modfd_listener_resp)
210 #define QSEECOM_IOCTL_GET_CE_PIPE_INFO _IOWR(QSEECOM_IOC_MAGIC, 40, struct qseecom_ce_info_req)
211 #define QSEECOM_IOCTL_FREE_CE_PIPE_INFO _IOWR(QSEECOM_IOC_MAGIC, 41, struct qseecom_ce_info_req)
212 #define QSEECOM_IOCTL_QUERY_CE_PIPE_INFO _IOWR(QSEECOM_IOC_MAGIC, 42, struct qseecom_ce_info_req)
213 #endif
214 
215