Home | History | Annotate | only in /src/sys/arch/sparc64/dev
History log of /src/sys/arch/sparc64/dev
RevisionDateAuthorComments
 1.2 05-Sep-1998  pk Remove unused files.
 1.1 20-Jun-1998  eeh branches: 1.1.1;
Initial revision
 1.1.1.1 20-Jun-1998  eeh Import of sparc64.
 1.2 05-Sep-1998  pk Remove unused files.
 1.1 20-Jun-1998  eeh branches: 1.1.1;
Initial revision
 1.1.1.1 20-Jun-1998  eeh Import of sparc64.
 1.27 20-Dec-2023  thorpej Remove unnecessary <sys/malloc.h>.
 1.26 14-Oct-2016  mlelstv the mutex is also used for fdc attachment, so initialize it also
for a kernel without BLINK option.
 1.25 06-Oct-2015  martin branches: 1.25.2;
Split auxio at ebus and auxio at sbus properly, so we can build kernels
without sbus support.
 1.24 24-Aug-2015  mrg convert auxio(4) to use a mutex for exclusion (this existing code didn't
really work for MP systems, anyway -- it only went to splhigh.)

various cleanups:
- remove unused AUXIO_SBUS
- make most functions static
- introduce auxio_{read,write}_led() frontends
- avoid a potential NULL deref in auxio_fd_control()

the text is 32 bytes smaller.
 1.23 11-Jul-2015  kamil Improve spelling: regsiter -> register

This change is non-functional.

Approved by <riastradh>, <pgoyette>
 1.22 02-Jun-2011  christos branches: 1.22.12; 1.22.30;
split auxio, ebus, psycho, sab.
 1.21 12-Mar-2011  nakayama branches: 1.21.2;
Remove implicit include <dev/sbus/sbusvar.h> from autoconf.h, and
add it explicitly in files depending on it.
 1.20 13-Jun-2008  cegger branches: 1.20.18; 1.20.24;
use device_lookup_private to get softc
 1.19 29-May-2008  mrg branches: 1.19.2;
remove clause #3 from my license where there are no other
copyright holders involved.
 1.18 17-Oct-2007  garbled branches: 1.18.16; 1.18.18; 1.18.20; 1.18.22;
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.17 09-Jul-2007  ad branches: 1.17.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.16 06-Oct-2006  jnemeth branches: 1.16.8; 1.16.10; 1.16.16;
Initial support for floppy drives on sparc64. This has been tested
on an Ultra 2 and works fine, apart from formatting which is known
to be broken. It failed to work on an ebus machine. The ebus
support compiles fine, but I don't have hardware for testing. This
code is based on the sparc driver with hints from OpenBSD on how
to do the sbus and ebus attachments, along with help from martin@
and mrg@.

Initial commit approved by martin@

TODO:
- fix ebus support
- fix XXX issues
- check resource deallocation
- fix formatting
- merge remaining differences from sparc driver
- split out back end chip support
- have sparc driver use new common back end chip support
- adapt to newlock when branch is ready
- adapt to "disk-info" property dictionary
 1.15 13-Feb-2006  cdi branches: 1.15.14; 1.15.16;
ANSIfy: u_intN_t -> uintN_t, remove __P(), fix function definitions.
 1.14 11-Dec-2005  christos branches: 1.14.2; 1.14.4; 1.14.6;
merge ktrace-lwp.
 1.13 14-Oct-2004  bouyer branches: 1.13.12;
In auxio_blink(), only toggle the AUXIO_LED_LED bit, don't clear the others.
It looks like bit 3 control the on-board le's link test, clearing it breaks
the interface (no link detected on the remote end). bit 3 is defined as
AUXIO4M_LTE (link-test enable) for sun4m systems (maybe all the AUXIO4M_*
bits are valid on the Ultra/1 too ?).
Tested on Ultra/1 and Ultra/5, approved by Martin Husemann and Matthew Green.
Should fix port-sparc64/25039 by Lubomir Sedlacik.
 1.12 29-Sep-2004  mrg allow the LED blinker to be disabled via do_blink.
 1.11 15-Jul-2003  lukem branches: 1.11.4;
__KERNEL_RCSID()
 1.10 16-Jun-2003  heas branches: 1.10.2;
Define option BLINK in option file opt_auxio.h and include it in auxio.c.
approved by martin@
 1.9 02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.8 01-Oct-2002  thorpej Use CFATTACH_DECL().
 1.7 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.6 21-Mar-2002  eeh Add missing brace.
 1.5 20-Mar-2002  eeh Overhaul bus space.

bus_space_handle_t now holds an address and two ASIs, one for normal accesses
and one for streaming accesses. This allows to map individual handles
different ways, so some can use MMU bypass accesses and others use virtual
addresses. bus_space_map() will now create handles that use bypass accesses
unles BUS_SPACE_MAP_LINEAR is passed in. So only pass in BUS_SPACE_MAP_LINEAR
if you absolutely *need* to use bus_space_vaddr(). This removes at least one
extra level of indirection and should reduce TLB misses.

32-bit kernels have problems accessing 64-bit addresses, so they always use
virtual addresses.
 1.4 16-Mar-2002  mrg convert to using <dev/ebus/ebusvar.h> and it's struct member names.
 1.3 23-Oct-2001  pooka branches: 1.3.4;
declare variable used only with BLINK inside #ifdef BLINK to avoid
unused variable warning
 1.2 22-Oct-2001  mrg implement `options BLINK' for sparc64 for ebus & sbus. tested on a U2
(sbus) and a U5 (ebus).
 1.1 15-Apr-2000  mrg branches: 1.1.6; 1.1.10;
- auxio cleanup and sbus support.
- make GENERIC64 include GENERIC and set the 3 optoins it needs. suggested
by hubert feyrer.
- add a comment that we maybe should use the `bpp' driver, not the lpt, on
the ebus because the `bpp' driver does DMA already.
- ebus_attach_args got a member renamed
 1.1.10.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.10.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.1.10.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.1.6.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.1.6.1 15-Apr-2000  bouyer file auxio.c was added on branch thorpej_scsipi on 2000-11-20 20:26:41 +0000
 1.3.4.3 18-Oct-2002  nathanw Catch up to -current.
 1.3.4.2 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.3.4.1 23-Oct-2001  nathanw file auxio.c was added on branch nathanw_sa on 2002-04-01 07:42:59 +0000
 1.10.2.4 19-Oct-2004  skrll Sync with HEAD
 1.10.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.10.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.10.2.1 03-Aug-2004  skrll Sync with HEAD
 1.11.4.1 16-Jan-2005  he Pull up revision 1.13 (requested by bouyer in ticket #924):
In auxio_blink(), only toggle the AUXIO_LED_LED bit, don't
clear the others. It looks like bit 3 control the on-board
le's link test, clearing it breaks the interface (no link
detected on the remote end). Bit 3 is defined as AUXIO4M_LTE
(link-test enable) for sun4m systems (maybe all the AUXIO4M_*
bits are valid on the Ultra/1 too?).
Tested on Ultra/1 and Ultra/5. Fixes PR#25039.
 1.13.12.3 03-Sep-2007  yamt sync with head.
 1.13.12.2 30-Dec-2006  yamt sync with head.
 1.13.12.1 21-Jun-2006  yamt sync with head.
 1.14.6.1 22-Apr-2006  simonb Sync with head.
 1.14.4.1 09-Sep-2006  rpaulo sync with head
 1.14.2.1 18-Feb-2006  yamt sync with head.
 1.15.16.1 22-Oct-2006  yamt sync with head
 1.15.14.1 18-Nov-2006  ad Sync with head.
 1.16.16.1 03-Oct-2007  garbled Sync with HEAD
 1.16.10.1 11-Jul-2007  mjf Sync with head.
 1.16.8.1 15-Jul-2007  ad Sync with head.
 1.17.10.1 06-Nov-2007  matt sync with HEAD
 1.18.22.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.18.20.1 04-May-2009  yamt sync with head.
 1.18.18.2 17-Jun-2008  yamt sync with head.
 1.18.18.1 04-Jun-2008  yamt sync with head
 1.18.16.2 29-Jun-2008  mjf Sync with HEAD.
 1.18.16.1 02-Jun-2008  mjf Sync with HEAD.
 1.19.2.1 18-Jun-2008  simonb Sync with head.
 1.20.24.1 06-Jun-2011  jruoho Sync with HEAD.
 1.20.18.2 12-Jun-2011  rmind sync with head
 1.20.18.1 21-Apr-2011  rmind sync with head
 1.21.2.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.22.30.3 05-Dec-2016  skrll Sync with HEAD
 1.22.30.2 27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.22.30.1 22-Sep-2015  skrll Sync with HEAD
 1.22.12.1 03-Dec-2017  jdolecek update from HEAD
 1.25.2.1 04-Nov-2016  pgoyette Sync with HEAD
 1.7 20-Dec-2023  thorpej Remove unnecessary <sys/malloc.h>.
 1.6 06-Oct-2015  martin branches: 1.6.2; 1.6.18;
Split auxio at ebus and auxio at sbus properly, so we can build kernels
without sbus support.
 1.5 15-Apr-2000  mrg - auxio cleanup and sbus support.
- make GENERIC64 include GENERIC and set the 3 optoins it needs. suggested
by hubert feyrer.
- add a comment that we maybe should use the `bpp' driver, not the lpt, on
the ebus because the `bpp' driver does DMA already.
- ebus_attach_args got a member renamed
 1.4 13-Apr-2000  mrg store all the physical address bits.
 1.3 08-Apr-2000  mrg actually, i wrote these in 2000
 1.2 05-Apr-2000  mrg correct a message
 1.1 05-Apr-2000  mrg driver for the PCI/ebus AUXIO registers.
 1.6.18.2 03-Dec-2017  jdolecek update from HEAD
 1.6.18.1 06-Oct-2015  jdolecek file auxio_ebus.c was added on branch tls-maxphys on 2017-12-03 11:36:44 +0000
 1.6.2.2 27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.6.2.1 06-Oct-2015  skrll file auxio_ebus.c was added on branch nick-nhusb on 2015-12-27 12:09:43 +0000
 1.2 20-Dec-2023  thorpej Remove unnecessary <sys/malloc.h>.
 1.1 06-Oct-2015  martin branches: 1.1.2; 1.1.18;
Split auxio at ebus and auxio at sbus properly, so we can build kernels
without sbus support.
 1.1.18.2 03-Dec-2017  jdolecek update from HEAD
 1.1.18.1 06-Oct-2015  jdolecek file auxio_sbus.c was added on branch tls-maxphys on 2017-12-03 11:36:44 +0000
 1.1.2.2 27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.1.2.1 06-Oct-2015  skrll file auxio_sbus.c was added on branch nick-nhusb on 2015-12-27 12:09:43 +0000
 1.8 11-Jul-2015  kamil Improve spelling: regsiter -> register

This change is non-functional.

Approved by <riastradh>, <pgoyette>
 1.7 29-May-2008  mrg branches: 1.7.42; 1.7.62;
remove clause #3 from my license where there are no other
copyright holders involved.
 1.6 27-Mar-2007  jnemeth branches: 1.6.34; 1.6.36; 1.6.38; 1.6.40;
move definition of FTC_FLIP to auxioreg.h to mirror sparc
 1.5 06-Oct-2006  jnemeth branches: 1.5.4; 1.5.8; 1.5.10; 1.5.12;
Initial support for floppy drives on sparc64. This has been tested
on an Ultra 2 and works fine, apart from formatting which is known
to be broken. It failed to work on an ebus machine. The ebus
support compiles fine, but I don't have hardware for testing. This
code is based on the sparc driver with hints from OpenBSD on how
to do the sbus and ebus attachments, along with help from martin@
and mrg@.

Initial commit approved by martin@

TODO:
- fix ebus support
- fix XXX issues
- check resource deallocation
- fix formatting
- merge remaining differences from sparc driver
- split out back end chip support
- have sparc driver use new common back end chip support
- adapt to newlock when branch is ready
- adapt to "disk-info" property dictionary
 1.4 22-Oct-2001  mrg branches: 1.4.4; 1.4.36; 1.4.66; 1.4.68;
implement `options BLINK' for sparc64 for ebus & sbus. tested on a U2
(sbus) and a U5 (ebus).
 1.3 15-Apr-2000  mrg branches: 1.3.6; 1.3.10;
- auxio cleanup and sbus support.
- make GENERIC64 include GENERIC and set the 3 optoins it needs. suggested
by hubert feyrer.
- add a comment that we maybe should use the `bpp' driver, not the lpt, on
the ebus because the `bpp' driver does DMA already.
- ebus_attach_args got a member renamed
 1.2 08-Apr-2000  mrg actually, i wrote these in 2000
 1.1 05-Apr-2000  mrg driver for the PCI/ebus AUXIO registers.
 1.3.10.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.3.6.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.6.1 15-Apr-2000  bouyer file auxioreg.h was added on branch thorpej_scsipi on 2000-11-20 20:26:41 +0000
 1.4.68.1 22-Oct-2006  yamt sync with head
 1.4.66.1 18-Nov-2006  ad Sync with head.
 1.4.36.2 03-Sep-2007  yamt sync with head.
 1.4.36.1 30-Dec-2006  yamt sync with head.
 1.4.4.2 22-Oct-2001  mrg implement `options BLINK' for sparc64 for ebus & sbus. tested on a U2
(sbus) and a U5 (ebus).
 1.4.4.1 22-Oct-2001  mrg file auxioreg.h was added on branch nathanw_sa on 2001-10-22 07:31:42 +0000
 1.5.12.1 29-Mar-2007  reinoud Pullup to -current
 1.5.10.1 11-Jul-2007  mjf Sync with head.
 1.5.8.1 10-Apr-2007  ad Sync with head.
 1.5.4.1 15-Apr-2007  yamt sync with head.
 1.6.40.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.6.38.1 04-May-2009  yamt sync with head.
 1.6.36.1 04-Jun-2008  yamt sync with head
 1.6.34.1 02-Jun-2008  mjf Sync with HEAD.
 1.7.62.1 22-Sep-2015  skrll Sync with HEAD
 1.7.42.1 03-Dec-2017  jdolecek update from HEAD
 1.8 06-Oct-2015  martin Split auxio at ebus and auxio at sbus properly, so we can build kernels
without sbus support.
 1.7 29-May-2008  mrg branches: 1.7.42; 1.7.62;
remove clause #3 from my license where there are no other
copyright holders involved.
 1.6 06-Oct-2006  jnemeth branches: 1.6.52; 1.6.54; 1.6.56; 1.6.58;
Initial support for floppy drives on sparc64. This has been tested
on an Ultra 2 and works fine, apart from formatting which is known
to be broken. It failed to work on an ebus machine. The ebus
support compiles fine, but I don't have hardware for testing. This
code is based on the sparc driver with hints from OpenBSD on how
to do the sbus and ebus attachments, along with help from martin@
and mrg@.

Initial commit approved by martin@

TODO:
- fix ebus support
- fix XXX issues
- check resource deallocation
- fix formatting
- merge remaining differences from sparc driver
- split out back end chip support
- have sparc driver use new common back end chip support
- adapt to newlock when branch is ready
- adapt to "disk-info" property dictionary
 1.5 22-Oct-2001  mrg branches: 1.5.22; 1.5.40; 1.5.42;
implement `options BLINK' for sparc64 for ebus & sbus. tested on a U2
(sbus) and a U5 (ebus).
 1.4 15-Apr-2000  mrg branches: 1.4.6; 1.4.10;
- auxio cleanup and sbus support.
- make GENERIC64 include GENERIC and set the 3 optoins it needs. suggested
by hubert feyrer.
- add a comment that we maybe should use the `bpp' driver, not the lpt, on
the ebus because the `bpp' driver does DMA already.
- ebus_attach_args got a member renamed
 1.3 13-Apr-2000  mrg store all the physical address bits.
 1.2 08-Apr-2000  mrg actually, i wrote these in 2000
 1.1 05-Apr-2000  mrg driver for the PCI/ebus AUXIO registers.
 1.4.10.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.4.6.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.4.6.1 15-Apr-2000  bouyer file auxiovar.h was added on branch thorpej_scsipi on 2000-11-20 20:26:42 +0000
 1.5.42.1 22-Oct-2006  yamt sync with head
 1.5.40.1 18-Nov-2006  ad Sync with head.
 1.5.22.1 30-Dec-2006  yamt sync with head.
 1.6.58.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.6.56.1 04-May-2009  yamt sync with head.
 1.6.54.1 04-Jun-2008  yamt sync with head
 1.6.52.1 02-Jun-2008  mjf Sync with HEAD.
 1.7.62.1 27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.7.42.1 03-Dec-2017  jdolecek update from HEAD
 1.6 23-Aug-2000  pk Brooktree DAC support now lives in sys/dev/sun.
 1.5 29-Jun-2000  mrg remove include of <vm/vm.h>. <vm/vm.h> -> <uvm/uvm_extern.h>
 1.4 24-Mar-1999  mrg branches: 1.4.8; 1.4.18;
completely remove Mach VM support. all that is left is the all the
header files as UVM still uses (most of) these.
 1.3 11-Sep-1998  eeh Don't use fuword()/suword() -- can't count on their size.
 1.2 13-Aug-1998  eeh Merge paddr_t changes into the main branch.
 1.1 20-Jun-1998  eeh branches: 1.1.1;
Initial revision
 1.1.1.1 20-Jun-1998  eeh branches: 1.1.1.1.2;
Import of sparc64.
 1.1.1.1.2.1 02-Aug-1998  eeh Cleanup work:

Sync up with sys/dev/sbus
get cgsix to work right
 1.4.18.1 04-Sep-2002  itojun pullup (itojun)

sys/arch/amiga/dev/grf_cv3d.c 1.11
sys/arch/hpcmips/dev/mq200.c 1.21
sys/arch/i386/i386/sys_machdep.c 1.64
sys/arch/luna68k/dev/lunafb.c 1.9
sys/arch/sparc/dev/bt_subr.c via patch
sys/arch/sparc64/dev/bt_subr.c via patch
sys/arch/sun3/dev/bt_subr.c via patch
sys/compat/ibcs2/ibcs2_stat.c 1.21-1.23
sys/dev/sun/bt_subr.c 1.3
sys/dev/tc/cfb.c 1.34
sys/dev/tc/sfb.c 1.53
sys/dev/tc/xcfb.c 1.29
integer overflow. reported by silvio@qualys.com
 1.4.8.1 20-Nov-2000  bouyer Remove files that are no longer on the trunck
 1.2 23-Aug-2000  pk Brooktree DAC support now lives in sys/dev/sun.
 1.1 20-Jun-1998  eeh branches: 1.1.1;
Initial revision
 1.1.1.1 20-Jun-1998  eeh branches: 1.1.1.1.14;
Import of sparc64.
 1.1.1.1.14.1 20-Nov-2000  bouyer Remove files that are no longer on the trunck
 1.2 23-Aug-2000  pk Brooktree DAC support now lives in sys/dev/sun.
 1.1 20-Jun-1998  eeh branches: 1.1.1;
Initial revision
 1.1.1.1 20-Jun-1998  eeh branches: 1.1.1.1.14;
Import of sparc64.
 1.1.1.1.14.1 20-Nov-2000  bouyer Remove files that are no longer on the trunck
 1.11 23-Aug-2000  pk These drivers are now in sys/dev/sun
 1.10 29-Jun-2000  mrg remove include of <vm/vm.h>. <vm/vm.h> -> <uvm/uvm_extern.h>
 1.9 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.8 07-Jun-1999  eeh branches: 1.8.2; 1.8.12;
Another general cleanup:

Remove the entire idea of fasttrap interrupts since V9 traps are really cheap,
the CPUs are really fast, and the completely different trap frames would make
these handlers really difficult to implement.

pmap_changeprot() was only used by the clock and one other place; deprecate it.

probeget() and probeset() now take 64-bit addresses even in 32-bit mode so we
can probe IO locations by physical addresses.

Some pmap cleanup.

Some more copyright cleanup.
 1.7 05-Jun-1999  mrg catch up with probe[gs]et() changes.
 1.6 23-May-1999  eeh Start putting in hooks for non-zs console devices.
 1.5 05-Sep-1998  eeh branches: 1.5.8;
It slices. It dices. It does everything except exec a sparc32_compat init.
 1.4 05-Sep-1998  pk #include <dev/sbus/sbusvar.h>
 1.3 26-Aug-1998  mrg fix missed sparc -> sparc64
 1.2 13-Aug-1998  eeh Merge paddr_t changes into the main branch.
 1.1 20-Jun-1998  eeh branches: 1.1.1;
Initial revision
 1.1.1.1 20-Jun-1998  eeh branches: 1.1.1.1.2;
Import of sparc64.
 1.1.1.1.2.2 08-Aug-1998  eeh Revert cdevsw mmap routines to return int.
 1.1.1.1.2.1 02-Aug-1998  eeh Cleanup work:

Sync up with sys/dev/sbus
get cgsix to work right
 1.5.8.1 21-Jun-1999  thorpej Sync w/ -current.
 1.8.12.1 30-Jun-2000  simonb Pull up mmap paddr_t/off_t changes from trunk.
 1.8.2.1 20-Nov-2000  bouyer Remove files that are no longer on the trunck
 1.2 23-Aug-2000  pk These drivers are now in sys/dev/sun
 1.1 20-Jun-1998  eeh branches: 1.1.1;
Initial revision
 1.1.1.1 20-Jun-1998  eeh branches: 1.1.1.1.14;
Import of sparc64.
 1.1.1.1.14.1 20-Nov-2000  bouyer Remove files that are no longer on the trunck
 1.8 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.7 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.6 10-May-2021  thorpej branches: 1.6.4;
Associate the OpenBoot / OpenFirmware node with attached devices
at config_found() time.
 1.5 24-Apr-2021  thorpej branches: 1.5.2; 1.5.4;
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 04-Jan-2021  thorpej branches: 1.4.2;
malloc(9) -> kmem(9) -- just the simple, straightforward conversions for now.
 1.3 10-Nov-2019  chs branches: 1.3.8;
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.2 18-Jul-2016  palle branches: 1.2.14; 1.2.18;
sun4v: reset cbus debug back to zero
 1.1 22-Jun-2016  palle branches: 1.1.2; 1.1.4;
sun4v: add cbus driver - from OpenBSD
 1.1.4.1 26-Jul-2016  pgoyette Sync with HEAD
 1.1.2.3 05-Oct-2016  skrll Sync with HEAD
 1.1.2.2 09-Jul-2016  skrll Sync with HEAD
 1.1.2.1 22-Jun-2016  skrll file cbus.c was added on branch nick-nhusb on 2016-07-09 20:24:57 +0000
 1.2.18.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.2.14.2 03-Dec-2017  jdolecek update from HEAD
 1.2.14.1 18-Jul-2016  jdolecek file cbus.c was added on branch tls-maxphys on 2017-12-03 11:36:44 +0000
 1.3.8.1 03-Apr-2021  thorpej Sync with HEAD.
 1.4.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.5.4.1 31-May-2021  cjep sync with head
 1.5.2.1 13-May-2021  thorpej Sync with HEAD.
 1.6.4.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.1 22-Jun-2016  palle branches: 1.1.2; 1.1.18;
sun4v: add cbus driver - from OpenBSD
 1.1.18.2 03-Dec-2017  jdolecek update from HEAD
 1.1.18.1 22-Jun-2016  jdolecek file cbusvar.h was added on branch tls-maxphys on 2017-12-03 11:36:44 +0000
 1.1.2.2 09-Jul-2016  skrll Sync with HEAD
 1.1.2.1 22-Jun-2016  skrll file cbusvar.h was added on branch nick-nhusb on 2016-07-09 20:24:57 +0000
 1.9 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.8 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.7 10-May-2021  thorpej branches: 1.7.4;
Associate the OpenBoot / OpenFirmware node with attached devices
at config_found() time.
 1.6 24-Apr-2021  thorpej branches: 1.6.2; 1.6.4;
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 04-Jan-2021  thorpej branches: 1.5.2;
malloc(9) -> kmem(9) -- just the simple, straightforward conversions for now.
 1.4 10-Nov-2019  chs branches: 1.4.8;
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.3 18-Mar-2012  mrg branches: 1.3.40;
add missing __KERNEL_RCSID().
 1.2 01-Aug-2011  mrg branches: 1.2.2; 1.2.6;
use device_private(). thanks to jmcneill for pointing this out.
 1.1 29-Jul-2011  mrg port the openbsd central and fhc drivers, and the clock/zs attachments.
doesn't quite work yet, crashes when central_attach() calls
config_attach() (faulting address is 0xf8000000.)
 1.2.6.1 05-Apr-2012  mrg sync to latest -current.
 1.2.2.1 17-Apr-2012  yamt sync with head
 1.3.40.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.4.8.1 03-Apr-2021  thorpej Sync with HEAD.
 1.5.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.6.4.1 31-May-2021  cjep sync with head
 1.6.2.1 13-May-2021  thorpej Sync with HEAD.
 1.7.4.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.1 29-Jul-2011  mrg port the openbsd central and fhc drivers, and the clock/zs attachments.
doesn't quite work yet, crashes when central_attach() calls
config_attach() (faulting address is 0xf8000000.)
 1.7 22-Aug-2000  pk These devices will never be found on sun4u machines.
 1.6 29-Jun-2000  mrg remove include of <vm/vm.h>. <vm/vm.h> -> <uvm/uvm_extern.h>
 1.5 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.4 05-Jun-1999  eeh branches: 1.4.2; 1.4.12;
Make pbrobeget() and probeset() work for 64-bit values as well. To do this
the arguments are changed so the address is first and the ASI second so we
can have the address in %o0:%o1 and not worry about unused registers.

Also a bit of copyright cleanup.
 1.3 19-Nov-1998  mrg branches: 1.3.6;
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.2 13-Aug-1998  eeh Merge paddr_t changes into the main branch.
 1.1 20-Jun-1998  eeh branches: 1.1.1;
Initial revision
 1.1.1.1 20-Jun-1998  eeh branches: 1.1.1.1.2;
Import of sparc64.
 1.1.1.1.2.2 08-Aug-1998  eeh Revert cdevsw mmap routines to return int.
 1.1.1.1.2.1 02-Aug-1998  eeh Cleanup work:

Sync up with sys/dev/sbus
get cgsix to work right
 1.3.6.1 21-Jun-1999  thorpej Sync w/ -current.
 1.4.12.1 30-Jun-2000  simonb Pull up mmap paddr_t/off_t changes from trunk.
 1.4.2.1 20-Nov-2000  bouyer Remove files that are no longer on the trunck
 1.8 22-Aug-2000  pk These devices will never be found on sun4u machines.
 1.7 29-Jun-2000  mrg remove include of <vm/vm.h>. <vm/vm.h> -> <uvm/uvm_extern.h>
 1.6 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.5 05-Jun-1999  eeh branches: 1.5.2; 1.5.12;
Make pbrobeget() and probeset() work for 64-bit values as well. To do this
the arguments are changed so the address is first and the ASI second so we
can have the address in %o0:%o1 and not worry about unused registers.

Also a bit of copyright cleanup.
 1.4 05-Jun-1999  mrg catch up with probe[gs]et() changes.
 1.3 19-Nov-1998  mrg branches: 1.3.6;
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.2 13-Aug-1998  eeh Merge paddr_t changes into the main branch.
 1.1 20-Jun-1998  eeh branches: 1.1.1;
Initial revision
 1.1.1.1 20-Jun-1998  eeh branches: 1.1.1.1.2;
Import of sparc64.
 1.1.1.1.2.2 08-Aug-1998  eeh Revert cdevsw mmap routines to return int.
 1.1.1.1.2.1 02-Aug-1998  eeh Cleanup work:

Sync up with sys/dev/sbus
get cgsix to work right
 1.3.6.1 21-Jun-1999  thorpej Sync w/ -current.
 1.5.12.1 30-Jun-2000  simonb Pull up mmap paddr_t/off_t changes from trunk.
 1.5.2.1 20-Nov-2000  bouyer Remove files that are no longer on the trunck
 1.7 22-Aug-2000  pk These devices will never be found on sun4u machines.
 1.6 29-Jun-2000  mrg remove include of <vm/vm.h>. <vm/vm.h> -> <uvm/uvm_extern.h>
 1.5 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.4 23-May-1999  eeh branches: 1.4.2; 1.4.12;
Start putting in hooks for non-zs console devices.
 1.3 19-Nov-1998  mrg branches: 1.3.6;
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.2 13-Aug-1998  eeh Merge paddr_t changes into the main branch.
 1.1 20-Jun-1998  eeh branches: 1.1.1;
Initial revision
 1.1.1.1 20-Jun-1998  eeh branches: 1.1.1.1.2;
Import of sparc64.
 1.1.1.1.2.2 08-Aug-1998  eeh Revert cdevsw mmap routines to return int.
 1.1.1.1.2.1 02-Aug-1998  eeh Cleanup work:

Sync up with sys/dev/sbus
get cgsix to work right
 1.3.6.1 21-Jun-1999  thorpej Sync w/ -current.
 1.4.12.1 30-Jun-2000  simonb Pull up mmap paddr_t/off_t changes from trunk.
 1.4.2.1 20-Nov-2000  bouyer Remove files that are no longer on the trunck
 1.2 22-Aug-2000  pk These devices will never be found on sun4u machines.
 1.1 20-Jun-1998  eeh branches: 1.1.1;
Initial revision
 1.1.1.1 20-Jun-1998  eeh branches: 1.1.1.1.14;
Import of sparc64.
 1.1.1.1.14.1 20-Nov-2000  bouyer Remove files that are no longer on the trunck
 1.2 22-Aug-2000  pk These devices will never be found on sun4u machines.
 1.1 20-Jun-1998  eeh branches: 1.1.1;
Initial revision
 1.1.1.1 20-Jun-1998  eeh branches: 1.1.1.1.14;
Import of sparc64.
 1.1.1.1.14.1 20-Nov-2000  bouyer Remove files that are no longer on the trunck
 1.8 23-Jul-2001  eeh Get rid of a bunch of obsolete files.
 1.7 26-Aug-2000  eeh branches: 1.7.4;
Make 64-bit clean.
 1.6 29-Jun-2000  mrg remove include of <vm/vm.h>. <vm/vm.h> -> <uvm/uvm_extern.h>
 1.5 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.4 24-Mar-1999  mrg branches: 1.4.8; 1.4.18;
completely remove Mach VM support. all that is left is the all the
header files as UVM still uses (most of) these.
 1.3 05-Sep-1998  pk #include <dev/sbus/sbusvar.h>
 1.2 13-Aug-1998  eeh Merge paddr_t changes into the main branch.
 1.1 20-Jun-1998  eeh branches: 1.1.1;
Initial revision
 1.1.1.1 20-Jun-1998  eeh branches: 1.1.1.1.2;
Import of sparc64.
 1.1.1.1.2.3 08-Aug-1998  eeh Revert cdevsw mmap routines to return int.
 1.1.1.1.2.2 02-Aug-1998  eeh Cleanup work:

Sync up with sys/dev/sbus
get cgsix to work right
 1.1.1.1.2.1 30-Jul-1998  eeh Split vm_offset_t and vm_size_t into paddr_t, psize_t, vaddr_t, and vsize_t.
 1.4.18.2 09-Sep-2000  eeh Pullup of 1.2 and 1.7 (approved by thorpej):

revision 1.7
date: 2000/08/26 16:02:06; author: eeh; state: Exp; lines: +5 -5
Make 64-bit clean.

revision 1.2
date: 2000/08/26 16:02:06; author: eeh; state: Exp; lines: +2 -2
Make 64-bit clean.
 1.4.18.1 30-Jun-2000  simonb Pull up mmap paddr_t/off_t changes from trunk.
 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.4.1 03-Aug-2001  lukem update to -current
 1.5 23-Jul-2001  eeh Get rid of a bunch of obsolete files.
 1.4 29-Jun-2000  mrg branches: 1.4.4;
remove include of <vm/vm.h>. <vm/vm.h> -> <uvm/uvm_extern.h>
 1.3 25-Mar-1999  mrg branches: 1.3.8;
remove opt_uvm.h
 1.2 05-Sep-1998  pk #include <dev/sbus/sbusvar.h>
 1.1 20-Jun-1998  eeh branches: 1.1.1;
Initial revision
 1.1.1.1 20-Jun-1998  eeh Import of sparc64.
 1.3.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.4.4.1 03-Aug-2001  lukem update to -current
 1.7 23-Jul-2001  eeh Get rid of a bunch of obsolete files.
 1.6 29-Jun-2000  mrg branches: 1.6.4;
remove include of <vm/vm.h>. <vm/vm.h> -> <uvm/uvm_extern.h>
 1.5 14-Apr-2000  mrg add some casts to (u_long) to shut up gcc. cleanup unused variables
 1.4 23-May-1999  eeh branches: 1.4.2;
Start putting in hooks for non-zs console devices.
 1.3 05-Sep-1998  pk branches: 1.3.8;
#include <dev/sbus/sbusvar.h>
 1.2 02-Sep-1998  eeh Periodic update: now starts probing devices.
 1.1 20-Jun-1998  eeh branches: 1.1.1;
Initial revision
 1.1.1.1 20-Jun-1998  eeh Import of sparc64.
 1.3.8.1 21-Jun-1999  thorpej Sync w/ -current.
 1.4.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.6.4.1 03-Aug-2001  lukem update to -current
 1.3 23-Jul-2001  eeh Get rid of a bunch of obsolete files.
 1.2 26-Aug-2000  eeh branches: 1.2.4;
Make 64-bit clean.
 1.1 20-Jun-1998  eeh branches: 1.1.1;
Initial revision
 1.1.1.1 20-Jun-1998  eeh branches: 1.1.1.1.14; 1.1.1.1.24;
Import of sparc64.
 1.1.1.1.24.1 09-Sep-2000  eeh Pullup of 1.2 and 1.7 (approved by thorpej):

revision 1.7
date: 2000/08/26 16:02:06; author: eeh; state: Exp; lines: +5 -5
Make 64-bit clean.

revision 1.2
date: 2000/08/26 16:02:06; author: eeh; state: Exp; lines: +2 -2
Make 64-bit clean.
 1.1.1.1.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.2.4.1 03-Aug-2001  lukem update to -current
 1.2 23-Jul-2001  eeh Get rid of a bunch of obsolete files.
 1.1 20-Jun-1998  eeh branches: 1.1.1;
Initial revision
 1.1.1.1 20-Jun-1998  eeh branches: 1.1.1.1.28;
Import of sparc64.
 1.1.1.1.28.1 03-Aug-2001  lukem update to -current
 1.10 23-Aug-2000  pk These drivers are now in sys/dev/sun
 1.9 29-Jun-2000  mrg remove include of <vm/vm.h>. <vm/vm.h> -> <uvm/uvm_extern.h>
 1.8 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.7 05-Jun-1999  eeh branches: 1.7.2; 1.7.12;
Make pbrobeget() and probeset() work for 64-bit values as well. To do this
the arguments are changed so the address is first and the ASI second so we
can have the address in %o0:%o1 and not worry about unused registers.

Also a bit of copyright cleanup.
 1.6 05-Jun-1999  mrg catch up with probe[gs]et() changes.
 1.5 23-May-1999  eeh Start putting in hooks for non-zs console devices.
 1.4 19-Nov-1998  mrg branches: 1.4.6;
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 05-Sep-1998  pk #include <dev/sbus/sbusvar.h>
 1.2 13-Aug-1998  eeh Merge paddr_t changes into the main branch.
 1.1 20-Jun-1998  eeh branches: 1.1.1;
Initial revision
 1.1.1.1 20-Jun-1998  eeh branches: 1.1.1.1.2;
Import of sparc64.
 1.1.1.1.2.2 08-Aug-1998  eeh Revert cdevsw mmap routines to return int.
 1.1.1.1.2.1 02-Aug-1998  eeh Cleanup work:

Sync up with sys/dev/sbus
get cgsix to work right
 1.4.6.1 21-Jun-1999  thorpej Sync w/ -current.
 1.7.12.1 30-Jun-2000  simonb Pull up mmap paddr_t/off_t changes from trunk.
 1.7.2.1 20-Nov-2000  bouyer Remove files that are no longer on the trunck
 1.2 23-Aug-2000  pk These drivers are now in sys/dev/sun
 1.1 20-Jun-1998  eeh branches: 1.1.1;
Initial revision
 1.1.1.1 20-Jun-1998  eeh branches: 1.1.1.1.14;
Import of sparc64.
 1.1.1.1.14.1 20-Nov-2000  bouyer Remove files that are no longer on the trunck
 1.7 22-Aug-2000  pk These devices will never be found on sun4u machines.
 1.6 29-Jun-2000  mrg remove include of <vm/vm.h>. <vm/vm.h> -> <uvm/uvm_extern.h>
 1.5 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.4 05-Jun-1999  eeh branches: 1.4.2; 1.4.12;
Make pbrobeget() and probeset() work for 64-bit values as well. To do this
the arguments are changed so the address is first and the ASI second so we
can have the address in %o0:%o1 and not worry about unused registers.

Also a bit of copyright cleanup.
 1.3 05-Jun-1999  mrg catch up with probe[gs]et() changes.
 1.2 13-Aug-1998  eeh branches: 1.2.8;
Merge paddr_t changes into the main branch.
 1.1 20-Jun-1998  eeh branches: 1.1.1;
Initial revision
 1.1.1.1 20-Jun-1998  eeh branches: 1.1.1.1.2;
Import of sparc64.
 1.1.1.1.2.2 08-Aug-1998  eeh Revert cdevsw mmap routines to return int.
 1.1.1.1.2.1 02-Aug-1998  eeh Cleanup work:

Sync up with sys/dev/sbus
get cgsix to work right
 1.2.8.1 21-Jun-1999  thorpej Sync w/ -current.
 1.4.12.1 30-Jun-2000  simonb Pull up mmap paddr_t/off_t changes from trunk.
 1.4.2.1 20-Nov-2000  bouyer Remove files that are no longer on the trunck
 1.36 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.35 24-Apr-2021  thorpej branches: 1.35.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.34 08-Dec-2018  thorpej branches: 1.34.14;
Clean up initialization of com_regs structure, in preparation for
some additional changers.
 1.33 01-Jul-2011  dyoung branches: 1.33.52; 1.33.54;
#include <sys/bus.h> instead of <machine/bus.h>.
 1.32 02-Jun-2011  mrg also look for "FJSV,su" as found on PRIMEPOWER machines.
while here, copy some code from openbsd that should allow this to work
on the Fujitsu SPARC Enterprise Mx000 systems.
 1.31 15-Mar-2011  mrg branches: 1.31.2;
also attach for su16552 compatible devices.
 1.30 03-Jan-2010  jdc branches: 1.30.4; 1.30.6;
Match "rsc-console" and set its baud rate to 115200.
Makes the 501-5856 (RSC2) card usuable as console on a Fire 280R.
 1.29 14-Nov-2009  nakayama comcons in dev/ic/com.c is now declared as static, so don't peek it
directly but use it via cn_tab.

Tested on my Netra X1.
 1.28 29-May-2008  mrg remove clause #3 from my license where there are no other
copyright holders involved.
 1.27 14-Mar-2008  cube branches: 1.27.2; 1.27.4; 1.27.6;
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.26 13-Jul-2006  gdamore branches: 1.26.34; 1.26.54; 1.26.58;
Add an option COM_REGMAP to allow com(4) to use an array of register indices.
This allows us to convert aucom to just another com attachment, and cleanup
some code in the com_arbus.c.

Additionally, we use a common com_cleanup routine rather than having a
zillion copies of it in the attachment points.

This has been tested on a number architectures, and it has been shown to get
close to comparable performance when COM_REGMAP is defined, and comparable
when it is not defined.

Approved by core@. Fixes PR port-evbmips/32362.
 1.25 28-Mar-2006  thorpej branches: 1.25.4;
Use device_unit().
 1.24 11-Feb-2006  cdi branches: 1.24.2; 1.24.4; 1.24.6;
ANSIfication: u_intN_t -> uintN_t, use ANSI function declarations/definitions
instead of K&R ones.
 1.23 11-Dec-2005  christos branches: 1.23.2; 1.23.4; 1.23.6;
merge ktrace-lwp.
 1.22 31-May-2005  christos branches: 1.22.2;
- sprinkle const
- avoid variable shadow
 1.21 21-Mar-2004  pk Use the promlib I/O routines.
 1.20 15-Jul-2003  lukem __KERNEL_RCSID()
 1.19 14-Jun-2003  thorpej branches: 1.19.2;
Also pass a type argument to comcnattach() and com_kgdb_attach().
comspeed() (and thus cominit()) may need this information.
 1.18 10-Dec-2002  pk Remove the `flags' argument from bus_intr_establish().
 1.17 02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.16 01-Oct-2002  thorpej Use CFATTACH_DECL().
 1.15 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.14 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.13 18-Jul-2002  wiz Spell 'should' correctly.
 1.12 20-Mar-2002  eeh branches: 1.12.4;
Overhaul bus space.

bus_space_handle_t now holds an address and two ASIs, one for normal accesses
and one for streaming accesses. This allows to map individual handles
different ways, so some can use MMU bypass accesses and others use virtual
addresses. bus_space_map() will now create handles that use bypass accesses
unles BUS_SPACE_MAP_LINEAR is passed in. So only pass in BUS_SPACE_MAP_LINEAR
if you absolutely *need* to use bus_space_vaddr(). This removes at least one
extra level of indirection and should reduce TLB misses.

32-bit kernels have problems accessing 64-bit addresses, so they always use
virtual addresses.
 1.11 16-Mar-2002  mrg convert to using <dev/ebus/ebusvar.h> and it's struct member names.
 1.10 15-Mar-2002  eeh Get PCI working with the new bus_space*.
 1.9 01-Mar-2002  martin Rename EBUS_PADDR_FROM_REG uses to EBUS_ADDR_FROM_REG.
 1.8 22-Oct-2001  mrg branches: 1.8.4;
use <dev/ebus/ebusreg.h>
 1.7 02-Oct-2001  eeh Handle the situation where console input and console output go to different
devices. (N.B. The com driver does not handle different instances as input
and output devices, so this only works for two different drivers.)
 1.6 24-Jul-2001  eeh branches: 1.6.2;
Use OF_getprop instead of getprop.
 1.5 19-Jul-2001  eeh Also attach apropriate devices named "serial".
 1.4 20-Dec-2000  mrg branches: 1.4.4;
com_attach_subr() prints the newline for us.
 1.3 03-Dec-2000  fvdl Make softintr_establish prototype match other ports, avoiding compile
warnings.
 1.2 08-Nov-2000  eeh branches: 1.2.2;
Remove debug printfs.
 1.1 21-Sep-2000  eeh Guts of the Sun Keyboard/Mouse line disciplines.
N.B. They don't recognize L1-A yet.
 1.2.2.5 05-Jan-2001  bouyer Sync with HEAD
 1.2.2.4 08-Dec-2000  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 08-Nov-2000  bouyer file com_ebus.c was added on branch thorpej_scsipi on 2000-11-20 20:26:42 +0000
 1.4.4.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.4.4.5 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.4.4.4 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.4.4.3 16-Mar-2002  jdolecek Catch up with -current.
 1.4.4.2 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.4.4.1 03-Aug-2001  lukem update to -current
 1.6.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.8.4.6 11-Dec-2002  thorpej Sync with HEAD.
 1.8.4.5 18-Oct-2002  nathanw Catch up to -current.
 1.8.4.4 17-Sep-2002  nathanw Catch up to -current.
 1.8.4.3 01-Aug-2002  nathanw Catch up to -current.
 1.8.4.2 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.8.4.1 22-Oct-2001  nathanw file com_ebus.c was added on branch nathanw_sa on 2002-04-01 07:43:00 +0000
 1.12.4.2 21-Jul-2002  gehenna catch up with -current.
 1.12.4.1 19-May-2002  gehenna Replace the access to devsw table and the hard-coded majors with devsw API.
 1.19.2.4 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.19.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.19.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.19.2.1 03-Aug-2004  skrll Sync with HEAD
 1.22.2.3 17-Mar-2008  yamt sync with head.
 1.22.2.2 30-Dec-2006  yamt sync with head.
 1.22.2.1 21-Jun-2006  yamt sync with head.
 1.23.6.1 22-Apr-2006  simonb Sync with head.
 1.23.4.1 09-Sep-2006  rpaulo sync with head
 1.23.2.1 18-Feb-2006  yamt sync with head.
 1.24.6.1 31-Mar-2006  tron Merge 2006-03-31 NetBSD-current into the "peter-altq" branch.
 1.24.4.1 19-Apr-2006  elad sync with head - hopefully this will work
 1.24.2.2 11-Aug-2006  yamt sync with head
 1.24.2.1 01-Apr-2006  yamt sync with head.
 1.25.4.1 15-Jun-2006  gdamore Adapt to new com framework.
 1.26.58.2 02-Jun-2008  mjf Sync with HEAD.
 1.26.58.1 03-Apr-2008  mjf Sync with HEAD.
 1.26.54.1 24-Mar-2008  keiichi sync with head.
 1.26.34.1 23-Mar-2008  matt sync with HEAD
 1.27.6.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.27.4.2 11-Mar-2010  yamt sync with head
 1.27.4.1 04-May-2009  yamt sync with head.
 1.27.2.1 04-Jun-2008  yamt sync with head
 1.30.6.1 06-Jun-2011  jruoho Sync with HEAD.
 1.30.4.2 12-Jun-2011  rmind sync with head
 1.30.4.1 21-Apr-2011  rmind sync with head
 1.31.2.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.33.54.1 10-Jun-2019  christos Sync with HEAD
 1.33.52.1 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.34.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.35.8.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.4 19-May-2000  mrg this file has not been used for a long time.
 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 05-Aug-1999  thorpej branches: 1.2.2;
Change the semantics of splsoftclock() to be like other spl*() functions,
that is priority is rasied. Add a new spllowersoftclock() to provide the
atomic drop-to-softclock semantics that the old splsoftclock() provided,
and update calls accordingly.

This fixes a problem with using the "rnd" pseudo-device from within
interrupt context to extract random data (e.g. from within the softnet
interrupt) where doing so would incorrectly unblock interrupts (causing
all sorts of lossage).

XXX 4 platforms do not have priority-raising capability: newsmips, sparc,
XXX sparc64, and VAX. This platforms still have this bug until their
XXX spl*() functions are fixed.
 1.1 20-Jun-1998  eeh branches: 1.1.1;
Initial revision
 1.1.1.1 20-Jun-1998  eeh Import of sparc64.
 1.2.2.1 20-Nov-2000  bouyer Remove files that are no longer on the trunck
 1.9 03-Jun-2011  christos CFATTACH_DECL_NEW
 1.8 16-Oct-2006  martin branches: 1.8.78; 1.8.84; 1.8.88;
Remove obsolete kgdb prototypes.
 1.7 13-Feb-2006  cdi branches: 1.7.14; 1.7.16;
ANSIfy: u_intN_t -> uintN_t, remove __P(), fix function definitions.
 1.6 11-Dec-2005  christos branches: 1.6.2; 1.6.4; 1.6.6;
merge ktrace-lwp.
 1.5 21-Mar-2004  pk branches: 1.5.16;
`stdin' and `stdout' are obsolete.
 1.4 19-Mar-2004  pk Sync with sparc: rename
stdinnode => prom_stdin_node,
fbnode => prom_stdout_node.
 1.3 19-May-2000  eeh branches: 1.3.28;
Fix the sparc64 console.

Unlike the other Sun machines, UltraSPARCs can have consoles run on different
chips than zs, so we need to support them. So, here we go:

Add a new PROM console driver with a major number and everything.
This is the default driver if nothing else attaches. It does not
use the keyboard driver since the PROM translates keystrokes itself.
(Unfortunately it also swallows L1-A).

Have the keyboard driver take over the console when it attaches on a
serial port. When a serial port detects a keyboard and attaches the
keyboard driver, it needs to provide a set of consdev vectors. They
keyboard driver will use those to send I/O to the keyboard and mouse.
 1.2 15-Feb-1999  hubertf branches: 1.2.8;
RCS ID police
 1.1 20-Jun-1998  eeh branches: 1.1.1;
Initial revision
 1.1.1.1 20-Jun-1998  eeh Import of sparc64.
 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.28.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.3.28.2 18-Sep-2004  skrll Sync with HEAD.
 1.3.28.1 03-Aug-2004  skrll Sync with HEAD
 1.5.16.2 30-Dec-2006  yamt sync with head.
 1.5.16.1 21-Jun-2006  yamt sync with head.
 1.6.6.1 22-Apr-2006  simonb Sync with head.
 1.6.4.1 09-Sep-2006  rpaulo sync with head
 1.6.2.1 18-Feb-2006  yamt sync with head.
 1.7.16.1 22-Oct-2006  yamt sync with head
 1.7.14.1 18-Nov-2006  ad Sync with head.
 1.8.88.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.8.84.1 06-Jun-2011  jruoho Sync with HEAD.
 1.8.78.1 12-Jun-2011  rmind sync with head
 1.28 02-Mar-2015  nakayama prom_printf converts "\n" to "\r\n" internally, so omit "\r".
 1.27 12-Sep-2013  martin branches: 1.27.6;
Remove an unused variable, avoid unused variable warning.
 1.26 31-Jul-2012  martin branches: 1.26.2; 1.26.4;
Set up cn_tab in bootstrap() instead of initializing it statically.
Fixes -Wno-common fallout, idea from tsutsui.
 1.25 18-Mar-2009  cegger branches: 1.25.12;
Ansify function definitions w/o arguments. Generated with sed.
 1.24 17-Oct-2007  garbled branches: 1.24.20; 1.24.28; 1.24.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.23 01-Oct-2007  martin printf -> DPRINTF
 1.22 15-Oct-2006  martin branches: 1.22.8; 1.22.16; 1.22.26; 1.22.28; 1.22.30;
Initialize struct consdev in C99 style
 1.21 13-Feb-2006  cdi branches: 1.21.14; 1.21.16;
ANSIfy: u_intN_t -> uintN_t, remove __P(), fix function definitions.
 1.20 17-Dec-2005  jdc branches: 1.20.2; 1.20.4; 1.20.6;
Check the PROM stdin path for the string "/usb@0". If we find a match, call
ukbd_cnattach(), so that the USB keyboard will become the console keyboard.
Makes the keyboard work on a Blade 100.
 1.19 11-Dec-2005  christos merge ktrace-lwp.
 1.18 31-May-2005  christos branches: 1.18.2;
- sprinkle const
- avoid variable shadow
 1.17 21-Mar-2004  pk branches: 1.17.14;
Use the promlib I/O routines.
 1.16 19-Mar-2004  petrov More on fbnode to prom_stdout_node rename.
 1.15 19-Mar-2004  pk Sync with sparc: rename
stdinnode => prom_stdin_node,
fbnode => prom_stdout_node.
 1.14 21-Oct-2003  petrov don't initialize an int with NULL.
 1.13 15-Jul-2003  lukem __KERNEL_RCSID()
 1.12 06-Sep-2002  gehenna branches: 1.12.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.11 31-Aug-2001  eeh branches: 1.11.6; 1.11.14;
instance-to-path works on instances not nodes.
 1.10 28-Aug-2001  eeh Fix incorrect parentheses.
 1.9 20-Oct-2000  mrg branches: 1.9.4;
#include <machine/sparc64.h> for prom_printf() prototype.
 1.8 28-Sep-2000  eeh Use prom_printf() for debugging instead of printf() since the console may
not be functional.
 1.7 10-Jul-2000  eeh Break into debugger by typing `+++++',
 1.6 24-Jun-2000  eeh Get rid of vaddrs.h.
 1.5 19-May-2000  eeh branches: 1.5.4;
Fix the sparc64 console.

Unlike the other Sun machines, UltraSPARCs can have consoles run on different
chips than zs, so we need to support them. So, here we go:

Add a new PROM console driver with a major number and everything.
This is the default driver if nothing else attaches. It does not
use the keyboard driver since the PROM translates keystrokes itself.
(Unfortunately it also swallows L1-A).

Have the keyboard driver take over the console when it attaches on a
serial port. When a serial port detects a keyboard and attaches the
keyboard driver, it needs to provide a set of consdev vectors. They
keyboard driver will use those to send I/O to the keyboard and mouse.
 1.4 19-Apr-2000  pk Have prom_cngetc() wait until input has been typed.
 1.3 13-Apr-2000  mrg this does not need auxreg.h
 1.2 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.1 23-May-1999  eeh branches: 1.1.2; 1.1.4;
Separate out the generic console handling from zs.c
 1.1.4.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.1.2.1 21-Jun-1999  thorpej Sync w/ -current.
 1.5.4.1 18-Jul-2000  mrg pullup the contents of -current arch/sparc64. this gives us significant
ultrasparc PCI support (ultra5, ultra10, AXi, and E250 tested so far),
plus many other small fixes. netbooting is now supported.
 1.9.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.9.4.1 13-Sep-2001  thorpej Update the kqueue branch to HEAD.
 1.11.14.1 19-May-2002  gehenna Replace the access to devsw table and the hard-coded majors with devsw API.
 1.11.6.2 17-Sep-2002  nathanw Catch up to -current.
 1.11.6.1 31-Aug-2001  nathanw file consinit.c was added on branch nathanw_sa on 2002-09-17 21:17:55 +0000
 1.12.6.4 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 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.17.14.1 01-Jan-2006  riz Pull up following revision(s) (requested by jdc in ticket #1076):
sys/arch/sparc64/dev/consinit.c: revision 1.20
Check the PROM stdin path for the string "/usb@0". If we find a match, call
ukbd_cnattach(), so that the USB keyboard will become the console keyboard.
Makes the keyboard work on a Blade 100.
 1.18.2.3 27-Oct-2007  yamt sync with head.
 1.18.2.2 30-Dec-2006  yamt sync with head.
 1.18.2.1 21-Jun-2006  yamt sync with head.
 1.20.6.1 22-Apr-2006  simonb Sync with head.
 1.20.4.1 09-Sep-2006  rpaulo sync with head
 1.20.2.1 18-Feb-2006  yamt sync with head.
 1.21.16.1 22-Oct-2006  yamt sync with head
 1.21.14.1 18-Nov-2006  ad Sync with head.
 1.22.30.1 06-Oct-2007  yamt sync with head.
 1.22.28.1 06-Nov-2007  matt sync with HEAD
 1.22.26.1 02-Oct-2007  joerg Sync with HEAD.
 1.22.16.1 03-Oct-2007  garbled Sync with HEAD
 1.22.8.1 09-Oct-2007  ad Sync with head.
 1.24.34.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.24.28.1 28-Apr-2009  skrll Sync with HEAD.
 1.24.20.1 04-May-2009  yamt sync with head.
 1.25.12.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.25.12.1 30-Oct-2012  yamt sync with head
 1.26.4.1 18-May-2014  rmind sync with head
 1.26.2.2 03-Dec-2017  jdolecek update from HEAD
 1.26.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.27.6.1 06-Apr-2015  skrll Sync with HEAD
 1.9 12-Mar-2002  uwe Rework the driver to add EBus DMA support and improve APC DMA support.
Audio-related stuff is left almost intact.

* support audiocs at ebus playback and capture
tested on krups and u5 (thanks, martin)
* make first attempt at supporting audiocs at sbus capture
* nb: full-duplex is not tested
* while here, fix CSAUDIO_MONITOR_MUTE to be of CSAUDIO_MONITOR_CLASS
i.e. outputs.monitor.mute -> monitor.monitor.mute

Ok by pk, eeh.
 1.8 01-Mar-2002  martin Rename EBUS_PADDR_FROM_REG uses to EBUS_ADDR_FROM_REG.
 1.7 22-Oct-2001  mrg branches: 1.7.4;
use <dev/ebus/ebusreg.h>
 1.6 09-Jul-2000  pk branches: 1.6.4;
Add a `device class' interrupt level argument (from machine/intr.h)
to bus_interrupt_establish().

It's currently only used in sparc64/dev/psycho.c to assign a CPU interrupt
level to devices in PCI slots.
 1.5 18-Jun-2000  mrg branches: 1.5.2;
add a (u_long) cast for quietness
 1.4 04-Jun-2000  cgd Implement the more flexiable `evcnt' interface as discussed (briefly) on
tech-kern and now documented in evcnt(9).
 1.3 15-Apr-2000  mrg branches: 1.3.2;
- auxio cleanup and sbus support.
- make GENERIC64 include GENERIC and set the 3 optoins it needs. suggested
by hubert feyrer.
- add a comment that we maybe should use the `bpp' driver, not the lpt, on
the ebus because the `bpp' driver does DMA already.
- ebus_attach_args got a member renamed
 1.2 05-Apr-2000  mrg add a couple of comments.
 1.1 07-Jun-1999  mrg branches: 1.1.2; 1.1.4;
add ebus attachment for cs4231. this does not work as it requires ebus DMA and will panic if enabled. but it should otherwise be mostly complete.
 1.1.4.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.1.2.2 21-Jun-1999  thorpej Sync w/ -current.
 1.1.2.1 07-Jun-1999  thorpej file cs4231_ebus.c was added on branch chs-ubc2 on 1999-06-21 01:02:30 +0000
 1.3.2.1 22-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.5.2.1 18-Jul-2000  mrg pullup the contents of -current arch/sparc64. this gives us significant
ultrasparc PCI support (ultra5, ultra10, AXi, and E250 tested so far),
plus many other small fixes. netbooting is now supported.
 1.6.4.2 16-Mar-2002  jdolecek Catch up with -current.
 1.6.4.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.7.4.2 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.7.4.1 22-Oct-2001  nathanw file cs4231_ebus.c was added on branch nathanw_sa on 2002-04-01 07:43:00 +0000
 1.6 05-Sep-1998  pk These are replaced by drivers in <sys/dev/sbus>.
 1.5 05-Sep-1998  pk #include <dev/sbus/sbusvar.h>
 1.4 27-Aug-1998  mrg remove sparc64 "options BUS_DMA" -- it is now standard
 1.3 13-Aug-1998  eeh Merge paddr_t changes into the main branch.
 1.2 07-Jul-1998  eeh branches: 1.2.2;
General update:

Added genassym.cf
Removed lderr which should never have gotten in
Removed lots of dead code from locore.s
Added some softint stuff to intr.c
Added support for halt -p
esp and le both use bus_dmamap_*() functions now
instead of kdvma_mapin()
groundwork for PCI (but we still have no drivers for
any sun4u PCI devices)
 1.1 20-Jun-1998  eeh branches: 1.1.1;
Initial revision
 1.1.1.1 20-Jun-1998  eeh Import of sparc64.
 1.2.2.2 02-Aug-1998  eeh Cleanup work:

Sync up with sys/dev/sbus
get cgsix to work right
 1.2.2.1 30-Jul-1998  eeh Split vm_offset_t and vm_size_t into paddr_t, psize_t, vaddr_t, and vsize_t.
 1.2 05-Sep-1998  pk These are replaced by drivers in <sys/dev/sbus>.
 1.1 20-Jun-1998  eeh branches: 1.1.1;
Initial revision
 1.1.1.1 20-Jun-1998  eeh Import of sparc64.
 1.2 05-Sep-1998  pk These are replaced by drivers in <sys/dev/sbus>.
 1.1 20-Jun-1998  eeh branches: 1.1.1;
Initial revision
 1.1.1.1 20-Jun-1998  eeh Import of sparc64.
 1.69 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.68 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.67 10-May-2021  thorpej branches: 1.67.4;
Associate the OpenBoot / OpenFirmware node with attached devices
at config_found() time.
 1.66 24-Apr-2021  thorpej branches: 1.66.2; 1.66.4;
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.65 04-Jan-2021  thorpej branches: 1.65.2;
malloc(9) -> kmem(9) -- just the simple, straightforward conversions for now.
 1.64 10-Nov-2019  chs branches: 1.64.8;
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.63 18-Jan-2018  mrg branches: 1.63.4;
merge the ebus@pci attach output to be like most PCI drivers:

ebus0 at pci1 dev 1 function 0
ebus0: Sun Microsystems PCIO Ebus2, revision 0x01

becomes:

ebus0 at pci1 dev 1 function 0: Sun Microsystems PCIO Ebus2, revision 0x01
 1.62 18-Oct-2014  snj src is too big these days to tolerate superfluous apostrophes. It's
"its", people!
 1.61 19-Sep-2012  jdc Match the Altera ebus bridge, as found on the Tadpole SPARCle.
 1.60 30-Jan-2012  mrg branches: 1.60.6;
avoid writing 1 byte beyond the end of the string promlib.c has given us.
instead of forcing a nul byte afterwards, KASSERT() that the final byte
already is a nul. if there are broken proms... well, we can fix them.

this, plus one more change, allows my SS20 to boot multiuser.
 1.59 20-Jul-2011  macallan branches: 1.59.2; 1.59.6;
add per ivec event counters
 1.58 01-Jul-2011  dyoung #include <sys/bus.h> instead of <machine/bus.h>.
 1.57 02-Jun-2011  christos split auxio, ebus, psycho, sab.
 1.56 18-Mar-2011  mrg branches: 1.56.2;
re-add local ebusvar.h, and use it to share between ebus.c and ebus_mainbus.c
 1.55 11-Mar-2011  nakayama Remove unnecessary headers.
 1.54 11-Mar-2010  mrg branches: 1.54.2; 1.54.4;
various aprint_* fixes.
 1.53 13-Oct-2008  nakayama branches: 1.53.14;
Remove unnecessary includes.
 1.52 29-May-2008  mrg branches: 1.52.4;
remove clause #3 from my license where there are no other
copyright holders involved.
 1.51 05-Apr-2008  cegger branches: 1.51.2; 1.51.4; 1.51.6;
use aprint_*_dev and device_xname
OK martin
 1.50 13-Feb-2006  cdi branches: 1.50.68;
ANSIfy: u_intN_t -> uintN_t, remove __P(), fix function definitions.
 1.49 11-Feb-2006  cdi ANSIfication: u_intN_t -> uintN_t, use ANSI function declarations/definitions
instead of K&R ones.
 1.48 11-Dec-2005  christos branches: 1.48.2; 1.48.4; 1.48.6;
merge ktrace-lwp.
 1.47 31-May-2005  christos branches: 1.47.2;
- sprinkle const
- avoid variable shadow
 1.46 24-Apr-2004  kleink Update for new pci_devinfo(9) signature.
 1.45 21-Mar-2004  pk Use prom_getpropstring().
 1.44 21-Mar-2004  martin Make sure prom_getprop is called with the size pointed to by nitem
initialized. (Some of these are more paranoia, but two were actual bugs.)
Print error codes in some panic messages.
 1.43 17-Mar-2004  pk Rename PROM_getprop*() => prom_getprop*().
 1.42 09-Nov-2003  martin Nuke bcopy/bzero.
 1.41 27-Aug-2003  mrg change PROM_getprop() from taking a "void **" for the storage, to a
"void *", and do the extra de-reference directly in the function. this
avoids having to cast dozens of different types to "void **", which sets
of GCC3's strict-aliasing. testing by martin@
 1.40 15-Jul-2003  lukem __KERNEL_RCSID()
 1.39 17-May-2003  nakayama branches: 1.39.2;
Avoid strict-alias warnings in gcc 3.3.
 1.38 03-May-2003  wiz DMA, not dma nor Dma.
 1.37 01-Jan-2003  thorpej Use aprint_normal() for cfprint routines.
 1.36 10-Dec-2002  pk Remove the `flags' argument from bus_intr_establish().
 1.35 10-Dec-2002  pk bus_intr_establish() signature change.
The additional `fast trap' argument is ignored in these drivers.
BUS_INTR_ESTABLISH_FASTTRAP and BUS_INTR_ESTABLISH_SOFTINTR are no longer used.
 1.34 02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.33 01-Oct-2002  thorpej Use CFATTACH_DECL().
 1.32 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.31 16-Mar-2002  mrg convert to using <dev/ebus/ebusvar.h> and it's struct member names.
 1.30 15-Mar-2002  eeh Get PCI working with the new bus_space*.
 1.29 22-Oct-2001  mrg branches: 1.29.4;
clean up ebus:
- kill dead dma code
- remove icky self->dv_parent casts

audiocs @ ebus doesn't crash anymore, but it doesn't appear to work
yet either...
 1.28 26-Sep-2001  eeh getprop* -> PROM_getprop*
 1.27 24-Sep-2001  eeh Change bus_space_mmap() signature to the official one.
 1.26 10-Sep-2001  eeh Get rid of spurious OF_getprop().
 1.25 10-Sep-2001  eeh Sun Blade 100 support (and some psycho fixes from Jason Wright).
 1.24 25-Jul-2001  eeh branches: 1.24.2;
Don't match ebus nodes not called "ebus" like the ones on hme cards.
 1.23 20-Jul-2001  eeh PCI overhaul.
 1.22 04-Jun-2001  mrg branches: 1.22.2;
fix lint exposed by GCC 3.0 20010604 (prerelease).
 1.21 18-May-2001  mrg correct some comments. <80 char debug statements.
 1.20 18-May-2001  mrg do not force ebus interrupts to have bit 0x20 set.
 1.19 08-Jan-2001  pk branches: 1.19.2;
ebus_find_node(): plug memory leak; make debug output meaningfuller.
 1.18 04-Dec-2000  fvdl Warning police. Mostly useless format warnings. Switch Makefile for
kernel compiles to the warning flags that other ports also use.
 1.17 27-Jul-2000  mrg ebus sc_is is a pointer now, already.
 1.16 12-Jul-2000  pk If there is no "interrupt-map" property on the ebus node, assume the
child "interrupt" properties are already in a format suitable for
the parent bus.
 1.15 09-Jul-2000  pk Add a `device class' interrupt level argument (from machine/intr.h)
to bus_interrupt_establish().

It's currently only used in sparc64/dev/psycho.c to assign a CPU interrupt
level to devices in PCI slots.
 1.14 29-Jun-2000  mrg remove include of <vm/vm.h>. <vm/vm.h> -> <uvm/uvm_extern.h>
 1.13 26-Jun-2000  mrg remove/move more mach vm header files:

<vm/pglist.h> -> <uvm/uvm_pglist.h>
<vm/vm_inherit.h> -> <uvm/uvm_inherit.h>
<vm/vm_kern.h> -> into <uvm/uvm_extern.h>
<vm/vm_object.h> -> nothing
<vm/vm_pager.h> -> into <uvm/uvm_pager.h>

also includes a bunch of <vm/vm_page.h> include removals (due to redudancy
with <vm/vm.h>), and a scattering of other similar headers.
 1.12 24-Jun-2000  eeh Enable interrupts.
 1.11 12-Jun-2000  eeh branches: 1.11.2;
ebus_ca needs to specify enough memory to hold an ebus_softc, not a struct device.
 1.10 08-Jun-2000  mrg ensure an ebus really does exist in ebus_match; fixes spurious attachments with the ebus on a hme pci card.
 1.9 17-May-2000  mrg branches: 1.9.2;
expand a comment slightly.
 1.8 22-Apr-2000  mrg whole bunch of changes:
- merge IOMMU DVMA code from sbus/psycho into iommu.c. this code was
identical and a few minor inconsistencies had crept in. this way
keeps them all in sync.
- with this code gone from psycho, merge the psycho.c and psycho_bus.c
files. same with ebus/ebus_bus.c. delete the _bus.c files.
- add a _ds_boundary member to the dma segment structure, so that later
dma mappings can find this value.
- set _ds_boundary in machdep.c:_bus_dmamem_alloc().
- kill much dead code.
 1.7 15-Apr-2000  mrg - auxio cleanup and sbus support.
- make GENERIC64 include GENERIC and set the 3 optoins it needs. suggested
by hubert feyrer.
- add a comment that we maybe should use the `bpp' driver, not the lpt, on
the ebus because the `bpp' driver does DMA already.
- ebus_attach_args got a member renamed
 1.6 13-Apr-2000  mrg avoid a potential memory leak.
 1.5 08-Apr-2000  mrg - store the ebus's parent so we can find the IOMMU
- use generic iommu routines in the ebus code (uses the above)
- add some more comments.
 1.4 05-Apr-2000  mrg be slightly more verbose when attaching ebus devices.
 1.3 05-Jun-1999  mrg branches: 1.3.2; 1.3.4;
find ebus device INO values via the "interrupt-map" and "interrupt-map-mask" properties.
 1.2 04-Jun-1999  mrg avoid uninitalised pointers.
 1.1 04-Jun-1999  mrg support for the UltraSPARC `Extension Bus' found on the PCI machines.
the bus space/dma code is cloned from the PCI code to do the same thing
which itself was cloned from the sbus bus space/dma code. the bus dma
code is non-functional at this point.
 1.3.4.3 18-Jan-2001  bouyer Sync with head (for UBC+NFS fixes, mostly).
 1.3.4.2 08-Dec-2000  bouyer Sync with HEAD.
 1.3.4.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-1999  thorpej Sync w/ -current.
 1.9.2.1 22-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.11.2.2 15-May-2001  he Pull up revision 1.17 (requested by martin):
Fix a bug: ``sc'' is a pointer, so use it correctly.
 1.11.2.1 18-Jul-2000  mrg pullup the contents of -current arch/sparc64. this gives us significant
ultrasparc PCI support (ultra5, ultra10, AXi, and E250 tested so far),
plus many other small fixes. netbooting is now supported.
 1.19.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.22.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.22.2.4 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.22.2.3 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.22.2.2 13-Sep-2001  thorpej Update the kqueue branch to HEAD.
 1.22.2.1 03-Aug-2001  lukem update to -current
 1.24.2.1 01-Oct-2001  fvdl Catch up with -current.
 1.29.4.5 03-Jan-2003  thorpej Sync with HEAD.
 1.29.4.4 11-Dec-2002  thorpej Sync with HEAD.
 1.29.4.3 18-Oct-2002  nathanw Catch up to -current.
 1.29.4.2 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.29.4.1 22-Oct-2001  nathanw file ebus.c was added on branch nathanw_sa on 2002-04-01 07:43:00 +0000
 1.39.2.4 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.39.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.39.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.39.2.1 03-Aug-2004  skrll Sync with HEAD
 1.47.2.1 21-Jun-2006  yamt sync with head.
 1.48.6.1 22-Apr-2006  simonb Sync with head.
 1.48.4.1 09-Sep-2006  rpaulo sync with head
 1.48.2.1 18-Feb-2006  yamt sync with head.
 1.50.68.2 17-Jan-2009  mjf Sync with HEAD.
 1.50.68.1 02-Jun-2008  mjf Sync with HEAD.
 1.51.6.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.51.4.2 11-Aug-2010  yamt sync with head.
 1.51.4.1 04-May-2009  yamt sync with head.
 1.51.2.1 04-Jun-2008  yamt sync with head
 1.52.4.1 19-Oct-2008  haad Sync with HEAD.
 1.53.14.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.54.4.1 06-Jun-2011  jruoho Sync with HEAD.
 1.54.2.2 12-Jun-2011  rmind sync with head
 1.54.2.1 21-Apr-2011  rmind sync with head
 1.56.2.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.59.6.1 18-Feb-2012  mrg merge to -current.
 1.59.2.2 30-Oct-2012  yamt sync with head
 1.59.2.1 17-Apr-2012  yamt sync with head
 1.60.6.2 03-Dec-2017  jdolecek update from HEAD
 1.60.6.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.63.4.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.64.8.1 03-Apr-2021  thorpej Sync with HEAD.
 1.65.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.66.4.1 31-May-2021  cjep sync with head
 1.66.2.1 13-May-2021  thorpej Sync with HEAD.
 1.67.4.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.9 22-Apr-2000  mrg whole bunch of changes:
- merge IOMMU DVMA code from sbus/psycho into iommu.c. this code was
identical and a few minor inconsistencies had crept in. this way
keeps them all in sync.
- with this code gone from psycho, merge the psycho.c and psycho_bus.c
files. same with ebus/ebus_bus.c. delete the _bus.c files.
- add a _ds_boundary member to the dma segment structure, so that later
dma mappings can find this value.
- set _ds_boundary in machdep.c:_bus_dmamem_alloc().
- kill much dead code.
 1.8 10-Apr-2000  mrg UltraSPARC IIi CPU has bits 6-10 of the INO hardwired to 1. when we
install an interrupt handler, make sure we set these bits to 1. now,
interrupt_vector in locore can find our registered interrupt handlers
and at least try to setup a call to them.
 1.7 08-Apr-2000  mrg - store the ebus's parent so we can find the IOMMU
- use generic iommu routines in the ebus code (uses the above)
- add some more comments.
 1.6 05-Apr-2000  mrg include opt_ddb.h
 1.5 13-Mar-2000  soren Fix doubled 'the's in comments.
 1.4 13-Nov-1999  thorpej Update for pmap_enter() API change. No functional difference.
 1.3 08-Jul-1999  thorpej branches: 1.3.2; 1.3.4; 1.3.8;
Change the pmap_extract() interface to:
boolean_t pmap_extract(pmap_t, vaddr_t, paddr_t *);
This makes it possible for the pmap to map physical address 0.
 1.2 07-Jun-1999  eeh branches: 1.2.2;
Another general cleanup:

Remove the entire idea of fasttrap interrupts since V9 traps are really cheap,
the CPUs are really fast, and the completely different trap frames would make
these handlers really difficult to implement.

pmap_changeprot() was only used by the clock and one other place; deprecate it.

probeget() and probeset() now take 64-bit addresses even in 32-bit mode so we
can probe IO locations by physical addresses.

Some pmap cleanup.

Some more copyright cleanup.
 1.1 04-Jun-1999  mrg support for the UltraSPARC `Extension Bus' found on the PCI machines.
the bus space/dma code is cloned from the PCI code to do the same thing
which itself was cloned from the sbus bus space/dma code. the bus dma
code is non-functional at this point.
 1.2.2.3 02-Aug-1999  thorpej Update from trunk.
 1.2.2.2 21-Jun-1999  thorpej Sync w/ -current.
 1.2.2.1 07-Jun-1999  thorpej file ebus_bus.c was added on branch chs-ubc2 on 1999-06-21 01:02:30 +0000
 1.3.8.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.3.4.1 15-Nov-1999  fvdl Sync with -current
 1.3.2.1 20-Nov-2000  bouyer Remove files that are no longer on the trunck
 1.23 24-May-2022  andvar fix various typos in comment, documentation and log messages.
 1.22 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.21 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.20 10-May-2021  thorpej branches: 1.20.4;
Associate the OpenBoot / OpenFirmware node with attached devices
at config_found() time.
 1.19 24-Apr-2021  thorpej branches: 1.19.2; 1.19.4;
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.18 04-Jan-2021  thorpej branches: 1.18.2;
malloc(9) -> kmem(9) -- just the simple, straightforward conversions for now.
 1.17 10-Nov-2019  chs branches: 1.17.8;
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.16 13-May-2016  nakayama branches: 1.16.18;
Use newly introduced intrhand_alloc().
 1.15 04-Nov-2014  palle branches: 1.15.2;
sun4v: Removed a bunch of ifdef SUN4V since the CPU_ISSUN4V already has the necessary logic. Noticed by mrg@
 1.14 27-Aug-2014  palle Use device_lookup() to locate device instances
 1.13 24-Aug-2014  palle Generalize the code to allow for arbitrary interrupt wirings - with this change the serial console is usable on Sun Fire V445 systems - from OpenBSD - ok mrg@ martin@
 1.12 16-Dec-2013  palle Updates to pmap_bootstrap() for sun4v - parts from OpenBSD - OK martin@
 1.11 12-Sep-2013  martin #if 0 a variable just like their only use
 1.10 27-Oct-2012  chs branches: 1.10.2;
split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.9 18-Mar-2012  mrg branches: 1.9.2;
add missing __KERNEL_RCSID().
 1.8 14-Aug-2011  mrg branches: 1.8.2; 1.8.6;
initialise ih_ivec.
 1.7 12-Aug-2011  mrg - make a bunch of functions static
- set nmapmask to 1 before prom_getprop(), so we don't trigger an ENOMEM
- initialise ih_pending
 1.6 12-Aug-2011  mrg use device_private() to find the matching pyro leaf, now that pyro
has been device_t-ified.
 1.5 01-Jul-2011  dyoung #include <sys/bus.h> instead of <machine/bus.h>.
 1.4 02-Jun-2011  christos branches: 1.4.2;
split auxio, ebus, psycho, sab.
 1.3 16-Mar-2011  mrg branches: 1.3.2; 1.3.4;
minor clean up.
 1.2 15-Mar-2011  mrg initial port of these drivers to netbsd. both pyro(4) and ebus(4) at
mainbus depend upon other as-yet uncommited changes.
 1.1 15-Mar-2011  mrg branches: 1.1.1;
Initial revision
 1.1.1.1 15-Mar-2011  mrg import the openbsd pyro and ebus_mainbus drivers for base reference.
 1.3.4.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.3.2.3 12-Jun-2011  rmind sync with head
 1.3.2.2 21-Apr-2011  rmind sync with head
 1.3.2.1 16-Mar-2011  rmind file ebus_mainbus.c was added on branch rmind-uvmplock on 2011-04-21 01:41:26 +0000
 1.4.2.2 06-Jun-2011  jruoho Sync with HEAD.
 1.4.2.1 02-Jun-2011  jruoho file ebus_mainbus.c was added on branch jruoho-x86intr on 2011-06-06 09:06:49 +0000
 1.8.6.1 05-Apr-2012  mrg sync to latest -current.
 1.8.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.8.2.2 30-Oct-2012  yamt sync with head
 1.8.2.1 17-Apr-2012  yamt sync with head
 1.9.2.3 03-Dec-2017  jdolecek update from HEAD
 1.9.2.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.9.2.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.10.2.1 18-May-2014  rmind sync with head
 1.15.2.1 29-May-2016  skrll Sync with HEAD
 1.16.18.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.17.8.1 03-Apr-2021  thorpej Sync with HEAD.
 1.18.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.19.4.1 31-May-2021  cjep sync with head
 1.19.2.1 13-May-2021  thorpej Sync with HEAD.
 1.20.4.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.2 22-Oct-2001  mrg this has moved to dev/ebus
 1.1 04-Jun-1999  mrg branches: 1.1.2; 1.1.18;
support for the UltraSPARC `Extension Bus' found on the PCI machines.
the bus space/dma code is cloned from the PCI code to do the same thing
which itself was cloned from the sbus bus space/dma code. the bus dma
code is non-functional at this point.
 1.1.18.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.1.2.1 21-Jun-1999  thorpej Sync w/ -current.
 1.12 24-Aug-2014  palle Generalize the code to allow for arbitrary interrupt wirings - with this change the serial console is usable on Sun Fire V445 systems - from OpenBSD - ok mrg@ martin@
 1.11 01-Jul-2011  dyoung branches: 1.11.12;
#include <sys/bus.h> instead of <machine/bus.h>.
 1.10 02-Jun-2011  christos split auxio, ebus, psycho, sab.
 1.9 18-Mar-2011  mrg branches: 1.9.2;
re-add local ebusvar.h, and use it to share between ebus.c and ebus_mainbus.c
 1.8 16-Mar-2002  mrg branches: 1.8.86; 1.8.92;
this file is no longer used.
 1.7 14-Mar-2002  eeh bus_space_map2 no longer exists.
 1.6 22-Oct-2001  mrg branches: 1.6.4;
clean up ebus:
- kill dead dma code
- remove icky self->dv_parent casts

audiocs @ ebus doesn't crash anymore, but it doesn't appear to work
yet either...
 1.5 20-Jul-2001  eeh PCI overhaul.
 1.4 15-Apr-2000  mrg branches: 1.4.8;
- auxio cleanup and sbus support.
- make GENERIC64 include GENERIC and set the 3 optoins it needs. suggested
by hubert feyrer.
- add a comment that we maybe should use the `bpp' driver, not the lpt, on
the ebus because the `bpp' driver does DMA already.
- ebus_attach_args got a member renamed
 1.3 08-Apr-2000  mrg - store the ebus's parent so we can find the IOMMU
- use generic iommu routines in the ebus code (uses the above)
- add some more comments.
 1.2 05-Jun-1999  mrg branches: 1.2.2; 1.2.4;
find ebus device INO values via the "interrupt-map" and "interrupt-map-mask" properties.
 1.1 04-Jun-1999  mrg support for the UltraSPARC `Extension Bus' found on the PCI machines.
the bus space/dma code is cloned from the PCI code to do the same thing
which itself was cloned from the sbus bus space/dma code. the bus dma
code is non-functional at this point.
 1.2.4.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 21-Jun-1999  thorpej Sync w/ -current.
 1.4.8.3 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.4.8.2 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.4.8.1 03-Aug-2001  lukem update to -current
 1.6.4.2 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.6.4.1 22-Oct-2001  nathanw file ebusvar.h was added on branch nathanw_sa on 2002-04-01 07:43:01 +0000
 1.8.92.1 06-Jun-2011  jruoho Sync with HEAD.
 1.8.86.2 12-Jun-2011  rmind sync with head
 1.8.86.1 21-Apr-2011  rmind sync with head
 1.9.2.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.11.12.1 03-Dec-2017  jdolecek update from HEAD
 1.12 28-Feb-2010  martin Remove the envctrl driver, it is superseeded by the more general pcfiic @
ebus. Add the SB1000/SB2000 fan controll driver (tda). From OpenBSD.
Move config files over to direct configuration of i2c devices.
 1.11 28-Apr-2008  martin branches: 1.11.14; 1.11.20;
Remove clause 3 and 4 from TNF licenses
 1.10 26-Mar-2008  xtraeme branches: 1.10.2; 1.10.4;
sme_cookie is not needed when SME_DISABLE_REFRESH is set.
 1.9 26-Mar-2008  tnn Split device_t/softc for envctrl(4).
 1.8 16-Nov-2007  xtraeme branches: 1.8.14;
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.7 17-Oct-2007  garbled branches: 1.7.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.6 16-Jul-2007  xtraeme branches: 1.6.8; 1.6.10; 1.6.12; 1.6.16;
Disable monitoring in the Integer sensors, they are just informative
and shouldn't need it anyway.
 1.5 09-Jul-2007  ad branches: 1.5.2;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements
 1.4 01-Jul-2007  xtraeme Imported envsys 2, a brief description of the new features:
(Part 2: drivers)

* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.

Tested by:

blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
riz: owtemp(4).
xtraeme: acpiacad(4), acpibat(4), acpitz(4), aiboost(4), it(4), lm(4).
 1.3 02-May-2007  tnn branches: 1.3.2;
Define microvoltage scale factor which was previously a magic constant.
 1.2 15-Apr-2007  tnn branches: 1.2.2; 1.2.4;
Correct envsys ranges. From njoly@
 1.1 14-Apr-2007  tnn Add envctrl(4): Sun Ultra Enterprise 450 environmental monitoring driver.
Also add accompanying i2c controller driver, pcf8584.
Both written by me. Some cosmetic improvements from Iain Hibbert.
ok <martin>
 1.2.4.2 03-Oct-2007  garbled Sync with HEAD
 1.2.4.1 22-May-2007  matt Update to HEAD.
 1.2.2.3 07-May-2007  yamt sync with head.
 1.2.2.2 15-Apr-2007  yamt sync with head.
 1.2.2.1 15-Apr-2007  yamt file envctrl.c was added on branch yamt-idlelwp on 2007-04-15 16:03:08 +0000
 1.3.2.5 03-Dec-2007  ad Sync with HEAD.
 1.3.2.4 20-Aug-2007  ad Sync with HEAD.
 1.3.2.3 15-Jul-2007  ad Sync with head.
 1.3.2.2 09-Jun-2007  ad Sync with head.
 1.3.2.1 02-May-2007  ad file envctrl.c was added on branch vmlocking on 2007-06-09 21:37:03 +0000
 1.5.2.2 11-Jul-2007  mjf Sync with head.
 1.5.2.1 09-Jul-2007  mjf file envctrl.c was added on branch mjf-ufs-trans on 2007-07-11 20:02:33 +0000
 1.6.16.1 18-Nov-2007  bouyer Sync with HEAD
 1.6.12.3 07-Dec-2007  yamt sync with head
 1.6.12.2 03-Sep-2007  yamt sync with head.
 1.6.12.1 16-Jul-2007  yamt file envctrl.c was added on branch yamt-lazymbuf on 2007-09-03 14:30:13 +0000
 1.6.10.2 09-Jan-2008  matt sync with HEAD
 1.6.10.1 06-Nov-2007  matt sync with HEAD
 1.6.8.1 21-Nov-2007  joerg Sync with HEAD.
 1.7.2.1 19-Nov-2007  mjf Sync with HEAD.
 1.8.14.2 02-Jun-2008  mjf Sync with HEAD.
 1.8.14.1 03-Apr-2008  mjf Sync with HEAD.
 1.10.4.2 11-Mar-2010  yamt sync with head
 1.10.4.1 16-May-2008  yamt sync with head.
 1.10.2.1 18-May-2008  yamt sync with head.
 1.11.20.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.11.14.1 24-Oct-2010  jym Sync with HEAD
 1.6 28-Feb-2010  martin Remove the envctrl driver, it is superseeded by the more general pcfiic @
ebus. Add the SB1000/SB2000 fan controll driver (tda). From OpenBSD.
Move config files over to direct configuration of i2c devices.
 1.5 28-Apr-2008  martin branches: 1.5.14; 1.5.20;
Remove clause 3 and 4 from TNF licenses
 1.4 17-Oct-2007  garbled branches: 1.4.16; 1.4.18; 1.4.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.3 02-May-2007  tnn branches: 1.3.2; 1.3.4; 1.3.14; 1.3.16;
Define microvoltage scale factor which was previously a magic constant.
 1.2 18-Apr-2007  tnn branches: 1.2.2;
We can't support them in a clean way, but still note the bus addresses
of the disk failure LEDs.
 1.1 14-Apr-2007  tnn branches: 1.1.2;
Add envctrl(4): Sun Ultra Enterprise 450 environmental monitoring driver.
Also add accompanying i2c controller driver, pcf8584.
Both written by me. Some cosmetic improvements from Iain Hibbert.
ok <martin>
 1.1.2.3 07-May-2007  yamt sync with head.
 1.1.2.2 15-Apr-2007  yamt sync with head.
 1.1.2.1 14-Apr-2007  yamt file envctrlreg.h was added on branch yamt-idlelwp on 2007-04-15 16:03:08 +0000
 1.2.2.1 22-May-2007  matt Update to HEAD.
 1.3.16.2 03-Sep-2007  yamt sync with head.
 1.3.16.1 02-May-2007  yamt file envctrlreg.h was added on branch yamt-lazymbuf on 2007-09-03 14:30:14 +0000
 1.3.14.1 06-Nov-2007  matt sync with HEAD
 1.3.4.2 11-Jul-2007  mjf Sync with head.
 1.3.4.1 02-May-2007  mjf file envctrlreg.h was added on branch mjf-ufs-trans on 2007-07-11 20:02:34 +0000
 1.3.2.2 09-Jun-2007  ad Sync with head.
 1.3.2.1 02-May-2007  ad file envctrlreg.h was added on branch vmlocking on 2007-06-09 21:37:03 +0000
 1.4.20.2 11-Mar-2010  yamt sync with head
 1.4.20.1 16-May-2008  yamt sync with head.
 1.4.18.1 18-May-2008  yamt sync with head.
 1.4.16.1 02-Jun-2008  mjf Sync with HEAD.
 1.5.20.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.5.14.1 24-Oct-2010  jym Sync with HEAD
 1.7 05-Sep-1998  pk These are replaced by drivers in <sys/dev/sbus>.
 1.6 05-Sep-1998  pk #include <dev/sbus/sbusvar.h>
 1.5 15-Aug-1998  mycroft Minor edit.
 1.4 15-Aug-1998  mycroft Assign copyright to TNF.
 1.3 13-Aug-1998  eeh Merge paddr_t changes into the main branch.
 1.2 07-Jul-1998  eeh branches: 1.2.2;
General update:

Added genassym.cf
Removed lderr which should never have gotten in
Removed lots of dead code from locore.s
Added some softint stuff to intr.c
Added support for halt -p
esp and le both use bus_dmamap_*() functions now
instead of kdvma_mapin()
groundwork for PCI (but we still have no drivers for
any sun4u PCI devices)
 1.1 20-Jun-1998  eeh branches: 1.1.1;
Initial revision
 1.1.1.1 20-Jun-1998  eeh Import of sparc64.
 1.2.2.1 02-Aug-1998  eeh Cleanup work:

Sync up with sys/dev/sbus
get cgsix to work right
 1.2 05-Sep-1998  pk These are replaced by drivers in <sys/dev/sbus>.
 1.1 20-Jun-1998  eeh branches: 1.1.1;
Initial revision
 1.1.1.1 20-Jun-1998  eeh Import of sparc64.
 1.2 05-Sep-1998  pk These are replaced by drivers in <sys/dev/sbus>.
 1.1 20-Jun-1998  eeh branches: 1.1.1;
Initial revision
 1.1.1.1 20-Jun-1998  eeh Import of sparc64.
 1.2 25-Jun-2001  eeh Remove unused file.
 1.1 20-Jun-1998  eeh branches: 1.1.1;
Initial revision
 1.1.1.1 20-Jun-1998  eeh Import of sparc64.
 1.2 25-Jun-2001  eeh Remove another unused file.
 1.1 20-Jun-1998  eeh branches: 1.1.1;
Initial revision
 1.1.1.1 20-Jun-1998  eeh Import of sparc64.
 1.22 07-Oct-2002  martin Remove unused file, superseeded by syssrc/dev/sun/fb.c.
 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 26-Sep-2001  eeh branches: 1.20.4; 1.20.12;
getprop* -> PROM_getprop*
 1.19 19-Sep-2001  thorpej machine/fbio.h -> dev/sun/fbio.h
 1.18 23-Aug-2000  pk branches: 1.18.2; 1.18.4;
remove pfourreg.h.
 1.17 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.16 26-Aug-1999  thorpej branches: 1.16.2; 1.16.12;
Suns use black-on-white as the default rcons colors.
 1.15 23-May-1999  ad - Setting initial position of cursor is up to caller.
- Set cursor position properly for SPARC. From Juergen Hannken-Illjes.
 1.14 23-May-1999  eeh Start putting in hooks for non-zs console devices.
 1.13 19-May-1999  ad SPARC console is black on white, and is centered by default.
 1.12 19-May-1999  ad Add arg to rcons_init() that when set causes screen to be cleared.
 1.11 19-May-1999  ad Insert missing code that defines screen metrics for rcons. This fixes the
more blatant rcons brokenness (ie no panics).
 1.10 18-May-1999  ad Sync with last two changes made to sys/arch/sparc/dev/fb.c (don't clear
screen, typo).
 1.9 16-May-1999  ad Fix typo on my behalf. From Juergen Hannken-Illjes.
 1.8 15-May-1999  ad Panic if rasops_init() fails us (should never be the case).
 1.7 15-May-1999  ad Make sure rasops_info descriptor is zeroed out before initializing.
 1.6 26-Apr-1999  ad Update configuration to match `rasops' fixes and config glue.
 1.5 13-Apr-1999  ad Leave font selection to 'rasops' until 'rasops1' has been completed and can
handle non {8,16} pixel wide fonts.
 1.4 13-Apr-1999  ad Bring sparc/sparc64 fb code and kernel configuration into line with
rcons changes.
 1.3 02-Sep-1998  eeh branches: 1.3.8;
Periodic update: now starts probing devices.
 1.2 13-Aug-1998  eeh Merge paddr_t changes into the main branch.
 1.1 20-Jun-1998  eeh branches: 1.1.1;
Initial revision
 1.1.1.1 20-Jun-1998  eeh branches: 1.1.1.1.2;
Import of sparc64.
 1.1.1.1.2.2 08-Aug-1998  eeh Revert cdevsw mmap routines to return int.
 1.1.1.1.2.1 30-Jul-1998  eeh Split vm_offset_t and vm_size_t into paddr_t, psize_t, vaddr_t, and vsize_t.
 1.3.8.1 21-Jun-1999  thorpej Sync w/ -current.
 1.16.12.1 30-Jun-2000  simonb Pull up mmap paddr_t/off_t changes from trunk.
 1.16.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.18.4.3 11-Oct-2002  jdolecek follow rev. 1.22, and g/c this file
 1.18.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.18.4.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.18.2.2 10-Oct-2001  fvdl Convert all remaining devices.
 1.18.2.1 01-Oct-2001  fvdl Catch up with -current.
 1.20.12.1 17-May-2002  gehenna Add device switch.
 1.20.4.3 18-Oct-2002  nathanw Catch up to -current.
 1.20.4.2 17-Sep-2002  nathanw Catch up to -current.
 1.20.4.1 26-Sep-2001  nathanw file fb.c was added on branch nathanw_sa on 2002-09-17 21:17:56 +0000
 1.20 22-Oct-2001  mrg kill a dead driver. the floppy driver will be shared with sparc anyway...
 1.19 08-Jul-2001  wiz branches: 1.19.2; 1.19.4;
Correct various misspellings of 'transfer' and inflected forms.
 1.18 24-Aug-2000  nathanw In fdioctl(), allocate fd_formb dynamically when needed, rather than on
the stack, and remove the no-longer-necessary PHOLD()/PRELE() calls
in fdformat().

(This eliminates 1/3 of the instances of PHOLD()/PRELE() in the kernel code.)

XXX We still have too many mostly-redundant floppy drivers.
 1.17 04-Jun-2000  cgd Implement the more flexiable `evcnt' interface as discussed (briefly) on
tech-kern and now documented in evcnt(9).
 1.16 16-May-2000  thorpej branches: 1.16.2;
Nuke dk_establish() from orbit except from those ports which still use
it to determine the boot device: mvme68k, pc532, macppc, ofppc. Those
platforms should be changed to use device_register(). In the mean time,
those ports defined __BROKEN_DK_ESTABLISH.
 1.15 15-Apr-2000  mrg - auxio cleanup and sbus support.
- make GENERIC64 include GENERIC and set the 3 optoins it needs. suggested
by hubert feyrer.
- add a comment that we maybe should use the `bpp' driver, not the lpt, on
the ebus because the `bpp' driver does DMA already.
- ebus_attach_args got a member renamed
 1.14 07-Apr-2000  thorpej Use separate callouts for motor-on and motor-off. Fixes a condition
where the floppy driver would wedge because a motor-on timeout would
be cancelled by another I/O operation cancelling a motor-off timeout.

From enami tsugutomo <enami@sm.sony.co.jp>.
 1.13 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.12 16-Mar-2000  eeh Revamp interrupts again:

Fix a bug causing interrmittent panics in interrupt dispatch.
Use interrupt vectors for softints.
Add a new send_softint interface.
Improved D$ flushing.
Improve traptrace and other debugging enhancements.
 1.11 07-Feb-2000  thorpej Fix a bug in disksort_*() which caused non-optimal ordering when multiple
active partitions were on a single spindle. Add a b_rawblkno member to
struct buf which contains the non-partition-relative block number to sort
by.
 1.10 21-Jan-2000  thorpej Update for sys/buf.h/disksort_*() changes.
 1.9 14-Jan-2000  pk Remove old-style boot device recognition.
 1.8 07-Jun-1999  eeh branches: 1.8.2; 1.8.8;
Another general cleanup:

Remove the entire idea of fasttrap interrupts since V9 traps are really cheap,
the CPUs are really fast, and the completely different trap frames would make
these handlers really difficult to implement.

pmap_changeprot() was only used by the clock and one other place; deprecate it.

probeget() and probeset() now take 64-bit addresses even in 32-bit mode so we
can probe IO locations by physical addresses.

Some pmap cleanup.

Some more copyright cleanup.
 1.7 05-Jun-1999  eeh Make pbrobeget() and probeset() work for 64-bit values as well. To do this
the arguments are changed so the address is first and the ASI second so we
can have the address in %o0:%o1 and not worry about unused registers.

Also a bit of copyright cleanup.
 1.6 05-Jun-1999  mrg catch up with probe[gs]et() changes.
 1.5 08-Feb-1999  bouyer branches: 1.5.4;
Change DIOCEJECT to do what's needed to eject a device before the eject
command (unlock for sd and cd) if no other partitions are open, return
EBUSY otherwise. DIOCEJECT will have the old semantic if its argument is not
0. The old ioctl has been renamed to ODIOCEJECT for binary compatibility.
 1.4 07-Feb-1999  jonathan defopt MEMORY_DISK_{HOOKS,SERVER,IS_ROOT}.
 1.3 15-Aug-1998  mycroft Make copyright notices with my name consistent.
 1.2 04-Jul-1998  jonathan defopt DDB.
 1.1 20-Jun-1998  eeh branches: 1.1.1;
Initial revision
 1.1.1.1 20-Jun-1998  eeh Import of sparc64.
 1.5.4.1 21-Jun-1999  thorpej Sync w/ -current.
 1.8.8.1 21-Dec-1999  wrstuden Initial commit of recent changes to make DEV_BSIZE go away.

Runs on i386, needs work on other arch's. Main kernel routines should be
fine, but a number of the stand programs need help.

cd, fd, ccd, wd, and sd have been updated. sd has been tested with non-512
byte block devices. vnd, raidframe, and lfs need work.

Non 2**n block support is automatic for LKM's and conditional for kernels
on "options NON_PO2_BLOCKS".
 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.16.2.1 22-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.19.4.1 10-Oct-2001  fvdl Convert all remaining devices.
 1.19.2.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.52 02-Sep-2023  jdc sparc64: fix interrupt level mapping for disk and and parallel devices
on SBUS-based machines
Change the mapping from PIL_SCSI to PIL_BIO, so that they interrupt above
the highest soft interrupt (softserial)
Remove unused PIL_SCSI, PIL_FDSOFT, PIL_AUSOFT and fix the printf in fdc.c
Add "socal" and "SUNW,bpp" to the interrupt map.
 1.51 07-Aug-2021  thorpej branches: 1.51.6;
Merge thorpej-cfargs2.
 1.50 24-Apr-2021  thorpej branches: 1.50.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.49 04-Jan-2021  thorpej branches: 1.49.2;
malloc(9) -> kmem(9) -- just the simple, straightforward conversions for now.
 1.48 10-Nov-2019  chs branches: 1.48.8;
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.47 08-Feb-2019  mrg make *fd*.c's fd_dev_to_type() always a static inline. some
have it as a const, and have code to copy the defaults to
modify them before using them, but that probably requires a
real test to feel confident in changing.
 1.46 05-Feb-2019  mrg add or avoid fallthru comments.
 1.45 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.44 26-Apr-2015  mlelstv branches: 1.44.16; 1.44.18;
Use C99-style initializers for struct dkdriver.
 1.43 02-Jan-2015  christos We have three sets of DTYPE_ constants in the kernel:
altq Drop Type
disklabel Disk Type
file Descriptor Type
(not to mention constants that contain the string DTYPE).
Let's make them two, by changing the disklabel one to be DisK TYPE since the
other disklabel constants seem to do that. Not many userland programs use
these constants (and the ones that they do are mostly in ifdefs). They will
be fixed shortly.
 1.42 19-Aug-2014  jnemeth branches: 1.42.2;
Sync with sparc/dev/fd.c:1.155.

Fix panic() on opening fd(4), caused by a wrong pointer passed to memset().

I'm not sure why this 18 year old bug didn't cause problem before
(at least my old 5.99.23 kernel worked), but probably it's triggered
by new gcc 4.8 which might do more aggressive memory allocation.
The problem is found by Nobuyoshi Sato on trying eject(1) against fd(4).

Should be pulled up to netbsd-7.
 1.41 25-Jul-2014  dholland branches: 1.41.2;
Add d_discard to all struct cdevsw instances I could find.

All have been set to "nodiscard"; some should get a real implementation.
 1.40 25-Jul-2014  dholland Add d_discard to all struct bdevsw instances I could find.

I've set them all to nodiscard. Some of them (wd, dk, vnd, ld,
raidframe, maybe cgd) should be implemented for real.
 1.39 16-Mar-2014  dholland branches: 1.39.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.38 30-May-2013  martin branches: 1.38.2;
Make it compile again
 1.37 29-May-2013  christos phase 1 of disk geometry cleanup:
- centralize the geometry -> plist code so that we don't have
n useless copies of it.
 1.36 08-Aug-2011  jakllsch branches: 1.36.2; 1.36.8; 1.36.12; 1.36.14; 1.36.22;
inline -> static inline
For successful gcc 4.5 builds.
 1.35 03-Jun-2011  christos CFATTACH_DECL_NEW
 1.34 12-Mar-2011  nakayama branches: 1.34.2;
Remove implicit include <dev/sbus/sbusvar.h> from autoconf.h, and
add it explicitly in files depending on it.
 1.33 24-Feb-2010  dyoung branches: 1.33.2; 1.33.4;
A pointer typedef entails trading too much flexibility to declare const
and non-const types, and the kernel uses both const and non-const
PMF qualifiers and device suspensors, so change the pmf_qual_t and
device_suspensor_t typedefs from "pointers to const" to non-pointer,
non-const types.
 1.32 08-Jan-2010  dyoung branches: 1.32.2;
Expand PMF_FN_* macros.
 1.31 15-May-2009  jnemeth Convert shutdownhook_establish() to pmf_device_register1().

XXX This should be done as part of an overall plan to support
power management and device detachment. However, in order to do
that, I would first have to invent sbus_intr_disestablish(). This
is being done at this time in order to aid in the effort to eliminate
shutdownhook_establish().
 1.30 18-Mar-2009  cegger bzero -> memset
 1.29 13-Jan-2009  yamt branches: 1.29.2;
g/c BUFQ_FOO() macros and use bufq_foo() directly.
 1.28 17-Dec-2008  cegger kill MALLOC and FREE macros.
 1.27 17-Dec-2008  cegger make this compile
 1.26 16-Dec-2008  christos replace bitmask_snprintf(9) with snprintb(3)
 1.25 20-Jun-2008  jnemeth branches: 1.25.4;
KNF: space after comma -- be consistent!
 1.24 18-Jun-2008  dogcow add a missing close-parenthesis. (HI CEGGER!)
 1.23 13-Jun-2008  cegger use device_lookup_private to get softc
 1.22 28-Apr-2008  martin branches: 1.22.2; 1.22.4;
Remove clause 3 and 4 from TNF licenses
 1.21 05-Apr-2008  cegger branches: 1.21.2; 1.21.4;
use aprint_*_dev and device_xname
OK martin
 1.20 02-Jan-2008  ad branches: 1.20.6;
Merge vmlocking2 to head.
 1.19 28-Nov-2007  jnemeth branches: 1.19.2; 1.19.6;
don't include sys/intr.h twice, why aren't the includes sorted?
 1.18 28-Nov-2007  ad Use the softint API.
 1.17 28-Nov-2007  jnemeth Sync with src/sys/sparc/dev/fd.c change to use softint(9) API.

XXX Please keep these two in sync as this one is a drop-in replacement
for the sparc version and the idea is to have both sparc and sparc64
use the same file one day.
 1.16 17-Oct-2007  garbled branches: 1.16.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.15 08-Oct-2007  ad Merge disk init changes from the vmlocking branch. These seperate init /
destroy of 'struct disk' from attach / detach.
 1.14 29-Jul-2007  ad branches: 1.14.4; 1.14.6; 1.14.8;
It's not a good idea for device drivers to modify b_flags, as they don't
need to understand the locking around that field. Instead of setting
B_ERROR, set b_error instead. b_error is 'owned' by whoever completes
the I/O request.
 1.13 09-Jul-2007  ad branches: 1.13.2; 1.13.4;
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 27-Mar-2007  jnemeth branches: 1.12.4;
fix a couple of syntax issues in sparc code from Tobias Nygren
 1.11 27-Mar-2007  jnemeth move definition of FTC_FLIP to auxioreg.h to mirror sparc
 1.10 25-Mar-2007  jnemeth Fixed formatting. Problem was that we were trying to get the result
of a data transfer operation immediately after the data transfer
was finished, instead of waiting for the chip to interrupt us and
tell us that it was finished and had the result for us. This worked
okay for read and write since the operation would be finished very
shortly after the data transfer completed. However, with formatting,
the chip still had most of the rest of the track to do, so we ended
up timing out before the operation was finished.
 1.9 09-Mar-2007  jnemeth branches: 1.9.2; 1.9.4; 1.9.6;
Correct gap2 length from ISA driver.

XXX The machine no longer becomes unusable when formatting, but it still
doesn't format properly.
 1.8 06-Mar-2007  dogcow more caddr_t fallout.
 1.7 04-Mar-2007  christos fix fallout from caddr_t changes.
 1.6 04-Mar-2007  christos Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.5 02-Mar-2007  jnemeth Deallocate resources where possible when we fail to attach.

XXX Somebody needs to write bus_intr_disestablish().
 1.4 02-Mar-2007  jnemeth add support for drvctl properties
 1.3 02-Mar-2007  jnemeth merge remaining differences from sparc driver in
 1.2 15-Feb-2007  reinoud branches: 1.2.2;
Rename the B_XXX flag to B_DEVPRIVATE flag since it was never used for
debugging and its main use is in device drivers. Its used there to signal
that the flagged buffer has a special meaning or should be handled
differently.

OK'd by Bill Sudenmund on tech-kern.
 1.1 06-Oct-2006  jnemeth branches: 1.1.2; 1.1.4; 1.1.6; 1.1.8; 1.1.10;
Initial support for floppy drives on sparc64. This has been tested
on an Ultra 2 and works fine, apart from formatting which is known
to be broken. It failed to work on an ebus machine. The ebus
support compiles fine, but I don't have hardware for testing. This
code is based on the sparc driver with hints from OpenBSD on how
to do the sbus and ebus attachments, along with help from martin@
and mrg@.

Initial commit approved by martin@

TODO:
- fix ebus support
- fix XXX issues
- check resource deallocation
- fix formatting
- merge remaining differences from sparc driver
- split out back end chip support
- have sparc driver use new common back end chip support
- adapt to newlock when branch is ready
- adapt to "disk-info" property dictionary
 1.1.10.1 03-Jun-2007  wrstuden Catch up with now-somewhat-dated netbsd-4. These changes took longer
than expected for me to actually get around to merging.
 1.1.8.7 21-Jan-2008  yamt sync with head
 1.1.8.6 07-Dec-2007  yamt sync with head
 1.1.8.5 27-Oct-2007  yamt sync with head.
 1.1.8.4 03-Sep-2007  yamt sync with head.
 1.1.8.3 26-Feb-2007  yamt sync with head.
 1.1.8.2 30-Dec-2006  yamt sync with head.
 1.1.8.1 06-Oct-2006  yamt file fdc.c was added on branch yamt-lazymbuf on 2006-12-30 20:47:02 +0000
 1.1.6.1 20-May-2007  jdc APull up revisions 1.9-1.10 (requested by jnemeth in ticket #647)

Correct gap2 length from ISA driver.

XXX The machine no longer becomes unusable when formatting, but it still
doesn't format properly.

Fixed formatting. Problem was that we were trying to get the result
of a data transfer operation immediately after the data transfer
was finished, instead of waiting for the chip to interrupt us and
tell us that it was finished and had the result for us. This worked
okay for read and write since the operation would be finished very
shortly after the data transfer completed. However, with formatting,
the chip still had most of the rest of the track to do, so we ended
up timing out before the operation was finished.
 1.1.4.2 18-Nov-2006  ad Sync with head.
 1.1.4.1 06-Oct-2006  ad file fdc.c was added on branch newlock2 on 2006-11-18 21:29:32 +0000
 1.1.2.2 22-Oct-2006  yamt sync with head
 1.1.2.1 06-Oct-2006  yamt file fdc.c was added on branch yamt-splraiseipl on 2006-10-22 06:05:11 +0000
 1.2.2.2 15-Apr-2007  yamt sync with head.
 1.2.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.9.6.1 29-Mar-2007  reinoud Pullup to -current
 1.9.4.1 11-Jul-2007  mjf Sync with head.
 1.9.2.5 03-Dec-2007  ad Sync with HEAD.
 1.9.2.4 20-Aug-2007  ad - Alter disk attach/detach to fix a panic when closing a vnd device.
- Sync with HEAD.
 1.9.2.3 19-Aug-2007  ad - Back out the biodone() changes.
- Eliminate B_ERROR (from HEAD).
 1.9.2.2 01-Jul-2007  ad Adapt to callout API change.
 1.9.2.1 10-Apr-2007  ad Sync with head.
 1.12.4.2 16-Oct-2007  garbled Sync with HEAD
 1.12.4.1 03-Oct-2007  garbled Sync with HEAD
 1.13.4.1 15-Aug-2007  skrll Sync with HEAD.
 1.13.2.1 07-Aug-2007  matt Sync with HEAD.
 1.14.8.1 14-Oct-2007  yamt sync with head.
 1.14.6.2 09-Jan-2008  matt sync with HEAD
 1.14.6.1 06-Nov-2007  matt sync with HEAD
 1.14.4.2 03-Dec-2007  joerg Sync with HEAD.
 1.14.4.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.16.2.2 18-Feb-2008  mjf Sync with HEAD.
 1.16.2.1 08-Dec-2007  mjf Sync with HEAD.
 1.19.6.1 02-Jan-2008  bouyer Sync with HEAD
 1.19.2.2 31-Dec-2007  ad Catch up with buffer cache changes.
 1.19.2.1 10-Dec-2007  ad Make it compile.
 1.20.6.3 17-Jan-2009  mjf Sync with HEAD.
 1.20.6.2 29-Jun-2008  mjf Sync with HEAD.
 1.20.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.21.4.4 11-Mar-2010  yamt sync with head
 1.21.4.3 16-May-2009  yamt sync with head
 1.21.4.2 04-May-2009  yamt sync with head.
 1.21.4.1 16-May-2008  yamt sync with head.
 1.21.2.2 17-Jun-2008  yamt sync with head.
 1.21.2.1 18-May-2008  yamt sync with head.
 1.22.4.2 27-Jun-2008  simonb Sync with head.
 1.22.4.1 18-Jun-2008  simonb Sync with head.
 1.22.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.25.4.2 28-Apr-2009  skrll Sync with HEAD.
 1.25.4.1 19-Jan-2009  skrll Sync with HEAD.
 1.29.2.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.32.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.33.4.1 06-Jun-2011  jruoho Sync with HEAD.
 1.33.2.2 12-Jun-2011  rmind sync with head
 1.33.2.1 21-Apr-2011  rmind sync with head
 1.34.2.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.36.22.1 03-Nov-2014  msaitoh Pull up following revision(s) (requested by tsutsui in ticket #1139):
sys/arch/sun3/dev/fd.c: revision 1.78
sys/arch/sparc/dev/fd.c: revision 1.155
sys/arch/sparc64/dev/fdc.c: revision 1.42
Fix panic() on opening fd(4), caused by a wrong pointer passed to memset().
I'm not sure why this 18 year old bug didn't cause problem before
(at least my old 5.99.23 kernel worked), but probably it's triggered
by new gcc 4.8 which might do more aggressive memory allocation.
The problem is found by Nobuyoshi Sato on trying eject(1) against fd(4).
Should be pulled up to netbsd-7.
Sync with sparc/dev/fd.c:1.155.
Fix panic() on opening fd(4), caused by a wrong pointer passed to memset().
I'm not sure why this 18 year old bug didn't cause problem before
(at least my old 5.99.23 kernel worked), but probably it's triggered
by new gcc 4.8 which might do more aggressive memory allocation.
The problem is found by Nobuyoshi Sato on trying eject(1) against fd(4).
Should be pulled up to netbsd-7.
Sync with sparc/dev/fd.c rev 1.155.
Fix panic() on opening fd(4), caused by a wrong pointer passed to memset().
Note sun3 still uses gcc 4.5.4 but also panicked by this old bug,
so probably this problem was triggered by not gcc 4.8 but struct disk
changes (struct disk_geom was added in <sys/disk.h> rev 1.58),
which increased sizeof(struct fd_softc) from 248 bytes to 296 bytes.
(i.e. now struct fd_softc could be allocated in a different pool block,
probably near the wrong pointer of the struct disklabel)
Anyway, this fix should be pullued up to netbsd-7.
(probably I'm the only user of floppy on sun3 though)
 1.36.14.1 03-Nov-2014  msaitoh Pull up following revision(s) (requested by tsutsui in ticket #1139):
sys/arch/sun3/dev/fd.c: revision 1.78
sys/arch/sparc/dev/fd.c: revision 1.155
sys/arch/sparc64/dev/fdc.c: revision 1.42
Fix panic() on opening fd(4), caused by a wrong pointer passed to memset().
I'm not sure why this 18 year old bug didn't cause problem before
(at least my old 5.99.23 kernel worked), but probably it's triggered
by new gcc 4.8 which might do more aggressive memory allocation.
The problem is found by Nobuyoshi Sato on trying eject(1) against fd(4).
Should be pulled up to netbsd-7.
Sync with sparc/dev/fd.c:1.155.
Fix panic() on opening fd(4), caused by a wrong pointer passed to memset().
I'm not sure why this 18 year old bug didn't cause problem before
(at least my old 5.99.23 kernel worked), but probably it's triggered
by new gcc 4.8 which might do more aggressive memory allocation.
The problem is found by Nobuyoshi Sato on trying eject(1) against fd(4).
Should be pulled up to netbsd-7.
Sync with sparc/dev/fd.c rev 1.155.
Fix panic() on opening fd(4), caused by a wrong pointer passed to memset().
Note sun3 still uses gcc 4.5.4 but also panicked by this old bug,
so probably this problem was triggered by not gcc 4.8 but struct disk
changes (struct disk_geom was added in <sys/disk.h> rev 1.58),
which increased sizeof(struct fd_softc) from 248 bytes to 296 bytes.
(i.e. now struct fd_softc could be allocated in a different pool block,
probably near the wrong pointer of the struct disklabel)
Anyway, this fix should be pullued up to netbsd-7.
(probably I'm the only user of floppy on sun3 though)
 1.36.12.3 03-Dec-2017  jdolecek update from HEAD
 1.36.12.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.36.12.1 23-Jun-2013  tls resync from head
 1.36.8.1 03-Nov-2014  msaitoh Pull up following revision(s) (requested by tsutsui in ticket #1139):
sys/arch/sun3/dev/fd.c: revision 1.78
sys/arch/sparc/dev/fd.c: revision 1.155
sys/arch/sparc64/dev/fdc.c: revision 1.42
Fix panic() on opening fd(4), caused by a wrong pointer passed to memset().
I'm not sure why this 18 year old bug didn't cause problem before
(at least my old 5.99.23 kernel worked), but probably it's triggered
by new gcc 4.8 which might do more aggressive memory allocation.
The problem is found by Nobuyoshi Sato on trying eject(1) against fd(4).
Should be pulled up to netbsd-7.
Sync with sparc/dev/fd.c:1.155.
Fix panic() on opening fd(4), caused by a wrong pointer passed to memset().
I'm not sure why this 18 year old bug didn't cause problem before
(at least my old 5.99.23 kernel worked), but probably it's triggered
by new gcc 4.8 which might do more aggressive memory allocation.
The problem is found by Nobuyoshi Sato on trying eject(1) against fd(4).
Should be pulled up to netbsd-7.
Sync with sparc/dev/fd.c rev 1.155.
Fix panic() on opening fd(4), caused by a wrong pointer passed to memset().
Note sun3 still uses gcc 4.5.4 but also panicked by this old bug,
so probably this problem was triggered by not gcc 4.8 but struct disk
changes (struct disk_geom was added in <sys/disk.h> rev 1.58),
which increased sizeof(struct fd_softc) from 248 bytes to 296 bytes.
(i.e. now struct fd_softc could be allocated in a different pool block,
probably near the wrong pointer of the struct disklabel)
Anyway, this fix should be pullued up to netbsd-7.
(probably I'm the only user of floppy on sun3 though)
 1.36.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.38.2.1 18-May-2014  rmind sync with head
 1.39.2.1 10-Aug-2014  tls Rebase.
 1.41.2.1 24-Aug-2014  martin Pull up following revision(s) (requested by tsutsui in ticket #53):
sys/arch/sun3/dev/fd.c: revision 1.78
sys/arch/sparc/dev/fd.c: revision 1.155
sys/arch/sparc64/dev/fdc.c: revision 1.42
Fix panic() on opening fd(4), caused by a wrong pointer passed to memset().
 1.42.2.2 06-Jun-2015  skrll Sync with HEAD
 1.42.2.1 06-Apr-2015  skrll Sync with HEAD
 1.44.18.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.44.18.1 10-Jun-2019  christos Sync with HEAD
 1.44.16.1 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.48.8.1 03-Apr-2021  thorpej Sync with HEAD.
 1.49.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.50.8.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.51.6.1 09-Sep-2023  martin Pull up following revision(s) (requested by jdc in ticket #360):

sys/arch/sparc64/dev/fdc.c: revision 1.52
sys/arch/sparc64/include/intr.h: revision 1.32
sys/arch/sparc64/sparc64/autoconf.c: revision 1.239
sys/arch/sparc64/include/psl.h: revision 1.64

sparc64: fix interrupt level mapping for disk and and parallel devices
on SBUS-based machines

Change the mapping from PIL_SCSI to PIL_BIO, so that they interrupt above
the highest soft interrupt (softserial)

Remove unused PIL_SCSI, PIL_FDSOFT, PIL_AUSOFT and fix the printf in fdc.c

Add "socal" and "SUNW,bpp" to the interrupt map.
 1.1 06-Oct-2006  jnemeth branches: 1.1.2; 1.1.4; 1.1.8;
Initial support for floppy drives on sparc64. This has been tested
on an Ultra 2 and works fine, apart from formatting which is known
to be broken. It failed to work on an ebus machine. The ebus
support compiles fine, but I don't have hardware for testing. This
code is based on the sparc driver with hints from OpenBSD on how
to do the sbus and ebus attachments, along with help from martin@
and mrg@.

Initial commit approved by martin@

TODO:
- fix ebus support
- fix XXX issues
- check resource deallocation
- fix formatting
- merge remaining differences from sparc driver
- split out back end chip support
- have sparc driver use new common back end chip support
- adapt to newlock when branch is ready
- adapt to "disk-info" property dictionary
 1.1.8.2 30-Dec-2006  yamt sync with head.
 1.1.8.1 06-Oct-2006  yamt file fdcreg.h was added on branch yamt-lazymbuf on 2006-12-30 20:47:02 +0000
 1.1.4.2 18-Nov-2006  ad Sync with head.
 1.1.4.1 06-Oct-2006  ad file fdcreg.h was added on branch newlock2 on 2006-11-18 21:29:32 +0000
 1.1.2.2 22-Oct-2006  yamt sync with head
 1.1.2.1 06-Oct-2006  yamt file fdcreg.h was added on branch yamt-splraiseipl on 2006-10-22 06:05:11 +0000
 1.3 30-Jun-2011  wiz dependant -> dependent
 1.2 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.1 06-Oct-2006  jnemeth branches: 1.1.2; 1.1.4; 1.1.8; 1.1.58; 1.1.60; 1.1.62;
Initial support for floppy drives on sparc64. This has been tested
on an Ultra 2 and works fine, apart from formatting which is known
to be broken. It failed to work on an ebus machine. The ebus
support compiles fine, but I don't have hardware for testing. This
code is based on the sparc driver with hints from OpenBSD on how
to do the sbus and ebus attachments, along with help from martin@
and mrg@.

Initial commit approved by martin@

TODO:
- fix ebus support
- fix XXX issues
- check resource deallocation
- fix formatting
- merge remaining differences from sparc driver
- split out back end chip support
- have sparc driver use new common back end chip support
- adapt to newlock when branch is ready
- adapt to "disk-info" property dictionary
 1.1.62.1 16-May-2008  yamt sync with head.
 1.1.60.1 18-May-2008  yamt sync with head.
 1.1.58.1 02-Jun-2008  mjf Sync with HEAD.
 1.1.8.2 30-Dec-2006  yamt sync with head.
 1.1.8.1 06-Oct-2006  yamt file fdcvar.h was added on branch yamt-lazymbuf on 2006-12-30 20:47:02 +0000
 1.1.4.2 18-Nov-2006  ad Sync with head.
 1.1.4.1 06-Oct-2006  ad file fdcvar.h was added on branch newlock2 on 2006-11-18 21:29:32 +0000
 1.1.2.2 22-Oct-2006  yamt sync with head
 1.1.2.1 06-Oct-2006  yamt file fdcvar.h was added on branch yamt-splraiseipl on 2006-10-22 06:05:11 +0000
 1.2 22-Oct-2001  mrg kill a dead driver. the floppy driver will be shared with sparc anyway...
 1.1 20-Jun-1998  eeh branches: 1.1.1;
Initial revision
 1.1.1.1 20-Jun-1998  eeh branches: 1.1.1.1.28;
Import of sparc64.
 1.1.1.1.28.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.3 22-Oct-2001  mrg kill a dead driver. the floppy driver will be shared with sparc anyway...
 1.2 05-Sep-1998  pk branches: 1.2.26;
Assign my copyrights to TNF.
 1.1 20-Jun-1998  eeh branches: 1.1.1;
Initial revision
 1.1.1.1 20-Jun-1998  eeh Import of sparc64.
 1.2.26.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.68 20-Dec-2023  thorpej Remove unnecessary <sys/malloc.h>.
 1.67 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.66 24-Apr-2021  thorpej branches: 1.66.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.65 05-Jul-2020  martin branches: 1.65.4;
Adapt to proplib api changes
 1.64 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.63 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.62 26-Mar-2018  jdc branches: 1.62.2;
Correct a typo in the openprom variable name.
 1.61 19-May-2017  macallan branches: 1.61.8;
enable font loading / screen resizing
 1.60 27-Apr-2017  macallan - don't blindly copy attribute bits which we don't support or which make no
sense in the attribute buffer
- support WSATTR_UNDERLINE
- remove unused function
 1.59 22-Apr-2017  macallan branches: 1.59.2;
- set RI_FULLCLEAR
- clear RI_CURSOR when we clear the screen
no more garbage when switching screens
while there set RI_PREFER_ALPHA
 1.58 04-Nov-2016  macallan mmap() memory-ish regions with BUS_SPACE_MAP_PREFETCHABLE
 1.57 07-Jul-2016  msaitoh branches: 1.57.2;
KNF. Remove extra spaces. No functional change.
 1.56 11-Sep-2015  macallan - initialize sc_bg_cache and FFB_FBC_BG along with everything else so things
get redrawn properly when exiting X
- fix off by one in ffb_ras_erasecols(), no more artifacts when the screen
is redrawn
 1.55 09-Oct-2013  macallan branches: 1.55.6;
support WSDISPLAYIO_GET_FBINFO
 1.54 12-Sep-2013  martin Remove unused variable
 1.53 30-Jul-2013  macallan avoid uninitialized use of defattr
 1.52 09-Aug-2012  macallan branches: 1.52.2; 1.52.4;
split ffb_putchar() into a version for mono fonts and one for anti-aliased
ones. While there use the blitter to draw the cursor and remove some waits
that are unnecessary now that characters are drawn by hardware.
 1.51 12-Apr-2012  macallan don't assume that wscons assumes BGR ordering and request it explicitly
 1.50 11-Jan-2012  macallan use rasops_init(0, 0)
 1.49 22-Dec-2011  macallan support anti-aliased fonts and let the hardware do the alpha blending
 1.48 31-Oct-2011  jdc branches: 1.48.2; 1.48.6;
Add support for the WSDISPLAYIO_GET_EDID ioctl (requires passing a device_t
to ffb_attach).
 1.47 23-Oct-2011  jdc Correct the VSYNC-related register definitions and rework how they are used
(only when the monitor supports composite sync). OK macallan@.
 1.46 18-Aug-2011  macallan shut up some debug output accidentially left in
 1.45 16-Aug-2011  macallan use appropriate WID and FBC for high resolution mode
Tested with a 1680x1050 TFT on an ffb2+
 1.44 01-Jul-2011  dyoung #include <sys/bus.h> instead of <machine/bus.h>.
 1.43 03-Jun-2011  christos CFATTACH_DECL_NEW
 1.42 19-May-2011  macallan branches: 1.42.2;
remove obsolete comment - putchar() does in fact use the blitter now
 1.41 09-May-2011  jdc Alter the sync-on-green and composite-sync settings:

if the monitor doesn't support composite sync, enable sync-on-green

then, if the monitor supports separate sync, disable composite vsync

(Prompted by macallan@.)
 1.40 20-Apr-2011  martin Remove some leftovers
 1.39 09-Apr-2011  jdc Add EDID and video mode setting support to FFB.

Add definitions for registers related to video modes, and to DDC. Rename
other registers to be more descriptive.
Add i2c bus routines to read the EDID data via DDC.
Add routines to calculate, and to set, the video mode.

Note, that interlaced and stereo video modes are not supported.

Thanks to Michael Lorenz and Jared McNeill for advice and encouragement,
and to Martin Husemann for testing.
 1.38 21-Sep-2010  macallan branches: 1.38.2;
* implement hw acceleration for putchar()
* use VCONS for copycols()
* don't map the framebuffer now that we don't access it anymore
* make a bunch of drawing engine syncs optional
 1.37 20-Aug-2009  macallan branches: 1.37.2; 1.37.4;
call vcons_replay_msgbuf() when appropriate
 1.36 16-Nov-2008  macallan make this work right with WSDISPLAY_SCROLLSUPPORT
 1.35 28-Aug-2008  martin branches: 1.35.2; 1.35.4;
use device_private() to get the softc
 1.34 13-Jun-2008  cegger branches: 1.34.2;
use device_lookup_private to get softc
 1.33 05-Apr-2008  cegger branches: 1.33.2; 1.33.4; 1.33.6; 1.33.8;
use aprint_*_dev and device_xname
OK martin
 1.32 04-Mar-2007  christos branches: 1.32.40;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.31 15-Oct-2006  martin branches: 1.31.4;
Missing initializer
 1.30 14-Sep-2006  martin branches: 1.30.2;
Vcons-ify the ffb driver, from macallan.
Also adds some redrawing when entering DDB.
 1.29 07-Sep-2006  martin branches: 1.29.2;
Remove accidently commited debug printf when unblanking, and actually
do the unblank instead.
 1.28 18-Aug-2006  martin Fix wrong prom_getoption() return value checks
 1.27 04-Jul-2006  martin branches: 1.27.2;
Initialize the "console screen" once - no matter if we are console or
not.
 1.26 15-Apr-2006  jmmv branches: 1.26.4;
Remove the getwschar and putwschar accessops from wsdisplay drivers as
requested by uwe@. These were wrong because they were receiving an
emulcookie yet they were accessops (thus having to receive an accesscookie).
Instead, just handle the WSDISPLAYIO_{GET,PUT}WSCHAR ioctls from the
driver's ioctl accessop.

As this reduces the amount of code needed to handle these operations to
two small functions in each driver, remove the WSDISPLAY_CHARFUNCS kernel
option.

Reviewed by, at least, uwe@ and macallan@. No objections in tech-kern@.
 1.25 12-Apr-2006  macallan make this compile again
 1.24 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.23 29-Mar-2006  thorpej Use device_cfdata().
 1.22 13-Feb-2006  cdi branches: 1.22.2; 1.22.4; 1.22.6;
ANSIfy: u_intN_t -> uintN_t, remove __P(), fix function definitions.
 1.21 12-Dec-2005  christos branches: 1.21.2; 1.21.4; 1.21.6;
more proc -> lwp conversions.
 1.20 11-Dec-2005  christos merge ktrace-lwp.
 1.19 04-Jul-2005  jdc branches: 1.19.2;
Only set up the console screen on the console ffb.
Fixes bug where ttyE0 ends up on the 2nd ffb.
Based on dev/sun/cgsix.c:r1.27 (from macallan@).
 1.18 31-May-2005  macallan fixed a stupid typo that chained copycols to itself
 1.17 31-May-2005  macallan added missing ffb_ras_wait()
 1.16 31-May-2005  macallan added support for virtual consoles
 1.15 31-May-2005  christos - sprinkle const
- avoid variable shadow
 1.14 27-May-2005  macallan fixed a bug in ffbfb_mmap to make XFree's sunffb driver work, added another
special case region for afbinit
 1.13 15-May-2005  martin Just ignore (and don't fail) FBIO{S,G}CURSOR.
 1.12 13-May-2005  mhitch Fill in fb_depth, fb_width, and fb_height in the fb_type info. XFree86 works
better now.
 1.11 04-May-2005  martin Make ffb take part in the /dev/fbN circus.
 1.10 04-May-2005  martin Use ansi function header style consistently.
 1.9 29-Apr-2005  martin Avoid returning -1 from ffb_ioctl() - we want EPASSTHROUGH or EIO.
 1.8 19-Jul-2004  heas branches: 1.8.4; 1.8.10;
Collect and save the FFB DAC version, which will be needed for the h/w cursor
since the Elite3d's logic is reversed. From FreeBSD.
Fix comments in wsdisplay_accessops initialisation.
 1.7 21-May-2004  heas Map the ffb's DAC register space and add support for video "blanking"
(aka WSDISPLAYIO_{S,G}VIDEO).
 1.6 21-May-2004  heas ffb wsdisplay type should be sunffb/SUNFFB
 1.5 17-Mar-2004  pk Rename PROM_getprop*() => prom_getprop*().
 1.4 17-Mar-2004  pk ffb_attach: Use prom_getoption() and drop home-grown string-to-integer
conversion code.
 1.3 15-Jul-2003  lukem __KERNEL_RCSID()
 1.2 11-Jun-2003  petrov branches: 1.2.2;
Comment out debug output.
 1.1 23-May-2003  petrov Port of OpenBSD ffb driver written by Jason L. Wright.
 1.2.2.2 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.2.2.1 03-Aug-2004  skrll Sync with HEAD
 1.8.10.11 12-Sep-2006  ghen Pull up following revision(s) (requested by martin in ticket #1507):
sys/arch/sparc64/dev/zs.c: revision 1.61
sys/arch/sparc64/dev/ffb.c: revision 1.28
Fix wrong prom_getoption() return value checks
 1.8.10.10 07-Jun-2005  tron Pull up revision 1.18 (requested by martin in ticket #376):
fixed a stupid typo that chained copycols to itself
 1.8.10.9 07-Jun-2005  tron Pull up revision 1.17 (requested by martin in ticket #376):
added missing ffb_ras_wait()
 1.8.10.8 07-Jun-2005  tron Pull up revision 1.16 (requested by martin in ticket #376):
added support for virtual consoles
 1.8.10.7 07-Jun-2005  tron Pull up revision 1.15 (requested by martin in ticket #376):
- sprinkle const
- avoid variable shadow
 1.8.10.6 07-Jun-2005  tron Pull up revision 1.14 (requested by martin in ticket #376):
fixed a bug in ffbfb_mmap to make XFree's sunffb driver work, added another
special case region for afbinit
 1.8.10.5 07-Jun-2005  tron Pull up revision 1.13 (requested by martin in ticket #376):
Just ignore (and don't fail) FBIO{S,G}CURSOR.
 1.8.10.4 07-Jun-2005  tron Pull up revision 1.12 (requested by martin in ticket #376):
Fill in fb_depth, fb_width, and fb_height in the fb_type info. XFree86 works
better now.
 1.8.10.3 07-Jun-2005  tron Pull up revision 1.11 (requested by martin in ticket #376):
Make ffb take part in the /dev/fbN circus.
 1.8.10.2 07-Jun-2005  tron Pull up revision 1.10 (requested by martin in ticket #376):
Use ansi function header style consistently.
 1.8.10.1 07-Jun-2005  tron Pull up revision 1.9 (requested by martin in ticket #376):
Avoid returning -1 from ffb_ioctl() - we want EPASSTHROUGH or EIO.
 1.8.4.1 29-Apr-2005  kent sync with -current
 1.19.2.3 03-Sep-2007  yamt sync with head.
 1.19.2.2 30-Dec-2006  yamt sync with head.
 1.19.2.1 21-Jun-2006  yamt sync with head.
 1.21.6.1 22-Apr-2006  simonb Sync with head.
 1.21.4.1 09-Sep-2006  rpaulo sync with head
 1.21.2.1 18-Feb-2006  yamt sync with head.
 1.22.6.2 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.22.6.1 31-Mar-2006  tron Merge 2006-03-31 NetBSD-current into the "peter-altq" branch.
 1.22.4.1 19-Apr-2006  elad sync with head - hopefully this will work
 1.22.2.5 14-Sep-2006  yamt sync with head.
 1.22.2.4 03-Sep-2006  yamt sync with head.
 1.22.2.3 11-Aug-2006  yamt sync with head
 1.22.2.2 24-May-2006  yamt sync with head.
 1.22.2.1 01-Apr-2006  yamt sync with head.
 1.26.4.1 13-Jul-2006  gdamore Merge from HEAD.
 1.27.2.1 21-Aug-2006  tron Pull up following revision(s) (requested by martin in ticket #34):
sys/arch/sparc64/dev/zs.c: revision 1.61
sys/arch/sparc64/dev/ffb.c: revision 1.28
Fix wrong prom_getoption() return value checks
 1.29.2.1 18-Nov-2006  ad Sync with head.
 1.30.2.1 22-Oct-2006  yamt sync with head
 1.31.4.1 12-Mar-2007  rmind Sync with HEAD.
 1.32.40.4 17-Jan-2009  mjf Sync with HEAD.
 1.32.40.3 28-Sep-2008  mjf Sync with HEAD.
 1.32.40.2 29-Jun-2008  mjf Sync with HEAD.
 1.32.40.1 02-Jun-2008  mjf Sync with HEAD.
 1.33.8.1 18-Jun-2008  simonb Sync with head.
 1.33.6.2 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.33.6.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.33.4.3 09-Oct-2010  yamt sync with head
 1.33.4.2 16-Sep-2009  yamt sync with head
 1.33.4.1 04-May-2009  yamt sync with head.
 1.33.2.1 17-Jun-2008  yamt sync with head.
 1.34.2.2 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.34.2.1 19-Oct-2008  haad Sync with HEAD.
 1.35.4.3 18-Oct-2009  bouyer back out ticket 972
 1.35.4.2 18-Oct-2009  bouyer Pull up following revision(s) (requested by macallan in ticket #972):
sys/arch/sparc64/dev/ffb.c: revision 1.37
call vcons_replay_msgbuf() when appropriate
 1.35.4.1 25-Feb-2009  snj branches: 1.35.4.1.4;
Pull up following revision(s) (requested by macallan in ticket #515):
sys/arch/sparc64/dev/ffb.c: revision 1.36
make this work right with WSDISPLAY_SCROLLSUPPORT
 1.35.4.1.4.1 21-Apr-2010  matt sync to netbsd-5
 1.35.2.1 19-Jan-2009  skrll Sync with HEAD.
 1.37.4.4 12-Jun-2011  rmind sync with head
 1.37.4.3 31-May-2011  rmind sync with head
 1.37.4.2 21-Apr-2011  rmind sync with head
 1.37.4.1 05-Mar-2011  rmind sync with head
 1.37.2.1 22-Oct-2010  uebayasi Sync with HEAD (-D20101022).
 1.38.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.42.2.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.48.6.2 29-Apr-2012  mrg sync to latest -current.
 1.48.6.1 18-Feb-2012  mrg merge to -current.
 1.48.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.48.2.2 30-Oct-2012  yamt sync with head
 1.48.2.1 17-Apr-2012  yamt sync with head
 1.52.4.2 18-May-2014  rmind sync with head
 1.52.4.1 28-Aug-2013  rmind sync with head
 1.52.2.2 03-Dec-2017  jdolecek update from HEAD
 1.52.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.55.6.4 28-Aug-2017  skrll Sync with HEAD
 1.55.6.3 05-Dec-2016  skrll Sync with HEAD
 1.55.6.2 09-Jul-2016  skrll Sync with HEAD
 1.55.6.1 22-Sep-2015  skrll Sync with HEAD
 1.57.2.2 26-Apr-2017  pgoyette Sync with HEAD
 1.57.2.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.59.2.1 02-May-2017  pgoyette Sync with HEAD - tag prg-localcount2-base1
 1.61.8.2 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.61.8.1 30-Mar-2018  pgoyette Resolve conflicts between branch and HEAD
 1.62.2.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.62.2.1 10-Jun-2019  christos Sync with HEAD
 1.65.4.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.66.8.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.15 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.14 04-Nov-2016  macallan branches: 1.14.14; 1.14.16;
set BUS_SPACE_MAP_PREFETCHABLE when mapping the SFB32 range
now using alpha fonts is actually faster than using bitmap fonts
 1.13 22-Dec-2011  macallan branches: 1.13.6; 1.13.24; 1.13.28;
support anti-aliased fonts and let the hardware do the alpha blending
 1.12 31-Oct-2011  jdc branches: 1.12.2; 1.12.6;
Add support for the WSDISPLAYIO_GET_EDID ioctl (requires passing a device_t
to ffb_attach).
 1.11 01-Jul-2011  dyoung #include <sys/bus.h> instead of <machine/bus.h>.
 1.10 03-Jun-2011  christos CFATTACH_DECL_NEW
 1.9 21-Sep-2010  macallan branches: 1.9.2; 1.9.6;
* implement hw acceleration for putchar()
* use VCONS for copycols()
* don't map the framebuffer now that we don't access it anymore
* make a bunch of drawing engine syncs optional
 1.8 11-Dec-2005  christos branches: 1.8.78; 1.8.98; 1.8.100;
merge ktrace-lwp.
 1.7 04-May-2005  martin Make ffb take part in the /dev/fbN circus.
 1.6 04-May-2005  martin Ansify.
 1.5 01-Jul-2004  heas branches: 1.5.10;
The DAC registers do not need to be mapped linearly and thus should not.
 1.4 21-May-2004  heas Map the ffb's DAC register space and add support for video "blanking"
(aka WSDISPLAYIO_{S,G}VIDEO).
 1.3 19-Mar-2004  petrov More on fbnode to prom_stdout_node rename.
 1.2 15-Jul-2003  lukem __KERNEL_RCSID()
 1.1 23-May-2003  petrov branches: 1.1.2;
Port of OpenBSD ffb driver written by Jason L. Wright.
 1.1.2.4 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.1.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.1.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.1.2.1 03-Aug-2004  skrll Sync with HEAD
 1.5.10.2 07-Jun-2005  tron Pull up revision 1.7 (requested by martin in ticket #376):
Make ffb take part in the /dev/fbN circus.
 1.5.10.1 07-Jun-2005  tron Pull up revision 1.6 (requested by martin in ticket #376):
Ansify.
 1.8.100.2 12-Jun-2011  rmind sync with head
 1.8.100.1 05-Mar-2011  rmind sync with head
 1.8.98.1 22-Oct-2010  uebayasi Sync with HEAD (-D20101022).
 1.8.78.1 09-Oct-2010  yamt sync with head
 1.9.6.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.9.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.12.6.1 18-Feb-2012  mrg merge to -current.
 1.12.2.1 17-Apr-2012  yamt sync with head
 1.13.28.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.13.24.1 05-Dec-2016  skrll Sync with HEAD
 1.13.6.1 03-Dec-2017  jdolecek update from HEAD
 1.14.16.1 10-Jun-2019  christos Sync with HEAD
 1.14.14.1 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.12 20-May-2022  andvar s/auxillary/auxiliary/ in comments.
 1.11 09-Aug-2012  macallan split ffb_putchar() into a version for mono fonts and one for anti-aliased
ones. While there use the blitter to draw the cursor and remove some waits
that are unnecessary now that characters are drawn by hardware.
 1.10 22-Dec-2011  macallan support anti-aliased fonts and let the hardware do the alpha blending
 1.9 23-Oct-2011  jdc branches: 1.9.2; 1.9.6;
Correct the VSYNC-related register definitions and rework how they are used
(only when the monitor supports composite sync). OK macallan@.
 1.8 09-May-2011  jdc Correc the "enable pedestal" register definition.
 1.7 09-Apr-2011  jdc Add EDID and video mode setting support to FFB.

Add definitions for registers related to video modes, and to DDC. Rename
other registers to be more descriptive.
Add i2c bus routines to read the EDID data via DDC.
Add routines to calculate, and to set, the video mode.

Note, that interlaced and stereo video modes are not supported.

Thanks to Michael Lorenz and Jared McNeill for advice and encouragement,
and to Martin Husemann for testing.
 1.6 14-Sep-2006  martin branches: 1.6.80; 1.6.86;
Vcons-ify the ffb driver, from macallan.
Also adds some redrawing when entering DDB.
 1.5 11-Dec-2005  christos branches: 1.5.20;
merge ktrace-lwp.
 1.4 19-Jul-2004  heas branches: 1.4.12;
Add comments for a few of the FFB registers.

From FreeBSD.
 1.3 21-May-2004  heas Map the ffb's DAC register space and add support for video "blanking"
(aka WSDISPLAYIO_{S,G}VIDEO).
 1.2 20-May-2004  heas add DAC command/value register offsets
 1.1 23-May-2003  petrov branches: 1.1.2;
Port of OpenBSD ffb driver written by Jason L. Wright.
 1.1.2.1 03-Aug-2004  skrll Sync with HEAD
 1.4.12.1 30-Dec-2006  yamt sync with head.
 1.5.20.1 18-Nov-2006  ad Sync with head.
 1.6.86.1 06-Jun-2011  jruoho Sync with HEAD.
 1.6.80.2 31-May-2011  rmind sync with head
 1.6.80.1 21-Apr-2011  rmind sync with head
 1.9.6.1 18-Feb-2012  mrg merge to -current.
 1.9.2.2 30-Oct-2012  yamt sync with head
 1.9.2.1 17-Apr-2012  yamt sync with head
 1.13 22-Dec-2011  macallan support anti-aliased fonts and let the hardware do the alpha blending
 1.12 31-Oct-2011  jdc branches: 1.12.2; 1.12.6;
Add support for the WSDISPLAYIO_GET_EDID ioctl (requires passing a device_t
to ffb_attach).
 1.11 03-Jun-2011  christos CFATTACH_DECL_NEW
 1.10 09-Apr-2011  jdc branches: 1.10.2;
Add EDID and video mode setting support to FFB.

Add definitions for registers related to video modes, and to DDC. Rename
other registers to be more descriptive.
Add i2c bus routines to read the EDID data via DDC.
Add routines to calculate, and to set, the video mode.

Note, that interlaced and stereo video modes are not supported.

Thanks to Michael Lorenz and Jared McNeill for advice and encouragement,
and to Martin Husemann for testing.
 1.9 21-Sep-2010  macallan branches: 1.9.2;
* implement hw acceleration for putchar()
* use VCONS for copycols()
* don't map the framebuffer now that we don't access it anymore
* make a bunch of drawing engine syncs optional
 1.8 14-Sep-2006  martin branches: 1.8.58; 1.8.78; 1.8.80;
Vcons-ify the ffb driver, from macallan.
Also adds some redrawing when entering DDB.
 1.7 13-Feb-2006  cdi branches: 1.7.14;
ANSIfy: u_intN_t -> uintN_t, remove __P(), fix function definitions.
 1.6 11-Dec-2005  christos branches: 1.6.2; 1.6.4; 1.6.6;
merge ktrace-lwp.
 1.5 31-May-2005  macallan branches: 1.5.2;
added support for virtual consoles
 1.4 04-May-2005  martin Make ffb take part in the /dev/fbN circus.
 1.3 19-Jul-2004  heas branches: 1.3.10;
Collect and save the FFB DAC version, which will be needed for the h/w cursor
since the Elite3d's logic is reversed. From FreeBSD.
Fix comments in wsdisplay_accessops initialisation.
 1.2 21-May-2004  heas Map the ffb's DAC register space and add support for video "blanking"
(aka WSDISPLAYIO_{S,G}VIDEO).
 1.1 23-May-2003  petrov branches: 1.1.2;
Port of OpenBSD ffb driver written by Jason L. Wright.
 1.1.2.2 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.1.2.1 03-Aug-2004  skrll Sync with HEAD
 1.3.10.2 07-Jun-2005  tron Pull up revision 1.5 (requested by martin in ticket #376):
added support for virtual consoles
 1.3.10.1 07-Jun-2005  tron Pull up revision 1.4 (requested by martin in ticket #376):
Make ffb take part in the /dev/fbN circus.
 1.5.2.2 30-Dec-2006  yamt sync with head.
 1.5.2.1 21-Jun-2006  yamt sync with head.
 1.6.6.1 22-Apr-2006  simonb Sync with head.
 1.6.4.1 09-Sep-2006  rpaulo sync with head
 1.6.2.1 18-Feb-2006  yamt sync with head.
 1.7.14.1 18-Nov-2006  ad Sync with head.
 1.8.80.3 12-Jun-2011  rmind sync with head
 1.8.80.2 21-Apr-2011  rmind sync with head
 1.8.80.1 05-Mar-2011  rmind sync with head
 1.8.78.1 22-Oct-2010  uebayasi Sync with HEAD (-D20101022).
 1.8.58.1 09-Oct-2010  yamt sync with head
 1.9.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.10.2.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.12.6.1 18-Feb-2012  mrg merge to -current.
 1.12.2.1 17-Apr-2012  yamt sync with head
 1.11 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.10 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.9 10-May-2021  thorpej branches: 1.9.4;
Associate the OpenBoot / OpenFirmware node with attached devices
at config_found() time.
 1.8 24-Apr-2021  thorpej branches: 1.8.2; 1.8.4;
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.7 04-Jan-2021  thorpej branches: 1.7.2;
malloc(9) -> kmem(9) -- just the simple, straightforward conversions for now.
 1.6 10-Nov-2019  chs branches: 1.6.8;
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.5 07-Jul-2016  msaitoh branches: 1.5.18;
KNF. Remove extra spaces. No functional change.
 1.4 10-May-2016  palle sun4v: make device interrupts work. Introduce a new intrhand_alloc() function for allocation of interrupt handlers and adapt to this. Parts from OpenBSD. ok martin@
 1.3 18-Mar-2012  mrg branches: 1.3.2; 1.3.16;
add missing __KERNEL_RCSID().
 1.2 12-Aug-2011  jdc branches: 1.2.2; 1.2.6;
Set the destination UPAID when establishing the interrupt mapping.
From eeh@.
 1.1 29-Jul-2011  mrg port the openbsd central and fhc drivers, and the clock/zs attachments.
doesn't quite work yet, crashes when central_attach() calls
config_attach() (faulting address is 0xf8000000.)
 1.2.6.1 05-Apr-2012  mrg sync to latest -current.
 1.2.2.1 17-Apr-2012  yamt sync with head
 1.3.16.2 09-Jul-2016  skrll Sync with HEAD
 1.3.16.1 29-May-2016  skrll Sync with HEAD
 1.3.2.1 03-Dec-2017  jdolecek update from HEAD
 1.5.18.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.6.8.1 03-Apr-2021  thorpej Sync with HEAD.
 1.7.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.8.4.1 31-May-2021  cjep sync with head
 1.8.2.1 13-May-2021  thorpej Sync with HEAD.
 1.9.4.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.3 18-Mar-2012  mrg add missing __KERNEL_RCSID().
 1.2 01-Aug-2011  mrg branches: 1.2.2; 1.2.6;
use device_private(). thanks to jmcneill for pointing this out.
 1.1 29-Jul-2011  mrg port the openbsd central and fhc drivers, and the clock/zs attachments.
doesn't quite work yet, crashes when central_attach() calls
config_attach() (faulting address is 0xf8000000.)
 1.2.6.1 05-Apr-2012  mrg sync to latest -current.
 1.2.2.1 17-Apr-2012  yamt sync with head
 1.3 18-Mar-2012  mrg add missing __KERNEL_RCSID().
 1.2 01-Aug-2011  mrg branches: 1.2.2; 1.2.6;
use device_private(). thanks to jmcneill for pointing this out.
 1.1 29-Jul-2011  mrg port the openbsd central and fhc drivers, and the clock/zs attachments.
doesn't quite work yet, crashes when central_attach() calls
config_attach() (faulting address is 0xf8000000.)
 1.2.6.1 05-Apr-2012  mrg sync to latest -current.
 1.2.2.1 17-Apr-2012  yamt sync with head
 1.1 29-Jul-2011  mrg port the openbsd central and fhc drivers, and the clock/zs attachments.
doesn't quite work yet, crashes when central_attach() calls
config_attach() (faulting address is 0xf8000000.)
 1.1 29-Jul-2011  mrg port the openbsd central and fhc drivers, and the clock/zs attachments.
doesn't quite work yet, crashes when central_attach() calls
config_attach() (faulting address is 0xf8000000.)
 1.12 20-Dec-2023  thorpej Remove unnecessary <sys/malloc.h>.
 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 23-Nov-2016  macallan branches: 1.9.30;
support WSDISPLAYIO_GET_FBINFO
also, use _PREFETCHABLE for rasops
 1.8 07-Jul-2016  msaitoh branches: 1.8.2;
KNF. Remove extra spaces. No functional change.
 1.7 12-Apr-2012  macallan branches: 1.7.2; 1.7.16;
- don't mess with more than 256 colour map entries
- don't assume that wscons assumes BGR
- while there enable alpha
 1.6 13-Mar-2012  elad 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.5 11-Jan-2012  macallan use rasops_init(0, 0)
 1.4 01-Jul-2011  dyoung branches: 1.4.2; 1.4.6;
#include <sys/bus.h> instead of <machine/bus.h>.
 1.3 31-Aug-2010  macallan remove shadow framebuffer support, use VCONS_DONT_READ instead
 1.2 31-Dec-2009  macallan branches: 1.2.2; 1.2.4; 1.2.6;
add WSDISPLAY_TYPE_XVR1000
 1.1 29-Dec-2009  macallan a simple fb driver for Sun XVR-1000 boards
 1.2.6.1 05-Mar-2011  rmind sync with head
 1.2.4.3 09-Oct-2010  yamt sync with head
 1.2.4.2 11-Mar-2010  yamt sync with head
 1.2.4.1 31-Dec-2009  yamt file gfb.c was added on branch yamt-nfs-mp on 2010-03-11 15:03:00 +0000
 1.2.2.1 22-Oct-2010  uebayasi Sync with HEAD (-D20101022).
 1.4.6.3 29-Apr-2012  mrg sync to latest -current.
 1.4.6.2 05-Apr-2012  mrg sync to latest -current.
 1.4.6.1 18-Feb-2012  mrg merge to -current.
 1.4.2.1 17-Apr-2012  yamt sync with head
 1.7.16.2 05-Dec-2016  skrll Sync with HEAD
 1.7.16.1 09-Jul-2016  skrll Sync with HEAD
 1.7.2.1 03-Dec-2017  jdolecek update from HEAD
 1.8.2.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.9.30.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.2 05-Sep-1998  pk Remove unused files.
 1.1 20-Jun-1998  eeh branches: 1.1.1;
Initial revision
 1.1.1.1 20-Jun-1998  eeh Import of sparc64.
 1.2 05-Sep-1998  pk Remove unused files.
 1.1 20-Jun-1998  eeh branches: 1.1.1;
Initial revision
 1.1.1.1 20-Jun-1998  eeh Import of sparc64.
 1.6 05-Sep-1998  pk Remove unused files.
 1.5 15-Aug-1998  mycroft Make copyright notices with my name consistent.
 1.4 13-Aug-1998  eeh Merge paddr_t changes into the main branch.
 1.3 05-Jul-1998  jonathan branches: 1.3.2;
defopt NS, NSIP.
 1.2 05-Jul-1998  jonathan defopt INET, NETATALK.
 1.1 20-Jun-1998  eeh branches: 1.1.1;
Initial revision
 1.1.1.1 20-Jun-1998  eeh Import of sparc64.
 1.3.2.1 30-Jul-1998  eeh Split vm_offset_t and vm_size_t into paddr_t, psize_t, vaddr_t, and vsize_t.
 1.2 05-Sep-1998  pk Remove unused files.
 1.1 20-Jun-1998  eeh branches: 1.1.1;
Initial revision
 1.1.1.1 20-Jun-1998  eeh Import of sparc64.
 1.7 05-Sep-1998  pk Remove unused files.
 1.6 27-Aug-1998  mrg remove sparc64 "options BUS_DMA" -- it is now standard
 1.5 15-Aug-1998  mycroft Assign my copyrights to TNF.
 1.4 13-Aug-1998  eeh Merge paddr_t changes into the main branch.
 1.3 21-Jul-1998  drochner branches: 1.3.2;
adapt to LANCE driver split
 1.2 07-Jul-1998  eeh General update:

Added genassym.cf
Removed lderr which should never have gotten in
Removed lots of dead code from locore.s
Added some softint stuff to intr.c
Added support for halt -p
esp and le both use bus_dmamap_*() functions now
instead of kdvma_mapin()
groundwork for PCI (but we still have no drivers for
any sun4u PCI devices)
 1.1 20-Jun-1998  eeh branches: 1.1.1;
Initial revision
 1.1.1.1 20-Jun-1998  eeh Import of sparc64.
 1.3.2.1 30-Jul-1998  eeh Split vm_offset_t and vm_size_t into paddr_t, psize_t, vaddr_t, and vsize_t.
 1.3 05-Sep-1998  pk Remove unused files.
 1.2 15-Aug-1998  mycroft Assign my copyrights to TNF.
 1.1 20-Jun-1998  eeh branches: 1.1.1;
Initial revision
 1.1.1.1 20-Jun-1998  eeh Import of sparc64.
 1.3 05-Sep-1998  pk Remove unused files.
 1.2 15-Aug-1998  mycroft Assign my copyrights to TNF.
 1.1 20-Jun-1998  eeh branches: 1.1.1;
Initial revision
 1.1.1.1 20-Jun-1998  eeh Import of sparc64.
 1.119 20-Dec-2023  thorpej Remove unnecessary <sys/malloc.h>.
 1.118 08-Dec-2023  thorpej Change one vmem_free() in an error path that should be vmem_xfree().
 1.117 01-Dec-2023  thorpej Use vmem(9) rather than extent(9) to manage DVMA mappings.
 1.116 26-Apr-2021  mrg iommu_enter() and iommu_remove() are static to iommu.c.
 1.115 09-Feb-2019  mrg branches: 1.115.16;
on tomatillo unload the map before flushing the iommu, instead of
the reverse. from opensolaris.
 1.114 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.113 07-Mar-2016  christos branches: 1.113.16; 1.113.18;
Better to panic! Otherwise we end in an endless loop.
 1.112 07-Mar-2016  christos Return instead of crashing. This is wrong, and should be fixed properly.
 1.111 07-Mar-2016  christos Don't throw us in the debugger!
 1.110 06-Sep-2015  nakayama Fix build w/o options SUN4V.
 1.109 03-Sep-2015  palle sun4v: iommu setup seems to work now - device detection is now possible - parts from OpenBSD - ok mrg@, martin@
 1.108 24-Aug-2014  palle branches: 1.108.2;
Initialize IOMMU control and status register properly - from OpenBSD - ok mrg@
 1.107 25-Mar-2012  mrg branches: 1.107.2;
replace splhigh() usage with an IPL_HIGH mutex.
 1.106 27-Jan-2012  para converting extent(9) from malloc(9) to kmem(9)
preceding kmem-vmem-pool-uvm patch

releng@ acknowledged
 1.105 08-Oct-2011  nakayama branches: 1.105.2; 1.105.6;
Fix namespace confilicts membar_ops(3) vs. macros for SPARC V9
membar instructions.
 1.104 01-Jul-2011  dyoung #include <sys/bus.h> instead of <machine/bus.h>.
 1.103 20-Mar-2011  mrg re-add most of the pryo-supporting code, and some general clean up:
- handle setting tsb size in the ptsb via IOMMU_TSBSIZE_IN_PTSB (partly from
openbsd)
- fix IDB_INFO for systems without a STC that fault on accesses to the
flush register (like pyro)
- move iommu_reset() to the end of iommu_init()
- use IOMMUREG_WRITE() in a few places
- add a missing membar_lookaside() (from openbsd)
- if pmap_extract() on the flush buffer fails, disable flushing (from openbsd)
- flush the pyro-style iommu when IOMMU_FLUSH_CACHE is set (partly from openbsd)
- clear up a bit of debugging code so it spew a little less (sometimes you will
get kernel lock spinouts due to long scrolling printfs)
- use __func__ in several places
 1.102 16-Mar-2011  mrg revert the iommu changes for now. my U60 doesn't like them.
 1.101 16-Mar-2011  mrg various changes to adapt for Fire controller support, based upon the
openbsd code to do the same:

- add the tsb size into the ptsb bits
- avoid setting tsbsize in the CR
- disable IDB_INFO for now; it crashes
- add new macros for reading/writing IOMMU registers (need to use
these more regularly across the whole file)
- add a missing membar #lookaside
- add support for flushing the pyro(4) caches
- extend struct iommureg to include everything pyro
 1.100 06-Nov-2010  uebayasi branches: 1.100.2;
Machine dependent code is considered as part of UVM. Include
internal API header.
 1.99 17-Jun-2010  mrg in iommu_remove() don't invalidate the IOMMU mapping. for reasons not
yet determined, some PCI devices (at least fxp(4) and re(4)) sometimes
appear to perform DMA operations while this is happening, and we get
uncorrectable DMA errors. ideally, this "shouldn't happen", but none
of the investigation so far has reveal the problem, and my source
investigation of both opensolaris and linux show that their perform
the invaliation when unmapping.

"handles" PR#43274 as well as other issues...

XXX: candidate for netbsd-5
 1.98 11-Mar-2010  mrg branches: 1.98.2;
various aprint_* fixes.
 1.97 24-Feb-2010  skrll Typo in comment
 1.96 10-Dec-2009  nakayama branches: 1.96.2;
iommu_dvmamap_load:
Split a segment if its size is larger than dm_maxsegsz.

iommu_dvmamap_load_raw:
Don't coalesce segments if total size is larger than dm_maxsegsz.

This should fix port-sparc64/35299.
 1.95 07-Dec-2009  nakayama Print the warning message if extent_free fails.
 1.94 07-Dec-2009  nakayama Add comment about an uncorrectable DMA error sometimes observed on
tlp(4) on Netra X1, and its workaround.

Also add membar_storestore, from OpenBSD.
 1.93 07-Dec-2009  nakayama Calculate DVMA pages correctly.
 1.92 07-Dec-2009  nakayama Avoid use of iommu_dvmamap_unload in error path. It is too
expensive since it contains data cache flushing.

Some driver (tlp(4) with DM9201 on Netra X1) can only handle one
DMA segment, so it was called frequently.
 1.91 06-Dec-2009  nakayama Call iommu_strbuf_flush_done every iommu_enter is too expensive,
so call it once if needed.
 1.90 06-Dec-2009  nakayama Make is_dvmaend point to the last DVMA map address not the next
address, and fix off by one errors.

Also, do some optimization.
 1.89 05-Dec-2009  jdc Avoid a panic if we are asked to sync a zero-length map, by returning
immediately.
 1.88 07-Nov-2009  cegger Add a flags argument to pmap_kenter_pa(9).
Patch showed on tech-kern@ http://mail-index.netbsd.org/tech-kern/2009/11/04/msg006434.html
No objections.
 1.87 24-Oct-2009  nakayama Use trunc_page or round_page where appropriate.
No functional changes intended, and generate same binaries.
 1.86 15-Feb-2009  martin fix the formats of a debug printf for the time_t changes.
 1.85 18-Oct-2008  nakayama branches: 1.85.2; 1.85.8;
It is wasteful that reconstructing arguments for inserting the pointer
to streaming buffers in each bus_dma functions on sbus/psycho layer.

Use iommu functions directly with storing the pointer into (unused)
_dm_cookie at bus_dmamap_create time.
 1.84 13-Oct-2008  nakayama Remove unnecessary includes.
 1.83 04-Jun-2008  ad branches: 1.83.4;
vm_page: put TAILQ_ENTRY into a union with LIST_ENTRY, so we can use both.
 1.82 30-May-2008  mrg convert the rest of my licenses to 2-clause, extracting myself out
from a group as necessary.

bozohttpd remains, but it will get fixed next time i update it.
 1.81 04-Mar-2007  christos branches: 1.81.40; 1.81.42; 1.81.44; 1.81.46;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.80 01-Sep-2006  mrg branches: 1.80.8;
s/E2BIG/EFBIG/ for bus_dma(9) errors. this is what every other
bus_dma does and several drivers depend on it. in particular,
both re(4) and ath(4) would both spew "can't map mbuf" messages
as rapidly as possible (spamming the 9600 bps console) and
effectively locking up the interface until ifconfig "down up"
cycle was run. with this fix, i get a much, much slower spew
of messages, and the interface (re(4)) continues to operate.
 1.79 13-Feb-2006  cdi branches: 1.79.2; 1.79.12;
ANSIfy: u_intN_t -> uintN_t, remove __P(), fix function definitions.
 1.78 11-Feb-2006  cdi ANSIfication: u_intN_t -> uintN_t, use ANSI function declarations/definitions
instead of K&R ones.
 1.77 24-Nov-2005  yamt branches: 1.77.2; 1.77.4; 1.77.6;
bus_dmamem_map: honour BUS_DMA_NOWAIT. noted by Manuel Bouyer.
bus_space_map: always do NOWAIT allocation as it used to be before yamt-km.

we have too many copies!
 1.76 01-Apr-2005  yamt branches: 1.76.2; 1.76.8;
merge yamt-km branch.
- don't use managed mappings/backing objects for wired memory allocations.
save some resources like pv_entry. also fix (most of) PR/27030.
- simplify kernel memory management API.
- simplify pmap bootstrap of some ports.
- some related cleanups.
 1.75 01-Jul-2004  petrov branches: 1.75.4; 1.75.6;
iommu_dvma_load_raw: reserve extra dvma page. Fixes PR #13654.
 1.74 03-Jun-2004  petrov Add DIAGNOSTIC in iommu_dvmamap_load if pmap_extract fails.
 1.73 22-Mar-2004  nakayama branches: 1.73.2;
Make 32-bit kernels compile with options DIAGNOSTIC.
 1.72 13-Feb-2004  snj s/rediculous/ridiculous/
 1.71 16-Nov-2003  tsutsui Fix address calculation for split segment address when the buffer is
crossing boundary in iommu_dvmamap_load().
Fixes E2BIG error on dmamap with smaller boundary size than maxxfersize
(which is used by recent changed pcscp(4)).

While here, some KNF around debug printf etc.
 1.70 26-Oct-2003  christos Actually initialize the size that is printed in case of an error, so garbage
does not get printed.
 1.69 21-Oct-2003  petrov don't use NULL for u_long initialization.
 1.68 15-Sep-2003  martin Make a panic format 32bit safe.
 1.67 08-Sep-2003  petrov Support multisegment dmamap sync, adopted from OpenBSD.
 1.66 15-Jul-2003  lukem __KERNEL_RCSID()
 1.65 17-May-2003  nakayama branches: 1.65.2;
Avoid comparison is always false warnings in gcc 3.3 w/ 32-bit kernels.
 1.64 01-Apr-2003  thorpej Use PAGE_SIZE rather than NBPG.
 1.63 16-Jan-2003  petrov Don't do anything if there are no streaming buffer cache.
 1.62 24-Oct-2002  petrov Remove duplicate code in iommu_dvmamap_sync.
 1.61 16-Oct-2002  martin Make 32bit sparc64 kernels with DEBUG and DIAGNOSTIC compile.
 1.60 13-Oct-2002  petrov rearrange streming cache flushes in iommu_dvmamap_sync
 1.59 28-Sep-2002  martin Fix broken timeval comparison.
Reported by Takeshi Nakayama in PR sparc64/18453, but fixed a bit
differently.
 1.58 22-Sep-2002  chs many improvements:
- use struct vm_page_md for attaching pv entries to struct vm_page
- change pseg_set()'s return value to indicate whether the spare page
was used as an L2 or L3 PTP.
- use a pool for pv entries instead of malloc().
- put PTPs on a list attached to the pmap so we can free them
more efficiently (by just walking the list) in pmap_destroy().
- use the new pmap_remove_all() interface to avoid flushing the cache and TLB
for each pmap_remove() that's done as we are tearing down an address space.
- in pmap_enter(), handle replacing an existing mapping more efficiently
than just calling pmap_remove() on it. also, skip flushing the
TSB and TLB if there was no previous mapping, since there can't be
anything we need to flush. also, preload the TSB if we're pre-setting
the mod/ref bits.
- allocate hardware contexts like the MIPS pmap:
allocate them all sequentially without reuse, then once we run out
just invalidate all user TLB entries and flush the entire L1 dcache.
- fix pmap_extract() for the case where the va is not page-aligned and
nothing is mapped there.
- fix calculation of TSB size. it was comparing physmem (which is
in units of pages) to constants that only make sense if they are
in units of bytes.
- avoid sleeping in pmap_enter(), instead let the caller do it.
- use pmap_kenter_pa() instead of pmap_enter() where appropriate.
- remove code to handle impossible cases in various functions.
- tweak asm code to pipeline a little better.
- remove many unnecessary spls and membars.
- lots of code cleanup.
- no doubt other stuff that I've forgotten.

the result of all this is that a fork+exit microbenchmark is 34% faster
and a fork+exec+exit microbenchmark is 28% faster.
 1.57 29-Aug-2002  chs wrap Debugger() in #ifdef DDB. fixes PR 15881.
 1.56 24-Jun-2002  eeh Fix compilation problems in DEBUG code.
 1.55 20-Jun-2002  eeh Overhaul streaming buffer handling:

sysio streaming buffer flushes write a single 8-byte aligned 8-byte
value.

psycho streaming buffer flushes write a 64-byte aligned 64-byte block.

So separate out the streaming buffers into their own structure and pass those
in to all iommu operations. This also means we only flush the correct
streaming buffer for psycho rather than needing to flush both just in case.
 1.54 14-Jun-2002  eeh NEVER CAST REFERENCE PARAMETERS!!!!!
 1.53 12-Jun-2002  eeh Fix some corner cases in bus_dmamap_load_mbuf().
From Takeshi Nakayama <tn@catvmics.ne.jp>
 1.52 02-Jun-2002  drochner move initialization of the "struct pglist" returned by uvm_pglistalloc()
from the calling code into uvm_pglistalloc() itself for consistency
and easier error handling
 1.51 13-May-2002  eeh branches: 1.51.2; 1.51.4;
Fix off-by-one error in iommu_dvmamap_load_raw() where if a DMA segment
has just one byte on a page the page is never mapped into the IOMMU.
 1.50 20-Mar-2002  eeh Overhaul bus space.

bus_space_handle_t now holds an address and two ASIs, one for normal accesses
and one for streaming accesses. This allows to map individual handles
different ways, so some can use MMU bypass accesses and others use virtual
addresses. bus_space_map() will now create handles that use bypass accesses
unles BUS_SPACE_MAP_LINEAR is passed in. So only pass in BUS_SPACE_MAP_LINEAR
if you absolutely *need* to use bus_space_vaddr(). This removes at least one
extra level of indirection and should reduce TLB misses.

32-bit kernels have problems accessing 64-bit addresses, so they always use
virtual addresses.
 1.49 06-Mar-2002  tsutsui Fix calculation of dma segment length
when the DVMA range is crossing the boundary.
Approved by eeh, and fixes port-sparc64/15200.
 1.48 21-Feb-2002  eeh Fix pr sparc64/15633: datafault at tlp_start causes panic
Also clean up some additional 32-bit kernel printf issues.
 1.47 08-Feb-2002  eeh Handle the case where a DMA operation wraps from the end of a page to the
beginning of the same page properly by double-mapping that page.
 1.46 08-Feb-2002  eeh Move a brace so this will compile w/o DEBUG.
 1.45 07-Feb-2002  eeh Overhaul iommu_dvmamap_load_raw().
 1.44 17-Oct-2001  thorpej branches: 1.44.4;
Fix a typo in a DIAGNOSTIC check.
 1.43 08-Oct-2001  eeh Clear the dmamap inside splhigh() protection.
 1.42 07-Oct-2001  eeh Manage both streaming caches on psycho/psycho+.
 1.41 28-Sep-2001  chs don't depend on other headers to include sys/proc.h for us.
 1.40 21-Sep-2001  eeh Handle DMA boundaries a bit better.
 1.39 15-Sep-2001  eeh Added iommu_extract() for debug purposes.
Anyone caught using it for anything other than debug will be shot.
 1.38 10-Sep-2001  chris Update pmap_update to now take the updated pmap as an argument.
This will allow improvements to the pmaps so that they can more easily defer expensive operations, eg tlb/cache flush, til the last possible moment.

Currently this is a no-op on most platforms, so they should see no difference.

Reviewed by Jason.
 1.37 06-Aug-2001  eeh branches: 1.37.2;
Fix bug involving small, non-contiguous dma segments.
From Manuel Bouyer.
 1.36 20-Jul-2001  eeh PCI overhaul.
 1.35 26-May-2001  chs branches: 1.35.2;
replace vm_page_t with struct vm_page *.
 1.34 18-May-2001  mrg move the sbus IOMMU work around into the sbus code, so that the psycho
doesn't have to lose a page.
 1.33 24-Apr-2001  thorpej Sprinkle pmap_update() calls after calls to:
- pmap_enter()
- pmap_remove()
- pmap_protect()
- pmap_kenter_pa()
- pmap_kremove()
as described in pmap(9).

These calls are relatively conservative. It may be possible to
optimize these a little more.
 1.32 09-Mar-2001  thorpej Pay attention to BUS_DMA_STREAMING when builing an IOMMU TTE.
 1.31 24-Feb-2001  eeh branches: 1.31.2;
Improve legibility and iommu_dvmamap_sync().
 1.30 06-Feb-2001  eeh Fix D$ aliasing issues in a DIAGNOSTIC check.
 1.29 28-Jan-2001  martin Faster error handling for iommu_dmamap_load_raw; avoid loading the map
and unloading on error when we clearly can't get out without an error.
 1.28 27-Jan-2001  eeh Fix dvma problem caused by previous. Seems like the dvma segment calculation
in iommu_dmamap_unload() was not quite right.
 1.27 25-Jan-2001  martin iommu_dvmamap_load_raw: add a check for creating maps larger than
expected by the creator of the dma map and fail apropriately. This
makes the syssrc/dev/pci/if_vr.c driver work.
 1.26 23-Jan-2001  martin Make bus_dmamap_load_mbuf and bus_dmamap_load_uio use independend
segment lists for their mapping; make iommu_dmamap_unload deal with
this type of maps.

Coded by Eduardo, tested (and minimaly tweaked) by me.
 1.25 06-Dec-2000  mrg fix warnings in DEBUG & DIAGNSTIC code.
 1.24 28-Sep-2000  eeh Don't take ref/mod faults on DMA segments mapped in to the kernel.
 1.23 01-Aug-2000  eeh Call the parent bus dvmamap_unload function to clear the cache rather
than do it ourselves.
 1.22 07-Jul-2000  mrg split up debug flags so i can turn off some of them
 1.21 07-Jul-2000  eeh Handle bus_dma aligment properly.
 1.20 02-Jul-2000  mrg iommu_dvmamap_load*(), pass an alignment constraint, as well as
EX_BOUNDZERO, to extent_alloc(). this fixes problems with it
(extent_alloc()) returning incorrect values, when the start of
the extent is not aligned as strongly as the requested area..

raw access to ide disks now works.
 1.19 29-Jun-2000  mrg remove include of <vm/vm.h>. <vm/vm.h> -> <uvm/uvm_extern.h>
 1.18 26-Jun-2000  mrg remove/move more mach vm header files:

<vm/pglist.h> -> <uvm/uvm_pglist.h>
<vm/vm_inherit.h> -> <uvm/uvm_inherit.h>
<vm/vm_kern.h> -> into <uvm/uvm_extern.h>
<vm/vm_object.h> -> nothing
<vm/vm_pager.h> -> into <uvm/uvm_pager.h>

also includes a bunch of <vm/vm_page.h> include removals (due to redudancy
with <vm/vm.h>), and a scattering of other similar headers.
 1.17 24-Jun-2000  eeh With these changes the kernel seems almost stable again.
 1.16 22-Jun-2000  eeh Correct calculation of length for dma segments in iommu_dmamap_load().
 1.15 19-Jun-2000  eeh branches: 1.15.2;
Have separate data and text segments, make text read-only.
 1.14 18-Jun-2000  mrg iommu_flush becomes iommu_strbuf_flush cuz that's what it does.
 1.13 18-Jun-2000  mrg remove an unused variable.
 1.12 12-Jun-2000  mrg formatting nit.
 1.11 08-Jun-2000  eeh Support large (>1 page) DVMA maps so UltraSPARC IIi will work.
 1.10 17-May-2000  mrg branches: 1.10.2;
- in iommu_remove(), move len adjustment outside if statement, leaving
just one copy of this.
- remove duplicate setting of sgsize in iommu_dvmamap_load().
- fix DIAGNOSTIC check in iommu_dvmamap_load_raw() to panic() in unexpected
conditions only (not normal ones), and also add an extra case.
 1.9 17-May-2000  eeh Add support for bus_dma_load_raw() so the le driver will work again.
 1.8 25-Apr-2000  mrg - add a note about streaming buffers and US IIi not having them.
- make some debugging messages in iommu_remove() saner and add some more.
- decrement 'len' in the no streaming buffer case, also.
- in iommu_dvmamem_map(), do not enter these mappings into the IOMMU,
only into the CPU (the former is done at _load time).
- make a panic that shouldn't happen a DIAGNOSTIC.
 1.7 22-Apr-2000  mrg whole bunch of changes:
- merge IOMMU DVMA code from sbus/psycho into iommu.c. this code was
identical and a few minor inconsistencies had crept in. this way
keeps them all in sync.
- with this code gone from psycho, merge the psycho.c and psycho_bus.c
files. same with ebus/ebus_bus.c. delete the _bus.c files.
- add a _ds_boundary member to the dma segment structure, so that later
dma mappings can find this value.
- set _ds_boundary in machdep.c:_bus_dmamem_alloc().
- kill much dead code.
 1.6 08-Apr-2000  mrg with these two, POWEROFSEVEN now compiles cleanly.
 1.5 05-Apr-2000  mrg after enabling the streaming buffer, check to see that it is actually
there and enabled. if it appears to be missing or not enabled, do
not use it.
 1.4 05-Apr-2000  mrg use DPRINTF() style debug messages; s/sbus/iommu/ in a few remaining places.
 1.3 08-Jul-1999  thorpej branches: 1.3.2;
Change the pmap_extract() interface to:
boolean_t pmap_extract(pmap_t, vaddr_t, paddr_t *);
This makes it possible for the pmap to map physical address 0.
 1.2 20-Jun-1999  eeh branches: 1.2.2;
Move the DVMA mapin/mapout functions from the SBus driver to the iommu driver.
 1.1 04-Jun-1999  mrg pull iommu code out of sbus code so we can share it with the PCI.
define some useful PCI macros.
 1.2.2.3 02-Aug-1999  thorpej Update from trunk.
 1.2.2.2 21-Jun-1999  thorpej Sync w/ -current.
 1.2.2.1 20-Jun-1999  thorpej file iommu.c was added on branch chs-ubc2 on 1999-06-21 01:02:30 +0000
 1.3.2.4 12-Mar-2001  bouyer Sync with HEAD.
 1.3.2.3 11-Feb-2001  bouyer Sync with HEAD.
 1.3.2.2 08-Dec-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.10.2.1 22-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.15.2.2 07-Aug-2000  mrg pullup 1.23 (approved by thorpej):
>Call the parent bus dvmamap_unload function to clear the cache rather
>than do it ourselves.
 1.15.2.1 18-Jul-2000  mrg pullup the contents of -current arch/sparc64. this gives us significant
ultrasparc PCI support (ultra5, ultra10, AXi, and E250 tested so far),
plus many other small fixes. netbooting is now supported.
 1.31.2.2 21-Jun-2001  nathanw Catch up to -current.
 1.31.2.1 09-Apr-2001  nathanw Catch up with -current.
 1.35.2.8 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.35.2.7 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.35.2.6 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.35.2.5 16-Mar-2002  jdolecek Catch up with -current.
 1.35.2.4 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.35.2.3 13-Sep-2001  thorpej Update the kqueue branch to HEAD.
 1.35.2.2 25-Aug-2001  thorpej Merge Aug 24 -current into the kqueue branch.
 1.35.2.1 03-Aug-2001  lukem update to -current
 1.37.2.2 11-Oct-2001  fvdl Catch up with -current. Fix some bogons in the sparc64 kbd/ms
attach code. cd18xx conversion provided by mrg.
 1.37.2.1 01-Oct-2001  fvdl Catch up with -current.
 1.44.4.9 17-Jan-2003  thorpej Sync with HEAD.
 1.44.4.8 11-Nov-2002  nathanw Catch up to -current
 1.44.4.7 18-Oct-2002  nathanw Catch up to -current.
 1.44.4.6 17-Sep-2002  nathanw Catch up to -current.
 1.44.4.5 01-Aug-2002  nathanw Catch up to -current.
 1.44.4.4 20-Jun-2002  nathanw Catch up to -current.
 1.44.4.3 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.44.4.2 28-Feb-2002  nathanw Catch up to -current.
 1.44.4.1 17-Oct-2001  nathanw file iommu.c was added on branch nathanw_sa on 2002-02-28 04:12:11 +0000
 1.51.4.6 01-Dec-2002  he Pull up revision 1.59 (requested by martin in ticket #874):
Fix broken timeval comparison. Fixes PR#18453.
 1.51.4.5 08-Nov-2002  tron Pull up revision 1.61 (via patch, requested by martin in ticket #916):
Make 32bit sparc64 kernels with DEBUG and DIAGNOSTIC compile.
 1.51.4.4 24-Jun-2002  lukem Pull up revision 1.56 (requested by eeh in ticket #361):
Fix compilation problems in DEBUG code.
 1.51.4.3 21-Jun-2002  lukem Pull up revision 1.55 (requested by eeh in ticket #337):
Overhaul streaming buffer handling:
sysio streaming buffer flushes write a single 8-byte aligned 8-byte
value.
psycho streaming buffer flushes write a 64-byte aligned 64-byte block.
So separate out the streaming buffers into their own structure and pass those
in to all iommu operations. This also means we only flush the correct
streaming buffer for psycho rather than needing to flush both just in case.
[Gets E220R working]
 1.51.4.2 14-Jun-2002  lukem Pull up revision 1.54 (requested by eeh in ticket #271):
NEVER CAST REFERENCE PARAMETERS!!!!!
 1.51.4.1 13-Jun-2002  lukem Pull up revision 1.53 (requested by eeh in ticket #258):
Fix some corner cases in bus_dmamap_load_mbuf().
From Takeshi Nakayama <tn@catvmics.ne.jp>
 1.51.2.3 31-Aug-2002  gehenna catch up with -current.
 1.51.2.2 17-Jul-2002  gehenna catch up with -current.
 1.51.2.1 15-Jul-2002  gehenna catch up with -current.
 1.65.2.5 11-Dec-2005  christos Sync with head.
 1.65.2.4 01-Apr-2005  skrll Sync with HEAD.
 1.65.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.65.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.65.2.1 03-Aug-2004  skrll Sync with HEAD
 1.73.2.1 02-Jul-2004  he Pull up revision 1.75 (requested by petrov in ticket #576):
Reserve extra dvma page in iommu_dvma_load_raw(). Fixes
PR#13654.
 1.75.6.1 12-Feb-2005  yamt use new apis.
 1.75.4.1 29-Apr-2005  kent sync with -current
 1.76.8.1 29-Nov-2005  yamt sync with head.
 1.76.2.3 03-Sep-2007  yamt sync with head.
 1.76.2.2 30-Dec-2006  yamt sync with head.
 1.76.2.1 21-Jun-2006  yamt sync with head.
 1.77.6.1 22-Apr-2006  simonb Sync with head.
 1.77.4.1 09-Sep-2006  rpaulo sync with head
 1.77.2.1 18-Feb-2006  yamt sync with head.
 1.79.12.1 03-Sep-2006  riz Pull up following revision(s) (requested by mrg in ticket #109):
sys/arch/sparc64/sparc64/machdep.c: revision 1.188
sys/arch/sparc64/dev/iommu.c: revision 1.80
s/E2BIG/EFBIG/ for bus_dma(9) errors. this is what every other
bus_dma does and several drivers depend on it. in particular,
both re(4) and ath(4) would both spew "can't map mbuf" messages
as rapidly as possible (spamming the 9600 bps console) and
effectively locking up the interface until ifconfig "down up"
cycle was run. with this fix, i get a much, much slower spew
of messages, and the interface (re(4)) continues to operate.
 1.79.2.1 03-Sep-2006  yamt sync with head.
 1.80.8.1 12-Mar-2007  rmind Sync with HEAD.
 1.81.46.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.81.44.3 11-Aug-2010  yamt sync with head.
 1.81.44.2 11-Mar-2010  yamt sync with head
 1.81.44.1 04-May-2009  yamt sync with head.
 1.81.42.2 17-Jun-2008  yamt sync with head.
 1.81.42.1 04-Jun-2008  yamt sync with head
 1.81.40.3 17-Jan-2009  mjf Sync with HEAD.
 1.81.40.2 05-Jun-2008  mjf Sync with HEAD.

Also fix build.
 1.81.40.1 02-Jun-2008  mjf Sync with HEAD.
 1.83.4.1 19-Oct-2008  haad Sync with HEAD.
 1.85.8.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.85.2.1 03-Mar-2009  skrll Sync with HEAD.
 1.96.2.3 17-Aug-2010  uebayasi Sync with HEAD.
 1.96.2.2 27-May-2010  uebayasi Fix build.
 1.96.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.98.2.3 21-Apr-2011  rmind sync with head
 1.98.2.2 05-Mar-2011  rmind sync with head
 1.98.2.1 03-Jul-2010  rmind sync with head
 1.100.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.105.6.2 05-Apr-2012  mrg sync to latest -current.
 1.105.6.1 18-Feb-2012  mrg merge to -current.
 1.105.2.1 17-Apr-2012  yamt sync with head
 1.107.2.1 03-Dec-2017  jdolecek update from HEAD
 1.108.2.2 19-Mar-2016  skrll Sync with HEAD
 1.108.2.1 22-Sep-2015  skrll Sync with HEAD
 1.113.18.1 10-Jun-2019  christos Sync with HEAD
 1.113.16.1 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.115.16.1 13-May-2021  thorpej Sync with HEAD.
 1.21 24-Aug-2016  mrg use uint64_t consistently.
 1.20 24-Aug-2014  palle branches: 1.20.2;
Initialize IOMMU control and status register properly - from OpenBSD - ok mrg@
 1.19 20-Mar-2011  mrg branches: 1.19.14;
define 'struct iommureg2', that includes the full set of regs for the
schizo and pyro iommu's. use these in IOMMUREG().

add back IOMMUREG_READ() and IOMMUREG_WRITE() macros.
 1.18 16-Mar-2011  mrg revert the iommu changes for now. my U60 doesn't like them.
 1.17 16-Mar-2011  mrg add back the old iommureg definition, as iommureg_old.
 1.16 16-Mar-2011  mrg various changes to adapt for Fire controller support, based upon the
openbsd code to do the same:

- add the tsb size into the ptsb bits
- avoid setting tsbsize in the CR
- disable IDB_INFO for now; it crashes
- add new macros for reading/writing IOMMU registers (need to use
these more regularly across the whole file)
- add a missing membar #lookaside
- add support for flushing the pyro(4) caches
- extend struct iommureg to include everything pyro
 1.15 07-Dec-2008  mrg branches: 1.15.8; 1.15.10;
add INTMAP_IGN_SHIFT and INTIGN() macros for schizo support (from openbsd)
 1.14 13-Feb-2006  cdi branches: 1.14.68; 1.14.72; 1.14.78; 1.14.80;
ANSIfy: u_intN_t -> uintN_t, remove __P(), fix function definitions.
 1.13 11-Dec-2005  christos branches: 1.13.2; 1.13.4; 1.13.6;
merge ktrace-lwp.
 1.12 23-Apr-2004  simonb branches: 1.12.12;
s/the the/the/ (only in sources that aren't regularly imported from
elsewhere).
 1.11 11-Oct-2003  petrov When establishing interrupt set CPU_UPAID in mapping register
so that interrupt would be delivered.
 1.10 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.9 06-Jan-2003  wiz branches: 1.9.2;
writable, not writeable.
 1.8 20-Mar-2002  eeh Overhaul bus space.

bus_space_handle_t now holds an address and two ASIs, one for normal accesses
and one for streaming accesses. This allows to map individual handles
different ways, so some can use MMU bypass accesses and others use virtual
addresses. bus_space_map() will now create handles that use bypass accesses
unles BUS_SPACE_MAP_LINEAR is passed in. So only pass in BUS_SPACE_MAP_LINEAR
if you absolutely *need* to use bus_space_vaddr(). This removes at least one
extra level of indirection and should reduce TLB misses.

32-bit kernels have problems accessing 64-bit addresses, so they always use
virtual addresses.
 1.7 07-Feb-2002  eeh Overhaul iommu_dvmamap_load_raw().
 1.6 20-Jul-2001  eeh branches: 1.6.6;
PCI overhaul.
 1.5 12-Jun-2000  eeh branches: 1.5.6;
Comment describing the IOMMU DVMA address space layout.
 1.4 08-Jun-2000  eeh Fix DVMA base address calculations.
 1.3 04-Jun-1999  mrg branches: 1.3.2; 1.3.4; 1.3.12;
pull iommu code out of sbus code so we can share it with the PCI.
define some useful PCI macros.
 1.2 24-May-1999  mrg pull struct strbuf + defines into iommureg.h. properly merge previous commit.
 1.1 23-May-1999  mrg place iommu definitions in iommureg.h
 1.3.12.1 22-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.3.4.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-1999  thorpej Sync w/ -current.
 1.5.6.3 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.5.6.2 16-Mar-2002  jdolecek Catch up with -current.
 1.5.6.1 03-Aug-2001  lukem update to -current
 1.6.6.4 07-Jan-2003  thorpej Sync with HEAD.
 1.6.6.3 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.6.6.2 28-Feb-2002  nathanw Catch up to -current.
 1.6.6.1 20-Jul-2001  nathanw file iommureg.h was added on branch nathanw_sa on 2002-02-28 04:12:11 +0000
 1.9.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.9.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.9.2.1 03-Aug-2004  skrll Sync with HEAD
 1.12.12.1 21-Jun-2006  yamt sync with head.
 1.13.6.1 22-Apr-2006  simonb Sync with head.
 1.13.4.1 09-Sep-2006  rpaulo sync with head
 1.13.2.1 18-Feb-2006  yamt sync with head.
 1.14.80.1 19-Jan-2009  skrll Sync with HEAD.
 1.14.78.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.14.72.1 04-May-2009  yamt sync with head.
 1.14.68.1 17-Jan-2009  mjf Sync with HEAD.
 1.15.10.1 06-Jun-2011  jruoho Sync with HEAD.
 1.15.8.1 21-Apr-2011  rmind sync with head
 1.19.14.1 03-Dec-2017  jdolecek update from HEAD
 1.20.2.1 05-Oct-2016  skrll Sync with HEAD
 1.26 01-Dec-2023  thorpej Use vmem(9) rather than extent(9) to manage DVMA mappings.
 1.25 24-Jul-2021  andvar 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.24 26-Apr-2021  mrg iommu_enter() and iommu_remove() are static to iommu.c.
 1.23 09-Feb-2019  mrg branches: 1.23.16;
on tomatillo unload the map before flushing the iommu, instead of
the reverse. from opensolaris.
 1.22 03-Sep-2015  palle branches: 1.22.18;
sun4v: iommu setup seems to work now - device detection is now possible - parts from OpenBSD - ok mrg@, martin@
 1.21 25-Mar-2012  mrg branches: 1.21.2; 1.21.16;
replace splhigh() usage with an IPL_HIGH mutex.
 1.20 20-Mar-2011  mrg branches: 1.20.4; 1.20.8;
add a new is_flags member to strut iommu_state. add two flags:
IOMMU_FLUSH_CACHE - extra flushes needed for some pyro
IOMMU_TSBSIZE_IN_PTSB - different ptsb assignment for pyro

partly from openbsd.
 1.19 16-Mar-2011  mrg revert the iommu changes for now. my U60 doesn't like them.
 1.18 16-Mar-2011  mrg various changes to adapt for Fire controller support, based upon the
openbsd code to do the same:

- add the tsb size into the ptsb bits
- avoid setting tsbsize in the CR
- disable IDB_INFO for now; it crashes
- add new macros for reading/writing IOMMU registers (need to use
these more regularly across the whole file)
- add a missing membar #lookaside
- add support for flushing the pyro(4) caches
- extend struct iommureg to include everything pyro
 1.17 18-Oct-2008  nakayama branches: 1.17.16; 1.17.22;
It is wasteful that reconstructing arguments for inserting the pointer
to streaming buffers in each bus_dma functions on sbus/psycho layer.

Use iommu functions directly with storing the pointer into (unused)
_dm_cookie at bus_dmamap_create time.
 1.16 29-May-2008  mrg branches: 1.16.4;
remove clause #3 from my license where there are no other
copyright holders involved.
 1.15 04-Mar-2007  christos branches: 1.15.40; 1.15.42; 1.15.44; 1.15.46;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.14 13-Feb-2006  cdi branches: 1.14.20;
ANSIfy: u_intN_t -> uintN_t, remove __P(), fix function definitions.
 1.13 11-Feb-2006  cdi ANSIfication: u_intN_t -> uintN_t, use ANSI function declarations/definitions
instead of K&R ones.
 1.12 20-Jun-2002  eeh branches: 1.12.22; 1.12.34; 1.12.36; 1.12.38;
Overhaul streaming buffer handling:

sysio streaming buffer flushes write a single 8-byte aligned 8-byte
value.

psycho streaming buffer flushes write a 64-byte aligned 64-byte block.

So separate out the streaming buffers into their own structure and pass those
in to all iommu operations. This also means we only flush the correct
streaming buffer for psycho rather than needing to flush both just in case.
 1.11 20-Mar-2002  eeh branches: 1.11.4; 1.11.6;
Overhaul bus space.

bus_space_handle_t now holds an address and two ASIs, one for normal accesses
and one for streaming accesses. This allows to map individual handles
different ways, so some can use MMU bypass accesses and others use virtual
addresses. bus_space_map() will now create handles that use bypass accesses
unles BUS_SPACE_MAP_LINEAR is passed in. So only pass in BUS_SPACE_MAP_LINEAR
if you absolutely *need* to use bus_space_vaddr(). This removes at least one
extra level of indirection and should reduce TLB misses.

32-bit kernels have problems accessing 64-bit addresses, so they always use
virtual addresses.
 1.10 07-Feb-2002  eeh Overhaul iommu_dvmamap_load_raw().
 1.9 07-Oct-2001  eeh branches: 1.9.4;
Manage both streaming caches on psycho/psycho+.
 1.8 15-Sep-2001  eeh Added iommu_extract() for debug purposes.
Anyone caught using it for anything other than debug will be shot.
 1.7 20-Jul-2001  eeh branches: 1.7.2;
PCI overhaul.
 1.6 07-Jul-2000  mrg branches: 1.6.4;
work around a bug passing arguments to iommu_dvma_load_raw()
 1.5 18-Jun-2000  mrg branches: 1.5.2;
iommu_flush becomes iommu_strbuf_flush cuz that's what it does.
 1.4 17-May-2000  eeh branches: 1.4.2;
Add support for bus_dma_load_raw() so the le driver will work again.
 1.3 22-Apr-2000  mrg whole bunch of changes:
- merge IOMMU DVMA code from sbus/psycho into iommu.c. this code was
identical and a few minor inconsistencies had crept in. this way
keeps them all in sync.
- with this code gone from psycho, merge the psycho.c and psycho_bus.c
files. same with ebus/ebus_bus.c. delete the _bus.c files.
- add a _ds_boundary member to the dma segment structure, so that later
dma mappings can find this value.
- set _ds_boundary in machdep.c:_bus_dmamem_alloc().
- kill much dead code.
 1.2 20-Jun-1999  eeh branches: 1.2.2; 1.2.4;
Move the DVMA mapin/mapout functions from the SBus driver to the iommu driver.
 1.1 04-Jun-1999  mrg pull iommu code out of sbus code so we can share it with the PCI.
define some useful PCI macros.
 1.2.4.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.2 21-Jun-1999  thorpej Sync w/ -current.
 1.2.2.1 20-Jun-1999  thorpej file iommuvar.h was added on branch chs-ubc2 on 1999-06-21 01:02:31 +0000
 1.4.2.1 22-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.5.2.1 18-Jul-2000  mrg pullup the contents of -current arch/sparc64. this gives us significant
ultrasparc PCI support (ultra5, ultra10, AXi, and E250 tested so far),
plus many other small fixes. netbooting is now supported.
 1.6.4.5 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.6.4.4 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.6.4.3 16-Mar-2002  jdolecek Catch up with -current.
 1.6.4.2 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.6.4.1 03-Aug-2001  lukem update to -current
 1.7.2.2 11-Oct-2001  fvdl Catch up with -current. Fix some bogons in the sparc64 kbd/ms
attach code. cd18xx conversion provided by mrg.
 1.7.2.1 01-Oct-2001  fvdl Catch up with -current.
 1.9.4.4 01-Aug-2002  nathanw Catch up to -current.
 1.9.4.3 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.9.4.2 28-Feb-2002  nathanw Catch up to -current.
 1.9.4.1 07-Oct-2001  nathanw file iommuvar.h was added on branch nathanw_sa on 2002-02-28 04:12:11 +0000
 1.11.6.1 21-Jun-2002  lukem Pull up revision 1.12 (requested by eeh in ticket #337):
Overhaul streaming buffer handling:
sysio streaming buffer flushes write a single 8-byte aligned 8-byte
value.
psycho streaming buffer flushes write a 64-byte aligned 64-byte block.
So separate out the streaming buffers into their own structure and pass those
in to all iommu operations. This also means we only flush the correct
streaming buffer for psycho rather than needing to flush both just in case.
[Gets E220R working]
 1.11.4.1 17-Jul-2002  gehenna catch up with -current.
 1.12.38.1 22-Apr-2006  simonb Sync with head.
 1.12.36.1 09-Sep-2006  rpaulo sync with head
 1.12.34.1 18-Feb-2006  yamt sync with head.
 1.12.22.2 03-Sep-2007  yamt sync with head.
 1.12.22.1 21-Jun-2006  yamt sync with head.
 1.14.20.1 12-Mar-2007  rmind Sync with HEAD.
 1.15.46.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.15.44.1 04-May-2009  yamt sync with head.
 1.15.42.1 04-Jun-2008  yamt sync with head
 1.15.40.2 17-Jan-2009  mjf Sync with HEAD.
 1.15.40.1 02-Jun-2008  mjf Sync with HEAD.
 1.16.4.1 19-Oct-2008  haad Sync with HEAD.
 1.17.22.1 06-Jun-2011  jruoho Sync with HEAD.
 1.17.16.1 21-Apr-2011  rmind sync with head
 1.20.8.1 05-Apr-2012  mrg sync to latest -current.
 1.20.4.1 17-Apr-2012  yamt sync with head
 1.21.16.1 22-Sep-2015  skrll Sync with HEAD
 1.21.2.1 03-Dec-2017  jdolecek update from HEAD
 1.22.18.1 10-Jun-2019  christos Sync with HEAD
 1.23.16.2 01-Aug-2021  thorpej Sync with HEAD.
 1.23.16.1 13-May-2021  thorpej Sync with HEAD.
 1.3 27-Aug-1998  mrg move isp sbus attachment to dev/sbus and support it on the sparc64
 1.2 13-Aug-1998  eeh Merge paddr_t changes into the main branch.
 1.1 20-Jun-1998  eeh branches: 1.1.1;
Initial revision
 1.1.1.1 20-Jun-1998  eeh branches: 1.1.1.1.2;
Import of sparc64.
 1.1.1.1.2.1 30-Jul-1998  eeh Split vm_offset_t and vm_size_t into paddr_t, psize_t, vaddr_t, and vsize_t.
 1.9 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.8 15-Sep-2025  thorpej Encapsulate what's needed to attach an I2C bus into a iicbus_attach()
inline.
 1.7 07-Aug-2021  thorpej branches: 1.7.2;
Merge thorpej-cfargs2.
 1.6 24-Apr-2021  thorpej branches: 1.6.2; 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 12-Jun-2020  thorpej branches: 1.5.4;
Update for proplib(3) API changes.
 1.4 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.3 03-Nov-2018  martin branches: 1.3.2; 1.3.6;
Use PRIx64 printf format to make the 32bit version compile.
 1.2 26-Oct-2018  macallan - map registers ourselves, no more schizo hackery
- remove some leftover debug code
- print address when attaching
- actually lock/unlock in acquire_bus()/release_bus()
should be ready for general consumption now
 1.1 20-Oct-2018  macallan support for jbus-i2c found in US-IIIi machines
this needs help from schizo to access its registers, which is suboptimal and
should go away. So, for now this is for documentation purposes only.
 1.3.6.3 08-Apr-2020  martin Merge changes from current as of 20200406
 1.3.6.2 10-Jun-2019  christos Sync with HEAD
 1.3.6.1 03-Nov-2018  christos file jbus-i2c.c was added on branch phil-wifi on 2019-06-10 22:06:47 +0000
 1.3.2.2 26-Nov-2018  pgoyette Sync with HEAD, resolve a couple of conflicts
 1.3.2.1 03-Nov-2018  pgoyette file jbus-i2c.c was added on branch pgoyette-compat on 2018-11-26 01:52:27 +0000
 1.5.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.6.8.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.6.2.1 14-May-2021  thorpej Adapt jbusi2c to the new i2c device enumeration scheme.
 1.7.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.2 05-Sep-1998  pk Remove unused files.
 1.1 20-Jun-1998  eeh branches: 1.1.1;
Initial revision
 1.1.1.1 20-Jun-1998  eeh Import of sparc64.
 1.53 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.52 16-Mar-2014  dholland branches: 1.52.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.51 27-Oct-2012  chs branches: 1.51.2;
split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.50 24-Apr-2011  rmind branches: 1.50.4; 1.50.14;
Rename ttymalloc() to tty_alloc(), and ttyfree() to tty_free() for
consistency. Remove some unnecessary malloc.h inclusions as well.
 1.49 28-Apr-2008  martin branches: 1.49.22; 1.49.28;
Remove clause 3 and 4 from TNF licenses
 1.48 30-Mar-2008  tsutsui branches: 1.48.2; 1.48.4;
One missed file in the previous commit:
> Split softc and device_t for zsc(4) and its children.

Pointed out by mrg@.
 1.47 19-Nov-2007  ad branches: 1.47.14;
- Factor out too many copies of the same bit of tty code.
- Fix another tty signalling/wakeup problem.
 1.46 19-Oct-2007  dogcow branches: 1.46.2;
It's always nice to prototype functions before using them.
 1.45 18-Oct-2007  joerg 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.44 04-Mar-2007  christos branches: 1.44.2; 1.44.18; 1.44.20; 1.44.24;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.43 16-Feb-2007  ad branches: 1.43.2;
More spllowersoftclock() fallout.
 1.42 15-Oct-2006  martin Initializers
 1.41 01-Oct-2006  elad Adapt MD code to KAUTH_DEVICE_TTY_OPEN. Patch from Matt Fleming, thanks!
 1.40 26-Jul-2006  martin branches: 1.40.4; 1.40.6;
Make it compile again
 1.39 23-Jul-2006  ad Use the LWP cached credentials where sane.
 1.38 14-May-2006  elad integrate kauth.
 1.37 13-Feb-2006  cdi branches: 1.37.2; 1.37.4; 1.37.6;
ANSIfy: u_intN_t -> uintN_t, remove __P(), fix function definitions.
 1.36 11-Feb-2006  cdi ANSIfication: u_intN_t -> uintN_t, use ANSI function declarations/definitions
instead of K&R ones.
 1.35 11-Dec-2005  christos branches: 1.35.2; 1.35.4; 1.35.6;
merge ktrace-lwp.
 1.34 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.33 25-Feb-2005  martin branches: 1.33.4;
Nuke options RASTERCONSOLE for sparc64
 1.32 21-Mar-2004  pk branches: 1.32.8; 1.32.10;
Use the promlib I/O routines.
 1.31 17-Mar-2004  pk Use prom_getoption() and drop home-grown string-to-integer conversion code.
 1.30 25-Aug-2003  uwe Use dev/sun/fbvar.h instead of machine/fbvar.h (which is just an out
of date copy of the former).

Compile tested with GENERIC32.
Ok by Martin Husemann <martin@netbsd>.
 1.29 25-Aug-2003  uwe Undo previous as it broke things.

There are some scattered implicit RASTERCONSOLE dependencies,
so there should be a better way.
 1.28 24-Aug-2003  uwe #include "opt_rcons.h"
 1.27 15-Jul-2003  lukem __KERNEL_RCSID()
 1.26 29-Jun-2003  fvdl branches: 1.26.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.25 29-Jun-2003  martin Passing struct lwp * instead of struct proc * to device functions,
replace a homegrown check with proper suser() call.
 1.24 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.23 10-Oct-2002  jdolecek tag the cdevsw as D_TTY
 1.22 10-Oct-2002  martin Pass a struct cons_channel * to cc_iclose, not a struct kbd_softc *.
This argument has been previously unused, thus undetected due to void*
typing. Mmm, copy & paste. Note that sparc got it right though.

Many thanks to Valeriy E. Ushakov <uwe@netbsd.org> for debugging support.
 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 19-Mar-2002  eeh branches: 1.20.4;
Using PSR_PIL in conjunction with the IPL results in a comparison that is
always true.
 1.19 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.18 26-Sep-2001  eeh branches: 1.18.4;
getprop* -> PROM_getprop*
 1.17 19-Sep-2001  thorpej machine/fbio.h -> dev/sun/fbio.h
 1.16 02-May-2001  scw branches: 1.16.2; 1.16.4;
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.15 09-Nov-2000  eeh branches: 1.15.2;
Attach the sunkbd line discipline to zstty.
 1.14 02-Nov-2000  eeh Adapt to the new line discipline scheme.
 1.13 21-Sep-2000  eeh Sun Keyboard/Mouse line discipline support.
 1.12 19-May-2000  eeh Fix the sparc64 console.

Unlike the other Sun machines, UltraSPARCs can have consoles run on different
chips than zs, so we need to support them. So, here we go:

Add a new PROM console driver with a major number and everything.
This is the default driver if nothing else attaches. It does not
use the keyboard driver since the PROM translates keystrokes itself.
(Unfortunately it also swallows L1-A).

Have the keyboard driver take over the console when it attaches on a
serial port. When a serial port detects a keyboard and attaches the
keyboard driver, it needs to provide a set of consdev vectors. They
keyboard driver will use those to send I/O to the keyboard and mouse.
 1.11 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.10 21-Mar-2000  pk We need cons_attach_input().
 1.9 20-Mar-2000  pk Call rcons_ttyinit() on first open.
 1.8 19-Mar-2000  pk Nuke dead code.
 1.7 19-Mar-2000  pk Minimal changes to accomodate the console input channel attachment
changes in the keyboard driver (see /sys/dev/sun/kbd*)
 1.6 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.5 05-Aug-1999  thorpej branches: 1.5.2;
Change the semantics of splsoftclock() to be like other spl*() functions,
that is priority is rasied. Add a new spllowersoftclock() to provide the
atomic drop-to-softclock semantics that the old splsoftclock() provided,
and update calls accordingly.

This fixes a problem with using the "rnd" pseudo-device from within
interrupt context to extract random data (e.g. from within the softnet
interrupt) where doing so would incorrectly unblock interrupts (causing
all sorts of lossage).

XXX 4 platforms do not have priority-raising capability: newsmips, sparc,
XXX sparc64, and VAX. This platforms still have this bug until their
XXX spl*() functions are fixed.
 1.4 23-May-1999  eeh Start putting in hooks for non-zs console devices.
 1.3 22-May-1999  eeh If the zs has not yet attached use the PROM for console input.
 1.2 25-Apr-1999  eeh Defer final console attach to zs_attach().
 1.1 20-Jun-1998  eeh branches: 1.1.1;
Initial revision
 1.1.1.1 20-Jun-1998  eeh branches: 1.1.1.1.10;
Import of sparc64.
 1.1.1.1.10.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.15.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.16.4.4 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.16.4.3 11-Oct-2001  fvdl Catch up with -current. Fix some bogons in the sparc64 kbd/ms
attach code. cd18xx conversion provided by mrg.
 1.16.4.2 10-Oct-2001  fvdl Convert all remaining devices.
 1.16.4.1 01-Oct-2001  fvdl Catch up with -current.
 1.16.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.16.2.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.16.2.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.18.4.5 11-Nov-2002  nathanw Catch up to -current
 1.18.4.4 18-Oct-2002  nathanw Catch up to -current.
 1.18.4.3 17-Sep-2002  nathanw Catch up to -current.
 1.18.4.2 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.18.4.1 26-Sep-2001  nathanw file kd.c was added on branch nathanw_sa on 2002-04-01 07:43:03 +0000
 1.20.4.1 19-May-2002  gehenna Add device switch.
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-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.26.2.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.26.2.3 18-Sep-2004  skrll Sync with HEAD.
 1.26.2.2 26-Aug-2004  skrll Adapt to branch.

sparc64 GENERIC compiles.
 1.26.2.1 03-Aug-2004  skrll Sync with HEAD
 1.32.10.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.32.8.1 29-Apr-2005  kent sync with -current
 1.33.4.6 07-Dec-2007  yamt sync with head
 1.33.4.5 27-Oct-2007  yamt sync with head.
 1.33.4.4 03-Sep-2007  yamt sync with head.
 1.33.4.3 26-Feb-2007  yamt sync with head.
 1.33.4.2 30-Dec-2006  yamt sync with head.
 1.33.4.1 21-Jun-2006  yamt sync with head.
 1.35.6.2 01-Jun-2006  kardel Sync with head.
 1.35.6.1 22-Apr-2006  simonb Sync with head.
 1.35.4.1 09-Sep-2006  rpaulo sync with head
 1.35.2.1 18-Feb-2006  yamt sync with head.
 1.37.6.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.37.4.3 12-May-2006  elad adapt to kauth kpi, include sys/kauth.h where needed..
 1.37.4.2 10-Mar-2006  elad generic_authorize() -> kauth_authorize_generic().
 1.37.4.1 08-Mar-2006  elad Adapt to kernel authorization KPI.

I expect *some* lossage here...
 1.37.2.2 11-Aug-2006  yamt sync with head
 1.37.2.1 24-May-2006  yamt sync with head.
 1.40.6.1 22-Oct-2006  yamt sync with head
 1.40.4.1 18-Nov-2006  ad Sync with head.
 1.43.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.44.24.2 21-Nov-2007  bouyer Sync with HEAD
 1.44.24.1 25-Oct-2007  bouyer Sync with HEAD.
 1.44.20.2 09-Jan-2008  matt sync with HEAD
 1.44.20.1 06-Nov-2007  matt sync with HEAD
 1.44.18.2 21-Nov-2007  joerg Sync with HEAD.
 1.44.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.44.2.2 03-Dec-2007  ad Sync with HEAD.
 1.44.2.1 23-Oct-2007  ad Sync with head.
 1.46.2.1 08-Dec-2007  mjf Sync with HEAD.
 1.47.14.2 02-Jun-2008  mjf Sync with HEAD.
 1.47.14.1 03-Apr-2008  mjf Sync with HEAD.
 1.48.4.1 16-May-2008  yamt sync with head.
 1.48.2.1 18-May-2008  yamt sync with head.
 1.49.28.1 06-Jun-2011  jruoho Sync with HEAD.
 1.49.22.1 31-May-2011  rmind sync with head
 1.50.14.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.50.14.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.50.4.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.50.4.1 30-Oct-2012  yamt sync with head
 1.51.2.1 18-May-2014  rmind sync with head
 1.52.2.1 10-Aug-2014  tls Rebase.
 1.10 06-Feb-2025  palle sun4v ldc: fix 32-bit build
 1.9 05-Feb-2025  palle sun4v ldc: improve the ldc_send_xxx functions so they can print an error message and return a proper error code
 1.8 20-Dec-2023  thorpej branches: 1.8.2;
Remove unnecessary <sys/malloc.h>.
 1.7 05-Apr-2021  palle sun4v: Ignore spurious ldc CTRL/ACK/VERS messages (do not reset the connection anymore). Fixes occationals stalls when vdsk uses the ldc service. Observed on both T2000 and T5 host systems
 1.6 15-Oct-2019  chs branches: 1.6.10;
convert more KM_NOSLEEP to KM_SLEEP and remove code to handle failures.
 1.5 01-Oct-2019  chs in many device attach paths, allocate memory with KM_SLEEP instead of KM_NOSLEEP
and remove code to handle failures that can no longer happen.
 1.4 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.3 03-Mar-2017  palle branches: 1.3.12; 1.3.14; 1.3.16;
sun4v: Fixed PR 51554 - Avoid unsafe allocation in ldc/vdsk
 1.2 20-Aug-2016  nakayama branches: 1.2.2; 1.2.4; 1.2.6;
Avoid "cast to pointer from integer of different size" warning on
32-bit kernels.
 1.1 19-Aug-2016  palle sun4v: vdsk and ldc drivers - from OpenBSD, but heavily adapted to NetBSD scsipi - access to a virtual disk served from a ldom primary domain now works
 1.2.6.1 21-Apr-2017  bouyer Sync with HEAD
 1.2.4.3 28-Aug-2017  skrll Sync with HEAD
 1.2.4.2 05-Oct-2016  skrll Sync with HEAD
 1.2.4.1 20-Aug-2016  skrll file ldc.c was added on branch nick-nhusb on 2016-10-05 20:55:36 +0000
 1.2.2.3 20-Mar-2017  pgoyette Sync with HEAD
 1.2.2.2 14-Sep-2016  pgoyette Sync with HEAD
 1.2.2.1 20-Aug-2016  pgoyette file ldc.c was added on branch pgoyette-localcount on 2016-09-14 03:04:17 +0000
 1.3.16.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.3.16.1 10-Jun-2019  christos Sync with HEAD
 1.3.14.1 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.3.12.2 03-Dec-2017  jdolecek update from HEAD
 1.3.12.1 03-Mar-2017  jdolecek file ldc.c was added on branch tls-maxphys on 2017-12-03 11:36:44 +0000
 1.6.10.1 17-Apr-2021  thorpej Sync with HEAD.
 1.8.2.1 02-Aug-2025  perseant Sync with HEAD
 1.2 05-Feb-2025  palle sun4v ldc: improve the ldc_send_xxx functions so they can print an error message and return a proper error code
 1.1 19-Aug-2016  palle branches: 1.1.2; 1.1.4; 1.1.18; 1.1.58;
sun4v: vdsk and ldc drivers - from OpenBSD, but heavily adapted to NetBSD scsipi - access to a virtual disk served from a ldom primary domain now works
 1.1.58.1 02-Aug-2025  perseant Sync with HEAD
 1.1.18.2 03-Dec-2017  jdolecek update from HEAD
 1.1.18.1 19-Aug-2016  jdolecek file ldcvar.h was added on branch tls-maxphys on 2017-12-03 11:36:44 +0000
 1.1.4.2 05-Oct-2016  skrll Sync with HEAD
 1.1.4.1 19-Aug-2016  skrll file ldcvar.h was added on branch nick-nhusb on 2016-10-05 20:55:36 +0000
 1.1.2.2 14-Sep-2016  pgoyette Sync with HEAD
 1.1.2.1 19-Aug-2016  pgoyette file ldcvar.h was added on branch pgoyette-localcount on 2016-09-14 03:04:17 +0000
 1.2 27-Jul-1998  mrg this has moved (and was never used here anyway)
 1.1 20-Jun-1998  eeh branches: 1.1.1;
Initial revision
 1.1.1.1 20-Jun-1998  eeh Import of sparc64.
 1.16 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.15 27-Apr-2015  martin branches: 1.15.16; 1.15.18;
Print error codes from sysmon
 1.14 21-Feb-2015  nakayama Fix queue handling to make the watchdog timer actually works on
netbsd-7 if it is configured by wdogctl=YES in rc.conf, and also
avoid a hangup duaring shutdown.

- don't put an entry which is already in the queue.
- read a first entry properly to handle the queue.
- check the lom status if input buffer is empty before writing.
 1.13 25-Feb-2014  pooka branches: 1.13.4; 1.13.6;
Ensure that the top level sysctl nodes (kern, vfs, net, ...) exist before
the sysctl link sets are processed, and remove redundancy.

Shaves >13kB off of an amd64 GENERIC, not to mention >1k duplicate
lines of code.
 1.12 20-Feb-2014  joerg Don't use conditional format strings, if they aren't equivalent in the
arguments they use.
 1.11 24-Jan-2013  nakayama branches: 1.11.2;
Fix typo in KASSERT, pointed out by riastradh@ and martin@.
 1.10 02-Jun-2012  dsl branches: 1.10.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.9 20-Jun-2011  pgoyette branches: 1.9.2;
Initialize sensor states before registering.
 1.8 19-Jun-2011  nakayama Limit reading from registers at most once every second with using
ratecheck(9).
 1.7 28-Feb-2011  nakayama branches: 1.7.2;
lom_refresh():
Update only the sensor status specified by the edata as noted in
sysmon_envsys(9).

lom_sysctl_alarm():
Update alarm status before reading via sysctl to make it usable at
a boot time.
 1.6 22-Mar-2010  nakayama branches: 1.6.2; 1.6.4; 1.6.6;
Fix off-by-one in LOMlite hostname code. From rev 1.21 of OpenBSD.
 1.5 28-Dec-2009  nakayama branches: 1.5.2; 1.5.4; 1.5.6;
Make fault LED and alarms status changeable via sysctl(8).
The sysctl entries are created under the hw.lomN MIB.
 1.4 13-Dec-2009  nakayama Merge change of OpenBSD rev 1.20:

Remove debug printf and properly dequeue command instead when a read times out
on LOMLite2.
 1.3 28-Nov-2009  nakayama Add support for monitoring Fault LED and Alarms status.
 1.2 16-Nov-2009  nakayama Merge changes between revision 1.16 and 1.19 of OpenBSD with
shutdownhook_establish(9) to pmf(9) conversion:

- LOMlite seems to get wedged from time to time; add some code to unwedge it.

- Make sure we don't insert and entry into the list of pending commends twice.

- Establish a shutdown hook to disable the watchdog timer to prevent watchdog
triggers after the kernel has been halted.

- Handle LOMlite2 in an interrupt-driven way; avoids using delay(9) once the
machine is up and running.
 1.1 02-Oct-2009  nakayama branches: 1.1.2;
Port lom(4) driver for LOMlite lights out management hardware monitor
and watchdog timer from OpenBSD.

It supports the LOMlite found on Sun Netra t1 and the LOMlite2 found
on Sun Netra T1/X1 and Sun Fire V100/V120.
 1.1.2.8 16-Jul-2011  riz Pull up following revision(s) (requested by nakayama in ticket #1641):
sys/arch/sparc64/dev/lom.c: revision 1.8
Limit reading from registers at most once every second with using
ratecheck(9).
 1.1.2.7 20-Mar-2011  bouyer Pull up following revision(s) (requested by nakayama in ticket #1570):
sys/arch/sparc64/dev/lom.c: revision 1.7
lom_refresh():
Update only the sensor status specified by the edata as noted in
sysmon_envsys(9).
lom_sysctl_alarm():
Update alarm status before reading via sysctl to make it usable at
a boot time.
 1.1.2.6 28-Mar-2010  snj Pull up following revision(s) (requested by nakayama in ticket #1349):
sys/arch/sparc64/dev/lom.c: revision 1.6
Fix off-by-one in LOMlite hostname code. From rev 1.21 of OpenBSD.
 1.1.2.5 09-Jan-2010  snj Pull up following revision(s) (requested by nakayama in ticket #1216):
share/man/man4/man4.sparc64/lom.4: revision 1.4
sys/arch/sparc64/dev/lom.c: revision 1.5
Make fault LED and alarms status changeable via sysctl(8).
The sysctl entries are created under the hw.lomN MIB.
 1.1.2.4 18-Dec-2009  snj Pull up following revision(s) (requested by nakayama in ticket #1193):
sys/arch/sparc64/dev/lom.c: revision 1.4
Merge change of OpenBSD rev 1.20:
Remove debug printf and properly dequeue command instead when a read times out
on LOMLite2.
 1.1.2.3 28-Nov-2009  bouyer Pull up following revision(s) (requested by nakayama in ticket #1151):
share/man/man4/man4.sparc64/lom.4: revision 1.3
sys/arch/sparc64/dev/lom.c: revision 1.2, 1.3
Merge changes between revision 1.16 and 1.19 of OpenBSD with
shutdownhook_establish(9) to pmf(9) conversion:
- LOMlite seems to get wedged from time to time; add some code to unwedge it.
- Make sure we don't insert and entry into the list of pending commends twice.
- Establish a shutdown hook to disable the watchdog timer to prevent watchdog
triggers after the kernel has been halted.
- Handle LOMlite2 in an interrupt-driven way; avoids using delay(9) once the
machine is up and running.
Add support for monitoring Fault LED and Alarms status.
 1.1.2.2 16-Oct-2009  sborrill Pull up the following revisions(s) (requested by nakayama in ticket #1064):
distrib/sets/lists/man/mi: revision 1.1161
share/man/man4/man4.sparc64/Makefile: revision 1.5
share/man/man4/man4.sparc64/lom.4: revision 1.1-1.2
sys/arch/sparc64/conf/GENERIC: revision 1.111
sys/arch/sparc64/conf/files.sparc64: revision 1.121
sys/arch/sparc64/dev/lom.c: revision 1.1
sys/dev/DEVNAMES: revision 1.252

Add a driver for LOMlite lights out management hardware monitor and watchdog
timer.
 1.1.2.1 02-Oct-2009  sborrill file lom.c was added on branch netbsd-5 on 2009-10-16 11:56:11 +0000
 1.5.6.2 05-Mar-2011  rmind sync with head
 1.5.6.1 30-May-2010  rmind sync with head
 1.5.4.3 11-Aug-2010  yamt sync with head.
 1.5.4.2 11-Mar-2010  yamt sync with head
 1.5.4.1 28-Dec-2009  yamt file lom.c was added on branch yamt-nfs-mp on 2010-03-11 15:03:00 +0000
 1.5.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.6.6.1 05-Mar-2011  bouyer Sync with HEAD
 1.6.4.1 06-Jun-2011  jruoho Sync with HEAD.
 1.6.2.2 21-Apr-2010  matt sync to netbsd-5
 1.6.2.1 22-Mar-2010  matt file lom.c was added on branch matt-nb5-mips64 on 2010-04-21 00:33:49 +0000
 1.7.2.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.9.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.9.2.1 30-Oct-2012  yamt sync with head
 1.10.2.3 03-Dec-2017  jdolecek update from HEAD
 1.10.2.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.10.2.1 25-Feb-2013  tls resync with head
 1.11.2.1 18-May-2014  rmind sync with head
 1.13.6.2 06-Jun-2015  skrll Sync with HEAD
 1.13.6.1 06-Apr-2015  skrll Sync with HEAD
 1.13.4.1 21-Feb-2015  martin Pull up following revision(s) (requested by nakayama in ticket #539):
sys/arch/sparc64/dev/lom.c: revision 1.14
Fix queue handling to make the watchdog timer actually works on
netbsd-7 if it is configured by wdogctl=YES in rc.conf, and also
avoid a hangup duaring shutdown.
- don't put an entry which is already in the queue.
- read a first entry properly to handle the queue.
- check the lom status if input buffer is empty before writing.
 1.15.18.1 10-Jun-2019  christos Sync with HEAD
 1.15.16.1 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.24 03-May-2014  martin Also attach to devices named "parallel"
 1.23 01-Jul-2011  dyoung branches: 1.23.2; 1.23.12; 1.23.16; 1.23.26;
#include <sys/bus.h> instead of <machine/bus.h>.
 1.22 29-May-2008  mrg remove clause #3 from my license where there are no other
copyright holders involved.
 1.21 07-Mar-2008  cube branches: 1.21.2; 1.21.4; 1.21.6;
Split the softc from the device_t for all lpt(4) variants and attachments
except the ppbus stuff (which doesn't compile) and ulpt(4) which is
unrelated and can be dealt with separately.

As usual, it comes with related cosmetic changes.
 1.20 11-Feb-2006  cdi branches: 1.20.44; 1.20.64; 1.20.68;
ANSIfication: u_intN_t -> uintN_t, use ANSI function declarations/definitions
instead of K&R ones.
 1.19 11-Dec-2005  christos branches: 1.19.2; 1.19.4; 1.19.6;
merge ktrace-lwp.
 1.18 15-Jul-2003  lukem branches: 1.18.16;
__KERNEL_RCSID()
 1.17 10-Dec-2002  pk branches: 1.17.6;
Remove the `flags' argument from bus_intr_establish().
 1.16 02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.15 01-Oct-2002  thorpej Use CFATTACH_DECL().
 1.14 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.13 18-Jul-2002  wiz Spell 'should' correctly.
 1.12 21-Mar-2002  eeh branches: 1.12.4;
Cleanup.
 1.11 20-Mar-2002  eeh Overhaul bus space.

bus_space_handle_t now holds an address and two ASIs, one for normal accesses
and one for streaming accesses. This allows to map individual handles
different ways, so some can use MMU bypass accesses and others use virtual
addresses. bus_space_map() will now create handles that use bypass accesses
unles BUS_SPACE_MAP_LINEAR is passed in. So only pass in BUS_SPACE_MAP_LINEAR
if you absolutely *need* to use bus_space_vaddr(). This removes at least one
extra level of indirection and should reduce TLB misses.

32-bit kernels have problems accessing 64-bit addresses, so they always use
virtual addresses.
 1.10 16-Mar-2002  mrg convert to using <dev/ebus/ebusvar.h> and it's struct member names.
 1.9 15-Mar-2002  eeh Get PCI working with the new bus_space*.
 1.8 01-Mar-2002  martin Rename EBUS_PADDR_FROM_REG uses to EBUS_ADDR_FROM_REG.
 1.7 22-Oct-2001  mrg branches: 1.7.4;
use <dev/ebus/ebusreg.h>
 1.6 09-Jul-2000  pk branches: 1.6.4;
Add a `device class' interrupt level argument (from machine/intr.h)
to bus_interrupt_establish().

It's currently only used in sparc64/dev/psycho.c to assign a CPU interrupt
level to devices in PCI slots.
 1.5 15-Apr-2000  mrg branches: 1.5.4;
- auxio cleanup and sbus support.
- make GENERIC64 include GENERIC and set the 3 optoins it needs. suggested
by hubert feyrer.
- add a comment that we maybe should use the `bpp' driver, not the lpt, on
the ebus because the `bpp' driver does DMA already.
- ebus_attach_args got a member renamed
 1.4 08-Apr-2000  mrg - store the ebus's parent so we can find the IOMMU
- use generic iommu routines in the ebus code (uses the above)
- add some more comments.
 1.3 05-Apr-2000  mrg add some comments, clean this up a bit.
 1.2 05-Jun-1999  mrg branches: 1.2.2; 1.2.4;
map in registers, configure interrupts, this appears to be OK now.
 1.1 05-Jun-1999  mrg lpt at ebus.
 1.2.4.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 21-Jun-1999  thorpej Sync w/ -current.
 1.5.4.1 18-Jul-2000  mrg pullup the contents of -current arch/sparc64. this gives us significant
ultrasparc PCI support (ultra5, ultra10, AXi, and E250 tested so far),
plus many other small fixes. netbooting is now supported.
 1.6.4.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.6.4.4 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.6.4.3 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.6.4.2 16-Mar-2002  jdolecek Catch up with -current.
 1.6.4.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.7.4.5 11-Dec-2002  thorpej Sync with HEAD.
 1.7.4.4 18-Oct-2002  nathanw Catch up to -current.
 1.7.4.3 01-Aug-2002  nathanw Catch up to -current.
 1.7.4.2 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.7.4.1 22-Oct-2001  nathanw file lpt_ebus.c was added on branch nathanw_sa on 2002-04-01 07:43:03 +0000
 1.12.4.1 21-Jul-2002  gehenna catch up with -current.
 1.17.6.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.17.6.2 18-Sep-2004  skrll Sync with HEAD.
 1.17.6.1 03-Aug-2004  skrll Sync with HEAD
 1.18.16.2 17-Mar-2008  yamt sync with head.
 1.18.16.1 21-Jun-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.19.2.1 18-Feb-2006  yamt sync with head.
 1.20.68.2 02-Jun-2008  mjf Sync with HEAD.
 1.20.68.1 03-Apr-2008  mjf Sync with HEAD.
 1.20.64.1 24-Mar-2008  keiichi sync with head.
 1.20.44.1 23-Mar-2008  matt sync with HEAD
 1.21.6.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.21.4.1 04-May-2009  yamt sync with head.
 1.21.2.1 04-Jun-2008  yamt sync with head
 1.23.26.1 10-Aug-2014  tls Rebase.
 1.23.16.1 18-May-2014  rmind sync with head
 1.23.12.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.23.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.4 21-Jan-2002  jdolecek Switch to MI dev/md_root.c for archs which don't have any special
memory disk hooks (i.e. everything except atari).
 1.3 19-Apr-2000  mrg branches: 1.3.8; 1.3.12;
add a newline to this fake autoconfig line.
 1.2 06-Apr-2000  mrg make this work with years-old new-style mdsetimage, etc.
 1.1 20-Jun-1998  eeh branches: 1.1.1;
Initial revision
 1.1.1.1 20-Jun-1998  eeh branches: 1.1.1.1.14;
Import of sparc64.
 1.1.1.1.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.12.1 28-Feb-2002  nathanw Catch up to -current.
 1.3.8.1 11-Feb-2002  jdolecek Sync w/ -current.
 1.14 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.13 20-Dec-2023  thorpej Remove unnecessary <sys/malloc.h>.
 1.12 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.11 19-Sep-2012  jdc Use the PROM mapping for the clock, if it exists.
Allows the clock on the Tadpole SPARCle to attach.
Idea from r1.43 of OpenBSD sys/arch/sparc64/sparc64/clock.c
 1.10 11-Aug-2012  mrg branches: 1.10.2;
add an XXXSMP comment.
 1.9 29-Jul-2011  mrg branches: 1.9.2;
port the openbsd central and fhc drivers, and the clock/zs attachments.
doesn't quite work yet, crashes when central_attach() calls
config_attach() (faulting address is 0xf8000000.)
 1.8 01-Jul-2011  dyoung #include <sys/bus.h> instead of <machine/bus.h>.
 1.7 12-Mar-2011  nakayama Remove unnecessary headers.
 1.6 24-Oct-2009  nakayama branches: 1.6.4; 1.6.6;
Use trunc_page or round_page where appropriate.
No functional changes intended, and generate same binaries.
 1.5 29-Mar-2008  tsutsui branches: 1.5.4;
Don't forget to initialize sc_dev.
 1.4 29-Mar-2008  tsutsui Use device_private(), missed in the previous.
 1.3 28-Mar-2008  tsutsui Split device_t and softc for MI mk48txx(4) and intersil7170(4) clocks,
and other related misc cosmetics.
 1.2 10-Jan-2008  tsutsui branches: 1.2.6;
- move todr_attach(9) calls from each MD attachment to MI mk48txx_attach()
- don't clear todr_setwen in mk48txx_attach() since it might be set by
MD attachments
 1.1 09-Nov-2006  tsutsui branches: 1.1.2; 1.1.6; 1.1.8; 1.1.34; 1.1.40; 1.1.48;
More cleanup of sparc64 clock stuff:
- split mkclock attachment from sparc64/clock.c into dev/mkclock.c
(now clock.s only contains clock interrupt and timecounter stuff)
- rename match/attach functions of rtc at ebus to match the device name
- update some comments around clock devices in GENERIC

No objection on port-sparc64 for a month.
 1.1.48.1 10-Jan-2008  bouyer Sync with HEAD
 1.1.40.1 18-Feb-2008  mjf Sync with HEAD.
 1.1.34.1 23-Mar-2008  matt sync with HEAD
 1.1.8.3 21-Jan-2008  yamt sync with head
 1.1.8.2 30-Dec-2006  yamt sync with head.
 1.1.8.1 09-Nov-2006  yamt file mkclock.c was added on branch yamt-lazymbuf on 2006-12-30 20:47:02 +0000
 1.1.6.2 10-Dec-2006  yamt sync with head.
 1.1.6.1 09-Nov-2006  yamt file mkclock.c was added on branch yamt-splraiseipl on 2006-12-10 07:16:36 +0000
 1.1.2.2 18-Nov-2006  ad Sync with head.
 1.1.2.1 09-Nov-2006  ad file mkclock.c was added on branch newlock2 on 2006-11-18 21:29:32 +0000
 1.2.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.5.4.1 11-Mar-2010  yamt sync with head
 1.6.6.1 06-Jun-2011  jruoho Sync with HEAD.
 1.6.4.1 21-Apr-2011  rmind sync with head
 1.9.2.1 30-Oct-2012  yamt sync with head
 1.10.2.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.2 05-Sep-1998  pk Remove unused files.
 1.1 20-Jun-1998  eeh branches: 1.1.1;
Initial revision
 1.1.1.1 20-Jun-1998  eeh Import of sparc64.
 1.2 05-Sep-1998  pk Remove unused files.
 1.1 20-Jun-1998  eeh branches: 1.1.1;
Initial revision
 1.1.1.1 20-Jun-1998  eeh Import of sparc64.
 1.4 16-May-2002  thorpej branches: 1.4.2;
* Add "pcitag_t *pba_bridgetag" to pci_attach_args. This is set to
NULL for root PCI busses. For busses behind a bridge, it points to
a persistent copy of the bridge's pcitag_t. This can be very useful
for machine-dependent PCI bus enumeration code.
* Implement a machine-dependent pci_enumerate_bus() for sparc64 which
uses OFW device nodes to enumerate the bus. When a PCI bus that is
behind a bridge is attached, pci_attach_hook() allocates a new PCI
chipset tag for the new bus and sets it's "curnode" to the OFW node
of the bridge. This is used as a starting point when enumerating
that bus. Root busses get the OFW node of the host bridge (psycho).
* Garbage-collect "ofpci" and "ofppb" from the sparc64 port.
 1.3 13-May-2002  matt Don't panic is no class-code, just return. Needed for NetraX1.
 1.2 06-May-2002  eeh Fix printing during attach and get rid of pci_cd that's provided by the linker.
 1.1 06-May-2002  eeh Add the ofpci driver.
 1.4.2.2 16-May-2002  thorpej * Add "pcitag_t *pba_bridgetag" to pci_attach_args. This is set to
NULL for root PCI busses. For busses behind a bridge, it points to
a persistent copy of the bridge's pcitag_t. This can be very useful
for machine-dependent PCI bus enumeration code.
* Implement a machine-dependent pci_enumerate_bus() for sparc64 which
uses OFW device nodes to enumerate the bus. When a PCI bus that is
behind a bridge is attached, pci_attach_hook() allocates a new PCI
chipset tag for the new bus and sets it's "curnode" to the OFW node
of the bridge. This is used as a starting point when enumerating
that bus. Root busses get the OFW node of the host bridge (psycho).
* Garbage-collect "ofpci" and "ofppb" from the sparc64 port.
 1.4.2.1 16-May-2002  thorpej file ofpci.c was added on branch gehenna-devsw on 2002-05-16 01:01:45 +0000
 1.2 16-May-2002  thorpej branches: 1.2.2;
* Add "pcitag_t *pba_bridgetag" to pci_attach_args. This is set to
NULL for root PCI busses. For busses behind a bridge, it points to
a persistent copy of the bridge's pcitag_t. This can be very useful
for machine-dependent PCI bus enumeration code.
* Implement a machine-dependent pci_enumerate_bus() for sparc64 which
uses OFW device nodes to enumerate the bus. When a PCI bus that is
behind a bridge is attached, pci_attach_hook() allocates a new PCI
chipset tag for the new bus and sets it's "curnode" to the OFW node
of the bridge. This is used as a starting point when enumerating
that bus. Root busses get the OFW node of the host bridge (psycho).
* Garbage-collect "ofpci" and "ofppb" from the sparc64 port.
 1.1 06-May-2002  eeh Add the ofpci driver.
 1.2.2.2 16-May-2002  thorpej * Add "pcitag_t *pba_bridgetag" to pci_attach_args. This is set to
NULL for root PCI busses. For busses behind a bridge, it points to
a persistent copy of the bridge's pcitag_t. This can be very useful
for machine-dependent PCI bus enumeration code.
* Implement a machine-dependent pci_enumerate_bus() for sparc64 which
uses OFW device nodes to enumerate the bus. When a PCI bus that is
behind a bridge is attached, pci_attach_hook() allocates a new PCI
chipset tag for the new bus and sets it's "curnode" to the OFW node
of the bridge. This is used as a starting point when enumerating
that bus. Root busses get the OFW node of the host bridge (psycho).
* Garbage-collect "ofpci" and "ofppb" from the sparc64 port.
 1.2.2.1 16-May-2002  thorpej file ofpcivar.h was added on branch gehenna-devsw on 2002-05-16 01:01:45 +0000
 1.2 16-May-2002  thorpej branches: 1.2.2;
* Add "pcitag_t *pba_bridgetag" to pci_attach_args. This is set to
NULL for root PCI busses. For busses behind a bridge, it points to
a persistent copy of the bridge's pcitag_t. This can be very useful
for machine-dependent PCI bus enumeration code.
* Implement a machine-dependent pci_enumerate_bus() for sparc64 which
uses OFW device nodes to enumerate the bus. When a PCI bus that is
behind a bridge is attached, pci_attach_hook() allocates a new PCI
chipset tag for the new bus and sets it's "curnode" to the OFW node
of the bridge. This is used as a starting point when enumerating
that bus. Root busses get the OFW node of the host bridge (psycho).
* Garbage-collect "ofpci" and "ofppb" from the sparc64 port.
 1.1 06-May-2002  eeh Add ofppb to match ofpci.
 1.2.2.2 16-May-2002  thorpej * Add "pcitag_t *pba_bridgetag" to pci_attach_args. This is set to
NULL for root PCI busses. For busses behind a bridge, it points to
a persistent copy of the bridge's pcitag_t. This can be very useful
for machine-dependent PCI bus enumeration code.
* Implement a machine-dependent pci_enumerate_bus() for sparc64 which
uses OFW device nodes to enumerate the bus. When a PCI bus that is
behind a bridge is attached, pci_attach_hook() allocates a new PCI
chipset tag for the new bus and sets it's "curnode" to the OFW node
of the bridge. This is used as a starting point when enumerating
that bus. Root busses get the OFW node of the host bridge (psycho).
* Garbage-collect "ofpci" and "ofppb" from the sparc64 port.
 1.2.2.1 16-May-2002  thorpej file ofppb.c was added on branch gehenna-devsw on 2002-05-16 01:01:46 +0000
 1.20 17-Sep-2025  thorpej Don't get the OF phandle from i2c_attach_args::ia_cookie; get it from
self's devhandle.
 1.19 27-Jan-2021  thorpej branches: 1.19.4; 1.19.14;
Use DEVICE_COMPAT_EOL.
 1.18 25-Jan-2021  thorpej Since we're using designated initialisers for compat data, we should
use a completely empty initializer for the sentinel.
 1.17 17-Jan-2021  thorpej Use designated initializers and a consistent termination style in
compat_data[].
 1.16 23-Dec-2020  jdc Rename the CPU fan to SYS fan to match what the firmware calls it.
Check for fan failure and high temperature events when setting the fan
speed. If one or both is true, run the fans at full speed.
 1.15 20-Dec-2020  jdc For the E250:
set fans to medium speed when attaching and full speed when detaching.
remove unused PS fan definition.
In general:
return early from attach if the device isn't present.
handle errors from sysmon during attach so that detach doesn't crash.
try to handle errors when acquiring the iic bus during detach.
 1.14 07-Dec-2020  jdc Add some debugging output to check sensor addition and refresh.
 1.13 06-Dec-2020  jdc Don't read from the chip when matching, fail the attach instead (requested
by jmcneill). Reverts previous.
While here, handle errors attaching sysmon and acquiring the iic bus lock.
 1.12 05-Dec-2020  jdc When matching, try a read in case this is an optional device and isn't
actually present.
 1.11 31-Oct-2020  jdc branches: 1.11.2;
Call sysmon_envsys_unregister() not sysmon_envsys_destroy() when
detaching. Pointed out by Michael van Elst.
 1.10 24-Oct-2020  jdc Add support for automatically changing the CPU fan speed on the E250 in a
similar way to the SB1000/SB2000.
The fan control information was determined by experiment, as it's only
partially available in OFW.
Hardcode the missing information for E250 fan control into the driver
(it should be possible to support the E450 in future too).
 1.9 26-Jun-2018  thorpej 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.8 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.7 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.6 18-Mar-2012  mrg branches: 1.6.38;
add missing __KERNEL_RCSID().
 1.5 20-Jun-2011  pgoyette branches: 1.5.2; 1.5.6;
Initialize sensor states before registering.
 1.4 03-Apr-2011  jdc branches: 1.4.2;
Remove ENVSYS_FMONNOTSUPP, so that we can monitor this sensor.
 1.3 28-Feb-2010  martin branches: 1.3.2; 1.3.4; 1.3.6; 1.3.8;
dmesg cosmetics
 1.2 28-Feb-2010  pgoyette Set the FMONNOTSUPP flag for each individual sensor, and add the
FMONLIMITS flag so the sensor is actually monitored and events can
be generated.

As discussed with martin@ in private email.
 1.1 28-Feb-2010  martin Remove the envctrl driver, it is superseeded by the more general pcfiic @
ebus. Add the SB1000/SB2000 fan controll driver (tda). From OpenBSD.
Move config files over to direct configuration of i2c devices.
 1.3.8.1 06-Jun-2011  jruoho Sync with HEAD.
 1.3.6.2 30-Apr-2010  uebayasi Sync with HEAD.
 1.3.6.1 28-Feb-2010  uebayasi file pcf8591_envctrl.c was added on branch uebayasi-xip on 2010-04-30 14:39:51 +0000
 1.3.4.1 21-Apr-2011  rmind sync with head
 1.3.2.2 11-Mar-2010  yamt sync with head
 1.3.2.1 28-Feb-2010  yamt file pcf8591_envctrl.c was added on branch yamt-nfs-mp on 2010-03-11 15:03:00 +0000
 1.4.2.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.5.6.1 05-Apr-2012  mrg sync to latest -current.
 1.5.2.1 17-Apr-2012  yamt sync with head
 1.6.38.2 28-Jul-2018  pgoyette Sync with HEAD
 1.6.38.1 25-Jun-2018  pgoyette Sync with HEAD
 1.11.2.3 03-Apr-2021  thorpej Sync with HEAD.
 1.11.2.2 03-Jan-2021  thorpej Sync w/ HEAD.
 1.11.2.1 14-Dec-2020  thorpej Sync w/ HEAD.
 1.19.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.19.4.1 15-May-2021  thorpej - Move all of the stuff-missing-from-OFW-device-tree stuff into a
new function sparc64_device_tree_fixup(), and call it from
device_register().
- sparc64_device_tree_fixup() is table-driven, selecting the table
based on the machine_model. It can appy "dtnode" fixups (by matching
the device's OFW path) and "special" fixups, which are especially
useful when a property needs to be added to another device that happens
to not be in the OFW device tree.
- Implement enumeration of missing-from-OFW-device-tree i2c devices
by "sub-classing" the controller's device handle, intercepting the
"i2c-enumerate-devices" device call. We let the "super" first
enumerate any i2c devices that are in the OFW device tree, and then
enumerate our own additions after that is done. i2c additions are
provided by the machine_model fixup tables.
 1.9 01-Sep-2025  thorpej Put the pcfiic driver declaration in the global location, and adapt
the sparc64 instance to be a proper separate attachment.
 1.8 31-Aug-2025  thorpej Don't rely on pcfiic_attach() to print the newline.
 1.7 23-Oct-2020  jdc branches: 1.7.6; 1.7.16;
Move E250 and E450 i2c patches from dev/pcfiic_ebus.c to sparc64/ofw_patch.c.
They are now co-located with the other OFW patch routines.
New i2c devices are created for E250/E450 and v210/v240, so create new
functions to avoid duplicate code.
 1.6 12-Jun-2020  thorpej Update for proplib(3) API changes.
 1.5 03-Jan-2016  jdc Remove duplicate register definitions and merge them all into pcf8584reg.h.
No functional change.
 1.4 03-Feb-2013  jdc branches: 1.4.14;
Output "iic mux present" if this device has multiple IIC buses (0 and 1).
The device has multiple buses if the second (bus select) register is present.
 1.3 18-Mar-2012  mrg branches: 1.3.2;
add missing __KERNEL_RCSID().
 1.2 01-Jul-2011  dyoung branches: 1.2.2; 1.2.6;
#include <sys/bus.h> instead of <machine/bus.h>.
 1.1 28-Feb-2010  martin branches: 1.1.2; 1.1.6;
Remove the envctrl driver, it is superseeded by the more general pcfiic @
ebus. Add the SB1000/SB2000 fan controll driver (tda). From OpenBSD.
Move config files over to direct configuration of i2c devices.
 1.1.6.2 30-Apr-2010  uebayasi Sync with HEAD.
 1.1.6.1 28-Feb-2010  uebayasi file pcfiic_ebus.c was added on branch uebayasi-xip on 2010-04-30 14:39:51 +0000
 1.1.2.2 11-Mar-2010  yamt sync with head
 1.1.2.1 28-Feb-2010  yamt file pcfiic_ebus.c was added on branch yamt-nfs-mp on 2010-03-11 15:03:00 +0000
 1.2.6.1 05-Apr-2012  mrg sync to latest -current.
 1.2.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.2.2.1 17-Apr-2012  yamt sync with head
 1.3.2.2 03-Dec-2017  jdolecek update from HEAD
 1.3.2.1 25-Feb-2013  tls resync with head
 1.4.14.1 19-Mar-2016  skrll Sync with HEAD
 1.7.16.2 12-Sep-2021  thorpej - Improve some comments.
- Update pcfiic_i2c_exec() for the channel split (might fix an issue
spotted by tnn@ in testing).
 1.7.16.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.7.6.1 14-May-2021  thorpej Update the pcfiic driver for the new i2c device enumeration scheme.
Push the multiple-channels complexity up into the ebus front-end,
as that specific to a particular Sun model of controller. Now
the BBC-type controllers get multiple I2C bus instances attached to
them.
 1.84 04-Oct-2025  thorpej Don't use the common OpenFirmware PCI-device-to-devhandle mapping
routine. We've gone through the trouble of encoding the PROM node
into the pcitag_t, and using that ensures we're consistent with
any PROM data quirks.
 1.83 23-Jun-2024  riastradh pci: Pass cookie through pci_find_device, pci_enumerate_bus, take 2.

New functions pci_find_device1 and pci_enumerate_bus1 have the cookie
argument. Existing symbols pci_find_device and pci_enumerate_bus are
now wrappers for the cookieless version.

This will allow pci_find_device callers to pass a cookie through to
the match function so they can keep state or pass in extra parameters
like b/d/f numbers, which will allow us to nix some horrible kludges
in the Linux PCI API emulation for drm (and, perhaps, Intel wifi).

This change drops the symbol pci_probe_device, in favour of a new
pci_probe_device1 with the cookie argument. But I don't think that
requires a revbump because it's only called by MD pci_enumerate_bus1
implementations, which don't live in modules anyway.

Take 2: Make sure to handle NULL match function.
 1.82 20-May-2024  riastradh Revert "pci: Pass cookie through pci_find_device, pci_enumerate_bus."

Evidently something is wrong with this, to be diagnosed and redone
once the builds and tests are in better shape.
 1.81 20-May-2024  riastradh pci: Pass cookie through pci_find_device, pci_enumerate_bus.

New functions pci_find_device1 and pci_enumerate_bus1 have the cookie
argument. Existing symbols pci_find_device and pci_enumerate_bus are
now wrappers for the cookieless version.

This drops the symbol pci_probe_device, in favour of a new
pci_probe_device1 with the cookie argument. But I don't think that
requires a revbump because it's only called by MD pci_enumerate_bus1
implementations, which don't live in modules anyway.
 1.80 20-Dec-2023  thorpej Remove unnecessary <sys/malloc.h>.
 1.79 01-Oct-2022  charlotte branches: 1.79.4;
Don't try to make a tag based on node 0
 1.78 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.77 29-Mar-2014  christos branches: 1.77.28; 1.77.30;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.76 26-Mar-2014  christos kill sprintf
 1.75 27-Oct-2012  chs branches: 1.75.2;
split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.74 12-Aug-2011  mrg branches: 1.74.2; 1.74.12;
convert some open-coded SPDB_PROBE printf calls to use DPRINTF() macro.
 1.73 01-Jul-2011  dyoung #include <sys/bus.h> instead of <machine/bus.h>.
 1.72 11-May-2011  macallan when looking for a device's node we want to start with the child nodes of the
root bus, not its peers
 1.71 04-Apr-2011  dyoung Neither pci_dma64_available(), pci_probe_device(), pci_mapreg_map(9),
pci_find_rom(), pci_intr_map(9), pci_enumerate_bus(), nor the match
predicate passed to pciide_compat_intr_establish() should ever modify
their pci_attach_args argument, so make their pci_attach_args arguments
const and deal with the fallout throughout the kernel.

For the most part, these changes add a 'const' where there was no
'const' before, however, some drivers and MD code used to modify
pci_attach_args. Now those drivers either copy their pci_attach_args
and modify the copy, or refrain from modifying pci_attach_args:

Xen: according to Manuel Bouyer, writing to pci_attach_args in
pci_intr_map() was a leftover from Xen 2. Probably a bug. I
stopped writing it. I have not tested this change.

siside(4): sis_hostbr_match() needlessly wrote to pci_attach_args.
Probably a bug. I use a temporary variable. I have not tested this
change.

slide(4): sl82c105_chip_map() overwrote the caller's pci_attach_args.
Probably a bug. Use a local pci_attach_args. I have not tested
this change.

viaide(4): via_sata_chip_map() and via_sata_chip_map_new() overwrote the
caller's pci_attach_args. Probably a bug. Make a local copy of the
caller's pci_attach_args and modify the copy. I have not tested
this change.

While I'm here, make pci_mapreg_submap() static.

With these changes in place, I have tested the compilation of these
kernels:

alpha GENERIC
amd64 GENERIC XEN3_DOM0
arc GENERIC
atari HADES MILAN-PCIIDE
bebox GENERIC
cats GENERIC
cobalt GENERIC
evbarm-eb NSLU2
evbarm-el ADI_BRH ARMADILLO9 CP3100 GEMINI GEMINI_MASTER GEMINI_SLAVE GUMSTIX
HDL_G IMX31LITE INTEGRATOR IQ31244 IQ80310 IQ80321 IXDP425 IXM1200
KUROBOX_PRO LUBBOCK MARVELL_NAS NAPPI SHEEVAPLUG SMDK2800 TEAMASA_NPWR
TEAMASA_NPWR_FC TS7200 TWINTAIL ZAO425
evbmips-el AP30 DBAU1500 DBAU1550 MALTA MERAKI MTX-1 OMSAL400 RB153 WGT624V3
evbmips64-el XLSATX
evbppc EV64260 MPC8536DS MPC8548CDS OPENBLOCKS200 OPENBLOCKS266
OPENBLOCKS266_OPT P2020RDB PMPPC RB800 WALNUT
hp700 GENERIC
i386 ALL XEN3_DOM0 XEN3_DOMU
ibmnws GENERIC
macppc GENERIC
mvmeppc GENERIC
netwinder GENERIC
ofppc GENERIC
prep GENERIC
sandpoint GENERIC
sgimips GENERIC32_IP2x
sparc GENERIC_SUN4U KRUPS
sparc64 GENERIC

As of Sun Apr 3 15:26:26 CDT 2011, I could not compile these kernels
with or without my patches in place:

### evbmips-el GDIUM

nbmake: nbmake: don't know how to make /home/dyoung/pristine-nbsd/src/sys/arch/mips/mips/softintr.c. Stop

### evbarm-el MPCSA_GENERIC
src/sys/arch/evbarm/conf/MPCSA_GENERIC:318: ds1672rtc*: unknown device `ds1672rtc'

### ia64 GENERIC

/tmp/genassym.28085/assym.c: In function 'f111':
/tmp/genassym.28085/assym.c:67: error: invalid application of 'sizeof' to incomplete type 'struct pcb'
/tmp/genassym.28085/assym.c:76: error: dereferencing pointer to incomplete type

### sgimips GENERIC32_IP3x

crmfb.o: In function `crmfb_attach':
crmfb.c:(.text+0x2304): undefined reference to `ddc_read_edid'
crmfb.c:(.text+0x2304): relocation truncated to fit: R_MIPS_26 against `ddc_read_edid'
crmfb.c:(.text+0x234c): undefined reference to `edid_parse'
crmfb.c:(.text+0x234c): relocation truncated to fit: R_MIPS_26 against `edid_parse'
crmfb.c:(.text+0x2354): undefined reference to `edid_print'
crmfb.c:(.text+0x2354): relocation truncated to fit: R_MIPS_26 against `edid_print'
 1.70 20-Mar-2011  mrg remove unnecessary iommuvar.h and psycho{reg,var}.h includes.
 1.69 16-Mar-2011  mrg don't try to turn on parity or set the latency timer, or dump pci config
space for the pci bridge in sparc64_pci_enumerate_bus(). it doesn't work
on PCIe adapters. #if 0'ed for now, should move this into psycho/schizo.
 1.68 18-Dec-2010  mrg branches: 1.68.2;
allow sparc64 spc_find_ino() to be NULL; schizo doesn't need it.
 1.67 07-Jan-2010  jdc branches: 1.67.4;
Cope with up to four "interrupts" properties for a node.
Just use the first one for now. This should be improved.
OK: mrg@.
 1.66 06-Jan-2010  mrg move the guts of pci_intr_map() into pci_machdep.c, and move the schizo
ign addition into a hook. also, don't double shift the ign in set_intr.

tested on U60 and SB2500.
 1.65 30-Nov-2009  mrg convert pci_intr_map() into a chipset tag function pointer, and implement
the schizo version slightly differently.

pull out the schizo's IGN from the upaid, not the apparently broken device
ID register. from openbsd.

with this i appear to have valid working interrupts on the SB2500.

tested on U60 and SB2500.


XXX: we can probably kill (*spc_find_ino)() now that pci_intr_map() itself
XXX: is no longer a first class function.
 1.64 28-Nov-2009  mrg give more debug output about mapping interrupts.
 1.63 27-Nov-2009  mrg clean up some debug messages a little bit.
 1.62 10-Dec-2008  nakayama pci_make_tag:
- add assertion for checking spc_busnode initialization.
 1.61 10-Dec-2008  mrg ofpci_make_tag():
don't write PCI_COMMAND_STATUS_REG with
PCI_COMMAND_(MEM|MASTER|IO)_ENABLE, or it in.
sparc_pci_childspace():
move psycho.c:get_childspace() into pci_machdep.c but rename it
psycho_alloc_bus_tag():
use M_ZERO
 1.60 07-Dec-2008  mrg a few clean up/rearrange changes, somewhat inspired from openbsd's
schizo.c:

- rename pp_busnode{} -> spc_busnode{}, and move it to
sparc_pci_chipset{}

- move public pci functions pci_conf_read(), pci_conf_write() and
pci_intr_establish() into psycho.c, renaming them in the process,
and add pointers through sparc_pci_chipset{} to access them.
as part of this, add PDB_INTMAP and PDB_CONF debug options to
psycho.c

- move and rename sparc64 private pci_find_ino() into
sparc_pci_chipset{}, like the above

- update psycho_alloc_chipset() to set the new 4 function members


no functional change intended. XXX: not tested on cardbus.
 1.59 30-May-2008  ad branches: 1.59.4; 1.59.6;
pci_intr_setattr(), allows PCI interrupts to be marked MPSAFE on x86, and
other platforms if the code is added.

pci_intr_map(...)
pci_intr_setattr(pc, ih, PCI_INTR_MPSAFE, 1);
pci_intr_establish(...)
 1.58 29-May-2008  mrg remove clause #3 from my license where there are no other
copyright holders involved.
 1.57 24-Mar-2008  cube branches: 1.57.2; 1.57.4; 1.57.6;
Change previous to use aprint_error_dev.
 1.56 23-Mar-2008  macallan use device_xname()
 1.55 03-Feb-2008  martin branches: 1.55.6;
Do not panic when trying to disestablish a pci interrupt.
 1.54 04-Apr-2007  tnn branches: 1.54.14; 1.54.20;
pci_find_ino(): Use interrupt pin from pci_attach_args when mapping interrupts.
Use *ihp as a pure output. Fix case where interrupt pin #D was incorrectly
mapped. Some cosmetic changes while here. Ok'd by martin.
 1.53 21-Oct-2006  mrg branches: 1.53.4; 1.53.8; 1.53.10;
remove "struct cacheline" and the "cacheline" variable. (it was only set
in cpu_attach(), overwritten by multiple cpus, and only one member of the
12 or more were ever used again.) add an ecache_min_line_size to replace
this functionality.

clean up some non-SMP friendly code from cpu_attach():
- only reset the fpu state on the boot cpu
- don't bother printing "FPU version 0" always
- don't call getver() and ignore the result
- print the UPA id on the first cpu0: line

only print mp_tramp address #ifdef DEBUG.

reset the fpu state in cpu_hatch(), like cpu_attach() does for the boot cpu.


cpu_attach() is now free of SMP-unfriendly code.
 1.52 15-Oct-2006  martin Missing initializers
 1.51 11-Feb-2006  cdi branches: 1.51.14; 1.51.16;
ANSIfication: u_intN_t -> uintN_t, use ANSI function declarations/definitions
instead of K&R ones.
 1.50 11-Dec-2005  christos branches: 1.50.2; 1.50.4; 1.50.6;
merge ktrace-lwp.
 1.49 17-Aug-2004  drochner branches: 1.49.12;
make PCI devices attachable/detachable (as far as the particular drivers
allow), and allow to rescan a bus selectively (ie only the device/
function I'm looking at)
 1.48 29-Jul-2004  drochner give the special PCI bus enumerator a sparc64_ prefix and make the
PCI_MACHDEP_ENUMERATE_BUS macro point to it
 1.47 11-Jun-2004  petrov pci_find_ino: support pci-pci bridges.
 1.46 04-Apr-2004  nakayama Revert a part of rev. 1.44.

OF_getprop can get only the first "reg" property with a statically
allocated buffer, but prom_getprop cannot.
This should fix a "kernel trap 30: data access exception" when you
invoke a pcictl(8).
 1.45 28-Mar-2004  nakayama branches: 1.45.2;
Set prom_getprop args correctly.
 1.44 21-Mar-2004  pk Some more promlib interface conversions.
 1.43 21-Mar-2004  pk Two commas went missing in last commit.
 1.42 21-Mar-2004  pk Partial switch to the promlib interface.
 1.41 21-Jan-2004  petrov For pci devices without ofw mapping find ino by pci bus/slot/device
information, from OpenBSD.
 1.40 09-Nov-2003  martin Nuke bcopy/bzero.
 1.39 22-Aug-2003  petrov Cosmetic: move DEBUG defines.
 1.38 15-Jul-2003  lukem __KERNEL_RCSID()
 1.37 05-May-2003  martin branches: 1.37.2;
When overwriting the cache line size configuration, do not use the magic
value 0x10, but instead calculate a line size that is properly aligned
to the IOMMU strbuf cache and our external cache line size.
From FreeBSD.
 1.36 04-May-2003  martin Move the bus speed query code into it's own function and make it default
to 33 MHz. Cosmetics, no functional change.
 1.35 22-Mar-2003  nakayama PCI-CardBus bridge support for sparc64:
- handle devices which has no OBP node.
- move PCI latency-timer initialization from pci_intr_map to
pci_enumerate_bus.
- make PCI bus free space extents for cardbus devices.
- fix PCI config space map size.
- some code integrations.
 1.34 10-Dec-2002  pk Remove the `flags' argument from bus_intr_establish().
 1.33 28-Sep-2002  martin Set the PCI latency timer for bus master devices.

Slightly different to the patch suggested by Takeshi Nakayama in PR 18451
(idea from FreeBSD).

Additional input from Jason Thorpe: do not hard code the bus frequency,
instead get it from OpenFirmware.
 1.32 29-Jun-2002  eeh Turn on parity checking for the PCI bus.
 1.31 16-May-2002  eeh branches: 1.31.2;
Make the PCI code actually work.
 1.30 16-May-2002  thorpej branches: 1.30.2;
* Add "pcitag_t *pba_bridgetag" to pci_attach_args. This is set to
NULL for root PCI busses. For busses behind a bridge, it points to
a persistent copy of the bridge's pcitag_t. This can be very useful
for machine-dependent PCI bus enumeration code.
* Implement a machine-dependent pci_enumerate_bus() for sparc64 which
uses OFW device nodes to enumerate the bus. When a PCI bus that is
behind a bridge is attached, pci_attach_hook() allocates a new PCI
chipset tag for the new bus and sets it's "curnode" to the OFW node
of the bridge. This is used as a starting point when enumerating
that bus. Root busses get the OFW node of the host bridge (psycho).
* Garbage-collect "ofpci" and "ofppb" from the sparc64 port.
 1.29 15-May-2002  thorpej Garbage-collect __PCI_DEV_FUNCORDER.
 1.28 15-May-2002  thorpej Implement pci_decompose_tag().
 1.27 06-May-2002  eeh Add ofpci_make_tag().
 1.26 20-Mar-2002  eeh Overhaul bus space.

bus_space_handle_t now holds an address and two ASIs, one for normal accesses
and one for streaming accesses. This allows to map individual handles
different ways, so some can use MMU bypass accesses and others use virtual
addresses. bus_space_map() will now create handles that use bypass accesses
unles BUS_SPACE_MAP_LINEAR is passed in. So only pass in BUS_SPACE_MAP_LINEAR
if you absolutely *need* to use bus_space_vaddr(). This removes at least one
extra level of indirection and should reduce TLB misses.

32-bit kernels have problems accessing 64-bit addresses, so they always use
virtual addresses.
 1.25 17-Oct-2001  thorpej branches: 1.25.4;
Fix the semantics of __PCI_DEV_FUNCORDER so that they're actually useful:
If __PCI_DEV_FUNCORDER is defined, don't do the song-and-dance to check if
a device is multi-function; machdep code is going to tell us exactly which
functions to probe.

Note this required changing how pci_func_devorder() works in the
sparc64 PCI machdep code; now the "curnode" is assumed to point
to the bus, rather than some function (typically 0) on the device,
just as pci_bus_devorder() makes that assumption.

All this should allow the PCI code to actually locate the second
HME device on a Sun Netra t1, which is at 3,1 -- previously, the
PCI code would have missed it because there is no device at 3,0.

(Sun deserves a brick to the head for this one -- this seems clearly
out of line with the PCI spec.)
 1.24 15-Sep-2001  mrg in pci_conf_read() and pci_conf_write(), convert all printf()'s to only
occur if SPDB_CONF (and hence DEBUG). also convert the panic in
pci_conf_write() to a SPDB_CONF warning and a return.

this cleans up pcictl(8) support.
 1.23 23-Aug-2001  eeh branches: 1.23.2;
Fix backwards compare. (From Jason Wright)
 1.22 20-Jul-2001  eeh PCI overhaul.
 1.21 21-Mar-2001  mrg branches: 1.21.2;
adapt to systems with out interrupt-map & interrupt-map-mask properties.
 1.20 06-Mar-2001  mrg rework pci_attach_hook() to just deal with the INO, not the full
interrupt number. properly find interrupts for the E250. modify
pci_intr_map() accordingly. retire psycho_intr_map(). deal with
INO values upto 0x3f, not upto 0x32. restructure sabre_init() and
psycho_init() to be more similar, and display each psycho's IGN.
psycho_intr_establish() deals with INO upto 0x3f, values from 0x32
and higher get 0 for IPL.

tested on E250 & U5.
 1.19 02-Mar-2001  mrg branches: 1.19.2;
use pci_bus_devorder() and pci_dev_funcorder()
 1.18 19-Jan-2001  martin Enable IO space mapping by default.
Fixes PR 11940.
 1.17 14-Jan-2001  martin Fix format warnings to make it compile again.
 1.16 28-Dec-2000  sommerfeld 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.15 26-Jul-2000  pk On-board devices on psycho machines seem to have the `interrupt' property
in the parent bus format (i.e. an INO) rather than being represented as
an PCI interrupt line. Provide a hack to work around this in pci_attach_hook().
 1.14 18-Jul-2000  pk Use probeget() in pci_config_read() for the psycho, to avoid bus
faults when probing PCI space.
 1.13 09-Jul-2000  pk Add a `device class' interrupt level argument (from machine/intr.h)
to bus_interrupt_establish().

It's currently only used in sparc64/dev/psycho.c to assign a CPU interrupt
level to devices in PCI slots.
 1.12 29-Jun-2000  mrg remove include of <vm/vm.h>. <vm/vm.h> -> <uvm/uvm_extern.h>
 1.11 26-Jun-2000  mrg remove/move more mach vm header files:

<vm/pglist.h> -> <uvm/uvm_pglist.h>
<vm/vm_inherit.h> -> <uvm/uvm_inherit.h>
<vm/vm_kern.h> -> into <uvm/uvm_extern.h>
<vm/vm_object.h> -> nothing
<vm/vm_pager.h> -> into <uvm/uvm_pager.h>

also includes a bunch of <vm/vm_page.h> include removals (due to redudancy
with <vm/vm.h>), and a scattering of other similar headers.
 1.10 18-Jun-2000  mrg branches: 1.10.2;
kill dead code.
 1.9 08-Jun-2000  eeh Turn on PCI MEM and DMA.
 1.8 04-Jun-2000  cgd Implement the more flexiable `evcnt' interface as discussed (briefly) on
tech-kern and now documented in evcnt(9).
 1.7 24-May-2000  eeh branches: 1.7.2;
Use the PCI function code to distinguish simba bus A from bus B instead
of the current hack.
 1.6 17-May-2000  mrg add a note about US IIi and PCI_INTERRUPT_LINE register
 1.5 08-Apr-2000  mrg - store the ebus's parent so we can find the IOMMU
- use generic iommu routines in the ebus code (uses the above)
- add some more comments.
 1.4 05-Apr-2000  mrg clean this up some.
 1.3 05-Jun-1999  eeh branches: 1.3.2; 1.3.4;
Make pbrobeget() and probeset() work for 64-bit values as well. To do this
the arguments are changed so the address is first and the ASI second so we
can have the address in %o0:%o1 and not worry about unused registers.

Also a bit of copyright cleanup.
 1.2 05-Jun-1999  mrg clean up a bit, implement pci_conf_{read,write}() with probe[gs]et() (not yet used).
 1.1 04-Jun-1999  mrg PCI driver for the UltraSPARC. this only works on the Ultra5/10 machines
(`SUNW,sabre') for now, and it doesn't really quite work there yet anyway.
the bus space/dma code is cloned from the sbus driver. the IOMMU code also
is cloned from the sbus code, but separated out into iommu.c so that we can
share it with the sbus driver. hopefully, much of the bus space/dma code
can also be re-shared with the sbus driver and the ebus driver but for now
these copies will do.

support for the real UltraSPARC PCI (`SUNW,psycho') is unwritten, though
most of this code is shared with it.

we can probe PCI config space and try to configue devices, but interrupts
don't work yet...
 1.3.4.6 27-Mar-2001  bouyer Sync with HEAD.
 1.3.4.5 12-Mar-2001  bouyer Sync with HEAD.
 1.3.4.4 11-Feb-2001  bouyer Sync with HEAD.
 1.3.4.3 18-Jan-2001  bouyer Sync with head (for UBC+NFS fixes, mostly).
 1.3.4.2 05-Jan-2001  bouyer Sync with HEAD
 1.3.4.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-1999  thorpej Sync w/ -current.
 1.7.2.1 22-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.10.2.2 31-Jul-2000  mrg pull up 1.15 (approved by thorpej):
>On-board devices on psycho machines seem to have the `interrupt' property
>in the parent bus format (i.e. an INO) rather than being represented as
>an PCI interrupt line. Provide a hack to work around this in pci_attach_hook().
 1.10.2.1 18-Jul-2000  mrg pullup the contents of -current arch/sparc64. this gives us significant
ultrasparc PCI support (ultra5, ultra10, AXi, and E250 tested so far),
plus many other small fixes. netbooting is now supported.
 1.19.2.1 09-Apr-2001  nathanw Catch up with -current.
 1.21.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.21.2.5 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.21.2.4 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.21.2.3 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.21.2.2 25-Aug-2001  thorpej Merge Aug 24 -current into the kqueue branch.
 1.21.2.1 03-Aug-2001  lukem update to -current
 1.23.2.1 01-Oct-2001  fvdl Catch up with -current.
 1.25.4.6 11-Dec-2002  thorpej Sync with HEAD.
 1.25.4.5 18-Oct-2002  nathanw Catch up to -current.
 1.25.4.4 01-Aug-2002  nathanw Catch up to -current.
 1.25.4.3 20-Jun-2002  nathanw Catch up to -current.
 1.25.4.2 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.25.4.1 17-Oct-2001  nathanw file pci_machdep.c was added on branch nathanw_sa on 2002-04-01 07:43:03 +0000
 1.30.2.3 17-Jul-2002  gehenna catch up with -current.
 1.30.2.2 30-May-2002  gehenna Catch up with -current.
 1.30.2.1 16-May-2002  gehenna file pci_machdep.c was added on branch gehenna-devsw on 2002-05-30 15:35:48 +0000
 1.31.2.1 22-Nov-2002  tron Pull up revision 1.33 (requested by martin in ticket #875):
Set the PCI latency timer for bus master devices.
Slightly different to the patch suggested by Takeshi Nakayama in PR 18451
(idea from FreeBSD).
Additional input from Jason Thorpe: do not hard code the bus frequency,
instead get it from OpenFirmware.
 1.37.2.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.37.2.3 18-Sep-2004  skrll Sync with HEAD.
 1.37.2.2 25-Aug-2004  skrll Sync with HEAD.
 1.37.2.1 03-Aug-2004  skrll Sync with HEAD
 1.45.2.2 14-Jun-2004  jmc Pullup rev 1.47 (requested by petrov in ticket #469)

pci_find_ino: support pci-pci bridges.
 1.45.2.1 05-Apr-2004  tron Pull up revision 1.46 (requested by nakayama in ticket #60):
Revert a part of rev. 1.44.
OF_getprop can get only the first "reg" property with a statically
allocated buffer, but prom_getprop cannot.
This should fix a "kernel trap 30: data access exception" when you
invoke a pcictl(8).
 1.49.12.5 24-Mar-2008  yamt sync with head.
 1.49.12.4 04-Feb-2008  yamt sync with head.
 1.49.12.3 03-Sep-2007  yamt sync with head.
 1.49.12.2 30-Dec-2006  yamt sync with head.
 1.49.12.1 21-Jun-2006  yamt sync with head.
 1.50.6.1 22-Apr-2006  simonb Sync with head.
 1.50.4.1 09-Sep-2006  rpaulo sync with head
 1.50.2.1 18-Feb-2006  yamt sync with head.
 1.51.16.1 22-Oct-2006  yamt sync with head
 1.51.14.1 18-Nov-2006  ad Sync with head.
 1.53.10.1 11-Jul-2007  mjf Sync with head.
 1.53.8.1 10-Apr-2007  ad Sync with head.
 1.53.4.1 15-Apr-2007  yamt sync with head.
 1.54.20.1 18-Feb-2008  mjf Sync with HEAD.
 1.54.14.1 23-Mar-2008  matt sync with HEAD
 1.55.6.3 17-Jan-2009  mjf Sync with HEAD.
 1.55.6.2 02-Jun-2008  mjf Sync with HEAD.
 1.55.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.57.6.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.57.4.2 11-Mar-2010  yamt sync with head
 1.57.4.1 04-May-2009  yamt sync with head.
 1.57.2.1 04-Jun-2008  yamt sync with head
 1.59.6.1 19-Jan-2009  skrll Sync with HEAD.
 1.59.4.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.67.4.3 31-May-2011  rmind sync with head
 1.67.4.2 21-Apr-2011  rmind sync with head
 1.67.4.1 05-Mar-2011  rmind sync with head
 1.68.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.74.12.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.74.12.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.74.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.74.2.1 30-Oct-2012  yamt sync with head
 1.75.2.1 18-May-2014  rmind sync with head
 1.77.30.1 10-Jun-2019  christos Sync with HEAD
 1.77.28.1 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.79.4.1 04-Oct-2024  martin Pull up following revision(s) (requested by rin in ticket #928):

sys/external/bsd/drm2/dist/drm/drm_gem.c: revision 1.25
sys/external/bsd/drm2/dist/drm/radeon/radeon_ci_dpm.c: revision 1.7
sys/external/bsd/drm2/dist/drm/nouveau/nvkm/engine/device/priv.h: revision 1.4
sys/external/bsd/drm2/dist/drm/nouveau/nvkm/engine/device/nouveau_nvkm_engine_device_acpi.c: revision 1.4
sys/external/bsd/drm2/dist/drm/i915/display/intel_opregion.h: revision 1.6
sys/external/bsd/drm2/dist/drm/i915/i915_drv.h: revision 1.49
sys/external/bsd/drm2/include/linux/mxm-wmi.h: revision 1.1
sys/external/bsd/drm2/dist/drm/nouveau/nvkm/subdev/pci/nouveau_nvkm_subdev_pci_pcie.c: revision 1.4
sys/external/bsd/drm2/dist/drm/nouveau/nvkm/engine/device/nouveau_nvkm_engine_device_base.c: revision 1.13
sys/external/bsd/common/include/linux/bitops.h: revision 1.17
sys/external/bsd/drm2/nouveau/files.nouveau: revision 1.40
sys/external/bsd/drm2/linux/linux_pci.c: revision 1.30
sys/external/bsd/drm2/dist/drm/radeon/radeon_drv.h: revision 1.5
sys/external/bsd/drm2/dist/drm/nouveau/nvkm/subdev/pci/nouveau_nvkm_subdev_pci_pcie.c: revision 1.5
sys/external/bsd/drm2/dist/drm/nouveau/nvkm/subdev/mxm/nouveau_nvkm_subdev_mxm_base.c: revision 1.5
sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_gart.c: revision 1.12
sys/external/bsd/drm2/dist/drm/radeon/radeon_rv770.c: revision 1.3
sys/external/bsd/drm2/dist/drm/nouveau/nvkm/engine/disp/nouveau_nvkm_engine_disp_sorgm200.c: revision 1.3
sys/external/bsd/common/include/linux/printk.h: revision 1.14
sys/external/bsd/drm2/dist/drm/nouveau/nvkm/subdev/instmem/nouveau_nvkm_subdev_instmem_gk20a.c: revision 1.10
sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_vi.c: revision 1.4
sys/external/bsd/drm2/include/linux/acpi.h: revision 1.11
sys/external/bsd/drm2/drm/drm_cdevsw.c: revision 1.31
sys/external/bsd/drm2/dist/drm/radeon/radeon_si.c: revision 1.6
sys/external/bsd/drm2/dist/drm/nouveau/nouveau_acpi.c: revision 1.5
sys/external/bsd/drm2/dist/drm/i915/display/intel_acpi.h: revision 1.5
sys/external/bsd/drm2/include/acpi/video.h: revision 1.3
sys/external/bsd/drm2/dist/drm/radeon/radeon_evergreen.c: revision 1.6
sys/external/bsd/drm2/dist/drm/nouveau/nouveau_acpi.h: revision 1.4
sys/arch/sparc64/include/pci_machdep.h: revision 1.31
sys/arch/sparc64/dev/pci_machdep.c: revision 1.83
sys/external/bsd/drm2/include/linux/kref.h: revision 1.14
sys/external/bsd/drm2/dist/drm/nouveau/nvkm/engine/device/nouveau_nvkm_engine_device_pci.c: revision 1.12
sys/external/bsd/drm2/linux/linux_dma_buf.c: revision 1.17
sys/external/bsd/drm2/dist/drm/nouveau/nvkm/subdev/bios/nouveau_nvkm_subdev_bios_shadowacpi.c: revision 1.4
sys/external/bsd/drm2/drm/drm_module.c: revision 1.32
sys/external/bsd/drm2/dist/drm/i915/i915_gem.h: revision 1.8
sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_dmabuf.c: revision 1.7
sys/external/bsd/drm2/include/linux/smp.h: revision 1.5
sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_si.c: revision 1.5
sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_device.c: revision 1.20
sys/arch/x86/x86/bus_dma.c: revision 1.91
sys/external/bsd/drm2/radeon/files.radeon: revision 1.40
sys/external/bsd/drm2/include/acpi/acpi_bus.h: revision 1.1
sys/external/bsd/drm2/dist/drm/nouveau/nouveau_drv.h: revision 1.5
sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_device.c: revision 1.21
sys/external/bsd/common/include/asm/barrier.h: revision 1.20
sys/external/bsd/drm2/include/linux/nbsd-namespace-acpi.h: revision 1.2
sys/external/bsd/common/include/asm/barrier.h: revision 1.21
sys/modules/drmkms/drmkms_pci.h: revision 1.1
sys/external/bsd/drm2/dist/drm/drm_dp_helper.c: revision 1.17
sys/external/bsd/drm2/radeon/radeon_pci.c: revision 1.23
sys/external/bsd/drm2/linux/linux_xa.c: revision 1.4
sys/external/bsd/drm2/ttm/ttm_bo_vm.c: revision 1.23
sys/external/bsd/drm2/ttm/ttm_bo_vm.c: revision 1.24
sys/external/bsd/drm2/ttm/ttm_bo_vm.c: revision 1.25
sys/external/bsd/drm2/linux/linux_pci.c: revision 1.26
sys/dev/pci/pcivar.h: revision 1.120
sys/arch/xen/include/pci_machdep.h: revision 1.24
sys/external/bsd/drm2/ttm/ttm_bo_vm.c: revision 1.26
sys/external/bsd/drm2/linux/linux_pci.c: revision 1.27
sys/external/bsd/drm2/ttm/ttm_bo_vm.c: revision 1.27
sys/external/bsd/drm2/linux/linux_pci.c: revision 1.28
sys/external/bsd/drm2/dist/drm/radeon/radeon_cik.c: revision 1.8
sys/external/bsd/drm2/ttm/ttm_bo_vm.c: revision 1.28
sys/external/bsd/drm2/linux/linux_pci.c: revision 1.29
sys/external/bsd/drm2/include/linux/pci.h: revision 1.57
sys/external/bsd/drm2/include/linux/pci.h: revision 1.58
sys/external/bsd/drm2/dist/drm/radeon/radeon_acpi.c: revision 1.5
sys/external/bsd/drm2/dist/drm/nouveau/nouveau_display.c: revision 1.6
sys/external/bsd/drm2/dist/drm/amd/powerplay/hwmgr/amdgpu_hwmgr.c: revision 1.3
sys/external/bsd/drm2/dist/drm/amd/display/dc/core/amdgpu_dc_stream.c: revision 1.3
share/man/man9/bus_dma.9: revision 1.69
sys/external/bsd/drm2/drm/drm_gem_cma_helper.c: revision 1.15
sys/external/bsd/drm2/dist/drm/radeon/radeon_acpi.c: revision 1.6
sys/external/bsd/drm2/dist/drm/radeon/radeon.h: revision 1.12
sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_cik.c: revision 1.7
sys/dev/acpi/acpi_mcfg.c: revision 1.29
sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_acpi.c: revision 1.6
sys/external/bsd/drm2/dist/drm/radeon/radeon_r600.c: revision 1.7
sys/external/bsd/drm2/dist/drm/radeon/radeon_bios.c: revision 1.13
sys/modules/amdgpu/Makefile: revision 1.9
sys/external/bsd/drm2/dist/drm/radeon/radeon_bios.c: revision 1.14
sys/external/bsd/common/linux/linux_tasklet.c: revision 1.12
sys/external/bsd/drm2/dist/drm/nouveau/include/nvkm/core/device.h: revision 1.10
sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_mman.c: revision 1.23
sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu.h: revision 1.9
sys/external/bsd/drm2/include/linux/interval_tree.h: revision 1.14
sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_mman.c: revision 1.26
sys/external/bsd/drm2/dist/drm/amd/powerplay/hwmgr/amdgpu_smu7_hwmgr.c: revision 1.5
sys/dev/pci/pci.c: revision 1.168
sys/external/bsd/drm2/dist/drm/i915/gem/i915_gem_mman.c: revision 1.27
sys/external/bsd/drm2/dist/drm/radeon/radeon_si_dpm.c: revision 1.9
sys/external/bsd/drm2/pci/files.drmkms_pci: revision 1.18
sys/external/bsd/drm2/linux/linux_sync_file.c: revision 1.3
sys/external/bsd/drm2/amdgpu/files.amdgpu: revision 1.31
sys/external/bsd/drm2/dist/drm/nouveau/nvkm/engine/device/nouveau_nvkm_engine_device_tegra.c: revision 1.4
sys/external/bsd/drm2/dist/drm/drm_gem.c: revision 1.24
sys/arch/xen/xen/xpci_xenbus.c: revision 1.29

drm: Eliminate __HAVE_ATOMIC_AS_MEMBAR conditionals.
Discussed on tech-kern:
https://mail-index.netbsd.org/tech-kern/2023/02/23/msg028729.html

linux asm/barrier.h: Fix !MULTIPROCESSOR build.

remove "nouveau" from a comment. noted by jmcneill.

drm: KASSERT(A && B) -> KASSERT(A); KASSERT(B)
comment a function that has a clear overbounds read but it isn't used.
found by GCC 12.

nix the NetBSD specific GEM_BUG_ON().
avoids GCC 12 warnings, and matches upstream closer.
avoid uninitialised variable usage in drm_gem_cma_create_internal().
in the case nothing has returned 'error', 'nsegs' and the dma info
are (potentially) uninitialised, so consider this an error.
found by GCC 12.

avoid a GCC 12 warning.
there's a 1-element long array and a loop conditional that tries to see
if indexes for it are not identical. as these indexes will always both
be 0, the only valid index, the condition is always false. GCC 12
triggers a strange warning on this code that can never run (see below),
so simply assert the array size is 1 and comment the rest.
amdgpu_dc_stream.c:470:55: error: array subscript [0, 0] is outside array bounds of 'struct dc_writeback_info[1]' [-Werror=array-bounds]
470 | stream->writeback_info[j] = stream->writeback_info[i];

convert a KASSERT() into an if () panic() sequence to appease GCC 12.
OK riastradh@.

drm: Fix conditionals around drmkms_pci and agp.
Kernel should build now with all pci drm drivers stripped out but
DRM_LEGACY still enabled. (Might not be very useful, but it'll
build. Maybe we should also have DRM_LEGACY_PCI so those drivers can
be modloaded later.)

drmkms: Fix module build.
avoid an unlikely array bounds issue picked up by GCC 12.
nvkm_pcie_speed() can return -1, which is then used as an array index,
so make this default return PCIe 1.0 speeds.

drm: enable almost all PCIe functionality
linux_pci.c revisions 1.24 and 1.25 implemented most of the remaining
missing PCIe backends, but only enabled them for some amdgpu portions.
this enables all code marked with "XXX amdgpu pcie", "XXX radeon pcie",
and "XXX pcie speed". for most of it, simply removing #ifndefs __NetBSD__
to enable compliation was required, once the new "bus->max_bus_speed"
member was added to struct pci_bus. add an "always fails" backend for
pci_enable_atomic_ops_to_root() which seems to only be necessary
for virtual GPU functionality (and could be implemented if needed.)
tested on radeon 5450, 7750, R7 240 [radeon], and RX 550 [amdgpu], and
nvidia 750 and 1030 [nouveau].
this still does not quite work on nvidia cards. there are two problems
that remain:
- the call to set the link speed is skipped because the speed is set
to the default value of "-1". nvkm_pcie_set_link() will actually
determine the right value for this and for some cards, calling this
function if the current speed is -1 helps set the link speed. it
may be that on linux other paths we don't have enabled properly
would set this (there's one via debugfs, and a jetson specific one,
though perhaps setting either AC or DC speed values as boot options
(after hooking up these for netbsd) would currently work.
- worse, cards newer than kepler - geforce 900, 1000, and newer, are
all lacking the backing support to set pcie link speed. the GT 1030
card i have been testing with remains at pcie 1.0.

radeon: fix and enable ACPI methods for getting ROM BIOS
The hacky way of getting the BIOS mapped only works on x86. ACPI
should be preferred if available. Makes BIOS reading though VFCT
work on aarch64 with EDK2. (But only if EDK2 has POSTed the GPU.)
XXX amdgpu should get the same treatment.

drm: put_cpu() should enable preemption, not disable it again

drm(4): make pr_debug equivalent to aprint_debug
significantly reduces the default spam from amdgpu(4).

drm: Set CONFIG_ACPI in linux/acpi.h and make it build.

Leave a little ACPI-related functionality disabled for now, like
getting EDID out of ACPI -- needs a bit more work to make this work,
and I don't have hardware to work on that.
Should help with failures of the forms:
- unable to locate a BIOS ROM
- bios: unable to locate usable image
on various machines.

radeon_acpi.c: ifdef out unused function on NetBSD.
Should fix syzkaller build.

drm(4): Fix st_rdev in stat.
dminor->index already has the 64*type adjustment, as allocated in
drm_minor_alloc.
PR kern/58180

linux_sync_file: Fix missing init/fini steps.
Noted by rjs@.
PR kern/58210

ttm: Sync ttm_bo_uvm_fault_idle better with Linux.
PR xsrc/58133
ttm: Undo mistake in previous.

PR xsrc/58133
linux: Add a few more cases to pci_get_class.
Should fix crash on boot with amdgpu now that the ACPI business is
enabled.

i915: Fix dmabuf mmap object.

drm: Fix missing bounds checks in dma buf mmap.

drm_gem.c: Fix sense of assertion.
This is the opposite of WARN_ON.
Noted by rjs@.

drm_gem.c: Enable drm_gem_fence_array_add now that we emulate xa.
linux_xa: Delete and replace collision in xa_store as intended.
Don't free the colliding node that's still in the tree.
Noted by rjs@.

i915_gem_mman.c: Apply mmap types via pmap flags.
This way, userland gets buffers mapped write-combining or uncached as
needed.
PR xsrc/58307

x86: Teach bus_dmamem_map about BUS_DMA_PREFETCHABLE.
PR port-amd64/58308

bus_dma(9): Document BUS_DMA_PREFETCHABLE.
Like BUS_DMA_NOCACHE. Doesn't absolve you of the need for
bus_dmamap_sync, but if you later pass the vaddr to bus_dmamap_load,
the DMA map might notice the mapping is write-combining and use this
to make bus_dmamap_sync cheaper.
PR kern/58309

nouveau_nvkm_subdev_instmem_gk20a.c: Use BUS_DMA_PREFETCHABLE.
Matches Linux's pgprot_writecombine.
Unclear where the appropriate bus_dmamap_sync happens, or is supposed
to happen -- not using it would be wrong, but asking for a
prefetchable mapping may paper over symptoms, at least!

ttm: Sync more with Linux.
Add the original copyright and attribution since this is now,
intentionally, a modified copy of the original and not just roughly
the same algorithm.

ttm: Respect PGO_ALLPAGES.
Not sure this is useful but it reduces XXX's and makes this match
udv_fault better so it's easier to understand.

ttm: Sync cacheability flag logic with Linux.

ttm: Add XXX about readahead fault failures.

pci: Pass cookie through pci_find_device, pci_enumerate_bus, take 2.
New functions pci_find_device1 and pci_enumerate_bus1 have the cookie
argument. Existing symbols pci_find_device and pci_enumerate_bus are
now wrappers for the cookieless version.
This will allow pci_find_device callers to pass a cookie through to
the match function so they can keep state or pass in extra parameters
like b/d/f numbers, which will allow us to nix some horrible kludges
in the Linux PCI API emulation for drm (and, perhaps, Intel wifi).
This change drops the symbol pci_probe_device, in favour of a new
pci_probe_device1 with the cookie argument. But I don't think that
requires a revbump because it's only called by MD pci_enumerate_bus1
implementations, which don't live in modules anyway.
Take 2: Make sure to handle NULL match function.
linux_pci: Nix pci enumeration kludges.
Now that we can pass a cookie through, this stuff will be a little
less fragile.

i915: Omit needless i915_gem_object_pin/unpin_pages cycle in fault.
vm_fault_cpu and vm_fault_gtt, called by i915_gem_fault, already do
the pinning and unpinning internally, so there is no need for
i915_gem_fault to do it.
No functional change intended, except that the transient pin count
will be one lower than before during the fault routine (but it will
still be positive).

i915: Match Linux fault routine return code actions.
Omit needless EINTR interception -- this is now handled by
i915_error_to_vmf_fault.
Earlier revert was over a false alarm -- bisection shows the new
warnings arose from linux_pci.c 1.29 here:
https://mail-index.netbsd.org/source-changes/2024/06/23/msg151929.html

linux_pci: Fix shifto in pci_get_class.
It looks like Linux's pci_get_class also matches the interface part
of the PCI class register (but not the revision part), and I hadn't
noticed that in the previous shim structured differently.

With GCC12 kernel ALL/amd64 triggers "'sor' may be used uninitialized".
If "sublinks & 3" is zero GCC is right and sor[1] may be returned unitialized.
Fix by initializing "sor" to zero to return -1 instead of uninitialized value.
Ok: Taylor R Campbell <riastradh@>

amdgpu: Map BAR 2, not BAR 5, on pre-bonaire chips.
PR kern/58384

amdgpu: Map consecutive pages, not the same one over and over again.
PR kern/58385

linux/bitops: Fix overestimate for BITS_TO_LONGS(9)
Fortunately, this seems harmless except for allocating
excessive buffer memory.
Pointed out by nonaka@, OK riastradh@.
 1.3 08-Jun-2001  simonb For ports that wire up pciide in compatibility mode, have
them define __HAVE_PCIIDE_MACHDEP_COMPAT_INTR_ESTABLISH
in pci_machdep.h and pciide_map_compat_intr() only calls
pciide_machdep_compat_intr_establish() if that preprocessor
define exists.

Ports that don't need to do this no longer need to supply a
dummy function.
 1.2 21-Nov-1999  pk Also pull in <pci/pciidereg.h>.
 1.1 04-Jun-1999  mrg branches: 1.1.2; 1.1.4; 1.1.10;
clone this from the macppc port.
 1.1.10.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.1.4.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.1.2.1 21-Jun-1999  thorpej Sync w/ -current.
 1.4 04-Jan-2021  thorpej malloc(9) -> kmem(9) -- just the simple, straightforward conversions for now.
 1.3 13-Oct-2018  macallan branches: 1.3.12;
config and attachment goop for tadpmu
 1.2 14-Aug-2015  nakayama branches: 1.2.16; 1.2.18;
pckbc@ebus: match "kb_ps2" device to make keyboard and mouse work
on qemu-sparc64.

XXX OpenBIOS doesn't provide interrupts for pckbc currently, so use
the interrupt numbers described in QEMU's hw/sparc64/sun4u.c::isa_irq_handler.
 1.1 09-Oct-2012  jdc branches: 1.1.2; 1.1.4; 1.1.16; 1.1.18;
Driver for pckbc at ebus, as found on Tadpole SPARCle.
Largely based on sparc's pckbc_js.c.
 1.1.18.1 22-Sep-2015  skrll Sync with HEAD
 1.1.16.1 04-Sep-2015  martin Pull up following revision(s) (requested by nakayama in ticket #951):
sys/arch/sparc64/dev/pckbc_ebus.c: revision 1.2
sys/arch/sparc64/sparc64/autoconf.c: revision 1.204
Detect a boot device more precisely on QEMU by checking the device
name.
pckbc@ebus: match "kb_ps2" device to make keyboard and mouse work
on qemu-sparc64.
XXX OpenBIOS doesn't provide interrupts for pckbc currently, so use
the interrupt numbers described in QEMU's hw/sparc64/sun4u.c::isa_irq_handler.
 1.1.4.3 03-Dec-2017  jdolecek update from HEAD
 1.1.4.2 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.1.4.1 09-Oct-2012  tls file pckbc_ebus.c was added on branch tls-maxphys on 2012-11-20 03:01:45 +0000
 1.1.2.2 30-Oct-2012  yamt sync with head
 1.1.2.1 09-Oct-2012  yamt file pckbc_ebus.c was added on branch yamt-pagecache on 2012-10-30 17:20:24 +0000
 1.2.18.1 10-Jun-2019  christos Sync with HEAD
 1.2.16.1 20-Oct-2018  pgoyette Sync with head
 1.3.12.1 03-Apr-2021  thorpej Sync with HEAD.
 1.34 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.33 16-Mar-2014  dholland branches: 1.33.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.32 15-Sep-2013  martin Remove an unused variable
 1.31 03-Jun-2011  christos branches: 1.31.2; 1.31.12; 1.31.16;
CFATTACH_DECL_NEW
 1.30 24-Apr-2011  rmind branches: 1.30.2;
Rename ttymalloc() to tty_alloc(), and ttyfree() to tty_free() for
consistency. Remove some unnecessary malloc.h inclusions as well.
 1.29 13-Jun-2008  cegger branches: 1.29.18; 1.29.24;
use device_lookup_private to get softc
 1.28 19-Nov-2007  ad branches: 1.28.14; 1.28.16; 1.28.18; 1.28.20; 1.28.22;
- Factor out too many copies of the same bit of tty code.
- Fix another tty signalling/wakeup problem.
 1.27 18-Oct-2007  joerg branches: 1.27.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.26 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.25 09-Jul-2007  ad branches: 1.25.8; 1.25.10; 1.25.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.24 04-Mar-2007  christos branches: 1.24.2; 1.24.4; 1.24.10;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.23 01-Oct-2006  elad branches: 1.23.4;
Adapt MD code to KAUTH_DEVICE_TTY_OPEN. Patch from Matt Fleming, thanks!
 1.22 23-Jul-2006  ad branches: 1.22.4; 1.22.6;
Use the LWP cached credentials where sane.
 1.21 14-May-2006  elad integrate kauth.
 1.20 13-Feb-2006  cdi branches: 1.20.2; 1.20.4; 1.20.6;
ANSIfy: u_intN_t -> uintN_t, remove __P(), fix function definitions.
 1.19 11-Dec-2005  christos branches: 1.19.2; 1.19.4; 1.19.6;
merge ktrace-lwp.
 1.18 21-Mar-2004  pk branches: 1.18.16;
Use the promlib I/O routines.
 1.17 15-Jul-2003  lukem __KERNEL_RCSID()
 1.16 29-Jun-2003  fvdl branches: 1.16.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.15 29-Jun-2003  martin Passing struct lwp * instead of struct proc * to device functions.
 1.14 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.13 02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.12 01-Oct-2002  thorpej Use CFATTACH_DECL().
 1.11 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.10 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.9 17-Mar-2002  atatat branches: 1.9.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.8 05-Oct-2001  eeh branches: 1.8.4;
Remove bsd_openprom.h, which is only for compatibility with the sparc port.
 1.7 02-May-2001  scw branches: 1.7.2; 1.7.4;
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 10-Nov-2000  eeh branches: 1.6.2; 1.6.4;
Remove unnecessary header file that causes linker issues.
 1.5 08-Nov-2000  eeh Use new MI console magic framework.
 1.4 02-Nov-2000  eeh Adapt to the new line discipline scheme.
 1.3 10-Jul-2000  eeh Break into debugger by typing `+++++',
 1.2 24-Jun-2000  eeh Remove a couple of references to vaddrs.h that slipped through.
 1.1 20-May-2000  eeh branches: 1.1.4;
Oops. Seems like we do need this file to make pcons work.
 1.1.4.1 18-Jul-2000  mrg pullup the contents of -current arch/sparc64. this gives us significant
ultrasparc PCI support (ultra5, ultra10, AXi, and E250 tested so far),
plus many other small fixes. netbooting is now supported.
 1.6.4.1 21-Jun-2001  nathanw Catch up to -current.
 1.6.2.3 22-Nov-2000  bouyer Sync with HEAD.
 1.6.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.6.2.1 10-Nov-2000  bouyer file pcons.c was added on branch thorpej_scsipi on 2000-11-20 20:26:44 +0000
 1.7.4.3 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.2 11-Oct-2001  fvdl Catch up with -current. Fix some bogons in the sparc64 kbd/ms
attach code. cd18xx conversion provided by mrg.
 1.7.4.1 10-Oct-2001  fvdl Convert all remaining devices.
 1.7.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.7.2.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.7.2.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.8.4.5 11-Nov-2002  nathanw Catch up to -current
 1.8.4.4 18-Oct-2002  nathanw Catch up to -current.
 1.8.4.3 17-Sep-2002  nathanw Catch up to -current.
 1.8.4.2 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.8.4.1 05-Oct-2001  nathanw file pcons.c was added on branch nathanw_sa on 2002-04-01 07:43:04 +0000
 1.9.4.1 17-May-2002  gehenna Add device switch.
 1.16.2.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.16.2.3 18-Sep-2004  skrll Sync with HEAD.
 1.16.2.2 26-Aug-2004  skrll Adapt to branch.

sparc64 GENERIC compiles.
 1.16.2.1 03-Aug-2004  skrll Sync with HEAD
 1.18.16.5 07-Dec-2007  yamt sync with head
 1.18.16.4 27-Oct-2007  yamt sync with head.
 1.18.16.3 03-Sep-2007  yamt sync with head.
 1.18.16.2 30-Dec-2006  yamt sync with head.
 1.18.16.1 21-Jun-2006  yamt sync with head.
 1.19.6.2 01-Jun-2006  kardel 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.19.2.1 18-Feb-2006  yamt sync with head.
 1.20.6.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.20.4.3 12-May-2006  elad adapt to kauth kpi, include sys/kauth.h where needed..
 1.20.4.2 10-Mar-2006  elad generic_authorize() -> kauth_authorize_generic().
 1.20.4.1 08-Mar-2006  elad Adapt to kernel authorization KPI.

I expect *some* lossage here...
 1.20.2.2 11-Aug-2006  yamt sync with head
 1.20.2.1 24-May-2006  yamt sync with head.
 1.22.6.1 22-Oct-2006  yamt sync with head
 1.22.4.1 18-Nov-2006  ad Sync with head.
 1.23.4.1 12-Mar-2007  rmind Sync with HEAD.
 1.24.10.1 03-Oct-2007  garbled Sync with HEAD
 1.24.4.1 11-Jul-2007  mjf Sync with head.
 1.24.2.3 03-Dec-2007  ad Sync with HEAD.
 1.24.2.2 23-Oct-2007  ad Sync with head.
 1.24.2.1 15-Jul-2007  ad Sync with head.
 1.25.14.2 21-Nov-2007  bouyer Sync with HEAD
 1.25.14.1 25-Oct-2007  bouyer Sync with HEAD.
 1.25.10.2 09-Jan-2008  matt sync with HEAD
 1.25.10.1 06-Nov-2007  matt sync with HEAD
 1.25.8.2 21-Nov-2007  joerg Sync with HEAD.
 1.25.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.27.2.1 08-Dec-2007  mjf Sync with HEAD.
 1.28.22.1 18-Jun-2008  simonb Sync with head.
 1.28.20.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.28.18.1 04-May-2009  yamt sync with head.
 1.28.16.1 17-Jun-2008  yamt sync with head.
 1.28.14.1 29-Jun-2008  mjf Sync with HEAD.
 1.29.24.1 06-Jun-2011  jruoho Sync with HEAD.
 1.29.18.2 12-Jun-2011  rmind sync with head
 1.29.18.1 31-May-2011  rmind sync with head
 1.30.2.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.31.16.1 18-May-2014  rmind sync with head
 1.31.12.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.31.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.2.1 10-Aug-2014  tls Rebase.
 1.2 23-Aug-2000  pk This file is now in sys/dev/sun.
 1.1 20-Jun-1998  eeh branches: 1.1.1;
Initial revision
 1.1.1.1 20-Jun-1998  eeh branches: 1.1.1.1.14;
Import of sparc64.
 1.1.1.1.14.1 20-Nov-2000  bouyer Remove files that are no longer on the trunck
 1.11 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.10 18-Mar-2012  mrg branches: 1.10.2;
add missing __KERNEL_RCSID().
 1.9 03-Jun-2011  christos branches: 1.9.2; 1.9.6;
forgot _NEW again.
 1.8 03-Jun-2011  christos CFATTACH_DECL_NEW
 1.7 18-Mar-2009  cegger branches: 1.7.4; 1.7.6; 1.7.10;
Ansify function definitions w/o arguments. Generated with sed.
 1.6 28-Apr-2008  martin branches: 1.6.8; 1.6.14;
Remove clause 3 and 4 from TNF licenses
 1.5 05-Apr-2008  cegger branches: 1.5.2; 1.5.4;
use aprint_*_dev and device_xname
OK martin
 1.4 11-Dec-2005  christos branches: 1.4.74;
merge ktrace-lwp.
 1.3 30-Jul-2003  petrov branches: 1.3.4;
It's 2003 now, print newline in attach.
 1.2 24-Jul-2003  petrov ansify.
 1.1 17-Jul-2003  petrov Driver for CP1500/1400 watchdog timer.
 1.3.4.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.3.4.3 18-Sep-2004  skrll Sync with HEAD.
 1.3.4.2 03-Aug-2004  skrll Sync with HEAD
 1.3.4.1 30-Jul-2003  skrll file pld_wdog.c was added on branch ktrace-lwp on 2004-08-03 10:41:24 +0000
 1.4.74.1 02-Jun-2008  mjf Sync with HEAD.
 1.5.4.2 04-May-2009  yamt sync with head.
 1.5.4.1 16-May-2008  yamt sync with head.
 1.5.2.1 18-May-2008  yamt sync with head.
 1.6.14.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.6.8.1 28-Apr-2009  skrll Sync with HEAD.
 1.7.10.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.7.6.1 06-Jun-2011  jruoho Sync with HEAD.
 1.7.4.1 12-Jun-2011  rmind sync with head
 1.9.6.1 05-Apr-2012  mrg sync to latest -current.
 1.9.2.2 30-Oct-2012  yamt sync with head
 1.9.2.1 17-Apr-2012  yamt sync with head
 1.10.2.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.13 06-Jul-2017  martin Remove unused "power @ ebus" device, we use the firmware to handle power/
reboot.
 1.12 03-Jun-2011  christos branches: 1.12.12; 1.12.30;
CFATTACH_DECL_NEW
 1.11 18-Mar-2009  cegger branches: 1.11.4; 1.11.6; 1.11.10;
Ansify function definitions w/o arguments. Generated with sed.
 1.10 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.9 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.8 12-May-2006  uwe branches: 1.8.66; 1.8.74; 1.8.80;
De-__P.
 1.7 11-Dec-2005  christos branches: 1.7.4; 1.7.6; 1.7.8; 1.7.12;
merge ktrace-lwp.
 1.6 15-Jul-2003  lukem branches: 1.6.16;
__KERNEL_RCSID()
 1.5 05-Feb-2003  perry branches: 1.5.2;
"Utilize" has exactly the same meaning as "use," but it is more
difficult to read and understand. Most manuals of English style
therefore say that you should use "use".
 1.4 02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.3 01-Oct-2002  thorpej Use CFATTACH_DECL().
 1.2 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.1 20-Jun-1998  eeh branches: 1.1.1;
Initial revision
 1.1.1.1 20-Jun-1998  eeh branches: 1.1.1.1.28; 1.1.1.1.32;
Import of sparc64.
 1.1.1.1.32.1 18-Oct-2002  nathanw Catch up to -current.
 1.1.1.1.28.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.5.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.5.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.5.2.1 03-Aug-2004  skrll Sync with HEAD
 1.6.16.1 21-Jun-2006  yamt sync with head.
 1.7.12.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.7.8.1 24-May-2006  yamt sync with head.
 1.7.6.1 01-Jun-2006  kardel Sync with head.
 1.7.4.1 09-Sep-2006  rpaulo sync with head
 1.8.80.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.8.74.1 28-Apr-2009  skrll Sync with HEAD.
 1.8.66.1 04-May-2009  yamt sync with head.
 1.11.10.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.11.6.1 06-Jun-2011  jruoho Sync with HEAD.
 1.11.4.1 12-Jun-2011  rmind sync with head
 1.12.30.1 28-Aug-2017  skrll Sync with HEAD
 1.12.12.1 03-Dec-2017  jdolecek update from HEAD
 1.3 06-Jul-2017  martin Remove unused "power @ ebus" device, we use the firmware to handle power/
reboot.
 1.2 12-May-2006  uwe branches: 1.2.110; 1.2.130;
De-__P.
 1.1 20-Jun-1998  eeh branches: 1.1.1;
Initial revision
 1.1.1.1 20-Jun-1998  eeh branches: 1.1.1.1.64; 1.1.1.1.78; 1.1.1.1.80; 1.1.1.1.82; 1.1.1.1.86;
Import of sparc64.
 1.1.1.1.86.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.1.1.1.82.1 24-May-2006  yamt sync with head.
 1.1.1.1.80.1 01-Jun-2006  kardel Sync with head.
 1.1.1.1.78.1 09-Sep-2006  rpaulo sync with head
 1.1.1.1.64.1 21-Jun-2006  yamt sync with head.
 1.2.130.1 28-Aug-2017  skrll Sync with HEAD
 1.2.110.1 03-Dec-2017  jdolecek update from HEAD
 1.11 07-Jul-2016  msaitoh KNF. Remove extra spaces. No functional change.
 1.10 27-Oct-2012  chs branches: 1.10.14;
split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.9 01-Jul-2011  dyoung branches: 1.9.2; 1.9.12;
#include <sys/bus.h> instead of <machine/bus.h>.
 1.8 03-Jun-2011  christos CFATTACH_DECL_NEW
 1.7 05-Apr-2008  cegger branches: 1.7.26; 1.7.32; 1.7.36;
use aprint_*_dev and device_xname
OK martin
 1.6 17-Oct-2007  garbled branches: 1.6.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.5 09-Jul-2007  ad branches: 1.5.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.4 01-Jul-2007  xtraeme Use PSWITCH_EVENT_{PRESSED,RELEASED} for consistency with other drivers
using the sysmon_power framework.
 1.3 23-Aug-2006  jnemeth branches: 1.3.4; 1.3.10; 1.3.16; 1.3.18; 1.3.24;
make this compile when DEBUG is set
 1.2 12-Jul-2006  gdamore branches: 1.2.4;
Initialize batt for gcc 4.x, and while here add $NetBSD$ comment.
 1.1 10-Jul-2006  gdamore New psm driver for use on Ultrabook IIi. Right now it supports the power
button and lid switch. I will add environmentals (battery, etc.) later.
 1.2.4.3 03-Sep-2006  yamt sync with head.
 1.2.4.2 11-Aug-2006  yamt sync with head
 1.2.4.1 12-Jul-2006  yamt file psm.c was added on branch yamt-pdpolicy on 2006-08-11 15:43:00 +0000
 1.3.24.1 03-Oct-2007  garbled Sync with HEAD
 1.3.18.1 11-Jul-2007  mjf Sync with head.
 1.3.16.1 15-Jul-2007  ad Sync with head.
 1.3.10.3 03-Sep-2007  yamt sync with head.
 1.3.10.2 30-Dec-2006  yamt sync with head.
 1.3.10.1 23-Aug-2006  yamt file psm.c was added on branch yamt-lazymbuf on 2006-12-30 20:47:02 +0000
 1.3.4.2 09-Sep-2006  rpaulo sync with head
 1.3.4.1 23-Aug-2006  rpaulo file psm.c was added on branch rpaulo-netinet-merge-pcb on 2006-09-09 02:43:36 +0000
 1.5.10.1 06-Nov-2007  matt sync with HEAD
 1.6.16.1 02-Jun-2008  mjf Sync with HEAD.
 1.7.36.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.7.32.1 06-Jun-2011  jruoho Sync with HEAD.
 1.7.26.1 12-Jun-2011  rmind sync with head
 1.9.12.2 03-Dec-2017  jdolecek update from HEAD
 1.9.12.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.9.2.1 30-Oct-2012  yamt sync with head
 1.10.14.1 09-Jul-2016  skrll Sync with HEAD
 1.4 28-May-2022  andvar fix various typos in comments.
 1.3 10-Dec-2021  andvar s/occured/occurred/ in comments, log messages and man pages.
 1.2 30-Jun-2011  wiz dependant -> dependent
 1.1 10-Jul-2006  gdamore branches: 1.1.4; 1.1.8; 1.1.14;
New psm driver for use on Ultrabook IIi. Right now it supports the power
button and lid switch. I will add environmentals (battery, etc.) later.
 1.1.14.2 30-Dec-2006  yamt sync with head.
 1.1.14.1 10-Jul-2006  yamt file psmreg.h was added on branch yamt-lazymbuf on 2006-12-30 20:47:02 +0000
 1.1.8.2 09-Sep-2006  rpaulo sync with head
 1.1.8.1 10-Jul-2006  rpaulo file psmreg.h was added on branch rpaulo-netinet-merge-pcb on 2006-09-09 02:43:36 +0000
 1.1.4.2 11-Aug-2006  yamt sync with head
 1.1.4.1 10-Jul-2006  yamt file psmreg.h was added on branch yamt-pdpolicy on 2006-08-11 15:43:00 +0000
 1.138 08-Sep-2024  rillig fix a/an grammar in obvious cases
 1.137 23-Feb-2022  andvar branches: 1.137.10;
fix various typos in comments, mainly immediatly/immediately/,
as well shared and recently fixed typos in OpenBSD code by Jonathan Grey.
 1.136 21-Jan-2022  thorpej Don't bother with prom_node_to_devhandle() if we're just forwarding along
our own node; use device_handle(self) instead.
 1.135 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.134 10-May-2021  thorpej branches: 1.134.4;
Associate the OpenBoot / OpenFirmware node with attached devices
at config_found() time.
 1.133 24-Apr-2021  thorpej branches: 1.133.2; 1.133.4;
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.132 17-Jan-2021  mrg branches: 1.132.2;
reduce the scope of 'ci' variable.
 1.131 07-Jan-2021  nakayama The "available" property requires a variable length buffer, so
leave free(9) until prom_getprop is changed to use kmem_alloc(9)
instead of malloc(9).
 1.130 06-Jan-2021  palle psycho: explicit allocation of memory using kmem(9) instead of using the buffer indirectly allocted in the prom_getprop() function (which is still using malloc(9) for memory allocation
 1.129 04-Jan-2021  thorpej malloc(9) -> kmem(9) -- just the simple, straightforward conversions for now.
 1.128 10-Nov-2019  chs branches: 1.128.8;
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.127 05-Feb-2019  mrg add or avoid fallthru comments.
 1.126 26-Mar-2017  martin branches: 1.126.14;
Do not call OF_getprop on our node blindly - for the "pcons" hack we may
be called with all zeroed attach args.
 1.125 24-Mar-2017  macallan disable BUS_SPACE_MAP_PREFETCHABLE until I figure out which psychos support
partial writes
apparently the only devices which can actually do that are UPA graphics cards
 1.124 10-May-2016  palle branches: 1.124.2; 1.124.4;
sun4v: make device interrupts work. Introduce a new intrhand_alloc() function for allocation of interrupt handlers and adapt to this. Parts from OpenBSD. ok martin@
 1.123 27-Nov-2015  mrg s/pa/busaddr/ in a debug message, we print the actual paddr next.
 1.122 26-Nov-2015  mrg adjust a bunch of debugging messages to use __func__ and to normalise
newline usage (some sequences ended up printing blank lines.)
 1.121 02-Oct-2015  msaitoh PCI Extended Configuration stuff written by nonaka@:
- Add PCI Extended Configuration Space support into x86.
- Check register offset of pci_conf_read() in MD part. It returns (pcireg_t)-1
if it isn't accessible.
- Decode Extended Capability in PCI Extended Configuration Space.
Currently the following extended capabilities are decoded:
- Advanced Error Reporting
- Virtual Channel
- Device Serial Number
- Power Budgeting
- Root Complex Link Declaration
- Root Complex Event Collector Association
- Access Control Services
- Alternative Routing-ID Interpretation
- Address Translation Services
- Single Root IO Virtualization
- Page Request
- TPH Requester
- Latency Tolerance Reporting
- Secondary PCI Express
- Process Address Space ID
- LN Requester
- L1 PM Substates
The following extended capabilities are not decoded yet:
- Root Complex Internal Link Control
- Multi-Function Virtual Channel
- RCRB Header
- Vendor Unique
- Configuration Access Correction
- Multiple Root IO Virtualization
- Multicast
- Resizable BAR
- Dynamic Power Allocation
- Protocol Multiplexing
- Downstream Port Containment
- Precision Time Management
- M-PCIe
- Function Reading Status Queueing
- Readiness Time Reporting
- Designated Vendor-Specific
 1.120 18-Oct-2014  snj branches: 1.120.2;
src is too big these days to tolerate superfluous apostrophes. It's
"its", people!
 1.119 21-Sep-2014  christos fix leak
 1.118 07-Dec-2013  nakayama branches: 1.118.4;
Timecounter's tc_get_timecount requires only 32-bit (u_int), so
omit unnecessary upper 32-bit read from STICK counter.
 1.117 08-Nov-2013  nakayama "machine_model" is now declared in machine/autoconf.h.
 1.116 24-Sep-2013  jdc Work around invalid root PCI bus bus-range (0x00-0xff) by checking the
bus-range of any child buses, and altering the root bus bus-range to
suit. Required for cardbus bridge attach on SPARCle.
 1.115 22-Aug-2013  nakayama Handle US-IIe's STICK counter as 64-bit explicitly to fix a hang at
boot after about 6.5 minutes on 32-bit kernel.
 1.114 20-Aug-2013  macallan support UltraSPARC-IIe STICK counter as time base
 1.113 21-Jun-2013  nakayama branches: 1.113.2;
Avoid data_access_error trap panic when reading unused PCI
configuration space.

This method is described in UltraSPARC IIi User's Manual "16.2.1
Probing PCI during boot using deferred errors", and refer to the
implementation of OpenBSD.
 1.112 27-Jan-2012  para branches: 1.112.6;
converting extent(9) from malloc(9) to kmem(9)
preceding kmem-vmem-pool-uvm patch

releng@ acknowledged
 1.111 04-Sep-2011  nakayama branches: 1.111.2; 1.111.6;
ih_pil is an interrupt level, not an interrupt mask.
 1.110 12-Aug-2011  mrg initialise ih_pending.
 1.109 20-Jul-2011  macallan add per ivec event counters
 1.108 01-Jul-2011  dyoung #include <sys/bus.h> instead of <machine/bus.h>.
 1.107 02-Jun-2011  christos split auxio, ebus, psycho, sab.
 1.106 17-May-2011  dyoung branches: 1.106.2;
PCI_FLAGS_IO_ENABLED and PCI_FLAGS_MEM_ENABLED changed their functional
role in NetBSD (drivers are no longer supposed to write these to
pa_flags) without changing name. Correct that.

Rename PCI_FLAGS_IO_ENABLED to PCI_FLAGS_IO_OKAY and
PCI_FLAGS_MEM_ENABLED to PCI_FLAGS_MEM_OKAY, thus making their names
consistent with the other PCI flags and poisoning 3rd-party driver
sources that use the flags in the old bad way.

This patch produces no binary changes in this set of PCI kernels when
they are compiled w/o 'options DIAGNOSTIC' and w/ -V MKREPRO=yes:

algor P4032 P5064 P6032
alpha GENERIC
amd64 GENERIC XEN3_DOM0
arc GENERIC
atari HADES MILAN-PCIIDE
bebox GENERIC
cats GENERIC
cobalt GENERIC
evbarm-el ADI_BRH ARMADILLO9 CP3100 GEMINI GEMINI_MASTER GEMINI_SLAVE
evbarm-el GUMSTIX HDL_G IMX31LITE INTEGRATOR IQ31244 IQ80310 IQ80321
evbarm-el IXDP425 IXM1200 KUROBOX_PRO
evbarm-el LUBBOCK MARVELL_NAS NAPPI NSLU2 SHEEVAPLUG SMDK2800 TEAMASA_NPWR
evbarm-el TEAMASA_NPWR_FC TS7200 TWINTAIL ZAO425
evbmips-el AP30 DBAU1500 DBAU1550 MALTA MERAKI MTX-1 OMSAL400 RB153 WGT624V3
evbmips64-el XLSATX
evbppc EV64260 MPC8536DS MPC8548CDS OPENBLOCKS200 OPENBLOCKS266
evbppc OPENBLOCKS266_OPT P2020RDB PMPPC RB800 WALNUT
hp700 GENERIC
i386 ALL XEN3_DOM0 XEN3_DOMU
ibmnws GENERIC
iyonix GENERIC
landisk GENERIC
macppc GENERIC
mvmeppc GENERIC
netwinder GENERIC
ofppc GENERIC
prep GENERIC
sandpoint GENERIC
sbmips-el GENERIC
sgimips GENERIC32_IP2x GENERIC32_IP3x
sparc GENERIC_SUN4U KRUPS
sparc64 GENERIC
 1.105 04-Apr-2011  dyoung Neither pci_dma64_available(), pci_probe_device(), pci_mapreg_map(9),
pci_find_rom(), pci_intr_map(9), pci_enumerate_bus(), nor the match
predicate passed to pciide_compat_intr_establish() should ever modify
their pci_attach_args argument, so make their pci_attach_args arguments
const and deal with the fallout throughout the kernel.

For the most part, these changes add a 'const' where there was no
'const' before, however, some drivers and MD code used to modify
pci_attach_args. Now those drivers either copy their pci_attach_args
and modify the copy, or refrain from modifying pci_attach_args:

Xen: according to Manuel Bouyer, writing to pci_attach_args in
pci_intr_map() was a leftover from Xen 2. Probably a bug. I
stopped writing it. I have not tested this change.

siside(4): sis_hostbr_match() needlessly wrote to pci_attach_args.
Probably a bug. I use a temporary variable. I have not tested this
change.

slide(4): sl82c105_chip_map() overwrote the caller's pci_attach_args.
Probably a bug. Use a local pci_attach_args. I have not tested
this change.

viaide(4): via_sata_chip_map() and via_sata_chip_map_new() overwrote the
caller's pci_attach_args. Probably a bug. Make a local copy of the
caller's pci_attach_args and modify the copy. I have not tested
this change.

While I'm here, make pci_mapreg_submap() static.

With these changes in place, I have tested the compilation of these
kernels:

alpha GENERIC
amd64 GENERIC XEN3_DOM0
arc GENERIC
atari HADES MILAN-PCIIDE
bebox GENERIC
cats GENERIC
cobalt GENERIC
evbarm-eb NSLU2
evbarm-el ADI_BRH ARMADILLO9 CP3100 GEMINI GEMINI_MASTER GEMINI_SLAVE GUMSTIX
HDL_G IMX31LITE INTEGRATOR IQ31244 IQ80310 IQ80321 IXDP425 IXM1200
KUROBOX_PRO LUBBOCK MARVELL_NAS NAPPI SHEEVAPLUG SMDK2800 TEAMASA_NPWR
TEAMASA_NPWR_FC TS7200 TWINTAIL ZAO425
evbmips-el AP30 DBAU1500 DBAU1550 MALTA MERAKI MTX-1 OMSAL400 RB153 WGT624V3
evbmips64-el XLSATX
evbppc EV64260 MPC8536DS MPC8548CDS OPENBLOCKS200 OPENBLOCKS266
OPENBLOCKS266_OPT P2020RDB PMPPC RB800 WALNUT
hp700 GENERIC
i386 ALL XEN3_DOM0 XEN3_DOMU
ibmnws GENERIC
macppc GENERIC
mvmeppc GENERIC
netwinder GENERIC
ofppc GENERIC
prep GENERIC
sandpoint GENERIC
sgimips GENERIC32_IP2x
sparc GENERIC_SUN4U KRUPS
sparc64 GENERIC

As of Sun Apr 3 15:26:26 CDT 2011, I could not compile these kernels
with or without my patches in place:

### evbmips-el GDIUM

nbmake: nbmake: don't know how to make /home/dyoung/pristine-nbsd/src/sys/arch/mips/mips/softintr.c. Stop

### evbarm-el MPCSA_GENERIC
src/sys/arch/evbarm/conf/MPCSA_GENERIC:318: ds1672rtc*: unknown device `ds1672rtc'

### ia64 GENERIC

/tmp/genassym.28085/assym.c: In function 'f111':
/tmp/genassym.28085/assym.c:67: error: invalid application of 'sizeof' to incomplete type 'struct pcb'
/tmp/genassym.28085/assym.c:76: error: dereferencing pointer to incomplete type

### sgimips GENERIC32_IP3x

crmfb.o: In function `crmfb_attach':
crmfb.c:(.text+0x2304): undefined reference to `ddc_read_edid'
crmfb.c:(.text+0x2304): relocation truncated to fit: R_MIPS_26 against `ddc_read_edid'
crmfb.c:(.text+0x234c): undefined reference to `edid_parse'
crmfb.c:(.text+0x234c): relocation truncated to fit: R_MIPS_26 against `edid_parse'
crmfb.c:(.text+0x2354): undefined reference to `edid_print'
crmfb.c:(.text+0x2354): relocation truncated to fit: R_MIPS_26 against `edid_print'
 1.104 16-Mar-2011  mrg revert the iommu changes for now. my U60 doesn't like them.
 1.103 16-Mar-2011  mrg use struct iommureg_old.
 1.102 13-Feb-2011  nakayama Don't enable the powerfail interrupt on Netra X1 since it may hang.

Discussed on port-sparc64.
 1.101 10-Jul-2010  nakayama branches: 1.101.2; 1.101.4;
psycho_sabre_dmamap_sync: do nothing if len == 0 like iommu_dvmamap_sync.
 1.100 06-Jan-2010  mrg branches: 1.100.2; 1.100.4;
move the guts of pci_intr_map() into pci_machdep.c, and move the schizo
ign addition into a hook. also, don't double shift the ign in set_intr.

tested on U60 and SB2500.
 1.99 30-Dec-2009  nakayama Fix function name in debug messages, remove trailing space and tabify.
 1.98 06-Dec-2009  nakayama psycho_ue():
- remove printing of pa, it is irrelevant value since va address
passed to iommu_extract is incorrect and we can look at it in
IOTTE.
- print correct IOVA address.

While there, convert printf to aprint_error_dev and remove long
long casts by using PRIx64.
 1.97 30-Nov-2009  mrg convert pci_intr_map() into a chipset tag function pointer, and implement
the schizo version slightly differently.

pull out the schizo's IGN from the upaid, not the apparently broken device
ID register. from openbsd.

with this i appear to have valid working interrupts on the SB2500.

tested on U60 and SB2500.


XXX: we can probably kill (*spc_find_ino)() now that pci_intr_map() itself
XXX: is no longer a first class function.
 1.96 27-Nov-2009  mrg clean up some debug messages a little bit.
 1.95 16-Dec-2008  christos replace bitmask_snprintf(9) with snprintb(3)
 1.94 10-Dec-2008  mrg ofpci_make_tag():
don't write PCI_COMMAND_STATUS_REG with
PCI_COMMAND_(MEM|MASTER|IO)_ENABLE, or it in.
sparc_pci_childspace():
move psycho.c:get_childspace() into pci_machdep.c but rename it
psycho_alloc_bus_tag():
use M_ZERO
 1.93 09-Dec-2008  nakayama Fix CardBus, PCI-PCI bridge support borked in previous commit.
 1.92 07-Dec-2008  mrg a few clean up/rearrange changes, somewhat inspired from openbsd's
schizo.c:

- rename pp_busnode{} -> spc_busnode{}, and move it to
sparc_pci_chipset{}

- move public pci functions pci_conf_read(), pci_conf_write() and
pci_intr_establish() into psycho.c, renaming them in the process,
and add pointers through sparc_pci_chipset{} to access them.
as part of this, add PDB_INTMAP and PDB_CONF debug options to
psycho.c

- move and rename sparc64 private pci_find_ino() into
sparc_pci_chipset{}, like the above

- update psycho_alloc_chipset() to set the new 4 function members


no functional change intended. XXX: not tested on cardbus.
 1.91 18-Oct-2008  nakayama branches: 1.91.2; 1.91.4;
It is wasteful that reconstructing arguments for inserting the pointer
to streaming buffers in each bus_dma functions on sbus/psycho layer.

Use iommu functions directly with storing the pointer into (unused)
_dm_cookie at bus_dmamap_create time.
 1.90 18-Oct-2008  nakayama UltraSPARC IIi and IIe have PCI DMA Write Synchronization Register to
synchronize the DMA writes. So use it in case of BUS_DMASYNC_POSTREAD.

Tested on my Netra X1 for several years.
 1.89 13-Oct-2008  nakayama Remove unnecessary includes.
 1.88 13-Jun-2008  cegger branches: 1.88.2;
use device_lookup_private to get softc
 1.87 30-May-2008  mrg branches: 1.87.2;
convert the rest of my licenses to 2-clause, extracting myself out
from a group as necessary.

bozohttpd remains, but it will get fixed next time i update it.
 1.86 18-May-2008  martin Explicitly pass a "mpsafe" arg down to intr_establish, as at that point
we do not have the original ipl passed in around to check for mpsafeness.
Fixes PR port-sparc64/38673. Thanks to Andrew for pointing at the problem.
 1.85 05-Apr-2008  cegger branches: 1.85.2; 1.85.4; 1.85.6;
use aprint_*_dev and device_xname
OK martin
 1.84 16-Feb-2008  jmcneill branches: 1.84.6;
Use aprint_* instead of printf during attach.
 1.83 30-Dec-2007  jdc Make extent mapping error more meaningful. OK martin@.
 1.82 03-Dec-2007  rafal branches: 1.82.6;
Clear interrupts as they are established, rearrange interrupt-mapping code
to make sure PCI slot 0 interrupt doesn't accidentally match the (unused)
PCI error interrupt.

Fixes kern/25462 at least on my Netra T1 ac200.
From OpenBSD; ok martin@
 1.81 19-Nov-2007  macallan put the physical address of each psycho's memory range into a device
property so we can look it up in device_register() later on
ok'ed by martin
 1.80 04-Mar-2007  christos branches: 1.80.2; 1.80.18; 1.80.20; 1.80.24; 1.80.26;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.79 08-Mar-2006  lukem branches: 1.79.16;
Use the SI capitalization for "Hz", "kHz", and "MHz" in comments and strings.
Add a space between numbers and Hz unit.
 1.78 25-Feb-2006  wiz branches: 1.78.2; 1.78.4;
Fix some typos.
 1.77 13-Feb-2006  cdi ANSIfy: u_intN_t -> uintN_t, remove __P(), fix function definitions.
 1.76 01-Feb-2006  martin branches: 1.76.2;
Do not assume the bootstrap CPU has UPA id 0 - on some machines it hasn't.
Explicitly route all interrupts to the current cpu for now, we'll revisit
this when SMP is working.
Problem spotted and analyzed by Stephan Meisinger, fix inspired by FreeBSD.
 1.75 11-Dec-2005  christos branches: 1.75.2; 1.75.4;
merge ktrace-lwp.
 1.74 31-May-2005  christos branches: 1.74.2;
- sprinkle const
- avoid variable shadow
 1.73 30-Aug-2004  drochner Phase out the use of a string as first "attach args" member to control
which bustype should be attached with a specific call to config_found()
(from a "mainbus" or a bus bridge).
Do it for isa/eisa/mca and pci/agp for now. These buses all attach to
an mi interface attribute "isabus", "eisabus" etc., and the autoconf
framework now allows to specify an interface attribute on config_found()
and config_search(), which limits the search of matching config data
to these which attach to that specific attribute.
So we basically have to call config_found_ia(..., "foobus", ...) where
such a bus is attached.
As a consequence, where a "mainbus" or alike also attaches other
devices (eg CPUs) which do not attach to a specific attribute yet,
we need at least pass an attribute name (different from "foobus") so
that the foo bus is not found at these places. This made some minor
changes necessary which are not obviously related to the mentioned buses.
 1.72 28-Mar-2004  nakayama Set prom_getprop args correctly.
 1.71 22-Mar-2004  nakayama Make 32-bit kernels compile with options DEBUG.
 1.70 21-Mar-2004  martin Make sure prom_getprop is called with the size pointed to by nitem
initialized. (Some of these are more paranoia, but two were actual bugs.)
Print error codes in some panic messages.
 1.69 17-Mar-2004  pk Rename PROM_getprop*() => prom_getprop*().
 1.68 21-Jan-2004  petrov For pci devices without ofw mapping find ino by pci bus/slot/device
information, from OpenBSD.
 1.67 09-Nov-2003  martin Nuke bcopy/bzero.
 1.66 27-Aug-2003  mrg change PROM_getprop() from taking a "void **" for the storage, to a
"void *", and do the extra de-reference directly in the function. this
avoids having to cast dozens of different types to "void **", which sets
of GCC3's strict-aliasing. testing by martin@
 1.65 22-Aug-2003  petrov Don't set and check absent interrupts on sabre.
 1.64 15-Jul-2003  lukem __KERNEL_RCSID()
 1.63 15-Jun-2003  fvdl branches: 1.63.2;
Handle 64bit DMA addresses on PCI for platforms that can (currently only
enabled on amd64). Add a dmat64 field to various PCI attach structures,
and pass it down where needed. Implement a simple new function called
pci_dma64_available(pa) to test if 64bit DMA addresses may be used.
This returns 1 iff _PCI_HAVE_DMA64 is defined in <machine/pci_machdep.h>,
and there is more than 4G of memory.
 1.62 17-May-2003  nakayama Avoid strict-alias warnings in gcc 3.3.
 1.61 03-May-2003  wiz DMA, not dma nor Dma.
 1.60 21-Apr-2003  martin Connect the front panel power button on psycho based machines to sysmon's
/dev/power.

XXX - due to the way interrupt handling is structured we have no easy
way to defer clearing the button interrupt until the sysmon callback
has happened and the event is dispatched. We clear it imediately on
return from the interrupt handler. This means we get an interrupt storm
until the button is released, and then start to handle it.
This needs to be fixed! (But with the default application for the power
button does not make a user visible difference.)
 1.59 01-Apr-2003  thorpej Use PAGE_SIZE rather than NBPG.
 1.58 22-Mar-2003  nakayama PCI-CardBus bridge support for sparc64:
- handle devices which has no OBP node.
- move PCI latency-timer initialization from pci_intr_map to
pci_enumerate_bus.
- make PCI bus free space extents for cardbus devices.
- fix PCI config space map size.
- some code integrations.
 1.57 10-Dec-2002  pk Remove the `flags' argument from bus_intr_establish().
 1.56 10-Dec-2002  pk bus_intr_establish() signature change.
The additional `fast trap' argument is ignored in these drivers.
BUS_INTR_ESTABLISH_FASTTRAP and BUS_INTR_ESTABLISH_SOFTINTR are no longer used.
 1.55 02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.54 01-Oct-2002  thorpej Use CFATTACH_DECL().
 1.53 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.52 27-Sep-2002  provos remove trailing \n in panic(). approved perry.
 1.51 21-Jun-2002  eeh The FFB interrupt mapping registers need to compare IGN as well as INO since
they are totally programmable.
 1.50 20-Jun-2002  eeh Overhaul streaming buffer handling:

sysio streaming buffer flushes write a single 8-byte aligned 8-byte
value.

psycho streaming buffer flushes write a 64-byte aligned 64-byte block.

So separate out the streaming buffers into their own structure and pass those
in to all iommu operations. This also means we only flush the correct
streaming buffer for psycho rather than needing to flush both just in case.
 1.49 12-Jun-2002  eeh Use the correct bus handle to generate the handle for the streaming buffers.
 1.48 16-May-2002  eeh branches: 1.48.2;
Make the PCI code actually work.
 1.47 16-May-2002  thorpej branches: 1.47.2;
* Add "pcitag_t *pba_bridgetag" to pci_attach_args. This is set to
NULL for root PCI busses. For busses behind a bridge, it points to
a persistent copy of the bridge's pcitag_t. This can be very useful
for machine-dependent PCI bus enumeration code.
* Implement a machine-dependent pci_enumerate_bus() for sparc64 which
uses OFW device nodes to enumerate the bus. When a PCI bus that is
behind a bridge is attached, pci_attach_hook() allocates a new PCI
chipset tag for the new bus and sets it's "curnode" to the OFW node
of the bridge. This is used as a starting point when enumerating
that bus. Root busses get the OFW node of the host bridge (psycho).
* Garbage-collect "ofpci" and "ofppb" from the sparc64 port.
 1.46 06-May-2002  eeh Add code to attach ofpci.
 1.45 20-Mar-2002  eeh Overhaul bus space.

bus_space_handle_t now holds an address and two ASIs, one for normal accesses
and one for streaming accesses. This allows to map individual handles
different ways, so some can use MMU bypass accesses and others use virtual
addresses. bus_space_map() will now create handles that use bypass accesses
unles BUS_SPACE_MAP_LINEAR is passed in. So only pass in BUS_SPACE_MAP_LINEAR
if you absolutely *need* to use bus_space_vaddr(). This removes at least one
extra level of indirection and should reduce TLB misses.

32-bit kernels have problems accessing 64-bit addresses, so they always use
virtual addresses.
 1.44 15-Mar-2002  eeh Get PCI working with the new bus_space*.
 1.43 08-Mar-2002  chs make this compile without DDB.
 1.42 12-Feb-2002  martin Cast/format fix to make this build on 32bit kernels.
 1.41 08-Feb-2002  eeh Provide more info in psycho_ue.
 1.40 14-Jan-2002  eeh Set the interrupt retry timer to 0xff.
 1.39 07-Oct-2001  eeh branches: 1.39.4;
Manage both streaming caches on psycho/psycho+.
 1.38 26-Sep-2001  eeh getprop* -> PROM_getprop*
 1.37 24-Sep-2001  eeh Change bus_space_mmap() signature to the official one.
 1.36 15-Sep-2001  eeh Be a bit more elaborate with UE DMA errors.
 1.35 10-Sep-2001  eeh Sun Blade 100 support (and some psycho fixes from Jason Wright).
 1.34 20-Jul-2001  eeh branches: 1.34.2;
PCI overhaul.
 1.33 18-May-2001  mrg branches: 1.33.2;
minor cleanups.
 1.32 21-Mar-2001  mrg adapt to systems with out interrupt-map & interrupt-map-mask properties.
 1.31 06-Mar-2001  mrg rework pci_attach_hook() to just deal with the INO, not the full
interrupt number. properly find interrupts for the E250. modify
pci_intr_map() accordingly. retire psycho_intr_map(). deal with
INO values upto 0x3f, not upto 0x32. restructure sabre_init() and
psycho_init() to be more similar, and display each psycho's IGN.
psycho_intr_establish() deals with INO upto 0x3f, values from 0x32
and higher get 0 for IPL.

tested on E250 & U5.
 1.30 28-Feb-2001  mrg branches: 1.30.2;
adjust some comments to reality.
 1.29 11-Feb-2001  eeh Print out more useful data if there are interrupt issues.
 1.28 04-Dec-2000  fvdl Make gcc like a cast.
 1.27 04-Dec-2000  fvdl Warning police. Mostly useless format warnings. Switch Makefile for
kernel compiles to the warning flags that other ports also use.
 1.26 18-Nov-2000  mrg remove dead debugging code.
 1.25 19-Oct-2000  mrg add a cast to fix a warning.
 1.24 18-Jul-2000  pk Set up register bank sharing bwteen psycho A & B based on matching
physical addresses. Allocate IOMMU state separately and refer to it
from both psycho_softc's.
 1.23 14-Jul-2000  pk Use per-PBM control/status register addresses provided by the PROM.
Print version/implementation info.
 1.22 12-Jul-2000  pk No need to fetch the psycho's own registers as thet are already passed
down from the parent bus. Also account for the difference in `reg'
properties in psycho vs sabre chips.
 1.21 09-Jul-2000  pk Add a `device class' interrupt level argument (from machine/intr.h)
to bus_interrupt_establish().

It's currently only used in sparc64/dev/psycho.c to assign a CPU interrupt
level to devices in PCI slots.
 1.20 07-Jul-2000  mrg work around a bug passing arguments to iommu_dvma_load_raw()
 1.19 05-Jul-2000  pk We want to index the PCI `interrupt clear' registers with the Interrupt
Number Offset. (this stuff needs a serious cleanup).
 1.18 03-Jul-2000  eeh Use the same IPLs as everyone else.
 1.17 29-Jun-2000  mrg remove include of <vm/vm.h>. <vm/vm.h> -> <uvm/uvm_extern.h>
 1.16 26-Jun-2000  mrg remove/move more mach vm header files:

<vm/pglist.h> -> <uvm/uvm_pglist.h>
<vm/vm_inherit.h> -> <uvm/uvm_inherit.h>
<vm/vm_kern.h> -> into <uvm/uvm_extern.h>
<vm/vm_object.h> -> nothing
<vm/vm_pager.h> -> into <uvm/uvm_pager.h>

also includes a bunch of <vm/vm_page.h> include removals (due to redudancy
with <vm/vm.h>), and a scattering of other similar headers.
 1.15 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.14 19-Jun-2000  eeh branches: 1.14.2;
Fix uninitialized pointer bug.
 1.13 08-Jun-2000  eeh Support large (>1 page) DVMA maps so UltraSPARC IIi will work.
 1.12 24-May-2000  eeh branches: 1.12.2;
Use the PCI function code to distinguish simba bus A from bus B instead
of the current hack.
 1.11 17-May-2000  mrg fix if/ifdef mistake
 1.10 17-May-2000  mrg - add some psycho interrupt debugging stuff (#if 0'ed out)
- fix arguments passed in psycho_dmamap_load_raw()'s declaration, and
what it passes to it's parent bus.
 1.9 17-May-2000  eeh Add support for bus_dma_load_raw() so the le driver will work again.
 1.8 06-May-2000  mrg implement U2P PCI support in psycho_init. this is completely untested.
 1.7 22-Apr-2000  mrg whole bunch of changes:
- merge IOMMU DVMA code from sbus/psycho into iommu.c. this code was
identical and a few minor inconsistencies had crept in. this way
keeps them all in sync.
- with this code gone from psycho, merge the psycho.c and psycho_bus.c
files. same with ebus/ebus_bus.c. delete the _bus.c files.
- add a _ds_boundary member to the dma segment structure, so that later
dma mappings can find this value.
- set _ds_boundary in machdep.c:_bus_dmamem_alloc().
- kill much dead code.
 1.6 15-Apr-2000  mrg kill dead code
 1.5 10-Apr-2000  mrg - UltraSPARC IIi does not have streaming buffers; don't try to find it's
diag regsiter to work out why the (non-existant) strbufs don't work.
- check for malloc failure in _all_ places.
- setup the PCI control register as recommended in the IIi users manual.
 1.4 08-Apr-2000  mrg with these two, POWEROFSEVEN now compiles cleanly.
 1.3 08-Apr-2000  mrg rearrange a little to accommodate real SUNW,psycho support.
 1.2 08-Jul-1999  thorpej branches: 1.2.2;
Change the pmap_extract() interface to:
boolean_t pmap_extract(pmap_t, vaddr_t, paddr_t *);
This makes it possible for the pmap to map physical address 0.
 1.1 04-Jun-1999  mrg branches: 1.1.2;
PCI driver for the UltraSPARC. this only works on the Ultra5/10 machines
(`SUNW,sabre') for now, and it doesn't really quite work there yet anyway.
the bus space/dma code is cloned from the sbus driver. the IOMMU code also
is cloned from the sbus code, but separated out into iommu.c so that we can
share it with the sbus driver. hopefully, much of the bus space/dma code
can also be re-shared with the sbus driver and the ebus driver but for now
these copies will do.

support for the real UltraSPARC PCI (`SUNW,psycho') is unwritten, though
most of this code is shared with it.

we can probe PCI config space and try to configue devices, but interrupts
don't work yet...
 1.1.2.2 02-Aug-1999  thorpej Update from trunk.
 1.1.2.1 21-Jun-1999  thorpej Sync w/ -current.
 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 08-Dec-2000  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.12.2.1 22-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.14.2.2 18-Jul-2000  mrg pullup the contents of -current arch/sparc64. this gives us significant
ultrasparc PCI support (ultra5, ultra10, AXi, and E250 tested so far),
plus many other small fixes. netbooting is now supported.
 1.14.2.1 30-Jun-2000  simonb Pull up mmap paddr_t/off_t changes from trunk.
 1.30.2.2 21-Jun-2001  nathanw Catch up to -current.
 1.30.2.1 09-Apr-2001  nathanw Catch up with -current.
 1.33.2.8 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.33.2.7 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.33.2.6 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.33.2.5 16-Mar-2002  jdolecek Catch up with -current.
 1.33.2.4 11-Feb-2002  jdolecek Sync w/ -current.
 1.33.2.3 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.33.2.2 13-Sep-2001  thorpej Update the kqueue branch to HEAD.
 1.33.2.1 03-Aug-2001  lukem update to -current
 1.34.2.2 11-Oct-2001  fvdl Catch up with -current. Fix some bogons in the sparc64 kbd/ms
attach code. cd18xx conversion provided by mrg.
 1.34.2.1 01-Oct-2001  fvdl Catch up with -current.
 1.39.4.7 11-Dec-2002  thorpej Sync with HEAD.
 1.39.4.6 18-Oct-2002  nathanw Catch up to -current.
 1.39.4.5 01-Aug-2002  nathanw Catch up to -current.
 1.39.4.4 20-Jun-2002  nathanw Catch up to -current.
 1.39.4.3 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.39.4.2 28-Feb-2002  nathanw Catch up to -current.
 1.39.4.1 07-Oct-2001  nathanw file psycho.c was added on branch nathanw_sa on 2002-02-28 04:12:11 +0000
 1.47.2.4 17-Jul-2002  gehenna catch up with -current.
 1.47.2.3 15-Jul-2002  gehenna catch up with -current.
 1.47.2.2 30-May-2002  gehenna Catch up with -current.
 1.47.2.1 16-May-2002  gehenna file psycho.c was added on branch gehenna-devsw on 2002-05-30 15:35:49 +0000
 1.48.2.3 21-Jun-2002  lukem Pull up revision 1.51 (requested by eeh in ticket #338):
The FFB interrupt mapping registers need to compare IGN as well as INO since
they are totally programmable.
 1.48.2.2 21-Jun-2002  lukem Pull up revision 1.50 (requested by eeh in ticket #337):
Overhaul streaming buffer handling:
sysio streaming buffer flushes write a single 8-byte aligned 8-byte
value.
psycho streaming buffer flushes write a 64-byte aligned 64-byte block.
So separate out the streaming buffers into their own structure and pass those
in to all iommu operations. This also means we only flush the correct
streaming buffer for psycho rather than needing to flush both just in case.
[Gets E220R working]
 1.48.2.1 12-Jun-2002  lukem Pull up revision 1.49 (requested by eeh in ticket #254):
Use the correct bus handle to generate the handle for the streaming buffers.
 1.63.2.5 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.63.2.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.63.2.3 18-Sep-2004  skrll Sync with HEAD.
 1.63.2.2 03-Sep-2004  skrll Sync with HEAD
 1.63.2.1 03-Aug-2004  skrll Sync with HEAD
 1.74.2.5 27-Feb-2008  yamt sync with head.
 1.74.2.4 21-Jan-2008  yamt sync with head
 1.74.2.3 07-Dec-2007  yamt sync with head
 1.74.2.2 03-Sep-2007  yamt sync with head.
 1.74.2.1 21-Jun-2006  yamt sync with head.
 1.75.4.1 09-Sep-2006  rpaulo sync with head
 1.75.2.2 01-Mar-2006  yamt sync with head.
 1.75.2.1 18-Feb-2006  yamt sync with head.
 1.76.2.1 22-Apr-2006  simonb Sync with head.
 1.78.4.1 19-Apr-2006  elad sync with head - hopefully this will work
 1.78.2.1 13-Mar-2006  yamt sync with head.
 1.79.16.1 12-Mar-2007  rmind Sync with HEAD.
 1.80.26.2 18-Feb-2008  mjf Sync with HEAD.
 1.80.26.1 08-Dec-2007  mjf Sync with HEAD.
 1.80.24.1 21-Nov-2007  bouyer Sync with HEAD
 1.80.20.2 23-Mar-2008  matt sync with HEAD
 1.80.20.1 09-Jan-2008  matt sync with HEAD
 1.80.18.2 03-Dec-2007  joerg Sync with HEAD.
 1.80.18.1 21-Nov-2007  joerg Sync with HEAD.
 1.80.2.1 03-Dec-2007  ad Sync with HEAD.
 1.82.6.1 02-Jan-2008  bouyer Sync with HEAD
 1.84.6.3 17-Jan-2009  mjf Sync with HEAD.
 1.84.6.2 29-Jun-2008  mjf Sync with HEAD.
 1.84.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.85.6.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.85.4.3 11-Aug-2010  yamt sync with head.
 1.85.4.2 11-Mar-2010  yamt sync with head
 1.85.4.1 04-May-2009  yamt sync with head.
 1.85.2.2 17-Jun-2008  yamt sync with head.
 1.85.2.1 04-Jun-2008  yamt sync with head
 1.87.2.1 18-Jun-2008  simonb Sync with head.
 1.88.2.2 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.88.2.1 19-Oct-2008  haad Sync with HEAD.
 1.91.4.1 16-Feb-2011  bouyer Pull up following revision(s) (requested by nakayama in ticket #1555):
sys/arch/sparc64/dev/psycho.c: revision 1.102 via patch
Don't enable the powerfail interrupt on Netra X1 since it may hang.
Discussed on port-sparc64.
 1.91.2.1 19-Jan-2009  skrll Sync with HEAD.
 1.100.4.4 12-Jun-2011  rmind sync with head
 1.100.4.3 31-May-2011  rmind sync with head
 1.100.4.2 21-Apr-2011  rmind sync with head
 1.100.4.1 05-Mar-2011  rmind sync with head
 1.100.2.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.101.4.1 17-Feb-2011  bouyer Sync with HEAD
 1.101.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.106.2.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.111.6.1 18-Feb-2012  mrg merge to -current.
 1.111.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.111.2.1 17-Apr-2012  yamt sync with head
 1.112.6.3 03-Dec-2017  jdolecek update from HEAD
 1.112.6.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.112.6.1 23-Jun-2013  tls resync from head
 1.113.2.2 18-May-2014  rmind sync with head
 1.113.2.1 28-Aug-2013  rmind sync with head
 1.118.4.1 10-Nov-2014  snj Pull up following revision(s) (requested by maxv in ticket #195):
sys/arch/arm/iomd/iomd_irqhandler.c: revision 1.21
sys/arch/arm/ofw/ofw_irqhandler.c: revision 1.21
sys/arch/atari/atari/intr.c: revision 1.24-1.25
sys/arch/ews4800mips/sbd/fb_sbdio.c: revision 1.14
sys/arch/hpcmips/tx/tx39icu.c: revision 1.34
sys/arch/shark/isa/isa_irqhandler.c: revision 1.27
sys/arch/sparc/sparc/machdep.c: revision 1.327
sys/arch/sparc64/dev/psycho.c: revision 1.119
sys/arch/sparc64/dev/schizo.c: revision 1.32
sys/arch/sparc64/sparc64/machdep.c: revision 1.279
sys/arch/sun68k/sun68k/bus.c: revision 1.22
sys/arch/x86/x86/ipmi.c: revision 1.58
sys/arch/xen/xen/privcmd.c: revision 1.46-1.49
Fix several memory leaks.
 1.120.2.3 28-Aug-2017  skrll Sync with HEAD
 1.120.2.2 29-May-2016  skrll Sync with HEAD
 1.120.2.1 27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.124.4.1 21-Apr-2017  bouyer Sync with HEAD
 1.124.2.1 26-Apr-2017  pgoyette Sync with HEAD
 1.126.14.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.126.14.1 10-Jun-2019  christos Sync with HEAD
 1.128.8.1 03-Apr-2021  thorpej Sync with HEAD.
 1.132.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.133.4.1 31-May-2021  cjep sync with head
 1.133.2.1 13-May-2021  thorpej Sync with HEAD.
 1.134.4.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.137.10.1 02-Aug-2025  perseant Sync with HEAD
 1.10 22-Apr-2000  mrg whole bunch of changes:
- merge IOMMU DVMA code from sbus/psycho into iommu.c. this code was
identical and a few minor inconsistencies had crept in. this way
keeps them all in sync.
- with this code gone from psycho, merge the psycho.c and psycho_bus.c
files. same with ebus/ebus_bus.c. delete the _bus.c files.
- add a _ds_boundary member to the dma segment structure, so that later
dma mappings can find this value.
- set _ds_boundary in machdep.c:_bus_dmamem_alloc().
- kill much dead code.
 1.9 10-Apr-2000  mrg UltraSPARC IIi CPU has bits 6-10 of the INO hardwired to 1. when we
install an interrupt handler, make sure we set these bits to 1. now,
interrupt_vector in locore can find our registered interrupt handlers
and at least try to setup a call to them.
 1.8 08-Apr-2000  mrg correct the pci ino->ipl table. shut up gcc once more.
 1.7 05-Apr-2000  mrg include opt_ddb.h. use generic iommu enter/remove/flush routines
 1.6 13-Mar-2000  soren Fix doubled 'the's in comments.
 1.5 24-Nov-1999  mrg prefix a variable with "pci_"
 1.4 13-Nov-1999  thorpej Update for pmap_enter() API change. No functional difference.
 1.3 08-Jul-1999  thorpej branches: 1.3.2; 1.3.4; 1.3.8;
Change the pmap_extract() interface to:
boolean_t pmap_extract(pmap_t, vaddr_t, paddr_t *);
This makes it possible for the pmap to map physical address 0.
 1.2 07-Jun-1999  eeh branches: 1.2.2;
Another general cleanup:

Remove the entire idea of fasttrap interrupts since V9 traps are really cheap,
the CPUs are really fast, and the completely different trap frames would make
these handlers really difficult to implement.

pmap_changeprot() was only used by the clock and one other place; deprecate it.

probeget() and probeset() now take 64-bit addresses even in 32-bit mode so we
can probe IO locations by physical addresses.

Some pmap cleanup.

Some more copyright cleanup.
 1.1 04-Jun-1999  mrg PCI driver for the UltraSPARC. this only works on the Ultra5/10 machines
(`SUNW,sabre') for now, and it doesn't really quite work there yet anyway.
the bus space/dma code is cloned from the sbus driver. the IOMMU code also
is cloned from the sbus code, but separated out into iommu.c so that we can
share it with the sbus driver. hopefully, much of the bus space/dma code
can also be re-shared with the sbus driver and the ebus driver but for now
these copies will do.

support for the real UltraSPARC PCI (`SUNW,psycho') is unwritten, though
most of this code is shared with it.

we can probe PCI config space and try to configue devices, but interrupts
don't work yet...
 1.2.2.3 02-Aug-1999  thorpej Update from trunk.
 1.2.2.2 21-Jun-1999  thorpej Sync w/ -current.
 1.2.2.1 07-Jun-1999  thorpej file psycho_bus.c was added on branch chs-ubc2 on 1999-06-21 01:02:31 +0000
 1.3.8.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.3.4.1 15-Nov-1999  fvdl Sync with -current
 1.3.2.1 20-Nov-2000  bouyer Remove files that are no longer on the trunck
 1.19 20-Aug-2013  macallan support UltraSPARC-IIe STICK counter as time base
 1.18 20-Aug-2013  macallan add US-IIe specific STICK and ESTAR registers
 1.17 16-Mar-2011  mrg branches: 1.17.4; 1.17.14; 1.17.18;
revert the iommu changes for now. my U60 doesn't like them.
 1.16 16-Mar-2011  mrg use struct iommureg_old.
 1.15 10-Mar-2011  mrg fix a typo
 1.14 30-May-2008  mrg branches: 1.14.20; 1.14.26;
convert the rest of my licenses to 2-clause, extracting myself out
from a group as necessary.

bozohttpd remains, but it will get fixed next time i update it.
 1.13 25-Feb-2006  wiz branches: 1.13.68; 1.13.70; 1.13.72; 1.13.74;
Fix typos, reported by Alexey Dobriyan ("Gathered from Linux"),
forwarded by jmc@openbsd.
 1.12 13-Feb-2006  cdi ANSIfy: u_intN_t -> uintN_t, remove __P(), fix function definitions.
 1.11 17-May-2003  nakayama branches: 1.11.18; 1.11.30; 1.11.32; 1.11.34;
Avoid integer constant is too large warnings in gcc 3.3.
 1.10 17-Apr-2003  nakayama Comment fixes from OpenBSD.
 1.9 15-Sep-2001  eeh branches: 1.9.4;
Be a bit more elaborate with UE DMA errors.
 1.8 10-Sep-2001  eeh Sun Blade 100 support (and some psycho fixes from Jason Wright).
 1.7 20-Jul-2001  eeh branches: 1.7.2;
PCI overhaul.
 1.6 14-Jul-2000  pk branches: 1.6.4;
Provide details on the `psy_csr' register.
 1.5 14-Jul-2000  pk Fix padding in struct pci_ctl.
 1.4 24-May-2000  eeh branches: 1.4.4;
Use the PCI function code to distinguish simba bus A from bus B instead
of the current hack.
 1.3 10-Apr-2000  mrg add 4 more bits for the PCI control register
 1.2 07-Jun-1999  mrg branches: 1.2.2; 1.2.4;
copyright foo. in the future, we will all be binary-redistributable.
 1.1 04-Jun-1999  mrg PCI driver for the UltraSPARC. this only works on the Ultra5/10 machines
(`SUNW,sabre') for now, and it doesn't really quite work there yet anyway.
the bus space/dma code is cloned from the sbus driver. the IOMMU code also
is cloned from the sbus code, but separated out into iommu.c so that we can
share it with the sbus driver. hopefully, much of the bus space/dma code
can also be re-shared with the sbus driver and the ebus driver but for now
these copies will do.

support for the real UltraSPARC PCI (`SUNW,psycho') is unwritten, though
most of this code is shared with it.

we can probe PCI config space and try to configue devices, but interrupts
don't work yet...
 1.2.4.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.2 21-Jun-1999  thorpej Sync w/ -current.
 1.2.2.1 07-Jun-1999  thorpej file psychoreg.h was added on branch chs-ubc2 on 1999-06-21 01:02:31 +0000
 1.4.4.1 18-Jul-2000  mrg pullup the contents of -current arch/sparc64. this gives us significant
ultrasparc PCI support (ultra5, ultra10, AXi, and E250 tested so far),
plus many other small fixes. netbooting is now supported.
 1.6.4.3 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.6.4.2 13-Sep-2001  thorpej Update the kqueue branch to HEAD.
 1.6.4.1 03-Aug-2001  lukem update to -current
 1.7.2.1 01-Oct-2001  fvdl Catch up with -current.
 1.9.4.2 15-Sep-2001  eeh Be a bit more elaborate with UE DMA errors.
 1.9.4.1 15-Sep-2001  eeh file psychoreg.h was added on branch nathanw_sa on 2001-09-15 07:10:06 +0000
 1.11.34.1 22-Apr-2006  simonb Sync with head.
 1.11.32.1 09-Sep-2006  rpaulo sync with head
 1.11.30.2 01-Mar-2006  yamt sync with head.
 1.11.30.1 18-Feb-2006  yamt sync with head.
 1.11.18.1 21-Jun-2006  yamt sync with head.
 1.13.74.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.13.72.1 04-May-2009  yamt sync with head.
 1.13.70.1 04-Jun-2008  yamt sync with head
 1.13.68.1 02-Jun-2008  mjf Sync with HEAD.
 1.14.26.1 06-Jun-2011  jruoho Sync with HEAD.
 1.14.20.3 21-Apr-2011  rmind sync with head
 1.14.20.2 10-Mar-2011  mrg revert wrong branch commit
 1.14.20.1 10-Mar-2011  mrg fix a typo
 1.17.18.1 28-Aug-2013  rmind sync with head
 1.17.14.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.17.4.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.21 07-Dec-2013  nakayama Timecounter's tc_get_timecount requires only 32-bit (u_int), so
omit unnecessary upper 32-bit read from STICK counter.
 1.20 22-Aug-2013  nakayama Handle US-IIe's STICK counter as 64-bit explicitly to fix a hang at
boot after about 6.5 minutes on 32-bit kernel.
 1.19 20-Aug-2013  macallan support UltraSPARC-IIe STICK counter as time base
 1.18 02-Jun-2011  christos branches: 1.18.2; 1.18.12; 1.18.16;
split auxio, ebus, psycho, sab.
 1.17 09-Dec-2008  nakayama branches: 1.17.6; 1.17.8; 1.17.12;
Fix CardBus, PCI-PCI bridge support borked in previous commit.
 1.16 07-Dec-2008  mrg a few clean up/rearrange changes, somewhat inspired from openbsd's
schizo.c:

- rename pp_busnode{} -> spc_busnode{}, and move it to
sparc_pci_chipset{}

- move public pci functions pci_conf_read(), pci_conf_write() and
pci_intr_establish() into psycho.c, renaming them in the process,
and add pointers through sparc_pci_chipset{} to access them.
as part of this, add PDB_INTMAP and PDB_CONF debug options to
psycho.c

- move and rename sparc64 private pci_find_ino() into
sparc_pci_chipset{}, like the above

- update psycho_alloc_chipset() to set the new 4 function members


no functional change intended. XXX: not tested on cardbus.
 1.15 29-May-2008  mrg branches: 1.15.4; 1.15.6;
remove clause #3 from my license where there are no other
copyright holders involved.
 1.14 13-Feb-2006  cdi branches: 1.14.68; 1.14.70; 1.14.72; 1.14.74;
ANSIfy: u_intN_t -> uintN_t, remove __P(), fix function definitions.
 1.13 11-Dec-2005  christos branches: 1.13.2; 1.13.4; 1.13.6;
merge ktrace-lwp.
 1.12 21-Jan-2004  petrov branches: 1.12.16;
For pci devices without ofw mapping find ino by pci bus/slot/device
information, from OpenBSD.
 1.11 03-May-2003  wiz branches: 1.11.2;
DMA, not dma nor Dma.
 1.10 21-Apr-2003  martin Connect the front panel power button on psycho based machines to sysmon's
/dev/power.

XXX - due to the way interrupt handling is structured we have no easy
way to defer clearing the button interrupt until the sysmon callback
has happened and the event is dispatched. We clear it imediately on
return from the interrupt handler. This means we get an interrupt storm
until the button is released, and then start to handle it.
This needs to be fixed! (But with the default application for the power
button does not make a user visible difference.)
 1.9 22-Mar-2003  nakayama PCI-CardBus bridge support for sparc64:
- handle devices which has no OBP node.
- move PCI latency-timer initialization from pci_intr_map to
pci_enumerate_bus.
- make PCI bus free space extents for cardbus devices.
- fix PCI config space map size.
- some code integrations.
 1.8 20-Jun-2002  eeh Overhaul streaming buffer handling:

sysio streaming buffer flushes write a single 8-byte aligned 8-byte
value.

psycho streaming buffer flushes write a 64-byte aligned 64-byte block.

So separate out the streaming buffers into their own structure and pass those
in to all iommu operations. This also means we only flush the correct
streaming buffer for psycho rather than needing to flush both just in case.
 1.7 20-Mar-2002  eeh branches: 1.7.4; 1.7.6;
Overhaul bus space.

bus_space_handle_t now holds an address and two ASIs, one for normal accesses
and one for streaming accesses. This allows to map individual handles
different ways, so some can use MMU bypass accesses and others use virtual
addresses. bus_space_map() will now create handles that use bypass accesses
unles BUS_SPACE_MAP_LINEAR is passed in. So only pass in BUS_SPACE_MAP_LINEAR
if you absolutely *need* to use bus_space_vaddr(). This removes at least one
extra level of indirection and should reduce TLB misses.

32-bit kernels have problems accessing 64-bit addresses, so they always use
virtual addresses.
 1.6 20-Jul-2001  eeh branches: 1.6.6;
PCI overhaul.
 1.5 06-Mar-2001  mrg branches: 1.5.2;
rework pci_attach_hook() to just deal with the INO, not the full
interrupt number. properly find interrupts for the E250. modify
pci_intr_map() accordingly. retire psycho_intr_map(). deal with
INO values upto 0x3f, not upto 0x32. restructure sabre_init() and
psycho_init() to be more similar, and display each psycho's IGN.
psycho_intr_establish() deals with INO upto 0x3f, values from 0x32
and higher get 0 for IPL.

tested on E250 & U5.
 1.4 18-Jul-2000  pk branches: 1.4.2;
Set up register bank sharing bwteen psycho A & B based on matching
physical addresses. Allocate IOMMU state separately and refer to it
from both psycho_softc's.
 1.3 24-May-2000  eeh branches: 1.3.4;
Use the PCI function code to distinguish simba bus A from bus B instead
of the current hack.
 1.2 10-Apr-2000  mrg - UltraSPARC IIi does not have streaming buffers; don't try to find it's
diag regsiter to work out why the (non-existant) strbufs don't work.
- check for malloc failure in _all_ places.
- setup the PCI control register as recommended in the IIi users manual.
 1.1 04-Jun-1999  mrg branches: 1.1.2; 1.1.4;
PCI driver for the UltraSPARC. this only works on the Ultra5/10 machines
(`SUNW,sabre') for now, and it doesn't really quite work there yet anyway.
the bus space/dma code is cloned from the sbus driver. the IOMMU code also
is cloned from the sbus code, but separated out into iommu.c so that we can
share it with the sbus driver. hopefully, much of the bus space/dma code
can also be re-shared with the sbus driver and the ebus driver but for now
these copies will do.

support for the real UltraSPARC PCI (`SUNW,psycho') is unwritten, though
most of this code is shared with it.

we can probe PCI config space and try to configue devices, but interrupts
don't work yet...
 1.1.4.2 12-Mar-2001  bouyer Sync with HEAD.
 1.1.4.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.1.2.1 21-Jun-1999  thorpej Sync w/ -current.
 1.3.4.1 18-Jul-2000  mrg pullup the contents of -current arch/sparc64. this gives us significant
ultrasparc PCI support (ultra5, ultra10, AXi, and E250 tested so far),
plus many other small fixes. netbooting is now supported.
 1.4.2.1 09-Apr-2001  nathanw Catch up with -current.
 1.5.2.3 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.5.2.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.5.2.1 03-Aug-2001  lukem update to -current
 1.6.6.3 01-Aug-2002  nathanw Catch up to -current.
 1.6.6.2 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.6.6.1 20-Jul-2001  nathanw file psychovar.h was added on branch nathanw_sa on 2002-04-01 07:43:05 +0000
 1.7.6.1 21-Jun-2002  lukem Pull up revision 1.8 (requested by eeh in ticket #337):
Overhaul streaming buffer handling:
sysio streaming buffer flushes write a single 8-byte aligned 8-byte
value.
psycho streaming buffer flushes write a 64-byte aligned 64-byte block.
So separate out the streaming buffers into their own structure and pass those
in to all iommu operations. This also means we only flush the correct
streaming buffer for psycho rather than needing to flush both just in case.
[Gets E220R working]
 1.7.4.1 17-Jul-2002  gehenna catch up with -current.
 1.11.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.11.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.11.2.1 03-Aug-2004  skrll Sync with HEAD
 1.12.16.1 21-Jun-2006  yamt sync with head.
 1.13.6.1 22-Apr-2006  simonb Sync with head.
 1.13.4.1 09-Sep-2006  rpaulo sync with head
 1.13.2.1 18-Feb-2006  yamt sync with head.
 1.14.74.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.14.72.1 04-May-2009  yamt sync with head.
 1.14.70.1 04-Jun-2008  yamt sync with head
 1.14.68.2 17-Jan-2009  mjf Sync with HEAD.
 1.14.68.1 02-Jun-2008  mjf Sync with HEAD.
 1.15.6.1 19-Jan-2009  skrll Sync with HEAD.
 1.15.4.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.17.12.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.17.8.1 06-Jun-2011  jruoho Sync with HEAD.
 1.17.6.1 12-Jun-2011  rmind sync with head
 1.18.16.2 18-May-2014  rmind sync with head
 1.18.16.1 28-Aug-2013  rmind sync with head
 1.18.12.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.18.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.26 21-Jan-2022  thorpej Don't bother with prom_node_to_devhandle() if we're just forwarding along
our own node; use device_handle(self) instead.
 1.25 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.24 10-May-2021  thorpej branches: 1.24.4;
Associate the OpenBoot / OpenFirmware node with attached devices
at config_found() time.
 1.23 24-Apr-2021  thorpej branches: 1.23.2; 1.23.4;
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.22 17-Jan-2021  mrg branches: 1.22.2;
reduce the scope of 'ci' variable.
 1.21 04-Jan-2021  thorpej malloc(9) -> kmem(9) -- just the simple, straightforward conversions for now.
 1.20 10-Nov-2019  chs branches: 1.20.8;
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.19 21-Apr-2019  maya wether -> whether
 1.18 10-Nov-2016  macallan branches: 1.18.16;
weed out BUS_SPACE_MAP_PREFETCHABLE in resp. _map() and _mmap() methods
it works with UPA graphics cards and at least some psycho but causes problems
on these
 1.17 10-May-2016  palle branches: 1.17.2;
sun4v: make device interrupts work. Introduce a new intrhand_alloc() function for allocation of interrupt handlers and adapt to this. Parts from OpenBSD. ok martin@
 1.16 02-Oct-2015  msaitoh PCI Extended Configuration stuff written by nonaka@:
- Add PCI Extended Configuration Space support into x86.
- Check register offset of pci_conf_read() in MD part. It returns (pcireg_t)-1
if it isn't accessible.
- Decode Extended Capability in PCI Extended Configuration Space.
Currently the following extended capabilities are decoded:
- Advanced Error Reporting
- Virtual Channel
- Device Serial Number
- Power Budgeting
- Root Complex Link Declaration
- Root Complex Event Collector Association
- Access Control Services
- Alternative Routing-ID Interpretation
- Address Translation Services
- Single Root IO Virtualization
- Page Request
- TPH Requester
- Latency Tolerance Reporting
- Secondary PCI Express
- Process Address Space ID
- LN Requester
- L1 PM Substates
The following extended capabilities are not decoded yet:
- Root Complex Internal Link Control
- Multi-Function Virtual Channel
- RCRB Header
- Vendor Unique
- Configuration Access Correction
- Multiple Root IO Virtualization
- Multicast
- Resizable BAR
- Dynamic Power Allocation
- Protocol Multiplexing
- Downstream Port Containment
- Precision Time Management
- M-PCIe
- Function Reading Status Queueing
- Readiness Time Reporting
- Designated Vendor-Specific
 1.15 10-Aug-2013  mrg branches: 1.15.6;
thanks to mhitch, we got all the interrupt issues sorted out for now,
so turn off PDB_INTR in the debug kernel.
 1.14 24-Jun-2013  nakayama branches: 1.14.2;
Fix copy and paste.
 1.13 21-Jun-2013  nakayama Avoid data_access_error trap panic when reading unused PCI
configuration space.

This method is described in UltraSPARC IIi User's Manual "16.2.1
Probing PCI during boot using deferred errors", and refer to the
implementation of OpenBSD.
 1.12 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.11 18-Mar-2012  mrg branches: 1.11.2;
add missing __KERNEL_RCSID().
 1.10 12-Aug-2011  mrg branches: 1.10.2; 1.10.6;
initailise ih_pending and ih_ivec.
 1.9 12-Aug-2011  mrg print the ihandle passed in, not NULL.
 1.8 01-Jul-2011  dyoung #include <sys/bus.h> instead of <machine/bus.h>.
 1.7 03-Jun-2011  christos branches: 1.7.2;
forgot _NEW
 1.6 03-Jun-2011  christos CFATTACH_DECL_NEW
 1.5 17-May-2011  dyoung branches: 1.5.2;
PCI_FLAGS_IO_ENABLED and PCI_FLAGS_MEM_ENABLED changed their functional
role in NetBSD (drivers are no longer supposed to write these to
pa_flags) without changing name. Correct that.

Rename PCI_FLAGS_IO_ENABLED to PCI_FLAGS_IO_OKAY and
PCI_FLAGS_MEM_ENABLED to PCI_FLAGS_MEM_OKAY, thus making their names
consistent with the other PCI flags and poisoning 3rd-party driver
sources that use the flags in the old bad way.

This patch produces no binary changes in this set of PCI kernels when
they are compiled w/o 'options DIAGNOSTIC' and w/ -V MKREPRO=yes:

algor P4032 P5064 P6032
alpha GENERIC
amd64 GENERIC XEN3_DOM0
arc GENERIC
atari HADES MILAN-PCIIDE
bebox GENERIC
cats GENERIC
cobalt GENERIC
evbarm-el ADI_BRH ARMADILLO9 CP3100 GEMINI GEMINI_MASTER GEMINI_SLAVE
evbarm-el GUMSTIX HDL_G IMX31LITE INTEGRATOR IQ31244 IQ80310 IQ80321
evbarm-el IXDP425 IXM1200 KUROBOX_PRO
evbarm-el LUBBOCK MARVELL_NAS NAPPI NSLU2 SHEEVAPLUG SMDK2800 TEAMASA_NPWR
evbarm-el TEAMASA_NPWR_FC TS7200 TWINTAIL ZAO425
evbmips-el AP30 DBAU1500 DBAU1550 MALTA MERAKI MTX-1 OMSAL400 RB153 WGT624V3
evbmips64-el XLSATX
evbppc EV64260 MPC8536DS MPC8548CDS OPENBLOCKS200 OPENBLOCKS266
evbppc OPENBLOCKS266_OPT P2020RDB PMPPC RB800 WALNUT
hp700 GENERIC
i386 ALL XEN3_DOM0 XEN3_DOMU
ibmnws GENERIC
iyonix GENERIC
landisk GENERIC
macppc GENERIC
mvmeppc GENERIC
netwinder GENERIC
ofppc GENERIC
prep GENERIC
sandpoint GENERIC
sbmips-el GENERIC
sgimips GENERIC32_IP2x GENERIC32_IP3x
sparc GENERIC_SUN4U KRUPS
sparc64 GENERIC
 1.4 04-Apr-2011  dyoung branches: 1.4.2;
Neither pci_dma64_available(), pci_probe_device(), pci_mapreg_map(9),
pci_find_rom(), pci_intr_map(9), pci_enumerate_bus(), nor the match
predicate passed to pciide_compat_intr_establish() should ever modify
their pci_attach_args argument, so make their pci_attach_args arguments
const and deal with the fallout throughout the kernel.

For the most part, these changes add a 'const' where there was no
'const' before, however, some drivers and MD code used to modify
pci_attach_args. Now those drivers either copy their pci_attach_args
and modify the copy, or refrain from modifying pci_attach_args:

Xen: according to Manuel Bouyer, writing to pci_attach_args in
pci_intr_map() was a leftover from Xen 2. Probably a bug. I
stopped writing it. I have not tested this change.

siside(4): sis_hostbr_match() needlessly wrote to pci_attach_args.
Probably a bug. I use a temporary variable. I have not tested this
change.

slide(4): sl82c105_chip_map() overwrote the caller's pci_attach_args.
Probably a bug. Use a local pci_attach_args. I have not tested
this change.

viaide(4): via_sata_chip_map() and via_sata_chip_map_new() overwrote the
caller's pci_attach_args. Probably a bug. Make a local copy of the
caller's pci_attach_args and modify the copy. I have not tested
this change.

While I'm here, make pci_mapreg_submap() static.

With these changes in place, I have tested the compilation of these
kernels:

alpha GENERIC
amd64 GENERIC XEN3_DOM0
arc GENERIC
atari HADES MILAN-PCIIDE
bebox GENERIC
cats GENERIC
cobalt GENERIC
evbarm-eb NSLU2
evbarm-el ADI_BRH ARMADILLO9 CP3100 GEMINI GEMINI_MASTER GEMINI_SLAVE GUMSTIX
HDL_G IMX31LITE INTEGRATOR IQ31244 IQ80310 IQ80321 IXDP425 IXM1200
KUROBOX_PRO LUBBOCK MARVELL_NAS NAPPI SHEEVAPLUG SMDK2800 TEAMASA_NPWR
TEAMASA_NPWR_FC TS7200 TWINTAIL ZAO425
evbmips-el AP30 DBAU1500 DBAU1550 MALTA MERAKI MTX-1 OMSAL400 RB153 WGT624V3
evbmips64-el XLSATX
evbppc EV64260 MPC8536DS MPC8548CDS OPENBLOCKS200 OPENBLOCKS266
OPENBLOCKS266_OPT P2020RDB PMPPC RB800 WALNUT
hp700 GENERIC
i386 ALL XEN3_DOM0 XEN3_DOMU
ibmnws GENERIC
macppc GENERIC
mvmeppc GENERIC
netwinder GENERIC
ofppc GENERIC
prep GENERIC
sandpoint GENERIC
sgimips GENERIC32_IP2x
sparc GENERIC_SUN4U KRUPS
sparc64 GENERIC

As of Sun Apr 3 15:26:26 CDT 2011, I could not compile these kernels
with or without my patches in place:

### evbmips-el GDIUM

nbmake: nbmake: don't know how to make /home/dyoung/pristine-nbsd/src/sys/arch/mips/mips/softintr.c. Stop

### evbarm-el MPCSA_GENERIC
src/sys/arch/evbarm/conf/MPCSA_GENERIC:318: ds1672rtc*: unknown device `ds1672rtc'

### ia64 GENERIC

/tmp/genassym.28085/assym.c: In function 'f111':
/tmp/genassym.28085/assym.c:67: error: invalid application of 'sizeof' to incomplete type 'struct pcb'
/tmp/genassym.28085/assym.c:76: error: dereferencing pointer to incomplete type

### sgimips GENERIC32_IP3x

crmfb.o: In function `crmfb_attach':
crmfb.c:(.text+0x2304): undefined reference to `ddc_read_edid'
crmfb.c:(.text+0x2304): relocation truncated to fit: R_MIPS_26 against `ddc_read_edid'
crmfb.c:(.text+0x234c): undefined reference to `edid_parse'
crmfb.c:(.text+0x234c): relocation truncated to fit: R_MIPS_26 against `edid_parse'
crmfb.c:(.text+0x2354): undefined reference to `edid_print'
crmfb.c:(.text+0x2354): relocation truncated to fit: R_MIPS_26 against `edid_print'
 1.3 20-Mar-2011  mrg remove pyro_xir(). we don't have the MD support for it (yet?).
clean up some debug code. clean up the DPRINTF() code, and expand
the interrupt mapping debug code to match schizo and psycho.
set IOMMU_TSBSIZE_IN_PTSB, and if oberon, IOMMU_FLUSH_CACHE.
disable the STC explicitly.
 1.2 15-Mar-2011  mrg initial port of these drivers to netbsd. both pyro(4) and ebus(4) at
mainbus depend upon other as-yet uncommited changes.
 1.1 15-Mar-2011  mrg branches: 1.1.1;
Initial revision
 1.1.1.1 15-Mar-2011  mrg import the openbsd pyro and ebus_mainbus drivers for base reference.
 1.4.2.4 12-Jun-2011  rmind sync with head
 1.4.2.3 31-May-2011  rmind sync with head
 1.4.2.2 21-Apr-2011  rmind sync with head
 1.4.2.1 04-Apr-2011  rmind file pyro.c was added on branch rmind-uvmplock on 2011-04-21 01:41:27 +0000
 1.5.2.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.7.2.2 06-Jun-2011  jruoho Sync with HEAD.
 1.7.2.1 03-Jun-2011  jruoho file pyro.c was added on branch jruoho-x86intr on 2011-06-06 09:06:50 +0000
 1.10.6.1 05-Apr-2012  mrg sync to latest -current.
 1.10.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.10.2.2 30-Oct-2012  yamt sync with head
 1.10.2.1 17-Apr-2012  yamt sync with head
 1.11.2.4 03-Dec-2017  jdolecek update from HEAD
 1.11.2.3 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.11.2.2 23-Jun-2013  tls resync from head
 1.11.2.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.14.2.1 28-Aug-2013  rmind sync with head
 1.15.6.3 05-Dec-2016  skrll Sync with HEAD
 1.15.6.2 29-May-2016  skrll Sync with HEAD
 1.15.6.1 27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.17.2.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.18.16.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.18.16.1 10-Jun-2019  christos Sync with HEAD
 1.20.8.1 03-Apr-2021  thorpej Sync with HEAD.
 1.22.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.23.4.1 31-May-2021  cjep sync with head
 1.23.2.1 13-May-2021  thorpej Sync with HEAD.
 1.24.4.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.3 03-Jun-2011  christos branches: 1.3.2;
CFATTACH_DECL_NEW
 1.2 15-Mar-2011  mrg branches: 1.2.2; 1.2.4;
initial port of these drivers to netbsd. both pyro(4) and ebus(4) at
mainbus depend upon other as-yet uncommited changes.
 1.1 15-Mar-2011  mrg branches: 1.1.1;
Initial revision
 1.1.1.1 15-Mar-2011  mrg import the openbsd pyro and ebus_mainbus drivers for base reference.
 1.2.4.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.2.2.3 12-Jun-2011  rmind sync with head
 1.2.2.2 21-Apr-2011  rmind sync with head
 1.2.2.1 15-Mar-2011  rmind file pyrovar.h was added on branch rmind-uvmplock on 2011-04-21 01:41:27 +0000
 1.3.2.2 06-Jun-2011  jruoho Sync with HEAD.
 1.3.2.1 03-Jun-2011  jruoho file pyrovar.h was added on branch jruoho-x86intr on 2011-06-06 09:06:50 +0000
 1.2 13-Apr-1999  ad Fonts for rcons are now handled in sys/dev/wsfont.
 1.1 20-Jun-1998  eeh branches: 1.1.1;
Initial revision
 1.1.1.1 20-Jun-1998  eeh branches: 1.1.1.1.10;
Import of sparc64.
 1.1.1.1.10.1 21-Jun-1999  thorpej Sync w/ -current.
 1.9 27-Jun-2023  andvar remove double/tripple o in comments, where it likely was not added on purpose.
 1.8 01-Jul-2011  dyoung #include <sys/bus.h> instead of <machine/bus.h>.
 1.7 11-Mar-2010  mrg various aprint_* fixes.
 1.6 14-Dec-2008  mrg branches: 1.6.4;
no need for this to use BUS_SPACE_MAP_LINEAR - it uses bus_space properly
 1.5 29-Mar-2008  tsutsui branches: 1.5.4; 1.5.12;
Don't forget to initialize sc_dev.
 1.4 28-Mar-2008  tsutsui Split device_t and softc for MI mc146818 clock,
and other related misc cosmetics.
 1.3 10-Jan-2008  tsutsui branches: 1.3.6;
Move todr_attach(9) calls from each MD attachment to MI mc146818_attach().
 1.2 09-Nov-2006  tsutsui branches: 1.2.2; 1.2.6; 1.2.32; 1.2.38; 1.2.46;
More cleanup of sparc64 clock stuff:
- split mkclock attachment from sparc64/clock.c into dev/mkclock.c
(now clock.s only contains clock interrupt and timecounter stuff)
- rename match/attach functions of rtc at ebus to match the device name
- update some comments around clock devices in GENERIC

No objection on port-sparc64 for a month.
 1.1 09-Oct-2006  mrg branches: 1.1.2;
avoid bringing in mc146818 routines for kernels that do not have the
'rtc'-style clock linked in. put the rtc code in it's own file and
only link it in if it is actually configured. fixes PR#23342.
 1.1.2.3 10-Dec-2006  yamt sync with head.
 1.1.2.2 22-Oct-2006  yamt sync with head
 1.1.2.1 09-Oct-2006  yamt file rtc.c was added on branch yamt-splraiseipl on 2006-10-22 06:05:11 +0000
 1.2.46.1 10-Jan-2008  bouyer Sync with HEAD
 1.2.38.1 18-Feb-2008  mjf Sync with HEAD.
 1.2.32.1 23-Mar-2008  matt sync with HEAD
 1.2.6.3 21-Jan-2008  yamt sync with head
 1.2.6.2 30-Dec-2006  yamt sync with head.
 1.2.6.1 09-Nov-2006  yamt file rtc.c was added on branch yamt-lazymbuf on 2006-12-30 20:47:02 +0000
 1.2.2.2 18-Nov-2006  ad Sync with head.
 1.2.2.1 09-Nov-2006  ad file rtc.c was added on branch newlock2 on 2006-11-18 21:29:32 +0000
 1.3.6.2 17-Jan-2009  mjf Sync with HEAD.
 1.3.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.5.12.1 19-Jan-2009  skrll Sync with HEAD.
 1.5.4.2 11-Aug-2010  yamt sync with head.
 1.5.4.1 04-May-2009  yamt sync with head.
 1.6.4.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.58 26-Oct-2022  riastradh sparc64/sab(4): Convert to ttylock/ttyunlock.
 1.57 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.56 24-Apr-2021  thorpej branches: 1.56.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.55 31-Oct-2017  martin branches: 1.55.18;
As discussed on tech-kern: define a new tty internal state flag: TS_KERN_ONLY

Implement it in a few tty drivers. If this flag is set, the underlying
hardware is used by another driver and userland has no right to open
it. A few uses will appear soon in sys/dev/sun/sun{kbd,ms}.c.
 1.54 15-Nov-2014  christos branches: 1.54.12;
centralize the call unit / dialout macros
 1.53 01-Nov-2014  nakayama Convert sab_shutdown from deprecated shutdownhook_establish(9) API
to PMF(9) framework.

Tested on Ultra 60 with serial console.
 1.52 25-Jul-2014  dholland branches: 1.52.2;
Add d_discard to all struct cdevsw instances I could find.

All have been set to "nodiscard"; some should get a real implementation.
 1.51 16-Mar-2014  dholland branches: 1.51.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.50 15-Sep-2013  martin Remove unused variable
 1.49 03-Oct-2012  mlelstv branches: 1.49.2;
Only initialize when we are the first opener.
 1.48 02-Jun-2011  christos branches: 1.48.2; 1.48.12;
split auxio, ebus, psycho, sab.
 1.47 24-May-2011  mrg branches: 1.47.2;
also match the fujitsu sab: "FJSV,se" (from openbsd, pointed out by jdc)
 1.46 24-Apr-2011  rmind Rename ttymalloc() to tty_alloc(), and ttyfree() to tty_free() for
consistency. Remove some unnecessary malloc.h inclusions as well.
 1.45 11-Mar-2010  mrg branches: 1.45.2; 1.45.4;
various aprint_* fixes.
 1.44 18-Jan-2010  jdc branches: 1.44.2;
Re-do the previous check for the RSC console:
Do the check in sabtty_console_flags() and set a flag if we are an RSC port.
If we are an RSC port, note that the baud rate is 115200, but don't write a
new value to the baud rate generator register, as this stops the console
working.
 1.43 30-Dec-2009  jdc Check for "ssp-console" and "ssp-control" properties.
If we find them, set the baud rate to 115200.
This allows the RSC to be the console on an E250:

sab1 at ebus0 addr 200000-20007f ipl 35: rev 3.2
sabtty2 at sab1 port 0: console i/o
sabtty3 at sab1 port 1

XXX; We should really check the baud rate properties and use those to set
our rates.
 1.42 11-Jun-2008  cegger branches: 1.42.6; 1.42.14;
use device_lookup_private to get softc
fixes build errors about pointer type mismatches in assignment
 1.41 25-May-2008  ad branches: 1.41.2;
Properly fix the "hanging in tty" bug that was worked around with cv_wakeup()
some time again.
 1.40 28-Nov-2007  ad branches: 1.40.14; 1.40.16; 1.40.18; 1.40.20;
Use the softint API.
 1.39 19-Nov-2007  ad - Factor out too many copies of the same bit of tty code.
- Fix another tty signalling/wakeup problem.
 1.38 07-Nov-2007  ad Merge tty changes from the vmlocking branch.
 1.37 04-Mar-2007  christos branches: 1.37.2; 1.37.18; 1.37.20; 1.37.24; 1.37.26;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.36 19-Oct-2006  martin branches: 1.36.4;
kgdb support for sabtty
 1.35 01-Oct-2006  elad More from Matt Fleming:

Adapt to KAUTH_DEVICE_TTY_PRIVSET and KAUTH_DEVICE_TTY_OPEN.
 1.34 01-Oct-2006  elad Adapt MD code to KAUTH_DEVICE_TTY_OPEN. Patch from Matt Fleming, thanks!
 1.33 01-Oct-2006  martin When setting parameters, we should not only calculate the settings but
better write them back to the chip.
 1.32 01-Oct-2006  martin Use device_xname() accessor
 1.31 28-Jul-2006  hannken branches: 1.31.4; 1.31.6;
Remove 'unused variable p'.
 1.30 23-Jul-2006  ad Use the LWP cached credentials where sane.
 1.29 22-May-2006  christos void casts.
 1.28 14-May-2006  elad branches: 1.28.2;
integrate kauth.
 1.27 18-Apr-2006  martin Invert carrier detect sense, from Jonathan A. Kollasch
 1.26 28-Mar-2006  thorpej Use device_unit().
 1.25 13-Feb-2006  cdi branches: 1.25.2; 1.25.4; 1.25.6;
ANSIfy: u_intN_t -> uintN_t, remove __P(), fix function definitions.
 1.24 11-Dec-2005  christos branches: 1.24.2; 1.24.4; 1.24.6;
merge ktrace-lwp.
 1.23 26-Aug-2005  drochner kill some more simple submatch() functions, use config_stdsubmatch()
 1.22 25-Aug-2005  drochner replace the "locdesc_t" structure carrying the number of locators
explicitely by a plain integer array
the length in now known to all relevant parties, so this avoids
duplication of information, and we can allocate that thing in
drivers without hacks
 1.21 31-May-2005  christos branches: 1.21.2;
- sprinkle const
- avoid variable shadow
 1.20 13-Sep-2004  drochner clean up the questionable use of sabtty_match() as submatch function
(with no useful contents), and implement a real submatch function instead
 1.19 19-Jul-2004  heas If we are serial console, insert a delay just after switching from prom
i/o functions to talking to the sab directly, allowing any residual prom
output to drain. There does not appear to be a prom "flush" function.

Adresses PR 26226.
 1.18 17-Jul-2004  heas Use aprint_normal consistently.
 1.17 10-Jun-2004  seb Add cnmagic(9) support: previously only <Break> was supported to break
into the debugger or ROM monitor from the console.
Note that <Break> is still the default.

Thanks to martin@ for testing.
Approved by petrov@.
 1.16 21-Mar-2004  pk Use the promlib I/O routines.
 1.15 17-Mar-2004  pk Rename PROM_getprop*() => prom_getprop*().
 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  martin Passing struct lwp * instead of struct proc * to device functions.
 1.11 13-Jun-2003  petrov Pick up from OpenBSD:
The sab driver sometimes gets out of sync with the hardware. This can
cause the serial console to hang.
 1.10 11-Jun-2003  petrov Use cdevsw_lookup_major.
 1.9 01-Jan-2003  thorpej Use aprint_normal() for cfprint routines.
 1.8 10-Dec-2002  pk Remove the `flags' argument from bus_intr_establish().
 1.7 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.6 02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.5 01-Oct-2002  thorpej Use CFATTACH_DECL().
 1.4 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.3 21-Sep-2002  petrov Use /options instead of /chosen to find out where console is.
(found by Rafal Boni).
 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 16-Aug-2002  petrov branches: 1.1.2; 1.1.4; 1.1.6;
Port Jason L. Wright's sab82532 driver. From OpenBSD.
 1.1.6.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.6.2 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.1.6.1 16-Aug-2002  jdolecek file sab.c was added on branch kqueue on 2002-09-06 08:41:29 +0000
 1.1.4.4 02-Sep-2002  gehenna machine/conf.h has gone.
 1.1.4.3 31-Aug-2002  gehenna Add character device switch.
 1.1.4.2 31-Aug-2002  gehenna catch up with -current.
 1.1.4.1 16-Aug-2002  gehenna file sab.c was added on branch gehenna-devsw on 2002-08-31 14:52:28 +0000
 1.1.2.7 03-Jan-2003  thorpej Sync with HEAD.
 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 27-Aug-2002  nathanw Catch up to -current.
 1.1.2.1 16-Aug-2002  nathanw file sab.c was added on branch nathanw_sa on 2002-08-27 23:45:49 +0000
 1.13.2.5 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.13.2.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.13.2.3 18-Sep-2004  skrll Sync with HEAD.
 1.13.2.2 26-Aug-2004  skrll Adapt to branch.

sparc64 GENERIC compiles.
 1.13.2.1 03-Aug-2004  skrll Sync with HEAD
 1.21.2.5 07-Dec-2007  yamt sync with head
 1.21.2.4 15-Nov-2007  yamt sync with head.
 1.21.2.3 03-Sep-2007  yamt sync with head.
 1.21.2.2 30-Dec-2006  yamt sync with head.
 1.21.2.1 21-Jun-2006  yamt sync with head.
 1.24.6.2 01-Jun-2006  kardel 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.24.2.1 18-Feb-2006  yamt sync with head.
 1.25.6.2 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.25.6.1 31-Mar-2006  tron Merge 2006-03-31 NetBSD-current into the "peter-altq" branch.
 1.25.4.4 12-May-2006  elad adapt to kauth kpi, include sys/kauth.h where needed..
 1.25.4.3 19-Apr-2006  elad sync with head - hopefully this will work
 1.25.4.2 10-Mar-2006  elad generic_authorize() -> kauth_authorize_generic().
 1.25.4.1 08-Mar-2006  elad Adapt to kernel authorization KPI.

I expect *some* lossage here...
 1.25.2.3 11-Aug-2006  yamt sync with head
 1.25.2.2 24-May-2006  yamt sync with head.
 1.25.2.1 01-Apr-2006  yamt sync with head.
 1.28.2.1 19-Jun-2006  chap Sync with head.
 1.31.6.1 22-Oct-2006  yamt sync with head
 1.31.4.1 18-Nov-2006  ad Sync with head.
 1.36.4.1 12-Mar-2007  rmind Sync with HEAD.
 1.37.26.2 08-Dec-2007  mjf Sync with HEAD.
 1.37.26.1 19-Nov-2007  mjf Sync with HEAD.
 1.37.24.2 21-Nov-2007  bouyer Sync with HEAD
 1.37.24.1 13-Nov-2007  bouyer Sync with HEAD
 1.37.20.2 09-Jan-2008  matt sync with HEAD
 1.37.20.1 08-Nov-2007  matt sync with -HEAD
 1.37.18.3 03-Dec-2007  joerg Sync with HEAD.
 1.37.18.2 21-Nov-2007  joerg Sync with HEAD.
 1.37.18.1 11-Nov-2007  joerg Sync with HEAD.
 1.37.2.1 03-Dec-2007  ad Sync with HEAD.
 1.40.20.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.40.18.3 11-Aug-2010  yamt sync with head.
 1.40.18.2 11-Mar-2010  yamt sync with head
 1.40.18.1 04-May-2009  yamt sync with head.
 1.40.16.2 17-Jun-2008  yamt sync with head.
 1.40.16.1 04-Jun-2008  yamt sync with head
 1.40.14.2 29-Jun-2008  mjf Sync with HEAD.
 1.40.14.1 02-Jun-2008  mjf Sync with HEAD.
 1.41.2.1 18-Jun-2008  simonb Sync with head.
 1.42.14.1 21-Apr-2010  matt sync to netbsd-5
 1.42.6.1 14-Feb-2010  bouyer Pull up following revision(s) (requested by jdc in ticket #1297):
etc/etc.sparc64/MAKEDEV.conf: revision 1.14
sys/arch/sparc64/dev/sab.c: revision 1.43, 1.44
share/man/man4/man4.sparc64/sab.4: revision 1.4
Allow the RSC to be the console on an E250, by checking for RSC-specific
properties, and by not changing the port baud rate.
 1.44.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.45.4.1 06-Jun-2011  jruoho Sync with HEAD.
 1.45.2.2 12-Jun-2011  rmind sync with head
 1.45.2.1 31-May-2011  rmind sync with head
 1.47.2.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.48.12.3 03-Dec-2017  jdolecek update from HEAD
 1.48.12.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.48.12.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.48.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.48.2.1 30-Oct-2012  yamt sync with head
 1.49.2.1 18-May-2014  rmind sync with head
 1.51.2.1 10-Aug-2014  tls Rebase.
 1.52.2.1 07-Nov-2014  snj Pull up following revision(s) (requested by nakayama in ticket #186):
sys/arch/sparc64/dev/sab.c: revision 1.53
Convert sab_shutdown from deprecated shutdownhook_establish(9) API
to PMF(9) framework.
Tested on Ultra 60 with serial console.
 1.54.12.1 06-Nov-2017  snj Pull up following revision(s) (requested by martin in ticket #338):
sys/arch/sparc64/dev/sab.c: revision 1.55
sys/dev/ic/com.c: revision 1.345
sys/dev/ic/z8530tty.c: revision 1.132
sys/dev/sun/sunkbd.c: revision 1.30
sys/dev/sun/sunms.c: revision 1.33
sys/sys/tty.h: revision 1.94
As discussed on tech-kern: define a new tty internal state flag: TS_KERN_ONLY
Implement it in a few tty drivers. If this flag is set, the underlying
hardware is used by another driver and userland has no right to open
it. A few uses will appear soon in sys/dev/sun/sun{kbd,ms}.c.
--
PR port-sparc64/52622: mark the parent device as TS_KERN_ONLY,
so userland will not touch it (and change serial params w/o our
control).
 1.55.18.2 22-Mar-2021  thorpej Audit CFARG_IATTR in config_found() calls, and remove it in situations
where the interface attribute is not ambiguous.
 1.55.18.1 22-Mar-2021  thorpej Mechanical conversion of config_found_sm_loc() -> config_found().
CFARG_IATTR usage needs to be audited.
 1.56.8.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.2 03-May-2003  wiz DMA, not dma nor Dma.
 1.1 16-Aug-2002  petrov branches: 1.1.2; 1.1.4; 1.1.6;
Port Jason L. Wright's sab82532 driver. From OpenBSD.
 1.1.6.2 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.1.6.1 16-Aug-2002  jdolecek file sab82532reg.h was added on branch kqueue on 2002-09-06 08:41:29 +0000
 1.1.4.2 31-Aug-2002  gehenna catch up with -current.
 1.1.4.1 16-Aug-2002  gehenna file sab82532reg.h was added on branch gehenna-devsw on 2002-08-31 14:52:28 +0000
 1.1.2.2 27-Aug-2002  nathanw Catch up to -current.
 1.1.2.1 16-Aug-2002  nathanw file sab82532reg.h was added on branch nathanw_sa on 2002-08-27 23:45:50 +0000
 1.106 02-Dec-2023  thorpej Use vmem_xalloc_addr() to reserve the first Sbus DVMA page.
 1.105 01-Dec-2023  thorpej Use vmem(9) rather than extent(9) to manage DVMA mappings.
 1.104 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.103 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.102 10-May-2021  thorpej branches: 1.102.4;
Associate the OpenBoot / OpenFirmware node with attached devices
at config_found() time.
 1.101 24-Apr-2021  thorpej branches: 1.101.2; 1.101.4;
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.100 04-Jan-2021  thorpej branches: 1.100.2;
malloc(9) -> kmem(9) -- just the simple, straightforward conversions for now.
 1.99 14-Jun-2020  chs branches: 1.99.2;
replace EX_NOWAIT with EX_WAITOK in device attach methods.
remove checks for failures that can no longer occur.
 1.98 01-Jan-2020  thorpej - Introduce a new global kernel variable "shutting_down" to indicate that
the system is shutting down or rebooting.
- Set this global in a new function called kern_reboot(), which is currently
just a basic wrapper around cpu_reboot().
- Call kern_reboot() instead of cpu_reboot() almost everywhere; a few
places remain where it's still called directly, but those are in early
pre-main() machdep locations.

Eventually, all of the various cpu_reboot() functions should be re-factored
and common functionality moved to kern_reboot(), but that's for another day.
 1.97 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.96 10-Nov-2016  macallan branches: 1.96.16;
weed out BUS_SPACE_MAP_PREFETCHABLE in resp. _map() and _mmap() methods
it works with UPA graphics cards and at least some psycho but causes problems
on these
 1.95 07-Jul-2016  msaitoh branches: 1.95.2;
KNF. Remove extra spaces. No functional change.
 1.94 10-May-2016  palle sun4v: make device interrupts work. Introduce a new intrhand_alloc() function for allocation of interrupt handlers and adapt to this. Parts from OpenBSD. ok martin@
 1.93 30-Jan-2012  mrg branches: 1.93.6; 1.93.24;
avoid writing 1 byte beyond the end of the string promlib.c has given us.
instead of forcing a nul byte afterwards, KASSERT() that the final byte
already is a nul. if there are broken proms... well, we can fix them.

this, plus one more change, allows my SS20 to boot multiuser.
 1.92 04-Sep-2011  nakayama branches: 1.92.2; 1.92.6;
ih_pil is an interrupt level, not an interrupt mask.
 1.91 12-Aug-2011  mrg initialise ih_pending
 1.90 29-Jul-2011  mrg port the openbsd central and fhc drivers, and the clock/zs attachments.
doesn't quite work yet, crashes when central_attach() calls
config_attach() (faulting address is 0xf8000000.)
 1.89 20-Jul-2011  macallan add per ivec event counters
 1.88 01-Jul-2011  dyoung #include <sys/bus.h> instead of <machine/bus.h>.
 1.87 16-Mar-2011  mrg revert the iommu changes for now. my U60 doesn't like them.
 1.86 16-Mar-2011  mrg use struct iommureg_old.
 1.85 17-Sep-2009  tsutsui branches: 1.85.6;
Remove struct sbusdev and related functions sbus_establish() and sbusreset().
They are derived from 4.4BSD/sparc and have been there since initial import
of NetBSD/sparc in 1993, but the struct sbusdev is almost unused for years,
nothing calls sbusreset(), and all (*sd->sd_reset)() functions look bogus.

Suggested by mrg@ and martin@, and tested on SS1+ and SS20.
 1.84 17-May-2009  tsutsui Split device_t/softc. Compile test only, but mostly similar changes
with sparc/dev/sbus.c rev 1.69.

XXX: it looks some functions should be merged between sparc and sparc64.
 1.83 18-Oct-2008  nakayama It is wasteful that reconstructing arguments for inserting the pointer
to streaming buffers in each bus_dma functions on sbus/psycho layer.

Use iommu functions directly with storing the pointer into (unused)
_dm_cookie at bus_dmamap_create time.
 1.82 13-Oct-2008  nakayama Remove unnecessary includes.
 1.81 11-Jun-2008  cegger branches: 1.81.2;
use device_lookup_private to get softc
fixes build errors about pointer type mismatches in assignment
 1.80 18-May-2008  martin branches: 1.80.2;
Explicitly pass a "mpsafe" arg down to intr_establish, as at that point
we do not have the original ipl passed in around to check for mpsafeness.
Fixes PR port-sparc64/38673. Thanks to Andrew for pointing at the problem.
 1.79 05-Apr-2008  cegger branches: 1.79.2; 1.79.4; 1.79.6;
use aprint_*_dev and device_xname
OK martin
 1.78 04-Mar-2007  christos branches: 1.78.40;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.77 23-Feb-2006  thorpej branches: 1.77.20;
Use device_parent().
 1.76 13-Feb-2006  cdi ANSIfy: u_intN_t -> uintN_t, remove __P(), fix function definitions.
 1.75 11-Feb-2006  cdi ANSIfication: u_intN_t -> uintN_t, use ANSI function declarations/definitions
instead of K&R ones.
 1.74 01-Feb-2006  martin branches: 1.74.2;
Do not assume the bootstrap CPU has UPA id 0 - on some machines it hasn't.
Explicitly route all interrupts to the current cpu for now, we'll revisit
this when SMP is working.
Problem spotted and analyzed by Stephan Meisinger, fix inspired by FreeBSD.
 1.73 11-Dec-2005  christos branches: 1.73.2; 1.73.4;
merge ktrace-lwp.
 1.72 31-May-2005  christos branches: 1.72.2;
- sprinkle const
- avoid variable shadow
 1.71 04-Dec-2004  chs the arguments to BUS_ADDR() are (space, offset), not the other way around.
fixes PR 26472.
 1.70 28-Jul-2004  pk _sbus_bus_map: check for the existence of `ranges' in the tag before using them.
 1.69 30-Jun-2004  pk sbus_attach: use bus_space_tag_allocate();
sbus_bus_map: use bus_space_translate_generic();
sbus_bus_addr: use BUS_ADDR().
 1.68 21-Mar-2004  martin Make sure prom_getprop is called with the size pointed to by nitem
initialized. (Some of these are more paranoia, but two were actual bugs.)
Print error codes in some panic messages.
 1.67 17-Mar-2004  pk Rename PROM_getprop*() => prom_getprop*().
 1.66 17-Mar-2004  pk Pass the buffer size to PROM_getpropstringA(), as in sparc.
 1.65 09-Nov-2003  martin Nuke bcopy/bzero.
 1.64 26-Oct-2003  christos Fix uninitialized variable warning.
 1.63 11-Oct-2003  petrov When establishing interrupt set CPU_UPAID in mapping register
so that interrupt would be delivered.
 1.62 27-Aug-2003  mrg change PROM_getprop() from taking a "void **" for the storage, to a
"void *", and do the extra de-reference directly in the function. this
avoids having to cast dozens of different types to "void **", which sets
of GCC3's strict-aliasing. testing by martin@
 1.61 15-Jul-2003  lukem __KERNEL_RCSID()
 1.60 17-May-2003  nakayama branches: 1.60.2;
Avoid strict-alias warnings in gcc 3.3.
 1.59 01-Apr-2003  thorpej Use PAGE_SIZE rather than NBPG.
 1.58 01-Jan-2003  thorpej Use aprint_normal() for cfprint routines.
 1.57 10-Dec-2002  pk Remove the `flags' argument from bus_intr_establish().
 1.56 10-Dec-2002  pk bus_intr_establish() signature change.
The additional `fast trap' argument is ignored in these drivers.
BUS_INTR_ESTABLISH_FASTTRAP and BUS_INTR_ESTABLISH_SOFTINTR are no longer used.
 1.55 02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.54 01-Oct-2002  thorpej Use CFATTACH_DECL().
 1.53 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.52 27-Sep-2002  thorpej Rather than referencing the cfdriver directly in the cfdata entries,
instead use a string naming the driver. The cfdriver is then looked
up in a list which is built at run-time.
 1.51 23-Aug-2002  thorpej Use the structures defined in bsd_openprom.h for "reg", "range",
and "intr" properties, rather than having identical-except-for-names
sbus_* and iommu_* versions.
 1.50 20-Jun-2002  eeh Overhaul streaming buffer handling:

sysio streaming buffer flushes write a single 8-byte aligned 8-byte
value.

psycho streaming buffer flushes write a 64-byte aligned 64-byte block.

So separate out the streaming buffers into their own structure and pass those
in to all iommu operations. This also means we only flush the correct
streaming buffer for psycho rather than needing to flush both just in case.
 1.49 21-Mar-2002  eeh branches: 1.49.2; 1.49.4; 1.49.6;
Cleanup.
 1.48 20-Mar-2002  eeh Overhaul bus space.

bus_space_handle_t now holds an address and two ASIs, one for normal accesses
and one for streaming accesses. This allows to map individual handles
different ways, so some can use MMU bypass accesses and others use virtual
addresses. bus_space_map() will now create handles that use bypass accesses
unles BUS_SPACE_MAP_LINEAR is passed in. So only pass in BUS_SPACE_MAP_LINEAR
if you absolutely *need* to use bus_space_vaddr(). This removes at least one
extra level of indirection and should reduce TLB misses.

32-bit kernels have problems accessing 64-bit addresses, so they always use
virtual addresses.
 1.47 14-Mar-2002  eeh bus_space_map2() no longer exists.
 1.46 07-Oct-2001  eeh branches: 1.46.4;
Manage both streaming caches on psycho/psycho+.
 1.45 26-Sep-2001  eeh getprop* -> PROM_getprop*
 1.44 24-Sep-2001  eeh Change bus_space_mmap() signature to the official one.
 1.43 20-Jul-2001  eeh branches: 1.43.2;
PCI overhaul.
 1.42 18-May-2001  mrg branches: 1.42.2;
move the sbus IOMMU work around into the sbus code, so that the psycho
doesn't have to lose a page.
 1.41 16-Mar-2001  hubertf Add comment on what 'overtemp' is about. OK'd by eeh.
 1.40 14-Mar-2001  eeh Handle overtemp intr.
 1.39 06-Dec-2000  mrg branches: 1.39.2;
fix warnings in DEBUG & DIAGNSTIC code.
 1.38 04-Dec-2000  fvdl Avoid (safe) cast warnings.
 1.37 01-Nov-2000  eeh Pass along bus frequency.
 1.36 19-Oct-2000  mrg wrap long lines.
 1.35 09-Jul-2000  pk Add a `device class' interrupt level argument (from machine/intr.h)
to bus_interrupt_establish().

It's currently only used in sparc64/dev/psycho.c to assign a CPU interrupt
level to devices in PCI slots.
 1.34 07-Jul-2000  mrg work around a bug passing arguments to iommu_dvma_load_raw()
 1.33 29-Jun-2000  mrg remove include of <vm/vm.h>. <vm/vm.h> -> <uvm/uvm_extern.h>
 1.32 24-Jun-2000  eeh With these changes the kernel seems almost stable again.
 1.31 24-Jun-2000  eeh Get rid of vaddrs.h.
 1.30 08-Jun-2000  eeh branches: 1.30.2;
Fix ordering of sync operations depending on whether it's PRE- or POST-.
 1.29 17-May-2000  eeh branches: 1.29.2;
Add support for bus_dma_load_raw() so the le driver will work again.
 1.28 22-Apr-2000  mrg whole bunch of changes:
- merge IOMMU DVMA code from sbus/psycho into iommu.c. this code was
identical and a few minor inconsistencies had crept in. this way
keeps them all in sync.
- with this code gone from psycho, merge the psycho.c and psycho_bus.c
files. same with ebus/ebus_bus.c. delete the _bus.c files.
- add a _ds_boundary member to the dma segment structure, so that later
dma mappings can find this value.
- set _ds_boundary in machdep.c:_bus_dmamem_alloc().
- kill much dead code.
 1.27 22-Apr-2000  mrg - convert to DPRINTF() style debug messages.
- kill dead code.
- use the sbus dv_xname to construct a dvma map map, to pass to
extent_alloc(), to help support multiple sbusses
 1.26 10-Apr-2000  pk Get a kernel without DDB to build.
 1.25 08-Apr-2000  mrg - remove unused variable.
- include <sparc64/sparc64/cache.h> to get cache_flush() prototype.
- remove an unnecessary cast.
 1.24 13-Mar-2000  soren Fix doubled 'the's in comments.
 1.23 14-Jan-2000  pk Remove old-style boot device recognition.
 1.22 25-Nov-1999  mrg - pass slot number to sbus_get_intr() as a new argument.
- in sbus_get_intr(), if we are not an onboard device (ie, sbus card),
encode the slot number into the sbi_pri so that we can later extract
it and use it to find the interrupt map & clear registers for this
device.
- remove "intr" support as it is really pre-sun4u only.
- don't "pause" for so long in sbus interrupt debug messages..

with the slot number being passed back from sbus_get_intr(), the FS/BE
card in an ultra2 now appears to get interrupts and gets beyond
waiting for the scsibus probe!
 1.21 13-Nov-1999  thorpej Update for pmap_enter() API change. No functional difference.
 1.20 08-Jul-1999  thorpej branches: 1.20.2; 1.20.4; 1.20.8;
Change the pmap_extract() interface to:
boolean_t pmap_extract(pmap_t, vaddr_t, paddr_t *);
This makes it possible for the pmap to map physical address 0.
 1.19 20-Jun-1999  eeh Move the DVMA mapin/mapout functions from the SBus driver to the iommu driver.
 1.18 07-Jun-1999  eeh Another general cleanup:

Remove the entire idea of fasttrap interrupts since V9 traps are really cheap,
the CPUs are really fast, and the completely different trap frames would make
these handlers really difficult to implement.

pmap_changeprot() was only used by the clock and one other place; deprecate it.

probeget() and probeset() now take 64-bit addresses even in 32-bit mode so we
can probe IO locations by physical addresses.

Some pmap cleanup.

Some more copyright cleanup.
 1.17 05-Jun-1999  mrg use common IOMMU routines.
 1.16 31-May-1999  eeh Garbage collect.
 1.15 30-May-1999  eeh Add code to support using %tick as the system clock if no "counter-timer" node
is found.
 1.14 25-May-1999  thorpej bus_dmamem_map() maps DMA safe memory, which is usually one or more
managed pages, into KVA space. Since the pages are managed, we should
use pmap_enter(), not pmap_kenter_pa().

Also, when entering the mappings, enter with an access_type of
VM_PROT_READ | VM_PROT_WRITE. We do this for a couple of reasons:

(1) On systems that have H/W mod/ref attributes, the hardware
may not be able to track mod/ref done by a bus master.

(2) On systems that have to do mod/ref emulation, this prevents
a mod/ref page fault from potentially happening while in an
interrupt context, which can be problematic.

This latter change is fairly important if we ever want to be able to
transfer DMA-safe memory pages to anonymous memory objects; we will need
to know that the pages are modified, or else data could be lost!

Note that while the pages are unowned (i.e. "just DMA-safe memory pages"),
they won't consume any swap resources, as the mappings are wired, and
the pages aren't on the active or inactive queues.
 1.13 23-May-1999  mrg place iommu definitions in iommureg.h
 1.12 22-May-1999  eeh Well, looks like the MI allocsys() broke the dvmamap, so instead of using a
single map move it to the bus controller driver so each bus can handle its own
IOMMU without conflicts.
 1.11 26-Mar-1999  mycroft branches: 1.11.4;
Changes for modified pmap_enter() API:
* Map the message buffer with access_type = VM_PROT_READ|VM_PROT_WRITE `just
because'.
* Map the file system buffers with access_type = VM_PROT_READ|VM_PROT_WRITE to
avoid possible problems with pagemove().
* Do not use VM_PROT_EXEC with either of the above.
* Map pages for /dev/mem with access_type = prot. Also, DO NOT use
pmap_kenter() for this, as we DO NOT want to lose modification information.
* Map pages in dumpsys() with VM_PROT_READ.
* Map pages in m68k mappedcopyin()/mappedcopyout() and writeback() with
access_type = prot.
* For now, bus_dma*(), pmap_map(), vmapbuf(), and similar functions still use
access_type = 0. This should probably be revisited.
 1.10 18-Mar-1999  eeh Some devices don't have a `device-type' property we can use to allocate
an IPL. Check for those by name. Give the rest a default IPL of 2.
(Added `SUNW,CS4231' to the list.)
 1.9 10-Jan-1999  eeh Need to put IGN in SBUS slot interrupt vectors as well. (From Kapil Chowksey)
 1.8 05-Sep-1998  eeh It slices. It dices. It does everything except exec a sparc32_compat init.
 1.7 05-Sep-1998  pk #include <dev/sbus/sbusvar.h>
 1.6 05-Sep-1998  pk Nuke temporary `getpropA()'.
 1.5 02-Sep-1998  eeh Periodic update: now starts probing devices.
 1.4 30-Aug-1998  eeh Some more 64-bit cleanup. Now everything compiles.
 1.3 13-Aug-1998  eeh Merge paddr_t changes into the main branch.
 1.2 07-Jul-1998  eeh branches: 1.2.2;
General update:

Added genassym.cf
Removed lderr which should never have gotten in
Removed lots of dead code from locore.s
Added some softint stuff to intr.c
Added support for halt -p
esp and le both use bus_dmamap_*() functions now
instead of kdvma_mapin()
groundwork for PCI (but we still have no drivers for
any sun4u PCI devices)
 1.1 20-Jun-1998  eeh branches: 1.1.1;
Initial revision
 1.1.1.1 20-Jun-1998  eeh Import of sparc64.
 1.2.2.2 02-Aug-1998  eeh Cleanup work:

Sync up with sys/dev/sbus
get cgsix to work right
 1.2.2.1 30-Jul-1998  eeh Split vm_offset_t and vm_size_t into paddr_t, psize_t, vaddr_t, and vsize_t.
 1.11.4.2 02-Aug-1999  thorpej Update from trunk.
 1.11.4.1 21-Jun-1999  thorpej Sync w/ -current.
 1.20.8.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.20.4.1 15-Nov-1999  fvdl Sync with -current
 1.20.2.4 27-Mar-2001  bouyer Sync with HEAD.
 1.20.2.3 08-Dec-2000  bouyer Sync with HEAD.
 1.20.2.2 22-Nov-2000  bouyer Sync with HEAD.
 1.20.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.29.2.1 22-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.30.2.1 18-Jul-2000  mrg pullup the contents of -current arch/sparc64. this gives us significant
ultrasparc PCI support (ultra5, ultra10, AXi, and E250 tested so far),
plus many other small fixes. netbooting is now supported.
 1.39.2.2 21-Jun-2001  nathanw Catch up to -current.
 1.39.2.1 09-Apr-2001  nathanw Catch up with -current.
 1.42.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.42.2.4 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.42.2.3 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.42.2.2 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.42.2.1 03-Aug-2001  lukem update to -current
 1.43.2.2 11-Oct-2001  fvdl Catch up with -current. Fix some bogons in the sparc64 kbd/ms
attach code. cd18xx conversion provided by mrg.
 1.43.2.1 01-Oct-2001  fvdl Catch up with -current.
 1.46.4.7 03-Jan-2003  thorpej Sync with HEAD.
 1.46.4.6 11-Dec-2002  thorpej Sync with HEAD.
 1.46.4.5 18-Oct-2002  nathanw Catch up to -current.
 1.46.4.4 27-Aug-2002  nathanw Catch up to -current.
 1.46.4.3 01-Aug-2002  nathanw Catch up to -current.
 1.46.4.2 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.46.4.1 07-Oct-2001  nathanw file sbus.c was added on branch nathanw_sa on 2002-04-01 07:43:05 +0000
 1.49.6.2 22-Nov-2002  tron Pull up revision 1.51 (requested by martin in ticket #948):
Use the structures defined in bsd_openprom.h for "reg", "range",
and "intr" properties, rather than having identical-except-for-names
sbus_* and iommu_* versions.
 1.49.6.1 21-Jun-2002  lukem Pull up revision 1.50 (requested by eeh in ticket #337):
Overhaul streaming buffer handling:
sysio streaming buffer flushes write a single 8-byte aligned 8-byte
value.
psycho streaming buffer flushes write a 64-byte aligned 64-byte block.
So separate out the streaming buffers into their own structure and pass those
in to all iommu operations. This also means we only flush the correct
streaming buffer for psycho rather than needing to flush both just in case.
[Gets E220R working]
 1.49.4.2 31-Aug-2002  gehenna catch up with -current.
 1.49.4.1 17-Jul-2002  gehenna catch up with -current.
 1.49.2.2 06-Apr-2002  eeh Use DEV_PRIVATE() and distinguish between the softc and the device struct.
 1.49.2.1 26-Mar-2002  eeh Support probing and attaching with device properties too.
 1.60.2.5 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.60.2.4 18-Dec-2004  skrll Sync with HEAD.
 1.60.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.60.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.60.2.1 03-Aug-2004  skrll Sync with HEAD
 1.72.2.2 03-Sep-2007  yamt sync with head.
 1.72.2.1 21-Jun-2006  yamt sync with head.
 1.73.4.1 09-Sep-2006  rpaulo sync with head
 1.73.2.2 01-Mar-2006  yamt sync with head.
 1.73.2.1 18-Feb-2006  yamt sync with head.
 1.74.2.1 22-Apr-2006  simonb Sync with head.
 1.77.20.1 12-Mar-2007  rmind Sync with HEAD.
 1.78.40.3 17-Jan-2009  mjf Sync with HEAD.
 1.78.40.2 29-Jun-2008  mjf Sync with HEAD.
 1.78.40.1 02-Jun-2008  mjf Sync with HEAD.
 1.79.6.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.79.4.3 11-Mar-2010  yamt sync with head
 1.79.4.2 20-Jun-2009  yamt sync with head
 1.79.4.1 04-May-2009  yamt sync with head.
 1.79.2.2 17-Jun-2008  yamt sync with head.
 1.79.2.1 04-Jun-2008  yamt sync with head
 1.80.2.1 18-Jun-2008  simonb Sync with head.
 1.81.2.1 19-Oct-2008  haad Sync with HEAD.
 1.85.6.1 06-Jun-2011  jruoho Sync with HEAD.
 1.92.6.1 18-Feb-2012  mrg merge to -current.
 1.92.2.1 17-Apr-2012  yamt sync with head
 1.93.24.3 05-Dec-2016  skrll Sync with HEAD
 1.93.24.2 09-Jul-2016  skrll Sync with HEAD
 1.93.24.1 29-May-2016  skrll Sync with HEAD
 1.93.6.1 03-Dec-2017  jdolecek update from HEAD
 1.95.2.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.96.16.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.96.16.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.99.2.1 03-Apr-2021  thorpej Sync with HEAD.
 1.100.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.101.4.1 31-May-2021  cjep sync with head
 1.101.2.1 13-May-2021  thorpej Sync with HEAD.
 1.102.4.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.10 16-Mar-2011  mrg revert the iommu changes for now. my U60 doesn't like them.
 1.9 16-Mar-2011  mrg use struct iommureg_old.
 1.8 13-Feb-2006  cdi branches: 1.8.100;
ANSIfy: u_intN_t -> uintN_t, remove __P(), fix function definitions.
 1.7 07-Jun-1999  eeh branches: 1.7.52; 1.7.64; 1.7.66; 1.7.68;
Another general cleanup:

Remove the entire idea of fasttrap interrupts since V9 traps are really cheap,
the CPUs are really fast, and the completely different trap frames would make
these handlers really difficult to implement.

pmap_changeprot() was only used by the clock and one other place; deprecate it.

probeget() and probeset() now take 64-bit addresses even in 32-bit mode so we
can probe IO locations by physical addresses.

Some pmap cleanup.

Some more copyright cleanup.
 1.6 24-May-1999  mrg pull struct strbuf + defines into iommureg.h. properly merge previous commit.
 1.5 23-May-1999  mrg place iommu definitions in iommureg.h
 1.4 22-May-1999  eeh Well, looks like the MI allocsys() broke the dvmamap, so instead of using a
single map move it to the bus controller driver so each bus can handle its own
IOMMU without conflicts.
 1.3 05-Sep-1998  eeh branches: 1.3.8;
It slices. It dices. It does everything except exec a sparc32_compat init.
 1.2 13-Aug-1998  eeh Merge paddr_t changes into the main branch.
 1.1 20-Jun-1998  eeh branches: 1.1.1;
Initial revision
 1.1.1.1 20-Jun-1998  eeh branches: 1.1.1.1.2;
Import of sparc64.
 1.1.1.1.2.2 02-Aug-1998  eeh Cleanup work:

Sync up with sys/dev/sbus
get cgsix to work right
 1.1.1.1.2.1 30-Jul-1998  eeh Split vm_offset_t and vm_size_t into paddr_t, psize_t, vaddr_t, and vsize_t.
 1.3.8.1 21-Jun-1999  thorpej Sync w/ -current.
 1.7.68.1 22-Apr-2006  simonb Sync with head.
 1.7.66.1 09-Sep-2006  rpaulo sync with head
 1.7.64.1 18-Feb-2006  yamt sync with head.
 1.7.52.1 21-Jun-2006  yamt sync with head.
 1.8.100.1 06-Jun-2011  jruoho Sync with HEAD.
 1.18 01-Jul-2011  dyoung #include <sys/bus.h> instead of <machine/bus.h>.
 1.17 17-Sep-2009  tsutsui Remove struct sbusdev and related functions sbus_establish() and sbusreset().
They are derived from 4.4BSD/sparc and have been there since initial import
of NetBSD/sparc in 1993, but the struct sbusdev is almost unused for years,
nothing calls sbusreset(), and all (*sd->sd_reset)() functions look bogus.

Suggested by mrg@ and martin@, and tested on SS1+ and SS20.
 1.16 17-May-2009  tsutsui Split device_t/softc. Compile test only, but mostly similar changes
with sparc/dev/sbus.c rev 1.69.

XXX: it looks some functions should be merged between sparc and sparc64.
 1.15 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.14 11-Dec-2005  christos branches: 1.14.74; 1.14.76; 1.14.78;
merge ktrace-lwp.
 1.13 30-Jun-2004  pk sbus_attach: use bus_space_tag_allocate();
sbus_bus_map: use bus_space_translate_generic();
sbus_bus_addr: use BUS_ADDR().
 1.12 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.11 23-Aug-2002  thorpej branches: 1.11.6;
Use the structures defined in bsd_openprom.h for "reg", "range",
and "intr" properties, rather than having identical-except-for-names
sbus_* and iommu_* versions.
 1.10 20-Jun-2002  eeh Overhaul streaming buffer handling:

sysio streaming buffer flushes write a single 8-byte aligned 8-byte
value.

psycho streaming buffer flushes write a 64-byte aligned 64-byte block.

So separate out the streaming buffers into their own structure and pass those
in to all iommu operations. This also means we only flush the correct
streaming buffer for psycho rather than needing to flush both just in case.
 1.9 21-Mar-2002  eeh branches: 1.9.4; 1.9.6;
Cleanup.
 1.8 20-Mar-2002  eeh Add sbus_promaddr_to_handle() to convert a prom address to a bus_space_handle_t.
 1.7 05-Jun-1999  mrg branches: 1.7.16; 1.7.20;
use common IOMMU routines.
 1.6 22-May-1999  eeh Well, looks like the MI allocsys() broke the dvmamap, so instead of using a
single map move it to the bus controller driver so each bus can handle its own
IOMMU without conflicts.
 1.5 05-Sep-1998  eeh branches: 1.5.8;
It slices. It dices. It does everything except exec a sparc32_compat init.
 1.4 05-Sep-1998  pk Most of this now comes from <sys/dev/sbus/sbusvar.h>
 1.3 02-Sep-1998  eeh Periodic update: now starts probing devices.
 1.2 13-Aug-1998  eeh Merge paddr_t changes into the main branch.
 1.1 20-Jun-1998  eeh branches: 1.1.1;
Initial revision
 1.1.1.1 20-Jun-1998  eeh branches: 1.1.1.1.2;
Import of sparc64.
 1.1.1.1.2.2 02-Aug-1998  eeh Cleanup work:

Sync up with sys/dev/sbus
get cgsix to work right
 1.1.1.1.2.1 30-Jul-1998  eeh Split vm_offset_t and vm_size_t into paddr_t, psize_t, vaddr_t, and vsize_t.
 1.5.8.1 21-Jun-1999  thorpej Sync w/ -current.
 1.7.20.3 27-Aug-2002  nathanw Catch up to -current.
 1.7.20.2 01-Aug-2002  nathanw Catch up to -current.
 1.7.20.1 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.7.16.2 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.7.16.1 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.9.6.2 22-Nov-2002  tron Pull up revision 1.11 (requested by martin in ticket #948):
Use the structures defined in bsd_openprom.h for "reg", "range",
and "intr" properties, rather than having identical-except-for-names
sbus_* and iommu_* versions.
 1.9.6.1 21-Jun-2002  lukem Pull up revision 1.10 (requested by eeh in ticket #337):
Overhaul streaming buffer handling:
sysio streaming buffer flushes write a single 8-byte aligned 8-byte
value.
psycho streaming buffer flushes write a 64-byte aligned 64-byte block.
So separate out the streaming buffers into their own structure and pass those
in to all iommu operations. This also means we only flush the correct
streaming buffer for psycho rather than needing to flush both just in case.
[Gets E220R working]
 1.9.4.2 31-Aug-2002  gehenna catch up with -current.
 1.9.4.1 17-Jul-2002  gehenna catch up with -current.
 1.11.6.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.11.6.2 18-Sep-2004  skrll Sync with HEAD.
 1.11.6.1 03-Aug-2004  skrll Sync with HEAD
 1.14.78.3 11-Mar-2010  yamt sync with head
 1.14.78.2 20-Jun-2009  yamt sync with head
 1.14.78.1 16-May-2008  yamt sync with head.
 1.14.76.1 18-May-2008  yamt sync with head.
 1.14.74.1 02-Jun-2008  mjf Sync with HEAD.
 1.47 21-Jan-2022  thorpej Don't bother with prom_node_to_devhandle() if we're just forwarding along
our own node; use device_handle(self) instead.
 1.46 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.45 10-May-2021  thorpej branches: 1.45.4;
Associate the OpenBoot / OpenFirmware node with attached devices
at config_found() time.
 1.44 24-Apr-2021  thorpej branches: 1.44.2; 1.44.4;
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.43 17-Jan-2021  mrg branches: 1.43.2;
reduce the scope of 'ci' variable.
 1.42 01-Oct-2019  chs branches: 1.42.8;
in many device attach paths, allocate memory with KM_SLEEP instead of KM_NOSLEEP
and remove code to handle failures that can no longer happen.
 1.41 09-Feb-2019  mrg on tomatillo unload the map before flushing the iommu, instead of
the reverse. from opensolaris.
 1.40 05-Feb-2019  mrg add or avoid fallthru comments.
 1.39 03-Jun-2017  mrg branches: 1.39.10;
add __func__ to some panic strings.
 1.38 26-Mar-2017  martin Reorder attach slightly to avoid unintialized use of OF nodes.
 1.37 10-Nov-2016  macallan branches: 1.37.2;
weed out BUS_SPACE_MAP_PREFETCHABLE in resp. _map() and _mmap() methods
it works with UPA graphics cards and at least some psycho but causes problems
on these
 1.36 10-May-2016  palle branches: 1.36.2;
sun4v: make device interrupts work. Introduce a new intrhand_alloc() function for allocation of interrupt handlers and adapt to this. Parts from OpenBSD. ok martin@
 1.35 27-Nov-2015  martin Use __BIT() for some masks to fix the sparc build.
No binary changes.
 1.34 23-Nov-2015  jdc Set the target JPID for all interrupts on Tomatillo.
If the "ino-bitmap" property is available, use it to route error interrupts.
Minor cosmetic changes.
Add register printing when DEBUG is defined.
 1.33 02-Oct-2015  msaitoh PCI Extended Configuration stuff written by nonaka@:
- Add PCI Extended Configuration Space support into x86.
- Check register offset of pci_conf_read() in MD part. It returns (pcireg_t)-1
if it isn't accessible.
- Decode Extended Capability in PCI Extended Configuration Space.
Currently the following extended capabilities are decoded:
- Advanced Error Reporting
- Virtual Channel
- Device Serial Number
- Power Budgeting
- Root Complex Link Declaration
- Root Complex Event Collector Association
- Access Control Services
- Alternative Routing-ID Interpretation
- Address Translation Services
- Single Root IO Virtualization
- Page Request
- TPH Requester
- Latency Tolerance Reporting
- Secondary PCI Express
- Process Address Space ID
- LN Requester
- L1 PM Substates
The following extended capabilities are not decoded yet:
- Root Complex Internal Link Control
- Multi-Function Virtual Channel
- RCRB Header
- Vendor Unique
- Configuration Access Correction
- Multiple Root IO Virtualization
- Multicast
- Resizable BAR
- Dynamic Power Allocation
- Protocol Multiplexing
- Downstream Port Containment
- Precision Time Management
- M-PCIe
- Function Reading Status Queueing
- Readiness Time Reporting
- Designated Vendor-Specific
 1.32 21-Sep-2014  christos branches: 1.32.2;
fix leak
 1.31 21-Jun-2013  nakayama branches: 1.31.8;
Avoid data_access_error trap panic when reading unused PCI
configuration space.

This method is described in UltraSPARC IIi User's Manual "16.2.1
Probing PCI during boot using deferred errors", and refer to the
implementation of OpenBSD.
 1.30 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.29 25-Mar-2012  mrg branches: 1.29.2;
- save the "version#" in the softc, we will want it later
- enable some more things in the schizo CSR:
- tomatillo: DMA arbitration enable:
- tomatillo: prefetch read multiple / one / line
- schizo: enable parking unless "no-bus-parking" is set
- schizo: enable streaming buffer interrupts
- schizo: enable bus arbitration for schizo, not these reseved
bits for tomatillo

partly from and entirely inspired by freebsd schizo_attach().
 1.28 18-Mar-2012  mrg add missing __KERNEL_RCSID().
 1.27 04-Sep-2011  nakayama branches: 1.27.2; 1.27.6;
ih_pil is an interrupt level, not an interrupt mask.
 1.26 12-Aug-2011  mrg initialise ih_pending
 1.25 20-Jul-2011  macallan add per ivec event counters
 1.24 20-Jul-2011  macallan some malloc() -> kmem_alloc()
 1.23 01-Jul-2011  dyoung #include <sys/bus.h> instead of <machine/bus.h>.
 1.22 03-Jun-2011  christos forgot the _NEW part
 1.21 03-Jun-2011  christos CFATTACH_DECL_NEW
 1.20 17-May-2011  dyoung branches: 1.20.2;
PCI_FLAGS_IO_ENABLED and PCI_FLAGS_MEM_ENABLED changed their functional
role in NetBSD (drivers are no longer supposed to write these to
pa_flags) without changing name. Correct that.

Rename PCI_FLAGS_IO_ENABLED to PCI_FLAGS_IO_OKAY and
PCI_FLAGS_MEM_ENABLED to PCI_FLAGS_MEM_OKAY, thus making their names
consistent with the other PCI flags and poisoning 3rd-party driver
sources that use the flags in the old bad way.

This patch produces no binary changes in this set of PCI kernels when
they are compiled w/o 'options DIAGNOSTIC' and w/ -V MKREPRO=yes:

algor P4032 P5064 P6032
alpha GENERIC
amd64 GENERIC XEN3_DOM0
arc GENERIC
atari HADES MILAN-PCIIDE
bebox GENERIC
cats GENERIC
cobalt GENERIC
evbarm-el ADI_BRH ARMADILLO9 CP3100 GEMINI GEMINI_MASTER GEMINI_SLAVE
evbarm-el GUMSTIX HDL_G IMX31LITE INTEGRATOR IQ31244 IQ80310 IQ80321
evbarm-el IXDP425 IXM1200 KUROBOX_PRO
evbarm-el LUBBOCK MARVELL_NAS NAPPI NSLU2 SHEEVAPLUG SMDK2800 TEAMASA_NPWR
evbarm-el TEAMASA_NPWR_FC TS7200 TWINTAIL ZAO425
evbmips-el AP30 DBAU1500 DBAU1550 MALTA MERAKI MTX-1 OMSAL400 RB153 WGT624V3
evbmips64-el XLSATX
evbppc EV64260 MPC8536DS MPC8548CDS OPENBLOCKS200 OPENBLOCKS266
evbppc OPENBLOCKS266_OPT P2020RDB PMPPC RB800 WALNUT
hp700 GENERIC
i386 ALL XEN3_DOM0 XEN3_DOMU
ibmnws GENERIC
iyonix GENERIC
landisk GENERIC
macppc GENERIC
mvmeppc GENERIC
netwinder GENERIC
ofppc GENERIC
prep GENERIC
sandpoint GENERIC
sbmips-el GENERIC
sgimips GENERIC32_IP2x GENERIC32_IP3x
sparc GENERIC_SUN4U KRUPS
sparc64 GENERIC
 1.19 04-Apr-2011  dyoung Neither pci_dma64_available(), pci_probe_device(), pci_mapreg_map(9),
pci_find_rom(), pci_intr_map(9), pci_enumerate_bus(), nor the match
predicate passed to pciide_compat_intr_establish() should ever modify
their pci_attach_args argument, so make their pci_attach_args arguments
const and deal with the fallout throughout the kernel.

For the most part, these changes add a 'const' where there was no
'const' before, however, some drivers and MD code used to modify
pci_attach_args. Now those drivers either copy their pci_attach_args
and modify the copy, or refrain from modifying pci_attach_args:

Xen: according to Manuel Bouyer, writing to pci_attach_args in
pci_intr_map() was a leftover from Xen 2. Probably a bug. I
stopped writing it. I have not tested this change.

siside(4): sis_hostbr_match() needlessly wrote to pci_attach_args.
Probably a bug. I use a temporary variable. I have not tested this
change.

slide(4): sl82c105_chip_map() overwrote the caller's pci_attach_args.
Probably a bug. Use a local pci_attach_args. I have not tested
this change.

viaide(4): via_sata_chip_map() and via_sata_chip_map_new() overwrote the
caller's pci_attach_args. Probably a bug. Make a local copy of the
caller's pci_attach_args and modify the copy. I have not tested
this change.

While I'm here, make pci_mapreg_submap() static.

With these changes in place, I have tested the compilation of these
kernels:

alpha GENERIC
amd64 GENERIC XEN3_DOM0
arc GENERIC
atari HADES MILAN-PCIIDE
bebox GENERIC
cats GENERIC
cobalt GENERIC
evbarm-eb NSLU2
evbarm-el ADI_BRH ARMADILLO9 CP3100 GEMINI GEMINI_MASTER GEMINI_SLAVE GUMSTIX
HDL_G IMX31LITE INTEGRATOR IQ31244 IQ80310 IQ80321 IXDP425 IXM1200
KUROBOX_PRO LUBBOCK MARVELL_NAS NAPPI SHEEVAPLUG SMDK2800 TEAMASA_NPWR
TEAMASA_NPWR_FC TS7200 TWINTAIL ZAO425
evbmips-el AP30 DBAU1500 DBAU1550 MALTA MERAKI MTX-1 OMSAL400 RB153 WGT624V3
evbmips64-el XLSATX
evbppc EV64260 MPC8536DS MPC8548CDS OPENBLOCKS200 OPENBLOCKS266
OPENBLOCKS266_OPT P2020RDB PMPPC RB800 WALNUT
hp700 GENERIC
i386 ALL XEN3_DOM0 XEN3_DOMU
ibmnws GENERIC
macppc GENERIC
mvmeppc GENERIC
netwinder GENERIC
ofppc GENERIC
prep GENERIC
sandpoint GENERIC
sgimips GENERIC32_IP2x
sparc GENERIC_SUN4U KRUPS
sparc64 GENERIC

As of Sun Apr 3 15:26:26 CDT 2011, I could not compile these kernels
with or without my patches in place:

### evbmips-el GDIUM

nbmake: nbmake: don't know how to make /home/dyoung/pristine-nbsd/src/sys/arch/mips/mips/softintr.c. Stop

### evbarm-el MPCSA_GENERIC
src/sys/arch/evbarm/conf/MPCSA_GENERIC:318: ds1672rtc*: unknown device `ds1672rtc'

### ia64 GENERIC

/tmp/genassym.28085/assym.c: In function 'f111':
/tmp/genassym.28085/assym.c:67: error: invalid application of 'sizeof' to incomplete type 'struct pcb'
/tmp/genassym.28085/assym.c:76: error: dereferencing pointer to incomplete type

### sgimips GENERIC32_IP3x

crmfb.o: In function `crmfb_attach':
crmfb.c:(.text+0x2304): undefined reference to `ddc_read_edid'
crmfb.c:(.text+0x2304): relocation truncated to fit: R_MIPS_26 against `ddc_read_edid'
crmfb.c:(.text+0x234c): undefined reference to `edid_parse'
crmfb.c:(.text+0x234c): relocation truncated to fit: R_MIPS_26 against `edid_parse'
crmfb.c:(.text+0x2354): undefined reference to `edid_print'
crmfb.c:(.text+0x2354): relocation truncated to fit: R_MIPS_26 against `edid_print'
 1.18 20-Mar-2011  mrg enable the tomatillo iocache.
garbage collect struct iommureg_schizo and use struct iommureg2.
 1.17 02-Jan-2011  mrg branches: 1.17.2;
now that it's optional, kill schizo_pci_find_ino().
prepare to enable the tomatillo iocache.
 1.16 11-Mar-2010  mrg branches: 1.16.2;
various aprint_* fixes.
 1.15 11-Mar-2010  mrg - pay attention to the "no-streaming-cache" flag.
- minor re-structure so this looks a little more like psycho.c.
 1.14 13-Feb-2010  nakayama Make 32-bit kernels compilable.
 1.13 06-Feb-2010  mrg branches: 1.13.2;
- properly map the schizo interrupt registers, so we can use the normal
virtual mappings to access them.
- with the above fxied, kill SCHIZO_BUS_SPACE_BROKEN, and introduce
an options CHEETAH for now, that disables the SPITFIRE code in locore.
- merge schizo_init() into schizo_attach() and clean up the softc a bit.


with this we are only one more step away from GENERIC booting on USIII
machines.
 1.12 06-Jan-2010  mrg move the guts of pci_intr_map() into pci_machdep.c, and move the schizo
ign addition into a hook. also, don't double shift the ign in set_intr.

tested on U60 and SB2500.
 1.11 30-Dec-2009  nakayama It seems that accessing to a PCI configration space where devices
are unavailable causes data_access_error trap. We need to check a
validity of OF node embeded in pcitag to avoid the trap.

Fixes PR port-sparc64/42545.
 1.10 30-Nov-2009  mrg convert pci_intr_map() into a chipset tag function pointer, and implement
the schizo version slightly differently.

pull out the schizo's IGN from the upaid, not the apparently broken device
ID register. from openbsd.

with this i appear to have valid working interrupts on the SB2500.

tested on U60 and SB2500.


XXX: we can probably kill (*spc_find_ino)() now that pci_intr_map() itself
XXX: is no longer a first class function.
 1.9 27-Nov-2009  mrg clean up some debug messages a little bit.
 1.8 16-Dec-2008  christos branches: 1.8.2; 1.8.4; 1.8.8;
replace bitmask_snprintf(9) with snprintb(3)
 1.7 15-Dec-2008  mrg properly calculate the addresses of the interrupt map & clr registers.
now interrupts are working. but /sbin/init is failing to work over nfs.
 1.6 13-Dec-2008  mrg - read AgentID out of the schizo CSR and use that, rather than the
passed in portid, to calculate the IGN.
- don't logical-or in the IGN always, possible twice
 1.5 13-Dec-2008  mrg fix much of the interrupt mapping/establishment code. still does
not yet work, but we are now seeing spurious interrupts (that should
be mapped to some handler..)
 1.4 13-Dec-2008  mrg - enable schizo_dmamap_create() after fixing it
- clean up some debug code
- remove unused schizo_intr_map()
- setup our iommu state properly
- for now, implement a 'struct schizo_iommureg' and use it in schizo.
XXX this should be merged with iommu*

interrupts are still not working but we get to scsi probe now.
 1.3 10-Dec-2008  nakayama branches: 1.3.2;
Add initialization of spc_busmax and spc_busnode in sparc_pci_chipset.
 1.2 10-Dec-2008  mrg checkpoint my work-in-progress port of this driver.
it boots some way but will crash attaching rtc0.

known TODO items:
- figure out why BUS_SPACE_MAP_LINEAR mappings generate data errors
(cause of the rtc issue)
- several interrupt issues
 1.1 10-Dec-2008  mrg branches: 1.1.1;
Initial revision
 1.1.1.1 10-Dec-2008  mrg import the original openbsd "schizo" PCI driver as found on US-III systems.
 1.3.2.2 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.3.2.1 10-Dec-2008  haad file schizo.c was added on branch haad-dm on 2008-12-13 01:13:29 +0000
 1.8.8.4 11-Aug-2010  yamt sync with head.
 1.8.8.3 11-Mar-2010  yamt sync with head
 1.8.8.2 04-May-2009  yamt sync with head.
 1.8.8.1 16-Dec-2008  yamt file schizo.c was added on branch yamt-nfs-mp on 2009-05-04 08:11:57 +0000
 1.8.4.2 19-Jan-2009  skrll Sync with HEAD.
 1.8.4.1 16-Dec-2008  skrll file schizo.c was added on branch nick-hppapmap on 2009-01-19 13:16:47 +0000
 1.8.2.2 17-Jan-2009  mjf Sync with HEAD.
 1.8.2.1 16-Dec-2008  mjf file schizo.c was added on branch mjf-devfs2 on 2009-01-17 13:28:32 +0000
 1.13.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.16.2.4 12-Jun-2011  rmind sync with head
 1.16.2.3 31-May-2011  rmind sync with head
 1.16.2.2 21-Apr-2011  rmind sync with head
 1.16.2.1 05-Mar-2011  rmind sync with head
 1.17.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.20.2.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.27.6.1 05-Apr-2012  mrg sync to latest -current.
 1.27.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.27.2.2 30-Oct-2012  yamt sync with head
 1.27.2.1 17-Apr-2012  yamt sync with head
 1.29.2.3 03-Dec-2017  jdolecek update from HEAD
 1.29.2.2 23-Jun-2013  tls resync from head
 1.29.2.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.31.8.2 26-Jan-2016  riz Pull up following revision(s) (requested by jdc in ticket #1064):
sys/arch/sparc64/dev/schizo.c: revision 1.34
sys/arch/sparc64/dev/schizo.c: revision 1.35
sys/arch/sparc64/dev/schizovar.h: revision 1.7
sys/arch/sparc64/dev/schizoreg.h: revision 1.10
sys/arch/sparc64/dev/schizoreg.h: revision 1.11
add some tomatillo specific information to schizo_pbm_regs.
Set the target JPID for all interrupts on Tomatillo.
If the "ino-bitmap" property is available, use it to route error interrupts.
Minor cosmetic changes.
Add register printing when DEBUG is defined.
Use __BIT() for some masks to fix the sparc build.
No binary changes.
 1.31.8.1 10-Nov-2014  snj Pull up following revision(s) (requested by maxv in ticket #195):
sys/arch/arm/iomd/iomd_irqhandler.c: revision 1.21
sys/arch/arm/ofw/ofw_irqhandler.c: revision 1.21
sys/arch/atari/atari/intr.c: revision 1.24-1.25
sys/arch/ews4800mips/sbd/fb_sbdio.c: revision 1.14
sys/arch/hpcmips/tx/tx39icu.c: revision 1.34
sys/arch/shark/isa/isa_irqhandler.c: revision 1.27
sys/arch/sparc/sparc/machdep.c: revision 1.327
sys/arch/sparc64/dev/psycho.c: revision 1.119
sys/arch/sparc64/dev/schizo.c: revision 1.32
sys/arch/sparc64/sparc64/machdep.c: revision 1.279
sys/arch/sun68k/sun68k/bus.c: revision 1.22
sys/arch/x86/x86/ipmi.c: revision 1.58
sys/arch/xen/xen/privcmd.c: revision 1.46-1.49
Fix several memory leaks.
 1.32.2.4 28-Aug-2017  skrll Sync with HEAD
 1.32.2.3 05-Dec-2016  skrll Sync with HEAD
 1.32.2.2 29-May-2016  skrll Sync with HEAD
 1.32.2.1 27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.36.2.2 26-Apr-2017  pgoyette Sync with HEAD
 1.36.2.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.37.2.1 21-Apr-2017  bouyer Sync with HEAD
 1.39.10.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.39.10.1 10-Jun-2019  christos Sync with HEAD
 1.42.8.1 03-Apr-2021  thorpej Sync with HEAD.
 1.43.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.44.4.1 31-May-2021  cjep sync with head
 1.44.2.1 13-May-2021  thorpej Sync with HEAD.
 1.45.4.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.12 19-Oct-2018  macallan add Tomatillo ESTAR and GPIO registers
 1.11 23-Nov-2015  jdc branches: 1.11.16; 1.11.18;
Set the target JPID for all interrupts on Tomatillo.
If the "ino-bitmap" property is available, use it to route error interrupts.
Minor cosmetic changes.
Add register printing when DEBUG is defined.
 1.10 10-Aug-2015  mrg add some tomatillo specific information to schizo_pbm_regs.
 1.9 25-Mar-2012  mrg branches: 1.9.2; 1.9.14; 1.9.16;
- save the "version#" in the softc, we will want it later
- enable some more things in the schizo CSR:
- tomatillo: DMA arbitration enable:
- tomatillo: prefetch read multiple / one / line
- schizo: enable parking unless "no-bus-parking" is set
- schizo: enable streaming buffer interrupts
- schizo: enable bus arbitration for schizo, not these reseved
bits for tomatillo

partly from and entirely inspired by freebsd schizo_attach().
 1.8 20-Mar-2011  mrg branches: 1.8.4; 1.8.8;
enable the tomatillo iocache.
garbage collect struct iommureg_schizo and use struct iommureg2.
 1.7 02-Jan-2011  mrg branches: 1.7.2;
now that it's optional, kill schizo_pci_find_ino().
prepare to enable the tomatillo iocache.
 1.6 13-Feb-2010  nakayama branches: 1.6.2;
Make 32-bit kernels compilable.
 1.5 13-Dec-2008  mrg branches: 1.5.2; 1.5.4; 1.5.8; 1.5.10;
- read AgentID out of the schizo CSR and use that, rather than the
passed in portid, to calculate the IGN.
- don't logical-or in the IGN always, possible twice
 1.4 13-Dec-2008  mrg - enable schizo_dmamap_create() after fixing it
- clean up some debug code
- remove unused schizo_intr_map()
- setup our iommu state properly
- for now, implement a 'struct schizo_iommureg' and use it in schizo.
XXX this should be merged with iommu*

interrupts are still not working but we get to scsi probe now.
 1.3 10-Dec-2008  mrg branches: 1.3.2;
revert part of the previous.
 1.2 10-Dec-2008  mrg checkpoint my work-in-progress port of this driver.
it boots some way but will crash attaching rtc0.

known TODO items:
- figure out why BUS_SPACE_MAP_LINEAR mappings generate data errors
(cause of the rtc issue)
- several interrupt issues
 1.1 10-Dec-2008  mrg branches: 1.1.1;
Initial revision
 1.1.1.1 10-Dec-2008  mrg import the original openbsd "schizo" PCI driver as found on US-III systems.
 1.3.2.2 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.3.2.1 10-Dec-2008  haad file schizoreg.h was added on branch haad-dm on 2008-12-13 01:13:29 +0000
 1.5.10.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.5.8.3 11-Mar-2010  yamt sync with head
 1.5.8.2 04-May-2009  yamt sync with head.
 1.5.8.1 13-Dec-2008  yamt file schizoreg.h was added on branch yamt-nfs-mp on 2009-05-04 08:11:57 +0000
 1.5.4.2 19-Jan-2009  skrll Sync with HEAD.
 1.5.4.1 13-Dec-2008  skrll file schizoreg.h was added on branch nick-hppapmap on 2009-01-19 13:16:47 +0000
 1.5.2.2 17-Jan-2009  mjf Sync with HEAD.
 1.5.2.1 13-Dec-2008  mjf file schizoreg.h was added on branch mjf-devfs2 on 2009-01-17 13:28:32 +0000
 1.6.2.2 21-Apr-2011  rmind sync with head
 1.6.2.1 05-Mar-2011  rmind sync with head
 1.7.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.8.8.1 05-Apr-2012  mrg sync to latest -current.
 1.8.4.1 17-Apr-2012  yamt sync with head
 1.9.16.2 27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.9.16.1 22-Sep-2015  skrll Sync with HEAD
 1.9.14.1 26-Jan-2016  riz Pull up following revision(s) (requested by jdc in ticket #1064):
sys/arch/sparc64/dev/schizo.c: revision 1.34
sys/arch/sparc64/dev/schizo.c: revision 1.35
sys/arch/sparc64/dev/schizovar.h: revision 1.7
sys/arch/sparc64/dev/schizoreg.h: revision 1.10
sys/arch/sparc64/dev/schizoreg.h: revision 1.11
add some tomatillo specific information to schizo_pbm_regs.
Set the target JPID for all interrupts on Tomatillo.
If the "ino-bitmap" property is available, use it to route error interrupts.
Minor cosmetic changes.
Add register printing when DEBUG is defined.
Use __BIT() for some masks to fix the sparc build.
No binary changes.
 1.9.2.1 03-Dec-2017  jdolecek update from HEAD
 1.11.18.1 10-Jun-2019  christos Sync with HEAD
 1.11.16.1 20-Oct-2018  pgoyette Sync with head
 1.7 23-Nov-2015  jdc Set the target JPID for all interrupts on Tomatillo.
If the "ino-bitmap" property is available, use it to route error interrupts.
Minor cosmetic changes.
Add register printing when DEBUG is defined.
 1.6 25-Mar-2012  mrg branches: 1.6.2; 1.6.14; 1.6.16;
- save the "version#" in the softc, we will want it later
- enable some more things in the schizo CSR:
- tomatillo: DMA arbitration enable:
- tomatillo: prefetch read multiple / one / line
- schizo: enable parking unless "no-bus-parking" is set
- schizo: enable streaming buffer interrupts
- schizo: enable bus arbitration for schizo, not these reseved
bits for tomatillo

partly from and entirely inspired by freebsd schizo_attach().
 1.5 03-Jun-2011  christos branches: 1.5.2; 1.5.6;
CFATTACH_DECL_NEW
 1.4 06-Feb-2010  mrg branches: 1.4.4; 1.4.6; 1.4.10;
- properly map the schizo interrupt registers, so we can use the normal
virtual mappings to access them.
- with the above fxied, kill SCHIZO_BUS_SPACE_BROKEN, and introduce
an options CHEETAH for now, that disables the SPITFIRE code in locore.
- merge schizo_init() into schizo_attach() and clean up the softc a bit.


with this we are only one more step away from GENERIC booting on USIII
machines.
 1.3 13-Dec-2008  mrg branches: 1.3.2; 1.3.4; 1.3.8;
fix much of the interrupt mapping/establishment code. still does
not yet work, but we are now seeing spurious interrupts (that should
be mapped to some handler..)
 1.2 10-Dec-2008  mrg branches: 1.2.2;
checkpoint my work-in-progress port of this driver.
it boots some way but will crash attaching rtc0.

known TODO items:
- figure out why BUS_SPACE_MAP_LINEAR mappings generate data errors
(cause of the rtc issue)
- several interrupt issues
 1.1 10-Dec-2008  mrg branches: 1.1.1;
Initial revision
 1.1.1.1 10-Dec-2008  mrg import the original openbsd "schizo" PCI driver as found on US-III systems.
 1.2.2.2 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.2.2.1 10-Dec-2008  haad file schizovar.h was added on branch haad-dm on 2008-12-13 01:13:29 +0000
 1.3.8.3 11-Mar-2010  yamt sync with head
 1.3.8.2 04-May-2009  yamt sync with head.
 1.3.8.1 13-Dec-2008  yamt file schizovar.h was added on branch yamt-nfs-mp on 2009-05-04 08:11:57 +0000
 1.3.4.2 19-Jan-2009  skrll Sync with HEAD.
 1.3.4.1 13-Dec-2008  skrll file schizovar.h was added on branch nick-hppapmap on 2009-01-19 13:16:47 +0000
 1.3.2.2 17-Jan-2009  mjf Sync with HEAD.
 1.3.2.1 13-Dec-2008  mjf file schizovar.h was added on branch mjf-devfs2 on 2009-01-17 13:28:32 +0000
 1.4.10.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.4.6.1 06-Jun-2011  jruoho Sync with HEAD.
 1.4.4.1 12-Jun-2011  rmind sync with head
 1.5.6.1 05-Apr-2012  mrg sync to latest -current.
 1.5.2.1 17-Apr-2012  yamt sync with head
 1.6.16.1 27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.6.14.1 26-Jan-2016  riz Pull up following revision(s) (requested by jdc in ticket #1064):
sys/arch/sparc64/dev/schizo.c: revision 1.34
sys/arch/sparc64/dev/schizo.c: revision 1.35
sys/arch/sparc64/dev/schizovar.h: revision 1.7
sys/arch/sparc64/dev/schizoreg.h: revision 1.10
sys/arch/sparc64/dev/schizoreg.h: revision 1.11
add some tomatillo specific information to schizo_pbm_regs.
Set the target JPID for all interrupts on Tomatillo.
If the "ino-bitmap" property is available, use it to route error interrupts.
Minor cosmetic changes.
Add register printing when DEBUG is defined.
Use __BIT() for some masks to fix the sparc build.
No binary changes.
 1.6.2.1 03-Dec-2017  jdolecek update from HEAD
 1.4 05-Sep-1998  pk Remove unused files.
 1.3 13-Aug-1998  eeh Merge paddr_t changes into the main branch.
 1.2 04-Jul-1998  jonathan branches: 1.2.2;
defopt DDB.
 1.1 20-Jun-1998  eeh branches: 1.1.1;
Initial revision
 1.1.1.1 20-Jun-1998  eeh Import of sparc64.
 1.2.2.1 30-Jul-1998  eeh Split vm_offset_t and vm_size_t into paddr_t, psize_t, vaddr_t, and vsize_t.
 1.3 20-Jul-2001  eeh PCI overhaul.
 1.2 24-May-2000  eeh branches: 1.2.8;
Use the PCI function code to distinguish simba bus A from bus B instead
of the current hack.
 1.1 04-Jun-1999  mrg branches: 1.1.2; 1.1.4;
PCI driver for the UltraSPARC. this only works on the Ultra5/10 machines
(`SUNW,sabre') for now, and it doesn't really quite work there yet anyway.
the bus space/dma code is cloned from the sbus driver. the IOMMU code also
is cloned from the sbus code, but separated out into iommu.c so that we can
share it with the sbus driver. hopefully, much of the bus space/dma code
can also be re-shared with the sbus driver and the ebus driver but for now
these copies will do.

support for the real UltraSPARC PCI (`SUNW,psycho') is unwritten, though
most of this code is shared with it.

we can probe PCI config space and try to configue devices, but interrupts
don't work yet...
 1.1.4.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.1.2.1 21-Jun-1999  thorpej Sync w/ -current.
 1.2.8.1 03-Aug-2001  lukem update to -current
 1.2 05-Oct-2001  thorpej Delete this file; nothing includes it, and it is simply an (incomplete)
copy of <dev/pci/ppbreg.h> anyway.
 1.1 04-Jun-1999  mrg branches: 1.1.2; 1.1.16; 1.1.18;
PCI driver for the UltraSPARC. this only works on the Ultra5/10 machines
(`SUNW,sabre') for now, and it doesn't really quite work there yet anyway.
the bus space/dma code is cloned from the sbus driver. the IOMMU code also
is cloned from the sbus code, but separated out into iommu.c so that we can
share it with the sbus driver. hopefully, much of the bus space/dma code
can also be re-shared with the sbus driver and the ebus driver but for now
these copies will do.

support for the real UltraSPARC PCI (`SUNW,psycho') is unwritten, though
most of this code is shared with it.

we can probe PCI config space and try to configue devices, but interrupts
don't work yet...
 1.1.18.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.1.16.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.1.2.1 21-Jun-1999  thorpej Sync w/ -current.
 1.2 05-Sep-1998  pk Remove unused files.
 1.1 20-Jun-1998  eeh branches: 1.1.1;
Initial revision
 1.1.1.1 20-Jun-1998  eeh Import of sparc64.
 1.6 20-Dec-2023  thorpej Remove unnecessary <sys/malloc.h>.
 1.5 16-May-2020  jdc Extend the monitoring to battery state, with capacity based on voltage.
Add more PMU definitions.
 1.4 14-Oct-2018  macallan branches: 1.4.2; 1.4.6;
- protect PMU transactions with a mutex
- report lid switch events to powerd
 1.3 13-Oct-2018  macallan config and attachment goop for tadpmu
 1.2 13-Oct-2018  macallan - use interrupts
- report power button to sysmon
 1.1 12-Oct-2018  macallan experimental code to talk to the PMU found in Tadpole Viper laptops
 1.4.6.2 10-Jun-2019  christos Sync with HEAD
 1.4.6.1 14-Oct-2018  christos file tadpmu.c was added on branch phil-wifi on 2019-06-10 22:06:47 +0000
 1.4.2.2 20-Oct-2018  pgoyette Sync with head
 1.4.2.1 14-Oct-2018  pgoyette file tadpmu.c was added on branch pgoyette-compat on 2018-10-20 06:58:29 +0000
 1.3 16-May-2020  jdc Extend the monitoring to battery state, with capacity based on voltage.
Add more PMU definitions.
 1.2 13-Oct-2018  macallan branches: 1.2.2; 1.2.6;
- use interrupts
- report power button to sysmon
 1.1 12-Oct-2018  macallan experimental code to talk to the PMU found in Tadpole Viper laptops
 1.2.6.2 10-Jun-2019  christos Sync with HEAD
 1.2.6.1 13-Oct-2018  christos file tadpmureg.h was added on branch phil-wifi on 2019-06-10 22:06:47 +0000
 1.2.2.2 20-Oct-2018  pgoyette Sync with head
 1.2.2.1 13-Oct-2018  pgoyette file tadpmureg.h was added on branch pgoyette-compat on 2018-10-20 06:58:29 +0000
 1.3 16-May-2020  jdc Extend the monitoring to battery state, with capacity based on voltage.
Add more PMU definitions.
 1.2 13-Oct-2018  macallan branches: 1.2.2; 1.2.6;
- use interrupts
- report power button to sysmon
 1.1 12-Oct-2018  macallan experimental code to talk to the PMU found in Tadpole Viper laptops
 1.2.6.2 10-Jun-2019  christos Sync with HEAD
 1.2.6.1 13-Oct-2018  christos file tadpmuvar.h was added on branch phil-wifi on 2019-06-10 22:06:47 +0000
 1.2.2.2 20-Oct-2018  pgoyette Sync with head
 1.2.2.1 13-Oct-2018  pgoyette file tadpmuvar.h was added on branch pgoyette-compat on 2018-10-20 06:58:29 +0000
 1.6 23-Aug-2000  pk This driver is now in sys/dev/sbus.
 1.5 29-Jun-2000  mrg remove include of <vm/vm.h>. <vm/vm.h> -> <uvm/uvm_extern.h>
 1.4 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.3 23-May-1999  eeh branches: 1.3.2; 1.3.12;
Start putting in hooks for non-zs console devices.
 1.2 05-Sep-1998  pk branches: 1.2.8;
#include <dev/sbus/sbusvar.h>
 1.1 20-Jun-1998  eeh branches: 1.1.1;
Initial revision
 1.1.1.1 20-Jun-1998  eeh Import of sparc64.
 1.2.8.1 21-Jun-1999  thorpej Sync w/ -current.
 1.3.12.1 30-Jun-2000  simonb Pull up mmap paddr_t/off_t changes from trunk.
 1.3.2.1 20-Nov-2000  bouyer Remove files that are no longer on the trunck
 1.2 23-Aug-2000  pk This driver is now in sys/dev/sbus.
 1.1 20-Jun-1998  eeh branches: 1.1.1;
Initial revision
 1.1.1.1 20-Jun-1998  eeh branches: 1.1.1.1.14;
Import of sparc64.
 1.1.1.1.14.1 20-Nov-2000  bouyer Remove files that are no longer on the trunck
 1.14 31-Oct-2020  jdc Call sysmon_envsys_unregister() not sysmon_envsys_destroy() when
detaching. Pointed out by Michael van Elst.
 1.13 01-Mar-2019  mrg make the conversion from degC to uK a macro instead of open
coding it 4 places.
 1.12 16-Jun-2018  thorpej branches: 1.12.2;
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.11 07-Jul-2016  msaitoh branches: 1.11.16;
KNF. Remove extra spaces. No functional change.
 1.10 27-Apr-2015  martin Print error codes from sysmon
 1.9 26-Oct-2013  jdc branches: 1.9.6;
Use machine_model from autoconf.c, instead of calling the firmware here.
 1.8 03-Feb-2013  jdc branches: 1.8.2;
Add a detach function and use this when shutting down:
halt the fan speed callout
set the speed of both fans to maximum

Also avoids occasional panics in shutdown because the callout is not stopped.
 1.7 02-Feb-2013  jdc Add sysmon support to display the fan-speed related values for the CPU and
system fans.
Fix a bug where the system fan was always set to full speed (63), which was
noticed when viewing the values reported by `envstat`.
 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 18-Mar-2012  mrg branches: 1.5.2;
add missing __KERNEL_RCSID().
 1.4 03-Apr-2011  jdc branches: 1.4.4; 1.4.8; 1.4.10;
Return early if we are called from indirect attach (i.e., not the normal
case).
 1.3 11-Mar-2010  mrg branches: 1.3.2; 1.3.4; 1.3.6; 1.3.8;
various aprint_* fixes.
 1.2 01-Mar-2010  martin Fix printf formats (for 32bit compiles)
 1.1 28-Feb-2010  martin Remove the envctrl driver, it is superseeded by the more general pcfiic @
ebus. Add the SB1000/SB2000 fan controll driver (tda). From OpenBSD.
Move config files over to direct configuration of i2c devices.
 1.3.8.1 06-Jun-2011  jruoho Sync with HEAD.
 1.3.6.2 30-Apr-2010  uebayasi Sync with HEAD.
 1.3.6.1 11-Mar-2010  uebayasi file tda.c was added on branch uebayasi-xip on 2010-04-30 14:39:51 +0000
 1.3.4.1 21-Apr-2011  rmind sync with head
 1.3.2.3 11-Aug-2010  yamt sync with head.
 1.3.2.2 11-Mar-2010  yamt sync with head
 1.3.2.1 11-Mar-2010  yamt file tda.c was added on branch yamt-nfs-mp on 2010-03-11 15:03:00 +0000
 1.4.10.1 13-Jun-2013  msaitoh Pull up following revision(s) (requested by jdp in ticket #893):
sys/arch/sparc64/dev/tda.c 1.7-1.8
share/man/man4/man4.sparc64/tda.4 1.1-1.3
share/man/man4/man4.sparc64/Makefile 1.7
distrib/sets/lists/man/mi 1.1419
Add sysmon support to display the CPU and Sytem fan speeds for the
tda driver. Add a manual page for tda(4). Fix a bug which caused
the system fan to always run at full speed.
 1.4.8.1 05-Apr-2012  mrg sync to latest -current.
 1.4.4.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.4.4.2 30-Oct-2012  yamt sync with head
 1.4.4.1 17-Apr-2012  yamt sync with head
 1.5.2.4 03-Dec-2017  jdolecek update from HEAD
 1.5.2.3 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.5.2.2 25-Feb-2013  tls resync with head
 1.5.2.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.8.2.1 18-May-2014  rmind sync with head
 1.9.6.2 09-Jul-2016  skrll Sync with HEAD
 1.9.6.1 06-Jun-2015  skrll Sync with HEAD
 1.11.16.1 25-Jun-2018  pgoyette Sync with HEAD
 1.12.2.1 10-Jun-2019  christos Sync with HEAD
 1.24 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.23 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.22 10-May-2021  thorpej branches: 1.22.4;
Associate the OpenBoot / OpenFirmware node with attached devices
at config_found() time.
 1.21 24-Apr-2021  thorpej branches: 1.21.2; 1.21.4;
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.20 04-Jan-2021  thorpej branches: 1.20.2;
malloc(9) -> kmem(9) -- just the simple, straightforward conversions for now.
 1.19 10-Nov-2019  chs branches: 1.19.8;
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.18 18-Mar-2012  mrg branches: 1.18.40;
add missing __KERNEL_RCSID().
 1.17 01-Jul-2011  dyoung branches: 1.17.2; 1.17.6;
#include <sys/bus.h> instead of <machine/bus.h>.
 1.16 03-Jun-2011  christos CFATTACH_DECL_NEW
 1.15 12-Jan-2010  martin branches: 1.15.4; 1.15.6; 1.15.10;
Import support for upa64s device (/upa on SB1000/2000) from OpenBSD.
Attach ffb both at mainbus and at upa.
 1.14 20-Oct-2002  martin branches: 1.14.66;
We are not going to get a "upa at mainbus" autoconfig entity, since
UPA is just a physical incarnation of our mainbus0.

Evidence:

- There can only be one!
- The firmware node coresponding to it is the root of the OF tree

So: remove the unused (and uncompilable) upa.c, remove upavar.h after
moving the only declaration used from it to autoconf.h.
 1.13 02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.12 01-Oct-2002  thorpej Use CFATTACH_DECL().
 1.11 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.10 27-Sep-2002  thorpej Rather than referencing the cfdriver directly in the cfdata entries,
instead use a string naming the driver. The cfdriver is then looked
up in a list which is built at run-time.
 1.9 16-May-2002  wiz #ifdef 1 -> #if 1
 1.8 26-Sep-2001  eeh branches: 1.8.4; 1.8.12;
getprop* -> PROM_getprop*
 1.7 29-Jun-2000  mrg branches: 1.7.2; 1.7.4;
remove include of <vm/vm.h>. <vm/vm.h> -> <uvm/uvm_extern.h>
 1.6 14-Jan-2000  pk Remove old-style boot device recognition.
 1.5 07-Jun-1999  eeh branches: 1.5.2;
Another general cleanup:

Remove the entire idea of fasttrap interrupts since V9 traps are really cheap,
the CPUs are really fast, and the completely different trap frames would make
these handlers really difficult to implement.

pmap_changeprot() was only used by the clock and one other place; deprecate it.

probeget() and probeset() now take 64-bit addresses even in 32-bit mode so we
can probe IO locations by physical addresses.

Some pmap cleanup.

Some more copyright cleanup.
 1.4 05-Sep-1998  eeh branches: 1.4.8;
It slices. It dices. It does everything except exec a sparc32_compat init.
 1.3 05-Sep-1998  pk Nuke temporary `getpropA()'.
 1.2 13-Aug-1998  eeh Merge paddr_t changes into the main branch.
 1.1 20-Jun-1998  eeh branches: 1.1.1;
Initial revision
 1.1.1.1 20-Jun-1998  eeh branches: 1.1.1.1.2;
Import of sparc64.
 1.1.1.1.2.1 30-Jul-1998  eeh Split vm_offset_t and vm_size_t into paddr_t, psize_t, vaddr_t, and vsize_t.
 1.4.8.1 21-Jun-1999  thorpej Sync w/ -current.
 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.7.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.7.4.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.7.4.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.7.2.1 01-Oct-2001  fvdl Catch up with -current.
 1.8.12.1 30-May-2002  gehenna Catch up with -current.
 1.8.4.4 11-Nov-2002  nathanw Catch up to -current
 1.8.4.3 18-Oct-2002  nathanw Catch up to -current.
 1.8.4.2 20-Jun-2002  nathanw Catch up to -current.
 1.8.4.1 26-Sep-2001  nathanw file upa.c was added on branch nathanw_sa on 2002-06-20 03:41:23 +0000
 1.14.66.1 11-Mar-2010  yamt sync with head
 1.15.10.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.15.6.1 06-Jun-2011  jruoho Sync with HEAD.
 1.15.4.1 12-Jun-2011  rmind sync with head
 1.17.6.1 05-Apr-2012  mrg sync to latest -current.
 1.17.2.1 17-Apr-2012  yamt sync with head
 1.18.40.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.19.8.1 03-Apr-2021  thorpej Sync with HEAD.
 1.20.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.21.4.1 31-May-2021  cjep sync with head
 1.21.2.1 13-May-2021  thorpej Sync with HEAD.
 1.22.4.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.3 20-Oct-2002  martin We are not going to get a "upa at mainbus" autoconfig entity, since
UPA is just a physical incarnation of our mainbus0.

Evidence:

- There can only be one!
- The firmware node coresponding to it is the root of the OF tree

So: remove the unused (and uncompilable) upa.c, remove upavar.h after
moving the only declaration used from it to autoconf.h.
 1.2 14-Jan-2000  pk branches: 1.2.12;
Remove old-style boot device recognition.
 1.1 20-Jun-1998  eeh branches: 1.1.1;
Initial revision
 1.1.1.1 20-Jun-1998  eeh branches: 1.1.1.1.14;
Import of sparc64.
 1.1.1.1.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.2.12.1 11-Nov-2002  nathanw Catch up to -current
 1.9 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.8 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.7 10-May-2021  thorpej branches: 1.7.4;
Associate the OpenBoot / OpenFirmware node with attached devices
at config_found() time.
 1.6 24-Apr-2021  thorpej branches: 1.6.2; 1.6.4;
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 04-Jan-2021  thorpej branches: 1.5.2;
malloc(9) -> kmem(9) -- just the simple, straightforward conversions for now.
 1.4 10-Nov-2019  chs branches: 1.4.8;
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.3 17-Feb-2017  palle branches: 1.3.12; 1.3.16;
sun4v: Fix potential memory leaks - spotted by maxv@
 1.2 21-Jun-2016  palle branches: 1.2.2; 1.2.4; 1.2.6;
sun4v: vbus_attach() bugfix - use device_private()
 1.1 17-Jun-2016  palle sun4v: vbus and vrtc drivers - from OpenBSD
 1.2.6.1 21-Apr-2017  bouyer Sync with HEAD
 1.2.4.1 20-Mar-2017  pgoyette Sync with HEAD
 1.2.2.3 28-Aug-2017  skrll Sync with HEAD
 1.2.2.2 09-Jul-2016  skrll Sync with HEAD
 1.2.2.1 21-Jun-2016  skrll file vbus.c was added on branch nick-nhusb on 2016-07-09 20:24:57 +0000
 1.3.16.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.3.12.2 03-Dec-2017  jdolecek update from HEAD
 1.3.12.1 17-Feb-2017  jdolecek file vbus.c was added on branch tls-maxphys on 2017-12-03 11:36:44 +0000
 1.4.8.1 03-Apr-2021  thorpej Sync with HEAD.
 1.5.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.6.4.1 31-May-2021  cjep sync with head
 1.6.2.1 13-May-2021  thorpej Sync with HEAD.
 1.7.4.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.1 17-Jun-2016  palle branches: 1.1.2; 1.1.18;
sun4v: vbus and vrtc drivers - from OpenBSD
 1.1.18.2 03-Dec-2017  jdolecek update from HEAD
 1.1.18.1 17-Jun-2016  jdolecek file vbusvar.h was added on branch tls-maxphys on 2017-12-03 11:36:44 +0000
 1.1.2.2 09-Jul-2016  skrll Sync with HEAD
 1.1.2.1 17-Jun-2016  skrll file vbusvar.h was added on branch nick-nhusb on 2016-07-09 20:24:57 +0000
 1.21 26-Jul-2025  palle sun4v: minor updates to please cd(4) so no warning are emitted
 1.20 08-Jul-2025  palle vdsk: ignore commands not implemented yet
 1.19 23-Feb-2025  palle sun4v: Ensure that the ldc map table entries are properly cleared. It has been observed that the inner while loop in vdsk_submit_cmd() may encounter stale entries resulting in an endless loop
 1.18 20-Jun-2024  palle branches: 1.18.2;
sun4v: change some debug printf() to DPRINTF()
 1.17 20-Jun-2024  palle sun4v: add some DPRINTF() to vdsk
 1.16 19-Jun-2024  palle sun4v: revert two new functions introduced in rev. 1.13 - not necessary yet
 1.15 19-Jun-2024  palle sun4v: fix incorrect string length (product name Virtual CDROM)
 1.14 12-Jun-2024  riastradh arch/sparc64/dev/dsk.c: Nix trailing whitespace.

No functional change intended.
 1.13 10-Jun-2024  palle sun4v: add incomplete implementation of the CD-specific READ_DISCINFO and READ_TRACKINFO - probably needs some more work though...
 1.12 09-Jun-2024  palle sun4v: fix vdsk so an iso image exported by the ldom virtual disk service is correctly detected as a cd device + some whitespace fixes
 1.11 12-Dec-2023  andvar extract capacity variable to make VDSK_DEBUG enabled code build.
 1.10 16-May-2022  palle sun4v/vdsk: add handling of SCSI_REPORT_LUNS
 1.9 04-Dec-2021  andvar fix typos in comments and log messages, mainly in establish(ed).
 1.8 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.7 25-Jun-2021  palle branches: 1.7.2;
sun4v: vdsk - restart the ldc state machine when the ldc endpoint resets the link or a DATA/NACK/DRING_DATA message is received. These changes make the driver more robust. In a ldom with Solaris 11.4 SRU30 as primary domain (T5 host system) frequent resets and NACK messages are observed.
 1.6 24-Apr-2021  thorpej branches: 1.6.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.5 19-Nov-2019  palle branches: 1.5.10;
sun4v: added support for handling of opcode SCSI_MAINTENANCE_IN when using ldom based virtual disk
 1.4 01-Oct-2019  chs in many device attach paths, allocate memory with KM_SLEEP instead of KM_NOSLEEP
and remove code to handle failures that can no longer happen.
 1.3 03-Mar-2017  palle branches: 1.3.12; 1.3.16;
sun4v: Fixed PR 51554 - Avoid unsafe allocation in ldc/vdsk
 1.2 20-Aug-2016  nakayama branches: 1.2.2; 1.2.4; 1.2.6;
Avoid "cast to pointer from integer of different size" warning on
32-bit kernels.
 1.1 19-Aug-2016  palle sun4v: vdsk and ldc drivers - from OpenBSD, but heavily adapted to NetBSD scsipi - access to a virtual disk served from a ldom primary domain now works
 1.2.6.1 21-Apr-2017  bouyer Sync with HEAD
 1.2.4.3 28-Aug-2017  skrll Sync with HEAD
 1.2.4.2 05-Oct-2016  skrll Sync with HEAD
 1.2.4.1 20-Aug-2016  skrll file vdsk.c was added on branch nick-nhusb on 2016-10-05 20:55:36 +0000
 1.2.2.3 20-Mar-2017  pgoyette Sync with HEAD
 1.2.2.2 14-Sep-2016  pgoyette Sync with HEAD
 1.2.2.1 20-Aug-2016  pgoyette file vdsk.c was added on branch pgoyette-localcount on 2016-09-14 03:04:17 +0000
 1.3.16.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.3.16.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.3.12.2 03-Dec-2017  jdolecek update from HEAD
 1.3.12.1 03-Mar-2017  jdolecek file vdsk.c was added on branch tls-maxphys on 2017-12-03 11:36:44 +0000
 1.5.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.6.2.1 01-Aug-2021  thorpej Sync with HEAD.
 1.7.2.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.18.2.1 02-Aug-2025  perseant Sync with HEAD
 1.1 19-Aug-2016  palle branches: 1.1.2; 1.1.4; 1.1.18;
sun4v: vdsk and ldc drivers - from OpenBSD, but heavily adapted to NetBSD scsipi - access to a virtual disk served from a ldom primary domain now works
 1.1.18.2 03-Dec-2017  jdolecek update from HEAD
 1.1.18.1 19-Aug-2016  jdolecek file viovar.h was added on branch tls-maxphys on 2017-12-03 11:36:44 +0000
 1.1.4.2 05-Oct-2016  skrll Sync with HEAD
 1.1.4.1 19-Aug-2016  skrll file viovar.h was added on branch nick-nhusb on 2016-10-05 20:55:36 +0000
 1.1.2.2 14-Sep-2016  pgoyette Sync with HEAD
 1.1.2.1 19-Aug-2016  pgoyette file viovar.h was added on branch pgoyette-localcount on 2016-09-14 03:04:17 +0000
 1.10 14-Dec-2023  andvar Use console_debugger() vs Debugger() which allows to avoid #ifdef DDB blocks.

From uwe@
 1.9 13-Dec-2023  andvar Add #ifdef DDB blocks around Debugger(); calls to make kernel build without DDB.
 1.8 13-Dec-2023  andvar Make NBPFILTER build by adopting NetBSD's bpf_mtap() interface and definitions.
Condition is also not needed, since this check is performed inside function.
 1.7 18-Sep-2022  thorpej Eliminate use of IFF_OACTIVE.
 1.6 11-Feb-2022  riastradh sparc64/vnet(4): device_t/softc split
 1.5 15-Mar-2021  palle branches: 1.5.4;
sun4v: vnet - cleanup of debug code (no functional changes)
 1.4 13-Mar-2021  palle sun4v: vnet - reception and transmission of eternet frames seems to work now (it is possible to ping 8.8.8.8 from inside a sun4v ldom). Still cleanup of debug code to be done.
 1.3 11-Mar-2021  palle sun4v: vnet - reception of ethernet frames seems to work now (WIP and code is still full of debug code)
 1.2 04-Mar-2021  palle sun4v: add vnet driver from openbsd - compiles but probably does not work yet - still WIP (now with NetBSD cvs tag and compiles for 32-bit SUN4U
 1.1 04-Mar-2021  palle sun4v: add vnet driver from openbsd - compiles but probably does not work yet - still WIP
 1.5.4.2 03-Apr-2021  thorpej Sync with HEAD.
 1.5.4.1 15-Mar-2021  thorpej file vnet.c was added on branch thorpej-futex on 2021-04-03 22:28:38 +0000
 1.13 21-Jan-2022  thorpej Don't bother with prom_node_to_devhandle() if we're just forwarding along
our own node; use device_handle(self) instead.
 1.12 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.11 10-May-2021  thorpej branches: 1.11.4;
Associate the OpenBoot / OpenFirmware node with attached devices
at config_found() time.
 1.10 24-Apr-2021  thorpej branches: 1.10.2; 1.10.4;
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 04-Jan-2021  thorpej branches: 1.9.2;
malloc(9) -> kmem(9) -- just the simple, straightforward conversions for now.
 1.8 10-Nov-2019  chs branches: 1.8.8;
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.7 10-May-2016  palle branches: 1.7.16; 1.7.20;
sun4v: make device interrupts work. Introduce a new intrhand_alloc() function for allocation of interrupt handlers and adapt to this. Parts from OpenBSD. ok martin@
 1.6 27-Nov-2015  joerg Shuffle a bit to avoid empty loop body.
 1.5 09-Sep-2015  palle Fixed console logging when booting with -q
 1.4 08-Sep-2015  palle Improve printout duing autoconfiguration
 1.3 06-Sep-2015  nakayama Use <machine/*.h> instead of <sparc64/*.h> for consistency.
 1.2 03-Sep-2015  palle sun4v: iommu setup seems to work now - device detection is now possible - parts from OpenBSD - ok mrg@, martin@
 1.1 12-Feb-2015  palle branches: 1.1.2;
sun4v: vpci driver - initial (and incomplete) version of virtual PCIe host bridge driver for sun4v systems. Based on the NetBSD pyro driver and OpenBSD vpci driver. Future work will include integrating code from the OpenBSD vpci driver.
 1.1.2.5 29-May-2016  skrll Sync with HEAD
 1.1.2.4 27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.1.2.3 22-Sep-2015  skrll Sync with HEAD
 1.1.2.2 06-Apr-2015  skrll Sync with HEAD
 1.1.2.1 12-Feb-2015  skrll file vpci.c was added on branch nick-nhusb on 2015-04-06 15:18:03 +0000
 1.7.20.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.7.16.2 03-Dec-2017  jdolecek update from HEAD
 1.7.16.1 10-May-2016  jdolecek file vpci.c was added on branch tls-maxphys on 2017-12-03 11:36:44 +0000
 1.8.8.1 03-Apr-2021  thorpej Sync with HEAD.
 1.9.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.10.4.1 31-May-2021  cjep sync with head
 1.10.2.1 13-May-2021  thorpej Sync with HEAD.
 1.11.4.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.1 12-Feb-2015  palle branches: 1.1.2; 1.1.18;
sun4v: vpci driver - initial (and incomplete) version of virtual PCIe host bridge driver for sun4v systems. Based on the NetBSD pyro driver and OpenBSD vpci driver. Future work will include integrating code from the OpenBSD vpci driver.
 1.1.18.2 03-Dec-2017  jdolecek update from HEAD
 1.1.18.1 12-Feb-2015  jdolecek file vpcivar.h was added on branch tls-maxphys on 2017-12-03 11:36:44 +0000
 1.1.2.2 06-Apr-2015  skrll Sync with HEAD
 1.1.2.1 12-Feb-2015  skrll file vpcivar.h was added on branch nick-nhusb on 2015-04-06 15:18:03 +0000
 1.5 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.4 07-Sep-2025  thorpej Keep the TODR handle in vrtc_softc.
 1.3 04-Jan-2021  thorpej malloc(9) -> kmem(9) -- just the simple, straightforward conversions for now.
 1.2 10-Nov-2019  chs branches: 1.2.8;
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.1 17-Jun-2016  palle branches: 1.1.2; 1.1.18; 1.1.22;
sun4v: vbus and vrtc drivers - from OpenBSD
 1.1.22.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.1.18.2 03-Dec-2017  jdolecek update from HEAD
 1.1.18.1 17-Jun-2016  jdolecek file vrtc.c was added on branch tls-maxphys on 2017-12-03 11:36:44 +0000
 1.1.2.2 09-Jul-2016  skrll Sync with HEAD
 1.1.2.1 17-Jun-2016  skrll file vrtc.c was added on branch nick-nhusb on 2016-07-09 20:24:57 +0000
 1.2.8.1 03-Apr-2021  thorpej Sync with HEAD.
 1.1 11-May-2020  jdc Add an ebus frontend for the Winbond W83l518D SD card reader as found on
Tadpole SPARCLE latops.
 1.4 05-Sep-1998  pk Remove unused files.
 1.3 13-Aug-1998  eeh Merge paddr_t changes into the main branch.
 1.2 20-Jun-1998  mrg branches: 1.2.2;
moved <machine/sun_disklabel.h> to <dev/sun/disklabel.h>
 1.1 20-Jun-1998  eeh branches: 1.1.1;
Initial revision
 1.1.1.1 20-Jun-1998  eeh Import of sparc64.
 1.2.2.1 30-Jul-1998  eeh Split vm_offset_t and vm_size_t into paddr_t, psize_t, vaddr_t, and vsize_t.
 1.2 05-Sep-1998  pk Remove unused files.
 1.1 20-Jun-1998  eeh branches: 1.1.1;
Initial revision
 1.1.1.1 20-Jun-1998  eeh Import of sparc64.
 1.2 05-Sep-1998  pk Remove unused files.
 1.1 20-Jun-1998  eeh branches: 1.1.1;
Initial revision
 1.1.1.1 20-Jun-1998  eeh Import of sparc64.
 1.2 05-Sep-1998  pk Remove unused files.
 1.1 20-Jun-1998  eeh branches: 1.1.1;
Initial revision
 1.1.1.1 20-Jun-1998  eeh Import of sparc64.
 1.4 05-Sep-1998  pk Remove unused files.
 1.3 13-Aug-1998  eeh Merge paddr_t changes into the main branch.
 1.2 20-Jun-1998  mrg branches: 1.2.2;
moved <machine/sun_disklabel.h> to <dev/sun/disklabel.h>
 1.1 20-Jun-1998  eeh branches: 1.1.1;
Initial revision
 1.1.1.1 20-Jun-1998  eeh Import of sparc64.
 1.2.2.1 30-Jul-1998  eeh Split vm_offset_t and vm_size_t into paddr_t, psize_t, vaddr_t, and vsize_t.
 1.2 05-Sep-1998  pk Remove unused files.
 1.1 20-Jun-1998  eeh branches: 1.1.1;
Initial revision
 1.1.1.1 20-Jun-1998  eeh Import of sparc64.
 1.2 05-Sep-1998  pk Remove unused files.
 1.1 20-Jun-1998  eeh branches: 1.1.1;
Initial revision
 1.1.1.1 20-Jun-1998  eeh Import of sparc64.
 1.81 12-Dec-2023  andvar remove TTY_DEBUG code from sun2/sparc64 zs.c code. it doesn't look relevant
to this particular drivers and likely is a leftover from some historical code.
 1.80 26-Oct-2022  riastradh sparc64/zs(4): Convert to ttylock/ttyunlock.
 1.79 26-Oct-2022  riastradh ddb/db_active.h: New home for extern db_active.

This can be included unconditionally, and db_active can then be
queried unconditionally; if DDB is not in the kernel, then db_active
is a constant zero. Reduces need for #include opt_ddb.h, #ifdef DDB.
 1.78 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.77 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.76 24-Apr-2021  thorpej branches: 1.76.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.75 30-Oct-2015  tsutsui branches: 1.75.32;
Add a missing newline in zs at sbus attach message.
 1.74 27-Oct-2012  chs branches: 1.74.12; 1.74.14; 1.74.16;
split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.73 12-Aug-2011  jdc branches: 1.73.2; 1.73.12;
Use aprint_normal(). From apb@.
 1.72 12-Aug-2011  jdc Add missing new line to zs_attach_fhc()
 1.71 29-Jul-2011  mrg port the openbsd central and fhc drivers, and the clock/zs attachments.
doesn't quite work yet, crashes when central_attach() calls
config_attach() (faulting address is 0xf8000000.)
 1.70 12-Mar-2011  nakayama Remove implicit include <dev/sbus/sbusvar.h> from autoconf.h, and
add it explicitly in files depending on it.
 1.69 26-Oct-2009  martin branches: 1.69.4; 1.69.6;
g/c zssoftpending
 1.68 22-May-2009  mrg add two new functions for z8530tty: zs_chan_lock() and zs_chan_unlock(),
and use them instead of various spl's in the zs.c's.

reviewed by ad and martin.
 1.67 13-Jun-2008  cegger branches: 1.67.6;
use device_lookup_private to get softc
 1.66 28-Apr-2008  martin branches: 1.66.2; 1.66.4;
Remove clause 3 and 4 from TNF licenses
 1.65 29-Mar-2008  tsutsui branches: 1.65.2; 1.65.4;
Split softc and device_t for zsc(4) and its children.

XXX we should restructure MI APIs and make it really machine independent.
 1.64 28-Nov-2007  ad branches: 1.64.14;
Use the softint API.
 1.63 09-Nov-2007  ad Call zs_lock_init() to set up the chanstate's lock.
 1.62 16-Oct-2006  martin branches: 1.62.8; 1.62.26; 1.62.28; 1.62.32; 1.62.34;
Initializers
 1.61 18-Aug-2006  martin branches: 1.61.2; 1.61.4;
Fix wrong prom_getoption() return value checks
 1.60 28-Mar-2006  thorpej branches: 1.60.6;
Use device_is_a().
 1.59 28-Mar-2006  thorpej Use device_unit().
 1.58 13-Feb-2006  cdi branches: 1.58.2; 1.58.4; 1.58.6;
ANSIfy: u_intN_t -> uintN_t, remove __P(), fix function definitions.
 1.57 11-Feb-2006  cdi ANSIfication: u_intN_t -> uintN_t, use ANSI function declarations/definitions
instead of K&R ones.
 1.56 11-Dec-2005  christos branches: 1.56.2; 1.56.4; 1.56.6;
merge ktrace-lwp.
 1.55 19-Jul-2005  macallan use zstty_get_tty_from_dev() instead of using a zstty_softc lookalike hack,
same as in sparc/dev/zs.c
 1.54 21-Mar-2004  pk branches: 1.54.14; 1.54.16;
Use the promlib I/O routines.
 1.53 19-Mar-2004  pk zs_console_flags: use prom_getoption().
 1.52 19-Mar-2004  pk Drop fbnode & stdinnode.
 1.51 17-Mar-2004  pk Rename PROM_getprop*() => prom_getprop*().
 1.50 13-Feb-2004  wiz Uppercase CPU, plural is CPUs.
 1.49 09-Nov-2003  martin Nuke bcopy/bzero.
 1.48 31-Oct-2003  petrov Attach zs to sbus only, current driver cannot attach to mainbus.
 1.47 15-Jul-2003  lukem __KERNEL_RCSID()
 1.46 28-Jan-2003  pk branches: 1.46.2;
Provide locking required by the interrupt handlers running at IPL_SERIAL.
 1.45 01-Jan-2003  thorpej Use aprint_normal() for cfprint routines.
 1.44 10-Dec-2002  pk Remove the `flags' argument from bus_intr_establish().
 1.43 02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.42 01-Oct-2002  thorpej Use CFATTACH_DECL().
 1.41 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.40 27-Sep-2002  provos remove trailing \n in panic(). approved perry.
 1.39 27-Sep-2002  thorpej Rather than referencing the cfdriver directly in the cfdata entries,
instead use a string naming the driver. The cfdriver is then looked
up in a list which is built at run-time.
 1.38 26-Sep-2002  thorpej Compare driver name, don't check against zstty_cd.
 1.37 21-Sep-2002  petrov Use /options instead of /chosen to find out where console is.
(found by Rafal Boni).
 1.36 12-Sep-2002  abs Protect extern zstty_cd with (NKBD > 0) || (NMS > 0)
 1.35 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.34 21-Mar-2002  eeh branches: 1.34.4; 1.34.6;
Add missing semicolon.
 1.33 20-Mar-2002  eeh Overhaul bus space.

bus_space_handle_t now holds an address and two ASIs, one for normal accesses
and one for streaming accesses. This allows to map individual handles
different ways, so some can use MMU bypass accesses and others use virtual
addresses. bus_space_map() will now create handles that use bypass accesses
unles BUS_SPACE_MAP_LINEAR is passed in. So only pass in BUS_SPACE_MAP_LINEAR
if you absolutely *need* to use bus_space_vaddr(). This removes at least one
extra level of indirection and should reduce TLB misses.

32-bit kernels have problems accessing 64-bit addresses, so they always use
virtual addresses.
 1.32 14-Mar-2002  eeh sbus_bus_map() no longer has a preferred vaddr parameter.
 1.31 05-Oct-2001  eeh branches: 1.31.4;
Remove bsd_openprom.h, which is only for compatibility with the sparc port.
 1.30 26-Sep-2001  eeh getprop* -> PROM_getprop*
 1.29 30-May-2001  lukem branches: 1.29.2; 1.29.4;
add missing #include "opt_kgdb.h"
 1.28 03-Dec-2000  fvdl branches: 1.28.2;
Make softintr_establish prototype match other ports, avoiding compile
warnings.
 1.27 10-Nov-2000  mrg remove unused variable
 1.26 09-Nov-2000  eeh Attach the sunkbd line discipline to zstty.
 1.25 10-Jul-2000  eeh Function signature for bus_intr_establish() changed.
 1.24 09-Jul-2000  eeh Upgrate interrupt handling:

1) use interrupt vectors for specific zs chips rather than polling
all of them.

2) use softintr_schedule() and schedule it for a particular device
rather than poll all devices.
 1.23 09-Jul-2000  pk Add a `device class' interrupt level argument (from machine/intr.h)
to bus_interrupt_establish().

It's currently only used in sparc64/dev/psycho.c to assign a CPU interrupt
level to devices in PCI slots.
 1.22 24-Jun-2000  eeh Get rid of vaddrs.h.
 1.21 04-Jun-2000  cgd branches: 1.21.2;
Implement the more flexiable `evcnt' interface as discussed (briefly) on
tech-kern and now documented in evcnt(9).
 1.20 19-May-2000  eeh branches: 1.20.2;
Fix the sparc64 console.

Unlike the other Sun machines, UltraSPARCs can have consoles run on different
chips than zs, so we need to support them. So, here we go:

Add a new PROM console driver with a major number and everything.
This is the default driver if nothing else attaches. It does not
use the keyboard driver since the PROM translates keystrokes itself.
(Unfortunately it also swallows L1-A).

Have the keyboard driver take over the console when it attaches on a
serial port. When a serial port detects a keyboard and attaches the
keyboard driver, it needs to provide a set of consdev vectors. They
keyboard driver will use those to send I/O to the keyboard and mouse.
 1.19 17-May-2000  mrg move zs_attach() to after the setting of the console device, to avoid
having cn_dev being 0 and thus cnopen() being called recursively. this
fixes this problem for zs-based console's only.
 1.18 13-Apr-2000  mrg this does not need auxreg.h
 1.17 10-Apr-2000  pk Get a kernel without DDB to build.
 1.16 08-Apr-2000  mrg include <ddb/db_output.h> to get the db_printf() prototype.
 1.15 16-Mar-2000  eeh Revamp interrupts again:

Fix a bug causing interrmittent panics in interrupt dispatch.
Use interrupt vectors for softints.
Add a new send_softint interface.
Improved D$ flushing.
Improve traptrace and other debugging enhancements.
 1.14 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.13 11-Oct-1999  eeh branches: 1.13.2;
Update to post 1.4.
 1.12 23-May-1999  eeh branches: 1.12.2;
Start putting in hooks for non-zs console devices.
 1.11 25-Apr-1999  eeh Defer final console attach to zs_attach().
 1.10 24-Apr-1999  eeh Deprecate `findzs()' and try to map in the zs registers if they're not mapped
by the prom.
 1.9 27-Mar-1999  wrstuden branches: 1.9.4;
Add pps support. Only enable pps if CLOCAL & !MDMBUF.
 1.8 28-Feb-1999  eeh Let's try to make prom_cnget() work.
 1.7 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.6 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.5 05-Sep-1998  eeh It slices. It dices. It does everything except exec a sparc32_compat init.
 1.4 02-Sep-1998  eeh Periodic update: now starts probing devices.
 1.3 13-Aug-1998  eeh Merge paddr_t changes into the main branch.
 1.2 04-Jul-1998  jonathan branches: 1.2.2;
defopt DDB.
 1.1 20-Jun-1998  eeh branches: 1.1.1;
Initial revision
 1.1.1.1 20-Jun-1998  eeh Import of sparc64.
 1.2.2.1 30-Jul-1998  eeh Split vm_offset_t and vm_size_t into paddr_t, psize_t, vaddr_t, and vsize_t.
 1.9.4.1 21-Jun-1999  thorpej Sync w/ -current.
 1.12.2.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.13.2.3 08-Dec-2000  bouyer Sync with HEAD.
 1.13.2.2 22-Nov-2000  bouyer Sync with HEAD.
 1.13.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.20.2.1 22-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.21.2.1 18-Jul-2000  mrg pullup the contents of -current arch/sparc64. this gives us significant
ultrasparc PCI support (ultra5, ultra10, AXi, and E250 tested so far),
plus many other small fixes. netbooting is now supported.
 1.28.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.29.4.3 11-Oct-2001  fvdl Catch up with -current. Fix some bogons in the sparc64 kbd/ms
attach code. cd18xx conversion provided by mrg.
 1.29.4.2 10-Oct-2001  fvdl Convert all remaining devices.
 1.29.4.1 01-Oct-2001  fvdl Catch up with -current.
 1.29.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.29.2.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.29.2.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.31.4.6 03-Jan-2003  thorpej Sync with HEAD.
 1.31.4.5 11-Dec-2002  thorpej Sync with HEAD.
 1.31.4.4 18-Oct-2002  nathanw Catch up to -current.
 1.31.4.3 17-Sep-2002  nathanw Catch up to -current.
 1.31.4.2 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.31.4.1 05-Oct-2001  nathanw file zs.c was added on branch nathanw_sa on 2002-04-01 07:43:07 +0000
 1.34.6.1 07-Dec-2002  he Pull up revision 1.36 (requested by abs in ticket #890):
Allow sparc64 kernels to be compiled without kbd.
 1.34.4.1 19-May-2002  gehenna Remove hard-coded major.
 1.46.2.4 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.46.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.46.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.46.2.1 03-Aug-2004  skrll Sync with HEAD
 1.54.16.4 07-Dec-2007  yamt sync with head
 1.54.16.3 15-Nov-2007  yamt sync with head.
 1.54.16.2 30-Dec-2006  yamt sync with head.
 1.54.16.1 21-Jun-2006  yamt sync with head.
 1.54.14.1 12-Sep-2006  ghen Pull up following revision(s) (requested by martin in ticket #1507):
sys/arch/sparc64/dev/zs.c: revision 1.61
sys/arch/sparc64/dev/ffb.c: revision 1.28
Fix wrong prom_getoption() return value checks
 1.56.6.1 22-Apr-2006  simonb Sync with head.
 1.56.4.1 09-Sep-2006  rpaulo sync with head
 1.56.2.1 18-Feb-2006  yamt sync with head.
 1.58.6.1 31-Mar-2006  tron Merge 2006-03-31 NetBSD-current into the "peter-altq" branch.
 1.58.4.1 19-Apr-2006  elad sync with head - hopefully this will work
 1.58.2.2 03-Sep-2006  yamt sync with head.
 1.58.2.1 01-Apr-2006  yamt sync with head.
 1.60.6.1 21-Aug-2006  tron Pull up following revision(s) (requested by martin in ticket #34):
sys/arch/sparc64/dev/zs.c: revision 1.61
sys/arch/sparc64/dev/ffb.c: revision 1.28
Fix wrong prom_getoption() return value checks
 1.61.4.1 22-Oct-2006  yamt sync with head
 1.61.2.1 18-Nov-2006  ad Sync with head.
 1.62.34.2 08-Dec-2007  mjf Sync with HEAD.
 1.62.34.1 19-Nov-2007  mjf Sync with HEAD.
 1.62.32.1 13-Nov-2007  bouyer Sync with HEAD
 1.62.28.1 09-Jan-2008  matt sync with HEAD
 1.62.26.2 03-Dec-2007  joerg Sync with HEAD.
 1.62.26.1 11-Nov-2007  joerg Sync with HEAD.
 1.62.8.1 03-Dec-2007  ad Sync with HEAD.
 1.64.14.3 29-Jun-2008  mjf Sync with HEAD.
 1.64.14.2 02-Jun-2008  mjf Sync with HEAD.
 1.64.14.1 03-Apr-2008  mjf Sync with HEAD.
 1.65.4.4 11-Mar-2010  yamt sync with head
 1.65.4.3 20-Jun-2009  yamt sync with head
 1.65.4.2 04-May-2009  yamt sync with head.
 1.65.4.1 16-May-2008  yamt sync with head.
 1.65.2.2 17-Jun-2008  yamt sync with head.
 1.65.2.1 18-May-2008  yamt sync with head.
 1.66.4.1 18-Jun-2008  simonb Sync with head.
 1.66.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.67.6.1 16-Jan-2011  bouyer Pull up following revision(s) (requested by mrg in ticket #1526):
sys/arch/sparc/dev/zs.c: revision 1.115
sys/dev/ic/z8530sc.h: revision 1.26
sys/dev/ic/z8530sc.c: revision 1.30
sys/dev/ic/z8530tty.c: revision 1.127
sys/arch/sparc64/dev/zs.c: revision 1.68
add two new functions for z8530tty: zs_chan_lock() and zs_chan_unlock(),
and use them instead of various spl's in the zs.c's.
reviewed by ad and martin.
 1.69.6.1 06-Jun-2011  jruoho Sync with HEAD.
 1.69.4.1 21-Apr-2011  rmind sync with head
 1.73.12.2 03-Dec-2017  jdolecek update from HEAD
 1.73.12.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.73.2.1 30-Oct-2012  yamt sync with head
 1.74.16.1 26-Dec-2015  snj Pull up following revision(s) (requested by tsutsui in ticket #1050):
sys/arch/sparc64/dev/zs.c: revision 1.75
Add a missing newline in zs at sbus attach message.
 1.74.14.1 27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.74.12.1 26-Dec-2015  snj Pull up following revision(s) (requested by tsutsui in ticket #1050):
sys/arch/sparc64/dev/zs.c: revision 1.75
Add a missing newline in zs at sbus attach message.
 1.75.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.76.8.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.7 17-Jan-2022  andvar fix typos in comments, mainly s/foward/forward/.
 1.6 29-Mar-2008  tsutsui Split softc and device_t for zsc(4) and its children.

XXX we should restructure MI APIs and make it really machine independent.
 1.5 04-Mar-2007  christos branches: 1.5.40;
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 07-Aug-2003  agc branches: 1.3.16;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.2 09-Jul-2000  eeh branches: 1.2.24;
Shuffle around some fields to waste less space on LP64.
 1.1 20-Jun-1998  eeh branches: 1.1.1;
Initial revision
 1.1.1.1 20-Jun-1998  eeh branches: 1.1.1.1.14; 1.1.1.1.24;
Import of sparc64.
 1.1.1.1.24.1 18-Jul-2000  mrg pullup the contents of -current arch/sparc64. this gives us significant
ultrasparc PCI support (ultra5, ultra10, AXi, and E250 tested so far),
plus many other small fixes. netbooting is now supported.
 1.1.1.1.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.2.24.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.2.24.2 18-Sep-2004  skrll Sync with HEAD.
 1.2.24.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.40.1 03-Apr-2008  mjf Sync with HEAD.

RSS XML Feed