Hi Graham, On Tue, Jan 3, 2012 at 2:37 AM, Graeme Russ <graeme.r...@gmail.com> wrote: > Hi Wolfgang, > > On 03/01/12 01:49, Wolfgang Denk wrote: >> Dear Graeme Russ, >> >> In message <4f019abb.9010...@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?
Good with me - will be very interesting to see where this takes us. I have been thinking if there is a way we can avoid the post-processing perhaps by specifying two function parameters to the macro (the init function to call and its prerequisite) and having the initcall code sort the list before starting. We could have dummy functions to mark particular stages of interest to boards. But it can't deal with adding a new function as a prerequisite of an existing one without perhaps a third parameter. I haven't looked at the algorithm either... But I wonder if it would be possible for your macro to generate a table which includes the init function as well as the string? That way we get a compile warning and link error if the function doesn't exist. Regards, Simon > > Regards, > > Graeme _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot