11bb92983SJerome Forissier /* SPDX-License-Identifier: BSD-2-Clause */ 2b0104773SPascal Brand /* 3b0104773SPascal Brand * Copyright (c) 2014, STMicroelectronics International N.V. 4b0104773SPascal Brand */ 5b0104773SPascal Brand 6b0104773SPascal Brand #ifndef TEE_INTERNAL_API_EXTENSIONS_H 7b0104773SPascal Brand #define TEE_INTERNAL_API_EXTENSIONS_H 8b0104773SPascal Brand 9b0104773SPascal Brand /* trace support */ 104de4bebcSJens Wiklander #include <trace.h> 11cebdec51SJens Wiklander #include <stdio.h> 12dd3247beSEtienne Carriere #include <tee_api_defines_extensions.h> 13fa530828SPascal Brand #include <tee_api_types.h> 14b0104773SPascal Brand 15b0104773SPascal Brand void tee_user_mem_mark_heap(void); 16b0104773SPascal Brand size_t tee_user_mem_check_heap(void); 17b0104773SPascal Brand /* Hint implementation defines */ 18b0104773SPascal Brand #define TEE_USER_MEM_HINT_NO_FILL_ZERO 0x80000000 19b0104773SPascal Brand 20fa530828SPascal Brand /* 21fa530828SPascal Brand * Cache maintenance support (TA requires the CACHE_MAINTENANCE property) 22fa530828SPascal Brand * 23fa530828SPascal Brand * TEE_CacheClean() Write back to memory any dirty data cache lines. The line 24fa530828SPascal Brand * is marked as not dirty. The valid bit is unchanged. 25fa530828SPascal Brand * 26fa530828SPascal Brand * TEE_CacheFlush() Purges any valid data cache lines. Any dirty cache lines 27fa530828SPascal Brand * are first written back to memory, then the cache line is 28fa530828SPascal Brand * invalidated. 29fa530828SPascal Brand * 30fa530828SPascal Brand * TEE_CacheInvalidate() Invalidate any valid data cache lines. Any dirty line 31fa530828SPascal Brand * are not written back to memory. 32fa530828SPascal Brand */ 33fa530828SPascal Brand TEE_Result TEE_CacheClean(char *buf, size_t len); 34fa530828SPascal Brand TEE_Result TEE_CacheFlush(char *buf, size_t len); 35fa530828SPascal Brand TEE_Result TEE_CacheInvalidate(char *buf, size_t len); 36fa530828SPascal Brand 3787065172SJens Wiklander /* 3887065172SJens Wiklander * tee_map_zi() - Map zero initialized memory 3987065172SJens Wiklander * @len: Number of bytes 4087065172SJens Wiklander * @flags: 0 or TEE_MEMORY_ACCESS_ANY_OWNER to allow sharing with other TAs 4187065172SJens Wiklander * 4287065172SJens Wiklander * Returns valid pointer on success or NULL on error. 4387065172SJens Wiklander */ 4487065172SJens Wiklander void *tee_map_zi(size_t len, uint32_t flags); 4587065172SJens Wiklander 4687065172SJens Wiklander /* 4787065172SJens Wiklander * tee_unmap() - Unmap previously mapped memory 4887065172SJens Wiklander * @buf: Buffer 4987065172SJens Wiklander * @len: Number of bytes 5087065172SJens Wiklander * 5187065172SJens Wiklander * Note that supplied @buf and @len has to match exactly what has 5287065172SJens Wiklander * previously been returned by tee_map_zi(). 5387065172SJens Wiklander * 5487065172SJens Wiklander * Return TEE_SUCCESS on success or TEE_ERRROR_* on failure. 5587065172SJens Wiklander */ 5687065172SJens Wiklander TEE_Result tee_unmap(void *buf, size_t len); 5787065172SJens Wiklander 58*791ee55cSJerome Forissier /* 59*791ee55cSJerome Forissier * Convert a UUID string @s into a TEE_UUID @uuid 60*791ee55cSJerome Forissier * Expected format for @s is: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx 61*791ee55cSJerome Forissier * 'x' being any hexadecimal digit (0-9a-fA-F) 62*791ee55cSJerome Forissier */ 63*791ee55cSJerome Forissier TEE_Result tee_uuid_from_str(TEE_UUID *uuid, const char *s); 64*791ee55cSJerome Forissier 65b0104773SPascal Brand #endif 66