From mboxrd@z Thu Jan 1 00:00:00 1970 From: Graeme Russ Date: Tue, 03 Jan 2012 21:37:24 +1100 Subject: [U-Boot] initcall revisited - A new idea to discuss In-Reply-To: <20120102144904.A3F1082272@gemini.denx.de> References: <4F019ABB.9010201@gmail.com> <20120102144904.A3F1082272@gemini.denx.de> Message-ID: <4F02DA64.60502@gmail.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Hi Wolfgang, On 03/01/12 01:49, Wolfgang Denk wrote: > Dear Graeme Russ, > > In message <4F019ABB.9010201@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