Expand PMF_FN_* macros.
[netbsd-mini2440.git] / sys / arch / evbppc / compile / walnut-mkimg.sh
blob785ac62e16e0710d5836392ca156894dac9491c5
1 #!/bin/sh
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
8 if [ $# -ne 2 ] ; then
9 echo usage: $0 kernel image 1>&2
10 exit 1
13 kernel=$1; shift
14 output=$1; shift
16 : ${OBJDUMP=objdump}
17 : ${OBJCOPY=objcopy}
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 |
25 awk '{
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;
31 ' > ${output}
33 cat ${kernel}.bin.$$ >> ${output}
35 rm -f ${kernel}.bin.$$
36 exit