diff options
author | Gregory Nutt <gnutt@nuttx.org> | 2014-08-31 11:46:47 -0600 |
---|---|---|
committer | Gregory Nutt <gnutt@nuttx.org> | 2014-08-31 11:46:47 -0600 |
commit | 085bc3e78cd5de4a900b00531bb47535d4872924 (patch) | |
tree | b08bb3c6d170cf4619d0404efcd3a051c4e86518 /nuttx | |
parent | 089bae8a5cce5546b13a63db4c86fe02f516e535 (diff) | |
download | px4-nuttx-085bc3e78cd5de4a900b00531bb47535d4872924.tar.gz px4-nuttx-085bc3e78cd5de4a900b00531bb47535d4872924.tar.bz2 px4-nuttx-085bc3e78cd5de4a900b00531bb47535d4872924.zip |
mm: Break up mm_user.c and mm_kernel.c into separate files for better symmetry
Diffstat (limited to 'nuttx')
-rw-r--r-- | nuttx/include/nuttx/mm.h | 15 | ||||
-rw-r--r-- | nuttx/mm/Makefile | 7 | ||||
-rw-r--r-- | nuttx/mm/kmm_addregion.c | 86 | ||||
-rw-r--r-- | nuttx/mm/kmm_heapmember.c | 120 | ||||
-rw-r--r-- | nuttx/mm/kmm_initialize.c | 91 | ||||
-rw-r--r-- | nuttx/mm/kmm_kernel.c (renamed from nuttx/mm/mm_kernel.c) | 87 | ||||
-rw-r--r-- | nuttx/mm/kmm_sem.c | 104 | ||||
-rw-r--r-- | nuttx/mm/umm_addregion.c | 88 | ||||
-rw-r--r-- | nuttx/mm/umm_initialize.c | 92 | ||||
-rw-r--r-- | nuttx/mm/umm_sem.c (renamed from nuttx/mm/mm_user.c) | 54 |
10 files changed, 605 insertions, 139 deletions
diff --git a/nuttx/include/nuttx/mm.h b/nuttx/include/nuttx/mm.h index 09ea1756a..de217e550 100644 --- a/nuttx/include/nuttx/mm.h +++ b/nuttx/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/nuttx/mm/Makefile b/nuttx/mm/Makefile index ef57255b0..054393734 100644 --- a/nuttx/mm/Makefile +++ b/nuttx/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/nuttx/mm/kmm_addregion.c b/nuttx/mm/kmm_addregion.c new file mode 100644 index 000000000..574a983f6 --- /dev/null +++ b/nuttx/mm/kmm_addregion.c @@ -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 */ diff --git a/nuttx/mm/kmm_heapmember.c b/nuttx/mm/kmm_heapmember.c new file mode 100644 index 000000000..01fa8b53c --- /dev/null +++ b/nuttx/mm/kmm_heapmember.c @@ -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 */ diff --git a/nuttx/mm/kmm_initialize.c b/nuttx/mm/kmm_initialize.c new file mode 100644 index 000000000..591c76715 --- /dev/null +++ b/nuttx/mm/kmm_initialize.c @@ -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 */ diff --git a/nuttx/mm/mm_kernel.c b/nuttx/mm/kmm_kernel.c index 5435b9316..646cafa6c 100644 --- a/nuttx/mm/mm_kernel.c +++ b/nuttx/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 <gnutt@nuttx.org> * * 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 ************************************************************************/ @@ -71,85 +67,6 @@ struct mm_heap_s g_kmmheap; ************************************************************************/ /************************************************************************ - * 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 * * Description: diff --git a/nuttx/mm/kmm_sem.c b/nuttx/mm/kmm_sem.c new file mode 100644 index 000000000..7883a6e56 --- /dev/null +++ b/nuttx/mm/kmm_sem.c @@ -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 */ diff --git a/nuttx/mm/umm_addregion.c b/nuttx/mm/umm_addregion.c new file mode 100644 index 000000000..4293529f8 --- /dev/null +++ b/nuttx/mm/umm_addregion.c @@ -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 */ diff --git a/nuttx/mm/umm_initialize.c b/nuttx/mm/umm_initialize.c new file mode 100644 index 000000000..be5e74f9d --- /dev/null +++ b/nuttx/mm/umm_initialize.c @@ -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 */ diff --git a/nuttx/mm/mm_user.c b/nuttx/mm/umm_sem.c index 8a733de26..d390865ca 100644 --- a/nuttx/mm/mm_user.c +++ b/nuttx/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 <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without @@ -38,7 +38,7 @@ ************************************************************************/ #include <nuttx/config.h> -#include <assert.h> + #include <nuttx/mm.h> #ifdef CONFIG_MM_USER_HEAP @@ -55,10 +55,6 @@ * Public Data ************************************************************************/ -/* This is the user heap */ - -struct mm_heap_s g_mmheap; - /************************************************************************ * Private Functions ************************************************************************/ @@ -68,50 +64,6 @@ struct mm_heap_s g_mmheap; ************************************************************************/ /************************************************************************ - * 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 * * Description: |