xref: /rk3399_ARM-atf/lib/xlat_tables_v2/xlat_tables_private.h (revision cedfa04ba58841b5c547b409e435c0bdafa4c912)
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 
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 
430b64f4efSAntonio Nino Diaz /*
44468e2382SAntonio Nino Diaz  * Return the execute-never mask that will prevent instruction fetch at the
45468e2382SAntonio Nino Diaz  * given translation regime.
46468e2382SAntonio Nino Diaz  */
47468e2382SAntonio Nino Diaz uint64_t xlat_arch_regime_get_xn_desc(int xlat_regime);
48468e2382SAntonio Nino Diaz 
49468e2382SAntonio Nino Diaz /*
50b4ae615bSDouglas Raillard  * Invalidate all TLB entries that match the given virtual address. This
51b4ae615bSDouglas Raillard  * operation applies to all PEs in the same Inner Shareable domain as the PE
52b4ae615bSDouglas Raillard  * that executes this function. This functions must be called for every
538d164bc6SAntonio Nino Diaz  * translation table entry that is modified. It only affects the specified
548d164bc6SAntonio Nino Diaz  * translation regime.
55b4ae615bSDouglas Raillard  *
56b4ae615bSDouglas Raillard  * Note, however, that it is architecturally UNDEFINED to invalidate TLB entries
57b4ae615bSDouglas Raillard  * pertaining to a higher exception level, e.g. invalidating EL3 entries from
58b4ae615bSDouglas Raillard  * S-EL1.
590b64f4efSAntonio Nino Diaz  */
608d164bc6SAntonio Nino Diaz void xlat_arch_tlbi_va(uintptr_t va, int xlat_regime);
610b64f4efSAntonio Nino Diaz 
620b64f4efSAntonio Nino Diaz /*
630b64f4efSAntonio Nino Diaz  * This function has to be called at the end of any code that uses the function
640b64f4efSAntonio Nino Diaz  * xlat_arch_tlbi_va().
650b64f4efSAntonio Nino Diaz  */
660b64f4efSAntonio Nino Diaz void xlat_arch_tlbi_va_sync(void);
670b64f4efSAntonio Nino Diaz 
687bb01fb2SAntonio Nino Diaz /* Print VA, PA, size and attributes of all regions in the mmap array. */
69e7b9886cSAntonio Nino Diaz void xlat_mmap_print(const mmap_region_t *mmap);
707bb01fb2SAntonio Nino Diaz 
717bb01fb2SAntonio Nino Diaz /*
727bb01fb2SAntonio Nino Diaz  * Print the current state of the translation tables by reading them from
737bb01fb2SAntonio Nino Diaz  * memory.
747bb01fb2SAntonio Nino Diaz  */
757bb01fb2SAntonio Nino Diaz void xlat_tables_print(xlat_ctx_t *ctx);
767bb01fb2SAntonio Nino Diaz 
777bb01fb2SAntonio Nino Diaz /*
78fd2299e6SAntonio Nino Diaz  * Returns a block/page table descriptor for the given level and attributes.
79fd2299e6SAntonio Nino Diaz  */
80fd2299e6SAntonio Nino Diaz uint64_t xlat_desc(const xlat_ctx_t *ctx, uint32_t attr,
81e7b9886cSAntonio Nino Diaz 		   unsigned long long addr_pa, unsigned int level);
82fd2299e6SAntonio Nino Diaz 
83fd2299e6SAntonio Nino Diaz /*
847bb01fb2SAntonio Nino Diaz  * Architecture-specific initialization code.
857bb01fb2SAntonio Nino Diaz  */
867bb01fb2SAntonio Nino Diaz 
87a5640252SAntonio Nino Diaz /* Returns the current Exception Level. The returned EL must be 1 or higher. */
88e7b9886cSAntonio Nino Diaz unsigned int xlat_arch_current_el(void);
89a5640252SAntonio Nino Diaz 
90a5640252SAntonio Nino Diaz /*
9199f60798SSandrine Bailleux  * Return the maximum physical address supported by the hardware.
9299f60798SSandrine Bailleux  * This value depends on the execution state (AArch32/AArch64).
9399f60798SSandrine Bailleux  */
9499f60798SSandrine Bailleux unsigned long long xlat_arch_get_max_supported_pa(void);
957bb01fb2SAntonio Nino Diaz 
96609c9191SAntonio Nino Diaz /*
975b395e37SAntonio Nino Diaz  * Returns true if the MMU of the translation regime managed by the given
985b395e37SAntonio Nino Diaz  * xlat_ctx_t is enabled, false otherwise.
99609c9191SAntonio Nino Diaz  */
1005b395e37SAntonio Nino Diaz bool is_mmu_enabled_ctx(const xlat_ctx_t *ctx);
1017bb01fb2SAntonio Nino Diaz 
1023e318e40SAntonio Nino Diaz /* Returns true if the data cache is enabled at the current EL. */
1033e318e40SAntonio Nino Diaz bool is_dcache_enabled(void);
1043e318e40SAntonio Nino Diaz 
105*cedfa04bSSathees Balya /*
106*cedfa04bSSathees Balya  * Returns minimum virtual address space size supported by the architecture
107*cedfa04bSSathees Balya  */
108*cedfa04bSSathees Balya uintptr_t xlat_get_min_virt_addr_space_size(void);
109*cedfa04bSSathees Balya 
110e7b9886cSAntonio Nino Diaz #endif /* XLAT_TABLES_PRIVATE_H */
111