| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame^] | 1 | /* 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 |  | 
|  | 9 | /** | 
|  | 10 | * struct tzcom_register_svc_op_req - for register service ioctl request | 
|  | 11 | * @svc_id - service id (shared between userspace and TZ) | 
|  | 12 | * @cmd_id_low - low number in cmd_id range (shared between userspace and TZ) | 
|  | 13 | * @cmd_id_high - high number in cmd_id range (shared between userspace and TZ) | 
|  | 14 | * @instance_id - unique id for the given service generated by tzcom driver | 
|  | 15 | */ | 
|  | 16 | struct tzcom_register_svc_op_req { | 
|  | 17 | uint32_t svc_id; /* in */ | 
|  | 18 | uint32_t cmd_id_low; /* in */ | 
|  | 19 | uint32_t cmd_id_high; /* in */ | 
|  | 20 | uint32_t instance_id; /* out */ | 
|  | 21 | }; | 
|  | 22 |  | 
|  | 23 | /** | 
|  | 24 | * struct tzcom_unregister_svc_op_req - for unregister service ioctl request | 
|  | 25 | * @svc_id - service id to unregister (provided in register_service request) | 
|  | 26 | * @instance_id - instance id generated in register service request | 
|  | 27 | */ | 
|  | 28 | struct tzcom_unregister_svc_op_req { | 
|  | 29 | uint32_t svc_id; /* in */ | 
|  | 30 | uint32_t instance_id; /* in */ | 
|  | 31 | }; | 
|  | 32 |  | 
|  | 33 | /** | 
|  | 34 | * struct tzcom_next_cmd_op_req - for read next command ioctl request | 
|  | 35 | * @svc_id - has to be a registered svc_id (see @tzcom_register_svc_op_req) | 
|  | 36 | * @instance_id - unique id for the given service (see @tzcom_register_svc_op_req) | 
|  | 37 | * @cmd_id - command to execute on the given service, received from TZ | 
|  | 38 | * @req_len - request buffer length, received from TZ | 
|  | 39 | * @req - request buffer, received from TZ | 
|  | 40 | */ | 
|  | 41 | struct tzcom_next_cmd_op_req { | 
|  | 42 | uint32_t svc_id; /* in */ | 
|  | 43 | uint32_t instance_id; /* in */ | 
|  | 44 | uint32_t cmd_id; /* out */ | 
|  | 45 | unsigned int req_len; /* in/out */ | 
|  | 46 | void *req_buf; /* in/out */ | 
|  | 47 | }; | 
|  | 48 |  | 
|  | 49 | /** | 
|  | 50 | * struct tzcom_send_cmd_op_req - for send command ioctl request | 
|  | 51 | * @cmd_id - command to execute on TZBSP side | 
|  | 52 | * @cmd_len - command buffer length | 
|  | 53 | * @cmd_buf - command buffer | 
|  | 54 | * @resp_len - response buffer length | 
|  | 55 | * @resp_buf - response buffer | 
|  | 56 | */ | 
|  | 57 | struct tzcom_send_cmd_op_req { | 
|  | 58 | uint32_t cmd_id; /* in */ | 
|  | 59 | unsigned int cmd_len; /* in */ | 
|  | 60 | void *cmd_buf; /* in */ | 
|  | 61 | unsigned int resp_len; /* in/out */ | 
|  | 62 | void *resp_buf; /* in/out */ | 
|  | 63 | }; | 
|  | 64 |  | 
|  | 65 | /** | 
|  | 66 | * struct tzcom_cont_cmd_op_req - for continue command ioctl request. used | 
|  | 67 | * as a trigger from HLOS service to notify TZCOM that it's done with its | 
|  | 68 | * operation and provide the response for TZCOM can continue the incomplete | 
|  | 69 | * command execution | 
|  | 70 | * @cmd_id - Command to continue filled in by tzcom as tzcom knows about the | 
|  | 71 | *           last incomplete command. | 
|  | 72 | * @instance_id - Instance id of the svc | 
|  | 73 | * @resp_len - Length of the response | 
|  | 74 | * @resp_buf - Response buffer where the response of the cmd should go. | 
|  | 75 | */ | 
|  | 76 | struct tzcom_cont_cmd_op_req { | 
|  | 77 | uint32_t cmd_id; /* out */ | 
|  | 78 | uint32_t instance_id; /* in */ | 
|  | 79 | unsigned int resp_len; /* in */ | 
|  | 80 | void *resp_buf; /* in */ | 
|  | 81 | }; | 
|  | 82 |  | 
|  | 83 | #define TZCOM_IOC_MAGIC    0x97 | 
|  | 84 |  | 
|  | 85 | /* For HLOS service */ | 
|  | 86 | #define TZCOM_IOCTL_REGISTER_SERVICE_REQ \ | 
|  | 87 | _IOWR(TZCOM_IOC_MAGIC, 1, struct tzcom_register_svc_op_req) | 
|  | 88 | /* For HLOS service */ | 
|  | 89 | #define TZCOM_IOCTL_UNREGISTER_SERVICE_REQ \ | 
|  | 90 | _IOWR(TZCOM_IOC_MAGIC, 2, struct tzcom_unregister_svc_op_req) | 
|  | 91 | /* For TZ service */ | 
|  | 92 | #define TZCOM_IOCTL_SEND_CMD_REQ \ | 
|  | 93 | _IOWR(TZCOM_IOC_MAGIC, 3, struct tzcom_send_cmd_op_req) | 
|  | 94 | /* For HLOS service */ | 
|  | 95 | #define TZCOM_IOCTL_READ_NEXT_CMD_REQ \ | 
|  | 96 | _IOWR(TZCOM_IOC_MAGIC, 4, struct tzcom_next_cmd_op_req) | 
|  | 97 | /* For TZ service */ | 
|  | 98 | #define TZCOM_IOCTL_CONTINUE_CMD_REQ \ | 
|  | 99 | _IOWR(TZCOM_IOC_MAGIC, 5, struct tzcom_cont_cmd_op_req) | 
|  | 100 |  | 
|  | 101 | #endif /* __TZCOM_H_ */ |