7e4c10e16b025056c2ce34e2aa658a32868cbe99
[platform/core/security/tef-optee_os.git] / core / include / tee / tee_svc_storage.h
1 /*
2  * Copyright (c) 2014, STMicroelectronics International N.V.
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
28 #ifndef TEE_SVC_STORAGE_H
29 #define TEE_SVC_STORAGE_H
30
31 #include <tee_api_types.h>
32 #include <kernel/tee_ta_manager.h>
33 #include <tee/tee_fs.h>
34
35 /*
36  * Persistant Object Functions
37  */
38 TEE_Result syscall_storage_obj_open(unsigned long storage_id, void *object_id,
39                         size_t object_id_len, unsigned long flags,
40                         uint32_t *obj);
41
42 TEE_Result syscall_storage_obj_create(unsigned long storage_id, void *object_id,
43                         size_t object_id_len, unsigned long flags,
44                         unsigned long attr, void *data, size_t len,
45                         uint32_t *obj);
46
47 TEE_Result syscall_storage_obj_del(unsigned long obj);
48
49 TEE_Result syscall_storage_obj_rename(unsigned long obj, void *object_id,
50                         size_t object_id_len);
51
52 /*
53  * Persistent Object Enumeration Functions
54  */
55 TEE_Result syscall_storage_alloc_enum(uint32_t *obj_enum);
56
57 TEE_Result syscall_storage_free_enum(unsigned long obj_enum);
58
59 TEE_Result syscall_storage_reset_enum(unsigned long obj_enum);
60
61 TEE_Result syscall_storage_start_enum(unsigned long obj_enum,
62                         unsigned long storage_id);
63
64 TEE_Result syscall_storage_next_enum(unsigned long obj_enum,
65                         TEE_ObjectInfo *info, void *obj_id, uint64_t *len);
66
67 /*
68  * Data Stream Access Functions
69  */
70 TEE_Result syscall_storage_obj_read(unsigned long obj, void *data, size_t len,
71                         uint64_t *count);
72
73 TEE_Result syscall_storage_obj_write(unsigned long obj, void *data,
74                         size_t len);
75
76 TEE_Result syscall_storage_obj_trunc(unsigned long obj, size_t len);
77
78 TEE_Result syscall_storage_obj_seek(unsigned long obj, int32_t offset,
79                                     unsigned long whence);
80
81 void tee_svc_storage_close_all_enum(struct user_ta_ctx *utc);
82
83 void tee_svc_storage_init(void);
84
85 char *tee_svc_storage_create_filename(struct tee_ta_session *sess,
86                                       void *object_id,
87                                       uint32_t object_id_len,
88                                       bool transient);
89
90 char *tee_svc_storage_create_dirname(struct tee_ta_session *sess);
91
92 #endif /* TEE_SVC_STORAGE_H */