refactor(xlat): add several refactorizations to the xlat library
This patch includes a number of refactorizations of the xlat library in
order to facilitate the implementation of unittests for the library.
Amongst the improvements there are:
* Macros to allocate and initialize the translation tables as well
as the translation context structures have been removed and
replaced with library APIs.
* Some of the library APIs have been collapsed, reducing the size
of the overall interface and presenting a more compact API to
the consumer.
* The distinction between the translation base tables and the
intermediate tables have been removed, presenting now a single
array of tables for the whole translation context.
The patch also adapts the rest of RMM to use the new library API.
Signed-off-by: Javier Almansa Sobrino <javier.almansasobrino@arm.com>
Change-Id: I2fb486c0c5bc005446b09e3fef5e7de9bf0efda0
diff --git a/lib/xlat/include/xlat_tables.h b/lib/xlat/include/xlat_tables.h
index 3caeb8d..3556880 100644
--- a/lib/xlat/include/xlat_tables.h
+++ b/lib/xlat/include/xlat_tables.h
@@ -181,7 +181,7 @@
/*
* Structure containing a table entry and its related information.
*/
-struct xlat_table_entry {
+struct xlat_tbl_info {
uint64_t *table; /* Pointer to the translation table. */
uintptr_t base_va; /* Context base VA for the current entry. */
unsigned int level; /* Table level of the current entry. */
@@ -192,63 +192,23 @@
* Generic translation table APIs.
*****************************************************************************/
-static inline void xlat_write_descriptor(uint64_t *entry, uint64_t desc)
+static inline void xlat_write_tte(uint64_t *entry, uint64_t desc)
{
SCA_WRITE64(entry, desc);
}
-static inline uint64_t xlat_read_descriptor(uint64_t *entry)
+static inline uint64_t xlat_read_tte(uint64_t *entry)
{
return SCA_READ64(entry);
}
/*
- * Initialize translation tables (and mark xlat_ctx_cfg as initialized if
- * not already initialized) associated to the current context.
- *
- * The struct xlat_ctx_cfg of the context might be shared with other
- * contexts that might have already initialized it. This is expected and
- * should not cause any problem.
- *
- * This function assumes that the xlat_ctx_cfg field of the context has been
- * properly configured by previous calls to xlat_mmap_add_region_ctx().
- *
- * This function returns 0 on success or an error code otherwise.
- */
-int xlat_init_tables_ctx(struct xlat_ctx *ctx);
-
-/*
- * Add a memory region with defined base PA and base VA. This function can only
- * be used before marking the xlat_ctx_cfg for the current xlat_ctx as
- * initialized.
- *
- * The region cannot be removed once added.
- *
- * This function returns 0 on success or an error code otherwise.
- */
-int xlat_mmap_add_region_ctx(struct xlat_ctx *ctx,
- struct xlat_mmap_region *mm);
-
-/*
- * Add an array of memory regions with defined base PA and base VA.
- * This function needs to be called before initialiting the xlat_ctx_cfg.
- * Setting the `last` argument to true will initialise the xlat_ctx_cfg.
- *
- * The regions cannot be removed once added.
- *
- * Return 0 on success or a negative error code otherwise.
- */
-int xlat_mmap_add_ctx(struct xlat_ctx *ctx,
- struct xlat_mmap_region *mm,
- bool last);
-
-/*
* Return a table entry structure given a context and a VA.
* The return structure is populated on the retval field.
*
* This function returns 0 on success or a negative error code otherwise.
*/
-int xlat_get_table_from_va(struct xlat_table_entry * const retval,
+int xlat_get_table_from_va(struct xlat_tbl_info * const retval,
const struct xlat_ctx * const ctx,
const uintptr_t va);
@@ -260,7 +220,7 @@
*
* This function returns 0 on success or a negative error code otherwise.
*/
-int xlat_unmap_memory_page(struct xlat_table_entry * const table,
+int xlat_unmap_memory_page(struct xlat_tbl_info * const table,
const uintptr_t va);
/*
@@ -271,7 +231,7 @@
*
* This function returns 0 on success or a negative error code otherwise.
*/
-int xlat_map_memory_page_with_attrs(const struct xlat_table_entry * const table,
+int xlat_map_memory_page_with_attrs(const struct xlat_tbl_info * const table,
const uintptr_t va,
const uintptr_t pa,
const uint64_t attrs);
@@ -281,8 +241,8 @@
* table entry structure and the VA for that descriptor.
*
*/
-uint64_t *xlat_get_pte_from_table(const struct xlat_table_entry * const table,
- const uintptr_t va);
+uint64_t *xlat_get_tte_ptr(const struct xlat_tbl_info * const table,
+ const uintptr_t va);
/*
* Set up the MMU configuration registers for the specified platform parameters.
@@ -301,30 +261,5 @@
/* MMU control */
void xlat_enable_mmu_el2(void);
-/*
- * Returns true if the xlat_ctx_cfg field in the xlat_ctx is initialized.
- */
-bool xlat_ctx_cfg_initialized(const struct xlat_ctx * const ctx);
-
-/*
- * Returns true if the translation tables on the current context are already
- * initialized or false otherwise.
- */
-bool xlat_ctx_tbls_initialized(const struct xlat_ctx * const ctx);
-
-/*
- * Initialize a context dynamically at runtime using the given xlat_ctx_cfg
- * and xlat_ctx_tbls structures.
- *
- * Return 0 if success or a Posix erro code otherwise.
- */
-int xlat_ctx_create_dynamic(struct xlat_ctx *ctx,
- struct xlat_ctx_cfg *cfg,
- struct xlat_ctx_tbls *tbls,
- void *base_tables,
- unsigned int base_level_entries,
- void *tables_ptr,
- unsigned int ntables);
-
#endif /*__ASSEMBLER__*/
#endif /* XLAT_TABLES_H */