Waldemar Kornewald wrote:
Isn't the 'uninit_driver()' function meant for this purpose? The BeBook says it's called when unloading the driver ...En réponse à Waldemar Kornewald <Waldemar.Kornewald@xxxxxx>:
Good point...Hi, is there some way for a driver/module get notified when the system is shut down? The problem is, for example, that in BONE the ppp module does not know this and thus does not disconnect. This is a bad behaviour. Can we implement some additional ioctl and module code like B_UNLOAD_ON_SHUTDOWN. If it returns B_OK the kernel will unload the driver/module from memory. Otherwise it will leave it and turning the computer off should not cause an error. This is very useful for all kernel drivers/modules that must disconnect their hardware properly. Of course, ATA devices or a sound card do not need this feature, but maybe there are devices that need a turn-off signal.
Here we come to the point that something like a real windows-like turn-the-computer-off screen is needed (if the computer cannot do that automatically).
What do you think?
I had thoughts about a power managment module, but not even simple
shutdown...
I'm not sure how we could hook in in R5 to get that behaviour, but
it's certainly a good addition to OBOS.
Actually, this should be no problem. We add the ioctl and std_ops action B_UNLOAD_ON_SHUTDOWN. When the system is shut down the kernel calls
if(ioctl(fd,B_UNLOAD_ON_SHUTDOWN...) == B_OK) unload_driver(fd);
and
if(module->std_ops(B_UNLOAD_ON_SHUTDOWN) == B_OK) unload_module(module);
for each module and driver that is loaded.
Drivers/modules that do not support this automatically return B_ERROR or something like that. The same goes for drivers/modules that do not need this behaviour. They just do not implement it and the switch-case part in the driver will fall through and return B_ERROR.
Why should we need an additional call for driver/modules if we can use the current API without any problems? The advantage is that old drivers will still work and can be adapted without much work (just add a new "case" statement).
Waldemar