diff --git a/arch/risc-v/src/common/riscv_mmu.h b/arch/risc-v/src/common/riscv_mmu.h index 26e398fc1d..fbc5a68828 100644 --- a/arch/risc-v/src/common/riscv_mmu.h +++ b/arch/risc-v/src/common/riscv_mmu.h @@ -307,11 +307,30 @@ static inline uintptr_t mmu_pte_to_paddr(uintptr_t pte) return paddr; } +/**************************************************************************** + * Name: mmu_satp_to_paddr + * + * Description: + * Extract physical address from SATP + * + * Returned Value: + * Physical address from SATP value + * + ****************************************************************************/ + +static inline uintptr_t mmu_satp_to_paddr(uintptr_t satp) +{ + uintptr_t ppn; + ppn = satp; + ppn = ((ppn >> SATP_PPN_SHIFT) & SATP_PPN_MASK); + return SATP_PPN_TO_ADDR(ppn); +} + /**************************************************************************** * Name: mmu_get_satp_pgbase * * Description: - * Utility function to read the base page table physical address + * Utility function to read the current base page table physical address * * Returned Value: * Physical address of the current base page table @@ -320,10 +339,7 @@ static inline uintptr_t mmu_pte_to_paddr(uintptr_t pte) static inline uintptr_t mmu_get_satp_pgbase(void) { - uintptr_t ppn; - ppn = mmu_read_satp(); - ppn = ((ppn >> SATP_PPN_SHIFT) & SATP_PPN_MASK); - return SATP_PPN_TO_ADDR(ppn); + return mmu_satp_to_paddr(mmu_read_satp()); } /****************************************************************************