feat(tzc400): update filters by region

Add a new function that allows to enable or disabled filters on
configured regions dynamically. This will avoid the need to
reconfigure the entire attribute and just manage to
enable/disable filters.

Change-Id: If0937ca755bec6c45d3649718147108459682fff
Signed-off-by: Lionel Debieve <lionel.debieve@st.com>
Signed-off-by: Yann Gautier <yann.gautier@foss.st.com>
This commit is contained in:
Lionel Debieve 2020-09-27 20:48:30 +02:00 committed by Yann Gautier
parent 86b43c58a4
commit ce7ef9d146
3 changed files with 33 additions and 1 deletions

View File

@ -68,6 +68,7 @@ DEFINE_TZC_COMMON_WRITE_REGION_BASE(400, 400)
DEFINE_TZC_COMMON_WRITE_REGION_TOP(400, 400)
DEFINE_TZC_COMMON_WRITE_REGION_ATTRIBUTES(400, 400)
DEFINE_TZC_COMMON_WRITE_REGION_ID_ACCESS(400, 400)
DEFINE_TZC_COMMON_UPDATE_FILTERS(400, 400)
DEFINE_TZC_COMMON_CONFIGURE_REGION0(400)
DEFINE_TZC_COMMON_CONFIGURE_REGION(400)
@ -271,6 +272,15 @@ void tzc400_configure_region(unsigned int filters,
sec_attr, nsaid_permissions);
}
void tzc400_update_filters(unsigned int region, unsigned int filters)
{
/* Do range checks on filters and regions. */
assert(((filters >> tzc400.num_filters) == 0U) &&
(region < tzc400.num_regions));
_tzc400_update_filters(tzc400.base, region, tzc400.num_filters, filters);
}
void tzc400_enable_filters(void)
{
unsigned int state;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2016-2020, ARM Limited and Contributors. All rights reserved.
* Copyright (c) 2016-2021, ARM Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
@ -89,6 +89,27 @@
val); \
}
/*
* It is used to modify the filters status for a defined region.
*/
#define DEFINE_TZC_COMMON_UPDATE_FILTERS(fn_name, macro_name) \
static inline void _tzc##fn_name##_update_filters( \
uintptr_t base, \
unsigned int region_no, \
unsigned int nbfilters, \
unsigned int filters) \
{ \
uint32_t filters_mask = GENMASK(nbfilters - 1U, 0); \
\
mmio_clrsetbits_32(base + \
TZC_REGION_OFFSET( \
TZC_##macro_name##_REGION_SIZE, \
region_no) + \
TZC_##macro_name##_REGION_ATTR_0_OFFSET, \
filters_mask << TZC_REGION_ATTR_F_EN_SHIFT, \
filters << TZC_REGION_ATTR_F_EN_SHIFT); \
}
/*
* It is used to program region 0 ATTRIBUTES and ACCESS register.
*/

View File

@ -109,6 +109,7 @@ void tzc400_configure_region(unsigned int filters,
unsigned long long region_top,
unsigned int sec_attr,
unsigned int nsaid_permissions);
void tzc400_update_filters(unsigned int region, unsigned int filters);
void tzc400_set_action(unsigned int action);
void tzc400_enable_filters(void);
void tzc400_disable_filters(void);