Skip to content

bootwrapper: arch/powerpc/boot code reorg patches

Mark A. Greer linuxppc-dev 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest6 patches 58 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/6bootwrapper: arch/powerpc/boot code reorgarch/powerpc/boot/main.c arch/powerpc/boot/ops.h arch/powerpc/boot/stdio.c +1 more+248 -12118 replies
2/6bootwrapper: Add in OF operations (and rename to of.c)arch/powerpc/boot/Makefile arch/powerpc/boot/of.c arch/powerpc/boot/prom.c +1 more+305 -2071 reply
3/6bootwrapper: Add device tree ops for flattened device treearch/powerpc/boot/Makefile arch/powerpc/boot/fdt.c+526 -116 replies
4/6bootwrapper: Add non-OF serial console supportarch/powerpc/boot/io.h arch/powerpc/boot/ns16550.c arch/powerpc/boot/serial.c +1 more+360 -03 replies
5/6bootwrapper: Add support for the DINK firmwarearch/powerpc/boot/dink.c+56 -06 replies
6/6bootwrapper: Add support for the sandpoint platformarch/powerpc/boot/Makefile arch/powerpc/boot/mpc10x.c arch/powerpc/boot/sandpoint.c+259 -08 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/6] bootwrapper: arch/powerpc/boot code reorg patches

Hi,

The following emails from me in this thread are the latest set of patches that reorg the bootwrapper code so that OF and non-OF platforms can live together.

I punted somewhat on "The Tool" that's been talked about that takes a kernel and attaches a flattened device tree (fdt) to it. I thought about it for a while but I think we need to clarify the requirements better before it makes sense to spend a lot of cycles on it.

In the interim, dt_blob_start defined in arch/powerpc/boot/main.c allocates 8KB in a separate ELF section called '__builtin_fdt'. You can then 'dd' a dtb generated by the dtc utility directly into that section and it the bootwrapper will use it. I tried playing with loader scripts so that the section could be deleted and a new, larger one added (and that preserves all the alignments, etc. in the zImage) but couldn't figure out the magic so I've given up for now.

I hope that after OLS (or during?), "The Tool" will be discussed and we can get that finished. Unless what I've done is good enough but I doubt it...

Notes:
- These patches will collide with Milton Miller's kexec patches but they haven't been accepted yet so I didn't put my patches on top of them.
- Below is the script that I use to copy a dtb into the __builtin_fdt section of a zImage so that non-OF machines can use the zImage. Its basically a hack of the script that Michal Ostrowski provided for copying a new cmdline to an ELF section.

Mark
--

#!/bin/bash
#
# Copyright (C) 2006 Michal Ostrowski <mostrows at watson.ibm.com <https://ozlabs.org/mailman/listinfo/linuxppc-dev>>, IBM Corp. #
# Modified to put a dtb into the "__builtin_fdt" section by Mark A. Greer
# <[email protected]>
#
# This program is free software; you can redistribute it and/or modify

# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA

usage(){
echo 'set_builtin_fdt [--fdt <file>] <input_obj> [<output_obj>]'
echo ' Sets the builtin command line embedded in an object file.'
echo
echo ' If <output_obj> is not specified, <input_obj> is modified'
echo ' in place.'
echo ' If --fdt <file> argument is present contents of embedded'
echo ' command line will be copied from <file>, otherwise from stdin.'
exit 1
}

fdt_file=

while case "$#" in 0) break ;; esac
do

        case "$1" in
        --fdt)
		case "$#" in
		    1)
			usage ;;
		    *)
			fdt_file="$2";
			shift;;
		esac;;
        *)
                set x "$@"
                shift
                break ;;
        esac
        shift

done

if [ "$#" -lt 1 ]; then

    echo "No input object specified." ; 
    usage;

fi

if [ "$#" -gt 2 ]; then

    echo "Unrecognized arguments: $@";
    usage;

fi

infile=$1
shift;

if [ ! -r "$infile" ] ; then

    echo "Can't read '$infile'."; 
    usage;

fi

if [ "$#" -eq 0 ] ; then

    outfile=$infile;
else
    outfile=$1;
    if ! cp $infile $outfile ;  then
	echo "Can't create output: '$outfile' $?" 
	usage;
    fi
    shift;

fi

offset=$(objdump -h  $infile | \
         gawk -- '{if($2=="__builtin_fdt") {print strtonum("0x" $6);}}')
size=$(objdump -h  $infile | \
       gawk -- '{if($2=="__builtin_fdt") {print strtonum("0x" $3);}}')

if [ "x$offset" != "x" ] ; then
if [ "$offset" -ne 0 ] ; then
set -e
# Zero the destination buffer first
exec 2>/dev/null
dd if=$fdt_file of=$outfile bs=1 seek=$offset conv=notrunc count=$size exit $?
fi
fi