2 # $NetBSD: walnut-mkimg.sh,v 1.1.8.3 2004/09/21 13:15:01 skrll Exp $
4 # Convert a kernel to an tftp image loadable by the IBM PowerPC OpenBIOS.
6 magic
=5394511 # IBM OpenBIOS magic number 0x0052504f
9 echo usage
: $0 kernel image
1>&2
19 start
=`${OBJDUMP} -f ${kernel} | awk '/start address/ { print $NF }'`
20 start
=`printf "%d" $start`
21 ${OBJCOPY} -O binary ${kernel} ${kernel}.bin.$$
22 size
=`/bin/ls -l ${kernel}.bin.$$ | awk '{ printf "%d", ( $5 + 511 ) / 512 }'`
24 printf "%d\n%d\n%d\n0\n%d\n0\n0\n0\n" $magic $start $size $start |
26 printf "%c", int($0 / 256 / 256 / 256) % 256;
27 printf "%c", int($0 / 256 / 256 ) % 256;
28 printf "%c", int($0 / 256 ) % 256;
29 printf "%c", int($0 ) % 256;
33 cat ${kernel}.bin.$$
>> ${output}
35 rm -f ${kernel}.bin.$$