public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Graeme Russ <graeme.russ@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] RFC: Aligning arch initialisation sequences
Date: Sun, 14 Nov 2010 21:21:53 +1100	[thread overview]
Message-ID: <4CDFB841.9050708@gmail.com> (raw)
In-Reply-To: <20101114090416.E560814EA7E@gemini.denx.de>

On 14/11/10 20:04, Wolfgang Denk wrote:
> Dear Graeme Russ,
> 
> In message <4CDF36E3.7060505@gmail.com> you wrote:
>>
>> board_early_init_f() is (in most cases) the very first entry in the
>> init_sequence[]
> 
> Right.
> 
>> So if global data is defined on the stack in board_init_f() and copied to
>> the heap at the end of board_init_f() we should be OK. Is global data
>> needed prior to board_init_f()?
> 
> Yes, as we have no writable data segmeit before relocation. We need a
> way to pass around some data.
> 
>> For x86, I allocate global data in asm and set three members. The sticking
>> point for me is the single ulong parameter to board_init_f() which does not
>> present enough flexibility to pass all the information I need.
> 
> Pass a pointer to a struct ?

Which is what I do (a pointer to a gd_t allocated in asm)

There are two minor perceived 'issues' with board_init_f()
 1) The parameter is defined as a 'ulong bootflag'
    - arm, blackfin, mips, and powerpc do not use the parameter at all
    - avr redefines it as 'ulong board_type'
    - x86 uses it as a gd_t *
    - m68k and sparc use it as bootflag
    - microblaze and nios2 do not even use board_init_f() (they defines
there own board_init(void)
    - sh is like microblaze and nios2 but defines sh_generic_init()

 2) At least one list member does not like the allocation of global data in
asm and suggests that it should be on the stack of board_init_f() and
copied to the heap at the end of board_init_f() (NOTE: there was some
confusion with board_early_init_f(), but I think the discussion always
intended to focus on board_init_f())

and a few other inconsistencies:
 - blackfin and avr do not use init_sequence[] (but look like they could)
 - blackfin has an interesting (read wrong) comment:
   * The requirements for any new initalization function is simple: it
   * receives a pointer to the "global data" structure as it's only
   * argument, and returns an integer return code, where 0 means
   * "continue" and != 0 means "fatal error, hang the system".
 -

Why don't we just change board_init_f(ulong bootflag) to board_init_f(gd_t
*gd)? avr would need a slight mod to add board_type to gd_t. m68k and sparc
would need similar to add bootflag

So start.S would calculate the location of the initial global data struct
(in cache, SRAM, Flash etc) and pass this to board_init_f(). A lot of
arches would just pass a constant (arm would pass CONFIG_SYS_INIT_SP_ADDR
for example)

> 
>> One nit-pick is that, in reality, the stack space used by board_init_f() is
>> never reclaimed because it never returns. What we could do is reset the
>> stack pointer prior to calling board_init_r()
> 
> This is not correct. After relocation, we set up a completely new
> stack in RAM.

Ah, OK - x86 does not, but after the realignment of x86 to the other
arches, I will do this as well

Regards,

Graeme

  reply	other threads:[~2010-11-14 10:21 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-07 10:06 [U-Boot] RFC: Aligning arch initialisation sequences Graeme Russ
2010-11-09 23:35 ` Mike Frysinger
2010-11-13  4:16   ` Graeme Russ
2010-11-13  4:58     ` Mike Frysinger
2010-11-13  6:31     ` Reinhard Meyer
2010-11-13  6:38       ` Reinhard Meyer
2010-11-13  9:51         ` Graeme Russ
2010-11-13  8:17       ` Wolfgang Denk
2010-11-13 21:35         ` Reinhard Meyer
2010-11-13 21:53           ` Wolfgang Denk
2010-11-13 22:38             ` Reinhard Meyer
2010-11-13 22:45               ` Wolfgang Denk
2010-11-13 22:48                 ` Reinhard Meyer
2010-11-14  0:07                   ` Wolfgang Denk
2010-11-14  0:25                     ` Graeme Russ
2010-11-14  0:35                       ` Wolfgang Denk
2010-11-14  1:09                         ` Graeme Russ
2010-11-14  9:04                           ` Wolfgang Denk
2010-11-14 10:21                             ` Graeme Russ [this message]
2010-11-14 19:43                               ` Graeme Russ
2010-11-14  4:07                         ` Reinhard Meyer
2010-11-14  9:07                           ` Wolfgang Denk
2010-11-14 13:46                           ` Reinhard Meyer
2010-11-14 19:36                             ` Graeme Russ
2010-11-14 20:16                               ` Reinhard Meyer
2010-11-14 21:01                                 ` Graeme Russ
2010-11-13  8:20     ` Albert ARIBAUD
2010-11-13 11:18       ` Graeme Russ
2010-11-14  5:10         ` Graeme Russ
2010-11-14  5:48           ` Graeme Russ
2010-11-14  9:16             ` Albert ARIBAUD
2010-11-14 10:30               ` Wolfgang Denk
2010-11-14 12:10                 ` Albert ARIBAUD
2010-11-14 15:01                   ` Wolfgang Denk
2010-11-14 17:53                     ` Albert ARIBAUD
2010-11-14 19:06                       ` Wolfgang Denk
2010-11-14 19:29                         ` Albert ARIBAUD
2010-11-14 19:55                           ` Wolfgang Denk
2010-11-14 20:10                             ` Albert ARIBAUD
2010-11-14 20:42                               ` Wolfgang Denk
2010-11-14 19:23                       ` Wolfgang Denk
2010-11-14 19:34                         ` Graeme Russ
2010-11-14 20:05                           ` Albert ARIBAUD
2010-11-14 21:27                             ` Graeme Russ
2010-11-15 11:08                             ` Graeme Russ
2010-11-14 21:51   ` Wolfgang Denk

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=4CDFB841.9050708@gmail.com \
    --to=graeme.russ@gmail.com \
    --cc=u-boot@lists.denx.de \
    /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