Commit f1e510bb authored by Oliver O'Halloran's avatar Oliver O'Halloran Committed by Michael Ellerman

powerpc/boot: Add XZ support to the wrapper script

This modifies the wrapper script so that the -Z option takes an argument
to specify the compression type. It can either be 'gz', 'xz' or 'none'.

The legazy --no-gzip and -z options are still supported and will set the
compression to none and gzip respectively, but they are not documented.

Only XZ -6 is used for compression rather than XZ -9. Using compression
levels higher than 6 requires the decompressor to build a large (64MB)
dictionary when decompressing and some environments cannot satisfy such
large allocations (e.g. POWER 6 LPAR partition firmware).
Signed-off-by: default avatarOliver O'Halloran <oohall@gmail.com>
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
parent a4da56fb
...@@ -225,10 +225,13 @@ CROSSWRAP := -C "$(CROSS_COMPILE)" ...@@ -225,10 +225,13 @@ CROSSWRAP := -C "$(CROSS_COMPILE)"
endif endif
endif endif
compressor-$(CONFIG_KERNEL_GZIP) := gz
# args (to if_changed): 1 = (this rule), 2 = platform, 3 = dts 4=dtb 5=initrd # args (to if_changed): 1 = (this rule), 2 = platform, 3 = dts 4=dtb 5=initrd
quiet_cmd_wrap = WRAP $@ quiet_cmd_wrap = WRAP $@
cmd_wrap =$(CONFIG_SHELL) $(wrapper) -c -o $@ -p $2 $(CROSSWRAP) \ cmd_wrap =$(CONFIG_SHELL) $(wrapper) -Z $(compressor-y) -c -o $@ -p $2 \
$(if $3, -s $3)$(if $4, -d $4)$(if $5, -i $5) vmlinux $(CROSSWRAP) $(if $3, -s $3)$(if $4, -d $4)$(if $5, -i $5) \
vmlinux
image-$(CONFIG_PPC_PSERIES) += zImage.pseries image-$(CONFIG_PPC_PSERIES) += zImage.pseries
image-$(CONFIG_PPC_POWERNV) += zImage.pseries image-$(CONFIG_PPC_POWERNV) += zImage.pseries
......
...@@ -20,6 +20,8 @@ ...@@ -20,6 +20,8 @@
# -D dir specify directory containing data files used by script # -D dir specify directory containing data files used by script
# (default ./arch/powerpc/boot) # (default ./arch/powerpc/boot)
# -W dir specify working directory for temporary files (default .) # -W dir specify working directory for temporary files (default .)
# -z use gzip (legacy)
# -Z zsuffix compression to use (gz, xz or none)
# Stop execution if any command fails # Stop execution if any command fails
set -e set -e
...@@ -38,7 +40,7 @@ dtb= ...@@ -38,7 +40,7 @@ dtb=
dts= dts=
cacheit= cacheit=
binary= binary=
gzip=.gz compression=.gz
pie= pie=
format= format=
...@@ -59,7 +61,8 @@ tmpdir=. ...@@ -59,7 +61,8 @@ tmpdir=.
usage() { usage() {
echo 'Usage: wrapper [-o output] [-p platform] [-i initrd]' >&2 echo 'Usage: wrapper [-o output] [-p platform] [-i initrd]' >&2
echo ' [-d devtree] [-s tree.dts] [-c] [-C cross-prefix]' >&2 echo ' [-d devtree] [-s tree.dts] [-c] [-C cross-prefix]' >&2
echo ' [-D datadir] [-W workingdir] [--no-gzip] [vmlinux]' >&2 echo ' [-D datadir] [-W workingdir] [-Z (gz|xz|none)]' >&2
echo ' [--no-compression] [vmlinux]' >&2
exit 1 exit 1
} }
...@@ -126,8 +129,24 @@ while [ "$#" -gt 0 ]; do ...@@ -126,8 +129,24 @@ while [ "$#" -gt 0 ]; do
[ "$#" -gt 0 ] || usage [ "$#" -gt 0 ] || usage
tmpdir="$1" tmpdir="$1"
;; ;;
-z)
compression=.gz
;;
-Z)
shift
[ "$#" -gt 0 ] || usage
[ "$1" != "gz" -o "$1" != "xz" -o "$1" != "none" ] || usage
compression=".$1"
if [ $compression = ".none" ]; then
compression=
fi
;;
--no-gzip) --no-gzip)
gzip= # a "feature" of the the wrapper script is that it can be used outside
# the kernel tree. So keeping this around for backwards compatibility.
compression=
;; ;;
-?) -?)
usage usage
...@@ -140,6 +159,7 @@ while [ "$#" -gt 0 ]; do ...@@ -140,6 +159,7 @@ while [ "$#" -gt 0 ]; do
shift shift
done done
if [ -n "$dts" ]; then if [ -n "$dts" ]; then
if [ ! -r "$dts" -a -r "$object/dts/$dts" ]; then if [ ! -r "$dts" -a -r "$object/dts/$dts" ]; then
dts="$object/dts/$dts" dts="$object/dts/$dts"
...@@ -212,7 +232,7 @@ miboot|uboot*) ...@@ -212,7 +232,7 @@ miboot|uboot*)
;; ;;
cuboot*) cuboot*)
binary=y binary=y
gzip= compression=
case "$platform" in case "$platform" in
*-mpc866ads|*-mpc885ads|*-adder875*|*-ep88xc) *-mpc866ads|*-mpc885ads|*-adder875*|*-ep88xc)
platformo=$object/cuboot-8xx.o platformo=$object/cuboot-8xx.o
...@@ -243,7 +263,7 @@ cuboot*) ...@@ -243,7 +263,7 @@ cuboot*)
ps3) ps3)
platformo="$object/ps3-head.o $object/ps3-hvcall.o $object/ps3.o" platformo="$object/ps3-head.o $object/ps3-hvcall.o $object/ps3.o"
lds=$object/zImage.ps3.lds lds=$object/zImage.ps3.lds
gzip= compression=
ext=bin ext=bin
objflags="-O binary --set-section-flags=.bss=contents,alloc,load,data" objflags="-O binary --set-section-flags=.bss=contents,alloc,load,data"
ksection=.kernel:vmlinux.bin ksection=.kernel:vmlinux.bin
...@@ -310,27 +330,37 @@ mvme7100) ...@@ -310,27 +330,37 @@ mvme7100)
esac esac
vmz="$tmpdir/`basename \"$kernel\"`.$ext" vmz="$tmpdir/`basename \"$kernel\"`.$ext"
if [ -z "$cacheit" -o ! -f "$vmz$gzip" -o "$vmz$gzip" -ot "$kernel" ]; then
${CROSS}objcopy $objflags "$kernel" "$vmz.$$"
strip_size=$(stat -c %s $vmz.$$) # Calculate the vmlinux.strip size
${CROSS}objcopy $objflags "$kernel" "$vmz.$$"
strip_size=$(stat -c %s $vmz.$$)
if [ -n "$gzip" ]; then if [ -z "$cacheit" -o ! -f "$vmz$compression" -o "$vmz$compression" -ot "$kernel" ]; then
# recompress the image if we need to
case $compression in
.xz)
xz --check=crc32 -f -6 "$vmz.$$"
;;
.gz)
gzip -n -f -9 "$vmz.$$" gzip -n -f -9 "$vmz.$$"
fi ;;
*)
# drop the compression suffix so the stripped vmlinux is used
compression=
;;
esac
if [ -n "$cacheit" ]; then if [ -n "$cacheit" ]; then
mv -f "$vmz.$$$gzip" "$vmz$gzip" mv -f "$vmz.$$$compression" "$vmz$compression"
else else
vmz="$vmz.$$" vmz="$vmz.$$"
fi fi
else else
# Calculate the vmlinux.strip size
${CROSS}objcopy $objflags "$kernel" "$vmz.$$"
strip_size=$(stat -c %s $vmz.$$)
rm -f $vmz.$$ rm -f $vmz.$$
fi fi
vmz="$vmz$compression"
if [ "$make_space" = "y" ]; then if [ "$make_space" = "y" ]; then
# Round the size to next higher MB limit # Round the size to next higher MB limit
round_size=$(((strip_size + 0xfffff) & 0xfff00000)) round_size=$(((strip_size + 0xfffff) & 0xfff00000))
...@@ -346,8 +376,6 @@ if [ "$make_space" = "y" ]; then ...@@ -346,8 +376,6 @@ if [ "$make_space" = "y" ]; then
fi fi
fi fi
vmz="$vmz$gzip"
# Extract kernel version information, some platforms want to include # Extract kernel version information, some platforms want to include
# it in the image header # it in the image header
version=`${CROSS}strings "$kernel" | grep '^Linux version [-0-9.]' | \ version=`${CROSS}strings "$kernel" | grep '^Linux version [-0-9.]' | \
...@@ -417,6 +445,7 @@ if [ "$platform" != "miboot" ]; then ...@@ -417,6 +445,7 @@ if [ "$platform" != "miboot" ]; then
if [ -n "$link_address" ] ; then if [ -n "$link_address" ] ; then
text_start="-Ttext $link_address" text_start="-Ttext $link_address"
fi fi
#link everything
${CROSS}ld -m $format -T $lds $text_start $pie -o "$ofile" \ ${CROSS}ld -m $format -T $lds $text_start $pie -o "$ofile" \
$platformo $tmp $object/wrapper.a $platformo $tmp $object/wrapper.a
rm $tmp rm $tmp
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment