1 /* SPDX-License-Identifier: BSD-2-Clause */ 2 /* 3 * Copyright (c) 2017, Linaro Limited 4 */ 5 6 #ifndef __TEE_TADB_H 7 #define __TEE_TADB_H 8 9 #include <tee/tee_fs.h> 10 11 struct tee_tadb_ta_write; 12 struct tee_tadb_ta_read; 13 14 /* 15 * struct tee_tadb_property 16 * @uuid: UUID of Trusted Application (TA) or Security Domain (SD) 17 * @version: Version of TA or SD 18 * @custom_size:Size of customized properties, prepended to the encrypted 19 * TA binary 20 * @bin_size: Size of the binary TA 21 */ 22 struct tee_tadb_property { 23 TEE_UUID uuid; 24 uint32_t version; 25 uint32_t custom_size; 26 uint32_t bin_size; 27 }; 28 29 struct tee_fs_rpc_operation; 30 31 struct tee_tadb_file_operations { 32 TEE_Result (*open)(uint32_t file_number, int *fd); 33 TEE_Result (*create)(uint32_t file_number, int *fd); 34 void (*close)(int fd); 35 TEE_Result (*remove)(uint32_t file_number); 36 37 TEE_Result (*read_init)(struct tee_fs_rpc_operation *op, int fd, 38 size_t pos, uint8_t **data, size_t bytes); 39 TEE_Result (*read_final)(struct tee_fs_rpc_operation *op, 40 size_t *bytes); 41 42 TEE_Result (*write_init)(struct tee_fs_rpc_operation *op, int fd, 43 size_t pos, uint8_t **data, size_t len); 44 TEE_Result (*write_final)(struct tee_fs_rpc_operation *op); 45 }; 46 47 TEE_Result tee_tadb_ta_create(const struct tee_tadb_property *property, 48 struct tee_tadb_ta_write **ta); 49 TEE_Result tee_tadb_ta_write(struct tee_tadb_ta_write *ta, const void *buf, 50 size_t len); 51 void tee_tadb_ta_close_and_delete(struct tee_tadb_ta_write *ta); 52 TEE_Result tee_tadb_ta_close_and_commit(struct tee_tadb_ta_write *ta); 53 54 TEE_Result tee_tadb_ta_delete(const TEE_UUID *uuid); 55 56 TEE_Result tee_tadb_ta_open(const TEE_UUID *uuid, struct tee_tadb_ta_read **ta); 57 const struct tee_tadb_property * 58 tee_tadb_ta_get_property(struct tee_tadb_ta_read *ta); 59 TEE_Result tee_tadb_get_tag(struct tee_tadb_ta_read *ta, uint8_t *tag, 60 unsigned int *tag_len); 61 TEE_Result tee_tadb_ta_read(struct tee_tadb_ta_read *ta, void *buf, 62 size_t *len); 63 void tee_tadb_ta_close(struct tee_tadb_ta_read *ta); 64 65 66 #endif /*__TEE_TADB_H*/ 67