xref: /OK3568_Linux_fs/u-boot/include/optee_include/OpteeClientRkFs.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
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 #include <stddef.h>
31 
32 /*
33  * Operations and defines shared with TEE.
34  */
35 #define TEE_FS_OPEN       1
36 #define TEE_FS_CLOSE      2
37 #define TEE_FS_READ       3
38 #define TEE_FS_WRITE      4
39 #define TEE_FS_SEEK       5
40 #define TEE_FS_UNLINK     6
41 #define TEE_FS_RENAME     7
42 #define TEE_FS_TRUNC      8
43 #define TEE_FS_MKDIR      9
44 #define TEE_FS_OPENDIR   10
45 #define TEE_FS_CLOSEDIR  11
46 #define TEE_FS_READDIR   12
47 #define TEE_FS_RMDIR     13
48 #define TEE_FS_ACCESS    14
49 #define TEE_FS_LINK      15
50 
51 /*
52  * Open flags, defines shared with TEE.
53  */
54 #define TEE_FS_O_RDONLY 0x1
55 #define TEE_FS_O_WRONLY 0x2
56 #define TEE_FS_O_RDWR   0x4
57 #define TEE_FS_O_CREAT  0x8
58 #define TEE_FS_O_EXCL   0x10
59 #define TEE_FS_O_APPEND 0x20
60 
61 /*
62  * Seek flags, defines shared with TEE.
63  */
64 #define TEE_FS_SEEK_SET 0x1
65 #define TEE_FS_SEEK_END 0x2
66 #define TEE_FS_SEEK_CUR 0x4
67 
68 /*
69  * Mkdir flags, defines shared with TEE.
70  */
71 #define TEE_FS_S_IWUSR 0x1
72 #define TEE_FS_S_IRUSR 0x2
73 
74 /*
75  * Access flags, X_OK not supported, defines shared with TEE.
76  */
77 #define TEE_FS_R_OK    0x1
78 #define TEE_FS_W_OK    0x2
79 #define TEE_FS_F_OK    0x4
80 
81 #define RK_FS_R    0x1
82 #define RK_FS_W    0x2
83 #define RK_FS_D    0x8
84 
85 /* Function Defines */
86 #define UNREFERENCED_PARAMETER(P) (P = P)
87 #define CHECKFLAG(flags, flag) (flags & flag)
88 #define ADDFLAG(flags, flag) (flags | flag)
89 
90 #define RKSS_VERSION_V1			1
91 #define RKSS_VERSION_V2			2
92 #define RKSS_VERSION_ERR			100
93 
94 /*
95  * Structure for file related RPC calls
96  *
97  * @op     The operation like open, close, read, write etc
98  * @flags  Flags to the operation shared with secure world
99  * @arg    Argument to operation
100  * @fd     NW file descriptor
101  * @len    Length of buffer at the end of this struct
102  * @res    Result of the operation
103  */
104 struct tee_fs_rpc {
105 	int op;
106 	int flags;
107 	int arg;
108 	int fd;
109 	uint32_t len;
110 	int res;
111 };
112 
113 int tee_supp_rk_fs_init_v1(void);
114 
115 int tee_supp_rk_fs_process_v1(void *cmd, size_t cmd_size);
116 
117 int tee_supp_rk_fs_init_v2(void);
118 
119 int tee_supp_rk_fs_process_v2(void *cmd, size_t cmd_size);
120 
121 int OpteeClientRkFsInit(void);
122 
123 int OpteeClientRkFsProcess(void *cmd, size_t cmd_size);
124 
125 #endif
126