Commit Graph

23 Commits

Author SHA1 Message Date
dyoung
0d1ba3e899 During shutdown, detach devices in an orderly fashion.
Call the detach routine for every device in the device tree, starting
with the leaves and moving toward the root, expecting that each
(pseudo-)device driver will use the opportunity to gracefully commit
outstandings transactions to the underlying (pseudo-)device and to
relinquish control of the hardware to the system BIOS.

Detaching devices is not suitable for every shutdown: in an emergency,
or if the system state is inconsistent, we should resort to a fast,
simple shutdown that uses only the pmf(9) shutdown hooks and the
(deprecated) shutdownhooks.  For now, if the flag RB_NOSYNC is set in
boothowto, opt for the fast, simple shutdown.

Add a device flag, DVF_DETACH_SHUTDOWN, that indicates by its presence
that it is safe to detach a device during shutdown.  Introduce macros
CFATTACH_DECL3() and CFATTACH_DECL3_NEW() for creating autoconf
attachments with default device flags.  Add DVF_DETACH_SHUTDOWN
to configuration attachments for atabus(4), atw(4) at cardbus(4),
cardbus(4), cardslot(4), com(4) at isa(4), elanpar(4), elanpex(4),
elansc(4), gpio(4), npx(4) at isa(4), nsphyter(4), pci(4), pcib(4),
pcmcia(4), ppb(4), sip(4), wd(4), and wdc(4) at isa(4).

Add a device-detachment "reason" flag, DETACH_SHUTDOWN, that tells the
autoconf code and a device driver that the reason for detachment is
system shutdown.

Add a sysctl, kern.detachall, that tells the system to try to detach
every device at shutdown, regardless of any device's DVF_DETACH_SHUTDOWN
flag.  The default for kern.detachall is 0.  SET IT TO 1, PLEASE, TO
HELP TEST AND DEBUG DEVICE DETACHMENT AT SHUTDOWN.

This is a work in progress.  In future work, I aim to treat
pseudo-devices more thoroughly, and to gracefully tear down a stack of
(pseudo-)disk drivers and filesystems, including cgd(4), vnd(4), and
raid(4) instances at shutdown.

Also commit some changes that are not easily untangled from the rest:

(1) begin to simplify device_t locking: rename struct pmf_private to
device_lock, and incorporate device_lock into struct device.

(2) #include <sys/device.h> in sys/pmf.h in order to get some
definitions that it needs.  Stop unnecessarily #including <sys/device.h>
in sys/arch/x86/include/pic.h to keep the amd64, xen, and i386 releases
building.
2009-04-02 00:09:32 +00:00
cegger
c363a9cb62 bzero -> memset 2009-03-18 16:00:08 +00:00
gmcgarry
333aec56cb Both legs of a diagraph must return the same type. 2008-06-24 10:05:01 +00:00
dyoung
fef8b3ebea #include <sys/device.h> for device_t definition. 2008-05-27 19:26:27 +00:00
xtraeme
7ecae1b00d Finish device_t/softc split. Previous commit was incomplete. 2008-05-04 14:01:14 +00:00
cegger
8127f641e3 device_t / softc split. From Hans Rosenfeld. 2008-05-01 22:00:44 +00:00
cegger
b574865ea4 gpio(4): Extend with open/close to request/release the ppbus(4) on open/close.
ppbus(4): Extend to attach on gpiobus.
From Hans Rosenfeld from tech-kern:
http://mail-index.netbsd.org/tech-kern/2008/04/28/msg001168.html
Hint: Hans sent me this diff which differs in the one from tech-kern in:
- 2-clause license
- sprinkled some consts
2008-04-29 14:07:36 +00:00
dyoung
f612df5fb6 Use PMF_FN_ARGS, PMF_FN_PROTO. 2008-02-29 06:38:28 +00:00
dyoung
d3a283186c Use device_t. 2008-01-10 07:49:04 +00:00
dyoung
417afa7caa Bug fix: record the new state (high/low) set by gpio_pin_write().
I don't know why we gpio(4) didn't do that before, but it seems
harmless.

Add naive power handling: when a gpio(4) instance is resumed, write
each pin's configuration flags and output state from the softc to
the hardware using gpiobus_pin_ctl() and gpiobus_pin_write().
While suspended, fail every ioctl() except for GPIOINFO with EBUSY.
2007-12-14 01:49:23 +00:00
christos
53524e44ef Kill caddr_t; there will be some MI fallout, but it will be fixed shortly. 2007-03-04 05:59:00 +00:00
christos
168cd830d2 __unused removal on arguments; approved by core. 2006-11-16 01:32:37 +00:00
christos
4d595fd7b1 - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
2006-10-12 01:30:41 +00:00
christos
afca61baba add missing initializers 2006-08-30 02:09:40 +00:00
uwe
8398f3ff65 Whitespace nit. 2006-04-08 22:33:36 +00:00
riz
637bfc29f9 Dallas Semiconductor 1-Wire bus support, from OpenBSD. Currently includes
gpioow(4), attaching a bit-banging driver via a GPIO pin.  Also,
owtemp(4) which supports some of the 1-Wire temperature sensors, including
the DS18b20 and DS1920 - temperatures are returned via the envsys(4)
framework.

Original drivers by Alexander Yurchenko (grange@openbsd), with envsys(4)
support and a fix to the 1-wire search algorithm (for discovering
devices on the bus) by me.

As discussed on tech-kern earlier this week.
2006-04-07 18:55:21 +00:00
thorpej
92c7bba3df Use device_private(). 2006-03-29 06:28:38 +00:00
thorpej
39cd836ee1 Use device_unit(). 2006-03-28 17:38:24 +00:00
riz
74baa88e7d Flesh out the framework for attaching drivers to the GPIO pins.
From OpenBSD, Alexander Yurchenko <grange@openbsd
2006-02-20 03:18:36 +00:00
christos
95e1ffb156 merge ktrace-lwp. 2005-12-11 12:16:03 +00:00
drochner
dbbdf74175 -kill gba_name in attach arg
-use constants from locators.h
2005-10-11 16:01:03 +00:00
cube
0e6cb1fa09 Add __KERNEL_RCSID. 2005-10-11 09:56:51 +00:00
jmcneill
bec79ef231 Import general purpose I/O framework from OpenBSD. 2005-09-27 02:34:02 +00:00