Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) #!/bin/sh
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) # SPDX-License-Identifier: GPL-2.0-only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4) # Copyright (C) 2006 Paul Mackerras, IBM Corporation <paulus@samba.org>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6) # This script takes a kernel binary and optionally an initrd image
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) # and/or a device-tree blob, and creates a bootable zImage for a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) # given platform.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) # Options:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) # -o zImage	specify output file
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) # -p platform	specify platform (links in $platform.o)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) # -i initrd	specify initrd file
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) # -d devtree	specify device-tree blob
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) # -s tree.dts	specify device-tree source file (needs dtc installed)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) # -e esm_blob   specify ESM blob for secure images
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) # -c		cache $kernel.strip.gz (use if present & newer, else make)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) # -C prefix	specify command prefix for cross-building tools
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) #		(strip, objcopy, ld)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) # -D dir	specify directory containing data files used by script
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) #		(default ./arch/powerpc/boot)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) # -W dir	specify working directory for temporary files (default .)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) # -z		use gzip (legacy)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) # -Z zsuffix    compression to use (gz, xz or none)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) # Stop execution if any command fails
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) set -e
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) # Allow for verbose output
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) if [ "$V" = 1 ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31)     set -x
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32)     map="-Map wrapper.map"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) # defaults
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) kernel=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) ofile=zImage
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) platform=of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) initrd=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) dtb=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) dts=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) esm_blob=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) cacheit=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) binary=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) compression=.gz
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) uboot_comp=gzip
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) pie=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) format=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) # cross-compilation prefix
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) CROSS=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) # mkimage wrapper script
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) MKIMAGE=$srctree/scripts/mkuboot.sh
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) # directory for object and other files used by this script
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) object=arch/powerpc/boot
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) objbin=$object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) dtc=scripts/dtc/dtc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) # directory for working files
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) tmpdir=.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) usage() {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65)     echo 'Usage: wrapper [-o output] [-p platform] [-i initrd]' >&2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66)     echo '       [-d devtree] [-s tree.dts] [-e esm_blob]' >&2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67)     echo '       [-c] [-C cross-prefix] [-D datadir] [-W workingdir]' >&2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68)     echo '       [-Z (gz|xz|none)] [--no-compression] [vmlinux]' >&2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69)     exit 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) run_cmd() {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73)     if [ "$V" = 1 ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74)         $* 2>&1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75)     else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76)         local msg
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78)         set +e
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79)         msg=$($* 2>&1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81)         if [ $? -ne "0" ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82)                 echo $msg
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83)                 exit 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84)         fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85)         set -e
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86)     fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) while [ "$#" -gt 0 ]; do
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90)     case "$1" in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91)     -o)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 	shift
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 	[ "$#" -gt 0 ] || usage
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 	ofile="$1"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 	;;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96)     -p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 	shift
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 	[ "$#" -gt 0 ] || usage
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 	platform="$1"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 	;;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101)     -i)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 	shift
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 	[ "$#" -gt 0 ] || usage
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 	initrd="$1"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 	;;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106)     -d)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 	shift
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 	[ "$#" -gt 0 ] || usage
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 	dtb="$1"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 	;;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111)     -e)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 	shift
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 	[ "$#" -gt 0 ] || usage
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 	esm_blob="$1"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 	;;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116)     -s)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 	shift
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 	[ "$#" -gt 0 ] || usage
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 	dts="$1"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 	;;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121)     -c)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 	cacheit=y
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 	;;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124)     -C)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 	shift
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 	[ "$#" -gt 0 ] || usage
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 	CROSS="$1"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 	;;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129)     -D)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 	shift
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 	[ "$#" -gt 0 ] || usage
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 	object="$1"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 	objbin="$1"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 	;;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135)     -W)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 	shift
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 	[ "$#" -gt 0 ] || usage
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 	tmpdir="$1"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 	;;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140)     -z)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 	compression=.gz
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 	uboot_comp=gzip
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 	;;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144)     -Z)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 	shift
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 	[ "$#" -gt 0 ] || usage
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147)         [ "$1" != "gz" -o "$1" != "xz" -o "$1" != "lzma" -o "$1" != "lzo" -o "$1" != "none" ] || usage
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 	compression=".$1"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 	uboot_comp=$1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152)         if [ $compression = ".none" ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153)                 compression=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 		uboot_comp=none
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155)         fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 	if [ $uboot_comp = "gz" ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 		uboot_comp=gzip
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 	fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 	;;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160)     --no-gzip)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161)         # a "feature" of the the wrapper script is that it can be used outside
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162)         # the kernel tree. So keeping this around for backwards compatibility.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163)         compression=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 	uboot_comp=none
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165)         ;;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166)     -?)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 	usage
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 	;;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169)     *)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 	[ -z "$kernel" ] || usage
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 	kernel="$1"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 	;;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173)     esac
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174)     shift
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) done
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) if [ -n "$dts" ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179)     if [ ! -r "$dts" -a -r "$object/dts/$dts" ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 	dts="$object/dts/$dts"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181)     fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182)     if [ -z "$dtb" ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 	dtb="$platform.dtb"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184)     fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185)     $dtc -O dtb -o "$dtb" -b 0 "$dts"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) if [ -z "$kernel" ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189)     kernel=vmlinux
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) LANG=C elfformat="`${CROSS}objdump -p "$kernel" | grep 'file format' | awk '{print $4}'`"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) case "$elfformat" in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194)     elf64-powerpcle)	format=elf64lppc	;;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195)     elf64-powerpc)	format=elf32ppc	;;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196)     elf32-powerpc)	format=elf32ppc	;;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) esac
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) ld_version()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201)     # Poached from scripts/ld-version.sh, but we don't want to call that because
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202)     # this script (wrapper) is distributed separately from the kernel source.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203)     # Extract linker version number from stdin and turn into single number.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204)     awk '{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 	gsub(".*\\)", "");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 	gsub(".*version ", "");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 	gsub("-.*", "");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 	split($1,a, ".");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 	print a[1]*100000000 + a[2]*1000000 + a[3]*10000;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 	exit
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211)     }'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) # Do not include PT_INTERP segment when linking pie. Non-pie linking
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) # just ignores this option.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) LD_VERSION=$(${CROSS}ld --version | ld_version)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) LD_NO_DL_MIN_VERSION=$(echo 2.26 | ld_version)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) if [ "$LD_VERSION" -ge "$LD_NO_DL_MIN_VERSION" ] ; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 	nodl="--no-dynamic-linker"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) platformo=$object/"$platform".o
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) lds=$object/zImage.lds
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) ext=strip
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) objflags=-S
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) tmp=$tmpdir/zImage.$$.o
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) ksection=.kernel:vmlinux.strip
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) isection=.kernel:initrd
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) esection=.kernel:esm_blob
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) link_address='0x400000'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) make_space=y
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) if [ -n "$esm_blob" -a "$platform" != "pseries" ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235)     echo "ESM blob not support on non-pseries platforms" >&2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236)     exit 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) case "$platform" in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) of)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241)     platformo="$object/of.o $object/epapr.o"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242)     make_space=n
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243)     ;;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) pseries)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245)     platformo="$object/pseries-head.o $object/of.o $object/epapr.o"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246)     link_address='0x4000000'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247)     if [ "$format" != "elf32ppc" ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 	link_address=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 	pie=-pie
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250)     fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251)     make_space=n
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252)     ;;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) maple)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254)     platformo="$object/of.o $object/epapr.o"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255)     link_address='0x400000'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256)     make_space=n
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257)     ;;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) pmac|chrp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259)     platformo="$object/of.o $object/epapr.o"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260)     make_space=n
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261)     ;;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) coff)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263)     platformo="$object/crt0.o $object/of.o $object/epapr.o"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264)     lds=$object/zImage.coff.lds
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265)     link_address='0x500000'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266)     make_space=n
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267)     pie=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268)     ;;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) miboot|uboot*)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270)     # miboot and U-boot want just the bare bits, not an ELF binary
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271)     ext=bin
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272)     objflags="-O binary"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273)     tmp="$ofile"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274)     ksection=image
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275)     isection=initrd
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276)     ;;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) cuboot*)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278)     binary=y
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279)     compression=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280)     case "$platform" in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281)     *-mpc866ads|*-mpc885ads|*-adder875*|*-ep88xc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282)         platformo=$object/cuboot-8xx.o
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283)         ;;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284)     *5200*|*-motionpro)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285)         platformo=$object/cuboot-52xx.o
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286)         ;;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287)     *-pq2fads|*-ep8248e|*-mpc8272*|*-storcenter)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288)         platformo=$object/cuboot-pq2.o
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289)         ;;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290)     *-mpc824*)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291)         platformo=$object/cuboot-824x.o
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292)         ;;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293)     *-mpc83*|*-asp834x*)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294)         platformo=$object/cuboot-83xx.o
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295)         ;;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296)     *-tqm8541|*-mpc8560*|*-tqm8560|*-tqm8555|*-ksi8560*)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297)         platformo=$object/cuboot-85xx-cpm2.o
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298)         ;;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299)     *-mpc85*|*-tqm85*|*-sbc85*)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300)         platformo=$object/cuboot-85xx.o
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301)         ;;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302)     *-amigaone)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303)         link_address='0x800000'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304)         ;;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305)     esac
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306)     ;;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) ps3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308)     platformo="$object/ps3-head.o $object/ps3-hvcall.o $object/ps3.o"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309)     lds=$object/zImage.ps3.lds
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310)     compression=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311)     ext=bin
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312)     objflags="-O binary --set-section-flags=.bss=contents,alloc,load,data"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313)     ksection=.kernel:vmlinux.bin
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314)     isection=.kernel:initrd
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315)     link_address=''
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316)     make_space=n
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317)     pie=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318)     ;;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) ep88xc|ep405|ep8248e)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320)     platformo="$object/fixed-head.o $object/$platform.o"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321)     binary=y
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322)     ;;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) adder875-redboot)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324)     platformo="$object/fixed-head.o $object/redboot-8xx.o"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325)     binary=y
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326)     ;;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) simpleboot-*)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328)     platformo="$object/fixed-head.o $object/simpleboot.o"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329)     binary=y
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330)     ;;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) asp834x-redboot)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332)     platformo="$object/fixed-head.o $object/redboot-83xx.o"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333)     binary=y
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334)     ;;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) xpedite52*)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336)     link_address='0x1400000'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337)     platformo=$object/cuboot-85xx.o
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338)     ;;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) gamecube|wii)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340)     link_address='0x600000'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341)     platformo="$object/$platform-head.o $object/$platform.o"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342)     ;;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) treeboot-currituck)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344)     link_address='0x1000000'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345)     ;;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) treeboot-akebono)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347)     link_address='0x1000000'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348)     ;;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) treeboot-iss4xx-mpic)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350)     platformo="$object/treeboot-iss4xx.o"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351)     ;;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) epapr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353)     platformo="$object/pseries-head.o $object/epapr.o $object/epapr-wrapper.o"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354)     link_address='0x20000000'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355)     pie=-pie
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356)     ;;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) mvme5100)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358)     platformo="$object/fixed-head.o $object/mvme5100.o"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359)     binary=y
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360)     ;;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) mvme7100)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362)     platformo="$object/motload-head.o $object/mvme7100.o"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363)     link_address='0x4000000'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364)     binary=y
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365)     ;;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) esac
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) vmz="$tmpdir/`basename \"$kernel\"`.$ext"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) # Calculate the vmlinux.strip size
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) ${CROSS}objcopy $objflags "$kernel" "$vmz.$$"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) strip_size=$(${CONFIG_SHELL} "${srctree}/scripts/file-size.sh" "$vmz.$$")
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) if [ -z "$cacheit" -o ! -f "$vmz$compression" -o "$vmz$compression" -ot "$kernel" ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375)     # recompress the image if we need to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376)     case $compression in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377)     .xz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378)         xz --check=crc32 -f -6 "$vmz.$$"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379)         ;;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380)     .gz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381)         gzip -n -f -9 "$vmz.$$"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382)         ;;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383)     .lzma)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384)         xz --format=lzma -f -6 "$vmz.$$"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) 	;;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386)     .lzo)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387)         lzop -f -9 "$vmz.$$"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) 	;;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389)     *)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390)         # drop the compression suffix so the stripped vmlinux is used
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391)         compression=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) 	uboot_comp=none
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) 	;;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394)     esac
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396)     if [ -n "$cacheit" ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) 	mv -f "$vmz.$$$compression" "$vmz$compression"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398)     else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) 	vmz="$vmz.$$"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400)     fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402)     rm -f $vmz.$$
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) vmz="$vmz$compression"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) if [ "$make_space" = "y" ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) 	# Round the size to next higher MB limit
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) 	round_size=$(((strip_size + 0xfffff) & 0xfff00000))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) 	round_size=0x$(printf "%x" $round_size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) 	link_addr=$(printf "%d" $link_address)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) 	if [ $link_addr -lt $strip_size ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) 	    echo "INFO: Uncompressed kernel (size 0x$(printf "%x\n" $strip_size))" \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) 			"overlaps the address of the wrapper($link_address)"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) 	    echo "INFO: Fixing the link_address of wrapper to ($round_size)"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) 	    link_address=$round_size
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) 	fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) # Extract kernel version information, some platforms want to include
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) # it in the image header
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) version=`${CROSS}strings "$kernel" | grep '^Linux version [-0-9.]' | \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425)     cut -d' ' -f3`
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) if [ -n "$version" ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427)     uboot_version="-n Linux-$version"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) # physical offset of kernel image
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) membase=`${CROSS}objdump -p "$kernel" | grep -m 1 LOAD | awk '{print $7}'`
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) case "$platform" in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) uboot)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435)     rm -f "$ofile"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436)     ${MKIMAGE} -A ppc -O linux -T kernel -C $uboot_comp -a $membase -e $membase \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) 	$uboot_version -d "$vmz" "$ofile"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438)     if [ -z "$cacheit" ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) 	rm -f "$vmz"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440)     fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441)     exit 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442)     ;;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) uboot-obs600)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444)     rm -f "$ofile"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445)     # obs600 wants a multi image with an initrd, so we need to put a fake
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446)     # one in even when building a "normal" image.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447)     if [ -n "$initrd" ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) 	real_rd="$initrd"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449)     else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) 	real_rd=`mktemp`
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) 	echo "\0" >>"$real_rd"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452)     fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453)     ${MKIMAGE} -A ppc -O linux -T multi -C gzip -a $membase -e $membase \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) 	$uboot_version -d "$vmz":"$real_rd":"$dtb" "$ofile"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455)     if [ -z "$initrd" ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) 	rm -f "$real_rd"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457)     fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458)     if [ -z "$cacheit" ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) 	rm -f "$vmz"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460)     fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461)     exit 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462)     ;;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) esac
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) addsec() {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466)     ${CROSS}objcopy $4 $1 \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) 	--add-section=$3="$2" \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) 	--set-section-flags=$3=contents,alloc,load,readonly,data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) addsec $tmp "$vmz" $ksection $object/empty.o
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) if [ -z "$cacheit" ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473)     rm -f "$vmz"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) if [ -n "$initrd" ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477)     addsec $tmp "$initrd" $isection
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) if [ -n "$dtb" ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481)     addsec $tmp "$dtb" .kernel:dtb
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482)     if [ -n "$dts" ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) 	rm $dtb
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484)     fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) if [ -n "$esm_blob" ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488)     addsec $tmp "$esm_blob" $esection
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) if [ "$platform" != "miboot" ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492)     if [ -n "$link_address" ] ; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493)         text_start="-Ttext $link_address"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494)     fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) #link everything
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496)     ${CROSS}ld -m $format -T $lds $text_start $pie $nodl -o "$ofile" $map \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) 	$platformo $tmp $object/wrapper.a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498)     rm $tmp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) # Some platforms need the zImage's entry point and base address
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) base=0x`${CROSS}nm "$ofile" | grep ' _start$' | cut -d' ' -f1`
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) entry=`${CROSS}objdump -f "$ofile" | grep '^start address ' | cut -d' ' -f3`
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505) if [ -n "$binary" ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506)     mv "$ofile" "$ofile".elf
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507)     ${CROSS}objcopy -O binary "$ofile".elf "$ofile"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) # post-processing needed for some platforms
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) case "$platform" in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) pseries|chrp|maple)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513)     $objbin/addnote "$ofile"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514)     ;;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) coff)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516)     ${CROSS}objcopy -O aixcoff-rs6000 --set-start "$entry" "$ofile"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517)     $objbin/hack-coff "$ofile"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518)     ;;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519) cuboot*)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520)     gzip -n -f -9 "$ofile"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521)     ${MKIMAGE} -A ppc -O linux -T kernel -C gzip -a "$base" -e "$entry" \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522)             $uboot_version -d "$ofile".gz "$ofile"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523)     ;;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524) treeboot*)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525)     mv "$ofile" "$ofile.elf"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526)     $objbin/mktree "$ofile.elf" "$ofile" "$base" "$entry"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527)     if [ -z "$cacheit" ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528) 	rm -f "$ofile.elf"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529)     fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530)     exit 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531)     ;;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532) ps3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533)     # The ps3's loader supports loading a gzipped binary image from flash
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534)     # rom to ram addr zero. The loader then enters the system reset
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535)     # vector at addr 0x100.  A bootwrapper overlay is used to arrange for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536)     # a binary image of the kernel to be at addr zero, and yet have a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537)     # suitable bootwrapper entry at 0x100.  To construct the final rom
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538)     # image 512 bytes from offset 0x100 is copied to the bootwrapper
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539)     # place holder at symbol __system_reset_kernel.  The 512 bytes of the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 540)     # bootwrapper entry code at symbol __system_reset_overlay is then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541)     # copied to offset 0x100.  At runtime the bootwrapper program copies
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542)     # the data at __system_reset_kernel back to addr 0x100.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544)     system_reset_overlay=0x`${CROSS}nm "$ofile" \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545)         | grep ' __system_reset_overlay$'       \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546)         | cut -d' ' -f1`
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547)     system_reset_overlay=`printf "%d" $system_reset_overlay`
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548)     system_reset_kernel=0x`${CROSS}nm "$ofile" \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549)         | grep ' __system_reset_kernel$'       \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 550)         | cut -d' ' -f1`
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 551)     system_reset_kernel=`printf "%d" $system_reset_kernel`
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 552)     overlay_dest="256"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 553)     overlay_size="512"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 554) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 555)     ${CROSS}objcopy -O binary "$ofile" "$ofile.bin"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 556) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 557)     run_cmd dd if="$ofile.bin" of="$ofile.bin" conv=notrunc   \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 558)         skip=$overlay_dest seek=$system_reset_kernel          \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 559)         count=$overlay_size bs=1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 560) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 561)     run_cmd dd if="$ofile.bin" of="$ofile.bin" conv=notrunc   \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 562)         skip=$system_reset_overlay seek=$overlay_dest         \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 563)         count=$overlay_size bs=1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 564) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 565)     odir="$(dirname "$ofile.bin")"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 566) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 567)     # The ps3's flash loader has a size limit of 16 MiB for the uncompressed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 568)     # image.  If a compressed image that exceeded this limit is written to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 569)     # flash the loader will decompress that image until the 16 MiB limit is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 570)     # reached, then enter the system reset vector of the partially decompressed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 571)     # image.  No warning is issued.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 572)     rm -f "$odir"/{otheros,otheros-too-big}.bld
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 573)     size=$(${CROSS}nm --no-sort --radix=d "$ofile" | egrep ' _end$' | cut -d' ' -f1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 574)     bld="otheros.bld"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 575)     if [ $size -gt $((0x1000000)) ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 576)         bld="otheros-too-big.bld"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 577)     fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 578)     gzip -n --force -9 --stdout "$ofile.bin" > "$odir/$bld"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 579)     ;;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 580) esac