mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Trent Piepho <tpiepho@kymetacorp.com>
Cc: "barebox@lists.infradead.org" <barebox@lists.infradead.org>
Subject: Re: [PATCH] Add support for Baltos systems
Date: Wed, 1 Jun 2016 09:23:10 +0200	[thread overview]
Message-ID: <20160601072310.GK31666@pengutronix.de> (raw)
In-Reply-To: <1464720425.15779.86.camel@rtred1test09.kymeta.local>

On Tue, May 31, 2016 at 06:46:57PM +0000, Trent Piepho wrote:
> On Fri, 2016-05-27 at 15:48 +0200, yegorslists@googlemail.com wrote:
> 
> > +
> > +/**
> > + * @brief The basic entry point for board initialization.
> > + *
> > + * This is called as part of machine init (after arch init).
> > + * This is again called with stack in SRAM, so not too many
> > + * constructs possible here.
> > + *
> > + * @return void
> > + */
> 
> Does anyone (Sascha?) know why this is noline?  Obviously it is being
> copied from the all the other boards that do this, and the only thing it
> can be doing is preventing this from being inlined into the entry
> function.  But why must this be prevented?

Only after calling relocate_to_current_adr() / setup_c() the C
environment is correctly initialized. Before that for example pointers
to global variables are not valid. The following does not work:

ENTRY_FUNCTION(start_am33xx_baltos_sram, bootinfo, r1, r2)
{
	void *fdt = __dtb_am335x_baltos_minimal_start;

	relocate_to_current_adr();
	setup_c();

	barebox_arm_entry(0x80000000, sdram_size, fdt);
}

Wenn entering start_am33xx_baltos_sram() we do not run at the address we
are linked at, so *fdt will have the offset between link address and
actual runtime address in it. Basically we must make sure that *fdt is
initialized *after* calling relocate_to_current_adr()/setup_c(). The same
might happen when create an extra function but let the compiler inline it:

static inline void cont(void)
{
	void *fdt = __dtb_am335x_baltos_minimal_start;

	barebox_arm_entry(0x80000000, sdram_size, fdt);
}

ENTRY_FUNCTION(start_am33xx_baltos_sram, bootinfo, r1, r2)
{
	relocate_to_current_adr();
	setup_c();

	cont();
}

This doesn't happen when we explicitly noinline cont().

The compiler simply doesn't know about the dirty tricks we play in
relocate_to_current_adr() and setup_c().

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:[~2016-06-01  7:23 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-27 13:48 yegorslists
2016-05-30  5:33 ` Sascha Hauer
2016-05-30  9:46   ` Yegor Yefremov
2016-05-31  7:01     ` Sascha Hauer
2016-05-31  7:08       ` Yegor Yefremov
2016-05-31 18:46 ` Trent Piepho
2016-06-01  7:23   ` Sascha Hauer [this message]

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=20160601072310.GK31666@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=tpiepho@kymetacorp.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