Protected mode: Redesign how the user space heap is accessed from the kernel code. It used to call memory management functions in user space via function pointers in the userspace interface. That is inefficient because the first thing that those memory management functions do is to trap back into the kernel to get the current PID. Worse, that operation can be fatal is certain fragile situations such as when a task is exitting.
The solution is to remove all of the memory management function calls from the interface. Instead, the interface exports the userspace heap structure and then kernel size implementations of those memory management functions will operate on the userspace heap structure. This avoids the unnecessary system calls and, more importantly, failures do to freeing memory when a test exits.
This commit is contained in:
parent
da1c2cd112
commit
59cc4a7a7b
18 changed files with 60 additions and 446 deletions
2
configs
2
configs
|
|
@ -1 +1 @@
|
|||
Subproject commit 6112bb038416a3553504fad20eca1bd39f79b371
|
||||
Subproject commit 8e27cf333e78b19ade6dff857e865cdf65056253
|
||||
|
|
@ -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 */
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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 <gnutt@nuttx.org>
|
||||
#
|
||||
# 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
|
||||
|
|
|
|||
|
|
@ -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 <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
|
@ -41,40 +41,7 @@
|
|||
|
||||
#include <nuttx/mm/mm.h>
|
||||
|
||||
#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 <nuttx/addrenv.h>
|
||||
# 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__ */
|
||||
|
|
|
|||
|
|
@ -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 <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
|
@ -43,28 +43,7 @@
|
|||
|
||||
#include <nuttx/mm/mm.h>
|
||||
|
||||
#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 <nuttx/addrenv.h>
|
||||
# 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__ */
|
||||
|
|
|
|||
|
|
@ -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 <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
|
@ -43,28 +43,7 @@
|
|||
|
||||
#include <nuttx/mm/mm.h>
|
||||
|
||||
#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 <nuttx/addrenv.h>
|
||||
# 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__ */
|
||||
|
|
|
|||
|
|
@ -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 <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
|
@ -41,28 +41,7 @@
|
|||
|
||||
#include <nuttx/mm/mm.h>
|
||||
|
||||
#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 <nuttx/addrenv.h>
|
||||
# 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__ */
|
||||
|
|
|
|||
|
|
@ -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 <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
|
@ -43,32 +43,7 @@
|
|||
|
||||
#include <nuttx/mm/mm.h>
|
||||
|
||||
#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 <nuttx/addrenv.h>
|
||||
# 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__ */
|
||||
|
|
|
|||
|
|
@ -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 <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
|
@ -43,41 +43,7 @@
|
|||
|
||||
#include <nuttx/mm/mm.h>
|
||||
|
||||
#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 <nuttx/addrenv.h>
|
||||
# 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__ */
|
||||
|
|
|
|||
|
|
@ -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 <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
|
@ -43,36 +43,7 @@
|
|||
|
||||
#include <nuttx/mm/mm.h>
|
||||
|
||||
#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 <nuttx/addrenv.h>
|
||||
# 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__ */
|
||||
|
|
|
|||
|
|
@ -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 <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
|
@ -44,44 +44,7 @@
|
|||
|
||||
#include <nuttx/mm/mm.h>
|
||||
|
||||
#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 <nuttx/addrenv.h>
|
||||
# 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__ */
|
||||
|
|
|
|||
|
|
@ -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 <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
|
@ -43,32 +43,7 @@
|
|||
|
||||
#include <nuttx/mm/mm.h>
|
||||
|
||||
#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 <nuttx/addrenv.h>
|
||||
# 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__ */
|
||||
|
|
|
|||
|
|
@ -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 <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
|
@ -43,32 +43,7 @@
|
|||
|
||||
#include <nuttx/mm/mm.h>
|
||||
|
||||
#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 <nuttx/addrenv.h>
|
||||
# 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__ */
|
||||
|
|
|
|||
|
|
@ -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 <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
|
@ -45,20 +45,7 @@
|
|||
#include <nuttx/addrenv.h>
|
||||
#include <nuttx/pgalloc.h>
|
||||
|
||||
#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 */
|
||||
|
|
|
|||
|
|
@ -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 <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
|
@ -41,40 +41,7 @@
|
|||
|
||||
#include <nuttx/mm/mm.h>
|
||||
|
||||
#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 <nuttx/addrenv.h>
|
||||
# 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__ */
|
||||
|
|
|
|||
|
|
@ -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 <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
|
@ -44,28 +44,7 @@
|
|||
|
||||
#include <nuttx/mm/mm.h>
|
||||
|
||||
#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 <nuttx/addrenv.h>
|
||||
# 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__ */
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue