linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/6] bootwrapper: arch/powerpc/boot code reorg patches
@ 2006-07-19 22:53 Mark A. Greer
  2006-07-22 15:04 ` Tom Rini
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Mark A. Greer @ 2006-07-19 22:53 UTC (permalink / raw)
  To: linuxppc-dev

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
# <mgreer@mvista.com>
#
# 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

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2006-09-08  3:32 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-07-19 22:53 [PATCH 0/6] bootwrapper: arch/powerpc/boot code reorg patches Mark A. Greer
2006-07-22 15:04 ` Tom Rini
2006-08-08 19:14 ` Mark A. Greer
2006-08-15 19:37   ` Hollis Blanchard
2006-08-18 21:46     ` Mark A. Greer
2006-08-18 21:41       ` Jon Loeliger
2006-09-08  3:32 ` Mark A. Greer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).