incubator-nuttx/mm
Gregory Nutt f9b9875952 Various Kconfig files still have references to CONFIG_ variables. Some in harmless comments, some in config definionts which is not harmless. All removed 2013-04-25 15:52:00 -06:00
..
bin Directories where the same source files are used to build different objects need to keep those objects in separate directories; LPC17xx updates from Chris Taglia 2013-03-19 23:40:07 +00:00
kbin Directories where the same source files are used to build different objects need to keep those objects in separate directories; LPC17xx updates from Chris Taglia 2013-03-19 23:40:07 +00:00
ubin Directories where the same source files are used to build different objects need to keep those objects in separate directories; LPC17xx updates from Chris Taglia 2013-03-19 23:40:07 +00:00
.gitignore Mostly updates and corrections to .gitignore files 2013-04-04 15:39:50 -06:00
Kconfig Various Kconfig files still have references to CONFIG_ variables. Some in harmless comments, some in config definionts which is not harmless. All removed 2013-04-25 15:52:00 -06:00
Makefile Directories where the same source files are used to build different objects need to keep those objects in separate directories; LPC17xx updates from Chris Taglia 2013-03-19 23:40:07 +00:00
README.txt up_addregion should use kmm_addregion; move garbage kmm*.c file to mm/. for now 2013-03-08 22:01:50 +00:00
mm_addfreechunk.c Add support for multiple heaps 2013-03-08 20:36:18 +00:00
mm_calloc.c Add support for multiple heaps 2013-03-08 20:36:18 +00:00
mm_free.c Add support for multiple heaps 2013-03-08 20:36:18 +00:00
mm_gran.h Fix MMC/SD support for Wildfire board; Granule allocator can now be used from intrrupt handler 2012-09-12 15:18:56 +00:00
mm_granalloc.c Misc fixes and optimizations for the granule allocator 2012-09-12 17:55:03 +00:00
mm_grancritical.c New file missed in last check-in 2012-09-12 15:21:26 +00:00
mm_granfree.c Misc fixes and optimizations for the granule allocator 2012-09-12 17:55:03 +00:00
mm_graninit.c Fix some early z180 compile errors 2012-12-11 22:51:20 +00:00
mm_initialize.c More changes for a kernel-mode allocator (more to be done) 2013-03-09 21:12:20 +00:00
mm_kernel.c AT91SAM3 now supports kernel-mode heap; SAM3U-EK knsh configuration converted to use kconfig-frontends tool 2013-03-10 19:31:10 +00:00
mm_mallinfo.c Add support for multiple heaps 2013-03-08 20:36:18 +00:00
mm_malloc.c Need to include debug.h or compile fails when memory management debug is enabled 2013-04-18 11:40:38 -06:00
mm_memalign.c Add support for multiple heaps 2013-03-08 20:36:18 +00:00
mm_realloc.c Fix a bug introduced in the last check-in 2013-03-11 00:04:50 +00:00
mm_sem.c Add support for multiple heaps 2013-03-08 20:36:18 +00:00
mm_shrinkchunk.c Add support for multiple heaps 2013-03-08 20:36:18 +00:00
mm_size2ndx.c Add support for multiple heaps 2013-03-08 20:36:18 +00:00
mm_user.c Fixe to kernel build and syscalls. 2013-03-13 17:32:37 +00:00
mm_zalloc.c Add support for multiple heaps 2013-03-08 20:36:18 +00:00

README.txt

mm/README.txt
=============

This directory contains the NuttX memory management logic.  This include:

1) The standard memory management functions as prototyped in stdlib.h as
   specified in the  Base definitions volume of IEEE Std 1003.1-2001.  This
   include the files:

   o Standard Interfaces: mm_malloc.c, mm_calloc.c, mm_realloc.c,
       mm_memalign.c, mm_free.c
   o Less-Standard Interfaces: mm_zalloc.c, mm_mallinfo.c
   o Internal Implementation: mm_initialize.c mm_sem.c  mm_addfreechunk.c
       mm_size2ndx.c mm_shrinkchunk.c, mm_internal.h
   o Build and Configuration files: Kconfig, Makefile

   Memory Models:

   o Small Memory Model.  If the MCU supports only 16-bit data addressing
     then the small memory model is automatically used.  The maximum size
     of the heap is then 64K.  The small memory model can also be forced
     MCUs with wider addressing by defining CONFIG_SMALL_MEMORY in the
     NuttX configuration file.
   o Large Memory Model.  Otherwise, the allocator uses a model that
     supports a heap of up to 4G.

   This implementation uses a variable length allocator with the following
   properties:

   o Overhead:  Either 8- or 4-bytes per allocation for large and small
     models, respectively.
   o Alignment:  All allocations are aligned to 8- or 4-bytes for large
     and small models, respectively.

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.

   The granule allocator interfaces are defined in nuttx/include/nuttx/gran.h.
   The granule allocator consists of these files in this directory:

     mm_gran.h, mm_granalloc.c, mm_grancritical.c, mm_granfree.c
     mm_graninit.c

   The granule allocator is not used anywhere within the base NuttX code
   as of this writing.  The intent of the granule allocator is to provide
   a tool to support platform-specific management of aligned DMA memory.

   NOTE: Because each granule may be aligned and each allocation is in
   units of the granule size, selection of the granule size is important:
   Larger granules will give better performance and less overhead but more
   losses of memory due to quantization waste.  Additional memory waste
   can occur from alignment;  Of course, heap alignment should no be
   used unless (a) you are using the granule allocator to manage DMA memory
   and (b) your hardware has specific memory alignment requirements.

   The current implementation also restricts the maximum allocation size
   to 32 granules.  That restriction could be eliminated with some
   additional coding effort, but currently requires larger granule
   sizes for larger allocations.

  Geneneral Usage Example.  This is an example using the GCC section
  attribute to position a DMA heap in memory (logic in the linker script
  would assign the section .dmaheap to the DMA memory.
 
    FAR uint32_t g_dmaheap[DMAHEAP_SIZE] __attribute__((section(.dmaheap)));
 
  The heap is created by calling gran_initialize.  Here the granual size
  is set to 64 bytes and the alignment to 16 bytes:
 
    GRAN_HANDLE handle = gran_initialize(g_dmaheap, DMAHEAP_SIZE, 6, 4);
 
  Then the GRAN_HANDLE can be used to allocate memory (There is no
  GRAN_HANDLE if CONFIG_GRAN_SINGLE=y):
 
    FAR uint8_t *dma_memory = (FAR uint8_t *)gran_alloc(handle, 47);
 
  The actual memory allocates will be 64 byte (wasting 17 bytes) and
  will be aligned at least to (1 << log2align).