summaryrefslogtreecommitdiff
path: root/nuttx/mm
diff options
context:
space:
mode:
authorGregory Nutt <gnutt@nuttx.org>2014-09-02 11:21:23 -0600
committerGregory Nutt <gnutt@nuttx.org>2014-09-02 11:21:23 -0600
commit0c224f7e3dd878868fe921a5b41efe2362ce7fb6 (patch)
treeff432b46a6a217aa4bc58dee531ab70d1c7d29cd /nuttx/mm
parente33f20ad81548da27d8bf90a5889fc5f727d7cec (diff)
downloadnuttx-0c224f7e3dd878868fe921a5b41efe2362ce7fb6.tar.gz
nuttx-0c224f7e3dd878868fe921a5b41efe2362ce7fb6.tar.bz2
nuttx-0c224f7e3dd878868fe921a5b41efe2362ce7fb6.zip
Space at the beginning of the process data space is now reserved for user heap management structures. In the kernel build mode, these heap structures are shared between the kernel and use code in order to allocate user-specific data.
Diffstat (limited to 'nuttx/mm')
-rw-r--r--nuttx/mm/umm_addregion.c23
-rw-r--r--nuttx/mm/umm_brkaddr.c23
-rw-r--r--nuttx/mm/umm_calloc.c23
-rw-r--r--nuttx/mm/umm_extend.c23
-rw-r--r--nuttx/mm/umm_free.c23
-rw-r--r--nuttx/mm/umm_initialize.c23
-rw-r--r--nuttx/mm/umm_mallinfo.c24
-rw-r--r--nuttx/mm/umm_malloc.c25
-rw-r--r--nuttx/mm/umm_memalign.c23
-rw-r--r--nuttx/mm/umm_realloc.c23
-rw-r--r--nuttx/mm/umm_sbrk.c24
-rw-r--r--nuttx/mm/umm_sem.c25
-rw-r--r--nuttx/mm/umm_zalloc.c23
13 files changed, 243 insertions, 62 deletions
diff --git a/nuttx/mm/umm_addregion.c b/nuttx/mm/umm_addregion.c
index 4293529f8..a0eb3002c 100644
--- a/nuttx/mm/umm_addregion.c
+++ b/nuttx/mm/umm_addregion.c
@@ -41,12 +41,29 @@
#include <nuttx/mm.h>
-#ifdef CONFIG_MM_USER_HEAP
+#ifdef MM_KERNEL_USRHEAP_INTF
/************************************************************************
* Pre-processor definition
************************************************************************/
+#if defined(CONFIG_ARCH_ADDRENV) && defined(CONFIG_BUILD_KERNEL)
+/* In the kernel build, there a multiple user heaps; one for each task
+ * group. In this build configuration, the user heap structure lies
+ * in a reserved region at the beginning of the .bss/.data address
+ * space (CONFIG_ARCH_DATA_VBASE). The size of that region is given by
+ * ARCH_DATA_RESERVE
+ */
+
+# include <nuttx/addrenv.h>
+# define USR_HEAP ((FAR struct mm_heap_s *)CONFIG_ARCH_DATA_VBASE)
+
+#else
+/* Otherwise, the user heap data structures are in common .bss */
+
+# define USR_HEAP &g_mmheap;
+#endif
+
/************************************************************************
* Private Types
************************************************************************/
@@ -82,7 +99,7 @@
void umm_addregion(FAR void *heap_start, size_t heap_size)
{
- mm_addregion(&g_mmheap, heap_start, heap_size);
+ mm_addregion(USR_HEAP, heap_start, heap_size);
}
-#endif /* CONFIG_MM_USER_HEAP */
+#endif /* MM_KERNEL_USRHEAP_INTF */
diff --git a/nuttx/mm/umm_brkaddr.c b/nuttx/mm/umm_brkaddr.c
index dc646f20a..8bf047c56 100644
--- a/nuttx/mm/umm_brkaddr.c
+++ b/nuttx/mm/umm_brkaddr.c
@@ -43,12 +43,27 @@
#include <nuttx/mm.h>
-#ifdef CONFIG_MM_USER_HEAP
-
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
+#if defined(CONFIG_ARCH_ADDRENV) && defined(CONFIG_BUILD_KERNEL)
+/* In the kernel build, there a multiple user heaps; one for each task
+ * group. In this build configuration, the user heap structure lies
+ * in a reserved region at the beginning of the .bss/.data address
+ * space (CONFIG_ARCH_DATA_VBASE). The size of that region is given by
+ * ARCH_DATA_RESERVE
+ */
+
+# include <nuttx/addrenv.h>
+# define USR_HEAP ((FAR struct mm_heap_s *)CONFIG_ARCH_DATA_VBASE)
+
+#else
+/* Otherwise, the user heap data structures are in common .bss */
+
+# define USR_HEAP &g_mmheap;
+#endif
+
/****************************************************************************
* Public Functions
****************************************************************************/
@@ -63,7 +78,5 @@
FAR void *umm_brkaddr(int region)
{
- return mm_brkaddr(&g_mmheap, region);
+ return mm_brkaddr(USR_HEAP, region);
}
-
-#endif /* CONFIG_MM_USER_HEAP */
diff --git a/nuttx/mm/umm_calloc.c b/nuttx/mm/umm_calloc.c
index fd3ac60f2..2acf1c9d1 100644
--- a/nuttx/mm/umm_calloc.c
+++ b/nuttx/mm/umm_calloc.c
@@ -43,12 +43,27 @@
#include <nuttx/mm.h>
-#ifdef CONFIG_MM_USER_HEAP
-
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
+#if defined(CONFIG_ARCH_ADDRENV) && defined(CONFIG_BUILD_KERNEL)
+/* In the kernel build, there a multiple user heaps; one for each task
+ * group. In this build configuration, the user heap structure lies
+ * in a reserved region at the beginning of the .bss/.data address
+ * space (CONFIG_ARCH_DATA_VBASE). The size of that region is given by
+ * ARCH_DATA_RESERVE
+ */
+
+# include <nuttx/addrenv.h>
+# define USR_HEAP ((FAR struct mm_heap_s *)CONFIG_ARCH_DATA_VBASE)
+
+#else
+/* Otherwise, the user heap data structures are in common .bss */
+
+# define USR_HEAP &g_mmheap;
+#endif
+
/****************************************************************************
* Public Functions
****************************************************************************/
@@ -63,7 +78,5 @@
FAR void *calloc(size_t n, size_t elem_size)
{
- return mm_calloc(&g_mmheap, n, elem_size);
+ return mm_calloc(USR_HEAP, n, elem_size);
}
-
-#endif /* CONFIG_MM_USER_HEAP */
diff --git a/nuttx/mm/umm_extend.c b/nuttx/mm/umm_extend.c
index 6e16e56f8..6982ed813 100644
--- a/nuttx/mm/umm_extend.c
+++ b/nuttx/mm/umm_extend.c
@@ -41,12 +41,27 @@
#include <nuttx/mm.h>
-#ifdef CONFIG_MM_USER_HEAP
-
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
+#if defined(CONFIG_ARCH_ADDRENV) && defined(CONFIG_BUILD_KERNEL)
+/* In the kernel build, there a multiple user heaps; one for each task
+ * group. In this build configuration, the user heap structure lies
+ * in a reserved region at the beginning of the .bss/.data address
+ * space (CONFIG_ARCH_DATA_VBASE). The size of that region is given by
+ * ARCH_DATA_RESERVE
+ */
+
+# include <nuttx/addrenv.h>
+# define USR_HEAP ((FAR struct mm_heap_s *)CONFIG_ARCH_DATA_VBASE)
+
+#else
+/* Otherwise, the user heap data structures are in common .bss */
+
+# define USR_HEAP &g_mmheap;
+#endif
+
/****************************************************************************
* Public Functions
****************************************************************************/
@@ -62,7 +77,5 @@
void umm_extend(FAR void *mem, size_t size, int region)
{
- mm_extend(&g_mmheap, mem, size, region);
+ mm_extend(USR_HEAP, mem, size, region);
}
-
-#endif /* CONFIG_MM_USER_HEAP */
diff --git a/nuttx/mm/umm_free.c b/nuttx/mm/umm_free.c
index 366bf4560..e0f9f4faf 100644
--- a/nuttx/mm/umm_free.c
+++ b/nuttx/mm/umm_free.c
@@ -43,12 +43,27 @@
#include <nuttx/mm.h>
-#ifdef CONFIG_MM_USER_HEAP
-
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
+#if defined(CONFIG_ARCH_ADDRENV) && defined(CONFIG_BUILD_KERNEL)
+/* In the kernel build, there a multiple user heaps; one for each task
+ * group. In this build configuration, the user heap structure lies
+ * in a reserved region at the beginning of the .bss/.data address
+ * space (CONFIG_ARCH_DATA_VBASE). The size of that region is given by
+ * ARCH_DATA_RESERVE
+ */
+
+# include <nuttx/addrenv.h>
+# define USR_HEAP ((FAR struct mm_heap_s *)CONFIG_ARCH_DATA_VBASE)
+
+#else
+/* Otherwise, the user heap data structures are in common .bss */
+
+# define USR_HEAP &g_mmheap;
+#endif
+
/****************************************************************************
* Private Functions
****************************************************************************/
@@ -68,7 +83,5 @@
void free(FAR void *mem)
{
- mm_free(&g_mmheap, mem);
+ mm_free(USR_HEAP, mem);
}
-
-#endif /* CONFIG_MM_USER_HEAP */
diff --git a/nuttx/mm/umm_initialize.c b/nuttx/mm/umm_initialize.c
index be5e74f9d..9deaf61fa 100644
--- a/nuttx/mm/umm_initialize.c
+++ b/nuttx/mm/umm_initialize.c
@@ -41,7 +41,7 @@
#include <nuttx/mm.h>
-#ifdef CONFIG_MM_USER_HEAP
+#ifdef MM_KERNEL_USRHEAP_INTF
/************************************************************************
* Pre-processor definition
@@ -55,9 +55,23 @@
* Public Data
************************************************************************/
-/* This is the user heap */
+#if defined(CONFIG_ARCH_ADDRENV) && defined(CONFIG_BUILD_KERNEL)
+/* In the kernel build, there a multiple user heaps; one for each task
+ * group. In this build configuration, the user heap structure lies
+ * in a reserved region at the beginning of the .bss/.data address
+ * space (CONFIG_ARCH_DATA_VBASE). The size of that region is given by
+ * ARCH_DATA_RESERVE
+ */
+
+# include <nuttx/addrenv.h>
+# define USR_HEAP ((FAR struct mm_heap_s *)CONFIG_ARCH_DATA_VBASE)
+
+#else
+/* Otherwise, the user heap data structures are in common .bss */
struct mm_heap_s g_mmheap;
+#define USR_HEAP &g_mmheap;
+#endif
/************************************************************************
* Private Functions
@@ -86,7 +100,8 @@ struct mm_heap_s g_mmheap;
void umm_initialize(FAR void *heap_start, size_t heap_size)
{
- mm_initialize(&g_mmheap, heap_start, heap_size);
+ DEBUGASSERT(ARCH_DATA_RESERVE >= sizeof(struct mm_heap_s));
+ mm_initialize(USR_HEAP, heap_start, heap_size);
}
-#endif /* CONFIG_MM_USER_HEAP */
+#endif /* MM_KERNEL_USRHEAP_INTF */
diff --git a/nuttx/mm/umm_mallinfo.c b/nuttx/mm/umm_mallinfo.c
index 9ef03aec7..3a85b3229 100644
--- a/nuttx/mm/umm_mallinfo.c
+++ b/nuttx/mm/umm_mallinfo.c
@@ -43,12 +43,27 @@
#include <nuttx/mm.h>
-#ifdef CONFIG_MM_USER_HEAP
-
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
+#if defined(CONFIG_ARCH_ADDRENV) && defined(CONFIG_BUILD_KERNEL)
+/* In the kernel build, there a multiple user heaps; one for each task
+ * group. In this build configuration, the user heap structure lies
+ * in a reserved region at the beginning of the .bss/.data address
+ * space (CONFIG_ARCH_DATA_VBASE). The size of that region is given by
+ * ARCH_DATA_RESERVE
+ */
+
+# include <nuttx/addrenv.h>
+# define USR_HEAP ((FAR struct mm_heap_s *)CONFIG_ARCH_DATA_VBASE)
+
+#else
+/* Otherwise, the user heap data structures are in common .bss */
+
+# define USR_HEAP &g_mmheap;
+#endif
+
/****************************************************************************
* Private Data
****************************************************************************/
@@ -75,7 +90,7 @@
struct mallinfo mallinfo(void)
{
struct mallinfo info;
- mm_mallinfo(&g_mmheap, &info);
+ mm_mallinfo(USR_HEAP, &info);
return info;
}
@@ -83,8 +98,7 @@ struct mallinfo mallinfo(void)
int mallinfo(struct mallinfo *info)
{
- return mm_mallinfo(&g_mmheap, info);
+ return mm_mallinfo(USR_HEAP, info);
}
#endif /* CONFIG_CAN_PASS_STRUCTS */
-#endif /* CONFIG_MM_USER_HEAP */
diff --git a/nuttx/mm/umm_malloc.c b/nuttx/mm/umm_malloc.c
index a2f68eca3..8a0bdfec7 100644
--- a/nuttx/mm/umm_malloc.c
+++ b/nuttx/mm/umm_malloc.c
@@ -44,12 +44,27 @@
#include <nuttx/mm.h>
-#ifdef CONFIG_MM_USER_HEAP
-
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
+#if defined(CONFIG_ARCH_ADDRENV) && defined(CONFIG_BUILD_KERNEL)
+/* In the kernel build, there a multiple user heaps; one for each task
+ * group. In this build configuration, the user heap structure lies
+ * in a reserved region at the beginning of the .bss/.data address
+ * space (CONFIG_ARCH_DATA_VBASE). The size of that region is given by
+ * ARCH_DATA_RESERVE
+ */
+
+# include <nuttx/addrenv.h>
+# define USR_HEAP ((FAR struct mm_heap_s *)CONFIG_ARCH_DATA_VBASE)
+
+#else
+/* Otherwise, the user heap data structures are in common .bss */
+
+# define USR_HEAP &g_mmheap;
+#endif
+
/****************************************************************************
* Type Definitions
****************************************************************************/
@@ -103,7 +118,7 @@ FAR void *malloc(size_t size)
do
{
- mem = mm_malloc(&g_mmheap, size);
+ mem = mm_malloc(USR_HEAP, size);
if (!mem)
{
brkaddr = sbrk(size);
@@ -117,8 +132,6 @@ FAR void *malloc(size_t size)
return mem;
#else
- return mm_malloc(&g_mmheap, size);
+ return mm_malloc(USR_HEAP, size);
#endif
}
-
-#endif /* CONFIG_MM_USER_HEAP */
diff --git a/nuttx/mm/umm_memalign.c b/nuttx/mm/umm_memalign.c
index 429b81f89..cd098d12c 100644
--- a/nuttx/mm/umm_memalign.c
+++ b/nuttx/mm/umm_memalign.c
@@ -43,12 +43,27 @@
#include <nuttx/mm.h>
-#ifdef CONFIG_MM_USER_HEAP
-
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
+#if defined(CONFIG_ARCH_ADDRENV) && defined(CONFIG_BUILD_KERNEL)
+/* In the kernel build, there a multiple user heaps; one for each task
+ * group. In this build configuration, the user heap structure lies
+ * in a reserved region at the beginning of the .bss/.data address
+ * space (CONFIG_ARCH_DATA_VBASE). The size of that region is given by
+ * ARCH_DATA_RESERVE
+ */
+
+# include <nuttx/addrenv.h>
+# define USR_HEAP ((FAR struct mm_heap_s *)CONFIG_ARCH_DATA_VBASE)
+
+#else
+/* Otherwise, the user heap data structures are in common .bss */
+
+# define USR_HEAP &g_mmheap;
+#endif
+
/****************************************************************************
* Private Functions
****************************************************************************/
@@ -72,7 +87,5 @@
FAR void *memalign(size_t alignment, size_t size)
{
- return mm_memalign(&g_mmheap, alignment, size);
+ return mm_memalign(USR_HEAP, alignment, size);
}
-
-#endif /* CONFIG_MM_USER_HEAP */
diff --git a/nuttx/mm/umm_realloc.c b/nuttx/mm/umm_realloc.c
index 6791bb18b..9fdad8fee 100644
--- a/nuttx/mm/umm_realloc.c
+++ b/nuttx/mm/umm_realloc.c
@@ -43,12 +43,27 @@
#include <nuttx/mm.h>
-#ifdef CONFIG_MM_USER_HEAP
-
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
+#if defined(CONFIG_ARCH_ADDRENV) && defined(CONFIG_BUILD_KERNEL)
+/* In the kernel build, there a multiple user heaps; one for each task
+ * group. In this build configuration, the user heap structure lies
+ * in a reserved region at the beginning of the .bss/.data address
+ * space (CONFIG_ARCH_DATA_VBASE). The size of that region is given by
+ * ARCH_DATA_RESERVE
+ */
+
+# include <nuttx/addrenv.h>
+# define USR_HEAP ((FAR struct mm_heap_s *)CONFIG_ARCH_DATA_VBASE)
+
+#else
+/* Otherwise, the user heap data structures are in common .bss */
+
+# define USR_HEAP &g_mmheap;
+#endif
+
/****************************************************************************
* Private Functions
****************************************************************************/
@@ -74,7 +89,5 @@
FAR void *realloc(FAR void *oldmem, size_t size)
{
- return mm_realloc(&g_mmheap, oldmem, size);
+ return mm_realloc(USR_HEAP, oldmem, size);
}
-
-#endif /* CONFIG_MM_USER_HEAP */
diff --git a/nuttx/mm/umm_sbrk.c b/nuttx/mm/umm_sbrk.c
index b404b020c..9c26a3de4 100644
--- a/nuttx/mm/umm_sbrk.c
+++ b/nuttx/mm/umm_sbrk.c
@@ -44,12 +44,30 @@
#include <nuttx/mm.h>
#include <nuttx/pgalloc.h>
-#if defined(CONFIG_MM_USER_HEAP) && defined(CONFIG_ARCH_ADDRENV)
+#if defined(CONFIG_ARCH_ADDRENV) && defined(CONFIG_MM_PGALLOC) && \
+ defined(CONFIG_ARCH_USE_MMU)
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
+#if defined(CONFIG_ARCH_ADDRENV) && defined(CONFIG_BUILD_KERNEL)
+/* In the kernel build, there a multiple user heaps; one for each task
+ * group. In this build configuration, the user heap structure lies
+ * in a reserved region at the beginning of the .bss/.data address
+ * space (CONFIG_ARCH_DATA_VBASE). The size of that region is given by
+ * ARCH_DATA_RESERVE
+ */
+
+# include <nuttx/addrenv.h>
+# define USR_HEAP ((FAR struct mm_heap_s *)CONFIG_ARCH_DATA_VBASE)
+
+#else
+/* Otherwise, the user heap data structures are in common .bss */
+
+# define USR_HEAP &g_mmheap;
+#endif
+
/****************************************************************************
* Public Functions
****************************************************************************/
@@ -88,7 +106,7 @@
FAR void *sbrk(intptr_t incr)
{
- return mm_sbrk(&g_mmheap, incr, CONFIG_ARCH_STACK_NPAGES << MM_PGSHIFT);
+ return mm_sbrk(USR_HEAP, incr, CONFIG_ARCH_STACK_NPAGES << MM_PGSHIFT);
}
-#endif /* CONFIG_MM_USER_HEAP && CONFIG_ARCH_ADDRENV */
+#endif /* CONFIG_ARCH_ADDRENV && CONFIG_MM_PGALLOC && CONFIG_ARCH_USE_MMU */
diff --git a/nuttx/mm/umm_sem.c b/nuttx/mm/umm_sem.c
index d390865ca..6242f1719 100644
--- a/nuttx/mm/umm_sem.c
+++ b/nuttx/mm/umm_sem.c
@@ -41,12 +41,27 @@
#include <nuttx/mm.h>
-#ifdef CONFIG_MM_USER_HEAP
-
/************************************************************************
* Pre-processor definition
************************************************************************/
+#if defined(CONFIG_ARCH_ADDRENV) && defined(CONFIG_BUILD_KERNEL)
+/* In the kernel build, there a multiple user heaps; one for each task
+ * group. In this build configuration, the user heap structure lies
+ * in a reserved region at the beginning of the .bss/.data address
+ * space (CONFIG_ARCH_DATA_VBASE). The size of that region is given by
+ * ARCH_DATA_RESERVE
+ */
+
+# include <nuttx/addrenv.h>
+# define USR_HEAP ((FAR struct mm_heap_s *)CONFIG_ARCH_DATA_VBASE)
+
+#else
+/* Otherwise, the user heap data structures are in common .bss */
+
+# define USR_HEAP &g_mmheap;
+#endif
+
/************************************************************************
* Private Types
************************************************************************/
@@ -81,7 +96,7 @@
int umm_trysemaphore(void)
{
- return mm_trysemaphore(&g_mmheap);
+ return mm_trysemaphore(USR_HEAP);
}
/************************************************************************
@@ -102,7 +117,5 @@ int umm_trysemaphore(void)
void umm_givesemaphore(void)
{
- mm_givesemaphore(&g_mmheap);
+ mm_givesemaphore(USR_HEAP);
}
-
-#endif /* CONFIG_MM_USER_HEAP */
diff --git a/nuttx/mm/umm_zalloc.c b/nuttx/mm/umm_zalloc.c
index 835841a75..0c2ddddeb 100644
--- a/nuttx/mm/umm_zalloc.c
+++ b/nuttx/mm/umm_zalloc.c
@@ -44,12 +44,27 @@
#include <nuttx/mm.h>
-#ifdef CONFIG_MM_USER_HEAP
-
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
+#if defined(CONFIG_ARCH_ADDRENV) && defined(CONFIG_BUILD_KERNEL)
+/* In the kernel build, there a multiple user heaps; one for each task
+ * group. In this build configuration, the user heap structure lies
+ * in a reserved region at the beginning of the .bss/.data address
+ * space (CONFIG_ARCH_DATA_VBASE). The size of that region is given by
+ * ARCH_DATA_RESERVE
+ */
+
+# include <nuttx/addrenv.h>
+# define USR_HEAP ((FAR struct mm_heap_s *)CONFIG_ARCH_DATA_VBASE)
+
+#else
+/* Otherwise, the user heap data structures are in common .bss */
+
+# define USR_HEAP &g_mmheap;
+#endif
+
/****************************************************************************
* Public Functions
****************************************************************************/
@@ -84,8 +99,6 @@ FAR void *zalloc(size_t size)
#else
/* Use mm_zalloc() becuase it implements the clear */
- return mm_zalloc(&g_mmheap, size);
+ return mm_zalloc(USR_HEAP, size);
#endif
}
-
-#endif /* CONFIG_MM_USER_HEAP */