arch/Kconfig: remove virtual memory allocator dependency from MM_SHM

The dependency should be vice versa; the MM_SHM should depend on the
existence of the virtual memory range allocator.

Create a new CONFIG flag CONFIG_ARCH_VMA_MAPPING, which will define that
there is a virtual memory range allocator. Make MM_SHM select that flag

Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
This commit is contained in:
Jukka Laitinen 2023-01-11 13:56:59 +04:00 committed by Xiang Xiao
parent fd0195b0d8
commit 70de321de3
14 changed files with 29 additions and 24 deletions

View File

@ -534,9 +534,13 @@ config ARCH_HEAP_VBASE
---help---
The virtual address of the beginning of the heap region.
config ARCH_VMA_MAPPING
bool "Support runtime memory mapping into SHM area"
default n
config ARCH_SHM_VBASE
hex "Shared memory base"
depends on MM_SHM
depends on ARCH_VMA_MAPPING
---help---
The virtual address of the beginning of the shared memory region.
@ -564,7 +568,7 @@ config ARCH_HEAP_NPAGES
This, along with knowledge of the page size, determines the size of
the heap virtual address space. Default is 1.
if MM_SHM
if ARCH_VMA_MAPPING
config ARCH_SHM_MAXREGIONS
int "Max shared memory regions"
@ -592,7 +596,7 @@ config ARCH_SHM_NPAGES
maximum number of pages per region, and the configured size of
each page.
endif # MM_SHM
endif # ARCH_VMA_MAPPING
config ARCH_STACK_DYNAMIC
bool "Dynamic user stack"

View File

@ -95,7 +95,7 @@ do { \
# define ARCH_DATA_NSECTS ARCH_PG2SECT(CONFIG_ARCH_DATA_NPAGES)
# define ARCH_HEAP_NSECTS ARCH_PG2SECT(CONFIG_ARCH_HEAP_NPAGES)
# ifdef CONFIG_MM_SHM
# ifdef CONFIG_ARCH_VMA_MAPPING
# define ARCH_SHM_NSECTS ARCH_PG2SECT(ARCH_SHM_MAXPAGES)
# endif
@ -138,7 +138,7 @@ struct group_addrenv_s
uintptr_t *data[ARCH_DATA_NSECTS];
#ifdef CONFIG_BUILD_KERNEL
uintptr_t *heap[ARCH_HEAP_NSECTS];
#ifdef CONFIG_MM_SHM
#ifdef CONFIG_ARCH_VMA_MAPPING
uintptr_t *shm[ARCH_SHM_NSECTS];
#endif
@ -169,7 +169,7 @@ struct save_addrenv_s
uint32_t data[ARCH_DATA_NSECTS];
#ifdef CONFIG_BUILD_KERNEL
uint32_t heap[ARCH_HEAP_NSECTS];
#ifdef CONFIG_MM_SHM
#ifdef CONFIG_ARCH_VMA_MAPPING
uint32_t shm[ARCH_SHM_NSECTS];
#endif
#endif

View File

@ -71,7 +71,7 @@ ifeq ($(CONFIG_ARCH_ADDRENV),y)
ifeq ($(CONFIG_ARCH_KERNEL_STACK),y)
CMN_CSRCS += arm_addrenv_kstack.c
endif
ifeq ($(CONFIG_MM_SHM),y)
ifeq ($(CONFIG_ARCH_VMA_MAPPING),y)
CMN_CSRCS += arm_addrenv_shm.c
endif
endif

View File

@ -346,7 +346,7 @@ int up_addrenv_destroy(group_addrenv_t *addrenv)
arm_addrenv_destroy_region(addrenv->heap, ARCH_HEAP_NSECTS,
CONFIG_ARCH_HEAP_VBASE, false);
#ifdef CONFIG_MM_SHM
#ifdef CONFIG_ARCH_VMA_MAPPING
/* Destroy the shared memory region (without freeing the physical page
* data).
*/
@ -592,7 +592,7 @@ int up_addrenv_select(const group_addrenv_t *addrenv,
}
}
#ifdef CONFIG_MM_SHM
#ifdef CONFIG_ARCH_VMA_MAPPING
for (vaddr = CONFIG_ARCH_SHM_VBASE, i = 0;
i < ARCH_SHM_NSECTS;
vaddr += SECTION_SIZE, i++)
@ -676,7 +676,7 @@ int up_addrenv_restore(const save_addrenv_t *oldenv)
mmu_l1_restore(vaddr, oldenv->heap[i]);
}
#ifdef CONFIG_MM_SHM
#ifdef CONFIG_ARCH_VMA_MAPPING
for (vaddr = CONFIG_ARCH_SHM_VBASE, i = 0;
i < ARCH_SHM_NSECTS;
vaddr += SECTION_SIZE, i++)

View File

@ -38,7 +38,7 @@
#include "addrenv.h"
#include "pgalloc.h"
#if defined(CONFIG_BUILD_KERNEL) && defined(CONFIG_MM_SHM)
#if defined(CONFIG_BUILD_KERNEL) && defined(CONFIG_ARCH_VMA_MAPPING)
/****************************************************************************
* Public Functions
@ -269,4 +269,4 @@ int up_shmdt(uintptr_t vaddr, unsigned int npages)
return OK;
}
#endif /* CONFIG_BUILD_KERNEL && CONFIG_MM_SHM */
#endif /* CONFIG_BUILD_KERNEL && CONFIG_ARCH_VMA_MAPPING */

View File

@ -92,7 +92,7 @@ static inline bool arm_uservaddr(uintptr_t vaddr)
#ifdef CONFIG_ARCH_STACK_DYNAMIC
|| (vaddr >= CONFIG_ARCH_STACK_VBASE && vaddr < ARCH_STACK_VEND)
#endif
#ifdef CONFIG_MM_SHM
#ifdef CONFIG_ARCH_VMA_MAPPING
|| (vaddr >= CONFIG_ARCH_SHM_VBASE && vaddr < ARCH_SHM_VEND)
#endif
);

View File

@ -75,7 +75,7 @@ struct group_addrenv_s
uintptr_t *data[ARCH_DATA_NSECTS];
#ifdef CONFIG_BUILD_KERNEL
uintptr_t *heap[ARCH_HEAP_NSECTS];
#ifdef CONFIG_MM_SHM
#ifdef CONFIG_ARCH_VMA_MAPPING
uintptr_t *shm[ARCH_SHM_NSECTS];
#endif
@ -106,7 +106,7 @@ struct save_addrenv_s
uint32_t data[ARCH_DATA_NSECTS];
#ifdef CONFIG_BUILD_KERNEL
uint32_t heap[ARCH_HEAP_NSECTS];
#ifdef CONFIG_MM_SHM
#ifdef CONFIG_ARCH_VMA_MAPPING
uint32_t shm[ARCH_SHM_NSECTS];
#endif
#endif

View File

@ -74,7 +74,7 @@ endif
ifeq ($(CONFIG_ARCH_KERNEL_STACK),y)
CMN_CSRCS += arm64_addrenv_kstack.c
endif
ifeq ($(CONFIG_MM_SHM),y)
ifeq ($(CONFIG_ARCH_VMA_MAPPING),y)
CMN_CSRCS += arm64_addrenv_shm.c
endif
endif

View File

@ -57,7 +57,7 @@
# define ARCH_DATA_NSECTS ARCH_PG2SECT(CONFIG_ARCH_DATA_NPAGES)
# define ARCH_HEAP_NSECTS ARCH_PG2SECT(CONFIG_ARCH_HEAP_NPAGES)
# ifdef CONFIG_MM_SHM
# ifdef CONFIG_ARCH_VMA_MAPPING
# define ARCH_SHM_NSECTS ARCH_PG2SECT(ARCH_SHM_MAXPAGES)
# endif
@ -89,7 +89,7 @@ struct group_addrenv_s
uintptr_t *data[ARCH_DATA_NSECTS];
#ifdef CONFIG_BUILD_KERNEL
uintptr_t *heap[ARCH_HEAP_NSECTS];
#ifdef CONFIG_MM_SHM
#ifdef CONFIG_ARCH_VMA_MAPPING
uintptr_t *shm[ARCH_SHM_NSECTS];
#endif
@ -120,7 +120,7 @@ struct save_addrenv_s
uint32_t data[ARCH_DATA_NSECTS];
#ifdef CONFIG_BUILD_KERNEL
uint32_t heap[ARCH_HEAP_NSECTS];
#ifdef CONFIG_MM_SHM
#ifdef CONFIG_ARCH_VMA_MAPPING
uint32_t shm[ARCH_SHM_NSECTS];
#endif
#endif

View File

@ -39,7 +39,7 @@
#include "pgalloc.h"
#include "riscv_mmu.h"
#if defined(CONFIG_BUILD_KERNEL) && defined(CONFIG_MM_SHM)
#if defined(CONFIG_BUILD_KERNEL) && defined(CONFIG_ARCH_VMA_MAPPING)
/****************************************************************************
* Public Functions

View File

@ -298,7 +298,7 @@ int exec_module(FAR const struct binary_s *binp,
return (int)pid;
#if defined(CONFIG_ARCH_ADDRENV) || defined(CONFIG_MM_SHM)
#if defined(CONFIG_ARCH_ADDRENV) || defined(CONFIG_ARCH_VMA_MAPPING)
errout_with_tcbinit:
tcb->cmn.stack_alloc_ptr = NULL;
nxsched_release_tcb(&tcb->cmn, TCB_FLAG_TTYPE_TASK);

View File

@ -164,7 +164,7 @@
/* Shared memory regions */
#ifdef CONFIG_MM_SHM
#ifdef CONFIG_ARCH_VMA_MAPPING
# ifndef CONFIG_ARCH_SHM_VBASE
# error CONFIG_ARCH_SHM_VBASE not defined
# define CONFIG_ARCH_SHM_VBASE __ARCH_SHM_VBASE

View File

@ -1346,7 +1346,7 @@ uintptr_t up_addrenv_va_to_pa(FAR void *va);
*
****************************************************************************/
#ifdef CONFIG_MM_SHM
#ifdef CONFIG_ARCH_VMA_MAPPING
int up_shmat(FAR uintptr_t *pages, unsigned int npages, uintptr_t vaddr);
#endif
@ -1367,7 +1367,7 @@ int up_shmat(FAR uintptr_t *pages, unsigned int npages, uintptr_t vaddr);
*
****************************************************************************/
#ifdef CONFIG_MM_SHM
#ifdef CONFIG_ARCH_VMA_MAPPING
int up_shmdt(uintptr_t vaddr, unsigned int npages);
#endif

View File

@ -162,6 +162,7 @@ config MM_SHM
bool "Shared memory support"
default n
depends on MM_PGALLOC && BUILD_KERNEL
select ARCH_VMA_MAPPING
---help---
Build in support for the shared memory interfaces shmget(), shmat(),
shmctl(), and shmdt().