summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2008-02-06 19:04:36 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2008-02-06 19:04:36 +0000
commit0b541307c5971c46f955fe047e3ba8ca9a4c1b88 (patch)
tree6d829c427507c272ad102fc4bcdd5607ce6eb7de
parenteff022ae2b6d80ed7d0779a52252f9e940e98635 (diff)
downloadnuttx-0b541307c5971c46f955fe047e3ba8ca9a4c1b88.tar.gz
nuttx-0b541307c5971c46f955fe047e3ba8ca9a4c1b88.tar.bz2
nuttx-0b541307c5971c46f955fe047e3ba8ca9a4c1b88.zip
Fixes bug 1887170
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@641 42af7a65-404d-4744-a932-0658087f49c3
-rw-r--r--nuttx/arch/z80/src/Makefile27
-rwxr-xr-xnuttx/arch/z80/src/mkhpbase.sh109
2 files changed, 112 insertions, 24 deletions
diff --git a/nuttx/arch/z80/src/Makefile b/nuttx/arch/z80/src/Makefile
index 9f5e752d4..c5f77d180 100644
--- a/nuttx/arch/z80/src/Makefile
+++ b/nuttx/arch/z80/src/Makefile
@@ -83,30 +83,9 @@ VPATH = chip:common
LIBGCC = ${shell $(CC) -print-libgcc-file-name}
-# Supports dynamic sizing of HEAP. This adds up the size of each memory area.
-# This does not account for the alignment of the _CODE area to 0x0100 (hence
-# the fudge factor 196 is added).
-
-HEAP_BASE = ${shell \
- if [ -e pass1.map ]; then \
- list=`cat pass1.map | grep "SIZE" | sed -e "s/\t//g" | cut -d' ' -f2`; \
- unset result; \
- first=yes; \
- for size in $${list}; do \
- if [ "$${size}" != "0000" ]; then \
- if [ -z "$$first" ]; then \
- result="$${result} + 0x$${size}"; \
- else \
- result="(0x$${size}"; \
- unset first; \
- fi; \
- fi; \
- done; \
- echo "$${result} + 196)"; \
- else \
- echo "(UP_HEAP1_END - 8192)"; \
- fi; \
- }
+# Supports dynamic sizing of HEAP.
+#
+HEAP_BASE = ${shell ./mkhpbase.sh}
############################################################################
# Targets
diff --git a/nuttx/arch/z80/src/mkhpbase.sh b/nuttx/arch/z80/src/mkhpbase.sh
new file mode 100755
index 000000000..a2c9a64a8
--- /dev/null
+++ b/nuttx/arch/z80/src/mkhpbase.sh
@@ -0,0 +1,109 @@
+#/bin/sh
+############################################################################
+# arch/z80/src/mkhpbase.sh
+#
+# Copyright (C) 2007, 2008 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.
+#
+############################################################################
+#
+# This script supports dynamic sizing of HEAP when building with the SDCC
+# toolchain. This script adds up the size of each section of the program.
+# This does not account for the alignment of the _CODE area to 0x0100 (hence
+# the fudge factor 196 is added).
+#
+# -- There must be a better way! ---
+#
+#set -x
+
+MAPFILE=pass1.map
+
+# Verify that pass1.map exists
+
+if [ -e ${MAPFILE} ]; then
+
+ # The map file exists, get a list of the sizes of each section
+ # This works for SDCC 2.7.0
+
+ list=`cat ${MAPFILE} | grep "bytes" | sed -e 's/[ \t][ \t]*/ /g' | cut -d' ' -f3`
+
+ # If this is SDCC version 2.6.0, then the list will be empty
+
+ if [ -z "${list}" ]; then
+
+ # This works for SDCC 2.6.0
+
+ list=`cat ${MAPFILE} | grep "SIZE" | sed -e 's/[ \t][ \t]*/ /g' | cut -d' ' -f3`
+ fi
+
+ # Did we successfully create the list of section sizes?
+
+ if [ ! -z "${list}" ]; then
+ unset result
+ first=yes
+
+ # Examine each size in the list
+
+ for size in ${list}; do
+
+ # Skip over zero-length sizes
+
+ if [ "${size}" != "0000" ]; then
+
+ # Each hex size must be prefixed with "0x". The
+ # First size must also include a left parenthesis
+
+ if [ -z "$first" ]; then
+ result="${result} + 0x${size}"
+ else
+ result="(0x${size}"
+ unset first
+ fi
+ fi
+ done
+
+ # Add a fudge factor to guarantee no overlap between the code and
+ # the heap and close the expression with a left parenthesis
+
+ echo "${result} + 196)"
+ else
+
+ # We could not parse the map file. Try to generate some meaningful error
+
+ echo "#\"Makefile: Could not parse map file\""
+ exit 1
+ fi
+else
+ # pass1.map does not yet exist. In this case, just output a valid, default heap size
+
+ echo "(UP_HEAP1_END - 8192)"
+fi
+
+