mm: Break up mm_user.c and mm_kernel.c into separate files for better symmetry

This commit is contained in:
Gregory Nutt 2014-08-31 11:46:47 -06:00
parent 50e40a93ba
commit b0246d0b7d
10 changed files with 605 additions and 139 deletions

View File

@ -255,6 +255,12 @@ void mm_addregion(FAR struct mm_heap_s *heap, FAR void *heapstart,
void umm_initialize(FAR void *heap_start, size_t heap_size); void umm_initialize(FAR void *heap_start, size_t heap_size);
#endif #endif
/* Functions contained in kmm_initialize.c **********************************/
#ifdef CONFIG_MM_KERNEL_HEAP
void kmm_initialize(FAR void *heap_start, size_t heap_size);
#endif
/* Functions contained in umm_addregion.c ***********************************/ /* Functions contained in umm_addregion.c ***********************************/
#ifdef CONFIG_MM_USER_HEAP #ifdef CONFIG_MM_USER_HEAP
@ -268,13 +274,20 @@ void mm_takesemaphore(FAR struct mm_heap_s *heap);
int mm_trysemaphore(FAR struct mm_heap_s *heap); int mm_trysemaphore(FAR struct mm_heap_s *heap);
void mm_givesemaphore(FAR struct mm_heap_s *heap); void mm_givesemaphore(FAR struct mm_heap_s *heap);
/* Functions contained in umm_semaphore.c ***********************************/ /* Functions contained in umm_sem.c ****************************************/
#ifdef CONFIG_MM_USER_HEAP #ifdef CONFIG_MM_USER_HEAP
int umm_trysemaphore(void); int umm_trysemaphore(void);
void umm_givesemaphore(void); void umm_givesemaphore(void);
#endif #endif
/* Functions contained in kmm_sem.c ****************************************/
#ifdef CONFIG_MM_KERNEL_HEAP
int kmm_trysemaphore(void);
void kmm_givesemaphore(void);
#endif
/* Functions contained in mm_malloc.c ***************************************/ /* Functions contained in mm_malloc.c ***************************************/
FAR void *mm_malloc(FAR struct mm_heap_s *heap, size_t size); FAR void *mm_malloc(FAR struct mm_heap_s *heap, size_t size);

View File

@ -58,16 +58,19 @@ CSRCS += mm_realloc.c mm_zalloc.c
# User allocator # User allocator
CSRCS += mm_user.c CSRCS += umm_initialize.c umm_addregion.c umm_sem.c
CSRCS += umm_calloc.c umm_free.c umm_mallinfo.c umm_malloc.c CSRCS += umm_calloc.c umm_free.c umm_mallinfo.c umm_malloc.c
CSRCS += umm_memalign.c umm_realloc.c umm_zalloc.c CSRCS += umm_memalign.c umm_realloc.c umm_zalloc.c
# Kernel allocator # Kernel allocator
ifeq ($(CONFIG_MM_KERNEL_HEAP),y) ifeq ($(CONFIG_MM_KERNEL_HEAP),y)
CSRCS += mm_kernel.c CSRCS += kmm_initialize.c kmm_addregion.c kmm_sem.c
CSRCS += kmm_calloc.c kmm_free.c kmm_mallinfo.c kmm_malloc.c CSRCS += kmm_calloc.c kmm_free.c kmm_mallinfo.c kmm_malloc.c
CSRCS += kmm_memalign.c kmm_realloc.c kmm_zalloc.c CSRCS += kmm_memalign.c kmm_realloc.c kmm_zalloc.c
ifeq ($(CONFIG_DEBUG),y)
CSRCS += kmm_heapmember.c
endif
endif endif
# An optional granule allocator # An optional granule allocator

86
mm/kmm_addregion.c Normal file
View File

@ -0,0 +1,86 @@
/************************************************************************
* mm/kmm_addregion.c
*
* Copyright (C) 2014 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name NuttX nor the names of its contributors may be
* used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
************************************************************************/
/************************************************************************
* Included Files
************************************************************************/
#include <nuttx/config.h>
#include <nuttx/mm.h>
#ifdef CONFIG_MM_KERNEL_HEAP
/************************************************************************
* Pre-processor definition
************************************************************************/
/************************************************************************
* Private Types
************************************************************************/
/************************************************************************
* Public Data
************************************************************************/
/************************************************************************
* Private Functions
************************************************************************/
/************************************************************************
* Public Functions
************************************************************************/
/************************************************************************
* Name: kmm_addregion
*
* Description:
* This function adds a region of contiguous memory to the kernel heap.
*
* Parameters:
* heap_start - Address of the beginning of the memory region
* heap_size - The size (in bytes) if the memory region.
*
* Return Value:
* None
*
************************************************************************/
void kmm_addregion(FAR void *heap_start, size_t heap_size)
{
return mm_addregion(&g_kmmheap, heap_start, heap_size);
}
#endif /* CONFIG_MM_KERNEL_HEAP */

120
mm/kmm_heapmember.c Normal file
View File

@ -0,0 +1,120 @@
/************************************************************************
* mm/kmm_heapmember.c
*
* Copyright (C) 2013-2014 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name NuttX nor the names of its contributors may be
* used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
************************************************************************/
/************************************************************************
* Included Files
************************************************************************/
#include <nuttx/config.h>
#if defined(CONFIG_MM_KERNEL_HEAP) && defined(CONFIG_DEBUG)
/************************************************************************
* Pre-processor definition
************************************************************************/
/************************************************************************
* Private Types
************************************************************************/
/************************************************************************
* Public Data
************************************************************************/
/************************************************************************
* Private Functions
************************************************************************/
/************************************************************************
* Public Functions
************************************************************************/
/************************************************************************
* Name: kmm_heapmember
*
* Description:
* Check if an address lies in the kernel heap.
*
* Parameters:
* mem - The address to check
*
* Return Value:
* true if the address is a member of the kernel heap. false if not
* not. If the address is not a member of the kernel heap, then it
* must be a member of the user-space heap (unchecked)
*
************************************************************************/
bool kmm_heapmember(FAR void *mem)
{
#if CONFIG_MM_REGIONS > 1
int i;
/* A valid address from the kernel heap for this region would have to lie
* between the region's two guard nodes.
*/
for (i = 0; i < g_kmmheap.mm_nregions; i++)
{
if (mem > (FAR void *)g_kmmheap.mm_heapstart[i] &&
mem < (FAR void *)g_kmmheap.mm_heapend[i])
{
return true;
}
}
/* The address does not like any any region assigned to kernel heap */
return false;
#else
/* A valid address from the kernel heap would have to lie between the
* two guard nodes.
*/
if (mem > (FAR void *)g_kmmheap.mm_heapstart[0] &&
mem < (FAR void *)g_kmmheap.mm_heapend[0])
{
return true;
}
/* Otherwise, the address does not lie in the kernel heap */
return false;
#endif
}
#endif /* CONFIG_MM_KERNEL_HEAP && CONFIG_DEBUG */

91
mm/kmm_initialize.c Normal file
View File

@ -0,0 +1,91 @@
/************************************************************************
* mm/kmm_initialize.c
*
* Copyright (C) 2013-2014 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name NuttX nor the names of its contributors may be
* used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
************************************************************************/
/************************************************************************
* Included Files
************************************************************************/
#include <nuttx/config.h>
#include <nuttx/mm.h>
#ifdef CONFIG_MM_KERNEL_HEAP
/************************************************************************
* Pre-processor definition
************************************************************************/
/************************************************************************
* Private Types
************************************************************************/
/************************************************************************
* Public Data
************************************************************************/
/* This is the kernel heap */
struct mm_heap_s g_kmmheap;
/************************************************************************
* Private Functions
************************************************************************/
/************************************************************************
* Public Functions
************************************************************************/
/************************************************************************
* Name: kmm_initialize
*
* Description:
* Initialize the kernel heap data structures, providing the initial
* heap region.
*
* Parameters:
* heap_start - Address of the beginning of the (initial) memory region
* heap_size - The size (in bytes) if the (initial) memory region.
*
* Return Value:
* None
*
************************************************************************/
void kmm_initialize(FAR void *heap_start, size_t heap_size)
{
return mm_initialize(&g_kmmheap, heap_start, heap_size);
}
#endif /* CONFIG_MM_KERNEL_HEAP */

View File

@ -1,7 +1,7 @@
/************************************************************************ /************************************************************************
* mm/mm_kernel.c * mm/kmm_kernel.c
* *
* Copyright (C) 2013 Gregory Nutt. All rights reserved. * Copyright (C) 2013-2014 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org> * Author: Gregory Nutt <gnutt@nuttx.org>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -58,10 +58,6 @@
* Public Data * Public Data
************************************************************************/ ************************************************************************/
/* This is the kernel heap */
struct mm_heap_s g_kmmheap;
/************************************************************************ /************************************************************************
* Private Functions * Private Functions
************************************************************************/ ************************************************************************/
@ -70,85 +66,6 @@ struct mm_heap_s g_kmmheap;
* Public Functions * Public Functions
************************************************************************/ ************************************************************************/
/************************************************************************
* Name: kmm_initialize
*
* Description:
* Initialize the kernel heap data structures, providing the initial
* heap region.
*
* Parameters:
* heap_start - Address of the beginning of the (initial) memory region
* heap_size - The size (in bytes) if the (initial) memory region.
*
* Return Value:
* None
*
************************************************************************/
void kmm_initialize(FAR void *heap_start, size_t heap_size)
{
return mm_initialize(&g_kmmheap, heap_start, heap_size);
}
/************************************************************************
* Name: kmm_addregion
*
* Description:
* This function adds a region of contiguous memory to the kernel heap.
*
* Parameters:
* heap_start - Address of the beginning of the memory region
* heap_size - The size (in bytes) if the memory region.
*
* Return Value:
* None
*
************************************************************************/
void kmm_addregion(FAR void *heap_start, size_t heap_size)
{
return mm_addregion(&g_kmmheap, heap_start, heap_size);
}
/************************************************************************
* Name: kmm_trysemaphore
*
* Description:
* Try to take the kernel heap semaphore.
*
* Parameters:
* None
*
* Return Value:
* OK on success; a negated errno on failure
*
************************************************************************/
int kmm_trysemaphore(void)
{
return mm_trysemaphore(&g_kmmheap);
}
/************************************************************************
* Name: kmm_givesemaphore
*
* Description:
* Give the kernel heap semaphore.
*
* Parameters:
* None
*
* Return Value:
* OK on success; a negated errno on failure
*
************************************************************************/
void kmm_givesemaphore(void)
{
return mm_givesemaphore(&g_kmmheap);
}
/************************************************************************ /************************************************************************
* Name: kmm_heapmember * Name: kmm_heapmember
* *

104
mm/kmm_sem.c Normal file
View File

@ -0,0 +1,104 @@
/************************************************************************
* mm/kmm_sem.c
*
* Copyright (C) 2014 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name NuttX nor the names of its contributors may be
* used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
************************************************************************/
/************************************************************************
* Included Files
************************************************************************/
#include <nuttx/config.h>
#include <nuttx/mm.h>
#ifdef CONFIG_MM_KERNEL_HEAP
/************************************************************************
* Pre-processor definition
************************************************************************/
/************************************************************************
* Private Types
************************************************************************/
/************************************************************************
* Public Data
************************************************************************/
/************************************************************************
* Private Functions
************************************************************************/
/************************************************************************
* Public Functions
************************************************************************/
/************************************************************************
* Name: kmm_trysemaphore
*
* Description:
* Try to take the kernel heap semaphore.
*
* Parameters:
* None
*
* Return Value:
* OK on success; a negated errno on failure
*
************************************************************************/
int kmm_trysemaphore(void)
{
return mm_trysemaphore(&g_kmmheap);
}
/************************************************************************
* Name: kmm_givesemaphore
*
* Description:
* Give the kernel heap semaphore.
*
* Parameters:
* None
*
* Return Value:
* OK on success; a negated errno on failure
*
************************************************************************/
void kmm_givesemaphore(void)
{
return mm_givesemaphore(&g_kmmheap);
}
#endif /* CONFIG_MM_KERNEL_HEAP */

88
mm/umm_addregion.c Normal file
View File

@ -0,0 +1,88 @@
/************************************************************************
* mm/umm_addregion.c
*
* Copyright (C) 2013-2014 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name NuttX nor the names of its contributors may be
* used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
************************************************************************/
/************************************************************************
* Included Files
************************************************************************/
#include <nuttx/config.h>
#include <nuttx/mm.h>
#ifdef CONFIG_MM_USER_HEAP
/************************************************************************
* Pre-processor definition
************************************************************************/
/************************************************************************
* Private Types
************************************************************************/
/************************************************************************
* Public Data
************************************************************************/
/************************************************************************
* Private Functions
************************************************************************/
/************************************************************************
* Public Functions
************************************************************************/
/************************************************************************
* Name: umm_addregion
*
* Description:
* This is a simple wrapper for the mm_addregion() function. This
* function is exported from the user-space blob so that the kernel
* can initialize the user-mode allocator.
*
* Parameters:
* heap_start - Address of the beginning of the memory region
* heap_size - The size (in bytes) if the memory region.
*
* Return Value:
* None
*
************************************************************************/
void umm_addregion(FAR void *heap_start, size_t heap_size)
{
mm_addregion(&g_mmheap, heap_start, heap_size);
}
#endif /* CONFIG_MM_USER_HEAP */

92
mm/umm_initialize.c Normal file
View File

@ -0,0 +1,92 @@
/************************************************************************
* mm/umm_initialize.c
*
* Copyright (C) 2013-2014 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name NuttX nor the names of its contributors may be
* used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
************************************************************************/
/************************************************************************
* Included Files
************************************************************************/
#include <nuttx/config.h>
#include <nuttx/mm.h>
#ifdef CONFIG_MM_USER_HEAP
/************************************************************************
* Pre-processor definition
************************************************************************/
/************************************************************************
* Private Types
************************************************************************/
/************************************************************************
* Public Data
************************************************************************/
/* This is the user heap */
struct mm_heap_s g_mmheap;
/************************************************************************
* Private Functions
************************************************************************/
/************************************************************************
* Public Functions
************************************************************************/
/************************************************************************
* Name: umm_initialize
*
* Description:
* This is a simple wrapper for the mm_initialize() function. This
* function is exported from the user-space blob so that the kernel
* can initialize the user-mode allocator.
*
* Parameters:
* heap_start - Address of the beginning of the (initial) memory region
* heap_size - The size (in bytes) if the (initial) memory region.
*
* Return Value:
* None
*
************************************************************************/
void umm_initialize(FAR void *heap_start, size_t heap_size)
{
mm_initialize(&g_mmheap, heap_start, heap_size);
}
#endif /* CONFIG_MM_USER_HEAP */

View File

@ -1,7 +1,7 @@
/************************************************************************ /************************************************************************
* mm/mm_user.c * mm/umm_sem.c
* *
* Copyright (C) 2013 Gregory Nutt. All rights reserved. * Copyright (C) 2013-2014 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org> * Author: Gregory Nutt <gnutt@nuttx.org>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -38,7 +38,7 @@
************************************************************************/ ************************************************************************/
#include <nuttx/config.h> #include <nuttx/config.h>
#include <assert.h>
#include <nuttx/mm.h> #include <nuttx/mm.h>
#ifdef CONFIG_MM_USER_HEAP #ifdef CONFIG_MM_USER_HEAP
@ -55,10 +55,6 @@
* Public Data * Public Data
************************************************************************/ ************************************************************************/
/* This is the user heap */
struct mm_heap_s g_mmheap;
/************************************************************************ /************************************************************************
* Private Functions * Private Functions
************************************************************************/ ************************************************************************/
@ -67,50 +63,6 @@ struct mm_heap_s g_mmheap;
* Public Functions * Public Functions
************************************************************************/ ************************************************************************/
/************************************************************************
* Name: umm_initialize
*
* Description:
* This is a simple wrapper for the mm_initialize() function. This
* function is exported from the user-space blob so that the kernel
* can initialize the user-mode allocator.
*
* Parameters:
* heap_start - Address of the beginning of the (initial) memory region
* heap_size - The size (in bytes) if the (initial) memory region.
*
* Return Value:
* None
*
************************************************************************/
void umm_initialize(FAR void *heap_start, size_t heap_size)
{
mm_initialize(&g_mmheap, heap_start, heap_size);
}
/************************************************************************
* Name: umm_addregion
*
* Description:
* This is a simple wrapper for the mm_addregion() function. This
* function is exported from the user-space blob so that the kernel
* can initialize the user-mode allocator.
*
* Parameters:
* heap_start - Address of the beginning of the memory region
* heap_size - The size (in bytes) if the memory region.
*
* Return Value:
* None
*
************************************************************************/
void umm_addregion(FAR void *heap_start, size_t heap_size)
{
mm_addregion(&g_mmheap, heap_start, heap_size);
}
/************************************************************************ /************************************************************************
* Name: umm_trysemaphore * Name: umm_trysemaphore
* *