Dinesh K Garg | 02ab8bf | 2015-08-17 15:53:33 -0700 | [diff] [blame] | 1 | /* Copyright (c) 2015, The Linux Foundation. All rights reserved. |
| 2 | * |
| 3 | * Redistribution and use in source and binary forms, with or without |
| 4 | * modification, are permitted provided that the following conditions are |
| 5 | * met: |
| 6 | * * Redistributions of source code must retain the above copyright |
| 7 | * notice, this list of conditions and the following disclaimer. |
| 8 | * * Redistributions in binary form must reproduce the above |
| 9 | * copyright notice, this list of conditions and the following |
| 10 | * disclaimer in the documentation and/or other materials provided |
| 11 | * with the distribution. |
| 12 | * * Neither the name of The Linux Foundation nor the names of its |
| 13 | * contributors may be used to endorse or promote products derived |
| 14 | * from this software without specific prior written permission. |
| 15 | * |
| 16 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED |
| 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
| 18 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT |
| 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS |
| 20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR |
| 23 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
| 24 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE |
| 25 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN |
| 26 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | */ |
| 28 | |
| 29 | #ifndef __QSEECOM_LK_API_H_ |
| 30 | #define __QSEECOM_LK_API_H_ |
| 31 | |
| 32 | #define MAX_APP_NAME_LEN 32 |
| 33 | |
| 34 | #include <stdint.h> |
| 35 | /** |
| 36 | * Qseecom Init |
| 37 | * To be called before any calls to qsee secure apps. |
| 38 | * |
| 39 | * @return int |
| 40 | * Success: Init succeeded. |
| 41 | * Failure: Error code (negative only). |
| 42 | */ |
| 43 | int qseecom_init(); |
| 44 | |
| 45 | /** |
| 46 | * Qseecom Tz Init |
| 47 | * To be called before any calls to qsee secure apps. |
| 48 | * |
| 49 | * @return int |
| 50 | * Success: Tz init succeeded. |
| 51 | * Failure: Error code (negative only). |
| 52 | */ |
| 53 | int qseecom_tz_init(); |
| 54 | |
| 55 | /** |
| 56 | * Qseecom Exit |
| 57 | * To be called before exit of lk. |
| 58 | * Once this is called no calls to |
| 59 | * Qsee Apps. |
| 60 | * |
| 61 | * @return int |
| 62 | * Success: Exit succeeded. |
| 63 | * Failure: Error code (negative only). |
| 64 | */ |
| 65 | int qseecom_exit(); |
| 66 | |
| 67 | /** |
| 68 | * Start a Secure App |
| 69 | * |
| 70 | * @param char* app_name |
| 71 | * App name of the Secure App to be started |
| 72 | * The app_name provided should be the same |
| 73 | * name as the partition/ file and should |
| 74 | * be the same name mentioned in TZ_APP_NAME |
| 75 | * in the secure app. |
| 76 | * |
| 77 | * @return int |
| 78 | * Success: handle to be used for all calls to |
| 79 | * Secure app. Always greater than zero. |
| 80 | * Failure: Error code (negative only). |
| 81 | */ |
| 82 | int qseecom_start_app(char *app_name); |
| 83 | |
| 84 | /** |
| 85 | * Shutdown a Secure App |
| 86 | * |
| 87 | * @param int handle |
| 88 | * Handle of the Secure App to be shutdown |
| 89 | * |
| 90 | * @return int |
| 91 | * Status: |
| 92 | * 0 - Success |
| 93 | * Negative value indicates failure. |
| 94 | */ |
| 95 | int qseecom_shutdown_app(int handle); |
| 96 | |
| 97 | /** |
| 98 | * Shutdown a Secure App |
| 99 | * |
| 100 | * @param int handle |
| 101 | * Handle of the Secure App to send the cmd |
| 102 | * |
| 103 | * @param void *send_buf |
| 104 | * Pointer to the App request buffer |
| 105 | * |
| 106 | * @param uint32_t sbuf_len |
| 107 | * Size of the request buffer |
| 108 | * |
| 109 | * @param void *resp_buf |
| 110 | * Pointer to the App response buffer |
| 111 | * |
| 112 | * @param uint32_t rbuf_len |
| 113 | * Size of the response buffer |
| 114 | * |
| 115 | * @return int |
| 116 | * Status: |
| 117 | * 0 - Success |
| 118 | * Negative value indicates failure. |
| 119 | */ |
| 120 | int qseecom_send_command(int handle, void *send_buf, |
| 121 | uint32_t sbuf_len, void *resp_buf, uint32_t rbuf_len); |
| 122 | |
| 123 | typedef int (*ListenerCallback)(void*, uint32_t); |
| 124 | |
| 125 | /** |
| 126 | * @param char* service_name |
| 127 | * The name of the listener service. |
| 128 | * @param uint32_t id |
| 129 | * The id used to register a listener with |
| 130 | * QSEE in the secure side. This id should |
| 131 | * be unique. |
| 132 | * @param ListenerCallback service_cmd_handler |
| 133 | * This is the service cmd handler, this cb |
| 134 | * is called for a specific service request. |
| 135 | * The input params are, |
| 136 | * @param void *buf |
| 137 | * The shared buffer which contains the |
| 138 | * request from the secure side. The service |
| 139 | * also updates this buffer with the response. |
| 140 | * @param uint32_t size |
| 141 | * The size of the shared buffer. |
| 142 | * @return int |
| 143 | * Success: Exit succeeded. |
| 144 | * Failure: Error code (negative only). |
| 145 | */ |
| 146 | struct qseecom_listener_services { |
| 147 | char *service_name; |
| 148 | uint32_t id; |
| 149 | uint32_t sb_size; |
| 150 | ListenerCallback service_cmd_handler; |
| 151 | }; |
| 152 | |
| 153 | /** |
| 154 | * Registers a Listener Service with QSEE |
| 155 | * This api should be called after all |
| 156 | * service specific initialization is |
| 157 | * completed, once this is called the |
| 158 | * service_cmd_handler for the service can |
| 159 | * be called. |
| 160 | * |
| 161 | * @param struct qseecom_listener_services listnr |
| 162 | * Listener structure that contains all the info |
| 163 | * to register a listener service. |
| 164 | * |
| 165 | * @return int |
| 166 | * Status: |
| 167 | * 0 - Success |
| 168 | * Negative value indicates failure. |
| 169 | */ |
| 170 | int qseecom_register_listener(struct qseecom_listener_services *listnr); |
| 171 | |
| 172 | /** |
| 173 | * De-Registers a Listener Service with QSEE |
| 174 | * This api should be called before exiting lk and |
| 175 | * all service de-init should be done before calling |
| 176 | * the api. service_cmd_handler will not be called |
| 177 | * after this api is called. |
| 178 | * |
| 179 | * @param uint32_t listnr_id |
| 180 | * Pre-defined Listener ID to be de-registered |
| 181 | * |
| 182 | * @return int |
| 183 | * Status: |
| 184 | * 0 - Success |
| 185 | * Negative value indicates failure. |
| 186 | */ |
| 187 | int qseecom_deregister_listener(uint32_t listnr_id); |
| 188 | |
| 189 | #endif /* __QSEECOM_API_LK_H_ */ |