Skip to content

Commit

Permalink
core: merge core_mmu_init_phys_mem() and core_mmu_init_virtualization()
Browse files Browse the repository at this point in the history
Moves the implementation of core_mmu_init_virtualization() into
core_mmu_init_phys_mem().

This simplifies init_primary() in core/arch/arm/kernel/boot.c.

Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
  • Loading branch information
jenswi-linaro committed Sep 13, 2024
1 parent 799029c commit beeb6a6
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 25 deletions.
7 changes: 1 addition & 6 deletions core/arch/arm/kernel/boot.c
Original file line number Diff line number Diff line change
Expand Up @@ -927,12 +927,7 @@ static void init_primary(unsigned long pageable_part, unsigned long nsec_entry)
#endif

core_mmu_save_mem_map();
if (IS_ENABLED(CFG_NS_VIRTUALIZATION)) {
IMSG("Initializing virtualization support");
core_mmu_init_virtualization();
} else {
core_mmu_init_phys_mem();
}
core_mmu_init_phys_mem();
boot_mem_release_unused();

IMSG_RAW("\n");
Expand Down
2 changes: 0 additions & 2 deletions core/include/mm/core_mmu.h
Original file line number Diff line number Diff line change
Expand Up @@ -640,8 +640,6 @@ void core_mmu_set_default_prtn(void);
void core_mmu_set_default_prtn_tbl(void);
#endif

void core_mmu_init_virtualization(void);

/* Initialize physical memory pool */
void core_mmu_init_phys_mem(void);

Expand Down
34 changes: 17 additions & 17 deletions core/mm/core_mmu.c
Original file line number Diff line number Diff line change
Expand Up @@ -2581,20 +2581,6 @@ bool is_nexus(const void *va)
}
#endif

void core_mmu_init_virtualization(void)
{
paddr_t b1 = 0;
paddr_size_t s1 = 0;

static_assert(ARRAY_SIZE(secure_only) <= 2);
if (ARRAY_SIZE(secure_only) == 2) {
b1 = secure_only[1].paddr;
s1 = secure_only[1].size;
}
virt_init_memory(&static_memory_map, secure_only[0].paddr,
secure_only[0].size, b1, s1);
}

vaddr_t io_pa_or_va(struct io_pa_va *p, size_t len)
{
assert(p->pa);
Expand Down Expand Up @@ -2675,10 +2661,22 @@ static void __maybe_unused carve_out_core_mem(paddr_t pa, paddr_t end_pa)

void core_mmu_init_phys_mem(void)
{
paddr_t ps = 0;
size_t size = 0;
/*
* Get virtual addr/size of RAM where TA are loaded/executedNSec
* shared mem allocated from teecore.
*/
if (IS_ENABLED(CFG_NS_VIRTUALIZATION)) {
paddr_t b1 = 0;
paddr_size_t s1 = 0;

if (!IS_ENABLED(CFG_NS_VIRTUALIZATION)) {
static_assert(ARRAY_SIZE(secure_only) <= 2);
if (ARRAY_SIZE(secure_only) == 2) {
b1 = secure_only[1].paddr;
s1 = secure_only[1].size;
}
virt_init_memory(&static_memory_map, secure_only[0].paddr,
secure_only[0].size, b1, s1);
} else {
#ifdef CFG_WITH_PAGER
/*
* The pager uses all core memory so there's no need to add
Expand All @@ -2689,6 +2687,8 @@ void core_mmu_init_phys_mem(void)
#else /*!CFG_WITH_PAGER*/
size_t align = BIT(CORE_MMU_USER_CODE_SHIFT);
paddr_t end_pa = 0;
size_t size = 0;
paddr_t ps = 0;
paddr_t pa = 0;

static_assert(ARRAY_SIZE(secure_only) <= 2);
Expand Down

0 comments on commit beeb6a6

Please sign in to comment.