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] initcall revisited - A new idea to discuss
Date: Mon, 02 Jan 2012 22:53:31 +1100	[thread overview]
Message-ID: <4F019ABB.9010201@gmail.com> (raw)

Hi All,

I've been thinking about the renaissance of the arch-independent
initialisation sequence that has been generating a somewhat 'warm'
discussion lately and had a thought based on a comment passed on by
Wolfgang from Detlev:

"basicly what we are trying to solve is a dependency issue: each init
function has a list of dependencies (other init steps) that need to be run
before"

Which got me to thinking, what if we had an initcall macro which included
the dependency information. Imagine this rough example:

	set_reloc_flag_r,
	init_bd_struct_r,
	mem_malloc_init_r,
	cpu_init_r,
	board_early_init_r,
	dram_init,
	interrupt_init,
	timer_init,
	display_banner,
	display_dram_config,

'display_banner' (for the sake of this example) needs 'dram_init' and
'board_early_init_r' while 'timer_init' needs 'interrupt_init'

Now lets imagine a macro which we use thusly:

int display_banner(void)
{
...
}
INITCALL(display_banner, "banner", "dram,board_early")

Which says that the display_banner() function, when completed fulfils the
'banner' dependency, and requires both the 'dram' and 'board_early'
dependencies to be fulfilled in order to run

We may also have...

int serial_initialize_r(void)
{
...
}
INITCALL(serial_initialize_r, "serial,console", "environment")

int console_init_r(void)
{
...
}
INITCALL(console_init_r, "console", "serial")

So anything requiring 'console' must happen after both serial_initialize_r
and console_init_r (yes, this is a trivial example, but it's the best I can
come up with)

So how do we implement it...

If the INITCALL macro can place the parameter data in a separate section in
the object file, and this data gets amalgamated into the libraries, we
should be able to pull the information out during the build process.

So the build process builds all the libraries, but before the final link,
we autogenerate the 'init sequence' array using a fancy 'tool' which scans
all the libraries and builds the init sequence in order to satisfy all the
dependencies or throws an error if the dependencies cannot be met like:

'console_init_r' requires 'serial' but there are no 'serial' init functions

or

'circular reference - 'serial' requires 'console' requires 'serial'

etc.

Thoughts?

Regards,

Graeme

             reply	other threads:[~2012-01-02 11:53 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-02 11:53 Graeme Russ [this message]
2012-01-02 14:49 ` [U-Boot] initcall revisited - A new idea to discuss Wolfgang Denk
2012-01-03 10:37   ` Graeme Russ
2012-01-03 14:44     ` Wolfgang Denk
2012-01-03 21:53       ` Graeme Russ
2012-01-05 22:18       ` Graeme Russ
2012-01-06  4:30         ` Simon Glass
2012-01-06  4:59           ` Graeme Russ
2012-01-06  5:41             ` Hebbar, Gururaja
2012-01-06  6:35               ` Wolfgang Denk
     [not found]                 ` <1BAFE6F6C881BF42822005164F1491C305D08F@DBDE01.ent.ti.com>
2012-01-07 22:39                   ` Simon Glass
2012-01-08 11:59                     ` Graeme Russ
2012-01-06  6:30             ` Wolfgang Denk
2012-01-03 16:04     ` Simon Glass
2012-01-03 22:36       ` Wolfgang Denk
2012-01-03 22:43         ` Simon Glass

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=4F019ABB.9010201@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