Home | History | Annotate | only in /src/sys/arch/macppc/dev
History log of /src/sys/arch/macppc/dev
RevisionDateAuthorComments
 1.20 17-Aug-2014  wiz Add missing parameter in printf. From Henning Petersen in PR 49122.
 1.19 27-Oct-2012  chs split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.18 18-Jun-2011  matt branches: 1.18.2; 1.18.12;
struct device * -> device_t
struct cfdata * -> cfdata_t
use device accessors, use device_private.
some softc/device_t splits (macppc needs a bunch more)
aprint*_dev used considerably more
 1.17 14-Mar-2009  dsl branches: 1.17.10;
ANSIfy another 1261 function definitions.
The only ones left in sys are beyond by sed script!
(or in sys/dist or sys/external)
Mostly they have function pointer parameters.
 1.16 14-Mar-2009  dsl Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.15 14-Mar-2009  dsl Remove all the __P() from sys (excluding sys/dist)
Diff checked with grep and MK1 eyeball.
i386 and amd64 GENERIC and sys still build.
 1.14 13-Jun-2008  cegger branches: 1.14.4; 1.14.10;
use device_lookup_private to get softc
 1.13 05-Mar-2007  tsutsui branches: 1.13.40; 1.13.42; 1.13.44; 1.13.46; 1.13.48;
- use (uint8_t *) for buffer args on *_adbcomplete() functions
- remove kbd_adbcomplete() decl from akbd.c since it's in akbdvar.h
 1.12 04-Mar-2007  christos Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.11 11-Dec-2005  christos branches: 1.11.26;
merge ktrace-lwp.
 1.10 28-Jul-2003  nathanw branches: 1.10.16;
Correct comment in FORCE_FUNCTION_KEYS code; the 0x0b (eject) button is
on the f12 key, not f7 (the keycode value was correct for f12 already).
 1.9 24-Jul-2003  nathanw Add an option, enabled with the FORCE_FUNCTION_KEYS macro, that converts
"hotkey" abtn events into the function-key akbd events for the keys
that they're actually on (though the eject/f12 mapping is probably wrong for
the 12" PowerBook G4).
 1.8 15-Jul-2003  lukem __KERNEL_RCSID()
 1.7 05-Mar-2003  soren branches: 1.7.2;
Forgot dummy printf.
 1.6 05-Mar-2003  soren Be more verbose about unsupported keys.
 1.5 02-Oct-2002  thorpej Use CFATTACH_DECL().
 1.4 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.3 08-Jun-2001  matt branches: 1.3.2; 1.3.8;
Make macppc compile by default with -Wall -Wmissing-prototype in addition
to its currently enabled warnings. For the lack of a better place, most
global function prototype wound up in <machine/autoconf.h> unless there
was a better place for them. ofb_* structs renamed to offb_* to avoid
conflict with ofb_softc in <dev/ofw/openfirm.h>
 1.2 29-Mar-2001  tsubai When attached, do not change brightness if the value is zero.
 1.1 12-Jul-1999  tsubai branches: 1.1.2; 1.1.4; 1.1.16;
Add PowerBook LCD brightness and speaker volume button device.
Only brightness works for now.
 1.1.16.2 21-Jun-2001  nathanw Catch up to -current.
 1.1.16.1 09-Apr-2001  nathanw Catch up with -current.
 1.1.4.1 21-Apr-2001  bouyer Sync with HEAD
 1.1.2.2 02-Aug-1999  thorpej Update from trunk.
 1.1.2.1 12-Jul-1999  thorpej file abtn.c was added on branch chs-ubc2 on 1999-08-02 19:55:12 +0000
 1.3.8.2 18-Oct-2002  nathanw Catch up to -current.
 1.3.8.1 08-Jun-2001  nathanw file abtn.c was added on branch nathanw_sa on 2002-10-18 02:38:33 +0000
 1.3.2.1 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.7.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.7.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.7.2.1 03-Aug-2004  skrll Sync with HEAD
 1.10.16.1 03-Sep-2007  yamt sync with head.
 1.11.26.1 12-Mar-2007  rmind Sync with HEAD.
 1.13.48.1 18-Jun-2008  simonb Sync with head.
 1.13.46.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.13.44.1 04-May-2009  yamt sync with head.
 1.13.42.1 17-Jun-2008  yamt sync with head.
 1.13.40.1 29-Jun-2008  mjf Sync with HEAD.
 1.14.10.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.14.4.1 28-Apr-2009  skrll Sync with HEAD.
 1.17.10.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.18.12.2 03-Dec-2017  jdolecek update from HEAD
 1.18.12.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.18.2.1 30-Oct-2012  yamt sync with head
 1.37 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.36 24-Apr-2021  thorpej branches: 1.36.8;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).
 1.35 05-Mar-2021  rin branches: 1.35.2;
Convert to intr_establish_xname().
 1.34 27-Oct-2012  chs branches: 1.34.50;
split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.33 01-Feb-2012  matt branches: 1.33.6;
Use C89 function prototypes.
 1.32 01-Jul-2011  dyoung branches: 1.32.2; 1.32.6;
#include <sys/bus.h> instead of <machine/bus.h>.
 1.31 30-Jun-2011  matt Modify mapiodev to take a third argument indicating whether the space
should be prefetchable (true) or not (false).
 1.30 18-Jun-2011  matt struct device * -> device_t
struct cfdata * -> cfdata_t
use device accessors, use device_private.
some softc/device_t splits (macppc needs a bunch more)
aprint*_dev used considerably more
 1.29 12-Dec-2009  tsutsui branches: 1.29.10;
Remove `volatile' qualifier from argument types of
struct timeval passed to todr_gettime(9) and todr_settime(9).
We no longer have an ancient and volatile struct timeval `time'
global since we have switched to MI timercounter(9) on all port.

XXX1: some of these RTC drivers still assume 32bit time_t
XXX2: some of these should be rewritten to use todr_[gs]ettime_ymdhms()
XXX3: todr(9) man page doesn't mention todr_[gs]ettime_ymdhms()
 1.28 01-Nov-2009  snj Drop 3rd and 4th clauses. Approved by Brad Grantham (copyright holder).
 1.27 14-Mar-2009  dsl ANSIfy another 1261 function definitions.
The only ones left in sys are beyond by sed script!
(or in sys/dist or sys/external)
Mostly they have function pointer parameters.
 1.26 14-Mar-2009  dsl Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.25 14-Mar-2009  dsl Remove all the __P() from sys (excluding sys/dist)
Diff checked with grep and MK1 eyeball.
i386 and amd64 GENERIC and sys still build.
 1.24 07-Nov-2007  garbled branches: 1.24.18; 1.24.26; 1.24.32;
Convert macppc to shared ofw_autoconf.c. Compile tested only.
 1.23 17-Oct-2007  garbled branches: 1.23.2;
Merge the ppcoea-renovation branch to HEAD.

This branch was a major cleanup and rototill of many of the various OEA
cpu based PPC ports that focused on sharing as much code as possible
between the various ports to eliminate near-identical copies of files in
every tree. Additionally there is a new PIC system that unifies the
interface to interrupt code for all different OEA ppc arches. The work
for this branch was done by a variety of people, too long to list here.

TODO:
bebox still needs work to complete the transition to -renovation.
ofppc still needs a bunch of work, which I will be looking at.
ev64260 still needs to be renovated
amigappc was not attempted.

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.22 15-Feb-2007  macallan branches: 1.22.6; 1.22.14; 1.22.22; 1.22.24; 1.22.26; 1.22.28;
don't use IPL_HIGH
 1.21 10-Dec-2006  macallan don't issue ADB commands if there's no adb node.
This should fix spontaneous poweroffs seen on PowerBooks that have no ADB
(last generation PBG4 which have only USB)
needs testing on more machines
 1.20 13-Sep-2006  gdamore branches: 1.20.2;
Convert macppc to generic todr. ok macallan@.
 1.19 11-Dec-2005  christos branches: 1.19.8; 1.19.20;
merge ktrace-lwp.
 1.18 01-Feb-2005  briggs branches: 1.18.6;
Remove one level of interrupt redirection by switching on the ADB
hardware type and registering a Cuda or PMU interrupt handler
specifically instead of an intermediate interrupt handler.
 1.17 01-Feb-2005  briggs Add a PMU initialization call at ADB init time. This probes the machine
type for PMU / battery information, then uses that when getting battery
information for APM. Allows older PowerBooks (pre-smart batteries) to
function with apm enabled in the kernel. Thanks to Linux code for battery
information for these old batteries. Something is still odd, though,
because a charging battery can show > 100% when it's near to full charge.

Enable more interrupts from PMU and handle PB3400 card eject buttons
properly, too.

Also use #defines for commands instead of raw hex codes.
 1.16 01-Feb-2005  briggs ADB_HW_PB is really ADB_HW_PMU.
 1.15 15-Jul-2003  lukem branches: 1.15.8; 1.15.10;
__KERNEL_RCSID()
 1.14 01-Jan-2003  thorpej branches: 1.14.2;
Use aprint_normal() in cfprint routines.
 1.13 02-Oct-2002  thorpej Use CFATTACH_DECL().
 1.12 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.11 18-Jun-2002  itojun apm emulation, from openbsd
 1.10 18-Jun-2002  itojun extern decl for adbHardware
 1.9 08-Jun-2001  matt branches: 1.9.2; 1.9.8; 1.9.16;
Make macppc compile by default with -Wall -Wmissing-prototype in addition
to its currently enabled warnings. For the lack of a better place, most
global function prototype wound up in <machine/autoconf.h> unless there
was a better place for them. ofb_* structs renamed to offb_* to avoid
conflict with ofb_softc in <dev/ofw/openfirm.h>
 1.8 01-Apr-2001  tsubai Adjust timing for pmu99. Internal keyboard of recent PowerBooks
should work now.
 1.7 19-Dec-2000  tsubai branches: 1.7.2;
Sync with mac68k.
 1.6 16-Aug-1999  tsubai branches: 1.6.2; 1.6.12;
Make configurable without ams.
 1.5 20-Oct-1998  tsubai Add via-pmu support (only PowerBook 2400c/180 is tested).
 1.4 18-Oct-1998  tsubai Make compilable without aed.
 1.3 13-Oct-1998  tsubai Split ADB driver to aed (ADB event device), akbd (ADB keyboard),
and ams (ADB mouse). adb is a bus now. (from Colin Wood)
 1.2 02-Jul-1998  tsubai Console support.
 1.1 15-May-1998  tsubai Initial import of macppc port.
 1.6.12.1 01-Apr-2001  he Pull up revision 1.8 (requested by tsubai):
Fix Keyboard problem of recent PowerBooks (Pismo, PowerBook G4,
etc.).
 1.6.2.2 21-Apr-2001  bouyer Sync with HEAD
 1.6.2.1 05-Jan-2001  bouyer Sync with HEAD
 1.7.2.2 21-Jun-2001  nathanw Catch up to -current.
 1.7.2.1 09-Apr-2001  nathanw Catch up with -current.
 1.9.16.1 16-Jul-2002  gehenna catch up with -current.
 1.9.8.4 03-Jan-2003  thorpej Sync with HEAD.
 1.9.8.3 18-Oct-2002  nathanw Catch up to -current.
 1.9.8.2 20-Jun-2002  nathanw Catch up to -current.
 1.9.8.1 08-Jun-2001  nathanw file adb.c was added on branch nathanw_sa on 2002-06-20 03:39:32 +0000
 1.9.2.2 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.9.2.1 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.14.2.4 04-Feb-2005  skrll Sync with HEAD.
 1.14.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.14.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.14.2.1 03-Aug-2004  skrll Sync with HEAD
 1.15.10.1 12-Feb-2005  yamt sync with head.
 1.15.8.1 29-Apr-2005  kent sync with -current
 1.18.6.4 15-Nov-2007  yamt sync with head.
 1.18.6.3 27-Oct-2007  yamt sync with head.
 1.18.6.2 26-Feb-2007  yamt sync with head.
 1.18.6.1 30-Dec-2006  yamt sync with head.
 1.19.20.2 12-Jan-2007  ad Sync with head.
 1.19.20.1 18-Nov-2006  ad Sync with head.
 1.19.8.1 14-Sep-2006  yamt sync with head.
 1.20.2.1 18-Dec-2006  yamt sync with head.
 1.22.28.2 13-Nov-2007  bouyer Sync with HEAD
 1.22.28.1 25-Oct-2007  bouyer Sync with HEAD.
 1.22.26.1 18-Oct-2007  yamt sync with head.
 1.22.24.2 08-Nov-2007  matt sync with -HEAD
 1.22.24.1 06-Nov-2007  matt sync with HEAD
 1.22.22.2 11-Nov-2007  joerg Sync with HEAD.
 1.22.22.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.22.14.1 07-Jun-2007  garbled Convert macppc to powerpc bus_space. Lots of work here from Matt Thomas,
as well as the common ofwoea code from myself. Compile tested only,
still probably needs some fine tuning.

Also in this commit:
Convert macppc to new shared ofwoea routines.
Lots of KNF.
 1.22.6.2 03-Dec-2007  ad Sync with HEAD.
 1.22.6.1 23-Oct-2007  ad Sync with head.
 1.23.2.1 19-Nov-2007  mjf Sync with HEAD.
 1.24.32.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.24.26.1 28-Apr-2009  skrll Sync with HEAD.
 1.24.18.2 11-Mar-2010  yamt sync with head
 1.24.18.1 04-May-2009  yamt sync with head.
 1.29.10.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.32.6.1 18-Feb-2012  mrg merge to -current.
 1.32.2.2 30-Oct-2012  yamt sync with head
 1.32.2.1 17-Apr-2012  yamt sync with head
 1.33.6.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.34.50.1 03-Apr-2021  thorpej Sync with HEAD.
 1.35.2.1 21-Mar-2021  thorpej Give config_found() the same variadic arguments treatment as
config_search(). This commit only adds the CFARG_EOL sentinel
to the existing config_found() calls. Conversion of config_found_sm_loc()
and config_found_ia() call sites will be in subsequent commits.
 1.36.8.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.47 07-Sep-2025  andvar Fix various typos, mainly in comments.
 1.46 05-Mar-2024  andvar Remove duplicate "when" word in comments.
 1.45 21-Sep-2023  msaitoh s/ for for / for / in comment.
 1.44 18-Oct-2014  snj src is too big these days to tolerate superfluous apostrophes. It's
"its", people!
 1.43 01-Feb-2012  matt branches: 1.43.6;
Use C89 function prototypes.
 1.42 18-Mar-2009  cegger branches: 1.42.12; 1.42.16;
Ansify function definitions w/o arguments. Generated with sed.
 1.41 14-Mar-2009  dsl Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.40 14-Mar-2009  dsl Remove all the __P() from sys (excluding sys/dist)
Diff checked with grep and MK1 eyeball.
i386 and amd64 GENERIC and sys still build.
 1.39 17-Oct-2007  garbled branches: 1.39.20; 1.39.28; 1.39.34;
Merge the ppcoea-renovation branch to HEAD.

This branch was a major cleanup and rototill of many of the various OEA
cpu based PPC ports that focused on sharing as much code as possible
between the various ports to eliminate near-identical copies of files in
every tree. Additionally there is a new PIC system that unifies the
interface to interrupt code for all different OEA ppc arches. The work
for this branch was done by a variety of people, too long to list here.

TODO:
bebox still needs work to complete the transition to -renovation.
ofppc still needs a bunch of work, which I will be looking at.
ev64260 still needs to be renovated
amigappc was not attempted.

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.38 09-Jul-2007  ad branches: 1.38.8; 1.38.10; 1.38.12; 1.38.14;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements
 1.37 04-Mar-2007  christos branches: 1.37.2; 1.37.4; 1.37.10;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.36 24-Jan-2007  hubertf branches: 1.36.2;
Remove duplicate #includes, patch contributed in private mail
by Slava Semushin <slava.semushin@gmail.com>.

To verify that no nasty side effects of duplicate includes (or their
removal) have an effect here, I've compiled an i386/ALL kernel with
and without the patch, and the only difference in the resulting .o
files was in shifted line numbers in some assert() calls.
The comparison of the .o files was based on the output of "objdump -D".

Thanks to martin@ for the input on testing.
 1.35 24-Nov-2006  wiz s/independant/independent/, from Zafer.
 1.34 07-Jun-2006  kardel branches: 1.34.6; 1.34.8;
avoid shadowing time while it still exists
 1.33 11-Dec-2005  christos branches: 1.33.4; 1.33.6; 1.33.8; 1.33.14;
merge ktrace-lwp.
 1.32 05-Jun-2005  nathanw branches: 1.32.2;
Rearrange some of the ADB types and void * abuse to make -Wcast-qual
happy in the presence of the "volatile int flag" construct. Fix up a variety
of calls to pass NULL instead of (Ptr)0 to maintain function-pointer safety.
 1.31 05-Jun-2005  nathanw Nuke the II and IIsi code from this file; it's never used on a
macppc. Remove variables and macros no longer used as a result.

This driver *still* needs an enema.
 1.30 01-Feb-2005  briggs Remove one level of interrupt redirection by switching on the ADB
hardware type and registering a Cuda or PMU interrupt handler
specifically instead of an intermediate interrupt handler.
 1.29 01-Feb-2005  briggs Clear all interrupts set by cuda. From Michael Lorenz.
 1.28 01-Feb-2005  briggs ADB_HW_PB is really ADB_HW_PMU.
 1.27 27-Oct-2003  dyoung branches: 1.27.8; 1.27.10;
Stop false uninitialized variable warning.
 1.26 26-Oct-2003  mycroft Remove optimization hack.
 1.25 15-Jul-2003  lukem __KERNEL_RCSID()
 1.24 05-May-2002  tsutsui branches: 1.24.10;
Add a null asm statement in adb_read_date_time()
to avoid wrong reordering by gcc-2.95.3 with -fgcse.

XXX Should we disable -fgcse everywhere?
 1.23 05-May-2002  tsutsui Backout previous. It is not timing problem, but gcc optimization bug.
 1.22 29-Apr-2002  tsutsui Add a delay() in adb_read_date_time() so that my Apus2000 can get
correct date in inittodr().
 1.21 23-Feb-2002  dbj In adb_soft_intr, remove the packet from the queue before calling the
completion routine so that the completion routine can reentrantly
process the queue. This happens, for example. when polling is turned
on by entering the debugger by keystroke.
 1.20 02-Jan-2002  dbj add some error checks in adb_reinit, enabled with ADB_DEBUG and adb_debug
 1.19 03-Aug-2001  tsubai branches: 1.19.6;
Remove (#if 0'ed) m68k asm codes.
 1.18 19-Jun-2001  simonb branches: 1.18.2;
Add/change prototypes so that macpcc builds with -Wstrict-prototypes.
 1.17 08-Jun-2001  matt Make macppc compile by default with -Wall -Wmissing-prototype in addition
to its currently enabled warnings. For the lack of a better place, most
global function prototype wound up in <machine/autoconf.h> unless there
was a better place for them. ofb_* structs renamed to offb_* to avoid
conflict with ofb_softc in <dev/ofw/openfirm.h>
 1.16 01-Apr-2001  tsubai Adjust timing for pmu99. Internal keyboard of recent PowerBooks
should work now.
 1.15 19-Dec-2000  tsubai branches: 1.15.2;
Sync with mac68k.
 1.14 08-Jun-2000  tsubai branches: 1.14.2;
Sync with mac68k.
 1.13 23-Mar-2000  thorpej branches: 1.13.2;
New callout mechanism with two major improvements over the old
timeout()/untimeout() API:
- Clients supply callout handle storage, thus eliminating problems of
resource allocation.
- Insertion and removal of callouts is constant time, important as
this facility is used quite a lot in the kernel.

The old timeout()/untimeout() API has been removed from the kernel.
 1.12 27-Jan-2000  tsubai Make this work on the G4 too.
 1.11 11-Jul-1999  tsubai branches: 1.11.2;
Enable soft poweroff on PowerBook.
 1.10 22-Jun-1999  tsubai Use RTC on PB.
 1.9 12-Jan-1999  tsubai branches: 1.9.4;
Always use polling when poweroff/restart.
 1.8 24-Nov-1998  tsubai Add more delay in adb_reinit().
 1.7 15-Nov-1998  tsubai RTC support for pmu (read only).
 1.6 05-Nov-1998  tsubai Sync to mac68k.
 1.5 04-Nov-1998  tsubai Move conversion of PRAM-time to UNIX-time to clock.c (like mac68k).
 1.4 20-Oct-1998  tsubai Add via-pmu support (only PowerBook 2400c/180 is tested).
 1.3 13-Oct-1998  tsubai Split ADB driver to aed (ADB event device), akbd (ADB keyboard),
and ams (ADB mouse). adb is a bus now. (from Colin Wood)
 1.2 26-Jun-1998  tsubai Powerdown support.
 1.1 15-May-1998  tsubai Initial import of macppc port.
 1.9.4.2 02-Aug-1999  thorpej Update from trunk.
 1.9.4.1 01-Jul-1999  thorpej Sync w/ -current.
 1.11.2.3 21-Apr-2001  bouyer Sync with HEAD
 1.11.2.2 05-Jan-2001  bouyer Sync with HEAD
 1.11.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.13.2.1 22-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.14.2.1 01-Apr-2001  he Pull up revision 1.16 (requested by tsubai):
Fix Keyboard problem of recent PowerBooks (Pismo, PowerBook G4,
etc.).
 1.15.2.2 21-Jun-2001  nathanw Catch up to -current.
 1.15.2.1 09-Apr-2001  nathanw Catch up with -current.
 1.18.2.4 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.18.2.3 16-Mar-2002  jdolecek Catch up with -current.
 1.18.2.2 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.18.2.1 25-Aug-2001  thorpej Merge Aug 24 -current into the kqueue branch.
 1.19.6.4 20-Jun-2002  nathanw Catch up to -current.
 1.19.6.3 28-Feb-2002  nathanw Catch up to -current.
 1.19.6.2 11-Jan-2002  nathanw More catchup.
 1.19.6.1 03-Aug-2001  nathanw file adb_direct.c was added on branch nathanw_sa on 2002-01-11 23:38:34 +0000
 1.24.10.5 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.24.10.4 04-Feb-2005  skrll Sync with HEAD.
 1.24.10.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.24.10.2 18-Sep-2004  skrll Sync with HEAD.
 1.24.10.1 03-Aug-2004  skrll Sync with HEAD
 1.27.10.1 12-Feb-2005  yamt sync with head.
 1.27.8.1 29-Apr-2005  kent sync with -current
 1.32.2.5 27-Oct-2007  yamt sync with head.
 1.32.2.4 03-Sep-2007  yamt sync with head.
 1.32.2.3 26-Feb-2007  yamt sync with head.
 1.32.2.2 30-Dec-2006  yamt sync with head.
 1.32.2.1 21-Jun-2006  yamt sync with head.
 1.33.14.1 19-Jun-2006  chap Sync with head.
 1.33.8.1 26-Jun-2006  yamt sync with head.
 1.33.6.1 22-Apr-2006  simonb Fix some shadowed variable warnings.
 1.33.4.1 09-Sep-2006  rpaulo sync with head
 1.34.8.1 10-Dec-2006  yamt sync with head.
 1.34.6.2 01-Feb-2007  ad Sync with head.
 1.34.6.1 12-Jan-2007  ad Sync with head.
 1.36.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.37.10.3 03-Oct-2007  garbled Sync with HEAD
 1.37.10.2 02-Aug-2007  macallan sync with HEAD
 1.37.10.1 07-Jun-2007  garbled Convert macppc to powerpc bus_space. Lots of work here from Matt Thomas,
as well as the common ofwoea code from myself. Compile tested only,
still probably needs some fine tuning.

Also in this commit:
Convert macppc to new shared ofwoea routines.
Lots of KNF.
 1.37.4.1 11-Jul-2007  mjf Sync with head.
 1.37.2.2 23-Oct-2007  ad Sync with head.
 1.37.2.1 15-Jul-2007  ad Sync with head.
 1.38.14.1 25-Oct-2007  bouyer Sync with HEAD.
 1.38.12.1 18-Oct-2007  yamt sync with head.
 1.38.10.1 06-Nov-2007  matt sync with HEAD
 1.38.8.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.39.34.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.39.28.1 28-Apr-2009  skrll Sync with HEAD.
 1.39.20.1 04-May-2009  yamt sync with head.
 1.42.16.1 18-Feb-2012  mrg merge to -current.
 1.42.12.1 17-Apr-2012  yamt sync with head
 1.43.6.1 03-Dec-2017  jdolecek update from HEAD
 1.2 01-Feb-2005  briggs adb_direct.h contents are in adbvar.h. No need for duplication.
 1.1 15-May-1998  tsubai branches: 1.1.48; 1.1.56; 1.1.58;
Initial import of macppc port.
 1.1.58.1 12-Feb-2005  yamt sync with head.
 1.1.56.1 29-Apr-2005  kent sync with -current
 1.1.48.1 04-Feb-2005  skrll Sync with HEAD.
 1.2 28-Mar-1999  tsubai Remove unused files.
 1.1 15-May-1998  tsubai Initial import of macppc port.
 1.15 27-Oct-2012  chs split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.14 01-Nov-2009  snj branches: 1.14.12; 1.14.22;
Drop 3rd and 4th clauses. Approved by Brad Grantham (copyright holder).
 1.13 14-Mar-2009  dsl Remove all the __P() from sys (excluding sys/dist)
Diff checked with grep and MK1 eyeball.
i386 and amd64 GENERIC and sys still build.
 1.12 04-Mar-2007  christos branches: 1.12.44; 1.12.52; 1.12.58;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.11 11-Dec-2005  christos branches: 1.11.26;
merge ktrace-lwp.
 1.10 05-Jun-2005  nathanw branches: 1.10.2;
Rearrange some of the ADB types and void * abuse to make -Wcast-qual
happy in the presence of the "volatile int flag" construct. Fix up a variety
of calls to pass NULL instead of (Ptr)0 to maintain function-pointer safety.
 1.9 01-Feb-2005  briggs Remove one level of interrupt redirection by switching on the ADB
hardware type and registering a Cuda or PMU interrupt handler
specifically instead of an intermediate interrupt handler.
 1.8 01-Feb-2005  briggs ADB_HW_PB is really ADB_HW_PMU.
 1.7 09-Apr-2003  thorpej branches: 1.7.2; 1.7.10; 1.7.12;
G/c the traceq; nothing uses it.
 1.6 18-Jun-2002  itojun extern decl for adbHardware
 1.5 08-Jun-2001  matt branches: 1.5.2; 1.5.8; 1.5.16;
Make macppc compile by default with -Wall -Wmissing-prototype in addition
to its currently enabled warnings. For the lack of a better place, most
global function prototype wound up in <machine/autoconf.h> unless there
was a better place for them. ofb_* structs renamed to offb_* to avoid
conflict with ofb_softc in <dev/ofw/openfirm.h>
 1.4 19-Dec-2000  tsubai branches: 1.4.2;
Sync with mac68k.
 1.3 08-Jun-2000  tsubai Sync with mac68k.
 1.2 13-Oct-1998  tsubai branches: 1.2.12; 1.2.20;
Split ADB driver to aed (ADB event device), akbd (ADB keyboard),
and ams (ADB mouse). adb is a bus now. (from Colin Wood)
 1.1 15-May-1998  tsubai Initial import of macppc port.
 1.2.20.1 22-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.2.12.2 05-Jan-2001  bouyer Sync with HEAD
 1.2.12.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.4.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.5.16.1 16-Jul-2002  gehenna catch up with -current.
 1.5.8.2 20-Jun-2002  nathanw Catch up to -current.
 1.5.8.1 08-Jun-2001  nathanw file adbvar.h was added on branch nathanw_sa on 2002-06-20 03:39:33 +0000
 1.5.2.1 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.7.12.1 12-Feb-2005  yamt sync with head.
 1.7.10.1 29-Apr-2005  kent sync with -current
 1.7.2.2 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.7.2.1 04-Feb-2005  skrll Sync with HEAD.
 1.10.2.1 03-Sep-2007  yamt sync with head.
 1.11.26.1 12-Mar-2007  rmind Sync with HEAD.
 1.12.58.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.12.52.1 28-Apr-2009  skrll Sync with HEAD.
 1.12.44.2 11-Mar-2010  yamt sync with head
 1.12.44.1 04-May-2009  yamt sync with head.
 1.14.22.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.14.12.1 30-Oct-2012  yamt sync with head
 1.5 07-Oct-2008  pgoyette Remove chip-specific drivers for ADT7463, ADT7467, and ADM1030; these
have been superseded by the dbcool(4) driver.
 1.4 08-May-2008  macallan branches: 1.4.4;
nuke license clause 3
 1.3 04-May-2008  xtraeme branches: 1.3.2;
device_t/softc split for adt7467c(4) and adm1030, and other related
cosmetic changes.
 1.2 11-Dec-2005  christos branches: 1.2.18; 1.2.76; 1.2.78; 1.2.80;
merge ktrace-lwp.
 1.1 10-Aug-2005  macallan branches: 1.1.6;
glue to attach thermal monitor chips directly to ki2c
 1.1.6.2 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.1.6.1 10-Aug-2005  skrll file adm1030_ki2c.c was added on branch ktrace-lwp on 2005-11-10 13:57:27 +0000
 1.2.80.2 04-May-2009  yamt sync with head.
 1.2.80.1 16-May-2008  yamt sync with head.
 1.2.78.1 18-May-2008  yamt sync with head.
 1.2.76.2 17-Jan-2009  mjf Sync with HEAD.
 1.2.76.1 02-Jun-2008  mjf Sync with HEAD.
 1.2.18.2 21-Jun-2006  yamt sync with head.
 1.2.18.1 11-Dec-2005  yamt file adm1030_ki2c.c was added on branch yamt-lazymbuf on 2006-06-21 14:53:13 +0000
 1.3.2.2 10-Oct-2008  skrll Sync with HEAD.
 1.3.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.4.4.1 19-Oct-2008  haad Sync with HEAD.
 1.6 07-Oct-2008  pgoyette Remove chip-specific drivers for ADT7463, ADT7467, and ADM1030; these
have been superseded by the dbcool(4) driver.
 1.5 08-May-2008  macallan branches: 1.5.4;
nuke license clause 3
 1.4 08-May-2008  macallan report chip revision
 1.3 04-May-2008  xtraeme branches: 1.3.2;
device_t/softc split for adt7467c(4) and adm1030, and other related
cosmetic changes.
 1.2 11-Dec-2005  christos branches: 1.2.18; 1.2.76; 1.2.78; 1.2.80;
merge ktrace-lwp.
 1.1 10-Aug-2005  macallan branches: 1.1.6;
glue to attach thermal monitor chips directly to ki2c
 1.1.6.2 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.1.6.1 10-Aug-2005  skrll file adt7467_ki2c.c was added on branch ktrace-lwp on 2005-11-10 13:57:27 +0000
 1.2.80.2 04-May-2009  yamt sync with head.
 1.2.80.1 16-May-2008  yamt sync with head.
 1.2.78.1 18-May-2008  yamt sync with head.
 1.2.76.2 17-Jan-2009  mjf Sync with HEAD.
 1.2.76.1 02-Jun-2008  mjf Sync with HEAD.
 1.2.18.2 21-Jun-2006  yamt sync with head.
 1.2.18.1 11-Dec-2005  yamt file adt7467_ki2c.c was added on branch yamt-lazymbuf on 2006-06-21 14:53:13 +0000
 1.3.2.2 10-Oct-2008  skrll Sync with HEAD.
 1.3.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.5.4.1 19-Oct-2008  haad Sync with HEAD.
 1.37 13-Jan-2025  riastradh macppc/aed, akbd: Nix trailing whitespace.

No functional change intended.
 1.36 12-Jan-2025  nat Catch up macppc to the same as mac68k.

Unfortunately these files could not be tested fully as aed/akbd/ams and
adb_direct have suffered from bit rot and there corresponding attachments
are commented out in all macppc kernels.
 1.35 05-Jun-2024  nat branches: 1.35.2;
Pass event up to adb device.

While here do the same for macppc.

Addresses PR/58303
 1.34 26-Sep-2021  thorpej branches: 1.34.4;
Driver "kqfilter" entry points return an error code, so if an invalid
filter is requested, return EINVAL rather than 1.
 1.33 26-Sep-2021  thorpej Use seltrue_filtops rather than rolling our own with filt_seltrue.
 1.32 26-Sep-2021  thorpej Change the kqueue filterops::f_isfd field to filterops::f_flags, and
define a flag FILTEROP_ISFD that has the meaning of the prior f_isfd.
Field and flag name aligned with OpenBSD.

This does not constitute a functional or ABI change, as the field location
and size, and the value placed in that field, are the same as the previous
code, but we're bumping __NetBSD_Version__ so 3rd-party module source code
can adapt, as needed.

NetBSD 9.99.89
 1.31 19-Dec-2020  thorpej Use sel{record,remove}_knote().
 1.30 25-Oct-2017  maya branches: 1.30.8; 1.30.16;
Use C99 initializer for filterops

Mostly done with spatch with touchups for indentation

@@
expression a;
identifier b,c,d;
identifier p;
@@
const struct filterops p =
- { a, b, c, d
+ {
+ .f_isfd = a,
+ .f_attach = b,
+ .f_detach = c,
+ .f_event = d,
};
 1.29 25-Jul-2014  dholland Add d_discard to all struct cdevsw instances I could find.

All have been set to "nodiscard"; some should get a real implementation.
 1.28 16-Mar-2014  dholland branches: 1.28.2;
Change (mostly mechanically) every cdevsw/bdevsw I can find to use
designated initializers.

I have not built every extant kernel so I have probably broken at
least one build; however I've also found and fixed some wrong
cdevsw/bdevsw entries so even if so I think we come out ahead.
 1.27 27-Oct-2012  chs branches: 1.27.2;
split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.26 18-Jun-2011  matt branches: 1.26.2; 1.26.12;
struct device * -> device_t
struct cfdata * -> cfdata_t
use device accessors, use device_private.
some softc/device_t splits (macppc needs a bunch more)
aprint*_dev used considerably more
 1.25 01-Nov-2009  snj branches: 1.25.10;
Drop 3rd and 4th clauses. Approved by Brad Grantham (copyright holder).
 1.24 14-Mar-2009  dsl ANSIfy another 1261 function definitions.
The only ones left in sys are beyond by sed script!
(or in sys/dist or sys/external)
Mostly they have function pointer parameters.
 1.23 14-Mar-2009  dsl Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.22 14-Mar-2009  dsl Remove all the __P() from sys (excluding sys/dist)
Diff checked with grep and MK1 eyeball.
i386 and amd64 GENERIC and sys still build.
 1.21 01-Mar-2008  rmind branches: 1.21.4; 1.21.12; 1.21.18;
Welcome to 4.99.55:

- Add a lot of missing selinit() and seldestroy() calls.

- Merge selwakeup() and selnotify() calls into a single selnotify().

- Add an additional 'events' argument to selnotify() call. It will
indicate which event (POLL_IN, POLL_OUT, etc) happen. If unknown,
zero may be used.

Note: please pass appropriate value of 'events' where possible.
Proposed on: <tech-kern>
 1.20 17-Oct-2007  garbled branches: 1.20.12; 1.20.16;
Merge the ppcoea-renovation branch to HEAD.

This branch was a major cleanup and rototill of many of the various OEA
cpu based PPC ports that focused on sharing as much code as possible
between the various ports to eliminate near-identical copies of files in
every tree. Additionally there is a new PIC system that unifies the
interface to interrupt code for all different OEA ppc arches. The work
for this branch was done by a variety of people, too long to list here.

TODO:
bebox still needs work to complete the transition to -renovation.
ofppc still needs a bunch of work, which I will be looking at.
ev64260 still needs to be renovated
amigappc was not attempted.

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.19 09-Jul-2007  ad branches: 1.19.10;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements
 1.18 04-Mar-2007  christos branches: 1.18.2; 1.18.4; 1.18.10;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.17 29-Mar-2006  thorpej branches: 1.17.14;
Use device_cfdata().
 1.16 11-Dec-2005  christos branches: 1.16.4; 1.16.6; 1.16.8; 1.16.10; 1.16.12;
merge ktrace-lwp.
 1.15 05-Jun-2005  nathanw branches: 1.15.2;
Don't shadow global aed_sc with local aed_sc.
XXX there shouldn't be a global aed_sc in the first place; the interface
among ADB devices is terrible.
 1.14 15-Jul-2003  lukem __KERNEL_RCSID()
 1.13 29-Jun-2003  fvdl branches: 1.13.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.12 29-Jun-2003  darrenr 'struct proc *' -> 'struct lwp *' as required to get GENERIC for macppc built
 1.11 26-Nov-2002  christos si_ -> sel_
 1.10 23-Oct-2002  jdolecek merge kqueue branch into -current

kqueue provides a stateful and efficient event notification framework
currently supported events include socket, file, directory, fifo,
pipe, tty and device changes, and monitoring of processes and signals

kqueue is supported by all writable filesystems in NetBSD tree
(with exception of Coda) and all device drivers supporting poll(2)

based on work done by Jonathan Lemon for FreeBSD
initial NetBSD port done by Luke Mewburn and Jason Thorpe
 1.9 02-Oct-2002  thorpej Use CFATTACH_DECL().
 1.8 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.7 27-Sep-2002  provos remove trailing \n in panic(). approved perry.
 1.6 06-Sep-2002  gehenna Merge the gehenna-devsw branch into the trunk.

This merge changes the device switch tables from static array to
dynamically generated by config(8).

- All device switches is defined as a constant structure in device drivers.

- The new grammer ``device-major'' is introduced to ``files''.

device-major <prefix> char <num> [block <num>] [<rules>]

- All device major numbers must be listed up in port dependent majors.<arch>
by using this grammer.

- Added the new naming convention.
The name of the device switch must be <prefix>_[bc]devsw for auto-generation
of device switch tables.

- The backward compatibility of loading block/character device
switch by LKM framework is broken. This is necessary to convert
from block/character device major to device name in runtime and vice versa.

- The restriction to assign device major by LKM is completely removed.
We don't need to reserve LKM entries for dynamic loading of device switch.

- In compile time, device major numbers list is packed into the kernel and
the LKM framework will refer it to assign device major number dynamically.
 1.5 23-Mar-2000  thorpej branches: 1.5.6; 1.5.8; 1.5.12; 1.5.20;
New callout mechanism with two major improvements over the old
timeout()/untimeout() API:
- Clients supply callout handle storage, thus eliminating problems of
resource allocation.
- Insertion and removal of callouts is constant time, important as
this facility is used quite a lot in the kernel.

The old timeout()/untimeout() API has been removed from the kernel.
 1.4 17-Feb-1999  tsubai branches: 1.4.8;
Sync with mac68k.
 1.3 18-Oct-1998  tsubai Add wsmouse support.
 1.2 13-Oct-1998  tsubai Fix cut-and-paste miss...
 1.1 13-Oct-1998  tsubai Split ADB driver to aed (ADB event device), akbd (ADB keyboard),
and ams (ADB mouse). adb is a bus now. (from Colin Wood)
 1.4.8.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.5.20.1 17-May-2002  gehenna Add device switch.
 1.5.12.4 11-Dec-2002  thorpej Sync with HEAD.
 1.5.12.3 11-Nov-2002  nathanw Catch up to -current
 1.5.12.2 18-Oct-2002  nathanw Catch up to -current.
 1.5.12.1 17-Sep-2002  nathanw Catch up to -current.
 1.5.8.3 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.5.8.2 18-Jun-2002  jdolecek make compile - use cdev_decl() and couple minor fixes
 1.5.8.1 09-Sep-2001  thorpej Add kqueue support (not yet compiled).
 1.5.6.1 10-Oct-2001  fvdl Convert all remaining devices.
 1.13.2.5 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.13.2.4 18-Nov-2004  skrll Adapt to branch. macppc release builds.
 1.13.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.13.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.13.2.1 03-Aug-2004  skrll Sync with HEAD
 1.15.2.3 17-Mar-2008  yamt sync with head.
 1.15.2.2 03-Sep-2007  yamt sync with head.
 1.15.2.1 21-Jun-2006  yamt sync with head.
 1.16.12.1 31-Mar-2006  tron Merge 2006-03-31 NetBSD-current into the "peter-altq" branch.
 1.16.10.1 19-Apr-2006  elad sync with head - hopefully this will work
 1.16.8.1 01-Apr-2006  yamt sync with head.
 1.16.6.1 22-Apr-2006  simonb Sync with head.
 1.16.4.1 09-Sep-2006  rpaulo sync with head
 1.17.14.1 12-Mar-2007  rmind Sync with HEAD.
 1.18.10.2 03-Oct-2007  garbled Sync with HEAD
 1.18.10.1 02-Aug-2007  macallan sync with HEAD
 1.18.4.1 11-Jul-2007  mjf Sync with head.
 1.18.2.1 15-Jul-2007  ad Sync with head.
 1.19.10.2 23-Mar-2008  matt sync with HEAD
 1.19.10.1 06-Nov-2007  matt sync with HEAD
 1.20.16.1 03-Apr-2008  mjf Sync with HEAD.
 1.20.12.1 24-Mar-2008  keiichi sync with head.
 1.21.18.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.21.12.1 28-Apr-2009  skrll Sync with HEAD.
 1.21.4.2 11-Mar-2010  yamt sync with head
 1.21.4.1 04-May-2009  yamt sync with head.
 1.25.10.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.26.12.3 03-Dec-2017  jdolecek update from HEAD
 1.26.12.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.26.12.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.26.2.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.26.2.1 30-Oct-2012  yamt sync with head
 1.27.2.1 18-May-2014  rmind sync with head
 1.28.2.1 10-Aug-2014  tls Rebase.
 1.30.16.1 03-Jan-2021  thorpej Sync w/ HEAD.
 1.30.8.1 20-Jun-2024  martin Pull up following revision(s) (requested by nat in ticket #1847):

sys/arch/macppc/dev/aed.c: revision 1.35
sys/arch/mac68k/dev/aed.c: revision 1.39

Pass event up to adb device.

While here do the same for macppc.

Addresses PR/58303
 1.34.4.1 20-Jun-2024  martin Pull up following revision(s) (requested by nat in ticket #708):

sys/arch/macppc/dev/aed.c: revision 1.35
sys/arch/mac68k/dev/aed.c: revision 1.39

Pass event up to adb device.

While here do the same for macppc.

Addresses PR/58303
 1.35.2.1 02-Aug-2025  perseant Sync with HEAD
 1.6 27-Oct-2012  chs split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.5 01-Nov-2009  snj branches: 1.5.12; 1.5.22;
Drop 3rd and 4th clauses. Approved by Brad Grantham (copyright holder).
 1.4 14-Mar-2009  dsl Remove all the __P() from sys (excluding sys/dist)
Diff checked with grep and MK1 eyeball.
i386 and amd64 GENERIC and sys still build.
 1.3 06-Sep-2002  gehenna branches: 1.3.112; 1.3.120; 1.3.126;
Merge the gehenna-devsw branch into the trunk.

This merge changes the device switch tables from static array to
dynamically generated by config(8).

- All device switches is defined as a constant structure in device drivers.

- The new grammer ``device-major'' is introduced to ``files''.

device-major <prefix> char <num> [block <num>] [<rules>]

- All device major numbers must be listed up in port dependent majors.<arch>
by using this grammer.

- Added the new naming convention.
The name of the device switch must be <prefix>_[bc]devsw for auto-generation
of device switch tables.

- The backward compatibility of loading block/character device
switch by LKM framework is broken. This is necessary to convert
from block/character device major to device name in runtime and vice versa.

- The restriction to assign device major by LKM is completely removed.
We don't need to reserve LKM entries for dynamic loading of device switch.

- In compile time, device major numbers list is packed into the kernel and
the LKM framework will refer it to assign device major number dynamically.
 1.2 23-Mar-2000  thorpej branches: 1.2.6; 1.2.8; 1.2.12; 1.2.20;
New callout mechanism with two major improvements over the old
timeout()/untimeout() API:
- Clients supply callout handle storage, thus eliminating problems of
resource allocation.
- Insertion and removal of callouts is constant time, important as
this facility is used quite a lot in the kernel.

The old timeout()/untimeout() API has been removed from the kernel.
 1.1 13-Oct-1998  tsubai branches: 1.1.12;
Split ADB driver to aed (ADB event device), akbd (ADB keyboard),
and ams (ADB mouse). adb is a bus now. (from Colin Wood)
 1.1.12.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.2.20.1 19-May-2002  gehenna Remove unnecessary prototype.
 1.2.12.1 17-Sep-2002  nathanw Catch up to -current.
 1.2.8.2 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.2.8.1 18-Jun-2002  jdolecek don't define aed driver hooks here
 1.2.6.1 10-Oct-2001  fvdl Convert all remaining devices.
 1.3.126.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.3.120.1 28-Apr-2009  skrll Sync with HEAD.
 1.3.112.2 11-Mar-2010  yamt sync with head
 1.3.112.1 04-May-2009  yamt sync with head.
 1.5.22.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.5.12.1 30-Oct-2012  yamt sync with head
 1.49 13-Jan-2025  riastradh macppc/aed, akbd: Nix trailing whitespace.

No functional change intended.
 1.48 12-Jan-2025  nat Catch up macppc to the same as mac68k.

Unfortunately these files could not be tested fully as aed/akbd/ams and
adb_direct have suffered from bit rot and there corresponding attachments
are commented out in all macppc kernels.
 1.47 07-Aug-2021  thorpej branches: 1.47.12;
Merge thorpej-cfargs2.
 1.46 24-Apr-2021  thorpej branches: 1.46.8;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).
 1.45 27-Oct-2012  chs branches: 1.45.52;
split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.44 18-Jun-2011  matt branches: 1.44.2; 1.44.12;
struct device * -> device_t
struct cfdata * -> cfdata_t
use device accessors, use device_private.
some softc/device_t splits (macppc needs a bunch more)
aprint*_dev used considerably more
 1.43 18-Mar-2009  cegger branches: 1.43.10;
Ansify function definitions w/o arguments. Generated with sed.
 1.42 14-Mar-2009  dsl ANSIfy another 1261 function definitions.
The only ones left in sys are beyond by sed script!
(or in sys/dist or sys/external)
Mostly they have function pointer parameters.
 1.41 14-Mar-2009  dsl Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.40 14-Mar-2009  dsl Remove all the __P() from sys (excluding sys/dist)
Diff checked with grep and MK1 eyeball.
i386 and amd64 GENERIC and sys still build.
 1.39 13-Jun-2008  cegger branches: 1.39.4; 1.39.10;
use device_lookup_private to get softc
 1.38 17-Oct-2007  garbled branches: 1.38.16; 1.38.18; 1.38.20; 1.38.22; 1.38.24;
Merge the ppcoea-renovation branch to HEAD.

This branch was a major cleanup and rototill of many of the various OEA
cpu based PPC ports that focused on sharing as much code as possible
between the various ports to eliminate near-identical copies of files in
every tree. Additionally there is a new PIC system that unifies the
interface to interrupt code for all different OEA ppc arches. The work
for this branch was done by a variety of people, too long to list here.

TODO:
bebox still needs work to complete the transition to -renovation.
ofppc still needs a bunch of work, which I will be looking at.
ev64260 still needs to be renovated
amigappc was not attempted.

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.37 08-Aug-2007  macallan branches: 1.37.2;
use the ADB keymap in dev/adb/
 1.36 05-Mar-2007  tsutsui branches: 1.36.2; 1.36.10; 1.36.14; 1.36.18;
- use (uint8_t *) for buffer args on *_adbcomplete() functions
- remove kbd_adbcomplete() decl from akbd.c since it's in akbdvar.h
 1.35 04-Mar-2007  christos Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.34 11-Dec-2005  christos branches: 1.34.26;
merge ktrace-lwp.
 1.33 05-Jun-2005  nathanw branches: 1.33.2;
Pass NULL instead of (Ptr)0 to maintain function-pointer safety.
 1.32 01-Feb-2005  briggs Remove one level of interrupt redirection by switching on the ADB
hardware type and registering a Cuda or PMU interrupt handler
specifically instead of an intermediate interrupt handler.
 1.31 24-Jul-2003  nathanw branches: 1.31.8; 1.31.10;
Make kbd_passup() an exposed function.
 1.30 15-Jul-2003  lukem __KERNEL_RCSID()
 1.29 02-Oct-2002  thorpej branches: 1.29.6;
Use CFATTACH_DECL().
 1.28 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.27 14-Aug-2002  aymeric Remove the key repeating feature.
It is asking for trouble and is useless for the X server.
We can add it back later if need be.
 1.26 13-Aug-2002  aymeric akbd's now have a raw mode, and implement the WSKBDIO_SETMODE ioctl.
Adapted from OpenBSD.
 1.25 14-Jun-2002  itojun whitespace
 1.24 14-Jun-2002  itojun #define CAPS_IS_CONTROL will make caps key a control key (with weird
LCD indicator). From: "Nathan J. Williams" <nathanw@wasabisystems.com>
(#define name taken from arch/i386/isa/pccons.c)
 1.23 17-Mar-2002  atatat branches: 1.23.4; 1.23.6;
Convert ioctl code to use EPASSTHROUGH instead of -1 or ENOTTY for
indicating an unhandled "command". ERESTART is -1, which can lead to
confusion. ERESTART has been moved to -3 and EPASSTHROUGH has been
placed at -4. No ioctl code should now return -1 anywhere. The
ioctl() system call is now properly restartable.
 1.22 12-Mar-2002  wrstuden Only attach the first adb keyboard as the console kbd. Don't try for
the others. It is perfectly reasonable to have multiple adb keyboards,
and a number of multi-button mice have a fake kbd for the second and
third mouse buttons. Now my machine doesn't panic during boot when it
is trying to add a second ws console kbd.
 1.21 24-Feb-2002  dbj solve polled adb keyboard problems with dropped keys and unsynced caps lock
by queueing polled keys.
 1.20 23-Feb-2002  dbj turn on polling using cnpollc
 1.19 02-Jan-2002  dbj defer attaching akbd as console until after it has
been initialized in akbdattach
 1.18 02-Oct-2001  mycroft branches: 1.18.4;
Use WSKBD_TYPE_ADB.
 1.17 26-Jul-2001  tsubai branches: 1.17.2;
Change description of handler-ID == 195.
 1.16 17-Jul-2001  tsubai Eject PCMCIA card on ohare based models only.
 1.15 12-Jul-2001  nathanw Add the keyboard ID found on the American versions of the PowerBook G4 and
iBook (dual USB).
 1.14 08-Jun-2001  matt branches: 1.14.2;
Make macppc compile by default with -Wall -Wmissing-prototype in addition
to its currently enabled warnings. For the lack of a better place, most
global function prototype wound up in <machine/autoconf.h> unless there
was a better place for them. ofb_* structs renamed to offb_* to avoid
conflict with ofb_softc in <dev/ofw/openfirm.h>
 1.13 25-Jan-2001  tsubai branches: 1.13.2;
Generate key press event and key release event when capslock is pressed.
Now capslock key works correctly on X11.
 1.12 19-Dec-2000  tsubai Remove unnecessary casts.
 1.11 19-Dec-2000  tsubai Sync with mac68k.
 1.10 01-Sep-2000  tsubai Add fr key layout. (From Manuel Bouyer, modified by me)
 1.9 05-Sep-1999  tsubai branches: 1.9.2;
Recognize PCMCIA eject button. (Tested on only PowerBook 2400.)
 1.8 16-Jun-1999  tsubai Define PowerBook G3 Japanese keyboard.
 1.7 06-May-1999  thorpej Take all of the OpenFirmware "stdin" grovelling out of the ADB keyboard
driver, as the smarts for this all live somewhere else now.
 1.6 17-Feb-1999  tsubai branches: 1.6.2;
Sync with mac68k.
 1.5 10-Jan-1999  tsubai Add sanity checks in akbd_cnattach().
 1.4 20-Oct-1998  tsubai Add via-pmu support (only PowerBook 2400c/180 is tested).
 1.3 18-Oct-1998  tsubai Make compilable without aed.
 1.2 14-Oct-1998  tsubai akbd: wskbd support.
ofb: OpenFirmware generic framebuffer.
 1.1 13-Oct-1998  tsubai Split ADB driver to aed (ADB event device), akbd (ADB keyboard),
and ams (ADB mouse). adb is a bus now. (from Colin Wood)
 1.6.2.1 06-May-1999  perry branches: 1.6.2.1.2;
pullup 1.6->1.7 (thorpej)
 1.6.2.1.2.1 21-Jun-1999  thorpej Sync w/ -current.
 1.9.2.3 11-Feb-2001  bouyer Sync with HEAD.
 1.9.2.2 05-Jan-2001  bouyer Sync with HEAD
 1.9.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.13.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.14.2.6 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.14.2.5 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.14.2.4 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.14.2.3 16-Mar-2002  jdolecek Catch up with -current.
 1.14.2.2 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.14.2.1 03-Aug-2001  lukem update to -current
 1.17.2.1 11-Oct-2001  fvdl Catch up with -current. Fix some bogons in the sparc64 kbd/ms
attach code. cd18xx conversion provided by mrg.
 1.18.4.7 18-Oct-2002  nathanw Catch up to -current.
 1.18.4.6 27-Aug-2002  nathanw Catch up to -current.
 1.18.4.5 20-Jun-2002  nathanw Catch up to -current.
 1.18.4.4 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.18.4.3 28-Feb-2002  nathanw Catch up to -current.
 1.18.4.2 11-Jan-2002  nathanw More catchup.
 1.18.4.1 02-Oct-2001  nathanw file akbd.c was added on branch nathanw_sa on 2002-01-11 23:38:35 +0000
 1.23.6.1 19-Jun-2003  grant Pull up revisions 1.26-1.27 (requested by aymeric in ticket #1324):

akbd's now have a raw mode, and implement the WSKBDIO_SETMODE ioctl.
Adapted from OpenBSD.

Remove the key repeating feature.
It is asking for trouble and is useless for the X server.
We can add it back later if need be.
 1.23.4.2 31-Aug-2002  gehenna catch up with -current.
 1.23.4.1 14-Jul-2002  gehenna catch up with -current.
 1.29.6.6 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.29.6.5 04-Feb-2005  skrll Sync with HEAD.
 1.29.6.4 13-Jan-2005  skrll Adapt to branch
 1.29.6.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.29.6.2 18-Sep-2004  skrll Sync with HEAD.
 1.29.6.1 03-Aug-2004  skrll Sync with HEAD
 1.31.10.1 12-Feb-2005  yamt sync with head.
 1.31.8.1 29-Apr-2005  kent sync with -current
 1.33.2.2 03-Sep-2007  yamt sync with head.
 1.33.2.1 21-Jun-2006  yamt sync with head.
 1.34.26.1 12-Mar-2007  rmind Sync with HEAD.
 1.36.18.1 09-Aug-2007  jmcneill Sync with HEAD.
 1.36.14.1 15-Aug-2007  skrll Sync with HEAD.
 1.36.10.1 03-Oct-2007  garbled Sync with HEAD
 1.36.2.1 20-Aug-2007  ad Sync with HEAD.
 1.37.2.1 06-Nov-2007  matt sync with HEAD
 1.38.24.1 18-Jun-2008  simonb Sync with head.
 1.38.22.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.38.20.1 04-May-2009  yamt sync with head.
 1.38.18.1 17-Jun-2008  yamt sync with head.
 1.38.16.1 29-Jun-2008  mjf Sync with HEAD.
 1.39.10.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.39.4.1 28-Apr-2009  skrll Sync with HEAD.
 1.43.10.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.44.12.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.44.2.1 30-Oct-2012  yamt sync with head
 1.45.52.1 21-Mar-2021  thorpej Give config_found() the same variadic arguments treatment as
config_search(). This commit only adds the CFARG_EOL sentinel
to the existing config_found() calls. Conversion of config_found_sm_loc()
and config_found_ia() call sites will be in subsequent commits.
 1.46.8.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.47.12.1 02-Aug-2025  perseant Sync with HEAD
 1.5 23-Feb-2003  manu Merged mac68k and macppc keayboards, since they are the same. The file
could move to <arch/mac> if one day we create it.

Fixed french keymap: option was not mapped correctly, thus making
impossible to use |{}[] (tested).
Added jp keymap from PR/15438, and sf, sv, de and uk keymaps from OpenBSD.
(all untested).
 1.4 04-Mar-2002  dbj branches: 1.4.8;
add a few missing keys, including f1-f12,home,end,next,prior
 1.3 01-Sep-2000  tsubai branches: 1.3.4; 1.3.8;
Add fr key layout. (From Manuel Bouyer, modified by me)
 1.2 13-Jan-1999  tsubai branches: 1.2.8;
Use KS_KEYCODE macro.
 1.1 14-Oct-1998  tsubai akbd: wskbd support.
ofb: OpenFirmware generic framebuffer.
 1.2.8.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.3.8.1 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.3.4.1 16-Mar-2002  jdolecek Catch up with -current.
 1.4.8.1 02-Jun-2003  tron Pull up revision 1.5 (requested by manu in ticket #1183):
Merged mac68k and macppc keayboards, since they are the same. The file
could move to <arch/mac> if one day we create it.
Fixed french keymap: option was not mapped correctly, thus making
impossible to use |{}[] (tested).
Added jp keymap from PR/15438, and sf, sv, de and uk keymaps from
OpenBSD.
(all untested).
 1.14 27-Oct-2012  chs split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.13 14-Mar-2009  dsl branches: 1.13.12; 1.13.22;
Remove all the __P() from sys (excluding sys/dist)
Diff checked with grep and MK1 eyeball.
i386 and amd64 GENERIC and sys still build.
 1.12 05-Mar-2007  tsutsui branches: 1.12.44; 1.12.52; 1.12.58;
- use (uint8_t *) for buffer args on *_adbcomplete() functions
- remove kbd_adbcomplete() decl from akbd.c since it's in akbdvar.h
 1.11 04-Mar-2007  christos Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.10 11-Dec-2005  christos branches: 1.10.26;
merge ktrace-lwp.
 1.9 24-Jul-2003  nathanw branches: 1.9.16;
Make kbd_passup() an exposed function.
 1.8 05-Sep-2002  jdolecek branches: 1.8.6;
put back NetBSD RCS Id removed in rev 1.6
 1.7 14-Aug-2002  aymeric Remove the key repeating feature.
It is asking for trouble and is useless for the X server.
We can add it back later if need be.
 1.6 13-Aug-2002  aymeric akbd's now have a raw mode, and implement the WSKBDIO_SETMODE ioctl.
Adapted from OpenBSD.
 1.5 24-Feb-2002  dbj branches: 1.5.8; 1.5.10;
solve polled adb keyboard problems with dropped keys and unsynced caps lock
by queueing polled keys.
 1.4 17-Feb-1999  tsubai branches: 1.4.22; 1.4.26;
Sync with mac68k.
 1.3 14-Oct-1998  tsubai Fix typo.
 1.2 14-Oct-1998  tsubai wskbd support.
 1.1 13-Oct-1998  tsubai Split ADB driver to aed (ADB event device), akbd (ADB keyboard),
and ams (ADB mouse). adb is a bus now. (from Colin Wood)
 1.4.26.3 17-Sep-2002  nathanw Catch up to -current.
 1.4.26.2 27-Aug-2002  nathanw Catch up to -current.
 1.4.26.1 28-Feb-2002  nathanw Catch up to -current.
 1.4.22.2 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.4.22.1 16-Mar-2002  jdolecek Catch up with -current.
 1.5.10.1 19-Jun-2003  grant Pull up revisions 1.6-1.7 (requested by aymeric in ticket #1324):

akbd's now have a raw mode, and implement the WSKBDIO_SETMODE ioctl.
Adapted from OpenBSD.

Remove the key repeating feature.
It is asking for trouble and is useless for the X server.
We can add it back later if need be.
 1.5.8.1 31-Aug-2002  gehenna catch up with -current.
 1.8.6.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.8.6.2 18-Sep-2004  skrll Sync with HEAD.
 1.8.6.1 03-Aug-2004  skrll Sync with HEAD
 1.9.16.1 03-Sep-2007  yamt sync with head.
 1.10.26.1 12-Mar-2007  rmind Sync with HEAD.
 1.12.58.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.12.52.1 28-Apr-2009  skrll Sync with HEAD.
 1.12.44.1 04-May-2009  yamt sync with head.
 1.13.22.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.13.12.1 30-Oct-2012  yamt sync with head
 1.52 29-Jun-2024  riastradh if_stats(9): Add ifp argument to if_stat..._ref.

This will enable us to pass the ifp through to a dtrace probe inside.

No functional change intended in this change, but this is an API
change visible to modules so it shouldn't be pulled up.

PR kern/58377
 1.51 18-Sep-2022  thorpej Eliminate use of IFF_OACTIVE.
 1.50 20-Oct-2020  roy le(4): add link status change reporting to drivers which support it

Reviewed by thorpej@
Tested by martin@
 1.49 04-Feb-2020  martin Convert a few more drivers to the if_stats interface
 1.48 04-Feb-2020  skrll Adopt <net/if_stats.h>
 1.47 27-Dec-2019  msaitoh branches: 1.47.2;
s/expresion/expression/ in comment.
 1.46 29-May-2019  msaitoh Even if we don't use MII(4), use the common path of SIOC[GS]IFMEDIA in
sys/net/if_ethersubr.c if we can.
- Add ec_ifmedia into struct ethercom.
- ec_mii in struct ethercom is kept and used as it is. It might be used in
future. Note that some Ethernet drivers which _DOESN'T_ use mii(4) use
ec_mii for keeping the if_media. Those should be changed in future.
 1.45 28-May-2019  msaitoh Use ETHER_LOCK()/ETHER_UNLOCK() for all ethernet drivers to protect ec_multi*.
 1.44 23-May-2019  msaitoh No functional change:
- Change ac(was arpcom) to ec(ethercom)
- Simplify MII structure initialization.
- u_int*_t -> uint*_t.
- KNF
 1.43 26-Apr-2019  msaitoh No functional change:
- u_int_{8,16,32}_t -> uint_{8,16,32}_t
- KNF.
- Tabify.
- Remove extra space.
 1.42 05-Feb-2019  msaitoh Remove very old IFF_NOTRAILERS flag.
 1.41 03-Sep-2018  riastradh Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)
 1.40 26-Jun-2018  msaitoh branches: 1.40.2;
Implement the BPF direction filter (BIOC[GS]DIRECTION). It provides backward
compatibility with BIOC[GS]SEESENT ioctl. The userland interface is the same
as FreeBSD.

This change also fixes a bug that the direction is misunderstand on some
environment by passing the direction to bpf_mtap*() instead of checking
m->m_pkthdr.rcvif.
 1.39 22-Jun-2018  msaitoh It's not required to include net/bpfdesc.h. Remove it.
 1.38 22-Feb-2017  nonaka branches: 1.38.6; 1.38.12;
Apply deferred if_start to more MD drivers.
 1.37 15-Dec-2016  ozaki-r branches: 1.37.2;
Move bpf_mtap and if_ipackets++ on Rx of each driver to percpuq if_input

The benefits of the change are:
- We can reduce codes
- We can provide the same behavior between drivers
- Where/When if_ipackets is counted up
- Note that some drivers still update packet statistics in their own
way (periodical update)
- Moved bpf_mtap run in softint
- This makes it easy to MP-ify bpf

Proposed on tech-kern and tech-net
 1.36 02-Oct-2016  christos MFREE -> m_free
 1.35 10-Jun-2016  ozaki-r branches: 1.35.2;
Introduce m_set_rcvif and m_reset_rcvif

The API is used to set (or reset) a received interface of a mbuf.
They are counterpart of m_get_rcvif, which will come in another
commit, hide internal of rcvif operation, and reduce the diff of
the upcoming change.

No functional change.
 1.34 09-Feb-2016  ozaki-r Introduce softint-based if_input

This change intends to run the whole network stack in softint context
(or normal LWP), not hardware interrupt context. Note that the work is
still incomplete by this change; to that end, we also have to softint-ify
if_link_state_change (and bpf) which can still run in hardware interrupt.

This change softint-ifies at ifp->if_input that is called from
each device driver (and ieee80211_input) to ensure Layer 2 runs
in softint (e.g., ether_input and bridge_input). To this end,
we provide a framework (called percpuq) that utlizes softint(9)
and percpu ifqueues. With this patch, rxintr of most drivers just
queues received packets and schedules a softint, and the softint
dequeues packets and does rest packet processing.

To minimize changes to each driver, percpuq is allocated in struct
ifnet for now and that is initialized by default (in if_attach).
We probably have to move percpuq to softc of each driver, but it's
future work. At this point, only wm(4) has percpuq in its softc
as a reference implementation.

Additional information including performance numbers can be found
in the thread at tech-kern@ and tech-net@:
http://mail-index.netbsd.org/tech-kern/2016/01/14/msg019997.html

Acknowledgment: riastradh@ greatly helped this work.
Thank you very much!
 1.33 14-Mar-2014  mrg branches: 1.33.6;
remove various set-but-unused variables.
 1.32 26-Jul-2011  macallan branches: 1.32.2; 1.32.12; 1.32.16;
finish device_t-ification
 1.31 01-Jul-2011  dyoung #include <sys/bus.h> instead of <machine/bus.h>.
 1.30 20-Dec-2010  matt Move counting of faults, traps, intrs, soft[intr]s, syscalls, and nswtch
from uvmexp to per-cpu cpu_data and move them to 64bits. Remove unneeded
includes of <uvm/uvm_extern.h> and/or <uvm/uvm.h>.
 1.29 05-Apr-2010  joerg Push the bpf_ops usage back into bpf.h. Push the common ifp->if_bpf
check into the inline functions as well the fourth argument for
bpf_attach.
 1.28 19-Jan-2010  pooka branches: 1.28.2; 1.28.4;
Redefine bpf linkage through an always present op vector, i.e.
#if NBPFILTER is no longer required in the client. This change
doesn't yet add support for loading bpf as a module, since drivers
can register before bpf is attached. However, callers of bpf can
now be modularized.

Dynamically loadable bpf could probably be done fairly easily with
coordination from the stub driver and the real driver by registering
attachments in the stub before the real driver is loaded and doing
a handoff. ... and I'm not going to ponder the depths of unload
here.

Tested with i386/MONOLITHIC, modified MONOLITHIC without bpf and rump.
 1.27 14-Mar-2009  dsl ANSIfy another 1261 function definitions.
The only ones left in sys are beyond by sed script!
(or in sys/dist or sys/external)
Mostly they have function pointer parameters.
 1.26 14-Mar-2009  dsl Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.25 14-Mar-2009  dsl Remove all the __P() from sys (excluding sys/dist)
Diff checked with grep and MK1 eyeball.
i386 and amd64 GENERIC and sys still build.
 1.24 07-Nov-2008  dyoung branches: 1.24.4;
*** Summary ***

When a link-layer address changes (e.g., ifconfig ex0 link
02:de:ad:be:ef:02 active), send a gratuitous ARP and/or a Neighbor
Advertisement to update the network-/link-layer address bindings
on our LAN peers.

Refuse a change of ethernet address to the address 00:00:00:00:00:00
or to any multicast/broadcast address. (Thanks matt@.)

Reorder ifnet ioctl operations so that driver ioctls may inherit
the functions of their "class"---ether_ioctl(), fddi_ioctl(), et
cetera---and the class ioctls may inherit from the generic ioctl,
ifioctl_common(), but both driver- and class-ioctls may override
the generic behavior. Make network drivers share more code.

Distinguish a "factory" link-layer address from others for the
purposes of both protecting that address from deletion and computing
EUI64.

Return consistent, appropriate error codes from network drivers.

Improve readability. KNF.

*** Details ***

In if_attach(), always initialize the interface ioctl routine,
ifnet->if_ioctl, if the driver has not already initialized it.
Delete if_ioctl == NULL tests everywhere else, because it cannot
happen.

In the ioctl routines of network interfaces, inherit common ioctl
behaviors by calling either ifioctl_common() or whichever ioctl
routine is appropriate for the class of interface---e.g., ether_ioctl()
for ethernets.

Stop (ab)using SIOCSIFADDR and start to use SIOCINITIFADDR. In
the user->kernel interface, SIOCSIFADDR's argument was an ifreq,
but on the protocol->ifnet interface, SIOCSIFADDR's argument was
an ifaddr. That was confusing, and it would work against me as I
make it possible for a network interface to overload most ioctls.
On the protocol->ifnet interface, replace SIOCSIFADDR with
SIOCINITIFADDR. In ifioctl(), return EPERM if userland tries to
invoke SIOCINITIFADDR.

In ifioctl(), give the interface the first shot at handling most
interface ioctls, and give the protocol the second shot, instead
of the other way around. Finally, let compatibility code (COMPAT_OSOCK)
take a shot.

Pull device initialization out of switch statements under
SIOCINITIFADDR. For example, pull ..._init() out of any switch
statement that looks like this:

switch (...->sa_family) {
case ...:
..._init();
...
break;
...
default:
..._init();
...
break;
}

Rewrite many if-else clauses that handle all permutations of IFF_UP
and IFF_RUNNING to use a switch statement,

switch (x & (IFF_UP|IFF_RUNNING)) {
case 0:
...
break;
case IFF_RUNNING:
...
break;
case IFF_UP:
...
break;
case IFF_UP|IFF_RUNNING:
...
break;
}

unifdef lots of code containing #ifdef FreeBSD, #ifdef NetBSD, and
#ifdef SIOCSIFMTU, especially in fwip(4) and in ndis(4).

In ipw(4), remove an if_set_sadl() call that is out of place.

In nfe(4), reuse the jumbo MTU logic in ether_ioctl().

Let ethernets register a callback for setting h/w state such as
promiscuous mode and the multicast filter in accord with a change
in the if_flags: ether_set_ifflags_cb() registers a callback that
returns ENETRESET if the caller should reset the ethernet by calling
if_init(), 0 on success, != 0 on failure. Pull common code from
ex(4), gem(4), nfe(4), sip(4), tlp(4), vge(4) into ether_ioctl(),
and register if_flags callbacks for those drivers.

Return ENOTTY instead of EINVAL for inappropriate ioctls. In
zyd(4), use ENXIO instead of ENOTTY to indicate that the device is
not any longer attached.

Add to if_set_sadl() a boolean 'factory' argument that indicates
whether a link-layer address was assigned by the factory or some
other source. In a comment, recommend using the factory address
for generating an EUI64, and update in6_get_hw_ifid() to prefer a
factory address to any other link-layer address.

Add a routing message, RTM_LLINFO_UPD, that tells protocols to
update the binding of network-layer addresses to link-layer addresses.
Implement this message in IPv4 and IPv6 by sending a gratuitous
ARP or a neighbor advertisement, respectively. Generate RTM_LLINFO_UPD
messages on a change of an interface's link-layer address.

In ether_ioctl(), do not let SIOCALIFADDR set a link-layer address
that is broadcast/multicast or equal to 00:00:00:00:00:00.

Make ether_ioctl() call ifioctl_common() to handle ioctls that it
does not understand.

In gif(4), initialize if_softc and use it, instead of assuming that
the gif_softc and ifp overlap.

Let ifioctl_common() handle SIOCGIFADDR.

Sprinkle rtcache_invariants(), which checks on DIAGNOSTIC kernels
that certain invariants on a struct route are satisfied.

In agr(4), rewrite agr_ioctl_filter() to be a bit more explicit
about the ioctls that we do not allow on an agr(4) member interface.

bzero -> memset. Delete unnecessary casts to void *. Use
sockaddr_in_init() and sockaddr_in6_init(). Compare pointers with
NULL instead of "testing truth". Replace some instances of (type
*)0 with NULL. Change some K&R prototypes to ANSI C, and join
lines.
 1.23 17-Oct-2007  garbled branches: 1.23.16; 1.23.20; 1.23.26; 1.23.28;
Merge the ppcoea-renovation branch to HEAD.

This branch was a major cleanup and rototill of many of the various OEA
cpu based PPC ports that focused on sharing as much code as possible
between the various ports to eliminate near-identical copies of files in
every tree. Additionally there is a new PIC system that unifies the
interface to interrupt code for all different OEA ppc arches. The work
for this branch was done by a variety of people, too long to list here.

TODO:
bebox still needs work to complete the transition to -renovation.
ofppc still needs a bunch of work, which I will be looking at.
ev64260 still needs to be renovated
amigappc was not attempted.

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.22 01-Sep-2007  dyoung branches: 1.22.2; 1.22.4;
Change a bazillion occurrences of code resembling this,

error = (cmd == SIOCADDMULTI) ?
ether_addmulti(ifr, &sc->sc_ec) :
ether_delmulti(ifr, &sc->sc_ec);

if (error == ENETRESET) {

to this,

if ((error = ether_ioctl(ifp, cmd, data)) == ENETRESET) {

which does the same thing.

(A bazillion is a very large number. This seems to make the i386
ALL kernel smaller by 3kB to 4kB.)

Use ifreq_getaddr() twice in es(4).

Whitespace nits.
 1.21 05-Mar-2007  tsutsui branches: 1.21.2; 1.21.10; 1.21.14; 1.21.18; 1.21.20;
Use (uint8_t *) for RX buffer.
 1.20 04-Mar-2007  christos Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.19 24-Jan-2007  hubertf branches: 1.19.2;
Remove duplicate #includes, patch contributed in private mail
by Slava Semushin <slava.semushin@gmail.com>.

To verify that no nasty side effects of duplicate includes (or their
removal) have an effect here, I've compiled an i386/ALL kernel with
and without the patch, and the only difference in the resulting .o
files was in shifted line numbers in some assert() calls.
The comparison of the .o files was based on the output of "objdump -D".

Thanks to martin@ for the input on testing.
 1.18 07-Sep-2006  dogcow branches: 1.18.2;
remove more vestiges of CCITT, LLC, HDLC, NS, and NSIP.
 1.17 11-Dec-2005  christos branches: 1.17.4; 1.17.8;
merge ktrace-lwp.
 1.16 30-Oct-2004  thorpej branches: 1.16.12;
When adding/deleting multicast addresses, only whack the address
filter if the interface is marked RUNNING.

Fixes kern/27678.
 1.15 15-Jul-2003  lukem branches: 1.15.4;
__KERNEL_RCSID()
 1.14 04-Jun-2003  bjh21 branches: 1.14.2;
In mcstop(), don't clear IFF_UP. Other drivers don't mess with IFF_UP
internally, other than to set it when they gain their first address.
Every caller of mcstop() bar one was either preserving the state of IFF_UP
itself or was conditional on its already being clear, so the only effect of
this is to simplify the code and to change that one case, thereby curing
PR port-macppc/12088 (underflows on "mc" cause it to be taken down).
 1.13 02-Apr-2003  thorpej Use PAGE_SIZE rather than NBPG.
 1.12 16-Jan-2002  thorpej branches: 1.12.10;
Use bpf_mtap().
 1.11 22-Jul-2001  wiz branches: 1.11.6;
bcopy -> memcpy, bzero -> memset, bcmp -> memcmp.
Reviewed by Matt Thomas, ok'd by Tsubai Masanari.
 1.10 15-Nov-2000  thorpej branches: 1.10.4;
Move bpfattach()/bpfdetach() calls into ether_ifattach()/ether_ifdetach().
 1.9 01-Oct-2000  thorpej Move the check for "promisc + unicast + not for us" into ether_input(),
and change Ethernet drivers to always pass all received frames to
ether_input() (with a few exceptions, which are documented in the
code).
 1.8 29-Jun-2000  mrg remove include of <vm/vm.h>. <vm/vm.h> -> <uvm/uvm_extern.h>
 1.7 18-May-1999  thorpej branches: 1.7.2; 1.7.12;
Rework layer 2 protocol input routines. Instead of calling e.g. ether_input()
directly, call the function pointer (*if_input)(ifp, m). The input routine
expects the packet header to be at the head of the packet, and will adjust
as necessary. Privatize the layer 2 input and output routines, allowing
*_ifattach() to set them up as appropriate.
 1.6 03-Sep-1998  tsubai branches: 1.6.8;
Change void mcintr() to int mcintr().
 1.5 05-Jul-1998  jonathan defopt NS, NSIP.
 1.4 05-Jul-1998  jonathan defopt LLC
 1.3 05-Jul-1998  jonathan defopt CCITT.
 1.2 05-Jul-1998  jonathan defopt INET, NETATALK.
 1.1 15-May-1998  tsubai Initial import of macppc port.
 1.6.8.1 21-Jun-1999  thorpej Sync w/ -current.
 1.7.12.1 17-Jun-2003  msaitoh Pull up revisions 1.14 (requested by Ben Harris in ticket #46):
Don't bring down mc(4) interfaces when they underflow.
Fixes PR#12088.
 1.7.2.2 22-Nov-2000  bouyer Sync with HEAD.
 1.7.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.10.4.2 11-Feb-2002  jdolecek Sync w/ -current.
 1.10.4.1 03-Aug-2001  lukem update to -current
 1.11.6.2 28-Feb-2002  nathanw Catch up to -current.
 1.11.6.1 22-Jul-2001  nathanw file am79c950.c was added on branch nathanw_sa on 2002-02-28 04:10:39 +0000
 1.12.10.1 17-Jun-2003  msaitoh Pull up revisions 1.14 (requested by Ben Harris in ticket #1314):
Don't bring down mc(4) interfaces when they underflow.
Fixes PR#12088.
 1.14.2.4 02-Nov-2004  skrll Sync with HEAD.
 1.14.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.14.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.14.2.1 03-Aug-2004  skrll Sync with HEAD
 1.15.4.1 24-Jan-2005  he Pull up revision 1.16 (requested by thorpej in ticket #939):
When adding or deleting multicast addresses, only change
the address filter if the interface is marked RUNNING.
Fixes PR#27678.
 1.16.12.4 27-Oct-2007  yamt sync with head.
 1.16.12.3 03-Sep-2007  yamt sync with head.
 1.16.12.2 26-Feb-2007  yamt sync with head.
 1.16.12.1 30-Dec-2006  yamt sync with head.
 1.17.8.1 14-Sep-2006  yamt sync with head.
 1.17.4.1 09-Sep-2006  rpaulo sync with head
 1.18.2.1 01-Feb-2007  ad Sync with head.
 1.19.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.21.20.1 06-Nov-2007  matt sync with HEAD
 1.21.18.2 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.21.18.1 03-Sep-2007  jmcneill Sync with HEAD.
 1.21.14.1 03-Sep-2007  skrll Sync with HEAD.
 1.21.10.3 03-Oct-2007  garbled Sync with HEAD
 1.21.10.2 27-Sep-2007  macallan use ether_ioctl()
 1.21.10.1 07-Jun-2007  garbled Convert macppc to powerpc bus_space. Lots of work here from Matt Thomas,
as well as the common ofwoea code from myself. Compile tested only,
still probably needs some fine tuning.

Also in this commit:
Convert macppc to new shared ofwoea routines.
Lots of KNF.
 1.21.2.2 23-Oct-2007  ad Sync with head.
 1.21.2.1 09-Oct-2007  ad Sync with head.
 1.22.4.1 25-Oct-2007  bouyer Sync with HEAD.
 1.22.2.1 18-Oct-2007  yamt sync with head.
 1.23.28.2 28-Apr-2009  skrll Sync with HEAD.
 1.23.28.1 19-Jan-2009  skrll Sync with HEAD.
 1.23.26.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.23.20.3 11-Aug-2010  yamt sync with head.
 1.23.20.2 11-Mar-2010  yamt sync with head
 1.23.20.1 04-May-2009  yamt sync with head.
 1.23.16.1 17-Jan-2009  mjf Sync with HEAD.
 1.24.4.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.28.4.2 05-Mar-2011  rmind sync with head
 1.28.4.1 30-May-2010  rmind sync with head
 1.28.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.32.16.1 18-May-2014  rmind sync with head
 1.32.12.2 03-Dec-2017  jdolecek update from HEAD
 1.32.12.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.32.2.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.33.6.5 28-Aug-2017  skrll Sync with HEAD
 1.33.6.4 05-Feb-2017  skrll Sync with HEAD
 1.33.6.3 05-Oct-2016  skrll Sync with HEAD
 1.33.6.2 09-Jul-2016  skrll Sync with HEAD
 1.33.6.1 19-Mar-2016  skrll Sync with HEAD
 1.35.2.3 20-Mar-2017  pgoyette Sync with HEAD
 1.35.2.2 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.35.2.1 04-Nov-2016  pgoyette Sync with HEAD
 1.37.2.1 21-Apr-2017  bouyer Sync with HEAD
 1.38.12.3 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.38.12.2 28-Jul-2018  pgoyette Sync with HEAD
 1.38.12.1 25-Jun-2018  pgoyette Sync with HEAD
 1.38.6.1 26-Jul-2018  snj Pull up following revision(s) (requested by msaitoh in ticket #938):
sys/arch/acorn32/podulebus/if_ie.c: revision 1.41
sys/arch/amiga/dev/if_es.c: revision 1.58
sys/arch/amiga/dev/if_qn.c: revision 1.45
sys/arch/arm/at91/at91emac.c: revision 1.20
sys/arch/arm/ep93xx/epe.c: revision 1.37
sys/arch/emips/ebus/if_le_ebus.c: revision 1.14
sys/arch/emips/ebus/if_le_ebus.c: revision 1.15
sys/arch/mac68k/dev/if_mc.c: revision 1.46
sys/arch/macppc/dev/am79c950.c: revision 1.39
sys/arch/newsmips/apbus/if_sn.c: revision 1.40
sys/arch/next68k/dev/mb8795.c: revision 1.59
sys/arch/playstation2/dev/if_smap.c: revision 1.25
sys/arch/playstation2/dev/if_smap.c: revision 1.26
sys/arch/sun2/dev/if_ec.c: revision 1.28
sys/arch/sun3/dev/if_ie.c: revision 1.63
sys/arch/x68k/dev/if_ne_intio.c: revision 1.19
sys/arch/xen/xen/if_xennet_xenbus.c: revision 1.75
sys/arch/xen/xen/xennetback_xenbus.c: revision 1.63
sys/dev/bi/if_ni.c: revision 1.45
sys/dev/cadence/if_cemac.c: revision 1.12
sys/dev/ic/am7990.c: revision 1.78
sys/dev/ic/am79900.c: revision 1.27
sys/dev/ic/an.c: revision 1.67
sys/dev/ic/cs89x0.c: revision 1.40
sys/dev/ic/dm9000.c: revision 1.13
sys/dev/ic/dm9000.c: revision 1.14
sys/dev/ic/dp8390.c: revision 1.88
sys/dev/ic/elink3.c: revision 1.141
sys/dev/ic/elinkxl.c: revision 1.122
sys/dev/ic/hme.c: revision 1.98
sys/dev/ic/i82586.c: revision 1.77
sys/dev/ic/lance.c: revision 1.53
sys/dev/ic/mb86950.c: revision 1.27
sys/dev/ic/mb86960.c: revision 1.86
sys/dev/ic/mtd803.c: revision 1.34
sys/dev/ic/pdq_ifsubr.c: revision 1.59
sys/dev/ic/rrunner.c: revision 1.86
sys/dev/ic/seeq8005.c: revision 1.58
sys/dev/ic/sgec.c: revision 1.47
sys/dev/ic/smc90cx6.c: revision 1.72
sys/dev/ic/smc91cxx.c: revision 1.96
sys/dev/ic/tropic.c: revision 1.49
sys/dev/ic/wi.c: revision 1.245
sys/dev/isa/if_eg.c: revision 1.93
sys/dev/isa/if_el.c: revision 1.95
sys/dev/isa/if_iy.c: revision 1.101
sys/dev/ofw/ofnet.c: revision 1.58
sys/dev/pci/if_alc.c: revision 1.27
sys/dev/pci/if_de.c: revision 1.152
sys/dev/pci/if_fpa.c: revision 1.61
sys/dev/pci/if_jme.c: revision 1.34
sys/dev/pci/if_tl.c: revision 1.108
sys/dev/pci/if_vte.c: revision 1.19
sys/dev/pci/ixgbe/ixgbe.h: revision 1.50
sys/dev/pcmcia/if_cnw.c: revision 1.62
sys/dev/pcmcia/if_malo_pcmcia.c: revision 1.17
sys/dev/pcmcia/if_ray.c: revision 1.89
sys/dev/pcmcia/if_xi.c: revision 1.81
sys/dev/pcmcia/mhzc.c: revision 1.51
sys/dev/pcmcia/xirc.c: revision 1.34
sys/dev/qbus/if_de.c: revision 1.33
sys/dev/qbus/if_qe.c: revision 1.78
sys/dev/qbus/if_qt.c: revision 1.22
sys/dev/sbus/be.c: revision 1.87
sys/dev/sbus/qe.c: revision 1.68
sys/dev/scsipi/if_se.c: revision 1.96
sys/dev/usb/if_atu.c: revision 1.59
sys/net/if_l2tp.c: revision 1.28 via patch
sys/net/if_ppp.c: revision 1.160
It's not required to include net/bpfdesc.h. Remove it.
--
Simplify like other drivers. NULL check of ifp->if_bpf is done in
bpf_mtap(), so it's not required to do it here.
--
Remove duplicated inclusion of net/bpf.h.
--
Remove duplicated inclusion of net/bpf.h.
--
Simplify bpf_mtap() call. No functional change.
 1.40.2.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.40.2.1 10-Jun-2019  christos Sync with HEAD
 1.47.2.1 29-Feb-2020  ad Sync with head.
 1.3 25-Jun-2025  andvar s/Confiuration/Configuration/ in comments.
 1.2 31-Oct-2022  andvar branches: 1.2.8;
s/interrut/interrupt/ and s/accelelerator/accelerator/ in comments.
 1.1 15-May-1998  tsubai Initial import of macppc port.
 1.2.8.1 02-Aug-2025  perseant Sync with HEAD
 1.31 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.30 24-Apr-2021  thorpej branches: 1.30.8;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).
 1.29 27-Oct-2012  chs branches: 1.29.52;
split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.28 01-Aug-2011  mbalmer branches: 1.28.2; 1.28.12;
According to the Oxford Dictionary of Etymology, a wether is a male sheep
or ram.
 1.27 18-Jun-2011  matt struct device * -> device_t
struct cfdata * -> cfdata_t
use device accessors, use device_private.
some softc/device_t splits (macppc needs a bunch more)
aprint*_dev used considerably more
 1.26 10-Dec-2010  macallan branches: 1.26.6;
return the right values for ioctl(WSKBDIO_GTYPE) and ioctl(WSMOUSEIO_GTYPE)
fixes PR 23991
 1.25 05-Mar-2007  tsutsui branches: 1.25.66;
- use (uint8_t *) for buffer args on *_adbcomplete() functions
- remove kbd_adbcomplete() decl from akbd.c since it's in akbdvar.h
 1.24 04-Mar-2007  christos Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.23 14-Jan-2007  macallan branches: 1.23.2;
for trackpads add a sysctl to control wether tapping causes button events
 1.22 13-Nov-2006  he branches: 1.22.2;
Adapt to the wsmouse_input() change where we now require the 'w' axis.
 1.21 12-Nov-2006  plunky Tidy away wsmouse_input() abstractions and update
documentation to include the W direction.
 1.20 15-Oct-2006  macallan ansify
 1.19 15-Oct-2006  macallan report button clicks when tapping a trackpad
Tested on a PB3400c and an iBook G4
 1.18 11-Dec-2005  christos branches: 1.18.20; 1.18.22;
merge ktrace-lwp.
 1.17 05-Jun-2005  nathanw branches: 1.17.2;
Rearrange some of the ADB types and void * abuse to make -Wcast-qual
happy in the presence of the "volatile int flag" construct. Fix up a variety
of calls to pass NULL instead of (Ptr)0 to maintain function-pointer safety.
 1.16 15-Jul-2003  lukem __KERNEL_RCSID()
 1.15 02-Oct-2002  thorpej branches: 1.15.6;
Use CFATTACH_DECL().
 1.14 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.13 17-Mar-2002  atatat Convert ioctl code to use EPASSTHROUGH instead of -1 or ENOTTY for
indicating an unhandled "command". ERESTART is -1, which can lead to
confusion. ERESTART has been moved to -3 and EPASSTHROUGH has been
placed at -4. No ioctl code should now return -1 anywhere. The
ioctl() system call is now properly restartable.
 1.12 22-Jul-2001  wiz branches: 1.12.6;
bcopy -> memcpy, bzero -> memset, bcmp -> memcmp.
Reviewed by Matt Thomas, ok'd by Tsubai Masanari.
 1.11 19-Dec-2000  tsubai branches: 1.11.4;
Remove unnecessary casts.
 1.10 19-Dec-2000  tsubai Add support for Kensington Turbo Mouse.
 1.9 19-Dec-2000  tsubai Sync with mac68k.
 1.8 08-Jan-2000  takemura Absolute pointing device support.
- Wsmouse_input() get new argument 'flag', which indicates whether x/y/z are
relative or absolute.
- Wsmouse get new io controls, WSMOUSEIO_SCALIBCOORDS and
WSMOUSEIO_GCALIBCOORDS.
 1.7 16-Aug-1999  tsubai branches: 1.7.2;
Make configurable without ams.
 1.6 17-Jun-1999  tsubai Add "trackpad" definition.
 1.5 17-Feb-1999  tsubai branches: 1.5.4;
Sync with mac68k.
 1.4 18-Jan-1999  tsubai Invert Y axis (like ums, pms, ...).
 1.3 18-Nov-1998  tsubai Don't send mouse events to wsmouse layer if wsmouse isn't configured.
 1.2 18-Oct-1998  tsubai Add wsmouse support.
 1.1 13-Oct-1998  tsubai Split ADB driver to aed (ADB event device), akbd (ADB keyboard),
and ams (ADB mouse). adb is a bus now. (from Colin Wood)
 1.5.4.1 21-Jun-1999  thorpej Sync w/ -current.
 1.7.2.2 05-Jan-2001  bouyer Sync with HEAD
 1.7.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.11.4.3 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.11.4.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.11.4.1 03-Aug-2001  lukem update to -current
 1.12.6.3 18-Oct-2002  nathanw Catch up to -current.
 1.12.6.2 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.12.6.1 22-Jul-2001  nathanw file ams.c was added on branch nathanw_sa on 2002-04-01 07:40:53 +0000
 1.15.6.5 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.15.6.4 13-Jan-2005  skrll Adapt to branch
 1.15.6.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.15.6.2 18-Sep-2004  skrll Sync with HEAD.
 1.15.6.1 03-Aug-2004  skrll Sync with HEAD
 1.17.2.4 03-Sep-2007  yamt sync with head.
 1.17.2.3 26-Feb-2007  yamt sync with head.
 1.17.2.2 30-Dec-2006  yamt sync with head.
 1.17.2.1 21-Jun-2006  yamt sync with head.
 1.18.22.2 10-Dec-2006  yamt sync with head.
 1.18.22.1 22-Oct-2006  yamt sync with head
 1.18.20.2 01-Feb-2007  ad Sync with head.
 1.18.20.1 18-Nov-2006  ad Sync with head.
 1.22.2.1 19-Jan-2007  bouyer Pull up following revision(s) (requested by macallan in ticket #373):
sys/arch/macppc/dev/amsvar.h: revision 1.6
sys/arch/macppc/dev/ams.c: revision 1.23
for trackpads add a sysctl to control wether tapping causes button
events
 1.23.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.25.66.1 05-Mar-2011  rmind sync with head
 1.26.6.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.28.12.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.28.2.1 30-Oct-2012  yamt sync with head
 1.29.52.1 21-Mar-2021  thorpej Give config_found() the same variadic arguments treatment as
config_search(). This commit only adds the CFARG_EOL sentinel
to the existing config_found() calls. Conversion of config_found_sm_loc()
and config_found_ia() call sites will be in subsequent commits.
 1.30.8.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.11 27-Jun-2025  andvar Grammar and spelling fixes, mainly in comments. A few in documentation,
logging, test description, and SCSI ASC/ASCQ assignment descriptions.
 1.10 27-Oct-2012  chs branches: 1.10.74;
split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.9 14-Mar-2009  dsl branches: 1.9.12; 1.9.22;
Remove all the __P() from sys (excluding sys/dist)
Diff checked with grep and MK1 eyeball.
i386 and amd64 GENERIC and sys still build.
 1.8 05-Mar-2007  tsutsui branches: 1.8.44; 1.8.52; 1.8.58;
- use (uint8_t *) for buffer args on *_adbcomplete() functions
- remove kbd_adbcomplete() decl from akbd.c since it's in akbdvar.h
 1.7 04-Mar-2007  christos Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.6 14-Jan-2007  macallan branches: 1.6.2;
for trackpads add a sysctl to control wether tapping causes button events
 1.5 15-Oct-2006  macallan branches: 1.5.2;
report button clicks when tapping a trackpad
Tested on a PB3400c and an iBook G4
 1.4 17-Jun-1999  tsubai branches: 1.4.52; 1.4.82; 1.4.84;
Add "trackpad" definition.
 1.3 17-Feb-1999  tsubai branches: 1.3.4;
Sync with mac68k.
 1.2 18-Oct-1998  tsubai Add wsmouse support.
 1.1 13-Oct-1998  tsubai Split ADB driver to aed (ADB event device), akbd (ADB keyboard),
and ams (ADB mouse). adb is a bus now. (from Colin Wood)
 1.3.4.1 21-Jun-1999  thorpej Sync w/ -current.
 1.4.84.1 22-Oct-2006  yamt sync with head
 1.4.82.2 01-Feb-2007  ad Sync with head.
 1.4.82.1 18-Nov-2006  ad Sync with head.
 1.4.52.3 03-Sep-2007  yamt sync with head.
 1.4.52.2 26-Feb-2007  yamt sync with head.
 1.4.52.1 30-Dec-2006  yamt sync with head.
 1.5.2.1 19-Jan-2007  bouyer Pull up following revision(s) (requested by macallan in ticket #373):
sys/arch/macppc/dev/amsvar.h: revision 1.6
sys/arch/macppc/dev/ams.c: revision 1.23
for trackpads add a sysctl to control wether tapping causes button
events
 1.6.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.8.58.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.8.52.1 28-Apr-2009  skrll Sync with HEAD.
 1.8.44.1 04-May-2009  yamt sync with head.
 1.9.22.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.9.12.1 30-Oct-2012  yamt sync with head
 1.10.74.1 02-Aug-2025  perseant Sync with HEAD
 1.32 11-Feb-2022  thorpej Remove some #ifdef __OpenBSD__ code that's not complete and thus doesn't
serve much point in existing here.
 1.31 26-Sep-2021  thorpej Driver "kqfilter" entry points return an error code, so if an invalid
filter is requested, return EINVAL rather than 1.
 1.30 26-Sep-2021  thorpej Change the kqueue filterops::f_isfd field to filterops::f_flags, and
define a flag FILTEROP_ISFD that has the meaning of the prior f_isfd.
Field and flag name aligned with OpenBSD.

This does not constitute a functional or ABI change, as the field location
and size, and the value placed in that field, are the same as the previous
code, but we're bumping __NetBSD_Version__ so 3rd-party module source code
can adapt, as needed.

NetBSD 9.99.89
 1.29 19-Dec-2020  thorpej Use sel{record,remove}_knote().
 1.28 30-Oct-2020  christos branches: 1.28.2;
c99 struct initializers
 1.27 25-Jul-2014  dholland Add d_discard to all struct cdevsw instances I could find.

All have been set to "nodiscard"; some should get a real implementation.
 1.26 16-Mar-2014  dholland branches: 1.26.2;
Change (mostly mechanically) every cdevsw/bdevsw I can find to use
designated initializers.

I have not built every extant kernel so I have probably broken at
least one build; however I've also found and fixed some wrong
cdevsw/bdevsw entries so even if so I think we come out ahead.
 1.25 27-Oct-2012  chs branches: 1.25.2;
split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.24 18-Jun-2011  matt branches: 1.24.2; 1.24.12;
struct device * -> device_t
struct cfdata * -> cfdata_t
use device accessors, use device_private.
some softc/device_t splits (macppc needs a bunch more)
aprint*_dev used considerably more
 1.23 14-Mar-2009  dsl branches: 1.23.10;
ANSIfy another 1261 function definitions.
The only ones left in sys are beyond by sed script!
(or in sys/dist or sys/external)
Mostly they have function pointer parameters.
 1.22 14-Mar-2009  dsl Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.21 14-Mar-2009  dsl Remove all the __P() from sys (excluding sys/dist)
Diff checked with grep and MK1 eyeball.
i386 and amd64 GENERIC and sys still build.
 1.20 13-Jun-2008  cegger branches: 1.20.4; 1.20.10;
use device_lookup_private to get softc
 1.19 01-Mar-2008  rmind branches: 1.19.2; 1.19.4; 1.19.6; 1.19.8;
Welcome to 4.99.55:

- Add a lot of missing selinit() and seldestroy() calls.

- Merge selwakeup() and selnotify() calls into a single selnotify().

- Add an additional 'events' argument to selnotify() call. It will
indicate which event (POLL_IN, POLL_OUT, etc) happen. If unknown,
zero may be used.

Note: please pass appropriate value of 'events' where possible.
Proposed on: <tech-kern>
 1.18 11-Dec-2007  david branches: 1.18.2; 1.18.6;
Wrong copyright template used on import. Referenced Regents, but
Berkeley wasn't in on this one.

closes port-macppc/37520, filed by Ted Unangst.
 1.17 06-Dec-2007  ad branches: 1.17.2; 1.17.4;
lockmgr -> mutex
 1.16 04-Mar-2007  christos branches: 1.16.6; 1.16.18; 1.16.20; 1.16.26; 1.16.28;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.15 11-Dec-2005  christos branches: 1.15.26;
merge ktrace-lwp.
 1.14 05-Jun-2005  nathanw branches: 1.14.2;
Fix shadowing of parameter with local variable.
 1.13 01-Feb-2005  briggs Calculate and use seconds of power remaining for smart battery types.
 1.12 01-Feb-2005  briggs ADB_HW_PB is really ADB_HW_PMU.
 1.11 01-Feb-2005  briggs adb_direct.h contents are in adbvar.h. No need for duplication.
 1.10 15-Apr-2004  aymeric branches: 1.10.4; 1.10.6;
. add a missing call to lockinit() in apmattach()
. while here, explicitly initialize three softc variables to 0
 1.9 15-Jul-2003  lukem __KERNEL_RCSID()
 1.8 29-Jun-2003  fvdl branches: 1.8.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.7 29-Jun-2003  darrenr 'struct proc *' -> 'struct lwp *' as required to get GENERIC for macppc built
 1.6 26-Nov-2002  christos si_ -> sel_
 1.5 23-Oct-2002  jdolecek merge kqueue branch into -current

kqueue provides a stateful and efficient event notification framework
currently supported events include socket, file, directory, fifo,
pipe, tty and device changes, and monitoring of processes and signals

kqueue is supported by all writable filesystems in NetBSD tree
(with exception of Coda) and all device drivers supporting poll(2)

based on work done by Jonathan Lemon for FreeBSD
initial NetBSD port done by Luke Mewburn and Jason Thorpe
 1.4 02-Oct-2002  thorpej Use CFATTACH_DECL().
 1.3 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.2 06-Sep-2002  gehenna Merge the gehenna-devsw branch into the trunk.

This merge changes the device switch tables from static array to
dynamically generated by config(8).

- All device switches is defined as a constant structure in device drivers.

- The new grammer ``device-major'' is introduced to ``files''.

device-major <prefix> char <num> [block <num>] [<rules>]

- All device major numbers must be listed up in port dependent majors.<arch>
by using this grammer.

- Added the new naming convention.
The name of the device switch must be <prefix>_[bc]devsw for auto-generation
of device switch tables.

- The backward compatibility of loading block/character device
switch by LKM framework is broken. This is necessary to convert
from block/character device major to device name in runtime and vice versa.

- The restriction to assign device major by LKM is completely removed.
We don't need to reserve LKM entries for dynamic loading of device switch.

- In compile time, device major numbers list is packed into the kernel and
the LKM framework will refer it to assign device major number dynamically.
 1.1 18-Jun-2002  itojun branches: 1.1.2; 1.1.4; 1.1.6;
apm emulation, from openbsd
 1.1.6.4 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.1.6.3 02-Oct-2002  jdolecek do not need the (void *) cast for kn_hook anymore
 1.1.6.2 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.1.6.1 18-Jun-2002  jdolecek file apm.c was added on branch kqueue on 2002-09-06 08:37:06 +0000
 1.1.4.2 16-Jul-2002  gehenna catch up with -current.
 1.1.4.1 18-Jun-2002  gehenna file apm.c was added on branch gehenna-devsw on 2002-07-16 08:48:16 +0000
 1.1.2.6 11-Dec-2002  thorpej Sync with HEAD.
 1.1.2.5 11-Nov-2002  nathanw Catch up to -current
 1.1.2.4 18-Oct-2002  nathanw Catch up to -current.
 1.1.2.3 17-Sep-2002  nathanw Catch up to -current.
 1.1.2.2 20-Jun-2002  nathanw Catch up to -current.
 1.1.2.1 18-Jun-2002  nathanw file apm.c was added on branch nathanw_sa on 2002-06-20 03:39:33 +0000
 1.8.2.6 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.8.2.5 04-Feb-2005  skrll Sync with HEAD.
 1.8.2.4 18-Nov-2004  skrll Adapt to branch. macppc release builds.
 1.8.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.8.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.8.2.1 03-Aug-2004  skrll Sync with HEAD
 1.10.6.1 12-Feb-2005  yamt sync with head.
 1.10.4.1 29-Apr-2005  kent sync with -current
 1.14.2.5 17-Mar-2008  yamt sync with head.
 1.14.2.4 21-Jan-2008  yamt sync with head
 1.14.2.3 07-Dec-2007  yamt sync with head
 1.14.2.2 03-Sep-2007  yamt sync with head.
 1.14.2.1 21-Jun-2006  yamt sync with head.
 1.15.26.1 12-Mar-2007  rmind Sync with HEAD.
 1.16.28.2 26-Dec-2007  ad Sync with head.
 1.16.28.1 08-Dec-2007  ad Sync with head.
 1.16.26.2 27-Dec-2007  mjf Sync with HEAD.
 1.16.26.1 08-Dec-2007  mjf Sync with HEAD.
 1.16.20.2 23-Mar-2008  matt sync with HEAD
 1.16.20.1 09-Jan-2008  matt sync with HEAD
 1.16.18.1 09-Dec-2007  jmcneill Sync with HEAD.
 1.16.6.1 09-Dec-2007  reinoud Pullup to HEAD
 1.17.4.1 13-Dec-2007  bouyer Sync with HEAD
 1.17.2.1 13-Dec-2007  yamt sync with head.
 1.18.6.2 29-Jun-2008  mjf Sync with HEAD.
 1.18.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.18.2.1 24-Mar-2008  keiichi sync with head.
 1.19.8.1 18-Jun-2008  simonb Sync with head.
 1.19.6.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.19.4.1 04-May-2009  yamt sync with head.
 1.19.2.1 17-Jun-2008  yamt sync with head.
 1.20.10.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.20.4.1 28-Apr-2009  skrll Sync with HEAD.
 1.23.10.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.24.12.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.24.12.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.24.2.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.24.2.1 30-Oct-2012  yamt sync with head
 1.25.2.1 18-May-2014  rmind sync with head
 1.26.2.1 10-Aug-2014  tls Rebase.
 1.28.2.1 03-Jan-2021  thorpej Sync w/ HEAD.
 1.52 30-Aug-2023  macallan don't abuse the interrupt lock for waits in the event thread
 1.51 05-Mar-2021  rin Convert to intr_establish_xname().
 1.50 06-Feb-2021  isaki Calling halt_{input,output} is done by the MI audio layer if necessary.
 1.49 26-Jan-2021  thorpej There is not much point in of_compatible() returning -1 for "no match"
and >= 0 for "match". Just make it return 0 for "no match" and >0 for
"match" so it can be treated like a boolean expression.

As such of_match_compatible() (a wrapper around of_compatible()) is now
obsolete, and will be removed once all call sites are converted to an
appropriate replacement.
 1.48 08-Jun-2019  isaki branches: 1.48.10;
Clean get_props().
- Make get_props() return AUDIO_PROP_{PLAYBACK,CAPTURE} properly.
This eliminates need for audio.c to take care of such (old)
drivers which don't return both of PLAYBACK and CAPTURE.
- All get_props() doesn't need to return AUDIO_PROP_MMAP.
It is handled in the audio layer now.
 1.47 08-May-2019  isaki Merge isaki-audio2 branch, the overhaul of audio subsystem.
- Interrupt-oriented system rather than thread-oriented.
- Improve stability, quality and performance.
- Split playback and record cleanly. Improve halfduplex support.
- Many bugs are fixed including deadlocks, resource leaks, abuses, etc.
- Simplify audio filter mechanism. The encoding/channels/frequency
conversions are completely handled in the upper layer. So the hard-
ware driver only converts its hardware encoding (if necessary).
- audio_hw_if changes:
- Obsoletes query_encoding and add query_format instead.
- Obsoletes set_params and add set_format instead.
- Remove drain, setfd, mappage.
- The call sequences are changed.
- ioctl AUDIO_GETFD/SETFD, AUDIO_GETCHAN/SETCHAN are obsoleted.
- ioctl AUDIO_{QUERY,GET,SET}FORMAT are introduced.
- cleanup config attributes: au*conv and mulaw.
- All hardware drivers should follow it (I've done as much as possible).

Some file paths are changed:
- dev/audio.c -> dev/audio/audio.c (rewritten)
- dev/audiovar.h -> dev/audio/audiovar.h
- dev/audio_dai.h -> dev/audio/audio_dai.h
- dev/audio_if.h -> dev/audio/audio_if.h
- dev/audiobell.c -> dev/audio/audiobell.c
- dev/audiobellvar.h -> dev/audio/audiobellvar.h
- dev/mulaw.[ch] -> dev/audio/mulaw.[ch] + dev/audio/alaw.c
 1.46 16-Mar-2019  isaki branches: 1.46.2;
Use C99 style struct initializer to audio_hw_if.
 1.45 24-Aug-2016  macallan branches: 1.45.16;
don't grab the interrupt lock around mixer operations
 1.44 15-Jul-2016  macallan adjust to dbdma changes
 1.43 02-Nov-2012  phx branches: 1.43.14; 1.43.18;
My PowerMac3,1 is using gpio4 to detect a connected headphone, and I would bet
that the same is true for PowerMac3,2.
 1.42 24-Nov-2011  mrg branches: 1.42.4; 1.42.8;
put back IPL_AUDIO and splaudio(), at the request of rmind. they are
aliases and now we can easily revert audio to IPL_VM if necessary,
without having to revert the whole branch.
 1.41 23-Nov-2011  jmcneill Merge jmcneill-audiomp3 branch, which is derived from ad-audiomp2. From
the original ad-audiomp branch notes:

Add MP locking to the audio drivers.

Making the audio drivers MP safe is necessary before efforts
can be made to make the VM system MP safe.

The are two locks per device instance, an ISR lock and
a character device lock. The ISR lock replaces calls to
splaudio()/splx(), and will be held across calls to device
methods which were called at splaudio() before (e.g.
trigger_output). The character device lock is held across
calls to nearly all of the methods, excluding some only
used for initialization, e.g. get_locks.

Welcome to 5.99.57.
 1.40 20-Feb-2011  macallan branches: 1.40.4; 1.40.6;
bus_spacify, while there explicitly un-mute the headphone output when using
the beige G3's external mixer
 1.39 22-Dec-2010  macallan branches: 1.39.2; 1.39.4;
we need uvm_extern.h now
 1.38 20-Dec-2010  matt Move counting of faults, traps, intrs, soft[intr]s, syscalls, and nswtch
from uvmexp to per-cpu cpu_data and move them to 64bits. Remove unneeded
includes of <uvm/uvm_extern.h> and/or <uvm/uvm.h>.
 1.37 07-Sep-2010  macallan make this work with PMF hotkey events
Now the volume control buttons work on my Pismo
 1.36 05-Nov-2009  dyoung branches: 1.36.2; 1.36.4;
In awacs(4) and snapper(4), use deviter(9) instead of accessing
alldevs directly.

In pbms(4), delete some unused debugging macros, expand USB
compatibility macros, and add a child-detachment routine. Simplify
pbms(4) deactivation and detachment.

These changes are compile-tested, only.
 1.35 27-Aug-2008  jmcneill branches: 1.35.4;
PR#39414: No audio from awacs on PowerBook G3 (Firewire/Pismo)

Don't enable parallel output on PowerBook3,1 models.
 1.34 16-May-2008  macallan branches: 1.34.4;
struct device * -> device_t
 1.33 04-Nov-2007  macallan branches: 1.33.16; 1.33.18; 1.33.20; 1.33.22;
add a mixer control for the loopthrough channel that some awacs have - it
controls the volume of input data looped through to the output ( for
listening to what you record, it has no influence on recording level )
- defaults to zero.
 1.32 18-Oct-2007  macallan - make match() return 100 for awacs and only 1 for i2s
- correct gpio wiring for PowerMac3,3 / Gigabit G4
 1.31 17-Oct-2007  garbled Merge the ppcoea-renovation branch to HEAD.

This branch was a major cleanup and rototill of many of the various OEA
cpu based PPC ports that focused on sharing as much code as possible
between the various ports to eliminate near-identical copies of files in
every tree. Additionally there is a new PIC system that unifies the
interface to interrupt code for all different OEA ppc arches. The work
for this branch was done by a variety of people, too long to list here.

TODO:
bebox still needs work to complete the transition to -renovation.
ofppc still needs a bunch of work, which I will be looking at.
ev64260 still needs to be renovated
amigappc was not attempted.

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.30 14-Aug-2007  macallan branches: 1.30.2; 1.30.4; 1.30.6;
fix a logic botch in the headphone wiring setup - what was thought to be
'screamer' specific is actually beige G3 specific.
 1.29 09-Jul-2007  ad branches: 1.29.4; 1.29.8;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements
 1.28 25-Mar-2007  macallan branches: 1.28.4;
automatically switch between speaker and headphone output, simplify mixer
controls to match snapper
XXX - the gpios to monitor audio jacks are wired differently on different
Macs, this is known to work right on beige G3, PowerBook 3400 and Performa
63xx, it should do The Right Thing on others as well but needs more testing
 1.27 25-Mar-2007  jmcneill Handle the input change interrupt, and automatically switch between
headphone and speaker as appropriate.
 1.26 28-Feb-2007  thorpej branches: 1.26.2; 1.26.4; 1.26.6;
TRUE -> true, FALSE -> false
 1.25 17-Jan-2007  macallan branches: 1.25.2;
use sgsmix if present and appropriate
 1.24 11-Dec-2005  christos branches: 1.24.20;
merge ktrace-lwp.
 1.23 15-Jan-2005  kent branches: 1.23.10;
ansify and KNF
 1.22 10-Jan-2005  kent merge kent-audio1 branch, which introduces audio filter pipeline to the MI
audio framework


Summary of changes:

* struct audio_params
- remove sw_code, factor, factor_denom, hw_sample_rate,
hw_encoding ,hw_precision, and hw_channels. Conversion information
is conveyed by stream_filter_list_t.
- change the type of sample_rate: u_long -> u_int
- add `validbits,' which represents the valid data size in
precision bits. It is required in order to distinguish 24/32bit
from 24/24bit or 32/32bit.

* audio_hw_if
- add two parameters to set_params()
stream_filter_list_t *pfil, stream_filter_list *rfil
A HW driver should set filter recipes for requested formats
- constify audio_params parameters of trigger_output() and
trigger_input(). They represent audio formats for the hardware.
- make open() and close() optional
- add int (AUMODE_PLAY or AUMODE_RECORD) and audio_params_t parameters
to round_blocksize()

* sw_code is replaced with stream_filter_t.
stream_filer_t converts audio data in an input buffer and writes
into another output buffer unlike sw_code, which converts data in
single buffer.
converters in dev/auconv.c, dev/mulaw.c, dev/aurateconv.c,
dev/tc/bba.c, dev/ic/msm6258.c, and arch/arm/iomd/vidcaudio.c are
reimplemented as stream_filter_t

* MI audio
- audiosetinfo() builds filter pipelines from stream_filter_list_t
filled by audio_hw_if::set_params()
- audiosetinfo() returns with EINVAL if mmapped and set_params()
requests filters
- audio_write(), audio_pint(), and audio_rint() invoke a filter
pipeline.
- ioctl() for FIONREAD, AUDIO_WSEEK, AUDIO_GETIOFFS,
AUDIO_GETOOFFS, and audio_prinfo::{seek,samples} for
AUDIO_GETINFO handle values for a buffer nearest to userland.

* add `struct device *' parameter to ac97_attach()

* all of audio HW drivers follow audio_hw_if and ac97 changes
 1.21 29-Oct-2004  yamt branches: 1.21.2;
constify audio_hw_if, midi_hw_if, and radio_hw_if.
 1.20 02-Nov-2003  thorpej Squish some recent compiler warnings.
 1.19 15-Jul-2003  lukem __KERNEL_RCSID()
 1.18 03-May-2003  wiz branches: 1.18.2;
DMA, not dma nor Dma.
 1.17 02-Apr-2003  thorpej Use PAGE_SIZE rather than NBPG.
 1.16 04-Mar-2003  soren Attach on recent TiBooks.
XXX The mixer doesn't work yet.
 1.15 13-Oct-2002  wiz Support 48kHz by using aurateconv.
Based on a patch by TAMURA Kent -- thanks!
 1.14 02-Oct-2002  thorpej Use CFATTACH_DECL().
 1.13 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.12 03-Oct-2001  augustss branches: 1.12.4;
Add a new optional method, dev_ioctl, to the audio hardware driver interface.
It is called when an unrecognized ioctl() is performed on a device,
thus allowing ioctl()s that frob the hardware driver (like loading
microcode).
 1.11 19-Jun-2001  simonb branches: 1.11.2; 1.11.4;
Add/change prototypes so that macpcc builds with -Wstrict-prototypes.
 1.10 08-Jun-2001  matt Make macppc compile by default with -Wall -Wmissing-prototype in addition
to its currently enabled warnings. For the lack of a better place, most
global function prototype wound up in <machine/autoconf.h> unless there
was a better place for them. ofb_* structs renamed to offb_* to avoid
conflict with ofb_softc in <dev/ofw/openfirm.h>
 1.9 05-Apr-2001  tsubai Support uni-north based models. (XXX not complete)
 1.8 05-Apr-2001  tsubai Correct input volume settings.
 1.7 15-Mar-2001  tsubai Accept 8000Hz (XXX).
 1.6 15-Mar-2001  tsubai Add ulinear16 support.
Return EINVAL if specified rate is not available.
 1.5 12-Mar-2001  tsubai Round up block size to at least NBPG bytes.
 1.4 26-Feb-2001  wiz branches: 1.4.2;
add handling for the input channel selection/volume (no recording yet,
just the mixer interface)
 1.3 25-Jan-2001  wiz branches: 1.3.2;
Make output selection work -- you can use lineout now instead of the
internal loudspeakers.
 1.2 03-Nov-2000  tsubai branches: 1.2.2;
Don't match if nintr > 12 (more than 3 cells).
 1.1 25-Aug-2000  tsubai Add (experimental) awacs audio driver. Output (play) only.
 1.2.2.7 21-Apr-2001  bouyer Sync with HEAD
 1.2.2.6 27-Mar-2001  bouyer Sync with HEAD.
 1.2.2.5 12-Mar-2001  bouyer Sync with HEAD.
 1.2.2.4 11-Feb-2001  bouyer Sync with HEAD.
 1.2.2.3 22-Nov-2000  bouyer Sync with HEAD.
 1.2.2.2 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.2.2.1 03-Nov-2000  bouyer file awacs.c was added on branch thorpej_scsipi on 2000-11-20 20:12:56 +0000
 1.3.2.4 22-Mar-2001  he Pull up revisions 1.5-1.7 (requested by tsubai):
Round up block size to at least NBPG bytes.
Return EINVAL if specified sample rate is not available.
Fix 16bit ulinear bug, and enable ulinear.
 1.3.2.3 26-Feb-2001  he Apply patch (requested by wrstuden):
Make this compile on this release branch.
 1.3.2.2 04-Feb-2001  he Pull up revision 1.1 (new, requested by mycroft):
Add new driver for Apple sound chip.
 1.3.2.1 25-Jan-2001  he file awacs.c was added on branch netbsd-1-5 on 2001-02-04 20:22:48 +0000
 1.4.2.2 21-Jun-2001  nathanw Catch up to -current.
 1.4.2.1 09-Apr-2001  nathanw Catch up with -current.
 1.11.4.1 11-Oct-2001  fvdl Catch up with -current. Fix some bogons in the sparc64 kbd/ms
attach code. cd18xx conversion provided by mrg.
 1.11.2.2 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.11.2.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.12.4.2 18-Oct-2002  nathanw Catch up to -current.
 1.12.4.1 03-Oct-2001  nathanw file awacs.c was added on branch nathanw_sa on 2002-10-18 02:38:34 +0000
 1.18.2.5 17-Jan-2005  skrll Sync with HEAD.
 1.18.2.4 02-Nov-2004  skrll Sync with HEAD.
 1.18.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.18.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.18.2.1 03-Aug-2004  skrll Sync with HEAD
 1.21.2.2 09-Jan-2005  kent audio_hw_if change
* make open() and close() optional
* add int (AUMODE_PLAY or AUMODE_RECORD) and audio_params_t parameters
to round_blocksize()
 1.21.2.1 03-Jan-2005  kent adopt the filter pipeline framework
 1.23.10.4 15-Nov-2007  yamt sync with head.
 1.23.10.3 27-Oct-2007  yamt sync with head.
 1.23.10.2 03-Sep-2007  yamt sync with head.
 1.23.10.1 26-Feb-2007  yamt sync with head.
 1.24.20.1 01-Feb-2007  ad Sync with head.
 1.25.2.2 15-Apr-2007  yamt sync with head.
 1.25.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.26.6.1 29-Mar-2007  reinoud Pullup to -current
 1.26.4.1 11-Jul-2007  mjf Sync with head.
 1.26.2.6 03-Dec-2007  ad Sync with HEAD.
 1.26.2.5 03-Dec-2007  ad Sync with HEAD.
 1.26.2.4 23-Oct-2007  ad Sync with head.
 1.26.2.3 20-Aug-2007  ad Sync with HEAD.
 1.26.2.2 15-Jul-2007  ad Sync with head.
 1.26.2.1 10-Apr-2007  ad Sync with head.
 1.28.4.5 03-Oct-2007  garbled Sync with HEAD
 1.28.4.4 14-Aug-2007  macallan sync with HEAD
 1.28.4.3 02-Aug-2007  macallan sync with HEAD
 1.28.4.2 14-Jun-2007  macallan fix some bus_spacification fallout
 1.28.4.1 11-May-2007  macallan request the correct interrupt type in a couple drivers - necessary since
these days we actually do something with the type argument
 1.29.8.3 04-Nov-2007  jmcneill Sync with HEAD.
 1.29.8.2 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.29.8.1 16-Aug-2007  jmcneill Sync with HEAD.
 1.29.4.1 15-Aug-2007  skrll Sync with HEAD.
 1.30.6.2 13-Nov-2007  bouyer Sync with HEAD
 1.30.6.1 25-Oct-2007  bouyer Sync with HEAD.
 1.30.4.1 18-Oct-2007  yamt sync with head.
 1.30.2.1 06-Nov-2007  matt sync with HEAD
 1.33.22.2 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.33.22.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.33.20.3 09-Oct-2010  yamt sync with head
 1.33.20.2 11-Mar-2010  yamt sync with head
 1.33.20.1 04-May-2009  yamt sync with head.
 1.33.18.1 18-May-2008  yamt sync with head.
 1.33.16.2 28-Sep-2008  mjf Sync with HEAD.
 1.33.16.1 02-Jun-2008  mjf Sync with HEAD.
 1.34.4.1 19-Oct-2008  haad Sync with HEAD.
 1.35.4.1 06-Nov-2012  riz Pull up following revision(s) (requested by phx in ticket #1816):
sys/arch/macppc/dev/awacs.c: revision 1.43
My PowerMac3,1 is using gpio4 to detect a connected headphone, and I would bet
that the same is true for PowerMac3,2.
 1.36.4.1 05-Mar-2011  rmind sync with head
 1.36.2.1 22-Oct-2010  uebayasi Sync with HEAD (-D20101022).
 1.39.4.1 05-Mar-2011  bouyer Sync with HEAD
 1.39.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.40.6.2 22-Nov-2011  jmcneill get rid of unused 'powerstate' callback in audio_hw_if
 1.40.6.1 22-Nov-2011  macallan adapt to jmcneill-audiomp3
from mrg@, minor fixes and testing by me
 1.40.4.2 16-Jan-2013  yamt sync with (a bit old) head
 1.40.4.1 17-Apr-2012  yamt sync with head
 1.42.8.2 03-Dec-2017  jdolecek update from HEAD
 1.42.8.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.42.4.1 19-Nov-2012  riz Pull up following revision(s) (requested by phx in ticket #666):
sys/arch/macppc/dev/awacs.c: revision 1.43
My PowerMac3,1 is using gpio4 to detect a connected headphone, and I would bet
that the same is true for PowerMac3,2.
 1.43.18.1 26-Jul-2016  pgoyette Sync with HEAD
 1.43.14.1 05-Oct-2016  skrll Sync with HEAD
 1.45.16.1 10-Jun-2019  christos Sync with HEAD
 1.46.2.3 04-May-2019  isaki Move dev/audio_if.h -> dev/audio/audio_if.h
 1.46.2.2 24-Apr-2019  isaki Adapt to audio2.
- Some models don't have SLINEAR_LE but only SLINEAR_BE is enough.
 1.46.2.1 21-Apr-2019  isaki Use C99 style struct initializer to audio_format.
 1.48.10.1 03-Apr-2021  thorpej Sync with HEAD.
 1.15 26-Jul-2011  macallan finish device_t-ification
 1.14 10-Jul-2011  pgoyette Initialize sensor state. (Missed the commit for this in my last
roto-till.)
 1.13 01-Jul-2011  dyoung #include <sys/bus.h> instead of <machine/bus.h>.
 1.12 18-Jun-2011  matt struct device * -> device_t
struct cfdata * -> cfdata_t
use device accessors, use device_private.
some softc/device_t splits (macppc needs a bunch more)
aprint*_dev used considerably more
 1.11 23-Oct-2008  aymeric branches: 1.11.26;
pass the right sensor types so that the kernel doesn't panic() on my
iBook G3
 1.10 29-Apr-2008  martin branches: 1.10.6;
Convert to new 2 clause license
 1.9 30-Mar-2008  macallan branches: 1.9.2; 1.9.4;
actually update the 'battery present' sensor. Doh.
 1.8 12-Dec-2007  macallan branches: 1.8.6;
fix sensor attachment
 1.7 16-Nov-2007  xtraeme branches: 1.7.2; 1.7.4; 1.7.6;
Extend the envsys2 API (one more time, sorry) as defined in:

http://mail-index.netbsd.org/tech-kern/2007/11/09/0001.html

sysmon_envsys_create() and sysmon_envsys_destroy() were added to
create/destroy sysmon_envsys objects (and its TAILQ/LIST for sensors/events).

sysmon_envsys_sensor_attach() and sysmon_envsys_sensor_detach() were
added to attach/detach sensors to a specified sysmon_envsys device.

The events framework is now per device and configurable via the
ENVSYS_SETDICTIONARY ioctl or /etc/envsys.conf and envstat(8).

Update all users and documentation to reflect these changes.
 1.6 17-Oct-2007  garbled branches: 1.6.2;
Merge the ppcoea-renovation branch to HEAD.

This branch was a major cleanup and rototill of many of the various OEA
cpu based PPC ports that focused on sharing as much code as possible
between the various ports to eliminate near-identical copies of files in
every tree. Additionally there is a new PIC system that unifies the
interface to interrupt code for all different OEA ppc arches. The work
for this branch was done by a variety of people, too long to list here.

TODO:
bebox still needs work to complete the transition to -renovation.
ofppc still needs a bunch of work, which I will be looking at.
ev64260 still needs to be renovated
amigappc was not attempted.

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.5 16-Jul-2007  xtraeme branches: 1.5.8; 1.5.10; 1.5.12; 1.5.14;
battery_gtredata: there's no need to set ENVSYS_SVALID on each case,
just set it after the switch.
 1.4 05-Jul-2007  xtraeme - Adapt to envsys2.
- Use one Indicator sensor for battery charge and set it to 1 or 0
accordingly.
 1.3 09-May-2007  macallan add an optional callback from pmu's worker thread, use it to poll AC power
status on legacy batteries where we don't get environment interrupts. Also
report AC status changes to powerd.
 1.2 03-Apr-2007  macallan branches: 1.2.4;
adapt to pmu changes
 1.1 15-Feb-2007  macallan branches: 1.1.2; 1.1.4; 1.1.8; 1.1.10;
not quite complete yet driver for batteries found in ohare-based PowerBooks
no APM emulation or sysmon integration yet but some stuff is exposed via
envsys
 1.1.10.1 11-Jul-2007  mjf Sync with head.
 1.1.8.6 03-Dec-2007  ad Sync with HEAD.
 1.1.8.5 23-Oct-2007  ad Sync with head.
 1.1.8.4 20-Aug-2007  ad Sync with HEAD.
 1.1.8.3 15-Jul-2007  ad Sync with head.
 1.1.8.2 27-May-2007  ad Sync with head.
 1.1.8.1 10-Apr-2007  ad Sync with head.
 1.1.4.6 21-Jan-2008  yamt sync with head
 1.1.4.5 07-Dec-2007  yamt sync with head
 1.1.4.4 27-Oct-2007  yamt sync with head.
 1.1.4.3 03-Sep-2007  yamt sync with head.
 1.1.4.2 26-Feb-2007  yamt sync with head.
 1.1.4.1 15-Feb-2007  yamt file battery.c was added on branch yamt-lazymbuf on 2007-02-26 09:07:20 +0000
 1.1.2.2 17-May-2007  yamt sync with head.
 1.1.2.1 15-Apr-2007  yamt sync with head.
 1.2.4.5 03-Oct-2007  garbled Sync with HEAD
 1.2.4.4 02-Aug-2007  macallan sync with HEAD
 1.2.4.3 14-Jun-2007  macallan fix some bus_spacification fallout
 1.2.4.2 22-May-2007  matt Update to HEAD.
 1.2.4.1 09-May-2007  macallan sync with HEAD
 1.5.14.2 18-Nov-2007  bouyer Sync with HEAD
 1.5.14.1 25-Oct-2007  bouyer Sync with HEAD.
 1.5.12.1 18-Oct-2007  yamt sync with head.
 1.5.10.2 09-Jan-2008  matt sync with HEAD
 1.5.10.1 06-Nov-2007  matt sync with HEAD
 1.5.8.2 21-Nov-2007  joerg Sync with HEAD.
 1.5.8.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.6.2.2 27-Dec-2007  mjf Sync with HEAD.
 1.6.2.1 19-Nov-2007  mjf Sync with HEAD.
 1.7.6.1 13-Dec-2007  bouyer Sync with HEAD
 1.7.4.1 13-Dec-2007  yamt sync with head.
 1.7.2.1 26-Dec-2007  ad Sync with head.
 1.8.6.3 17-Jan-2009  mjf Sync with HEAD.
 1.8.6.2 02-Jun-2008  mjf Sync with HEAD.
 1.8.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.9.4.2 04-May-2009  yamt sync with head.
 1.9.4.1 16-May-2008  yamt sync with head.
 1.9.2.1 18-May-2008  yamt sync with head.
 1.10.6.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.11.26.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.4 16-Apr-2020  rin Revert previous for now:
http://mail-index.netbsd.org/source-changes/2020/04/16/msg116278.html

The reasoning turned out to be wrong; __KERNEL_RCSID() in header files
does *not* overwrite RCSID in main source files. The real problem is that
it inserts its RCSID into *every* object files. However, it can be still
useful even if heavily duplicated.
 1.3 16-Apr-2020  rin Stop using __KERNEL_RCSID() in header files; it confuses ident(1) by
overwriting RCSID in main source files.

XXX
The first argument of __KERNEL_RCSID() is neglected for ELF. If we wish
to have RCSID of header files in kernel binary, we need something like
__FBSDID() macro in FreeBSD.
 1.2 29-Apr-2008  martin branches: 1.2.98;
Convert to new 2 clause license
 1.1 15-Feb-2007  macallan branches: 1.1.4; 1.1.46; 1.1.48; 1.1.50;
not quite complete yet driver for batteries found in ohare-based PowerBooks
no APM emulation or sysmon integration yet but some stuff is exposed via
envsys
 1.1.50.1 16-May-2008  yamt sync with head.
 1.1.48.1 18-May-2008  yamt sync with head.
 1.1.46.1 02-Jun-2008  mjf Sync with HEAD.
 1.1.4.2 26-Feb-2007  yamt sync with head.
 1.1.4.1 15-Feb-2007  yamt file batteryvar.h was added on branch yamt-lazymbuf on 2007-02-26 09:07:20 +0000
 1.2.98.1 20-Apr-2020  bouyer Sync with HEAD
 1.7 05-Mar-2021  rin Convert to intr_establish_xname().
 1.6 08-Dec-2018  thorpej branches: 1.6.12;
Clean up initialization of com_regs structure, in preparation for
some additional changers.
 1.5 27-Oct-2012  chs branches: 1.5.36; 1.5.38;
split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.4 01-Jul-2011  dyoung branches: 1.4.2; 1.4.12;
#include <sys/bus.h> instead of <machine/bus.h>.
 1.3 14-Mar-2008  cube Split device_t and softc for all com(4) devices (well, everything that
uses a com_softc backend). Use proper types and ansify where appropriate.
 1.2 01-Sep-2006  matt branches: 1.2.4; 1.2.10; 1.2.36; 1.2.56; 1.2.60;
Make this compile. The "fixed" bus_space_tag_t is horrible.
 1.1 05-Aug-2006  sanjayl branches: 1.1.4;
1st cut of Powermac G5 support (uses bridge mode).
 1.1.4.3 03-Sep-2006  yamt sync with head.
 1.1.4.2 11-Aug-2006  yamt sync with head
 1.1.4.1 05-Aug-2006  yamt file com_mainbus.c was added on branch yamt-pdpolicy on 2006-08-11 15:42:13 +0000
 1.2.60.1 03-Apr-2008  mjf Sync with HEAD.
 1.2.56.1 24-Mar-2008  keiichi sync with head.
 1.2.36.1 23-Mar-2008  matt sync with HEAD
 1.2.10.3 17-Mar-2008  yamt sync with head.
 1.2.10.2 30-Dec-2006  yamt sync with head.
 1.2.10.1 01-Sep-2006  yamt file com_mainbus.c was added on branch yamt-lazymbuf on 2006-12-30 20:46:26 +0000
 1.2.4.2 09-Sep-2006  rpaulo sync with head
 1.2.4.1 01-Sep-2006  rpaulo file com_mainbus.c was added on branch rpaulo-netinet-merge-pcb on 2006-09-09 02:41:05 +0000
 1.4.12.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.4.2.1 30-Oct-2012  yamt sync with head
 1.5.38.1 10-Jun-2019  christos Sync with HEAD
 1.5.36.1 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.6.12.1 03-Apr-2021  thorpej Sync with HEAD.
 1.34 23-Sep-2025  thorpej Make the i2c_enumerate_deventries() callback a bit more generic so
it can also be used for the filtering function that macppc::cuda
and sandpoint need.
 1.33 22-Sep-2025  thorpej cuda's i2c children are not in the OF device tree. Rather than using
an i2c-child-devices array, provide a private i2c device enumeration
method by subclassing our devhandle and providing that to the iic
instance.
 1.32 15-Sep-2025  thorpej Encapsulate what's needed to attach an I2C bus into a iicbus_attach()
inline.
 1.31 07-Sep-2025  thorpej Change todr_chip_handle::cookie -> todr_chip_handle::todr_dev, and
make it a device_t. Upcoming functional changes will require the
device_t associated with a TODR device.

Change todr_chip_handle::bus_cookie -> todr_chip_handle::todr_devaux.
Nothing was using the old field, but I decided to keep it around just
in cause something needs it in the future.

And with these largely mechanical yet semantically meaningful changes,
thus spake the Oracle: "Welcome to NetBSD 11.99.2."
 1.30 06-Sep-2023  macallan yet another tsleep/wakeup -> cv_*
 1.29 07-Aug-2021  thorpej branches: 1.29.2;
Merge thorpej-cfargs2.
 1.28 24-Apr-2021  thorpej branches: 1.28.2; 1.28.8;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).
 1.27 05-Mar-2021  rin branches: 1.27.2;
Convert to intr_establish_xname().
 1.26 14-Jul-2020  martin branches: 1.26.2;
Adapt to new proplib API
 1.25 14-Jul-2020  martin Adapt to new proplib API
 1.24 22-Dec-2019  thorpej Cleanup i2c bus acquire / release, centralizing all of the logic into
iic_acquire_bus() / iic_release_bus(). "acquire" and "release" hooks
no longer need to be provided by back-end controller drivers (only if
they need special handling, e.g. powering on the i2c controller).
This results in the removal of a bunch of rendundant code from each
back-end controller driver.

Assert that we are not in hard interrupt context in iic_acquire_bus(),
iic_exec(), and iic_release_bus().
 1.23 03-Sep-2018  riastradh Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)
 1.22 22-Sep-2017  macallan branches: 1.22.2; 1.22.4;
direct configure i2c devices
 1.21 14-Feb-2016  chs zero the i2c_attach_args structure before filling it in.
fixes occasional crashes in iic_attach().
 1.20 13-Aug-2014  macallan branches: 1.20.2;
if we get garbage from the RTC try again a couple times
this seems to happen more frequently when the PRAM battery goes bad
 1.19 14-Mar-2014  mrg remove various set-but-unused variables.
 1.18 30-Jul-2013  joerg Strip redundant parenthesis.
 1.17 01-Jul-2011  dyoung branches: 1.17.2; 1.17.12; 1.17.16;
#include <sys/bus.h> instead of <machine/bus.h>.
 1.16 18-Jun-2011  matt struct device * -> device_t
struct cfdata * -> cfdata_t
use device accessors, use device_private.
some softc/device_t splits (macppc needs a bunch more)
aprint*_dev used considerably more
 1.15 12-Dec-2009  tsutsui branches: 1.15.10;
Remove `volatile' qualifier from argument types of
struct timeval passed to todr_gettime(9) and todr_settime(9).
We no longer have an ancient and volatile struct timeval `time'
global since we have switched to MI timercounter(9) on all port.

XXX1: some of these RTC drivers still assume 32bit time_t
XXX2: some of these should be rewritten to use todr_[gs]ettime_ymdhms()
XXX3: todr(9) man page doesn't mention todr_[gs]ettime_ymdhms()
 1.14 18-Mar-2009  cegger Ansify function definitions w/o arguments. Generated with sed.
 1.13 04-Feb-2009  pgoyette branches: 1.13.2;
Return error status if an attempt is made to use the quick_{read,write}
i2c protocols, since we don't (yet) know how to make the controller do it.
 1.12 11-Jan-2009  macallan fix format instead of casting wildly
 1.11 11-Jan-2009  christos don't truncate the print.
 1.10 11-Jan-2009  macallan deal with 64bit time_t
Noticed by Wojciech Galazka
 1.9 07-Dec-2008  tsutsui Fix attach messages. (extra colons, misplaced newline etc.)
 1.8 16-May-2008  macallan branches: 1.8.4; 1.8.6; 1.8.8;
struct device * -> device_t
 1.7 29-Apr-2008  martin branches: 1.7.2;
Convert to new 2 clause license
 1.6 06-Dec-2007  ad branches: 1.6.12; 1.6.14; 1.6.16;
lockmgr -> mutex
 1.5 07-Nov-2007  garbled branches: 1.5.2;
Convert macppc to shared ofw_autoconf.c. Compile tested only.
 1.4 17-Oct-2007  garbled branches: 1.4.2;
Merge the ppcoea-renovation branch to HEAD.

This branch was a major cleanup and rototill of many of the various OEA
cpu based PPC ports that focused on sharing as much code as possible
between the various ports to eliminate near-identical copies of files in
every tree. Additionally there is a new PIC system that unifies the
interface to interrupt code for all different OEA ppc arches. The work
for this branch was done by a variety of people, too long to list here.

TODO:
bebox still needs work to complete the transition to -renovation.
ofppc still needs a bunch of work, which I will be looking at.
ev64260 still needs to be renovated
amigappc was not attempted.

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.3 15-Feb-2007  macallan branches: 1.3.4; 1.3.8; 1.3.12; 1.3.16; 1.3.24; 1.3.26; 1.3.28; 1.3.30;
don't use IPL_HIGH
 1.2 05-Feb-2007  macallan - don't go CUDA_IDLE before calling message handlers, that way we force all
writes they might issue to be delayed which keeps us from deadlocking
- don't splhigh() in cuda_intr() - usually we're there already. Instead do
the splhigh()/splx() dance when we're polling
- remove some leftover debugging gunk
 1.1 17-Jan-2007  macallan branches: 1.1.2;
new drivers for pmu and cuda
 1.1.2.3 09-Feb-2007  ad Sync with HEAD.
 1.1.2.2 01-Feb-2007  ad Sync with head.
 1.1.2.1 17-Jan-2007  ad file cuda.c was added on branch newlock2 on 2007-02-01 08:48:07 +0000
 1.3.30.2 13-Nov-2007  bouyer Sync with HEAD
 1.3.30.1 25-Oct-2007  bouyer Sync with HEAD.
 1.3.28.1 18-Oct-2007  yamt sync with head.
 1.3.26.3 09-Jan-2008  matt sync with HEAD
 1.3.26.2 08-Nov-2007  matt sync with -HEAD
 1.3.26.1 06-Nov-2007  matt sync with HEAD
 1.3.24.3 09-Dec-2007  jmcneill Sync with HEAD.
 1.3.24.2 11-Nov-2007  joerg Sync with HEAD.
 1.3.24.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.3.16.2 02-Aug-2007  macallan these days we need to include pio.h for io macros
 1.3.16.1 11-May-2007  macallan request the correct interrupt type in a couple drivers - necessary since
these days we actually do something with the type argument
 1.3.12.1 09-Dec-2007  reinoud Pullup to HEAD
 1.3.8.2 03-Dec-2007  ad Sync with HEAD.
 1.3.8.1 23-Oct-2007  ad Sync with head.
 1.3.4.5 07-Dec-2007  yamt sync with head
 1.3.4.4 15-Nov-2007  yamt sync with head.
 1.3.4.3 27-Oct-2007  yamt sync with head.
 1.3.4.2 26-Feb-2007  yamt sync with head.
 1.3.4.1 15-Feb-2007  yamt file cuda.c was added on branch yamt-lazymbuf on 2007-02-26 09:07:20 +0000
 1.4.2.2 08-Dec-2007  mjf Sync with HEAD.
 1.4.2.1 19-Nov-2007  mjf Sync with HEAD.
 1.5.2.1 08-Dec-2007  ad Sync with head.
 1.6.16.3 11-Mar-2010  yamt sync with head
 1.6.16.2 04-May-2009  yamt sync with head.
 1.6.16.1 16-May-2008  yamt sync with head.
 1.6.14.1 18-May-2008  yamt sync with head.
 1.6.12.2 17-Jan-2009  mjf Sync with HEAD.
 1.6.12.1 02-Jun-2008  mjf Sync with HEAD.
 1.7.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.8.8.1 13-Dec-2008  bouyer Pull up following revision(s) (requested by tsutsui in ticket #182):
sys/arch/macppc/dev/cuda.c: revision 1.9
sys/arch/macppc/macppc/memory.c: revision 1.2
sys/arch/macppc/dev/zs.c: revision 1.48
Fix attach messages. (extra colons, misplaced newline etc.)
 1.8.6.3 28-Apr-2009  skrll Sync with HEAD.
 1.8.6.2 03-Mar-2009  skrll Sync with HEAD.
 1.8.6.1 19-Jan-2009  skrll Sync with HEAD.
 1.8.4.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.13.2.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.15.10.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.17.16.2 18-May-2014  rmind sync with head
 1.17.16.1 28-Aug-2013  rmind sync with head
 1.17.12.2 03-Dec-2017  jdolecek update from HEAD
 1.17.12.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.17.2.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.20.2.1 19-Mar-2016  skrll Sync with HEAD
 1.22.4.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.22.4.1 10-Jun-2019  christos Sync with HEAD
 1.22.2.1 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.26.2.1 03-Apr-2021  thorpej Sync with HEAD.
 1.27.2.2 02-Apr-2021  thorpej config_found_ia() -> config_found() w/ CFARG_IATTR.
 1.27.2.1 21-Mar-2021  thorpej Give config_found() the same variadic arguments treatment as
config_search(). This commit only adds the CFARG_EOL sentinel
to the existing config_found() calls. Conversion of config_found_sm_loc()
and config_found_ia() call sites will be in subsequent commits.
 1.28.8.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.28.2.2 08-May-2021  thorpej There are no more consumers of i2c attach args "cookie" and "cookietype",
so garbage-collect them.
 1.28.2.1 08-May-2021  thorpej Children of the "cuda" i2c controller don't appear in the OF device tree,
so we need to supply our own "i2c-enumerate-devices" method.
 1.29.2.6 13-Sep-2021  thorpej Move the i2c enumeration helpers to their own header file to detangle
it from reliance on "iic" being configured into the kernel.
 1.29.2.5 11-Sep-2021  thorpej Add a devhandle_subclass() helper function to simplify the common case
and use it. Improve some comments.
 1.29.2.4 11-Sep-2021  thorpej Remove some useless comments.
 1.29.2.3 11-Sep-2021  thorpej Use i2c_enumerate_deventries().
 1.29.2.2 10-Sep-2021  thorpej Remove unnecessary references to i2c_attach_args::ia_prop and mark the ones
that remain as XXX.
 1.29.2.1 09-Aug-2021  thorpej Port over the changes from thorpej-i2c-spi-conf to thorpej-i2c-spi-conf2,
which is based on a newer HEAD revision.
 1.5 16-Apr-2020  rin Revert previous for now:
http://mail-index.netbsd.org/source-changes/2020/04/16/msg116278.html

The reasoning turned out to be wrong; __KERNEL_RCSID() in header files
does *not* overwrite RCSID in main source files. The real problem is that
it inserts its RCSID into *every* object files. However, it can be still
useful even if heavily duplicated.
 1.4 16-Apr-2020  rin Stop using __KERNEL_RCSID() in header files; it confuses ident(1) by
overwriting RCSID in main source files.

XXX
The first argument of __KERNEL_RCSID() is neglected for ELF. If we wish
to have RCSID of header files in kernel binary, we need something like
__FBSDID() macro in FreeBSD.
 1.3 13-Aug-2014  macallan branches: 1.3.30;
add PRAM access commands
 1.2 29-Apr-2008  martin branches: 1.2.44;
Convert to new 2 clause license
 1.1 17-Jan-2007  macallan branches: 1.1.2; 1.1.6; 1.1.48; 1.1.50; 1.1.52;
new drivers for pmu and cuda
 1.1.52.1 16-May-2008  yamt sync with head.
 1.1.50.1 18-May-2008  yamt sync with head.
 1.1.48.1 02-Jun-2008  mjf Sync with HEAD.
 1.1.6.2 26-Feb-2007  yamt sync with head.
 1.1.6.1 17-Jan-2007  yamt file cudavar.h was added on branch yamt-lazymbuf on 2007-02-26 09:07:20 +0000
 1.1.2.2 01-Feb-2007  ad Sync with head.
 1.1.2.1 17-Jan-2007  ad file cudavar.h was added on branch newlock2 on 2007-02-01 08:48:07 +0000
 1.2.44.1 03-Dec-2017  jdolecek update from HEAD
 1.3.30.1 20-Apr-2020  bouyer Sync with HEAD
 1.10 22-Sep-2017  macallan no more special treatment for dbcool
 1.9 15-Sep-2017  macallan ki2c uses i2c addresses with the direction bit shifted out now, adjust
masking accordingly
 1.8 13-Dec-2011  riastradh branches: 1.8.6;
Match adm1030 too in dbcool_ki2c_match.

PR port-macppc/41916: dbcool at ki2c should support adm1030

ok macallan
 1.7 20-Dec-2010  matt branches: 1.7.8; 1.7.12;
Move counting of faults, traps, intrs, soft[intr]s, syscalls, and nswtch
from uvmexp to per-cpu cpu_data and move them to 64bits. Remove unneeded
includes of <uvm/uvm_extern.h> and/or <uvm/uvm.h>.
 1.6 05-Nov-2009  dyoung branches: 1.6.4;
Bring this up-to-date with the changes to dbcool_softc.
 1.5 02-Nov-2009  christos adjust to dbcool_chipset.
 1.4 14-Jan-2009  ahoka branches: 1.4.4;
The following patch makes dbcool(4) recognize the ADT7460 hardware in
the aluminium PowerBook G4 12". The hardware is very similar to
several other models, to the point that it cannot be distinguished by
its advertised device id and revision id, which are the same as the
ADT7463.

Patch from Taylor R Campbell.
 1.3 12-Oct-2008  pgoyette branches: 1.3.2; 1.3.4; 1.3.6;
Move the {read,write}reg() routine addresses into the dbcool_softc so
that we can use different routines for macppc's ki2c attachment. Fixes
problems reported by Robert Fritzsche on current-users@ list.
 1.2 09-Oct-2008  pgoyette branches: 1.2.2;
sc->sc_parent was removed because it was never used, so don't bother
trying to set it.
 1.1 02-Oct-2008  pgoyette branches: 1.1.2;
Add dbcool ki2c attachment for macppc
 1.1.2.3 17-Jan-2009  mjf Sync with HEAD.
 1.1.2.2 05-Oct-2008  mjf Sync with HEAD.
 1.1.2.1 02-Oct-2008  mjf file dbcool_ki2c.c was added on branch mjf-devfs2 on 2008-10-05 20:11:26 +0000
 1.2.2.2 10-Oct-2008  skrll Sync with HEAD.
 1.2.2.1 09-Oct-2008  skrll file dbcool_ki2c.c was added on branch wrstuden-revivesa on 2008-10-10 22:29:05 +0000
 1.3.6.1 16-Jan-2009  bouyer Pull up following revision(s) (requested by ahoka in ticket #264):
sys/arch/macppc/dev/dbcool_ki2c.c: revision 1.4
The following patch makes dbcool(4) recognize the ADT7460 hardware in
the aluminium PowerBook G4 12". The hardware is very similar to
several other models, to the point that it cannot be distinguished by
its advertised device id and revision id, which are the same as the
ADT7463.
Patch from Taylor R Campbell.
 1.3.4.1 19-Jan-2009  skrll Sync with HEAD.
 1.3.2.2 19-Oct-2008  haad Sync with HEAD.
 1.3.2.1 12-Oct-2008  haad file dbcool_ki2c.c was added on branch haad-dm on 2008-10-19 22:15:51 +0000
 1.4.4.3 11-Mar-2010  yamt sync with head
 1.4.4.2 04-May-2009  yamt sync with head.
 1.4.4.1 14-Jan-2009  yamt file dbcool_ki2c.c was added on branch yamt-nfs-mp on 2009-05-04 08:11:28 +0000
 1.6.4.1 05-Mar-2011  rmind sync with head
 1.7.12.1 18-Feb-2012  mrg merge to -current.
 1.7.8.1 17-Apr-2012  yamt sync with head
 1.8.6.1 03-Dec-2017  jdolecek update from HEAD
 1.12 15-Jul-2016  macallan first step to make dbdma less hackish
- dbdma_alloc gets a new parameter to return the actual address of the
buffer before being alignment-mangled so we can properly free it
- add dbdma_free which takes the pointer mentioned above
dbdma should really use bus_dma
 1.11 23-May-2012  macallan branches: 1.11.2; 1.11.16; 1.11.20;
malloc -> kmem_alloc
 1.10 14-Nov-2010  uebayasi branches: 1.10.8; 1.10.12;
Direct/indirect uses of sys/device.h and prop/proplib.h.
 1.9 14-Mar-2009  dsl branches: 1.9.4;
Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.8 17-Oct-2007  garbled branches: 1.8.20; 1.8.28; 1.8.34;
Merge the ppcoea-renovation branch to HEAD.

This branch was a major cleanup and rototill of many of the various OEA
cpu based PPC ports that focused on sharing as much code as possible
between the various ports to eliminate near-identical copies of files in
every tree. Additionally there is a new PIC system that unifies the
interface to interrupt code for all different OEA ppc arches. The work
for this branch was done by a variety of people, too long to list here.

TODO:
bebox still needs work to complete the transition to -renovation.
ofppc still needs a bunch of work, which I will be looking at.
ev64260 still needs to be renovated
amigappc was not attempted.

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.7 24-Dec-2005  perry branches: 1.7.30; 1.7.38; 1.7.48; 1.7.50; 1.7.52; 1.7.54;
__asm__ -> __asm
__const__ -> const
__inline__ -> inline
__volatile__ -> volatile
 1.6 11-Dec-2005  christos merge ktrace-lwp.
 1.5 15-Jul-2003  lukem branches: 1.5.16;
__KERNEL_RCSID()
 1.4 08-Jun-2001  matt branches: 1.4.8; 1.4.24;
Make macppc compile by default with -Wall -Wmissing-prototype in addition
to its currently enabled warnings. For the lack of a better place, most
global function prototype wound up in <machine/autoconf.h> unless there
was a better place for them. ofb_* structs renamed to offb_* to avoid
conflict with ofb_softc in <dev/ofw/openfirm.h>
 1.3 29-Jun-2000  mrg branches: 1.3.2;
remove include of <vm/vm.h>. <vm/vm.h> -> <uvm/uvm_extern.h>
 1.2 21-Aug-1998  tsubai branches: 1.2.12;
vm_offset_t --> [pv]addr_t.
 1.1 15-May-1998  tsubai Initial import of macppc port.
 1.2.12.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.3.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.4.24.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.4.24.2 18-Sep-2004  skrll Sync with HEAD.
 1.4.24.1 03-Aug-2004  skrll Sync with HEAD
 1.4.8.2 08-Jun-2001  matt Make macppc compile by default with -Wall -Wmissing-prototype in addition
to its currently enabled warnings. For the lack of a better place, most
global function prototype wound up in <machine/autoconf.h> unless there
was a better place for them. ofb_* structs renamed to offb_* to avoid
conflict with ofb_softc in <dev/ofw/openfirm.h>
 1.4.8.1 08-Jun-2001  matt file dbdma.c was added on branch nathanw_sa on 2001-06-08 00:32:03 +0000
 1.5.16.2 27-Oct-2007  yamt sync with head.
 1.5.16.1 21-Jun-2006  yamt sync with head.
 1.7.54.1 25-Oct-2007  bouyer Sync with HEAD.
 1.7.52.1 18-Oct-2007  yamt sync with head.
 1.7.50.1 06-Nov-2007  matt sync with HEAD
 1.7.48.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.7.38.1 07-Jun-2007  garbled Convert macppc to powerpc bus_space. Lots of work here from Matt Thomas,
as well as the common ofwoea code from myself. Compile tested only,
still probably needs some fine tuning.

Also in this commit:
Convert macppc to new shared ofwoea routines.
Lots of KNF.
 1.7.30.1 23-Oct-2007  ad Sync with head.
 1.8.34.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.8.28.1 28-Apr-2009  skrll Sync with HEAD.
 1.8.20.1 04-May-2009  yamt sync with head.
 1.9.4.1 05-Mar-2011  rmind sync with head
 1.10.12.1 02-Jun-2012  mrg sync to latest -current.
 1.10.8.1 30-Oct-2012  yamt sync with head
 1.11.20.1 26-Jul-2016  pgoyette Sync with HEAD
 1.11.16.1 05-Oct-2016  skrll Sync with HEAD
 1.11.2.1 03-Dec-2017  jdolecek update from HEAD
 1.6 15-Jul-2016  macallan first step to make dbdma less hackish
- dbdma_alloc gets a new parameter to return the actual address of the
buffer before being alignment-mangled so we can properly free it
- add dbdma_free which takes the pointer mentioned above
dbdma should really use bus_dma
 1.5 17-Oct-2007  garbled branches: 1.5.64; 1.5.84; 1.5.88;
Merge the ppcoea-renovation branch to HEAD.

This branch was a major cleanup and rototill of many of the various OEA
cpu based PPC ports that focused on sharing as much code as possible
between the various ports to eliminate near-identical copies of files in
every tree. Additionally there is a new PIC system that unifies the
interface to interrupt code for all different OEA ppc arches. The work
for this branch was done by a variety of people, too long to list here.

TODO:
bebox still needs work to complete the transition to -renovation.
ofppc still needs a bunch of work, which I will be looking at.
ev64260 still needs to be renovated
amigappc was not attempted.

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.4 24-Dec-2005  perry branches: 1.4.30; 1.4.38; 1.4.48; 1.4.50; 1.4.52; 1.4.54;
__asm__ -> __asm
__const__ -> const
__inline__ -> inline
__volatile__ -> volatile
 1.3 19-Jun-2001  simonb branches: 1.3.8; 1.3.40;
Add/change prototypes so that macpcc builds with -Wstrict-prototypes.
 1.2 21-Aug-1998  tsubai branches: 1.2.24;
vm_offset_t --> [pv]addr_t.
 1.1 15-May-1998  tsubai Initial import of macppc port.
 1.2.24.1 21-Jun-2001  nathanw Catch up to -current.
 1.3.40.2 27-Oct-2007  yamt sync with head.
 1.3.40.1 21-Jun-2006  yamt sync with head.
 1.3.8.2 19-Jun-2001  simonb Add/change prototypes so that macpcc builds with -Wstrict-prototypes.
 1.3.8.1 19-Jun-2001  simonb file dbdma.h was added on branch nathanw_sa on 2001-06-19 12:02:57 +0000
 1.4.54.1 25-Oct-2007  bouyer Sync with HEAD.
 1.4.52.1 18-Oct-2007  yamt sync with head.
 1.4.50.1 06-Nov-2007  matt sync with HEAD
 1.4.48.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.4.38.1 07-Jun-2007  garbled Convert macppc to powerpc bus_space. Lots of work here from Matt Thomas,
as well as the common ofwoea code from myself. Compile tested only,
still probably needs some fine tuning.

Also in this commit:
Convert macppc to new shared ofwoea routines.
Lots of KNF.
 1.4.30.1 23-Oct-2007  ad Sync with head.
 1.5.88.1 26-Jul-2016  pgoyette Sync with HEAD
 1.5.84.1 05-Oct-2016  skrll Sync with HEAD
 1.5.64.1 03-Dec-2017  jdolecek update from HEAD
 1.22 17-Sep-2025  thorpej Don't get the OF phandle from i2c_attach_args::ia_cookie; get it from
self's devhandle.
 1.21 20-Dec-2023  thorpej Remove unnecessary <sys/malloc.h>.
 1.20 27-Jan-2021  thorpej branches: 1.20.4; 1.20.14;
Use DEVICE_COMPAT_EOL.
 1.19 25-Jan-2021  thorpej Since we're using designated initialisers for compat data, we should
use a completely empty initializer for the sentinel.
 1.18 17-Jan-2021  thorpej Use designated initializers and a consistent termination style in
compat_data[].
 1.17 20-Sep-2019  macallan branches: 1.17.8;
identify TAS3001 from i2c address if there is no 'compatible' property
 1.16 26-Jun-2018  thorpej branches: 1.16.2;
In my quest to make device_compatible_entry (and associated goo)
super-general, it turns out I also made it a little to cumbersome
to use (if my tired fingers are any indication). So, this is a
course-correction -- one string per entry (like of_compat_data,
which it will soon replace), and remove the over-verbose macros.
 1.15 18-Jun-2018  thorpej - Rename iic_compat_match() to iic_compatible_match() and change it
to use the new device_compatible_match() routine. A pointer to
the matching device_compatible_entry is returned if a match is
found.
- Adjust iic_use_direct_match() accordingly.
- i2c drivers now provide device_compatible_entry tables when performing
direct-config matching.
- In the dsrtc driver, take advantage of this new capability to greatly
simplify model selection.

(I'm coming for you next, of_compat_data...)
 1.14 16-Jun-2018  thorpej More cleanup to i2c autoconfiguration:

- Get all of the drivers onto the new match quality constants.
- Introduce a new helper function, iic_use_direct_match(), that has
all of the logic for direct-config matching. If it returns true,
the driver returns the match result (which may be 0). If it returns
false, the driver does indirect-config matching.
- iic_compat_match() now returns a weighted match quality; matches to
lower-indexed "compatible" device property are more-specific matches,
and return a better match quality accordingly.
 1.13 04-May-2018  macallan don't cut off upper bits in the i2c address, ki2c knows how to deal with
them now
 1.12 27-Sep-2017  macallan branches: 1.12.2;
if there is no 'compatible' property try to guess the codec from the i2c
address
 1.11 27-Sep-2017  macallan identify as 'Audio Codec' and print out which codec we found
 1.10 22-Sep-2017  macallan attach to iic, use direct config
 1.9 15-Sep-2017  macallan ki2c uses i2c addresses with the direction bit shifted out now, adjust
masking accordingly
 1.8 20-Dec-2010  matt branches: 1.8.18;
Move counting of faults, traps, intrs, soft[intr]s, syscalls, and nswtch
from uvmexp to per-cpu cpu_data and move them to 64bits. Remove unneeded
includes of <uvm/uvm_extern.h> and/or <uvm/uvm.h>.
 1.7 15-Oct-2010  phx Make it match the TAS3004 "codec" node, which is found on newer PowerBook G4s
(PowerBook5,6).
 1.6 14-Mar-2009  dsl branches: 1.6.2; 1.6.4;
ANSIfy another 1261 function definitions.
The only ones left in sys are beyond by sed script!
(or in sys/dist or sys/external)
Mostly they have function pointer parameters.
 1.5 14-Mar-2009  dsl Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.4 16-May-2008  macallan branches: 1.4.6; 1.4.12;
struct device * -> device_t
 1.3 17-Jan-2007  macallan branches: 1.3.44; 1.3.46; 1.3.48; 1.3.50;
prefix a hexadecimal address with 0x
 1.2 11-Dec-2005  christos branches: 1.2.18; 1.2.22;
merge ktrace-lwp.
 1.1 10-Aug-2005  macallan branches: 1.1.6;
dummy driver to represent the deq node in OF, marks the equalizer/mixer chip used by snapper
 1.1.6.2 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.1.6.1 10-Aug-2005  skrll file deq.c was added on branch ktrace-lwp on 2005-11-10 13:57:27 +0000
 1.2.22.1 01-Feb-2007  ad Sync with head.
 1.2.18.3 26-Feb-2007  yamt sync with head.
 1.2.18.2 21-Jun-2006  yamt sync with head.
 1.2.18.1 11-Dec-2005  yamt file deq.c was added on branch yamt-lazymbuf on 2006-06-21 14:53:13 +0000
 1.3.50.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.3.48.1 04-May-2009  yamt sync with head.
 1.3.46.1 18-May-2008  yamt sync with head.
 1.3.44.1 02-Jun-2008  mjf Sync with HEAD.
 1.4.12.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.4.6.1 28-Apr-2009  skrll Sync with HEAD.
 1.6.4.1 05-Mar-2011  rmind sync with head
 1.6.2.1 22-Oct-2010  uebayasi Sync with HEAD (-D20101022).
 1.8.18.1 03-Dec-2017  jdolecek update from HEAD
 1.12.2.3 28-Jul-2018  pgoyette Sync with HEAD
 1.12.2.2 25-Jun-2018  pgoyette Sync with HEAD
 1.12.2.1 21-May-2018  pgoyette Sync with HEAD
 1.16.2.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.17.8.1 03-Apr-2021  thorpej Sync with HEAD.
 1.20.14.1 09-Aug-2021  thorpej Port over the changes from thorpej-i2c-spi-conf to thorpej-i2c-spi-conf2,
which is based on a newer HEAD revision.
 1.20.4.1 09-May-2021  thorpej ia->ia_cookie -> devhandle_to_of(device_handle(self))
 1.5 16-Apr-2020  rin Revert previous for now:
http://mail-index.netbsd.org/source-changes/2020/04/16/msg116278.html

The reasoning turned out to be wrong; __KERNEL_RCSID() in header files
does *not* overwrite RCSID in main source files. The real problem is that
it inserts its RCSID into *every* object files. However, it can be still
useful even if heavily duplicated.
 1.4 16-Apr-2020  rin Stop using __KERNEL_RCSID() in header files; it confuses ident(1) by
overwriting RCSID in main source files.

XXX
The first argument of __KERNEL_RCSID() is neglected for ELF. If we wish
to have RCSID of header files in kernel binary, we need something like
__FBSDID() macro in FreeBSD.
 1.3 16-May-2008  macallan branches: 1.3.96;
struct device * -> device_t
 1.2 11-Dec-2005  christos branches: 1.2.18; 1.2.76; 1.2.78; 1.2.80; 1.2.82;
merge ktrace-lwp.
 1.1 10-Aug-2005  macallan branches: 1.1.6;
dummy driver to represent the deq node in OF, marks the equalizer/mixer chip used by snapper
 1.1.6.2 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.1.6.1 10-Aug-2005  skrll file deqvar.h was added on branch ktrace-lwp on 2005-11-10 13:57:27 +0000
 1.2.82.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.2.80.1 04-May-2009  yamt sync with head.
 1.2.78.1 18-May-2008  yamt sync with head.
 1.2.76.1 02-Jun-2008  mjf Sync with HEAD.
 1.2.18.2 21-Jun-2006  yamt sync with head.
 1.2.18.1 11-Dec-2005  yamt file deqvar.h was added on branch yamt-lazymbuf on 2006-06-21 14:53:13 +0000
 1.3.96.1 20-Apr-2020  bouyer Sync with HEAD
 1.4 18-Aug-2025  macallan mave sysctl tree to hw.
 1.3 13-Aug-2025  macallan try not to read the input register more than once er second - they're not
expected to change very fast and it avoids excessive, slow reads triggered by
sysctl machdep
 1.2 12-Aug-2025  macallan add sysctl to show the status of the drive module's handle switch - 1 indicates
that the handle is pushed in
while there mark switch and present as read only
 1.1 12-Aug-2025  macallan a driver to control the Xserve G4's drive bays, it will:
- tell you if a drive module is present
- let you control LEDs and drive power
via sysctl machdep.drivebay*
 1.35 02-Jun-2024  andvar s/interuppts/interrupts/ and s/intruppts/interrupts/ in comment and log message.
 1.34 20-Dec-2023  thorpej Remove unnecessary <sys/malloc.h>.
 1.33 05-Mar-2021  rin Convert to intr_establish_xname().
 1.32 15-Jul-2016  macallan branches: 1.32.28;
adjust to dbdma changes
 1.31 30-Jun-2011  matt branches: 1.31.12; 1.31.30; 1.31.34;
Modify mapiodev to take a third argument indicating whether the space
should be prefetchable (true) or not (false).
 1.30 20-Dec-2010  matt Move counting of faults, traps, intrs, soft[intr]s, syscalls, and nswtch
from uvmexp to per-cpu cpu_data and move them to 64bits. Remove unneeded
includes of <uvm/uvm_extern.h> and/or <uvm/uvm.h>.
 1.29 27-Nov-2009  rmind branches: 1.29.4;
- Use uvm_lwp_setuarea() instead of directly setting address to lwp_t::l_addr.
- Replace most remaining uses of l_addr with uvm_lwp_getuarea() or lwp_getpcb().
- Amend assembly in ports where it accesses PCB via struct user.
- Rename L_ADDR to L_PCB in few places. Reduce sys/user.h inclusions.
 1.28 26-Sep-2009  tsutsui Make local functions static.
 1.27 26-Sep-2009  tsutsui Replace shutdownhook_establish(9) with pmf_device_register1(9).
Compile test only, but similar to mesh.c.
 1.26 16-Dec-2008  christos replace bitmask_snprintf(9) with snprintb(3)
 1.25 28-Apr-2008  martin branches: 1.25.8;
Remove clause 3 and 4 from TNF licenses
 1.24 13-Apr-2008  tsutsui branches: 1.24.2; 1.24.4;
Split device_t/softc for MI ncr53c9x and some related devices,
with various cleanup.
 1.23 17-Oct-2007  garbled branches: 1.23.16;
Merge the ppcoea-renovation branch to HEAD.

This branch was a major cleanup and rototill of many of the various OEA
cpu based PPC ports that focused on sharing as much code as possible
between the various ports to eliminate near-identical copies of files in
every tree. Additionally there is a new PIC system that unifies the
interface to interrupt code for all different OEA ppc arches. The work
for this branch was done by a variety of people, too long to list here.

TODO:
bebox still needs work to complete the transition to -renovation.
ofppc still needs a bunch of work, which I will be looking at.
ev64260 still needs to be renovated
amigappc was not attempted.

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.22 05-Mar-2007  tsutsui branches: 1.22.2; 1.22.10; 1.22.18; 1.22.20; 1.22.22; 1.22.24;
Use (char *) cast on pointer arith.
 1.21 04-Mar-2007  christos Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.20 08-Mar-2006  lukem branches: 1.20.16;
Use the SI capitalization for "Hz", "kHz", and "MHz" in comments and strings.
Add a space between numbers and Hz unit.
 1.19 11-Dec-2005  christos branches: 1.19.4; 1.19.6; 1.19.8; 1.19.10;
merge ktrace-lwp.
 1.18 15-Jul-2003  lukem branches: 1.18.16;
__KERNEL_RCSID()
 1.17 03-May-2003  wiz branches: 1.17.2;
DMA, not dma nor Dma.
 1.16 02-Apr-2003  thorpej Use PAGE_SIZE rather than NBPG.
 1.15 02-Oct-2002  thorpej Use CFATTACH_DECL().
 1.14 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.13 25-Apr-2001  bouyer branches: 1.13.2; 1.13.8;
Pull up the thorpej_scsipi branch to main branch.
This is a completely rewritten scsipi_xfer execution engine, and the
associated changes to HBA drivers. Overview of changes & features:
- All xfers are queued in the mid-layer, rather than doing so in an
ad-hoc fashion in individual adapter drivers.
- Adapter/channel resource management in the mid-layer, avoids even trying
to start running an xfer if the adapter/channel doesn't have the resources.
- Better communication between the mid-layer and the adapters.
- Asynchronous event notification mechanism from adapter to mid-layer and
peripherals.
- Better peripheral queue management: freeze/thaw, sorted requeueing during
recovery, etc.
- Clean separation of peripherals, adapters, and adapter channels (no more
scsipi_link).
- Kernel thread for each scsipi_channel makes error recovery much easier
(no more dealing with interrupt context when recovering from an error).
- Mid-layer support for tagged queueing: commands can have the tag type
set explicitly, tag IDs are allocated in the mid-layer (thus eliminating
the need to use buggy tag ID allocation schemes in many adapter drivers).
- support for QUEUE FULL and CHECK CONDITION status in mid-layer; the command
will be requeued, or a REQUEST SENSE will be sent as appropriate.

Just before the merge syssrc has been tagged with thorpej_scsipi_beforemerge
 1.12 29-Mar-2001  petrov use NCR_F_DMASELECT instead of ncr53c9x_dmaselect
 1.11 26-Jun-2000  mrg branches: 1.11.2;
<vm/vm_param.h> -> <uvm/uvm_param.h>
 1.10 05-Jun-2000  nisimura Have MI ncr53c9x_attach() the 2nd and 3rd arguments for scsipi_adater
and scsipi_device respectively, with size reduction of ncr53c9x_softc.
Specifying NULL instructs the driver to use default adapter and default
device codes. Every target port has ncr53c9x_attach(sc, NULL, NULL) anyway.
 1.9 19-Nov-1998  thorpej branches: 1.9.10; 1.9.18;
Adapt to the new scsipi_adapter interface.
 1.8 10-Oct-1998  thorpej Garbage-collect the open_target_lu and close_target_lu entry points from
struct scsipi_adapter; they were not used.

Add a scsipi_ioctl entry point to struct scsipi_adapter. This will be
used to issue ioctl commands to the host adapters.

Inspired by PR #6090, from Matt Jacob.
 1.7 05-Sep-1998  pk Relinquish my copyright claims on this file.
 1.6 15-Aug-1998  mycroft Minor edit.
 1.5 15-Aug-1998  mycroft Assign copyright to TNF.
 1.4 19-Jun-1998  tsubai Move shutdownhook_establish before the attachment of common parts.
 1.3 05-Jun-1998  tsubai Add support for UVM and MACHINE_NEW_NONCONTIG.
 1.2 30-May-1998  tsubai Remove unnecessary cache flush.
 1.1 15-May-1998  tsubai Initial import of macppc port.
 1.9.18.1 22-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.9.10.3 21-Apr-2001  bouyer Sync with HEAD
 1.9.10.2 29-Mar-2001  bouyer Pass compile-test on i386
 1.9.10.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.11.2.2 21-Jun-2001  nathanw Catch up to -current.
 1.11.2.1 09-Apr-2001  nathanw Catch up with -current.
 1.13.8.2 18-Oct-2002  nathanw Catch up to -current.
 1.13.8.1 25-Apr-2001  nathanw file esp.c was added on branch nathanw_sa on 2002-10-18 02:38:34 +0000
 1.13.2.1 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.17.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.17.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.17.2.1 03-Aug-2004  skrll Sync with HEAD
 1.18.16.3 27-Oct-2007  yamt sync with head.
 1.18.16.2 03-Sep-2007  yamt sync with head.
 1.18.16.1 21-Jun-2006  yamt sync with head.
 1.19.10.1 19-Apr-2006  elad sync with head - hopefully this will work
 1.19.8.1 13-Mar-2006  yamt sync with head.
 1.19.6.1 22-Apr-2006  simonb Sync with head.
 1.19.4.1 09-Sep-2006  rpaulo sync with head
 1.20.16.1 12-Mar-2007  rmind Sync with HEAD.
 1.22.24.1 25-Oct-2007  bouyer Sync with HEAD.
 1.22.22.1 18-Oct-2007  yamt sync with head.
 1.22.20.1 06-Nov-2007  matt sync with HEAD
 1.22.18.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.22.10.1 11-May-2007  macallan request the correct interrupt type in a couple drivers - necessary since
these days we actually do something with the type argument
 1.22.2.1 23-Oct-2007  ad Sync with head.
 1.23.16.2 17-Jan-2009  mjf Sync with HEAD.
 1.23.16.1 02-Jun-2008  mjf Sync with HEAD.
 1.24.4.3 11-Mar-2010  yamt sync with head
 1.24.4.2 04-May-2009  yamt sync with head.
 1.24.4.1 16-May-2008  yamt sync with head.
 1.24.2.1 18-May-2008  yamt sync with head.
 1.25.8.1 19-Jan-2009  skrll Sync with HEAD.
 1.29.4.1 05-Mar-2011  rmind sync with head
 1.31.34.1 26-Jul-2016  pgoyette Sync with HEAD
 1.31.30.1 05-Oct-2016  skrll Sync with HEAD
 1.31.12.1 03-Dec-2017  jdolecek update from HEAD
 1.32.28.1 03-Apr-2021  thorpej Sync with HEAD.
 1.4 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.3 13-Apr-2008  tsutsui branches: 1.3.2; 1.3.4;
Split device_t/softc for MI ncr53c9x and some related devices,
with various cleanup.
 1.2 04-Mar-2007  christos branches: 1.2.40;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.1 15-May-1998  tsubai branches: 1.1.64; 1.1.102;
Initial import of macppc port.
 1.1.102.1 12-Mar-2007  rmind Sync with HEAD.
 1.1.64.1 03-Sep-2007  yamt sync with head.
 1.2.40.1 02-Jun-2008  mjf Sync with HEAD.
 1.3.4.1 16-May-2008  yamt sync with head.
 1.3.2.1 18-May-2008  yamt sync with head.
 1.3 30-Jul-2021  macallan branches: 1.3.4;
make thermal zone parameters configurable by sysctl
 1.2 28-Jul-2021  macallan adjust comments, break a long line
NFC
 1.1 27-Jul-2021  macallan first step towards abstracting thermal zone management out of the fcu driver
( and eventually, the smu driver )
todo:
- add sysctl()s to set zone parameters
- handle envsys
- adapt smu
 1.3.4.2 01-Aug-2021  thorpej Sync with HEAD.
 1.3.4.1 30-Jul-2021  thorpej file fancontrol.c was added on branch thorpej-i2c-spi-conf on 2021-08-01 22:42:12 +0000
 1.2 30-Jul-2021  macallan branches: 1.2.4;
make thermal zone parameters configurable by sysctl
 1.1 27-Jul-2021  macallan first step towards abstracting thermal zone management out of the fcu driver
( and eventually, the smu driver )
todo:
- add sysctl()s to set zone parameters
- handle envsys
- adapt smu
 1.2.4.2 01-Aug-2021  thorpej Sync with HEAD.
 1.2.4.1 30-Jul-2021  thorpej file fancontrolvar.h was added on branch thorpej-i2c-spi-conf on 2021-08-01 22:42:12 +0000
 1.7 17-Sep-2025  thorpej Don't get the OF phandle from i2c_attach_args::ia_cookie; get it from
self's devhandle.
 1.6 01-Jul-2025  macallan deal with sensor encoding on older G5
now we have working fan control on PowerMac7,2
 1.5 08-Apr-2022  andvar branches: 1.5.10;
fix various typos, mainly in comments, but also log messages, docs, game text.
 1.4 30-Jul-2021  macallan branches: 1.4.4; 1.4.8;
make thermal zone parameters configurable by sysctl
 1.3 28-Jul-2021  macallan check temperatures a bit more often
while there, explain why the delay is variable
 1.2 27-Jul-2021  macallan first step towards abstracting thermal zone management out of the fcu driver
( and eventually, the smu driver )
todo:
- add sysctl()s to set zone parameters
- handle envsys
- adapt smu
 1.1 27-Jul-2021  macallan move the fcu driver into arch/macppc where it belongs
 1.4.8.1 09-Aug-2021  thorpej Adapt to thorpej-i2c-spi-conf2: ia->ia_cookie is gone.
 1.4.4.2 01-Aug-2021  thorpej Sync with HEAD.
 1.4.4.1 30-Jul-2021  thorpej file fcu.c was added on branch thorpej-i2c-spi-conf on 2021-08-01 22:42:12 +0000
 1.5.10.1 02-Aug-2025  perseant Sync with HEAD
 1.2 28-Mar-1999  tsubai Remove unused files.
 1.1 15-May-1998  tsubai Initial import of macppc port.
 1.17 20-Dec-2023  thorpej Remove unnecessary <sys/malloc.h>.
 1.16 22-Jan-2022  thorpej Change the devhandle_from_*() functions to also take a "super handle",
from which the newly created handle will inherit it's implementation.
The root implementation for a new handle type is used if an invalid
"super handle" is passed.
 1.15 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.14 24-Apr-2021  thorpej branches: 1.14.8;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).
 1.13 05-Mar-2021  rin branches: 1.13.2;
Convert to intr_establish_xname().
 1.12 27-Oct-2012  chs branches: 1.12.50;
split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.11 30-Jun-2011  matt branches: 1.11.2; 1.11.12;
Modify mapiodev to take a third argument indicating whether the space
should be prefetchable (true) or not (false).
 1.10 18-Jun-2011  matt struct device * -> device_t
struct cfdata * -> cfdata_t
use device accessors, use device_private.
some softc/device_t splits (macppc needs a bunch more)
aprint*_dev used considerably more
 1.9 13-Jun-2008  cegger branches: 1.9.28;
use device_lookup_private to get softc
 1.8 11-Dec-2005  christos branches: 1.8.74; 1.8.76; 1.8.78; 1.8.80; 1.8.82;
merge ktrace-lwp.
 1.7 15-Jul-2003  lukem __KERNEL_RCSID()
 1.6 01-Jan-2003  thorpej branches: 1.6.2;
Use aprint_normal() for cfprint routines.
 1.5 02-Oct-2002  thorpej Use CFATTACH_DECL().
 1.4 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.3 19-Jun-2001  simonb branches: 1.3.2; 1.3.8;
Add/change prototypes so that macpcc builds with -Wstrict-prototypes.
 1.2 27-Feb-2001  matt branches: 1.2.2; 1.2.4;
Be a bit more defensive.
 1.1 27-Feb-2001  matt Add a gpio device to handle the gpio device & extint-gpio1
interrupt. (think ibook/powerbook)
 1.2.4.2 12-Mar-2001  bouyer Sync with HEAD.
 1.2.4.1 27-Feb-2001  bouyer file gpio.c was added on branch thorpej_scsipi on 2001-03-12 13:29:00 +0000
 1.2.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.3.8.3 03-Jan-2003  thorpej Sync with HEAD.
 1.3.8.2 18-Oct-2002  nathanw Catch up to -current.
 1.3.8.1 19-Jun-2001  nathanw file gpio.c was added on branch nathanw_sa on 2002-10-18 02:38:34 +0000
 1.3.2.1 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.6.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.6.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.6.2.1 03-Aug-2004  skrll Sync with HEAD
 1.8.82.1 18-Jun-2008  simonb Sync with head.
 1.8.80.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.8.78.1 04-May-2009  yamt sync with head.
 1.8.76.1 17-Jun-2008  yamt sync with head.
 1.8.74.1 29-Jun-2008  mjf Sync with HEAD.
 1.9.28.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.11.12.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.11.2.1 30-Oct-2012  yamt sync with head
 1.12.50.1 03-Apr-2021  thorpej Sync with HEAD.
 1.13.2.2 04-Apr-2021  thorpej Associate the OpenFirmware phandle associated with a found device (including
PCI bus instances) by using CFARG_DEVHANDLE.
 1.13.2.1 21-Mar-2021  thorpej Give config_found() the same variadic arguments treatment as
config_search(). This commit only adds the CFARG_EOL sentinel
to the existing config_found() calls. Conversion of config_found_sm_loc()
and config_found_ia() call sites will be in subsequent commits.
 1.14.8.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.2 28-Mar-1999  tsubai Remove unused files.
 1.1 15-May-1998  tsubai Initial import of macppc port.
 1.3 28-Mar-1999  tsubai Remove unused files.
 1.2 13-Jul-1998  tsubai Get framebuffer address from Openfirmware.
 1.1 15-May-1998  tsubai Initial import of macppc port.
 1.2 28-Mar-1999  tsubai Remove unused files.
 1.1 15-May-1998  tsubai Initial import of macppc port.
 1.2 28-Mar-1999  tsubai Remove unused files.
 1.1 15-May-1998  tsubai Initial import of macppc port.
 1.2 08-Sep-2025  macallan more registers, add include guard
 1.1 08-Sep-2025  macallan move register definitions into the headers they belong
 1.66 04-Oct-2025  thorpej Add a shared function to query the common properties used for configuring
an Ethernet address.
 1.65 18-Sep-2022  thorpej Eliminate use of IFF_OACTIVE.
 1.64 05-Mar-2021  rin Convert to intr_establish_xname().
 1.63 04-Feb-2020  martin branches: 1.63.6;
Convert a few more drivers to the if_stats interface
 1.62 04-Feb-2020  skrll Adopt <net/if_stats.h>
 1.61 10-Nov-2019  chs branches: 1.61.2;
in many device attach paths, allocate memory with M_WAITOK instead of M_NOWAIT
and remove code to handle failures that can no longer happen.
 1.60 28-May-2019  msaitoh Use ETHER_LOCK()/ETHER_UNLOCK() for all ethernet drivers to protect ec_multi*.
 1.59 23-May-2019  msaitoh -No functional change:
- KNF
- u_int*_t -> uint*_t.
 1.58 22-Apr-2019  msaitoh These drivers do ether_ioctl() on SIOC{ADD,DEL}MULTI, SIOC{G,S}IFMEDIA and
default case in the switch statement. Only the default case didn't check the
return value with ENETRESET. Integrate them to one ether_ioctl() with
ENETRESET test. This change might improve SIOCSIFMTU or some other ioctl()s
which return ENETRESET by calling if_init().
 1.57 05-Feb-2019  msaitoh Remove very old IFF_NOTRAILERS flag.
 1.56 22-Jan-2019  msaitoh Change MII PHY read/write API from:

int (*mii_readreg_t)(device_t, int, int);
void (*mii_writereg_t)(device_t, int, int, int);
to:

int (*mii_readreg_t)(device_t, int, int, uint16_t *);
int (*mii_writereg_t)(device_t, int, int, uint16_t);

Now we can test if a read/write operation failed or not by the return value.

In 802.3 spec says that the PHY shall not respond to read/write transaction
to the unimplemented register(22.2.4.3). Detecting timeout can be used to
check whether a register is implemented or not (if the register conforms to
the spec). ukphy(4) can be used this for MII_MMDACR and MII_MMDAADR.

Note that I noticed that the following code do infinite loop in the
read/wirte function. If it accesses unimplemented PHY register, it will hang.
It should be fixed:

arm/at91/at91emac.c
arm/ep93xx/epe.c
arm/omap/omapl1x_emac.c
mips/ralink/ralink_eth.c
arch/powerpc/booke/dev/pq3etsec.c(read)
dev/cadence/if_cemac.c <- hkenken
dev/ic/lan9118.c


Tested with the following device:

axe+ukphy
axe+rgephy
axen+rgephy (tested by Andrius V)
wm+atphy
wm+ukphy
wm+igphy
wm+ihphy
wm+makphy
sk+makphy
sk+brgphy
sk+gentbi
msk+makphy
sip+icsphy
sip+ukphy
re+rgephy
bge+brgphy
bnx+brgphy
gsip+gphyter
rtk+rlphy
fxp+inphy (tested by Andrius V)
tlp+acphy
ex+exphy
epic+qsphy
vge+ciphy (tested by Andrius V)
vr+ukphy (tested by Andrius V)
vte+ukphy (tested by Andrius V)

Not tested (MAC):
arm:at91emac
arm:cemac
arm:epe
arm:geminigmac
arm:enet
arm:cpsw
arm:emac(omac)
arm:emac(sunxi)
arm:npe
evbppc:temac
macppc:bm
macppc:gm
mips:aumac
mips:ae
mips:cnmac
mips:reth
mips:sbmac
playstation2:smap
powerpc:tsec
powerpc:emac(ibm4xx)
sgimips:mec
sparc:be
sf
ne(ax88190, dl10019)
awge
ep
gem
hme
smsh
mtd
sm
age
alc
ale
bce
cas
et
jme
lii
nfe
pcn
ste
stge
tl
xi
aue
mue
smsc
udav
url

Not tested (PHY):
amhphy
bmtphy
dmphy
etphy
glxtphy
ikphy
iophy
lxtphy
nsphyter
pnaphy
rdcphy
sqphy
tlphy
tqphy
urlphy
 1.55 03-Sep-2018  riastradh Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)
 1.54 26-Jun-2018  msaitoh branches: 1.54.2;
Implement the BPF direction filter (BIOC[GS]DIRECTION). It provides backward
compatibility with BIOC[GS]SEESENT ioctl. The userland interface is the same
as FreeBSD.

This change also fixes a bug that the direction is misunderstand on some
environment by passing the direction to bpf_mtap*() instead of checking
m->m_pkthdr.rcvif.
 1.53 15-Dec-2016  ozaki-r branches: 1.53.14;
Move bpf_mtap and if_ipackets++ on Rx of each driver to percpuq if_input

The benefits of the change are:
- We can reduce codes
- We can provide the same behavior between drivers
- Where/When if_ipackets is counted up
- Note that some drivers still update packet statistics in their own
way (periodical update)
- Moved bpf_mtap run in softint
- This makes it easy to MP-ify bpf

Proposed on tech-kern and tech-net
 1.52 08-Dec-2016  ozaki-r Apply deferred if_start framework

if_schedule_deferred_start checks if the if_snd queue contains packets,
so drivers don't need to check it by themselves.
 1.51 03-Oct-2016  ozaki-r Fix typo
 1.50 02-Oct-2016  christos MFREE -> m_free
 1.49 15-Jul-2016  macallan adjust to dbdma changes
 1.48 10-Jun-2016  ozaki-r branches: 1.48.2;
Introduce m_set_rcvif and m_reset_rcvif

The API is used to set (or reset) a received interface of a mbuf.
They are counterpart of m_get_rcvif, which will come in another
commit, hide internal of rcvif operation, and reduce the diff of
the upcoming change.

No functional change.
 1.47 09-Feb-2016  ozaki-r Introduce softint-based if_input

This change intends to run the whole network stack in softint context
(or normal LWP), not hardware interrupt context. Note that the work is
still incomplete by this change; to that end, we also have to softint-ify
if_link_state_change (and bpf) which can still run in hardware interrupt.

This change softint-ifies at ifp->if_input that is called from
each device driver (and ieee80211_input) to ensure Layer 2 runs
in softint (e.g., ether_input and bridge_input). To this end,
we provide a framework (called percpuq) that utlizes softint(9)
and percpu ifqueues. With this patch, rxintr of most drivers just
queues received packets and schedules a softint, and the softint
dequeues packets and does rest packet processing.

To minimize changes to each driver, percpuq is allocated in struct
ifnet for now and that is initialized by default (in if_attach).
We probably have to move percpuq to softc of each driver, but it's
future work. At this point, only wm(4) has percpuq in its softc
as a reference implementation.

Additional information including performance numbers can be found
in the thread at tech-kern@ and tech-net@:
http://mail-index.netbsd.org/tech-kern/2016/01/14/msg019997.html

Acknowledgment: riastradh@ greatly helped this work.
Thank you very much!
 1.46 22-Jul-2012  matt branches: 1.46.2; 1.46.16;
Fix mii_statchg to take a 'struct ifnet *' instead of device_t. This fixes
problem with a common MDIO bus used for multiple interfaces.
Some drivers converted to CFATTACL_DECL_NEW.
 1.45 30-Jun-2011  matt branches: 1.45.2;
Modify mapiodev to take a third argument indicating whether the space
should be prefetchable (true) or not (false).
 1.44 18-Jun-2011  matt struct device * -> device_t
struct cfdata * -> cfdata_t
use device accessors, use device_private.
some softc/device_t splits (macppc needs a bunch more)
aprint*_dev used considerably more
 1.43 05-Apr-2010  joerg branches: 1.43.6;
Push the bpf_ops usage back into bpf.h. Push the common ifp->if_bpf
check into the inline functions as well the fourth argument for
bpf_attach.
 1.42 25-Feb-2010  matt branches: 1.42.2;
Adapt to <spr.h> breakup.
 1.41 19-Jan-2010  pooka branches: 1.41.2;
Redefine bpf linkage through an always present op vector, i.e.
#if NBPFILTER is no longer required in the client. This change
doesn't yet add support for loading bpf as a module, since drivers
can register before bpf is attached. However, callers of bpf can
now be modularized.

Dynamically loadable bpf could probably be done fairly easily with
coordination from the stub driver and the real driver by registering
attachments in the stub before the real driver is loaded and doing
a handoff. ... and I'm not going to ponder the depths of unload
here.

Tested with i386/MONOLITHIC, modified MONOLITHIC without bpf and rump.
 1.40 14-Mar-2009  dsl ANSIfy another 1261 function definitions.
The only ones left in sys are beyond by sed script!
(or in sys/dist or sys/external)
Mostly they have function pointer parameters.
 1.39 14-Mar-2009  dsl Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.38 07-Nov-2008  dyoung branches: 1.38.4;
*** Summary ***

When a link-layer address changes (e.g., ifconfig ex0 link
02:de:ad:be:ef:02 active), send a gratuitous ARP and/or a Neighbor
Advertisement to update the network-/link-layer address bindings
on our LAN peers.

Refuse a change of ethernet address to the address 00:00:00:00:00:00
or to any multicast/broadcast address. (Thanks matt@.)

Reorder ifnet ioctl operations so that driver ioctls may inherit
the functions of their "class"---ether_ioctl(), fddi_ioctl(), et
cetera---and the class ioctls may inherit from the generic ioctl,
ifioctl_common(), but both driver- and class-ioctls may override
the generic behavior. Make network drivers share more code.

Distinguish a "factory" link-layer address from others for the
purposes of both protecting that address from deletion and computing
EUI64.

Return consistent, appropriate error codes from network drivers.

Improve readability. KNF.

*** Details ***

In if_attach(), always initialize the interface ioctl routine,
ifnet->if_ioctl, if the driver has not already initialized it.
Delete if_ioctl == NULL tests everywhere else, because it cannot
happen.

In the ioctl routines of network interfaces, inherit common ioctl
behaviors by calling either ifioctl_common() or whichever ioctl
routine is appropriate for the class of interface---e.g., ether_ioctl()
for ethernets.

Stop (ab)using SIOCSIFADDR and start to use SIOCINITIFADDR. In
the user->kernel interface, SIOCSIFADDR's argument was an ifreq,
but on the protocol->ifnet interface, SIOCSIFADDR's argument was
an ifaddr. That was confusing, and it would work against me as I
make it possible for a network interface to overload most ioctls.
On the protocol->ifnet interface, replace SIOCSIFADDR with
SIOCINITIFADDR. In ifioctl(), return EPERM if userland tries to
invoke SIOCINITIFADDR.

In ifioctl(), give the interface the first shot at handling most
interface ioctls, and give the protocol the second shot, instead
of the other way around. Finally, let compatibility code (COMPAT_OSOCK)
take a shot.

Pull device initialization out of switch statements under
SIOCINITIFADDR. For example, pull ..._init() out of any switch
statement that looks like this:

switch (...->sa_family) {
case ...:
..._init();
...
break;
...
default:
..._init();
...
break;
}

Rewrite many if-else clauses that handle all permutations of IFF_UP
and IFF_RUNNING to use a switch statement,

switch (x & (IFF_UP|IFF_RUNNING)) {
case 0:
...
break;
case IFF_RUNNING:
...
break;
case IFF_UP:
...
break;
case IFF_UP|IFF_RUNNING:
...
break;
}

unifdef lots of code containing #ifdef FreeBSD, #ifdef NetBSD, and
#ifdef SIOCSIFMTU, especially in fwip(4) and in ndis(4).

In ipw(4), remove an if_set_sadl() call that is out of place.

In nfe(4), reuse the jumbo MTU logic in ether_ioctl().

Let ethernets register a callback for setting h/w state such as
promiscuous mode and the multicast filter in accord with a change
in the if_flags: ether_set_ifflags_cb() registers a callback that
returns ENETRESET if the caller should reset the ethernet by calling
if_init(), 0 on success, != 0 on failure. Pull common code from
ex(4), gem(4), nfe(4), sip(4), tlp(4), vge(4) into ether_ioctl(),
and register if_flags callbacks for those drivers.

Return ENOTTY instead of EINVAL for inappropriate ioctls. In
zyd(4), use ENXIO instead of ENOTTY to indicate that the device is
not any longer attached.

Add to if_set_sadl() a boolean 'factory' argument that indicates
whether a link-layer address was assigned by the factory or some
other source. In a comment, recommend using the factory address
for generating an EUI64, and update in6_get_hw_ifid() to prefer a
factory address to any other link-layer address.

Add a routing message, RTM_LLINFO_UPD, that tells protocols to
update the binding of network-layer addresses to link-layer addresses.
Implement this message in IPv4 and IPv6 by sending a gratuitous
ARP or a neighbor advertisement, respectively. Generate RTM_LLINFO_UPD
messages on a change of an interface's link-layer address.

In ether_ioctl(), do not let SIOCALIFADDR set a link-layer address
that is broadcast/multicast or equal to 00:00:00:00:00:00.

Make ether_ioctl() call ifioctl_common() to handle ioctls that it
does not understand.

In gif(4), initialize if_softc and use it, instead of assuming that
the gif_softc and ifp overlap.

Let ifioctl_common() handle SIOCGIFADDR.

Sprinkle rtcache_invariants(), which checks on DIAGNOSTIC kernels
that certain invariants on a struct route are satisfied.

In agr(4), rewrite agr_ioctl_filter() to be a bit more explicit
about the ioctls that we do not allow on an agr(4) member interface.

bzero -> memset. Delete unnecessary casts to void *. Use
sockaddr_in_init() and sockaddr_in6_init(). Compare pointers with
NULL instead of "testing truth". Replace some instances of (type
*)0 with NULL. Change some K&R prototypes to ANSI C, and join
lines.
 1.37 26-Sep-2008  macallan branches: 1.37.2; 1.37.12;
use access functions to mess with obio's registers
 1.36 19-Jan-2008  dyoung branches: 1.36.6; 1.36.10; 1.36.12; 1.36.16;
Make many ethernet drivers share the common code for MII media
handling, ether_mediastatus() and ether_mediachange(). Check for
a non-ENXIO error return from mii_mediachg(). (ENXIO indicates
that a PHY is suspended.)

This patch shrinks the source code size by 979 lines. There was
a 5100-byte savings on the NetBSD/i386 kernel configuration, ALL.

I have made a few miscellaneous changes, too:

gem(4): use LIST_EMPTY(), LIST_FOREACH().
mtd(4): handle media ioctls, for a change!
axe(4): do not track link status in sc->axe_link any longer
nfe(4), aue(4), axe(4), udav(4), url(4): do not reset all PHYs
on a change of media

Except for the change to mtd(4), no functional changes are intended.

XXX This patch affects more architectures than I can feasibly
XXX compile and run. I have compiled macppc, sparc64, i386. I
XXX have run the patches on i386 boxen with bnx(4) and sip(4).
XXX Compiling and running on evbmips (MERAKI, ADM5120) is in
XXX progress.
 1.35 29-Dec-2007  dyoung De-__P().
 1.34 17-Oct-2007  garbled branches: 1.34.2; 1.34.8;
Merge the ppcoea-renovation branch to HEAD.

This branch was a major cleanup and rototill of many of the various OEA
cpu based PPC ports that focused on sharing as much code as possible
between the various ports to eliminate near-identical copies of files in
every tree. Additionally there is a new PIC system that unifies the
interface to interrupt code for all different OEA ppc arches. The work
for this branch was done by a variety of people, too long to list here.

TODO:
bebox still needs work to complete the transition to -renovation.
ofppc still needs a bunch of work, which I will be looking at.
ev64260 still needs to be renovated
amigappc was not attempted.

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.33 01-Sep-2007  dyoung branches: 1.33.2; 1.33.4;
Change a bazillion occurrences of code resembling this,

error = (cmd == SIOCADDMULTI) ?
ether_addmulti(ifr, &sc->sc_ec) :
ether_delmulti(ifr, &sc->sc_ec);

if (error == ENETRESET) {

to this,

if ((error = ether_ioctl(ifp, cmd, data)) == ENETRESET) {

which does the same thing.

(A bazillion is a very large number. This seems to make the i386
ALL kernel smaller by 3kB to 4kB.)

Use ifreq_getaddr() twice in es(4).

Whitespace nits.
 1.32 09-Jul-2007  ad branches: 1.32.4; 1.32.8; 1.32.10;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements
 1.31 04-Mar-2007  macallan branches: 1.31.2; 1.31.4; 1.31.10;
make this compile again
 1.30 04-Mar-2007  christos Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.29 18-Oct-2006  jklos branches: 1.29.4;
Fix for PR 33667. Note that putting bmac_mediachange where thorpej
suggested doesn't fix this issue. Not a perfect fix, but much better than
leaving it as it was. Tested on several iMacs and a blue & white G3.
 1.28 07-Sep-2006  dogcow branches: 1.28.2; 1.28.4;
remove more vestiges of CCITT, LLC, HDLC, NS, and NSIP.
 1.27 24-Dec-2005  perry branches: 1.27.4; 1.27.8;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.
 1.26 11-Dec-2005  christos merge ktrace-lwp.
 1.25 30-Jan-2005  thorpej branches: 1.25.4; 1.25.6;
Eliminate use of M_HASFCS.
 1.24 26-Jan-2005  kleink MPC601: Use RTC instead of TB. (While I'm here, update these to use
the inline versions from <powerpc/cpu.h>).
 1.23 30-Oct-2004  thorpej branches: 1.23.4; 1.23.6;
When adding/deleting multicast addresses, only whack the address
filter if the interface is marked RUNNING.

Fixes kern/27678.
 1.22 18-Apr-2004  matt Make this compile with XNS enabled
 1.21 15-Jul-2003  lukem branches: 1.21.4;
__KERNEL_RCSID()
 1.20 02-Apr-2003  thorpej branches: 1.20.2;
Use PAGE_SIZE rather than NBPG.
 1.19 02-Oct-2002  thorpej Use CFATTACH_DECL().
 1.18 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.17 05-Mar-2002  itojun bring in latest ALTQ from kjc. ALTQify some of the drivers.
 1.16 22-Jul-2001  wiz branches: 1.16.6;
bcopy -> memcpy, bzero -> memset, bcmp -> memcmp.
Reviewed by Matt Thomas, ok'd by Tsubai Masanari.
 1.15 15-Nov-2000  thorpej branches: 1.15.4;
Move bpfattach()/bpfdetach() calls into ether_ifattach()/ether_ifdetach().
 1.14 01-Nov-2000  tsubai Don't set M_HASFCS flag twice.
 1.13 18-Oct-2000  matt Packets have the FCS append so set M_HASFCS.
 1.12 17-Oct-2000  tsubai Pass correct packet length to the upper layer.
 1.11 28-Aug-2000  tsubai Enable hash filter mode.
 1.10 29-Jun-2000  mrg remove include of <vm/vm.h>. <vm/vm.h> -> <uvm/uvm_extern.h>
 1.9 16-Jun-2000  tsubai branches: 1.9.2;
Use ether_crc32_le().
 1.8 07-Apr-2000  tsubai branches: 1.8.2;
Make this compile again.
 1.7 23-Mar-2000  thorpej New callout mechanism with two major improvements over the old
timeout()/untimeout() API:
- Clients supply callout handle storage, thus eliminating problems of
resource allocation.
- Insertion and removal of callouts is constant time, important as
this facility is used quite a lot in the kernel.

The old timeout()/untimeout() API has been removed from the kernel.
 1.6 02-Feb-2000  thorpej Don't dry to diving MIIF_NOISOLATE in the PHY drivers. Instead, pass
flags down from the parent to child vi mii_attach().
 1.5 02-Feb-2000  thorpej Bring some order to the chaos which was the MII code function naming
"conventions".
 1.4 25-Jan-2000  tsubai Use MII device layer.
XXX still 100Mbps receive side is very slow...
 1.3 20-Jun-1999  tsubai branches: 1.3.2;
More initialization by calling Open Firmware.
 1.2 18-May-1999  thorpej Rework layer 2 protocol input routines. Instead of calling e.g. ether_input()
directly, call the function pointer (*if_input)(ifp, m). The input routine
expects the packet header to be at the head of the packet, and will adjust
as necessary. Privatize the layer 2 input and output routines, allowing
*_ifattach() to set them up as appropriate.
 1.1 01-Jan-1999  tsubai branches: 1.1.2; 1.1.4;
bmac ethernet driver. (tested on iMac. only 10Base-T works.)
 1.1.4.2 01-Jul-1999  thorpej Sync w/ -current.
 1.1.4.1 21-Jun-1999  thorpej Sync w/ -current.
 1.1.2.1 20-Jan-2000  he Pull up revision 1.3 (requested by danw):
Work around a problem where the 'bm' (iMac and Blue G3 built-in
ethernet) driver only works if initialized from Open Firmware.
 1.3.2.2 22-Nov-2000  bouyer Sync with HEAD.
 1.3.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.8.2.1 22-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.9.2.1 01-Nov-2000  tv Pullup 1.11-1.13 [tsubai, matt, mycroft]:
Packets have the FCS append so set M_HASFCS.
Pass correct packet length to the upper layer.
Enable hash filter mode.
 1.15.4.3 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.15.4.2 16-Mar-2002  jdolecek Catch up with -current.
 1.15.4.1 03-Aug-2001  lukem update to -current
 1.16.6.3 18-Oct-2002  nathanw Catch up to -current.
 1.16.6.2 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.16.6.1 22-Jul-2001  nathanw file if_bm.c was added on branch nathanw_sa on 2002-04-01 07:40:53 +0000
 1.20.2.5 04-Feb-2005  skrll Sync with HEAD.
 1.20.2.4 02-Nov-2004  skrll Sync with HEAD.
 1.20.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.20.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.20.2.1 03-Aug-2004  skrll Sync with HEAD
 1.21.4.1 24-Jan-2005  he Pull up revision 1.23 (requested by thorpej in ticket #939):
When adding or deleting multicast addresses, only change
the address filter if the interface is marked RUNNING.
Fixes PR#27678.
 1.23.6.1 12-Feb-2005  yamt sync with head.
 1.23.4.1 29-Apr-2005  kent sync with -current
 1.25.6.5 21-Jan-2008  yamt sync with head
 1.25.6.4 27-Oct-2007  yamt sync with head.
 1.25.6.3 03-Sep-2007  yamt sync with head.
 1.25.6.2 30-Dec-2006  yamt sync with head.
 1.25.6.1 21-Jun-2006  yamt sync with head.
 1.25.4.1 31-Mar-2007  bouyer Pull up following revision(s) (requested by sborrill in ticket #1685):
sys/arch/macppc/dev/if_bm.c: revision 1.29
Fix for PR 33667. Note that putting bmac_mediachange where thorpej
suggested doesn't fix this issue. Not a perfect fix, but much better than
leaving it as it was. Tested on several iMacs and a blue & white G3.
 1.27.8.1 14-Sep-2006  yamt sync with head.
 1.27.4.1 09-Sep-2006  rpaulo sync with head
 1.28.4.1 22-Oct-2006  yamt sync with head
 1.28.2.1 18-Nov-2006  ad Sync with head.
 1.29.4.1 12-Mar-2007  rmind Sync with HEAD.
 1.31.10.6 03-Oct-2007  garbled Sync with HEAD
 1.31.10.5 27-Sep-2007  macallan adapt to changed ether_addmulti() signature
 1.31.10.4 02-Aug-2007  macallan fix typo - bus_space_map() returns 0 on success, not the other way around
also map what OF reports, not a whole page
 1.31.10.3 02-Aug-2007  macallan sync with HEAD
 1.31.10.2 07-Jun-2007  garbled Convert macppc to powerpc bus_space. Lots of work here from Matt Thomas,
as well as the common ofwoea code from myself. Compile tested only,
still probably needs some fine tuning.

Also in this commit:
Convert macppc to new shared ofwoea routines.
Lots of KNF.
 1.31.10.1 11-May-2007  macallan request the correct interrupt type in a couple drivers - necessary since
these days we actually do something with the type argument
 1.31.4.1 11-Jul-2007  mjf Sync with head.
 1.31.2.3 23-Oct-2007  ad Sync with head.
 1.31.2.2 09-Oct-2007  ad Sync with head.
 1.31.2.1 15-Jul-2007  ad Sync with head.
 1.32.10.3 23-Mar-2008  matt sync with HEAD
 1.32.10.2 09-Jan-2008  matt sync with HEAD
 1.32.10.1 06-Nov-2007  matt sync with HEAD
 1.32.8.2 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.32.8.1 03-Sep-2007  jmcneill Sync with HEAD.
 1.32.4.1 03-Sep-2007  skrll Sync with HEAD.
 1.33.4.1 25-Oct-2007  bouyer Sync with HEAD.
 1.33.2.1 18-Oct-2007  yamt sync with head.
 1.34.8.2 20-Jan-2008  bouyer Sync with HEAD
 1.34.8.1 02-Jan-2008  bouyer Sync with HEAD
 1.34.2.1 18-Feb-2008  mjf Sync with HEAD.
 1.36.16.2 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.36.16.1 19-Oct-2008  haad Sync with HEAD.
 1.36.12.1 10-Oct-2008  skrll Sync with HEAD.
 1.36.10.3 11-Aug-2010  yamt sync with head.
 1.36.10.2 11-Mar-2010  yamt sync with head
 1.36.10.1 04-May-2009  yamt sync with head.
 1.36.6.2 17-Jan-2009  mjf Sync with HEAD.
 1.36.6.1 28-Sep-2008  mjf Sync with HEAD.
 1.37.12.1 07-Jan-2011  matt Deal with split <spr.h> (and a few other misc fixes).
 1.37.2.2 28-Apr-2009  skrll Sync with HEAD.
 1.37.2.1 19-Jan-2009  skrll Sync with HEAD.
 1.38.4.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.41.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.42.2.1 30-May-2010  rmind sync with head
 1.43.6.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.45.2.1 30-Oct-2012  yamt sync with head
 1.46.16.4 05-Feb-2017  skrll Sync with HEAD
 1.46.16.3 05-Oct-2016  skrll Sync with HEAD
 1.46.16.2 09-Jul-2016  skrll Sync with HEAD
 1.46.16.1 19-Mar-2016  skrll Sync with HEAD
 1.46.2.1 03-Dec-2017  jdolecek update from HEAD
 1.48.2.3 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.48.2.2 04-Nov-2016  pgoyette Sync with HEAD
 1.48.2.1 26-Jul-2016  pgoyette Sync with HEAD
 1.53.14.3 26-Jan-2019  pgoyette Sync with HEAD
 1.53.14.2 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.53.14.1 28-Jul-2018  pgoyette Sync with HEAD
 1.54.2.3 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.54.2.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.54.2.1 10-Jun-2019  christos Sync with HEAD
 1.61.2.1 29-Feb-2020  ad Sync with head.
 1.63.6.1 03-Apr-2021  thorpej Sync with HEAD.
 1.2 25-Jan-2000  tsubai Use MII device layer.
XXX still 100Mbps receive side is very slow...
 1.1 01-Jan-1999  tsubai branches: 1.1.8;
bmac ethernet driver. (tested on iMac. only 10Base-T works.)
 1.1.8.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.60 04-Oct-2025  thorpej Add a shared function to query the common properties used for configuring
an Ethernet address.
 1.59 18-Sep-2022  thorpej Eliminate use of IFF_OACTIVE.
 1.58 05-Mar-2021  rin Convert to intr_establish_xname().
 1.57 04-Feb-2020  skrll branches: 1.57.6;
Adopt <net/if_stats.h>
 1.56 10-Nov-2019  chs branches: 1.56.2;
in many device attach paths, allocate memory with M_WAITOK instead of M_NOWAIT
and remove code to handle failures that can no longer happen.
 1.55 28-May-2019  msaitoh Use ETHER_LOCK()/ETHER_UNLOCK() for all ethernet drivers to protect ec_multi*.
 1.54 23-May-2019  msaitoh -No functional change:
- KNF
- u_int*_t -> uint*_t.
 1.53 22-Apr-2019  msaitoh These drivers do ether_ioctl() on SIOC{ADD,DEL}MULTI, SIOC{G,S}IFMEDIA and
default case in the switch statement. Only the default case didn't check the
return value with ENETRESET. Integrate them to one ether_ioctl() with
ENETRESET test. This change might improve SIOCSIFMTU or some other ioctl()s
which return ENETRESET by calling if_init().
 1.52 05-Feb-2019  msaitoh Remove very old IFF_NOTRAILERS flag.
 1.51 22-Jan-2019  msaitoh Change MII PHY read/write API from:

int (*mii_readreg_t)(device_t, int, int);
void (*mii_writereg_t)(device_t, int, int, int);
to:

int (*mii_readreg_t)(device_t, int, int, uint16_t *);
int (*mii_writereg_t)(device_t, int, int, uint16_t);

Now we can test if a read/write operation failed or not by the return value.

In 802.3 spec says that the PHY shall not respond to read/write transaction
to the unimplemented register(22.2.4.3). Detecting timeout can be used to
check whether a register is implemented or not (if the register conforms to
the spec). ukphy(4) can be used this for MII_MMDACR and MII_MMDAADR.

Note that I noticed that the following code do infinite loop in the
read/wirte function. If it accesses unimplemented PHY register, it will hang.
It should be fixed:

arm/at91/at91emac.c
arm/ep93xx/epe.c
arm/omap/omapl1x_emac.c
mips/ralink/ralink_eth.c
arch/powerpc/booke/dev/pq3etsec.c(read)
dev/cadence/if_cemac.c <- hkenken
dev/ic/lan9118.c


Tested with the following device:

axe+ukphy
axe+rgephy
axen+rgephy (tested by Andrius V)
wm+atphy
wm+ukphy
wm+igphy
wm+ihphy
wm+makphy
sk+makphy
sk+brgphy
sk+gentbi
msk+makphy
sip+icsphy
sip+ukphy
re+rgephy
bge+brgphy
bnx+brgphy
gsip+gphyter
rtk+rlphy
fxp+inphy (tested by Andrius V)
tlp+acphy
ex+exphy
epic+qsphy
vge+ciphy (tested by Andrius V)
vr+ukphy (tested by Andrius V)
vte+ukphy (tested by Andrius V)

Not tested (MAC):
arm:at91emac
arm:cemac
arm:epe
arm:geminigmac
arm:enet
arm:cpsw
arm:emac(omac)
arm:emac(sunxi)
arm:npe
evbppc:temac
macppc:bm
macppc:gm
mips:aumac
mips:ae
mips:cnmac
mips:reth
mips:sbmac
playstation2:smap
powerpc:tsec
powerpc:emac(ibm4xx)
sgimips:mec
sparc:be
sf
ne(ax88190, dl10019)
awge
ep
gem
hme
smsh
mtd
sm
age
alc
ale
bce
cas
et
jme
lii
nfe
pcn
ste
stge
tl
xi
aue
mue
smsc
udav
url

Not tested (PHY):
amhphy
bmtphy
dmphy
etphy
glxtphy
ikphy
iophy
lxtphy
nsphyter
pnaphy
rdcphy
sqphy
tlphy
tqphy
urlphy
 1.50 26-Jun-2018  msaitoh branches: 1.50.2;
Implement the BPF direction filter (BIOC[GS]DIRECTION). It provides backward
compatibility with BIOC[GS]SEESENT ioctl. The userland interface is the same
as FreeBSD.

This change also fixes a bug that the direction is misunderstand on some
environment by passing the direction to bpf_mtap*() instead of checking
m->m_pkthdr.rcvif.
 1.49 15-Dec-2016  ozaki-r branches: 1.49.14;
Move bpf_mtap and if_ipackets++ on Rx of each driver to percpuq if_input

The benefits of the change are:
- We can reduce codes
- We can provide the same behavior between drivers
- Where/When if_ipackets is counted up
- Note that some drivers still update packet statistics in their own
way (periodical update)
- Moved bpf_mtap run in softint
- This makes it easy to MP-ify bpf

Proposed on tech-kern and tech-net
 1.48 08-Dec-2016  ozaki-r Apply deferred if_start framework

if_schedule_deferred_start checks if the if_snd queue contains packets,
so drivers don't need to check it by themselves.
 1.47 10-Jun-2016  ozaki-r branches: 1.47.2;
Introduce m_set_rcvif and m_reset_rcvif

The API is used to set (or reset) a received interface of a mbuf.
They are counterpart of m_get_rcvif, which will come in another
commit, hide internal of rcvif operation, and reduce the diff of
the upcoming change.

No functional change.
 1.46 09-Feb-2016  ozaki-r Introduce softint-based if_input

This change intends to run the whole network stack in softint context
(or normal LWP), not hardware interrupt context. Note that the work is
still incomplete by this change; to that end, we also have to softint-ify
if_link_state_change (and bpf) which can still run in hardware interrupt.

This change softint-ifies at ifp->if_input that is called from
each device driver (and ieee80211_input) to ensure Layer 2 runs
in softint (e.g., ether_input and bridge_input). To this end,
we provide a framework (called percpuq) that utlizes softint(9)
and percpu ifqueues. With this patch, rxintr of most drivers just
queues received packets and schedules a softint, and the softint
dequeues packets and does rest packet processing.

To minimize changes to each driver, percpuq is allocated in struct
ifnet for now and that is initialized by default (in if_attach).
We probably have to move percpuq to softc of each driver, but it's
future work. At this point, only wm(4) has percpuq in its softc
as a reference implementation.

Additional information including performance numbers can be found
in the thread at tech-kern@ and tech-net@:
http://mail-index.netbsd.org/tech-kern/2016/01/14/msg019997.html

Acknowledgment: riastradh@ greatly helped this work.
Thank you very much!
 1.45 13-Apr-2015  riastradh MD rnd.h cleanups. Please let me know if I broke anything!
 1.44 10-Aug-2014  tls branches: 1.44.4;
Merge tls-earlyentropy branch into HEAD.
 1.43 29-Mar-2014  christos branches: 1.43.2;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.42 22-Jul-2012  matt branches: 1.42.2; 1.42.4;
Fix mii_statchg to take a 'struct ifnet *' instead of device_t. This fixes
problem with a common MDIO bus used for multiple interfaces.
Some drivers converted to CFATTACL_DECL_NEW.
 1.41 02-Feb-2012  tls Entropy-pool implementation move and cleanup.

1) Move core entropy-pool code and source/sink/sample management code
to sys/kern from sys/dev.

2) Remove use of NRND as test for presence of entropy-pool code throughout
source tree.

3) Remove use of RND_ENABLED in device drivers as microoptimization to
avoid expensive operations on disabled entropy sources; make the
rnd_add calls do this directly so all callers benefit.

4) Fix bug in recent rnd_add_data()/rnd_add_uint32() changes that might
have lead to slight entropy overestimation for some sources.

5) Add new source types for environmental sensors, power sensors, VM
system events, and skew between clocks, with a sample implementation
for each.

ok releng to go in before the branch due to the difficulty of later
pullup (widespread #ifdef removal and moved files). Tested with release
builds on amd64 and evbarm and live testing on amd64.
 1.40 19-Nov-2011  tls branches: 1.40.2;
First step of random number subsystem rework described in
<20111022023242.BA26F14A158@mail.netbsd.org>. This change includes
the following:

An initial cleanup and minor reorganization of the entropy pool
code in sys/dev/rnd.c and sys/dev/rndpool.c. Several bugs are
fixed. Some effort is made to accumulate entropy more quickly at
boot time.

A generic interface, "rndsink", is added, for stream generators to
request that they be re-keyed with good quality entropy from the pool
as soon as it is available.

The arc4random()/arc4randbytes() implementation in libkern is
adjusted to use the rndsink interface for rekeying, which helps
address the problem of low-quality keys at boot time.

An implementation of the FIPS 140-2 statistical tests for random
number generator quality is provided (libkern/rngtest.c). This
is based on Greg Rose's implementation from Qualcomm.

A new random stream generator, nist_ctr_drbg, is provided. It is
based on an implementation of the NIST SP800-90 CTR_DRBG by
Henric Jungheim. This generator users AES in a modified counter
mode to generate a backtracking-resistant random stream.

An abstraction layer, "cprng", is provided for in-kernel consumers
of randomness. The arc4random/arc4randbytes API is deprecated for
in-kernel use. It is replaced by "cprng_strong". The current
cprng_fast implementation wraps the existing arc4random
implementation. The current cprng_strong implementation wraps the
new CTR_DRBG implementation. Both interfaces are rekeyed from
the entropy pool automatically at intervals justifiable from best
current cryptographic practice.

In some quick tests, cprng_fast() is about the same speed as
the old arc4randbytes(), and cprng_strong() is about 20% faster
than rnd_extract_data(). Performance is expected to improve.

The AES code in src/crypto/rijndael is no longer an optional
kernel component, as it is required by cprng_strong, which is
not an optional kernel component.

The entropy pool output is subjected to the rngtest tests at
startup time; if it fails, the system will reboot. There is
approximately a 3/10000 chance of a false positive from these
tests. Entropy pool _input_ from hardware random numbers is
subjected to the rngtest tests at attach time, as well as the
FIPS continuous-output test, to detect bad or stuck hardware
RNGs; if any are detected, they are detached, but the system
continues to run.

A problem with rndctl(8) is fixed -- datastructures with
pointers in arrays are no longer passed to userspace (this
was not a security problem, but rather a major issue for
compat32). A new kernel will require a new rndctl.

The sysctl kern.arandom() and kern.urandom() nodes are hooked
up to the new generators, but the /dev/*random pseudodevices
are not, yet.

Manual pages for the new kernel interfaces are forthcoming.
 1.39 18-Jun-2011  matt branches: 1.39.2;
struct device * -> device_t
struct cfdata * -> cfdata_t
use device accessors, use device_private.
some softc/device_t splits (macppc needs a bunch more)
aprint*_dev used considerably more
 1.38 05-Apr-2010  joerg branches: 1.38.6;
Push the bpf_ops usage back into bpf.h. Push the common ifp->if_bpf
check into the inline functions as well the fourth argument for
bpf_attach.
 1.37 19-Jan-2010  pooka branches: 1.37.2; 1.37.4;
Redefine bpf linkage through an always present op vector, i.e.
#if NBPFILTER is no longer required in the client. This change
doesn't yet add support for loading bpf as a module, since drivers
can register before bpf is attached. However, callers of bpf can
now be modularized.

Dynamically loadable bpf could probably be done fairly easily with
coordination from the stub driver and the real driver by registering
attachments in the stub before the real driver is loaded and doing
a handoff. ... and I'm not going to ponder the depths of unload
here.

Tested with i386/MONOLITHIC, modified MONOLITHIC without bpf and rump.
 1.36 14-Mar-2009  dsl ANSIfy another 1261 function definitions.
The only ones left in sys are beyond by sed script!
(or in sys/dist or sys/external)
Mostly they have function pointer parameters.
 1.35 14-Mar-2009  dsl Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.34 07-Nov-2008  dyoung branches: 1.34.4;
*** Summary ***

When a link-layer address changes (e.g., ifconfig ex0 link
02:de:ad:be:ef:02 active), send a gratuitous ARP and/or a Neighbor
Advertisement to update the network-/link-layer address bindings
on our LAN peers.

Refuse a change of ethernet address to the address 00:00:00:00:00:00
or to any multicast/broadcast address. (Thanks matt@.)

Reorder ifnet ioctl operations so that driver ioctls may inherit
the functions of their "class"---ether_ioctl(), fddi_ioctl(), et
cetera---and the class ioctls may inherit from the generic ioctl,
ifioctl_common(), but both driver- and class-ioctls may override
the generic behavior. Make network drivers share more code.

Distinguish a "factory" link-layer address from others for the
purposes of both protecting that address from deletion and computing
EUI64.

Return consistent, appropriate error codes from network drivers.

Improve readability. KNF.

*** Details ***

In if_attach(), always initialize the interface ioctl routine,
ifnet->if_ioctl, if the driver has not already initialized it.
Delete if_ioctl == NULL tests everywhere else, because it cannot
happen.

In the ioctl routines of network interfaces, inherit common ioctl
behaviors by calling either ifioctl_common() or whichever ioctl
routine is appropriate for the class of interface---e.g., ether_ioctl()
for ethernets.

Stop (ab)using SIOCSIFADDR and start to use SIOCINITIFADDR. In
the user->kernel interface, SIOCSIFADDR's argument was an ifreq,
but on the protocol->ifnet interface, SIOCSIFADDR's argument was
an ifaddr. That was confusing, and it would work against me as I
make it possible for a network interface to overload most ioctls.
On the protocol->ifnet interface, replace SIOCSIFADDR with
SIOCINITIFADDR. In ifioctl(), return EPERM if userland tries to
invoke SIOCINITIFADDR.

In ifioctl(), give the interface the first shot at handling most
interface ioctls, and give the protocol the second shot, instead
of the other way around. Finally, let compatibility code (COMPAT_OSOCK)
take a shot.

Pull device initialization out of switch statements under
SIOCINITIFADDR. For example, pull ..._init() out of any switch
statement that looks like this:

switch (...->sa_family) {
case ...:
..._init();
...
break;
...
default:
..._init();
...
break;
}

Rewrite many if-else clauses that handle all permutations of IFF_UP
and IFF_RUNNING to use a switch statement,

switch (x & (IFF_UP|IFF_RUNNING)) {
case 0:
...
break;
case IFF_RUNNING:
...
break;
case IFF_UP:
...
break;
case IFF_UP|IFF_RUNNING:
...
break;
}

unifdef lots of code containing #ifdef FreeBSD, #ifdef NetBSD, and
#ifdef SIOCSIFMTU, especially in fwip(4) and in ndis(4).

In ipw(4), remove an if_set_sadl() call that is out of place.

In nfe(4), reuse the jumbo MTU logic in ether_ioctl().

Let ethernets register a callback for setting h/w state such as
promiscuous mode and the multicast filter in accord with a change
in the if_flags: ether_set_ifflags_cb() registers a callback that
returns ENETRESET if the caller should reset the ethernet by calling
if_init(), 0 on success, != 0 on failure. Pull common code from
ex(4), gem(4), nfe(4), sip(4), tlp(4), vge(4) into ether_ioctl(),
and register if_flags callbacks for those drivers.

Return ENOTTY instead of EINVAL for inappropriate ioctls. In
zyd(4), use ENXIO instead of ENOTTY to indicate that the device is
not any longer attached.

Add to if_set_sadl() a boolean 'factory' argument that indicates
whether a link-layer address was assigned by the factory or some
other source. In a comment, recommend using the factory address
for generating an EUI64, and update in6_get_hw_ifid() to prefer a
factory address to any other link-layer address.

Add a routing message, RTM_LLINFO_UPD, that tells protocols to
update the binding of network-layer addresses to link-layer addresses.
Implement this message in IPv4 and IPv6 by sending a gratuitous
ARP or a neighbor advertisement, respectively. Generate RTM_LLINFO_UPD
messages on a change of an interface's link-layer address.

In ether_ioctl(), do not let SIOCALIFADDR set a link-layer address
that is broadcast/multicast or equal to 00:00:00:00:00:00.

Make ether_ioctl() call ifioctl_common() to handle ioctls that it
does not understand.

In gif(4), initialize if_softc and use it, instead of assuming that
the gif_softc and ifp overlap.

Let ifioctl_common() handle SIOCGIFADDR.

Sprinkle rtcache_invariants(), which checks on DIAGNOSTIC kernels
that certain invariants on a struct route are satisfied.

In agr(4), rewrite agr_ioctl_filter() to be a bit more explicit
about the ioctls that we do not allow on an agr(4) member interface.

bzero -> memset. Delete unnecessary casts to void *. Use
sockaddr_in_init() and sockaddr_in6_init(). Compare pointers with
NULL instead of "testing truth". Replace some instances of (type
*)0 with NULL. Change some K&R prototypes to ANSI C, and join
lines.
 1.33 19-Jan-2008  dyoung branches: 1.33.6; 1.33.10; 1.33.16; 1.33.18;
Make many ethernet drivers share the common code for MII media
handling, ether_mediastatus() and ether_mediachange(). Check for
a non-ENXIO error return from mii_mediachg(). (ENXIO indicates
that a PHY is suspended.)

This patch shrinks the source code size by 979 lines. There was
a 5100-byte savings on the NetBSD/i386 kernel configuration, ALL.

I have made a few miscellaneous changes, too:

gem(4): use LIST_EMPTY(), LIST_FOREACH().
mtd(4): handle media ioctls, for a change!
axe(4): do not track link status in sc->axe_link any longer
nfe(4), aue(4), axe(4), udav(4), url(4): do not reset all PHYs
on a change of media

Except for the change to mtd(4), no functional changes are intended.

XXX This patch affects more architectures than I can feasibly
XXX compile and run. I have compiled macppc, sparc64, i386. I
XXX have run the patches on i386 boxen with bnx(4) and sip(4).
XXX Compiling and running on evbmips (MERAKI, ADM5120) is in
XXX progress.
 1.32 29-Dec-2007  dyoung De-__P().
 1.31 17-Oct-2007  garbled branches: 1.31.2; 1.31.8;
Merge the ppcoea-renovation branch to HEAD.

This branch was a major cleanup and rototill of many of the various OEA
cpu based PPC ports that focused on sharing as much code as possible
between the various ports to eliminate near-identical copies of files in
every tree. Additionally there is a new PIC system that unifies the
interface to interrupt code for all different OEA ppc arches. The work
for this branch was done by a variety of people, too long to list here.

TODO:
bebox still needs work to complete the transition to -renovation.
ofppc still needs a bunch of work, which I will be looking at.
ev64260 still needs to be renovated
amigappc was not attempted.

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.30 01-Sep-2007  dyoung Change a bazillion occurrences of code resembling this,

error = (cmd == SIOCADDMULTI) ?
ether_addmulti(ifr, &sc->sc_ec) :
ether_delmulti(ifr, &sc->sc_ec);

if (error == ENETRESET) {

to this,

if ((error = ether_ioctl(ifp, cmd, data)) == ENETRESET) {

which does the same thing.

(A bazillion is a very large number. This seems to make the i386
ALL kernel smaller by 3kB to 4kB.)

Use ifreq_getaddr() twice in es(4).

Whitespace nits.
 1.29 09-Jul-2007  ad branches: 1.29.4; 1.29.8; 1.29.10;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements
 1.28 04-Mar-2007  christos branches: 1.28.2; 1.28.4; 1.28.10;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.27 07-Sep-2006  dogcow branches: 1.27.8;
remove more vestiges of CCITT, LLC, HDLC, NS, and NSIP.
 1.26 24-Dec-2005  perry branches: 1.26.4; 1.26.8;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.
 1.25 11-Dec-2005  christos merge ktrace-lwp.
 1.24 26-Jan-2005  kleink branches: 1.24.6;
MPC601: Use RTC instead of TB. (While I'm here, update these to use
the inline versions from <powerpc/cpu.h>).
 1.23 30-Oct-2004  thorpej branches: 1.23.4; 1.23.6;
When adding/deleting multicast addresses, only whack the address
filter if the interface is marked RUNNING.

Fixes kern/27678.
 1.22 24-Aug-2003  chs branches: 1.22.4;
recognize the latest version of the GMAC.
 1.21 15-Jul-2003  lukem __KERNEL_RCSID()
 1.20 03-May-2003  wiz branches: 1.20.2;
DMA, not dma nor Dma.
 1.19 02-Oct-2002  thorpej Use CFATTACH_DECL().
 1.18 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.17 05-Mar-2002  itojun bring in latest ALTQ from kjc. ALTQify some of the drivers.
 1.16 16-Jan-2002  thorpej Use bpf_mtap().
 1.15 26-Jul-2001  mjl branches: 1.15.6;
Add rnd entropy gathering.
 1.14 22-Jul-2001  wiz bcopy -> memcpy, bzero -> memset, bcmp -> memcmp.
Reviewed by Matt Thomas, ok'd by Tsubai Masanari.
 1.13 17-Jun-2001  tsubai branches: 1.13.2;
Support the new iBook.
 1.12 24-Apr-2001  tsubai Make sure free rx buffers have GMAC_OWN set.
 1.11 20-Apr-2001  matt After finishing with the received descriptor, make sure to "eieio" to make
sure the OWN gets back to the gmac in the proper order. This reduces (and
maybe even fixes) the gm0 out-of-order problem.
 1.10 28-Dec-2000  sommerfeld branches: 1.10.2;
Change pci_intr_map to get interrupt source information from a "struct
pci_attach_args *" instead of from four separate parameters which in
all cases were extracted from the same "struct pci_attach_args".

This both simplifies the driver api, and allows for alternate PCI
interrupt mapping schemes, such as one using the tables described in
the Intel Multiprocessor Spec which describe interrupt wirings for
devices behind pci-pci bridges based on the device's location rather
the bridge's location.

Tested on alpha and i386; welcome to 1.5Q
 1.9 15-Nov-2000  thorpej branches: 1.9.2;
Move bpfattach()/bpfdetach() calls into ether_ifattach()/ether_ifdetach().
 1.8 29-Jun-2000  mrg remove include of <vm/vm.h>. <vm/vm.h> -> <uvm/uvm_extern.h>
 1.7 16-Jun-2000  tsubai branches: 1.7.2;
Use ether_crc32_le().
 1.6 15-Jun-2000  tsubai Implement multicast address filter. (Stolen from hme.c)
 1.5 02-Apr-2000  tsubai branches: 1.5.2;
Make this compile again.
 1.4 26-Mar-2000  tsubai Use ring buffer on tx side, too.
 1.3 23-Mar-2000  thorpej New callout mechanism with two major improvements over the old
timeout()/untimeout() API:
- Clients supply callout handle storage, thus eliminating problems of
resource allocation.
- Insertion and removal of callouts is constant time, important as
this facility is used quite a lot in the kernel.

The old timeout()/untimeout() API has been removed from the kernel.
 1.2 04-Mar-2000  tsubai Use ring buffer on tx side, too.
 1.1 27-Feb-2000  tsubai Initial version of gmac ethernet driver.
XXX doesn't work well yet.
 1.5.2.1 22-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.7.2.1 18-Jun-2001  jhawk Pull up revision 1.13 (requested by tsubai):
Support the new dual USB iBook.
 1.9.2.5 23-Apr-2001  bouyer Sync with HEAD.
 1.9.2.4 05-Jan-2001  bouyer Sync with HEAD
 1.9.2.3 22-Nov-2000  bouyer Sync with HEAD.
 1.9.2.2 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.9.2.1 15-Nov-2000  bouyer file if_gm.c was added on branch thorpej_scsipi on 2000-11-20 20:12:56 +0000
 1.10.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.13.2.4 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.13.2.3 16-Mar-2002  jdolecek Catch up with -current.
 1.13.2.2 11-Feb-2002  jdolecek Sync w/ -current.
 1.13.2.1 03-Aug-2001  lukem update to -current
 1.15.6.4 18-Oct-2002  nathanw Catch up to -current.
 1.15.6.3 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.15.6.2 28-Feb-2002  nathanw Catch up to -current.
 1.15.6.1 26-Jul-2001  nathanw file if_gm.c was added on branch nathanw_sa on 2002-02-28 04:10:39 +0000
 1.20.2.5 04-Feb-2005  skrll Sync with HEAD.
 1.20.2.4 02-Nov-2004  skrll Sync with HEAD.
 1.20.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.20.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.20.2.1 03-Aug-2004  skrll Sync with HEAD
 1.22.4.1 24-Jan-2005  he Pull up revision 1.23 (requested by thorpej in ticket #939):
When adding or deleting multicast addresses, only change
the address filter if the interface is marked RUNNING.
Fixes PR#27678.
 1.23.6.1 12-Feb-2005  yamt sync with head.
 1.23.4.1 29-Apr-2005  kent sync with -current
 1.24.6.4 21-Jan-2008  yamt sync with head
 1.24.6.3 03-Sep-2007  yamt sync with head.
 1.24.6.2 30-Dec-2006  yamt sync with head.
 1.24.6.1 21-Jun-2006  yamt sync with head.
 1.26.8.1 14-Sep-2006  yamt sync with head.
 1.26.4.1 09-Sep-2006  rpaulo sync with head
 1.27.8.1 12-Mar-2007  rmind Sync with HEAD.
 1.28.10.2 03-Oct-2007  garbled Sync with HEAD
 1.28.10.1 02-Aug-2007  macallan sync with HEAD
 1.28.4.1 11-Jul-2007  mjf Sync with head.
 1.28.2.2 09-Oct-2007  ad Sync with head.
 1.28.2.1 15-Jul-2007  ad Sync with head.
 1.29.10.3 23-Mar-2008  matt sync with HEAD
 1.29.10.2 09-Jan-2008  matt sync with HEAD
 1.29.10.1 06-Nov-2007  matt sync with HEAD
 1.29.8.1 03-Sep-2007  jmcneill Sync with HEAD.
 1.29.4.1 03-Sep-2007  skrll Sync with HEAD.
 1.31.8.2 20-Jan-2008  bouyer Sync with HEAD
 1.31.8.1 02-Jan-2008  bouyer Sync with HEAD
 1.31.2.1 18-Feb-2008  mjf Sync with HEAD.
 1.33.18.2 28-Apr-2009  skrll Sync with HEAD.
 1.33.18.1 19-Jan-2009  skrll Sync with HEAD.
 1.33.16.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.33.10.3 11-Aug-2010  yamt sync with head.
 1.33.10.2 11-Mar-2010  yamt sync with head
 1.33.10.1 04-May-2009  yamt sync with head.
 1.33.6.1 17-Jan-2009  mjf Sync with HEAD.
 1.34.4.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.37.4.1 30-May-2010  rmind sync with head
 1.37.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.38.6.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.39.2.3 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.39.2.2 30-Oct-2012  yamt sync with head
 1.39.2.1 17-Apr-2012  yamt sync with head
 1.40.2.1 18-Feb-2012  mrg merge to -current.
 1.42.4.1 18-May-2014  rmind sync with head
 1.42.2.2 03-Dec-2017  jdolecek update from HEAD
 1.42.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.43.2.1 07-Apr-2014  tls Be a little more clear and consistent about harvesting entropy from devices:

1) deprecate RND_FLAG_NO_ESTIMATE

2) define RND_FLAG_COLLECT_TIME, RND_FLAG_COLLECT_VALUE

3) define RND_FLAG_ESTIMATE_TIME, RND_FLAG_ESTIMATE_VALUE

4) define RND_FLAG_DEFAULT: RND_FLAG_COLLECT_TIME|
RND_FLAG_COLLECT_VALUE|RND_FLAG_ESTIMATE_TIME

5) Make entropy harvesting from environmental sensors a little more generic
and remove it from individual sensor drivers.

6) Remove individual open-coded delta-estimators for values from a few
places in the tree (uvm, environmental drivers).

7) 0 -> RND_FLAG_DEFAULT, actually gather entropy from various drivers
that had stubbed out code, other minor cleanups.
 1.44.4.4 05-Feb-2017  skrll Sync with HEAD
 1.44.4.3 09-Jul-2016  skrll Sync with HEAD
 1.44.4.2 19-Mar-2016  skrll Sync with HEAD
 1.44.4.1 06-Jun-2015  skrll Sync with HEAD
 1.47.2.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.49.14.2 26-Jan-2019  pgoyette Sync with HEAD
 1.49.14.1 28-Jul-2018  pgoyette Sync with HEAD
 1.50.2.3 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.50.2.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.50.2.1 10-Jun-2019  christos Sync with HEAD
 1.56.2.1 29-Feb-2020  ad Sync with head.
 1.57.6.1 03-Apr-2021  thorpej Sync with HEAD.
 1.3 15-Jun-2000  tsubai branches: 1.3.4;
Forgot to commit this.
 1.2 26-Mar-2000  tsubai branches: 1.2.2;
Use ring buffer on tx side, too.
 1.1 27-Feb-2000  tsubai Initial version of gmac ethernet driver.
XXX doesn't work well yet.
 1.2.2.1 22-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.3.4.2 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.3.4.1 15-Jun-2000  bouyer file if_gmreg.h was added on branch thorpej_scsipi on 2000-11-20 20:12:57 +0000
 1.29 04-Oct-2025  thorpej Add a shared function to query the common properties used for configuring
an Ethernet address.
 1.28 16-Feb-2022  riastradh powerpc: Sprinkle "memory" clobbers on eieio and nearby asm blocks.

Otherwise the compiler may reorder these around loads and stores,
which mostly defeats the purpose. `asm volatile' just ensures the
instruction isn't _deleted_; it may still move around.
 1.27 05-Mar-2021  rin Convert to intr_establish_xname().
 1.26 05-Dec-2019  msaitoh branches: 1.26.8;
Revert if_mc.c rev. 1.25. It's not required to check ifm->ifm_cur->ifm_media
instead of ifm->ifm_media.
 1.25 04-Dec-2019  msaitoh Fix macppc/dev/if_mc.c::mc_mediachange(). Not tested.

ifmedia_change() is used to change the device's media setting from
user-selected media. The user-selected media is not sc->sc_media.ifm_media but
sc->sc_media.ifm_cur->ifm_media. Note that mc_mediachange() is not called from
anywhere because it's disabled with #ifdef NOTYET.
 1.24 25-Apr-2019  msaitoh No functional change:
- Use __arraycount().
- u_int_{8,16,32}_t -> uint_{8,16,32}_t
- KNF.
- Tabify.
- Remove extra space.
 1.23 15-Jul-2016  macallan branches: 1.23.16;
adjust to dbdma changes
 1.22 26-Jul-2011  macallan branches: 1.22.12; 1.22.30; 1.22.34;
finish device_t-ification
 1.21 01-Jul-2011  dyoung #include <sys/bus.h> instead of <machine/bus.h>.
 1.20 30-Jun-2011  matt Modify mapiodev to take a third argument indicating whether the space
should be prefetchable (true) or not (false).
 1.19 18-Jun-2011  matt struct device * -> device_t
struct cfdata * -> cfdata_t
use device accessors, use device_private.
some softc/device_t splits (macppc needs a bunch more)
aprint*_dev used considerably more
 1.18 20-Dec-2010  matt branches: 1.18.6;
Move counting of faults, traps, intrs, soft[intr]s, syscalls, and nswtch
from uvmexp to per-cpu cpu_data and move them to 64bits. Remove unneeded
includes of <uvm/uvm_extern.h> and/or <uvm/uvm.h>.
 1.17 14-Mar-2009  dsl branches: 1.17.4;
ANSIfy another 1261 function definitions.
The only ones left in sys are beyond by sed script!
(or in sys/dist or sys/external)
Mostly they have function pointer parameters.
 1.16 14-Mar-2009  dsl Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.15 14-Mar-2009  dsl Remove all the __P() from sys (excluding sys/dist)
Diff checked with grep and MK1 eyeball.
i386 and amd64 GENERIC and sys still build.
 1.14 05-Oct-2008  macallan branches: 1.14.2; 1.14.8;
fix bus_spacification botch
from Marco Trillo in PR39696
 1.13 17-Oct-2007  garbled branches: 1.13.16; 1.13.20; 1.13.22; 1.13.26;
Merge the ppcoea-renovation branch to HEAD.

This branch was a major cleanup and rototill of many of the various OEA
cpu based PPC ports that focused on sharing as much code as possible
between the various ports to eliminate near-identical copies of files in
every tree. Additionally there is a new PIC system that unifies the
interface to interrupt code for all different OEA ppc arches. The work
for this branch was done by a variety of people, too long to list here.

TODO:
bebox still needs work to complete the transition to -renovation.
ofppc still needs a bunch of work, which I will be looking at.
ev64260 still needs to be renovated
amigappc was not attempted.

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.12 04-Mar-2007  christos branches: 1.12.2; 1.12.10; 1.12.18; 1.12.20; 1.12.22; 1.12.24;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.11 24-Dec-2005  perry branches: 1.11.26;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.
 1.10 11-Dec-2005  christos merge ktrace-lwp.
 1.9 15-Jul-2003  lukem branches: 1.9.16;
__KERNEL_RCSID()
 1.8 02-Apr-2003  thorpej branches: 1.8.2;
Use PAGE_SIZE rather than NBPG.
 1.7 02-Oct-2002  thorpej Use CFATTACH_DECL().
 1.6 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.5 22-Jul-2001  wiz branches: 1.5.6;
bcopy -> memcpy, bzero -> memset, bcmp -> memcmp.
Reviewed by Matt Thomas, ok'd by Tsubai Masanari.
 1.4 08-Jun-2001  matt branches: 1.4.2;
Make macppc compile by default with -Wall -Wmissing-prototype in addition
to its currently enabled warnings. For the lack of a better place, most
global function prototype wound up in <machine/autoconf.h> unless there
was a better place for them. ofb_* structs renamed to offb_* to avoid
conflict with ofb_softc in <dev/ofw/openfirm.h>
 1.3 29-Jun-2000  mrg branches: 1.3.2;
remove include of <vm/vm.h>. <vm/vm.h> -> <uvm/uvm_extern.h>
 1.2 30-May-1998  tsubai branches: 1.2.14;
Remove unnecessary cache flush.
 1.1 15-May-1998  tsubai Initial import of macppc port.
 1.2.14.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.3.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.4.2.2 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.4.2.1 03-Aug-2001  lukem update to -current
 1.5.6.2 18-Oct-2002  nathanw Catch up to -current.
 1.5.6.1 22-Jul-2001  nathanw file if_mc.c was added on branch nathanw_sa on 2002-10-18 02:38:35 +0000
 1.8.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.8.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.8.2.1 03-Aug-2004  skrll Sync with HEAD
 1.9.16.3 27-Oct-2007  yamt sync with head.
 1.9.16.2 03-Sep-2007  yamt sync with head.
 1.9.16.1 21-Jun-2006  yamt sync with head.
 1.11.26.1 12-Mar-2007  rmind Sync with HEAD.
 1.12.24.1 25-Oct-2007  bouyer Sync with HEAD.
 1.12.22.1 18-Oct-2007  yamt sync with head.
 1.12.20.1 06-Nov-2007  matt sync with HEAD
 1.12.18.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.12.10.2 07-Jun-2007  garbled Convert macppc to powerpc bus_space. Lots of work here from Matt Thomas,
as well as the common ofwoea code from myself. Compile tested only,
still probably needs some fine tuning.

Also in this commit:
Convert macppc to new shared ofwoea routines.
Lots of KNF.
 1.12.10.1 11-May-2007  macallan request the correct interrupt type in a couple drivers - necessary since
these days we actually do something with the type argument
 1.12.2.1 23-Oct-2007  ad Sync with head.
 1.13.26.1 19-Oct-2008  haad Sync with HEAD.
 1.13.22.1 10-Oct-2008  skrll Sync with HEAD.
 1.13.20.1 04-May-2009  yamt sync with head.
 1.13.16.1 05-Oct-2008  mjf Sync with HEAD.
 1.14.8.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.14.2.1 28-Apr-2009  skrll Sync with HEAD.
 1.17.4.1 05-Mar-2011  rmind sync with head
 1.18.6.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.22.34.1 26-Jul-2016  pgoyette Sync with HEAD
 1.22.30.1 05-Oct-2016  skrll Sync with HEAD
 1.22.12.1 03-Dec-2017  jdolecek update from HEAD
 1.23.16.1 10-Jun-2019  christos Sync with HEAD
 1.26.8.1 03-Apr-2021  thorpej Sync with HEAD.
 1.14 18-Sep-2022  thorpej Eliminate use of IFF_OACTIVE.
 1.13 26-Jul-2011  macallan finish device_t-ification
 1.12 14-Mar-2009  dsl Remove all the __P() from sys (excluding sys/dist)
Diff checked with grep and MK1 eyeball.
i386 and amd64 GENERIC and sys still build.
 1.11 05-Mar-2007  tsutsui branches: 1.11.44; 1.11.52; 1.11.58;
Use (uint8_t *) for RX buffer.
 1.10 24-Dec-2005  perry branches: 1.10.26;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.
 1.9 11-Dec-2005  christos merge ktrace-lwp.
 1.8 15-Jan-2005  briggs branches: 1.8.10;
Drop default RX bufs to 2 so that they fit in one page of RAM.
Located by Tim Kelly. Also discussed on port-macppc with Dave Huang.
XXX -- This driver really needs to be introduced to bus_dma(9).
 1.7 09-Apr-2003  thorpej branches: 1.7.2;
Use PAGE_SIZE rather than NBPG.
 1.6 26-Jul-2001  tsubai branches: 1.6.6;
Fix a warning when compiled w/o DDB.
 1.5 11-Jul-2001  briggs Allow build with KGDB defined.
 1.4 30-May-2001  mrg branches: 1.4.2;
use _KERNEL_OPT
 1.3 03-Sep-1998  tsubai branches: 1.3.24;
Change void mcintr() to int mcintr().
 1.2 04-Jul-1998  jonathan defopt DDB.
 1.1 15-May-1998  tsubai Initial import of macppc port.
 1.3.24.1 21-Jun-2001  nathanw Catch up to -current.
 1.4.2.1 03-Aug-2001  lukem update to -current
 1.6.6.2 26-Jul-2001  tsubai Fix a warning when compiled w/o DDB.
 1.6.6.1 26-Jul-2001  tsubai file if_mcvar.h was added on branch nathanw_sa on 2001-07-26 11:23:38 +0000
 1.7.2.1 17-Jan-2005  skrll Sync with HEAD.
 1.8.10.2 03-Sep-2007  yamt sync with head.
 1.8.10.1 21-Jun-2006  yamt sync with head.
 1.10.26.1 12-Mar-2007  rmind Sync with HEAD.
 1.11.58.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.11.52.1 28-Apr-2009  skrll Sync with HEAD.
 1.11.44.1 04-May-2009  yamt sync with head.
 1.25 05-Mar-2021  rin Convert to intr_establish_xname().
 1.24 27-Oct-2012  chs branches: 1.24.50;
split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.23 01-Jul-2011  dyoung branches: 1.23.2; 1.23.12;
#include <sys/bus.h> instead of <machine/bus.h>.
 1.22 18-Jun-2011  matt struct device * -> device_t
struct cfdata * -> cfdata_t
use device accessors, use device_private.
some softc/device_t splits (macppc needs a bunch more)
aprint*_dev used considerably more
 1.21 16-Dec-2010  macallan branches: 1.21.6;
finish device_t-ification, now it works again
 1.20 01-Dec-2010  he Follow up the changes done to wivar.h -- the consequence here is that
instead of a _disable and _enable routine, we have a single _enable which
takes a flag, and has a slightly different function signature.
Macppc kernels should build again.
 1.19 26-Sep-2008  macallan branches: 1.19.16;
Use access functions to mess with FCRs, GPIOs etc. in order to avoid
multiple mappings of obio's register space.
This needs testing.
 1.18 10-Sep-2008  macallan get rid if some mistyped magic number, spotted by Marco Trillo
While there map only the space we actually need.
Needs to be tested on actual hardware.
 1.17 11-Dec-2007  macallan branches: 1.17.6; 1.17.10; 1.17.12; 1.17.16;
make this compile again
 1.16 09-Dec-2007  jmcneill branches: 1.16.2;
Merge jmcneill-pm branch.
 1.15 22-Oct-2007  macallan branches: 1.15.4; 1.15.6;
fix bus_spacification fallout
from KIYOHARA Takashi
 1.14 17-Oct-2007  garbled Merge the ppcoea-renovation branch to HEAD.

This branch was a major cleanup and rototill of many of the various OEA
cpu based PPC ports that focused on sharing as much code as possible
between the various ports to eliminate near-identical copies of files in
every tree. Additionally there is a new PIC system that unifies the
interface to interrupt code for all different OEA ppc arches. The work
for this branch was done by a variety of people, too long to list here.

TODO:
bebox still needs work to complete the transition to -renovation.
ofppc still needs a bunch of work, which I will be looking at.
ev64260 still needs to be renovated
amigappc was not attempted.

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.13 24-Sep-2006  jmcneill branches: 1.13.8; 1.13.16; 1.13.26; 1.13.28; 1.13.30; 1.13.32;
Add "name" parameter to powerhook_establish, to aid debugging. No objections
on tech-kern@
 1.12 11-Dec-2005  christos branches: 1.12.20; 1.12.22;
merge ktrace-lwp.
 1.11 23-Jun-2005  jmmv branches: 1.11.2;
Let this build again by removing ieee80211_compat.h's inclusion (which does
not exist any more).
 1.10 07-Aug-2004  mycroft Don't pass in a MAC address -- yet.
 1.9 07-Dec-2003  dyoung Enable RSSI-based rate-adaptation for wi(4). This enables wi(4)-based
APs to run at "full speed" where before they ran at just 1 or 2Mb/s.
The AP will adapt the data rate for each client based on packet
losses and the received signal strength.

I have also enabled rate adaptation for STA mode and for IBSS mode,
but the hardware gives us less control over the data rate in those
modes.
 1.8 16-Nov-2003  dyoung Add data-link type DLT_IEEE802_11_RADIO to wi and atw. DLT_IEEE802_11_RADIO
lets you monitor radio stats like received signal strength, which
diversity antenna was used, channel/frequency, modulation, and data
rate.
 1.7 13-Oct-2003  dyoung Switch wi(4) to the new 802.11 layer.
 1.6 15-Jul-2003  lukem __KERNEL_RCSID()
 1.5 09-Jul-2003  he After the recent changes to if_ieee80211.h, we need to include
if_media.h earlier.
 1.4 02-Oct-2002  jdolecek branches: 1.4.6;
adapt to latest dev/ic/wi* changes
 1.3 02-Oct-2002  thorpej Use CFATTACH_DECL().
 1.2 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.1 16-May-2001  tsubai branches: 1.1.2; 1.1.4; 1.1.10;
Add AirMac frontend.
 1.1.10.2 18-Oct-2002  nathanw Catch up to -current.
 1.1.10.1 16-May-2001  nathanw file if_wi_obio.c was added on branch nathanw_sa on 2002-10-18 02:38:35 +0000
 1.1.4.1 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.1.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.4.6.5 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.4.6.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.4.6.3 18-Sep-2004  skrll Sync with HEAD.
 1.4.6.2 12-Aug-2004  skrll Sync with HEAD.
 1.4.6.1 03-Aug-2004  skrll Sync with HEAD
 1.11.2.3 21-Jan-2008  yamt sync with head
 1.11.2.2 27-Oct-2007  yamt sync with head.
 1.11.2.1 30-Dec-2006  yamt sync with head.
 1.12.22.1 22-Oct-2006  yamt sync with head
 1.12.20.1 18-Nov-2006  ad Sync with head.
 1.13.32.2 13-Nov-2007  bouyer Sync with HEAD
 1.13.32.1 25-Oct-2007  bouyer Sync with HEAD.
 1.13.30.1 18-Oct-2007  yamt sync with head.
 1.13.28.2 09-Jan-2008  matt sync with HEAD
 1.13.28.1 06-Nov-2007  matt sync with HEAD
 1.13.26.4 08-Dec-2007  jmcneill Rename pnp(9) -> pmf(9), as requested by many.
 1.13.26.3 06-Nov-2007  joerg Refactor PNP API:
- Make suspend/resume directly a device functionality. It consists of
three layers (class logic, device logic, bus logic), all of them being
optional. This replaces D0/D3 transitions.
- device_is_active returns true if the device was not disabled and was
not suspended (even partially), device_is_enabled returns true if the
device was enabled.
- Change pnp_global_transition into pnp_system_suspend and
pnp_system_resume. Before running any suspend/resume handlers, check
that all currently attached devices support power management and bail
out otherwise. The latter is not done for the shutdown/panic case.
- Make the former bus-specific generic network handlers a class handler.
- Make PNP message like volume up/down/toogle PNP events. Each device
can register what events they are interested in and whether the handler
should be global or not.
- Introduce device_active API for devices to mark themselve in use from
either the system or the device. Use this to implement the idle handling
for audio and input devices. This is intended to replace most ad-hoc
watchdogs as well.
- Fix somes situations in which audio resume would lose mixer settings.
- Make USB host controllers better deal with suspend in the light of
shared interrupts.
- Flush filesystem cache on suspend.
- Flush disk caches on suspend. Put ATA disks into standby on suspend as
well.
- Adopt drivers to use the new PNP API.
- Fix a critical bug in the generic cardbus layer that made D0->D3
break.
- Fix ral(4) to set if_stop.
- Convert cbb(4) to the new PNP API.
- Apply the PCI Express SCI fix on resume again.
 1.13.26.2 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.13.26.1 04-Sep-2007  joerg Convert wi(4) to jmcneill-pm style power management.
 1.13.16.1 07-Jun-2007  garbled Convert macppc to powerpc bus_space. Lots of work here from Matt Thomas,
as well as the common ofwoea code from myself. Compile tested only,
still probably needs some fine tuning.

Also in this commit:
Convert macppc to new shared ofwoea routines.
Lots of KNF.
 1.13.8.2 03-Dec-2007  ad Sync with HEAD.
 1.13.8.1 23-Oct-2007  ad Sync with head.
 1.15.6.2 13-Dec-2007  yamt sync with head.
 1.15.6.1 11-Dec-2007  yamt sync with head.
 1.15.4.1 26-Dec-2007  ad Sync with head.
 1.16.2.1 13-Dec-2007  bouyer Sync with HEAD
 1.17.16.1 19-Oct-2008  haad Sync with HEAD.
 1.17.12.2 10-Oct-2008  skrll Sync with HEAD.
 1.17.12.1 24-Sep-2008  wrstuden Merge in changes between wrstuden-revivesa-base-2 and
wrstuden-revivesa-base-3.
 1.17.10.1 04-May-2009  yamt sync with head.
 1.17.6.1 28-Sep-2008  mjf Sync with HEAD.
 1.19.16.1 05-Mar-2011  rmind sync with head
 1.21.6.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.23.12.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.23.2.1 30-Oct-2012  yamt sync with head
 1.24.50.1 03-Apr-2021  thorpej Sync with HEAD.
 1.5 28-Mar-1999  tsubai Remove unused files.
 1.4 12-Mar-1999  perry exterminate ovbcopy. patches provided by Erik Bertelsen, pr-7145
 1.3 13-Jul-1998  tsubai Revert to previous version.
Use ROM font.
 1.2 02-Jul-1998  tsubai Console support.
 1.1 15-May-1998  tsubai Initial import of macppc port.
 1.2 28-Mar-1999  tsubai Remove unused files.
 1.1 15-May-1998  tsubai Initial import of macppc port.
 1.42 20-Dec-2023  thorpej Remove unnecessary <sys/malloc.h>.
 1.41 05-Mar-2021  rin Convert to intr_establish_xname().
 1.40 03-Sep-2018  riastradh branches: 1.40.12;
Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)
 1.39 01-Mar-2018  macallan branches: 1.39.2; 1.39.4;
match K2 UATA, found in some G5
 1.38 20-Oct-2017  jdolecek move ata_queue_alloc(1) and ata_queue_free() calls to ata_channel_init()
and ata_channel_destroy() respectively, to make attachment code simpler,
and to make it easier to spot special queue manipulation like cmdide(4)

on topic of PR kern/52606
 1.37 07-Oct-2017  jdolecek Merge support for SATA NCQ (Native Command Queueing) from jdolecek-ncq branch

ATA subsystem was changed to support several outstanding commands, and use
NCQ xfers if supported by both the controller and the disk, including NCQ
error recovery. Set NCQ high priority for BPRIO_TIMECRITICAL xfers
if supported. Added FUA support.

Done some work towards MP-safe, all ATA code tsleep()/wakeup() replaced
by condvars, and switched most code from spl* to mutexes (separate
wd(4) and ata channel lock).

Introduced new option WD_CHAOS_MONKEY to facilitate testing of error
handling, fixed several uncovered issues. Also fixed several problems
with kernel dump to wd(4) disk.

Tested with ahcisata(4), mvsata(4), siisata(4), piixide(4) on amd64,
with and without port multiplier, both disk and ATAPI devices; other
drivers and archs mechanically adjusted and compile-tested. NCQ is
supported for ahcisata(4) and siisata(4) for any controller, for
mvsata(4) only Gen IIe ones for now. Also enabled ATAPI support in
mvsata(4).

Thanks to Matt Thomas for initial ATA infrastructure patch, and
Jonathan A.Kollasch for siisata(4) NCQ changes and general testing.

Also fixes PR kern/43169 (wd(4)); and PR kern/11811, PR kern/47041,
PR kern/51979 (kernel dump)
 1.36 15-Jul-2016  macallan branches: 1.36.4;
adjust to dbdma changes
 1.35 29-Mar-2014  christos branches: 1.35.6; 1.35.10;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.34 28-Apr-2013  macallan branches: 1.34.4;
make this work on G5
from Phileas Fogg, interrupt fixup from me
 1.33 31-Jul-2012  bouyer branches: 1.33.2;
Apply back changes that were reverted on Jul 24 and Jul 26 (general ata/wdc
cleanup and SATA PMP support), now that I'm back to fix the fallouts.
 1.32 26-Jul-2012  jakllsch Revert, with intention of restoring in a less invasive way, the SATA Port
Multiplier code.

ok christos@
 1.31 24-Jul-2012  jakllsch Revert dsl@'s changes of Sun, 15 Jul 2012 10:55:35 +0000 and
Sun, 15 Jul 2012 10:56:50 +0000, excepting the kernel version bump.
First step in reverting regressions to ata(4) subsystem during the addition of
port multiplier support.
 1.30 15-Jul-2012  dsl Some namespace protection (and add greppablity).
Prefix the DRIVE_ and DRIVET_ constants from atavar.h with ATA_.
Don't use an enum for drive_type - you don't know how big it will be.
Move driver_type to avoid implicit structure padding (esp on arm).
This change is purely lexical and mechanical.

Update to 6.99.9 - this wasn't done when the SATA PMP changes
were made - I'm sure they warranted a bump.
 1.29 02-Jul-2012  bouyer Add sata Port MultiPlier (PMP) support to the ata bus layer,
as described in
http://mail-index.netbsd.org/tech-kern/2012/06/23/msg013442.html
PMP support in integrated to the atabus layer.
struct ata_channel's ch_drive[] is not dynamically allocated, and ch_ndrive
(renamed to ch_ndrives) closely reflects the size of the ch_drive[] array.
Add helper functions atabus_alloc_drives() and atabus_free_drives()
to manage ch_drive[]/ch_ndrives.
Add wdc_maxdrives to struct wdc_softc so that bus front-end can specify
how much drive they really support (master/slave or single).
ata_reset_drive() callback gains a uint32_t *sigp argument which,
when not NULL, will contain the signature of the device being reset.
While there, some cosmetic changes:
- added a drive_type enum to ata_drive_datas, and stop encoding the
probed drive type in drive_flags (we were out of drive flags anyway).
- rename DRIVE_ATAPIST to DRIVE_ATAPIDSCW to better reflect what this
really is
- remove ata_channel->ata_drives, it's redundant with the pointer in
ata_drive_datas
- factor out the interpretation of SATA signatures in sata_interpet_sig()

propagate these changes to the ATA HBA drivers, and add support for PMP
to ahcisata(4) and siisata(4).

Thanks to:
- Protocase (http://www.protocase.com/) which provided a system
with lots of controllers, SATA PMP and drive slots
- Conservation Genomics Laboratory, Department of Biology, New Mexico State
University for hosting the above system
- Brook Milligan, who set up remote access and has been very responsive
when SATA cable move was needed
 1.28 01-Jul-2011  dyoung branches: 1.28.2;
#include <sys/bus.h> instead of <machine/bus.h>.
 1.27 18-Nov-2009  dyoung wdcactivate() is gone, don't use it.
 1.26 28-Jul-2008  macallan Fix remaining register offset shifting left over from proper bus_space-ification
done a while ago. From Marco Trillo.
This should fix PR 39176.
 1.25 02-Jul-2008  macallan branches: 1.25.2;
actually initialize sc_dmacmd and get rid of getnodebypci() - use
pcidev_to_ofdev() instead
noticed by Marco Trillo, tested on my iBook G4
 1.24 25-May-2008  chs branches: 1.24.2;
recognize the variant found in the last model of powermac G5.
 1.23 18-Mar-2008  cube branches: 1.23.2; 1.23.4; 1.23.6;
Split device_t and softc for ATA devices, as well as wd(4). Other
cosmetic changes where appropriate.
 1.22 25-Feb-2008  matt Convert to prototypes, de'__P, use device_private, switch to aprint_*,
make things static, and some minor constification.
 1.21 17-Oct-2007  garbled branches: 1.21.12; 1.21.16;
Merge the ppcoea-renovation branch to HEAD.

This branch was a major cleanup and rototill of many of the various OEA
cpu based PPC ports that focused on sharing as much code as possible
between the various ports to eliminate near-identical copies of files in
every tree. Additionally there is a new PIC system that unifies the
interface to interrupt code for all different OEA ppc arches. The work
for this branch was done by a variety of people, too long to list here.

TODO:
bebox still needs work to complete the transition to -renovation.
ofppc still needs a bunch of work, which I will be looking at.
ev64260 still needs to be renovated
amigappc was not attempted.

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.20 25-Jun-2007  aymeric branches: 1.20.8; 1.20.10; 1.20.12; 1.20.14;
Recognize the Intrepid2 ATA controller. Needed at least for the last PB G4
 1.19 16-Jan-2006  bouyer branches: 1.19.28; 1.19.30; 1.19.36;
properly use ata_channel->ch_ndrive:
- initialize it properly in the bus front-ends (all 2, exept in wdc_pcmcia.c
for the "Sandisk CompactFlash Card" where it's set to 1)
- remplace hardcoded '2' by ata_channel->ch_ndrive in MI IDE drivers.

From Christos Zoulas in kern/32501.
 1.18 11-Dec-2005  christos branches: 1.18.2;
merge ktrace-lwp.
 1.17 25-Nov-2004  manu branches: 1.17.12;
For and from bouyer@: call wdc_init_shadow_reg(chp) only after chp has
been initialized. Cause the hard disk to be detected again on the iBook G4,
and probably other machines.

Weee, I can run -current again!
 1.16 20-Aug-2004  thorpej Move most of wdc_softc into a new atac_softc structure that contains
info common to all types of ATA controllers.
 1.15 14-Aug-2004  thorpej - Split the register handles out of struct wdc_channel into a separate
wdc_regs structure, and array of which (indexed per channel) is pointed
to by struct wdc_softc.
- Move the resulting wdc_channel structure to atavar.h and rename it to
ata_channel. Rename the corresponding flags.
- Add a "ch_ndrive" member to struct ata_channel, which indicates the
maximum number of drives that can be present on the channel. For now,
this is always 2. Add an ATA_MAXDRIVES constant that places an upper
limit on this value, also currently 2.
 1.14 13-Aug-2004  thorpej Don't bother with bits that tell of the presence of optional callbacks;
just check the function pointers for NULL.
 1.13 25-May-2004  thorpej Add the notion of "shadow registers" to the wdc driver. These shadow
registers are registers that overlap with others on many controllers, but
which may actually be distinct on some controllers. Right now, the two
shadows are:

- wd_status (usually overlaps wd_command)
- wd_features (usually overlaps wd_error)

Add a new helper function, wdc_init_shadow_regs(), used to initialize
the shadow register handles on controllers where they do actually overlap.

Partially from Jordan Rhody @ Wasabi Systems, Inc.
 1.12 04-Jan-2004  dbj attempt to make these compile again after recent wdc changes.
 1.11 03-Jan-2004  thorpej More wdc_channel structure member namespace cleanup:
- channel -> ch_channel
- wdc -> ch_wdc
 1.10 03-Jan-2004  thorpej Rename "struct channel_softc" to "struct wdc_channel".
 1.9 01-Jan-2004  thorpej Rename:
- wdc_xfer to ata_xfer
- channel_queue to ata_queue
and move them to <dev/ata/atavar.h> so they can be used by non-wdc ATA
controllers. Clean up the member names of these structures while at it.
 1.8 31-Dec-2003  thorpej Simplify allocation of the channel queue.
 1.7 03-Dec-2003  bouyer Adapt for new wdc regiosters array. Should fix port-macppc/23604.
 1.6 08-Oct-2003  bouyer Adapt for wdcattach() prototype change, and deal with atabus in
device_register().
 1.5 25-Sep-2003  mycroft Hide the use of config_interrupts() in one place.
 1.4 19-Sep-2003  mycroft 1) Use config_interrupts() to attach IDE and ATAPI drives. This eliminates
most polling.
2) Clean up some goofiness in pciide -- get rid of the whole "candisable" path
(it's gratuitous) and simplify the code by calling pciide_map_compat_intr(),
*_set_modes() and wdc_print_modes() from central locations.
3) Add a register writability and register ghost test to eliminate phantom
drives more quickly.
 1.3 17-Aug-2003  chs recognize the product ID used on the latest G4s.
 1.2 15-Jul-2003  lukem __KERNEL_RCSID()
 1.1 11-Jun-2003  hamajima branches: 1.1.2; 1.1.4;
Support the PowerBook G4 12-inch (and maybe 17-inch).
Kauai ATA, new obio chip, and Japanese keymap for WSDISPLAY_COMPAT_RAWKBD

I tested only 12-inch Japanese model.
 1.1.4.5 29-Nov-2004  skrll Sync with HEAD.
 1.1.4.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.1.4.3 18-Sep-2004  skrll Sync with HEAD.
 1.1.4.2 25-Aug-2004  skrll Sync with HEAD.
 1.1.4.1 03-Aug-2004  skrll Sync with HEAD
 1.1.2.3 19-Jun-2003  grant Apply patch (requested by hamajima in ticket #1323):

patch for before devsw.
 1.1.2.2 19-Jun-2003  grant Create new file from rev 1.1 (requested by hamajima in ticket #1323):

Support the PowerBook G4 12-inch (and maybe 17-inch).
Kauai ATA, new obio chip, and Japanese keymap for WSDISPLAY_COMPAT_RAWKBD
 1.1.2.1 11-Jun-2003  grant file kauai.c was added on branch netbsd-1-6 on 2003-06-19 11:18:28 +0000
 1.17.12.5 24-Mar-2008  yamt sync with head.
 1.17.12.4 27-Feb-2008  yamt sync with head.
 1.17.12.3 27-Oct-2007  yamt sync with head.
 1.17.12.2 03-Sep-2007  yamt sync with head.
 1.17.12.1 21-Jun-2006  yamt sync with head.
 1.18.2.1 01-Feb-2006  yamt sync with head.
 1.19.36.5 08-Aug-2007  macallan don't make our own bus_space_tag_t anymore
 1.19.36.4 02-Aug-2007  macallan fix some more typos - now this one works on my iBook again
 1.19.36.3 02-Aug-2007  macallan sync with HEAD
 1.19.36.2 26-Jun-2007  garbled Sync with HEAD.
 1.19.36.1 07-Jun-2007  garbled Convert macppc to powerpc bus_space. Lots of work here from Matt Thomas,
as well as the common ofwoea code from myself. Compile tested only,
still probably needs some fine tuning.

Also in this commit:
Convert macppc to new shared ofwoea routines.
Lots of KNF.
 1.19.30.1 11-Jul-2007  mjf Sync with head.
 1.19.28.2 23-Oct-2007  ad Sync with head.
 1.19.28.1 15-Jul-2007  ad Sync with head.
 1.20.14.1 25-Oct-2007  bouyer Sync with HEAD.
 1.20.12.1 18-Oct-2007  yamt sync with head.
 1.20.10.2 23-Mar-2008  matt sync with HEAD
 1.20.10.1 06-Nov-2007  matt sync with HEAD
 1.20.8.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.21.16.4 28-Sep-2008  mjf Sync with HEAD.
 1.21.16.3 02-Jul-2008  mjf Sync with HEAD.
 1.21.16.2 02-Jun-2008  mjf Sync with HEAD.
 1.21.16.1 03-Apr-2008  mjf Sync with HEAD.
 1.21.12.1 24-Mar-2008  keiichi sync with head.
 1.23.6.2 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.23.6.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.23.4.2 11-Mar-2010  yamt sync with head
 1.23.4.1 04-May-2009  yamt sync with head.
 1.23.2.1 04-Jun-2008  yamt sync with head
 1.24.2.2 31-Jul-2008  simonb Sync with head.
 1.24.2.1 03-Jul-2008  simonb Sync with head.
 1.25.2.1 19-Oct-2008  haad Sync with HEAD.
 1.28.2.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.28.2.1 30-Oct-2012  yamt sync with head
 1.33.2.3 03-Dec-2017  jdolecek update from HEAD
 1.33.2.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.33.2.1 23-Jun-2013  tls resync from head
 1.34.4.1 18-May-2014  rmind sync with head
 1.35.10.1 26-Jul-2016  pgoyette Sync with HEAD
 1.35.6.1 05-Oct-2016  skrll Sync with HEAD
 1.36.4.2 27-Sep-2017  jdolecek change wdc_init_shadow_regs() to accept only struct wdc_regs, it doesn't
touch anything else

factor out the probe-only struct ata_channel initialization to wdcprobe(), to
reduce duplication of logic in individual drivers, and to actually work now
that more init is needed beyond the memset()
 1.36.4.1 24-Apr-2017  jdolecek use ata_queue_alloc() to dynamically allocate ata_queue for ata channel
 1.39.4.1 10-Jun-2019  christos Sync with HEAD
 1.39.2.1 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.40.12.1 03-Apr-2021  thorpej Sync with HEAD.
 1.44 28-Sep-2025  thorpej There are PowerMac G5 11.2 units in the wild with an OFW device tree containing
2 "i2c-bus@0" nodes on the mac-io ki2c, each containing audio codec ICs.
Work around this apparent error in the OFW device tree by skipping the channel
if it's already been initialized.

Patch provided by rin@, tweaked slightly to add a debug log breadcrumb.

PR port-macppc/59673.
 1.43 21-Sep-2025  thorpej Use direct device tree enumeration support for ki2c. Cleanly separate
the two ki2c channels rather than mixing them all together and using an
artificial i2c address bit to distinguish the channels.
 1.42 21-Sep-2025  thorpej It's no longer necessary to scan for sensor descriptive information
in the macppc i2c controller drivers; device_register() does it for
us.
 1.41 18-Sep-2025  thorpej In the "i2c-child-devices" array, don't pass in a "cookie" and "cookietype".
Instead, just create the appropriate devhandle and pass that along as a
data object.
 1.40 15-Sep-2025  thorpej Encapsulate what's needed to attach an I2C bus into a iicbus_attach()
inline.
 1.39 20-Aug-2025  macallan my Xserve G4's firmware doesn't provide sensor names, so we add them ourselves
since the fan control code needs them
 1.38 07-Jul-2025  macallan do a better job finding out openpic's base address on G4s
 1.37 05-Jul-2025  macallan deal with G5s that have two openpics by:
- checking interrupt-parent, trying to find the corresponding PIC, and adjusting
our IRQ number accordingly
- fall back to polling if we have interrupt-parent but no matching PIC
- if there is no interrupt-parent, assume we have only one PIC
... this should probably be handled by intr_establish*
 1.36 05-Jul-2025  macallan - don't enable I2C_INT_START, we don't do anything with it
- don't cv_signal() unless we are done
 1.35 05-Jul-2025  macallan use interrupts so we can sleep instead of busy waiting on i2c transfers
 1.34 30-Jun-2025  macallan deal with PowerMac7,2 sensor name encoding
 1.33 29-Jun-2022  mlelstv branches: 1.33.10;
Use old limit of 32 + 32 bytes to keep combining buffer on stack.
There are no devices on this platform that need more and for larger
values, the driver should be better rewritten.
 1.32 07-Aug-2021  thorpej branches: 1.32.2;
Merge thorpej-cfargs2.
 1.31 24-Apr-2021  thorpej branches: 1.31.2; 1.31.8;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).
 1.30 12-Jun-2020  macallan branches: 1.30.4;
more proplib API catchup
 1.29 09-Jan-2020  macallan defflag KI2C_DEBUG
 1.28 09-Jan-2020  macallan if we have more than one i2c-bus node, look for children on both
now we find the light sensor in my shiny new toy
 1.27 22-Dec-2019  thorpej branches: 1.27.2;
Cleanup i2c bus acquire / release, centralizing all of the logic into
iic_acquire_bus() / iic_release_bus(). "acquire" and "release" hooks
no longer need to be provided by back-end controller drivers (only if
they need special handling, e.g. powering on the i2c controller).
This results in the removal of a bunch of rendundant code from each
back-end controller driver.

Assert that we are not in hard interrupt context in iic_acquire_bus(),
iic_exec(), and iic_release_bus().
 1.26 15-Aug-2019  macallan pass sensor location info to drivers if we can find it
 1.25 08-Mar-2018  macallan branches: 1.25.2;
use channel info and set MODE bits accordingly instead of hoping OF set them
for us
now iic devices on different channels work properly
 1.24 24-Jan-2018  macallan branches: 1.24.2;
note to self: OF_getprop() returns -1 on error
now this works properly on sevan's iMac G4
 1.23 27-Sep-2017  macallan pass the right OF node to i2c devices
 1.22 22-Sep-2017  macallan follow sparc64 and do direct config for i2c-devices
while there, make sure we play nice with smbus single byte reads
 1.21 15-Sep-2017  macallan bus_space-ify
 1.20 05-Sep-2017  macallan first step to clean up & bus-spacification:
- use i2c addresses with the direction bit shifted out in iic_exec and when
attaching drivers so things attaching to iic* have a chance of working
- add an empty i2c-devices prop_array_t to keep drivers we don't want from
attaching to iic*
- printf -> DPRINTF / aprint_*
- usa mapiodev() for now to make this work on G5
 1.19 14-Feb-2016  chs zero the i2c_attach_args structure before filling it in.
fixes occasional crashes in iic_attach().
 1.18 26-Jul-2011  macallan branches: 1.18.12; 1.18.30;
finish device_t-ification
 1.17 18-Jun-2011  matt struct device * -> device_t
struct cfdata * -> cfdata_t
use device accessors, use device_private.
some softc/device_t splits (macppc needs a bunch more)
aprint*_dev used considerably more
 1.16 20-Dec-2010  matt branches: 1.16.6;
Move counting of faults, traps, intrs, soft[intr]s, syscalls, and nswtch
from uvmexp to per-cpu cpu_data and move them to 64bits. Remove unneeded
includes of <uvm/uvm_extern.h> and/or <uvm/uvm.h>.
 1.15 14-Mar-2009  dsl branches: 1.15.4;
ANSIfy another 1261 function definitions.
The only ones left in sys are beyond by sed script!
(or in sys/dist or sys/external)
Mostly they have function pointer parameters.
 1.14 14-Mar-2009  dsl Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.13 14-Mar-2009  dsl Remove all the __P() from sys (excluding sys/dist)
Diff checked with grep and MK1 eyeball.
i386 and amd64 GENERIC and sys still build.
 1.12 08-Feb-2009  pgoyette branches: 1.12.2;
Avoid asking the controller to transfer zero bytes of data, since we have
no clue if this works or not. This prevents the i2c quick_{read,write}
protocols from working, but the only place those protocols are used is in
the code that enumerates the i2c bus and that just doesn't make sense for
ki2c anyway.

While here, make sure that i2c send_{byte,word} operations will work even
if the caller provides the cmd (ie, register to modify) and the data in
separate args. This is the normal calling sequence for iic_exec() routines
and will enable dbcool (4) driver to update device registers.

OK'd macallan@
 1.11 06-Dec-2007  ad branches: 1.11.16; 1.11.24;
lockmgr -> mutex
 1.10 17-Oct-2007  garbled branches: 1.10.2; 1.10.4;
Merge the ppcoea-renovation branch to HEAD.

This branch was a major cleanup and rototill of many of the various OEA
cpu based PPC ports that focused on sharing as much code as possible
between the various ports to eliminate near-identical copies of files in
every tree. Additionally there is a new PIC system that unifies the
interface to interrupt code for all different OEA ppc arches. The work
for this branch was done by a variety of people, too long to list here.

TODO:
bebox still needs work to complete the transition to -renovation.
ofppc still needs a bunch of work, which I will be looking at.
ev64260 still needs to be renovated
amigappc was not attempted.

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.9 27-Sep-2007  dogcow branches: 1.9.2;
struct cfattach -> CFATTACH_DECL; compiles again.
 1.8 26-Jun-2006  drochner branches: 1.8.14; 1.8.18; 1.8.22; 1.8.32; 1.8.34; 1.8.36;
Better explicitely specify the "ki2c" interface attribute,
so that the "config_found" can't hit "i2cbus".
Up to now, this relied on the fact that the i2cbus and ki2c
attach args both had a string as first element which was used
to distinguish. Now, interface attributes should take care
that attach arguments are not misinterpreted.
 1.7 26-Jun-2006  drochner use the "i2cbus" interface attribute rather than putting a string name
into the i2cbus attach args
 1.6 24-Dec-2005  perry branches: 1.6.4; 1.6.8; 1.6.16;
bare asm -> __asm
 1.5 11-Dec-2005  christos merge ktrace-lwp.
 1.4 07-Oct-2005  macallan Check for 'i2c-bus' child and if found look for i2c devices there instead of
directly under the ki2c node.
Needed for newer ( 2005? ) OpenFirmware.
 1.3 10-Aug-2005  macallan allow to attach a normal iic bus, implements only iic_exec() and locking functions so far.
 1.2 05-Jun-2005  nathanw branches: 1.2.2;
In ki2c_write() Apply __UNCONST() to the data parameter passed to
ki2c_start(). The same back-end routine does reads and writes, so
there's no real type-safety to be had here.
 1.1 27-Dec-2003  grant branches: 1.1.4;
add support for the Keywest I2C and snapper audio device, as found on
some iBook and PowerBook models.

this driver was written by Tsubai Masanari and further hacked on by
Jared D. McNeill to work on his iBook.

the driver is limited (master volume control only, and I haven't
tested recording) but has been functioning perfectly on my PowerBook
g4 DVI (ivory) for some time.

ok'd by matt.
 1.1.4.5 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.1.4.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.1.4.3 18-Sep-2004  skrll Sync with HEAD.
 1.1.4.2 03-Aug-2004  skrll Sync with HEAD
 1.1.4.1 27-Dec-2003  skrll file ki2c.c was added on branch ktrace-lwp on 2004-08-03 10:37:21 +0000
 1.2.2.4 07-Dec-2007  yamt sync with head
 1.2.2.3 27-Oct-2007  yamt sync with head.
 1.2.2.2 30-Dec-2006  yamt sync with head.
 1.2.2.1 21-Jun-2006  yamt sync with head.
 1.6.16.1 13-Jul-2006  gdamore Merge from HEAD.
 1.6.8.1 11-Aug-2006  yamt sync with head
 1.6.4.1 09-Sep-2006  rpaulo sync with head
 1.8.36.2 18-Oct-2007  yamt sync with head.
 1.8.36.1 06-Oct-2007  yamt sync with head.
 1.8.34.2 09-Jan-2008  matt sync with HEAD
 1.8.34.1 06-Nov-2007  matt sync with HEAD
 1.8.32.3 09-Dec-2007  jmcneill Sync with HEAD.
 1.8.32.2 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.8.32.1 02-Oct-2007  joerg Sync with HEAD.
 1.8.22.2 03-Oct-2007  garbled Sync with HEAD
 1.8.22.1 27-Sep-2007  macallan use CFATTACH_DECL()
 1.8.18.1 09-Dec-2007  reinoud Pullup to HEAD
 1.8.14.2 23-Oct-2007  ad Sync with head.
 1.8.14.1 09-Oct-2007  ad Sync with head.
 1.9.2.1 25-Oct-2007  bouyer Sync with HEAD.
 1.10.4.1 08-Dec-2007  ad Sync with head.
 1.10.2.1 08-Dec-2007  mjf Sync with HEAD.
 1.11.24.2 28-Apr-2009  skrll Sync with HEAD.
 1.11.24.1 03-Mar-2009  skrll Sync with HEAD.
 1.11.16.1 04-May-2009  yamt sync with head.
 1.12.2.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.15.4.1 05-Mar-2011  rmind sync with head
 1.16.6.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.18.30.1 19-Mar-2016  skrll Sync with HEAD
 1.18.12.1 03-Dec-2017  jdolecek update from HEAD
 1.24.2.1 15-Mar-2018  pgoyette Synch with HEAD
 1.25.2.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.27.2.1 17-Jan-2020  ad Sync with head.
 1.30.4.1 23-Mar-2021  thorpej Convert config_found_ia() call sites where the device only carries
a single interface attribute to bare config_found() calls.
 1.31.8.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.31.2.2 14-May-2021  thorpej Move the bus/channel number for multi-channel / mux controllers out of
i2cbus_attach_args and stash it in the i2c_tag_t instead. This makes it
accessible to platform device tree code when enumerating devices.
 1.31.2.1 08-May-2021  thorpej Adapt the Keywest i2c controller driver to the new i2c device enumeration
mechanism. We need to provide our own enumeration callback because these
controllers do not use the standard OpenFirmware bindings.

The Keywest controller supports 2 physical i2c busses on a single controller,
so we logically split it up that way now, rather than encoding the channel in
in the i2c address as was done previously.

Different systems have different I2C device tree topologies.

Some systems use a scheme like this:

/u3@0,f8000000/i2c@f8001000/temp-monitor@98
/u3@0,f8000000/i2c@f8001000/fan@15e

Here, we see the channel encoded in bit #8 of the address.

Other systems use a scheme like this:

/ht@0,f2000000/pci@4000,0,0/mac-io@7/i2c@18000/i2c-bus@0
/ht@0,f2000000/pci@4000,0,0/mac-io@7/i2c@18000/i2c-bus@0/codec@8c

/u4@0,f8000000/i2c@f8001000/i2c-bus@1
/u4@0,f8000000/i2c@f8001000/i2c-bus@1/temp-monitor@94

Here, a separate device tree node represents the channel.
Note that in BOTH cases, the I2C address of the devices are
shifted left by 1 (as it would be on the wire to leave room
for the read/write bit).
 1.32.2.4 11-Sep-2021  thorpej Add a devhandle_subclass() helper function to simplify the common case
and use it. Improve some comments.
 1.32.2.3 11-Sep-2021  thorpej Fix a memory leak if the "compatible" property is > 32 bytes.
 1.32.2.2 10-Sep-2021  thorpej Remove unnecessary references to i2c_attach_args::ia_prop and mark the ones
that remain as XXX.
 1.32.2.1 09-Aug-2021  thorpej Port over the changes from thorpej-i2c-spi-conf to thorpej-i2c-spi-conf2,
which is based on a newer HEAD revision.
 1.33.10.1 02-Aug-2025  perseant Sync with HEAD
 1.8 21-Sep-2025  thorpej Use direct device tree enumeration support for ki2c. Cleanly separate
the two ki2c channels rather than mixing them all together and using an
artificial i2c address bit to distinguish the channels.
 1.7 05-Jul-2025  macallan deal with G5s that have two openpics by:
- checking interrupt-parent, trying to find the corresponding PIC, and adjusting
our IRQ number accordingly
- fall back to polling if we have interrupt-parent but no matching PIC
- if there is no interrupt-parent, assume we have only one PIC
... this should probably be handled by intr_establish*
 1.6 05-Jul-2025  macallan use interrupts so we can sleep instead of busy waiting on i2c transfers
 1.5 15-Sep-2017  macallan branches: 1.5.20; 1.5.30; 1.5.40;
bus_space-ify
 1.4 26-Jul-2011  macallan branches: 1.4.12;
finish device_t-ification
 1.3 07-Dec-2007  macallan finish mutexification, now ki2c compiles again
 1.2 11-Dec-2005  christos branches: 1.2.18; 1.2.36; 1.2.50; 1.2.52; 1.2.58; 1.2.62;
merge ktrace-lwp.
 1.1 10-Aug-2005  macallan branches: 1.1.6;
split from ki2c.c
 1.1.6.2 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.1.6.1 10-Aug-2005  skrll file ki2cvar.h was added on branch ktrace-lwp on 2005-11-10 13:57:27 +0000
 1.2.62.1 08-Dec-2007  ad Sync with head.
 1.2.58.1 08-Dec-2007  mjf Sync with HEAD.
 1.2.52.1 09-Jan-2008  matt sync with HEAD
 1.2.50.1 09-Dec-2007  jmcneill Sync with HEAD.
 1.2.36.1 09-Dec-2007  reinoud Pullup to HEAD
 1.2.18.3 21-Jan-2008  yamt sync with head
 1.2.18.2 21-Jun-2006  yamt sync with head.
 1.2.18.1 11-Dec-2005  yamt file ki2cvar.h was added on branch yamt-lazymbuf on 2006-06-21 14:53:13 +0000
 1.4.12.1 03-Dec-2017  jdolecek update from HEAD
 1.5.40.1 02-Aug-2025  perseant Sync with HEAD
 1.5.30.1 09-Aug-2021  thorpej Port over the changes from thorpej-i2c-spi-conf to thorpej-i2c-spi-conf2,
which is based on a newer HEAD revision.
 1.5.20.1 08-May-2021  thorpej Adapt the Keywest i2c controller driver to the new i2c device enumeration
mechanism. We need to provide our own enumeration callback because these
controllers do not use the standard OpenFirmware bindings.

The Keywest controller supports 2 physical i2c busses on a single controller,
so we logically split it up that way now, rather than encoding the channel in
in the i2c address as was done previously.

Different systems have different I2C device tree topologies.

Some systems use a scheme like this:

/u3@0,f8000000/i2c@f8001000/temp-monitor@98
/u3@0,f8000000/i2c@f8001000/fan@15e

Here, we see the channel encoded in bit #8 of the address.

Other systems use a scheme like this:

/ht@0,f2000000/pci@4000,0,0/mac-io@7/i2c@18000/i2c-bus@0
/ht@0,f2000000/pci@4000,0,0/mac-io@7/i2c@18000/i2c-bus@0/codec@8c

/u4@0,f8000000/i2c@f8001000/i2c-bus@1
/u4@0,f8000000/i2c@f8001000/i2c-bus@1/temp-monitor@94

Here, a separate device tree node represents the channel.
Note that in BOTH cases, the I2C address of the devices are
shifted left by 1 (as it would be on the wire to leave room
for the read/write bit).
 1.2 15-Sep-2025  macallan make things configurable via sysctl
 1.1 08-Sep-2025  macallan a driver for the LED bar found on Xserve G4
needs testing on SMP
 1.11 17-Sep-2025  thorpej This driver doesn't use the OF phandle anywhere, so don't bother
storing it in the softc.
 1.10 06-Jul-2025  macallan callout -> kthread since we can't i2c_exec from interrupt context anymore
 1.9 18-Jun-2021  macallan branches: 1.9.6; 1.9.16;
use opt_lmu.h
while there, remove an obsolete comment
 1.8 27-Jan-2021  thorpej branches: 1.8.4;
Use DEVICE_COMPAT_EOL.
 1.7 25-Jan-2021  thorpej Since we're using designated initialisers for compat data, we should
use a completely empty initializer for the sentinel.
 1.6 17-Jan-2021  thorpej Use designated initializers and a consistent termination style in
compat_data[].
 1.5 12-Sep-2020  macallan branches: 1.5.2;
respond to keyboard brightness control PMF events
 1.4 23-Apr-2020  macallan make this work properly:
- get rid of cargo-culted register assignments, I found the right ones by
experiment, now both light sensors report sane values
- keyboard brightness seems to max out at 16, act like it
- do what MacOS does and fade keyboard brightness instead of just switching
- add sysctls to configure keyboard brightness and environmental light
thresholds
- don't poll the chip more often than once a second
 1.3 23-Apr-2020  macallan drop openfirm.h include
 1.2 06-Feb-2020  macallan branches: 1.2.4; 1.2.6;
listen to PMF events in order to turn off keyboard lights when the lid is
closed or the screen is blanked
 1.1 10-Jan-2020  macallan branches: 1.1.2;
add driver for the ambient light sensor / keyboard light controller found in
PowerBook5,6 and probably others
 1.1.2.3 29-Feb-2020  ad Sync with head.
 1.1.2.2 17-Jan-2020  ad Sync with head.
 1.1.2.1 10-Jan-2020  ad file lmu.c was added on branch ad-namecache on 2020-01-17 21:47:26 +0000
 1.2.6.1 25-Apr-2020  bouyer Sync with bouyer-xenpvh-base2 (HEAD)
 1.2.4.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.2.4.1 06-Feb-2020  martin file lmu.c was added on branch phil-wifi on 2020-04-08 14:07:44 +0000
 1.5.2.1 03-Apr-2021  thorpej Sync with HEAD.
 1.8.4.3 01-Aug-2021  thorpej Sync with HEAD.
 1.8.4.2 13-May-2021  thorpej Don't use the OF phandle here.
 1.8.4.1 09-May-2021  thorpej ia->ia_cookie -> devhandle_to_of(device_handle(self))
 1.9.16.1 02-Aug-2025  perseant Sync with HEAD
 1.9.6.1 09-Aug-2021  thorpej Port over the changes from thorpej-i2c-spi-conf to thorpej-i2c-spi-conf2,
which is based on a newer HEAD revision.
 1.28 16-Feb-2022  riastradh powerpc: Sprinkle "memory" clobbers on eieio and nearby asm blocks.

Otherwise the compiler may reorder these around loads and stores,
which mostly defeats the purpose. `asm volatile' just ensures the
instruction isn't _deleted_; it may still move around.
 1.27 22-Jan-2022  thorpej Change the devhandle_from_*() functions to also take a "super handle",
from which the newly created handle will inherit it's implementation.
The root implementation for a new handle type is used if an invalid
"super handle" is passed.
 1.26 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.25 24-Apr-2021  thorpej branches: 1.25.8;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).
 1.24 05-Mar-2021  rin branches: 1.24.2;
Convert to intr_establish_xname().
 1.23 26-Jan-2021  thorpej There is not much point in of_compatible() returning -1 for "no match"
and >= 0 for "match". Just make it return 0 for "no match" and >0 for
"match" so it can be treated like a boolean expression.

As such of_match_compatible() (a wrapper around of_compatible()) is now
obsolete, and will be removed once all call sites are converted to an
appropriate replacement.
 1.22 26-Jul-2011  macallan branches: 1.22.66;
finish device_t-ification
 1.21 30-Jun-2011  matt Modify mapiodev to take a third argument indicating whether the space
should be prefetchable (true) or not (false).
 1.20 18-Jun-2011  matt struct device * -> device_t
struct cfdata * -> cfdata_t
use device accessors, use device_private.
some softc/device_t splits (macppc needs a bunch more)
aprint*_dev used considerably more
 1.19 20-Dec-2010  matt branches: 1.19.6;
Move counting of faults, traps, intrs, soft[intr]s, syscalls, and nswtch
from uvmexp to per-cpu cpu_data and move them to 64bits. Remove unneeded
includes of <uvm/uvm_extern.h> and/or <uvm/uvm.h>.
 1.18 14-Mar-2009  dsl branches: 1.18.4;
ANSIfy another 1261 function definitions.
The only ones left in sys are beyond by sed script!
(or in sys/dist or sys/external)
Mostly they have function pointer parameters.
 1.17 14-Mar-2009  dsl Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.16 14-Mar-2009  dsl Remove all the __P() from sys (excluding sys/dist)
Diff checked with grep and MK1 eyeball.
i386 and amd64 GENERIC and sys still build.
 1.15 28-Aug-2008  jmcneill branches: 1.15.2; 1.15.8;
Add support for keylargo-style mediabays, as found in eg. PowerBook3,1
 1.14 17-Oct-2007  garbled branches: 1.14.16; 1.14.20; 1.14.22; 1.14.26;
Merge the ppcoea-renovation branch to HEAD.

This branch was a major cleanup and rototill of many of the various OEA
cpu based PPC ports that focused on sharing as much code as possible
between the various ports to eliminate near-identical copies of files in
every tree. Additionally there is a new PIC system that unifies the
interface to interrupt code for all different OEA ppc arches. The work
for this branch was done by a variety of people, too long to list here.

TODO:
bebox still needs work to complete the transition to -renovation.
ofppc still needs a bunch of work, which I will be looking at.
ev64260 still needs to be renovated
amigappc was not attempted.

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.13 09-Jul-2007  ad branches: 1.13.8; 1.13.10; 1.13.12; 1.13.14;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements
 1.12 10-Dec-2006  macallan branches: 1.12.6; 1.12.8; 1.12.14;
when powering up the mediabay wait two seconds before looking for devices
Without this CDROM drives wouldn't be found when hotplugged.
 1.11 11-Dec-2005  christos branches: 1.11.20; 1.11.22; 1.11.24;
merge ktrace-lwp.
 1.10 08-Jan-2005  briggs branches: 1.10.10;
cosmetic changes.
 1.9 15-Jul-2003  lukem __KERNEL_RCSID()
 1.8 02-Apr-2003  thorpej branches: 1.8.2;
Use PAGE_SIZE rather than NBPG.
 1.7 01-Jan-2003  thorpej Use aprint_normal() for cfprint routines.
 1.6 02-Oct-2002  thorpej Use CFATTACH_DECL().
 1.5 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.4 22-Jul-2001  wiz branches: 1.4.6;
bcopy -> memcpy, bzero -> memset, bcmp -> memcmp.
Reviewed by Matt Thomas, ok'd by Tsubai Masanari.
 1.3 23-Aug-2000  tsubai branches: 1.3.4;
New PowerBook (firewire) seems to use edge-triggered interrupt.
XXX cannot hot-plug yet
 1.2 04-Oct-1999  tsubai branches: 1.2.2; 1.2.12;
Make media-bay CD detachable.
 1.1 21-Jul-1999  tsubai branches: 1.1.2;
media-bay CD support.
 1.1.2.2 02-Aug-1999  thorpej Update from trunk.
 1.1.2.1 21-Jul-1999  thorpej file mediabay.c was added on branch chs-ubc2 on 1999-08-02 19:55:12 +0000
 1.2.12.1 01-Nov-2000  tv Pullup 1.3 [tsubai, mycroft]:
New PowerBook (firewire) seems to use edge-triggered interrupt.
XXX cannot hot-plug yet
 1.2.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.3.4.2 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.3.4.1 03-Aug-2001  lukem update to -current
 1.4.6.3 03-Jan-2003  thorpej Sync with HEAD.
 1.4.6.2 18-Oct-2002  nathanw Catch up to -current.
 1.4.6.1 22-Jul-2001  nathanw file mediabay.c was added on branch nathanw_sa on 2002-10-18 02:38:35 +0000
 1.8.2.4 17-Jan-2005  skrll Sync with HEAD.
 1.8.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.8.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.8.2.1 03-Aug-2004  skrll Sync with HEAD
 1.10.10.3 27-Oct-2007  yamt sync with head.
 1.10.10.2 03-Sep-2007  yamt sync with head.
 1.10.10.1 30-Dec-2006  yamt sync with head.
 1.11.24.1 12-Jan-2007  bouyer Pull up following revision(s) (requested by macallan in ticket #352):
sys/arch/macppc/dev/mediabay.c: revision 1.12
when powering up the mediabay wait two seconds before looking for
devices
Without this CDROM drives wouldn't be found when hotplugged.
 1.11.22.1 10-Dec-2006  yamt sync with head.
 1.11.20.1 12-Jan-2007  ad Sync with head.
 1.12.14.4 03-Oct-2007  garbled Sync with HEAD
 1.12.14.3 02-Aug-2007  macallan sync with HEAD
 1.12.14.2 20-Jun-2007  macallan pass ca_tag to child devices
 1.12.14.1 11-May-2007  macallan request the correct interrupt type in a couple drivers - necessary since
these days we actually do something with the type argument
 1.12.8.1 11-Jul-2007  mjf Sync with head.
 1.12.6.2 23-Oct-2007  ad Sync with head.
 1.12.6.1 15-Jul-2007  ad Sync with head.
 1.13.14.1 25-Oct-2007  bouyer Sync with HEAD.
 1.13.12.1 18-Oct-2007  yamt sync with head.
 1.13.10.1 06-Nov-2007  matt sync with HEAD
 1.13.8.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.14.26.1 19-Oct-2008  haad Sync with HEAD.
 1.14.22.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.14.20.1 04-May-2009  yamt sync with head.
 1.14.16.1 28-Sep-2008  mjf Sync with HEAD.
 1.15.8.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.15.2.1 28-Apr-2009  skrll Sync with HEAD.
 1.18.4.1 05-Mar-2011  rmind sync with head
 1.19.6.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.22.66.1 03-Apr-2021  thorpej Sync with HEAD.
 1.24.2.2 04-Apr-2021  thorpej Associate the OpenFirmware phandle associated with a found device (including
PCI bus instances) by using CFARG_DEVHANDLE.
 1.24.2.1 21-Mar-2021  thorpej Give config_found() the same variadic arguments treatment as
config_search(). This commit only adds the CFARG_EOL sentinel
to the existing config_found() calls. Conversion of config_found_sm_loc()
and config_found_ia() call sites will be in subsequent commits.
 1.25.8.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.44 20-Dec-2023  thorpej Remove unnecessary <sys/malloc.h>.
 1.43 24-Sep-2023  andvar define i variable in for loop.
mesh_msgin() doesn't have one defined in the function scope.

fixes MESH_DEBUG enabled build for macppc.
 1.42 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.41 24-Apr-2021  thorpej branches: 1.41.8;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).
 1.40 05-Mar-2021  rin branches: 1.40.2;
Convert to intr_establish_xname().
 1.39 31-Mar-2017  msaitoh branches: 1.39.26;
Remove extra 0x. This bug was added when replacing bitmask_snprintf(9) with
snprintb(3) (in between NetBSD 5 and 6). Old bitmask_snprint(9) didn't add
0x" automatically for hexadecimal value, so old code used it with "0x%s".
 1.38 15-Feb-2017  tsutsui Fix an inverted logic.
 1.37 15-Jul-2016  macallan branches: 1.37.2;
adjust to dbdma changes
 1.36 14-Mar-2014  mrg branches: 1.36.6; 1.36.10;
remove various set-but-unused variables.
 1.35 30-Jun-2011  matt branches: 1.35.2; 1.35.12; 1.35.16;
Modify mapiodev to take a third argument indicating whether the space
should be prefetchable (true) or not (false).
 1.34 26-Sep-2009  tsutsui Make local functions static.
 1.33 26-Sep-2009  tsutsui Replace shutdownhook_establish(9) with pmf_device_register1(9).
Tested on Apus2000.
 1.32 26-Sep-2009  tsutsui Fix a botch on device_t/softc split:
Don't forget to set sc->sc_dev.
 1.31 15-May-2009  tsutsui Split device_t/softc. Tested on Apus2000.
 1.30 14-Mar-2009  dsl ANSIfy another 1261 function definitions.
The only ones left in sys are beyond by sed script!
(or in sys/dist or sys/external)
Mostly they have function pointer parameters.
 1.29 14-Mar-2009  dsl Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.28 14-Mar-2009  dsl Remove all the __P() from sys (excluding sys/dist)
Diff checked with grep and MK1 eyeball.
i386 and amd64 GENERIC and sys still build.
 1.27 16-Dec-2008  christos branches: 1.27.2;
replace bitmask_snprintf(9) with snprintb(3)
 1.26 17-Oct-2007  garbled branches: 1.26.16; 1.26.20; 1.26.28;
Merge the ppcoea-renovation branch to HEAD.

This branch was a major cleanup and rototill of many of the various OEA
cpu based PPC ports that focused on sharing as much code as possible
between the various ports to eliminate near-identical copies of files in
every tree. Additionally there is a new PIC system that unifies the
interface to interrupt code for all different OEA ppc arches. The work
for this branch was done by a variety of people, too long to list here.

TODO:
bebox still needs work to complete the transition to -renovation.
ofppc still needs a bunch of work, which I will be looking at.
ev64260 still needs to be renovated
amigappc was not attempted.

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.25 29-Mar-2006  thorpej branches: 1.25.18; 1.25.26; 1.25.36; 1.25.38; 1.25.40; 1.25.42;
Use device_cfdata().
 1.24 24-Dec-2005  perry branches: 1.24.4; 1.24.6; 1.24.8; 1.24.10; 1.24.12;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.
 1.23 17-Dec-2005  macallan return SCSI_CHECK in xs->status instead of xs->xs_status
This fixes a whole bunch of weird errors that plague(d) mesh forever, like
- failure to spin up drives automatically
- occasional bogus 'drive offline' messages
- LONG delays when trying to use a ZIP drive

It will probably expose more problems, we'll see.
 1.22 11-Dec-2005  christos merge ktrace-lwp.
 1.21 09-Dec-2004  briggs branches: 1.21.8; 1.21.10;
Several changes from Michael Lorenz. Adapted from PR port-macppc/27680.
1. Reset SCSI bus & MESH on reboot to keep OF happy.
2. Tweak interrupt handler to clear interrupt register again if we get a
CMDDONE interrupt with DMA active and a 0 fifocnt. It's not clear why
this is necessary, but is well documented in some other open source
drivers. This enables synchronous mode to work.
3. Dump a little more information if we do get a timeout.
 1.20 07-Dec-2004  thorpej Use "struct scsipi_command" in internal command structures so that
we have enough space for 16-byte CDBs.
 1.19 15-Jul-2003  lukem __KERNEL_RCSID()
 1.18 03-May-2003  wiz branches: 1.18.2;
DMA, not dma nor Dma.
 1.17 02-Apr-2003  thorpej Use PAGE_SIZE rather than NBPG.
 1.16 02-Oct-2002  thorpej Use CFATTACH_DECL().
 1.15 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.14 05-Apr-2002  bouyer Implement mstohz() as discussed on tech-kern, and use it in SCSI drivers
to convert xs->timeout to callout() parameter.
 1.13 04-Nov-2001  tsutsui Use common macro to check message length.
 1.12 22-Jul-2001  wiz branches: 1.12.4; 1.12.6;
bcopy -> memcpy, bzero -> memset, bcmp -> memcmp.
Reviewed by Matt Thomas, ok'd by Tsubai Masanari.
 1.11 08-Jun-2001  matt branches: 1.11.2;
Make macppc compile by default with -Wall -Wmissing-prototype in addition
to its currently enabled warnings. For the lack of a better place, most
global function prototype wound up in <machine/autoconf.h> unless there
was a better place for them. ofb_* structs renamed to offb_* to avoid
conflict with ofb_softc in <dev/ofw/openfirm.h>
 1.10 26-Apr-2001  tsubai Remove spaces at EOL.
 1.9 25-Apr-2001  bouyer Pull up the thorpej_scsipi branch to main branch.
This is a completely rewritten scsipi_xfer execution engine, and the
associated changes to HBA drivers. Overview of changes & features:
- All xfers are queued in the mid-layer, rather than doing so in an
ad-hoc fashion in individual adapter drivers.
- Adapter/channel resource management in the mid-layer, avoids even trying
to start running an xfer if the adapter/channel doesn't have the resources.
- Better communication between the mid-layer and the adapters.
- Asynchronous event notification mechanism from adapter to mid-layer and
peripherals.
- Better peripheral queue management: freeze/thaw, sorted requeueing during
recovery, etc.
- Clean separation of peripherals, adapters, and adapter channels (no more
scsipi_link).
- Kernel thread for each scsipi_channel makes error recovery much easier
(no more dealing with interrupt context when recovering from an error).
- Mid-layer support for tagged queueing: commands can have the tag type
set explicitly, tag IDs are allocated in the mid-layer (thus eliminating
the need to use buggy tag ID allocation schemes in many adapter drivers).
- support for QUEUE FULL and CHECK CONDITION status in mid-layer; the command
will be requeued, or a REQUEST SENSE will be sent as appropriate.

Just before the merge syssrc has been tagged with thorpej_scsipi_beforemerge
 1.8 24-Dec-2000  wiz branches: 1.8.2;
Honour SCSI command timeout -- fixes problems with SCSI commands that take
longer than 10s and were falling into a timeout, e.g. fixating.
 1.7 31-Oct-2000  tsubai Match "chrp,mesh0".
 1.6 23-Oct-2000  tsubai Fix Conner CFP1080 problem (pr 7612) and add debugging messages.
 1.5 29-Jun-2000  mrg remove include of <vm/vm.h>. <vm/vm.h> -> <uvm/uvm_extern.h>
 1.4 23-Mar-2000  thorpej branches: 1.4.4;
New callout mechanism with two major improvements over the old
timeout()/untimeout() API:
- Clients supply callout handle storage, thus eliminating problems of
resource allocation.
- Insertion and removal of callouts is constant time, important as
this facility is used quite a lot in the kernel.

The old timeout()/untimeout() API has been removed from the kernel.
 1.3 28-Dec-1999  tsubai Remove two panic conditions.
XXX untested.
 1.2 30-Sep-1999  thorpej branches: 1.2.2;
Update for SCSIPI changes.
 1.1 19-Feb-1999  tsubai branches: 1.1.2;
First step of MESH SCSI support.
XXX no disconnect/reselect.
XXX sync transfer is very unstable.
 1.1.2.3 23-Feb-2000  he Pull up revision 1.3 (via patch, requested by tsubai):
Fix the ``panic: mesh: FIFO != 0'' on some models.
 1.1.2.2 23-Feb-2000  he Revert pull-up of revision 1.3 (requested by he):
Causes compile error. Awaiting patch.
 1.1.2.1 22-Feb-2000  he Pull up revision 1.3 (requested by tsubai):
Fix the ``panic: mesh: FIFO != 0'' on some models.
 1.2.2.6 29-Mar-2001  bouyer Ops, don't use uninitialised pointer.
mesh now works, thanks to Emmanuel Dreyfus for testing !
 1.2.2.5 29-Mar-2001  bouyer Pass compile-test on i386
 1.2.2.4 27-Mar-2001  bouyer Convert to thorpej_scsipi (untested).
 1.2.2.3 05-Jan-2001  bouyer Sync with HEAD
 1.2.2.2 22-Nov-2000  bouyer Sync with HEAD.
 1.2.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.4.4.2 24-Jan-2002  he Pull up revision 1.8 (requested by briggs):
Honour SCSI command timeout. This fixes a problem with some SCSI
commands which take longer than 10s to complete, and were falling
into a timeout, e.g. CD-R fixating.
 1.4.4.1 26-Feb-2001  he Pull up revisions 1.6-1.7 (requested by briggs):
Match "chrp,mesh0", and fix Conner CFP1080 problem (PR#7612),
and add debugging messages.
 1.8.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.11.2.4 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.11.2.3 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.11.2.2 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.11.2.1 03-Aug-2001  lukem update to -current
 1.12.6.3 18-Oct-2002  nathanw Catch up to -current.
 1.12.6.2 17-Apr-2002  nathanw Catch up to -current.
 1.12.6.1 22-Jul-2001  nathanw file mesh.c was added on branch nathanw_sa on 2002-04-17 00:03:42 +0000
 1.12.4.1 12-Nov-2001  thorpej Sync the thorpej-mips-cache branch with -current.
 1.18.2.4 18-Dec-2004  skrll Sync with HEAD.
 1.18.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.18.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.18.2.1 03-Aug-2004  skrll Sync with HEAD
 1.21.10.2 27-Oct-2007  yamt sync with head.
 1.21.10.1 21-Jun-2006  yamt sync with head.
 1.21.8.1 18-Dec-2005  tron Pull up following revision(s) (requested by macallan in ticket #1064):
sys/arch/macppc/dev/mesh.c: revision 1.23
return SCSI_CHECK in xs->status instead of xs->xs_status
This fixes a whole bunch of weird errors that plague(d) mesh forever,
like
- failure to spin up drives automatically
- occasional bogus 'drive offline' messages
- LONG delays when trying to use a ZIP drive
It will probably expose more problems, we'll see.
 1.24.12.1 31-Mar-2006  tron Merge 2006-03-31 NetBSD-current into the "peter-altq" branch.
 1.24.10.1 19-Apr-2006  elad sync with head - hopefully this will work
 1.24.8.1 01-Apr-2006  yamt sync with head.
 1.24.6.1 22-Apr-2006  simonb Sync with head.
 1.24.4.1 09-Sep-2006  rpaulo sync with head
 1.25.42.1 25-Oct-2007  bouyer Sync with HEAD.
 1.25.40.1 18-Oct-2007  yamt sync with head.
 1.25.38.1 06-Nov-2007  matt sync with HEAD
 1.25.36.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.25.26.1 11-May-2007  macallan request the correct interrupt type in a couple drivers - necessary since
these days we actually do something with the type argument
 1.25.18.1 23-Oct-2007  ad Sync with head.
 1.26.28.2 28-Apr-2009  skrll Sync with HEAD.
 1.26.28.1 19-Jan-2009  skrll Sync with HEAD.
 1.26.20.3 11-Mar-2010  yamt sync with head
 1.26.20.2 16-May-2009  yamt sync with head
 1.26.20.1 04-May-2009  yamt sync with head.
 1.26.16.1 17-Jan-2009  mjf Sync with HEAD.
 1.27.2.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.35.16.1 18-May-2014  rmind sync with head
 1.35.12.2 03-Dec-2017  jdolecek update from HEAD
 1.35.12.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.35.2.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.36.10.3 26-Apr-2017  pgoyette Sync with HEAD
 1.36.10.2 20-Mar-2017  pgoyette Sync with HEAD
 1.36.10.1 26-Jul-2016  pgoyette Sync with HEAD
 1.36.6.2 28-Aug-2017  skrll Sync with HEAD
 1.36.6.1 05-Oct-2016  skrll Sync with HEAD
 1.37.2.1 21-Apr-2017  bouyer Sync with HEAD
 1.39.26.1 03-Apr-2021  thorpej Sync with HEAD.
 1.40.2.1 21-Mar-2021  thorpej Give config_found() the same variadic arguments treatment as
config_search(). This commit only adds the CFARG_EOL sentinel
to the existing config_found() calls. Conversion of config_found_sm_loc()
and config_found_ia() call sites will be in subsequent commits.
 1.41.8.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.2 23-Oct-2000  tsubai Fix Conner CFP1080 problem (pr 7612) and add debugging messages.
 1.1 19-Feb-1999  tsubai branches: 1.1.8;
First step of MESH SCSI support.
XXX no disconnect/reselect.
XXX sync transfer is very unstable.
 1.1.8.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.20 25-Jul-2014  dholland Add d_discard to all struct cdevsw instances I could find.

All have been set to "nodiscard"; some should get a real implementation.
 1.19 16-Mar-2014  dholland branches: 1.19.2;
Change (mostly mechanically) every cdevsw/bdevsw I can find to use
designated initializers.

I have not built every extant kernel so I have probably broken at
least one build; however I've also found and fixed some wrong
cdevsw/bdevsw entries so even if so I think we come out ahead.
 1.18 27-Oct-2012  chs branches: 1.18.2;
split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.17 30-Jun-2011  matt branches: 1.17.2; 1.17.12;
Modify mapiodev to take a third argument indicating whether the space
should be prefetchable (true) or not (false).
 1.16 18-Jun-2011  matt struct device * -> device_t
struct cfdata * -> cfdata_t
use device accessors, use device_private.
some softc/device_t splits (macppc needs a bunch more)
aprint*_dev used considerably more
 1.15 14-Mar-2009  dsl branches: 1.15.10;
ANSIfy another 1261 function definitions.
The only ones left in sys are beyond by sed script!
(or in sys/dist or sys/external)
Mostly they have function pointer parameters.
 1.14 14-Mar-2009  dsl Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.13 14-Mar-2009  dsl Remove all the __P() from sys (excluding sys/dist)
Diff checked with grep and MK1 eyeball.
i386 and amd64 GENERIC and sys still build.
 1.12 13-Jun-2008  cegger branches: 1.12.4; 1.12.10;
use device_lookup_private to get softc
 1.11 24-Jan-2007  hubertf branches: 1.11.44; 1.11.46; 1.11.48; 1.11.50; 1.11.52;
Remove duplicate #includes, patch contributed in private mail
by Slava Semushin <slava.semushin@gmail.com>.

To verify that no nasty side effects of duplicate includes (or their
removal) have an effect here, I've compiled an i386/ALL kernel with
and without the patch, and the only difference in the resulting .o
files was in shifted line numbers in some assert() calls.
The comparison of the .o files was based on the output of "objdump -D".

Thanks to martin@ for the input on testing.
 1.10 11-Dec-2005  christos branches: 1.10.20;
merge ktrace-lwp.
 1.9 15-Jul-2003  lukem branches: 1.9.16;
__KERNEL_RCSID()
 1.8 23-Oct-2002  jdolecek branches: 1.8.6;
merge kqueue branch into -current

kqueue provides a stateful and efficient event notification framework
currently supported events include socket, file, directory, fifo,
pipe, tty and device changes, and monitoring of processes and signals

kqueue is supported by all writable filesystems in NetBSD tree
(with exception of Coda) and all device drivers supporting poll(2)

based on work done by Jonathan Lemon for FreeBSD
initial NetBSD port done by Luke Mewburn and Jason Thorpe
 1.7 02-Oct-2002  thorpej Use CFATTACH_DECL().
 1.6 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.5 06-Sep-2002  gehenna Merge the gehenna-devsw branch into the trunk.

This merge changes the device switch tables from static array to
dynamically generated by config(8).

- All device switches is defined as a constant structure in device drivers.

- The new grammer ``device-major'' is introduced to ``files''.

device-major <prefix> char <num> [block <num>] [<rules>]

- All device major numbers must be listed up in port dependent majors.<arch>
by using this grammer.

- Added the new naming convention.
The name of the device switch must be <prefix>_[bc]devsw for auto-generation
of device switch tables.

- The backward compatibility of loading block/character device
switch by LKM framework is broken. This is necessary to convert
from block/character device major to device name in runtime and vice versa.

- The restriction to assign device major by LKM is completely removed.
We don't need to reserve LKM entries for dynamic loading of device switch.

- In compile time, device major numbers list is packed into the kernel and
the LKM framework will refer it to assign device major number dynamically.
 1.4 08-Jun-2001  matt branches: 1.4.2; 1.4.4; 1.4.8; 1.4.16;
Make macppc compile by default with -Wall -Wmissing-prototype in addition
to its currently enabled warnings. For the lack of a better place, most
global function prototype wound up in <machine/autoconf.h> unless there
was a better place for them. ofb_* structs renamed to offb_* to avoid
conflict with ofb_softc in <dev/ofw/openfirm.h>
 1.3 26-Jun-2000  simonb branches: 1.3.2;
Change the kernel mmap interface so that the offset to map is an
"off_t" and the return value is a "paddr_t" to allow mappings
at offsets past 2^31 bytes. Somewhat inspired by FreeBSD, which
only changed the offset to a "vm_offset_t".

Includes updates for the i386, pc532 and sh3 mmmmap from Jason Thorpe.
 1.2 19-Nov-1998  mrg branches: 1.2.10; 1.2.20;
fix problems in many d_mmap routines:
- returned EOPNOTSUPP rather than -1.
- no check for negative offset.
many of these fix potential security problems in these drivers.


XXX XXX XXX
the d_mmap cdev routine should be changed to have a prototype like:
paddr_t (*d_mmap) __P((dev_t, off_t, int));

by someone!
 1.1 03-Jul-1998  tsubai Add nvram device support.
 1.2.20.1 30-Jun-2000  simonb Pull up mmap paddr_t/off_t changes from trunk.
 1.2.10.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.3.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.4.16.1 17-May-2002  gehenna Add device switch.
 1.4.8.4 11-Nov-2002  nathanw Catch up to -current
 1.4.8.3 18-Oct-2002  nathanw Catch up to -current.
 1.4.8.2 17-Sep-2002  nathanw Catch up to -current.
 1.4.8.1 08-Jun-2001  nathanw file nvram.c was added on branch nathanw_sa on 2002-09-17 21:15:37 +0000
 1.4.4.1 10-Oct-2001  fvdl Convert all remaining devices.
 1.4.2.1 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.8.6.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.8.6.2 18-Sep-2004  skrll Sync with HEAD.
 1.8.6.1 03-Aug-2004  skrll Sync with HEAD
 1.9.16.1 26-Feb-2007  yamt sync with head.
 1.10.20.1 01-Feb-2007  ad Sync with head.
 1.11.52.1 18-Jun-2008  simonb Sync with head.
 1.11.50.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.11.48.1 04-May-2009  yamt sync with head.
 1.11.46.1 17-Jun-2008  yamt sync with head.
 1.11.44.1 29-Jun-2008  mjf Sync with HEAD.
 1.12.10.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.12.4.1 28-Apr-2009  skrll Sync with HEAD.
 1.15.10.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.17.12.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.17.12.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.17.2.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.17.2.1 30-Oct-2012  yamt sync with head
 1.18.2.1 18-May-2014  rmind sync with head
 1.19.2.1 10-Aug-2014  tls Rebase.
 1.54 20-Aug-2025  macallan add support for Xserve G4:
- fan control via pwm, works the same way as fcu and smu, zones can be
controlled via sysctl machdep.obio0
- add sysctls for pwms ( can be set ) and gpios ( read only )
- control indicator LED via sysctl hw.led
 1.53 28-Dec-2022  macallan one more skiplist entry...
 1.52 28-Dec-2022  macallan suppress 'not configured' message for mpic on G5s
 1.51 22-Jan-2022  thorpej Change the devhandle_from_*() functions to also take a "super handle",
from which the newly created handle will inherit it's implementation.
The root implementation for a new handle type is used if an invalid
"super handle" is passed.
 1.50 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.49 24-Apr-2021  thorpej branches: 1.49.8;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).
 1.48 26-Jan-2021  thorpej branches: 1.48.2;
There is not much point in of_compatible() returning -1 for "no match"
and >= 0 for "match". Just make it return 0 for "no match" and >0 for
"match" so it can be treated like a boolean expression.

As such of_match_compatible() (a wrapper around of_compatible()) is now
obsolete, and will be removed once all call sites are converted to an
appropriate replacement.
 1.47 25-Oct-2020  nia branches: 1.47.2;
Normalize some machine dependent CPU frequenct sysctl variables.

This moves machdep.*.frequency.* to machdep.cpu.frequency.*.

This was proposed on tech-kern some time ago. The intention is to allow
third-party tools such as estd and conky to more easily and reliably
fetch or modify the current CPU frequency without iterating through
various machine-dependent variables to check their presence.
 1.46 08-Jun-2018  macallan fix low CPU speed reporting when using DFS
 1.45 04-May-2018  macallan map 64KB register space on G5, provide function to bus_space_subregion()
from this area so we don't run into mapping conflicts on G5
Not really relevant on 32bit where we BAT-map everything
 1.44 29-Mar-2018  macallan don't map more PCI space than needed, avoid overlap with snapper so this has
a chance of working on G5
 1.43 04-Mar-2018  mrg branches: 1.43.2;
avoid indentation issues. re-do previous in obio.c to avoid the
does-nothing change, by fixing the intended indentation.
 1.42 04-Mar-2018  christos add braces.
 1.41 11-Nov-2014  macallan appease gcc 4.8
 1.40 25-Apr-2013  macallan map more register space on Shasta/K2, needed for SMU mailbox registers
 1.39 17-Apr-2013  macallan support Shasta
from Phileas Fogg
 1.38 27-Oct-2012  chs split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.37 02-Jun-2012  dsl branches: 1.37.2;
Add some pre-processor magic to verify that the type of the data item
passed to sysctl_createv() actually matches the declared type for
the item itself.
In the places where the caller specifies a function and a structure
address (typically the 'softc') an explicit (void *) cast is now needed.
Fixes bugs in sys/dev/acpi/asus_acpi.c sys/dev/bluetooth/bcsp.c
sys/kern/vfs_bio.c sys/miscfs/syncfs/sync_subr.c and setting
AcpiGbl_EnableAmlDebugObject.
(mostly passing the address of a uint64_t when typed as CTLTYPE_INT).
I've test built quite a few kernels, but there may be some unfixed MD
fallout. Most likely passing &char[] to char *.
Also add CTLFLAG_UNSIGNED for unsiged decimals - not set yet.
 1.36 19-Oct-2011  macallan branches: 1.36.2;
add cpufreq support
 1.35 01-Aug-2011  macallan sanitize sysctl interface in order to appease gcc 4.5
 1.34 26-Jul-2011  macallan finish device_t-ification
 1.33 18-Jun-2011  matt struct device * -> device_t
struct cfdata * -> cfdata_t
use device accessors, use device_private.
some softc/device_t splits (macppc needs a bunch more)
aprint*_dev used considerably more
 1.32 16-Mar-2011  macallan branches: 1.32.2;
change the CPU speed sysctl to look more like the ACPI ones, as in
machdep.<name>.frequency.available etc. so estd can work with minimal changes
 1.31 05-Dec-2010  phx branches: 1.31.2;
The gpio children have either register offsets based on gpio or on obio.
Implemented a workaround to deal with this uncertainty.
This fixes the machdep.cpu_speed control for 7447A-based iBookG4s.
 1.30 20-Oct-2010  phx Support sysctl machdep.cpu_speed for 7447A and 7448 based Macs. On those
machines the CPU's DFS (Dynamic Frequency Switching) feature is used instead
of a GPIO to control the speed.
Two new functions in powerpc/oea/cpu_subr.c were introduced to support
reading and writing of DFS: cpu_get_dfs() and cpu_set_dfs(). Also works
for multiple CPUs, but not before interrupts are enabled.
 1.29 14-Mar-2009  dsl branches: 1.29.2; 1.29.4;
Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.28 26-Sep-2008  macallan branches: 1.28.2; 1.28.8;
Provide access functions for mac-io registers in order to get rid of
private mappings some drivers use which won't work anymore in the new
post-ppcoea-renovation world order.
 1.27 17-Oct-2007  garbled branches: 1.27.16; 1.27.20; 1.27.22; 1.27.26;
Merge the ppcoea-renovation branch to HEAD.

This branch was a major cleanup and rototill of many of the various OEA
cpu based PPC ports that focused on sharing as much code as possible
between the various ports to eliminate near-identical copies of files in
every tree. Additionally there is a new PIC system that unifies the
interface to interrupt code for all different OEA ppc arches. The work
for this branch was done by a variety of people, too long to list here.

TODO:
bebox still needs work to complete the transition to -renovation.
ofppc still needs a bunch of work, which I will be looking at.
ev64260 still needs to be renovated
amigappc was not attempted.

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.26 18-Jan-2007  macallan branches: 1.26.6; 1.26.14; 1.26.22; 1.26.24; 1.26.26; 1.26.28;
fix accidential commit, this time really only add the bus_space_tag
 1.25 18-Jan-2007  macallan pass a bus_space_tag to children
 1.24 05-Aug-2006  sanjayl branches: 1.24.4;
1st cut of Powermac G5 support (uses bridge mode).
 1.23 11-Dec-2005  christos branches: 1.23.4; 1.23.8;
merge ktrace-lwp.
 1.22 05-Jun-2005  nathanw branches: 1.22.2;
constify skiplist.
 1.21 08-Jan-2005  briggs Make obio match multiple times to allow access to devices on systems
where there might be devices under two I/O bridges (like PowerBook G3s).
Attempt to have devices under 'gatwick' share parental interrupt. This
may still need some work, but a step in the right direction.
From Tim Kelly.
 1.20 09-Dec-2004  briggs Apply patch from Makoto Fujiwara (and Timm Wetzel) in PR port-macppc/15505
to enable internal modem for KeyLargo and Pangea.
 1.19 15-Jul-2003  lukem __KERNEL_RCSID()
 1.18 11-Jun-2003  hamajima branches: 1.18.2;
Support the PowerBook G4 12-inch (and maybe 17-inch).
Kauai ATA, new obio chip, and Japanese keymap for WSDISPLAY_COMPAT_RAWKBD

I tested only 12-inch Japanese model.
 1.17 01-Jan-2003  thorpej Use aprint_normal() for cfprint routines.
 1.16 02-Oct-2002  thorpej Use CFATTACH_DECL().
 1.15 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.14 17-Jun-2001  tsubai branches: 1.14.2; 1.14.8; 1.14.18;
Support the new iBook.
 1.13 02-Mar-2001  tsubai branches: 1.13.2;
Enable CD and microphone sound input on paddington based systems.
 1.12 27-Feb-2001  matt Back out change to print irq.
 1.11 27-Feb-2001  matt print out irq on unconf devices.
 1.10 03-Nov-2000  tsubai Get 6 interrupt cells from OF.
 1.9 08-Feb-2000  tsubai branches: 1.9.4;
Fix typo.
 1.8 07-Feb-2000  tsubai Don't print "... not configured" message for non real devices
like escc-legacy.
 1.7 23-Jan-2000  tsubai Match "keylargo".
 1.6 01-May-1999  tsubai branches: 1.6.2;
Find "mac-io" and "/pci/mac-io".
 1.5 22-Dec-1998  tsubai branches: 1.5.2;
Search "interrupts" property if "AAPL,interrupts" is not found.
 1.4 03-Nov-1998  tsubai Add "Paddington" ID.
 1.3 13-Jul-1998  tsubai Add support for G3 Mac.
 1.2 21-Jun-1998  tsubai Add support for "ohare" I/O controller.
 1.1 15-May-1998  tsubai Initial import of macppc port.
 1.5.2.1 06-May-1999  perry branches: 1.5.2.1.2;
pullup 1.5->1.6 (thorpej)
 1.5.2.1.2.1 21-Jun-1999  thorpej Sync w/ -current.
 1.6.2.3 12-Mar-2001  bouyer Sync with HEAD.
 1.6.2.2 22-Nov-2000  bouyer Sync with HEAD.
 1.6.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.9.4.1 18-Jun-2001  jhawk Pull up revision 1.14 (requested by tsubai):
Support the new dual USB iBook.
 1.13.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.14.18.1 19-Jun-2003  grant Pull up revision 1.18 (requested by hamajima in ticket #1323):

Support the PowerBook G4 12-inch (and maybe 17-inch).
Kauai ATA, new obio chip, and Japanese keymap for WSDISPLAY_COMPAT_RAWKBD
 1.14.8.3 03-Jan-2003  thorpej Sync with HEAD.
 1.14.8.2 18-Oct-2002  nathanw Catch up to -current.
 1.14.8.1 17-Jun-2001  nathanw file obio.c was added on branch nathanw_sa on 2002-10-18 02:38:36 +0000
 1.14.2.1 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.18.2.6 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.18.2.5 17-Jan-2005  skrll Sync with HEAD.
 1.18.2.4 18-Dec-2004  skrll Sync with HEAD.
 1.18.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.18.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.18.2.1 03-Aug-2004  skrll Sync with HEAD
 1.22.2.3 27-Oct-2007  yamt sync with head.
 1.22.2.2 26-Feb-2007  yamt sync with head.
 1.22.2.1 30-Dec-2006  yamt sync with head.
 1.23.8.1 11-Aug-2006  yamt sync with head
 1.23.4.1 09-Sep-2006  rpaulo sync with head
 1.24.4.1 01-Feb-2007  ad Sync with head.
 1.26.28.1 25-Oct-2007  bouyer Sync with HEAD.
 1.26.26.1 18-Oct-2007  yamt sync with head.
 1.26.24.1 06-Nov-2007  matt sync with HEAD
 1.26.22.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.26.14.3 14-Aug-2007  macallan add support for bus speed control found in some Intrepid-based *Books,
like the 800MHz iBook G4
 1.26.14.2 18-Jun-2007  macallan fix a couple typos and don't forget to initialize ca_tag before using it
 1.26.14.1 07-Jun-2007  garbled Convert macppc to powerpc bus_space. Lots of work here from Matt Thomas,
as well as the common ofwoea code from myself. Compile tested only,
still probably needs some fine tuning.

Also in this commit:
Convert macppc to new shared ofwoea routines.
Lots of KNF.
 1.26.6.1 23-Oct-2007  ad Sync with head.
 1.27.26.1 19-Oct-2008  haad Sync with HEAD.
 1.27.22.1 10-Oct-2008  skrll Sync with HEAD.
 1.27.20.1 04-May-2009  yamt sync with head.
 1.27.16.1 28-Sep-2008  mjf Sync with HEAD.
 1.28.8.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.28.2.1 28-Apr-2009  skrll Sync with HEAD.
 1.29.4.2 21-Apr-2011  rmind sync with head
 1.29.4.1 05-Mar-2011  rmind sync with head
 1.29.2.1 22-Oct-2010  uebayasi Sync with HEAD (-D20101022).
 1.31.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.32.2.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.36.2.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.36.2.1 30-Oct-2012  yamt sync with head
 1.37.2.3 03-Dec-2017  jdolecek update from HEAD
 1.37.2.2 23-Jun-2013  tls resync from head
 1.37.2.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.43.2.3 25-Jun-2018  pgoyette Sync with HEAD
 1.43.2.2 21-May-2018  pgoyette Sync with HEAD
 1.43.2.1 30-Mar-2018  pgoyette Resolve conflicts between branch and HEAD
 1.47.2.1 03-Apr-2021  thorpej Sync with HEAD.
 1.48.2.2 04-Apr-2021  thorpej Associate the OpenFirmware phandle associated with a found device (including
PCI bus instances) by using CFARG_DEVHANDLE.
 1.48.2.1 21-Mar-2021  thorpej Give config_found() the same variadic arguments treatment as
config_search(). This commit only adds the CFARG_EOL sentinel
to the existing config_found() calls. Conversion of config_found_sm_loc()
and config_found_ia() call sites will be in subsequent commits.
 1.49.8.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.3 01-Jul-2025  macallan keylargo can have up to 4 pwm fans, act like it.
Also, do a better job finding which fans are actually in use.
 1.2 11-Sep-2021  macallan branches: 1.2.10;
fix license copypasta
NFC
 1.1 10-Sep-2021  macallan this driver allows to read the speeds of fans controlled via mac-io/fans/*
found in some G5, for example my 7,3
based on guesswork and observation
 1.2.10.1 02-Aug-2025  perseant Sync with HEAD
 1.7 08-Sep-2025  macallan move register definitions into the headers they belong
 1.6 20-Aug-2025  macallan move GPIO definitions to obiovar.h
 1.5 16-Apr-2020  rin Revert previous for now:
http://mail-index.netbsd.org/source-changes/2020/04/16/msg116278.html

The reasoning turned out to be wrong; __KERNEL_RCSID() in header files
does *not* overwrite RCSID in main source files. The real problem is that
it inserts its RCSID into *every* object files. However, it can be still
useful even if heavily duplicated.
 1.4 16-Apr-2020  rin Stop using __KERNEL_RCSID() in header files; it confuses ident(1) by
overwriting RCSID in main source files.

XXX
The first argument of __KERNEL_RCSID() is neglected for ELF. If we wish
to have RCSID of header files in kernel binary, we need something like
__FBSDID() macro in FreeBSD.
 1.3 04-May-2018  macallan branches: 1.3.12;
map 64KB register space on G5, provide function to bus_space_subregion()
from this area so we don't run into mapping conflicts on G5
Not really relevant on 32bit where we BAT-map everything
 1.2 26-Sep-2008  macallan branches: 1.2.2; 1.2.4; 1.2.6; 1.2.18; 1.2.88;
add some register definitions
 1.1 26-Sep-2008  macallan Provide access functions for mac-io registers in order to get rid of
private mappings some drivers use which won't work anymore in the new
post-ppcoea-renovation world order.
 1.2.88.1 21-May-2018  pgoyette Sync with HEAD
 1.2.18.2 04-May-2009  yamt sync with head.
 1.2.18.1 26-Sep-2008  yamt file obiovar.h was added on branch yamt-nfs-mp on 2009-05-04 08:11:29 +0000
 1.2.6.2 19-Oct-2008  haad Sync with HEAD.
 1.2.6.1 26-Sep-2008  haad file obiovar.h was added on branch haad-dm on 2008-10-19 22:15:52 +0000
 1.2.4.2 10-Oct-2008  skrll Sync with HEAD.
 1.2.4.1 26-Sep-2008  skrll file obiovar.h was added on branch wrstuden-revivesa on 2008-10-10 22:29:05 +0000
 1.2.2.2 28-Sep-2008  mjf Sync with HEAD.
 1.2.2.1 26-Sep-2008  mjf file obiovar.h was added on branch mjf-devfs2 on 2008-09-28 10:40:03 +0000
 1.3.12.1 20-Apr-2020  bouyer Sync with HEAD
 1.73 20-Dec-2023  thorpej Remove unnecessary <sys/malloc.h>.
 1.72 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.71 24-Apr-2021  thorpej branches: 1.71.8;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).
 1.70 23-May-2016  chs branches: 1.70.32;
remove unused variables.
 1.69 27-Oct-2012  chs branches: 1.69.14;
split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.68 13-Mar-2012  elad branches: 1.68.2;
Replace the remaining KAUTH_GENERIC_ISSUSER authorization calls with
something meaningful. All relevant documentation has been updated or
written.

Most of these changes were brought up in the following messages:

http://mail-index.netbsd.org/tech-kern/2012/01/18/msg012490.html
http://mail-index.netbsd.org/tech-kern/2012/01/19/msg012502.html
http://mail-index.netbsd.org/tech-kern/2012/02/17/msg012728.html

Thanks to christos, manu, njoly, and jmmv for input.

Huge thanks to pgoyette for spinning these changes through some build
cycles and ATF.
 1.67 01-Jul-2011  dyoung branches: 1.67.2; 1.67.6;
#include <sys/bus.h> instead of <machine/bus.h>.
 1.66 18-Jun-2011  matt struct device * -> device_t
struct cfdata * -> cfdata_t
use device accessors, use device_private.
some softc/device_t splits (macppc needs a bunch more)
aprint*_dev used considerably more
 1.65 20-Dec-2010  matt branches: 1.65.6;
Move counting of faults, traps, intrs, soft[intr]s, syscalls, and nswtch
from uvmexp to per-cpu cpu_data and move them to 64bits. Remove unneeded
includes of <uvm/uvm_extern.h> and/or <uvm/uvm.h>.
 1.64 06-May-2009  elad branches: 1.64.4;
Replace curlwp->l_cred with kauth_cred_get().

Mailing list reference:

http://mail-index.netbsd.org/tech-kern/2009/05/05/msg005038.html
 1.63 26-Nov-2007  garbled branches: 1.63.18; 1.63.32;
Apply a set of patches from Frank Wille to make the genfb attachment work
better on ofppc. In doing so, we also move a few functions around in
macppc and the generic ofw powerpc stuff to allow better sharing of code.
Also, introduce a model_init function.

move ofb_cons.c from macppc/dev to powerpc/oea and rename it to rascons.
This gets rid of some naming confusion, and makes it OFW-MI rather than
macppc specific.
 1.62 17-Oct-2007  garbled branches: 1.62.2;
Merge the ppcoea-renovation branch to HEAD.

This branch was a major cleanup and rototill of many of the various OEA
cpu based PPC ports that focused on sharing as much code as possible
between the various ports to eliminate near-identical copies of files in
every tree. Additionally there is a new PIC system that unifies the
interface to interrupt code for all different OEA ppc arches. The work
for this branch was done by a variety of people, too long to list here.

TODO:
bebox still needs work to complete the transition to -renovation.
ofppc still needs a bunch of work, which I will be looking at.
ev64260 still needs to be renovated
amigappc was not attempted.

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.61 05-Aug-2007  macallan branches: 1.61.2;
fix another typo, now wsfb on ofb should work properly
 1.60 24-Jul-2007  macallan branches: 1.60.4;
add support for ioctl(WSDISPLAYIO_LINEBYTES) so XFree86/wsfb should work now.
Doh.
 1.59 21-Jul-2007  ad Don't depend on uvm_extern.h pulling in proc.h.
 1.58 16-Jul-2007  macallan branches: 1.58.2; 1.58.4;
fix a typo - if we pass no parameters to OF_interpret we better don't say
we do...
 1.57 25-Mar-2007  macallan branches: 1.57.4;
attach a drm
 1.56 04-Mar-2007  christos branches: 1.56.2; 1.56.4; 1.56.6;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.55 28-Feb-2007  thorpej TRUE -> true, FALSE -> false
 1.54 20-Jan-2007  he branches: 1.54.2;
Unify the declaration of OF_interpret() between sparc{,64} and macppc
by adding the "nargs" argument to the macppc version, and fix the macppc
ports uses of OF_interpret() accordingly.

Also move the declaration of OF_interpt() from macppc's autoconf.h to
ofw/openfirm.h. This fixes the build of the macppc port.

Approved by macallan@.
 1.53 16-Dec-2006  macallan (hopefully) fix a panic when ofb attaches without being console
 1.52 08-Nov-2006  macallan branches: 1.52.2;
split ofb into one part that attaches right on kernel startup and one that
attaches to pci so we can build kernels with - say - machfb but without
ofb at pci.
 1.51 05-Aug-2006  sanjayl branches: 1.51.4; 1.51.6;
1st cut of Powermac G5 support (uses bridge mode).
 1.50 23-Jul-2006  ad Use the LWP cached credentials where sane.
 1.49 14-May-2006  elad integrate kauth.
 1.48 12-Apr-2006  jmmv Add an extra cookie to the ioctl and mmap wsdisplay accessops that points
to the screen on which they are being called. The driver cannot guess
this by itself but it is needed to implement, at least, the getwschar and
putwschar functions in the correct place. There are no functional changes
yet.

Tested on i386 (vga, vga_raster, machfb, vesafb), macppc and sparc64.
Suggested and reviewed by macallan@.
 1.47 16-Feb-2006  macallan branches: 1.47.2; 1.47.4; 1.47.6;
also check child nodes when checking if we attach to what OF thinks is the
console since some Radeons ( and probably others ) can have more than one
display - in this case /chosen and ofb's node would mismatch.
 1.46 16-Feb-2006  macallan bail out when trying to attach to something that's not the console.
Fixes problems with more than one graphics card. Since OF doesn't set up
any secondary graphics devices anyway we don't lose anything.
 1.45 12-Feb-2006  macallan Add support for colour and virtual consoles
 1.44 07-Feb-2006  macallan ansify, de-__P(), sprinkle static
 1.43 11-Dec-2005  christos branches: 1.43.2; 1.43.4; 1.43.6;
merge ktrace-lwp.
 1.42 22-Sep-2005  macallan - center output to match firmware settings when using the ROM font
- allow the super user to mmap() the PCI IO area corresponding to ofb at offset
0xf2000000 - needed by some XFree drivers ( approved by Bill Studenmund )
- add a hack to allow mmap()ing offset 0xa0000 - 0xbffff if not covered by the
regular framebuffer mapping at offset 0 ( disabled by default, use options
OFB_FAKE_VGA_FB ) - this allows buggy XFree drivers which expect the VGA
framebuffer at this address to work.
 1.41 17-Dec-2004  briggs branches: 1.41.10;
Back out part of previous. OF_open() works fine with /chaos/control, but
is a bit picky about interrupts.
 1.40 15-Dec-2004  briggs * Don't try to clear the screen if we failed to map it.
* Don't try to call OF_open for /chaos@F0000000/control@B -- it hangs.
 1.39 24-Apr-2004  kleink Update for new pci_devinfo(9) signature.
 1.38 13-Nov-2003  chs eliminate uvm_useracc() in favor of checking the return value of
copyin() or copyout().

uvm_useracc() tells us whether the mapping permissions allow access to
the desired part of an address space, and many callers assume that
this is the same as knowing whether an attempt to access that part of
the address space will succeed. however, access to user space can
fail for reasons other than insufficient permission, most notably that
paging in any non-resident data can fail due to i/o errors. most of
the callers of uvm_useracc() make the above incorrect assumption. the
rest are all misguided optimizations, which optimize for the case
where an operation will fail. we'd rather optimize for operations
succeeding, in which case we should just attempt the access and handle
failures due to insufficient permissions the same way we handle i/o
errors. since there appear to be no good uses of uvm_useracc(), we'll
just remove it.
 1.37 20-Oct-2003  matt Reorganize the way powerpc port install machine specific headers.
Use <powerpc/oea/bat.h> exclusively and remove <machine/bat.h> and
<powerpc/bat.h>. Remove unneeded <machine/cpufunc.h>. To insure
1:1 correspondence of <powerpc/FOO.h> to <machine/FOO.h> include
"../../powerpc/include/Makefile" in "arch/FOO/include/Makefile".
Incororpate <byte_swap.h> into <bswap.h> and then byte_swap.h
 1.36 15-Jul-2003  lukem __KERNEL_RCSID()
 1.35 29-Jun-2003  fvdl branches: 1.35.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.34 29-Jun-2003  darrenr 'struct proc *' -> 'struct lwp *' as required to get GENERIC for macppc built
 1.33 15-Feb-2003  briggs Initialize the framebuffer BAT with BAT_G, too. This marks the region
as (G)uarded, protecting it from the processor being too aggressive in
reordering and prefetching. This allows OFB_ENABLE_CACHE to work on my
Powerbook G4.

Thanks to matt@ for suggesting this fix. "It's the right thing to do."
 1.32 02-Oct-2002  thorpej Use CFATTACH_DECL().
 1.31 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.30 07-Aug-2002  chs for ofb_enable_cache, turn on the BAT_M bit as well to prevent
the framebuffer from getting scrambled on MP systems.
 1.29 07-Jul-2002  matt Update OFB_ENABLE_CACHE to search for a empty bat that does not
conflict the USER_SR or one of the kernel SRs.
 1.28 04-Jul-2002  junyoung alloc_attr -> allocattr

Approved by Matthias Drochner.
 1.27 24-Jun-2002  nathanw Pass through the PCI configuration ioctls, like vga_pci.c does.
 1.26 17-Mar-2002  atatat branches: 1.26.4; 1.26.6;
Convert ioctl code to use EPASSTHROUGH instead of -1 or ENOTTY for
indicating an unhandled "command". ERESTART is -1, which can lead to
confusion. ERESTART has been moved to -3 and EPASSTHROUGH has been
placed at -4. No ioctl code should now return -1 anywhere. The
ioctl() system call is now properly restartable.
 1.25 05-Aug-2001  jdolecek branches: 1.25.6;
use unsigned variable types as appropriate
 1.24 22-Jul-2001  wiz bcopy -> memcpy, bzero -> memset, bcmp -> memcmp.
Reviewed by Matt Thomas, ok'd by Tsubai Masanari.
 1.23 10-Jun-2001  tsubai branches: 1.23.2;
Use machine/bat.h rather than powerpc/mpc6xx/bat.h.
 1.22 10-Jun-2001  tsubai Use ofb_softc again.
 1.21 10-Jun-2001  tsubai Enable color! call in ofb_putcmap again.
Matt, please don't remove codes silently without confirmation.
(At least, leave a log message!)
 1.20 08-Jun-2001  matt Make macppc compile by default with -Wall -Wmissing-prototype in addition
to its currently enabled warnings. For the lack of a better place, most
global function prototype wound up in <machine/autoconf.h> unless there
was a better place for them. ofb_* structs renamed to offb_* to avoid
conflict with ofb_softc in <dev/ofw/openfirm.h>
 1.19 06-Jun-2001  matt Changes new pmap, common param.h, vmparam.h, and moved includes.
 1.18 15-Mar-2001  tsubai Use write-through caching for video ram. (Disabled by default, for now.)
 1.17 02-Nov-2000  tsubai branches: 1.17.2;
Don't assume 12x22 font.
 1.16 01-Oct-2000  tsubai Get the correct OF node of the screen because PowerBooks have two screens
in one PCI device.
 1.15 29-Jun-2000  mrg remove include of <vm/vm.h>. <vm/vm.h> -> <uvm/uvm_extern.h>
 1.14 26-Jun-2000  simonb Change the kernel mmap interface so that the offset to map is an
"off_t" and the return value is a "paddr_t" to allow mappings
at offsets past 2^31 bytes. Somewhat inspired by FreeBSD, which
only changed the offset to a "vm_offset_t".

Includes updates for the i386, pc532 and sh3 mmmmap from Jason Thorpe.
 1.13 19-Jun-2000  tsubai branches: 1.13.2;
Allow mmap of frame buffer registers.
 1.12 02-Apr-2000  tsubai branches: 1.12.2;
Make sure color rgb:0/0/0 is black.
 1.11 09-Feb-2000  tsubai Use dev/rasops instead of dev/rcons.
 1.10 06-Dec-1999  drochner update for changed struct wsdisplay_accessops:show_screen signature.
no functional changes
 1.9 24-Mar-1999  mrg branches: 1.9.8; 1.9.14;
completely remove Mach VM support. all that is left is the all the
header files as UVM still uses (most of) these.
 1.8 19-Feb-1999  tsubai Use 6x11 font if screen size is smaller than 1024x768.
(Open Firmware ROM has 6x11 font.)
 1.7 02-Feb-1999  tsubai Don't use BAT register. (not needed now.)
 1.6 11-Jan-1999  drochner remove dummy "load_font" entries
 1.5 22-Dec-1998  tsubai Display frame buffer type when attached.
 1.4 19-Nov-1998  mrg fix problems in many d_mmap routines:
- returned EOPNOTSUPP rather than -1.
- no check for negative offset.
many of these fix potential security problems in these drivers.


XXX XXX XXX
the d_mmap cdev routine should be changed to have a prototype like:
paddr_t (*d_mmap) __P((dev_t, off_t, int));

by someone!
 1.3 15-Oct-1998  tsubai /chaos/control support. (tested 640x480 mode only)
 1.2 14-Oct-1998  tsubai Fix typo.
 1.1 14-Oct-1998  tsubai akbd: wskbd support.
ofb: OpenFirmware generic framebuffer.
 1.9.14.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.9.8.3 27-Mar-2001  bouyer Sync with HEAD.
 1.9.8.2 22-Nov-2000  bouyer Sync with HEAD.
 1.9.8.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.12.2.1 22-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.13.2.3 16-Aug-2001  tv Pullup [jdolecek]:

sys/arch/amiga/dev/grf_cl.c 1.26
sys/arch/amiga/dev/grfioctl.h 1.14
sys/arch/hpcmips/dev/plumvideo.c 1.20
sys/arch/macppc/dev/ofb.c 1.25
sys/arch/sparc/dev/cgtwo.c 1.35
sys/arch/sparc/include/fbio.h patch
sys/arch/sparc64/include/fbio.h patch
sys/arch/sun3/dev/cg2.c 1.14
sys/arch/sun3/include/fbio.h patch
sys/dev/pci/tga.c 1.35
sys/dev/tc/cfb.c 1.28
sys/dev/tc/mfb.c 1.27
sys/dev/tc/sfb.c 1.46
sys/dev/tc/sfbplus.c 1.10 via patch
sys/dev/tc/tfb.c 1.30
sys/dev/tc/xcfb.c 1.23
sys/net/if_ppp.c 1.71

Use unsigned variable types to make bounds checking more correct.
 1.13.2.2 01-Nov-2000  tv Pullup 1.16 [tsubai, mycroft]:
Get the correct OF node of the screen because PowerBooks have two screens
in one PCI device.
 1.13.2.1 30-Jun-2000  simonb Pull up mmap paddr_t/off_t changes from trunk.
 1.17.2.2 21-Jun-2001  nathanw Catch up to -current.
 1.17.2.1 09-Apr-2001  nathanw Catch up with -current.
 1.23.2.5 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.23.2.4 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.23.2.3 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.23.2.2 25-Aug-2001  thorpej Merge Aug 24 -current into the kqueue branch.
 1.23.2.1 03-Aug-2001  lukem update to -current
 1.25.6.5 18-Oct-2002  nathanw Catch up to -current.
 1.25.6.4 13-Aug-2002  nathanw Catch up to -current.
 1.25.6.3 01-Aug-2002  nathanw Catch up to -current.
 1.25.6.2 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.25.6.1 05-Aug-2001  nathanw file ofb.c was added on branch nathanw_sa on 2002-04-01 07:40:53 +0000
 1.26.6.1 24-Jun-2003  grant Pull up revisions 1.29-1.30, 1.33 (requested by briggs in ticket #1274):

Update OFB_ENABLE_CACHE to search for a empty bat that does not
conflict the USER_SR or one of the kernel SRs.

for ofb_enable_cache, turn on the BAT_M bit as well to prevent
the framebuffer from getting scrambled on MP systems.

Initialize the framebuffer BAT with BAT_G, too. This marks the region
as (G)uarded, protecting it from the processor being too aggressive in
reordering and prefetching. This allows OFB_ENABLE_CACHE to work on my
Powerbook G4.
 1.26.4.2 31-Aug-2002  gehenna catch up with -current.
 1.26.4.1 16-Jul-2002  gehenna catch up with -current.
 1.35.2.6 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.35.2.5 18-Dec-2004  skrll Sync with HEAD.
 1.35.2.4 18-Nov-2004  skrll Adapt to branch. macppc release builds.
 1.35.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.35.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.35.2.1 03-Aug-2004  skrll Sync with HEAD
 1.41.10.5 07-Dec-2007  yamt sync with head
 1.41.10.4 03-Sep-2007  yamt sync with head.
 1.41.10.3 26-Feb-2007  yamt sync with head.
 1.41.10.2 30-Dec-2006  yamt sync with head.
 1.41.10.1 21-Jun-2006  yamt sync with head.
 1.43.6.2 01-Jun-2006  kardel Sync with head.
 1.43.6.1 22-Apr-2006  simonb Sync with head.
 1.43.4.1 09-Sep-2006  rpaulo sync with head
 1.43.2.1 18-Feb-2006  yamt sync with head.
 1.47.6.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.47.4.4 13-May-2006  elad sprinkle some #include <sys/kauth.h> in files that use kauth kpi but
don't include it yet. hopefully this will prevent some fallout.
 1.47.4.3 19-Apr-2006  elad sync with head - hopefully this will work
 1.47.4.2 10-Mar-2006  elad generic_authorize() -> kauth_authorize_generic().
 1.47.4.1 08-Mar-2006  elad Adapt to kernel authorization KPI.

I expect *some* lossage here...
 1.47.2.2 11-Aug-2006  yamt sync with head
 1.47.2.1 24-May-2006  yamt sync with head.
 1.51.6.2 18-Dec-2006  yamt sync with head.
 1.51.6.1 10-Dec-2006  yamt sync with head.
 1.51.4.3 01-Feb-2007  ad Sync with head.
 1.51.4.2 12-Jan-2007  ad Sync with head.
 1.51.4.1 18-Nov-2006  ad Sync with head.
 1.52.2.2 20-Aug-2008  bouyer Pull up following revision(s) (requested by macallan in ticket #1178):
sys/arch/macppc/dev/ofb.c: revision 1.61
fix another typo, now wsfb on ofb should work properly
 1.52.2.1 12-Jan-2007  bouyer branches: 1.52.2.1.2;
Pull up following revision(s) (requested by macallan in ticket #349):
sys/arch/macppc/dev/ofb.c: revision 1.53
sys/arch/macppc/dev/ofb_cons.c: revision 1.2
(hopefully) fix a panic when ofb attaches without being console
 1.52.2.1.2.1 04-Sep-2008  skrll Sync with netbsd-4.
 1.54.2.2 15-Apr-2007  yamt sync with head.
 1.54.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.56.6.1 29-Mar-2007  reinoud Pullup to -current
 1.56.4.1 11-Jul-2007  mjf Sync with head.
 1.56.2.3 03-Dec-2007  ad Sync with HEAD.
 1.56.2.2 20-Aug-2007  ad Sync with HEAD.
 1.56.2.1 10-Apr-2007  ad Sync with head.
 1.57.4.3 03-Oct-2007  garbled Sync with HEAD
 1.57.4.2 07-Aug-2007  macallan sync with HEAD
 1.57.4.1 02-Aug-2007  macallan sync with HEAD
 1.58.4.1 15-Aug-2007  skrll Sync with HEAD.
 1.58.2.1 07-Aug-2007  matt Sync with HEAD.
 1.60.4.2 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.60.4.1 09-Aug-2007  jmcneill Sync with HEAD.
 1.61.2.2 09-Jan-2008  matt sync with HEAD
 1.61.2.1 06-Nov-2007  matt sync with HEAD
 1.62.2.1 08-Dec-2007  mjf Sync with HEAD.
 1.63.32.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.63.18.1 16-May-2009  yamt sync with head
 1.64.4.1 05-Mar-2011  rmind sync with head
 1.65.6.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.67.6.1 05-Apr-2012  mrg sync to latest -current.
 1.67.2.2 30-Oct-2012  yamt sync with head
 1.67.2.1 17-Apr-2012  yamt sync with head
 1.68.2.2 03-Dec-2017  jdolecek update from HEAD
 1.68.2.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.69.14.1 29-May-2016  skrll Sync with HEAD
 1.70.32.3 24-Apr-2021  thorpej Make sure to explcitly specify the "wsemuldisplaydev" interface attribute
when attaching the wscons display instance, because these devices can
also attach children using the "drm" interface attribute.
 1.70.32.2 02-Apr-2021  thorpej config_found_ia() -> config_found() w/ CFARG_IATTR.
 1.70.32.1 21-Mar-2021  thorpej Give config_found() the same variadic arguments treatment as
config_search(). This commit only adds the CFARG_EOL sentinel
to the existing config_found() calls. Conversion of config_found_sm_loc()
and config_found_ia() call sites will be in subsequent commits.
 1.71.8.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.9 26-Nov-2007  garbled Apply a set of patches from Frank Wille to make the genfb attachment work
better on ofppc. In doing so, we also move a few functions around in
macppc and the generic ofw powerpc stuff to allow better sharing of code.
Also, introduce a model_init function.

move ofb_cons.c from macppc/dev to powerpc/oea and rename it to rascons.
This gets rid of some naming confusion, and makes it OFW-MI rather than
macppc specific.
 1.8 17-Oct-2007  garbled branches: 1.8.2;
Merge the ppcoea-renovation branch to HEAD.

This branch was a major cleanup and rototill of many of the various OEA
cpu based PPC ports that focused on sharing as much code as possible
between the various ports to eliminate near-identical copies of files in
every tree. Additionally there is a new PIC system that unifies the
interface to interrupt code for all different OEA ppc arches. The work
for this branch was done by a variety of people, too long to list here.

TODO:
bebox still needs work to complete the transition to -renovation.
ofppc still needs a bunch of work, which I will be looking at.
ev64260 still needs to be renovated
amigappc was not attempted.

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.7 28-Feb-2007  thorpej branches: 1.7.2; 1.7.10; 1.7.18; 1.7.20; 1.7.22; 1.7.24;
TRUE -> true, FALSE -> false
 1.6 05-Feb-2007  macallan branches: 1.6.2;
fix fallout from making OF_interpret compatible with the other OF platforms
noticed by Leon Zadorin
 1.5 20-Jan-2007  he Unify the declaration of OF_interpret() between sparc{,64} and macppc
by adding the "nargs" argument to the macppc version, and fix the macppc
ports uses of OF_interpret() accordingly.

Also move the declaration of OF_interpt() from macppc's autoconf.h to
ofw/openfirm.h. This fixes the build of the macppc port.

Approved by macallan@.
 1.4 17-Jan-2007  macallan finding the console node / instance handle moved into machdep.c
 1.3 16-Dec-2006  macallan branches: 1.3.2;
make this compile without wsdisplay
 1.2 16-Dec-2006  macallan (hopefully) fix a panic when ofb attaches without being console
 1.1 08-Nov-2006  macallan branches: 1.1.2; 1.1.4; 1.1.6;
split ofb into one part that attaches right on kernel startup and one that
attaches to pci so we can build kernels with - say - machfb but without
ofb at pci.
 1.1.6.3 18-Dec-2006  yamt sync with head.
 1.1.6.2 10-Dec-2006  yamt sync with head.
 1.1.6.1 08-Nov-2006  yamt file ofb_cons.c was added on branch yamt-splraiseipl on 2006-12-10 07:16:26 +0000
 1.1.4.3 04-Mar-2007  bouyer Pull up following revision(s) (requested by macallan in ticket #475):
sys/arch/macppc/dev/ofb_cons.c: revision 1.4
finding the console node / instance handle moved into machdep.c
 1.1.4.2 12-Jan-2007  bouyer Pull up following revision(s) (requested by macallan in ticket #353):
sys/arch/macppc/dev/ofb_cons.c: revision 1.3
sys/arch/macppc/macppc/machdep.c: revision 1.143
make this compile without wsdisplay
 1.1.4.1 12-Jan-2007  bouyer Pull up following revision(s) (requested by macallan in ticket #349):
sys/arch/macppc/dev/ofb.c: revision 1.53
sys/arch/macppc/dev/ofb_cons.c: revision 1.2
(hopefully) fix a panic when ofb attaches without being console
 1.1.2.5 09-Feb-2007  ad Sync with HEAD.
 1.1.2.4 01-Feb-2007  ad Sync with head.
 1.1.2.3 12-Jan-2007  ad Sync with head.
 1.1.2.2 18-Nov-2006  ad Sync with head.
 1.1.2.1 08-Nov-2006  ad file ofb_cons.c was added on branch newlock2 on 2006-11-18 21:29:24 +0000
 1.3.2.6 07-Dec-2007  yamt sync with head
 1.3.2.5 27-Oct-2007  yamt sync with head.
 1.3.2.4 03-Sep-2007  yamt sync with head.
 1.3.2.3 26-Feb-2007  yamt sync with head.
 1.3.2.2 30-Dec-2006  yamt sync with head.
 1.3.2.1 16-Dec-2006  yamt file ofb_cons.c was added on branch yamt-lazymbuf on 2006-12-30 20:46:26 +0000
 1.6.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.7.24.1 25-Oct-2007  bouyer Sync with HEAD.
 1.7.22.1 18-Oct-2007  yamt sync with head.
 1.7.20.2 23-Mar-2008  matt sync with HEAD
 1.7.20.1 06-Nov-2007  matt sync with HEAD
 1.7.18.2 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.7.18.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.7.10.1 06-May-2007  macallan initially mimic firmware output whenever possible
 1.7.2.1 23-Oct-2007  ad Sync with head.
 1.8.2.1 08-Dec-2007  mjf Sync with HEAD.
 1.11 26-Nov-2007  garbled Apply a set of patches from Frank Wille to make the genfb attachment work
better on ofppc. In doing so, we also move a few functions around in
macppc and the generic ofw powerpc stuff to allow better sharing of code.
Also, introduce a model_init function.

move ofb_cons.c from macppc/dev to powerpc/oea and rename it to rascons.
This gets rid of some naming confusion, and makes it OFW-MI rather than
macppc specific.
 1.10 08-Nov-2006  macallan branches: 1.10.8; 1.10.26; 1.10.28; 1.10.34;
split ofb into one part that attaches right on kernel startup and one that
attaches to pci so we can build kernels with - say - machfb but without
ofb at pci.
 1.9 12-Feb-2006  macallan branches: 1.9.14; 1.9.16;
Add support for colour and virtual consoles
 1.8 11-Dec-2005  christos branches: 1.8.2; 1.8.4; 1.8.6;
merge ktrace-lwp.
 1.7 23-Sep-2005  macallan forgot to commit this along with ofb.c
 1.6 24-Jun-2002  nathanw branches: 1.6.6; 1.6.22;
Pass through the PCI configuration ioctls, like vga_pci.c does.
 1.5 10-Jun-2001  tsubai branches: 1.5.2; 1.5.8; 1.5.16;
Forgot to commit this; s/offb/ofb/.
 1.4 08-Jun-2001  matt Make macppc compile by default with -Wall -Wmissing-prototype in addition
to its currently enabled warnings. For the lack of a better place, most
global function prototype wound up in <machine/autoconf.h> unless there
was a better place for them. ofb_* structs renamed to offb_* to avoid
conflict with ofb_softc in <dev/ofw/openfirm.h>
 1.3 19-Jun-2000  tsubai branches: 1.3.4;
Allow mmap of frame buffer registers.
 1.2 09-Feb-2000  tsubai branches: 1.2.2;
Use dev/rasops instead of dev/rcons.
 1.1 14-Oct-1998  tsubai branches: 1.1.12;
akbd: wskbd support.
ofb: OpenFirmware generic framebuffer.
 1.1.12.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.2.2.1 22-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.3.4.1 21-Jun-2001  nathanw Catch up to -current.
 1.5.16.1 16-Jul-2002  gehenna catch up with -current.
 1.5.8.2 01-Aug-2002  nathanw Catch up to -current.
 1.5.8.1 10-Jun-2001  nathanw file ofbvar.h was added on branch nathanw_sa on 2002-08-01 02:42:24 +0000
 1.5.2.1 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.6.22.3 07-Dec-2007  yamt sync with head
 1.6.22.2 30-Dec-2006  yamt sync with head.
 1.6.22.1 21-Jun-2006  yamt sync with head.
 1.6.6.1 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.8.6.1 22-Apr-2006  simonb Sync with head.
 1.8.4.1 09-Sep-2006  rpaulo sync with head
 1.8.2.1 18-Feb-2006  yamt sync with head.
 1.9.16.1 10-Dec-2006  yamt sync with head.
 1.9.14.1 18-Nov-2006  ad Sync with head.
 1.10.34.1 08-Dec-2007  mjf Sync with HEAD.
 1.10.28.1 23-Mar-2008  matt sync with HEAD
 1.10.26.1 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.10.8.1 03-Dec-2007  ad Sync with HEAD.
 1.30 26-Feb-2018  sevan Remove support for macofcons(4), it's not actually possible to build a kernel
with it enabled - See PR port-macppc/53004 and it may have further problems even
so.
From <macallan>:
"There is some early console code that uses OF output but it causes problems
when we get close to MMU setup - I think it can go, it hasn't been enabled in
any config in at least a decade as far as I know."
 1.29 25-Jul-2014  dholland Add d_discard to all struct cdevsw instances I could find.

All have been set to "nodiscard"; some should get a real implementation.
 1.28 16-Mar-2014  dholland branches: 1.28.2;
Change (mostly mechanically) every cdevsw/bdevsw I can find to use
designated initializers.

I have not built every extant kernel so I have probably broken at
least one build; however I've also found and fixed some wrong
cdevsw/bdevsw entries so even if so I think we come out ahead.
 1.27 27-Oct-2012  chs branches: 1.27.2;
split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.26 18-Jun-2011  matt branches: 1.26.2; 1.26.12;
struct device * -> device_t
struct cfdata * -> cfdata_t
use device accessors, use device_private.
some softc/device_t splits (macppc needs a bunch more)
aprint*_dev used considerably more
 1.25 24-Apr-2011  rmind branches: 1.25.2;
Rename ttymalloc() to tty_alloc(), and ttyfree() to tty_free() for
consistency. Remove some unnecessary malloc.h inclusions as well.
 1.24 14-Mar-2009  dsl branches: 1.24.4; 1.24.6;
Remove all the __P() from sys (excluding sys/dist)
Diff checked with grep and MK1 eyeball.
i386 and amd64 GENERIC and sys still build.
 1.23 13-Jun-2008  cegger branches: 1.23.4; 1.23.10;
use device_lookup_private to get softc
 1.22 19-Nov-2007  ad branches: 1.22.14; 1.22.16; 1.22.18; 1.22.20; 1.22.22;
- Factor out too many copies of the same bit of tty code.
- Fix another tty signalling/wakeup problem.
 1.21 18-Oct-2007  joerg branches: 1.21.2;
Initialise the callbacks for tty.t_rstrt_ch in ttymalloc
as all drivers but Sun/SPARC's kd.c use the same arguments.
Separate callout_reset into callout_schedule and the initial
callout_setfunc using that.
 1.20 04-Mar-2007  christos branches: 1.20.2; 1.20.18; 1.20.20; 1.20.24;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.19 01-Oct-2006  elad branches: 1.19.4;
Adapt MD code to KAUTH_DEVICE_TTY_OPEN. Patch from Matt Fleming, thanks!
 1.18 23-Jul-2006  ad branches: 1.18.4; 1.18.6;
Use the LWP cached credentials where sane.
 1.17 14-May-2006  elad integrate kauth.
 1.16 20-Jan-2006  xtraeme branches: 1.16.2; 1.16.4; 1.16.6; 1.16.8; 1.16.10;
ktrace-lwp fallout. ok'ed by skrll.
 1.15 11-Dec-2005  christos branches: 1.15.2;
merge ktrace-lwp.
 1.14 04-Nov-2003  aymeric branches: 1.14.16;
. ANSIfy, make compile
. get rid of kbd_intr() and low-level keyboard handling
 1.13 15-Jul-2003  lukem __KERNEL_RCSID()
 1.12 23-Oct-2002  jdolecek branches: 1.12.6;
merge kqueue branch into -current

kqueue provides a stateful and efficient event notification framework
currently supported events include socket, file, directory, fifo,
pipe, tty and device changes, and monitoring of processes and signals

kqueue is supported by all writable filesystems in NetBSD tree
(with exception of Coda) and all device drivers supporting poll(2)

based on work done by Jonathan Lemon for FreeBSD
initial NetBSD port done by Luke Mewburn and Jason Thorpe
 1.11 02-Oct-2002  thorpej Use CFATTACH_DECL().
 1.10 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.9 06-Sep-2002  gehenna Merge the gehenna-devsw branch into the trunk.

This merge changes the device switch tables from static array to
dynamically generated by config(8).

- All device switches is defined as a constant structure in device drivers.

- The new grammer ``device-major'' is introduced to ``files''.

device-major <prefix> char <num> [block <num>] [<rules>]

- All device major numbers must be listed up in port dependent majors.<arch>
by using this grammer.

- Added the new naming convention.
The name of the device switch must be <prefix>_[bc]devsw for auto-generation
of device switch tables.

- The backward compatibility of loading block/character device
switch by LKM framework is broken. This is necessary to convert
from block/character device major to device name in runtime and vice versa.

- The restriction to assign device major by LKM is completely removed.
We don't need to reserve LKM entries for dynamic loading of device switch.

- In compile time, device major numbers list is packed into the kernel and
the LKM framework will refer it to assign device major number dynamically.
 1.8 17-Mar-2002  atatat branches: 1.8.4;
Convert ioctl code to use EPASSTHROUGH instead of -1 or ENOTTY for
indicating an unhandled "command". ERESTART is -1, which can lead to
confusion. ERESTART has been moved to -3 and EPASSTHROUGH has been
placed at -4. No ioctl code should now return -1 anywhere. The
ioctl() system call is now properly restartable.
 1.7 02-May-2001  scw branches: 1.7.2; 1.7.4; 1.7.8;
Add `l_poll' to `struct linesw' and provide an xxxpoll() entry point
in each tty driver to indirect through it.

This allows tty line-disciplines to handle poll(2) system calls.
 1.6 03-Nov-2000  wrstuden branches: 1.6.2;
Adjust to change in tty line discipline handling.
 1.5 02-Nov-2000  eeh Adapt to new line discipline scheme.
 1.4 23-Mar-2000  thorpej New callout mechanism with two major improvements over the old
timeout()/untimeout() API:
- Clients supply callout handle storage, thus eliminating problems of
resource allocation.
- Insertion and removal of callouts is constant time, important as
this facility is used quite a lot in the kernel.

The old timeout()/untimeout() API has been removed from the kernel.
 1.3 06-Mar-2000  thorpej - Implement cnbell() -- ring the console bell. The cn_bell entrypoint
is optional.
- Add cn_bell to statically allocated consdevs as appropriate.
 1.2 28-Jul-1998  thorpej branches: 1.2.14;
Ah, we use a _different_ ofcons; rename it macofcons to avoid the
name collision.
 1.1 02-Jul-1998  tsubai Display/Keyboard console support (by calling Openfirmware)
 1.2.14.2 22-Nov-2000  bouyer Sync with HEAD.
 1.2.14.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.6.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.7.8.5 11-Nov-2002  nathanw Catch up to -current
 1.7.8.4 18-Oct-2002  nathanw Catch up to -current.
 1.7.8.3 17-Sep-2002  nathanw Catch up to -current.
 1.7.8.2 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.7.8.1 02-May-2001  nathanw file ofcons.c was added on branch nathanw_sa on 2002-04-01 07:40:53 +0000
 1.7.4.2 13-Oct-2001  fvdl Revert the t_dev -> t_devvp change in struct tty. The way that tty
structs are currently used (especially by console ttys) aren't
ready for it, and this will require quite a few changes.
 1.7.4.1 10-Oct-2001  fvdl Convert all remaining devices.
 1.7.2.2 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.7.2.1 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.8.4.1 19-May-2002  gehenna Add device switch.
Replace the access to devsw table and the hard-coded majors with devsw API.
 1.12.6.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.12.6.2 18-Sep-2004  skrll Sync with HEAD.
 1.12.6.1 03-Aug-2004  skrll Sync with HEAD
 1.14.16.5 07-Dec-2007  yamt sync with head
 1.14.16.4 27-Oct-2007  yamt sync with head.
 1.14.16.3 03-Sep-2007  yamt sync with head.
 1.14.16.2 30-Dec-2006  yamt sync with head.
 1.14.16.1 21-Jun-2006  yamt sync with head.
 1.15.2.1 01-Feb-2006  yamt sync with head.
 1.16.10.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.16.8.3 13-May-2006  elad sprinkle some #include <sys/kauth.h> in files that use kauth kpi but
don't include it yet. hopefully this will prevent some fallout.
 1.16.8.2 10-Mar-2006  elad generic_authorize() -> kauth_authorize_generic().
 1.16.8.1 08-Mar-2006  elad Adapt to kernel authorization KPI.

I expect *some* lossage here...
 1.16.6.2 11-Aug-2006  yamt sync with head
 1.16.6.1 24-May-2006  yamt sync with head.
 1.16.4.1 01-Jun-2006  kardel Sync with head.
 1.16.2.1 09-Sep-2006  rpaulo sync with head
 1.18.6.1 22-Oct-2006  yamt sync with head
 1.18.4.1 18-Nov-2006  ad Sync with head.
 1.19.4.1 12-Mar-2007  rmind Sync with HEAD.
 1.20.24.2 21-Nov-2007  bouyer Sync with HEAD
 1.20.24.1 25-Oct-2007  bouyer Sync with HEAD.
 1.20.20.2 09-Jan-2008  matt sync with HEAD
 1.20.20.1 06-Nov-2007  matt sync with HEAD
 1.20.18.2 21-Nov-2007  joerg Sync with HEAD.
 1.20.18.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.20.2.2 03-Dec-2007  ad Sync with HEAD.
 1.20.2.1 23-Oct-2007  ad Sync with head.
 1.21.2.1 08-Dec-2007  mjf Sync with HEAD.
 1.22.22.1 18-Jun-2008  simonb Sync with head.
 1.22.20.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.22.18.1 04-May-2009  yamt sync with head.
 1.22.16.1 17-Jun-2008  yamt sync with head.
 1.22.14.1 29-Jun-2008  mjf Sync with HEAD.
 1.23.10.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.23.4.1 28-Apr-2009  skrll Sync with HEAD.
 1.24.6.1 06-Jun-2011  jruoho Sync with HEAD.
 1.24.4.1 31-May-2011  rmind sync with head
 1.25.2.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.26.12.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.26.12.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.26.2.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.26.2.1 30-Oct-2012  yamt sync with head
 1.27.2.1 18-May-2014  rmind sync with head
 1.28.2.1 10-Aug-2014  tls Rebase.
 1.2 21-Sep-2025  thorpej Add some conditional debug messages.
 1.1 21-Sep-2025  thorpej Add support for direct i2c device enumeration using the OpenFirmware
device tree.
 1.20 28-Mar-2022  riastradh uhidev(9): Get the device and interface through attach args.

This way uhidev drivers don't need access to uhidev_softc itself for
it.
 1.19 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.18 24-Jul-2021  andvar branches: 1.18.2;
Fix all remaining typos, mainly in comments but also in few definitions and log messages, reported by me in PR kern/54889.
Also fixed some additional typos in comments, found on review of same files or typos.
 1.17 24-Apr-2021  thorpej branches: 1.17.2;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).
 1.16 03-Sep-2018  riastradh branches: 1.16.14;
Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)
 1.15 13-Dec-2017  maya branches: 1.15.2; 1.15.4;
Catch up with hid.h header location change

Fixes macppc kernels build
 1.14 28-Apr-2016  skrll Fix build
 1.13 27-Oct-2012  chs branches: 1.13.12; 1.13.14;
split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.12 20-Dec-2010  phx branches: 1.12.8; 1.12.18;
The driver didn't work, because it expects the whole data packet in a
single interrupt. Reality shows that with current kernels a 81 bytes packet
is split into 3 interrupts with 32 + 32 + 17 bytes. I have added a workaround
to deal with it. The Geyser2 devices with 64 byte packets are unsupported
at the moment. Somebody needs to test it.

New: Added support for the iBook 12-inch trackpad.
 1.11 19-Nov-2010  phx Make sure the interface protocol is UIPROTO_MOUSE, before we attach.
 1.10 08-Nov-2010  pooka usb port stuff is a goner
 1.9 05-Nov-2009  dyoung branches: 1.9.2; 1.9.4;
In awacs(4) and snapper(4), use deviter(9) instead of accessing
alldevs directly.

In pbms(4), delete some unused debugging macros, expand USB
compatibility macros, and add a child-detachment routine. Simplify
pbms(4) deactivation and detachment.

These changes are compile-tested, only.
 1.8 01-Mar-2009  aymeric . use device_private() (led to immediate crash during attach)
. while there, fix the aspect ratio of the trackpad on the geyser2 model
 1.7 17-Oct-2007  garbled branches: 1.7.20; 1.7.28; 1.7.30; 1.7.34; 1.7.36; 1.7.38;
Merge the ppcoea-renovation branch to HEAD.

This branch was a major cleanup and rototill of many of the various OEA
cpu based PPC ports that focused on sharing as much code as possible
between the various ports to eliminate near-identical copies of files in
every tree. Additionally there is a new PIC system that unifies the
interface to interrupt code for all different OEA ppc arches. The work
for this branch was done by a variety of people, too long to list here.

TODO:
bebox still needs work to complete the transition to -renovation.
ofppc still needs a bunch of work, which I will be looking at.
ev64260 still needs to be renovated
amigappc was not attempted.

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.6 14-Sep-2007  aymeric add support for the "newer" trackpads found at least in the last generation
G4 powerbooks (powerbook5,8). Information found in the Linux driver.
 1.5 04-Mar-2007  christos branches: 1.5.2; 1.5.10; 1.5.18; 1.5.20;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.4 12-Nov-2006  plunky branches: 1.4.4;
Tidy away wsmouse_input() abstractions and update
documentation to include the W direction.
 1.3 06-Feb-2006  jmmv branches: 1.3.2; 1.3.10; 1.3.16; 1.3.20; 1.3.22; 1.3.24;
Fix build by correcting pbms_ioctl's prototype.
 1.2 05-Feb-2006  xtraeme Add a pbms(4) manpage. Remove it from the source code and update TODO.
 1.1 05-Feb-2006  christos powerbook 15" mouse driver from Johan Wallen.
 1.3.24.1 10-Dec-2006  yamt sync with head.
 1.3.22.2 09-Sep-2006  rpaulo sync with head
 1.3.22.1 06-Feb-2006  rpaulo file pbms.c was added on branch rpaulo-netinet-merge-pcb on 2006-09-09 02:41:05 +0000
 1.3.20.1 18-Nov-2006  ad Sync with head.
 1.3.16.5 27-Oct-2007  yamt sync with head.
 1.3.16.4 03-Sep-2007  yamt sync with head.
 1.3.16.3 30-Dec-2006  yamt sync with head.
 1.3.16.2 21-Jun-2006  yamt sync with head.
 1.3.16.1 06-Feb-2006  yamt file pbms.c was added on branch yamt-lazymbuf on 2006-06-21 14:53:13 +0000
 1.3.10.2 22-Apr-2006  simonb Sync with head.
 1.3.10.1 06-Feb-2006  simonb file pbms.c was added on branch simonb-timecounters on 2006-04-22 11:37:41 +0000
 1.3.2.2 18-Feb-2006  yamt sync with head.
 1.3.2.1 06-Feb-2006  yamt file pbms.c was added on branch yamt-uio_vmspace on 2006-02-18 15:38:41 +0000
 1.4.4.1 12-Mar-2007  rmind Sync with HEAD.
 1.5.20.1 06-Nov-2007  matt sync with HEAD
 1.5.18.1 02-Oct-2007  joerg Sync with HEAD.
 1.5.10.2 03-Oct-2007  garbled Sync with HEAD
 1.5.10.1 14-Sep-2007  macallan sync with HEAD
 1.5.2.1 09-Oct-2007  ad Sync with head.
 1.7.38.1 21-Apr-2010  matt sync to netbsd-5
 1.7.36.1 25-Aug-2009  snj Pull up following revision(s) (requested by aymeric in ticket #916):
sys/arch/macppc/dev/pbms.c: revision 1.8
. use device_private() (led to immediate crash during attach)
. while there, fix the aspect ratio of the trackpad on the geyser2 model
 1.7.34.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.7.30.2 11-Jan-2010  snj Apply patch (requested by tsutsui in ticket #916):
Fix crash on detach.
 1.7.30.1 25-Aug-2009  snj Pull up following revision(s) (requested by aymeric in ticket #916):
sys/arch/macppc/dev/pbms.c: revision 1.8
. use device_private() (led to immediate crash during attach)
. while there, fix the aspect ratio of the trackpad on the geyser2 model
 1.7.28.1 03-Mar-2009  skrll Sync with HEAD.
 1.7.20.2 11-Mar-2010  yamt sync with head
 1.7.20.1 04-May-2009  yamt sync with head.
 1.9.4.1 05-Mar-2011  rmind sync with head
 1.9.2.1 09-Nov-2010  uebayasi Sync with HEAD.
 1.12.18.2 03-Dec-2017  jdolecek update from HEAD
 1.12.18.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.12.8.1 30-Oct-2012  yamt sync with head
 1.13.14.1 29-May-2016  skrll Sync with HEAD
 1.13.12.1 08-Apr-2017  snj Pull up following revision(s) (requested by skrll in ticket #1398):
sys/arch/macppc/dev/pbms.c: revision 1.14
Fix build
 1.15.4.1 10-Jun-2019  christos Sync with HEAD
 1.15.2.1 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.16.14.1 21-Mar-2021  thorpej Give config_found() the same variadic arguments treatment as
config_search(). This commit only adds the CFARG_EOL sentinel
to the existing config_found() calls. Conversion of config_found_sm_loc()
and config_found_ia() call sites will be in subsequent commits.
 1.17.2.1 01-Aug-2021  thorpej Sync with HEAD.
 1.18.2.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.6 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.5 24-Apr-2021  thorpej branches: 1.5.8;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).
 1.4 11-Dec-2019  scole branches: 1.4.10;
Synchronize htdocs, manual, comments, and code so that enabling the platinumfb is done using "platinum" in openfirmware settings. Remove "screen" option which was somewhat disingenuous.
 1.3 16-Sep-2016  scole branches: 1.3.14; 1.3.18;
Add note about 16 bit console brokenness
 1.2 06-Jul-2016  macallan branches: 1.2.2; 1.2.4;
shut up unused function warning
 1.1 10-Jun-2016  macallan add driver for 'platinum' onboard video found in Power Mac 7200 and possibly
other machines
from s_cole
 1.2.4.1 04-Nov-2016  pgoyette Sync with HEAD
 1.2.2.3 05-Oct-2016  skrll Sync with HEAD
 1.2.2.2 09-Jul-2016  skrll Sync with HEAD
 1.2.2.1 06-Jul-2016  skrll file platinumfb.c was added on branch nick-nhusb on 2016-07-09 20:24:53 +0000
 1.3.18.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.3.14.2 03-Dec-2017  jdolecek update from HEAD
 1.3.14.1 16-Sep-2016  jdolecek file platinumfb.c was added on branch tls-maxphys on 2017-12-03 11:36:25 +0000
 1.4.10.1 21-Mar-2021  thorpej Give config_found() the same variadic arguments treatment as
config_search(). This commit only adds the CFARG_EOL sentinel
to the existing config_found() calls. Conversion of config_found_sm_loc()
and config_found_ia() call sites will be in subsequent commits.
 1.5.8.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.3 16-Apr-2020  rin Revert previous for now:
http://mail-index.netbsd.org/source-changes/2020/04/16/msg116278.html

The reasoning turned out to be wrong; __KERNEL_RCSID() in header files
does *not* overwrite RCSID in main source files. The real problem is that
it inserts its RCSID into *every* object files. However, it can be still
useful even if heavily duplicated.
 1.2 16-Apr-2020  rin Stop using __KERNEL_RCSID() in header files; it confuses ident(1) by
overwriting RCSID in main source files.

XXX
The first argument of __KERNEL_RCSID() is neglected for ELF. If we wish
to have RCSID of header files in kernel binary, we need something like
__FBSDID() macro in FreeBSD.
 1.1 16-Jun-2016  macallan branches: 1.1.2; 1.1.18; 1.1.32;
somehow this fell through the cracks when I committed platinumfb.c
thanks chuq for noticing
 1.1.32.1 20-Apr-2020  bouyer Sync with HEAD
 1.1.18.2 03-Dec-2017  jdolecek update from HEAD
 1.1.18.1 16-Jun-2016  jdolecek file platinumfbreg.h was added on branch tls-maxphys on 2017-12-03 11:36:25 +0000
 1.1.2.2 09-Jul-2016  skrll Sync with HEAD
 1.1.2.1 16-Jun-2016  skrll file platinumfbreg.h was added on branch nick-nhusb on 2016-07-09 20:24:53 +0000
 1.39 02-Jun-2024  andvar fix various typos in word `interrupt', mainly in comments.
 1.38 09-Feb-2022  andvar fix various typos in comments.
 1.37 18-Mar-2009  cegger Ansify function definitions w/o arguments. Generated with sed.
 1.36 14-Mar-2009  dsl ANSIfy another 1261 function definitions.
The only ones left in sys are beyond by sed script!
(or in sys/dist or sys/external)
Mostly they have function pointer parameters.
 1.35 14-Mar-2009  dsl Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.34 14-Mar-2009  dsl Remove all the __P() from sys (excluding sys/dist)
Diff checked with grep and MK1 eyeball.
i386 and amd64 GENERIC and sys still build.
 1.33 07-Nov-2007  garbled branches: 1.33.18; 1.33.26; 1.33.32;
Convert macppc to shared ofw_autoconf.c. Compile tested only.
 1.32 17-Oct-2007  garbled branches: 1.32.2;
Merge the ppcoea-renovation branch to HEAD.

This branch was a major cleanup and rototill of many of the various OEA
cpu based PPC ports that focused on sharing as much code as possible
between the various ports to eliminate near-identical copies of files in
every tree. Additionally there is a new PIC system that unifies the
interface to interrupt code for all different OEA ppc arches. The work
for this branch was done by a variety of people, too long to list here.

TODO:
bebox still needs work to complete the transition to -renovation.
ofppc still needs a bunch of work, which I will be looking at.
ev64260 still needs to be renovated
amigappc was not attempted.

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.31 24-Jan-2007  hubertf branches: 1.31.6; 1.31.14; 1.31.22; 1.31.24; 1.31.26; 1.31.28;
Remove duplicate #includes, patch contributed in private mail
by Slava Semushin <slava.semushin@gmail.com>.

To verify that no nasty side effects of duplicate includes (or their
removal) have an effect here, I've compiled an i386/ALL kernel with
and without the patch, and the only difference in the resulting .o
files was in shifted line numbers in some assert() calls.
The comparison of the .o files was based on the output of "objdump -D".

Thanks to martin@ for the input on testing.
 1.30 07-Jun-2006  kardel branches: 1.30.6;
avoid shadowing time while it still exists
 1.29 11-Dec-2005  christos branches: 1.29.4; 1.29.6; 1.29.8; 1.29.14;
merge ktrace-lwp.
 1.28 07-Jun-2005  jmmv branches: 1.28.2;
Constify char* arguments to pm_printerr. Fixes the build when ADB_DEBUG
is set.

Note that only the first argument needed to be constified to solve the issue,
but given the usage of the arguments in the function, it's worth to constify
all of them.
 1.27 05-Jun-2005  nathanw Rearrange some of the ADB types and void * abuse to make -Wcast-qual
happy in the presence of the "volatile int flag" construct. Fix up a variety
of calls to pass NULL instead of (Ptr)0 to maintain function-pointer safety.
 1.26 27-Apr-2005  briggs Correctly match battery types. Old function would end up matching a
zero-length string. Noted in PR port-macppc/30034 by Magnus Henoch.
Patched as in the PR.
 1.25 01-Feb-2005  briggs Strip old "pm1" code. All PPC PMUs are "pm2" style. Two benefits:
* Cleans code up a bit, and
* Reduces the call stack for PMU interrupts.
 1.24 01-Feb-2005  briggs Remove one level of interrupt redirection by switching on the ADB
hardware type and registering a Cuda or PMU interrupt handler
specifically instead of an intermediate interrupt handler.
 1.23 01-Feb-2005  briggs Add a PMU initialization call at ADB init time. This probes the machine
type for PMU / battery information, then uses that when getting battery
information for APM. Allows older PowerBooks (pre-smart batteries) to
function with apm enabled in the kernel. Thanks to Linux code for battery
information for these old batteries. Something is still odd, though,
because a charging battery can show > 100% when it's near to full charge.

Enable more interrupts from PMU and handle PB3400 card eject buttons
properly, too.

Also use #defines for commands instead of raw hex codes.
 1.22 01-Feb-2005  briggs Calculate and use seconds of power remaining for smart battery types.
 1.21 07-Jan-2005  briggs branches: 1.21.2; 1.21.4;
- If pm_pmgrop_pm2() fails, return after splx() -- there's no sense in
continuing.
- Note that there really needs to be bounds-checking on PMData.
 1.20 15-Jul-2003  lukem __KERNEL_RCSID()
 1.19 18-Jun-2002  itojun branches: 1.19.6;
apm emulation, from openbsd
 1.18 18-Jun-2002  itojun KNF (whitespace)
 1.17 02-Jan-2002  dbj branches: 1.17.8;
if pm_adb_op times out waiting for an interrupt, attempt to take
an interrupt anyway, just in case. Otherwise, report the timout condition.
This works around a problem in my ibook if a key is pressed after boot
and before adb is configured, such as when booting with -d.
 1.16 16-Sep-2001  wiz branches: 1.16.4;
Grammar improvements in comments.
 1.15 16-Sep-2001  wiz Spell 'occurred' with two 'r's.
 1.14 03-Aug-2001  tsubai branches: 1.14.2;
Remove (#if 0'ed) m68k asm codes.
 1.13 22-Jul-2001  wiz bcopy -> memcpy, bzero -> memset, bcmp -> memcmp.
Reviewed by Matt Thomas, ok'd by Tsubai Masanari.
 1.12 01-Apr-2001  tsubai branches: 1.12.2;
Adjust timing for pmu99. Internal keyboard of recent PowerBooks
should work now.
 1.11 28-Feb-2001  tsubai branches: 1.11.2;
Back out previous change. It was harmful on my PowerBook G3.
 1.10 27-Feb-2001  matt Enable a fix so that PowerBook(FireWire) keyboards work. This
should also work on iBooks and PowerBook(WallStreet). And if
we're really lucky, on the new G4 laptops.
 1.9 08-Jun-2000  tsubai branches: 1.9.2;
Sync with mac68k.
 1.8 05-Sep-1999  tsubai branches: 1.8.2; 1.8.10;
Recognize PCMCIA eject button. (Tested on only PowerBook 2400.)
 1.7 12-Jul-1999  tsubai Add read/set LCD brightness and eject PCMCIA card function.
 1.6 11-Jul-1999  tsubai Enable soft poweroff on PowerBook.
 1.5 22-Jun-1999  tsubai NVRAM read/write functions.
 1.4 22-Jun-1999  tsubai Use RTC on PB.
 1.3 07-Dec-1998  tsubai branches: 1.3.6;
Fix a typo.
 1.2 15-Nov-1998  tsubai RTC support for pmu (read only).
 1.1 20-Oct-1998  tsubai Oops, forgot to add them.
 1.3.6.2 02-Aug-1999  thorpej Update from trunk.
 1.3.6.1 01-Jul-1999  thorpej Sync w/ -current.
 1.8.10.1 22-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.8.2.2 21-Apr-2001  bouyer Sync with HEAD
 1.8.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.9.2.1 01-Apr-2001  he Pull up revision 1.12 (requested by tsubai):
Fix Keyboard problem of recent PowerBooks (Pismo, PowerBook G4,
etc.).
 1.11.2.1 09-Apr-2001  nathanw Catch up with -current.
 1.12.2.4 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.12.2.3 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.12.2.2 25-Aug-2001  thorpej Merge Aug 24 -current into the kqueue branch.
 1.12.2.1 03-Aug-2001  lukem update to -current
 1.14.2.1 01-Oct-2001  fvdl Catch up with -current.
 1.16.4.4 20-Jun-2002  nathanw Catch up to -current.
 1.16.4.3 28-Feb-2002  nathanw Catch up to -current.
 1.16.4.2 11-Jan-2002  nathanw More catchup.
 1.16.4.1 16-Sep-2001  nathanw file pm_direct.c was added on branch nathanw_sa on 2002-01-11 23:38:35 +0000
 1.17.8.1 16-Jul-2002  gehenna catch up with -current.
 1.19.6.6 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.19.6.5 04-Feb-2005  skrll Sync with HEAD.
 1.19.6.4 17-Jan-2005  skrll Sync with HEAD.
 1.19.6.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.19.6.2 18-Sep-2004  skrll Sync with HEAD.
 1.19.6.1 03-Aug-2004  skrll Sync with HEAD
 1.21.4.1 12-Feb-2005  yamt sync with head.
 1.21.2.1 29-Apr-2005  kent sync with -current
 1.28.2.4 15-Nov-2007  yamt sync with head.
 1.28.2.3 27-Oct-2007  yamt sync with head.
 1.28.2.2 26-Feb-2007  yamt sync with head.
 1.28.2.1 21-Jun-2006  yamt sync with head.
 1.29.14.1 19-Jun-2006  chap Sync with head.
 1.29.8.1 26-Jun-2006  yamt sync with head.
 1.29.6.1 22-Apr-2006  simonb Fix some shadowed variable warnings.
 1.29.4.1 09-Sep-2006  rpaulo sync with head
 1.30.6.1 01-Feb-2007  ad Sync with head.
 1.31.28.2 13-Nov-2007  bouyer Sync with HEAD
 1.31.28.1 25-Oct-2007  bouyer Sync with HEAD.
 1.31.26.1 18-Oct-2007  yamt sync with head.
 1.31.24.2 08-Nov-2007  matt sync with -HEAD
 1.31.24.1 06-Nov-2007  matt sync with HEAD
 1.31.22.2 11-Nov-2007  joerg Sync with HEAD.
 1.31.22.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.31.14.1 07-Jun-2007  garbled Convert macppc to powerpc bus_space. Lots of work here from Matt Thomas,
as well as the common ofwoea code from myself. Compile tested only,
still probably needs some fine tuning.

Also in this commit:
Convert macppc to new shared ofwoea routines.
Lots of KNF.
 1.31.6.2 03-Dec-2007  ad Sync with HEAD.
 1.31.6.1 23-Oct-2007  ad Sync with head.
 1.32.2.1 19-Nov-2007  mjf Sync with HEAD.
 1.33.32.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.33.26.1 28-Apr-2009  skrll Sync with HEAD.
 1.33.18.1 04-May-2009  yamt sync with head.
 1.12 14-Mar-2009  dsl Remove all the __P() from sys (excluding sys/dist)
Diff checked with grep and MK1 eyeball.
i386 and amd64 GENERIC and sys still build.
 1.11 11-Dec-2005  christos branches: 1.11.78; 1.11.86; 1.11.92;
merge ktrace-lwp.
 1.10 01-Feb-2005  briggs Remove one level of interrupt redirection by switching on the ADB
hardware type and registering a Cuda or PMU interrupt handler
specifically instead of an intermediate interrupt handler.
 1.9 01-Feb-2005  briggs Add a PMU initialization call at ADB init time. This probes the machine
type for PMU / battery information, then uses that when getting battery
information for APM. Allows older PowerBooks (pre-smart batteries) to
function with apm enabled in the kernel. Thanks to Linux code for battery
information for these old batteries. Something is still odd, though,
because a charging battery can show > 100% when it's near to full charge.

Enable more interrupts from PMU and handle PB3400 card eject buttons
properly, too.

Also use #defines for commands instead of raw hex codes.
 1.8 01-Feb-2005  briggs Add some command definitions gleaned from Linux.
Add a field to pmu_battery_info to contain est. seconds of power remaining.
 1.7 07-Jan-2005  briggs branches: 1.7.2; 1.7.4;
Increase buffer from 32 bytes to 128 bytes in PMData. I have observed a
response from the device that had 120 bytes of data. The lack of any
bounds-checking in pm_direct.c allowed that data to smash the stack in
the interrupt handler.
 1.6 18-Jun-2002  itojun branches: 1.6.6;
apm emulation, from openbsd
 1.5 12-Jul-1999  tsubai branches: 1.5.16; 1.5.20; 1.5.28;
Add read/set LCD brightness and eject PCMCIA card function.
 1.4 11-Jul-1999  tsubai Enable soft poweroff on PowerBook.
 1.3 22-Jun-1999  tsubai NVRAM read/write functions.
 1.2 16-Jun-1999  tsubai Define symbolic name of PMU commands.
 1.1 20-Oct-1998  tsubai branches: 1.1.8;
Oops, forgot to add them.
 1.1.8.3 02-Aug-1999  thorpej Update from trunk.
 1.1.8.2 01-Jul-1999  thorpej Sync w/ -current.
 1.1.8.1 21-Jun-1999  thorpej Sync w/ -current.
 1.5.28.1 16-Jul-2002  gehenna catch up with -current.
 1.5.20.1 20-Jun-2002  nathanw Catch up to -current.
 1.5.16.1 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.6.6.2 04-Feb-2005  skrll Sync with HEAD.
 1.6.6.1 17-Jan-2005  skrll Sync with HEAD.
 1.7.4.1 12-Feb-2005  yamt sync with head.
 1.7.2.1 29-Apr-2005  kent sync with -current
 1.11.92.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.11.86.1 28-Apr-2009  skrll Sync with HEAD.
 1.11.78.1 04-May-2009  yamt sync with head.
 1.47 21-Sep-2025  thorpej Support enumeration of i2c devices directly from the device tree.
 1.46 21-Sep-2025  thorpej It's no longer necessary to scan for sensor descriptive information
in the macppc i2c controller drivers; device_register() does it for
us.
 1.45 18-Sep-2025  thorpej In the "i2c-child-devices" array, don't pass in a "cookie" and "cookietype".
Instead, just create the appropriate devhandle and pass that along as a
data object.
 1.44 15-Sep-2025  thorpej Encapsulate what's needed to attach an I2C bus into a iicbus_attach()
inline.
 1.43 07-Sep-2025  thorpej Change todr_chip_handle::cookie -> todr_chip_handle::todr_dev, and
make it a device_t. Upcoming functional changes will require the
device_t associated with a TODR device.

Change todr_chip_handle::bus_cookie -> todr_chip_handle::todr_devaux.
Nothing was using the old field, but I decided to keep it around just
in cause something needs it in the future.

And with these largely mechanical yet semantically meaningful changes,
thus spake the Oracle: "Welcome to NetBSD 11.99.2."
 1.42 12-Aug-2025  macallan some updates and fixes:
- sprinkle volatile, mostly for clang
- on Xserve we need extra delays around i2c ops
- use combined mode for i2c reads - 2 ops instead of 3
- make sure we pass the whole compatible property to iic, not just the first
entry
 1.41 30-Aug-2023  macallan remove ancient #if 0 block
NFC
 1.40 22-Aug-2023  macallan tsleep()/wakeup() -> cv_*
 1.39 07-Aug-2021  thorpej branches: 1.39.2;
Merge thorpej-cfargs2.
 1.38 07-Aug-2021  macallan pass sensor locations to i2c devices if we can find them
tested on 2nd gen Mini
 1.37 24-Apr-2021  thorpej branches: 1.37.2; 1.37.8;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).
 1.36 05-Mar-2021  rin branches: 1.36.2;
Convert to intr_establish_xname().
 1.35 26-Jan-2021  thorpej There is not much point in of_compatible() returning -1 for "no match"
and >= 0 for "match". Just make it return 0 for "no match" and >0 for
"match" so it can be treated like a boolean expression.

As such of_match_compatible() (a wrapper around of_compatible()) is now
obsolete, and will be removed once all call sites are converted to an
appropriate replacement.
 1.34 14-Jul-2020  martin branches: 1.34.2;
Adapt to new proplib API
 1.33 22-Dec-2019  thorpej Cleanup i2c bus acquire / release, centralizing all of the logic into
iic_acquire_bus() / iic_release_bus(). "acquire" and "release" hooks
no longer need to be provided by back-end controller drivers (only if
they need special handling, e.g. powering on the i2c controller).
This results in the removal of a bunch of rendundant code from each
back-end controller driver.

Assert that we are not in hard interrupt context in iic_acquire_bus(),
iic_exec(), and iic_release_bus().
 1.32 03-Sep-2018  riastradh Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)
 1.31 28-Mar-2018  macallan branches: 1.31.2;
be less spammy on i2c errors
 1.30 16-Feb-2018  macallan branches: 1.30.2;
OF_getprop() retuns -1 on failure, not 0...
 1.29 29-Sep-2017  macallan pass the right device node to i2c devices
 1.28 01-Sep-2017  macallan support I2C bus and direct config of slave devices
 1.27 01-Jun-2016  macallan report the power button to sysmon when possible
 1.26 31-May-2016  macallan fix stupid tpyo
thanks chuq
 1.25 31-May-2016  macallan make sure we call sysmon_pswitch_event() from thread context
 1.24 14-Feb-2016  chs zero the i2c_attach_args structure before filling it in.
fixes occasional crashes in iic_attach().
 1.23 14-Mar-2014  mrg branches: 1.23.6;
remove various set-but-unused variables.
 1.22 05-Nov-2013  macallan do what cuda does - if we read garbage from the RTC try a few more times
 1.21 01-Jul-2011  dyoung branches: 1.21.2; 1.21.12; 1.21.16;
#include <sys/bus.h> instead of <machine/bus.h>.
 1.20 18-Jun-2011  matt struct device * -> device_t
struct cfdata * -> cfdata_t
use device accessors, use device_private.
some softc/device_t splits (macppc needs a bunch more)
aprint*_dev used considerably more
 1.19 09-Nov-2010  macallan branches: 1.19.6;
add support for controlling power to the modem in some PowerBooks
works at least with my Pismo, probably others
 1.18 14-Sep-2010  macallan report lid open/close events to sysmon
 1.17 12-Dec-2009  tsutsui branches: 1.17.2; 1.17.4;
Remove `volatile' qualifier from argument types of
struct timeval passed to todr_gettime(9) and todr_settime(9).
We no longer have an ancient and volatile struct timeval `time'
global since we have switched to MI timercounter(9) on all port.

XXX1: some of these RTC drivers still assume 32bit time_t
XXX2: some of these should be rewritten to use todr_[gs]ettime_ymdhms()
XXX3: todr(9) man page doesn't mention todr_[gs]ettime_ymdhms()
 1.16 18-Mar-2009  cegger Ansify function definitions w/o arguments. Generated with sed.
 1.15 11-Jan-2009  macallan branches: 1.15.2;
fix format instead of casting wildly
 1.14 11-Jan-2009  macallan deal with 64bit time_t
Noticed by Wojciech Galazka
 1.13 29-Apr-2008  martin branches: 1.13.8;
Convert to new 2 clause license
 1.12 30-Mar-2008  macallan branches: 1.12.2; 1.12.4;
don't splhigh() in the interrupt handler, instead spltty() in adb_poll()
 1.11 06-Dec-2007  ad branches: 1.11.12;
lockmgr -> mutex
 1.10 07-Nov-2007  garbled branches: 1.10.2;
Convert macppc to shared ofw_autoconf.c. Compile tested only.
 1.9 17-Oct-2007  garbled branches: 1.9.2;
Merge the ppcoea-renovation branch to HEAD.

This branch was a major cleanup and rototill of many of the various OEA
cpu based PPC ports that focused on sharing as much code as possible
between the various ports to eliminate near-identical copies of files in
every tree. Additionally there is a new PIC system that unifies the
interface to interrupt code for all different OEA ppc arches. The work
for this branch was done by a variety of people, too long to list here.

TODO:
bebox still needs work to complete the transition to -renovation.
ofppc still needs a bunch of work, which I will be looking at.
ev64260 still needs to be renovated
amigappc was not attempted.

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.8 08-Aug-2007  macallan branches: 1.8.2; 1.8.4; 1.8.6;
sync with ppcoea-renovation
 1.7 09-Jul-2007  ad branches: 1.7.4; 1.7.8;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements
 1.6 09-May-2007  macallan add an optional callback from pmu's worker thread, use it to poll AC power
status on legacy batteries where we don't get environment interrupts. Also
report AC status changes to powerd.
 1.5 03-Apr-2007  macallan branches: 1.5.4;
cleanup a bit, fix some stupid pasto
thanks to jmcneill for finding the problem
 1.4 25-Mar-2007  macallan attach smartbat* when appropriate
 1.3 15-Feb-2007  macallan branches: 1.3.2; 1.3.4; 1.3.8; 1.3.10; 1.3.12;
- don't use IPL_HIGH
- attach batteries when present
- some cleanup
 1.2 18-Jan-2007  macallan branches: 1.2.2;
make some tables static to avoid collisions
 1.1 17-Jan-2007  macallan new drivers for pmu and cuda
 1.2.2.2 01-Feb-2007  ad Sync with head.
 1.2.2.1 18-Jan-2007  ad file pmu.c was added on branch newlock2 on 2007-02-01 08:48:08 +0000
 1.3.12.2 09-Dec-2007  reinoud Pullup to HEAD
 1.3.12.1 29-Mar-2007  reinoud Pullup to -current
 1.3.10.1 11-Jul-2007  mjf Sync with head.
 1.3.8.6 03-Dec-2007  ad Sync with HEAD.
 1.3.8.5 23-Oct-2007  ad Sync with head.
 1.3.8.4 20-Aug-2007  ad Sync with HEAD.
 1.3.8.3 15-Jul-2007  ad Sync with head.
 1.3.8.2 27-May-2007  ad Sync with head.
 1.3.8.1 10-Apr-2007  ad Sync with head.
 1.3.4.6 07-Dec-2007  yamt sync with head
 1.3.4.5 15-Nov-2007  yamt sync with head.
 1.3.4.4 27-Oct-2007  yamt sync with head.
 1.3.4.3 03-Sep-2007  yamt sync with head.
 1.3.4.2 26-Feb-2007  yamt sync with head.
 1.3.4.1 15-Feb-2007  yamt file pmu.c was added on branch yamt-lazymbuf on 2007-02-26 09:07:21 +0000
 1.3.2.2 17-May-2007  yamt sync with head.
 1.3.2.1 15-Apr-2007  yamt sync with head.
 1.5.4.7 03-Oct-2007  garbled Sync with HEAD
 1.5.4.6 08-Aug-2007  macallan set display brightness on attach
 1.5.4.5 02-Aug-2007  macallan sync with HEAD
 1.5.4.4 14-Jun-2007  macallan fix some bus_spacification fallout
 1.5.4.3 22-May-2007  matt Update to HEAD.
 1.5.4.2 11-May-2007  macallan request the correct interrupt type in a couple drivers - necessary since
these days we actually do something with the type argument
 1.5.4.1 09-May-2007  macallan sync with HEAD
 1.7.8.4 09-Dec-2007  jmcneill Sync with HEAD.
 1.7.8.3 11-Nov-2007  joerg Sync with HEAD.
 1.7.8.2 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.7.8.1 09-Aug-2007  jmcneill Sync with HEAD.
 1.7.4.1 15-Aug-2007  skrll Sync with HEAD.
 1.8.6.2 13-Nov-2007  bouyer Sync with HEAD
 1.8.6.1 25-Oct-2007  bouyer Sync with HEAD.
 1.8.4.1 18-Oct-2007  yamt sync with head.
 1.8.2.3 09-Jan-2008  matt sync with HEAD
 1.8.2.2 08-Nov-2007  matt sync with -HEAD
 1.8.2.1 06-Nov-2007  matt sync with HEAD
 1.9.2.2 08-Dec-2007  mjf Sync with HEAD.
 1.9.2.1 19-Nov-2007  mjf Sync with HEAD.
 1.10.2.1 08-Dec-2007  ad Sync with head.
 1.11.12.3 17-Jan-2009  mjf Sync with HEAD.
 1.11.12.2 02-Jun-2008  mjf Sync with HEAD.
 1.11.12.1 03-Apr-2008  mjf Sync with HEAD.
 1.12.4.4 09-Oct-2010  yamt sync with head
 1.12.4.3 11-Mar-2010  yamt sync with head
 1.12.4.2 04-May-2009  yamt sync with head.
 1.12.4.1 16-May-2008  yamt sync with head.
 1.12.2.1 18-May-2008  yamt sync with head.
 1.13.8.2 28-Apr-2009  skrll Sync with HEAD.
 1.13.8.1 19-Jan-2009  skrll Sync with HEAD.
 1.15.2.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.17.4.1 05-Mar-2011  rmind sync with head
 1.17.2.1 22-Oct-2010  uebayasi Sync with HEAD (-D20101022).
 1.19.6.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.21.16.1 18-May-2014  rmind sync with head
 1.21.12.2 03-Dec-2017  jdolecek update from HEAD
 1.21.12.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.21.2.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.23.6.2 09-Jul-2016  skrll Sync with HEAD
 1.23.6.1 19-Mar-2016  skrll Sync with HEAD
 1.30.2.2 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.30.2.1 30-Mar-2018  pgoyette Resolve conflicts between branch and HEAD
 1.31.2.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.31.2.1 10-Jun-2019  christos Sync with HEAD
 1.34.2.1 03-Apr-2021  thorpej Sync with HEAD.
 1.36.2.1 02-Apr-2021  thorpej config_found_ia() -> config_found() w/ CFARG_IATTR.
 1.37.8.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.37.2.2 14-May-2021  thorpej Deal with quirks / differences in OpenFirmware implementations'
interpreation of the i2c "reg" property by embedding knowledge
of those quicks directly, rather than forcing lots of drivers
to provide their own devhandle implementations. We default to
assuming the Device Tree bindings, and tweak based on platform-
specific #ifdefs.

Start with __HAVE_OPENFIRMWARE_VARIANT_AAPL (all i2c "reg" properties
encode an address that's shifted left 1 bit to account for the R/W bit
that appears on the wire).
 1.37.2.1 08-May-2021  thorpej Adapt the pmu driver to the new i2c device enumeration mechanism. This
follows the OpenFirmware bindings for the most part, but has the i2c
addresses of children shifted left one bit as it would appear on the
wire (for the r/w bit).
 1.39.2.1 09-Aug-2021  thorpej Port over the changes from thorpej-i2c-spi-conf to thorpej-i2c-spi-conf2,
which is based on a newer HEAD revision.
 1.11 16-Apr-2020  rin Revert previous for now:
http://mail-index.netbsd.org/source-changes/2020/04/16/msg116278.html

The reasoning turned out to be wrong; __KERNEL_RCSID() in header files
does *not* overwrite RCSID in main source files. The real problem is that
it inserts its RCSID into *every* object files. However, it can be still
useful even if heavily duplicated.
 1.10 16-Apr-2020  rin Stop using __KERNEL_RCSID() in header files; it confuses ident(1) by
overwriting RCSID in main source files.

XXX
The first argument of __KERNEL_RCSID() is neglected for ELF. If we wish
to have RCSID of header files in kernel binary, we need something like
__FBSDID() macro in FreeBSD.
 1.9 01-Jun-2016  macallan branches: 1.9.28;
report the power button to sysmon when possible
 1.8 09-Nov-2010  macallan branches: 1.8.18; 1.8.36;
add support for controlling power to the modem in some PowerBooks
works at least with my Pismo, probably others
 1.7 29-Apr-2008  martin branches: 1.7.22;
Convert to new 2 clause license
 1.6 17-Oct-2007  garbled branches: 1.6.16; 1.6.18; 1.6.20;
Merge the ppcoea-renovation branch to HEAD.

This branch was a major cleanup and rototill of many of the various OEA
cpu based PPC ports that focused on sharing as much code as possible
between the various ports to eliminate near-identical copies of files in
every tree. Additionally there is a new PIC system that unifies the
interface to interrupt code for all different OEA ppc arches. The work
for this branch was done by a variety of people, too long to list here.

TODO:
bebox still needs work to complete the transition to -renovation.
ofppc still needs a bunch of work, which I will be looking at.
ev64260 still needs to be renovated
amigappc was not attempted.

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.5 08-Aug-2007  macallan branches: 1.5.2;
sync with ppcoea-renovation
 1.4 09-May-2007  macallan branches: 1.4.4; 1.4.8;
add an optional callback from pmu's worker thread, use it to poll AC power
status on legacy batteries where we don't get environment interrupts. Also
report AC status changes to powerd.
 1.3 03-Apr-2007  macallan branches: 1.3.4;
cleanup a bit, fix some stupid pasto
thanks to jmcneill for finding the problem
 1.2 15-Feb-2007  macallan branches: 1.2.2; 1.2.4; 1.2.8; 1.2.10;
- don't use IPL_HIGH
- attach batteries when present
- some cleanup
 1.1 17-Jan-2007  macallan branches: 1.1.2;
new drivers for pmu and cuda
 1.1.2.2 01-Feb-2007  ad Sync with head.
 1.1.2.1 17-Jan-2007  ad file pmuvar.h was added on branch newlock2 on 2007-02-01 08:48:08 +0000
 1.2.10.1 11-Jul-2007  mjf Sync with head.
 1.2.8.3 20-Aug-2007  ad Sync with HEAD.
 1.2.8.2 27-May-2007  ad Sync with head.
 1.2.8.1 10-Apr-2007  ad Sync with head.
 1.2.4.3 03-Sep-2007  yamt sync with head.
 1.2.4.2 26-Feb-2007  yamt sync with head.
 1.2.4.1 15-Feb-2007  yamt file pmuvar.h was added on branch yamt-lazymbuf on 2007-02-26 09:07:21 +0000
 1.2.2.2 17-May-2007  yamt sync with head.
 1.2.2.1 15-Apr-2007  yamt sync with head.
 1.3.4.4 03-Oct-2007  garbled Sync with HEAD
 1.3.4.3 02-Aug-2007  macallan sync with HEAD
 1.3.4.2 22-May-2007  matt Update to HEAD.
 1.3.4.1 09-May-2007  macallan sync with HEAD
 1.4.8.1 09-Aug-2007  jmcneill Sync with HEAD.
 1.4.4.1 15-Aug-2007  skrll Sync with HEAD.
 1.5.2.1 06-Nov-2007  matt sync with HEAD
 1.6.20.1 16-May-2008  yamt sync with head.
 1.6.18.1 18-May-2008  yamt sync with head.
 1.6.16.1 02-Jun-2008  mjf Sync with HEAD.
 1.7.22.1 05-Mar-2011  rmind sync with head
 1.8.36.1 09-Jul-2016  skrll Sync with HEAD
 1.8.18.1 03-Dec-2017  jdolecek update from HEAD
 1.9.28.1 20-Apr-2020  bouyer Sync with HEAD
 1.9 17-Sep-2025  thorpej Don't get the OF phandle from i2c_attach_args::ia_cookie; get it from
self's devhandle.
 1.8 18-Jun-2021  macallan branches: 1.8.6;
do ii2 locking dance in psoc_dump()
 1.7 18-Jun-2021  macallan use opt_psoc.h, suppress some debug output in !PSOC_DEBUG
 1.6 27-Jan-2021  thorpej branches: 1.6.4;
Use DEVICE_COMPAT_EOL.
 1.5 25-Jan-2021  thorpej Since we're using designated initialisers for compat data, we should
use a completely empty initializer for the sentinel.
 1.4 17-Jan-2021  thorpej Use designated initializers and a consistent termination style in
compat_data[].
 1.3 23-Nov-2019  macallan branches: 1.3.8; 1.3.10;
don't invalidate sensors every time we fail to read fan speeds
 1.2 22-Nov-2019  macallan report fan speeds
disclaimer:
this is guesswork obtained from watching temperatures, listening to fan noise
and staring at register dumps. Use with caution.
 1.1 01-Nov-2019  macallan the beginning of a driver for the 'Psoc' fan controller found in my 1GHz
TiBook. So far it does:
- initialize the fan controller via OF
- report temperatures to envsys
there is no documentation, only guesswork from looking at OF methods

With this my TiBook doesn't seem to overheat anymore.
 1.3.10.1 03-Apr-2021  thorpej Sync with HEAD.
 1.3.8.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.3.8.1 23-Nov-2019  martin file psoc.c was added on branch phil-wifi on 2020-04-13 08:03:58 +0000
 1.6.4.2 01-Aug-2021  thorpej Sync with HEAD.
 1.6.4.1 09-May-2021  thorpej ia->ia_cookie -> devhandle_to_of(device_handle(self))
 1.8.6.1 09-Aug-2021  thorpej Port over the changes from thorpej-i2c-spi-conf to thorpej-i2c-spi-conf2,
which is based on a newer HEAD revision.
 1.14 01-Nov-2012  macallan - apply limits consistently
- remove suspect pointer fudgery when interpreting PMU battery data
now if we had any idea what units these data are in...
 1.13 31-Oct-2012  macallan implement limits and support event monitoring
now emergency shutdown on low battery works
 1.12 18-Sep-2012  macallan fix typo
 1.11 06-Sep-2012  macallan branches: 1.11.2;
- make the charge state sensor actually do something
- work around a bug in envsys which expects a valid value for sensors with
states that have text descriptions even if the sensor is invalid
 1.10 06-Sep-2012  macallan only register a PMU callback when we're actually monitoring and reporting
AC power
fixes spontaneous power down with two smartbat instances present
 1.9 05-Sep-2012  macallan split the envsys sensors into two devices - one SME_CLASS_ACADAPTER and one
SME_CLASS_BATTERY, register the former only on unit 0 so we don't end up
with two of them on powerbooks that have two battery slots. Now userland has
a fighting chance to find the AC status.
TODO: make the battery sensors look more like acpibat's
 1.8 26-Jul-2011  macallan branches: 1.8.2;
finish device_t-ification
 1.7 10-Jul-2011  pgoyette Initialize sensor state. (Missed the commit for this in my last
roto-till.)
 1.6 01-Jul-2011  dyoung #include <sys/bus.h> instead of <machine/bus.h>.
 1.5 18-Jun-2011  matt struct device * -> device_t
struct cfdata * -> cfdata_t
use device accessors, use device_private.
some softc/device_t splits (macppc needs a bunch more)
aprint*_dev used considerably more
 1.4 14-Sep-2010  macallan branches: 1.4.6;
only mark battery status sensors valid if the battery is actually present
 1.3 12-Aug-2008  macallan branches: 1.3.14; 1.3.16;
actually implement smart battery support
From Magnus Henoch.
This needs more testing, especially on older PowerBooks which may have more thanone battery.
 1.2 29-Apr-2008  martin branches: 1.2.2; 1.2.6;
Convert to new 2 clause license
 1.1 25-Mar-2007  macallan branches: 1.1.2; 1.1.6; 1.1.10; 1.1.22; 1.1.42; 1.1.44; 1.1.46;
skeleton smart battery driver. Doesn't do much yet.
 1.1.46.3 09-Oct-2010  yamt sync with head
 1.1.46.2 04-May-2009  yamt sync with head.
 1.1.46.1 16-May-2008  yamt sync with head.
 1.1.44.1 18-May-2008  yamt sync with head.
 1.1.42.2 28-Sep-2008  mjf Sync with HEAD.
 1.1.42.1 02-Jun-2008  mjf Sync with HEAD.
 1.1.22.2 03-Sep-2007  yamt sync with head.
 1.1.22.1 25-Mar-2007  yamt file smartbat.c was added on branch yamt-lazymbuf on 2007-09-03 14:27:37 +0000
 1.1.10.2 11-Jul-2007  mjf Sync with head.
 1.1.10.1 25-Mar-2007  mjf file smartbat.c was added on branch mjf-ufs-trans on 2007-07-11 20:00:40 +0000
 1.1.6.2 15-Apr-2007  yamt sync with head.
 1.1.6.1 25-Mar-2007  yamt file smartbat.c was added on branch yamt-idlelwp on 2007-04-15 16:02:50 +0000
 1.1.2.2 10-Apr-2007  ad Sync with head.
 1.1.2.1 25-Mar-2007  ad file smartbat.c was added on branch vmlocking on 2007-04-10 13:22:43 +0000
 1.2.6.1 19-Oct-2008  haad Sync with HEAD.
 1.2.2.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.3.16.1 05-Mar-2011  rmind sync with head
 1.3.14.1 22-Oct-2010  uebayasi Sync with HEAD (-D20101022).
 1.4.6.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.8.2.2 16-Jan-2013  yamt sync with (a bit old) head
 1.8.2.1 30-Oct-2012  yamt sync with head
 1.11.2.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.17 07-Sep-2025  thorpej Change todr_chip_handle::cookie -> todr_chip_handle::todr_dev, and
make it a device_t. Upcoming functional changes will require the
device_t associated with a TODR device.

Change todr_chip_handle::bus_cookie -> todr_chip_handle::todr_devaux.
Nothing was using the old field, but I decided to keep it around just
in cause something needs it in the future.

And with these largely mechanical yet semantically meaningful changes,
thus spake the Oracle: "Welcome to NetBSD 11.99.2."
 1.16 22-Jan-2022  thorpej Change the devhandle_from_*() functions to also take a "super handle",
from which the newly created handle will inherit it's implementation.
The root implementation for a new handle type is used if an invalid
"super handle" is passed.
 1.15 03-Sep-2021  macallan switch smu to common fan control code
 1.14 07-Aug-2021  thorpej branches: 1.14.2;
Merge thorpej-cfargs2.
 1.13 24-Apr-2021  thorpej branches: 1.13.2; 1.13.8;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).
 1.12 09-Mar-2021  macallan branches: 1.12.2;
add support for the CPU temperature sensor found in iMac G5s
 1.11 05-Mar-2021  rin Convert to intr_establish_xname().
 1.10 25-Feb-2021  macallan deal with node name inconsistencies between PowerMac10,x and 8,x
Now we find fans and iic devices on iMac G5
 1.9 04-Jul-2020  rin branches: 1.9.2;
- Adjust location of \n in attach message.
- Convert to aprint_*(9).
 1.8 22-Dec-2019  thorpej Cleanup i2c bus acquire / release, centralizing all of the logic into
iic_acquire_bus() / iic_release_bus(). "acquire" and "release" hooks
no longer need to be provided by back-end controller drivers (only if
they need special handling, e.g. powering on the i2c controller).
This results in the removal of a bunch of rendundant code from each
back-end controller driver.

Assert that we are not in hard interrupt context in iic_acquire_bus(),
iic_exec(), and iic_release_bus().
 1.7 10-Nov-2019  chs in many device attach paths, allocate memory with M_WAITOK instead of M_NOWAIT
and remove code to handle failures that can no longer happen.
 1.6 03-Sep-2018  riastradh Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)
 1.5 20-Apr-2018  macallan branches: 1.5.2;
overhaul SMU i2c handling:
- get rid of the special smuiicbus, use generic i2cbus
- use shifted i2c addresses like everyone else
- use direct config
with this generic i2c drivers should work on the smu's i2c bus.
 1.4 09-Mar-2018  sevan Initialise ret to avoid returning uninitialised value if the if statement is
false. Found when building the POWERMAC_G5 kernel with clang.
 1.3 01-Oct-2017  macallan branches: 1.3.2; 1.3.4;
we support the drive bay sensor now
 1.2 29-Sep-2017  macallan provide crude but working fan control based on sensor readings
 1.1 06-Jun-2017  macallan branches: 1.1.4;
SMU support, from Phileas Fogg
 1.1.4.2 28-Aug-2017  skrll Sync with HEAD
 1.1.4.1 06-Jun-2017  skrll file smu.c was added on branch nick-nhusb on 2017-08-28 17:51:44 +0000
 1.3.4.3 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.3.4.2 22-Apr-2018  pgoyette Sync with HEAD
 1.3.4.1 15-Mar-2018  pgoyette Synch with HEAD
 1.3.2.2 03-Dec-2017  jdolecek update from HEAD
 1.3.2.1 01-Oct-2017  jdolecek file smu.c was added on branch tls-maxphys on 2017-12-03 11:36:25 +0000
 1.5.2.3 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.5.2.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.5.2.1 10-Jun-2019  christos Sync with HEAD
 1.9.2.1 03-Apr-2021  thorpej Sync with HEAD.
 1.12.2.2 04-Apr-2021  thorpej Associate the OpenFirmware phandle associated with a found device (including
PCI bus instances) by using CFARG_DEVHANDLE.
 1.12.2.1 23-Mar-2021  thorpej Convert config_found_ia() call sites where the device only carries
a single interface attribute to bare config_found() calls.
 1.13.8.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.13.2.3 14-May-2021  thorpej Move the bus/channel number for multi-channel / mux controllers out of
i2cbus_attach_args and stash it in the i2c_tag_t instead. This makes it
accessible to platform device tree code when enumerating devices.
 1.13.2.2 14-May-2021  thorpej Deal with quirks / differences in OpenFirmware implementations'
interpreation of the i2c "reg" property by embedding knowledge
of those quicks directly, rather than forcing lots of drivers
to provide their own devhandle implementations. We default to
assuming the Device Tree bindings, and tweak based on platform-
specific #ifdefs.

Start with __HAVE_OPENFIRMWARE_VARIANT_AAPL (all i2c "reg" properties
encode an address that's shifted left 1 bit to account for the R/W bit
that appears on the wire).
 1.13.2.1 09-May-2021  thorpej Adapt the smu driver to the new i2c device enumeration method. While
here, collapse the "smuiic" driver into the base "smu" driver; it was
superfluous given how the rest of the "smu" driver is structured.
 1.14.2.1 09-Aug-2021  thorpej Port over the changes from thorpej-i2c-spi-conf to thorpej-i2c-spi-conf2,
which is based on a newer HEAD revision.
 1.14 21-Sep-2025  thorpej It's no longer necessary to scan for sensor descriptive information
in the macppc i2c controller drivers; device_register() does it for
us.
 1.13 18-Sep-2025  thorpej In the "i2c-child-devices" array, don't pass in a "cookie" and "cookietype".
Instead, just create the appropriate devhandle and pass that along as a
data object.
 1.12 15-Sep-2025  thorpej Encapsulate what's needed to attach an I2C bus into a iicbus_attach()
inline.
 1.11 20-Dec-2023  thorpej Remove unnecessary <sys/malloc.h>.
 1.10 09-Aug-2021  thorpej Fix CVS eff-up.
 1.9 09-Aug-2021  thorpej Port over the changes from thorpej-i2c-spi-conf to thorpej-i2c-spi-conf2,
which is based on a newer HEAD revision.
 1.8 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.7 24-Apr-2021  thorpej branches: 1.7.2; 1.7.8;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).
 1.6 25-Feb-2021  macallan branches: 1.6.2;
more node name adjustments
also, pass sensor names if we can find them
now we find and currectly use the hard drive temperature sensor on my iMac G5
 1.5 02-Jul-2020  macallan branches: 1.5.2;
add $NetBSD:
 1.4 02-Jul-2020  macallan proplib API catchup
 1.3 20-Apr-2018  macallan overhaul SMU i2c handling:
- get rid of the special smuiicbus, use generic i2cbus
- use shifted i2c addresses like everyone else
- use direct config
with this generic i2c drivers should work on the smu's i2c bus.
 1.2 07-Jul-2017  macallan branches: 1.2.4; 1.2.6; 1.2.8;
tidy up output by moving linebreak to before we attach children
 1.1 06-Jun-2017  macallan SMU support, from Phileas Fogg
 1.2.8.1 22-Apr-2018  pgoyette Sync with HEAD
 1.2.6.2 03-Dec-2017  jdolecek update from HEAD
 1.2.6.1 07-Jul-2017  jdolecek file smuiic.c was added on branch tls-maxphys on 2017-12-03 11:36:25 +0000
 1.2.4.2 28-Aug-2017  skrll Sync with HEAD
 1.2.4.1 07-Jul-2017  skrll file smuiic.c was added on branch nick-nhusb on 2017-08-28 17:51:44 +0000
 1.5.2.1 03-Apr-2021  thorpej Sync with HEAD.
 1.6.2.1 23-Mar-2021  thorpej Convert config_found_ia() call sites where the device only carries
a single interface attribute to bare config_found() calls.
 1.7.8.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.7.2.1 09-May-2021  thorpej Adapt the smu driver to the new i2c device enumeration method. While
here, collapse the "smuiic" driver into the base "smu" driver; it was
superfluous given how the rest of the "smu" driver is structured.
 1.3 09-Aug-2021  thorpej Fix CVS eff-up.
 1.2 09-Aug-2021  thorpej Port over the changes from thorpej-i2c-spi-conf to thorpej-i2c-spi-conf2,
which is based on a newer HEAD revision.
 1.1 06-Jun-2017  macallan branches: 1.1.4; 1.1.6; 1.1.26;
SMU support, from Phileas Fogg
 1.1.26.1 09-May-2021  thorpej Adapt the smu driver to the new i2c device enumeration method. While
here, collapse the "smuiic" driver into the base "smu" driver; it was
superfluous given how the rest of the "smu" driver is structured.
 1.1.6.2 03-Dec-2017  jdolecek update from HEAD
 1.1.6.1 06-Jun-2017  jdolecek file smuiicvar.h was added on branch tls-maxphys on 2017-12-03 11:36:25 +0000
 1.1.4.2 28-Aug-2017  skrll Sync with HEAD
 1.1.4.1 06-Jun-2017  skrll file smuiicvar.h was added on branch nick-nhusb on 2017-08-28 17:51:44 +0000
 1.11 17-Sep-2025  thorpej Don't get the OF phandle from i2c_attach_args::ia_cookie; get it from
self's devhandle.
 1.10 20-Dec-2023  thorpej Remove unnecessary <sys/malloc.h>.
 1.9 27-Jan-2021  thorpej branches: 1.9.4; 1.9.14;
Use DEVICE_COMPAT_EOL.
 1.8 25-Jan-2021  thorpej Since we're using designated initialisers for compat data, we should
use a completely empty initializer for the sentinel.
 1.7 17-Jan-2021  thorpej Use designated initializers and a consistent termination style in
compat_data[].
 1.6 26-Jun-2018  thorpej branches: 1.6.14;
In my quest to make device_compatible_entry (and associated goo)
super-general, it turns out I also made it a little to cumbersome
to use (if my tired fingers are any indication). So, this is a
course-correction -- one string per entry (like of_compat_data,
which it will soon replace), and remove the over-verbose macros.
 1.5 18-Jun-2018  thorpej - Rename iic_compat_match() to iic_compatible_match() and change it
to use the new device_compatible_match() routine. A pointer to
the matching device_compatible_entry is returned if a match is
found.
- Adjust iic_use_direct_match() accordingly.
- i2c drivers now provide device_compatible_entry tables when performing
direct-config matching.
- In the dsrtc driver, take advantage of this new capability to greatly
simplify model selection.

(I'm coming for you next, of_compat_data...)
 1.4 16-Jun-2018  thorpej More cleanup to i2c autoconfiguration:

- Get all of the drivers onto the new match quality constants.
- Introduce a new helper function, iic_use_direct_match(), that has
all of the logic for direct-config matching. If it returns true,
the driver returns the match result (which may be 0). If it returns
false, the driver does indirect-config matching.
- iic_compat_match() now returns a weighted match quality; matches to
lower-indexed "compatible" device property are more-specific matches,
and return a better match quality accordingly.
 1.3 20-Apr-2018  macallan overhaul SMU i2c handling:
- get rid of the special smuiicbus, use generic i2cbus
- use shifted i2c addresses like everyone else
- use direct config
with this generic i2c drivers should work on the smu's i2c bus.
 1.2 05-Oct-2017  macallan branches: 1.2.2; 1.2.4;
do what linux and freebsd do here:
- ignore the raw 'adc' sensors
- update all sensors in a single transaction instead of one by one
now we're getting relatively sane readings
 1.1 06-Jun-2017  macallan branches: 1.1.4;
SMU support, from Phileas Fogg
 1.1.4.2 28-Aug-2017  skrll Sync with HEAD
 1.1.4.1 06-Jun-2017  skrll file smusat.c was added on branch nick-nhusb on 2017-08-28 17:51:44 +0000
 1.2.4.3 28-Jul-2018  pgoyette Sync with HEAD
 1.2.4.2 25-Jun-2018  pgoyette Sync with HEAD
 1.2.4.1 22-Apr-2018  pgoyette Sync with HEAD
 1.2.2.2 03-Dec-2017  jdolecek update from HEAD
 1.2.2.1 05-Oct-2017  jdolecek file smusat.c was added on branch tls-maxphys on 2017-12-03 11:36:25 +0000
 1.6.14.1 03-Apr-2021  thorpej Sync with HEAD.
 1.9.14.1 09-Aug-2021  thorpej Port over the changes from thorpej-i2c-spi-conf to thorpej-i2c-spi-conf2,
which is based on a newer HEAD revision.
 1.9.4.2 09-May-2021  thorpej ia->ia_cookie -> devhandle_to_of(device_handle(self))
 1.9.4.1 09-May-2021  thorpej No need to include smuiicvar.h.
 1.1 06-Jun-2017  macallan branches: 1.1.4; 1.1.6;
SMU support, from Phileas Fogg
 1.1.6.2 03-Dec-2017  jdolecek update from HEAD
 1.1.6.1 06-Jun-2017  jdolecek file smuvar.h was added on branch tls-maxphys on 2017-12-03 11:36:25 +0000
 1.1.4.2 28-Aug-2017  skrll Sync with HEAD
 1.1.4.1 06-Jun-2017  skrll file smuvar.h was added on branch nick-nhusb on 2017-08-28 17:51:44 +0000
 1.70 08-Sep-2025  macallan more registers, add include guard
 1.69 08-Sep-2025  macallan move register definitions into the headers they belong
 1.68 20-Aug-2025  macallan move GPIO definitions to obiovar.h
 1.67 20-Dec-2023  thorpej Remove unnecessary <sys/malloc.h>.
 1.66 11-Dec-2023  mlelstv Output is always 16bit, the internal audio data type may differ.
 1.65 02-Jun-2022  macallan check platform-do-*-mute properties to find out the resp. GPIO's polarity
now this works properly on pmac7,3
 1.64 01-Jun-2022  martin Revert previous, the mask is intented to be like sc_output_mask, a bitmask
of active ports.
 1.63 01-Jun-2022  martin In SNAPPER_OUTPUT_SELECT the "mask" is a bitmap of muted outputs, not
active outputs.
 1.62 01-Jun-2022  martin Recognize the OF labels used for line output and headphone output on a
G5 powermac 7,3.
 1.61 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.60 02-Jul-2021  jmcneill branches: 1.60.2;
port-macppc/56289: kernel spinout on macppc when runing ATF tests with LOCKDEBUG

Move call to snapper_set_rate from trigger_output to commit_settings,
since the intr lock is not held when calling the latter.
 1.59 26-Apr-2021  thorpej snapper carries multiple interface attributes, so be explicit about
"onewirebus" when attaching to it.
 1.58 24-Apr-2021  thorpej branches: 1.58.2;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).
 1.57 11-Mar-2021  macallan branches: 1.57.2;
add basic support for iMac G5 audio:
- match AOAShasta
- deal with headphone gpios labeled as lineout in OF
- set sc_mode to SNAPPER_IS_PCM3052 - OF makes it look like an unlabeled
TAS3004
TODO:
- actually support pcm3052 instead of treating it like a sw codec
 1.56 05-Mar-2021  rin Convert to intr_establish_xname().
 1.55 08-Aug-2020  macallan branches: 1.55.2;
add support for the onewire bus found in some macs, namely Quicksilver.
This can be used to read the EEPROM content from Apple Pro speakers, or to
hook up other onewire devices.
 1.54 11-Apr-2020  macallan don't try to read a 32bit property into a uint8_t.
Now headphone detection works properly on machines which have the gpio's
polarity reversed, like Quicksilver and TiBook.
 1.53 20-Sep-2019  macallan branches: 1.53.6;
various minor fixes and updates:
- add (very) basic ONYX support. Treat as 16bit codec with software volume
control. Makes basic audio work on PCIe G5
- correctly detect TAS3001 without 'compatible' property, now this works on
Quicksilver
- mute line input on TAS3001 - it's unconnected on Quicksilver and causes noise
- make more of an effort to match codecs to i2sbus instances, needed on G5 and
some other models with software 'modems'
 1.52 08-Jun-2019  isaki Clean get_props().
- Make get_props() return AUDIO_PROP_{PLAYBACK,CAPTURE} properly.
This eliminates need for audio.c to take care of such (old)
drivers which don't return both of PLAYBACK and CAPTURE.
- All get_props() doesn't need to return AUDIO_PROP_MMAP.
It is handled in the audio layer now.
 1.51 16-May-2019  macallan switch the default input to line in, to avoid feedback noise on laptops
should probably just mute the input, I need to read the datasheet again...
 1.50 08-May-2019  isaki Merge isaki-audio2 branch, the overhaul of audio subsystem.
- Interrupt-oriented system rather than thread-oriented.
- Improve stability, quality and performance.
- Split playback and record cleanly. Improve halfduplex support.
- Many bugs are fixed including deadlocks, resource leaks, abuses, etc.
- Simplify audio filter mechanism. The encoding/channels/frequency
conversions are completely handled in the upper layer. So the hard-
ware driver only converts its hardware encoding (if necessary).
- audio_hw_if changes:
- Obsoletes query_encoding and add query_format instead.
- Obsoletes set_params and add set_format instead.
- Remove drain, setfd, mappage.
- The call sequences are changed.
- ioctl AUDIO_GETFD/SETFD, AUDIO_GETCHAN/SETCHAN are obsoleted.
- ioctl AUDIO_{QUERY,GET,SET}FORMAT are introduced.
- cleanup config attributes: au*conv and mulaw.
- All hardware drivers should follow it (I've done as much as possible).

Some file paths are changed:
- dev/audio.c -> dev/audio/audio.c (rewritten)
- dev/audiovar.h -> dev/audio/audiovar.h
- dev/audio_dai.h -> dev/audio/audio_dai.h
- dev/audio_if.h -> dev/audio/audio_if.h
- dev/audiobell.c -> dev/audio/audiobell.c
- dev/audiobellvar.h -> dev/audio/audiobellvar.h
- dev/mulaw.[ch] -> dev/audio/mulaw.[ch] + dev/audio/alaw.c
 1.49 16-Mar-2019  isaki branches: 1.49.2;
Use C99 style struct initializer to audio_hw_if.
 1.48 03-Sep-2018  riastradh Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)
 1.47 04-May-2018  macallan branches: 1.47.2;
use obio_space_map() to map DMA registers, now this works on both G5 and
32bit hardware
 1.46 29-Mar-2018  macallan explicitly enable the i2s part in the keylargo FCR
now this works on my PCI-X G5
 1.45 29-Mar-2018  macallan deal with PowerMac7,* mac-io/i2s/sound reg properties
now we map the right registers on G5 and get DMA interrupts. Still no sound
but - well - progress
 1.44 24-Mar-2018  macallan don't poke GPIOs directly, use obio_*() access functions, now this
has a chance of working on G5 where we can't just BAT-map everything with
paddr == busaddr.
Doesn't play audio yet but things like headphone detection work.
 1.43 29-Jan-2018  macallan branches: 1.43.2;
remove some leftover references to ki2c in comments
no functional change
 1.42 27-Jan-2018  sevan Fix issue with audio being downpitched, thanks to <nat>

"it seems that snapper_init should be called before audio_attach_mi, as snapper
init is setting the rate to 44100 after the hardware format has been configured
by audio_attach_mi.

audio_attach_mi should be the last thing called during an attach of an audio
device so the audio device is ready to be configured when audio_attach_mi is
called."

Resolves PR port-macppc/52949
 1.41 31-Mar-2017  msaitoh branches: 1.41.6;
Remove extra 0x. This bug was added when replacing bitmask_snprintf(9) with
snprintb(3) (in between NetBSD 5 and 6). Old bitmask_snprint(9) didn't add
0x" automatically for hexadecimal value, so old code used it with "0x%s".
 1.40 15-Jul-2016  macallan branches: 1.40.2;
adjust to dbdma changes
 1.39 14-Mar-2014  mrg branches: 1.39.4; 1.39.6; 1.39.10;
remove various set-but-unused variables.
 1.38 24-Nov-2011  mrg branches: 1.38.4; 1.38.8; 1.38.12;
put back IPL_AUDIO and splaudio(), at the request of rmind. they are
aliases and now we can easily revert audio to IPL_VM if necessary,
without having to revert the whole branch.
 1.37 23-Nov-2011  jmcneill Merge jmcneill-audiomp3 branch, which is derived from ad-audiomp2. From
the original ad-audiomp branch notes:

Add MP locking to the audio drivers.

Making the audio drivers MP safe is necessary before efforts
can be made to make the VM system MP safe.

The are two locks per device instance, an ISR lock and
a character device lock. The ISR lock replaces calls to
splaudio()/splx(), and will be held across calls to device
methods which were called at splaudio() before (e.g.
trigger_output). The character device lock is held across
calls to nearly all of the methods, excluding some only
used for initialization, e.g. get_locks.

Welcome to 5.99.57.
 1.36 12-Nov-2010  phx branches: 1.36.8; 1.36.10;
Get the dma registers from the soundbus property. This should work with all
snapper-compatible hardware.
Tested on PowerBook G4, MacMini and iBook G4. Failed on the PowerBook before.
 1.35 16-Oct-2010  phx Find all GPIOs in OF also on newer PowerBooks.
Do not use a GPIO or establish an interrupt when it was not found.
To be done: We should use bus_space(9) for reading/writing GPIOs.
 1.34 09-Sep-2010  macallan get rid of custom PMF event handlers, instead do what the upper layer expects
so volume control via PMF still works
 1.33 05-Nov-2009  dyoung branches: 1.33.2; 1.33.4;
In awacs(4) and snapper(4), use deviter(9) instead of accessing
alldevs directly.

In pbms(4), delete some unused debugging macros, expand USB
compatibility macros, and add a child-detachment routine. Simplify
pbms(4) deactivation and detachment.

These changes are compile-tested, only.
 1.32 18-Mar-2009  cegger bzero -> memset
 1.31 16-Dec-2008  christos branches: 1.31.2;
replace bitmask_snprintf(9) with snprintb(3)
 1.30 26-Sep-2008  macallan branches: 1.30.2;
use access functions to mess with obio's registers
 1.29 26-Sep-2008  macallan use min(255, blah) to cap volume instead of masking the upper bits out
 1.28 16-May-2008  macallan branches: 1.28.4;
sprinkle static
 1.27 15-May-2008  macallan listen to PMF volume control events
With this volume vontrol via keyboard works on my iBook G4.
 1.26 15-May-2008  macallan struct device -> device_t
 1.25 07-Nov-2007  garbled branches: 1.25.14; 1.25.16; 1.25.18; 1.25.20;
Convert macppc to shared ofw_autoconf.c. Compile tested only.
 1.24 18-Oct-2007  macallan branches: 1.24.2;
cleanup, various fixes and TAS3001 / Tumbler support
from Marco Trillo in PR37076
 1.23 17-Oct-2007  garbled Merge the ppcoea-renovation branch to HEAD.

This branch was a major cleanup and rototill of many of the various OEA
cpu based PPC ports that focused on sharing as much code as possible
between the various ports to eliminate near-identical copies of files in
every tree. Additionally there is a new PIC system that unifies the
interface to interrupt code for all different OEA ppc arches. The work
for this branch was done by a variety of people, too long to list here.

TODO:
bebox still needs work to complete the transition to -renovation.
ofppc still needs a bunch of work, which I will be looking at.
ev64260 still needs to be renovated
amigappc was not attempted.

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.22 27-Sep-2007  dogcow branches: 1.22.2;
struct cfattach -> CFATTACH_DECL; compiles again.
 1.21 17-Sep-2007  aymeric branches: 1.21.2;
add support for the "tumbler" as found at least on iBook G3/600.
quick OK macallan@
 1.20 04-Apr-2007  jmcneill branches: 1.20.4; 1.20.12; 1.20.14;
Simplify sw volume control, attach to AOAK2 as well, make mono work as
well as stereo, and print a friendlier message when we don't find a
hardware mixer.
 1.19 03-Apr-2007  jmcneill In the AOAKeylargo case, there is no hardware volume control. Instead,
implement volume control in software via audio filter framework.

XXX: audio filter framework doesn't let me pass parameters from the hw
softc to the filter, so the volume variables are globals for now.
 1.18 03-Apr-2007  jmcneill Match AOAKeylargo, and don't make finding deq a requirement. Sound now
comes out of my last gen G4 Mac Mini, minus mixer controls. ok macallan@
 1.17 25-Mar-2007  macallan fix typo
 1.16 28-Feb-2007  thorpej branches: 1.16.2; 1.16.4; 1.16.6;
TRUE -> true, FALSE -> false
 1.15 17-Dec-2006  macallan branches: 1.15.2;
don't pretend to support 8kHz since the chip really doesn't
noticed by Marco Trillo
 1.14 11-Dec-2006  macallan actually change the sample rate when asked to.
Fix provided by Marco Trillo in PR35204
While there also enable 24bit I/O.
 1.13 24-Sep-2006  jmcneill branches: 1.13.2;
Don't use // for comments.
 1.12 23-Aug-2006  macallan branches: 1.12.2; 1.12.4;
use gain table for master volume as well
 1.11 23-Aug-2006  macallan fix some KNF nits
 1.10 11-Aug-2006  macallan Add audio input support. From Magnus Henoch, fixes PR 32664
 1.9 23-Feb-2006  thorpej branches: 1.9.2;
Use device_parent().
 1.8 24-Dec-2005  perry branches: 1.8.2; 1.8.4; 1.8.6;
bare asm -> __asm
 1.7 11-Dec-2005  christos merge ktrace-lwp.
 1.6 10-Aug-2005  macallan - don't call ki2c private functions anymore, use iic_exec() to be a good i2c citizen
- use the deq driver to find the mixer device
- add controls for bass and treble
 1.5 25-Jan-2005  briggs branches: 1.5.6;
Ensure i/o commands are allocated on 16-byte boundary by allocating 15
extra bytes and adjusting array starts.
Issue pointed out on port-macppc by Michael Lorenz.

Also remove extra print of the device name on attach().
 1.4 15-Jan-2005  kent branches: 1.4.2; 1.4.4;
ansify and KNF
 1.3 10-Jan-2005  kent merge kent-audio1 branch, which introduces audio filter pipeline to the MI
audio framework


Summary of changes:

* struct audio_params
- remove sw_code, factor, factor_denom, hw_sample_rate,
hw_encoding ,hw_precision, and hw_channels. Conversion information
is conveyed by stream_filter_list_t.
- change the type of sample_rate: u_long -> u_int
- add `validbits,' which represents the valid data size in
precision bits. It is required in order to distinguish 24/32bit
from 24/24bit or 32/32bit.

* audio_hw_if
- add two parameters to set_params()
stream_filter_list_t *pfil, stream_filter_list *rfil
A HW driver should set filter recipes for requested formats
- constify audio_params parameters of trigger_output() and
trigger_input(). They represent audio formats for the hardware.
- make open() and close() optional
- add int (AUMODE_PLAY or AUMODE_RECORD) and audio_params_t parameters
to round_blocksize()

* sw_code is replaced with stream_filter_t.
stream_filer_t converts audio data in an input buffer and writes
into another output buffer unlike sw_code, which converts data in
single buffer.
converters in dev/auconv.c, dev/mulaw.c, dev/aurateconv.c,
dev/tc/bba.c, dev/ic/msm6258.c, and arch/arm/iomd/vidcaudio.c are
reimplemented as stream_filter_t

* MI audio
- audiosetinfo() builds filter pipelines from stream_filter_list_t
filled by audio_hw_if::set_params()
- audiosetinfo() returns with EINVAL if mmapped and set_params()
requests filters
- audio_write(), audio_pint(), and audio_rint() invoke a filter
pipeline.
- ioctl() for FIONREAD, AUDIO_WSEEK, AUDIO_GETIOFFS,
AUDIO_GETOOFFS, and audio_prinfo::{seek,samples} for
AUDIO_GETINFO handle values for a buffer nearest to userland.

* add `struct device *' parameter to ac97_attach()

* all of audio HW drivers follow audio_hw_if and ac97 changes
 1.2 29-Oct-2004  yamt branches: 1.2.2;
constify audio_hw_if, midi_hw_if, and radio_hw_if.
 1.1 27-Dec-2003  grant branches: 1.1.4;
add support for the Keywest I2C and snapper audio device, as found on
some iBook and PowerBook models.

this driver was written by Tsubai Masanari and further hacked on by
Jared D. McNeill to work on his iBook.

the driver is limited (master volume control only, and I haven't
tested recording) but has been functioning perfectly on my PowerBook
g4 DVI (ivory) for some time.

ok'd by matt.
 1.1.4.8 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.1.4.7 04-Feb-2005  skrll Sync with HEAD.
 1.1.4.6 17-Jan-2005  skrll Sync with HEAD.
 1.1.4.5 02-Nov-2004  skrll Sync with HEAD.
 1.1.4.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.1.4.3 18-Sep-2004  skrll Sync with HEAD.
 1.1.4.2 03-Aug-2004  skrll Sync with HEAD
 1.1.4.1 27-Dec-2003  skrll file snapper.c was added on branch ktrace-lwp on 2004-08-03 10:37:21 +0000
 1.2.2.2 09-Jan-2005  kent audio_hw_if change
* make open() and close() optional
* add int (AUMODE_PLAY or AUMODE_RECORD) and audio_params_t parameters
to round_blocksize()
 1.2.2.1 03-Jan-2005  kent adopt the filter pipeline framework
 1.4.4.1 12-Feb-2005  yamt sync with head.
 1.4.2.1 29-Apr-2005  kent sync with -current
 1.5.6.5 15-Nov-2007  yamt sync with head.
 1.5.6.4 27-Oct-2007  yamt sync with head.
 1.5.6.3 03-Sep-2007  yamt sync with head.
 1.5.6.2 30-Dec-2006  yamt sync with head.
 1.5.6.1 21-Jun-2006  yamt sync with head.
 1.8.6.1 22-Apr-2006  simonb Sync with head.
 1.8.4.1 09-Sep-2006  rpaulo sync with head
 1.8.2.1 01-Mar-2006  yamt sync with head.
 1.9.2.1 03-Sep-2006  yamt sync with head.
 1.12.4.2 18-Dec-2006  yamt sync with head.
 1.12.4.1 22-Oct-2006  yamt sync with head
 1.12.2.2 12-Jan-2007  ad Sync with head.
 1.12.2.1 18-Nov-2006  ad Sync with head.
 1.13.2.1 25-Sep-2008  bouyer pullup the following revisions, requested my macallan in ticket 616:
sys/arch/macppc/dev/snapper.c 1.14-1.21
- proper support for 24bit audio on TAS3004 / snapper codecs
- fix sample rate setup bugs ( otherwise the chip would always stay in
44.1kHz )
- add support for the codecs found in G4 Mac Minis ( AOAKeylargo and
AOAK2 ), which don't have hardware volume control
- add support for 'tumbler' codecs found in some iBook G3 models
 1.15.2.2 15-Apr-2007  yamt sync with head.
 1.15.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.16.6.1 29-Mar-2007  reinoud Pullup to -current
 1.16.4.1 11-Jul-2007  mjf Sync with head.
 1.16.2.4 03-Dec-2007  ad Sync with HEAD.
 1.16.2.3 23-Oct-2007  ad Sync with head.
 1.16.2.2 09-Oct-2007  ad Sync with head.
 1.16.2.1 10-Apr-2007  ad Sync with head.
 1.20.14.2 08-Nov-2007  matt sync with -HEAD
 1.20.14.1 06-Nov-2007  matt sync with HEAD
 1.20.12.3 11-Nov-2007  joerg Sync with HEAD.
 1.20.12.2 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.20.12.1 02-Oct-2007  joerg Sync with HEAD.
 1.20.4.5 03-Oct-2007  garbled Sync with HEAD
 1.20.4.4 27-Sep-2007  macallan use CFATTACH_DECL()
 1.20.4.3 19-Sep-2007  macallan sync with HEAD
 1.20.4.2 08-Aug-2007  macallan don't bus_space_map(PAGE_SIZE) - use the actual length OF tells us instead
We need this since the new, shared bus_space_* stuff actually keeps track of
what ranges are mapped
 1.20.4.1 07-Jun-2007  garbled Convert macppc to powerpc bus_space. Lots of work here from Matt Thomas,
as well as the common ofwoea code from myself. Compile tested only,
still probably needs some fine tuning.

Also in this commit:
Convert macppc to new shared ofwoea routines.
Lots of KNF.
 1.21.2.2 18-Oct-2007  yamt sync with head.
 1.21.2.1 06-Oct-2007  yamt sync with head.
 1.22.2.2 13-Nov-2007  bouyer Sync with HEAD
 1.22.2.1 25-Oct-2007  bouyer Sync with HEAD.
 1.24.2.1 19-Nov-2007  mjf Sync with HEAD.
 1.25.20.2 10-Oct-2008  skrll Sync with HEAD.
 1.25.20.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.25.18.3 09-Oct-2010  yamt sync with head
 1.25.18.2 11-Mar-2010  yamt sync with head
 1.25.18.1 04-May-2009  yamt sync with head.
 1.25.16.1 18-May-2008  yamt sync with head.
 1.25.14.3 17-Jan-2009  mjf Sync with HEAD.
 1.25.14.2 28-Sep-2008  mjf Sync with HEAD.
 1.25.14.1 02-Jun-2008  mjf Sync with HEAD.
 1.28.4.1 19-Oct-2008  haad Sync with HEAD.
 1.30.2.2 28-Apr-2009  skrll Sync with HEAD.
 1.30.2.1 19-Jan-2009  skrll Sync with HEAD.
 1.31.2.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.33.4.1 05-Mar-2011  rmind sync with head
 1.33.2.1 22-Oct-2010  uebayasi Sync with HEAD (-D20101022).
 1.36.10.2 22-Nov-2011  jmcneill get rid of unused 'powerstate' callback in audio_hw_if
 1.36.10.1 22-Nov-2011  macallan convert snapper
code from mrg, tested on my iBook G4
 1.36.8.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.36.8.1 17-Apr-2012  yamt sync with head
 1.38.12.1 18-May-2014  rmind sync with head
 1.38.8.2 03-Dec-2017  jdolecek update from HEAD
 1.38.8.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.38.4.1 13-Mar-2018  snj Pull up following revision(s) (requested by sevan in ticket #1522):
sys/arch/macppc/dev/snapper.c: 1.42
Fix issue with audio being downpitched, thanks to <nat>
"it seems that snapper_init should be called before audio_attach_mi, as
snapper
init is setting the rate to 44100 after the hardware format has been
configured
by audio_attach_mi.
audio_attach_mi should be the last thing called during an attach of an audio
device so the audio device is ready to be configured when audio_attach_mi is
called."
Resolves PR port-macppc/52949
 1.39.10.2 26-Apr-2017  pgoyette Sync with HEAD
 1.39.10.1 26-Jul-2016  pgoyette Sync with HEAD
 1.39.6.2 28-Aug-2017  skrll Sync with HEAD
 1.39.6.1 05-Oct-2016  skrll Sync with HEAD
 1.39.4.1 19-Feb-2018  snj Pull up following revision(s) (requested by sevan in ticket #1559):
sys/arch/macppc/dev/snapper.c: 1.42
Fix issue with audio being downpitched, thanks to <nat>
"it seems that snapper_init should be called before audio_attach_mi, as
snapper
init is setting the rate to 44100 after the hardware format has been
configured
by audio_attach_mi.
audio_attach_mi should be the last thing called during an attach of an audio
device so the audio device is ready to be configured when audio_attach_mi is
called."
Resolves PR port-macppc/52949
 1.40.2.1 21-Apr-2017  bouyer Sync with HEAD
 1.41.6.1 04-Feb-2018  martin Pull up following revision(s) (requested by sevan in ticket #520):
sys/arch/macppc/dev/snapper.c: revision 1.42
Fix issue with audio being downpitched, thanks to <nat>
"it seems that snapper_init should be called before audio_attach_mi, as
snapper
init is setting the rate to 44100 after the hardware format has been
configured
by audio_attach_mi.
audio_attach_mi should be the last thing called during an attach of an audio
device so the audio device is ready to be configured when audio_attach_mi is
called."
Resolves PR port-macppc/52949
 1.43.2.3 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.43.2.2 21-May-2018  pgoyette Sync with HEAD
 1.43.2.1 30-Mar-2018  pgoyette Resolve conflicts between branch and HEAD
 1.47.2.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.47.2.1 10-Jun-2019  christos Sync with HEAD
 1.49.2.3 04-May-2019  isaki Move dev/audio_if.h -> dev/audio/audio_if.h
 1.49.2.2 22-Apr-2019  isaki Adapt to audio2.
- New audio filter can access softc so it's simple.
- Clear rval of fixphase on halt.
 1.49.2.1 21-Apr-2019  isaki Use C99 style struct initializer to audio_format.
 1.53.6.1 20-Apr-2020  bouyer Sync with HEAD
 1.55.2.1 03-Apr-2021  thorpej Sync with HEAD.
 1.57.2.1 21-Mar-2021  thorpej Give config_found() the same variadic arguments treatment as
config_search(). This commit only adds the CFARG_EOL sentinel
to the existing config_found() calls. Conversion of config_found_sm_loc()
and config_found_ia() call sites will be in subsequent commits.
 1.58.2.2 01-Aug-2021  thorpej Sync with HEAD.
 1.58.2.1 13-May-2021  thorpej Sync with HEAD.
 1.60.2.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.13 28-Dec-2022  macallan don't complain about mpic and dart not being configured
mpic is handled elsewhere, dart is an iommu we don't use yet
 1.12 22-Jan-2022  thorpej Change the devhandle_from_*() functions to also take a "super handle",
from which the newly created handle will inherit it's implementation.
The root implementation for a new handle type is used if an invalid
"super handle" is passed.
 1.11 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.10 24-Apr-2021  thorpej branches: 1.10.8;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).
 1.9 16-Mar-2018  macallan branches: 1.9.16;
gather per-CPU EEPROM contents if we have them
 1.8 01-Mar-2018  macallan branches: 1.8.2;
match /u3, found in some G5
 1.7 15-Sep-2017  macallan provide a bus_space to child devices
 1.6 26-Oct-2011  macallan branches: 1.6.12;
more device/softc splitting
 1.5 18-Jun-2011  matt struct device * -> device_t
struct cfdata * -> cfdata_t
use device accessors, use device_private.
some softc/device_t splits (macppc needs a bunch more)
aprint*_dev used considerably more
 1.4 14-Mar-2009  dsl branches: 1.4.10;
ANSIfy another 1261 function definitions.
The only ones left in sys are beyond by sed script!
(or in sys/dist or sys/external)
Mostly they have function pointer parameters.
 1.3 14-Mar-2009  dsl Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.2 11-Dec-2005  christos branches: 1.2.18; 1.2.80; 1.2.88; 1.2.94;
merge ktrace-lwp.
 1.1 10-Aug-2005  macallan branches: 1.1.6;
dummy driver to represent the uni-n node in OF and attach its children
 1.1.6.2 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.1.6.1 10-Aug-2005  skrll file uni-n.c was added on branch ktrace-lwp on 2005-11-10 13:57:27 +0000
 1.2.94.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.2.88.1 28-Apr-2009  skrll Sync with HEAD.
 1.2.80.1 04-May-2009  yamt sync with head.
 1.2.18.2 21-Jun-2006  yamt sync with head.
 1.2.18.1 11-Dec-2005  yamt file uni-n.c was added on branch yamt-lazymbuf on 2006-06-21 14:53:13 +0000
 1.4.10.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.6.12.1 03-Dec-2017  jdolecek update from HEAD
 1.8.2.1 22-Mar-2018  pgoyette Synch with HEAD, resolve conflicts
 1.9.16.2 04-Apr-2021  thorpej Associate the OpenFirmware phandle associated with a found device (including
PCI bus instances) by using CFARG_DEVHANDLE.
 1.9.16.1 21-Mar-2021  thorpej Give config_found() the same variadic arguments treatment as
config_search(). This commit only adds the CFARG_EOL sentinel
to the existing config_found() calls. Conversion of config_found_sm_loc()
and config_found_ia() call sites will be in subsequent commits.
 1.10.8.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.10 04-Oct-2025  thorpej Use device_{get,set}prop_bool() for "is_console".
 1.9 24-Sep-2023  andvar define i variable in for loop.
valkyriefb_attach() doesn't have one defined in the function scope.

fixes VALKYRIEFB_DEBUG enabled build for macppc.
 1.8 16-Feb-2022  riastradh powerpc: Sprinkle "memory" clobbers on eieio and nearby asm blocks.

Otherwise the compiler may reorder these around loads and stores,
which mostly defeats the purpose. `asm volatile' just ensures the
instruction isn't _deleted_; it may still move around.
 1.7 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.6 24-Apr-2021  thorpej branches: 1.6.8;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).
 1.5 16-Feb-2018  macallan branches: 1.5.18;
use _PREFETCHABLE
 1.4 06-Jul-2016  macallan shut up another unused function warning
 1.3 19-Feb-2014  macallan branches: 1.3.6;
- don't read beyond array bounds
- break a bunch of long lines
- remove an outdated comment
 1.2 23-May-2012  macallan branches: 1.2.2; 1.2.4;
cleanup, remove debug goo
 1.1 24-Jan-2012  macallan branches: 1.1.4; 1.1.6;
drivers to support the onboard video circuitry found in for example the
Performa 6360
 1.1.6.4 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.1.6.3 30-Oct-2012  yamt sync with head
 1.1.6.2 17-Apr-2012  yamt sync with head
 1.1.6.1 24-Jan-2012  yamt file valkyriefb.c was added on branch yamt-pagecache on 2012-04-17 00:06:37 +0000
 1.1.4.3 02-Jun-2012  mrg sync to latest -current.
 1.1.4.2 18-Feb-2012  mrg merge to -current.
 1.1.4.1 24-Jan-2012  mrg file valkyriefb.c was added on branch jmcneill-usbmp on 2012-02-18 07:32:35 +0000
 1.2.4.1 18-May-2014  rmind sync with head
 1.2.2.2 03-Dec-2017  jdolecek update from HEAD
 1.2.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.3.6.1 09-Jul-2016  skrll Sync with HEAD
 1.5.18.1 21-Mar-2021  thorpej Give config_found() the same variadic arguments treatment as
config_search(). This commit only adds the CFARG_EOL sentinel
to the existing config_found() calls. Conversion of config_found_sm_loc()
and config_found_ia() call sites will be in subsequent commits.
 1.6.8.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.5 16-Apr-2020  rin Revert previous for now:
http://mail-index.netbsd.org/source-changes/2020/04/16/msg116278.html

The reasoning turned out to be wrong; __KERNEL_RCSID() in header files
does *not* overwrite RCSID in main source files. The real problem is that
it inserts its RCSID into *every* object files. However, it can be still
useful even if heavily duplicated.
 1.4 16-Apr-2020  rin Stop using __KERNEL_RCSID() in header files; it confuses ident(1) by
overwriting RCSID in main source files.

XXX
The first argument of __KERNEL_RCSID() is neglected for ELF. If we wish
to have RCSID of header files in kernel binary, we need something like
__FBSDID() macro in FreeBSD.
 1.3 16-Feb-2018  macallan branches: 1.3.14;
remove accidential garbage
 1.2 16-Feb-2018  macallan add $NetBSD:
 1.1 24-Jan-2012  macallan branches: 1.1.4; 1.1.6;
drivers to support the onboard video circuitry found in for example the
Performa 6360
 1.1.6.2 17-Apr-2012  yamt sync with head
 1.1.6.1 24-Jan-2012  yamt file valkyriefbreg.h was added on branch yamt-pagecache on 2012-04-17 00:06:37 +0000
 1.1.4.2 18-Feb-2012  mrg merge to -current.
 1.1.4.1 24-Jan-2012  mrg file valkyriefbreg.h was added on branch jmcneill-usbmp on 2012-02-18 07:32:35 +0000
 1.3.14.1 20-Apr-2020  bouyer Sync with HEAD
 1.9 01-Feb-2012  matt Use C89 function prototypes.
 1.8 14-Mar-2009  dsl branches: 1.8.12; 1.8.16;
Remove all the __P() from sys (excluding sys/dist)
Diff checked with grep and MK1 eyeball.
i386 and amd64 GENERIC and sys still build.
 1.7 17-Oct-2007  garbled branches: 1.7.20; 1.7.28; 1.7.34;
Merge the ppcoea-renovation branch to HEAD.

This branch was a major cleanup and rototill of many of the various OEA
cpu based PPC ports that focused on sharing as much code as possible
between the various ports to eliminate near-identical copies of files in
every tree. Additionally there is a new PIC system that unifies the
interface to interrupt code for all different OEA ppc arches. The work
for this branch was done by a variety of people, too long to list here.

TODO:
bebox still needs work to complete the transition to -renovation.
ofppc still needs a bunch of work, which I will be looking at.
ev64260 still needs to be renovated
amigappc was not attempted.

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.6 17-Jan-2007  macallan branches: 1.6.6; 1.6.14; 1.6.22; 1.6.24; 1.6.26; 1.6.28;
new drivers for pmu and cuda
 1.5 24-Dec-2005  perry branches: 1.5.20;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.
 1.4 19-Jun-2001  simonb branches: 1.4.8; 1.4.40;
Add/change prototypes so that macpcc builds with -Wstrict-prototypes.
 1.3 01-Apr-2001  tsubai Correct vBufA offset. (currenly not used)
 1.2 20-Oct-1998  tsubai branches: 1.2.12; 1.2.24;
Add via-pmu support (only PowerBook 2400c/180 is tested).
 1.1 15-May-1998  tsubai Initial import of macppc port.
 1.2.24.2 21-Jun-2001  nathanw Catch up to -current.
 1.2.24.1 09-Apr-2001  nathanw Catch up with -current.
 1.2.12.1 21-Apr-2001  bouyer Sync with HEAD
 1.4.40.3 27-Oct-2007  yamt sync with head.
 1.4.40.2 26-Feb-2007  yamt sync with head.
 1.4.40.1 21-Jun-2006  yamt sync with head.
 1.4.8.2 19-Jun-2001  simonb Add/change prototypes so that macpcc builds with -Wstrict-prototypes.
 1.4.8.1 19-Jun-2001  simonb file viareg.h was added on branch nathanw_sa on 2001-06-19 12:02:57 +0000
 1.5.20.1 01-Feb-2007  ad Sync with head.
 1.6.28.1 25-Oct-2007  bouyer Sync with HEAD.
 1.6.26.1 18-Oct-2007  yamt sync with head.
 1.6.24.1 06-Nov-2007  matt sync with HEAD
 1.6.22.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.6.14.1 07-Jun-2007  garbled Convert macppc to powerpc bus_space. Lots of work here from Matt Thomas,
as well as the common ofwoea code from myself. Compile tested only,
still probably needs some fine tuning.

Also in this commit:
Convert macppc to new shared ofwoea routines.
Lots of KNF.
 1.6.6.1 23-Oct-2007  ad Sync with head.
 1.7.34.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.7.28.1 28-Apr-2009  skrll Sync with HEAD.
 1.7.20.1 04-May-2009  yamt sync with head.
 1.8.16.1 18-Feb-2012  mrg merge to -current.
 1.8.12.1 17-Apr-2012  yamt sync with head
 1.4 20-Dec-2023  thorpej Remove unnecessary <sys/malloc.h>.
 1.3 16-Jun-2018  thorpej branches: 1.3.18; 1.3.28;
More cleanup to i2c autoconfiguration:

- Get all of the drivers onto the new match quality constants.
- Introduce a new helper function, iic_use_direct_match(), that has
all of the logic for direct-config matching. If it returns true,
the driver returns the match result (which may be 0). If it returns
false, the driver does indirect-config matching.
- iic_compat_match() now returns a weighted match quality; matches to
lower-indexed "compatible" device property are more-specific matches,
and return a better match quality accordingly.
 1.2 22-Sep-2017  macallan branches: 1.2.2;
switch to direct configuration
 1.1 24-Jan-2012  macallan branches: 1.1.4; 1.1.6; 1.1.10;
drivers to support the onboard video circuitry found in for example the
Performa 6360
 1.1.10.1 03-Dec-2017  jdolecek update from HEAD
 1.1.6.2 17-Apr-2012  yamt sync with head
 1.1.6.1 24-Jan-2012  yamt file videopll.c was added on branch yamt-pagecache on 2012-04-17 00:06:37 +0000
 1.1.4.2 18-Feb-2012  mrg merge to -current.
 1.1.4.1 24-Jan-2012  mrg file videopll.c was added on branch jmcneill-usbmp on 2012-02-18 07:32:36 +0000
 1.2.2.1 25-Jun-2018  pgoyette Sync with HEAD
 1.3.28.2 11-Sep-2021  thorpej Remove some useless comments.
 1.3.28.1 09-Aug-2021  thorpej Port over the changes from thorpej-i2c-spi-conf to thorpej-i2c-spi-conf2,
which is based on a newer HEAD revision.
 1.3.18.1 08-May-2021  thorpej Children of the "cuda" i2c controller don't appear in the OF device tree,
so we need to supply our own "i2c-enumerate-devices" method.
 1.5 16-Apr-2020  rin Revert previous for now:
http://mail-index.netbsd.org/source-changes/2020/04/16/msg116278.html

The reasoning turned out to be wrong; __KERNEL_RCSID() in header files
does *not* overwrite RCSID in main source files. The real problem is that
it inserts its RCSID into *every* object files. However, it can be still
useful even if heavily duplicated.
 1.4 16-Apr-2020  rin Stop using __KERNEL_RCSID() in header files; it confuses ident(1) by
overwriting RCSID in main source files.

XXX
The first argument of __KERNEL_RCSID() is neglected for ELF. If we wish
to have RCSID of header files in kernel binary, we need something like
__FBSDID() macro in FreeBSD.
 1.3 16-Feb-2018  macallan branches: 1.3.14;
remove accidential garbage
 1.2 16-Feb-2018  macallan add $NetBSD:
 1.1 24-Jan-2012  macallan branches: 1.1.4; 1.1.6;
drivers to support the onboard video circuitry found in for example the
Performa 6360
 1.1.6.2 17-Apr-2012  yamt sync with head
 1.1.6.1 24-Jan-2012  yamt file videopllvar.h was added on branch yamt-pagecache on 2012-04-17 00:06:37 +0000
 1.1.4.2 18-Feb-2012  mrg merge to -current.
 1.1.4.1 24-Jan-2012  mrg file videopllvar.h was added on branch jmcneill-usbmp on 2012-02-18 07:32:36 +0000
 1.3.14.1 20-Apr-2020  bouyer Sync with HEAD
 1.63 05-Mar-2021  rin Convert to intr_establish_xname().
 1.62 26-Jan-2021  thorpej There is not much point in of_compatible() returning -1 for "no match"
and >= 0 for "match". Just make it return 0 for "no match" and >0 for
"match" so it can be treated like a boolean expression.

As such of_match_compatible() (a wrapper around of_compatible()) is now
obsolete, and will be removed once all call sites are converted to an
appropriate replacement.
 1.61 20-Oct-2017  jdolecek branches: 1.61.16;
move ata_queue_alloc(1) and ata_queue_free() calls to ata_channel_init()
and ata_channel_destroy() respectively, to make attachment code simpler,
and to make it easier to spot special queue manipulation like cmdide(4)

on topic of PR kern/52606
 1.60 07-Oct-2017  jdolecek Merge support for SATA NCQ (Native Command Queueing) from jdolecek-ncq branch

ATA subsystem was changed to support several outstanding commands, and use
NCQ xfers if supported by both the controller and the disk, including NCQ
error recovery. Set NCQ high priority for BPRIO_TIMECRITICAL xfers
if supported. Added FUA support.

Done some work towards MP-safe, all ATA code tsleep()/wakeup() replaced
by condvars, and switched most code from spl* to mutexes (separate
wd(4) and ata channel lock).

Introduced new option WD_CHAOS_MONKEY to facilitate testing of error
handling, fixed several uncovered issues. Also fixed several problems
with kernel dump to wd(4) disk.

Tested with ahcisata(4), mvsata(4), siisata(4), piixide(4) on amd64,
with and without port multiplier, both disk and ATAPI devices; other
drivers and archs mechanically adjusted and compile-tested. NCQ is
supported for ahcisata(4) and siisata(4) for any controller, for
mvsata(4) only Gen IIe ones for now. Also enabled ATAPI support in
mvsata(4).

Thanks to Matt Thomas for initial ATA infrastructure patch, and
Jonathan A.Kollasch for siisata(4) NCQ changes and general testing.

Also fixes PR kern/43169 (wd(4)); and PR kern/11811, PR kern/47041,
PR kern/51979 (kernel dump)
 1.59 15-Jul-2016  macallan branches: 1.59.4;
- only unmap / free dbdma stuff when we actually mapped / allocated it
- use dbdma_free
now wdc_obio_detach() actually works without crashing
 1.58 31-Jul-2012  bouyer branches: 1.58.2; 1.58.16; 1.58.20;
Apply back changes that were reverted on Jul 24 and Jul 26 (general ata/wdc
cleanup and SATA PMP support), now that I'm back to fix the fallouts.
 1.57 26-Jul-2012  jakllsch Revert, with intention of restoring in a less invasive way, the SATA Port
Multiplier code.

ok christos@
 1.56 24-Jul-2012  jakllsch Revert dsl@'s changes of Sun, 15 Jul 2012 10:55:35 +0000 and
Sun, 15 Jul 2012 10:56:50 +0000, excepting the kernel version bump.
First step in reverting regressions to ata(4) subsystem during the addition of
port multiplier support.
 1.55 15-Jul-2012  dsl Some namespace protection (and add greppablity).
Prefix the DRIVE_ and DRIVET_ constants from atavar.h with ATA_.
Don't use an enum for drive_type - you don't know how big it will be.
Move driver_type to avoid implicit structure padding (esp on arm).
This change is purely lexical and mechanical.

Update to 6.99.9 - this wasn't done when the SATA PMP changes
were made - I'm sure they warranted a bump.
 1.54 02-Jul-2012  bouyer Add sata Port MultiPlier (PMP) support to the ata bus layer,
as described in
http://mail-index.netbsd.org/tech-kern/2012/06/23/msg013442.html
PMP support in integrated to the atabus layer.
struct ata_channel's ch_drive[] is not dynamically allocated, and ch_ndrive
(renamed to ch_ndrives) closely reflects the size of the ch_drive[] array.
Add helper functions atabus_alloc_drives() and atabus_free_drives()
to manage ch_drive[]/ch_ndrives.
Add wdc_maxdrives to struct wdc_softc so that bus front-end can specify
how much drive they really support (master/slave or single).
ata_reset_drive() callback gains a uint32_t *sigp argument which,
when not NULL, will contain the signature of the device being reset.
While there, some cosmetic changes:
- added a drive_type enum to ata_drive_datas, and stop encoding the
probed drive type in drive_flags (we were out of drive flags anyway).
- rename DRIVE_ATAPIST to DRIVE_ATAPIDSCW to better reflect what this
really is
- remove ata_channel->ata_drives, it's redundant with the pointer in
ata_drive_datas
- factor out the interpretation of SATA signatures in sata_interpet_sig()

propagate these changes to the ATA HBA drivers, and add support for PMP
to ahcisata(4) and siisata(4).

Thanks to:
- Protocase (http://www.protocase.com/) which provided a system
with lots of controllers, SATA PMP and drive slots
- Conservation Genomics Laboratory, Department of Biology, New Mexico State
University for hosting the above system
- Brook Milligan, who set up remote access and has been very responsive
when SATA cable move was needed
 1.53 01-Jul-2011  dyoung branches: 1.53.2;
#include <sys/bus.h> instead of <machine/bus.h>.
 1.52 18-Nov-2009  dyoung wdcactivate() is gone, don't use it.
 1.51 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.50 30-Mar-2008  macallan branches: 1.50.2; 1.50.4;
free & unmap DMA memory and registers on detach()
Now removing and re-attaching a mediabay works again.
 1.49 18-Mar-2008  cube Split device_t and softc for ATA devices, as well as wd(4). Other
cosmetic changes where appropriate.
 1.48 25-Feb-2008  matt Convert to prototypes, de'__P, use device_private, switch to aprint_*,
make things static, and some minor constification.
 1.47 17-Oct-2007  garbled branches: 1.47.12; 1.47.16;
Merge the ppcoea-renovation branch to HEAD.

This branch was a major cleanup and rototill of many of the various OEA
cpu based PPC ports that focused on sharing as much code as possible
between the various ports to eliminate near-identical copies of files in
every tree. Additionally there is a new PIC system that unifies the
interface to interrupt code for all different OEA ppc arches. The work
for this branch was done by a variety of people, too long to list here.

TODO:
bebox still needs work to complete the transition to -renovation.
ofppc still needs a bunch of work, which I will be looking at.
ev64260 still needs to be renovated
amigappc was not attempted.

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.46 07-Nov-2006  macallan branches: 1.46.8; 1.46.16; 1.46.26; 1.46.28; 1.46.30; 1.46.32;
allow IDE DMA on Heathrow again
 1.45 04-Sep-2006  macallan branches: 1.45.2; 1.45.4;
trying to use IDE DMA on a Heathrow macio is busted so disable it for now.
 1.44 29-Mar-2006  thorpej Use device_cfdata().
 1.43 16-Jan-2006  bouyer branches: 1.43.2; 1.43.4; 1.43.6; 1.43.8; 1.43.10;
properly use ata_channel->ch_ndrive:
- initialize it properly in the bus front-ends (all 2, exept in wdc_pcmcia.c
for the "Sandisk CompactFlash Card" where it's set to 1)
- remplace hardcoded '2' by ata_channel->ch_ndrive in MI IDE drivers.

From Christos Zoulas in kern/32501.
 1.42 11-Dec-2005  christos branches: 1.42.2;
merge ktrace-lwp.
 1.41 23-Aug-2004  aymeric branches: 1.41.12;
postpone the calling of wdc_init_shadow_regs(), to follow MI changes.
Thanks to Jukka Andberg for finding that bug.
 1.40 20-Aug-2004  thorpej Move most of wdc_softc into a new atac_softc structure that contains
info common to all types of ATA controllers.
 1.39 14-Aug-2004  thorpej - Split the register handles out of struct wdc_channel into a separate
wdc_regs structure, and array of which (indexed per channel) is pointed
to by struct wdc_softc.
- Move the resulting wdc_channel structure to atavar.h and rename it to
ata_channel. Rename the corresponding flags.
- Add a "ch_ndrive" member to struct ata_channel, which indicates the
maximum number of drives that can be present on the channel. For now,
this is always 2. Add an ATA_MAXDRIVES constant that places an upper
limit on this value, also currently 2.
 1.38 13-Aug-2004  thorpej Don't bother with bits that tell of the presence of optional callbacks;
just check the function pointers for NULL.
 1.37 25-May-2004  thorpej Add the notion of "shadow registers" to the wdc driver. These shadow
registers are registers that overlap with others on many controllers, but
which may actually be distinct on some controllers. Right now, the two
shadows are:

- wd_status (usually overlaps wd_command)
- wd_features (usually overlaps wd_error)

Add a new helper function, wdc_init_shadow_regs(), used to initialize
the shadow register handles on controllers where they do actually overlap.

Partially from Jordan Rhody @ Wasabi Systems, Inc.
 1.36 04-Jan-2004  dbj attempt to make these compile again after recent wdc changes.
 1.35 03-Jan-2004  thorpej More wdc_channel structure member namespace cleanup:
- channel -> ch_channel
- wdc -> ch_wdc
 1.34 03-Jan-2004  thorpej Rename "struct channel_softc" to "struct wdc_channel".
 1.33 01-Jan-2004  thorpej Rename:
- wdc_xfer to ata_xfer
- channel_queue to ata_queue
and move them to <dev/ata/atavar.h> so they can be used by non-wdc ATA
controllers. Clean up the member names of these structures while at it.
 1.32 31-Dec-2003  thorpej Simplify allocation of the channel queue.
 1.31 27-Dec-2003  mjl Initialize some auto vars to appaise gcc3.
 1.30 03-Dec-2003  bouyer Adapt for new wdc regiosters array. Should fix port-macppc/23604.
 1.29 08-Oct-2003  bouyer Adapt for wdcattach() prototype change, and deal with atabus in
device_register().
 1.28 25-Sep-2003  mycroft Hide the use of config_interrupts() in one place.
 1.27 19-Sep-2003  mycroft 1) Use config_interrupts() to attach IDE and ATAPI drives. This eliminates
most polling.
2) Clean up some goofiness in pciide -- get rid of the whole "candisable" path
(it's gratuitous) and simplify the code by calling pciide_map_compat_intr(),
*_set_modes() and wdc_print_modes() from central locations.
3) Add a register writability and register ghost test to eliminate phantom
drives more quickly.
 1.26 15-Jul-2003  lukem __KERNEL_RCSID()
 1.25 19-Jun-2003  hamajima branches: 1.25.2;
Fix wdc_obio_dma_init() confused WDC_DMA_LBA48 with WDC_DMA_READ.
This was tested by jtb@netbsd.org.
 1.24 03-May-2003  wiz DMA, not dma nor Dma.
 1.23 02-Apr-2003  thorpej Use PAGE_SIZE rather than NBPG.
 1.22 02-Oct-2002  thorpej Use CFATTACH_DECL().
 1.21 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.20 18-Jul-2002  bouyer Wrap debug printf in #ifdef DEBUG/#endif
 1.19 09-Jan-2002  dbj branches: 1.19.8; 1.19.10;
tweak timings
 1.18 07-Jan-2002  dbj Changes to the wdc(4) mi driver that add the WDC_CAPABILITY_SELECT
flag and a callback function which gets called whenever a target is
selected on a channel.

The macppc wdc driver needs to reprogram its timing register
differently for each target on a channel each time that target is
selected. I also changed the ATA4_TIME_TO_TICK to use a divisor of
15, which brings our timing calculations consistent with darwin.

These patches fix problems on my dual usb ibook with combo dvd/cdrw
drive because the hard drive supports udma and the combo drive does
not. Without turning off the udma timings in the configuration
register, I cannot access the non-udma combo drive.
 1.17 09-Sep-2001  bouyer branches: 1.17.4;
Properly initiatize sc->sc_wdcdev.set_modes for non-DMA controllers.
 1.16 02-Aug-2001  bouyer branches: 1.16.2;
Properly setup timings for ata-4 controllers, including UDMA modes.
Tested on a brand new ("dual USB ?") ibook.
 1.15 25-Jul-2001  bouyer Return() if piomode == -1 (i.e. we have no drives), avoid reading an array with
a negative offset.
Thanks to Andrew Cagney for pointing this out.
 1.14 22-Jul-2001  wiz bcopy -> memcpy, bzero -> memset, bcmp -> memcmp.
Reviewed by Matt Thomas, ok'd by Tsubai Masanari.
 1.13 15-Jun-2001  bouyer branches: 1.13.2;
Pass WDC_CAPABILITY_MODE to the wdc core, so that it will set timings
on the drive side too.
Deal properly with the case where master and slave don't have the same timings,
and set PIO timings too.
 1.12 08-Jun-2001  matt Make macppc compile by default with -Wall -Wmissing-prototype in addition
to its currently enabled warnings. For the lack of a better place, most
global function prototype wound up in <machine/autoconf.h> unless there
was a better place for them. ofb_* structs renamed to offb_* to avoid
conflict with ofb_softc in <dev/ofw/openfirm.h>
 1.11 08-Nov-2000  wrstuden branches: 1.11.2;
Use wdc_print_modes() so that we get to see what DMA modes
are used with a drive.
 1.10 29-Jun-2000  mrg remove include of <vm/vm.h>. <vm/vm.h> -> <uvm/uvm_extern.h>
 1.9 23-May-2000  tsubai branches: 1.9.4;
Modify DMA access timings.
 1.8 14-Apr-2000  tsubai Make this compile.
 1.7 02-Apr-2000  tsubai Enable wdc1 (needed on StarMax).
 1.6 21-Jan-2000  tsubai Match "keylargo-ata".
 1.5 04-Oct-1999  tsubai branches: 1.5.2;
Make media-bay CD detachable.
 1.4 14-Jun-1999  tsubai * Don't use DMA interrupt.
* Stop DMA explicitly in finish routine.
 1.3 01-May-1999  tsubai Use "compatible" property to match.
 1.2 22-Jan-1999  tsubai branches: 1.2.2;
Match "ata0".
 1.1 10-Dec-1998  tsubai Add ata/atapi disk support.
 1.2.2.2 07-Jul-2000  he Apply patch (requested by bouyer):
Add support for the following PCIIDE controllers:
o AMD 756
o CMD PCI0648 and PCI0649
o Hightpoint HPT366
o OPTi 82c621 (and a few of its derivatives)
o Promise Ultra/33 and Ultra/66
o Intel 82801 (ICH/ICH0)
Also fix PR#10437 (detect more ATAPI devices).
 1.2.2.1 06-May-1999  perry branches: 1.2.2.1.2;
pullup 1.2->1.3 (thorpej)
 1.2.2.1.2.1 21-Jun-1999  thorpej Sync w/ -current.
 1.5.2.2 22-Nov-2000  bouyer Sync with HEAD.
 1.5.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.9.4.1 16-Jan-2002  he Pull up revisions 1.13,1.15-1.19 (via patch, requested by dbj):
Add UDMA support and allow separate DMA timings to be programmed
for two different devices on the same wdc channel on the macppc.
The machine-independent driver is updated to optionally use the
WDC_CAPABILITY_SELECT callback whenever a target is selected on
a channel.
 1.11.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.13.2.5 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.13.2.4 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.13.2.3 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.13.2.2 13-Sep-2001  thorpej Update the kqueue branch to HEAD.
 1.13.2.1 03-Aug-2001  lukem update to -current
 1.16.2.1 01-Oct-2001  fvdl Catch up with -current.
 1.17.4.5 18-Oct-2002  nathanw Catch up to -current.
 1.17.4.4 01-Aug-2002  nathanw Catch up to -current.
 1.17.4.3 28-Feb-2002  nathanw Catch up to -current.
 1.17.4.2 11-Jan-2002  nathanw More catchup.
 1.17.4.1 09-Sep-2001  nathanw file wdc_obio.c was added on branch nathanw_sa on 2002-01-11 23:38:35 +0000
 1.19.10.2 24-Jun-2003  grant Pull up revision 1.25 (requested by hamajima in ticket #1328):

Fix wdc_obio_dma_init() confused WDC_DMA_LBA48 with WDC_DMA_READ.
This was tested by jtb@netbsd.org.
 1.19.10.1 19-Jul-2002  lukem Pull up revision 1.20 (requested by bouyer in ticket #519):
Wrap debug printf in #ifdef DEBUG/#endif
 1.19.8.1 21-Jul-2002  gehenna catch up with -current.
 1.25.2.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.25.2.3 18-Sep-2004  skrll Sync with HEAD.
 1.25.2.2 25-Aug-2004  skrll Sync with HEAD.
 1.25.2.1 03-Aug-2004  skrll Sync with HEAD
 1.41.12.5 24-Mar-2008  yamt sync with head.
 1.41.12.4 27-Feb-2008  yamt sync with head.
 1.41.12.3 27-Oct-2007  yamt sync with head.
 1.41.12.2 30-Dec-2006  yamt sync with head.
 1.41.12.1 21-Jun-2006  yamt sync with head.
 1.42.2.1 01-Feb-2006  yamt sync with head.
 1.43.10.1 31-Mar-2006  tron Merge 2006-03-31 NetBSD-current into the "peter-altq" branch.
 1.43.8.1 19-Apr-2006  elad sync with head - hopefully this will work
 1.43.6.2 14-Sep-2006  yamt sync with head.
 1.43.6.1 01-Apr-2006  yamt sync with head.
 1.43.4.1 22-Apr-2006  simonb Sync with head.
 1.43.2.1 09-Sep-2006  rpaulo sync with head
 1.45.4.1 10-Dec-2006  yamt sync with head.
 1.45.2.1 18-Nov-2006  ad Sync with head.
 1.46.32.1 25-Oct-2007  bouyer Sync with HEAD.
 1.46.30.1 18-Oct-2007  yamt sync with head.
 1.46.28.2 23-Mar-2008  matt sync with HEAD
 1.46.28.1 06-Nov-2007  matt sync with HEAD
 1.46.26.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.46.16.8 12-Sep-2007  macallan remove some unused cargo-cult leftover, finish bus_space-ification, fix
some typos. Now UDMA66 with keylargo-ata should work again.
 1.46.16.7 08-Aug-2007  macallan use a level triggered interrupt if the firmware asks us to
 1.46.16.6 08-Aug-2007  macallan get rid of our own bus_space_tag - we provide a bus_space_handle_t for every
single WDC register anyway. Also request an edge-triggered IRQ since some
PIC drivers now actually honour the IRQ type.
 1.46.16.5 02-Aug-2007  macallan set pbs_limit to something sane
 1.46.16.4 02-Aug-2007  macallan adapt to new bus_space, now it works at least on my pb3400c
 1.46.16.3 19-Jun-2007  matt Simplify and don't allocate a separate bus space.
 1.46.16.2 07-Jun-2007  garbled Convert macppc to powerpc bus_space. Lots of work here from Matt Thomas,
as well as the common ofwoea code from myself. Compile tested only,
still probably needs some fine tuning.

Also in this commit:
Convert macppc to new shared ofwoea routines.
Lots of KNF.
 1.46.16.1 11-May-2007  macallan request the correct interrupt type in a couple drivers - necessary since
these days we actually do something with the type argument
 1.46.8.1 23-Oct-2007  ad Sync with head.
 1.47.16.2 02-Jun-2008  mjf Sync with HEAD.
 1.47.16.1 03-Apr-2008  mjf Sync with HEAD.
 1.47.12.1 24-Mar-2008  keiichi sync with head.
 1.50.4.2 11-Mar-2010  yamt sync with head
 1.50.4.1 16-May-2008  yamt sync with head.
 1.50.2.1 18-May-2008  yamt sync with head.
 1.53.2.1 30-Oct-2012  yamt sync with head
 1.58.20.1 26-Jul-2016  pgoyette Sync with HEAD
 1.58.16.1 05-Oct-2016  skrll Sync with HEAD
 1.58.2.1 03-Dec-2017  jdolecek update from HEAD
 1.59.4.2 27-Sep-2017  jdolecek change wdc_init_shadow_regs() to accept only struct wdc_regs, it doesn't
touch anything else

factor out the probe-only struct ata_channel initialization to wdcprobe(), to
reduce duplication of logic in individual drivers, and to actually work now
that more init is needed beyond the memset()
 1.59.4.1 24-Apr-2017  jdolecek use ata_queue_alloc() to dynamically allocate ata_queue for ata channel
 1.61.16.1 03-Apr-2021  thorpej Sync with HEAD.
 1.25 27-Dec-2005  chs switch macppc to use the MI zstty driver.
add macppc's ZS_TXDMA hooks there.
 1.24 11-Dec-2005  christos merge ktrace-lwp.
 1.23 06-Sep-2005  kleink Change the driver open function's conditional for overriding exclusive tty
use from checking the proc's uid to suser(9), and account for the use of
privileges. Noted by David Holland in PR kern/31126.
 1.22 03-Jun-2005  matt branches: 1.22.2;
cleanup const/volatile/shadowing
 1.21 04-Dec-2003  keihan netbsd.org -> NetBSD.org

All "netbsd.org" is now gone from src/sys/arch.
 1.20 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.19 15-Jul-2003  lukem __KERNEL_RCSID()
 1.18 29-Jun-2003  fvdl branches: 1.18.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.17 29-Jun-2003  darrenr 'struct proc *' -> 'struct lwp *' as required to get GENERIC for macppc built
 1.16 23-Oct-2002  jdolecek merge kqueue branch into -current

kqueue provides a stateful and efficient event notification framework
currently supported events include socket, file, directory, fifo,
pipe, tty and device changes, and monitoring of processes and signals

kqueue is supported by all writable filesystems in NetBSD tree
(with exception of Coda) and all device drivers supporting poll(2)

based on work done by Jonathan Lemon for FreeBSD
initial NetBSD port done by Luke Mewburn and Jason Thorpe
 1.15 02-Oct-2002  thorpej Use CFATTACH_DECL().
 1.14 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.13 06-Sep-2002  gehenna Merge the gehenna-devsw branch into the trunk.

This merge changes the device switch tables from static array to
dynamically generated by config(8).

- All device switches is defined as a constant structure in device drivers.

- The new grammer ``device-major'' is introduced to ``files''.

device-major <prefix> char <num> [block <num>] [<rules>]

- All device major numbers must be listed up in port dependent majors.<arch>
by using this grammer.

- Added the new naming convention.
The name of the device switch must be <prefix>_[bc]devsw for auto-generation
of device switch tables.

- The backward compatibility of loading block/character device
switch by LKM framework is broken. This is necessary to convert
from block/character device major to device name in runtime and vice versa.

- The restriction to assign device major by LKM is completely removed.
We don't need to reserve LKM entries for dynamic loading of device switch.

- In compile time, device major numbers list is packed into the kernel and
the LKM framework will refer it to assign device major number dynamically.
 1.12 17-Mar-2002  atatat branches: 1.12.4;
Convert ioctl code to use EPASSTHROUGH instead of -1 or ENOTTY for
indicating an unhandled "command". ERESTART is -1, which can lead to
confusion. ERESTART has been moved to -3 and EPASSTHROUGH has been
placed at -4. No ioctl code should now return -1 anywhere. The
ioctl() system call is now properly restartable.
 1.11 06-Jan-2002  dbj add support for kgdb over zs
 1.10 20-Jun-2001  briggs branches: 1.10.2; 1.10.4; 1.10.8;
There is no other support for KGDB in this driver yet, so ifdef out the
call to a non-existent (on macppc) zs_check_kgdb() for now.
 1.9 30-May-2001  lukem add missing #include "opt_kgdb.h"
 1.8 02-May-2001  scw Add `l_poll' to `struct linesw' and provide an xxxpoll() entry point
in each tty driver to indirect through it.

This allows tty line-disciplines to handle poll(2) system calls.
 1.7 02-Nov-2000  eeh branches: 1.7.2;
Adapt to new line discipline scheme.
 1.6 26-Mar-2000  tsubai Fix typo.
 1.5 23-Mar-2000  thorpej New callout mechanism with two major improvements over the old
timeout()/untimeout() API:
- Clients supply callout handle storage, thus eliminating problems of
resource allocation.
- Insertion and removal of callouts is constant time, important as
this facility is used quite a lot in the kernel.

The old timeout()/untimeout() API has been removed from the kernel.
 1.4 06-Feb-1999  tsubai branches: 1.4.8;
Make this compile. (and sync with dev/ic completely)
 1.3 03-Feb-1999  mycroft Clone changes from the version in dev/ic. (These should be merged!)
Note: NOT tested on this port yet.
 1.2 31-Aug-1998  cgd kill the last remnants of __BROKEN_INDIRECT_CONFIG. (only the pica port
used it, and it's non-working and apparently slated for replacement.)
 1.1 15-May-1998  tsubai Initial import of macppc port.
 1.4.8.2 22-Nov-2000  bouyer Sync with HEAD.
 1.4.8.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.7.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.10.8.7 11-Nov-2002  nathanw Catch up to -current
 1.10.8.6 18-Oct-2002  nathanw Catch up to -current.
 1.10.8.5 17-Sep-2002  nathanw Catch up to -current.
 1.10.8.4 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.10.8.3 28-Feb-2002  nathanw Catch up to -current.
 1.10.8.2 11-Jan-2002  nathanw More catchup.
 1.10.8.1 20-Jun-2001  nathanw file z8530tty.c was added on branch nathanw_sa on 2002-01-11 23:38:35 +0000
 1.10.4.2 13-Oct-2001  fvdl Revert the t_dev -> t_devvp change in struct tty. The way that tty
structs are currently used (especially by console ttys) aren't
ready for it, and this will require quite a few changes.
 1.10.4.1 10-Oct-2001  fvdl Convert all remaining devices.
 1.10.2.3 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.10.2.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.10.2.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.12.4.1 19-May-2002  gehenna Add device switch.
Replace the access to devsw table and the hard-coded majors with devsw API.
 1.18.2.5 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.18.2.4 18-Nov-2004  skrll Adapt to branch. macppc release builds.
 1.18.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.18.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.18.2.1 03-Aug-2004  skrll Sync with HEAD
 1.22.2.1 21-Jun-2006  yamt sync with head.
 1.59 24-Sep-2023  andvar pass NULL to the second dbdma_alloc() expected argement.
it was not adjusted after it acquired one 7 years ago.

fixes ZS_TXDMA enabled build for macppc.
 1.58 23-Sep-2023  andvar some whitespace cleanup for debug printf calls.
 1.57 23-Sep-2023  andvar change zsprintf to printf. It was defined as printf in include/z8530var.h
up to rev 1.4, then removed with conversion to MI 8530 SCC driver back in 1997.

Fixes build with ZSMACDEBUG option enabled for mac68k and macppc.
 1.56 16-Feb-2022  riastradh powerpc: Sprinkle "memory" clobbers on eieio and nearby asm blocks.

Otherwise the compiler may reorder these around loads and stores,
which mostly defeats the purpose. `asm volatile' just ensures the
instruction isn't _deleted_; it may still move around.
 1.55 13-Feb-2022  martin PR port-macppc/56091: on G5 macs we currently can not easily make
early serial console work, so keep the OF based "failsafe" console
but note that we would like to switch over.
Once zs attaches, use the new device mapping and do a belated init
of the zs console globals, and then switch over to real zs based
serial console.
 1.54 11-Sep-2021  andvar Add missing double p and d for stopped and overriden accordingly.
Fix few more typos along the way, mainly in copy-pasted comments.
 1.53 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.52 24-Apr-2021  thorpej branches: 1.52.8;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).
 1.51 05-Mar-2021  rin branches: 1.51.2;
Convert to intr_establish_xname().
 1.50 30-Jun-2011  matt branches: 1.50.66;
Modify mapiodev to take a third argument indicating whether the space
should be prefetchable (true) or not (false).
 1.49 27-Oct-2009  snj Drop 3rd and 4th clauses. Approved by gwr@ and wrstuden@ (copyright
holders).
 1.48 07-Dec-2008  tsutsui Fix attach messages. (extra colons, misplaced newline etc.)
 1.47 13-Jun-2008  cegger branches: 1.47.2; 1.47.4; 1.47.6;
use device_lookup_private to get softc
 1.46 29-Mar-2008  tsutsui branches: 1.46.2; 1.46.4; 1.46.6; 1.46.8;
Split softc and device_t for zsc(4) and its children.

XXX we should restructure MI APIs and make it really machine independent.
 1.45 19-Nov-2007  ad branches: 1.45.14;
Use the softint API.
 1.44 09-Nov-2007  ad Call zs_lock_init() to set up the chanstate's lock.
 1.43 17-Oct-2007  garbled branches: 1.43.2;
Merge the ppcoea-renovation branch to HEAD.

This branch was a major cleanup and rototill of many of the various OEA
cpu based PPC ports that focused on sharing as much code as possible
between the various ports to eliminate near-identical copies of files in
every tree. Additionally there is a new PIC system that unifies the
interface to interrupt code for all different OEA ppc arches. The work
for this branch was done by a variety of people, too long to list here.

TODO:
bebox still needs work to complete the transition to -renovation.
ofppc still needs a bunch of work, which I will be looking at.
ev64260 still needs to be renovated
amigappc was not attempted.

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.42 04-Mar-2007  christos branches: 1.42.2; 1.42.10; 1.42.18; 1.42.20; 1.42.22; 1.42.24;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.41 24-Nov-2006  wiz branches: 1.41.4;
s/independant/independent/, from Zafer.
 1.40 02-Nov-2006  tsutsui Remove a function declaration of zssoft() which was
inside #ifndef __HAVE_GENERIC_SOFT_INTERRUPTS.
 1.39 02-Nov-2006  tsutsui Pass zsc_softc to zshard() directly rather than searching it in zshard().

Checking all zsc units in zshard() is efficient only on ports
which share one interrupt among all zsc units, like sparc or sun3.
On such ports, zshard() is established as a handler only once.

XXX1: more other MD zs drivers should be fixed similarly.
XXX2: zsc on macppc has independent interrupts for channel A and B,
but MI z8530sc can't handle such configuration.
 1.38 02-Nov-2006  tsutsui macppc always defines __HAVE_GENERIC_SOFT_INTERRUPTS,
so remove #ifdef/#ifndefs against it.
 1.37 15-Aug-2006  macallan branches: 1.37.2; 1.37.4;
back out previous commit since it breaks console output when not using a
serial console
 1.36 05-Aug-2006  sanjayl branches: 1.36.2;
1st cut of Powermac G5 support (uses bridge mode).
 1.35 24-Dec-2005  perry branches: 1.35.4; 1.35.8;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.
 1.34 11-Dec-2005  christos merge ktrace-lwp.
 1.33 03-Jun-2005  matt branches: 1.33.2;
cleanup const/volatile/shadowing
 1.32 24-Jan-2005  matt Initialize zsconschannel to -1 so that it can't matched unless zscninit
is explicitly called to set it up.
 1.31 10-Jan-2005  chs branches: 1.31.2;
use a global variable to ensure that only one instance is configured
rather than requiring that its unit number be zero.
simplify by not pretending that powermacs can have more than 1 zsc.
 1.30 10-Jan-2005  chs de-__P, remove register, ansify.
 1.29 24-Mar-2004  matt Add latent generic soft interrupt support.
 1.28 04-Dec-2003  keihan netbsd.org -> NetBSD.org

All "netbsd.org" is now gone from src/sys/arch.
 1.27 15-Jul-2003  lukem __KERNEL_RCSID()
 1.26 15-Feb-2003  tsutsui branches: 1.26.2;
Add prototypes for ZS_TXDMA functions.
XXX Maybe we should have DMA hooks in MI z8530tty.
 1.25 28-Jan-2003  pk Provide locking required by the interrupt handlers running at IPL_SERIAL.
 1.24 01-Jan-2003  thorpej Use aprint_normal() for cfprint routines.
 1.23 02-Oct-2002  thorpej Use CFATTACH_DECL().
 1.22 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.21 06-Sep-2002  gehenna Merge the gehenna-devsw branch into the trunk.

This merge changes the device switch tables from static array to
dynamically generated by config(8).

- All device switches is defined as a constant structure in device drivers.

- The new grammer ``device-major'' is introduced to ``files''.

device-major <prefix> char <num> [block <num>] [<rules>]

- All device major numbers must be listed up in port dependent majors.<arch>
by using this grammer.

- Added the new naming convention.
The name of the device switch must be <prefix>_[bc]devsw for auto-generation
of device switch tables.

- The backward compatibility of loading block/character device
switch by LKM framework is broken. This is necessary to convert
from block/character device major to device name in runtime and vice versa.

- The restriction to assign device major by LKM is completely removed.
We don't need to reserve LKM entries for dynamic loading of device switch.

- In compile time, device major numbers list is packed into the kernel and
the LKM framework will refer it to assign device major number dynamically.
 1.20 17-Mar-2002  atatat branches: 1.20.4;
Convert ioctl code to use EPASSTHROUGH instead of -1 or ENOTTY for
indicating an unhandled "command". ERESTART is -1, which can lead to
confusion. ERESTART has been moved to -3 and EPASSTHROUGH has been
placed at -4. No ioctl code should now return -1 anywhere. The
ioctl() system call is now properly restartable.
 1.19 06-Jan-2002  dbj add support for kgdb over zs
 1.18 22-Jul-2001  wiz branches: 1.18.6;
bcopy -> memcpy, bzero -> memset, bcmp -> memcmp.
Reviewed by Matt Thomas, ok'd by Tsubai Masanari.
 1.17 19-Jun-2001  wiz branches: 1.17.2;
`existent', not `existant'
 1.16 08-Jun-2001  matt Make macppc compile by default with -Wall -Wmissing-prototype in addition
to its currently enabled warnings. For the lack of a better place, most
global function prototype wound up in <machine/autoconf.h> unless there
was a better place for them. ofb_* structs renamed to offb_* to avoid
conflict with ofb_softc in <dev/ofw/openfirm.h>
 1.15 07-Jun-2000  tsubai branches: 1.15.4;
* Access hardware directly in zscn* instead of calling OF.
* Clean up.
 1.14 06-Mar-2000  thorpej branches: 1.14.2;
- Implement cnbell() -- ring the console bell. The cn_bell entrypoint
is optional.
- Add cn_bell to statically allocated consdevs as appropriate.
 1.13 27-Feb-2000  tsubai Don't use hardcoded speed value when this is a console. Instead, read
from zs. (because OF-3.x uses 57600 bps)
 1.12 23-Mar-1999  wrstuden branches: 1.12.8;
Oops. macppc doesn't use PCLK as a baud rate source.
 1.11 11-Feb-1999  mycroft Minor cleanup.
Make the initializer for BAUDLO depend on PCLK directly; it was incorrect on
some ports where PCLK is not 4.9152MHz.
XXX Is the default value actually used?
 1.10 03-Feb-1999  mycroft Don't set DCD_IE in the frontends. KGDB doesn't even use DCD, and the tty
frontends get it from zsparam() anyway.
 1.9 29-Dec-1998  tsubai Fix a bug of last change.
 1.8 28-Dec-1998  tsubai Use "interrupt" property if "AAPL,interrupt" is not found.
 1.7 09-Sep-1998  wrstuden Turn on support for 115,200 and 230,400 baud. Should work, but might
generate lots of interupts (one per char or so) if we don't have
DMA set up.
 1.6 26-Aug-1998  tsubai Back out previous change.
 1.5 16-Aug-1998  tsubai Enable 115200 and (untested)230400 bps.
 1.4 13-Jul-1998  tsubai Add support for G3 Mac.
 1.3 04-Jul-1998  jonathan defopt DDB.
 1.2 02-Jul-1998  tsubai Console support.
 1.1 15-May-1998  tsubai Initial import of macppc port.
 1.12.8.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.14.2.1 22-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.15.4.1 21-Jun-2001  nathanw Catch up to -current.
 1.17.2.4 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.17.2.3 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.17.2.2 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.17.2.1 03-Aug-2001  lukem update to -current
 1.18.6.7 03-Jan-2003  thorpej Sync with HEAD.
 1.18.6.6 18-Oct-2002  nathanw Catch up to -current.
 1.18.6.5 17-Sep-2002  nathanw Catch up to -current.
 1.18.6.4 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.18.6.3 28-Feb-2002  nathanw Catch up to -current.
 1.18.6.2 11-Jan-2002  nathanw More catchup.
 1.18.6.1 22-Jul-2001  nathanw file zs.c was added on branch nathanw_sa on 2002-01-11 23:38:36 +0000
 1.20.4.1 19-May-2002  gehenna Replace the access to devsw table and the hard-coded majors with devsw API.
 1.26.2.6 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.26.2.5 04-Feb-2005  skrll Sync with HEAD.
 1.26.2.4 17-Jan-2005  skrll Sync with HEAD.
 1.26.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.26.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.26.2.1 03-Aug-2004  skrll Sync with HEAD
 1.31.2.1 29-Apr-2005  kent sync with -current
 1.33.2.6 07-Dec-2007  yamt sync with head
 1.33.2.5 15-Nov-2007  yamt sync with head.
 1.33.2.4 27-Oct-2007  yamt sync with head.
 1.33.2.3 03-Sep-2007  yamt sync with head.
 1.33.2.2 30-Dec-2006  yamt sync with head.
 1.33.2.1 21-Jun-2006  yamt sync with head.
 1.35.8.2 03-Sep-2006  yamt sync with head.
 1.35.8.1 11-Aug-2006  yamt sync with head
 1.35.4.1 09-Sep-2006  rpaulo sync with head
 1.36.2.1 21-Aug-2006  tron Pull up following revision(s) (requested by macallan in ticket #31):
sys/arch/macppc/dev/zs.c: revision 1.37
back out previous commit since it breaks console output when not using a
serial console
 1.37.4.1 10-Dec-2006  yamt sync with head.
 1.37.2.2 12-Jan-2007  ad Sync with head.
 1.37.2.1 18-Nov-2006  ad Sync with head.
 1.41.4.1 12-Mar-2007  rmind Sync with HEAD.
 1.42.24.3 21-Nov-2007  bouyer Sync with HEAD
 1.42.24.2 13-Nov-2007  bouyer Sync with HEAD
 1.42.24.1 25-Oct-2007  bouyer Sync with HEAD.
 1.42.22.1 18-Oct-2007  yamt sync with head.
 1.42.20.2 09-Jan-2008  matt sync with HEAD
 1.42.20.1 06-Nov-2007  matt sync with HEAD
 1.42.18.3 21-Nov-2007  joerg Sync with HEAD.
 1.42.18.2 11-Nov-2007  joerg Sync with HEAD.
 1.42.18.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.42.10.1 11-May-2007  macallan request the correct interrupt type in a couple drivers - necessary since
these days we actually do something with the type argument
 1.42.2.2 03-Dec-2007  ad Sync with HEAD.
 1.42.2.1 23-Oct-2007  ad Sync with head.
 1.43.2.2 08-Dec-2007  mjf Sync with HEAD.
 1.43.2.1 19-Nov-2007  mjf Sync with HEAD.
 1.45.14.3 17-Jan-2009  mjf Sync with HEAD.
 1.45.14.2 29-Jun-2008  mjf Sync with HEAD.
 1.45.14.1 03-Apr-2008  mjf Sync with HEAD.
 1.46.8.1 18-Jun-2008  simonb Sync with head.
 1.46.6.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.46.4.2 11-Mar-2010  yamt sync with head
 1.46.4.1 04-May-2009  yamt sync with head.
 1.46.2.1 17-Jun-2008  yamt sync with head.
 1.47.6.1 13-Dec-2008  bouyer Pull up following revision(s) (requested by tsutsui in ticket #182):
sys/arch/macppc/dev/cuda.c: revision 1.9
sys/arch/macppc/macppc/memory.c: revision 1.2
sys/arch/macppc/dev/zs.c: revision 1.48
Fix attach messages. (extra colons, misplaced newline etc.)
 1.47.4.1 19-Jan-2009  skrll Sync with HEAD.
 1.47.2.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.50.66.1 03-Apr-2021  thorpej Sync with HEAD.
 1.51.2.1 21-Mar-2021  thorpej Give config_found() the same variadic arguments treatment as
config_search(). This commit only adds the CFARG_EOL sentinel
to the existing config_found() calls. Conversion of config_found_sm_loc()
and config_found_ia() call sites will be in subsequent commits.
 1.52.8.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.15 24-Oct-2023  andvar apply similar changes between different archs/machines for zs_kgdb.c:
1) adjust zs_kgdb_init tty attachment message for kgdb_dev type change.
(one arch uses cast to int instead, but kept one approach for consistency)
2) remove unused rr0 declaration and assignment in zs_kgdb_txint()
3) adjust kgdb_dev format specifier to %llx/d if needed.
4) add const for zs_kgdb_devname declaration (macppc only).
should fix zs_kgdb.c build for all these ports.
 1.14 26-Oct-2009  cegger kill extra whitespaces
reviewed by tsutsui@
 1.13 18-Mar-2009  cegger bcopy -> memcpy
 1.12 18-Mar-2009  cegger bzero -> memset
 1.11 18-Mar-2009  cegger Ansify function definitions w/o arguments. Generated with sed.
 1.10 14-Mar-2009  dsl Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.9 14-Mar-2009  dsl Remove all the __P() from sys (excluding sys/dist)
Diff checked with grep and MK1 eyeball.
i386 and amd64 GENERIC and sys still build.
 1.8 28-Apr-2008  martin branches: 1.8.8; 1.8.14;
Remove clause 3 and 4 from TNF licenses
 1.7 17-Oct-2007  garbled branches: 1.7.16; 1.7.18; 1.7.20;
Merge the ppcoea-renovation branch to HEAD.

This branch was a major cleanup and rototill of many of the various OEA
cpu based PPC ports that focused on sharing as much code as possible
between the various ports to eliminate near-identical copies of files in
every tree. Additionally there is a new PIC system that unifies the
interface to interrupt code for all different OEA ppc arches. The work
for this branch was done by a variety of people, too long to list here.

TODO:
bebox still needs work to complete the transition to -renovation.
ofppc still needs a bunch of work, which I will be looking at.
ev64260 still needs to be renovated
amigappc was not attempted.

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.6 23-Jun-2007  hauke branches: 1.6.10;
Fix a warning from gcc 4 about stripping the volatile qualifier by a cast
by doing the proper __UNVOLATILE() dance.
 1.5 04-Mar-2007  christos branches: 1.5.2; 1.5.4; 1.5.10;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.4 11-Dec-2005  christos branches: 1.4.26;
merge ktrace-lwp.
 1.3 15-Jul-2003  lukem branches: 1.3.16;
__KERNEL_RCSID()
 1.2 06-Sep-2002  gehenna branches: 1.2.6;
Merge the gehenna-devsw branch into the trunk.

This merge changes the device switch tables from static array to
dynamically generated by config(8).

- All device switches is defined as a constant structure in device drivers.

- The new grammer ``device-major'' is introduced to ``files''.

device-major <prefix> char <num> [block <num>] [<rules>]

- All device major numbers must be listed up in port dependent majors.<arch>
by using this grammer.

- Added the new naming convention.
The name of the device switch must be <prefix>_[bc]devsw for auto-generation
of device switch tables.

- The backward compatibility of loading block/character device
switch by LKM framework is broken. This is necessary to convert
from block/character device major to device name in runtime and vice versa.

- The restriction to assign device major by LKM is completely removed.
We don't need to reserve LKM entries for dynamic loading of device switch.

- In compile time, device major numbers list is packed into the kernel and
the LKM framework will refer it to assign device major number dynamically.
 1.1 06-Jan-2002  dbj branches: 1.1.2; 1.1.4; 1.1.12;
add support for kgdb over zs
 1.1.12.1 19-May-2002  gehenna Replace the access to devsw table and the hard-coded majors with devsw API.
 1.1.4.3 17-Sep-2002  nathanw Catch up to -current.
 1.1.4.2 11-Jan-2002  nathanw More catchup.
 1.1.4.1 06-Jan-2002  nathanw file zs_kgdb.c was added on branch nathanw_sa on 2002-01-11 23:38:36 +0000
 1.1.2.3 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.1.2.2 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.1.2.1 06-Jan-2002  thorpej file zs_kgdb.c was added on branch kqueue on 2002-01-10 19:45:49 +0000
 1.2.6.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.2.6.2 18-Sep-2004  skrll Sync with HEAD.
 1.2.6.1 03-Aug-2004  skrll Sync with HEAD
 1.3.16.1 03-Sep-2007  yamt sync with head.
 1.4.26.1 12-Mar-2007  rmind Sync with HEAD.
 1.5.10.2 02-Aug-2007  macallan sync with HEAD
 1.5.10.1 26-Jun-2007  garbled Sync with HEAD.
 1.5.4.1 11-Jul-2007  mjf Sync with head.
 1.5.2.1 15-Jul-2007  ad Sync with head.
 1.6.10.1 06-Nov-2007  matt sync with HEAD
 1.7.20.3 11-Mar-2010  yamt sync with head
 1.7.20.2 04-May-2009  yamt sync with head.
 1.7.20.1 16-May-2008  yamt sync with head.
 1.7.18.1 18-May-2008  yamt sync with head.
 1.7.16.1 02-Jun-2008  mjf Sync with HEAD.
 1.8.14.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.8.8.1 28-Apr-2009  skrll Sync with HEAD.

RSS XML Feed