mirror of
https://github.com/ARM-software/arm-trusted-firmware.git
synced 2025-04-17 18:14:24 +00:00

In this patch, we are trying to introduce the wrapper macro CREATE_FEATURE_PRESENT to get the following capability and align it for all the features: -> is_feat_xx_present(): Does Hardware implement the feature. -> uniformity in naming the function across multiple features. -> improved readability The is_feat_xx_present() is implemented to check if the hardware implements the feature and does not take into account the ENABLE_FEAT_XXX flag enabled/disabled in software. - CREATE_FEATURE_PRESENT(name, idreg, shift, mask, idval) The wrapper macro reduces the function to a single line and creates the is_feat_xx_present function that checks the id register based on the shift and mask values and compares this against a determined idvalue. Change-Id: I7b91d2c9c6fbe55f94c693aa1b2c50be54fb9ecc Signed-off-by: Sona Mathew <sonarebecca.mathew@arm.com>
69 lines
1.4 KiB
C
69 lines
1.4 KiB
C
/*
|
|
* Copyright (c) 2021-2024, Arm Limited and Contributors. All rights reserved.
|
|
*
|
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
*/
|
|
|
|
#include <assert.h>
|
|
#include <stdbool.h>
|
|
#include <stdint.h>
|
|
|
|
#include "../xlat_mpu_private.h"
|
|
#include <arch.h>
|
|
#include <arch_features.h>
|
|
#include <lib/cassert.h>
|
|
#include <lib/utils_def.h>
|
|
#include <lib/xlat_tables/xlat_tables_v2.h>
|
|
|
|
#include <fvp_r_arch_helpers.h>
|
|
|
|
#warning "xlat_mpu library is currently experimental and its API may change in future."
|
|
|
|
#if ENABLE_ASSERTIONS
|
|
/*
|
|
* Return minimum virtual address space size supported by the architecture
|
|
*/
|
|
uintptr_t xlat_get_min_virt_addr_space_size(void)
|
|
{
|
|
uintptr_t ret;
|
|
|
|
if (is_feat_ttst_present()) {
|
|
ret = MIN_VIRT_ADDR_SPACE_SIZE_TTST;
|
|
} else {
|
|
ret = MIN_VIRT_ADDR_SPACE_SIZE;
|
|
}
|
|
return ret;
|
|
}
|
|
#endif /* ENABLE_ASSERTIONS*/
|
|
|
|
bool is_mpu_enabled_ctx(const xlat_ctx_t *ctx)
|
|
{
|
|
if (ctx->xlat_regime == EL1_EL0_REGIME) {
|
|
assert(xlat_arch_current_el() >= 1U);
|
|
return (read_sctlr_el1() & SCTLR_M_BIT) != 0U;
|
|
} else {
|
|
assert(xlat_arch_current_el() >= 2U);
|
|
return (read_sctlr_el2() & SCTLR_M_BIT) != 0U;
|
|
}
|
|
}
|
|
|
|
bool is_dcache_enabled(void)
|
|
{
|
|
unsigned int el = get_current_el();
|
|
|
|
if (el == 1U) {
|
|
return (read_sctlr_el1() & SCTLR_C_BIT) != 0U;
|
|
} else { /* must be EL2 */
|
|
return (read_sctlr_el2() & SCTLR_C_BIT) != 0U;
|
|
}
|
|
}
|
|
|
|
unsigned int xlat_arch_current_el(void)
|
|
{
|
|
unsigned int el = (unsigned int)GET_EL(read_CurrentEl());
|
|
|
|
assert(el > 0U);
|
|
|
|
return el;
|
|
}
|
|
|