1 /* 2 * Copyright (c) 2016, Fuzhou Rockchip Electronics Co.,Ltd. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are met: 7 * 8 * 1. Redistributions of source code must retain the above copyright notice, 9 * this list of conditions and the following disclaimer. 10 * 11 * 2. Redistributions in binary form must reproduce the above copyright notice, 12 * this list of conditions and the following disclaimer in the documentation 13 * and/or other materials provided with the distribution. 14 * 15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 19 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 * POSSIBILITY OF SUCH DAMAGE. 26 */ 27 #ifndef TEE_SUPP_RK_FS_H 28 #define TEE_SUPP_RK_FS_H 29 30 /* 31 * Operations and defines shared with TEE. 32 */ 33 #define OPTEE_MRF_OPEN 0 34 #define OPTEE_MRF_CREATE 1 35 #define OPTEE_MRF_CLOSE 2 36 #define OPTEE_MRF_READ 3 37 #define OPTEE_MRF_WRITE 4 38 #define OPTEE_MRF_TRUNCATE 5 39 #define OPTEE_MRF_REMOVE 6 40 #define OPTEE_MRF_RENAME 7 41 #define OPTEE_MRF_OPENDIR 8 42 #define OPTEE_MRF_CLOSEDIR 9 43 #define OPTEE_MRF_READDIR 10 44 45 /* 46 * Open flags, defines shared with TEE. 47 */ 48 #define TEE_FS_O_RDONLY 0x1 49 #define TEE_FS_O_WRONLY 0x2 50 #define TEE_FS_O_RDWR 0x4 51 #define TEE_FS_O_CREAT 0x8 52 #define TEE_FS_O_EXCL 0x10 53 #define TEE_FS_O_APPEND 0x20 54 55 /* 56 * Seek flags, defines shared with TEE. 57 */ 58 #define TEE_FS_SEEK_SET 0x1 59 #define TEE_FS_SEEK_END 0x2 60 #define TEE_FS_SEEK_CUR 0x4 61 62 /* 63 * Mkdir flags, defines shared with TEE. 64 */ 65 #define TEE_FS_S_IWUSR 0x1 66 #define TEE_FS_S_IRUSR 0x2 67 68 /* 69 * Access flags, X_OK not supported, defines shared with TEE. 70 */ 71 #define TEE_FS_R_OK 0x1 72 #define TEE_FS_W_OK 0x2 73 #define TEE_FS_F_OK 0x4 74 75 #define RK_FS_R 0x1 76 #define RK_FS_W 0x2 77 #define RK_FS_D 0x8 78 79 #define TEE_IOCTL_PARAM_ATTR_TYPE_MASK 0xff 80 #define TEE_IOCTL_PARAM_ATTR_TYPE_VALUE_INPUT 1 81 #define TEE_IOCTL_PARAM_ATTR_TYPE_VALUE_OUTPUT 2 82 #define TEE_IOCTL_PARAM_ATTR_TYPE_VALUE_INOUT 3 /* input and output */ 83 84 #define TEE_IOCTL_PARAM_ATTR_TYPE_MEMREF_INPUT 5 85 #define TEE_IOCTL_PARAM_ATTR_TYPE_MEMREF_OUTPUT 6 86 #define TEE_IOCTL_PARAM_ATTR_TYPE_MEMREF_INOUT 7 /* input and output */ 87 88 struct tee_ioctl_param_memref { 89 uint64_t shm_offs; 90 uint64_t size; 91 int64_t shm_id; 92 }; 93 94 struct tee_ioctl_param_value { 95 uint64_t a; 96 uint64_t b; 97 uint64_t c; 98 }; 99 100 struct tee_ioctl_param { 101 uint64_t attr; 102 union { 103 struct tee_ioctl_param_memref memref; 104 struct tee_ioctl_param_value value; 105 } u; 106 }; 107 108 /* Function Defines */ 109 #define UNREFERENCED_PARAMETER(P) (P = P) 110 #define CHECKFLAG(flags, flag) (flags & flag) 111 #define ADDFLAG(flags, flag) (flags | flag) 112 113 #define RKSS_VERSION_V1 1 114 #define RKSS_VERSION_V2 2 115 #define RKSS_VERSION_ERR 100 116 117 int tee_supp_rk_fs_init_v1(void); 118 119 int tee_supp_rk_fs_process_v1(size_t num_params, 120 struct tee_ioctl_param *params); 121 122 int tee_supp_rk_fs_init_v2(void); 123 124 int tee_supp_rk_fs_process_v2(size_t num_params, 125 struct tee_ioctl_param *params); 126 127 int OpteeClientRkFsInit(void); 128 129 int OpteeClientRkFsProcess(size_t num_params, 130 struct tee_ioctl_param *params); 131 132 #endif 133