hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
kernel/arch/powerpc/boot/wrapper
....@@ -1,8 +1,7 @@
11 #!/bin/sh
2
+# SPDX-License-Identifier: GPL-2.0-only
23
34 # Copyright (C) 2006 Paul Mackerras, IBM Corporation <paulus@samba.org>
4
-# This program may be used under the terms of version 2 of the GNU
5
-# General Public License.
65
76 # This script takes a kernel binary and optionally an initrd image
87 # and/or a device-tree blob, and creates a bootable zImage for a
....@@ -14,6 +13,7 @@
1413 # -i initrd specify initrd file
1514 # -d devtree specify device-tree blob
1615 # -s tree.dts specify device-tree source file (needs dtc installed)
16
+# -e esm_blob specify ESM blob for secure images
1717 # -c cache $kernel.strip.gz (use if present & newer, else make)
1818 # -C prefix specify command prefix for cross-building tools
1919 # (strip, objcopy, ld)
....@@ -29,6 +29,7 @@
2929 # Allow for verbose output
3030 if [ "$V" = 1 ]; then
3131 set -x
32
+ map="-Map wrapper.map"
3233 fi
3334
3435 # defaults
....@@ -38,9 +39,11 @@
3839 initrd=
3940 dtb=
4041 dts=
42
+esm_blob=
4143 cacheit=
4244 binary=
4345 compression=.gz
46
+uboot_comp=gzip
4447 pie=
4548 format=
4649
....@@ -60,9 +63,9 @@
6063
6164 usage() {
6265 echo 'Usage: wrapper [-o output] [-p platform] [-i initrd]' >&2
63
- echo ' [-d devtree] [-s tree.dts] [-c] [-C cross-prefix]' >&2
64
- echo ' [-D datadir] [-W workingdir] [-Z (gz|xz|none)]' >&2
65
- echo ' [--no-compression] [vmlinux]' >&2
66
+ echo ' [-d devtree] [-s tree.dts] [-e esm_blob]' >&2
67
+ echo ' [-c] [-C cross-prefix] [-D datadir] [-W workingdir]' >&2
68
+ echo ' [-Z (gz|xz|none)] [--no-compression] [vmlinux]' >&2
6669 exit 1
6770 }
6871
....@@ -105,6 +108,11 @@
105108 [ "$#" -gt 0 ] || usage
106109 dtb="$1"
107110 ;;
111
+ -e)
112
+ shift
113
+ [ "$#" -gt 0 ] || usage
114
+ esm_blob="$1"
115
+ ;;
108116 -s)
109117 shift
110118 [ "$#" -gt 0 ] || usage
....@@ -131,22 +139,29 @@
131139 ;;
132140 -z)
133141 compression=.gz
142
+ uboot_comp=gzip
134143 ;;
135144 -Z)
136145 shift
137146 [ "$#" -gt 0 ] || usage
138
- [ "$1" != "gz" -o "$1" != "xz" -o "$1" != "none" ] || usage
147
+ [ "$1" != "gz" -o "$1" != "xz" -o "$1" != "lzma" -o "$1" != "lzo" -o "$1" != "none" ] || usage
139148
140149 compression=".$1"
150
+ uboot_comp=$1
141151
142152 if [ $compression = ".none" ]; then
143153 compression=
154
+ uboot_comp=none
144155 fi
156
+ if [ $uboot_comp = "gz" ]; then
157
+ uboot_comp=gzip
158
+ fi
145159 ;;
146160 --no-gzip)
147161 # a "feature" of the the wrapper script is that it can be used outside
148162 # the kernel tree. So keeping this around for backwards compatibility.
149163 compression=
164
+ uboot_comp=none
150165 ;;
151166 -?)
152167 usage
....@@ -211,8 +226,15 @@
211226 tmp=$tmpdir/zImage.$$.o
212227 ksection=.kernel:vmlinux.strip
213228 isection=.kernel:initrd
229
+esection=.kernel:esm_blob
214230 link_address='0x400000'
215231 make_space=y
232
+
233
+
234
+if [ -n "$esm_blob" -a "$platform" != "pseries" ]; then
235
+ echo "ESM blob not support on non-pseries platforms" >&2
236
+ exit 1
237
+fi
216238
217239 case "$platform" in
218240 of)
....@@ -302,14 +324,6 @@
302324 platformo="$object/fixed-head.o $object/redboot-8xx.o"
303325 binary=y
304326 ;;
305
-simpleboot-virtex405-*)
306
- platformo="$object/virtex405-head.o $object/simpleboot.o $object/virtex.o"
307
- binary=y
308
- ;;
309
-simpleboot-virtex440-*)
310
- platformo="$object/fixed-head.o $object/simpleboot.o $object/virtex.o"
311
- binary=y
312
- ;;
313327 simpleboot-*)
314328 platformo="$object/fixed-head.o $object/simpleboot.o"
315329 binary=y
....@@ -366,9 +380,16 @@
366380 .gz)
367381 gzip -n -f -9 "$vmz.$$"
368382 ;;
383
+ .lzma)
384
+ xz --format=lzma -f -6 "$vmz.$$"
385
+ ;;
386
+ .lzo)
387
+ lzop -f -9 "$vmz.$$"
388
+ ;;
369389 *)
370390 # drop the compression suffix so the stripped vmlinux is used
371391 compression=
392
+ uboot_comp=none
372393 ;;
373394 esac
374395
....@@ -412,7 +433,7 @@
412433 case "$platform" in
413434 uboot)
414435 rm -f "$ofile"
415
- ${MKIMAGE} -A ppc -O linux -T kernel -C gzip -a $membase -e $membase \
436
+ ${MKIMAGE} -A ppc -O linux -T kernel -C $uboot_comp -a $membase -e $membase \
416437 $uboot_version -d "$vmz" "$ofile"
417438 if [ -z "$cacheit" ]; then
418439 rm -f "$vmz"
....@@ -463,12 +484,16 @@
463484 fi
464485 fi
465486
487
+if [ -n "$esm_blob" ]; then
488
+ addsec $tmp "$esm_blob" $esection
489
+fi
490
+
466491 if [ "$platform" != "miboot" ]; then
467492 if [ -n "$link_address" ] ; then
468493 text_start="-Ttext $link_address"
469494 fi
470495 #link everything
471
- ${CROSS}ld -m $format -T $lds $text_start $pie $nodl -o "$ofile" \
496
+ ${CROSS}ld -m $format -T $lds $text_start $pie $nodl -o "$ofile" $map \
472497 $platformo $tmp $object/wrapper.a
473498 rm $tmp
474499 fi
....@@ -538,7 +563,18 @@
538563 count=$overlay_size bs=1
539564
540565 odir="$(dirname "$ofile.bin")"
541
- rm -f "$odir/otheros.bld"
542
- gzip -n --force -9 --stdout "$ofile.bin" > "$odir/otheros.bld"
566
+
567
+ # The ps3's flash loader has a size limit of 16 MiB for the uncompressed
568
+ # image. If a compressed image that exceeded this limit is written to
569
+ # flash the loader will decompress that image until the 16 MiB limit is
570
+ # reached, then enter the system reset vector of the partially decompressed
571
+ # image. No warning is issued.
572
+ rm -f "$odir"/{otheros,otheros-too-big}.bld
573
+ size=$(${CROSS}nm --no-sort --radix=d "$ofile" | egrep ' _end$' | cut -d' ' -f1)
574
+ bld="otheros.bld"
575
+ if [ $size -gt $((0x1000000)) ]; then
576
+ bld="otheros-too-big.bld"
577
+ fi
578
+ gzip -n --force -9 --stdout "$ofile.bin" > "$odir/$bld"
543579 ;;
544580 esac