1 /* SPDX-License-Identifier: BSD-2-Clause */
2 /*
3 * Copyright (c) 2024, Linaro Limited
4 */
5
6 #ifndef __MM_PHYS_MEM_H
7 #define __MM_PHYS_MEM_H
8
9 #include <mm/tee_mm.h>
10 #include <types_ext.h>
11
12 void nex_phys_mem_init(paddr_t core_base, paddr_size_t core_size,
13 paddr_t ta_base, paddr_size_t ta_size);
14 paddr_size_t nex_phys_mem_get_ta_size(void);
15 paddr_t nex_phys_mem_get_ta_base(void);
16 tee_mm_entry_t *nex_phys_mem_mm_find(paddr_t addr);
17 tee_mm_entry_t *nex_phys_mem_core_alloc(size_t size);
18 tee_mm_entry_t *nex_phys_mem_ta_alloc(size_t size);
19 tee_mm_entry_t *nex_phys_mem_alloc2(paddr_t base, size_t size);
20 void nex_phys_mem_partial_carve_out(paddr_t base, size_t size);
21 #ifdef CFG_WITH_STATS
22 void nex_phys_mem_stats(struct pta_stats_alloc *stats, bool reset);
23 #endif
24
25 #ifdef CFG_NS_VIRTUALIZATION
26 void phys_mem_init(paddr_t core_base, paddr_size_t core_size,
27 paddr_t ta_base, paddr_size_t ta_size);
28 tee_mm_entry_t *phys_mem_mm_find(paddr_t addr);
29 tee_mm_entry_t *phys_mem_core_alloc(size_t size);
30 tee_mm_entry_t *phys_mem_ta_alloc(size_t size);
31 tee_mm_entry_t *phys_mem_alloc2(paddr_t base, size_t size);
32 #ifdef CFG_WITH_STATS
33 void phys_mem_stats(struct pta_stats_alloc *stats, bool reset);
34 #endif
35 #else
phys_mem_init(paddr_t core_base,paddr_size_t core_size,paddr_t ta_base,paddr_size_t ta_size)36 static inline void phys_mem_init(paddr_t core_base, paddr_size_t core_size,
37 paddr_t ta_base, paddr_size_t ta_size)
38 {
39 nex_phys_mem_init(core_base, core_size, ta_base, ta_size);
40 }
41
phys_mem_mm_find(paddr_t addr)42 static inline tee_mm_entry_t *phys_mem_mm_find(paddr_t addr)
43 {
44 return nex_phys_mem_mm_find(addr);
45 }
46
phys_mem_core_alloc(size_t size)47 static inline tee_mm_entry_t *phys_mem_core_alloc(size_t size)
48 {
49 return nex_phys_mem_core_alloc(size);
50 }
51
phys_mem_ta_alloc(size_t size)52 static inline tee_mm_entry_t *phys_mem_ta_alloc(size_t size)
53 {
54 return nex_phys_mem_ta_alloc(size);
55 }
56
phys_mem_alloc2(paddr_t base,size_t size)57 static inline tee_mm_entry_t *phys_mem_alloc2(paddr_t base, size_t size)
58 {
59 return nex_phys_mem_alloc2(base, size);
60 }
61
62 #ifdef CFG_WITH_STATS
phys_mem_stats(struct pta_stats_alloc * stats,bool reset)63 static inline void phys_mem_stats(struct pta_stats_alloc *stats, bool reset)
64 {
65 return nex_phys_mem_stats(stats, reset);
66 }
67 #endif
68 #endif
69
70 /*
71 * MAF_NEX selects nexus physical memory
72 * MAF_CORE_MEM selects core physical memory
73 * flags are passed on underlying implementation, tee_mm_alloc_flags().
74 */
75 tee_mm_entry_t *phys_mem_alloc_flags(size_t size, uint32_t flags);
76
77 #endif /*__MM_PHYS_MEM_H*/
78