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 
16 void tee_user_mem_mark_heap(void);
17 size_t tee_user_mem_check_heap(void);
18 /* Hint implementation defines */
19 #define TEE_USER_MEM_HINT_NO_FILL_ZERO       0x80000000
20 
21 /*
22  * Cache maintenance support (TA requires the CACHE_MAINTENANCE property)
23  *
24  * TEE_CacheClean() Write back to memory any dirty data cache lines. The line
25  *                  is marked as not dirty. The valid bit is unchanged.
26  *
27  * TEE_CacheFlush() Purges any valid data cache lines. Any dirty cache lines
28  *                  are first written back to memory, then the cache line is
29  *                  invalidated.
30  *
31  * TEE_CacheInvalidate() Invalidate any valid data cache lines. Any dirty line
32  *                       are not written back to memory.
33  */
34 TEE_Result TEE_CacheClean(char *buf, size_t len);
35 TEE_Result TEE_CacheFlush(char *buf, size_t len);
36 TEE_Result TEE_CacheInvalidate(char *buf, size_t len);
37 
38 /*
39  * tee_map_zi() - Map zero initialized memory
40  * @len:	Number of bytes
41  * @flags:	0 or TEE_MEMORY_ACCESS_ANY_OWNER to allow sharing with other TAs
42  *
43  * Returns valid pointer on success or NULL on error.
44  */
45 void *tee_map_zi(size_t len, uint32_t flags);
46 
47 /*
48  * tee_unmap() - Unmap previously mapped memory
49  * @buf:	Buffer
50  * @len:	Number of bytes
51  *
52  * Note that supplied @buf and @len has to match exactly what has
53  * previously been returned by tee_map_zi().
54  *
55  * Return TEE_SUCCESS on success or TEE_ERRROR_* on failure.
56  */
57 TEE_Result tee_unmap(void *buf, size_t len);
58 
59 /*
60  * Convert a UUID string @s into a TEE_UUID @uuid
61  * Expected format for @s is: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
62  * 'x' being any hexadecimal digit (0-9a-fA-F)
63  */
64 TEE_Result tee_uuid_from_str(TEE_UUID *uuid, const char *s);
65 
66 /*
67  * tee_invoke_supp_plugin() - invoke a tee-supplicant's plugin
68  * @uuid:       uuid of the plugin
69  * @cmd:        command for the plugin
70  * @sub_cmd:    subcommand for the plugin
71  * @buf:        data [for/from] the plugin [in/out]
72  * @len:        length of the input buf
73  * @outlen:     pointer to length of the output data (if they will be used)
74  *
75  * Return TEE_SUCCESS on success or TEE_ERRROR_* on failure.
76  */
77 TEE_Result tee_invoke_supp_plugin(const TEE_UUID *uuid, uint32_t cmd,
78 				  uint32_t sub_cmd, void *buf, size_t len,
79 				  size_t *outlen);
80 
81 #endif
82