From: David Gibson <david@gibson.dropbear.id.au>
To: Jerry Van Baren <gerald.vanbaren@smiths-aerospace.com>
Cc: linuxppc-dev@ozlabs.org, jdl@jdl.com,
Jerry Van Baren <gvb.uboot@gmail.com>
Subject: Re: [PATCH: dtc] Improve -S handling
Date: Thu, 19 Apr 2007 10:18:10 +1000 [thread overview]
Message-ID: <20070419001810.GA4193@localhost.localdomain> (raw)
In-Reply-To: <46260EB6.6010506@smiths-aerospace.com>
On Wed, Apr 18, 2007 at 08:27:34AM -0400, Jerry Van Baren wrote:
> David Gibson wrote:
> > On Wed, Apr 18, 2007 at 01:05:28PM +1000, David Gibson wrote:
> >> On Tue, Apr 17, 2007 at 10:05:35PM -0400, Jerry Van Baren wrote:
> >>> If the user requests extra space, pad out the blob (previously the unused
> >>> data was undefined).
> >>>
> >>> Signed-off-by: Gerald Van Baren <vanbaren@cideas.com>
> >>> ---
> >>>
> >>> Hi Jon, David, Milton,
> >>>
> >>> This improves the -S option to pad out the blob with zeros when the user
> >>> asks for extra space.
> >> Comment below
> >>> diff --git a/flattree.c b/flattree.c
> >>> index 151d16e..d2ee0dc 100644
> >>> --- a/flattree.c
> >>> +++ b/flattree.c
> >>> @@ -310,6 +310,7 @@ static struct data flatten_reserve_list(struct reserve_info *reservelist,
> >>>
> >>> return d;
> >>> }
> >>> +
> >>> static void make_bph(struct boot_param_header *bph,
> >>> struct version_info *vi,
> >>> int reservesize, int dtsize, int strsize,
> >>> @@ -358,12 +359,15 @@ void dt_to_blob(FILE *f, struct boot_info *bi, int version,
> >>> {
> >>> struct version_info *vi = NULL;
> >>> int i;
> >>> + int size;
> >>> struct data dtbuf = empty_data;
> >>> struct data strbuf = empty_data;
> >>> struct data reservebuf;
> >>> struct boot_param_header bph;
> >>> struct reserve_entry termre = {.address = 0, .size = 0};
> >>>
> >>> + size = 0;
> >>> +
> >
> > Oh, also, you shouldn't need this new variable to track the size.
> > Just use whatever expression we used to use for totalsize before we
> > forced it out to the minimum size.
>
> It was simpler that way. Much simpler. With the calculated version, I
> had to know the header size and re-calculate all the alignment gaps.
> Ugly and nasty (respectively and collectively).
Hrm.. but we already did all that calculation in make_bph().
Here's a revised idea: with -S, instead of overriding the totalsize
header field directly in make_bph(), instead revert that function to
always computing the "natural minimum" size of the blob. Then do the
-S handling in dt_to_blob() instead: compute the number of padding
bytes necessary from make_bph()'s totalsize value, then overwrite the
totalsize field with the expanded value.
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
next prev parent reply other threads:[~2007-04-19 0:18 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-04-18 2:05 [PATCH: dtc] Improve -S handling Jerry Van Baren
2007-04-18 3:05 ` David Gibson
2007-04-18 6:45 ` David Gibson
2007-04-18 12:27 ` Jerry Van Baren
2007-04-19 0:18 ` David Gibson [this message]
2007-04-18 12:19 ` Jerry Van Baren
2007-04-19 1:42 ` David Gibson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20070419001810.GA4193@localhost.localdomain \
--to=david@gibson.dropbear.id.au \
--cc=gerald.vanbaren@smiths-aerospace.com \
--cc=gvb.uboot@gmail.com \
--cc=jdl@jdl.com \
--cc=linuxppc-dev@ozlabs.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).