summaryrefslogtreecommitdiff
path: root/nuttx/mm
diff options
context:
space:
mode:
authorGregory Nutt <gnutt@nuttx.org>2014-09-23 16:04:39 -0600
committerGregory Nutt <gnutt@nuttx.org>2014-09-23 16:04:39 -0600
commitbda6baf012802a5748bbec3f5d3d8fc0ea398245 (patch)
tree70a7246e73e685637d9320e19608cc6140c50ff8 /nuttx/mm
parentf78a387b5ccea2d459a913b018c5a3fe1c24fac6 (diff)
downloadnuttx-bda6baf012802a5748bbec3f5d3d8fc0ea398245.tar.gz
nuttx-bda6baf012802a5748bbec3f5d3d8fc0ea398245.tar.bz2
nuttx-bda6baf012802a5748bbec3f5d3d8fc0ea398245.zip
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.
Diffstat (limited to 'nuttx/mm')
-rw-r--r--[-rwxr-xr-x]nuttx/mm/shm/shm_initialize.c69
1 files changed, 69 insertions, 0 deletions
diff --git a/nuttx/mm/shm/shm_initialize.c b/nuttx/mm/shm/shm_initialize.c
index 2b7d7d406..de942793c 100755..100644
--- a/nuttx/mm/shm/shm_initialize.c
+++ b/nuttx/mm/shm/shm_initialize.c
@@ -39,6 +39,15 @@
#include <nuttx/config.h>
+#include <assert.h>
+#include <errno.h>
+
+#include <nuttx/addrenv.h>
+#include <nuttx/sched.h>
+#include <nuttx/gran.h>
+#include <nuttx/pgalloc.h>
+#include <nuttx/shm.h>
+
#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 */