From b0246d0b7db73305d644065d407418073f6b23b5 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Sun, 31 Aug 2014 11:46:47 -0600 Subject: [PATCH] mm: Break up mm_user.c and mm_kernel.c into separate files for better symmetry --- include/nuttx/mm.h | 15 +++- mm/Makefile | 7 +- mm/kmm_addregion.c | 86 ++++++++++++++++++++++ mm/kmm_heapmember.c | 120 +++++++++++++++++++++++++++++++ mm/kmm_initialize.c | 91 +++++++++++++++++++++++ mm/{mm_kernel.c => kmm_kernel.c} | 87 +--------------------- mm/kmm_sem.c | 104 +++++++++++++++++++++++++++ mm/umm_addregion.c | 88 +++++++++++++++++++++++ mm/umm_initialize.c | 92 ++++++++++++++++++++++++ mm/{mm_user.c => umm_sem.c} | 54 +------------- 10 files changed, 605 insertions(+), 139 deletions(-) create mode 100644 mm/kmm_addregion.c create mode 100644 mm/kmm_heapmember.c create mode 100644 mm/kmm_initialize.c rename mm/{mm_kernel.c => kmm_kernel.c} (67%) create mode 100644 mm/kmm_sem.c create mode 100644 mm/umm_addregion.c create mode 100644 mm/umm_initialize.c rename mm/{mm_user.c => umm_sem.c} (72%) diff --git a/include/nuttx/mm.h b/include/nuttx/mm.h index 09ea1756a2..de217e550d 100644 --- a/include/nuttx/mm.h +++ b/include/nuttx/mm.h @@ -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); #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 ***********************************/ #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); 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 int umm_trysemaphore(void); void umm_givesemaphore(void); #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 ***************************************/ FAR void *mm_malloc(FAR struct mm_heap_s *heap, size_t size); diff --git a/mm/Makefile b/mm/Makefile index ef57255b01..054393734a 100644 --- a/mm/Makefile +++ b/mm/Makefile @@ -58,16 +58,19 @@ CSRCS += mm_realloc.c mm_zalloc.c # 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_memalign.c umm_realloc.c umm_zalloc.c # Kernel allocator 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_memalign.c kmm_realloc.c kmm_zalloc.c +ifeq ($(CONFIG_DEBUG),y) +CSRCS += kmm_heapmember.c +endif endif # An optional granule allocator diff --git a/mm/kmm_addregion.c b/mm/kmm_addregion.c new file mode 100644 index 0000000000..574a983f64 --- /dev/null +++ b/mm/kmm_addregion.c @@ -0,0 +1,86 @@ +/************************************************************************ + * mm/kmm_addregion.c + * + * Copyright (C) 2014 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * 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 + +#include + +#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 */ diff --git a/mm/kmm_heapmember.c b/mm/kmm_heapmember.c new file mode 100644 index 0000000000..01fa8b53c0 --- /dev/null +++ b/mm/kmm_heapmember.c @@ -0,0 +1,120 @@ +/************************************************************************ + * mm/kmm_heapmember.c + * + * Copyright (C) 2013-2014 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * 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 + +#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 */ diff --git a/mm/kmm_initialize.c b/mm/kmm_initialize.c new file mode 100644 index 0000000000..591c767156 --- /dev/null +++ b/mm/kmm_initialize.c @@ -0,0 +1,91 @@ +/************************************************************************ + * mm/kmm_initialize.c + * + * Copyright (C) 2013-2014 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * 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 + +#include + +#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 */ diff --git a/mm/mm_kernel.c b/mm/kmm_kernel.c similarity index 67% rename from mm/mm_kernel.c rename to mm/kmm_kernel.c index 5435b9316d..646cafa6cb 100644 --- a/mm/mm_kernel.c +++ b/mm/kmm_kernel.c @@ -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 * * Redistribution and use in source and binary forms, with or without @@ -58,10 +58,6 @@ * Public Data ************************************************************************/ -/* This is the kernel heap */ - -struct mm_heap_s g_kmmheap; - /************************************************************************ * Private Functions ************************************************************************/ @@ -70,85 +66,6 @@ struct mm_heap_s g_kmmheap; * 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 * diff --git a/mm/kmm_sem.c b/mm/kmm_sem.c new file mode 100644 index 0000000000..7883a6e56e --- /dev/null +++ b/mm/kmm_sem.c @@ -0,0 +1,104 @@ +/************************************************************************ + * mm/kmm_sem.c + * + * Copyright (C) 2014 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * 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 + +#include + +#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 */ diff --git a/mm/umm_addregion.c b/mm/umm_addregion.c new file mode 100644 index 0000000000..4293529f85 --- /dev/null +++ b/mm/umm_addregion.c @@ -0,0 +1,88 @@ +/************************************************************************ + * mm/umm_addregion.c + * + * Copyright (C) 2013-2014 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * 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 + +#include + +#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 */ diff --git a/mm/umm_initialize.c b/mm/umm_initialize.c new file mode 100644 index 0000000000..be5e74f9d8 --- /dev/null +++ b/mm/umm_initialize.c @@ -0,0 +1,92 @@ +/************************************************************************ + * mm/umm_initialize.c + * + * Copyright (C) 2013-2014 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * 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 + +#include + +#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 */ diff --git a/mm/mm_user.c b/mm/umm_sem.c similarity index 72% rename from mm/mm_user.c rename to mm/umm_sem.c index 8a733de267..d390865ca1 100644 --- a/mm/mm_user.c +++ b/mm/umm_sem.c @@ -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 * * Redistribution and use in source and binary forms, with or without @@ -38,7 +38,7 @@ ************************************************************************/ #include -#include + #include #ifdef CONFIG_MM_USER_HEAP @@ -55,10 +55,6 @@ * Public Data ************************************************************************/ -/* This is the user heap */ - -struct mm_heap_s g_mmheap; - /************************************************************************ * Private Functions ************************************************************************/ @@ -67,50 +63,6 @@ struct mm_heap_s g_mmheap; * 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 *