[U-Boot] initcall revisited - A new idea to discuss

Graeme Russ graeme.russ at gmail.com
Mon Jan 2 12:53:31 CET 2012


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


More information about the U-Boot mailing list