From cdbe91aeb92357f01dbaceba528673f7d0b914cd Mon Sep 17 00:00:00 2001 From: buxiasen Date: Fri, 28 Feb 2025 12:58:11 +0800 Subject: [PATCH] armv7a: rename and implement va2pa & pa2va Notice: the up_addrenv_pa_to_va is not correct, it will be complex if we search all address to lookup all virtual address according to physical address. Use up_addrenv_x method as common interface across va & pa Signed-off-by: buxiasen --- arch/arm/src/armv7-a/arm_physpgaddr.c | 7 ++++--- arch/arm/src/armv7-a/arm_virtpgaddr.c | 9 +++++---- arch/arm/src/armv7-a/pgalloc.h | 22 ---------------------- 3 files changed, 9 insertions(+), 29 deletions(-) diff --git a/arch/arm/src/armv7-a/arm_physpgaddr.c b/arch/arm/src/armv7-a/arm_physpgaddr.c index 4a481fedd7e..7cb4c6bfd60 100644 --- a/arch/arm/src/armv7-a/arm_physpgaddr.c +++ b/arch/arm/src/armv7-a/arm_physpgaddr.c @@ -46,7 +46,7 @@ ****************************************************************************/ /**************************************************************************** - * Name: arm_physpgaddr + * Name: up_addrenv_va_to_pa * * Description: * Check if the virtual address lies in the user data area and, if so @@ -54,8 +54,9 @@ * ****************************************************************************/ -uintptr_t arm_physpgaddr(uintptr_t vaddr) +uintptr_t up_addrenv_va_to_pa(void *va) { + uintptr_t vaddr = (uintptr_t)va; uint32_t *l2table; uintptr_t paddr; uint32_t l1entry; @@ -113,7 +114,7 @@ uintptr_t arm_physpgaddr(uintptr_t vaddr) /* No mapping available */ - return 0; + return vaddr; } #endif /* CONFIG_MM_PGALLOC */ diff --git a/arch/arm/src/armv7-a/arm_virtpgaddr.c b/arch/arm/src/armv7-a/arm_virtpgaddr.c index fc3fc36ca62..f583e4b80e4 100644 --- a/arch/arm/src/armv7-a/arm_virtpgaddr.c +++ b/arch/arm/src/armv7-a/arm_virtpgaddr.c @@ -35,7 +35,7 @@ ****************************************************************************/ /**************************************************************************** - * Name: arm_virtpgaddr + * Name: up_addrenv_pa_to_va * * Description: * Check if the physical address lies in the page pool and, if so @@ -43,7 +43,7 @@ * ****************************************************************************/ -uintptr_t arm_virtpgaddr(uintptr_t paddr) +void *up_addrenv_pa_to_va(uintptr_t paddr) { /* REVISIT: Not implemented correctly. The reverse lookup from physical * to virtual. This will return a kernel accessible virtual address, but @@ -54,10 +54,11 @@ uintptr_t arm_virtpgaddr(uintptr_t paddr) if (paddr >= CONFIG_ARCH_PGPOOL_PBASE && paddr < CONFIG_ARCH_PGPOOL_PEND) { - return paddr - CONFIG_ARCH_PGPOOL_PBASE + CONFIG_ARCH_PGPOOL_VBASE; + return (void *)(paddr - CONFIG_ARCH_PGPOOL_PBASE + + CONFIG_ARCH_PGPOOL_VBASE); } - return 0; + return (void *)paddr; } #endif /* CONFIG_MM_PGALLOC */ diff --git a/arch/arm/src/armv7-a/pgalloc.h b/arch/arm/src/armv7-a/pgalloc.h index 8cbd2d219ec..aa6e28db2e9 100644 --- a/arch/arm/src/armv7-a/pgalloc.h +++ b/arch/arm/src/armv7-a/pgalloc.h @@ -179,27 +179,5 @@ static inline uintptr_t get_l2_entry(uint32_t *l2table, uintptr_t vaddr) * Public Functions Prototypes ****************************************************************************/ -/**************************************************************************** - * Name: arm_physpgaddr - * - * Description: - * Check if the virtual address lies in the user data area and, if so - * get the mapping to the physical address in the page pool. - * - ****************************************************************************/ - -uintptr_t arm_physpgaddr(uintptr_t vaddr); - -/**************************************************************************** - * Name: arm_virtpgaddr - * - * Description: - * Check if the physical address lies in the page pool and, if so - * get the mapping to the virtual address in the user data area. - * - ****************************************************************************/ - -uintptr_t arm_virtpgaddr(uintptr_t paddr); - #endif /* CONFIG_MM_PGALLOC */ #endif /* __ARCH_ARM_SRC_ARMV7_A_PGALLOC_H */