xref: /optee_os/lib/libutee/include/tee_internal_api_extensions.h (revision b462a51c9c748df753cb823ce33c58f7bb28ba98)
1 /* SPDX-License-Identifier: BSD-2-Clause */
2 /*
3  * Copyright (c) 2014, STMicroelectronics International N.V.
4  * Copyright (c) 2020, Open Mobile Platform LLC
5  */
6 
7 #ifndef TEE_INTERNAL_API_EXTENSIONS_H
8 #define TEE_INTERNAL_API_EXTENSIONS_H
9 
10 /* trace support */
11 #include <trace.h>
12 #include <stdio.h>
13 #include <tee_api_defines_extensions.h>
14 #include <tee_api_types.h>
15 #include <types_ext.h>
16 
17 void tee_user_mem_mark_heap(void);
18 size_t tee_user_mem_check_heap(void);
19 /* Hint implementation defines */
20 #define TEE_USER_MEM_HINT_NO_FILL_ZERO       0x80000000
21 
22 /*
23  * Cache maintenance support (TA requires the CACHE_MAINTENANCE property)
24  *
25  * TEE_CacheClean() Write back to memory any dirty data cache lines. The line
26  *                  is marked as not dirty. The valid bit is unchanged.
27  *
28  * TEE_CacheFlush() Purges any valid data cache lines. Any dirty cache lines
29  *                  are first written back to memory, then the cache line is
30  *                  invalidated.
31  *
32  * TEE_CacheInvalidate() Invalidate any valid data cache lines. Any dirty line
33  *                       are not written back to memory.
34  */
35 TEE_Result TEE_CacheClean(char *buf, size_t len);
36 TEE_Result TEE_CacheFlush(char *buf, size_t len);
37 TEE_Result TEE_CacheInvalidate(char *buf, size_t len);
38 
39 /*
40  * tee_map_zi() - Map zero initialized memory
41  * @len:	Number of bytes
42  * @flags:	0 or TEE_MEMORY_ACCESS_ANY_OWNER to allow sharing with other TAs
43  *
44  * Returns valid pointer on success or NULL on error.
45  */
46 void *tee_map_zi(size_t len, uint32_t flags);
47 
48 /*
49  * tee_map_zi_va() - Map zero initialized memory with hint va
50  * @va		Hint address for the mapping
51  * @len:	Number of bytes
52  * @flags:	0 or TEE_MEMORY_ACCESS_ANY_OWNER to allow sharing with other TAs
53  *
54  * Returns valid pointer on success or NULL on error.
55  */
56 void *tee_map_zi_va(vaddr_t va, size_t len, uint32_t flags);
57 
58 /*
59  * tee_unmap() - Unmap previously mapped memory
60  * @buf:	Buffer
61  * @len:	Number of bytes
62  *
63  * Note that supplied @buf and @len has to match exactly what has
64  * previously been returned by tee_map_zi().
65  *
66  * Return TEE_SUCCESS on success or TEE_ERRROR_* on failure.
67  */
68 TEE_Result tee_unmap(void *buf, size_t len);
69 
70 /*
71  * Convert a UUID string @s into a TEE_UUID @uuid
72  * Expected format for @s is: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
73  * 'x' being any hexadecimal digit (0-9a-fA-F)
74  */
75 TEE_Result tee_uuid_from_str(TEE_UUID *uuid, const char *s);
76 
77 /*
78  * tee_invoke_supp_plugin() - invoke a tee-supplicant's plugin
79  * @uuid:       uuid of the plugin
80  * @cmd:        command for the plugin
81  * @sub_cmd:    subcommand for the plugin
82  * @buf:        data [for/from] the plugin [in/out]
83  * @len:        length of the input buf
84  * @outlen:     pointer to length of the output data (if they will be used)
85  *
86  * Return TEE_SUCCESS on success or TEE_ERRROR_* on failure.
87  */
88 TEE_Result tee_invoke_supp_plugin(const TEE_UUID *uuid, uint32_t cmd,
89 				  uint32_t sub_cmd, void *buf, size_t len,
90 				  size_t *outlen);
91 
92 #endif
93