xref: /rk3399_ARM-atf/include/lib/xlat_tables/xlat_mmu_helpers.h (revision 0cc7aa896465ad7ecd8c253a4dc970508d96724c)
17bb01fb2SAntonio Nino Diaz /*
2883d1b5dSAntonio Nino Diaz  * Copyright (c) 2014-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 
77bb01fb2SAntonio Nino Diaz #ifndef __XLAT_MMU_HELPERS_H__
87bb01fb2SAntonio Nino Diaz #define __XLAT_MMU_HELPERS_H__
97bb01fb2SAntonio Nino Diaz 
10883d1b5dSAntonio Nino Diaz /*
11883d1b5dSAntonio Nino Diaz  * The following flags are passed to enable_mmu_xxx() to override the default
12883d1b5dSAntonio Nino Diaz  * values used to program system registers while enabling the MMU.
13883d1b5dSAntonio Nino Diaz  */
14883d1b5dSAntonio Nino Diaz 
15883d1b5dSAntonio Nino Diaz /*
16883d1b5dSAntonio Nino Diaz  * When this flag is used, all data access to Normal memory from this EL and all
17883d1b5dSAntonio Nino Diaz  * Normal memory accesses to the translation tables of this EL are non-cacheable
18883d1b5dSAntonio Nino Diaz  * for all levels of data and unified cache until the caches are enabled by
19883d1b5dSAntonio Nino Diaz  * setting the bit SCTLR_ELx.C.
20883d1b5dSAntonio Nino Diaz  */
21883d1b5dSAntonio Nino Diaz #define DISABLE_DCACHE			(U(1) << 0)
22883d1b5dSAntonio Nino Diaz 
23883d1b5dSAntonio Nino Diaz /*
24883d1b5dSAntonio Nino Diaz  * Mark the translation tables as non-cacheable for the MMU table walker, which
25883d1b5dSAntonio Nino Diaz  * is a different observer from the PE/CPU. If the flag is not specified, the
26883d1b5dSAntonio Nino Diaz  * tables are cacheable for the MMU table walker.
27883d1b5dSAntonio Nino Diaz  *
28883d1b5dSAntonio Nino Diaz  * Note that, as far as the PE/CPU observer is concerned, the attributes used
29883d1b5dSAntonio Nino Diaz  * are the ones specified in the translation tables themselves. The MAIR
30883d1b5dSAntonio Nino Diaz  * register specifies the cacheability through the field AttrIndx of the lower
31883d1b5dSAntonio Nino Diaz  * attributes of the translation tables. The shareability is specified in the SH
32883d1b5dSAntonio Nino Diaz  * field of the lower attributes.
33883d1b5dSAntonio Nino Diaz  *
34883d1b5dSAntonio Nino Diaz  * The MMU table walker uses the attributes specified in the fields ORGNn, IRGNn
35883d1b5dSAntonio Nino Diaz  * and SHn of the TCR register to access the translation tables.
36883d1b5dSAntonio Nino Diaz  *
37883d1b5dSAntonio Nino Diaz  * The attributes specified in the TCR register and the tables can be different
38883d1b5dSAntonio Nino Diaz  * as there are no checks to prevent that. Special care must be taken to ensure
39883d1b5dSAntonio Nino Diaz  * that there aren't mismatches. The behaviour in that case is described in the
40883d1b5dSAntonio Nino Diaz  * sections 'Mismatched memory attributes' in the ARMv8 ARM.
41883d1b5dSAntonio Nino Diaz  */
42883d1b5dSAntonio Nino Diaz #define XLAT_TABLE_NC			(U(1) << 1)
43883d1b5dSAntonio Nino Diaz 
44883d1b5dSAntonio Nino Diaz #ifndef __ASSEMBLY__
45883d1b5dSAntonio Nino Diaz 
46a0b9bb79SAntonio Nino Diaz #include <sys/types.h>
47a0b9bb79SAntonio Nino Diaz 
487bb01fb2SAntonio Nino Diaz #ifdef AARCH32
497bb01fb2SAntonio Nino Diaz /* AArch32 specific translation table API */
50883d1b5dSAntonio Nino Diaz void enable_mmu_secure(unsigned int flags);
51*0cc7aa89SJeenu Viswambharan 
52*0cc7aa89SJeenu Viswambharan void enable_mmu_direct(unsigned int flags);
537bb01fb2SAntonio Nino Diaz #else
547bb01fb2SAntonio Nino Diaz /* AArch64 specific translation table APIs */
557bb01fb2SAntonio Nino Diaz void enable_mmu_el1(unsigned int flags);
567bb01fb2SAntonio Nino Diaz void enable_mmu_el3(unsigned int flags);
57*0cc7aa89SJeenu Viswambharan 
58*0cc7aa89SJeenu Viswambharan void enable_mmu_direct_el1(unsigned int flags);
59*0cc7aa89SJeenu Viswambharan void enable_mmu_direct_el3(unsigned int flags);
607bb01fb2SAntonio Nino Diaz #endif /* AARCH32 */
617bb01fb2SAntonio Nino Diaz 
62a0b9bb79SAntonio Nino Diaz int xlat_arch_is_granule_size_supported(size_t size);
63a0b9bb79SAntonio Nino Diaz size_t xlat_arch_get_max_supported_granule_size(void);
64a0b9bb79SAntonio Nino Diaz 
65883d1b5dSAntonio Nino Diaz #endif /* __ASSEMBLY__ */
66883d1b5dSAntonio Nino Diaz 
677bb01fb2SAntonio Nino Diaz #endif /* __XLAT_MMU_HELPERS_H__ */
68