Rohit Vaswani | 5fd759e | 2012-11-07 07:05:08 -0800 | [diff] [blame] | 1 | /* Qualcomm SMC Module API */ |
| 2 | |
| 3 | #ifndef __SMCMOD_H_ |
| 4 | #define __SMCMOD_H_ |
| 5 | |
| 6 | #include <linux/types.h> |
| 7 | #include <linux/ioctl.h> |
| 8 | |
| 9 | #define SMCMOD_DEV "smcmod" |
| 10 | |
| 11 | #define SMCMOD_REG_REQ_MAX_ARGS 2 |
| 12 | |
| 13 | /** |
| 14 | * struct smcmod_reg_req - for SMC register ioctl request |
| 15 | * |
| 16 | * @service_id - requested service. |
| 17 | * @command_id - requested command. |
| 18 | * @num_args - number of arguments. |
| 19 | * @args - argument(s) to be passed to the secure world. |
| 20 | * @return_val - return value from secure world operation. |
| 21 | */ |
| 22 | struct smcmod_reg_req { |
| 23 | uint32_t service_id; /* in */ |
| 24 | uint32_t command_id; /* in */ |
| 25 | uint8_t num_args; /* in */ |
| 26 | uint32_t args[SMCMOD_REG_REQ_MAX_ARGS]; /* in */ |
| 27 | uint32_t return_val; /* out */ |
| 28 | }; |
| 29 | |
| 30 | /** |
| 31 | * struct smcmod_buf_req - for SMC buffer ioctl request |
| 32 | * |
| 33 | * @service_id - requested service. |
| 34 | * @command_id - requested command. |
| 35 | * @ion_cmd_fd - fd obtained from ION_IOC_MAP or ION_IOC_SHARE. |
| 36 | * @cmd_len - length of command data buffer in bytes. |
| 37 | * @ion_resp_fd - fd obtained from ION_IOC_MAP or ION_IOC_SHARE. |
| 38 | * @resp_len - length of response data buffer in bytes. |
| 39 | * @return_val - return value from secure world operation. |
| 40 | */ |
| 41 | struct smcmod_buf_req { |
| 42 | uint32_t service_id;/* in */ |
| 43 | uint32_t command_id; /* in */ |
| 44 | int32_t ion_cmd_fd; /* in */ |
| 45 | uint32_t cmd_len; /* in */ |
| 46 | int32_t ion_resp_fd; /* in */ |
| 47 | uint32_t resp_len; /* in */ |
| 48 | uint32_t return_val; /* out */ |
| 49 | }; |
| 50 | |
| 51 | /** |
| 52 | * struct smcmod_cipher_req - for SMC cipher command ioctl |
| 53 | * |
| 54 | * @algorithm - specifies the cipher algorithm. |
| 55 | * @operation - specifies encryption or decryption. |
| 56 | * @mode - specifies cipher mode. |
| 57 | * @ion_key_fd - fd obtained form ION_IOC_MAP or ION_IOC_SHARE. |
| 58 | * @key_size - key size in bytes. |
| 59 | * @ion_plain_text_fd - fd obtained form ION_IOC_MAP or ION_IOC_SHARE. |
| 60 | * @plain_text_size - size of plain text in bytes. |
| 61 | * @ion_cipher_text_fd - fd obtained form ION_IOC_MAP or ION_IOC_SHARE. |
| 62 | * @cipher_text_size - cipher text size in bytes. |
| 63 | * @ion_init_vector_fd - fd obtained form ION_IOC_MAP or ION_IOC_SHARE. |
| 64 | * @init_vector_size - size of initialization vector in bytes. |
| 65 | * @key_is_null - indicates that the key is null. |
| 66 | * @return_val - return value from secure world opreation. |
| 67 | */ |
| 68 | struct smcmod_cipher_req { |
| 69 | uint32_t algorithm; /* in */ |
| 70 | uint32_t operation; /* in */ |
| 71 | uint32_t mode; /* in */ |
| 72 | int32_t ion_key_fd; /* in */ |
| 73 | uint32_t key_size; /* in */ |
| 74 | int32_t ion_plain_text_fd; /* in (encrypt)/out (decrypt) */ |
| 75 | uint32_t plain_text_size; /* in */ |
| 76 | int32_t ion_cipher_text_fd; /* out (encrypt)/in (decrypt) */ |
| 77 | uint32_t cipher_text_size; /* in */ |
| 78 | int32_t ion_init_vector_fd; /* in */ |
| 79 | uint32_t init_vector_size; /* in */ |
| 80 | uint32_t key_is_null; /* in */ |
| 81 | uint32_t return_val; /* out */ |
| 82 | }; |
| 83 | |
| 84 | /** |
| 85 | * struct smcmod_msg_digest_req - for message digest command ioctl |
| 86 | * |
| 87 | * @algorithm - specifies the cipher algorithm. |
| 88 | * @ion_key_fd - fd obtained form ION_IOC_MAP or ION_IOC_SHARE. |
| 89 | * @key_size - hash key size in bytes. |
| 90 | * @ion_input_fd - fd obtained form ION_IOC_MAP or ION_IOC_SHARE. |
| 91 | * @input_size - input data size in bytes. |
| 92 | * @ion_output_fd - fd obtained form ION_IOC_MAP or ION_IOC_SHARE. |
| 93 | * @output_size - size of output buffer in bytes. |
| 94 | * @fixed_block - indicates whether this is a fixed block digest. |
| 95 | * @key_is_null - indicates that the key is null. |
| 96 | * @return_val - return value from secure world opreation. |
| 97 | */ |
| 98 | struct smcmod_msg_digest_req { |
| 99 | uint32_t algorithm; /* in */ |
| 100 | int32_t ion_key_fd; /* in */ |
| 101 | uint32_t key_size; /* in */ |
| 102 | int32_t ion_input_fd; /* in */ |
| 103 | uint32_t input_size; /* in */ |
| 104 | int32_t ion_output_fd; /* in/out */ |
| 105 | uint32_t output_size; /* in */ |
| 106 | uint32_t fixed_block; /* in */ |
| 107 | uint32_t key_is_null; /* in */ |
| 108 | uint32_t return_val; /* out */ |
| 109 | } __packed; |
| 110 | |
| 111 | #define SMCMOD_IOC_MAGIC 0x97 |
| 112 | |
| 113 | /* Number chosen to avoid any conflicts */ |
| 114 | #define SMCMOD_IOCTL_SEND_REG_CMD \ |
| 115 | _IOWR(SMCMOD_IOC_MAGIC, 32, struct smcmod_reg_req) |
| 116 | #define SMCMOD_IOCTL_SEND_BUF_CMD \ |
| 117 | _IOWR(SMCMOD_IOC_MAGIC, 33, struct smcmod_buf_req) |
| 118 | #define SMCMOD_IOCTL_SEND_CIPHER_CMD \ |
| 119 | _IOWR(SMCMOD_IOC_MAGIC, 34, struct smcmod_cipher_req) |
| 120 | #define SMCMOD_IOCTL_SEND_MSG_DIGEST_CMD \ |
| 121 | _IOWR(SMCMOD_IOC_MAGIC, 35, struct smcmod_msg_digest_req) |
| 122 | #define SMCMOD_IOCTL_GET_VERSION _IOWR(SMCMOD_IOC_MAGIC, 36, uint32_t) |
| 123 | #endif /* __SMCMOD_H_ */ |