xlat_mmu_helpers.h 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /*
  2. * Copyright (c) 2014-2018, Arm Limited and Contributors. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #ifndef XLAT_MMU_HELPERS_H
  7. #define XLAT_MMU_HELPERS_H
  8. /*
  9. * The following flags are passed to enable_mmu_xxx() to override the default
  10. * values used to program system registers while enabling the MMU.
  11. */
  12. /*
  13. * When this flag is used, all data access to Normal memory from this EL and all
  14. * Normal memory accesses to the translation tables of this EL are non-cacheable
  15. * for all levels of data and unified cache until the caches are enabled by
  16. * setting the bit SCTLR_ELx.C.
  17. */
  18. #define DISABLE_DCACHE (U(1) << 0)
  19. /*
  20. * Mark the translation tables as non-cacheable for the MMU table walker, which
  21. * is a different observer from the PE/CPU. If the flag is not specified, the
  22. * tables are cacheable for the MMU table walker.
  23. *
  24. * Note that, as far as the PE/CPU observer is concerned, the attributes used
  25. * are the ones specified in the translation tables themselves. The MAIR
  26. * register specifies the cacheability through the field AttrIndx of the lower
  27. * attributes of the translation tables. The shareability is specified in the SH
  28. * field of the lower attributes.
  29. *
  30. * The MMU table walker uses the attributes specified in the fields ORGNn, IRGNn
  31. * and SHn of the TCR register to access the translation tables.
  32. *
  33. * The attributes specified in the TCR register and the tables can be different
  34. * as there are no checks to prevent that. Special care must be taken to ensure
  35. * that there aren't mismatches. The behaviour in that case is described in the
  36. * sections 'Mismatched memory attributes' in the ARMv8 ARM.
  37. */
  38. #define XLAT_TABLE_NC (U(1) << 1)
  39. /*
  40. * Offsets into a mmu_cfg_params array generated by setup_mmu_cfg(). All
  41. * parameters are 64 bits wide.
  42. */
  43. #define MMU_CFG_MAIR 0
  44. #define MMU_CFG_TCR 1
  45. #define MMU_CFG_TTBR0 2
  46. #define MMU_CFG_PARAM_MAX 3
  47. #ifndef __ASSEMBLER__
  48. #include <stdbool.h>
  49. #include <stdint.h>
  50. #include <string.h>
  51. #include <arch_helpers.h>
  52. /*
  53. * Return the values that the MMU configuration registers must contain for the
  54. * specified translation context. `params` must be a pointer to array of size
  55. * MMU_CFG_PARAM_MAX.
  56. */
  57. void setup_mmu_cfg(uint64_t *params, unsigned int flags,
  58. const uint64_t *base_table, unsigned long long max_pa,
  59. uintptr_t max_va, int xlat_regime);
  60. #ifdef __aarch64__
  61. /* AArch64 specific translation table APIs */
  62. void enable_mmu_el1(unsigned int flags);
  63. void enable_mmu_el2(unsigned int flags);
  64. void enable_mmu_el3(unsigned int flags);
  65. void enable_mmu(unsigned int flags);
  66. void enable_mmu_direct_el1(unsigned int flags);
  67. void enable_mmu_direct_el2(unsigned int flags);
  68. void enable_mmu_direct_el3(unsigned int flags);
  69. #else
  70. /* AArch32 specific translation table API */
  71. void enable_mmu_svc_mon(unsigned int flags);
  72. void enable_mmu_hyp(unsigned int flags);
  73. void enable_mmu_direct_svc_mon(unsigned int flags);
  74. void enable_mmu_direct_hyp(unsigned int flags);
  75. #endif /* __aarch64__ */
  76. bool xlat_arch_is_granule_size_supported(size_t size);
  77. size_t xlat_arch_get_max_supported_granule_size(void);
  78. #endif /* __ASSEMBLER__ */
  79. #endif /* XLAT_MMU_HELPERS_H */