Commit 63ddbae3 authored by Antonio Nino Diaz's avatar Antonio Nino Diaz
Browse files

xlat v2: Make setup_mmu_config public



This allows other parts of the code to reuse it. No functional changes.

Change-Id: Ib052ae235c422d9179958bd3016c3e678779ae9b
Signed-off-by: default avatarAntonio Nino Diaz <antonio.ninodiaz@arm.com>
parent 6563c0be
...@@ -41,10 +41,28 @@ ...@@ -41,10 +41,28 @@
*/ */
#define XLAT_TABLE_NC (U(1) << 1) #define XLAT_TABLE_NC (U(1) << 1)
/*
* Offsets into a mmu_cfg_params array generated by setup_mmu_cfg(). All
* parameters are 64 bits wide.
*/
#define MMU_CFG_MAIR 0
#define MMU_CFG_TCR 1
#define MMU_CFG_TTBR0 2
#define MMU_CFG_PARAM_MAX 3
#ifndef __ASSEMBLY__ #ifndef __ASSEMBLY__
#include <sys/types.h> #include <sys/types.h>
/*
* Return the values that the MMU configuration registers must contain for the
* specified translation context. `params` must be a pointer to array of size
* MMU_CFG_PARAM_MAX.
*/
void setup_mmu_cfg(uint64_t *params, unsigned int flags,
const uint64_t *base_table, unsigned long long max_pa,
uintptr_t max_va, int xlat_regime);
#ifdef AARCH32 #ifdef AARCH32
/* AArch32 specific translation table API */ /* AArch32 specific translation table API */
void enable_mmu_secure(unsigned int flags); void enable_mmu_secure(unsigned int flags);
......
...@@ -16,12 +16,6 @@ ...@@ -16,12 +16,6 @@
#error "Do not include this header file directly. Include xlat_tables_v2.h instead." #error "Do not include this header file directly. Include xlat_tables_v2.h instead."
#endif #endif
/* Offsets into mmu_cfg_params array. All parameters are 64 bits wide. */
#define MMU_CFG_MAIR 0
#define MMU_CFG_TCR 1
#define MMU_CFG_TTBR0 2
#define MMU_CFG_PARAM_MAX 3
#ifndef __ASSEMBLY__ #ifndef __ASSEMBLY__
#include <cassert.h> #include <cassert.h>
...@@ -30,9 +24,6 @@ ...@@ -30,9 +24,6 @@
#include <xlat_tables_arch.h> #include <xlat_tables_arch.h>
#include <xlat_tables_defs.h> #include <xlat_tables_defs.h>
/* Parameters of register values required when enabling MMU */
extern uint64_t mmu_cfg_params[MMU_CFG_PARAM_MAX];
/* Forward declaration */ /* Forward declaration */
struct mmap_region; struct mmap_region;
......
...@@ -18,8 +18,6 @@ ...@@ -18,8 +18,6 @@
#error ARMv7 target does not support LPAE MMU descriptors #error ARMv7 target does not support LPAE MMU descriptors
#endif #endif
uint64_t mmu_cfg_params[MMU_CFG_PARAM_MAX];
/* /*
* Returns 1 if the provided granule size is supported, 0 otherwise. * Returns 1 if the provided granule size is supported, 0 otherwise.
*/ */
...@@ -109,9 +107,9 @@ int xlat_arch_current_el(void) ...@@ -109,9 +107,9 @@ int xlat_arch_current_el(void)
* Function for enabling the MMU in Secure PL1, assuming that the page tables * Function for enabling the MMU in Secure PL1, assuming that the page tables
* have already been created. * have already been created.
******************************************************************************/ ******************************************************************************/
void setup_mmu_cfg(unsigned int flags, const uint64_t *base_table, void setup_mmu_cfg(uint64_t *params, unsigned int flags,
unsigned long long max_pa, uintptr_t max_va, const uint64_t *base_table, unsigned long long max_pa,
__unused int xlat_regime) uintptr_t max_va, __unused int xlat_regime)
{ {
uint64_t mair, ttbr0; uint64_t mair, ttbr0;
uint32_t ttbcr; uint32_t ttbcr;
...@@ -180,7 +178,7 @@ void setup_mmu_cfg(unsigned int flags, const uint64_t *base_table, ...@@ -180,7 +178,7 @@ void setup_mmu_cfg(unsigned int flags, const uint64_t *base_table,
#endif #endif
/* Now populate MMU configuration */ /* Now populate MMU configuration */
mmu_cfg_params[MMU_CFG_MAIR] = mair; params[MMU_CFG_MAIR] = mair;
mmu_cfg_params[MMU_CFG_TCR] = (uint64_t) ttbcr; params[MMU_CFG_TCR] = (uint64_t) ttbcr;
mmu_cfg_params[MMU_CFG_TTBR0] = ttbr0; params[MMU_CFG_TTBR0] = ttbr0;
} }
...@@ -13,8 +13,6 @@ ...@@ -13,8 +13,6 @@
#include <xlat_tables_v2.h> #include <xlat_tables_v2.h>
#include "../xlat_tables_private.h" #include "../xlat_tables_private.h"
uint64_t mmu_cfg_params[MMU_CFG_PARAM_MAX];
/* /*
* Returns 1 if the provided granule size is supported, 0 otherwise. * Returns 1 if the provided granule size is supported, 0 otherwise.
*/ */
...@@ -180,8 +178,9 @@ int xlat_arch_current_el(void) ...@@ -180,8 +178,9 @@ int xlat_arch_current_el(void)
return el; return el;
} }
void setup_mmu_cfg(unsigned int flags, const uint64_t *base_table, void setup_mmu_cfg(uint64_t *params, unsigned int flags,
unsigned long long max_pa, uintptr_t max_va, int xlat_regime) const uint64_t *base_table, unsigned long long max_pa,
uintptr_t max_va, int xlat_regime)
{ {
uint64_t mair, ttbr0, tcr; uint64_t mair, ttbr0, tcr;
uintptr_t virtual_addr_space_size; uintptr_t virtual_addr_space_size;
...@@ -248,7 +247,7 @@ void setup_mmu_cfg(unsigned int flags, const uint64_t *base_table, ...@@ -248,7 +247,7 @@ void setup_mmu_cfg(unsigned int flags, const uint64_t *base_table,
ttbr0 |= TTBR_CNP_BIT; ttbr0 |= TTBR_CNP_BIT;
#endif #endif
mmu_cfg_params[MMU_CFG_MAIR] = mair; params[MMU_CFG_MAIR] = mair;
mmu_cfg_params[MMU_CFG_TCR] = tcr; params[MMU_CFG_TCR] = tcr;
mmu_cfg_params[MMU_CFG_TTBR0] = ttbr0; params[MMU_CFG_TTBR0] = ttbr0;
} }
...@@ -12,6 +12,12 @@ ...@@ -12,6 +12,12 @@
#include "xlat_tables_private.h" #include "xlat_tables_private.h"
/*
* MMU configuration register values for the active translation context. Used
* from the MMU assembly helpers.
*/
uint64_t mmu_cfg_params[MMU_CFG_PARAM_MAX];
/* /*
* Each platform can define the size of its physical and virtual address spaces. * Each platform can define the size of its physical and virtual address spaces.
* If the platform hasn't defined one or both of them, default to * If the platform hasn't defined one or both of them, default to
...@@ -105,7 +111,8 @@ void init_xlat_tables(void) ...@@ -105,7 +111,8 @@ void init_xlat_tables(void)
void enable_mmu_secure(unsigned int flags) void enable_mmu_secure(unsigned int flags)
{ {
setup_mmu_cfg(flags, tf_xlat_ctx.base_table, MAX_PHYS_ADDR, setup_mmu_cfg((uint64_t *)&mmu_cfg_params, flags,
tf_xlat_ctx.base_table, MAX_PHYS_ADDR,
tf_xlat_ctx.va_max_address, EL1_EL0_REGIME); tf_xlat_ctx.va_max_address, EL1_EL0_REGIME);
enable_mmu_direct(flags); enable_mmu_direct(flags);
} }
...@@ -114,14 +121,16 @@ void enable_mmu_secure(unsigned int flags) ...@@ -114,14 +121,16 @@ void enable_mmu_secure(unsigned int flags)
void enable_mmu_el1(unsigned int flags) void enable_mmu_el1(unsigned int flags)
{ {
setup_mmu_cfg(flags, tf_xlat_ctx.base_table, MAX_PHYS_ADDR, setup_mmu_cfg((uint64_t *)&mmu_cfg_params, flags,
tf_xlat_ctx.base_table, MAX_PHYS_ADDR,
tf_xlat_ctx.va_max_address, EL1_EL0_REGIME); tf_xlat_ctx.va_max_address, EL1_EL0_REGIME);
enable_mmu_direct_el1(flags); enable_mmu_direct_el1(flags);
} }
void enable_mmu_el3(unsigned int flags) void enable_mmu_el3(unsigned int flags)
{ {
setup_mmu_cfg(flags, tf_xlat_ctx.base_table, MAX_PHYS_ADDR, setup_mmu_cfg((uint64_t *)&mmu_cfg_params, flags,
tf_xlat_ctx.base_table, MAX_PHYS_ADDR,
tf_xlat_ctx.va_max_address, EL3_REGIME); tf_xlat_ctx.va_max_address, EL3_REGIME);
enable_mmu_direct_el3(flags); enable_mmu_direct_el3(flags);
} }
......
...@@ -88,11 +88,6 @@ int xlat_arch_current_el(void); ...@@ -88,11 +88,6 @@ int xlat_arch_current_el(void);
*/ */
unsigned long long xlat_arch_get_max_supported_pa(void); unsigned long long xlat_arch_get_max_supported_pa(void);
/* Enable MMU and configure it to use the specified translation tables. */
void setup_mmu_cfg(unsigned int flags, const uint64_t *base_table,
unsigned long long max_pa, uintptr_t max_va,
int xlat_regime);
/* /*
* Return 1 if the MMU of the translation regime managed by the given xlat_ctx_t * Return 1 if the MMU of the translation regime managed by the given xlat_ctx_t
* is enabled, 0 otherwise. * is enabled, 0 otherwise.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment