1 /* SPDX-License-Identifier: BSD-2-Clause */
2 /*
3  * Copyright (c) 2014, STMicroelectronics International N.V.
4  * Copyright (c) 2020, Linaro Limited
5  */
6 #ifndef __KERNEL_USER_ACCESS_H
7 #define __KERNEL_USER_ACCESS_H
8 
9 #include <assert.h>
10 #include <tee_api_types.h>
11 #include <types_ext.h>
12 
13 #ifdef CFG_WITH_USER_TA
14 TEE_Result copy_from_user_private(void *kaddr, const void *uaddr, size_t len);
15 TEE_Result copy_from_user(void *kaddr, const void *uaddr, size_t len);
16 #else
copy_from_user_private(void * kaddr __unused,const void * uaddr __unused,size_t len __unused)17 static inline TEE_Result copy_from_user_private(void *kaddr __unused,
18 						const void *uaddr __unused,
19 						size_t len __unused)
20 {
21 	return TEE_ERROR_NOT_SUPPORTED;
22 }
23 
copy_from_user(void * kaddr __unused,const void * uaddr __unused,size_t len __unused)24 static inline TEE_Result copy_from_user(void *kaddr __unused,
25 					const void *uaddr __unused,
26 					size_t len __unused)
27 {
28 	return TEE_ERROR_NOT_SUPPORTED;
29 }
30 
31 #endif
32 
33 TEE_Result copy_to_user_private(void *uaddr, const void *kaddr, size_t len);
34 TEE_Result copy_to_user(void *uaddr, const void *kaddr, size_t len);
35 
36 TEE_Result copy_kaddr_to_uref(uint32_t *uref, void *kaddr);
37 
38 uint32_t kaddr_to_uref(void *kaddr);
39 vaddr_t uref_to_vaddr(uint32_t uref);
uref_to_kaddr(uint32_t uref)40 static inline void *uref_to_kaddr(uint32_t uref)
41 {
42 	return (void *)uref_to_vaddr(uref);
43 }
44 
45 #endif /*__KERNEL_USER_ACCESS_H*/
46