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

Graeme Russ graeme.russ at gmail.com
Tue Jan 3 11:37:24 CET 2012


Hi Wolfgang,

On 03/01/12 01:49, Wolfgang Denk wrote:
> Dear Graeme Russ,
> 
> In message <4F019ABB.9010201 at gmail.com> you wrote:
>>
>> Which got me to thinking, what if we had an initcall macro which included
>> the dependency information. Imagine this rough example:
> ...
>> 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
> 
> Sounds great!

OK, I think I can do this...

#define INIT_FUNC(fn, stage, reqs, prereqs, postreqs) \
	static const char *__initfunc_ ## fn __used \
	__attribute__((__section__(".initfuncs"))) = \
	#stage ":" #fn ":" #reqs ":" #prereqs ":" #postreqs

'postreq' are requisite functions that the given function must be run
before (USB init priot to console if using a USB serial dongle for example)

Then:

INIT_FUNC(cpu_init_f, f, "fred", "blah", "foo");

Generates the string:
f:cpu_init_f:"fred":"blah":"foo"

and we can parse each of the elf archives to obtain a list of string
pointers from the .initfuncs, extract the strings and process them to
generate the init arrays

and add:

	/DISCARD/ : { *(.initfuncs*) }

to the linker script to throw away the strings

It's a tad ugly under the hood, but the output will be very clean

Does this sound like a plan?

Regards,

Graeme


More information about the U-Boot mailing list