From bda6baf012802a5748bbec3f5d3d8fc0ea398245 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Tue, 23 Sep 2014 16:04:39 -0600 Subject: Add support for a per-process virtual page allocator. This is a new member of the task_group_s structure. The allocaor must be initialized when a new user process is started and uninitialize when the process group is finally destroyed. It is used by shmat() and shmdt() to pick the virtual address onto which to map the shared physical memory. --- nuttx/mm/shm/shm_initialize.c | 69 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) mode change 100755 => 100644 nuttx/mm/shm/shm_initialize.c (limited to 'nuttx/mm') diff --git a/nuttx/mm/shm/shm_initialize.c b/nuttx/mm/shm/shm_initialize.c old mode 100755 new mode 100644 index 2b7d7d406..de942793c --- a/nuttx/mm/shm/shm_initialize.c +++ b/nuttx/mm/shm/shm_initialize.c @@ -39,6 +39,15 @@ #include +#include +#include + +#include +#include +#include +#include +#include + #include "shm/shm.h" #ifdef CONFIG_MM_SHM @@ -104,4 +113,64 @@ void shm_initialize(void) #endif } +/**************************************************************************** + * Name: shm_group_initialize + * + * Description: + * Initialize the group shared memory data structures when a new task + * group is initialized. + * + * Input Parameters: + * group - A reference to the new group structure to be initialized. + * + * Returned Value: + * Zero (OK) on success; a negated errno value on failure. + * + ****************************************************************************/ + +int shm_group_initialize(FAR struct task_group_s *group) +{ + DEBUGASSERT(group && !group->tg_shm.gs_handle); + + group->tg_shm.gs_handle = + gran_initialize((FAR void *)CONFIG_ARCH_SHM_VBASE, + ARCH_SHM_MAXPAGES << MM_PGSHIFT, + MM_PGSHIFT, MM_PGSHIFT); + + if (!group->tg_shm.gs_handle) + { + shmdbg("gran_initialize() failed\n"); + return -ENOMEM; + } + + return OK; +} + +/**************************************************************************** + * Name: shm_group_release + * + * Description: + * Release resources used by the group shared memory logic. This function + * is called at the time at the group is destroyed. + * + * Input Parameters: + * group - A reference to the group structure to be un-initialized. + * + * Returned Value: + * None + * + ****************************************************************************/ + +void shm_group_release(FAR struct task_group_s *group) +{ + GRAN_HANDLE handle; + DEBUGASSERT(group) + + handle = group->tg_shm.gs_handle; + if (handle) + { + gran_release(handle); + } +} + #endif /* CONFIG_MM_SHM */ -- cgit v1.2.3