mirror of
https://github.com/ARM-software/arm-trusted-firmware.git
synced 2025-04-15 00:54:22 +00:00
xlat_tables_v2: merge REGISTER_XLAT_CONTEXT_{FULL_SPEC,RO_BASE_TABLE}
xlat_tables_v2_helpers.h defines two quite similar macros, REGISTER_XLAT_CONTEXT_FULL_SPEC and REGISTER_XLAT_CONTEXT_RO_BASE_TABLE. Only the difference is the section of _ctx_name##_base_xlat_table. Parameterize it and unify these two macros. The base xlat table goes into the .bss section by default. If PLAT_RO_XLAT_TABLES is defined, it goes into the .rodata section. Change-Id: I8b02f4da98f0c272e348a200cebd89f479099c55 Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
This commit is contained in:
parent
65012c0892
commit
363830df1c
3 changed files with 21 additions and 50 deletions
|
@ -164,14 +164,20 @@ typedef struct xlat_ctx xlat_ctx_t;
|
|||
* Would typically be PLAT_VIRT_ADDR_SPACE_SIZE
|
||||
* (resp. PLAT_PHY_ADDR_SPACE_SIZE) for the translation context describing the
|
||||
* BL image currently executing.
|
||||
|
||||
* _base_table_section:
|
||||
* Specify the name of the section where the base translation tables have to
|
||||
* be placed by the linker.
|
||||
*/
|
||||
#define REGISTER_XLAT_CONTEXT(_ctx_name, _mmap_count, _xlat_tables_count, \
|
||||
_virt_addr_space_size, _phy_addr_space_size) \
|
||||
_virt_addr_space_size, _phy_addr_space_size, \
|
||||
_base_table_section) \
|
||||
REGISTER_XLAT_CONTEXT_FULL_SPEC(_ctx_name, (_mmap_count), \
|
||||
(_xlat_tables_count), \
|
||||
(_virt_addr_space_size), \
|
||||
(_phy_addr_space_size), \
|
||||
EL_REGIME_INVALID, "xlat_table")
|
||||
EL_REGIME_INVALID, \
|
||||
"xlat_table", (_base_table_section))
|
||||
|
||||
/*
|
||||
* Same as REGISTER_XLAT_CONTEXT plus the additional parameters:
|
||||
|
@ -191,7 +197,9 @@ typedef struct xlat_ctx xlat_ctx_t;
|
|||
(_xlat_tables_count), \
|
||||
(_virt_addr_space_size), \
|
||||
(_phy_addr_space_size), \
|
||||
(_xlat_regime), (_section_name))
|
||||
(_xlat_regime), \
|
||||
(_section_name), ".bss" \
|
||||
)
|
||||
|
||||
/******************************************************************************
|
||||
* Generic translation table APIs.
|
||||
|
|
|
@ -135,7 +135,8 @@ struct xlat_ctx {
|
|||
|
||||
#define REGISTER_XLAT_CONTEXT_FULL_SPEC(_ctx_name, _mmap_count, \
|
||||
_xlat_tables_count, _virt_addr_space_size, \
|
||||
_phy_addr_space_size, _xlat_regime, _section_name)\
|
||||
_phy_addr_space_size, _xlat_regime, \
|
||||
_table_section, _base_table_section) \
|
||||
CASSERT(CHECK_PHY_ADDR_SPACE_SIZE(_phy_addr_space_size), \
|
||||
assert_invalid_physical_addr_space_sizefor_##_ctx_name);\
|
||||
\
|
||||
|
@ -143,52 +144,13 @@ struct xlat_ctx {
|
|||
\
|
||||
static uint64_t _ctx_name##_xlat_tables[_xlat_tables_count] \
|
||||
[XLAT_TABLE_ENTRIES] \
|
||||
__aligned(XLAT_TABLE_SIZE) __section(_section_name); \
|
||||
\
|
||||
static uint64_t _ctx_name##_base_xlat_table \
|
||||
[GET_NUM_BASE_LEVEL_ENTRIES(_virt_addr_space_size)] \
|
||||
__aligned(GET_NUM_BASE_LEVEL_ENTRIES(_virt_addr_space_size)\
|
||||
* sizeof(uint64_t)); \
|
||||
\
|
||||
XLAT_ALLOC_DYNMAP_STRUCT(_ctx_name, _xlat_tables_count) \
|
||||
\
|
||||
static xlat_ctx_t _ctx_name##_xlat_ctx = { \
|
||||
.pa_max_address = (_phy_addr_space_size) - 1ULL, \
|
||||
.va_max_address = (_virt_addr_space_size) - 1UL, \
|
||||
.mmap = _ctx_name##_mmap, \
|
||||
.mmap_num = (_mmap_count), \
|
||||
.tables = _ctx_name##_xlat_tables, \
|
||||
.tables_num = _xlat_tables_count, \
|
||||
XLAT_CTX_INIT_TABLE_ATTR() \
|
||||
XLAT_REGISTER_DYNMAP_STRUCT(_ctx_name) \
|
||||
.next_table = 0, \
|
||||
.base_table = _ctx_name##_base_xlat_table, \
|
||||
.base_table_entries = \
|
||||
GET_NUM_BASE_LEVEL_ENTRIES(_virt_addr_space_size),\
|
||||
.max_pa = 0U, \
|
||||
.max_va = 0U, \
|
||||
.base_level = GET_XLAT_TABLE_LEVEL_BASE(_virt_addr_space_size),\
|
||||
.initialized = false, \
|
||||
.xlat_regime = (_xlat_regime) \
|
||||
}
|
||||
|
||||
#define REGISTER_XLAT_CONTEXT_RO_BASE_TABLE(_ctx_name, _mmap_count, \
|
||||
_xlat_tables_count, _virt_addr_space_size, \
|
||||
_phy_addr_space_size, _xlat_regime, _section_name)\
|
||||
CASSERT(CHECK_PHY_ADDR_SPACE_SIZE(_phy_addr_space_size), \
|
||||
assert_invalid_physical_addr_space_sizefor_##_ctx_name);\
|
||||
\
|
||||
static mmap_region_t _ctx_name##_mmap[_mmap_count + 1]; \
|
||||
\
|
||||
static uint64_t _ctx_name##_xlat_tables[_xlat_tables_count] \
|
||||
[XLAT_TABLE_ENTRIES] \
|
||||
__aligned(XLAT_TABLE_SIZE) __section(_section_name); \
|
||||
__aligned(XLAT_TABLE_SIZE) __section(_table_section); \
|
||||
\
|
||||
static uint64_t _ctx_name##_base_xlat_table \
|
||||
[GET_NUM_BASE_LEVEL_ENTRIES(_virt_addr_space_size)] \
|
||||
__aligned(GET_NUM_BASE_LEVEL_ENTRIES(_virt_addr_space_size)\
|
||||
* sizeof(uint64_t)) \
|
||||
__section(".rodata"); \
|
||||
__section(_base_table_section); \
|
||||
\
|
||||
XLAT_ALLOC_DYNMAP_STRUCT(_ctx_name, _xlat_tables_count) \
|
||||
\
|
||||
|
|
|
@ -26,14 +26,15 @@ uint64_t mmu_cfg_params[MMU_CFG_PARAM_MAX];
|
|||
* currently executing.
|
||||
*/
|
||||
#if PLAT_RO_XLAT_TABLES
|
||||
REGISTER_XLAT_CONTEXT_RO_BASE_TABLE(tf, MAX_MMAP_REGIONS, MAX_XLAT_TABLES,
|
||||
PLAT_VIRT_ADDR_SPACE_SIZE, PLAT_PHY_ADDR_SPACE_SIZE,
|
||||
EL_REGIME_INVALID, "xlat_table");
|
||||
#define BASE_XLAT_TABLE_SECTION ".rodata"
|
||||
#else
|
||||
REGISTER_XLAT_CONTEXT(tf, MAX_MMAP_REGIONS, MAX_XLAT_TABLES,
|
||||
PLAT_VIRT_ADDR_SPACE_SIZE, PLAT_PHY_ADDR_SPACE_SIZE);
|
||||
#define BASE_XLAT_TABLE_SECTION ".bss"
|
||||
#endif
|
||||
|
||||
REGISTER_XLAT_CONTEXT(tf, MAX_MMAP_REGIONS, MAX_XLAT_TABLES,
|
||||
PLAT_VIRT_ADDR_SPACE_SIZE, PLAT_PHY_ADDR_SPACE_SIZE,
|
||||
BASE_XLAT_TABLE_SECTION);
|
||||
|
||||
void mmap_add_region(unsigned long long base_pa, uintptr_t base_va, size_t size,
|
||||
unsigned int attr)
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue