Home | History | Annotate | only in /src/sys/arch/sparc/dev
History log of /src/sys/arch/sparc/dev
RevisionDateAuthorComments
 1.1 30-May-2013  macallan branches: 1.1.2; 1.1.10;
install sxreg.h to /usr/include/sparc/
 1.1.10.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.1.10.1 30-May-2013  yamt file Makefile was added on branch yamt-pagecache on 2014-05-22 11:40:08 +0000
 1.1.2.2 23-Jun-2013  tls resync from head
 1.1.2.1 30-May-2013  tls file Makefile was added on branch tls-maxphys on 2013-06-23 06:20:12 +0000
 1.50 13-Jun-2002  gmcgarry Hasn't been used for years.
 1.49 11-Mar-2002  pk branches: 1.49.4;
* `bus_type_t' is gone.
* Use BUS_ADDR() where appropriate to encode I/O space and physical
address offset into a `bus_addr_t' value.
* Drop obio_bus_map() since it's now completely equivalent to bus_space_map()
* Use bus_space_map2() to map device space at a fixed virtual address.
* Remove the virtual address argument from sbus_sbus_addr()
 1.48 03-Oct-2001  augustss branches: 1.48.4;
Add a new optional method, dev_ioctl, to the audio hardware driver interface.
It is called when an unrecognized ioctl() is performed on a device,
thus allowing ioctl()s that frob the hardware driver (like loading
microcode).
 1.47 09-Jul-2000  pk branches: 1.47.2; 1.47.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.46 04-Jun-2000  cgd branches: 1.46.2;
Implement the more flexiable `evcnt' interface as discussed (briefly) on
tech-kern and now documented in evcnt(9).
 1.45 21-Nov-1999  pk branches: 1.45.2;
Check presence of Sbus interrupt properties before using them.
 1.44 14-Mar-1999  jonathan branches: 1.44.8; 1.44.14;
Use bus_space tags and handles, embedded in MD hooks AM7930_{READ_WRITE}_REG
to handle MD delay and bus padding. Tested on sparc2 by David Brownlee.

Should use regmaps, but that breaks sparc pDMA assembly code.
 1.43 13-Jan-1999  abs fix void arithmetic
 1.42 29-Aug-1998  pk Nuke unnecessary header files.
 1.41 28-Aug-1998  pk Nuke Dprintf; fix formats.
 1.40 17-Aug-1998  augustss * Redo the way the way the MIDI driver attaches to audio devices.
* Improve the midisyn layer a little.
* Add a driver for the Yamaha OPL[23] FM synths.
The opl driver is not finished yet; it sounds pretty awful.

For some strange reason I cannot get any FM sound from my SB64 cards,
but a regular SB16 works fine.
 1.39 24-Jun-1998  jonathan Split arch/sparc/dev/amd7930.c into:
* MI sys/dev/ic/{am7930.c,am7930var.h} chipset driver
* sparc frontend.
Presere revision history (this time).

TODO: bus.h'ify, and padded register mappings.
 1.38 07-May-1998  kleink Fix some arithmetics lossage on typeless pointers.
 1.37 30-Mar-1998  pk Replace direct `sparc_bus_map()' calls with bus space map method.
 1.36 21-Mar-1998  pk Account for changed bus attachment scheme.
 1.35 12-Jan-1998  thorpej Update for changes to config.
 1.34 06-Dec-1997  chuck fix mixer code that was clearly untested:
- allow get/set of enums SUNAUDIO_SOURCE and SUNAUDIO_OUTPUT rather
than returning EINVAL
- add missing SUNAUDIO_MONITOR_CLASS case in query_devinfo
- convert SUNAUDIO_MONITOR case from a MIXER_CLASS to a MIXER_VALUE
like it is supposed to be
- the labels for outputs/record class were swapped: fix it

this patch allows "mixerctl" to work properly on a sparc
 1.33 19-Oct-1997  christos branches: 1.33.2;
Make this compile again.
 1.32 19-Oct-1997  augustss Make the audio API (almost) SunOS compatible.
The changes is to allow some limited mixer manipulation through
the audio device (instead of the mixer device).
This rendered 4 methods in audio_hw_if unused so garbage collect these.
 1.31 11-Oct-1997  mycroft AudioC[A-Z] -> AudioC[a-z]
AudioElinear -> AudioEslinear
 1.30 27-Aug-1997  augustss Change match routine to use "audio" as the ROM name.
 1.29 27-Aug-1997  augustss Fix prototype for amd7930_set_params.
 1.28 24-Aug-1997  augustss - Change audio_hw_if a little: set_param now sets the play and record modes
at the same time instead by using two different calls. This enables
it to check more easily if the combined mode is all right.
- Improve the error checking in audio.c.
- Add a new audio property, AUDIO_PROP_INDEPENDENT, show if the
play and record settings are independent.
- Fix some buglets in audio.c.
 1.27 19-Aug-1997  augustss Change the MI audio driver so it attaches to the MD driver in the
normal way. This requires adding a line to the config files to
get audio to work again.
 1.26 31-Jul-1997  augustss Audio changes:
- Change the way attach and open works to allow multiple audio
devices.
- Split the mulaw.c file into two to avoid dragging in mulaw
convertsion when they are not needed. Add 16 bit alaw/mulaw tables.
- Change the way audio properties are gotten.
- Recognize more versions os SoundBlaster.
 1.25 28-Jul-1997  augustss branches: 1.25.2;
Audio: Remove the machine dependant code I put in audio.c by mistake.
This adds another method to audio_hw_if. Also remove a field from
audio_hw_if that was not read-only.
 1.24 27-Jul-1997  augustss audio: Simplify handling of AUDIO_SETFD and committing of encoding mode.
 1.23 27-Jul-1997  augustss Changes to the sudio system:
- It is now possible to handle devices that want "looping" DMA,
e.g. the SoundBlaster correctly. The WSS and SB drivers use this.
To do this several new methods were introduced in audio_hw_if.
- Different silence handling (forced by previous change).
- The audio driver can now be mmap()-ed, but due to problems in
the VM system only for writing for now.
- The OSS (Linux) audio emulation takes advantage of some of the
new features.
 1.22 24-May-1997  pk Remove all `bustype' arguments from map[io]dev() and REG2PHYS().
 1.21 15-May-1997  pk Tweak gain curve (from nsayer@kfu.com; PR#2909)
 1.20 09-May-1997  augustss Change the interface between high and lowlevel audio drivers again:
Set the encoding parameters slightly differently.
Remove the SW encoding/decodinf functions from this interface
and move them to the audio_parameter struct; this is both more efficient
and flexible.
 1.19 07-May-1997  augustss Convert to new orthogonal audio encoding scheme and implement
some of the new encodings. The change to ioctl AUDIO_GETENC is
NOT backwards compatible.
 1.18 29-Apr-1997  augustss Change the interface between the high and low level audio drivers
so that all audio encoding parameters are set at once. This simplifies
the interface and make error checking easier.
 1.17 20-Mar-1997  mycroft Implement set_format.
 1.16 13-Mar-1997  mycroft Don't share the silence block between devices. Make silence filling work for
more encodings, and make it device-independent. From Lennart Augustsson, in
PR kern/3305.
 1.15 10-Dec-1996  pk Comply with recent autoconfiguration changes. Diffs graciously
supplied by Chris Demetriou.
 1.14 01-Nov-1996  pk Drop in a sun4m version of AUDIO_SET_SWINTR; thanks to Nick Sayer for
the reminder.
 1.13 13-Oct-1996  christos backout previous kprintf change
 1.12 11-Oct-1996  christos printf -> kprintf, sprintf -> ksprintf
 1.11 28-May-1996  mrg count audio interupts (from OpenBSD).
 1.10 31-Mar-1996  pk Various cleanup; mostly trailing spaces/tabs.
 1.9 17-Mar-1996  thorpej New device attachment scheme:

- split softc size and match/attach out from cfdriver into
a new struct cfattach.

- new "attach" directive for files.*. May specify the name of
the cfattach structure, so that devices may be easily attached
to parents with different autoconfiguration semantics.
 1.8 14-Mar-1996  christos Bring prototypes into scope and fix compiler warnings.
 1.7 25-Feb-1996  pk Use CPU-type macros
 1.6 19-Feb-1996  pk Fix typo; pointed out by jtk.
 1.5 11-Dec-1995  pk Adapt to changed mapiodev() interface.
 1.4 19-Jul-1995  brezak Change DEBUG-->AUDIO_DEBUG. PR# port-sparc/1241
 1.3 28-Jun-1995  cgd note that most of dev/ic's contents have changed names
 1.2 04-May-1995  pk Add `evcnt' field.
 1.1 25-Apr-1995  pk New audio driver from Rolf Grossmann.
 1.25.2.4 14-Oct-1997  thorpej Update marc-pcmcia branch from trunk.
 1.25.2.3 01-Sep-1997  thorpej Update marc-pcmcia branch from trunk.
 1.25.2.2 27-Aug-1997  thorpej Update marc-pcmcia branch from trunk.
 1.25.2.1 23-Aug-1997  thorpej Update marc-pcmcia branch from trunk.
 1.33.2.1 09-Dec-1997  thorpej Sync w/ trunk: fix mixer code (chuck)
 1.44.14.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.44.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.45.2.1 22-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.46.2.1 19-Jul-2000  mrg pull up sparc/sparc64 bus_intr_establish() changes, necessary for sparc64
(originally done by pk, approved by thorpej):

>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.47.4.3 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.47.4.2 16-Mar-2002  jdolecek Catch up with -current.
 1.47.4.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.47.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.48.4.3 20-Jun-2002  nathanw Catch up to -current.
 1.48.4.2 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.48.4.1 03-Oct-2001  nathanw file am7930_sparc.c was added on branch nathanw_sa on 2002-04-01 07:42:38 +0000
 1.49.4.1 15-Jul-2002  gehenna catch up with -current.
 1.40 24-Aug-1998  pk These files are no longer used.
 1.39 17-Aug-1998  augustss * Redo the way the way the MIDI driver attaches to audio devices.
* Improve the midisyn layer a little.
* Add a driver for the Yamaha OPL[23] FM synths.
The opl driver is not finished yet; it sounds pretty awful.

For some strange reason I cannot get any FM sound from my SB64 cards,
but a regular SB16 works fine.
 1.38 07-May-1998  kleink Fix some arithmetics lossage on typeless pointers.
 1.37 30-Mar-1998  pk Replace direct `sparc_bus_map()' calls with bus space map method.
 1.36 21-Mar-1998  pk Account for changed bus attachment scheme.
 1.35 12-Jan-1998  thorpej Update for changes to config.
 1.34 06-Dec-1997  chuck fix mixer code that was clearly untested:
- allow get/set of enums SUNAUDIO_SOURCE and SUNAUDIO_OUTPUT rather
than returning EINVAL
- add missing SUNAUDIO_MONITOR_CLASS case in query_devinfo
- convert SUNAUDIO_MONITOR case from a MIXER_CLASS to a MIXER_VALUE
like it is supposed to be
- the labels for outputs/record class were swapped: fix it

this patch allows "mixerctl" to work properly on a sparc
 1.33 19-Oct-1997  christos branches: 1.33.2;
Make this compile again.
 1.32 19-Oct-1997  augustss Make the audio API (almost) SunOS compatible.
The changes is to allow some limited mixer manipulation through
the audio device (instead of the mixer device).
This rendered 4 methods in audio_hw_if unused so garbage collect these.
 1.31 11-Oct-1997  mycroft AudioC[A-Z] -> AudioC[a-z]
AudioElinear -> AudioEslinear
 1.30 27-Aug-1997  augustss Change match routine to use "audio" as the ROM name.
 1.29 27-Aug-1997  augustss Fix prototype for amd7930_set_params.
 1.28 24-Aug-1997  augustss - Change audio_hw_if a little: set_param now sets the play and record modes
at the same time instead by using two different calls. This enables
it to check more easily if the combined mode is all right.
- Improve the error checking in audio.c.
- Add a new audio property, AUDIO_PROP_INDEPENDENT, show if the
play and record settings are independent.
- Fix some buglets in audio.c.
 1.27 19-Aug-1997  augustss Change the MI audio driver so it attaches to the MD driver in the
normal way. This requires adding a line to the config files to
get audio to work again.
 1.26 31-Jul-1997  augustss Audio changes:
- Change the way attach and open works to allow multiple audio
devices.
- Split the mulaw.c file into two to avoid dragging in mulaw
convertsion when they are not needed. Add 16 bit alaw/mulaw tables.
- Change the way audio properties are gotten.
- Recognize more versions os SoundBlaster.
 1.25 28-Jul-1997  augustss branches: 1.25.2;
Audio: Remove the machine dependant code I put in audio.c by mistake.
This adds another method to audio_hw_if. Also remove a field from
audio_hw_if that was not read-only.
 1.24 27-Jul-1997  augustss audio: Simplify handling of AUDIO_SETFD and committing of encoding mode.
 1.23 27-Jul-1997  augustss Changes to the sudio system:
- It is now possible to handle devices that want "looping" DMA,
e.g. the SoundBlaster correctly. The WSS and SB drivers use this.
To do this several new methods were introduced in audio_hw_if.
- Different silence handling (forced by previous change).
- The audio driver can now be mmap()-ed, but due to problems in
the VM system only for writing for now.
- The OSS (Linux) audio emulation takes advantage of some of the
new features.
 1.22 24-May-1997  pk Remove all `bustype' arguments from map[io]dev() and REG2PHYS().
 1.21 15-May-1997  pk Tweak gain curve (from nsayer@kfu.com; PR#2909)
 1.20 09-May-1997  augustss Change the interface between high and lowlevel audio drivers again:
Set the encoding parameters slightly differently.
Remove the SW encoding/decodinf functions from this interface
and move them to the audio_parameter struct; this is both more efficient
and flexible.
 1.19 07-May-1997  augustss Convert to new orthogonal audio encoding scheme and implement
some of the new encodings. The change to ioctl AUDIO_GETENC is
NOT backwards compatible.
 1.18 29-Apr-1997  augustss Change the interface between the high and low level audio drivers
so that all audio encoding parameters are set at once. This simplifies
the interface and make error checking easier.
 1.17 20-Mar-1997  mycroft Implement set_format.
 1.16 13-Mar-1997  mycroft Don't share the silence block between devices. Make silence filling work for
more encodings, and make it device-independent. From Lennart Augustsson, in
PR kern/3305.
 1.15 10-Dec-1996  pk Comply with recent autoconfiguration changes. Diffs graciously
supplied by Chris Demetriou.
 1.14 01-Nov-1996  pk Drop in a sun4m version of AUDIO_SET_SWINTR; thanks to Nick Sayer for
the reminder.
 1.13 13-Oct-1996  christos backout previous kprintf change
 1.12 11-Oct-1996  christos printf -> kprintf, sprintf -> ksprintf
 1.11 28-May-1996  mrg count audio interupts (from OpenBSD).
 1.10 31-Mar-1996  pk Various cleanup; mostly trailing spaces/tabs.
 1.9 17-Mar-1996  thorpej New device attachment scheme:

- split softc size and match/attach out from cfdriver into
a new struct cfattach.

- new "attach" directive for files.*. May specify the name of
the cfattach structure, so that devices may be easily attached
to parents with different autoconfiguration semantics.
 1.8 14-Mar-1996  christos Bring prototypes into scope and fix compiler warnings.
 1.7 25-Feb-1996  pk Use CPU-type macros
 1.6 19-Feb-1996  pk Fix typo; pointed out by jtk.
 1.5 11-Dec-1995  pk Adapt to changed mapiodev() interface.
 1.4 19-Jul-1995  brezak Change DEBUG-->AUDIO_DEBUG. PR# port-sparc/1241
 1.3 28-Jun-1995  cgd note that most of dev/ic's contents have changed names
 1.2 04-May-1995  pk Add `evcnt' field.
 1.1 25-Apr-1995  pk New audio driver from Rolf Grossmann.
 1.25.2.4 14-Oct-1997  thorpej Update marc-pcmcia branch from trunk.
 1.25.2.3 01-Sep-1997  thorpej Update marc-pcmcia branch from trunk.
 1.25.2.2 27-Aug-1997  thorpej Update marc-pcmcia branch from trunk.
 1.25.2.1 23-Aug-1997  thorpej Update marc-pcmcia branch from trunk.
 1.33.2.1 09-Dec-1997  thorpej Sync w/ trunk: fix mixer code (chuck)
 1.5 24-Aug-1998  pk These files are no longer used.
 1.4 19-Oct-1997  augustss Make the audio API (almost) SunOS compatible.
The changes is to allow some limited mixer manipulation through
the audio device (instead of the mixer device).
This rendered 4 methods in audio_hw_if unused so garbage collect these.
 1.3 01-Feb-1996  mycroft LOCORE -> _LOCORE
 1.2 04-May-1995  pk Add `evcnt' field.
 1.1 25-Apr-1995  pk New audio driver from Rolf Grossmann.
 1.3 31-May-2025  jdc Set the idle bit for all the CPU's on a multi-processor system. QEMU uses
this to idle all of the emulated CPU's, otherwise only one CPU is idled.
 1.2 30-Dec-2019  ad branches: 1.2.26; 1.2.32;
PR port-sparc/54789: Sparc boot fails with "Trap 0x21 while interrupts disabled"

Remove assumption that cpu_info is smaller than 1kB.
 1.1 15-Jan-2010  bouyer branches: 1.1.2; 1.1.6; 1.1.10; 1.1.70;
Add apc(4), a driver for the Aurora Personality Chip (APC) found
on SPARCstation-4/5, and emulated by qemu to idle the simulator
when the CPU is idle. Infos about the registers from the linux driver.
Not enabled by default because it can cause some Sparc systems to
hang (so says the linux driver).
Only the CPU idle part implemented at this time; fan speed and
Convenience power outlet management to be added.
Tested on qemu.
 1.1.70.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.1.10.2 21-Apr-2010  matt sync to netbsd-5
 1.1.10.1 15-Jan-2010  matt file apc.c was added on branch matt-nb5-mips64 on 2010-04-21 00:33:47 +0000
 1.1.6.2 11-Mar-2010  yamt sync with head
 1.1.6.1 15-Jan-2010  yamt file apc.c was added on branch yamt-nfs-mp on 2010-03-11 15:02:56 +0000
 1.1.2.2 27-Jan-2010  sborrill Pull up the following revisions(s) (requested by bouyer in ticket #1248):
sys/arch/sparc/conf/GENERIC: revision 1.219
sys/arch/sparc/conf/files.sparc: revision 1.149
sys/arch/sparc/dev/apc.c: revision 1.1
sys/arch/sparc/dev/apcreg.h: revision 1.1
sys/dev/DEVNAMES: revision 1.255

Add apc(4), a driver for the Aurora Personality Chip (APC) found
on SPARCstation-4/5, and emulated by qemu to idle the simulator
when the CPU is idle. Infos about the registers from the linux driver.
Not enabled by default because it can cause some Sparc systems to
hang (so says the linux driver).
Only the CPU idle part implemented at this time; fan speed and
Convenience power outlet management to be added.
Tested on qemu.
 1.1.2.1 15-Jan-2010  sborrill file apc.c was added on branch netbsd-5 on 2010-01-27 21:17:55 +0000
 1.2.32.1 02-Aug-2025  perseant Sync with HEAD
 1.2.26.1 20-Oct-2025  martin Pull up following revision(s) (requested by jdc in ticket #1181):

sys/arch/sparc/dev/apc.c: revision 1.3

Set the idle bit for all the CPU's on a multi-processor system. QEMU uses
this to idle all of the emulated CPU's, otherwise only one CPU is idled.
 1.1 15-Jan-2010  bouyer branches: 1.1.2; 1.1.6; 1.1.10;
Add apc(4), a driver for the Aurora Personality Chip (APC) found
on SPARCstation-4/5, and emulated by qemu to idle the simulator
when the CPU is idle. Infos about the registers from the linux driver.
Not enabled by default because it can cause some Sparc systems to
hang (so says the linux driver).
Only the CPU idle part implemented at this time; fan speed and
Convenience power outlet management to be added.
Tested on qemu.
 1.1.10.2 21-Apr-2010  matt sync to netbsd-5
 1.1.10.1 15-Jan-2010  matt file apcreg.h was added on branch matt-nb5-mips64 on 2010-04-21 00:33:47 +0000
 1.1.6.2 11-Mar-2010  yamt sync with head
 1.1.6.1 15-Jan-2010  yamt file apcreg.h was added on branch yamt-nfs-mp on 2010-03-11 15:02:56 +0000
 1.1.2.2 27-Jan-2010  sborrill Pull up the following revisions(s) (requested by bouyer in ticket #1248):
sys/arch/sparc/conf/GENERIC: revision 1.219
sys/arch/sparc/conf/files.sparc: revision 1.149
sys/arch/sparc/dev/apc.c: revision 1.1
sys/arch/sparc/dev/apcreg.h: revision 1.1
sys/dev/DEVNAMES: revision 1.255

Add apc(4), a driver for the Aurora Personality Chip (APC) found
on SPARCstation-4/5, and emulated by qemu to idle the simulator
when the CPU is idle. Infos about the registers from the linux driver.
Not enabled by default because it can cause some Sparc systems to
hang (so says the linux driver).
Only the CPU idle part implemented at this time; fan speed and
Convenience power outlet management to be added.
Tested on qemu.
 1.1.2.1 15-Jan-2010  sborrill file apcreg.h was added on branch netbsd-5 on 2010-01-27 21:17:55 +0000
 1.30 12-Sep-2020  isaki Improve am7930 family drivers to share more code.
audioamd(4) on sparc, vsaudio(4) on vax, and bba(4) are.
- Remove complex and useless callbacks: onopen, onclose, and
indirect_{read,write}. This makes audioamd and vsaudio almost the same.
- Remove (already disabled) assembly fast interrupt path from audioamd(4).
cf. http://mail-index.netbsd.org/source-changes/2009/12/19/msg004585.html
- Use trigger_* method rather than start_* method. It's more suitable.
vsaudio(4) was tested by naru@, bba(4) was tested by tsutsui@.
 1.29 08-May-2019  isaki branches: 1.29.2;
Merge isaki-audio2 branch, the overhaul of audio subsystem.
- Interrupt-oriented system rather than thread-oriented.
- Improve stability, quality and performance.
- Split playback and record cleanly. Improve halfduplex support.
- Many bugs are fixed including deadlocks, resource leaks, abuses, etc.
- Simplify audio filter mechanism. The encoding/channels/frequency
conversions are completely handled in the upper layer. So the hard-
ware driver only converts its hardware encoding (if necessary).
- audio_hw_if changes:
- Obsoletes query_encoding and add query_format instead.
- Obsoletes set_params and add set_format instead.
- Remove drain, setfd, mappage.
- The call sequences are changed.
- ioctl AUDIO_GETFD/SETFD, AUDIO_GETCHAN/SETCHAN are obsoleted.
- ioctl AUDIO_{QUERY,GET,SET}FORMAT are introduced.
- cleanup config attributes: au*conv and mulaw.
- All hardware drivers should follow it (I've done as much as possible).

Some file paths are changed:
- dev/audio.c -> dev/audio/audio.c (rewritten)
- dev/audiovar.h -> dev/audio/audiovar.h
- dev/audio_dai.h -> dev/audio/audio_dai.h
- dev/audio_if.h -> dev/audio/audio_if.h
- dev/audiobell.c -> dev/audio/audiobell.c
- dev/audiobellvar.h -> dev/audio/audiobellvar.h
- dev/mulaw.[ch] -> dev/audio/mulaw.[ch] + dev/audio/alaw.c
 1.28 16-Mar-2019  isaki branches: 1.28.2;
Use C99 style struct initializer to audio_hw_if.
 1.27 23-Nov-2011  jmcneill branches: 1.27.50;
Merge jmcneill-audiomp3 branch, which is derived from ad-audiomp2. From
the original ad-audiomp branch notes:

Add MP locking to the audio drivers.

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

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

Welcome to 5.99.57.
 1.26 04-Jun-2011  tsutsui branches: 1.26.2; 1.26.4;
Split device_t/softc of am7930. No crash on TME and GXemul.
 1.25 19-Dec-2009  tsutsui branches: 1.25.4; 1.25.6; 1.25.10;
Disable "fast trap" handlers which invoke software interrupts
in sparc/amd7930intr.s and sparc/bsd_fdintr.s until they are
rewritten to adapt new MI softint(9) API.

No particular comments on PR port-sparc/42192, but
this fixes timeout problem on floppy access on my SPARCstation 1+.

XXX: floppy support on sun4m seems to have another problem (data overrun).
 1.24 17-Sep-2009  tsutsui Use device_t, cfdriver_t, device_private(), device_xname(),
and appropriate types and variables for device_t/softc.
 1.23 03-Dec-2007  ad branches: 1.23.18; 1.23.28; 1.23.36;
Interrupt handling changes, in discussion since February:

- Reduce available SPL levels for hardware devices to none, vm, sched, high.
- Acquire kernel_lock only for interrupts at IPL_VM.
- Implement threaded soft interrupts.
 1.22 27-Nov-2007  ad Use the softint API.
 1.21 11-Dec-2005  christos branches: 1.21.28; 1.21.30; 1.21.48; 1.21.50; 1.21.56;
merge ktrace-lwp.
 1.20 15-Jan-2005  kent branches: 1.20.10;
ansify and KNF
 1.19 29-Oct-2004  yamt constify audio_hw_if, midi_hw_if, and radio_hw_if.
 1.18 11-Jul-2004  mycroft Make this build again.
 1.17 15-Jul-2003  lukem __KERNEL_RCSID()
 1.16 10-Dec-2002  pk branches: 1.16.6;
Remove the `flags' argument from bus_intr_establish().
 1.15 10-Dec-2002  pk The `fast trap' handlers are now pssed as an optional argument to
bus_intr_establish(). Allow fall-back on a regular interrupt handler if
the interrupt level must be shared with another device.
 1.14 09-Dec-2002  pk Finish the switch to the softintr(9) framework.

To make this work, we now have to use separate handler lists for hardware
and software interrupts as the soft interrupt handlers do not return
an `interrupt handled' status.

Thanks to Matt Fredette for providing an initial set of patches on port-sparc.
 1.13 15-Oct-2002  jdc Add audioamd at obio attachment. Now we have working audio on 4/600's :

audioamd0 at obio0 slot 0 offset 0x500000 level 13 softpri 4
audio0 at audioamd0: full duplex
 1.12 02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.11 01-Oct-2002  thorpej Use CFATTACH_DECL().
 1.10 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.9 13-Jun-2002  gmcgarry Make this work with AUDIO_C_HANDLER.
 1.8 11-Mar-2002  pk branches: 1.8.4; 1.8.6;
* `bus_type_t' is gone.
* Use BUS_ADDR() where appropriate to encode I/O space and physical
address offset into a `bus_addr_t' value.
* Drop obio_bus_map() since it's now completely equivalent to bus_space_map()
* Use bus_space_map2() to map device space at a fixed virtual address.
* Remove the virtual address argument from sbus_sbus_addr()
 1.7 03-Oct-2001  augustss branches: 1.7.4;
Add a new optional method, dev_ioctl, to the audio hardware driver interface.
It is called when an unrecognized ioctl() is performed on a device,
thus allowing ioctl()s that frob the hardware driver (like loading
microcode).
 1.6 09-Jul-2000  pk branches: 1.6.2; 1.6.4; 1.6.6;
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 06-Jun-2000  gmcgarry branches: 1.5.2;
- Clean up use of AUDIO_C_HANDLER.
- Copy bus_space handles into auio for fast handler.
 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 08-May-2000  mycroft branches: 1.3.2;
Make the audioamd assembler code compile again.
 1.2 08-May-2000  mycroft Make the SPARC audioamd driver at least *compile*. Well, the C code, that is.
*sigh*
 1.1 02-May-2000  augustss Adapt to new am7930 driver. PR 10033 from Gregory McGarry.
 1.3.2.1 22-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.5.2.1 19-Jul-2000  mrg pull up sparc/sparc64 bus_intr_establish() changes, necessary for sparc64
(originally done by pk, approved by thorpej):

>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.6.6.4 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.6.6.3 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.6.6.2 16-Mar-2002  jdolecek Catch up with -current.
 1.6.6.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.6.4.1 11-Oct-2001  fvdl Catch up with -current. Fix some bogons in the sparc64 kbd/ms
attach code. cd18xx conversion provided by mrg.
 1.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 09-Jul-2000  bouyer file audioamd.c was added on branch thorpej_scsipi on 2000-11-20 20:25:30 +0000
 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 20-Jun-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 03-Oct-2001  nathanw file audioamd.c was added on branch nathanw_sa on 2002-04-01 07:42:38 +0000
 1.8.6.1 24-Jun-2002  lukem Pull up revision 1.9 (requested by pk in ticket #357):
Make this work with AUDIO_C_HANDLER.
 1.8.4.1 15-Jul-2002  gehenna catch up with -current.
 1.16.6.5 17-Jan-2005  skrll Sync with HEAD.
 1.16.6.4 02-Nov-2004  skrll Sync with HEAD.
 1.16.6.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.16.6.2 18-Sep-2004  skrll Sync with HEAD.
 1.16.6.1 03-Aug-2004  skrll Sync with HEAD
 1.20.10.1 07-Dec-2007  yamt sync with head
 1.21.56.1 08-Dec-2007  mjf Sync with HEAD.
 1.21.50.1 09-Jan-2008  matt sync with HEAD
 1.21.48.2 09-Dec-2007  jmcneill Sync with HEAD.
 1.21.48.1 03-Dec-2007  joerg Sync with HEAD.
 1.21.30.1 03-Dec-2007  ad Sync with HEAD.
 1.21.28.1 27-Feb-2007  ad Add MP locking for audio drivers.
 1.23.36.1 21-Apr-2010  matt sync to netbsd-5
 1.23.28.1 23-Jan-2010  bouyer Pull up following revision(s) (requested by tsutsui in ticket #1251):
sys/arch/sparc/sparc/auxreg.h: revision 1.13
distrib/sparc/ramdisk/dot.profile: revision 1.20
sys/arch/sparc/dev/audioamd.c: revision 1.25
sys/arch/sparc/dev/fd.c: revision 1.147
sys/arch/sparc/stand/common/promdev.c: revision 1.23
distrib/sparc/miniroot/Makefile.inc: revision 1.16
Build miniroot binaries for sparc with -Os to shrink instfs.tgz
for the second boot floppy which use miniroot objects.
This is workaround for PR install/42146, and ok'ed by mrg@.
Don't try to read disklabel to check FS_RAID on floppy boot since
reopening floppy could cause Data Access Exception later.
Fixes PR port-sparc/42186, ok'ed by mrg@.
Disable "fast trap" handlers which invoke software interrupts
in sparc/amd7930intr.s and sparc/bsd_fdintr.s until they are
rewritten to adapt new MI softint(9) API.
No particular comments on PR port-sparc/42192, but
this fixes timeout problem on floppy access on my SPARCstation 1+.
XXX: floppy support on sun4m seems to have another problem (data overrun).
Use /dev/fd0a rather than /dev/rfd0a to read instfs.tgz image from floppy.
It looks newer (appearred after 1.6) gzip tries to read less than DEV_BSIZE
(to check header?) so we can't use raw device directly.
(note sparc bootfs ramdisk doesn't have dd(1))
Workaround for PR port-sparc/42193, and would also fix PR install/28734.
Explicitly clear AUXIO4M_FTC bit in FTC_FLIP macro used on
pseudo-dma for floppy, as well as AUXIO4C_FTC bit for sun4c.
A comment in the macro says AUXIO4M_FTC bit is auto-clear,
but my two SS20s (including compatible) with 150MHz hyperSPARCs
get data_overrun without it, and no bad side effect on SS5
(works with and without this change).
Closes PR port-sparc/42516, which is the last one of a bunch of
floppy issue on NetBSD/sparc since NetBSD 2.0 days. See
http://mail-index.NetBSD.org/port-sparc/2009/12/20/msg000484.html
for details.
 1.23.18.1 11-Mar-2010  yamt sync with head
 1.25.10.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.25.6.1 06-Jun-2011  jruoho Sync with HEAD.
 1.25.4.1 12-Jun-2011  rmind sync with head
 1.26.4.3 22-Nov-2011  jmcneill get rid of unused 'powerstate' callback in audio_hw_if
 1.26.4.2 20-Nov-2011  mrg use the sc_intr_lock when calling the rint/tint functions.
 1.26.4.1 20-Nov-2011  mrg port the am7930 drivers to audiomp. sparc and pmax GENERIC builds,
but i am unable to test these drivers.
 1.26.2.1 17-Apr-2012  yamt sync with head
 1.27.50.1 10-Jun-2019  christos Sync with HEAD
 1.28.2.2 04-May-2019  isaki Move dev/audio_if.h -> dev/audio/audio_if.h
 1.28.2.1 22-Apr-2019  isaki Adapt am7930 families to audio2.
- Remove {input/output}_conv stuff from am7930_glue.
Filter pipelines for user encoding are not necessary in audio2
so the driver only needs to handle its hardware encoding.
- audioamd/vsaudio use an ordinal linear-mulaw conversion filter
and bba requires special one. dev/audio/mulaw.c supports this
variant just for bba. It might not a good way for bba but it
keeps all other drivers simple.
- Tested on vsaudio(4) by naru@, bba(4) by tsutsui@ (a few months ago).
Thanks!
 1.29.2.1 31-Mar-2021  martin Apply patch, requested by tsutsui in ticket #1239:

sys/arch/sparc/dev/audioamd.c (apply patch)

Fix for PR 56078 (different solution applied to -current): fix wrong
lock usage.
 1.5 12-Sep-2020  isaki Improve am7930 family drivers to share more code.
audioamd(4) on sparc, vsaudio(4) on vax, and bba(4) are.
- Remove complex and useless callbacks: onopen, onclose, and
indirect_{read,write}. This makes audioamd and vsaudio almost the same.
- Remove (already disabled) assembly fast interrupt path from audioamd(4).
cf. http://mail-index.netbsd.org/source-changes/2009/12/19/msg004585.html
- Use trigger_* method rather than start_* method. It's more suitable.
vsaudio(4) was tested by naru@, bba(4) was tested by tsutsui@.
 1.4 11-Dec-2005  christos merge ktrace-lwp.
 1.3 15-Jan-2005  kent ansify and KNF
 1.2 08-May-2000  mycroft branches: 1.2.6; 1.2.30;
Fix the RCS tag format. Duh.
 1.1 08-May-2000  mycroft Make the audioamd assembler code compile again.
 1.2.30.1 17-Jan-2005  skrll Sync with HEAD.
 1.2.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.2.6.1 08-May-2000  bouyer file audioamdvar.h was added on branch thorpej_scsipi on 2000-11-20 20:25:30 +0000
 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 22-Nov-2020  thorpej branches: 1.20.2;
malloc(9) -> kmem(9) (easy, straight-forward cases only, for now)
 1.19 18-Jul-2011  mrg branches: 1.19.66;
convert the remaining sparc drivers to CFATTACH_DECL_NEW/cfdata_t/device_t.
(cgsix_obio.c was only partially converted with the rest of the cgsix code
when it was changed some time ago.)
 1.18 01-Jul-2011  dyoung #include <sys/bus.h> instead of <machine/bus.h>.
 1.17 20-Sep-2009  tsutsui - use device_t and cfdriver_t
- use device_private() and device_xname()
- use proper types or variables for device_t/softc
 1.16 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.15 11-Dec-2005  christos branches: 1.15.74; 1.15.76; 1.15.78;
merge ktrace-lwp.
 1.14 26-Aug-2005  drochner s/locdesc_t/int/g
 1.13 28-Jun-2005  drochner branches: 1.13.2;
convert remaining autoconf bus "submatch" functions to use the new
signature (passing locators), and remove some which obviously don't
serve any purpose
(untested, sorry)
 1.12 17-Mar-2004  pk Rename PROM_getprop*() => prom_getprop*().
 1.11 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.10 15-Jul-2003  lukem __KERNEL_RCSID()
 1.9 01-Jan-2003  thorpej branches: 1.9.2;
Use aprint_normal() for cfprint routines.
 1.8 02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.7 01-Oct-2002  thorpej Use CFATTACH_DECL().
 1.6 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.5 27-Sep-2002  thorpej Introduce a new routine, config_match(), which invokes the
cfattach->ca_match function in behalf of the caller. Use it
rather than invoking cfattach->ca_match directly.
 1.4 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.3 25-Aug-2002  thorpej branches: 1.3.2; 1.3.4; 1.3.6;
Put a bus's ranges in the bus space tag, and make sparc_bus_map()
perform the translation and recursion if t->ranges != NULL. Make
sbus, cpuunit, and bootbus inherit the parent's map/mmap routines,
and delete the now-unused mapping functions. Update all places where
bus space tags are statically allocated.
 1.2 25-Aug-2002  thorpej Add a generic function to translate a device address using a
parent's "ranges" property, and use it.
 1.1 24-Aug-2002  thorpej Add autoconfiguration support for the Sun4d "bootbus". Add a
zs @ bootbus attachment.
 1.3.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.3.6.2 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.3.6.1 25-Aug-2002  jdolecek file bootbus.c was added on branch kqueue on 2002-09-06 08:40:48 +0000
 1.3.4.2 31-Aug-2002  gehenna catch up with -current.
 1.3.4.1 25-Aug-2002  gehenna file bootbus.c was added on branch gehenna-devsw on 2002-08-31 14:52:13 +0000
 1.3.2.4 03-Jan-2003  thorpej Sync with HEAD.

XXX ALT_SWITCH_CODE is not yet LWP'ified.
 1.3.2.3 18-Oct-2002  nathanw Catch up to -current.
 1.3.2.2 27-Aug-2002  nathanw Catch up to -current.
 1.3.2.1 25-Aug-2002  nathanw file bootbus.c was added on branch nathanw_sa on 2002-08-27 23:45:27 +0000
 1.9.2.4 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 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.13.2.1 21-Jun-2006  yamt sync with head.
 1.15.78.2 11-Mar-2010  yamt sync with head
 1.15.78.1 16-May-2008  yamt sync with head.
 1.15.76.1 18-May-2008  yamt sync with head.
 1.15.74.1 02-Jun-2008  mjf Sync with HEAD.
 1.19.66.1 14-Dec-2020  thorpej Sync w/ HEAD.
 1.20.2.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.20.2.1 22-Mar-2021  thorpej Mechanical conversion of config_found_sm_loc() -> config_found().
CFARG_IATTR usage needs to be audited.
 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.2 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.1 24-Aug-2002  thorpej branches: 1.1.2; 1.1.4; 1.1.6; 1.1.114; 1.1.116; 1.1.118;
Add autoconfiguration support for the Sun4d "bootbus". Add a
zs @ bootbus attachment.
 1.1.118.1 16-May-2008  yamt sync with head.
 1.1.116.1 18-May-2008  yamt sync with head.
 1.1.114.1 02-Jun-2008  mjf Sync with HEAD.
 1.1.6.2 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.1.6.1 24-Aug-2002  jdolecek file bootbusvar.h was added on branch kqueue on 2002-09-06 08:40:48 +0000
 1.1.4.2 31-Aug-2002  gehenna catch up with -current.
 1.1.4.1 24-Aug-2002  gehenna file bootbusvar.h was added on branch gehenna-devsw on 2002-08-31 14:52:13 +0000
 1.1.2.2 27-Aug-2002  nathanw Catch up to -current.
 1.1.2.1 24-Aug-2002  nathanw file bootbusvar.h was added on branch nathanw_sa on 2002-08-27 23:45:27 +0000
 1.10 25-Apr-1995  pk New audio driver from Rolf Grossmann.
 1.9 04-Mar-1995  pk Move SunOS audio_info compat to <compat/sunos/sunos_ioctl.c>.
 1.8 02-Mar-1995  pk Rename audio*() functions to avoid conflicts with sys/dev/audio.c; this is an
emergency measure, driver needs to be converted to generic audio subsystem.
 1.7 23-Nov-1994  deraadt XXmatch change (and a few __P() as well)
 1.6 20-Nov-1994  deraadt copyright/Id cleanup
 1.5 02-Nov-1994  deraadt ioctl u_long cmd
 1.4 15-Oct-1994  deraadt mapiodev takes a bustype argument now
 1.3 02-Oct-1994  deraadt sun4/300 support works
 1.2 17-Sep-1994  deraadt sbus/* --> dev/*
deal with multiple bus types (start of vme/obio support)
 1.1 02-Oct-1993  deraadt Chris Torek's sparc port. Missing lots of things.
 1.3 25-Apr-1995  pk New audio driver from Rolf Grossmann.
 1.2 20-Nov-1994  deraadt copyright/Id cleanup
 1.1 02-Oct-1993  deraadt Chris Torek's sparc port. Missing lots of things.
 1.3 25-Apr-1995  pk New audio driver from Rolf Grossmann.
 1.2 20-Nov-1994  deraadt copyright/Id cleanup
 1.1 02-Oct-1993  deraadt Chris Torek's sparc port. Missing lots of things.
 1.13 22-Aug-2000  pk Use the framebuffer drivers & header files that now live in /sys/dev/sun.
 1.12 29-Jun-2000  mrg remove include of <vm/vm.h> and <machine/pmap.h>. <vm/vm.h> -> <uvm/uvm_extern.h>
 1.11 16-Apr-2000  pk branches: 1.11.4;
Switch initial colormap setup again to be compatible with the PROM's,
i.e. background at index 0: white, foreground at index 255: black.

Also, allocate a slice for an ANSI colormap, so we can experiment
with coloured text on the bare console.
 1.10 04-Apr-2000  pk Use copyin/copyout to get a colormap from/to user space.
Also, prepare for the case of a colormap maintained in kernel space.
 1.9 26-Aug-1999  thorpej branches: 1.9.2;
Initialize the default colormap to 0 == black, all others == full white.
 1.8 24-Mar-1999  mrg completely remove Mach VM support. all that is left is the all the
header files as UVM still uses (most of) these.
 1.7 10-Feb-1998  mrg - add defopt's for UVM, UVMHIST and PMAP_NEW.
- remove unnecessary UVMHIST_DECL's.
 1.6 05-Feb-1998  mrg initial import of the new virtual memory system, UVM, into -current.

UVM was written by chuck cranor <chuck@maria.wustl.edu>, with some
minor portions derived from the old Mach code. i provided some help
getting swap and paging working, and other bug fixes/ideas. chuck
silvers <chuq@chuq.com> also provided some other fixes.

this is the sparc portion.

this will be KNF'd shortly. :-)
 1.5 14-Mar-1996  christos Bring prototypes into scope and fix compiler warnings.
 1.4 20-Nov-1994  deraadt copyright/Id cleanup
 1.3 17-Sep-1994  deraadt sbus/* --> dev/*
deal with multiple bus types (start of vme/obio support)
 1.2 29-Nov-1993  deraadt fbio.h is in machine/
 1.1 11-Nov-1993  deraadt from torek:
new brooktree dac code
hacked cgthree code
new cgsix (ala GX) code
 1.9.2.1 20-Nov-2000  bouyer Remove files that are no longer on the trunck
 1.11.4.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.5 22-Aug-2000  pk Use the framebuffer drivers & header files that now live in /sys/dev/sun.
 1.4 27-Feb-1996  thorpej branches: 1.4.30;
First-cut support for P4 framebuffers. Currently supports P4 variants
of bwtwo, cgfour, cgsix, and cgeight. Includes support for attaching
the overlay plane of the cgfour and cgeight as a bwtwo instance (a'la
SunOS).

P4 register descriptions, cgfour driver, and cgeight driver partially
derived from OpenBSD.

This code may still need polishing.
 1.3 27-Feb-1996  pk Define a couple more framebuffer control bits.
 1.2 20-Nov-1994  deraadt copyright/Id cleanup
 1.1 11-Nov-1993  deraadt from torek:
new brooktree dac code
hacked cgthree code
new cgsix (ala GX) code
 1.4.30.1 20-Nov-2000  bouyer Remove files that are no longer on the trunck
 1.5 22-Aug-2000  pk Use the framebuffer drivers & header files that now live in /sys/dev/sun.
 1.4 04-Apr-2000  pk Use copyin/copyout to get a colormap from/to user space.
Also, prepare for the case of a colormap maintained in kernel space.
 1.3 26-Aug-1999  thorpej branches: 1.3.2;
Initialize the default colormap to 0 == black, all others == full white.
 1.2 20-Nov-1994  deraadt copyright/Id cleanup
 1.1 11-Nov-1993  deraadt from torek:
new brooktree dac code
hacked cgthree code
new cgsix (ala GX) code
 1.3.2.1 20-Nov-2000  bouyer Remove files that are no longer on the trunck
 1.46 22-Aug-2000  pk Use the framebuffer drivers & header files that now live in /sys/dev/sun.
 1.45 29-Jun-2000  mrg remove include of <vm/vm.h> and <machine/pmap.h>. <vm/vm.h> -> <uvm/uvm_extern.h>
 1.44 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.43 19-Mar-2000  pk branches: 1.43.4;
Use fb_is_console(); retract fbconstty & fbnode from service.
 1.42 10-Aug-1999  christos branches: 1.42.2;
split bwtwo driver in sbus and obio parts.
 1.41 19-May-1999  pk Turn on the video timing which is not always done by the PROM (e.g. if we're
not the console).
 1.40 07-Sep-1998  pk branches: 1.40.8;
Need to cast sbus attach `prom_vaddrs' field.
 1.39 29-Jul-1998  pk Deal with sbus attach args changes.
 1.38 07-Apr-1998  pk bus_space_mmap() has changed to take a `bus_space_handle_t *' argument,
like other bus space methods.
 1.37 29-Mar-1998  pk obio_bus_probe() => bus_space_probe()
 1.36 21-Mar-1998  pk Account for changed bus attachment scheme.
 1.35 12-Jan-1998  thorpej Update for changes to config.
 1.34 05-Oct-1997  thorpej Copyright assigned to The NetBSD Foundation.
 1.33 24-May-1997  pk branches: 1.33.4;
Remove all `bustype' arguments from map[io]dev() and REG2PHYS().
 1.32 10-Dec-1996  pk Comply with recent autoconfiguration changes. Diffs graciously
supplied by Chris Demetriou.
 1.31 20-Oct-1996  pk Make sure to refer to `sc_ovtype' only when SUN4 is defined, as noted
by `r.evans@ic.ac.uk'.
Also, explicitly testwhether we're dealing with a pfour.
 1.30 13-Oct-1996  christos backout previous kprintf change
 1.29 11-Oct-1996  christos printf -> kprintf, sprintf -> ksprintf
 1.28 04-Oct-1996  thorpej Returning ENODEV is not correct in a poll entry point. Instead, since
read/write returns an error, use seltrue().
 1.27 20-Sep-1996  thorpej Don't attach an rcons to a cgfour/cgeight overlay plane; it doesn't work
properly. Problem reported by Charles Hannum.

XXX This is temporary until someone with the hardware has time to fix it!
 1.26 01-Apr-1996  christos branches: 1.26.4;
Eliminated dependencies on dev_conf.h
 1.25 31-Mar-1996  pk Various cleanup; mostly trailing spaces/tabs.
 1.24 17-Mar-1996  thorpej New device attachment scheme:

- split softc size and match/attach out from cfdriver into
a new struct cfattach.

- new "attach" directive for files.*. May specify the name of
the cfattach structure, so that devices may be easily attached
to parents with different autoconfiguration semantics.
 1.23 14-Mar-1996  christos Bring prototypes into scope and fix compiler warnings.
 1.22 27-Feb-1996  thorpej First-cut support for P4 framebuffers. Currently supports P4 variants
of bwtwo, cgfour, cgsix, and cgeight. Includes support for attaching
the overlay plane of the cgfour and cgeight as a bwtwo instance (a'la
SunOS).

P4 register descriptions, cgfour driver, and cgeight driver partially
derived from OpenBSD.

This code may still need polishing.
 1.21 27-Feb-1996  pk `bwtworeg' is just about the same as the generic `fbcontrol'.
 1.20 25-Feb-1996  pk Use CPU-type macros.
 1.19 19-Feb-1996  thorpej Fix bug in bwtwounblank() ... didn't have code to enable video on sun4/200
obio framebuffer. Noticed when my 4/260 dropped into DDB and the screen
didn't unblank. Pull all of the video enable/disable into functions so
this mishap doesn't happen again.
 1.18 11-Dec-1995  pk Adapt to changed mapiodev() interface.
 1.17 29-Nov-1995  pk Code from Jason to better configure /dev/fb.
 1.16 23-Oct-1995  pk On-board bwtwo diddles a system enable register bit for video, per Jason
Thorpe (PR#1672).
 1.15 09-Oct-1995  pk branches: 1.15.2;
RASTERCONS now works on sun4's too.
 1.14 08-Oct-1995  pk Patch from Jason to factor out a common framebuffer size determination
routine from the individual drivers.
 1.13 05-Oct-1995  pk Do not set `ra_len' in bwtwomatch(); we only need the pixels for CONSOLE,
but if so, we need the lot.
 1.12 04-Oct-1995  pk RCONSOLE => RASTERCONSOLE.
 1.11 17-Sep-1995  pk Change interface to th `fb' pseudo device to not need the major device
number (a la sun3).
Put in new glue for rcons.
 1.10 29-Aug-1995  pk Support for sun4 (from Jason Thorpe).
 1.9 10-Apr-1995  mycroft map --> mmap
 1.8 17-Feb-1995  pk match/attach on sun4's obio bus, from Theo.
 1.7 20-Nov-1994  deraadt copyright/Id cleanup
 1.6 02-Nov-1994  deraadt ioctl u_long cmd
 1.5 15-Oct-1994  deraadt mapiodev takes a bustype argument now
 1.4 17-Sep-1994  deraadt sbus/* --> dev/*
deal with multiple bus types (start of vme/obio support)
 1.3 04-Jul-1994  deraadt need vm/vm.h
 1.2 11-Oct-1993  deraadt bwtwo.c, cgthree.c: sys-fbio.h -> machine/fbio.h
if_le.c: #ifdef MULTICAST some things, and do arp the old way
 1.1 02-Oct-1993  deraadt Chris Torek's sparc port. Missing lots of things.
 1.15.2.1 16-Feb-1996  thorpej Pull in improved framebuffer autoconfiguration code from -current.
Prevents panics when multiple framebuffers are found on sun4 systems.
 1.26.4.2 02-Mar-1997  pk From trunk:
> Make sure to refer to `sc_ovtype' only when SUN4 is defined
 1.26.4.1 10-Dec-1996  mycroft From trunk:
Disable rcons for now.
 1.33.4.1 14-Oct-1997  thorpej Update marc-pcmcia branch from trunk.
 1.40.8.1 21-Jun-1999  thorpej Sync w/ -current.
 1.42.2.1 20-Nov-2000  bouyer Remove files that are no longer on the trunck
 1.43.4.1 30-Jun-2000  simonb Pull up mmap paddr_t/off_t changes from trunk.
 1.18 20-Dec-2023  thorpej Remove unnecessary <sys/malloc.h>.
 1.17 19-Sep-2009  tsutsui Split device_t/softc.
Tested on TME emulating SS2.

XXX: bwtwo at obmem on TME emulating sun2 didn't match and cannot test
 1.16 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.15 29-Mar-2006  thorpej branches: 1.15.62; 1.15.64; 1.15.66;
Use device_cfdata().
 1.14 16-Nov-2005  uwe branches: 1.14.4; 1.14.6; 1.14.8; 1.14.10; 1.14.12;
ANSIify function declarations/defintions. Use uint<N>_t.
Propagate "static" to function definitions. Drop trailing whitespace.
Same binary code is produced for GENERIC.MP + KGDB + DDB.
 1.13 03-Jun-2005  tsutsui branches: 1.13.2; 1.13.8;
Add const.
 1.12 04-Dec-2003  keihan NetBSD.ORG -> NetBSD.org

Now all "NetBSD.ORG" are gone from src/sys.
 1.11 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.10 15-Jul-2003  lukem __KERNEL_RCSID()
 1.9 02-Oct-2002  thorpej branches: 1.9.6;
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 06-Sep-2002  gehenna Merge the gehenna-devsw branch into the trunk.

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

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

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

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

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

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

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

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

- In compile time, device major numbers list is packed into the kernel and
the LKM framework will refer it to assign device major number dynamically.
 1.5 11-Mar-2002  pk branches: 1.5.4;
* `bus_type_t' is gone.
* Use BUS_ADDR() where appropriate to encode I/O space and physical
address offset into a `bus_addr_t' value.
* Drop obio_bus_map() since it's now completely equivalent to bus_space_map()
* Use bus_space_map2() to map device space at a fixed virtual address.
* Remove the virtual address argument from sbus_sbus_addr()
 1.4 22-Aug-2000  pk branches: 1.4.4; 1.4.8;
Use the framebuffer drivers & header files that now live in /sys/dev/sun.
 1.3 29-Jun-2000  mrg remove include of <vm/vm.h> and <machine/pmap.h>. <vm/vm.h> -> <uvm/uvm_extern.h>
 1.2 19-Mar-2000  pk Use fb_is_console(); retract fbconstty & fbnode from service.
 1.1 10-Aug-1999  christos branches: 1.1.2;
split bwtwo driver in sbus and obio parts.
 1.1.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.4.8.3 18-Oct-2002  nathanw Catch up to -current.
 1.4.8.2 17-Sep-2002  nathanw Catch up to -current.
 1.4.8.1 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.4.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.4.4.1 16-Mar-2002  jdolecek Catch up with -current.
 1.5.4.1 19-May-2002  gehenna Remove unnecessary #include
 1.9.6.5 11-Dec-2005  christos Sync with head.
 1.9.6.4 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.9.6.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.9.6.2 18-Sep-2004  skrll Sync with HEAD.
 1.9.6.1 03-Aug-2004  skrll Sync with HEAD
 1.13.8.1 22-Nov-2005  yamt sync with head.
 1.13.2.1 21-Jun-2006  yamt sync with head.
 1.14.12.1 31-Mar-2006  tron Merge 2006-03-31 NetBSD-current into the "peter-altq" branch.
 1.14.10.1 19-Apr-2006  elad sync with head - hopefully this will work
 1.14.8.1 01-Apr-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.15.66.2 11-Mar-2010  yamt sync with head
 1.15.66.1 16-May-2008  yamt sync with head.
 1.15.64.1 18-May-2008  yamt sync with head.
 1.15.62.1 02-Jun-2008  mjf Sync with HEAD.
 1.4 22-Aug-2000  pk Use the framebuffer drivers & header files that now live in /sys/dev/sun.
 1.3 29-Jun-2000  mrg remove include of <vm/vm.h> and <machine/pmap.h>. <vm/vm.h> -> <uvm/uvm_extern.h>
 1.2 19-Mar-2000  pk Use fb_is_console(); retract fbconstty & fbnode from service.
 1.1 10-Aug-1999  christos branches: 1.1.2;
split bwtwo driver in sbus and obio parts.
 1.1.2.1 20-Nov-2000  bouyer Remove files that are no longer on the trunck
 1.4 22-Aug-2000  pk Use the framebuffer drivers & header files that now live in /sys/dev/sun.
 1.3 27-Feb-1996  pk branches: 1.3.30;
`bwtworeg' is just about the same as the generic `fbcontrol'.
 1.2 20-Nov-1994  deraadt copyright/Id cleanup
 1.1 02-Oct-1993  deraadt Chris Torek's sparc port. Missing lots of things.
 1.3.30.1 20-Nov-2000  bouyer Remove files that are no longer on the trunck
 1.3 22-Aug-2000  pk Use the framebuffer drivers & header files that now live in /sys/dev/sun.
 1.2 19-Mar-2000  pk Use fb_is_console(); retract fbconstty & fbnode from service.
 1.1 10-Aug-1999  christos branches: 1.1.2;
split bwtwo driver in sbus and obio parts.
 1.1.2.1 20-Nov-2000  bouyer Remove files that are no longer on the trunck
 1.51 20-Dec-2023  thorpej Remove unnecessary <sys/malloc.h>.
 1.50 18-Oct-2014  snj src is too big these days to tolerate superfluous apostrophes. It's
"its", people!
 1.49 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.48 16-Mar-2014  dholland branches: 1.48.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.47 18-Jul-2011  mrg branches: 1.47.2; 1.47.12; 1.47.16;
convert to use device_t, cfdata_t and CFATTACH_DECL_NEW().

XXX: compile time tested only.
 1.46 11-Jun-2008  drochner mechanical changes to use device_private() or device_lookup_private()
to get softcs, makes the code compile under the stricter type checking
introduced earlier today
 1.45 28-Apr-2008  martin branches: 1.45.2; 1.45.4;
Remove clause 3 and 4 from TNF licenses
 1.44 04-Mar-2007  christos branches: 1.44.40; 1.44.42; 1.44.44;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.43 29-Mar-2006  thorpej branches: 1.43.14;
Use device_cfdata().
 1.42 11-Dec-2005  christos branches: 1.42.4; 1.42.6; 1.42.8; 1.42.10; 1.42.12;
merge ktrace-lwp.
 1.41 16-Nov-2005  uwe ANSIify function declarations/defintions. Use uint<N>_t.
Propagate "static" to function definitions. Drop trailing whitespace.
Same binary code is produced for GENERIC.MP + KGDB + DDB.
 1.40 10-Dec-2003  agc branches: 1.40.16; 1.40.24;
Modify the licences of code written by Theo De Raadt from a 4-clause
to a 2-clause licence (retaining UCB clauses (1) and (2)), per PR
22409 from Joel Baker, approved by Theo de Raadt, and ratified by
myself - the only discrepancy being the handling of the original
clause 3 in src/usr.sbin/yppoll/yppoll.c.
 1.39 04-Dec-2003  keihan NetBSD.ORG -> NetBSD.org

Now all "NetBSD.ORG" are gone from src/sys.
 1.38 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.37 24-Aug-2003  uwe #include "opt_rcons.h"
 1.36 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.35 15-Jul-2003  lukem __KERNEL_RCSID()
 1.34 29-Jun-2003  fvdl branches: 1.34.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.33 29-Jun-2003  darrenr More changes for providing lwpid for ktrace (sparc GENERIC built)
 1.32 02-Apr-2003  thorpej Use PAGE_SIZE rather than NBPG.
 1.31 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.30 02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.29 01-Oct-2002  thorpej Use CFATTACH_DECL().
 1.28 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.27 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.26 11-Mar-2002  pk branches: 1.26.4;
* `bus_type_t' is gone.
* Use BUS_ADDR() where appropriate to encode I/O space and physical
address offset into a `bus_addr_t' value.
* Drop obio_bus_map() since it's now completely equivalent to bus_space_map()
* Use bus_space_map2() to map device space at a fixed virtual address.
* Remove the virtual address argument from sbus_sbus_addr()
 1.25 24-Sep-2001  eeh branches: 1.25.4;
Change bus_space_mmap() signature to the official one.
 1.24 22-Aug-2000  pk branches: 1.24.2; 1.24.4;
Use the framebuffer drivers & header files that now live in /sys/dev/sun.
 1.23 29-Jun-2000  mrg remove include of <vm/vm.h> and <machine/pmap.h>. <vm/vm.h> -> <uvm/uvm_extern.h>
 1.22 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.21 04-Apr-2000  pk branches: 1.21.4;
Use copyin/copyout to get a colormap from/to user space.
Also, prepare for the case of a colormap maintained in kernel space.
 1.20 19-Mar-2000  pk Use fb_is_console(); retract fbconstty & fbnode from service.
 1.19 19-Nov-1998  mrg branches: 1.19.10;
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.18 07-Apr-1998  pk bus_space_mmap() has changed to take a `bus_space_handle_t *' argument,
like other bus space methods.
 1.17 29-Mar-1998  pk obio_bus_probe() => bus_space_probe()
 1.16 21-Mar-1998  pk Account for changed bus attachment scheme.
 1.15 12-Jan-1998  thorpej Update for changes to config.
 1.14 05-Oct-1997  thorpej branches: 1.14.2;
Copyright assigned to The NetBSD Foundation.
 1.13 24-May-1997  pk branches: 1.13.4;
Remove all `bustype' arguments from map[io]dev() and REG2PHYS().
 1.12 10-Dec-1996  pk Comply with recent autoconfiguration changes. Diffs graciously
supplied by Chris Demetriou.
 1.11 13-Oct-1996  christos backout previous kprintf change
 1.10 11-Oct-1996  christos printf -> kprintf, sprintf -> ksprintf
 1.9 04-Oct-1996  thorpej Returning ENODEV is not correct in a poll entry point. Instead, since
read/write returns an error, use seltrue().
 1.8 25-Aug-1996  thorpej Correct mistakes similar to those made in cgfour.c: Log message from
cgfour.c:

Fix a typo and an error in color plane offset calculation. Submitted by
Konrad Schroder <perseant@hitl.washington.edu>, PR #2695.
 1.7 01-Apr-1996  christos Eliminated dependencies on dev_conf.h
 1.6 31-Mar-1996  pk Re-arrange a bit to stear clear of gcc `-Wall' bites.
 1.5 17-Mar-1996  thorpej New device attachment scheme:

- split softc size and match/attach out from cfdriver into
a new struct cfattach.

- new "attach" directive for files.*. May specify the name of
the cfattach structure, so that devices may be easily attached
to parents with different autoconfiguration semantics.
 1.4 16-Mar-1996  christos This could have never worked (fb in attach was never initialized); include <sys/systm.h>
 1.3 14-Mar-1996  christos Bring prototypes into scope and fix compiler warnings.
 1.2 28-Feb-1996  thorpej Oops...missed to places where I could have used CPU type macros.
 1.1 27-Feb-1996  thorpej First-cut support for P4 framebuffers. Currently supports P4 variants
of bwtwo, cgfour, cgsix, and cgeight. Includes support for attaching
the overlay plane of the cgfour and cgeight as a bwtwo instance (a'la
SunOS).

P4 register descriptions, cgfour driver, and cgeight driver partially
derived from OpenBSD.

This code may still need polishing.
 1.13.4.1 14-Oct-1997  thorpej Update marc-pcmcia branch from trunk.
 1.14.2.1 23-Nov-1998  cgd Fix many real and potential security problems with character device
driver mmap routines that did not properly bounds check offsets.
See NetBSD security advisory NetBSD-SA1998-005 for details. Done
as a patch because it's large, and a fair number of bits are different
in -current. (mrg)
 1.19.10.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.21.4.1 30-Jun-2000  simonb Pull up mmap paddr_t/off_t changes from trunk.
 1.24.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.24.4.4 28-Jun-2002  jdolecek hook fbkqfilter to leaf drivers' kqfilter
 1.24.4.3 28-Jun-2002  jdolecek prove kqfilter hook; it's very simple equivalent of seltrue()
 1.24.4.2 16-Mar-2002  jdolecek Catch up with -current.
 1.24.4.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.24.2.2 10-Oct-2001  fvdl Convert all remaining devices.
 1.24.2.1 01-Oct-2001  fvdl Catch up with -current.
 1.25.4.5 11-Nov-2002  nathanw Catch up to -current
 1.25.4.4 18-Oct-2002  nathanw Catch up to -current.
 1.25.4.3 17-Sep-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 24-Sep-2001  nathanw file cgeight.c was added on branch nathanw_sa on 2002-04-01 07:42:39 +0000
 1.26.4.1 17-May-2002  gehenna Add device switch.
 1.34.2.5 11-Dec-2005  christos Sync with head.
 1.34.2.4 04-Feb-2005  skrll Adapt to branch.
 1.34.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.34.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.34.2.1 03-Aug-2004  skrll Sync with HEAD
 1.40.24.1 22-Nov-2005  yamt sync with head.
 1.40.16.2 03-Sep-2007  yamt sync with head.
 1.40.16.1 21-Jun-2006  yamt sync with head.
 1.42.12.1 31-Mar-2006  tron Merge 2006-03-31 NetBSD-current into the "peter-altq" branch.
 1.42.10.1 19-Apr-2006  elad sync with head - hopefully this will work
 1.42.8.1 01-Apr-2006  yamt sync with head.
 1.42.6.1 22-Apr-2006  simonb Sync with head.
 1.42.4.1 09-Sep-2006  rpaulo sync with head
 1.43.14.1 12-Mar-2007  rmind Sync with HEAD.
 1.44.44.2 04-May-2009  yamt sync with head.
 1.44.44.1 16-May-2008  yamt sync with head.
 1.44.42.2 17-Jun-2008  yamt sync with head.
 1.44.42.1 18-May-2008  yamt sync with head.
 1.44.40.2 29-Jun-2008  mjf Sync with HEAD.
 1.44.40.1 02-Jun-2008  mjf Sync with HEAD.
 1.45.4.1 18-Jun-2008  simonb Sync with head.
 1.45.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.47.16.1 18-May-2014  rmind sync with head
 1.47.12.2 03-Dec-2017  jdolecek update from HEAD
 1.47.12.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.47.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.48.2.1 10-Aug-2014  tls Rebase.
 1.51 20-Dec-2023  thorpej Remove unnecessary <sys/malloc.h>.
 1.50 18-Oct-2014  snj src is too big these days to tolerate superfluous apostrophes. It's
"its", people!
 1.49 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.48 16-Mar-2014  dholland branches: 1.48.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.47 27-Oct-2012  chs branches: 1.47.2;
split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.46 18-Jul-2011  mrg branches: 1.46.2; 1.46.12;
convert to use device_t, cfdata_t and CFATTACH_DECL_NEW().

XXX: compile time tested only.
 1.45 11-Jun-2008  drochner mechanical changes to use device_private() or device_lookup_private()
to get softcs, makes the code compile under the stricter type checking
introduced earlier today
 1.44 28-Apr-2008  martin branches: 1.44.2; 1.44.4;
Remove clause 3 and 4 from TNF licenses
 1.43 04-Mar-2007  christos branches: 1.43.40; 1.43.42; 1.43.44;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.42 29-Mar-2006  thorpej branches: 1.42.14;
Use device_cfdata().
 1.41 11-Dec-2005  christos branches: 1.41.4; 1.41.6; 1.41.8; 1.41.10; 1.41.12;
merge ktrace-lwp.
 1.40 16-Nov-2005  uwe ANSIify function declarations/defintions. Use uint<N>_t.
Propagate "static" to function definitions. Drop trailing whitespace.
Same binary code is produced for GENERIC.MP + KGDB + DDB.
 1.39 10-Dec-2003  agc branches: 1.39.16; 1.39.24;
Modify the licences of code written by Theo De Raadt from a 4-clause
to a 2-clause licence (retaining UCB clauses (1) and (2)), per PR
22409 from Joel Baker, approved by Theo de Raadt, and ratified by
myself - the only discrepancy being the handling of the original
clause 3 in src/usr.sbin/yppoll/yppoll.c.
 1.38 04-Dec-2003  keihan NetBSD.ORG -> NetBSD.org

Now all "NetBSD.ORG" are gone from src/sys.
 1.37 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.36 24-Aug-2003  uwe #include "opt_rcons.h"
 1.35 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.34 15-Jul-2003  lukem __KERNEL_RCSID()
 1.33 29-Jun-2003  fvdl branches: 1.33.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.32 29-Jun-2003  darrenr More changes for providing lwpid for ktrace (sparc GENERIC built)
 1.31 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.30 02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.29 01-Oct-2002  thorpej Use CFATTACH_DECL().
 1.28 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.27 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.26 11-Mar-2002  pk branches: 1.26.4;
* `bus_type_t' is gone.
* Use BUS_ADDR() where appropriate to encode I/O space and physical
address offset into a `bus_addr_t' value.
* Drop obio_bus_map() since it's now completely equivalent to bus_space_map()
* Use bus_space_map2() to map device space at a fixed virtual address.
* Remove the virtual address argument from sbus_sbus_addr()
 1.25 24-Sep-2001  eeh branches: 1.25.4;
Change bus_space_mmap() signature to the official one.
 1.24 22-Aug-2000  pk branches: 1.24.2; 1.24.4;
Use the framebuffer drivers & header files that now live in /sys/dev/sun.
 1.23 29-Jun-2000  mrg remove include of <vm/vm.h> and <machine/pmap.h>. <vm/vm.h> -> <uvm/uvm_extern.h>
 1.22 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.21 04-Apr-2000  pk branches: 1.21.4;
Use copyin/copyout to get a colormap from/to user space.
Also, prepare for the case of a colormap maintained in kernel space.
 1.20 19-Mar-2000  pk Use fb_is_console(); retract fbconstty & fbnode from service.
 1.19 19-Nov-1998  mrg branches: 1.19.10;
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.18 07-Apr-1998  pk bus_space_mmap() has changed to take a `bus_space_handle_t *' argument,
like other bus space methods.
 1.17 29-Mar-1998  pk obio_bus_probe() => bus_space_probe()
 1.16 21-Mar-1998  pk Account for changed bus attachment scheme.
 1.15 12-Jan-1998  thorpej Update for changes to config.
 1.14 05-Oct-1997  thorpej branches: 1.14.2;
Copyright assigned to The NetBSD Foundation.
 1.13 24-May-1997  pk branches: 1.13.4;
Remove all `bustype' arguments from map[io]dev() and REG2PHYS().
 1.12 10-Dec-1996  pk Comply with recent autoconfiguration changes. Diffs graciously
supplied by Chris Demetriou.
 1.11 13-Oct-1996  christos backout previous kprintf change
 1.10 11-Oct-1996  christos printf -> kprintf, sprintf -> ksprintf
 1.9 04-Oct-1996  thorpej Returning ENODEV is not correct in a poll entry point. Instead, since
read/write returns an error, use seltrue().
 1.8 13-Aug-1996  thorpej Fix a typo and an error in color plane offset calculation. Submitted by
Konrad Schroder <perseant@hitl.washington.edu>, PR #2695.
 1.7 01-Apr-1996  christos branches: 1.7.4;
Eliminated dependencies on dev_conf.h
 1.6 31-Mar-1996  pk Re-arrange a bit to stear clear of gcc `-Wall' bites.
 1.5 17-Mar-1996  thorpej New device attachment scheme:

- split softc size and match/attach out from cfdriver into
a new struct cfattach.

- new "attach" directive for files.*. May specify the name of
the cfattach structure, so that devices may be easily attached
to parents with different autoconfiguration semantics.
 1.4 16-Mar-1996  christos include <sys/systm.h>
 1.3 14-Mar-1996  christos Bring prototypes into scope and fix compiler warnings.
 1.2 28-Feb-1996  thorpej Oops...missed to places where I could have used CPU type macros.
 1.1 27-Feb-1996  thorpej First-cut support for P4 framebuffers. Currently supports P4 variants
of bwtwo, cgfour, cgsix, and cgeight. Includes support for attaching
the overlay plane of the cgfour and cgeight as a bwtwo instance (a'la
SunOS).

P4 register descriptions, cgfour driver, and cgeight driver partially
derived from OpenBSD.

This code may still need polishing.
 1.7.4.1 10-Dec-1996  mycroft From trunk:
Fix plane offset calculation.
 1.13.4.1 14-Oct-1997  thorpej Update marc-pcmcia branch from trunk.
 1.14.2.1 23-Nov-1998  cgd Fix many real and potential security problems with character device
driver mmap routines that did not properly bounds check offsets.
See NetBSD security advisory NetBSD-SA1998-005 for details. Done
as a patch because it's large, and a fair number of bits are different
in -current. (mrg)
 1.19.10.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.21.4.1 30-Jun-2000  simonb Pull up mmap paddr_t/off_t changes from trunk.
 1.24.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.24.4.4 28-Jun-2002  jdolecek hook fbkqfilter to leaf drivers' kqfilter
 1.24.4.3 28-Jun-2002  jdolecek prove kqfilter hook; it's very simple equivalent of seltrue()
 1.24.4.2 16-Mar-2002  jdolecek Catch up with -current.
 1.24.4.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.24.2.2 10-Oct-2001  fvdl Convert all remaining devices.
 1.24.2.1 01-Oct-2001  fvdl Catch up with -current.
 1.25.4.5 11-Nov-2002  nathanw Catch up to -current
 1.25.4.4 18-Oct-2002  nathanw Catch up to -current.
 1.25.4.3 17-Sep-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 24-Sep-2001  nathanw file cgfour.c was added on branch nathanw_sa on 2002-04-01 07:42:39 +0000
 1.26.4.1 17-May-2002  gehenna Add device switch.
 1.33.2.5 11-Dec-2005  christos Sync with head.
 1.33.2.4 04-Feb-2005  skrll Adapt to branch.
 1.33.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.33.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.33.2.1 03-Aug-2004  skrll Sync with HEAD
 1.39.24.1 22-Nov-2005  yamt sync with head.
 1.39.16.2 03-Sep-2007  yamt sync with head.
 1.39.16.1 21-Jun-2006  yamt sync with head.
 1.41.12.1 31-Mar-2006  tron Merge 2006-03-31 NetBSD-current into the "peter-altq" branch.
 1.41.10.1 19-Apr-2006  elad sync with head - hopefully this will work
 1.41.8.1 01-Apr-2006  yamt sync with head.
 1.41.6.1 22-Apr-2006  simonb Sync with head.
 1.41.4.1 09-Sep-2006  rpaulo sync with head
 1.42.14.1 12-Mar-2007  rmind Sync with HEAD.
 1.43.44.2 04-May-2009  yamt sync with head.
 1.43.44.1 16-May-2008  yamt sync with head.
 1.43.42.2 17-Jun-2008  yamt sync with head.
 1.43.42.1 18-May-2008  yamt sync with head.
 1.43.40.2 29-Jun-2008  mjf Sync with HEAD.
 1.43.40.1 02-Jun-2008  mjf Sync with HEAD.
 1.44.4.1 18-Jun-2008  simonb Sync with head.
 1.44.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.46.12.3 03-Dec-2017  jdolecek update from HEAD
 1.46.12.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.46.12.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.46.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.46.2.1 30-Oct-2012  yamt sync with head
 1.47.2.1 18-May-2014  rmind sync with head
 1.48.2.1 10-Aug-2014  tls Rebase.
 1.99 25-Sep-2024  macallan some minor nits:
- clarify 16bit colour table construction a bit
- print some more hw info
- fix WSDISPLAYIO_GVIDEO
 1.98 12-May-2024  macallan branches: 1.98.2;
support 16bit / RGB565 colour
 1.97 24-Apr-2024  macallan allow userland to switch to 16bit colour
 1.96 20-Dec-2023  thorpej Remove unnecessary <sys/malloc.h>.
 1.95 13-Jun-2023  macallan - use sx_wait() to avoid stalling the MBus
- request 32bit alignment for glyphcache cells
 1.94 23-May-2023  macallan use macros compatible with xf86-video-suncg14 to issue SX instructions
much more readable, alignment weirdness is handled automatically and code is
interchangable
 1.93 25-May-2022  macallan branches: 1.93.4;
be lazy about clearing the cursor since most likely we're going to overwrite
it anyway. Same logic as in cgsix.
 1.92 17-Dec-2021  macallan only write the mask register if we're actually changing it
 1.91 17-Dec-2021  macallan cg14_invert():
- use only 32bit accesses
- use byte mask / ROPs for partial writes
 1.90 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.89 24-Apr-2021  thorpej branches: 1.89.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.88 11-Aug-2019  macallan branches: 1.88.10;
remove orphaned comment
 1.87 17-Jan-2019  macallan don't crash when we're not the console
 1.86 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.85 25-Jan-2018  macallan branches: 1.85.2; 1.85.4;
do boundary checks when writing cursor sprite colour registers
 1.84 12-Jan-2018  macallan enable font loading
 1.83 06-Jan-2018  macallan support underlines
 1.82 16-Sep-2016  macallan wipe glyph cache as needed when re-entering text mode
now the console is readable again when leaving X
 1.81 02-Jun-2016  macallan branches: 1.81.2;
use DEFATTR if we're not the console and can't init defattr.
should appease clang
TODO: we should really init the glyphcache whith the first screen
 1.80 30-Apr-2016  macallan support anti-aliased fonts, glyphcache etc.
 1.79 25-Jul-2014  dholland branches: 1.79.4;
Add d_discard to all struct cdevsw instances I could find.

All have been set to "nodiscard"; some should get a real implementation.
 1.78 23-Apr-2014  macallan rev. 27 SX needs memory referencing instructions written to 64bit aligned
addresses ( my rev. 25 just ignores the lower 3 bits )
so, we zero these bits now
 1.77 16-Mar-2014  dholland branches: 1.77.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.76 14-Aug-2013  macallan comments & whitespace police
 1.75 04-Jun-2013  macallan branches: 1.75.2;
report actual VRAM size in fb_type.fb_size
 1.74 04-Jun-2013  macallan actually map the whole SX IO space instead of just the first page over and
over again (doh)
 1.73 29-May-2013  macallan allow userland to map SX registers and IO space
 1.72 12-Feb-2013  macallan break some more long lines
 1.71 07-Feb-2013  macallan - implement buttom-up copies in cg14_bitblt() so scrolling down works now
- use more registers when copying
- use hardware to draw the cursor
- use putchar() for horizontal scrolling since byte-wise overlapping copy
ops wouldn't be any faster anyway
 1.70 06-Feb-2013  macallan use SX for basic hardware acceleration
not quite complete yet but good enough to be useful
missing things include:
- backwards blits
- ROP support
- the cursor is still drawn by software
 1.69 05-Feb-2013  macallan throw out RASTERCONSOLE goo
 1.68 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.67 11-Jan-2012  macallan branches: 1.67.6;
use rasops_init(0, 0)
 1.66 13-Apr-2011  macallan branches: 1.66.4; 1.66.8;
use the same function whenever we change colour depth
also, when opening the fb device switch to 32bit and back to 8 on close, not
the other way around
 1.65 31-Aug-2010  macallan branches: 1.65.2;
remove shadow framebuffer support, use VCONS_DONT_READ instead
 1.64 10-Jun-2010  macallan Add a couple more hw offset definitions, add an ioctl() to set colour depth
which works like Solaris and Linux, and finally make mmap() behave like an
actual CG14. This should be all we need to get Xorg's suncg14 driver going.
 1.63 08-Jun-2010  macallan get rid of the cg3/cg8 'emulation' kludge since we have the xf86-video-suncg14
driver now
this will probably need some work in cgfourteenmmap() to match what the
driver expects from a cg14
 1.62 27-Aug-2009  macallan branches: 1.62.2; 1.62.4;
use vcons_replay_msgbuf()
 1.61 14-Jul-2009  apb Enclose the argument to #error in quotes, to protect an embedded single
quote. Part of PR 41255 from Kurt Lidl.
 1.60 26-May-2009  macallan use BUS_SPACE_MAP_LARGE to map the framebuffer
 1.59 16-May-2009  cegger KNF, same object code generated
 1.58 16-Apr-2009  macallan use sparc_bus_map_large() to map the framebuffer if we can't find a PROM
mapping - now we won't exhaust the IODEV range and thus prevent other graphics
devices from working.
 1.57 18-Mar-2009  cegger bcopy -> memcpy
 1.56 05-Feb-2009  macallan branches: 1.56.2;
Recycle OBP's framebuffer mapping if available instead of wasting KVA space
by creating our own.
 1.55 12-Dec-2008  macallan some cleanup, add shadowfb support
 1.54 13-Jun-2008  cegger branches: 1.54.4;
use device_lookup_private to get softc
 1.53 17-May-2008  macallan branches: 1.53.2;
struct device * -> device_t
 1.52 17-Oct-2007  garbled branches: 1.52.16; 1.52.18; 1.52.20; 1.52.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.51 19-Aug-2007  jdc branches: 1.51.2;
Also print a new line if we are not the console.
 1.50 30-Jul-2007  macallan branches: 1.50.2;
add hardware cursor support
 1.49 30-Jul-2007  macallan add wsdisplay support for cg14
The console will run in 8bit but switch to 32bit in mapped mode so XFree86
with wsfb can run in 24bit colour.
 1.48 04-Mar-2007  christos branches: 1.48.2; 1.48.10; 1.48.12; 1.48.14;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.47 23-Nov-2006  elad branches: 1.47.4;
Always #undef CG14_MAP_REGS, since it opens a security hole (as the comment
says) and should be used only for debugging.

Okay mouse@, christos@.
 1.46 29-Mar-2006  thorpej branches: 1.46.8; 1.46.10;
Use device_cfdata().
 1.45 04-Mar-2006  uwe branches: 1.45.2; 1.45.4; 1.45.6;
s/u_intN_t/uintN_t/
 1.44 19-Jan-2006  he branches: 1.44.2; 1.44.4;
Wrap the definition of cg14_set_rcons_luts() in an #ifdef RASTERCONSOLE,
to allow the INSTALL kernel to build, as it's unused there.
 1.43 19-Jan-2006  he Make this compile again by ensuring that we don't cast away the volatile
qualifier.
 1.42 17-Jan-2006  christos PR/32552: Antonio Bravo: cgfourteen 24-bit support
Original code from der Mouse, posted to the mailing lists by Jakob Menzi.
 1.41 11-Dec-2005  christos branches: 1.41.2;
merge ktrace-lwp.
 1.40 16-Nov-2005  uwe ANSIify function declarations/defintions. Use uint<N>_t.
Propagate "static" to function definitions. Drop trailing whitespace.
Same binary code is produced for GENERIC.MP + KGDB + DDB.
 1.39 04-Jun-2005  tsutsui branches: 1.39.2; 1.39.8;
Fix for gcc -Wcast-qual.
 1.38 13-Nov-2003  chs eliminate uvm_useracc() in favor of checking the return value of
copyin() or copyout().

uvm_useracc() tells us whether the mapping permissions allow access to
the desired part of an address space, and many callers assume that
this is the same as knowing whether an attempt to access that part of
the address space will succeed. however, access to user space can
fail for reasons other than insufficient permission, most notably that
paging in any non-resident data can fail due to i/o errors. most of
the callers of uvm_useracc() make the above incorrect assumption. the
rest are all misguided optimizations, which optimize for the case
where an operation will fail. we'd rather optimize for operations
succeeding, in which case we should just attempt the access and handle
failures due to insufficient permissions the same way we handle i/o
errors. since there appear to be no good uses of uvm_useracc(), we'll
just remove it.
 1.37 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.36 24-Aug-2003  uwe #include "opt_rcons.h"
 1.35 15-Jul-2003  lukem __KERNEL_RCSID()
 1.34 29-Jun-2003  fvdl branches: 1.34.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.33 29-Jun-2003  darrenr More changes for providing lwpid for ktrace (sparc GENERIC built)
 1.32 02-Apr-2003  thorpej Use PAGE_SIZE rather than NBPG.
 1.31 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.30 02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.29 01-Oct-2002  thorpej Use CFATTACH_DECL().
 1.28 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.27 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.26 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.25 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.24 03-Aug-2002  itojun correct range check, have overflow check, fix type mismatches,
for cmap args and some other calls. from openbsd
 1.23 03-Apr-2002  darrenr branches: 1.23.2; 1.23.4;
apply patches from PR#10170
 1.22 11-Mar-2002  pk * `bus_type_t' is gone.
* Use BUS_ADDR() where appropriate to encode I/O space and physical
address offset into a `bus_addr_t' value.
* Drop obio_bus_map() since it's now completely equivalent to bus_space_map()
* Use bus_space_map2() to map device space at a fixed virtual address.
* Remove the virtual address argument from sbus_sbus_addr()
 1.21 24-Sep-2001  eeh branches: 1.21.4;
Change bus_space_mmap() signature to the official one.
 1.20 22-Aug-2000  pk branches: 1.20.2; 1.20.4;
Use the framebuffer drivers & header files that now live in /sys/dev/sun.
 1.19 09-Jul-2000  pk Re-arrange headers; drop <machine/cpu.h>.
 1.18 29-Jun-2000  mrg remove include of <vm/vm.h> and <machine/pmap.h>. <vm/vm.h> -> <uvm/uvm_extern.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 19-Mar-2000  pk branches: 1.16.4;
Use fb_is_console(); retract fbconstty & fbnode from service.
 1.15 24-Mar-1999  mrg branches: 1.15.8;
completely remove Mach VM support. all that is left is the all the
header files as UVM still uses (most of) these.
 1.14 19-Nov-1998  mrg fix problems in many d_mmap routines:
- returned EOPNOTSUPP rather than -1.
- no check for negative offset.
many of these fix potential security problems in these drivers.


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

by someone!
 1.13 29-Jul-1998  pk We no longer need to get the register sets by ourselves.
 1.12 07-Apr-1998  pk bus_space_mmap() has changed to take a `bus_space_handle_t *' argument,
like other bus space methods.
 1.11 21-Mar-1998  pk Account for changed bus attachment scheme.
 1.10 10-Feb-1998  mrg - add defopt's for UVM, UVMHIST and PMAP_NEW.
- remove unnecessary UVMHIST_DECL's.
 1.9 05-Feb-1998  mrg initial import of the new virtual memory system, UVM, into -current.

UVM was written by chuck cranor <chuck@maria.wustl.edu>, with some
minor portions derived from the old Mach code. i provided some help
getting swap and paging working, and other bug fixes/ideas. chuck
silvers <chuq@chuq.com> also provided some other fixes.

this is the sparc portion.

this will be KNF'd shortly. :-)
 1.8 12-Jan-1998  thorpej Update for changes to config.
 1.7 24-May-1997  pk branches: 1.7.8;
Remove all `bustype' arguments from map[io]dev() and REG2PHYS().
 1.6 10-Dec-1996  pk Comply with recent autoconfiguration changes. Diffs graciously
supplied by Chris Demetriou.
 1.5 13-Oct-1996  christos backout previous kprintf change
 1.4 11-Oct-1996  christos printf -> kprintf, sprintf -> ksprintf
 1.3 04-Oct-1996  thorpej Returning ENODEV is not correct in a poll entry point. Instead, since
read/write returns an error, use seltrue().
 1.2 01-Oct-1996  abrown Add cgfourteen_poll() entry point to sync with recent changes in frame
buffer cdev code.
 1.1 30-Sep-1996  abrown Initial commit of cg14 framebuffer driver for Sun4m SPARCs.
- This driver supports the on-board mbus-based cgfourteen (sometimes referred
to as "SX") video hardware present on SS20-class machines.
- It does *not* support any of the SX acceleration features.
- It does support the 8-bit mode of the hardware, and looks to X like
a cgthree.
- It does support the cg6-style hardware cursor, even when running X in
cgthree emulation.
- It does support DPMS power-down of compatible displays on later-revision
cg14's.
- There is code to support the true color (32-bit) mode of the cg14 as
cg8 emulation, but it is disabled by default because it is most likely
broken. #define CG14_CG8 to turn it on.

The driver is not yet installed in the conf files, but I will do so
shortly...
 1.7.8.1 23-Nov-1998  cgd Fix many real and potential security problems with character device
driver mmap routines that did not properly bounds check offsets.
See NetBSD security advisory NetBSD-SA1998-005 for details. Done
as a patch because it's large, and a fair number of bits are different
in -current. (mrg)
 1.15.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.16.4.1 30-Jun-2000  simonb Pull up mmap paddr_t/off_t changes from trunk.
 1.20.4.7 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.20.4.6 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.20.4.5 28-Jun-2002  jdolecek hook fbkqfilter to leaf drivers' kqfilter
 1.20.4.4 28-Jun-2002  jdolecek prove kqfilter hook; it's very simple equivalent of seltrue()
 1.20.4.3 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.20.4.2 16-Mar-2002  jdolecek Catch up with -current.
 1.20.4.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.20.2.2 10-Oct-2001  fvdl Convert all remaining devices.
 1.20.2.1 01-Oct-2001  fvdl Catch up with -current.
 1.21.4.8 11-Nov-2002  nathanw Catch up to -current
 1.21.4.7 18-Oct-2002  nathanw Catch up to -current.
 1.21.4.6 17-Sep-2002  nathanw Catch up to -current.
 1.21.4.5 27-Aug-2002  nathanw Catch up to -current.
 1.21.4.4 13-Aug-2002  nathanw Catch up to -current.
 1.21.4.3 17-Apr-2002  nathanw Catch up to -current.
 1.21.4.2 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.21.4.1 24-Sep-2001  nathanw file cgfourteen.c was added on branch nathanw_sa on 2002-04-01 07:42:39 +0000
 1.23.4.2 22-Nov-2002  tron Pull up revision 1.25 (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.23.4.1 07-Aug-2002  lukem Pull up revision 1.24 (requested by itojun in ticket #616):
correct range check, have overflow check, fix type mismatches,
for cmap args and some other calls. from openbsd
 1.23.2.2 31-Aug-2002  gehenna catch up with -current.
 1.23.2.1 17-May-2002  gehenna Add device switch.
 1.34.2.6 11-Dec-2005  christos Sync with head.
 1.34.2.5 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.34.2.4 04-Feb-2005  skrll Adapt to branch.
 1.34.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.34.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.34.2.1 03-Aug-2004  skrll Sync with HEAD
 1.39.8.1 22-Nov-2005  yamt sync with head.
 1.39.2.3 03-Sep-2007  yamt sync with head.
 1.39.2.2 30-Dec-2006  yamt sync with head.
 1.39.2.1 21-Jun-2006  yamt sync with head.
 1.41.2.1 01-Feb-2006  yamt sync with head.
 1.44.4.1 22-Apr-2006  simonb Sync with head.
 1.44.2.1 09-Sep-2006  rpaulo sync with head
 1.45.6.1 31-Mar-2006  tron Merge 2006-03-31 NetBSD-current into the "peter-altq" branch.
 1.45.4.1 19-Apr-2006  elad sync with head - hopefully this will work
 1.45.2.1 01-Apr-2006  yamt sync with head.
 1.46.10.1 10-Dec-2006  yamt sync with head.
 1.46.8.1 12-Jan-2007  ad Sync with head.
 1.47.4.1 12-Mar-2007  rmind Sync with HEAD.
 1.48.14.2 03-Sep-2007  skrll Sync with HEAD.
 1.48.14.1 15-Aug-2007  skrll Sync with HEAD.
 1.48.12.1 07-Aug-2007  matt Sync with HEAD.
 1.48.10.1 03-Oct-2007  garbled Sync with HEAD
 1.48.2.1 20-Aug-2007  ad Sync with HEAD.
 1.50.2.1 03-Sep-2007  jmcneill Sync with HEAD.
 1.51.2.1 06-Nov-2007  matt sync with HEAD
 1.52.22.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.52.20.6 09-Oct-2010  yamt sync with head
 1.52.20.5 11-Aug-2010  yamt sync with head.
 1.52.20.4 16-Sep-2009  yamt sync with head
 1.52.20.3 18-Jul-2009  yamt sync with head.
 1.52.20.2 20-Jun-2009  yamt sync with head
 1.52.20.1 04-May-2009  yamt sync with head.
 1.52.18.2 17-Jun-2008  yamt sync with head.
 1.52.18.1 18-May-2008  yamt sync with head.
 1.52.16.3 17-Jan-2009  mjf Sync with HEAD.
 1.52.16.2 29-Jun-2008  mjf Sync with HEAD.
 1.52.16.1 02-Jun-2008  mjf Sync with HEAD.
 1.53.2.1 18-Jun-2008  simonb Sync with head.
 1.54.4.3 28-Apr-2009  skrll Sync with HEAD.
 1.54.4.2 03-Mar-2009  skrll Sync with HEAD.
 1.54.4.1 19-Jan-2009  skrll Sync with HEAD.
 1.56.2.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.62.4.3 21-Apr-2011  rmind sync with head
 1.62.4.2 05-Mar-2011  rmind sync with head
 1.62.4.1 03-Jul-2010  rmind sync with head
 1.62.2.2 22-Oct-2010  uebayasi Sync with HEAD (-D20101022).
 1.62.2.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.65.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.66.8.1 18-Feb-2012  mrg merge to -current.
 1.66.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.66.4.2 30-Oct-2012  yamt sync with head
 1.66.4.1 17-Apr-2012  yamt sync with head
 1.67.6.5 03-Dec-2017  jdolecek update from HEAD
 1.67.6.4 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.67.6.3 23-Jun-2013  tls resync from head
 1.67.6.2 25-Feb-2013  tls resync with head
 1.67.6.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.75.2.2 18-May-2014  rmind sync with head
 1.75.2.1 28-Aug-2013  rmind sync with head
 1.77.2.1 10-Aug-2014  tls Rebase.
 1.79.4.3 05-Oct-2016  skrll Sync with HEAD
 1.79.4.2 09-Jul-2016  skrll Sync with HEAD
 1.79.4.1 29-May-2016  skrll Sync with HEAD
 1.81.2.1 04-Nov-2016  pgoyette Sync with HEAD
 1.85.4.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.85.4.1 10-Jun-2019  christos Sync with HEAD
 1.85.2.2 18-Jan-2019  pgoyette Synch with HEAD
 1.85.2.1 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.88.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.89.8.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.93.4.1 05-Jul-2023  martin Pull up following revision(s) (requested by abs in ticket #224):

sys/dev/wscons/wsdisplay_vconsvar.h: revision 1.34
sys/dev/wscons/wsdisplay_glyphcachevar.h: revision 1.6
sys/arch/sparc/dev/cgfourteen.c: revision 1.94
sys/arch/sparc/dev/cgfourteen.c: revision 1.95
sys/dev/sbus/mgx.c: revision 1.21
sys/dev/sbus/mgx.c: revision 1.22
sys/dev/sbus/mgx.c: revision 1.23
sys/dev/wscons/wsdisplay_vcons.c: revision 1.65
sys/dev/wscons/wsdisplay_vcons.c: revision 1.66
sys/dev/wscons/wsdisplay_glyphcache.c: revision 1.12
sys/arch/sparc/dev/sxvar.h: revision 1.5
sys/arch/sparc/dev/sx.c: revision 1.6
sys/arch/sparc/dev/sx.c: revision 1.7

make vcons_putchar_buffer() return a flag indicating if anything actually
changed, skip the actual drawing op if nothing did

add flags for drivers to requesr R2L bit/byte-ordered fonts, default to
L2R, chack them in vcons_load_font() instead of just trusting that we'd get
what we need

initialize the diagnostic register with the value suggested by the SunOS
header. This sets a bunch of undocumented bits and yields a 10% speed increase
when rendering antialiased text.

use macros compatible with xf86-video-suncg14 to issue SX instructions
much more readable, alignment weirdness is handled automatically and code is
interchangable

allow drivers to specify horizontal alignment of glyph cache cells
for things like SX which have alignment restrictions

add counter to periodically drain the instruction queue in order to avoid
stalling the MBus during long SX operations

adapted from xf86-video-suncg14
- use sx_wait() to avoid stalling the MBus
- request 32bit alignment for glyphcache cells

wait for the engine to go idle before issuing rectfill commands
we get occasional overlap with blit commands if we just wait for fifo slots
needs further investigation, it is possible that not all writes to drawing
engine registers are pipelined and of course we don't have docs

following a hunch...
- cache DEC and FG registers, only write them if the value actually changes
- wait for the engine to go idle before writing DEC
- wait for FIFO slots on everything else
with this we avoid waiting if possible and still avoid overlapping blit and
fill commands
 1.98.2.1 02-Aug-2025  perseant Sync with HEAD
 1.9 14-May-2025  macallan remove definition for non-existant CG14_CURSOR_COLOR3 register
 1.8 12-May-2024  macallan branches: 1.8.2;
moar registers
in particular, document XLUT bits
 1.7 12-Jun-2010  macallan add some more offsets
this should have been committed with the previous, noticed by he
 1.6 17-Oct-2007  garbled branches: 1.6.20; 1.6.40; 1.6.42;
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 30-Jul-2007  macallan branches: 1.5.4;
add hardware cursor support
 1.4 30-Jul-2007  macallan add wsdisplay support for cg14
The console will run in 8bit but switch to 32bit in mapped mode so XFree86
with wsfb can run in 24bit colour.
 1.3 17-Jan-2006  christos branches: 1.3.28; 1.3.36; 1.3.40; 1.3.42;
PR/32552: Antonio Bravo: cgfourteen 24-bit support
Original code from der Mouse, posted to the mailing lists by Jakob Menzi.
 1.2 16-Nov-2005  uwe ANSIify function declarations/defintions. Use uint<N>_t.
Propagate "static" to function definitions. Drop trailing whitespace.
Same binary code is produced for GENERIC.MP + KGDB + DDB.
 1.1 30-Sep-1996  abrown branches: 1.1.62; 1.1.78; 1.1.86;
Initial commit of cg14 framebuffer driver for Sun4m SPARCs.
- This driver supports the on-board mbus-based cgfourteen (sometimes referred
to as "SX") video hardware present on SS20-class machines.
- It does *not* support any of the SX acceleration features.
- It does support the 8-bit mode of the hardware, and looks to X like
a cgthree.
- It does support the cg6-style hardware cursor, even when running X in
cgthree emulation.
- It does support DPMS power-down of compatible displays on later-revision
cg14's.
- There is code to support the true color (32-bit) mode of the cg14 as
cg8 emulation, but it is disabled by default because it is most likely
broken. #define CG14_CG8 to turn it on.

The driver is not yet installed in the conf files, but I will do so
shortly...
 1.1.86.1 22-Nov-2005  yamt sync with head.
 1.1.78.2 03-Sep-2007  yamt sync with head.
 1.1.78.1 21-Jun-2006  yamt sync with head.
 1.1.62.1 11-Dec-2005  christos Sync with head.
 1.3.42.1 15-Aug-2007  skrll Sync with HEAD.
 1.3.40.1 07-Aug-2007  matt Sync with HEAD.
 1.3.36.1 03-Oct-2007  garbled Sync with HEAD
 1.3.28.1 20-Aug-2007  ad Sync with HEAD.
 1.5.4.1 06-Nov-2007  matt sync with HEAD
 1.6.42.1 03-Jul-2010  rmind sync with head
 1.6.40.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.6.20.1 11-Aug-2010  yamt sync with head.
 1.8.2.1 02-Aug-2025  perseant Sync with HEAD
 1.19 17-Dec-2021  macallan only write the mask register if we're actually changing it
 1.18 30-Apr-2016  macallan support anti-aliased fonts, glyphcache etc.
 1.17 07-Sep-2015  dholland Final bit of PR 41200: headers that declare ioctls should include sys/ioccom.h.
This covers most if not all of the MD headers.

XXX: a lot of the ioctl definitions in some of these files are cutpasted.
 1.16 29-May-2013  macallan branches: 1.16.10;
allow userland to map SX registers and IO space
 1.15 06-Feb-2013  macallan use SX for basic hardware acceleration
not quite complete yet but good enough to be useful
missing things include:
- backwards blits
- ROP support
- the cursor is still drawn by software
 1.14 05-Feb-2013  macallan throw out RASTERCONSOLE goo
 1.13 31-Aug-2010  macallan branches: 1.13.8; 1.13.18;
remove shadow framebuffer support, use VCONS_DONT_READ instead
 1.12 10-Jun-2010  macallan Add a couple more hw offset definitions, add an ioctl() to set colour depth
which works like Solaris and Linux, and finally make mmap() behave like an
actual CG14. This should be all we need to get Xorg's suncg14 driver going.
 1.11 12-Dec-2008  macallan branches: 1.11.4; 1.11.6;
some cleanup, add shadowfb support
 1.10 17-May-2008  macallan branches: 1.10.6;
struct device * -> device_t
 1.9 17-Oct-2007  garbled branches: 1.9.16; 1.9.18; 1.9.20; 1.9.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.8 30-Jul-2007  macallan branches: 1.8.4;
add hardware cursor support
 1.7 30-Jul-2007  macallan add wsdisplay support for cg14
The console will run in 8bit but switch to 32bit in mapped mode so XFree86
with wsfb can run in 24bit colour.
 1.6 17-Jan-2006  christos branches: 1.6.28; 1.6.36; 1.6.40; 1.6.42;
PR/32552: Antonio Bravo: cgfourteen 24-bit support
Original code from der Mouse, posted to the mailing lists by Jakob Menzi.
 1.5 16-Nov-2005  uwe branches: 1.5.2;
ANSIify function declarations/defintions. Use uint<N>_t.
Propagate "static" to function definitions. Drop trailing whitespace.
Same binary code is produced for GENERIC.MP + KGDB + DDB.
 1.4 23-Aug-2002  thorpej branches: 1.4.6; 1.4.22; 1.4.30;
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.3 29-Jul-1998  pk branches: 1.3.28; 1.3.32; 1.3.40; 1.3.42;
We no longer need to get the register sets by ourselves.
 1.2 21-Mar-1998  pk Account for changed bus attachment scheme.
 1.1 30-Sep-1996  abrown Initial commit of cg14 framebuffer driver for Sun4m SPARCs.
- This driver supports the on-board mbus-based cgfourteen (sometimes referred
to as "SX") video hardware present on SS20-class machines.
- It does *not* support any of the SX acceleration features.
- It does support the 8-bit mode of the hardware, and looks to X like
a cgthree.
- It does support the cg6-style hardware cursor, even when running X in
cgthree emulation.
- It does support DPMS power-down of compatible displays on later-revision
cg14's.
- There is code to support the true color (32-bit) mode of the cg14 as
cg8 emulation, but it is disabled by default because it is most likely
broken. #define CG14_CG8 to turn it on.

The driver is not yet installed in the conf files, but I will do so
shortly...
 1.3.42.1 22-Nov-2002  tron Pull up revision 1.4 (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.3.40.1 31-Aug-2002  gehenna catch up with -current.
 1.3.32.1 27-Aug-2002  nathanw Catch up to -current.
 1.3.28.1 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.4.30.1 22-Nov-2005  yamt sync with head.
 1.4.22.2 03-Sep-2007  yamt sync with head.
 1.4.22.1 21-Jun-2006  yamt sync with head.
 1.4.6.1 11-Dec-2005  christos Sync with head.
 1.5.2.1 01-Feb-2006  yamt sync with head.
 1.6.42.1 15-Aug-2007  skrll Sync with HEAD.
 1.6.40.1 07-Aug-2007  matt Sync with HEAD.
 1.6.36.1 03-Oct-2007  garbled Sync with HEAD
 1.6.28.1 20-Aug-2007  ad Sync with HEAD.
 1.8.4.1 06-Nov-2007  matt sync with HEAD
 1.9.22.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.9.20.3 09-Oct-2010  yamt sync with head
 1.9.20.2 11-Aug-2010  yamt sync with head.
 1.9.20.1 04-May-2009  yamt sync with head.
 1.9.18.1 18-May-2008  yamt sync with head.
 1.9.16.2 17-Jan-2009  mjf Sync with HEAD.
 1.9.16.1 02-Jun-2008  mjf Sync with HEAD.
 1.10.6.1 19-Jan-2009  skrll Sync with HEAD.
 1.11.6.2 05-Mar-2011  rmind sync with head
 1.11.6.1 03-Jul-2010  rmind sync with head
 1.11.4.2 22-Oct-2010  uebayasi Sync with HEAD (-D20101022).
 1.11.4.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.13.18.3 03-Dec-2017  jdolecek update from HEAD
 1.13.18.2 23-Jun-2013  tls resync from head
 1.13.18.1 25-Feb-2013  tls resync with head
 1.13.8.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.16.10.2 29-May-2016  skrll Sync with HEAD
 1.16.10.1 22-Sep-2015  skrll Sync with HEAD
 1.54 22-Aug-2000  pk Use the framebuffer drivers & header files that now live in /sys/dev/sun.
 1.53 09-Jul-2000  pk Re-arrange headers; drop <machine/cpu.h>.
 1.52 29-Jun-2000  mrg remove include of <vm/vm.h> and <machine/pmap.h>. <vm/vm.h> -> <uvm/uvm_extern.h>
 1.51 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.50 16-Apr-2000  pk branches: 1.50.4;
Use screen attributes passed to our hardware rasops routines.

Move colormap initialization to cg6reset(), so this is also done
on last close of the framebuffer device (e.g. after X server shutdown).
 1.49 04-Apr-2000  pk Use copyin/copyout to get a colormap from/to user space.
Also, prepare for the case of a colormap maintained in kernel space.
 1.48 31-Mar-2000  pk Make this compile without RASTERCONSOLE too.
 1.47 30-Mar-2000  pk Add hardware acceleration features for use with the RASTERCONSOLE option.
Code posted on port-sparc by `der Mouse'; it was slightly re-arranged to
fit the layout of this driver.
 1.46 19-Mar-2000  pk Use fb_is_console(); retract fbconstty & fbnode from service.
 1.45 26-Aug-1999  thorpej branches: 1.45.2;
Initialize the default colormap to 0 == black, all others == full white.
 1.44 30-Jul-1999  thorpej The new rasops stuff is a LOT faster; turn on rasterconsole on the cgsix.
 1.43 24-Mar-1999  mrg branches: 1.43.4;
completely remove Mach VM support. all that is left is the all the
header files as UVM still uses (most of) these.
 1.42 07-Apr-1998  pk bus_space_mmap() has changed to take a `bus_space_handle_t *' argument,
like other bus space methods.
 1.41 31-Mar-1998  pk Factor out bus code into separate files.
 1.40 29-Mar-1998  pk obio_bus_probe() => bus_space_probe()
 1.39 23-Mar-1998  pk Fix yank-and-put error in sbus attach code.
Misc. cleanup.
 1.38 21-Mar-1998  pk Account for changed bus attachment scheme.
 1.37 10-Feb-1998  mrg - add defopt's for UVM, UVMHIST and PMAP_NEW.
- remove unnecessary UVMHIST_DECL's.
 1.36 05-Feb-1998  mrg initial import of the new virtual memory system, UVM, into -current.

UVM was written by chuck cranor <chuck@maria.wustl.edu>, with some
minor portions derived from the old Mach code. i provided some help
getting swap and paging working, and other bug fixes/ideas. chuck
silvers <chuq@chuq.com> also provided some other fixes.

this is the sparc portion.

this will be KNF'd shortly. :-)
 1.35 25-Jan-1998  pk bus_tmp() => obio_bus_tmp()
 1.34 12-Jan-1998  thorpej Update for changes to config.
 1.33 07-Aug-1997  pk Do not use `rasterconsole' by default on this framebuffer.
 1.32 29-Jul-1997  fair branches: 1.32.2;
%x -> 0x%x
 1.31 24-May-1997  pk Remove all `bustype' arguments from map[io]dev() and REG2PHYS().
 1.30 19-May-1997  pk Replace bus_tmp() by mapdev() equivalent.
 1.29 10-Dec-1996  pk Comply with recent autoconfiguration changes. Diffs graciously
supplied by Chris Demetriou.
 1.28 13-Oct-1996  christos backout previous kprintf change
 1.27 11-Oct-1996  christos printf -> kprintf, sprintf -> ksprintf
 1.26 04-Oct-1996  thorpej Returning ENODEV is not correct in a poll entry point. Instead, since
read/write returns an error, use seltrue().
 1.25 01-Apr-1996  christos Eliminated dependencies on dev_conf.h
 1.24 31-Mar-1996  pk Re-arrange a bit to stear clear of gcc `-Wall' bites.
 1.23 17-Mar-1996  thorpej New device attachment scheme:

- split softc size and match/attach out from cfdriver into
a new struct cfattach.

- new "attach" directive for files.*. May specify the name of
the cfattach structure, so that devices may be easily attached
to parents with different autoconfiguration semantics.
 1.22 16-Mar-1996  christos fix format in log()
 1.21 14-Mar-1996  christos Bring prototypes into scope and fix compiler warnings.
 1.20 27-Feb-1996  thorpej First-cut support for P4 framebuffers. Currently supports P4 variants
of bwtwo, cgfour, cgsix, and cgeight. Includes support for attaching
the overlay plane of the cgfour and cgeight as a bwtwo instance (a'la
SunOS).

P4 register descriptions, cgfour driver, and cgeight driver partially
derived from OpenBSD.

This code may still need polishing.
 1.19 25-Feb-1996  pk Use CPU-type macros.
 1.18 11-Dec-1995  pk Adapt to changed mapiodev() interface.
 1.17 29-Nov-1995  pk Code from Jason to better configure /dev/fb.
 1.16 08-Oct-1995  pk branches: 1.16.2;
Patch from Jason to factor out a common framebuffer size determination
routine from the individual drivers.
 1.15 17-Sep-1995  pk Change interface to th `fb' pseudo device to not need the major device
number (a la sun3).
Put in new glue for rcons.
 1.14 29-Aug-1995  pk If we're the console, say so in attach message.
 1.13 10-Apr-1995  mycroft map --> mmap
 1.12 16-Feb-1995  pk Working "config generic" support; from Theo.
 1.11 23-Nov-1994  deraadt XXmatch change (and a few __P() as well)
 1.10 20-Nov-1994  deraadt copyright/Id cleanup
 1.9 02-Nov-1994  deraadt ioctl u_long cmd
 1.8 15-Oct-1994  deraadt sbus_establish() is sun4c/sun4m specific
 1.7 15-Oct-1994  deraadt mapiodev takes a bustype argument now
 1.6 02-Oct-1994  deraadt sun4/300 support works
 1.5 17-Sep-1994  deraadt sbus/* --> dev/*
deal with multiple bus types (start of vme/obio support)
 1.4 04-Jul-1994  deraadt need vm/vm.h
 1.3 07-May-1994  deraadt update from lite
 1.2 30-Nov-1993  deraadt fbio.h is in machine/
 1.1 11-Nov-1993  deraadt from torek:
new brooktree dac code
hacked cgthree code
new cgsix (ala GX) code
 1.16.2.1 16-Feb-1996  thorpej Pull in improved framebuffer autoconfiguration code from -current.
Prevents panics when multiple framebuffers are found on sun4 systems.
 1.32.2.1 23-Aug-1997  thorpej Update marc-pcmcia branch from trunk.
 1.43.4.1 02-Aug-1999  thorpej Update from trunk.
 1.45.2.1 20-Nov-2000  bouyer Remove files that are no longer on the trunck
 1.50.4.2 27-Jan-2001  jhawk Pull up revision 1.5 of sys/dev/sun/cgsix.c via patch (requested by tsutsui):
Initialize cgsix registers for machines that do not do so by themselves.
Fixes PR port-sparc/11944.
 1.50.4.1 30-Jun-2000  simonb Pull up mmap paddr_t/off_t changes from trunk.
 1.28 20-Dec-2023  thorpej Remove unnecessary <sys/malloc.h>.
 1.27 21-Apr-2016  macallan RASTERCONSOLE is no more
 1.26 27-Oct-2012  chs branches: 1.26.14;
split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.25 18-Jul-2011  mrg branches: 1.25.2; 1.25.12;
convert the remaining sparc drivers to CFATTACH_DECL_NEW/cfdata_t/device_t.
(cgsix_obio.c was only partially converted with the rest of the cgsix code
when it was changed some time ago.)
 1.24 01-Jul-2011  dyoung #include <sys/bus.h> instead of <machine/bus.h>.
 1.23 12-Dec-2008  macallan device_t-ify
 1.22 28-Apr-2008  martin branches: 1.22.8;
Remove clause 3 and 4 from TNF licenses
 1.21 04-Mar-2007  christos branches: 1.21.40; 1.21.42; 1.21.44;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.20 08-Feb-2007  jdc branches: 1.20.2;
Clarify the console checking comment.
 1.19 10-Jan-2007  jdc sys/dev/sun/cgsix.c expects us to fill in sc->sc_ramsize.
Do that and also use it to replace a local variable.
 1.18 29-Mar-2006  thorpej branches: 1.18.8;
Use device_cfdata().
 1.17 16-Nov-2005  uwe branches: 1.17.4; 1.17.6; 1.17.8; 1.17.10; 1.17.12;
ANSIify function declarations/defintions. Use uint<N>_t.
Propagate "static" to function definitions. Drop trailing whitespace.
Same binary code is produced for GENERIC.MP + KGDB + DDB.
 1.16 04-Jun-2005  tsutsui branches: 1.16.2; 1.16.8;
Add const.
 1.15 04-Jun-2005  tsutsui Remove an unneeded cast to appease gcc -Wcast-qual.
 1.14 15-Jul-2003  lukem __KERNEL_RCSID()
 1.13 02-Oct-2002  thorpej branches: 1.13.6;
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 11-Mar-2002  pk branches: 1.9.4;
* `bus_type_t' is gone.
* Use BUS_ADDR() where appropriate to encode I/O space and physical
address offset into a `bus_addr_t' value.
* Drop obio_bus_map() since it's now completely equivalent to bus_space_map()
* Use bus_space_map2() to map device space at a fixed virtual address.
* Remove the virtual address argument from sbus_sbus_addr()
 1.8 22-Aug-2000  pk branches: 1.8.2; 1.8.4; 1.8.8;
Use the framebuffer drivers & header files that now live in /sys/dev/sun.
 1.7 09-Jul-2000  pk Re-arrange headers; drop <machine/cpu.h>.
 1.6 29-Jun-2000  mrg remove include of <vm/vm.h> and <machine/pmap.h>. <vm/vm.h> -> <uvm/uvm_extern.h>
 1.5 30-Mar-2000  pk Add hardware acceleration features for use with the RASTERCONSOLE option.
Code posted on port-sparc by `der Mouse'; it was slightly re-arranged to
fit the layout of this driver.
 1.4 19-Mar-2000  pk Use fb_is_console(); retract fbconstty & fbnode from service.
 1.3 09-Aug-1999  christos branches: 1.3.2;
PR/8178:Julian Coleman: sparc kernel will not build with cgtwo/cgsix but
without sbus. Remove call to cgsix-sbus-attach (impossible code). Make
routines static (they were declared static, but not defined static and
some compilers can complain).
 1.2 25-Mar-1999  mrg remove opt_uvm.h
 1.1 31-Mar-1998  pk Factor out bus code into separate files.
 1.3.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.8.8.3 18-Oct-2002  nathanw Catch up to -current.
 1.8.8.2 17-Sep-2002  nathanw Catch up to -current.
 1.8.8.1 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.8.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.8.4.1 16-Mar-2002  jdolecek Catch up with -current.
 1.8.2.1 10-Oct-2001  fvdl Convert all remaining devices.
 1.9.4.1 19-May-2002  gehenna Remove unnecessary #include
 1.13.6.5 11-Dec-2005  christos Sync with head.
 1.13.6.4 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.13.6.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.13.6.2 18-Sep-2004  skrll Sync with HEAD.
 1.13.6.1 03-Aug-2004  skrll Sync with HEAD
 1.16.8.1 22-Nov-2005  yamt sync with head.
 1.16.2.3 03-Sep-2007  yamt sync with head.
 1.16.2.2 26-Feb-2007  yamt sync with head.
 1.16.2.1 21-Jun-2006  yamt sync with head.
 1.17.12.1 31-Mar-2006  tron Merge 2006-03-31 NetBSD-current into the "peter-altq" branch.
 1.17.10.1 19-Apr-2006  elad sync with head - hopefully this will work
 1.17.8.1 01-Apr-2006  yamt sync with head.
 1.17.6.1 22-Apr-2006  simonb Sync with head.
 1.17.4.1 09-Sep-2006  rpaulo sync with head
 1.18.8.2 09-Feb-2007  ad Sync with HEAD.
 1.18.8.1 12-Jan-2007  ad Sync with head.
 1.20.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.21.44.2 04-May-2009  yamt sync with head.
 1.21.44.1 16-May-2008  yamt sync with head.
 1.21.42.1 18-May-2008  yamt sync with head.
 1.21.40.2 17-Jan-2009  mjf Sync with HEAD.
 1.21.40.1 02-Jun-2008  mjf Sync with HEAD.
 1.22.8.1 19-Jan-2009  skrll Sync with HEAD.
 1.25.12.2 03-Dec-2017  jdolecek update from HEAD
 1.25.12.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.25.2.1 30-Oct-2012  yamt sync with head
 1.26.14.1 22-Apr-2016  skrll Sync with HEAD
 1.6 22-Aug-2000  pk Use the framebuffer drivers & header files that now live in /sys/dev/sun.
 1.5 09-Jul-2000  pk Re-arrange headers; drop <machine/cpu.h>.
 1.4 29-Jun-2000  mrg remove include of <vm/vm.h> and <machine/pmap.h>. <vm/vm.h> -> <uvm/uvm_extern.h>
 1.3 30-Mar-2000  pk Add hardware acceleration features for use with the RASTERCONSOLE option.
Code posted on port-sparc by `der Mouse'; it was slightly re-arranged to
fit the layout of this driver.
 1.2 19-Mar-2000  pk Use fb_is_console(); retract fbconstty & fbnode from service.
 1.1 31-Mar-1998  pk branches: 1.1.14;
Factor out bus code into separate files.
 1.1.14.1 20-Nov-2000  bouyer Remove files that are no longer on the trunck
 1.7 22-Aug-2000  pk Use the framebuffer drivers & header files that now live in /sys/dev/sun.
 1.6 30-Mar-2000  pk branches: 1.6.4;
Add hardware acceleration features for use with the RASTERCONSOLE option.
Code posted on port-sparc by `der Mouse'; it was slightly re-arranged to
fit the layout of this driver.
 1.5 21-Mar-1998  pk branches: 1.5.14;
#define several register bank offsets, so we don't need to refer to
structure fields.
 1.4 27-Feb-1996  thorpej First-cut support for P4 framebuffers. Currently supports P4 variants
of bwtwo, cgfour, cgsix, and cgeight. Includes support for attaching
the overlay plane of the cgfour and cgeight as a bwtwo instance (a'la
SunOS).

P4 register descriptions, cgfour driver, and cgeight driver partially
derived from OpenBSD.

This code may still need polishing.
 1.3 20-Nov-1994  deraadt copyright/Id cleanup
 1.2 07-May-1994  deraadt update from lite
 1.1 11-Nov-1993  deraadt from torek:
new brooktree dac code
hacked cgthree code
new cgsix (ala GX) code
 1.5.14.1 20-Nov-2000  bouyer Remove files that are no longer on the trunck
 1.6.4.1 27-Jan-2001  jhawk Pull up revisions 1.3-1.4 of sys/dev/sun/cgsixreg.h via patch (requested by tsutsui):
Initialize cgsix registers for machines that do not do so by themselves.
Fixes PR port-sparc/11944.
 1.4 22-Aug-2000  pk Use the framebuffer drivers & header files that now live in /sys/dev/sun.
 1.3 30-Mar-2000  pk Add hardware acceleration features for use with the RASTERCONSOLE option.
Code posted on port-sparc by `der Mouse'; it was slightly re-arranged to
fit the layout of this driver.
 1.2 19-Mar-2000  pk Use fb_is_console(); retract fbconstty & fbnode from service.
 1.1 31-Mar-1998  pk branches: 1.1.14;
Factor out bus code into separate files.
 1.1.14.1 20-Nov-2000  bouyer Remove files that are no longer on the trunck
 1.49 22-Aug-2000  pk Use the framebuffer drivers & header files that now live in /sys/dev/sun.
 1.48 09-Jul-2000  pk Re-arrange headers; drop <machine/cpu.h>.
 1.47 29-Jun-2000  mrg remove include of <vm/vm.h> and <machine/pmap.h>. <vm/vm.h> -> <uvm/uvm_extern.h>
 1.46 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.45 16-Apr-2000  pk branches: 1.45.4;
Slight optimization when searching the video parameter table.
 1.44 14-Apr-2000  pk Initialize local variable `bt' in cgthree_attach().
 1.43 04-Apr-2000  pk Use copyin/copyout to get a colormap from/to user space.
Also, prepare for the case of a colormap maintained in kernel space.
 1.42 19-Mar-2000  pk Use fb_is_console(); retract fbconstty & fbnode from service.
 1.41 26-Aug-1999  thorpej branches: 1.41.2;
Initialize the default colormap to 0 == black, all others == full white.
 1.40 19-Nov-1998  mrg fix problems in many d_mmap routines:
- returned EOPNOTSUPP rather than -1.
- no check for negative offset.
many of these fix potential security problems in these drivers.


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

by someone!
 1.39 07-Sep-1998  pk Need to cast sbus attach `prom_vaddrs' field.
 1.38 29-Jul-1998  pk Deal with sbus attach args changes.
 1.37 07-Apr-1998  pk bus_space_mmap() has changed to take a `bus_space_handle_t *' argument,
like other bus space methods.
 1.36 29-Mar-1998  pk obio_bus_probe() => bus_space_probe()
 1.35 21-Mar-1998  pk Account for changed bus attachment scheme.
 1.34 12-Jan-1998  thorpej Update for changes to config.
 1.33 24-May-1997  pk branches: 1.33.8;
Remove all `bustype' arguments from map[io]dev() and REG2PHYS().
 1.32 10-Dec-1996  pk Comply with recent autoconfiguration changes. Diffs graciously
supplied by Chris Demetriou.
 1.31 13-Oct-1996  christos backout previous kprintf change
 1.30 11-Oct-1996  christos printf -> kprintf, sprintf -> ksprintf
 1.29 04-Oct-1996  thorpej Returning ENODEV is not correct in a poll entry point. Instead, since
read/write returns an error, use seltrue().
 1.28 31-May-1996  pk Initialize video parameters if the board is not yet running. Useful if
the cg3 is not the console.
 1.27 01-Apr-1996  christos Eliminated dependencies on dev_conf.h
 1.26 31-Mar-1996  pk Re-arrange a bit to stear clear of gcc `-Wall' bites.
 1.25 17-Mar-1996  thorpej New device attachment scheme:

- split softc size and match/attach out from cfdriver into
a new struct cfattach.

- new "attach" directive for files.*. May specify the name of
the cfattach structure, so that devices may be easily attached
to parents with different autoconfiguration semantics.
 1.24 14-Mar-1996  christos Bring prototypes into scope and fix compiler warnings.
 1.23 28-Feb-1996  pk Fix typo
 1.22 27-Feb-1996  thorpej First-cut support for P4 framebuffers. Currently supports P4 variants
of bwtwo, cgfour, cgsix, and cgeight. Includes support for attaching
the overlay plane of the cgfour and cgeight as a bwtwo instance (a'la
SunOS).

P4 register descriptions, cgfour driver, and cgeight driver partially
derived from OpenBSD.

This code may still need polishing.
 1.21 27-Feb-1996  pk remove a printf
 1.20 27-Feb-1996  pk Use `video enable' bit in framebuffer control.
 1.19 25-Feb-1996  pk Use CPU-type macros.
 1.18 11-Dec-1995  pk Adapt to changed mapiodev() interface.
 1.17 29-Nov-1995  pk Code from Jason to better configure /dev/fb.
 1.16 08-Oct-1995  pk branches: 1.16.2;
Patch from Jason to factor out a common framebuffer size determination
routine from the individual drivers.
 1.15 04-Oct-1995  pk RCONSOLE => RASTERCONSOLE.
 1.14 17-Sep-1995  pk Change interface to th `fb' pseudo device to not need the major device
number (a la sun3).
Put in new glue for rcons.
 1.13 10-Apr-1995  mycroft map --> mmap
 1.12 23-Nov-1994  deraadt XXmatch change (and a few __P() as well)
 1.11 20-Nov-1994  deraadt copyright/Id cleanup
 1.10 02-Nov-1994  deraadt ioctl u_long cmd
 1.9 15-Oct-1994  deraadt mapiodev takes a bustype argument now
 1.8 02-Oct-1994  deraadt sun4/300 support works
 1.7 17-Sep-1994  deraadt sbus/* --> dev/*
deal with multiple bus types (start of vme/obio support)
 1.6 04-Jul-1994  deraadt need vm/vm.h
 1.5 13-Apr-1994  deraadt darn, whoops
 1.4 12-Apr-1994  deraadt support mmap() at 0x04000000; fb_size should be rounded up.
 1.3 11-Nov-1993  deraadt from torek:
new brooktree dac code
hacked cgthree code
new cgsix (ala GX) code
 1.2 11-Oct-1993  deraadt bwtwo.c, cgthree.c: sys-fbio.h -> machine/fbio.h
if_le.c: #ifdef MULTICAST some things, and do arp the old way
 1.1 02-Oct-1993  deraadt Chris Torek's sparc port. Missing lots of things.
 1.16.2.1 16-Feb-1996  thorpej Pull in improved framebuffer autoconfiguration code from -current.
Prevents panics when multiple framebuffers are found on sun4 systems.
 1.33.8.1 23-Nov-1998  cgd Fix many real and potential security problems with character device
driver mmap routines that did not properly bounds check offsets.
See NetBSD security advisory NetBSD-SA1998-005 for details. Done
as a patch because it's large, and a fair number of bits are different
in -current. (mrg)
 1.41.2.1 20-Nov-2000  bouyer Remove files that are no longer on the trunck
 1.45.4.1 30-Jun-2000  simonb Pull up mmap paddr_t/off_t changes from trunk.
 1.6 22-Aug-2000  pk Use the framebuffer drivers & header files that now live in /sys/dev/sun.
 1.5 27-Feb-1996  pk branches: 1.5.30;
bt_reg => fbcontrol.
 1.4 20-Nov-1994  deraadt copyright/Id cleanup
 1.3 03-Mar-1994  deraadt fix rcsid
 1.2 11-Nov-1993  deraadt from torek:
new brooktree dac code
hacked cgthree code
new cgsix (ala GX) code
 1.1 02-Oct-1993  deraadt Chris Torek's sparc port. Missing lots of things.
 1.5.30.1 20-Nov-2000  bouyer Remove files that are no longer on the trunck
 1.58 20-Dec-2023  thorpej Remove unnecessary <sys/malloc.h>.
 1.57 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.56 16-Mar-2014  dholland branches: 1.56.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.55 18-Jul-2011  mrg branches: 1.55.2; 1.55.12; 1.55.16;
convert to use device_t, cfdata_t and CFATTACH_DECL_NEW().

XXX: compile time tested only.
 1.54 11-Jun-2008  drochner mechanical changes to use device_private() or device_lookup_private()
to get softcs, makes the code compile under the stricter type checking
introduced earlier today
 1.53 04-Mar-2007  christos branches: 1.53.40; 1.53.42; 1.53.44; 1.53.46; 1.53.48;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.52 29-Mar-2006  thorpej branches: 1.52.14;
Use device_cfdata().
 1.51 11-Dec-2005  christos branches: 1.51.4; 1.51.6; 1.51.8; 1.51.10; 1.51.12;
merge ktrace-lwp.
 1.50 16-Nov-2005  uwe ANSIify function declarations/defintions. Use uint<N>_t.
Propagate "static" to function definitions. Drop trailing whitespace.
Same binary code is produced for GENERIC.MP + KGDB + DDB.
 1.49 25-Aug-2003  uwe branches: 1.49.16; 1.49.24;
Undo previous as it broke things.

There are some scattered implicit RASTERCONSOLE dependencies,
so there should be a better way.
 1.48 24-Aug-2003  uwe #include "opt_rcons.h"
 1.47 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.46 15-Jul-2003  lukem __KERNEL_RCSID()
 1.45 29-Jun-2003  fvdl branches: 1.45.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.44 29-Jun-2003  darrenr More changes for providing lwpid for ktrace (sparc GENERIC built)
 1.43 02-Apr-2003  thorpej Use PAGE_SIZE rather than NBPG.
 1.42 05-Dec-2002  fredette Fixed a null pointer passed to printf().
 1.41 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.40 02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.39 01-Oct-2002  thorpej Use CFATTACH_DECL().
 1.38 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.37 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.36 03-Aug-2002  itojun correct range check, have overflow check, fix type mismatches,
for cmap args and some other calls. from openbsd
 1.35 05-Aug-2001  jdolecek branches: 1.35.2; 1.35.6; 1.35.14; 1.35.16;
use unsigned variable types as appropriate
 1.34 22-Aug-2000  pk branches: 1.34.4;
Use the framebuffer drivers & header files that now live in /sys/dev/sun.
 1.33 29-Jun-2000  mrg remove include of <vm/vm.h> and <machine/pmap.h>. <vm/vm.h> -> <uvm/uvm_extern.h>
 1.32 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.31 19-Mar-2000  pk branches: 1.31.4;
Use fb_is_console(); retract fbconstty & fbnode from service.
 1.30 30-Jun-1999  drochner branches: 1.30.2;
update for new VME framework
 1.29 07-Apr-1998  pk branches: 1.29.10;
bus_space_mmap() has changed to take a `bus_space_handle_t *' argument,
like other bus space methods.
 1.28 21-Mar-1998  pk Account for changed bus attachment scheme.
 1.27 06-Feb-1998  pk vme_bus_probe() takes an `offset' argument.
 1.26 04-Feb-1998  pk Account for changed vme_bus_probe() arguments.
 1.25 28-Jan-1998  thorpej Use offsetof() from libkern.h
 1.24 25-Jan-1998  pk Convert to new VME interface.
 1.23 12-Jan-1998  thorpej Update for changes to config.
 1.22 24-May-1997  pk Remove all `bustype' arguments from map[io]dev() and REG2PHYS().
 1.21 19-May-1997  pk Replace bus_tmp() with mapdev() equivalent.
 1.20 10-Dec-1996  pk Comply with recent autoconfiguration changes. Diffs graciously
supplied by Chris Demetriou.
 1.19 13-Oct-1996  christos backout previous kprintf change
 1.18 11-Oct-1996  christos printf -> kprintf, sprintf -> ksprintf
 1.17 04-Oct-1996  thorpej Returning ENODEV is not correct in a poll entry point. Instead, since
read/write returns an error, use seltrue().
 1.16 18-May-1996  mrg use __P
 1.15 23-Apr-1996  pk Map the pixels explicitly on the VME32 bus.
 1.14 01-Apr-1996  christos Eliminated dependencies on dev_conf.h
 1.13 17-Mar-1996  pk Avoid "unused variable" warning.
 1.12 17-Mar-1996  thorpej New device attachment scheme:

- split softc size and match/attach out from cfdriver into
a new struct cfattach.

- new "attach" directive for files.*. May specify the name of
the cfattach structure, so that devices may be easily attached
to parents with different autoconfiguration semantics.
 1.11 14-Mar-1996  christos Bring prototypes into scope and fix compiler warnings.
 1.10 27-Feb-1996  thorpej First-cut support for P4 framebuffers. Currently supports P4 variants
of bwtwo, cgfour, cgsix, and cgeight. Includes support for attaching
the overlay plane of the cgfour and cgeight as a bwtwo instance (a'la
SunOS).

P4 register descriptions, cgfour driver, and cgeight driver partially
derived from OpenBSD.

This code may still need polishing.
 1.9 25-Feb-1996  pk Use CPU-type macros.
 1.8 11-Dec-1995  pk Adapt to changed mapiodev() interface.
 1.7 29-Nov-1995  pk Code from Jason to better configure /dev/fb.
 1.6 28-Oct-1995  pk Map pixels in VME32 space
 1.5 08-Oct-1995  pk branches: 1.5.2;
Patch from Jason to factor out a common framebuffer size determination
routine from the individual drivers.
 1.4 04-Oct-1995  pk RCONSOLE => RASTERCONSOLE.
 1.3 02-Oct-1995  pk Update to use <machine/cgtworeg.h>
 1.2 02-Oct-1995  pk Get some of the bugs out. Thanks to David Gilbert for testing.
 1.1 17-Sep-1995  pk cgtwo framebuffer, cloned from cgthree.c and sun3's cg2.c.
Note: untested, shall be considered a framework to get things started..
 1.5.2.2 16-Feb-1996  thorpej Pull in improved framebuffer autoconfiguration code from -current.
Prevents panics when multiple framebuffers are found on sun4 systems.
 1.5.2.1 28-Oct-1995  pk Update from trunk: Map pixels in VME32 space.
 1.29.10.1 01-Jul-1999  thorpej Sync w/ -current.
 1.30.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.31.4.2 16-Aug-2001  tv Pullup [jdolecek]:

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

Use unsigned variable types to make bounds checking more correct.
 1.31.4.1 30-Jun-2000  simonb Pull up mmap paddr_t/off_t changes from trunk.
 1.34.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.34.4.4 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.34.4.3 28-Jun-2002  jdolecek hook fbkqfilter to leaf drivers' kqfilter
 1.34.4.2 28-Jun-2002  jdolecek prove kqfilter hook; it's very simple equivalent of seltrue()
 1.34.4.1 25-Aug-2001  thorpej Merge Aug 24 -current into the kqueue branch.
 1.35.16.1 07-Aug-2002  lukem Pull up revision 1.36 (requested by itojun in ticket #616):
correct range check, have overflow check, fix type mismatches,
for cmap args and some other calls. from openbsd
 1.35.14.2 31-Aug-2002  gehenna catch up with -current.
 1.35.14.1 17-May-2002  gehenna Add device switch.
 1.35.6.6 11-Dec-2002  thorpej Sync with HEAD.
 1.35.6.5 11-Nov-2002  nathanw Catch up to -current
 1.35.6.4 18-Oct-2002  nathanw Catch up to -current.
 1.35.6.3 17-Sep-2002  nathanw Catch up to -current.
 1.35.6.2 13-Aug-2002  nathanw Catch up to -current.
 1.35.6.1 05-Aug-2001  nathanw file cgtwo.c was added on branch nathanw_sa on 2002-08-13 02:18:52 +0000
 1.35.2.1 10-Oct-2001  fvdl Convert all remaining devices.
 1.45.2.5 11-Dec-2005  christos Sync with head.
 1.45.2.4 04-Feb-2005  skrll Adapt to branch.
 1.45.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.45.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.45.2.1 03-Aug-2004  skrll Sync with HEAD
 1.49.24.1 22-Nov-2005  yamt sync with head.
 1.49.16.2 03-Sep-2007  yamt sync with head.
 1.49.16.1 21-Jun-2006  yamt sync with head.
 1.51.12.1 31-Mar-2006  tron Merge 2006-03-31 NetBSD-current into the "peter-altq" branch.
 1.51.10.1 19-Apr-2006  elad sync with head - hopefully this will work
 1.51.8.1 01-Apr-2006  yamt sync with head.
 1.51.6.1 22-Apr-2006  simonb Sync with head.
 1.51.4.1 09-Sep-2006  rpaulo sync with head
 1.52.14.1 12-Mar-2007  rmind Sync with HEAD.
 1.53.48.1 18-Jun-2008  simonb Sync with head.
 1.53.46.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.53.44.1 04-May-2009  yamt sync with head.
 1.53.42.1 17-Jun-2008  yamt sync with head.
 1.53.40.1 29-Jun-2008  mjf Sync with HEAD.
 1.55.16.1 18-May-2014  rmind sync with head
 1.55.12.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.55.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.56.2.1 10-Aug-2014  tls Rebase.
 1.3 02-Oct-1995  pk Silly me.. there's already a <machine/cgtworeg.h>
 1.2 02-Oct-1995  pk Get some of the bugs out. Thanks to David Gilbert for testing.
 1.1 17-Sep-1995  pk cgtwo framebuffer, cloned from cgthree.c and sun3's cg2.c.
Note: untested, shall be considered a framework to get things started..
 1.17 08-Dec-2018  thorpej Clean up initialization of com_regs structure, in preparation for
some additional changers.
 1.16 01-Jul-2011  dyoung branches: 1.16.52; 1.16.54;
#include <sys/bus.h> instead of <machine/bus.h>.
 1.15 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.14 14-Mar-2008  cube branches: 1.14.2; 1.14.4;
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.13 13-Jul-2006  gdamore branches: 1.13.34; 1.13.54; 1.13.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.12 16-Nov-2005  uwe branches: 1.12.4; 1.12.8; 1.12.16;
ANSIify.
 1.11 15-Jul-2003  lukem branches: 1.11.16; 1.11.24;
__KERNEL_RCSID()
 1.10 14-Jun-2003  thorpej branches: 1.10.2;
Also pass a type argument to comcnattach() and com_kgdb_attach().
comspeed() (and thus cominit()) may need this information.
 1.9 10-Dec-2002  pk Remove the `flags' argument from bus_intr_establish().
 1.8 08-Oct-2002  uwe G/c unnecessary includes.
 1.7 02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.6 01-Oct-2002  thorpej Use CFATTACH_DECL().
 1.5 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.4 12-Apr-2002  thorpej Set COM_HW_NO_TXPRELOAD.
 1.3 12-Mar-2002  uwe Drop ebus_bus_map(), use plain bus_space_map() instead.
 1.2 18-Feb-2002  uwe Switch to shared EBus headers in dev/ebus.
 1.1 11-Dec-2001  uwe branches: 1.1.2; 1.1.4;
Attachment for MI com(4) driver at ebus.
 1.1.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.1.4.4 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.1.4.3 16-Mar-2002  jdolecek Catch up with -current.
 1.1.4.2 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.1.4.1 11-Dec-2001  thorpej file com_ebus.c was added on branch kqueue on 2002-01-10 19:48:45 +0000
 1.1.2.7 11-Dec-2002  thorpej Sync with HEAD.
 1.1.2.6 18-Oct-2002  nathanw Catch up to -current.
 1.1.2.5 17-Apr-2002  nathanw Catch up to -current.
 1.1.2.4 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.1.2.3 28-Feb-2002  nathanw Catch up to -current.
 1.1.2.2 08-Jan-2002  nathanw Catch up to -current.
 1.1.2.1 11-Dec-2001  nathanw file com_ebus.c was added on branch nathanw_sa on 2002-01-08 00:27:34 +0000
 1.10.2.4 11-Dec-2005  christos 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.24.1 22-Nov-2005  yamt sync with head.
 1.11.16.3 17-Mar-2008  yamt sync with head.
 1.11.16.2 30-Dec-2006  yamt sync with head.
 1.11.16.1 21-Jun-2006  yamt sync with head.
 1.12.16.2 17-Jun-2006  gdamore Fix for another compile problem. bus_intr_establish takes a bus_space_tag_t
on sparc, caught me off-guard. Thanks to macallan@.
 1.12.16.1 15-Jun-2006  gdamore Adapt to new com framework.
 1.12.8.1 11-Aug-2006  yamt sync with head
 1.12.4.1 09-Sep-2006  rpaulo sync with head
 1.13.58.2 02-Jun-2008  mjf Sync with HEAD.
 1.13.58.1 03-Apr-2008  mjf Sync with HEAD.
 1.13.54.1 24-Mar-2008  keiichi sync with head.
 1.13.34.1 23-Mar-2008  matt sync with HEAD
 1.14.4.1 16-May-2008  yamt sync with head.
 1.14.2.1 18-May-2008  yamt sync with head.
 1.16.54.1 10-Jun-2019  christos Sync with HEAD
 1.16.52.1 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.25 08-Dec-2018  thorpej Clean up initialization of com_regs structure, in preparation for
some additional changers.
 1.24 01-Jul-2011  dyoung branches: 1.24.52; 1.24.54;
#include <sys/bus.h> instead of <machine/bus.h>.
 1.23 21-Nov-2009  rmind Use lwp_getpcb() on sparc{64} and sun2/3 MD code, clean from struct user usage.
 1.22 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.21 14-Mar-2008  cube branches: 1.21.2; 1.21.4;
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.20 29-Feb-2008  dyoung Use pmf_device_register1() instead of shutdownhook_establish() to
register com_cleanup() as the shutdown hook.

Add a generic suspend routine. Suspend and resume com@isa.

Protect against dereferencing a NULL softc in comioctl().

Destroy both a mutex and a callout in com_detach().

Cosmetic: use aprint_*_dev(). Use PMF_FN_ARGS, PMF_FN_PROTO.
 1.19 13-Jul-2006  gdamore branches: 1.19.34; 1.19.54; 1.19.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.18 16-Nov-2005  uwe branches: 1.18.4; 1.18.8; 1.18.16;
ANSIify function declarations/defintions. Use uint<N>_t.
Propagate "static" to function definitions. Drop trailing whitespace.
Same binary code is produced for GENERIC.MP + KGDB + DDB.
 1.17 28-Oct-2003  chs branches: 1.17.16; 1.17.24;
uninitialized variables.
 1.16 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.15 15-Jul-2003  lukem __KERNEL_RCSID()
 1.14 14-Jun-2003  thorpej branches: 1.14.2;
Also pass a type argument to comcnattach() and com_kgdb_attach().
comspeed() (and thus cominit()) may need this information.
 1.13 10-Dec-2002  pk Remove the `flags' argument from bus_intr_establish().
 1.12 02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.11 01-Oct-2002  thorpej Use CFATTACH_DECL().
 1.10 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.9 11-Mar-2002  pk * `bus_type_t' is gone.
* Use BUS_ADDR() where appropriate to encode I/O space and physical
address offset into a `bus_addr_t' value.
* Drop obio_bus_map() since it's now completely equivalent to bus_space_map()
* Use bus_space_map2() to map device space at a fixed virtual address.
* Remove the virtual address argument from sbus_sbus_addr()
 1.8 20-Jun-2001  uwe branches: 1.8.2; 1.8.8;
Attach serial console at com.
 1.7 15-Jul-2000  matt Enhance this so it support the com port on the JavaStation 1 as well as
the tadpole internal modem.
 1.6 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.5 04-Jun-2000  cgd branches: 1.5.2;
Implement the more flexiable `evcnt' interface as discussed (briefly) on
tech-kern and now documented in evcnt(9).
 1.4 21-Nov-1999  pk branches: 1.4.2;
Check presence of Sbus interrupt properties before using them.
 1.3 12-Nov-1999  matt turns we need to tweak the auxio1 reg to enable the modem. also fix a call
to sbus_bus_map. it's closer to working but I wonder if COM_FREQ is the
right value.
 1.2 03-Aug-1999  matt branches: 1.2.2; 1.2.4; 1.2.8;
Remove the false positive on the probe of the built-in modem
on tadpoles by calling comprobe1 to see if the modem is really
there.
 1.1 30-Jul-1999  matt branches: 1.1.2;
Add preliminary support for the built-in modem on Tadpole 3GX/S
laptops. There is currently something wrong with the interrupt
code but it does attach and sense a 16550a. (anyways the built
in modem is only a 14.4Kb and you'd really want to use a PCMCIA
modem to get faster dialup rates).
 1.1.2.2 02-Aug-1999  thorpej Update from trunk.
 1.1.2.1 30-Jul-1999  thorpej file com_obio.c was added on branch chs-ubc2 on 1999-08-02 20:09:13 +0000
 1.2.8.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.2.4.1 15-Nov-1999  fvdl Sync with -current
 1.2.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.4.2.1 22-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.5.2.1 19-Jul-2000  mrg pull up sparc/sparc64 bus_intr_establish() changes, necessary for sparc64
(originally done by pk, approved by thorpej):

>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.8.8.4 11-Dec-2002  thorpej Sync with HEAD.
 1.8.8.3 18-Oct-2002  nathanw Catch up to -current.
 1.8.8.2 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.8.8.1 20-Jun-2001  nathanw file com_obio.c was added on branch nathanw_sa on 2002-04-01 07:42:40 +0000
 1.8.2.2 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.8.2.1 16-Mar-2002  jdolecek Catch up with -current.
 1.14.2.4 11-Dec-2005  christos Sync with head.
 1.14.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.14.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.14.2.1 03-Aug-2004  skrll Sync with HEAD
 1.17.24.1 22-Nov-2005  yamt sync with head.
 1.17.16.3 17-Mar-2008  yamt sync with head.
 1.17.16.2 30-Dec-2006  yamt sync with head.
 1.17.16.1 21-Jun-2006  yamt sync with head.
 1.18.16.3 17-Jun-2006  gdamore Oops... left a static around.
 1.18.16.2 17-Jun-2006  gdamore Fix problems found by macallan@.
 1.18.16.1 15-Jun-2006  gdamore Adapt to new com framework.
 1.18.8.1 11-Aug-2006  yamt sync with head
 1.18.4.1 09-Sep-2006  rpaulo sync with head
 1.19.58.2 02-Jun-2008  mjf Sync with HEAD.
 1.19.58.1 03-Apr-2008  mjf Sync with HEAD.
 1.19.54.1 24-Mar-2008  keiichi sync with head.
 1.19.34.1 23-Mar-2008  matt sync with HEAD
 1.21.4.2 11-Mar-2010  yamt sync with head
 1.21.4.1 16-May-2008  yamt sync with head.
 1.21.2.1 18-May-2008  yamt sync with head.
 1.24.54.1 10-Jun-2019  christos Sync with HEAD
 1.24.52.1 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.31 18-Oct-1997  gwr Use common zs code.
 1.30 07-Jul-1997  pk Get console tty size from raster console if applicable.
 1.29 13-Oct-1996  christos backout previous kprintf change
 1.28 11-Oct-1996  christos printf -> kprintf, sprintf -> ksprintf
 1.27 12-Sep-1996  mrg update these for poll(2) changes.
 1.26 05-Sep-1996  thorpej Make the SPARC kernel compile again after recent tty cdevsw changes.
 1.25 02-Sep-1996  mycroft tty stop functions really should return void, not int, and certainly not both.
 1.24 29-May-1996  mrg impliment ttylist stats based on disk stats.
 1.23 19-May-1996  mrg branches: 1.23.4;
set the console struct winsize to the values given in the prom (sun4c/sun4m)
or the eeprom (sun4) when opening the console. (note: sun4 code untested
but jason claims it will `Just Work').
 1.22 18-May-1996  mrg put promdev definition into <machine/bsd_openprom.h>.
 1.21 22-Apr-1996  christos Remove dependency on <sys/cpu.h>
 1.20 01-Apr-1996  christos Eliminated dependencies on dev_conf.h
 1.19 31-Mar-1996  pk Various cleanup; mostly trailing spaces/tabs.
 1.18 14-Mar-1996  christos Bring prototypes into scope and fix compiler warnings.
 1.17 25-Feb-1996  pk Use CPU-type macros.
 1.16 13-Feb-1996  pk Fix ANSI prototype goof (from Openbsd).
Add explicit return type to most functions.
V3 PROM console support.
 1.15 13-Jul-1995  pk Move SUN4 console echo hack cnget() (from Chuck Cranor).
 1.14 01-Jun-1995  pk Deal with v.3 proms (sigh).
 1.13 25-Apr-1995  pk Stop-gap measure to prevent panic when select()ing on /dev/console.
 1.12 10-Apr-1995  mycroft cn_tty is unneeded.
 1.11 25-Nov-1994  deraadt cnpollc function for DDB
 1.10 20-Nov-1994  deraadt copyright/Id cleanup
 1.9 02-Nov-1994  deraadt ioctl u_long cmd
 1.8 13-May-1994  deraadt play nice with new tty code
 1.7 05-May-1994  deraadt timeout and ndflush casts
 1.6 14-Feb-1994  deraadt ioctl takes a proc *
 1.5 10-Nov-1993  deraadt s/cntty/cn_tty/
 1.4 13-Oct-1993  deraadt fix typos
 1.3 13-Oct-1993  deraadt fixups for dynamic tty allocation:
cdevsw[]->d_ttys must be initialized
XXstop() functions must be callable from cdevsw[]->d_stop
the console tty is used before vm system is up, and must
allocate it's own clists..
 1.2 11-Oct-1993  deraadt cons.c, zs.c: tty->t_stop doesn't exist here. I think it goes through d_stop
automatically now, but have not checked.
l_ioctl() has no last parameter 'p'
fb.c: move sys/fbio.h to machine/fbio.h
various: typecast parms for timeout() properly
zs.c: extra level of indir in cdevsw[]->d_ttys
 1.1 02-Oct-1993  deraadt Chris Torek's sparc port. Missing lots of things.
 1.23.4.1 02-Jun-1996  mrg pull up tty stats "bug fix".
 1.6 24-Jan-2021  mrg avoid using 'extern <func|data>;' inside a .c file, but instead
use header files and ensure definitions are not duplicated or
are technically (if not in codegen) wrong.
 1.5 16-Nov-2005  uwe branches: 1.5.178;
ANSIify function declarations/defintions. Use uint<N>_t.
Propagate "static" to function definitions. Drop trailing whitespace.
Same binary code is produced for GENERIC.MP + KGDB + DDB.
 1.4 19-Mar-2000  pk branches: 1.4.28; 1.4.44; 1.4.52;
Declare the prom stdio nodes and arguments.
 1.3 12-Feb-2000  pk Eliminate much of the goo in setting up zs device addressing.
 1.2 05-Jan-1998  perry branches: 1.2.14;
RCSID Police.
 1.1 18-Oct-1997  gwr Use common zs code.
 1.2.14.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.4.52.1 22-Nov-2005  yamt sync with head.
 1.4.44.1 21-Jun-2006  yamt sync with head.
 1.4.28.1 11-Dec-2005  christos Sync with head.
 1.5.178.1 03-Apr-2021  thorpej Sync with HEAD.
 1.2 01-Apr-1996  christos Remove last dependency to dev_conf.h and the file itself.
 1.1 14-Mar-1996  christos Bring prototypes into scope and fix compiler warnings.
 1.57 29-Aug-1998  pk Split `esp' driver and DMA engine into separate front-end files.
The Sbus front-ends have all been moved to `sys/dev/sbus', while
the `obio' front-ends remain here.
 1.56 28-Aug-1998  pk Remove cache flush from dma_espintr(); the bus dma routines take care
of that now. Hence we no longer need <sparc/cpuvar.h>.
 1.55 30-Jul-1998  pk Use bus_dma_*() instead of dvma_mapin/dvma_mapout.
 1.54 29-Jul-1998  pk branches: 1.54.2;
Deal with sbus attch args changes.
Use sbus_destroy_attach_args().
 1.53 27-Jul-1998  pk <sparc/dev/sbusvar.h> => <dev/sbus/sbusvar.h>
 1.52 07-Apr-1998  pk The bus space functions now take care of "pass-through" methods.
 1.51 29-Mar-1998  pk Fill in the bus tag's `bus_space_unmap' method.
 1.50 21-Mar-1998  pk Switch to a bus_space(9)-based device attachment scheme.
The dma & lebuffer devices behave like busses to accommodate the
OBP layout. For practical purposes, they are implemented as
Sbus "extensions".
 1.49 07-Feb-1998  pk Define a `DMA_FLUSH' macro; dma chip revs 0 & 1 have a different bit
to reset the internal state engine.
 1.48 12-Jan-1998  thorpej Update for changes to config.
 1.47 16-Oct-1997  mycroft branches: 1.47.2;
Fix up includes.
 1.46 27-Aug-1997  bouyer Merge scsipi branch in the mainline. This add support for ATAPI devices
(currently only CD-ROM drives on i386). The sys/dev/scsipi system provides 2
busses to which devices can attach (scsibus and atapibus). This needed to
change some include files and structure names in the low level scsi drivers.
 1.45 29-Jul-1997  fair branches: 1.45.2;
%x -> 0x%x
 1.44 26-Jun-1997  thorpej branches: 1.44.2;
Don't print a warning if the returned transfer count is less than 0.
This can happen during perfectly normal operation if:
(a) We are using DMA to select a target, and
(b) we are interrupted by another target reselecting us.
Per discussion with Paul Krannenburg.
 1.43 24-May-1997  pk Remove all `bustype' arguments from map[io]dev() and REG2PHYS().
 1.42 27-Apr-1997  pk Remove esp FLUSH when residual bytes are present in FIFO, the ncr53c9x
driver will flush when necessary. Doing the FLUSH here interferes
with DMA-enabled target selection.
 1.41 23-Mar-1997  pk Clamp burst sizes to maximum value of parent.
Reset ledma from leattach().
 1.40 10-Mar-1997  pk Replace `cpumod' with `cpuinfo.cpu_type' equivalents.
 1.39 27-Feb-1997  thorpej Update for MI 53c9x driver.
 1.38 10-Dec-1996  pk branches: 1.38.6;
Comply with recent autoconfiguration changes. Diffs graciously
supplied by Chris Demetriou.
 1.37 28-Nov-1996  pk Handle Sbus burst settings in dma reset().
 1.36 27-Nov-1996  pk Handle the `ESC gate array' variant of the DMA engine, including an
essential bug work-around. Graciously supplied by David Miller.

Also re-arrange the macros that do the dma drain song-and-dance for
better clarity.
 1.35 13-Nov-1996  thorpej Use bitmask_snprintf().
 1.34 13-Oct-1996  christos backout previous kprintf change
 1.33 11-Oct-1996  christos printf -> kprintf, sprintf -> ksprintf
 1.32 27-Aug-1996  cgd change cfprint_t type definition to take a const char *, rather than
a char *, because that's what was really intended, and because
if the print function modifies the string, various things could become
unhappy (so the string should _not_ be modified).
 1.31 29-Jun-1996  pk Avoid compiler warning on SUN4-only kernels.
 1.30 12-Jun-1996  pk Use the setting of the ESPCFG2_FE bit rather than revision number to decide
on the ESP chip's maximum transfer count.
 1.29 03-Jun-1996  pk Code the residual computation a bit differently.
 1.28 21-May-1996  pk branches: 1.28.2;
Allow all esp dma channels to be called `dma'.
 1.27 17-May-1996  pk Correct an oversight and a silly past-o in last change.
 1.26 16-May-1996  pk Re-arrange code that looks for the esp driver to allow for the fact that
any "dma" device (i.e. not just "espdma") can have an OBP child. This is
the case with (at least some) SBus SCSI boards.
 1.25 22-Apr-1996  abrown - Changed Sun4m DMA chip support to detect and use maximum available SBus
burst size when transferring data.
- Changed ledma attach code to pay attention to the PROM's notion of what
cable type is being used. Note that this patch does not fix the problem
recently discussed on port-sparc; in most cases the PROM doesn't know
what cable type is being used. The default is now TP rather than AUI,
though. A complete fix is forthcoming.
 1.24 01-Apr-1996  christos Remove casts of printf args for %b format.
 1.23 31-Mar-1996  pk Handle sun4m `ledma' and `espdma'.
DMA setup requires services of the IOMMU.
 1.22 26-Mar-1996  pk Bitfields are unsigned.
 1.21 26-Mar-1996  pk Back to normal printf()s, now that gcc understands `%b'.
 1.20 17-Mar-1996  thorpej New device attachment scheme:

- split softc size and match/attach out from cfdriver into
a new struct cfattach.

- new "attach" directive for files.*. May specify the name of
the cfattach structure, so that devices may be easily attached
to parents with different autoconfiguration semantics.
 1.19 14-Mar-1996  christos Bring prototypes into scope and fix compiler warnings.
 1.18 27-Feb-1996  pk Drain rev 1 chips in dma_reset().
 1.17 12-Feb-1996  pk Separate DMA and SCSI routines more.
 1.16 12-Jan-1996  chuck dmamatch never added in the offset for the dma registers to the VA,
and thus probed the wrong address on the 4/300 (but it worked because
it was probing the esp0 registers!).

now that bus_tmp() adds the offset in for us [as of obio 1.19] i
discoved that a byte access to the dma registers is not allowed.
so, i've change probeget to use a word access.
 1.15 18-Dec-1995  pk Towards machine independency, per cgd: macros to access hardware registers.
 1.14 11-Dec-1995  pk Adapt to changed mapiodev() interface.
 1.13 28-Nov-1995  pk Careful with signed chars (caddr_t *!).
Merge in 1.1 changes.
 1.12 03-Nov-1995  pk Stop DMA before resetting
 1.11 24-Oct-1995  pk Move DMA chip draining to dmaintr() and drain when a (possibly partial)
transfer ends in stead of doing it before starting a new transfer.
Use a different CSR bit to wait for "chip not busy" (may be necessary to
make this conditional on chip revision).
 1.10 18-Aug-1995  pk branches: 1.10.2;
Use bootpath_store() to set next boot component; used in dk_establish()
to match `sd' devices against the PROM's boot path.

Detect DMA "overshoots" when handling odd-sized transfer sizes (e.g., xfers
from/to raw partitions), by using the "Transfer Pad" command when the
transfer count reaches zero.
 1.9 01-Mar-1995  pk Better 4/100 support.
 1.8 01-Feb-1995  pk Integrate changes from Chuck Cranor for the Sun 4/100.
Support for multiple register banks on SBUS devices (based on patches
from Francis Dupont).
Highlights:
romaux defines an array of register spaces.
pay attention to `vactype'.
quirks handling 4/100 idiosyncracies.
 1.7 25-Nov-1994  deraadt no need to turn DMA off twice
 1.6 23-Nov-1994  deraadt XXmatch change (and a few __P() as well)
 1.5 20-Nov-1994  deraadt copyright/Id cleanup
 1.4 15-Oct-1994  deraadt sbus_establish() is sun4c/sun4m specific
 1.3 15-Oct-1994  deraadt mapiodev takes a bustype argument now
 1.2 02-Oct-1994  deraadt sun4/300 support works
 1.1 17-Sep-1994  deraadt Replacement esp (NCR 53C9X + LSI DMA) scsi driver from Peter Galbavy.
 1.10.2.4 26-Feb-1996  pk From trunk: DMArev1 drainage.
 1.10.2.3 17-Feb-1996  pk Pull over fixes from trunk.
 1.10.2.2 12-Nov-1995  pk Incorporate error-recovery fixes from trunk.
 1.10.2.1 24-Oct-1995  pk Update from trunk: various
 1.28.2.2 02-Jul-1996  jtc merge in rev 1.30=>1.31:
> Avoid compiler warning on SUN4-only kernels.
 1.28.2.1 12-Jun-1996  pk Pull down from trunk:
>rev 1.30: Use the setting of the ESPCFG2_FE bit rather than revision number ...
>rev 1.29: Code the residual computation a bit differently.
 1.38.6.1 12-Mar-1997  is Merge in changes from The Trunk
 1.44.2.2 30-Jul-1997  bouyer Sync with trunk.
 1.44.2.1 01-Jul-1997  bouyer Updates for new scsipi subsystem. Actally known to work on i386 and sparc.
 1.45.2.1 27-Aug-1997  thorpej Update marc-pcmcia branch from trunk.
 1.47.2.1 07-Feb-1998  mellon Pull up 1.49 (pk)
 1.54.2.1 08-Aug-1998  eeh Revert cdevsw mmap routines to return int.
 1.13 20-Dec-2023  thorpej Remove unnecessary <sys/malloc.h>.
 1.12 01-Jul-2011  dyoung #include <sys/bus.h> instead of <machine/bus.h>.
 1.11 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.10 13-Apr-2008  tsutsui branches: 1.10.2; 1.10.4;
Split device_t/softc for MI ncr53c9x and some related devices,
with various cleanup.
 1.9 16-Nov-2005  uwe branches: 1.9.74;
ANSIify function declarations/defintions. Use uint<N>_t.
Propagate "static" to function definitions. Drop trailing whitespace.
Same binary code is produced for GENERIC.MP + KGDB + DDB.
 1.8 15-Jul-2003  lukem branches: 1.8.16; 1.8.24;
__KERNEL_RCSID()
 1.7 02-Oct-2002  thorpej branches: 1.7.6;
Add trailing ; to CFATTACH_DECL.
 1.6 01-Oct-2002  thorpej Use CFATTACH_DECL().
 1.5 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.4 11-Mar-2002  pk * `bus_type_t' is gone.
* Use BUS_ADDR() where appropriate to encode I/O space and physical
address offset into a `bus_addr_t' value.
* Drop obio_bus_map() since it's now completely equivalent to bus_space_map()
* Use bus_space_map2() to map device space at a fixed virtual address.
* Remove the virtual address argument from sbus_sbus_addr()
 1.3 12-Apr-1999  pk branches: 1.3.16; 1.3.20;
Identify ourselves as a SCSI channel to the DMA chip.
 1.2 29-Aug-1998  pk branches: 1.2.6;
Adjust for some small changes in lsi64854 back-end driver.
 1.1 29-Aug-1998  pk Split `esp' driver and DMA engine into separate front-end files.
The Sbus front-ends have all been moved to `sys/dev/sbus', while
the `obio' front-ends remain here.
 1.2.6.1 13-Apr-1999  pk branches: 1.2.6.1.2;
Pull up rev 1.3 from trunk.
 1.2.6.1.2.1 21-Jun-1999  thorpej Sync w/ -current.
 1.3.20.2 18-Oct-2002  nathanw Catch up to -current.
 1.3.20.1 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.3.16.2 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.3.16.1 16-Mar-2002  jdolecek Catch up with -current.
 1.7.6.4 11-Dec-2005  christos Sync with head.
 1.7.6.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.7.6.2 18-Sep-2004  skrll Sync with HEAD.
 1.7.6.1 03-Aug-2004  skrll Sync with HEAD
 1.8.24.1 22-Nov-2005  yamt sync with head.
 1.8.16.1 21-Jun-2006  yamt sync with head.
 1.9.74.1 02-Jun-2008  mjf 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.12 29-Aug-1998  pk Split `esp' driver and DMA engine into separate front-end files.
The Sbus front-ends have all been moved to `sys/dev/sbus', while
the `obio' front-ends remain here.
 1.11 27-Jul-1998  pk SBU_BURST_* are now in <dev/sbus/sbusvar.h>
 1.10 28-Nov-1996  pk Fix typo in D_BURST* macros.
 1.9 27-Nov-1996  pk Add some `DMA ESC gate array' specific constants.
 1.8 22-Apr-1996  abrown - Changed Sun4m DMA chip support to detect and use maximum available SBus
burst size when transferring data.
- Changed ledma attach code to pay attention to the PROM's notion of what
cable type is being used. Note that this patch does not fix the problem
recently discussed on port-sparc; in most cases the PROM doesn't know
what cable type is being used. The default is now TP rather than AUI,
though. A complete fix is forthcoming.
 1.7 31-Mar-1996  pk Handle sun4m `ledma' and `espdma'.
DMA setup requires services of the IOMMU.
 1.6 11-Dec-1995  pk Adapt to changed mapiodev() interface.
 1.5 20-Nov-1994  deraadt branches: 1.5.2;
copyright/Id cleanup
 1.4 28-Oct-1994  deraadt repair a type
 1.3 02-Oct-1994  deraadt sun4/300 support works
 1.2 17-Sep-1994  deraadt Replacement esp (NCR 53C9X + LSI DMA) scsi driver from Peter Galbavy.
 1.1 02-Oct-1993  deraadt Chris Torek's sparc port. Missing lots of things.
 1.5.2.1 17-Feb-1996  pk Pull over fixes from trunk.
 1.14 29-Aug-1998  pk Split `esp' driver and DMA engine into separate front-end files.
The Sbus front-ends have all been moved to `sys/dev/sbus', while
the `obio' front-ends remain here.
 1.13 30-Jul-1998  pk Use bus_dma_*() instead of dvma_mapin/dvma_mapout.
 1.12 21-Mar-1998  pk branches: 1.12.2;
Add bus tags.
Add interrupt chaining facility (currently used for `le'; the `esp'
device should follow).
 1.11 27-Nov-1996  pk DMA draining macros have moved to dma.c
 1.10 13-Oct-1996  christos backout previous kprintf change
 1.9 11-Oct-1996  christos printf -> kprintf, sprintf -> ksprintf
 1.8 22-Apr-1996  abrown - Changed Sun4m DMA chip support to detect and use maximum available SBus
burst size when transferring data.
- Changed ledma attach code to pay attention to the PROM's notion of what
cable type is being used. Note that this patch does not fix the problem
recently discussed on port-sparc; in most cases the PROM doesn't know
what cable type is being used. The default is now TP rather than AUI,
though. A complete fix is forthcoming.
 1.7 31-Mar-1996  pk Handle sun4m `ledma' and `espdma'.
DMA setup requires services of the IOMMU.
 1.6 16-Mar-1996  christos fix format in printf()
 1.5 12-Feb-1996  pk Separate DMA and SCSI routines more.
 1.4 27-Nov-1994  deraadt branches: 1.4.2;
debug code for dma hang
 1.3 20-Nov-1994  deraadt copyright/Id cleanup
 1.2 02-Oct-1994  deraadt sun4/300 support works
 1.1 17-Sep-1994  deraadt Replacement esp (NCR 53C9X + LSI DMA) scsi driver from Peter Galbavy.
 1.4.2.1 17-Feb-1996  pk Pull over fixes from trunk.
 1.12.2.1 08-Aug-1998  eeh Revert cdevsw mmap routines to return int.
 1.42 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.41 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.40 10-May-2021  thorpej branches: 1.40.4;
Associate the OpenBoot / OpenFirmware node with attached devices
at config_found() time.
 1.39 24-Apr-2021  thorpej branches: 1.39.2; 1.39.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.38 22-Nov-2020  thorpej branches: 1.38.2;
malloc(9) -> kmem(9) (easy, straight-forward cases only, for now)
 1.37 10-Nov-2019  chs branches: 1.37.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.36 18-Oct-2019  msaitoh s/initalize/initialize/ in comment or printf message.
 1.35 18-Oct-2014  snj branches: 1.35.20;
src is too big these days to tolerate superfluous apostrophes. It's
"its", people!
 1.34 30-Jan-2012  mrg branches: 1.34.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.33 18-Jul-2011  mrg branches: 1.33.2; 1.33.6;
convert the remaining sparc drivers to CFATTACH_DECL_NEW/cfdata_t/device_t.
(cgsix_obio.c was only partially converted with the rest of the cgsix code
when it was changed some time ago.)
 1.32 01-Jul-2011  dyoung #include <sys/bus.h> instead of <machine/bus.h>.
 1.31 20-Sep-2009  tsutsui - use device_t and cfdriver_t
- use device_private() and device_xname()
- use proper types or variables for device_t/softc
 1.30 29-May-2008  mrg remove clause #3 from my license where there are no other
copyright holders involved.
 1.29 17-Oct-2007  garbled branches: 1.29.16; 1.29.18; 1.29.20; 1.29.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.28 09-Jul-2007  ad branches: 1.28.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.27 04-Mar-2007  christos branches: 1.27.2; 1.27.4; 1.27.10;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.26 25-Feb-2007  uwe G/c debugging printf (hi, macallan!).
 1.25 02-Jul-2006  jdc branches: 1.25.10;
PCI device list and interrupt mapping for JavaStation Espresso.
Interrupt line values from Linux sparc sources.
 1.24 24-Nov-2005  he branches: 1.24.4; 1.24.8; 1.24.16;
Remove declaration of a variable which is no longer used.
 1.23 24-Nov-2005  he Make sure the file ends with a newline, so the port builds again.
 1.22 22-Nov-2005  macallan add support for options BLINK
 1.21 16-Nov-2005  uwe ANSIify. Use uint<N>_t. Drop unnecessary inlcudes.
Declare as static everything we don't need to export.
 1.20 12-Aug-2005  macallan branches: 1.20.6;
revert previous version, will create a device node in the boot loader instead
 1.19 12-Aug-2005  macallan For Krups only - attach audiocs at ebus even if there's no sound node in the
device tree. Works only as long as the cs4231 driver doesn't attempt to use
the node since we can't really supply one.
Tested on a Krups with OF 3.11.10
 1.18 10-Jul-2004  pk branches: 1.18.12;
Use bus_space_tag_alloc().
 1.17 24-Apr-2004  kleink Update for new pci_devinfo(9) signature.
 1.16 17-Mar-2004  pk Rename PROM_getprop*() => prom_getprop*().
 1.15 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.14 15-Jul-2003  lukem __KERNEL_RCSID()
 1.13 03-May-2003  wiz branches: 1.13.2;
DMA, not dma nor Dma.
 1.12 26-Feb-2003  pk Move all `ID prom' stuff into the prom library.
 1.11 01-Jan-2003  thorpej Use aprint_normal() for cfprint routines.
 1.10 10-Dec-2002  pk Remove the `flags' argument from bus_intr_establish().
 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 11-Mar-2002  uwe Do not pass bus type argument (R.I.P.) to bus_space_map2.
 1.5 11-Mar-2002  pk * `bus_type_t' is gone.
* Use BUS_ADDR() where appropriate to encode I/O space and physical
address offset into a `bus_addr_t' value.
* Drop obio_bus_map() since it's now completely equivalent to bus_space_map()
* Use bus_space_map2() to map device space at a fixed virtual address.
* Remove the virtual address argument from sbus_sbus_addr()
 1.4 18-Feb-2002  uwe Convert to use shared headers in dev/ebus. Move ebus_softc definition here.
Normalize bar field of EBus children PROM "reg" property to be the BAR
offset in PCI config space like on sparc64 when building ebus_attach_args.
 1.3 08-Feb-2002  uwe Cosmetic changes: clean up debugging ifdefs and use consistent wording
in panic messages.
 1.2 31-Jan-2002  uwe Auto-configuration output formatting nit.
Don't start the attachment message on a new line.
 1.1 11-Dec-2001  uwe branches: 1.1.2; 1.1.4;
EBus support for ms-IIep.
 1.1.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.1.4.4 16-Mar-2002  jdolecek Catch up with -current.
 1.1.4.3 11-Feb-2002  jdolecek Sync w/ -current.
 1.1.4.2 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.1.4.1 11-Dec-2001  thorpej file ebus.c was added on branch kqueue on 2002-01-10 19:48:45 +0000
 1.1.2.7 03-Jan-2003  thorpej Sync with HEAD.

XXX ALT_SWITCH_CODE is not yet LWP'ified.
 1.1.2.6 11-Dec-2002  thorpej Sync with HEAD.
 1.1.2.5 18-Oct-2002  nathanw Catch up to -current.
 1.1.2.4 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.1.2.3 28-Feb-2002  nathanw Catch up to -current.
 1.1.2.2 08-Jan-2002  nathanw Catch up to -current.
 1.1.2.1 11-Dec-2001  nathanw file ebus.c was added on branch nathanw_sa on 2002-01-08 00:27:35 +0000
 1.13.2.5 11-Dec-2005  christos Sync with head.
 1.13.2.4 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.13.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.13.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.13.2.1 03-Aug-2004  skrll Sync with HEAD
 1.18.12.4 03-Sep-2007  yamt sync with head.
 1.18.12.3 26-Feb-2007  yamt sync with head.
 1.18.12.2 30-Dec-2006  yamt sync with head.
 1.18.12.1 21-Jun-2006  yamt sync with head.
 1.20.6.2 29-Nov-2005  yamt sync with head.
 1.20.6.1 22-Nov-2005  yamt sync with head.
 1.24.16.1 13-Jul-2006  gdamore Merge from HEAD.
 1.24.8.1 11-Aug-2006  yamt sync with head
 1.24.4.1 09-Sep-2006  rpaulo sync with head
 1.25.10.2 12-Mar-2007  rmind Sync with HEAD.
 1.25.10.1 27-Feb-2007  yamt - sync with head.
- move sched_changepri back to kern_synch.c as it doesn't know PPQ anymore.
 1.27.10.1 03-Oct-2007  garbled Sync with HEAD
 1.27.4.1 11-Jul-2007  mjf Sync with head.
 1.27.2.1 15-Jul-2007  ad Sync with head.
 1.28.10.1 06-Nov-2007  matt sync with HEAD
 1.29.22.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.29.20.2 11-Mar-2010  yamt sync with head
 1.29.20.1 04-May-2009  yamt sync with head.
 1.29.18.1 04-Jun-2008  yamt sync with head
 1.29.16.1 02-Jun-2008  mjf Sync with HEAD.
 1.33.6.1 18-Feb-2012  mrg merge to -current.
 1.33.2.1 17-Apr-2012  yamt sync with head
 1.34.6.1 03-Dec-2017  jdolecek update from HEAD
 1.35.20.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.37.8.1 14-Dec-2020  thorpej Sync w/ HEAD.
 1.38.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.39.4.1 31-May-2021  cjep sync with head
 1.39.2.1 13-May-2021  thorpej Sync with HEAD.
 1.40.4.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.3 18-Feb-2002  uwe We are using shared headers from dev/ebus now.
 1.2 11-Dec-2001  uwe branches: 1.2.2; 1.2.4;
tabify
 1.1 11-Dec-2001  uwe EBus support for ms-IIep. This file should eventually be merged into
sys/dev/ebus/ebusreg.h and shared with sparc64 port.
 1.2.4.3 16-Mar-2002  jdolecek Catch up with -current.
 1.2.4.2 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.2.4.1 11-Dec-2001  thorpej file ebusreg.h was added on branch kqueue on 2002-01-10 19:48:45 +0000
 1.2.2.3 28-Feb-2002  nathanw Catch up to -current.
 1.2.2.2 08-Jan-2002  nathanw Catch up to -current.
 1.2.2.1 11-Dec-2001  nathanw file ebusreg.h was added on branch nathanw_sa on 2002-01-08 00:27:35 +0000
 1.2 18-Feb-2002  uwe We are using shared headers from dev/ebus now.
 1.1 11-Dec-2001  uwe branches: 1.1.2; 1.1.4;
EBus support for ms-IIep.
 1.1.4.3 16-Mar-2002  jdolecek Catch up with -current.
 1.1.4.2 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.1.4.1 11-Dec-2001  thorpej file ebusvar.h was added on branch kqueue on 2002-01-10 19:48:45 +0000
 1.1.2.3 28-Feb-2002  nathanw Catch up to -current.
 1.1.2.2 08-Jan-2002  nathanw Catch up to -current.
 1.1.2.1 11-Dec-2001  nathanw file ebusvar.h was added on branch nathanw_sa on 2002-01-08 00:27:35 +0000
 1.78 29-Aug-1998  pk Split `esp' driver and DMA engine into separate front-end files.
The Sbus front-ends have all been moved to `sys/dev/sbus', while
the `obio' front-ends remain here.
 1.77 15-Aug-1998  mycroft Minor edit.
 1.76 15-Aug-1998  mycroft Assign copyright to TNF.
 1.75 29-Jul-1998  pk Deal with sbus attach args changes.
 1.74 27-Jul-1998  pk <sparc/dev/sbusvar.h> => <dev/sbus/sbusvar.h>
 1.73 29-Mar-1998  pk obio_bus_probe() => bus_space_probe()
 1.72 21-Mar-1998  pk Account for changed bus attachment scheme.
 1.71 12-Jan-1998  thorpej Update for changes to config.
 1.70 05-Oct-1997  thorpej Copyright assigned to The NetBSD Foundation.
 1.69 27-Aug-1997  bouyer Merge scsipi branch in the mainline. This add support for ATAPI devices
(currently only CD-ROM drives on i386). The sys/dev/scsipi system provides 2
busses to which devices can attach (scsibus and atapibus). This needed to
change some include files and structure names in the low level scsi drivers.
 1.68 19-Jul-1997  pk branches: 1.68.2;
Use `target selection with DMA' by default.
 1.67 24-May-1997  pk branches: 1.67.2;
Remove all `bustype' arguments from map[io]dev() and REG2PHYS().
 1.66 27-Feb-1997  thorpej Convert the SPARC esp driver to be a front-end for the MI 53c9x driver.
 1.65 10-Dec-1996  pk branches: 1.65.6;
Comply with recent autoconfiguration changes. Diffs graciously
supplied by Chris Demetriou.
 1.64 10-Dec-1996  thorpej Fill in sc_link.max_target
 1.63 27-Nov-1996  pk Cancel any queued timer events before re-scheduling a timeout, so esp_abort()
can be called from other places besides the timeout handler.
 1.62 27-Nov-1996  pk Pay attention to DMA errors as reported by DMAINTR() returning -1. If this
happens reset everything.

Re-schedule a timeout when first attempting to abort an operation.
 1.61 16-Nov-1996  pk Add explicit casts to `%l*' formatted arguments.
 1.60 12-Nov-1996  cgd sync with alpha version
 1.59 13-Oct-1996  christos backout previous kprintf change
 1.58 11-Oct-1996  christos printf -> kprintf, sprintf -> ksprintf
 1.57 28-Sep-1996  mycroft Remove unused variable.
 1.56 28-Sep-1996  mycroft Sync with Alpha version.
 1.55 28-Sep-1996  thorpej Sync with the alpha version, fixing several SCSI protocol bugs.

NOTE: THESE FILES ARE NOW IDENTICAL TO THEIR ALPHA COUNTERPARTS.
The C preprocessor does the Right Thing when these files are built
on a SPARC. This makes it significantly easier to diff the two
versions (until a real MI 53c9x driver is done, hint hint).
 1.54 09-Sep-1996  cgd replace sequences of 8 spaces with tabs (only one instance). kill
unnecessary newlines after return statements but before function
close-braces.
 1.53 28-Aug-1996  cgd (1) set scsi_link channel to either the appropriate channel (if a
multi-channel driver), or to SCSI_CHANNEL_ONLY_ONE if a
single-channel driver.
(2) use scsiprint() rather than a locally-defined autoconfig print
function, and kill any locally-defined print function.
 1.52 27-Aug-1996  cgd change cfprint_t type definition to take a const char *, rather than
a char *, because that's what was really intended, and because
if the print function modifies the string, various things could become
unhappy (so the string should _not_ be modified).
 1.51 12-Jun-1996  pk Use the setting of the ESPCFG2_FE bit rather than revision number to decide
on the ESP chip's maximum transfer count.
 1.50 12-Jun-1996  pk Correct test for `dmachild' which failed on `esp at obio*' configs (PR#2541).
 1.49 11-Jun-1996  pk Avoid the "features enable" bit on ESP100A's; apperently this is a source
of trouble on many machines (from Krister Walfridsson; PR#2537).
 1.48 30-May-1996  pk Clamp synch-transfer parameters at our maximum values on device-initiated
synch negotiation.
 1.47 21-May-1996  pk branches: 1.47.2;
espattach() requires DMA to be configured. For now, panic if it is not.
 1.46 16-May-1996  pk Use configuration file flags to disable reselection and/or sync negotiation,
on a per target basis (until the driver can sort things out on its own).

Test against "sbus" in stead of "espdma" to find out where in the
configuration tree we are: an esp can be the child of a "dma" on SBus
add-on boards.
 1.45 31-Mar-1996  pk Various cleanup; mostly trailing spaces/tabs.
 1.44 23-Mar-1996  pk Remove reference to sense code "internals".
 1.43 17-Mar-1996  thorpej New device attachment scheme:

- split softc size and match/attach out from cfdriver into
a new struct cfattach.

- new "attach" directive for files.*. May specify the name of
the cfattach structure, so that devices may be easily attached
to parents with different autoconfiguration semantics.
 1.42 16-Mar-1996  christos fix format in panic()
 1.41 14-Mar-1996  christos Bring prototypes into scope and fix compiler warnings.
 1.40 05-Mar-1996  pk Don't come down so hard on targets that ignore SDTR msgs.
 1.39 29-Feb-1996  pk Don't reset `xs->retries'.
 1.38 26-Feb-1996  pk Interims:
Comment out `STATINT' checking; this is apparently unreliable on some
ESP revisions.
Deal with target initiated synch re-negotiation.
 1.37 22-Feb-1996  mycroft Implement SDEV_AUTOSAVE.
 1.36 21-Feb-1996  pk Correct format in a printf().
 1.35 12-Feb-1996  pk Separate DMA and SCSI routines more.
 1.34 06-Feb-1996  pk Be sure to reset the chip when relection fails to prevent corrupting data.
 1.33 18-Dec-1995  pk Towards machine independency, per cgd: macros to access hardware registers.
 1.32 11-Dec-1995  pk Adapt to changed mapiodev() interface.
 1.31 01-Dec-1995  pk Don't return `XS_DRIVER_STUFFUP' too easily; this can hose buffer cache
writes. Say XS_TIMEOUT in stead so the scsi code will retry.
 1.30 28-Nov-1995  pk Prevent synch negotiation on ESP100 chips
 1.29 28-Nov-1995  pk Lots of major and minor bug fixes and changes.
- properly do MSG_IN handshaking, so we can actually receive multi-byte msgs.
- do synch negotiation (now that the above works).
- handle disconnects.
There are a few trial-and-error bits at points where the docs I have are
particularly ambiguous about the state of chip and/or SCSI bus.

Things to do:
- more cleanup
- deal with MSG_OUT phase better
- keep some "config reg 3" bits per target (ie. FASTCLK and FASTSCSI).
 1.28 03-Nov-1995  pk Make error recovery actually work, i.e. don't hang on SCSI bus resets
and re-synchronize before re-scheduling pending operations.
Things seem to be a fair bit stabler now.
 1.27 24-Oct-1995  pk Various:
- make esp_poll() approximate the given timeout value.
- introduce esp_abort(), and use it for timed out commands; make targets and driver less confused.
- make {free,ready,nexus}-list management somewhat more coherent.
- make sure we only proceed down the state machine in espintr()
if there really is an interrupt pending.
 1.26 14-Sep-1995  pk branches: 1.26.2;
Re-instate configuration print routines, following Chris' suggestion.
Only prints something if there's no scsi bus to attach.
 1.25 11-Sep-1995  pk We have no need for `esp_print()'; the only child we expect is a `scsibus',
and there's nothing to say if it isn't there. Returning -1 is an error
anyway as noted by Chuck Cranor.
 1.24 06-Sep-1995  pk Probe config registers correctly.
 1.23 18-Aug-1995  pk Use bootpath_store() to set next boot component; used in dk_establish()
to match `sd' devices against the PROM's boot path.

Detect DMA "overshoots" when handling odd-sized transfer sizes (e.g., xfers
from/to raw partitions), by using the "Transfer Pad" command when the
transfer count reaches zero.
 1.22 24-Jul-1995  cgd update SCSI minphys routines' definitions to match standard minphys()
definition and usage.
 1.21 13-Jul-1995  pk Have esp_minphys limit transfers to MAXPHYS bytes.
 1.20 02-Jun-1995  pk Try to recover from multi-byte messages sent by a target for which we
get an "Illegal command" (why is this?) when we try to pull it in.
On detection of this condition, we reset the SCSI bus and simply stop asking
this target for an identify messages, for now.
 1.19 01-Mar-1995  pk Better 4/100 support.
 1.18 01-Feb-1995  pk Integrate changes from Chuck Cranor for the Sun 4/100.
Support for multiple register banks on SBUS devices (based on patches
from Francis Dupont).
Highlights:
romaux defines an array of register spaces.
pay attention to `vactype'.
quirks handling 4/100 idiosyncracies.
 1.17 01-Feb-1995  mycroft Handle incoming messages longer than 1 byte correctly.
 1.16 07-Jan-1995  mycroft ESP_ID -> ESP_SELID
 1.15 02-Jan-1995  pk Adapt to changed SCSI subsystem.
 1.14 23-Nov-1994  deraadt XXmatch change (and a few __P() as well)
 1.13 21-Nov-1994  deraadt C error
 1.12 20-Nov-1994  deraadt copyright/Id cleanup
 1.11 05-Nov-1994  deraadt reset scsi bus at attach time
 1.10 15-Oct-1994  deraadt sbus_establish() is sun4c/sun4m specific
 1.9 15-Oct-1994  deraadt mapiodev takes a bustype argument now
 1.8 02-Oct-1994  deraadt sun4/300 support works
 1.7 17-Sep-1994  deraadt Replacement esp (NCR 53C9X + LSI DMA) scsi driver from Peter Galbavy.
 1.6 13-Aug-1994  deraadt fix for bug #403 from <grossman@informatik.tu-muenchen.de>
 1.5 27-May-1994  deraadt branches: 1.5.2;
new from torek; now multiple drives will work
 1.4 12-Nov-1993  deraadt new from torek:
add torek's comments to my DMA_DRAIN fix
 1.3 05-Nov-1993  deraadt DELAY(1) after a DMA_DRAIN, to let the esp chip have a chance to
recover from the DMA.. seems to let my ss1+ work with the cache enabled.
+ also esp reset code from Torek.
 1.2 27-Oct-1993  deraadt sys/dev/scsi -> sys/arch/sparc/scsi.
 1.1 02-Oct-1993  deraadt Chris Torek's sparc port. Missing lots of things.
 1.5.2.1 13-Aug-1994  mycroft update from trunk
 1.26.2.6 26-Feb-1996  pk From trunk:
`STATINT' is not reliable on some ESP revisions.
Deal with target initiated synch re-negotiation.
 1.26.2.5 21-Feb-1996  pk From trunk: Correct format in a printf().
 1.26.2.4 17-Feb-1996  pk Pull over fixes from trunk.
 1.26.2.3 12-Nov-1995  pk Incorporate error-recovery fixes from trunk.
 1.26.2.2 24-Oct-1995  pk Update from trunk: various
 1.26.2.1 18-Oct-1995  pk Set cfg2 bits for chip revisions ESP100A and above.
 1.47.2.2 15-Oct-1996  mycroft Integrate post-1.2 bug fixes to date.
 1.47.2.1 12-Jun-1996  pk Pull down from trunk:
>rev 1.49/1.51: judicious use of ESPCFG2_FE configuration flag.
>rev 1.50: Correct test for "being child of dma".
>rev 1.48: Clamp synch-transfer parameters at our maximum values ...
 1.65.6.1 12-Mar-1997  is Merge in changes from The Trunk
 1.67.2.2 22-Jul-1997  bouyer Sync with trunk.
 1.67.2.1 01-Jul-1997  bouyer Updates for new scsipi subsystem. Actally known to work on i386 and sparc.
 1.68.2.2 14-Oct-1997  thorpej Update marc-pcmcia branch from trunk.
 1.68.2.1 27-Aug-1997  thorpej Update marc-pcmcia branch from trunk.
 1.24 01-Jul-2011  dyoung #include <sys/bus.h> instead of <machine/bus.h>.
 1.23 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.22 13-Apr-2008  tsutsui branches: 1.22.2; 1.22.4;
Split device_t/softc for MI ncr53c9x and some related devices,
with various cleanup.
 1.21 12-Feb-2008  joerg branches: 1.21.6;
Introduce device_find_by_xname and device_find_by_driver_unit to replace
alldevs iterations all over src.

Patch discussed with and improved on suggestioned from cube@.
 1.20 04-Mar-2007  christos branches: 1.20.20; 1.20.26;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.19 28-Mar-2006  thorpej branches: 1.19.14;
Use device_unit().
 1.18 08-Mar-2006  lukem branches: 1.18.2;
Use the SI capitalization for "Hz", "kHz", and "MHz" in comments and strings.
Add a space between numbers and Hz unit.
 1.17 16-Nov-2005  uwe branches: 1.17.4; 1.17.6; 1.17.8; 1.17.10;
ANSIify function declarations/defintions. Use uint<N>_t.
Propagate "static" to function definitions. Drop trailing whitespace.
Same binary code is produced for GENERIC.MP + KGDB + DDB.
 1.16 15-Jul-2003  lukem branches: 1.16.16; 1.16.24;
__KERNEL_RCSID()
 1.15 10-Dec-2002  pk branches: 1.15.6;
Remove the `flags' argument from bus_intr_establish().
 1.14 02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.13 01-Oct-2002  thorpej Use CFATTACH_DECL().
 1.12 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.11 11-Mar-2002  pk * `bus_type_t' is gone.
* Use BUS_ADDR() where appropriate to encode I/O space and physical
address offset into a `bus_addr_t' value.
* Drop obio_bus_map() since it's now completely equivalent to bus_space_map()
* Use bus_space_map2() to map device space at a fixed virtual address.
* Remove the virtual address argument from sbus_sbus_addr()
 1.10 25-Apr-2001  bouyer branches: 1.10.2; 1.10.8;
Pull up the thorpej_scsipi branch to main branch.
This is a completely rewritten scsipi_xfer execution engine, and the
associated changes to HBA drivers. Overview of changes & features:
- All xfers are queued in the mid-layer, rather than doing so in an
ad-hoc fashion in individual adapter drivers.
- Adapter/channel resource management in the mid-layer, avoids even trying
to start running an xfer if the adapter/channel doesn't have the resources.
- Better communication between the mid-layer and the adapters.
- Asynchronous event notification mechanism from adapter to mid-layer and
peripherals.
- Better peripheral queue management: freeze/thaw, sorted requeueing during
recovery, etc.
- Clean separation of peripherals, adapters, and adapter channels (no more
scsipi_link).
- Kernel thread for each scsipi_channel makes error recovery much easier
(no more dealing with interrupt context when recovering from an error).
- Mid-layer support for tagged queueing: commands can have the tag type
set explicitly, tag IDs are allocated in the mid-layer (thus eliminating
the need to use buggy tag ID allocation schemes in many adapter drivers).
- support for QUEUE FULL and CHECK CONDITION status in mid-layer; the command
will be requeued, or a REQUEST SENSE will be sent as appropriate.

Just before the merge syssrc has been tagged with thorpej_scsipi_beforemerge
 1.9 29-Mar-2001  petrov use NCR_F_DMASELECT instead of ncr53c9x_dmaselect
 1.8 09-Jul-2000  pk branches: 1.8.2;
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.7 05-Jun-2000  nisimura branches: 1.7.2;
Have MI ncr53c9x_attach() the 2nd and 3rd arguments for scsipi_adater
and scsipi_device respectively, with size reduction of ncr53c9x_softc.
Specifying NULL instructs the driver to use default adapter and default
device codes. Every target port has ncr53c9x_attach(sc, NULL, NULL) anyway.
 1.6 04-Jun-2000  cgd Implement the more flexiable `evcnt' interface as discussed (briefly) on
tech-kern and now documented in evcnt(9).
 1.5 11-Jan-2000  pk branches: 1.5.2;
Remove old-style boot device recognition.
 1.4 19-Nov-1998  thorpej branches: 1.4.10;
Adapt to the new scsipi_adapter interface.
 1.3 10-Oct-1998  thorpej Garbage-collect the open_target_lu and close_target_lu entry points from
struct scsipi_adapter; they were not used.

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

Inspired by PR #6090, from Matt Jacob.
 1.2 29-Aug-1998  pk Adjust for some small changes in lsi64854 back-end driver.
 1.1 29-Aug-1998  pk Split `esp' driver and DMA engine into separate front-end files.
The Sbus front-ends have all been moved to `sys/dev/sbus', while
the `obio' front-ends remain here.
 1.4.10.3 21-Apr-2001  bouyer Sync with HEAD
 1.4.10.2 23-Mar-2001  bouyer Correct attach to ncr53c9x.
 1.4.10.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.5.2.1 22-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.7.2.1 19-Jul-2000  mrg pull up sparc/sparc64 bus_intr_establish() changes, necessary for sparc64
(originally done by pk, approved by thorpej):

>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.8.2.2 21-Jun-2001  nathanw Catch up to -current.
 1.8.2.1 09-Apr-2001  nathanw Catch up with -current.
 1.10.8.4 11-Dec-2002  thorpej Sync with HEAD.
 1.10.8.3 18-Oct-2002  nathanw Catch up to -current.
 1.10.8.2 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.10.8.1 25-Apr-2001  nathanw file esp_obio.c was added on branch nathanw_sa on 2002-04-01 07:42:40 +0000
 1.10.2.2 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.10.2.1 16-Mar-2002  jdolecek Catch up with -current.
 1.15.6.4 11-Dec-2005  christos Sync with head.
 1.15.6.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.15.6.2 18-Sep-2004  skrll Sync with HEAD.
 1.15.6.1 03-Aug-2004  skrll Sync with HEAD
 1.16.24.1 22-Nov-2005  yamt sync with head.
 1.16.16.3 27-Feb-2008  yamt sync with head.
 1.16.16.2 03-Sep-2007  yamt sync with head.
 1.16.16.1 21-Jun-2006  yamt sync with head.
 1.17.10.1 19-Apr-2006  elad sync with head - hopefully this will work
 1.17.8.2 01-Apr-2006  yamt sync with head.
 1.17.8.1 13-Mar-2006  yamt sync with head.
 1.17.6.1 22-Apr-2006  simonb Sync with head.
 1.17.4.1 09-Sep-2006  rpaulo sync with head
 1.18.2.1 31-Mar-2006  tron Merge 2006-03-31 NetBSD-current into the "peter-altq" branch.
 1.19.14.1 12-Mar-2007  rmind Sync with HEAD.
 1.20.26.1 18-Feb-2008  mjf Sync with HEAD.
 1.20.20.1 23-Mar-2008  matt sync with HEAD
 1.21.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.22.4.1 16-May-2008  yamt sync with head.
 1.22.2.1 18-May-2008  yamt sync with head.
 1.8 27-Feb-1997  thorpej Convert the SPARC esp driver to be a front-end for the MI 53c9x driver.
 1.7 18-Dec-1995  pk branches: 1.7.8;
Towards machine independency, per cgd: macros to access hardware registers.
 1.6 29-Aug-1995  pk branches: 1.6.2;
define reserved bits in cfg2 & cfg3 registers correctly.
 1.5 07-Jan-1995  mycroft Sort.
 1.4 20-Nov-1994  deraadt copyright/Id cleanup
 1.3 17-Sep-1994  deraadt Replacement esp (NCR 53C9X + LSI DMA) scsi driver from Peter Galbavy.
 1.2 27-May-1994  deraadt new from torek; now multiple drives will work
 1.1 02-Oct-1993  deraadt Chris Torek's sparc port. Missing lots of things.
 1.6.2.1 17-Feb-1996  pk Pull over fixes from trunk.
 1.7.8.1 12-Mar-1997  is Merge in changes from The Trunk
 1.22 29-Aug-1998  pk Split `esp' driver and DMA engine into separate front-end files.
The Sbus front-ends have all been moved to `sys/dev/sbus', while
the `obio' front-ends remain here.
 1.21 21-Mar-1998  pk Add bus tags to softc.
 1.20 05-Oct-1997  thorpej Copyright assigned to The NetBSD Foundation.
 1.19 27-Feb-1997  thorpej branches: 1.19.4;
Convert the SPARC esp driver to be a front-end for the MI 53c9x driver.
 1.18 22-Nov-1996  pk branches: 1.18.6;
One control block per target is insufficient if you have a full complement
of targets attached and access those simultaneously (like in a ccd(4) array).
We (now) allocate (somewhat arbitrarily) three per target.
Noticed by Marshall Midden.
 1.17 12-Nov-1996  cgd sync with alpha version
 1.16 13-Oct-1996  christos backout previous kprintf change
 1.15 11-Oct-1996  christos printf -> kprintf, sprintf -> ksprintf
 1.14 28-Sep-1996  thorpej Sync with the alpha version, fixing several SCSI protocol bugs.

NOTE: THESE FILES ARE NOW IDENTICAL TO THEIR ALPHA COUNTERPARTS.
The C preprocessor does the Right Thing when these files are built
on a SPARC. This makes it significantly easier to diff the two
versions (until a real MI 53c9x driver is done, hint hint).
 1.13 16-May-1996  pk branches: 1.13.4;
Use configuration file flags to disable reselection and/or sync negotiation,
on a per target basis (until the driver can sort things out on its own).

Test against "sbus" in stead of "espdma" to find out where in the
configuration tree we are: an esp can be the child of a "dma" on SBus
add-on boards.
 1.12 31-Mar-1996  pk Various cleanup; mostly trailing spaces/tabs.
 1.11 12-Feb-1996  pk Separate DMA and SCSI routines more.
 1.10 18-Dec-1995  pk Towards machine independency, per cgd: macros to access hardware registers.
 1.9 28-Nov-1995  pk Prevent synch negotiation on ESP100 chips
 1.8 28-Nov-1995  pk Lots of major and minor bug fixes and changes.
- properly do MSG_IN handshaking, so we can actually receive multi-byte msgs.
- do synch negotiation (now that the above works).
- handle disconnects.
There are a few trial-and-error bits at points where the docs I have are
particularly ambiguous about the state of chip and/or SCSI bus.

Things to do:
- more cleanup
- deal with MSG_OUT phase better
- keep some "config reg 3" bits per target (ie. FASTCLK and FASTSCSI).
 1.7 03-Nov-1995  pk Make error recovery actually work, i.e. don't hang on SCSI bus resets
and re-synchronize before re-scheduling pending operations.
Things seem to be a fair bit stabler now.
 1.6 24-Oct-1995  pk Various:
- make esp_poll() approximate the given timeout value.
- introduce esp_abort(), and use it for timed out commands; make targets and driver less confused.
- make {free,ready,nexus}-list management somewhat more coherent.
- make sure we only proceed down the state machine in espintr()
if there really is an interrupt pending.
 1.5 18-Aug-1995  pk branches: 1.5.2;
Add a debug flag.
Make `sc_dleft' a `ssize_t' since it's involved in a signed
comparison in esp.c.
 1.4 02-Jun-1995  pk Try to recover from multi-byte messages sent by a target for which we
get an "Illegal command" (why is this?) when we try to pull it in.
On detection of this condition, we reset the SCSI bus and simply stop asking
this target for an identify messages, for now.
 1.3 20-Nov-1994  deraadt copyright/Id cleanup
 1.2 02-Oct-1994  deraadt sun4/300 support works
 1.1 17-Sep-1994  deraadt Replacement esp (NCR 53C9X + LSI DMA) scsi driver from Peter Galbavy.
 1.5.2.3 17-Feb-1996  pk Pull over fixes from trunk.
 1.5.2.2 12-Nov-1995  pk Incorporate error-recovery fixes from trunk.
 1.5.2.1 24-Oct-1995  pk Update from trunk: various
 1.13.4.1 15-Oct-1996  mycroft Integrate post-1.2 bug fixes to date.
 1.18.6.1 12-Mar-1997  is Merge in changes from The Trunk
 1.19.4.1 14-Oct-1997  thorpej Update marc-pcmcia branch from trunk.
 1.5 29-May-1996  pk Swiatch to `sys/dev/sun/event*'.
 1.4 29-May-1996  pk Add missing splx(), per Jason.
 1.3 20-Nov-1994  deraadt copyright/Id cleanup
 1.2 21-Jul-1994  deraadt make X11R5 compile easier
 1.1 02-Oct-1993  deraadt branches: 1.1.2;
Chris Torek's sparc port. Missing lots of things.
 1.1.2.1 22-Jul-1994  cgd from trunk.
 1.3 29-May-1996  pk Swiatch to `sys/dev/sun/event*'.
 1.2 20-Nov-1994  deraadt copyright/Id cleanup
 1.1 02-Oct-1993  deraadt Chris Torek's sparc port. Missing lots of things.
 1.48 31-Oct-2000  pk This file now lives in sys/dev/sun.
 1.47 22-Aug-2000  pk Use the framebuffer drivers & header files that now live in /sys/dev/sun.
 1.46 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.45 17-Apr-2000  pk branches: 1.45.4;
When constructing `ri_devcmap[]', pack four instances of the LUTs in each
32 bit wide entry (as not documented in the non-existent rasops(9)..)
 1.44 16-Apr-2000  pk Initialize the rasops device colormap to match colormaps used by
our supported devices (including even coloured text on the console).
 1.43 19-Mar-2000  pk Add `fb_is_console()', which is a helper function for frame buffer
device drivers used to decide whether or not to act as console output.
 1.42 26-Aug-1999  thorpej branches: 1.42.2;
Suns use black-on-white as the default rcons colors.
 1.41 24-Aug-1999  ad - Update to match new rasops_init semantics
- Set RI_FULLCLEAR so that we clear the *entire* display
- Set RI_CURSOR and cursor position so that old cursor glyph gets wiped

Fixes PR: port-sparc/8121
 1.40 13-Aug-1999  ad The 8bpp PROM console uses index 0 as black, 255 as white. Update ri_devcmap
to cater. Partially addresses PR port-sparc/8121.
 1.39 02-Jun-1999  christos Don't include rasops and wscons goo here; we get it already from fbvar.h
 1.38 02-Jun-1999  mycroft We need wsdisplayvar.h for this to compile now!
 1.37 23-May-1999  ad - Setting initial position of cursor is up to caller.
- Set cursor position properly for SPARC. From Juergen Hannken-Illjes.
 1.36 19-May-1999  ad SPARC console is black on white, and is centered by default.
 1.35 19-May-1999  ad Add arg to rcons_init() that when set causes screen to be cleared.
 1.34 19-May-1999  ad Insert missing code that defines screen metrics for rcons. This fixes the
more blatant rcons brokenness (ie no panics).
 1.33 18-May-1999  ad Fix typo that broke rasops operation.
 1.32 18-May-1999  thorpej Don't clear the screen when we connect rasops; the SPARC doesn't connect
the rasops console until autoconfiguration, and it kinda sucks to have
the boot messages suddenly disappear from the screen.
 1.31 16-May-1999  ad Fix typo on my behalf. From Juergen Hannken-Illjes.
 1.30 15-May-1999  ad Panic if rasops_init() fails us (should never be the case).
 1.29 15-May-1999  ad Make sure rasops_info descriptor is zeroed out before initializing.
 1.28 27-Apr-1999  thorpej Fix a typo that prevented this from compiling.
 1.27 26-Apr-1999  ad Update configuration to match `rasops' fixes and config glue.
 1.26 13-Apr-1999  ad Leave font selection to 'rasops' until 'rasops1' has been completed and can
handle non {8,16} pixel wide fonts.
 1.25 13-Apr-1999  ad Bring sparc/sparc64 fb code and kernel configuration into line with
rcons changes.
 1.24 21-Mar-1998  pk branches: 1.24.10;
Split the fb_setsize() utility in two separate functions: one to be
used by OBP machines and another one for sun4/eeprom machines.
 1.23 07-Jul-1997  pk Get console tty size from raster console if applicable.
 1.22 23-Dec-1996  pk Prevent `unused function' warning (from Robert Evans; PR#2770).
 1.21 13-Oct-1996  christos backout previous kprintf change
 1.20 11-Oct-1996  christos printf -> kprintf, sprintf -> ksprintf
 1.19 04-Oct-1996  thorpej Returning ENODEV is not correct in a poll entry point. Instead, since
read/write returns an error, use seltrue().
 1.18 01-Apr-1996  christos Eliminated dependencies on dev_conf.h
 1.17 31-Mar-1996  pk Re-arrange a bit to stear clear of gcc `-Wall' bites.
 1.16 14-Mar-1996  christos Bring prototypes into scope and fix compiler warnings.
 1.15 27-Feb-1996  thorpej First-cut support for P4 framebuffers. Currently supports P4 variants
of bwtwo, cgfour, cgsix, and cgeight. Includes support for attaching
the overlay plane of the cgfour and cgeight as a bwtwo instance (a'la
SunOS).

P4 register descriptions, cgfour driver, and cgeight driver partially
derived from OpenBSD.

This code may still need polishing.
 1.14 25-Feb-1996  pk Use CPU-type macros
 1.13 10-Dec-1995  pk Use `def_width' and `def_height' as default values when getting rom properties.
 1.12 29-Nov-1995  pk Code from Jason to better configure /dev/fb.
 1.11 08-Oct-1995  pk branches: 1.11.2;
Patch from Jason to factor out a common framebuffer size determination
routine from the individual drivers.
 1.10 05-Oct-1995  pk rcons: rc_maxcol and rc_maxrow were swapped.
 1.9 05-Oct-1995  pk Machine dependent RASTERCONSOLE font definition to be passed to rcons_init().
 1.8 02-Oct-1995  pk Make fbrcons_init() resistant against SUN4s.
 1.7 17-Sep-1995  pk Change interface to th `fb' pseudo device to not need the major device
number (a la sun3).
Put in new glue for rcons.
 1.6 10-Apr-1995  mycroft map --> mmap
 1.5 16-Dec-1994  deraadt open changed again
 1.4 20-Nov-1994  deraadt copyright/Id cleanup
 1.3 02-Nov-1994  deraadt ioctl u_long cmd
 1.2 11-Oct-1993  deraadt cons.c, zs.c: tty->t_stop doesn't exist here. I think it goes through d_stop
automatically now, but have not checked.
l_ioctl() has no last parameter 'p'
fb.c: move sys/fbio.h to machine/fbio.h
various: typecast parms for timeout() properly
zs.c: extra level of indir in cdevsw[]->d_ttys
 1.1 02-Oct-1993  deraadt Chris Torek's sparc port. Missing lots of things.
 1.11.2.1 16-Feb-1996  thorpej Pull in improved framebuffer autoconfiguration code from -current.
Prevents panics when multiple framebuffers are found on sun4 systems.
 1.24.10.1 21-Jun-1999  thorpej Sync w/ -current.
 1.42.2.2 22-Nov-2000  bouyer Sync with HEAD.
 1.42.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.45.4.2 01-Nov-2000  tv Pullup 1.2 from syssrc/sys/dev/sun/fb.c by patch [pk]:

fb_is_console(): we must match on the `fb' propery in a V0 PROMs root node
only after establishing that the PROM output device is a frame buffer device.
 1.45.4.1 30-Jun-2000  simonb Pull up mmap paddr_t/off_t changes from trunk.
 1.164 11-Dec-2023  andvar Surround fdc declaration and definition with FD_DEBUG blocks.

FD_DEBUG is defined by default, thus build passes, however would fail otherwise
since it is only used in debug block.
 1.163 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.162 24-Apr-2021  thorpej branches: 1.162.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.161 22-Nov-2020  thorpej branches: 1.161.2;
malloc(9) -> kmem(9) (easy, straight-forward cases only, for now)
 1.160 10-Nov-2019  chs branches: 1.160.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.159 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.158 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.157 26-Apr-2015  mlelstv branches: 1.157.16; 1.157.18;
Use C99-style initializers for struct dkdriver.
 1.156 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.155 19-Aug-2014  tsutsui branches: 1.155.2;
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.154 25-Jul-2014  dholland branches: 1.154.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.153 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.152 16-Mar-2014  dholland branches: 1.152.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.151 10-Oct-2012  tsutsui branches: 1.151.2;
Fix device_t/softc split botches that could be fatal. From
Chuck Silvers' patch posted current-users and tech-kern:
http://mail-index.netbsd.org/current-users/2012/10/09/msg021233.html

Should be pulled up to netbsd-6.
 1.150 17-Jul-2011  mrg branches: 1.150.2; 1.150.8; 1.150.12; 1.150.14;
convert all the sparc drivers that attach on my ss20 to use device_t,
cfdata_t and CFATTACH_DECL_NEW().

fd/fdc could use better testing, but i'm pretty sure i got it right.
 1.149 24-Feb-2010  dyoung 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.148 08-Jan-2010  dyoung branches: 1.148.2;
Expand PMF_FN_* macros.
 1.147 19-Dec-2009  tsutsui Disable "fast trap" handlers which invoke software interrupts
in sparc/amd7930intr.s and sparc/bsd_fdintr.s until they are
rewritten to adapt new MI softint(9) API.

No particular comments on PR port-sparc/42192, but
this fixes timeout problem on floppy access on my SPARCstation 1+.

XXX: floppy support on sun4m seems to have another problem (data overrun).
 1.146 25-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().

This was based on the sys/arch/sparc64/fd.c change. Thanks to jdc@
for testing this version.
 1.145 18-Mar-2009  cegger bzero -> memset
 1.144 13-Jan-2009  yamt branches: 1.144.2;
g/c BUFQ_FOO() macros and use bufq_foo() directly.
 1.143 17-Dec-2008  cegger kill MALLOC and FREE macros.
 1.142 16-Dec-2008  christos replace bitmask_snprintf(9) with snprintb(3)
 1.141 11-Jun-2008  drochner branches: 1.141.4; 1.141.6; 1.141.12;
mechanical changes to use device_private() or device_lookup_private()
to get softcs, makes the code compile under the stricter type checking
introduced earlier today
 1.140 28-Apr-2008  martin branches: 1.140.2; 1.140.4;
Remove clause 3 and 4 from TNF licenses
 1.139 02-Jan-2008  ad branches: 1.139.6; 1.139.8; 1.139.10;
Merge vmlocking2 to head.
 1.138 27-Nov-2007  ad branches: 1.138.2; 1.138.6;
Use the softint API.
 1.137 17-Oct-2007  garbled branches: 1.137.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.136 08-Oct-2007  ad Merge disk init changes from the vmlocking branch. These seperate init /
destroy of 'struct disk' from attach / detach.
 1.135 29-Jul-2007  ad branches: 1.135.4; 1.135.6; 1.135.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.134 09-Jul-2007  ad branches: 1.134.2; 1.134.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.133 11-May-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. This fix is from
sparc64/dev/fdc.c and was tested on sparc by tnn@.
 1.132 11-May-2007  jnemeth revert last; committed wrong file
 1.131 11-May-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. This fix is from
sparc64/dev/fdc.c and was tested on sparc by tnn@.
 1.130 09-Mar-2007  he branches: 1.130.2; 1.130.4; 1.130.10;
Cast to char* before doing pointer arithmetic.
 1.129 04-Mar-2007  mrg fix fall out from caddr_t changes.
 1.128 04-Mar-2007  christos Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.127 15-Feb-2007  reinoud branches: 1.127.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.126 14-Apr-2006  blymn Make i/o statistics collection more generic, include tape drives and
nfs mounts in the set of devices that statistics will be reported on.
 1.125 23-Feb-2006  thorpej branches: 1.125.2; 1.125.4; 1.125.6;
Use device_parent().
 1.124 06-Jan-2006  yamt branches: 1.124.2; 1.124.4;
initialize necessary members of struct buf. PR/32462 from Reinoud Zandijk.
 1.123 04-Jan-2006  yamt add a missing putiobuf in the previous. pointed by Thomas Klausner.
 1.122 04-Jan-2006  yamt - add simple functions to allocate/free a buffer for i/o.
- make bufpool static.
 1.121 11-Dec-2005  christos branches: 1.121.2;
merge ktrace-lwp.
 1.120 16-Nov-2005  uwe ANSIify function declarations/defintions. Use uint<N>_t.
Propagate "static" to function definitions. Drop trailing whitespace.
Same binary code is produced for GENERIC.MP + KGDB + DDB.
 1.119 01-Nov-2005  bjh21 branches: 1.119.2;
Fix second "no drives attached" message (as seen on sun4c) so as not to
include the device name, since this message is printed on the same line
as the attach message anyway.
 1.118 15-Oct-2005  yamt branches: 1.118.2;
- change the way to specify a bufq strategy. (by string rather than by number)
- rather than embedding bufq_state in driver softc,
have a pointer to the former.
- move bufq related functions from kern/subr_disk.c to kern/subr_bufq.c.
- rename method to strategy for consistency.
- move some definitions which don't need to be exposed to the rest of kernel
from sys/bufq.h to sys/bufq_impl.h.
(is it better to move it to kern/ or somewhere?)
- fix some obvious breakage in dev/qbus/ts.c. (not tested)
 1.117 04-Jun-2005  tsutsui branches: 1.117.2;
- Add const.
- Remove parameter names from prototype declarations.
 1.116 28-Oct-2004  yamt move buffer queue related stuffs from buf.h to their own header, bufq.h.
 1.115 19-Sep-2004  he Fix build problem -- track the change to <sys/buf.h>.
 1.114 24-Mar-2004  pk Remove my name from the old UCB copyright notice, thereby reducing its
reference count to 1.
 1.113 17-Mar-2004  pk Rename PROM_getprop*() => prom_getprop*().
 1.112 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.111 15-Jul-2003  lukem __KERNEL_RCSID()
 1.110 11-Jul-2003  pk Deal with disk change notification.
 1.109 29-Jun-2003  fvdl branches: 1.109.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.108 29-Jun-2003  darrenr More changes for providing lwpid for ktrace (sparc GENERIC built)
 1.107 18-Jun-2003  drochner don't #include <sys/dkstat.h> where it is (appearently) unused
 1.106 03-May-2003  wiz DMA, not dma nor Dma.
 1.105 25-Feb-2003  thorpej Add missing splbio() protecting of bufpool access. Add a clarifying
comment to <sys/buf.h> reminding everyone of the need for splbio().
 1.104 25-Feb-2003  thorpej Add a new BUF_INIT() macro which initializes b_dep and b_interlock, and
use it. This fixes a few places where either b_dep or b_interlock were
not properly initialized.
 1.103 05-Feb-2003  pk Make the buffer cache code MP-safe.
 1.102 30-Jan-2003  hannken Fix printf() problem caused by "daddr_t" change.
 1.101 24-Jan-2003  fvdl Bump daddr_t to 64 bits. Replace it with int32_t in all places where
it was used on-disk, so that on-disk formats remain the same.
Remove ufs_daddr_t and ufs_lbn_t for the time being.
 1.100 01-Jan-2003  thorpej Use aprint_normal() for cfprint routines.
 1.99 10-Dec-2002  pk Remove the `flags' argument from bus_intr_establish().
 1.98 10-Dec-2002  pk The `fast trap' handlers are now pssed as an optional argument to
bus_intr_establish(). Allow fall-back on a regular interrupt handler if
the interrupt level must be shared with another device.
 1.97 09-Dec-2002  pk Finish the switch to the softintr(9) framework.

To make this work, we now have to use separate handler lists for hardware
and software interrupts as the soft interrupt handlers do not return
an `interrupt handled' status.

Thanks to Matt Fredette for providing an initial set of patches on port-sparc.
 1.96 01-Nov-2002  mrg implement separate read/write disk statistics:
- disk_unbusy() gets a new parameter to tell the IO direction.
- struct disk_sysctl gets 4 new members for read/write bytes/transfers.
when processing hw.diskstats, add the read&write bytes/transfers for
the old combined stats to attempt to keep backwards compatibility.

unfortunately, due to multiple bugs, this will cause new kernels and old
vmstat/iostat/systat programs to fail. however, the next time this is
change it will not fail again.

this is just the kernel portion.
 1.95 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.94 02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.93 01-Oct-2002  thorpej Use CFATTACH_DECL().
 1.92 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.91 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.90 06-Aug-2002  hannken Convert to new device buffer queue interface.

Approved by: Paul Kranenburg <pk@netbsd.org>
 1.89 11-Mar-2002  pk branches: 1.89.4;
* `bus_type_t' is gone.
* Use BUS_ADDR() where appropriate to encode I/O space and physical
address offset into a `bus_addr_t' value.
* Drop obio_bus_map() since it's now completely equivalent to bus_space_map()
* Use bus_space_map2() to map device space at a fixed virtual address.
* Remove the virtual address argument from sbus_sbus_addr()
 1.88 26-Sep-2001  eeh branches: 1.88.4;
getprop* -> PROM_getprop*
 1.87 08-Jul-2001  wiz branches: 1.87.2; 1.87.4;
Correct various misspellings of 'transfer' and inflected forms.
 1.86 19-Apr-2001  pk Fix fdc_c_hwintr() and use it as a fall back if the `fast trap' handler
cannot be registered.
 1.85 24-Aug-2000  nathanw branches: 1.85.2;
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.84 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.83 29-Jun-2000  mrg remove include of <vm/vm.h> and <machine/pmap.h>. <vm/vm.h> -> <uvm/uvm_extern.h>
 1.82 04-Jun-2000  cgd branches: 1.82.2;
Implement the more flexiable `evcnt' interface as discussed (briefly) on
tech-kern and now documented in evcnt(9).
 1.81 16-May-2000  thorpej branches: 1.81.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.80 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.79 24-Mar-2000  hannken Fix a typo from last commit.
 1.78 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.77 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.76 07-Feb-2000  pk Don't use PROM the virtual address (if any) for the device registers;
they are not reliably mapped. Also, unmap registers if the device
cannot be configured properly.
 1.75 28-Jan-2000  pk fdcstatus() formatting.
 1.74 24-Jan-2000  pk Report write-protected disks.
 1.73 23-Jan-2000  pk * b_cylin -> b_cylinder; deals with PR9283.
* a few optimizations & misc. style updates.
 1.72 21-Jan-2000  thorpej Update for sys/buf.h/disksort_*() changes.
 1.71 21-Jan-2000  pk Medium sized code overhaul:
* Improve communication between the `hard' and `soft' interrupt handlers
to better distinguish various interrupt sources.
* Eliminate several race conditions where we would set a time out handler
only after starting the command on the hardware.
* Handle most timeouts by resetting the controller; there isn't much chance
of recovery in any other way. Currently, the exception is a timeout
on I/O, in which case we first try to pulse the controller's TC line
in order to abort the pseudo-dma sequence. Apparently, "normal"
conditions can induce such a timeout when there's no disk in the drive.
* Reduce the formatting gap parameter to 0x54.
* On the obio bus, interpret the `status' attribute.
* Minimize console diagnostic output if the errors we get appear to be
caused by the absence of a disk.
 1.70 17-Jan-2000  pk Use bus_space(9) functions to access the controller registers.
Add probes to the attach routines before poking the chip to see
where the registers are located.
 1.69 11-Jan-2000  pk Remove old-style boot device recognition.
 1.68 21-Nov-1999  pk Check presence of Sbus interrupt properties before using them.
 1.67 24-Mar-1999  mrg branches: 1.67.2; 1.67.8; 1.67.14;
completely remove Mach VM support. all that is left is the all the
header files as UVM still uses (most of) these.
 1.66 08-Feb-1999  bouyer 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.65 07-Feb-1999  jonathan defopt MEMORY_DISK_{HOOKS,SERVER,IS_ROOT}.
 1.64 15-Aug-1998  mycroft Make copyright notices with my name consistent.
 1.63 29-Jul-1998  pk Deal with sbus attach args changes.
 1.62 04-Jul-1998  jonathan defopt DDB.
 1.61 05-Jun-1998  mrg remove old (now broken) memory disks hooks code.
 1.60 30-Mar-1998  pk Replace direct `sparc_bus_map()' calls with bus space map method.
 1.59 25-Mar-1998  pk Check for a valid PROM virtual address.
 1.58 21-Mar-1998  pk Account for changed bus attachment scheme.
 1.57 10-Feb-1998  mrg - add defopt's for UVM, UVMHIST and PMAP_NEW.
- remove unnecessary UVMHIST_DECL's.
 1.56 05-Feb-1998  mrg initial import of the new virtual memory system, UVM, into -current.

UVM was written by chuck cranor <chuck@maria.wustl.edu>, with some
minor portions derived from the old Mach code. i provided some help
getting swap and paging working, and other bug fixes/ideas. chuck
silvers <chuq@chuq.com> also provided some other fixes.

this is the sparc portion.

this will be KNF'd shortly. :-)
 1.55 12-Jan-1998  thorpej Update for changes to config.
 1.54 19-Oct-1997  pk Nuke 5.25 inch formats.
 1.53 19-Oct-1997  pk Add an odd-ball japanese floppy format (PR#2903).
A good time to get rid of the hard-coded floppy sector size.
 1.52 29-Jul-1997  fair %x -> 0x%x
 1.51 24-May-1997  pk Remove all `bustype' arguments from map[io]dev() and REG2PHYS().
 1.50 02-May-1997  pk * finish off support for the 82077 chip as found on sun4m machines.
* add non-dma mode bit to `specify command', so formatting disks starts
working (thanks to Jeremy Cooper for finding out about this).
 1.49 07-Apr-1997  pk sun4c and sun4m `aux' register bits differ slightly.
 1.48 31-Mar-1997  pk Remove bogon from otherwise unused fdchwintr() function.
 1.47 31-Jan-1997  thorpej Use new machine-independent mountroothook code.
 1.46 01-Jan-1997  pk branches: 1.46.2;
RAMDISK_HOOKS => MEMORY_DISK_HOOKS
 1.45 28-Dec-1996  pk rename: ramdisk => md
 1.44 10-Dec-1996  pk Comply with recent autoconfiguration changes. Diffs graciously
supplied by Chris Demetriou.
 1.43 10-Dec-1996  pk Finish import of floppy formatting code; not really usable yet, lots of
data overruns.
 1.42 08-Dec-1996  pk Import formatting code from the i386 version.
Revise communication between hw & sw interrupt handler.
 1.41 27-Nov-1996  pk Stabilize timeout values in fdcresult() and out_fdc() by adding delay()s.
Noted by Jason Thorpe over in the i386 driver.
 1.40 13-Nov-1996  thorpej Use bitmask_snprintf().
 1.39 13-Oct-1996  christos backout previous kprintf change
 1.38 11-Oct-1996  christos printf -> kprintf, sprintf -> ksprintf
 1.37 27-Aug-1996  cgd change cfprint_t type definition to take a const char *, rather than
a char *, because that's what was really intended, and because
if the print function modifies the string, various things could become
unhappy (so the string should _not_ be modified).
 1.36 20-Jun-1996  pk When booting from a floppy drive and RAMDSK_HOOKS is defined, arrange for
a callback from memory disk driver to load the actual root image.
 1.35 16-Jun-1996  pk bootpath detection: some (newer?) v2 prom versions use actual device address,
e.g. `/fd@1,72000000'.
 1.34 27-May-1996  pk Fix case where sequence state wasn't updated properly, resulting in
`disk_unbusy' panic.
 1.33 29-Apr-1996  pk branches: 1.33.4;
Chip needs much more time to think things over (up to 2 seconds to complete
a `recalibrate' command if no flop present).
 1.32 22-Apr-1996  christos Remove dependency on <sys/cpu.h>
 1.31 10-Apr-1996  pk `bootdv' is gone. Instead, set the device pointer in the `struct bootpath'
that is passed in the attach arguments.
 1.30 01-Apr-1996  christos - remove dependency to dev_conf.h
- remove unneeded casts for %b
 1.29 31-Mar-1996  pk Various cleanup; mostly trailing spaces/tabs.
 1.28 26-Mar-1996  pk Bitfields are unsigned.
 1.27 26-Mar-1996  pk Back to normal printf()s, now that gcc understands `%b'.
 1.26 17-Mar-1996  thorpej New device attachment scheme:

- split softc size and match/attach out from cfdriver into
a new struct cfattach.

- new "attach" directive for files.*. May specify the name of
the cfattach structure, so that devices may be easily attached
to parents with different autoconfiguration semantics.
 1.25 16-Mar-1996  christos fix format in printf()
 1.24 14-Mar-1996  christos Bring prototypes into scope and fix compiler warnings.
 1.23 25-Feb-1996  pk Use CPU-type macros.
 1.22 10-Feb-1996  thorpej In fdcretry(), if we're not using implied seeks, set the state to DOSEEK
rather than SEEKCOMPLETE before retrying the operation. If implied seeks
are being used, the state is set to DOIO (no change). This is why I
couldn't reproduce the disk_unbusy() panic on my SS2; it uses implied
seeks. Patch from John F. Woods <jfw@jfwhome.funhouse.com>
 1.21 30-Jan-1996  thorpej Implement DIOCLOCK. It's a no-op in this driver.
 1.20 16-Jan-1996  thorpej Use a shutdownhook to make sure the drive motor is turned off
at halt/reboot time, as suggested by Perry Metzger.
 1.19 15-Jan-1996  thorpej Three distinct changes:
- Better disklabel handling. While a disklabel isn't used
in the driver, some versions of the OpenPROM insist on
one being present in order to boot from floppy. These
changes provide a default label (in a way similar to how
the SCSI disk driver provides a default) so that a user
can more easily place the label on the disk.

- Fix semi-bug in bootpath handling. It appears as if the
bootpath can appear in a couple of formats: "/fd@0,0", which
is what bootpath_fake() creates on v0 proms and may be
passed by some v2 proms, and "/fd0" which is what the
v2 prom on my SS2 passes. We now handle both formats.

- Use a mountroot hook to eject the floppy and wait for
the user to insert a filesystem floppy if we're the boot/root
device.
 1.18 12-Jan-1996  thorpej Balance calls to disk_busy() and disk_unbusy() properly to avoid
dk_busy < 0 panics. Count seeks.
 1.17 11-Jan-1996  pk Return `no error' after ejecting; per Jason.
 1.16 07-Jan-1996  thorpej New generic disk framework. Highlights:

- New metrics handling. Metrics are now kept in the new
`struct disk'. Busy time is now stored as a timeval, and
transfer count in bytes.

- Storage for disklabels is now dynamically allocated, so that
the size of the disk structure is not machine-dependent.

- Several new functions for attaching and detaching disks, and
handling metrics calculation.

Old-style instrumentation is still supported in drivers that did it before.
However, old-style instrumentation is being deprecated, and will go away
once the userland utilities are updated for the new framework.

For usage and architectural details, see the forthcoming disk(9) manual
page.
 1.15 11-Dec-1995  pk Adapt to changed mapiodev() interface.
 1.14 11-Nov-1995  pk dk_device => device in controller structure (noted by Jason Thorpe).
 1.13 09-Oct-1995  pk Point `bootdv' at the disk device instead of the controller (from Jason Thorpe).
 1.12 03-Oct-1995  pk Bring reset logic into interrupt state machine.
 1.11 02-Oct-1995  pk Fix some bogus calls to {read/write}disklabel().
 1.10 18-Aug-1995  pk Set `bootdv' if booted from the floppy drive.
 1.9 05-Jul-1995  pk Add xxread/xxwrite.
 1.8 20-May-1995  pk Use a different method to discriminate a 82077 from a 82072 (from Chris Torek);
using the NE7CMD_VERSION command is too unreliable.
 1.7 16-May-1995  pk Really test # of status bytes.
 1.6 25-Apr-1995  pk Do not report each pseudo-DMA overrun as a (soft) error.
Add a small heuristic to converge on an acceptable threshold value.
 1.5 13-Apr-1995  pk Do a probe in fdmatch() to guard against dumb PROMs.
 1.4 10-Apr-1995  mycroft Fdclose --> fdclose
 1.3 07-Apr-1995  pk Add evcnt_attach().
 1.2 22-Feb-1995  pk Reorganize to use fast interrupt handler.
 1.1 17-Feb-1995  pk Pilot sun4c floppy driver based on i386 version;
- same limitations as isa/fd.c: just read/write
- in need of a fast interrupt handler
 1.33.4.1 12-Jun-1996  pk Pull down from trunk:
>rev 1.34: Fix case where sequence state wasn't updated properly ...
 1.46.2.1 14-Jan-1997  thorpej Snapshot of work-in-progress, committed to private branch.

These changes implement machine-independent root device and file system
selection. Notable features:

- All ports behave in a consistent manner regarding root
device selection.
- No more "options GENERIC"; all kernels have the ability
to boot with RB_ASKNAME to select root device and file system
type.
- Root file system type can be wildcarded; a machine-independent
function will try all possible file systems for the selected
root device until one succeeds.
- If the root file system fails to mount, the operator will
be given the chance to select a new root device and file
system type, rather than having the machine simply panic.
- nfs_mountroot() no longer panics if any part of the NFS
mount process fails; it now returns an error, giving the
operator a chance to recover.
- New, more consistent, config(8) grammar. The constructs:

config netbsd swap generic
config netbsd root on nfs

have been replaced with:

config netbsd root on ? type ?
config netbsd root on ? type nfs

Additionally, the operator may select or wildcard root file
system type in the kernel configuration file:

config netbsd root on cd0a type cd9660

config(8) now requires that a "root" specification be
made. "root" may be wired down or wildcarded. "swap" and
"dump" specifications are optional, and follow previous
semantics.

- config(8) has a new "file-system" keyword, used to configure
file systems into the kernel. Eventually, this will be used
to generate the default vfssw[].

- "options NFSCLIENT" is obsolete, and is replaced by
"file-system NFS". "options NFSSERVER" still exists, since
NFS server support is independent of the NFS file system
client.

- sys/arch/<foo>/<foo>/swapgeneric.c is no longer used, and
will be removed; all information is now generated by config(8).

As of this commit, all ports except arm32 have been updated to use
the new setroot(). Only SPARC, i386, and Alpha ports have been
tested at this time. Port masters should test these changes on their
ports, and report any problems back to me.

More changes are on their way, including RB_ASKNAME support in
nfs_mountroot() (to prompt for server address and path) and, potentially,
the ability to select rarp/bootparam or bootp in nfs_mountroot().
 1.67.14.2 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.67.14.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.67.8.2 23-Apr-2001  bouyer Sync with HEAD.
 1.67.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.67.2.1 07-Feb-2000  he Apply patch (requested by pk):
Fix several problems:
o Floppy driver dislikes being accessed with no floppy inserted
(PR#5740)
o Floppy drive being detected even though there is none (PR#5760)
o Panic when fdformat is used (PR#9251)
 1.81.2.1 22-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.82.2.1 19-Jul-2000  mrg pull up sparc/sparc64 bus_intr_establish() changes, necessary for sparc64
(originally done by pk, approved by thorpej):

>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.85.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.87.4.2 10-Oct-2001  fvdl Convert all remaining devices.
 1.87.4.1 01-Oct-2001  fvdl Catch up with -current.
 1.87.2.4 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.87.2.3 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.87.2.2 16-Mar-2002  jdolecek Catch up with -current.
 1.87.2.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.88.4.8 03-Jan-2003  thorpej Sync with HEAD.

XXX ALT_SWITCH_CODE is not yet LWP'ified.
 1.88.4.7 11-Dec-2002  thorpej Sync with HEAD.
 1.88.4.6 11-Nov-2002  nathanw Catch up to -current
 1.88.4.5 18-Oct-2002  nathanw Catch up to -current.
 1.88.4.4 17-Sep-2002  nathanw Catch up to -current.
 1.88.4.3 13-Aug-2002  nathanw Catch up to -current.
 1.88.4.2 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.88.4.1 26-Sep-2001  nathanw file fd.c was added on branch nathanw_sa on 2002-04-01 07:42:41 +0000
 1.89.4.2 31-Aug-2002  gehenna catch up with -current.
 1.89.4.1 17-May-2002  gehenna Add device switch.
 1.109.2.8 11-Dec-2005  christos Sync with head.
 1.109.2.7 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.109.2.6 04-Feb-2005  skrll Adapt to branch.
 1.109.2.5 02-Nov-2004  skrll Sync with HEAD.
 1.109.2.4 24-Sep-2004  skrll Sync with HEAD.
 1.109.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.109.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.109.2.1 03-Aug-2004  skrll Sync with HEAD
 1.117.2.6 21-Jan-2008  yamt sync with head
 1.117.2.5 07-Dec-2007  yamt sync with head
 1.117.2.4 27-Oct-2007  yamt sync with head.
 1.117.2.3 03-Sep-2007  yamt sync with head.
 1.117.2.2 26-Feb-2007  yamt sync with head.
 1.117.2.1 21-Jun-2006  yamt sync with head.
 1.118.2.1 02-Nov-2005  yamt sync with head.
 1.119.2.1 22-Nov-2005  yamt sync with head.
 1.121.2.2 01-Mar-2006  yamt sync with head.
 1.121.2.1 15-Jan-2006  yamt sync with head.
 1.124.4.1 22-Apr-2006  simonb Sync with head.
 1.124.2.1 09-Sep-2006  rpaulo sync with head
 1.125.6.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.125.4.1 19-Apr-2006  elad sync with head - hopefully this will work
 1.125.2.1 24-May-2006  yamt sync with head.
 1.127.2.2 17-May-2007  yamt sync with head.
 1.127.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.130.10.3 16-Oct-2007  garbled Sync with HEAD
 1.130.10.2 03-Oct-2007  garbled Sync with HEAD
 1.130.10.1 22-May-2007  matt Update to HEAD.
 1.130.4.1 11-Jul-2007  mjf Sync with head.
 1.130.2.5 03-Dec-2007  ad Sync with HEAD.
 1.130.2.4 20-Aug-2007  ad - Alter disk attach/detach to fix a panic when closing a vnd device.
- Sync with HEAD.
 1.130.2.3 19-Aug-2007  ad - Back out the biodone() changes.
- Eliminate B_ERROR (from HEAD).
 1.130.2.2 01-Jul-2007  ad Adapt to callout API change.
 1.130.2.1 27-May-2007  ad Sync with head.
 1.134.4.1 15-Aug-2007  skrll Sync with HEAD.
 1.134.2.1 07-Aug-2007  matt Sync with HEAD.
 1.135.8.1 14-Oct-2007  yamt sync with head.
 1.135.6.2 09-Jan-2008  matt sync with HEAD
 1.135.6.1 06-Nov-2007  matt sync with HEAD
 1.135.4.2 03-Dec-2007  joerg Sync with HEAD.
 1.135.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.137.2.2 18-Feb-2008  mjf Sync with HEAD.
 1.137.2.1 08-Dec-2007  mjf Sync with HEAD.
 1.138.6.1 02-Jan-2008  bouyer Sync with HEAD
 1.138.2.1 31-Dec-2007  ad Catch up with buffer cache changes.
 1.139.10.4 11-Mar-2010  yamt sync with head
 1.139.10.3 20-Jun-2009  yamt sync with head
 1.139.10.2 04-May-2009  yamt sync with head.
 1.139.10.1 16-May-2008  yamt sync with head.
 1.139.8.2 17-Jun-2008  yamt sync with head.
 1.139.8.1 18-May-2008  yamt sync with head.
 1.139.6.3 17-Jan-2009  mjf Sync with HEAD.
 1.139.6.2 29-Jun-2008  mjf Sync with HEAD.
 1.139.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.140.4.1 18-Jun-2008  simonb Sync with head.
 1.140.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.141.12.1 21-Apr-2010  matt sync to netbsd-5
 1.141.6.1 23-Jan-2010  bouyer Pull up following revision(s) (requested by tsutsui in ticket #1251):
sys/arch/sparc/sparc/auxreg.h: revision 1.13
distrib/sparc/ramdisk/dot.profile: revision 1.20
sys/arch/sparc/dev/audioamd.c: revision 1.25
sys/arch/sparc/dev/fd.c: revision 1.147
sys/arch/sparc/stand/common/promdev.c: revision 1.23
distrib/sparc/miniroot/Makefile.inc: revision 1.16
Build miniroot binaries for sparc with -Os to shrink instfs.tgz
for the second boot floppy which use miniroot objects.
This is workaround for PR install/42146, and ok'ed by mrg@.
Don't try to read disklabel to check FS_RAID on floppy boot since
reopening floppy could cause Data Access Exception later.
Fixes PR port-sparc/42186, ok'ed by mrg@.
Disable "fast trap" handlers which invoke software interrupts
in sparc/amd7930intr.s and sparc/bsd_fdintr.s until they are
rewritten to adapt new MI softint(9) API.
No particular comments on PR port-sparc/42192, but
this fixes timeout problem on floppy access on my SPARCstation 1+.
XXX: floppy support on sun4m seems to have another problem (data overrun).
Use /dev/fd0a rather than /dev/rfd0a to read instfs.tgz image from floppy.
It looks newer (appearred after 1.6) gzip tries to read less than DEV_BSIZE
(to check header?) so we can't use raw device directly.
(note sparc bootfs ramdisk doesn't have dd(1))
Workaround for PR port-sparc/42193, and would also fix PR install/28734.
Explicitly clear AUXIO4M_FTC bit in FTC_FLIP macro used on
pseudo-dma for floppy, as well as AUXIO4C_FTC bit for sun4c.
A comment in the macro says AUXIO4M_FTC bit is auto-clear,
but my two SS20s (including compatible) with 150MHz hyperSPARCs
get data_overrun without it, and no bad side effect on SS5
(works with and without this change).
Closes PR port-sparc/42516, which is the last one of a bunch of
floppy issue on NetBSD/sparc since NetBSD 2.0 days. See
http://mail-index.NetBSD.org/port-sparc/2009/12/20/msg000484.html
for details.
 1.141.4.2 28-Apr-2009  skrll Sync with HEAD.
 1.141.4.1 19-Jan-2009  skrll Sync with HEAD.
 1.144.2.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.148.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.150.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.150.12.3 03-Dec-2017  jdolecek update from HEAD
 1.150.12.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.150.12.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.150.8.2 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.150.8.1 17-Oct-2012  riz branches: 1.150.8.1.2;
Pull up following revision(s) (requested by tsutsui in ticket #602):
sys/arch/sparc/dev/fd.c: revision 1.151
sys/arch/sparc/sparc/memecc.c: revision 1.15
Fix device_t/softc split botches that could be fatal. From
Chuck Silvers' patch posted current-users and tech-kern:
http://mail-index.netbsd.org/current-users/2012/10/09/msg021233.html
Should be pulled up to netbsd-6.
 1.150.8.1.2.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.150.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.150.2.1 30-Oct-2012  yamt sync with head
 1.151.2.1 18-May-2014  rmind sync with head
 1.152.2.1 10-Aug-2014  tls Rebase.
 1.154.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.155.2.2 06-Jun-2015  skrll Sync with HEAD
 1.155.2.1 06-Apr-2015  skrll Sync with HEAD
 1.157.18.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.157.18.1 10-Jun-2019  christos Sync with HEAD
 1.157.16.1 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.160.8.1 14-Dec-2020  thorpej Sync w/ HEAD.
 1.161.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.162.8.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.10 11-Dec-2005  christos merge ktrace-lwp.
 1.9 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.8 11-Jul-2003  pk Deal with disk change notification.
 1.7 17-Jan-2000  pk branches: 1.7.28;
Use bus_space(9) functions to access the controller registers.
Add probes to the attach routines before poking the chip to see
where the registers are located.
 1.6 02-May-1997  pk branches: 1.6.16; 1.6.22;
* finish off support for the 82077 chip as found on sun4m machines.
* add non-dma mode bit to `specify command', so formatting disks starts
working (thanks to Jeremy Cooper for finding out about this).
 1.5 01-Feb-1996  mycroft LOCORE -> _LOCORE
 1.4 28-Jun-1995  cgd note that most of dev/ic's contents have changed names
 1.3 20-May-1995  pk Name fd register structures more appropriately.
 1.2 22-Feb-1995  pk Reorganize to use fast interrupt handler.
 1.1 17-Feb-1995  pk Pilot sun4c floppy driver based on i386 version;
- same limitations as isa/fd.c: just read/write
- in need of a fast interrupt handler
 1.6.22.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.16.1 07-Feb-2000  he Apply patch (requested by pk):
Fix several problems:
o Floppy driver dislikes being accessed with no floppy inserted
(PR#5740)
o Floppy drive being detected even though there is none (PR#5760)
o Panic when fdformat is used (PR#9251)
 1.7.28.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.7.28.2 18-Sep-2004  skrll Sync with HEAD.
 1.7.28.1 03-Aug-2004  skrll Sync with HEAD
 1.15 30-Jun-2011  wiz dependant -> dependent
 1.14 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.13 11-Dec-2005  christos branches: 1.13.74; 1.13.76; 1.13.78;
merge ktrace-lwp.
 1.12 11-Jul-2003  pk Deal with disk change notification.
 1.11 03-May-2003  wiz branches: 1.11.2;
DMA, not dma nor Dma.
 1.10 21-Jan-2000  pk Medium sized code overhaul:
* Improve communication between the `hard' and `soft' interrupt handlers
to better distinguish various interrupt sources.
* Eliminate several race conditions where we would set a time out handler
only after starting the command on the hardware.
* Handle most timeouts by resetting the controller; there isn't much chance
of recovery in any other way. Currently, the exception is a timeout
on I/O, in which case we first try to pulse the controller's TC line
in order to abort the pseudo-dma sequence. Apparently, "normal"
conditions can induce such a timeout when there's no disk in the drive.
* Reduce the formatting gap parameter to 0x54.
* On the obio bus, interpret the `status' attribute.
* Minimize console diagnostic output if the errors we get appear to be
caused by the absence of a disk.
 1.9 17-Jan-2000  pk Use bus_space(9) functions to access the controller registers.
Add probes to the attach routines before poking the chip to see
where the registers are located.
 1.8 05-Sep-1998  pk branches: 1.8.6; 1.8.12;
Assign my copyrights to TNF.
 1.7 05-Sep-1998  pk Assign my copyrights to TNF.
 1.6 19-Oct-1997  pk Add an odd-ball japanese floppy format (PR#2903).
A good time to get rid of the hard-coded floppy sector size.
 1.5 08-Dec-1996  pk Import formatting code from the i386 version.
Revise communication between hw & sw interrupt handler.
 1.4 01-Feb-1996  mycroft LOCORE -> _LOCORE
 1.3 07-Apr-1995  pk Add evcnt_attach().
 1.2 08-Mar-1995  pk Add a CR.
 1.1 22-Feb-1995  pk Reorganize to use fast interrupt handler.
 1.8.12.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.8.6.1 07-Feb-2000  he Apply patch (requested by pk):
Fix several problems:
o Floppy driver dislikes being accessed with no floppy inserted
(PR#5740)
o Floppy drive being detected even though there is none (PR#5760)
o Panic when fdformat is used (PR#9251)
 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.13.78.1 16-May-2008  yamt sync with head.
 1.13.76.1 18-May-2008  yamt sync with head.
 1.13.74.1 02-Jun-2008  mjf Sync with HEAD.
 1.4 25-Jul-1998  pk This file is no longer used.
 1.3 27-Jan-1995  pk Update based on i386 version; from Chuck Cranor.
 1.2 20-Nov-1994  deraadt copyright/Id cleanup
 1.1 26-Oct-1994  deraadt obio/vme16 Intel Ethernet driver by Chuck Cranor. works on vme16.
 1.6 28-Jul-1998  pk This file is now in dev/sbus.
 1.5 21-Mar-1998  pk Account for changed bus attachment scheme.
 1.4 24-May-1997  pk Remove all `bustype' arguments from map[io]dev() and REG2PHYS().
 1.3 13-Oct-1996  christos backout previous kprintf change
 1.2 11-Oct-1996  christos printf -> kprintf, sprintf -> ksprintf
 1.1 22-Jun-1996  chuck sbus specific stuff for eni155s sbus atm card.
XXX: only works on sun4c, needs something better than vtophys() for
machines with IOMMUs(?).
 1.35 25-Jan-1998  pk These drivers are now in dev/vme.
The `ie' driver has been split in a VME and OBIO front-end. The latter
lives on in this directory as `if_ie_obio.c'
 1.34 12-Jan-1998  thorpej Update for changes to config.
 1.33 29-Jul-1997  fair fix editing boo-boo
 1.32 29-Jul-1997  fair %x -> 0x%x
 1.31 10-Jun-1997  pk Avoid "false positives" in match routines.
 1.30 24-May-1997  pk Remove all `bustype' arguments from map[io]dev() and REG2PHYS().
 1.29 15-Mar-1997  pk Fix a `new-ARP' pasto.
 1.28 15-Mar-1997  is New ARP system, supports IPv4 over any hardware link.

Some of the stuff (e.g., rarpd, bootpd, dhcpd etc., libsa) still will
only support Ethernet. Tcpdump itself should be ok, but libpcap needs
lot of work.

For the detailed change history, look at the commit log entries for
the is-newarp branch.
 1.27 10-Dec-1996  pk branches: 1.27.6;
Comply with recent autoconfiguration changes. Diffs graciously
supplied by Chris Demetriou.
 1.26 13-Oct-1996  christos backout previous kprintf change
 1.25 11-Oct-1996  christos printf -> kprintf, sprintf -> ksprintf
 1.24 07-May-1996  thorpej Changed struct ifnet to have a pointer to the softc of the underlying
device and a printable "external name" (name + unit number), thus eliminating
if_name and if_unit. Updated interface to (*if_watchdog)() and (*if_start)()
to take a struct ifnet *, rather than a unit number.
 1.23 10-Apr-1996  pk `bootdv' is gone. Instead, set the device pointer in the `struct bootpath'
that is passed in the attach arguments.
 1.22 31-Mar-1996  pk Various cleanup; mostly trailing spaces/tabs.
 1.21 17-Mar-1996  thorpej New device attachment scheme:

- split softc size and match/attach out from cfdriver into
a new struct cfattach.

- new "attach" directive for files.*. May specify the name of
the cfattach structure, so that devices may be easily attached
to parents with different autoconfiguration semantics.
 1.20 14-Mar-1996  christos Bring prototypes into scope and fix compiler warnings.
 1.19 25-Feb-1996  pk Use CPU-type macros.
 1.18 12-Jan-1996  chuck we handle all our mappings, so don't have obio.c do any for us
(i.e. don't set ra->ra_len in the match function).
 1.17 24-Dec-1995  mycroft The IST_* and IPL_* constants are not bus-specific; don't treat them as such.
Change splimp -> splnet in Ethernet, ARCnet, and FDDI drivers.
 1.16 11-Dec-1995  pk Adapt to changed mapiodev() interface.
 1.15 11-Apr-1995  pk iestart() returns nothing.
 1.14 11-Apr-1995  mycroft Sync with the rest of the world.
 1.13 10-Apr-1995  mycroft kernel_pmap --> pmap_kernel()
 1.12 16-Feb-1995  pk Working "config generic" support; from Theo.
 1.11 27-Jan-1995  pk Update based on i386 version; from Chuck Cranor.
 1.10 16-Dec-1994  deraadt obio ie support by chuck and me
 1.9 14-Dec-1994  deraadt obio fixes from the two chucks!
 1.8 29-Nov-1994  deraadt wait for ack from chip
 1.7 25-Nov-1994  deraadt choose {w,b}{copy,zero} automatically
 1.6 23-Nov-1994  deraadt ie cards coldstart with a parity error, reset it
 1.5 20-Nov-1994  deraadt copyright/Id cleanup
 1.4 02-Nov-1994  deraadt cleanup
 1.3 02-Nov-1994  deraadt ioctl u_long cmd
 1.2 30-Oct-1994  deraadt KNF
 1.1 26-Oct-1994  deraadt obio/vme16 Intel Ethernet driver by Chuck Cranor. works on vme16.
 1.27.6.2 10-Mar-1997  is netinet/if_ether.h => netinet/if_inarp.h
 1.27.6.1 06-Mar-1997  is Convert to new ARP code.
 1.5 25-Jan-1998  pk These drivers are now in dev/vme.
The `ie' driver has been split in a VME and OBIO front-end. The latter
lives on in this directory as `if_ie_obio.c'
 1.4 16-Dec-1994  deraadt obio ie support by chuck and me
 1.3 20-Nov-1994  deraadt copyright/Id cleanup
 1.2 30-Oct-1994  deraadt KNF
 1.1 26-Oct-1994  deraadt obio/vme16 Intel Ethernet driver by Chuck Cranor. works on vme16.
 1.44 20-Dec-2023  thorpej Remove unnecessary <sys/malloc.h>.
 1.43 24-Oct-2021  andvar fix various typos in comments, mainly copypasta.
 1.42 25-Apr-2019  msaitoh No functional change:
- Use __arraycount().
- u_int_{8,16,32}_t -> uint_{8,16,32}_t
- KNF.
- Tabify.
- Remove extra space.
 1.41 19-Oct-2013  mrg branches: 1.41.30;
- remove unused but set variables.
- use __USE() where necessary.
- remove useless 'volatile' markers

kd.c:consinit() might be wrong for old proms, but i've not
changed it really.
 1.40 01-Jul-2011  dyoung branches: 1.40.2; 1.40.12; 1.40.16;
#include <sys/bus.h> instead of <machine/bus.h>.
 1.39 03-Jun-2011  tsutsui Split device_t/softc of i82586. No crash on TME emulating sun2.
 1.38 01-Feb-2011  chuck branches: 1.38.2;
udpate license clauses on my code to match the new-style BSD licenses.
remove no-longer-valid wustl email address for me.
based on diff that rmind@ sent me.

no functional change with this commit.
 1.37 20-Sep-2009  tsutsui branches: 1.37.4; 1.37.6; 1.37.8;
- use device_t and cfdriver_t
- use device_private() and device_xname()
- use proper types or variables for device_t/softc
 1.36 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.35 04-Mar-2007  christos branches: 1.35.40; 1.35.42; 1.35.44;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.34 22-Feb-2007  thorpej TRUE -> true, FALSE -> false
 1.33 16-Nov-2005  uwe branches: 1.33.26;
ANSIify function declarations/defintions. Use uint<N>_t.
Propagate "static" to function definitions. Drop trailing whitespace.
Same binary code is produced for GENERIC.MP + KGDB + DDB.
 1.32 04-Jun-2005  tsutsui branches: 1.32.2; 1.32.8;
Fix for gcc -Wshadow.
 1.31 15-Mar-2004  pk Replace myetheraddr() by prom_getether().
 1.30 15-Jul-2003  lukem __KERNEL_RCSID()
 1.29 02-Apr-2003  thorpej branches: 1.29.2;
Use PAGE_SIZE rather than NBPG.
 1.28 10-Dec-2002  pk Remove the `flags' argument from bus_intr_establish().
 1.27 02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.26 01-Oct-2002  thorpej Use CFATTACH_DECL().
 1.25 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.24 11-Mar-2002  pk * `bus_type_t' is gone.
* Use BUS_ADDR() where appropriate to encode I/O space and physical
address offset into a `bus_addr_t' value.
* Drop obio_bus_map() since it's now completely equivalent to bus_space_map()
* Use bus_space_map2() to map device space at a fixed virtual address.
* Remove the virtual address argument from sbus_sbus_addr()
 1.23 10-Sep-2001  chris branches: 1.23.4;
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.22 24-Apr-2001  thorpej branches: 1.22.2; 1.22.4;
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.21 13-Mar-2001  tsutsui Update for recent changes to the MI i82586 driver.
(added 'why' argument to the channel attention hook function)
 1.20 08-Mar-2001  thorpej Duh, don't forget the proc argument.
 1.19 08-Mar-2001  thorpej Use bus_dmamap_load(), not bus_dmamap_load_raw().
 1.18 22-Jan-2001  bjh21 branches: 1.18.2;
Patch from PR kern/8001, submitted by Rafal Boni.

This adds support for EtherExpress/16 cards with 16k of RAM, and in the
process adds general support for PIO mode on these cards. This entails
changing the way the i82586 driver handles bus barriers, since it doesn't
allow for strange cases like this.

This has been tested on the i386 port with the 'ix' driver in both
16KB (which was the source of the problem) and 32KB modes, as well
as with the 'ef' driver. I've tested it (briefly) with 'ei' on arm26
as well. In theory, drivers other than 'ix' should follow precisely the
same code paths as before.
 1.17 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.16 29-Jun-2000  mrg remove include of <vm/vm.h> and <machine/pmap.h>. <vm/vm.h> -> <uvm/uvm_extern.h>
 1.15 15-Jun-2000  pk branches: 1.15.2;
bus_dmapmap_create: boundary must be 0, not NBPG.
 1.14 09-May-2000  pk branches: 1.14.2;
Conform bus_dmamem_{alloc,map} usage to bus_dma(9) specs.
 1.13 11-Jan-2000  pk Remove old-style boot device recognition.
 1.12 13-Nov-1999  thorpej Update for pmap_enter() API change. No functional difference.
 1.11 08-Jul-1999  thorpej branches: 1.11.2; 1.11.4; 1.11.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.10 26-Mar-1999  mycroft branches: 1.10.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.9 18-Mar-1999  pk Fix various things that kept this bus front-end from functioning..
 1.8 23-Aug-1998  pk Use bus_dmamem_{alloc,free} instead of the old VM hack.
 1.7 21-Aug-1998  pk Convert to [pv]addr_t.
 1.6 29-Mar-1998  pk obio_bus_probe() => bus_space_probe()
 1.5 22-Mar-1998  pk Fill in the pointers the MI back-end expects correctly.
Add comment and diagram explaining the memory layout (to be revisited..).
 1.4 21-Mar-1998  pk Account for changed bus attachment scheme.
 1.3 28-Feb-1998  pk Remove `_NEW_I82586'.
 1.2 07-Feb-1998  chs add UVM stuff.
 1.1 25-Jan-1998  pk sparc/obio bus front-end to the i82586 driver.
 1.10.4.1 02-Aug-1999  thorpej Update from trunk.
 1.11.8.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.11.4.1 15-Nov-1999  fvdl Sync with -current
 1.11.2.4 27-Mar-2001  bouyer Sync with HEAD.
 1.11.2.3 12-Mar-2001  bouyer Sync with HEAD.
 1.11.2.2 11-Feb-2001  bouyer Sync with HEAD.
 1.11.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.14.2.1 22-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.15.2.1 19-Jul-2000  mrg pull up sparc/sparc64 bus_intr_establish() changes, necessary for sparc64
(originally done by pk, approved by thorpej):

>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.18.2.2 21-Jun-2001  nathanw Catch up to -current.
 1.18.2.1 09-Apr-2001  nathanw Catch up with -current.
 1.22.4.1 01-Oct-2001  fvdl Catch up with -current.
 1.22.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.22.2.2 16-Mar-2002  jdolecek Catch up with -current.
 1.22.2.1 13-Sep-2001  thorpej Update the kqueue branch to HEAD.
 1.23.4.4 11-Dec-2002  thorpej Sync with HEAD.
 1.23.4.3 18-Oct-2002  nathanw Catch up to -current.
 1.23.4.2 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.23.4.1 10-Sep-2001  nathanw file if_ie_obio.c was added on branch nathanw_sa on 2002-04-01 07:42:41 +0000
 1.29.2.5 11-Dec-2005  christos Sync with head.
 1.29.2.4 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.29.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.29.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.29.2.1 03-Aug-2004  skrll Sync with HEAD
 1.32.8.1 22-Nov-2005  yamt sync with head.
 1.32.2.3 03-Sep-2007  yamt sync with head.
 1.32.2.2 26-Feb-2007  yamt sync with head.
 1.32.2.1 21-Jun-2006  yamt sync with head.
 1.33.26.2 12-Mar-2007  rmind Sync with HEAD.
 1.33.26.1 27-Feb-2007  yamt - sync with head.
- move sched_changepri back to kern_synch.c as it doesn't know PPQ anymore.
 1.35.44.2 11-Mar-2010  yamt sync with head
 1.35.44.1 16-May-2008  yamt sync with head.
 1.35.42.1 18-May-2008  yamt sync with head.
 1.35.40.1 02-Jun-2008  mjf Sync with HEAD.
 1.37.8.1 08-Feb-2011  bouyer Sync with HEAD
 1.37.6.1 06-Jun-2011  jruoho Sync with HEAD.
 1.37.4.2 12-Jun-2011  rmind sync with head
 1.37.4.1 05-Mar-2011  rmind sync with head
 1.38.2.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.40.16.1 18-May-2014  rmind sync with head
 1.40.12.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.40.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.41.30.1 10-Jun-2019  christos Sync with HEAD
 1.57 27-Jul-1998  pk Split the `le' driver front-ends into separate files.
The sbus and lebuffer front-end have moved to dev/sbus.
 1.56 21-Jul-1998  drochner adapt to LANCE driver split
 1.55 05-Jul-1998  jonathan defopt INET, NETATALK.
 1.54 29-Mar-1998  pk obio_bus_probe() => bus_space_probe()
 1.53 21-Mar-1998  pk Account for changed bus attachment scheme.
 1.52 12-Jan-1998  thorpej Update for changes to config.
 1.51 05-Oct-1997  thorpej Copyright assigned to The NetBSD Foundation.
 1.50 09-Sep-1997  pk Turn on D_DSBL_WRINVAL on `ledma'.
 1.49 07-Jul-1997  pk branches: 1.49.2;
Install media functions only if something useful can be returned.
 1.48 24-May-1997  pk Remove all `bustype' arguments from map[io]dev() and REG2PHYS().
 1.47 04-Apr-1997  pk Use sc_hwreset() hook to reset ledma (if applicable).
 1.46 23-Mar-1997  pk Clamp burst sizes to maximum value of parent.
Reset ledma from leattach().
 1.45 17-Mar-1997  thorpej Use if_media to select media (or autoselect rules) on the Sun4m.
 1.44 15-Mar-1997  is New ARP system, supports IPv4 over any hardware link.

Some of the stuff (e.g., rarpd, bootpd, dhcpd etc., libsa) still will
only support Ethernet. Tcpdump itself should be ok, but libpcap needs
lot of work.

For the detailed change history, look at the commit log entries for
the is-newarp branch.
 1.43 10-Mar-1997  pk Redo attach code somewhat. Have a go at matching le's and lebuffer's on
machines where the PROM does not provide a parent/child relationship.
 1.42 10-Dec-1996  pk branches: 1.42.6;
Comply with recent autoconfiguration changes. Diffs graciously
supplied by Chris Demetriou.
 1.41 06-Dec-1996  pk Detect `lebuffer' parents and use the provided buffer.
 1.40 13-Oct-1996  christos backout previous kprintf change
 1.39 11-Oct-1996  christos printf -> kprintf, sprintf -> ksprintf
 1.38 27-Sep-1996  abrown Oops. Last change will slow down a GENERIC kernel. Add a CPU type test
for cleanliness.
KNF a return statement.
 1.37 27-Sep-1996  abrown Fix long-standing bug with Lance ethernet and Sun4m's, where each packet
would generate two interrupts, one real and one spurious. The solution
is to force a drain of the SBus->MBus write buffers after writing to the
lance to clear the interrupt. Thanks to Chris Torek for pointing out a much
easier way to do this than I had planned...
 1.36 06-Jul-1996  abrown Take advantage of new am7990 sc_nocarrier() function in order to do auto-
matic media detection on Sun4m machines which support multiple media
(UTP and AUI). New function lenocarrier() switches media type when called
if no link? flags are set.

Redefine link flags for Lance ethernet (le):
<none>: switch between media as needed to find carrier (autodetect)
Preference to whatever the PROM is using (AUI if not booted
from the network)
link0: use UTP port only
link1: use AUI port only

This allows Sun4m machines with dual media Lance ethernet adapters to
boot from the network on the UTP port.
 1.35 16-May-1996  pk branches: 1.35.4;
Check for `configuration parent' differently: compare against "sbus"
rather than "ledma".
 1.34 16-May-1996  abrown Copyright police (s/Harvard University/Harvard College/).
 1.33 07-May-1996  thorpej Make the MI LANCE driver standalone, and use cfattach to resolve
naming conflicts between bus attachments on ports that can have
multiple instances of the LANCE.

Changed struct ifnet to have a pointer to the softc of the underlying
device and a printable "external name" (name + unit number), thus eliminating
if_name and if_unit. Updated interface to (*if_watchdog)() and (*if_start)()
to take a struct ifnet *, rather than a unit number.
 1.32 22-Apr-1996  abrown Now that we have lehwinit() for the Sun4m, make sure that we wait 20ms
after changing the cable type, as specified in the chip documentation.
Also, sanity-check that sc_dma is valid in case a Sun4m ever exists without
a ledma.
 1.31 22-Apr-1996  christos Oops the name of the UTP/AUI bit changed under me...
 1.30 22-Apr-1996  christos Add a hardware dependent initialization function lehwinit()
to support selecting UTP media on sun4m
 1.29 18-Apr-1996  cgd change LANCE copy & zero functions' names to start with amd7990_, and
remove their 'integrate' (usually defined to be 'static') keywords.
when lance drivers are split up by attachment, more than one file will
reference the copy/zero functions (i.e. not just the file that pulls in
am7990.c... and eventually inclusion of am7990.c should go away entirely).
 1.28 10-Apr-1996  pk `bootdv' is gone. Instead, set the device pointer in the `struct bootpath'
that is passed in the attach arguments.
 1.27 31-Mar-1996  pk Deal with sun4m le/ledma. Work around spurious interrupt problem (aaron).
 1.26 17-Mar-1996  thorpej New device attachment scheme:

- split softc size and match/attach out from cfdriver into
a new struct cfattach.

- new "attach" directive for files.*. May specify the name of
the cfattach structure, so that devices may be easily attached
to parents with different autoconfiguration semantics.
 1.25 12-Jan-1996  chuck we handle all our mappings, so don't have obio.c do any for us
(i.e. don't set ra->ra_len in the match function).
 1.24 11-Dec-1995  pk Adapt to changed mapiodev() interface.
 1.23 10-Dec-1995  mycroft Use the MI LANCE code.
 1.22 06-Dec-1995  pk dvma_malloc => malloc/dvma_mapin. (not the most elegant solution, but it'll
have to do for now).
 1.21 23-Jun-1995  pk Sync with net/if.h
 1.20 12-Apr-1995  pk Use arp_ifinit().
 1.19 09-Apr-1995  pk Adapt to if.h changes.
 1.18 16-Feb-1995  pk Working "config generic" support; from Theo.
 1.17 23-Nov-1994  deraadt XXmatch change (and a few __P() as well)
 1.16 20-Nov-1994  deraadt copyright/Id cleanup
 1.15 02-Nov-1994  deraadt ioctl u_long cmd
 1.14 15-Oct-1994  deraadt sbus_establish() is sun4c/sun4m specific
 1.13 15-Oct-1994  deraadt mapiodev takes a bustype argument now
 1.12 02-Oct-1994  deraadt sun4/300 support works
 1.11 17-Sep-1994  deraadt sbus/* --> dev/*
deal with multiple bus types (start of vme/obio support)
 1.10 04-Jul-1994  deraadt need vm/vm.h
 1.9 02-Jul-1994  deraadt tmd2/rmd2 have bits which must be set to 1
 1.8 17-May-1994  deraadt use ether_input
 1.7 13-May-1994  deraadt new from 4.4-lite
 1.6 22-Apr-1994  deraadt stub fix
 1.5 08-Apr-1994  deraadt MULTICAST is standard now
 1.4 24-Jan-1994  deraadt ether_input() takes ether_type in net byte order now
 1.3 05-Nov-1993  deraadt if_init goes away.
 1.2 11-Oct-1993  deraadt bwtwo.c, cgthree.c: sys-fbio.h -> machine/fbio.h
if_le.c: #ifdef MULTICAST some things, and do arp the old way
 1.1 02-Oct-1993  deraadt Chris Torek's sparc port. Missing lots of things.
 1.35.4.2 06-Dec-1996  rat Pullup request 1.36 -> 1.38 from Aaron Brown <abrown@eecs.harvard.edu>

>Fixes a long-standing bug in the Sun4m ethernet driver that causes
>cause each received packet to generate two interrupts rather than one.
 1.35.4.1 17-Jul-1996  jtc Patch from Aaron Brown needed for netboot
 1.42.6.3 12-Mar-1997  is Merge in changes from The Trunk
 1.42.6.2 10-Mar-1997  is netinet/if_ether.h => netinet/if_inarp.h
 1.42.6.1 06-Mar-1997  is Convert to new ARP code.
 1.49.2.2 14-Oct-1997  thorpej Update marc-pcmcia branch from trunk.
 1.49.2.1 16-Sep-1997  thorpej Update marc-pcmcia branch from trunk.
 1.5 29-Aug-1998  pk Split `esp' driver and DMA engine into separate front-end files.
The Sbus front-ends have all been moved to `sys/dev/sbus', while
the `obio' front-ends remain here.
 1.4 28-Aug-1998  pk Specify our boundary restriction when allocating DMAble memory.
 1.3 15-Aug-1998  mycroft Assign my copyrights to TNF.
 1.2 29-Jul-1998  pk In the reset() function, preserve the current cable selection bit.
If in auto media select mode, this avoids losing carrier every time
the lance code decides to re-initialize.
 1.1 27-Jul-1998  pk Split the `le' driver front-ends into separate files.
The sbus and lebuffer front-end have moved to dev/sbus.
 1.29 29-May-2022  rin le(4): Fix resource leaks for error paths.

XXX
Compile test only (at least one arch per driver).
 1.28 25-Apr-2019  msaitoh No functional change:
- Use __arraycount().
- u_int_{8,16,32}_t -> uint_{8,16,32}_t
- KNF.
- Tabify.
- Remove extra space.
 1.27 01-Jul-2011  dyoung branches: 1.27.54;
#include <sys/bus.h> instead of <machine/bus.h>.
 1.26 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.25 04-Apr-2008  tsutsui branches: 1.25.2; 1.25.4;
Split device_t/softc for le(4) and variants and misc cosmetic changes.
 1.24 04-Mar-2007  christos branches: 1.24.40;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.23 16-Nov-2005  uwe branches: 1.23.26;
Drop unnecessary includes and extern declarations.
Declare match/attach routines static.
 1.22 16-Nov-2005  uwe ANSIify function declarations/defintions. Use uint<N>_t.
Propagate "static" to function definitions. Drop trailing whitespace.
Same binary code is produced for GENERIC.MP + KGDB + DDB.
 1.21 15-Mar-2004  pk branches: 1.21.16; 1.21.24;
Replace myetheraddr() by prom_getether().
 1.20 11-Nov-2003  pk Remove ancient DDB-dependent `hide/integrate'.
Simplify lewrcsr/lerdcsr; read-back after write doesn't hurt on sun4 so
skip the cpu type test in generic kernels.
 1.19 15-Jul-2003  lukem __KERNEL_RCSID()
 1.18 02-Apr-2003  thorpej branches: 1.18.2;
Use PAGE_SIZE rather than NBPG.
 1.17 10-Dec-2002  pk 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 11-Mar-2002  pk * `bus_type_t' is gone.
* Use BUS_ADDR() where appropriate to encode I/O space and physical
address offset into a `bus_addr_t' value.
* Drop obio_bus_map() since it's now completely equivalent to bus_space_map()
* Use bus_space_map2() to map device space at a fixed virtual address.
* Remove the virtual address argument from sbus_sbus_addr()
 1.12 30-May-2001  mrg branches: 1.12.2; 1.12.8;
use _KERNEL_OPT
 1.11 09-Mar-2001  pk pasto: sc_maddr => sc_mem
 1.10 08-Mar-2001  thorpej Duh, don't forget the proc argument.
 1.9 08-Mar-2001  thorpej Use bus_dmamap_load(), not bus_dmamap_load_raw().
 1.8 09-Jul-2000  pk branches: 1.8.2;
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.7 09-May-2000  pk branches: 1.7.4;
Conform bus_dmamem_{alloc,map} usage to bus_dma(9) specs.
 1.6 11-Jan-2000  pk Remove old-style boot device recognition.
 1.5 29-Aug-1998  pk branches: 1.5.12;
Split `esp' driver and DMA engine into separate front-end files.
The Sbus front-ends have all been moved to `sys/dev/sbus', while
the `obio' front-ends remain here.
 1.4 15-Aug-1998  mycroft Assign my copyrights to TNF.
 1.3 31-Jul-1998  pk Use bus_dmamem_alloc/bus_dmamem_map.
 1.2 28-Jul-1998  pk branches: 1.2.2;
GC.
 1.1 27-Jul-1998  pk Split the `le' driver front-ends into separate files.
The sbus and lebuffer front-end have moved to dev/sbus.
 1.2.2.1 08-Aug-1998  eeh Revert cdevsw mmap routines to return int.
 1.5.12.2 12-Mar-2001  bouyer Sync with HEAD.
 1.5.12.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.7.4.1 19-Jul-2000  mrg pull up sparc/sparc64 bus_intr_establish() changes, necessary for sparc64
(originally done by pk, approved by thorpej):

>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.8.2.2 21-Jun-2001  nathanw Catch up to -current.
 1.8.2.1 09-Apr-2001  nathanw Catch up with -current.
 1.12.8.4 11-Dec-2002  thorpej Sync with HEAD.
 1.12.8.3 18-Oct-2002  nathanw Catch up to -current.
 1.12.8.2 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.12.8.1 30-May-2001  nathanw file if_le_obio.c was added on branch nathanw_sa on 2002-04-01 07:42:42 +0000
 1.12.2.2 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.12.2.1 16-Mar-2002  jdolecek Catch up with -current.
 1.18.2.4 11-Dec-2005  christos Sync with head.
 1.18.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.18.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.18.2.1 03-Aug-2004  skrll Sync with HEAD
 1.21.24.1 22-Nov-2005  yamt sync with head.
 1.21.16.2 03-Sep-2007  yamt sync with head.
 1.21.16.1 21-Jun-2006  yamt sync with head.
 1.23.26.1 12-Mar-2007  rmind Sync with HEAD.
 1.24.40.1 02-Jun-2008  mjf Sync with HEAD.
 1.25.4.1 16-May-2008  yamt sync with head.
 1.25.2.1 18-May-2008  yamt sync with head.
 1.27.54.1 10-Jun-2019  christos Sync with HEAD
 1.6 28-Jul-1998  pk We no longer use these.
 1.5 10-Dec-1995  mycroft Use the MI LANCE code.
 1.4 20-Nov-1994  deraadt copyright/Id cleanup
 1.3 02-Jul-1994  deraadt tmd2/rmd2 have bits which must be set to 1
 1.2 13-May-1994  deraadt new from 4.4-lite
 1.1 02-Oct-1993  deraadt Chris Torek's sparc port. Missing lots of things.
 1.9 28-Jul-1998  pk We no longer use these.
 1.8 21-Mar-1998  pk Add bus tags to softc.
 1.7 04-Apr-1997  pk Use sc_hwreset() hook to reset ledma (if applicable).
 1.6 15-Mar-1997  is New ARP system, supports IPv4 over any hardware link.

Some of the stuff (e.g., rarpd, bootpd, dhcpd etc., libsa) still will
only support Ethernet. Tcpdump itself should be ok, but libpcap needs
lot of work.

For the detailed change history, look at the commit log entries for
the is-newarp branch.
 1.5 07-May-1996  thorpej branches: 1.5.8;
Make the MI LANCE driver standalone, and use cfattach to resolve
naming conflicts between bus attachments on ports that can have
multiple instances of the LANCE.

Changed struct ifnet to have a pointer to the softc of the underlying
device and a printable "external name" (name + unit number), thus eliminating
if_name and if_unit. Updated interface to (*if_watchdog)() and (*if_start)()
to take a struct ifnet *, rather than a unit number.
 1.4 31-Mar-1996  pk Various cleanup; mostly trailing spaces/tabs.
 1.3 14-Mar-1996  christos Bring prototypes into scope and fix compiler warnings.
 1.2 11-Dec-1995  pk Adapt to changed mapiodev() interface.
 1.1 10-Dec-1995  mycroft Use the MI LANCE code.
 1.5.8.1 06-Mar-1997  is Convert to new ARP code.
 1.2 30-Oct-1994  mycroft Clean up deleted files.
 1.1 26-Oct-1994  deraadt obio/vme16 Intel Ethernet driver by Chuck Cranor. works on vme16.
 1.19 27-Aug-1998  mrg move isp sbus attachment to dev/sbus
 1.18 13-Aug-1998  eeh Merge paddr_t changes into the main branch.
 1.17 12-Aug-1998  mjacob minor change to make the message less linux like
 1.16 31-Jul-1998  pk Convert to bus dma.
 1.15 31-Jul-1998  thorpej Back out previous; it is perfectly reasonable, and desirable, to print out
debugging info ifdef DEBUG.
 1.14 31-Jul-1998  mjacob >We're not Linux. If we still want driver version strings to be displayed
>at boot, then I suppose DEBUG is a reasonable compromise.
Makes the whole concept useless. This is for default printouts. If you
can build a debug kernel, you know what version you have. This was under
the concept of 'RAS' so that hapless users could tell you microversion
things. But I guess this isn't the right way according to our local
Jesuits. Oh, well. I'll think up something different and hopefully
less objectionable. And yes, NetBSD isn't linux. The developers seem
to be equally bad tempered, but linux is more successful.
 1.13 29-Jul-1998  pk branches: 1.13.2;
Deal with sbus attach args changes.
 1.12 20-Jul-1998  thorpej We're not Linux. If we still want driver version strings to be displayed
at boot, then I suppose DEBUG is a reasonable compromise.
 1.11 18-Jul-1998  mjacob locking now out of main framework for isp_reset/isp_init
 1.10 15-Jul-1998  mjacob new framework
 1.9 21-Mar-1998  pk Account for changed bus attachment scheme.
 1.8 27-Aug-1997  bouyer branches: 1.8.4;
Merge scsipi branch in the mainline. This add support for ATAPI devices
(currently only CD-ROM drives on i386). The sys/dev/scsipi system provides 2
busses to which devices can attach (scsibus and atapibus). This needed to
change some include files and structure names in the low level scsi drivers.
 1.7 16-Aug-1997  mjacob Changes for PCI Qlogic ISP2100 meant a few minor changes.
 1.6 08-Jun-1997  thorpej branches: 1.6.2; 1.6.4;
Update for changes in the core ISP driver.
 1.5 24-May-1997  pk Remove all `bustype' arguments from map[io]dev() and REG2PHYS().
 1.4 13-Mar-1997  cgd change microcode array definitions from "unsigned short" to the more
correct u_int16_t, and remove bogus casts that the old definition
required.
 1.3 13-Mar-1997  mycroft Make the microcode table const.
 1.2 12-Mar-1997  cgd NetBSD RCS ID tweaks, a few comment block tweaks. Also, make copyright
notices consistent (per Matt Jacob).
 1.1 12-Mar-1997  cgd branches: 1.1.1;
Initial revision
 1.1.1.1 12-Mar-1997  cgd ISP 10x0 driver from Matthew Jacob of NASA Ames Research Center.
(March 12, 1997 version).
 1.6.4.2 27-Aug-1997  thorpej Update marc-pcmcia branch from trunk.
 1.6.4.1 23-Aug-1997  thorpej Update marc-pcmcia branch from trunk.
 1.6.2.2 26-Aug-1997  bouyer Update from trunk.
 1.6.2.1 01-Jul-1997  bouyer Updates for new scsipi subsystem. Actally known to work on i386 and sparc.
 1.8.4.1 07-Nov-1998  cgd patch to update this code to work with the rest of the updated
MI ISP driver. (mjacob)
 1.13.2.1 08-Aug-1998  eeh Revert cdevsw mmap routines to return int.
 1.29 18-Oct-1997  gwr Use common zs code.
 1.28 13-Sep-1997  pk In kbdattach() (the pseudo-device attach routine) wait for the keyboard
reset sequence to complete. Just sending the reset command and rushing
off -- like it used to do -- might cause the keyboard's response to get
lost in case the remaining kernel initialization decides to interact
with the console (RB_ASK!) by calling cngetc(), which goes off polling
within the PROM.
 1.27 13-Oct-1996  christos branches: 1.27.10;
backout previous kprintf change
 1.26 11-Oct-1996  christos printf -> kprintf, sprintf -> ksprintf
 1.25 12-Sep-1996  mrg update these for poll(2) changes.
 1.24 30-May-1996  pk event_var.h changed location.
 1.23 01-Apr-1996  christos Remove last dependency to dev_conf.h and the file itself.
 1.22 14-Mar-1996  christos Bring prototypes into scope and fix compiler warnings.
 1.21 25-Feb-1996  pk Use CPU-type macros
 1.20 12-Feb-1996  pk Avoid compiler warning.
 1.19 06-Jul-1995  pk Support KIOC_GETLAYOUT, so other than US keyboards can be dealt with better.
 1.18 10-May-1995  pk Minimalist implementation of KIOC[SG]KEY.
 1.17 02-May-1995  pk Make sure kbdopen() ships the keyboard reset cmd.
 1.16 27-Apr-1995  pk Handle KIOC[GS]LED ioctls; from Lon Willett.
 1.15 20-Nov-1994  deraadt copyright/Id cleanup
 1.14 02-Nov-1994  deraadt ioctl u_long cmd
 1.13 17-Sep-1994  deraadt sbus/* --> dev/*
deal with multiple bus types (start of vme/obio support)
 1.12 25-Aug-1994  deraadt sun4: don't use openprom
 1.11 21-Jul-1994  deraadt make X11R5 compile easier
 1.10 05-May-1994  deraadt branches: 1.10.2;
timeout and ndflush casts
 1.9 16-Apr-1994  deraadt my dumb bug of the week: keyboard repeat fritzed if you typed ^@
and repeated that character forever
 1.8 10-Apr-1994  deraadt small optimization
 1.7 09-Apr-1994  deraadt keyboard repeat code!
 1.6 03-Mar-1994  deraadt kbd is now a pseudo-device
 1.5 03-Mar-1994  deraadt fix comment
 1.4 27-Feb-1994  deraadt whoops
 1.3 27-Feb-1994  deraadt fake out KIOCLAYOUT
 1.2 11-Oct-1993  deraadt cons.c, zs.c: tty->t_stop doesn't exist here. I think it goes through d_stop
automatically now, but have not checked.
l_ioctl() has no last parameter 'p'
fb.c: move sys/fbio.h to machine/fbio.h
various: typecast parms for timeout() properly
zs.c: extra level of indir in cdevsw[]->d_ttys
 1.1 02-Oct-1993  deraadt Chris Torek's sparc port. Missing lots of things.
 1.10.2.1 22-Jul-1994  cgd from trunk.
 1.27.10.1 16-Sep-1997  thorpej Update marc-pcmcia branch from trunk.
 1.2 21-Jul-1994  mycroft Clean up deleted files.
 1.1 02-Oct-1993  deraadt Chris Torek's sparc port. Missing lots of things.
 1.4 13-Mar-2004  bjh21 Abstract the interface between pckbc(4), and the pckbd(4) and pms(4)
drivers that attach to it. This allows for other host interface chips
that use the same keyboards and mice, such as the ones in the ARM
IOMD20, ARM7500, and SA-1111. The PC-compatible driver is still
called pckbc(4), and the new abstraction layer is "pckbport", so the
child devices have moved from sys/dev/pckbc to sys/dev/pckbport, which
also contains some code shared between all host controllers. To avoid
incompatibility, pckbdreg.h is still installed in
/usr/include/dev/pckbc.

In theory, this shouldn't cause any behavioural changes in the drivers
concerned. Thy just use rather more function pointers than before. Tested
on i386 and (with a new host driver) acorn32. Compiled on several other
affected architectures.
 1.3 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.2 21-Oct-2002  uwe branches: 1.2.6;
Clean-up kbd driver layers a bit more. Lift common code into the upper layer.
Add some wskbd TODO remarks (hi, martin).
 1.1 03-Oct-2002  uwe branches: 1.1.2;
First cut at PS/2 keyboard and mouse drivers that talk Sun firm events.
Console and Xsun for Mr.Coffee.
 1.1.2.3 11-Nov-2002  nathanw Catch up to -current
 1.1.2.2 18-Oct-2002  nathanw Catch up to -current.
 1.1.2.1 03-Oct-2002  nathanw file kbd_pckbc.c was added on branch nathanw_sa on 2002-10-18 02:39:54 +0000
 1.2.6.1 03-Aug-2004  skrll Sync with HEAD
 1.7 24-May-2022  andvar fix various typos in comment, documentation and log messages.
 1.6 01-Jul-2011  dyoung #include <sys/bus.h> instead of <machine/bus.h>.
 1.5 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.4 07-Apr-2008  tsutsui branches: 1.4.2; 1.4.4;
Split device_t/softc, as following parents in sys/dev/sun.
 1.3 16-Nov-2005  uwe branches: 1.3.74;
ANSIify. Use uint<N>_t. Drop unnecessary includes.
Drop trailing whitespace.
 1.2 16-Jun-2005  jmc branches: 1.2.2; 1.2.8;
Rename a shadowed variable
 1.1 13-Mar-2004  bjh21 branches: 1.1.4;
Abstract the interface between pckbc(4), and the pckbd(4) and pms(4)
drivers that attach to it. This allows for other host interface chips
that use the same keyboards and mice, such as the ones in the ARM
IOMD20, ARM7500, and SA-1111. The PC-compatible driver is still
called pckbc(4), and the new abstraction layer is "pckbport", so the
child devices have moved from sys/dev/pckbc to sys/dev/pckbport, which
also contains some code shared between all host controllers. To avoid
incompatibility, pckbdreg.h is still installed in
/usr/include/dev/pckbc.

In theory, this shouldn't cause any behavioural changes in the drivers
concerned. Thy just use rather more function pointers than before. Tested
on i386 and (with a new host driver) acorn32. Compiled on several other
affected architectures.
 1.1.4.6 11-Dec-2005  christos Sync with head.
 1.1.4.5 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.1.4.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.1.4.3 18-Sep-2004  skrll Sync with HEAD.
 1.1.4.2 03-Aug-2004  skrll Sync with HEAD
 1.1.4.1 13-Mar-2004  skrll file kbd_pckbport.c was added on branch ktrace-lwp on 2004-08-03 10:40:45 +0000
 1.2.8.1 22-Nov-2005  yamt sync with head.
 1.2.2.1 21-Jun-2006  yamt sync with head.
 1.3.74.1 02-Jun-2008  mjf Sync with HEAD.
 1.4.4.1 16-May-2008  yamt sync with head.
 1.4.2.1 18-May-2008  yamt sync with head.
 1.4 21-Jul-1994  mycroft Clean up deleted files.
 1.3 05-May-1994  deraadt space/tab garple
 1.2 27-Feb-1994  deraadt fake out KIOCLAYOUT
 1.1 02-Oct-1993  deraadt Chris Torek's sparc port. Missing lots of things.
 1.54 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.53 16-Mar-2014  dholland branches: 1.53.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.52 19-Oct-2013  mrg - remove unused but set variables.
- use __USE() where necessary.
- remove useless 'volatile' markers

kd.c:consinit() might be wrong for old proms, but i've not
changed it really.
 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 30-Jul-2012  christos branches: 1.50.2;
move cn_tab initializationt to cpu_startup
 1.49 24-Apr-2011  rmind branches: 1.49.4;
Rename ttymalloc() to tty_alloc(), and ttyfree() to tty_free() for
consistency. Remove some unnecessary malloc.h inclusions as well.
 1.48 28-Apr-2008  martin branches: 1.48.22; 1.48.28;
Remove clause 3 and 4 from TNF licenses
 1.47 19-Nov-2007  ad branches: 1.47.14; 1.47.16; 1.47.18;
- Factor out too many copies of the same bit of tty code.
- Fix another tty signalling/wakeup problem.
 1.46 18-Oct-2007  joerg branches: 1.46.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.45 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.44 09-Jul-2007  ad branches: 1.44.8; 1.44.10; 1.44.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.43 04-Mar-2007  christos branches: 1.43.2; 1.43.4; 1.43.10;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.42 16-Feb-2007  ad branches: 1.42.2;
More spllowersoftclock() fallout.
 1.41 01-Oct-2006  elad Adapt MD code to KAUTH_DEVICE_TTY_OPEN. Patch from Matt Fleming, thanks!
 1.40 23-Jul-2006  ad branches: 1.40.4; 1.40.6;
Use the LWP cached credentials where sane.
 1.39 14-May-2006  elad integrate kauth.
 1.38 11-Dec-2005  christos branches: 1.38.4; 1.38.6; 1.38.8; 1.38.10; 1.38.12;
merge ktrace-lwp.
 1.37 16-Nov-2005  uwe Drop trailing whitespace.
 1.36 14-Nov-2005  uwe ANSIify. Same code is generated.
While here, collect in one place prototypes that were scattered
throughout the file, apply static to prom_cn* consistently.
 1.35 06-Sep-2005  kleink branches: 1.35.6;
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.34 30-Jun-2005  macallan branches: 1.34.2;
Allow sparc64-style attachment of mouse and keyboard via zstty, needed for
wscons support.
Reviewed by uwe.
 1.33 03-Jun-2005  martin Sprinkle some const
 1.32 17-Mar-2004  pk Rename PROM_getprop*() => prom_getprop*().
 1.31 16-Mar-2004  pk Use prom_getoption() and drop home-grown string-to-integer conversion code.
 1.30 27-Aug-2003  uwe cc_callout does not belong to struct cons_channel, as it's only used
by sparc for PROM console input channel. Demote it to kd.c as a
static variable.

While there, use callout_schedule instead of callout_reset to
reschedule the PROM polling callout, and init prom_cons_channel
statically.
 1.29 27-Aug-2003  uwe Kill __P().
 1.28 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.27 24-Aug-2003  uwe #include "opt_rcons.h"
 1.26 15-Jul-2003  lukem __KERNEL_RCSID()
 1.25 29-Jun-2003  fvdl branches: 1.25.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.24 29-Jun-2003  darrenr More changes for providing lwpid for ktrace (sparc GENERIC built)
 1.23 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.22 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.21 17-Mar-2002  atatat branches: 1.21.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.20 26-Sep-2001  eeh branches: 1.20.4;
getprop* -> PROM_getprop*
 1.19 11-Jun-2001  pk branches: 1.19.2; 1.19.4;
Use NFB from "fb.h" to include console framebuffer support.
 1.18 26-May-2001  pk Pull in "opt_kgdb.h"; see PR#13036.
 1.17 02-May-2001  scw Add `l_poll' to `struct linesw' and provide an xxxpoll() entry point
in each tty driver to indirect through it.

This allows tty line-disciplines to handle poll(2) system calls.
 1.16 02-Nov-2000  eeh branches: 1.16.2;
Adapt to new line discipline scheme.
 1.15 12-Oct-2000  christos add missing kd_attach_input routine.
someone needs to clean this shit up.
 1.14 22-Aug-2000  pk Use the framebuffer drivers & header files that now live in /sys/dev/sun.
 1.13 04-Jul-2000  pk Pass correct argument to the console channel close routine.
 1.12 21-May-2000  eeh branches: 1.12.4;
Need to provide a consdev to the cons_attach_input call now.
 1.11 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.10 24-Mar-2000  hannken Fix typos from last commit (callout).
 1.9 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.8 20-Mar-2000  pk Call rcons_ttyinit() on first open.
 1.7 19-Mar-2000  pk Revise console device handling:
* do not require a `zs' driver for console handling
* run the console on PROM primitives until a device recognises
itself as a console device during normal autoconfiguration.
* allow (keyboard) devices to take over the input channel of
the PROM primitive-based console device.

As a result, consinit() is much simplified and does no longer have
to "detect" devices to setup a working console device. This complexity
has moved to individual drivers which interpret the PROM information
after they have attached to decide whether or not to act as a console.
 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 14-Feb-1999  pk Use the PROMLIB interface.
 1.3 08-Jan-1998  mrg don't call fb_unblank if NFB < 0
 1.2 03-Dec-1997  mjacob handle case of no keyboard configured
 1.1 18-Oct-1997  gwr Use common zs code.
 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.12.4.1 05-Jul-2000  thorpej Pull up rev. 1.13 (pk):
Pass correct argument to the console channel close routine.
 1.16.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.19.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.19.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.19.4.2 10-Oct-2001  fvdl Convert all remaining devices.
 1.19.4.1 01-Oct-2001  fvdl Catch up with -current.
 1.19.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.19.2.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.19.2.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.20.4.4 11-Nov-2002  nathanw Catch up to -current
 1.20.4.3 17-Sep-2002  nathanw Catch up to -current.
 1.20.4.2 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.20.4.1 26-Sep-2001  nathanw file kd.c was added on branch nathanw_sa on 2002-04-01 07:42:42 +0000
 1.21.4.1 19-May-2002  gehenna Add device switch.
Replace the access to devsw table and the hard-coded majors with devsw API.
 1.25.2.6 11-Dec-2005  christos Sync with head.
 1.25.2.5 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.25.2.4 04-Feb-2005  skrll Adapt to branch.
 1.25.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.25.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.25.2.1 03-Aug-2004  skrll Sync with HEAD
 1.34.2.6 07-Dec-2007  yamt sync with head
 1.34.2.5 27-Oct-2007  yamt sync with head.
 1.34.2.4 03-Sep-2007  yamt sync with head.
 1.34.2.3 26-Feb-2007  yamt sync with head.
 1.34.2.2 30-Dec-2006  yamt sync with head.
 1.34.2.1 21-Jun-2006  yamt sync with head.
 1.35.6.1 22-Nov-2005  yamt sync with head.
 1.38.12.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.38.10.3 13-May-2006  elad sprinkle some #include <sys/kauth.h> in files that use kauth kpi but
don't include it yet. hopefully this will prevent some fallout.
 1.38.10.2 10-Mar-2006  elad generic_authorize() -> kauth_authorize_generic().
 1.38.10.1 08-Mar-2006  elad Adapt to kernel authorization KPI.

I expect *some* lossage here...
 1.38.8.2 11-Aug-2006  yamt sync with head
 1.38.8.1 24-May-2006  yamt sync with head.
 1.38.6.1 01-Jun-2006  kardel Sync with head.
 1.38.4.1 09-Sep-2006  rpaulo 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.42.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.43.10.1 03-Oct-2007  garbled Sync with HEAD
 1.43.4.1 11-Jul-2007  mjf Sync with head.
 1.43.2.3 03-Dec-2007  ad Sync with HEAD.
 1.43.2.2 23-Oct-2007  ad Sync with head.
 1.43.2.1 15-Jul-2007  ad Sync with head.
 1.44.14.2 21-Nov-2007  bouyer Sync with HEAD
 1.44.14.1 25-Oct-2007  bouyer Sync with HEAD.
 1.44.10.2 09-Jan-2008  matt sync with HEAD
 1.44.10.1 06-Nov-2007  matt sync with HEAD
 1.44.8.2 21-Nov-2007  joerg Sync with HEAD.
 1.44.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.46.2.1 08-Dec-2007  mjf Sync with HEAD.
 1.47.18.1 16-May-2008  yamt sync with head.
 1.47.16.1 18-May-2008  yamt sync with head.
 1.47.14.1 02-Jun-2008  mjf Sync with HEAD.
 1.48.28.1 06-Jun-2011  jruoho Sync with HEAD.
 1.48.22.1 31-May-2011  rmind sync with head
 1.49.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.49.4.1 30-Oct-2012  yamt sync with head
 1.50.2.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.50.2.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.51.2.1 18-May-2014  rmind sync with head
 1.53.2.1 10-Aug-2014  tls Rebase.
 1.8 27-Jul-1998  mrg these have moved to sys/dev/sbus.
 1.7 24-Jul-1998  pk Remove conditionals on SUN4C+SUN4M.
A few cosmetic changes.
 1.6 07-Apr-1998  pk The bus space functions now take care of "pass-through" methods.
 1.5 21-Mar-1998  pk Switch to a bus_space(9)-based device attachment scheme.
The dma & lebuffer devices behave like busses to accommodate the
OBP layout. For practical purposes, they are implemented as
Sbus "extensions".
 1.4 12-Jan-1998  thorpej Update for changes to config.
 1.3 24-May-1997  pk Remove all `bustype' arguments from map[io]dev() and REG2PHYS().
 1.2 23-Mar-1997  pk Clamp burst sizes to maximum value of parent.
Reset ledma from leattach().
 1.1 06-Dec-1996  pk Special Lance buffer glue.
 1.4 27-Jul-1998  mrg these have moved to sys/dev/sbus.
 1.3 21-Mar-1998  pk Switch to a bus_space(9)-based device attachment scheme.
The dma & lebuffer devices behave like busses to accommodate the
OBP layout. For practical purposes, they are implemented as
Sbus "extensions".
 1.2 10-Mar-1997  pk Add a field indicating this instance has attached to an `le', so we
can have a go at matching le's and lebuffer's on machines where the
PROM does not provide a parent/child relationship.
 1.1 06-Dec-1996  pk branches: 1.1.6;
Special Lance buffer glue.
 1.1.6.1 12-Mar-1997  is Merge in changes from The Trunk
 1.4 28-Jul-1998  pk Magma driver has been moved to <dev/sbus>.
 1.3 03-Jun-1998  pk Update from Iain on the parallel port stuff.
 1.2 20-May-1998  pk Do not assume that a parallel component is always configured.
Squash compiler warnings if MAGMA_DEBUG is on.
 1.1 19-May-1998  pk Magma SBus serial & parallel port driver from Iain Hibbert.
 1.3 28-Jul-1998  pk Magma driver has been moved to <dev/sbus>.
 1.2 07-Jun-1998  pk Update from Iain for the parallel port stuff.
 1.1 19-May-1998  pk Magma SBus serial & parallel port driver from Iain Hibbert.
 1.11 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.10 20-Oct-2000  pk branches: 1.10.4; 1.10.8;
Add new-line to md attach message.
 1.9 17-Mar-1999  sommerfe branches: 1.9.8;
defopt MINIROOTSIZE
 1.8 06-Jun-1998  mrg sync with other md_root.c files.
 1.7 05-Jun-1998  mrg make this work with new md root stuff.
 1.6 09-Oct-1997  jtc Fix tipo inherited from old version of TNF copyright template.
 1.5 28-Dec-1996  pk branches: 1.5.10;
rename: ramdisk => md
 1.4 09-Dec-1996  thorpej Copyright assigned to The NetBSD Foundation.
 1.3 13-Oct-1996  christos backout previous kprintf change
 1.2 11-Oct-1996  christos printf -> kprintf, sprintf -> ksprintf
 1.1 20-Jun-1996  pk memory disk driver hooks to pass on the root filesystem bits.
Note: this file is called `md_root.c' in anticipation of the forthcoming
`rd' => `md' rename.
 1.5.10.1 14-Oct-1997  thorpej Update marc-pcmcia branch from trunk.
 1.9.8.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.10.8.1 28-Feb-2002  nathanw Catch up to -current.
 1.10.4.1 11-Feb-2002  jdolecek Sync w/ -current.
 1.11 18-Oct-1997  gwr Use common zs code.
 1.10 12-Sep-1996  mrg update these for poll(2) changes.
 1.9 30-May-1996  pk event_var.h changed location.
 1.8 01-Apr-1996  christos Eliminated dependencies on dev_conf.h
 1.7 14-Mar-1996  christos Bring prototypes into scope and fix compiler warnings.
 1.6 25-Feb-1996  pk Use CPU-type macros
 1.5 29-Aug-1995  pk Sun4s must set baud rate on the mouse port (from Jason Thorpe).
 1.4 20-Nov-1994  deraadt copyright/Id cleanup
 1.3 02-Nov-1994  deraadt ioctl u_long cmd
 1.2 21-Jul-1994  deraadt make X11R5 compile easier
 1.1 02-Oct-1993  deraadt branches: 1.1.2;
Chris Torek's sparc port. Missing lots of things.
 1.1.2.1 22-Jul-1994  cgd from trunk.
 1.2 13-Mar-2004  bjh21 Abstract the interface between pckbc(4), and the pckbd(4) and pms(4)
drivers that attach to it. This allows for other host interface chips
that use the same keyboards and mice, such as the ones in the ARM
IOMD20, ARM7500, and SA-1111. The PC-compatible driver is still
called pckbc(4), and the new abstraction layer is "pckbport", so the
child devices have moved from sys/dev/pckbc to sys/dev/pckbport, which
also contains some code shared between all host controllers. To avoid
incompatibility, pckbdreg.h is still installed in
/usr/include/dev/pckbc.

In theory, this shouldn't cause any behavioural changes in the drivers
concerned. Thy just use rather more function pointers than before. Tested
on i386 and (with a new host driver) acorn32. Compiled on several other
affected architectures.
 1.1 03-Oct-2002  uwe branches: 1.1.2; 1.1.8;
First cut at PS/2 keyboard and mouse drivers that talk Sun firm events.
Console and Xsun for Mr.Coffee.
 1.1.8.1 03-Aug-2004  skrll Sync with HEAD
 1.1.2.2 18-Oct-2002  nathanw Catch up to -current.
 1.1.2.1 03-Oct-2002  nathanw file ms_pckbc.c was added on branch nathanw_sa on 2002-10-18 02:39:54 +0000
 1.9 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.8 08-Sep-2011  jakllsch branches: 1.8.2; 1.8.12;
Another copy/paste problem with a function name in a error printf.
 1.7 08-Sep-2011  jakllsch Correct copy/paste of function name in error printf.
 1.6 01-Jul-2011  dyoung #include <sys/bus.h> instead of <machine/bus.h>.
 1.5 17-Jan-2009  he Use firm_gettime() to retain compatibility with old firm_event. From amiga.
 1.4 07-Apr-2008  tsutsui branches: 1.4.4; 1.4.12;
Split device_t/softc, as following parents in sys/dev/sun.
 1.3 07-Jun-2006  kardel branches: 1.3.60;
convert to timecounters (from branch simonb-timecounters)
 1.2 16-Nov-2005  uwe branches: 1.2.4; 1.2.6; 1.2.8; 1.2.14;
ANSIify. Use uint<N>_t. Drop unnecessary includes.
Drop trailing whitespace.
 1.1 13-Mar-2004  bjh21 branches: 1.1.4; 1.1.18; 1.1.26;
Abstract the interface between pckbc(4), and the pckbd(4) and pms(4)
drivers that attach to it. This allows for other host interface chips
that use the same keyboards and mice, such as the ones in the ARM
IOMD20, ARM7500, and SA-1111. The PC-compatible driver is still
called pckbc(4), and the new abstraction layer is "pckbport", so the
child devices have moved from sys/dev/pckbc to sys/dev/pckbport, which
also contains some code shared between all host controllers. To avoid
incompatibility, pckbdreg.h is still installed in
/usr/include/dev/pckbc.

In theory, this shouldn't cause any behavioural changes in the drivers
concerned. Thy just use rather more function pointers than before. Tested
on i386 and (with a new host driver) acorn32. Compiled on several other
affected architectures.
 1.1.26.1 22-Nov-2005  yamt sync with head.
 1.1.18.1 21-Jun-2006  yamt sync with head.
 1.1.4.5 11-Dec-2005  christos Sync with head.
 1.1.4.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.1.4.3 18-Sep-2004  skrll Sync with HEAD.
 1.1.4.2 03-Aug-2004  skrll Sync with HEAD
 1.1.4.1 13-Mar-2004  skrll file ms_pckbport.c was added on branch ktrace-lwp on 2004-08-03 10:40:45 +0000
 1.2.14.1 19-Jun-2006  chap Sync with head.
 1.2.8.1 26-Jun-2006  yamt sync with head.
 1.2.6.1 27-May-2006  kardel convert to timecounters
 1.2.4.1 09-Sep-2006  rpaulo sync with head
 1.3.60.1 02-Jun-2008  mjf Sync with HEAD.
 1.4.12.1 19-Jan-2009  skrll Sync with HEAD.
 1.4.4.1 04-May-2009  yamt sync with head.
 1.8.12.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.8.2.1 30-Oct-2012  yamt sync with head
 1.77 20-Dec-2023  thorpej Remove unnecessary <sys/malloc.h>.
 1.76 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.75 24-Apr-2021  thorpej branches: 1.75.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.74 24-Mar-2013  jdc branches: 1.74.50;
Check if sbus is defined in the kernel configuration before using it.
From Taylor R Campbell.
 1.73 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.72 01-Jul-2011  dyoung branches: 1.72.2; 1.72.12;
#include <sys/bus.h> instead of <machine/bus.h>.
 1.71 17-May-2008  macallan more device_t-ification
 1.70 28-Apr-2008  martin branches: 1.70.2;
Remove clause 3 and 4 from TNF licenses
 1.69 16-Nov-2005  uwe branches: 1.69.74; 1.69.76; 1.69.78;
ANSIify function declarations/defintions. Use uint<N>_t.
Propagate "static" to function definitions. Drop trailing whitespace.
Same binary code is produced for GENERIC.MP + KGDB + DDB.
 1.68 26-Aug-2005  drochner branches: 1.68.6;
s/locdesc_t/int/g
 1.67 30-Jun-2005  drochner branches: 1.67.2;
adaptions to config_search() change, and minor autoconf fixes, mostly from Havard Eidnes
 1.66 14-Dec-2004  chs use the generated macros in locators.h rather than hard-coded numbers
to index the cf_loc[] array. reviewed by allen briggs.
 1.65 27-Jun-2004  pk Always use `full bus space'. In order to implement this more efficiently,
require that all bus tags have pointers to bus_space_read/write functions,
i.e. no run-time hunting for the first "upstream" implementation.
Since this changes the way bus tags should be constructed it makes sense
to do the same thing for the rest of the bus space methods.
So, now bus space tags are generally constructed by copying the parent's bus
tag and then overriding the methods that the bus driver needs to handle,
instead of starting with an empty bus tag and fiiling in only the fields needed.
 1.64 15-Jul-2003  lukem __KERNEL_RCSID()
 1.63 03-May-2003  wiz branches: 1.63.2;
DMA, not dma nor Dma.
 1.62 30-Apr-2003  martin Make this compile with __FULL_SPARC_BUS_SPACE,
from Steve Rumble in PR 21398.
 1.61 02-Apr-2003  thorpej Use PAGE_SIZE rather than NBPG.
 1.60 03-Jan-2003  mrg part one of bus_space(9) fixes to enable bus spaces to override the
bus_space_{read,write}_[1248]() functions, which will allow 16-bit
PCMCIA support to work without additional hacks in MI drivers.
this option is not enabled yet.
 1.59 01-Jan-2003  thorpej Use aprint_normal() for cfprint routines.
 1.58 02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.57 01-Oct-2002  thorpej Use CFATTACH_DECL().
 1.56 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.55 27-Sep-2002  thorpej Introduce a new routine, config_match(), which invokes the
cfattach->ca_match function in behalf of the caller. Use it
rather than invoking cfattach->ca_match directly.
 1.54 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.53 25-Aug-2002  thorpej Put a bus's ranges in the bus space tag, and make sparc_bus_map()
perform the translation and recursion if t->ranges != NULL. Make
sbus, cpuunit, and bootbus inherit the parent's map/mmap routines,
and delete the now-unused mapping functions. Update all places where
bus space tags are statically allocated.
 1.52 11-Apr-2002  pk branches: 1.52.2;
Pass fully encoded bus addresses in the attach arguments.
 1.51 11-Mar-2002  pk * `bus_type_t' is gone.
* Use BUS_ADDR() where appropriate to encode I/O space and physical
address offset into a `bus_addr_t' value.
* Drop obio_bus_map() since it's now completely equivalent to bus_space_map()
* Use bus_space_map2() to map device space at a fixed virtual address.
* Remove the virtual address argument from sbus_sbus_addr()
 1.50 24-Sep-2001  eeh branches: 1.50.4;
Change bus_space_mmap() signature to the official one.
 1.49 25-Jul-2000  pk branches: 1.49.2; 1.49.4;
Add `dma' to the `early device' list, since we need it before an `esp'
is configured. Traced and tested by Julian Coleman.
 1.48 29-Jun-2000  mrg remove include of <vm/vm.h> and <machine/pmap.h>. <vm/vm.h> -> <uvm/uvm_extern.h>
 1.47 11-Jan-2000  pk branches: 1.47.4;
Remove old-style boot device recognition.
 1.46 28-Jun-1999  pk branches: 1.46.2;
More ugly code to force early configuration of the sun4 on-board timer.
 1.45 05-Sep-1998  eeh branches: 1.45.8;
Remove function naming conflict.
 1.44 21-Aug-1998  pk Convert to [pv]addr_t.
 1.43 07-Apr-1998  pk The bus space functions now take care of "pass-through" methods.
 1.42 29-Mar-1998  pk Implement `_obio_bus_map()' and insert it into the obio bus' bus tag.
Remove obio_bus_probe().
 1.41 23-Mar-1998  pk Only print interesting interrupt levels.
 1.40 21-Mar-1998  pk Switch to a bus_space(9)-based device attachment scheme.

- device attachment arguments contain bus-specific
address and interrupt levels.

- devices must call back on bus map functions to get their
addresses and interrupt levels translated properly.

- sun4m's obio bus is treated like an Sbus slot.

- the sun4-style obio bus has its own attach arguments
and map functions.
 1.39 25-Jan-1998  pk All VME stuff is gone from here.
 1.38 12-Jan-1998  thorpej Update for changes to config.
 1.37 29-Jul-1997  fair %x -> 0x%x
 1.36 10-Jun-1997  pk vme_establishintr: remove SUN4 arch check; this now works on sun4m as well.
 1.35 07-Jun-1997  pk Use the `ranges' property to deal with VMEbus address spaces.
 1.34 24-May-1997  pk Use `rr_iospace' to track the MMU page type bits. On sun4c/sun4m the
iospace value is always learned from the PROM; on sun4, we infer it
from the BUS_* parameters.

This obsoletes the `bustype' argument in bus_tmp().
 1.33 18-May-1997  pk Remove bus_tmp(); it's just a special case of mapdev().
 1.32 18-May-1997  pk A bit of framework for sun4m VME busses.
 1.31 08-Apr-1997  pk Move "range" property description out of generic `romaux'.
Allocate room for this property when needed in bus attachment.
 1.30 10-Mar-1997  pk Replace `cpumod' with `cpuinfo.cpu_type' equivalents.
 1.29 10-Dec-1996  pk branches: 1.29.6;
Not all sun4m's have an `auxio'.
 1.28 10-Dec-1996  pk Comply with recent autoconfiguration changes. Diffs graciously
supplied by Chris Demetriou.
 1.27 13-Oct-1996  christos backout previous kprintf change
 1.26 11-Oct-1996  christos printf -> kprintf, sprintf -> ksprintf
 1.25 27-Aug-1996  cgd change cfprint_t type definition to take a const char *, rather than
a char *, because that's what was really intended, and because
if the print function modifies the string, various things could become
unhappy (so the string should _not_ be modified).
 1.24 18-May-1996  mrg don't set tmp twice.
 1.23 05-Apr-1996  chuck make netbsd/sparc boot on sun4 once again. the sun4m changes introduced
config lines for obio0 devices without addresses (thus cf->cf_loc[0] took
the default value of -1). we now ignore these entries on a sun4 since
they could never be valid (eliminates a 'panic:alignment' fault at bootup).
 1.22 31-Mar-1996  pk Handle sun4m `obio' devices.
Cleanup `#if defined(SUN4*)' mess.
 1.21 17-Mar-1996  thorpej New device attachment scheme:

- split softc size and match/attach out from cfdriver into
a new struct cfattach.

- new "attach" directive for files.*. May specify the name of
the cfattach structure, so that devices may be easily attached
to parents with different autoconfiguration semantics.
 1.20 14-Mar-1996  christos Bring prototypes into scope and fix compiler warnings.
 1.19 12-Jan-1996  chuck improved handling of mapping of devices who's registers do not reside on
page boundaries:
- change bus_tmp() to include the offset from the start of page in the
returned KVA [rather than forcing each driver to add it back in
individually]
- changed bus_map() to include the offset from the start of page in the
the returned value if a mapping is found in the PROM's KVA area
- clarified a few comments
 1.18 11-Jan-1996  pk Correct page frame calculation after mapdev() interface change.
 1.17 11-Dec-1995  pk Adapt to changed mapiodev() interface.
 1.16 18-Aug-1995  pk Use actual bus names (matches Chuck's bootpath code).
 1.15 27-May-1995  pk Propagate bootpaths
 1.14 25-Apr-1995  pk Remove duplication of code from subr_autoconf.c
 1.13 10-Apr-1995  mycroft kernel_pmap --> pmap_kernel()
 1.12 01-Mar-1995  pk Better 4/100 support.
 1.11 01-Feb-1995  pk Integrate changes from Chuck Cranor for the Sun 4/100.
Support for multiple register banks on SBUS devices (based on patches
from Francis Dupont).
Highlights:
romaux defines an array of register spaces.
pay attention to `vactype'.
quirks handling 4/100 idiosyncracies.
 1.10 25-Nov-1994  deraadt wzero/wcopy moved to machdep.c
 1.9 23-Nov-1994  deraadt XXmatch change (and a few __P() as well)
 1.8 05-Nov-1994  deraadt only print the vec if needed
 1.7 02-Nov-1994  deraadt let busmatch print the level/vec
 1.6 02-Nov-1994  deraadt add wcopy/wzero, and ack VME using ldcontrob
 1.5 26-Oct-1994  deraadt working vme16/32 support
 1.4 15-Oct-1994  deraadt mapiodev takes a bustype argument now
 1.3 02-Oct-1994  deraadt sun4/300 support works
 1.2 17-Sep-1994  deraadt obio bus driver, for dealing with devices on the sun4 motherboard.
 1.1 24-Aug-1994  deraadt first cut at sun4 on-board io bus
 1.29.6.1 12-Mar-1997  is Merge in changes from The Trunk
 1.45.8.1 01-Jul-1999  thorpej Sync w/ -current.
 1.46.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.47.4.1 26-Jul-2000  pk Pull up revision 1.49 from trunk:

Add `dma' to the `early device' list, since we need it before an `esp'
is configured. Traced and tested by Julian Coleman.
 1.49.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.49.4.4 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.49.4.3 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.49.4.2 16-Mar-2002  jdolecek Catch up with -current.
 1.49.4.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.49.2.1 01-Oct-2001  fvdl Catch up with -current.
 1.50.4.7 03-Jan-2003  thorpej Sync with HEAD (again).
 1.50.4.6 03-Jan-2003  thorpej Sync with HEAD.

XXX ALT_SWITCH_CODE is not yet LWP'ified.
 1.50.4.5 18-Oct-2002  nathanw Catch up to -current.
 1.50.4.4 27-Aug-2002  nathanw Catch up to -current.
 1.50.4.3 17-Apr-2002  nathanw Catch up to -current.
 1.50.4.2 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.50.4.1 24-Sep-2001  nathanw file obio.c was added on branch nathanw_sa on 2002-04-01 07:42:42 +0000
 1.52.2.1 31-Aug-2002  gehenna catch up with -current.
 1.63.2.6 11-Dec-2005  christos Sync with head.
 1.63.2.5 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.63.2.4 18-Dec-2004  skrll Sync with HEAD.
 1.63.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.63.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.63.2.1 03-Aug-2004  skrll Sync with HEAD
 1.67.2.1 21-Jun-2006  yamt sync with head.
 1.68.6.1 22-Nov-2005  yamt sync with head.
 1.69.78.2 04-May-2009  yamt sync with head.
 1.69.78.1 16-May-2008  yamt sync with head.
 1.69.76.1 18-May-2008  yamt sync with head.
 1.69.74.1 02-Jun-2008  mjf Sync with HEAD.
 1.70.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.72.12.2 23-Jun-2013  tls resync from head
 1.72.12.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.72.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.72.2.1 30-Oct-2012  yamt sync with head
 1.74.50.6 05-Apr-2021  thorpej Treat config_probe() as if it were a boolean function; don't compare
return value > 0... except for the odd balls, which are now really easy
to spot.
 1.74.50.5 05-Apr-2021  thorpej config_match() -> config_probe() for the straight-forward indirect config
cases. There are still a few odd balls using config_match() which should
be sorted out later.
 1.74.50.4 04-Apr-2021  thorpej CFARG_SUBMATCH -> CFARG_SEARCH for the indirect configuration uses.
 1.74.50.3 03-Apr-2021  thorpej Give config_attach() the tagged variadic argument treatment and
mechanically convert all call sites.
 1.74.50.2 21-Mar-2021  thorpej CFARG_IATTR usage audit:

If a device carries only one interface attribute, there is no need
to specify it when calling config_search(); that specification is
meant only to disambiguate which interface attribute (which is a
proxy for "what kind of attach args are being used") is having
children attached. cfparent_match() will take care of ensuring that
any potential children can attach to one of the parent's iterface
attributes, and if the parent only carries one, no disambiguation is
necessary.
 1.74.50.1 20-Mar-2021  thorpej The proliferation if config_search_*() and config_found_*() combinations
is a little absurd, so begin to tidy this up:

- Introduce a new cfarg_t enumerated type, that defines the types of
tag-value variadic arguments that can be passed to the various
config_*() functions (CFARG_SUBMATCH, CFARG_IATTR, and CFARG_LOCATORS,
for now, plus a CFARG_EOL sentinel).
- Collapse config_search_*() into config_search() that takes these
variadic arguments.
- Convert all call sites of config_search_*() to the new signature.
Noticed several incorrect usages along the way, which will be
audited in a future commit.
 1.75.8.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.14 22-Aug-2000  pk Use the framebuffer drivers & header files that now live in /sys/dev/sun.
 1.13 09-Jul-2000  pk Re-arrange headers; drop <machine/cpu.h>.
 1.12 29-Jun-2000  mrg remove include of <vm/vm.h> and <machine/pmap.h>. <vm/vm.h> -> <uvm/uvm_extern.h>
 1.11 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.10 04-Apr-2000  pk branches: 1.10.4;
Use copyin/copyout to get a colormap from/to user space.
Also, prepare for the case of a colormap maintained in kernel space.
 1.9 19-Mar-2000  pk Use fb_is_console(); retract fbconstty & fbnode from service.
 1.8 15-Dec-1999  garbled add <machine/tctrl.h> where needed.
Add some undocumented commands to the ts102 registers file, and fix a few
typos.

Modifications to tctrl.c:

Add entrypoints to driver for open/close/ioctl/poll.
Make device work with apmd. (still no support for suspend/sleep)
Make device work with ENVSYS API.
Slightly restructure handling of events.
Add function to make microcontroller requests.
 1.7 12-Nov-1999  matt make this compile under current
 1.6 26-Aug-1999  thorpej branches: 1.6.2; 1.6.4; 1.6.8;
Initialize the default colormap to 0 == black, all others == full white.
 1.5 11-Aug-1999  matt do a little colormap manipulation. use the tft power hooks in tctrl
 1.4 02-Aug-1999  matt Add video blanking support. It does not power-down the TFT
since that requires talking to the H8 microcontroller and
that support is not yet done.
 1.3 02-Aug-1999  matt branches: 1.3.2;
Colormaps now work. Besides a small fencepost error, the real problem
is that the Tadpole 3GX tech-ref-man was WRONG. The RAMDAC registers
at at 4 byte offsets, not 8. Once that was discovered, all the code
just worked.
 1.2 01-Aug-1999  matt fix a few mmap bugs. pretend to be a cg3 and implement a hack
to fack the Xsun server to believe that the p9100's framebuffer
is really a cg3's. So if only colormaps worked, X would be able
to run.
 1.1 01-Aug-1999  matt Initial stab at a P9100 console FB driver for the Tadpole 3GX.
It supports RASTERCONSOLE only and the colormap support is
broken (the hardware doesn't seem to be doing what the tech.
docs. say it should be doing). But it is usable as a console
(but with blue on white as the only color choice). I figured
I'd check it in since it is somewhat usable and someone else
might figure what I screwed up in the color map support.
 1.3.2.2 02-Aug-1999  thorpej Update from trunk.
 1.3.2.1 02-Aug-1999  thorpej file p9100.c was added on branch chs-ubc2 on 1999-08-02 20:09:13 +0000
 1.6.8.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.6.4.1 15-Nov-1999  fvdl Sync with -current
 1.6.2.1 20-Nov-2000  bouyer Remove files that are no longer on the trunck
 1.10.4.2 22-Dec-2001  he Apply patch (requested by cyber):
The PROM does not set up the frame buffer if it is not the console.
We should not try to configure it in that case. This makes serial
console work on the SPARCbook, and fixes PR#14213.
Patch comes from revision 1.7 of sys/dev/sbus/p9100.c.
 1.10.4.1 30-Jun-2000  simonb Pull up mmap paddr_t/off_t changes from trunk.
 1.21 04-Dec-2021  andvar s/establised/established/ in struct variable name. Also fixed typos in comments.
 1.20 22-Nov-2020  thorpej malloc(9) -> kmem(9) (easy, straight-forward cases only, for now)
 1.19 13-Oct-2012  jdc branches: 1.19.50;
Adapt to the changed signature of pckbc_cnattach().
 1.18 18-Mar-2008  dogcow branches: 1.18.38; 1.18.48;
pesky missing spaces.
 1.17 15-Mar-2008  cube Split device_t and softc for pckbc(4) and its attachments.
 1.16 03-Dec-2007  ad branches: 1.16.10; 1.16.14;
Interrupt handling changes, in discussion since February:

- Reduce available SPL levels for hardware devices to none, vm, sched, high.
- Acquire kernel_lock only for interrupts at IPL_VM.
- Implement threaded soft interrupts.
 1.15 17-Oct-2007  garbled branches: 1.15.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.14 09-Jul-2007  ad branches: 1.14.8; 1.14.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.13 16-Nov-2005  uwe branches: 1.13.30; 1.13.32; 1.13.38;
ANSIify. Use uint<N>_t. Drop unnecessary includes.
Drop trailing whitespace.
 1.12 17-Mar-2004  martin branches: 1.12.16; 1.12.24;
Adapt to pckbc -> pckbport changes
 1.11 13-Mar-2004  bjh21 Abstract the interface between pckbc(4), and the pckbd(4) and pms(4)
drivers that attach to it. This allows for other host interface chips
that use the same keyboards and mice, such as the ones in the ARM
IOMD20, ARM7500, and SA-1111. The PC-compatible driver is still
called pckbc(4), and the new abstraction layer is "pckbport", so the
child devices have moved from sys/dev/pckbc to sys/dev/pckbport, which
also contains some code shared between all host controllers. To avoid
incompatibility, pckbdreg.h is still installed in
/usr/include/dev/pckbc.

In theory, this shouldn't cause any behavioural changes in the drivers
concerned. Thy just use rather more function pointers than before. Tested
on i386 and (with a new host driver) acorn32. Compiled on several other
affected architectures.
 1.10 10-Feb-2004  bjh21 __HAVE_NWSCONS seems to mean, "If this port uses pckbc(4), it also uses
sys/dev/pckbc/files.pckbc." This is true of sparc, so define __HAVE_NWSCONS,
and remove the code in pckbc_machdep_cnattach() that was conditional on its
not being defined and that is no longer needed (since with __HAVE_NWSCONS,
pckbc_cnattach() will call pckbd_cnattach() itself if necessary).
 1.9 12-Dec-2003  martin Use the new split hard/softinterrupt handlers to avoid running mouse/keyboard
input functions to be run at IPL_SERIAL (instead of the intended IPL_TTY).
 1.8 15-Jul-2003  lukem __KERNEL_RCSID()
 1.7 10-Dec-2002  pk branches: 1.7.6;
Remove the `flags' argument from bus_intr_establish().
 1.6 03-Oct-2002  uwe Search children of the "8042" node to check if keyboard is the stdin.
 1.5 02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.4 01-Oct-2002  thorpej Use CFATTACH_DECL().
 1.3 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.2 18-Feb-2002  uwe branches: 1.2.2;
Switch to shared EBus headers in dev/ebus.
 1.1 31-Jan-2002  uwe branches: 1.1.2;
Driver for pckbc in javastations. Not finished yet.
 1.1.2.4 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.1.2.3 16-Mar-2002  jdolecek Catch up with -current.
 1.1.2.2 11-Feb-2002  jdolecek Sync w/ -current.
 1.1.2.1 31-Jan-2002  jdolecek file pckbc_js.c was added on branch kqueue on 2002-02-11 20:09:03 +0000
 1.2.2.4 11-Dec-2002  thorpej Sync with HEAD.
 1.2.2.3 18-Oct-2002  nathanw Catch up to -current.
 1.2.2.2 28-Feb-2002  nathanw Catch up to -current.
 1.2.2.1 18-Feb-2002  nathanw file pckbc_js.c was added on branch nathanw_sa on 2002-02-28 04:12:02 +0000
 1.7.6.4 11-Dec-2005  christos Sync with head.
 1.7.6.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.7.6.2 18-Sep-2004  skrll Sync with HEAD.
 1.7.6.1 03-Aug-2004  skrll Sync with HEAD
 1.12.24.1 22-Nov-2005  yamt sync with head.
 1.12.16.5 24-Mar-2008  yamt sync with head.
 1.12.16.4 17-Mar-2008  yamt sync with head.
 1.12.16.3 07-Dec-2007  yamt sync with head
 1.12.16.2 03-Sep-2007  yamt sync with head.
 1.12.16.1 21-Jun-2006  yamt sync with head.
 1.13.38.1 03-Oct-2007  garbled Sync with HEAD
 1.13.32.1 11-Jul-2007  mjf Sync with head.
 1.13.30.2 03-Dec-2007  ad Sync with HEAD.
 1.13.30.1 01-Jul-2007  ad Adapt to callout API change.
 1.14.10.3 23-Mar-2008  matt sync with HEAD
 1.14.10.2 09-Jan-2008  matt sync with HEAD
 1.14.10.1 06-Nov-2007  matt sync with HEAD
 1.14.8.1 09-Dec-2007  jmcneill Sync with HEAD.
 1.15.2.1 08-Dec-2007  mjf Sync with HEAD.
 1.16.14.1 03-Apr-2008  mjf Sync with HEAD.
 1.16.10.1 24-Mar-2008  keiichi sync with head.
 1.18.48.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.18.38.1 30-Oct-2012  yamt sync with head
 1.19.50.1 14-Dec-2020  thorpej Sync w/ HEAD.
 1.3 22-Aug-2000  pk Use the framebuffer drivers & header files that now live in /sys/dev/sun.
 1.2 05-Oct-1997  thorpej branches: 1.2.16;
Copyright assigned to The NetBSD Foundation.
 1.1 27-Feb-1996  thorpej branches: 1.1.12;
First-cut support for P4 framebuffers. Currently supports P4 variants
of bwtwo, cgfour, cgsix, and cgeight. Includes support for attaching
the overlay plane of the cgfour and cgeight as a bwtwo instance (a'la
SunOS).

P4 register descriptions, cgfour driver, and cgeight driver partially
derived from OpenBSD.

This code may still need polishing.
 1.1.12.1 14-Oct-1997  thorpej Update marc-pcmcia branch from trunk.
 1.2.16.1 20-Nov-2000  bouyer Remove files that are no longer on the trunck
 1.19 29-Jul-2012  matt Fix more -fno-common fallout.
 1.18 17-Jul-2011  mrg branches: 1.18.2;
convert all the sparc drivers that attach on my ss20 to use device_t,
cfdata_t and CFATTACH_DECL_NEW().

fd/fdc could use better testing, but i'm pretty sure i got it right.
 1.17 16-Nov-2005  uwe ANSIify function declarations/defintions. Use uint<N>_t.
Propagate "static" to function definitions. Drop trailing whitespace.
Same binary code is produced for GENERIC.MP + KGDB + DDB.
 1.16 15-Jul-2003  lukem branches: 1.16.16; 1.16.24;
__KERNEL_RCSID()
 1.15 02-Oct-2002  thorpej branches: 1.15.6;
Add trailing ; to CFATTACH_DECL.
 1.14 01-Oct-2002  thorpej Use CFATTACH_DECL().
 1.13 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.12 11-Mar-2002  pk * `bus_type_t' is gone.
* Use BUS_ADDR() where appropriate to encode I/O space and physical
address offset into a `bus_addr_t' value.
* Drop obio_bus_map() since it's now completely equivalent to bus_space_map()
* Use bus_space_map2() to map device space at a fixed virtual address.
* Remove the virtual address argument from sbus_sbus_addr()
 1.11 28-Apr-1999  fair branches: 1.11.16; 1.11.20;
Add a 1 second delay to powerdown sequence to prevent the OpenBoot PROMs
from getting control and reporting a "powerdown failure", per PR#7487
 1.10 06-Jun-1998  thorpej branches: 1.10.8;
Only attempt the powerdown if the power register was mapped.
 1.9 21-Mar-1998  pk Account for changed bus attachment scheme.
 1.8 12-Jan-1998  thorpej Update for changes to config.
 1.7 24-May-1997  pk Remove all `bustype' arguments from map[io]dev() and REG2PHYS().
 1.6 10-Dec-1996  pk Comply with recent autoconfiguration changes. Diffs graciously
supplied by Chris Demetriou.
 1.5 13-Oct-1996  christos backout previous kprintf change
 1.4 11-Oct-1996  christos printf -> kprintf, sprintf -> ksprintf
 1.3 07-Jun-1996  thorpej Squish a couple of rogue $Id's..
 1.2 16-May-1996  abrown Copyright police (s/Harvard University/Harvard College/).
 1.1 31-Mar-1996  pk Diddling of the `power' bit in machine control register (Aaron).
 1.10.8.1 28-Apr-1999  perry branches: 1.10.8.1.2;
pullup 1.10->1.11 (fair)
 1.10.8.1.2.1 21-Jun-1999  thorpej Sync w/ -current.
 1.11.20.2 18-Oct-2002  nathanw Catch up to -current.
 1.11.20.1 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.11.16.2 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.11.16.1 16-Mar-2002  jdolecek Catch up with -current.
 1.15.6.4 11-Dec-2005  christos Sync with head.
 1.15.6.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.15.6.2 18-Sep-2004  skrll Sync with HEAD.
 1.15.6.1 03-Aug-2004  skrll Sync with HEAD
 1.16.24.1 22-Nov-2005  yamt sync with head.
 1.16.16.1 21-Jun-2006  yamt sync with head.
 1.18.2.1 30-Oct-2012  yamt sync with head
 1.6 29-Jul-2012  matt Fix more -fno-common fallout.
 1.5 16-Nov-2005  uwe branches: 1.5.112;
ANSIify function declarations/defintions. Use uint<N>_t.
Propagate "static" to function definitions. Drop trailing whitespace.
Same binary code is produced for GENERIC.MP + KGDB + DDB.
 1.4 21-Mar-1998  pk branches: 1.4.48; 1.4.64; 1.4.72;
Account for changed bus attachment scheme.
 1.3 07-Jun-1996  thorpej Squish a couple of rogue $Id's..
 1.2 16-May-1996  abrown Copyright police (s/Harvard University/Harvard College/).
 1.1 31-Mar-1996  pk Diddling of the `power' bit in machine control register (Aaron).
 1.4.72.1 22-Nov-2005  yamt sync with head.
 1.4.64.1 21-Jun-2006  yamt sync with head.
 1.4.48.1 11-Dec-2005  christos Sync with head.
 1.5.112.1 30-Oct-2012  yamt sync with head
 1.5 13-Apr-1999  ad Fonts for rcons are now handled in sys/dev/wsfont.
 1.4 22-Mar-1998  pk branches: 1.4.10;
Lift the tilde a bit.
 1.3 29-Nov-1995  pk Must change `u_long' to `u_int32_t' as Jason pointed out.
 1.2 08-Oct-1995  pk Fill in `ascent' values correctly.
 1.1 05-Oct-1995  pk Machine dependent RASTERCONSOLE font definition to be passed to rcons_init().
 1.4.10.1 21-Jun-1999  thorpej Sync w/ -current.
 1.23 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.22 07-Sep-2025  thorpej Remove unnecessary NULL-initialization of TODR handle fields.
 1.21 20-Dec-2023  thorpej Remove unnecessary <sys/malloc.h>.
 1.20 02-Jan-2020  thorpej - Use todr_gettime_ymdhms / todr_settime_ymdhms.
- Allocate the todr_handle with the softc, not separately.
 1.19 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.18 18-Jul-2011  mrg branches: 1.18.54;
convert the remaining sparc drivers to CFATTACH_DECL_NEW/cfdata_t/device_t.
(cgsix_obio.c was only partially converted with the rest of the cgsix code
when it was changed some time ago.)
 1.17 01-Jul-2011  dyoung #include <sys/bus.h> instead of <machine/bus.h>.
 1.16 12-Dec-2009  tsutsui Remove `volatile' qualifier from argument types of
struct timeval passed to todr_gettime(9) and todr_settime(9).
We no longer have an ancient and volatile struct timeval `time'
global since we have switched to MI timercounter(9) on all port.

XXX1: some of these RTC drivers still assume 32bit time_t
XXX2: some of these should be rewritten to use todr_[gs]ettime_ymdhms()
XXX3: todr(9) man page doesn't mention todr_[gs]ettime_ymdhms()
 1.15 20-Sep-2009  tsutsui - use device_t and cfdriver_t
- use device_private() and device_xname()
- use proper types or variables for device_t/softc
 1.14 04-Sep-2006  gdamore branches: 1.14.60;
Remove unused todr_setcal/todr_getcal and all the assorted stub
implementations.
 1.13 03-Sep-2006  uwe Catch up with __HAVE_GENERIC_TODR changes.
Compile-tested only.
 1.12 16-Nov-2005  uwe branches: 1.12.4; 1.12.8;
ANSIify. Declare as static everything we don't need to export.
 1.11 05-Jun-2005  jdc branches: 1.11.2; 1.11.8;
Add volatile to make rtc_{g|s}ettime match todr_chip_handle_t.
 1.10 15-Jul-2003  lukem __KERNEL_RCSID()
 1.9 03-Dec-2002  uwe branches: 1.9.6;
The chip treats weekday 1 == Sunday, correct dt_wday adjustment logic
appropriately. NB: the old code would never write weekday zero that,
I've been told, might cause the RTC to reset.
Pointed out by kenh.
 1.8 02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.7 01-Oct-2002  thorpej Use CFATTACH_DECL().
 1.6 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.5 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.4 04-Apr-2002  uwe Fix error message.
 1.3 12-Mar-2002  uwe Drop ebus_bus_map(), use plain bus_space_map() instead.
 1.2 18-Feb-2002  uwe Switch to shared EBus headers in dev/ebus.
 1.1 11-Dec-2001  uwe branches: 1.1.2; 1.1.4;
rtc (ds1287a) time of day clock at ebus.
 1.1.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.1.4.4 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.1.4.3 16-Mar-2002  jdolecek Catch up with -current.
 1.1.4.2 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.1.4.1 11-Dec-2001  thorpej file rtc.c was added on branch kqueue on 2002-01-10 19:48:47 +0000
 1.1.2.7 11-Dec-2002  thorpej Sync with HEAD.
 1.1.2.6 18-Oct-2002  nathanw Catch up to -current.
 1.1.2.5 17-Apr-2002  nathanw Catch up to -current.
 1.1.2.4 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.1.2.3 28-Feb-2002  nathanw Catch up to -current.
 1.1.2.2 08-Jan-2002  nathanw Catch up to -current.
 1.1.2.1 11-Dec-2001  nathanw file rtc.c was added on branch nathanw_sa on 2002-01-08 00:27:35 +0000
 1.9.6.5 11-Dec-2005  christos Sync with head.
 1.9.6.4 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.9.6.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.9.6.2 18-Sep-2004  skrll Sync with HEAD.
 1.9.6.1 03-Aug-2004  skrll Sync with HEAD
 1.11.8.1 22-Nov-2005  yamt sync with head.
 1.11.2.2 30-Dec-2006  yamt sync with head.
 1.11.2.1 21-Jun-2006  yamt sync with head.
 1.12.8.1 14-Sep-2006  yamt sync with head.
 1.12.4.1 09-Sep-2006  rpaulo sync with head
 1.14.60.1 11-Mar-2010  yamt sync with head
 1.18.54.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.84 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.83 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.82 10-May-2021  thorpej branches: 1.82.4;
Associate the OpenBoot / OpenFirmware node with attached devices
at config_found() time.
 1.81 24-Apr-2021  thorpej branches: 1.81.2; 1.81.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.80 22-Nov-2020  thorpej branches: 1.80.2;
malloc(9) -> kmem(9) (easy, straight-forward cases only, for now)
 1.79 10-Nov-2019  chs branches: 1.79.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.78 23-Sep-2012  jdc branches: 1.78.38;
Wrap sbuserr_handler and sbus_error with:
#if (defined(SUN4M) && !defined(MSIIEP)) || defined(SUN4D)
to give them the same scope as the definitions in ../sparc/intr.c.
Allows SUN4C-only kernels to compile.
OK mrg
 1.77 29-Jul-2012  matt branches: 1.77.2;
Fix more -fno-common fallout.
 1.76 30-Jan-2012  mrg 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.75 01-Jul-2011  dyoung branches: 1.75.2; 1.75.6;
#include <sys/bus.h> instead of <machine/bus.h>.
 1.74 03-Jan-2010  mrg add an explicit "bool mpsafe" to intr_establish(). only set it to true
for the sun4m timer/counter interrupts. this gets lev10/14 working again
on SMP systems, where those interrupts started taking the kernel lock and
hanging...
 1.73 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.72 18-Mar-2009  cegger bzero -> memset
 1.71 16-Dec-2008  christos branches: 1.71.2;
replace bitmask_snprintf(9) with snprintb(3)
 1.70 13-Jun-2008  cegger branches: 1.70.4;
use device_lookup_private to get softc
 1.69 17-May-2008  macallan branches: 1.69.2;
more device_t-ification
 1.68 28-Apr-2008  martin branches: 1.68.2;
Remove clause 3 and 4 from TNF licenses
 1.67 07-Jun-2006  kardel branches: 1.67.60; 1.67.62; 1.67.64;
convert to timecounters (from branch simonb-timecounters)
 1.66 23-Feb-2006  thorpej branches: 1.66.2; 1.66.8;
Use device_parent().
 1.65 16-Nov-2005  uwe branches: 1.65.2; 1.65.4; 1.65.6;
ANSIify function declarations/defintions. Use uint<N>_t.
Propagate "static" to function definitions. Drop trailing whitespace.
Same binary code is produced for GENERIC.MP + KGDB + DDB.
 1.64 04-Jun-2005  tsutsui branches: 1.64.2; 1.64.8;
Add const.
 1.63 13-Dec-2004  chs for drivers that support only one instance, use a global variable to ensure
that only one instance is configured rather than requiring that its
unit number be zero.
 1.62 05-Jul-2004  pk Use bus_space_tag_alloc().
 1.61 27-Jun-2004  pk Always use `full bus space'. In order to implement this more efficiently,
require that all bus tags have pointers to bus_space_read/write functions,
i.e. no run-time hunting for the first "upstream" implementation.
Since this changes the way bus tags should be constructed it makes sense
to do the same thing for the rest of the bus space methods.
So, now bus space tags are generally constructed by copying the parent's bus
tag and then overriding the methods that the bus driver needs to handle,
instead of starting with an empty bus tag and fiiling in only the fields needed.
 1.60 17-Mar-2004  pk Rename PROM_getprop*() => prom_getprop*().
 1.59 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.58 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.57 15-Jul-2003  lukem __KERNEL_RCSID()
 1.56 01-Jan-2003  thorpej branches: 1.56.2;
Use aprint_normal() for cfprint routines.
 1.55 10-Dec-2002  pk Remove the `flags' argument from bus_intr_establish().
 1.54 10-Dec-2002  pk bus_intr_establish() now takes an optional `fast trap' handler argument.
BUS_INTR_ESTABLISH_FASTTRAP and BUS_INTR_ESTABLISH_SOFTINTR are no longer used.
 1.53 06-Dec-2002  pk Pass the `device class interrupt level' on to intr_establish() and use to
raise the ipl in the interrupt handlers to the appropriate level. This avoids
interrupt handler interference if one of the devices actually interrupts at
a lower hardware level than the maximum level assined to a device class.

Based on code from Art Grabowski in openbsd.
 1.52 02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.51 01-Oct-2002  thorpej Use CFATTACH_DECL().
 1.50 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.49 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.48 25-Aug-2002  thorpej Put a bus's ranges in the bus space tag, and make sparc_bus_map()
perform the translation and recursion if t->ranges != NULL. Make
sbus, cpuunit, and bootbus inherit the parent's map/mmap routines,
and delete the now-unused mapping functions. Update all places where
bus space tags are statically allocated.
 1.47 25-Aug-2002  thorpej Add a generic function to translate a device address using a
parent's "ranges" property, and use it.
 1.46 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.45 11-Mar-2002  pk branches: 1.45.4; 1.45.6;
* `bus_type_t' is gone.
* Use BUS_ADDR() where appropriate to encode I/O space and physical
address offset into a `bus_addr_t' value.
* Drop obio_bus_map() since it's now completely equivalent to bus_space_map()
* Use bus_space_map2() to map device space at a fixed virtual address.
* Remove the virtual address argument from sbus_sbus_addr()
 1.44 31-Dec-2001  uwe Now that sbus_bus_mmap was converted to do the proper address
translation, get rid of sbus_bus_addr. Since sbus_bus_addr is used by
framebuffer drivers that are shared with sparc64 we cannot just change
the callers to use BUS_ADDR() w/out coordinating the change with
sparc64 that uses a different calling protocol, so stub our
sbus_bus_addr to just return BUS_ADDR.
 1.43 20-Dec-2001  uwe Rewrite sbus_bus_mmap to conform to new signature and unbreak bus_space_mmap.
This fixes the problem with X server killing the kernel by writing to
the middle of physical memory instead of the frame buffer.
 1.42 05-Oct-2001  mrg branches: 1.42.4;
avoid a memory leak
 1.41 26-Sep-2001  eeh getprop* -> PROM_getprop*
 1.40 24-Sep-2001  eeh Change bus_space_mmap() signature to the official one.
 1.39 01-Nov-2000  eeh branches: 1.39.2; 1.39.4;
Pass on the sbus frequency.
 1.38 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.37 29-Jun-2000  mrg remove include of <vm/vm.h> and <machine/pmap.h>. <vm/vm.h> -> <uvm/uvm_extern.h>
 1.36 11-Jan-2000  pk branches: 1.36.4;
Remove old-style boot device recognition.
 1.35 14-Apr-1999  pk branches: 1.35.2;
Mask out 64-bit burst capability on sun4m's, since some models (SS20)
erroneously report this in their sbus properties.
 1.34 14-Feb-1999  pk branches: 1.34.2;
Use the PROMLIB interface.
 1.33 20-Sep-1998  pk Don't map sbus `registers' on sun4c (i.e. sbus @ mainbus); it's almost
certainly not the control space we want..
 1.32 19-Sep-1998  pk Map Sbus control registers.
 1.31 07-Sep-1998  pk Undo last change (we're passing the address of a pointer here).
 1.30 05-Sep-1998  eeh The `address' field from the prom is really an unsigned 32-bit value.
Make it so.
 1.29 05-Sep-1998  eeh Remove function naming conflict.
 1.28 30-Aug-1998  pk getpropA() => getprop().
 1.27 21-Aug-1998  pk Convert to [pv]addr_t.
 1.26 29-Jul-1998  pk Switch to new sbus attach arguments layout.
 1.25 27-Jul-1998  pk Get headers from <dev/sbus>
 1.24 18-Apr-1998  pk Skeleton code for the SBus expander box.
 1.23 07-Apr-1998  pk No need to export bus_intr_establish().
 1.22 07-Apr-1998  pk The bus space functions now take care of "pass-through" methods.
 1.21 29-Mar-1998  pk Fill in the bus tag's `bus_space_unmap' method.
 1.20 21-Mar-1998  pk Direct the Sbus bus map function through the bus tag.
 1.19 21-Mar-1998  pk Switch to a bus_space(9)-based device attachment scheme.

- device attachment arguments contain bus-specific
address and interrupt levels.

- devices must call back on bus map functions to get their
addresses and interrupt levels translated properly.

- sun4m's obio bus is treated like an Sbus slot.

- the sun4-style obio bus has its own attach arguments
and map functions.
 1.18 12-Jan-1998  thorpej Update for changes to config.
 1.17 01-Jun-1997  pk Set `rr_iospace' to PMAP_OBIO when translating relative sbus addresses.
 1.16 08-Apr-1997  pk Move "range" property description out of generic `romaux'.
Allocate room for this property when needed in bus attachment.
 1.15 10-Mar-1997  pk Replace `cpumod' with `cpuinfo.cpu_type' equivalents.
 1.14 10-Dec-1996  pk branches: 1.14.6;
Comply with recent autoconfiguration changes. Diffs graciously
supplied by Chris Demetriou.
 1.13 13-Oct-1996  christos backout previous kprintf change
 1.12 11-Oct-1996  christos printf -> kprintf, sprintf -> ksprintf
 1.11 27-Aug-1996  cgd change cfprint_t type definition to take a const char *, rather than
a char *, because that's what was really intended, and because
if the print function modifies the string, various things could become
unhappy (so the string should _not_ be modified).
 1.10 22-Apr-1996  abrown - Changed Sun4m DMA chip support to detect and use maximum available SBus
burst size when transferring data.
- Changed ledma attach code to pay attention to the PROM's notion of what
cable type is being used. Note that this patch does not fix the problem
recently discussed on port-sparc; in most cases the PROM doesn't know
what cable type is being used. The default is now TP rather than AUI,
though. A complete fix is forthcoming.
 1.9 31-Mar-1996  pk Add sbus_translate() to deal with slot address translations, including
new v3 PROM style "range" properties. This routine is also called from obio.c
(which can be viewed upon as just a another Sbus slot).
 1.8 17-Mar-1996  thorpej New device attachment scheme:

- split softc size and match/attach out from cfdriver into
a new struct cfattach.

- new "attach" directive for files.*. May specify the name of
the cfattach structure, so that devices may be easily attached
to parents with different autoconfiguration semantics.
 1.7 14-Mar-1996  christos Bring prototypes into scope and fix compiler warnings.
 1.6 01-Feb-1995  pk Integrate changes from Chuck Cranor for the Sun 4/100.
Support for multiple register banks on SBUS devices (based on patches
from Francis Dupont).
Highlights:
romaux defines an array of register spaces.
pay attention to `vactype'.
quirks handling 4/100 idiosyncracies.
 1.5 23-Nov-1994  deraadt XXmatch change (and a few __P() as well)
 1.4 20-Nov-1994  deraadt copyright/Id cleanup
 1.3 02-Oct-1994  deraadt sun4/300 support works
 1.2 17-Sep-1994  deraadt sbus/* --> dev/*
deal with multiple bus types (start of vme/obio support)
 1.1 02-Oct-1993  deraadt Chris Torek's sparc port. Missing lots of things.
 1.14.6.1 12-Mar-1997  is Merge in changes from The Trunk
 1.34.2.1 14-Apr-1999  pk branches: 1.34.2.1.2;
Pull up rev 1.35 from trunk.
 1.34.2.1.2.1 21-Jun-1999  thorpej Sync w/ -current.
 1.35.2.2 22-Nov-2000  bouyer Sync with HEAD.
 1.35.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.36.4.1 19-Jul-2000  mrg pull up sparc/sparc64 bus_intr_establish() changes, necessary for sparc64
(originally done by pk, approved by thorpej):

>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.39.4.4 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.39.4.3 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.39.4.2 16-Mar-2002  jdolecek Catch up with -current.
 1.39.4.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.39.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.39.2.1 01-Oct-2001  fvdl Catch up with -current.
 1.42.4.7 03-Jan-2003  thorpej Sync with HEAD.

XXX ALT_SWITCH_CODE is not yet LWP'ified.
 1.42.4.6 11-Dec-2002  thorpej Sync with HEAD.
 1.42.4.5 18-Oct-2002  nathanw Catch up to -current.
 1.42.4.4 27-Aug-2002  nathanw Catch up to -current.
 1.42.4.3 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.42.4.2 08-Jan-2002  nathanw Catch up to -current.
 1.42.4.1 05-Oct-2001  nathanw file sbus.c was added on branch nathanw_sa on 2002-01-08 00:27:35 +0000
 1.45.6.1 22-Nov-2002  tron Pull up revision 1.46 (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.45.4.1 31-Aug-2002  gehenna catch up with -current.
 1.56.2.6 11-Dec-2005  christos Sync with head.
 1.56.2.5 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.56.2.4 18-Dec-2004  skrll Sync with HEAD.
 1.56.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.56.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.56.2.1 03-Aug-2004  skrll Sync with HEAD
 1.64.8.1 22-Nov-2005  yamt sync with head.
 1.64.2.1 21-Jun-2006  yamt sync with head.
 1.65.6.2 27-May-2006  kardel convert to timecounters (struct time gone)
 1.65.6.1 22-Apr-2006  simonb Sync with head.
 1.65.4.1 09-Sep-2006  rpaulo sync with head
 1.65.2.1 01-Mar-2006  yamt sync with head.
 1.66.8.1 19-Jun-2006  chap Sync with head.
 1.66.2.1 26-Jun-2006  yamt sync with head.
 1.67.64.3 11-Mar-2010  yamt sync with head
 1.67.64.2 04-May-2009  yamt sync with head.
 1.67.64.1 16-May-2008  yamt sync with head.
 1.67.62.2 17-Jun-2008  yamt sync with head.
 1.67.62.1 18-May-2008  yamt sync with head.
 1.67.60.3 17-Jan-2009  mjf Sync with HEAD.
 1.67.60.2 29-Jun-2008  mjf Sync with HEAD.
 1.67.60.1 02-Jun-2008  mjf Sync with HEAD.
 1.68.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.69.2.1 18-Jun-2008  simonb Sync with head.
 1.70.4.2 28-Apr-2009  skrll Sync with HEAD.
 1.70.4.1 19-Jan-2009  skrll Sync with HEAD.
 1.71.2.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.75.6.1 18-Feb-2012  mrg merge to -current.
 1.75.2.2 30-Oct-2012  yamt sync with head
 1.75.2.1 17-Apr-2012  yamt sync with head
 1.77.2.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.78.38.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.79.8.1 14-Dec-2020  thorpej Sync w/ HEAD.
 1.80.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.81.4.1 31-May-2021  cjep sync with head
 1.81.2.1 13-May-2021  thorpej Sync with HEAD.
 1.82.4.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.7 10-Mar-2024  rillig sparc/sbusreg: fix snprintb format for SBUS_AFSR_BITS
 1.6 16-Nov-2005  uwe ANSIify function declarations/defintions. Use uint<N>_t.
Propagate "static" to function definitions. Drop trailing whitespace.
Same binary code is produced for GENERIC.MP + KGDB + DDB.
 1.5 07-Aug-2003  agc branches: 1.5.16; 1.5.24;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.4 19-Sep-1998  pk branches: 1.4.46;
Add a bunch of SBus control register definitions.
 1.3 14-Sep-1997  pk Collect sbus status and configuration registers in `struct sbusreg'.
 1.2 20-Nov-1994  deraadt branches: 1.2.14;
copyright/Id cleanup
 1.1 02-Oct-1993  deraadt Chris Torek's sparc port. Missing lots of things.
 1.2.14.1 16-Sep-1997  thorpej Update marc-pcmcia branch from trunk.
 1.4.46.4 11-Dec-2005  christos Sync with head.
 1.4.46.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.4.46.2 18-Sep-2004  skrll Sync with HEAD.
 1.4.46.1 03-Aug-2004  skrll Sync with HEAD
 1.5.24.1 22-Nov-2005  yamt sync with head.
 1.5.16.1 21-Jun-2006  yamt sync with head.
 1.20 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.19 17-May-2008  macallan more device_t-ification
 1.18 28-Apr-2008  martin branches: 1.18.2;
Remove clause 3 and 4 from TNF licenses
 1.17 24-Dec-2005  perry branches: 1.17.74; 1.17.76; 1.17.78;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.
 1.16 11-Dec-2005  christos merge ktrace-lwp.
 1.15 04-Feb-2005  jmc branches: 1.15.6;
Do the same thing sparc64 does and redefine sbus_promaddr_to_handle to a static
inline'd function. This way prototypes for it still work in the master
dev/sbusvar.h header. Found when the recent de-_P'ing occured
 1.14 07-Aug-2003  agc branches: 1.14.8; 1.14.10;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.13 25-Aug-2002  thorpej branches: 1.13.6;
Put a bus's ranges in the bus space tag, and make sparc_bus_map()
perform the translation and recursion if t->ranges != NULL. Make
sbus, cpuunit, and bootbus inherit the parent's map/mmap routines,
and delete the now-unused mapping functions. Update all places where
bus space tags are statically allocated.
 1.12 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.11 21-Mar-2002  uwe branches: 1.11.4; 1.11.6;
Fix cast in sbus_promaddr_to_handle().
 1.10 20-Mar-2002  eeh Add sbus_promaddr_to_handle() to convert a prom address to a bus_space_handle_t.
 1.9 19-Sep-1998  pk branches: 1.9.26; 1.9.30;
Map Sbus control registers.
 1.8 29-Jul-1998  pk Lots of things have moved to <dev/sbus/sbusvar.h>
 1.7 07-Apr-1998  pk No need to export bus_intr_establish().
 1.6 21-Mar-1998  pk Direct the Sbus bus map function through the bus tag.
 1.5 21-Mar-1998  pk Sbus attach arguments and map function prototypes go here.
 1.4 22-Apr-1996  abrown - Changed Sun4m DMA chip support to detect and use maximum available SBus
burst size when transferring data.
- Changed ledma attach code to pay attention to the PROM's notion of what
cable type is being used. Note that this patch does not fix the problem
recently discussed on port-sparc; in most cases the PROM doesn't know
what cable type is being used. The default is now TP rather than AUI,
though. A complete fix is forthcoming.
 1.3 31-Mar-1996  pk Various cleanup; mostly trailing spaces/tabs.
 1.2 20-Nov-1994  deraadt copyright/Id cleanup
 1.1 02-Oct-1993  deraadt Chris Torek's sparc port. Missing lots of things.
 1.9.30.2 27-Aug-2002  nathanw Catch up to -current.
 1.9.30.1 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.9.26.2 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.9.26.1 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.11.6.1 22-Nov-2002  tron Pull up revision 1.12 (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.11.4.1 31-Aug-2002  gehenna catch up with -current.
 1.13.6.4 06-Feb-2005  skrll Sync with HEAD.
 1.13.6.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.13.6.2 18-Sep-2004  skrll Sync with HEAD.
 1.13.6.1 03-Aug-2004  skrll Sync with HEAD
 1.14.10.1 12-Feb-2005  yamt sync with head.
 1.14.8.1 29-Apr-2005  kent sync with -current
 1.15.6.1 21-Jun-2006  yamt sync with head.
 1.17.78.3 11-Mar-2010  yamt sync with head
 1.17.78.2 04-May-2009  yamt sync with head.
 1.17.78.1 16-May-2008  yamt sync with head.
 1.17.76.1 18-May-2008  yamt sync with head.
 1.17.74.1 02-Jun-2008  mjf Sync with HEAD.
 1.18.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.66 03-Jul-2000  pk The `si' driver has been transformed into an MI VME frontend.
 1.65 03-Jul-2000  pk * Remove MAX_DMA_LEN & si_minphys().
* Disable the DMA engine when setting up a DMA transfer, just in case
the 5380 driver didn't instruct us to do so already.
* More useful debug output when entering the "left-over bytes" case after
a DMA transfer finishes.
 1.64 29-Jun-2000  pk When winding down a DMA transfer, don't complain about the actual
transfer count being smaller than the minimum transfer size for which
we would use DMA. The device may be disconnecting, to complete the
transaction at a later time. Just let the 5380 engine proceed acting
on the current SCSI bus phase.
 1.63 26-Jun-2000  pk Split si & sw drivers.
 1.62 26-Jun-2000  pk The `sw' driver should not use vme bus routines.
 1.61 25-Jun-2000  pk Use vme_dmamap_create() instead of bus_dmamap_create().
Remove Sun hardware id test from si_match().
 1.60 18-Jun-2000  pk branches: 1.60.2;
Conversion to bus_space*().
 1.59 15-Jun-2000  pk Remove pointless debugging check.
 1.58 15-Jun-2000  pk Enable DMA interrupts.
 1.57 25-Mar-2000  tsutsui branches: 1.57.2;
Add a "sc_rev" member to ncr5380_softc and handle CXD1180 quirk
in MI ncr5380sbc.
 1.56 18-Mar-2000  mycroft Add a ncr5380_attach() routine which does part of the initialization, attaches
the scsibus, and does the addref/delref dance.
 1.55 13-Mar-2000  soren Fix doubled 'the's in comments.
 1.54 11-Jan-2000  pk Remove old-style boot device recognition.
 1.53 21-Oct-1999  pk Comply with recent MI scsi changes.
 1.52 30-Jun-1999  drochner branches: 1.52.2; 1.52.4; 1.52.6;
update for new VME framework
 1.51 17-Mar-1999  pk branches: 1.51.4;
Got a VME probe result backwards.
 1.50 19-Nov-1998  thorpej Adapt to the new scsipi_adapter interface.
 1.49 10-Oct-1998  thorpej Garbage-collect the open_target_lu and close_target_lu entry points from
struct scsipi_adapter; they were not used.

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

Inspired by PR #6090, from Matt Jacob.
 1.48 31-Jul-1998  pk Convert to bus_dma.
 1.47 04-Jul-1998  jonathan branches: 1.47.2;
defopt DDB.
 1.46 29-Mar-1998  pk obio_bus_probe() => bus_space_probe()
 1.45 21-Mar-1998  pk Account for changed bus attachment scheme.
 1.44 06-Feb-1998  pk vme_bus_probe() takes an `offset' argument.
 1.43 04-Feb-1998  pk Use vme_bus_probe() in si_attach().
 1.42 25-Jan-1998  pk Split si & sw attach routines, and make the si part use the new VME interface.
 1.41 12-Jan-1998  thorpej Update for changes to config.
 1.40 16-Oct-1997  mycroft Fix up includes.
 1.39 09-Oct-1997  jtc Fix tipo inherited from old version of TNF copyright template.
 1.38 27-Aug-1997  bouyer Merge scsipi branch in the mainline. This add support for ATAPI devices
(currently only CD-ROM drives on i386). The sys/dev/scsipi system provides 2
busses to which devices can attach (scsibus and atapibus). This needed to
change some include files and structure names in the low level scsi drivers.
 1.37 29-Jul-1997  fair branches: 1.37.2;
%x -> 0x%x
 1.36 24-May-1997  pk branches: 1.36.2;
Remove all `bustype' arguments from map[io]dev() and REG2PHYS().
 1.35 14-Mar-1997  cjs Remove code that stops transfers of >63K. The Sun 4 doesn't have this
limitation, and minphys() is supposed to catch this on other architectures.
 1.34 10-Mar-1997  pk Replace `cpumod' with `cpuinfo.cpu_type' equivalents.
 1.33 26-Feb-1997  gwr Minimal changes to adapt to removal of NCR5380_PERMIT_RESELECT.
This driver should be updated to allow per-target control over
disconnect/reselect, but I will leave that to the port masters.
 1.32 23-Jan-1997  thorpej branches: 1.32.4;
Arrange the code that sets the options flags such that the user can
completely override the defaults (including disabling DMA) in the
kernel config file.
 1.31 10-Dec-1996  pk Comply with recent autoconfiguration changes. Diffs graciously
supplied by Chris Demetriou.
 1.30 09-Dec-1996  thorpej Copyright assigned to The NetBSD Foundation.
 1.29 13-Nov-1996  thorpej Use bitmask_snprintf().
 1.28 13-Oct-1996  christos backout previous kprintf change
 1.27 11-Oct-1996  christos printf -> kprintf, sprintf -> ksprintf
 1.26 28-Aug-1996  cgd (1) set scsi_link channel to either the appropriate channel (if a
multi-channel driver), or to SCSI_CHANNEL_ONLY_ONE if a
single-channel driver.
(2) use scsiprint() rather than a locally-defined autoconfig print
function, and kill any locally-defined print function.
 1.25 27-Aug-1996  cgd change cfprint_t type definition to take a const char *, rather than
a char *, because that's what was really intended, and because
if the print function modifies the string, various things could become
unhappy (so the string should _not_ be modified).
 1.24 13-May-1996  thorpej Enable DMA by default on the 4/100 "sw" controller; the DMA bugs appear
to have been fixed.
 1.23 31-Mar-1996  pk Various cleanup; mostly trailing spaces/tabs.
 1.22 26-Mar-1996  pk Back to normal printf()s, now that gcc understands `%b'.
 1.21 17-Mar-1996  thorpej New device attachment scheme:

- split softc size and match/attach out from cfdriver into
a new struct cfattach.

- new "attach" directive for files.*. May specify the name of
the cfattach structure, so that devices may be easily attached
to parents with different autoconfiguration semantics.
 1.20 16-Mar-1996  christos fix formats in printf() and panic()
 1.19 14-Mar-1996  christos Bring prototypes into scope and fix compiler warnings.
 1.18 01-Mar-1996  thorpej Fix an operator precedence botch. *sigh* This just hasn't been my week.
 1.17 29-Feb-1996  thorpej Back out the "don't use DMA if SCSI_POLL is set" saftey-net. The
MI 5380 code did something I didn't really expect, which caused DMA
to disable itself if only DMA was enabled. *grumble*
 1.16 25-Feb-1996  pk Use CPU-type macros
 1.15 23-Feb-1996  thorpej Add an "sw_options" patchable global so that folks can still live life
on the edge (of sw DMA uncertainty) with pre-built kernels.
 1.14 23-Feb-1996  thorpej Attempt to work around a hardware bug that screws up DMA on the 4/100.
Apparently, some early 4/100 DMA controllers do illegal memory access on
large ( >= NBPG ) transfers at the end of the transfer. This appears
as SI_CSR_DMA_BUS_ERR in the csr. To work around this, we simply
transfer the (up to 3) missing bytes from the bpr. We were doing this
anyway, so the work-around is to ignore the bus error.

BUT! I goofed when I implemented the "left-over byte" code for the sw!
It *should* be correct now. Keep metrics (acceeible via DDB) on the number
of 1, 2, and 3 byte clean-ups, as well as the number of "clean" transfers,
just so we can get a clearer picture.

Thanks to Andrew Gillham <gillham@whirlpool.com> for noticing this!
 1.13 22-Feb-1996  thorpej If we get a transfer with the SCSI_POLL flag set, don't use DVMA. We
only get these during autoconfiguration and during crash dumps. During
autoconfiguration, the transfers are small enough that DVMA won't be used
anyway. However, using DVMA during a crash dump can be dangerous,
depending on the nature of the panic, so we avoid it.
 1.12 22-Feb-1996  thorpej Bring in Gordon's fix from the sun3 port:

Correct the DMA transfer count when the target disconnects before
the whole transfer is completed. (Affects VME writes)
Reselect now works on the VME si board!
 1.11 09-Jan-1996  thorpej Re-arrange slightly the si_options special case for the `sw'.
 1.10 09-Jan-1996  thorpej Disable DMA by default on the 4/100 `sw' controller. I've had a couple
of reports of data corruption, and would rather be slow and safe until
the DMA bug is fixed.
 1.9 04-Jan-1996  thorpej Fix a typo that would bite if the interrupt level were wildcarded in the
kernel config file.
 1.8 01-Jan-1996  thorpej New driver for the Sun SCSI-3 VME and 4/100-series SCSI "Weird" controllers,
utilizing David Jones' new MI NCR 5380 code. Ported from the sun3 ncr_si.c
and "sw" DMA code written by me.

This driver contains user-configurable "options", which can be set via the
"flags" directive in the kernel configuration file. By default, only
DMA is enabled. DMA completion interrupts and reselection may be enabled
by setting the appropriate bits with "flags". See si.c for details.

Note that DMA completion interrupts and reselection don't yet work on the
4/100 controller. I don't know why, and it's unlikely that I'll have
the opportunity to find out any time soon. DMA does work, and results
in a considerable performance increase.

DMA, DMA completion interrupts, and reslection all work on my 4/260 (VME)
system with modern SCSI-II disks.
 1.7 11-Dec-1995  pk Adapt to changed mapiodev() interface.
 1.6 14-Sep-1995  pk Re-instate configuration print routines, following Chris' suggestion.
Only prints something if there's no scsi bus to attach.
 1.5 11-Sep-1995  pk We have no need for `si_print()'; the only child we expect is a `scsibus',
and there's nothing to say if it isn't there.
 1.4 03-Sep-1995  pk Patches from Jason Thorpe to deal with 4/110 scsi (PR#1422). Also includes
bootpath glue (PR#1414) (this needs finishing off in disksubr.c).
 1.3 16-Aug-1995  pk Drop si_minphys().
 1.2 24-Jul-1995  cgd update SCSI minphys routines' definitions to match standard minphys()
definition and usage.
 1.1 08-Jul-1995  pk si scsi driver, adapted from sun3 version by Jason Thorpe.
Note: re-arranged to use dev/ic/ncr5380* MI files.
 1.32.4.1 12-Mar-1997  is Merge in changes from The Trunk
 1.36.2.2 30-Jul-1997  bouyer Sync with trunk.
 1.36.2.1 01-Jul-1997  bouyer Updates for new scsipi subsystem. Actally known to work on i386 and sparc.
 1.37.2.2 14-Oct-1997  thorpej Update marc-pcmcia branch from trunk.
 1.37.2.1 27-Aug-1997  thorpej Update marc-pcmcia branch from trunk.
 1.47.2.1 08-Aug-1998  eeh Revert cdevsw mmap routines to return int.
 1.51.4.1 01-Jul-1999  thorpej Sync w/ -current.
 1.52.6.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.52.4.1 15-Nov-1999  fvdl Sync with -current
 1.52.2.1 20-Nov-2000  bouyer Remove files that are no longer on the trunck
 1.57.2.1 22-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.60.2.1 19-Jul-2000  mrg pull up sparc/sparc64 bus_intr_establish() changes, necessary for sparc64
(originally done by pk, approved by thorpej):

>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.6 03-Jul-2000  pk The `si' driver has been transformed into an MI VME frontend.
 1.5 26-Jun-2000  pk Split si & sw drivers.
 1.4 18-Jun-2000  pk Conversion to bus_space*().
 1.3 01-Jan-1996  thorpej branches: 1.3.30; 1.3.38;
New driver for the Sun SCSI-3 VME and 4/100-series SCSI "Weird" controllers,
utilizing David Jones' new MI NCR 5380 code. Ported from the sun3 ncr_si.c
and "sw" DMA code written by me.

This driver contains user-configurable "options", which can be set via the
"flags" directive in the kernel configuration file. By default, only
DMA is enabled. DMA completion interrupts and reselection may be enabled
by setting the appropriate bits with "flags". See si.c for details.

Note that DMA completion interrupts and reselection don't yet work on the
4/100 controller. I don't know why, and it's unlikely that I'll have
the opportunity to find out any time soon. DMA does work, and results
in a considerable performance increase.

DMA, DMA completion interrupts, and reslection all work on my 4/260 (VME)
system with modern SCSI-II disks.
 1.2 03-Sep-1995  pk Patches from Jason Thorpe to deal with 4/110 scsi (PR#1422). Also includes
bootpath glue (PR#1414) (this needs finishing off in disksubr.c).
 1.1 08-Jul-1995  pk si scsi driver, adapted from sun3 version by Jason Thorpe.
Note: re-arranged to use dev/ic/ncr5380* MI files.
 1.3.38.1 22-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.3.30.1 20-Nov-2000  bouyer Remove files that are no longer on the trunck
 1.26 23-Jan-2023  andvar s/lager/larger/ in comments.
 1.25 22-Nov-2020  thorpej malloc(9) -> kmem(9) (easy, straight-forward cases only, for now)
 1.24 10-Nov-2019  chs branches: 1.24.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.23 01-Jul-2011  dyoung branches: 1.23.54;
#include <sys/bus.h> instead of <machine/bus.h>.
 1.22 16-Dec-2008  christos replace bitmask_snprintf(9) with snprintb(3)
 1.21 28-Apr-2008  martin branches: 1.21.8;
Remove clause 3 and 4 from TNF licenses
 1.20 04-Apr-2008  tsutsui branches: 1.20.2; 1.20.4;
Split devict_t/softc for ncr5380sbc SCSI, and misc cosmetic changes.
 1.19 01-Nov-2007  jnemeth branches: 1.19.16;
typo
 1.18 04-Mar-2007  christos branches: 1.18.2; 1.18.18; 1.18.20; 1.18.24;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.17 29-Mar-2006  thorpej branches: 1.17.14;
Use device_cfdata().
 1.16 16-Nov-2005  uwe branches: 1.16.4; 1.16.6; 1.16.8; 1.16.10; 1.16.12;
Duplicate open curlies in both #if and #else parts confuse
paren-matching in editors, drop them and add one after #endif.
 1.15 16-Nov-2005  uwe ANSIify function declarations/defintions. Use uint<N>_t.
Propagate "static" to function definitions. Drop trailing whitespace.
Same binary code is produced for GENERIC.MP + KGDB + DDB.
 1.14 04-Dec-2003  keihan branches: 1.14.16; 1.14.24;
NetBSD.ORG -> NetBSD.org

Now all "NetBSD.ORG" are gone from src/sys.
 1.13 15-Jul-2003  lukem __KERNEL_RCSID()
 1.12 03-May-2003  wiz branches: 1.12.2;
DMA, not dma nor Dma.
 1.11 10-Dec-2002  pk Remove the `flags' argument from bus_intr_establish().
 1.10 02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.9 01-Oct-2002  thorpej Use CFATTACH_DECL().
 1.8 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.7 27-Sep-2002  provos remove trailing \n in panic(). approved perry.
 1.6 11-Mar-2002  pk * `bus_type_t' is gone.
* Use BUS_ADDR() where appropriate to encode I/O space and physical
address offset into a `bus_addr_t' value.
* Drop obio_bus_map() since it's now completely equivalent to bus_space_map()
* Use bus_space_map2() to map device space at a fixed virtual address.
* Remove the virtual address argument from sbus_sbus_addr()
 1.5 20-Aug-2001  wiz branches: 1.5.6;
precede, not preceed.
 1.4 25-Apr-2001  bouyer branches: 1.4.2;
Pull up the thorpej_scsipi branch to main branch.
This is a completely rewritten scsipi_xfer execution engine, and the
associated changes to HBA drivers. Overview of changes & features:
- All xfers are queued in the mid-layer, rather than doing so in an
ad-hoc fashion in individual adapter drivers.
- Adapter/channel resource management in the mid-layer, avoids even trying
to start running an xfer if the adapter/channel doesn't have the resources.
- Better communication between the mid-layer and the adapters.
- Asynchronous event notification mechanism from adapter to mid-layer and
peripherals.
- Better peripheral queue management: freeze/thaw, sorted requeueing during
recovery, etc.
- Clean separation of peripherals, adapters, and adapter channels (no more
scsipi_link).
- Kernel thread for each scsipi_channel makes error recovery much easier
(no more dealing with interrupt context when recovering from an error).
- Mid-layer support for tagged queueing: commands can have the tag type
set explicitly, tag IDs are allocated in the mid-layer (thus eliminating
the need to use buggy tag ID allocation schemes in many adapter drivers).
- support for QUEUE FULL and CHECK CONDITION status in mid-layer; the command
will be requeued, or a REQUEST SENSE will be sent as appropriate.

Just before the merge syssrc has been tagged with thorpej_scsipi_beforemerge
 1.3 09-Jul-2000  pk branches: 1.3.2; 1.3.4; 1.3.6;
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.2 29-Jun-2000  pk When winding down a DMA transfer, don't complain about the actual
transfer count being smaller than the minimum transfer size for which
we would use DMA. The device may be disconnecting, to complete the
transaction at a later time. Just let the 5380 engine proceed acting
on the current SCSI bus phase.
 1.1 26-Jun-2000  pk Split si & sw drivers.
 1.3.6.1 21-Jun-2001  nathanw Catch up to -current.
 1.3.4.3 22-Jan-2001  bouyer GENERIC without isp now compiles
 1.3.4.2 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.3.4.1 09-Jul-2000  bouyer file sw.c was added on branch thorpej_scsipi on 2000-11-20 20:25:34 +0000
 1.3.2.2 22-Jul-2000  pk New in netbsd-1-5: sw.c revision 1.3; swreg.h revision 1.1.

Split si & sw drivers.
 1.3.2.1 09-Jul-2000  pk file sw.c was added on branch netbsd-1-5 on 2000-07-22 21:14:19 +0000
 1.4.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.4.2.2 16-Mar-2002  jdolecek Catch up with -current.
 1.4.2.1 25-Aug-2001  thorpej Merge Aug 24 -current into the kqueue branch.
 1.5.6.4 11-Dec-2002  thorpej Sync with HEAD.
 1.5.6.3 18-Oct-2002  nathanw Catch up to -current.
 1.5.6.2 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.5.6.1 20-Aug-2001  nathanw file sw.c was added on branch nathanw_sa on 2002-04-01 07:42:43 +0000
 1.12.2.4 11-Dec-2005  christos Sync with head.
 1.12.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.12.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.12.2.1 03-Aug-2004  skrll Sync with HEAD
 1.14.24.1 22-Nov-2005  yamt sync with head.
 1.14.16.3 15-Nov-2007  yamt sync with head.
 1.14.16.2 03-Sep-2007  yamt sync with head.
 1.14.16.1 21-Jun-2006  yamt sync with head.
 1.16.12.1 31-Mar-2006  tron Merge 2006-03-31 NetBSD-current into the "peter-altq" branch.
 1.16.10.1 19-Apr-2006  elad sync with head - hopefully this will work
 1.16.8.1 01-Apr-2006  yamt sync with head.
 1.16.6.1 22-Apr-2006  simonb Sync with head.
 1.16.4.1 09-Sep-2006  rpaulo sync with head
 1.17.14.1 12-Mar-2007  rmind Sync with HEAD.
 1.18.24.1 13-Nov-2007  bouyer Sync with HEAD
 1.18.20.1 06-Nov-2007  matt sync with HEAD
 1.18.18.1 04-Nov-2007  jmcneill Sync with HEAD.
 1.18.2.1 03-Dec-2007  ad Sync with HEAD.
 1.19.16.2 17-Jan-2009  mjf Sync with HEAD.
 1.19.16.1 02-Jun-2008  mjf Sync with HEAD.
 1.20.4.2 04-May-2009  yamt sync with head.
 1.20.4.1 16-May-2008  yamt sync with head.
 1.20.2.1 18-May-2008  yamt sync with head.
 1.21.8.1 19-Jan-2009  skrll Sync with HEAD.
 1.23.54.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.24.8.1 14-Dec-2020  thorpej Sync w/ HEAD.
 1.5 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.4 11-Dec-2005  christos branches: 1.4.74; 1.4.76; 1.4.78;
merge ktrace-lwp.
 1.3 04-Dec-2003  keihan NetBSD.ORG -> NetBSD.org

Now all "NetBSD.ORG" are gone from src/sys.
 1.2 03-May-2003  wiz branches: 1.2.2;
DMA, not dma nor Dma.
 1.1 26-Jun-2000  pk branches: 1.1.2; 1.1.4;
Split si & sw drivers.
 1.1.4.2 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.1.4.1 26-Jun-2000  bouyer file swreg.h was added on branch thorpej_scsipi on 2000-11-20 20:25:34 +0000
 1.1.2.2 22-Jul-2000  pk New in netbsd-1-5: sw.c revision 1.3; swreg.h revision 1.1.

Split si & sw drivers.
 1.1.2.1 26-Jun-2000  pk file swreg.h was added on branch netbsd-1-5 on 2000-07-22 21:14:20 +0000
 1.2.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.2.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.2.2.1 03-Aug-2004  skrll Sync with HEAD
 1.4.78.1 16-May-2008  yamt sync with head.
 1.4.76.1 18-May-2008  yamt sync with head.
 1.4.74.1 02-Jun-2008  mjf Sync with HEAD.
 1.8 20-Dec-2023  thorpej Remove unnecessary <sys/malloc.h>.
 1.7 13-Jun-2023  macallan add counter to periodically drain the instruction queue in order to avoid
stalling the MBus during long SX operations
adapted from xf86-video-suncg14
 1.6 13-Apr-2023  macallan initialize the diagnostic register with the value suggested by the SunOS
header. This sets a bunch of undocumented bits and yields a 10% speed increase
when rendering antialiased text.
 1.5 11-Sep-2021  andvar branches: 1.5.4;
Add missing double p and d for stopped and overriden accordingly.
Fix few more typos along the way, mainly in copy-pasted comments.
 1.4 01-Mar-2019  macallan adapt to changes in sxreg.h
 1.3 15-Apr-2014  macallan branches: 1.3.2; 1.3.30;
print chip revision on attach
 1.2 06-Feb-2013  macallan branches: 1.2.2; 1.2.4; 1.2.12;
fix typos, deal with hardware insanity
 1.1 05-Feb-2013  macallan attachment and initialization for SX
 1.2.12.1 10-Aug-2014  tls Rebase.
 1.2.4.3 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.2.4.2 25-Feb-2013  tls resync with head
 1.2.4.1 06-Feb-2013  tls file sx.c was added on branch tls-maxphys on 2013-02-25 00:28:57 +0000
 1.2.2.1 18-May-2014  rmind sync with head
 1.3.30.1 10-Jun-2019  christos Sync with HEAD
 1.3.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.3.2.1 15-Apr-2014  yamt file sx.c was added on branch yamt-pagecache on 2014-05-22 11:40:08 +0000
 1.5.4.1 05-Jul-2023  martin Pull up following revision(s) (requested by abs in ticket #224):

sys/dev/wscons/wsdisplay_vconsvar.h: revision 1.34
sys/dev/wscons/wsdisplay_glyphcachevar.h: revision 1.6
sys/arch/sparc/dev/cgfourteen.c: revision 1.94
sys/arch/sparc/dev/cgfourteen.c: revision 1.95
sys/dev/sbus/mgx.c: revision 1.21
sys/dev/sbus/mgx.c: revision 1.22
sys/dev/sbus/mgx.c: revision 1.23
sys/dev/wscons/wsdisplay_vcons.c: revision 1.65
sys/dev/wscons/wsdisplay_vcons.c: revision 1.66
sys/dev/wscons/wsdisplay_glyphcache.c: revision 1.12
sys/arch/sparc/dev/sxvar.h: revision 1.5
sys/arch/sparc/dev/sx.c: revision 1.6
sys/arch/sparc/dev/sx.c: revision 1.7

make vcons_putchar_buffer() return a flag indicating if anything actually
changed, skip the actual drawing op if nothing did

add flags for drivers to requesr R2L bit/byte-ordered fonts, default to
L2R, chack them in vcons_load_font() instead of just trusting that we'd get
what we need

initialize the diagnostic register with the value suggested by the SunOS
header. This sets a bunch of undocumented bits and yields a 10% speed increase
when rendering antialiased text.

use macros compatible with xf86-video-suncg14 to issue SX instructions
much more readable, alignment weirdness is handled automatically and code is
interchangable

allow drivers to specify horizontal alignment of glyph cache cells
for things like SX which have alignment restrictions

add counter to periodically drain the instruction queue in order to avoid
stalling the MBus during long SX operations

adapted from xf86-video-suncg14
- use sx_wait() to avoid stalling the MBus
- request 32bit alignment for glyphcache cells

wait for the engine to go idle before issuing rectfill commands
we get occasional overlap with blit commands if we just wait for fifo slots
needs further investigation, it is possible that not all writes to drawing
engine registers are pipelined and of course we don't have docs

following a hunch...
- cache DEC and FG registers, only write them if the value actually changes
- wait for the engine to go idle before writing DEC
- wait for FIFO slots on everything else
with this we avoid waiting if possible and still avoid overlapping blit and
fill commands
 1.22 12-May-2024  macallan add simple 16bit load and store ops
 1.21 10-Dec-2021  andvar s/occured/occurred/ in comments, log messages and man pages.
 1.20 08-Dec-2021  macallan be more consistent with underscores in instruction names
 1.19 08-Dec-2021  macallan add SX_ROPB instruction
 1.18 03-Dec-2021  macallan add shift instructions
 1.17 22-Feb-2019  macallan some register bits are defined differently by SunOS's sxreg.h and the SPAM
manual, upon investigation the hardware appears to agree with the SunOS header,
so adapt accordingly
 1.16 08-Dec-2017  macallan branches: 1.16.4;
fix tpyos and pastos
 1.15 07-Dec-2017  macallan add SCATTER/GATHER instructions
 1.14 30-Oct-2017  macallan add load & store instructions for channel data type
mostly for Xorg
 1.13 13-Jan-2017  macallan add SX_STBM ( STore Byte Masked ) instruction
 1.12 30-Apr-2016  macallan branches: 1.12.2;
sprinkle ()s in macros
 1.11 19-Jun-2013  macallan branches: 1.11.8; 1.11.12;
add store-with-clamp instructions
 1.10 12-Jun-2013  macallan fix typo
 1.9 12-Jun-2013  macallan document arithmetics instructions
 1.8 12-Jun-2013  macallan fix serial type&pasto, while there add SX_ADD instructions
 1.7 05-Jun-2013  macallan add a bunch more instructions ( still not complete but we're getting there )
 1.6 04-Jun-2013  macallan add STore with (plane) Mask instruction
 1.5 30-May-2013  macallan add SX_SELECT_S instruction
 1.4 29-May-2013  macallan fix a typo
 1.3 06-Feb-2013  macallan branches: 1.3.4;
add SX_ROP instruction
 1.2 06-Feb-2013  macallan fix typos, deal with hardware insanity
 1.1 05-Feb-2013  macallan attachment and initialization for SX
 1.3.4.4 03-Dec-2017  jdolecek update from HEAD
 1.3.4.3 23-Jun-2013  tls resync from head
 1.3.4.2 25-Feb-2013  tls resync with head
 1.3.4.1 06-Feb-2013  tls file sxreg.h was added on branch tls-maxphys on 2013-02-25 00:28:57 +0000
 1.11.12.2 05-Feb-2017  skrll Sync with HEAD
 1.11.12.1 29-May-2016  skrll Sync with HEAD
 1.11.8.2 22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.11.8.1 19-Jun-2013  yamt file sxreg.h was added on branch yamt-pagecache on 2014-05-22 11:40:08 +0000
 1.12.2.1 20-Mar-2017  pgoyette Sync with HEAD
 1.16.4.1 10-Jun-2019  christos Sync with HEAD
 1.5 13-Jun-2023  macallan add counter to periodically drain the instruction queue in order to avoid
stalling the MBus during long SX operations
adapted from xf86-video-suncg14
 1.4 01-Mar-2019  macallan branches: 1.4.30;
adapt to changes in sxreg.h
 1.3 29-Jun-2014  tsutsui branches: 1.3.28;
Add a newline at end of file.
 1.2 15-Apr-2014  macallan branches: 1.2.2;
print chip revision on attach
 1.1 05-Feb-2013  macallan branches: 1.1.2; 1.1.4; 1.1.12;
attachment and initialization for SX
 1.1.12.1 10-Aug-2014  tls Rebase.
 1.1.4.3 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.4.2 25-Feb-2013  tls resync with head
 1.1.4.1 05-Feb-2013  tls file sxvar.h was added on branch tls-maxphys on 2013-02-25 00:28:57 +0000
 1.1.2.1 18-May-2014  rmind sync with head
 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 15-Apr-2014  yamt file sxvar.h was added on branch yamt-pagecache on 2014-05-22 11:40:08 +0000
 1.3.28.1 10-Jun-2019  christos Sync with HEAD
 1.4.30.1 05-Jul-2023  martin Pull up following revision(s) (requested by abs in ticket #224):

sys/dev/wscons/wsdisplay_vconsvar.h: revision 1.34
sys/dev/wscons/wsdisplay_glyphcachevar.h: revision 1.6
sys/arch/sparc/dev/cgfourteen.c: revision 1.94
sys/arch/sparc/dev/cgfourteen.c: revision 1.95
sys/dev/sbus/mgx.c: revision 1.21
sys/dev/sbus/mgx.c: revision 1.22
sys/dev/sbus/mgx.c: revision 1.23
sys/dev/wscons/wsdisplay_vcons.c: revision 1.65
sys/dev/wscons/wsdisplay_vcons.c: revision 1.66
sys/dev/wscons/wsdisplay_glyphcache.c: revision 1.12
sys/arch/sparc/dev/sxvar.h: revision 1.5
sys/arch/sparc/dev/sx.c: revision 1.6
sys/arch/sparc/dev/sx.c: revision 1.7

make vcons_putchar_buffer() return a flag indicating if anything actually
changed, skip the actual drawing op if nothing did

add flags for drivers to requesr R2L bit/byte-ordered fonts, default to
L2R, chack them in vcons_load_font() instead of just trusting that we'd get
what we need

initialize the diagnostic register with the value suggested by the SunOS
header. This sets a bunch of undocumented bits and yields a 10% speed increase
when rendering antialiased text.

use macros compatible with xf86-video-suncg14 to issue SX instructions
much more readable, alignment weirdness is handled automatically and code is
interchangable

allow drivers to specify horizontal alignment of glyph cache cells
for things like SX which have alignment restrictions

add counter to periodically drain the instruction queue in order to avoid
stalling the MBus during long SX operations

adapted from xf86-video-suncg14
- use sx_wait() to avoid stalling the MBus
- request 32bit alignment for glyphcache cells

wait for the engine to go idle before issuing rectfill commands
we get occasional overlap with blit commands if we just wait for fifo slots
needs further investigation, it is possible that not all writes to drawing
engine registers are pipelined and of course we don't have docs

following a hunch...
- cache DEC and FG registers, only write them if the value actually changes
- wait for the engine to go idle before writing DEC
- wait for FIFO slots on everything else
with this we avoid waiting if possible and still avoid overlapping blit and
fill commands
 1.65 26-Sep-2021  thorpej Driver "kqfilter" entry points return an error code, so if an invalid
filter is requested, return EINVAL rather than 1.
 1.64 26-Sep-2021  thorpej Change the kqueue filterops::f_isfd field to filterops::f_flags, and
define a flag FILTEROP_ISFD that has the meaning of the prior f_isfd.
Field and flag name aligned with OpenBSD.

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

NetBSD 9.99.89
 1.63 04-Jan-2021  thorpej Use sel{record,remove}_knote().
 1.62 13-Jun-2020  jdc branches: 1.62.2;
Initialise the mutex before we use it.
 1.61 25-Oct-2017  maya Use C99 initializer for filterops

Mostly done with spatch with touchups for indentation

@@
expression a;
identifier b,c,d;
identifier p;
@@
const struct filterops p =
- { a, b, c, d
+ {
+ .f_isfd = a,
+ .f_attach = b,
+ .f_detach = c,
+ .f_event = d,
};
 1.60 11-Dec-2016  christos catch up with sd changes.
 1.59 25-Jul-2014  dholland branches: 1.59.4; 1.59.8;
Add d_discard to all struct cdevsw instances I could find.

All have been set to "nodiscard"; some should get a real implementation.
 1.58 16-Mar-2014  dholland branches: 1.58.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.57 19-Oct-2013  mrg - remove unused but set variables.
- use __USE() where necessary.
- remove useless 'volatile' markers

kd.c:consinit() might be wrong for old proms, but i've not
changed it really.
 1.56 27-Oct-2012  chs branches: 1.56.2;
split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.55 25-Mar-2012  martin branches: 1.55.2;
Make explicitly clear that we mean raw I/O on device passthru, not just
generic passthru.
 1.54 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.53 18-Jul-2011  mrg branches: 1.53.2; 1.53.6;
convert the remaining sparc drivers to CFATTACH_DECL_NEW/cfdata_t/device_t.
(cgsix_obio.c was only partially converted with the rest of the cgsix code
when it was changed some time ago.)
 1.52 01-Jul-2011  dyoung #include <sys/bus.h> instead of <machine/bus.h>.
 1.51 20-Jun-2011  pgoyette Initialize sensor states before registering
 1.50 21-Nov-2009  rmind branches: 1.50.10;
Use lwp_getpcb() on sparc{64} and sun2/3 MD code, clean from struct user usage.
 1.49 17-Jul-2008  cegger make this compile
 1.48 11-Jun-2008  drochner branches: 1.48.2;
mechanical changes to use device_private() or device_lookup_private()
to get softcs, makes the code compile under the stricter type checking
introduced earlier today
 1.47 28-Apr-2008  martin branches: 1.47.2; 1.47.4;
Remove clause 3 and 4 from TNF licenses
 1.46 01-Mar-2008  rmind branches: 1.46.2; 1.46.4;
Welcome to 4.99.55:

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

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

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

Note: please pass appropriate value of 'events' where possible.
Proposed on: <tech-kern>
 1.45 12-Feb-2008  joerg branches: 1.45.2; 1.45.6;
Introduce device_find_by_xname and device_find_by_driver_unit to replace
alldevs iterations all over src.

Patch discussed with and improved on suggestioned from cube@.
 1.44 16-Nov-2007  xtraeme 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.43 17-Oct-2007  garbled branches: 1.43.2;
Merge the ppcoea-renovation branch to HEAD.

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

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

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.42 09-Jul-2007  ad branches: 1.42.8; 1.42.10; 1.42.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.41 04-Jul-2007  xtraeme s/cur_tre/edata/ => should fix the build error reported by rjs@.
 1.40 01-Jul-2007  xtraeme Use PSWITCH_EVENT_{PRESSED,RELEASED} for consistency with other drivers
using the sysmon_power framework.
 1.39 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.38 11-Apr-2007  macallan branches: 1.38.4;
clean up tadpole_request() API
from mrg
 1.37 04-Mar-2007  christos branches: 1.37.2; 1.37.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.36 04-Jan-2007  elad branches: 1.36.2;
Consistent usage of KAUTH_GENERIC_ISSUSER.
 1.35 23-Jul-2006  ad branches: 1.35.4;
Use the LWP cached credentials where sane.
 1.34 14-May-2006  elad integrate kauth.
 1.33 20-Apr-2006  blymn Prefix iostat structure elements with io_
 1.32 14-Apr-2006  blymn Make i/o statistics collection more generic, include tape drives and
nfs mounts in the set of devices that statistics will be reported on.
 1.31 08-Mar-2006  macallan branches: 1.31.2;
report lid and AC power state to sysmon
 1.30 06-Mar-2006  macallan branches: 1.30.2;
- use a lock to serialize tadpole_request()
- add a callback to signal monitor detection on the external VGA port
- don't call tadpole-request() in interrupt context
- use a kernel thread for various not time-critical work like device
monitoring, LCD status updates, external event handling and so on
(the monitoring stuff is preliminary and to be replaced by a more generic API)
 1.29 11-Dec-2005  christos branches: 1.29.4; 1.29.6; 1.29.8;
merge ktrace-lwp.
 1.28 16-Nov-2005  uwe ANSIify function declarations/defintions. Use uint<N>_t.
Drop trailing whitespace.
Same binary code is produced for GENERIC.MP + KGDB + DDB.
 1.27 06-Jul-2005  macallan branches: 1.27.6;
changed envsys support to use the sysmon API, added support for the power
button ( see powerd(8) )
 1.26 13-Feb-2004  wiz branches: 1.26.16;
Uppercase CPU, plural is CPUs.
 1.25 15-Jul-2003  lukem __KERNEL_RCSID()
 1.24 29-Jun-2003  fvdl branches: 1.24.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.23 29-Jun-2003  darrenr More changes for providing lwpid for ktrace (sparc GENERIC built)
 1.22 10-Dec-2002  pk Remove the `flags' argument from bus_intr_establish().
 1.21 26-Nov-2002  christos si_ -> sel_
 1.20 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.19 14-Oct-2002  takemura Moved MI APM definitions into dev/apm.
 1.18 02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.17 01-Oct-2002  thorpej Use CFATTACH_DECL().
 1.16 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.15 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.14 11-Mar-2002  pk branches: 1.14.4;
* `bus_type_t' is gone.
* Use BUS_ADDR() where appropriate to encode I/O space and physical
address offset into a `bus_addr_t' value.
* Drop obio_bus_map() since it's now completely equivalent to bus_space_map()
* Use bus_space_map2() to map device space at a fixed virtual address.
* Remove the virtual address argument from sbus_sbus_addr()
 1.13 20-Aug-2001  wiz branches: 1.13.2; 1.13.6;
"wierd" is weird.
 1.12 25-Jul-2000  toddpw branches: 1.12.4;
Ignore all undefined bits in the Tadpole microcontroller status register.
Only the low nibble is defined, and on at least one 3gx (mine) there is an
undefined bit which reads as a one -- bit 6 (0x40). This screwed tctrl_intr()
which would loop forever, thinking it always had new events to process.
 1.11 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.10 04-Jun-2000  cgd branches: 1.10.2;
Implement the more flexiable `evcnt' interface as discussed (briefly) on
tech-kern and now documented in evcnt(9).
 1.9 04-Apr-2000  thorpej branches: 1.9.2;
Fix fallout from callout.
 1.8 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.7 14-Mar-2000  jdc Add port power management ioctls.
 1.6 09-Mar-2000  garbled New features:
tctrl now initializes the state of the internal LCD icons. The icons
are unprogrammed at boot time. This incidentally makes the DC-POWER icon
work.

Fixes:
Fix my stupidity in the ENVSYS stuff, and actually follow the API.
 1.5 17-Dec-1999  garbled avoid uninterruptable sleep on a CMD_REQ ioctl.
 1.4 15-Dec-1999  garbled add <machine/tctrl.h> where needed.
Add some undocumented commands to the ts102 registers file, and fix a few
typos.

Modifications to tctrl.c:

Add entrypoints to driver for open/close/ioctl/poll.
Make device work with apmd. (still no support for suspend/sleep)
Make device work with ENVSYS API.
Slightly restructure handling of events.
Add function to make microcontroller requests.
 1.3 21-Nov-1999  pk Check presence of Sbus interrupt properties before using them.
 1.2 11-Aug-1999  matt branches: 1.2.2; 1.2.8;
This now works properly and uses interrupts. If you close the lid, the
screen will turn off and when you open the lid screen turns on. If you
do too rapidly, the driver won't be notified but you can press the micro
switch and it will come back. Also "halt -p" now works so you don't
have to do Pause-P to powerdown.
 1.1 09-Aug-1999  matt Add a driver for the Tadpole SPARCbook microcontroller. It doesn't
do much yet (except for power down support). As sson as I figure
out to get its interrupts enabled, it will be much more functional.
(e.g., print console messages on low power warnings, be able to turn
off the TFT, etc.).
 1.2.8.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 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.9.2.1 22-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.10.2.2 26-Jul-2000  toddpw Pull up tctrl.c 1.12, and ts102reg.h 1.6 (both requested by toddpw):
Prevent kernel freeze during boot on some Sparcbook 3gx's (namely, mine).
Sparc "tctrl0" device was sensitive to undefined bits in the hardware.
 1.10.2.1 19-Jul-2000  mrg pull up sparc/sparc64 bus_intr_establish() changes, necessary for sparc64
(originally done by pk, approved by thorpej):

>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.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.12.4.5 02-Oct-2002  jdolecek do not need the (void *) cast for kn_hook anymore
 1.12.4.4 18-Jun-2002  jdolecek make compile
 1.12.4.3 16-Mar-2002  jdolecek Catch up with -current.
 1.12.4.2 09-Sep-2001  thorpej Add kqueue support (not yet compiled).
 1.12.4.1 25-Aug-2001  thorpej Merge Aug 24 -current into the kqueue branch.
 1.13.6.6 11-Dec-2002  thorpej Sync with HEAD.
 1.13.6.5 11-Nov-2002  nathanw Catch up to -current
 1.13.6.4 18-Oct-2002  nathanw Catch up to -current.
 1.13.6.3 17-Sep-2002  nathanw Catch up to -current.
 1.13.6.2 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.13.6.1 20-Aug-2001  nathanw file tctrl.c was added on branch nathanw_sa on 2002-04-01 07:42:43 +0000
 1.13.2.1 10-Oct-2001  fvdl Convert all remaining devices.
 1.14.4.1 17-May-2002  gehenna Add device switch.
 1.24.2.6 11-Dec-2005  christos Sync with head.
 1.24.2.5 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.24.2.4 04-Feb-2005  skrll Adapt to branch.
 1.24.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.24.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.24.2.1 03-Aug-2004  skrll Sync with HEAD
 1.26.16.7 17-Mar-2008  yamt sync with head.
 1.26.16.6 27-Feb-2008  yamt sync with head.
 1.26.16.5 07-Dec-2007  yamt sync with head
 1.26.16.4 03-Sep-2007  yamt sync with head.
 1.26.16.3 26-Feb-2007  yamt sync with head.
 1.26.16.2 30-Dec-2006  yamt sync with head.
 1.26.16.1 21-Jun-2006  yamt sync with head.
 1.27.6.1 22-Nov-2005  yamt sync with head.
 1.29.8.3 11-Aug-2006  yamt sync with head
 1.29.8.2 24-May-2006  yamt sync with head.
 1.29.8.1 13-Mar-2006  yamt sync with head.
 1.29.6.2 01-Jun-2006  kardel Sync with head.
 1.29.6.1 22-Apr-2006  simonb Sync with head.
 1.29.4.1 09-Sep-2006  rpaulo sync with head
 1.30.2.5 13-May-2006  elad sprinkle some #include <sys/kauth.h> in files that use kauth kpi but
don't include it yet. hopefully this will prevent some fallout.
 1.30.2.4 11-May-2006  elad sync with head
 1.30.2.3 19-Apr-2006  elad sync with head - hopefully this will work
 1.30.2.2 10-Mar-2006  elad generic_authorize() -> kauth_authorize_generic().
 1.30.2.1 08-Mar-2006  elad Adapt to kernel authorization KPI.

I expect *some* lossage here...
 1.31.2.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.35.4.1 12-Jan-2007  ad Sync with head.
 1.36.2.2 15-Apr-2007  yamt sync with head.
 1.36.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.37.4.1 11-Jul-2007  mjf Sync with head.
 1.37.2.3 03-Dec-2007  ad Sync with HEAD.
 1.37.2.2 15-Jul-2007  ad Sync with head.
 1.37.2.1 27-May-2007  ad Sync with head.
 1.38.4.1 03-Oct-2007  garbled Sync with HEAD
 1.42.14.1 18-Nov-2007  bouyer Sync with HEAD
 1.42.10.3 23-Mar-2008  matt sync with HEAD
 1.42.10.2 09-Jan-2008  matt sync with HEAD
 1.42.10.1 06-Nov-2007  matt sync with HEAD
 1.42.8.1 21-Nov-2007  joerg Sync with HEAD.
 1.43.2.2 18-Feb-2008  mjf Sync with HEAD.
 1.43.2.1 19-Nov-2007  mjf Sync with HEAD.
 1.45.6.4 28-Sep-2008  mjf Sync with HEAD.
 1.45.6.3 29-Jun-2008  mjf Sync with HEAD.
 1.45.6.2 02-Jun-2008  mjf Sync with HEAD.
 1.45.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.45.2.1 24-Mar-2008  keiichi sync with head.
 1.46.4.3 11-Mar-2010  yamt sync with head
 1.46.4.2 04-May-2009  yamt sync with head.
 1.46.4.1 16-May-2008  yamt sync with head.
 1.46.2.2 17-Jun-2008  yamt sync with head.
 1.46.2.1 18-May-2008  yamt sync with head.
 1.47.4.2 18-Jul-2008  simonb Sync with head.
 1.47.4.1 18-Jun-2008  simonb Sync with head.
 1.47.2.2 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.47.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.48.2.1 19-Oct-2008  haad Sync with HEAD.
 1.50.10.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.53.6.1 05-Apr-2012  mrg sync to latest -current.
 1.53.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.53.2.2 30-Oct-2012  yamt sync with head
 1.53.2.1 17-Apr-2012  yamt sync with head
 1.55.2.3 03-Dec-2017  jdolecek update from HEAD
 1.55.2.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.55.2.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.56.2.1 18-May-2014  rmind sync with head
 1.58.2.1 10-Aug-2014  tls Rebase.
 1.59.8.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.59.4.1 05-Feb-2017  skrll Sync with HEAD
 1.62.2.1 03-Apr-2021  thorpej Sync with HEAD.
 1.8 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.7 11-Apr-2007  macallan branches: 1.7.34; 1.7.36; 1.7.38;
clean up tadpole_request() API
from mrg
 1.6 04-Mar-2007  christos branches: 1.6.2; 1.6.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.5 06-Mar-2006  macallan branches: 1.5.18;
- use a lock to serialize tadpole_request()
- add a callback to signal monitor detection on the external VGA port
- don't call tadpole-request() in interrupt context
- use a kernel thread for various not time-critical work like device
monitoring, LCD status updates, external event handling and so on
(the monitoring stuff is preliminary and to be replaced by a more generic API)
 1.4 16-Nov-2005  uwe branches: 1.4.4; 1.4.6; 1.4.8;
ANSIify function declarations/defintions. Use uint<N>_t.
Drop trailing whitespace.
Same binary code is produced for GENERIC.MP + KGDB + DDB.
 1.3 09-Mar-2000  garbled branches: 1.3.28; 1.3.44; 1.3.52;
New features:
tctrl now initializes the state of the internal LCD icons. The icons
are unprogrammed at boot time. This incidentally makes the DC-POWER icon
work.

Fixes:
Fix my stupidity in the ENVSYS stuff, and actually follow the API.
 1.2 15-Dec-1999  garbled add <machine/tctrl.h> where needed.
Add some undocumented commands to the ts102 registers file, and fix a few
typos.

Modifications to tctrl.c:

Add entrypoints to driver for open/close/ioctl/poll.
Make device work with apmd. (still no support for suspend/sleep)
Make device work with ENVSYS API.
Slightly restructure handling of events.
Add function to make microcontroller requests.
 1.1 09-Aug-1999  matt branches: 1.1.2; 1.1.8;
Add a driver for the Tadpole SPARCbook microcontroller. It doesn't
do much yet (except for power down support). As sson as I figure
out to get its interrupts enabled, it will be much more functional.
(e.g., print console messages on low power warnings, be able to turn
off the TFT, etc.).
 1.1.8.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.1.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.3.52.1 22-Nov-2005  yamt sync with head.
 1.3.44.2 03-Sep-2007  yamt sync with head.
 1.3.44.1 21-Jun-2006  yamt sync with head.
 1.3.28.1 11-Dec-2005  christos Sync with head.
 1.4.8.1 13-Mar-2006  yamt sync with head.
 1.4.6.1 22-Apr-2006  simonb Sync with head.
 1.4.4.1 09-Sep-2006  rpaulo sync with head
 1.5.18.2 15-Apr-2007  yamt sync with head.
 1.5.18.1 12-Mar-2007  rmind Sync with HEAD.
 1.6.4.1 11-Jul-2007  mjf Sync with head.
 1.6.2.1 27-May-2007  ad Sync with head.
 1.7.38.1 16-May-2008  yamt sync with head.
 1.7.36.1 18-May-2008  yamt sync with head.
 1.7.34.1 02-Jun-2008  mjf Sync with HEAD.
 1.21 22-Aug-2000  pk Use the framebuffer drivers & header files that now live in /sys/dev/sun.
 1.20 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.19 29-Jun-2000  mrg remove include of <vm/vm.h> and <machine/pmap.h>. <vm/vm.h> -> <uvm/uvm_extern.h>
 1.18 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.17 04-Apr-2000  pk branches: 1.17.4;
Use copyin/copyout to get a colormap from/to user space.
Also, prepare for the case of a colormap maintained in kernel space.
 1.16 19-Mar-2000  pk Use fb_is_console(); retract fbconstty & fbnode from service.
 1.15 27-Aug-1999  hannken branches: 1.15.2;
Remove now unused variable `i'.
 1.14 26-Aug-1999  thorpej Initialize the default colormap to 0 == black, all others == full white.
 1.13 29-Jul-1998  pk We no longer need to get the register sets by ourselves.
 1.12 07-Apr-1998  pk bus_space_mmap() has changed to take a `bus_space_handle_t *' argument,
like other bus space methods.
 1.11 21-Mar-1998  pk Account for changed bus attachment scheme.
 1.10 12-Jan-1998  thorpej Update for changes to config.
 1.9 09-Oct-1997  jtc Fix tipo inherited from old version of TNF copyright template.
 1.8 29-Jul-1997  fair branches: 1.8.2;
%x -> 0x%x
 1.7 24-May-1997  pk Remove all `bustype' arguments from map[io]dev() and REG2PHYS().
 1.6 10-Dec-1996  pk Comply with recent autoconfiguration changes. Diffs graciously
supplied by Chris Demetriou.
 1.5 13-Oct-1996  christos backout previous kprintf change
 1.4 11-Oct-1996  christos printf -> kprintf, sprintf -> ksprintf
 1.3 04-Oct-1996  thorpej Use FBTYPE_RESERVED3 for our `unknown' fbtype ... RESERVED1 seems to
have disappeared.
 1.2 04-Oct-1996  thorpej Returning ENODEV is not correct in a poll entry point. Instead, since
read/write returns an error, use seltrue().
 1.1 19-Jun-1996  pk First go at a TCX framebuffer driver. This version does enough to
load and store colour lookup tables
blank the screen / put monitor in power-saving mode
make X11 run on it in `cgthree' emulation.
 1.8.2.1 14-Oct-1997  thorpej Update marc-pcmcia branch from trunk.
 1.15.2.1 20-Nov-2000  bouyer Remove files that are no longer on the trunck
 1.17.4.2 19-Jul-2000  mrg pull up sparc/sparc64 bus_intr_establish() changes, necessary for sparc64
(originally done by pk, approved by thorpej):

>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.17.4.1 30-Jun-2000  simonb Pull up mmap paddr_t/off_t changes from trunk.
 1.3 22-Aug-2000  pk Use the framebuffer drivers & header files that now live in /sys/dev/sun.
 1.2 09-Oct-1997  jtc branches: 1.2.16;
Fix tipo inherited from old version of TNF copyright template.
 1.1 19-Jun-1996  pk branches: 1.1.10;
First go at a TCX framebuffer driver. This version does enough to
load and store colour lookup tables
blank the screen / put monitor in power-saving mode
make X11 run on it in `cgthree' emulation.
 1.1.10.1 14-Oct-1997  thorpej Update marc-pcmcia branch from trunk.
 1.2.16.1 20-Nov-2000  bouyer Remove files that are no longer on the trunck
 1.22 20-Dec-2023  thorpej Remove unnecessary <sys/malloc.h>.
 1.21 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.20 11-Jun-2021  jdc branches: 1.20.2;
During slot enable and disable, make sure that the card Access and VCC
controls are enabled and disabled at the same time.
Also remove the software reset during slot enable (we are already in
reset because of the earlier Access and VCC changes).
While here, convert DELAY() to delay() and tsleep(), like nell(4).
 1.19 24-Apr-2021  thorpej branches: 1.19.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.18 19-Oct-2013  mrg branches: 1.18.44;
- remove unused but set variables.
- use __USE() where necessary.
- remove useless 'volatile' markers

kd.c:consinit() might be wrong for old proms, but i've not
changed it really.
 1.17 27-Oct-2012  chs branches: 1.17.2;
split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.16 26-Jul-2011  dyoung branches: 1.16.2; 1.16.12;
Don't set the iobase and iosize members of pcmciabus_attach_args because
they're not used in any meaningful way.
 1.15 01-Jul-2011  dyoung #include <sys/bus.h> instead of <machine/bus.h>.
 1.14 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.13 04-Aug-2008  macallan fix another botched device_t-ification
 1.12 17-May-2008  macallan branches: 1.12.4;
struct device * -> device_t
 1.11 17-May-2008  macallan cosmetics:
- finally add my copyright, almost 3 year after the fact
- remove a comment that never applied to the NetBSD port of this driver,
only the OpenBSD version
 1.10 03-Dec-2007  ad branches: 1.10.14; 1.10.16; 1.10.18; 1.10.20;
Interrupt handling changes, in discussion since February:

- Reduce available SPL levels for hardware devices to none, vm, sched, high.
- Acquire kernel_lock only for interrupts at IPL_VM.
- Implement threaded soft interrupts.
 1.9 17-Oct-2007  garbled branches: 1.9.2;
Merge the ppcoea-renovation branch to HEAD.

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

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

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.8 09-Jul-2007  ad branches: 1.8.8; 1.8.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.7 06-Mar-2006  macallan branches: 1.7.10; 1.7.24; 1.7.26; 1.7.32;
- use a lock to serialize tadpole_request()
- add a callback to signal monitor detection on the external VGA port
- don't call tadpole-request() in interrupt context
- use a kernel thread for various not time-critical work like device
monitoring, LCD status updates, external event handling and so on
(the monitoring stuff is preliminary and to be replaced by a more generic API)
 1.6 04-Mar-2006  uwe branches: 1.6.2;
s/u_intN_t/uintN_t/
 1.5 16-Nov-2005  macallan branches: 1.5.4; 1.5.6;
- ansify
- pick some KNF nits
- remove trailing whitespaces
- remove some useless commented out code
 1.4 14-Nov-2005  uwe Make this compile with DEBUG.
 1.3 13-Jul-2005  macallan branches: 1.3.6; 1.3.8;
fixed a glitch that would trigger a warning when compiled without tctrl.
Doesn't make much sense since tctrl is on the same chip but anyway.
 1.2 06-Jul-2005  macallan forgot the $NetBSD header
 1.1 06-Jul-2005  macallan Add support for the TS102 PCMCIA controller found in SPARCbooks
 1.3.8.1 22-Nov-2005  yamt sync with head.
 1.3.6.3 11-Dec-2005  christos Sync with head.
 1.3.6.2 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.3.6.1 13-Jul-2005  skrll file ts102.c was added on branch ktrace-lwp on 2005-11-10 13:58:55 +0000
 1.5.6.1 22-Apr-2006  simonb Sync with head.
 1.5.4.1 09-Sep-2006  rpaulo sync with head
 1.6.2.1 13-Mar-2006  yamt sync with head.
 1.7.32.1 03-Oct-2007  garbled Sync with HEAD
 1.7.26.1 11-Jul-2007  mjf Sync with head.
 1.7.24.2 03-Dec-2007  ad Sync with HEAD.
 1.7.24.1 15-Jul-2007  ad Sync with head.
 1.7.10.4 07-Dec-2007  yamt sync with head
 1.7.10.3 03-Sep-2007  yamt sync with head.
 1.7.10.2 21-Jun-2006  yamt sync with head.
 1.7.10.1 06-Mar-2006  yamt file ts102.c was added on branch yamt-lazymbuf on 2006-06-21 14:55:54 +0000
 1.8.10.2 09-Jan-2008  matt sync with HEAD
 1.8.10.1 06-Nov-2007  matt sync with HEAD
 1.8.8.1 09-Dec-2007  jmcneill Sync with HEAD.
 1.9.2.1 08-Dec-2007  mjf Sync with HEAD.
 1.10.20.2 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.10.20.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.10.18.2 11-Mar-2010  yamt sync with head
 1.10.18.1 04-May-2009  yamt sync with head.
 1.10.16.1 18-May-2008  yamt sync with head.
 1.10.14.2 28-Sep-2008  mjf Sync with HEAD.
 1.10.14.1 02-Jun-2008  mjf Sync with HEAD.
 1.12.4.1 19-Oct-2008  haad Sync with HEAD.
 1.16.12.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.16.12.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.16.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.16.2.1 30-Oct-2012  yamt sync with head
 1.17.2.1 18-May-2014  rmind sync with head
 1.18.44.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.2.1 17-Jun-2021  thorpej Sync w/ HEAD.
 1.20.2.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.12 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.11 06-Mar-2006  macallan branches: 1.11.66; 1.11.68; 1.11.70;
- use a lock to serialize tadpole_request()
- add a callback to signal monitor detection on the external VGA port
- don't call tadpole-request() in interrupt context
- use a kernel thread for various not time-critical work like device
monitoring, LCD status updates, external event handling and so on
(the monitoring stuff is preliminary and to be replaced by a more generic API)
 1.10 04-Mar-2006  uwe branches: 1.10.2;
s/u_intN_t/uintN_t/
 1.9 11-Dec-2005  christos branches: 1.9.4; 1.9.6;
merge ktrace-lwp.
 1.8 06-Jul-2005  macallan Add support for the TS102 PCMCIA controller found in SPARCbooks
 1.7 29-Sep-2002  wiz branches: 1.7.6; 1.7.22;
"definitions" has lots of 'i's, but that's not reason to leave one out.
 1.6 25-Jul-2000  toddpw branches: 1.6.4; 1.6.8;
Ignore all undefined bits in the Tadpole microcontroller status register.
Only the low nibble is defined, and on at least one 3gx (mine) there is an
undefined bit which reads as a one -- bit 6 (0x40). This screwed tctrl_intr()
which would loop forever, thinking it always had new events to process.
 1.5 09-Mar-2000  garbled branches: 1.5.4;
New features:
tctrl now initializes the state of the internal LCD icons. The icons
are unprogrammed at boot time. This incidentally makes the DC-POWER icon
work.

Fixes:
Fix my stupidity in the ENVSYS stuff, and actually follow the API.
 1.4 15-Dec-1999  garbled add <machine/tctrl.h> where needed.
Add some undocumented commands to the ts102 registers file, and fix a few
typos.

Modifications to tctrl.c:

Add entrypoints to driver for open/close/ioctl/poll.
Make device work with apmd. (still no support for suspend/sleep)
Make device work with ENVSYS API.
Slightly restructure handling of events.
Add function to make microcontroller requests.
 1.3 12-Nov-1999  matt add some stuff needed for pcmcia support
 1.2 11-Aug-1999  matt branches: 1.2.2; 1.2.4; 1.2.8;
This now works properly and uses interrupts. If you close the lid, the
screen will turn off and when you open the lid screen turns on. If you
do too rapidly, the driver won't be notified but you can press the micro
switch and it will come back. Also "halt -p" now works so you don't
have to do Pause-P to powerdown.
 1.1 09-Aug-1999  matt Add a driver for the Tadpole SPARCbook microcontroller. It doesn't
do much yet (except for power down support). As sson as I figure
out to get its interrupts enabled, it will be much more functional.
(e.g., print console messages on low power warnings, be able to turn
off the TFT, etc.).
 1.2.8.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.2.4.1 15-Nov-1999  fvdl Sync with -current
 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.5.4.1 26-Jul-2000  toddpw Pull up tctrl.c 1.12, and ts102reg.h 1.6 (both requested by toddpw):
Prevent kernel freeze during boot on some Sparcbook 3gx's (namely, mine).
Sparc "tctrl0" device was sensitive to undefined bits in the hardware.
 1.6.8.1 18-Oct-2002  nathanw Catch up to -current.
 1.6.4.1 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.7.22.1 21-Jun-2006  yamt sync with head.
 1.7.6.1 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.9.6.1 22-Apr-2006  simonb Sync with head.
 1.9.4.1 09-Sep-2006  rpaulo sync with head
 1.10.2.1 13-Mar-2006  yamt sync with head.
 1.11.70.1 16-May-2008  yamt sync with head.
 1.11.68.1 18-May-2008  yamt sync with head.
 1.11.66.1 02-Jun-2008  mjf Sync with HEAD.
 1.78 13-May-2024  msaitoh s/of of/of/ in comment.
 1.77 01-Dec-2023  thorpej Use vmem(9) rather than extent(9) to manage DVMA mappings.
 1.76 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.75 05-Dec-2021  msaitoh s/alloction/allocation/
 1.74 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.73 10-May-2021  thorpej branches: 1.73.4;
Associate the OpenBoot / OpenFirmware node with attached devices
at config_found() time.
 1.72 24-Apr-2021  thorpej branches: 1.72.2; 1.72.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.71 22-Nov-2020  thorpej branches: 1.71.2;
malloc(9) -> kmem(9) (easy, straight-forward cases only, for now)
 1.70 14-Jun-2020  chs branches: 1.70.2;
replace EX_NOWAIT with EX_WAITOK in device attach methods.
remove checks for failures that can no longer occur.
 1.69 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.68 27-Oct-2012  chs branches: 1.68.38;
split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.67 29-Jul-2012  matt branches: 1.67.2;
Fix more -fno-common fallout.
 1.66 27-Jan-2012  para converting extent(9) from malloc(9) to kmem(9)
preceding kmem-vmem-pool-uvm patch

releng@ acknowledged
 1.65 18-Jul-2011  mrg branches: 1.65.2; 1.65.6;
convert the remaining sparc drivers to CFATTACH_DECL_NEW/cfdata_t/device_t.
(cgsix_obio.c was only partially converted with the rest of the cgsix code
when it was changed some time ago.)
 1.64 01-Jul-2011  dyoung #include <sys/bus.h> instead of <machine/bus.h>.
 1.63 14-Jan-2011  rmind Retire struct user, remove sys/user.h inclusions. Note sys/user.h header
as obsolete. Remove USER_TO_UAREA/UAREA_TO_USER macros.

Various #include fixes and review by matt@.
 1.62 03-Jan-2010  mrg branches: 1.62.4;
add an explicit "bool mpsafe" to intr_establish(). only set it to true
for the sun4m timer/counter interrupts. this gets lev10/14 working again
on SMP systems, where those interrupts started taking the kernel lock and
hanging...
 1.61 21-Nov-2009  rmind Use lwp_getpcb() on sparc{64} and sun2/3 MD code, clean from struct user usage.
 1.60 20-Sep-2009  tsutsui - use device_t and cfdriver_t
- use device_private() and device_xname()
- use proper types or variables for device_t/softc
 1.59 19-Dec-2008  cegger use M_ZERO on malloc() and remove subsequent bzero().
 1.58 16-Dec-2008  christos replace bitmask_snprintf(9) with snprintb(3)
 1.57 28-Apr-2008  martin branches: 1.57.8;
Remove clause 3 and 4 from TNF licenses
 1.56 17-Oct-2007  garbled branches: 1.56.16; 1.56.18; 1.56.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.55 17-May-2007  yamt branches: 1.55.10;
merge yamt-idlelwp branch. asked by core@. some ports still needs work.

from doc/BRANCHES:

idle lwp, and some changes depending on it.

1. separate context switching and thread scheduling.
(cf. gmcgarry_ctxsw)
2. implement idle lwp.
3. clean up related MD/MI interfaces.
4. make scheduler(s) modular.
 1.54 04-Mar-2007  christos branches: 1.54.2; 1.54.4; 1.54.10;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.53 16-Nov-2005  uwe branches: 1.53.26;
ANSIify function declarations/defintions. Use uint<N>_t.
Propagate "static" to function definitions. Drop trailing whitespace.
Same binary code is produced for GENERIC.MP + KGDB + DDB.
 1.52 04-Jun-2005  tsutsui branches: 1.52.2; 1.52.8;
fkbyte() is in locore.s and accoring to its description it's used
only for work around unexplained transient bus errors when reading
the VME interrupt vector in vmeintr4m(), so change the prototype
declaration of fkbyte() in vmeintr4m() to appease gcc -Wcast-qual.
 1.51 13-Dec-2004  chs for drivers that support only one instance, use a global variable to ensure
that only one instance is configured rather than requiring that its
unit number be zero.
 1.50 27-Jun-2004  pk GC unsed sparc_vme_bus_tag.
 1.49 17-Mar-2004  pk Rename PROM_getprop*() => prom_getprop*().
 1.48 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.47 01-Aug-2003  pk Correct some `defined(SUN*)' inconsistencies.
 1.46 15-Jul-2003  lukem __KERNEL_RCSID()
 1.45 18-Jan-2003  thorpej branches: 1.45.2;
Merge the nathanw_sa branch.
 1.44 03-Jan-2003  mrg part one of bus_space(9) fixes to enable bus spaces to override the
bus_space_{read,write}_[1248]() functions, which will allow 16-bit
PCMCIA support to work without additional hacks in MI drivers.
this option is not enabled yet.
 1.43 28-Dec-2002  mrg update the vme bus_space_tag_t to reality.
 1.42 16-Dec-2002  pk The cache flush routines now take a CPU context parameter. This is going
to be necessary in SMP kernels.
 1.41 10-Dec-2002  pk bus_intr_establish() now takes an optional `fast trap' handler argument.
BUS_INTR_ESTABLISH_FASTTRAP and BUS_INTR_ESTABLISH_SOFTINTR are no longer used.
 1.40 06-Dec-2002  pk Pass the `device class interrupt level' on to intr_establish() and use to
raise the ipl in the interrupt handlers to the appropriate level. This avoids
interrupt handler interference if one of the devices actually interrupts at
a lower hardware level than the maximum level assined to a device class.

Based on code from Art Grabowski in openbsd.
 1.39 02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.38 01-Oct-2002  thorpej Use CFATTACH_DECL().
 1.37 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.36 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.35 11-Mar-2002  pk branches: 1.35.4; 1.35.6;
* `bus_type_t' is gone.
* Use BUS_ADDR() where appropriate to encode I/O space and physical
address offset into a `bus_addr_t' value.
* Drop obio_bus_map() since it's now completely equivalent to bus_space_map()
* Use bus_space_map2() to map device space at a fixed virtual address.
* Remove the virtual address argument from sbus_sbus_addr()
 1.34 26-Sep-2001  eeh branches: 1.34.4;
getprop* -> PROM_getprop*
 1.33 24-Sep-2001  eeh Change bus_space_mmap() signature to the official one.
 1.32 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.31 24-Apr-2001  thorpej branches: 1.31.2; 1.31.4;
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.30 04-Jul-2000  pk branches: 1.30.2;
Report spurious VME interrupts only #ifdef DEBUG for now. The i82586
based `ie1' board seems to cause this for no apparent reason.
 1.29 29-Jun-2000  mrg remove include of <vm/vm.h> and <machine/pmap.h>. <vm/vm.h> -> <uvm/uvm_extern.h>
 1.28 27-Jun-2000  pk VME/IOMMU DMA load must also relocate DVMA addresses to the start of VME space.
 1.27 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.26 25-Jun-2000  pk Implement vme_dmamap_create/vme_dmamap_destroy, which allows us to
select the appropriate DVMA subrange for VME devices.
 1.25 18-Jun-2000  pk branches: 1.25.2;
vme4_dmamap_[un]load: ensure enough DVMA space is allocated to cover the
buffer and store that amount in the DMA map to avoid re-computation.
Also add a cache flush as the bus_dmamap_sync() don't do that yet.
 1.24 04-Jun-2000  cgd Implement the more flexiable `evcnt' interface as discussed (briefly) on
tech-kern and now documented in evcnt(9).
 1.23 09-May-2000  pk branches: 1.23.2;
The bus_dma(9) implementation now allocates DVMA addresses in
bus_dmamap_load_*() routines only. Note that DMA memory buffers
allocated with bus_dmamem_alloc() _must_ be loaded by bus_dmamap_load_raw().
 1.22 11-Jan-2000  pk Remove old-style boot device recognition.
 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 30-Jun-1999  drochner update for new VME framework
 1.18 14-Apr-1999  pk Initialize the VME bus tag.
 1.17 26-Mar-1999  mycroft branches: 1.17.2;
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.16 08-Feb-1999  fvdl Make this compile for SUN4 only.
 1.15 15-Jan-1999  pk Sanity check from Matthias Drochner.
 1.14 19-Sep-1998  pk Provide an error entry point like sbus and memory.
 1.13 30-Aug-1998  pk getpropA() => getprop().
 1.12 23-Aug-1998  pk Move sparc_vme_dmamem_map() outside `#ifdef SUN4M'
 1.11 23-Aug-1998  pk Rename DVMA constants.
 1.10 20-Aug-1998  pk Flesh out more of the sun4 busdma functions.
 1.9 30-Jul-1998  pk Adapt to changes in the base bus_dma* functions.
 1.8 30-Jul-1998  pk Get to DMA map functions through parent tag, instead of calling some base
functions directly.
 1.7 07-Apr-1998  pk branches: 1.7.2;
Use bus space methods to implement the vme bus space functions.
 1.6 21-Mar-1998  pk Account for bus_space(9)-style bus attachment scheme.
 1.5 06-Feb-1998  pk vme_bus_probe() takes an `offset' argument.
 1.4 04-Feb-1998  thorpej Add offset and length parameters to bus_dmamap_sync(), used for specifiying
partial syncs of a DMA mapping.
 1.3 04-Feb-1998  thorpej Change the last argument of bus_dmamap_sync() from bus_dmasync_op_t to int,
and allow more than one synchronization operation to be specified in
a single call. Dissallow mixing of PRE and POST operations.
 1.2 04-Feb-1998  pk sparc_vme_probe(): handle callback argument.
 1.1 25-Jan-1998  pk sparc/VME bus implementation.
 1.7.2.1 08-Aug-1998  eeh Revert cdevsw mmap routines to return int.
 1.17.2.1 14-Apr-1999  pk branches: 1.17.2.1.2;
Pull up rev. 1.18 from trunk.
 1.17.2.1.2.3 02-Aug-1999  thorpej Update from trunk.
 1.17.2.1.2.2 01-Jul-1999  thorpej Sync w/ -current.
 1.17.2.1.2.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.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.23.2.1 22-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.25.2.2 22-Jul-2000  pk Pull up revisions 1.26,1.28,1.30.

revision 1.26
Implement vme_dmamap_create/vme_dmamap_destroy, which allows us to
select the appropriate DVMA subrange for VME devices.

revision 1.28
VME/IOMMU DMA load must also relocate DVMA addresses to the start of VME space.

revision 1.30
Report spurious VME interrupts only #ifdef DEBUG for now. The i82586
based `ie1' board seems to cause this for no apparent reason.
 1.25.2.1 30-Jun-2000  simonb Pull up mmap paddr_t/off_t changes from trunk.
 1.30.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.31.4.1 01-Oct-2001  fvdl Catch up with -current.
 1.31.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.31.2.4 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.31.2.3 16-Mar-2002  jdolecek Catch up with -current.
 1.31.2.2 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.31.2.1 13-Sep-2001  thorpej Update the kqueue branch to HEAD.
 1.34.4.10 03-Jan-2003  thorpej Sync with HEAD (again).
 1.34.4.9 29-Dec-2002  thorpej Sync with HEAD.
 1.34.4.8 19-Dec-2002  thorpej Sync with HEAD.
 1.34.4.7 11-Dec-2002  thorpej Sync with HEAD.
 1.34.4.6 18-Oct-2002  nathanw Catch up to -current.
 1.34.4.5 27-Aug-2002  nathanw Catch up to -current.
 1.34.4.4 24-Jun-2002  nathanw Curproc->curlwp renaming.

Change uses of "curproc->l_proc" back to "curproc", which is more like the
original use. Bare uses of "curproc" are now "curlwp".

"curproc" is now #defined in proc.h as ((curlwp) ? (curlwp)->l_proc) : NULL)
so that it is always safe to reference curproc (*de*referencing curproc
is another story, but that's always been true).
 1.34.4.3 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.34.4.2 20-Nov-2001  pk Convert to SA framework.
 1.34.4.1 26-Sep-2001  pk file vme_machdep.c was added on branch nathanw_sa on 2001-11-20 16:29:52 +0000
 1.35.6.1 22-Nov-2002  tron Pull up revision 1.36 (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.35.4.1 31-Aug-2002  gehenna catch up with -current.
 1.45.2.6 11-Dec-2005  christos Sync with head.
 1.45.2.5 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.45.2.4 18-Dec-2004  skrll Sync with HEAD.
 1.45.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.45.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.45.2.1 03-Aug-2004  skrll Sync with HEAD
 1.52.8.1 22-Nov-2005  yamt sync with head.
 1.52.2.2 03-Sep-2007  yamt sync with head.
 1.52.2.1 21-Jun-2006  yamt sync with head.
 1.53.26.2 28-Apr-2007  mrg port yamt-idlelwp to sparc. this does not work yet, but others have
asked that i commit this work-in-progress.

currently kernel threads end up running with PSR_S missing from %psr
and end up failing to dump a user corefile.
 1.53.26.1 12-Mar-2007  rmind Sync with HEAD.
 1.54.10.1 22-May-2007  matt Update to HEAD.
 1.54.4.1 11-Jul-2007  mjf Sync with head.
 1.54.2.1 27-May-2007  ad Sync with head.
 1.55.10.1 06-Nov-2007  matt sync with HEAD
 1.56.20.3 11-Mar-2010  yamt sync with head
 1.56.20.2 04-May-2009  yamt sync with head.
 1.56.20.1 16-May-2008  yamt sync with head.
 1.56.18.1 18-May-2008  yamt sync with head.
 1.56.16.2 17-Jan-2009  mjf Sync with HEAD.
 1.56.16.1 02-Jun-2008  mjf Sync with HEAD.
 1.57.8.1 19-Jan-2009  skrll Sync with HEAD.
 1.62.4.1 05-Mar-2011  rmind sync with head
 1.65.6.1 18-Feb-2012  mrg merge to -current.
 1.65.2.2 30-Oct-2012  yamt sync with head
 1.65.2.1 17-Apr-2012  yamt sync with head
 1.67.2.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.68.38.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.70.2.1 14-Dec-2020  thorpej Sync w/ HEAD.
 1.71.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.72.4.1 31-May-2021  cjep sync with head
 1.72.2.1 13-May-2021  thorpej Sync with HEAD.
 1.73.4.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.8 10-Mar-2024  rillig sparc/vmereg: fix snprintb format VMEBUS_AFSR_BITS
 1.7 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.6 16-Nov-2005  uwe branches: 1.6.74; 1.6.76; 1.6.78;
ANSIify function declarations/defintions. Use uint<N>_t.
Propagate "static" to function definitions. Drop trailing whitespace.
Same binary code is produced for GENERIC.MP + KGDB + DDB.
 1.5 19-Sep-1998  pk branches: 1.5.46; 1.5.62; 1.5.70;
Add %b format strings.
 1.4 05-Sep-1998  pk Assign my copyrights to TNF.
 1.3 25-Jan-1998  pk sparc/VME bus implementation.
 1.2 07-Jun-1997  pk Add some VME address modifiers used by vmebus_translate().
 1.1 18-May-1997  pk A bit of framework for sun4m VME busses.
 1.5.70.1 22-Nov-2005  yamt sync with head.
 1.5.62.1 21-Jun-2006  yamt sync with head.
 1.5.46.1 11-Dec-2005  christos Sync with head.
 1.6.78.1 16-May-2008  yamt sync with head.
 1.6.76.1 18-May-2008  yamt sync with head.
 1.6.74.1 02-Jun-2008  mjf Sync with HEAD.
 1.2 21-Jul-1994  mycroft Clean up deleted files.
 1.1 02-Oct-1993  deraadt Chris Torek's sparc port. Missing lots of things.
 1.2 27-Jul-1998  pk These files are now in <dev/sbus>.
 1.1 18-Apr-1998  pk Skeleton code for the SBus expander box.
 1.2 27-Jul-1998  pk These files are now in <dev/sbus>.
 1.1 18-Apr-1998  pk Skeleton code for the SBus expander box.
 1.39 25-Jan-1998  pk These drivers are now in dev/vme.
The `ie' driver has been split in a VME and OBIO front-end. The latter
lives on in this directory as `if_ie_obio.c'
 1.38 12-Jan-1998  thorpej Update for changes to config.
 1.37 29-Jul-1997  fair %x -> 0x%x
 1.36 19-Jul-1997  pk #include "locators.h"
 1.35 17-Jul-1997  jtk use locator defines in "locators.h" to index cf_loc[]
 1.34 24-Jun-1997  thorpej foosize()'s return value is in DEV_BSIZE units; adjust the size obtained
from the disklabel accordingly.
 1.33 18-Jun-1997  pk xdsize(): only call xdopen()/xdclose() if not already open, per the
current `openmask'.
 1.32 10-Jun-1997  pk Avoid "false positives" in match routines.
 1.31 24-May-1997  pk Remove all `bustype' arguments from map[io]dev() and REG2PHYS().
 1.30 10-Mar-1997  pk Replace `cpumod' with `cpuinfo.cpu_type' equivalents.
 1.29 10-Dec-1996  pk branches: 1.29.6;
Comply with recent autoconfiguration changes. Diffs graciously
supplied by Chris Demetriou.
 1.28 13-Oct-1996  christos backout previous kprintf change
 1.27 11-Oct-1996  christos printf -> kprintf, sprintf -> ksprintf
 1.26 12-Aug-1996  chuck repair XDC_HWAIT macro to handle the fact that waithead is now
unsigned. should fix xdc watchdog timeouts noted in port-sparc
by nathanw@mit.edu.
 1.25 22-Apr-1996  christos branches: 1.25.4;
Remove dependency on <sys/cpu.h>
 1.24 10-Apr-1996  pk `bootdv' is gone. Instead, set the device pointer in the `struct bootpath'
that is passed in the attach arguments.
 1.23 01-Apr-1996  christos Eliminated dependencies on dev_conf.h
 1.22 31-Mar-1996  pk Various cleanup; mostly trailing spaces/tabs.
 1.21 17-Mar-1996  thorpej New device attachment scheme:

- split softc size and match/attach out from cfdriver into
a new struct cfattach.

- new "attach" directive for files.*. May specify the name of
the cfattach structure, so that devices may be easily attached
to parents with different autoconfiguration semantics.
 1.20 16-Mar-1996  christos cast argument to probeget()
 1.19 14-Mar-1996  christos Bring prototypes into scope and fix compiler warnings.
 1.18 04-Mar-1996  chuck Fix two bugs reported by Don Koch <aardvark@poirot.krl.com> (PR#2169).
[1] check return value from malloc() for NULL before trying to bzero it.
[2] use "=" rather than "|=" when writing to CSR (otherwise you may
ACK something you don't mean to!).
 1.17 25-Feb-1996  pk Use CPU-type macros
 1.16 22-Feb-1996  thorpej Fixup some RCS ids.
 1.15 08-Feb-1996  chuck - moved disk_busy() call from xdstrategy() to xdc_startbuf()
[prevents disk_unbusy panic when disk is loaded (if no
free IOPBs, xdstrategy() would queue the buffer for pickup
by xdcintr() but xdcintr() would never call disk_busy().
xdc_startbuf() is a better place since all bufs are routed
through here] problem detected by girish@dworkin.wustl.edu,
diagnosed and corrected by me.
- move disk_unbusy() call in xdc_remove_iorq() before the call to
XDC_FREE() [don't want to access a data structure that was just put
on a free list]
 1.14 13-Jan-1996  chuck - call mapiodev() with sizeof(struct xdc) rather than ra_len (which is
zero since xdcmatch no longer sets it). [if you call mapiodev()
with a zero size it will reuse the KVA it returns, swiping the device
out from under you!]
- make xdc->iopbase point in the kernels DVMA space rather than at the
normal malloc'd KVA. this isn't compatable with sun4m [doesn't
have a kernel DVMA space] and will need to be changed later (XXX).
- move disk_attach() to before reading the disk label as per Jason.
otherwise we are reading into an unallocated buffer (oops!)
 1.13 12-Jan-1996  chuck nuke uneeded variable in match function.
 1.12 12-Jan-1996  chuck we no longer need to add in the offset to the mapped VA to get the correct
device address (bus_tmp, bus_map, and mapiodev now do this for us).

also, we handle all our mappings, so don't have obio.c do any for us
(i.e. don't set ra->ra_len in xdcmatch).
 1.11 07-Jan-1996  thorpej New generic disk framework. Highlights:

- New metrics handling. Metrics are now kept in the new
`struct disk'. Busy time is now stored as a timeval, and
transfer count in bytes.

- Storage for disklabels is now dynamically allocated, so that
the size of the disk structure is not machine-dependent.

- Several new functions for attaching and detaching disks, and
handling metrics calculation.

Old-style instrumentation is still supported in drivers that did it before.
However, old-style instrumentation is being deprecated, and will go away
once the userland utilities are updated for the new framework.

For usage and architectural details, see the forthcoming disk(9) manual
page.
 1.10 11-Dec-1995  pk Adapt to changed mapiodev() interface.
Use new DVMA routines.
 1.9 25-Sep-1995  chuck minor cleanups:
- don't let pcyl go unassigned if we have a non-sunos disklabel.
if nothing else, guess pcyl = ncyl + acyl.
- don't use bogus disklabel data if disk label is invalid
(xdgetdisklabel() now returns if label was ok or not).
- move xddriver decl. before start of actual code (cleanup).
 1.8 25-Sep-1995  chuck bug fix: xddummystrat() was clearing all but B_BUSY when it should
have been clearing just B_BUSY (s/B_BUSY/~B_BUSY/). this
fixes hard hang when reading disklabel when booting system.
minor clean up: added a few prototypes and only fool with bootpath
if booting the system (in xdattach).
 1.7 24-Sep-1995  chuck init bad144 table before we actually try and read anything from the
disk, rather than init'ing after reading block 0 [in case we get an
error reading block zero].
 1.6 18-Sep-1995  pk Make this compile again by calling readdisklabel() with a dummy strategy routine.
XXX - need some reorganization to this from xdopen().
 1.5 18-Aug-1995  pk Do bootpath matching.
 1.4 01-Aug-1995  pk update from Chuck
 1.3 05-Jul-1995  pk KNFify a bit.
 1.2 05-Jul-1995  pk Add xxread/xxwrite.
 1.1 26-Jun-1995  pk SMD disk driver, from Chuck Cranor.
 1.25.4.1 16-Aug-1996  jtc Pulled up from rev 1.26 by request from pk
 1.29.6.1 12-Mar-1997  is Merge in changes from The Trunk
 1.4 25-Jan-1998  pk These drivers are now in dev/vme.
The `ie' driver has been split in a VME and OBIO front-end. The latter
lives on in this directory as `if_ie_obio.c'
 1.3 31-Mar-1996  pk Various cleanup; mostly trailing spaces/tabs.
 1.2 22-Feb-1996  thorpej Fixup some RCS ids.
 1.1 26-Jun-1995  pk SMD disk driver, from Chuck Cranor.
 1.6 25-Jan-1998  pk These drivers are now in dev/vme.
The `ie' driver has been split in a VME and OBIO front-end. The latter
lives on in this directory as `if_ie_obio.c'
 1.5 31-Mar-1996  pk Various cleanup; mostly trailing spaces/tabs.
 1.4 14-Mar-1996  christos Bring prototypes into scope and fix compiler warnings.
 1.3 22-Feb-1996  thorpej Fixup some RCS ids.
 1.2 07-Jan-1996  thorpej New generic disk framework. Highlights:

- New metrics handling. Metrics are now kept in the new
`struct disk'. Busy time is now stored as a timeval, and
transfer count in bytes.

- Storage for disklabels is now dynamically allocated, so that
the size of the disk structure is not machine-dependent.

- Several new functions for attaching and detaching disks, and
handling metrics calculation.

Old-style instrumentation is still supported in drivers that did it before.
However, old-style instrumentation is being deprecated, and will go away
once the userland utilities are updated for the new framework.

For usage and architectural details, see the forthcoming disk(9) manual
page.
 1.1 26-Jun-1995  pk SMD disk driver, from Chuck Cranor.
 1.3 05-Feb-1998  pk This file has been moved to dev/vme a while ago.
 1.2 31-Mar-1996  pk Various cleanup; mostly trailing spaces/tabs.
 1.1 26-Jun-1995  pk SMD disk driver, from Chuck Cranor.
 1.28 25-Jan-1998  pk These drivers are now in dev/vme.
The `ie' driver has been split in a VME and OBIO front-end. The latter
lives on in this directory as `if_ie_obio.c'
 1.27 12-Jan-1998  thorpej Update for changes to config.
 1.26 19-Jul-1997  pk #include "locators.h"
 1.25 17-Jul-1997  jtk use locator defines in "locators.h" to index cf_loc[]
 1.24 24-Jun-1997  thorpej foosize()'s return value is in DEV_BSIZE units; adjust the size obtained
from the disklabel accordingly.
 1.23 18-Jun-1997  pk xysize(): only call xyopen()/xyclose() if not already open, per the
current `openmask'.
 1.22 10-Jun-1997  pk Avoid "false positives" in match routines.
 1.21 24-May-1997  pk Remove all `bustype' arguments from map[io]dev() and REG2PHYS().
 1.20 10-Dec-1996  pk Comply with recent autoconfiguration changes. Diffs graciously
supplied by Chris Demetriou.
 1.19 13-Oct-1996  christos backout previous kprintf change
 1.18 11-Oct-1996  christos printf -> kprintf, sprintf -> ksprintf
 1.17 22-Apr-1996  christos Remove dependency on <sys/cpu.h>
 1.16 10-Apr-1996  pk `bootdv' is gone. Instead, set the device pointer in the `struct bootpath'
that is passed in the attach arguments.
 1.15 01-Apr-1996  christos Eliminated dependencies on dev_conf.h
 1.14 31-Mar-1996  pk Various cleanup; mostly trailing spaces/tabs.
 1.13 17-Mar-1996  thorpej New device attachment scheme:

- split softc size and match/attach out from cfdriver into
a new struct cfattach.

- new "attach" directive for files.*. May specify the name of
the cfattach structure, so that devices may be easily attached
to parents with different autoconfiguration semantics.
 1.12 16-Mar-1996  christos cast argument to probeget()
 1.11 14-Mar-1996  christos Bring prototypes into scope and fix compiler warnings.
 1.10 04-Mar-1996  chuck Fix two bugs reported by Don Koch <aardvark@poirot.krl.com> (PR#2169)
[these bugs apply to the xy as well as the xd driver]
[1] check return value from malloc() for NULL before trying to bzero it.
[2] use "=" rather than "|=" when writing to CSR (otherwise you may
ACK something you don't mean to!).
 1.9 25-Feb-1996  pk Use CPU-type macros
 1.8 22-Feb-1996  thorpej Fixup some RCS ids.
 1.7 21-Feb-1996  chuck minor clean up: revise locations of disk_busy/disk_unbusy calls to match xd.c
 1.6 13-Jan-1996  chuck - call mapiodev() with sizeof(struct xyc) rather than ra_len (which is
zero since xycmatch no longer sets it). [if you call mapiodev()
with a zero size it will reuse the KVA it returns, swiping the device
out from under you!]
- make xyc->iopbase point in the kernels DVMA space rather than at the
normal malloc'd KVA. this isn't compatable with sun4m [doesn't
have a kernel DVMA space] and will need to be changed later (XXX).
- move disk_attach() to before reading the disk label as per Jason.
otherwise we are reading into an unallocated buffer (oops!)
 1.5 12-Jan-1996  chuck nuke uneeded variable in match function.
 1.4 12-Jan-1996  chuck we no longer need to add in the offset to the mapped VA to get the correct
device address (bus_tmp, bus_map, and mapiodev now do this for us).

also, we handle all our mappings, so don't have obio.c do any for us
(i.e. don't set ra->ra_len in xycmatch).
 1.3 07-Jan-1996  thorpej New generic disk framework. Highlights:

- New metrics handling. Metrics are now kept in the new
`struct disk'. Busy time is now stored as a timeval, and
transfer count in bytes.

- Storage for disklabels is now dynamically allocated, so that
the size of the disk structure is not machine-dependent.

- Several new functions for attaching and detaching disks, and
handling metrics calculation.

Old-style instrumentation is still supported in drivers that did it before.
However, old-style instrumentation is being deprecated, and will go away
once the userland utilities are updated for the new framework.

For usage and architectural details, see the forthcoming disk(9) manual
page.
 1.2 11-Dec-1995  pk Adapt to changed mapiodev() interface.
Use new DVMA routines.
 1.1 25-Sep-1995  chuck new "xy" disk device driver from me.
the "xy" driver runs Xylogics 450/451 SMD disk controllers.
 1.4 25-Jan-1998  pk These drivers are now in dev/vme.
The `ie' driver has been split in a VME and OBIO front-end. The latter
lives on in this directory as `if_ie_obio.c'
 1.3 31-Mar-1996  pk Various cleanup; mostly trailing spaces/tabs.
 1.2 22-Feb-1996  thorpej Fixup some RCS ids.
 1.1 25-Sep-1995  chuck new "xy" disk device driver from me.
the "xy" driver runs Xylogics 450/451 SMD disk controllers.
 1.5 25-Jan-1998  pk These drivers are now in dev/vme.
The `ie' driver has been split in a VME and OBIO front-end. The latter
lives on in this directory as `if_ie_obio.c'
 1.4 31-Mar-1996  pk Various cleanup; mostly trailing spaces/tabs.
 1.3 22-Feb-1996  thorpej Fixup some RCS ids.
 1.2 07-Jan-1996  thorpej New generic disk framework. Highlights:

- New metrics handling. Metrics are now kept in the new
`struct disk'. Busy time is now stored as a timeval, and
transfer count in bytes.

- Storage for disklabels is now dynamically allocated, so that
the size of the disk structure is not machine-dependent.

- Several new functions for attaching and detaching disks, and
handling metrics calculation.

Old-style instrumentation is still supported in drivers that did it before.
However, old-style instrumentation is being deprecated, and will go away
once the userland utilities are updated for the new framework.

For usage and architectural details, see the forthcoming disk(9) manual
page.
 1.1 25-Sep-1995  chuck new "xy" disk device driver from me.
the "xy" driver runs Xylogics 450/451 SMD disk controllers.
 1.124 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.123 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.122 24-Apr-2021  thorpej branches: 1.122.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.121 27-Oct-2012  chs branches: 1.121.52;
split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.120 26-Jun-2010  tsutsui branches: 1.120.8; 1.120.18;
Remove an unused variable.
 1.119 26-Jun-2010  tsutsui Establish interrupt handlers with proper softc per each zs device
rather than sharing them among all zs devices and searching softc
in handlers.

The latter method is derived from ancient sun3 zs driver which tried
to reduce overhead on autovectored interrupts, but nowadays such hack
might cause recursive global locks on modern SMP capable framework.

Fixes "5.99.30 sparc panic during startup" reported by Hauke Fath
on tech-kern@:
http://mail-index.NetBSD.org/tech-kern/2010/06/19/msg008374.html
and also tested by Jochen Kunz on SS20 with both serial and kbd console.

Ok'ed by mrg@ and dyoung@.
 1.118 04-Jun-2010  macallan make sure we pass a valid consdev pointer to the console keyboard so kbd
knows it's console and passes the right flags to wskbd, now the wskbd will
not drop off the mux when leaving event mode.
Symptoms: now the keyboard should no longer be dead when leaving X and there
should be no more panics caused by it
I tested this on an SS5 and an SS20, may need some more attention and zs.c
sure could use some cleanup - there are a few differences to sparc64 that
really don't make much sense to me, like not passing console flags to zstty
which sparc64 does but sparc avoids, which caused this problem in the first
place.
 1.117 17-Jan-2010  tsutsui branches: 1.117.2; 1.117.4;
Make sure to set ZS_HWFLAG_USE_CONSDEV and zs_consdev into zsc_args
passed to child devices even in !(NWSKBD == 0) case so that zs console
functions are actually used rather than the default prom console.
Fixes stray interrupts on MP machines running GENERIC.MP kernel with
zs serial console.

Ok'ed by mrg@.
 1.116 31-May-2009  martin Properly initialize child attach args to zero - we could end up with
various devices having different ideas about being console otherwise.
 1.115 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.114 16-May-2009  cegger KNF, same object code generated
 1.113 18-Mar-2009  cegger bcopy -> memcpy
 1.112 17-Nov-2008  martin branches: 1.112.4;
PR port-sparc/39942: ifdef ch0_is_cons declaration and all uses consistently
 1.111 13-Jun-2008  cegger branches: 1.111.2; 1.111.4; 1.111.6;
use device_lookup_private to get softc
 1.110 28-Apr-2008  martin branches: 1.110.2; 1.110.4;
Remove clause 3 and 4 from TNF licenses
 1.109 29-Mar-2008  tsutsui branches: 1.109.2; 1.109.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.108 27-Nov-2007  ad branches: 1.108.14;
Use the softint API.
 1.107 09-Nov-2007  ad Call zs_lock_init() to set up the chanstate's lock.
 1.106 14-Mar-2007  jdc branches: 1.106.14; 1.106.16; 1.106.20; 1.106.22;
Final steps to for working wscons on sun-4 class machines. Restructure
the previous revision so that we don't tell the common zs code that we
are the console if we're using wscons. Thanks to wrstuden@ for the hints.
 1.105 08-Feb-2007  jdc branches: 1.105.2; 1.105.6; 1.105.8;
First steps for working wscons on sun-4 class machines - recognise the
console keyboard and mouse on them.

We are not there yet because currently both wsdisplay and zstty assume
that they are the console. On sun-4, zstty wins because it attaches
last and overwrites the console device that wscons had set previously.
 1.104 26-Feb-2006  thorpej branches: 1.104.14;
Use device_is_a().
 1.103 16-Nov-2005  uwe branches: 1.103.2; 1.103.4; 1.103.6;
ANSIify function declarations/defintions. Use uint<N>_t.
Propagate "static" to function definitions. Drop trailing whitespace.
Same binary code is produced for GENERIC.MP + KGDB + DDB.
 1.102 30-Jun-2005  macallan branches: 1.102.2; 1.102.8;
Allow sparc64-style attachment of mouse and keyboard via zstty, needed for
wscons support.
Reviewed by uwe.
 1.101 03-Apr-2004  chs add some SUN4D stuff.
zs and zstty no longer need "needs-count" or "needs-flag",
so get rid of those and wild-card the extra zs devices on SUN4D.
 1.100 17-Mar-2004  pk Rename PROM_getprop*() => prom_getprop*().
 1.99 13-Feb-2004  wiz Uppercase CPU, plural is CPUs.
 1.98 15-Jul-2003  lukem __KERNEL_RCSID()
 1.97 28-Jan-2003  pk branches: 1.97.2;
Provide locking required by the interrupt handlers running at IPL_SERIAL.
 1.96 22-Jan-2003  pk Set the interrupt target to the current CPU when directly accessing
the chip for console I/O.
 1.95 01-Jan-2003  thorpej Use aprint_normal() for cfprint routines.
 1.94 10-Dec-2002  pk Remove the `flags' argument from bus_intr_establish().
 1.93 09-Dec-2002  pk Finish the switch to the softintr(9) framework.

To make this work, we now have to use separate handler lists for hardware
and software interrupts as the soft interrupt handlers do not return
an `interrupt handled' status.

Thanks to Matt Fredette for providing an initial set of patches on port-sparc.
 1.92 09-Oct-2002  jdc Check only the physical address of serial ports on a Sun 4.

Reviewed by Uwe.
 1.91 02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.90 01-Oct-2002  thorpej Use CFATTACH_DECL().
 1.89 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.88 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.87 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.86 24-Aug-2002  thorpej Add autoconfiguration support for the Sun4d "bootbus". Add a
zs @ bootbus attachment.
 1.85 11-Mar-2002  pk branches: 1.85.4; 1.85.6;
* `bus_type_t' is gone.
* Use BUS_ADDR() where appropriate to encode I/O space and physical
address offset into a `bus_addr_t' value.
* Drop obio_bus_map() since it's now completely equivalent to bus_space_map()
* Use bus_space_map2() to map device space at a fixed virtual address.
* Remove the virtual address argument from sbus_sbus_addr()
 1.84 26-Sep-2001  eeh branches: 1.84.4;
getprop* -> PROM_getprop*
 1.83 30-Jun-2001  mrg branches: 1.83.2; 1.83.4;
KGDB needs both zs_putc and zs_getc; make them non-static.
 1.82 26-May-2001  pk Pull in "opt_kgdb.h"; see PR#13036.
 1.81 18-Oct-2000  pk branches: 1.81.2;
Account for the top-most 4 bits of obio addresses being zero on sun 4/100
machines, when inferring zs PROM device numbers from the physical address.
 1.80 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.79 04-Jun-2000  cgd branches: 1.79.2;
Implement the more flexiable `evcnt' interface as discussed (briefly) on
tech-kern and now documented in evcnt(9).
 1.78 21-Mar-2000  pk branches: 1.78.2;
Delete debugging printf().
 1.77 19-Mar-2000  pk Just don't force the baud rate in the driver, ever.
 1.76 19-Mar-2000  pk Revise console device handling:
* do not require a `zs' driver for console handling
* run the console on PROM primitives until a device recognises
itself as a console device during normal autoconfiguration.
* allow (keyboard) devices to take over the input channel of
the PROM primitive-based console device.

As a result, consinit() is much simplified and does no longer have
to "detect" devices to setup a working console device. This complexity
has moved to individual drivers which interpret the PROM information
after they have attached to decide whether or not to act as a console.
 1.75 14-Mar-2000  jdc Add power management hooks.
 1.74 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.73 14-Feb-2000  pk Just skip matching the `slave' property against `cf_unit'.
 1.72 12-Feb-2000  pk Eliminate much of the goo in setting up zs device addressing.
 1.71 21-Nov-1999  pk Check presence of Sbus interrupt properties before using them.
 1.70 07-Nov-1999  pk Handle empty `input/output path' when looking for console device; patch
from Brian D. Chase.
 1.69 27-Mar-1999  wrstuden branches: 1.69.2; 1.69.8; 1.69.10; 1.69.14;
Add pps support. Only enable pps if CLOCAL & !MDMBUF.
 1.68 05-Mar-1999  pk consinit: cover all cases.
 1.67 02-Mar-1999  pk Sanatize consinit() a bit.
 1.66 22-Feb-1999  pk Since V2 & V3 proms already pass us ihandles for stdin and stdout,
there's no need to open the device a second time. It suffices to
just convert the `ihandles' to `phandles'.
 1.65 16-Feb-1999  pk Use promlib version correctly.
 1.64 14-Feb-1999  pk Use the PROMLIB interface.
 1.63 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.62 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.61 04-Jul-1998  jonathan defopt DDB.
 1.60 23-Apr-1998  chs fix a timing problem with polled output on sun4c's.
 1.59 30-Mar-1998  mycroft Eliminate cs_heldchar. It is not necessary in my version of the driver.
 1.58 29-Mar-1998  pk obio_bus_probe() => bus_space_probe()
 1.57 21-Mar-1998  pk Account for changed bus attachment scheme.
 1.56 21-Jan-1998  mrg KNF, and use splzs over splhigh in one place.
 1.55 12-Jan-1998  thorpej Update for changes to config.
 1.54 12-Nov-1997  pk If necessary, defer console output until TX interrupt handler runs.
 1.53 03-Nov-1997  mycroft Handle CDTRCTS, for silly Mac-like connector on some models (e.g. IPX).
 1.52 02-Nov-1997  mycroft Set rr0_dcd.
Don't set DCD_IE and CTS_IE here; let the MI code do it.
Handle MDMBUF.
 1.51 22-Oct-1997  gwr Correct the values of zs_unit in consinit(),
so ddb will work on the keyboard/display.
 1.50 18-Oct-1997  gwr branches: 1.50.2;
Use common zs code.
 1.49 31-Aug-1997  pk Allow a BREAK to cause a kgdb_connect().
 1.48 29-Jul-1997  fair branches: 1.48.2;
%x -> 0x%x
 1.47 14-Apr-1997  pk Avoid race for the chip's interrupt pending status bits in zscnputc()
by introducing a single-character queue to defer kernel console output
until the transmitter interrupt handler runs.
 1.46 09-Apr-1997  mrg as per discussion with torek, allow TC=1. also add option
to allow TC=0. the zilog documentation says not to allow
TC=0 -- however, i tested this and it "does work", as far
as i could tell, so, allow this use if so desired.
 1.45 10-Dec-1996  pk Comply with recent autoconfiguration changes. Diffs graciously
supplied by Chris Demetriou.
 1.44 13-Oct-1996  christos backout previous kprintf change
 1.43 11-Oct-1996  christos printf -> kprintf, sprintf -> ksprintf
 1.42 02-Sep-1996  mycroft tty stop functions really should return void, not int, and certainly not both.
 1.41 30-May-1996  pk Put back a `#if defined(SUN4M)' for now.
 1.40 29-May-1996  pk We really need a ring buffer for every unit.
Eliminate extraneous ttyalloc() calls.
 1.39 29-May-1996  mrg find a couple minor nits from previous change.
 1.38 28-May-1996  mrg change zsinfo to a zs_softc, and impliment intr counts. mostly from OpenBSD.
 1.37 01-Apr-1996  christos branches: 1.37.4;
Eliminated dependencies on dev_conf.h
 1.36 31-Mar-1996  pk Various cleanup; mostly trailing spaces/tabs.
 1.35 17-Mar-1996  thorpej New device attachment scheme:

- split softc size and match/attach out from cfdriver into
a new struct cfattach.

- new "attach" directive for files.*. May specify the name of
the cfattach structure, so that devices may be easily attached
to parents with different autoconfiguration semantics.
 1.34 14-Mar-1996  christos Bring prototypes into scope and fix compiler warnings.
 1.33 25-Feb-1996  pk Use CPU-type macros.
 1.32 29-Nov-1995  pk Extend the size of the "soft" FIFOs which reportedly reduces the number
of FIFO overflows on high baud rates.
However, doing so on all 4 ports would cost a whopping 64KB (at 4096 entries
per FIFO) of kernel memory. So, the FIFOs are now allocated at attach time
allowing the size for the keyboard and mouse ports to be reduced (to 128)
which should be adequate for the 1200 baud they use.
 1.31 28-Jun-1995  cgd note that most of dev/ic's contents have changed names
 1.30 26-Jun-1995  pk Small optimisation & 1 fewer depedency on zs_ctty.
 1.29 26-Jun-1995  pk Use ZS_DELAY() in a few more places (from Gordon Ross, cf. sun3/dev/zs.c).
 1.28 21-Apr-1995  pk Implement zstty().
 1.27 11-Apr-1995  mycroft Undo accidental change.
 1.26 11-Apr-1995  mycroft Move CHAN_[AB] into here, and prefix with ZS_.
 1.25 11-Apr-1995  mycroft zsreg.h --> z8530.h
 1.24 01-Mar-1995  pk Better 4/100 support.
 1.23 01-Feb-1995  pk Integrate changes from Chuck Cranor for the Sun 4/100.
Support for multiple register banks on SBUS devices (based on patches
from Francis Dupont).
Highlights:
romaux defines an array of register spaces.
pay attention to `vactype'.
quirks handling 4/100 idiosyncracies.
 1.22 29-Jan-1995  pk TIOC[SC]DTR ioctls.
 1.21 06-Dec-1994  deraadt TIOC[SG]FLAGS from matthew green
 1.20 26-Nov-1994  deraadt i hate ttyX-ignore-cd, but leave it here for a while longer
 1.19 23-Nov-1994  deraadt XXmatch change (and a few __P() as well)
 1.18 20-Nov-1994  deraadt copyright/Id cleanup
 1.17 03-Nov-1994  pk Don't mess with device if it was opened while we napped.
 1.16 02-Nov-1994  deraadt ioctl u_long cmd; and KNF
 1.15 15-Oct-1994  deraadt mapiodev takes a bustype argument now
 1.14 02-Oct-1994  deraadt sun4/300 support works
 1.13 17-Sep-1994  deraadt sbus/* --> dev/*
deal with multiple bus types (start of vme/obio support)
 1.12 20-Aug-1994  deraadt sun4 needs software delays for register accesses
 1.11 21-Jul-1994  deraadt make X11R5 compile easier
 1.10 24-Jun-1994  deraadt branches: 1.10.2;
sun4c -> SUN4C
 1.9 27-May-1994  pk cast to make compiler happy.
 1.8 19-May-1994  deraadt t_stop has been erradicated
 1.7 14-May-1994  deraadt TIOCSBRK/TIOCCBRK
 1.6 05-May-1994  deraadt timeout and ndflush casts
 1.5 23-Mar-1994  pk DDB support
 1.4 14-Feb-1994  deraadt ioctl takes a proc *
 1.3 13-Oct-1993  deraadt fixups for dynamic tty allocation:
cdevsw[]->d_ttys must be initialized
XXstop() functions must be callable from cdevsw[]->d_stop
the console tty is used before vm system is up, and must
allocate it's own clists..
 1.2 11-Oct-1993  deraadt cons.c, zs.c: tty->t_stop doesn't exist here. I think it goes through d_stop
automatically now, but have not checked.
l_ioctl() has no last parameter 'p'
fb.c: move sys/fbio.h to machine/fbio.h
various: typecast parms for timeout() properly
zs.c: extra level of indir in cdevsw[]->d_ttys
 1.1 02-Oct-1993  deraadt Chris Torek's sparc port. Missing lots of things.
 1.10.2.1 22-Jul-1994  cgd from trunk.
 1.37.4.1 02-Jun-1996  mrg pull up tty stats "bug fix".
 1.48.2.1 01-Sep-1997  thorpej Update marc-pcmcia branch from trunk.
 1.50.2.4 08-May-1998  mycroft Pull up 1.59-1.60, per request of mycroft.
 1.50.2.3 14-Nov-1997  mellon Pull rev 1.54 up from trunk (pk)
 1.50.2.2 04-Nov-1997  mellon Pull rev 1.52 and 1.53 up from trunk (mycroft)
 1.50.2.1 23-Oct-1997  mellon Pull rev 1.51 up from trunk
 1.69.14.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.69.10.1 15-Nov-1999  fvdl Sync with -current
 1.69.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.69.2.2 29-Mar-2000  he Apply patch (requested by pk):
Fix a NULL pointer dereference when a zs device interrupts during
autoconfiguration of subdevices (keyboard & mouse).
 1.69.2.1 15-Jan-2000  he Pull up revision 1.70 (requested by pk):
Two fixes:
o Fix out of bound indexing of buffer.
o Default to first serial port if console property is absent.
 1.78.2.1 22-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.79.2.2 19-Oct-2000  he Pull up revision 1.81 (requested by pk):
Account for the top-most 4 bits of obio addresses being zero on
sun 4/100 machines when inferring zs PROM device numbers from the
physical address.
 1.79.2.1 19-Jul-2000  mrg pull up sparc/sparc64 bus_intr_establish() changes, necessary for sparc64
(originally done by pk, approved by thorpej):

>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.81.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.83.4.1 01-Oct-2001  fvdl Catch up with -current.
 1.83.2.4 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.83.2.3 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.83.2.2 16-Mar-2002  jdolecek Catch up with -current.
 1.83.2.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.84.4.7 03-Jan-2003  thorpej Sync with HEAD.

XXX ALT_SWITCH_CODE is not yet LWP'ified.
 1.84.4.6 11-Dec-2002  thorpej Sync with HEAD.
 1.84.4.5 18-Oct-2002  nathanw Catch up to -current.
 1.84.4.4 17-Sep-2002  nathanw Catch up to -current.
 1.84.4.3 27-Aug-2002  nathanw Catch up to -current.
 1.84.4.2 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.84.4.1 26-Sep-2001  nathanw file zs.c was added on branch nathanw_sa on 2002-04-01 07:42:44 +0000
 1.85.6.1 07-Dec-2002  he Pull up revision 1.92 (requested by jdc in ticket #908):
Check only the physical address of serial ports on a Sun4.
 1.85.4.2 31-Aug-2002  gehenna catch up with -current.
 1.85.4.1 19-May-2002  gehenna Remove hard-coded major.
 1.97.2.5 11-Dec-2005  christos Sync with head.
 1.97.2.4 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.97.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.97.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.97.2.1 03-Aug-2004  skrll Sync with HEAD
 1.102.8.1 22-Nov-2005  yamt sync with head.
 1.102.2.5 07-Dec-2007  yamt sync with head
 1.102.2.4 15-Nov-2007  yamt sync with head.
 1.102.2.3 03-Sep-2007  yamt sync with head.
 1.102.2.2 26-Feb-2007  yamt sync with head.
 1.102.2.1 21-Jun-2006  yamt sync with head.
 1.103.6.1 22-Apr-2006  simonb Sync with head.
 1.103.4.1 09-Sep-2006  rpaulo sync with head
 1.103.2.1 01-Mar-2006  yamt sync with head.
 1.104.14.1 09-Feb-2007  ad Sync with HEAD.
 1.105.8.1 11-Jul-2007  mjf Sync with head.
 1.105.6.2 03-Dec-2007  ad Sync with HEAD.
 1.105.6.1 10-Apr-2007  ad Sync with head.
 1.105.2.1 24-Mar-2007  yamt sync with head.
 1.106.22.2 08-Dec-2007  mjf Sync with HEAD.
 1.106.22.1 19-Nov-2007  mjf Sync with HEAD.
 1.106.20.1 13-Nov-2007  bouyer Sync with HEAD
 1.106.16.1 09-Jan-2008  matt sync with HEAD
 1.106.14.2 03-Dec-2007  joerg Sync with HEAD.
 1.106.14.1 11-Nov-2007  joerg Sync with HEAD.
 1.108.14.4 17-Jan-2009  mjf Sync with HEAD.
 1.108.14.3 29-Jun-2008  mjf Sync with HEAD.
 1.108.14.2 02-Jun-2008  mjf Sync with HEAD.
 1.108.14.1 03-Apr-2008  mjf Sync with HEAD.
 1.109.4.5 11-Aug-2010  yamt sync with head.
 1.109.4.4 11-Mar-2010  yamt sync with head
 1.109.4.3 20-Jun-2009  yamt sync with head
 1.109.4.2 04-May-2009  yamt sync with head.
 1.109.4.1 16-May-2008  yamt sync with head.
 1.109.2.2 17-Jun-2008  yamt sync with head.
 1.109.2.1 18-May-2008  yamt sync with head.
 1.110.4.1 18-Jun-2008  simonb Sync with head.
 1.110.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.111.6.4 08-Mar-2011  riz Apply patches (requested by mrg in ticket #1564):
sys/arch/sparc/dev/zs.c: patch
sys/arch/sparc/include/cpu.h: patch
sys/arch/sparc/include/z8530var.h: patch
sys/arch/sparc/sparc/cpu.c: patch
sys/arch/sparc/sparc/cpuvar.h: patch
sys/arch/sparc/sparc/db_interface.c: patch
sys/arch/sparc/sparc/genassym.cf: patch
sys/arch/sparc/sparc/intr.c: patch
sys/arch/sparc/sparc/locore.s: patch
sys/arch/sparc/sparc/machdep.c: patch
sys/arch/sparc/sparc/timer.c: patch
sys/arch/sparc/sparc/timer_sun4m.c: patch
sys/arch/sparc/sparc/timervar.h: patch
sys/arch/sparc/sparc/trap.c: patch
sys/arch/sparc/sparc/vm_machdep.c: patch

- fix a panic in savefpstate. idea, and code suggestions from uwe
- convert xpmsg_lock to IPL_SCHED. the old spl/simple_lock code ran at
splsched(), and this significantly helps with stability under load when
running with multiple active CPUs
- in strayintr() don't print about stray zs inters in MP case
- fix a deadlock in xcall()
- consolidate the interrupt evcnt(9) into a full set of per-IPL per-CPU
soft/hard counters
- fix xcall() failure messages in some cases
- addd new ddb command "mach xcall"
- use schedintr() (not schedintr_4m()) on MP or single CPU configurations
- call hardclock() the same way on cpu0 in MP and !MP cases
- request the appropriate stack space for nmi_sun4m, in particular,
make sure we have space for %g2...%g5. now entering ddb via eg,
serial break no longer causes cpu1 to fault.
- give memfault_sun*() some entry points that both gdb and ddb will find.
from tsutsui:
- fix panic in interrupt handlers in zs
 1.111.6.3 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.111.6.2 09-Jun-2009  snj Pull up following revision(s) (requested by martin in ticket #800):
sys/arch/sparc/dev/zs.c: revision 1.116
Properly initialize child attach args to zero - we could end up with
various devices having different ideas about being console otherwise.
 1.111.6.1 18-Nov-2008  snj branches: 1.111.6.1.2;
Pull up following revision(s) (requested by martin in ticket #77):
sys/arch/sparc/dev/zs.c: revision 1.112
PR port-sparc/39942: ifdef ch0_is_cons declaration and all uses
consistently
 1.111.6.1.2.1 09-Jun-2009  snj branches: 1.111.6.1.2.1.2;
Pull up following revision(s) (requested by martin in ticket #800):
sys/arch/sparc/dev/zs.c: revision 1.116
Properly initialize child attach args to zero - we could end up with
various devices having different ideas about being console otherwise.
 1.111.6.1.2.1.2.1 21-Apr-2010  matt sync to netbsd-5
 1.111.4.2 28-Apr-2009  skrll Sync with HEAD.
 1.111.4.1 19-Jan-2009  skrll Sync with HEAD.
 1.111.2.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.112.4.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.117.4.1 03-Jul-2010  rmind sync with head
 1.117.2.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.120.18.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.120.8.1 30-Oct-2012  yamt sync with head
 1.121.52.1 21-Mar-2021  thorpej Give config_found() the same variadic arguments treatment as
config_search(). This commit only adds the CFARG_EOL sentinel
to the existing config_found() calls. Conversion of config_found_sm_loc()
and config_found_ia() call sites will be in subsequent commits.
 1.122.8.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.22 24-Oct-2023  andvar apply similar changes between different archs/machines for zs_kgdb.c:
1) adjust zs_kgdb_init tty attachment message for kgdb_dev type change.
(one arch uses cast to int instead, but kept one approach for consistency)
2) remove unused rr0 declaration and assignment in zs_kgdb_txint()
3) adjust kgdb_dev format specifier to %llx/d if needed.
4) add const for zs_kgdb_devname declaration (macppc only).
should fix zs_kgdb.c build for all these ports.
 1.21 16-May-2009  cegger branches: 1.21.44; 1.21.54;
KNF, same object code generated
 1.20 18-Mar-2009  cegger bcopy -> memcpy
 1.19 18-Mar-2009  cegger bzero -> memset
 1.18 28-Apr-2008  martin branches: 1.18.8; 1.18.14;
Remove clause 3 and 4 from TNF licenses
 1.17 04-Mar-2007  christos branches: 1.17.40; 1.17.42; 1.17.44;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.16 16-Nov-2005  uwe branches: 1.16.26;
ANSIify function declarations/defintions. Use uint<N>_t.
Propagate "static" to function definitions. Drop trailing whitespace.
Same binary code is produced for GENERIC.MP + KGDB + DDB.
 1.15 14-Nov-2005  uwe branches: 1.15.2;
Catch up with the signature change of obio_find_rom_map.
Add __UNVOLATILE when zc is passed as kgdb ioarg.
 1.14 17-Mar-2004  pk branches: 1.14.16;
Rename PROM_getprop*() => prom_getprop*().
 1.13 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.12 15-Jul-2003  lukem __KERNEL_RCSID()
 1.11 02-Apr-2003  thorpej branches: 1.11.2;
Use PAGE_SIZE rather than NBPG.
 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-Jul-2002  thorpej Remote CPU_ISSUN4OR4C and CPU_ISSUN4COR4M, and instead express them
as (CPU_ISSUN4 || CPU_ISSUN4C) and (CPU_ISSUN4C || CPU_ISSUN4M),
respectively. The compiler can still optimize as desired by expressing
them this way, and it simplifies adding new tests.

While here, just remove CPU_ISSUN4MOR4U; it's not used by anything.
 1.8 26-Sep-2001  eeh branches: 1.8.4; 1.8.12;
getprop* -> PROM_getprop*
 1.7 29-Jun-2001  mrg branches: 1.7.2; 1.7.4;
#include <machine/autoconf.h>
 1.6 26-May-2001  pk Pull in "opt_kgdb.h"; see PR#13036.
 1.5 21-Mar-2000  pk branches: 1.5.6;
findzs() is now used only by the kgbd initialision code.
 1.4 12-Feb-2000  pk Eliminate much of the goo in setting up zs device addressing.
 1.3 03-Feb-1999  mycroft branches: 1.3.8;
Don't set DCD_IE in the frontends. KGDB doesn't even use DCD, and the tty
frontends get it from zsparam() anyway.
 1.2 22-Oct-1997  gwr Correct zs_unit in zs_kgdb_init().
Similar problem as zs.c:consinit().
 1.1 18-Oct-1997  gwr branches: 1.1.2;
Use common zs code.
 1.1.2.1 23-Oct-1997  mellon Pull rev 1.2 up from main trunk
 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.5.6.1 21-Jun-2001  nathanw Catch up to -current.
 1.7.4.1 01-Oct-2001  fvdl Catch up with -current.
 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 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.7.2.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.8.12.2 21-Jul-2002  gehenna catch up with -current.
 1.8.12.1 19-May-2002  gehenna Replace the access to devsw table and the hard-coded majors with devsw API.
 1.8.4.3 17-Sep-2002  nathanw Catch up to -current.
 1.8.4.2 01-Aug-2002  nathanw Catch up to -current.
 1.8.4.1 26-Sep-2001  nathanw file zs_kgdb.c was added on branch nathanw_sa on 2002-08-01 02:43:22 +0000
 1.11.2.4 11-Dec-2005  christos Sync with head.
 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.14.16.2 03-Sep-2007  yamt sync with head.
 1.14.16.1 21-Jun-2006  yamt sync with head.
 1.15.2.2 22-Nov-2005  yamt sync with head.
 1.15.2.1 14-Nov-2005  yamt file zs_kgdb.c was added on branch yamt-readahead on 2005-11-22 16:08:02 +0000
 1.16.26.1 12-Mar-2007  rmind Sync with HEAD.
 1.17.44.3 20-Jun-2009  yamt sync with head
 1.17.44.2 04-May-2009  yamt sync with head.
 1.17.44.1 16-May-2008  yamt sync with head.
 1.17.42.1 18-May-2008  yamt sync with head.
 1.17.40.1 02-Jun-2008  mjf Sync with HEAD.
 1.18.14.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.18.8.1 28-Apr-2009  skrll Sync with HEAD.
 1.21.54.1 27-Apr-2017  pgoyette Restore all work from the former pgoyette-localcount branch (which is
now abandoned doe to cvs merge botch).

The branch now builds, and installs via anita. There are still some
problems (cgd is non-functional and all atf tests time-out) but they
will get resolved soon.
 1.21.44.1 20-Jul-2016  pgoyette Adapt the machine/arch dependent code to the new {b,c}devsw reference
counting.

XXX Most of these will require testing by someone other than myself, as
I have a limited selection of hardware!
 1.3 11-Apr-1995  mycroft Move this into a generic location.
 1.2 20-Nov-1994  deraadt copyright/Id cleanup
 1.1 02-Oct-1993  deraadt Chris Torek's sparc port. Missing lots of things.
 1.11 18-Oct-1997  gwr Use common zs code.
 1.10 14-Apr-1997  pk Avoid race for the chip's interrupt pending status bits in zscnputc()
by introducing a single-character queue to defer kernel console output
until the transmitter interrupt handler runs.
 1.9 29-May-1996  mrg find a couple minor nits from previous change.
 1.8 31-Mar-1996  pk Various cleanup; mostly trailing spaces/tabs.
 1.7 25-Feb-1996  pk Use CPU-type macros.
 1.6 24-Jan-1996  gwr Move struct definitions to MD code.
 1.5 29-Nov-1995  pk Extend the size of the "soft" FIFOs which reportedly reduces the number
of FIFO overflows on high baud rates.
However, doing so on all 4 ports would cost a whopping 64KB (at 4096 entries
per FIFO) of kernel memory. So, the FIFOs are now allocated at attach time
allowing the size for the keyboard and mouse ports to be reduced (to 128)
which should be adequate for the 1200 baud they use.
 1.4 11-Apr-1995  mycroft Move CHAN_[AB] into here, and prefix with ZS_.
 1.3 20-Nov-1994  deraadt copyright/Id cleanup
 1.2 20-Aug-1994  deraadt sun4 needs software delays for register accesses
 1.1 02-Oct-1993  deraadt Chris Torek's sparc port. Missing lots of things.

RSS XML Feed