xref: /rk3399_ARM-atf/lib/xlat_tables_v2/xlat_tables_private.h (revision 1d651211748cdc01b6a838925e7987572a5816e0)
17bb01fb2SAntonio Nino Diaz /*
2*36218238SZelalem Aweke  * Copyright (c) 2017-2021, Arm Limited and Contributors. All rights reserved.
37bb01fb2SAntonio Nino Diaz  *
482cb2c1aSdp-arm  * SPDX-License-Identifier: BSD-3-Clause
57bb01fb2SAntonio Nino Diaz  */
67bb01fb2SAntonio Nino Diaz 
7e7b9886cSAntonio Nino Diaz #ifndef XLAT_TABLES_PRIVATE_H
8e7b9886cSAntonio Nino Diaz #define XLAT_TABLES_PRIVATE_H
97bb01fb2SAntonio Nino Diaz 
105b395e37SAntonio Nino Diaz #include <stdbool.h>
1109d40e0eSAntonio Nino Diaz 
1209d40e0eSAntonio Nino Diaz #include <platform_def.h>
1309d40e0eSAntonio Nino Diaz 
1409d40e0eSAntonio Nino Diaz #include <lib/xlat_tables/xlat_tables_defs.h>
157bb01fb2SAntonio Nino Diaz 
160b64f4efSAntonio Nino Diaz #if PLAT_XLAT_TABLES_DYNAMIC
170b64f4efSAntonio Nino Diaz /*
183a1b7b10SAntonio Nino Diaz  * Private shifts and masks to access fields of an mmap attribute
190b64f4efSAntonio Nino Diaz  */
200b64f4efSAntonio Nino Diaz /* Dynamic or static */
213a1b7b10SAntonio Nino Diaz #define MT_DYN_SHIFT		U(31)
220b64f4efSAntonio Nino Diaz 
230b64f4efSAntonio Nino Diaz /*
240b64f4efSAntonio Nino Diaz  * Memory mapping private attributes
250b64f4efSAntonio Nino Diaz  *
263a1b7b10SAntonio Nino Diaz  * Private attributes not exposed in the public header.
270b64f4efSAntonio Nino Diaz  */
283a1b7b10SAntonio Nino Diaz 
290b64f4efSAntonio Nino Diaz /*
300b64f4efSAntonio Nino Diaz  * Regions mapped before the MMU can't be unmapped dynamically (they are
310b64f4efSAntonio Nino Diaz  * static) and regions mapped with MMU enabled can be unmapped. This
320b64f4efSAntonio Nino Diaz  * behaviour can't be overridden.
330b64f4efSAntonio Nino Diaz  *
340b64f4efSAntonio Nino Diaz  * Static regions can overlap each other, dynamic regions can't.
350b64f4efSAntonio Nino Diaz  */
363a1b7b10SAntonio Nino Diaz #define MT_STATIC	(U(0) << MT_DYN_SHIFT)
373a1b7b10SAntonio Nino Diaz #define MT_DYNAMIC	(U(1) << MT_DYN_SHIFT)
380b64f4efSAntonio Nino Diaz 
39f301da44SSandrine Bailleux #endif /* PLAT_XLAT_TABLES_DYNAMIC */
40f301da44SSandrine Bailleux 
41e7b9886cSAntonio Nino Diaz extern uint64_t mmu_cfg_params[MMU_CFG_PARAM_MAX];
42e7b9886cSAntonio Nino Diaz 
43*36218238SZelalem Aweke /* Determine the physical address space encoded in the 'attr' parameter. */
44*36218238SZelalem Aweke uint32_t xlat_arch_get_pas(uint32_t attr);
45*36218238SZelalem Aweke 
460b64f4efSAntonio Nino Diaz /*
47468e2382SAntonio Nino Diaz  * Return the execute-never mask that will prevent instruction fetch at the
48468e2382SAntonio Nino Diaz  * given translation regime.
49468e2382SAntonio Nino Diaz  */
50468e2382SAntonio Nino Diaz uint64_t xlat_arch_regime_get_xn_desc(int xlat_regime);
51468e2382SAntonio Nino Diaz 
52468e2382SAntonio Nino Diaz /*
53b4ae615bSDouglas Raillard  * Invalidate all TLB entries that match the given virtual address. This
54b4ae615bSDouglas Raillard  * operation applies to all PEs in the same Inner Shareable domain as the PE
55b4ae615bSDouglas Raillard  * that executes this function. This functions must be called for every
568d164bc6SAntonio Nino Diaz  * translation table entry that is modified. It only affects the specified
578d164bc6SAntonio Nino Diaz  * translation regime.
58b4ae615bSDouglas Raillard  *
59b4ae615bSDouglas Raillard  * Note, however, that it is architecturally UNDEFINED to invalidate TLB entries
60b4ae615bSDouglas Raillard  * pertaining to a higher exception level, e.g. invalidating EL3 entries from
61b4ae615bSDouglas Raillard  * S-EL1.
620b64f4efSAntonio Nino Diaz  */
638d164bc6SAntonio Nino Diaz void xlat_arch_tlbi_va(uintptr_t va, int xlat_regime);
640b64f4efSAntonio Nino Diaz 
650b64f4efSAntonio Nino Diaz /*
660b64f4efSAntonio Nino Diaz  * This function has to be called at the end of any code that uses the function
670b64f4efSAntonio Nino Diaz  * xlat_arch_tlbi_va().
680b64f4efSAntonio Nino Diaz  */
690b64f4efSAntonio Nino Diaz void xlat_arch_tlbi_va_sync(void);
700b64f4efSAntonio Nino Diaz 
717bb01fb2SAntonio Nino Diaz /* Print VA, PA, size and attributes of all regions in the mmap array. */
72e7b9886cSAntonio Nino Diaz void xlat_mmap_print(const mmap_region_t *mmap);
737bb01fb2SAntonio Nino Diaz 
747bb01fb2SAntonio Nino Diaz /*
757bb01fb2SAntonio Nino Diaz  * Print the current state of the translation tables by reading them from
767bb01fb2SAntonio Nino Diaz  * memory.
777bb01fb2SAntonio Nino Diaz  */
787bb01fb2SAntonio Nino Diaz void xlat_tables_print(xlat_ctx_t *ctx);
797bb01fb2SAntonio Nino Diaz 
807bb01fb2SAntonio Nino Diaz /*
81fd2299e6SAntonio Nino Diaz  * Returns a block/page table descriptor for the given level and attributes.
82fd2299e6SAntonio Nino Diaz  */
83fd2299e6SAntonio Nino Diaz uint64_t xlat_desc(const xlat_ctx_t *ctx, uint32_t attr,
84e7b9886cSAntonio Nino Diaz 		   unsigned long long addr_pa, unsigned int level);
85fd2299e6SAntonio Nino Diaz 
86fd2299e6SAntonio Nino Diaz /*
877bb01fb2SAntonio Nino Diaz  * Architecture-specific initialization code.
887bb01fb2SAntonio Nino Diaz  */
897bb01fb2SAntonio Nino Diaz 
90a5640252SAntonio Nino Diaz /* Returns the current Exception Level. The returned EL must be 1 or higher. */
91e7b9886cSAntonio Nino Diaz unsigned int xlat_arch_current_el(void);
92a5640252SAntonio Nino Diaz 
93a5640252SAntonio Nino Diaz /*
9499f60798SSandrine Bailleux  * Return the maximum physical address supported by the hardware.
9599f60798SSandrine Bailleux  * This value depends on the execution state (AArch32/AArch64).
9699f60798SSandrine Bailleux  */
9799f60798SSandrine Bailleux unsigned long long xlat_arch_get_max_supported_pa(void);
987bb01fb2SAntonio Nino Diaz 
99609c9191SAntonio Nino Diaz /*
1005b395e37SAntonio Nino Diaz  * Returns true if the MMU of the translation regime managed by the given
1015b395e37SAntonio Nino Diaz  * xlat_ctx_t is enabled, false otherwise.
102609c9191SAntonio Nino Diaz  */
1035b395e37SAntonio Nino Diaz bool is_mmu_enabled_ctx(const xlat_ctx_t *ctx);
1047bb01fb2SAntonio Nino Diaz 
105cedfa04bSSathees Balya /*
106cedfa04bSSathees Balya  * Returns minimum virtual address space size supported by the architecture
107cedfa04bSSathees Balya  */
108cedfa04bSSathees Balya uintptr_t xlat_get_min_virt_addr_space_size(void);
109cedfa04bSSathees Balya 
110e7b9886cSAntonio Nino Diaz #endif /* XLAT_TABLES_PRIVATE_H */
111