History log of /openbsd-current/sys/sys/device.h
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 1.67 28-May-2024 kettenis

Garbage collect sleep_abort(); it doesn't do anything useful anymore.

ok deraadt@, mlarkin@


Revision tags: OPENBSD_7_4_BASE OPENBSD_7_5_BASE
# 1.66 08-Jul-2023 tobhe

Adds request_sleep(), a MI way of sending the machine to sleep in
a safe thread. Support is limited to amd64, i386 and arm64 at the
moment, macppc gets only an empty stub.

feedback from kettenis@
tested by bluhm@
ok phessler@


# 1.65 17-May-2023 patrick

Lenovo x13s requires a Qualcomm firmware file which is 13.7MB, so increase
the limit from 5MB to 15MB.

What does it contain? A full copy of Windows VM framework? For now, we
need it to read the battery status...

"go for it" deraadt@


Revision tags: OPENBSD_7_2_BASE OPENBSD_7_3_BASE
# 1.64 03-Sep-2022 kettenis

Make sure we don't suspend if we have no way to wake up the machine.
The idea is that device drivers that can wake up the machine register
themselves by calling device_register_wakeup(). To prevent regressions
on amd64, we let acpi(4) register itself as a wakeup device if the AML
for the machine defines wakeup devices. This may be refined in the
future.

This diff will prevent people from suspending their arm64 SBCs without
having a way to wake them up. For now the only driver that registers
itself is axppmic(4), which means that at this moment only SBCs with
an allwinner A64 or H5 SoC will actually support suspend/resume.

ok mlarkin@, deraadt@


# 1.63 07-Apr-2022 tb

Fix kernel builds with pseudo-device rd

Make the cf_attach member of struct cfdata const and sprinkle a few
const into subr_autoconf.c to make this work. Fixes the compilation
of sys/dev/rd.c with newly const rd_ca.

ok miod (who had a similar diff)


Revision tags: OPENBSD_7_1_BASE
# 1.62 16-Feb-2022 deraadt

change MD gosleep() and sleep_finish() to return int, the MI code will be
able to react to this suitably.


# 1.61 15-Feb-2022 deraadt

Since acpitoshiba brightness button processing no longer plays games
with AML parsing outside the acpi thread, the locking-release dance
around wsdisplay_{suspend,resume} can be removed
ok kettenis


# 1.60 15-Feb-2022 deraadt

when the MI suspend code encounters problems, we need a way to
reset the MD state before bailing out. New MD function sleep_abort()
does that.


# 1.59 15-Feb-2022 deraadt

MI disable_lid_wakeups() is not needed, x86 systems can do this
in sleep_resume(), which seems sensible for other future systems also


# 1.58 11-Feb-2022 deraadt

the sleep_clocks() hook is not needed because the architectures which
need to do this can do it a few moments later in a different hook


# 1.57 08-Feb-2022 deraadt

The suspend/resume code is a sticky mess of MI, MD, and ACPI sequencing.
This splits out the MI sequencing, backing it with per-architecture helper
functions. Further steps will be neccesary because ACPI and MD are too
tightly coupled, but soon we'll be able to use this code for more architectures
(which depends on figuring out the lowest-level cpu sleeping method)
ok kettenis


# 1.56 26-Oct-2021 deraadt

Improve unhibernate performance (30% on some machines, another upcoming diff
shows gains up to 50%) by skipping attach of irrelevant devices, which are
tagged CD_SKIPHIBERNATE in the per-driver cfdriver. In particular, usb devices
are not attached, so they don't need to detach during the suspend-unpack-resume.
New bootblocks are required (which tell the kernel it's job is unhibernate
before configure runs)
tested by various


Revision tags: OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE OPENBSD_6_7_BASE OPENBSD_6_8_BASE OPENBSD_6_9_BASE OPENBSD_7_0_BASE
# 1.55 10-Sep-2018 sashan

- if_cloners list populated at boot time only then becomes immutable,
so we can let go if_cloners_lock.

OK tb@, claudio@, bluhm@, kn@, henning@


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.54 11-Dec-2015 mpi

Replace mountroothook_establish(9) by config_mountroot(9) a narrower API
similar to config_defer(9).

ok mikeb@, deraadt@


# 1.53 11-Sep-2015 dlg

back out refcnt for dv_ref, there's too many hand crafted devices all
over the tree.

much encouragement from l2k15


# 1.52 11-Sep-2015 dlg

use refcnts for the device reference counts as an example of how
refcnt(9) can be used.


# 1.51 11-Sep-2015 miod

Change device locators type from int to long, for the sake of 64-bit ports
without proper device trees.

Be sure to build and install config(8) and rerun it before attempting to build
a kernel.

ok kettenis@ deraadt@ jasper@ visa@


Revision tags: OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.50 18-Sep-2014 kettenis

Introduce config_suspend_all(9) a function that invokes config_suspend(9)
on all relevant device hierarchies in the appropriate order. For now this
means mpath(4) and mainbus(4), doing mpath(4) before mainbus(4) when
suspending or powering down and doing mpath(4) after mainbus(4) when
resuming such that mpath(4) can realy on the underlying hardware being
in a functional state.

Fixes problems with unflushed disk caches on machines where mpath(4) takes
control of some of your disks.

ok dlg@


Revision tags: OPENBSD_5_6_BASE
# 1.49 29-Mar-2014 guenther

It's been a quarter century: we can assume volatile is present with that name.

ok dlg@ mpi@ deraadt@


# 1.48 13-Mar-2014 dlg

get rid of the assumption that the head of the alldevs list is the
"mainbus" device. this breaks when mpath is enabled because it
attaches before mainbus and therefore takes the head position.

have autoconf provide device_mainbus() which looks up mainbus_cd,
and use that instead.

discussed with deraadt who just wants mpath stuff to move forward
despite there being many ways to shine this particular turd.


Revision tags: OPENBSD_5_5_BASE
# 1.47 06-Dec-2013 deraadt

Add a DVACT_WAKEUP op to the *_activate() API. This is called after the
kernel resumes normal (non-cold, able to run processes, etc) operation.
Previously we were relying on specific DVACT_RESUME op's in drivers
creating callback/threads themselves, but that has become too common,
indicating the need for a built-in mechanism.
ok dlg kettenis, tested by a sufficient amount of people


# 1.46 27-Nov-2013 dlg

get rid of the goop for maintaining multiple cftables since theres
no current code there to add or remove them. such code was put in
17 years ago, disabled 14 years ago, and removed 11 years ago, so
i suspect we dont really need it or the goop to support it.

very ok miod@


Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.45 08-Oct-2012 deraadt

Revamp the sequences for suspend/hibernate -> resume so that the code
paths are reflexive. It is now possible to fail part-way through a
suspend sequence, and recover along the resume code path.
Split DVACT_SUSPEND by adding a new DVACT_POWERDOWN method is used
after hibernate (and suspend too) to finish the job. Some drivers
must be converted at the same time to use this instead of shutdown hooks
(the others will follow at a later time)
ok kettenis mlarkin


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.44 03-Jul-2011 matthew

Remove config_activate() and DVACT_ACTIVATE. PCMCIA's the only thing
that's ever used it, and it's long since been changed to use
DVACT_{QUIESCE,SUSPEND,RESUME} instead.

ok deraadt@, dlg@; miod@ also agreed with this idea when I brought it
up a few weeks ago


# 1.43 01-Jun-2011 matthew

Kill the nearly-15-years-dead cf_ivstubs field from struct cfdata.

ok miod@, deraadt@

N.B.: If you're following -current, you MUST recompile config(8) and
re-config your kernel or else ioconf.c will fail to compile.


Revision tags: OPENBSD_4_9_BASE
# 1.42 31-Aug-2010 deraadt

Add DVACT_QUIECE support. This is called before splhigh() and before
DVACT_SUSPEND, therefore DVACT_QUIECE can do standard sleeping operations
to get ready.
Discussed quite a while back with kettenis and jakemsr, oga suddenly needed
it as well and wrote half of it, so it was time to finish it.
proofread by miod.


Revision tags: OPENBSD_4_7_BASE OPENBSD_4_8_BASE
# 1.41 23-Nov-2009 deraadt

Make config_activate_children() more useable as a suspend-and-resume
device tree walker, and add config_suspend() as well.
ok mlarkin pirofti, discussion with kettenis


# 1.40 22-Nov-2009 pirofti

Forgot the declarations in former commit. From martin@, okay oga@.


# 1.39 22-Nov-2009 pirofti

Add basic suspend/resume autoconf functionality.

Okay deraadt@, kettenis@, mlarkin@.


# 1.38 13-Oct-2009 pirofti

Get rid of devact enum, substitute it with an int and coresponding defines.

This is needed for the addition of further suspend/resume actions.

Okay deraadt@, marco@.


Revision tags: OPENBSD_4_3_BASE OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE
# 1.37 24-Nov-2007 dlg

we dont need ot include sys/lock.h here

ok miod@ krw@


Revision tags: OPENBSD_4_2_BASE
# 1.36 15-May-2007 deraadt

kill __HAVE_DEVICE_REGISTER by requiring all architectures to have a
device_register() function -- even if it does nothing. reduces the
cpp-based blather different between architectures
idea ok'd by miod; tested on all architectures (except a few miod will
need to cleanup because he has them)


# 1.35 10-May-2007 deraadt

evcnt & friends were replaced by a proper interrupt counting mechanism 3 years ago; ok miod


# 1.34 04-May-2007 deraadt

make findblkmajor() and findblkname() MI; ok miod


# 1.33 04-May-2007 deraadt

setroot() was a ugly mix of MI and MD code, with different bugs on different
machines. Instead -- build one solid clean MI version, and thenchange all
the architectures to use it. ok various people, tested on almost all cases.
(it is a 10094 line diff..)


Revision tags: OPENBSD_4_0_BASE OPENBSD_4_1_BASE
# 1.32 28-May-2006 henning

intrducing device type DV_SENSOR turned out to be a bad idea as it
affects way more than just hotplug messages. remove DV_SENSOR and use
DV_DULL for the moment. proper solution coming.
discussed with deraadt mk jason


# 1.31 27-May-2006 mk

Make sensor add/remove create hotplug events (after much prodding from henning). Idea from mbalmer. 'in it goes!' deraadt.


Revision tags: OPENBSD_3_9_BASE
# 1.30 21-Jan-2006 miod

Remove now unused zeroref member in cfattach structures.


Revision tags: OPENBSD_3_7_BASE OPENBSD_3_8_BASE
# 1.29 23-Nov-2004 miod

Create the init process earlier, before the root filesystem is mounted,
and have it stall on a semaphore. This allows all kthread creations which
could have been requested during autoconf to be processed before root
is mounted as well.

This causes umass devices attached to any usb with flags 1 (such as on macppc)
to configure properly instead of panicing the kernel at mountroot time.

From NetBSD; tested by various.


# 1.28 17-Nov-2004 deraadt

firmware loading; ok pedro tedu dlg miod


Revision tags: OPENBSD_3_4_BASE OPENBSD_3_5_BASE OPENBSD_3_6_BASE SMP_SYNC_A SMP_SYNC_B
# 1.27 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


Revision tags: OPENBSD_3_3_BASE UBC_SYNC_A UBC_SYNC_B
# 1.26 06-Oct-2002 art

Remove some '#if 0' cruft.


Revision tags: OPENBSD_3_2_BASE
# 1.25 06-Sep-2002 deraadt

remove last , in enum


# 1.24 27-Aug-2002 wcobb

config_edit() isn't used anywhere. ok art@


Revision tags: OPENBSD_3_1_BASE
# 1.23 15-Mar-2002 millert

Cosmetic changes only, primarily making comments line up nicely after the
__P removal.


# 1.22 14-Mar-2002 millert

Final __P removal plus some cosmetic fixups


# 1.21 14-Mar-2002 millert

First round of __P removal in sys


Revision tags: OPENBSD_3_0_BASE UBC_BASE
# 1.20 01-Sep-2001 jason

branches: 1.20.4;
Add __HAVE_DEVICE_REGISTER to hp300/alpha (sparc64 already had it) and
clean up the arch specific #ifdef's in subr_autoconf.c; from NetBSD.
(tested by me on alpha/sparc64 and miod on hp300)


# 1.19 22-Jun-2001 deraadt

KNF


Revision tags: OPENBSD_2_7_BASE OPENBSD_2_8_BASE OPENBSD_2_9_BASE
# 1.18 09-Apr-2000 csapuntz

Added config_detach_children, config_activate_children.

Added ref counting to devices: device_ref, device_unref and a new method
for devices : ca_zeroref, called when the ref count hits zero.

Note that ca_zeroref may be called from interrupt context.


Revision tags: OPENBSD_2_6_BASE SMP_BASE kame_19991208
# 1.17 08-Aug-1999 niklas

branches: 1.17.4;
From NetBSD; new device detaching infrastructure.


# 1.16 05-Aug-1999 niklas

From NetBSD; config_defer to defer configuration of a device until after all
other siblings.


# 1.15 23-Jul-1999 niklas

Remove obsolete detach logic in preparation of a newer one


# 1.14 28-Apr-1999 deraadt

add autoconfig_verbose toggling command to boot_config


Revision tags: OPENBSD_2_4_BASE OPENBSD_2_5_BASE
# 1.13 11-May-1998 niklas

Formerly reuse of unit numbers of detached devices was impossible, with
this change starred devices will search from the first allowed unit for
such devices and up for free units when attaching. This means you have
to rerun config(8) before yopu compile current kernels. FYI, this is
a necessity when doing PCMCIA flashcard reading, otherwise you soon run
out of unit numbers.

I have also added a way to detach all children of a certain device, used
in a new PCMCIA framework to come, so you detach all functions on a
single PCMCIA card when pulling it out.

A few bugs wrt starred devices fixed in the autoconfig_verbose code too.
Last and least, fixed some panic messages.


Revision tags: OPENBSD_2_2_BASE OPENBSD_2_3_BASE
# 1.12 07-Aug-1997 downsj

Back that out, I'm too tired to be messing with this.


# 1.11 07-Aug-1997 downsj

Add cf_locnames to struct cfdata.


Revision tags: OPENBSD_2_1_BASE
# 1.10 23-Nov-1996 kstailey

added const to second parameter of cfprint_t routines


# 1.9 21-Nov-1996 mickey

export struct cfdata cfdata[];


Revision tags: OPENBSD_2_0_BASE
# 1.8 02-Jul-1996 deraadt

provide config_make_softc proto


# 1.7 23-Jun-1996 maja

Added support for user modifiable kernel at boot (-c) /maja


# 1.6 16-Jun-1996 deraadt

provide locator names to kernel (update your config(8) binary!)


# 1.5 29-Apr-1996 hvozda

Pull in John Kohl's [jtk@netbsd.org] most recent (15Apr96) APM and PCMCIA work
(original PCMCIA framework by Stefan Grefen [grefen@convex.com]).


# 1.4 21-Apr-1996 deraadt

partial sync with netbsd 960418, more to come


# 1.3 18-Apr-1996 niklas

Merge of NetBSD 960317


# 1.2 03-Mar-1996 niklas

From NetBSD: 960217 merge


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.66 08-Jul-2023 tobhe

Adds request_sleep(), a MI way of sending the machine to sleep in
a safe thread. Support is limited to amd64, i386 and arm64 at the
moment, macppc gets only an empty stub.

feedback from kettenis@
tested by bluhm@
ok phessler@


# 1.65 17-May-2023 patrick

Lenovo x13s requires a Qualcomm firmware file which is 13.7MB, so increase
the limit from 5MB to 15MB.

What does it contain? A full copy of Windows VM framework? For now, we
need it to read the battery status...

"go for it" deraadt@


Revision tags: OPENBSD_7_2_BASE OPENBSD_7_3_BASE
# 1.64 03-Sep-2022 kettenis

Make sure we don't suspend if we have no way to wake up the machine.
The idea is that device drivers that can wake up the machine register
themselves by calling device_register_wakeup(). To prevent regressions
on amd64, we let acpi(4) register itself as a wakeup device if the AML
for the machine defines wakeup devices. This may be refined in the
future.

This diff will prevent people from suspending their arm64 SBCs without
having a way to wake them up. For now the only driver that registers
itself is axppmic(4), which means that at this moment only SBCs with
an allwinner A64 or H5 SoC will actually support suspend/resume.

ok mlarkin@, deraadt@


# 1.63 07-Apr-2022 tb

Fix kernel builds with pseudo-device rd

Make the cf_attach member of struct cfdata const and sprinkle a few
const into subr_autoconf.c to make this work. Fixes the compilation
of sys/dev/rd.c with newly const rd_ca.

ok miod (who had a similar diff)


Revision tags: OPENBSD_7_1_BASE
# 1.62 16-Feb-2022 deraadt

change MD gosleep() and sleep_finish() to return int, the MI code will be
able to react to this suitably.


# 1.61 15-Feb-2022 deraadt

Since acpitoshiba brightness button processing no longer plays games
with AML parsing outside the acpi thread, the locking-release dance
around wsdisplay_{suspend,resume} can be removed
ok kettenis


# 1.60 15-Feb-2022 deraadt

when the MI suspend code encounters problems, we need a way to
reset the MD state before bailing out. New MD function sleep_abort()
does that.


# 1.59 15-Feb-2022 deraadt

MI disable_lid_wakeups() is not needed, x86 systems can do this
in sleep_resume(), which seems sensible for other future systems also


# 1.58 11-Feb-2022 deraadt

the sleep_clocks() hook is not needed because the architectures which
need to do this can do it a few moments later in a different hook


# 1.57 08-Feb-2022 deraadt

The suspend/resume code is a sticky mess of MI, MD, and ACPI sequencing.
This splits out the MI sequencing, backing it with per-architecture helper
functions. Further steps will be neccesary because ACPI and MD are too
tightly coupled, but soon we'll be able to use this code for more architectures
(which depends on figuring out the lowest-level cpu sleeping method)
ok kettenis


# 1.56 26-Oct-2021 deraadt

Improve unhibernate performance (30% on some machines, another upcoming diff
shows gains up to 50%) by skipping attach of irrelevant devices, which are
tagged CD_SKIPHIBERNATE in the per-driver cfdriver. In particular, usb devices
are not attached, so they don't need to detach during the suspend-unpack-resume.
New bootblocks are required (which tell the kernel it's job is unhibernate
before configure runs)
tested by various


Revision tags: OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE OPENBSD_6_7_BASE OPENBSD_6_8_BASE OPENBSD_6_9_BASE OPENBSD_7_0_BASE
# 1.55 10-Sep-2018 sashan

- if_cloners list populated at boot time only then becomes immutable,
so we can let go if_cloners_lock.

OK tb@, claudio@, bluhm@, kn@, henning@


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.54 11-Dec-2015 mpi

Replace mountroothook_establish(9) by config_mountroot(9) a narrower API
similar to config_defer(9).

ok mikeb@, deraadt@


# 1.53 11-Sep-2015 dlg

back out refcnt for dv_ref, there's too many hand crafted devices all
over the tree.

much encouragement from l2k15


# 1.52 11-Sep-2015 dlg

use refcnts for the device reference counts as an example of how
refcnt(9) can be used.


# 1.51 11-Sep-2015 miod

Change device locators type from int to long, for the sake of 64-bit ports
without proper device trees.

Be sure to build and install config(8) and rerun it before attempting to build
a kernel.

ok kettenis@ deraadt@ jasper@ visa@


Revision tags: OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.50 18-Sep-2014 kettenis

Introduce config_suspend_all(9) a function that invokes config_suspend(9)
on all relevant device hierarchies in the appropriate order. For now this
means mpath(4) and mainbus(4), doing mpath(4) before mainbus(4) when
suspending or powering down and doing mpath(4) after mainbus(4) when
resuming such that mpath(4) can realy on the underlying hardware being
in a functional state.

Fixes problems with unflushed disk caches on machines where mpath(4) takes
control of some of your disks.

ok dlg@


Revision tags: OPENBSD_5_6_BASE
# 1.49 29-Mar-2014 guenther

It's been a quarter century: we can assume volatile is present with that name.

ok dlg@ mpi@ deraadt@


# 1.48 13-Mar-2014 dlg

get rid of the assumption that the head of the alldevs list is the
"mainbus" device. this breaks when mpath is enabled because it
attaches before mainbus and therefore takes the head position.

have autoconf provide device_mainbus() which looks up mainbus_cd,
and use that instead.

discussed with deraadt who just wants mpath stuff to move forward
despite there being many ways to shine this particular turd.


Revision tags: OPENBSD_5_5_BASE
# 1.47 06-Dec-2013 deraadt

Add a DVACT_WAKEUP op to the *_activate() API. This is called after the
kernel resumes normal (non-cold, able to run processes, etc) operation.
Previously we were relying on specific DVACT_RESUME op's in drivers
creating callback/threads themselves, but that has become too common,
indicating the need for a built-in mechanism.
ok dlg kettenis, tested by a sufficient amount of people


# 1.46 27-Nov-2013 dlg

get rid of the goop for maintaining multiple cftables since theres
no current code there to add or remove them. such code was put in
17 years ago, disabled 14 years ago, and removed 11 years ago, so
i suspect we dont really need it or the goop to support it.

very ok miod@


Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.45 08-Oct-2012 deraadt

Revamp the sequences for suspend/hibernate -> resume so that the code
paths are reflexive. It is now possible to fail part-way through a
suspend sequence, and recover along the resume code path.
Split DVACT_SUSPEND by adding a new DVACT_POWERDOWN method is used
after hibernate (and suspend too) to finish the job. Some drivers
must be converted at the same time to use this instead of shutdown hooks
(the others will follow at a later time)
ok kettenis mlarkin


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.44 03-Jul-2011 matthew

Remove config_activate() and DVACT_ACTIVATE. PCMCIA's the only thing
that's ever used it, and it's long since been changed to use
DVACT_{QUIESCE,SUSPEND,RESUME} instead.

ok deraadt@, dlg@; miod@ also agreed with this idea when I brought it
up a few weeks ago


# 1.43 01-Jun-2011 matthew

Kill the nearly-15-years-dead cf_ivstubs field from struct cfdata.

ok miod@, deraadt@

N.B.: If you're following -current, you MUST recompile config(8) and
re-config your kernel or else ioconf.c will fail to compile.


Revision tags: OPENBSD_4_9_BASE
# 1.42 31-Aug-2010 deraadt

Add DVACT_QUIECE support. This is called before splhigh() and before
DVACT_SUSPEND, therefore DVACT_QUIECE can do standard sleeping operations
to get ready.
Discussed quite a while back with kettenis and jakemsr, oga suddenly needed
it as well and wrote half of it, so it was time to finish it.
proofread by miod.


Revision tags: OPENBSD_4_7_BASE OPENBSD_4_8_BASE
# 1.41 23-Nov-2009 deraadt

Make config_activate_children() more useable as a suspend-and-resume
device tree walker, and add config_suspend() as well.
ok mlarkin pirofti, discussion with kettenis


# 1.40 22-Nov-2009 pirofti

Forgot the declarations in former commit. From martin@, okay oga@.


# 1.39 22-Nov-2009 pirofti

Add basic suspend/resume autoconf functionality.

Okay deraadt@, kettenis@, mlarkin@.


# 1.38 13-Oct-2009 pirofti

Get rid of devact enum, substitute it with an int and coresponding defines.

This is needed for the addition of further suspend/resume actions.

Okay deraadt@, marco@.


Revision tags: OPENBSD_4_3_BASE OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE
# 1.37 24-Nov-2007 dlg

we dont need ot include sys/lock.h here

ok miod@ krw@


Revision tags: OPENBSD_4_2_BASE
# 1.36 15-May-2007 deraadt

kill __HAVE_DEVICE_REGISTER by requiring all architectures to have a
device_register() function -- even if it does nothing. reduces the
cpp-based blather different between architectures
idea ok'd by miod; tested on all architectures (except a few miod will
need to cleanup because he has them)


# 1.35 10-May-2007 deraadt

evcnt & friends were replaced by a proper interrupt counting mechanism 3 years ago; ok miod


# 1.34 04-May-2007 deraadt

make findblkmajor() and findblkname() MI; ok miod


# 1.33 04-May-2007 deraadt

setroot() was a ugly mix of MI and MD code, with different bugs on different
machines. Instead -- build one solid clean MI version, and thenchange all
the architectures to use it. ok various people, tested on almost all cases.
(it is a 10094 line diff..)


Revision tags: OPENBSD_4_0_BASE OPENBSD_4_1_BASE
# 1.32 28-May-2006 henning

intrducing device type DV_SENSOR turned out to be a bad idea as it
affects way more than just hotplug messages. remove DV_SENSOR and use
DV_DULL for the moment. proper solution coming.
discussed with deraadt mk jason


# 1.31 27-May-2006 mk

Make sensor add/remove create hotplug events (after much prodding from henning). Idea from mbalmer. 'in it goes!' deraadt.


Revision tags: OPENBSD_3_9_BASE
# 1.30 21-Jan-2006 miod

Remove now unused zeroref member in cfattach structures.


Revision tags: OPENBSD_3_7_BASE OPENBSD_3_8_BASE
# 1.29 23-Nov-2004 miod

Create the init process earlier, before the root filesystem is mounted,
and have it stall on a semaphore. This allows all kthread creations which
could have been requested during autoconf to be processed before root
is mounted as well.

This causes umass devices attached to any usb with flags 1 (such as on macppc)
to configure properly instead of panicing the kernel at mountroot time.

From NetBSD; tested by various.


# 1.28 17-Nov-2004 deraadt

firmware loading; ok pedro tedu dlg miod


Revision tags: OPENBSD_3_4_BASE OPENBSD_3_5_BASE OPENBSD_3_6_BASE SMP_SYNC_A SMP_SYNC_B
# 1.27 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


Revision tags: OPENBSD_3_3_BASE UBC_SYNC_A UBC_SYNC_B
# 1.26 06-Oct-2002 art

Remove some '#if 0' cruft.


Revision tags: OPENBSD_3_2_BASE
# 1.25 06-Sep-2002 deraadt

remove last , in enum


# 1.24 27-Aug-2002 wcobb

config_edit() isn't used anywhere. ok art@


Revision tags: OPENBSD_3_1_BASE
# 1.23 15-Mar-2002 millert

Cosmetic changes only, primarily making comments line up nicely after the
__P removal.


# 1.22 14-Mar-2002 millert

Final __P removal plus some cosmetic fixups


# 1.21 14-Mar-2002 millert

First round of __P removal in sys


Revision tags: OPENBSD_3_0_BASE UBC_BASE
# 1.20 01-Sep-2001 jason

branches: 1.20.4;
Add __HAVE_DEVICE_REGISTER to hp300/alpha (sparc64 already had it) and
clean up the arch specific #ifdef's in subr_autoconf.c; from NetBSD.
(tested by me on alpha/sparc64 and miod on hp300)


# 1.19 22-Jun-2001 deraadt

KNF


Revision tags: OPENBSD_2_7_BASE OPENBSD_2_8_BASE OPENBSD_2_9_BASE
# 1.18 09-Apr-2000 csapuntz

Added config_detach_children, config_activate_children.

Added ref counting to devices: device_ref, device_unref and a new method
for devices : ca_zeroref, called when the ref count hits zero.

Note that ca_zeroref may be called from interrupt context.


Revision tags: OPENBSD_2_6_BASE SMP_BASE kame_19991208
# 1.17 08-Aug-1999 niklas

branches: 1.17.4;
From NetBSD; new device detaching infrastructure.


# 1.16 05-Aug-1999 niklas

From NetBSD; config_defer to defer configuration of a device until after all
other siblings.


# 1.15 23-Jul-1999 niklas

Remove obsolete detach logic in preparation of a newer one


# 1.14 28-Apr-1999 deraadt

add autoconfig_verbose toggling command to boot_config


Revision tags: OPENBSD_2_4_BASE OPENBSD_2_5_BASE
# 1.13 11-May-1998 niklas

Formerly reuse of unit numbers of detached devices was impossible, with
this change starred devices will search from the first allowed unit for
such devices and up for free units when attaching. This means you have
to rerun config(8) before yopu compile current kernels. FYI, this is
a necessity when doing PCMCIA flashcard reading, otherwise you soon run
out of unit numbers.

I have also added a way to detach all children of a certain device, used
in a new PCMCIA framework to come, so you detach all functions on a
single PCMCIA card when pulling it out.

A few bugs wrt starred devices fixed in the autoconfig_verbose code too.
Last and least, fixed some panic messages.


Revision tags: OPENBSD_2_2_BASE OPENBSD_2_3_BASE
# 1.12 07-Aug-1997 downsj

Back that out, I'm too tired to be messing with this.


# 1.11 07-Aug-1997 downsj

Add cf_locnames to struct cfdata.


Revision tags: OPENBSD_2_1_BASE
# 1.10 23-Nov-1996 kstailey

added const to second parameter of cfprint_t routines


# 1.9 21-Nov-1996 mickey

export struct cfdata cfdata[];


Revision tags: OPENBSD_2_0_BASE
# 1.8 02-Jul-1996 deraadt

provide config_make_softc proto


# 1.7 23-Jun-1996 maja

Added support for user modifiable kernel at boot (-c) /maja


# 1.6 16-Jun-1996 deraadt

provide locator names to kernel (update your config(8) binary!)


# 1.5 29-Apr-1996 hvozda

Pull in John Kohl's [jtk@netbsd.org] most recent (15Apr96) APM and PCMCIA work
(original PCMCIA framework by Stefan Grefen [grefen@convex.com]).


# 1.4 21-Apr-1996 deraadt

partial sync with netbsd 960418, more to come


# 1.3 18-Apr-1996 niklas

Merge of NetBSD 960317


# 1.2 03-Mar-1996 niklas

From NetBSD: 960217 merge


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.65 17-May-2023 patrick

Lenovo x13s requires a Qualcomm firmware file which is 13.7MB, so increase
the limit from 5MB to 15MB.

What does it contain? A full copy of Windows VM framework? For now, we
need it to read the battery status...

"go for it" deraadt@


Revision tags: OPENBSD_7_2_BASE OPENBSD_7_3_BASE
# 1.64 03-Sep-2022 kettenis

Make sure we don't suspend if we have no way to wake up the machine.
The idea is that device drivers that can wake up the machine register
themselves by calling device_register_wakeup(). To prevent regressions
on amd64, we let acpi(4) register itself as a wakeup device if the AML
for the machine defines wakeup devices. This may be refined in the
future.

This diff will prevent people from suspending their arm64 SBCs without
having a way to wake them up. For now the only driver that registers
itself is axppmic(4), which means that at this moment only SBCs with
an allwinner A64 or H5 SoC will actually support suspend/resume.

ok mlarkin@, deraadt@


# 1.63 07-Apr-2022 tb

Fix kernel builds with pseudo-device rd

Make the cf_attach member of struct cfdata const and sprinkle a few
const into subr_autoconf.c to make this work. Fixes the compilation
of sys/dev/rd.c with newly const rd_ca.

ok miod (who had a similar diff)


Revision tags: OPENBSD_7_1_BASE
# 1.62 16-Feb-2022 deraadt

change MD gosleep() and sleep_finish() to return int, the MI code will be
able to react to this suitably.


# 1.61 15-Feb-2022 deraadt

Since acpitoshiba brightness button processing no longer plays games
with AML parsing outside the acpi thread, the locking-release dance
around wsdisplay_{suspend,resume} can be removed
ok kettenis


# 1.60 15-Feb-2022 deraadt

when the MI suspend code encounters problems, we need a way to
reset the MD state before bailing out. New MD function sleep_abort()
does that.


# 1.59 15-Feb-2022 deraadt

MI disable_lid_wakeups() is not needed, x86 systems can do this
in sleep_resume(), which seems sensible for other future systems also


# 1.58 11-Feb-2022 deraadt

the sleep_clocks() hook is not needed because the architectures which
need to do this can do it a few moments later in a different hook


# 1.57 08-Feb-2022 deraadt

The suspend/resume code is a sticky mess of MI, MD, and ACPI sequencing.
This splits out the MI sequencing, backing it with per-architecture helper
functions. Further steps will be neccesary because ACPI and MD are too
tightly coupled, but soon we'll be able to use this code for more architectures
(which depends on figuring out the lowest-level cpu sleeping method)
ok kettenis


# 1.56 26-Oct-2021 deraadt

Improve unhibernate performance (30% on some machines, another upcoming diff
shows gains up to 50%) by skipping attach of irrelevant devices, which are
tagged CD_SKIPHIBERNATE in the per-driver cfdriver. In particular, usb devices
are not attached, so they don't need to detach during the suspend-unpack-resume.
New bootblocks are required (which tell the kernel it's job is unhibernate
before configure runs)
tested by various


Revision tags: OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE OPENBSD_6_7_BASE OPENBSD_6_8_BASE OPENBSD_6_9_BASE OPENBSD_7_0_BASE
# 1.55 10-Sep-2018 sashan

- if_cloners list populated at boot time only then becomes immutable,
so we can let go if_cloners_lock.

OK tb@, claudio@, bluhm@, kn@, henning@


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.54 11-Dec-2015 mpi

Replace mountroothook_establish(9) by config_mountroot(9) a narrower API
similar to config_defer(9).

ok mikeb@, deraadt@


# 1.53 11-Sep-2015 dlg

back out refcnt for dv_ref, there's too many hand crafted devices all
over the tree.

much encouragement from l2k15


# 1.52 11-Sep-2015 dlg

use refcnts for the device reference counts as an example of how
refcnt(9) can be used.


# 1.51 11-Sep-2015 miod

Change device locators type from int to long, for the sake of 64-bit ports
without proper device trees.

Be sure to build and install config(8) and rerun it before attempting to build
a kernel.

ok kettenis@ deraadt@ jasper@ visa@


Revision tags: OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.50 18-Sep-2014 kettenis

Introduce config_suspend_all(9) a function that invokes config_suspend(9)
on all relevant device hierarchies in the appropriate order. For now this
means mpath(4) and mainbus(4), doing mpath(4) before mainbus(4) when
suspending or powering down and doing mpath(4) after mainbus(4) when
resuming such that mpath(4) can realy on the underlying hardware being
in a functional state.

Fixes problems with unflushed disk caches on machines where mpath(4) takes
control of some of your disks.

ok dlg@


Revision tags: OPENBSD_5_6_BASE
# 1.49 29-Mar-2014 guenther

It's been a quarter century: we can assume volatile is present with that name.

ok dlg@ mpi@ deraadt@


# 1.48 13-Mar-2014 dlg

get rid of the assumption that the head of the alldevs list is the
"mainbus" device. this breaks when mpath is enabled because it
attaches before mainbus and therefore takes the head position.

have autoconf provide device_mainbus() which looks up mainbus_cd,
and use that instead.

discussed with deraadt who just wants mpath stuff to move forward
despite there being many ways to shine this particular turd.


Revision tags: OPENBSD_5_5_BASE
# 1.47 06-Dec-2013 deraadt

Add a DVACT_WAKEUP op to the *_activate() API. This is called after the
kernel resumes normal (non-cold, able to run processes, etc) operation.
Previously we were relying on specific DVACT_RESUME op's in drivers
creating callback/threads themselves, but that has become too common,
indicating the need for a built-in mechanism.
ok dlg kettenis, tested by a sufficient amount of people


# 1.46 27-Nov-2013 dlg

get rid of the goop for maintaining multiple cftables since theres
no current code there to add or remove them. such code was put in
17 years ago, disabled 14 years ago, and removed 11 years ago, so
i suspect we dont really need it or the goop to support it.

very ok miod@


Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.45 08-Oct-2012 deraadt

Revamp the sequences for suspend/hibernate -> resume so that the code
paths are reflexive. It is now possible to fail part-way through a
suspend sequence, and recover along the resume code path.
Split DVACT_SUSPEND by adding a new DVACT_POWERDOWN method is used
after hibernate (and suspend too) to finish the job. Some drivers
must be converted at the same time to use this instead of shutdown hooks
(the others will follow at a later time)
ok kettenis mlarkin


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.44 03-Jul-2011 matthew

Remove config_activate() and DVACT_ACTIVATE. PCMCIA's the only thing
that's ever used it, and it's long since been changed to use
DVACT_{QUIESCE,SUSPEND,RESUME} instead.

ok deraadt@, dlg@; miod@ also agreed with this idea when I brought it
up a few weeks ago


# 1.43 01-Jun-2011 matthew

Kill the nearly-15-years-dead cf_ivstubs field from struct cfdata.

ok miod@, deraadt@

N.B.: If you're following -current, you MUST recompile config(8) and
re-config your kernel or else ioconf.c will fail to compile.


Revision tags: OPENBSD_4_9_BASE
# 1.42 31-Aug-2010 deraadt

Add DVACT_QUIECE support. This is called before splhigh() and before
DVACT_SUSPEND, therefore DVACT_QUIECE can do standard sleeping operations
to get ready.
Discussed quite a while back with kettenis and jakemsr, oga suddenly needed
it as well and wrote half of it, so it was time to finish it.
proofread by miod.


Revision tags: OPENBSD_4_7_BASE OPENBSD_4_8_BASE
# 1.41 23-Nov-2009 deraadt

Make config_activate_children() more useable as a suspend-and-resume
device tree walker, and add config_suspend() as well.
ok mlarkin pirofti, discussion with kettenis


# 1.40 22-Nov-2009 pirofti

Forgot the declarations in former commit. From martin@, okay oga@.


# 1.39 22-Nov-2009 pirofti

Add basic suspend/resume autoconf functionality.

Okay deraadt@, kettenis@, mlarkin@.


# 1.38 13-Oct-2009 pirofti

Get rid of devact enum, substitute it with an int and coresponding defines.

This is needed for the addition of further suspend/resume actions.

Okay deraadt@, marco@.


Revision tags: OPENBSD_4_3_BASE OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE
# 1.37 24-Nov-2007 dlg

we dont need ot include sys/lock.h here

ok miod@ krw@


Revision tags: OPENBSD_4_2_BASE
# 1.36 15-May-2007 deraadt

kill __HAVE_DEVICE_REGISTER by requiring all architectures to have a
device_register() function -- even if it does nothing. reduces the
cpp-based blather different between architectures
idea ok'd by miod; tested on all architectures (except a few miod will
need to cleanup because he has them)


# 1.35 10-May-2007 deraadt

evcnt & friends were replaced by a proper interrupt counting mechanism 3 years ago; ok miod


# 1.34 04-May-2007 deraadt

make findblkmajor() and findblkname() MI; ok miod


# 1.33 04-May-2007 deraadt

setroot() was a ugly mix of MI and MD code, with different bugs on different
machines. Instead -- build one solid clean MI version, and thenchange all
the architectures to use it. ok various people, tested on almost all cases.
(it is a 10094 line diff..)


Revision tags: OPENBSD_4_0_BASE OPENBSD_4_1_BASE
# 1.32 28-May-2006 henning

intrducing device type DV_SENSOR turned out to be a bad idea as it
affects way more than just hotplug messages. remove DV_SENSOR and use
DV_DULL for the moment. proper solution coming.
discussed with deraadt mk jason


# 1.31 27-May-2006 mk

Make sensor add/remove create hotplug events (after much prodding from henning). Idea from mbalmer. 'in it goes!' deraadt.


Revision tags: OPENBSD_3_9_BASE
# 1.30 21-Jan-2006 miod

Remove now unused zeroref member in cfattach structures.


Revision tags: OPENBSD_3_7_BASE OPENBSD_3_8_BASE
# 1.29 23-Nov-2004 miod

Create the init process earlier, before the root filesystem is mounted,
and have it stall on a semaphore. This allows all kthread creations which
could have been requested during autoconf to be processed before root
is mounted as well.

This causes umass devices attached to any usb with flags 1 (such as on macppc)
to configure properly instead of panicing the kernel at mountroot time.

From NetBSD; tested by various.


# 1.28 17-Nov-2004 deraadt

firmware loading; ok pedro tedu dlg miod


Revision tags: OPENBSD_3_4_BASE OPENBSD_3_5_BASE OPENBSD_3_6_BASE SMP_SYNC_A SMP_SYNC_B
# 1.27 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


Revision tags: OPENBSD_3_3_BASE UBC_SYNC_A UBC_SYNC_B
# 1.26 06-Oct-2002 art

Remove some '#if 0' cruft.


Revision tags: OPENBSD_3_2_BASE
# 1.25 06-Sep-2002 deraadt

remove last , in enum


# 1.24 27-Aug-2002 wcobb

config_edit() isn't used anywhere. ok art@


Revision tags: OPENBSD_3_1_BASE
# 1.23 15-Mar-2002 millert

Cosmetic changes only, primarily making comments line up nicely after the
__P removal.


# 1.22 14-Mar-2002 millert

Final __P removal plus some cosmetic fixups


# 1.21 14-Mar-2002 millert

First round of __P removal in sys


Revision tags: OPENBSD_3_0_BASE UBC_BASE
# 1.20 01-Sep-2001 jason

branches: 1.20.4;
Add __HAVE_DEVICE_REGISTER to hp300/alpha (sparc64 already had it) and
clean up the arch specific #ifdef's in subr_autoconf.c; from NetBSD.
(tested by me on alpha/sparc64 and miod on hp300)


# 1.19 22-Jun-2001 deraadt

KNF


Revision tags: OPENBSD_2_7_BASE OPENBSD_2_8_BASE OPENBSD_2_9_BASE
# 1.18 09-Apr-2000 csapuntz

Added config_detach_children, config_activate_children.

Added ref counting to devices: device_ref, device_unref and a new method
for devices : ca_zeroref, called when the ref count hits zero.

Note that ca_zeroref may be called from interrupt context.


Revision tags: OPENBSD_2_6_BASE SMP_BASE kame_19991208
# 1.17 08-Aug-1999 niklas

branches: 1.17.4;
From NetBSD; new device detaching infrastructure.


# 1.16 05-Aug-1999 niklas

From NetBSD; config_defer to defer configuration of a device until after all
other siblings.


# 1.15 23-Jul-1999 niklas

Remove obsolete detach logic in preparation of a newer one


# 1.14 28-Apr-1999 deraadt

add autoconfig_verbose toggling command to boot_config


Revision tags: OPENBSD_2_4_BASE OPENBSD_2_5_BASE
# 1.13 11-May-1998 niklas

Formerly reuse of unit numbers of detached devices was impossible, with
this change starred devices will search from the first allowed unit for
such devices and up for free units when attaching. This means you have
to rerun config(8) before yopu compile current kernels. FYI, this is
a necessity when doing PCMCIA flashcard reading, otherwise you soon run
out of unit numbers.

I have also added a way to detach all children of a certain device, used
in a new PCMCIA framework to come, so you detach all functions on a
single PCMCIA card when pulling it out.

A few bugs wrt starred devices fixed in the autoconfig_verbose code too.
Last and least, fixed some panic messages.


Revision tags: OPENBSD_2_2_BASE OPENBSD_2_3_BASE
# 1.12 07-Aug-1997 downsj

Back that out, I'm too tired to be messing with this.


# 1.11 07-Aug-1997 downsj

Add cf_locnames to struct cfdata.


Revision tags: OPENBSD_2_1_BASE
# 1.10 23-Nov-1996 kstailey

added const to second parameter of cfprint_t routines


# 1.9 21-Nov-1996 mickey

export struct cfdata cfdata[];


Revision tags: OPENBSD_2_0_BASE
# 1.8 02-Jul-1996 deraadt

provide config_make_softc proto


# 1.7 23-Jun-1996 maja

Added support for user modifiable kernel at boot (-c) /maja


# 1.6 16-Jun-1996 deraadt

provide locator names to kernel (update your config(8) binary!)


# 1.5 29-Apr-1996 hvozda

Pull in John Kohl's [jtk@netbsd.org] most recent (15Apr96) APM and PCMCIA work
(original PCMCIA framework by Stefan Grefen [grefen@convex.com]).


# 1.4 21-Apr-1996 deraadt

partial sync with netbsd 960418, more to come


# 1.3 18-Apr-1996 niklas

Merge of NetBSD 960317


# 1.2 03-Mar-1996 niklas

From NetBSD: 960217 merge


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.64 03-Sep-2022 kettenis

Make sure we don't suspend if we have no way to wake up the machine.
The idea is that device drivers that can wake up the machine register
themselves by calling device_register_wakeup(). To prevent regressions
on amd64, we let acpi(4) register itself as a wakeup device if the AML
for the machine defines wakeup devices. This may be refined in the
future.

This diff will prevent people from suspending their arm64 SBCs without
having a way to wake them up. For now the only driver that registers
itself is axppmic(4), which means that at this moment only SBCs with
an allwinner A64 or H5 SoC will actually support suspend/resume.

ok mlarkin@, deraadt@


# 1.63 07-Apr-2022 tb

Fix kernel builds with pseudo-device rd

Make the cf_attach member of struct cfdata const and sprinkle a few
const into subr_autoconf.c to make this work. Fixes the compilation
of sys/dev/rd.c with newly const rd_ca.

ok miod (who had a similar diff)


Revision tags: OPENBSD_7_1_BASE
# 1.62 16-Feb-2022 deraadt

change MD gosleep() and sleep_finish() to return int, the MI code will be
able to react to this suitably.


# 1.61 15-Feb-2022 deraadt

Since acpitoshiba brightness button processing no longer plays games
with AML parsing outside the acpi thread, the locking-release dance
around wsdisplay_{suspend,resume} can be removed
ok kettenis


# 1.60 15-Feb-2022 deraadt

when the MI suspend code encounters problems, we need a way to
reset the MD state before bailing out. New MD function sleep_abort()
does that.


# 1.59 15-Feb-2022 deraadt

MI disable_lid_wakeups() is not needed, x86 systems can do this
in sleep_resume(), which seems sensible for other future systems also


# 1.58 11-Feb-2022 deraadt

the sleep_clocks() hook is not needed because the architectures which
need to do this can do it a few moments later in a different hook


# 1.57 08-Feb-2022 deraadt

The suspend/resume code is a sticky mess of MI, MD, and ACPI sequencing.
This splits out the MI sequencing, backing it with per-architecture helper
functions. Further steps will be neccesary because ACPI and MD are too
tightly coupled, but soon we'll be able to use this code for more architectures
(which depends on figuring out the lowest-level cpu sleeping method)
ok kettenis


# 1.56 26-Oct-2021 deraadt

Improve unhibernate performance (30% on some machines, another upcoming diff
shows gains up to 50%) by skipping attach of irrelevant devices, which are
tagged CD_SKIPHIBERNATE in the per-driver cfdriver. In particular, usb devices
are not attached, so they don't need to detach during the suspend-unpack-resume.
New bootblocks are required (which tell the kernel it's job is unhibernate
before configure runs)
tested by various


Revision tags: OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE OPENBSD_6_7_BASE OPENBSD_6_8_BASE OPENBSD_6_9_BASE OPENBSD_7_0_BASE
# 1.55 10-Sep-2018 sashan

- if_cloners list populated at boot time only then becomes immutable,
so we can let go if_cloners_lock.

OK tb@, claudio@, bluhm@, kn@, henning@


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.54 11-Dec-2015 mpi

Replace mountroothook_establish(9) by config_mountroot(9) a narrower API
similar to config_defer(9).

ok mikeb@, deraadt@


# 1.53 11-Sep-2015 dlg

back out refcnt for dv_ref, there's too many hand crafted devices all
over the tree.

much encouragement from l2k15


# 1.52 11-Sep-2015 dlg

use refcnts for the device reference counts as an example of how
refcnt(9) can be used.


# 1.51 11-Sep-2015 miod

Change device locators type from int to long, for the sake of 64-bit ports
without proper device trees.

Be sure to build and install config(8) and rerun it before attempting to build
a kernel.

ok kettenis@ deraadt@ jasper@ visa@


Revision tags: OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.50 18-Sep-2014 kettenis

Introduce config_suspend_all(9) a function that invokes config_suspend(9)
on all relevant device hierarchies in the appropriate order. For now this
means mpath(4) and mainbus(4), doing mpath(4) before mainbus(4) when
suspending or powering down and doing mpath(4) after mainbus(4) when
resuming such that mpath(4) can realy on the underlying hardware being
in a functional state.

Fixes problems with unflushed disk caches on machines where mpath(4) takes
control of some of your disks.

ok dlg@


Revision tags: OPENBSD_5_6_BASE
# 1.49 29-Mar-2014 guenther

It's been a quarter century: we can assume volatile is present with that name.

ok dlg@ mpi@ deraadt@


# 1.48 13-Mar-2014 dlg

get rid of the assumption that the head of the alldevs list is the
"mainbus" device. this breaks when mpath is enabled because it
attaches before mainbus and therefore takes the head position.

have autoconf provide device_mainbus() which looks up mainbus_cd,
and use that instead.

discussed with deraadt who just wants mpath stuff to move forward
despite there being many ways to shine this particular turd.


Revision tags: OPENBSD_5_5_BASE
# 1.47 06-Dec-2013 deraadt

Add a DVACT_WAKEUP op to the *_activate() API. This is called after the
kernel resumes normal (non-cold, able to run processes, etc) operation.
Previously we were relying on specific DVACT_RESUME op's in drivers
creating callback/threads themselves, but that has become too common,
indicating the need for a built-in mechanism.
ok dlg kettenis, tested by a sufficient amount of people


# 1.46 27-Nov-2013 dlg

get rid of the goop for maintaining multiple cftables since theres
no current code there to add or remove them. such code was put in
17 years ago, disabled 14 years ago, and removed 11 years ago, so
i suspect we dont really need it or the goop to support it.

very ok miod@


Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.45 08-Oct-2012 deraadt

Revamp the sequences for suspend/hibernate -> resume so that the code
paths are reflexive. It is now possible to fail part-way through a
suspend sequence, and recover along the resume code path.
Split DVACT_SUSPEND by adding a new DVACT_POWERDOWN method is used
after hibernate (and suspend too) to finish the job. Some drivers
must be converted at the same time to use this instead of shutdown hooks
(the others will follow at a later time)
ok kettenis mlarkin


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.44 03-Jul-2011 matthew

Remove config_activate() and DVACT_ACTIVATE. PCMCIA's the only thing
that's ever used it, and it's long since been changed to use
DVACT_{QUIESCE,SUSPEND,RESUME} instead.

ok deraadt@, dlg@; miod@ also agreed with this idea when I brought it
up a few weeks ago


# 1.43 01-Jun-2011 matthew

Kill the nearly-15-years-dead cf_ivstubs field from struct cfdata.

ok miod@, deraadt@

N.B.: If you're following -current, you MUST recompile config(8) and
re-config your kernel or else ioconf.c will fail to compile.


Revision tags: OPENBSD_4_9_BASE
# 1.42 31-Aug-2010 deraadt

Add DVACT_QUIECE support. This is called before splhigh() and before
DVACT_SUSPEND, therefore DVACT_QUIECE can do standard sleeping operations
to get ready.
Discussed quite a while back with kettenis and jakemsr, oga suddenly needed
it as well and wrote half of it, so it was time to finish it.
proofread by miod.


Revision tags: OPENBSD_4_7_BASE OPENBSD_4_8_BASE
# 1.41 23-Nov-2009 deraadt

Make config_activate_children() more useable as a suspend-and-resume
device tree walker, and add config_suspend() as well.
ok mlarkin pirofti, discussion with kettenis


# 1.40 22-Nov-2009 pirofti

Forgot the declarations in former commit. From martin@, okay oga@.


# 1.39 22-Nov-2009 pirofti

Add basic suspend/resume autoconf functionality.

Okay deraadt@, kettenis@, mlarkin@.


# 1.38 13-Oct-2009 pirofti

Get rid of devact enum, substitute it with an int and coresponding defines.

This is needed for the addition of further suspend/resume actions.

Okay deraadt@, marco@.


Revision tags: OPENBSD_4_3_BASE OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE
# 1.37 24-Nov-2007 dlg

we dont need ot include sys/lock.h here

ok miod@ krw@


Revision tags: OPENBSD_4_2_BASE
# 1.36 15-May-2007 deraadt

kill __HAVE_DEVICE_REGISTER by requiring all architectures to have a
device_register() function -- even if it does nothing. reduces the
cpp-based blather different between architectures
idea ok'd by miod; tested on all architectures (except a few miod will
need to cleanup because he has them)


# 1.35 10-May-2007 deraadt

evcnt & friends were replaced by a proper interrupt counting mechanism 3 years ago; ok miod


# 1.34 04-May-2007 deraadt

make findblkmajor() and findblkname() MI; ok miod


# 1.33 04-May-2007 deraadt

setroot() was a ugly mix of MI and MD code, with different bugs on different
machines. Instead -- build one solid clean MI version, and thenchange all
the architectures to use it. ok various people, tested on almost all cases.
(it is a 10094 line diff..)


Revision tags: OPENBSD_4_0_BASE OPENBSD_4_1_BASE
# 1.32 28-May-2006 henning

intrducing device type DV_SENSOR turned out to be a bad idea as it
affects way more than just hotplug messages. remove DV_SENSOR and use
DV_DULL for the moment. proper solution coming.
discussed with deraadt mk jason


# 1.31 27-May-2006 mk

Make sensor add/remove create hotplug events (after much prodding from henning). Idea from mbalmer. 'in it goes!' deraadt.


Revision tags: OPENBSD_3_9_BASE
# 1.30 21-Jan-2006 miod

Remove now unused zeroref member in cfattach structures.


Revision tags: OPENBSD_3_7_BASE OPENBSD_3_8_BASE
# 1.29 23-Nov-2004 miod

Create the init process earlier, before the root filesystem is mounted,
and have it stall on a semaphore. This allows all kthread creations which
could have been requested during autoconf to be processed before root
is mounted as well.

This causes umass devices attached to any usb with flags 1 (such as on macppc)
to configure properly instead of panicing the kernel at mountroot time.

From NetBSD; tested by various.


# 1.28 17-Nov-2004 deraadt

firmware loading; ok pedro tedu dlg miod


Revision tags: OPENBSD_3_4_BASE OPENBSD_3_5_BASE OPENBSD_3_6_BASE SMP_SYNC_A SMP_SYNC_B
# 1.27 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


Revision tags: OPENBSD_3_3_BASE UBC_SYNC_A UBC_SYNC_B
# 1.26 06-Oct-2002 art

Remove some '#if 0' cruft.


Revision tags: OPENBSD_3_2_BASE
# 1.25 06-Sep-2002 deraadt

remove last , in enum


# 1.24 27-Aug-2002 wcobb

config_edit() isn't used anywhere. ok art@


Revision tags: OPENBSD_3_1_BASE
# 1.23 15-Mar-2002 millert

Cosmetic changes only, primarily making comments line up nicely after the
__P removal.


# 1.22 14-Mar-2002 millert

Final __P removal plus some cosmetic fixups


# 1.21 14-Mar-2002 millert

First round of __P removal in sys


Revision tags: OPENBSD_3_0_BASE UBC_BASE
# 1.20 01-Sep-2001 jason

branches: 1.20.4;
Add __HAVE_DEVICE_REGISTER to hp300/alpha (sparc64 already had it) and
clean up the arch specific #ifdef's in subr_autoconf.c; from NetBSD.
(tested by me on alpha/sparc64 and miod on hp300)


# 1.19 22-Jun-2001 deraadt

KNF


Revision tags: OPENBSD_2_7_BASE OPENBSD_2_8_BASE OPENBSD_2_9_BASE
# 1.18 09-Apr-2000 csapuntz

Added config_detach_children, config_activate_children.

Added ref counting to devices: device_ref, device_unref and a new method
for devices : ca_zeroref, called when the ref count hits zero.

Note that ca_zeroref may be called from interrupt context.


Revision tags: OPENBSD_2_6_BASE SMP_BASE kame_19991208
# 1.17 08-Aug-1999 niklas

branches: 1.17.4;
From NetBSD; new device detaching infrastructure.


# 1.16 05-Aug-1999 niklas

From NetBSD; config_defer to defer configuration of a device until after all
other siblings.


# 1.15 23-Jul-1999 niklas

Remove obsolete detach logic in preparation of a newer one


# 1.14 28-Apr-1999 deraadt

add autoconfig_verbose toggling command to boot_config


Revision tags: OPENBSD_2_4_BASE OPENBSD_2_5_BASE
# 1.13 11-May-1998 niklas

Formerly reuse of unit numbers of detached devices was impossible, with
this change starred devices will search from the first allowed unit for
such devices and up for free units when attaching. This means you have
to rerun config(8) before yopu compile current kernels. FYI, this is
a necessity when doing PCMCIA flashcard reading, otherwise you soon run
out of unit numbers.

I have also added a way to detach all children of a certain device, used
in a new PCMCIA framework to come, so you detach all functions on a
single PCMCIA card when pulling it out.

A few bugs wrt starred devices fixed in the autoconfig_verbose code too.
Last and least, fixed some panic messages.


Revision tags: OPENBSD_2_2_BASE OPENBSD_2_3_BASE
# 1.12 07-Aug-1997 downsj

Back that out, I'm too tired to be messing with this.


# 1.11 07-Aug-1997 downsj

Add cf_locnames to struct cfdata.


Revision tags: OPENBSD_2_1_BASE
# 1.10 23-Nov-1996 kstailey

added const to second parameter of cfprint_t routines


# 1.9 21-Nov-1996 mickey

export struct cfdata cfdata[];


Revision tags: OPENBSD_2_0_BASE
# 1.8 02-Jul-1996 deraadt

provide config_make_softc proto


# 1.7 23-Jun-1996 maja

Added support for user modifiable kernel at boot (-c) /maja


# 1.6 16-Jun-1996 deraadt

provide locator names to kernel (update your config(8) binary!)


# 1.5 29-Apr-1996 hvozda

Pull in John Kohl's [jtk@netbsd.org] most recent (15Apr96) APM and PCMCIA work
(original PCMCIA framework by Stefan Grefen [grefen@convex.com]).


# 1.4 21-Apr-1996 deraadt

partial sync with netbsd 960418, more to come


# 1.3 18-Apr-1996 niklas

Merge of NetBSD 960317


# 1.2 03-Mar-1996 niklas

From NetBSD: 960217 merge


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.63 07-Apr-2022 tb

Fix kernel builds with pseudo-device rd

Make the cf_attach member of struct cfdata const and sprinkle a few
const into subr_autoconf.c to make this work. Fixes the compilation
of sys/dev/rd.c with newly const rd_ca.

ok miod (who had a similar diff)


Revision tags: OPENBSD_7_1_BASE
# 1.62 16-Feb-2022 deraadt

change MD gosleep() and sleep_finish() to return int, the MI code will be
able to react to this suitably.


# 1.61 15-Feb-2022 deraadt

Since acpitoshiba brightness button processing no longer plays games
with AML parsing outside the acpi thread, the locking-release dance
around wsdisplay_{suspend,resume} can be removed
ok kettenis


# 1.60 15-Feb-2022 deraadt

when the MI suspend code encounters problems, we need a way to
reset the MD state before bailing out. New MD function sleep_abort()
does that.


# 1.59 15-Feb-2022 deraadt

MI disable_lid_wakeups() is not needed, x86 systems can do this
in sleep_resume(), which seems sensible for other future systems also


# 1.58 11-Feb-2022 deraadt

the sleep_clocks() hook is not needed because the architectures which
need to do this can do it a few moments later in a different hook


# 1.57 08-Feb-2022 deraadt

The suspend/resume code is a sticky mess of MI, MD, and ACPI sequencing.
This splits out the MI sequencing, backing it with per-architecture helper
functions. Further steps will be neccesary because ACPI and MD are too
tightly coupled, but soon we'll be able to use this code for more architectures
(which depends on figuring out the lowest-level cpu sleeping method)
ok kettenis


# 1.56 26-Oct-2021 deraadt

Improve unhibernate performance (30% on some machines, another upcoming diff
shows gains up to 50%) by skipping attach of irrelevant devices, which are
tagged CD_SKIPHIBERNATE in the per-driver cfdriver. In particular, usb devices
are not attached, so they don't need to detach during the suspend-unpack-resume.
New bootblocks are required (which tell the kernel it's job is unhibernate
before configure runs)
tested by various


Revision tags: OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE OPENBSD_6_7_BASE OPENBSD_6_8_BASE OPENBSD_6_9_BASE OPENBSD_7_0_BASE
# 1.55 10-Sep-2018 sashan

- if_cloners list populated at boot time only then becomes immutable,
so we can let go if_cloners_lock.

OK tb@, claudio@, bluhm@, kn@, henning@


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.54 11-Dec-2015 mpi

Replace mountroothook_establish(9) by config_mountroot(9) a narrower API
similar to config_defer(9).

ok mikeb@, deraadt@


# 1.53 11-Sep-2015 dlg

back out refcnt for dv_ref, there's too many hand crafted devices all
over the tree.

much encouragement from l2k15


# 1.52 11-Sep-2015 dlg

use refcnts for the device reference counts as an example of how
refcnt(9) can be used.


# 1.51 11-Sep-2015 miod

Change device locators type from int to long, for the sake of 64-bit ports
without proper device trees.

Be sure to build and install config(8) and rerun it before attempting to build
a kernel.

ok kettenis@ deraadt@ jasper@ visa@


Revision tags: OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.50 18-Sep-2014 kettenis

Introduce config_suspend_all(9) a function that invokes config_suspend(9)
on all relevant device hierarchies in the appropriate order. For now this
means mpath(4) and mainbus(4), doing mpath(4) before mainbus(4) when
suspending or powering down and doing mpath(4) after mainbus(4) when
resuming such that mpath(4) can realy on the underlying hardware being
in a functional state.

Fixes problems with unflushed disk caches on machines where mpath(4) takes
control of some of your disks.

ok dlg@


Revision tags: OPENBSD_5_6_BASE
# 1.49 29-Mar-2014 guenther

It's been a quarter century: we can assume volatile is present with that name.

ok dlg@ mpi@ deraadt@


# 1.48 13-Mar-2014 dlg

get rid of the assumption that the head of the alldevs list is the
"mainbus" device. this breaks when mpath is enabled because it
attaches before mainbus and therefore takes the head position.

have autoconf provide device_mainbus() which looks up mainbus_cd,
and use that instead.

discussed with deraadt who just wants mpath stuff to move forward
despite there being many ways to shine this particular turd.


Revision tags: OPENBSD_5_5_BASE
# 1.47 06-Dec-2013 deraadt

Add a DVACT_WAKEUP op to the *_activate() API. This is called after the
kernel resumes normal (non-cold, able to run processes, etc) operation.
Previously we were relying on specific DVACT_RESUME op's in drivers
creating callback/threads themselves, but that has become too common,
indicating the need for a built-in mechanism.
ok dlg kettenis, tested by a sufficient amount of people


# 1.46 27-Nov-2013 dlg

get rid of the goop for maintaining multiple cftables since theres
no current code there to add or remove them. such code was put in
17 years ago, disabled 14 years ago, and removed 11 years ago, so
i suspect we dont really need it or the goop to support it.

very ok miod@


Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.45 08-Oct-2012 deraadt

Revamp the sequences for suspend/hibernate -> resume so that the code
paths are reflexive. It is now possible to fail part-way through a
suspend sequence, and recover along the resume code path.
Split DVACT_SUSPEND by adding a new DVACT_POWERDOWN method is used
after hibernate (and suspend too) to finish the job. Some drivers
must be converted at the same time to use this instead of shutdown hooks
(the others will follow at a later time)
ok kettenis mlarkin


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.44 03-Jul-2011 matthew

Remove config_activate() and DVACT_ACTIVATE. PCMCIA's the only thing
that's ever used it, and it's long since been changed to use
DVACT_{QUIESCE,SUSPEND,RESUME} instead.

ok deraadt@, dlg@; miod@ also agreed with this idea when I brought it
up a few weeks ago


# 1.43 01-Jun-2011 matthew

Kill the nearly-15-years-dead cf_ivstubs field from struct cfdata.

ok miod@, deraadt@

N.B.: If you're following -current, you MUST recompile config(8) and
re-config your kernel or else ioconf.c will fail to compile.


Revision tags: OPENBSD_4_9_BASE
# 1.42 31-Aug-2010 deraadt

Add DVACT_QUIECE support. This is called before splhigh() and before
DVACT_SUSPEND, therefore DVACT_QUIECE can do standard sleeping operations
to get ready.
Discussed quite a while back with kettenis and jakemsr, oga suddenly needed
it as well and wrote half of it, so it was time to finish it.
proofread by miod.


Revision tags: OPENBSD_4_7_BASE OPENBSD_4_8_BASE
# 1.41 23-Nov-2009 deraadt

Make config_activate_children() more useable as a suspend-and-resume
device tree walker, and add config_suspend() as well.
ok mlarkin pirofti, discussion with kettenis


# 1.40 22-Nov-2009 pirofti

Forgot the declarations in former commit. From martin@, okay oga@.


# 1.39 22-Nov-2009 pirofti

Add basic suspend/resume autoconf functionality.

Okay deraadt@, kettenis@, mlarkin@.


# 1.38 13-Oct-2009 pirofti

Get rid of devact enum, substitute it with an int and coresponding defines.

This is needed for the addition of further suspend/resume actions.

Okay deraadt@, marco@.


Revision tags: OPENBSD_4_3_BASE OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE
# 1.37 24-Nov-2007 dlg

we dont need ot include sys/lock.h here

ok miod@ krw@


Revision tags: OPENBSD_4_2_BASE
# 1.36 15-May-2007 deraadt

kill __HAVE_DEVICE_REGISTER by requiring all architectures to have a
device_register() function -- even if it does nothing. reduces the
cpp-based blather different between architectures
idea ok'd by miod; tested on all architectures (except a few miod will
need to cleanup because he has them)


# 1.35 10-May-2007 deraadt

evcnt & friends were replaced by a proper interrupt counting mechanism 3 years ago; ok miod


# 1.34 04-May-2007 deraadt

make findblkmajor() and findblkname() MI; ok miod


# 1.33 04-May-2007 deraadt

setroot() was a ugly mix of MI and MD code, with different bugs on different
machines. Instead -- build one solid clean MI version, and thenchange all
the architectures to use it. ok various people, tested on almost all cases.
(it is a 10094 line diff..)


Revision tags: OPENBSD_4_0_BASE OPENBSD_4_1_BASE
# 1.32 28-May-2006 henning

intrducing device type DV_SENSOR turned out to be a bad idea as it
affects way more than just hotplug messages. remove DV_SENSOR and use
DV_DULL for the moment. proper solution coming.
discussed with deraadt mk jason


# 1.31 27-May-2006 mk

Make sensor add/remove create hotplug events (after much prodding from henning). Idea from mbalmer. 'in it goes!' deraadt.


Revision tags: OPENBSD_3_9_BASE
# 1.30 21-Jan-2006 miod

Remove now unused zeroref member in cfattach structures.


Revision tags: OPENBSD_3_7_BASE OPENBSD_3_8_BASE
# 1.29 23-Nov-2004 miod

Create the init process earlier, before the root filesystem is mounted,
and have it stall on a semaphore. This allows all kthread creations which
could have been requested during autoconf to be processed before root
is mounted as well.

This causes umass devices attached to any usb with flags 1 (such as on macppc)
to configure properly instead of panicing the kernel at mountroot time.

From NetBSD; tested by various.


# 1.28 17-Nov-2004 deraadt

firmware loading; ok pedro tedu dlg miod


Revision tags: OPENBSD_3_4_BASE OPENBSD_3_5_BASE OPENBSD_3_6_BASE SMP_SYNC_A SMP_SYNC_B
# 1.27 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


Revision tags: OPENBSD_3_3_BASE UBC_SYNC_A UBC_SYNC_B
# 1.26 06-Oct-2002 art

Remove some '#if 0' cruft.


Revision tags: OPENBSD_3_2_BASE
# 1.25 06-Sep-2002 deraadt

remove last , in enum


# 1.24 27-Aug-2002 wcobb

config_edit() isn't used anywhere. ok art@


Revision tags: OPENBSD_3_1_BASE
# 1.23 15-Mar-2002 millert

Cosmetic changes only, primarily making comments line up nicely after the
__P removal.


# 1.22 14-Mar-2002 millert

Final __P removal plus some cosmetic fixups


# 1.21 14-Mar-2002 millert

First round of __P removal in sys


Revision tags: OPENBSD_3_0_BASE UBC_BASE
# 1.20 01-Sep-2001 jason

branches: 1.20.4;
Add __HAVE_DEVICE_REGISTER to hp300/alpha (sparc64 already had it) and
clean up the arch specific #ifdef's in subr_autoconf.c; from NetBSD.
(tested by me on alpha/sparc64 and miod on hp300)


# 1.19 22-Jun-2001 deraadt

KNF


Revision tags: OPENBSD_2_7_BASE OPENBSD_2_8_BASE OPENBSD_2_9_BASE
# 1.18 09-Apr-2000 csapuntz

Added config_detach_children, config_activate_children.

Added ref counting to devices: device_ref, device_unref and a new method
for devices : ca_zeroref, called when the ref count hits zero.

Note that ca_zeroref may be called from interrupt context.


Revision tags: OPENBSD_2_6_BASE SMP_BASE kame_19991208
# 1.17 08-Aug-1999 niklas

branches: 1.17.4;
From NetBSD; new device detaching infrastructure.


# 1.16 05-Aug-1999 niklas

From NetBSD; config_defer to defer configuration of a device until after all
other siblings.


# 1.15 23-Jul-1999 niklas

Remove obsolete detach logic in preparation of a newer one


# 1.14 28-Apr-1999 deraadt

add autoconfig_verbose toggling command to boot_config


Revision tags: OPENBSD_2_4_BASE OPENBSD_2_5_BASE
# 1.13 11-May-1998 niklas

Formerly reuse of unit numbers of detached devices was impossible, with
this change starred devices will search from the first allowed unit for
such devices and up for free units when attaching. This means you have
to rerun config(8) before yopu compile current kernels. FYI, this is
a necessity when doing PCMCIA flashcard reading, otherwise you soon run
out of unit numbers.

I have also added a way to detach all children of a certain device, used
in a new PCMCIA framework to come, so you detach all functions on a
single PCMCIA card when pulling it out.

A few bugs wrt starred devices fixed in the autoconfig_verbose code too.
Last and least, fixed some panic messages.


Revision tags: OPENBSD_2_2_BASE OPENBSD_2_3_BASE
# 1.12 07-Aug-1997 downsj

Back that out, I'm too tired to be messing with this.


# 1.11 07-Aug-1997 downsj

Add cf_locnames to struct cfdata.


Revision tags: OPENBSD_2_1_BASE
# 1.10 23-Nov-1996 kstailey

added const to second parameter of cfprint_t routines


# 1.9 21-Nov-1996 mickey

export struct cfdata cfdata[];


Revision tags: OPENBSD_2_0_BASE
# 1.8 02-Jul-1996 deraadt

provide config_make_softc proto


# 1.7 23-Jun-1996 maja

Added support for user modifiable kernel at boot (-c) /maja


# 1.6 16-Jun-1996 deraadt

provide locator names to kernel (update your config(8) binary!)


# 1.5 29-Apr-1996 hvozda

Pull in John Kohl's [jtk@netbsd.org] most recent (15Apr96) APM and PCMCIA work
(original PCMCIA framework by Stefan Grefen [grefen@convex.com]).


# 1.4 21-Apr-1996 deraadt

partial sync with netbsd 960418, more to come


# 1.3 18-Apr-1996 niklas

Merge of NetBSD 960317


# 1.2 03-Mar-1996 niklas

From NetBSD: 960217 merge


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.62 16-Feb-2022 deraadt

change MD gosleep() and sleep_finish() to return int, the MI code will be
able to react to this suitably.


# 1.61 15-Feb-2022 deraadt

Since acpitoshiba brightness button processing no longer plays games
with AML parsing outside the acpi thread, the locking-release dance
around wsdisplay_{suspend,resume} can be removed
ok kettenis


# 1.60 15-Feb-2022 deraadt

when the MI suspend code encounters problems, we need a way to
reset the MD state before bailing out. New MD function sleep_abort()
does that.


# 1.59 15-Feb-2022 deraadt

MI disable_lid_wakeups() is not needed, x86 systems can do this
in sleep_resume(), which seems sensible for other future systems also


# 1.58 11-Feb-2022 deraadt

the sleep_clocks() hook is not needed because the architectures which
need to do this can do it a few moments later in a different hook


# 1.57 08-Feb-2022 deraadt

The suspend/resume code is a sticky mess of MI, MD, and ACPI sequencing.
This splits out the MI sequencing, backing it with per-architecture helper
functions. Further steps will be neccesary because ACPI and MD are too
tightly coupled, but soon we'll be able to use this code for more architectures
(which depends on figuring out the lowest-level cpu sleeping method)
ok kettenis


# 1.56 26-Oct-2021 deraadt

Improve unhibernate performance (30% on some machines, another upcoming diff
shows gains up to 50%) by skipping attach of irrelevant devices, which are
tagged CD_SKIPHIBERNATE in the per-driver cfdriver. In particular, usb devices
are not attached, so they don't need to detach during the suspend-unpack-resume.
New bootblocks are required (which tell the kernel it's job is unhibernate
before configure runs)
tested by various


Revision tags: OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE OPENBSD_6_7_BASE OPENBSD_6_8_BASE OPENBSD_6_9_BASE OPENBSD_7_0_BASE
# 1.55 10-Sep-2018 sashan

- if_cloners list populated at boot time only then becomes immutable,
so we can let go if_cloners_lock.

OK tb@, claudio@, bluhm@, kn@, henning@


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.54 11-Dec-2015 mpi

Replace mountroothook_establish(9) by config_mountroot(9) a narrower API
similar to config_defer(9).

ok mikeb@, deraadt@


# 1.53 11-Sep-2015 dlg

back out refcnt for dv_ref, there's too many hand crafted devices all
over the tree.

much encouragement from l2k15


# 1.52 11-Sep-2015 dlg

use refcnts for the device reference counts as an example of how
refcnt(9) can be used.


# 1.51 11-Sep-2015 miod

Change device locators type from int to long, for the sake of 64-bit ports
without proper device trees.

Be sure to build and install config(8) and rerun it before attempting to build
a kernel.

ok kettenis@ deraadt@ jasper@ visa@


Revision tags: OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.50 18-Sep-2014 kettenis

Introduce config_suspend_all(9) a function that invokes config_suspend(9)
on all relevant device hierarchies in the appropriate order. For now this
means mpath(4) and mainbus(4), doing mpath(4) before mainbus(4) when
suspending or powering down and doing mpath(4) after mainbus(4) when
resuming such that mpath(4) can realy on the underlying hardware being
in a functional state.

Fixes problems with unflushed disk caches on machines where mpath(4) takes
control of some of your disks.

ok dlg@


Revision tags: OPENBSD_5_6_BASE
# 1.49 29-Mar-2014 guenther

It's been a quarter century: we can assume volatile is present with that name.

ok dlg@ mpi@ deraadt@


# 1.48 13-Mar-2014 dlg

get rid of the assumption that the head of the alldevs list is the
"mainbus" device. this breaks when mpath is enabled because it
attaches before mainbus and therefore takes the head position.

have autoconf provide device_mainbus() which looks up mainbus_cd,
and use that instead.

discussed with deraadt who just wants mpath stuff to move forward
despite there being many ways to shine this particular turd.


Revision tags: OPENBSD_5_5_BASE
# 1.47 06-Dec-2013 deraadt

Add a DVACT_WAKEUP op to the *_activate() API. This is called after the
kernel resumes normal (non-cold, able to run processes, etc) operation.
Previously we were relying on specific DVACT_RESUME op's in drivers
creating callback/threads themselves, but that has become too common,
indicating the need for a built-in mechanism.
ok dlg kettenis, tested by a sufficient amount of people


# 1.46 27-Nov-2013 dlg

get rid of the goop for maintaining multiple cftables since theres
no current code there to add or remove them. such code was put in
17 years ago, disabled 14 years ago, and removed 11 years ago, so
i suspect we dont really need it or the goop to support it.

very ok miod@


Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.45 08-Oct-2012 deraadt

Revamp the sequences for suspend/hibernate -> resume so that the code
paths are reflexive. It is now possible to fail part-way through a
suspend sequence, and recover along the resume code path.
Split DVACT_SUSPEND by adding a new DVACT_POWERDOWN method is used
after hibernate (and suspend too) to finish the job. Some drivers
must be converted at the same time to use this instead of shutdown hooks
(the others will follow at a later time)
ok kettenis mlarkin


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.44 03-Jul-2011 matthew

Remove config_activate() and DVACT_ACTIVATE. PCMCIA's the only thing
that's ever used it, and it's long since been changed to use
DVACT_{QUIESCE,SUSPEND,RESUME} instead.

ok deraadt@, dlg@; miod@ also agreed with this idea when I brought it
up a few weeks ago


# 1.43 01-Jun-2011 matthew

Kill the nearly-15-years-dead cf_ivstubs field from struct cfdata.

ok miod@, deraadt@

N.B.: If you're following -current, you MUST recompile config(8) and
re-config your kernel or else ioconf.c will fail to compile.


Revision tags: OPENBSD_4_9_BASE
# 1.42 31-Aug-2010 deraadt

Add DVACT_QUIECE support. This is called before splhigh() and before
DVACT_SUSPEND, therefore DVACT_QUIECE can do standard sleeping operations
to get ready.
Discussed quite a while back with kettenis and jakemsr, oga suddenly needed
it as well and wrote half of it, so it was time to finish it.
proofread by miod.


Revision tags: OPENBSD_4_7_BASE OPENBSD_4_8_BASE
# 1.41 23-Nov-2009 deraadt

Make config_activate_children() more useable as a suspend-and-resume
device tree walker, and add config_suspend() as well.
ok mlarkin pirofti, discussion with kettenis


# 1.40 22-Nov-2009 pirofti

Forgot the declarations in former commit. From martin@, okay oga@.


# 1.39 22-Nov-2009 pirofti

Add basic suspend/resume autoconf functionality.

Okay deraadt@, kettenis@, mlarkin@.


# 1.38 13-Oct-2009 pirofti

Get rid of devact enum, substitute it with an int and coresponding defines.

This is needed for the addition of further suspend/resume actions.

Okay deraadt@, marco@.


Revision tags: OPENBSD_4_3_BASE OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE
# 1.37 24-Nov-2007 dlg

we dont need ot include sys/lock.h here

ok miod@ krw@


Revision tags: OPENBSD_4_2_BASE
# 1.36 15-May-2007 deraadt

kill __HAVE_DEVICE_REGISTER by requiring all architectures to have a
device_register() function -- even if it does nothing. reduces the
cpp-based blather different between architectures
idea ok'd by miod; tested on all architectures (except a few miod will
need to cleanup because he has them)


# 1.35 10-May-2007 deraadt

evcnt & friends were replaced by a proper interrupt counting mechanism 3 years ago; ok miod


# 1.34 04-May-2007 deraadt

make findblkmajor() and findblkname() MI; ok miod


# 1.33 04-May-2007 deraadt

setroot() was a ugly mix of MI and MD code, with different bugs on different
machines. Instead -- build one solid clean MI version, and thenchange all
the architectures to use it. ok various people, tested on almost all cases.
(it is a 10094 line diff..)


Revision tags: OPENBSD_4_0_BASE OPENBSD_4_1_BASE
# 1.32 28-May-2006 henning

intrducing device type DV_SENSOR turned out to be a bad idea as it
affects way more than just hotplug messages. remove DV_SENSOR and use
DV_DULL for the moment. proper solution coming.
discussed with deraadt mk jason


# 1.31 27-May-2006 mk

Make sensor add/remove create hotplug events (after much prodding from henning). Idea from mbalmer. 'in it goes!' deraadt.


Revision tags: OPENBSD_3_9_BASE
# 1.30 21-Jan-2006 miod

Remove now unused zeroref member in cfattach structures.


Revision tags: OPENBSD_3_7_BASE OPENBSD_3_8_BASE
# 1.29 23-Nov-2004 miod

Create the init process earlier, before the root filesystem is mounted,
and have it stall on a semaphore. This allows all kthread creations which
could have been requested during autoconf to be processed before root
is mounted as well.

This causes umass devices attached to any usb with flags 1 (such as on macppc)
to configure properly instead of panicing the kernel at mountroot time.

From NetBSD; tested by various.


# 1.28 17-Nov-2004 deraadt

firmware loading; ok pedro tedu dlg miod


Revision tags: OPENBSD_3_4_BASE OPENBSD_3_5_BASE OPENBSD_3_6_BASE SMP_SYNC_A SMP_SYNC_B
# 1.27 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


Revision tags: OPENBSD_3_3_BASE UBC_SYNC_A UBC_SYNC_B
# 1.26 06-Oct-2002 art

Remove some '#if 0' cruft.


Revision tags: OPENBSD_3_2_BASE
# 1.25 06-Sep-2002 deraadt

remove last , in enum


# 1.24 27-Aug-2002 wcobb

config_edit() isn't used anywhere. ok art@


Revision tags: OPENBSD_3_1_BASE
# 1.23 15-Mar-2002 millert

Cosmetic changes only, primarily making comments line up nicely after the
__P removal.


# 1.22 14-Mar-2002 millert

Final __P removal plus some cosmetic fixups


# 1.21 14-Mar-2002 millert

First round of __P removal in sys


Revision tags: OPENBSD_3_0_BASE UBC_BASE
# 1.20 01-Sep-2001 jason

branches: 1.20.4;
Add __HAVE_DEVICE_REGISTER to hp300/alpha (sparc64 already had it) and
clean up the arch specific #ifdef's in subr_autoconf.c; from NetBSD.
(tested by me on alpha/sparc64 and miod on hp300)


# 1.19 22-Jun-2001 deraadt

KNF


Revision tags: OPENBSD_2_7_BASE OPENBSD_2_8_BASE OPENBSD_2_9_BASE
# 1.18 09-Apr-2000 csapuntz

Added config_detach_children, config_activate_children.

Added ref counting to devices: device_ref, device_unref and a new method
for devices : ca_zeroref, called when the ref count hits zero.

Note that ca_zeroref may be called from interrupt context.


Revision tags: OPENBSD_2_6_BASE SMP_BASE kame_19991208
# 1.17 08-Aug-1999 niklas

branches: 1.17.4;
From NetBSD; new device detaching infrastructure.


# 1.16 05-Aug-1999 niklas

From NetBSD; config_defer to defer configuration of a device until after all
other siblings.


# 1.15 23-Jul-1999 niklas

Remove obsolete detach logic in preparation of a newer one


# 1.14 28-Apr-1999 deraadt

add autoconfig_verbose toggling command to boot_config


Revision tags: OPENBSD_2_4_BASE OPENBSD_2_5_BASE
# 1.13 11-May-1998 niklas

Formerly reuse of unit numbers of detached devices was impossible, with
this change starred devices will search from the first allowed unit for
such devices and up for free units when attaching. This means you have
to rerun config(8) before yopu compile current kernels. FYI, this is
a necessity when doing PCMCIA flashcard reading, otherwise you soon run
out of unit numbers.

I have also added a way to detach all children of a certain device, used
in a new PCMCIA framework to come, so you detach all functions on a
single PCMCIA card when pulling it out.

A few bugs wrt starred devices fixed in the autoconfig_verbose code too.
Last and least, fixed some panic messages.


Revision tags: OPENBSD_2_2_BASE OPENBSD_2_3_BASE
# 1.12 07-Aug-1997 downsj

Back that out, I'm too tired to be messing with this.


# 1.11 07-Aug-1997 downsj

Add cf_locnames to struct cfdata.


Revision tags: OPENBSD_2_1_BASE
# 1.10 23-Nov-1996 kstailey

added const to second parameter of cfprint_t routines


# 1.9 21-Nov-1996 mickey

export struct cfdata cfdata[];


Revision tags: OPENBSD_2_0_BASE
# 1.8 02-Jul-1996 deraadt

provide config_make_softc proto


# 1.7 23-Jun-1996 maja

Added support for user modifiable kernel at boot (-c) /maja


# 1.6 16-Jun-1996 deraadt

provide locator names to kernel (update your config(8) binary!)


# 1.5 29-Apr-1996 hvozda

Pull in John Kohl's [jtk@netbsd.org] most recent (15Apr96) APM and PCMCIA work
(original PCMCIA framework by Stefan Grefen [grefen@convex.com]).


# 1.4 21-Apr-1996 deraadt

partial sync with netbsd 960418, more to come


# 1.3 18-Apr-1996 niklas

Merge of NetBSD 960317


# 1.2 03-Mar-1996 niklas

From NetBSD: 960217 merge


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.59 15-Feb-2022 deraadt

MI disable_lid_wakeups() is not needed, x86 systems can do this
in sleep_resume(), which seems sensible for other future systems also


# 1.58 11-Feb-2022 deraadt

the sleep_clocks() hook is not needed because the architectures which
need to do this can do it a few moments later in a different hook


# 1.57 08-Feb-2022 deraadt

The suspend/resume code is a sticky mess of MI, MD, and ACPI sequencing.
This splits out the MI sequencing, backing it with per-architecture helper
functions. Further steps will be neccesary because ACPI and MD are too
tightly coupled, but soon we'll be able to use this code for more architectures
(which depends on figuring out the lowest-level cpu sleeping method)
ok kettenis


# 1.56 26-Oct-2021 deraadt

Improve unhibernate performance (30% on some machines, another upcoming diff
shows gains up to 50%) by skipping attach of irrelevant devices, which are
tagged CD_SKIPHIBERNATE in the per-driver cfdriver. In particular, usb devices
are not attached, so they don't need to detach during the suspend-unpack-resume.
New bootblocks are required (which tell the kernel it's job is unhibernate
before configure runs)
tested by various


Revision tags: OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE OPENBSD_6_7_BASE OPENBSD_6_8_BASE OPENBSD_6_9_BASE OPENBSD_7_0_BASE
# 1.55 10-Sep-2018 sashan

- if_cloners list populated at boot time only then becomes immutable,
so we can let go if_cloners_lock.

OK tb@, claudio@, bluhm@, kn@, henning@


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.54 11-Dec-2015 mpi

Replace mountroothook_establish(9) by config_mountroot(9) a narrower API
similar to config_defer(9).

ok mikeb@, deraadt@


# 1.53 11-Sep-2015 dlg

back out refcnt for dv_ref, there's too many hand crafted devices all
over the tree.

much encouragement from l2k15


# 1.52 11-Sep-2015 dlg

use refcnts for the device reference counts as an example of how
refcnt(9) can be used.


# 1.51 11-Sep-2015 miod

Change device locators type from int to long, for the sake of 64-bit ports
without proper device trees.

Be sure to build and install config(8) and rerun it before attempting to build
a kernel.

ok kettenis@ deraadt@ jasper@ visa@


Revision tags: OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.50 18-Sep-2014 kettenis

Introduce config_suspend_all(9) a function that invokes config_suspend(9)
on all relevant device hierarchies in the appropriate order. For now this
means mpath(4) and mainbus(4), doing mpath(4) before mainbus(4) when
suspending or powering down and doing mpath(4) after mainbus(4) when
resuming such that mpath(4) can realy on the underlying hardware being
in a functional state.

Fixes problems with unflushed disk caches on machines where mpath(4) takes
control of some of your disks.

ok dlg@


Revision tags: OPENBSD_5_6_BASE
# 1.49 29-Mar-2014 guenther

It's been a quarter century: we can assume volatile is present with that name.

ok dlg@ mpi@ deraadt@


# 1.48 13-Mar-2014 dlg

get rid of the assumption that the head of the alldevs list is the
"mainbus" device. this breaks when mpath is enabled because it
attaches before mainbus and therefore takes the head position.

have autoconf provide device_mainbus() which looks up mainbus_cd,
and use that instead.

discussed with deraadt who just wants mpath stuff to move forward
despite there being many ways to shine this particular turd.


Revision tags: OPENBSD_5_5_BASE
# 1.47 06-Dec-2013 deraadt

Add a DVACT_WAKEUP op to the *_activate() API. This is called after the
kernel resumes normal (non-cold, able to run processes, etc) operation.
Previously we were relying on specific DVACT_RESUME op's in drivers
creating callback/threads themselves, but that has become too common,
indicating the need for a built-in mechanism.
ok dlg kettenis, tested by a sufficient amount of people


# 1.46 27-Nov-2013 dlg

get rid of the goop for maintaining multiple cftables since theres
no current code there to add or remove them. such code was put in
17 years ago, disabled 14 years ago, and removed 11 years ago, so
i suspect we dont really need it or the goop to support it.

very ok miod@


Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.45 08-Oct-2012 deraadt

Revamp the sequences for suspend/hibernate -> resume so that the code
paths are reflexive. It is now possible to fail part-way through a
suspend sequence, and recover along the resume code path.
Split DVACT_SUSPEND by adding a new DVACT_POWERDOWN method is used
after hibernate (and suspend too) to finish the job. Some drivers
must be converted at the same time to use this instead of shutdown hooks
(the others will follow at a later time)
ok kettenis mlarkin


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.44 03-Jul-2011 matthew

Remove config_activate() and DVACT_ACTIVATE. PCMCIA's the only thing
that's ever used it, and it's long since been changed to use
DVACT_{QUIESCE,SUSPEND,RESUME} instead.

ok deraadt@, dlg@; miod@ also agreed with this idea when I brought it
up a few weeks ago


# 1.43 01-Jun-2011 matthew

Kill the nearly-15-years-dead cf_ivstubs field from struct cfdata.

ok miod@, deraadt@

N.B.: If you're following -current, you MUST recompile config(8) and
re-config your kernel or else ioconf.c will fail to compile.


Revision tags: OPENBSD_4_9_BASE
# 1.42 31-Aug-2010 deraadt

Add DVACT_QUIECE support. This is called before splhigh() and before
DVACT_SUSPEND, therefore DVACT_QUIECE can do standard sleeping operations
to get ready.
Discussed quite a while back with kettenis and jakemsr, oga suddenly needed
it as well and wrote half of it, so it was time to finish it.
proofread by miod.


Revision tags: OPENBSD_4_7_BASE OPENBSD_4_8_BASE
# 1.41 23-Nov-2009 deraadt

Make config_activate_children() more useable as a suspend-and-resume
device tree walker, and add config_suspend() as well.
ok mlarkin pirofti, discussion with kettenis


# 1.40 22-Nov-2009 pirofti

Forgot the declarations in former commit. From martin@, okay oga@.


# 1.39 22-Nov-2009 pirofti

Add basic suspend/resume autoconf functionality.

Okay deraadt@, kettenis@, mlarkin@.


# 1.38 13-Oct-2009 pirofti

Get rid of devact enum, substitute it with an int and coresponding defines.

This is needed for the addition of further suspend/resume actions.

Okay deraadt@, marco@.


Revision tags: OPENBSD_4_3_BASE OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE
# 1.37 24-Nov-2007 dlg

we dont need ot include sys/lock.h here

ok miod@ krw@


Revision tags: OPENBSD_4_2_BASE
# 1.36 15-May-2007 deraadt

kill __HAVE_DEVICE_REGISTER by requiring all architectures to have a
device_register() function -- even if it does nothing. reduces the
cpp-based blather different between architectures
idea ok'd by miod; tested on all architectures (except a few miod will
need to cleanup because he has them)


# 1.35 10-May-2007 deraadt

evcnt & friends were replaced by a proper interrupt counting mechanism 3 years ago; ok miod


# 1.34 04-May-2007 deraadt

make findblkmajor() and findblkname() MI; ok miod


# 1.33 04-May-2007 deraadt

setroot() was a ugly mix of MI and MD code, with different bugs on different
machines. Instead -- build one solid clean MI version, and thenchange all
the architectures to use it. ok various people, tested on almost all cases.
(it is a 10094 line diff..)


Revision tags: OPENBSD_4_0_BASE OPENBSD_4_1_BASE
# 1.32 28-May-2006 henning

intrducing device type DV_SENSOR turned out to be a bad idea as it
affects way more than just hotplug messages. remove DV_SENSOR and use
DV_DULL for the moment. proper solution coming.
discussed with deraadt mk jason


# 1.31 27-May-2006 mk

Make sensor add/remove create hotplug events (after much prodding from henning). Idea from mbalmer. 'in it goes!' deraadt.


Revision tags: OPENBSD_3_9_BASE
# 1.30 21-Jan-2006 miod

Remove now unused zeroref member in cfattach structures.


Revision tags: OPENBSD_3_7_BASE OPENBSD_3_8_BASE
# 1.29 23-Nov-2004 miod

Create the init process earlier, before the root filesystem is mounted,
and have it stall on a semaphore. This allows all kthread creations which
could have been requested during autoconf to be processed before root
is mounted as well.

This causes umass devices attached to any usb with flags 1 (such as on macppc)
to configure properly instead of panicing the kernel at mountroot time.

From NetBSD; tested by various.


# 1.28 17-Nov-2004 deraadt

firmware loading; ok pedro tedu dlg miod


Revision tags: OPENBSD_3_4_BASE OPENBSD_3_5_BASE OPENBSD_3_6_BASE SMP_SYNC_A SMP_SYNC_B
# 1.27 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


Revision tags: OPENBSD_3_3_BASE UBC_SYNC_A UBC_SYNC_B
# 1.26 06-Oct-2002 art

Remove some '#if 0' cruft.


Revision tags: OPENBSD_3_2_BASE
# 1.25 06-Sep-2002 deraadt

remove last , in enum


# 1.24 27-Aug-2002 wcobb

config_edit() isn't used anywhere. ok art@


Revision tags: OPENBSD_3_1_BASE
# 1.23 15-Mar-2002 millert

Cosmetic changes only, primarily making comments line up nicely after the
__P removal.


# 1.22 14-Mar-2002 millert

Final __P removal plus some cosmetic fixups


# 1.21 14-Mar-2002 millert

First round of __P removal in sys


Revision tags: OPENBSD_3_0_BASE UBC_BASE
# 1.20 01-Sep-2001 jason

branches: 1.20.4;
Add __HAVE_DEVICE_REGISTER to hp300/alpha (sparc64 already had it) and
clean up the arch specific #ifdef's in subr_autoconf.c; from NetBSD.
(tested by me on alpha/sparc64 and miod on hp300)


# 1.19 22-Jun-2001 deraadt

KNF


Revision tags: OPENBSD_2_7_BASE OPENBSD_2_8_BASE OPENBSD_2_9_BASE
# 1.18 09-Apr-2000 csapuntz

Added config_detach_children, config_activate_children.

Added ref counting to devices: device_ref, device_unref and a new method
for devices : ca_zeroref, called when the ref count hits zero.

Note that ca_zeroref may be called from interrupt context.


Revision tags: OPENBSD_2_6_BASE SMP_BASE kame_19991208
# 1.17 08-Aug-1999 niklas

branches: 1.17.4;
From NetBSD; new device detaching infrastructure.


# 1.16 05-Aug-1999 niklas

From NetBSD; config_defer to defer configuration of a device until after all
other siblings.


# 1.15 23-Jul-1999 niklas

Remove obsolete detach logic in preparation of a newer one


# 1.14 28-Apr-1999 deraadt

add autoconfig_verbose toggling command to boot_config


Revision tags: OPENBSD_2_4_BASE OPENBSD_2_5_BASE
# 1.13 11-May-1998 niklas

Formerly reuse of unit numbers of detached devices was impossible, with
this change starred devices will search from the first allowed unit for
such devices and up for free units when attaching. This means you have
to rerun config(8) before yopu compile current kernels. FYI, this is
a necessity when doing PCMCIA flashcard reading, otherwise you soon run
out of unit numbers.

I have also added a way to detach all children of a certain device, used
in a new PCMCIA framework to come, so you detach all functions on a
single PCMCIA card when pulling it out.

A few bugs wrt starred devices fixed in the autoconfig_verbose code too.
Last and least, fixed some panic messages.


Revision tags: OPENBSD_2_2_BASE OPENBSD_2_3_BASE
# 1.12 07-Aug-1997 downsj

Back that out, I'm too tired to be messing with this.


# 1.11 07-Aug-1997 downsj

Add cf_locnames to struct cfdata.


Revision tags: OPENBSD_2_1_BASE
# 1.10 23-Nov-1996 kstailey

added const to second parameter of cfprint_t routines


# 1.9 21-Nov-1996 mickey

export struct cfdata cfdata[];


Revision tags: OPENBSD_2_0_BASE
# 1.8 02-Jul-1996 deraadt

provide config_make_softc proto


# 1.7 23-Jun-1996 maja

Added support for user modifiable kernel at boot (-c) /maja


# 1.6 16-Jun-1996 deraadt

provide locator names to kernel (update your config(8) binary!)


# 1.5 29-Apr-1996 hvozda

Pull in John Kohl's [jtk@netbsd.org] most recent (15Apr96) APM and PCMCIA work
(original PCMCIA framework by Stefan Grefen [grefen@convex.com]).


# 1.4 21-Apr-1996 deraadt

partial sync with netbsd 960418, more to come


# 1.3 18-Apr-1996 niklas

Merge of NetBSD 960317


# 1.2 03-Mar-1996 niklas

From NetBSD: 960217 merge


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.58 11-Feb-2022 deraadt

the sleep_clocks() hook is not needed because the architectures which
need to do this can do it a few moments later in a different hook


# 1.57 08-Feb-2022 deraadt

The suspend/resume code is a sticky mess of MI, MD, and ACPI sequencing.
This splits out the MI sequencing, backing it with per-architecture helper
functions. Further steps will be neccesary because ACPI and MD are too
tightly coupled, but soon we'll be able to use this code for more architectures
(which depends on figuring out the lowest-level cpu sleeping method)
ok kettenis


# 1.56 26-Oct-2021 deraadt

Improve unhibernate performance (30% on some machines, another upcoming diff
shows gains up to 50%) by skipping attach of irrelevant devices, which are
tagged CD_SKIPHIBERNATE in the per-driver cfdriver. In particular, usb devices
are not attached, so they don't need to detach during the suspend-unpack-resume.
New bootblocks are required (which tell the kernel it's job is unhibernate
before configure runs)
tested by various


Revision tags: OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE OPENBSD_6_7_BASE OPENBSD_6_8_BASE OPENBSD_6_9_BASE OPENBSD_7_0_BASE
# 1.55 10-Sep-2018 sashan

- if_cloners list populated at boot time only then becomes immutable,
so we can let go if_cloners_lock.

OK tb@, claudio@, bluhm@, kn@, henning@


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.54 11-Dec-2015 mpi

Replace mountroothook_establish(9) by config_mountroot(9) a narrower API
similar to config_defer(9).

ok mikeb@, deraadt@


# 1.53 11-Sep-2015 dlg

back out refcnt for dv_ref, there's too many hand crafted devices all
over the tree.

much encouragement from l2k15


# 1.52 11-Sep-2015 dlg

use refcnts for the device reference counts as an example of how
refcnt(9) can be used.


# 1.51 11-Sep-2015 miod

Change device locators type from int to long, for the sake of 64-bit ports
without proper device trees.

Be sure to build and install config(8) and rerun it before attempting to build
a kernel.

ok kettenis@ deraadt@ jasper@ visa@


Revision tags: OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.50 18-Sep-2014 kettenis

Introduce config_suspend_all(9) a function that invokes config_suspend(9)
on all relevant device hierarchies in the appropriate order. For now this
means mpath(4) and mainbus(4), doing mpath(4) before mainbus(4) when
suspending or powering down and doing mpath(4) after mainbus(4) when
resuming such that mpath(4) can realy on the underlying hardware being
in a functional state.

Fixes problems with unflushed disk caches on machines where mpath(4) takes
control of some of your disks.

ok dlg@


Revision tags: OPENBSD_5_6_BASE
# 1.49 29-Mar-2014 guenther

It's been a quarter century: we can assume volatile is present with that name.

ok dlg@ mpi@ deraadt@


# 1.48 13-Mar-2014 dlg

get rid of the assumption that the head of the alldevs list is the
"mainbus" device. this breaks when mpath is enabled because it
attaches before mainbus and therefore takes the head position.

have autoconf provide device_mainbus() which looks up mainbus_cd,
and use that instead.

discussed with deraadt who just wants mpath stuff to move forward
despite there being many ways to shine this particular turd.


Revision tags: OPENBSD_5_5_BASE
# 1.47 06-Dec-2013 deraadt

Add a DVACT_WAKEUP op to the *_activate() API. This is called after the
kernel resumes normal (non-cold, able to run processes, etc) operation.
Previously we were relying on specific DVACT_RESUME op's in drivers
creating callback/threads themselves, but that has become too common,
indicating the need for a built-in mechanism.
ok dlg kettenis, tested by a sufficient amount of people


# 1.46 27-Nov-2013 dlg

get rid of the goop for maintaining multiple cftables since theres
no current code there to add or remove them. such code was put in
17 years ago, disabled 14 years ago, and removed 11 years ago, so
i suspect we dont really need it or the goop to support it.

very ok miod@


Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.45 08-Oct-2012 deraadt

Revamp the sequences for suspend/hibernate -> resume so that the code
paths are reflexive. It is now possible to fail part-way through a
suspend sequence, and recover along the resume code path.
Split DVACT_SUSPEND by adding a new DVACT_POWERDOWN method is used
after hibernate (and suspend too) to finish the job. Some drivers
must be converted at the same time to use this instead of shutdown hooks
(the others will follow at a later time)
ok kettenis mlarkin


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.44 03-Jul-2011 matthew

Remove config_activate() and DVACT_ACTIVATE. PCMCIA's the only thing
that's ever used it, and it's long since been changed to use
DVACT_{QUIESCE,SUSPEND,RESUME} instead.

ok deraadt@, dlg@; miod@ also agreed with this idea when I brought it
up a few weeks ago


# 1.43 01-Jun-2011 matthew

Kill the nearly-15-years-dead cf_ivstubs field from struct cfdata.

ok miod@, deraadt@

N.B.: If you're following -current, you MUST recompile config(8) and
re-config your kernel or else ioconf.c will fail to compile.


Revision tags: OPENBSD_4_9_BASE
# 1.42 31-Aug-2010 deraadt

Add DVACT_QUIECE support. This is called before splhigh() and before
DVACT_SUSPEND, therefore DVACT_QUIECE can do standard sleeping operations
to get ready.
Discussed quite a while back with kettenis and jakemsr, oga suddenly needed
it as well and wrote half of it, so it was time to finish it.
proofread by miod.


Revision tags: OPENBSD_4_7_BASE OPENBSD_4_8_BASE
# 1.41 23-Nov-2009 deraadt

Make config_activate_children() more useable as a suspend-and-resume
device tree walker, and add config_suspend() as well.
ok mlarkin pirofti, discussion with kettenis


# 1.40 22-Nov-2009 pirofti

Forgot the declarations in former commit. From martin@, okay oga@.


# 1.39 22-Nov-2009 pirofti

Add basic suspend/resume autoconf functionality.

Okay deraadt@, kettenis@, mlarkin@.


# 1.38 13-Oct-2009 pirofti

Get rid of devact enum, substitute it with an int and coresponding defines.

This is needed for the addition of further suspend/resume actions.

Okay deraadt@, marco@.


Revision tags: OPENBSD_4_3_BASE OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE
# 1.37 24-Nov-2007 dlg

we dont need ot include sys/lock.h here

ok miod@ krw@


Revision tags: OPENBSD_4_2_BASE
# 1.36 15-May-2007 deraadt

kill __HAVE_DEVICE_REGISTER by requiring all architectures to have a
device_register() function -- even if it does nothing. reduces the
cpp-based blather different between architectures
idea ok'd by miod; tested on all architectures (except a few miod will
need to cleanup because he has them)


# 1.35 10-May-2007 deraadt

evcnt & friends were replaced by a proper interrupt counting mechanism 3 years ago; ok miod


# 1.34 04-May-2007 deraadt

make findblkmajor() and findblkname() MI; ok miod


# 1.33 04-May-2007 deraadt

setroot() was a ugly mix of MI and MD code, with different bugs on different
machines. Instead -- build one solid clean MI version, and thenchange all
the architectures to use it. ok various people, tested on almost all cases.
(it is a 10094 line diff..)


Revision tags: OPENBSD_4_0_BASE OPENBSD_4_1_BASE
# 1.32 28-May-2006 henning

intrducing device type DV_SENSOR turned out to be a bad idea as it
affects way more than just hotplug messages. remove DV_SENSOR and use
DV_DULL for the moment. proper solution coming.
discussed with deraadt mk jason


# 1.31 27-May-2006 mk

Make sensor add/remove create hotplug events (after much prodding from henning). Idea from mbalmer. 'in it goes!' deraadt.


Revision tags: OPENBSD_3_9_BASE
# 1.30 21-Jan-2006 miod

Remove now unused zeroref member in cfattach structures.


Revision tags: OPENBSD_3_7_BASE OPENBSD_3_8_BASE
# 1.29 23-Nov-2004 miod

Create the init process earlier, before the root filesystem is mounted,
and have it stall on a semaphore. This allows all kthread creations which
could have been requested during autoconf to be processed before root
is mounted as well.

This causes umass devices attached to any usb with flags 1 (such as on macppc)
to configure properly instead of panicing the kernel at mountroot time.

From NetBSD; tested by various.


# 1.28 17-Nov-2004 deraadt

firmware loading; ok pedro tedu dlg miod


Revision tags: OPENBSD_3_4_BASE OPENBSD_3_5_BASE OPENBSD_3_6_BASE SMP_SYNC_A SMP_SYNC_B
# 1.27 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


Revision tags: OPENBSD_3_3_BASE UBC_SYNC_A UBC_SYNC_B
# 1.26 06-Oct-2002 art

Remove some '#if 0' cruft.


Revision tags: OPENBSD_3_2_BASE
# 1.25 06-Sep-2002 deraadt

remove last , in enum


# 1.24 27-Aug-2002 wcobb

config_edit() isn't used anywhere. ok art@


Revision tags: OPENBSD_3_1_BASE
# 1.23 15-Mar-2002 millert

Cosmetic changes only, primarily making comments line up nicely after the
__P removal.


# 1.22 14-Mar-2002 millert

Final __P removal plus some cosmetic fixups


# 1.21 14-Mar-2002 millert

First round of __P removal in sys


Revision tags: OPENBSD_3_0_BASE UBC_BASE
# 1.20 01-Sep-2001 jason

branches: 1.20.4;
Add __HAVE_DEVICE_REGISTER to hp300/alpha (sparc64 already had it) and
clean up the arch specific #ifdef's in subr_autoconf.c; from NetBSD.
(tested by me on alpha/sparc64 and miod on hp300)


# 1.19 22-Jun-2001 deraadt

KNF


Revision tags: OPENBSD_2_7_BASE OPENBSD_2_8_BASE OPENBSD_2_9_BASE
# 1.18 09-Apr-2000 csapuntz

Added config_detach_children, config_activate_children.

Added ref counting to devices: device_ref, device_unref and a new method
for devices : ca_zeroref, called when the ref count hits zero.

Note that ca_zeroref may be called from interrupt context.


Revision tags: OPENBSD_2_6_BASE SMP_BASE kame_19991208
# 1.17 08-Aug-1999 niklas

branches: 1.17.4;
From NetBSD; new device detaching infrastructure.


# 1.16 05-Aug-1999 niklas

From NetBSD; config_defer to defer configuration of a device until after all
other siblings.


# 1.15 23-Jul-1999 niklas

Remove obsolete detach logic in preparation of a newer one


# 1.14 28-Apr-1999 deraadt

add autoconfig_verbose toggling command to boot_config


Revision tags: OPENBSD_2_4_BASE OPENBSD_2_5_BASE
# 1.13 11-May-1998 niklas

Formerly reuse of unit numbers of detached devices was impossible, with
this change starred devices will search from the first allowed unit for
such devices and up for free units when attaching. This means you have
to rerun config(8) before yopu compile current kernels. FYI, this is
a necessity when doing PCMCIA flashcard reading, otherwise you soon run
out of unit numbers.

I have also added a way to detach all children of a certain device, used
in a new PCMCIA framework to come, so you detach all functions on a
single PCMCIA card when pulling it out.

A few bugs wrt starred devices fixed in the autoconfig_verbose code too.
Last and least, fixed some panic messages.


Revision tags: OPENBSD_2_2_BASE OPENBSD_2_3_BASE
# 1.12 07-Aug-1997 downsj

Back that out, I'm too tired to be messing with this.


# 1.11 07-Aug-1997 downsj

Add cf_locnames to struct cfdata.


Revision tags: OPENBSD_2_1_BASE
# 1.10 23-Nov-1996 kstailey

added const to second parameter of cfprint_t routines


# 1.9 21-Nov-1996 mickey

export struct cfdata cfdata[];


Revision tags: OPENBSD_2_0_BASE
# 1.8 02-Jul-1996 deraadt

provide config_make_softc proto


# 1.7 23-Jun-1996 maja

Added support for user modifiable kernel at boot (-c) /maja


# 1.6 16-Jun-1996 deraadt

provide locator names to kernel (update your config(8) binary!)


# 1.5 29-Apr-1996 hvozda

Pull in John Kohl's [jtk@netbsd.org] most recent (15Apr96) APM and PCMCIA work
(original PCMCIA framework by Stefan Grefen [grefen@convex.com]).


# 1.4 21-Apr-1996 deraadt

partial sync with netbsd 960418, more to come


# 1.3 18-Apr-1996 niklas

Merge of NetBSD 960317


# 1.2 03-Mar-1996 niklas

From NetBSD: 960217 merge


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.57 08-Feb-2022 deraadt

The suspend/resume code is a sticky mess of MI, MD, and ACPI sequencing.
This splits out the MI sequencing, backing it with per-architecture helper
functions. Further steps will be neccesary because ACPI and MD are too
tightly coupled, but soon we'll be able to use this code for more architectures
(which depends on figuring out the lowest-level cpu sleeping method)
ok kettenis


# 1.56 26-Oct-2021 deraadt

Improve unhibernate performance (30% on some machines, another upcoming diff
shows gains up to 50%) by skipping attach of irrelevant devices, which are
tagged CD_SKIPHIBERNATE in the per-driver cfdriver. In particular, usb devices
are not attached, so they don't need to detach during the suspend-unpack-resume.
New bootblocks are required (which tell the kernel it's job is unhibernate
before configure runs)
tested by various


Revision tags: OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE OPENBSD_6_7_BASE OPENBSD_6_8_BASE OPENBSD_6_9_BASE OPENBSD_7_0_BASE
# 1.55 10-Sep-2018 sashan

- if_cloners list populated at boot time only then becomes immutable,
so we can let go if_cloners_lock.

OK tb@, claudio@, bluhm@, kn@, henning@


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.54 11-Dec-2015 mpi

Replace mountroothook_establish(9) by config_mountroot(9) a narrower API
similar to config_defer(9).

ok mikeb@, deraadt@


# 1.53 11-Sep-2015 dlg

back out refcnt for dv_ref, there's too many hand crafted devices all
over the tree.

much encouragement from l2k15


# 1.52 11-Sep-2015 dlg

use refcnts for the device reference counts as an example of how
refcnt(9) can be used.


# 1.51 11-Sep-2015 miod

Change device locators type from int to long, for the sake of 64-bit ports
without proper device trees.

Be sure to build and install config(8) and rerun it before attempting to build
a kernel.

ok kettenis@ deraadt@ jasper@ visa@


Revision tags: OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.50 18-Sep-2014 kettenis

Introduce config_suspend_all(9) a function that invokes config_suspend(9)
on all relevant device hierarchies in the appropriate order. For now this
means mpath(4) and mainbus(4), doing mpath(4) before mainbus(4) when
suspending or powering down and doing mpath(4) after mainbus(4) when
resuming such that mpath(4) can realy on the underlying hardware being
in a functional state.

Fixes problems with unflushed disk caches on machines where mpath(4) takes
control of some of your disks.

ok dlg@


Revision tags: OPENBSD_5_6_BASE
# 1.49 29-Mar-2014 guenther

It's been a quarter century: we can assume volatile is present with that name.

ok dlg@ mpi@ deraadt@


# 1.48 13-Mar-2014 dlg

get rid of the assumption that the head of the alldevs list is the
"mainbus" device. this breaks when mpath is enabled because it
attaches before mainbus and therefore takes the head position.

have autoconf provide device_mainbus() which looks up mainbus_cd,
and use that instead.

discussed with deraadt who just wants mpath stuff to move forward
despite there being many ways to shine this particular turd.


Revision tags: OPENBSD_5_5_BASE
# 1.47 06-Dec-2013 deraadt

Add a DVACT_WAKEUP op to the *_activate() API. This is called after the
kernel resumes normal (non-cold, able to run processes, etc) operation.
Previously we were relying on specific DVACT_RESUME op's in drivers
creating callback/threads themselves, but that has become too common,
indicating the need for a built-in mechanism.
ok dlg kettenis, tested by a sufficient amount of people


# 1.46 27-Nov-2013 dlg

get rid of the goop for maintaining multiple cftables since theres
no current code there to add or remove them. such code was put in
17 years ago, disabled 14 years ago, and removed 11 years ago, so
i suspect we dont really need it or the goop to support it.

very ok miod@


Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.45 08-Oct-2012 deraadt

Revamp the sequences for suspend/hibernate -> resume so that the code
paths are reflexive. It is now possible to fail part-way through a
suspend sequence, and recover along the resume code path.
Split DVACT_SUSPEND by adding a new DVACT_POWERDOWN method is used
after hibernate (and suspend too) to finish the job. Some drivers
must be converted at the same time to use this instead of shutdown hooks
(the others will follow at a later time)
ok kettenis mlarkin


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.44 03-Jul-2011 matthew

Remove config_activate() and DVACT_ACTIVATE. PCMCIA's the only thing
that's ever used it, and it's long since been changed to use
DVACT_{QUIESCE,SUSPEND,RESUME} instead.

ok deraadt@, dlg@; miod@ also agreed with this idea when I brought it
up a few weeks ago


# 1.43 01-Jun-2011 matthew

Kill the nearly-15-years-dead cf_ivstubs field from struct cfdata.

ok miod@, deraadt@

N.B.: If you're following -current, you MUST recompile config(8) and
re-config your kernel or else ioconf.c will fail to compile.


Revision tags: OPENBSD_4_9_BASE
# 1.42 31-Aug-2010 deraadt

Add DVACT_QUIECE support. This is called before splhigh() and before
DVACT_SUSPEND, therefore DVACT_QUIECE can do standard sleeping operations
to get ready.
Discussed quite a while back with kettenis and jakemsr, oga suddenly needed
it as well and wrote half of it, so it was time to finish it.
proofread by miod.


Revision tags: OPENBSD_4_7_BASE OPENBSD_4_8_BASE
# 1.41 23-Nov-2009 deraadt

Make config_activate_children() more useable as a suspend-and-resume
device tree walker, and add config_suspend() as well.
ok mlarkin pirofti, discussion with kettenis


# 1.40 22-Nov-2009 pirofti

Forgot the declarations in former commit. From martin@, okay oga@.


# 1.39 22-Nov-2009 pirofti

Add basic suspend/resume autoconf functionality.

Okay deraadt@, kettenis@, mlarkin@.


# 1.38 13-Oct-2009 pirofti

Get rid of devact enum, substitute it with an int and coresponding defines.

This is needed for the addition of further suspend/resume actions.

Okay deraadt@, marco@.


Revision tags: OPENBSD_4_3_BASE OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE
# 1.37 24-Nov-2007 dlg

we dont need ot include sys/lock.h here

ok miod@ krw@


Revision tags: OPENBSD_4_2_BASE
# 1.36 15-May-2007 deraadt

kill __HAVE_DEVICE_REGISTER by requiring all architectures to have a
device_register() function -- even if it does nothing. reduces the
cpp-based blather different between architectures
idea ok'd by miod; tested on all architectures (except a few miod will
need to cleanup because he has them)


# 1.35 10-May-2007 deraadt

evcnt & friends were replaced by a proper interrupt counting mechanism 3 years ago; ok miod


# 1.34 04-May-2007 deraadt

make findblkmajor() and findblkname() MI; ok miod


# 1.33 04-May-2007 deraadt

setroot() was a ugly mix of MI and MD code, with different bugs on different
machines. Instead -- build one solid clean MI version, and thenchange all
the architectures to use it. ok various people, tested on almost all cases.
(it is a 10094 line diff..)


Revision tags: OPENBSD_4_0_BASE OPENBSD_4_1_BASE
# 1.32 28-May-2006 henning

intrducing device type DV_SENSOR turned out to be a bad idea as it
affects way more than just hotplug messages. remove DV_SENSOR and use
DV_DULL for the moment. proper solution coming.
discussed with deraadt mk jason


# 1.31 27-May-2006 mk

Make sensor add/remove create hotplug events (after much prodding from henning). Idea from mbalmer. 'in it goes!' deraadt.


Revision tags: OPENBSD_3_9_BASE
# 1.30 21-Jan-2006 miod

Remove now unused zeroref member in cfattach structures.


Revision tags: OPENBSD_3_7_BASE OPENBSD_3_8_BASE
# 1.29 23-Nov-2004 miod

Create the init process earlier, before the root filesystem is mounted,
and have it stall on a semaphore. This allows all kthread creations which
could have been requested during autoconf to be processed before root
is mounted as well.

This causes umass devices attached to any usb with flags 1 (such as on macppc)
to configure properly instead of panicing the kernel at mountroot time.

From NetBSD; tested by various.


# 1.28 17-Nov-2004 deraadt

firmware loading; ok pedro tedu dlg miod


Revision tags: OPENBSD_3_4_BASE OPENBSD_3_5_BASE OPENBSD_3_6_BASE SMP_SYNC_A SMP_SYNC_B
# 1.27 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


Revision tags: OPENBSD_3_3_BASE UBC_SYNC_A UBC_SYNC_B
# 1.26 06-Oct-2002 art

Remove some '#if 0' cruft.


Revision tags: OPENBSD_3_2_BASE
# 1.25 06-Sep-2002 deraadt

remove last , in enum


# 1.24 27-Aug-2002 wcobb

config_edit() isn't used anywhere. ok art@


Revision tags: OPENBSD_3_1_BASE
# 1.23 15-Mar-2002 millert

Cosmetic changes only, primarily making comments line up nicely after the
__P removal.


# 1.22 14-Mar-2002 millert

Final __P removal plus some cosmetic fixups


# 1.21 14-Mar-2002 millert

First round of __P removal in sys


Revision tags: OPENBSD_3_0_BASE UBC_BASE
# 1.20 01-Sep-2001 jason

branches: 1.20.4;
Add __HAVE_DEVICE_REGISTER to hp300/alpha (sparc64 already had it) and
clean up the arch specific #ifdef's in subr_autoconf.c; from NetBSD.
(tested by me on alpha/sparc64 and miod on hp300)


# 1.19 22-Jun-2001 deraadt

KNF


Revision tags: OPENBSD_2_7_BASE OPENBSD_2_8_BASE OPENBSD_2_9_BASE
# 1.18 09-Apr-2000 csapuntz

Added config_detach_children, config_activate_children.

Added ref counting to devices: device_ref, device_unref and a new method
for devices : ca_zeroref, called when the ref count hits zero.

Note that ca_zeroref may be called from interrupt context.


Revision tags: OPENBSD_2_6_BASE SMP_BASE kame_19991208
# 1.17 08-Aug-1999 niklas

branches: 1.17.4;
From NetBSD; new device detaching infrastructure.


# 1.16 05-Aug-1999 niklas

From NetBSD; config_defer to defer configuration of a device until after all
other siblings.


# 1.15 23-Jul-1999 niklas

Remove obsolete detach logic in preparation of a newer one


# 1.14 28-Apr-1999 deraadt

add autoconfig_verbose toggling command to boot_config


Revision tags: OPENBSD_2_4_BASE OPENBSD_2_5_BASE
# 1.13 11-May-1998 niklas

Formerly reuse of unit numbers of detached devices was impossible, with
this change starred devices will search from the first allowed unit for
such devices and up for free units when attaching. This means you have
to rerun config(8) before yopu compile current kernels. FYI, this is
a necessity when doing PCMCIA flashcard reading, otherwise you soon run
out of unit numbers.

I have also added a way to detach all children of a certain device, used
in a new PCMCIA framework to come, so you detach all functions on a
single PCMCIA card when pulling it out.

A few bugs wrt starred devices fixed in the autoconfig_verbose code too.
Last and least, fixed some panic messages.


Revision tags: OPENBSD_2_2_BASE OPENBSD_2_3_BASE
# 1.12 07-Aug-1997 downsj

Back that out, I'm too tired to be messing with this.


# 1.11 07-Aug-1997 downsj

Add cf_locnames to struct cfdata.


Revision tags: OPENBSD_2_1_BASE
# 1.10 23-Nov-1996 kstailey

added const to second parameter of cfprint_t routines


# 1.9 21-Nov-1996 mickey

export struct cfdata cfdata[];


Revision tags: OPENBSD_2_0_BASE
# 1.8 02-Jul-1996 deraadt

provide config_make_softc proto


# 1.7 23-Jun-1996 maja

Added support for user modifiable kernel at boot (-c) /maja


# 1.6 16-Jun-1996 deraadt

provide locator names to kernel (update your config(8) binary!)


# 1.5 29-Apr-1996 hvozda

Pull in John Kohl's [jtk@netbsd.org] most recent (15Apr96) APM and PCMCIA work
(original PCMCIA framework by Stefan Grefen [grefen@convex.com]).


# 1.4 21-Apr-1996 deraadt

partial sync with netbsd 960418, more to come


# 1.3 18-Apr-1996 niklas

Merge of NetBSD 960317


# 1.2 03-Mar-1996 niklas

From NetBSD: 960217 merge


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.56 26-Oct-2021 deraadt

Improve unhibernate performance (30% on some machines, another upcoming diff
shows gains up to 50%) by skipping attach of irrelevant devices, which are
tagged CD_SKIPHIBERNATE in the per-driver cfdriver. In particular, usb devices
are not attached, so they don't need to detach during the suspend-unpack-resume.
New bootblocks are required (which tell the kernel it's job is unhibernate
before configure runs)
tested by various


Revision tags: OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE OPENBSD_6_7_BASE OPENBSD_6_8_BASE OPENBSD_6_9_BASE OPENBSD_7_0_BASE
# 1.55 10-Sep-2018 sashan

- if_cloners list populated at boot time only then becomes immutable,
so we can let go if_cloners_lock.

OK tb@, claudio@, bluhm@, kn@, henning@


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.54 11-Dec-2015 mpi

Replace mountroothook_establish(9) by config_mountroot(9) a narrower API
similar to config_defer(9).

ok mikeb@, deraadt@


# 1.53 11-Sep-2015 dlg

back out refcnt for dv_ref, there's too many hand crafted devices all
over the tree.

much encouragement from l2k15


# 1.52 11-Sep-2015 dlg

use refcnts for the device reference counts as an example of how
refcnt(9) can be used.


# 1.51 11-Sep-2015 miod

Change device locators type from int to long, for the sake of 64-bit ports
without proper device trees.

Be sure to build and install config(8) and rerun it before attempting to build
a kernel.

ok kettenis@ deraadt@ jasper@ visa@


Revision tags: OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.50 18-Sep-2014 kettenis

Introduce config_suspend_all(9) a function that invokes config_suspend(9)
on all relevant device hierarchies in the appropriate order. For now this
means mpath(4) and mainbus(4), doing mpath(4) before mainbus(4) when
suspending or powering down and doing mpath(4) after mainbus(4) when
resuming such that mpath(4) can realy on the underlying hardware being
in a functional state.

Fixes problems with unflushed disk caches on machines where mpath(4) takes
control of some of your disks.

ok dlg@


Revision tags: OPENBSD_5_6_BASE
# 1.49 29-Mar-2014 guenther

It's been a quarter century: we can assume volatile is present with that name.

ok dlg@ mpi@ deraadt@


# 1.48 13-Mar-2014 dlg

get rid of the assumption that the head of the alldevs list is the
"mainbus" device. this breaks when mpath is enabled because it
attaches before mainbus and therefore takes the head position.

have autoconf provide device_mainbus() which looks up mainbus_cd,
and use that instead.

discussed with deraadt who just wants mpath stuff to move forward
despite there being many ways to shine this particular turd.


Revision tags: OPENBSD_5_5_BASE
# 1.47 06-Dec-2013 deraadt

Add a DVACT_WAKEUP op to the *_activate() API. This is called after the
kernel resumes normal (non-cold, able to run processes, etc) operation.
Previously we were relying on specific DVACT_RESUME op's in drivers
creating callback/threads themselves, but that has become too common,
indicating the need for a built-in mechanism.
ok dlg kettenis, tested by a sufficient amount of people


# 1.46 27-Nov-2013 dlg

get rid of the goop for maintaining multiple cftables since theres
no current code there to add or remove them. such code was put in
17 years ago, disabled 14 years ago, and removed 11 years ago, so
i suspect we dont really need it or the goop to support it.

very ok miod@


Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.45 08-Oct-2012 deraadt

Revamp the sequences for suspend/hibernate -> resume so that the code
paths are reflexive. It is now possible to fail part-way through a
suspend sequence, and recover along the resume code path.
Split DVACT_SUSPEND by adding a new DVACT_POWERDOWN method is used
after hibernate (and suspend too) to finish the job. Some drivers
must be converted at the same time to use this instead of shutdown hooks
(the others will follow at a later time)
ok kettenis mlarkin


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.44 03-Jul-2011 matthew

Remove config_activate() and DVACT_ACTIVATE. PCMCIA's the only thing
that's ever used it, and it's long since been changed to use
DVACT_{QUIESCE,SUSPEND,RESUME} instead.

ok deraadt@, dlg@; miod@ also agreed with this idea when I brought it
up a few weeks ago


# 1.43 01-Jun-2011 matthew

Kill the nearly-15-years-dead cf_ivstubs field from struct cfdata.

ok miod@, deraadt@

N.B.: If you're following -current, you MUST recompile config(8) and
re-config your kernel or else ioconf.c will fail to compile.


Revision tags: OPENBSD_4_9_BASE
# 1.42 31-Aug-2010 deraadt

Add DVACT_QUIECE support. This is called before splhigh() and before
DVACT_SUSPEND, therefore DVACT_QUIECE can do standard sleeping operations
to get ready.
Discussed quite a while back with kettenis and jakemsr, oga suddenly needed
it as well and wrote half of it, so it was time to finish it.
proofread by miod.


Revision tags: OPENBSD_4_7_BASE OPENBSD_4_8_BASE
# 1.41 23-Nov-2009 deraadt

Make config_activate_children() more useable as a suspend-and-resume
device tree walker, and add config_suspend() as well.
ok mlarkin pirofti, discussion with kettenis


# 1.40 22-Nov-2009 pirofti

Forgot the declarations in former commit. From martin@, okay oga@.


# 1.39 22-Nov-2009 pirofti

Add basic suspend/resume autoconf functionality.

Okay deraadt@, kettenis@, mlarkin@.


# 1.38 13-Oct-2009 pirofti

Get rid of devact enum, substitute it with an int and coresponding defines.

This is needed for the addition of further suspend/resume actions.

Okay deraadt@, marco@.


Revision tags: OPENBSD_4_3_BASE OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE
# 1.37 24-Nov-2007 dlg

we dont need ot include sys/lock.h here

ok miod@ krw@


Revision tags: OPENBSD_4_2_BASE
# 1.36 15-May-2007 deraadt

kill __HAVE_DEVICE_REGISTER by requiring all architectures to have a
device_register() function -- even if it does nothing. reduces the
cpp-based blather different between architectures
idea ok'd by miod; tested on all architectures (except a few miod will
need to cleanup because he has them)


# 1.35 10-May-2007 deraadt

evcnt & friends were replaced by a proper interrupt counting mechanism 3 years ago; ok miod


# 1.34 04-May-2007 deraadt

make findblkmajor() and findblkname() MI; ok miod


# 1.33 04-May-2007 deraadt

setroot() was a ugly mix of MI and MD code, with different bugs on different
machines. Instead -- build one solid clean MI version, and thenchange all
the architectures to use it. ok various people, tested on almost all cases.
(it is a 10094 line diff..)


Revision tags: OPENBSD_4_0_BASE OPENBSD_4_1_BASE
# 1.32 28-May-2006 henning

intrducing device type DV_SENSOR turned out to be a bad idea as it
affects way more than just hotplug messages. remove DV_SENSOR and use
DV_DULL for the moment. proper solution coming.
discussed with deraadt mk jason


# 1.31 27-May-2006 mk

Make sensor add/remove create hotplug events (after much prodding from henning). Idea from mbalmer. 'in it goes!' deraadt.


Revision tags: OPENBSD_3_9_BASE
# 1.30 21-Jan-2006 miod

Remove now unused zeroref member in cfattach structures.


Revision tags: OPENBSD_3_7_BASE OPENBSD_3_8_BASE
# 1.29 23-Nov-2004 miod

Create the init process earlier, before the root filesystem is mounted,
and have it stall on a semaphore. This allows all kthread creations which
could have been requested during autoconf to be processed before root
is mounted as well.

This causes umass devices attached to any usb with flags 1 (such as on macppc)
to configure properly instead of panicing the kernel at mountroot time.

From NetBSD; tested by various.


# 1.28 17-Nov-2004 deraadt

firmware loading; ok pedro tedu dlg miod


Revision tags: OPENBSD_3_4_BASE OPENBSD_3_5_BASE OPENBSD_3_6_BASE SMP_SYNC_A SMP_SYNC_B
# 1.27 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


Revision tags: OPENBSD_3_3_BASE UBC_SYNC_A UBC_SYNC_B
# 1.26 06-Oct-2002 art

Remove some '#if 0' cruft.


Revision tags: OPENBSD_3_2_BASE
# 1.25 06-Sep-2002 deraadt

remove last , in enum


# 1.24 27-Aug-2002 wcobb

config_edit() isn't used anywhere. ok art@


Revision tags: OPENBSD_3_1_BASE
# 1.23 15-Mar-2002 millert

Cosmetic changes only, primarily making comments line up nicely after the
__P removal.


# 1.22 14-Mar-2002 millert

Final __P removal plus some cosmetic fixups


# 1.21 14-Mar-2002 millert

First round of __P removal in sys


Revision tags: OPENBSD_3_0_BASE UBC_BASE
# 1.20 01-Sep-2001 jason

branches: 1.20.4;
Add __HAVE_DEVICE_REGISTER to hp300/alpha (sparc64 already had it) and
clean up the arch specific #ifdef's in subr_autoconf.c; from NetBSD.
(tested by me on alpha/sparc64 and miod on hp300)


# 1.19 22-Jun-2001 deraadt

KNF


Revision tags: OPENBSD_2_7_BASE OPENBSD_2_8_BASE OPENBSD_2_9_BASE
# 1.18 09-Apr-2000 csapuntz

Added config_detach_children, config_activate_children.

Added ref counting to devices: device_ref, device_unref and a new method
for devices : ca_zeroref, called when the ref count hits zero.

Note that ca_zeroref may be called from interrupt context.


Revision tags: OPENBSD_2_6_BASE SMP_BASE kame_19991208
# 1.17 08-Aug-1999 niklas

branches: 1.17.4;
From NetBSD; new device detaching infrastructure.


# 1.16 05-Aug-1999 niklas

From NetBSD; config_defer to defer configuration of a device until after all
other siblings.


# 1.15 23-Jul-1999 niklas

Remove obsolete detach logic in preparation of a newer one


# 1.14 28-Apr-1999 deraadt

add autoconfig_verbose toggling command to boot_config


Revision tags: OPENBSD_2_4_BASE OPENBSD_2_5_BASE
# 1.13 11-May-1998 niklas

Formerly reuse of unit numbers of detached devices was impossible, with
this change starred devices will search from the first allowed unit for
such devices and up for free units when attaching. This means you have
to rerun config(8) before yopu compile current kernels. FYI, this is
a necessity when doing PCMCIA flashcard reading, otherwise you soon run
out of unit numbers.

I have also added a way to detach all children of a certain device, used
in a new PCMCIA framework to come, so you detach all functions on a
single PCMCIA card when pulling it out.

A few bugs wrt starred devices fixed in the autoconfig_verbose code too.
Last and least, fixed some panic messages.


Revision tags: OPENBSD_2_2_BASE OPENBSD_2_3_BASE
# 1.12 07-Aug-1997 downsj

Back that out, I'm too tired to be messing with this.


# 1.11 07-Aug-1997 downsj

Add cf_locnames to struct cfdata.


Revision tags: OPENBSD_2_1_BASE
# 1.10 23-Nov-1996 kstailey

added const to second parameter of cfprint_t routines


# 1.9 21-Nov-1996 mickey

export struct cfdata cfdata[];


Revision tags: OPENBSD_2_0_BASE
# 1.8 02-Jul-1996 deraadt

provide config_make_softc proto


# 1.7 23-Jun-1996 maja

Added support for user modifiable kernel at boot (-c) /maja


# 1.6 16-Jun-1996 deraadt

provide locator names to kernel (update your config(8) binary!)


# 1.5 29-Apr-1996 hvozda

Pull in John Kohl's [jtk@netbsd.org] most recent (15Apr96) APM and PCMCIA work
(original PCMCIA framework by Stefan Grefen [grefen@convex.com]).


# 1.4 21-Apr-1996 deraadt

partial sync with netbsd 960418, more to come


# 1.3 18-Apr-1996 niklas

Merge of NetBSD 960317


# 1.2 03-Mar-1996 niklas

From NetBSD: 960217 merge


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.55 10-Sep-2018 sashan

- if_cloners list populated at boot time only then becomes immutable,
so we can let go if_cloners_lock.

OK tb@, claudio@, bluhm@, kn@, henning@


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.54 11-Dec-2015 mpi

Replace mountroothook_establish(9) by config_mountroot(9) a narrower API
similar to config_defer(9).

ok mikeb@, deraadt@


# 1.53 11-Sep-2015 dlg

back out refcnt for dv_ref, there's too many hand crafted devices all
over the tree.

much encouragement from l2k15


# 1.52 11-Sep-2015 dlg

use refcnts for the device reference counts as an example of how
refcnt(9) can be used.


# 1.51 11-Sep-2015 miod

Change device locators type from int to long, for the sake of 64-bit ports
without proper device trees.

Be sure to build and install config(8) and rerun it before attempting to build
a kernel.

ok kettenis@ deraadt@ jasper@ visa@


Revision tags: OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.50 18-Sep-2014 kettenis

Introduce config_suspend_all(9) a function that invokes config_suspend(9)
on all relevant device hierarchies in the appropriate order. For now this
means mpath(4) and mainbus(4), doing mpath(4) before mainbus(4) when
suspending or powering down and doing mpath(4) after mainbus(4) when
resuming such that mpath(4) can realy on the underlying hardware being
in a functional state.

Fixes problems with unflushed disk caches on machines where mpath(4) takes
control of some of your disks.

ok dlg@


Revision tags: OPENBSD_5_6_BASE
# 1.49 29-Mar-2014 guenther

It's been a quarter century: we can assume volatile is present with that name.

ok dlg@ mpi@ deraadt@


# 1.48 13-Mar-2014 dlg

get rid of the assumption that the head of the alldevs list is the
"mainbus" device. this breaks when mpath is enabled because it
attaches before mainbus and therefore takes the head position.

have autoconf provide device_mainbus() which looks up mainbus_cd,
and use that instead.

discussed with deraadt who just wants mpath stuff to move forward
despite there being many ways to shine this particular turd.


Revision tags: OPENBSD_5_5_BASE
# 1.47 06-Dec-2013 deraadt

Add a DVACT_WAKEUP op to the *_activate() API. This is called after the
kernel resumes normal (non-cold, able to run processes, etc) operation.
Previously we were relying on specific DVACT_RESUME op's in drivers
creating callback/threads themselves, but that has become too common,
indicating the need for a built-in mechanism.
ok dlg kettenis, tested by a sufficient amount of people


# 1.46 27-Nov-2013 dlg

get rid of the goop for maintaining multiple cftables since theres
no current code there to add or remove them. such code was put in
17 years ago, disabled 14 years ago, and removed 11 years ago, so
i suspect we dont really need it or the goop to support it.

very ok miod@


Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.45 08-Oct-2012 deraadt

Revamp the sequences for suspend/hibernate -> resume so that the code
paths are reflexive. It is now possible to fail part-way through a
suspend sequence, and recover along the resume code path.
Split DVACT_SUSPEND by adding a new DVACT_POWERDOWN method is used
after hibernate (and suspend too) to finish the job. Some drivers
must be converted at the same time to use this instead of shutdown hooks
(the others will follow at a later time)
ok kettenis mlarkin


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.44 03-Jul-2011 matthew

Remove config_activate() and DVACT_ACTIVATE. PCMCIA's the only thing
that's ever used it, and it's long since been changed to use
DVACT_{QUIESCE,SUSPEND,RESUME} instead.

ok deraadt@, dlg@; miod@ also agreed with this idea when I brought it
up a few weeks ago


# 1.43 01-Jun-2011 matthew

Kill the nearly-15-years-dead cf_ivstubs field from struct cfdata.

ok miod@, deraadt@

N.B.: If you're following -current, you MUST recompile config(8) and
re-config your kernel or else ioconf.c will fail to compile.


Revision tags: OPENBSD_4_9_BASE
# 1.42 31-Aug-2010 deraadt

Add DVACT_QUIECE support. This is called before splhigh() and before
DVACT_SUSPEND, therefore DVACT_QUIECE can do standard sleeping operations
to get ready.
Discussed quite a while back with kettenis and jakemsr, oga suddenly needed
it as well and wrote half of it, so it was time to finish it.
proofread by miod.


Revision tags: OPENBSD_4_7_BASE OPENBSD_4_8_BASE
# 1.41 23-Nov-2009 deraadt

Make config_activate_children() more useable as a suspend-and-resume
device tree walker, and add config_suspend() as well.
ok mlarkin pirofti, discussion with kettenis


# 1.40 22-Nov-2009 pirofti

Forgot the declarations in former commit. From martin@, okay oga@.


# 1.39 22-Nov-2009 pirofti

Add basic suspend/resume autoconf functionality.

Okay deraadt@, kettenis@, mlarkin@.


# 1.38 13-Oct-2009 pirofti

Get rid of devact enum, substitute it with an int and coresponding defines.

This is needed for the addition of further suspend/resume actions.

Okay deraadt@, marco@.


Revision tags: OPENBSD_4_3_BASE OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE
# 1.37 24-Nov-2007 dlg

we dont need ot include sys/lock.h here

ok miod@ krw@


Revision tags: OPENBSD_4_2_BASE
# 1.36 15-May-2007 deraadt

kill __HAVE_DEVICE_REGISTER by requiring all architectures to have a
device_register() function -- even if it does nothing. reduces the
cpp-based blather different between architectures
idea ok'd by miod; tested on all architectures (except a few miod will
need to cleanup because he has them)


# 1.35 10-May-2007 deraadt

evcnt & friends were replaced by a proper interrupt counting mechanism 3 years ago; ok miod


# 1.34 04-May-2007 deraadt

make findblkmajor() and findblkname() MI; ok miod


# 1.33 04-May-2007 deraadt

setroot() was a ugly mix of MI and MD code, with different bugs on different
machines. Instead -- build one solid clean MI version, and thenchange all
the architectures to use it. ok various people, tested on almost all cases.
(it is a 10094 line diff..)


Revision tags: OPENBSD_4_0_BASE OPENBSD_4_1_BASE
# 1.32 28-May-2006 henning

intrducing device type DV_SENSOR turned out to be a bad idea as it
affects way more than just hotplug messages. remove DV_SENSOR and use
DV_DULL for the moment. proper solution coming.
discussed with deraadt mk jason


# 1.31 27-May-2006 mk

Make sensor add/remove create hotplug events (after much prodding from henning). Idea from mbalmer. 'in it goes!' deraadt.


Revision tags: OPENBSD_3_9_BASE
# 1.30 21-Jan-2006 miod

Remove now unused zeroref member in cfattach structures.


Revision tags: OPENBSD_3_7_BASE OPENBSD_3_8_BASE
# 1.29 23-Nov-2004 miod

Create the init process earlier, before the root filesystem is mounted,
and have it stall on a semaphore. This allows all kthread creations which
could have been requested during autoconf to be processed before root
is mounted as well.

This causes umass devices attached to any usb with flags 1 (such as on macppc)
to configure properly instead of panicing the kernel at mountroot time.

From NetBSD; tested by various.


# 1.28 17-Nov-2004 deraadt

firmware loading; ok pedro tedu dlg miod


Revision tags: OPENBSD_3_4_BASE OPENBSD_3_5_BASE OPENBSD_3_6_BASE SMP_SYNC_A SMP_SYNC_B
# 1.27 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


Revision tags: OPENBSD_3_3_BASE UBC_SYNC_A UBC_SYNC_B
# 1.26 06-Oct-2002 art

Remove some '#if 0' cruft.


Revision tags: OPENBSD_3_2_BASE
# 1.25 06-Sep-2002 deraadt

remove last , in enum


# 1.24 27-Aug-2002 wcobb

config_edit() isn't used anywhere. ok art@


Revision tags: OPENBSD_3_1_BASE
# 1.23 15-Mar-2002 millert

Cosmetic changes only, primarily making comments line up nicely after the
__P removal.


# 1.22 14-Mar-2002 millert

Final __P removal plus some cosmetic fixups


# 1.21 14-Mar-2002 millert

First round of __P removal in sys


Revision tags: OPENBSD_3_0_BASE UBC_BASE
# 1.20 01-Sep-2001 jason

branches: 1.20.4;
Add __HAVE_DEVICE_REGISTER to hp300/alpha (sparc64 already had it) and
clean up the arch specific #ifdef's in subr_autoconf.c; from NetBSD.
(tested by me on alpha/sparc64 and miod on hp300)


# 1.19 22-Jun-2001 deraadt

KNF


Revision tags: OPENBSD_2_7_BASE OPENBSD_2_8_BASE OPENBSD_2_9_BASE
# 1.18 09-Apr-2000 csapuntz

Added config_detach_children, config_activate_children.

Added ref counting to devices: device_ref, device_unref and a new method
for devices : ca_zeroref, called when the ref count hits zero.

Note that ca_zeroref may be called from interrupt context.


Revision tags: OPENBSD_2_6_BASE SMP_BASE kame_19991208
# 1.17 08-Aug-1999 niklas

branches: 1.17.4;
From NetBSD; new device detaching infrastructure.


# 1.16 05-Aug-1999 niklas

From NetBSD; config_defer to defer configuration of a device until after all
other siblings.


# 1.15 23-Jul-1999 niklas

Remove obsolete detach logic in preparation of a newer one


# 1.14 28-Apr-1999 deraadt

add autoconfig_verbose toggling command to boot_config


Revision tags: OPENBSD_2_4_BASE OPENBSD_2_5_BASE
# 1.13 11-May-1998 niklas

Formerly reuse of unit numbers of detached devices was impossible, with
this change starred devices will search from the first allowed unit for
such devices and up for free units when attaching. This means you have
to rerun config(8) before yopu compile current kernels. FYI, this is
a necessity when doing PCMCIA flashcard reading, otherwise you soon run
out of unit numbers.

I have also added a way to detach all children of a certain device, used
in a new PCMCIA framework to come, so you detach all functions on a
single PCMCIA card when pulling it out.

A few bugs wrt starred devices fixed in the autoconfig_verbose code too.
Last and least, fixed some panic messages.


Revision tags: OPENBSD_2_2_BASE OPENBSD_2_3_BASE
# 1.12 07-Aug-1997 downsj

Back that out, I'm too tired to be messing with this.


# 1.11 07-Aug-1997 downsj

Add cf_locnames to struct cfdata.


Revision tags: OPENBSD_2_1_BASE
# 1.10 23-Nov-1996 kstailey

added const to second parameter of cfprint_t routines


# 1.9 21-Nov-1996 mickey

export struct cfdata cfdata[];


Revision tags: OPENBSD_2_0_BASE
# 1.8 02-Jul-1996 deraadt

provide config_make_softc proto


# 1.7 23-Jun-1996 maja

Added support for user modifiable kernel at boot (-c) /maja


# 1.6 16-Jun-1996 deraadt

provide locator names to kernel (update your config(8) binary!)


# 1.5 29-Apr-1996 hvozda

Pull in John Kohl's [jtk@netbsd.org] most recent (15Apr96) APM and PCMCIA work
(original PCMCIA framework by Stefan Grefen [grefen@convex.com]).


# 1.4 21-Apr-1996 deraadt

partial sync with netbsd 960418, more to come


# 1.3 18-Apr-1996 niklas

Merge of NetBSD 960317


# 1.2 03-Mar-1996 niklas

From NetBSD: 960217 merge


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE
# 1.54 11-Dec-2015 mpi

Replace mountroothook_establish(9) by config_mountroot(9) a narrower API
similar to config_defer(9).

ok mikeb@, deraadt@


# 1.53 11-Sep-2015 dlg

back out refcnt for dv_ref, there's too many hand crafted devices all
over the tree.

much encouragement from l2k15


# 1.52 11-Sep-2015 dlg

use refcnts for the device reference counts as an example of how
refcnt(9) can be used.


# 1.51 11-Sep-2015 miod

Change device locators type from int to long, for the sake of 64-bit ports
without proper device trees.

Be sure to build and install config(8) and rerun it before attempting to build
a kernel.

ok kettenis@ deraadt@ jasper@ visa@


Revision tags: OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.50 18-Sep-2014 kettenis

Introduce config_suspend_all(9) a function that invokes config_suspend(9)
on all relevant device hierarchies in the appropriate order. For now this
means mpath(4) and mainbus(4), doing mpath(4) before mainbus(4) when
suspending or powering down and doing mpath(4) after mainbus(4) when
resuming such that mpath(4) can realy on the underlying hardware being
in a functional state.

Fixes problems with unflushed disk caches on machines where mpath(4) takes
control of some of your disks.

ok dlg@


Revision tags: OPENBSD_5_6_BASE
# 1.49 29-Mar-2014 guenther

It's been a quarter century: we can assume volatile is present with that name.

ok dlg@ mpi@ deraadt@


# 1.48 13-Mar-2014 dlg

get rid of the assumption that the head of the alldevs list is the
"mainbus" device. this breaks when mpath is enabled because it
attaches before mainbus and therefore takes the head position.

have autoconf provide device_mainbus() which looks up mainbus_cd,
and use that instead.

discussed with deraadt who just wants mpath stuff to move forward
despite there being many ways to shine this particular turd.


Revision tags: OPENBSD_5_5_BASE
# 1.47 06-Dec-2013 deraadt

Add a DVACT_WAKEUP op to the *_activate() API. This is called after the
kernel resumes normal (non-cold, able to run processes, etc) operation.
Previously we were relying on specific DVACT_RESUME op's in drivers
creating callback/threads themselves, but that has become too common,
indicating the need for a built-in mechanism.
ok dlg kettenis, tested by a sufficient amount of people


# 1.46 27-Nov-2013 dlg

get rid of the goop for maintaining multiple cftables since theres
no current code there to add or remove them. such code was put in
17 years ago, disabled 14 years ago, and removed 11 years ago, so
i suspect we dont really need it or the goop to support it.

very ok miod@


Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.45 08-Oct-2012 deraadt

Revamp the sequences for suspend/hibernate -> resume so that the code
paths are reflexive. It is now possible to fail part-way through a
suspend sequence, and recover along the resume code path.
Split DVACT_SUSPEND by adding a new DVACT_POWERDOWN method is used
after hibernate (and suspend too) to finish the job. Some drivers
must be converted at the same time to use this instead of shutdown hooks
(the others will follow at a later time)
ok kettenis mlarkin


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.44 03-Jul-2011 matthew

Remove config_activate() and DVACT_ACTIVATE. PCMCIA's the only thing
that's ever used it, and it's long since been changed to use
DVACT_{QUIESCE,SUSPEND,RESUME} instead.

ok deraadt@, dlg@; miod@ also agreed with this idea when I brought it
up a few weeks ago


# 1.43 01-Jun-2011 matthew

Kill the nearly-15-years-dead cf_ivstubs field from struct cfdata.

ok miod@, deraadt@

N.B.: If you're following -current, you MUST recompile config(8) and
re-config your kernel or else ioconf.c will fail to compile.


Revision tags: OPENBSD_4_9_BASE
# 1.42 31-Aug-2010 deraadt

Add DVACT_QUIECE support. This is called before splhigh() and before
DVACT_SUSPEND, therefore DVACT_QUIECE can do standard sleeping operations
to get ready.
Discussed quite a while back with kettenis and jakemsr, oga suddenly needed
it as well and wrote half of it, so it was time to finish it.
proofread by miod.


Revision tags: OPENBSD_4_7_BASE OPENBSD_4_8_BASE
# 1.41 23-Nov-2009 deraadt

Make config_activate_children() more useable as a suspend-and-resume
device tree walker, and add config_suspend() as well.
ok mlarkin pirofti, discussion with kettenis


# 1.40 22-Nov-2009 pirofti

Forgot the declarations in former commit. From martin@, okay oga@.


# 1.39 22-Nov-2009 pirofti

Add basic suspend/resume autoconf functionality.

Okay deraadt@, kettenis@, mlarkin@.


# 1.38 13-Oct-2009 pirofti

Get rid of devact enum, substitute it with an int and coresponding defines.

This is needed for the addition of further suspend/resume actions.

Okay deraadt@, marco@.


Revision tags: OPENBSD_4_3_BASE OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE
# 1.37 24-Nov-2007 dlg

we dont need ot include sys/lock.h here

ok miod@ krw@


Revision tags: OPENBSD_4_2_BASE
# 1.36 15-May-2007 deraadt

kill __HAVE_DEVICE_REGISTER by requiring all architectures to have a
device_register() function -- even if it does nothing. reduces the
cpp-based blather different between architectures
idea ok'd by miod; tested on all architectures (except a few miod will
need to cleanup because he has them)


# 1.35 10-May-2007 deraadt

evcnt & friends were replaced by a proper interrupt counting mechanism 3 years ago; ok miod


# 1.34 04-May-2007 deraadt

make findblkmajor() and findblkname() MI; ok miod


# 1.33 04-May-2007 deraadt

setroot() was a ugly mix of MI and MD code, with different bugs on different
machines. Instead -- build one solid clean MI version, and thenchange all
the architectures to use it. ok various people, tested on almost all cases.
(it is a 10094 line diff..)


Revision tags: OPENBSD_4_0_BASE OPENBSD_4_1_BASE
# 1.32 28-May-2006 henning

intrducing device type DV_SENSOR turned out to be a bad idea as it
affects way more than just hotplug messages. remove DV_SENSOR and use
DV_DULL for the moment. proper solution coming.
discussed with deraadt mk jason


# 1.31 27-May-2006 mk

Make sensor add/remove create hotplug events (after much prodding from henning). Idea from mbalmer. 'in it goes!' deraadt.


Revision tags: OPENBSD_3_9_BASE
# 1.30 21-Jan-2006 miod

Remove now unused zeroref member in cfattach structures.


Revision tags: OPENBSD_3_7_BASE OPENBSD_3_8_BASE
# 1.29 23-Nov-2004 miod

Create the init process earlier, before the root filesystem is mounted,
and have it stall on a semaphore. This allows all kthread creations which
could have been requested during autoconf to be processed before root
is mounted as well.

This causes umass devices attached to any usb with flags 1 (such as on macppc)
to configure properly instead of panicing the kernel at mountroot time.

From NetBSD; tested by various.


# 1.28 17-Nov-2004 deraadt

firmware loading; ok pedro tedu dlg miod


Revision tags: OPENBSD_3_4_BASE OPENBSD_3_5_BASE OPENBSD_3_6_BASE SMP_SYNC_A SMP_SYNC_B
# 1.27 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


Revision tags: OPENBSD_3_3_BASE UBC_SYNC_A UBC_SYNC_B
# 1.26 06-Oct-2002 art

Remove some '#if 0' cruft.


Revision tags: OPENBSD_3_2_BASE
# 1.25 06-Sep-2002 deraadt

remove last , in enum


# 1.24 27-Aug-2002 wcobb

config_edit() isn't used anywhere. ok art@


Revision tags: OPENBSD_3_1_BASE
# 1.23 15-Mar-2002 millert

Cosmetic changes only, primarily making comments line up nicely after the
__P removal.


# 1.22 14-Mar-2002 millert

Final __P removal plus some cosmetic fixups


# 1.21 14-Mar-2002 millert

First round of __P removal in sys


Revision tags: OPENBSD_3_0_BASE UBC_BASE
# 1.20 01-Sep-2001 jason

branches: 1.20.4;
Add __HAVE_DEVICE_REGISTER to hp300/alpha (sparc64 already had it) and
clean up the arch specific #ifdef's in subr_autoconf.c; from NetBSD.
(tested by me on alpha/sparc64 and miod on hp300)


# 1.19 22-Jun-2001 deraadt

KNF


Revision tags: OPENBSD_2_7_BASE OPENBSD_2_8_BASE OPENBSD_2_9_BASE
# 1.18 09-Apr-2000 csapuntz

Added config_detach_children, config_activate_children.

Added ref counting to devices: device_ref, device_unref and a new method
for devices : ca_zeroref, called when the ref count hits zero.

Note that ca_zeroref may be called from interrupt context.


Revision tags: OPENBSD_2_6_BASE SMP_BASE kame_19991208
# 1.17 08-Aug-1999 niklas

branches: 1.17.4;
From NetBSD; new device detaching infrastructure.


# 1.16 05-Aug-1999 niklas

From NetBSD; config_defer to defer configuration of a device until after all
other siblings.


# 1.15 23-Jul-1999 niklas

Remove obsolete detach logic in preparation of a newer one


# 1.14 28-Apr-1999 deraadt

add autoconfig_verbose toggling command to boot_config


Revision tags: OPENBSD_2_4_BASE OPENBSD_2_5_BASE
# 1.13 11-May-1998 niklas

Formerly reuse of unit numbers of detached devices was impossible, with
this change starred devices will search from the first allowed unit for
such devices and up for free units when attaching. This means you have
to rerun config(8) before yopu compile current kernels. FYI, this is
a necessity when doing PCMCIA flashcard reading, otherwise you soon run
out of unit numbers.

I have also added a way to detach all children of a certain device, used
in a new PCMCIA framework to come, so you detach all functions on a
single PCMCIA card when pulling it out.

A few bugs wrt starred devices fixed in the autoconfig_verbose code too.
Last and least, fixed some panic messages.


Revision tags: OPENBSD_2_2_BASE OPENBSD_2_3_BASE
# 1.12 07-Aug-1997 downsj

Back that out, I'm too tired to be messing with this.


# 1.11 07-Aug-1997 downsj

Add cf_locnames to struct cfdata.


Revision tags: OPENBSD_2_1_BASE
# 1.10 23-Nov-1996 kstailey

added const to second parameter of cfprint_t routines


# 1.9 21-Nov-1996 mickey

export struct cfdata cfdata[];


Revision tags: OPENBSD_2_0_BASE
# 1.8 02-Jul-1996 deraadt

provide config_make_softc proto


# 1.7 23-Jun-1996 maja

Added support for user modifiable kernel at boot (-c) /maja


# 1.6 16-Jun-1996 deraadt

provide locator names to kernel (update your config(8) binary!)


# 1.5 29-Apr-1996 hvozda

Pull in John Kohl's [jtk@netbsd.org] most recent (15Apr96) APM and PCMCIA work
(original PCMCIA framework by Stefan Grefen [grefen@convex.com]).


# 1.4 21-Apr-1996 deraadt

partial sync with netbsd 960418, more to come


# 1.3 18-Apr-1996 niklas

Merge of NetBSD 960317


# 1.2 03-Mar-1996 niklas

From NetBSD: 960217 merge


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision