PReP support for mkvmlinuz & kernel-image 2.6
Hello Jens,
Find here attached both a new mkvmlinuz and the diff to mkvmlinuz-6 for
adding PReP support.
This needs some modification of the powerpc kernel package to include
the needed file for this, which can be found at revision 811 on the
subversion repo.
That said, since there is a filename conflict between the openfirmware
and prep objs files, i moved them both into subdirectories, which means
that the future 2.6.7-3 will conflict with mkvmlinuz <= 6. We need to do
this the other way around too, or detect the openfirmware subdir in
mkvmlinuz. I am not really satisfied of this solution, please comment on
it.
The last complicated point is that the Makefile has a configurable
CONFIG_BOOT_LOAD, which is set to 0x00800000 by default, and i hardcode
this. A more interesting solution would be to make this configurable,
but i am not entirely sure that it has any real effect, given that the
simple script is not doing special cases on this, but then my knowledge
of simple booting is not all that big.
Anyway, Jens, can you review those two files, and prepare sample
packages, so that Joerg can test them on his RS6000 PReP box.
Joerg, can you test those kernels and mkvmlinuz for us, once Jens build
them, or build them yourself out of subversion ?
Friendly,
Sven Luther
#!/bin/sh
# usage information
usage() {
echo 'usage:'
echo ' -o <output> - path to output file for compressed kernel image'
echo ' -a <arch> - PowerPC sub-architecture'
echo ' -k <kernel> - path to kernel image file in ELF format'
echo ' -s <sysmap> - path to System.map file'
echo ' -i <initrd> - path to initrd image file in uncompressed format'
echo ' -d <objdir> - path to directory with additional object files'
echo ' -r <release> - kernel release number'
echo ' -z - assume the initrd image file is already compressed'
echo ' -q - quiet operation (do not indicate progress)'
echo ' -v - verbose operation (print commands)'
exit 0
}
# echo a shell command if desired, and execute it
do_cmd() {
test -z "$verbose" || echo $@; eval $@
return
}
# parse command line
while getopts o:k:s:i:d:r:a:zqv option; do
case "$option" in
o) output=$OPTARG ;;
k) kernel=$OPTARG ;;
s) sysmap=$OPTARG ;;
i) initrd=$OPTARG ;;
d) objdir=$OPTARG ;;
r) release=$OPTARG ;;
a) arch=$OPTARG ;;
z) compressed="Yes" ;;
q) quiet="Yes" ;;
v) verbose="Yes" ;;
*) usage; exit 0 ;;
esac
done
# use non-option arguments as release version and kernel image file if needed
shift $((OPTIND-1))
if test -z "$release" -a -n "$1"; then
release=$1
fi
if test -z "$kernel" -a -n "$2"; then
kernel=$2
fi
# if no sub-architecture was specified, read it from /proc
if test -z "$arch"; then
case $(grep ^machine /proc/cpuinfo) in
*PReP*) arch=prep ;;
*CHRP*) arch=chrp ;;
*Amiga) arch=amiga ;;
*iSeries) arch=iseries ;;
*)
case $(grep ^pmac-generation /proc/cpuinfo) in
*NewWorld) arch=newworld ;;
*OldWorld) arch=coff ;;
esac
;;
esac
fi
test -n "$quiet" || echo === Building for sub-architecture $arch.
# if no kernel was specified, try to find one
if test -z "$kernel"; then
# guess the location of a kernel
if kernel=/boot/vmlinux-$release; test -n "$release" -a -r $kernel; then
:
elif kernel=/vmlinux; test -r $kernel; then
:
elif kernel=/boot/vmlinux; test -r $kernel; then
:
elif kernel=/boot/vmlinux-$(uname -r); test -r $kernel; then
:
else
kernel=""
fi
# we couldn't find a kernel, and therefore give up
if test -z "$kernel"; then
echo Could not find a kernel image file, please specify one.
exit 1
fi
# sanitize the location of the kernel
kernel=$(readlink -f $kernel)
fi
test -n "$quiet" || echo === Using kernel image file $kernel.
# if no initrd was specified, try to find one that goes with the kernel
if test -z "$initrd"; then
# guess the location of an initrd, but don't try too hard
if initrd=${kernel/vmlinux/initrd.img}; test -r $initrd; then
:
else
initrd=""
fi
# sanitize the location of the initrd
if test -n "$initrd"; then
initrd=$(readlink -f $initrd)
fi
fi
test -n "$quiet" -a -n "$initrd" || echo === Using initrd image file $initrd.
# if no release was specified, extract it from the kernel image name
if test -z "$release"; then
release=$(echo $kernel | sed s/.*vmlinux-//)
if echo $release | grep -q '2\.[46]\.[0-9]*'; then
:
else
release=""
fi
fi
test -n "$quiet" || echo === Release version seems to be $release.
# if no object file directory was specified, try to find one
if test -z "$objdir"; then
# try a default location first, then use the current directory
if objdir=/usr/lib/kernel-image-$release; test -d $objdir; then
:
else
objdir=$PWD
fi
fi
test -n "$quiet" || echo === Using object files from $objdir.
# if no output file was specified, source the configuration file
if test -z "$output" -a -r /etc/mkvmlinuz/output; then
. /etc/mkvmlinuz/output
fi
# we absolutely need an output file, and won't attempt guesses
if test -z "$output"; then
echo Please specify an output file.
exit 1
fi
test -n "$quiet" || echo === Building a bootable compressed kernel image in $output.
# create a work directory
work=$(mktemp -d)
test -n "$quiet" || echo === Doing build in $work.
# utilities
ADDNOTE=$objdir/utils/addnote
HACKOFF=$objdir/utils/hack-coff
MKNOTE=$objdir/utils/mknote
MKPREP=$objdir/utils/mkprep
MKBUGBOOT=$objdir/utils/mkbugboot
LD=ld
OBJCOPY=objcopy
GZIP="--force --best"
# libraries and common object files
libs=$objdir/lib
LIBS="$libs/lib.a $libs/ppc.a $libs/of.a $libs/common.a"
SIMPLE_LIBS="$lib/lib.a $lib/common.a $lib/of1275.a"
of_objs=$objdir/obj/openfirmware
simple_objs=$objdir/obj/simple
OBJS="$of_objs/start.o $of_objs/misc.o $of_objs/common.o $of_objs/${arch}main.o"
SIMPLE_OBJS="$simple_obj/head.o $simple_obj/relocate.o $simple_obj/legacy.o $simple_obj/misc.o $simple_obj/misc-prep.o $simple_obj/mpc10x_memory.o"
# off we go...
# create the compressed kernel image file
test -n "$quiet" || echo === Creating compressed kernel image vmlinux.gz...
do_cmd $OBJCOPY -O binary $kernel $work/vmlinux
do_cmd gzip $work/vmlinux
# create the compressed initrd image file
if test -n "$initrd"; then
test -n "$quiet" || echo === Creating compressed initrd image initrd.gz...
if test -n "$compressed"; then
do_cmd cp -p $initrd $work/initrd.gz
else
do_cmd cp -p $initrd $work/initrd
do_cmd gzip $work/initrd
fi
fi
# create the raw ELF image file
test -n "$quiet" || echo === Putting everything into ELF image file image.o...
do_cmd $OBJCOPY -R .comment $objdir/obj/dummy.o $work/image.o
do_cmd $OBJCOPY $work/image.o $work/image.o \
--add-section=.image=$work/vmlinux.gz \
--set-section-flags=.image=contents,alloc,load,readonly,data
if test -n "$sysmap"; then
do_cmd $OBJCOPY $work/image.o $work/image.o \
--add-section=.sysmap=$sysmap \
--set-section-flags=.sysmap=contents,alloc,load,readonly,data
fi
if test -n "$initrd"; then
do_cmd $OBJCOPY $work/image.o $work/image.o \
--add-section=.ramdisk=$work/initrd.gz \
--set-section-flags=.ramdisk=contents,alloc,load,readonly,data
fi
# link everything into the final image file and make it bootable
vmlinuz=$work/vmlinuz.$arch
LD_ARGS="-T $objdir/boot/ld.script"
OF_LD_ARGS="$LD_ARGS -e _start"
OBJCOPY_ARGS="-R .comment"
test -n "$quiet" || echo === Creating bootable kernel image file vmlinuz.$arch...
case $arch in
chrp)
LD_ARGS="$OF_LD_ARGS -Ttext 0x00800000"
do_cmd $LD -o $vmlinuz $LD_ARGS $objs/crt0.o $OBJS $work/image.o $LIBS
do_cmd $OBJCOPY $OBJCOPY_ARGS $vmlinuz $vmlinuz
do_cmd cp -p $objdir/boot/note $work
do_cmd $ADDNOTE $vmlinuz
;;
coff)
LD_ARGS="$OF_LD_ARGS -Ttext 0x00500000 -Bstatic"
OBJCOPY_ARGS="-O aixcoff-rs6000 -R .stab -R .stabstr $OBJCOPY_ARGS"
do_cmd $LD -o $vmlinuz $LD_ARGS $objs/coffcrt0.o $OBJS $work/image.o $LIBS
do_cmd $OBJCOPY $OBJCOPY_ARGS $vmlinuz $vmlinuz
do_cmd $HACKOFF $vmlinuz
;;
newworld)
LD_ARGS="$OF_LD_ARGS -Ttext 0x01000000"
OBJCOPY_ARGS="--add-section=.note=$work/note $OBJCOPY_ARGS"
do_cmd $LD -o $vmlinuz $LD_ARGS $objs/crt0.o $OBJS $LIBS $work/image.o
do_cmd $MKNOTE > $work/note
do_cmd $OBJCOPY $OBJCOPY_ARGS $vmlinuz $vmlinuz
;;
prep)
# TODO: 0x00800000 should be configurable (set by CONFIG_BOOT_LOADER)
LD_ARGS="$LD_ARGS -Ttext 0x00800000 -Bstatic"
# TODO: Do we need to add -O elf32-powerpc to the previous objcopy calls too ?
OBJCOPY_ARGS="-O elf32-powerpc $OBJCOPY_ARGS -R .stab -R .stabstr -R .sysmap"
do_cmd $OBJCOPY $OBJCOPY_ARGS $vmlinuz $vmlinuz
do_cmd $LD -o $vmlinuz $LD_ARGS $SIMPLE_OBJS $SIMPLE_LIBS $work/image.o
# TODO: Do we really need MKBUGBOOT ?
do_cmd $MKBUGBOOT $vmlinuz $vmlinuz.bugboot
do_cmd $MKPREP -pbp $vmlinuz $vmlinuz
;;
*)
echo Sorry, I do not know how to handle PowerPC sub-architecture $arch.
esac
# move bootable kernel image to its final location
if test -e $vmlinuz; then
test -n "$quiet" || echo === Moving bootable kernel image file to $output...
if test -e $output; then
echo Output file $output exists, attempting to back it up...
mv $output $output.old 2> /dev/null
fi
cat $vmlinuz > $output
fi
# clean up
test -n "$quiet" || echo === Cleaning up...
rm -rf $work
--- mkvmlinuz-6 2004-07-07 11:25:08.228899856 +0200
+++ mkvmlinuz 2004-07-07 12:00:30.041335336 +0200
@@ -162,6 +162,8 @@
ADDNOTE=$objdir/utils/addnote
HACKOFF=$objdir/utils/hack-coff
MKNOTE=$objdir/utils/mknote
+MKPREP=$objdir/utils/mkprep
+MKBUGBOOT=$objdir/utils/mkbugboot
LD=ld
OBJCOPY=objcopy
@@ -170,8 +172,11 @@
# libraries and common object files
libs=$objdir/lib
LIBS="$libs/lib.a $libs/ppc.a $libs/of.a $libs/common.a"
-objs=$objdir/obj
-OBJS="$objs/start.o $objs/misc.o $objs/common.o $objs/${arch}main.o"
+SIMPLE_LIBS="$lib/lib.a $lib/common.a $lib/of1275.a"
+of_objs=$objdir/obj/openfirmware
+simple_objs=$objdir/obj/simple
+OBJS="$of_objs/start.o $of_objs/misc.o $of_objs/common.o $of_objs/${arch}main.o"
+SIMPLE_OBJS="$simple_obj/head.o $simple_obj/relocate.o $simple_obj/legacy.o $simple_obj/misc.o $simple_obj/misc-prep.o $simple_obj/mpc10x_memory.o"
# off we go...
@@ -210,32 +215,43 @@
# link everything into the final image file and make it bootable
vmlinuz=$work/vmlinuz.$arch
-LD_ARGS="-T $objdir/boot/ld.script -e _start"
+LD_ARGS="-T $objdir/boot/ld.script"
+OF_LD_ARGS="$LD_ARGS -e _start"
OBJCOPY_ARGS="-R .comment"
test -n "$quiet" || echo === Creating bootable kernel image file vmlinuz.$arch...
case $arch in
chrp)
- LD_ARGS="$LD_ARGS -Ttext 0x00800000"
+ LD_ARGS="$OF_LD_ARGS -Ttext 0x00800000"
do_cmd $LD -o $vmlinuz $LD_ARGS $objs/crt0.o $OBJS $work/image.o $LIBS
do_cmd $OBJCOPY $OBJCOPY_ARGS $vmlinuz $vmlinuz
do_cmd cp -p $objdir/boot/note $work
do_cmd $ADDNOTE $vmlinuz
;;
coff)
- LD_ARGS="$LD_ARGS -Ttext 0x00500000 -Bstatic"
+ LD_ARGS="$OF_LD_ARGS -Ttext 0x00500000 -Bstatic"
OBJCOPY_ARGS="-O aixcoff-rs6000 -R .stab -R .stabstr $OBJCOPY_ARGS"
do_cmd $LD -o $vmlinuz $LD_ARGS $objs/coffcrt0.o $OBJS $work/image.o $LIBS
do_cmd $OBJCOPY $OBJCOPY_ARGS $vmlinuz $vmlinuz
do_cmd $HACKOFF $vmlinuz
;;
newworld)
- LD_ARGS="$LD_ARGS -Ttext 0x01000000"
+ LD_ARGS="$OF_LD_ARGS -Ttext 0x01000000"
OBJCOPY_ARGS="--add-section=.note=$work/note $OBJCOPY_ARGS"
do_cmd $LD -o $vmlinuz $LD_ARGS $objs/crt0.o $OBJS $LIBS $work/image.o
do_cmd $MKNOTE > $work/note
do_cmd $OBJCOPY $OBJCOPY_ARGS $vmlinuz $vmlinuz
;;
- #prep)
+ prep)
+ # TODO: 0x00800000 should be configurable (set by CONFIG_BOOT_LOADER)
+ LD_ARGS="$LD_ARGS -Ttext 0x00800000 -Bstatic"
+ # TODO: Do we need to add -O elf32-powerpc to the previous objcopy calls too ?
+ OBJCOPY_ARGS="-O elf32-powerpc $OBJCOPY_ARGS -R .stab -R .stabstr -R .sysmap"
+ do_cmd $OBJCOPY $OBJCOPY_ARGS $vmlinuz $vmlinuz
+ do_cmd $LD -o $vmlinuz $LD_ARGS $SIMPLE_OBJS $SIMPLE_LIBS $work/image.o
+ # TODO: Do we really need MKBUGBOOT ?
+ do_cmd $MKBUGBOOT $vmlinuz $vmlinuz.bugboot
+ do_cmd $MKPREP -pbp $vmlinuz $vmlinuz
+ ;;
*)
echo Sorry, I do not know how to handle PowerPC sub-architecture $arch.
esac
Reply to: