1 /* 2 * Copyright (c) 2024 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 #ifndef TEE_DRV_CLIENT_H 16 #define TEE_DRV_CLIENT_H 17 18 /** 19 * @addtogroup TeeTrusted 20 * @{ 21 * 22 * @brief TEE(Trusted Excution Environment) API. 23 * Provides security capability APIs such as trusted storage, encryption and decryption, 24 * and trusted time for trusted application development. 25 * 26 * @since 12 27 */ 28 29 /** 30 * @file tee_drv_client.h 31 * 32 * @brief Declare tee driver client API. 33 * 34 * @library NA 35 * @kit TEEKit 36 * @syscap SystemCapability.Tee.TeeClient 37 * @since 12 38 * @version 1.0 39 */ 40 41 #include <stdint.h> 42 43 #ifdef __cplusplus 44 extern "C" { 45 #endif 46 47 /** 48 * @brief Open the specified driver in the TEE. 49 * 50 * @param drv_name [IN] The driver name. 51 * @param param [IN] The parameter information. 52 * @param param_len [IN] The length of the parameter. 53 * 54 * @return Returns greater than 0, which means the fd of the corresponding driver. 55 * Returns less than or equal to 0, which means falied to open the driver. 56 * 57 * @since 12 58 * @version 1.0 59 */ 60 int64_t tee_drv_open(const char *drv_name, const void *param, uint32_t param_len); 61 62 /** 63 * @brief Cancels an operation. 64 * 65 * @param fd [IN] The file descriptor of the driver. 66 * @param cmd_id [IN] The command id. 67 * @param param [IN] The parameter information. 68 * @param param_len [IN] The length of the parameter. 69 * 70 * @return Returns <b>0</b> if the operation is successful. 71 * Returns <b>-1</b> if the operation is failed. 72 * 73 * @since 12 74 * @version 1.0 75 */ 76 int64_t tee_drv_ioctl(int64_t fd, uint32_t cmd_id, const void *param, uint32_t param_len); 77 78 /** 79 * @brief Open the specified driver in the TEE. 80 * 81 * @param fd [IN] The file descriptor of the driver. 82 * 83 * @return Returns <b>0</b> if the operation is successful. 84 * Returns <b>-1</b> if the operation is failed. 85 * 86 * @since 12 87 * @version 1.0 88 */ 89 int64_t tee_drv_close(int64_t fd); 90 91 #ifdef __cplusplus 92 } 93 #endif 94 /** @} */ 95 #endif 96 97