Home | History | Annotate | Line # | Download | only in compile
walnut-mkimg.sh revision 1.1.2.2
      1  1.1.2.2  thorpej #!/bin/sh
      2  1.1.2.2  thorpej # $NetBSD: walnut-mkimg.sh,v 1.1.2.2 2002/12/11 06:28:57 thorpej Exp $
      3  1.1.2.2  thorpej 
      4  1.1.2.2  thorpej # Convert a kernel to an tftp image loadable by the walnut IBM openbios.
      5  1.1.2.2  thorpej 
      6  1.1.2.2  thorpej if [ $# -ne 2 ] ; then
      7  1.1.2.2  thorpej 	echo usage: $0 kernel image 1>&2
      8  1.1.2.2  thorpej 	exit 1
      9  1.1.2.2  thorpej fi
     10  1.1.2.2  thorpej 
     11  1.1.2.2  thorpej kernel=$1; shift
     12  1.1.2.2  thorpej output=$1; shift
     13  1.1.2.2  thorpej 
     14  1.1.2.2  thorpej : ${OBJDUMP=objdump}
     15  1.1.2.2  thorpej : ${OBJCOPY=objcopy}
     16  1.1.2.2  thorpej 
     17  1.1.2.2  thorpej start=`${OBJDUMP} -f ${kernel} | awk '/start address/ { print $NF }'`
     18  1.1.2.2  thorpej start=`printf "%d" $start`
     19  1.1.2.2  thorpej ${OBJCOPY} -O binary ${kernel} ${kernel}.bin.$$
     20  1.1.2.2  thorpej size=`/bin/ls -l ${kernel}.bin.$$ | awk '{ printf "%d", ( $5 + 511 ) / 512 }'`
     21  1.1.2.2  thorpej 
     22  1.1.2.2  thorpej printf "%d\n%d\n0\n%d\n0\n0\n0\n" $start $size $start |
     23  1.1.2.2  thorpej     awk 'BEGIN { printf "\x00\x52\x50\x4f" }
     24  1.1.2.2  thorpej 	{
     25  1.1.2.2  thorpej 		printf "%c", $0 / 256 / 256 / 256 ;
     26  1.1.2.2  thorpej 		printf "%c", $0 / 256 / 256 ;
     27  1.1.2.2  thorpej 		printf "%c", $0 / 256 ;
     28  1.1.2.2  thorpej 		printf "%c", $0 ;
     29  1.1.2.2  thorpej 	}
     30  1.1.2.2  thorpej     ' > ${output}
     31  1.1.2.2  thorpej 
     32  1.1.2.2  thorpej cat ${kernel}.bin.$$ >> ${output}
     33  1.1.2.2  thorpej 
     34  1.1.2.2  thorpej rm -f ${kernel}.bin.$$
     35  1.1.2.2  thorpej exit
     36