Along the way, I discovered a little tidbit about how the tod (time of day) modules - the interface to the hardware clock - work on SPARC.
If you look, there are a whole bunch of tod modules, and it's not at all obvious how they fit together - they all appear to be candidates for loading, and it's not obvious how the correct one for a platform is chosen.
The mechanism is actually pretty simple, if a little odd.
There's a global variable in the kernel named:
tod_module_name
This can be set in several ways - for some platforms, it's hard-coded in that platform's platmod. Or it could be extracted from the firmware (OBP). That tells the system which tod module should be used.
And the way this works is that each tod module has _init code that looks like
if (tod_module_name is myself) {
initialize the driver
} else {
do nothing
}
so at boot all the tod modules get loaded, but only the one that matches the name set by the platform actually initializes itself.
Later in boot, there's an attempt to unload all modules. Similarly the _fini for each driver essentially does
if (tod_module_name is myself) {
I'm busy and can't be unloaded
} else {
yeah, unload me
}
So, when the system finishes booting, you end up with only one tod module loaded and functional, and it's the right one.
Returning to the original question, can any of the tod modules be safely removed because no platform uses them? To be honest, I don't know. Some have names that match the platform they're for. It's pretty obvious, for example, that todstarfire goes with the starfire platform, so it was safe to take that out. But I don't know the module names returned by every possible piece of SPARC hardware, so it isn't really safe to remove some of the others. (And, as a further problem, I know that at least one is only referenced in closed source, binary only, platform modules.)
No comments:
Post a Comment