Subject: Re: foo_init()s in main() [was: CVS commit: src/sys]
To: Rhialto <>
From: Jachym Holecek <>
List: tech-kern
Date: 11/25/2005 23:33:58
> On Tue 22 Nov 2005 at 10:29:17 +0100, wrote:
> > The only question for NetBSD adoption is, whether any architecture still
> > has a non-ELF kernel. I don't mean the format of the final image, but
> > whether the linkage is ELF. Depending on that, the work can be just used
> > or needs some work in ld for the specific format.
> Why not have config(8) generate a table with function pointers in the
> correct order, to be called from main() (or whereever)?
> Another option is to make the linker do the same as what it does for C++
> global constructors, except that their order isn't specified. (or is
> that those 'link sets' that were mentioned?)

Any explicit order-dependency of subsystem modules should be expressed
at config(8) level IMO. So the point of the idea can ("should be") be
quite simple to implement using either approach you mentioned. It boils
down to correct 'machine/${foo}.h' definition of 'SUBSYSTEM_{INIT,EXIT}'
or alike.

BTW, this functionality is needed to implement the 'pinbus' idea briefly
discussed at tech-embed a couple of months ago (around Jan-Apr 2004?) in
a clean way. To recall the main point, that would allow all bitbang
interfaces (ie. IIC, MII, character LCDs, various EEPROMs, ...) to
operate over a common API, instead of a number of bus-specific callback
APIs. To get the most flexibility, we would need to be able to mark
a driver as "needs to be matched after all ${foobus} providers known upto
now" have been given a chance to attach -- a generalized "config_defer()
for the benefit of a generalized gpio(4)" in essence.

		-- Jachym Holecek