1 /* SPDX-License-Identifier: BSD-2-Clause */ 2 /* 3 * Copyright (c) 2016, Linaro Limited 4 * All rights reserved. 5 */ 6 7 /* 8 * Interface with tee-supplicant for file operations 9 */ 10 11 #ifndef TEE_FS_RPC_H 12 #define TEE_FS_RPC_H 13 14 #include <stdbool.h> 15 #include <stddef.h> 16 #include <tee_api_types.h> 17 #include <tee/tee_fs.h> 18 #include <kernel/thread.h> 19 20 struct tee_fs_rpc_operation { 21 uint32_t id; 22 struct optee_msg_param params[THREAD_RPC_MAX_NUM_PARAMS]; 23 size_t num_params; 24 }; 25 26 struct tee_fs_dirfile_fileh; 27 28 TEE_Result tee_fs_rpc_open(uint32_t id, struct tee_pobj *po, int *fd); 29 TEE_Result tee_fs_rpc_open_dfh(uint32_t id, 30 const struct tee_fs_dirfile_fileh *dfh, int *fd); 31 TEE_Result tee_fs_rpc_create(uint32_t id, struct tee_pobj *po, int *fd); 32 TEE_Result tee_fs_rpc_create_dfh(uint32_t id, 33 const struct tee_fs_dirfile_fileh *dfh, 34 int *fd); 35 TEE_Result tee_fs_rpc_close(uint32_t id, int fd); 36 37 TEE_Result tee_fs_rpc_read_init(struct tee_fs_rpc_operation *op, 38 uint32_t id, int fd, tee_fs_off_t offset, 39 size_t data_len, void **out_data); 40 TEE_Result tee_fs_rpc_read_final(struct tee_fs_rpc_operation *op, 41 size_t *data_len); 42 43 TEE_Result tee_fs_rpc_write_init(struct tee_fs_rpc_operation *op, 44 uint32_t id, int fd, tee_fs_off_t offset, 45 size_t data_len, void **data); 46 TEE_Result tee_fs_rpc_write_final(struct tee_fs_rpc_operation *op); 47 48 49 TEE_Result tee_fs_rpc_truncate(uint32_t id, int fd, size_t len); 50 TEE_Result tee_fs_rpc_remove(uint32_t id, struct tee_pobj *po); 51 TEE_Result tee_fs_rpc_remove_dfh(uint32_t id, 52 const struct tee_fs_dirfile_fileh *dfh); 53 TEE_Result tee_fs_rpc_rename(uint32_t id, struct tee_pobj *old, 54 struct tee_pobj *new, bool overwrite); 55 56 TEE_Result tee_fs_rpc_opendir(uint32_t id, const TEE_UUID *uuid, 57 struct tee_fs_dir **d); 58 TEE_Result tee_fs_rpc_closedir(uint32_t id, struct tee_fs_dir *d); 59 TEE_Result tee_fs_rpc_readdir(uint32_t id, struct tee_fs_dir *d, 60 struct tee_fs_dirent **ent); 61 62 struct thread_specific_data; 63 #if defined(CFG_WITH_USER_TA) && (defined(CFG_REE_FS) || defined(CFG_RPMB_FS)) 64 /* Frees the cache of allocated FS RPC memory */ 65 void tee_fs_rpc_cache_clear(struct thread_specific_data *tsd); 66 #else 67 static inline void tee_fs_rpc_cache_clear( 68 struct thread_specific_data *tsd __unused) 69 { 70 } 71 #endif 72 73 /* 74 * Returns a pointer to the cached FS RPC memory. Each thread has a unique 75 * cache. The pointer is guaranteed to point to a large enough area or to 76 * be NULL. 77 */ 78 void *tee_fs_rpc_cache_alloc(size_t size, struct mobj **mobj, uint64_t *cookie); 79 80 #endif /* TEE_FS_RPC_H */ 81