RISC-V: Move wipe_page to pgalloc.h and rename it riscv_pgwipe

This commit is contained in:
Ville Juven 2022-04-19 14:39:04 +03:00 committed by Xiang Xiao
parent 3d8ba496a2
commit 0ccda05a82
3 changed files with 22 additions and 39 deletions

View File

@ -78,5 +78,22 @@ static inline uintptr_t riscv_pgvaddr(uintptr_t paddr)
}
#endif /* CONFIG_ARCH_PGPOOL_MAPPING */
/****************************************************************************
* Name: riscv_pgwipe
*
* Description:
* Wipe a page of physical memory, first mapping it into virtual memory.
*
* Input Parameters:
* paddr - Physical address of page
*
****************************************************************************/
static inline void riscv_pgwipe(uintptr_t paddr)
{
uintptr_t vaddr = riscv_pgvaddr(paddr);
memset((void *)vaddr, 0, MM_PGSIZE);
}
#endif /* CONFIG_MM_PGALLOC */
#endif /* __ARCH_RISC_V_SRC_COMMON_PGALLOC_H */

View File

@ -99,23 +99,6 @@ extern uintptr_t g_kernel_mappings;
* Private Functions
****************************************************************************/
/****************************************************************************
* Name: wipe_page
*
* Description:
* Wipe a page of physical memory, first mapping it into virtual memory.
*
* Input Parameters:
* paddr - Physical address of page
*
****************************************************************************/
static inline void wipe_page(uintptr_t paddr)
{
uintptr_t vaddr = riscv_pgvaddr(paddr);
memset((void *)vaddr, 0, MM_PGSIZE);
}
/****************************************************************************
* Name: map_spgtables
*
@ -183,7 +166,7 @@ static int create_spgtables(group_addrenv_t *addrenv)
/* Wipe the memory and assign it */
wipe_page(paddr);
riscv_pgwipe(paddr);
addrenv->spgtables[i] = paddr;
}
@ -290,7 +273,7 @@ static int create_region(group_addrenv_t *addrenv, uintptr_t vaddr,
/* This is then used to map the final level */
wipe_page(paddr);
riscv_pgwipe(paddr);
}
ptlast = riscv_pgvaddr(paddr);
@ -307,7 +290,7 @@ static int create_region(group_addrenv_t *addrenv, uintptr_t vaddr,
/* Wipe the physical page memory */
wipe_page(paddr);
riscv_pgwipe(paddr);
/* Then map the virtual address to the physical address */

View File

@ -54,23 +54,6 @@
* Private Functions
****************************************************************************/
/****************************************************************************
* Name: wipe_page
*
* Description:
* Wipe a page of physical memory, first mapping it into virtual memory.
*
* Input Parameters:
* paddr - Physical address of page
*
****************************************************************************/
static inline void wipe_page(uintptr_t paddr)
{
uintptr_t vaddr = riscv_pgvaddr(paddr);
memset((void *)vaddr, 0, MM_PGSIZE);
}
/****************************************************************************
* Name: get_pgtable
*
@ -101,7 +84,7 @@ static uintptr_t get_pgtable(group_addrenv_t *addrenv, uintptr_t vaddr)
{
/* Wipe the page and assign it */
wipe_page(paddr);
riscv_pgwipe(paddr);
mmu_ln_setentry(ptlevel, ptprev, paddr, vaddr, MMU_UPGT_FLAGS);
}
}
@ -205,7 +188,7 @@ uintptr_t pgalloc(uintptr_t brkaddr, unsigned int npages)
/* Wipe the memory */
wipe_page(paddr);
riscv_pgwipe(paddr);
/* Then add the reference */