SPM: Refactor xlat context creation
[project/bcm63xx/atf.git] / services / std_svc / spm / spm_xlat.c
index 58d61fc347af1585c092b66083a11be59dfc1e73..1619f9720aab5602101dd98f0d9d51dcfd094b91 100644 (file)
@@ -50,17 +50,6 @@ static OBJECT_POOL(sp_xlat_tables_pool, sp_xlat_tables,
        XLAT_TABLE_ENTRIES * sizeof(uint64_t),
        (PLAT_SP_IMAGE_MAX_XLAT_TABLES + 1) * PLAT_SPM_MAX_PARTITIONS);
 
-/* Allocate base translation tables. */
-static uint64_t sp_xlat_base_tables
-       [GET_NUM_BASE_LEVEL_ENTRIES(PLAT_VIRT_ADDR_SPACE_SIZE)]
-       [PLAT_SPM_MAX_PARTITIONS]
-       __aligned(GET_NUM_BASE_LEVEL_ENTRIES(PLAT_VIRT_ADDR_SPACE_SIZE)
-                 * sizeof(uint64_t))
-       __section(PLAT_SP_IMAGE_XLAT_SECTION_NAME);
-static OBJECT_POOL(sp_xlat_base_tables_pool, sp_xlat_base_tables,
-       GET_NUM_BASE_LEVEL_ENTRIES(PLAT_VIRT_ADDR_SPACE_SIZE) * sizeof(uint64_t),
-       PLAT_SPM_MAX_PARTITIONS);
-
 /* Allocate arrays. */
 static int sp_xlat_mapped_regions[PLAT_SP_IMAGE_MAX_XLAT_TABLES]
        [PLAT_SPM_MAX_PARTITIONS];
@@ -73,13 +62,13 @@ static OBJECT_POOL(sp_xlat_ctx_pool, sp_xlat_ctx, sizeof(xlat_ctx_t),
        PLAT_SPM_MAX_PARTITIONS);
 
 /* Get handle of Secure Partition translation context */
-xlat_ctx_t *spm_sp_xlat_context_alloc(void)
+void spm_sp_xlat_context_alloc(sp_context_t *sp_ctx)
 {
        xlat_ctx_t *ctx = pool_alloc(&sp_xlat_ctx_pool);
 
        struct mmap_region *mmap = pool_alloc(&sp_mmap_regions_pool);
 
-       uint64_t *base_table = pool_alloc(&sp_xlat_base_tables_pool);
+       uint64_t *base_table = pool_alloc(&sp_xlat_tables_pool);
        uint64_t **tables = pool_alloc_n(&sp_xlat_tables_pool,
                                        PLAT_SP_IMAGE_MAX_XLAT_TABLES);
 
@@ -91,7 +80,7 @@ xlat_ctx_t *spm_sp_xlat_context_alloc(void)
                               PLAT_SP_IMAGE_MAX_XLAT_TABLES, base_table,
                               EL1_EL0_REGIME, mapped_regions);
 
-       return ctx;
+       sp_ctx->xlat_ctx_handle = ctx;
 };
 
 /*******************************************************************************