Skip to content

Commit

Permalink
Extend MMU Flags to 64-bit for T-Head C906 and Svpbmt
Browse files Browse the repository at this point in the history
Currently RISC-V NuttX supports 32-bit MMU Flags inside a Page Table Entry. This PR extends the MMU Flags to 64-bit, to support T-Head C906 Core and the new RISC-V Svpbmt Extension.

T-Head C906 uses Bits 59 to 63 in a Leaf Page Table Entry to configure the Memory Type: Cacheable / Bufferable / Strongly-Ordered. For the upcoming port of NuttX to PINE64 Ox64 BL808 SBC, we need to set the Memory Type to Strongly-Ordered for I/O Memory, which requires 64-bit MMU Flags.

Details of C906 MMU: https://lupyuen.github.io/articles/plic3#t-head-errata

Newer RISC-V Cores will use the Svpbmt Extension to configure the Memory Type (Cacheable / Strongly-Ordered). Svpbmt uses Bits 61 to 62 in a Leaf Page Table Entry to define the Memory Type. This also requires 64-bit MMU Flags.

Details of Svpbmt: https://github.com/riscv/riscv-isa-manual/blob/main/src/supervisor.adoc#svpbmt
  • Loading branch information
lupyuen authored and xiaoxiang781216 committed Dec 11, 2023
1 parent 1295ccd commit 0bac2ef
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions arch/risc-v/src/common/riscv_mmu.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ static const size_t g_pgt_sizes[] =
****************************************************************************/

void mmu_ln_setentry(uint32_t ptlevel, uintptr_t lnvaddr, uintptr_t paddr,
uintptr_t vaddr, uint32_t mmuflags)
uintptr_t vaddr, uint64_t mmuflags)
{
uintptr_t *lntable = (uintptr_t *)lnvaddr;
uint32_t index;
Expand Down Expand Up @@ -136,7 +136,7 @@ void mmu_ln_restore(uint32_t ptlevel, uintptr_t lnvaddr, uintptr_t vaddr,
}

void mmu_ln_map_region(uint32_t ptlevel, uintptr_t lnvaddr, uintptr_t paddr,
uintptr_t vaddr, size_t size, uint32_t mmuflags)
uintptr_t vaddr, size_t size, uint64_t mmuflags)
{
uintptr_t end_paddr = paddr + size;
size_t page_size = g_pgt_sizes[ptlevel - 1];
Expand Down
4 changes: 2 additions & 2 deletions arch/risc-v/src/common/riscv_mmu.h
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ static inline uintptr_t mmu_get_satp_pgbase(void)
****************************************************************************/

void mmu_ln_setentry(uint32_t ptlevel, uintptr_t lnvaddr, uintptr_t paddr,
uintptr_t vaddr, uint32_t mmuflags);
uintptr_t vaddr, uint64_t mmuflags);

/****************************************************************************
* Name: mmu_ln_getentry
Expand Down Expand Up @@ -448,7 +448,7 @@ void mmu_ln_restore(uint32_t ptlevel, uintptr_t lnvaddr, uintptr_t vaddr,
****************************************************************************/

void mmu_ln_map_region(uint32_t ptlevel, uintptr_t lnvaddr, uintptr_t paddr,
uintptr_t vaddr, size_t size, uint32_t mmuflags);
uintptr_t vaddr, size_t size, uint64_t mmuflags);

/****************************************************************************
* Name: mmu_ln_map_region
Expand Down

0 comments on commit 0bac2ef

Please sign in to comment.