up_addregion should use kmm_addregion; move garbage kmm*.c file to mm/. for now

git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@5721 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo
2013-03-08 22:01:50 +00:00
parent 017e07d35d
commit 0db8dc83ee
32 changed files with 199 additions and 182 deletions
+6 -2
View File
@@ -4284,6 +4284,10 @@
* mm/: Move all memory manager globals into a structure. A reference
to this structure is now passed internally between mm APIs. This
change will (eventually) support multiple heaps and heap allocators.
(2013-03-07).
(2013-03-08).
* mm/ and include/nuttx/mm.h: Implement support for multiple heaps.
(2013-03-07).
(2013-03-08).
* arch/*/src: xyz_addregion() needs to call kmm_addregion, not mm_addretion.
(2013-03-08).
* sched/kmm*.c: Move this garbage kmm*.c file to mm/. until I decide what
to do with them (which is probably to just delete them). (2013-03-08).
+1 -1
View File
@@ -4396,7 +4396,7 @@ build
<code>CONFIG_MM_REGIONS</code>: If the architecture includes multiple
regions of memory to allocate from, this specifies the
number of memory regions that the memory manager must
handle and enables the API mm_addregion(start, end);
handle and enables the API <code>mm_addregion(heap, start, end)</code>.
</li>
<li>
<code>CONFIG_MM_SMALL</code>: Each memory allocation has a small allocation
+21 -10
View File
@@ -198,10 +198,10 @@ USERLIBS =
# is placed in user space (only).
ifeq ($(CONFIG_NUTTX_KERNEL),y)
NUTTXLIBS += lib/libstubs$(LIBEXT) lib/libkc$(LIBEXT)
USERLIBS += lib/libproxies$(LIBEXT) lib/libuc$(LIBEXT) lib/libmm$(LIBEXT)
NUTTXLIBS += lib/libstubs$(LIBEXT) lib/libkc$(LIBEXT) lib/libkmm$(LIBEXT)
USERLIBS += lib/libproxies$(LIBEXT) lib/libuc$(LIBEXT) lib/libumm$(LIBEXT)
else
NUTTXLIBS += lib/libmm$(LIBEXT) lib/libc$(LIBEXT)
NUTTXLIBS += lib/libc$(LIBEXT) lib/libmm$(LIBEXT)
endif
# Add libraries for C++ support. CXX, CXXFLAGS, and COMPILEXX must
@@ -457,6 +457,12 @@ libc/libkc$(LIBEXT): context
lib/libkc$(LIBEXT): libc/libkc$(LIBEXT)
$(Q) install libc/libkc$(LIBEXT) lib/libkc$(LIBEXT)
mm/libkmm$(LIBEXT): context
$(Q) $(MAKE) -C mm TOPDIR="$(TOPDIR)" libkmm$(LIBEXT) EXTRADEFINES=$(KDEFINE)
lib/libkmm$(LIBEXT): mm/libkmm$(LIBEXT)
$(Q) install mm/libkmm$(LIBEXT) lib/libkmm$(LIBEXT)
sched/libsched$(LIBEXT): context
$(Q) $(MAKE) -C sched TOPDIR="$(TOPDIR)" libsched$(LIBEXT) EXTRADEFINES=$(KDEFINE)
@@ -513,18 +519,18 @@ libc/libuc$(LIBEXT): context
lib/libuc$(LIBEXT): libc/libuc$(LIBEXT)
$(Q) install libc/libuc$(LIBEXT) lib/libuc$(LIBEXT)
mm/libumm$(LIBEXT): context
$(Q) $(MAKE) -C mm TOPDIR="$(TOPDIR)" libumm$(LIBEXT) EXTRADEFINES=$(KDEFINE)
lib/libumm$(LIBEXT): mm/libumm$(LIBEXT)
$(Q) install mm/libumm$(LIBEXT) lib/libumm$(LIBEXT)
libxx/libcxx$(LIBEXT): context
$(Q) $(MAKE) -C libxx TOPDIR="$(TOPDIR)" libcxx$(LIBEXT)
lib/libcxx$(LIBEXT): libxx/libcxx$(LIBEXT)
$(Q) install libxx/libcxx$(LIBEXT) lib/libcxx$(LIBEXT)
mm/libmm$(LIBEXT): context
$(Q) $(MAKE) -C mm TOPDIR="$(TOPDIR)" libmm$(LIBEXT) EXTRADEFINES=$(KDEFINE)
lib/libmm$(LIBEXT): mm/libmm$(LIBEXT)
$(Q) install mm/libmm$(LIBEXT) lib/libmm$(LIBEXT)
$(APPDIR)/libapps$(LIBEXT): context
$(Q) $(MAKE) -C $(APPDIR) TOPDIR="$(TOPDIR)" libapps$(LIBEXT)
@@ -545,6 +551,12 @@ libc/libc$(LIBEXT): context
lib/libc$(LIBEXT): libc/libc$(LIBEXT)
$(Q) install libc/libc$(LIBEXT) lib/libc$(LIBEXT)
mm/libmm$(LIBEXT): context
$(Q) $(MAKE) -C mm TOPDIR="$(TOPDIR)" libmm$(LIBEXT) EXTRADEFINES=$(KDEFINE)
lib/libmm$(LIBEXT): mm/libmm$(LIBEXT)
$(Q) install mm/libmm$(LIBEXT) lib/libmm$(LIBEXT)
# pass1 and pass2
#
# If the 2 pass build option is selected, then this pass1 target is
@@ -680,7 +692,6 @@ subdir_clean:
fi \
done
$(Q) $(MAKE) -C tools -f Makefile.host TOPDIR="$(TOPDIR)" clean
$(Q) $(MAKE) -C mm -f Makefile.test TOPDIR="$(TOPDIR)" clean
ifeq ($(CONFIG_BUILD_2PASS),y)
$(Q) $(MAKE) -C $(CONFIG_PASS1_BUILDIR) TOPDIR="$(TOPDIR)" clean
endif
+21 -10
View File
@@ -191,10 +191,10 @@ USERLIBS =
# is placed in user space (only).
ifeq ($(CONFIG_NUTTX_KERNEL),y)
NUTTXLIBS += lib\libstubs$(LIBEXT) lib\libkc$(LIBEXT)
USERLIBS += lib\libproxies$(LIBEXT) lib\libuc$(LIBEXT) lib\libmm$(LIBEXT)
NUTTXLIBS += lib\libstubs$(LIBEXT) lib\libkc$(LIBEXT) lib\libkmm$(LIBEXT)
USERLIBS += lib\libproxies$(LIBEXT) lib\libuc$(LIBEXT) lib\libumm$(LIBEXT)
else
NUTTXLIBS += lib\libmm$(LIBEXT) lib\libc$(LIBEXT)
NUTTXLIBS += lib\libc$(LIBEXT) lib\libmm$(LIBEXT)
endif
# Add libraries for C++ support. CXX, CXXFLAGS, and COMPILEXX must
@@ -473,6 +473,12 @@ libc\libkc$(LIBEXT): context
lib\libkc$(LIBEXT): libc\libkc$(LIBEXT)
$(Q) install libc\libkc$(LIBEXT) lib\libkc$(LIBEXT)
mm\libkmm$(LIBEXT): context
$(Q) $(MAKE) -C mm TOPDIR="$(TOPDIR)" libkmm$(LIBEXT) EXTRADEFINES=$(KDEFINE)
lib\libkmm$(LIBEXT): mm\libkmm$(LIBEXT)
$(Q) install mm\libkmm$(LIBEXT) lib\libkmm$(LIBEXT)
sched\libsched$(LIBEXT): context
$(Q) $(MAKE) -C sched TOPDIR="$(TOPDIR)" libsched$(LIBEXT) EXTRADEFINES=$(KDEFINE)
@@ -529,18 +535,18 @@ libc\libuc$(LIBEXT): context
lib\libuc$(LIBEXT): libc\libuc$(LIBEXT)
$(Q) install libc\libuc$(LIBEXT) lib\libuc$(LIBEXT)
mm\libumm$(LIBEXT): context
$(Q) $(MAKE) -C mm TOPDIR="$(TOPDIR)" libumm$(LIBEXT) EXTRADEFINES=$(KDEFINE)
lib\libumm$(LIBEXT): mm\libumm$(LIBEXT)
$(Q) install mm\libumm$(LIBEXT) lib\libumm$(LIBEXT)
libxx\libcxx$(LIBEXT): context
$(Q) $(MAKE) -C libxx TOPDIR="$(TOPDIR)" libcxx$(LIBEXT)
lib\libcxx$(LIBEXT): libxx\libcxx$(LIBEXT)
$(Q) install libxx\libcxx$(LIBEXT) lib\libcxx$(LIBEXT)
mm\libmm$(LIBEXT): context
$(Q) $(MAKE) -C mm TOPDIR="$(TOPDIR)" libmm$(LIBEXT) EXTRADEFINES=$(KDEFINE)
lib\libmm$(LIBEXT): mm\libmm$(LIBEXT)
$(Q) install mm\libmm$(LIBEXT) lib\libmm$(LIBEXT)
$(APPDIR)\libapps$(LIBEXT): context
$(Q) $(MAKE) -C $(APPDIR) TOPDIR="$(TOPDIR)" libapps$(LIBEXT)
@@ -561,6 +567,12 @@ libc\libc$(LIBEXT): context
lib\libc$(LIBEXT): libc\libc$(LIBEXT)
$(Q) install libc\libc$(LIBEXT) lib\libc$(LIBEXT)
mm\libmm$(LIBEXT): context
$(Q) $(MAKE) -C mm TOPDIR="$(TOPDIR)" libmm$(LIBEXT) EXTRADEFINES=$(KDEFINE)
lib\libmm$(LIBEXT): mm\libmm$(LIBEXT)
$(Q) install mm\libmm$(LIBEXT) lib\libmm$(LIBEXT)
# pass1 and pass2
#
# If the 2 pass build option is selected, then this pass1 target is
@@ -685,7 +697,6 @@ depend: pass1dep pass2dep
subdir_clean:
$(Q) for %%G in ($(CLEANDIRS)) do ( if exist %%G\Makefile $(MAKE) -C %%G TOPDIR="$(TOPDIR)" clean )
$(Q) $(MAKE) -C tools -f Makefile.host TOPDIR="$(TOPDIR)" clean
$(Q) $(MAKE) -C mm -f Makefile.test TOPDIR="$(TOPDIR)" clean
ifeq ($(CONFIG_BUILD_2PASS),y)
$(Q) $(MAKE) -C $(CONFIG_PASS1_BUILDIR) TOPDIR="$(TOPDIR)" clean
endif
+6 -3
View File
@@ -1,7 +1,7 @@
/************************************************************
* up_allocateheap.c
*
* Copyright (C) 2007 Gregory Nutt. All rights reserved.
* Copyright (C) 2007, 2013 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@@ -38,11 +38,14 @@
************************************************************/
#include <nuttx/config.h>
#include <sys/types.h>
#include <sched.h>
#include <debug.h>
#include <nuttx/arch.h>
#include <nuttx/mm.h>
#include <nuttx/kmalloc.h>
#include "os_internal.h"
#include "up_internal.h"
#include "up_mem.h"
@@ -84,6 +87,6 @@ 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*)UP_HEAP2_BASE, UP_HEAP2_END - UP_HEAP2_BASE);
kmm_addregion((FAR void*)UP_HEAP2_BASE, UP_HEAP2_END - UP_HEAP2_BASE);
}
#endif
+2 -3
View File
@@ -42,7 +42,7 @@
****************************************************************************/
#include <nuttx/config.h>
#include <nuttx/mm.h>
#include <nuttx/kmalloc.h>
#include <sys/types.h>
#include <debug.h>
@@ -96,7 +96,6 @@ void up_addregion(void)
/* Configure the RHEA bridge with some sane default values */
calypso_rhea_cfg(0, 0, 0xff, 0, 1, 0, 0);
mm_addregion((FAR void*)CONFIG_HEAP2_BASE, CONFIG_HEAP2_SIZE);
kmm_addregion((FAR void*)CONFIG_HEAP2_BASE, CONFIG_HEAP2_SIZE);
}
#endif
+4 -4
View File
@@ -2,7 +2,7 @@
* arch/arm/src/imx/imx_allocateheap.c
* arch/arm/src/chip/imx_allocateheap.c
*
* Copyright (C) 2009 Gregory Nutt. All rights reserved.
* Copyright (C) 2009, 2013 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@@ -44,7 +44,7 @@
#include <stdint.h>
#include <debug.h>
#include <nuttx/mm.h>
#include <nuttx/kmalloc.h>
#include <nuttx/arch.h>
#include <arch/board/board.h>
@@ -105,14 +105,14 @@ void up_addregion(void)
# if (CONFIG_DRAM_NUTTXENTRY & 0xffff0000) != CONFIG_DRAM_VSTART
uint32_t start = CONFIG_DRAM_VSTART + 0x1000;
uint32_t end = (CONFIG_DRAM_NUTTXENTRY & 0xffff0000);
mm_addregion((FAR void*)start, end - start);
kmm_addregion((FAR void*)start, end - start);
# endif
#endif
/* Check for any additional memory regions */
#if defined(CONFIG_HEAP2_BASE) && defined(CONFIG_HEAP2_SIZE)
mm_addregion((FAR void*)CONFIG_HEAP2_BASE, CONFIG_HEAP2_SIZE);
kmm_addregion((FAR void*)CONFIG_HEAP2_BASE, CONFIG_HEAP2_SIZE);
#endif
}
#endif
+2 -2
View File
@@ -1,7 +1,7 @@
/****************************************************************************
* arch/arm/src/lpc17xx/lpc17_allocateheap.c
*
* Copyright (C) 2010-2011 Gregory Nutt. All rights reserved.
* Copyright (C) 2010-2011, 2013 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@@ -224,7 +224,7 @@ void up_addregion(void)
/* Yes... Add the AHB SRAM heap region. */
mm_addregion((FAR void*)LPC17_AHB_HEAPBASE, LPC17_AHB_HEAPSIZE);
kmm_addregion((FAR void*)LPC17_AHB_HEAPBASE, LPC17_AHB_HEAPSIZE);
#endif
}
#endif
+5 -4
View File
@@ -1,7 +1,7 @@
/************************************************************************
* arch/arm/src/lpc31xx/lpc31_allocateheap.c
*
* Copyright (C) 2009-2010 Gregory Nutt. All rights reserved.
* Copyright (C) 2009-2010, 2013 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@@ -43,6 +43,7 @@
#include <debug.h>
#include <nuttx/arch.h>
#include <nuttx/kmalloc.h>
#include <arch/board/board.h>
#include "arm.h"
@@ -192,15 +193,15 @@ void up_allocate_heap(FAR void **heap_start, size_t *heap_size)
void up_addregion(void)
{
#if defined(CONFIG_ARCH_EXTSRAM0) && defined(CONFIG_ARCH_EXTSRAM0HEAP)
mm_addregion((FAR void*)LPC31_EXTSRAM0_VSECTION, CONFIG_ARCH_EXTSRAM0SIZE);
kmm_addregion((FAR void*)LPC31_EXTSRAM0_VSECTION, CONFIG_ARCH_EXTSRAM0SIZE);
#endif
#if defined(CONFIG_ARCH_EXTSRAM1) && defined(CONFIG_ARCH_EXTSRAM1HEAP)
mm_addregion((FAR void*)LPC31_EXTSRAM1_VSECTION, CONFIG_ARCH_EXTSRAM1SIZE);
kmm_addregion((FAR void*)LPC31_EXTSRAM1_VSECTION, CONFIG_ARCH_EXTSRAM1SIZE);
#endif
#if defined(CONFIG_ARCH_EXTDRAM) && defined(CONFIG_ARCH_EXTDRAMHEAP)
mm_addregion((FAR void*)LPC31_EXTSDRAM_VSECTION, CONFIG_ARCH_EXTDRAMSIZE);
kmm_addregion((FAR void*)LPC31_EXTSDRAM_VSECTION, CONFIG_ARCH_EXTDRAMSIZE);
#endif
}
#endif
+6 -6
View File
@@ -1,7 +1,7 @@
/****************************************************************************
* arch/arm/src/lpc43xx/lpc43_allocateheap.c
*
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
* Copyright (C) 2012-2013 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@@ -43,7 +43,7 @@
#include <debug.h>
#include <nuttx/arch.h>
#include <nuttx/mm.h>
#include <nuttx/kmalloc.h>
#include <arch/board/board.h>
#include "chip.h"
@@ -259,7 +259,7 @@ void up_addregion(void)
#if CONFIG_MM_REGIONS > 1
/* Add the next SRAM region (which should exist) */
mm_addregion((FAR void*)MM_REGION2_BASE, MM_REGION2_SIZE);
kmm_addregion((FAR void*)MM_REGION2_BASE, MM_REGION2_SIZE);
#ifdef MM_REGION3_BASE
/* Add the third SRAM region (which will not exist in configuration B) */
@@ -267,12 +267,12 @@ void up_addregion(void)
#if CONFIG_MM_REGIONS > 2
/* Add the third SRAM region (which may not exist) */
mm_addregion((FAR void*)MM_REGION3_BASE, MM_REGION3_SIZE);
kmm_addregion((FAR void*)MM_REGION3_BASE, MM_REGION3_SIZE);
#if CONFIG_MM_REGIONS > 3 && defined(MM_DMAHEAP_BASE)
/* Add the DMA region (which may not be available) */
mm_addregion((FAR void*)MM_DMAHEAP_BASE, MM_DMAHEAP_SIZE);
kmm_addregion((FAR void*)MM_DMAHEAP_BASE, MM_DMAHEAP_SIZE);
#endif /* CONFIG_MM_REGIONS > 3 && defined(MM_DMAHEAP_BASE) */
#endif /* CONFIG_MM_REGIONS > 2 */
@@ -281,7 +281,7 @@ void up_addregion(void)
#if CONFIG_MM_REGIONS > 2 && defined(MM_DMAHEAP_BASE)
/* Add the DMA region (which may not be available) */
mm_addregion((FAR void*)MM_DMAHEAP_BASE, MM_DMAHEAP_SIZE);
kmm_addregion((FAR void*)MM_DMAHEAP_BASE, MM_DMAHEAP_SIZE);
#endif /* CONFIG_MM_REGIONS > 3 && defined(MM_DMAHEAP_BASE) */
#endif /* MM_REGION3_BASE */
+1 -1
View File
@@ -1,7 +1,7 @@
/****************************************************************************
* arch/arm/src/common/sam3u_allocateheap.c
*
* Copyright (C) 2010 Gregory Nutt. All rights reserved.
* Copyright (C) 2010, 2013 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
+4 -4
View File
@@ -1,7 +1,7 @@
/****************************************************************************
* arch/arm/src/stm32/up_allocateheap.c
*
* Copyright (C) 2011-2012 Gregory Nutt. All rights reserved.
* Copyright (C) 2011-2013 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@@ -43,7 +43,7 @@
#include <debug.h>
#include <nuttx/arch.h>
#include <nuttx/mm.h>
#include <nuttx/kmalloc.h>
#include <arch/board/board.h>
@@ -385,13 +385,13 @@ void up_addregion(void)
/* Add the STM32F20xxx/STM32F40xxx CCM SRAM heap region. */
#ifndef CONFIG_STM32_CCMEXCLUDE
mm_addregion((FAR void*)SRAM2_START, SRAM2_END-SRAM2_START);
kmm_addregion((FAR void*)SRAM2_START, SRAM2_END-SRAM2_START);
#endif
/* Add the external FSMC SRAM heap region. */
#ifdef CONFIG_STM32_FSMC_SRAM
mm_addregion((FAR void*)CONFIG_HEAP2_BASE, CONFIG_HEAP2_SIZE);
kmm_addregion((FAR void*)CONFIG_HEAP2_BASE, CONFIG_HEAP2_SIZE);
#endif
}
#endif
+4 -3
View File
@@ -1,7 +1,7 @@
/****************************************************************************
* common/up_allocateheap.c
*
* Copyright (C) 2008 Gregory Nutt. All rights reserved.
* Copyright (C) 2008, 2013 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@@ -41,8 +41,9 @@
#include <sys/types.h>
#include <debug.h>
#include <nuttx/arch.h>
#include <nuttx/mm.h>
#include <nuttx/kmalloc.h>
#include <arch/board/board.h>
#include "chip/chip.h"
@@ -107,6 +108,6 @@ 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*)CONFIG_HEAP2_BASE, CONFIG_HEAP2_SIZE);
kmm_addregion((FAR void*)CONFIG_HEAP2_BASE, CONFIG_HEAP2_SIZE);
}
#endif
+4 -3
View File
@@ -1,7 +1,7 @@
/****************************************************************************
* common/up_allocateheap.c
*
* Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved.
* Copyright (C) 2007, 2008, 2013 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@@ -41,8 +41,9 @@
#include <sys/types.h>
#include <debug.h>
#include <nuttx/arch.h>
#include <nuttx/mm.h>
#include <nuttx/kmalloc.h>
#include "up_arch.h"
#include "up_internal.h"
@@ -109,6 +110,6 @@ 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*)CONFIG_HEAP2_BASE, CONFIG_HEAP2_SIZE);
kmm_addregion((FAR void*)CONFIG_HEAP2_BASE, CONFIG_HEAP2_SIZE);
}
#endif
+1 -1
View File
@@ -284,7 +284,7 @@ defconfig -- This is a configuration file similar to the Linux
CONFIG_MM_REGIONS - If the architecture includes multiple
regions of memory to allocate from, this specifies the
number of memory regions that the memory manager must
handle and enables the API mm_addregion(start, end);
handle and enables the API mm_addregion(heap, start, end);
CONFIG_MM_SMALL - Each memory allocation has a small allocation
overhead. The size of that overhead is normally determined by
the "width" of the address support by the MCU. MCUs that support
+1 -1
View File
@@ -63,7 +63,7 @@ CONFIG_ARCH_BOARD_RGMP=y
# CONFIG_MM_REGIONS - If the architecture includes multiple
# regions of memory to allocate from, this specifies the
# number of memory regions that the memory manager must
# handle and enables the API mm_addregion(start, end);
# handle and enables the API mm_addregion(heap, start, end);
# CONFIG_ARCH_LOWPUTC - architecture supports low-level, boot
# time console output
# CONFIG_MSEC_PER_TICK - The default system timer is 100Hz
+1 -1
View File
@@ -63,7 +63,7 @@ CONFIG_ARCH_BOARD_RGMP=y
# CONFIG_MM_REGIONS - If the architecture includes multiple
# regions of memory to allocate from, this specifies the
# number of memory regions that the memory manager must
# handle and enables the API mm_addregion(start, end);
# handle and enables the API mm_addregion(heap, start, end);
# CONFIG_ARCH_LOWPUTC - architecture supports low-level, boot
# time console output
# CONFIG_MSEC_PER_TICK - The default system timer is 100Hz
+2 -2
View File
@@ -77,8 +77,8 @@ extern "C"
#ifndef CONFIG_NUTTX_KERNEL
# define kmm_initialize(h,s) mm_initialize(h,s)
# define kmm_addregion(h,s) mm_addregion(h,s)
# define kmm_initialize(h,s) mm_initialize(&g_mmheap,h,s)
# define kmm_addregion(h,s) mm_addregion(&g_mmheap,h,s)
# define kmm_trysemaphore() mm_trysemaphore(&g_mmheap)
# define kmm_givesemaphore() mm_givesemaphore(&g_mmheap)
+4 -2
View File
@@ -233,8 +233,10 @@ EXTERN struct mm_heap_s g_mmheap;
/* Functions contained in mm_initialize.c ***********************************/
void mm_initialize(FAR void *heap_start, size_t heap_size);
void mm_addregion(FAR void *heapstart, size_t heapsize);
void mm_initialize(FAR struct mm_heap_s *heap, FAR void *heap_start,
size_t heap_size);
void mm_addregion(FAR struct mm_heap_s *heap, FAR void *heapstart,
size_t heapsize);
/* Functions contained in mm_sem.c ******************************************/
+1 -1
View File
@@ -37,7 +37,7 @@ config MM_REGIONS
If the architecture includes multiple, non-contiguous regions of
memory to allocate from, this specifies the number of memory regions
that the memory manager must handle and enables the API
mm_addregion(start, end);
mm_addregion(heap, start, end);
NOTE: If MM_MULTIHEAP is selected, then this maximum number of regions
applies to all heaps.
+62 -12
View File
@@ -1,7 +1,7 @@
############################################################################
# mm/Makefile
#
# Copyright (C) 2007, 2012 Gregory Nutt. All rights reserved.
# Copyright (C) 2007, 2012, 2013 Gregory Nutt. All rights reserved.
# Author: Gregory Nutt <gnutt@nuttx.org>
#
# Redistribution and use in source and binary forms, with or without
@@ -35,22 +35,29 @@
-include $(TOPDIR)/Make.defs
ASRCS =
CSRCS = mm_initialize.c mm_sem.c mm_addfreechunk.c mm_size2ndx.c mm_shrinkchunk.c \
mm_malloc.c mm_zalloc.c mm_calloc.c mm_realloc.c \
mm_memalign.c mm_free.c mm_mallinfo.c
ASRCS =
CSRCS = mm_initialize.c mm_sem.c mm_addfreechunk.c mm_size2ndx.c
CSRCS += mm_shrinkchunk.c mm_malloc.c mm_zalloc.c mm_calloc.c mm_realloc.c
CSRCS += mm_memalign.c mm_free.c mm_mallinfo.c
ifeq ($(CONFIG_GRAN),y)
CSRCS += mm_graninit.c mm_granalloc.c mm_granfree.c mm_grancritical.c
ifeq ($(CONFIG_NUTTX_KERNEL),y)
CSRCS += kmm_initialize.c kmm_addregion.c kmm_semaphore.c
CSRCS += kmm_kmalloc.c kmm_kzalloc.c kmm_krealloc.c kmm_kfree.c
endif
AOBJS = $(ASRCS:.S=$(OBJEXT))
COBJS = $(CSRCS:.c=$(OBJEXT))
ifeq ($(CONFIG_GRAN),y)
CSRCS += mm_graninit.c mm_granalloc.c mm_granfree.c mm_grancritical.c
endif
SRCS = $(ASRCS) $(CSRCS)
OBJS = $(AOBJS) $(COBJS)
AOBJS = $(ASRCS:.S=$(OBJEXT))
COBJS = $(CSRCS:.c=$(OBJEXT))
BIN = libmm$(LIBEXT)
SRCS = $(ASRCS) $(CSRCS)
OBJS = $(AOBJS) $(COBJS)
UBIN = libumm$(LIBEXT)
KBIN = libkmm$(LIBEXT)
BIN = libmm$(LIBEXT)
all: $(BIN)
@@ -63,14 +70,57 @@ $(COBJS): %$(OBJEXT): %.c
$(BIN): $(OBJS)
$(call ARCHIVE, $@, $(OBJS))
ifneq ($(BIN),$(UBIN))
.userlib:
$(Q) $(MAKE) $(UBIN) BIN=$(UBIN) TOPDIR=$(TOPDIR) EXTRADEFINES=$(EXTRADEFINES)
$(Q) touch .userlib
$(UBIN): kclean .userlib
endif
ifneq ($(BIN),$(KBIN))
.kernlib:
$(Q) $(MAKE) $(KBIN) BIN=$(KBIN) TOPDIR=$(TOPDIR) EXTRADEFINES=$(EXTRADEFINES)
$(Q) touch .kernlib
$(KBIN): uclean .kernlib
endif
.depend: Makefile $(SRCS)
$(Q) $(MKDEP) "$(CC)" -- $(CFLAGS) -- $(SRCS) >Make.dep
$(Q) touch $@
depend: .depend
# Clean Targets:
# Clean user-mode temporary files (retaining the UBIN binary)
uclean:
ifneq ($(OBJEXT),)
ifeq ($(CONFIG_WINDOWS_NATIVE),y)
$(Q) if exist .userlib ]; then del *$(OBJEXT)
else
$(Q) ( if [ -f .userlib ]; then rm -f *$(OBJEXT); fi )
endif
endif
$(call DELFILE, .userlib)
# Clean kernel-mode temporary files (retaining the KBIN binary)
kclean:
ifneq ($(OBJEXT),)
ifeq ($(CONFIG_WINDOWS_NATIVE),y)
$(Q) if exist .kernlib ]; then del *$(OBJEXT)
else
$(Q) ( if [ -f .kernlib ]; then rm -f *$(OBJEXT); fi )
endif
endif
$(call DELFILE, .kernlib)
clean:
$(call DELFILE, $(BIN))
$(call DELFILE, $(UBIN))
$(call DELFILE, $(KBIN))
$(call CLEAN)
distclean: clean
+1 -13
View File
@@ -32,19 +32,7 @@ This directory contains the NuttX memory management logic. This include:
o Alignment: All allocations are aligned to 8- or 4-bytes for large
and small models, respectively.
2) Test Program. There is also a host-best test program that can be
used to verify the memory manager. These are the file:
Makefile.test, mm_test.c, and mm_environment.h.
Build instructions:
make -f Makefile.test
The executable will be built in the top-level directory as nuttx/mm_text
(or mm_test.exe under Cygwin).
3) Granule Allocator. A non-standard granule allocator is also available
2) Granule Allocator. A non-standard granule allocator is also available
in this directory The granule allocator allocates memory in units
of a fixed sized block ("granule"). Allocations may be aligned to a user-
provided address boundary.
+4 -4
View File
@@ -1,5 +1,5 @@
/************************************************************************
* sched/kmm_addregion.c
* mm/kmm_addregion.c
*
* Copyright (C) 2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
@@ -40,7 +40,7 @@
#include <nuttx/config.h>
#include <nuttx/kmalloc.h>
#ifdef CONFIG_NUTTX_KERNEL
#if defined(CONFIG_NUTTX_KERNEL) && defined(__KERNEL__)
/* This logic is all tentatively and, hopefully, will grow in usability.
* For now, the kernel-mode build uses the memory manager that is
@@ -107,7 +107,7 @@ typedef void (*kmaddregion_t)(FAR void*, size_t);
void kmm_addregion(FAR void *heap_start, size_t heap_size)
{
return KADDREGION(heap_start, heap_size);
return KADDREGION(&g_kmmheap, heap_start, heap_size);
}
#endif /* CONFIG_NUTTX_KERNEL */
#endif /* CONFIG_NUTTX_KERNEL && __KERNEL__ */
@@ -1,5 +1,5 @@
/************************************************************************
* sched/kmm_initialize.c
* mm/kmm_initialize.c
*
* Copyright (C) 2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
@@ -40,7 +40,7 @@
#include <nuttx/config.h>
#include <nuttx/kmalloc.h>
#ifdef CONFIG_NUTTX_KERNEL
#if defined(CONFIG_NUTTX_KERNEL) && defined(__KERNEL__)
/* This logic is all tentatively and, hopefully, will grow in usability.
* For now, the kernel-mode build uses the memory manager that is
@@ -110,4 +110,4 @@ void kmm_initialize(FAR void *heap_start, size_t heap_size)
return KINITIALIZE(heap_start, heap_size);
}
#endif /* CONFIG_NUTTX_KERNEL */
#endif /* CONFIG_NUTTX_KERNEL && __KERNEL__ */
+3 -3
View File
@@ -1,5 +1,5 @@
/************************************************************************
* sched/kmm_kfree.c
* mm/kmm_kfree.c
*
* Copyright (C) 2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
@@ -40,7 +40,7 @@
#include <nuttx/config.h>
#include <nuttx/kmalloc.h>
#ifdef CONFIG_NUTTX_KERNEL
#if defined(CONFIG_NUTTX_KERNEL) && defined(__KERNEL__)
/* This logic is all tentatively and, hopefully, will grow in usability.
* For now, the kernel-mode build uses the memory manager that is
@@ -107,4 +107,4 @@ void kfree(FAR void *mem)
return KFREE(mem);
}
#endif /* CONFIG_NUTTX_KERNEL */
#endif /* CONFIG_NUTTX_KERNEL && __KERNEL__ */
+3 -3
View File
@@ -1,5 +1,5 @@
/************************************************************************
* sched/kmm_kmalloc.c
* mm/kmm_kmalloc.c
*
* Copyright (C) 2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
@@ -40,7 +40,7 @@
#include <nuttx/config.h>
#include <nuttx/kmalloc.h>
#ifdef CONFIG_NUTTX_KERNEL
#if defined(CONFIG_NUTTX_KERNEL) && defined(__KERNEL__)
/* This logic is all tentatively and, hopefully, will grow in usability.
* For now, the kernel-mode build uses the memory manager that is
@@ -107,4 +107,4 @@ FAR void *kmalloc(size_t size)
return KMALLOC(size);
}
#endif /* CONFIG_NUTTX_KERNEL */
#endif /* CONFIG_NUTTX_KERNEL && __KERNEL__ */
+3 -3
View File
@@ -1,5 +1,5 @@
/************************************************************************
* sched/kmm_krealloc.c
* mm/kmm_krealloc.c
*
* Copyright (C) 2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
@@ -40,7 +40,7 @@
#include <nuttx/config.h>
#include <nuttx/kmalloc.h>
#ifdef CONFIG_NUTTX_KERNEL
#if defined(CONFIG_NUTTX_KERNEL) && defined(__KERNEL__)
/* This logic is all tentatively and, hopefully, will grow in usability.
* For now, the kernel-mode build uses the memory manager that is
@@ -108,4 +108,4 @@ FAR void *krealloc(FAR void *oldmem, size_t size)
return KREALLOC(oldmem, size);
}
#endif /* CONFIG_NUTTX_KERNEL */
#endif /* CONFIG_NUTTX_KERNEL && __KERNEL__ */
+3 -3
View File
@@ -1,5 +1,5 @@
/************************************************************************
* sched/kmm_kzalloc.c
* mm/kmm_kzalloc.c
*
* Copyright (C) 2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
@@ -40,7 +40,7 @@
#include <nuttx/config.h>
#include <nuttx/kmalloc.h>
#ifdef CONFIG_NUTTX_KERNEL
#if defined(CONFIG_NUTTX_KERNEL) && defined(__KERNEL__)
/* This logic is all tentatively and, hopefully, will grow in usability.
* For now, the kernel-mode build uses the memory manager that is
@@ -107,4 +107,4 @@ FAR void *kzalloc(size_t size)
return KZALLOC(size);
}
#endif /* CONFIG_NUTTX_KERNEL */
#endif /* CONFIG_NUTTX_KERNEL && __KERNEL__ */
+3 -3
View File
@@ -1,5 +1,5 @@
/************************************************************************
* sched/kmm_semaphore.c
* mm/kmm_semaphore.c
*
* Copyright (C) 2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
@@ -40,7 +40,7 @@
#include <nuttx/config.h>
#include <nuttx/kmalloc.h>
#ifdef CONFIG_NUTTX_KERNEL
#if defined(CONFIG_NUTTX_KERNEL) && defined(__KERNEL__)
/* This logic is all tentatively and, hopefully, will grow in usability.
* For now, the kernel-mode build uses the memory manager that is
@@ -137,4 +137,4 @@ void kmm_givesemaphore(void)
KGIVESEMAPHORE();
}
#endif /* CONFIG_NUTTX_KERNEL */
#endif /* CONFIG_NUTTX_KERNEL && __KERNEL__ */
+11 -64
View File
@@ -65,7 +65,11 @@ struct mm_heap_s g_mmheap;
****************************************************************************/
/****************************************************************************
* Name: _mm_addregion
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: mm_addregion
*
* Description:
* This function adds a region of contiguous memory to the selected heap.
@@ -82,8 +86,8 @@ struct mm_heap_s g_mmheap;
*
****************************************************************************/
static inline void _mm_addregion(FAR struct mm_heap_s *heap,
FAR void *heapstart, size_t heapsize)
void mm_addregion(FAR struct mm_heap_s *heap, FAR void *heapstart,
size_t heapsize)
{
FAR struct mm_freenode_s *node;
uintptr_t heapbase;
@@ -149,7 +153,7 @@ static inline void _mm_addregion(FAR struct mm_heap_s *heap,
}
/****************************************************************************
* Name: _mm_initialize
* Name: mm_initialize
*
* Description:
* Initialize the selected heap data structures, providing the initial
@@ -167,8 +171,8 @@ static inline void _mm_addregion(FAR struct mm_heap_s *heap,
*
****************************************************************************/
static inline void _mm_initialize(FAR struct mm_heap_s *heap,
FAR void *heapstart, size_t heapsize)
void mm_initialize(FAR struct mm_heap_s *heap, FAR void *heapstart,
size_t heapsize)
{
int i;
@@ -209,62 +213,5 @@ static inline void _mm_initialize(FAR struct mm_heap_s *heap,
/* Add the initial region of memory to the heap */
_mm_addregion(heap, heapstart, heapsize);
mm_addregion(heap, heapstart, heapsize);
}
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: mm_initialize
*
* Description:
* This this function is called during initialization to initialize the
* user heap.
*
* Parameters:
* heapstart - Start of the initial heap region
* heapsize - Size of the initial heap region
*
* Return Value:
* None
*
* Assumptions:
*
****************************************************************************/
#if !defined(CONFIG_NUTTX_KERNEL) || !defined(__KERNEL__)
void mm_initialize(FAR void *heapstart, size_t heapsize)
{
_mm_initialize(&g_mmheap, heapstart, heapsize);
}
#endif
/****************************************************************************
* Name: mm_addregion
*
* Description:
* This function adds a region of contiguous memory to the user heap.
*
* Parameters:
* heapstart - Start of the heap region
* heapsize - Size of the heap region
*
* Return Value:
* None
*
* Assumptions:
*
****************************************************************************/
#if !defined(CONFIG_NUTTX_KERNEL) || !defined(__KERNEL__)
void mm_addregion(FAR void *heapstart, size_t heapsize)
{
_mm_addregion(&g_mmheap, heapstart, heapsize);
}
#endif
-7
View File
@@ -181,9 +181,6 @@ endif
IRQ_SRCS = irq_initialize.c irq_attach.c irq_dispatch.c irq_unexpectedisr.c
KMM_SRCS = kmm_initialize.c kmm_addregion.c kmm_semaphore.c
KMM_SRCS = kmm_kmalloc.c kmm_kzalloc.c kmm_krealloc.c kmm_kfree.c
CSRCS = $(MISC_SRCS) $(TSK_SRCS) $(GRP_SRCS) $(SCHED_SRCS) $(WDOG_SRCS)
CSRCS += $(TIME_SRCS) $(SEM_SRCS) $(TIMER_SRCS) $(PGFILL_SRCS)
CSRCS += $(IRQ_SRCS)
@@ -208,10 +205,6 @@ ifneq ($(CONFIG_DISABLE_ENVIRON),y)
CSRCS += $(ENV_SRCS)
endif
ifeq ($(CONFIG_NUTTX_KERNEL),y)
CSRCS += $(KMM_SRCS)
endif
COBJS = $(CSRCS:.c=$(OBJEXT))
SRCS = $(ASRCS) $(CSRCS)
+6
View File
@@ -195,6 +195,12 @@ int os_bringup(void)
/* Once the operating system has been initialized, the system must be
* started by spawning the user init thread of execution. This is the
* first user-mode thead.
*
* In a kernel build (CONFIG_NUTTX_KERNEL), it is expected that this user
* initialization function will:
*
* - Call mm_initialized() to initialize the user memmory manager, and
* - Is so configured, call work_usrstart() to start the user work thread.
*/
svdbg("Starting init thread\n");