Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions libcpu/risc-v/common64/mmu.c
Original file line number Diff line number Diff line change
Expand Up @@ -691,11 +691,13 @@ void rt_hw_mem_setup_early(void)
* identical mapping,
* PC are still at lower region before relocating to high memory
*/
for (size_t i = 0; i < __SIZE(PPN0_BIT); i++)
{
early_pgtbl[i] = COMBINEPTE(ps, MMU_MAP_EARLY);
ps += L1_PAGE_SIZE;
}
rt_ubase_t pg_idx ;
/* Round down symb_pc to L1_PAGE_SIZE boundary to ensure proper page alignment.
* This is necessary because MMU operations work with page-aligned addresses, and
* make sure all the text region is mapped.*/
ps = (rt_ubase_t)symb_pc & (~(L1_PAGE_SIZE - 1));
pg_idx = GET_L1(ps);
early_pgtbl[pg_idx] = COMBINEPTE(ps, MMU_MAP_EARLY);

/* relocate text region */
__asm__ volatile("la %0, _start\n" : "=r"(ps));
Expand Down