diff options
author | Oliver O'Halloran <oohall@gmail.com> | 2016-09-22 02:54:33 -0400 |
---|---|---|
committer | Michael Ellerman <mpe@ellerman.id.au> | 2016-09-28 00:32:27 -0400 |
commit | f1e510bbb9f265acb4147a3a650882876a76d48b (patch) | |
tree | 08127f565c17ac1beb45bf1dd8acb1c82a577436 /arch/powerpc/boot | |
parent | a4da56fbc553ea941f3de6ec55070d62f6957d51 (diff) |
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: Oliver O'Halloran <oohall@gmail.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Diffstat (limited to 'arch/powerpc/boot')
-rw-r--r-- | arch/powerpc/boot/Makefile | 7 | ||||
-rwxr-xr-x | arch/powerpc/boot/wrapper | 61 |
2 files changed, 50 insertions, 18 deletions
diff --git a/arch/powerpc/boot/Makefile b/arch/powerpc/boot/Makefile index 861348c72519..9fb451d0586e 100644 --- a/arch/powerpc/boot/Makefile +++ b/arch/powerpc/boot/Makefile | |||
@@ -225,10 +225,13 @@ CROSSWRAP := -C "$(CROSS_COMPILE)" | |||
225 | endif | 225 | endif |
226 | endif | 226 | endif |
227 | 227 | ||
228 | compressor-$(CONFIG_KERNEL_GZIP) := gz | ||
229 | |||
228 | # args (to if_changed): 1 = (this rule), 2 = platform, 3 = dts 4=dtb 5=initrd | 230 | # args (to if_changed): 1 = (this rule), 2 = platform, 3 = dts 4=dtb 5=initrd |
229 | quiet_cmd_wrap = WRAP $@ | 231 | quiet_cmd_wrap = WRAP $@ |
230 | cmd_wrap =$(CONFIG_SHELL) $(wrapper) -c -o $@ -p $2 $(CROSSWRAP) \ | 232 | cmd_wrap =$(CONFIG_SHELL) $(wrapper) -Z $(compressor-y) -c -o $@ -p $2 \ |
231 | $(if $3, -s $3)$(if $4, -d $4)$(if $5, -i $5) vmlinux | 233 | $(CROSSWRAP) $(if $3, -s $3)$(if $4, -d $4)$(if $5, -i $5) \ |
234 | vmlinux | ||
232 | 235 | ||
233 | image-$(CONFIG_PPC_PSERIES) += zImage.pseries | 236 | image-$(CONFIG_PPC_PSERIES) += zImage.pseries |
234 | image-$(CONFIG_PPC_POWERNV) += zImage.pseries | 237 | image-$(CONFIG_PPC_POWERNV) += zImage.pseries |
diff --git a/arch/powerpc/boot/wrapper b/arch/powerpc/boot/wrapper index 6681ec3625c9..404b3aabdb4d 100755 --- a/arch/powerpc/boot/wrapper +++ b/arch/powerpc/boot/wrapper | |||
@@ -20,6 +20,8 @@ | |||
20 | # -D dir specify directory containing data files used by script | 20 | # -D dir specify directory containing data files used by script |
21 | # (default ./arch/powerpc/boot) | 21 | # (default ./arch/powerpc/boot) |
22 | # -W dir specify working directory for temporary files (default .) | 22 | # -W dir specify working directory for temporary files (default .) |
23 | # -z use gzip (legacy) | ||
24 | # -Z zsuffix compression to use (gz, xz or none) | ||
23 | 25 | ||
24 | # Stop execution if any command fails | 26 | # Stop execution if any command fails |
25 | set -e | 27 | set -e |
@@ -38,7 +40,7 @@ dtb= | |||
38 | dts= | 40 | dts= |
39 | cacheit= | 41 | cacheit= |
40 | binary= | 42 | binary= |
41 | gzip=.gz | 43 | compression=.gz |
42 | pie= | 44 | pie= |
43 | format= | 45 | format= |
44 | 46 | ||
@@ -59,7 +61,8 @@ tmpdir=. | |||
59 | usage() { | 61 | usage() { |
60 | echo 'Usage: wrapper [-o output] [-p platform] [-i initrd]' >&2 | 62 | echo 'Usage: wrapper [-o output] [-p platform] [-i initrd]' >&2 |
61 | echo ' [-d devtree] [-s tree.dts] [-c] [-C cross-prefix]' >&2 | 63 | echo ' [-d devtree] [-s tree.dts] [-c] [-C cross-prefix]' >&2 |
62 | echo ' [-D datadir] [-W workingdir] [--no-gzip] [vmlinux]' >&2 | 64 | echo ' [-D datadir] [-W workingdir] [-Z (gz|xz|none)]' >&2 |
65 | echo ' [--no-compression] [vmlinux]' >&2 | ||
63 | exit 1 | 66 | exit 1 |
64 | } | 67 | } |
65 | 68 | ||
@@ -126,8 +129,24 @@ while [ "$#" -gt 0 ]; do | |||
126 | [ "$#" -gt 0 ] || usage | 129 | [ "$#" -gt 0 ] || usage |
127 | tmpdir="$1" | 130 | tmpdir="$1" |
128 | ;; | 131 | ;; |
132 | -z) | ||
133 | compression=.gz | ||
134 | ;; | ||
135 | -Z) | ||
136 | shift | ||
137 | [ "$#" -gt 0 ] || usage | ||
138 | [ "$1" != "gz" -o "$1" != "xz" -o "$1" != "none" ] || usage | ||
139 | |||
140 | compression=".$1" | ||
141 | |||
142 | if [ $compression = ".none" ]; then | ||
143 | compression= | ||
144 | fi | ||
145 | ;; | ||
129 | --no-gzip) | 146 | --no-gzip) |
130 | gzip= | 147 | # a "feature" of the the wrapper script is that it can be used outside |
148 | # the kernel tree. So keeping this around for backwards compatibility. | ||
149 | compression= | ||
131 | ;; | 150 | ;; |
132 | -?) | 151 | -?) |
133 | usage | 152 | usage |
@@ -140,6 +159,7 @@ while [ "$#" -gt 0 ]; do | |||
140 | shift | 159 | shift |
141 | done | 160 | done |
142 | 161 | ||
162 | |||
143 | if [ -n "$dts" ]; then | 163 | if [ -n "$dts" ]; then |
144 | if [ ! -r "$dts" -a -r "$object/dts/$dts" ]; then | 164 | if [ ! -r "$dts" -a -r "$object/dts/$dts" ]; then |
145 | dts="$object/dts/$dts" | 165 | dts="$object/dts/$dts" |
@@ -212,7 +232,7 @@ miboot|uboot*) | |||
212 | ;; | 232 | ;; |
213 | cuboot*) | 233 | cuboot*) |
214 | binary=y | 234 | binary=y |
215 | gzip= | 235 | compression= |
216 | case "$platform" in | 236 | case "$platform" in |
217 | *-mpc866ads|*-mpc885ads|*-adder875*|*-ep88xc) | 237 | *-mpc866ads|*-mpc885ads|*-adder875*|*-ep88xc) |
218 | platformo=$object/cuboot-8xx.o | 238 | platformo=$object/cuboot-8xx.o |
@@ -243,7 +263,7 @@ cuboot*) | |||
243 | ps3) | 263 | ps3) |
244 | platformo="$object/ps3-head.o $object/ps3-hvcall.o $object/ps3.o" | 264 | platformo="$object/ps3-head.o $object/ps3-hvcall.o $object/ps3.o" |
245 | lds=$object/zImage.ps3.lds | 265 | lds=$object/zImage.ps3.lds |
246 | gzip= | 266 | compression= |
247 | ext=bin | 267 | ext=bin |
248 | objflags="-O binary --set-section-flags=.bss=contents,alloc,load,data" | 268 | objflags="-O binary --set-section-flags=.bss=contents,alloc,load,data" |
249 | ksection=.kernel:vmlinux.bin | 269 | ksection=.kernel:vmlinux.bin |
@@ -310,27 +330,37 @@ mvme7100) | |||
310 | esac | 330 | esac |
311 | 331 | ||
312 | vmz="$tmpdir/`basename \"$kernel\"`.$ext" | 332 | vmz="$tmpdir/`basename \"$kernel\"`.$ext" |
313 | if [ -z "$cacheit" -o ! -f "$vmz$gzip" -o "$vmz$gzip" -ot "$kernel" ]; then | ||
314 | ${CROSS}objcopy $objflags "$kernel" "$vmz.$$" | ||
315 | 333 | ||
316 | strip_size=$(stat -c %s $vmz.$$) | 334 | # Calculate the vmlinux.strip size |
335 | ${CROSS}objcopy $objflags "$kernel" "$vmz.$$" | ||
336 | strip_size=$(stat -c %s $vmz.$$) | ||
317 | 337 | ||
318 | if [ -n "$gzip" ]; then | 338 | if [ -z "$cacheit" -o ! -f "$vmz$compression" -o "$vmz$compression" -ot "$kernel" ]; then |
339 | # recompress the image if we need to | ||
340 | case $compression in | ||
341 | .xz) | ||
342 | xz --check=crc32 -f -6 "$vmz.$$" | ||
343 | ;; | ||
344 | .gz) | ||
319 | gzip -n -f -9 "$vmz.$$" | 345 | gzip -n -f -9 "$vmz.$$" |
320 | fi | 346 | ;; |
347 | *) | ||
348 | # drop the compression suffix so the stripped vmlinux is used | ||
349 | compression= | ||
350 | ;; | ||
351 | esac | ||
321 | 352 | ||
322 | if [ -n "$cacheit" ]; then | 353 | if [ -n "$cacheit" ]; then |
323 | mv -f "$vmz.$$$gzip" "$vmz$gzip" | 354 | mv -f "$vmz.$$$compression" "$vmz$compression" |
324 | else | 355 | else |
325 | vmz="$vmz.$$" | 356 | vmz="$vmz.$$" |
326 | fi | 357 | fi |
327 | else | 358 | else |
328 | # Calculate the vmlinux.strip size | ||
329 | ${CROSS}objcopy $objflags "$kernel" "$vmz.$$" | ||
330 | strip_size=$(stat -c %s $vmz.$$) | ||
331 | rm -f $vmz.$$ | 359 | rm -f $vmz.$$ |
332 | fi | 360 | fi |
333 | 361 | ||
362 | vmz="$vmz$compression" | ||
363 | |||
334 | if [ "$make_space" = "y" ]; then | 364 | if [ "$make_space" = "y" ]; then |
335 | # Round the size to next higher MB limit | 365 | # Round the size to next higher MB limit |
336 | round_size=$(((strip_size + 0xfffff) & 0xfff00000)) | 366 | round_size=$(((strip_size + 0xfffff) & 0xfff00000)) |
@@ -346,8 +376,6 @@ if [ "$make_space" = "y" ]; then | |||
346 | fi | 376 | fi |
347 | fi | 377 | fi |
348 | 378 | ||
349 | vmz="$vmz$gzip" | ||
350 | |||
351 | # Extract kernel version information, some platforms want to include | 379 | # Extract kernel version information, some platforms want to include |
352 | # it in the image header | 380 | # it in the image header |
353 | version=`${CROSS}strings "$kernel" | grep '^Linux version [-0-9.]' | \ | 381 | version=`${CROSS}strings "$kernel" | grep '^Linux version [-0-9.]' | \ |
@@ -417,6 +445,7 @@ if [ "$platform" != "miboot" ]; then | |||
417 | if [ -n "$link_address" ] ; then | 445 | if [ -n "$link_address" ] ; then |
418 | text_start="-Ttext $link_address" | 446 | text_start="-Ttext $link_address" |
419 | fi | 447 | fi |
448 | #link everything | ||
420 | ${CROSS}ld -m $format -T $lds $text_start $pie -o "$ofile" \ | 449 | ${CROSS}ld -m $format -T $lds $text_start $pie -o "$ofile" \ |
421 | $platformo $tmp $object/wrapper.a | 450 | $platformo $tmp $object/wrapper.a |
422 | rm $tmp | 451 | rm $tmp |