diff --git a/arch/arm/src/sam3u/sam3u_allocateheap.c b/arch/arm/src/sam3u/sam3u_allocateheap.c index 2bd8cacab8d1c3f1cde3fe96fd18ef62eb1a7685..c8ea98ade21e6171a0ec5da4c4fee7d04c80c9fe 100755 --- a/arch/arm/src/sam3u/sam3u_allocateheap.c +++ b/arch/arm/src/sam3u/sam3u_allocateheap.c @@ -43,6 +43,8 @@ #include <debug.h> #include <nuttx/arch.h> +#include <nuttx/kmalloc.h> + #include <arch/board/board.h> #include "chip.h" @@ -117,10 +119,10 @@ void up_allocate_heap(FAR void **heap_start, size_t *heap_size) #if CONFIG_MM_REGIONS > 1 void up_addregion(void) { - mm_addregion((FAR void*)SAM3U_INTSRAM1_BASE, CONFIG_SAM3U_SRAM1_SIZE); + kmm_addregion((FAR void*)SAM3U_INTSRAM1_BASE, CONFIG_SAM3U_SRAM1_SIZE); #if CONFIG_MM_REGIONS > 2 - mm_addregion((FAR void*)SAM3U_NFCSRAM_BASE, CONFIG_SAM3U_NFCSRAM_SIZE); + kmm_addregion((FAR void*)SAM3U_NFCSRAM_BASE, CONFIG_SAM3U_NFCSRAM_SIZE); #endif } #endif diff --git a/configs/sam3u-ek/kernel/Makefile b/configs/sam3u-ek/kernel/Makefile index 5f7d939b23c35e84f210d9d0ab392e31c2fcf12b..688ad0e6237f198b21e7c094c3b39edd03159bda 100755 --- a/configs/sam3u-ek/kernel/Makefile +++ b/configs/sam3u-ek/kernel/Makefile @@ -96,8 +96,8 @@ $(BOARD_INCLUDE)/user_map.h: $(TOPDIR)/User.map @echo "" >> $(BOARD_INCLUDE)/user_map.h @echo "#define CONFIG_USER_MMINIT 0x`grep \" mm_initialize$\" $(TOPDIR)/User.map | cut -d' ' -f1`" >> $(BOARD_INCLUDE)/user_map.h @echo "#define CONFIG_USER_MMADDREGION 0x`grep \" mm_addregion$\" $(TOPDIR)/User.map | cut -d' ' -f1`" >> $(BOARD_INCLUDE)/user_map.h - @echo "#define CONFIG_USER_TRYSEM 0x`grep \" mm_trysemaphore$\" $(TOPDIR)/User.map | cut -d' ' -f1`" >> $(BOARD_INCLUDE)/user_map.h - @echo "#define CONFIG_USER_GIVSEM 0x`grep \" mm_givesemaphore$\" $(TOPDIR)/User.map | cut -d' ' -f1`" >> $(BOARD_INCLUDE)/user_map.h + @echo "#define CONFIG_USER_MMTRYSEM 0x`grep \" mm_trysemaphore$\" $(TOPDIR)/User.map | cut -d' ' -f1`" >> $(BOARD_INCLUDE)/user_map.h + @echo "#define CONFIG_USER_MMGIVESEM 0x`grep \" mm_givesemaphore$\" $(TOPDIR)/User.map | cut -d' ' -f1`" >> $(BOARD_INCLUDE)/user_map.h @echo "" >> $(BOARD_INCLUDE)/user_map.h @echo "#define CONFIG_USER_MALLOC 0x`grep \" malloc$\" $(TOPDIR)/User.map | cut -d' ' -f1`" >> $(BOARD_INCLUDE)/user_map.h @echo "#define CONFIG_USER_REALLOC 0x`grep \" realloc$\" $(TOPDIR)/User.map | cut -d' ' -f1`" >> $(BOARD_INCLUDE)/user_map.h diff --git a/configs/sam3u-ek/kernel/kernel.ld b/configs/sam3u-ek/kernel/kernel.ld index b15188787c190e950f761ab8109ff6afa4208604..8b0ea0244cfbe10f612042c9cb0410dcd37015e4 100644 --- a/configs/sam3u-ek/kernel/kernel.ld +++ b/configs/sam3u-ek/kernel/kernel.ld @@ -62,13 +62,14 @@ MEMORY sram2 (rwx) : ORIGIN = 0x20080000, LENGTH = 16K } -# Force user_start into the link. This is the application entry point +/* Force user_start into the link. This is the application entry point */ EXTERN(user_start) -# Make sure that the critical memory management functions are in user-space. -# Currently, the plan is that the memory manager will reside in user-space -# but be usable both by kernel- and user-space code +/* Make sure that the critical memory management functions are in user-space. + * Currently, the plan is that the memory manager will reside in user-space + * but be usable both by kernel- and user-space code + */ EXTERN(mm_initialize) EXTERN(mm_addregion) diff --git a/include/nuttx/kmalloc.h b/include/nuttx/kmalloc.h index 08b1b319bb5f6f541efd13cbbb1c4dab7e8a44d7..aafe150fdda6787aed3fb09339fd69fa66b4586c 100644 --- a/include/nuttx/kmalloc.h +++ b/include/nuttx/kmalloc.h @@ -41,10 +41,12 @@ ****************************************************************************/ #include <nuttx/config.h> + #include <sys/types.h> #ifndef CONFIG_NUTTX_KERNEL # include <stdlib.h> +# include <nuttx/mm.h> #endif /**************************************************************************** @@ -74,13 +76,23 @@ extern "C" { #ifndef CONFIG_NUTTX_KERNEL -# define kmalloc(s) malloc(s) -# define kzalloc(s) zalloc(s) -# define krealloc(p,s) realloc(p,s) -# define kfree(p) free(p) +# define kmm_initialize(h,s) mm_initialize(h,s) +# define kmm_addregion(h,s) mm_addregion(h,s) +# define kmm_trysemaphore(h,s) mm_trysemaphore(h,s) +# define kmm_givesemaphore(h,s) mm_givesemaphore(h,s) + +# define kmalloc(s) malloc(s) +# define kzalloc(s) zalloc(s) +# define krealloc(p,s) realloc(p,s) +# define kfree(p) free(p) #else +KMALLOC_EXTERN void kmm_initialize(FAR void *heap_start, size_t heap_size); +KMALLOC_EXTERN void kmm_addregion(FAR void *heapstart, size_t heapsize); +KMALLOC_EXTERN int kmm_trysemaphore(void); +KMALLOC_EXTERN void kmm_givesemaphore(void); + KMALLOC_EXTERN FAR void *kmalloc(size_t); KMALLOC_EXTERN FAR void *kzalloc(size_t); KMALLOC_EXTERN FAR void *krealloc(FAR void*, size_t); diff --git a/sched/Makefile b/sched/Makefile index f164630bfd76846711c9945fd9cb0e7a8eb494bb..93807b6957b9f7f2b47d83b12d4c547658f6b517 100644 --- a/sched/Makefile +++ b/sched/Makefile @@ -134,7 +134,8 @@ endif IRQ_SRCS = irq_initialize.c irq_attach.c irq_dispatch.c irq_unexpectedisr.c -KMM_SRCS = kmm_kmalloc.c kmm_kzalloc.c kmm_krealloc.c kmm_kfree.c +KMM_SRCS = kmm_initialize.c kmm_addregion.c kmm_semaphore.c \ + kmm_kmalloc.c kmm_kzalloc.c kmm_krealloc.c kmm_kfree.c CSRCS = $(MISC_SRCS) $(TSK_SRCS) $(SCHED_SRCS) $(WDOG_SRCS) $(TIME_SRCS) \ $(SEM_SRCS) $(TIMER_SRCS) $(WORK_SRCS) $(PGFILL_SRCS) $(IRQ_SRCS) diff --git a/sched/kmm_addregion.c b/sched/kmm_addregion.c new file mode 100644 index 0000000000000000000000000000000000000000..ed923a56f4eb8fa701cd5ace959082e12b874f4b --- /dev/null +++ b/sched/kmm_addregion.c @@ -0,0 +1,113 @@ +/************************************************************************ + * sched/kmm_addregion.c + * + * Copyright (C) 2011 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * + * 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/kmalloc.h> + +#ifdef CONFIG_NUTTX_KERNEL + +/* This logic is all tentatively and, hopefully, will grow in usability. + * For now, the kernel-mode build uses the memory manager that is + * provided in the user-space build. That is awkward but reasonable for + * the current level of support: At present, only memory protection is + * provided. Kernel-mode code may call into user-mode code, but not + * vice-versa. So hosting the memory manager in user-space allows the + * memory manager to be shared in both kernel- and user-mode spaces. + * + * In the longer run, if an MMU is support that can provide virtualized + * memory, then some SLAB memory manager will be required in kernel-space + * with some kind of brk() system call to obtain mapped heap space. + * + * In the current build model, the user-space module is built first. The + * file user_map.h is generated in the first pass and contains the + * addresses of the memory manager needed in this file: + */ + +#include <arch/board/user_map.h> + +/************************************************************************ + * Pre-processor definition + ************************************************************************/ + +/* This value is obtained from user_map.h */ + +#define KADDREGION(h,s) ((kmaddregion_t)CONFIG_USER_MMADDREGION)(h,s) + +/************************************************************************ + * Private Types + ************************************************************************/ + +typedef void (*kmaddregion_t)(FAR void*, size_t); + +/************************************************************************ + * Private Functions + ************************************************************************/ + +/************************************************************************ + * Public Functions + ************************************************************************/ + +/************************************************************************ + * Function: kmm_addregion + * + * Description: + * This is a simple redirection to the user-space mm_addregion() + * function. + * + * Parameters: + * heap_start - Address of the beginning of the memory region + * heap_size - The size (in bytes) if the memory region. + * + * Return Value: + * None + * + * Assumptions: + * 1. mm_addregion() resides in user-space + * 2. The address of the user space mm_addregion() is provided in + * user_map.h + * 3. The user-space mm_addregion() is callable from kernel-space. + * + ************************************************************************/ + +void kmm_addregion(FAR void *heap_start, size_t heap_size) +{ + return KADDREGION(heap_start, heap_size); +} + +#endif /* CONFIG_NUTTX_KERNEL */ diff --git a/sched/kmm_initialize.c b/sched/kmm_initialize.c new file mode 100644 index 0000000000000000000000000000000000000000..59a554adccaae1e226e95d71d824de82d0b9a673 --- /dev/null +++ b/sched/kmm_initialize.c @@ -0,0 +1,113 @@ +/************************************************************************ + * sched/kmm_initialize.c + * + * Copyright (C) 2011 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * + * 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/kmalloc.h> + +#ifdef CONFIG_NUTTX_KERNEL + +/* This logic is all tentatively and, hopefully, will grow in usability. + * For now, the kernel-mode build uses the memory manager that is + * provided in the user-space build. That is awkward but reasonable for + * the current level of support: At present, only memory protection is + * provided. Kernel-mode code may call into user-mode code, but not + * vice-versa. So hosting the memory manager in user-space allows the + * memory manager to be shared in both kernel- and user-mode spaces. + * + * In the longer run, if an MMU is support that can provide virtualized + * memory, then some SLAB memory manager will be required in kernel-space + * with some kind of brk() system call to obtain mapped heap space. + * + * In the current build model, the user-space module is built first. The + * file user_map.h is generated in the first pass and contains the + * addresses of the memory manager needed in this file: + */ + +#include <arch/board/user_map.h> + +/************************************************************************ + * Pre-processor definition + ************************************************************************/ + +/* This value is obtained from user_map.h */ + +#define KINITIALIZE(h,s) ((kminitialize_t)CONFIG_USER_MMINIT)(h,s) + +/************************************************************************ + * Private Types + ************************************************************************/ + +typedef void (*kminitialize_t)(FAR void*, size_t); + +/************************************************************************ + * Private Functions + ************************************************************************/ + +/************************************************************************ + * Public Functions + ************************************************************************/ + +/************************************************************************ + * Function: kmm_initialize + * + * Description: + * This is a simple redirection to the user-space mm_initialize() + * function. + * + * 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 + * + * Assumptions: + * 1. mm_initialize() resides in user-space + * 2. The address of the user space mm_initialize() is provided in + * user_map.h + * 3. The user-space mm_initialize() is callable from kernel-space. + * + ************************************************************************/ + +void kmm_initialize(FAR void *heap_start, size_t heap_size) +{ + return KINITIALIZE(heap_start, heap_size); +} + +#endif /* CONFIG_NUTTX_KERNEL */ diff --git a/sched/kmm_kfree.c b/sched/kmm_kfree.c index 0370ce8ee946e77d79696c6a03f00fd064874ecf..2e64be4bc893f131de08352ef60d0d76506e3a61 100644 --- a/sched/kmm_kfree.c +++ b/sched/kmm_kfree.c @@ -102,7 +102,7 @@ typedef void (*kfree_t)(FAR void *); * ************************************************************************/ -void free(FAR void *mem) +void kfree(FAR void *mem) { return KFREE(mem); } diff --git a/sched/kmm_kmalloc.c b/sched/kmm_kmalloc.c index 01267ab486a324dbcdca0b90331509ac0b467795..aee5306f272ebd55b85fb91e35b5cea402aa0882 100644 --- a/sched/kmm_kmalloc.c +++ b/sched/kmm_kmalloc.c @@ -90,7 +90,7 @@ typedef FAR void *(*kmalloc_t)(size_t); * This is a simple redirection to the user-space malloc() function. * * Parameters: - * None + * size - Size (in bytes) of the memory region to be allocated. * * Return Value: * The address of the allocated memory (NULL on failure to allocate) diff --git a/sched/kmm_krealloc.c b/sched/kmm_krealloc.c index b52d864995fd5eec9d7fc69387c34232f23833ee..91b3448b8c4dd560a3551361e80589c7aacff679 100644 --- a/sched/kmm_krealloc.c +++ b/sched/kmm_krealloc.c @@ -90,7 +90,8 @@ typedef FAR void *(*krealloc_t)(FAR void*, size_t); * This is a simple redirection to the user-space realloc() function. * * Parameters: - * None + * oldmem - The old memory allocated + * size - Size (in bytes) of the new memory region to be re-allocated. * * Return Value: * The address of the re-allocated memory (NULL on failure to re-allocate) diff --git a/sched/kmm_kzalloc.c b/sched/kmm_kzalloc.c index 567cd37d4341756db4a800d7fd5cc6d60f50c304..aba3cf26fdd47e110b072baa6f1275b8e9478154 100644 --- a/sched/kmm_kzalloc.c +++ b/sched/kmm_kzalloc.c @@ -90,7 +90,7 @@ typedef FAR void *(*kzalloc_t)(size_t); * This is a simple redirection to the user-space zalloc() function. * * Parameters: - * None + * size - Size (in bytes) of the memory region to be allocated. * * Return Value: * The address of the allocated memory (NULL on failure to allocate) diff --git a/sched/kmm_semaphore.c b/sched/kmm_semaphore.c new file mode 100644 index 0000000000000000000000000000000000000000..a78a0bed7bae18c795fa8e0d903054c420d4f087 --- /dev/null +++ b/sched/kmm_semaphore.c @@ -0,0 +1,140 @@ +/************************************************************************ + * sched/kmm_semaphore.c + * + * Copyright (C) 2011 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * + * 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/kmalloc.h> + +#ifdef CONFIG_NUTTX_KERNEL + +/* This logic is all tentatively and, hopefully, will grow in usability. + * For now, the kernel-mode build uses the memory manager that is + * provided in the user-space build. That is awkward but reasonable for + * the current level of support: At present, only memory protection is + * provided. Kernel-mode code may call into user-mode code, but not + * vice-versa. So hosting the memory manager in user-space allows the + * memory manager to be shared in both kernel- and user-mode spaces. + * + * In the longer run, if an MMU is support that can provide virtualized + * memory, then some SLAB memory manager will be required in kernel-space + * with some kind of brk() system call to obtain mapped heap space. + * + * In the current build model, the user-space module is built first. The + * file user_map.h is generated in the first pass and contains the + * addresses of the memory manager needed in this file: + */ + +#include <arch/board/user_map.h> + +/************************************************************************ + * Pre-processor definition + ************************************************************************/ + +/* These values are obtained from user_map.h */ + +#define KTRYSEMAPHORE() ((kmtrysemaphore_t) CONFIG_USER_MMTRYSEM )() +#define KGIVESEMAPHORE() ((kmgivesemaphore_t)CONFIG_USER_MMGIVESEM)() + +/************************************************************************ + * Private Types + ************************************************************************/ + +typedef int (*kmtrysemaphore_t)(void); +typedef void (*kmgivesemaphore_t)(void); + +/************************************************************************ + * Private Functions + ************************************************************************/ + +/************************************************************************ + * Public Functions + ************************************************************************/ + +/************************************************************************ + * Function: kmm_trysemaphore + * + * Description: + * This is a simple redirection to the user-space mm_trysemaphore() + * function. + * + * Parameters: + * None + * + * Return Value: + * OK on success; a negated errno on failure + * + * Assumptions: + * 1. mm_trysemaphore() resides in user-space + * 2. The address of the user space mm_trysemaphore() is provided in + * user_map.h + * 3. The user-space mm_semaphore() is callable from kernel-space. + * + ************************************************************************/ + +int kmm_trysemaphore(void) +{ + return KTRYSEMAPHORE(); +} + +/************************************************************************ + * Function: kmm_givesemaphore + * + * Description: + * This is a simple redirection to the user-space mm_givesemaphore() + * function. + * + * Parameters: + * None + * + * Return Value: + * OK on success; a negated errno on failure + * + * Assumptions: + * 1. mm_givesemaphore() resides in user-space + * 2. The address of the user space mm_givesemaphore() is provided in + * user_map.h + * 3. The user-space mm_semaphore() is callable from kernel-space. + * + ************************************************************************/ + +void kmm_givesemaphore(void) +{ + KGIVESEMAPHORE(); +} + +#endif /* CONFIG_NUTTX_KERNEL */ diff --git a/sched/os_start.c b/sched/os_start.c index 5b5e659e7152969891fe51d5b143851d49755216..0e44099c83303689690fda4df40ab75f712bffcf 100644 --- a/sched/os_start.c +++ b/sched/os_start.c @@ -47,8 +47,9 @@ #include <nuttx/fs.h> #include <nuttx/net.h> #include <nuttx/lib.h> -#include <nuttx/mm.h> +#include <nuttx/kmalloc.h> #include <nuttx/init.h> + #include "os_internal.h" #include "sig_internal.h" #include "wd_internal.h" @@ -295,10 +296,10 @@ void os_start(void) FAR void *heap_start; size_t heap_size; up_allocate_heap(&heap_start, &heap_size); - mm_initialize(heap_start, heap_size); + kmm_initialize(heap_start, heap_size); } #else - mm_initialize((void*)CONFIG_HEAP_BASE, CONFIG_HEAP_SIZE); + kmm_initialize((void*)CONFIG_HEAP_BASE, CONFIG_HEAP_SIZE); #endif /* Initialize the interrupt handling subsystem (if included) */ @@ -460,10 +461,10 @@ void os_start(void) * possible because if the IDLE thread is running, no other task is! */ - if (mm_trysemaphore() == 0) + if (kmm_trysemaphore() == 0) { sched_garbagecollection(); - mm_givesemaphore(); + kmm_givesemaphore(); } #endif diff --git a/sched/sched_free.c b/sched/sched_free.c index 998f5458ced9a17072c98e9f114b34b3e70ad51c..2bdf9670ed8281d32cf95aab89ed3866beaaad81 100644 --- a/sched/sched_free.c +++ b/sched/sched_free.c @@ -45,8 +45,6 @@ #include <nuttx/kmalloc.h> #include <nuttx/arch.h> #include <nuttx/wqueue.h> -#include <nuttx/mm.h> - #include "os_internal.h" /************************************************************************ @@ -92,7 +90,7 @@ void sched_free(FAR void *address) * manager to do this. */ - if (up_interrupt_context() || mm_trysemaphore() != 0) + if (up_interrupt_context() || kmm_trysemaphore() != 0) { /* Yes.. Delay the deallocation until a more appropriate time. */ @@ -111,7 +109,7 @@ void sched_free(FAR void *address) /* No.. just deallocate the memory now. */ kfree(address); - mm_givesemaphore(); + kmm_givesemaphore(); } } diff --git a/sched/sched_garbage.c b/sched/sched_garbage.c index 946198ede183ac90a74f0dd84a471bd794d682b9..714422bd672aefe66a2d6d635f7994712683ced7 100755 --- a/sched/sched_garbage.c +++ b/sched/sched_garbage.c @@ -1,7 +1,7 @@ /**************************************************************************** - * sched/work_garbage.c + * sched/sched_garbage.c * - * Copyright (C) 2009 Gregory Nutt. All rights reserved. + * Copyright (C) 2009, 2011 Gregory Nutt. All rights reserved. * Author: Gregory Nutt <spudmonkey@racsa.co.cr> * * Redistribution and use in source and binary forms, with or without