summaryrefslogtreecommitdiff
path: root/nuttx
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
parente33f20ad81548da27d8bf90a5889fc5f727d7cec (diff)
downloadpx4-nuttx-0c224f7e3dd878868fe921a5b41efe2362ce7fb6.tar.gz
px4-nuttx-0c224f7e3dd878868fe921a5b41efe2362ce7fb6.tar.bz2
px4-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')
-rw-r--r--nuttx/arch/arm/src/armv7-a/arm_addrenv.c15
-rw-r--r--nuttx/include/nuttx/addrenv.h16
-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
15 files changed, 270 insertions, 66 deletions
diff --git a/nuttx/arch/arm/src/armv7-a/arm_addrenv.c b/nuttx/arch/arm/src/armv7-a/arm_addrenv.c
index fe765a182..bdb6c291d 100644
--- a/nuttx/arch/arm/src/armv7-a/arm_addrenv.c
+++ b/nuttx/arch/arm/src/armv7-a/arm_addrenv.c
@@ -329,7 +329,10 @@ static void up_addrenv_destroy_region(FAR uintptr_t **list,
* textsize - The size (in bytes) of the .text address environment needed
* by the task. This region may be read/execute only.
* datasize - The size (in bytes) of the .data/.bss address environment
- * needed by the task. This region may be read/write only.
+ * needed by the task. This region may be read/write only. NOTE: The
+ * actual size of the data region that is allocated will include a
+ * OS private reserved region at the beginning. The size of the
+ * private, reserved region is give by ARCH_DATA_RESERVE.
* addrenv - The location to return the representation of the task address
* environment.
*
@@ -368,10 +371,14 @@ int up_addrenv_create(size_t textsize, size_t datasize,
goto errout;
}
- /* Allocate .bss/.data space pages */
+ /* Allocate .bss/.data space pages. NOTE that a configurable offset is
+ * added to the allocted size. This is matched by the offset that is
+ * used when reporting the virtual data address in up_addrenv_vdata().
+ */
ret = up_addrenv_create_region(addrenv->data, ARCH_DATA_NSECTS,
- CONFIG_ARCH_DATA_VBASE, datasize,
+ CONFIG_ARCH_DATA_VBASE,
+ datasize + ARCH_DATA_RESERVE,
MMU_L2_UDATAFLAGS);
if (ret < 0)
{
@@ -488,7 +495,7 @@ int up_addrenv_vdata(FAR group_addrenv_t *addrenv, uintptr_t textsize,
/* Not much to do in this case */
DEBUGASSERT(addrenv && vdata);
- *vdata = (FAR void *)CONFIG_ARCH_DATA_VBASE;
+ *vdata = (FAR void *)(CONFIG_ARCH_DATA_VBASE + ARCH_DATA_RESERVE);
return OK;
}
diff --git a/nuttx/include/nuttx/addrenv.h b/nuttx/include/nuttx/addrenv.h
index 1825a0170..49a46c897 100644
--- a/nuttx/include/nuttx/addrenv.h
+++ b/nuttx/include/nuttx/addrenv.h
@@ -96,6 +96,22 @@
#define ARCH_DATA_SIZE (CONFIG_ARCH_DATA_NPAGES * CONFIG_MM_PGSIZE)
#define ARCH_DATA_VEND (CONFIG_ARCH_DATA_VBASE + ARCH_DATA_SIZE)
+/* Reserved .bss/.data region. In the kernel build (CONFIG_BUILD_KERNEL),
+ * the region at the beginning of the .bss/.data region is reserved for use
+ * by the OS. This reserved region contains only the task group's heap
+ * memory management data structures.
+ *
+ * We don't use sizeof(struct mm_heap_s) but, instead, a nice even number
+ * that we must be assure is greater than or equal to
+ * sizeof(struct mm_heap_s)
+ */
+
+#ifdef CONFIG_BUILD_KERNEL
+# define ARCH_DATA_RESERVE 512
+#else
+# define ARCH_DATA_RESERVE 0
+#endif
+
/* Heap region */
#ifndef CONFIG_ARCH_HEAP_VBASE
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 */