xref: /rk3399_ARM-atf/lib/xlat_tables_v2/xlat_tables_private.h (revision 5b395e37465aa12a3249a6ab1dd776f89dc16d05)
17bb01fb2SAntonio Nino Diaz /*
29fb8af33SRoberto Vargas  * Copyright (c) 2017-2018, 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 
107bb01fb2SAntonio Nino Diaz #include <platform_def.h>
11*5b395e37SAntonio Nino Diaz #include <stdbool.h>
128933c34bSSandrine Bailleux #include <xlat_tables_defs.h>
137bb01fb2SAntonio Nino Diaz 
140b64f4efSAntonio Nino Diaz #if PLAT_XLAT_TABLES_DYNAMIC
150b64f4efSAntonio Nino Diaz /*
163a1b7b10SAntonio Nino Diaz  * Private shifts and masks to access fields of an mmap attribute
170b64f4efSAntonio Nino Diaz  */
180b64f4efSAntonio Nino Diaz /* Dynamic or static */
193a1b7b10SAntonio Nino Diaz #define MT_DYN_SHIFT		U(31)
200b64f4efSAntonio Nino Diaz 
210b64f4efSAntonio Nino Diaz /*
220b64f4efSAntonio Nino Diaz  * Memory mapping private attributes
230b64f4efSAntonio Nino Diaz  *
243a1b7b10SAntonio Nino Diaz  * Private attributes not exposed in the public header.
250b64f4efSAntonio Nino Diaz  */
263a1b7b10SAntonio Nino Diaz 
270b64f4efSAntonio Nino Diaz /*
280b64f4efSAntonio Nino Diaz  * Regions mapped before the MMU can't be unmapped dynamically (they are
290b64f4efSAntonio Nino Diaz  * static) and regions mapped with MMU enabled can be unmapped. This
300b64f4efSAntonio Nino Diaz  * behaviour can't be overridden.
310b64f4efSAntonio Nino Diaz  *
320b64f4efSAntonio Nino Diaz  * Static regions can overlap each other, dynamic regions can't.
330b64f4efSAntonio Nino Diaz  */
343a1b7b10SAntonio Nino Diaz #define MT_STATIC	(U(0) << MT_DYN_SHIFT)
353a1b7b10SAntonio Nino Diaz #define MT_DYNAMIC	(U(1) << MT_DYN_SHIFT)
360b64f4efSAntonio Nino Diaz 
37f301da44SSandrine Bailleux #endif /* PLAT_XLAT_TABLES_DYNAMIC */
38f301da44SSandrine Bailleux 
39e7b9886cSAntonio Nino Diaz extern uint64_t mmu_cfg_params[MMU_CFG_PARAM_MAX];
40e7b9886cSAntonio Nino Diaz 
410b64f4efSAntonio Nino Diaz /*
42468e2382SAntonio Nino Diaz  * Return the execute-never mask that will prevent instruction fetch at the
43468e2382SAntonio Nino Diaz  * given translation regime.
44468e2382SAntonio Nino Diaz  */
45468e2382SAntonio Nino Diaz uint64_t xlat_arch_regime_get_xn_desc(int xlat_regime);
46468e2382SAntonio Nino Diaz 
47468e2382SAntonio Nino Diaz /*
48b4ae615bSDouglas Raillard  * Invalidate all TLB entries that match the given virtual address. This
49b4ae615bSDouglas Raillard  * operation applies to all PEs in the same Inner Shareable domain as the PE
50b4ae615bSDouglas Raillard  * that executes this function. This functions must be called for every
518d164bc6SAntonio Nino Diaz  * translation table entry that is modified. It only affects the specified
528d164bc6SAntonio Nino Diaz  * translation regime.
53b4ae615bSDouglas Raillard  *
54b4ae615bSDouglas Raillard  * Note, however, that it is architecturally UNDEFINED to invalidate TLB entries
55b4ae615bSDouglas Raillard  * pertaining to a higher exception level, e.g. invalidating EL3 entries from
56b4ae615bSDouglas Raillard  * S-EL1.
570b64f4efSAntonio Nino Diaz  */
588d164bc6SAntonio Nino Diaz void xlat_arch_tlbi_va(uintptr_t va, int xlat_regime);
590b64f4efSAntonio Nino Diaz 
600b64f4efSAntonio Nino Diaz /*
610b64f4efSAntonio Nino Diaz  * This function has to be called at the end of any code that uses the function
620b64f4efSAntonio Nino Diaz  * xlat_arch_tlbi_va().
630b64f4efSAntonio Nino Diaz  */
640b64f4efSAntonio Nino Diaz void xlat_arch_tlbi_va_sync(void);
650b64f4efSAntonio Nino Diaz 
667bb01fb2SAntonio Nino Diaz /* Print VA, PA, size and attributes of all regions in the mmap array. */
67e7b9886cSAntonio Nino Diaz void xlat_mmap_print(const mmap_region_t *mmap);
687bb01fb2SAntonio Nino Diaz 
697bb01fb2SAntonio Nino Diaz /*
707bb01fb2SAntonio Nino Diaz  * Print the current state of the translation tables by reading them from
717bb01fb2SAntonio Nino Diaz  * memory.
727bb01fb2SAntonio Nino Diaz  */
737bb01fb2SAntonio Nino Diaz void xlat_tables_print(xlat_ctx_t *ctx);
747bb01fb2SAntonio Nino Diaz 
757bb01fb2SAntonio Nino Diaz /*
76fd2299e6SAntonio Nino Diaz  * Returns a block/page table descriptor for the given level and attributes.
77fd2299e6SAntonio Nino Diaz  */
78fd2299e6SAntonio Nino Diaz uint64_t xlat_desc(const xlat_ctx_t *ctx, uint32_t attr,
79e7b9886cSAntonio Nino Diaz 		   unsigned long long addr_pa, unsigned int level);
80fd2299e6SAntonio Nino Diaz 
81fd2299e6SAntonio Nino Diaz /*
827bb01fb2SAntonio Nino Diaz  * Architecture-specific initialization code.
837bb01fb2SAntonio Nino Diaz  */
847bb01fb2SAntonio Nino Diaz 
85a5640252SAntonio Nino Diaz /* Returns the current Exception Level. The returned EL must be 1 or higher. */
86e7b9886cSAntonio Nino Diaz unsigned int xlat_arch_current_el(void);
87a5640252SAntonio Nino Diaz 
88a5640252SAntonio Nino Diaz /*
8999f60798SSandrine Bailleux  * Return the maximum physical address supported by the hardware.
9099f60798SSandrine Bailleux  * This value depends on the execution state (AArch32/AArch64).
9199f60798SSandrine Bailleux  */
9299f60798SSandrine Bailleux unsigned long long xlat_arch_get_max_supported_pa(void);
937bb01fb2SAntonio Nino Diaz 
94609c9191SAntonio Nino Diaz /*
95*5b395e37SAntonio Nino Diaz  * Returns true if the MMU of the translation regime managed by the given
96*5b395e37SAntonio Nino Diaz  * xlat_ctx_t is enabled, false otherwise.
97609c9191SAntonio Nino Diaz  */
98*5b395e37SAntonio Nino Diaz bool is_mmu_enabled_ctx(const xlat_ctx_t *ctx);
997bb01fb2SAntonio Nino Diaz 
100e7b9886cSAntonio Nino Diaz #endif /* XLAT_TABLES_PRIVATE_H */
101