summaryrefslogtreecommitdiff
path: root/nuttx/arch/arm/src/lpc313x
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2009-12-29 16:04:14 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2009-12-29 16:04:14 +0000
commit8011552bd03acb1cebd794617478775a88dc46d3 (patch)
tree98798b08bc14b1d5e7f2b7c0170d565f6f5cf0b5 /nuttx/arch/arm/src/lpc313x
parent51846872434e33843cea4a86e7d551deefe17118 (diff)
downloadpx4-nuttx-8011552bd03acb1cebd794617478775a88dc46d3.tar.gz
px4-nuttx-8011552bd03acb1cebd794617478775a88dc46d3.tar.bz2
px4-nuttx-8011552bd03acb1cebd794617478775a88dc46d3.zip
Add logic to add external memory to heap
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@2455 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/arch/arm/src/lpc313x')
-rwxr-xr-xnuttx/arch/arm/src/lpc313x/lpc313x_allocateheap.c82
1 files changed, 82 insertions, 0 deletions
diff --git a/nuttx/arch/arm/src/lpc313x/lpc313x_allocateheap.c b/nuttx/arch/arm/src/lpc313x/lpc313x_allocateheap.c
index cd3ccdc0d..ec0d924b8 100755
--- a/nuttx/arch/arm/src/lpc313x/lpc313x_allocateheap.c
+++ b/nuttx/arch/arm/src/lpc313x/lpc313x_allocateheap.c
@@ -53,6 +53,62 @@
* Pre-processor Definitions
************************************************************************/
+/* Configuration ********************************************************/
+
+/* Some sanity checking. If external memory regions are defined, verify
+ * that CONFIG_MM_REGIONS is set to match, exactly, the number of external
+ * memory regions that we have been asked to add to the heap.
+ */
+
+#if defined(CONFIG_LPC313X_EXTSRAM0) && defined(CONFIG_LPC313X_EXTSRAM0HEAP)
+# if defined(CONFIG_LPC313X_EXTSRAM1) && defined(CONFIG_LPC313X_EXTSRAM1HEAP)
+# if defined(CONFIG_LPC313X_EXTSDRAM) && defined(CONFIG_LPC313X_EXTSDRAMHEAP)
+# /* SRAM+EXTSRAM0+EXTSRAM1+EXTSDRAM */
+# define LPC313X_NEXT_REGIONS 4
+# else
+# /* SRAM+EXTSRAM0+EXTSRAM1 */
+# define LPC313X_NEXT_REGIONS 3
+# endif
+# elif defined(CONFIG_LPC313X_EXTSDRAM) && defined(CONFIG_LPC313X_EXTSDRAMHEAP)
+# /* SRAM+EXTSRAM0+EXTSDRAM */
+# define LPC313X_NEXT_REGIONS 3
+# else
+# /* SRAM+EXTSRAM0 */
+# define LPC313X_NEXT_REGIONS 2
+# endif
+#elif defined(CONFIG_LPC313X_EXTSRAM1) && defined(CONFIG_LPC313X_EXTSRAM1HEAP)
+# if defined(CONFIG_LPC313X_EXTSDRAM) && defined(CONFIG_LPC313X_EXTSDRAMHEAP)
+# /* SRAM+EXTSRAM1+EXTSDRAM */
+# define LPC313X_NEXT_REGIONS 3
+# else
+# /* SRAM+EXTSRAM1 */
+# define LPC313X_NEXT_REGIONS 2
+# endif
+#elif defined(CONFIG_LPC313X_EXTSDRAM) && defined(CONFIG_LPC313X_EXTSDRAMHEAP)
+# /* SRAM+EXTSDRAM */
+# define LPC313X_NEXT_REGIONS 2
+#else
+# /* SRAM */
+# define LPC313X_NEXT_REGIONS 1
+#endif
+
+#if CONFIG_MM_REGIONS != LPC313X_NEXT_REGIONS
+# if CONFIG_MM_REGIONS < LPC313X_NEXT_REGIONS
+# error "CONFIG_MM_REGIONS is large enough for the selected memory regions"
+# else
+# error "CONFIG_MM_REGIONS is too large for the selected memory regions"
+# endif
+# if defined(CONFIG_LPC313X_EXTSRAM0) && defined(CONFIG_LPC313X_EXTSRAM0HEAP)
+# error "External SRAM0 is selected for heap"
+# endif
+# if defined(CONFIG_LPC313X_EXTSRAM1) && defined(CONFIG_LPC313X_EXTSRAM1HEAP)
+# error "External SRAM1 is selected for heap"
+# endif
+# if defined(CONFIG_LPC313X_EXTSDRAM) && defined(CONFIG_LPC313X_EXTSDRAMHEAP)
+# error "External SRAM1 is selected for heap"
+# endif
+#endif
+
/************************************************************************
* Private Data
************************************************************************/
@@ -91,3 +147,29 @@ void up_allocate_heap(FAR void **heap_start, size_t *heap_size)
*heap_start = (FAR void*)g_heapbase;
*heap_size = (LPC313X_SRAM_VADDR + CONFIG_DRAM_SIZE) - g_heapbase;
}
+
+/************************************************************************
+ * Name: up_addregion
+ *
+ * Description:
+ * Memory may be added in non-contiguous chunks. Additional chunks are
+ * added by calling this function.
+ *
+ ************************************************************************/
+
+#if CONFIG_MM_REGIONS > 1
+void up_addregion(void)
+{
+#if defined(CONFIG_LPC313X_EXTSRAM0) && defined(CONFIG_LPC313X_EXTSRAM0HEAP)
+ mm_addregion((FAR void*)LPC313X_EXTSRAM0_VSECTION, CONFIG_LPC313X_EXTSRAM0SIZE);
+#endif
+
+#if defined(CONFIG_LPC313X_EXTSRAM1) && defined(CONFIG_LPC313X_EXTSRAM1HEAP)
+ mm_addregion((FAR void*)LPC313X_EXTSRAM1_VSECTION, CONFIG_LPC313X_EXTSRAM1SIZE);
+#endif
+
+#if defined(CONFIG_LPC313X_EXTSDRAM) && defined(CONFIG_LPC313X_EXTSDRAMHEAP)
+ mm_addregion((FAR void*)LPC313X_EXTSDRAM_VSECTION, CONFIG_LPC313X_EXTSDRAMSIZE);
+#endif
+}
+#endif