Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/cats/conf Initial mechanism for building a working ...



details:   https://anonhg.NetBSD.org/src/rev/1eadc4721322
branches:  trunk
changeset: 521470:1eadc4721322
user:      chris <chris%NetBSD.org@localhost>
date:      Thu Jan 31 10:37:41 2002 +0000

description:
Initial mechanism for building a working cats kernel with ELF compiler.  Note that the shell script needs work, currently it assumes TOOLDIR is valid, if it's not it should probably just try using 
objdump and size.  So some work still to do, but you can cross compile cats kernels now.

diffstat:

 sys/arch/cats/conf/Makefile.cats.inc |  11 ++++++-
 sys/arch/cats/conf/elf2aout.sh       |  52 ++++++++++++++++++++++++++++++++++++
 2 files changed, 62 insertions(+), 1 deletions(-)

diffs (74 lines):

diff -r 12ce098fcb74 -r 1eadc4721322 sys/arch/cats/conf/Makefile.cats.inc
--- a/sys/arch/cats/conf/Makefile.cats.inc      Thu Jan 31 10:26:42 2002 +0000
+++ b/sys/arch/cats/conf/Makefile.cats.inc      Thu Jan 31 10:37:41 2002 +0000
@@ -1,4 +1,13 @@
-#      $NetBSD: Makefile.cats.inc,v 1.2 2002/01/31 09:53:34 chris Exp $
+#      $NetBSD: Makefile.cats.inc,v 1.3 2002/01/31 10:37:41 chris Exp $
 
 GENASSYM_EXTRAS+=      ${ARM}/footbridge/genassym.cf
 LOOSE_PROTOTYPES=      NO
+
+.if (${OBJECT_FMT} == "ELF")
+# Under ELF we need to do a whole load of stuff extra to get that kernel.
+
+LINKADDRESS=0xF0000020
+
+SYSTEM_LD_TAIL= \
+       $S/arch/${MACHINE}/conf/elf2aout.sh
+.endif 
diff -r 12ce098fcb74 -r 1eadc4721322 sys/arch/cats/conf/elf2aout.sh
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/cats/conf/elf2aout.sh    Thu Jan 31 10:37:41 2002 +0000
@@ -0,0 +1,52 @@
+#!/bin/sh
+# $NetBSD: elf2aout.sh,v 1.1 2002/01/31 10:37:41 chris Exp $
+# Shell script to convert a cats ELF kernel into a bootable a.out kernel by
+# changing the header block on the kernel, and shuffling bits around in the
+# file.  Care has to be taken with the sections as they need to be page
+# aligned.
+
+AWKPROG='\
+function r(v) { return sprintf("%d", ((v + 4095) / 4096)) * 4096 } \
+function x(v) { printf "%c%c%c\0", v, v / 256, v / 65536 } \
+{ \
+        printf "\0\217\01\013"; \
+        x(r($1)); \
+        x(r($2 + 32768 - (r($1) - $1))); \
+        x($3); \
+        printf "\0\0\0\0\040\0\0\360\0\0\0\0\0\0\0\0" \
+}'
+
+OBJCOPY=$TOOLDIR/bin/arm--netbsdelf-objcopy
+SIZE=$TOOLDIR/bin/arm--netbsdelf-size
+
+mv -f netbsd netbsd.elf
+${OBJCOPY} -O binary -j .text netbsd.elf netbsd.text
+${OBJCOPY} -O binary -j .data netbsd.elf netbsd.data
+
+TEXT=`${SIZE} netbsd.elf | tail +2 | awk '
+function r(v) { return sprintf("%d", ((v + 4095) / 4096)) * 4096 }
+{print r($1)}'`
+echo TEXT = $TEXT
+
+TPAD=`${SIZE} netbsd.elf | tail +2 | awk '
+       function r(v) { return sprintf("%d", ((v + 4095) / 4096)) * 4096 }
+       {print r($1) - $1}'`
+       echo TPAD = $TPAD
+
+DATA=`${SIZE} netbsd.elf | tail +2 | awk '
+function r(v) { return sprintf("%d", ((v + 4095) / 4096)) * 4096 }
+{print r($2 + 32768 - (r($1) - $1))}'`
+echo DATA = $DATA
+
+DPAD=`${SIZE} netbsd.elf | tail +2 | awk '
+function r(v) { return sprintf("%d", ((v + 4095) / 4096)) * 4096 }
+{print r($2 + 32768 - (r($1) - $1)) - ($2 + 32768 - (r($1) - $1))}'`
+echo DPAD = $DPAD
+
+(${SIZE} netbsd.elf | tail +2 | awk "${AWKPROG}" ; \
+  cat netbsd.text ; dd if=/dev/zero bs=32k count=1; cat netbsd.data; dd if=/dev/zero bs=$DPAD count=1 \
+) > netbsd.aout
+
+cp netbsd.aout netbsd
+
+exit 0



Home | Main Index | Thread Index | Old Index