1 /* SPDX-License-Identifier: BSD-2-Clause */
2 /*
3  * Copyright (c) 2015-2016, Linaro Limited
4  */
5 #ifndef CORE_MMU_PRIVATE_H
6 #define CORE_MMU_PRIVATE_H
7 
8 #include <mm/core_mmu.h>
9 #include <mm/tee_mmu_types.h>
10 
11 
12 void core_init_mmu(struct tee_mmap_region *mm);
13 
14 void core_mmu_set_info_table(struct core_mmu_table_info *tbl_info,
15 			     unsigned level, vaddr_t va_base, void *table);
16 void core_mmu_populate_user_map(struct core_mmu_table_info *dir_info,
17 				struct user_mode_ctx *uctx);
18 void core_mmu_map_region(struct mmu_partition *prtn,
19 			 struct tee_mmap_region *mm);
20 
core_mmap_is_end_of_table(const struct tee_mmap_region * mm)21 static inline bool core_mmap_is_end_of_table(const struct tee_mmap_region *mm)
22 {
23 	return mm->type == MEM_AREA_END;
24 }
25 
core_mmu_check_max_pa(paddr_t pa __maybe_unused)26 static inline bool core_mmu_check_max_pa(paddr_t pa __maybe_unused)
27 {
28 #if defined(ARM64)
29 	return pa <= (BIT64(CFG_CORE_ARM64_PA_BITS) - 1);
30 #elif defined(CFG_CORE_LARGE_PHYS_ADDR)
31 	return pa <= (BIT64(40) - 1);
32 #else
33 	COMPILE_TIME_ASSERT(sizeof(paddr_t) == sizeof(uint32_t));
34 	return true;
35 #endif
36 }
37 
core_mmu_check_end_pa(paddr_t pa,size_t len)38 static inline bool core_mmu_check_end_pa(paddr_t pa, size_t len)
39 {
40 	paddr_t end_pa = 0;
41 
42 	if (ADD_OVERFLOW(pa, len - 1, &end_pa))
43 		return false;
44 	return core_mmu_check_max_pa(end_pa);
45 }
46 
47 #endif /*CORE_MMU_PRIVATE_H*/
48 
49