Subject: passing additional info to shutdown hooks?
To: None <tech-kern@netbsd.org>
From: Rafal Boni <rafal@mediaone.net>
List: tech-kern
Date: 04/08/1999 14:39:17
Folks:
I have a custom (x86) motherboard that won't reboot unless a magic
value is written into an on-board FPGA. I've hacked cpu_reboot to
DTRT on this machine, but was thinking about a more general way to
solve this problem (preferrably one that didn't involve my having to
hack in my patch every time I update my tree).
It came to me that I could use the shutdown hooks, but only if I could
pass 'howto' down to the shutdown routine (and possibly invoke the
shutdown hooks more than once in the case of a howto == RB_HALT and
the user then hitting 'enter' to reboot).
So I came up with this little scheme, and would like some feedback
on it:
(1) When registering shutdown hooks, one could specify a
'when' parameter, which would just be a bitwise OR of
all the RB_xxx conditions we'd like to be called in.
(2) doshutdownhooks() would be passed 'howto' as a parameter,
and only hooks where (when & howto) != 0 would be called.
It may also be good for howto to be passed through to the
hook function itself, for reasons given below.
(3) each shutdown hook would return a value to indicate
whether it had completed its' work and should be removed
from the list, or whether it has done nothing/only
partially done its' work/... and thus should be kept in
the list.
Then, cpu_reboot would call 'doshutdownhooks(howto)' after it had
completed dumps/sync/... and then call 'doshutdownhooks(RB_REBOOT)'
[I'm not sure how RB_AUTOBOOT is used, but it wouldn't work here
as (RB_AUTOBOOT & anything) == 0] if it fell into the reboot case.
Comments, ideas?
--rafal
----
Rafal Boni rafal@mediaone.net