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