blob: 448ab2a12c5d5818e39ce985e7b653e6f7dae6dc [file] [log] [blame]
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001/* Qualcomm TrustZone communicator API */
2
3#ifndef __TZCOM_H_
4#define __TZCOM_H_
5
6#include <linux/types.h>
7#include <linux/ioctl.h>
8
Mona Hossain6e2e2692012-01-05 11:28:04 -08009#define MAX_ION_FD 4
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070010/**
11 * struct tzcom_register_svc_op_req - for register service ioctl request
12 * @svc_id - service id (shared between userspace and TZ)
13 * @cmd_id_low - low number in cmd_id range (shared between userspace and TZ)
14 * @cmd_id_high - high number in cmd_id range (shared between userspace and TZ)
15 * @instance_id - unique id for the given service generated by tzcom driver
16 */
17struct tzcom_register_svc_op_req {
18 uint32_t svc_id; /* in */
19 uint32_t cmd_id_low; /* in */
20 uint32_t cmd_id_high; /* in */
21 uint32_t instance_id; /* out */
22};
23
24/**
25 * struct tzcom_unregister_svc_op_req - for unregister service ioctl request
26 * @svc_id - service id to unregister (provided in register_service request)
27 * @instance_id - instance id generated in register service request
28 */
29struct tzcom_unregister_svc_op_req {
30 uint32_t svc_id; /* in */
31 uint32_t instance_id; /* in */
32};
33
34/**
35 * struct tzcom_next_cmd_op_req - for read next command ioctl request
36 * @svc_id - has to be a registered svc_id (see @tzcom_register_svc_op_req)
37 * @instance_id - unique id for the given service (see @tzcom_register_svc_op_req)
38 * @cmd_id - command to execute on the given service, received from TZ
39 * @req_len - request buffer length, received from TZ
40 * @req - request buffer, received from TZ
41 */
42struct tzcom_next_cmd_op_req {
43 uint32_t svc_id; /* in */
44 uint32_t instance_id; /* in */
45 uint32_t cmd_id; /* out */
46 unsigned int req_len; /* in/out */
47 void *req_buf; /* in/out */
48};
49
50/**
51 * struct tzcom_send_cmd_op_req - for send command ioctl request
52 * @cmd_id - command to execute on TZBSP side
Mona Hossain6e2e2692012-01-05 11:28:04 -080053 * @ifd_data_fd - ion handle to some memory allocated in user space
54 * @cmd_buf_offset - command buffer offset
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070055 * @cmd_len - command buffer length
56 * @cmd_buf - command buffer
57 * @resp_len - response buffer length
58 * @resp_buf - response buffer
59 */
60struct tzcom_send_cmd_op_req {
61 uint32_t cmd_id; /* in */
62 unsigned int cmd_len; /* in */
63 void *cmd_buf; /* in */
64 unsigned int resp_len; /* in/out */
65 void *resp_buf; /* in/out */
66};
67
68/**
Mona Hossain6e2e2692012-01-05 11:28:04 -080069 * struct tzcom_ion_fd_info - ion fd handle data information
70 * @fd - ion handle to some memory allocated in user space
71 * @cmd_buf_offset - command buffer offset
72 */
73struct tzcom_ion_fd_info {
74 int32_t fd;
75 uint32_t cmd_buf_offset;
76};
77
78/**
79 * struct tzcom_send_cmd_op_req - for send command ioctl request
80 * @cmd_id - command to execute on TZBSP side
81 * @ifd_data_fd - ion handle to some memory allocated in user space
82 * @cmd_buf_offset - command buffer offset
83 * @cmd_len - command buffer length
84 * @cmd_buf - command buffer
85 * @resp_len - response buffer length
86 * @resp_buf - response buffer
87 */
88struct tzcom_send_cmd_fd_op_req {
89 uint32_t cmd_id; /* in */
90 struct tzcom_ion_fd_info ifd_data[MAX_ION_FD];
91 unsigned int cmd_len; /* in */
92 void *cmd_buf; /* in */
93 unsigned int resp_len; /* in/out */
94 void *resp_buf; /* in/out */
95};
96/**
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070097 * struct tzcom_cont_cmd_op_req - for continue command ioctl request. used
98 * as a trigger from HLOS service to notify TZCOM that it's done with its
99 * operation and provide the response for TZCOM can continue the incomplete
100 * command execution
101 * @cmd_id - Command to continue filled in by tzcom as tzcom knows about the
102 * last incomplete command.
103 * @instance_id - Instance id of the svc
104 * @resp_len - Length of the response
105 * @resp_buf - Response buffer where the response of the cmd should go.
106 */
107struct tzcom_cont_cmd_op_req {
108 uint32_t cmd_id; /* out */
109 uint32_t instance_id; /* in */
110 unsigned int resp_len; /* in */
111 void *resp_buf; /* in */
112};
113
114#define TZCOM_IOC_MAGIC 0x97
115
116/* For HLOS service */
117#define TZCOM_IOCTL_REGISTER_SERVICE_REQ \
118 _IOWR(TZCOM_IOC_MAGIC, 1, struct tzcom_register_svc_op_req)
119/* For HLOS service */
120#define TZCOM_IOCTL_UNREGISTER_SERVICE_REQ \
121 _IOWR(TZCOM_IOC_MAGIC, 2, struct tzcom_unregister_svc_op_req)
122/* For TZ service */
123#define TZCOM_IOCTL_SEND_CMD_REQ \
124 _IOWR(TZCOM_IOC_MAGIC, 3, struct tzcom_send_cmd_op_req)
125/* For HLOS service */
126#define TZCOM_IOCTL_READ_NEXT_CMD_REQ \
127 _IOWR(TZCOM_IOC_MAGIC, 4, struct tzcom_next_cmd_op_req)
128/* For TZ service */
129#define TZCOM_IOCTL_CONTINUE_CMD_REQ \
130 _IOWR(TZCOM_IOC_MAGIC, 5, struct tzcom_cont_cmd_op_req)
131
Sachin Shahd7e02d42011-09-12 20:31:02 -0700132#define TZCOM_IOCTL_ABORT_REQ _IO(TZCOM_IOC_MAGIC, 6)
Mona Hossain6e2e2692012-01-05 11:28:04 -0800133/* For TZ service */
134#define TZCOM_IOCTL_SEND_CMD_FD_REQ \
135 _IOWR(TZCOM_IOC_MAGIC, 7, struct tzcom_send_cmd_fd_op_req)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700136#endif /* __TZCOM_H_ */