Home | History | Annotate | only in /src/sys/arch/mac68k/dev
History log of /src/sys/arch/mac68k/dev
RevisionDateAuthorComments
 1.4 21-Apr-1995  briggs First pass of KNFication. Needs more.
 1.3 26-Oct-1994  cgd new RCS ID format.
 1.2 08-Jul-1994  lkestel 6x10.h: shifted font over by two pixels.
keyboard.h: added constants for commonly used keys and reformatted
array so that gcc would be happy.
adbsys.c: new adb system.
bounds.h: bound-checking macros.
ite.c: new built-in mini-console.
8x14.h: no longer used by built-in console.
adb.c: replaced by adbsys.c
 1.1 29-Sep-1993  briggs branches: 1.1.1;
Initial revision
 1.1.1.1 29-Sep-1993  briggs branches: 1.1.1.1.2;
The current MacBSD architecture sub-directory for NetBSD-0.9--more or
less. It needs some help to get to be -current. Support for minimal
hardware on the SE/30, II, IIx, and IIcx exists.
 1.1.1.1.2.1 24-Jul-1994  cgd update, as requested by briggs
 1.1 29-Sep-1993  briggs branches: 1.1.1;
Initial revision
 1.1.1.2 24-Jul-1994  mycroft Clean up deleted files.
 1.1.1.1 29-Sep-1993  briggs The current MacBSD architecture sub-directory for NetBSD-0.9--more or
less. It needs some help to get to be -current. Support for minimal
hardware on the SE/30, II, IIx, and IIcx exists.
 1.62 18-Sep-2024  nat The delay is only required for machines with built-in floppy drives.

I doubt the vibration from an external drive on the Duos would affect adb
before it attaches.
 1.61 18-Sep-2024  nat Use attach delay only on affected machines.

It is only required for machines with built-in trackballs.

Requested by rin@.
 1.60 14-Sep-2024  nat Allow a few seconds for adb devices to settle.

The spin up of the floppy drive motor would cause a crash on my PowerBook
when adb was attached.
 1.59 07-Aug-2021  thorpej branches: 1.59.12;
Merge thorpej-cfargs2.
 1.58 24-Apr-2021  thorpej branches: 1.58.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.57 19-Oct-2018  martin branches: 1.57.14;
#ifdef DIAGNOSTIC should not cause functional differences (even if
minor or cosmetic)
 1.56 18-Oct-2014  snj branches: 1.56.18; 1.56.20;
src is too big these days to tolerate superfluous apostrophes. It's
"its", people!
 1.55 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.54 06-Jun-2011  matt branches: 1.54.2; 1.54.12;
CFATTACH_DECL(..., sizeof(struct device), -> CFATTACH_DECL_NEW(..., 0
struct device * -> device_t
struct cfdata * -> cfdata_t
use bool when appropriate
 1.53 01-Nov-2009  snj branches: 1.53.4; 1.53.10;
Drop 3rd and 4th clauses. Approved by Brad Grantham (copyright holder).
 1.52 03-Apr-2008  scottr branches: 1.52.4;
Factor out ADB spin-wait timeout loop, and use it for synchronous
operations to access the PRAM RTC, etc. in the IIsi and Cuda cases.
Thanks to Martin Husemann for pointing out the flaw.

This is a slightly more thorough workaround for the issue Martin found
in PR 37611, as it affected more than just adb_read_date_time().
 1.51 03-Dec-2007  ad branches: 1.51.14;
Interrupt handling changes, in discussion since February:

- Reduce available SPL levels for hardware devices to none, vm, sched, high.
- Acquire kernel_lock only for interrupts at IPL_VM.
- Implement threaded soft interrupts.
 1.50 08-Mar-2007  tsutsui branches: 1.50.2; 1.50.18; 1.50.20; 1.50.26;
MI softintr(9)'fy.
Probably problematic, but LC630 is running at single user.
 1.49 24-Dec-2005  perry branches: 1.49.26;
bare asm -> __asm
 1.48 11-Dec-2005  christos merge ktrace-lwp.
 1.47 16-Jun-2005  jmc branches: 1.47.2;
Fixes for volatile problems
 1.46 15-Jan-2005  chs de-__P, remove register, ansify, b* -> mem*.
 1.45 15-Jul-2003  lukem __KERNEL_RCSID()
 1.44 01-Jan-2003  thorpej branches: 1.44.2;
Use aprint_normal() in cfprint routines.
 1.43 02-Oct-2002  thorpej Use CFATTACH_DECL().
 1.42 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.41 20-Nov-2001  chs prepare for ELF:
- add "%" prefix to register names in assembly code.
- use _C_LABEL() where necessary.
- use packed structures where necessary to match the old ABI.
 1.40 15-Nov-2000  scottr branches: 1.40.4; 1.40.8;
The Cuda-based ADB hardware has the ability to queue some commands and
return control to the main CPU before completing the ADB transaction.
Double the adb_op_sync() timeout as a result. Fixes PR 11310.
 1.39 27-Sep-2000  scottr Now that we do collision detection and assign all ADB devices to distinct
addresses, it makes sense to print the actual address of the device rather
than the original address. The latter is useful to distinguish the type
of device only, so we maintain that data internally (as we always have).

This closes PR 10557 from Dave Huang.
 1.38 19-Sep-2000  scottr Ken'ichi Ishizaka discovered that some devices, e.g. the A3 Mouse, don't
respond in the allotted time if they're told to TALK immediately after
completing a LISTEN command. Experimentation with adb_op_sync() yielded
consistent results when the timeout was increased from the documented
6900 usec to 8000 usec, so we'll make that change here.

(Accurate and complete documentation of the hardware sure would help...)
 1.37 03-Jul-2000  scottr Stabilize ADB support for some non-Apple ADB peripherals. This is the
second (and final) part of the fix for PR 10086. (There are no longer
any infinite-wait busy loops in the ADB driver!)
 1.36 18-Jun-2000  scottr branches: 1.36.2;
Revert debug-related bogon that snuck in (no change in functionality).
 1.35 19-Mar-2000  scottr branches: 1.35.2;
The MRG and direct ADB drivers were inconsistent in how they worked with
a serial console; the direct driver didn't care, but the MRG driver
wouldn't probe ADB when using a serial console. Remove the check from
the MRG version of the code to resolve this difference.
 1.34 14-Feb-2000  scottr Merge wscons work onto the main development branch.
 1.33 28-Nov-1999  scottr Don't use the plural form of the word "target" if there is only one!
 1.32 07-Nov-1999  scottr Garbage collect adb_initted.
 1.31 07-Nov-1999  scottr We want adb_polling set regardless of whether we're using the MRG driver.
 1.30 07-Nov-1999  scottr ite_polling -> adb_polling
 1.29 05-Nov-1999  scottr Defer ADB configuration until interrupts are (normally) enabled.
 1.28 05-Nov-1999  scottr An aesthetic change to autoconfig output to complement Colin Wood's
change to macrom.c in June.
 1.27 11-Feb-1999  ender branches: 1.27.2; 1.27.4; 1.27.10; 1.27.12; 1.27.16;
o Change various attach arg and softc datatypes to ints.
o Use explicit typecasts when interfacing with MRG data

Should fix port-mac68k/6839. Patch supplied by
Frederick Bruckman <fb@enteract.com>
 1.26 26-Oct-1998  scottr Make it compile for MRG_ADB kernels.
 1.25 23-Oct-1998  ender New ADB "bus" interface:
o Separate ms and kbd drivers
o aed device for compatibility
o debug message cleanup in hardware direct support (from scottr)
 1.24 11-Aug-1998  briggs Patch from Takashi NAKAMURA <QZM00427@nifty.ne.jp> to support the
Contour 3-button mouse from the Contour Design Corp.
It looks like a Microspeed mouse.
 1.23 13-Apr-1998  scottr Make type explicit for egcs, from Erik Bertelsen in PR 5288.
 1.22 27-Mar-1998  scottr Don't map Opt-{1,2,3} to mouse buttons unless the ALTXBUTTONS option is
specified. (Doing so breaks German keyboards!) Fixes PR 4929.
 1.21 23-Feb-1998  scottr Mostly KNF. There's still a bunch of ugly comments and some problems
with long lines, but this is at least a big step in the right direction.
 1.20 21-Feb-1998  scottr Unify ADB options and place them all into opt_adb.h. Provide a knob to
enable ADB debugging messages if ADB_DEBUG is configured.
 1.19 12-Jan-1998  thorpej Update for changes to config.
 1.18 26-Nov-1997  scottr Don't attempt to open the ADB device if it hasn't been initialized.
Also, don't allow more than one instance to be configured.
 1.17 11-Aug-1997  scottr Make #include directives consistent. All MD headers are of the form:

#include <mac68k/{dev,mac68k}/foo.h>
 1.16 25-Jul-1997  scottr branches: 1.16.2;
Add option-{1,2,3} as an alternative to option-{,left,right} for mouse
button emulation. From SUNAGAWA Keiki <kei_sun@ba2.so-net.or.jp> in
PR 3887.
 1.15 16-Jun-1997  scottr Add support for Mouse Systems A3 mouse. From Colin Wood.
 1.14 08-Apr-1997  scottr Updates from John Wittkoski for new ADB driver.
 1.13 16-Dec-1996  scottr Convert all foo_match() functions to use a `struct cfdata *' for their
second argument. The NuBus autoconfig code had to be reorganized as a
result of this, and looks much more like a directly-attached bus now.
These changes eliminate __BROKEN_INDIRECT_CONFIG.
 1.12 13-Oct-1996  christos backout previous kprintf change
 1.11 11-Oct-1996  christos printf -> kprintf, sprintf -> ksprintf
 1.10 14-Sep-1996  scottr - Implement poll(2)
- Convert splhigh() -> spladb()
- Guard references to adb_evq_tail and adb_evq_len!
 1.9 05-May-1996  briggs Fix typo in last.
 1.8 05-May-1996  briggs MicroSpeed mouse support from Taras Ivanenko <ivanenko@ctpa03.mit.edu>.
Also some updates to actually used #defined constants instead of numeric
constants.
 1.7 05-May-1996  briggs Prototype for -Wall -Wstrict-prototypes -Wmissing-prototypes -Wno-uninitialized
Also change the device probing scheme to use something a bit more rational.
A current side-effect is that nubus cards are double-mapped. I expect
to fix that shortly.
Also change splclock() to block everything but serial hardware interrupts.
 1.6 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.5 01-Nov-1995  briggs port-mac/1707: mac68k mouse drag problems with Cmd+arrow keys
from Ken Nakata <kenn@remus.rutgers.edu>
 1.4 03-Sep-1995  briggs branches: 1.4.2;
Add support for Extended Apple Mouse Protocol from
Ken Nakata <kenn@remus.rutgers.edu>.
 1.3 30-Jun-1995  briggs Option key fix from Ken Nakata (kenn@remus.rutgers.edu).
 1.2 21-Apr-1995  briggs First pass of KNFication. Needs more.
 1.1 03-Dec-1994  briggs Mac ROM Glue changes from grantham@tenon.com.
 1.4.2.1 02-Nov-1995  briggs from HEAD; patch from Ken Nakata to allow mouse movement when using keyboard
mouse buttons.
 1.16.2.1 23-Aug-1997  thorpej Update marc-pcmcia branch from trunk.
 1.27.16.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.27.12.1 15-Nov-1999  fvdl Sync with -current
 1.27.10.2 22-Nov-2000  bouyer Sync with HEAD.
 1.27.10.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.27.4.2 29-Nov-1999  he Pull up revision 1.33 (requested by scottr):
Use correct English when reporting the number of ADB target(s).
 1.27.4.1 21-Nov-1999  he Pull up revisions 1.28,1.30-1.32 (via patch, requested by sr):
Clean up the ADB driver, and eliminate duplicate keystrokes under
heavy load, fixing PR#7870.
 1.27.2.4 13-Feb-2000  scottr itevar.h is gone.
 1.27.2.3 28-Nov-1999  scottr Sync with main branch.
 1.27.2.2 09-Nov-1999  scottr Sync with main branch.
 1.27.2.1 05-Mar-1999  scottr checkpoint: input side code should work. no output side yet.
 1.35.2.1 22-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.36.2.2 15-Nov-2000  tv Pullup 1.40 [scottr]:
The Cuda-based ADB hardware has the ability to queue some commands and
return control to the main CPU before completing the ADB transaction.
Double the adb_op_sync() timeout as a result. Fixes PR 11310.
 1.36.2.1 21-Sep-2000  scottr Pull up revs 1.37 and 1.38 from scottr:
Stabilize ADB support for some non-Apple ADB peripherals.
 1.40.8.3 03-Jan-2003  thorpej Sync with HEAD.
 1.40.8.2 18-Oct-2002  nathanw Catch up to -current.
 1.40.8.1 08-Jan-2002  nathanw Catch up to -current.
 1.40.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.40.4.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.44.2.5 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.44.2.4 17-Jan-2005  skrll Sync with HEAD.
 1.44.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.44.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.44.2.1 03-Aug-2004  skrll Sync with HEAD
 1.47.2.3 07-Dec-2007  yamt sync with head
 1.47.2.2 03-Sep-2007  yamt sync with head.
 1.47.2.1 21-Jun-2006  yamt sync with head.
 1.49.26.1 12-Mar-2007  rmind Sync with HEAD.
 1.50.26.1 08-Dec-2007  mjf Sync with HEAD.
 1.50.20.1 09-Jan-2008  matt sync with HEAD
 1.50.18.1 09-Dec-2007  jmcneill Sync with HEAD.
 1.50.2.1 03-Dec-2007  ad Sync with HEAD.
 1.51.14.1 03-Apr-2008  mjf Sync with HEAD.
 1.52.4.1 11-Mar-2010  yamt sync with head
 1.53.10.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.53.4.1 12-Jun-2011  rmind sync with head
 1.54.12.2 03-Dec-2017  jdolecek update from HEAD
 1.54.12.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.54.2.1 30-Oct-2012  yamt sync with head
 1.56.20.1 10-Jun-2019  christos Sync with HEAD
 1.56.18.1 20-Oct-2018  pgoyette Sync with head
 1.57.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.58.8.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.59.12.1 02-Aug-2025  perseant Sync with HEAD
 1.73 14-Jun-2025  nat Increase delay when resetting adb.

This fixes intermittent device detection and no lockups when pressing the
keyboard or moving the mouse when the kernel is booting.
 1.72 05-Mar-2024  andvar branches: 1.72.2;
Remove duplicate "when" word in comments.
 1.71 28-Feb-2024  thorpej Fix up the mac68k interrupt handlers to work with the new style common
clockframe layout and remove the CLOCK_FORMAT0 work-around. As a nice
side-effect, this also eliminates the super-sketchy stack unwinding used
by rtclock_intr to get at the interrupt stack frame.
 1.70 09-Feb-2024  andvar s/anthing/anything/ and s/be to/too/ in comments.
 1.69 21-Sep-2023  msaitoh s/ for for / for / in comment.
 1.68 08-Jan-2019  jdolecek no need to include <machine/param.h> if <sys/param.h> already included
 1.67 18-Oct-2014  snj branches: 1.67.18; 1.67.20;
src is too big these days to tolerate superfluous apostrophes. It's
"its", people!
 1.66 25-Oct-2013  martin Mark potentially unused variable
 1.65 19-Oct-2013  martin Make sure we don't accidently pass an unsolicited packet as "ack only"
(which would dereference unitialized pointers)
 1.64 18-Oct-2013  martin Remove set but unused variables.
 1.63 04-Apr-2008  yamt branches: 1.63.38; 1.63.48; 1.63.54;
adb_read_date_time: remove an unused variable.
 1.62 03-Apr-2008  scottr Factor out ADB spin-wait timeout loop, and use it for synchronous
operations to access the PRAM RTC, etc. in the IIsi and Cuda cases.
Thanks to Martin Husemann for pointing out the flaw.

This is a slightly more thorough workaround for the issue Martin found
in PR 37611, as it affected more than just adb_read_date_time().
 1.61 01-Apr-2008  martin Add timeout to busy loops waiting for ADB command completition.
Turns the hard hang in PR port-mac68k/37611 into a warning.
 1.60 03-Dec-2007  ad branches: 1.60.14;
Interrupt handling changes, in discussion since February:

- Reduce available SPL levels for hardware devices to none, vm, sched, high.
- Acquire kernel_lock only for interrupts at IPL_VM.
- Implement threaded soft interrupts.
 1.59 17-Oct-2007  garbled branches: 1.59.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.58 09-Jul-2007  ad branches: 1.58.8; 1.58.10;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements
 1.57 08-Mar-2007  tsutsui branches: 1.57.2; 1.57.4; 1.57.10;
MI softintr(9)'fy.
Probably problematic, but LC630 is running at single user.
 1.56 24-Jan-2007  hubertf branches: 1.56.2;
Remove duplicate #includes, patch contributed in private mail
by Slava Semushin <slava.semushin@gmail.com>.

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

Thanks to martin@ for the input on testing.
 1.55 24-Nov-2006  wiz s/independant/independent/, from Zafer.
 1.54 21-Jun-2006  rjs branches: 1.54.4; 1.54.6;
Rename shadowing time variable.
 1.53 24-Dec-2005  perry branches: 1.53.4; 1.53.8; 1.53.16;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.
 1.52 11-Dec-2005  christos merge ktrace-lwp.
 1.51 16-Jun-2005  jmc branches: 1.51.2;
Fixes for volatile problems
 1.50 15-Jan-2005  chs de-__P, remove register, ansify, b* -> mem*.
 1.49 15-Jul-2003  lukem __KERNEL_RCSID()
 1.48 03-Nov-2002  shiba branches: 1.48.6;
Support internal ADB keyboard of PowerBook 190,190cs.
The keyboard works fine now. I don't confirm working internal
ADB track pad.

But an internal IDE drive is not recognized, and
an internal SCSI host controller(sbc driver) don't work yet.
 1.47 30-May-2002  thorpej - Don't use multi-line string literals.
- Statements must follow labels.
 1.46 05-Mar-2002  shiba branches: 1.46.6;
Fix up a bug which PB150 shuts down when one boots up in progress.
PB150 will work with SCSI disk. But we cannot use an internal IDE
disk yet.

Reviewed by briggs
 1.45 20-Nov-2001  chs prepare for ELF:
- add "%" prefix to register names in assembly code.
- use _C_LABEL() where necessary.
- use packed structures where necessary to match the old ABI.
 1.44 27-Sep-2000  scottr branches: 1.44.4; 1.44.8;
Set up ADB hardware type before making decisions based on same.
This is part of PR 9852 from Daishi Kato.
 1.43 03-Jul-2000  scottr Stabilize ADB support for some non-Apple ADB peripherals. This is the
second (and final) part of the fix for PR 10086. (There are no longer
any infinite-wait busy loops in the ADB driver!)
 1.42 23-Mar-2000  thorpej branches: 1.42.4;
New callout mechanism with two major improvements over the old
timeout()/untimeout() API:
- Clients supply callout handle storage, thus eliminating problems of
resource allocation.
- Insertion and removal of callouts is constant time, important as
this facility is used quite a lot in the kernel.

The old timeout()/untimeout() API has been removed from the kernel.
 1.41 19-Mar-2000  scottr Add and use macros to build ADB FLUSH, LISTEN, and TALK commands.
 1.40 18-Mar-2000  scottr Check to make sure we get a valid handler ID in response to a TALK R3.
 1.39 07-Mar-2000  scottr Low-level drivers, like the Power Manager driver, can get us into a major
funk when they misbehave and give us unexpected results. Specifically:

- Don't assume that the first free slot is at the top of the table if
we can't find one.
- Don't increment ADBNumDevices when backfilling "holes" left by devices
that didn't respond to a TALK R3 during the initial device scan.
- Don't assume that an address reassignment worked; make sure something
responds on the new address before plowing forward.
- If after device reassignment there are no free slots, make sure to
indicate this fact.
- Failing all else, handle the situation where we run out of slots in
the device table -- which now should "never" happen -- gracefully.

While the Power Manager driver still sometimes misbehaves, it shouldn't
cause the system to crash/hang due to us walking off the end of the
device table.
 1.38 21-Feb-2000  scottr Explicitly include headers needed by iopreg.h
 1.37 21-Feb-2000  scottr Bracket disabled IIfx IOP code with #ifdef __notyet__, rather than
commenting it out or using #if 0.
 1.36 25-Dec-1999  scottr Apparently, the Mac TV is a re-packaged Performa 550. Add code to
recognize this so that Mac TV users can finally ditch the MRG_ADB option.
 1.35 10-Dec-1999  scottr An interrupt handler may change adbInCount underneath us, so qualify the declaration
with volatile. The bug didn't show its face until more agressive
optimization showed up, apparently a result of the last egcs upgrade.
(The interrupt handling changes from June have certainly also played
a part.) Thanks to Ken'ichi Ishizaka for discovering the problem.
 1.34 28-Nov-1999  scottr If there is only one ADB device, it will do us no good to avoid it
when guessing which device to poll next. Resolves PR 7407, but the
bug is a lot older than that.
 1.33 07-Nov-1999  scottr In the interrupt handlers, check adb_polling instead of
adb_initted to decide whether to handle 'recovered' interrupts
immediately.
 1.32 07-Nov-1999  scottr Oops... last rev created an unused variable. While here, clean up
adb_reinit()'s variables a bit, too.
 1.31 07-Nov-1999  scottr Convert one more buffer copy that I missed in rev 1.28.
 1.30 07-Nov-1999  scottr Always using polling for poweroff (from macppc).
 1.29 07-Nov-1999  scottr ite_polling -> adb_polling
 1.28 06-Nov-1999  scottr Convert buffer copies to memcpy().
 1.27 06-Nov-1999  scottr Add more delay in adb_reinit() (from macppc).
 1.26 06-Nov-1999  scottr branches: 1.26.2;
Don't invoke the upper half handler unless we're still
initializing the ADB bus. This fixes PR 7870.
 1.25 29-Jun-1999  briggs branches: 1.25.2; 1.25.4; 1.25.6;
Poll for serial interrupts. Return to 3000us delay instead of 4000us in init.
 1.24 28-Jun-1999  briggs Unfortunately, several changes that are intermingled:
- Add initial IOP support. ADB doesn't work yet for me, but it's here so
that others will be encouraged to work on it. ADB_HW_IOP basically
is configured as a NOP so that serial consoles will continue to work.
- Roll via1_intr and via2_intr into the intr.c scheme--this also required
changing rtclock_intr to grovel the stack differently so that hardclock
gets the right arguments and softclock() doesn't get all reentrant.
- Make via1 interrupts parallel to via2 interrupts--handlers get a pass-
through pointer and we can register handlers. Register via1 interrupt
with intr_establish()--normally level 1, level 6 for A/UX scheme.
- Use intr_establish() to set real via2 interrupt handler instead of the
hacked function pointer.
- Reorganize adb-direct interrupts so that a function call is removed.
- Implement A/UX interrupts for all Quadras right now. We may need to
special case some Quadras, but Linux folks are reporting success on
several models.
- Fix intrnames to be accurate for the normal, PSC, and A/UX interrupt
configurations.
 1.23 15-May-1999  scottr From Yasuhiro Endoh: Performa 58x uses ADB soft poweroff.
 1.22 06-May-1999  scottr Correct two more problems of the same type as in rev 1.21: use the length
of the buffer you're copying from as the loop interator, not the length
of the buffer you're copying to. Also, rewrite print_single() with
pointer instead of array operators. Appears to correct some ADB-related
`hangs' during autoconfig.
 1.21 18-Mar-1999  scottr branches: 1.21.2;
Fix an obscure bug in send_adb_cuda() found be comparison with
the macppc version.
 1.20 11-Feb-1999  ender branches: 1.20.2;
o Change various attach arg and softc datatypes to ints.
o Use explicit typecasts when interfacing with MRG data

Should fix port-mac68k/6839. Patch supplied by
Frederick Bruckman <fb@enteract.com>
 1.19 14-Nov-1998  briggs Make this compile _and_ link with DEBUG / ADB_DEBUG defined.
 1.18 14-Nov-1998  briggs Allow this to compile with DEBUG defined.
 1.17 26-Oct-1998  scottr Make it compile for MRG_ADB kernels.
 1.16 23-Oct-1998  ender New ADB "bus" interface:
o Separate ms and kbd drivers
o aed device for compatibility
o debug message cleanup in hardware direct support (from scottr)
 1.15 12-Aug-1998  scottr New framework for handling processor interrupts, derived in part from
the hp300 port.

- Interrupts 3-6 use this immediately. Interrupt 7 is a special case,
and the VIA interrupts (1 and 2) will be addressed when that code is
rototilled.

- Modify the zs front end to register with the appropriate interrupt
controller: through the PSC on the AV Quadras, and direct to
interrupt 4 on the rest. Arrange to have the appropriate zsc_softc
supplied to us at interrupt time.

- Modify the direct ADB driver (and its PowerManager cousin) to call
intr_dispatch(), rather than zshard(). XXX This is a kludge, but at
least limits the brokenness to the ADB drivers, now.

As a side effect, this should fix PR 5590. Thanks to Bill Studenmund for
correctly determining the cause of the problem reported there.
 1.14 29-Mar-1998  scottr Better integration of Power Manager IC ADB driver into the direct ADB driver framework,
from Takashi Hamada. Also includes a handler for unsolicited ADB
packets.
 1.13 26-Mar-1998  scottr Add Performa 580/588 to the list of machines which have a Cuda chip.
XXX - we should really be using machine ID symbolic constants here, not
numbers.
 1.12 23-Feb-1998  scottr Rewritten II-series ADB code from John Wittkoski. Also, a whole
lotta KNF.
 1.11 21-Feb-1998  scottr Unify ADB options and place them all into opt_adb.h. Provide a knob to
enable ADB debugging messages if ADB_DEBUG is configured.
 1.10 09-Jan-1998  scottr Another update from John: if we're polling, e.g. in ddb, pass the
keystroke to the upper half directly.
 1.9 07-Jan-1998  scottr Update from John Wittkoski: the Color Classic and Color Classic II
have Cuda hardware, not IIsi-based.
 1.8 07-Nov-1997  scottr Update from John Wittkoski: bug fixes for Cuda support.
 1.7 04-Nov-1997  briggs remove an obsolete comment.
 1.6 11-Aug-1997  scottr branches: 1.6.4;
Make #include directives consistent. All MD headers are of the form:

#include <mac68k/{dev,mac68k}/foo.h>
 1.5 21-Apr-1997  scottr branches: 1.5.4;
April 18 update from John Wittkoski, w/space vs. tab KNFing by me.
 1.4 18-Apr-1997  scottr Make sure to call adbop() on Power Manager-based machines. Noted by
Takashi Hamada, who also provided the code I based this modifcation
on.
 1.3 14-Apr-1997  scottr Use the new opt_mrg_adb.h header.
 1.2 08-Apr-1997  scottr Fix several more instances where the volatile modifier was needed.
From Allen.
 1.1 08-Apr-1997  scottr Direct-to-hardware ADB interface/driver, written by John P. Wittkoski.
 1.5.4.1 23-Aug-1997  thorpej Update marc-pcmcia branch from trunk.
 1.6.4.2 29-Jan-1998  mellon Pull up 1.9
 1.6.4.1 11-Nov-1997  mellon Pull rev 1.7 and 1.8 up from trunk (scottr)
 1.20.2.7 25-Dec-1999  scottr Sync with main branch.
 1.20.2.6 12-Dec-1999  scottr Sync with main branch.
 1.20.2.5 28-Nov-1999  scottr Sync with main branch.
 1.20.2.4 09-Nov-1999  scottr Sync with main branch.
 1.20.2.3 02-Nov-1999  scottr [Redo] Sync with main branch.
 1.20.2.2 16-May-1999  scottr Sync with main branch.
 1.20.2.1 05-Mar-1999  scottr checkpoint: input side code should work. no output side yet.
 1.21.2.5 16-Dec-1999  he Pull up revision 1.35 (requested by scottr):
Make adbInCount volatile to fix problems uncovered by aggressive
optimization.
 1.21.2.4 29-Nov-1999  he Pull up revision 1.34 (requested by scottr):
Make it possible to have only one ADB device on machines with
first-generation ADB hardware. Fixes PR#7407.
 1.21.2.3 21-Nov-1999  he Pull up revisions 1.26-1.33 (via patch, requested by sr):
Clean up the ADB driver, and eliminate duplicate keystrokes under
heavy load, fixing PR#7870.
 1.21.2.2 07-Jun-1999  perry pullup 1.22->1.23 (scottr): make auto power off work on Performa 58x's
 1.21.2.1 06-May-1999  cgd branches: 1.21.2.1.2; 1.21.2.1.4;
pull up rev 1.22 from trunk (scottr)
 1.21.2.1.4.1 30-Nov-1999  itojun bring in latest KAME (as of 19991130, KAME/NetBSD141) into kame branch
just for reference purposes.
This commit includes 1.4 -> 1.4.1 sync for kame branch.

The branch does not compile at all (due to the lack of ALTQ and some other
source code). Please do not try to modify the branch, this is just for
referenre purposes.

synchronization to latest KAME will take place on HEAD branch soon.
 1.21.2.1.2.2 01-Jul-1999  thorpej Sync w/ -current.
 1.21.2.1.2.1 21-Jun-1999  thorpej Sync w/ -current.
 1.25.6.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.25.4.1 15-Nov-1999  fvdl Sync with -current
 1.25.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.26.2.2 06-Nov-1999  scottr Don't invoke the upper half handler unless we're still
initializing the ADB bus. This fixes PR 7870.
 1.26.2.1 06-Nov-1999  scottr file adb_direct.c was added on branch comdex-fall-1999 on 1999-11-06 22:25:21 +0000
 1.42.4.2 28-Sep-2000  scottr Pull up rev 1.44 from scottr (approved by thorpej):
Set up ADB hardware type before making decisions based on same.
 1.42.4.1 21-Sep-2000  scottr Pull up rev 1.43 from scottr:
Stabilize ADB support for some non-Apple ADB peripherals.
 1.44.8.4 11-Nov-2002  nathanw Catch up to -current
 1.44.8.3 20-Jun-2002  nathanw Catch up to -current.
 1.44.8.2 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.44.8.1 08-Jan-2002  nathanw Catch up to -current.
 1.44.4.3 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.44.4.2 16-Mar-2002  jdolecek Catch up with -current.
 1.44.4.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.46.6.1 14-Jul-2002  gehenna catch up with -current.
 1.48.6.5 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.48.6.4 17-Jan-2005  skrll Sync with HEAD.
 1.48.6.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.48.6.2 18-Sep-2004  skrll Sync with HEAD.
 1.48.6.1 03-Aug-2004  skrll Sync with HEAD
 1.51.2.5 07-Dec-2007  yamt sync with head
 1.51.2.4 03-Sep-2007  yamt sync with head.
 1.51.2.3 26-Feb-2007  yamt sync with head.
 1.51.2.2 30-Dec-2006  yamt sync with head.
 1.51.2.1 21-Jun-2006  yamt sync with head.
 1.53.16.1 13-Jul-2006  gdamore Merge from HEAD.
 1.53.8.1 26-Jun-2006  yamt sync with head.
 1.53.4.1 09-Sep-2006  rpaulo sync with head
 1.54.6.1 10-Dec-2006  yamt sync with head.
 1.54.4.2 01-Feb-2007  ad Sync with head.
 1.54.4.1 12-Jan-2007  ad Sync with head.
 1.56.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.57.10.1 03-Oct-2007  garbled Sync with HEAD
 1.57.4.1 11-Jul-2007  mjf Sync with head.
 1.57.2.2 03-Dec-2007  ad Sync with HEAD.
 1.57.2.1 15-Jul-2007  ad Sync with head.
 1.58.10.2 09-Jan-2008  matt sync with HEAD
 1.58.10.1 06-Nov-2007  matt sync with HEAD
 1.58.8.1 09-Dec-2007  jmcneill Sync with HEAD.
 1.59.2.1 08-Dec-2007  mjf Sync with HEAD.
 1.60.14.2 02-Jun-2008  mjf Sync with HEAD.
 1.60.14.1 03-Apr-2008  mjf Sync with HEAD.
 1.63.54.1 18-May-2014  rmind sync with head
 1.63.48.2 03-Dec-2017  jdolecek update from HEAD
 1.63.48.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.63.38.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.67.20.1 10-Jun-2019  christos Sync with HEAD
 1.67.18.1 18-Jan-2019  pgoyette Synch with HEAD
 1.72.2.1 02-Aug-2025  perseant Sync with HEAD
 1.2 23-Oct-1998  ender New ADB "bus" interface:
o Separate ms and kbd drivers
o aed device for compatibility
o debug message cleanup in hardware direct support (from scottr)
 1.1 08-Apr-1997  scottr Direct-to-hardware ADB interface/driver, written by John P. Wittkoski.
 1.49 22-Aug-2019  rin Remove adbsys.c, which has been unused since 1998!
 1.48 01-Nov-2009  snj branches: 1.48.64;
Drop 3rd and 4th clauses. Approved by Brad Grantham (copyright holder).
 1.47 04-Mar-2007  christos branches: 1.47.44;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.46 11-Dec-2005  christos branches: 1.46.26;
merge ktrace-lwp.
 1.45 15-Jan-2005  chs branches: 1.45.10;
de-__P, remove register, ansify, b* -> mem*.
 1.44 15-Jul-2003  lukem __KERNEL_RCSID()
 1.43 19-Mar-2000  scottr branches: 1.43.28;
Add and use macros to build ADB FLUSH, LISTEN, and TALK commands.
 1.42 07-Nov-1999  scottr Garbage-collect adb_init(). It's been dead for a long time.
 1.41 07-Nov-1999  scottr ite_polling -> adb_polling
 1.40 11-Feb-1999  ender branches: 1.40.2; 1.40.4; 1.40.10; 1.40.12; 1.40.16;
o Change various attach arg and softc datatypes to ints.
o Use explicit typecasts when interfacing with MRG data

Should fix port-mac68k/6839. Patch supplied by
Frederick Bruckman <fb@enteract.com>
 1.39 11-Aug-1998  briggs Patch from Takashi NAKAMURA <QZM00427@nifty.ne.jp> to support the
Contour 3-button mouse from the Contour Design Corp.
It looks like a Microspeed mouse.
 1.38 28-May-1998  scottr Handle a non-EMP Trackman the same way we handle a non-EMP Mouseman.
Patch from John Wittkoski.
 1.37 23-Feb-1998  scottr Mostly KNF. There's still a bunch of ugly comments and some problems
with long lines, but this is at least a big step in the right direction.
 1.36 21-Feb-1998  scottr Unify ADB options and place them all into opt_adb.h. Provide a knob to
enable ADB debugging messages if ADB_DEBUG is configured.
 1.35 20-Feb-1998  scottr Fix for ADB hang while probing, based on information from Colin Wood:
Rather than waiting indefinitely for a mouse or extended keyboard to
respond -- which may not even exist -- time out after 2 seconds and
continue. This corrects a very common problem with the MRG-based ADB
driver that has bitten many people running 1.3.
 1.34 26-Nov-1997  scottr Don't attempt to open the ADB device if it hasn't been initialized.
Also, don't allow more than one instance to be configured.
 1.33 07-Nov-1997  scottr Update from John Wittkoski: work around problem with mice that claim to
support Extended Mouse Protocol, but really don't; the Logitech Mouseman
is one such mouse (model M-AC13-4MD).
 1.32 05-Nov-1997  ender Recognize Apple Standard Keyboard (ISO layout)
 1.31 02-Oct-1997  briggs branches: 1.31.2;
port-mac68k/4158: current kernel doesn't recognize some adb devices.
Patch applied. Thanks to SUNAGAWA Keiki for the change-request.
 1.30 11-Aug-1997  scottr Make #include directives consistent. All MD headers are of the form:

#include <mac68k/{dev,mac68k}/foo.h>
 1.29 09-Aug-1997  ender o Fixed definition of PowerBook extended keyboard from previous commit
o Added recognition of some additional ADB device types
 1.28 08-Aug-1997  ender Add recognition of more keyboard types (including ISO layouts)
 1.27 16-Jun-1997  scottr branches: 1.27.4;
Add support for Mouse Systems A3 mouse. From Colin Wood.
 1.26 14-Apr-1997  scottr Use the new opt_mrg_adb.h header.
 1.25 08-Apr-1997  scottr Updates from John Wittkoski for new ADB driver.
 1.24 13-Jan-1997  scottr Some changes to make ADB work when compiled with -O2:

- extdms_done is modified by things outside of our direct control;
it needs to be declared `volatile'
- CountADBs() fails when we call it the second time. We can work
around this by telling extdms_init() how many ADB devices we have,
only calling CountADBs() once.
 1.23 13-Oct-1996  christos backout previous kprintf change
 1.22 11-Oct-1996  christos printf -> kprintf, sprintf -> ksprintf
 1.21 21-Jun-1996  scottr Test for serial console in adb_init() early, and abort if we're using it.
Initiialize ROM vectors regardless of this so that the PRAM RTC read and
write work regardless of whether a serial console is in use.
 1.20 08-May-1996  briggs Minor fix to last patch--from Taras.
 1.19 08-May-1996  briggs Minor update from Taras Ivanenko <ivanenko@ctpa03.mit.edu>.
 1.18 05-May-1996  briggs MicroSpeed mouse support from Taras Ivanenko <ivanenko@ctpa03.mit.edu>.
Also some updates to actually used #defined constants instead of numeric
constants.
 1.17 05-May-1996  briggs Prototype for -Wall -Wstrict-prototypes -Wmissing-prototypes -Wno-uninitialized
Also change the device probing scheme to use something a bit more rational.
A current side-effect is that nubus cards are double-mapped. I expect
to fix that shortly.
Also change splclock() to block everything but serial hardware interrupts.
 1.16 29-Mar-1996  briggs via.h -> machine/viareg.h.
 1.15 04-Sep-1995  briggs Remove an extra "talk" command--from Ken Nakata <kenn@remus.rutgers.edu>
 1.14 03-Sep-1995  briggs Add support for Extended Apple Mouse Protocol from
Ken Nakata <kenn@remus.rutgers.edu>.
 1.13 03-Sep-1995  briggs Changes from Walter Ruetten <walter@ghpc8.ihf.rwth-aachen.de>.
This forces the need for booter version 1.8.
 1.12 02-Sep-1995  briggs Weren't quite ready for the last change.
 1.11 02-Sep-1995  briggs Rearrange a bit.
 1.10 25-Jun-1995  briggs Remove a compile warning.
 1.9 21-Apr-1995  briggs First pass of KNFication. Needs more.
 1.8 03-Dec-1994  briggs Mac ROM Glue changes from grantham@tenon.com.
 1.7 26-Oct-1994  cgd new RCS ID format.
 1.6 12-Sep-1994  briggs Nuke a CVS Log entry. Attribute introspection to Brad.
 1.5 12-Sep-1994  briggs Remove need for "bounds.h." Brad can still use it if he wants ;-)
 1.4 30-Jul-1994  lkestel branches: 1.4.2;
Moved adbsys.h grfioctl.h and keyboard.h to include to make desktop
and X compile more cleanly.
 1.3 21-Jul-1994  lkestel Fixed a few bugs in the key-repeat function and disabled key-repeat
when /dev/adb is closed to avoid infinite repeat problem. Brad claims
that he's got this solved in his version...
 1.2 09-Jul-1994  briggs Cleanup a printf, raise the probe timeout, and notice if the probe
does time out.
 1.1 08-Jul-1994  lkestel 6x10.h: shifted font over by two pixels.
keyboard.h: added constants for commonly used keys and reformatted
array so that gcc would be happy.
adbsys.c: new adb system.
bounds.h: bound-checking macros.
ite.c: new built-in mini-console.
8x14.h: no longer used by built-in console.
adb.c: replaced by adbsys.c
 1.4.2.2 12-Sep-1994  cgd from trunk, per briggs
 1.4.2.1 30-Jul-1994  cgd file adbsys.c was added on branch netbsd-1-0 on 1994-09-12 21:07:41 +0000
 1.27.4.2 14-Oct-1997  thorpej Update marc-pcmcia branch from trunk.
 1.27.4.1 23-Aug-1997  thorpej Update marc-pcmcia branch from trunk.
 1.31.2.4 24-Feb-1998  mellon Pull up 1.35 (scottr)
 1.31.2.3 11-Nov-1997  mellon Pull rev 1.33 back up from trunk (scottr)
 1.31.2.2 10-Nov-1997  scottr Back out rev 1.33 changes, as they are part of a separate pull-up
reqeust. (approved by mellon)
 1.31.2.1 07-Nov-1997  mellon Pull rev 1.32 and 1.33 up from trunk (ender)
 1.40.16.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.40.12.1 15-Nov-1999  fvdl Sync with -current
 1.40.10.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.40.4.1 21-Nov-1999  he Pull up revisions 1.41-1.42 (requested by sr):
Clean up the ADB driver, and eliminate duplicate keystrokes under
heavy load, fixing PR#7870.
 1.40.2.1 09-Nov-1999  scottr Sync with main branch.
 1.43.28.4 17-Jan-2005  skrll Sync with HEAD.
 1.43.28.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.43.28.2 18-Sep-2004  skrll Sync with HEAD.
 1.43.28.1 03-Aug-2004  skrll Sync with HEAD
 1.45.10.1 03-Sep-2007  yamt sync with head.
 1.46.26.1 12-Mar-2007  rmind Sync with HEAD.
 1.47.44.1 11-Mar-2010  yamt sync with head
 1.48.64.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.2 30-Jul-1994  mycroft Clean up deleted files.
 1.1 08-Jul-1994  lkestel 6x10.h: shifted font over by two pixels.
keyboard.h: added constants for commonly used keys and reformatted
array so that gcc would be happy.
adbsys.c: new adb system.
bounds.h: bound-checking macros.
ite.c: new built-in mini-console.
8x14.h: no longer used by built-in console.
adb.c: replaced by adbsys.c
 1.13 31-May-2020  rin #ifdef out debug garbage.
 1.12 01-Nov-2009  snj Drop 3rd and 4th clauses. Approved by Brad Grantham (copyright holder).
 1.11 20-Nov-2001  chs branches: 1.11.122;
prepare for ELF:
- add "%" prefix to register names in assembly code.
- use _C_LABEL() where necessary.
- use packed structures where necessary to match the old ABI.
 1.10 14-Feb-2000  scottr branches: 1.10.8; 1.10.12;
Merge wscons work onto the main development branch.
 1.9 11-Feb-1999  ender branches: 1.9.2; 1.9.10;
o Change various attach arg and softc datatypes to ints.
o Use explicit typecasts when interfacing with MRG data

Should fix port-mac68k/6839. Patch supplied by
Frederick Bruckman <fb@enteract.com>
 1.8 26-Oct-1998  scottr Use the <machine/asm.h> macros, and don't call code that we haven't
included.
 1.7 23-Oct-1998  ender New ADB "bus" interface:
o Separate ms and kbd drivers
o aed device for compatibility
o debug message cleanup in hardware direct support (from scottr)
 1.6 07-Nov-1997  scottr Update from John Wittkoski: work around problem with mice that claim to
support Extended Mouse Protocol, but really don't; the Logitech Mouseman
is one such mouse (model M-AC13-4MD).
 1.5 16-Jun-1997  scottr branches: 1.5.8;
Add support for Mouse Systems A3 mouse. From Colin Wood.
 1.4 13-Oct-1996  christos backout previous kprintf change
 1.3 11-Oct-1996  christos printf -> kprintf, sprintf -> ksprintf
 1.2 03-Sep-1995  briggs Add support for Extended Apple Mouse Protocol from
Ken Nakata <kenn@remus.rutgers.edu>.
 1.1 03-Dec-1994  briggs Mac ROM Glue changes from grantham@tenon.com.
 1.5.8.1 11-Nov-1997  mellon Pull rev 1.6 up from trunk (scottr)
 1.9.10.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.9.2.1 05-Mar-1999  scottr checkpoint: input side code should work. no output side yet.
 1.10.12.1 08-Jan-2002  nathanw Catch up to -current.
 1.10.8.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.11.122.1 11-Mar-2010  yamt sync with head
 1.26 01-Nov-2009  snj Drop 3rd and 4th clauses. Approved by Brad Grantham (copyright holder).
 1.25 03-Apr-2008  scottr branches: 1.25.4;
Factor out ADB spin-wait timeout loop, and use it for synchronous
operations to access the PRAM RTC, etc. in the IIsi and Cuda cases.
Thanks to Martin Husemann for pointing out the flaw.

This is a slightly more thorough workaround for the issue Martin found
in PR 37611, as it affected more than just adb_read_date_time().
 1.24 08-Mar-2007  tsutsui branches: 1.24.40;
MI softintr(9)'fy.
Probably problematic, but LC630 is running at single user.
 1.23 11-Dec-2005  christos branches: 1.23.26;
merge ktrace-lwp.
 1.22 15-Jan-2005  chs branches: 1.22.10;
de-__P, remove register, ansify, b* -> mem*.
 1.21 09-Apr-2003  thorpej branches: 1.21.2;
G/c the traceq; nothing uses it.
 1.20 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.19 03-Jul-2000  scottr branches: 1.19.4; 1.19.8; 1.19.16;
Stabilize ADB support for some non-Apple ADB peripherals. This is the
second (and final) part of the fix for PR 10086. (There are no longer
any infinite-wait busy loops in the ADB driver!)
 1.18 19-Mar-2000  scottr branches: 1.18.4;
Add and use macros to build ADB FLUSH, LISTEN, and TALK commands.
 1.17 07-Nov-1999  scottr Garbage collect adb_initted.
 1.16 07-Nov-1999  scottr We need adb_initted in a couple of places; declare it here.
 1.15 28-Jun-1999  briggs branches: 1.15.2; 1.15.4; 1.15.8;
Unfortunately, several changes that are intermingled:
- Add initial IOP support. ADB doesn't work yet for me, but it's here so
that others will be encouraged to work on it. ADB_HW_IOP basically
is configured as a NOP so that serial consoles will continue to work.
- Roll via1_intr and via2_intr into the intr.c scheme--this also required
changing rtclock_intr to grovel the stack differently so that hardclock
gets the right arguments and softclock() doesn't get all reentrant.
- Make via1 interrupts parallel to via2 interrupts--handlers get a pass-
through pointer and we can register handlers. Register via1 interrupt
with intr_establish()--normally level 1, level 6 for A/UX scheme.
- Use intr_establish() to set real via2 interrupt handler instead of the
hacked function pointer.
- Reorganize adb-direct interrupts so that a function call is removed.
- Implement A/UX interrupts for all Quadras right now. We may need to
special case some Quadras, but Linux folks are reporting success on
several models.
- Fix intrnames to be accurate for the normal, PSC, and A/UX interrupt
configurations.
 1.14 11-Feb-1999  ender branches: 1.14.2; 1.14.6;
o Change various attach arg and softc datatypes to ints.
o Use explicit typecasts when interfacing with MRG data

Should fix port-mac68k/6839. Patch supplied by
Frederick Bruckman <fb@enteract.com>
 1.13 14-Nov-1998  briggs Make this compile _and_ link with DEBUG / ADB_DEBUG defined.
 1.12 26-Oct-1998  scottr Don't hide the ADB hardware types when we're building an MRG_ADB kernel;
we really do need them around, anyway.
 1.11 23-Oct-1998  ender New ADB "bus" interface:
o Separate ms and kbd drivers
o aed device for compatibility
o debug message cleanup in hardware direct support (from scottr)
 1.10 23-Feb-1998  scottr Mostly KNF. There's still a bunch of ugly comments and some problems
with long lines, but this is at least a big step in the right direction.
 1.9 21-Feb-1998  scottr Unify ADB options and place them all into opt_adb.h. Provide a knob to
enable ADB debugging messages if ADB_DEBUG is configured.
 1.8 07-Nov-1997  scottr Update from John Wittkoski: work around problem with mice that claim to
support Extended Mouse Protocol, but really don't; the Logitech Mouseman
is one such mouse (model M-AC13-4MD).
 1.7 16-Jun-1997  scottr branches: 1.7.8;
Add support for Mouse Systems A3 mouse. From Colin Wood.
 1.6 08-Apr-1997  scottr Updates from John Wittkoski for new ADB driver.
 1.5 13-Jan-1997  scottr Some changes to make ADB work when compiled with -O2:

- extdms_done is modified by things outside of our direct control;
it needs to be declared `volatile'
- CountADBs() fails when we call it the second time. We can work
around this by telling extdms_init() how many ADB devices we have,
only calling CountADBs() once.
 1.4 14-Sep-1996  scottr Implement poll(2).
 1.3 05-May-1996  briggs Prototype for -Wall -Wstrict-prototypes -Wmissing-prototypes -Wno-uninitialized
Also change the device probing scheme to use something a bit more rational.
A current side-effect is that nubus cards are double-mapped. I expect
to fix that shortly.
Also change splclock() to block everything but serial hardware interrupts.
 1.2 21-Apr-1995  briggs First pass of KNFication. Needs more.
 1.1 03-Dec-1994  briggs Mac ROM Glue changes from grantham@tenon.com.
 1.7.8.1 11-Nov-1997  mellon Pull rev 1.8 up from trunk (scottr)
 1.14.6.1 01-Jul-1999  thorpej Sync w/ -current.
 1.14.2.1 02-Nov-1999  scottr [Redo] Sync with main branch.
 1.15.8.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 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.18.4.1 21-Sep-2000  scottr Pull up rev 1.19 from scottr:
Stabilize ADB support for some non-Apple ADB peripherals.
 1.19.16.1 19-May-2002  gehenna Remove unnecessary prototype.
 1.19.8.1 17-Sep-2002  nathanw Catch up to -current.
 1.19.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.21.2.1 17-Jan-2005  skrll Sync with HEAD.
 1.22.10.1 03-Sep-2007  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.4.1 11-Mar-2010  yamt sync with head
 1.43 03-Apr-2025  nat Add pbbat(4)

Now it is possible to monitor the PowerBook 1xx AC adaptors and battery via
envsys(4).
 1.42 12-Jan-2025  nat Stop echoing keys for special key sequences.

This includes brightness and emulated mouse buttons.
 1.41 09-Dec-2024  nat Add support for backlight control.

Currently it is only supported on PowerBooks.
The backlight can be turned off or on via pmf(9) events on wsdisplay(4)
devices.
 1.40 14-Sep-2024  nat Add support for brightness control on Powerbook 1xx.
 1.39 05-Jun-2024  nat branches: 1.39.2;
Pass event up to adb device.

While here do the same for macppc.

Addresses PR/58303
 1.38 26-Sep-2021  thorpej branches: 1.38.4;
Driver "kqfilter" entry points return an error code, so if an invalid
filter is requested, return EINVAL rather than 1.
 1.37 26-Sep-2021  thorpej Use seltrue_filtops rather than rolling our own with filt_seltrue.
 1.36 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.35 19-Dec-2020  thorpej Use sel{record,remove}_knote().
 1.34 25-Oct-2017  maya branches: 1.34.8; 1.34.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.33 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.32 16-Mar-2014  dholland branches: 1.32.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.31 19-Oct-2013  martin comment out unused code (for documentation purposes)
 1.30 27-Oct-2012  chs branches: 1.30.2;
split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.29 01-Nov-2009  snj branches: 1.29.12; 1.29.22;
Drop 3rd and 4th clauses. Approved by Brad Grantham (copyright holder).
 1.28 11-Jun-2008  cegger use device_lookup_private to get softc
 1.27 01-Mar-2008  rmind branches: 1.27.2; 1.27.4; 1.27.6; 1.27.8;
Welcome to 4.99.55:

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

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

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

Note: please pass appropriate value of 'events' where possible.
Proposed on: <tech-kern>
 1.26 03-Dec-2007  ad branches: 1.26.10; 1.26.14;
Interrupt handling changes, in discussion since February:

- Reduce available SPL levels for hardware devices to none, vm, sched, high.
- Acquire kernel_lock only for interrupts at IPL_VM.
- Implement threaded soft interrupts.
 1.25 17-Oct-2007  garbled branches: 1.25.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.24 09-Jul-2007  ad branches: 1.24.8; 1.24.10;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements
 1.23 04-Mar-2007  christos branches: 1.23.2; 1.23.4; 1.23.10;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.22 29-Mar-2006  thorpej branches: 1.22.14;
Use device_cfdata().
 1.21 11-Dec-2005  christos branches: 1.21.4; 1.21.6; 1.21.8; 1.21.10; 1.21.12;
merge ktrace-lwp.
 1.20 05-Jun-2005  rjs branches: 1.20.2;
Rename shadowing variable.
 1.19 16-Jan-2005  chs branches: 1.19.2;
don't require that the aed unit number be zero.
 1.18 15-Jan-2005  chs de-__P, remove register, ansify, b* -> mem*.
 1.17 15-Jul-2003  lukem __KERNEL_RCSID()
 1.16 26-Nov-2002  christos branches: 1.16.6;
si_ -> sel_
 1.15 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.14 02-Oct-2002  thorpej Use CFATTACH_DECL().
 1.13 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.12 27-Sep-2002  provos remove trailing \n in panic(). approved perry.
 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.6; 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 14-Feb-2000  scottr Merge wscons work onto the main development branch.
 1.8 07-Nov-1999  scottr ite_polling -> adb_polling
 1.7 16-Feb-1999  ender branches: 1.7.2; 1.7.4; 1.7.10; 1.7.12; 1.7.16;
Add NetBSD RCS Id's
 1.6 11-Feb-1999  ender o Change various attach arg and softc datatypes to ints.
o Use explicit typecasts when interfacing with MRG data

Should fix port-mac68k/6839. Patch supplied by
Frederick Bruckman <fb@enteract.com>
 1.5 19-Dec-1998  scottr Protect a keyup event for ADBK_3 in the mouse button emulation code with
ALTXBUTTONS, so as to not cause trouble with some non-US English
keyboards. From SUNAGAWA Keiki, PR 6613.
 1.4 28-Nov-1998  ender Remember to recognize modifier key releases when the Option key is down.
Fixes art of PR 6444. Tested by Frederick Bruckman <fb@enteract.com>.
 1.3 24-Nov-1998  ender Take emulated button state into account before handing off mouse events.
Fixes part of PR 6444. Tested by Frederick Bruckman (fb@enteract.com).
 1.2 26-Oct-1998  ender Make the kernel compile when the ALTXBUTTONS option is set.
Fixes PR#6363 from Frederick Bruckman (fb@enteract.com)
 1.1 23-Oct-1998  ender New ADB "bus" interface:
o Separate ms and kbd drivers
o aed device for compatibility
o debug message cleanup in hardware direct support (from scottr)
 1.7.16.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.7.12.1 15-Nov-1999  fvdl Sync with -current
 1.7.10.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.7.4.1 21-Nov-1999  he Pull up revision 1.8 (requested by sr):
Clean up the ADB driver, and eliminate duplicate keystrokes under
heavy load, fixing PR#7870.
 1.7.2.4 15-Nov-1999  scottr Avoid passing data up to wskbd if the aed device is open.
 1.7.2.3 09-Nov-1999  scottr Sync with main branch.
 1.7.2.2 11-Mar-1999  scottr We no longer have ite or grf in files.mac68k.
 1.7.2.1 05-Mar-1999  scottr checkpoint: input side code should work. no output side yet.
 1.10.20.1 17-May-2002  gehenna Add device switch.
 1.10.12.4 11-Dec-2002  thorpej Sync with HEAD.
 1.10.12.3 11-Nov-2002  nathanw Catch up to -current
 1.10.12.2 18-Oct-2002  nathanw Catch up to -current.
 1.10.12.1 17-Sep-2002  nathanw Catch up to -current.
 1.10.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.10.8.2 18-Jun-2002  jdolecek g/c prototypes from aedvar.h, use cdev_decl(), compile fixes
 1.10.8.1 09-Sep-2001  thorpej Add kqueue support (not yet compiled).
 1.10.6.1 10-Oct-2001  fvdl Convert all remaining devices.
 1.16.6.6 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.16.6.5 25-Jan-2005  skrll Adapt to branch.
 1.16.6.4 17-Jan-2005  skrll Sync with HEAD.
 1.16.6.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.16.6.2 18-Sep-2004  skrll Sync with HEAD.
 1.16.6.1 03-Aug-2004  skrll Sync with HEAD
 1.19.2.2 16-Jan-2005  chs don't require that the aed unit number be zero.
 1.19.2.1 16-Jan-2005  chs file aed.c was added on branch kent-audio2 on 2005-01-16 00:32:17 +0000
 1.20.2.4 17-Mar-2008  yamt sync with head.
 1.20.2.3 07-Dec-2007  yamt sync with head
 1.20.2.2 03-Sep-2007  yamt sync with head.
 1.20.2.1 21-Jun-2006  yamt sync with head.
 1.21.12.1 31-Mar-2006  tron Merge 2006-03-31 NetBSD-current into the "peter-altq" branch.
 1.21.10.1 19-Apr-2006  elad sync with head - hopefully this will work
 1.21.8.1 01-Apr-2006  yamt sync with head.
 1.21.6.1 22-Apr-2006  simonb Sync with head.
 1.21.4.1 09-Sep-2006  rpaulo sync with head
 1.22.14.1 12-Mar-2007  rmind Sync with HEAD.
 1.23.10.1 03-Oct-2007  garbled Sync with HEAD
 1.23.4.1 11-Jul-2007  mjf Sync with head.
 1.23.2.2 03-Dec-2007  ad Sync with HEAD.
 1.23.2.1 15-Jul-2007  ad Sync with head.
 1.24.10.3 23-Mar-2008  matt sync with HEAD
 1.24.10.2 09-Jan-2008  matt sync with HEAD
 1.24.10.1 06-Nov-2007  matt sync with HEAD
 1.24.8.1 09-Dec-2007  jmcneill Sync with HEAD.
 1.25.2.1 08-Dec-2007  mjf Sync with HEAD.
 1.26.14.2 29-Jun-2008  mjf Sync with HEAD.
 1.26.14.1 03-Apr-2008  mjf Sync with HEAD.
 1.26.10.1 24-Mar-2008  keiichi sync with head.
 1.27.8.1 18-Jun-2008  simonb Sync with head.
 1.27.6.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.27.4.2 11-Mar-2010  yamt sync with head
 1.27.4.1 04-May-2009  yamt sync with head.
 1.27.2.1 17-Jun-2008  yamt sync with head.
 1.29.22.3 03-Dec-2017  jdolecek update from HEAD
 1.29.22.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.29.22.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.29.12.2 22-May-2014  yamt sync with head.

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

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

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

Pass event up to adb device.

While here do the same for macppc.

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

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

Pass event up to adb device.

While here do the same for macppc.

Addresses PR/58303
 1.39.2.1 02-Aug-2025  perseant Sync with HEAD
 1.9 27-Oct-2012  chs split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.8 01-Nov-2009  snj branches: 1.8.12; 1.8.22;
Drop 3rd and 4th clauses. Approved by Brad Grantham (copyright holder).
 1.7 11-Dec-2005  christos branches: 1.7.78;
merge ktrace-lwp.
 1.6 15-Jan-2005  chs de-__P, remove register, ansify, b* -> mem*.
 1.5 06-Sep-2002  gehenna branches: 1.5.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.4 23-Mar-2000  thorpej branches: 1.4.6; 1.4.8; 1.4.12; 1.4.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.3 14-Feb-2000  scottr Merge wscons work onto the main development branch.
 1.2 11-Feb-1999  ender branches: 1.2.2; 1.2.10;
o Change various attach arg and softc datatypes to ints.
o Use explicit typecasts when interfacing with MRG data

Should fix port-mac68k/6839. Patch supplied by
Frederick Bruckman <fb@enteract.com>
 1.1 23-Oct-1998  ender New ADB "bus" interface:
o Separate ms and kbd drivers
o aed device for compatibility
o debug message cleanup in hardware direct support (from scottr)
 1.2.10.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.2.2.1 15-Nov-1999  scottr Avoid passing data up to wskbd if the aed device is open.
 1.4.20.1 19-May-2002  gehenna Remove unnecessary prototype.
 1.4.12.1 17-Sep-2002  nathanw Catch up to -current.
 1.4.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.4.8.1 18-Jun-2002  jdolecek g/c prototypes from aedvar.h, use cdev_decl(), compile fixes
 1.4.6.1 10-Oct-2001  fvdl Convert all remaining devices.
 1.5.6.1 17-Jan-2005  skrll Sync with HEAD.
 1.7.78.1 11-Mar-2010  yamt sync with head
 1.8.22.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.8.12.1 30-Oct-2012  yamt sync with head
 1.28 12-Jan-2025  nat Stop echoing keys for special key sequences.

This includes brightness and emulated mouse buttons.
 1.27 18-Sep-2021  tsutsui branches: 1.27.10;
Remove unnecessary (and unimplemented) WSKBD_*BELL ioctls in kbd drivers.

It looks the only ioctl(4) to be implemented for WSKBDIO_*BELL in
the backend keyboard driver is WSKBDIO_COMPLEXBELL.
All other BELL ioctls (WSKBDIO_BELL, WSKBDIO_SETBELL, WSKBDIO_GETBELL,
WSKBDIO_SETDEFAULTBELL, and WSKBDIO_GETDEFAULTBELL) are handled in the
MI wskbd driver (in wskbd_displayioctl() in src/sys/dev/wscons/wskbd.c).
 1.26 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.25 24-Apr-2021  thorpej branches: 1.25.8;
Merge thorpej-cfargs branch:

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

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

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

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

...and a sentinel value CFARG_EOL.

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

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).
 1.24 25-Oct-2013  martin branches: 1.24.44;
Mark a potentially unused variable
 1.23 27-Oct-2012  chs branches: 1.23.2;
split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.22 10-Dec-2010  macallan branches: 1.22.8; 1.22.18;
return the right values for ioctl(WSKBDIO_GTYPE) and ioctl(WSMOUSEIO_GTYPE)
fixes PR 23991
 1.21 10-Mar-2007  hauke branches: 1.21.66;
Fix more fallout from caddr_t removal.

Since kbd_adbcomplete() uses the buffer parameter for accessing a
(sic!) data buffer, make it uint8_t *, instead of casting the pointer
everywhere it is actually used.

While here, fix prototype naming issue. One of these days, the code
should be converted to either all kbd_*, or all akbd_*.
 1.20 05-Mar-2007  he Cast to uint8_t* or char* before indexing or doing pointer arithmetic.
 1.19 04-Mar-2007  christos Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.18 11-Dec-2005  christos branches: 1.18.26;
merge ktrace-lwp.
 1.17 15-Jan-2005  chs branches: 1.17.10;
de-__P, remove register, ansify, b* -> mem*.
 1.16 15-Jul-2003  lukem __KERNEL_RCSID()
 1.15 02-Oct-2002  thorpej branches: 1.15.6;
Use CFATTACH_DECL().
 1.14 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.13 17-Mar-2002  atatat Convert ioctl code to use EPASSTHROUGH instead of -1 or ENOTTY for
indicating an unhandled "command". ERESTART is -1, which can lead to
confusion. ERESTART has been moved to -3 and EPASSTHROUGH has been
placed at -4. No ioctl code should now return -1 anywhere. The
ioctl() system call is now properly restartable.
 1.12 05-Jun-2001  thorpej branches: 1.12.2; 1.12.8;
HZ -> hz
 1.11 22-Sep-2000  scottr branches: 1.11.2;
Attach exactly one keyboard to the wscons console.
 1.10 03-Jul-2000  scottr Stabilize ADB support for some non-Apple ADB peripherals. This is the
second (and final) part of the fix for PR 10086. (There are no longer
any infinite-wait busy loops in the ADB driver!)
 1.9 17-Jun-2000  scottr branches: 1.9.2;
Since interrupts are now enabled during ADB autoconfig, it's possible to get
a keyboard event before wskbd is attached. Make sure we've done that before
passing an event to kbd_intr(), which in turn hands off to wskbd_input().
This is another part of the fix for PR 10086.
 1.8 17-Jun-2000  scottr Only the first device that we're sure is a keyboard should be attached
as the wskbd console device. (Part of the fix for PR 10086.)
 1.7 19-Mar-2000  scottr branches: 1.7.2;
Add and use macros to build ADB FLUSH, LISTEN, and TALK commands.
 1.6 17-Feb-2000  ender Include mac68k/dev/akbdmap.h, not macppc/dev/akbdmap.h. Fixes PR 9435
filed by Dave Huang <khym@bga.com>.
 1.5 14-Feb-2000  scottr Merge wscons work onto the main development branch.
 1.4 05-Mar-1999  scottr branches: 1.4.2;
These files were created by repository copy for use on the
scottr-mac68k-wscons branch.
 1.3 16-Feb-1999  ender branches: 1.3.2;
Add NetBSD RCS Id's
 1.2 11-Feb-1999  ender o Change various attach arg and softc datatypes to ints.
o Use explicit typecasts when interfacing with MRG data

Should fix port-mac68k/6839. Patch supplied by
Frederick Bruckman <fb@enteract.com>
 1.1 23-Oct-1998  ender New ADB "bus" interface:
o Separate ms and kbd drivers
o aed device for compatibility
o debug message cleanup in hardware direct support (from scottr)
 1.3.2.7 20-Nov-1999  scottr Cosmetic changes to make a bit of #ifdef'ed code slightly less ugly.
 1.3.2.6 18-Nov-1999  scottr If we're polling, i.e. in the debugger, we really ought to make
sure to pass events on up. The debugger is kind of useless without
a console keyboard...
 1.3.2.5 15-Nov-1999  scottr Avoid passing data up to wskbd if the aed device is open.
 1.3.2.4 11-Mar-1999  scottr Pull in opt_adb.h for ADB_DEBUG
 1.3.2.3 10-Mar-1999  scottr Make akbd_cngetc() work for the MRG-based driver.
 1.3.2.2 08-Mar-1999  scottr Add output-side support, using existing intvid/macvid support.
 1.3.2.1 05-Mar-1999  scottr checkpoint: input side code should work. no output side yet.
 1.4.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.7.2.1 22-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.9.2.2 22-Sep-2000  scottr Pull up rev 1.11 from scottr:
Attach exactly one keyboard to the wscons console.
 1.9.2.1 21-Sep-2000  scottr Pull up rev 1.10 from scottr:
Stabilize ADB support for some non-Apple ADB peripherals.
 1.11.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.12.8.3 18-Oct-2002  nathanw Catch up to -current.
 1.12.8.2 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.12.8.1 05-Jun-2001  nathanw file akbd.c was added on branch nathanw_sa on 2002-04-01 07:40:48 +0000
 1.12.2.2 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.12.2.1 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.15.6.5 25-Jan-2005  skrll Adapt to branch.
 1.15.6.4 17-Jan-2005  skrll Sync with HEAD.
 1.15.6.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.15.6.2 18-Sep-2004  skrll Sync with HEAD.
 1.15.6.1 03-Aug-2004  skrll Sync with HEAD
 1.17.10.2 03-Sep-2007  yamt sync with head.
 1.17.10.1 21-Jun-2006  yamt sync with head.
 1.18.26.1 12-Mar-2007  rmind Sync with HEAD.
 1.21.66.1 05-Mar-2011  rmind sync with head
 1.22.18.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.22.18.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.22.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.22.8.1 30-Oct-2012  yamt sync with head
 1.23.2.1 18-May-2014  rmind sync with head
 1.24.44.1 21-Mar-2021  thorpej Give config_found() the same variadic arguments treatment as
config_search(). This commit only adds the CFARG_EOL sentinel
to the existing config_found() calls. Conversion of config_found_sm_loc()
and config_found_ia() call sites will be in subsequent commits.
 1.25.8.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.27.10.1 02-Aug-2025  perseant Sync with HEAD
 1.10 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.9 08-Nov-2006  macallan branches: 1.9.52; 1.9.54; 1.9.56;
add control codes for virtual console switching
looks like I forgot to commit this ages ago...
 1.8 11-Dec-2005  christos branches: 1.8.20; 1.8.22;
merge ktrace-lwp.
 1.7 05-May-2005  abs branches: 1.7.2;
Add ADB Portuguese (pt_PT) keyboard map, from Rui Paulo in PR/30126
 1.6 30-Oct-2004  mbw branches: 1.6.10;
Change to fix PR 25689 for Swedish ADB keyboards
- KC(52), KS_Mode_switch,KS_Multi_key,
+ KC(58), KS_Mode_switch,KS_Multi_key,
 1.5 19-Jul-2004  jmmv Add the Spanish keymap.

While here, add support for the Num Lock key (with all needed changes in the
numeric keypad), Print Screen, Hold Screen, Pause, Insert, and Delete.

Ok'ed by silence in port-mac68k@.
 1.4 23-Feb-2003  manu branches: 1.4.2; 1.4.6;
Merged mac68k and macppc keayboards, since they are the same. The file
could move to <arch/mac> if one day we create it.

Fixed french keymap: option was not mapped correctly, thus making
impossible to use |{}[] (tested).
Added jp keymap from PR/15438, and sf, sv, de and uk keymaps from OpenBSD.
(all untested).
 1.3 22-Feb-2003  manu Added a french keyboard layout.
 1.2 14-Feb-2000  scottr branches: 1.2.22;
Merge wscons work onto the main development branch.
 1.1 05-Mar-1999  scottr branches: 1.1.2; 1.1.4;
file akbdmap.h was initially added on branch scottr-mac68k-wscons.
 1.1.4.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.1.2.1 05-Mar-1999  scottr checkpoint: input side code should work. no output side yet.
 1.2.22.1 02-Jun-2003  tron Pull up revision 1.3-1.4 (requested by manu in ticket #1183):
Added a french keyboard layout.
Merged mac68k and macppc keayboards, since they are the same. The file
could move to <arch/mac> if one day we create it.
Fixed french keymap: option was not mapped correctly, thus making
impossible to use |{}[] (tested).
Added jp keymap from PR/15438, and sf, sv, de and uk keymaps from
OpenBSD.
(all untested).
 1.4.6.1 16-May-2005  riz Pull up revision 1.7 via patch (requested by abs in ticket #1506):
Add ADB Portuguese (pt_PT) keyboard map, from Rui Paulo in PR/30126
 1.4.2.3 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.4.2.2 02-Nov-2004  skrll Sync with HEAD.
 1.4.2.1 03-Aug-2004  skrll Sync with HEAD
 1.6.10.1 09-May-2005  tron Pull up revision 1.7 (requested by abs in ticket #268):
Add ADB Portuguese (pt_PT) keyboard map, from Rui Paulo in PR/30126
 1.7.2.1 30-Dec-2006  yamt sync with head.
 1.8.22.1 10-Dec-2006  yamt sync with head.
 1.8.20.1 18-Nov-2006  ad Sync with head.
 1.9.56.1 16-May-2008  yamt sync with head.
 1.9.54.1 18-May-2008  yamt sync with head.
 1.9.52.1 02-Jun-2008  mjf Sync with HEAD.
 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 10-Mar-2007  hauke branches: 1.9.78; 1.9.88;
Fix more fallout from caddr_t removal.

Since kbd_adbcomplete() uses the buffer parameter for accessing a
(sic!) data buffer, make it uint8_t *, instead of casting the pointer
everywhere it is actually used.

While here, fix prototype naming issue. One of these days, the code
should be converted to either all kbd_*, or all akbd_*.
 1.8 04-Mar-2007  christos Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.7 11-Dec-2005  christos branches: 1.7.26;
merge ktrace-lwp.
 1.6 15-Jan-2005  chs branches: 1.6.10;
de-__P, remove register, ansify, b* -> mem*.
 1.5 14-Feb-2000  scottr branches: 1.5.28;
Merge wscons work onto the main development branch.
 1.4 05-Mar-1999  scottr branches: 1.4.2;
These files were created by repository copy for use on the
scottr-mac68k-wscons branch.
 1.3 16-Feb-1999  ender branches: 1.3.2;
Add NetBSD RCS Id's
 1.2 11-Feb-1999  ender o Change various attach arg and softc datatypes to ints.
o Use explicit typecasts when interfacing with MRG data

Should fix port-mac68k/6839. Patch supplied by
Frederick Bruckman <fb@enteract.com>
 1.1 23-Oct-1998  ender New ADB "bus" interface:
o Separate ms and kbd drivers
o aed device for compatibility
o debug message cleanup in hardware direct support (from scottr)
 1.3.2.1 05-Mar-1999  scottr checkpoint: input side code should work. no output side yet.
 1.4.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.5.28.1 17-Jan-2005  skrll Sync with HEAD.
 1.6.10.1 03-Sep-2007  yamt sync with head.
 1.7.26.1 12-Mar-2007  rmind Sync with HEAD.
 1.9.88.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.9.78.1 30-Oct-2012  yamt sync with head
 1.28 16-Dec-2024  nat Fix matching of the PowerBook 500 trackpad.

Addresses PR port-mac68k/58883.
 1.27 07-Dec-2024  nat Usability enhancement.

For the emulated middle and right mouse buttons, one has to hold the combo keys
and it is sent on the mouse click.

Patch from PR applied.

Addresses PR mac68k/58672.
 1.26 30-Jul-2022  rin branches: 1.26.10;
Fix WSMOUSEIO_GTYPE so that X does not fail to initialize wsmouse(4).
 1.25 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.24 24-Apr-2021  thorpej branches: 1.24.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.23 09-Jun-2020  tsutsui branches: 1.23.4;
Fix inverted Y-axis value passed to wsmouse_input(9).

Note this is what src/sys/arch/macppc/dev/ams.c does as
"upward (moving the mouse forward) is positive" as noted in wsmouse(9):
http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/arch/macppc/dev/ams.c#rev1.4

Reported and tested by @NonameInsect on his SE/30 and Xorg server.
Should be pulled up to netbsd-8 and netbsd-9.
 1.22 19-Oct-2013  martin branches: 1.22.22; 1.22.34;
Mark a potentially unused variable
 1.21 27-Oct-2012  chs branches: 1.21.2;
split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.20 10-Dec-2010  macallan branches: 1.20.8; 1.20.18;
return the right values for ioctl(WSKBDIO_GTYPE) and ioctl(WSMOUSEIO_GTYPE)
fixes PR 23991
 1.19 05-Mar-2007  he branches: 1.19.66;
Use a helper variable so that we can index it as an array.
 1.18 04-Mar-2007  christos Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.17 12-Nov-2006  plunky branches: 1.17.4;
Tidy away wsmouse_input() abstractions and update
documentation to include the W direction.
 1.16 11-Dec-2005  christos branches: 1.16.20; 1.16.22;
merge ktrace-lwp.
 1.15 15-Jan-2005  chs branches: 1.15.10;
de-__P, remove register, ansify, b* -> mem*.
 1.14 15-Jul-2003  lukem __KERNEL_RCSID()
 1.13 02-Oct-2002  thorpej branches: 1.13.6;
Use CFATTACH_DECL().
 1.12 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.11 17-Mar-2002  atatat Convert ioctl code to use EPASSTHROUGH instead of -1 or ENOTTY for
indicating an unhandled "command". ERESTART is -1, which can lead to
confusion. ERESTART has been moved to -3 and EPASSTHROUGH has been
placed at -4. No ioctl code should now return -1 anywhere. The
ioctl() system call is now properly restartable.
 1.10 01-Oct-2000  scottr branches: 1.10.4; 1.10.8;
In ems_init(): make sure there's valid data in the buffer after sending
a TALK command to a device. Noticed by Ken'ichi Ishizaka.
 1.9 03-Jul-2000  scottr Stabilize ADB support for some non-Apple ADB peripherals. This is the
second (and final) part of the fix for PR 10086. (There are no longer
any infinite-wait busy loops in the ADB driver!)
 1.8 11-Jun-2000  scottr branches: 1.8.2;
Since interrupts are now enabled during ADB autoconfig, it's possible
to get a mouse event before wsmouse is attached. Make sure we've done
that before passing an event to wsmouse_input().
 1.7 19-Mar-2000  scottr branches: 1.7.2;
Add and use macros to build ADB FLUSH, LISTEN, and TALK commands.
 1.6 14-Feb-2000  scottr Merge wscons work onto the main development branch.
 1.5 05-Mar-1999  scottr branches: 1.5.2;
These files were created by repository copy for use on the
scottr-mac68k-wscons branch.
 1.4 16-Feb-1999  ender branches: 1.4.2;
Add NetBSD RCS Id's
 1.3 11-Feb-1999  ender o Change various attach arg and softc datatypes to ints.
o Use explicit typecasts when interfacing with MRG data

Should fix port-mac68k/6839. Patch supplied by
Frederick Bruckman <fb@enteract.com>
 1.2 16-Jan-1999  scottr Add support for the Contour 3-button mouse, inadvertantly missed
in the ADB split a few months back. Noticed by Takashi NAKAMURA.
 1.1 23-Oct-1998  ender New ADB "bus" interface:
o Separate ms and kbd drivers
o aed device for compatibility
o debug message cleanup in hardware direct support (from scottr)
 1.4.2.5 13-Feb-2000  scottr Fix return value of iteioctl().
 1.4.2.4 13-Feb-2000  scottr Catch up with wsmouse_input() interface change.
 1.4.2.3 20-Nov-1999  scottr Pass input up to the wsmouse driver. From Colin (mostly).
 1.4.2.2 15-Nov-1999  scottr Avoid passing data up to wskbd if the aed device is open.
 1.4.2.1 05-Mar-1999  scottr checkpoint: input side code should work. no output side yet.
 1.5.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.7.2.1 22-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.8.2.2 15-Nov-2000  tv Pullup 1.10 [scottr]:
In ems_init(): make sure there's valid data in the buffer after sending
a TALK command to a device. Noticed by Ken'ichi Ishizaka.
 1.8.2.1 21-Sep-2000  scottr Pull up rev 1.9 from scottr:
Stabilize ADB support for some non-Apple ADB peripherals.
 1.10.8.2 18-Oct-2002  nathanw Catch up to -current.
 1.10.8.1 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.10.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.10.4.1 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.13.6.5 25-Jan-2005  skrll Adapt to branch.
 1.13.6.4 17-Jan-2005  skrll Sync with HEAD.
 1.13.6.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.13.6.2 18-Sep-2004  skrll Sync with HEAD.
 1.13.6.1 03-Aug-2004  skrll Sync with HEAD
 1.15.10.3 03-Sep-2007  yamt sync with head.
 1.15.10.2 30-Dec-2006  yamt sync with head.
 1.15.10.1 21-Jun-2006  yamt sync with head.
 1.16.22.1 10-Dec-2006  yamt sync with head.
 1.16.20.1 18-Nov-2006  ad Sync with head.
 1.17.4.1 12-Mar-2007  rmind Sync with HEAD.
 1.19.66.1 05-Mar-2011  rmind sync with head
 1.20.18.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.20.18.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.20.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.20.8.1 30-Oct-2012  yamt sync with head
 1.21.2.1 18-May-2014  rmind sync with head
 1.22.34.1 20-Jun-2020  martin Pull up following revision(s) (requested by tsutsui in ticket #955):

sys/arch/mac68k/dev/ams.c: revision 1.23

Fix inverted Y-axis value passed to wsmouse_input(9).

Note this is what src/sys/arch/macppc/dev/ams.c does as
"upward (moving the mouse forward) is positive" as noted in wsmouse(9):
http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/arch/macppc/dev/ams.c#rev1.4

Reported and tested by @NonameInsect on his SE/30 and Xorg server.
Should be pulled up to netbsd-8 and netbsd-9.
 1.22.22.1 16-Jun-2020  bouyer Pull up following revision(s) (requested by tsutsui in ticket #1557):
sys/arch/mac68k/dev/ams.c: revision 1.23
Fix inverted Y-axis value passed to wsmouse_input(9).
Note this is what src/sys/arch/macppc/dev/ams.c does as
"upward (moving the mouse forward) is positive" as noted in wsmouse(9):
http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/arch/macppc/dev/ams.c#rev1.4
Reported and tested by @NonameInsect on his SE/30 and Xorg server.
Should be pulled up to netbsd-8 and netbsd-9.
 1.23.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.24.8.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.26.10.1 02-Aug-2025  perseant Sync with HEAD
 1.11 27-Jun-2025  andvar Grammar and spelling fixes, mainly in comments. A few in documentation,
logging, test description, and SCSI ASC/ASCQ assignment descriptions.
 1.10 07-Dec-2024  nat Usability enhancement.

For the emulated middle and right mouse buttons, one has to hold the combo keys
and it is sent on the mouse click.

Patch from PR applied.

Addresses PR mac68k/58672.
 1.9 27-Oct-2012  chs branches: 1.9.74;
split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.8 04-Mar-2007  christos branches: 1.8.78; 1.8.88;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.7 11-Dec-2005  christos branches: 1.7.26;
merge ktrace-lwp.
 1.6 15-Jan-2005  chs branches: 1.6.10;
de-__P, remove register, ansify, b* -> mem*.
 1.5 14-Feb-2000  scottr branches: 1.5.28;
Merge wscons work onto the main development branch.
 1.4 05-Mar-1999  scottr branches: 1.4.2;
These files were created by repository copy for use on the
scottr-mac68k-wscons branch.
 1.3 16-Feb-1999  ender branches: 1.3.2;
Add NetBSD RCS Id's
 1.2 11-Feb-1999  ender o Change various attach arg and softc datatypes to ints.
o Use explicit typecasts when interfacing with MRG data

Should fix port-mac68k/6839. Patch supplied by
Frederick Bruckman <fb@enteract.com>
 1.1 23-Oct-1998  ender New ADB "bus" interface:
o Separate ms and kbd drivers
o aed device for compatibility
o debug message cleanup in hardware direct support (from scottr)
 1.3.2.1 05-Mar-1999  scottr checkpoint: input side code should work. no output side yet.
 1.4.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.5.28.1 17-Jan-2005  skrll Sync with HEAD.
 1.6.10.1 03-Sep-2007  yamt sync with head.
 1.7.26.1 12-Mar-2007  rmind Sync with HEAD.
 1.8.88.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.8.78.1 30-Oct-2012  yamt sync with head
 1.9.74.1 02-Aug-2025  perseant Sync with HEAD
 1.27 02-May-1998  scottr Move on-board I/O and NuBus drivers to their own directories
via repository copy, and make the necessary adjustments to reflect
the moved files.
 1.26 13-Jan-1998  scottr Update for bus.h changes.
 1.25 12-Jan-1998  thorpej Update for changes to config.
 1.24 10-Oct-1997  scottr branches: 1.24.2;
Remove advertising clause.
 1.23 16-Sep-1997  scottr Set up base address of ASC for IIfx, per GtMFH.
 1.22 11-Aug-1997  scottr Make #include directives consistent. All MD headers are of the form:

#include <mac68k/{dev,mac68k}/foo.h>
 1.21 10-Jun-1997  veego branches: 1.21.4;
s/mac68k_btop/m68k_btop/
 1.20 24-Feb-1997  scottr Update copyright and license.
 1.19 13-Feb-1997  scottr Remove redundant info from bus_space_map() diagnostic in ascattach()
 1.18 11-Feb-1997  scottr Add a bus space tag field to obio_attach args, initialize it in
obio_search(), and use it in the ASC driver. Thanks to Jason for
pointing this out. Minor KNFing while I'm here.
 1.17 11-Feb-1997  scottr Complete revamp of Apple Sound Chip support. The ASC can now be accessed
as a real device whose registers and buffers are available through mmap(2),
which makes further development of the driver considerably less painful.
 1.16 03-Feb-1997  scottr branches: 1.16.2;
Convert to bus.h; this removes the need for the ASCBase global.
 1.15 16-Dec-1996  scottr Convert all foo_match() functions to use a `struct cfdata *' for their
second argument. The NuBus autoconfig code had to be reorganized as a
result of this, and looks much more like a directly-attached bus now.
These changes eliminate __BROKEN_INDIRECT_CONFIG.
 1.14 09-Nov-1996  briggs Check to make sure that ASCBase is accessable before claiming that we
have an Apple Sound Chip. Make sure that we have configured the device
before allowing accesses to ASC memory. Among other things, this
prevents the 660AV and 840AV from getting a kernel bus error when trying
to beep on the console.
 1.13 13-Oct-1996  christos backout previous kprintf change
 1.12 11-Oct-1996  christos printf -> kprintf, sprintf -> ksprintf
 1.11 05-May-1996  briggs Prototype for -Wall -Wstrict-prototypes -Wmissing-prototypes -Wno-uninitialized
Also change the device probing scheme to use something a bit more rational.
A current side-effect is that nubus cards are double-mapped. I expect
to fix that shortly.
Also change splclock() to block everything but serial hardware interrupts.
 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 01-Nov-1995  briggs Remove bogus assignment.
 1.8 21-Sep-1995  briggs Fix warning and use __P for prototypes.
 1.7 21-Apr-1995  briggs First pass of KNFication. Needs more.
 1.6 26-Oct-1994  cgd new RCS ID format.
 1.5 21-Jul-1994  briggs Make this into more of a device so it can be probed and attached. Nuke
RCS/CVS Log. Make ASCBase an offset instead of an absolute.
 1.4 26-Jun-1994  briggs branches: 1.4.2;
Minor mods. Get rid of constants, or update to use a better default
value.
 1.3 06-May-1994  briggs Missed some warnings...
 1.2 06-May-1994  briggs Clean up some warnings, mainly w/ timeout().
 1.1 21-Dec-1993  briggs Add basic sound support and a beeping (instead of flashing) console...
from Brad Grantham.
 1.4.2.1 24-Jul-1994  cgd update, as requested by briggs
 1.16.2.1 12-Mar-1997  is Merge in changes from The Trunk, partially just reimplementing newarp.
 1.21.4.3 14-Oct-1997  thorpej Update marc-pcmcia branch from trunk.
 1.21.4.2 22-Sep-1997  thorpej Update marc-pcmcia branch from trunk.
 1.21.4.1 23-Aug-1997  thorpej Update marc-pcmcia branch from trunk.
 1.24.2.1 23-Nov-1998  cgd Fix many real and potential security problems with character device
driver mmap routines that did not properly bounds check offsets.
See NetBSD security advisory NetBSD-SA1998-005 for details. Done
as a patch because it's large, and a fair number of bits are different
in -current. (mrg)
 1.4 11-Feb-1997  scottr Complete revamp of Apple Sound Chip support. The ASC can now be accessed
as a real device whose registers and buffers are available through mmap(2),
which makes further development of the driver considerably less painful.
 1.3 21-Apr-1995  briggs branches: 1.3.8;
First pass of KNFication. Needs more.
 1.2 26-Oct-1994  cgd new RCS ID format.
 1.1 21-Dec-1993  briggs Add basic sound support and a beeping (instead of flashing) console...
from Brad Grantham.
 1.3.8.1 12-Mar-1997  is Merge in changes from The Trunk, partially just reimplementing newarp.
 1.5 02-May-1998  scottr Move on-board I/O and NuBus drivers to their own directories
via repository copy, and make the necessary adjustments to reflect
the moved files.
 1.4 10-Oct-1997  scottr Remove advertising clause.
 1.3 24-Feb-1997  scottr branches: 1.3.4;
Update copyright and license.
 1.2 11-Feb-1997  scottr Complete revamp of Apple Sound Chip support. The ASC can now be accessed
as a real device whose registers and buffers are available through mmap(2),
which makes further development of the driver considerably less painful.
 1.1 05-May-1996  briggs branches: 1.1.6;
Prototype for -Wall -Wstrict-prototypes -Wmissing-prototypes -Wno-uninitialized
Also change the device probing scheme to use something a bit more rational.
A current side-effect is that nubus cards are double-mapped. I expect
to fix that shortly.
Also change splclock() to block everything but serial hardware interrupts.
 1.1.6.1 12-Mar-1997  is Merge in changes from The Trunk, partially just reimplementing newarp.
 1.3.4.1 14-Oct-1997  thorpej Update marc-pcmcia branch from trunk.
 1.6 02-May-1998  scottr Dead, unused, kaput.
 1.5 13-Oct-1996  christos backout previous kprintf change
 1.4 11-Oct-1996  christos printf -> kprintf, sprintf -> ksprintf
 1.3 21-Apr-1995  briggs First pass of KNFication. Needs more.
 1.2 26-Oct-1994  cgd new RCS ID format.
 1.1 08-Jul-1994  lkestel 6x10.h: shifted font over by two pixels.
keyboard.h: added constants for commonly used keys and reformatted
array so that gcc would be happy.
adbsys.c: new adb system.
bounds.h: bound-checking macros.
ite.c: new built-in mini-console.
8x14.h: no longer used by built-in console.
adb.c: replaced by adbsys.c
 1.3 30-Jan-1994  mycroft Clean up deleted files.
 1.2 29-Nov-1993  briggs Update to current work in progress. This includes an update to
use config.new.
Numerous updates to console so it works better on the SE/30 screen.
Some nice changes from Brad Parker for handling NuBUS and an ethernet
driver that I haven't worked on, yet.
 1.1 29-Sep-1993  briggs branches: 1.1.1;
Initial revision
 1.1.1.1 29-Sep-1993  briggs The current MacBSD architecture sub-directory for NetBSD-0.9--more or
less. It needs some help to get to be -current. Support for minimal
hardware on the SE/30, II, IIx, and IIcx exists.
 1.16 24-Jul-1994  mycroft Clean up deleted files.
 1.15 05-Jul-1994  briggs Need the extra byte in the temp buffer to avoid overrun in scrollup on
wide screens.
 1.14 04-Jul-1994  briggs Don't blow up on huge screens.
 1.13 02-Jul-1994  briggs Reset sccaddr if we're resetting the video address.
Nuke some debugging output.
 1.12 26-Jun-1994  briggs Minor mods. Get rid of constants, or update to use a better default
value.
 1.11 06-May-1994  briggs Clean up some warnings, mainly w/ timeout().
 1.10 22-Feb-1994  briggs Various fixes, changes and so forth by lkestel. Among them should be
support for > 1-bit modes (slow...)...
 1.9 10-Feb-1994  briggs ioctl now takes struct proc *.
 1.8 30-Jan-1994  briggs Nuke final references to chars.h. It wasn't being used.
 1.7 20-Jan-1994  briggs Take out coninit and clean up some warnings.
 1.6 13-Jan-1994  briggs Basic cleanup. Get rid of my_frame for frame.
 1.5 21-Dec-1993  briggs Add basic sound support and a beeping (instead of flashing) console...
from Brad Grantham.
 1.4 15-Dec-1993  briggs Add (broken) support for DDB. Also fix a bug in console that confused the
scrollback. Clean up includes a tad.
 1.3 06-Dec-1993  briggs Fix includes to use ../mac68k instead of ../mac and add some semi-colons
to a couple of default: switches. gcc2 doesn't mind not having them,
but gcc1 sure does.
 1.2 29-Nov-1993  briggs Update to current work in progress. This includes an update to
use config.new.
Numerous updates to console so it works better on the SE/30 screen.
Some nice changes from Brad Parker for handling NuBUS and an ethernet
driver that I haven't worked on, yet.
 1.1 29-Sep-1993  briggs branches: 1.1.1;
Initial revision
 1.1.1.1 29-Sep-1993  briggs The current MacBSD architecture sub-directory for NetBSD-0.9--more or
less. It needs some help to get to be -current. Support for minimal
hardware on the SE/30, II, IIx, and IIcx exists.
 1.4 24-Jul-1994  mycroft Clean up deleted files.
 1.3 21-Dec-1993  briggs Add basic sound support and a beeping (instead of flashing) console...
from Brad Grantham.
 1.2 29-Nov-1993  briggs Update to current work in progress. This includes an update to
use config.new.
Numerous updates to console so it works better on the SE/30 screen.
Some nice changes from Brad Parker for handling NuBUS and an ethernet
driver that I haven't worked on, yet.
 1.1 29-Sep-1993  briggs branches: 1.1.1;
Initial revision
 1.1.1.1 29-Sep-1993  briggs The current MacBSD architecture sub-directory for NetBSD-0.9--more or
less. It needs some help to get to be -current. Support for minimal
hardware on the SE/30, II, IIx, and IIcx exists.
 1.4 03-Jul-1994  mycroft Clean up deleted files.
 1.3 26-Jun-1994  briggs This should probably be deprecated--minor slash job.
 1.2 29-Nov-1993  briggs Update to current work in progress. This includes an update to
use config.new.
Numerous updates to console so it works better on the SE/30 screen.
Some nice changes from Brad Parker for handling NuBUS and an ethernet
driver that I haven't worked on, yet.
 1.1 29-Sep-1993  briggs branches: 1.1.1;
Initial revision
 1.1.1.1 29-Sep-1993  briggs The current MacBSD architecture sub-directory for NetBSD-0.9--more or
less. It needs some help to get to be -current. Support for minimal
hardware on the SE/30, II, IIx, and IIcx exists.
 1.15 02-May-1998  scottr Move on-board I/O and NuBus drivers to their own directories
via repository copy, and make the necessary adjustments to reflect
the moved files.
 1.14 12-Jan-1998  thorpej Update for changes to config.
 1.13 19-Nov-1997  briggs * Disable parity checking on all devices until we find a better way to
deal with cheap CD-ROMs and other devices that do not appear to have
any way to enable parity generation. In the future, it might be nice
to have this configurable on a per-device basis with back-to-back
parity errors automatically disabling parity for the device. That
would require some MI changes.
* Handle unaligned and odd-length transfers.
This could probably be handled better in the future.
 1.12 05-Nov-1997  briggs A first cut at faster SCSI for non-AV quadras. Could probably perform better,
but is a marked improvement. This takes advantage of a pseudo-DMA hardware
hack of Apple's that exposes a 16-bit register that the Apple-designed
memory controller acts like a DMA controller and handshakes into or out
of the FIFO. Wierd.
 1.11 27-Aug-1997  bouyer branches: 1.11.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.10 05-Mar-1997  briggs branches: 1.10.2; 1.10.4;
Copyright foo.
 1.9 01-Mar-1997  scottr Fix prototype for espmatch()
 1.8 28-Feb-1997  scottr Convert to generalized VIA interrupt registration
 1.7 27-Feb-1997  briggs mac68k-specific portion of m.i. ncr53c9x driver.
 1.6 16-Dec-1996  scottr branches: 1.6.6;
Convert all foo_match() functions to use a `struct cfdata *' for their
second argument. The NuBus autoconfig code had to be reorganized as a
result of this, and looks much more like a directly-attached bus now.
These changes eliminate __BROKEN_INDIRECT_CONFIG.
 1.5 10-Dec-1996  thorpej Fill in sc_link.max_target
 1.4 04-Nov-1996  briggs - Move offset for 2nd scsi controller (Q900/Q950/WGS95) to 0x402
instead of 0x400.
- Restructure interrupt handling for more performance--continue to
read/write data as long as the device keeps us in a data xfer phase.
There is still a lot of room for speed improvement here. Perhaps it
lies is speeding up the interrupt path in general?
 1.3 02-Nov-1996  briggs Improve reliability on my Q700, at least. Was getting the occasional
glitch--an extra byte on occasion.
 1.2 30-Oct-1996  briggs macs with scsibase offset 0x10000 from iobase use a SCSI CLK of 16.5MHz
(off PrimeTime)--all others appear to use 25MHz.
 1.1 29-Oct-1996  briggs Interrupt-driven, but slow, NCR 53c96 driver for the 040-based macs. Contains
some guesses for the machines that have two of these buggers (I don't have
such a machine). This driver is a copy of the sparc/alpha esp with a
minimum of changes--after we get it performing a bit more respectably,
we should see about re-normalizing the sources.
 1.6.6.1 12-Mar-1997  is Merge in changes from The Trunk, partially just reimplementing newarp.
 1.10.4.1 27-Aug-1997  thorpej Update marc-pcmcia branch from trunk.
 1.10.2.1 01-Jul-1997  bouyer Updates for new scsipi subsystem. Actally known to work on i386 and sparc.
 1.11.4.2 19-Nov-1997  mellon Pull rev 1.13 up from trunk (briggs)
 1.11.4.1 15-Nov-1997  mellon Pull rev 1.12 up from trunk (briggs)
 1.2 27-Feb-1997  briggs mac68k-specific portion of m.i. ncr53c9x driver.
 1.1 29-Oct-1996  briggs branches: 1.1.6;
Interrupt-driven, but slow, NCR 53c96 driver for the 040-based macs. Contains
some guesses for the machines that have two of these buggers (I don't have
such a machine). This driver is a copy of the sparc/alpha esp with a
minimum of changes--after we get it performing a bit more respectably,
we should see about re-normalizing the sources.
 1.1.6.1 12-Mar-1997  is Merge in changes from The Trunk, partially just reimplementing newarp.
 1.6 02-May-1998  scottr Move on-board I/O and NuBus drivers to their own directories
via repository copy, and make the necessary adjustments to reflect
the moved files.
 1.5 25-Nov-1997  briggs Forgot a declaration in last change to esp.c.
 1.4 05-Nov-1997  briggs A first cut at faster SCSI for non-AV quadras. Could probably perform better,
but is a marked improvement. This takes advantage of a pseudo-DMA hardware
hack of Apple's that exposes a 16-bit register that the Apple-designed
memory controller acts like a DMA controller and handshakes into or out
of the FIFO. Wierd.
 1.3 27-Feb-1997  briggs branches: 1.3.8;
mac68k-specific portion of m.i. ncr53c9x driver.
 1.2 02-Nov-1996  briggs branches: 1.2.6;
Improve reliability on my Q700, at least. Was getting the occasional
glitch--an extra byte on occasion.
 1.1 29-Oct-1996  briggs Interrupt-driven, but slow, NCR 53c96 driver for the 040-based macs. Contains
some guesses for the machines that have two of these buggers (I don't have
such a machine). This driver is a copy of the sparc/alpha esp with a
minimum of changes--after we get it performing a bit more respectably,
we should see about re-normalizing the sources.
 1.2.6.1 12-Mar-1997  is Merge in changes from The Trunk, partially just reimplementing newarp.
 1.3.8.2 26-Nov-1997  mellon Pull rev 1.5 up from trunk (briggs)
 1.3.8.1 15-Nov-1997  mellon Pull rev 1.4 up from trunk (briggs)
 1.3 09-Dec-2024  nat Add support for backlight control.

Currently it is only supported on PowerBooks.
The backlight can be turned off or on via pmf(9) events on wsdisplay(4)
devices.
 1.2 21-Oct-2020  rin branches: 1.2.26;
Drop inappropriate WSFB_VRAM_IS_RAM bit from fbi_flags;
framebuffer is not regular RAM.

Thanks to jmcneill@ and macallan@ for kind explanation
(at elsewhere).
 1.1 26-Jul-2019  rin branches: 1.1.10;
Add genfb(4) driver for mac68k grfbus.
1, 2, 4, 8, 15, and 32 color-depths are supported.

ANSI colors on console are functional for depth >= 4.

Graphic applications based on wsfb API should work, provided
they can correctly handle fbi_fboffset and your color depth.

wsfb driver of Xorg 1.20 and mlterm-fb (framebuffer version of
x11/mlterm) work fine for depth == 1 || depth >= 8.

For depth == 8 (256 colors), graphic applications require
colormap callback, which is currently supported for some
internal graphic adapters, and only Civic (found on Quadra
AV series) was tested. Register definition and its usage are
taken from Linux. You can easily support other adapters if
Linux supports that.

Have fun, and any problem reports are welcomed!
 1.1.10.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.1.10.1 26-Jul-2019  martin file genfb_grfbus.c was added on branch phil-wifi on 2020-04-13 08:03:57 +0000
 1.2.26.1 02-Aug-2025  perseant Sync with HEAD
 1.64 14-Feb-2000  scottr Merge wscons work onto the main development branch.
 1.63 28-Jun-1999  briggs branches: 1.63.2;
Include resourcevar.h for p_limit/rlimit definition.
 1.62 18-Jun-1999  thorpej Add the guts of mlockall(MCL_FUTURE). This requires that a process's
"memlock" resource limit to uvm_mmap(). Update all calls accordingly.
 1.61 07-Apr-1999  scottr vm_size_t -> vsize_t
 1.60 26-Mar-1999  ender branches: 1.60.4;
Include uvm/uvm.h instead of uvm/uvm_extern.h because we need the prototype
for uvm_unmap() in order to compile a kernel with GRF_COMPAT defined.

Fix provided by Frederick Bruckman <fb@enteract.com> in PR #7237.
 1.59 24-Mar-1999  mrg completely remove Mach VM support. all that is left is the all the
header files as UVM still uses (most of) these.
 1.58 22-Dec-1998  scottr branches: 1.58.2;
vm_offset_t -> {paddr_t, vaddr_t}
 1.57 19-Nov-1998  mrg fix problems in many d_mmap routines:
- returned EOPNOTSUPP rather than -1.
- no check for negative offset.
many of these fix potential security problems in these drivers.


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

by someone!
 1.56 11-Oct-1998  chuck remove unused share map code from UVM:
- update calls to uvm_unmap_remove/uvm_unmap (mainonly boolean arg
has been removed)
 1.55 12-Aug-1998  scottr New and improved console framebuffer initialization and autoconfig. This
resolves a great many issues, including Performa 58x interrupt handling
and offset displays on some models.

Programs that depend on the old (pre-NetBSD 1.1) grf interface may break.
That's actually a separate issue uncovered by this code, not caused by it.
 1.54 01-Jul-1998  scottr Add a GRF_COMPAT option so that old-style grf ioctl() code can be
removed from the kernel.
 1.53 02-Jun-1998  scottr Store the PA of the framebuffer in the softc. This eliminates the need
for the sc_phys callback; we can just store the PA in the grfbus attach
args, rather than a function pointer, which simplifies the code nicely.
 1.52 02-May-1998  scottr Move on-board I/O and NuBus drivers to their own directories
via repository copy, and make the necessary adjustments to reflect
the moved files.
 1.51 24-Apr-1998  scottr Checkpoint of UVM work to date. This includes a fully-functioning
MACHINE_NEW_NONCONTIG interface implementation, which is now enabled
on all systems. Thanks to Jason Thorpe for his work on the hp300 port,
from which most of the code used here was derived.

XXX In spite of the fact that it works on the hp300, UVM does not (yet)
work well under load on mac68k.
 1.50 17-Jan-1998  scottr Now, correct the problem the correct way: s/cfattach/cfdriver/
 1.49 17-Jan-1998  scottr Back out previous change.
 1.48 12-Jan-1998  scottr Missed a change for the updated config(8).
 1.47 12-Jan-1998  thorpej Update for changes to config.
 1.46 01-Dec-1997  scottr Make grfdebug a patchable variable, and default to no debugging messages.
Noticed by Hauke Fath.
 1.45 11-Aug-1997  scottr branches: 1.45.4;
Make #include directives consistent. All MD headers are of the form:

#include <mac68k/{dev,mac68k}/foo.h>
 1.44 03-Aug-1997  scottr Overhaul grf drivers to correct recent problems with X and dt
(address error faults), as well as other reported problems:

- Simplify grfmv_phys() to work like grfiv_phys(), and eliminate the
second argument to both, as we don't use it anyway.
- Handle fbbase and fboff consistently throughout. Closes PR 3862.
- Eliminate grfaddr() by pulling it into grfmmap(), which is the
only place it was used, previously.
- grfmap() now gets the physical address of the framebuffer from
the appropriate driver, rather than try to compute it by itself.
Be careful with aligning the base to a page address and increase
the length of the mapped region appropriately. Closes PR 2867.
 1.43 10-Jun-1997  veego branches: 1.43.4;
s/mac68k_round_page/m68k_round_page/ s/mac68k_trunc_page/m68k_trunc_page/
s/mac68k_btop/m68k_btop/
 1.42 11-May-1997  scottr Implement new NuBus slot space mapping/probing code, utilizing bus.h (and
our MD bus_space_probe() extension). This has several side effects:

- NuBus drivers must map and unmap slot space, rather than relying
on this happening before they are attached.
- Functions exported to NuBus drivers from nubus.c now need to be
supplied with a bus space tag/handle pair.
- Old bus map/peek functions can be garbage collected, as can pmap
support for the same.

Because of some current limitations of the bus space specification, we
are violating the abstraction in grf_mv (NuBus grf driver). All such
violations are clearly marked /* XXX */, and must be addressed when
the specification is updated.
 1.41 24-Feb-1997  scottr NUBUS_SLOT_TO_PADDR -> NUBUS_SLOT2PA
 1.40 20-Feb-1997  scottr We need bus.h now, due to recent nubus_attach_args change.
 1.39 16-Dec-1996  scottr branches: 1.39.6;
Convert all foo_match() functions to use a `struct cfdata *' for their
second argument. The NuBus autoconfig code had to be reorganized as a
result of this, and looks much more like a directly-attached bus now.
These changes eliminate __BROKEN_INDIRECT_CONFIG.
 1.38 13-Oct-1996  christos backout previous kprintf change
 1.37 11-Oct-1996  christos printf -> kprintf, sprintf -> ksprintf
 1.36 14-Sep-1996  scottr Implement poll(2).
 1.35 05-Aug-1996  scottr Attach ite semantics to the appropriate grf device, instead of obio.
 1.34 04-Aug-1996  scottr Add a way to tell grf_establish() that internal video doesn't actually
occupy a slot. This is necessary so that GRFIOCMAP can find the correct
physical address of the framebuffer. Fixes P550, some LC models, and
perhaps the PB520.
 1.33 19-May-1996  scottr branches: 1.33.4;
New grf attachment code, mostly by Jason Thorpe with some cleanup by me.
This will allow dt and X to work with a generic kernel, rather than
compiling different kernels that attach grf0 to a NuBus adapter or
internal video.
 1.32 06-May-1996  briggs Do not depend on the nubus being mapped in one huge segment.
 1.31 05-May-1996  briggs Prototype for -Wall -Wstrict-prototypes -Wmissing-prototypes -Wno-uninitialized
Also change the device probing scheme to use something a bit more rational.
A current side-effect is that nubus cards are double-mapped. I expect
to fix that shortly.
Also change splclock() to block everything but serial hardware interrupts.
 1.30 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.29 21-Sep-1995  briggs Fix a warning.
 1.28 06-Jul-1995  briggs Add another routine for the grf display-specific drivers to return a physical
address.
 1.27 06-Jul-1995  briggs Put in a cast to make compiler happy.
 1.26 06-Jul-1995  briggs Fix a bug I introduced earlier.
 1.25 02-Jul-1995  briggs Add missing interface for getting a grfmode structure from kernel.
 1.24 02-Jul-1995  briggs Fix grfmap() as well as grfmmap().
 1.23 02-Jul-1995  briggs Set and use new fboff element from grfmode structure.
 1.22 01-Jul-1995  briggs Fix buglet that was missed when converting nubus to non pa==va mapping.
 1.21 29-Apr-1995  briggs Add new nubus handling that's much more robust.
Update via, if_ae, and grf accordingly.
Revamp grf.
 1.20 21-Apr-1995  briggs Handle grf_softc in the config.new manner.
Should have been done long ago.
 1.19 21-Apr-1995  briggs First pass of KNFication. Needs more.
 1.18 13-Apr-1995  briggs Update interrupts to use (void *client_data) instead of (int unit) as
parameter to interrupt function.
 1.17 10-Apr-1995  mycroft Switch grfmap and grfmmap.
 1.16 26-Mar-1995  briggs Do iteon() and iteoff(). Right now, they just clear/draw the cursor and
clear the screen. "We" should look at updating these further.
 1.15 25-Mar-1995  briggs Don't count video interrupts.
 1.14 23-Mar-1995  briggs Add macvideo_intr to handle video interrupts. Currently has behavior
that was previously in slot_noint().
 1.13 03-Dec-1994  briggs Nuke DEBUG.
 1.12 30-Oct-1994  briggs Fix a buglet in computation of fbsize. Pointed out by monroe@cs.pdx.edu.
 1.11 26-Oct-1994  cgd new RCS ID format.
 1.10 31-Jul-1994  lkestel Make internal video look like a grf device so that desktop and X can use
it. GRFIOCMAP modifies addr to include the offset into the screen where
the first pixel is. Not a very clean way to do it -- we should add a
field to grfinfo for offset.
 1.9 30-Jul-1994  lkestel Moved adbsys.h grfioctl.h and keyboard.h to include to make desktop
and X compile more cleanly.
 1.8 09-Jul-1994  briggs Minor hacks to get this to compile for now. ite.c now uses the proper
consdev structure to keep itself from crashing...
 1.7 26-Jun-1994  briggs branches: 1.7.2;
Minor mods. Get rid of constants, or update to use a better default
value.
 1.6 04-May-1994  briggs Don't even pay lip service to HPUXCOMPAT, now COMPAT_HPUX.
 1.5 05-Apr-1994  briggs Clean out some old printf()s and get rid of MAP_FILE reference.
 1.4 30-Jan-1994  briggs Include-cop.
 1.3 10-Jan-1994  briggs Update grf.h to increment a number of devices when it configures.
Fix a small bug in serial.
Both from Brad, Lawrence, and/or Mike.
 1.2 29-Nov-1993  briggs Update to current work in progress. This includes an update to
use config.new.
Numerous updates to console so it works better on the SE/30 screen.
Some nice changes from Brad Parker for handling NuBUS and an ethernet
driver that I haven't worked on, yet.
 1.1 29-Sep-1993  briggs branches: 1.1.1;
Initial revision
 1.1.1.1 29-Sep-1993  briggs The current MacBSD architecture sub-directory for NetBSD-0.9--more or
less. It needs some help to get to be -current. Support for minimal
hardware on the SE/30, II, IIx, and IIcx exists.
 1.7.2.2 05-Aug-1994  mycroft update from trunk
 1.7.2.1 24-Jul-1994  cgd update, as requested by briggs
 1.33.4.1 05-Aug-1996  jtc Pulled up from rev 1.34 by request from Scott Reynolds
 1.39.6.1 12-Mar-1997  is Merge in changes from The Trunk, partially just reimplementing newarp.
 1.43.4.1 23-Aug-1997  thorpej Update marc-pcmcia branch from trunk.
 1.45.4.2 23-Nov-1998  cgd Fix many real and potential security problems with character device
driver mmap routines that did not properly bounds check offsets.
See NetBSD security advisory NetBSD-SA1998-005 for details. Done
as a patch because it's large, and a fair number of bits are different
in -current. (mrg)
 1.45.4.1 29-Jan-1998  mellon PUll up 1.46 (scottr)
 1.58.2.1 11-Mar-1999  scottr ite/grf is dead. long live ite/grf!
 1.60.4.2 01-Jul-1999  thorpej Sync w/ -current.
 1.60.4.1 21-Jun-1999  thorpej Sync w/ -current.
 1.63.2.1 20-Nov-2000  bouyer Remove files that are no longer on the trunck
 1.29 10-Nov-2019  chs in many device attach paths, allocate memory with M_WAITOK instead of M_NOWAIT
and remove code to handle failures that can no longer happen.
 1.28 20-Aug-2015  christos branches: 1.28.18;
include "ioconf.h" to get the 'void <driver>attach(int count);' prototype.
 1.27 14-Dec-2014  chs add a new "fo_mmap" fileops method to allow use of arbitrary uvm_objects for
mappings of file objects. move vnode-specific details of mmap()ing a vnode
from uvm_mmap() to the new vnode-specific vn_mmap(). add new uvm_mmap_dev()
and uvm_mmap_anon() convenience functions for mapping character devices
and anonymous memory, and replace all other calls to uvm_mmap() with those.
use the new fileop in drm2 so that libdrm can use mmap() to map things
like on other platforms (instead of the ioctl that we have used so far).
 1.26 25-Jul-2014  dholland branches: 1.26.2; 1.26.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.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 30-Jan-2014  martin Add missing cast (to make it compilable)
 1.23 26-Jan-2014  christos kill VM_DEFAULT_ADDRESS use
 1.22 06-Jun-2010  mrg branches: 1.22.8; 1.22.18; 1.22.22;
defflag GRF_COMPAT.
 1.21 25-Jan-2008  dogcow branches: 1.21.10; 1.21.30; 1.21.32;
fallout from v_specinfo removal
 1.20 05-Mar-2007  he branches: 1.20.20; 1.20.26;
Cast to char* before doing pointer arithmetic.
 1.19 04-Mar-2007  christos Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.18 24-Jan-2007  hubertf branches: 1.18.2;
Remove duplicate #includes, patch contributed in private mail
by Slava Semushin <slava.semushin@gmail.com>.

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

Thanks to martin@ for the input on testing.
 1.17 09-Mar-2006  he branches: 1.17.10;
Remove now-unused local variable.
 1.16 08-Mar-2006  scottr Cleaner check for offset to grf_mmap
 1.15 11-Dec-2005  christos branches: 1.15.4; 1.15.6; 1.15.8; 1.15.10;
merge ktrace-lwp.
 1.14 15-Jan-2005  chs branches: 1.14.10;
de-__P, remove register, ansify, b* -> mem*.
 1.13 15-Jul-2003  lukem branches: 1.13.6;
__KERNEL_RCSID()
 1.12 24-Feb-2003  atatat branches: 1.12.2;
Cast VM_DEFAULT_ADDRESS() to a caddr_t.
 1.11 20-Feb-2003  atatat Introduce "top down" memory management for mmap()ed allocations. This
means that the dynamic linker gets mapped in at the top of available
user virtual memory (typically just below the stack), shared libraries
get mapped downwards from that point, and calls to mmap() that don't
specify a preferred address will get mapped in below those.

This means that the heap and the mmap()ed allocations will grow
towards each other, allowing one or the other to grow larger than
before. Previously, the heap was limited to MAXDSIZ by the placement
of the dynamic linker (and the process's rlimits) and the space
available to mmap was hobbled by this reservation.

This is currently only enabled via an *option* for the i386 platform
(though other platforms are expected to follow). Add "options
USE_TOPDOWN_VM" to your kernel config file, rerun config, and rebuild
your kernel to take advantage of this.

Note that the pmap_prefer() interface has not yet been modified to
play nicely with this, so those platforms require a bit more work
(most notably the sparc) before they can use this new memory
arrangement.

This change also introduces a VM_DEFAULT_ADDRESS() macro that picks
the appropriate default address based on the size of the allocation or
the size of the process's text segment accordingly. Several drivers
and the SYSV SHM address assignment were changed to use this instead
of each one picking their own "default".
 1.10 23-Oct-2002  jdolecek merge kqueue branch into -current

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

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

based on work done by Jonathan Lemon for FreeBSD
initial NetBSD port done by Luke Mewburn and Jason Thorpe
 1.9 10-Oct-2002  jdolecek replace the somewhat strange poll routine with standard nopoll() (a.k.a
seltrue())
 1.8 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.7 30-Apr-2001  wiz branches: 1.7.2; 1.7.4; 1.7.8; 1.7.16;
Remove unused variable. Reported by Thilo Manske in port-mac68k/12794.
 1.6 15-Mar-2001  chs eliminate the KERN_* error codes in favor of the traditional E* codes.
the mapping is:

KERN_SUCCESS 0
KERN_INVALID_ADDRESS EFAULT
KERN_PROTECTION_FAILURE EACCES
KERN_NO_SPACE ENOMEM
KERN_INVALID_ARGUMENT EINVAL
KERN_FAILURE various, mostly turn into KASSERTs
KERN_RESOURCE_SHORTAGE ENOMEM
KERN_NOT_RECEIVER <unused>
KERN_NO_ACCESS <unused>
KERN_PAGES_LOCKED <unused>
 1.5 29-Jun-2000  mrg branches: 1.5.2; 1.5.4;
remove include of <vm/vm.h>. <vm/vm.h> -> <uvm/uvm_extern.h>
 1.4 26-Jun-2000  simonb Change the kernel mmap interface so that the offset to map is an
"off_t" and the return value is a "paddr_t" to allow mappings
at offsets past 2^31 bytes. Somewhat inspired by FreeBSD, which
only changed the offset to a "vm_offset_t".

Includes updates for the i386, pc532 and sh3 mmmmap from Jason Thorpe.
 1.3 08-Jun-2000  scottr branches: 1.3.2;
Make this compile with GRF_COMPAT. Problem pointed out by Hauke Fath.
 1.2 14-Feb-2000  scottr branches: 1.2.2;
Merge wscons work onto the main development branch.
 1.1 15-Nov-1999  scottr branches: 1.1.2;
file grf_compat.c was initially added on branch scottr-mac68k-wscons.
 1.1.2.5 20-Nov-1999  scottr Clear the screen on close to emulate the behavior of legacy
grf devices.
 1.1.2.4 18-Nov-1999  scottr Revert 1.1.2.2; further testing shows that the problem lies elsewhere.
 1.1.2.3 18-Nov-1999  scottr Improved emulation of grf devices:

- sync return value for unsupported ioctls with legacy grf driver
- returning (-1) from grfioctl() is hardly appropriate; return EINVAL
when we are given an unknown ioctl (duh)
- don't add the displayable region offset in grfmmap(); apps handlj
this themselves
 1.1.2.2 17-Nov-1999  scottr Avoid MAP_FIXED in grfmap(); it doesn't buy us anything
with the apps that use it, and can cause some systems (e.g. the IIci)
to behave erratically.
 1.1.2.1 15-Nov-1999  scottr Implement a more straightforward approach to grf emulation.
 1.2.2.1 22-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.3.2.1 30-Jun-2000  simonb Pull up mmap paddr_t/off_t changes from trunk.
 1.5.4.2 21-Jun-2001  nathanw Catch up to -current.
 1.5.4.1 09-Apr-2001  nathanw Catch up with -current.
 1.5.2.3 27-Mar-2001  bouyer Sync with HEAD.
 1.5.2.2 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.5.2.1 29-Jun-2000  bouyer file grf_compat.c was added on branch thorpej_scsipi on 2000-11-20 20:12:16 +0000
 1.7.16.1 17-May-2002  gehenna Add device switch.
 1.7.8.4 11-Nov-2002  nathanw Catch up to -current
 1.7.8.3 18-Oct-2002  nathanw Catch up to -current.
 1.7.8.2 17-Sep-2002  nathanw Catch up to -current.
 1.7.8.1 30-Apr-2001  nathanw file grf_compat.c was added on branch nathanw_sa on 2002-09-17 21:15:24 +0000
 1.7.4.1 10-Oct-2001  fvdl Convert all remaining devices.
 1.7.2.3 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.7.2.2 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.7.2.1 18-Jun-2002  jdolecek provide dummy grfkqfilter()
 1.12.2.5 25-Jan-2005  skrll Adapt to branch.
 1.12.2.4 17-Jan-2005  skrll Sync with HEAD.
 1.12.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.12.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.12.2.1 03-Aug-2004  skrll Sync with HEAD
 1.13.6.2 09-Mar-2006  snj Revert previous change, which was accidentally committed to the wrong branch.
 1.13.6.1 08-Mar-2006  scottr Cleaner check for offset to grf_mmap
 1.14.10.4 04-Feb-2008  yamt sync with head.
 1.14.10.3 03-Sep-2007  yamt sync with head.
 1.14.10.2 26-Feb-2007  yamt sync with head.
 1.14.10.1 21-Jun-2006  yamt sync with head.
 1.15.10.1 19-Apr-2006  elad sync with head - hopefully this will work
 1.15.8.1 13-Mar-2006  yamt sync with head.
 1.15.6.1 22-Apr-2006  simonb Sync with head.
 1.15.4.1 09-Sep-2006  rpaulo sync with head
 1.17.10.1 01-Feb-2007  ad Sync with head.
 1.18.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.20.26.1 18-Feb-2008  mjf Sync with HEAD.
 1.20.20.1 23-Mar-2008  matt sync with HEAD
 1.21.32.1 03-Jul-2010  rmind sync with head
 1.21.30.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.21.10.1 11-Aug-2010  yamt sync with head.
 1.22.22.1 18-May-2014  rmind sync with head
 1.22.18.2 03-Dec-2017  jdolecek update from HEAD
 1.22.18.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.22.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.25.2.1 10-Aug-2014  tls Rebase.
 1.26.4.2 22-Sep-2015  skrll Sync with HEAD
 1.26.4.1 06-Apr-2015  skrll Sync with HEAD
 1.26.2.1 31-Dec-2014  snj Pull up following revision(s) (requested by chs in ticket #363):
common/lib/libprop/prop_kern.c: revision 1.18
sys/arch/mac68k/dev/grf_compat.c: revision 1.27
sys/arch/x68k/dev/grf.c: revision 1.45
sys/external/bsd/drm/dist/bsd-core/drm_bufs.c: revision 1.12
sys/external/bsd/drm2/drm/drm_drv.c: revision 1.12
sys/external/bsd/drm2/drm/drm_vm.c: revision 1.6
sys/external/bsd/drm2/include/linux/mm.h: revision 1.4
sys/kern/vfs_vnops.c: revision 1.192 via patch
sys/rump/librump/rumpkern/vm.c: revision 1.160
sys/sys/file.h: revision 1.78 via patch
sys/uvm/uvm_device.c: revision 1.64
sys/uvm/uvm_device.h: revision 1.13
sys/uvm/uvm_extern.h: revision 1.192
sys/uvm/uvm_mmap.c: revision 1.150 via patch
add a new "fo_mmap" fileops method to allow use of arbitrary uvm_objects for
mappings of file objects. move vnode-specific details of mmap()ing a vnode
from uvm_mmap() to the new vnode-specific vn_mmap(). add new uvm_mmap_dev()
and uvm_mmap_anon() convenience functions for mapping character devices
and anonymous memory, and replace all other calls to uvm_mmap() with those.
use the new fileop in drm2 so that libdrm can use mmap() to map things
like on other platforms (instead of the ioctl that we have used so far).
 1.28.18.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.7 21-Apr-1995  briggs First pass of KNFication. Needs more.
 1.6 26-Oct-1994  cgd new RCS ID format.
 1.5 30-Jul-1994  lkestel Moved adbsys.h grfioctl.h and keyboard.h to include to make desktop
and X compile more cleanly.
 1.4 26-Jun-1994  briggs branches: 1.4.2;
Minor mods. Get rid of constants, or update to use a better default
value.
 1.3 30-Jan-1994  briggs Include-cop.
 1.2 29-Nov-1993  briggs Update to current work in progress. This includes an update to
use config.new.
Numerous updates to console so it works better on the SE/30 screen.
Some nice changes from Brad Parker for handling NuBUS and an ethernet
driver that I haven't worked on, yet.
 1.1 29-Sep-1993  briggs branches: 1.1.1;
Initial revision
 1.1.1.1 29-Sep-1993  briggs The current MacBSD architecture sub-directory for NetBSD-0.9--more or
less. It needs some help to get to be -current. Support for minimal
hardware on the SE/30, II, IIx, and IIcx exists.
 1.4.2.1 11-Aug-1994  mycroft update from trunk
 1.4 21-Apr-1995  briggs First pass of KNFication. Needs more.
 1.3 26-Oct-1994  cgd new RCS ID format.
 1.2 29-Nov-1993  briggs Update to current work in progress. This includes an update to
use config.new.
Numerous updates to console so it works better on the SE/30 screen.
Some nice changes from Brad Parker for handling NuBUS and an ethernet
driver that I haven't worked on, yet.
 1.1 29-Sep-1993  briggs branches: 1.1.1;
Initial revision
 1.1.1.1 29-Sep-1993  briggs The current MacBSD architecture sub-directory for NetBSD-0.9--more or
less. It needs some help to get to be -current. Support for minimal
hardware on the SE/30, II, IIx, and IIcx exists.
 1.32 02-May-1998  scottr Move on-board I/O and NuBus drivers to their own directories
via repository copy, and make the necessary adjustments to reflect
the moved files.
 1.31 22-Mar-1998  scottr The monitor sense code we have is not reliable on DAFB-based machines with
certain 17" monitors. Change from Michael R. Zucca, PR 4988.

XXX - This can cause problems on system with the DAFB chip which currently
use only a NuBus-based video adapter. In particular, grf devices may not be
attached properly in this case. This unfortunate situation is less annoying
than not having a reasonable console, however. A reasonable, reliable
monitor sense algorithm for the DAFB would resolve the problem.
 1.30 22-Mar-1998  scottr Disable Valkyrie interrupts on the Quadra 630. Part of a change
from Michael R. Zucca, PR 4988.
 1.29 13-Jan-1998  scottr Update for bus.h changes.
 1.28 12-Jan-1998  thorpej Update for changes to config.
 1.27 08-Nov-1997  scottr KNF: Fix some whitespace inconsistencies.
 1.26 08-Nov-1997  briggs Force the probe to find the internal video for the 63x/575 models.
 1.25 08-Oct-1997  briggs branches: 1.25.2;
Disable video interrupts on the AV machines. Thanks to Michael R. Zucca
(mrz5149@cs.rit.edu) for the addresses and hints as to how the interrupts
might be disabled, and thanks to Henry Hotz (h.b.hotz@jpl.nasa.gov) for
testing on the 840AV.
Unmap the DAFB regs on the other Quadras after attachment. They're not
used.
 1.24 03-Aug-1997  scottr Fix grf{i,m}v_phys() prototypes.
 1.23 03-Aug-1997  scottr Overhaul grf drivers to correct recent problems with X and dt
(address error faults), as well as other reported problems:

- Simplify grfmv_phys() to work like grfiv_phys(), and eliminate the
second argument to both, as we don't use it anyway.
- Handle fbbase and fboff consistently throughout. Closes PR 3862.
- Eliminate grfaddr() by pulling it into grfmmap(), which is the
only place it was used, previously.
- grfmap() now gets the physical address of the framebuffer from
the appropriate driver, rather than try to compute it by itself.
Be careful with aligning the base to a page address and increase
the length of the mapped region appropriately. Closes PR 2867.
 1.22 26-Jul-1997  scottr branches: 1.22.2;
KNF
 1.21 10-Jun-1997  veego s/mac68k_trunc_page/m68k_trunc_page/
 1.20 21-Apr-1997  briggs Take care when accessing DAFB--some quadra-class machines use other video
controllers.
 1.19 01-Apr-1997  briggs Remove tag.
 1.18 01-Apr-1997  briggs - Support DAFB machines mo' better. Actually detect if a monitor is
present and initialize a few things. No color support, yet.
- Properly disable interrupts for DAFB.
- Rearrange for better nubus display card interrupt support. Only register
an interrupt if we know how to clear it.
- Complain if we don't know about a given display card and can not install
an interrupt handler.
- Change MYSTERY stuff to cb264--still need to get the DrSW so we can
actually call the routine to clear an interrupt from this card.
 1.17 20-Feb-1997  scottr We need bus.h now, due to recent nubus_attach_args change.
 1.16 16-Dec-1996  scottr branches: 1.16.6;
Convert all foo_match() functions to use a `struct cfdata *' for their
second argument. The NuBus autoconfig code had to be reorganized as a
result of this, and looks much more like a directly-attached bus now.
These changes eliminate __BROKEN_INDIRECT_CONFIG.
 1.15 13-Oct-1996  christos backout previous kprintf change
 1.14 11-Oct-1996  christos printf -> kprintf, sprintf -> ksprintf
 1.13 04-Aug-1996  scottr Add a way to tell grf_establish() that internal video doesn't actually
occupy a slot. This is necessary so that GRFIOCMAP can find the correct
physical address of the framebuffer. Fixes P550, some LC models, and
perhaps the PB520.
 1.12 19-May-1996  scottr branches: 1.12.4;
New grf attachment code, mostly by Jason Thorpe with some cleanup by me.
This will allow dt and X to work with a generic kernel, rather than
compiling different kernels that attach grf0 to a NuBus adapter or
internal video.
 1.11 05-May-1996  briggs Prototype for -Wall -Wstrict-prototypes -Wmissing-prototypes -Wno-uninitialized
Also change the device probing scheme to use something a bit more rational.
A current side-effect is that nubus cards are double-mapped. I expect
to fix that shortly.
Also change splclock() to block everything but serial hardware interrupts.
 1.10 11-Aug-1995  briggs Don't fake these values.
 1.9 04-Aug-1995  briggs Nuke int_video_start in favor of consistent use of mac68k_vidlog.
Don't find the internal video more than once.
Probe for internal video before nubus instead of after.
 1.8 04-Aug-1995  briggs Be consistent and use mac68k_vidlog instead of int_video_start.
 1.7 30-Jul-1995  briggs Fix the internal video probe again.
 1.6 28-Jul-1995  briggs Don't show up in "slot" 0xe.\n
 1.5 06-Jul-1995  briggs Add another routine for the grf display-specific drivers to return a physical
address.
 1.4 04-Jul-1995  briggs First cut at a kludge for IIvx internal video.
 1.3 02-Jul-1995  briggs Set and use new fboff element from grfmode structure.
 1.2 21-Jun-1995  briggs Be a bit more careful on the probe... Make sure that the current slot's
addresses contain the int_video_start--or assume that internal video is
is "slot" 0xE.
 1.1 29-Apr-1995  briggs Add new nubus handling that's much more robust.
Update via, if_ae, and grf accordingly.
Revamp grf.
 1.12.4.1 05-Aug-1996  jtc Pulled up from rev 1.13 by request from Scott Reynolds
 1.16.6.1 12-Mar-1997  is Merge in changes from The Trunk, partially just reimplementing newarp.
 1.22.2.2 14-Oct-1997  thorpej Update marc-pcmcia branch from trunk.
 1.22.2.1 23-Aug-1997  thorpej Update marc-pcmcia branch from trunk.
 1.25.2.2 05-May-1998  mycroft Pull up 1.30-1.31, per request of scottr.
 1.25.2.1 09-Nov-1997  mellon Pull rev 1.26 up from trunk (briggs)
 1.43 02-May-1998  scottr Move on-board I/O and NuBus drivers to their own directories
via repository copy, and make the necessary adjustments to reflect
the moved files.
 1.42 26-Apr-1998  briggs Deal with the video interrupt for the RasterOps 8/24XLi. Thanks for the
information go to Tadashi Ueda <ng6t-ued@asahi-net.or.jp>.
 1.41 25-Apr-1998  scottr Garbage collect the second (slot number) parameter to NuBus interrupt
handlers. (Only slot_ignore() and slot_noint() need this, and we already
have a place to put this information.) Adjust add_nubus_intr() so that if
the client_data arg is specified as NULL, pass the slot number as
client_data to the interrupt handler.
 1.40 24-Apr-1998  briggs Add interrupt support for two more video cards: the Formac color card II
and the Radius PrecisionColor 24Xp. Thanks to <falk.stern@luene.net> and
<Mario_Magliocco@broder.com> for their remote sleuthing and testing.
 1.39 12-Jan-1998  thorpej Update for changes to config.
 1.38 03-Dec-1997  briggs Thanks to Paul Goyette <paul@whooppee.com> for a patch to clear the
interrupt properly on a SuperMac Spectrum/8 Series III, and thanks
to Dan McMahill for loaning the card to Paul.
I modified Paul's patch somewhat to change grfmv_intr_generic_{1,4}
to grfmv_intr_generic_write{1,4} and added grfmv_intr_generic_or4 to
handle this card.
 1.37 01-Dec-1997  scottr Correct a comment from previous commit.
 1.36 30-Nov-1997  briggs Support for the Lapis ProColorServer 8 PDS on the SE/30. This prevents
hangs when trying to use this video card in conjunction with an ethernet
card. Thanks to David Condon <david@apk.net> for information and testing.
 1.35 25-Oct-1997  briggs Handle interrupts on E-Machines Futura-SX. From Paul Goyette, PR 4348.
 1.34 09-Oct-1997  briggs branches: 1.34.2;
Clear interrupts properly on the Radius PrecisionColor 8.
Thanks for the info go to Andrew MacGibbon <andrew-m@cs.auckland.ac.nz>
 1.33 15-Aug-1997  briggs Add interrupt handler for SuperMac GFX.
Tested by Kai-Yew Lum <kaiyewl@engin.umich.edu> back in May.
 1.32 14-Aug-1997  scottr Recognize the Sigma Designs ColorMax card, and handle the interrupt. Code
provided by Brian Foley <bfoley@gpo.iol.ie> via Allen Briggs, updated for
bus.h by me.
 1.31 11-Aug-1997  scottr Make #include directives consistent. All MD headers are of the form:

#include <mac68k/{dev,mac68k}/foo.h>
 1.30 03-Aug-1997  scottr Fix grf{i,m}v_phys() prototypes.
 1.29 03-Aug-1997  scottr Overhaul grf drivers to correct recent problems with X and dt
(address error faults), as well as other reported problems:

- Simplify grfmv_phys() to work like grfiv_phys(), and eliminate the
second argument to both, as we don't use it anyway.
- Handle fbbase and fboff consistently throughout. Closes PR 3862.
- Eliminate grfaddr() by pulling it into grfmmap(), which is the
only place it was used, previously.
- grfmap() now gets the physical address of the framebuffer from
the appropriate driver, rather than try to compute it by itself.
Be careful with aligning the base to a page address and increase
the length of the mapped region appropriately. Closes PR 2867.
 1.28 26-Jul-1997  scottr branches: 1.28.2;
Add support for Macintosh Display Card, using information provided
by Taras Ivanenko <ivanenko@ctpa03.mit.edu> in PR 3862. (The PR
is still open, due to an unresolved issue regarding the fbbase
field.)
 1.27 01-Jul-1997  scottr Add support for Portrait Video Card. From SUNAGAWA Keiki
<kei_sun@ba2.so-net.or.jp> in PR 3821.
 1.26 12-May-1997  scottr Convert several interrupt handlers to bus space model, removing some
XXX's. Also, fix a bug in grfmv_intr_generic() that I found and
confirmed with Allen.
 1.25 11-May-1997  scottr Implement new NuBus slot space mapping/probing code, utilizing bus.h (and
our MD bus_space_probe() extension). This has several side effects:

- NuBus drivers must map and unmap slot space, rather than relying
on this happening before they are attached.
- Functions exported to NuBus drivers from nubus.c now need to be
supplied with a bus space tag/handle pair.
- Old bus map/peek functions can be garbage collected, as can pmap
support for the same.

Because of some current limitations of the bus space specification, we
are violating the abstraction in grf_mv (NuBus grf driver). All such
violations are clearly marked /* XXX */, and must be addressed when
the specification is updated.
 1.24 03-May-1997  briggs Support for clearing interrupts on a Rasterops Colorboard 364.
Thanks go to Michel Chalufour <michelc@tiac.net> for grovelling around for
me.
 1.23 02-May-1997  briggs Thanks to Tobias Beal <tbeal41@maine.maine.edu>, we can clear interrupts
on at least one Radius Precisioncolor 8 board.
 1.22 01-May-1997  briggs Clear the interrupts properly on an E-Machines Futura II LX and make a wild
guess at clearing them on a Futura II SX/DSP and RasterOps ColorBoard 364.
Thanks to Michel Chalufour <michelc@tiac.net> for loaning me the II LX.
 1.21 14-Apr-1997  scottr Purely cosmetic cleanup:

- Remove unused `register' modifier on declarations
- Reverse the sense of some tests to make the code more clear
- Type casts per KNF
- Move a static variable into the only function that uses it (perhaps
we can eliminate it entirely, someday?)
 1.20 10-Apr-1997  briggs Ignore SE/30 faux-video card.
 1.19 01-Apr-1997  briggs Add DrHW for RasterOps CB264--From Scott Reynolds--and link it in to the
proper interrupt routine.
 1.18 01-Apr-1997  briggs - Support DAFB machines mo' better. Actually detect if a monitor is
present and initialize a few things. No color support, yet.
- Properly disable interrupts for DAFB.
- Rearrange for better nubus display card interrupt support. Only register
an interrupt if we know how to clear it.
- Complain if we don't know about a given display card and can not install
an interrupt handler.
- Change MYSTERY stuff to cb264--still need to get the DrSW so we can
actually call the routine to clear an interrupt from this card.
 1.17 24-Feb-1997  scottr NUBUS_SLOT_TO_PADDR -> NUBUS_SLOT2PA
 1.16 20-Feb-1997  scottr We need bus.h now, due to recent nubus_attach_args change.
 1.15 16-Dec-1996  scottr branches: 1.15.6;
Convert all foo_match() functions to use a `struct cfdata *' for their
second argument. The NuBus autoconfig code had to be reorganized as a
result of this, and looks much more like a directly-attached bus now.
These changes eliminate __BROKEN_INDIRECT_CONFIG.
 1.14 13-Oct-1996  christos backout previous kprintf change
 1.13 11-Oct-1996  christos printf -> kprintf, sprintf -> ksprintf
 1.12 04-Aug-1996  scottr Add a way to tell grf_establish() that internal video doesn't actually
occupy a slot. This is necessary so that GRFIOCMAP can find the correct
physical address of the framebuffer. Fixes P550, some LC models, and
perhaps the PB520.
 1.11 19-May-1996  scottr branches: 1.11.4;
New grf attachment code, mostly by Jason Thorpe with some cleanup by me.
This will allow dt and X to work with a generic kernel, rather than
compiling different kernels that attach grf0 to a NuBus adapter or
internal video.
 1.10 06-May-1996  briggs Set sc_slot--we need it later.
 1.9 06-May-1996  briggs Do not depend on the nubus being mapped in one huge segment.
 1.8 05-May-1996  briggs Prototype for -Wall -Wstrict-prototypes -Wmissing-prototypes -Wno-uninitialized
Also change the device probing scheme to use something a bit more rational.
A current side-effect is that nubus cards are double-mapped. I expect
to fix that shortly.
Also change splclock() to block everything but serial hardware interrupts.
 1.7 24-Aug-1995  briggs Some code to support a vector passed in from booter 1.8.
 1.6 06-Jul-1995  briggs Add another routine for the grf display-specific drivers to return a physical
address.
 1.5 02-Jul-1995  briggs Set and use new fboff element from grfmode structure.
 1.4 30-Jun-1995  briggs Fix oversight.
 1.3 21-Jun-1995  briggs Make no assumptions about the absolute address of nubus cards.
 1.2 06-May-1995  briggs Get rid of a printf() that got left behind in the probe.
 1.1 29-Apr-1995  briggs Add new nubus handling that's much more robust.
Update via, if_ae, and grf accordingly.
Revamp grf.
 1.11.4.1 05-Aug-1996  jtc Pulled up from rev 1.12 by request from Scott Reynolds
 1.15.6.1 12-Mar-1997  is Merge in changes from The Trunk, partially just reimplementing newarp.
 1.28.2.2 14-Oct-1997  thorpej Update marc-pcmcia branch from trunk.
 1.28.2.1 23-Aug-1997  thorpej Update marc-pcmcia branch from trunk.
 1.34.2.2 01-Dec-1997  mellon Pull rev 1.36 and 1.37 up from trunk (briggs) (reviewed by mellon)
 1.34.2.1 26-Oct-1997  mellon Pull rev 1.35 up from trunk (briggs)
 1.25 09-Aug-2022  rin Switch from ``(1 << depth) color'' to ``(depth)-bpp color'' in
attach message.

For depth == 32, fix ``0 color'', and prevent ambiguous ``16Mi color''.

I don't know whether there is 24-bpp graphic card for mac68k or not,
although.
 1.24 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.23 24-Apr-2021  thorpej branches: 1.23.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.22 26-Jul-2019  rin branches: 1.22.12;
Add genfb(4) driver for mac68k grfbus.
1, 2, 4, 8, 15, and 32 color-depths are supported.

ANSI colors on console are functional for depth >= 4.

Graphic applications based on wsfb API should work, provided
they can correctly handle fbi_fboffset and your color depth.

wsfb driver of Xorg 1.20 and mlterm-fb (framebuffer version of
x11/mlterm) work fine for depth == 1 || depth >= 8.

For depth == 8 (256 colors), graphic applications require
colormap callback, which is currently supported for some
internal graphic adapters, and only Civic (found on Quadra
AV series) was tested. Register definition and its usage are
taken from Linux. You can easily support other adapters if
Linux supports that.

Have fun, and any problem reports are welcomed!
 1.21 27-Oct-2012  chs branches: 1.21.38;
split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.20 28-Apr-2008  martin branches: 1.20.34; 1.20.44;
Remove clause 3 and 4 from TNF licenses
 1.19 11-Dec-2005  christos branches: 1.19.74; 1.19.76; 1.19.78;
merge ktrace-lwp.
 1.18 15-Jan-2005  chs de-__P, remove register, ansify, b* -> mem*.
 1.17 15-Jul-2003  lukem __KERNEL_RCSID()
 1.16 01-Jan-2003  thorpej branches: 1.16.2;
Use aprint_normal() for cfprint routines.
 1.15 14-Feb-2000  scottr branches: 1.15.12;
Merge wscons work onto the main development branch.
 1.14 12-Aug-1998  scottr branches: 1.14.6; 1.14.14;
New and improved console framebuffer initialization and autoconfig. This
resolves a great many issues, including Performa 58x interrupt handling
and offset displays on some models.

Programs that depend on the old (pre-NetBSD 1.1) grf interface may break.
That's actually a separate issue uncovered by this code, not caused by it.
 1.13 01-Jul-1998  scottr Add a GRF_COMPAT option so that old-style grf ioctl() code can be
removed from the kernel.
 1.12 02-Jun-1998  scottr Store the PA of the framebuffer in the softc. This eliminates the need
for the sc_phys callback; we can just store the PA in the grfbus attach
args, rather than a function pointer, which simplifies the code nicely.
 1.11 02-May-1998  scottr Move on-board I/O and NuBus drivers to their own directories
via repository copy, and make the necessary adjustments to reflect
the moved files.
 1.10 09-Oct-1997  jtc Fix tipo inherited from old version of TNF copyright template.
 1.9 03-Aug-1997  scottr Fix typo found by Colin Wood, PR 3934: ga_handle should get the value of
the handle, not the tag.
 1.8 03-Aug-1997  scottr Adjust grf_establish() prototype.
 1.7 11-May-1997  scottr branches: 1.7.4;
Implement new NuBus slot space mapping/probing code, utilizing bus.h (and
our MD bus_space_probe() extension). This has several side effects:

- NuBus drivers must map and unmap slot space, rather than relying
on this happening before they are attached.
- Functions exported to NuBus drivers from nubus.c now need to be
supplied with a bus space tag/handle pair.
- Old bus map/peek functions can be garbage collected, as can pmap
support for the same.

Because of some current limitations of the bus space specification, we
are violating the abstraction in grf_mv (NuBus grf driver). All such
violations are clearly marked /* XXX */, and must be addressed when
the specification is updated.
 1.6 20-Feb-1997  scottr We need bus.h now, due to recent nubus_attach_args change.
 1.5 13-Oct-1996  christos branches: 1.5.6;
backout previous kprintf change
 1.4 11-Oct-1996  christos printf -> kprintf, sprintf -> ksprintf
 1.3 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.2 04-Aug-1996  scottr Add a way to tell grf_establish() that internal video doesn't actually
occupy a slot. This is necessary so that GRFIOCMAP can find the correct
physical address of the framebuffer. Fixes P550, some LC models, and
perhaps the PB520.
 1.1 19-May-1996  scottr branches: 1.1.4;
New grf attachment code, mostly by Jason Thorpe with some cleanup by me.
This will allow dt and X to work with a generic kernel, rather than
compiling different kernels that attach grf0 to a NuBus adapter or
internal video.
 1.1.4.1 05-Aug-1996  jtc Pulled up from rev 1.2 by request from Scott Reynolds
 1.5.6.1 12-Mar-1997  is Merge in changes from The Trunk, partially just reimplementing newarp.
 1.7.4.2 14-Oct-1997  thorpej Update marc-pcmcia branch from trunk.
 1.7.4.1 23-Aug-1997  thorpej Update marc-pcmcia branch from trunk.
 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.14.6.1 11-Mar-1999  scottr First cut at grf emulation. Neither GRFIOCMAP nor mmap'ing a wsdisplay device
work, though several other grf ioctls are properly emulated.
 1.15.12.1 03-Jan-2003  thorpej Sync with HEAD.
 1.16.2.4 17-Jan-2005  skrll Sync with HEAD.
 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.19.78.1 16-May-2008  yamt sync with head.
 1.19.76.1 18-May-2008  yamt sync with head.
 1.19.74.1 02-Jun-2008  mjf Sync with HEAD.
 1.20.44.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.20.34.1 30-Oct-2012  yamt sync with head
 1.21.38.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.22.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.23.8.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.3 30-Jul-1994  mycroft Clean up deleted files.
 1.2 29-Nov-1993  briggs Update to current work in progress. This includes an update to
use config.new.
Numerous updates to console so it works better on the SE/30 screen.
Some nice changes from Brad Parker for handling NuBUS and an ethernet
driver that I haven't worked on, yet.
 1.1 29-Sep-1993  briggs branches: 1.1.1;
Initial revision
 1.1.1.1 29-Sep-1993  briggs The current MacBSD architecture sub-directory for NetBSD-0.9--more or
less. It needs some help to get to be -current. Support for minimal
hardware on the SE/30, II, IIx, and IIcx exists.
 1.32 26-Jul-2019  rin Add genfb(4) driver for mac68k grfbus.
1, 2, 4, 8, 15, and 32 color-depths are supported.

ANSI colors on console are functional for depth >= 4.

Graphic applications based on wsfb API should work, provided
they can correctly handle fbi_fboffset and your color depth.

wsfb driver of Xorg 1.20 and mlterm-fb (framebuffer version of
x11/mlterm) work fine for depth == 1 || depth >= 8.

For depth == 8 (256 colors), graphic applications require
colormap callback, which is currently supported for some
internal graphic adapters, and only Civic (found on Quadra
AV series) was tested. Register definition and its usage are
taken from Linux. You can easily support other adapters if
Linux supports that.

Have fun, and any problem reports are welcomed!
 1.31 27-Oct-2012  chs branches: 1.31.38;
split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.30 08-Feb-2011  rmind branches: 1.30.4; 1.30.14;
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.29 04-Mar-2007  christos branches: 1.29.66; 1.29.72; 1.29.74;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.28 11-Dec-2005  christos branches: 1.28.26;
merge ktrace-lwp.
 1.27 03-Jun-2005  rjs branches: 1.27.2;
Add const.
 1.26 15-Jan-2005  chs de-__P, remove register, ansify, b* -> mem*.
 1.25 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.24 14-Feb-2000  scottr branches: 1.24.28;
Merge wscons work onto the main development branch.
 1.23 22-Dec-1998  scottr branches: 1.23.2; 1.23.10;
vm_offset_t -> {paddr_t, vaddr_t}
 1.22 12-Aug-1998  scottr New and improved console framebuffer initialization and autoconfig. This
resolves a great many issues, including Performa 58x interrupt handling
and offset displays on some models.

Programs that depend on the old (pre-NetBSD 1.1) grf interface may break.
That's actually a separate issue uncovered by this code, not caused by it.
 1.21 02-Jun-1998  scottr Store the PA of the framebuffer in the softc. This eliminates the need
for the sc_phys callback; we can just store the PA in the grfbus attach
args, rather than a function pointer, which simplifies the code nicely.
 1.20 03-Aug-1997  scottr Adjust prototype for ga_phys field in grfbus_attach_args.
 1.19 03-Aug-1997  scottr Adjust grf_establish() prototype.
 1.18 03-Aug-1997  scottr Overhaul grf drivers to correct recent problems with X and dt
(address error faults), as well as other reported problems:

- Simplify grfmv_phys() to work like grfiv_phys(), and eliminate the
second argument to both, as we don't use it anyway.
- Handle fbbase and fboff consistently throughout. Closes PR 3862.
- Eliminate grfaddr() by pulling it into grfmmap(), which is the
only place it was used, previously.
- grfmap() now gets the physical address of the framebuffer from
the appropriate driver, rather than try to compute it by itself.
Be careful with aligning the base to a page address and increase
the length of the mapped region appropriately. Closes PR 2867.
 1.17 26-Jul-1997  scottr branches: 1.17.2;
cli_offset should be a bus_size_t now, and cli_value is an unsigned 32-bit int.
 1.16 11-May-1997  scottr Implement new NuBus slot space mapping/probing code, utilizing bus.h (and
our MD bus_space_probe() extension). This has several side effects:

- NuBus drivers must map and unmap slot space, rather than relying
on this happening before they are attached.
- Functions exported to NuBus drivers from nubus.c now need to be
supplied with a bus space tag/handle pair.
- Old bus map/peek functions can be garbage collected, as can pmap
support for the same.

Because of some current limitations of the bus space specification, we
are violating the abstraction in grf_mv (NuBus grf driver). All such
violations are clearly marked /* XXX */, and must be addressed when
the specification is updated.
 1.15 01-May-1997  briggs Clear the interrupts properly on an E-Machines Futura II LX and make a wild
guess at clearing them on a Futura II SX/DSP and RasterOps ColorBoard 364.
Thanks to Michel Chalufour <michelc@tiac.net> for loaning me the II LX.
 1.14 01-Apr-1997  briggs - Support DAFB machines mo' better. Actually detect if a monitor is
present and initialize a few things. No color support, yet.
- Properly disable interrupts for DAFB.
- Rearrange for better nubus display card interrupt support. Only register
an interrupt if we know how to clear it.
- Complain if we don't know about a given display card and can not install
an interrupt handler.
- Change MYSTERY stuff to cb264--still need to get the DrSW so we can
actually call the routine to clear an interrupt from this card.
 1.13 14-Sep-1996  scottr Implement poll(2).
 1.12 14-Sep-1996  scottr Update prototypes to match Chris' cfprint_t change. Also, update comments
in autoconf.h to reflect the mainbus.c split.
 1.11 04-Aug-1996  scottr Add a way to tell grf_establish() that internal video doesn't actually
occupy a slot. This is necessary so that GRFIOCMAP can find the correct
physical address of the framebuffer. Fixes P550, some LC models, and
perhaps the PB520.
 1.10 19-May-1996  scottr branches: 1.10.4;
New grf attachment code, mostly by Jason Thorpe with some cleanup by me.
This will allow dt and X to work with a generic kernel, rather than
compiling different kernels that attach grf0 to a NuBus adapter or
internal video.
 1.9 05-May-1996  briggs Prototype for -Wall -Wstrict-prototypes -Wmissing-prototypes -Wno-uninitialized
Also change the device probing scheme to use something a bit more rational.
A current side-effect is that nubus cards are double-mapped. I expect
to fix that shortly.
Also change splclock() to block everything but serial hardware interrupts.
 1.8 06-Jul-1995  briggs Add another routine for the grf display-specific drivers to return a physical
address.
 1.7 29-Apr-1995  briggs Add new nubus handling that's much more robust.
Update via, if_ae, and grf accordingly.
Revamp grf.
 1.6 21-Apr-1995  briggs Handle grf_softc in the config.new manner.
Should have been done long ago.
 1.5 21-Apr-1995  briggs First pass of KNFication. Needs more.
 1.4 23-Mar-1995  briggs KERNEL -> _KERNEL
 1.3 26-Oct-1994  cgd new RCS ID format.
 1.2 29-Nov-1993  briggs Update to current work in progress. This includes an update to
use config.new.
Numerous updates to console so it works better on the SE/30 screen.
Some nice changes from Brad Parker for handling NuBUS and an ethernet
driver that I haven't worked on, yet.
 1.1 29-Sep-1993  briggs branches: 1.1.1;
Initial revision
 1.1.1.1 29-Sep-1993  briggs The current MacBSD architecture sub-directory for NetBSD-0.9--more or
less. It needs some help to get to be -current. Support for minimal
hardware on the SE/30, II, IIx, and IIcx exists.
 1.10.4.1 05-Aug-1996  jtc Pulled up from rev 1.11 by request from Scott Reynolds
 1.17.2.1 23-Aug-1997  thorpej Update marc-pcmcia branch from trunk.
 1.23.10.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.23.2.2 20-Nov-1999  scottr G/C the sc_isopen field in out softc.
 1.23.2.1 15-Nov-1999  scottr Implement a more straightforward approach to grf emulation.
 1.24.28.5 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.24.28.4 17-Jan-2005  skrll Sync with HEAD.
 1.24.28.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.24.28.2 18-Sep-2004  skrll Sync with HEAD.
 1.24.28.1 03-Aug-2004  skrll Sync with HEAD
 1.27.2.1 03-Sep-2007  yamt sync with head.
 1.28.26.1 12-Mar-2007  rmind Sync with HEAD.
 1.29.74.1 17-Feb-2011  bouyer Sync with HEAD
 1.29.72.1 06-Jun-2011  jruoho Sync with HEAD.
 1.29.66.1 05-Mar-2011  rmind sync with head
 1.30.14.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.30.4.1 30-Oct-2012  yamt sync with head
 1.31.38.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.80 19-Jan-2010  pooka Redefine bpf linkage through an always present op vector, i.e.
#if NBPFILTER is no longer required in the client. This change
doesn't yet add support for loading bpf as a module, since drivers
can register before bpf is attached. However, callers of bpf can
now be modularized.

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

Tested with i386/MONOLITHIC, modified MONOLITHIC without bpf and rump.
 1.79 06-Jan-2007  martin branches: 1.79.48;
If we have a single byte left over after filling in all mbuf data, we need
to increase the "totlen" count too. From Sungwon Chung.
 1.78 09-Sep-2006  tsutsui branches: 1.78.4;
Apply patch from Scott Reynolds in PR port-mac68k/32583
with some tweaks (add a comment and macro):
Handle odd byte case correctly in (ETHER_MIN_LEN-ETHER_CRC_LEN) padding
so that bus_space_set_region_2() won't be called with count==0.
 1.77 11-Dec-2005  christos branches: 1.77.8; 1.77.18; 1.77.20;
merge ktrace-lwp.
 1.76 15-Jan-2005  chs branches: 1.76.8; 1.76.10;
de-__P, remove register, ansify, b* -> mem*.
 1.75 15-Jul-2003  lukem branches: 1.75.6;
__KERNEL_RCSID()
 1.74 22-Jan-2003  bouyer branches: 1.74.2;
We want bus_space_set_region_2(), not _1() here.
 1.73 21-Jan-2003  jdolecek fix pasto in previous to make this compile
 1.72 15-Jan-2003  bouyer Zero out the NIC memory when padding packet to ETHER_MIN_LEN-ETHER_CRC_LEN
sc->write_mbuf now return len of buffer, including padding.
Tested with a PCI ne2000.
 1.71 10-Nov-2001  jklos branches: 1.71.10;
Now properly probes for cards with 64k of buffer. Reversed order
of tests in case space isn't fully decoded.
 1.70 13-Sep-2000  scottr branches: 1.70.4; 1.70.6; 1.70.8;
Resolve bus_space_write_region_2() type mismatches.
 1.69 13-Sep-2000  scottr ae_write_mbuf() broke with the last change; revert.
 1.68 30-Jul-2000  briggs Make bus_space_write_region_2 usage match prototype.
 1.67 12-Jan-1998  thorpej branches: 1.67.16; 1.67.26;
Update for changes to config.
 1.66 02-Nov-1997  thorpej Adjust for ifmedia-related changes to dp8390 driver.
 1.65 11-Aug-1997  scottr branches: 1.65.4;
Make #include directives consistent. All MD headers are of the form:

#include <mac68k/{dev,mac68k}/foo.h>
 1.64 29-Apr-1997  scottr branches: 1.64.4;
Use the new MI 8390 driver, and garbage collect.
 1.63 28-Apr-1997  scottr From Mycroft: Oops; forgot to GC the last mbuf allocated when
out of clusters.
 1.62 24-Apr-1997  scottr From Mycroft: If we fail to allocate a cluster to hold a large packet,
simply drop it rather than using a chain of tiny mbufs.
 1.61 14-Apr-1997  scottr Purely cosmetic cleanup:

- Remove unused `register' modifier on declarations
- Reverse the sense of some tests to make the code more clear
- Type casts per KNF
- Move a static variable into the only function that uses it (perhaps
we can eliminate it entirely, someday?)
 1.60 19-Mar-1997  scottr Several more changes to move us toward MI-ness:

- Use more consistent and portable types in the softc.
- Map registers using an array of bus_size_t offsets, and set up the
mapping in the attach code (thanks to Jason Thorpe for suggesting
this!).
- Disable the ae-specific watchdog, which is no longer necessary in
the general case.

Still remaining: split out functions used to copy data to/from the
card, and retain a way to have a local driver name with the MI code.
 1.59 17-Mar-1997  scottr Clean up some missed pieces of the new ARP conversion.
 1.58 15-Mar-1997  is New ARP system, supports IPv4 over any hardware link.

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

For the detailed change history, look at the commit log entries for
the is-newarp branch.
 1.57 04-Mar-1997  scottr Correct offsets in the memory size probe; bus_space uses byte offsets. Fix suggested by
Ken Nakata.
 1.56 28-Feb-1997  scottr Define aesetup() to return an int, so that the attach function can
determine whether there was an error (if so, we unmap the slot space
for this device). Use this functionality to tell the attach function
that we couldn't clear the card's buffer.

Also in aesetup(), eliminate the bogus repetition of the error message
we print when the buffer clear actually fails. Noticed by Hauke Fath.
 1.55 28-Feb-1997  scottr Move the NuBus-specific watchdog function from if_ae.c to if_ae_nubus.c,
and allow the attach function to override the default watchdog. Also,
do some minor cosmetic surgery (rename bus space tags/handles and some
KNFing I missed the first time around).
 1.54 25-Feb-1997  scottr Move bus-independent setup code back into if_ae.c; enable the use of
configuration flags. For NuBus cards, attempt to find the MAC address
in the declaration ROM resources.
 1.53 24-Feb-1997  scottr Add support for the Kinetics EtherPort SE/30, from Ken Nakata.
 1.52 24-Feb-1997  scottr Split out the NuBus attachment code, and convert to bus.h
 1.51 22-Feb-1997  scottr Add bus.h, in light of recent nubus_attach_args changes
 1.50 18-Dec-1996  scottr branches: 1.50.6;
Work around uninitialized variable warning
 1.49 16-Dec-1996  scottr Convert all foo_match() functions to use a `struct cfdata *' for their
second argument. The NuBus autoconfig code had to be reorganized as a
result of this, and looks much more like a directly-attached bus now.
These changes eliminate __BROKEN_INDIRECT_CONFIG.
 1.48 13-Oct-1996  christos backout previous kprintf change
 1.47 11-Oct-1996  christos printf -> kprintf, sprintf -> ksprintf
 1.46 15-May-1996  briggs print the failure if we do not correctly determine the amount of RAM
on the ethernet card.
 1.45 07-May-1996  thorpej Changed struct ifnet to have a pointer to the softc of the underlying
device and a printable "external name" (name + unit number), thus eliminating
if_name and if_unit. Updated interface to (*if_watchdog)() and (*if_start)()
to take a struct ifnet *, rather than a unit number.
 1.44 06-May-1996  briggs Do not depend on the nubus being mapped in one huge segment.
 1.43 05-May-1996  briggs Prototype for -Wall -Wstrict-prototypes -Wmissing-prototypes -Wno-uninitialized
Also change the device probing scheme to use something a bit more rational.
A current side-effect is that nubus cards are double-mapped. I expect
to fix that shortly.
Also change splclock() to block everything but serial hardware interrupts.
 1.42 29-Mar-1996  briggs via.h -> machine/viareg.h.
 1.41 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.40 02-Feb-1996  briggs Force the talley counters to be read when we get the interrupt. GCC was
nicely optimizing the reads out for us. Kudos for this one go to
Steven R. Weiss <srw@hvcn.org>.
 1.39 13-Jan-1996  briggs Fix typo in last change.
 1.38 12-Jan-1996  briggs Patch to at least recognise FOCUS EtherLAN. From Erik Bertelson
<erik@sockdev.uni-c.dk>
 1.37 24-Dec-1995  mycroft The IST_* and IPL_* constants are not bus-specific; don't treat them as such.
Change splimp -> splnet in Ethernet, ARCnet, and FDDI drivers.
 1.36 24-Sep-1995  briggs Add Technology Works ethernet card. From
Kazunari Nakamura <kazu@nkk.co.jp>.
 1.35 09-Aug-1995  briggs Missing increment operator for if_opackets in last change.
 1.34 30-Jul-1995  briggs Fix signed/unsigned gaff in last.
Bring up-to-date with latest rash of changes to if_ed.c.
 1.33 30-Jul-1995  briggs Add support for Farallon from Brian Gaeke (brg@dgate.org).
 1.32 30-Jul-1995  briggs Read the packet header count in bytes, not as a word--word reads return
invalid data on some cards (notably old Apple Ethernet NB and Farallon
cards at least).
 1.31 28-Jun-1995  cgd note that most of dev/ic's contents have changed names
 1.30 21-Jun-1995  briggs Treat 0 as a failure case for ae_id_card() and take out
null-op check for a 0 addrlist in init.
 1.29 05-May-1995  briggs Add some code/defines to differentiate Asante and Interlan/Gator cards
correctly with the new nubus code.
 1.28 29-Apr-1995  briggs Add new nubus handling that's much more robust.
Update via, if_ae, and grf accordingly.
Revamp grf.
 1.27 22-Apr-1995  briggs Add some multicast byteorder-related changes from djh@mulga.cs.mu.OZ.AU.
 1.26 21-Apr-1995  briggs Enable nubus interrupts after registering.
 1.25 21-Apr-1995  briggs First pass of KNFication. Needs more.
 1.24 19-Apr-1995  briggs Initialize totlen in ae_put. Thanks to chopps for pointing it out!
Also, switch back from using struct ed_ring to using struct ae_ring
because BYTE_ORDER == BIG_ENDIAN, but the card is in x86 byte order
mode because NuBUS does the swap "for us" on 16- and 32-bit transfers.
We should probably figure some way to use the std ed_ring if/when
all the 8390 drivers are all fully merged.
 1.23 16-Apr-1995  briggs Get this working. Mainly, don't always round to word transfers on
receive.
 1.22 13-Apr-1995  briggs Update to use dev/ic/dp8390.h. Mostly from mycroft.
Still get extra data on either transmit or recieve, but want to
checkpoint this work.
 1.21 12-Apr-1995  briggs Almost working synch with if_ed.c. Much by mycroft. Fixups by me.
Inserts garbage characters--this driver isn't ready for use quite yet.
 1.20 08-Apr-1995  briggs Fixup types of a few functions to match if.h structure.
 1.19 08-Apr-1995  briggs Print a diagnostic if we do hit the watchdog and recover w/o resetting.
 1.18 23-Mar-1995  briggs Serious kludge around network timeouts. Network timeouts seem to be
caused by the VIA missing the ethernet slot interrupt. If we get a
watchdog, try calling the via's nubus interrupt function. If that
causes an interrupt, don't reset anything. If it doesn't, use old
behavior (log timeout and reset).

Yuck.
 1.17 01-Mar-1995  briggs Raise watchdog timer a tad.
 1.16 04-Dec-1994  briggs Nuke Log in if_aereg.h and remove duplicate (and benign) sc->smem_size
assignment from Brad Parker (brad@fcr.com).
 1.15 03-Dec-1994  briggs At least somewhat functional ethernet driver from Brad Parker
(brad@fcr.com). Requires changes to via.c which are coming with
other changes in a moment...
 1.14 26-Oct-1994  cgd new RCS ID format.
 1.13 26-Jun-1994  briggs MIN -> min. This needs a lot of work.
 1.12 20-Mar-1994  lkestel Fixed a few major bugs. add_nubus_intr() was getting the wrong address,
and bcopy and bzero were being used. The latter use longs to copy/zero,
and some ethernet cards can't handle longs. I've added bbcopy and bbzero
as a temporary hack, but these should later be added to locore and maybe
changed to use shorts. Still doesn't work: I can now get an interrupt on
the first transmit, but further transmits don't generate more interrupts.
 1.11 20-Mar-1994  briggs Goof. Missed some mods in the changes to config.new a long time ago.
Thanks go to kesteloo@cs.unc.edu (Lawrence Kesteloot) for finding this.
 1.10 01-Mar-1994  briggs More Dayna separation.
 1.9 27-Feb-1994  briggs A little clean-up.
 1.8 26-Feb-1994  briggs Cleaned up the probe a little by actually using data from the decl. ROMs.
 1.7 23-Feb-1994  briggs Bail out in the probe since it's not safe at the moment (hangs on my
DaynaPort card). Will fix when I get docs for the card.
 1.6 22-Feb-1994  briggs Get rid of if_init assignment.
 1.5 30-Jan-1994  briggs Include-cop strikes again.
 1.4 24-Jan-1994  briggs Apply patch as suggested by Theo.
 1.3 21-Dec-1993  briggs Update ethernet driver to use config.new. At least, it's a first stab
working from mycroft's magnum changes to if_ed.c.
 1.2 15-Dec-1993  briggs Get rid of IFF_ALTPHYS and hence IFF_LLC0 reference. It doesn't appear
to have been used in this driver ;-)
 1.1 29-Nov-1993  briggs Update to current work in progress. This includes an update to
use config.new.
Numerous updates to console so it works better on the SE/30 screen.
Some nice changes from Brad Parker for handling NuBUS and an ethernet
driver that I haven't worked on, yet.
 1.50.6.3 12-Mar-1997  is Merge in changes from The Trunk, partially just reimplementing newarp.
 1.50.6.2 10-Mar-1997  is netinet/if_ether.h => netinet/if_inarp.h
 1.50.6.1 04-Mar-1997  is Convert to the new world order.
 1.64.4.1 23-Aug-1997  thorpej Update marc-pcmcia branch from trunk.
 1.65.4.1 05-Nov-1997  thorpej Pull up from trunk: update for ifmedia changes to dp8390.c
 1.67.26.3 23-Feb-2002  he Pull up revision 1.71 (requested by jklos):
Detect the full 64KB of buffer on many Nubus ethernet cards.
Fixes PR#14455.
 1.67.26.2 14-Sep-2000  scottr Pull up revs 1.69 and 1.70 from scottr:
The last change causes garbage data to be sent. Revert and
implement a different solution.
 1.67.26.1 06-Aug-2000  briggs Pullups approved by thorpej --
Add byte-swap and stride options to bus_space. Allocate as normal, then
call mac68k_bus_space_handle_swapped() or mac68k_bus_space_handle_set_stride().
Stride is untested. Swapped code works for SMC ethernet.

Add bus_space_*_stream_N functions to bus_space.

Add a DIAGNOSTIC panic if (count-using) bus_space macros are called with
a count of zero. Some drivers do this accidentally and some bus_space
implementations will fail if count is passed as zero (they are set up in
a do-{}-while structure).

There were some bogus assumptions about bus_space_handle_t and some
function calls that didn't match prototypes--fix those here, too.
 1.67.16.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.70.8.2 17-Jan-2003  thorpej Sync with HEAD.
 1.70.8.1 08-Jan-2002  nathanw Catch up to -current.
 1.70.6.1 12-Nov-2001  thorpej Sync the thorpej-mips-cache branch with -current.
 1.70.4.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.71.10.2 28-Jan-2003  jmc Pullup revisions 1.73-1.74 (requested by bouyer in ticket #1124)
We want bus_space_set_region_2(), not _1() here.
 1.71.10.1 27-Jan-2003  jmc Pullup revisions 1.71-1.73 (requested by bouyer in ticket #1096)
Zero out the NIC memory when padding packet to
ETHER_MIN_LEN-ETHER_CRC_LEN sc->write_mbuf now return len of
buffer, including padding.
 1.74.2.4 17-Jan-2005  skrll Sync with HEAD.
 1.74.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.74.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.74.2.1 03-Aug-2004  skrll Sync with HEAD
 1.75.6.1 11-Sep-2006  tron Pull up following revision(s) (requested by tsutsui in ticket #10692):
sys/arch/mac68k/dev/if_ae.c: revision 1.78
Apply patch from Scott Reynolds in PR port-mac68k/32583
with some tweaks (add a comment and macro):
Handle odd byte case correctly in (ETHER_MIN_LEN-ETHER_CRC_LEN) padding
so that bus_space_set_region_2() won't be called with count==0.
 1.76.10.2 26-Feb-2007  yamt sync with head.
 1.76.10.1 30-Dec-2006  yamt sync with head.
 1.76.8.1 16-Sep-2006  ghen Pull up following revision(s) (requested by tsutsui in ticket #1512):
sys/arch/mac68k/include/bus.h: revision 1.25
sys/arch/mac68k/dev/if_ae.c: revision 1.78
Apply patch from Scott Reynolds in PR port-mac68k/32583
with some tweaks (add a comment and macro):
Handle odd byte case correctly in (ETHER_MIN_LEN-ETHER_CRC_LEN) padding
so that bus_space_set_region_2() won't be called with count==0.
Apply patch in PR port-mac68k/33636 from Dave Huang (with wrapping long lines).
i.e. args in macro should be wrapped with parentheses.
 1.77.20.2 12-Jan-2007  ad Sync with head.
 1.77.20.1 18-Nov-2006  ad Sync with head.
 1.77.18.1 14-Sep-2006  riz Pull up following revision(s) (requested by tsutsui in ticket #154):
sys/arch/mac68k/include/bus.h: revision 1.25
sys/arch/mac68k/dev/if_ae.c: revision 1.78
Apply patch from Scott Reynolds in PR port-mac68k/32583
with some tweaks (add a comment and macro):
Handle odd byte case correctly in (ETHER_MIN_LEN-ETHER_CRC_LEN) padding
so that bus_space_set_region_2() won't be called with count==0.
Apply patch in PR port-mac68k/33636 from Dave Huang (with wrapping long lines).
i.e. args in macro should be wrapped with parentheses.
 1.77.8.1 14-Sep-2006  yamt sync with head.
 1.78.4.1 06-Jan-2007  bouyer Pull up following revision(s) (requested by martin in ticket #335):
sys/arch/mac68k/dev/if_ae.c: revision 1.79
If we have a single byte left over after filling in all mbuf data, we need
to increase the "totlen" count too. From Sungwon Chung.
 1.79.48.1 11-Mar-2010  yamt sync with head
 1.26 02-May-1998  scottr Move on-board I/O and NuBus drivers to their own directories
via repository copy, and make the necessary adjustments to reflect
the moved files.
 1.25 25-Apr-1998  scottr Garbage collect the second (slot number) parameter to NuBus interrupt
handlers. (Only slot_ignore() and slot_noint() need this, and we already
have a place to put this information.) Adjust add_nubus_intr() so that if
the client_data arg is specified as NULL, pass the slot number as
client_data to the interrupt handler.
 1.24 02-Nov-1997  thorpej Adjust for ifmedia-related changes to dp8390 driver.
 1.23 17-Oct-1997  briggs branches: 1.23.2;
Make this compile again.
 1.22 15-Oct-1997  thorpej Pulldown from marc-pcmcia branch: adapt to changes in the MI dp8390 driver.
 1.21 10-Oct-1997  scottr Remove advertising clause.
 1.20 26-Sep-1997  briggs Add another Dayna card to the Apple-compa. list.
Define a constant for the SuperMac Spectrum/24 series III display card.
Thanks go to Luca Falzoni <falzoni@jetai.unipv.it> for trying out the
code for the Dayna ethernet support.
 1.19 11-Aug-1997  scottr Make #include directives consistent. All MD headers are of the form:

#include <mac68k/{dev,mac68k}/foo.h>
 1.18 11-May-1997  scottr branches: 1.18.4;
Implement new NuBus slot space mapping/probing code, utilizing bus.h (and
our MD bus_space_probe() extension). This has several side effects:

- NuBus drivers must map and unmap slot space, rather than relying
on this happening before they are attached.
- Functions exported to NuBus drivers from nubus.c now need to be
supplied with a bus space tag/handle pair.
- Old bus map/peek functions can be garbage collected, as can pmap
support for the same.

Because of some current limitations of the bus space specification, we
are violating the abstraction in grf_mv (NuBus grf driver). All such
violations are clearly marked /* XXX */, and must be addressed when
the specification is updated.
 1.17 01-May-1997  briggs Treat drhw 118 and 119 the same for Apple ethernet cards.
 1.16 30-Apr-1997  scottr Fix typo in last change.
 1.15 30-Apr-1997  scottr Adjust to use16bit -> dcr_reg change in MI driver.
 1.14 29-Apr-1997  scottr Use the new MI 8390 driver, and garbage collect.
 1.13 22-Apr-1997  scottr Remove obsolete drsw diagnostic
 1.12 10-Apr-1997  briggs Changes from Bob Nestor to come closer to supporting his Apple SONIC-based
nubus card.
 1.11 19-Mar-1997  scottr Several more changes to move us toward MI-ness:

- Use more consistent and portable types in the softc.
- Map registers using an array of bus_size_t offsets, and set up the
mapping in the attach code (thanks to Jason Thorpe for suggesting
this!).
- Disable the ae-specific watchdog, which is no longer necessary in
the general case.

Still remaining: split out functions used to copy data to/from the
card, and retain a way to have a local driver name with the MI code.
 1.10 18-Mar-1997  briggs Help this compile and get the nubus address into myaddr instead of
sc->sc_arpcom.ac_enaddr.
 1.9 17-Mar-1997  scottr Some cards we identify as InterLAN cards do not seem to have the MAC
address in the configuration ROM. For these, fall back to the old method
if we can't find the expected sResource record.
 1.8 15-Mar-1997  scottr Defer enabling NuBus slot interrupts until all slots have been probed
and drivers attached. This removes the need for the MAC68K_BROKEN_VIDEO
option. From Allen Briggs.
 1.7 15-Mar-1997  is New ARP system, supports IPv4 over any hardware link.

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

For the detailed change history, look at the commit log entries for
the is-newarp branch.
 1.6 10-Mar-1997  scottr branches: 1.6.2;
Add missing call to ae_nb_get_enaddr(), from <kei_sun@ba2.so-net.or.jp>.
Fixes PR 3312.
 1.5 28-Feb-1997  scottr Define aesetup() to return an int, so that the attach function can
determine whether there was an error (if so, we unmap the slot space
for this device). Use this functionality to tell the attach function
that we couldn't clear the card's buffer.

Also in aesetup(), eliminate the bogus repetition of the error message
we print when the buffer clear actually fails. Noticed by Hauke Fath.
 1.4 28-Feb-1997  scottr Move the NuBus-specific watchdog function from if_ae.c to if_ae_nubus.c,
and allow the attach function to override the default watchdog. Also,
do some minor cosmetic surgery (rename bus space tags/handles and some
KNFing I missed the first time around).
 1.3 25-Feb-1997  scottr Move bus-independent setup code back into if_ae.c; enable the use of
configuration flags. For NuBus cards, attempt to find the MAC address
in the declaration ROM resources.
 1.2 24-Feb-1997  scottr Add support for the Kinetics EtherPort SE/30, from Ken Nakata.
 1.1 24-Feb-1997  scottr Split out the NuBus attachment code, and convert to bus.h
 1.6.2.2 12-Mar-1997  is Merge in changes from The Trunk, partially just reimplementing newarp.
 1.6.2.1 10-Mar-1997  is file if_ae_nubus.c was added on branch is-newarp on 1997-03-12 15:08:37 +0000
 1.18.4.5 14-Oct-1997  thorpej Mark this interface as enabled right from the get-go.
 1.18.4.4 14-Oct-1997  thorpej Update marc-pcmcia branch from trunk.
 1.18.4.3 14-Oct-1997  thorpej Adapt to changes in the generic DP8390 driver.
 1.18.4.2 29-Sep-1997  thorpej Update marc-pcmcia branch from trunk.
 1.18.4.1 23-Aug-1997  thorpej Update marc-pcmcia branch from trunk.
 1.23.2.1 05-Nov-1997  thorpej Pull up from trunk: update for ifmedia changes to dp8390.c
 1.17 12-Aug-1998  scottr Support Cabletron Ethernet card, from John Marohn in PR 5762.
 1.16 29-Apr-1997  scottr Use the new MI 8390 driver, and garbage collect.
 1.15 15-Mar-1997  is New ARP system, supports IPv4 over any hardware link.

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

For the detailed change history, look at the commit log entries for
the is-newarp branch.
 1.14 24-Feb-1997  scottr Add support for the Kinetics EtherPort SE/30, from Ken Nakata.
 1.13 24-Feb-1997  scottr Split out the NuBus attachment code, and convert to bus.h
 1.12 12-Jan-1996  briggs branches: 1.12.8;
Patch to at least recognise FOCUS EtherLAN. From Erik Bertelson
<erik@sockdev.uni-c.dk>
 1.11 30-Jul-1995  briggs Add support for Farallon from Brian Gaeke (brg@dgate.org).
 1.10 28-Jun-1995  cgd note that most of dev/ic's contents have changed names
 1.9 21-Apr-1995  briggs First pass of KNFication. Needs more.
 1.8 19-Apr-1995  briggs Define struct ae_ring which is necessary because BYTE_ORDER == BIG_ENDIAN,
but the card is in x86 byte order mode because NuBUS does the swap "for us"
on 16- and 32-bit transfers. We should probably figure some way to use
the std struct ed_ring if/when all the 8390 drivers are all fully merged.
 1.7 13-Apr-1995  briggs Update to use dev/ic/dp8390.h. Mostly from mycroft.
Still get extra data on either transmit or recieve, but want to
checkpoint this work.
 1.6 12-Apr-1995  briggs Almost working synch with if_ed.c. Much by mycroft. Fixups by me.
Inserts garbage characters--this driver isn't ready for use quite yet.
 1.5 04-Dec-1994  briggs Nuke Log in if_aereg.h and remove duplicate (and benign) sc->smem_size
assignment from Brad Parker (brad@fcr.com).
 1.4 03-Dec-1994  briggs At least somewhat functional ethernet driver from Brad Parker
(brad@fcr.com). Requires changes to via.c which are coming with
other changes in a moment...
 1.3 26-Oct-1994  cgd new RCS ID format.
 1.2 01-Mar-1994  briggs More Dayna separation.
 1.1 29-Nov-1993  briggs Update to current work in progress. This includes an update to
use config.new.
Numerous updates to console so it works better on the SE/30 screen.
Some nice changes from Brad Parker for handling NuBUS and an ethernet
driver that I haven't worked on, yet.
 1.12.8.1 12-Mar-1997  is Merge in changes from The Trunk, partially just reimplementing newarp.
 1.10 11-Dec-2005  christos merge ktrace-lwp.
 1.9 15-Jan-2005  chs de-__P, remove register, ansify, b* -> mem*.
 1.8 29-Apr-1997  scottr branches: 1.8.58;
Use the new MI 8390 driver, and garbage collect.
 1.7 19-Mar-1997  scottr Several more changes to move us toward MI-ness:

- Use more consistent and portable types in the softc.
- Map registers using an array of bus_size_t offsets, and set up the
mapping in the attach code (thanks to Jason Thorpe for suggesting
this!).
- Disable the ae-specific watchdog, which is no longer necessary in
the general case.

Still remaining: split out functions used to copy data to/from the
card, and retain a way to have a local driver name with the MI code.
 1.6 15-Mar-1997  is New ARP system, supports IPv4 over any hardware link.

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

For the detailed change history, look at the commit log entries for
the is-newarp branch.
 1.5 28-Feb-1997  scottr branches: 1.5.2;
Define aesetup() to return an int, so that the attach function can
determine whether there was an error (if so, we unmap the slot space
for this device). Use this functionality to tell the attach function
that we couldn't clear the card's buffer.

Also in aesetup(), eliminate the bogus repetition of the error message
we print when the buffer clear actually fails. Noticed by Hauke Fath.
 1.4 28-Feb-1997  scottr Move the NuBus-specific watchdog function from if_ae.c to if_ae_nubus.c,
and allow the attach function to override the default watchdog. Also,
do some minor cosmetic surgery (rename bus space tags/handles and some
KNFing I missed the first time around).
 1.3 25-Feb-1997  scottr Move bus-independent setup code back into if_ae.c; enable the use of
configuration flags. For NuBus cards, attempt to find the MAC address
in the declaration ROM resources.
 1.2 24-Feb-1997  scottr Add support for the Kinetics EtherPort SE/30, from Ken Nakata.
 1.1 24-Feb-1997  scottr Split out the NuBus attachment code, and convert to bus.h
 1.5.2.2 12-Mar-1997  is Merge in changes from The Trunk, partially just reimplementing newarp.
 1.5.2.1 28-Feb-1997  is file if_aevar.h was added on branch is-newarp on 1997-03-12 15:08:39 +0000
 1.8.58.1 17-Jan-2005  skrll Sync with HEAD.
 1.59 29-Jun-2024  riastradh if_stats(9): Add ifp argument to if_stat..._ref.

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

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

PR kern/58377
 1.58 18-Sep-2022  thorpej Eliminate use of IFF_OACTIVE.
 1.57 24-Jan-2021  rin Add rnd(9) support.
 1.56 20-Oct-2020  roy branches: 1.56.2;
le(4): add link status change reporting to drivers which support it

Reviewed by thorpej@
Tested by martin@
 1.55 30-Jan-2020  martin Fix more typos
 1.54 30-Jan-2020  martin Fix typo
 1.53 29-Jan-2020  thorpej Adopt <net/if_stats.h>.
 1.52 27-Dec-2019  msaitoh branches: 1.52.2;
s/expresion/expression/ in comment.
 1.51 28-May-2019  msaitoh Use ETHER_LOCK()/ETHER_UNLOCK() for all ethernet drivers to protect ec_multi*.
 1.50 23-May-2019  msaitoh No functional change:
- Change ac(was arpcom) to ec(ethercom)
- Simplify MII structure initialization.
- u_int*_t -> uint*_t.
- KNF
 1.49 05-Feb-2019  msaitoh Remove very old IFF_NOTRAILERS flag.
 1.48 03-Sep-2018  riastradh Rename min/max -> uimin/uimax for better honesty.

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

HOWEVER! Some subsystems have

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Acknowledgment: riastradh@ greatly helped this work.
Thank you very much!
 1.40 19-Oct-2013  martin branches: 1.40.6;
Remove an unused variable
 1.39 27-Oct-2012  chs branches: 1.39.2;
split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.38 05-Apr-2010  joerg branches: 1.38.8; 1.38.18;
Push the bpf_ops usage back into bpf.h. Push the common ifp->if_bpf
check into the inline functions as well the fourth argument for
bpf_attach.
 1.37 19-Jan-2010  pooka branches: 1.37.2; 1.37.4;
Redefine bpf linkage through an always present op vector, i.e.
#if NBPFILTER is no longer required in the client. This change
doesn't yet add support for loading bpf as a module, since drivers
can register before bpf is attached. However, callers of bpf can
now be modularized.

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

Tested with i386/MONOLITHIC, modified MONOLITHIC without bpf and rump.
 1.36 18-Mar-2009  cegger bcmp -> memcmp
 1.35 07-Nov-2008  dyoung branches: 1.35.4;
*** Summary ***

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

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

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

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

Return consistent, appropriate error codes from network drivers.

Improve readability. KNF.

*** Details ***

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Let ifioctl_common() handle SIOCGIFADDR.

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

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

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

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

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

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.33 01-Sep-2007  jmmv Fix build after dyoung's changes.
 1.32 01-Sep-2007  dyoung Change a bazillion occurrences of code resembling this,

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

if (error == ENETRESET) {

to this,

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

which does the same thing.

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

Use ifreq_getaddr() twice in es(4).

Whitespace nits.
 1.31 05-Mar-2007  he branches: 1.31.2; 1.31.10; 1.31.14; 1.31.18; 1.31.20;
Cast to char* or u_char* before doing pointer arithmetic.
 1.30 04-Mar-2007  christos Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.29 24-Jan-2007  hubertf branches: 1.29.2;
Remove duplicate #includes, patch contributed in private mail
by Slava Semushin <slava.semushin@gmail.com>.

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

Thanks to martin@ for the input on testing.
 1.28 12-Dec-2006  martin Convert DMA memory allocation to bus_dmamem_alloc. From Dave Huang.
 1.27 07-Sep-2006  dogcow branches: 1.27.2; 1.27.4; 1.27.6;
remove more vestiges of CCITT, LLC, HDLC, NS, and NSIP.
 1.26 11-Dec-2005  christos branches: 1.26.4; 1.26.8;
merge ktrace-lwp.
 1.25 15-Jan-2005  chs branches: 1.25.10;
de-__P, remove register, ansify, b* -> mem*.
 1.24 30-Oct-2004  thorpej When adding/deleting multicast addresses, only whack the address
filter if the interface is marked RUNNING.

Fixes kern/27678.
 1.23 26-Mar-2004  wiz branches: 1.23.4;
Update David Huang's email address in the license
per his request in PR 24907.
 1.22 15-Jul-2003  lukem __KERNEL_RCSID()
 1.21 04-Jun-2003  bjh21 branches: 1.21.2;
In mcstop(), don't clear IFF_UP. Other drivers don't mess with IFF_UP
internally, other than to set it when they gain their first address.
Every caller of mcstop() bar one was either preserving the state of IFF_UP
itself or was conditional on its already being clear, so the only effect of
this is to simplify the code and to change that one case, thereby curing
PR port-macppc/12088 (underflows on "mc" cause it to be taken down).
 1.20 02-Apr-2003  thorpej Use PAGE_SIZE rather than NBPG.
 1.19 16-Jan-2002  thorpej branches: 1.19.10;
Use bpf_mtap().
 1.18 15-Nov-2000  thorpej branches: 1.18.4; 1.18.8;
Move bpfattach()/bpfdetach() calls into ether_ifattach()/ether_ifdetach().
 1.17 01-Oct-2000  thorpej Move the check for "promisc + unicast + not for us" into ether_input(),
and change Ethernet drivers to always pass all received frames to
ether_input() (with a few exceptions, which are documented in the
code).
 1.16 29-Jun-2000  mrg remove include of <vm/vm.h>. <vm/vm.h> -> <uvm/uvm_extern.h>
 1.15 20-Dec-1999  scottr branches: 1.15.4;
Make this compile without bpf. Problem noted by Bob Nestor, fix from
Frederick Bruckman.
 1.14 14-Oct-1999  scottr branches: 1.14.2;
Be less noisy about collision errors. From Dave Huang, closes PR 8605.
 1.13 18-May-1999  thorpej branches: 1.13.2;
Rework layer 2 protocol input routines. Instead of calling e.g. ether_input()
directly, call the function pointer (*if_input)(ifp, m). The input routine
expects the packet header to be at the head of the packet, and will adjust
as necessary. Privatize the layer 2 input and output routines, allowing
*_ifattach() to set them up as appropriate.
 1.12 22-Dec-1998  scottr branches: 1.12.2; 1.12.4; 1.12.6;
vm_offset_t -> {paddr_t, vaddr_t}
 1.11 08-Jul-1998  scottr branches: 1.11.6;
mac68k/obio/if_mc_obio.c needs hide/integrate defines, too. Moved back to
if_mcvar.h.
 1.10 05-Jul-1998  jonathan defopt NS, NSIP.
 1.9 05-Jul-1998  jonathan defopt LLC
 1.8 05-Jul-1998  jonathan defopt CCITT.
 1.7 05-Jul-1998  jonathan defopt INET, NETATALK.
 1.6 29-Mar-1998  mycroft Use a 4-bit table to speed up the CRC even further, without increasing the
code size too much.
 1.5 09-Mar-1998  scottr Sync mc_rint() prototype with if_mcvar.h. (How did this
one slip by? Forty lashes for me...)
 1.4 12-Jan-1998  thorpej Update for changes to config.
 1.3 07-Dec-1997  scottr Fix prototypes so that we can compile without DDB. Closes
PR 4633.
 1.2 07-Nov-1997  briggs NetBSD RCSIds.
 1.1 04-Nov-1997  briggs branches: 1.1.2;
Add in the if_mc ethernet driver for the AMD "MACE" part. This is the
internal ethernet on the Quadra/Centris 660av/840av.
Add initial support for the PSC (DMA controller) to support the above
(DMA SCSI remains unsupported). This involved also changing the way
that several interrupts are handled.
Above from David Huang <khym@bga.com>
Since the interrupts changed somewhat, we must also make the ipls
dynamic, defaulting to their prior levels and adjusted for the AVs.
I modelled this on the hp300.
 1.1.2.4 05-May-1998  mycroft Pull up 1.5, per request of scottr.
 1.1.2.3 09-Dec-1997  thorpej Sync w/ trunk: make it work without DDB (scottr)
 1.1.2.2 12-Nov-1997  mellon Pull rev 1.2 up from trunk (briggs)
 1.1.2.1 04-Nov-1997  mellon file if_mc.c was added on branch netbsd-1-3 on 1997-11-12 02:09:22 +0000
 1.11.6.1 11-Dec-1998  kenh The beginnings of interface detach support. Still some bugs, but mostly
works for me.

This work was originally by Bill Studenmund, and cleaned up by me.
 1.12.6.1 21-Jun-1999  thorpej Sync w/ -current.
 1.12.4.2 05-Jan-2000  he Undo pullup of revision 1.15 (requested by scottr).
The fix in that revision is not relevant to the netbsd-1-4 branch.
 1.12.4.1 20-Dec-1999  he Pull up revision 1.15 (requested by scottr):
Make this compile without bpf.
 1.12.2.3 13-Feb-2000  scottr Sync with main branch.
 1.12.2.2 02-Nov-1999  scottr [Redo] Sync with main branch.
 1.12.2.1 08-Jun-1999  scottr Sync with main branch.
 1.13.2.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.14.2.2 22-Nov-2000  bouyer Sync with HEAD.
 1.14.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.15.4.1 17-Jun-2003  msaitoh Pull up revisions 1.21 (requested by Ben Harris in ticket #46):
Don't bring down mc(4) interfaces when they underflow.
Fixes PR#12088.
 1.18.8.1 28-Feb-2002  nathanw Catch up to -current.
 1.18.4.1 11-Feb-2002  jdolecek Sync w/ -current.
 1.19.10.1 17-Jun-2003  msaitoh Pull up revisions 1.21 (requested by Ben Harris in ticket #1314):
Don't bring down mc(4) interfaces when they underflow.
Fixes PR#12088.
 1.21.2.5 17-Jan-2005  skrll Sync with HEAD.
 1.21.2.4 02-Nov-2004  skrll Sync with HEAD.
 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.4.1 24-Jan-2005  he Pull up revision 1.24 (requested by thorpej in ticket #939):
When adding or deleting multicast addresses, only change
the address filter if the interface is marked RUNNING.
Fixes PR#27678.
 1.25.10.3 03-Sep-2007  yamt sync with head.
 1.25.10.2 26-Feb-2007  yamt sync with head.
 1.25.10.1 30-Dec-2006  yamt sync with head.
 1.26.8.1 14-Sep-2006  yamt sync with head.
 1.26.4.1 09-Sep-2006  rpaulo sync with head
 1.27.6.1 15-Dec-2006  tron Pull up following revision(s) (requested by martin in ticket #272):
sys/arch/mac68k/dev/if_mc.c: revision 1.28
sys/arch/mac68k/obio/if_mc_obio.c: revision 1.16
sys/arch/mac68k/dev/if_mcvar.h: revision 1.12
Convert DMA memory allocation to bus_dmamem_alloc. From Dave Huang.
 1.27.4.1 18-Dec-2006  yamt sync with head.
 1.27.2.2 01-Feb-2007  ad Sync with head.
 1.27.2.1 12-Jan-2007  ad Sync with head.
 1.29.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.31.20.1 06-Nov-2007  matt sync with HEAD
 1.31.18.1 03-Sep-2007  jmcneill Sync with HEAD.
 1.31.14.1 03-Sep-2007  skrll Sync with HEAD.
 1.31.10.1 03-Oct-2007  garbled Sync with HEAD
 1.31.2.1 09-Oct-2007  ad Sync with head.
 1.34.28.2 28-Apr-2009  skrll Sync with HEAD.
 1.34.28.1 19-Jan-2009  skrll Sync with HEAD.
 1.34.26.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.34.20.3 11-Aug-2010  yamt sync with head.
 1.34.20.2 11-Mar-2010  yamt sync with head
 1.34.20.1 04-May-2009  yamt sync with head.
 1.34.16.1 17-Jan-2009  mjf Sync with HEAD.
 1.35.4.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.37.4.1 30-May-2010  rmind sync with head
 1.37.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.38.18.3 03-Dec-2017  jdolecek update from HEAD
 1.38.18.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.38.18.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.38.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.38.8.1 30-Oct-2012  yamt sync with head
 1.39.2.1 18-May-2014  rmind sync with head
 1.40.6.5 28-Aug-2017  skrll Sync with HEAD
 1.40.6.4 05-Feb-2017  skrll Sync with HEAD
 1.40.6.3 05-Oct-2016  skrll Sync with HEAD
 1.40.6.2 09-Jul-2016  skrll Sync with HEAD
 1.40.6.1 19-Mar-2016  skrll Sync with HEAD
 1.42.2.3 20-Mar-2017  pgoyette Sync with HEAD
 1.42.2.2 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.42.2.1 04-Nov-2016  pgoyette Sync with HEAD
 1.44.2.1 21-Apr-2017  bouyer Sync with HEAD
 1.45.12.3 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.45.12.2 28-Jul-2018  pgoyette Sync with HEAD
 1.45.12.1 25-Jun-2018  pgoyette Sync with HEAD
 1.45.6.1 26-Jul-2018  snj Pull up following revision(s) (requested by msaitoh in ticket #938):
sys/arch/acorn32/podulebus/if_ie.c: revision 1.41
sys/arch/amiga/dev/if_es.c: revision 1.58
sys/arch/amiga/dev/if_qn.c: revision 1.45
sys/arch/arm/at91/at91emac.c: revision 1.20
sys/arch/arm/ep93xx/epe.c: revision 1.37
sys/arch/emips/ebus/if_le_ebus.c: revision 1.14
sys/arch/emips/ebus/if_le_ebus.c: revision 1.15
sys/arch/mac68k/dev/if_mc.c: revision 1.46
sys/arch/macppc/dev/am79c950.c: revision 1.39
sys/arch/newsmips/apbus/if_sn.c: revision 1.40
sys/arch/next68k/dev/mb8795.c: revision 1.59
sys/arch/playstation2/dev/if_smap.c: revision 1.25
sys/arch/playstation2/dev/if_smap.c: revision 1.26
sys/arch/sun2/dev/if_ec.c: revision 1.28
sys/arch/sun3/dev/if_ie.c: revision 1.63
sys/arch/x68k/dev/if_ne_intio.c: revision 1.19
sys/arch/xen/xen/if_xennet_xenbus.c: revision 1.75
sys/arch/xen/xen/xennetback_xenbus.c: revision 1.63
sys/dev/bi/if_ni.c: revision 1.45
sys/dev/cadence/if_cemac.c: revision 1.12
sys/dev/ic/am7990.c: revision 1.78
sys/dev/ic/am79900.c: revision 1.27
sys/dev/ic/an.c: revision 1.67
sys/dev/ic/cs89x0.c: revision 1.40
sys/dev/ic/dm9000.c: revision 1.13
sys/dev/ic/dm9000.c: revision 1.14
sys/dev/ic/dp8390.c: revision 1.88
sys/dev/ic/elink3.c: revision 1.141
sys/dev/ic/elinkxl.c: revision 1.122
sys/dev/ic/hme.c: revision 1.98
sys/dev/ic/i82586.c: revision 1.77
sys/dev/ic/lance.c: revision 1.53
sys/dev/ic/mb86950.c: revision 1.27
sys/dev/ic/mb86960.c: revision 1.86
sys/dev/ic/mtd803.c: revision 1.34
sys/dev/ic/pdq_ifsubr.c: revision 1.59
sys/dev/ic/rrunner.c: revision 1.86
sys/dev/ic/seeq8005.c: revision 1.58
sys/dev/ic/sgec.c: revision 1.47
sys/dev/ic/smc90cx6.c: revision 1.72
sys/dev/ic/smc91cxx.c: revision 1.96
sys/dev/ic/tropic.c: revision 1.49
sys/dev/ic/wi.c: revision 1.245
sys/dev/isa/if_eg.c: revision 1.93
sys/dev/isa/if_el.c: revision 1.95
sys/dev/isa/if_iy.c: revision 1.101
sys/dev/ofw/ofnet.c: revision 1.58
sys/dev/pci/if_alc.c: revision 1.27
sys/dev/pci/if_de.c: revision 1.152
sys/dev/pci/if_fpa.c: revision 1.61
sys/dev/pci/if_jme.c: revision 1.34
sys/dev/pci/if_tl.c: revision 1.108
sys/dev/pci/if_vte.c: revision 1.19
sys/dev/pci/ixgbe/ixgbe.h: revision 1.50
sys/dev/pcmcia/if_cnw.c: revision 1.62
sys/dev/pcmcia/if_malo_pcmcia.c: revision 1.17
sys/dev/pcmcia/if_ray.c: revision 1.89
sys/dev/pcmcia/if_xi.c: revision 1.81
sys/dev/pcmcia/mhzc.c: revision 1.51
sys/dev/pcmcia/xirc.c: revision 1.34
sys/dev/qbus/if_de.c: revision 1.33
sys/dev/qbus/if_qe.c: revision 1.78
sys/dev/qbus/if_qt.c: revision 1.22
sys/dev/sbus/be.c: revision 1.87
sys/dev/sbus/qe.c: revision 1.68
sys/dev/scsipi/if_se.c: revision 1.96
sys/dev/usb/if_atu.c: revision 1.59
sys/net/if_l2tp.c: revision 1.28 via patch
sys/net/if_ppp.c: revision 1.160
It's not required to include net/bpfdesc.h. Remove it.
--
Simplify like other drivers. NULL check of ifp->if_bpf is done in
bpf_mtap(), so it's not required to do it here.
--
Remove duplicated inclusion of net/bpf.h.
--
Remove duplicated inclusion of net/bpf.h.
--
Simplify bpf_mtap() call. No functional change.
 1.47.2.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.47.2.1 10-Jun-2019  christos Sync with HEAD
 1.52.2.1 29-Feb-2020  ad Sync with head.
 1.56.2.1 03-Apr-2021  thorpej Sync with HEAD.
 1.5 02-May-1998  scottr Move on-board I/O and NuBus drivers to their own directories
via repository copy, and make the necessary adjustments to reflect
the moved files.
 1.4 13-Jan-1998  scottr Update for bus.h changes.
 1.3 07-Nov-1997  briggs NetBSD RCSIds.
 1.2 05-Nov-1997  briggs Check for machine class, not for PSCBase as initial check in mc_obio_match().
 1.1 04-Nov-1997  briggs branches: 1.1.2;
Add in the if_mc ethernet driver for the AMD "MACE" part. This is the
internal ethernet on the Quadra/Centris 660av/840av.
Add initial support for the PSC (DMA controller) to support the above
(DMA SCSI remains unsupported). This involved also changing the way
that several interrupts are handled.
Above from David Huang <khym@bga.com>
Since the interrupts changed somewhat, we must also make the ipls
dynamic, defaulting to their prior levels and adjusted for the AVs.
I modelled this on the hp300.
 1.1.2.2 12-Nov-1997  mellon Pull rev 1.3 up from trunk (briggs)
 1.1.2.1 04-Nov-1997  mellon file if_mc_obio.c was added on branch netbsd-1-3 on 1997-11-12 02:10:42 +0000
 1.6 25-Jun-2025  andvar s/Confiuration/Configuration/ in comments.
 1.5 31-Oct-2022  andvar branches: 1.5.8;
s/interrut/interrupt/ and s/accelelerator/accelerator/ in comments.
 1.4 11-Dec-2005  christos merge ktrace-lwp.
 1.3 26-Mar-2004  wiz Update David Huang's email address in the license
per his request in PR 24907.
 1.2 07-Nov-1997  briggs branches: 1.2.50;
NetBSD RCSIds.
 1.1 04-Nov-1997  briggs branches: 1.1.2;
Add in the if_mc ethernet driver for the AMD "MACE" part. This is the
internal ethernet on the Quadra/Centris 660av/840av.
Add initial support for the PSC (DMA controller) to support the above
(DMA SCSI remains unsupported). This involved also changing the way
that several interrupts are handled.
Above from David Huang <khym@bga.com>
Since the interrupts changed somewhat, we must also make the ipls
dynamic, defaulting to their prior levels and adjusted for the AVs.
I modelled this on the hp300.
 1.1.2.2 12-Nov-1997  mellon Pull rev 1.2 up from trunk (briggs)
 1.1.2.1 04-Nov-1997  mellon file if_mcreg.h was added on branch netbsd-1-3 on 1997-11-12 02:11:35 +0000
 1.2.50.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.2.50.2 18-Sep-2004  skrll Sync with HEAD.
 1.2.50.1 03-Aug-2004  skrll Sync with HEAD
 1.5.8.1 02-Aug-2025  perseant Sync with HEAD
 1.18 18-Sep-2022  thorpej Eliminate use of IFF_OACTIVE.
 1.17 24-Jan-2021  rin Add rnd(9) support.
 1.16 27-Oct-2012  chs branches: 1.16.50;
split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.15 05-Mar-2007  he branches: 1.15.78; 1.15.88;
On second thought, make sc_txbuf and sc_rxbuf uint8_t*s, since if_mc_obio.c
likes to index directly into sc_rxbuf.
 1.14 05-Mar-2007  he Fix another instance of "void * a, b;" to be "void *a, *b;".
 1.13 04-Mar-2007  christos Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.12 12-Dec-2006  martin branches: 1.12.2;
Convert DMA memory allocation to bus_dmamem_alloc. From Dave Huang.
 1.11 24-Dec-2005  perry branches: 1.11.20; 1.11.22; 1.11.24;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.
 1.10 11-Dec-2005  christos merge ktrace-lwp.
 1.9 15-Jan-2005  chs branches: 1.9.10;
de-__P, remove register, ansify, b* -> mem*.
 1.8 26-Mar-2004  wiz Update David Huang's email address in the license
per his request in PR 24907.
 1.7 09-Apr-2003  thorpej branches: 1.7.2;
Use PAGE_SIZE rather than NBPG.
 1.6 22-Dec-1998  scottr vm_offset_t -> {paddr_t, vaddr_t}
 1.5 08-Jul-1998  scottr Revert last change.
 1.4 04-Jul-1998  jonathan defopt DDB.
 1.3 07-Dec-1997  scottr Fix prototypes so that we can compile without DDB. Closes
PR 4633.
 1.2 07-Nov-1997  briggs NetBSD RCSIds.
 1.1 04-Nov-1997  briggs branches: 1.1.2;
Add in the if_mc ethernet driver for the AMD "MACE" part. This is the
internal ethernet on the Quadra/Centris 660av/840av.
Add initial support for the PSC (DMA controller) to support the above
(DMA SCSI remains unsupported). This involved also changing the way
that several interrupts are handled.
Above from David Huang <khym@bga.com>
Since the interrupts changed somewhat, we must also make the ipls
dynamic, defaulting to their prior levels and adjusted for the AVs.
I modelled this on the hp300.
 1.1.2.3 09-Dec-1997  thorpej Sync w/ trunk: make it work without DDB (scottr)
 1.1.2.2 12-Nov-1997  mellon Pull rev 1.2 up from trunk (briggs)
 1.1.2.1 04-Nov-1997  mellon file if_mcvar.h was added on branch netbsd-1-3 on 1997-11-12 02:12:24 +0000
 1.7.2.4 17-Jan-2005  skrll Sync with HEAD.
 1.7.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.7.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.7.2.1 03-Aug-2004  skrll Sync with HEAD
 1.9.10.3 03-Sep-2007  yamt sync with head.
 1.9.10.2 30-Dec-2006  yamt sync with head.
 1.9.10.1 21-Jun-2006  yamt sync with head.
 1.11.24.1 15-Dec-2006  tron Pull up following revision(s) (requested by martin in ticket #272):
sys/arch/mac68k/dev/if_mc.c: revision 1.28
sys/arch/mac68k/obio/if_mc_obio.c: revision 1.16
sys/arch/mac68k/dev/if_mcvar.h: revision 1.12
Convert DMA memory allocation to bus_dmamem_alloc. From Dave Huang.
 1.11.22.1 18-Dec-2006  yamt sync with head.
 1.11.20.1 12-Jan-2007  ad Sync with head.
 1.12.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.15.88.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.15.78.1 30-Oct-2012  yamt sync with head
 1.16.50.1 03-Apr-2021  thorpej Sync with HEAD.
 1.47 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.46 10-Jun-2007  tsutsui branches: 1.46.10;
Switch mac68k's sn(4) Ethernet to MI SONIC driver.

Tested with Apple Ethernet CS Twisted-Pare Card on LC630 by me
and Quadra 650 on-board Ethernet by hauke@.
NuBus based cards and PowerBook variants are still untested.
 1.45 08-Mar-2007  tsutsui branches: 1.45.2; 1.45.4; 1.45.10;
In snintr(), reset the chip on fatal errors and
call snstart() after all events are handled.

XXX: We should switch to MI sys/dev/ic/dp83932.c.
 1.44 05-Mar-2007  he Use char* for pointer arithmetic.
 1.43 04-Mar-2007  christos Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.42 24-Jan-2007  hubertf branches: 1.42.2;
Remove duplicate #includes, patch contributed in private mail
by Slava Semushin <slava.semushin@gmail.com>.

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

Thanks to martin@ for the input on testing.
 1.41 07-Oct-2006  he Cast addresses to int before doing arithmetic on them, as in uses
of roundup().
 1.40 04-Oct-2006  christos don't use home-grown round macros
 1.39 24-Dec-2005  perry branches: 1.39.20; 1.39.22;
__asm__ -> __asm
__const__ -> const
__inline__ -> inline
__volatile__ -> volatile
 1.38 11-Dec-2005  christos merge ktrace-lwp.
 1.37 22-May-2005  christos branches: 1.37.2;
No 0x in front of %p...
 1.36 15-Jan-2005  chs de-__P, remove register, ansify, b* -> mem*.
 1.35 30-Oct-2004  thorpej When adding/deleting multicast addresses, only whack the address
filter if the interface is marked RUNNING.

Fixes kern/27678.
 1.34 15-Jul-2003  lukem branches: 1.34.4;
__KERNEL_RCSID()
 1.33 02-Apr-2003  thorpej branches: 1.33.2;
Use PAGE_SIZE rather than NBPG.
 1.32 27-Sep-2002  provos remove trailing \n in panic(). approved perry.
 1.31 16-Jan-2002  thorpej Use bpf_mtap().
 1.30 22-Jul-2001  wiz branches: 1.30.6;
seperate -> separate
 1.29 19-Jun-2001  wiz branches: 1.29.2;
`accessible' only has one `a'.
 1.28 15-Nov-2000  thorpej branches: 1.28.2;
Move bpfattach()/bpfdetach() calls into ether_ifattach()/ether_ifdetach().
 1.27 01-Oct-2000  thorpej Move the check for "promisc + unicast + not for us" into ether_input(),
and change Ethernet drivers to always pass all received frames to
ether_input() (with a few exceptions, which are documented in the
code).
 1.26 29-Jun-2000  mrg remove include of <vm/vm.h>. <vm/vm.h> -> <uvm/uvm_extern.h>
 1.25 12-Dec-1999  scottr Replace references to PGOFSET with m68k_trunc_page() and m68k_page_offset(),
as appropriate.
 1.24 29-Sep-1999  scottr branches: 1.24.2; 1.24.8;
Normalize autoconfig output.
 1.23 24-May-1999  thorpej Fix some broken packet length checks. Really (no, I mean really) works now
after the ether_input() changes -- tested on my Quadra 650.
 1.22 21-May-1999  thorpej Fix a couple of problems from the ether_input() change:
- Make it compile again, with BPF.
- Don't subtract the Ethernet header length from the total packet length.
- Copy the alignment fix from sys/dev/ic/i82586.c (though the m68k shouldn't
really be affected).
 1.21 18-May-1999  thorpej Rework layer 2 protocol input routines. Instead of calling e.g. ether_input()
directly, call the function pointer (*if_input)(ifp, m). The input routine
expects the packet header to be at the head of the packet, and will adjust
as necessary. Privatize the layer 2 input and output routines, allowing
*_ifattach() to set them up as appropriate.
 1.20 22-Dec-1998  scottr branches: 1.20.2; 1.20.6;
vm_offset_t -> {paddr_t, vaddr_t}
 1.19 05-Jul-1998  jonathan branches: 1.19.6;
defopt INET, NETATALK.
 1.18 25-Apr-1998  scottr Garbage collect the second (slot number) parameter to NuBus interrupt
handlers. (Only slot_ignore() and slot_noint() need this, and we already
have a place to put this information.) Adjust add_nubus_intr() so that if
the client_data arg is specified as NULL, pass the slot number as
client_data to the interrupt handler.
 1.17 12-Jan-1998  thorpej Update for changes to config.
 1.16 04-Nov-1997  briggs Fix a space-wasting bug found by David Huang in his work on the MACE driver.
 1.15 15-Jun-1997  scottr branches: 1.15.8;
Update from Denny Gentry <denny1@home.com>, PR 3685:

Simplify the way transmit buffers are managed, remove assumptions about
NBPG, simplify sonic_get handling, update snioctl to be more like other
current drivers, and probably a few other changes I've now forgotten about.
 1.14 19-May-1997  scottr Fix some printf format inconsistencies; from SUNAGAWA Keiki
<kei_sun@ba2.so-net.or.jp>, fixes PR 3619.
 1.13 25-Apr-1997  briggs A couple of performance improvements from Denny Gentry <denny1@home.com>
 1.12 22-Apr-1997  scottr Make formatting consistent; inline -> __inline__; KNF.
 1.11 18-Apr-1997  briggs Fix from Denny Gentry--initialize receive seq. counter.
 1.10 13-Apr-1997  briggs Some updates based on information from Bob Nestor <rnestor@metronet.com>
about his SONIC-T LC/PDS card.
 1.9 10-Apr-1997  briggs Changes from Denny Gentry <denny1@home.com>:
Change in the way receive buffer areas are handled. Before we gave
the chip 16 buffers, each 1536 bytes (big enough for one packet).
Now we're handing the chip 8 buffers, each 4 Kbytes, and letting
the chip fit as many packets as it can in each one. This should
help keep it from running out of buffer space. Also make some of
the performance-crucial routines inline. It made no measurable
difference except to make me feel better

Changes from Bob Nestor <rnestor@metronet.com> to get closer to support
for his Apple SONIC-based nubus card.

Changes from me to try to get SONIC's MAC address from MacOS settings if
we can't read the PROM space.
 1.8 30-Mar-1997  briggs Some new SONIC code from Denny Gentry <denny1@home.com> with a couple of
tweaks and bug fixes by yours truly.

Here's what Denny had to say:

nubus.h:
- add a drsw entry for my card
[ I also added a couple of constants for more display cards ]
if_sn.c:
- allocate sc->space using malloc (Scott wanted this).
- make csr accesses use NIC_PUT/GET, remove sc->sc_csr.
- add multicast and IFF_PROMISC support. multicast isn't
well tested, but I made sure the unicast case still
works.
- finish the new arp interface, remove sc->sc_enaddr
if_snreg.h:
- remove struct sonic_reg
if_snvar.h:
- add NIC_PUT and NIC_GET macros a la if_ae
- remove sc_txhead, it isn't used.
if_sn_nubus.c:
- clean up support for my SE/30 card.
- Move add_nubus_intr from if_sn.c (to keep if_sn.c MI)
if_sn_obio.c:
- make Q610, C610, Q650, C650, Q800 use EXBUS.
- PB500 had a "return" where "break" was intended. PB500
probably wasn't working.
- move add_nubus_intr from if_sn.c.
- add an "explanation" why Apple's ethernet addr is encoded
in token ring format in the PROM.
 1.7 20-Mar-1997  scottr Several minor changes:

- Indent some comments appropriately per KNF.
- Output all diagnostics using the device name rather than a static string.
- Fix a (mostly marmless) bug in snintr(), where loss of heartbeat wasn't
properly ignored and could mask the `receive descriptors exhausted'
diagnostic.
 1.6 17-Mar-1997  briggs Flip around Takeshi Yanagisawa's name. Add back a physaccess() call that I was a bit hasty
in removing.
 1.5 17-Mar-1997  briggs *Blush* It's Denton, not Dennis, Gentry.
 1.4 17-Mar-1997  briggs Make this compile again. XXX - save ethernet address in softc until multicast is supported.
 1.3 17-Mar-1997  briggs Integrate a couple of changes suggested by Scott Reynolds and Takeshi Yanagisawa.
 1.2 16-Mar-1997  is On request from Allen Briggs, converted this to new ARP
system. Somebody should actually test if this compiles (and works) on
Mac68k... I only carefully checked cvs diff -u.
 1.1 15-Mar-1997  briggs SONIC driver--originally from pica. Much work done by Dennis Gentry and
Takeshi Yanagisawa to get it working. Some minor hacking by me here and
there.
 1.15.8.1 15-Nov-1997  mellon Pull rev 1.16 up from trunk (briggs)
 1.19.6.1 11-Dec-1998  kenh The beginnings of interface detach support. Still some bugs, but mostly
works for me.

This work was originally by Bill Studenmund, and cleaned up by me.
 1.20.6.1 21-Jun-1999  thorpej Sync w/ -current.
 1.20.2.3 12-Dec-1999  scottr Sync with main branch.
 1.20.2.2 02-Nov-1999  scottr [Redo] Sync with main branch.
 1.20.2.1 08-Jun-1999  scottr Sync with main branch.
 1.24.8.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.24.2.2 22-Nov-2000  bouyer Sync with HEAD.
 1.24.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.28.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.29.2.3 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.29.2.2 11-Feb-2002  jdolecek Sync w/ -current.
 1.29.2.1 03-Aug-2001  lukem update to -current
 1.30.6.3 18-Oct-2002  nathanw Catch up to -current.
 1.30.6.2 28-Feb-2002  nathanw Catch up to -current.
 1.30.6.1 22-Jul-2001  nathanw file if_sn.c was added on branch nathanw_sa on 2002-02-28 04:10:35 +0000
 1.33.2.6 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.33.2.5 17-Jan-2005  skrll Sync with HEAD.
 1.33.2.4 02-Nov-2004  skrll Sync with HEAD.
 1.33.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.33.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.33.2.1 03-Aug-2004  skrll Sync with HEAD
 1.34.4.1 24-Jan-2005  he Pull up revision 1.35 (requested by thorpej in ticket #939):
When adding or deleting multicast addresses, only change
the address filter if the interface is marked RUNNING.
Fixes PR#27678.
 1.37.2.4 03-Sep-2007  yamt sync with head.
 1.37.2.3 26-Feb-2007  yamt sync with head.
 1.37.2.2 30-Dec-2006  yamt sync with head.
 1.37.2.1 21-Jun-2006  yamt sync with head.
 1.39.22.1 22-Oct-2006  yamt sync with head
 1.39.20.2 01-Feb-2007  ad Sync with head.
 1.39.20.1 18-Nov-2006  ad Sync with head.
 1.42.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.45.10.1 26-Jun-2007  garbled Sync with HEAD.
 1.45.4.1 11-Jul-2007  mjf Sync with head.
 1.45.2.1 15-Jul-2007  ad Sync with head.
 1.46.10.1 06-Nov-2007  matt sync with HEAD
 1.18 02-May-1998  scottr Move on-board I/O and NuBus drivers to their own directories
via repository copy, and make the necessary adjustments to reflect
the moved files.
 1.17 26-Oct-1997  briggs The 16- and 32-bit Apple card types got reversed somehow.
 1.16 11-Aug-1997  scottr branches: 1.16.4;
Make #include directives consistent. All MD headers are of the form:

#include <mac68k/{dev,mac68k}/foo.h>
 1.15 26-Jun-1997  scottr branches: 1.15.4;
Identify and use the Apple Twisted Pair NB card properly, from PR 3789
submitted by Denny Gentry <denny1@home.com>; investigation on the hardware
done by Bob Nestor.
 1.14 15-Jun-1997  scottr Update from Denny Gentry <denny1@home.com>, PR 3685:

Simplify the way transmit buffers are managed, remove assumptions about
NBPG, simplify sonic_get handling, update snioctl to be more like other
current drivers, and probably a few other changes I've now forgotten about.
 1.13 11-May-1997  scottr Implement new NuBus slot space mapping/probing code, utilizing bus.h (and
our MD bus_space_probe() extension). This has several side effects:

- NuBus drivers must map and unmap slot space, rather than relying
on this happening before they are attached.
- Functions exported to NuBus drivers from nubus.c now need to be
supplied with a bus space tag/handle pair.
- Old bus map/peek functions can be garbage collected, as can pmap
support for the same.

Because of some current limitations of the bus space specification, we
are violating the abstraction in grf_mv (NuBus grf driver). All such
violations are clearly marked /* XXX */, and must be addressed when
the specification is updated.
 1.12 01-May-1997  briggs Treat drhw 118 and 119 the same for Apple ethernet cards.
 1.11 30-Apr-1997  scottr Remove dependency on if_aereg.h for vendor constants; these are really
driver-, not architecture-specific.
 1.10 22-Apr-1997  scottr Remove obsolete drsw diagnostic; make formatting consistent; KNF.
 1.9 22-Apr-1997  briggs Make sure that we unmap the space that we mapped if we can't identify the card.
 1.8 22-Apr-1997  briggs Initialize 'offset' to make gcc happy.
 1.7 14-Apr-1997  briggs Use an offset parameter when loading the reg_map--some cards use the "other"
16 bits of the words.
 1.6 13-Apr-1997  briggs Oops. We do not want to unmap something that we've used bus_space_subregion
to get.
 1.5 13-Apr-1997  briggs Some updates based on information from Bob Nestor <rnestor@metronet.com>
about his SONIC-T LC/PDS card.
 1.4 10-Apr-1997  briggs Changes from Denny Gentry <denny1@home.com>:
Change in the way receive buffer areas are handled. Before we gave
the chip 16 buffers, each 1536 bytes (big enough for one packet).
Now we're handing the chip 8 buffers, each 4 Kbytes, and letting
the chip fit as many packets as it can in each one. This should
help keep it from running out of buffer space. Also make some of
the performance-crucial routines inline. It made no measurable
difference except to make me feel better

Changes from Bob Nestor <rnestor@metronet.com> to get closer to support
for his Apple SONIC-based nubus card.

Changes from me to try to get SONIC's MAC address from MacOS settings if
we can't read the PROM space.
 1.3 30-Mar-1997  briggs Some new SONIC code from Denny Gentry <denny1@home.com> with a couple of
tweaks and bug fixes by yours truly.

Here's what Denny had to say:

nubus.h:
- add a drsw entry for my card
[ I also added a couple of constants for more display cards ]
if_sn.c:
- allocate sc->space using malloc (Scott wanted this).
- make csr accesses use NIC_PUT/GET, remove sc->sc_csr.
- add multicast and IFF_PROMISC support. multicast isn't
well tested, but I made sure the unicast case still
works.
- finish the new arp interface, remove sc->sc_enaddr
if_snreg.h:
- remove struct sonic_reg
if_snvar.h:
- add NIC_PUT and NIC_GET macros a la if_ae
- remove sc_txhead, it isn't used.
if_sn_nubus.c:
- clean up support for my SE/30 card.
- Move add_nubus_intr from if_sn.c (to keep if_sn.c MI)
if_sn_obio.c:
- make Q610, C610, Q650, C650, Q800 use EXBUS.
- PB500 had a "return" where "break" was intended. PB500
probably wasn't working.
- move add_nubus_intr from if_sn.c.
- add an "explanation" why Apple's ethernet addr is encoded
in token ring format in the PROM.
 1.2 16-Mar-1997  is On request from Allen Briggs, converted this to new ARP
system. Somebody should actually test if this compiles (and works) on
Mac68k... I only carefully checked cvs diff -u.
 1.1 15-Mar-1997  briggs SONIC driver--originally from pica. Much work done by Dennis Gentry and
Takeshi Yanagisawa to get it working. Some minor hacking by me here and
there.
 1.15.4.1 23-Aug-1997  thorpej Update marc-pcmcia branch from trunk.
 1.16.4.1 27-Oct-1997  mellon Pull rev 1.17 up from trunk (briggs)
 1.15 02-May-1998  scottr Move on-board I/O and NuBus drivers to their own directories
via repository copy, and make the necessary adjustments to reflect
the moved files.
 1.14 13-Jan-1998  scottr Update for bus.h changes.
 1.13 05-Nov-1997  briggs For the LC575/Q630 (comm-slot machines), try to derive the card settings.
Unfortunately, there does not seem to be a good way to determine what
variety of comm-slot card is present in a machine. There is still an
interrupt issue preventing these cards from working--hopefully that will
be ironed out shortly.
 1.12 09-Oct-1997  briggs branches: 1.12.2;
Probe for the SONIC before saying that we found it. Some early Centris
models (low-end) shipped without ethernet installed.
 1.11 11-Aug-1997  scottr Make #include directives consistent. All MD headers are of the form:

#include <mac68k/{dev,mac68k}/foo.h>
 1.10 15-Jun-1997  scottr branches: 1.10.4;
Update from Denny Gentry <denny1@home.com>, PR 3685:

Simplify the way transmit buffers are managed, remove assumptions about
NBPG, simplify sonic_get handling, update snioctl to be more like other
current drivers, and probably a few other changes I've now forgotten about.
 1.9 22-Apr-1997  scottr If we can't map SONIC register space, just print a diagnostic message and
continue. Make formatting consistent and KNF while here.
 1.8 13-Apr-1997  briggs Some updates based on information from Bob Nestor <rnestor@metronet.com>
about his SONIC-T LC/PDS card.
 1.7 10-Apr-1997  briggs Changes from Denny Gentry <denny1@home.com>:
Change in the way receive buffer areas are handled. Before we gave
the chip 16 buffers, each 1536 bytes (big enough for one packet).
Now we're handing the chip 8 buffers, each 4 Kbytes, and letting
the chip fit as many packets as it can in each one. This should
help keep it from running out of buffer space. Also make some of
the performance-crucial routines inline. It made no measurable
difference except to make me feel better

Changes from Bob Nestor <rnestor@metronet.com> to get closer to support
for his Apple SONIC-based nubus card.

Changes from me to try to get SONIC's MAC address from MacOS settings if
we can't read the PROM space.
 1.6 04-Apr-1997  briggs Do not set DCR_SYNC for the C/Q[68]xx systems.
Thanks to Steve Brown <sbrown@best.com> for working with me to find this.
 1.5 30-Mar-1997  briggs Some new SONIC code from Denny Gentry <denny1@home.com> with a couple of
tweaks and bug fixes by yours truly.

Here's what Denny had to say:

nubus.h:
- add a drsw entry for my card
[ I also added a couple of constants for more display cards ]
if_sn.c:
- allocate sc->space using malloc (Scott wanted this).
- make csr accesses use NIC_PUT/GET, remove sc->sc_csr.
- add multicast and IFF_PROMISC support. multicast isn't
well tested, but I made sure the unicast case still
works.
- finish the new arp interface, remove sc->sc_enaddr
if_snreg.h:
- remove struct sonic_reg
if_snvar.h:
- add NIC_PUT and NIC_GET macros a la if_ae
- remove sc_txhead, it isn't used.
if_sn_nubus.c:
- clean up support for my SE/30 card.
- Move add_nubus_intr from if_sn.c (to keep if_sn.c MI)
if_sn_obio.c:
- make Q610, C610, Q650, C650, Q800 use EXBUS.
- PB500 had a "return" where "break" was intended. PB500
probably wasn't working.
- move add_nubus_intr from if_sn.c.
- add an "explanation" why Apple's ethernet addr is encoded
in token ring format in the PROM.
 1.4 29-Mar-1997  briggs Fix bug that would have prevented PB5xx series from detecting the SONIC.
Bug noticed by Denny Gentry.
 1.3 17-Mar-1997  briggs Make this compile again. XXX - save ethernet address in softc until multicast is supported.
 1.2 16-Mar-1997  is On request from Allen Briggs, converted this to new ARP
system. Somebody should actually test if this compiles (and works) on
Mac68k... I only carefully checked cvs diff -u.
 1.1 15-Mar-1997  briggs SONIC driver--originally from pica. Much work done by Dennis Gentry and
Takeshi Yanagisawa to get it working. Some minor hacking by me here and
there.
 1.10.4.2 14-Oct-1997  thorpej Update marc-pcmcia branch from trunk.
 1.10.4.1 23-Aug-1997  thorpej Update marc-pcmcia branch from trunk.
 1.12.2.1 15-Nov-1997  mellon Pull rev 1.13 up from trunk (briggs)
 1.5 10-Jun-2007  tsutsui Switch mac68k's sn(4) Ethernet to MI SONIC driver.

Tested with Apple Ethernet CS Twisted-Pare Card on LC630 by me
and Quadra 650 on-board Ethernet by hauke@.
NuBus based cards and PowerBook variants are still untested.
 1.4 15-Jun-1997  scottr branches: 1.4.74; 1.4.116; 1.4.118; 1.4.124;
Update from Denny Gentry <denny1@home.com>, PR 3685:

Simplify the way transmit buffers are managed, remove assumptions about
NBPG, simplify sonic_get handling, update snioctl to be more like other
current drivers, and probably a few other changes I've now forgotten about.
 1.3 30-Apr-1997  scottr Remove dependency on if_aereg.h for vendor constants; these are really
driver-, not architecture-specific.
 1.2 30-Mar-1997  briggs Some new SONIC code from Denny Gentry <denny1@home.com> with a couple of
tweaks and bug fixes by yours truly.

Here's what Denny had to say:

nubus.h:
- add a drsw entry for my card
[ I also added a couple of constants for more display cards ]
if_sn.c:
- allocate sc->space using malloc (Scott wanted this).
- make csr accesses use NIC_PUT/GET, remove sc->sc_csr.
- add multicast and IFF_PROMISC support. multicast isn't
well tested, but I made sure the unicast case still
works.
- finish the new arp interface, remove sc->sc_enaddr
if_snreg.h:
- remove struct sonic_reg
if_snvar.h:
- add NIC_PUT and NIC_GET macros a la if_ae
- remove sc_txhead, it isn't used.
if_sn_nubus.c:
- clean up support for my SE/30 card.
- Move add_nubus_intr from if_sn.c (to keep if_sn.c MI)
if_sn_obio.c:
- make Q610, C610, Q650, C650, Q800 use EXBUS.
- PB500 had a "return" where "break" was intended. PB500
probably wasn't working.
- move add_nubus_intr from if_sn.c.
- add an "explanation" why Apple's ethernet addr is encoded
in token ring format in the PROM.
 1.1 15-Mar-1997  briggs SONIC driver--originally from pica. Much work done by Dennis Gentry and
Takeshi Yanagisawa to get it working. Some minor hacking by me here and
there.
 1.4.124.1 26-Jun-2007  garbled Sync with HEAD.
 1.4.118.1 11-Jul-2007  mjf Sync with head.
 1.4.116.1 15-Jul-2007  ad Sync with head.
 1.4.74.1 03-Sep-2007  yamt sync with head.
 1.21 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.20 10-Jun-2007  tsutsui branches: 1.20.10;
Switch mac68k's sn(4) Ethernet to MI SONIC driver.

Tested with Apple Ethernet CS Twisted-Pare Card on LC630 by me
and Quadra 650 on-board Ethernet by hauke@.
NuBus based cards and PowerBook variants are still untested.
 1.19 08-Mar-2007  tsutsui branches: 1.19.2; 1.19.4; 1.19.10;
Use volatile on access to DMA descriptors.
 1.18 04-Mar-2007  christos 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-Jan-2005  chs branches: 1.16.10;
de-__P, remove register, ansify, b* -> mem*.
 1.15 20-Oct-2002  chs branches: 1.15.6;
merge the 12 copies of vm_machdep.c on the m68k platforms.
clean up some other stuff along the way, including:
- use m68k/cacheops.*, remove duplicates from cpu.h.
- centralize a few declarations in (all the copies of) cpu.h.
- define M68K_VAC on platforms which have a VAC.
- switch the sun platforms to the (now common) proc_trampoline().
- do the phys_map thang on the sun platforms too, no reason not to.
 1.14 29-Sep-1999  scottr branches: 1.14.20;
Add support for the Macintosh LC Ethernet Adapter, from Ken'ichi Ishizaka.
This was erroneously recognized as an 8390-based card, where in fact it is
using the 83932 (SONIC) controller.
 1.13 22-Dec-1998  scottr branches: 1.13.2; 1.13.4;
vm_offset_t -> {paddr_t, vaddr_t}
 1.12 01-May-1998  scottr Missed a prototype in the NuBus interrupt handler cleanup.
Fixes PRs 5365, 5367, 5368, and 5373.
 1.11 04-Nov-1997  briggs Raise the number of transmit and receive buffers.
 1.10 26-Jun-1997  scottr branches: 1.10.8;
Identify and use the Apple Twisted Pair NB card properly, from PR 3789
submitted by Denny Gentry <denny1@home.com>; investigation on the hardware
done by Bob Nestor.
 1.9 15-Jun-1997  scottr Update from Denny Gentry <denny1@home.com>, PR 3685:

Simplify the way transmit buffers are managed, remove assumptions about
NBPG, simplify sonic_get handling, update snioctl to be more like other
current drivers, and probably a few other changes I've now forgotten about.
 1.8 25-Apr-1997  briggs A couple of performance improvements from Denny Gentry <denny1@home.com>
 1.7 22-Apr-1997  scottr space vs. tab formatting, KNF
 1.6 13-Apr-1997  briggs Some updates based on information from Bob Nestor <rnestor@metronet.com>
about his SONIC-T LC/PDS card.
 1.5 10-Apr-1997  briggs Changes from Denny Gentry <denny1@home.com>:
Change in the way receive buffer areas are handled. Before we gave
the chip 16 buffers, each 1536 bytes (big enough for one packet).
Now we're handing the chip 8 buffers, each 4 Kbytes, and letting
the chip fit as many packets as it can in each one. This should
help keep it from running out of buffer space. Also make some of
the performance-crucial routines inline. It made no measurable
difference except to make me feel better

Changes from Bob Nestor <rnestor@metronet.com> to get closer to support
for his Apple SONIC-based nubus card.

Changes from me to try to get SONIC's MAC address from MacOS settings if
we can't read the PROM space.
 1.4 30-Mar-1997  briggs Some new SONIC code from Denny Gentry <denny1@home.com> with a couple of
tweaks and bug fixes by yours truly.

Here's what Denny had to say:

nubus.h:
- add a drsw entry for my card
[ I also added a couple of constants for more display cards ]
if_sn.c:
- allocate sc->space using malloc (Scott wanted this).
- make csr accesses use NIC_PUT/GET, remove sc->sc_csr.
- add multicast and IFF_PROMISC support. multicast isn't
well tested, but I made sure the unicast case still
works.
- finish the new arp interface, remove sc->sc_enaddr
if_snreg.h:
- remove struct sonic_reg
if_snvar.h:
- add NIC_PUT and NIC_GET macros a la if_ae
- remove sc_txhead, it isn't used.
if_sn_nubus.c:
- clean up support for my SE/30 card.
- Move add_nubus_intr from if_sn.c (to keep if_sn.c MI)
if_sn_obio.c:
- make Q610, C610, Q650, C650, Q800 use EXBUS.
- PB500 had a "return" where "break" was intended. PB500
probably wasn't working.
- move add_nubus_intr from if_sn.c.
- add an "explanation" why Apple's ethernet addr is encoded
in token ring format in the PROM.
 1.3 17-Mar-1997  briggs Make this compile again. XXX - save ethernet address in softc until multicast is supported.
 1.2 16-Mar-1997  is On request from Allen Briggs, converted this to new ARP
system. Somebody should actually test if this compiles (and works) on
Mac68k... I only carefully checked cvs diff -u.
 1.1 15-Mar-1997  briggs SONIC driver--originally from pica. Much work done by Dennis Gentry and
Takeshi Yanagisawa to get it working. Some minor hacking by me here and
there.
 1.10.8.1 15-Nov-1997  mellon Pull rev 1.11 up from trunk (briggs)
 1.13.4.1 01-Jul-2000  he Pull up revision 1.14 (requested by fredb):
Add support for the Macintosh LC Ethernet Adapter. This was
previously erroneously recognized as an 8390-based card, where
in fact it is using the 83932 (SONIC) controller.
 1.13.2.1 02-Nov-1999  scottr [Redo] Sync with main branch.
 1.14.20.1 11-Nov-2002  nathanw Catch up to -current
 1.15.6.1 17-Jan-2005  skrll Sync with HEAD.
 1.16.10.1 03-Sep-2007  yamt sync with head.
 1.17.26.1 12-Mar-2007  rmind Sync with HEAD.
 1.19.10.1 26-Jun-2007  garbled Sync with HEAD.
 1.19.4.1 11-Jul-2007  mjf Sync with head.
 1.19.2.1 15-Jul-2007  ad Sync with head.
 1.20.10.1 06-Nov-2007  matt sync with HEAD
 1.53 14-Feb-2000  scottr Merge wscons work onto the main development branch.
 1.52 07-Nov-1999  scottr ite_polling -> adb_polling
 1.51 08-Jul-1999  thorpej branches: 1.51.2; 1.51.4; 1.51.8;
Change the pmap_extract() interface to:
boolean_t pmap_extract(pmap_t, vaddr_t, paddr_t *);
This makes it possible for the pmap to map physical address 0.
 1.50 21-Apr-1999  scottr Actually, the last change solved a different but related problem than
the one mentioned in PR 7376. By clearing the display in iteon()
instead, we can kill both birds with the same stone.
 1.49 21-Apr-1999  scottr When attaching the ite console, clear the entire display rather than assuming
that the emulator will do it for us. (The emulator will only clear
full character-sized rows.) Incidentally fixes PR 7376.
 1.48 27-Mar-1999  briggs branches: 1.48.2;
Compile itecnputc if NZSC == 0.
 1.47 12-Mar-1999  perry exterminate ovbcopy. patches provided by Erik Bertelsen, pr-7145
 1.46 22-Dec-1998  scottr branches: 1.46.2;
vm_offset_t -> {paddr_t, vaddr_t}
 1.45 23-Oct-1998  ender New ADB "bus" interface:
o Separate ms and kbd drivers
o aed device for compatibility
o debug message cleanup in hardware direct support (from scottr)
 1.44 01-Jul-1998  scottr Add a GRF_COMPAT option so that old-style grf ioctl() code can be
removed from the kernel.
 1.43 02-May-1998  scottr Move on-board I/O and NuBus drivers to their own directories
via repository copy, and make the necessary adjustments to reflect
the moved files.
 1.42 12-Jan-1998  thorpej Update for changes to config.
 1.41 25-Nov-1997  scottr In iteoff()/iteon(), don't try to do anything if we haven't
initialized the ite.
 1.40 19-Nov-1997  scottr Fix emulation, mostly from Dave Huang in PR 4482 (one tweak by me for CUU/CUD, and
one from him to correct a fencepost error in {reset,clear}_tabs()).
 1.39 06-Sep-1997  scottr branches: 1.39.4;
In itematch(), check to see if the framebuffer PA matches either the
$Fssxxxxx 1MB slot space documented in the old Inside Macintosh, or the
$Fs0xxxxx 1MB slot space documented in the new IM and Guide to Macintosh
Family Hardware.
 1.38 11-Aug-1997  scottr Make #include directives consistent. All MD headers are of the form:

#include <mac68k/{dev,mac68k}/foo.h>
 1.37 23-Jul-1997  scottr branches: 1.37.2;
The PA of the framebuffer may not be page aligned, so make sure to
do this before comparing against the result of pmap_extract().
 1.36 12-May-1997  scottr KNF and other cosmetics.
 1.35 20-Apr-1997  scottr Fix itematch() for case where fboff is not zero. From Dave Huang,
closes PR #3501.
 1.34 14-Apr-1997  briggs Capslock support from Steve Brown <sbrown@best.com>
 1.33 08-Apr-1997  briggs Changes from Michael R. Zucca <mrz5149@cs.rit.edu> for 16-bit and 32-bit
console support.
 1.32 20-Feb-1997  scottr We need bus.h now, due to recent nubus_attach_args change.
 1.31 11-Feb-1997  scottr Remove dependency on asc driver, using generic console bell callback
instead. Bell parameters are now entirely self-contained, as they
are managed by ite-specific ioctl()'s.
 1.30 18-Dec-1996  scottr branches: 1.30.4;
Fix the potentially uninitialized variable in clear_screen() (correctly
pointed out by gcc -Wall).
 1.29 16-Dec-1996  scottr Convert all foo_match() functions to use a `struct cfdata *' for their
second argument. The NuBus autoconfig code had to be reorganized as a
result of this, and looks much more like a directly-attached bus now.
These changes eliminate __BROKEN_INDIRECT_CONFIG.
 1.28 19-Nov-1996  scottr Kill the conspa variable, and use mac68k_vidphys instead. Where we used
to initialize conspa was invalid on non-040 machines, since we don't
know which MMU we're using on those, yet. On the other hand, by the time
we get to check_video() on the 040 machines, the MMU has been disabled.
Compromise: get the video PA in setmachdep() on the 040, and in
check_video() on the others. (This is not optimal. *sigh*)
 1.27 10-Nov-1996  scottr VT220-related emulation additions:
- Add reset attribute sequences for bold, underline, and reverse
- Add insert/delete line sequences
- Recognize but ignore G0/G1 character set sequences

Performance:
- Speed up clear_line() when clearing the entire line

Also, some stylistic changes for checking/setting scroll region bounds
and in putc_getpars().

These changes make the ITE work properly with the 1.2 termcap file.
 1.26 13-Oct-1996  christos backout previous kprintf change
 1.25 11-Oct-1996  christos printf -> kprintf, sprintf -> ksprintf
 1.24 05-Aug-1996  scottr Attach ite semantics to the appropriate grf device, instead of obio.
 1.23 01-Jun-1996  scottr Add tty_attach() as appropriate (for pstat -t)
 1.22 25-May-1996  briggs Do not let getty open ite if it's not been initialized.
 1.21 18-May-1996  briggs branches: 1.21.4;
Serial driver with interface to a slightly modified version of the machine-
independent z8530 driver. When that driver is updated, the local copy
of those files may be removed. From Bill Studenmund.
Compiler warnings fixed by me.
 1.20 07-May-1996  scottr - Rewrite scrollup(), scrolldown(), and clear_screen() to move/clear only
visible screen memory. This results in a considerable performance win
at all depths.
- Correct clear_screen() behavior when clearing to the top and bottom of
screen; start at current cursor position, not current cursor row.
- Add local prototypes, and other KNF.
 1.19 05-May-1996  briggs Prototype for -Wall -Wstrict-prototypes -Wmissing-prototypes -Wno-uninitialized
Also change the device probing scheme to use something a bit more rational.
A current side-effect is that nubus cards are double-mapped. I expect
to fix that shortly.
Also change splclock() to block everything but serial hardware interrupts.
 1.18 29-Mar-1996  briggs via.h -> machine/viareg.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 17-Jul-1995  briggs Some more bugs fixed and functionality corrected by:
"Paul R. Goyette" <paul@pgoyette.bdt.com>.
Implemeted the Set Scrolling Region, Set Tab Stop, and Clear All
Tab Stops functions.
 1.15 09-Jul-1995  briggs patch to handle cursor moves better. From Paul Goyette
(Paul@pgoyette.bdt.com)
 1.14 21-Apr-1995  briggs First pass of KNFication. Needs more.
 1.13 20-Apr-1995  briggs Prototype iteopen correctly (oversight from a while back...).
 1.12 20-Apr-1995  briggs Add itetty().
 1.11 26-Mar-1995  briggs Do iteon() and iteoff(). Right now, they just clear/draw the cursor and
clear the screen. "We" should look at updating these further.
 1.10 03-Dec-1994  briggs Mac ROM Glue changes from grantham@tenon.com.
 1.9 26-Oct-1994  cgd new RCS ID format.
 1.8 29-Sep-1994  briggs Actually implement serial boot (console) echo (minor change to ite.c).
Remove some old junk in ser.c and implement serial console and serial
boot echo (if serial console's enabled, clear echo).
 1.7 12-Sep-1994  briggs Fix a scrolling bug when we have more than 64k to scroll.
 1.6 02-Aug-1994  briggs branches: 1.6.2;
Nuke holdovers from old HP300 console code. Get rid of any reference
to serial_boot_echo stuff here.
 1.5 31-Jul-1994  lkestel Fixed bug with bcopy()'ing more than 65535 bytes; initialize d_ttys and cn_tp
on itecnprobe(); other minor bug and warning fixes.
 1.4 30-Jul-1994  lkestel Moved adbsys.h grfioctl.h and keyboard.h to include to make desktop
and X compile more cleanly.
 1.3 21-Jul-1994  lkestel Added vt100 emulation and sped up text writing, scrolling, etc.
 1.2 09-Jul-1994  briggs Minor hacks to get this to compile for now. ite.c now uses the proper
consdev structure to keep itself from crashing...
 1.1 08-Jul-1994  lkestel 6x10.h: shifted font over by two pixels.
keyboard.h: added constants for commonly used keys and reformatted
array so that gcc would be happy.
adbsys.c: new adb system.
bounds.h: bound-checking macros.
ite.c: new built-in mini-console.
8x14.h: no longer used by built-in console.
adb.c: replaced by adbsys.c
 1.6.2.3 29-Sep-1994  cgd from trunk, per briggs.
 1.6.2.2 12-Sep-1994  cgd from trunk, per briggs
 1.6.2.1 02-Aug-1994  cgd file ite.c was added on branch netbsd-1-0 on 1994-09-12 21:07:58 +0000
 1.21.4.3 03-Jun-1996  scottr Back out previous change; we now have new tty stats code.
 1.21.4.2 02-Jun-1996  scottr My mistake; we're not yet ready for tty_attach() on this branch.
 1.21.4.1 01-Jun-1996  scottr Pull up version 1.23 from the main branch.
 1.30.4.1 12-Mar-1997  is Merge in changes from The Trunk, partially just reimplementing newarp.
 1.37.2.2 06-Sep-1997  thorpej Update marc-pcmcia branch from trunk.
 1.37.2.1 23-Aug-1997  thorpej Update marc-pcmcia branch from trunk.
 1.39.4.2 26-Nov-1997  mellon Pull rev 1.41 up from trunk (scott)
 1.39.4.1 19-Nov-1997  mellon Pull rev 1.40 up from trunk (scottr)
 1.46.2.3 11-Mar-1999  scottr ite/grf is dead. long live ite/grf!
 1.46.2.2 08-Mar-1999  scottr Add output-side support, using existing intvid/macvid support.
 1.46.2.1 05-Mar-1999  scottr checkpoint: input side code should work. no output side yet.
 1.48.2.3 21-Nov-1999  he Pull up revision 1.52 (requested by sr):
Clean up the ADB driver, and eliminate duplicate keystrokes under
heavy load, fixing PR#7870.
 1.48.2.2 21-Apr-1999  perry branches: 1.48.2.2.2;
pullup 1.49->1.50 (scottr): rest of fix for pr7376
 1.48.2.1 21-Apr-1999  perry pullup 1.48->1.49 (scottr): partial fix for pr7376
 1.48.2.2.2.2 02-Aug-1999  thorpej Update from trunk.
 1.48.2.2.2.1 21-Jun-1999  thorpej Sync w/ -current.
 1.51.8.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.51.4.1 15-Nov-1999  fvdl Sync with -current
 1.51.2.1 20-Nov-2000  bouyer Remove files that are no longer on the trunck
 1.14 26-Mar-2023  andvar s/diplay/display/ and s/DIPPLAY/DISPLAY/ in comments.
 1.13 20-Aug-2015  christos include "ioconf.h" to get the 'void <driver>attach(int count);' prototype.
 1.12 25-Jul-2014  dholland branches: 1.12.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.11 16-Mar-2014  dholland branches: 1.11.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.10 04-Mar-2007  christos branches: 1.10.78; 1.10.88; 1.10.94;
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 15-Jan-2005  chs branches: 1.8.10;
de-__P, remove register, ansify, b* -> mem*.
 1.7 15-Jul-2003  lukem __KERNEL_RCSID()
 1.6 23-Oct-2002  jdolecek branches: 1.6.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.5 06-Sep-2002  gehenna Merge the gehenna-devsw branch into the trunk.

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

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

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

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

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

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

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

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

- In compile time, device major numbers list is packed into the kernel and
the LKM framework will refer it to assign device major number dynamically.
 1.4 14-May-2001  scw branches: 1.4.2; 1.4.4; 1.4.8; 1.4.16;
port-mac68l/12931 by Dave Huang:

Add an itepoll() function. This one slipped through my recent sweep
of line-disciplines...
 1.3 22-Jan-2001  scottr branches: 1.3.2;
Correct a thinko: iteopen()/iteclose() shouldn't just pass off to
the wsdisplay driver. Otherwise, closing ttye0 (ite compat) ends
up closing ttyE0, the actual console, when ttyflags runs. Fixes
PR 12022.
 1.2 14-Feb-2000  scottr branches: 1.2.4; 1.2.6;
Merge wscons work onto the main development branch.
 1.1 07-Feb-2000  scottr branches: 1.1.2;
file ite_compat.c was initially added on branch scottr-mac68k-wscons.
 1.1.2.3 11-Feb-2000  scottr Get the console device without any outside help. Also, do a sanity
check in iteioctl().
 1.1.2.2 07-Feb-2000  scottr Add missing copyright/license.
 1.1.2.1 07-Feb-2000  scottr Implement an ite console emulator for wscons. The only thing we actually
need to do is handle a few ioctls, as wsdisplay already handles everything
else nicely.
 1.2.6.3 11-Feb-2001  bouyer Sync with HEAD.
 1.2.6.2 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.2.6.1 14-Feb-2000  bouyer file ite_compat.c was added on branch thorpej_scsipi on 2000-11-20 20:12:17 +0000
 1.2.4.1 03-Feb-2001  he Pull up revision 1.3 (requested by scottr):
Correct the implementation of iteopen()/iteclose(). Fixes
PR#12022.
 1.3.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.4.16.1 19-May-2002  gehenna Add device switch.
Replace the access to devsw table and the hard-coded majors with devsw API.
 1.4.8.3 11-Nov-2002  nathanw Catch up to -current
 1.4.8.2 17-Sep-2002  nathanw Catch up to -current.
 1.4.8.1 14-May-2001  nathanw file ite_compat.c was added on branch nathanw_sa on 2002-09-17 21:15:25 +0000
 1.4.4.1 10-Oct-2001  fvdl Convert all remaining devices.
 1.4.2.1 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.6.6.5 25-Jan-2005  skrll Adapt to branch.
 1.6.6.4 17-Jan-2005  skrll Sync with HEAD.
 1.6.6.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.6.6.2 18-Sep-2004  skrll Sync with HEAD.
 1.6.6.1 03-Aug-2004  skrll Sync with HEAD
 1.8.10.2 03-Sep-2007  yamt sync with head.
 1.8.10.1 21-Jun-2006  yamt sync with head.
 1.9.26.1 12-Mar-2007  rmind Sync with HEAD.
 1.10.94.1 18-May-2014  rmind sync with head
 1.10.88.2 03-Dec-2017  jdolecek update from HEAD
 1.10.88.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.10.78.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.11.2.1 10-Aug-2014  tls Rebase.
 1.12.4.1 22-Sep-2015  skrll Sync with HEAD
 1.3 14-Feb-2000  scottr Merge wscons work onto the main development branch.
 1.2 08-Apr-1997  briggs branches: 1.2.16; 1.2.24;
Changes from Michael R. Zucca <mrz5149@cs.rit.edu> for 16-bit and 32-bit
console support.
 1.1 05-May-1996  briggs Prototype for -Wall -Wstrict-prototypes -Wmissing-prototypes -Wno-uninitialized
Also change the device probing scheme to use something a bit more rational.
A current side-effect is that nubus cards are double-mapped. I expect
to fix that shortly.
Also change splclock() to block everything but serial hardware interrupts.
 1.2.24.1 20-Nov-2000  bouyer Remove files that are no longer on the trunck
 1.2.16.3 11-Feb-2000  scottr Get the console device without any outside help. Also, do a sanity
check in iteioctl().
 1.2.16.2 07-Feb-2000  scottr Update copyright/license.
 1.2.16.1 07-Feb-2000  scottr Implement an ite console emulator for wscons. The only thing we actually
need to do is handle a few ioctls, as wsdisplay already handles everything
else nicely.
 1.4 14-Feb-2000  scottr Merge wscons work onto the main development branch.
 1.3 16-Feb-1999  ender branches: 1.3.2; 1.3.10;
Add NetBSD RCS Id's
 1.2 11-Feb-1999  ender o Change various attach arg and softc datatypes to ints.
o Use explicit typecasts when interfacing with MRG data

Should fix port-mac68k/6839. Patch supplied by
Frederick Bruckman <fb@enteract.com>
 1.1 23-Oct-1998  ender New ADB "bus" interface:
o Separate ms and kbd drivers
o aed device for compatibility
o debug message cleanup in hardware direct support (from scottr)
 1.3.10.1 20-Nov-2000  bouyer Remove files that are no longer on the trunck
 1.3.2.2 15-Nov-1999  scottr These have been moved via repository copy to akbd/ams for consistency with
the macppc port.
 1.3.2.1 05-Mar-1999  scottr checkpoint: input side code should work. no output side yet.
 1.4 14-Feb-2000  scottr Merge wscons work onto the main development branch.
 1.3 16-Feb-1999  ender branches: 1.3.2; 1.3.10;
Add NetBSD RCS Id's
 1.2 11-Feb-1999  ender o Change various attach arg and softc datatypes to ints.
o Use explicit typecasts when interfacing with MRG data

Should fix port-mac68k/6839. Patch supplied by
Frederick Bruckman <fb@enteract.com>
 1.1 23-Oct-1998  ender New ADB "bus" interface:
o Separate ms and kbd drivers
o aed device for compatibility
o debug message cleanup in hardware direct support (from scottr)
 1.3.10.1 20-Nov-2000  bouyer Remove files that are no longer on the trunck
 1.3.2.1 15-Nov-1999  scottr These have been moved via repository copy to akbd/ams for consistency with
the macppc port.
 1.4 30-Jul-1994  mycroft Clean up deleted files.
 1.3 08-Jul-1994  lkestel 6x10.h: shifted font over by two pixels.
keyboard.h: added constants for commonly used keys and reformatted
array so that gcc would be happy.
adbsys.c: new adb system.
bounds.h: bound-checking macros.
ite.c: new built-in mini-console.
8x14.h: no longer used by built-in console.
adb.c: replaced by adbsys.c
 1.2 29-Nov-1993  briggs branches: 1.2.2;
Update to current work in progress. This includes an update to
use config.new.
Numerous updates to console so it works better on the SE/30 screen.
Some nice changes from Brad Parker for handling NuBUS and an ethernet
driver that I haven't worked on, yet.
 1.1 29-Sep-1993  briggs branches: 1.1.1;
Initial revision
 1.1.1.1 29-Sep-1993  briggs The current MacBSD architecture sub-directory for NetBSD-0.9--more or
less. It needs some help to get to be -current. Support for minimal
hardware on the SE/30, II, IIx, and IIcx exists.
 1.2.2.1 24-Jul-1994  cgd update, as requested by briggs
 1.50 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.49 25-Oct-2013  martin branches: 1.49.28; 1.49.30;
Simplify
 1.48 06-Dec-2012  hauke branches: 1.48.2;
Remove the R1 syntactic sugar, since it collides with a #define in
<m68k/regs.h>, breaking the build.

The R1s serve to bring the buffer pointer to a 4 byte boundary, but
that should be clear from the context.
 1.47 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.46 17-Jul-2011  joerg branches: 1.46.2; 1.46.12;
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.45 09-Jul-2011  mrg avoid inconsistent inline usage to appease gcc 4.5.
 1.44 24-Dec-2005  perry __asm__ -> __asm
__const__ -> const
__inline__ -> inline
__volatile__ -> volatile
 1.43 11-Dec-2005  christos merge ktrace-lwp.
 1.42 16-Jun-2005  jmc branches: 1.42.2;
Fixes for volatile problems
 1.41 15-Jan-2005  chs de-__P, remove register, ansify, b* -> mem*.
 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 02-Apr-2003  thorpej Use PAGE_SIZE rather than NBPG.
 1.37 27-Sep-2002  provos remove trailing \n in panic(). approved perry.
 1.36 14-Feb-2000  scottr branches: 1.36.8; 1.36.12;
Merge wscons work onto the main development branch.
 1.35 22-Dec-1998  scottr branches: 1.35.2; 1.35.10;
vm_offset_t -> {paddr_t, vaddr_t}
 1.34 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.33 11-Aug-1997  scottr Make #include directives consistent. All MD headers are of the form:

#include <mac68k/{dev,mac68k}/foo.h>
 1.32 29-Jun-1997  scottr branches: 1.32.2; 1.32.4;
Update for mac68k_buserr_addr -> m68k_fault_addr change.
 1.31 27-Apr-1997  briggs What was I thinking?
 1.30 15-Apr-1997  briggs Take a stab at making this more reliable.
 1.29 28-Feb-1997  scottr Convert to generalized VIA interrupt registration
 1.28 19-Dec-1996  scottr branches: 1.28.6;
Clean up a few bogons+typos introduced in the removal of the broken indirect
config code.
 1.27 13-Oct-1996  christos backout previous kprintf change
 1.26 11-Oct-1996  christos printf -> kprintf, sprintf -> ksprintf
 1.25 07-Jun-1996  briggs Fix a typo.
 1.24 25-May-1996  briggs Clean up the interrupt handling somewhat.
 1.23 05-May-1996  briggs branches: 1.23.4;
Prototype for -Wall -Wstrict-prototypes -Wmissing-prototypes -Wno-uninitialized
Also change the device probing scheme to use something a bit more rational.
A current side-effect is that nubus cards are double-mapped. I expect
to fix that shortly.
Also change splclock() to block everything but serial hardware interrupts.
 1.22 29-Mar-1996  briggs via.h -> machine/viareg.h.
 1.21 20-Mar-1996  scottr Fix a long-standing bug uncovered by the new device attachment
model. Thanks to Jason Thorpe for the fix (fixed PR 2235).
 1.20 17-Mar-1996  thorpej New device attachment scheme:

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

- new "attach" directive for files.*. May specify the name of
the cfattach structure, so that devices may be easily attached
to parents with different autoconfiguration semantics.
 1.19 19-Feb-1996  briggs Update to latest Atari driver, but with some local modifications.
 1.18 03-Feb-1996  briggs Move debugging defines, etc. into mac68k5380.c and use them instead of
something similar but different. Make a few cosmetic changes.
 1.17 24-Jan-1996  briggs Patch a few of the holes in the machine-dependent part of this driver.
Sync the m.i. part with the Atari.
 1.16 11-Jan-1996  briggs Keep two states for pdma debugging. Turn debugging back on. Sigh.
 1.15 01-Nov-1995  briggs Fixup error/debugging message.
 1.14 01-Oct-1995  briggs Finally get this right... Final fix from Paul Goyette paul@pgoyette.bdt.com
 1.13 30-Sep-1995  briggs Yet another error in the (next-to) last changes.
 1.12 30-Sep-1995  briggs Fix stupid error in one of my last changes here.
 1.11 27-Sep-1995  briggs Bullet-proof a little.
Make some more pdma code conditional on USE_PDMA.
Handle transfers of size > MIN_PHYS.
 1.10 23-Sep-1995  briggs Much improved pdma transfers.
Still not nearly as fast as FWB's drivers under the MacOS.
Uses the "blind" transfer method instead of polled pdma.
 1.9 16-Sep-1995  briggs Only use PIO instead of PDMA if DRIVER_NOINT.
 1.8 16-Sep-1995  briggs Rename scsi_main_irq() to pdma_ready().
Missed a few ATNs in last patch. (pointed out by Leo).
Raise timeout from 100 to 1000. From Leo.
 1.7 12-Sep-1995  briggs Update for Leo's changes.
 1.6 04-Sep-1995  briggs Get softc as parameter in interrupt function, using new changes from
via.[ch]
 1.5 03-Sep-1995  briggs Make a local copy of the atari m.i. scsi driver sources for the time
being. Some people aren't supping arch/atari and this allows those
people to get the sources.
 1.4 02-Sep-1995  briggs Optimize this some. Still seems slower than it ought to be.
Register interrupt functions with via.c.
Clean up somewhat. Turn off DEBUG.
 1.3 02-Sep-1995  briggs Rearrange a bit.
 1.2 02-Sep-1995  briggs DTRT. This should be considered the base version of the file.
 1.1 01-Sep-1995  briggs A first pass at a scsi driver based on the Atari ncr5380{reg.h,.c} code.
 1.23.4.2 07-Jun-1996  briggs Bring in fix for a typo from -current.
 1.23.4.1 01-Jun-1996  scottr Pull up version 1.24 from the main branch (fix interrupt handling)
 1.28.6.1 12-Mar-1997  is Merge in changes from The Trunk, partially just reimplementing newarp.
 1.32.4.2 27-Aug-1997  thorpej Update marc-pcmcia branch from trunk.
 1.32.4.1 23-Aug-1997  thorpej Update marc-pcmcia branch from trunk.
 1.32.2.2 14-Aug-1997  bouyer Sync with trunk.
 1.32.2.1 01-Jul-1997  bouyer Updates for new scsipi subsystem. Actally known to work on i386 and sparc.
 1.35.10.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.35.2.1 14-Feb-2000  scottr Make this compile (we lost cpu.h somewhere along the line).
 1.36.12.1 18-Oct-2002  nathanw Catch up to -current.
 1.36.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.39.2.5 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.39.2.4 17-Jan-2005  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.42.2.1 21-Jun-2006  yamt sync with head.
 1.46.12.3 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.46.12.2 25-Feb-2013  tls resync with head
 1.46.12.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.46.2.3 22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.46.2.2 16-Jan-2013  yamt sync with (a bit old) head
 1.46.2.1 30-Oct-2012  yamt sync with head
 1.48.2.1 18-May-2014  rmind sync with head
 1.49.30.1 10-Jun-2019  christos Sync with HEAD
 1.49.28.1 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.10 26-Jul-2019  rin Add genfb(4) driver for mac68k grfbus.
1, 2, 4, 8, 15, and 32 color-depths are supported.

ANSI colors on console are functional for depth >= 4.

Graphic applications based on wsfb API should work, provided
they can correctly handle fbi_fboffset and your color depth.

wsfb driver of Xorg 1.20 and mlterm-fb (framebuffer version of
x11/mlterm) work fine for depth == 1 || depth >= 8.

For depth == 8 (256 colors), graphic applications require
colormap callback, which is currently supported for some
internal graphic adapters, and only Civic (found on Quadra
AV series) was tested. Register definition and its usage are
taken from Linux. You can easily support other adapters if
Linux supports that.

Have fun, and any problem reports are welcomed!
 1.9 17-Oct-2007  garbled branches: 1.9.108;
Merge the ppcoea-renovation branch to HEAD.

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

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

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.8 29-Aug-2007  jmmv Pack all global video-related variables into a structure for clarity.

A comment said that they weren't in a struct for speed reasons but...
this should not affect performance because these variables are mostly
used to set other variables (hence they are read few times).
 1.7 29-Aug-2007  jmmv Move the definition of multiple video-related variables into a new
header file (machine/video.h) so that we can kill all the "manual"
externs spread around the code (which were inconsistent among them).
 1.6 11-Dec-2005  christos branches: 1.6.30; 1.6.38; 1.6.44; 1.6.48; 1.6.50;
merge ktrace-lwp.
 1.5 15-Jan-2005  chs branches: 1.5.10;
de-__P, remove register, ansify, b* -> mem*.
 1.4 15-Jul-2003  lukem __KERNEL_RCSID()
 1.3 06-Sep-2002  gehenna branches: 1.3.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.2 14-Feb-2000  scottr branches: 1.2.8; 1.2.12; 1.2.20;
Merge wscons work onto the main development branch.
 1.1 22-May-1999  scottr branches: 1.1.2; 1.1.4;
file maccons.c was initially added on branch scottr-mac68k-wscons.
 1.1.4.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.1.2.3 09-Feb-2000  scottr Add support for serial boot echo.
 1.1.2.2 29-Dec-1999  scottr Don't avoid the IIfx. The original idea was to avoid crashes due to the fact that
the ADB driver isn't working, but that's no longer a problem. (In
reality, while the IOP code doesn't quite work, it does not cause
instability like previous attempts to use MRG ADB did.)
 1.1.2.1 22-May-1999  scottr Add support for wscons as a console, using evil trickery. To fix this
we'll have to revisit (and rip out) a bunch of things that happen before
the MMU is set up.

As a result, serial consoles now work again.
 1.2.20.1 19-May-2002  gehenna Replace the access to devsw table and the hard-coded majors with devsw API.
 1.2.12.1 17-Sep-2002  nathanw Catch up to -current.
 1.2.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.3.6.4 17-Jan-2005  skrll Sync with HEAD.
 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.5.10.1 03-Sep-2007  yamt sync with head.
 1.6.50.1 06-Nov-2007  matt sync with HEAD
 1.6.48.1 03-Sep-2007  jmcneill Sync with HEAD.
 1.6.44.1 03-Sep-2007  skrll Sync with HEAD.
 1.6.38.1 03-Oct-2007  garbled Sync with HEAD
 1.6.30.1 09-Oct-2007  ad Sync with head.
 1.9.108.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.23 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.22 24-Apr-2021  thorpej branches: 1.22.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.21 19-Dec-2020  thorpej branches: 1.21.2;
malloc(9) -> kmem(9)
 1.20 27-Oct-2012  chs branches: 1.20.50;
split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.19 17-Oct-2007  garbled branches: 1.19.54; 1.19.64;
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 29-Aug-2007  jmmv Pack all global video-related variables into a structure for clarity.

A comment said that they weren't in a struct for speed reasons but...
this should not affect performance because these variables are mostly
used to set other variables (hence they are read few times).
 1.17 29-Aug-2007  jmmv Move the definition of multiple video-related variables into a new
header file (machine/video.h) so that we can kill all the "manual"
externs spread around the code (which were inconsistent among them).
 1.16 29-Aug-2007  jmmv Split the global videosize variable into videowidth and videoheight:
makes the code clearer and avoids multiple parts of it having to know
how videosize was encoded.
 1.15 04-Mar-2007  christos branches: 1.15.2; 1.15.10; 1.15.14; 1.15.18; 1.15.20;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.14 12-Apr-2006  jmmv branches: 1.14.14;
Add an extra cookie to the ioctl and mmap wsdisplay accessops that points
to the screen on which they are being called. The driver cannot guess
this by itself but it is needed to implement, at least, the getwschar and
putwschar functions in the correct place. There are no functional changes
yet.

Tested on i386 (vga, vga_raster, machfb, vesafb), macppc and sparc64.
Suggested and reviewed by macallan@.
 1.13 28-Mar-2006  thorpej Use device_unit().
 1.12 11-Dec-2005  christos branches: 1.12.4; 1.12.6; 1.12.8; 1.12.10; 1.12.12;
merge ktrace-lwp.
 1.11 15-Jan-2005  chs branches: 1.11.10;
de-__P, remove register, ansify, b* -> mem*.
 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 04-Jul-2002  junyoung alloc_attr -> allocattr

Approved by Matthias Drochner.
 1.6 17-Mar-2002  atatat branches: 1.6.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.5 22-Oct-2000  scottr branches: 1.5.4; 1.5.8;
Replace the call to macfb_init() when attaching a non-console fb device
with a call to macfb_clear().

[The purpose of macfb_init() is almost exclusively to initialize the
raster console blitter. We really, really do not want to do this unless
we are actually initializing the console device, else we'll give rcons
the attributes of the last-seen fb device. These will not necessarily
correspond to the attributes of the actual console device!]
 1.4 26-Jun-2000  simonb Change the kernel mmap interface so that the offset to map is an
"off_t" and the return value is a "paddr_t" to allow mappings
at offsets past 2^31 bytes. Somewhat inspired by FreeBSD, which
only changed the offset to a "vm_offset_t".

Includes updates for the i386, pc532 and sh3 mmmmap from Jason Thorpe.
 1.3 17-Mar-2000  scottr branches: 1.3.4;
Resurrect a chunk of code from the ite driver that we lost along the way.
This code is necessary for SE/30 internal video, at a minimum.
 1.2 14-Feb-2000  scottr Merge wscons work onto the main development branch.
 1.1 08-Mar-1999  scottr branches: 1.1.2; 1.1.4;
file macfb.c was initially added on branch scottr-mac68k-wscons.
 1.1.4.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.1.2.11 12-Feb-2000  scottr Remove ite emulation code. This is now done by the ite pseudo-device.
 1.1.2.10 24-Dec-1999  scottr Calculate the rcons start-of-pixels value correctly.
 1.1.2.9 13-Dec-1999  scottr A change and a bugfix, inadvertantly committed together:

- Catch up with recent change to the show_screen accessop.

- Be careful to set dc_paddr/dc_vaddr to page-aligned values, and
use dc_offset to take up the slack.
 1.1.2.8 23-Nov-1999  scottr Transpose error in rcons_init args.
 1.1.2.7 21-Nov-1999  scottr Bump maxcols to 192 so that we don't artificially limit 1152x864 displays.
Noted by Frederick Bruckman.
 1.1.2.6 20-Nov-1999  scottr Pull out the code to clear the display into a separate function.
 1.1.2.5 15-Nov-1999  scottr Implement a more straightforward approach to grf emulation.
 1.1.2.4 02-Nov-1999  scottr [Redo] Catch up to uvm_mmap() interface change.
 1.1.2.3 16-May-1999  scottr UVM is no longer optional.
 1.1.2.2 11-Mar-1999  scottr First cut at grf emulation. Neither GRFIOCMAP nor mmap'ing a wsdisplay device
work, though several other grf ioctls are properly emulated.
 1.1.2.1 08-Mar-1999  scottr Add output-side support, using existing intvid/macvid support.
 1.3.4.2 01-Nov-2000  tv Pullup 1.5 [scottr]:
Replace the call to macfb_init() when attaching a non-console fb device
with a call to macfb_clear().
 1.3.4.1 30-Jun-2000  simonb Pull up mmap paddr_t/off_t changes from trunk.
 1.5.8.3 18-Oct-2002  nathanw Catch up to -current.
 1.5.8.2 01-Aug-2002  nathanw Catch up to -current.
 1.5.8.1 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.5.4.3 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.5.4.2 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.5.4.1 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.6.4.1 16-Jul-2002  gehenna catch up with -current.
 1.9.6.5 25-Jan-2005  skrll Adapt to branch.
 1.9.6.4 17-Jan-2005  skrll Sync with HEAD.
 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.10.2 03-Sep-2007  yamt sync with head.
 1.11.10.1 21-Jun-2006  yamt sync with head.
 1.12.12.2 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.12.12.1 31-Mar-2006  tron Merge 2006-03-31 NetBSD-current into the "peter-altq" branch.
 1.12.10.1 19-Apr-2006  elad sync with head - hopefully this will work
 1.12.8.2 24-May-2006  yamt sync with head.
 1.12.8.1 01-Apr-2006  yamt sync with head.
 1.12.6.1 22-Apr-2006  simonb Sync with head.
 1.12.4.1 09-Sep-2006  rpaulo sync with head
 1.14.14.1 12-Mar-2007  rmind Sync with HEAD.
 1.15.20.1 06-Nov-2007  matt sync with HEAD
 1.15.18.1 03-Sep-2007  jmcneill Sync with HEAD.
 1.15.14.1 03-Sep-2007  skrll Sync with HEAD.
 1.15.10.1 03-Oct-2007  garbled Sync with HEAD
 1.15.2.1 09-Oct-2007  ad Sync with head.
 1.19.64.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.19.54.1 30-Oct-2012  yamt sync with head
 1.20.50.1 03-Jan-2021  thorpej Sync w/ HEAD.
 1.21.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.22.8.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.5 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.4 11-Dec-2005  christos branches: 1.4.112; 1.4.122;
merge ktrace-lwp.
 1.3 15-Jan-2005  chs de-__P, remove register, ansify, b* -> mem*.
 1.2 14-Feb-2000  scottr branches: 1.2.28;
Merge wscons work onto the main development branch.
 1.1 08-Mar-1999  scottr branches: 1.1.2; 1.1.4;
file macfbvar.h was initially added on branch scottr-mac68k-wscons.
 1.1.4.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.1.2.3 20-Nov-1999  scottr Pull out the code to clear the display into a separate function.
 1.1.2.2 11-Mar-1999  scottr First cut at grf emulation. Neither GRFIOCMAP nor mmap'ing a wsdisplay device
work, though several other grf ioctls are properly emulated.
 1.1.2.1 08-Mar-1999  scottr Add output-side support, using existing intvid/macvid support.
 1.2.28.1 17-Jan-2005  skrll Sync with HEAD.
 1.4.122.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.4.112.1 30-Oct-2012  yamt sync with head
 1.9 21-Jan-2002  jdolecek Switch to MI dev/md_root.c for archs which don't have any special
memory disk hooks (i.e. everything except atari).
 1.8 17-Mar-1999  sommerfe branches: 1.8.22; 1.8.26;
defopt MINIROOTSIZE
 1.7 13-Feb-1997  scottr branches: 1.7.16;
#include <sys/systm.h> to bring in printf() prototype
 1.6 28-Dec-1996  pk branches: 1.6.6;
rename: ramdisk => md
 1.5 13-Oct-1996  christos backout previous kprintf change
 1.4 11-Oct-1996  christos printf -> kprintf, sprintf -> ksprintf
 1.3 05-May-1996  briggs Prototype for -Wall -Wstrict-prototypes -Wmissing-prototypes -Wno-uninitialized
Also change the device probing scheme to use something a bit more rational.
A current side-effect is that nubus cards are double-mapped. I expect
to fix that shortly.
Also change splclock() to block everything but serial hardware interrupts.
 1.2 07-Mar-1996  leo Allow for a machine dependent match function - rd_match_hook()
 1.1 21-Nov-1995  briggs Add rd_root.c from sun3.
 1.6.6.1 12-Mar-1997  is Merge in changes from The Trunk, partially just reimplementing newarp.
 1.7.16.1 16-May-1999  scottr Sync with main branch.
 1.8.26.1 28-Feb-2002  nathanw Catch up to -current.
 1.8.22.1 11-Feb-2002  jdolecek Sync w/ -current.
 1.5 14-Feb-2000  scottr Merge wscons work onto the main development branch.
 1.4 16-Feb-1999  ender branches: 1.4.2; 1.4.10;
Add NetBSD RCS Id's
 1.3 11-Feb-1999  ender o Change various attach arg and softc datatypes to ints.
o Use explicit typecasts when interfacing with MRG data

Should fix port-mac68k/6839. Patch supplied by
Frederick Bruckman <fb@enteract.com>
 1.2 16-Jan-1999  scottr Add support for the Contour 3-button mouse, inadvertantly missed
in the ADB split a few months back. Noticed by Takashi NAKAMURA.
 1.1 23-Oct-1998  ender New ADB "bus" interface:
o Separate ms and kbd drivers
o aed device for compatibility
o debug message cleanup in hardware direct support (from scottr)
 1.4.10.1 20-Nov-2000  bouyer Remove files that are no longer on the trunck
 1.4.2.1 15-Nov-1999  scottr These have been moved via repository copy to akbd/ams for consistency with
the macppc port.
 1.4 14-Feb-2000  scottr Merge wscons work onto the main development branch.
 1.3 16-Feb-1999  ender branches: 1.3.2; 1.3.10;
Add NetBSD RCS Id's
 1.2 11-Feb-1999  ender o Change various attach arg and softc datatypes to ints.
o Use explicit typecasts when interfacing with MRG data

Should fix port-mac68k/6839. Patch supplied by
Frederick Bruckman <fb@enteract.com>
 1.1 23-Oct-1998  ender New ADB "bus" interface:
o Separate ms and kbd drivers
o aed device for compatibility
o debug message cleanup in hardware direct support (from scottr)
 1.3.10.1 20-Nov-2000  bouyer Remove files that are no longer on the trunck
 1.3.2.1 15-Nov-1999  scottr These have been moved via repository copy to akbd/ams for consistency with
the macppc port.
 1.72 01-Aug-2023  andvar fix various typos in comments.
 1.71 07-Apr-2022  andvar fix various typos in comments.
 1.70 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.69 24-Apr-2021  thorpej branches: 1.69.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.68 29-Sep-2020  msaitoh branches: 1.68.4;
s/implicitely/implicitly/
 1.67 18-Oct-2014  snj src is too big these days to tolerate superfluous apostrophes. It's
"its", people!
 1.66 25-Oct-2013  martin Simplify
 1.65 27-Oct-2012  chs branches: 1.65.2;
split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.64 28-Feb-2010  snj branches: 1.64.10; 1.64.20;
Fight the ever-increasing size of src checkouts by spelling "useful"
without an extra l.
 1.63 20-Oct-2009  snj branches: 1.63.2;
Remove 3rd and 4th clause on Leo Weppelman's license. OK leo@.
 1.62 25-Feb-2006  wiz branches: 1.62.72;
Fix typos, reported by Alexey Dobriyan ("Gathered from Linux"),
forwarded by jmc@openbsd.
 1.61 24-Dec-2005  perry branches: 1.61.2; 1.61.4; 1.61.6;
__asm__ -> __asm
__const__ -> const
__inline__ -> inline
__volatile__ -> volatile
 1.60 11-Dec-2005  christos merge ktrace-lwp.
 1.59 16-Jun-2005  jmc branches: 1.59.2;
Shadowing and const fixes.
 1.58 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.57 15-Jan-2005  chs branches: 1.57.2; 1.57.4;
de-__P, remove register, ansify, b* -> mem*.
 1.56 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.55 30-Oct-2003  matt Fix real uninitialized variable bug.
 1.54 30-Oct-2003  matt Fix indentation/whitespace.
 1.53 15-Jul-2003  lukem __KERNEL_RCSID()
 1.52 03-May-2003  wiz branches: 1.52.2;
DMA, not dma nor Dma.
 1.51 02-Apr-2003  thorpej Use PAGE_SIZE rather than NBPG.
 1.50 02-Oct-2002  thorpej Use CFATTACH_DECL().
 1.49 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.48 27-Sep-2002  provos remove trailing \n in panic(). approved perry.
 1.47 25-Apr-2001  bouyer branches: 1.47.2; 1.47.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.46 12-Dec-1999  scottr branches: 1.46.6;
Replace references to PGOFSET with m68k_trunc_page() and m68k_page_offset(),
as appropriate.
 1.45 30-Sep-1999  thorpej branches: 1.45.2; 1.45.8;
Update for SCSIPI changes.
 1.44 05-Dec-1998  mjacob branches: 1.44.4;
Update HBAs to incorporate the new max_lun property.
 1.43 19-Nov-1998  thorpej Adapt to the new scsipi_adapter interface.
 1.42 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.41 02-Jul-1998  wrstuden Another printf("%:"...) bites the dust (->vprintf(...))
 1.40 12-Jan-1998  thorpej Update for changes to config.
 1.39 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.38 19-Dec-1996  scottr branches: 1.38.8; 1.38.10;
Clean up a few bogons+typos introduced in the removal of the broken indirect
config code.
 1.37 16-Dec-1996  scottr Convert all foo_match() functions to use a `struct cfdata *' for their
second argument. The NuBus autoconfig code had to be reorganized as a
result of this, and looks much more like a directly-attached bus now.
These changes eliminate __BROKEN_INDIRECT_CONFIG.
 1.36 10-Dec-1996  thorpej Fill in sc_link.max_target
 1.35 13-Oct-1996  christos backout previous kprintf change
 1.34 11-Oct-1996  christos printf -> kprintf, sprintf -> ksprintf
 1.33 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.32 27-Aug-1996  cgd change cfprint_t type definition to take a const char *, rather than
a char *, because that's what was really intended, and because
if the print function modifies the string, various things could become
unhappy (so the string should _not_ be modified).
 1.31 23-Jun-1996  briggs Add a comment about the last change.
 1.30 07-Jun-1996  briggs Wait longer (2.5 sec) in wait_req_true/false. Some targets take a long time.
 1.29 22-May-1996  briggs Get rid of compiler warning if DBG_PID is not defined.
 1.28 06-May-1996  briggs branches: 1.28.4;
Update to something closer to the atari port.
 1.27 05-May-1996  briggs Prototype for -Wall -Wstrict-prototypes -Wmissing-prototypes -Wno-uninitialized
Also change the device probing scheme to use something a bit more rational.
A current side-effect is that nubus cards are double-mapped. I expect
to fix that shortly.
Also change splclock() to block everything but serial hardware interrupts.
 1.26 30-Mar-1996  christos Change %r -> %: as for recursive printf's
 1.25 29-Mar-1996  briggs Fix minor oversight in a sanity check--caught by Jason, I think, and reported
by Scott.
 1.24 20-Mar-1996  scottr Fix a long-standing bug uncovered by the new device attachment
model. Thanks to Jason Thorpe for the fix (fixed PR 2235).
 1.23 17-Mar-1996  thorpej New device attachment scheme:

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

- new "attach" directive for files.*. May specify the name of
the cfattach structure, so that devices may be easily attached
to parents with different autoconfiguration semantics.
 1.22 07-Mar-1996  briggs Fix a typo in last.
 1.21 07-Mar-1996  briggs Disable SCSI linked commands, but allow kernel option to override.
 1.20 19-Feb-1996  briggs Update to latest Atari driver, but with some local modifications.
 1.19 03-Feb-1996  briggs Move debugging defines, etc. into mac68k5380.c and use them instead of
something similar but different. Make a few cosmetic changes.
 1.18 24-Jan-1996  briggs Patch a few of the holes in the machine-dependent part of this driver.
Sync the m.i. part with the Atari.
 1.17 06-Jan-1996  briggs Fix from Paul Goyette for off-by-one error.
 1.16 06-Jan-1996  briggs Bring in a few changes from Atari port.
Add support from Paul Goyette for keeping more than just the last 2
states when debugging.
 1.15 13-Dec-1995  briggs Fix from Paul Goyette to disable linked commands on drives that
reject them for simple commands. Leo W. reports that this does
not work for some systems. It's better than what we have now,
though. From Paul Goyette <paul@pgoyette.bdt.com>.
 1.14 04-Dec-1995  briggs Fix from Paul Goyette (paul@pgoyette.bdt.com) for drives that don't grok
linked commands.
 1.13 01-Dec-1995  briggs cmdlen-2 is right for the last byte of the command. Ifdef out for right now,
though, as some devices apparently don't support linked commands and will
reject commands that have the link bit set in them.
 1.12 30-Nov-1995  briggs Put the link flag in the right place.
Pointed out by Paul@pgoyette.bdt.com (Paul Goyette).
 1.11 31-Oct-1995  briggs Pull in all but one of Leo's changes from the atari copy.
 1.10 08-Oct-1995  briggs branches: 1.10.2;
Pick up changes from leo's latest version.
 1.9 02-Oct-1995  briggs Change to allow nack_message() to take an argument and send
MSG_REJECT_MESSAGE instead of MSG_ABORT when we get an extended message.
This allows a DEC drive to work when it attempts to negotiate synch.
transfers on us.
 1.8 18-Sep-1995  briggs Do not define MIN_PHYS here--it is m.d..
 1.7 16-Sep-1995  briggs Sync. with atari ncr5380.c -- mainly whitespace changes.
 1.6 16-Sep-1995  briggs Rename scsi_main_irq() to pdma_ready().
Missed a few ATNs in last patch. (pointed out by Leo).
Raise timeout from 100 to 1000. From Leo.
 1.5 15-Sep-1995  briggs As Leo pointed out, my last change was not safe. This one should be.
I added two new bitfields to ncr_softc. They flag which devices have
been selected, and which ones have failed to go to message out when
selected with ATN. If a target fails to go to message out the first
time it is selected, it goes into the latter bitfield. If it fails
thereafter, we treat it as we did before.
 1.4 14-Sep-1995  briggs Gah... The Asante SCSI/ethernet box doesn't answer the ATN request
for a 'MESSAGE OUT' phase, so add support in scsi_select() for the
phase to be either 'MESSAGE OUT' or 'COMMAND'.
 1.3 12-Sep-1995  briggs Updates from Leo's changes in the atari port.
 1.2 05-Sep-1995  briggs Remove infinite loop per Leo and Mycroft.
 1.1 03-Sep-1995  briggs Make a local copy of the atari m.i. scsi driver sources for the time
being. Some people aren't supping arch/atari and this allows those
people to get the sources.
 1.10.2.2 31-Oct-1995  briggs Bring in version from HEAD.
 1.10.2.1 16-Oct-1995  briggs Get rid of an 'if' in reselect() that causes a hang for me--pointed out by
Leo and Mattias(sp?).
 1.28.4.2 25-Jun-1996  jtc Pulled up from rev 1.30 by request from Allen Briggs
 1.28.4.1 01-Jun-1996  scottr Pull up version 1.29 from the main branch (unused variable warning)
 1.38.10.1 27-Aug-1997  thorpej Update marc-pcmcia branch from trunk.
 1.38.8.1 01-Jul-1997  bouyer Updates for new scsipi subsystem. Actally known to work on i386 and sparc.
 1.44.4.2 12-Dec-1999  scottr Sync with main branch.
 1.44.4.1 02-Nov-1999  scottr [Redo] Sync with main branch.
 1.45.8.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.45.2.3 29-Mar-2001  bouyer Pass compile-test on i386.
 1.45.2.2 27-Mar-2001  bouyer Convert to thorpej_scsipi (untested).
 1.45.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.46.6.1 21-Jun-2001  nathanw Catch up to -current.
 1.47.8.2 18-Oct-2002  nathanw Catch up to -current.
 1.47.8.1 25-Apr-2001  nathanw file ncr5380.c was added on branch nathanw_sa on 2002-10-18 02:38:20 +0000
 1.47.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.52.2.7 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.52.2.6 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.52.2.5 17-Jan-2005  skrll Sync with HEAD.
 1.52.2.4 18-Dec-2004  skrll Sync with HEAD.
 1.52.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.52.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.52.2.1 03-Aug-2004  skrll Sync with HEAD
 1.57.4.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.57.2.1 29-Apr-2005  kent sync with -current
 1.59.2.1 21-Jun-2006  yamt sync with head.
 1.61.6.1 22-Apr-2006  simonb Sync with head.
 1.61.4.1 09-Sep-2006  rpaulo sync with head
 1.61.2.1 01-Mar-2006  yamt sync with head.
 1.62.72.1 11-Mar-2010  yamt sync with head
 1.63.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.64.20.3 03-Dec-2017  jdolecek update from HEAD
 1.64.20.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.64.20.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.64.10.2 22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.64.10.1 30-Oct-2012  yamt sync with head
 1.65.2.1 18-May-2014  rmind sync with head
 1.68.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.69.8.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.20 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.19 20-Oct-2009  snj branches: 1.19.12; 1.19.22;
Remove 3rd and 4th clause on Leo Weppelman's license. OK leo@.
 1.18 11-Dec-2005  christos branches: 1.18.78;
merge ktrace-lwp.
 1.17 16-Jun-2005  jmc Shadowing and const fixes.
 1.16 15-Jan-2005  chs de-__P, remove register, ansify, b* -> mem*.
 1.15 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.14 03-May-2003  wiz branches: 1.14.2;
DMA, not dma nor Dma.
 1.13 09-Apr-2003  thorpej Use PAGE_SIZE rather than NBPG.
 1.12 25-Apr-2001  bouyer branches: 1.12.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.11 19-Nov-1998  thorpej branches: 1.11.12; 1.11.24;
Adapt to the new scsipi_adapter interface.
 1.10 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.9 05-May-1996  briggs branches: 1.9.10; 1.9.12;
Prototype for -Wall -Wstrict-prototypes -Wmissing-prototypes -Wno-uninitialized
Also change the device probing scheme to use something a bit more rational.
A current side-effect is that nubus cards are double-mapped. I expect
to fix that shortly.
Also change splclock() to block everything but serial hardware interrupts.
 1.8 19-Feb-1996  briggs Update to latest Atari driver, but with some local modifications.
 1.7 03-Feb-1996  briggs Move debugging defines, etc. into mac68k5380.c and use them instead of
something similar but different. Make a few cosmetic changes.
 1.6 13-Dec-1995  briggs Fix from Paul Goyette to disable linked commands on drives that
reject them for simple commands. Leo W. reports that this does
not work for some systems. It's better than what we have now,
though. From Paul Goyette <paul@pgoyette.bdt.com>.
 1.5 04-Dec-1995  briggs Fix from Paul Goyette (paul@pgoyette.bdt.com) for drives that don't grok
linked commands.
 1.4 02-Oct-1995  briggs Change to allow nack_message() to take an argument and send
MSG_REJECT_MESSAGE instead of MSG_ABORT when we get an extended message.
This allows a DEC drive to work when it attempts to negotiate synch.
transfers on us.
 1.3 15-Sep-1995  briggs As Leo pointed out, my last change was not safe. This one should be.
I added two new bitfields to ncr_softc. They flag which devices have
been selected, and which ones have failed to go to message out when
selected with ATN. If a target fails to go to message out the first
time it is selected, it goes into the latter bitfield. If it fails
thereafter, we treat it as we did before.
 1.2 12-Sep-1995  briggs Update from Leo's changes.
 1.1 03-Sep-1995  briggs Make a local copy of the atari m.i. scsi driver sources for the time
being. Some people aren't supping arch/atari and this allows those
people to get the sources.
 1.9.12.1 27-Aug-1997  thorpej Update marc-pcmcia branch from trunk.
 1.9.10.1 01-Jul-1997  bouyer Updates for new scsipi subsystem. Actally known to work on i386 and sparc.
 1.11.24.1 21-Jun-2001  nathanw Catch up to -current.
 1.11.12.1 27-Mar-2001  bouyer Convert to thorpej_scsipi (untested).
 1.12.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.12.8.1 25-Apr-2001  bouyer file ncr5380reg.h was added on branch nathanw_sa on 2001-04-25 17:53:15 +0000
 1.14.2.3 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.14.2.2 17-Jan-2005  skrll Sync with HEAD.
 1.14.2.1 18-Dec-2004  skrll Sync with HEAD.
 1.18.78.1 11-Mar-2010  yamt sync with head
 1.19.22.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.19.12.1 30-Oct-2012  yamt sync with head
 1.5 24-Dec-2005  perry __asm__ -> __asm
__const__ -> const
__inline__ -> inline
__volatile__ -> volatile
 1.4 11-Dec-2005  christos merge ktrace-lwp.
 1.3 15-Jan-2005  chs branches: 1.3.10;
de-__P, remove register, ansify, b* -> mem*.
 1.2 25-May-1996  briggs branches: 1.2.64;
Clean up the interrupt handling somewhat.
 1.1 05-May-1996  briggs branches: 1.1.4;
Prototype for -Wall -Wstrict-prototypes -Wmissing-prototypes -Wno-uninitialized
Also change the device probing scheme to use something a bit more rational.
A current side-effect is that nubus cards are double-mapped. I expect
to fix that shortly.
Also change splclock() to block everything but serial hardware interrupts.
 1.1.4.1 01-Jun-1996  scottr Pull up version 1.2 from the main branch (fix interrupt handling)
 1.2.64.1 17-Jan-2005  skrll Sync with HEAD.
 1.3.10.1 21-Jun-2006  yamt sync with head.
 1.11 25-Apr-1996  scottr Renamed these files.
 1.10 25-Apr-1996  scottr Remove some now-useless code.
 1.9 25-Apr-1996  scottr We don't need to enforce the MAX_DMA_SIZE limit in dma_alloc();
this is handled properly by sbc_drq_intr() already.
 1.8 25-Apr-1996  scottr - Remove several hacks that didn't do much but waste cycles.
- Disable interrupt-driven PDMA when writing (use polled PDMA instead).
- Be more careful about when to flag a transfer as completed.

The result of these changes is that interrupt-driven PDMA works well
enough to bring the system up.
 1.7 23-Apr-1996  scottr Clean up sbc_drq_intr() a bit; also, be more paranoid about size of transfer.
 1.6 29-Mar-1996  briggs via.h -> machine/viareg.h.
 1.5 21-Mar-1996  scottr DEBUG -> SBC_DEBUG, and fix comment regarding sbc_options
 1.4 20-Mar-1996  scottr Fix a long-standing bug uncovered by the new device attachment
model. Thanks to Jason Thorpe for the fix (fixed PR 2235).
 1.3 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.2 22-Feb-1996  scottr - Clean up DEBUG code.
- Setting the "monitor BSY" flag for polled PDMA is non-optimal. The
polled requests generate an interrupt that isn't serviced until the
command has been cleared from the queue.
 1.1 10-Feb-1996  scottr New SCSI driver for Macintosh II family machines, implemented using
the MI 5380 driver. It has been verified to work on the IIx, IIsi,
and IIci only, but should work with any Macintosh 5380-based SCSI
controller.

- This driver is _not_ intended to be a general purpose replacement
for the `ncrscsi' driver. It is an alternative for those having
problems with that driver.
- Disconnect/reselect doesn't (yet) work, so don't expect SCSI tape
or magneto-optical disk drives to function properly.
 1.2 25-Apr-1996  scottr Renamed these files.
 1.1 10-Feb-1996  scottr New SCSI driver for Macintosh II family machines, implemented using
the MI 5380 driver. It has been verified to work on the IIx, IIsi,
and IIci only, but should work with any Macintosh 5380-based SCSI
controller.

- This driver is _not_ intended to be a general purpose replacement
for the `ncrscsi' driver. It is an alternative for those having
problems with that driver.
- Disconnect/reselect doesn't (yet) work, so don't expect SCSI tape
or magneto-optical disk drives to function properly.
 1.44 02-May-1998  scottr Move on-board I/O and NuBus drivers to their own directories
via repository copy, and make the necessary adjustments to reflect
the moved files.
 1.43 13-Jan-1998  scottr Update for bus.h changes.
 1.42 12-Jan-1998  thorpej Update for changes to config.
 1.41 11-Aug-1997  scottr Make #include directives consistent. All MD headers are of the form:

#include <mac68k/{dev,mac68k}/foo.h>
 1.40 15-Jul-1997  scottr branches: 1.40.2;
In nubus_print(), always print the NuBus slot number. Also, refine it so
that when no driver matches, our output is a little more consistent with
existing practice.
 1.39 14-Jul-1997  scottr Clean up some DIAGNOSTIC messages: use %x to display the slot number.
 1.38 13-May-1997  scottr Update a recently-added comment re: bytelanes values.
 1.37 11-May-1997  scottr Implement new NuBus slot space mapping/probing code, utilizing bus.h (and
our MD bus_space_probe() extension). This has several side effects:

- NuBus drivers must map and unmap slot space, rather than relying
on this happening before they are attached.
- Functions exported to NuBus drivers from nubus.c now need to be
supplied with a bus space tag/handle pair.
- Old bus map/peek functions can be garbage collected, as can pmap
support for the same.

Because of some current limitations of the bus space specification, we
are violating the abstraction in grf_mv (NuBus grf driver). All such
violations are clearly marked /* XXX */, and must be addressed when
the specification is updated.
 1.36 23-Apr-1997  briggs On video devices, if we're loading non-default resource values, save the
resource ID. Thanks to Paul Goyette <paul@pgoyette.bdt.com> for spotting
this one.
 1.35 22-Apr-1997  scottr #ifdef DIAGNOSTIC, print the NuBus type fields for unrecognized boards.
 1.34 10-Apr-1997  briggs Some patches from Bob Nestor <rnestor@metronet.com> and myself to edge
toward support for an Apple SONIC-based ethernet card. Some cards, like
his, were being missed and/or probed like video cards!
 1.33 15-Mar-1997  scottr Defer enabling NuBus slot interrupts until all slots have been probed
and drivers attached. This removes the need for the MAC68K_BROKEN_VIDEO
option. From Allen Briggs.
 1.32 28-Feb-1997  scottr Remove duplicate <machine/bus.h> include that crept in.
 1.31 24-Feb-1997  scottr NUBUS_SLOT_TO_PADDR -> NUBUS_SLOT2PA
 1.30 22-Feb-1997  scottr Make this compile again; missed this file when fixing nubus.h errors.
 1.29 17-Dec-1996  scottr branches: 1.29.6;
Revamp mainbus and obio autoconfiguration, with some direction (and the
indirect bus code framework) from Jason Thorpe. This allows us to dump
bus_scan() and bus_print(), and move bus_peek() and bus_mapin() to the
NuBus code (since they'll eventually go away, anyway).
 1.28 16-Dec-1996  scottr Convert all foo_match() functions to use a `struct cfdata *' for their
second argument. The NuBus autoconfig code had to be reorganized as a
result of this, and looks much more like a directly-attached bus now.
These changes eliminate __BROKEN_INDIRECT_CONFIG.
 1.27 21-Oct-1996  scottr Fix a raft of printf format strings and some declaration problems for
the case where we define DEBUG. From Erik Bertelsen, closes PR 2871.
 1.26 13-Oct-1996  christos backout previous kprintf change
 1.25 11-Oct-1996  christos printf -> kprintf, sprintf -> ksprintf
 1.24 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.23 08-May-1996  scottr Make this compile if DEBUG is defined.
 1.22 07-May-1996  briggs Clean up an error printf() and use proper macro.
 1.21 06-May-1996  briggs Ooops. Remove debugging printf().
 1.20 06-May-1996  briggs Do not depend on the nubus being mapped in one huge segment.
 1.19 05-May-1996  briggs Prototype for -Wall -Wstrict-prototypes -Wmissing-prototypes -Wno-uninitialized
Also change the device probing scheme to use something a bit more rational.
A current side-effect is that nubus cards are double-mapped. I expect
to fix that shortly.
Also change splclock() to block everything but serial hardware interrupts.
 1.18 04-Apr-1996  scottr Make this compile again; will need to deal with matchbyname() later, though.
 1.17 01-Apr-1996  briggs Clean up for higher warning level.
 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 12-Jan-1996  briggs Fixes from PR #1931 w/ minor mod in vm_machdep.c
 1.14 04-Aug-1995  briggs Nuke int_video_start in favor of consistent use of mac68k_vidlog.
Don't find the internal video more than once.
Probe for internal video before nubus instead of after.
 1.13 30-Jul-1995  briggs Fix the internal video probe again.
 1.12 21-Jun-1995  briggs Add some debugging (conditional on DEBUG). Add a more correct probe for
internal video. Clean up nubusprint() a bit.
 1.11 29-Apr-1995  briggs Add new nubus handling that's much more robust.
Update via, if_ae, and grf accordingly.
Revamp grf.
 1.10 21-Apr-1995  briggs First pass of KNFication. Needs more.
 1.9 12-Apr-1995  briggs Make nubus indirect. Duh.
 1.8 26-Oct-1994  cgd new RCS ID format.
 1.7 26-Jun-1994  briggs Don't assume NuBus is at NBBASE. We might remap it.
 1.6 23-Feb-1994  briggs Do a cleaner probe. This still needs lots of work, but will work on
reasonable cards...
 1.5 22-Feb-1994  briggs Minor tweaks to prevent hangs and other bad behavior... Needs much more
work now that we have more info (Designing Cards and Drivers for the
Macintosh Family Hardware.
 1.4 30-Jan-1994  briggs Just playing include-cop.
 1.3 21-Dec-1993  briggs Update ethernet driver to use config.new. At least, it's a first stab
working from mycroft's magnum changes to if_ed.c.
 1.2 29-Nov-1993  briggs Update to current work in progress. This includes an update to
use config.new.
Numerous updates to console so it works better on the SE/30 screen.
Some nice changes from Brad Parker for handling NuBUS and an ethernet
driver that I haven't worked on, yet.
 1.1 29-Sep-1993  briggs branches: 1.1.1;
Initial revision
 1.1.1.1 29-Sep-1993  briggs The current MacBSD architecture sub-directory for NetBSD-0.9--more or
less. It needs some help to get to be -current. Support for minimal
hardware on the SE/30, II, IIx, and IIcx exists.
 1.29.6.1 12-Mar-1997  is Merge in changes from The Trunk, partially just reimplementing newarp.
 1.40.2.1 23-Aug-1997  thorpej Update marc-pcmcia branch from trunk.
 1.38 02-May-1998  scottr Move on-board I/O and NuBus drivers to their own directories
via repository copy, and make the necessary adjustments to reflect
the moved files.
 1.37 26-Apr-1998  briggs Deal with the video interrupt for the RasterOps 8/24XLi. Thanks for the
information go to Tadashi Ueda <ng6t-ued@asahi-net.or.jp>.
 1.36 24-Apr-1998  briggs Add interrupt support for two more video cards: the Formac color card II
and the Radius PrecisionColor 24Xp. Thanks to <falk.stern@luene.net> and
<Mario_Magliocco@broder.com> for their remote sleuthing and testing.
 1.35 03-Dec-1997  briggs Thanks to Paul Goyette <paul@whooppee.com> for a patch to clear the
interrupt properly on a SuperMac Spectrum/8 Series III, and thanks
to Dan McMahill for loaning the card to Paul.
I modified Paul's patch somewhat to change grfmv_intr_generic_{1,4}
to grfmv_intr_generic_write{1,4} and added grfmv_intr_generic_or4 to
handle this card.
 1.34 30-Nov-1997  briggs Support for the Lapis ProColorServer 8 PDS on the SE/30. This prevents
hangs when trying to use this video card in conjunction with an ethernet
card. Thanks to David Condon <david@apk.net> for information and testing.
 1.33 25-Oct-1997  briggs Handle interrupts on E-Machines Futura-SX. From Paul Goyette, PR 4348.
 1.32 09-Oct-1997  briggs branches: 1.32.2;
Clear interrupts properly on the Radius PrecisionColor 8.
Thanks for the info go to Andrew MacGibbon <andrew-m@cs.auckland.ac.nz>
 1.31 26-Sep-1997  briggs Add another Dayna card to the Apple-compa. list.
Define a constant for the SuperMac Spectrum/24 series III display card.
Thanks go to Luca Falzoni <falzoni@jetai.unipv.it> for trying out the
code for the Dayna ethernet support.
 1.30 15-Aug-1997  briggs Add interrupt handler for SuperMac GFX.
Tested by Kai-Yew Lum <kaiyewl@engin.umich.edu> back in May.
 1.29 14-Aug-1997  scottr Recognize the Sigma Designs ColorMax card, and handle the interrupt. Code
provided by Brian Foley <bfoley@gpo.iol.ie> via Allen Briggs, updated for
bus.h by me.
 1.28 15-Jul-1997  scottr branches: 1.28.2;
Add DrHw value for the Macintosh Display Card
 1.27 01-Jul-1997  scottr Add support for Portrait Video Card. From SUNAGAWA Keiki
<kei_sun@ba2.so-net.or.jp> in PR 3821.
 1.26 11-May-1997  scottr Implement new NuBus slot space mapping/probing code, utilizing bus.h (and
our MD bus_space_probe() extension). This has several side effects:

- NuBus drivers must map and unmap slot space, rather than relying
on this happening before they are attached.
- Functions exported to NuBus drivers from nubus.c now need to be
supplied with a bus space tag/handle pair.
- Old bus map/peek functions can be garbage collected, as can pmap
support for the same.

Because of some current limitations of the bus space specification, we
are violating the abstraction in grf_mv (NuBus grf driver). All such
violations are clearly marked /* XXX */, and must be addressed when
the specification is updated.
 1.25 02-May-1997  briggs Thanks to Tobias Beal <tbeal41@maine.maine.edu>, we can clear interrupts
on at least one Radius Precisioncolor 8 board.
 1.24 01-May-1997  briggs Treat drhw 118 and 119 the same for Apple ethernet cards.
 1.23 01-May-1997  briggs Add in a couple more board types.
 1.22 10-Apr-1997  briggs Ignore SE/30 faux-video card.
 1.21 10-Apr-1997  briggs Comment video cards and add define for SuperMac Thunder/24.
 1.20 10-Apr-1997  briggs Changes from Bob Nestor to come closer to supporting his Apple SONIC-based
nubus card.
 1.19 01-Apr-1997  briggs Add DrHW for RasterOps CB264--From Scott Reynolds--and link it in to the
proper interrupt routine.
 1.18 30-Mar-1997  briggs Some new SONIC code from Denny Gentry <denny1@home.com> with a couple of
tweaks and bug fixes by yours truly.

Here's what Denny had to say:

nubus.h:
- add a drsw entry for my card
[ I also added a couple of constants for more display cards ]
if_sn.c:
- allocate sc->space using malloc (Scott wanted this).
- make csr accesses use NIC_PUT/GET, remove sc->sc_csr.
- add multicast and IFF_PROMISC support. multicast isn't
well tested, but I made sure the unicast case still
works.
- finish the new arp interface, remove sc->sc_enaddr
if_snreg.h:
- remove struct sonic_reg
if_snvar.h:
- add NIC_PUT and NIC_GET macros a la if_ae
- remove sc_txhead, it isn't used.
if_sn_nubus.c:
- clean up support for my SE/30 card.
- Move add_nubus_intr from if_sn.c (to keep if_sn.c MI)
if_sn_obio.c:
- make Q610, C610, Q650, C650, Q800 use EXBUS.
- PB500 had a "return" where "break" was intended. PB500
probably wasn't working.
- move add_nubus_intr from if_sn.c.
- add an "explanation" why Apple's ethernet addr is encoded
in token ring format in the PROM.
 1.17 24-Feb-1997  scottr NUBUS_SLOT_TO_PADDR -> NUBUS_SLOT2PA
 1.16 19-Feb-1997  scottr Add a bus space tag field to nubus_attach_args
 1.15 17-Dec-1996  scottr branches: 1.15.6;
Define struct nubus_attach_args
 1.14 07-May-1996  briggs Get rid of some old, now meaningless macros.
 1.13 05-May-1996  briggs Prototype for -Wall -Wstrict-prototypes -Wmissing-prototypes -Wno-uninitialized
Also change the device probing scheme to use something a bit more rational.
A current side-effect is that nubus cards are double-mapped. I expect
to fix that shortly.
Also change splclock() to block everything but serial hardware interrupts.
 1.12 12-Jan-1996  briggs Patch to at least recognise FOCUS EtherLAN. From Erik Bertelson
<erik@sockdev.uni-c.dk>
 1.11 24-Sep-1995  briggs Add Technology Works ethernet card. From
Kazunari Nakamura <kazu@nkk.co.jp>.
 1.10 25-Aug-1995  briggs Add constants for CSI's communications card.
 1.9 30-Jul-1995  briggs Fix the internal video probe again.
 1.8 01-Jul-1995  briggs Fix buglet that was missed when converting nubus to non pa==va mapping.
 1.7 21-Jun-1995  briggs Make NUBUS_BASE_TO_SLOT and reverse not depend on VA==PA for NuBus.
Add constant for DRSW_FARALLON.
 1.6 05-May-1995  briggs Add some code/defines to differentiate Asante and Interlan/Gator cards
correctly with the new nubus code.
 1.5 29-Apr-1995  briggs Add new nubus handling that's much more robust.
Update via, if_ae, and grf accordingly.
Revamp grf.
 1.4 21-Apr-1995  briggs First pass of KNFication. Needs more.
 1.3 26-Oct-1994  cgd new RCS ID format.
 1.2 29-Nov-1993  briggs Update to current work in progress. This includes an update to
use config.new.
Numerous updates to console so it works better on the SE/30 screen.
Some nice changes from Brad Parker for handling NuBUS and an ethernet
driver that I haven't worked on, yet.
 1.1 29-Sep-1993  briggs branches: 1.1.1;
Initial revision
 1.1.1.1 29-Sep-1993  briggs The current MacBSD architecture sub-directory for NetBSD-0.9--more or
less. It needs some help to get to be -current. Support for minimal
hardware on the SE/30, II, IIx, and IIcx exists.
 1.15.6.1 12-Mar-1997  is Merge in changes from The Trunk, partially just reimplementing newarp.
 1.28.2.3 14-Oct-1997  thorpej Update marc-pcmcia branch from trunk.
 1.28.2.2 29-Sep-1997  thorpej Update marc-pcmcia branch from trunk.
 1.28.2.1 23-Aug-1997  thorpej Update marc-pcmcia branch from trunk.
 1.32.2.2 01-Dec-1997  mellon Pull rev 1.34 up from trunk (briggs) (reviewed by mellon)
 1.32.2.1 26-Oct-1997  mellon Pull rev 1.33 up from trunk (briggs)
 1.10 02-May-1998  scottr Move on-board I/O and NuBus drivers to their own directories
via repository copy, and make the necessary adjustments to reflect
the moved files.
 1.9 12-Jan-1998  thorpej Update for changes to config.
 1.8 09-Oct-1997  jtc Fix tipo inherited from old version of TNF copyright template.
 1.7 13-Feb-1997  scottr branches: 1.7.4;
Add hsk and drq locators, which will be used only by SCSI devices.
 1.6 11-Feb-1997  scottr Add a bus space tag field to obio_attach args, initialize it in
obio_search(), and use it in the ASC driver. Thanks to Jason for
pointing this out. Minor KNFing while I'm here.
 1.5 17-Dec-1996  scottr branches: 1.5.4;
Revamp mainbus and obio autoconfiguration, with some direction (and the
indirect bus code framework) from Jason Thorpe. This allows us to dump
bus_scan() and bus_print(), and move bus_peek() and bus_mapin() to the
NuBus code (since they'll eventually go away, anyway).
 1.4 16-Dec-1996  scottr Convert all foo_match() functions to use a `struct cfdata *' for their
second argument. The NuBus autoconfig code had to be reorganized as a
result of this, and looks much more like a directly-attached bus now.
These changes eliminate __BROKEN_INDIRECT_CONFIG.
 1.3 13-Oct-1996  christos backout previous kprintf change
 1.2 11-Oct-1996  christos printf -> kprintf, sprintf -> ksprintf
 1.1 05-May-1996  briggs Prototype for -Wall -Wstrict-prototypes -Wmissing-prototypes -Wno-uninitialized
Also change the device probing scheme to use something a bit more rational.
A current side-effect is that nubus cards are double-mapped. I expect
to fix that shortly.
Also change splclock() to block everything but serial hardware interrupts.
 1.5.4.1 12-Mar-1997  is Merge in changes from The Trunk, partially just reimplementing newarp.
 1.7.4.1 14-Oct-1997  thorpej Update marc-pcmcia branch from trunk.
 1.5 02-May-1998  scottr Move on-board I/O and NuBus drivers to their own directories
via repository copy, and make the necessary adjustments to reflect
the moved files.
 1.4 09-Oct-1997  jtc Fix tipo inherited from old version of TNF copyright template.
 1.3 13-Feb-1997  scottr branches: 1.3.4;
Add hsk and drq locators, which will be used only by SCSI devices.
 1.2 11-Feb-1997  scottr Add a bus space tag field to obio_attach args, initialize it in
obio_search(), and use it in the ASC driver. Thanks to Jason for
pointing this out. Minor KNFing while I'm here.
 1.1 17-Dec-1996  scottr branches: 1.1.4;
Revamp mainbus and obio autoconfiguration, with some direction (and the
indirect bus code framework) from Jason Thorpe. This allows us to dump
bus_scan() and bus_print(), and move bus_peek() and bus_mapin() to the
NuBus code (since they'll eventually go away, anyway).
 1.1.4.1 12-Mar-1997  is Merge in changes from The Trunk, partially just reimplementing newarp.
 1.3.4.1 14-Oct-1997  thorpej Update marc-pcmcia branch from trunk.
 1.2 09-Apr-2025  nat branches: 1.2.4;
If the charge rate is zero we're not charging.
 1.1 03-Apr-2025  nat Add pbbat(4)

Now it is possible to monitor the PowerBook 1xx AC adaptors and battery via
envsys(4).
 1.2.4.2 02-Aug-2025  perseant Sync with HEAD
 1.2.4.1 09-Apr-2025  perseant file pbbat.c was added on branch perseant-exfatfs on 2025-08-02 05:55:50 +0000
 1.43 14-May-2025  nat Add sysctls for brightness control of PowerBook LCD screens.

Manual page description of these will be in a follow up commit.
 1.42 12-May-2025  nat Expose power manager type and defines.

These will be used by ascaudio(4) in future for setting up the Digitally
Filtered Audio Chip (dafc) on PowerBook 500 and similar.

NFCI.
 1.41 06-May-2025  nat Lessen the number of times a second the slider thread runs.

Four times a second is plenty and it's still nice and responsive.
 1.40 01-May-2025  nat Support the brightness slider on PowerBook 1xx series.
Update copyright.
 1.39 01-May-2025  nat Use the right location for powering off the PowerBook.

The previous location would only power off the computer if the AC adaptor was
connected.
 1.38 03-Apr-2025  nat Serialize pm requests.

Now with pbbat(4) added there is more than one caller to the power manager.
So serialize the requests with a lock.
 1.37 12-Jan-2025  nat Fix brightness controls on PowerBook 500 and similar.
 1.36 26-Sep-2024  riastradh mac68k/dev/pm_direct.c: Nix trailing whitespace.

No functional change intended.
 1.35 14-Sep-2024  nat Add support for the power button on the PowerBook 160/180.
 1.34 14-Sep-2024  nat Add support for poweroff on PowerBook 1xx.

This excludes the PowerBook 150 and 190, which are more similar to the 500
series.
 1.33 14-Sep-2024  nat Add support for brightness control on Powerbook 1xx.
 1.32 02-Jun-2024  andvar branches: 1.32.2;
fix various typos in word `interrupt', mainly in comments.
 1.31 26-Apr-2024  nat Return early if PM data is not available.

This avoids random crashes on my Powerbook when using the mouse or keyboard.

The same was needed for the Powerbook 5xx/Duos (compile tested only).

XXX pullup-10, pullup-9, pullup-8.
 1.30 21-Aug-2021  andvar branches: 1.30.4;
fix some more typos in comments/log messages, improve wording as well.
 1.29 25-Oct-2013  martin branches: 1.29.34;
Remove unused variables
 1.28 24-Jan-2007  hubertf branches: 1.28.82; 1.28.92; 1.28.98;
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.27 24-Dec-2005  perry branches: 1.27.20;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.
 1.26 11-Dec-2005  christos merge ktrace-lwp.
 1.25 28-Oct-2005  christos PR/31942: Hauke Fath: -current DEBUG kernel build fails because of gcc whining
 1.24 16-Jun-2005  jmc branches: 1.24.2; 1.24.4;
Shadowing and const fixes.
 1.23 15-Jan-2005  chs de-__P, remove register, ansify, b* -> mem*.
 1.22 15-Jul-2003  lukem __KERNEL_RCSID()
 1.21 03-Nov-2002  shiba branches: 1.21.6;
Support internal ADB keyboard of PowerBook 190,190cs.
The keyboard works fine now. I don't confirm working internal
ADB track pad.

But an internal IDE drive is not recognized, and
an internal SCSI host controller(sbc driver) don't work yet.
 1.20 30-May-2002  thorpej Don't use multi-line string literals.
 1.19 05-Mar-2002  shiba branches: 1.19.6;
Fix up a bug which PB150 shuts down when one boots up in progress.
PB150 will work with SCSI disk. But we cannot use an internal IDE
disk yet.

Reviewed by briggs
 1.18 20-Nov-2001  chs prepare for ELF:
- add "%" prefix to register names in assembly code.
- use _C_LABEL() where necessary.
- use packed structures where necessary to match the old ABI.
 1.17 16-Sep-2001  wiz branches: 1.17.4;
Grammar improvements in comments.
 1.16 16-Sep-2001  wiz Spell 'occurred' with two 'r's.
 1.15 27-Sep-2000  scottr branches: 1.15.2; 1.15.4;
The Duo ADB controller doesn't notify us that it needs to be polled
through the (emulated) VIA. Work around this problem by polling the
Power Manager chip directly. From Daishi Kato, PR 9852.
 1.14 03-Jul-2000  scottr Stabilize ADB support for some non-Apple ADB peripherals. This is the
second (and final) part of the fix for PR 10086. (There are no longer
any infinite-wait busy loops in the ADB driver!)
 1.13 05-Apr-2000  scottr branches: 1.13.4;
Correct a pasto in pm_pmgrop_pm1(); while there were no negative side
effects, the place this code ended up couldn't have had any positive
effect, either.
 1.12 05-Apr-2000  scottr Correct a few instances where we returned from a function that
had set splhigh() but returned without restoring the previous spl.
The PowerBook keyboard works better, now, but still starts to flake
out pretty badly at 70+ wpm.
 1.11 19-Mar-2000  scottr Add and use macros to build ADB FLUSH, LISTEN, and TALK commands.
 1.10 07-Nov-1999  scottr ite_polling -> adb_polling
 1.9 28-Jun-1999  briggs branches: 1.9.2; 1.9.4; 1.9.8;
Unfortunately, several changes that are intermingled:
- Add initial IOP support. ADB doesn't work yet for me, but it's here so
that others will be encouraged to work on it. ADB_HW_IOP basically
is configured as a NOP so that serial consoles will continue to work.
- Roll via1_intr and via2_intr into the intr.c scheme--this also required
changing rtclock_intr to grovel the stack differently so that hardclock
gets the right arguments and softclock() doesn't get all reentrant.
- Make via1 interrupts parallel to via2 interrupts--handlers get a pass-
through pointer and we can register handlers. Register via1 interrupt
with intr_establish()--normally level 1, level 6 for A/UX scheme.
- Use intr_establish() to set real via2 interrupt handler instead of the
hacked function pointer.
- Reorganize adb-direct interrupts so that a function call is removed.
- Implement A/UX interrupts for all Quadras right now. We may need to
special case some Quadras, but Linux folks are reporting success on
several models.
- Fix intrnames to be accurate for the normal, PSC, and A/UX interrupt
configurations.
 1.8 05-Mar-1999  scottr branches: 1.8.2; 1.8.4; 1.8.6;
Add the PowerBook 170 to what appears to be the correct
class of systems, based on the Apple dev notes for this system.
 1.7 23-Oct-1998  ender New ADB "bus" interface:
o Separate ms and kbd drivers
o aed device for compatibility
o debug message cleanup in hardware direct support (from scottr)
 1.6 12-Aug-1998  scottr New framework for handling processor interrupts, derived in part from
the hp300 port.

- Interrupts 3-6 use this immediately. Interrupt 7 is a special case,
and the VIA interrupts (1 and 2) will be addressed when that code is
rototilled.

- Modify the zs front end to register with the appropriate interrupt
controller: through the PSC on the AV Quadras, and direct to
interrupt 4 on the rest. Arrange to have the appropriate zsc_softc
supplied to us at interrupt time.

- Modify the direct ADB driver (and its PowerManager cousin) to call
intr_dispatch(), rather than zshard(). XXX This is a kludge, but at
least limits the brokenness to the ADB drivers, now.

As a side effect, this should fix PR 5590. Thanks to Bill Studenmund for
correctly determining the cause of the problem reported there.
 1.5 29-Mar-1998  scottr Better integration of Power Manager IC ADB driver into the direct ADB driver framework,
from Takashi Hamada. Also includes a handler for unsolicited ADB
packets.
 1.4 23-Feb-1998  scottr Mostly KNF. There's still a bunch of ugly comments and some problems
with long lines, but this is at least a big step in the right direction.
 1.3 21-Feb-1998  scottr Unify ADB options and place them all into opt_adb.h. Provide a knob to
enable ADB debugging messages if ADB_DEBUG is configured.
 1.2 11-Aug-1997  scottr Make #include directives consistent. All MD headers are of the form:

#include <mac68k/{dev,mac68k}/foo.h>
 1.1 08-Apr-1997  scottr branches: 1.1.4;
Power Manager interface/driver, written by Takashi Hamada.
 1.1.4.1 23-Aug-1997  thorpej Update marc-pcmcia branch from trunk.
 1.8.6.1 01-Jul-1999  thorpej Sync w/ -current.
 1.8.4.1 21-Nov-1999  he Pull up revision 1.10 (requested by sr):
Clean up the ADB driver, and eliminate duplicate keystrokes under
heavy load, fixing PR#7870.
 1.8.2.4 09-Nov-1999  scottr Sync with main branch.
 1.8.2.3 02-Nov-1999  scottr [Redo] Sync with main branch.
 1.8.2.2 05-Mar-1999  scottr checkpoint: input side code should work. no output side yet.
 1.8.2.1 05-Mar-1999  scottr file pm_direct.c was added on branch scottr-mac68k-wscons on 1999-03-05 08:24:25 +0000
 1.9.8.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.9.4.1 15-Nov-1999  fvdl Sync with -current
 1.9.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.13.4.2 28-Sep-2000  scottr Pull up rev 1.15 from scottr (approved by thorpej):
On the Duo, poll the Power Manager directly rather than waiting
for the VIA to indicate that the PM has data queued.
 1.13.4.1 21-Sep-2000  scottr Pull up rev 1.14 from scottr:
Stabilize ADB support for some non-Apple ADB peripherals.
 1.15.4.3 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.15.4.2 16-Mar-2002  jdolecek Catch up with -current.
 1.15.4.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.15.2.1 01-Oct-2001  fvdl Catch up with -current.
 1.17.4.5 11-Nov-2002  nathanw Catch up to -current
 1.17.4.4 20-Jun-2002  nathanw Catch up to -current.
 1.17.4.3 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.17.4.2 08-Jan-2002  nathanw Catch up to -current.
 1.17.4.1 16-Sep-2001  nathanw file pm_direct.c was added on branch nathanw_sa on 2002-01-08 00:26:00 +0000
 1.19.6.1 14-Jul-2002  gehenna catch up with -current.
 1.21.6.5 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.21.6.4 17-Jan-2005  skrll Sync with HEAD.
 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.24.4.1 02-Nov-2005  yamt sync with head.
 1.24.2.2 26-Feb-2007  yamt sync with head.
 1.24.2.1 21-Jun-2006  yamt sync with head.
 1.27.20.1 01-Feb-2007  ad Sync with head.
 1.28.98.1 18-May-2014  rmind sync with head
 1.28.92.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.28.82.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.29.34.1 11-May-2024  martin Pull up following revision(s) (requested by nat in ticket #1839):

sys/arch/mac68k/dev/pm_direct.c: revision 1.31

Return early if PM data is not available.

This avoids random crashes on my Powerbook when using the mouse or keyboard.

The same was needed for the Powerbook 5xx/Duos (compile tested only).
 1.30.4.1 11-May-2024  martin Pull up following revision(s) (requested by nat in ticket #686):

sys/arch/mac68k/dev/pm_direct.c: revision 1.31

Return early if PM data is not available.

This avoids random crashes on my Powerbook when using the mouse or keyboard.

The same was needed for the Powerbook 5xx/Duos (compile tested only).
 1.32.2.1 02-Aug-2025  perseant Sync with HEAD
 1.4 12-May-2025  nat Expose power manager type and defines.

These will be used by ascaudio(4) in future for setting up the Digitally
Filtered Audio Chip (dafc) on PowerBook 500 and similar.

NFCI.
 1.3 14-Sep-2024  nat Add support for poweroff on PowerBook 1xx.

This excludes the PowerBook 150 and 190, which are more similar to the 500
series.
 1.2 14-Sep-2024  nat Add support for brightness control on Powerbook 1xx.
 1.1 08-Apr-1997  scottr branches: 1.1.284;
Power Manager interface/driver, written by Takashi Hamada.
 1.1.284.1 02-Aug-2025  perseant Sync with HEAD
 1.6 28-Dec-1996  pk rename: ramdisk => md
 1.5 13-Oct-1996  christos backout previous kprintf change
 1.4 11-Oct-1996  christos printf -> kprintf, sprintf -> ksprintf
 1.3 05-May-1996  briggs Prototype for -Wall -Wstrict-prototypes -Wmissing-prototypes -Wno-uninitialized
Also change the device probing scheme to use something a bit more rational.
A current side-effect is that nubus cards are double-mapped. I expect
to fix that shortly.
Also change splclock() to block everything but serial hardware interrupts.
 1.2 07-Mar-1996  leo Allow for a machine dependent match function - rd_match_hook()
 1.1 21-Nov-1995  briggs Add rd_root.c from sun3.
 1.70 24-May-2025  nat Should the transfer stop somewhere in the firt four bytes transferred,
make sure the count is correct.

NFCI.
 1.69 10-Mar-2025  nat Remove CHECKMORE.

This was a performance penalty and was found to be unnecessary as the root
cause of errors doing pdma interrupt xfers was addressed in an earlier commit.
 1.68 10-Mar-2025  nat Serialize pdma xfers.

The same is done for pdma interrupt xfers.
 1.67 22-Nov-2024  nat Make writing of dummy byte conditional.

This is insurance against devices that do not leave ACK hanging at the end of
each transfer.

Final part of PR kern/58452.
 1.66 22-Nov-2024  nat This delay is no longer necessary.

The delays throught the code were there to ensure error free transfers. This
has been fixed in an eariler commit today by serializing the drq interrupt.

Part of PR kern/58452.
 1.65 22-Nov-2024  nat No need any additional delay waiting for DREQ.

This results in utilites like time(1) reporting results closer to reality
when timing the transfer of data. With the added benefit that transfers are
slightly faster.

Part of PR kern/58452.
 1.64 22-Nov-2024  nat Serialize drq interrupt.

This results in error free transfers between disks.

Part of PR kern/58452.
 1.63 26-Oct-2024  nat Spinkle a little delay.

This was needed to ensure a reliable transfer of data.
 1.62 26-Oct-2024  nat Write an extra byte to handle the last ACK from 5380.

This was found from the example code in the NCR5380 Interface Manual.

This is not needed (but does not hurt) on the 53C80 and later.

This fixed many problems from stuck busy to phase mismatches when aborting
transfers and avoiding hard lockups of the scsi subsystem originating from
what I first thought were errors from the target device.

XXX pullup-9, pullup 10.

I will look next at the pdma_out function to do the same there.
 1.61 26-Oct-2024  nat Rework of previous.

While here set the priority in sync witho pdma_in/out.
Use sbc_ready same as pdma_in/out.
 1.60 14-Sep-2024  nat Use smaller size when sending PDMA data, and check that the next block can
be sent before sending it.

This fixes PDMA support (which previously has been flakey at best).

These changes provide maximum performance and importantly reliablity.

The lack of support for the PDMA intr should now be revisited on the PowerBook
5xx series (Unfortunately I don't have the hw to test with).

These changes have been tested on emulated (PiSCSI/BlueSCSI) and real hw.
 1.59 18-Feb-2023  nat branches: 1.59.6;
Introduce a flag to disable PDMA when writing.

The use of pdma when writing would always cause a panic on my Powerbook 160,
possibly others as well.

As posted to tech-kern.
 1.58 18-Feb-2023  nat Honor the XS_CTL_POLL flag and fallback to polled io instead of PDMA.

As posted to tech-kern.
 1.57 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.56 29-Jun-2014  martin branches: 1.56.26; 1.56.28;
Remove an unused variable
 1.55 07-Dec-2012  hauke branches: 1.55.10;
Remove the R1 syntactic sugar, since it collides with a #define in
<m68k/regs.h>, breaking the build.

The R1s serve to bring the buffer pointer to a 4 byte boundary, but
that should be clear from the context.
 1.54 23-Nov-2009  rmind branches: 1.54.12; 1.54.22;
Use lwp_getpcb() on m68k ports, clean from struct user usage.
 1.53 04-Apr-2008  tsutsui branches: 1.53.4;
Split devict_t/softc for ncr5380sbc SCSI, and misc cosmetic changes.
 1.52 04-Mar-2007  christos branches: 1.52.40;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.51 04-Aug-2006  mhitch branches: 1.51.10;
gcc4 "uninitialized" variable; previous workaround doesn't satisfy gcc4 -
explicitly initialize drq.
 1.50 10-May-2006  skrll Fix a bunch of cast lvalues.
 1.49 17-Jan-2006  chs branches: 1.49.2; 1.49.4; 1.49.6; 1.49.8; 1.49.10;
add fault-protection in sbc_pdma_in() like in all the other PDMA functions.
fixes PR 9679.
 1.48 24-Dec-2005  perry branches: 1.48.2;
__asm__ -> __asm
__const__ -> const
__inline__ -> inline
__volatile__ -> volatile
 1.47 11-Dec-2005  christos merge ktrace-lwp.
 1.46 16-Jun-2005  jmc branches: 1.46.2;
Fixes for volatile problems
 1.45 15-Jan-2005  chs branches: 1.45.8;
de-__P, remove register, ansify, b* -> mem*.
 1.44 15-Jul-2003  lukem __KERNEL_RCSID()
 1.43 03-May-2003  wiz branches: 1.43.2;
DMA, not dma nor Dma.
 1.42 27-Sep-2002  provos remove trailing \n in panic(). approved perry.
 1.41 18-Mar-2000  mycroft branches: 1.41.8; 1.41.12;
Add a ncr5380_attach() routine which does part of the initialization, attaches
the scsibus, and does the addref/delref dance.
 1.40 02-Nov-1999  scottr [Redo] Catch up with recent changes to scsipi flags. Closes PR 8675.
 1.39 17-Sep-1999  thorpej branches: 1.39.2; 1.39.4; 1.39.6;
Centralize the declaration and clearing of `cold'.
 1.38 19-Nov-1998  thorpej branches: 1.38.4;
Adapt to the new scsipi_adapter interface.
 1.37 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.36 04-Jul-1998  jonathan defopt DDB.
 1.35 17-Jan-1998  scottr We haven't needed a driver-specific minphys() for quite some time now.
 1.34 12-Jan-1998  thorpej Update for changes to config.
 1.33 06-Dec-1997  scottr PR 4078: Enabling the SCSI IRQ interrupt to allow reselects to work
causes the MI interrupt handler to barf when we get a 5380 RST interrupt
while probing. Worse, the VIA latches the interrupt, so simply having
all interrupts disabled during autoconfig doesn't resolve the problem.
[I demonstrated the latter on a IIci, which erroneously reports a
reselection attempt(!) after autoconfig is complete. The latched
interrupt results from the SCSI bus reset we do when initializing the
bus.]

Since interrupts must be enabled during autoconfig anyway (sigh), test
to see if autoconfig has completed in sbc_irq_intr(). If not, we don't
pass the interrupt up to the MI interrupt handler. Also, make sure to
clear the VIA interrupt if we're servicing an unclaimed 5380 RST
interrupt.

Thanks to Bill Studenmund for providing the key insight needed to unlock
this problem.
 1.32 10-Oct-1997  scottr branches: 1.32.2;
Remove advertising clause.
 1.31 06-Sep-1997  scottr Catch bus error in sbc_pdma_out() and panic with a reasonable
error message.
 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 11-Aug-1997  scottr Make #include directives consistent. All MD headers are of the form:

#include <mac68k/{dev,mac68k}/foo.h>
 1.28 30-Jun-1997  scottr branches: 1.28.2; 1.28.4;
Due to reliability problems on some models, back out the more radical of
the pc532/dev/ncr.c-inspired changes; in particular, wait for previous
transfer to complete before starting another, as we used to do. Retain
splbio() protection and simplified sbc_pdma_in().
 1.27 29-Jun-1997  scottr Update for mac68k_buserr_addr -> m68k_fault_addr change.
 1.26 13-May-1997  scottr Tweak sbc_drq_intr() (interrupt-driven PDMA interrupt handler); it
now works properly on at least some disks. Further testing is
necessary.
 1.25 28-Apr-1997  scottr Undo a hack added in the last overhaul (which caused an extraneous byte
to be written to the target). Also, use the sc_min_dma_len field
to determine whether to use PDMA or PIO.
 1.24 18-Apr-1997  scottr For small writes, use PIO rather than PDMA; this increases the reliability
of the driver (considerably, on some systems/targets).
 1.23 07-Apr-1997  scottr Rework PDMA read/write functions based on Matthias Pfaller's pc532 ncr
driver. Major highlights:

- Protect with splbio(), now that interrupts from the chip might be
enabled by default;
- Wait for current transfer to complete before returning, rather than
wait for previous transfer to complete before starting another;
- Instead of logging a "timeout" message when a target disconnects,
just return, letting the sbc_ready() and sbc_wait_not_req() print
timeout messages if such really did occur.

With interrupt changes to sbc_obio.c, disconnect/reselect now works if
configured into the kernel.
 1.22 01-Mar-1997  scottr Split bus-dependent autoconfig code from the driver. This allows for
the future addition of a Duo Dock front end.
 1.21 28-Feb-1997  scottr Convert to generalized VIA interrupt registration
 1.20 26-Feb-1997  gwr Minimal changes to adapt to removal of NCR5380_PERMIT_RESELECT.
This driver should be updated to allow per-target control over
disconnect/reselect, but I will leave that to the port masters.
 1.19 24-Feb-1997  scottr Update copyright and license.
 1.18 20-Jan-1997  scottr branches: 1.18.4;
#ifdef out write hack, and fix possible uninitialized variable.
 1.17 07-Jan-1997  scottr Fix typo in last: cf->cf_unit -> sc->dv.dv_unit
 1.16 05-Jan-1997  scottr Add basic support for a Duo dock SCSI controller, from Daishi Kato.

XXX - This could probably be improved if all docking hardware has a
NuBus declaration ROM that we can get to. This should be investigated
further.
 1.15 16-Dec-1996  scottr Convert all foo_match() functions to use a `struct cfdata *' for their
second argument. The NuBus autoconfig code had to be reorganized as a
result of this, and looks much more like a directly-attached bus now.
These changes eliminate __BROKEN_INDIRECT_CONFIG.
 1.14 13-Nov-1996  thorpej Use bitmask_snprintf().
 1.13 13-Oct-1996  christos backout previous kprintf change
 1.12 11-Oct-1996  christos printf -> kprintf, sprintf -> ksprintf
 1.11 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.10 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.9 19-Jun-1996  scottr Update some comments, and the copyright
 1.8 11-Jun-1996  scottr Deal with interrupt flags more carefully, and use the correct offset
for PB500-series SCSI I/O. While I'm here, update the copyright.
 1.7 29-May-1996  scottr - Simplify writes in sbc_drq_intr().
- When finished writing, if the SCSI bus has BSY asserted, write another
byte to the SBC to ensure we get an interrupt.
- Unflag SCSI interrupts on the VIA whenever we clear the interrupts
on the SBC itself.
 1.6 08-May-1996  scottr branches: 1.6.4;
Remove some gross hacks that were added due to interrupt grossness that
has been partially fixed. Also, add a new flag (which rearranges them
a bit, unfortunately) to use PDMA for polled transfers.
 1.5 05-May-1996  briggs Prototype for -Wall -Wstrict-prototypes -Wmissing-prototypes -Wno-uninitialized
Also change the device probing scheme to use something a bit more rational.
A current side-effect is that nubus cards are double-mapped. I expect
to fix that shortly.
Also change splclock() to block everything but serial hardware interrupts.
 1.4 30-Apr-1996  scottr Kill unused variables and fix prototypes.
 1.3 30-Apr-1996  scottr - Drop SCSI IRQ interrupts if we are already handling one. This works around
a condition that occurs with some slow SCSI devices when they disconnect
(e.g. the AppleCD 600), generating spurious selection interrupts.
- Reorganize the debugging code slightly.
 1.2 25-Apr-1996  scottr Ooops. ncr_sbcreg.h -> sbcreg.h
 1.1 25-Apr-1996  scottr Renamed these files.
 1.6.4.2 20-Jun-1996  jtc Pulled up from revision 1.9 by request of Scott Reynolds.
Updates copyright/licence and comments. No code changes.
 1.6.4.1 11-Jun-1996  scottr Pull up from trunk:
>Deal with interrupt flags more carefully, and use the correct offset
>for PB500-series SCSI I/O. While I'm here, update the copyright.
 1.18.4.1 12-Mar-1997  is Merge in changes from The Trunk, partially just reimplementing newarp.
 1.28.4.4 14-Oct-1997  thorpej Update marc-pcmcia branch from trunk.
 1.28.4.3 06-Sep-1997  thorpej Update marc-pcmcia branch from trunk.
 1.28.4.2 27-Aug-1997  thorpej Update marc-pcmcia branch from trunk.
 1.28.4.1 23-Aug-1997  thorpej Update marc-pcmcia branch from trunk.
 1.28.2.2 14-Aug-1997  bouyer Sync with trunk.
 1.28.2.1 01-Jul-1997  bouyer Updates for new scsipi subsystem. Actally known to work on i386 and sparc.
 1.32.2.4 29-Jan-1998  mellon Pull up 1.34 (scottr)
 1.32.2.3 09-Dec-1997  thorpej Sync w/ trunk: fix potential hang during autoconfig. (scottr)
 1.32.2.2 19-Nov-1997  mellon DEBUG -> SBC_DEBUG (scottr)
 1.32.2.1 18-Nov-1997  mellon Undo parts of 1.23 to fix autoconfig hangs on some Macs. Not on trunk - trunk version is more correct. (scottr)
 1.38.4.3 16-Nov-1999  scottr Pull up the version from the trunk; some changes crept in that ought not
to have been committed.
 1.38.4.2 02-Nov-1999  scottr [Redo] Sync with main branch.
 1.38.4.1 16-May-1999  scottr Sync with main branch.
 1.39.6.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.39.4.1 15-Nov-1999  fvdl Sync with -current
 1.39.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.41.12.1 18-Oct-2002  nathanw Catch up to -current.
 1.41.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.43.2.5 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.43.2.4 17-Jan-2005  skrll Sync with HEAD.
 1.43.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.43.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.43.2.1 03-Aug-2004  skrll Sync with HEAD
 1.45.8.1 30-Jan-2006  tron Pull up following revision(s) (requested by chs in ticket #1146):
sys/arch/mac68k/dev/sbc.c: revision 1.49
add fault-protection in sbc_pdma_in() like in all the other PDMA functions.
fixes PR 9679.
 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.48.2.1 01-Feb-2006  yamt sync with head.
 1.49.10.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.49.8.1 11-May-2006  elad sync with head
 1.49.6.2 11-Aug-2006  yamt sync with head
 1.49.6.1 24-May-2006  yamt sync with head.
 1.49.4.1 01-Jun-2006  kardel Sync with head.
 1.49.2.1 09-Sep-2006  rpaulo sync with head
 1.51.10.1 12-Mar-2007  rmind Sync with HEAD.
 1.52.40.1 02-Jun-2008  mjf Sync with HEAD.
 1.53.4.1 11-Mar-2010  yamt sync with head
 1.54.22.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.54.22.1 25-Feb-2013  tls resync with head
 1.54.12.1 16-Jan-2013  yamt sync with (a bit old) head
 1.55.10.1 10-Aug-2014  tls Rebase.
 1.56.28.1 10-Jun-2019  christos Sync with HEAD
 1.56.26.1 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.59.6.1 02-Aug-2025  perseant Sync with HEAD
 1.8 02-May-1998  scottr Move on-board I/O and NuBus drivers to their own directories
via repository copy, and make the necessary adjustments to reflect
the moved files.
 1.7 16-Dec-1997  scottr Don't enable interrupts unless we are using reselect or interrupt-
driven PDMA modes.
 1.6 10-Oct-1997  scottr branches: 1.6.2;
Remove advertising clause.
 1.5 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.4 11-Aug-1997  scottr Make #include directives consistent. All MD headers are of the form:

#include <mac68k/{dev,mac68k}/foo.h>
 1.3 07-Apr-1997  scottr branches: 1.3.2; 1.3.4;
Always enable SCSI IRQ interrupt; the SBC_INTR flag now controls only
the SCSI DRQ interrupt, for "blind" transfers.
 1.2 15-Mar-1997  is New ARP system, supports IPv4 over any hardware link.

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

For the detailed change history, look at the commit log entries for
the is-newarp branch.
 1.1 01-Mar-1997  scottr branches: 1.1.2;
Split bus-dependent autoconfig code from the driver. This allows for
the future addition of a Duo Dock front end.
 1.1.2.2 12-Mar-1997  is Merge in changes from The Trunk, partially just reimplementing newarp.
 1.1.2.1 01-Mar-1997  is file sbc_obio.c was added on branch is-newarp on 1997-03-12 15:08:48 +0000
 1.3.4.3 14-Oct-1997  thorpej Update marc-pcmcia branch from trunk.
 1.3.4.2 27-Aug-1997  thorpej Update marc-pcmcia branch from trunk.
 1.3.4.1 23-Aug-1997  thorpej Update marc-pcmcia branch from trunk.
 1.3.2.2 14-Aug-1997  bouyer Sync with trunk.
 1.3.2.1 01-Jul-1997  bouyer Updates for new scsipi subsystem. Actally known to work on i386 and sparc.
 1.6.2.1 17-Dec-1997  mellon Pull rev 1.7 up from trunk (scottr)
 1.2 01-Mar-1997  scottr Split bus-dependent autoconfig code from the driver. This allows for
the future addition of a Duo Dock front end.
 1.1 25-Apr-1996  scottr branches: 1.1.8;
Renamed these files.
 1.1.8.1 12-Mar-1997  is Merge in changes from The Trunk, partially just reimplementing newarp.
 1.15 22-Nov-2024  nat Serialize drq interrupt.

This results in error free transfers between disks.

Part of PR kern/58452.
 1.14 22-Jan-2024  nat branches: 1.14.2;
Missing '\'

Many thnanks rillig@

XXX-pullup10.
 1.13 18-Feb-2023  nat Introduce a flag to disable PDMA when writing.

The use of pdma when writing would always cause a panic on my Powerbook 160,
possibly others as well.

As posted to tech-kern.
 1.12 11-Dec-2005  christos merge ktrace-lwp.
 1.11 05-Mar-2005  chs remove some more __P that I missed before.
 1.10 15-Jan-2005  chs branches: 1.10.2; 1.10.4;
de-__P, remove register, ansify, b* -> mem*.
 1.9 18-Mar-2000  mycroft branches: 1.9.28;
Add a ncr5380_attach() routine which does part of the initialization, attaches
the scsibus, and does the addref/delref dance.
 1.8 14-Feb-2000  scottr Merge wscons work onto the main development branch.
 1.7 22-Dec-1998  scottr branches: 1.7.2; 1.7.10;
vm_offset_t -> {paddr_t, vaddr_t}
 1.6 19-Nov-1998  thorpej Adapt to the new scsipi_adapter interface.
 1.5 04-Jul-1998  jonathan defopt DDB.
 1.4 10-Oct-1997  scottr Remove advertising clause.
 1.3 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.2 15-Mar-1997  is branches: 1.2.2; 1.2.4;
New ARP system, supports IPv4 over any hardware link.

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

For the detailed change history, look at the commit log entries for
the is-newarp branch.
 1.1 01-Mar-1997  scottr branches: 1.1.2;
Split bus-dependent autoconfig code from the driver. This allows for
the future addition of a Duo Dock front end.
 1.1.2.2 12-Mar-1997  is Merge in changes from The Trunk, partially just reimplementing newarp.
 1.1.2.1 01-Mar-1997  is file sbcvar.h was added on branch is-newarp on 1997-03-12 15:08:50 +0000
 1.2.4.2 14-Oct-1997  thorpej Update marc-pcmcia branch from trunk.
 1.2.4.1 27-Aug-1997  thorpej Update marc-pcmcia branch from trunk.
 1.2.2.1 01-Jul-1997  bouyer Updates for new scsipi subsystem. Actally known to work on i386 and sparc.
 1.7.10.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.7.2.1 16-May-1999  scottr Sync with main branch.
 1.9.28.2 08-Mar-2005  skrll Sync with HEAD.
 1.9.28.1 17-Jan-2005  skrll Sync with HEAD.
 1.10.4.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.10.2.1 29-Apr-2005  kent sync with -current
 1.14.2.1 02-Aug-2025  perseant Sync with HEAD
 1.1 29-Sep-1993  briggs branches: 1.1.1;
Initial revision
 1.1.1.2 01-Mar-1995  mycroft Clean up deleted files.
 1.1.1.1 29-Sep-1993  briggs The current MacBSD architecture sub-directory for NetBSD-0.9--more or
less. It needs some help to get to be -current. Support for minimal
hardware on the SE/30, II, IIx, and IIcx exists.
 1.1 29-Sep-1993  briggs branches: 1.1.1;
Initial revision
 1.1.1.2 01-Mar-1995  mycroft Clean up deleted files.
 1.1.1.1 29-Sep-1993  briggs The current MacBSD architecture sub-directory for NetBSD-0.9--more or
less. It needs some help to get to be -current. Support for minimal
hardware on the SE/30, II, IIx, and IIcx exists.
 1.21 06-May-1996  briggs This code has not been used in ages and there are at least 2 better 5380
drivers in the tree, now.
 1.20 05-May-1996  briggs Prototype for -Wall -Wstrict-prototypes -Wmissing-prototypes -Wno-uninitialized
Also change the device probing scheme to use something a bit more rational.
A current side-effect is that nubus cards are double-mapped. I expect
to fix that shortly.
Also change splclock() to block everything but serial hardware interrupts.
 1.19 03-Sep-1995  briggs Note that this is now an obsolete driver.
 1.18 12-Aug-1995  mycroft minphys() functions really should return void.
 1.17 24-Jul-1995  cgd update SCSI minphys routines' definitions to match standard minphys()
definition and usage.
 1.16 04-Jul-1995  briggs A few nits.
 1.15 21-Jun-1995  briggs Clean up I/O base settings a bit.
 1.14 21-Apr-1995  briggs First pass of KNFication. Needs more.
 1.13 20-Apr-1995  briggs Update to use softc better and handle mainbus being indirect.
 1.12 01-Feb-1995  briggs Set sc_link->openings.
Simplification of scsi_cmd from pc532 mods to this driver.
 1.11 15-Jan-1995  briggs Update for scsi changes. Incl. xs->resid = 0 (thanks Phil).
Changes compile, but are not tested.
 1.10 03-Dec-1994  briggs Remove private delay() and clean up some odd delay times that we were
using...
 1.9 29-Nov-1994  briggs "../scsi/*.h" -> <scsi/*.h>
 1.8 26-Oct-1994  cgd new RCS ID format.
 1.7 10-Jul-1994  briggs Be somewhat better at machine dependence.
 1.6 26-Jun-1994  briggs branches: 1.6.2;
Add some support for the '040 macs which use a different scsi chip. The
scsi96 driver is just a skeleton at the moment.
 1.5 30-Jan-1994  briggs Change to support config.new and magnum-esque scsi code. Works much
more nicely.
 1.4 15-Jan-1994  briggs Put lun in CDB. Is there be a way to determine when this is really
necessary? (It is for some drives).
 1.3 15-Dec-1993  briggs Add (semi-bogus?) test to scsi_gen to handle luns in test unit ready
commands. W/o this test, some old drives were being identified at
all luns... Also some cleanup and spelling corrections ;-)
 1.2 29-Nov-1993  briggs Update to current work in progress. This includes an update to
use config.new.
Numerous updates to console so it works better on the SE/30 screen.
Some nice changes from Brad Parker for handling NuBUS and an ethernet
driver that I haven't worked on, yet.
 1.1 29-Sep-1993  briggs branches: 1.1.1;
Initial revision
 1.1.1.1 29-Sep-1993  briggs The current MacBSD architecture sub-directory for NetBSD-0.9--more or
less. It needs some help to get to be -current. Support for minimal
hardware on the SE/30, II, IIx, and IIcx exists.
 1.6.2.1 24-Jul-1994  cgd update, as requested by briggs
 1.22 15-Nov-1996  briggs Remove scsi96 driver.
 1.21 13-Oct-1996  christos backout previous kprintf change
 1.20 11-Oct-1996  christos printf -> kprintf, sprintf -> ksprintf
 1.19 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.18 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.17 05-May-1996  briggs Prototype for -Wall -Wstrict-prototypes -Wmissing-prototypes -Wno-uninitialized
Also change the device probing scheme to use something a bit more rational.
A current side-effect is that nubus cards are double-mapped. I expect
to fix that shortly.
Also change splclock() to block everything but serial hardware interrupts.
 1.16 29-Mar-1996  briggs via.h -> machine/viareg.h.
 1.15 24-Mar-1996  briggs Get rid of a compiler warning about Debugger();
 1.14 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.13 14-Aug-1995  briggs Always fail when probed--until this driver works.
 1.12 12-Aug-1995  mycroft minphys() functions really should return void.
 1.11 24-Jul-1995  cgd update SCSI minphys routines' definitions to match standard minphys()
definition and usage.
 1.10 04-Jul-1995  briggs Update a bit.
 1.9 21-Apr-1995  briggs First pass of KNFication. Needs more.
 1.8 15-Jan-1995  briggs Update for scsi changes. Incl. xs->resid = 0 (thanks Phil).
Changes compile, but are not tested.
 1.7 03-Dec-1994  briggs Get rid of private delay().
 1.6 29-Nov-1994  briggs "../scsi/*.h" -> <scsi/*.h>
 1.5 26-Oct-1994  cgd new RCS ID format.
 1.4 21-Jul-1994  briggs Put in a warning message that the driver is non-working and checkpoint
with a little bit more debugging stuffage.
 1.3 10-Jul-1994  briggs Be somewhat better at machine dependence.
 1.2 08-Jul-1994  briggs Just a checkpoint. Still not close to working, but TUR works--more docs
coming today...
 1.1 26-Jun-1994  briggs branches: 1.1.2;
Add some support for the '040 macs which use a different scsi chip. The
scsi96 driver is just a skeleton at the moment.
 1.1.2.1 24-Jul-1994  cgd update, as requested by briggs
 1.4 02-May-1998  scottr Dead, unused, kaput.
 1.3 26-Oct-1994  cgd new RCS ID format.
 1.2 29-Nov-1993  briggs Update to current work in progress. This includes an update to
use config.new.
Numerous updates to console so it works better on the SE/30 screen.
Some nice changes from Brad Parker for handling NuBUS and an ethernet
driver that I haven't worked on, yet.
 1.1 29-Sep-1993  briggs branches: 1.1.1;
Initial revision
 1.1.1.1 29-Sep-1993  briggs The current MacBSD architecture sub-directory for NetBSD-0.9--more or
less. It needs some help to get to be -current. Support for minimal
hardware on the SE/30, II, IIx, and IIcx exists.
 1.39 18-May-1996  briggs Serial driver with interface to a slightly modified version of the machine-
independent z8530 driver. When that driver is updated, the local copy
of those files may be removed. From Bill Studenmund.
Compiler warnings fixed by me.
 1.38 05-May-1996  briggs Prototype for -Wall -Wstrict-prototypes -Wmissing-prototypes -Wno-uninitialized
Also change the device probing scheme to use something a bit more rational.
A current side-effect is that nubus cards are double-mapped. I expect
to fix that shortly.
Also change splclock() to block everything but serial hardware interrupts.
 1.37 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.36 06-Mar-1996  briggs Fix for serial console handling from Bill Studenmund.
 1.35 01-Feb-1996  mycroft LOCORE -> _LOCORE
 1.34 12-Jan-1996  briggs Fixes from PR #1931 w/ minor mod in vm_machdep.c
 1.33 11-Jan-1996  briggs Move splzs to spl4 from splhigh. Really same difference...
 1.32 13-Dec-1995  briggs Remove printf() that I forgot about.
 1.31 13-Dec-1995  briggs Update from Bill Studenmund <wrstuden@loki.stanford.edu> with some minor
cleanup from me. Now supports serial console.
 1.30 09-Oct-1995  briggs Port of Sun3/Sparc zs driver from wrstuden@loki.stanford.edu
(Bill Studenmund). Should be massaged into machine independence
for 1.2.
 1.29 11-Aug-1995  briggs The serial console works again (at least on the Q700).
 1.28 11-Aug-1995  briggs Note that we've been initialized.
 1.27 11-Aug-1995  briggs Do the serial console a bit better (still has problems).
 1.26 28-Jun-1995  cgd note that most of dev/ic's contents have changed names
 1.25 21-Jun-1995  briggs Clean up I/O base settings a bit.
 1.24 09-Jun-1995  briggs "Always compile before you commit."
 1.23 08-Jun-1995  briggs In the interrupt routine, bail out if we've not been initialized, yet.
 1.22 21-Apr-1995  briggs First pass of KNFication. Needs more.
 1.21 20-Apr-1995  briggs Add a sertty() and update to use ser_softc instead of a bunch of arrays
everywhere.
 1.20 12-Apr-1995  briggs Fix typo from last changes.
 1.19 11-Apr-1995  mycroft Use global 8530 defs.
 1.18 08-Apr-1995  briggs Back to previous version of the serial driver until we can figure out
why the new one gets a lot of overflows and doesn't work on the IIsi
or IIvx at all.
 1.17 11-Feb-1995  briggs Many changes and updates from Dave Leonard (d@fnarg.net.au) and
Brad Parker (brad@fcr.com). I've been sitting on these for a while.
Notes from Dave:
redocumented z8530 stuff.
Added break ioctls and detection.
Pass framing/parity errors to line discipline.
Added TIOC[SG]FLAG.
Attempt at bringing all chip ops together.
deepended s/w fifos to match chip's.
 1.16 29-Nov-1994  briggs Boolean goof. (True)
 1.15 03-Nov-1994  briggs Modify the serial port initialization slightly so it works on the IIsi.
 1.14 26-Oct-1994  cgd new RCS ID format.
 1.13 30-Sep-1994  briggs Change strategy slightly so that serial console is enabled if internal
console is not--regardless of the value of the boot-time flag.
Suggested by a question from bit@gnu.ai.mit.edu (jim howard - bit.map).
 1.12 29-Sep-1994  briggs Actually implement serial boot (console) echo (minor change to ite.c).
Remove some old junk in ser.c and implement serial console and serial
boot echo (if serial console's enabled, clear echo).
 1.11 05-Aug-1994  briggs Lots of cleanup. Add functions for serial console--just stubs for now.
Fix initialization (for good this time?).
Little things.
 1.10 21-Jul-1994  briggs Make "unknown ioctl" printf ifdef DEBUG and take out an extra comma from
the format string.
 1.9 21-Jul-1994  briggs Separate init from serattach and make more machine independent by
calculating speed during init (different models of macs feed SCC with
different clocks).
 1.8 10-Jul-1994  briggs Be somewhat better at machine dependence.
 1.7 09-Jul-1994  briggs Move a function here from the old console.c.
 1.6 26-Jun-1994  briggs branches: 1.6.2;
Change some default constants--might be overridden during boot, but
correct for MacII-class.
 1.5 10-Feb-1994  briggs ioctl now takes struct proc *.
 1.4 30-Jan-1994  briggs Fixup includes and prototype stuff. Still need to go back and put in
old-style function headers to be pedantic.
 1.3 10-Jan-1994  briggs Update grf.h to increment a number of devices when it configures.
Fix a small bug in serial.
Both from Brad, Lawrence, and/or Mike.
 1.2 29-Nov-1993  briggs Update to current work in progress. This includes an update to
use config.new.
Numerous updates to console so it works better on the SE/30 screen.
Some nice changes from Brad Parker for handling NuBUS and an ethernet
driver that I haven't worked on, yet.
 1.1 29-Sep-1993  briggs branches: 1.1.1;
Initial revision
 1.1.1.1 29-Sep-1993  briggs The current MacBSD architecture sub-directory for NetBSD-0.9--more or
less. It needs some help to get to be -current. Support for minimal
hardware on the SE/30, II, IIx, and IIcx exists.
 1.6.2.3 29-Sep-1994  cgd from trunk, per briggs.
 1.6.2.2 05-Aug-1994  mycroft update from trunk
 1.6.2.1 24-Jul-1994  cgd update, as requested by briggs
 1.10 18-May-1996  briggs Serial driver with interface to a slightly modified version of the machine-
independent z8530 driver. When that driver is updated, the local copy
of those files may be removed. From Bill Studenmund.
Compiler warnings fixed by me.
 1.9 21-Apr-1995  briggs First pass of KNFication. Needs more.
 1.8 11-Apr-1995  mycroft Use global 8530 defs.
 1.7 08-Apr-1995  briggs Back to previous version of the serial driver until we can figure out
why the new one gets a lot of overflows and doesn't work on the IIsi
or IIvx at all.
 1.6 11-Feb-1995  briggs Many changes and updates from Dave Leonard (d@fnarg.net.au) and
Brad Parker (brad@fcr.com). I've been sitting on these for a while.
Notes from Dave:
redocumented z8530 stuff.
Added break ioctls and detection.
Pass framing/parity errors to line discipline.
Added TIOC[SG]FLAG.
Attempt at bringing all chip ops together.
deepended s/w fifos to match chip's.
 1.5 26-Oct-1994  cgd new RCS ID format.
 1.4 10-Jul-1994  briggs Be somewhat better at machine dependence.
 1.3 26-Jun-1994  briggs branches: 1.3.2;
Let's not hard-code constants, OK?
 1.2 29-Nov-1993  briggs Update to current work in progress. This includes an update to
use config.new.
Numerous updates to console so it works better on the SE/30 screen.
Some nice changes from Brad Parker for handling NuBUS and an ethernet
driver that I haven't worked on, yet.
 1.1 29-Sep-1993  briggs branches: 1.1.1;
Initial revision
 1.1.1.1 29-Sep-1993  briggs The current MacBSD architecture sub-directory for NetBSD-0.9--more or
less. It needs some help to get to be -current. Support for minimal
hardware on the SE/30, II, IIx, and IIcx exists.
 1.3.2.1 24-Jul-1994  cgd update, as requested by briggs
 1.3 15-Dec-1993  mycroft Clean up deleted files.
 1.2 29-Nov-1993  briggs Update to current work in progress. This includes an update to
use config.new.
Numerous updates to console so it works better on the SE/30 screen.
Some nice changes from Brad Parker for handling NuBUS and an ethernet
driver that I haven't worked on, yet.
 1.1 29-Sep-1993  briggs branches: 1.1.1;
Initial revision
 1.1.1.1 29-Sep-1993  briggs The current MacBSD architecture sub-directory for NetBSD-0.9--more or
less. It needs some help to get to be -current. Support for minimal
hardware on the SE/30, II, IIx, and IIcx exists.
 1.4 20-Oct-1997  scottr Convert to MI 8530 SCC driver, from Bill Studenmund. The new front end
also supports DTR/CTS flow control.
 1.3 18-May-1996  briggs Serial driver with interface to a slightly modified version of the machine-
independent z8530 driver. When that driver is updated, the local copy
of those files may be removed. From Bill Studenmund.
Compiler warnings fixed by me.
 1.2 01-Feb-1996  mycroft LOCORE -> _LOCORE
 1.1 09-Oct-1995  briggs Port of Sun3/Sparc zs driver from wrstuden@loki.stanford.edu
(Bill Studenmund). Should be massaged into machine independence
for 1.2.
 1.4 20-Oct-1997  scottr Convert to MI 8530 SCC driver, from Bill Studenmund. The new front end
also supports DTR/CTS flow control.
 1.3 11-Aug-1997  scottr Make #include directives consistent. All MD headers are of the form:

#include <mac68k/{dev,mac68k}/foo.h>
 1.2 26-Aug-1996  scottr branches: 1.2.10;
After servicing an interrupt, check to see that there's not another
one pending before we clear the interrupt flag. This avoids a condition
where the line appears to go catatonic (which is particularly easily
triggered by pppd). From Bill Studenmund <wrstuden@loki.stanford.edu>.
XXX - we should probably log this if it gets excessive.
 1.1 18-May-1996  briggs branches: 1.1.4;
Serial driver with interface to a slightly modified version of the machine-
independent z8530 driver. When that driver is updated, the local copy
of those files may be removed. From Bill Studenmund.
Compiler warnings fixed by me.
 1.1.4.1 05-Sep-1996  jtc Pulled up rev 1.2 by request from Scott Reynolds
 1.2.10.1 23-Aug-1997  thorpej Update marc-pcmcia branch from trunk.
 1.3 20-Oct-1997  scottr Convert to MI 8530 SCC driver, from Bill Studenmund. The new front end
also supports DTR/CTS flow control.
 1.2 15-Oct-1996  scottr Critical fix from Bill Studenmund: if CTS is deasserted and then
immediately reasserted before we get a chance to process the interrupt,
we can inadvertantly get stuck with zs_tx_stopped set. Move the delta
detection to the hard zs interrupt handler; the softint handler
will notice that something has happened with CTS and restart the
transmitter if it's asserted.
 1.1 18-May-1996  briggs branches: 1.1.4;
Serial driver with interface to a slightly modified version of the machine-
independent z8530 driver. When that driver is updated, the local copy
of those files may be removed. From Bill Studenmund.
Compiler warnings fixed by me.
 1.1.4.1 05-Dec-1996  rat Patch supplied by Scott Reynolds <scottr@NetBSD.ORG>

>The following patch corrects a mac68k zs bug corresponding to Gordon's
>MI zs changes submitted for patch 1. Specifically, output may fail to
>restart if we get multiple status interrupts before the "software
>interrupt" routine gets a chance to run.
>
>Bill Studenmund noticed this and submitted the original fix.
 1.14 20-Oct-1997  scottr Convert to MI 8530 SCC driver, from Bill Studenmund. The new front end
also supports DTR/CTS flow control.
 1.13 11-Aug-1997  scottr Make #include directives consistent. All MD headers are of the form:

#include <mac68k/{dev,mac68k}/foo.h>
 1.12 23-Jul-1997  scottr branches: 1.12.2;
Since spltty() will not lower the spl, only raise it, we need to
use splx() to undo the effect of the splzs() in zstty_softint().
 1.11 17-Jul-1997  jtk use locator defines in "locators.h" to index cf_loc[]
 1.10 18-Dec-1996  scottr Work around another gcc initialization warning.
 1.9 16-Dec-1996  scottr Convert all foo_match() functions to use a `struct cfdata *' for their
second argument. The NuBus autoconfig code had to be reorganized as a
result of this, and looks much more like a directly-attached bus now.
These changes eliminate __BROKEN_INDIRECT_CONFIG.
 1.8 15-Oct-1996  scottr Critical fix from Bill Studenmund: if CTS is deasserted and then
immediately reasserted before we get a chance to process the interrupt,
we can inadvertantly get stuck with zs_tx_stopped set. Move the delta
detection to the hard zs interrupt handler; the softint handler
will notice that something has happened with CTS and restart the
transmitter if it's asserted.
 1.7 13-Oct-1996  christos backout previous kprintf change
 1.6 11-Oct-1996  christos printf -> kprintf, sprintf -> ksprintf
 1.5 16-Sep-1996  scottr Move check for ZS_HWFLAG_CONABRT to zs_abort().
 1.4 02-Sep-1996  mycroft tty stop functions really should return void, not int, and certainly not both.
 1.3 01-Jun-1996  scottr Add tty_attach() as appropriate (for pstat -t)
 1.2 23-May-1996  briggs Fix from Bill Studenmund to set flags sanely on serial console.
 1.1 18-May-1996  briggs branches: 1.1.4;
Serial driver with interface to a slightly modified version of the machine-
independent z8530 driver. When that driver is updated, the local copy
of those files may be removed. From Bill Studenmund.
Compiler warnings fixed by me.
 1.1.4.4 05-Dec-1996  rat Patch supplied by Scott Reynolds <scottr@NetBSD.ORG>

>The following patch corrects a mac68k zs bug corresponding to Gordon's
>MI zs changes submitted for patch 1. Specifically, output may fail to
>restart if we get multiple status interrupts before the "software
>interrupt" routine gets a chance to run.
>
>Bill Studenmund noticed this and submitted the original fix.
 1.1.4.3 03-Jun-1996  scottr Back out previous change; we now have new tty stats code.
 1.1.4.2 02-Jun-1996  scottr My mistake; we're not yet ready for tty_attach() on this branch.
 1.1.4.1 01-Jun-1996  scottr Pull up version 1.2 from the main branch
 1.12.2.1 23-Aug-1997  thorpej Update marc-pcmcia branch from trunk.
 1.2 20-Oct-1997  scottr Convert to MI 8530 SCC driver, from Bill Studenmund. The new front end
also supports DTR/CTS flow control.
 1.1 18-May-1996  briggs Serial driver with interface to a slightly modified version of the machine-
independent z8530 driver. When that driver is updated, the local copy
of those files may be removed. From Bill Studenmund.
Compiler warnings fixed by me.
 1.63 23-Sep-2023  andvar some whitespace cleanup for debug printf calls.
 1.62 23-Sep-2023  andvar change zsprintf to printf. It was defined as printf in include/z8530var.h
up to rev 1.4, then removed with conversion to MI 8530 SCC driver back in 1997.

Fixes build with ZSMACDEBUG option enabled for mac68k and macppc.
 1.61 11-Sep-2021  andvar Add missing double p and d for stopped and overriden accordingly.
Fix few more typos along the way, mainly in copy-pasted comments.
 1.60 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.59 24-Apr-2021  thorpej branches: 1.59.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.58 27-Oct-2009  snj branches: 1.58.78;
Drop 3rd and 4th clauses. Approved by gwr@ and wrstuden@ (copyright
holders).
 1.57 18-Mar-2009  cegger Ansify function definitions w/o arguments. Generated with sed.
 1.56 29-Mar-2008  tsutsui branches: 1.56.4; 1.56.12; 1.56.18;
Split softc and device_t for zsc(4) and its children.

XXX we should restructure MI APIs and make it really machine independent.
 1.55 03-Dec-2007  ad branches: 1.55.14;
Interrupt handling changes, in discussion since February:

- Reduce available SPL levels for hardware devices to none, vm, sched, high.
- Acquire kernel_lock only for interrupts at IPL_VM.
- Implement threaded soft interrupts.
 1.54 09-Nov-2007  ad Call zs_lock_init() to set up the chanstate's lock.
 1.53 08-Mar-2007  tsutsui branches: 1.53.2; 1.53.18; 1.53.20; 1.53.24; 1.53.26;
MI softintr(9)'fy.
Probably problematic, but LC630 is running at single user.
 1.52 04-Mar-2007  christos Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.51 24-Nov-2006  wiz branches: 1.51.4;
s/independant/independent/, from Zafer.
 1.50 28-Mar-2006  thorpej branches: 1.50.8; 1.50.10;
Use device_unit().
 1.49 11-Dec-2005  christos branches: 1.49.4; 1.49.6; 1.49.8; 1.49.10; 1.49.12;
merge ktrace-lwp.
 1.48 16-Jun-2005  jmc branches: 1.48.2;
Fixes for volatile problems
 1.47 16-Jan-2005  chs branches: 1.47.2;
only match one instance (instead of an unlimited number).
simplify by not pretending that mac68k can have more than 1 zsc.
 1.46 15-Jan-2005  chs de-__P, remove register, ansify, b* -> mem*.
 1.45 14-Dec-2004  christos Move the definition of sccA from zc.c to machdep.c and always initialize it.
This way we save a mess of #ifdefs. XXX: This code is disgusting. Drivers
should not communicate with the rest of the kernel by means of global variables.
 1.44 04-Dec-2003  keihan netbsd.org -> NetBSD.org

All "netbsd.org" is now gone from src/sys/arch.
 1.43 15-Jul-2003  lukem __KERNEL_RCSID()
 1.42 28-Jan-2003  pk branches: 1.42.2;
Provide locking required by the interrupt handlers running at IPL_SERIAL.
 1.41 06-Jan-2003  wiz interrupt with two rs.
 1.40 01-Jan-2003  thorpej Use aprint_normal() for cfprint routines.
 1.39 02-Oct-2002  thorpej Use CFATTACH_DECL().
 1.38 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.37 27-Sep-2002  provos remove trailing \n in panic(). approved perry.
 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 19-Jun-2001  wiz branches: 1.34.2; 1.34.4; 1.34.8;
`existent', not `existant'
 1.33 25-Jun-2000  wrstuden branches: 1.33.2;
Fix logic bug which would keep PPS from working. Noticed by:

Charles Carvalho <carvalho@cisco.com>
 1.32 02-Nov-1999  scottr branches: 1.32.6;
[Redo] Allow rates higher than 57600, per PR 8070. Change originally
from Bill Studenmund.
 1.31 27-Mar-1999  wrstuden branches: 1.31.2; 1.31.8; 1.31.10; 1.31.12;
Enable pps support, only if CLOCAL set & MDMBUF clear and no clock present.
 1.30 23-Mar-1999  wrstuden Oops. mac68k does NOT use PCLK as a clock source, so don't enable it in
the default channel setup.
 1.29 11-Feb-1999  mycroft branches: 1.29.2;
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.28 03-Feb-1999  mycroft Don't set DCD_IE in the frontends. KGDB doesn't even use DCD, and the tty
frontends get it from zsparam() anyway.
 1.27 22-Oct-1998  scottr Defopt ALTXBUTTONS, DISABLE_EXT_CACHE, and ZS_CONSOLE_ABORT.
 1.26 10-Sep-1998  scottr Use correct devices for zs driver on AVs. From Dave Huang (PR 6107).
 1.25 12-Aug-1998  scottr A simple, obvious optimization, now that the loop has been
removed from zshard(). Pointed out by Bill Studenmund.
 1.24 12-Aug-1998  scottr New framework for handling processor interrupts, derived in part from
the hp300 port.

- Interrupts 3-6 use this immediately. Interrupt 7 is a special case,
and the VIA interrupts (1 and 2) will be addressed when that code is
rototilled.

- Modify the zs front end to register with the appropriate interrupt
controller: through the PSC on the AV Quadras, and direct to
interrupt 4 on the rest. Arrange to have the appropriate zsc_softc
supplied to us at interrupt time.

- Modify the direct ADB driver (and its PowerManager cousin) to call
intr_dispatch(), rather than zshard(). XXX This is a kludge, but at
least limits the brokenness to the ADB drivers, now.

As a side effect, this should fix PR 5590. Thanks to Bill Studenmund for
correctly determining the cause of the problem reported there.
 1.23 04-Jul-1998  jonathan defopt DDB.
 1.22 02-Jul-1998  wrstuden Fixup last revision to zs.c. Keep a lot of the comment cleanup, and
keep the explicit clearing of interupts in zscnprobe.
 1.21 30-Jun-1998  wrstuden Overkill patches to make serial console work again. Should also make
serial echo work, but not sure. Tested by Paul Goyette.

A few of these changes can probably be backed out, but I'm not sure which.
This part should work for now, and get things going again. These fixes
should also get rid of the problem of things crashing just as zstty0 gets
configured.
 1.20 05-May-1998  scottr Add the remaining kgdb pieces from sun3/hp300, with some mac68k-specific
adjustments to initialization.
 1.19 12-Jan-1998  thorpej Update for changes to config.
 1.18 16-Dec-1997  wrstuden Add initialization code for cs_wr5_dtr as the M.I. layer now tests
it in initializing during autoconfig. Similar to sys/arch/sun3/dev/zs.c
revision 1.47. Ought to fix hangs at first tty access reported by
Johnny Lam, <jlbg+@andrew.cmu.edu>.
 1.17 06-Dec-1997  scottr Shades of rev 1.13: Really, we shouldn't call Debugger() if we
haven't got ddb in the kernel. Fixes PR 4632.
 1.16 02-Nov-1997  mycroft Set rr0_dcd.
Don't set DCD_IE and CTS_IE here; let the MI code do it.
Handle MDMBUF.
 1.15 20-Oct-1997  scottr branches: 1.15.2;
Convert to MI 8530 SCC driver, from Bill Studenmund. The new front end
also supports DTR/CTS flow control.
 1.14 11-Aug-1997  scottr Make #include directives consistent. All MD headers are of the form:

#include <mac68k/{dev,mac68k}/foo.h>
 1.13 15-Jun-1997  scottr branches: 1.13.4;
Don't call Debugger() if we don't have ddb. Fixes PR 3744.
 1.12 18-Dec-1996  scottr Work around another bogus uninitialized warning, and fix a legitimate one.
Clearly mark the former.

XXX The bogus warnings show up with -O, but not -O2. Unfortunately,
NetBSD/mac68k can't (yet) use -O2.
 1.11 16-Dec-1996  scottr Convert all foo_match() functions to use a `struct cfdata *' for their
second argument. The NuBus autoconfig code had to be reorganized as a
result of this, and looks much more like a directly-attached bus now.
These changes eliminate __BROKEN_INDIRECT_CONFIG.
 1.10 13-Oct-1996  christos backout previous kprintf change
 1.9 11-Oct-1996  christos printf -> kprintf, sprintf -> ksprintf
 1.8 16-Sep-1996  scottr Somehow the last change got mangled. Do over.
 1.7 16-Sep-1996  scottr - Add a ZS_CONSOLE_ABORT option to enable a serial console break to
force a drop to the system debugger. WARNING: this used to be the
default behavior! Modify custom kernel configs accordingly.
- Check for ZS_HWFLAG_CONABRT in zs_abort(), and don't abort if it's
not set.
 1.6 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.5 09-Jun-1996  briggs Add machine/viareg for prototype of via_set_modem().
 1.4 07-Jun-1996  briggs Changes from Bill Studenmund to support external clocks on the modem port.
 1.3 07-Jun-1996  briggs Patches from Bill Studenmund to get serial default settings from the booter.
 1.2 23-May-1996  briggs Change the console banner message.
 1.1 18-May-1996  briggs branches: 1.1.4;
Serial driver with interface to a slightly modified version of the machine-
independent z8530 driver. When that driver is updated, the local copy
of those files may be removed. From Bill Studenmund.
Compiler warnings fixed by me.
 1.1.4.4 09-Jun-1996  briggs Bring #include <machine/viareg.h> from trunk for via_set_modem() prototype.
 1.1.4.3 07-Jun-1996  briggs Pull up changes from trunk. Console fix and external serial clock support.
 1.1.4.2 07-Jun-1996  briggs Bring in last changes from -current. ADB fixes for MacTV and serial state
from the booter.
 1.1.4.1 01-Jun-1996  scottr Pull up version 1.2 from the main branch.
 1.13.4.1 23-Aug-1997  thorpej Update marc-pcmcia branch from trunk.
 1.15.2.3 17-Dec-1997  mellon Pull rev 1.18 up from trunk (scottr)
 1.15.2.2 09-Dec-1997  thorpej Sync w/ trunk: Make it work without DDB (scottr)
 1.15.2.1 04-Nov-1997  mellon Pull rev 1.16 up from trunk (mycroft)
 1.29.2.2 02-Nov-1999  scottr [Redo] Sync with main branch.
 1.29.2.1 16-May-1999  scottr Sync with main branch.
 1.31.12.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.31.10.1 15-Nov-1999  fvdl Sync with -current
 1.31.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.31.2.2 27-Jun-2000  he Pull up revision 1.33 (requested by wrstuden):
Correct a bug in handling of CLOCAL and MDMBUF flags.
 1.31.2.1 20-Nov-1999  he Pull up revision 1.32 (requested by wrstuden):
Allow rates higher than 57600, fixing PR#8070
 1.32.6.1 03-Jul-2000  thorpej Pull up rev. 1.33:
Fix logic bug which would keep PPS from working. Noticed by:

Charles Carvalho <carvalho@cisco.com>
 1.33.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.34.8.6 07-Jan-2003  thorpej Sync with HEAD.
 1.34.8.5 03-Jan-2003  thorpej Sync with HEAD.
 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 19-Jun-2001  nathanw file zs.c was added on branch nathanw_sa on 2002-04-01 07:40:49 +0000
 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 Replace the access to devsw table and the hard-coded majors with devsw API.
 1.42.2.6 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.42.2.5 17-Jan-2005  skrll Sync with HEAD.
 1.42.2.4 18-Dec-2004  skrll Sync with HEAD.
 1.42.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.42.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.42.2.1 03-Aug-2004  skrll Sync with HEAD
 1.47.2.2 16-Jan-2005  chs only match one instance (instead of an unlimited number).
simplify by not pretending that mac68k can have more than 1 zsc.
 1.47.2.1 16-Jan-2005  chs file zs.c was added on branch kent-audio2 on 2005-01-16 00:33:00 +0000
 1.48.2.5 07-Dec-2007  yamt sync with head
 1.48.2.4 15-Nov-2007  yamt sync with head.
 1.48.2.3 03-Sep-2007  yamt sync with head.
 1.48.2.2 30-Dec-2006  yamt sync with head.
 1.48.2.1 21-Jun-2006  yamt sync with head.
 1.49.12.1 31-Mar-2006  tron Merge 2006-03-31 NetBSD-current into the "peter-altq" branch.
 1.49.10.1 19-Apr-2006  elad sync with head - hopefully this will work
 1.49.8.1 01-Apr-2006  yamt 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.50.10.1 10-Dec-2006  yamt sync with head.
 1.50.8.1 12-Jan-2007  ad Sync with head.
 1.51.4.1 12-Mar-2007  rmind Sync with HEAD.
 1.53.26.2 08-Dec-2007  mjf Sync with HEAD.
 1.53.26.1 19-Nov-2007  mjf Sync with HEAD.
 1.53.24.1 13-Nov-2007  bouyer Sync with HEAD
 1.53.20.1 09-Jan-2008  matt sync with HEAD
 1.53.18.2 09-Dec-2007  jmcneill Sync with HEAD.
 1.53.18.1 11-Nov-2007  joerg Sync with HEAD.
 1.53.2.1 03-Dec-2007  ad Sync with HEAD.
 1.55.14.1 03-Apr-2008  mjf Sync with HEAD.
 1.56.18.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.56.12.1 28-Apr-2009  skrll Sync with HEAD.
 1.56.4.2 11-Mar-2010  yamt sync with head
 1.56.4.1 04-May-2009  yamt sync with head.
 1.58.78.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.59.8.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.4 11-Dec-2005  christos merge ktrace-lwp.
 1.3 16-Jan-2005  chs branches: 1.3.2;
only match one instance (instead of an unlimited number).
simplify by not pretending that mac68k can have more than 1 zsc.
 1.2 15-Jan-2005  chs de-__P, remove register, ansify, b* -> mem*.
 1.1 05-May-1998  scottr branches: 1.1.50;
Add the remaining kgdb pieces from sun3/hp300, with some mac68k-specific
adjustments to initialization.
 1.1.50.1 17-Jan-2005  skrll Sync with HEAD.
 1.3.2.2 16-Jan-2005  chs only match one instance (instead of an unlimited number).
simplify by not pretending that mac68k can have more than 1 zsc.
 1.3.2.1 16-Jan-2005  chs file zs_cons.h was added on branch kent-audio2 on 2005-01-16 00:33:00 +0000
 1.12 24-Oct-2023  andvar apply similar changes between different archs/machines for zs_kgdb.c:
1) adjust zs_kgdb_init tty attachment message for kgdb_dev type change.
(one arch uses cast to int instead, but kept one approach for consistency)
2) remove unused rr0 declaration and assignment in zs_kgdb_txint()
3) adjust kgdb_dev format specifier to %llx/d if needed.
4) add const for zs_kgdb_devname declaration (macppc only).
should fix zs_kgdb.c build for all these ports.
 1.11 28-Apr-2008  martin branches: 1.11.68; 1.11.78;
Remove clause 3 and 4 from TNF licenses
 1.10 17-Oct-2007  garbled branches: 1.10.16; 1.10.18; 1.10.20;
Merge the ppcoea-renovation branch to HEAD.

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

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

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.9 23-Jun-2007  hauke branches: 1.9.10;
Fix a warning from gcc 4 about stripping the volatile qualifier by a cast
by doing the proper __UNVOLATILE() dance.
 1.8 11-Dec-2005  christos branches: 1.8.30; 1.8.32; 1.8.38;
merge ktrace-lwp.
 1.7 16-Jan-2005  chs branches: 1.7.2; 1.7.10;
simplify by not pretending that mac68k can have more than 1 zsc.
 1.6 15-Jan-2005  chs de-__P, remove register, ansify, b* -> mem*.
 1.5 16-Jun-2004  briggs Make sure kernels with KGDB enabled will compile properly.
Apply patch from Hauke Fath in PR port-mac68k/25678.
 1.4 15-Jul-2003  lukem branches: 1.4.2;
__KERNEL_RCSID()
 1.3 06-Sep-2002  gehenna branches: 1.3.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.2 03-Feb-1999  mycroft branches: 1.2.24; 1.2.28; 1.2.36;
Don't set DCD_IE in the frontends. KGDB doesn't even use DCD, and the tty
frontends get it from zsparam() anyway.
 1.1 05-May-1998  scottr Add the remaining kgdb pieces from sun3/hp300, with some mac68k-specific
adjustments to initialization.
 1.2.36.1 19-May-2002  gehenna Replace the access to devsw table and the hard-coded majors with devsw API.
 1.2.28.1 17-Sep-2002  nathanw Catch up to -current.
 1.2.24.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.3.6.4 17-Jan-2005  skrll Sync with HEAD.
 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.2.1 17-Jun-2004  tron Pull up revision 1.5 (requested by briggs in ticket #500):
Make sure kernels with KGDB enabled will compile properly.
Apply patch from Hauke Fath in PR port-mac68k/25678.
 1.7.10.1 03-Sep-2007  yamt sync with head.
 1.7.2.2 16-Jan-2005  chs simplify by not pretending that mac68k can have more than 1 zsc.
 1.7.2.1 16-Jan-2005  chs file zs_kgdb.c was added on branch kent-audio2 on 2005-01-16 00:33:44 +0000
 1.8.38.1 26-Jun-2007  garbled Sync with HEAD.
 1.8.32.1 11-Jul-2007  mjf Sync with head.
 1.8.30.1 15-Jul-2007  ad Sync with head.
 1.9.10.1 06-Nov-2007  matt sync with HEAD
 1.10.20.1 16-May-2008  yamt sync with head.
 1.10.18.1 18-May-2008  yamt sync with head.
 1.10.16.1 02-Jun-2008  mjf Sync with HEAD.
 1.11.78.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.11.68.1 20-Jul-2016  pgoyette Adapt the machine/arch dependent code to the new {b,c}devsw reference
counting.

XXX Most of these will require testing by someone other than myself, as
I have a limited selection of hardware!
 1.3 20-Oct-1997  scottr Convert to MI 8530 SCC driver, from Bill Studenmund. The new front end
also supports DTR/CTS flow control.
 1.2 13-Dec-1995  briggs Double ring limits from Bill Studenmund <wrstuden@loki.stanford.edu>.
 1.1 09-Oct-1995  briggs Port of Sun3/Sparc zs driver from wrstuden@loki.stanford.edu
(Bill Studenmund). Should be massaged into machine independence
for 1.2.

RSS XML Feed