diff --git a/configs b/configs index 6112bb03841..8e27cf333e7 160000 --- a/configs +++ b/configs @@ -1 +1 @@ -Subproject commit 6112bb038416a3553504fad20eca1bd39f79b371 +Subproject commit 8e27cf333e78b19ade6dff857e865cdf65056253 diff --git a/include/nuttx/kmalloc.h b/include/nuttx/kmalloc.h index 43d9f344c1a..162b9356db4 100644 --- a/include/nuttx/kmalloc.h +++ b/include/nuttx/kmalloc.h @@ -89,31 +89,11 @@ extern "C" #define kumm_trysemaphore() umm_trysemaphore() #define kumm_givesemaphore() umm_givesemaphore() -#ifdef CONFIG_BUILD_PROTECTED -/* In the kernel-phase of the protected build, the these macros are defined - * in userspace.h. These macros version call into user-space via a header - * at the beginning of the user-space blob. - */ - -# define kumm_malloc(s) umm_malloc(s) -# define kumm_zalloc(s) umm_zalloc(s) -# define kumm_realloc(p,s) umm_realloc(p,s) -# define kumm_memalign(a,s) umm_memalign(a,s) -# define kumm_free(p) umm_free(p) - -#else -/* In the flat build (CONFIG_BUILD_FLAT) and in the kernel build - * (CONFIG_BUILD_KERNEL), the following are declared in stdlib.h and are - * directly callable. - */ - -# define kumm_malloc(s) malloc(s) -# define kumm_zalloc(s) zalloc(s) -# define kumm_realloc(p,s) realloc(p,s) -# define kumm_memalign(a,s) memalign(a,s) -# define kumm_free(p) free(p) - -#endif +#define kumm_malloc(s) malloc(s) +#define kumm_zalloc(s) zalloc(s) +#define kumm_realloc(p,s) realloc(p,s) +#define kumm_memalign(a,s) memalign(a,s) +#define kumm_free(p) free(p) /* This family of allocators is used to manage kernel protected memory */ diff --git a/include/nuttx/mm/mm.h b/include/nuttx/mm/mm.h index 738640a7f2b..b12f4366aa0 100644 --- a/include/nuttx/mm/mm.h +++ b/include/nuttx/mm/mm.h @@ -276,7 +276,6 @@ extern "C" #define EXTERN extern #endif -#if !defined(CONFIG_BUILD_PROTECTED) || !defined(__KERNEL__) /* User heap structure: * * - Flat build: In the FLAT build, the user heap structure is a globally @@ -288,6 +287,23 @@ extern "C" * no global user heap structure. */ + #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_SIZE + */ + +#elif defined(CONFIG_BUILD_PROTECTED) && defined(__KERNEL__) +/* In the protected mode, there are two heaps: A kernel heap and a single + * user heap. In that case the user heap structure lies in the user space + * (with a reference in the userspace interface). + */ + +#else +/* Otherwise, the user heap data structures are in common .bss */ + EXTERN struct mm_heap_s g_mmheap; #endif diff --git a/include/nuttx/userspace.h b/include/nuttx/userspace.h index db21e967df1..6e1afc2aa15 100644 --- a/include/nuttx/userspace.h +++ b/include/nuttx/userspace.h @@ -83,22 +83,13 @@ * they can be called through the userspace structure. */ -#if defined(CONFIG_BUILD_PROTECTED) && defined(__KERNEL__) -# define umm_initialize(b,s) USERSPACE->mm_initialize(b,s) -# define umm_addregion(b,s) USERSPACE->mm_addregion(b,s) -# define umm_trysemaphore() USERSPACE->mm_trysemaphore() -# define umm_givesemaphore() USERSPACE->mm_givesemaphore() -# define umm_malloc(s) USERSPACE->mm_malloc(s) -# define umm_zalloc(s) USERSPACE->mm_zalloc(s) -# define umm_realloc(p,s) USERSPACE->mm_realloc(p,s) -# define umm_memalign(a,s) USERSPACE->mm_memalign(a,s) -# define umm_free(p) USERSPACE->mm_free(p) -#endif - /**************************************************************************** - * Type Definitions + * Public Type Definitions ****************************************************************************/ -/* Every user-space blob starts with a header that provides information about + +struct mm_heaps_s; /* Forward reference */ + + /* Every user-space blob starts with a header that provides information about * the blob. The form of that header is provided by struct userspace_s. An * instance of this structure is expected to reside at CONFIG_NUTTX_USERSPACE. */ @@ -116,6 +107,10 @@ struct userspace_s uintptr_t us_bssstart; uintptr_t us_bssend; + /* Memory manager heap structure */ + + FAR struct mm_heap_s *us_heap; + /* Task/thread startup routines */ void (*task_startup)(main_t entrypt, int argc, FAR char *argv[]) @@ -132,21 +127,6 @@ struct userspace_s FAR siginfo_t *info, FAR void *ucontext); #endif - /* Memory manager entry points */ - - void (*mm_initialize)(FAR void *heap_start, size_t heap_size); - void (*mm_addregion)(FAR void *heap_start, size_t heap_size); - int (*mm_trysemaphore)(void); - void (*mm_givesemaphore)(void); - - FAR void *(*mm_malloc)(size_t size); - FAR void *(*mm_realloc)(FAR void *oldmem, size_t newsize); -#if 0 /* Not yet integrated */ - FAR void *(*mm_memalign)(size_t alignment, size_t size); -#endif - FAR void *(*mm_zalloc)(size_t size); - void (*mm_free)(FAR void *mem); - /* User-space work queue support */ #ifdef CONFIG_LIB_USRWORK diff --git a/mm/umm_heap/Make.defs b/mm/umm_heap/Make.defs index f29870d216b..20409c38066 100644 --- a/mm/umm_heap/Make.defs +++ b/mm/umm_heap/Make.defs @@ -1,7 +1,7 @@ ############################################################################ # mm/umm_heap/Make.defs # -# Copyright (C) 2014 Gregory Nutt. All rights reserved. +# Copyright (C) 2014-2015 Gregory Nutt. All rights reserved. # Author: Gregory Nutt # # Redistribution and use in source and binary forms, with or without @@ -38,6 +38,7 @@ CSRCS += umm_initialize.c umm_addregion.c umm_sem.c CSRCS += umm_brkaddr.c umm_calloc.c umm_extend.c umm_free.c umm_mallinfo.c CSRCS += umm_malloc.c umm_memalign.c umm_realloc.c umm_zalloc.c +CSRCS += umm_globals.c ifeq ($(CONFIG_BUILD_KERNEL),y) CSRCS += umm_sbrk.c diff --git a/mm/umm_heap/umm_addregion.c b/mm/umm_heap/umm_addregion.c index 3e756a999ae..3aaa890aa23 100644 --- a/mm/umm_heap/umm_addregion.c +++ b/mm/umm_heap/umm_addregion.c @@ -1,7 +1,7 @@ /************************************************************************ * mm/umm_heap/umm_addregion.c * - * Copyright (C) 2013-2014 Gregory Nutt. All rights reserved. + * Copyright (C) 2013-2015 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -41,40 +41,7 @@ #include -#if !defined(CONFIG_BUILD_PROTECTED) || !defined(__KERNEL__) - -/************************************************************************ - * 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_SIZE - */ - -# include -# define USR_HEAP (&ARCH_DATA_RESERVE->ar_usrheap) - -#else -/* Otherwise, the user heap data structures are in common .bss */ - -# define USR_HEAP &g_mmheap -#endif - -/************************************************************************ - * Private Types - ************************************************************************/ - -/************************************************************************ - * Public Data - ************************************************************************/ - -/************************************************************************ - * Private Functions - ************************************************************************/ +#include "umm_heap/umm_heap.h" /************************************************************************ * Public Functions @@ -101,5 +68,3 @@ void umm_addregion(FAR void *heap_start, size_t heap_size) { mm_addregion(USR_HEAP, heap_start, heap_size); } - -#endif /* !CONFIG_BUILD_PROTECTED || !__KERNEL__ */ diff --git a/mm/umm_heap/umm_brkaddr.c b/mm/umm_heap/umm_brkaddr.c index 217f00641bf..f31b7c870e7 100644 --- a/mm/umm_heap/umm_brkaddr.c +++ b/mm/umm_heap/umm_brkaddr.c @@ -1,7 +1,7 @@ /**************************************************************************** * mm/umm_heap/umm_breakaddr.c * - * Copyright (C) 2014 Gregory Nutt. All rights reserved. + * Copyright (C) 2014-2015 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -43,28 +43,7 @@ #include -#if !defined(CONFIG_BUILD_PROTECTED) || !defined(__KERNEL__) - -/**************************************************************************** - * 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_SIZE - */ - -# include -# define USR_HEAP (&ARCH_DATA_RESERVE->ar_usrheap) - -#else -/* Otherwise, the user heap data structures are in common .bss */ - -# define USR_HEAP &g_mmheap -#endif +#include "umm_heap/umm_heap.h" /**************************************************************************** * Public Functions @@ -82,5 +61,3 @@ FAR void *umm_brkaddr(int region) { return mm_brkaddr(USR_HEAP, region); } - -#endif /* !CONFIG_BUILD_PROTECTED || !__KERNEL__ */ diff --git a/mm/umm_heap/umm_calloc.c b/mm/umm_heap/umm_calloc.c index 9e75c0b827d..627843caad5 100644 --- a/mm/umm_heap/umm_calloc.c +++ b/mm/umm_heap/umm_calloc.c @@ -1,7 +1,7 @@ /**************************************************************************** * mm/umm_heap/umm_calloc.c * - * Copyright (C) 2007, 2009, 2014 Gregory Nutt. All rights reserved. + * Copyright (C) 2007, 2009, 2014-2015 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -43,28 +43,7 @@ #include -#if !defined(CONFIG_BUILD_PROTECTED) || !defined(__KERNEL__) - -/**************************************************************************** - * 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_SIZE - */ - -# include -# define USR_HEAP (&ARCH_DATA_RESERVE->ar_usrheap) - -#else -/* Otherwise, the user heap data structures are in common .bss */ - -# define USR_HEAP &g_mmheap -#endif +#include "umm_heap/umm_heap.h" /**************************************************************************** * Public Functions @@ -82,5 +61,3 @@ FAR void *calloc(size_t n, size_t elem_size) { return mm_calloc(USR_HEAP, n, elem_size); } - -#endif /* !CONFIG_BUILD_PROTECTED || !__KERNEL__ */ diff --git a/mm/umm_heap/umm_extend.c b/mm/umm_heap/umm_extend.c index c95c57d6bf6..da28c416883 100644 --- a/mm/umm_heap/umm_extend.c +++ b/mm/umm_heap/umm_extend.c @@ -1,7 +1,7 @@ /**************************************************************************** * mm/umm_heap/umm_extend.c * - * Copyright (C) 2014 Gregory Nutt. All rights reserved. + * Copyright (C) 2014-2015 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -41,28 +41,7 @@ #include -#if !defined(CONFIG_BUILD_PROTECTED) || !defined(__KERNEL__) - -/**************************************************************************** - * 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_SIZE - */ - -# include -# define USR_HEAP (&ARCH_DATA_RESERVE->ar_usrheap) - -#else -/* Otherwise, the user heap data structures are in common .bss */ - -# define USR_HEAP &g_mmheap -#endif +#include "umm_heap/umm_heap.h" /**************************************************************************** * Public Functions @@ -81,5 +60,3 @@ void umm_extend(FAR void *mem, size_t size, int region) { mm_extend(USR_HEAP, mem, size, region); } - -#endif /* !CONFIG_BUILD_PROTECTED || !__KERNEL__ */ diff --git a/mm/umm_heap/umm_free.c b/mm/umm_heap/umm_free.c index 0230273d676..3fb60eb9c5b 100644 --- a/mm/umm_heap/umm_free.c +++ b/mm/umm_heap/umm_free.c @@ -1,7 +1,7 @@ /**************************************************************************** * mm/umm_heap/umm_free.c * - * Copyright (C) 2007, 2009, 2013-2014 Gregory Nutt. All rights reserved. + * Copyright (C) 2007, 2009, 2013-2015 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -43,32 +43,7 @@ #include -#if !defined(CONFIG_BUILD_PROTECTED) || !defined(__KERNEL__) - -/**************************************************************************** - * 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_SIZE - */ - -# include -# define USR_HEAP (&ARCH_DATA_RESERVE->ar_usrheap) - -#else -/* Otherwise, the user heap data structures are in common .bss */ - -# define USR_HEAP &g_mmheap -#endif - -/**************************************************************************** - * Private Functions - ****************************************************************************/ +#include "umm_heap/umm_heap.h" /**************************************************************************** * Public Functions @@ -87,5 +62,3 @@ void free(FAR void *mem) { mm_free(USR_HEAP, mem); } - -#endif /* !CONFIG_BUILD_PROTECTED || !__KERNEL__ */ diff --git a/mm/umm_heap/umm_initialize.c b/mm/umm_heap/umm_initialize.c index 8efb0cc87a8..f4d319844a6 100644 --- a/mm/umm_heap/umm_initialize.c +++ b/mm/umm_heap/umm_initialize.c @@ -1,7 +1,7 @@ /************************************************************************ * mm/umm_heap/umm_initialize.c * - * Copyright (C) 2013-2014 Gregory Nutt. All rights reserved. + * Copyright (C) 2013-2015 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -43,41 +43,7 @@ #include -#if !defined(CONFIG_BUILD_PROTECTED) || !defined(__KERNEL__) - -/************************************************************************ - * Pre-processor definition - ************************************************************************/ - -/************************************************************************ - * Private Types - ************************************************************************/ - -/************************************************************************ - * Public Data - ************************************************************************/ - -#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_SIZE - */ - -# include -# define USR_HEAP (&ARCH_DATA_RESERVE->ar_usrheap) - -#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 - ************************************************************************/ +#include "umm_heap/umm_heap.h" /************************************************************************ * Public Functions @@ -132,5 +98,3 @@ void umm_initialize(FAR void *heap_start, size_t heap_size) { mm_initialize(USR_HEAP, heap_start, heap_size); } - -#endif /* !CONFIG_BUILD_PROTECTED || !__KERNEL__ */ diff --git a/mm/umm_heap/umm_mallinfo.c b/mm/umm_heap/umm_mallinfo.c index 14f83cd9283..f7a5b9dc07f 100644 --- a/mm/umm_heap/umm_mallinfo.c +++ b/mm/umm_heap/umm_mallinfo.c @@ -1,7 +1,7 @@ /**************************************************************************** * mm/umm_heap/umm_mallinfo.c * - * Copyright (C) 2007, 2009, 2013-2014 Gregory Nutt. All rights reserved. + * Copyright (C) 2007, 2009, 2013-2015 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -43,36 +43,7 @@ #include -#if !defined(CONFIG_BUILD_PROTECTED) || !defined(__KERNEL__) - -/**************************************************************************** - * 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_SIZE - */ - -# include -# define USR_HEAP (&ARCH_DATA_RESERVE->ar_usrheap) - -#else -/* Otherwise, the user heap data structures are in common .bss */ - -# define USR_HEAP &g_mmheap -#endif - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ +#include "umm_heap/umm_heap.h" /**************************************************************************** * Public Functions @@ -104,4 +75,3 @@ int mallinfo(struct mallinfo *info) } #endif /* CONFIG_CAN_PASS_STRUCTS */ -#endif /* !CONFIG_BUILD_PROTECTED || !__KERNEL__ */ diff --git a/mm/umm_heap/umm_malloc.c b/mm/umm_heap/umm_malloc.c index e2cea6e3ad3..19dfa89918e 100644 --- a/mm/umm_heap/umm_malloc.c +++ b/mm/umm_heap/umm_malloc.c @@ -1,7 +1,7 @@ /**************************************************************************** * mm/umm_heap/umm_malloc.c * - * Copyright (C) 2007, 2009, 2013-2014 Gregory Nutt. All rights reserved. + * Copyright (C) 2007, 2009, 2013-2015 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -44,44 +44,7 @@ #include -#if !defined(CONFIG_BUILD_PROTECTED) || !defined(__KERNEL__) - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -#ifdef 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_SIZE - */ - -# include -# define USR_HEAP (&ARCH_DATA_RESERVE->ar_usrheap) - -#else -/* Otherwise, the user heap data structures are in common .bss */ - -# define USR_HEAP &g_mmheap -#endif - -/**************************************************************************** - * Type Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Public Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ +#include "umm_heap/umm_heap.h" /**************************************************************************** * Public Functions @@ -137,5 +100,3 @@ FAR void *malloc(size_t size) return mm_malloc(USR_HEAP, size); #endif } - -#endif /* !CONFIG_BUILD_PROTECTED || !__KERNEL__ */ diff --git a/mm/umm_heap/umm_memalign.c b/mm/umm_heap/umm_memalign.c index fefd5ce2187..4e198cc8a9a 100644 --- a/mm/umm_heap/umm_memalign.c +++ b/mm/umm_heap/umm_memalign.c @@ -1,7 +1,7 @@ /**************************************************************************** * mm/umm_heap/umm_memalign.c * - * Copyright (C) 2007, 2009, 2011, 2013-2014 Gregory Nutt. All rights reserved. + * Copyright (C) 2007, 2009, 2011, 2013-2015 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -43,32 +43,7 @@ #include -#if !defined(CONFIG_BUILD_PROTECTED) || !defined(__KERNEL__) - -/**************************************************************************** - * 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_SIZE - */ - -# include -# define USR_HEAP (&ARCH_DATA_RESERVE->ar_usrheap) - -#else -/* Otherwise, the user heap data structures are in common .bss */ - -# define USR_HEAP &g_mmheap -#endif - -/**************************************************************************** - * Private Functions - ****************************************************************************/ +#include "umm_heap/umm_heap.h" /**************************************************************************** * Public Functions @@ -91,5 +66,3 @@ FAR void *memalign(size_t alignment, size_t size) { return mm_memalign(USR_HEAP, alignment, size); } - -#endif /* !CONFIG_BUILD_PROTECTED || !__KERNEL__ */ diff --git a/mm/umm_heap/umm_realloc.c b/mm/umm_heap/umm_realloc.c index 925c28d3d01..a517aa200a9 100644 --- a/mm/umm_heap/umm_realloc.c +++ b/mm/umm_heap/umm_realloc.c @@ -1,7 +1,7 @@ /**************************************************************************** * mm/umm_heap/umm_realloc.c * - * Copyright (C) 2007, 2009, 2013-2014 Gregory Nutt. All rights reserved. + * Copyright (C) 2007, 2009, 2013-2015 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -43,32 +43,7 @@ #include -#if !defined(CONFIG_BUILD_PROTECTED) || !defined(__KERNEL__) - -/**************************************************************************** - * 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_SIZE - */ - -# include -# define USR_HEAP (&ARCH_DATA_RESERVE->ar_usrheap) - -#else -/* Otherwise, the user heap data structures are in common .bss */ - -# define USR_HEAP &g_mmheap -#endif - -/**************************************************************************** - * Private Functions - ****************************************************************************/ +#include "umm_heap/umm_heap.h" /**************************************************************************** * Public Functions @@ -93,5 +68,3 @@ FAR void *realloc(FAR void *oldmem, size_t size) { return mm_realloc(USR_HEAP, oldmem, size); } - -#endif /* !CONFIG_BUILD_PROTECTED || !__KERNEL__ */ diff --git a/mm/umm_heap/umm_sbrk.c b/mm/umm_heap/umm_sbrk.c index dcb9be932c4..ecd7416cc03 100644 --- a/mm/umm_heap/umm_sbrk.c +++ b/mm/umm_heap/umm_sbrk.c @@ -1,7 +1,7 @@ /**************************************************************************** * mm/umm_heap/umm_sbrk.c * - * Copyright (C) 2014 Gregory Nutt. All rights reserved. + * Copyright (C) 2014-2015 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -45,20 +45,7 @@ #include #include -#if defined(CONFIG_BUILD_KERNEL) - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/* 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_SIZE - */ - -#define USR_HEAP (&ARCH_DATA_RESERVE->ar_usrheap) +#include "umm_heap/umm_heap.h" /**************************************************************************** * Public Functions @@ -100,5 +87,3 @@ FAR void *sbrk(intptr_t incr) { return mm_sbrk(USR_HEAP, incr, CONFIG_ARCH_HEAP_NPAGES << MM_PGSHIFT); } - -#endif /* CONFIG_BUILD_KERNEL */ diff --git a/mm/umm_heap/umm_sem.c b/mm/umm_heap/umm_sem.c index 387266ae538..f8cf11b6c8a 100644 --- a/mm/umm_heap/umm_sem.c +++ b/mm/umm_heap/umm_sem.c @@ -1,7 +1,7 @@ /************************************************************************ * mm/umm_heap/umm_sem.c * - * Copyright (C) 2013-2014 Gregory Nutt. All rights reserved. + * Copyright (C) 2013-2015 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -41,40 +41,7 @@ #include -#if !defined(CONFIG_BUILD_PROTECTED) || !defined(__KERNEL__) - -/************************************************************************ - * 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_SIZE - */ - -# include -# define USR_HEAP (&ARCH_DATA_RESERVE->ar_usrheap) - -#else -/* Otherwise, the user heap data structures are in common .bss */ - -# define USR_HEAP &g_mmheap -#endif - -/************************************************************************ - * Private Types - ************************************************************************/ - -/************************************************************************ - * Public Data - ************************************************************************/ - -/************************************************************************ - * Private Functions - ************************************************************************/ +#include "umm_heap/umm_heap.h" /************************************************************************ * Public Functions @@ -121,5 +88,3 @@ void umm_givesemaphore(void) { mm_givesemaphore(USR_HEAP); } - -#endif /* !CONFIG_BUILD_PROTECTED || !__KERNEL__ */ diff --git a/mm/umm_heap/umm_zalloc.c b/mm/umm_heap/umm_zalloc.c index 37b602dd94c..95080427cf6 100644 --- a/mm/umm_heap/umm_zalloc.c +++ b/mm/umm_heap/umm_zalloc.c @@ -1,7 +1,7 @@ /**************************************************************************** * mm/umm/umm_zalloc.c * - * Copyright (C) 2007, 2009, 2014 Gregory Nutt. All rights reserved. + * Copyright (C) 2007, 2009, 2014-2015 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -44,28 +44,7 @@ #include -#if !defined(CONFIG_BUILD_PROTECTED) || !defined(__KERNEL__) - -/**************************************************************************** - * 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_SIZE - */ - -# include -# define USR_HEAP (&ARCH_DATA_RESERVE->ar_usrheap) - -#else -/* Otherwise, the user heap data structures are in common .bss */ - -# define USR_HEAP &g_mmheap -#endif +#include "umm_heap/umm_heap.h" /**************************************************************************** * Public Functions @@ -104,5 +83,3 @@ FAR void *zalloc(size_t size) return mm_zalloc(USR_HEAP, size); #endif } - -#endif /* !CONFIG_BUILD_PROTECTED || !__KERNEL__ */