summaryrefslogtreecommitdiff
path: root/package/etrax-tools/src/e100boot/cbl/free_size
diff options
context:
space:
mode:
Diffstat (limited to 'package/etrax-tools/src/e100boot/cbl/free_size')
-rwxr-xr-xpackage/etrax-tools/src/e100boot/cbl/free_size42
1 files changed, 42 insertions, 0 deletions
diff --git a/package/etrax-tools/src/e100boot/cbl/free_size b/package/etrax-tools/src/e100boot/cbl/free_size
new file mode 100755
index 000000000..73e1365e4
--- /dev/null
+++ b/package/etrax-tools/src/e100boot/cbl/free_size
@@ -0,0 +1,42 @@
+#!/bin/sh
+#
+# Calculates the size left in ETRAX cache when bootloader is loaded.
+#
+
+BOOT_FILE=`dirname $0`/net/net.out
+HEADER_FILE=`dirname $0`/src/e100boot.h
+
+for FILE in $BOOT_FILE $HEADER_FILE; do
+ if [ ! -f $FILE ]; then
+ echo "Could not find the file \"$FILE\"!"
+ exit 1
+ fi
+done
+
+# The cache size is given in hex
+CACHE_SIZE=2000
+
+BSS_SIZE=`nm-cris $BOOT_FILE | grep Ebss | cut -d ' ' -f 1 | tr a-f A-F`
+
+TEXT_SIZE=`nm-cris $BOOT_FILE | grep Stext | cut -d ' ' -f 1 | tr a-f A-F`
+
+IO_BUF_END=`grep IO_BUF_END $HEADER_FILE | awk '{ print $3 }' | \
+ cut -d x -f 2 | tr a-f A-F`
+
+IO_BUF_START=`grep IO_BUF_START $HEADER_FILE | awk '{ print $3 }' | \
+ cut -d x -f 2 | tr a-f A-F`
+
+FREE_SIZE=`echo "ibase=16 ; \
+ $CACHE_SIZE - \
+ ($BSS_SIZE - $TEXT_SIZE + $IO_BUF_END - $IO_BUF_START)" | \
+ bc`
+
+echo "Free cache size when cbl is loaded will be:"
+echo -e "\t$FREE_SIZE bytes - size of stack"
+
+if [ $FREE_SIZE -lt 0 ]; then
+ echo "Bootloader is too large! You will have to do some optimizing..."
+ exit 1
+fi
+
+exit 0