summaryrefslogtreecommitdiffstats
path: root/tools/cpu/generic/size_rtems.in
blob: 6ab8f04d9274be9c9d01f9e4efdf910c95254ae5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
#!KSHELL -p
#
#  size_rtems
#
#  This script gathers information related to the size of RTEMS
#  using the GNU "size" command.
#
#  This script operates by summing up the sizes of the various
#  object files which constitute a particular configuration of
#  RTEMS.  This size information is gathered for placement in the
#  brochure flyers and supplement manuals.
#
#  NOTE: The concept of the minimum executive size is buried in this script.
#
#  COPYRIGHT (c) 1989-1997.
#  On-Line Applications Research Corporation (OAR).
#  Copyright assigned to U.S. Government, 1994.
#
#  The license and distribution terms for this file may be
#  found in the file LICENSE in this distribution or at
#  http://www.OARcorp.com/rtems/license.html.
#
#  $Id$
#

target=@target@
program_prefix=@program_prefix@

gnusize=${program_prefix}size

# check usage
if [ $# -ne 1 ] ; then
  echo usage ${0}: bsp
  exit 1
fi

cpu=`echo $target | sed -e 's/-.*//'`
case $cpu in 
  hppa1.1) rtems_cpu=hppa1_1 ;;
  powerpc) rtems_cpu=ppc ;;
  *)       rtems_cpu=$cpu ;;
esac
bsp=$1

echo
echo Generating sizes for CPU ${cpu} on board ${bsp}
echo

#
#  KLUDGE to figure out at runtime how to echo a line without a
#  newline.
#
count=`echo "\\c" | wc -c`
if [ ${count} -ne 0 ] ; then
  EARG="-n"
  EOL=""
else
  EARG=""
  EOL="\\c"
fi

if [ ! -d ${bsp} ] ; then
  echo "${bsp} does not exist ... is the current directory the build directory?"
  exit 1
fi

#DIRLIST -- so greps for DIRLIST will find this file
CPUOBJ=c/src/exec/score/cpu/${rtems_cpu}/o-${bsp}
COREOBJ=c/src/exec/score/src/o-${bsp}
RTEMSOBJ=c/src/exec/rtems/src/o-${bsp}
SAPIOBJ=c/src/exec/sapi/src/o-${bsp}
OPTOBJ=${bsp}/lib

MANLIST=" \
${RTEMSOBJ}/clock.o \
${RTEMSOBJ}/dpmem.o \
${RTEMSOBJ}/event.o \
${RTEMSOBJ}/intr.o \
${RTEMSOBJ}/msg.o \
${RTEMSOBJ}/part.o \
${RTEMSOBJ}/ratemon.o \
${RTEMSOBJ}/region.o \
${RTEMSOBJ}/sem.o \
${RTEMSOBJ}/signal.o \
${RTEMSOBJ}/tasks.o \
${RTEMSOBJ}/timer.o \
${SAPIOBJ}/debug.o \
${SAPIOBJ}/extension.o \
${SAPIOBJ}/fatal.o \
${SAPIOBJ}/init.o \
${SAPIOBJ}/io.o \
${SAPIOBJ}/rtemsapi.o \
"
MPLIST="\
${RTEMSOBJ}/mp.o ${RTEMSOBJ}/eventmp.o \
${COREOBJ}/mpci.o ${RTEMSOBJ}/msgmp.o ${COREOBJ}/objectmp.o \
${RTEMSOBJ}/partmp.o ${RTEMSOBJ}/regionmp.o ${RTEMSOBJ}/semmp.o \
${RTEMSOBJ}/signalmp.o ${RTEMSOBJ}/taskmp.o ${COREOBJ}/threadmp.o \
"

OPTMANLIST="\
${OPTOBJ}/no-dpmem.rel \
${OPTOBJ}/no-event.rel \
${OPTOBJ}/no-mp.rel \
${OPTOBJ}/no-msg.rel \
${OPTOBJ}/no-part.rel \
${OPTOBJ}/no-region.rel \
${OPTOBJ}/no-rtmon.rel \
${OPTOBJ}/no-sem.rel \
${OPTOBJ}/no-signal.rel \
${OPTOBJ}/no-timer.rel \
"
REQMANLIST="\
${SAPIOBJ}/init.o \
${RTEMSOBJ}/tasks.o \
${RTEMSOBJ}/intr.o \
${SAPIOBJ}/fatal.o \
"
CORELIST=" \
${COREOBJ}/apiext.o ${COREOBJ}/chain.o \
${COREOBJ}/coremsg.o   ${COREOBJ}/coremutex.o ${COREOBJ}/coresem.o \
${COREOBJ}/heap.o  ${COREOBJ}/interr.o \
${COREOBJ}/isr.o \
${COREOBJ}/object.o \
${SAPIOBJ}/rtemsapi.o \
${COREOBJ}/thread.o ${COREOBJ}/threadq.o ${COREOBJ}/tod.o \
${COREOBJ}/userext.o \
${COREOBJ}/watchdog.o ${COREOBJ}/wkspace.o \
"

CPULIST="\
${CPUOBJ}/rtems-cpu.rel \
"

# check directories
for i in ${EXECOBJ} ${CPUOBJ} ${OPTOBJ}
do
  if [ ! -d ${i} ] ; then
    echo "${i} does not exist ... is RTEMS compiled and installed?"
    exit 1
  fi
done

for i in ${MANLIST} ${MPLIST} ${OPTMANLIST} ${REQMANLIST} ${CORELIST} ${CPULIST}
do
  if [ ! -r ${i} ] ; then
    echo ${i} does not exist ... is RTEMS compiled and installed?
    exit 1
  fi
done

# "rips" a line of gsize's output and prints size, data, bss
parse_size()
{
  echo $1 $2 $3
}

# prepares a list of code, data, bss sizes for a directory
sizedir()
{
  ${gnusize} $* | sed -e '1,1d' |
    while read line
      do
        parse_size ${line}
      done
}

# adds a column from the output of sizedir
addsizes()
{
  cut -d' ' -f${1} | sed -e '2,$s/$/ + /' -e '$,$s/$/ p/' | dc
}

# calculates total size of a directory and prints report line
size_files()
{
  trap "rm -f /tmp/size.$$ ; exit 1"  2 3

    for file in $*
      do
        parse_size `${gnusize} $file | sed -e '/text/d'`
      done >/tmp/size.$$

  code=`cat /tmp/size.$$ | addsizes 1`
  data=`cat /tmp/size.$$ | addsizes 2`
  bss=` cat /tmp/size.$$ | addsizes 3`
  echo "${code}	${data}	${bss}"
  rm /tmp/size.$$
}

echo
echo "     RTEMS SIZE REPORT"
echo
echo   "          CODE	DATA	BSS"
echo   "          =================="
echo ${EARG} "MANAGERS: " ${EOL} ; size_files $MANLIST $MPLIST
echo ${EARG} "CORE    : " ${EOL} ; size_files $CORELIST $CPULIST
echo ${EARG} "CPU     : " ${EOL} ; size_files $CPULIST
echo ${EARG} "OVERALL : " ${EOL} ; size_files $CPULIST $CORELIST $MANLIST \
                                               $MPLIST
echo ${EARG} "MINIMUM : " ${EOL} ; size_files $CPULIST $CORELIST \
                                               $OPTMANLIST $REQMANLIST
echo

for file in $MANLIST
do
  base=`basename ${file}`
  echo ${EARG}  ""${base}	: " ${EOL} " ; size_files ${file}
done

echo ${EARG} "MP	 : " ${EOL} ; size_files $MPLIST

echo
for file in $OPTMANLIST
do
  base=`basename ${file}`
  echo ${EARG} "${base}	: " ${EOL} ; size_files ${file}
done

echo
exit 0