Home | History | Annotate | only in /src/sys/arch/atari/dev
History log of /src/sys/arch/atari/dev
RevisionDateAuthorComments
 1.3 26-Nov-2002  lukem Remove KDIR=, since SYS_INCLUDE=symlinks and KDIR are not supported any more.
 1.2 20-Dec-1998  thomas branches: 1.2.26;
Install kbdreg.h. The Xserver needs it.
 1.1 02-Sep-1998  leo Reorganize installation if include files. Nuke some from atari/include as
they make no sense out of the kernel add some from atari/dev (ioctl's).
 1.2.26.1 11-Dec-2002  thorpej Sync with HEAD.
 1.66 06-Jan-2023  tsutsui TAB/spaces/indents cleanup.
 1.65 04-Oct-2021  andvar follow fcambus steps by fixing typos for "unknown" in few more error messages.
 1.64 27-Dec-2019  msaitoh s/transfered/transferred/
 1.63 07-Oct-2017  jdolecek branches: 1.63.4;
Merge support for SATA NCQ (Native Command Queueing) from jdolecek-ncq branch

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

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

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

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

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

Also fixes PR kern/43169 (wd(4)); and PR kern/11811, PR kern/47041,
PR kern/51979 (kernel dump)
 1.62 18-Oct-2014  snj branches: 1.62.8;
src is too big these days to tolerate superfluous apostrophes. It's
"its", people!
 1.61 05-Jul-2014  tsutsui Appease gcc48 -Wunused-but-set-variable warning.
 1.60 24-Mar-2014  christos branches: 1.60.2;
- remove unused
- use cpu_{g,s}etmodel() (not committed yet)
 1.59 12-Feb-2012  matt branches: 1.59.6; 1.59.10;
Change old-style function defintions to C89 prototypes.

Approved by releng.
 1.58 17-Jul-2011  joerg branches: 1.58.2; 1.58.6;
Retire varargs.h support. Move machine/stdarg.h logic into MI
sys/stdarg.h and expect compiler to provide proper builtins, defaulting
to the GCC interface. lint still has a special fallback.
Reduce abuse of _BSD_VA_LIST_ by defining __va_list by default and
derive va_list as required by standards.
 1.57 05-Jun-2011  tsutsui Split device_t/softc. No crash on TT030.
 1.56 17-Apr-2010  tsutsui branches: 1.56.2; 1.56.6;
extern inline -> static inline
 1.55 13-Apr-2010  tsutsui Misc KNF and cosmetics.
 1.54 10-Apr-2010  tsutsui Always schedule callback functions via add_sicallback(),
which calls softint_schedule(9).

We cannot use BASEPRI() to check recursive calls any longer
since softint(9) has been reorganized to use kernel thread.
 1.53 20-Oct-2009  snj branches: 1.53.2; 1.53.4;
Remove 3rd and 4th clause on Leo Weppelman's license. OK leo@.
 1.52 08-Jul-2009  tsutsui Merge local <atari/atari/intr.h> into common <machine/intr.h>.
 1.51 18-Mar-2009  cegger Ansify function definitions w/o arguments. Generated with sed.
 1.50 14-Mar-2009  dsl ANSIfy another 1261 function definitions.
The only ones left in sys are beyond by sed script!
(or in sys/dist or sys/external)
Mostly they have function pointer parameters.
 1.49 14-Mar-2009  dsl Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.48 14-Mar-2009  dsl Remove all the __P() from sys (excluding sys/dist)
Diff checked with grep and MK1 eyeball.
i386 and amd64 GENERIC and sys still build.
 1.47 24-Jan-2009  tsutsui branches: 1.47.2;
Replace multi-statement macro using GCC extension `({})' with
static inline functions to avoid possible side effects or confusion.

Tested on TT030 by David Ross and on Falcon by Tuomo Makinen on port-atari.
 1.46 29-Oct-2008  abs branches: 1.46.2;
Cleanup spelling and syntax in a comment
 1.45 20-Jul-2008  tsutsui branches: 1.45.2;
Specify volatile to some pointers to access DMA registers.
 1.44 20-Jul-2008  tsutsui No need to specify '&' to get array's address.
No binary changes.
 1.43 20-Jul-2008  tsutsui Fix pointer arithmetic botch in rev 1.37.
 1.42 04-Mar-2007  christos branches: 1.42.40; 1.42.44; 1.42.46; 1.42.48; 1.42.50;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.41 10-May-2006  skrll branches: 1.41.12; 1.41.14;
Fix a bunch of cast lvalues.
 1.40 24-Dec-2005  perry branches: 1.40.4; 1.40.6; 1.40.8; 1.40.10; 1.40.12;
__asm__ -> __asm
__const__ -> const
__inline__ -> inline
__volatile__ -> volatile
 1.39 24-Dec-2005  perry Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.
 1.38 11-Dec-2005  christos merge ktrace-lwp.
 1.37 04-Jun-2005  he branches: 1.37.2;
Adapt to compiling with -Wshadow and -Wcast-qual, by adding const
qualification in places and renaming a few local variables.
Also adds a couple uses of __UNVOLATILE() to allow passing volatile
variables to functions wanting e.g. caddr_t.
 1.36 15-Jul-2003  lukem __KERNEL_RCSID()
 1.35 03-May-2003  wiz branches: 1.35.2;
DMA, not dma nor Dma.
 1.34 01-Apr-2003  thorpej Use PAGE_SIZE rather than NBPG.
 1.33 16-Sep-2001  wiz branches: 1.33.4;
Spell 'occurred' with two 'r's.
 1.32 09-Jul-2001  leo branches: 1.32.2; 1.32.4;
defopt atari scsi options.
 1.31 29-Mar-2000  leo Nuke a bunch of cf_unit abuses.
 1.30 06-Aug-1999  leo branches: 1.30.2;
Change the way that bit's are cleared in the InterruptPending register of
the 68901. Do this now by _assigning_ ~<bit_to_clear> instead of the
previously used 'andb ~<bit_to_clear>'. The latter caused a rwm-cycle that
caused a race condition to happen when an interrupt arrived between the
Read and Modify-Write.
Anyway, this solved my hanging keyboard problem.
 1.29 06-Oct-1998  leo branches: 1.29.6;
Disable SCSI interrupts while polling for the transfer to finish. This
fixes spurious panics while booting my Hades. This bug could also occur
on a TT030.
 1.28 27-Aug-1997  bouyer branches: 1.28.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.27 27-Aug-1997  leo Don't enable the dma-interrupt while polling for dma to end. This sometimes
caused a system panic on the Hades while probing the SCSI devices.
 1.26 04-Jun-1997  leo branches: 1.26.2; 1.26.4;
Use m68k cacheops
 1.25 06-Apr-1997  leo Make Hades DMA transfers work in polling mode with all interrupts
disabled. This makes dumps to scsi work.
 1.24 30-Mar-1997  leo Remove a hardcoded interrupt handler. Now uses intr_establish() for the
SCSI-drq handler on the Hades.
 1.23 12-Jan-1997  leo Use the mask register to block the interrups, not the enable register. This
enables the interrupt to be shared (with IDE for example ;-) ).
 1.22 04-Jan-1997  leo Fix a rather nasty thinko that made the keyboard useless on the Falcon.
Thanks to Markus Kilbinger for finding it.
 1.21 17-Nov-1996  leo Make splbio really splbio. All holes now seem to be plugged. At least
on the Hades & TT030.
 1.20 13-Oct-1996  christos backout previous kprintf changes
 1.19 11-Oct-1996  christos printf -> kprintf, sprintf -> ksprintf
 1.18 16-Sep-1996  leo Add support for Hades platform.
 1.17 16-Aug-1996  leo Revert to polled-DMA on Falcon.
 1.16 05-Jul-1996  leo During a rather lengthy debug session with Markus Kilbinger (Thanks again!),
we managed to kill the following SCSI-driver bugs for the Falcon:
- The Byte_Count_zero bit of the falcon DMA controller does not always
tell the truth! This caused the SCSI-driver to choke on devices that
disconnected in the middle of a DMA-transfer (mostly removables).
- Printing debug info about the 5380 on the Falcon is *only* permitted
when DMA is not active.
- Some functions forgot to remove possibly pending sofware interrupts
- Some debug options didn't allow debugging a single target while they
could easily be made to do so. This is fixed.
 1.15 18-Jun-1996  leo Pull down from release. Sorry, should have been the other way around....
 1.14 15-May-1996  leo branches: 1.14.4;
Prototype + -Wall fixes.
 1.13 26-Apr-1996  leo - Fixup the ipending function for the Falcon. This seemed to be the source
of a lot of instability problems on the Falcon. I also enabled DMA on
interrupt basis for the Falcon.
- Try to handle targets that request too much data more sanely.
- Some fixups for strict prototypes + -Wall

Thanks to Markus Kilbinger for providing the debugging support.
 1.12 18-Apr-1996  leo Yet more prototyping and -Wall fixes.
 1.11 12-Apr-1996  leo Prototyping.
 1.10 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.9 08-Mar-1996  leo Just prototyping.
 1.8 22-Feb-1996  leo A bit of reshuffling. Also some stricter prototyping.
 1.7 14-Feb-1996  leo Oops, should have been updated in conjunction with ncr5380.c .
 1.6 02-Feb-1996  mycroft Fix #includes.
 1.5 14-Jan-1996  leo The changes frpm Paul Goyette with respect to the driver trace require
DBG_PID to be defined to an interger value....make it so.
 1.4 05-Oct-1995  leo Get in sync with the mac68k version to incorporate Allen Briggs' changes
- emit MSG_ABORT/MSG_REJECT at the right times:
- make MIN_PHYS machine dependent.
 1.3 16-Sep-1995  leo - Handle devices that do not support identify messages (Allen Briggs)
- Add pdma_ready() hook (Allen Briggs)
- Increase timeout to 1000 (Matthias Pfaller)
 1.2 19-Aug-1995  leo - Add 'restbyte' handling for TT.
- Don't _ever_ do DMA for less than 512 bytes on the Falcon
- Fix bug in autosense-handling. Now asks for the correct number of bytes.
Now it won't read ghost bytes on the tape anymore.
- Add missing braces as suggested by Matthias Pfaller
- Make it possible to debug requests on a specified number of targets
- Add debug option to show only transaction with error code != 0
 1.1 11-Aug-1995  leo New version of NCR5380-SCSI driver. This version is far more generic than
the previous version. The machine dependent part contains the configuration
for both the TT and FALCON. The configuration files have been changed to
select SCSI-support for either TT, Falcon or both.
The configuration file for the Atari-Falcon will only get _really_ usefull
when the Falcon video part is finished.
 1.14.4.4 06-Sep-1996  jtc Pulled up rev 1.17 by request from leo
 1.14.4.3 31-Jul-1996  jtc Pulled up from rev 1.16 by request from Leo Weppelman
 1.14.4.2 20-Jul-1996  jtc Pulled up from rev 1.15 by request from Leo Weppelman
 1.14.4.1 18-Jun-1996  leo Get rid of some spurious interrupts caused by pending software interrupts.
 1.26.4.1 27-Aug-1997  thorpej Update marc-pcmcia branch from trunk.
 1.26.2.1 01-Jul-1997  bouyer Updates for new scsipi subsystem. Actally known to work on i386 and sparc.
 1.28.4.1 30-Oct-1998  cgd pull up rev 1.29 from trunk (leo)
 1.29.6.1 16-Dec-1999  he Pull up revision 1.30 (requested by leo):
Change the way that bits are cleared in the InterruptPending
register of the 68901, avoiding a read-modify-write cycle.
Solves a "hanging keyboard" problem.
 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.32.4.1 01-Oct-2001  fvdl Catch up with -current.
 1.32.2.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.33.4.2 16-Sep-2001  wiz Spell 'occurred' with two 'r's.
 1.33.4.1 16-Sep-2001  wiz file atari5380.c was added on branch nathanw_sa on 2001-09-16 16:34:29 +0000
 1.35.2.4 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.35.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.35.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.35.2.1 03-Aug-2004  skrll Sync with HEAD
 1.37.2.2 03-Sep-2007  yamt sync with head.
 1.37.2.1 21-Jun-2006  yamt sync with head.
 1.40.12.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.40.10.1 11-May-2006  elad sync with head
 1.40.8.1 24-May-2006  yamt sync with head.
 1.40.6.1 01-Jun-2006  kardel Sync with head.
 1.40.4.1 09-Sep-2006  rpaulo sync with head
 1.41.14.1 12-Mar-2007  rmind Sync with HEAD.
 1.41.12.3 13-Nov-2008  snj Pull up following revision(s) (requested by abs in ticket #1223):
sys/arch/atari/dev/atari5380.c: revision 1.45
Specify volatile to some pointers to access DMA registers.
 1.41.12.2 13-Nov-2008  snj Pull up following revision(s) (requested by abs in ticket #1223):
sys/arch/atari/dev/atari5380.c: revision 1.44
No need to specify '&' to get array's address.
No binary changes.
 1.41.12.1 13-Nov-2008  snj Pull up following revision(s) (requested by abs in ticket #1223):
sys/arch/atari/dev/atari5380.c: revision 1.43
Fix pointer arithmetic botch in rev 1.37.
 1.42.50.2 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.42.50.1 19-Oct-2008  haad Sync with HEAD.
 1.42.48.1 28-Jul-2008  simonb Sync with head.
 1.42.46.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.42.44.4 11-Aug-2010  yamt sync with head.
 1.42.44.3 11-Mar-2010  yamt sync with head
 1.42.44.2 18-Jul-2009  yamt sync with head.
 1.42.44.1 04-May-2009  yamt sync with head.
 1.42.40.2 17-Jan-2009  mjf Sync with HEAD.
 1.42.40.1 28-Sep-2008  mjf Sync with HEAD.
 1.45.2.3 28-Apr-2009  skrll Sync with HEAD.
 1.45.2.2 03-Mar-2009  skrll Sync with HEAD.
 1.45.2.1 19-Jan-2009  skrll Sync with HEAD.
 1.46.2.1 20-Nov-2010  riz Pull up following revision(s) (requested by tsutsui in ticket #1373):
sys/arch/atari/dev/dma.c: revision 1.25
sys/arch/atari/dev/atari5380.c: revision 1.54
Always schedule callback functions via add_sicallback(),
which calls softint_schedule(9).
We cannot use BASEPRI() to check recursive calls any longer
since softint(9) has been reorganized to use kernel thread.
 1.47.2.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.53.4.2 12-Jun-2011  rmind sync with head
 1.53.4.1 30-May-2010  rmind sync with head
 1.53.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.56.6.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.56.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.58.6.1 18-Feb-2012  mrg merge to -current.
 1.58.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.58.2.1 17-Apr-2012  yamt sync with head
 1.59.10.1 18-May-2014  rmind sync with head
 1.59.6.2 03-Dec-2017  jdolecek update from HEAD
 1.59.6.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.60.2.1 10-Aug-2014  tls Rebase.
 1.62.8.1 27-Sep-2017  jdolecek pass ata channel interlock to st_dmagrab() so that it can release
and reacquire it if it sleeps
 1.63.4.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.67 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.66 07-Sep-2025  thorpej Remove unnecessary NULL-initialization of TODR handle fields.
 1.65 07-Sep-2025  thorpej Initialize the TODR cookie. Not used now, but will be in the future.
 1.64 26-Jun-2022  tsutsui Use aprint_*(9) for device attach messages.
 1.63 26-Jun-2022  tsutsui Make local devsw functions static.

No visible regression on TT030.
 1.62 03-Jul-2020  maxv hardclock_ticks -> getticks()
 1.61 29-May-2020  rin For struct timecounter, use C99 initializers.
Compile tested. No functional changes intended.
 1.60 29-Jun-2019  tsutsui Misc cosmetics and cleanup.
 1.59 25-Jul-2014  dholland branches: 1.59.28;
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 26-Mar-2014  christos branches: 1.58.2;
kill sprintf
 1.57 24-Mar-2014  christos - remove unused
- use cpu_{g,s}etmodel() (not committed yet)
 1.56 16-Mar-2014  dholland 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 26-Jan-2013  apb branches: 1.55.2;
use sizeof(buffer) - 1, not sizeof(buffer - 1)
 1.54 30-Jun-2012  tsutsui branches: 1.54.2;
Fix buffer overrun (off by one). PR port-atari/42717
 1.53 05-Jun-2011  tsutsui branches: 1.53.2;
Split device_t/softc. No crash on TT030.
 1.52 08-Feb-2011  rmind branches: 1.52.2;
Remove clause 3 (UCB advertising clause) from the University of Utah
copyright. Confirmed by Mike Hibler, mike at cs.utah.edu - thanks!
Also, merge UCB and Utah copyright texts back into one, as they
originally were.

Extra verification by snj@.
 1.51 13-Apr-2010  tsutsui branches: 1.51.2; 1.51.4;
Include "ioconf.h" to declare struct cfdriver foo_cd.
 1.50 23-Aug-2009  tsutsui branches: 1.50.2; 1.50.4;
Use proper pointer types and names rather than casts for readability.
 1.49 07-Jul-2009  tsutsui KNF, ANSIfy, etc.
 1.48 07-Jul-2009  tsutsui Explicitly initialize the MFP Timer-B for delay(9) from atari_hwinit()
rather than using if(!atari_realconfig) in clockmatch().
(I doubt the latter one has actually been called..)
 1.47 07-Jul-2009  tsutsui Add a workaround for annoying
"WARNING: negative runtime; monotonic clock has gone backwards"
message. Partially taken from hp300.
 1.46 18-Mar-2009  cegger Ansify function definitions w/o arguments. Generated with sed.
 1.45 14-Mar-2009  dsl ANSIfy another 1261 function definitions.
The only ones left in sys are beyond by sed script!
(or in sys/dist or sys/external)
Mostly they have function pointer parameters.
 1.44 14-Mar-2009  dsl Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.43 14-Mar-2009  dsl Remove all the __P() from sys (excluding sys/dist)
Diff checked with grep and MK1 eyeball.
i386 and amd64 GENERIC and sys still build.
 1.42 04-Nov-2008  abs branches: 1.42.4;
Move tc_init(&clk_timecounter); to stop the "timecounter:" message
appearing in the middle of the clock0 attach message. Tested by
Tuomo Makinen
 1.41 11-Jun-2008  tsutsui branches: 1.41.2; 1.41.4; 1.41.6;
Use device_private() and device_lookup_privat() to get softc.
 1.40 08-Jan-2008  joerg branches: 1.40.6; 1.40.8; 1.40.10; 1.40.12; 1.40.14;
Convert Atari to generic TODR and timecounter.
 1.39 03-Jan-2008  joerg Simplify delay based on x86 version.
 1.38 04-Mar-2007  christos branches: 1.38.20; 1.38.26; 1.38.32;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.37 24-Dec-2005  perry branches: 1.37.24; 1.37.26; 1.37.34;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.
 1.36 11-Dec-2005  christos merge ktrace-lwp.
 1.35 04-Jun-2005  he branches: 1.35.2;
Adapt to compiling with -Wshadow and -Wcast-qual, by adding const
qualification in places and renaming a few local variables.
Also adds a couple uses of __UNVOLATILE() to allow passing volatile
variables to functions wanting e.g. caddr_t.
 1.34 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.33 15-Jul-2003  lukem __KERNEL_RCSID()
 1.32 17-Jan-2003  thorpej branches: 1.32.2;
Merge the nathanw_sa branch.
 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 Use CFATTACH_DECL().
 1.29 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.28 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.27 26-Jul-2001  wiz branches: 1.27.2; 1.27.6; 1.27.14;
Various typos in comments (neccessary, sceme, choise, ...).
 1.26 18-Jun-2001  wiz branches: 1.26.2;
Symmetric has one s and two m's.
 1.25 24-Apr-2001  leo Add sanity checking on register B of the mc146818.
 1.24 29-Jan-2001  leo branches: 1.24.2;
Fix y2001 problem in the initial read of the RTC.
 1.23 07-Jun-2000  leo branches: 1.23.2;
Mark 'n' explicitely as output of the 'mulul' instruction.
 1.22 31-May-2000  leo Fix some bugs in clkread(). These bugs caused strange time leaps.
 1.21 06-Jan-2000  leo branches: 1.21.2;
Fix y2k buglet in /dev/rtc reported by Julian Coleman. Note that the input
and output format of /dev/rtc is now changed.
 1.20 06-Aug-1999  leo branches: 1.20.2;
Change the way that bit's are cleared in the InterruptPending register of
the 68901. Do this now by _assigning_ ~<bit_to_clear> instead of the
previously used 'andb ~<bit_to_clear>'. The latter caused a rwm-cycle that
caused a race condition to happen when an interrupt arrived between the
Read and Modify-Write.
Anyway, this solved my hanging keyboard problem.
 1.19 12-Jan-1998  thorpej branches: 1.19.8;
Update for changes to config.
 1.18 26-Feb-1997  leo Use generic date conversion module.
 1.17 20-Dec-1996  leo branches: 1.17.6;
Get rid of BROKEN_INDIRECT_CONFIG
 1.16 18-Dec-1996  leo Tweak the clockframe structure a bit so we are able to save a few cycles
at interrupt time. (From Gordon Ross).
 1.15 16-Dec-1996  leo Move up the initialisations for the delay routine in the initialisation
process. It's now also available to the different device probes.
 1.14 16-Dec-1996  leo Implement an rtc-device. Credits for the idea goes to Wolfgang Solfrank.
Because there is no way yet to tell init(1) to execute commands before
single user-mode is entered, the inittodr() function is still partly
functional. It retrieves the value of the RTC and sets the time as if
the RTC was running at UTC. The resettodr() function is a No-Op. The
RTC can only be changed by a write to /dev/rtc.
The TIMEZONE and DST options are no longer needed and removed from the
config files.
 1.13 13-Oct-1996  christos backout previous kprintf changes
 1.12 11-Oct-1996  christos printf -> kprintf, sprintf -> ksprintf
 1.11 26-Apr-1996  leo Corrections for removed <sys/cpu.h> and some more prototypes.
 1.10 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.9 22-Feb-1996  leo First bunch of changes due to stricter prototype checking.
 1.8 11-Feb-1996  leo Some extra range-tests on the RTC values.
 1.7 06-Jan-1996  leo Add an nvram-driver. This driver makes it possible to read/write the
configuration info stored in the nvram on the mc146818.
 1.6 01-Dec-1995  leo Remove forgotten #endif
 1.5 30-Nov-1995  leo Add kernel option for separate {stat,prof}clock
 1.4 23-Sep-1995  leo PROF -> GPROF
 1.3 28-May-1995  leo Use <dev/ic/mc146818.h>. Change systemclock settings. Usable values for
HZ are now 48/64/96. This reduces the interrupt overhead, because we
don't need the extra division by 4 in the interrupt handler.
 1.2 05-May-1995  leo Shift system clocks from TT-mfp to ST-mfp and remove some dead-code.
 1.1 26-Mar-1995  leo branches: 1.1.1;
Initial revision
 1.1.1.1 26-Mar-1995  leo NetBSD/Atari, port by Leo Weppelman.
 1.17.6.1 12-Mar-1997  is Merge in Changes from The Trunk.
 1.19.8.2 21-Jan-2000  he Pull up revision 1.21 (requested by leo):
Fix Y2K buglet in /dev/rtc. Note that the input and output format
of that device has now changed.
 1.19.8.1 16-Dec-1999  he Pull up revision 1.20 (requested by leo):
Change the way that bits are cleared in the InterruptPending
register of the 68901, avoiding a read-modify-write cycle.
Solves a "hanging keyboard" problem.
 1.20.2.2 11-Feb-2001  bouyer Sync with HEAD.
 1.20.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.21.2.1 22-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.23.2.1 26-Feb-2001  he Pull up revision 1.24 (requested by leo):
Fix y2k+1 problem.
 1.24.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.26.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.26.2.1 03-Aug-2001  lukem update to -current
 1.27.14.1 17-May-2002  gehenna Add device switch.
 1.27.6.7 11-Nov-2002  nathanw Catch up to -current
 1.27.6.6 18-Oct-2002  nathanw Catch up to -current.
 1.27.6.5 17-Sep-2002  nathanw Catch up to -current.
 1.27.6.4 12-Jul-2002  nathanw No longer need to pull in lwp.h; proc.h pulls it in for us.
 1.27.6.3 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.27.6.2 17-Nov-2001  scw MD Scheduler Activation bits for Atari.
Compile-tested only.
 1.27.6.1 26-Jul-2001  scw file clock.c was added on branch nathanw_sa on 2001-11-17 23:18:08 +0000
 1.27.2.1 10-Oct-2001  fvdl Convert all remaining devices.
 1.32.2.5 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.32.2.4 17-Jan-2005  skrll Adapt to branch.
 1.32.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.32.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.32.2.1 03-Aug-2004  skrll Sync with HEAD
 1.35.2.3 21-Jan-2008  yamt sync with head
 1.35.2.2 03-Sep-2007  yamt sync with head.
 1.35.2.1 21-Jun-2006  yamt sync with head.
 1.37.34.1 03-Jan-2009  jdc Pull up revisions:
1.39 sys/arch/atari/dev/clock.c
1.31 sys/arch/atari/include/param.h
(requested by tsutsui in ticket #1253).

Simplify delay based on x86 version.
 1.37.26.1 12-Mar-2007  rmind Sync with HEAD.
 1.37.24.1 02-Jan-2009  jdc Pull up revisions:
1.39 sys/arch/atari/dev/clock.c
1.31 sys/arch/atari/include/param.h
(requested by tsutsui in ticket #1253).

Simplify delay based on x86 version.
 1.38.32.1 08-Jan-2008  bouyer Sync with HEAD
 1.38.26.1 18-Feb-2008  mjf Sync with HEAD.
 1.38.20.2 23-Mar-2008  matt sync with HEAD
 1.38.20.1 09-Jan-2008  matt sync with HEAD
 1.40.14.1 18-Jun-2008  simonb Sync with head.
 1.40.12.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.40.10.4 11-Aug-2010  yamt sync with head.
 1.40.10.3 16-Sep-2009  yamt sync with head
 1.40.10.2 18-Jul-2009  yamt sync with head.
 1.40.10.1 04-May-2009  yamt sync with head.
 1.40.8.1 17-Jun-2008  yamt sync with head.
 1.40.6.2 17-Jan-2009  mjf Sync with HEAD.
 1.40.6.1 29-Jun-2008  mjf Sync with HEAD.
 1.41.6.2 04-Oct-2009  snj Pull up following revision(s) (requested by tsutsui in ticket #1057):
sys/arch/atari/dev/clock.c: revision 1.47
Add a workaround for annoying
"WARNING: negative runtime; monotonic clock has gone backwards"
message. Partially taken from hp300.
 1.41.6.1 06-Nov-2008  snj branches: 1.41.6.1.4;
Pull up following revision(s) (requested by abs in ticket #13):
sys/arch/atari/dev/clock.c: revision 1.42
Move tc_init(&clk_timecounter); to stop the "timecounter:" message
appearing in the middle of the clock0 attach message. Tested by
Tuomo Makinen
 1.41.6.1.4.1 21-Apr-2010  matt sync to netbsd-5
 1.41.4.2 28-Apr-2009  skrll Sync with HEAD.
 1.41.4.1 19-Jan-2009  skrll Sync with HEAD.
 1.41.2.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.42.4.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.50.4.3 12-Jun-2011  rmind sync with head
 1.50.4.2 05-Mar-2011  rmind sync with head
 1.50.4.1 30-May-2010  rmind sync with head
 1.50.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.51.4.1 17-Feb-2011  bouyer Sync with HEAD
 1.51.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.52.2.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.53.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.53.2.1 30-Oct-2012  yamt sync with head
 1.54.2.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.54.2.1 25-Feb-2013  tls resync with head
 1.55.2.1 18-May-2014  rmind sync with head
 1.58.2.1 10-Aug-2014  tls Rebase.
 1.59.28.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.5 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.4 08-Feb-2011  rmind branches: 1.4.14; 1.4.32;
Remove clause 3 (UCB advertising clause) from the University of Utah
copyright. Confirmed by Mike Hibler, mike at cs.utah.edu - thanks!
Also, merge UCB and Utah copyright texts back into one, as they
originally were.

Extra verification by snj@.
 1.3 11-Dec-2005  christos branches: 1.3.100; 1.3.106; 1.3.108;
merge ktrace-lwp.
 1.2 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.1 26-Mar-1995  leo branches: 1.1.1;
Initial revision
 1.1.1.1 26-Mar-1995  leo branches: 1.1.1.1.66;
NetBSD/Atari, port by Leo Weppelman.
 1.1.1.1.66.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.1.1.1.66.2 18-Sep-2004  skrll Sync with HEAD.
 1.1.1.1.66.1 03-Aug-2004  skrll Sync with HEAD
 1.3.108.1 17-Feb-2011  bouyer Sync with HEAD
 1.3.106.1 06-Jun-2011  jruoho Sync with HEAD.
 1.3.100.1 05-Mar-2011  rmind sync with head
 1.4.32.1 22-Sep-2015  skrll Sync with HEAD
 1.4.14.1 03-Dec-2017  jdolecek update from HEAD
 1.7 17-Nov-2014  christos PR/49207: Kamil Rytarowski: Add sys/clock.h with generic time macros
(derived from clock_subr.h). Keep clock_subr.h with the kernel structures
and functions to reduce diffs, and have clock.h only include standalone
constants and macros.
 1.6 20-Oct-2009  snj branches: 1.6.22;
Remove 3rd and 4th clause on Leo Weppelman's license. OK leo@.
 1.5 24-Apr-2001  leo branches: 1.5.8; 1.5.130;
The register spacing for the Milan is different.
 1.4 06-Jan-1996  leo branches: 1.4.42;
Add an nvram-driver. This driver makes it possible to read/write the
configuration info stored in the nvram on the mc146818.
 1.3 28-Jun-1995  cgd note that most of dev/ic's contents have changed names
 1.2 28-May-1995  leo Use <dev/ic/mc146818.h>. Change systemclock settings. Usable values for
HZ are now 48/64/96. This reduces the interrupt overhead, because we
don't need the extra division by 4 in the interrupt handler.
 1.1 26-Mar-1995  leo branches: 1.1.1;
Initial revision
 1.1.1.1 26-Mar-1995  leo NetBSD/Atari, port by Leo Weppelman.
 1.4.42.1 21-Jun-2001  nathanw Catch up to -current.
 1.5.130.1 11-Mar-2010  yamt sync with head
 1.5.8.2 24-Apr-2001  leo The register spacing for the Milan is different.
 1.5.8.1 24-Apr-2001  leo file clockreg.h was added on branch nathanw_sa on 2001-04-24 06:27:59 +0000
 1.6.22.1 03-Dec-2017  jdolecek update from HEAD
 1.1 07-Jul-2009  tsutsui branches: 1.1.2;
Explicitly initialize the MFP Timer-B for delay(9) from atari_hwinit()
rather than using if(!atari_realconfig) in clockmatch().
(I doubt the latter one has actually been called..)
 1.1.2.2 18-Jul-2009  yamt sync with head.
 1.1.2.1 07-Jul-2009  yamt file clockvar.h was added on branch yamt-nfs-mp on 2009-07-18 14:52:52 +0000
 1.29 06-Jan-2023  tsutsui TAB/spaces/indents cleanup.
 1.28 07-Oct-2017  jdolecek Merge support for SATA NCQ (Native Command Queueing) from jdolecek-ncq branch

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

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

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

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

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

Also fixes PR kern/43169 (wd(4)); and PR kern/11811, PR kern/47041,
PR kern/51979 (kernel dump)
 1.27 12-Apr-2010  tsutsui branches: 1.27.18; 1.27.48;
- more cosmetics
- use queue(3) macro properly
 1.26 12-Apr-2010  tsutsui KNF and cosmetics.
 1.25 10-Apr-2010  tsutsui Always schedule callback functions via add_sicallback(),
which calls softint_schedule(9).

We cannot use BASEPRI() to check recursive calls any longer
since softint(9) has been reorganized to use kernel thread.
 1.24 20-Oct-2009  snj branches: 1.24.2; 1.24.4;
Remove 3rd and 4th clause on Leo Weppelman's license. OK leo@.
 1.23 08-Jul-2009  tsutsui Merge local <atari/atari/intr.h> into common <machine/intr.h>.
 1.22 18-Mar-2009  cegger Ansify function definitions w/o arguments. Generated with sed.
 1.21 14-Mar-2009  dsl ANSIfy another 1261 function definitions.
The only ones left in sys are beyond by sed script!
(or in sys/dist or sys/external)
Mostly they have function pointer parameters.
 1.20 14-Mar-2009  dsl Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.19 14-Mar-2009  dsl Remove all the __P() from sys (excluding sys/dist)
Diff checked with grep and MK1 eyeball.
i386 and amd64 GENERIC and sys still build.
 1.18 04-Mar-2007  christos branches: 1.18.44; 1.18.52; 1.18.54; 1.18.58;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.17 11-Dec-2005  christos branches: 1.17.26;
merge ktrace-lwp.
 1.16 15-Jul-2003  lukem branches: 1.16.16;
__KERNEL_RCSID()
 1.15 27-Sep-2002  provos branches: 1.15.6;
remove trailing \n in panic(). approved perry.
 1.14 27-Jan-1997  leo branches: 1.14.40; 1.14.44;
Add option to sleep until ST_DMA becomes available.
 1.13 12-Jan-1997  leo branches: 1.13.2;
Fix return value of the interrupt function.
 1.12 01-Jan-1997  leo The ST-DMA driver now uses intr_establish.
 1.11 13-Oct-1996  christos backout previous kprintf changes
 1.10 11-Oct-1996  christos printf -> kprintf, sprintf -> ksprintf
 1.9 05-Jul-1996  leo Add missing spl0() call.
 1.8 18-Jun-1996  leo Pull down from release. Sorry, should have been the other way around....
 1.7 19-Apr-1996  leo branches: 1.7.4;
Prototypes.
 1.6 22-Feb-1996  leo First bunch of changes due to stricter prototype checking.
 1.5 06-Nov-1995  leo The Falcon needs a delay after writing the dma_data register (Thomas Gerner)
 1.4 14-May-1995  leo branches: 1.4.2;
- Remove race condition from DMA interrupt handler
- Add function to get current DMA address for Falcon SCSI.
 1.3 30-Apr-1995  leo Complete rewrite, made necessary because Falcon SCSI needs to share
NCR5380 and DMA access with floppy.
 1.2 22-Apr-1995  leo - Remove register access functions from dma.c -> fd.c and inline them
- Add write protect checking (mistereously disapeared during port)
- Make fdclose() return a sensible value
- Prefix 'dma-defines' with DMA_
 1.1 26-Mar-1995  leo branches: 1.1.1;
Initial revision
 1.1.1.1 26-Mar-1995  leo NetBSD/Atari, port by Leo Weppelman.
 1.4.2.1 06-Nov-1995  leo Update from main branch.
 1.7.4.2 19-Jul-1996  jtc Pulled up from rev 1.9 by request from Leo Weppelman
 1.7.4.1 18-Jun-1996  leo Get rid of some spurious interrupts caused by pending software interrupts.
 1.13.2.1 30-Jan-1997  thorpej update from trunk
 1.14.44.1 18-Oct-2002  nathanw Catch up to -current.
 1.14.40.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.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.16.1 03-Sep-2007  yamt sync with head.
 1.17.26.1 12-Mar-2007  rmind Sync with HEAD.
 1.18.58.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.18.54.1 20-Nov-2010  riz Pull up following revision(s) (requested by tsutsui in ticket #1373):
sys/arch/atari/dev/dma.c: revision 1.25
sys/arch/atari/dev/atari5380.c: revision 1.54
Always schedule callback functions via add_sicallback(),
which calls softint_schedule(9).
We cannot use BASEPRI() to check recursive calls any longer
since softint(9) has been reorganized to use kernel thread.
 1.18.52.1 28-Apr-2009  skrll Sync with HEAD.
 1.18.44.4 11-Aug-2010  yamt sync with head.
 1.18.44.3 11-Mar-2010  yamt sync with head
 1.18.44.2 18-Jul-2009  yamt sync with head.
 1.18.44.1 04-May-2009  yamt sync with head.
 1.24.4.1 30-May-2010  rmind sync with head
 1.24.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.27.48.1 27-Sep-2017  jdolecek pass ata channel interlock to st_dmagrab() so that it can release
and reacquire it if it sleeps
 1.27.18.1 03-Dec-2017  jdolecek update from HEAD
 1.17 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.16 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.15 19-Dec-2020  thorpej - malloc(9) -> kmem(9)
- Use sel{record,remove}_knote().
 1.14 25-Oct-2017  maya branches: 1.14.16;
Use C99 initializer for filterops

Mostly done with spatch with touchups for indentation

@@
expression a;
identifier b,c,d;
identifier p;
@@
const struct filterops p =
- { a, b, c, d
+ {
+ .f_isfd = a,
+ .f_attach = b,
+ .f_detach = c,
+ .f_event = d,
};
 1.13 14-Mar-2009  dsl branches: 1.13.22;
Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.12 01-Mar-2008  rmind branches: 1.12.4; 1.12.12; 1.12.18;
Welcome to 4.99.55:

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

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

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

Note: please pass appropriate value of 'events' where possible.
Proposed on: <tech-kern>
 1.11 04-Mar-2007  christos branches: 1.11.20; 1.11.36; 1.11.40;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.10 11-Dec-2005  christos branches: 1.10.26;
merge ktrace-lwp.
 1.9 07-Aug-2003  agc branches: 1.9.16;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.8 15-Jul-2003  lukem __KERNEL_RCSID()
 1.7 26-Nov-2002  christos branches: 1.7.6;
si_ -> sel_
 1.6 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.5 08-Oct-1996  thorpej branches: 1.5.42; 1.5.46;
Merge the netbsd-1-2 branch into the mainline.
 1.4 25-Sep-1996  leo Catchup with -current:
- Extra argument to boot()
- select -> poll
 1.3 30-May-1996  leo Add missing spl(x). (Jason Thorpe)
 1.2 25-Jun-1995  leo branches: 1.2.6;
Mouse driver added.
 1.1 26-Mar-1995  leo branches: 1.1.1;
Initial revision
 1.1.1.1 26-Mar-1995  leo NetBSD/Atari, port by Leo Weppelman.
 1.2.6.1 18-Jun-1996  leo Pull up from trunk.
 1.5.46.2 11-Dec-2002  thorpej Sync with HEAD.
 1.5.46.1 11-Nov-2002  nathanw Catch up to -current
 1.5.42.3 02-Oct-2002  jdolecek do not need the (void *) cast for kn_hook anymore
 1.5.42.2 12-Sep-2001  thorpej Fix a past'o.
 1.5.42.1 09-Sep-2001  thorpej Add kqueue support (not yet compiled).
 1.7.6.4 17-Jan-2005  skrll Adapt to branch.
 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.9.16.3 17-Mar-2008  yamt sync with head.
 1.9.16.2 03-Sep-2007  yamt sync with head.
 1.9.16.1 21-Jun-2006  yamt sync with head.
 1.10.26.1 12-Mar-2007  rmind Sync with HEAD.
 1.11.40.1 03-Apr-2008  mjf Sync with HEAD.
 1.11.36.1 24-Mar-2008  keiichi sync with head.
 1.11.20.1 23-Mar-2008  matt sync with HEAD
 1.12.18.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.12.12.1 28-Apr-2009  skrll Sync with HEAD.
 1.12.4.1 04-May-2009  yamt sync with head.
 1.13.22.1 03-Dec-2017  jdolecek update from HEAD
 1.14.16.1 03-Jan-2021  thorpej Sync w/ HEAD.
 1.10 24-May-2020  hannken Change proc_lock -> &proc_lock.
 1.9 29-Mar-2014  tsutsui Make sure to acquire proc_lock mutex on calling psignal(9) in EV_WAKEUP().

Without this, Xserver could cause panic on the DIAGNOSTIC kernel as x68k:
http://mail-index.netbsd.org/source-changes/2012/08/15/msg036632.html
 1.8 14-Mar-2009  dsl branches: 1.8.12; 1.8.22; 1.8.26;
Remove all the __P() from sys (excluding sys/dist)
Diff checked with grep and MK1 eyeball.
i386 and amd64 GENERIC and sys still build.
 1.7 01-Mar-2008  rmind branches: 1.7.4; 1.7.12; 1.7.18;
Welcome to 4.99.55:

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

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

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

Note: please pass appropriate value of 'events' where possible.
Proposed on: <tech-kern>
 1.6 04-Mar-2007  christos branches: 1.6.20; 1.6.36; 1.6.40;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.5 11-Dec-2005  christos branches: 1.5.26;
merge ktrace-lwp.
 1.4 07-Aug-2003  agc branches: 1.4.16;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.3 23-Oct-2002  jdolecek branches: 1.3.6;
merge kqueue branch into -current

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

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

based on work done by Jonathan Lemon for FreeBSD
initial NetBSD port done by Luke Mewburn and Jason Thorpe
 1.2 25-Sep-1996  leo branches: 1.2.42; 1.2.46;
Catchup with -current:
- Extra argument to boot()
- select -> poll
 1.1 26-Mar-1995  leo branches: 1.1.1;
Initial revision
 1.1.1.1 26-Mar-1995  leo NetBSD/Atari, port by Leo Weppelman.
 1.2.46.1 11-Nov-2002  nathanw Catch up to -current
 1.2.42.1 09-Sep-2001  thorpej Add kqueue support (not yet compiled).
 1.3.6.4 17-Jan-2005  skrll Adapt to branch.
 1.3.6.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.3.6.2 18-Sep-2004  skrll Sync with HEAD.
 1.3.6.1 03-Aug-2004  skrll Sync with HEAD
 1.4.16.3 17-Mar-2008  yamt sync with head.
 1.4.16.2 03-Sep-2007  yamt sync with head.
 1.4.16.1 21-Jun-2006  yamt sync with head.
 1.5.26.1 12-Mar-2007  rmind Sync with HEAD.
 1.6.40.1 03-Apr-2008  mjf Sync with HEAD.
 1.6.36.1 24-Mar-2008  keiichi sync with head.
 1.6.20.1 23-Mar-2008  matt sync with HEAD
 1.7.18.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.7.12.1 28-Apr-2009  skrll Sync with HEAD.
 1.7.4.1 04-May-2009  yamt sync with head.
 1.8.26.1 18-May-2014  rmind sync with head
 1.8.22.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.8.12.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.99 20-Jul-2024  andvar fix typos in comments, mainly s/harware/hardware/.
 1.98 20-Dec-2023  thorpej branches: 1.98.2;
Remove unnecessary <sys/malloc.h> include.
 1.97 30-Aug-2023  andvar atari/fdc(4): fix printf format specifiers for FLP_DEBUG build.
 1.96 24-Jun-2023  msaitoh Fix typo in comment.
 1.95 06-Jan-2023  tsutsui TAB/spaces/indents cleanup.
 1.94 26-Jun-2022  tsutsui Use aprint_*(9) for device attach messages.
 1.93 26-Jun-2022  tsutsui Make local devsw functions static.

No visible regression on TT030.
 1.92 15-May-2022  andvar s/wich/which in comments.
 1.91 03-May-2022  andvar fix various typos, mainly s/trasfering/transferring/ and s/theese/these/.
 1.90 11-Apr-2022  andvar s/simular/similar/
 1.89 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.88 24-Apr-2021  thorpej branches: 1.88.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.87 03-Sep-2018  riastradh branches: 1.87.14;
Rename min/max -> uimin/uimax for better honesty.

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

HOWEVER! Some subsystems have

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

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

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

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

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

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

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)
 1.86 08-Feb-2018  dholland branches: 1.86.2; 1.86.4;
Typos.
 1.85 07-Oct-2017  jdolecek Merge support for SATA NCQ (Native Command Queueing) from jdolecek-ncq branch

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

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

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

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

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

Also fixes PR kern/43169 (wd(4)); and PR kern/11811, PR kern/47041,
PR kern/51979 (kernel dump)
 1.84 26-Apr-2015  mlelstv branches: 1.84.6;
Use C99-style initializers for struct dkdriver.
 1.83 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.82 01-Jan-2015  christos declare error
 1.81 31-Dec-2014  christos make more drivers use disk_ioctl, and add a dev parameter to it so that
we can merge the "easy" disklabel ioctls to it. Ultimately all this will
go do dk_ioctl once all the drivers have been converted.
 1.80 18-Oct-2014  snj branches: 1.80.2;
src is too big these days to tolerate superfluous apostrophes. It's
"its", people!
 1.79 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.78 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.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 13-Apr-2010  tsutsui branches: 1.76.8; 1.76.18; 1.76.22;
Misc KNF.
 1.75 07-Apr-2010  tsutsui Misc KNF.
 1.74 07-Apr-2010  tsutsui - split device_t/softc
- use device_lookup_private() directly rather than via local macro
 1.73 07-Apr-2010  tsutsui extern inline -> static inline
 1.72 20-Oct-2009  snj branches: 1.72.2; 1.72.4;
Remove 3rd and 4th clause on Leo Weppelman's license. OK leo@.
 1.71 31-Jul-2009  tsutsui Read AD_CFG_SWITCH via volatile pointer so that
the default density is detected correctly.
 1.70 19-Jul-2009  tsutsui Remove extra whitespace added by a dumb tool which replaced bcopy with memcpy.
 1.69 18-Mar-2009  cegger bcopy -> memcpy
 1.68 18-Mar-2009  cegger bzero -> memset
 1.67 18-Mar-2009  cegger Ansify function definitions w/o arguments. Generated with sed.
 1.66 14-Mar-2009  dsl ANSIfy another 1261 function definitions.
The only ones left in sys are beyond by sed script!
(or in sys/dist or sys/external)
Mostly they have function pointer parameters.
 1.65 14-Mar-2009  dsl Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.64 14-Mar-2009  dsl Remove all the __P() from sys (excluding sys/dist)
Diff checked with grep and MK1 eyeball.
i386 and amd64 GENERIC and sys still build.
 1.63 13-Jan-2009  yamt branches: 1.63.2;
g/c BUFQ_FOO() macros and use bufq_foo() directly.
 1.62 11-Jun-2008  tsutsui branches: 1.62.4; 1.62.6; 1.62.12;
Use device_private() and device_lookup_privat() to get softc.
 1.61 17-Oct-2007  garbled branches: 1.61.16; 1.61.18; 1.61.20; 1.61.22; 1.61.24;
Merge the ppcoea-renovation branch to HEAD.

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

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

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.60 17-Oct-2007  he Fix typo: in disk_init() call: fd -> sc.
 1.59 08-Oct-2007  ad branches: 1.59.2;
Merge disk init changes from the vmlocking branch. These seperate init /
destroy of 'struct disk' from attach / detach.
 1.58 29-Jul-2007  ad branches: 1.58.4; 1.58.6; 1.58.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.57 09-Jul-2007  ad branches: 1.57.2; 1.57.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.56 06-Mar-2007  tsutsui branches: 1.56.2; 1.56.4; 1.56.10;
Make io_data (char *) rather than adding an extra cast
since it's used only in this file to calculate buffer address.
 1.55 06-Mar-2007  he More fixes after the caddr_t removal.
Mostly cast to char* for pointer arithmetic,
but also one missing indirection, and one "void *v, x;" fix.
 1.54 04-Mar-2007  christos Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.53 24-Dec-2005  perry branches: 1.53.26;
__asm__ -> __asm
__const__ -> const
__inline__ -> inline
__volatile__ -> volatile
 1.52 11-Dec-2005  christos merge ktrace-lwp.
 1.51 15-Oct-2005  yamt - 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.50 04-Jun-2005  he branches: 1.50.2;
Adapt to compiling with -Wshadow and -Wcast-qual, by adding const
qualification in places and renaming a few local variables.
Also adds a couple uses of __UNVOLATILE() to allow passing volatile
variables to functions wanting e.g. caddr_t.
 1.49 28-Oct-2004  yamt move buffer queue related stuffs from buf.h to their own header, bufq.h.
 1.48 04-Jan-2004  wiz Spell controller with two ls. Inspired by miod@openbsd.
 1.47 15-Jul-2003  lukem __KERNEL_RCSID()
 1.46 03-May-2003  wiz branches: 1.46.2;
DMA, not dma nor Dma.
 1.45 01-Jan-2003  thorpej Use aprint_normal() for cfprint routines.
 1.44 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.43 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.42 02-Oct-2002  thorpej Use CFATTACH_DECL().
 1.41 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.40 27-Sep-2002  provos remove trailing \n in panic(). approved perry.
 1.39 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.38 10-Aug-2002  hannken Convert to new device buffer queue interface.

Approved by: Leo Weppelman <leo@netbsd.org>
 1.37 26-Jul-2001  wiz branches: 1.37.2; 1.37.6; 1.37.14;
issueing -> issuing
 1.36 29-Mar-2000  leo branches: 1.36.8;
Nuke a bunch of cf_unit abuses.
 1.35 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.34 13-Mar-2000  soren Fix doubled 'the's in comments.
 1.33 15-Feb-2000  leo Grabage collect a 'struct buf *' left over from recent disksort changes.
 1.32 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.31 21-Jan-2000  thorpej Update for sys/buf.h/disksort_*() changes.
 1.30 06-Jan-2000  leo Determine the default floppy type on the TT/Falcon by reading the config
switches. (Thanks to Michael Schwingen for the missing bits of information!).
 1.29 06-Aug-1999  leo branches: 1.29.2;
Change the way that bit's are cleared in the InterruptPending register of
the 68901. Do this now by _assigning_ ~<bit_to_clear> instead of the
previously used 'andb ~<bit_to_clear>'. The latter caused a rwm-cycle that
caused a race condition to happen when an interrupt arrived between the
Read and Modify-Write.
Anyway, this solved my hanging keyboard problem.
 1.28 24-Feb-1998  leo branches: 1.28.8;
Declare 'fd_cd'.
 1.27 12-Jan-1998  thorpej Update for changes to config.
 1.26 08-Oct-1997  thorpej Implement DIOCGDEFLABEL.
 1.25 28-Dec-1996  leo branches: 1.25.10;
Oops, this one was missed in the BROKEN_INDIRECT_CONFIG cruisade.
 1.24 06-Nov-1996  leo - Make it's behaviour on minor numbers identical to that of the Hades
floppy driver.
- Fixup format types in the debug-printf's
- Don't print empty lines on unconfigured drives.
- When a drive is detected, show it's default format.

---- Warning: minor numbers are shifted! ---
 1.23 13-Oct-1996  christos backout previous kprintf changes
 1.22 11-Oct-1996  christos printf -> kprintf, sprintf -> ksprintf
 1.21 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.20 18-Apr-1996  leo Yet more prototyping and -Wall fixes.
 1.19 12-Apr-1996  leo Prototyping.
 1.18 27-Mar-1996  leo Take out direct access to the YM2149. The chip definitions are moved
from video.h to ym2149reg.h.
 1.17 20-Mar-1996  leo Another bit of prototyping...
 1.16 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.15 22-Feb-1996  leo First bunch of changes due to stricter prototype checking.
 1.14 02-Feb-1996  mycroft Fix #includes.
 1.13 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.12 10-Dec-1995  leo Make sure that the motor will be turned off when a floppy is inserted.
 1.11 14-Oct-1995  leo Use general bound-check function.
 1.10 12-Aug-1995  mycroft branches: 1.10.2;
minphys() functions really should return void.
 1.9 24-Jul-1995  cgd fix minphys so that it actually works properly
 1.8 11-Jul-1995  leo - Change character interface as suggested by Charles
- HD floppies really have 2 sides ;-)
- Cleanup drive/density selection
 1.7 14-May-1995  leo Change of function params for Falcon SCSI.
 1.6 05-May-1995  leo Fix bug on handling HD-floppy's.
 1.5 30-Apr-1995  leo Small changes in dma locking code.
 1.4 22-Apr-1995  leo - Remove register access functions from dma.c -> fd.c and inline them
- Add write protect checking (mistereously disapeared during port)
- Make fdclose() return a sensible value
- Prefix 'dma-defines' with DMA_
 1.3 16-Apr-1995  leo Make it consistent with conf.c .
 1.2 10-Apr-1995  mycroft Fdclose --> fdclose
 1.1 26-Mar-1995  leo branches: 1.1.1;
Initial revision
 1.1.1.1 26-Mar-1995  leo NetBSD/Atari, port by Leo Weppelman.
 1.10.2.1 14-Oct-1995  leo Use general bound-check function.
 1.25.10.1 14-Oct-1997  thorpej Update marc-pcmcia branch from trunk.
 1.28.8.1 16-Dec-1999  he Pull up revision 1.29 (requested by leo):
Change the way that bits are cleared in the InterruptPending
register of the 68901, avoiding a read-modify-write cycle.
Solves a "hanging keyboard" problem.
 1.29.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.8.3 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.36.8.2 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.36.8.1 03-Aug-2001  lukem update to -current
 1.37.14.2 30-Aug-2002  gehenna catch up with -current.
 1.37.14.1 17-May-2002  gehenna Add device switch.
 1.37.6.6 03-Jan-2003  thorpej Sync with HEAD.
 1.37.6.5 11-Nov-2002  nathanw Catch up to -current
 1.37.6.4 18-Oct-2002  nathanw Catch up to -current.
 1.37.6.3 17-Sep-2002  nathanw Catch up to -current.
 1.37.6.2 13-Aug-2002  nathanw Catch up to -current.
 1.37.6.1 26-Jul-2001  nathanw file fd.c was added on branch nathanw_sa on 2002-08-13 02:18:01 +0000
 1.37.2.1 10-Oct-2001  fvdl Convert all remaining devices.
 1.46.2.6 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.46.2.5 17-Jan-2005  skrll Adapt to branch.
 1.46.2.4 02-Nov-2004  skrll Sync with HEAD.
 1.46.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.46.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.46.2.1 03-Aug-2004  skrll Sync with HEAD
 1.50.2.3 27-Oct-2007  yamt sync with head.
 1.50.2.2 03-Sep-2007  yamt sync with head.
 1.50.2.1 21-Jun-2006  yamt sync with head.
 1.53.26.1 12-Mar-2007  rmind Sync with HEAD.
 1.56.10.3 17-Oct-2007  garbled Sync with HEAD
 1.56.10.2 16-Oct-2007  garbled Sync with HEAD
 1.56.10.1 03-Oct-2007  garbled Sync with HEAD
 1.56.4.1 11-Jul-2007  mjf Sync with head.
 1.56.2.4 23-Oct-2007  ad Sync with head.
 1.56.2.3 20-Aug-2007  ad - Alter disk attach/detach to fix a panic when closing a vnd device.
- Sync with HEAD.
 1.56.2.2 19-Aug-2007  ad - Back out the biodone() changes.
- Eliminate B_ERROR (from HEAD).
 1.56.2.1 15-Jul-2007  ad Sync with head.
 1.57.4.1 15-Aug-2007  skrll Sync with HEAD.
 1.57.2.1 07-Aug-2007  matt Sync with HEAD.
 1.58.8.2 18-Oct-2007  yamt sync with head.
 1.58.8.1 14-Oct-2007  yamt sync with head.
 1.58.6.1 06-Nov-2007  matt sync with HEAD
 1.58.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.59.2.1 25-Oct-2007  bouyer Sync with HEAD.
 1.61.24.1 18-Jun-2008  simonb Sync with head.
 1.61.22.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.61.20.4 11-Aug-2010  yamt sync with head.
 1.61.20.3 11-Mar-2010  yamt sync with head
 1.61.20.2 19-Aug-2009  yamt sync with head.
 1.61.20.1 04-May-2009  yamt sync with head.
 1.61.18.1 17-Jun-2008  yamt sync with head.
 1.61.16.2 17-Jan-2009  mjf Sync with HEAD.
 1.61.16.1 29-Jun-2008  mjf Sync with HEAD.
 1.62.12.1 21-Apr-2010  matt sync to netbsd-5
 1.62.6.1 04-Oct-2009  snj Pull up following revision(s) (requested by tsutsui in ticket #1058):
sys/arch/atari/dev/fd.c: revision 1.71
Read AD_CFG_SWITCH via volatile pointer so that
the default density is detected correctly.
 1.62.4.2 28-Apr-2009  skrll Sync with HEAD.
 1.62.4.1 19-Jan-2009  skrll Sync with HEAD.
 1.63.2.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.72.4.1 30-May-2010  rmind sync with head
 1.72.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.76.22.1 18-May-2014  rmind sync with head
 1.76.18.2 03-Dec-2017  jdolecek update from HEAD
 1.76.18.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.76.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.77.2.1 10-Aug-2014  tls Rebase.
 1.80.2.2 06-Jun-2015  skrll Sync with HEAD
 1.80.2.1 06-Apr-2015  skrll Sync with HEAD
 1.84.6.1 27-Sep-2017  jdolecek pass ata channel interlock to st_dmagrab() so that it can release
and reacquire it if it sleeps
 1.86.4.1 10-Jun-2019  christos Sync with HEAD
 1.86.2.1 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.87.14.1 21-Mar-2021  thorpej Give config_found() the same variadic arguments treatment as
config_search(). This commit only adds the CFARG_EOL sentinel
to the existing config_found() calls. Conversion of config_found_sm_loc()
and config_found_ia() call sites will be in subsequent commits.
 1.88.8.1 03-Aug-2021  thorpej Adapt to CFARGS().
 1.98.2.1 02-Aug-2025  perseant Sync with HEAD
 1.3 20-Oct-2009  snj Remove 3rd and 4th clause on Leo Weppelman's license. OK leo@.
 1.2 22-Apr-1995  leo branches: 1.2.172;
- Remove register access functions from dma.c -> fd.c and inline them
- Add write protect checking (mistereously disapeared during port)
- Make fdclose() return a sensible value
- Prefix 'dma-defines' with DMA_
 1.1 26-Mar-1995  leo branches: 1.1.1;
Initial revision
 1.1.1.1 26-Mar-1995  leo NetBSD/Atari, port by Leo Weppelman.
 1.2.172.1 11-Mar-2010  yamt sync with head
 1.2 20-Oct-2009  snj Remove 3rd and 4th clause on Leo Weppelman's license. OK leo@.
 1.1 26-Mar-1995  leo branches: 1.1.1;
Initial revision
 1.1.1.1 26-Mar-1995  leo branches: 1.1.1.1.172;
NetBSD/Atari, port by Leo Weppelman.
 1.1.1.1.172.1 11-Mar-2010  yamt sync with head
 1.7 21-Sep-2023  msaitoh s/ for for / for / in comment.
 1.6 06-Jan-2023  tsutsui TAB/spaces/indents cleanup.
 1.5 21-Jun-2022  tsutsui Correct flipped glyph of 'N' in the "New Line" in the DEC graphics chars.
 1.4 11-Dec-2005  christos merge ktrace-lwp.
 1.3 15-Jul-2003  lukem __KERNEL_RCSID()
 1.2 23-Sep-1995  leo branches: 1.2.66;
Make them compliant to iso-8859-1 (Thomas Gerner).
 1.1 26-Mar-1995  leo branches: 1.1.1;
Initial revision
 1.1.1.1 26-Mar-1995  leo NetBSD/Atari, port by Leo Weppelman.
 1.2.66.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.2.66.2 18-Sep-2004  skrll Sync with HEAD.
 1.2.66.1 03-Aug-2004  skrll Sync with HEAD
 1.6 21-Sep-2023  msaitoh s/ for for / for / in comment.
 1.5 06-Jan-2023  tsutsui TAB/spaces/indents cleanup.
 1.4 11-Dec-2005  christos merge ktrace-lwp.
 1.3 15-Jul-2003  lukem __KERNEL_RCSID()
 1.2 23-Sep-1995  leo branches: 1.2.66;
Make them compliant to iso-8859-1 (Thomas Gerner).
 1.1 26-Mar-1995  leo branches: 1.1.1;
Initial revision
 1.1.1.1 26-Mar-1995  leo NetBSD/Atari, port by Leo Weppelman.
 1.2.66.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.2.66.2 18-Sep-2004  skrll Sync with HEAD.
 1.2.66.1 03-Aug-2004  skrll Sync with HEAD
 1.57 20-Dec-2023  thorpej Remove unnecessary <sys/malloc.h> include.
 1.56 06-Jan-2023  tsutsui TAB/spaces/indents cleanup.
 1.55 26-Jun-2022  tsutsui Use aprint_*(9) for device attach messages.
 1.54 26-Jun-2022  tsutsui Make local devsw functions static.

No visible regression on TT030.
 1.53 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.52 27-Apr-2021  thorpej branches: 1.52.6;
The Amiga and Atari ports abuse some autoconfiguration internals as part
of their early console bring-up, so we need to expose some of the new
internals to them and adapt the call sites.
 1.51 24-Apr-2021  thorpej branches: 1.51.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.50 29-Jun-2019  tsutsui branches: 1.50.12;
Make local functions static.
 1.49 25-Jul-2014  dholland branches: 1.49.28;
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 30-Jun-2011  wiz branches: 1.47.2; 1.47.12; 1.47.16;
dependant -> dependent
 1.46 05-Jun-2011  matt A few missed device_t, cfdata_t cleanups
 1.45 05-Jun-2011  tsutsui - use CFATTACH_DECL_NEW() (no softc)
- use device_t, cfdata_t etc.
 1.44 08-Feb-2011  rmind branches: 1.44.2;
Remove clause 3 (UCB advertising clause) from the University of Utah
copyright. Confirmed by Mike Hibler, mike at cs.utah.edu - thanks!
Also, merge UCB and Utah copyright texts back into one, as they
originally were.

Extra verification by snj@.
 1.43 13-Apr-2010  tsutsui branches: 1.43.2; 1.43.4;
Misc KNF.
 1.42 13-Apr-2010  tsutsui Include "ioconf.h" to declare struct cfdriver foo_cd.
 1.41 19-Jul-2009  tsutsui branches: 1.41.2; 1.41.4;
Remove extra whitespace added by a dumb tool which replaced bcopy with memcpy.
 1.40 18-Mar-2009  cegger bcopy -> memcpy
 1.39 14-Mar-2009  dsl ANSIfy another 1261 function definitions.
The only ones left in sys are beyond by sed script!
(or in sys/dist or sys/external)
Mostly they have function pointer parameters.
 1.38 14-Mar-2009  dsl Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.37 14-Mar-2009  dsl Remove all the __P() from sys (excluding sys/dist)
Diff checked with grep and MK1 eyeball.
i386 and amd64 GENERIC and sys still build.
 1.36 04-Mar-2007  christos branches: 1.36.44; 1.36.52; 1.36.58;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.35 11-Dec-2005  christos branches: 1.35.26;
merge ktrace-lwp.
 1.34 25-Mar-2004  leo branches: 1.34.16;
Licence cleanup (suggested by wiz).
 1.33 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.32 15-Jul-2003  lukem __KERNEL_RCSID()
 1.31 23-Oct-2002  jdolecek branches: 1.31.6;
merge kqueue branch into -current

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

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

based on work done by Jonathan Lemon for FreeBSD
initial NetBSD port done by Luke Mewburn and Jason Thorpe
 1.30 10-Oct-2002  jdolecek replace the somewhat strange poll routine with standard nopoll() (a.k.a
seltrue())
 1.29 02-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 17-Mar-2002  atatat branches: 1.26.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.25 29-Jun-2000  mrg branches: 1.25.2; 1.25.4; 1.25.8;
remove include of <vm/vm.h>. <vm/vm.h> -> <uvm/uvm_extern.h>
 1.24 26-Jun-2000  mrg remove/move more mach vm header files:

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

also includes a bunch of <vm/vm_page.h> include removals (due to redudancy
with <vm/vm.h>), and a scattering of other similar headers.
 1.23 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.22 20-Dec-1998  thomas branches: 1.22.8; 1.22.18;
Changed grf mmap that it is closer to XFree. VGA memory on et4000/et6000
is now at offset 0xa0000.
 1.21 12-Jan-1998  thorpej Update for changes to config.
 1.20 25-Apr-1997  leo - Provide the reasonable size that can/may be mmap-ed. This might differ
from the current frame buffer size.
- The et-driver now allows for a 16Kb io-region (was 8Kb) that can be
mapped. The XFree server uses this.
 1.19 26-Feb-1997  leo Fix a kernel-dump that occurred when accessing a grf-device that was configured
in the config file but not found by the autoconfig code.
 1.18 10-Jan-1997  leo branches: 1.18.6;
Allow the control registers to be mapped too.
 1.17 20-Dec-1996  leo Get rid of BROKEN_INDIRECT_CONFIG
 1.16 13-Oct-1996  christos backout previous kprintf changes
 1.15 11-Oct-1996  christos printf -> kprintf, sprintf -> ksprintf
 1.14 04-Oct-1996  leo Checkpointing my et4000 work. Note that the et-console will not be
functional until the minimal pci-support is checked in.
 1.13 25-Sep-1996  leo Catchup with -current:
- Extra argument to boot()
- select -> poll
 1.12 16-Sep-1996  leo Prepare for (soon to come) et4000 PCI console.
 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 18-Apr-1996  leo Yet more prototyping and -Wall fixes.
 1.9 20-Mar-1996  leo Fix typo in neew config changes.
 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 22-Feb-1996  leo First bunch of changes due to stricter prototype checking.
 1.6 26-Jun-1995  leo Sync grf with underlying view on open.
 1.5 09-Jun-1995  leo Fix grfmmap()
 1.4 28-May-1995  leo Remove the pointer to view_t from the grf-structure, use viewview(dev)
to obtain the pointer instead. This removes a kernel-crash that happened
when something was written to the console while the console was being
resized.
 1.3 21-May-1995  leo Minor fixes.
 1.2 10-Apr-1995  mycroft map --> mmap
 1.1 26-Mar-1995  leo branches: 1.1.1;
Initial revision
 1.1.1.1 26-Mar-1995  leo NetBSD/Atari, port by Leo Weppelman.
 1.18.6.1 12-Mar-1997  is Merge in Changes from The Trunk.
 1.22.18.1 30-Jun-2000  simonb Pull up mmap paddr_t/off_t changes from trunk.
 1.22.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.25.8.4 11-Nov-2002  nathanw Catch up to -current
 1.25.8.3 18-Oct-2002  nathanw Catch up to -current.
 1.25.8.2 17-Sep-2002  nathanw Catch up to -current.
 1.25.8.1 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.25.4.5 10-Oct-2002  jdolecek use nokqfilter (or seltrue_kqfilter()) for drivers which provide poll
routine very similar to seltrue(); the poll routines would be cleaned
up on trunk
 1.25.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.25.4.3 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.25.4.2 17-Jun-2002  jdolecek make compilable - use cdev_decl(), and remove unnecessary prototypes
from headers
 1.25.4.1 12-Sep-2001  thorpej Add noop kqueue entry points.
 1.25.2.1 10-Oct-2001  fvdl Convert all remaining devices.
 1.26.4.1 19-May-2002  gehenna Add device switch.
Replace the access to devsw table and the hard-coded majors with devsw API.
 1.31.6.4 17-Jan-2005  skrll Adapt to branch.
 1.31.6.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.31.6.2 18-Sep-2004  skrll Sync with HEAD.
 1.31.6.1 03-Aug-2004  skrll Sync with HEAD
 1.34.16.2 03-Sep-2007  yamt sync with head.
 1.34.16.1 21-Jun-2006  yamt sync with head.
 1.35.26.1 12-Mar-2007  rmind Sync with HEAD.
 1.36.58.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.36.52.1 28-Apr-2009  skrll Sync with HEAD.
 1.36.44.3 11-Aug-2010  yamt sync with head.
 1.36.44.2 19-Aug-2009  yamt sync with head.
 1.36.44.1 04-May-2009  yamt sync with head.
 1.41.4.3 12-Jun-2011  rmind sync with head
 1.41.4.2 05-Mar-2011  rmind sync with head
 1.41.4.1 30-May-2010  rmind sync with head
 1.41.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.43.4.1 17-Feb-2011  bouyer Sync with HEAD
 1.43.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.44.2.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.47.16.1 18-May-2014  rmind sync with 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.49.28.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.50.12.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.51.2.1 13-May-2021  thorpej Sync with HEAD.
 1.52.6.1 03-Aug-2021  thorpej Adapt to CFARGS().
 1.3 06-Jan-2023  tsutsui TAB/spaces/indents cleanup.
 1.2 04-Mar-2007  christos Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.1 04-Oct-1996  leo branches: 1.1.78; 1.1.116;
Checkpointing my et4000 work. Note that the et-console will not be
functional until the minimal pci-support is checked in.
 1.1.116.1 12-Mar-2007  rmind Sync with HEAD.
 1.1.78.1 03-Sep-2007  yamt sync with head.
 1.20 20-Dec-2023  thorpej Remove unnecessary <sys/malloc.h> include.
 1.19 06-Jan-2023  tsutsui TAB/spaces/indents cleanup.
 1.18 12-Feb-2012  matt Change old-style function defintions to C89 prototypes.

Approved by releng.
 1.17 20-Oct-2009  snj branches: 1.17.12; 1.17.16;
Remove 3rd and 4th clause on Leo Weppelman's license. OK leo@.
 1.16 18-Mar-2009  cegger bzero -> memset
 1.15 14-Mar-2009  dsl Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.14 14-Mar-2009  dsl Remove all the __P() from sys (excluding sys/dist)
Diff checked with grep and MK1 eyeball.
i386 and amd64 GENERIC and sys still build.
 1.13 11-Dec-2005  christos branches: 1.13.78; 1.13.86; 1.13.92;
merge ktrace-lwp.
 1.12 15-Jul-2003  lukem __KERNEL_RCSID()
 1.11 04-Mar-2002  wiz branches: 1.11.14;
possible has two s.
 1.10 04-Oct-1996  leo branches: 1.10.42; 1.10.46;
Checkpointing my et4000 work. Note that the et-console will not be
functional until the minimal pci-support is checked in.
 1.9 16-Sep-1996  leo Prepare for (soon to come) et4000 PCI console
 1.8 08-Mar-1996  leo When having a perfect match on the resolution, try to match the screen
depth as best we can.
 1.7 23-Sep-1995  leo Make sure the prototypes and inline definitions are included.
 1.6 04-Sep-1995  leo Right align color values in the bytes.
 1.5 20-Aug-1995  leo Add Falcon video support. Thanks to Thomas Gerner.
 1.4 21-May-1995  leo - Add grf_get_best_mode()
- Only update 'real' colormap when actually displaying
- Fix TT-HIGH video mode
 1.3 28-Apr-1995  leo Better way to select a display mode?
 1.2 28-Mar-1995  leo Make ite ioctl work and fixup the colormap stuff.
 1.1 26-Mar-1995  leo branches: 1.1.1;
Initial revision
 1.1.1.1 26-Mar-1995  leo NetBSD/Atari, port by Leo Weppelman.
 1.10.46.1 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.10.42.1 16-Mar-2002  jdolecek Catch up with -current.
 1.11.14.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.11.14.2 18-Sep-2004  skrll Sync with HEAD.
 1.11.14.1 03-Aug-2004  skrll Sync with HEAD
 1.13.92.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.13.86.1 28-Apr-2009  skrll Sync with HEAD.
 1.13.78.2 11-Mar-2010  yamt sync with head
 1.13.78.1 04-May-2009  yamt sync with head.
 1.17.16.1 18-Feb-2012  mrg merge to -current.
 1.17.12.1 17-Apr-2012  yamt sync with head
 1.37 06-Jan-2023  tsutsui TAB/spaces/indents cleanup.
 1.36 12-Aug-2021  andvar fix various typos in comments.
 1.35 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.34 13-Apr-2010  tsutsui branches: 1.34.58; 1.34.60;
Misc KNF.
 1.33 20-Oct-2009  snj branches: 1.33.2; 1.33.4;
Remove 3rd and 4th clause on Leo Weppelman's license. OK leo@.
 1.32 19-Jul-2009  tsutsui Remove extra whitespace added by a dumb tool which replaced bcopy with memcpy.
 1.31 18-Mar-2009  cegger bcopy -> memcpy
 1.30 18-Mar-2009  cegger Ansify function definitions w/o arguments. Generated with sed.
 1.29 14-Mar-2009  dsl Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.28 14-Mar-2009  dsl Remove all the __P() from sys (excluding sys/dist)
Diff checked with grep and MK1 eyeball.
i386 and amd64 GENERIC and sys still build.
 1.27 06-Mar-2007  tsutsui branches: 1.27.44; 1.27.52; 1.27.58;
- remove volatile from *regkva member in struct grfabs_et_priv
and use temporary variables on register accesses
- also remove volatile from *memkva member in struct grfabs_et_priv
because it isn't used to refer memory
XXX: I'm not sure if bm->plane should be volatile or not
but I don't think previous code treats it as volatile anyway.
(though I'm not sure how compiler handled "volatile caddr_t")
 1.26 04-Mar-2007  christos Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.25 29-Mar-2006  thomas branches: 1.25.14;
Do not disable access to tseng private registers
 1.24 11-Dec-2005  christos branches: 1.24.4; 1.24.6; 1.24.8; 1.24.10; 1.24.12;
merge ktrace-lwp.
 1.23 13-Feb-2004  wiz branches: 1.23.16;
Uppercase CPU, plural is CPUs.
 1.22 15-Jul-2003  lukem __KERNEL_RCSID()
 1.21 02-Feb-2003  thomas branches: 1.21.2;
Config option for et4000 boards with 2MB memory.
 1.20 27-Sep-2002  provos remove trailing \n in panic(). approved perry.
 1.19 04-Mar-2002  wiz possible has two s.
 1.18 29-Jun-2000  mrg branches: 1.18.4; 1.18.8;
remove include of <vm/vm.h>. <vm/vm.h> -> <uvm/uvm_extern.h>
 1.17 26-Jun-2000  mrg remove/move more mach vm header files:

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

also includes a bunch of <vm/vm_page.h> include removals (due to redudancy
with <vm/vm.h>), and a scattering of other similar headers.
 1.16 11-Apr-2000  leo Now what are we doing with the return value of splx()? (probably a pasto)
 1.15 11-Feb-2000  leo Remove redundant test.
 1.14 12-Jan-2000  leo Init the preset_row_scan register. This fixes a sometimes partly scrolled-up
console.
 1.13 26-Mar-1999  leo branches: 1.13.8;
Nuke the pieces of code obsoleted by .../pci/pci_tseng.c
 1.12 19-Feb-1999  leo More work on Tseng support. Now both my et6000 _and_ the et6100 work. I just
whish that programming MDRAM latency values came out of the BlackMagic(tm)
domain :-(
 1.11 20-Dec-1998  thomas Changed grf mmap that it is closer to XFree. VGA memory on et4000/et6000
is now at offset 0xa0000.
 1.10 20-Nov-1998  leo Checkpoint my work on et6000 support.
 1.9 11-May-1998  thomas Let et4000 work with other RAMDAC than STG1703
 1.8 23-Apr-1998  leo Use NOWAIT when malloc()-ing a buffer for switching screens. It might be
running from an interrupt handler.
 1.7 25-Apr-1997  leo branches: 1.7.8;
- Provide the reasonable size that can/may be mmap-ed. This might differ
from the current frame buffer size.
- The et-driver now allows for a 16Kb io-region (was 8Kb) that can be
mapped. The XFree server uses this.
 1.6 10-Jan-1997  leo Record physical addresses in the bitmap structure instead of VA's. The
latter breaks the mmap-functions.
 1.5 17-Nov-1996  leo Shift screen a bit to the left.
 1.4 13-Oct-1996  christos backout previous kprintf changes
 1.3 11-Oct-1996  leo *** empty log message ***
 1.2 11-Oct-1996  christos printf -> kprintf, sprintf -> ksprintf
 1.1 04-Oct-1996  leo Checkpointing my et4000 work. Note that the et-console will not be
functional until the minimal pci-support is checked in.
 1.7.8.1 30-Oct-1998  cgd pull up revs 1.8 and 1.9 from trunk (leo)
 1.13.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.18.8.2 18-Oct-2002  nathanw Catch up to -current.
 1.18.8.1 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.18.4.2 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.18.4.1 16-Mar-2002  jdolecek Catch up with -current.
 1.21.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.21.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.21.2.1 03-Aug-2004  skrll Sync with HEAD
 1.23.16.2 03-Sep-2007  yamt sync with head.
 1.23.16.1 21-Jun-2006  yamt sync with head.
 1.24.12.1 31-Mar-2006  tron Merge 2006-03-31 NetBSD-current into the "peter-altq" branch.
 1.24.10.1 19-Apr-2006  elad sync with head - hopefully this will work
 1.24.8.1 01-Apr-2006  yamt sync with head.
 1.24.6.1 22-Apr-2006  simonb Sync with head.
 1.24.4.1 09-Sep-2006  rpaulo sync with head
 1.25.14.1 12-Mar-2007  rmind Sync with HEAD.
 1.27.58.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.27.52.1 28-Apr-2009  skrll Sync with HEAD.
 1.27.44.4 11-Aug-2010  yamt sync with head.
 1.27.44.3 11-Mar-2010  yamt sync with head
 1.27.44.2 19-Aug-2009  yamt sync with head.
 1.27.44.1 04-May-2009  yamt sync with head.
 1.33.4.1 30-May-2010  rmind sync with head
 1.33.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.34.60.1 10-Jun-2019  christos Sync with HEAD
 1.34.58.1 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.4 04-Oct-2011  chs expand the attr array to hold all the bytes we store in it.
not that the code actually does anything with the extra bytes,
but at least it builds with gcc 4.5.
 1.3 20-Oct-2009  snj Remove 3rd and 4th clause on Leo Weppelman's license. OK leo@.
 1.2 14-Mar-2009  dsl Remove all the __P() from sys (excluding sys/dist)
Diff checked with grep and MK1 eyeball.
i386 and amd64 GENERIC and sys still build.
 1.1 11-Oct-1996  leo branches: 1.1.168; 1.1.176; 1.1.182;
- add a iteet_ioctl function so iteconfig(1) can be used to select the
screen geometry.
- Re-arrange et_loadmode() and et_inittextmode() to write into shadow
register set instead of writing to the card-registers directly.
- provide et_hwsave()/et_hwrest() functions to transfer the card-registers
to and from the shadow set.
 1.1.182.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.1.176.1 28-Apr-2009  skrll Sync with HEAD.
 1.1.168.2 11-Mar-2010  yamt sync with head
 1.1.168.1 04-May-2009  yamt sync with head.
 1.31 08-Sep-2024  rillig fix a/an grammar in obvious cases
 1.30 05-Jul-2024  andvar fix various typos in comments and log messages, mainly s/hight/high/
s/hight/height/ and removing double m in time(ing).
 1.29 06-Jan-2023  tsutsui branches: 1.29.6;
TAB/spaces/indents cleanup.
 1.28 17-Aug-2021  andvar fix multiplei repetitive typos in comments, messages and documentation. mainly because copy paste code big amount of files are affected.
 1.27 13-Apr-2010  tsutsui Misc KNF.
 1.26 21-Oct-2009  snj branches: 1.26.2; 1.26.4;
Drop 3rd and 4th clause. Approved by leo@ and thomas@ (copyright holders).
 1.25 19-Jul-2009  tsutsui Remove extra whitespace added by a dumb tool which replaced bcopy with memcpy.
 1.24 18-Mar-2009  cegger bcopy -> memcpy
 1.23 18-Mar-2009  cegger bzero -> memset
 1.22 18-Mar-2009  cegger Ansify function definitions w/o arguments. Generated with sed.
 1.21 14-Mar-2009  dsl ANSIfy another 1261 function definitions.
The only ones left in sys are beyond by sed script!
(or in sys/dist or sys/external)
Mostly they have function pointer parameters.
 1.20 14-Mar-2009  dsl Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.19 14-Mar-2009  dsl Remove all the __P() from sys (excluding sys/dist)
Diff checked with grep and MK1 eyeball.
i386 and amd64 GENERIC and sys still build.
 1.18 11-Dec-2005  christos branches: 1.18.78; 1.18.86; 1.18.92;
merge ktrace-lwp.
 1.17 15-Jul-2003  lukem __KERNEL_RCSID()
 1.16 01-Apr-2003  thorpej branches: 1.16.2;
Use PAGE_SIZE rather than NBPG.
 1.15 27-Sep-2002  provos remove trailing \n in panic(). approved perry.
 1.14 04-Mar-2002  wiz possible has two s.
 1.13 13-Mar-2000  soren branches: 1.13.8; 1.13.12;
Fix doubled 'the's in comments.
 1.12 20-Dec-1998  thomas branches: 1.12.8;
Changed grf mmap that it is closer to XFree. VGA memory on et4000/et6000
is now at offset 0xa0000.
 1.11 21-Jan-1998  leo Fix a bug in the colormap handling. (Thomas Gerner)
 1.10 10-Jun-1997  veego branches: 1.10.8;
s/atari_round_page/m68k_round_page/
 1.9 19-May-1997  leo Fix the 'shifting screens' bug on the Falcon. This solution is not perfect
since it gives a bit of flicker while switching frame buffers. From
Thomas Gerner.
 1.8 25-Apr-1997  leo - Provide the reasonable size that can/may be mmap-ed. This might differ
from the current frame buffer size.
- The et-driver now allows for a 16Kb io-region (was 8Kb) that can be
mapped. The XFree server uses this.
 1.7 04-Oct-1996  leo Checkpointing my et4000 work. Note that the et-console will not be
functional until the minimal pci-support is checked in.
 1.6 16-Sep-1996  leo Prepare for (soon to come) et4000 PCI console.
 1.5 23-Aug-1996  leo Don't use an absolute I/O adress.
 1.4 15-May-1996  leo Prototype + -Wall fixes.
 1.3 10-Mar-1996  leo Take the type of the attached monitor into account when selecting a
display-mode. Includes hack to make things work on non-VGA monitors.
 1.2 02-Jan-1996  leo Allow selection of Falcon (videl) video modes other than the mode selected
on startup (Thomas Gerner).
 1.1 20-Aug-1995  leo Add Falcon video support. Thanks to Thomas Gerner.
 1.10.8.1 30-Oct-1998  cgd pull up rev 1.11 from trunk (leo)
 1.12.8.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.13.12.2 18-Oct-2002  nathanw Catch up to -current.
 1.13.12.1 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.13.8.2 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.13.8.1 16-Mar-2002  jdolecek Catch up with -current.
 1.16.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.16.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.16.2.1 03-Aug-2004  skrll Sync with HEAD
 1.18.92.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.18.86.1 28-Apr-2009  skrll Sync with HEAD.
 1.18.78.4 11-Aug-2010  yamt sync with head.
 1.18.78.3 11-Mar-2010  yamt sync with head
 1.18.78.2 19-Aug-2009  yamt sync with head.
 1.18.78.1 04-May-2009  yamt sync with head.
 1.26.4.1 30-May-2010  rmind sync with head
 1.26.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.29.6.1 02-Aug-2025  perseant Sync with HEAD
 1.6 06-Jan-2023  tsutsui TAB/spaces/indents cleanup.
 1.5 21-Oct-2009  snj Drop 3rd and 4th clauses. Approved by thomas@ (copyright holder).
 1.4 14-Mar-2009  dsl Remove all the __P() from sys (excluding sys/dist)
Diff checked with grep and MK1 eyeball.
i386 and amd64 GENERIC and sys still build.
 1.3 16-Sep-1996  leo branches: 1.3.168; 1.3.176; 1.3.182;
Prepare for (soon to come) et4000 PCI console.
 1.2 10-Mar-1996  leo Take the type of the attached monitor into account when selecting a
display-mode. Includes hack to make things work on non-VGA monitors.
 1.1 02-Jan-1996  leo Allow selection of Falcon (videl) video modes other than the mode selected
on startup (Thomas Gerner).
 1.3.182.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.3.176.1 28-Apr-2009  skrll Sync with HEAD.
 1.3.168.2 11-Mar-2010  yamt sync with head
 1.3.168.1 04-May-2009  yamt sync with head.
 1.15 06-Jan-2023  tsutsui TAB/spaces/indents cleanup.
 1.14 14-Mar-2009  dsl Remove all the __P() from sys (excluding sys/dist)
Diff checked with grep and MK1 eyeball.
i386 and amd64 GENERIC and sys still build.
 1.13 11-Dec-2005  christos branches: 1.13.78; 1.13.86; 1.13.92;
merge ktrace-lwp.
 1.12 04-Jun-2005  he Adapt to compiling with -Wshadow and -Wcast-qual, by adding const
qualification in places and renaming a few local variables.
Also adds a couple uses of __UNVOLATILE() to allow passing volatile
variables to functions wanting e.g. caddr_t.
 1.11 20-Dec-1998  thomas branches: 1.11.42;
Changed grf mmap that it is closer to XFree. VGA memory on et4000/et6000
is now at offset 0xa0000.
 1.10 13-Mar-1997  leo Add member to bitmap struct that gives the size of mappable memory.
 1.9 11-Oct-1996  leo *** empty log message ***
 1.8 04-Oct-1996  leo Checkpointing my et4000 work. Note that the et-console will not be
functional until the minimal pci-support is checked in.
 1.7 16-Sep-1996  leo Prepare for (soon to come) et4000 PCI console.
 1.6 10-Mar-1996  leo Take the type of the attached monitor into account when selecting a
display-mode. Includes hack to make things work on non-VGA monitors.
 1.5 04-Sep-1995  leo Right align color values in the bytes.
 1.4 20-Aug-1995  leo Add Falcon video support. Thanks to Thomas Gerner.
 1.3 21-May-1995  leo Add prototype for grf_get_best_mode()
 1.2 28-Mar-1995  leo Make ite ioctl work and fixup the colormap stuff.
 1.1 26-Mar-1995  leo branches: 1.1.1;
Initial revision
 1.1.1.1 26-Mar-1995  leo NetBSD/Atari, port by Leo Weppelman.
 1.11.42.1 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.13.92.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.13.86.1 28-Apr-2009  skrll Sync with HEAD.
 1.13.78.1 04-May-2009  yamt sync with head.
 1.25 06-Jan-2023  tsutsui TAB/spaces/indents cleanup.
 1.24 17-Aug-2021  andvar fix multiplei repetitive typos in comments, messages and documentation. mainly because copy paste code big amount of files are affected.
 1.23 13-Apr-2010  tsutsui Misc KNF.
 1.22 20-Oct-2009  snj branches: 1.22.2; 1.22.4;
Remove 3rd and 4th clause on Leo Weppelman's license. OK leo@.
 1.21 19-Jul-2009  tsutsui Remove extra whitespace added by a dumb tool which replaced bcopy with memcpy.
 1.20 18-Mar-2009  cegger bcopy -> memcpy
 1.19 18-Mar-2009  cegger bzero -> memset
 1.18 14-Mar-2009  dsl ANSIfy another 1261 function definitions.
The only ones left in sys are beyond by sed script!
(or in sys/dist or sys/external)
Mostly they have function pointer parameters.
 1.17 14-Mar-2009  dsl Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.16 14-Mar-2009  dsl Remove all the __P() from sys (excluding sys/dist)
Diff checked with grep and MK1 eyeball.
i386 and amd64 GENERIC and sys still build.
 1.15 11-Dec-2005  christos branches: 1.15.78; 1.15.86; 1.15.92;
merge ktrace-lwp.
 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 01-Apr-2003  thorpej Use PAGE_SIZE rather than NBPG.
 1.11 27-Sep-2002  provos remove trailing \n in panic(). approved perry.
 1.10 04-Mar-2002  wiz possible has two s.
 1.9 20-Dec-1998  thomas branches: 1.9.22; 1.9.26;
Changed grf mmap that it is closer to XFree. VGA memory on et4000/et6000
is now at offset 0xa0000.
 1.8 10-Jun-1997  veego s/atari_round_page/m68k_round_page/
 1.7 25-Apr-1997  leo - Provide the reasonable size that can/may be mmap-ed. This might differ
from the current frame buffer size.
- The et-driver now allows for a 16Kb io-region (was 8Kb) that can be
mapped. The XFree server uses this.
 1.6 04-Oct-1996  leo Checkpointing my et4000 work. Note that the et-console will not be
functional until the minimal pci-support is checked in.
 1.5 16-Sep-1996  leo Prepare for (soon to come) et4000 PCI console.
 1.4 18-Apr-1996  leo Yet more prototyping and -Wall fixes.
 1.3 12-Apr-1996  leo Prototyping.
 1.2 22-Feb-1996  leo First bunch of changes due to stricter prototype checking.
 1.1 20-Aug-1995  leo Add Falcon video support. Thanks to Thomas Gerner.
 1.9.26.2 18-Oct-2002  nathanw Catch up to -current.
 1.9.26.1 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.9.22.2 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.9.22.1 16-Mar-2002  jdolecek Catch up with -current.
 1.13.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.13.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.13.2.1 03-Aug-2004  skrll Sync with HEAD
 1.15.92.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.15.86.1 28-Apr-2009  skrll Sync with HEAD.
 1.15.78.4 11-Aug-2010  yamt sync with head.
 1.15.78.3 11-Mar-2010  yamt sync with head
 1.15.78.2 19-Aug-2009  yamt sync with head.
 1.15.78.1 04-May-2009  yamt sync with head.
 1.22.4.1 30-May-2010  rmind sync with head
 1.22.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.3 20-Oct-2009  snj Remove 3rd and 4th clause on Leo Weppelman's license. OK leo@.
 1.2 14-Mar-2009  dsl Remove all the __P() from sys (excluding sys/dist)
Diff checked with grep and MK1 eyeball.
i386 and amd64 GENERIC and sys still build.
 1.1 16-Sep-1996  leo branches: 1.1.168; 1.1.176; 1.1.182;
Prepare for (soon to come) et4000 PCI console
 1.1.182.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.1.176.1 28-Apr-2009  skrll Sync with HEAD.
 1.1.168.2 11-Mar-2010  yamt sync with head
 1.1.168.1 04-May-2009  yamt sync with head.
 1.13 06-Jan-2023  tsutsui TAB/spaces/indents cleanup.
 1.12 24-May-2022  andvar s/changable/changeable/ in comments.
 1.11 01-Nov-2021  andvar fix typos, mainly in words minimum and maximum, but also few others.
 1.10 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.9 08-Feb-2011  rmind branches: 1.9.14; 1.9.32;
Remove clause 3 (UCB advertising clause) from the University of Utah
copyright. Confirmed by Mike Hibler, mike at cs.utah.edu - thanks!
Also, merge UCB and Utah copyright texts back into one, as they
originally were.

Extra verification by snj@.
 1.8 04-Mar-2007  christos branches: 1.8.66; 1.8.72; 1.8.74;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.7 24-Nov-2006  wiz branches: 1.7.4;
s/independant/independent/, from Zafer.
 1.6 11-Dec-2005  christos branches: 1.6.20; 1.6.22;
merge ktrace-lwp.
 1.5 18-May-2004  he branches: 1.5.12;
Add some mulitple include protection.
Include kbdmap.h from iteioctl.h so that kdump compiles, otherwise
the size of struct kbdmap as used in various ioctl defines is unknown.
 1.4 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.3 20-Dec-1998  thomas branches: 1.3.42;
Changed grf mmap that it is closer to XFree. VGA memory on et4000/et6000
is now at offset 0xa0000.
 1.2 16-Sep-1996  leo Prepare for (soon to come) et4000 PCI console.
 1.1 26-Mar-1995  leo branches: 1.1.1;
Initial revision
 1.1.1.1 26-Mar-1995  leo NetBSD/Atari, port by Leo Weppelman.
 1.3.42.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.3.42.2 18-Sep-2004  skrll Sync with HEAD.
 1.3.42.1 03-Aug-2004  skrll Sync with HEAD
 1.5.12.2 03-Sep-2007  yamt sync with head.
 1.5.12.1 30-Dec-2006  yamt sync with head.
 1.6.22.1 10-Dec-2006  yamt sync with head.
 1.6.20.1 12-Jan-2007  ad Sync with head.
 1.7.4.1 12-Mar-2007  rmind Sync with HEAD.
 1.8.74.1 17-Feb-2011  bouyer Sync with HEAD
 1.8.72.1 06-Jun-2011  jruoho Sync with HEAD.
 1.8.66.1 05-Mar-2011  rmind sync with head
 1.9.32.1 22-Sep-2015  skrll Sync with HEAD
 1.9.14.1 03-Dec-2017  jdolecek update from HEAD
 1.15 06-Jan-2023  tsutsui TAB/spaces/indents cleanup.
 1.14 27-Oct-2012  chs split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.13 05-Jun-2011  tsutsui branches: 1.13.2; 1.13.12;
Split device_t/softc. Also rename some softc variables. Tested on TT030.

XXX: old ugly config_console() hack should go away...
 1.12 08-Feb-2011  rmind branches: 1.12.2;
Remove clause 3 (UCB advertising clause) from the University of Utah
copyright. Confirmed by Mike Hibler, mike at cs.utah.edu - thanks!
Also, merge UCB and Utah copyright texts back into one, as they
originally were.

Extra verification by snj@.
 1.11 14-Mar-2009  dsl branches: 1.11.4; 1.11.6; 1.11.8;
Remove all the __P() from sys (excluding sys/dist)
Diff checked with grep and MK1 eyeball.
i386 and amd64 GENERIC and sys still build.
 1.10 04-Mar-2007  christos branches: 1.10.44; 1.10.52; 1.10.58;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.9 11-Dec-2005  christos branches: 1.9.26;
merge ktrace-lwp.
 1.8 07-Aug-2003  agc branches: 1.8.16;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.7 06-Sep-2002  gehenna branches: 1.7.6;
Merge the gehenna-devsw branch into the trunk.

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

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

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

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

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

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

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

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

- In compile time, device major numbers list is packed into the kernel and
the LKM framework will refer it to assign device major number dynamically.
 1.6 04-Oct-1996  leo branches: 1.6.42; 1.6.46; 1.6.54;
Checkpointing my et4000 work. Note that the et-console will not be
functional until the minimal pci-support is checked in.
 1.5 25-Sep-1996  leo Catchup with -current:
- Extra argument to boot()
- select -> poll
 1.4 16-Sep-1996  leo Prepare for (soon to come) et4000 PCI console.
 1.3 22-Feb-1996  leo First bunch of changes due to stricter prototype checking.
 1.2 28-May-1995  leo Remove the pointer to view_t from the grf-structure, use viewview(dev)
to obtain the pointer instead. This removes a kernel-crash that happened
when something was written to the console while the console was being
resized.
 1.1 26-Mar-1995  leo branches: 1.1.1;
Initial revision
 1.1.1.1 26-Mar-1995  leo NetBSD/Atari, port by Leo Weppelman.
 1.6.54.1 19-May-2002  gehenna Remove unnecessary prototype.
 1.6.46.1 17-Sep-2002  nathanw Catch up to -current.
 1.6.42.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.6.42.1 17-Jun-2002  jdolecek make compilable - use cdev_decl(), and remove unnecessary prototypes
from headers
 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.16.1 03-Sep-2007  yamt sync with head.
 1.9.26.1 12-Mar-2007  rmind Sync with HEAD.
 1.10.58.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.10.52.1 28-Apr-2009  skrll Sync with HEAD.
 1.10.44.1 04-May-2009  yamt sync with head.
 1.11.8.1 17-Feb-2011  bouyer Sync with HEAD
 1.11.6.1 06-Jun-2011  jruoho Sync with HEAD.
 1.11.4.2 12-Jun-2011  rmind sync with head
 1.11.4.1 05-Mar-2011  rmind sync with head
 1.12.2.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.13.12.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.13.2.1 30-Oct-2012  yamt sync with head
 1.92 06-Jan-2023  tsutsui TAB/spaces/indents cleanup.
 1.91 26-Jun-2022  tsutsui Use aprint_*(9) for device attach messages.
 1.90 26-Jun-2022  tsutsui Make local devsw functions static.

No visible regression on TT030.
 1.89 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.88 24-Apr-2021  thorpej branches: 1.88.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.87 03-Jan-2021  thorpej branches: 1.87.2;
malloc(9) -> kmem(9)
 1.86 10-Nov-2019  chs branches: 1.86.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.85 29-Jun-2019  tsutsui Make local functions static.
 1.84 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.83 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.82 08-Dec-2015  christos branches: 1.82.16; 1.82.18;
Replace DIOCGPART -> DIOCGPARTINFO which returns the data needed instead of
pointers.
 1.81 26-Apr-2015  mlelstv Use C99-style initializers for struct dkdriver.
 1.80 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.79 31-Dec-2014  christos make more drivers use disk_ioctl, and add a dev parameter to it so that
we can merge the "easy" disklabel ioctls to it. Ultimately all this will
go do dk_ioctl once all the drivers have been converted.
 1.78 25-Jul-2014  dholland branches: 1.78.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.77 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.76 16-Mar-2014  dholland branches: 1.76.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.75 01-Jul-2011  dyoung branches: 1.75.2; 1.75.12; 1.75.16;
#include <sys/bus.h> instead of <machine/bus.h>.
 1.74 10-Jun-2011  tsutsui Split device_t/softc. Compile test only.
 1.73 13-Apr-2010  tsutsui branches: 1.73.6;
Misc KNF.
 1.72 13-Apr-2010  tsutsui Include "ioconf.h" to declare struct cfdriver foo_cd.
 1.71 08-Jul-2009  tsutsui branches: 1.71.2; 1.71.4;
Merge local <atari/atari/intr.h> into common <machine/intr.h>.
 1.70 18-Mar-2009  cegger bzero -> memset
 1.69 17-Mar-2009  he Re-balance parenthesis in a couple of places.
 1.68 14-Mar-2009  dsl ANSIfy another 1261 function definitions.
The only ones left in sys are beyond by sed script!
(or in sys/dist or sys/external)
Mostly they have function pointer parameters.
 1.67 14-Mar-2009  dsl Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.66 14-Mar-2009  dsl Remove all the __P() from sys (excluding sys/dist)
Diff checked with grep and MK1 eyeball.
i386 and amd64 GENERIC and sys still build.
 1.65 13-Jan-2009  yamt branches: 1.65.2;
g/c BUFQ_FOO() macros and use bufq_foo() directly.
 1.64 18-Dec-2008  he Correct two typos and remove a now-unused variable to make this
build again.
 1.63 16-Dec-2008  christos replace bitmask_snprintf(9) with snprintb(3)
 1.62 13-Jun-2008  cegger branches: 1.62.4;
use device_lookup_private to get softc
 1.61 03-Jan-2008  he branches: 1.61.6; 1.61.8; 1.61.10; 1.61.12; 1.61.14;
Fix a cv_timedwait() usage after the vmlocking2 merge, and remove
a now-no-longer-used local variable.
 1.60 02-Jan-2008  ad Merge vmlocking2 to head.
 1.59 17-Oct-2007  garbled branches: 1.59.2; 1.59.4; 1.59.8;
Merge the ppcoea-renovation branch to HEAD.

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

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

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.58 08-Oct-2007  ad Merge disk init changes from the vmlocking branch. These seperate init /
destroy of 'struct disk' from attach / detach.
 1.57 29-Jul-2007  ad branches: 1.57.4; 1.57.6; 1.57.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.56 09-Jul-2007  ad branches: 1.56.2; 1.56.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.55 06-Mar-2007  tsutsui branches: 1.55.2; 1.55.4; 1.55.10;
Treat bus_space_handle_t as opaque, and use bus_space_vaddr(9) to
get device address.

XXX: This driver should be rewritten to use bus_space(9) more properly.
 1.54 06-Mar-2007  tsutsui Add (char *) cast to appease -Wpointer-arith.
 1.53 04-Mar-2007  christos Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.52 15-Feb-2007  reinoud branches: 1.52.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.51 24-Jan-2007  hubertf Remove duplicate #includes, patch contributed in private mail
by Slava Semushin <slava.semushin@gmail.com>.

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

Thanks to martin@ for the input on testing.
 1.50 14-Apr-2006  blymn branches: 1.50.8;
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.49 23-Feb-2006  thorpej branches: 1.49.2; 1.49.4; 1.49.6;
Use device_parent().
 1.48 24-Dec-2005  perry branches: 1.48.2; 1.48.4; 1.48.6;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.
 1.47 11-Dec-2005  christos merge ktrace-lwp.
 1.46 15-Oct-2005  yamt - 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.45 04-Jun-2005  he branches: 1.45.2;
Adapt to compiling with -Wshadow and -Wcast-qual, by adding const
qualification in places and renaming a few local variables.
Also adds a couple uses of __UNVOLATILE() to allow passing volatile
variables to functions wanting e.g. caddr_t.
 1.44 28-Oct-2004  yamt move buffer queue related stuffs from buf.h to their own header, bufq.h.
 1.43 25-Mar-2004  leo Licence cleanup (suggested by wiz).
 1.42 29-Sep-2003  cl Cast through (void *) to appease gcc3.
 1.41 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.40 15-Jul-2003  lukem __KERNEL_RCSID()
 1.39 18-Jun-2003  drochner branches: 1.39.2;
don't #include <sys/dkstat.h> where it is (appearently) unused
 1.38 03-May-2003  wiz DMA, not dma nor Dma.
 1.37 02-Feb-2003  thomas Fix printf format for typ daddr_t.
 1.36 01-Jan-2003  thorpej Use aprint_normal() for cfprint routines.
 1.35 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.34 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.33 02-Oct-2002  thorpej Use CFATTACH_DECL().
 1.32 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.31 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.30 10-Aug-2002  hannken Convert to new device buffer queue interface.

Approved by: Leo Weppelman <leo@netbsd.org>
 1.29 21-Nov-2001  wiz branches: 1.29.8;
Explicitly write explicitly without a second e.
 1.28 08-Jul-2001  wiz branches: 1.28.2; 1.28.4; 1.28.8;
Correct various misspellings of 'transfer' and inflected forms.
 1.27 29-Aug-2000  leo Now that formatting works (Thanks Nathan!), it shows that spec_read() is
issueing a 'DIOCGPART' at every read. Avoid re-reading the label at
every format-verify (or read/write on the block-device) by fetching the label
at open-time and caching it until we close.
 1.26 24-Aug-2000  nathanw In fdioctl(), allocate fd_formb dynamically when needed, rather than on
the stack, and remove the no-longer-necessary PHOLD()/PRELE() calls
in fdformat().

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

XXX We still have too many mostly-redundant floppy drivers.
 1.25 29-Jun-2000  mrg remove include of <vm/vm.h>. <vm/vm.h> -> <uvm/uvm_extern.h>
 1.24 16-May-2000  thorpej branches: 1.24.4;
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.23 09-May-2000  leo Add some {u}vm includes for the sake of PHOLD().
 1.22 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.21 29-Mar-2000  leo Nuke a bunch of cf_unit abuses.
 1.20 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.19 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.18 21-Jan-2000  thorpej Update for sys/buf.h/disksort_*() changes.
 1.17 22-Oct-1999  leo Limit the io-region mapped by this driver to the part actually used.
Otherwise, it conflicts with the wd-driver.
 1.16 21-Oct-1999  leo implement DIOCSDINFO.
 1.15 06-Aug-1999  leo branches: 1.15.2; 1.15.4; 1.15.6;
Change the way that bit's are cleared in the InterruptPending register of
the 68901. Do this now by _assigning_ ~<bit_to_clear> instead of the
previously used 'andb ~<bit_to_clear>'. The latter caused a rwm-cycle that
caused a race condition to happen when an interrupt arrived between the
Read and Modify-Write.
Anyway, this solved my hanging keyboard problem.
 1.14 04-May-1999  leo If the floppy has no label, fake one.
 1.13 20-Nov-1998  leo branches: 1.13.4; 1.13.6;
If the disklabel on the floppy says that there are more tracks and sectors
than the hardware is capable off, believe the hardware...
 1.12 06-Oct-1998  leo Some DEBUG fixups
 1.11 04-Jul-1998  jonathan defopt DDB.
 1.10 10-Apr-1998  leo Major overhaul of the atari bus_space implementation.
 1.9 12-Jan-1998  thorpej Update for changes to config.
 1.8 17-Jul-1997  jtk use locator defines in "locators.h" to index cf_loc[]
 1.7 25-Apr-1997  leo Allow formatting of 360Kb floppies.
 1.6 01-Jan-1997  leo The Hades floppy driver now uses intr_establish(). Also the interrupt
accounting is fixed (ie. counted as the right interrupt).
 1.5 20-Dec-1996  leo Get rid of BROKEN_INDIRECT_CONFIG
 1.4 18-Dec-1996  leo Tweak the clockframe structure a bit so we are able to save a few cycles
at interrupt time. (From Gordon Ross).
 1.3 14-Dec-1996  leo Merge the formatting code from the i386-port.
 1.2 13-Nov-1996  thorpej Use bitmask_snprintf().
 1.1 09-Nov-1996  leo Hades floppy driver.
 1.13.6.1 21-Jun-1999  thorpej Sync w/ -current.
 1.13.4.2 16-Dec-1999  he Pull up revision 1.15 (requested by leo):
Change the way that bits are cleared in the InterruptPending
register of the 68901, avoiding a read-modify-write cycle.
Solves a "hanging keyboard" problem.
 1.13.4.1 04-Dec-1999  he Pull up revision 1.14 (requested by leo):
If the floppy has no label, fake one.
 1.15.6.2 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.15.6.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.15.4.1 15-Nov-1999  fvdl Sync with -current
 1.15.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.24.4.1 06-Sep-2000  leo Apply patch (requested by leo, approved by thorpej).

Fix formatting floppies on the Hades. This fix contains a bugfix
from nathanw introduced in revision 1.26 and all of the label caching
code from revision 1.27. The latter is needed to avoid a seek to track
zero after each track has been formatted.
 1.28.8.7 03-Jan-2003  thorpej Sync with HEAD.
 1.28.8.6 11-Nov-2002  nathanw Catch up to -current
 1.28.8.5 18-Oct-2002  nathanw Catch up to -current.
 1.28.8.4 17-Sep-2002  nathanw Catch up to -current.
 1.28.8.3 13-Aug-2002  nathanw Catch up to -current.
 1.28.8.2 08-Jan-2002  nathanw Catch up to -current.
 1.28.8.1 08-Jul-2001  nathanw file hdfd.c was added on branch nathanw_sa on 2002-01-08 00:23:37 +0000
 1.28.4.1 10-Oct-2001  fvdl Convert all remaining devices.
 1.28.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.28.2.2 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.28.2.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.29.8.2 30-Aug-2002  gehenna catch up with -current.
 1.29.8.1 17-May-2002  gehenna Add device switch.
 1.39.2.6 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.39.2.5 17-Jan-2005  skrll Adapt to branch.
 1.39.2.4 02-Nov-2004  skrll Sync with HEAD.
 1.39.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.39.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.39.2.1 03-Aug-2004  skrll Sync with HEAD
 1.45.2.5 21-Jan-2008  yamt sync with head
 1.45.2.4 27-Oct-2007  yamt sync with head.
 1.45.2.3 03-Sep-2007  yamt sync with head.
 1.45.2.2 26-Feb-2007  yamt sync with head.
 1.45.2.1 21-Jun-2006  yamt sync with head.
 1.48.6.1 22-Apr-2006  simonb Sync with head.
 1.48.4.1 09-Sep-2006  rpaulo sync with head
 1.48.2.1 01-Mar-2006  yamt sync with head.
 1.49.6.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.49.4.1 19-Apr-2006  elad sync with head - hopefully this will work
 1.49.2.1 24-May-2006  yamt sync with head.
 1.50.8.1 01-Feb-2007  ad Sync with head.
 1.52.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.55.10.2 16-Oct-2007  garbled Sync with HEAD
 1.55.10.1 03-Oct-2007  garbled Sync with HEAD
 1.55.4.1 11-Jul-2007  mjf Sync with head.
 1.55.2.3 20-Aug-2007  ad - Alter disk attach/detach to fix a panic when closing a vnd device.
- Sync with HEAD.
 1.55.2.2 19-Aug-2007  ad - Back out the biodone() changes.
- Eliminate B_ERROR (from HEAD).
 1.55.2.1 15-Jul-2007  ad Sync with head.
 1.56.4.1 15-Aug-2007  skrll Sync with HEAD.
 1.56.2.1 07-Aug-2007  matt Sync with HEAD.
 1.57.8.1 14-Oct-2007  yamt sync with head.
 1.57.6.2 09-Jan-2008  matt sync with HEAD
 1.57.6.1 06-Nov-2007  matt sync with HEAD
 1.57.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.59.8.2 08-Jan-2008  bouyer Sync with HEAD
 1.59.8.1 02-Jan-2008  bouyer Sync with HEAD
 1.59.4.2 31-Dec-2007  ad Catch up with buffer cache changes.
 1.59.4.1 31-Dec-2007  ad Make compile with new buffer cache locking scheme.

XXX This should be largely MI, please do not make another clone of disksubr.c.
 1.59.2.1 18-Feb-2008  mjf Sync with HEAD.
 1.61.14.1 18-Jun-2008  simonb Sync with head.
 1.61.12.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.61.10.3 11-Aug-2010  yamt sync with head.
 1.61.10.2 18-Jul-2009  yamt sync with head.
 1.61.10.1 04-May-2009  yamt sync with head.
 1.61.8.1 17-Jun-2008  yamt sync with head.
 1.61.6.2 17-Jan-2009  mjf Sync with HEAD.
 1.61.6.1 29-Jun-2008  mjf Sync with HEAD.
 1.62.4.2 28-Apr-2009  skrll Sync with HEAD.
 1.62.4.1 19-Jan-2009  skrll Sync with HEAD.
 1.65.2.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.71.4.2 12-Jun-2011  rmind sync with head
 1.71.4.1 30-May-2010  rmind sync with head
 1.71.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.73.6.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.75.16.1 18-May-2014  rmind sync with head
 1.75.12.2 03-Dec-2017  jdolecek update from HEAD
 1.75.12.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.75.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.76.2.1 10-Aug-2014  tls Rebase.
 1.78.4.3 27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.78.4.2 06-Jun-2015  skrll Sync with HEAD
 1.78.4.1 06-Apr-2015  skrll Sync with HEAD
 1.82.18.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.82.18.1 10-Jun-2019  christos Sync with HEAD
 1.82.16.1 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.86.8.1 03-Apr-2021  thorpej Sync with HEAD.
 1.87.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.88.8.1 03-Aug-2021  thorpej Adapt to CFARGS().
 1.11 06-Jan-2023  tsutsui TAB/spaces/indents cleanup.
 1.10 20-Dec-2010  matt Move counting of faults, traps, intrs, soft[intr]s, syscalls, and nswtch
from uvmexp to per-cpu cpu_data and move them to 64bits. Remove unneeded
includes of <uvm/uvm_extern.h> and/or <uvm/uvm.h>.
 1.9 20-Oct-2009  snj branches: 1.9.4;
Remove 3rd and 4th clause on Leo Weppelman's license. OK leo@.
 1.8 03-May-2003  wiz branches: 1.8.108;
DMA, not dma nor Dma.
 1.7 08-Sep-2001  thomas branches: 1.7.4;
ELF abaption.
 1.6 24-Mar-1999  mrg branches: 1.6.20; 1.6.22;
completely remove Mach VM support. all that is left is the all the
header files as UVM still uses (most of) these.
 1.5 12-May-1998  leo Forgotten with last UVM check-in.
 1.4 01-Jan-1997  leo The Hades floppy driver now uses intr_establish(). Also the interrupt
accounting is fixed (ie. counted as the right interrupt).
 1.3 18-Dec-1996  leo Tweak the clockframe structure a bit so we are able to save a few cycles
at interrupt time. (From Gordon Ross).
 1.2 14-Dec-1996  leo Merge the formatting code from the i386-port.
 1.1 09-Nov-1996  leo Hades floppy driver.
 1.6.22.1 13-Sep-2001  thorpej Update the kqueue branch to HEAD.
 1.6.20.1 01-Oct-2001  fvdl Catch up with -current.
 1.7.4.2 08-Sep-2001  thomas ELF abaption.
 1.7.4.1 08-Sep-2001  thomas file hdfd_intr.s was added on branch nathanw_sa on 2001-09-08 11:15:36 +0000
 1.8.108.1 11-Mar-2010  yamt sync with head
 1.9.4.1 05-Mar-2011  rmind sync with head
 1.8 06-Jan-2023  tsutsui TAB/spaces/indents cleanup.
 1.7 30-Jun-2011  wiz dependant -> dependent
 1.6 11-Dec-2005  christos merge ktrace-lwp.
 1.5 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.4 09-Apr-2003  thorpej branches: 1.4.2;
Use PAGE_SIZE rather than NBPG.
 1.3 22-Oct-1999  leo Limit the io-region mapped by this driver to the part actually used.
Otherwise, it conflicts with the wd-driver.
 1.2 14-Dec-1996  leo branches: 1.2.28; 1.2.30; 1.2.32;
Merge the formatting code from the i386-port.
 1.1 09-Nov-1996  leo Hades floppy driver.
 1.2.32.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.2.30.1 15-Nov-1999  fvdl Sync with -current
 1.2.28.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.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.4.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.4.2.1 03-Aug-2004  skrll Sync with HEAD
 1.3 17-Aug-2021  andvar fix multiplei repetitive typos in comments, messages and documentation. mainly because copy paste code big amount of files are affected.
 1.2 06-Apr-2010  tsutsui branches: 1.2.2; 1.2.4; 1.2.6; 1.2.8;
Use callout_schedule(9) rather than callout_reset(9) on polling
as callout(9) man says.
 1.1 01-Apr-2010  tsutsui Add support for the EtherNEC.

The EtherNEC is yet another user designed device for Atari machines,
an NE2000 based ISA board connected to Atari's ROM cartridge slot with
simple but ingenious interface and cartridge port adapter, and
it's the most available network solution for the old Atari machines.

See following pages for more details about EtherNEC:
http://hardware.atari.org/ether/
http://home.arcor.de/thomas.redelberger/prj/atari/etherne/
http://www.freemint.org/ethernec/ethernec.html
 1.2.8.2 20-Nov-2010  riz Pull up following revision(s) (requested by tsutsui in ticket #1367):
sys/dev/ic/ne2000var.h: revision 1.25
sys/arch/atari/conf/MILAN.in: revision 1.24
sys/arch/atari/conf/MILAN.in: revision 1.25
sys/dev/ic/ne2000.c: revision 1.71
sys/dev/ic/ne2000.c: revision 1.72
sys/arch/atari/dev/if_ne_mb.c: revision 1.1
sys/arch/atari/dev/if_ne_mb.c: revision 1.2
sys/arch/atari/conf/MILAN-PCIIDE: revision 1.69
sys/arch/atari/conf/HADES.in: revision 1.10
sys/arch/atari/conf/HADES.in: revision 1.11
sys/arch/x68k/dev/if_ne_neptune.c: revision 1.20
sys/dev/isa/if_ne_isa.c: revision 1.27
sys/arch/atari/atari/autoconf.c: revision 1.57
sys/dev/ic/ne2000.c: revision 1.62
sys/dev/isapnp/if_ne_isapnp.c: revision 1.27
sys/arch/atari/conf/files.atari: revision 1.117
sys/arch/atari/conf/HADES: revision 1.88
sys/arch/atari/conf/GENERIC.in: revision 1.85
sys/dev/ic/ne2000.c: revision 1.65
sys/dev/ic/ne2000.c: revision 1.66
sys/dev/ic/ne2000.c: revision 1.68
sys/arch/atari/conf/MILAN-ISAIDE: revision 1.65
distrib/notes/atari/hardware: revision 1.24
sys/conf/files: revision 1.980
sys/dev/ic/ne2000var.h: revision 1.21
sys/arch/x68k/dev/if_ne_intio.c: revision 1.16
sys/dev/ic/dp8390.c: revision 1.74
sys/dev/ic/dp8390.c: revision 1.75
Added NE2000 with 8bit bus width support.
reviewd by tsutsui@ at tech-kern ML.
Fix a wrong calculation bug around RX ring buffer memory address
slipped in about sixteen years ago. Fortunately, it had been working
for ages because some devices used address zero and other devices
ignored wrong higher bits.
Tested on we(4) (SMC Elite Ultra) and ne(4) (NE2000 compatible
named UL0001) on ISA.
Note FreeBSD also uses the same correct value in their ed(4) driver.
Now dp8390_config() calculates mem_ring correctly so
no longer need to override it in ne2000_attach().
Use roundup2() in <sys/param.h> rather than a conditional.
Also fix a wrong mem_ring calculation in dp8390_ipkdb_attach().
Put several fixes to ne(4) driver for better 8 bit mode support,
especially on RTL8019AS which is also used for non-ISA local bus of
embedded controllers and some m68k machines like atari and x68k.
* move RTL8019 probe and attach code from each bus attachment
to MI ne2000_detect() and ne2000_attach()
* change a method for backend and attachment to specify 8 bit mode
to use a new sc->sc_quirk member, instead of sc->sc_dmawidth
* handle more NE2000 8 bit mode specific settings, including
bus_space(9) access width and available size of buffer memory
* add a function to detect NE2000 8 bit mode
(disabled by default, but enalbed by options NE2000_DETECT_8BIT
to avoid possible regression on various ISA clones)
* fix ipkdb attachment accordingly (untested)
Tested on two NE2000 ISA variants (RTL8019AS and another clone named UL0001)
in both 8 bit and 16 bit mode on i386. "Looks good" from nonaka@.
See my post on tech-kern for details:
http://mail-index.NetBSD.org/tech-kern/2010/02/26/msg007423.html
No need to override mem_ring value in ne2000_ipkdb_attach()
since a wrong calculation in dp8390_ipkdb_attach() was fixed.
Don't warn about DMA timeout during probe.
Add support for the EtherNEC.
The EtherNEC is yet another user designed device for Atari machines,
an NE2000 based ISA board connected to Atari's ROM cartridge slot with
simple but ingenious interface and cartridge port adapter, and
it's the most available network solution for the old Atari machines.
See following pages for more details about EtherNEC:
http://hardware.atari.org/ether/
http://home.arcor.de/thomas.redelberger/prj/atari/etherne/
http://www.freemint.org/ethernec/ethernec.html
Also note EtherNEC.
Use callout_schedule(9) rather than callout_reset(9) on polling
as callout(9) man says.
Remove EtherNEC from HADES and MILAN.
They have ISA so no one will bother to connect ISA NE2000 via EtherNEC.
Regen from HADES.in rev 1.11 and MILAN.in rev 1.25:
Remove EtherNEC from HADES and MILAN.
They have ISA so no one will bother to connect ISA NE2000 via EtherNEC.
 1.2.8.1 06-Apr-2010  riz file if_ne_mb.c was added on branch netbsd-5 on 2010-11-20 00:33:46 +0000
 1.2.6.2 11-Aug-2010  yamt sync with head.
 1.2.6.1 06-Apr-2010  yamt file if_ne_mb.c was added on branch yamt-nfs-mp on 2010-08-11 22:51:45 +0000
 1.2.4.2 30-May-2010  rmind sync with head
 1.2.4.1 06-Apr-2010  rmind file if_ne_mb.c was added on branch rmind-uvmplock on 2010-05-30 05:16:39 +0000
 1.2.2.2 30-Apr-2010  uebayasi Sync with HEAD.
 1.2.2.1 06-Apr-2010  uebayasi file if_ne_mb.c was added on branch uebayasi-xip on 2010-04-30 14:39:11 +0000
 1.85 06-Jan-2023  tsutsui TAB/spaces/indents cleanup.
 1.84 26-Jun-2022  tsutsui Use aprint_*(9) for device attach messages.
 1.83 26-Jun-2022  tsutsui Make local devsw functions static.

No visible regression on TT030.
 1.82 25-Jun-2022  tsutsui Add a minimum DEC special graphics character support for atari ite(4).

This closes PR port-atari/46647 (Menu borders in sysinst appear as
characters with diacritical marks instead of graphics characters).

Switching encoding support by "ESC ( <F>" sequence for vt220 was
pulled from x68k ite(4) (that already supports ISO-2022-JP and EUC-JP).
Note atari's fonts already include DEC special graphics characters.
ET4000 on Hades is untested due to long-term lack of hardware.
Discussed on port-atari@ etc.
 1.81 28-May-2022  andvar fix various typos, mainly in comments.
 1.80 03-Jan-2021  thorpej malloc(9) -> kmem(9)
 1.79 29-Jun-2019  tsutsui branches: 1.79.2; 1.79.10;
Make local functions static.
 1.78 03-Sep-2018  riastradh Rename min/max -> uimin/uimax for better honesty.

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

HOWEVER! Some subsystems have

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

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

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

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

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

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

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)
 1.77 29-Feb-2016  christos branches: 1.77.16; 1.77.18;
PR/50868: David Binderman: Fix operator precedence.
 1.76 25-Jul-2014  dholland branches: 1.76.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.75 26-Mar-2014  christos branches: 1.75.2;
kill sprintf
 1.74 24-Mar-2014  christos - remove unused
- use cpu_{g,s}etmodel() (not committed yet)
 1.73 16-Mar-2014  dholland 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.72 19-Feb-2014  tsutsui Fix kernel crash when a user tries to switch to nonexistent terminal.

Reported by Gabor Sebestyen in PR port-atari/48599.

Should be pulled up to all netbsd-6 branches.
 1.71 05-Jun-2011  tsutsui branches: 1.71.2; 1.71.8; 1.71.12; 1.71.14; 1.71.16; 1.71.22;
Split device_t/softc. Also rename some softc variables. Tested on TT030.

XXX: old ugly config_console() hack should go away...
 1.70 24-Apr-2011  rmind branches: 1.70.2;
Rename ttymalloc() to tty_alloc(), and ttyfree() to tty_free() for
consistency. Remove some unnecessary malloc.h inclusions as well.
 1.69 08-Feb-2011  rmind Remove clause 3 (UCB advertising clause) from the University of Utah
copyright. Confirmed by Mike Hibler, mike at cs.utah.edu - thanks!
Also, merge UCB and Utah copyright texts back into one, as they
originally were.

Extra verification by snj@.
 1.68 13-Apr-2010  tsutsui branches: 1.68.2; 1.68.4;
Misc KNF.
 1.67 13-Apr-2010  tsutsui Include "ioconf.h" to declare struct cfdriver foo_cd.
 1.66 19-Jul-2009  tsutsui branches: 1.66.2; 1.66.4;
Remove extra whitespace added by a dumb tool which replaced bcopy with memcpy.
 1.65 18-Mar-2009  cegger bcopy -> memcpy
 1.64 18-Mar-2009  cegger bzero -> memset
 1.63 18-Mar-2009  cegger bcmp -> memcmp
 1.62 14-Mar-2009  dsl ANSIfy another 1261 function definitions.
The only ones left in sys are beyond by sed script!
(or in sys/dist or sys/external)
Mostly they have function pointer parameters.
 1.61 14-Mar-2009  dsl Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.60 14-Mar-2009  dsl Remove all the __P() from sys (excluding sys/dist)
Diff checked with grep and MK1 eyeball.
i386 and amd64 GENERIC and sys still build.
 1.59 11-Jun-2008  tsutsui branches: 1.59.4; 1.59.10;
Use device_private() and device_lookup_privat() to get softc.
 1.58 19-Nov-2007  ad branches: 1.58.14; 1.58.16; 1.58.18; 1.58.20; 1.58.22;
- Factor out too many copies of the same bit of tty code.
- Fix another tty signalling/wakeup problem.
 1.57 18-Oct-2007  joerg branches: 1.57.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.56 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.55 09-Jul-2007  ad branches: 1.55.8; 1.55.10; 1.55.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.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 01-Oct-2006  elad branches: 1.53.4;
Adapt MD code to KAUTH_DEVICE_TTY_OPEN. Patch from Matt Fleming, thanks!
 1.52 23-Jul-2006  ad branches: 1.52.4; 1.52.6;
Use the LWP cached credentials where sane.
 1.51 14-May-2006  elad integrate kauth.
 1.50 26-Mar-2006  thorpej Use device_unit().
 1.49 24-Dec-2005  perry branches: 1.49.4; 1.49.6; 1.49.8; 1.49.10; 1.49.12;
__asm__ -> __asm
__const__ -> const
__inline__ -> inline
__volatile__ -> volatile
 1.48 11-Dec-2005  christos merge ktrace-lwp.
 1.47 06-Sep-2005  kleink Change the driver open function's conditional for overriding exclusive tty
use from checking the proc's uid to suser(9), and account for the use of
privileges. Noted by David Holland in PR kern/31126.
 1.46 04-Jun-2005  he branches: 1.46.2;
Adapt to compiling with -Wshadow and -Wcast-qual, by adding const
qualification in places and renaming a few local variables.
Also adds a couple uses of __UNVOLATILE() to allow passing volatile
variables to functions wanting e.g. caddr_t.
 1.45 02-Mar-2005  chs getitesp() can return NULL, so check for that in iteopen().
pointed out by Michael Hitch.
 1.44 23-Jan-2005  he branches: 1.44.2;
Adapt to the change in type of ite_on() -- don't pretend that it returns
a value anymore (return type is now void).
 1.43 19-Jan-2005  chs use a flag in the softc to indicate if an instance has been configured,
rather than a bit in 32-bit global variable indexed by unit number.
 1.42 01-Nov-2003  jdolecek branches: 1.42.8;
g/c local index() routine and switch to (libkern's) strchr()
 1.41 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.40 15-Jul-2003  lukem __KERNEL_RCSID()
 1.39 23-Oct-2002  jdolecek branches: 1.39.6;
merge kqueue branch into -current

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

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

based on work done by Jonathan Lemon for FreeBSD
initial NetBSD port done by Luke Mewburn and Jason Thorpe
 1.38 02-Oct-2002  thorpej Use CFATTACH_DECL().
 1.37 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.36 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.35 17-Mar-2002  atatat branches: 1.35.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.34 09-Jul-2001  leo branches: 1.34.2; 1.34.4; 1.34.8;
Nuke some cf_unit abuses.
 1.33 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.32 01-Feb-2001  leo branches: 1.32.2;
Fix fallout from lastest tty changes.
 1.31 02-Nov-2000  eeh Adapt to new line discipline scheme.
 1.30 28-Sep-2000  leo Move config_console() out of the grf-layer. This allows for more than just
grf-type consoles (wscons). Config_console() is now called from consinit(),
just after setting up the kernel msgbuf, so debugging is easy(er).
To further facilitate this move, the pcibus now allows for early-console
attaches by allocating static bus_space_tags (no mallocs possible at this
point).
 1.29 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.28 11-Feb-2000  leo Move the ite_default_* variables to ite.c. They are generic ite.
 1.27 19-Jan-2000  leo No longer abuse cf_unit. This broke with the latest autoconf changes.
 1.26 04-Jul-1998  jonathan branches: 1.26.14;
defopt DDB.
 1.25 25-Mar-1998  leo Sync with latest tty changes.
 1.24 12-Jan-1998  thorpej Update for changes to config.
 1.23 29-Jun-1997  leo Add code to set pitch and duration of the keyboard bell. (Thomas Gerner).
 1.22 10-Jan-1997  leo Handle keyboard modifiers *before* handing the keycodes to either the
console driver or the DDB keyboard functions. This prevents annoyances
with out of sync modifier stati.
 1.21 08-Jan-1997  leo Don't try to init the keyboard interrupts in cngetc(). This caused the
keyboard to hang when booting directly into the debugger.
 1.20 20-Dec-1996  leo Get rid of BROKEN_INDIRECT_CONFIG
 1.19 13-Oct-1996  christos backout previous kprintf changes
 1.18 11-Oct-1996  leo Remove grf_ite_ioctl(). Replace it by 'itexx_ioctl' that is configurable
per ite-type.
 1.17 11-Oct-1996  christos printf -> kprintf, sprintf -> ksprintf
 1.16 25-Sep-1996  leo The KDASSERT macro is now defined in libkern
 1.15 16-Sep-1996  leo Prepare for (soon to come) et4000 PCI console.
 1.14 02-Sep-1996  mycroft tty stop functions really should return void, not int, and certainly not both.
 1.13 18-Jun-1996  leo Add tty_attach() calls.
 1.12 18-Apr-1996  leo branches: 1.12.4;
Yet more prototyping and -Wall fixes.
 1.11 20-Mar-1996  leo Another bit of prototyping...
 1.10 19-Mar-1996  leo Debugger() prototype is in systm.h, don't define Debugger() here.
 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 22-Feb-1996  leo First bunch of changes due to stricter prototype checking.
 1.7 04-Sep-1995  leo Allow chars > 0x7f to be displayed on the ite's
 1.6 24-Jul-1995  leo Change and fix the way of keyboard mapping. Each virtual console has it's
own private keymap, initialized on open from the system-keymap. Both
system and private keymaps are settable.
 1.5 21-May-1995  leo Minor fixes.
 1.4 22-Apr-1995  leo Adapt for new conf.h:
- Add xxxtty() functions
- Remove xxx_tty array
 1.3 10-Apr-1995  mycroft Add dummy itestop(), and rename a few functions.
 1.2 28-Mar-1995  leo Make ite ioctl work and fixup the colormap stuff.
 1.1 26-Mar-1995  leo branches: 1.1.1;
Initial revision
 1.1.1.1 26-Mar-1995  leo NetBSD/Atari, port by Leo Weppelman.
 1.12.4.1 18-Jun-1996  leo Pull up tty_attach() changes from trunk.
 1.26.14.3 11-Feb-2001  bouyer Sync with HEAD.
 1.26.14.2 22-Nov-2000  bouyer Sync with HEAD.
 1.26.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.32.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.34.8.5 11-Nov-2002  nathanw Catch up to -current
 1.34.8.4 18-Oct-2002  nathanw Catch up to -current.
 1.34.8.3 17-Sep-2002  nathanw Catch up to -current.
 1.34.8.2 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.34.8.1 09-Jul-2001  nathanw file ite.c was added on branch nathanw_sa on 2002-04-01 07:39:32 +0000
 1.34.4.2 13-Oct-2001  fvdl Revert the t_dev -> t_devvp change in struct tty. The way that tty
structs are currently used (especially by console ttys) aren't
ready for it, and this will require quite a few changes.
 1.34.4.1 10-Oct-2001  fvdl Convert all remaining devices.
 1.34.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.34.2.1 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.35.4.1 19-May-2002  gehenna Add device switch.
Replace the access to devsw table and the hard-coded majors with devsw API.
 1.39.6.7 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.39.6.6 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.39.6.5 24-Jan-2005  skrll Sync with HEAD.
 1.39.6.4 17-Jan-2005  skrll Adapt to branch.
 1.39.6.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.39.6.2 18-Sep-2004  skrll Sync with HEAD.
 1.39.6.1 03-Aug-2004  skrll Sync with HEAD
 1.42.8.1 29-Apr-2005  kent sync with -current
 1.44.2.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.46.2.5 07-Dec-2007  yamt sync with head
 1.46.2.4 27-Oct-2007  yamt sync with head.
 1.46.2.3 03-Sep-2007  yamt sync with head.
 1.46.2.2 30-Dec-2006  yamt sync with head.
 1.46.2.1 21-Jun-2006  yamt sync with head.
 1.49.12.2 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.49.12.1 28-Mar-2006  tron Merge 2006-03-28 NetBSD-current into the "peter-altq" branch.
 1.49.10.4 13-May-2006  elad sprinkle some #include <sys/kauth.h> in files that use kauth kpi but
don't include it yet. hopefully this will prevent some fallout.
 1.49.10.3 19-Apr-2006  elad sync with head - hopefully this will work
 1.49.10.2 10-Mar-2006  elad generic_authorize() -> kauth_authorize_generic().
 1.49.10.1 08-Mar-2006  elad Adapt to kernel authorization KPI.

I expect *some* lossage here...
 1.49.8.3 11-Aug-2006  yamt sync with head
 1.49.8.2 24-May-2006  yamt sync with head.
 1.49.8.1 01-Apr-2006  yamt sync with head.
 1.49.6.2 01-Jun-2006  kardel Sync with head.
 1.49.6.1 22-Apr-2006  simonb Sync with head.
 1.49.4.1 09-Sep-2006  rpaulo sync with head
 1.52.6.1 22-Oct-2006  yamt sync with head
 1.52.4.1 18-Nov-2006  ad Sync with head.
 1.53.4.1 12-Mar-2007  rmind Sync with HEAD.
 1.54.10.1 03-Oct-2007  garbled Sync with HEAD
 1.54.4.1 11-Jul-2007  mjf Sync with head.
 1.54.2.3 03-Dec-2007  ad Sync with HEAD.
 1.54.2.2 23-Oct-2007  ad Sync with head.
 1.54.2.1 15-Jul-2007  ad Sync with head.
 1.55.14.2 21-Nov-2007  bouyer Sync with HEAD
 1.55.14.1 25-Oct-2007  bouyer Sync with HEAD.
 1.55.10.2 09-Jan-2008  matt sync with HEAD
 1.55.10.1 06-Nov-2007  matt sync with HEAD
 1.55.8.2 21-Nov-2007  joerg Sync with HEAD.
 1.55.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.57.2.1 08-Dec-2007  mjf Sync with HEAD.
 1.58.22.1 18-Jun-2008  simonb Sync with head.
 1.58.20.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.58.18.3 11-Aug-2010  yamt sync with head.
 1.58.18.2 19-Aug-2009  yamt sync with head.
 1.58.18.1 04-May-2009  yamt sync with head.
 1.58.16.1 17-Jun-2008  yamt sync with head.
 1.58.14.1 29-Jun-2008  mjf Sync with HEAD.
 1.59.10.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.59.4.1 28-Apr-2009  skrll Sync with HEAD.
 1.66.4.4 12-Jun-2011  rmind sync with head
 1.66.4.3 31-May-2011  rmind sync with head
 1.66.4.2 05-Mar-2011  rmind sync with head
 1.66.4.1 30-May-2010  rmind sync with head
 1.66.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.68.4.1 17-Feb-2011  bouyer Sync with HEAD
 1.68.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.70.2.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.71.22.1 21-Feb-2014  sborrill Pull up the following revisions(s) (requested by tsutsui in ticket #1033):
sys/arch/atari/dev/ite.c: revision 1.72

Fix kernel crash when a user tries to switch to nonexistent terminal.
Fixes PR/48599.
 1.71.16.1 18-May-2014  rmind sync with head
 1.71.14.1 21-Feb-2014  sborrill Pull up the following revisions(s) (requested by tsutsui in ticket #1033):
sys/arch/atari/dev/ite.c: revision 1.72

Fix kernel crash when a user tries to switch to nonexistent terminal.
Fixes PR/48599.
 1.71.12.2 03-Dec-2017  jdolecek update from HEAD
 1.71.12.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.71.8.1 21-Feb-2014  sborrill Pull up the following revisions(s) (requested by tsutsui in ticket #1033):
sys/arch/atari/dev/ite.c: revision 1.72

Fix kernel crash when a user tries to switch to nonexistent terminal.
Fixes PR/48599.
 1.71.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.75.2.1 10-Aug-2014  tls Rebase.
 1.76.4.1 19-Mar-2016  skrll Sync with HEAD
 1.77.18.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.77.18.1 10-Jun-2019  christos Sync with HEAD
 1.77.16.1 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.79.10.1 03-Apr-2021  thorpej Sync with HEAD.
 1.79.2.1 11-Sep-2022  martin Pull up following revision(s) (requested by tsutsui in ticket #1518):

sys/arch/atari/dev/ite.c: revision 1.82
sys/arch/atari/dev/ite_cc.c: revision 1.45
sys/arch/atari/dev/ite_et.c: revision 1.36
sys/arch/atari/dev/itevar.h: revision 1.15

Add a minimum DEC special graphics character support for atari ite(4).

This closes PR port-atari/46647 (Menu borders in sysinst appear as
characters with diacritical marks instead of graphics characters).

Switching encoding support by "ESC ( <F>" sequence for vt220 was
pulled from x68k ite(4) (that already supports ISO-2022-JP and EUC-JP).

Note atari's fonts already include DEC special graphics characters.
ET4000 on Hades is untested due to long-term lack of hardware.

Discussed on port-atari@ etc.
 1.47 06-Jan-2023  tsutsui TAB/spaces/indents cleanup.
 1.46 26-Jun-2022  tsutsui Use aprint_*(9) for device attach messages.
 1.45 25-Jun-2022  tsutsui Add a minimum DEC special graphics character support for atari ite(4).

This closes PR port-atari/46647 (Menu borders in sysinst appear as
characters with diacritical marks instead of graphics characters).

Switching encoding support by "ESC ( <F>" sequence for vt220 was
pulled from x68k ite(4) (that already supports ISO-2022-JP and EUC-JP).
Note atari's fonts already include DEC special graphics characters.
ET4000 on Hades is untested due to long-term lack of hardware.
Discussed on port-atari@ etc.
 1.44 28-Mar-2022  riastradh sys: Split struct device into a private device_impl.h.

Include this only inside autoconf itself, and a few files that abuse
autoconf in ways I can't confidently make easy fixes for.

XXX kernel ABI change requires bump -- no more use of struct device
internals allowed, previously done by some drivers
 1.43 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.42 27-Apr-2021  thorpej branches: 1.42.6;
The Amiga and Atari ports abuse some autoconfiguration internals as part
of their early console bring-up, so we need to expose some of the new
internals to them and adapt the call sites.
 1.41 24-Apr-2021  thorpej branches: 1.41.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.40 29-Jun-2019  tsutsui branches: 1.40.2; 1.40.12;
Make local functions static.
 1.39 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.38 27-Oct-2012  chs branches: 1.38.36; 1.38.38;
split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.37 05-Jun-2011  tsutsui branches: 1.37.2; 1.37.12;
Split device_t/softc. Also rename some softc variables. Tested on TT030.

XXX: old ugly config_console() hack should go away...
 1.36 13-Apr-2010  tsutsui branches: 1.36.2; 1.36.6;
Misc KNF.
 1.35 09-Feb-2010  wiz branches: 1.35.2;
Fix typo in comment.
 1.34 19-Jul-2009  tsutsui branches: 1.34.2;
Remove extra whitespace added by a dumb tool which replaced bcopy with memcpy.
 1.33 18-Mar-2009  cegger bcopy -> memcpy
 1.32 18-Mar-2009  cegger bzero -> memset
 1.31 18-Mar-2009  cegger Ansify function definitions w/o arguments. Generated with sed.
 1.30 14-Mar-2009  dsl ANSIfy another 1261 function definitions.
The only ones left in sys are beyond by sed script!
(or in sys/dist or sys/external)
Mostly they have function pointer parameters.
 1.29 14-Mar-2009  dsl Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.28 14-Mar-2009  dsl Remove all the __P() from sys (excluding sys/dist)
Diff checked with grep and MK1 eyeball.
i386 and amd64 GENERIC and sys still build.
 1.27 04-Mar-2007  christos branches: 1.27.44; 1.27.52; 1.27.58;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.26 26-Mar-2006  thorpej branches: 1.26.14;
Use device_unit().
 1.25 24-Dec-2005  perry branches: 1.25.4; 1.25.6; 1.25.8; 1.25.10; 1.25.12;
__asm__ -> __asm
__const__ -> const
__inline__ -> inline
__volatile__ -> volatile
 1.24 24-Dec-2005  perry bare asm -> __asm
 1.23 11-Dec-2005  christos merge ktrace-lwp.
 1.22 15-Jul-2003  lukem branches: 1.22.16;
__KERNEL_RCSID()
 1.21 01-Jan-2003  thorpej branches: 1.21.2;
Use aprint_normal() for cfprint routines.
 1.20 02-Oct-2002  thorpej Use CFATTACH_DECL().
 1.19 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.18 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.17 17-Mar-2002  atatat branches: 1.17.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.16 10-Jul-2001  leo branches: 1.16.6;
Nuke another cf_unit abuse.
 1.15 11-Feb-2000  leo branches: 1.15.8;
Move the ite_default_* variables to ite.c. They are generic ite.
 1.14 12-Jan-1998  thorpej branches: 1.14.14;
Update for changes to config.
 1.13 15-Jul-1997  leo Garbage collect bell-ioctl's.
 1.12 20-Dec-1996  leo Get rid of BROKEN_INDIRECT_CONFIG
 1.11 13-Oct-1996  christos backout previous kprintf changes
 1.10 11-Oct-1996  leo Remove grf_ite_ioctl(). Replace it by 'itexx_ioctl' that is configurable
per ite-type.
 1.9 11-Oct-1996  christos printf -> kprintf, sprintf -> ksprintf
 1.8 04-Oct-1996  leo Checkpointing my et4000 work. Note that the et-console will not be
functional until the minimal pci-support is checked in.
 1.7 16-Sep-1996  leo Prepare for (soon to come) et4000 PCI console.
 1.6 18-Apr-1996  leo Yet more prototyping and -Wall fixes.
 1.5 22-Feb-1996  leo First bunch of changes due to stricter prototype checking.
 1.4 28-May-1995  leo Remove the pointer to view_t from the grf-structure, use viewview(dev)
to obtain the pointer instead. This removes a kernel-crash that happened
when something was written to the console while the console was being
resized.
 1.3 21-May-1995  leo Fix UL-handling
 1.2 28-Mar-1995  leo Make ite ioctl work and fixup the colormap stuff.
 1.1 26-Mar-1995  leo branches: 1.1.1;
Initial revision
 1.1.1.1 26-Mar-1995  leo NetBSD/Atari, port by Leo Weppelman.
 1.14.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.15.8.3 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.15.8.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.15.8.1 03-Aug-2001  lukem update to -current
 1.16.6.5 03-Jan-2003  thorpej Sync with HEAD.
 1.16.6.4 18-Oct-2002  nathanw Catch up to -current.
 1.16.6.3 17-Sep-2002  nathanw Catch up to -current.
 1.16.6.2 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.16.6.1 10-Jul-2001  nathanw file ite_cc.c was added on branch nathanw_sa on 2002-04-01 07:39:32 +0000
 1.17.4.1 19-May-2002  gehenna Replace the access to devsw table and the hard-coded majors with devsw API.
 1.21.2.4 17-Jan-2005  skrll Adapt to branch.
 1.21.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.21.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.21.2.1 03-Aug-2004  skrll Sync with HEAD
 1.22.16.2 03-Sep-2007  yamt sync with head.
 1.22.16.1 21-Jun-2006  yamt sync with head.
 1.25.12.1 28-Mar-2006  tron Merge 2006-03-28 NetBSD-current into the "peter-altq" branch.
 1.25.10.1 19-Apr-2006  elad sync with head - hopefully this will work
 1.25.8.1 01-Apr-2006  yamt sync with head.
 1.25.6.1 22-Apr-2006  simonb Sync with head.
 1.25.4.1 09-Sep-2006  rpaulo sync with head
 1.26.14.1 12-Mar-2007  rmind Sync with HEAD.
 1.27.58.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.27.52.1 28-Apr-2009  skrll Sync with HEAD.
 1.27.44.4 11-Aug-2010  yamt sync with head.
 1.27.44.3 11-Mar-2010  yamt sync with head
 1.27.44.2 19-Aug-2009  yamt sync with head.
 1.27.44.1 04-May-2009  yamt sync with head.
 1.34.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.35.2.2 12-Jun-2011  rmind sync with head
 1.35.2.1 30-May-2010  rmind sync with head
 1.36.6.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.36.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.37.12.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.37.2.1 30-Oct-2012  yamt sync with head
 1.38.38.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.38.38.1 10-Jun-2019  christos Sync with HEAD
 1.38.36.1 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.40.12.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.40.2.1 11-Sep-2022  martin Pull up following revision(s) (requested by tsutsui in ticket #1518):

sys/arch/atari/dev/ite.c: revision 1.82
sys/arch/atari/dev/ite_cc.c: revision 1.45
sys/arch/atari/dev/ite_et.c: revision 1.36
sys/arch/atari/dev/itevar.h: revision 1.15

Add a minimum DEC special graphics character support for atari ite(4).

This closes PR port-atari/46647 (Menu borders in sysinst appear as
characters with diacritical marks instead of graphics characters).

Switching encoding support by "ESC ( <F>" sequence for vt220 was
pulled from x68k ite(4) (that already supports ISO-2022-JP and EUC-JP).

Note atari's fonts already include DEC special graphics characters.
ET4000 on Hades is untested due to long-term lack of hardware.

Discussed on port-atari@ etc.
 1.41.2.1 13-May-2021  thorpej Sync with HEAD.
 1.42.6.1 03-Aug-2021  thorpej Adapt to CFARGS().
 1.38 06-Jan-2023  tsutsui TAB/spaces/indents cleanup.
 1.37 26-Jun-2022  tsutsui Use aprint_*(9) for device attach messages.
 1.36 25-Jun-2022  tsutsui Add a minimum DEC special graphics character support for atari ite(4).

This closes PR port-atari/46647 (Menu borders in sysinst appear as
characters with diacritical marks instead of graphics characters).

Switching encoding support by "ESC ( <F>" sequence for vt220 was
pulled from x68k ite(4) (that already supports ISO-2022-JP and EUC-JP).
Note atari's fonts already include DEC special graphics characters.
ET4000 on Hades is untested due to long-term lack of hardware.
Discussed on port-atari@ etc.
 1.35 28-Mar-2022  riastradh sys: Split struct device into a private device_impl.h.

Include this only inside autoconf itself, and a few files that abuse
autoconf in ways I can't confidently make easy fixes for.

XXX kernel ABI change requires bump -- no more use of struct device
internals allowed, previously done by some drivers
 1.34 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.33 27-Apr-2021  thorpej branches: 1.33.6;
The Amiga and Atari ports abuse some autoconfiguration internals as part
of their early console bring-up, so we need to expose some of the new
internals to them and adapt the call sites.
 1.32 24-Apr-2021  thorpej branches: 1.32.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.31 29-Jun-2019  tsutsui branches: 1.31.2; 1.31.12;
Make local functions static.
 1.30 05-Jun-2011  tsutsui branches: 1.30.54;
Split device_t/softc. Also rename some softc variables. Tested on TT030.

XXX: old ugly config_console() hack should go away...
 1.29 13-Apr-2010  tsutsui branches: 1.29.2; 1.29.6;
Misc KNF.
 1.28 09-Feb-2010  wiz branches: 1.28.2;
Fix typo in comment.
 1.27 20-Oct-2009  snj branches: 1.27.2;
Remove 3rd and 4th clause on Leo Weppelman's license. OK leo@.
 1.26 19-Jul-2009  tsutsui Remove extra whitespace added by a dumb tool which replaced bcopy with memcpy.
 1.25 18-Mar-2009  cegger bcopy -> memcpy
 1.24 18-Mar-2009  cegger bzero -> memset
 1.23 14-Mar-2009  dsl ANSIfy another 1261 function definitions.
The only ones left in sys are beyond by sed script!
(or in sys/dist or sys/external)
Mostly they have function pointer parameters.
 1.22 14-Mar-2009  dsl Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.21 14-Mar-2009  dsl Remove all the __P() from sys (excluding sys/dist)
Diff checked with grep and MK1 eyeball.
i386 and amd64 GENERIC and sys still build.
 1.20 04-Mar-2007  christos branches: 1.20.44; 1.20.52; 1.20.58;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.19 26-Mar-2006  thorpej branches: 1.19.14;
Use device_unit().
 1.18 11-Dec-2005  christos branches: 1.18.4; 1.18.6; 1.18.8; 1.18.10; 1.18.12;
merge ktrace-lwp.
 1.17 15-Jul-2003  lukem branches: 1.17.16;
__KERNEL_RCSID()
 1.16 01-Jan-2003  thorpej branches: 1.16.2;
Use aprint_normal() for cfprint routines.
 1.15 02-Oct-2002  thorpej Use CFATTACH_DECL().
 1.14 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.13 06-Sep-2002  gehenna Merge the gehenna-devsw branch into the trunk.

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

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

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

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

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

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

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

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

- In compile time, device major numbers list is packed into the kernel and
the LKM framework will refer it to assign device major number dynamically.
 1.12 17-Mar-2002  atatat branches: 1.12.4;
Convert ioctl code to use EPASSTHROUGH instead of -1 or ENOTTY for
indicating an unhandled "command". ERESTART is -1, which can lead to
confusion. ERESTART has been moved to -3 and EPASSTHROUGH has been
placed at -4. No ioctl code should now return -1 anywhere. The
ioctl() system call is now properly restartable.
 1.11 09-Jul-2001  leo branches: 1.11.2; 1.11.8;
Nuke some cf_unit abuses.
 1.10 29-Mar-2000  leo Nuke a bunch of cf_unit abuses.
 1.9 11-Feb-2000  leo Move the ite_default_* variables to ite.c. They are generic ite.
 1.8 12-Jan-1998  thorpej branches: 1.8.14;
Update for changes to config.
 1.7 15-Jul-1997  leo Garbage collect bell-ioctl's.
 1.6 09-Jul-1997  leo Make sure the card is probed once.
 1.5 20-Dec-1996  leo Get rid of BROKEN_INDIRECT_CONFIG
 1.4 13-Oct-1996  christos backout previous kprintf changes
 1.3 11-Oct-1996  leo *** empty log message ***
 1.2 11-Oct-1996  christos printf -> kprintf, sprintf -> ksprintf
 1.1 04-Oct-1996  leo Checkpointing my et4000 work. Note that the et-console will not be
functional until the minimal pci-support is checked in.
 1.8.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.11.8.5 03-Jan-2003  thorpej Sync with HEAD.
 1.11.8.4 18-Oct-2002  nathanw Catch up to -current.
 1.11.8.3 17-Sep-2002  nathanw Catch up to -current.
 1.11.8.2 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.11.8.1 09-Jul-2001  nathanw file ite_et.c was added on branch nathanw_sa on 2002-04-01 07:39:32 +0000
 1.11.2.2 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.11.2.1 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.12.4.1 19-May-2002  gehenna Replace the access to devsw table and the hard-coded majors with devsw API.
 1.16.2.4 17-Jan-2005  skrll Adapt to branch.
 1.16.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.16.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.16.2.1 03-Aug-2004  skrll Sync with HEAD
 1.17.16.2 03-Sep-2007  yamt sync with head.
 1.17.16.1 21-Jun-2006  yamt sync with head.
 1.18.12.1 28-Mar-2006  tron Merge 2006-03-28 NetBSD-current into the "peter-altq" branch.
 1.18.10.1 19-Apr-2006  elad sync with head - hopefully this will work
 1.18.8.1 01-Apr-2006  yamt sync with head.
 1.18.6.1 22-Apr-2006  simonb Sync with head.
 1.18.4.1 09-Sep-2006  rpaulo sync with head
 1.19.14.1 12-Mar-2007  rmind Sync with HEAD.
 1.20.58.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.20.52.1 28-Apr-2009  skrll Sync with HEAD.
 1.20.44.4 11-Aug-2010  yamt sync with head.
 1.20.44.3 11-Mar-2010  yamt sync with head
 1.20.44.2 19-Aug-2009  yamt sync with head.
 1.20.44.1 04-May-2009  yamt sync with head.
 1.27.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.28.2.2 12-Jun-2011  rmind sync with head
 1.28.2.1 30-May-2010  rmind sync with head
 1.29.6.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.29.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.30.54.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.31.12.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.31.2.1 11-Sep-2022  martin Pull up following revision(s) (requested by tsutsui in ticket #1518):

sys/arch/atari/dev/ite.c: revision 1.82
sys/arch/atari/dev/ite_cc.c: revision 1.45
sys/arch/atari/dev/ite_et.c: revision 1.36
sys/arch/atari/dev/itevar.h: revision 1.15

Add a minimum DEC special graphics character support for atari ite(4).

This closes PR port-atari/46647 (Menu borders in sysinst appear as
characters with diacritical marks instead of graphics characters).

Switching encoding support by "ESC ( <F>" sequence for vt220 was
pulled from x68k ite(4) (that already supports ISO-2022-JP and EUC-JP).

Note atari's fonts already include DEC special graphics characters.
ET4000 on Hades is untested due to long-term lack of hardware.

Discussed on port-atari@ etc.
 1.32.2.1 13-May-2021  thorpej Sync with HEAD.
 1.33.6.1 03-Aug-2021  thorpej Adapt to CFARGS().
 1.9 01-Nov-2021  andvar fix typos, mainly in words minimum and maximum, but also few others.
 1.8 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.7 08-Feb-2011  rmind branches: 1.7.14; 1.7.32;
Remove clause 3 (UCB advertising clause) from the University of Utah
copyright. Confirmed by Mike Hibler, mike at cs.utah.edu - thanks!
Also, merge UCB and Utah copyright texts back into one, as they
originally were.

Extra verification by snj@.
 1.6 11-Dec-2005  christos branches: 1.6.100; 1.6.106; 1.6.108;
merge ktrace-lwp.
 1.5 19-May-2004  he Include <machine/kbdmap.h> only outside the kernel, as that file
isn't present in that location in the source tree.
 1.4 18-May-2004  he Add some mulitple include protection.
Include kbdmap.h from iteioctl.h so that kdump compiles, otherwise
the size of struct kbdmap as used in various ioctl defines is unknown.
 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 24-Jul-1995  leo branches: 1.2.66;
Change and fix the way of keyboard mapping. Each virtual console has it's
own private keymap, initialized on open from the system-keymap. Both
system and private keymaps are settable.
 1.1 26-Mar-1995  leo branches: 1.1.1;
Initial revision
 1.1.1.1 26-Mar-1995  leo NetBSD/Atari, port by Leo Weppelman.
 1.2.66.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.2.66.2 18-Sep-2004  skrll Sync with HEAD.
 1.2.66.1 03-Aug-2004  skrll Sync with HEAD
 1.6.108.1 17-Feb-2011  bouyer Sync with HEAD
 1.6.106.1 06-Jun-2011  jruoho Sync with HEAD.
 1.6.100.1 05-Mar-2011  rmind sync with head
 1.7.32.1 22-Sep-2015  skrll Sync with HEAD
 1.7.14.1 03-Dec-2017  jdolecek update from HEAD
 1.16 06-Jan-2023  tsutsui TAB/spaces/indents cleanup.
 1.15 25-Jun-2022  tsutsui Add a minimum DEC special graphics character support for atari ite(4).

This closes PR port-atari/46647 (Menu borders in sysinst appear as
characters with diacritical marks instead of graphics characters).

Switching encoding support by "ESC ( <F>" sequence for vt220 was
pulled from x68k ite(4) (that already supports ISO-2022-JP and EUC-JP).
Note atari's fonts already include DEC special graphics characters.
ET4000 on Hades is untested due to long-term lack of hardware.
Discussed on port-atari@ etc.
 1.14 05-Jun-2011  tsutsui branches: 1.14.58;
Split device_t/softc. Also rename some softc variables. Tested on TT030.

XXX: old ugly config_console() hack should go away...
 1.13 14-Mar-2009  dsl branches: 1.13.4; 1.13.6; 1.13.10;
Remove all the __P() from sys (excluding sys/dist)
Diff checked with grep and MK1 eyeball.
i386 and amd64 GENERIC and sys still build.
 1.12 04-Mar-2007  christos branches: 1.12.44; 1.12.52; 1.12.58;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.11 11-Dec-2005  christos branches: 1.11.26;
merge ktrace-lwp.
 1.10 19-Jan-2005  chs branches: 1.10.8;
use a flag in the softc to indicate if an instance has been configured,
rather than a bit in 32-bit global variable indexed by unit number.
 1.9 06-Sep-2002  gehenna branches: 1.9.6; 1.9.14;
Merge the gehenna-devsw branch into the trunk.

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

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

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

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

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

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

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

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

- In compile time, device major numbers list is packed into the kernel and
the LKM framework will refer it to assign device major number dynamically.
 1.8 30-May-2001  leo branches: 1.8.2; 1.8.8; 1.8.16;
Add itepoll() prototype as suggested by 'maximum entropy' (pr#13047).
 1.7 27-Mar-2000  leo branches: 1.7.6;
This file was forgotten in the commit with log message:
Move the ite_default_* variables to ite.c. They are generic ite.
 1.6 11-Oct-1996  leo branches: 1.6.28;
Remove grf_ite_ioctl(). Replace it by 'itexx_ioctl' that is configurable
per ite-type.
 1.5 18-Apr-1996  leo Yet more prototyping and -Wall fixes.
 1.4 20-Mar-1996  leo And more proto's.....
 1.3 22-Feb-1996  leo First bunch of changes due to stricter prototype checking.
 1.2 25-Jul-1995  leo A forgotten file for the kbdmap fixes.
 1.1 26-Mar-1995  leo branches: 1.1.1;
Initial revision
 1.1.1.1 26-Mar-1995  leo NetBSD/Atari, port by Leo Weppelman.
 1.6.28.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.6.1 21-Jun-2001  nathanw Catch up to -current.
 1.8.16.1 19-May-2002  gehenna Remove unnecessary prototype.
 1.8.8.2 17-Sep-2002  nathanw Catch up to -current.
 1.8.8.1 30-May-2001  nathanw file itevar.h was added on branch nathanw_sa on 2002-09-17 21:13:46 +0000
 1.8.2.1 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.9.14.1 29-Apr-2005  kent sync with -current
 1.9.6.2 24-Jan-2005  skrll Sync with HEAD.
 1.9.6.1 17-Jan-2005  skrll Adapt to branch.
 1.10.8.2 03-Sep-2007  yamt sync with head.
 1.10.8.1 21-Jun-2006  yamt sync with head.
 1.11.26.1 12-Mar-2007  rmind Sync with HEAD.
 1.12.58.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.12.52.1 28-Apr-2009  skrll Sync with HEAD.
 1.12.44.1 04-May-2009  yamt sync with head.
 1.13.10.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.13.6.1 06-Jun-2011  jruoho Sync with HEAD.
 1.13.4.1 12-Jun-2011  rmind sync with head
 1.14.58.1 11-Sep-2022  martin Pull up following revision(s) (requested by tsutsui in ticket #1518):

sys/arch/atari/dev/ite.c: revision 1.82
sys/arch/atari/dev/ite_cc.c: revision 1.45
sys/arch/atari/dev/ite_et.c: revision 1.36
sys/arch/atari/dev/itevar.h: revision 1.15

Add a minimum DEC special graphics character support for atari ite(4).

This closes PR port-atari/46647 (Menu borders in sysinst appear as
characters with diacritical marks instead of graphics characters).

Switching encoding support by "ESC ( <F>" sequence for vt220 was
pulled from x68k ite(4) (that already supports ISO-2022-JP and EUC-JP).

Note atari's fonts already include DEC special graphics characters.
ET4000 on Hades is untested due to long-term lack of hardware.

Discussed on port-atari@ etc.
 1.59 08-Sep-2024  rillig fix a/an grammar in obvious cases
 1.58 26-Jun-2023  andvar branches: 1.58.6;
s/privious/previous/ in comment.
 1.57 06-Jan-2023  tsutsui TAB/spaces/indents cleanup.
 1.56 26-Jun-2022  martin gcc is not smart enough to track the equivalence of conditions used
here and warns about an unused value - initialize "code" always.
 1.55 26-Jun-2022  tsutsui Restore redundant register accesses as the original implementation did.

It looks my refactored one for entropy sometimes returns unexpected
values and they cause "kbd: Unknown packet 0xfd" errors and missing
keyboard release events.
 1.54 25-Jun-2022  tsutsui Add rnd(9) entropy source from keyboard and mouse.
 1.53 25-Jun-2022  tsutsui Use aprint_*(9) for device attach messages.
 1.52 25-Jun-2022  tsutsui Rename and reformat softc stuff for readablity, and misc more cleanups.

No binary change.
 1.51 25-Jun-2022  tsutsui Move declarations to proper places.
 1.50 25-Jun-2022  tsutsui Misc cleanup. No functional changes, no regression on TT030.

- KNF and TAB/space
- make local functions static
- avoid unnesessary __USE()
- use proper integer types
- remove a register keyword
 1.49 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.48 24-Apr-2021  thorpej branches: 1.48.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.47 08-Feb-2018  dholland branches: 1.47.18;
Typos.
 1.46 18-Oct-2014  snj src is too big these days to tolerate superfluous apostrophes. It's
"its", people!
 1.45 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.44 24-Mar-2014  christos branches: 1.44.2;
- remove unused
- use cpu_{g,s}etmodel() (not committed yet)
 1.43 16-Mar-2014  dholland 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.42 05-Jun-2011  tsutsui branches: 1.42.2; 1.42.12; 1.42.16;
- use CFATTACH_DECL_NEW() (no softc)
- use device_t, cfdata_t etc.
 1.41 13-Apr-2010  tsutsui branches: 1.41.2; 1.41.6;
Misc KNF.
 1.40 25-Nov-2009  abs branches: 1.40.2; 1.40.4;
Fix a missed proc -> lwp change, only compiled if NWSKBD
 1.39 03-Jul-2009  tsutsui Replace one traditional MD si_callback() with MI softint(9).
 1.38 03-Jul-2009  tsutsui Use more uint8_t, and constify.
 1.37 03-Jul-2009  tsutsui KNF, use uint8_t, and misc cosmetics.
 1.36 18-Mar-2009  cegger Ansify function definitions w/o arguments. Generated with sed.
 1.35 14-Mar-2009  dsl ANSIfy another 1261 function definitions.
The only ones left in sys are beyond by sed script!
(or in sys/dist or sys/external)
Mostly they have function pointer parameters.
 1.34 14-Mar-2009  dsl Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.33 14-Mar-2009  dsl Remove all the __P() from sys (excluding sys/dist)
Diff checked with grep and MK1 eyeball.
i386 and amd64 GENERIC and sys still build.
 1.32 17-Jan-2009  tsutsui branches: 1.32.2;
Use firm_gettime() to retain compatibility with old firm_event. From amiga.
 1.31 08-Jan-2008  joerg branches: 1.31.6; 1.31.10; 1.31.18;
Convert Atari to generic TODR and timecounter.
 1.30 04-Mar-2007  christos branches: 1.30.20; 1.30.26; 1.30.32;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.29 11-Dec-2005  christos branches: 1.29.26;
merge ktrace-lwp.
 1.28 25-Mar-2004  leo branches: 1.28.16;
Licence cleanup (suggested by wiz).
 1.27 21-Sep-2003  jdolecek cleanup & uniform descriptor owner handling:
* introduce fsetown(), fgetown(), fownsignal() - this sets/retrieves/signals
the owner of descriptor, according to appropriate sematics
of TIOCSPGRP/FIOSETOWN/SIOCSPGRP/TIOCGPGRP/FIOGETOWN/SIOCGPGRP ioctl; use
these routines instead of custom code where appropriate
* make every place handling TIOCSPGRP/TIOCGPGRP handle also FIOSETOWN/FIOGETOWN
properly, and remove the translation of FIO[SG]OWN to TIOC[SG]PGRP
in sys_ioctl() & sys_fcntl()
* also remove the socket-specific hack in sys_ioctl()/sys_fcntl() and
pass the ioctls down to soo_ioctl() as any other ioctl

change discussed on tech-kern@
 1.26 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.25 15-Jul-2003  lukem __KERNEL_RCSID()
 1.24 04-Feb-2003  leo branches: 1.24.2;
NUL -> NULL.
 1.23 02-Feb-2003  thomas WS keyboard support for atari native keyboards.
 1.22 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.21 02-Oct-2002  thorpej Use CFATTACH_DECL().
 1.20 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.19 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.18 06-Aug-1999  leo branches: 1.18.14; 1.18.16; 1.18.20; 1.18.28;
Change the way that bit's are cleared in the InterruptPending register of
the 68901. Do this now by _assigning_ ~<bit_to_clear> instead of the
previously used 'andb ~<bit_to_clear>'. The latter caused a rwm-cycle that
caused a race condition to happen when an interrupt arrived between the
Read and Modify-Write.
Anyway, this solved my hanging keyboard problem.
 1.17 12-Jan-1998  thorpej Update for changes to config.
 1.16 29-Jun-1997  leo Add code to set pitch and duration of the keyboard bell. (Thomas Gerner).
 1.15 10-Jan-1997  leo Handle keyboard modifiers *before* handing the keycodes to either the
console driver or the DDB keyboard functions. This prevents annoyances
with out of sync modifier stati.
 1.14 20-Dec-1996  leo Get rid of BROKEN_INDIRECT_CONFIG
 1.13 16-Oct-1996  leo select -> poll
 1.12 13-Oct-1996  christos backout previous kprintf changes
 1.11 11-Oct-1996  christos printf -> kprintf, sprintf -> ksprintf
 1.10 18-Apr-1996  leo Yet more prototyping and -Wall fixes.
 1.9 12-Apr-1996  leo Add 3-button mouse support.
 1.8 27-Mar-1996  leo Small nits because of changes in ym2149 handling.
 1.7 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.6 22-Feb-1996  leo First bunch of changes due to stricter prototype checking.
 1.5 26-Jun-1995  leo Fix thinko. It will now also work when no mouse is configured.
 1.4 25-Jun-1995  leo Mouse driver added.
 1.3 09-Jun-1995  leo Handle mouse and other packages received from the keyboard correctly.
The initialisation now resets the keyboard and disables all packages
that make no sense because their drivers are not activated.
 1.2 10-Apr-1995  mycroft Nuke kbdwrite().
 1.1 26-Mar-1995  leo branches: 1.1.1;
Initial revision
 1.1.1.1 26-Mar-1995  leo NetBSD/Atari, port by Leo Weppelman.
 1.18.28.1 17-May-2002  gehenna Add device switch.
 1.18.20.3 11-Nov-2002  nathanw Catch up to -current
 1.18.20.2 18-Oct-2002  nathanw Catch up to -current.
 1.18.20.1 17-Sep-2002  nathanw Catch up to -current.
 1.18.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.18.16.1 09-Sep-2001  thorpej Add kqueue support (not yet compiled).
 1.18.14.1 10-Oct-2001  fvdl Convert all remaining devices.
 1.24.2.4 17-Jan-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.28.16.3 21-Jan-2008  yamt sync with head
 1.28.16.2 03-Sep-2007  yamt sync with head.
 1.28.16.1 21-Jun-2006  yamt sync with head.
 1.29.26.1 12-Mar-2007  rmind Sync with HEAD.
 1.30.32.1 08-Jan-2008  bouyer Sync with HEAD
 1.30.26.1 18-Feb-2008  mjf Sync with HEAD.
 1.30.20.1 23-Mar-2008  matt sync with HEAD
 1.31.18.2 28-Apr-2009  skrll Sync with HEAD.
 1.31.18.1 19-Jan-2009  skrll Sync with HEAD.
 1.31.10.4 11-Aug-2010  yamt sync with head.
 1.31.10.3 11-Mar-2010  yamt sync with head
 1.31.10.2 18-Jul-2009  yamt sync with head.
 1.31.10.1 04-May-2009  yamt sync with head.
 1.31.6.1 17-Jan-2009  mjf Sync with HEAD.
 1.32.2.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.40.4.2 12-Jun-2011  rmind sync with head
 1.40.4.1 30-May-2010  rmind sync with head
 1.40.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.41.6.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.41.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.42.16.1 18-May-2014  rmind sync with head
 1.42.12.2 03-Dec-2017  jdolecek update from HEAD
 1.42.12.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.42.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.44.2.1 10-Aug-2014  tls Rebase.
 1.47.18.1 21-Mar-2021  thorpej Give config_found() the same variadic arguments treatment as
config_search(). This commit only adds the CFARG_EOL sentinel
to the existing config_found() calls. Conversion of config_found_sm_loc()
and config_found_ia() call sites will be in subsequent commits.
 1.48.8.1 03-Aug-2021  thorpej Adapt to CFARGS().
 1.58.6.1 02-Aug-2025  perseant Sync with HEAD
 1.7 06-Jan-2023  tsutsui TAB/spaces/indents cleanup.
 1.6 20-Oct-2009  snj Remove 3rd and 4th clause on Leo Weppelman's license. OK leo@.
 1.5 11-Dec-2005  christos branches: 1.5.78;
merge ktrace-lwp.
 1.4 15-Jul-2003  lukem __KERNEL_RCSID()
 1.3 15-May-1996  leo branches: 1.3.64;
Prototype + -Wall fixes.
 1.2 24-Jul-1995  leo Change and fix the way of keyboard mapping. Each virtual console has it's
own private keymap, initialized on open from the system-keymap. Both
system and private keymaps are settable.
 1.1 26-Mar-1995  leo branches: 1.1.1;
Initial revision
 1.1.1.1 26-Mar-1995  leo NetBSD/Atari, port by Leo Weppelman.
 1.3.64.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.3.64.2 18-Sep-2004  skrll Sync with HEAD.
 1.3.64.1 03-Aug-2004  skrll Sync with HEAD
 1.5.78.1 11-Mar-2010  yamt sync with head
 1.6 11-Dec-2005  christos merge ktrace-lwp.
 1.5 18-May-2004  he Add some mulitple include protection.
Include kbdmap.h from iteioctl.h so that kdump compiles, otherwise
the size of struct kbdmap as used in various ioctl defines is unknown.
 1.4 10-Jan-1997  leo branches: 1.4.62;
Handle keyboard modifiers *before* handing the keycodes to either the
console driver or the DDB keyboard functions. This prevents annoyances
with out of sync modifier stati.
 1.3 24-Jul-1995  leo Change and fix the way of keyboard mapping. Each virtual console has it's
own private keymap, initialized on open from the system-keymap. Both
system and private keymaps are settable.
 1.2 30-Mar-1995  leo KERNEL -> _KERNEL
 1.1 26-Mar-1995  leo branches: 1.1.1;
Initial revision
 1.1.1.1 26-Mar-1995  leo NetBSD/Atari, port by Leo Weppelman.
 1.4.62.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.4.62.2 18-Sep-2004  skrll Sync with HEAD.
 1.4.62.1 03-Aug-2004  skrll Sync with HEAD
 1.6 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.5 11-Dec-2005  christos branches: 1.5.122; 1.5.142;
merge ktrace-lwp.
 1.4 18-May-2004  he Add some mulitple include protection.
Include kbdmap.h from iteioctl.h so that kdump compiles, otherwise
the size of struct kbdmap as used in various ioctl defines is unknown.
 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 29-Jun-1997  leo branches: 1.2.56;
Add code to set pitch and duration of the keyboard bell. (Thomas Gerner).
 1.1 26-Mar-1995  leo branches: 1.1.1;
Initial revision
 1.1.1.1 26-Mar-1995  leo NetBSD/Atari, port by Leo Weppelman.
 1.2.56.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.2.56.2 18-Sep-2004  skrll Sync with HEAD.
 1.2.56.1 03-Aug-2004  skrll Sync with HEAD
 1.5.142.1 22-Sep-2015  skrll Sync with HEAD
 1.5.122.1 03-Dec-2017  jdolecek update from HEAD
 1.11 25-Jun-2022  tsutsui Move declarations to proper places.
 1.10 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.9 20-Oct-2009  snj branches: 1.9.12; 1.9.22;
Remove 3rd and 4th clause on Leo Weppelman's license. OK leo@.
 1.8 03-Jul-2009  tsutsui Replace one traditional MD si_callback() with MI softint(9).
 1.7 03-Jul-2009  tsutsui Use more uint8_t, and constify.
 1.6 14-Mar-2009  dsl Remove all the __P() from sys (excluding sys/dist)
Diff checked with grep and MK1 eyeball.
i386 and amd64 GENERIC and sys still build.
 1.5 02-Feb-2003  thomas branches: 1.5.108; 1.5.116; 1.5.122;
WS keyboard support for atari native keyboards.
 1.4 31-Aug-2001  simonb branches: 1.4.6;
Use comments around the token after a #endif.
 1.3 29-Jun-1997  leo branches: 1.3.36;
Add code to set pitch and duration of the keyboard bell. (Thomas Gerner).
 1.2 12-Jan-1997  leo This should have been part of the keyboard-modifier changes.
 1.1 12-Apr-1996  leo Part of restructuring done for 3-button mouse support.
 1.3.36.1 13-Sep-2001  thorpej Update the kqueue branch to HEAD.
 1.4.6.2 31-Aug-2001  simonb Use comments around the token after a #endif.
 1.4.6.1 31-Aug-2001  simonb file kbdvar.h was added on branch nathanw_sa on 2001-08-31 04:44:57 +0000
 1.5.122.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.5.116.1 28-Apr-2009  skrll Sync with HEAD.
 1.5.108.3 11-Mar-2010  yamt sync with head
 1.5.108.2 18-Jul-2009  yamt sync with head.
 1.5.108.1 04-May-2009  yamt sync with head.
 1.9.22.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.9.12.1 30-Oct-2012  yamt sync with head
 1.40 06-Jan-2023  tsutsui TAB/spaces/indents cleanup.
 1.39 26-Jun-2022  tsutsui Make local devsw functions static.

No visible regression on TT030.
 1.38 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.37 25-Jul-2014  dholland branches: 1.37.26; 1.37.28;
Add d_discard to all struct cdevsw instances I could find.

All have been set to "nodiscard"; some should get a real implementation.
 1.36 16-Mar-2014  dholland branches: 1.36.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.35 27-Oct-2012  chs branches: 1.35.2;
split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.34 13-Apr-2010  tsutsui branches: 1.34.8; 1.34.18;
Include "ioconf.h" to declare struct cfdriver foo_cd.
 1.33 12-Apr-2010  tsutsui Replace old MD sicallback functions with MI softint(9).
 1.32 23-Nov-2009  rmind branches: 1.32.2; 1.32.4;
Use lwp_getpcb() on m68k ports, clean from struct user usage.
 1.31 08-Jul-2009  tsutsui Merge local <atari/atari/intr.h> into common <machine/intr.h>.
 1.30 13-Jun-2008  cegger use device_lookup_private to get softc
 1.29 07-Mar-2008  cube branches: 1.29.2; 1.29.4; 1.29.6; 1.29.8;
Split the softc from the device_t for all lpt(4) variants and attachments
except the ppbus stuff (which doesn't compile) and ulpt(4) which is
unrelated and can be dealt with separately.

As usual, it comes with related cosmetic changes.
 1.28 17-Oct-2007  garbled branches: 1.28.12; 1.28.16;
Merge the ppcoea-renovation branch to HEAD.

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

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

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.27 08-Oct-2007  ad Merge brelse() changes from the vmlocking branch.
 1.26 09-Jul-2007  ad branches: 1.26.8; 1.26.10; 1.26.12;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements
 1.25 04-Mar-2007  christos branches: 1.25.2; 1.25.4; 1.25.10;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.24 11-Dec-2005  christos branches: 1.24.26;
merge ktrace-lwp.
 1.23 15-Jul-2003  lukem branches: 1.23.16;
__KERNEL_RCSID()
 1.22 23-Oct-2002  jdolecek branches: 1.22.6;
merge kqueue branch into -current

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

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

based on work done by Jonathan Lemon for FreeBSD
initial NetBSD port done by Luke Mewburn and Jason Thorpe
 1.21 02-Oct-2002  thorpej Use CFATTACH_DECL().
 1.20 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.19 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.18 16-Jan-2001  thomas branches: 1.18.4; 1.18.8; 1.18.16;
Let lpmatch recognice the printer.
 1.17 29-Mar-2000  leo Nuke a bunch of cf_unit abuses.
 1.16 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.15 06-Apr-1999  pk branches: 1.15.2; 1.15.8;
Move advertisement text into a comment of its own.
 1.14 15-Aug-1998  mycroft branches: 1.14.6;
Make copyright notices with my name consistent.
 1.13 15-Jan-1998  leo Make this compile again after the latest config changes.
 1.12 12-Jan-1998  thorpej Update for changes to config.
 1.11 30-Jul-1997  leo Rename lpt to lp on some places to avoid botches between files.isa and
files.atari.
 1.10 26-Dec-1996  leo branches: 1.10.10;
Add intr_establish/disestablish functions. Currently only the lpt-driver
is converted to use them...
 1.9 20-Dec-1996  leo Get rid of BROKEN_INDIRECT_CONFIG
 1.8 20-Dec-1996  leo Get rid of BROKEN_INDIRECT_CONFIG
 1.7 17-Nov-1996  leo Plug some spl-holes in the lp-driver. Also be more strict in protecting
the register access to the psg-chip. The combination of those bugs
caused the printer to print garbage sometimes.
 1.6 13-Oct-1996  christos backout previous kprintf changes
 1.5 11-Oct-1996  leo - Fix configuration name of 'lpt'
- add 'pcibus' as a mainbus device.
 1.4 11-Oct-1996  christos printf -> kprintf, sprintf -> ksprintf
 1.3 14-May-1996  leo Remove a line of debugging code.
 1.2 18-Apr-1996  leo Yet more prototyping and -Wall fixes.
 1.1 27-Mar-1996  leo Add centronics printer driver.
 1.10.10.1 23-Aug-1997  thorpej Update marc-pcmcia branch from trunk.
 1.14.6.1 07-Apr-1999  pk branches: 1.14.6.1.2;
Pull up from trunk: copyright text warts.
 1.14.6.1.2.1 21-Jun-1999  thorpej Sync w/ -current.
 1.15.8.1 21-Dec-1999  wrstuden Initial commit of recent changes to make DEV_BSIZE go away.

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

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

Non 2**n block support is automatic for LKM's and conditional for kernels
on "options NON_PO2_BLOCKS".
 1.15.2.2 18-Jan-2001  bouyer Sync with head (for UBC+NFS fixes, mostly).
 1.15.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.18.16.1 17-May-2002  gehenna Add device switch.
 1.18.8.3 11-Nov-2002  nathanw Catch up to -current
 1.18.8.2 18-Oct-2002  nathanw Catch up to -current.
 1.18.8.1 17-Sep-2002  nathanw Catch up to -current.
 1.18.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.22.6.4 17-Jan-2005  skrll Adapt to branch.
 1.22.6.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.22.6.2 18-Sep-2004  skrll Sync with HEAD.
 1.22.6.1 03-Aug-2004  skrll Sync with HEAD
 1.23.16.4 17-Mar-2008  yamt sync with head.
 1.23.16.3 27-Oct-2007  yamt sync with head.
 1.23.16.2 03-Sep-2007  yamt sync with head.
 1.23.16.1 21-Jun-2006  yamt sync with head.
 1.24.26.1 12-Mar-2007  rmind Sync with HEAD.
 1.25.10.2 16-Oct-2007  garbled Sync with HEAD
 1.25.10.1 03-Oct-2007  garbled Sync with HEAD
 1.25.4.1 11-Jul-2007  mjf Sync with head.
 1.25.2.2 09-Oct-2007  ad Sync with head.
 1.25.2.1 15-Jul-2007  ad Sync with head.
 1.26.12.1 14-Oct-2007  yamt sync with head.
 1.26.10.2 23-Mar-2008  matt sync with HEAD
 1.26.10.1 06-Nov-2007  matt sync with HEAD
 1.26.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.28.16.2 29-Jun-2008  mjf Sync with HEAD.
 1.28.16.1 03-Apr-2008  mjf Sync with HEAD.
 1.28.12.1 24-Mar-2008  keiichi sync with head.
 1.29.8.1 18-Jun-2008  simonb Sync with head.
 1.29.6.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.29.4.4 11-Aug-2010  yamt sync with head.
 1.29.4.3 11-Mar-2010  yamt sync with head
 1.29.4.2 18-Jul-2009  yamt sync with head.
 1.29.4.1 04-May-2009  yamt sync with head.
 1.29.2.1 17-Jun-2008  yamt sync with head.
 1.32.4.1 30-May-2010  rmind sync with head
 1.32.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.34.18.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.34.18.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.34.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.34.8.1 30-Oct-2012  yamt sync with head
 1.35.2.1 18-May-2014  rmind sync with head
 1.36.2.1 10-Aug-2014  tls Rebase.
 1.37.28.1 10-Jun-2019  christos Sync with HEAD
 1.37.26.1 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.36 06-Jan-2023  tsutsui TAB/spaces/indents cleanup.
 1.35 03-Jan-2021  thorpej malloc(9) -> kmem(9)
 1.34 03-Sep-2018  riastradh branches: 1.34.12;
Rename min/max -> uimin/uimax for better honesty.

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

HOWEVER! Some subsystems have

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

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

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

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

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

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

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)
 1.33 20-Oct-2009  snj branches: 1.33.44; 1.33.54; 1.33.62; 1.33.64;
Remove 3rd and 4th clause on Leo Weppelman's license. OK leo@.
 1.32 07-Jul-2009  tsutsui Some KNF and cosmetics.
 1.31 18-Mar-2009  cegger bcopy -> memcpy
 1.30 14-Mar-2009  dsl Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.29 14-Mar-2009  dsl Remove all the __P() from sys (excluding sys/dist)
Diff checked with grep and MK1 eyeball.
i386 and amd64 GENERIC and sys still build.
 1.28 28-Dec-2008  tsutsui branches: 1.28.2;
Fix broken RCS Id.
 1.27 28-Dec-2008  tsutsui Clear bp->b_oflags (introduced on vmlocking2 merge) before read
rather than calling brelse(9) after read.
Tested by Tuomo Makinen on port-atari.

Should fix pool panics during installation reported by David Ross
on port-atari:
http://mail-index.NetBSD.org/port-atari/2008/11/13/msg000113.html
and actually close PR port-atari/39850.
 1.26 04-Nov-2008  abs Another fix from Tuomo Makinen - Use brelse() to unbusy bp buffer
to allow user to swap floppy disks when prompted.
 1.25 02-Jan-2008  ad branches: 1.25.6; 1.25.10; 1.25.16; 1.25.18; 1.25.20;
Merge vmlocking2 to head.
 1.24 17-Oct-2007  garbled branches: 1.24.2; 1.24.4; 1.24.8;
Merge the ppcoea-renovation branch to HEAD.

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

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

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.23 29-Jul-2007  ad branches: 1.23.6;
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.22 06-Mar-2007  tsutsui branches: 1.22.2; 1.22.10; 1.22.12; 1.22.14;
- change pointers which actually required caddr_t to calculate address
from (void *) to (char *)
- add (char *) cast to appease -Wpointer-arith
 1.21 04-Mar-2007  christos Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.20 11-Dec-2005  christos branches: 1.20.24; 1.20.26;
merge ktrace-lwp.
 1.19 15-Jul-2003  lukem branches: 1.19.16;
__KERNEL_RCSID()
 1.18 06-Sep-2002  gehenna branches: 1.18.6;
Merge the gehenna-devsw branch into the trunk.

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

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

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

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

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

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

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

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

- In compile time, device major numbers list is packed into the kernel and
the LKM framework will refer it to assign device major number dynamically.
 1.17 23-May-2002  leo Fix typo.
 1.16 23-May-2002  leo Update md config:
- md0 -> 1MB image on a 720KB floppy
- md1 -> 1.44MB image on a 720KB floppy
- md2 -> 1.44MB image on a 1.44MB floppy
 1.15 27-Nov-2000  chs branches: 1.15.2; 1.15.4; 1.15.8; 1.15.16; 1.15.18;
Initial integration of the Unified Buffer Cache project.
 1.14 21-Jan-2000  thorpej Update for sys/buf.h/disksort_*() changes.
 1.13 30-Jul-1997  leo branches: 1.13.18;
Add second md device.
 1.12 30-Mar-1997  leo branches: 1.12.4;
Add a space to the attach message.
 1.11 28-Dec-1996  pk omission in last commit: ramdisk.h => md.h
 1.10 28-Dec-1996  pk rename: ramdisk => md
 1.9 20-Dec-1996  leo Get rid of BROKEN_INDIRECT_CONFIG
 1.8 08-Nov-1996  leo Adapt to the change in the floppy minor-number sceme.
 1.7 13-Oct-1996  christos backout previous kprintf changes
 1.6 11-Oct-1996  christos printf -> kprintf, sprintf -> ksprintf
 1.5 16-Sep-1996  leo atari_realconfig now defined in <atari/device.h>
 1.4 26-Apr-1996  leo Corrections for removed <sys/cpu.h> and some more prototypes.
 1.3 18-Apr-1996  leo Yet more prototyping and -Wall fixes.
 1.2 27-Mar-1996  leo Remove rd_match_hook().
 1.1 14-Mar-1996  leo Switch to the mi ramdisk driver.
 1.12.4.1 23-Aug-1997  thorpej Update marc-pcmcia branch from trunk.
 1.13.18.2 08-Dec-2000  bouyer Sync with HEAD.
 1.13.18.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.15.18.1 28-May-2002  lukem Pull up revisions 1.16-1.17 (requested by leo):
Update md config:
- md0 -> 1MB image on a 720KB floppy
- md1 -> 1.44MB image on a 720KB floppy
- md2 -> 1.44MB image on a 1.44MB floppy
Fix typo.
 1.15.16.2 30-May-2002  gehenna Catch up with -current.
 1.15.16.1 19-May-2002  gehenna Replace the access to devsw table and the hard-coded majors with devsw API.
 1.15.8.5 17-Sep-2002  nathanw Catch up to -current.
 1.15.8.4 12-Jul-2002  nathanw No longer need to pull in lwp.h; proc.h pulls it in for us.
 1.15.8.3 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.15.8.2 20-Jun-2002  nathanw Catch up to -current.
 1.15.8.1 17-Nov-2001  scw MD Scheduler Activation bits for Atari.
Compile-tested only.
 1.15.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.15.4.1 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.15.2.1 10-Oct-2001  fvdl Convert all remaining devices.
 1.18.6.4 17-Jan-2005  skrll Adapt to branch.
 1.18.6.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.18.6.2 18-Sep-2004  skrll Sync with HEAD.
 1.18.6.1 03-Aug-2004  skrll Sync with HEAD
 1.19.16.3 21-Jan-2008  yamt sync with head
 1.19.16.2 03-Sep-2007  yamt sync with head.
 1.19.16.1 21-Jun-2006  yamt sync with head.
 1.20.26.1 12-Mar-2007  rmind Sync with HEAD.
 1.20.24.3 02-Jan-2009  jdc Back out changes 1.20.24.1 and 1.20.24.2 (requested by tsutsui in ticket
#1226).
This fix is not required on netbsd-4 branch.
 1.20.24.2 30-Nov-2008  bouyer Apply patch, requested by tsutsui as part of ticket 1226:
fix initial patch from abs to make it build (brelse() takes only one argument
on netbsd-4).
 1.20.24.1 18-Nov-2008  snj Pull up following revision(s) (requested by abs in ticket #1226):
sys/arch/atari/dev/md_root.c: revision 1.26 via patch
Another fix from Tuomo Makinen - Use brelse() to unbusy bp buffer
to allow user to swap floppy disks when prompted.
 1.22.14.1 15-Aug-2007  skrll Sync with HEAD.
 1.22.12.1 07-Aug-2007  matt Sync with HEAD.
 1.22.10.1 03-Oct-2007  garbled Sync with HEAD
 1.22.2.1 19-Aug-2007  ad - Back out the biodone() changes.
- Eliminate B_ERROR (from HEAD).
 1.23.6.2 09-Jan-2008  matt sync with HEAD
 1.23.6.1 06-Nov-2007  matt sync with HEAD
 1.24.8.1 02-Jan-2008  bouyer Sync with HEAD
 1.24.4.1 31-Dec-2007  ad Make compile with new buffer cache locking scheme.

XXX This should be largely MI, please do not make another clone of disksubr.c.
 1.24.2.1 18-Feb-2008  mjf Sync with HEAD.
 1.25.20.3 06-Jan-2009  snj Pull up following revision(s) (requested by tsutsui in ticket #220):
sys/arch/atari/dev/md_root.c: revision 1.28
Fix broken RCS Id.
 1.25.20.2 06-Jan-2009  snj Pull up following revision(s) (requested by tsutsui in ticket #220):
sys/arch/atari/dev/md_root.c: revision 1.27
Clear bp->b_oflags (introduced on vmlocking2 merge) before read
rather than calling brelse(9) after read.
Tested by Tuomo Makinen on port-atari.
Should fix pool panics during installation reported by David Ross
on port-atari:
http://mail-index.NetBSD.org/port-atari/2008/11/13/msg000113.html
and actually close PR port-atari/39850.
 1.25.20.1 06-Nov-2008  snj Pull up following revision(s) (requested by abs in ticket #14):
sys/arch/atari/dev/md_root.c: revision 1.26
Another fix from Tuomo Makinen - Use brelse() to unbusy bp buffer
to allow user to swap floppy disks when prompted.
 1.25.18.2 28-Apr-2009  skrll Sync with HEAD.
 1.25.18.1 19-Jan-2009  skrll Sync with HEAD.
 1.25.16.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.25.10.3 11-Mar-2010  yamt sync with head
 1.25.10.2 18-Jul-2009  yamt sync with head.
 1.25.10.1 04-May-2009  yamt sync with head.
 1.25.6.1 17-Jan-2009  mjf Sync with HEAD.
 1.28.2.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.33.64.1 10-Jun-2019  christos Sync with HEAD
 1.33.62.1 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.33.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.33.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.34.12.1 03-Apr-2021  thorpej Sync with HEAD.
 1.28 26-Jun-2022  tsutsui Make local devsw functions static.

No visible regression on TT030.
 1.27 26-Jun-2022  tsutsui Misc KNF and cleanup for readability.
 1.26 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.25 16-Mar-2014  dholland branches: 1.25.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.24 14-Mar-2009  dsl branches: 1.24.12; 1.24.22; 1.24.26;
ANSIfy another 1261 function definitions.
The only ones left in sys are beyond by sed script!
(or in sys/dist or sys/external)
Mostly they have function pointer parameters.
 1.23 14-Mar-2009  dsl Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.22 14-Mar-2009  dsl Remove all the __P() from sys (excluding sys/dist)
Diff checked with grep and MK1 eyeball.
i386 and amd64 GENERIC and sys still build.
 1.21 17-Jan-2009  tsutsui branches: 1.21.2;
Use firm_gettime() to retain compatibility with old firm_event. From amiga.
 1.20 08-Jan-2008  joerg branches: 1.20.6; 1.20.10; 1.20.18;
Convert Atari to generic TODR and timecounter.
 1.19 17-Oct-2007  garbled branches: 1.19.2; 1.19.8;
Merge the ppcoea-renovation branch to HEAD.

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

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

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.18 11-Jul-2007  he branches: 1.18.10;
Adapt to new signature for callout_init().
 1.17 04-Mar-2007  christos branches: 1.17.2; 1.17.10;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.16 11-Dec-2005  christos branches: 1.16.26;
merge ktrace-lwp.
 1.15 21-Sep-2003  jdolecek branches: 1.15.16;
cleanup & uniform descriptor owner handling:
* introduce fsetown(), fgetown(), fownsignal() - this sets/retrieves/signals
the owner of descriptor, according to appropriate sematics
of TIOCSPGRP/FIOSETOWN/SIOCSPGRP/TIOCGPGRP/FIOGETOWN/SIOCGPGRP ioctl; use
these routines instead of custom code where appropriate
* make every place handling TIOCSPGRP/TIOCGPGRP handle also FIOSETOWN/FIOGETOWN
properly, and remove the translation of FIO[SG]OWN to TIOC[SG]PGRP
in sys_ioctl() & sys_fcntl()
* also remove the socket-specific hack in sys_ioctl()/sys_fcntl() and
pass the ioctls down to soo_ioctl() as any other ioctl

change discussed on tech-kern@
 1.14 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.13 15-Jul-2003  lukem __KERNEL_RCSID()
 1.12 23-Oct-2002  jdolecek branches: 1.12.6;
merge kqueue branch into -current

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

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

based on work done by Jonathan Lemon for FreeBSD
initial NetBSD port done by Luke Mewburn and Jason Thorpe
 1.11 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.10 23-Mar-2000  thorpej branches: 1.10.8; 1.10.12; 1.10.20;
New callout mechanism with two major improvements over the old
timeout()/untimeout() API:
- Clients supply callout handle storage, thus eliminating problems of
resource allocation.
- Insertion and removal of callouts is constant time, important as
this facility is used quite a lot in the kernel.

The old timeout()/untimeout() API has been removed from the kernel.
 1.9 13-Oct-1996  christos branches: 1.9.28;
backout previous kprintf changes
 1.8 11-Oct-1996  christos printf -> kprintf, sprintf -> ksprintf
 1.7 25-Sep-1996  leo Catchup with -current:
- Extra argument to boot()
- select -> poll
 1.6 23-Apr-1996  leo Ignore joystick packages when running in 3b. emulation mode.
 1.5 12-Apr-1996  leo Add 3-button mouse support.
 1.4 12-Apr-1996  leo Add 3-button mouse support.
 1.3 27-Jul-1995  leo Add middle button emulation.
 1.2 26-Jun-1995  leo Fix thinko. It will now also work when no mouse is configured.
 1.1 25-Jun-1995  leo Mouse driver added.
 1.9.28.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.20.1 17-May-2002  gehenna Add device switch.
 1.10.12.2 11-Nov-2002  nathanw Catch up to -current
 1.10.12.1 17-Sep-2002  nathanw Catch up to -current.
 1.10.8.2 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.10.8.1 09-Sep-2001  thorpej Add kqueue support (not yet compiled).
 1.12.6.4 17-Jan-2005  skrll Adapt to branch.
 1.12.6.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.12.6.2 18-Sep-2004  skrll Sync with HEAD.
 1.12.6.1 03-Aug-2004  skrll Sync with HEAD
 1.15.16.3 21-Jan-2008  yamt sync with head
 1.15.16.2 03-Sep-2007  yamt sync with head.
 1.15.16.1 21-Jun-2006  yamt sync with head.
 1.16.26.1 12-Mar-2007  rmind Sync with HEAD.
 1.17.10.1 03-Oct-2007  garbled Sync with HEAD
 1.17.2.1 15-Jul-2007  ad Sync with head.
 1.18.10.2 23-Mar-2008  matt sync with HEAD
 1.18.10.1 06-Nov-2007  matt sync with HEAD
 1.19.8.1 08-Jan-2008  bouyer Sync with HEAD
 1.19.2.1 18-Feb-2008  mjf Sync with HEAD.
 1.20.18.2 28-Apr-2009  skrll Sync with HEAD.
 1.20.18.1 19-Jan-2009  skrll Sync with HEAD.
 1.20.10.1 04-May-2009  yamt sync with head.
 1.20.6.1 17-Jan-2009  mjf Sync with HEAD.
 1.21.2.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.24.26.1 18-May-2014  rmind sync with head
 1.24.22.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.24.12.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.25.2.1 10-Aug-2014  tls Rebase.
 1.5 26-Jun-2022  tsutsui Misc KNF and cleanup for readability.
 1.4 20-Oct-2009  snj Remove 3rd and 4th clause on Leo Weppelman's license. OK leo@.
 1.3 14-Mar-2009  dsl Remove all the __P() from sys (excluding sys/dist)
Diff checked with grep and MK1 eyeball.
i386 and amd64 GENERIC and sys still build.
 1.2 23-Mar-2000  thorpej branches: 1.2.134; 1.2.142; 1.2.148;
New callout mechanism with two major improvements over the old
timeout()/untimeout() API:
- Clients supply callout handle storage, thus eliminating problems of
resource allocation.
- Insertion and removal of callouts is constant time, important as
this facility is used quite a lot in the kernel.

The old timeout()/untimeout() API has been removed from the kernel.
 1.1 12-Apr-1996  leo branches: 1.1.30;
Add 3-button mouse support.
 1.1.30.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.2.148.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.2.142.1 28-Apr-2009  skrll Sync with HEAD.
 1.2.134.2 11-Mar-2010  yamt sync with head
 1.2.134.1 04-May-2009  yamt sync with head.
 1.79 01-Aug-2023  andvar fix various typos in comments.
 1.78 06-Jan-2023  tsutsui TAB/spaces/indents cleanup.
 1.77 07-Apr-2022  andvar fix various typos in comments.
 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 29-Sep-2020  msaitoh branches: 1.74.4;
s/implicitely/implicitly/
 1.73 29-Jun-2019  tsutsui Make local functions static.
 1.72 18-Oct-2014  snj branches: 1.72.20;
src is too big these days to tolerate superfluous apostrophes. It's
"its", people!
 1.71 24-Mar-2014  christos - remove unused
- use cpu_{g,s}etmodel() (not committed yet)
 1.70 27-Oct-2012  chs branches: 1.70.2;
split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.69 05-Jun-2011  tsutsui branches: 1.69.2; 1.69.12;
Split device_t/softc. No crash on TT030.
 1.68 17-Apr-2010  tsutsui branches: 1.68.2; 1.68.6;
extern inline -> static inline
 1.67 13-Apr-2010  tsutsui Misc KNF and cosmetics.
 1.66 28-Feb-2010  snj branches: 1.66.2;
Fight the ever-increasing size of src checkouts by spelling "useful"
without an extra l.
 1.65 20-Oct-2009  snj branches: 1.65.2;
Remove 3rd and 4th clause on Leo Weppelman's license. OK leo@.
 1.64 19-Jul-2009  tsutsui Remove extra whitespace added by a dumb tool which replaced bcopy with memcpy.
 1.63 18-Mar-2009  cegger bcopy -> memcpy
 1.62 18-Mar-2009  cegger bzero -> memset
 1.61 18-Mar-2009  cegger Ansify function definitions w/o arguments. Generated with sed.
 1.60 14-Mar-2009  dsl ANSIfy another 1261 function definitions.
The only ones left in sys are beyond by sed script!
(or in sys/dist or sys/external)
Mostly they have function pointer parameters.
 1.59 14-Mar-2009  dsl Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.58 14-Mar-2009  dsl Remove all the __P() from sys (excluding sys/dist)
Diff checked with grep and MK1 eyeball.
i386 and amd64 GENERIC and sys still build.
 1.57 15-Nov-2008  abs branches: 1.57.4;
To be safe, do not use DMA for Falcon - from Tuomo
 1.56 28-Oct-2008  abs branches: 1.56.2;
Remove unwanted 'xs->xs_status |= XS_STS_DONE' which caused scsipi_done()
to bail out early.
Found by T. Makinen, and additional confirmation by David Ross
 1.55 06-Mar-2007  tsutsui branches: 1.55.40; 1.55.44; 1.55.50; 1.55.52;
Make req_addr (char *) rather than adding an extra cast
since it's used only in this function to calculate buffer address.
 1.54 06-Mar-2007  he More fixes after the caddr_t removal.
Mostly cast to char* for pointer arithmetic,
but also one missing indirection, and one "void *v, x;" fix.
 1.53 04-Mar-2007  christos Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.52 25-Feb-2006  wiz branches: 1.52.18; 1.52.20; 1.52.28;
Fix some typos.
 1.51 24-Dec-2005  perry branches: 1.51.2; 1.51.4; 1.51.6;
__asm__ -> __asm
__const__ -> const
__inline__ -> inline
__volatile__ -> volatile
 1.50 11-Dec-2005  christos merge ktrace-lwp.
 1.49 04-Jun-2005  he branches: 1.49.2;
Adapt to compiling with -Wshadow and -Wcast-qual, by adding const
qualification in places and renaming a few local variables.
Also adds a couple uses of __UNVOLATILE() to allow passing volatile
variables to functions wanting e.g. caddr_t.
 1.48 21-Feb-2005  thorpej Part 1 of a cleanup pass over the SCSI subsystem. The aim is to name
everything "scsi_*", since we really are talking about the SCSI command
set, ATAPI transport not withstanding. Improve the names of many structures,
and prepend "SCSI_" onto all SCSI command opcodes. Place items described
by the SCSI Primary Commands document into scsi_spc.h.
 1.47 07-Dec-2004  thorpej branches: 1.47.2; 1.47.4;
- Use the cmdlen specified in the scsipi_xfer structure. Keying off
the command group ID won't necessarily work for vendor-specific commands.
- Expand the storage in the SC_REQ structure to account for 16-byte commands.
 1.46 15-Jul-2003  lukem __KERNEL_RCSID()
 1.45 03-May-2003  wiz branches: 1.45.2;
DMA, not dma nor Dma.
 1.44 01-Apr-2003  thorpej Use PAGE_SIZE rather than NBPG.
 1.43 02-Oct-2002  thorpej Use CFATTACH_DECL().
 1.42 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.41 27-Sep-2002  provos remove trailing \n in panic(). approved perry.
 1.40 25-Apr-2001  bouyer branches: 1.40.2; 1.40.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.39 28-Jul-2000  tv branches: 1.39.2;
Eliminate the other %:, using vsnprintf followed by printf.
 1.38 28-Jul-2000  tv Avoid a nonstandard %: format: printf("%:", fmt, ap) -> vprintf(fmt, ap)
 1.37 30-Sep-1999  thorpej branches: 1.37.2;
Update for SCSIPI changes.
 1.36 19-Feb-1999  leo Fix type lossage reported by Julian Coleman.
 1.35 05-Dec-1998  mjacob Update HBAs to incorporate the new max_lun property.
 1.34 19-Nov-1998  thorpej Adapt to the new scsipi_adapter interface.
 1.33 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.32 06-Oct-1998  leo Only return COMPLETE when polling.
 1.31 12-Jan-1998  thorpej Update for changes to config.
 1.30 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.29 20-Dec-1996  leo branches: 1.29.8; 1.29.10;
Get rid of BROKEN_INDIRECT_CONFIG
 1.28 10-Dec-1996  thorpej Fill in sc_link.max_target
 1.27 17-Nov-1996  leo Make splbio really splbio. All holes now seem to be plugged. At least
on the Hades & TT030.
 1.26 13-Oct-1996  christos backout previous kprintf changes
 1.25 11-Oct-1996  christos printf -> kprintf, sprintf -> ksprintf
 1.24 16-Sep-1996  leo Add support for Hades platform.
 1.23 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.22 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.21 05-Jul-1996  leo During a rather lengthy debug session with Markus Kilbinger (Thanks again!),
we managed to kill the following SCSI-driver bugs for the Falcon:
- The Byte_Count_zero bit of the falcon DMA controller does not always
tell the truth! This caused the SCSI-driver to choke on devices that
disconnected in the middle of a DMA-transfer (mostly removables).
- Printing debug info about the 5380 on the Falcon is *only* permitted
when DMA is not active.
- Some functions forgot to remove possibly pending sofware interrupts
- Some debug options didn't allow debugging a single target while they
could easily be made to do so. This is fixed.
 1.20 15-May-1996  leo branches: 1.20.4;
Get in sync with the mac68k version of the 5380 driver. Also increase
the maximum values of wait_req_xx() functions so some old (slow) scsi-1 drives
will work.
 1.19 26-Apr-1996  leo - Fixup the ipending function for the Falcon. This seemed to be the source
of a lot of instability problems on the Falcon. I also enabled DMA on
interrupt basis for the Falcon.
- Try to handle targets that request too much data more sanely.
- Some fixups for strict prototypes + -Wall

Thanks to Markus Kilbinger for providing the debugging support.
 1.18 30-Mar-1996  christos Change %r -> %: as for recursive printf's
 1.17 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.16 22-Feb-1996  leo A bit of reshuffling. Also some stricter prototyping.
 1.15 10-Feb-1996  leo Various small fixes.
 1.14 06-Jan-1996  leo Keep more debugging history (Paul Goyette). Synced with mac68k version.
 1.13 18-Dec-1995  leo Fixes for devices that don't support linked commands. (Paul Goyette)
 1.12 30-Nov-1995  jtc merge in changes from 1.1 release branch
 1.11 08-Oct-1995  leo branches: 1.11.2;
- Cleanup the arbitration
- Make sure the MON_BUSY flag is cleared after a DMA transfer. Otherwise
we might end up with a 'lost-busy' situation unexpectedly. This will
prevent the 5380 from driving the bus, which is not funny during
reselections.
 1.10 05-Oct-1995  leo Get in sync with the mac68k version to incorporate Allen Briggs' changes
- emit MSG_ABORT/MSG_REJECT at the right times:
- make MIN_PHYS machine dependent.
 1.9 16-Sep-1995  leo - Handle devices that do not support identify messages (Allen Briggs)
- Add pdma_ready() hook (Allen Briggs)
- Increase timeout to 1000 (Matthias Pfaller)
 1.8 12-Sep-1995  leo - Fix a timing bug in the loop, that was introduced in the previous version.
- Added some code to reject unsupported messages correctly.
 1.7 05-Sep-1995  leo Fix possibly endless loop (mycroft) and add fix requested by Allen Briggs.
 1.6 19-Aug-1995  leo - Add 'restbyte' handling for TT.
- Don't _ever_ do DMA for less than 512 bytes on the Falcon
- Fix bug in autosense-handling. Now asks for the correct number of bytes.
Now it won't read ghost bytes on the tape anymore.
- Add missing braces as suggested by Matthias Pfaller
- Make it possible to debug requests on a specified number of targets
- Add debug option to show only transaction with error code != 0
 1.5 12-Aug-1995  mycroft minphys() functions really should return void.
 1.4 11-Aug-1995  leo New version of NCR5380-SCSI driver. This version is far more generic than
the previous version. The machine dependent part contains the configuration
for both the TT and FALCON. The configuration files have been changed to
select SCSI-support for either TT, Falcon or both.
The configuration file for the Atari-Falcon will only get _really_ usefull
when the Falcon video part is finished.
 1.3 24-Jul-1995  cgd update SCSI minphys routines' definitions to match standard minphys()
definition and usage.
 1.2 28-Apr-1995  leo Made no_ttram_dma patchable instead of a define.
 1.1 26-Mar-1995  leo branches: 1.1.1;
Initial revision
 1.1.1.1 26-Mar-1995  leo NetBSD/Atari, port by Leo Weppelman.
 1.11.2.3 01-Nov-1995  leo Sync with Allen's version.
 1.11.2.2 27-Oct-1995  leo - Fix linked commands
- Fix reselection timeout procedure
 1.11.2.1 19-Oct-1995  leo '#ifdef notyet' the reselection timeout code in reselect(). This piece
of code causes problems on the mac/pc532 . Should be looked after.
 1.20.4.1 20-Jul-1996  jtc Pulled up from rev 1.21 by request from Leo Weppelman
 1.29.10.1 27-Aug-1997  thorpej Update marc-pcmcia branch from trunk.
 1.29.8.1 01-Jul-1997  bouyer Updates for new scsipi subsystem. Actally known to work on i386 and sparc.
 1.37.2.3 29-Mar-2001  bouyer Pass a compile test on i386
 1.37.2.2 27-Mar-2001  bouyer Convert to thorpej_scsipi (untested).
 1.37.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.39.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.40.8.2 18-Oct-2002  nathanw Catch up to -current.
 1.40.8.1 25-Apr-2001  nathanw file ncr5380.c was added on branch nathanw_sa on 2002-10-18 02:35:55 +0000
 1.40.2.1 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.45.2.6 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.45.2.5 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 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.47.4.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.47.2.1 29-Apr-2005  kent sync with -current
 1.49.2.2 03-Sep-2007  yamt sync with head.
 1.49.2.1 21-Jun-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.51.2.1 01-Mar-2006  yamt sync with head.
 1.52.28.1 06-Nov-2008  snj Pull up following revision(s) (requested by abs in ticket #1222):
sys/arch/atari/dev/ncr5380.c: revision 1.56
Remove unwanted 'xs->xs_status |= XS_STS_DONE' which caused scsipi_done()
to bail out early.
Found by T. Makinen, and additional confirmation by David Ross
 1.52.20.1 12-Mar-2007  rmind Sync with HEAD.
 1.52.18.2 15-Jan-2009  bouyer Pull up following revision(s) (requested by tjam in ticket #1261):
sys/arch/atari/dev/ncr5380.c: revision 1.57
To be safe, do not use DMA for Falcon - from Tuomo
 1.52.18.1 06-Nov-2008  snj Pull up following revision(s) (requested by abs in ticket #1222):
sys/arch/atari/dev/ncr5380.c: revision 1.56
Remove unwanted 'xs->xs_status |= XS_STS_DONE' which caused scsipi_done()
to bail out early.
Found by T. Makinen, and additional confirmation by David Ross
 1.55.52.2 28-Apr-2009  skrll Sync with HEAD.
 1.55.52.1 19-Jan-2009  skrll Sync with HEAD.
 1.55.50.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.55.44.4 11-Aug-2010  yamt sync with head.
 1.55.44.3 11-Mar-2010  yamt sync with head
 1.55.44.2 19-Aug-2009  yamt sync with head.
 1.55.44.1 04-May-2009  yamt sync with head.
 1.55.40.1 17-Jan-2009  mjf Sync with HEAD.
 1.56.2.1 16-Jan-2009  bouyer Pull up following revision(s) (requested by tjam in ticket #263):
sys/arch/atari/dev/ncr5380.c: revision 1.57
To be safe, do not use DMA for Falcon - from Tuomo
 1.57.4.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.65.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.66.2.2 12-Jun-2011  rmind sync with head
 1.66.2.1 30-May-2010  rmind sync with head
 1.68.6.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.68.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.69.12.3 03-Dec-2017  jdolecek update from HEAD
 1.69.12.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.69.12.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.69.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.69.2.1 30-Oct-2012  yamt sync with head
 1.70.2.1 18-May-2014  rmind sync with head
 1.72.20.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.74.4.1 21-Mar-2021  thorpej Give config_found() the same variadic arguments treatment as
config_search(). This commit only adds the CFARG_EOL sentinel
to the existing config_found() calls. Conversion of config_found_sm_loc()
and config_found_ia() call sites will be in subsequent commits.
 1.75.8.1 03-Aug-2021  thorpej Adapt to CFARGS().
 1.24 06-Jan-2023  tsutsui TAB/spaces/indents cleanup.
 1.23 05-Jun-2011  tsutsui Split device_t/softc. No crash on TT030.
 1.22 13-Apr-2010  tsutsui branches: 1.22.2; 1.22.6;
Misc KNF and cosmetics.
 1.21 20-Oct-2009  snj branches: 1.21.2; 1.21.4;
Remove 3rd and 4th clause on Leo Weppelman's license. OK leo@.
 1.20 14-Mar-2009  dsl Remove all the __P() from sys (excluding sys/dist)
Diff checked with grep and MK1 eyeball.
i386 and amd64 GENERIC and sys still build.
 1.19 11-Dec-2005  christos branches: 1.19.78; 1.19.86; 1.19.92;
merge ktrace-lwp.
 1.18 04-Jun-2005  he Adapt to compiling with -Wshadow and -Wcast-qual, by adding const
qualification in places and renaming a few local variables.
Also adds a couple uses of __UNVOLATILE() to allow passing volatile
variables to functions wanting e.g. caddr_t.
 1.17 07-Dec-2004  thorpej - Use the cmdlen specified in the scsipi_xfer structure. Keying off
the command group ID won't necessarily work for vendor-specific commands.
- Expand the storage in the SC_REQ structure to account for 16-byte commands.
 1.16 03-May-2003  wiz branches: 1.16.2;
DMA, not dma nor Dma.
 1.15 09-Apr-2003  thorpej Use PAGE_SIZE rather than NBPG.
 1.14 25-Apr-2001  bouyer branches: 1.14.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.13 19-Nov-1998  thorpej branches: 1.13.10; 1.13.22;
Adapt to the new scsipi_adapter interface.
 1.12 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.11 05-Jul-1996  leo branches: 1.11.8; 1.11.10;
During a rather lengthy debug session with Markus Kilbinger (Thanks again!),
we managed to kill the following SCSI-driver bugs for the Falcon:
- The Byte_Count_zero bit of the falcon DMA controller does not always
tell the truth! This caused the SCSI-driver to choke on devices that
disconnected in the middle of a DMA-transfer (mostly removables).
- Printing debug info about the 5380 on the Falcon is *only* permitted
when DMA is not active.
- Some functions forgot to remove possibly pending sofware interrupts
- Some debug options didn't allow debugging a single target while they
could easily be made to do so. This is fixed.
 1.10 15-May-1996  leo branches: 1.10.4;
Get in sync with the mac68k version of the 5380 driver. Also increase
the maximum values of wait_req_xx() functions so some old (slow) scsi-1 drives
will work.
 1.9 08-Mar-1996  leo Just prototyping.
 1.8 22-Feb-1996  leo A bit of reshuffling. Also some stricter prototyping.
 1.7 10-Feb-1996  leo Various small fixes.
 1.6 18-Dec-1995  leo Fixes for devices that don't support linked commands. (Paul Goyette)
 1.5 05-Oct-1995  leo Get in sync with the mac68k version to incorporate Allen Briggs' changes
- emit MSG_ABORT/MSG_REJECT at the right times:
- make MIN_PHYS machine dependent.
 1.4 16-Sep-1995  leo - Handle devices that do not support identify messages (Allen Briggs)
- Add pdma_ready() hook (Allen Briggs)
- Increase timeout to 1000 (Matthias Pfaller)
 1.3 12-Sep-1995  leo - Fix a timing bug in the loop, that was introduced in the previous version.
- Added some code to reject unsupported messages correctly.
 1.2 11-Aug-1995  leo New version of NCR5380-SCSI driver. This version is far more generic than
the previous version. The machine dependent part contains the configuration
for both the TT and FALCON. The configuration files have been changed to
select SCSI-support for either TT, Falcon or both.
The configuration file for the Atari-Falcon will only get _really_ usefull
when the Falcon video part is finished.
 1.1 26-Mar-1995  leo branches: 1.1.1;
Initial revision
 1.1.1.1 26-Mar-1995  leo NetBSD/Atari, port by Leo Weppelman.
 1.10.4.1 20-Jul-1996  jtc Pulled up from rev 1.11 by request from Leo Weppelman
 1.11.10.1 27-Aug-1997  thorpej Update marc-pcmcia branch from trunk.
 1.11.8.1 01-Jul-1997  bouyer Updates for new scsipi subsystem. Actally known to work on i386 and sparc.
 1.13.22.1 21-Jun-2001  nathanw Catch up to -current.
 1.13.10.1 27-Mar-2001  bouyer Convert to thorpej_scsipi (untested).
 1.14.8.2 25-Apr-2001  bouyer Pull up the thorpej_scsipi branch to main branch.
This is a completely rewritten scsipi_xfer execution engine, and the
associated changes to HBA drivers. Overview of changes & features:
- All xfers are queued in the mid-layer, rather than doing so in an
ad-hoc fashion in individual adapter drivers.
- Adapter/channel resource management in the mid-layer, avoids even trying
to start running an xfer if the adapter/channel doesn't have the resources.
- Better communication between the mid-layer and the adapters.
- Asynchronous event notification mechanism from adapter to mid-layer and
peripherals.
- Better peripheral queue management: freeze/thaw, sorted requeueing during
recovery, etc.
- Clean separation of peripherals, adapters, and adapter channels (no more
scsipi_link).
- Kernel thread for each scsipi_channel makes error recovery much easier
(no more dealing with interrupt context when recovering from an error).
- Mid-layer support for tagged queueing: commands can have the tag type
set explicitly, tag IDs are allocated in the mid-layer (thus eliminating
the need to use buggy tag ID allocation schemes in many adapter drivers).
- support for QUEUE FULL and CHECK CONDITION status in mid-layer; the command
will be requeued, or a REQUEST SENSE will be sent as appropriate.

Just before the merge syssrc has been tagged with thorpej_scsipi_beforemerge
 1.14.8.1 25-Apr-2001  bouyer file ncr5380reg.h was added on branch nathanw_sa on 2001-04-25 17:53:14 +0000
 1.16.2.2 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.16.2.1 18-Dec-2004  skrll Sync with HEAD.
 1.19.92.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.19.86.1 28-Apr-2009  skrll Sync with HEAD.
 1.19.78.3 11-Aug-2010  yamt sync with head.
 1.19.78.2 11-Mar-2010  yamt sync with head
 1.19.78.1 04-May-2009  yamt sync with head.
 1.21.4.2 12-Jun-2011  rmind sync with head
 1.21.4.1 30-May-2010  rmind sync with head
 1.21.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.22.6.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.22.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.10 07-Aug-2023  mrg fix indentation issues.

found by GCC 12.
 1.9 06-Jan-2023  tsutsui TAB/spaces/indents cleanup.
 1.8 13-Apr-2010  tsutsui Misc KNF and cosmetics.
 1.7 20-Oct-2009  snj branches: 1.7.2; 1.7.4;
Remove 3rd and 4th clause on Leo Weppelman's license. OK leo@.
 1.6 11-Dec-2005  christos branches: 1.6.78;
merge ktrace-lwp.
 1.5 04-Jun-2005  he Adapt to compiling with -Wshadow and -Wcast-qual, by adding const
qualification in places and renaming a few local variables.
Also adds a couple uses of __UNVOLATILE() to allow passing volatile
variables to functions wanting e.g. caddr_t.
 1.4 13-Oct-1996  christos branches: 1.4.62;
backout previous kprintf changes
 1.3 11-Oct-1996  christos printf -> kprintf, sprintf -> ksprintf
 1.2 15-May-1996  leo Get in sync with the mac68k version of the 5380 driver. Also increase
the maximum values of wait_req_xx() functions so some old (slow) scsi-1 drives
will work.
 1.1 22-Feb-1996  leo A bit of reshuffling. Also some stricter prototyping.
 1.4.62.1 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.6.78.2 11-Aug-2010  yamt sync with head.
 1.6.78.1 11-Mar-2010  yamt sync with head
 1.7.4.1 30-May-2010  rmind sync with head
 1.7.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.23 06-Jan-2023  tsutsui TAB/spaces/indents cleanup.
 1.22 02-Jul-2022  tsutsui Use aprint_*(9) for attach messages and misc KNF.
 1.21 20-Jan-2018  tsutsui Skip NVRAM checksum check and re-initialization on Milan.

Milan's firmware seems to use different check method.
 1.20 06-Mar-2015  christos branches: 1.20.10;
rename NV_DEBUG to NVRAM_DEBUG
 1.19 05-Jun-2011  tsutsui branches: 1.19.12; 1.19.30;
Split device_t/softc. No crash on TT030.
 1.18 13-Apr-2010  tsutsui branches: 1.18.2; 1.18.6;
Include "ioconf.h" to declare struct cfdriver foo_cd.
 1.17 20-Oct-2009  snj branches: 1.17.2; 1.17.4;
Remove 3rd and 4th clause on Leo Weppelman's license. OK leo@.
 1.16 18-Mar-2009  cegger Ansify function definitions w/o arguments. Generated with sed.
 1.15 14-Mar-2009  dsl Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.14 14-Mar-2009  dsl Remove all the __P() from sys (excluding sys/dist)
Diff checked with grep and MK1 eyeball.
i386 and amd64 GENERIC and sys still build.
 1.13 13-Jun-2008  cegger branches: 1.13.4; 1.13.10;
use device_lookup_private to get softc
 1.12 11-Jun-2008  tsutsui Use device_private() and device_lookup_privat() to get softc.
 1.11 11-Dec-2005  christos branches: 1.11.74; 1.11.76; 1.11.78; 1.11.80; 1.11.82;
merge ktrace-lwp.
 1.10 15-Jul-2003  lukem __KERNEL_RCSID()
 1.9 02-Oct-2002  thorpej branches: 1.9.6;
Use CFATTACH_DECL().
 1.8 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.7 12-Jan-1998  thorpej branches: 1.7.28; 1.7.32;
Update for changes to config.
 1.6 20-Dec-1996  leo Get rid of BROKEN_INDIRECT_CONFIG
 1.5 13-Oct-1996  christos backout previous kprintf changes
 1.4 11-Oct-1996  christos printf -> kprintf, sprintf -> ksprintf
 1.3 18-Apr-1996  leo Yet more prototyping and -Wall fixes.
 1.2 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.1 06-Jan-1996  leo Add an nvram-driver. This driver makes it possible to read/write the
configuration info stored in the nvram on the mc146818.
 1.7.32.1 18-Oct-2002  nathanw Catch up to -current.
 1.7.28.1 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.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.82.1 18-Jun-2008  simonb Sync with head.
 1.11.80.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.11.78.3 11-Aug-2010  yamt sync with head.
 1.11.78.2 11-Mar-2010  yamt sync with head
 1.11.78.1 04-May-2009  yamt sync with head.
 1.11.76.1 17-Jun-2008  yamt sync with head.
 1.11.74.1 29-Jun-2008  mjf Sync with HEAD.
 1.13.10.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.13.4.1 28-Apr-2009  skrll Sync with HEAD.
 1.17.4.2 12-Jun-2011  rmind sync with head
 1.17.4.1 30-May-2010  rmind sync with head
 1.17.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.18.6.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.18.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.19.30.1 06-Apr-2015  skrll Sync with HEAD
 1.19.12.1 03-Dec-2017  jdolecek update from HEAD
 1.20.10.1 13-Mar-2018  martin Pull up following revision(s) (requested by tsutsui in ticket #624):
sys/arch/atari/stand/xxboot/sdboot/milan/Makefile: revision 1.4
sys/arch/atari/dev/nvram.c: revision 1.21
sys/arch/atari/conf/MILAN.in: revision 1.28
sys/arch/atari/atari/pmap_bootstrap.c: revision 1.9
sys/dev/isa/fd.c: revision 1.111
sys/arch/atari/atari/bus.c: revision 1.60
sys/arch/atari/stand/xxboot/ahdi-xxboot/milan/Makefile: revision 1.4
sys/arch/atari/atari/locore.s: revision 1.111
sys/arch/atari/isa/isa_machdep.c: revision 1.41
distrib/sets/lists/base/md.atari: revision 1.55
sys/arch/atari/pci/pci_machdep.c: revision 1.55
sys/arch/atari/pci/pci_machdep.c: revision 1.56
sys/arch/atari/include/vmparam.h: revision 1.32
sys/arch/atari/isa/isa_milan.c: revision 1.15
sys/arch/atari/isa/isa_milan.c: revision 1.16
sys/arch/atari/atari/bus.c: revision 1.59
sys/arch/atari/atari/atari_init.c: revision 1.101
sys/arch/atari/pci/pci_milan.c: revision 1.15
Fix I/O access failures for regions allocated by bus_space_map(9) on Milan.

Passing to PMAP_WIRED against I/O spaces seems problematic,
probably after yamt-km branch merge, which was committed
between NetBSD 3.0 and NetBSD 4.0.
(i.e. ISA and PCI devices on Milan didn't work after 4.0 release)

XXX:
According to pmap(9) man page, the "flags" arg for pmap_enter(9)
doesn't take VM_PROT_READ and VM_PROT_WRITE, but pmap_enter()
implementation in sys/arch/m68k/m68k/pmap_motolora.c historically
checks them.

Fix silent hang during config_console() (before consinit()) on Milan.
config_console() was a dirty hack used by ancient m68k ports
to probe and initialize console devices before "real" configure(9),
using subset of configure(9) functions.

In that case, most device specific data (except I/O access method)
are not initialized so we must not access device specific device_t and
softc structures in config_console() cases.

Fix silent hang after isa_intr_establish() on Milan.
The problems (wrong macro replacements) were slipped in rev 1.107:
http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/arch/atari/atari/locore.s#rev1.107
Handle yet another atari specific quirk in the MI ISA fdc(4)/fd(4) driver.
This makes fd(4) drive(s) (which is necessary for installation)
properly attached on Milan.
atari uses "fdcisa" and "fdisa" for ISA fdc to co-exist other fd(4)
drivers, on-board (atari/dev/fd.c) one and Hades (atari/dev/hdfd.c) one.

Use a proper PSL value to be passed to splx(9) functions.
This should have been changed on yamt-splraiseipl branch merge
back in 2006, which made MI IPL_xxx values independent from
m68k MD PSL values for the %sr register.

Restore piixide(4) for Milan and disable other pciide devices.
piixide was removed in rev 1.18 and the log message said
"because Intel IDE disk controllers only exist as part of
Intel chipsets for x86 systems" but the Milan actually has
the Intel 82371FB southbridge on its board.
Other pciide devices are unlikely necessary for the default
kernel for such a rare machine.
Also fix pasto in comment.

Skip NVRAM checksum check and re-initialization on Milan.
Milan's firmware seems to use different check method.

Ack EOI for IRQ_SLAVE of the master PIC after ack for IRQ of the slave PIC.
I'm not sure if there are possible races in the original code, but
this is what i8259_asm_ack2() in sys/arch/x86/include/i8259.h does
and it looks this change makes a Milan kernel a bit stable.
Replace CRTC register values with ones taken from sys/dev/ic/vga_subr.c.
This fixes noise around column 3 and 4 and makes screen output clearer
on Milan with S3 Trio64V.

Explicitly setup the secondary IDE interrupt of PIIX on Milan.
The secondary IDE interrupt is connected to MBIRQ0 on PIIX, but
the Milan's ROM bootloader (at least version 0.99.7) doesn't seem
to setup the MBIRQ0 register to route it to IRQ15.

On Milan, also explicitly disable MBIRQ1 on PIIX.
Milan's ROM bootloader v1.2 and v1.4 incorrectly set MBIRQ0 connected
to the secondary IDE to IRQ14 (not 15) and unused MBIRQ1 to IRQ15,
so both IDE channels don't work properly.

Add dumb memory probe routines for Milan to use all available memory.
Tested on Milan with 32Mx1, 32Mx4, 128MBx1, and 128MBx3.
(bootloader ROM fails to load TOS with 128MBx4)
No particular comment on port-atari@:
http://mail-index.netbsd.org/port-atari/2018/02/09/msg000580.html

Provide wdboot as a copy of sdboot for Milan.
It looks Milan's bootloader ROM emulates IDE disks as SCSI disks
so sdboot works for them, but atari's installboot checks a specified
device name and requires wdboot for wd(4) devices.

Fix another possible out of bounds.

Replace bus_dmamap_sync(9) op with a newer one taken from m68k/bus_dma.c.
This could fix memory corruption issue caused by PREREAD ops with regions
whose boundaries are not aligned at cacheline size.
 1.5 02-Jul-2022  tsutsui Use aprint_*(9) for attach messages and misc KNF.
 1.4 05-Jun-2011  tsutsui Split device_t/softc. No crash on TT030.
 1.3 20-Oct-2009  snj branches: 1.3.4; 1.3.6; 1.3.10;
Remove 3rd and 4th clause on Leo Weppelman's license. OK leo@.
 1.2 14-Mar-2009  dsl Remove all the __P() from sys (excluding sys/dist)
Diff checked with grep and MK1 eyeball.
i386 and amd64 GENERIC and sys still build.
 1.1 06-Jan-1996  leo branches: 1.1.170; 1.1.178; 1.1.184;
Add an nvram-driver. This driver makes it possible to read/write the
configuration info stored in the nvram on the mc146818.
 1.1.184.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.1.178.1 28-Apr-2009  skrll Sync with HEAD.
 1.1.170.2 11-Mar-2010  yamt sync with head
 1.1.170.1 04-May-2009  yamt sync with head.
 1.3.10.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.3.6.1 06-Jun-2011  jruoho Sync with HEAD.
 1.3.4.1 12-Jun-2011  rmind sync with head
 1.7 14-Mar-1996  leo Switch to the mi ramdisk driver.
 1.6 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.5 12-Aug-1995  mycroft minphys() functions really should return void.
 1.4 24-Jul-1995  cgd update SCSI minphys routines' definitions to match standard minphys()
definition and usage.
 1.3 12-Jul-1995  leo Update raw-io functions as suggested by Charles.
 1.2 16-Apr-1995  leo Get RAMD_NDEV in sync with definitions in rd_info.
 1.1 26-Mar-1995  leo branches: 1.1.1;
Initial revision
 1.1.1.1 26-Mar-1995  leo NetBSD/Atari, port by Leo Weppelman.
 1.10 28-Dec-1996  pk rename: ramdisk => md
 1.9 20-Dec-1996  leo Get rid of BROKEN_INDIRECT_CONFIG
 1.8 08-Nov-1996  leo Adapt to the change in the floppy minor-number sceme.
 1.7 13-Oct-1996  christos backout previous kprintf changes
 1.6 11-Oct-1996  christos printf -> kprintf, sprintf -> ksprintf
 1.5 16-Sep-1996  leo atari_realconfig now defined in <atari/device.h>
 1.4 26-Apr-1996  leo Corrections for removed <sys/cpu.h> and some more prototypes.
 1.3 18-Apr-1996  leo Yet more prototyping and -Wall fixes.
 1.2 27-Mar-1996  leo Remove rd_match_hook().
 1.1 14-Mar-1996  leo Switch to the mi ramdisk driver.
 1.60 18-Aug-2025  andvar Fix various typos, mainly in comments:
s/invaid/invalid/
s/instad/instead/
s/wich/with/
s/tranform/transform/
s/tranmist/transmit/
s/tranceiver/transceiver/
s/Tranparent/Transparent/
s/tranlated/translated/
s/tranfer/transfer/
s/tranmissions/transmissions/
s/condtions/conditions/
s/Recient/Recent/
 1.59 30-Aug-2023  andvar atari/ser(4): constify "char *str" serstatus() argument to fix SER_DEBUG build.
 1.58 06-Jan-2023  tsutsui TAB/spaces/indents cleanup.
 1.57 26-Jun-2022  tsutsui Make local devsw functions static.

No visible regression on TT030.
 1.56 15-Nov-2014  christos centralize the call unit / dialout macros
 1.55 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.54 24-Mar-2014  christos branches: 1.54.2;
- remove unused
- use cpu_{g,s}etmodel() (not committed yet)
 1.53 16-Mar-2014  dholland 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 24-Apr-2011  rmind branches: 1.52.4; 1.52.14; 1.52.18;
Rename ttymalloc() to tty_alloc(), and ttyfree() to tty_free() for
consistency. Remove some unnecessary malloc.h inclusions as well.
 1.51 10-Apr-2010  tsutsui branches: 1.51.2;
Make local functions static.
 1.50 09-Apr-2010  tsutsui minor constify
 1.49 09-Apr-2010  tsutsui Make options SERCONSOLE (force serial console if DCD is detected)
patchable by binpatch(8) like:
---
# binpatch -s serconsole -r 0 /netbsd
serconsole(0x23bac4): 0x00000001 (1), at offset 0x23bb44 in /netbsd
new value: 0x00000000 (0)
#
---

May work around PR port-atari/39849
(netbsd-ATARITT kernel fails with serial port connected)
and some old TT030 with early revision boards.
 1.48 09-Apr-2010  tsutsui - split device_t/softc
- verbose output on attach as well as zs serial ports
 1.47 09-Apr-2010  tsutsui Include ioconf.h for struct cfdriver.
 1.46 09-Apr-2010  tsutsui Misc KNF.
 1.45 23-Nov-2009  rmind branches: 1.45.2; 1.45.4;
Use lwp_getpcb() on m68k ports, clean from struct user usage.
 1.44 08-Jul-2009  tsutsui Merge local <atari/atari/intr.h> into common <machine/intr.h>.
 1.43 03-Jul-2009  tsutsui Replace traditional MD si_callback() with MI softint(9).
 1.42 14-Mar-2009  dsl ANSIfy another 1261 function definitions.
The only ones left in sys are beyond by sed script!
(or in sys/dist or sys/external)
Mostly they have function pointer parameters.
 1.41 14-Mar-2009  dsl Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.40 14-Mar-2009  dsl Remove all the __P() from sys (excluding sys/dist)
Diff checked with grep and MK1 eyeball.
i386 and amd64 GENERIC and sys still build.
 1.39 11-Jun-2008  tsutsui branches: 1.39.4; 1.39.6; 1.39.10;
Use device_private() and device_lookup_privat() to get softc.
 1.38 28-Apr-2008  martin branches: 1.38.2; 1.38.4;
Remove clause 3 and 4 from TNF licenses
 1.37 03-Dec-2007  ad branches: 1.37.14; 1.37.16; 1.37.18;
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.36 19-Nov-2007  ad - Factor out too many copies of the same bit of tty code.
- Fix another tty signalling/wakeup problem.
 1.35 17-Oct-2007  garbled branches: 1.35.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.34 09-Jul-2007  ad branches: 1.34.8; 1.34.10; 1.34.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.33 04-Mar-2007  christos branches: 1.33.2; 1.33.4; 1.33.10;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.32 01-Oct-2006  elad branches: 1.32.4;
More from Matt Fleming:

Adapt to KAUTH_DEVICE_TTY_PRIVSET and KAUTH_DEVICE_TTY_OPEN.
 1.31 01-Oct-2006  elad Adapt MD code to KAUTH_DEVICE_TTY_OPEN. Patch from Matt Fleming, thanks!
 1.30 23-Jul-2006  ad branches: 1.30.4; 1.30.6;
Use the LWP cached credentials where sane.
 1.29 14-May-2006  elad integrate kauth.
 1.28 06-Mar-2006  he branches: 1.28.2; 1.28.4;
Remove another instance of the macro triplet SET/CLR/ISSET, now
found in <sys/types.h>.
 1.27 11-Dec-2005  christos branches: 1.27.4; 1.27.6; 1.27.8;
merge ktrace-lwp.
 1.26 06-Sep-2005  kleink Change the driver open function's conditional for overriding exclusive tty
use from checking the proc's uid to suser(9), and account for the use of
privileges. Noted by David Holland in PR kern/31126.
 1.25 04-Jun-2005  he branches: 1.25.2;
Remove the unused global variable "baud" because it is causing
shadowing warnings.
 1.24 11-Feb-2005  simonb White space nit- don't put a space before/after increment/decrement
operators.
 1.23 07-Aug-2003  agc branches: 1.23.8; 1.23.10;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.22 15-Jul-2003  lukem __KERNEL_RCSID()
 1.21 23-Oct-2002  jdolecek branches: 1.21.6;
merge kqueue branch into -current

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

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

based on work done by Jonathan Lemon for FreeBSD
initial NetBSD port done by Luke Mewburn and Jason Thorpe
 1.20 02-Oct-2002  thorpej Use CFATTACH_DECL().
 1.19 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.18 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.17 29-Aug-2002  leo defopt SERCONSOLE
 1.16 30-May-2002  thorpej Don't include params on macro when #undef'ing it.
 1.15 17-Mar-2002  atatat branches: 1.15.4; 1.15.6;
Convert ioctl code to use EPASSTHROUGH instead of -1 or ENOTTY for
indicating an unhandled "command". ERESTART is -1, which can lead to
confusion. ERESTART has been moved to -3 and EPASSTHROUGH has been
placed at -4. No ioctl code should now return -1 anywhere. The
ioctl() system call is now properly restartable.
 1.14 02-May-2001  scw branches: 1.14.2; 1.14.4; 1.14.8;
Add `l_poll' to `struct linesw' and provide an xxxpoll() entry point
in each tty driver to indirect through it.

This allows tty line-disciplines to handle poll(2) system calls.
 1.13 11-Apr-2001  leo Adapt these for use on the Milan.
 1.12 02-Nov-2000  eeh branches: 1.12.2;
Adapt to new line discipline scheme.
 1.11 29-Mar-2000  leo Nuke a bunch of cf_unit abuses.
 1.10 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.9 06-Aug-1999  leo branches: 1.9.2;
Change the way that bit's are cleared in the InterruptPending register of
the 68901. Do this now by _assigning_ ~<bit_to_clear> instead of the
previously used 'andb ~<bit_to_clear>'. The latter caused a rwm-cycle that
caused a race condition to happen when an interrupt arrived between the
Read and Modify-Write.
Anyway, this solved my hanging keyboard problem.
 1.8 06-Apr-1999  pk remove duplicate line in copyright.
 1.7 06-Apr-1999  pk Fix garbled word in copyright statement.
 1.6 07-Oct-1998  leo branches: 1.6.6;
Copyright stuff.
 1.5 04-Jul-1998  jonathan defopt DDB.
 1.4 25-Mar-1998  leo Sync with latest tty changes.
 1.3 12-Jan-1998  thorpej Update for changes to config.
 1.2 27-Aug-1997  leo According to Andre Lange, the Hades has the DTR/RTS lines exchanged on
the 68901 UART-port due to a PCB error. Take care of this.
 1.1 25-May-1997  leo branches: 1.1.4;
Add serial driver for 68901 UART (modem1 port).
 1.1.4.1 27-Aug-1997  thorpej Update marc-pcmcia branch from trunk.
 1.6.6.1 07-Apr-1999  pk branches: 1.6.6.1.2;
Pull up from trunk: copyright text warts.
 1.6.6.1.2.1 21-Jun-1999  thorpej Sync w/ -current.
 1.9.2.3 21-Apr-2001  bouyer Sync with HEAD
 1.9.2.2 22-Nov-2000  bouyer Sync with HEAD.
 1.9.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.12.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.14.8.6 11-Nov-2002  nathanw Catch up to -current
 1.14.8.5 18-Oct-2002  nathanw Catch up to -current.
 1.14.8.4 17-Sep-2002  nathanw Catch up to -current.
 1.14.8.3 20-Jun-2002  nathanw Catch up to -current.
 1.14.8.2 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.14.8.1 02-May-2001  nathanw file ser.c was added on branch nathanw_sa on 2002-04-01 07:39:33 +0000
 1.14.4.2 13-Oct-2001  fvdl Revert the t_dev -> t_devvp change in struct tty. The way that tty
structs are currently used (especially by console ttys) aren't
ready for it, and this will require quite a few changes.
 1.14.4.1 10-Oct-2001  fvdl Convert all remaining devices.
 1.14.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.14.2.2 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.14.2.1 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.15.6.1 30-May-2002  tv Pull up revision 1.16 (requested by thorpej in ticket #97):
Don't include params on macro when #undef'ing it.
 1.15.4.3 31-Aug-2002  gehenna catch up with -current.
 1.15.4.2 14-Jul-2002  gehenna catch up with -current.
 1.15.4.1 19-May-2002  gehenna Add device switch.
Replace the access to devsw table and the hard-coded majors with devsw API.
 1.21.6.6 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.21.6.5 15-Feb-2005  skrll Sync with HEAD.
 1.21.6.4 17-Jan-2005  skrll Adapt to branch.
 1.21.6.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.21.6.2 18-Sep-2004  skrll Sync with HEAD.
 1.21.6.1 03-Aug-2004  skrll Sync with HEAD
 1.23.10.1 12-Feb-2005  yamt sync with head.
 1.23.8.1 29-Apr-2005  kent sync with -current
 1.25.2.4 07-Dec-2007  yamt sync with head
 1.25.2.3 03-Sep-2007  yamt sync with head.
 1.25.2.2 30-Dec-2006  yamt sync with head.
 1.25.2.1 21-Jun-2006  yamt sync with head.
 1.27.8.3 11-Aug-2006  yamt sync with head
 1.27.8.2 24-May-2006  yamt sync with head.
 1.27.8.1 13-Mar-2006  yamt sync with head.
 1.27.6.2 01-Jun-2006  kardel Sync with head.
 1.27.6.1 22-Apr-2006  simonb Sync with head.
 1.27.4.1 09-Sep-2006  rpaulo sync with head
 1.28.4.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.28.2.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.28.2.2 10-Mar-2006  elad generic_authorize() -> kauth_authorize_generic().
 1.28.2.1 08-Mar-2006  elad Adapt to kernel authorization KPI.

I expect *some* lossage here...
 1.30.6.1 22-Oct-2006  yamt sync with head
 1.30.4.1 18-Nov-2006  ad Sync with head.
 1.32.4.1 12-Mar-2007  rmind Sync with HEAD.
 1.33.10.1 03-Oct-2007  garbled Sync with HEAD
 1.33.4.1 11-Jul-2007  mjf Sync with head.
 1.33.2.2 03-Dec-2007  ad Sync with HEAD.
 1.33.2.1 15-Jul-2007  ad Sync with head.
 1.34.14.1 21-Nov-2007  bouyer Sync with HEAD
 1.34.10.2 09-Jan-2008  matt sync with HEAD
 1.34.10.1 06-Nov-2007  matt sync with HEAD
 1.34.8.2 09-Dec-2007  jmcneill Sync with HEAD.
 1.34.8.1 21-Nov-2007  joerg Sync with HEAD.
 1.35.2.1 08-Dec-2007  mjf Sync with HEAD.
 1.37.18.5 11-Aug-2010  yamt sync with head.
 1.37.18.4 11-Mar-2010  yamt sync with head
 1.37.18.3 18-Jul-2009  yamt sync with head.
 1.37.18.2 04-May-2009  yamt sync with head.
 1.37.18.1 16-May-2008  yamt sync with head.
 1.37.16.2 17-Jun-2008  yamt sync with head.
 1.37.16.1 18-May-2008  yamt sync with head.
 1.37.14.2 29-Jun-2008  mjf Sync with HEAD.
 1.37.14.1 02-Jun-2008  mjf Sync with HEAD.
 1.38.4.1 18-Jun-2008  simonb Sync with head.
 1.38.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.39.10.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.39.6.1 20-Nov-2010  riz Pull up following revision(s) (requested by tsutsui in ticket #1368):
sys/arch/atari/dev/ser.c: revision 1.49
sys/arch/atari/conf/GENERIC.in: revision 1.86
Make options SERCONSOLE (force serial console if DCD is detected)
patchable by binpatch(8) like:
---
serconsole(0x23bac4): 0x00000001 (1), at offset 0x23bb44 in /netbsd
new value: 0x00000000 (0)
---
May work around PR port-atari/39849
(netbsd-ATARITT kernel fails with serial port connected)
and some old TT030 with early revision boards.
Disable options SERCONSOLE (force serial console if DCD is detected)
because now it's patchable by binpatch(8).
Enabling serial console by DCD signal could be problematic
on some earlier TT030 (with revision A board), and it's also
annoying for users who connect an active device on the serial port
as mentioned in PR port-atari/39849.
XXX: Eventually serial console should be enabled by MD bootloader flags,
XXX: but I have no idea how to build bootloader binaries for TOS.
 1.39.4.1 28-Apr-2009  skrll Sync with HEAD.
 1.45.4.2 31-May-2011  rmind sync with head
 1.45.4.1 30-May-2010  rmind sync with head
 1.45.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.51.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.52.18.1 18-May-2014  rmind sync with head
 1.52.14.2 03-Dec-2017  jdolecek update from HEAD
 1.52.14.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.52.4.1 22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.54.2.1 10-Aug-2014  tls Rebase.
 1.2 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.1 25-May-1997  leo branches: 1.1.158; 1.1.160; 1.1.162;
Add serial driver for 68901 UART (modem1 port).
 1.1.162.1 16-May-2008  yamt sync with head.
 1.1.160.1 18-May-2008  yamt sync with head.
 1.1.158.1 02-Jun-2008  mjf Sync with HEAD.
 1.40 27-Jan-2025  andvar s/probeing/probing/ in comments.
 1.39 26-Mar-2023  andvar branches: 1.39.6;
s/dipslay/display/ in comments.
 1.38 06-Jan-2023  tsutsui TAB/spaces/indents cleanup.
 1.37 26-Jun-2022  tsutsui Make local devsw functions static.

No visible regression on TT030.
 1.36 19-Sep-2021  andvar fix various typos in comments, messages and documentation.
 1.35 20-Aug-2015  christos include "ioconf.h" to get the 'void <driver>attach(int count);' prototype.
 1.34 25-Jul-2014  dholland branches: 1.34.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.33 16-Mar-2014  dholland branches: 1.33.2;
Change (mostly mechanically) every cdevsw/bdevsw I can find to use
designated initializers.

I have not built every extant kernel so I have probably broken at
least one build; however I've also found and fixed some wrong
cdevsw/bdevsw entries so even if so I think we come out ahead.
 1.32 13-Apr-2010  tsutsui branches: 1.32.8; 1.32.18; 1.32.22;
Misc KNF.
 1.31 19-Jul-2009  tsutsui branches: 1.31.2; 1.31.4;
Remove extra whitespace added by a dumb tool which replaced bcopy with memcpy.
 1.30 18-Mar-2009  cegger bcopy -> memcpy
 1.29 18-Mar-2009  cegger Ansify function definitions w/o arguments. Generated with sed.
 1.28 14-Mar-2009  dsl ANSIfy another 1261 function definitions.
The only ones left in sys are beyond by sed script!
(or in sys/dist or sys/external)
Mostly they have function pointer parameters.
 1.27 14-Mar-2009  dsl Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.26 14-Mar-2009  dsl Remove all the __P() from sys (excluding sys/dist)
Diff checked with grep and MK1 eyeball.
i386 and amd64 GENERIC and sys still build.
 1.25 23-Mar-2008  cube branches: 1.25.4; 1.25.12; 1.25.18;
Use M_TEMP for allocations instead of the now deceased M_IOCTLOPS.
 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 11-Dec-2005  christos branches: 1.23.26;
merge ktrace-lwp.
 1.22 15-Jul-2003  lukem branches: 1.22.16;
__KERNEL_RCSID()
 1.21 23-Oct-2002  jdolecek branches: 1.21.6;
merge kqueue branch into -current

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

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

based on work done by Jonathan Lemon for FreeBSD
initial NetBSD port done by Luke Mewburn and Jason Thorpe
 1.20 10-Oct-2002  jdolecek replace the somewhat strange poll routine with standard nopoll() (a.k.a
seltrue())
 1.19 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.18 17-Mar-2002  atatat branches: 1.18.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.17 26-Jun-2000  simonb branches: 1.17.4; 1.17.8;
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 20-Dec-1998  thomas branches: 1.16.8; 1.16.18;
Changed grf mmap that it is closer to XFree. VGA memory on et4000/et6000
is now at offset 0xa0000.
 1.15 25-Apr-1997  leo - Provide the reasonable size that can/may be mmap-ed. This might differ
from the current frame buffer size.
- The et-driver now allows for a 16Kb io-region (was 8Kb) that can be
mapped. The XFree server uses this.
 1.14 10-Jan-1997  leo Allow the control registers to be mapped too.
 1.13 13-Oct-1996  christos backout previous kprintf changes
 1.12 11-Oct-1996  christos printf -> kprintf, sprintf -> ksprintf
 1.11 04-Oct-1996  leo Checkpointing my et4000 work. Note that the et-console will not be
functional until the minimal pci-support is checked in.
 1.10 25-Sep-1996  leo Catchup with -current:
- Extra argument to boot()
- select -> poll
 1.9 16-Sep-1996  leo Prepare for (soon to come) et4000 PCI console.
 1.8 18-Apr-1996  leo Yet more prototyping and -Wall fixes.
 1.7 22-Feb-1996  leo First bunch of changes due to stricter prototype checking.
 1.6 17-Aug-1995  leo Remove 2 wrong proto-types.
 1.5 28-May-1995  leo Remove the pointer to view_t from the grf-structure, use viewview(dev)
to obtain the pointer instead. This removes a kernel-crash that happened
when something was written to the console while the console was being
resized.
 1.4 21-May-1995  leo ite_newsize(): Do not reallocate a display when the actual display mode
will be the same. Fixes a nasty bug where ite0 and ite1 share the same
bitmap.
 1.3 10-Apr-1995  mycroft map --> mmap
 1.2 28-Mar-1995  leo Make ite ioctl work and fixup the colormap stuff.
 1.1 26-Mar-1995  leo branches: 1.1.1;
Initial revision
 1.1.1.1 26-Mar-1995  leo NetBSD/Atari, port by Leo Weppelman.
 1.16.18.1 30-Jun-2000  simonb Pull up mmap paddr_t/off_t changes from trunk.
 1.16.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.17.8.4 11-Nov-2002  nathanw Catch up to -current
 1.17.8.3 18-Oct-2002  nathanw Catch up to -current.
 1.17.8.2 17-Sep-2002  nathanw Catch up to -current.
 1.17.8.1 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.17.4.5 10-Oct-2002  jdolecek use nokqfilter (or seltrue_kqfilter()) for drivers which provide poll
routine very similar to seltrue(); the poll routines would be cleaned
up on trunk
 1.17.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.17.4.3 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.17.4.2 17-Jun-2002  jdolecek make compilable - use cdev_decl(), and remove unnecessary prototypes
from headers
 1.17.4.1 12-Sep-2001  thorpej Add noop kqueue entry points.
 1.18.4.1 17-May-2002  gehenna Add device switch.
 1.21.6.4 17-Jan-2005  skrll Adapt to branch.
 1.21.6.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.21.6.2 18-Sep-2004  skrll Sync with HEAD.
 1.21.6.1 03-Aug-2004  skrll Sync with HEAD
 1.22.16.3 24-Mar-2008  yamt sync with head.
 1.22.16.2 03-Sep-2007  yamt sync with head.
 1.22.16.1 21-Jun-2006  yamt sync with head.
 1.23.26.1 12-Mar-2007  rmind Sync with HEAD.
 1.24.40.1 03-Apr-2008  mjf Sync with HEAD.
 1.25.18.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.25.12.1 28-Apr-2009  skrll Sync with HEAD.
 1.25.4.3 11-Aug-2010  yamt sync with head.
 1.25.4.2 19-Aug-2009  yamt sync with head.
 1.25.4.1 04-May-2009  yamt sync with head.
 1.31.4.1 30-May-2010  rmind sync with head
 1.31.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.32.22.1 18-May-2014  rmind sync with head
 1.32.18.2 03-Dec-2017  jdolecek update from HEAD
 1.32.18.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.32.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.33.2.1 10-Aug-2014  tls Rebase.
 1.34.4.1 22-Sep-2015  skrll Sync with HEAD
 1.39.6.1 02-Aug-2025  perseant Sync with HEAD
 1.4 06-Jan-2023  tsutsui TAB/spaces/indents cleanup.
 1.3 19-Sep-2021  andvar fix various typos in comments, messages and documentation.
 1.2 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.1 26-Mar-1995  leo branches: 1.1.1;
Initial revision
 1.1.1.1 26-Mar-1995  leo branches: 1.1.1.1.216; 1.1.1.1.236;
NetBSD/Atari, port by Leo Weppelman.
 1.1.1.1.236.1 22-Sep-2015  skrll Sync with HEAD
 1.1.1.1.216.1 03-Dec-2017  jdolecek update from HEAD
 1.9 26-Mar-2023  andvar s/dipslay/display/ in comments.
 1.8 19-Sep-2021  andvar fix various typos in comments, messages and documentation.
 1.7 14-Mar-2009  dsl Remove all the __P() from sys (excluding sys/dist)
Diff checked with grep and MK1 eyeball.
i386 and amd64 GENERIC and sys still build.
 1.6 11-Dec-2005  christos branches: 1.6.78; 1.6.86; 1.6.92;
merge ktrace-lwp.
 1.5 06-Sep-2002  gehenna branches: 1.5.6; 1.5.22;
Merge the gehenna-devsw branch into the trunk.

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

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

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

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

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

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

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

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

- In compile time, device major numbers list is packed into the kernel and
the LKM framework will refer it to assign device major number dynamically.
 1.4 16-Oct-1996  leo branches: 1.4.42; 1.4.46; 1.4.54;
select -> poll
 1.3 18-Apr-1996  leo Yet more prototyping and -Wall fixes.
 1.2 28-May-1995  leo Remove the pointer to view_t from the grf-structure, use viewview(dev)
to obtain the pointer instead. This removes a kernel-crash that happened
when something was written to the console while the console was being
resized.
 1.1 26-Mar-1995  leo branches: 1.1.1;
Initial revision
 1.1.1.1 26-Mar-1995  leo NetBSD/Atari, port by Leo Weppelman.
 1.4.54.1 19-May-2002  gehenna Remove unnecessary prototype.
 1.4.46.1 17-Sep-2002  nathanw Catch up to -current.
 1.4.42.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.42.1 17-Jun-2002  jdolecek make compilable - use cdev_decl(), and remove unnecessary prototypes
from headers
 1.5.22.1 21-Jun-2006  yamt sync with head.
 1.5.6.1 17-Jan-2005  skrll Adapt to branch.
 1.6.92.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.6.86.1 28-Apr-2009  skrll Sync with HEAD.
 1.6.78.1 04-May-2009  yamt sync with head.
 1.5 28-Aug-2006  he Use the common <dev/sun/vuid_event.h> header file instead of maintaining
separate copies in port-specific directories. Add duplicate include
protection. Makes the alpha and atari ports build usr.bin/kdump/ again.
 1.4 11-Dec-2005  christos branches: 1.4.4; 1.4.8;
merge ktrace-lwp.
 1.3 18-May-2004  he branches: 1.3.12;
Add some mulitple include protection.
Include kbdmap.h from iteioctl.h so that kdump compiles, otherwise
the size of struct kbdmap as used in various ioctl defines is unknown.
 1.2 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.1 26-Mar-1995  leo branches: 1.1.1;
Initial revision
 1.1.1.1 26-Mar-1995  leo branches: 1.1.1.1.66;
NetBSD/Atari, port by Leo Weppelman.
 1.1.1.1.66.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.1.1.1.66.2 18-Sep-2004  skrll Sync with HEAD.
 1.1.1.1.66.1 03-Aug-2004  skrll Sync with HEAD
 1.3.12.1 30-Dec-2006  yamt sync with head.
 1.4.8.1 03-Sep-2006  yamt sync with head.
 1.4.4.1 09-Sep-2006  rpaulo sync with head
 1.9 10-Apr-1998  leo Use MI wdc-driver.
 1.8 12-Jan-1998  thorpej Update for changes to config.
 1.7 08-Oct-1997  thorpej Implement DIOCGDEFLABEL.
 1.6 30-Jul-1997  leo Include 'locators.h'
 1.5 17-Jul-1997  jtk branches: 1.5.2;
use locator defines in "locators.h" to index cf_loc[]
 1.4 25-Jun-1997  leo Be consistent with more pedantic bus.h.
 1.3 24-Jun-1997  thorpej In wdsize():
- If the partition is already open, skip the open/close step. (Sync with
other disk drivers).
- foosize()'s return value is in DEV_BSIZE units; adjust the size obtained
from the disklabel accordingly.
 1.2 02-Apr-1997  leo The atari-TT really has no IDE-interface.
 1.1 01-Apr-1997  leo Add wd-driver. The driver is basically the driver present in the arm32
port (Thanks Mark!) with a few atari specific things and the bad block
handling disabled.
 1.5.2.2 14-Oct-1997  thorpej Update marc-pcmcia branch from trunk.
 1.5.2.1 23-Aug-1997  thorpej Update marc-pcmcia branch from trunk.
 1.2 07-Jun-2001  leo Remove the atari specific incarnation of wdc_isa.c. We don't need it (in
fact it didn't work that well either), all could be done by simply adding the
NOSTREAM options to the flags of the generic ISA frontend.
There was probably to much byteswapping in my brain when I invented this.
 1.1 31-Mar-2001  leo branches: 1.1.2; 1.1.4;
Wcd attacment code for the Milan. The Milan has the standard dual IDE port
hardware. A Milan specific attachment is needed to modify the iot so that
the streaming methods do a byteswap.
Configure like:
wdcisa0 at isa? port 0x1f0 irq 14
wdcisa1 at isa? port 0x170 irq 15
 1.1.4.2 21-Apr-2001  bouyer Sync with HEAD
 1.1.4.1 31-Mar-2001  bouyer file wdc_isa.c was added on branch thorpej_scsipi on 2001-04-21 17:53:24 +0000
 1.1.2.1 09-Apr-2001  nathanw Catch up with -current.
 1.43 20-Dec-2023  thorpej Remove unnecessary <sys/malloc.h> include.
 1.42 06-Jan-2023  tsutsui TAB/spaces/indents cleanup.
 1.41 29-Jun-2019  tsutsui Make local functions static.
 1.40 20-Oct-2017  jdolecek branches: 1.40.4;
move ata_queue_alloc(1) and ata_queue_free() calls to ata_channel_init()
and ata_channel_destroy() respectively, to make attachment code simpler,
and to make it easier to spot special queue manipulation like cmdide(4)

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

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

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

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

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

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

Also fixes PR kern/43169 (wd(4)); and PR kern/11811, PR kern/47041,
PR kern/51979 (kernel dump)
 1.38 31-Jul-2012  bouyer branches: 1.38.2; 1.38.28;
Apply back changes that were reverted on Jul 24 and Jul 26 (general ata/wdc
cleanup and SATA PMP support), now that I'm back to fix the fallouts.
 1.37 26-Jul-2012  jakllsch Revert, with intention of restoring in a less invasive way, the SATA Port
Multiplier code.

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

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

Thanks to:
- Protocase (http://www.protocase.com/) which provided a system
with lots of controllers, SATA PMP and drive slots
- Conservation Genomics Laboratory, Department of Biology, New Mexico State
University for hosting the above system
- Brook Milligan, who set up remote access and has been very responsive
when SATA cable move was needed
 1.35 01-Jul-2011  dyoung branches: 1.35.2;
#include <sys/bus.h> instead of <machine/bus.h>.
 1.34 08-Mar-2009  tsutsui ANSIfy, some KNF, misc cosmetics.
 1.33 27-Dec-2008  tsutsui branches: 1.33.2;
Sprinkle volatile to bus_space(9) access functions.
 1.32 28-Apr-2008  martin branches: 1.32.8; 1.32.10;
Remove clause 3 and 4 from TNF licenses
 1.31 18-Mar-2008  cube branches: 1.31.2; 1.31.4;
Split device_t and softc for ATA devices, as well as wd(4). Other
cosmetic changes where appropriate.
 1.30 04-Dec-2007  tsutsui branches: 1.30.8; 1.30.12;
- add a missing brace in the previous
- print error message on failure to map aux register
 1.29 04-Dec-2007  tsutsui Apply missed following MI wdc changes to atari's mainbus wdc backend:
- make bus space handles an array for each command register
http://mail-index.netbsd.org/source-changes/2003/11/27/0036.html
(note we no longer have to specify stride for wdc after this change)
- add the notion of "shadow register"
http://mail-index.netbsd.org/source-changes/2004/05/25/0048.html

Problem reported by Alan Hourihane in PR port-amiga/37464.
 1.28 29-Jan-2006  dsl branches: 1.28.22; 1.28.38; 1.28.46; 1.28.48; 1.28.54; 1.28.58;
Make almost everything #include <sys/bswap.h> instead of <machine/bswap.h>
The bswap.h and endian.h files are all rather incestuous, but I want to
get the constant folding stuff into one place - sys/bswap.h
 1.27 16-Jan-2006  bouyer properly use ata_channel->ch_ndrive:
- initialize it properly in the bus front-ends (all 2, exept in wdc_pcmcia.c
for the "Sandisk CompactFlash Card" where it's set to 1)
- remplace hardcoded '2' by ata_channel->ch_ndrive in MI IDE drivers.

From Christos Zoulas in kern/32501.
 1.26 11-Dec-2005  christos branches: 1.26.2;
merge ktrace-lwp.
 1.25 10-May-2005  jdc branches: 1.25.2;
Add some definitions of the (Falcon) IDE register locations and use these
to initialise the wdc register array.

Doesn't make the wdc probe work on the Falcon, but at least the kernel no
longer dies at boot time.
 1.24 20-Aug-2004  thorpej branches: 1.24.10;
Move most of wdc_softc into a new atac_softc structure that contains
info common to all types of ATA controllers.
 1.23 14-Aug-2004  thorpej - Split the register handles out of struct wdc_channel into a separate
wdc_regs structure, and array of which (indexed per channel) is pointed
to by struct wdc_softc.
- Move the resulting wdc_channel structure to atavar.h and rename it to
ata_channel. Rename the corresponding flags.
- Add a "ch_ndrive" member to struct ata_channel, which indicates the
maximum number of drives that can be present on the channel. For now,
this is always 2. Add an ATA_MAXDRIVES constant that places an upper
limit on this value, also currently 2.
 1.22 13-Aug-2004  thorpej Don't bother with bits that tell of the presence of optional callbacks;
just check the function pointers for NULL.
 1.21 06-Jan-2004  he Make these compile again after the latest adjustments.
 1.20 03-Jan-2004  thorpej More wdc_channel structure member namespace cleanup:
- channel -> ch_channel
- wdc -> ch_wdc
 1.19 03-Jan-2004  thorpej Rename "struct channel_softc" to "struct wdc_channel".
 1.18 01-Jan-2004  thorpej Rename:
- wdc_xfer to ata_xfer
- channel_queue to ata_queue
and move them to <dev/ata/atavar.h> so they can be used by non-wdc ATA
controllers. Clean up the member names of these structures while at it.
 1.17 31-Dec-2003  thorpej Simplfy allocation of the channel queue.
 1.16 16-Dec-2003  he Replace cmd_ioh with cmd_baseioh, to track changes to wdcvar.h, so
that this compiles again. Untested for now.

Reviewed by leo.
 1.15 08-Oct-2003  bouyer Adapt for wdcattach() prototype change.
 1.14 25-Sep-2003  mycroft Hide the use of config_interrupts() in one place.
 1.13 19-Sep-2003  mycroft 1) Use config_interrupts() to attach IDE and ATAPI drives. This eliminates
most polling.
2) Clean up some goofiness in pciide -- get rid of the whole "candisable" path
(it's gratuitous) and simplify the code by calling pciide_map_compat_intr(),
*_set_modes() and wdc_print_modes() from central locations.
3) Add a register writability and register ghost test to eliminate phantom
drives more quickly.
 1.12 15-Jul-2003  lukem __KERNEL_RCSID()
 1.11 02-Oct-2002  thorpej branches: 1.11.6;
Use CFATTACH_DECL().
 1.10 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.9 29-Mar-2000  leo branches: 1.9.8; 1.9.12;
Nuke a bunch of cf_unit abuses.
 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 06-Aug-1999  leo branches: 1.7.2;
Change the way that bit's are cleared in the InterruptPending register of
the 68901. Do this now by _assigning_ ~<bit_to_clear> instead of the
previously used 'andb ~<bit_to_clear>'. The latter caused a rwm-cycle that
caused a race condition to happen when an interrupt arrived between the
Read and Modify-Write.
Anyway, this solved my hanging keyboard problem.
 1.6 19-Feb-1999  leo Add <machine/bswap.h> in the list of include-files.
 1.5 03-Dec-1998  bouyer Rename pio_mode, etc ... to PIO_cap, etc ... for consistency with the
ata_drive_datas struct. Suggested by Soren S. Jorvan.
 1.4 22-Nov-1998  drochner oops - forget update for wdc_channels definition change
 1.3 12-Oct-1998  bouyer Merge bouyer-ide
 1.2 15-Aug-1998  mycroft Assign my copyrights to TNF.
 1.1 10-Apr-1998  leo branches: 1.1.2;
Use MI wdc-driver.
 1.1.2.6 02-Oct-1998  bouyer Cleanup a few error message, remove some dead code. Re-add a reset at end of
attach, unless we have WDC_NO_EXTRA_RESETS.
Add support for data32iot/data32ioh from -current: each controller pass
WDC_CAPABILITY_DATA32 if they can do 32bit, and WDC_CAPABILITY_DATA16 if they
can do 16bit. For controller that support both, the usual autodetect
mechanism is still used.
 1.1.2.5 21-Aug-1998  bouyer Sync with -current
 1.1.2.4 13-Aug-1998  bouyer - sync with -current
- b* -> mem*
 1.1.2.3 23-Jun-1998  leo Add necessary cruft to handle swapped byte-lanes on the data-register. It
basically boils down to the fact that there are 2 new options:
WDC_CAPABILITY_{ATA,ATAPI}_NOSTREAM with which you are able to control
the usage bus_space_read_multi_X() vs. bus_space_read_multi_stream_X().
 1.1.2.2 05-Jun-1998  bouyer Patches from Leo Weppelman for IDE on atari, with minor fixes by me
(needed the addition of a void wdcrestart __P((void*)) function).
Quoting his words:
These diffs are preliminary because it looks like the free_hw() function
does not get called. This is only a problem on the atari falcon. I have not
yet been able to track this down.
Also, KNF wdc.c.
 1.1.2.1 04-Jun-1998  bouyer Commit changes to the IDE system in a branch. This allows a better separation
between higth-level and low-level (i.e. registers read/write) and generalize
the queue for all commands. This also add supports for IDE DMA.
 1.7.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.9.12.1 18-Oct-2002  nathanw Catch up to -current.
 1.9.8.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.11.6.5 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.11.6.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.11.6.3 18-Sep-2004  skrll Sync with HEAD.
 1.11.6.2 25-Aug-2004  skrll Sync with HEAD.
 1.11.6.1 03-Aug-2004  skrll Sync with HEAD
 1.24.10.1 12-Dec-2007  bouyer Pull up following revision(s) (requested by tsutsui in ticket #1885):
sys/arch/atari/dev/wdc_mb.c: revisions 1.29, 1.30 via patch
Apply missed following MI wdc changes to atari's mainbus wdc backend:
- make bus space handles an array for each command register
http://mail-index.netbsd.org/source-changes/2003/11/27/0036.html
(note we no longer have to specify stride for wdc after this change)
- add the notion of "shadow register"
http://mail-index.netbsd.org/source-changes/2004/05/25/0048.html
Problem reported by Alan Hourihane in PR port-amiga/37464.
 1.25.2.3 24-Mar-2008  yamt sync with head.
 1.25.2.2 07-Dec-2007  yamt sync with head
 1.25.2.1 21-Jun-2006  yamt sync with head.
 1.26.2.1 01-Feb-2006  yamt sync with head.
 1.28.58.1 08-Dec-2007  ad Sync with head.
 1.28.54.1 08-Dec-2007  mjf Sync with HEAD.
 1.28.48.2 23-Mar-2008  matt sync with HEAD
 1.28.48.1 09-Jan-2008  matt sync with HEAD
 1.28.46.1 09-Dec-2007  jmcneill Sync with HEAD.
 1.28.38.1 03-Jun-2008  skrll Sync with netbsd-4.
 1.28.22.2 02-Jan-2009  jdc Pull up revisions:
1.10 src/sys/arch/atari/atari/be_bus.c
1.14 src/sys/arch/atari/atari/le_bus.c
1.8 src/sys/arch/atari/atari/mainbus.c
1.33 src/sys/arch/atari/dev/wdc_mb.c
(requested by tsutsui in ticket #1252).

Sprinkle volatile to bus_space(9) access functions.
 1.28.22.1 02-Feb-2008  riz Pull up following revision(s) (requested by tsutsui in ticket #1013):
sys/arch/atari/dev/wdc_mb.c: revision 1.30
sys/arch/atari/dev/wdc_mb.c: revision 1.29
Apply missed following MI wdc changes to atari's mainbus wdc backend:
- make bus space handles an array for each command register
http://mail-index.netbsd.org/source-changes/2003/11/27/0036.html
(note we no longer have to specify stride for wdc after this change)
- add the notion of "shadow register"
http://mail-index.netbsd.org/source-changes/2004/05/25/0048.html
Problem reported by Alan Hourihane in PR port-amiga/37464.
- add a missing brace in the previous
- print error message on failure to map aux register
 1.30.12.3 17-Jan-2009  mjf Sync with HEAD.
 1.30.12.2 02-Jun-2008  mjf Sync with HEAD.
 1.30.12.1 03-Apr-2008  mjf Sync with HEAD.
 1.30.8.1 24-Mar-2008  keiichi sync with head.
 1.31.4.2 04-May-2009  yamt sync with head.
 1.31.4.1 16-May-2008  yamt sync with head.
 1.31.2.1 18-May-2008  yamt sync with head.
 1.32.10.1 06-Jan-2009  snj Pull up following revision(s) (requested by tsutsui in ticket #218):
sys/arch/atari/dev/wdc_mb.c: revision 1.33
sys/arch/atari/atari/mainbus.c: revision 1.8
sys/arch/atari/atari/le_bus.c: revision 1.14
sys/arch/atari/atari/be_bus.c: revision 1.10
Sprinkle volatile to bus_space(9) access functions.
 1.32.8.2 28-Apr-2009  skrll Sync with HEAD.
 1.32.8.1 19-Jan-2009  skrll Sync with HEAD.
 1.33.2.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.35.2.1 30-Oct-2012  yamt sync with head
 1.38.28.4 27-Sep-2017  jdolecek pass ata channel interlock to st_dmagrab() so that it can release
and reacquire it if it sleeps
 1.38.28.3 27-Sep-2017  jdolecek g/c mistakely left over code
 1.38.28.2 27-Sep-2017  jdolecek change wdc_init_shadow_regs() to accept only struct wdc_regs, it doesn't
touch anything else

factor out the probe-only struct ata_channel initialization to wdcprobe(), to
reduce duplication of logic in individual drivers, and to actually work now
that more init is needed beyond the memset()
 1.38.28.1 24-Apr-2017  jdolecek use ata_queue_alloc() to dynamically allocate ata_queue for ata channel
 1.38.2.1 03-Dec-2017  jdolecek update from HEAD
 1.40.4.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.2 10-Apr-1998  leo Use MI wdc-driver.
 1.1 01-Apr-1997  leo Add wd-driver. The driver is basically the driver present in the arm32
port (Thanks Mark!) with a few atari specific things and the bad block
handling disabled.
 1.2 10-Apr-1998  leo Use MI wdc-driver.
 1.1 01-Apr-1997  leo Add wd-driver. The driver is basically the driver present in the arm32
port (Thanks Mark!) with a few atari specific things and the bad block
handling disabled.
 1.6 06-Jan-2023  tsutsui TAB/spaces/indents cleanup.
 1.5 19-Sep-2018  rin Remove unused KBD_NULLMAP entries copy-paste from sys/dev/pckbport.
 1.4 28-Apr-2008  martin branches: 1.4.86; 1.4.88;
Remove clause 3 and 4 from TNF licenses
 1.3 11-Dec-2005  christos branches: 1.3.74; 1.3.76; 1.3.78;
merge ktrace-lwp.
 1.2 13-Mar-2004  bjh21 Remove needless includes of <dev/pckbc/wskbdmap_mfii.h>.
 1.1 02-Feb-2003  thomas branches: 1.1.2;
WS keyboard support for atari native keyboards.
 1.1.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.1.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.1.2.1 03-Aug-2004  skrll Sync with HEAD
 1.3.78.1 16-May-2008  yamt sync with head.
 1.3.76.1 18-May-2008  yamt sync with head.
 1.3.74.1 02-Jun-2008  mjf Sync with HEAD.
 1.4.88.1 10-Jun-2019  christos Sync with HEAD
 1.4.86.1 30-Sep-2018  pgoyette Ssync with HEAD
 1.2 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.1 02-Feb-2003  thomas branches: 1.1.104; 1.1.106; 1.1.108;
WS keyboard support for atari native keyboards.
 1.1.108.1 16-May-2008  yamt sync with head.
 1.1.106.1 18-May-2008  yamt sync with head.
 1.1.104.1 02-Jun-2008  mjf Sync with HEAD.
 1.6 12-Feb-2012  matt Change old-style function defintions to C89 prototypes.

Approved by releng.
 1.5 20-Oct-2009  snj branches: 1.5.12; 1.5.16;
Remove 3rd and 4th clause on Leo Weppelman's license. OK leo@.
 1.4 11-Dec-2005  christos branches: 1.4.78;
merge ktrace-lwp.
 1.3 15-Jul-2003  lukem __KERNEL_RCSID()
 1.2 21-Jan-1997  leo branches: 1.2.60;
Don't set the PA_SER2 bit by default, this has the nasty side effect that
it disables the IDE hardware on the Falcon (Thanks Markus ;-) ). A function
is provided to toggle the bit.
 1.1 27-Mar-1996  leo branches: 1.1.2;
Take out direct access to the YM2149. The chip definitions are moved
from video.h to ym2149reg.h.
 1.1.2.1 30-Jan-1997  thorpej update from trunk
 1.2.60.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.2.60.2 18-Sep-2004  skrll Sync with HEAD.
 1.2.60.1 03-Aug-2004  skrll Sync with HEAD
 1.4.78.1 11-Mar-2010  yamt sync with head
 1.5.16.1 18-Feb-2012  mrg merge to -current.
 1.5.12.1 17-Apr-2012  yamt sync with head
 1.7 20-Oct-2009  snj Remove 3rd and 4th clause on Leo Weppelman's license. OK leo@.
 1.6 14-Mar-2009  dsl Remove all the __P() from sys (excluding sys/dist)
Diff checked with grep and MK1 eyeball.
i386 and amd64 GENERIC and sys still build.
 1.5 11-Dec-2005  christos branches: 1.5.78; 1.5.86; 1.5.92;
merge ktrace-lwp.
 1.4 04-Jun-2005  he Prefix local variables in macros with _, and add a character to
one variable name to avoid a shadowing warning.
 1.3 21-Jan-1997  leo branches: 1.3.60;
Don't set the PA_SER2 bit by default, this has the nasty side effect that
it disables the IDE hardware on the Falcon (Thanks Markus ;-) ). A function
is provided to toggle the bit.
 1.2 17-Nov-1996  leo branches: 1.2.2;
Plug some spl-holes in the lp-driver. Also be more strict in protecting
the register access to the psg-chip. The combination of those bugs
caused the printer to print garbage sometimes.
 1.1 27-Mar-1996  leo Take out direct access to the YM2149. The chip definitions are moved
from video.h to ym2149reg.h.
 1.2.2.1 30-Jan-1997  thorpej update from trunk
 1.3.60.1 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.5.92.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.5.86.1 28-Apr-2009  skrll Sync with HEAD.
 1.5.78.2 11-Mar-2010  yamt sync with head
 1.5.78.1 04-May-2009  yamt sync with head.
 1.82 06-Jul-2024  andvar Fix various typos in comments:
s/defininitions/definitions/
s/ininitialise/initialise/
s/collasped/collapsed/
s/optionaly/optionally/
 1.81 06-Jan-2023  tsutsui branches: 1.81.6;
TAB/spaces/indents cleanup.
 1.80 26-Jun-2022  tsutsui Make local devsw functions static.

No visible regression on TT030.
 1.79 03-Jan-2021  thorpej malloc(9) -> kmem(9)
 1.78 08-Feb-2018  dholland branches: 1.78.16;
Typos.
 1.77 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.76 24-Mar-2014  christos branches: 1.76.2;
- remove unused
- use cpu_{g,s}etmodel() (not committed yet)
 1.75 16-Mar-2014  dholland 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.74 30-Jun-2011  wiz branches: 1.74.2; 1.74.12; 1.74.16;
dependant -> dependent
 1.73 24-Apr-2011  rmind Rename ttymalloc() to tty_alloc(), and ttyfree() to tty_free() for
consistency. Remove some unnecessary malloc.h inclusions as well.
 1.72 09-Apr-2010  tsutsui branches: 1.72.2;
- establish zs interrupts via common intr_establish() function rather than
hardcording them in locore.s and vector.s
- also make interrupt handlers take per unit softc and put a softint cookie
into softc (though atari machines have only one zs)
- tweak some structures as per MI z8530sc driver

Tested on TT030 using sl(4) on zs.
 1.71 09-Apr-2010  tsutsui minor constify
 1.70 09-Apr-2010  tsutsui More KNF.
 1.69 09-Apr-2010  tsutsui Split device_t/softc.
 1.68 09-Apr-2010  tsutsui Rename variables and members of softc for readability.
 1.67 09-Apr-2010  tsutsui Remove unnecessary volatile keyword against struct zschan.
(volatile against structure member is enough)
 1.66 09-Apr-2010  tsutsui - misc KNF
- remove `register' keyword from variable declarations
 1.65 09-Apr-2010  tsutsui Include ioconf.h for struct cfdriver.
 1.64 19-Jul-2009  tsutsui branches: 1.64.2; 1.64.4;
Replace one missed bcopy(9) with memcpy(9).
 1.63 19-Jul-2009  tsutsui Remove extra whitespace added by a dumb tool which replaced bcopy with memcpy.
 1.62 18-Mar-2009  cegger bcopy -> memcpy
 1.61 14-Mar-2009  dsl ANSIfy another 1261 function definitions.
The only ones left in sys are beyond by sed script!
(or in sys/dist or sys/external)
Mostly they have function pointer parameters.
 1.60 14-Mar-2009  dsl Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.59 14-Mar-2009  dsl Remove all the __P() from sys (excluding sys/dist)
Diff checked with grep and MK1 eyeball.
i386 and amd64 GENERIC and sys still build.
 1.58 28-Jan-2009  tjam branches: 1.58.2;
Remove sicallback to use the MI softint(9) APIs directly - from Tsutsui
 1.57 11-Jun-2008  tsutsui branches: 1.57.4; 1.57.6;
Use device_private() and device_lookup_privat() to get softc.
 1.56 29-Apr-2008  martin branches: 1.56.2; 1.56.4;
Convert to new 2 clause license
 1.55 08-Jan-2008  joerg branches: 1.55.6; 1.55.8; 1.55.10;
Convert Atari to generic TODR and timecounter.
 1.54 19-Nov-2007  ad branches: 1.54.6;
- Factor out too many copies of the same bit of tty code.
- Fix another tty signalling/wakeup problem.
 1.53 06-Mar-2007  tsutsui branches: 1.53.2; 1.53.18; 1.53.20; 1.53.24; 1.53.26;
Make TX buffer (uint8_t *) and remove an unnecessary cast.
 1.52 04-Mar-2007  christos Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.51 01-Oct-2006  elad branches: 1.51.4;
More from Matt Fleming:

Adapt to KAUTH_DEVICE_TTY_PRIVSET and KAUTH_DEVICE_TTY_OPEN.
 1.50 01-Oct-2006  elad Adapt MD code to KAUTH_DEVICE_TTY_OPEN. Patch from Matt Fleming, thanks!
 1.49 04-Aug-2006  mhitch branches: 1.49.4; 1.49.6;
More gcc4 "uninitilized" variables.
 1.48 23-Jul-2006  ad Use the LWP cached credentials where sane.
 1.47 14-May-2006  elad integrate kauth.
 1.46 08-Mar-2006  lukem branches: 1.46.2;
Use the SI capitalization for "Hz", "kHz", and "MHz" in comments and strings.
Add a space between numbers and Hz unit.
 1.45 11-Dec-2005  christos branches: 1.45.4; 1.45.6; 1.45.8; 1.45.10;
merge ktrace-lwp.
 1.44 06-Sep-2005  kleink Change the driver open function's conditional for overriding exclusive tty
use from checking the proc's uid to suser(9), and account for the use of
privileges. Noted by David Holland in PR kern/31126.
 1.43 04-Jun-2005  he branches: 1.43.2;
Adapt to compiling with -Wshadow and -Wcast-qual, by adding const
qualification in places and renaming a few local variables.
Also adds a couple uses of __UNVOLATILE() to allow passing volatile
variables to functions wanting e.g. caddr_t.
 1.42 25-Mar-2004  leo Licence cleanup (suggested by wiz).
 1.41 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.40 15-Jul-2003  lukem __KERNEL_RCSID()
 1.39 23-Oct-2002  jdolecek branches: 1.39.6;
merge kqueue branch into -current

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

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

based on work done by Jonathan Lemon for FreeBSD
initial NetBSD port done by Luke Mewburn and Jason Thorpe
 1.38 02-Oct-2002  thorpej Use CFATTACH_DECL().
 1.37 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.36 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.35 17-Mar-2002  atatat branches: 1.35.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.34 02-May-2001  scw branches: 1.34.2; 1.34.4; 1.34.8;
Add `l_poll' to `struct linesw' and provide an xxxpoll() entry point
in each tty driver to indirect through it.

This allows tty line-disciplines to handle poll(2) system calls.
 1.33 01-Feb-2001  leo branches: 1.33.2;
Fix fallout from lastest tty changes.
 1.32 02-Nov-2000  eeh Adapt to new line discipline scheme.
 1.31 29-Mar-2000  leo Nuke a bunch of cf_unit abuses.
 1.30 11-Feb-1999  mycroft branches: 1.30.8;
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.29 25-Mar-1998  leo Sync with latest tty changes.
 1.28 12-Jan-1998  thorpej Update for changes to config.
 1.27 10-Mar-1997  leo Use vme_mask, not sys_mask to enable the SCC interrupt.
 1.26 21-Jan-1997  leo branches: 1.26.4;
Don't set the PA_SER2 bit by default, this has the nasty side effect that
it disables the IDE hardware on the Falcon (Thanks Markus ;-) ). A function
is provided to toggle the bit.
 1.25 20-Dec-1996  leo branches: 1.25.2;
Get rid of BROKEN_INDIRECT_CONFIG
 1.24 10-Nov-1996  leo Add frequency table for Hades.
 1.23 13-Oct-1996  christos backout previous kprintf changes
 1.22 11-Oct-1996  christos printf -> kprintf, sprintf -> ksprintf
 1.21 18-Jun-1996  leo Add tty_attach() calls.
 1.20 15-May-1996  leo branches: 1.20.4;
Prototype + -Wall fixes.
 1.19 18-Apr-1996  leo Yet more prototyping and -Wall fixes.
 1.18 27-Mar-1996  leo Take out direct access to the YM2149. The chip definitions are moved
from video.h to ym2149reg.h.
 1.17 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.16 08-Mar-1996  leo Fix a bug in the DCD handling. Because the state of the DCD line was
kept in a soft-copy that wasn't initialized on open, it sometimes happend
that a change of the carrier got lost. Also fixed some prototypes.
 1.15 22-Feb-1996  leo First bunch of changes due to stricter prototype checking.
 1.14 23-Jan-1996  leo Fixes 'hanging' problem when closing a serial port.
 1.13 25-Dec-1995  leo - Remove an unwanted interference between the 2 channels.
- Allocate the ringbuffer on a channel's first open.
 1.12 16-Dec-1995  leo Correct PCLK value.
 1.11 03-Dec-1995  leo Return a more sensible errno when someone is trying to set the unsupported
mdmbuf option.
 1.10 30-Nov-1995  jtc merge in changes from 1.1 release branch
 1.9 23-Sep-1995  leo branches: 1.9.2;
Make sure the prototypes and inline definitions are included.
 1.8 20-Aug-1995  leo - make sure that there is 1 pending software interrupt max.
- read status before character, so the status won't be lost (Thomas Gerner)
- accumulate as much interrupts as possible in zshard()
 1.7 28-Jun-1995  cgd note that most of dev/ic's contents have changed names
 1.6 28-May-1995  leo According to diffs from Waldi Raven:
Make speed/clock-source selection smarter. This makes the baudrates more
accurate and allows speeds upto 115k baud.
 1.5 14-May-1995  leo Don't mess with SCU on the Falcon.
 1.4 22-Apr-1995  leo Adapt for new conf.h:
- Add xxxtty() functions
- Remove xxx_tty array
 1.3 11-Apr-1995  mycroft Undo accidental change.
 1.2 11-Apr-1995  mycroft Use global 8530 defs.
 1.1 26-Mar-1995  leo branches: 1.1.1;
Initial revision
 1.1.1.1 26-Mar-1995  leo NetBSD/Atari, port by Leo Weppelman.
 1.9.2.1 15-Nov-1995  leo - Increase ringbuffer size.
- Make sure ser02 will be connected to the 8530 when being opened.
 1.20.4.1 18-Jun-1996  leo Pull up tty_attach() changes from trunk.
 1.25.2.1 30-Jan-1997  thorpej update from trunk
 1.26.4.1 12-Mar-1997  is Merge in Changes from The Trunk.
 1.30.8.3 11-Feb-2001  bouyer Sync with HEAD.
 1.30.8.2 22-Nov-2000  bouyer Sync with HEAD.
 1.30.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.33.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.34.8.5 11-Nov-2002  nathanw Catch up to -current
 1.34.8.4 18-Oct-2002  nathanw Catch up to -current.
 1.34.8.3 17-Sep-2002  nathanw Catch up to -current.
 1.34.8.2 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.34.8.1 02-May-2001  nathanw file zs.c was added on branch nathanw_sa on 2002-04-01 07:39:33 +0000
 1.34.4.1 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.34.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.34.2.1 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.35.4.1 17-May-2002  gehenna Add device switch.
 1.39.6.5 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.39.6.4 17-Jan-2005  skrll Adapt to branch.
 1.39.6.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.39.6.2 18-Sep-2004  skrll Sync with HEAD.
 1.39.6.1 03-Aug-2004  skrll Sync with HEAD
 1.43.2.5 21-Jan-2008  yamt sync with head
 1.43.2.4 07-Dec-2007  yamt sync with head
 1.43.2.3 03-Sep-2007  yamt sync with head.
 1.43.2.2 30-Dec-2006  yamt sync with head.
 1.43.2.1 21-Jun-2006  yamt sync with head.
 1.45.10.4 13-May-2006  elad sprinkle some #include <sys/kauth.h> in files that use kauth kpi but
don't include it yet. hopefully this will prevent some fallout.
 1.45.10.3 19-Apr-2006  elad sync with head - hopefully this will work
 1.45.10.2 10-Mar-2006  elad generic_authorize() -> kauth_authorize_generic().
 1.45.10.1 08-Mar-2006  elad Adapt to kernel authorization KPI.

I expect *some* lossage here...
 1.45.8.3 11-Aug-2006  yamt sync with head
 1.45.8.2 24-May-2006  yamt sync with head.
 1.45.8.1 13-Mar-2006  yamt sync with head.
 1.45.6.2 01-Jun-2006  kardel Sync with head.
 1.45.6.1 22-Apr-2006  simonb Sync with head.
 1.45.4.1 09-Sep-2006  rpaulo sync with head
 1.46.2.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.49.6.1 22-Oct-2006  yamt sync with head
 1.49.4.1 18-Nov-2006  ad Sync with head.
 1.51.4.1 12-Mar-2007  rmind Sync with HEAD.
 1.53.26.2 18-Feb-2008  mjf Sync with HEAD.
 1.53.26.1 08-Dec-2007  mjf Sync with HEAD.
 1.53.24.1 21-Nov-2007  bouyer Sync with HEAD
 1.53.20.2 23-Mar-2008  matt sync with HEAD
 1.53.20.1 09-Jan-2008  matt sync with HEAD
 1.53.18.1 21-Nov-2007  joerg Sync with HEAD.
 1.53.2.1 03-Dec-2007  ad Sync with HEAD.
 1.54.6.1 08-Jan-2008  bouyer Sync with HEAD
 1.55.10.4 11-Aug-2010  yamt sync with head.
 1.55.10.3 19-Aug-2009  yamt sync with head.
 1.55.10.2 04-May-2009  yamt sync with head.
 1.55.10.1 16-May-2008  yamt sync with head.
 1.55.8.2 17-Jun-2008  yamt sync with head.
 1.55.8.1 18-May-2008  yamt sync with head.
 1.55.6.2 29-Jun-2008  mjf Sync with HEAD.
 1.55.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.56.4.1 18-Jun-2008  simonb Sync with head.
 1.56.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.57.6.1 02-Feb-2009  snj Pull up following revision(s) (requested by tjam in ticket #370):
sys/arch/atari/dev/zs.c: revision 1.58
Remove sicallback to use the MI softint(9) APIs directly - from Tsutsui
 1.57.4.2 28-Apr-2009  skrll Sync with HEAD.
 1.57.4.1 03-Mar-2009  skrll Sync with HEAD.
 1.58.2.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.64.4.2 31-May-2011  rmind sync with head
 1.64.4.1 30-May-2010  rmind sync with head
 1.64.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.72.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.74.16.1 18-May-2014  rmind sync with head
 1.74.12.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.74.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.76.2.1 10-Aug-2014  tls Rebase.
 1.78.16.1 03-Apr-2021  thorpej Sync with HEAD.
 1.81.6.1 02-Aug-2025  perseant Sync with HEAD
 1.2 11-Apr-1995  mycroft Use global 8530 defs.
 1.1 26-Mar-1995  leo branches: 1.1.1;
Initial revision
 1.1.1.1 26-Mar-1995  leo NetBSD/Atari, port by Leo Weppelman.
 1.18 06-Jan-2023  tsutsui TAB/spaces/indents cleanup.
 1.17 15-Nov-2014  christos centralize the call unit / dialout macros
 1.16 09-Apr-2010  tsutsui branches: 1.16.18;
- establish zs interrupts via common intr_establish() function rather than
hardcording them in locore.s and vector.s
- also make interrupt handlers take per unit softc and put a softint cookie
into softc (though atari machines have only one zs)
- tweak some structures as per MI z8530sc driver

Tested on TT030 using sl(4) on zs.
 1.15 09-Apr-2010  tsutsui Remove unnecessary volatile keyword against struct zschan.
(volatile against structure member is enough)
 1.14 09-Apr-2010  tsutsui - misc KNF
- remove `register' keyword from variable declarations
 1.13 28-Jan-2009  tjam branches: 1.13.4; 1.13.6;
Use 8KB buffer for ZLRB_RING_SIZE to prevent overruns
 1.12 29-Apr-2008  martin branches: 1.12.8; 1.12.10;
Convert to new 2 clause license
 1.11 06-Mar-2007  tsutsui branches: 1.11.40; 1.11.42; 1.11.44;
Make TX buffer (uint8_t *) and remove an unnecessary cast.
 1.10 04-Mar-2007  christos Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.9 11-Dec-2005  christos branches: 1.9.26;
merge ktrace-lwp.
 1.8 25-Mar-2004  leo branches: 1.8.16;
Licence cleanup (suggested by wiz).
 1.7 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.6 25-Mar-1998  leo branches: 1.6.48;
Sync with latest tty changes.
 1.5 24-Jan-1996  gwr Move struct definitions to MD code.
 1.4 25-Dec-1995  leo - Remove an unwanted interference between the 2 channels.
- Allocate the ringbuffer on a channel's first open.
 1.3 30-Nov-1995  jtc merge in changes from 1.1 release branch
 1.2 11-Apr-1995  mycroft branches: 1.2.2;
Use global 8530 defs.
 1.1 26-Mar-1995  leo branches: 1.1.1;
Initial revision
 1.1.1.1 26-Mar-1995  leo NetBSD/Atari, port by Leo Weppelman.
 1.2.2.1 15-Nov-1995  leo - Increase ringbuffer size.
- Make sure ser02 will be connected to the 8530 when being opened.
 1.6.48.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.6.48.2 18-Sep-2004  skrll Sync with HEAD.
 1.6.48.1 03-Aug-2004  skrll Sync with HEAD
 1.8.16.1 03-Sep-2007  yamt sync with head.
 1.9.26.1 12-Mar-2007  rmind Sync with HEAD.
 1.11.44.3 11-Aug-2010  yamt sync with head.
 1.11.44.2 04-May-2009  yamt sync with head.
 1.11.44.1 16-May-2008  yamt sync with head.
 1.11.42.1 18-May-2008  yamt sync with head.
 1.11.40.1 02-Jun-2008  mjf Sync with HEAD.
 1.12.10.1 02-Feb-2009  snj Pull up following revision(s) (requested by tjam in ticket #370):
sys/arch/atari/dev/zsvar.h: revision 1.13
Use 8KB buffer for ZLRB_RING_SIZE to prevent overruns
 1.12.8.1 03-Mar-2009  skrll Sync with HEAD.
 1.13.6.1 30-May-2010  rmind sync with head
 1.13.4.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.16.18.1 03-Dec-2017  jdolecek update from HEAD

RSS XML Feed