mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH v2] bootm: update os_entry from uimage
Date: Mon, 23 Sep 2013 11:11:54 +0200	[thread overview]
Message-ID: <20130923091154.GA17135@pengutronix.de> (raw)
In-Reply-To: <20130923081243.GF31585@ns203013.ovh.net>

On Mon, Sep 23, 2013 at 10:12:43AM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
> On 10:07 Mon 23 Sep     , Jean-Christophe PLAGNIOL-VILLARD wrote:
> > On 08:33 Mon 23 Sep     , Sascha Hauer wrote:
> > > On Mon, Sep 23, 2013 at 06:40:25AM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > > > On 20:17 Sun 22 Sep     , Sascha Hauer wrote:
> > > > >  common/bootm.c | 2 ++
> > > > >  1 file changed, 2 insertions(+)
> > > > > 
> > > > > diff --git a/common/bootm.c b/common/bootm.c
> > > > > index 1987a09..4e62006 100644
> > > > > --- a/common/bootm.c
> > > > > +++ b/common/bootm.c
> > > > > @@ -73,6 +73,8 @@ static int bootm_open_os_uimage(struct image_data *data)
> > > > >  	if (data->os_address == UIMAGE_SOME_ADDRESS)
> > > > >  		data->os_address = data->os->header.ih_load;
> > > > >  
> > > > > +	data->os_entry = data->os->header.ih_ep - data->os->header.ih_load;
> > > > > +
> > > > >  	if (data->os_address != UIMAGE_INVALID_ADDRESS) {
> > > > >  		data->os_res = uimage_load_to_sdram(data->os, 0,
> > > > >  				data->os_address);
> > > > 
> > > > this does not work on INVALID_ADDRESS as this time teh ih_load is as
> > > > 0xffffffff and the ih_ep is relative not absolute
> > > 
> > > Right. How about this one then?
> > > 
> > > 
> > > From da3192d5c763361ec08a51ebaa3cc2c3884c9827 Mon Sep 17 00:00:00 2001
> > > From: Sascha Hauer <s.hauer@pengutronix.de>
> > > Date: Sun, 22 Sep 2013 19:51:53 +0200
> > > Subject: [PATCH] bootm: handle image entry point correctly
> > > 
> > > This fixes starting of uImages which have an entry point other than
> > > the load address.
> > > 
> > > The uImage format stores the entry point to the image in the ih_ep
> > > field. Normally it has the absolute address, so calculate the relative
> > > offset to the image start address and put it into data->os_entry. In
> > > case the uImage has a load address of 0xffffffff (UIMAGE_INVALID_ADDRESS)
> > > the entry point is stored relative to the image start, so just transfer
> > > it to data->os_address.
> > > 
> > > Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
> > > ---
> > >  common/bootm.c | 6 +++++-
> > >  1 file changed, 5 insertions(+), 1 deletion(-)
> > > 
> > > diff --git a/common/bootm.c b/common/bootm.c
> > > index 1987a09..16d3416 100644
> > > --- a/common/bootm.c
> > > +++ b/common/bootm.c
> > > @@ -73,7 +73,11 @@ static int bootm_open_os_uimage(struct image_data *data)
> > >  	if (data->os_address == UIMAGE_SOME_ADDRESS)
> > >  		data->os_address = data->os->header.ih_load;
> > >  
> > > -	if (data->os_address != UIMAGE_INVALID_ADDRESS) {
> > > +	if (data->os_address == UIMAGE_INVALID_ADDRESS) {
> > > +		data->os_entry = data->os->header.ih_ep;
> > > +	} else {
> > > +		data->os_entry = data->os->header.ih_ep -
> > > +			data->os->header.ih_load;
> > >  		data->os_res = uimage_load_to_sdram(data->os, 0,
> > >  				data->os_address);
> > >  		if (!data->os_res) {
> > 
> > same as my patch do
> 
> except one point you forget to reset data->os_entry in the case of a non
> uimage

To what should data->os_entry be resetted in the case of non uImage? The
code above is never executed for non uImages, so data->os_entry is never
modified in this case.

data->os_entry is expected to be an offset to the image start. Your
patch sets this to an absolute address first and adjusts this to an
offset later which is quite hard to read and understand.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  reply	other threads:[~2013-09-23  9:12 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-21 15:20 Jean-Christophe PLAGNIOL-VILLARD
2013-09-22 18:17 ` Sascha Hauer
2013-09-23  4:40   ` Jean-Christophe PLAGNIOL-VILLARD
2013-09-23  6:33     ` Sascha Hauer
2013-09-23  8:07       ` Jean-Christophe PLAGNIOL-VILLARD
2013-09-23  8:12         ` Jean-Christophe PLAGNIOL-VILLARD
2013-09-23  9:11           ` Sascha Hauer [this message]
2013-09-23  8:16 ` Jean-Christophe PLAGNIOL-VILLARD
2013-09-23  9:13   ` Sascha Hauer
2013-09-23 14:32     ` Jean-Christophe PLAGNIOL-VILLARD
2013-09-23 14:54       ` Sascha Hauer
2013-09-24  9:26         ` Jean-Christophe PLAGNIOL-VILLARD

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=20130923091154.GA17135@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=plagnioj@jcrosoft.com \
    /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