add initial support for the crisarchitecture used on foxboards to openwrt
[openwrt.git] / target / linux / etrax-2.6 / image / e100boot / src / cbl / free_size
1 #!/bin/sh
2 #
3 # Calculates the size left in ETRAX cache when bootloader is loaded.
4 #
5
6 BOOT_FILE=`dirname $0`/net/net.out
7 HEADER_FILE=`dirname $0`/src/e100boot.h
8
9 for FILE in $BOOT_FILE $HEADER_FILE; do
10 if [ ! -f $FILE ]; then
11 echo "Could not find the file \"$FILE\"!"
12 exit 1
13 fi
14 done
15
16 # The cache size is given in hex
17 CACHE_SIZE=2000
18
19 BSS_SIZE=`nm-cris $BOOT_FILE | grep Ebss | cut -d ' ' -f 1 | tr a-f A-F`
20
21 TEXT_SIZE=`nm-cris $BOOT_FILE | grep Stext | cut -d ' ' -f 1 | tr a-f A-F`
22
23 IO_BUF_END=`grep IO_BUF_END $HEADER_FILE | awk '{ print $3 }' | \
24 cut -d x -f 2 | tr a-f A-F`
25
26 IO_BUF_START=`grep IO_BUF_START $HEADER_FILE | awk '{ print $3 }' | \
27 cut -d x -f 2 | tr a-f A-F`
28
29 FREE_SIZE=`echo "ibase=16 ; \
30 $CACHE_SIZE - \
31 ($BSS_SIZE - $TEXT_SIZE + $IO_BUF_END - $IO_BUF_START)" | \
32 bc`
33
34 echo "Free cache size when cbl is loaded will be:"
35 echo -e "\t$FREE_SIZE bytes - size of stack"
36
37 if [ $FREE_SIZE -lt 0 ]; then
38 echo "Bootloader is too large! You will have to do some optimizing..."
39 exit 1
40 fi
41
42 exit 0
This page took 0.040574 seconds and 5 git commands to generate.