Home | History | Annotate | only in /src/sys/arch/m68k
History log of /src/sys/arch/m68k
RevisionDateAuthorComments
 1.1 12-Jun-1998  cgd Rework the way kernel include files are installed. In the new method,
as with user-land programs, include files are installed by each directory
in the tree that has includes to install. (This allows more flexibility
as to what gets installed, makes 'partial installs' easier, and gives us
more options as to which machines' includes get installed at any given
time.) The old SYS_INCLUDES={symlinks,copies} behaviours are _both_
still supported, though at least one bug in the 'symlinks' case is
fixed by this change. Include files can't be build before installation,
so directories that have includes as targets (e.g. dev/pci) have to move
those targets into a different Makefile.
 1.4 26-Jan-2022  andvar remove double t from targeted, add missing r to arbitrary
And fix few more typos along the way in comments and man pages.
 1.3 15-Dec-2020  martin Make comments are not C comments - use # instead of /* ... */
 1.2 12-Jul-2010  mrg branches: 1.2.72;
look for the m680[2346]0 options in the opt_m68k_arch.h and set them
appropriately in the kernel config, if not already set.

restores the settings before the M680x0 options became _KERNEL_OPT
options. tested by myself and mhitch.
 1.1 25-Jan-2009  abs branches: 1.1.4; 1.1.6; 1.1.8; 1.1.10;
Abstract out setting of '-m680X0' based on -DM68020, -DM68030,
-DM68040, and -DM68060 into sys/arch/m68k/Makefile.cmachflags and
include from both atari and amiga. Other m68k ports which build
kernels that support multiple CPU types can also switch across to
this.
 1.1.10.1 05-Mar-2011  rmind sync with head
 1.1.8.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.1.6.3 11-Aug-2010  yamt sync with head.
 1.1.6.2 04-May-2009  yamt sync with head.
 1.1.6.1 25-Jan-2009  yamt file Makefile.cmachflags was added on branch yamt-nfs-mp on 2009-05-04 08:11:25 +0000
 1.1.4.2 03-Mar-2009  skrll Sync with HEAD.
 1.1.4.1 25-Jan-2009  skrll file Makefile.cmachflags was added on branch nick-hppapmap on 2009-03-03 18:29:01 +0000
 1.2.72.1 03-Jan-2021  thorpej Sync w/ HEAD.
 1.3 25-Feb-2007  dyoung Make the mac68k 'tags' target work.
 1.2 15-Nov-1998  perry branches: 1.2.60; 1.2.98;
(mostly) fix kernel tags support. from Frederick Bruckman in pr-6445.
 1.1 11-Oct-1997  mycroft branches: 1.1.2;
Common stuff, like mips/Makefile.inc.
 1.1.2.2 14-Oct-1997  thorpej Update marc-pcmcia branch from trunk.
 1.1.2.1 11-Oct-1997  thorpej file Makefile.inc was added on branch marc-pcmcia on 1997-10-14 10:16:33 +0000
 1.2.98.1 27-Feb-2007  yamt - sync with head.
- move sched_changepri back to kern_synch.c as it doesn't know PPQ anymore.
 1.2.60.1 26-Feb-2007  yamt sync with head.
 1.11 10-Jan-2014  christos make it clean after itself, use standard rules files
 1.10 28-Mar-2008  apb branches: 1.10.38; 1.10.48; 1.10.54;
Adapt to changes in m68k/060sp/asm2gas script: pass SED=${TOOL_SED:Q}
instead of TOOL_SED=${TOOL_SED:Q} in the environment.
 1.9 27-Mar-2008  apb Use "${TOOL_SED}" instead of just "sed" in sys/arch/m68k/060sp/asm2gas.
 1.8 11-Dec-2005  christos branches: 1.8.74;
merge ktrace-lwp.
 1.7 26-Oct-2003  lukem Use ${HOST_SH} instead of `sh'.

If necessary, pull in <bsd.sys.mk> to get the definition of HOST_SH;
Makefiles that pull in one of (most of) <bsd.*.mk> will get this anyway.
 1.6 14-Apr-2000  is branches: 1.6.28;
Move original Motorola files to the "dist" subdirectory, in response
to PR 9626 by Kris Shannon.
 1.5 22-Feb-1999  is branches: 1.5.8;
Generate the MIT-assembler-format files statically. They nearly never change,
and if so, should be generated via the new Makefile and committed, too.
 1.4 28-Sep-1997  is Build the 68060 support package in the kernel build dir.
XXX PCB_ONFAULT is still hardwired to 64 in netbsd060sp.S.
 1.3 31-Dec-1996  veego branches: 1.3.10;
Add '-I${.CURDIR} ${.CURDIR}/' before netbsd.S to compile it with
object dirs.
 1.2 20-May-1996  is Now that our as pretends to understand the M68060 cpu, use -m68060 instead
of -m68040 to avoid confusion.
 1.1 15-May-1996  is Initial commit of the machine independend part of the glue code for
the 68060 software support package.
 1.3.10.1 14-Oct-1997  thorpej Update marc-pcmcia branch from trunk.
 1.5.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.6.28.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.6.28.2 18-Sep-2004  skrll Sync with HEAD.
 1.6.28.1 03-Aug-2004  skrll Sync with HEAD
 1.8.74.1 03-Apr-2008  mjf Sync with HEAD.
 1.10.54.1 18-May-2014  rmind sync with head
 1.10.48.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.10.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.6 30-Nov-2000  scw Prepare for the m68k ELF transition:
o Add register prefixes for the benefit of gas.new
o Wrap global symbols in the m68k/asm.h macros
o Fix `#' comments so the source can be run through the C pre-processor
 1.5 22-Feb-1999  is branches: 1.5.8; 1.5.18;
Generate the MIT-assembler-format files statically. They nearly never change,
and if so, should be generated via the new Makefile and committed, too.
 1.4 09-Oct-1997  is Help crosscompiling, by as -> $(AS). Define AS?= as in the calling
Makefile.$(ARCH)es. Will hopefully fix the (remaining) part or pr4010.
 1.3 28-Sep-1997  is Build the 68060 support package in the kernel build dir.
XXX PCB_ONFAULT is still hardwired to 64 in netbsd060sp.S.
 1.2 07-May-1997  mycroft branches: 1.2.4;
Add .MAKE to the .OBJDIR hacks, so they work with `make -n'.
 1.1 15-May-1996  is Initial commit of the machine independend part of the glue code for
the 68060 software support package.
 1.2.4.1 14-Oct-1997  thorpej Update marc-pcmcia branch from trunk.
 1.5.18.1 01-May-2001  he Pull up revision 1.6 (requested by tron):
Pass assembler files through $(CC) instead of $(AS).
Fixes build problem.
 1.5.8.1 08-Dec-2000  bouyer Sync with HEAD.
 1.7 28-May-2022  andvar fix various typos, mainly in comments.
 1.6 03-May-2008  martin Move to 2 clause TNF license
 1.5 14-Apr-2000  is branches: 1.5.130; 1.5.132; 1.5.134;
Move original Motorola files to the "dist" subdirectory, in response
to PR 9626 by Kris Shannon.
 1.4 22-Feb-1999  is branches: 1.4.8;
Update.
 1.3 16-Feb-1999  is Fix Copyright dates
 1.2 16-Feb-1999  is Assign my files to The NetBSD Foundation, Inc.
 1.1 15-May-1996  is Initial commit of the machine independend part of the glue code for
the 68060 software support package.
 1.4.8.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.5.134.1 16-May-2008  yamt sync with head.
 1.5.132.1 18-May-2008  yamt sync with head.
 1.5.130.1 02-Jun-2008  mjf Sync with HEAD.
 1.9 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.8 28-Mar-2008  apb branches: 1.8.2; 1.8.4;
Synchronise the two asm2gas scripts in sys/arch/m68k/060sp and
sys/arch/m68k/fpsp:

* The fpsp/asm2gas sed script previously hardcoded the fact that
registers needed a '%' prefix, and the 060sp/asm2gas sed scrip
previously did not have rules related to inserting '%' before register
names. Now, both scripts have the same rules, but the rules are
parapeterised to use "$P", which is set to '' or '%' as appropriate.

* Some other minor changes to the sed scripts.

The new asm2gas scripts have been verified to produce identical output
to the old asm2gas scripts, for all inputs in 060sp/dist/*.sa and
fpsp/*.sa, except for some differences inside comments.

Thanks to Izumi Tsutsui for suggesting that these scripts should be
synchronised.
 1.7 27-Mar-2008  apb Use "${TOOL_SED}" instead of just "sed" in sys/arch/m68k/060sp/asm2gas.
 1.6 15-Aug-1998  mycroft branches: 1.6.148;
Assign copyrights to TNF.
 1.5 15-Aug-1998  mycroft Make copyright notices with my name consistent.
 1.4 30-Sep-1997  is - only convert real hex constants to 0x form, not $NetBSD...
- protect comment lines from future uses of CPP by putting a | in front
 1.3 26-Oct-1994  cgd branches: 1.3.12;
new RCS ID format.
 1.2 07-Jul-1994  mycroft Simplify, speed it up, and do the right thing for floating point constants.
 1.1 05-Jul-1994  mycroft Port to NetBSD, with some bug fixes and minor performance tweaks.
 1.3.12.1 14-Oct-1997  thorpej Update marc-pcmcia branch from trunk.
 1.6.148.2 02-Jun-2008  mjf Sync with HEAD.
 1.6.148.1 03-Apr-2008  mjf Sync with HEAD.
 1.8.4.1 16-May-2008  yamt sync with head.
 1.8.2.1 18-May-2008  yamt sync with head.
 1.3 14-Apr-2000  is Move original Motorola files to the "dist" subdirectory, in response
to PR 9626 by Kris Shannon.
 1.2 15-May-1996  is branches: 1.2.30;
RCS ID police
 1.1 15-May-1996  is branches: 1.1.1;
Initial revision
 1.1.1.1 15-May-1996  is Initial import of the Motorola M68060 Software Package Production
Release, revision P1.01.
 1.2.30.1 20-Nov-2000  bouyer Remove files that are no longer on the trunck
 1.3 30-Nov-2000  scw Prepare for the m68k ELF transition:
o Add register prefixes for the benefit of gas.new
o Wrap global symbols in the m68k/asm.h macros
o Fix `#' comments so the source can be run through the C pre-processor
 1.2 16-May-1996  is branches: 1.2.30; 1.2.40;
Naive translation of text to assembler had caused some assembler syntax
errors. Fixed them. Thanks to Bernd Ernesti for the early report.
 1.1 15-May-1996  is Initial commit of the machine independend part of the glue code for
the 68060 software support package.
 1.2.40.1 24-Apr-2001  he Pull up revision 1.3 (requested by is):
Make these files successfully pass through the C preprocessor,
among other things.
 1.2.30.1 08-Dec-2000  bouyer Sync with HEAD.
 1.3 14-Apr-2000  is Move original Motorola files to the "dist" subdirectory, in response
to PR 9626 by Kris Shannon.
 1.2 15-May-1996  is branches: 1.2.30;
RCS ID police
 1.1 15-May-1996  is branches: 1.1.1;
Initial revision
 1.1.1.1 15-May-1996  is Initial import of the Motorola M68060 Software Package Production
Release, revision P1.01.
 1.2.30.1 20-Nov-2000  bouyer Remove files that are no longer on the trunck
 1.1 28-Sep-1997  is branches: 1.1.2;
Build the 68060 support package in the kernel build dir.
XXX PCB_ONFAULT is still hardwired to 64 in netbsd060sp.S.
 1.1.2.2 14-Oct-1997  thorpej Update marc-pcmcia branch from trunk.
 1.1.2.1 28-Sep-1997  thorpej file files.060sp was added on branch marc-pcmcia on 1997-10-14 10:16:37 +0000
 1.5 30-Nov-2000  scw Prepare for the m68k ELF transition:
o Add register prefixes for the benefit of gas.new
o Wrap global symbols in the m68k/asm.h macros
o Fix `#' comments so the source can be run through the C pre-processor
 1.4 22-Feb-1999  is branches: 1.4.8; 1.4.18;
Generate the MIT-assembler-format files statically. They nearly never change,
and if so, should be generated via the new Makefile and committed, too.
 1.3 28-Jul-1997  is Align some comments, so that I'll be able to track changes better.
 1.2 15-May-1996  is fix typo
 1.1 15-May-1996  is Initial commit of the machine independend part of the glue code for
the 68060 software support package.
 1.4.18.1 24-Apr-2001  he Pull up revision 1.5 (requested by is):
Make these files successfully pass through the C preprocessor,
among other things.
 1.4.8.1 08-Dec-2000  bouyer Sync with HEAD.
 1.3 14-Apr-2000  is Move original Motorola files to the "dist" subdirectory, in response
to PR 9626 by Kris Shannon.
 1.2 15-May-1996  is branches: 1.2.30;
RCS ID police
 1.1 15-May-1996  is branches: 1.1.1;
Initial revision
 1.1.1.1 15-May-1996  is Initial import of the Motorola M68060 Software Package Production
Release, revision P1.01.
 1.2.30.1 20-Nov-2000  bouyer Remove files that are no longer on the trunck
 1.4 14-Apr-2000  is Move original Motorola files to the "dist" subdirectory, in response
to PR 9626 by Kris Shannon.
 1.3 13-Mar-2000  soren Fix doubled 'the's in comments.
 1.2 15-May-1996  is branches: 1.2.30;
RCS ID police
 1.1 15-May-1996  is branches: 1.1.1;
Initial revision
 1.1.1.1 15-May-1996  is Initial import of the Motorola M68060 Software Package Production
Release, revision P1.01.
 1.2.30.1 20-Nov-2000  bouyer Remove files that are no longer on the trunck
 1.3 14-Apr-2000  is Move original Motorola files to the "dist" subdirectory, in response
to PR 9626 by Kris Shannon.
 1.2 15-May-1996  is branches: 1.2.30;
RCS ID police
 1.1 15-May-1996  is branches: 1.1.1;
Initial revision
 1.1.1.1 15-May-1996  is Initial import of the Motorola M68060 Software Package Production
Release, revision P1.01.
 1.2.30.1 20-Nov-2000  bouyer Remove files that are no longer on the trunck
 1.1 22-Feb-1999  is Generate the MIT-assembler-format files statically. They nearly never change,
and if so, should be generated via the new Makefile and committed, too.
 1.3 14-Apr-2000  is Move original Motorola files to the "dist" subdirectory, in response
to PR 9626 by Kris Shannon.
 1.2 15-May-1996  is branches: 1.2.30;
RCS ID police
 1.1 15-May-1996  is branches: 1.1.1;
Initial revision
 1.1.1.1 15-May-1996  is Initial import of the Motorola M68060 Software Package Production
Release, revision P1.01.
 1.2.30.1 20-Nov-2000  bouyer Remove files that are no longer on the trunck
 1.4 14-Apr-2000  is Move original Motorola files to the "dist" subdirectory, in response
to PR 9626 by Kris Shannon.
 1.3 13-Mar-2000  soren Fix doubled 'the's in comments.
 1.2 15-May-1996  is branches: 1.2.30;
RCS ID police
 1.1 15-May-1996  is branches: 1.1.1;
Initial revision
 1.1.1.1 15-May-1996  is Initial import of the Motorola M68060 Software Package Production
Release, revision P1.01.
 1.2.30.1 20-Nov-2000  bouyer Remove files that are no longer on the trunck
 1.3 14-Apr-2000  is Move original Motorola files to the "dist" subdirectory, in response
to PR 9626 by Kris Shannon.
 1.2 15-May-1996  is branches: 1.2.30;
RCS ID police
 1.1 15-May-1996  is branches: 1.1.1;
Initial revision
 1.1.1.1 15-May-1996  is Initial import of the Motorola M68060 Software Package Production
Release, revision P1.01.
 1.2.30.1 20-Nov-2000  bouyer Remove files that are no longer on the trunck
 1.3 14-Apr-2000  is Move original Motorola files to the "dist" subdirectory, in response
to PR 9626 by Kris Shannon.
 1.2 15-May-1996  is branches: 1.2.30;
RCS ID police
 1.1 15-May-1996  is branches: 1.1.1;
Initial revision
 1.1.1.1 15-May-1996  is Initial import of the Motorola M68060 Software Package Production
Release, revision P1.01.
 1.2.30.1 20-Nov-2000  bouyer Remove files that are no longer on the trunck
 1.3 14-Apr-2000  is Move original Motorola files to the "dist" subdirectory, in response
to PR 9626 by Kris Shannon.
 1.2 15-May-1996  is branches: 1.2.30;
RCS ID police
 1.1 15-May-1996  is branches: 1.1.1;
Initial revision
 1.1.1.1 15-May-1996  is Initial import of the Motorola M68060 Software Package Production
Release, revision P1.01.
 1.2.30.1 20-Nov-2000  bouyer Remove files that are no longer on the trunck
 1.3 14-Apr-2000  is Move original Motorola files to the "dist" subdirectory, in response
to PR 9626 by Kris Shannon.
 1.2 15-May-1996  is branches: 1.2.30;
RCS ID police
 1.1 15-May-1996  is branches: 1.1.1;
Initial revision
 1.1.1.1 15-May-1996  is Initial import of the Motorola M68060 Software Package Production
Release, revision P1.01.
 1.2.30.1 20-Nov-2000  bouyer Remove files that are no longer on the trunck
 1.3 14-Apr-2000  is Move original Motorola files to the "dist" subdirectory, in response
to PR 9626 by Kris Shannon.
 1.2 15-May-1996  is branches: 1.2.30;
RCS ID police
 1.1 15-May-1996  is branches: 1.1.1;
Initial revision
 1.1.1.1 15-May-1996  is Initial import of the Motorola M68060 Software Package Production
Release, revision P1.01.
 1.2.30.1 20-Nov-2000  bouyer Remove files that are no longer on the trunck
 1.3 14-Apr-2000  is Move original Motorola files to the "dist" subdirectory, in response
to PR 9626 by Kris Shannon.
 1.2 15-May-1996  is branches: 1.2.30;
RCS ID police
 1.1 15-May-1996  is branches: 1.1.1;
Initial revision
 1.1.1.1 15-May-1996  is Initial import of the Motorola M68060 Software Package Production
Release, revision P1.01.
 1.2.30.1 20-Nov-2000  bouyer Remove files that are no longer on the trunck
 1.3 14-Apr-2000  is Move original Motorola files to the "dist" subdirectory, in response
to PR 9626 by Kris Shannon.
 1.2 15-May-1996  is branches: 1.2.30;
RCS ID police
 1.1 15-May-1996  is branches: 1.1.1;
Initial revision
 1.1.1.1 15-May-1996  is Initial import of the Motorola M68060 Software Package Production
Release, revision P1.01.
 1.2.30.1 20-Nov-2000  bouyer Remove files that are no longer on the trunck
 1.5 13-May-2024  msaitoh s/Instrcution/Instruction/ in comment.
 1.4 30-Nov-2000  scw Prepare for the m68k ELF transition:
o Add register prefixes for the benefit of gas.new
o Wrap global symbols in the m68k/asm.h macros
o Fix `#' comments so the source can be run through the C pre-processor
 1.3 28-Jul-1997  is branches: 1.3.20; 1.3.30;
Align some comments, so that I'll be able to track changes better.
 1.2 15-May-1996  is fix typo
 1.1 15-May-1996  is Initial commit of the machine independend part of the glue code for
the 68060 software support package.
 1.3.30.1 24-Apr-2001  he Pull up revision 1.4 (requested by is):
Make these files successfully pass through the C preprocessor,
among other things.
 1.3.20.1 08-Dec-2000  bouyer Sync with HEAD.
 1.3 14-Apr-2000  is Move original Motorola files to the "dist" subdirectory, in response
to PR 9626 by Kris Shannon.
 1.2 15-May-1996  is branches: 1.2.30;
RCS ID police
 1.1 15-May-1996  is branches: 1.1.1;
Initial revision
 1.1.1.1 15-May-1996  is Initial import of the Motorola M68060 Software Package Production
Release, revision P1.01.
 1.2.30.1 20-Nov-2000  bouyer Remove files that are no longer on the trunck
 1.1 22-Feb-1999  is Generate the MIT-assembler-format files statically. They nearly never change,
and if so, should be generated via the new Makefile and committed, too.
 1.3 14-Apr-2000  is Move original Motorola files to the "dist" subdirectory, in response
to PR 9626 by Kris Shannon.
 1.2 15-May-1996  is branches: 1.2.30;
RCS ID police
 1.1 15-May-1996  is branches: 1.1.1;
Initial revision
 1.1.1.1 15-May-1996  is Initial import of the Motorola M68060 Software Package Production
Release, revision P1.01.
 1.2.30.1 20-Nov-2000  bouyer Remove files that are no longer on the trunck
 1.4 14-Apr-2000  is Move original Motorola files to the "dist" subdirectory, in response
to PR 9626 by Kris Shannon.
 1.3 13-Mar-2000  soren Fix doubled 'the's in comments.
 1.2 15-May-1996  is branches: 1.2.30;
RCS ID police
 1.1 15-May-1996  is branches: 1.1.1;
Initial revision
 1.1.1.1 15-May-1996  is Initial import of the Motorola M68060 Software Package Production
Release, revision P1.01.
 1.2.30.1 20-Nov-2000  bouyer Remove files that are no longer on the trunck
 1.3 14-Apr-2000  is Move original Motorola files to the "dist" subdirectory, in response
to PR 9626 by Kris Shannon.
 1.2 15-May-1996  is branches: 1.2.30;
RCS ID police
 1.1 15-May-1996  is branches: 1.1.1;
Initial revision
 1.1.1.1 15-May-1996  is Initial import of the Motorola M68060 Software Package Production
Release, revision P1.01.
 1.2.30.1 20-Nov-2000  bouyer Remove files that are no longer on the trunck
 1.3 14-Apr-2000  is Move original Motorola files to the "dist" subdirectory, in response
to PR 9626 by Kris Shannon.
 1.2 15-May-1996  is branches: 1.2.30;
RCS ID police
 1.1 15-May-1996  is branches: 1.1.1;
Initial revision
 1.1.1.1 15-May-1996  is Initial import of the Motorola M68060 Software Package Production
Release, revision P1.01.
 1.2.30.1 20-Nov-2000  bouyer Remove files that are no longer on the trunck
 1.3 14-Apr-2000  is Move original Motorola files to the "dist" subdirectory, in response
to PR 9626 by Kris Shannon.
 1.2 05-Jan-1998  perry branches: 1.2.14;
RCSID Police.
 1.1 15-May-1996  is branches: 1.1.1;
Initial revision
 1.1.1.1 15-May-1996  is Initial import of the Motorola M68060 Software Package Production
Release, revision P1.01.
 1.2.14.1 20-Nov-2000  bouyer Remove files that are no longer on the trunck
 1.3 14-Apr-2000  is Move original Motorola files to the "dist" subdirectory, in response
to PR 9626 by Kris Shannon.
 1.2 15-May-1996  is branches: 1.2.30;
RCS ID police
 1.1 15-May-1996  is branches: 1.1.1;
Initial revision
 1.1.1.1 15-May-1996  is Initial import of the Motorola M68060 Software Package Production
Release, revision P1.01.
 1.2.30.1 20-Nov-2000  bouyer Remove files that are no longer on the trunck
 1.5 29-Sep-1997  is Forgot to remove this yesterday... this was renamed to netbsd060sp.S.
 1.4 28-Sep-1997  is In the OS glue code for the 060SP, replace the copyin()/copyout() glue by
movs.
XXX As our CPP seems to hate the 060SP, I couldn't use assym.h for the
PCB_ONFAULT definition, but had to hardwire 64 in the code. This needs
to be fixed ASAP, and will be done in the upcoming reorganization of
the 060sp Makefiles.
 1.3 27-Jun-1997  is branches: 1.3.4;
Add support for T-racing of emulated instructions. (Yes, gdb uses this.)
 1.2 26-Jun-1997  is The recent buserr handler cleanup in the Amiga locore.s made the label
_buserr point to the 68020/030 buserr code _only_. This has broken access
error handling in the 060 support code.
This is repaired by jumping to _buserr60 from the 060SP, and by providing
a _buserr60 label identical to the _buserr in the unchanged m68k ports
using the 68060.
 1.1 15-May-1996  is Initial commit of the machine independend part of the glue code for
the 68060 software support package.
 1.3.4.1 14-Oct-1997  thorpej Update marc-pcmcia branch from trunk.
 1.8 08-Sep-2024  rillig fix a/an grammar in obvious cases
 1.7 12-Jul-2001  scw branches: 1.7.6; 1.7.248;
Use PCB_ONFAULT instead of hardcoding a value of 64. This is fine
for Amiga and Atari but not for other m68k ports which use m68k/pcb.h.
 1.6 30-Nov-2000  scw branches: 1.6.4;
Prepare for the m68k ELF transition:
o Add register prefixes for the benefit of gas.new
o Wrap global symbols in the m68k/asm.h macros
o Fix `#' comments so the source can be run through the C pre-processor
 1.5 30-Jan-1999  is branches: 1.5.8; 1.5.18;
Remove redundant code (leftover from editing).
 1.4 28-Sep-1997  is branches: 1.4.2;
In the OS glue code for the 060SP, replace the copyin()/copyout() glue by
movs.
XXX As our CPP seems to hate the 060SP, I couldn't use assym.h for the
PCB_ONFAULT definition, but had to hardwire 64 in the code. This needs
to be fixed ASAP, and will be done in the upcoming reorganization of
the 060sp Makefiles.
 1.3 27-Jun-1997  is Add support for T-racing of emulated instructions. (Yes, gdb uses this.)
 1.2 26-Jun-1997  is The recent buserr handler cleanup in the Amiga locore.s made the label
_buserr point to the 68020/030 buserr code _only_. This has broken access
error handling in the 060 support code.
This is repaired by jumping to _buserr60 from the 060SP, and by providing
a _buserr60 label identical to the _buserr in the unchanged m68k ports
using the 68060.
 1.1 15-May-1996  is Initial commit of the machine independend part of the glue code for
the 68060 software support package.
 1.4.2.2 14-Oct-1997  thorpej Update marc-pcmcia branch from trunk.
 1.4.2.1 28-Sep-1997  thorpej file netbsd060sp.S was added on branch marc-pcmcia on 1997-10-14 10:16:39 +0000
 1.5.18.1 24-Apr-2001  he Pull up revision 1.6 (requested by is):
Make these files successfully pass through the C preprocessor,
among other things.
 1.5.8.1 08-Dec-2000  bouyer Sync with HEAD.
 1.6.4.1 03-Aug-2001  lukem update to -current
 1.7.248.1 02-Aug-2025  perseant Sync with HEAD
 1.7.6.2 12-Jul-2001  scw Use PCB_ONFAULT instead of hardcoding a value of 64. This is fine
for Amiga and Atari but not for other m68k ports which use m68k/pcb.h.
 1.7.6.1 12-Jul-2001  scw file netbsd060sp.S was added on branch nathanw_sa on 2001-07-12 17:17:46 +0000
 1.3 14-Apr-2000  is Move original Motorola files to the "dist" subdirectory, in response
to PR 9626 by Kris Shannon.
 1.2 15-May-1996  is branches: 1.2.30;
RCS ID police
 1.1 15-May-1996  is branches: 1.1.1;
Initial revision
 1.1.1.1 15-May-1996  is Initial import of the Motorola M68060 Software Package Production
Release, revision P1.01.
 1.2.30.1 20-Nov-2000  bouyer Remove files that are no longer on the trunck
 1.1 22-Feb-1999  is Generate the MIT-assembler-format files statically. They nearly never change,
and if so, should be generated via the new Makefile and committed, too.
 1.4 14-Apr-2000  is Move original Motorola files to the "dist" subdirectory, in response
to PR 9626 by Kris Shannon.
 1.3 13-Mar-2000  soren Fix doubled 'the's in comments.
 1.2 15-May-1996  is branches: 1.2.30;
RCS ID police
 1.1 15-May-1996  is branches: 1.1.1;
Initial revision
 1.1.1.1 15-May-1996  is Initial import of the Motorola M68060 Software Package Production
Release, revision P1.01.
 1.2.30.1 20-Nov-2000  bouyer Remove files that are no longer on the trunck
 1.3 14-Apr-2000  is Move original Motorola files to the "dist" subdirectory, in response
to PR 9626 by Kris Shannon.
 1.2 15-May-1996  is branches: 1.2.30;
RCS ID police
 1.1 15-May-1996  is branches: 1.1.1;
Initial revision
 1.1.1.1 15-May-1996  is Initial import of the Motorola M68060 Software Package Production
Release, revision P1.01.
 1.2.30.1 20-Nov-2000  bouyer Remove files that are no longer on the trunck
 1.3 14-Apr-2000  is Move original Motorola files to the "dist" subdirectory, in response
to PR 9626 by Kris Shannon.
 1.2 15-May-1996  is branches: 1.2.30;
RCS ID police
 1.1 15-May-1996  is branches: 1.1.1;
Initial revision
 1.1.1.1 15-May-1996  is Initial import of the Motorola M68060 Software Package Production
Release, revision P1.01.
 1.2.30.1 20-Nov-2000  bouyer Remove files that are no longer on the trunck
 1.3 14-Apr-2000  is Move original Motorola files to the "dist" subdirectory, in response
to PR 9626 by Kris Shannon.
 1.2 15-May-1996  is branches: 1.2.30;
RCS ID police
 1.1 15-May-1996  is branches: 1.1.1;
Initial revision
 1.1.1.1 15-May-1996  is Initial import of the Motorola M68060 Software Package Production
Release, revision P1.01.
 1.2.30.1 20-Nov-2000  bouyer Remove files that are no longer on the trunck
 1.1 14-Apr-2000  is branches: 1.1.6;
Move original Motorola files to the "dist" subdirectory, in response
to PR 9626 by Kris Shannon.
 1.1.6.2 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.1.6.1 14-Apr-2000  bouyer file changes was added on branch thorpej_scsipi on 2000-11-20 20:11:27 +0000
 1.1 14-Apr-2000  is branches: 1.1.6;
Move original Motorola files to the "dist" subdirectory, in response
to PR 9626 by Kris Shannon.
 1.1.6.2 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.1.6.1 14-Apr-2000  bouyer file errata was added on branch thorpej_scsipi on 2000-11-20 20:11:27 +0000
 1.1 14-Apr-2000  is branches: 1.1.6;
Move original Motorola files to the "dist" subdirectory, in response
to PR 9626 by Kris Shannon.
 1.1.6.2 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.1.6.1 14-Apr-2000  bouyer file fplsp.doc was added on branch thorpej_scsipi on 2000-11-20 20:11:27 +0000
 1.3 05-Dec-2021  msaitoh s/MEMEORY/MEMORY/ in comment.
 1.2 05-Feb-2003  perry "Utilize" has exactly the same meaning as "use," but it is more
difficult to read and understand. Most manuals of English style
therefore say that you should use "use".
 1.1 14-Apr-2000  is branches: 1.1.6;
Move original Motorola files to the "dist" subdirectory, in response
to PR 9626 by Kris Shannon.
 1.1.6.2 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.1.6.1 14-Apr-2000  bouyer file fplsp.s was added on branch thorpej_scsipi on 2000-11-20 20:11:28 +0000
 1.1 14-Apr-2000  is branches: 1.1.6;
Move original Motorola files to the "dist" subdirectory, in response
to PR 9626 by Kris Shannon.
 1.1.6.2 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.1.6.1 14-Apr-2000  bouyer file fplsp.sa was added on branch thorpej_scsipi on 2000-11-20 20:11:29 +0000
 1.2 29-Apr-2007  msaitoh fix typos
 1.1 14-Apr-2000  is branches: 1.1.6; 1.1.46; 1.1.84; 1.1.88; 1.1.90;
Move original Motorola files to the "dist" subdirectory, in response
to PR 9626 by Kris Shannon.
 1.1.90.1 11-Jul-2007  mjf Sync with head.
 1.1.88.1 27-May-2007  ad Sync with head.
 1.1.84.1 07-May-2007  yamt sync with head.
 1.1.46.1 03-Sep-2007  yamt sync with head.
 1.1.6.2 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.1.6.1 14-Apr-2000  bouyer file fpsp.doc was added on branch thorpej_scsipi on 2000-11-20 20:11:29 +0000
 1.7 24-Jun-2023  msaitoh Fix typo in comment.
 1.6 10-Nov-2021  msaitoh s/threshhold/threshold/ in comment.
 1.5 11-Dec-2005  christos merge ktrace-lwp.
 1.4 24-Feb-2004  wiz becuase -> because. From Peter Postma.
 1.3 05-Feb-2003  perry branches: 1.3.2;
"Utilize" has exactly the same meaning as "use," but it is more
difficult to read and understand. Most manuals of English style
therefore say that you should use "use".
 1.2 16-Sep-2001  wiz branches: 1.2.4;
Spell 'occurred' with two 'r's.
 1.1 14-Apr-2000  is branches: 1.1.6; 1.1.8; 1.1.10;
Move original Motorola files to the "dist" subdirectory, in response
to PR 9626 by Kris Shannon.
 1.1.10.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.1.8.1 01-Oct-2001  fvdl Catch up with -current.
 1.1.6.2 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.1.6.1 14-Apr-2000  bouyer file fpsp.s was added on branch thorpej_scsipi on 2000-11-20 20:11:29 +0000
 1.2.4.2 16-Sep-2001  wiz Spell 'occurred' with two 'r's.
 1.2.4.1 16-Sep-2001  wiz file fpsp.s was added on branch nathanw_sa on 2001-09-16 16:34:31 +0000
 1.3.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.3.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.3.2.1 03-Aug-2004  skrll Sync with HEAD
 1.1 14-Apr-2000  is branches: 1.1.6;
Move original Motorola files to the "dist" subdirectory, in response
to PR 9626 by Kris Shannon.
 1.1.6.2 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.1.6.1 14-Apr-2000  bouyer file fpsp.sa was added on branch thorpej_scsipi on 2000-11-20 20:11:31 +0000
 1.1 14-Apr-2000  is branches: 1.1.6;
Move original Motorola files to the "dist" subdirectory, in response
to PR 9626 by Kris Shannon.
 1.1.6.2 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.1.6.1 14-Apr-2000  bouyer file fskeletn.s was added on branch thorpej_scsipi on 2000-11-20 20:11:31 +0000
 1.1 14-Apr-2000  is branches: 1.1.6;
Move original Motorola files to the "dist" subdirectory, in response
to PR 9626 by Kris Shannon.
 1.1.6.2 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.1.6.1 14-Apr-2000  bouyer file ftest.s was added on branch thorpej_scsipi on 2000-11-20 20:11:32 +0000
 1.1 14-Apr-2000  is branches: 1.1.6;
Move original Motorola files to the "dist" subdirectory, in response
to PR 9626 by Kris Shannon.
 1.1.6.2 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.1.6.1 14-Apr-2000  bouyer file ftest.sa was added on branch thorpej_scsipi on 2000-11-20 20:11:32 +0000
 1.1 14-Apr-2000  is branches: 1.1.6;
Move original Motorola files to the "dist" subdirectory, in response
to PR 9626 by Kris Shannon.
 1.1.6.2 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.1.6.1 14-Apr-2000  bouyer file ilsp.doc was added on branch thorpej_scsipi on 2000-11-20 20:11:32 +0000
 1.3 28-May-2022  andvar fix various typos in comments, mainly origional->original,
extened->extended, incomming->incoming.
 1.2 11-Jul-2015  kamil Improve spelling: regsiter -> register

This change is non-functional.

Approved by <riastradh>, <pgoyette>
 1.1 14-Apr-2000  is branches: 1.1.6; 1.1.180; 1.1.200;
Move original Motorola files to the "dist" subdirectory, in response
to PR 9626 by Kris Shannon.
 1.1.200.1 22-Sep-2015  skrll Sync with HEAD
 1.1.180.1 03-Dec-2017  jdolecek update from HEAD
 1.1.6.2 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.1.6.1 14-Apr-2000  bouyer file ilsp.s was added on branch thorpej_scsipi on 2000-11-20 20:11:32 +0000
 1.1 14-Apr-2000  is branches: 1.1.6;
Move original Motorola files to the "dist" subdirectory, in response
to PR 9626 by Kris Shannon.
 1.1.6.2 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.1.6.1 14-Apr-2000  bouyer file ilsp.sa was added on branch thorpej_scsipi on 2000-11-20 20:11:33 +0000
 1.2 13-May-2024  msaitoh s/Instrcution/Instruction/ in comment.
 1.1 14-Apr-2000  is branches: 1.1.6;
Move original Motorola files to the "dist" subdirectory, in response
to PR 9626 by Kris Shannon.
 1.1.6.2 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.1.6.1 14-Apr-2000  bouyer file iskeletn.s was added on branch thorpej_scsipi on 2000-11-20 20:11:33 +0000
 1.1 14-Apr-2000  is branches: 1.1.6;
Move original Motorola files to the "dist" subdirectory, in response
to PR 9626 by Kris Shannon.
 1.1.6.2 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.1.6.1 14-Apr-2000  bouyer file isp.doc was added on branch thorpej_scsipi on 2000-11-20 20:11:33 +0000
 1.5 02-Aug-2021  andvar fix various typos in comments and log messages.
 1.4 24-Jul-2021  andvar Fix all remaining typos, mainly in comments but also in few definitions and log messages, reported by me in PR kern/54889.
Also fixed some additional typos in comments, found on review of same files or typos.
 1.3 11-Jul-2015  kamil branches: 1.3.34;
Improve spelling: regsiter -> register

This change is non-functional.

Approved by <riastradh>, <pgoyette>
 1.2 11-Jun-2001  wiz branches: 1.2.8; 1.2.174; 1.2.194;
Fix various misspellings of compatible/compatibility.
 1.1 14-Apr-2000  is branches: 1.1.6; 1.1.8;
Move original Motorola files to the "dist" subdirectory, in response
to PR 9626 by Kris Shannon.
 1.1.8.1 21-Jun-2001  nathanw Catch up to -current.
 1.1.6.2 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.1.6.1 14-Apr-2000  bouyer file isp.s was added on branch thorpej_scsipi on 2000-11-20 20:11:33 +0000
 1.2.194.1 22-Sep-2015  skrll Sync with HEAD
 1.2.174.1 03-Dec-2017  jdolecek update from HEAD
 1.2.8.2 11-Jun-2001  wiz Fix various misspellings of compatible/compatibility.
 1.2.8.1 11-Jun-2001  wiz file isp.s was added on branch nathanw_sa on 2001-06-11 01:50:54 +0000
 1.3.34.1 01-Aug-2021  thorpej Sync with HEAD.
 1.1 14-Apr-2000  is branches: 1.1.6;
Move original Motorola files to the "dist" subdirectory, in response
to PR 9626 by Kris Shannon.
 1.1.6.2 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.1.6.1 14-Apr-2000  bouyer file isp.sa was added on branch thorpej_scsipi on 2000-11-20 20:11:33 +0000
 1.1 14-Apr-2000  is branches: 1.1.6;
Move original Motorola files to the "dist" subdirectory, in response
to PR 9626 by Kris Shannon.
 1.1.6.2 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.1.6.1 14-Apr-2000  bouyer file itest.s was added on branch thorpej_scsipi on 2000-11-20 20:11:33 +0000
 1.1 14-Apr-2000  is branches: 1.1.6;
Move original Motorola files to the "dist" subdirectory, in response
to PR 9626 by Kris Shannon.
 1.1.6.2 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.1.6.1 14-Apr-2000  bouyer file itest.sa was added on branch thorpej_scsipi on 2000-11-20 20:11:34 +0000
 1.1 14-Apr-2000  is branches: 1.1.6;
Move original Motorola files to the "dist" subdirectory, in response
to PR 9626 by Kris Shannon.
 1.1.6.2 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.1.6.1 14-Apr-2000  bouyer file misc was added on branch thorpej_scsipi on 2000-11-20 20:11:34 +0000
 1.1 14-Apr-2000  is branches: 1.1.6;
Move original Motorola files to the "dist" subdirectory, in response
to PR 9626 by Kris Shannon.
 1.1.6.2 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.1.6.1 14-Apr-2000  bouyer file os.s was added on branch thorpej_scsipi on 2000-11-20 20:11:34 +0000
 1.4 11-Dec-2005  christos merge ktrace-lwp.
 1.3 24-Feb-2004  wiz becuase -> because. From Peter Postma.
 1.2 16-Sep-2001  wiz branches: 1.2.4; 1.2.20;
Spell 'occurred' with two 'r's.
 1.1 14-Apr-2000  is branches: 1.1.6; 1.1.8; 1.1.10;
Move original Motorola files to the "dist" subdirectory, in response
to PR 9626 by Kris Shannon.
 1.1.10.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.1.8.1 01-Oct-2001  fvdl Catch up with -current.
 1.1.6.2 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.1.6.1 14-Apr-2000  bouyer file pfpsp.s was added on branch thorpej_scsipi on 2000-11-20 20:11:34 +0000
 1.2.20.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.2.20.2 18-Sep-2004  skrll Sync with HEAD.
 1.2.20.1 03-Aug-2004  skrll Sync with HEAD
 1.2.4.2 16-Sep-2001  wiz Spell 'occurred' with two 'r's.
 1.2.4.1 16-Sep-2001  wiz file pfpsp.s was added on branch nathanw_sa on 2001-09-16 16:34:32 +0000
 1.1 14-Apr-2000  is branches: 1.1.6;
Move original Motorola files to the "dist" subdirectory, in response
to PR 9626 by Kris Shannon.
 1.1.6.2 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.1.6.1 14-Apr-2000  bouyer file pfpsp.sa was added on branch thorpej_scsipi on 2000-11-20 20:11:35 +0000
 1.1 14-Apr-2000  is branches: 1.1.6;
Move original Motorola files to the "dist" subdirectory, in response
to PR 9626 by Kris Shannon.
 1.1.6.2 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.1.6.1 14-Apr-2000  bouyer file readme was added on branch thorpej_scsipi on 2000-11-20 20:11:35 +0000
 1.1 14-Apr-2000  is branches: 1.1.6;
Move original Motorola files to the "dist" subdirectory, in response
to PR 9626 by Kris Shannon.
 1.1.6.2 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.1.6.1 14-Apr-2000  bouyer file test.doc was added on branch thorpej_scsipi on 2000-11-20 20:11:35 +0000
 1.1 25-Feb-2018  mrg add a special rule to build m68k/fpu.c to avoid passing -msoft-float.
fixes GCC 6 kernel builds that use this file.
 1.57 18-Jan-2024  thorpej Make the M68K_MMU_* defines real kernel options, available in opt_m68k_arch.h.
For 68030, 68040, and 68060, infer M68K_MMU_MOTOROLA. For 68010 and 68020, it
must be an explicit option (set in std.${MACHINE} or, in the case of hp300,
inferred from the specific model option).
 1.56 18-Jan-2024  thorpej Bump required version (mkflagvar).
 1.55 18-Jan-2024  thorpej mkflagvar M68010 M68020 M68030 M68040 M68060
 1.54 17-Jan-2024  thorpej Make sigcode.s and sunos_sigcode.s build as their own stand-alone files.
 1.53 17-Jan-2024  thorpej Make compat_13_sigreturn13.s and compat_16_sigreturn14.s build as their
own stand-alone files and G/C the now-empty sigreturn.s.
 1.52 16-Jan-2024  thorpej Build m68k/support.s on its own; don't include it from locore.s
 1.51 21-Oct-2020  christos branches: 1.51.20;
make process_machdep.c included always since it provides register i/o used by
sys_process_getlwpstatus.c which is always included.
 1.50 20-Oct-2020  christos harmonize process_machdep.c inclusion.
 1.49 14-Mar-2019  thorpej G/C "MAPPECOPY". It is the deadest of wood, and never actually worked in
NetBSD.
 1.48 19-Dec-2018  maxv Remove compat_svr4 and compat_svr4_32, as discussed on tech-kern@ recently,
but also as discussed several times in the past.
 1.47 19-Sep-2010  tsutsui branches: 1.47.58; 1.47.60;
Add m68k MD cpu_in_cksum.c.
Based on sys/netinet/cpu_in_cksum.c but just modified
to use traditional MD m68k/oc_cksum.s.

Makes ~5% improvements of ttcp(1) xfer rates on ATARI TT030 + SMC_TT.
 1.46 06-Jun-2010  mrg fix PR 6724 - convert m68k options to defflag's. this means that
M680[12346] are now available from opt_m68k_arch.h. FPSP meantioned
in the PR has already been fixed, and i could not find any more.

i built these kernels to ensure i did not break their builds:

amiga: GENERIC DRACO
atari: HADES FALCON MILAN-PCIIDE
mac68k: GENERIC
sun2: GENERIC
sun3: GENERIC GENERIC3X
cesfic: attempted GENERIC, does not build due to lack of machine/bus.h
hp300: GENERIC
luna68k: GENERIC
mvme68k: GENERIC
news68k: GENERIC
next68k: GENERIC
x68k: GENERIC
 1.45 19-Nov-2008  ad branches: 1.45.6; 1.45.8;
Make the emulations, exec formats, coredump, NFS, and the NFS server
into modules. By and large this commit:

- shuffles header files and ifdefs
- splits code out where necessary to be modular
- adds module glue for each of the components
- adds/replaces hooks for things that can be installed at runtime
 1.44 25-Jan-2008  joerg branches: 1.44.6; 1.44.10; 1.44.16; 1.44.18;
Refactor in_cksum/in4_cksum/in6_cksum implementations:
- All three functions are included in the kernel by default.
They call a backend function cpu_in_cksum after possibly
computing the checksum of the pseudo header.
- cpu_in_cksum is the core to implement the one-complement sum.
The default implementation is moderate fast on most platforms
and provides a 32bit accumulator with 16bit addends for L32 platforms
and a 64bit accumulator with 32bit addends for L64 platforms.
It handles edge cases like very large mbuf chains (could happen with
native IPv6 in the future) and provides a good base for new native
implementations.
- Modify i386 and amd64 assembly to use the new interface.

This disables the MD implementations on !x86 until the conversion is
done. For Alpha, the portable version is faster.
 1.43 06-Jan-2008  ad Add MODULAR option. Include kernel linker stuff if MODULAR.
 1.42 31-Dec-2007  ad Remove COMPAT_HPUX.
 1.41 17-Oct-2007  garbled branches: 1.41.2; 1.41.8;
Merge the ppcoea-renovation branch to HEAD.

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

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

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.40 21-May-2007  tsutsui branches: 1.40.10;
Remove unused m68k/bcopy.s.
(src/common/lib/libc/arch/m68k/string/bcopy.S in libkern is enough)
 1.39 21-May-2007  tsutsui Remove netns stuff.
 1.38 15-Feb-2007  mhitch branches: 1.38.6; 1.38.8; 1.38.14;
Add lock stubs for m68k. Amiga builds and runs now.
 1.37 11-Dec-2005  christos merge ktrace-lwp.
 1.36 22-Sep-2003  cl branches: 1.36.16;
SA_SIGINFO support for m68k
 1.35 24-Jun-2003  martin branches: 1.35.2;
Move (and unify) PMAP_DEBUG and FPU_EMULATE here - it is tested in
shared files.
 1.34 17-Jan-2003  thorpej Merge the nathanw_sa branch.
 1.33 13-Jul-2002  scw m68k syscall rototill:

- Switch all m68k-based ports over to __HAVE_SYSCALL_INTERN.
- Add systrace glue.
- Define struct mdproc in <m68k/proc.h> instead of <machine/proc.h>.
(They were all defined exactly the same anyway, other than a couple
of the MDP_* flags.)
 1.32 28-Nov-2001  lukem branches: 1.32.8;
- convert usage of "defopt" to "defflag" where the relevant option does
not support a value (e.g., it's to be used as "options FOO" instead of
"options FOO=xxx"). options that take a value were converted to
defparam recently.
- minor whitespace & formatting cleanups
 1.31 20-Nov-2001  lukem cleanup:
options SPACE TAB
makeoptions TAB
psuedo-device TAB
remove trailing whitespace
replace multiple spaces -> tabs
options "FOO" -> options FOO
options "FOO=bar" -> options FOO=bar
options "FOO=\"bar\"" -> options FOO="\"bar\""
 1.30 19-Dec-2000  scw branches: 1.30.4; 1.30.8;
Unification of the m68k syscall() function.
 1.29 14-May-2000  minoura defopt FPSP.
 1.28 06-Apr-2000  jdolecek Switch to MI ns_cksum.c - the MD ns_cksum.c is equivalent to it
(modulo some u_intX_t vs. u_char type usage). In particular, the
MD version didn't contain any MD code.
 1.27 14-Feb-2000  thorpej Allow arch-specific code to specify in4_cksum() like it can specify
in_cksum().
 1.26 09-Jul-1999  thorpej branches: 1.26.2;
Normalize include paths.
 1.25 19-Apr-1999  kleink Add COMPAT_SVR4 for m68k.
 1.24 19-Apr-1999  kleink Move linux_reenter_syscall() to a common location and rename it to
reenter_syscall() - it's going to be shared with COMPAT_SVR4 and soon be
used by native code.
 1.23 01-Oct-1998  thorpej branches: 1.23.8;
Implement compat_13_sys_sigreturn().
 1.22 24-May-1998  is Back out the defopt for M680?0. As pointed out to me, this breaks ports which
dont use the M680?0 the way Amiga, Atari, Mac68k, and X68k do. I must have
missed this in the past discussion about this project.
 1.21 23-May-1998  is Move M680[2346]0 to opt_m68kcpu.h.
XXX Some explicit dependencies could be removed now from the individual
arch/$ARCH/conf/Makefile.$ARCH files, but this is still to be done.
 1.20 22-Feb-1998  mycroft Remove random.s.
 1.19 01-Feb-1998  is Amiga uses the common m68k/sig_machdep.c now. Also moved its definition from
the other 68k ports' files.${port} to arch/m68k/conf/files.m68k.
 1.18 06-Jun-1997  veego add src/sys/arch/m68k/m68k/m68k_machdep.c
 1.17 09-Apr-1997  thorpej Add bcopy.s, copy.s, copypage.s, and regdump.c; they're common to all
m68k ports.
 1.16 12-Feb-1997  gwr Add m68k/kgdb_m68k.c
 1.15 02-Feb-1997  thorpej branches: 1.15.2;
Build mappedcopy.c conditional on "options MAPPEDCOPY"
 1.14 10-Sep-1996  thorpej Pull in the COMPAT_M68K4K stuff when appropriate.
 1.13 24-Feb-1996  briggs Add ns_cksum.c.
 1.12 14-Feb-1996  gwr Remove ns_cksum.c (now in sys/conf/files)
 1.11 30-Apr-1995  cgd new-config files list. missed this yesterday.
 1.10 26-Oct-1994  cgd new RCS ID format.
 1.9 05-Jul-1994  mycroft Remove fpsp.U.
 1.8 03-Jul-1994  mycroft Remove bogon.
 1.7 21-Jun-1994  hpeyerl fix to avoid duplicate symbols w/hpfplib.
 1.6 23-May-1994  mycroft Remove copy.s. It's simply not that generic.
 1.5 03-Feb-1994  mycroft Add random.s.
 1.4 29-Jan-1994  cgd make FPSP m68k-generic
 1.3 23-Jan-1994  cgd add copy.s to files.m68k, and alphabetize files.m68k.newconf
 1.2 09-Jan-1994  cgd add ddb files, and also make sure alphabetically ordered
 1.1 08-Jan-1994  cgd common code
 1.15.2.1 12-Mar-1997  is Merge in changes from Trunk
 1.23.8.2 02-Aug-1999  thorpej Update from trunk.
 1.23.8.1 21-Jun-1999  thorpej Sync w/ -current.
 1.26.2.2 05-Jan-2001  bouyer Sync with HEAD
 1.26.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.30.8.3 01-Aug-2002  nathanw Catch up to -current.
 1.30.8.2 08-Jan-2002  nathanw Catch up to -current.
 1.30.8.1 10-Nov-2001  scw Kernel mcontext glue for Scheduler Activations on m68k from
Klaus Klein <kleink@netbsd.org>.
 1.30.4.2 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.30.4.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.32.8.1 16-Jul-2002  gehenna catch up with -current.
 1.35.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.35.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.35.2.1 03-Aug-2004  skrll Sync with HEAD
 1.36.16.4 04-Feb-2008  yamt sync with head.
 1.36.16.3 21-Jan-2008  yamt sync with head
 1.36.16.2 03-Sep-2007  yamt sync with head.
 1.36.16.1 26-Feb-2007  yamt sync with head.
 1.38.14.1 22-May-2007  matt Update to HEAD.
 1.38.8.1 11-Jul-2007  mjf Sync with head.
 1.38.6.1 27-May-2007  ad Sync with head.
 1.40.10.3 23-Mar-2008  matt sync with HEAD
 1.40.10.2 09-Jan-2008  matt sync with HEAD
 1.40.10.1 06-Nov-2007  matt sync with HEAD
 1.41.8.2 08-Jan-2008  bouyer Sync with HEAD
 1.41.8.1 02-Jan-2008  bouyer Sync with HEAD
 1.41.2.1 18-Feb-2008  mjf Sync with HEAD.
 1.44.18.1 19-Jan-2009  skrll Sync with HEAD.
 1.44.16.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.44.10.3 09-Oct-2010  yamt sync with head
 1.44.10.2 11-Aug-2010  yamt sync with head.
 1.44.10.1 04-May-2009  yamt sync with head.
 1.44.6.1 17-Jan-2009  mjf Sync with HEAD.
 1.45.8.2 05-Mar-2011  rmind sync with head
 1.45.8.1 03-Jul-2010  rmind sync with head
 1.45.6.2 22-Oct-2010  uebayasi Sync with HEAD (-D20101022).
 1.45.6.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.47.60.1 10-Jun-2019  christos Sync with HEAD
 1.47.58.1 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.51.20.1 27-Jun-2024  martin Pull up following revision(s) (requested by rin in ticket #724
to fix build fallout on the branch):

sys/arch/m68k/m68k/compat_16_sigreturn14.s: revision 1.6
sys/arch/mvme68k/mvme68k/locore.s: revision 1.129
sys/arch/news68k/news68k/locore.s: revision 1.84
sys/arch/hp300/hp300/locore.s: revision 1.183
sys/arch/m68k/m68k/compat_13_sigreturn13.s: revision 1.8
sys/arch/m68k/m68k/sigreturn.s: file removal
sys/arch/m68k/include/pte_motorola.h: revision 1.10
sys/arch/atari/atari/locore.s: revision 1.125
sys/arch/amiga/amiga/locore.s: revision 1.169
sys/arch/sun2/sun2/locore.s: revision 1.37
sys/arch/next68k/next68k/locore.s: revision 1.84
sys/arch/x68k/x68k/locore.s: revision 1.130
sys/arch/sun3/sun3x/locore.s: revision 1.77
sys/arch/cesfic/cesfic/locore.s: revision 1.45
sys/arch/m68k/conf/files.m68k: revision 1.53
sys/arch/sun3/sun3/locore.s: revision 1.109
sys/arch/luna68k/luna68k/locore.s: revision 1.81
sys/arch/mac68k/mac68k/locore.s: revision 1.182

Define PTE used in the pmap module int terms of the bit definitions
in mmu_{51,40}.h.

Make compat_13_sigreturn13.s and compat_16_sigreturn14.s build as their
own stand-alone files and G/C the now-empty sigreturn.s.
 1.12 28-Apr-1995  cgd rename files files for new config/config.old naming
 1.11 26-Oct-1994  cgd new RCS ID format.
 1.10 05-Jul-1994  mycroft Remove fpsp.U.
 1.9 03-Jul-1994  mycroft Remove bogon.
 1.8 23-May-1994  mycroft Remove copy.s. It's simply not that generic.
 1.7 18-May-1994  chopps always assemble fpspnull.s
 1.6 21-Apr-1994  briggs Add fpsp support. Comment out fpspnull line until I figure out how to
specify "not option" with new config. Don't need it yet, anyway.
 1.5 03-Feb-1994  mycroft Add random.s.
 1.4 23-Jan-1994  cgd add copy.s to files.m68k, and alphabetize files.m68k.newconf
 1.3 22-Jan-1994  briggs Use m68k/m68k/copy.s.
 1.2 09-Jan-1994  cgd add ddb files, and also make sure alphabetically ordered
 1.1 08-Jan-1994  cgd add files.m68k.newconf for the mac folks
 1.12 30-Jan-1997  thorpej This file is now obsolete.
 1.11 10-Sep-1996  thorpej Pull in the COMPAT_M68K4K stuff when appropriate.
 1.10 26-Oct-1994  cgd new RCS ID format.
 1.9 05-Jul-1994  mycroft Remove fpsp.U.
 1.8 03-Jul-1994  mycroft Remove bogon.
 1.7 21-Jun-1994  hpeyerl fix to avoid duplicate symbols w/hpfplib.
 1.6 23-May-1994  mycroft Remove copy.s. It's simply not that generic.
 1.5 03-Feb-1994  mycroft Add random.s.
 1.4 29-Jan-1994  cgd make FPSP m68k-generic
 1.3 23-Jan-1994  cgd add copy.s to files.m68k, and alphabetize files.m68k.newconf
 1.2 09-Jan-1994  cgd add ddb files, and also make sure alphabetically ordered
 1.1 08-Jan-1994  cgd common code
 1.2 04-Jun-2021  martin Sprinkle a few VMSWAP_DEFAULT_PLAINTEXT for architectures where we do not
have any spare cpu cycles to waste (encrypted swap still could be
enabled by the admin in /etc/sysctl.conf).
 1.1 19-Sep-2010  tsutsui branches: 1.1.2; 1.1.4; 1.1.10; 1.1.82; 1.1.86;
- add m68k/conf/std.m68k, which includes common standard options for m68k,
options EXEC_ELF32, EXEC_SCRIPTS, and CPU_IN_CKSUM for md cpu_in_cksum.c
- make all m68k ports include common arch/m68k/conf/std.m68k
from MD std.${MACHINE}
 1.1.86.1 06-Jun-2021  cjep sync with head
 1.1.82.1 17-Jun-2021  thorpej Sync w/ HEAD.
 1.1.10.2 05-Mar-2011  rmind sync with head
 1.1.10.1 19-Sep-2010  rmind file std.m68k was added on branch rmind-uvmplock on 2011-03-05 20:50:53 +0000
 1.1.4.2 22-Oct-2010  uebayasi Sync with HEAD (-D20101022).
 1.1.4.1 19-Sep-2010  uebayasi file std.m68k was added on branch uebayasi-xip on 2010-10-22 07:21:22 +0000
 1.1.2.2 09-Oct-2010  yamt sync with head
 1.1.2.1 19-Sep-2010  yamt file std.m68k was added on branch yamt-nfs-mp on 2010-10-09 03:31:49 +0000
 1.7 21-Aug-2021  andvar fix mainly same typos as in my previous commit but outside sys/dev/dm.
 1.6 20-Apr-2013  isaki Update a list of implement/unimplement functions.
 1.5 15-Oct-2011  tsutsui branches: 1.5.2; 1.5.12;
Update implemented/unimplemented FP functions.
 1.4 05-Nov-1995  briggs Update from Ken Nakata.
 1.3 05-Nov-1995  briggs Fixes from Ken Nakata. Mainly renaming debug_level to fpu_debug_level.
 1.2 03-Nov-1995  briggs Add NetBSD id string and update instructions.
 1.1 03-Nov-1995  briggs Still incomplete, but much more complete FPE from Ken Nakata
<kenn@remus.rutgers.edu>. This emulator does not yet emulate
the following functions:
FSINH, FETOXM1, FTANH, FATAN, FASIN, FATANH, FSIN, FTAN,
FETOX, FTWOTOX, FTENTOX, FCOSH, FACOS, FCOS, FSINCOS
It is sufficient, however, to allow programs like df, w, and newfs,
to run to completion with correct results.
Portions of this code were based on the sparc fpe and on initial
work by gwr.
 1.5.12.1 23-Jun-2013  tls resync from head
 1.5.2.1 22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.3 19-Apr-2013  isaki Introduce the CORDIC algorithm.
o sine and cosine (e.g., FSIN, FCOS and FSINCOS instructions) is now
calculated in the CORDIC instead of Taylor expansion.
o tangent (FTAN) is not touched from a viewpoint of the code size.
o The CORDIC is applicable for hyperbolic functions (e.g., FSINH,
FCOSH, FTANH instructions), but I didn't use it because its working
range is poor.
o The CORDIC is also usable for inverse trigonometric functions,
I will commit it at next phase.
o The code size becomes a bit big. I cannot evaluate speed on m68k
for some reasons, but in test on i386 the CORDIC is approximately
100 times faster in sin/cos.
 1.2 03-Nov-1995  briggs branches: 1.2.204; 1.2.214;
Add in NetBSD id string.
 1.1 03-Nov-1995  briggs Still incomplete, but much more complete FPE from Ken Nakata
<kenn@remus.rutgers.edu>. This emulator does not yet emulate
the following functions:
FSINH, FETOXM1, FTANH, FATAN, FASIN, FATANH, FSIN, FTAN,
FETOX, FTWOTOX, FTENTOX, FCOSH, FACOS, FCOS, FSINCOS
It is sufficient, however, to allow programs like df, w, and newfs,
to run to completion with correct results.
Portions of this code were based on the sparc fpe and on initial
work by gwr.
 1.2.214.1 23-Jun-2013  tls resync from head
 1.2.204.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.9 26-Mar-2013  isaki u_int -> uint32_t
 1.8 19-Mar-2013  isaki Remove 'register'.
 1.7 14-Mar-2009  dsl branches: 1.7.12; 1.7.22;
Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.6 11-Dec-2005  christos branches: 1.6.78; 1.6.86; 1.6.92;
merge ktrace-lwp.
 1.5 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.4 15-Jul-2003  lukem __KERNEL_RCSID()
 1.3 30-May-1999  briggs branches: 1.3.36;
PR 7220 from Ken Nakata:
I've fixed most (not all) m68k FPE bugs that give bogus
calculation results, esp. fsqrt instruction. Also, the internal FP
representation has been reduced from 115-bit mantissa to 67-bit
mantissa which reduced the required mantissa operation roughly by one
fourth. I've done an extensive (though not exhaustive - it's
impossible!) test on the internal routines by feeding them randomly
generated FP numbers, and found that the new code is more precise than
MC68040 FPU (it seems to have a rounding bug).

[ Only change was to keep fpu_calcea.c's name instead of renaming to
fpu_ea.c in Ken's patch. --akb ]
 1.2 30-Apr-1996  briggs branches: 1.2.24; 1.2.26; 1.2.28;
Update for -Wall -Wstrict-prototypes -Wmissing-prototypes -Wno-uninitialized.
 1.1 03-Nov-1995  briggs Still incomplete, but much more complete FPE from Ken Nakata
<kenn@remus.rutgers.edu>. This emulator does not yet emulate
the following functions:
FSINH, FETOXM1, FTANH, FATAN, FASIN, FATANH, FSIN, FTAN,
FETOX, FTWOTOX, FTENTOX, FCOSH, FACOS, FCOS, FSINCOS
It is sufficient, however, to allow programs like df, w, and newfs,
to run to completion with correct results.
Portions of this code were based on the sparc fpe and on initial
work by gwr.
 1.2.28.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.2.26.1 21-Jun-1999  thorpej Sync w/ -current.
 1.2.24.2 06-Feb-2000  he Apply patch (requested by is):
Revert floating point emulation software to the version released
as NetBSD 1.4. The upgrade done in 1.4.1 had problems.
 1.2.24.1 21-Jun-1999  perry pullup 1.2->1.3 (briggs): fix FPE
 1.3.36.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.3.36.2 18-Sep-2004  skrll Sync with HEAD.
 1.3.36.1 03-Aug-2004  skrll Sync with HEAD
 1.6.92.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.6.86.1 28-Apr-2009  skrll Sync with HEAD.
 1.6.78.1 04-May-2009  yamt sync with head.
 1.7.22.1 23-Jun-2013  tls resync from head
 1.7.12.1 22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.8 01-Apr-2013  isaki quad_t -> uint64_t
 1.7 26-Mar-2013  isaki u_int -> uint32_t
 1.6 19-Mar-2013  isaki Remove 'register'.
 1.5 24-Dec-2005  perry branches: 1.5.112; 1.5.122;
bare asm -> __asm
 1.4 11-Dec-2005  christos merge ktrace-lwp.
 1.3 07-Aug-2003  agc branches: 1.3.16;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.2 30-May-1999  briggs branches: 1.2.36;
PR 7220 from Ken Nakata:
I've fixed most (not all) m68k FPE bugs that give bogus
calculation results, esp. fsqrt instruction. Also, the internal FP
representation has been reduced from 115-bit mantissa to 67-bit
mantissa which reduced the required mantissa operation roughly by one
fourth. I've done an extensive (though not exhaustive - it's
impossible!) test on the internal routines by feeding them randomly
generated FP numbers, and found that the new code is more precise than
MC68040 FPU (it seems to have a rounding bug).

[ Only change was to keep fpu_calcea.c's name instead of renaming to
fpu_ea.c in Ken's patch. --akb ]
 1.1 03-Nov-1995  briggs branches: 1.1.24; 1.1.26; 1.1.28;
Still incomplete, but much more complete FPE from Ken Nakata
<kenn@remus.rutgers.edu>. This emulator does not yet emulate
the following functions:
FSINH, FETOXM1, FTANH, FATAN, FASIN, FATANH, FSIN, FTAN,
FETOX, FTWOTOX, FTENTOX, FCOSH, FACOS, FCOS, FSINCOS
It is sufficient, however, to allow programs like df, w, and newfs,
to run to completion with correct results.
Portions of this code were based on the sparc fpe and on initial
work by gwr.
 1.1.28.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.1.26.1 21-Jun-1999  thorpej Sync w/ -current.
 1.1.24.2 06-Feb-2000  he Apply patch (requested by is):
Revert floating point emulation software to the version released
as NetBSD 1.4. The upgrade done in 1.4.1 had problems.
 1.1.24.1 21-Jun-1999  perry pullup 1.1->1.2 (briggs): fix FPE
 1.2.36.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.2.36.2 18-Sep-2004  skrll Sync with HEAD.
 1.2.36.1 03-Aug-2004  skrll Sync with HEAD
 1.3.16.1 21-Jun-2006  yamt sync with head.
 1.5.122.1 23-Jun-2013  tls resync from head
 1.5.112.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.2 14-Mar-2009  dsl Remove all the __P() from sys (excluding sys/dist)
Diff checked with grep and MK1 eyeball.
i386 and amd64 GENERIC and sys still build.
 1.1 03-Nov-1995  briggs branches: 1.1.170; 1.1.178; 1.1.184;
Still incomplete, but much more complete FPE from Ken Nakata
<kenn@remus.rutgers.edu>. This emulator does not yet emulate
the following functions:
FSINH, FETOXM1, FTANH, FATAN, FASIN, FATANH, FSIN, FTAN,
FETOX, FTWOTOX, FTENTOX, FCOSH, FACOS, FCOS, FSINCOS
It is sufficient, however, to allow programs like df, w, and newfs,
to run to completion with correct results.
Portions of this code were based on the sparc fpe and on initial
work by gwr.
 1.1.184.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.1.178.1 28-Apr-2009  skrll Sync with HEAD.
 1.1.170.1 04-May-2009  yamt sync with head.
 1.28 28-Dec-2024  isaki Fix indent.
 1.27 06-Apr-2019  thorpej branches: 1.27.36;
Overhaul the API used to fetch and store individual memory cells in
userspace. The old fetch(9) and store(9) APIs (fubyte(), fuword(),
subyte(), suword(), etc.) are retired and replaced with new ufetch(9)
and ustore(9) APIs that can return proper error codes, etc. and are
implemented consistently across all platforms. The interrupt-safe
variants are no longer supported (and several of the existing attempts
at fuswintr(), etc. were buggy and not actually interrupt-safe).

Also augmement the ucas(9) API, making it consistently available on
all plaforms, supporting uniprocessor and multiprocessor systems, even
those that do not have CAS or LL/SC primitives.

Welcome to NetBSD 8.99.37.
 1.26 18-Jul-2011  isaki branches: 1.26.54;
fix indent again.
- "Second level indents are four spaces." pointed out by tsutsui@
- fold long line.
 1.25 18-Jul-2011  isaki fix indent. no functional changes.
 1.24 25-May-2011  tsutsui - consistently use #ifdef DEBUG_FPE and #ifdef DIAGNOSTIC
- use DPRINTF() style debug printfs
- use __func__ to print function names
 1.23 25-May-2011  tsutsui KNF. No binary change.
 1.22 06-Jun-2010  mrg branches: 1.22.2;
fix PR 6724 - convert m68k options to defflag's. this means that
M680[12346] are now available from opt_m68k_arch.h. FPSP meantioned
in the PR has already been fixed, and i could not find any more.

i built these kernels to ensure i did not break their builds:

amiga: GENERIC DRACO
atari: HADES FALCON MILAN-PCIIDE
mac68k: GENERIC
sun2: GENERIC
sun3: GENERIC GENERIC3X
cesfic: attempted GENERIC, does not build due to lack of machine/bus.h
hp300: GENERIC
luna68k: GENERIC
mvme68k: GENERIC
news68k: GENERIC
next68k: GENERIC
x68k: GENERIC
 1.21 14-Mar-2009  dsl branches: 1.21.2; 1.21.4;
ANSIfy another 1261 function definitions.
The only ones left in sys are beyond by sed script!
(or in sys/dist or sys/external)
Mostly they have function pointer parameters.
 1.20 14-Mar-2009  dsl Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.19 14-Mar-2009  dsl Remove all the __P() from sys (excluding sys/dist)
Diff checked with grep and MK1 eyeball.
i386 and amd64 GENERIC and sys still build.
 1.18 09-Mar-2007  tsutsui branches: 1.18.44; 1.18.52; 1.18.58;
Don't disable EA_DIRECT in fpu_load_ea(), which seems disabled
accidentally in rev 1.11 about six years ago, otherwise
fmovel %dN,%fpN instructions cause unexpected memory access.
 1.17 11-Dec-2005  christos branches: 1.17.24; 1.17.26;
merge ktrace-lwp.
 1.16 13-Feb-2004  wiz branches: 1.16.14; 1.16.16;
Uppercase CPU, plural is CPUs.
 1.15 15-Jul-2003  lukem __KERNEL_RCSID()
 1.14 27-Sep-2002  provos branches: 1.14.6;
remove trailing \n in panic(). approved perry.
 1.13 28-Jul-2001  tsutsui branches: 1.13.6;
bcopy -> memcpy
 1.12 05-Jul-2001  toshii branches: 1.12.2;
Fix typo. s/extention/extension/
 1.11 01-Mar-2001  is Don't use the frames' provided EA yet; something is wrong.
 1.10 05-Jan-2001  is Make this actually sort-of-work for 68060 w. disabled FPU (tested), 68LC060,
and I suspect, 68LC040 and 68040V machines. Method used:

1. do NOT use the frames effective address at all
2. do NOT use the frames next instruction address, but
3. restore the "this instruction" pc into the pc field of the frame at the
beginning of the emulation, if we got a frame format 4.

TODO:
A. find the bug in the usage of the frame EA, and revert to using it.
B. find the bug in the usage of the frames next instruction address, and
consider whether it's worthwhile to use it.
C. make the emulation complete.... FEXP FETOM1, and the trigonometric functions
are missing.
 1.9 13-Jun-2000  minoura Argument modreg of fpu_decode_ea() is actually an opecode.
That bug prevented awk(1) to work.
 1.8 30-May-1999  briggs branches: 1.8.2; 1.8.10;
PR 7220 from Ken Nakata:
I've fixed most (not all) m68k FPE bugs that give bogus
calculation results, esp. fsqrt instruction. Also, the internal FP
representation has been reduced from 115-bit mantissa to 67-bit
mantissa which reduced the required mantissa operation roughly by one
fourth. I've done an extensive (though not exhaustive - it's
impossible!) test on the internal routines by feeding them randomly
generated FP numbers, and found that the new code is more precise than
MC68040 FPU (it seems to have a rounding bug).

[ Only change was to keep fpu_calcea.c's name instead of renaming to
fpu_ea.c in Ken's patch. --akb ]
 1.7 16-Oct-1996  scottr branches: 1.7.22; 1.7.24; 1.7.26;
Eliminate fusword() prototype, as it's now in <sys/systm.h>
 1.6 13-Oct-1996  christos backout previous kprintf change
 1.5 11-Oct-1996  christos printf -> kprintf, sprintf -> ksprintf
 1.4 30-Apr-1996  briggs Update for -Wall -Wstrict-prototypes -Wmissing-prototypes -Wno-uninitialized.
 1.3 04-Feb-1996  briggs sys/types.h -> sys/param.h and remove include of stddef.h.
 1.2 05-Nov-1995  briggs Fixes from Ken Nakata. Mainly renaming debug_level to fpu_debug_level.
 1.1 03-Nov-1995  briggs Still incomplete, but much more complete FPE from Ken Nakata
<kenn@remus.rutgers.edu>. This emulator does not yet emulate
the following functions:
FSINH, FETOXM1, FTANH, FATAN, FASIN, FATANH, FSIN, FTAN,
FETOX, FTWOTOX, FTENTOX, FCOSH, FACOS, FCOS, FSINCOS
It is sufficient, however, to allow programs like df, w, and newfs,
to run to completion with correct results.
Portions of this code were based on the sparc fpe and on initial
work by gwr.
 1.7.26.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.7.24.1 21-Jun-1999  thorpej Sync w/ -current.
 1.7.22.2 06-Feb-2000  he Apply patch (requested by is):
Revert floating point emulation software to the version released
as NetBSD 1.4. The upgrade done in 1.4.1 had problems.
 1.7.22.1 21-Jun-1999  perry pullup 1.7->1.8 (briggs): fix FPE
 1.8.10.1 22-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.8.2.3 12-Mar-2001  bouyer Sync with HEAD.
 1.8.2.2 18-Jan-2001  bouyer Sync with head (for UBC+NFS fixes, mostly).
 1.8.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.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 03-Aug-2001  lukem update to -current
 1.13.6.2 18-Oct-2002  nathanw Catch up to -current.
 1.13.6.1 28-Jul-2001  nathanw file fpu_calcea.c was added on branch nathanw_sa on 2002-10-18 02:38:14 +0000
 1.14.6.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.14.6.2 18-Sep-2004  skrll Sync with HEAD.
 1.14.6.1 03-Aug-2004  skrll Sync with HEAD
 1.16.16.1 03-Sep-2007  yamt sync with head.
 1.16.14.1 31-Mar-2007  bouyer Pull up following revision(s) (requested by tsutsui in ticket #1703):
sys/arch/m68k/fpe/fpu_emulate.c: revision 1.27
sys/arch/m68k/fpe/fpu_calcea.c: revision 1.18
sys/arch/m68k/fpe/fpu_fstore.c: revision 1.10
Make these compile with options DEBUG_FPE.
Don't disable EA_DIRECT in fpu_load_ea(), which seems disabled
accidentally in rev 1.11 about six years ago, otherwise
fmovel %dN,%fpN instructions cause unexpected memory access.
 1.17.26.1 12-Mar-2007  rmind Sync with HEAD.
 1.17.24.1 31-Mar-2007  bouyer Pull up following revision(s) (requested by tsutsui in ticket #526):
sys/arch/m68k/fpe/fpu_emulate.c: revision 1.27
sys/arch/m68k/fpe/fpu_calcea.c: revision 1.18
sys/arch/m68k/fpe/fpu_fstore.c: revision 1.10
Make these compile with options DEBUG_FPE.
Don't disable EA_DIRECT in fpu_load_ea(), which seems disabled
accidentally in rev 1.11 about six years ago, otherwise
fmovel %dN,%fpN instructions cause unexpected memory access.
 1.18.58.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.18.52.1 28-Apr-2009  skrll Sync with HEAD.
 1.18.44.2 11-Aug-2010  yamt sync with head.
 1.18.44.1 04-May-2009  yamt sync with head.
 1.21.4.2 31-May-2011  rmind sync with head
 1.21.4.1 03-Jul-2010  rmind sync with head
 1.21.2.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.22.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.26.54.1 10-Jun-2019  christos Sync with HEAD
 1.27.36.1 02-Aug-2025  perseant Sync with HEAD
 1.4 06-Dec-2016  isaki Remove fpu_cordit2() and atanh_table[] completely.
Since cordit1 (for trigonometric functions) and cordit2 (for
hyperbolic functions) are very similar, so I implemented both
at first, but I didn't use cordit2 after all :(
 1.3 04-Aug-2016  isaki Move fpu_cordit2() to #ifdef CORDIC_BOOTSTRAP section.
This reduces ~2KB text segment.
Reported by Krister Walfridsson on tech-kern two months ago.
 1.2 20-Apr-2013  isaki branches: 1.2.4; 1.2.12; 1.2.16; 1.2.20;
s/tayler/taylor/. pointed out by christos@
 1.1 19-Apr-2013  isaki Introduce the CORDIC algorithm.
o sine and cosine (e.g., FSIN, FCOS and FSINCOS instructions) is now
calculated in the CORDIC instead of Taylor expansion.
o tangent (FTAN) is not touched from a viewpoint of the code size.
o The CORDIC is applicable for hyperbolic functions (e.g., FSINH,
FCOSH, FTANH instructions), but I didn't use it because its working
range is poor.
o The CORDIC is also usable for inverse trigonometric functions,
I will commit it at next phase.
o The code size becomes a bit big. I cannot evaluate speed on m68k
for some reasons, but in test on i386 the CORDIC is approximately
100 times faster in sin/cos.
 1.2.20.2 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.2.20.1 06-Aug-2016  pgoyette Sync with HEAD
 1.2.16.2 05-Feb-2017  skrll Sync with HEAD
 1.2.16.1 05-Oct-2016  skrll Sync with HEAD
 1.2.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.2.12.1 20-Apr-2013  yamt file fpu_cordic.c was added on branch yamt-pagecache on 2014-05-22 11:39:55 +0000
 1.2.4.3 03-Dec-2017  jdolecek update from HEAD
 1.2.4.2 23-Jun-2013  tls resync from head
 1.2.4.1 20-Apr-2013  tls file fpu_cordic.c was added on branch tls-maxphys on 2013-06-23 06:20:08 +0000
 1.10 01-Jan-2014  isaki indent fix in a comment.
 1.9 01-Jan-2014  isaki Fix a sign when a source or destination is either (plus/minus)zero
or (plus/minus)infinity. Found by XM6i.
 1.8 26-Mar-2013  isaki branches: 1.8.4;
u_int -> uint32_t
 1.7 19-Mar-2013  isaki Remove 'register'.
 1.6 14-Mar-2009  dsl branches: 1.6.12; 1.6.22;
Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.5 11-Dec-2005  christos branches: 1.5.78; 1.5.86; 1.5.92;
merge ktrace-lwp.
 1.4 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.3 15-Jul-2003  lukem __KERNEL_RCSID()
 1.2 30-May-1999  briggs branches: 1.2.36;
PR 7220 from Ken Nakata:
I've fixed most (not all) m68k FPE bugs that give bogus
calculation results, esp. fsqrt instruction. Also, the internal FP
representation has been reduced from 115-bit mantissa to 67-bit
mantissa which reduced the required mantissa operation roughly by one
fourth. I've done an extensive (though not exhaustive - it's
impossible!) test on the internal routines by feeding them randomly
generated FP numbers, and found that the new code is more precise than
MC68040 FPU (it seems to have a rounding bug).

[ Only change was to keep fpu_calcea.c's name instead of renaming to
fpu_ea.c in Ken's patch. --akb ]
 1.1 03-Nov-1995  briggs branches: 1.1.24; 1.1.26; 1.1.28;
Still incomplete, but much more complete FPE from Ken Nakata
<kenn@remus.rutgers.edu>. This emulator does not yet emulate
the following functions:
FSINH, FETOXM1, FTANH, FATAN, FASIN, FATANH, FSIN, FTAN,
FETOX, FTWOTOX, FTENTOX, FCOSH, FACOS, FCOS, FSINCOS
It is sufficient, however, to allow programs like df, w, and newfs,
to run to completion with correct results.
Portions of this code were based on the sparc fpe and on initial
work by gwr.
 1.1.28.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.1.26.1 21-Jun-1999  thorpej Sync w/ -current.
 1.1.24.2 06-Feb-2000  he Apply patch (requested by is):
Revert floating point emulation software to the version released
as NetBSD 1.4. The upgrade done in 1.4.1 had problems.
 1.1.24.1 21-Jun-1999  perry pullup 1.1->1.2 (briggs): fix FPE
 1.2.36.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.2.36.2 18-Sep-2004  skrll Sync with HEAD.
 1.2.36.1 03-Aug-2004  skrll Sync with HEAD
 1.5.92.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.5.86.1 28-Apr-2009  skrll Sync with HEAD.
 1.5.78.1 04-May-2009  yamt sync with head.
 1.6.22.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.6.22.1 23-Jun-2013  tls resync from head
 1.6.12.1 22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.8.4.1 18-May-2014  rmind sync with head
 1.49 06-Jan-2025  isaki m68k/fpe: Avoid an illegal mod/reg before decoding it.
This also works for machines with FPU.
If the kernel defines FPU_EMULATE, even illegal FPU instructions in the real
6888x machines, the FPE will be executed by F line exception. So the FPE
must raise SIGILL appropriately for these.
 1.48 28-Dec-2024  isaki m68k/fpe: Remove duplicated assignments.
These are already stored before. No functional changes intended.
 1.47 28-Dec-2024  isaki m68k/fpe: Fix FTRAPcc emulation raise the correct trap.
Currently fpu_emul_type1() returns SIGFPE only if FTRAPcc's condition is met,
so this works. But I wish there was a better way..
fputest.x(0.24.10.08) about ftrapcc passed 100%.
 1.46 28-Dec-2024  isaki m68k/fpe: Reimplement and simplify test_cc().
This logic was analized by Y.Sugahara (in 2016).
Finally fputest.x(0.24.10.08) about fbcc fdbcc fscc (40960 tests) passed 100%!
 1.45 28-Dec-2024  isaki m68k/fpe: Two bugfixes in test_cc().
- Don't clear the exception byte in FPSR.
According to the manual, all bits except BSUN are "not affected".
- Accumulate AIOP bit always.
XXX Need to look this again later. brcc() looks to have similar one.
 1.44 28-Dec-2024  isaki m68k/fpe: Several bugfixes in FDBcc and FTRAPcc emulation.
In fpu_emul_type1(),
- If test_cc() returns >0, it's an error, that is an illegal instruction in
this case. So it should just return without doing anything.
By this fix, FTRAPcc with illegal cc now causes SIGILL correctly.
- In result, branch can only be 0 or -1 after that. It makes code simple.
By this cleanup, FDBcc with illegal cc now causes SIGILL correctly.
- FTRAPcc must advance PC regardless of whether the condition is met.
(although FTRAPcc does not work at this point by anothor problem)
 1.43 28-Dec-2024  isaki m68k/fpe: Fix several FMOVEM FPctl emulation.
- Fix the write order of FMOVEM FPctl,-(An).
For example, "FMOVEM FPCR/FPSR,-(An)" instruction first decrements An by
the total size (4*2 bytes), then writes FPCR and FPSR in this order.
Therefore, it's differs from "FMOVEM FPCR,-(An); FMOVEM FPSR,-(An)" sequence.
- Support multiple immediate case like "FMOVEM #imm/#imm,FPCR/FPIAR".
- Mask writes to FPSR and FPCR registers correctly.
- Support reglist=0 case too. It's not common case but makes code easier.
 1.42 28-Dec-2024  isaki m68k/fpe: FMOVEM (both FPn and FPctl) must not update accrued byte in FPSR.
 1.41 17-Sep-2023  andvar branches: 1.41.6;
word was changed to sval at rev 1.39, but DPRINTF values were not updated.

Fixes DEBUG_FPE enabled build for 68k FPE code.
 1.40 27-Dec-2019  msaitoh s/opration/operation/
 1.39 06-Apr-2019  thorpej Overhaul the API used to fetch and store individual memory cells in
userspace. The old fetch(9) and store(9) APIs (fubyte(), fuword(),
subyte(), suword(), etc.) are retired and replaced with new ufetch(9)
and ustore(9) APIs that can return proper error codes, etc. and are
implemented consistently across all platforms. The interrupt-safe
variants are no longer supported (and several of the existing attempts
at fuswintr(), etc. were buggy and not actually interrupt-safe).

Also augmement the ucas(9) API, making it consistently available on
all plaforms, supporting uniprocessor and multiprocessor systems, even
those that do not have CAS or LL/SC primitives.

Welcome to NetBSD 8.99.37.
 1.38 25-Oct-2013  martin branches: 1.38.30;
Comment unused stuff (for documentation purposes)
 1.37 26-Mar-2013  isaki branches: 1.37.4;
u_int -> uint32_t
 1.36 15-Oct-2011  tsutsui branches: 1.36.2; 1.36.12;
Add hyperboric and trigonometric functions to m68k FPE, written by isaki@.
With these emulations (~4KB text) xeyes on XM6i works better.
Discussed with isaki@ at OSC 2011 Hiroshima.
 1.35 18-Jul-2011  isaki fix indent again.
- "Second level indents are four spaces." pointed out by tsutsui@
- fold long line.
 1.34 18-Jul-2011  isaki fix indent. no functional changes.
 1.33 23-May-2011  tsutsui - use DPRINTF() style debug printfs
- use __func__ to print function names
- consistently use #ifdef DEBUG_FPE
- add some missing debug messages including \n in error paths
 1.32 23-May-2011  tsutsui KNF, mostly indent. No binary change.
 1.31 14-May-2011  tsutsui Fix botch in rev 1.28 that causes wrong results of fcmp and ftst in FPE.
fpu_upd_fpsr() should be called even in discard_result case if an emulated
instruction gets proper result without signal.

Fixes weird behavior of awk(1) seen on /etc/rc.d/postfix on XM6i and
TME emulating sun3 without 68881.

Should be pulled up to all netbsd-4 and netbsd-5 branches.
 1.30 14-Mar-2009  dsl branches: 1.30.4; 1.30.6;
Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.29 14-Mar-2009  dsl Remove all the __P() from sys (excluding sys/dist)
Diff checked with grep and MK1 eyeball.
i386 and amd64 GENERIC and sys still build.
 1.28 20-Jan-2009  tsutsui branches: 1.28.2;
In fpu_emul_arith(), check lower 7 bits in word1 rather than only 6 bits
to check 040/060 FP instructions, and don't call fpu_implode() and
fpu_upd_fpsr() if no vaild emulated result is set otherwise these
functions cause NULL pointer dereference.

Fixes panics triggered by 040/060's FDADD instruction
(which has the same lower 6 bits with fscale instruction)
on 020/030 machines (even with 68881/68882) running kernels
with options FPU_EMULATE.
Problem reported by John Carr on port-sun3.

Should be pulled up to netbsd-4-0, netbsd-4 and netbsd-5.

XXX: m68k 4.0 packages binaries on ftp have this FDADD instruction.
 1.27 09-Mar-2007  tsutsui branches: 1.27.44; 1.27.52; 1.27.54;
Make these compile with options DEBUG_FPE.
 1.26 11-Dec-2005  christos branches: 1.26.24; 1.26.26;
merge ktrace-lwp.
 1.25 22-Sep-2003  cl branches: 1.25.14; 1.25.16;
SA_SIGINFO support for m68k
 1.24 15-Jul-2003  lukem __KERNEL_RCSID()
 1.23 05-Feb-2001  chs branches: 1.23.24;
conditionalize the ddb hook on DDB && DEBUG_FPE rather than DDB && DEBUG,
since that's the condition under which we include the header file that
allows it to compile.
 1.22 05-Jan-2001  is Make this actually sort-of-work for 68060 w. disabled FPU (tested), 68LC060,
and I suspect, 68LC040 and 68040V machines. Method used:

1. do NOT use the frames effective address at all
2. do NOT use the frames next instruction address, but
3. restore the "this instruction" pc into the pc field of the frame at the
beginning of the emulation, if we got a frame format 4.

TODO:
A. find the bug in the usage of the frame EA, and revert to using it.
B. find the bug in the usage of the frames next instruction address, and
consider whether it's worthwhile to use it.
C. make the emulation complete.... FEXP FETOM1, and the trigonometric functions
are missing.
 1.21 30-May-1999  briggs branches: 1.21.2;
PR 7220 from Ken Nakata:
I've fixed most (not all) m68k FPE bugs that give bogus
calculation results, esp. fsqrt instruction. Also, the internal FP
representation has been reduced from 115-bit mantissa to 67-bit
mantissa which reduced the required mantissa operation roughly by one
fourth. I've done an extensive (though not exhaustive - it's
impossible!) test on the internal routines by feeding them randomly
generated FP numbers, and found that the new code is more precise than
MC68040 FPU (it seems to have a rounding bug).

[ Only change was to keep fpu_calcea.c's name instead of renaming to
fpu_ea.c in Ken's patch. --akb ]
 1.20 04-Jul-1998  jonathan branches: 1.20.8; 1.20.10; 1.20.12;
defopt DDB.
 1.19 03-Nov-1997  is Back out last change, which was a thinko.
 1.18 02-Nov-1997  is Add ftwotox emulation, by using the fscale emulation routine (preload
destination register bit pattern with 1.0), which automatically provides
corner case handling.
Missing ftwotox emulation originally reported by Norman Mackenzie in PR 4237,
but he proposed a different implementation.
 1.17 20-Jul-1997  is Make us pass the full ieeefp except regression test.
XXX This is probably a horrible hack, and wrong. FPU signal handling needs
to be further evaluated.
 1.16 19-Jul-1997  is Fix my own PR port-m68k/3871, nee port-amiga/3871:
- don't erase FPSR exception bits _after_ doing most of the operations in
fpu_implode(), erase them before doing arith and store operations. This fixes
losing the DZ bit.
- create FPSR_OVFL and FPSR_UNFL bits in fpu_implode(). This showed up when
the first error was fixed.
XXX some more work needs to be done. E.g., creating OPERR together with
OVFL looks bogus, but I'm too tired know to re-check docs; and at least we
pass our own regression tests know.
 1.15 17-Jul-1997  veego include <m68k/db_machdep.h> to get the prototype for kdb_trap if DDB and
DEBUG are defined and add a cast for the second argument to the
kdb_trap call.
 1.14 18-Dec-1996  scottr Work around another uninitialized variable warning
 1.13 17-Dec-1996  gwr Fix warnings.
 1.12 30-Oct-1996  is Bug fix for FSINCOS: wouldn't handle FPc == FP1 earlier.
 1.11 16-Oct-1996  scottr Eliminate fusword() prototype, as it's now in <sys/systm.h>
 1.10 13-Oct-1996  christos backout previous kprintf change
 1.9 11-Oct-1996  christos printf -> kprintf, sprintf -> ksprintf
 1.8 07-Oct-1996  scottr The 68LC040 generates a format 4 stack frame for floating point
exceptions, which puts the address of the instruction we faulted
on in a different location. Copy it and handle as we normally would,
restoring the saved PC before returning.

The FPE should probably be reworked to take advantage of the 68LC040's
precalculated effective address, at some point.
 1.7 04-Oct-1996  scottr Fix FMOVEM emulation; postincrement modes use different ordering than
predecrement modes, per 68K Programmer's Manual p. 5-88. Pointed out
by Takeshi Nakayama <takeshi@sakabe.nuie.nagoya-u.ac.jp>, verified by me.
 1.6 15-May-1996  leo branches: 1.6.4;
Fix "might be used uninitialized" warnings.
 1.5 30-Apr-1996  briggs Update for -Wall -Wstrict-prototypes -Wmissing-prototypes -Wno-uninitialized.
 1.4 05-Nov-1995  briggs Fixes from Ken Nakata. Mainly renaming debug_level to fpu_debug_level.
 1.3 03-Nov-1995  briggs Still incomplete, but much more complete FPE from Ken Nakata
<kenn@remus.rutgers.edu>. This emulator does not yet emulate
the following functions:
FSINH, FETOXM1, FTANH, FATAN, FASIN, FATANH, FSIN, FTAN,
FETOX, FTWOTOX, FTENTOX, FCOSH, FACOS, FCOS, FSINCOS
It is sufficient, however, to allow programs like df, w, and newfs,
to run to completion with correct results.
Portions of this code were based on the sparc fpe and on initial
work by gwr.
 1.2 10-Mar-1995  gwr Add missing break in switch (not that it mattered 8^)
 1.1 01-Mar-1995  gwr branches: 1.1.1;
Initial revision
 1.1.1.1 01-Mar-1995  gwr First cut at an mc68881 emulator. Works only for fmovem right now.
 1.6.4.1 05-Dec-1996  rat Pullup request 1.11 to 1.12 from Ignatios Souvatzis <ignatios@cs.uni-bonn.de>

>This fixes an oversight/editing error, which would prevent us from emulating
>the FSINCOS opcode, where FPcos == FP1.
 1.20.12.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.20.10.1 21-Jun-1999  thorpej Sync w/ -current.
 1.20.8.2 06-Feb-2000  he Apply patch (requested by is):
Revert floating point emulation software to the version released
as NetBSD 1.4. The upgrade done in 1.4.1 had problems.
 1.20.8.1 21-Jun-1999  perry pullup 1.20->1.21 (briggs): fix FPE
 1.21.2.2 11-Feb-2001  bouyer Sync with HEAD.
 1.21.2.1 18-Jan-2001  bouyer Sync with head (for UBC+NFS fixes, mostly).
 1.23.24.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.23.24.2 18-Sep-2004  skrll Sync with HEAD.
 1.23.24.1 03-Aug-2004  skrll Sync with HEAD
 1.25.16.1 03-Sep-2007  yamt sync with head.
 1.25.14.1 31-Mar-2007  bouyer Pull up following revision(s) (requested by tsutsui in ticket #1703):
sys/arch/m68k/fpe/fpu_emulate.c: revision 1.27
sys/arch/m68k/fpe/fpu_calcea.c: revision 1.18
sys/arch/m68k/fpe/fpu_fstore.c: revision 1.10
Make these compile with options DEBUG_FPE.
Don't disable EA_DIRECT in fpu_load_ea(), which seems disabled
accidentally in rev 1.11 about six years ago, otherwise
fmovel %dN,%fpN instructions cause unexpected memory access.
 1.26.26.1 12-Mar-2007  rmind Sync with HEAD.
 1.26.24.2 31-Jan-2009  bouyer Pull up following revision(s) (requested by tsutsui in ticket #1268):
sys/arch/m68k/fpe/fpu_emulate.c: revision 1.28
In fpu_emul_arith(), check lower 7 bits in word1 rather than only 6 bits
to check 040/060 FP instructions, and don't call fpu_implode() and
fpu_upd_fpsr() if no vaild emulated result is set otherwise these
functions cause NULL pointer dereference.
Fixes panics triggered by 040/060's FDADD instruction
(which has the same lower 6 bits with fscale instruction)
on 020/030 machines (even with 68881/68882) running kernels
with options FPU_EMULATE.
Problem reported by John Carr on port-sun3.
Should be pulled up to netbsd-4-0, netbsd-4 and netbsd-5.
XXX: m68k 4.0 packages binaries on ftp have this FDADD instruction.
 1.26.24.1 31-Mar-2007  bouyer branches: 1.26.24.1.6;
Pull up following revision(s) (requested by tsutsui in ticket #526):
sys/arch/m68k/fpe/fpu_emulate.c: revision 1.27
sys/arch/m68k/fpe/fpu_calcea.c: revision 1.18
sys/arch/m68k/fpe/fpu_fstore.c: revision 1.10
Make these compile with options DEBUG_FPE.
Don't disable EA_DIRECT in fpu_load_ea(), which seems disabled
accidentally in rev 1.11 about six years ago, otherwise
fmovel %dN,%fpN instructions cause unexpected memory access.
 1.26.24.1.6.1 31-Jan-2009  bouyer Pull up following revision(s) (requested by tsutsui in ticket #1268):
sys/arch/m68k/fpe/fpu_emulate.c: revision 1.28
In fpu_emul_arith(), check lower 7 bits in word1 rather than only 6 bits
to check 040/060 FP instructions, and don't call fpu_implode() and
fpu_upd_fpsr() if no vaild emulated result is set otherwise these
functions cause NULL pointer dereference.
Fixes panics triggered by 040/060's FDADD instruction
(which has the same lower 6 bits with fscale instruction)
on 020/030 machines (even with 68881/68882) running kernels
with options FPU_EMULATE.
Problem reported by John Carr on port-sun3.
Should be pulled up to netbsd-4-0, netbsd-4 and netbsd-5.
XXX: m68k 4.0 packages binaries on ftp have this FDADD instruction.
 1.27.54.2 18-Jun-2011  bouyer Pull up following revision(s) (requested by tsutsui in ticket #1626):
sys/arch/m68k/fpe/fpu_emulate.c: revision 1.31
Fix botch in rev 1.28 that causes wrong results of fcmp and ftst in FPE.
fpu_upd_fpsr() should be called even in discard_result case if an emulated
instruction gets proper result without signal.
Fixes weird behavior of awk(1) seen on /etc/rc.d/postfix on XM6i and
TME emulating sun3 without 68881.
Should be pulled up to all netbsd-4 and netbsd-5 branches.
 1.27.54.1 26-Jan-2009  snj branches: 1.27.54.1.2; 1.27.54.1.6;
Pull up following revision(s) (requested by tsutsui in ticket #308):
sys/arch/m68k/fpe/fpu_emulate.c: revision 1.28
In fpu_emul_arith(), check lower 7 bits in word1 rather than only 6 bits
to check 040/060 FP instructions, and don't call fpu_implode() and
fpu_upd_fpsr() if no vaild emulated result is set otherwise these
functions cause NULL pointer dereference.
Fixes panics triggered by 040/060's FDADD instruction
(which has the same lower 6 bits with fscale instruction)
on 020/030 machines (even with 68881/68882) running kernels
with options FPU_EMULATE.
Problem reported by John Carr on port-sun3.
Should be pulled up to netbsd-4-0, netbsd-4 and netbsd-5.
XXX: m68k 4.0 packages binaries on ftp have this FDADD instruction.
 1.27.54.1.6.1 18-Jun-2011  bouyer Pull up following revision(s) (requested by tsutsui in ticket #1626):
sys/arch/m68k/fpe/fpu_emulate.c: revision 1.31
Fix botch in rev 1.28 that causes wrong results of fcmp and ftst in FPE.
fpu_upd_fpsr() should be called even in discard_result case if an emulated
instruction gets proper result without signal.
Fixes weird behavior of awk(1) seen on /etc/rc.d/postfix on XM6i and
TME emulating sun3 without 68881.
Should be pulled up to all netbsd-4 and netbsd-5 branches.
 1.27.54.1.2.1 18-Jun-2011  bouyer Pull up following revision(s) (requested by tsutsui in ticket #1626):
sys/arch/m68k/fpe/fpu_emulate.c: revision 1.31
Fix botch in rev 1.28 that causes wrong results of fcmp and ftst in FPE.
fpu_upd_fpsr() should be called even in discard_result case if an emulated
instruction gets proper result without signal.
Fixes weird behavior of awk(1) seen on /etc/rc.d/postfix on XM6i and
TME emulating sun3 without 68881.
Should be pulled up to all netbsd-4 and netbsd-5 branches.
 1.27.52.2 28-Apr-2009  skrll Sync with HEAD.
 1.27.52.1 03-Mar-2009  skrll Sync with HEAD.
 1.27.44.1 04-May-2009  yamt sync with head.
 1.28.2.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.30.6.1 06-Jun-2011  jruoho Sync with HEAD.
 1.30.4.1 31-May-2011  rmind sync with head
 1.36.12.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.36.12.1 23-Jun-2013  tls resync from head
 1.36.2.1 22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.37.4.1 18-May-2014  rmind sync with head
 1.38.30.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.38.30.1 10-Jun-2019  christos Sync with HEAD
 1.41.6.1 02-Aug-2025  perseant Sync with HEAD
 1.26 06-Dec-2016  isaki Remove fpu_cordit2() and atanh_table[] completely.
Since cordit1 (for trigonometric functions) and cordit2 (for
hyperbolic functions) are very similar, so I implemented both
at first, but I didn't use cordit2 after all :(
 1.25 04-Aug-2016  isaki Move fpu_cordit2() to #ifdef CORDIC_BOOTSTRAP section.
This reduces ~2KB text segment.
Reported by Krister Walfridsson on tech-kern two months ago.
 1.24 19-Apr-2013  isaki branches: 1.24.12; 1.24.16;
Introduce the CORDIC algorithm.
o sine and cosine (e.g., FSIN, FCOS and FSINCOS instructions) is now
calculated in the CORDIC instead of Taylor expansion.
o tangent (FTAN) is not touched from a viewpoint of the code size.
o The CORDIC is applicable for hyperbolic functions (e.g., FSINH,
FCOSH, FTANH instructions), but I didn't use it because its working
range is poor.
o The CORDIC is also usable for inverse trigonometric functions,
I will commit it at next phase.
o The code size becomes a bit big. I cannot evaluate speed on m68k
for some reasons, but in test on i386 the CORDIC is approximately
100 times faster in sin/cos.
 1.23 11-Apr-2013  isaki Introduce FPU_CONST_* constants to avoid a magic number.
 1.22 26-Mar-2013  isaki u_int -> uint32_t
 1.21 19-Mar-2013  isaki const-ify.
 1.20 19-Mar-2013  isaki Remove 'register'.
 1.19 15-Oct-2011  tsutsui branches: 1.19.2; 1.19.12;
- remove variable names from function declarations
- some KNF
 1.18 15-Oct-2011  tsutsui Add hyperboric and trigonometric functions to m68k FPE, written by isaki@.
With these emulations (~4KB text) xeyes on XM6i works better.
Discussed with isaki@ at OSC 2011 Hiroshima.
 1.17 09-Oct-2011  tsutsui Use static inline structure assignment for CPYFPN(). From isaki@.
Tested on XM6i.
 1.16 18-Jul-2011  isaki fix indent. no functional changes.
 1.15 14-Mar-2009  dsl Remove all the __P() from sys (excluding sys/dist)
Diff checked with grep and MK1 eyeball.
i386 and amd64 GENERIC and sys still build.
 1.14 27-Jan-2009  martin branches: 1.14.2;
fix include path in previous
 1.13 27-Jan-2009  martin Move FPSR_ register bit definitions into their own file
 1.12 11-Dec-2005  christos branches: 1.12.78; 1.12.86; 1.12.88;
merge ktrace-lwp.
 1.11 13-Aug-2005  he Include <sys/time.h> before <sys/signalvar.h> so that copyinout_t is
defined before it is used in the second of these.

Fixes a build problem for several of our m68k ports. I've been
waiting for a better fix, but now my "proper fix timeout" triggered.
 1.10 22-Sep-2003  cl branches: 1.10.16;
SA_SIGINFO support for m68k
 1.9 05-Jul-2001  toshii branches: 1.9.8; 1.9.24;
Fix typo. s/extention/extension/
 1.8 18-Feb-2001  chs rename round() to fpu_round() to avoid a name conflict with
the "round" assembly function in FPSP when building with ELF.
 1.7 22-Sep-2000  is fpu_emulate.h:
the fmovecr constant table has the internal format
of the constants. So, when changing the mantissa size by a
non-multiple of 32 bits, we'd have to change this table, too. As
all other code changes just chopped of the least significand
32bit word of the mantissa, we correct the mantissa size instead
to (115 - 32 == 83) bits.
fpu_fmovecr.c:
put a safety belt in, to catch the next person who doesn't know this.
fpu_int.c:
in one place, the reduction of the mantissa size was overlooked.
fpu_log.c:
as the most significand 32bit word of the mantissa was changed back to the
old format, change back the table indexing code, too.

This should fix PR 11045.
 1.6 19-Sep-2000  minoura Correct comments.
 1.5 30-May-1999  briggs branches: 1.5.2; 1.5.12;
PR 7220 from Ken Nakata:
I've fixed most (not all) m68k FPE bugs that give bogus
calculation results, esp. fsqrt instruction. Also, the internal FP
representation has been reduced from 115-bit mantissa to 67-bit
mantissa which reduced the required mantissa operation roughly by one
fourth. I've done an extensive (though not exhaustive - it's
impossible!) test on the internal routines by feeding them randomly
generated FP numbers, and found that the new code is more precise than
MC68040 FPU (it seems to have a rounding bug).

[ Only change was to keep fpu_calcea.c's name instead of renaming to
fpu_ea.c in Ken's patch. --akb ]
 1.4 30-Apr-1996  briggs branches: 1.4.24; 1.4.26; 1.4.28;
Update for -Wall -Wstrict-prototypes -Wmissing-prototypes -Wno-uninitialized.
 1.3 12-Jan-1996  briggs Remove explicit #define of DEBUG, per PR #1931.
 1.2 05-Nov-1995  briggs Fixes from Ken Nakata. Mainly renaming debug_level to fpu_debug_level.
 1.1 03-Nov-1995  briggs Still incomplete, but much more complete FPE from Ken Nakata
<kenn@remus.rutgers.edu>. This emulator does not yet emulate
the following functions:
FSINH, FETOXM1, FTANH, FATAN, FASIN, FATANH, FSIN, FTAN,
FETOX, FTWOTOX, FTENTOX, FCOSH, FACOS, FCOS, FSINCOS
It is sufficient, however, to allow programs like df, w, and newfs,
to run to completion with correct results.
Portions of this code were based on the sparc fpe and on initial
work by gwr.
 1.4.28.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.4.26.1 21-Jun-1999  thorpej Sync w/ -current.
 1.4.24.2 06-Feb-2000  he Apply patch (requested by is):
Revert floating point emulation software to the version released
as NetBSD 1.4. The upgrade done in 1.4.1 had problems.
 1.4.24.1 21-Jun-1999  perry pullup 1.4->1.5 (briggs): fix FPE
 1.5.12.2 26-Sep-2000  is Pullup from -current, requested by is, approved by thorpej:

fpu_emulate.h 1.7, fpu_log.c 1.7: synchronize mantissa length % 32 with fpu_fmovecr.c table
fpu_fmovecr.c 1.8: cheap compile-time consistency check for this
fpu_int.c 1.3: fix bug introduced when reducing mantissa size
This fixes PR 11045.
 1.5.12.1 19-Sep-2000  minoura Correct comments.
 1.5.2.2 12-Mar-2001  bouyer Sync with HEAD.
 1.5.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.9.24.4 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.9.24.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.9.24.2 18-Sep-2004  skrll Sync with HEAD.
 1.9.24.1 03-Aug-2004  skrll Sync with HEAD
 1.9.8.2 05-Jul-2001  toshii Fix typo. s/extention/extension/
 1.9.8.1 05-Jul-2001  toshii file fpu_emulate.h was added on branch nathanw_sa on 2001-07-05 08:38:26 +0000
 1.10.16.1 21-Jun-2006  yamt sync with head.
 1.12.88.2 02-Feb-2009  snj Pull up following revision(s) (requested by martin in ticket #332):
sys/arch/m68k/fpe/fpu_emulate.h: revision 1.14
fix include path in previous
 1.12.88.1 02-Feb-2009  snj Pull up following revision(s) (requested by martin in ticket #332):
sys/arch/m68k/fpe/fpu_emulate.h: revision 1.13
sys/arch/m68k/include/fpreg.h: revision 1.1
Move FPSR_ register bit definitions into their own file
 1.12.86.2 28-Apr-2009  skrll Sync with HEAD.
 1.12.86.1 03-Mar-2009  skrll Sync with HEAD.
 1.12.78.1 04-May-2009  yamt sync with head.
 1.14.2.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.19.12.2 03-Dec-2017  jdolecek update from HEAD
 1.19.12.1 23-Jun-2013  tls resync from head
 1.19.2.1 22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.24.16.2 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.24.16.1 06-Aug-2016  pgoyette Sync with HEAD
 1.24.12.2 05-Feb-2017  skrll Sync with HEAD
 1.24.12.1 05-Oct-2016  skrll Sync with HEAD
 1.11 15-Jan-2017  isaki exp(>11356) is +inf even if extended precision.
exp(<-11401) is 0 even if extended precision.
 1.10 07-Dec-2016  isaki Fix sign of zero in case of x > -(2^18).
# By the way, I will modify this case later.
 1.9 05-Dec-2016  isaki Improve the exponential and hyperbolic function's performance
10..100 times faster.
PR port-m68k/51645 from rin@ (and modified by me)
 1.8 20-Apr-2013  isaki branches: 1.8.12; 1.8.16;
Terminate a loop in EXT_FRACBITS(64bits) instead of FP_NMANT(83bits).
I don't know why the mantissa of the accumulator is 83bits, but 64bits
or more are not affected.
 1.7 20-Apr-2013  isaki Break a loop off to avoid a long loop even if the precision is not enough.
 1.6 20-Apr-2013  isaki Implement exponential and power functions.
o FETOX .. exp(x)
o FETOXM1 .. exp(x) - 1
o FTENTOX .. 10^x
o FTWOTOX .. 2^x
At last all mathematics functions of FPE were implemented.
Thanks to Yosuke Sugahara.
 1.5 18-Jul-2011  isaki branches: 1.5.2; 1.5.12;
fix indent. no functional changes.
 1.4 14-Mar-2009  dsl Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.3 11-Dec-2005  christos branches: 1.3.78; 1.3.86; 1.3.92;
merge ktrace-lwp.
 1.2 15-Jul-2003  lukem __KERNEL_RCSID()
 1.1 03-Nov-1995  briggs branches: 1.1.64;
Still incomplete, but much more complete FPE from Ken Nakata
<kenn@remus.rutgers.edu>. This emulator does not yet emulate
the following functions:
FSINH, FETOXM1, FTANH, FATAN, FASIN, FATANH, FSIN, FTAN,
FETOX, FTWOTOX, FTENTOX, FCOSH, FACOS, FCOS, FSINCOS
It is sufficient, however, to allow programs like df, w, and newfs,
to run to completion with correct results.
Portions of this code were based on the sparc fpe and on initial
work by gwr.
 1.1.64.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.1.64.2 18-Sep-2004  skrll Sync with HEAD.
 1.1.64.1 03-Aug-2004  skrll Sync with HEAD
 1.3.92.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.3.86.1 28-Apr-2009  skrll Sync with HEAD.
 1.3.78.1 04-May-2009  yamt sync with head.
 1.5.12.2 03-Dec-2017  jdolecek update from HEAD
 1.5.12.1 23-Jun-2013  tls resync from head
 1.5.2.1 22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.8.16.2 20-Mar-2017  pgoyette Sync with HEAD
 1.8.16.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.8.12.1 05-Feb-2017  skrll Sync with HEAD
 1.16 08-Mar-2021  isaki Remove incorrect byte and word conversions from fpu_explode.
The correct operation here is arithmetic right shift, but nobody calls it.
 1.15 05-Feb-2015  isaki branches: 1.15.30;
For the extended precision, the MSB of the mantissa is an integer
part, and this bit must be ignored at Infinity.
found by tests/lib/libc/stdlib/t_strtod.c::strtold_inf.
 1.14 26-Mar-2013  isaki branches: 1.14.12;
u_int -> uint32_t
 1.13 19-Mar-2013  isaki const-ify.
 1.12 19-Mar-2013  isaki Remove 'register'.
 1.11 18-Jul-2011  isaki branches: 1.11.2; 1.11.12;
fix indent. no functional changes.
 1.10 14-Mar-2009  dsl ANSIfy another 1261 function definitions.
The only ones left in sys are beyond by sed script!
(or in sys/dist or sys/external)
Mostly they have function pointer parameters.
 1.9 14-Mar-2009  dsl Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.8 14-Mar-2009  dsl Remove all the __P() from sys (excluding sys/dist)
Diff checked with grep and MK1 eyeball.
i386 and amd64 GENERIC and sys still build.
 1.7 11-Dec-2005  christos branches: 1.7.78; 1.7.86; 1.7.92;
merge ktrace-lwp.
 1.6 23-Oct-2003  kleink While I'm here, retire the FPE code's own copy of ieee.h.
 1.5 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.4 15-Jul-2003  lukem __KERNEL_RCSID()
 1.3 30-May-1999  briggs branches: 1.3.36;
PR 7220 from Ken Nakata:
I've fixed most (not all) m68k FPE bugs that give bogus
calculation results, esp. fsqrt instruction. Also, the internal FP
representation has been reduced from 115-bit mantissa to 67-bit
mantissa which reduced the required mantissa operation roughly by one
fourth. I've done an extensive (though not exhaustive - it's
impossible!) test on the internal routines by feeding them randomly
generated FP numbers, and found that the new code is more precise than
MC68040 FPU (it seems to have a rounding bug).

[ Only change was to keep fpu_calcea.c's name instead of renaming to
fpu_ea.c in Ken's patch. --akb ]
 1.2 30-Apr-1996  briggs branches: 1.2.24; 1.2.26; 1.2.28;
Update for -Wall -Wstrict-prototypes -Wmissing-prototypes -Wno-uninitialized.
 1.1 03-Nov-1995  briggs Still incomplete, but much more complete FPE from Ken Nakata
<kenn@remus.rutgers.edu>. This emulator does not yet emulate
the following functions:
FSINH, FETOXM1, FTANH, FATAN, FASIN, FATANH, FSIN, FTAN,
FETOX, FTWOTOX, FTENTOX, FCOSH, FACOS, FCOS, FSINCOS
It is sufficient, however, to allow programs like df, w, and newfs,
to run to completion with correct results.
Portions of this code were based on the sparc fpe and on initial
work by gwr.
 1.2.28.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.2.26.1 21-Jun-1999  thorpej Sync w/ -current.
 1.2.24.2 06-Feb-2000  he Apply patch (requested by is):
Revert floating point emulation software to the version released
as NetBSD 1.4. The upgrade done in 1.4.1 had problems.
 1.2.24.1 21-Jun-1999  perry pullup 1.2->1.3 (briggs): fix FPE
 1.3.36.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.3.36.2 18-Sep-2004  skrll Sync with HEAD.
 1.3.36.1 03-Aug-2004  skrll Sync with HEAD
 1.7.92.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.7.86.1 28-Apr-2009  skrll Sync with HEAD.
 1.7.78.1 04-May-2009  yamt sync with head.
 1.11.12.2 03-Dec-2017  jdolecek update from HEAD
 1.11.12.1 23-Jun-2013  tls resync from head
 1.11.2.1 22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.14.12.1 06-Apr-2015  skrll Sync with HEAD
 1.15.30.1 03-Apr-2021  thorpej Sync with HEAD.
 1.16 26-Mar-2013  isaki u_int -> uint32_t
 1.15 23-Mar-2013  isaki Use the #error directive.
 1.14 18-Jul-2011  isaki branches: 1.14.2; 1.14.12;
fix indent again.
- "Second level indents are four spaces." pointed out by tsutsui@
- fold long line.
 1.13 18-Jul-2011  isaki fix indent. no functional changes.
 1.12 14-Mar-2009  dsl Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.11 11-Dec-2005  christos branches: 1.11.78; 1.11.86; 1.11.92;
merge ktrace-lwp.
 1.10 15-Jul-2003  lukem __KERNEL_RCSID()
 1.9 27-Sep-2002  provos branches: 1.9.6;
remove trailing \n in panic(). approved perry.
 1.8 22-Sep-2000  is branches: 1.8.4; 1.8.8;
fpu_emulate.h:
the fmovecr constant table has the internal format
of the constants. So, when changing the mantissa size by a
non-multiple of 32 bits, we'd have to change this table, too. As
all other code changes just chopped of the least significand
32bit word of the mantissa, we correct the mantissa size instead
to (115 - 32 == 83) bits.
fpu_fmovecr.c:
put a safety belt in, to catch the next person who doesn't know this.
fpu_int.c:
in one place, the reduction of the mantissa size was overlooked.
fpu_log.c:
as the most significand 32bit word of the mantissa was changed back to the
old format, change back the table indexing code, too.

This should fix PR 11045.
 1.7 30-May-1999  briggs branches: 1.7.2; 1.7.12;
PR 7220 from Ken Nakata:
I've fixed most (not all) m68k FPE bugs that give bogus
calculation results, esp. fsqrt instruction. Also, the internal FP
representation has been reduced from 115-bit mantissa to 67-bit
mantissa which reduced the required mantissa operation roughly by one
fourth. I've done an extensive (though not exhaustive - it's
impossible!) test on the internal routines by feeding them randomly
generated FP numbers, and found that the new code is more precise than
MC68040 FPU (it seems to have a rounding bug).

[ Only change was to keep fpu_calcea.c's name instead of renaming to
fpu_ea.c in Ken's patch. --akb ]
 1.6 13-Oct-1996  christos branches: 1.6.22; 1.6.24; 1.6.26;
backout previous kprintf change
 1.5 11-Oct-1996  christos printf -> kprintf, sprintf -> ksprintf
 1.4 30-Apr-1996  briggs Update for -Wall -Wstrict-prototypes -Wmissing-prototypes -Wno-uninitialized.
 1.3 04-Feb-1996  briggs sys/types.h -> sys/param.h and remove include of stddef.h.
 1.2 05-Nov-1995  briggs Fixes from Ken Nakata. Mainly renaming debug_level to fpu_debug_level.
 1.1 03-Nov-1995  briggs Still incomplete, but much more complete FPE from Ken Nakata
<kenn@remus.rutgers.edu>. This emulator does not yet emulate
the following functions:
FSINH, FETOXM1, FTANH, FATAN, FASIN, FATANH, FSIN, FTAN,
FETOX, FTWOTOX, FTENTOX, FCOSH, FACOS, FCOS, FSINCOS
It is sufficient, however, to allow programs like df, w, and newfs,
to run to completion with correct results.
Portions of this code were based on the sparc fpe and on initial
work by gwr.
 1.6.26.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.6.24.1 21-Jun-1999  thorpej Sync w/ -current.
 1.6.22.2 06-Feb-2000  he Apply patch (requested by is):
Revert floating point emulation software to the version released
as NetBSD 1.4. The upgrade done in 1.4.1 had problems.
 1.6.22.1 21-Jun-1999  perry pullup 1.6->1.7 (briggs): fix FPE
 1.7.12.1 26-Sep-2000  is Pullup from -current, requested by is, approved by thorpej:

fpu_emulate.h 1.7, fpu_log.c 1.7: synchronize mantissa length % 32 with fpu_fmovecr.c table
fpu_fmovecr.c 1.8: cheap compile-time consistency check for this
fpu_int.c 1.3: fix bug introduced when reducing mantissa size
This fixes PR 11045.
 1.7.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.8.8.1 18-Oct-2002  nathanw Catch up to -current.
 1.8.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.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.92.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.11.86.1 28-Apr-2009  skrll Sync with HEAD.
 1.11.78.1 04-May-2009  yamt sync with head.
 1.14.12.1 23-Jun-2013  tls resync from head
 1.14.2.1 22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.17 06-Jan-2025  isaki m68k/fpe: Avoid an illegal mod/reg before decoding it.
This also works for machines with FPU.
If the kernel defines FPU_EMULATE, even illegal FPU instructions in the real
6888x machines, the FPE will be executed by F line exception. So the FPE
must raise SIGILL appropriately for these.
 1.16 26-Mar-2013  isaki branches: 1.16.72;
u_int -> uint32_t
 1.15 18-Jul-2011  isaki branches: 1.15.2; 1.15.12;
fix indent again.
- "Second level indents are four spaces." pointed out by tsutsui@
- fold long line.
 1.14 18-Jul-2011  isaki fix indent. no functional changes.
 1.13 14-Mar-2009  dsl Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.12 11-Dec-2005  christos branches: 1.12.78; 1.12.86; 1.12.92;
merge ktrace-lwp.
 1.11 15-Jul-2003  lukem __KERNEL_RCSID()
 1.10 30-May-1999  briggs branches: 1.10.36;
PR 7220 from Ken Nakata:
I've fixed most (not all) m68k FPE bugs that give bogus
calculation results, esp. fsqrt instruction. Also, the internal FP
representation has been reduced from 115-bit mantissa to 67-bit
mantissa which reduced the required mantissa operation roughly by one
fourth. I've done an extensive (though not exhaustive - it's
impossible!) test on the internal routines by feeding them randomly
generated FP numbers, and found that the new code is more precise than
MC68040 FPU (it seems to have a rounding bug).

[ Only change was to keep fpu_calcea.c's name instead of renaming to
fpu_ea.c in Ken's patch. --akb ]
 1.9 03-Nov-1997  is branches: 1.9.8; 1.9.10; 1.9.12;
Back out last change, which was a thinko.
 1.8 02-Nov-1997  is Add ftwotox emulation, by using the fscale emulation routine (preload
destination register bit pattern with 1.0), which automatically provides
corner case handling.
Missing ftwotox emulation originally reported by Norman Mackenzie in PR 4237,
but he proposed a different implementation.
 1.7 09-Oct-1997  is Don't forget to set the scale variable even if we dont need to sign-extend it.
From PR 4236 by Norman Mackenzie.
 1.6 13-Oct-1996  christos branches: 1.6.10;
backout previous kprintf change
 1.5 11-Oct-1996  christos printf -> kprintf, sprintf -> ksprintf
 1.4 15-May-1996  leo Fix "might be used uninitialized" warnings.
 1.3 30-Apr-1996  briggs Update for -Wall -Wstrict-prototypes -Wmissing-prototypes -Wno-uninitialized.
 1.2 05-Nov-1995  briggs Fixes from Ken Nakata. Mainly renaming debug_level to fpu_debug_level.
 1.1 03-Nov-1995  briggs Still incomplete, but much more complete FPE from Ken Nakata
<kenn@remus.rutgers.edu>. This emulator does not yet emulate
the following functions:
FSINH, FETOXM1, FTANH, FATAN, FASIN, FATANH, FSIN, FTAN,
FETOX, FTWOTOX, FTENTOX, FCOSH, FACOS, FCOS, FSINCOS
It is sufficient, however, to allow programs like df, w, and newfs,
to run to completion with correct results.
Portions of this code were based on the sparc fpe and on initial
work by gwr.
 1.6.10.1 14-Oct-1997  thorpej Update marc-pcmcia branch from trunk.
 1.9.12.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.9.10.1 21-Jun-1999  thorpej Sync w/ -current.
 1.9.8.2 06-Feb-2000  he Apply patch (requested by is):
Revert floating point emulation software to the version released
as NetBSD 1.4. The upgrade done in 1.4.1 had problems.
 1.9.8.1 21-Jun-1999  perry pullup 1.9->1.10 (briggs): fix FPE
 1.10.36.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.10.36.2 18-Sep-2004  skrll Sync with HEAD.
 1.10.36.1 03-Aug-2004  skrll Sync with HEAD
 1.12.92.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.12.86.1 28-Apr-2009  skrll Sync with HEAD.
 1.12.78.1 04-May-2009  yamt sync with head.
 1.15.12.1 23-Jun-2013  tls resync from head
 1.15.2.1 22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.16.72.1 02-Aug-2025  perseant Sync with HEAD
 1.17 06-Jan-2025  isaki m68k/fpe: Remove redundant code.
This was assigned before the function was called.
 1.16 03-Jan-2025  isaki m68k/fpe: Check an illegal mod/reg before decoding it.
This avoids a kernel panic if an instruction has illegal mod/reg bits
like FMOVE.X FPn,#imm (Of course normally assemblers never emit these).
XXX Other instructions probably need such treatment...
 1.15 03-Jan-2025  isaki m68k/fpe: Add a missing return.
FMOVE.P FPn,<ea> now raises SIGFPE. (Our FPE doesn't support .P)
 1.14 26-Mar-2013  isaki branches: 1.14.72;
u_int -> uint32_t
 1.13 18-Jul-2011  isaki branches: 1.13.2; 1.13.12;
fix indent again.
- "Second level indents are four spaces." pointed out by tsutsui@
- fold long line.
 1.12 18-Jul-2011  isaki fix indent. no functional changes.
 1.11 14-Mar-2009  dsl Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.10 09-Mar-2007  tsutsui branches: 1.10.44; 1.10.52; 1.10.58;
Make these compile with options DEBUG_FPE.
 1.9 11-Dec-2005  christos branches: 1.9.24; 1.9.26;
merge ktrace-lwp.
 1.8 15-Jul-2003  lukem branches: 1.8.14; 1.8.16;
__KERNEL_RCSID()
 1.7 30-May-1999  briggs branches: 1.7.36;
PR 7220 from Ken Nakata:
I've fixed most (not all) m68k FPE bugs that give bogus
calculation results, esp. fsqrt instruction. Also, the internal FP
representation has been reduced from 115-bit mantissa to 67-bit
mantissa which reduced the required mantissa operation roughly by one
fourth. I've done an extensive (though not exhaustive - it's
impossible!) test on the internal routines by feeding them randomly
generated FP numbers, and found that the new code is more precise than
MC68040 FPU (it seems to have a rounding bug).

[ Only change was to keep fpu_calcea.c's name instead of renaming to
fpu_ea.c in Ken's patch. --akb ]
 1.6 19-Jul-1997  is branches: 1.6.14; 1.6.16; 1.6.18;
Fix my own PR port-m68k/3871, nee port-amiga/3871:
- don't erase FPSR exception bits _after_ doing most of the operations in
fpu_implode(), erase them before doing arith and store operations. This fixes
losing the DZ bit.
- create FPSR_OVFL and FPSR_UNFL bits in fpu_implode(). This showed up when
the first error was fixed.
XXX some more work needs to be done. E.g., creating OPERR together with
OVFL looks bogus, but I'm too tired know to re-check docs; and at least we
pass our own regression tests know.
 1.5 13-Oct-1996  christos backout previous kprintf change
 1.4 11-Oct-1996  christos printf -> kprintf, sprintf -> ksprintf
 1.3 30-Apr-1996  briggs Update for -Wall -Wstrict-prototypes -Wmissing-prototypes -Wno-uninitialized.
 1.2 05-Nov-1995  briggs Fixes from Ken Nakata. Mainly renaming debug_level to fpu_debug_level.
 1.1 03-Nov-1995  briggs Still incomplete, but much more complete FPE from Ken Nakata
<kenn@remus.rutgers.edu>. This emulator does not yet emulate
the following functions:
FSINH, FETOXM1, FTANH, FATAN, FASIN, FATANH, FSIN, FTAN,
FETOX, FTWOTOX, FTENTOX, FCOSH, FACOS, FCOS, FSINCOS
It is sufficient, however, to allow programs like df, w, and newfs,
to run to completion with correct results.
Portions of this code were based on the sparc fpe and on initial
work by gwr.
 1.6.18.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.6.16.1 21-Jun-1999  thorpej Sync w/ -current.
 1.6.14.2 06-Feb-2000  he Apply patch (requested by is):
Revert floating point emulation software to the version released
as NetBSD 1.4. The upgrade done in 1.4.1 had problems.
 1.6.14.1 21-Jun-1999  perry pullup 1.6->1.7 (briggs): fix FPE
 1.7.36.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.7.36.2 18-Sep-2004  skrll Sync with HEAD.
 1.7.36.1 03-Aug-2004  skrll Sync with HEAD
 1.8.16.1 03-Sep-2007  yamt sync with head.
 1.8.14.1 31-Mar-2007  bouyer Pull up following revision(s) (requested by tsutsui in ticket #1703):
sys/arch/m68k/fpe/fpu_emulate.c: revision 1.27
sys/arch/m68k/fpe/fpu_calcea.c: revision 1.18
sys/arch/m68k/fpe/fpu_fstore.c: revision 1.10
Make these compile with options DEBUG_FPE.
Don't disable EA_DIRECT in fpu_load_ea(), which seems disabled
accidentally in rev 1.11 about six years ago, otherwise
fmovel %dN,%fpN instructions cause unexpected memory access.
 1.9.26.1 12-Mar-2007  rmind Sync with HEAD.
 1.9.24.1 31-Mar-2007  bouyer Pull up following revision(s) (requested by tsutsui in ticket #526):
sys/arch/m68k/fpe/fpu_emulate.c: revision 1.27
sys/arch/m68k/fpe/fpu_calcea.c: revision 1.18
sys/arch/m68k/fpe/fpu_fstore.c: revision 1.10
Make these compile with options DEBUG_FPE.
Don't disable EA_DIRECT in fpu_load_ea(), which seems disabled
accidentally in rev 1.11 about six years ago, otherwise
fmovel %dN,%fpN instructions cause unexpected memory access.
 1.10.58.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.10.52.1 28-Apr-2009  skrll Sync with HEAD.
 1.10.44.1 04-May-2009  yamt sync with head.
 1.13.12.1 23-Jun-2013  tls resync from head
 1.13.2.1 22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.14.72.1 02-Aug-2025  perseant Sync with HEAD
 1.5 18-Jul-2011  isaki fix indent. no functional changes.
 1.4 14-Mar-2009  dsl Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.3 11-Dec-2005  christos branches: 1.3.78; 1.3.86; 1.3.92;
merge ktrace-lwp.
 1.2 15-Jul-2003  lukem __KERNEL_RCSID()
 1.1 03-Nov-1995  briggs branches: 1.1.64;
Still incomplete, but much more complete FPE from Ken Nakata
<kenn@remus.rutgers.edu>. This emulator does not yet emulate
the following functions:
FSINH, FETOXM1, FTANH, FATAN, FASIN, FATANH, FSIN, FTAN,
FETOX, FTWOTOX, FTENTOX, FCOSH, FACOS, FCOS, FSINCOS
It is sufficient, however, to allow programs like df, w, and newfs,
to run to completion with correct results.
Portions of this code were based on the sparc fpe and on initial
work by gwr.
 1.1.64.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.1.64.2 18-Sep-2004  skrll Sync with HEAD.
 1.1.64.1 03-Aug-2004  skrll Sync with HEAD
 1.3.92.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.3.86.1 28-Apr-2009  skrll Sync with HEAD.
 1.3.78.1 04-May-2009  yamt sync with head.
 1.17 05-Dec-2016  isaki Improve the exponential and hyperbolic function's performance
10..100 times faster.
PR port-m68k/51645 from rin@ (and modified by me)
 1.16 11-Oct-2013  isaki branches: 1.16.6; 1.16.10;
FATANH(-0) is -0, not +0.
This bug was introduced by the mistake of my test program.
Last week, I talked about the probelm (my FATANH(-0) returns +0 ?)
by NetBSD seminar at Open Source Conference 2013 Hiroshima,
and tsutsui@ confirmed that returns -0.
 1.15 20-Apr-2013  isaki branches: 1.15.4;
Support sinh(-0.0) and tanh(-0.0).
 1.14 20-Apr-2013  isaki Clean up some useless codes.
 1.13 20-Apr-2013  isaki Fix typo in comment.
 1.12 20-Apr-2013  isaki Terminate a loop in EXT_FRACBITS(64bits) instead of FP_NMANT(83bits).
I don't know why the mantissa of the accumulator is 83bits, but 64bits
or more are not affected.
 1.11 20-Apr-2013  isaki Break a loop off to avoid a long loop even if the precision is not enough.
 1.10 19-Apr-2013  isaki Implement a hyperbolic arctangent (FATANH).
 1.9 19-Apr-2013  isaki Introduce the CORDIC algorithm.
o sine and cosine (e.g., FSIN, FCOS and FSINCOS instructions) is now
calculated in the CORDIC instead of Taylor expansion.
o tangent (FTAN) is not touched from a viewpoint of the code size.
o The CORDIC is applicable for hyperbolic functions (e.g., FSINH,
FCOSH, FTANH instructions), but I didn't use it because its working
range is poor.
o The CORDIC is also usable for inverse trigonometric functions,
I will commit it at next phase.
o The code size becomes a bit big. I cannot evaluate speed on m68k
for some reasons, but in test on i386 the CORDIC is approximately
100 times faster in sin/cos.
 1.8 11-Apr-2013  isaki Introduce FPU_CONST_* constants to avoid a magic number.
 1.7 23-Mar-2013  isaki Remove about updating fpsr. It was introduced by me but obviously
duplicated with fpu_emul_arith().
 1.6 15-Oct-2011  tsutsui branches: 1.6.2; 1.6.12;
Add hyperboric and trigonometric functions to m68k FPE, written by isaki@.
With these emulations (~4KB text) xeyes on XM6i works better.
Discussed with isaki@ at OSC 2011 Hiroshima.
 1.5 18-Jul-2011  isaki fix indent. no functional changes.
 1.4 14-Mar-2009  dsl Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.3 11-Dec-2005  christos branches: 1.3.78; 1.3.86; 1.3.92;
merge ktrace-lwp.
 1.2 15-Jul-2003  lukem __KERNEL_RCSID()
 1.1 03-Nov-1995  briggs branches: 1.1.64;
Still incomplete, but much more complete FPE from Ken Nakata
<kenn@remus.rutgers.edu>. This emulator does not yet emulate
the following functions:
FSINH, FETOXM1, FTANH, FATAN, FASIN, FATANH, FSIN, FTAN,
FETOX, FTWOTOX, FTENTOX, FCOSH, FACOS, FCOS, FSINCOS
It is sufficient, however, to allow programs like df, w, and newfs,
to run to completion with correct results.
Portions of this code were based on the sparc fpe and on initial
work by gwr.
 1.1.64.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.1.64.2 18-Sep-2004  skrll Sync with HEAD.
 1.1.64.1 03-Aug-2004  skrll Sync with HEAD
 1.3.92.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.3.86.1 28-Apr-2009  skrll Sync with HEAD.
 1.3.78.1 04-May-2009  yamt sync with head.
 1.6.12.3 03-Dec-2017  jdolecek update from HEAD
 1.6.12.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.6.12.1 23-Jun-2013  tls resync from head
 1.6.2.1 22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.15.4.1 18-May-2014  rmind sync with head
 1.16.10.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.16.6.1 05-Feb-2017  skrll Sync with HEAD
 1.15 26-Mar-2013  isaki u_int -> uint32_t
 1.14 22-Mar-2013  isaki Fix fpu_ftox().
Update not only exponential but also mantissa when an integer part
becomes 2 by rounding up. Without this fix, the extended precision
value becomes 0.0 because mantissa (including explicit integer bit)
is all-zero.
 1.13 19-Mar-2013  isaki Remove 'register'.
 1.12 18-Jul-2011  isaki branches: 1.12.2; 1.12.12;
fix indent. no functional changes.
 1.11 14-Mar-2009  dsl Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.10 14-Mar-2009  dsl Remove all the __P() from sys (excluding sys/dist)
Diff checked with grep and MK1 eyeball.
i386 and amd64 GENERIC and sys still build.
 1.9 11-Dec-2005  christos branches: 1.9.78; 1.9.86; 1.9.92;
merge ktrace-lwp.
 1.8 23-Oct-2003  kleink While I'm here, retire the FPE code's own copy of ieee.h.
 1.7 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.6 15-Jul-2003  lukem __KERNEL_RCSID()
 1.5 18-Feb-2001  chs branches: 1.5.24;
rename round() to fpu_round() to avoid a name conflict with
the "round" assembly function in FPSP when building with ELF.
 1.4 30-May-1999  briggs branches: 1.4.2;
PR 7220 from Ken Nakata:
I've fixed most (not all) m68k FPE bugs that give bogus
calculation results, esp. fsqrt instruction. Also, the internal FP
representation has been reduced from 115-bit mantissa to 67-bit
mantissa which reduced the required mantissa operation roughly by one
fourth. I've done an extensive (though not exhaustive - it's
impossible!) test on the internal routines by feeding them randomly
generated FP numbers, and found that the new code is more precise than
MC68040 FPU (it seems to have a rounding bug).

[ Only change was to keep fpu_calcea.c's name instead of renaming to
fpu_ea.c in Ken's patch. --akb ]
 1.3 19-Jul-1997  is branches: 1.3.14; 1.3.16; 1.3.18;
Fix my own PR port-m68k/3871, nee port-amiga/3871:
- don't erase FPSR exception bits _after_ doing most of the operations in
fpu_implode(), erase them before doing arith and store operations. This fixes
losing the DZ bit.
- create FPSR_OVFL and FPSR_UNFL bits in fpu_implode(). This showed up when
the first error was fixed.
XXX some more work needs to be done. E.g., creating OPERR together with
OVFL looks bogus, but I'm too tired know to re-check docs; and at least we
pass our own regression tests know.
 1.2 30-Apr-1996  briggs Update for -Wall -Wstrict-prototypes -Wmissing-prototypes -Wno-uninitialized.
 1.1 03-Nov-1995  briggs Still incomplete, but much more complete FPE from Ken Nakata
<kenn@remus.rutgers.edu>. This emulator does not yet emulate
the following functions:
FSINH, FETOXM1, FTANH, FATAN, FASIN, FATANH, FSIN, FTAN,
FETOX, FTWOTOX, FTENTOX, FCOSH, FACOS, FCOS, FSINCOS
It is sufficient, however, to allow programs like df, w, and newfs,
to run to completion with correct results.
Portions of this code were based on the sparc fpe and on initial
work by gwr.
 1.3.18.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.3.16.1 21-Jun-1999  thorpej Sync w/ -current.
 1.3.14.2 06-Feb-2000  he Apply patch (requested by is):
Revert floating point emulation software to the version released
as NetBSD 1.4. The upgrade done in 1.4.1 had problems.
 1.3.14.1 21-Jun-1999  perry pullup 1.3->1.4 (briggs): fix FPE
 1.4.2.1 12-Mar-2001  bouyer Sync with HEAD.
 1.5.24.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.5.24.2 18-Sep-2004  skrll Sync with HEAD.
 1.5.24.1 03-Aug-2004  skrll Sync with HEAD
 1.9.92.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.9.86.1 28-Apr-2009  skrll Sync with HEAD.
 1.9.78.1 04-May-2009  yamt sync with head.
 1.12.12.1 23-Jun-2013  tls resync from head
 1.12.2.1 22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.12 19-Mar-2013  isaki Remove 'register'.
 1.11 25-Jun-2012  isaki branches: 1.11.2;
Rewrite fpu_int().
Especially, remove the special treatment when |x| < 1
because it forgets to consider FPCR round mode.
See PR/46627 for the detail. Thanks Y.Sugahara for advice.
 1.10 18-Jul-2011  isaki branches: 1.10.2; 1.10.8;
fix indent again.
- "Second level indents are four spaces." pointed out by tsutsui@
- fold long line.
 1.9 18-Jul-2011  isaki fix indent. no functional changes.
 1.8 14-Mar-2009  dsl Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.7 11-Dec-2005  christos branches: 1.7.78; 1.7.86; 1.7.92;
merge ktrace-lwp.
 1.6 15-Jul-2003  lukem __KERNEL_RCSID()
 1.5 30-May-2002  thorpej branches: 1.5.6;
Fix undefined operation (= is not a sequence point).
 1.4 18-Feb-2001  chs branches: 1.4.4; 1.4.8; 1.4.16;
rename round() to fpu_round() to avoid a name conflict with
the "round" assembly function in FPSP when building with ELF.
 1.3 22-Sep-2000  is fpu_emulate.h:
the fmovecr constant table has the internal format
of the constants. So, when changing the mantissa size by a
non-multiple of 32 bits, we'd have to change this table, too. As
all other code changes just chopped of the least significand
32bit word of the mantissa, we correct the mantissa size instead
to (115 - 32 == 83) bits.
fpu_fmovecr.c:
put a safety belt in, to catch the next person who doesn't know this.
fpu_int.c:
in one place, the reduction of the mantissa size was overlooked.
fpu_log.c:
as the most significand 32bit word of the mantissa was changed back to the
old format, change back the table indexing code, too.

This should fix PR 11045.
 1.2 30-May-1999  briggs branches: 1.2.2; 1.2.12;
PR 7220 from Ken Nakata:
I've fixed most (not all) m68k FPE bugs that give bogus
calculation results, esp. fsqrt instruction. Also, the internal FP
representation has been reduced from 115-bit mantissa to 67-bit
mantissa which reduced the required mantissa operation roughly by one
fourth. I've done an extensive (though not exhaustive - it's
impossible!) test on the internal routines by feeding them randomly
generated FP numbers, and found that the new code is more precise than
MC68040 FPU (it seems to have a rounding bug).

[ Only change was to keep fpu_calcea.c's name instead of renaming to
fpu_ea.c in Ken's patch. --akb ]
 1.1 03-Nov-1995  briggs branches: 1.1.24; 1.1.26; 1.1.28;
Still incomplete, but much more complete FPE from Ken Nakata
<kenn@remus.rutgers.edu>. This emulator does not yet emulate
the following functions:
FSINH, FETOXM1, FTANH, FATAN, FASIN, FATANH, FSIN, FTAN,
FETOX, FTWOTOX, FTENTOX, FCOSH, FACOS, FCOS, FSINCOS
It is sufficient, however, to allow programs like df, w, and newfs,
to run to completion with correct results.
Portions of this code were based on the sparc fpe and on initial
work by gwr.
 1.1.28.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.1.26.1 21-Jun-1999  thorpej Sync w/ -current.
 1.1.24.2 06-Feb-2000  he Apply patch (requested by is):
Revert floating point emulation software to the version released
as NetBSD 1.4. The upgrade done in 1.4.1 had problems.
 1.1.24.1 21-Jun-1999  perry pullup 1.1->1.2 (briggs): fix FPE
 1.2.12.1 26-Sep-2000  is Pullup from -current, requested by is, approved by thorpej:

fpu_emulate.h 1.7, fpu_log.c 1.7: synchronize mantissa length % 32 with fpu_fmovecr.c table
fpu_fmovecr.c 1.8: cheap compile-time consistency check for this
fpu_int.c 1.3: fix bug introduced when reducing mantissa size
This fixes PR 11045.
 1.2.2.2 12-Mar-2001  bouyer Sync with HEAD.
 1.2.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.4.16.1 14-Jul-2002  gehenna catch up with -current.
 1.4.8.1 20-Jun-2002  nathanw Catch up to -current.
 1.4.4.1 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.5.6.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.5.6.2 18-Sep-2004  skrll Sync with HEAD.
 1.5.6.1 03-Aug-2004  skrll Sync with HEAD
 1.7.92.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.7.86.1 28-Apr-2009  skrll Sync with HEAD.
 1.7.78.1 04-May-2009  yamt sync with head.
 1.10.8.1 04-Jul-2012  jdc Pull up revision 1.11 (requested by isaki in ticket #384).

Rewrite fpu_int().
Especially, remove the special treatment when |x| < 1
because it forgets to consider FPCR round mode.
See PR/46627 for the detail. Thanks Y.Sugahara for advice.
 1.10.2.2 22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.10.2.1 30-Oct-2012  yamt sync with head
 1.11.2.1 23-Jun-2013  tls resync from head
 1.18 04-Jan-2014  isaki FLOGNP1(-0.0) is -0.0, not +0.0. Found by XM6i.
 1.17 20-Apr-2013  isaki branches: 1.17.4;
Clean up some useless codes.
 1.16 11-Apr-2013  isaki Introduce FPU_CONST_* constants to avoid a magic number.
 1.15 26-Mar-2013  isaki u_int -> uint32_t
 1.14 18-Jul-2011  isaki branches: 1.14.2; 1.14.12;
fix indent again.
- "Second level indents are four spaces." pointed out by tsutsui@
- fold long line.
 1.13 18-Jul-2011  isaki fix indent. no functional changes.
 1.12 14-Mar-2009  dsl ANSIfy another 1261 function definitions.
The only ones left in sys are beyond by sed script!
(or in sys/dist or sys/external)
Mostly they have function pointer parameters.
 1.11 14-Mar-2009  dsl Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.10 14-Mar-2009  dsl Remove all the __P() from sys (excluding sys/dist)
Diff checked with grep and MK1 eyeball.
i386 and amd64 GENERIC and sys still build.
 1.9 11-Dec-2005  christos branches: 1.9.78; 1.9.86; 1.9.92;
merge ktrace-lwp.
 1.8 15-Jul-2003  lukem __KERNEL_RCSID()
 1.7 22-Sep-2000  is branches: 1.7.24;
fpu_emulate.h:
the fmovecr constant table has the internal format
of the constants. So, when changing the mantissa size by a
non-multiple of 32 bits, we'd have to change this table, too. As
all other code changes just chopped of the least significand
32bit word of the mantissa, we correct the mantissa size instead
to (115 - 32 == 83) bits.
fpu_fmovecr.c:
put a safety belt in, to catch the next person who doesn't know this.
fpu_int.c:
in one place, the reduction of the mantissa size was overlooked.
fpu_log.c:
as the most significand 32bit word of the mantissa was changed back to the
old format, change back the table indexing code, too.

This should fix PR 11045.
 1.6 30-May-1999  briggs branches: 1.6.2; 1.6.12;
PR 7220 from Ken Nakata:
I've fixed most (not all) m68k FPE bugs that give bogus
calculation results, esp. fsqrt instruction. Also, the internal FP
representation has been reduced from 115-bit mantissa to 67-bit
mantissa which reduced the required mantissa operation roughly by one
fourth. I've done an extensive (though not exhaustive - it's
impossible!) test on the internal routines by feeding them randomly
generated FP numbers, and found that the new code is more precise than
MC68040 FPU (it seems to have a rounding bug).

[ Only change was to keep fpu_calcea.c's name instead of renaming to
fpu_ea.c in Ken's patch. --akb ]
 1.5 13-Oct-1996  christos branches: 1.5.22; 1.5.24; 1.5.26;
backout previous kprintf change
 1.4 11-Oct-1996  christos printf -> kprintf, sprintf -> ksprintf
 1.3 30-Apr-1996  briggs Update for -Wall -Wstrict-prototypes -Wmissing-prototypes -Wno-uninitialized.
 1.2 05-Nov-1995  briggs Fixes from Ken Nakata. Mainly renaming debug_level to fpu_debug_level.
 1.1 03-Nov-1995  briggs Still incomplete, but much more complete FPE from Ken Nakata
<kenn@remus.rutgers.edu>. This emulator does not yet emulate
the following functions:
FSINH, FETOXM1, FTANH, FATAN, FASIN, FATANH, FSIN, FTAN,
FETOX, FTWOTOX, FTENTOX, FCOSH, FACOS, FCOS, FSINCOS
It is sufficient, however, to allow programs like df, w, and newfs,
to run to completion with correct results.
Portions of this code were based on the sparc fpe and on initial
work by gwr.
 1.5.26.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.5.24.1 21-Jun-1999  thorpej Sync w/ -current.
 1.5.22.2 06-Feb-2000  he Apply patch (requested by is):
Revert floating point emulation software to the version released
as NetBSD 1.4. The upgrade done in 1.4.1 had problems.
 1.5.22.1 21-Jun-1999  perry pullup 1.5->1.6 (briggs): fix FPE
 1.6.12.1 26-Sep-2000  is Pullup from -current, requested by is, approved by thorpej:

fpu_emulate.h 1.7, fpu_log.c 1.7: synchronize mantissa length % 32 with fpu_fmovecr.c table
fpu_fmovecr.c 1.8: cheap compile-time consistency check for this
fpu_int.c 1.3: fix bug introduced when reducing mantissa size
This fixes PR 11045.
 1.6.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.7.24.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.7.24.2 18-Sep-2004  skrll Sync with HEAD.
 1.7.24.1 03-Aug-2004  skrll Sync with HEAD
 1.9.92.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.9.86.1 28-Apr-2009  skrll Sync with HEAD.
 1.9.78.1 04-May-2009  yamt sync with head.
 1.14.12.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.14.12.1 23-Jun-2013  tls resync from head
 1.14.2.1 22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.17.4.1 18-May-2014  rmind sync with head
 1.9 06-Dec-2016  isaki Fix sign of NAN. Found by XM6i.
 1.8 26-Mar-2013  isaki branches: 1.8.12; 1.8.16;
u_int -> uint32_t
 1.7 19-Mar-2013  isaki Remove 'register'.
 1.6 14-Mar-2009  dsl branches: 1.6.12; 1.6.22;
Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.5 11-Dec-2005  christos branches: 1.5.78; 1.5.86; 1.5.92;
merge ktrace-lwp.
 1.4 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.3 15-Jul-2003  lukem __KERNEL_RCSID()
 1.2 30-May-1999  briggs branches: 1.2.36;
PR 7220 from Ken Nakata:
I've fixed most (not all) m68k FPE bugs that give bogus
calculation results, esp. fsqrt instruction. Also, the internal FP
representation has been reduced from 115-bit mantissa to 67-bit
mantissa which reduced the required mantissa operation roughly by one
fourth. I've done an extensive (though not exhaustive - it's
impossible!) test on the internal routines by feeding them randomly
generated FP numbers, and found that the new code is more precise than
MC68040 FPU (it seems to have a rounding bug).

[ Only change was to keep fpu_calcea.c's name instead of renaming to
fpu_ea.c in Ken's patch. --akb ]
 1.1 03-Nov-1995  briggs branches: 1.1.24; 1.1.26; 1.1.28;
Still incomplete, but much more complete FPE from Ken Nakata
<kenn@remus.rutgers.edu>. This emulator does not yet emulate
the following functions:
FSINH, FETOXM1, FTANH, FATAN, FASIN, FATANH, FSIN, FTAN,
FETOX, FTWOTOX, FTENTOX, FCOSH, FACOS, FCOS, FSINCOS
It is sufficient, however, to allow programs like df, w, and newfs,
to run to completion with correct results.
Portions of this code were based on the sparc fpe and on initial
work by gwr.
 1.1.28.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.1.26.1 21-Jun-1999  thorpej Sync w/ -current.
 1.1.24.2 06-Feb-2000  he Apply patch (requested by is):
Revert floating point emulation software to the version released
as NetBSD 1.4. The upgrade done in 1.4.1 had problems.
 1.1.24.1 21-Jun-1999  perry pullup 1.1->1.2 (briggs): fix FPE
 1.2.36.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.2.36.2 18-Sep-2004  skrll Sync with HEAD.
 1.2.36.1 03-Aug-2004  skrll Sync with HEAD
 1.5.92.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.5.86.1 28-Apr-2009  skrll Sync with HEAD.
 1.5.78.1 04-May-2009  yamt sync with head.
 1.6.22.2 03-Dec-2017  jdolecek update from HEAD
 1.6.22.1 23-Jun-2013  tls resync from head
 1.6.12.1 22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.8.16.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.8.12.1 05-Feb-2017  skrll Sync with HEAD
 1.18 19-Nov-2023  isaki m68k: Remove an unused variable since rev 1.1.
Detected by clang15 (nono emulator has imported and used this FPE).
 1.17 05-Feb-2015  isaki Fix typo in comment. pointed out by Y.Sugahara.
 1.16 11-May-2013  isaki branches: 1.16.10;
Revise the algorithm after Step3.
almost written by Y.Sugahara and minor modify by me.
This works for all input of FMOD/FREM and of course solves PR/47810.
 1.15 05-May-2013  isaki R := X even if L < 0 in Step2, according to algorithm of the comment.
This solves many cases of |X| < |Y|.
 1.14 05-May-2013  isaki Rename modrem -> is_mod for a readability.
 1.13 26-Mar-2013  isaki u_int -> uint32_t
 1.12 26-Mar-2013  isaki Fix a wrong "raw" comparison in step3.2.
It should solve a PR kern/47692.
 1.11 18-Jul-2011  isaki branches: 1.11.2; 1.11.12;
fix indent again.
- "Second level indents are four spaces." pointed out by tsutsui@
- fold long line.
 1.10 18-Jul-2011  isaki fix indent. no functional changes.
 1.9 14-Mar-2009  dsl ANSIfy another 1261 function definitions.
The only ones left in sys are beyond by sed script!
(or in sys/dist or sys/external)
Mostly they have function pointer parameters.
 1.8 14-Mar-2009  dsl Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.7 14-Mar-2009  dsl Remove all the __P() from sys (excluding sys/dist)
Diff checked with grep and MK1 eyeball.
i386 and amd64 GENERIC and sys still build.
 1.6 11-Dec-2005  christos branches: 1.6.78; 1.6.86; 1.6.92;
merge ktrace-lwp.
 1.5 15-Jul-2003  lukem __KERNEL_RCSID()
 1.4 30-May-1999  briggs branches: 1.4.36;
PR 7220 from Ken Nakata:
I've fixed most (not all) m68k FPE bugs that give bogus
calculation results, esp. fsqrt instruction. Also, the internal FP
representation has been reduced from 115-bit mantissa to 67-bit
mantissa which reduced the required mantissa operation roughly by one
fourth. I've done an extensive (though not exhaustive - it's
impossible!) test on the internal routines by feeding them randomly
generated FP numbers, and found that the new code is more precise than
MC68040 FPU (it seems to have a rounding bug).

[ Only change was to keep fpu_calcea.c's name instead of renaming to
fpu_ea.c in Ken's patch. --akb ]
 1.3 30-Apr-1996  briggs branches: 1.3.24; 1.3.26; 1.3.28;
Bring back Step9 and fix an oversight from Ken Nakata <kenn@remus.rutgers.edu>
 1.2 30-Apr-1996  briggs Update for -Wall -Wstrict-prototypes -Wmissing-prototypes -Wno-uninitialized.
 1.1 03-Nov-1995  briggs Still incomplete, but much more complete FPE from Ken Nakata
<kenn@remus.rutgers.edu>. This emulator does not yet emulate
the following functions:
FSINH, FETOXM1, FTANH, FATAN, FASIN, FATANH, FSIN, FTAN,
FETOX, FTWOTOX, FTENTOX, FCOSH, FACOS, FCOS, FSINCOS
It is sufficient, however, to allow programs like df, w, and newfs,
to run to completion with correct results.
Portions of this code were based on the sparc fpe and on initial
work by gwr.
 1.3.28.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.3.26.1 21-Jun-1999  thorpej Sync w/ -current.
 1.3.24.2 06-Feb-2000  he Apply patch (requested by is):
Revert floating point emulation software to the version released
as NetBSD 1.4. The upgrade done in 1.4.1 had problems.
 1.3.24.1 21-Jun-1999  perry pullup 1.3->1.4 (briggs): fix FPE
 1.4.36.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.4.36.2 18-Sep-2004  skrll Sync with HEAD.
 1.4.36.1 03-Aug-2004  skrll Sync with HEAD
 1.6.92.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.6.86.1 28-Apr-2009  skrll Sync with HEAD.
 1.6.78.1 04-May-2009  yamt sync with head.
 1.11.12.2 03-Dec-2017  jdolecek update from HEAD
 1.11.12.1 23-Jun-2013  tls resync from head
 1.11.2.1 22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.16.10.1 06-Apr-2015  skrll Sync with HEAD
 1.9 24-May-2022  andvar s/equivalant/equivalent/ in copy pasted comment.
 1.8 26-Mar-2013  isaki u_int -> uint32_t
 1.7 19-Mar-2013  isaki Remove 'register'.
 1.6 14-Mar-2009  dsl branches: 1.6.12; 1.6.22;
Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.5 11-Dec-2005  christos branches: 1.5.78; 1.5.86; 1.5.92;
merge ktrace-lwp.
 1.4 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.3 15-Jul-2003  lukem __KERNEL_RCSID()
 1.2 30-May-1999  briggs branches: 1.2.36;
PR 7220 from Ken Nakata:
I've fixed most (not all) m68k FPE bugs that give bogus
calculation results, esp. fsqrt instruction. Also, the internal FP
representation has been reduced from 115-bit mantissa to 67-bit
mantissa which reduced the required mantissa operation roughly by one
fourth. I've done an extensive (though not exhaustive - it's
impossible!) test on the internal routines by feeding them randomly
generated FP numbers, and found that the new code is more precise than
MC68040 FPU (it seems to have a rounding bug).

[ Only change was to keep fpu_calcea.c's name instead of renaming to
fpu_ea.c in Ken's patch. --akb ]
 1.1 03-Nov-1995  briggs branches: 1.1.24; 1.1.26; 1.1.28;
Still incomplete, but much more complete FPE from Ken Nakata
<kenn@remus.rutgers.edu>. This emulator does not yet emulate
the following functions:
FSINH, FETOXM1, FTANH, FATAN, FASIN, FATANH, FSIN, FTAN,
FETOX, FTWOTOX, FTENTOX, FCOSH, FACOS, FCOS, FSINCOS
It is sufficient, however, to allow programs like df, w, and newfs,
to run to completion with correct results.
Portions of this code were based on the sparc fpe and on initial
work by gwr.
 1.1.28.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.1.26.1 21-Jun-1999  thorpej Sync w/ -current.
 1.1.24.2 06-Feb-2000  he Apply patch (requested by is):
Revert floating point emulation software to the version released
as NetBSD 1.4. The upgrade done in 1.4.1 had problems.
 1.1.24.1 21-Jun-1999  perry pullup 1.1->1.2 (briggs): fix FPE
 1.2.36.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.2.36.2 18-Sep-2004  skrll Sync with HEAD.
 1.2.36.1 03-Aug-2004  skrll Sync with HEAD
 1.5.92.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.5.86.1 28-Apr-2009  skrll Sync with HEAD.
 1.5.78.1 04-May-2009  yamt sync with head.
 1.6.22.1 23-Jun-2013  tls resync from head
 1.6.12.1 22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.12 21-Apr-2013  isaki M68010 -> __mc68010__, pointed out by tsutsui@
 1.11 20-Apr-2013  isaki Rewrite around BFFFO inline asm.
o Prepare C version of BFFFO (from XM6i).
It is helpful in running FPE on other platforms (for example, for a
test). It is also helpful in porting to non-m68k 3rd party :)
o A BFFFO is supported on 68020 or later (though I'm not sure whether
sun2/68010 uses this FPE correctly or not).
 1.10 26-Mar-2013  isaki u_int -> uint32_t
 1.9 19-Mar-2013  isaki Remove 'register'.
 1.8 24-Dec-2005  perry branches: 1.8.112; 1.8.122;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.
 1.7 11-Dec-2005  christos merge ktrace-lwp.
 1.6 07-Aug-2003  agc branches: 1.6.16;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.5 15-Jul-2003  lukem __KERNEL_RCSID()
 1.4 29-Dec-2002  kristerw branches: 1.4.2;
Use "__asm __volatile" instead of "asm volatile" to pacify lint.
 1.3 30-May-1999  briggs branches: 1.3.20;
PR 7220 from Ken Nakata:
I've fixed most (not all) m68k FPE bugs that give bogus
calculation results, esp. fsqrt instruction. Also, the internal FP
representation has been reduced from 115-bit mantissa to 67-bit
mantissa which reduced the required mantissa operation roughly by one
fourth. I've done an extensive (though not exhaustive - it's
impossible!) test on the internal routines by feeding them randomly
generated FP numbers, and found that the new code is more precise than
MC68040 FPU (it seems to have a rounding bug).

[ Only change was to keep fpu_calcea.c's name instead of renaming to
fpu_ea.c in Ken's patch. --akb ]
 1.2 30-Apr-1996  briggs branches: 1.2.24; 1.2.26; 1.2.28;
Update for -Wall -Wstrict-prototypes -Wmissing-prototypes -Wno-uninitialized.
 1.1 03-Nov-1995  briggs Still incomplete, but much more complete FPE from Ken Nakata
<kenn@remus.rutgers.edu>. This emulator does not yet emulate
the following functions:
FSINH, FETOXM1, FTANH, FATAN, FASIN, FATANH, FSIN, FTAN,
FETOX, FTWOTOX, FTENTOX, FCOSH, FACOS, FCOS, FSINCOS
It is sufficient, however, to allow programs like df, w, and newfs,
to run to completion with correct results.
Portions of this code were based on the sparc fpe and on initial
work by gwr.
 1.2.28.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.2.26.1 21-Jun-1999  thorpej Sync w/ -current.
 1.2.24.2 06-Feb-2000  he Apply patch (requested by is):
Revert floating point emulation software to the version released
as NetBSD 1.4. The upgrade done in 1.4.1 had problems.
 1.2.24.1 21-Jun-1999  perry pullup 1.2->1.3 (briggs): fix FPE
 1.3.20.1 29-Dec-2002  thorpej Sync with HEAD.
 1.4.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.4.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.4.2.1 03-Aug-2004  skrll Sync with HEAD
 1.6.16.1 21-Jun-2006  yamt sync with head.
 1.8.122.1 23-Jun-2013  tls resync from head
 1.8.112.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.18 16-Jan-2017  isaki FSINCOS: Fix register address which writes cosine value back.
 1.17 06-Aug-2016  isaki branches: 1.17.2;
Modify fpu_sin()'s logic to avoid GCC's warning that has been
pointed out in the previous commit.
For fpu_cos() there is no such problem, but sync with fpu_sin().
 1.16 23-Mar-2016  mrg branches: 1.16.2;
avoid a GCC warning with this:

+#if defined(__GNUC__) && (__GNUC__ >= 5) && defined(__OPTIMIZE__)
+ x.fp_sign = 0;
+#endif

(ridiculous, but seems better than disabling the warning entirely.)
 1.15 20-Apr-2013  isaki branches: 1.15.12;
Support sin(-0.0).
 1.14 20-Apr-2013  isaki Clean up some useless codes.
 1.13 20-Apr-2013  isaki Support tan(-0.0).
 1.12 19-Apr-2013  isaki Implement inverse trigonometric functions (i.e., FACOS, FASIN, FATAN
instructions).
o arccos is calculated using arcsin.
o arcsin is calculated using arctan.
o arctan is calculated by the CORDIC.
 1.11 19-Apr-2013  isaki Introduce the CORDIC algorithm.
o sine and cosine (e.g., FSIN, FCOS and FSINCOS instructions) is now
calculated in the CORDIC instead of Taylor expansion.
o tangent (FTAN) is not touched from a viewpoint of the code size.
o The CORDIC is applicable for hyperbolic functions (e.g., FSINH,
FCOSH, FTANH instructions), but I didn't use it because its working
range is poor.
o The CORDIC is also usable for inverse trigonometric functions,
I will commit it at next phase.
o The code size becomes a bit big. I cannot evaluate speed on m68k
for some reasons, but in test on i386 the CORDIC is approximately
100 times faster in sin/cos.
 1.10 18-Apr-2013  isaki Improve how to use cmp/sub.
 1.9 11-Apr-2013  isaki Introduce FPU_CONST_* constants to avoid a magic number.
 1.8 26-Mar-2013  isaki u_int -> uint32_t
 1.7 23-Mar-2013  isaki Remove about updating fpsr. It was introduced by me but obviously
duplicated with fpu_emul_arith().
 1.6 15-Oct-2011  tsutsui branches: 1.6.2; 1.6.12;
Add hyperboric and trigonometric functions to m68k FPE, written by isaki@.
With these emulations (~4KB text) xeyes on XM6i works better.
Discussed with isaki@ at OSC 2011 Hiroshima.
 1.5 18-Jul-2011  isaki fix indent. no functional changes.
 1.4 14-Mar-2009  dsl Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.3 11-Dec-2005  christos branches: 1.3.78; 1.3.86; 1.3.92;
merge ktrace-lwp.
 1.2 15-Jul-2003  lukem __KERNEL_RCSID()
 1.1 03-Nov-1995  briggs branches: 1.1.64;
Still incomplete, but much more complete FPE from Ken Nakata
<kenn@remus.rutgers.edu>. This emulator does not yet emulate
the following functions:
FSINH, FETOXM1, FTANH, FATAN, FASIN, FATANH, FSIN, FTAN,
FETOX, FTWOTOX, FTENTOX, FCOSH, FACOS, FCOS, FSINCOS
It is sufficient, however, to allow programs like df, w, and newfs,
to run to completion with correct results.
Portions of this code were based on the sparc fpe and on initial
work by gwr.
 1.1.64.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.1.64.2 18-Sep-2004  skrll Sync with HEAD.
 1.1.64.1 03-Aug-2004  skrll Sync with HEAD
 1.3.92.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.3.86.1 28-Apr-2009  skrll Sync with HEAD.
 1.3.78.1 04-May-2009  yamt sync with head.
 1.6.12.2 03-Dec-2017  jdolecek update from HEAD
 1.6.12.1 23-Jun-2013  tls resync from head
 1.6.2.1 22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.15.12.3 05-Feb-2017  skrll Sync with HEAD
 1.15.12.2 05-Oct-2016  skrll Sync with HEAD
 1.15.12.1 22-Apr-2016  skrll Sync with HEAD
 1.16.2.1 20-Mar-2017  pgoyette Sync with HEAD
 1.17.2.1 21-Apr-2017  bouyer Sync with HEAD
 1.3 23-Oct-2003  kleink While I'm here, retire the FPE code's own copy of ieee.h.
 1.2 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.1 03-Nov-1995  briggs branches: 1.1.64;
Still incomplete, but much more complete FPE from Ken Nakata
<kenn@remus.rutgers.edu>. This emulator does not yet emulate
the following functions:
FSINH, FETOXM1, FTANH, FATAN, FASIN, FATANH, FSIN, FTAN,
FETOX, FTWOTOX, FTENTOX, FCOSH, FACOS, FCOS, FSINCOS
It is sufficient, however, to allow programs like df, w, and newfs,
to run to completion with correct results.
Portions of this code were based on the sparc fpe and on initial
work by gwr.
 1.1.64.1 03-Aug-2004  skrll Sync with HEAD
 1.2 26-Oct-1994  cgd new RCS ID format.
 1.1 05-Jul-1994  mycroft branches: 1.1.1;
Initial revision
 1.1.1.1 05-Jul-1994  mycroft Import the Motorola 68040 Floating Point Software Package.
 1.2 26-Oct-1994  cgd new RCS ID format.
 1.1 05-Jul-1994  mycroft Port to NetBSD, with some bug fixes and minor performance tweaks.
 1.2 26-Oct-1994  cgd new RCS ID format.
 1.1 05-Jul-1994  mycroft branches: 1.1.1;
Initial revision
 1.1.1.1 05-Jul-1994  mycroft Import the Motorola 68040 Floating Point Software Package.
 1.2 26-Oct-1994  cgd new RCS ID format.
 1.1 05-Jul-1994  mycroft branches: 1.1.1;
Initial revision
 1.1.1.1 05-Jul-1994  mycroft Import the Motorola 68040 Floating Point Software Package.
 1.2 26-Oct-1994  cgd new RCS ID format.
 1.1 05-Jul-1994  mycroft branches: 1.1.1;
Initial revision
 1.1.1.1 05-Jul-1994  mycroft Import the Motorola 68040 Floating Point Software Package.
 1.2 26-Oct-1994  cgd new RCS ID format.
 1.1 05-Jul-1994  mycroft branches: 1.1.1;
Initial revision
 1.1.1.1 05-Jul-1994  mycroft Import the Motorola 68040 Floating Point Software Package.
 1.2 26-Oct-1994  cgd new RCS ID format.
 1.1 05-Jul-1994  mycroft branches: 1.1.1;
Initial revision
 1.1.1.1 05-Jul-1994  mycroft Import the Motorola 68040 Floating Point Software Package.
 1.2 26-Oct-1994  cgd new RCS ID format.
 1.1 05-Jul-1994  mycroft branches: 1.1.1;
Initial revision
 1.1.1.1 05-Jul-1994  mycroft Import the Motorola 68040 Floating Point Software Package.
 1.2 26-Oct-1994  cgd new RCS ID format.
 1.1 05-Jul-1994  mycroft Port to NetBSD, with some bug fixes and minor performance tweaks.
 1.3 26-Oct-1994  cgd new RCS ID format.
 1.2 05-Jul-1994  mycroft Port to NetBSD, with some bug fixes and minor performance tweaks.
 1.1 05-Jul-1994  mycroft branches: 1.1.1;
Initial revision
 1.1.1.1 05-Jul-1994  mycroft Import the Motorola 68040 Floating Point Software Package.
 1.2 26-Oct-1994  cgd new RCS ID format.
 1.1 05-Jul-1994  mycroft branches: 1.1.1;
Initial revision
 1.1.1.1 05-Jul-1994  mycroft Import the Motorola 68040 Floating Point Software Package.
 1.17 25-Oct-2008  apb Use ${TOOL_SED} instead if plain sed in Makefiles.
 1.16 19-Oct-2008  apb Use ${TOOL_AWK} instead of ${AWK} or plain "awk" in make commands.
Pass AWK=${TOOL_AWK:Q} to shell scripts that use awk.
 1.15 24-Jun-2006  tsutsui branches: 1.15.58; 1.15.62; 1.15.68;
Pass sed command path to asm2gas via environment
rather than arg. ok'ed by gdamore.
 1.14 18-Jun-2006  gdamore Use TOOL_SED for asm2gas, which makes it possible to cross-compile this
on Solaris 10. (Solaris 10's sed doesn't like the comment lines, and
also complains about too many commands in the input.)
 1.13 07-Apr-2006  mrg branches: 1.13.2; 1.13.4;
retire HAVE_GCC3/HAVE_GCC4 and introduce HAVE_GCC that is set to 2, 3 or 4.
 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 26-Oct-2003  lukem branches: 1.11.16;
Use ${HOST_SH} instead of `sh'.

If necessary, pull in <bsd.sys.mk> to get the definition of HOST_SH;
Makefiles that pull in one of (most of) <bsd.*.mk> will get this anyway.
 1.10 04-Jun-2002  thorpej branches: 1.10.6;
Don't use -traditional-cpp if HAVE_GCC3.
 1.9 07-Oct-2001  tsutsui branches: 1.9.4; 1.9.12;
Pass CPPFLAGS properly so that source files can include <machine/asm.h> .
 1.8 02-Oct-2001  chs support building fpsp with MAKEOBJDIRPREFIX.
 1.7 18-Sep-1997  jeremy branches: 1.7.28; 1.7.30;
Use ${CC} instead of cc and don't explicitly set AR and LD unless they are
unset.
 1.6 25-Apr-1997  veego branches: 1.6.4;
Add a -I${.CURDIR} to build netbsd.sa with a obj dir
 1.5 25-Apr-1997  thorpej Preprocess .s files before assembling them.
 1.4 26-Oct-1994  cgd new RCS ID format.
 1.3 07-Jul-1994  mycroft branches: 1.3.2;
Add copyright; clean up a bit.
 1.2 05-Jul-1994  mycroft Port to NetBSD, with some bug fixes and minor performance tweaks.
 1.1 05-Jul-1994  mycroft branches: 1.1.1;
Initial revision
 1.1.1.1 05-Jul-1994  mycroft Import the Motorola 68040 Floating Point Software Package.
 1.3.2.2 07-Jul-1994  mycroft Add copyright; clean up a bit.
 1.3.2.1 07-Jul-1994  mycroft file Makefile was added on branch netbsd-1-0 on 1994-07-07 07:29:08 +0000
 1.6.4.1 22-Sep-1997  thorpej Update marc-pcmcia branch from trunk.
 1.7.30.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.7.30.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.7.28.1 11-Oct-2001  fvdl Catch up with -current. Fix some bogons in the sparc64 kbd/ms
attach code. cd18xx conversion provided by mrg.
 1.9.12.1 14-Jul-2002  gehenna catch up with -current.
 1.9.4.2 20-Jun-2002  nathanw Catch up to -current.
 1.9.4.1 07-Oct-2001  nathanw file Makefile was added on branch nathanw_sa on 2002-06-20 03:39:19 +0000
 1.10.6.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.10.6.2 18-Sep-2004  skrll Sync with HEAD.
 1.10.6.1 03-Aug-2004  skrll Sync with HEAD
 1.11.16.2 30-Dec-2006  yamt sync with head.
 1.11.16.1 21-Jun-2006  yamt sync with head.
 1.12.12.1 24-May-2006  tron Merge 2006-05-24 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 26-Jun-2006  yamt sync with head.
 1.12.8.1 11-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.13.4.2 24-Jun-2006  tsutsui Pass sed command path to asm2gas via environment
rather than arg. ok'ed by gdamore.
 1.13.4.1 18-Jun-2006  gdamore Use TOOL_SED for asm2gas, which makes it possible to cross-compile this
on Solaris 10. (Solaris 10's sed doesn't like the comment lines, and
also complains about too many commands in the input.)
 1.13.2.1 19-Jun-2006  chap Sync with head.
 1.15.68.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.15.62.1 04-May-2009  yamt sync with head.
 1.15.58.1 17-Jan-2009  mjf Sync with HEAD.
 1.22 23-Sep-2025  rillig all: fix "Invalid internal option" warning from make
 1.21 27-May-2018  christos - Introduce :q modifier for make variables and make it double escape $'s so
that passing variables to recursive makes with :q works as expected.
- Revert :Q to work as before.
- Adjust makefiles that use recursive make to use :q

Discussed on tech-toolchain@
XXX: pullup 8
 1.20 22-Mar-2016  mrg branches: 1.20.10; 1.20.16;
remove a bunch of "@echo done" from the tail of rules. these messages
were vaguely useful back when we didn't run make -j, but now you end
up with a single line "done" every so often, with no idea what it is
for. very few other targets claim they're done so just remove these.
 1.19 06-Sep-2015  uebayasi In kernel lib build, print message when things not only start bug also end.
 1.18 06-Sep-2015  uebayasi Declare dependency on fpsp.o via newly introduced ${MD_LIBS} instead of
${MD_OBJS}.

${MD_OBJS} should be used only for objects that must be linked first (i.e.,
start code). Objects have to be compiled following common compile rules,
and have to be generated into common places (i.e., top of kernel build
directory).

${MD_LIBS} defines libraries that are built by separate makefiles, under
separate directories. `Makefile.kern.inc' doesn't know intermediate library
objects.
 1.17 04-Sep-2015  uebayasi Fix m68k build.
 1.16 28-Feb-2009  tsutsui branches: 1.16.40;
Avoid "returned non-zero status" warning on make depend for kernels
without options FPSP on ports which have support for 68040 and FPSP.

Should close PR port-atari/40678.
 1.15 17-Oct-2007  garbled branches: 1.15.20; 1.15.28; 1.15.34;
Merge the ppcoea-renovation branch to HEAD.

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

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

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.14 09-May-2007  dsl branches: 1.14.10;
Allow for other info in opt_fpsp.h when trying to find out whether FPSP
is enabled.
Surely there are proper mechanisms that can be used to conditionally include
this file?
 1.13 05-Mar-2006  aymeric branches: 1.13.16; 1.13.18; 1.13.22; 1.13.24; 1.13.30; 1.13.32;
pass -traditional to ${CPP} so that the test for FPSP indeed works
 1.12 02-Oct-2001  chs branches: 1.12.4; 1.12.36; 1.12.50; 1.12.52; 1.12.54;
support building fpsp with MAKEOBJDIRPREFIX.
 1.11 14-May-2000  minoura branches: 1.11.6; 1.11.8;
defopt FPSP.
 1.10 01-Feb-2000  tsutsui Revert STRIPPROG -> STRIP
 1.9 19-Jan-2000  tsutsui STRIP -> STRIPPROG
 1.8 14-Oct-1998  is branches: 1.8.12;
Activate cleandir (and distclean), as suggested in PR 6244 by
Frederick Bruckman.
 1.7 05-Sep-1998  lukem distclean is a synonym for cleandir
 1.6 21-Sep-1997  is Build this in ${KERNEL_BUILD_DIRECTORY}/lib/fpsp, similar to libkern.
 1.5 07-May-1997  mycroft branches: 1.5.4;
Add .MAKE to the .OBJDIR hacks, so they work with `make -n'.
 1.4 29-Oct-1996  scottr cpp -> ${CPP}
 1.3 03-Feb-1996  mycroft Use CPPFLAGS, not COPTS.
 1.2 26-Oct-1994  cgd new RCS ID format.
 1.1 05-Jul-1994  mycroft Port to NetBSD, with some bug fixes and minor performance tweaks.
 1.5.4.1 22-Sep-1997  thorpej Update marc-pcmcia branch from trunk.
 1.8.12.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.11.8.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.11.6.1 11-Oct-2001  fvdl Catch up with -current. Fix some bogons in the sparc64 kbd/ms
attach code. cd18xx conversion provided by mrg.
 1.12.54.1 13-Mar-2006  yamt sync with head.
 1.12.52.1 22-Apr-2006  simonb Sync with head.
 1.12.50.1 09-Sep-2006  rpaulo sync with head
 1.12.36.2 03-Sep-2007  yamt sync with head.
 1.12.36.1 21-Jun-2006  yamt sync with head.
 1.12.4.2 02-Oct-2001  chs support building fpsp with MAKEOBJDIRPREFIX.
 1.12.4.1 02-Oct-2001  chs file Makefile.inc was added on branch nathanw_sa on 2001-10-02 06:34:53 +0000
 1.13.32.1 03-Sep-2007  wrstuden Sync w/ NetBSD-4-RC_1
 1.13.30.1 22-May-2007  matt Update to HEAD.
 1.13.24.1 11-Jul-2007  mjf Sync with head.
 1.13.22.1 27-May-2007  ad Sync with head.
 1.13.18.1 17-May-2007  yamt sync with head.
 1.13.16.1 24-Aug-2007  liamjfoy Pull up following revision(s) (requested by tsutsui in ticket #836):
sys/arch/m68k/fpsp/Makefile.inc: revision 1.14
Allow for other info in opt_fpsp.h when trying to find out whether FPSP
is enabled.
Surely there are proper mechanisms that can be used to conditionally include
this file?
 1.14.10.1 06-Nov-2007  matt sync with HEAD
 1.15.34.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.15.28.1 03-Mar-2009  skrll Sync with HEAD.
 1.15.20.1 04-May-2009  yamt sync with head.
 1.16.40.2 22-Apr-2016  skrll Sync with HEAD
 1.16.40.1 22-Sep-2015  skrll Sync with HEAD
 1.20.16.1 25-Jun-2018  pgoyette Sync with HEAD
 1.20.10.1 09-Jun-2018  martin Pull up following revision(s) (requested by christos in ticket #870):

sys/lib/libgnuefi/Makefile.inc: revision 1.5
external/mit/xorg/xorg-pkg-ver.mk: revision 1.9
sys/arch/i386/stand/lib/Makefile.inc: revision 1.17
sys/compat/common/Makefile.inc: revision 1.25
usr.bin/make/unit-tests/varquote.exp: revision 1.1, 1.2
sys/lib/libsa/Makefile.inc: revision 1.24
usr.bin/make/var.c: revision 1.220
sys/arch/ia64/stand/efi/libefi/Makefile.inc: revision 1.5
sys/arch/hppa/spmath/Makefile.inc: revision 1.10
usr.bin/make/unit-tests/varquote.mk: revision 1.1, 1.2
usr.bin/make/unit-tests/Makefile: revision 1.53
sys/lib/libkern/Makefile.inc: revision 1.45
sys/arch/acorn32/stand/lib/Makefile.inc: revision 1.4
sys/arch/m68k/fpsp/Makefile.inc: revision 1.21
usr.bin/make/make.1: revision 1.273
sys/lib/libz/Makefile.inc: revision 1.17

- Introduce :q modifier for make variables and make it double escape $'s so
that passing variables to recursive makes with :q works as expected.
- Adjust makefiles that use recursive make to use :q

Discussed on tech-toolchain@

XXX: pullup 8
 1.2 05-Jul-1994  mycroft Clean up deleted files.
 1.1 26-Jan-1994  mw FPU software emulator for '40
 1.2 05-Jul-1994  mycroft Clean up deleted files.
 1.1 26-Jan-1994  mw FPU software emulator for '40
 1.2 05-Jul-1994  mycroft Clean up deleted files.
 1.1 26-Jan-1994  mw FPU software emulator for '40
 1.10 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.9 28-Mar-2008  apb branches: 1.9.2; 1.9.4;
Synchronise the two asm2gas scripts in sys/arch/m68k/060sp and
sys/arch/m68k/fpsp:

* The fpsp/asm2gas sed script previously hardcoded the fact that
registers needed a '%' prefix, and the 060sp/asm2gas sed scrip
previously did not have rules related to inserting '%' before register
names. Now, both scripts have the same rules, but the rules are
parapeterised to use "$P", which is set to '' or '%' as appropriate.

* Some other minor changes to the sed scripts.

The new asm2gas scripts have been verified to produce identical output
to the old asm2gas scripts, for all inputs in 060sp/dist/*.sa and
fpsp/*.sa, except for some differences inside comments.

Thanks to Izumi Tsutsui for suggesting that these scripts should be
synchronised.
 1.8 24-Jun-2006  tsutsui branches: 1.8.58;
Pass sed command path to asm2gas via environment
rather than arg. ok'ed by gdamore.
 1.7 18-Jun-2006  gdamore Use TOOL_SED for asm2gas, which makes it possible to cross-compile this
on Solaris 10. (Solaris 10's sed doesn't like the comment lines, and
also complains about too many commands in the input.)
 1.6 06-Dec-2000  is branches: 1.6.40; 1.6.54; 1.6.58; 1.6.64; 1.6.66;
Make this new-GAS ready. Code by Steve Woodford.
 1.5 15-Aug-1998  mycroft branches: 1.5.12;
Assign copyrights to TNF.
 1.4 15-Aug-1998  mycroft Make copyright notices with my name consistent.
 1.3 26-Oct-1994  cgd new RCS ID format.
 1.2 07-Jul-1994  mycroft branches: 1.2.2;
Simplify, speed it up, and do the right thing for floating point constants.
 1.1 05-Jul-1994  mycroft Port to NetBSD, with some bug fixes and minor performance tweaks.
 1.2.2.2 07-Jul-1994  mycroft Simplify, speed it up, and do the right thing for floating point constants.
 1.2.2.1 07-Jul-1994  mycroft file asm2gas was added on branch netbsd-1-0 on 1994-07-07 01:51:19 +0000
 1.5.12.1 08-Dec-2000  bouyer Sync with HEAD.
 1.6.66.2 24-Jun-2006  tsutsui Pass sed command path to asm2gas via environment
rather than arg. ok'ed by gdamore.
 1.6.66.1 18-Jun-2006  gdamore Use TOOL_SED for asm2gas, which makes it possible to cross-compile this
on Solaris 10. (Solaris 10's sed doesn't like the comment lines, and
also complains about too many commands in the input.)
 1.6.64.1 19-Jun-2006  chap Sync with head.
 1.6.58.1 26-Jun-2006  yamt sync with head.
 1.6.54.1 09-Sep-2006  rpaulo sync with head
 1.6.40.2 30-Dec-2006  yamt sync with head.
 1.6.40.1 21-Jun-2006  yamt sync with head.
 1.8.58.2 02-Jun-2008  mjf Sync with HEAD.
 1.8.58.1 03-Apr-2008  mjf Sync with HEAD.
 1.9.4.1 16-May-2008  yamt sync with head.
 1.9.2.1 18-May-2008  yamt sync with head.
 1.5 09-Dec-2001  briggs The new toolchain wants to generate relocatable branches to globally-defined
symbols--even when the branches are local and would otherwise work with
bxx.b. Compensate for this by shadowing the relevant labels with local
labels.
 1.4 16-Sep-2001  wiz branches: 1.4.4;
Spell 'occurred' with two 'r's.
 1.3 26-Oct-1994  cgd branches: 1.3.44; 1.3.46;
new RCS ID format.
 1.2 05-Jul-1994  mycroft Port to NetBSD, with some bug fixes and minor performance tweaks.
 1.1 05-Jul-1994  mycroft branches: 1.1.1;
Initial revision
 1.1.1.1 05-Jul-1994  mycroft Import the Motorola 68040 Floating Point Software Package.
 1.3.46.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.3.44.1 01-Oct-2001  fvdl Catch up with -current.
 1.4.4.2 08-Jan-2002  nathanw Catch up to -current.
 1.4.4.1 16-Sep-2001  nathanw file bindec.sa was added on branch nathanw_sa on 2002-01-08 00:25:52 +0000
 1.3 26-Oct-1994  cgd new RCS ID format.
 1.2 05-Jul-1994  mycroft Port to NetBSD, with some bug fixes and minor performance tweaks.
 1.1 05-Jul-1994  mycroft branches: 1.1.1;
Initial revision
 1.1.1.1 05-Jul-1994  mycroft Import the Motorola 68040 Floating Point Software Package.
 1.3 26-Oct-1994  cgd new RCS ID format.
 1.2 05-Jul-1994  mycroft Port to NetBSD, with some bug fixes and minor performance tweaks.
 1.1 05-Jul-1994  mycroft branches: 1.1.1;
Initial revision
 1.1.1.1 05-Jul-1994  mycroft Import the Motorola 68040 Floating Point Software Package.
 1.2 26-Oct-1994  cgd new RCS ID format.
 1.1 07-Jul-1994  mycroft branches: 1.1.2;
.ascii'd version of the copyright.
 1.1.2.2 07-Jul-1994  mycroft .ascii'd version of the copyright.
 1.1.2.1 07-Jul-1994  mycroft file copyright.s was added on branch netbsd-1-0 on 1994-07-07 07:28:50 +0000
 1.5 05-Feb-2024  andvar fix various typos in comments.
 1.4 09-Dec-2001  briggs The new toolchain wants to generate relocatable branches to globally-defined
symbols--even when the branches are local and would otherwise work with
bxx.b. Compensate for this by shadowing the relevant labels with local
labels.
 1.3 16-Sep-2001  wiz branches: 1.3.4;
Spell 'occurred' with two 'r's.
 1.2 26-Oct-1994  cgd branches: 1.2.44; 1.2.46;
new RCS ID format.
 1.1 05-Jul-1994  mycroft branches: 1.1.1;
Initial revision
 1.1.1.1 05-Jul-1994  mycroft Import the Motorola 68040 Floating Point Software Package.
 1.2.46.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.2.44.1 01-Oct-2001  fvdl Catch up with -current.
 1.3.4.2 08-Jan-2002  nathanw Catch up to -current.
 1.3.4.1 16-Sep-2001  nathanw file decbin.sa was added on branch nathanw_sa on 2002-01-08 00:25:53 +0000
 1.3 09-Dec-2001  briggs The new toolchain wants to generate relocatable branches to globally-defined
symbols--even when the branches are local and would otherwise work with
bxx.b. Compensate for this by shadowing the relevant labels with local
labels.
 1.2 26-Oct-1994  cgd branches: 1.2.46; 1.2.50;
new RCS ID format.
 1.1 05-Jul-1994  mycroft branches: 1.1.1;
Initial revision
 1.1.1.1 05-Jul-1994  mycroft Import the Motorola 68040 Floating Point Software Package.
 1.2.50.1 08-Jan-2002  nathanw Catch up to -current.
 1.2.46.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.3 05-Jul-1994  mycroft Clean up deleted files.
 1.2 29-May-1994  mycroft Fresh compilation, with a few bugs fixed.
 1.1 26-Jan-1994  mw FPU software emulator for '40
 1.2 26-Oct-1994  cgd new RCS ID format.
 1.1 05-Jul-1994  mycroft branches: 1.1.1;
Initial revision
 1.1.1.1 05-Jul-1994  mycroft Import the Motorola 68040 Floating Point Software Package.
 1.3 03-Jul-1994  mycroft Clean up deleted files.
 1.2 18-May-1994  chopps conditional contents on !FPSP
 1.1 26-Jan-1994  mw FPU software emulator for '40
 1.4 27-Feb-2010  snj Spell "exception" properly.
 1.3 26-Oct-1994  cgd branches: 1.3.172; 1.3.192;
new RCS ID format.
 1.2 05-Jul-1994  mycroft Port to NetBSD, with some bug fixes and minor performance tweaks.
 1.1 05-Jul-1994  mycroft branches: 1.1.1;
Initial revision
 1.1.1.1 05-Jul-1994  mycroft Import the Motorola 68040 Floating Point Software Package.
 1.3.192.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.3.172.1 11-Mar-2010  yamt sync with head
 1.5 02-Nov-2022  andvar fix various typos in comments and messages.
 1.4 09-Dec-2001  briggs The new toolchain wants to generate relocatable branches to globally-defined
symbols--even when the branches are local and would otherwise work with
bxx.b. Compensate for this by shadowing the relevant labels with local
labels.
 1.3 26-Oct-1994  cgd branches: 1.3.46; 1.3.50;
new RCS ID format.
 1.2 05-Jul-1994  mycroft Port to NetBSD, with some bug fixes and minor performance tweaks.
 1.1 05-Jul-1994  mycroft branches: 1.1.1;
Initial revision
 1.1.1.1 05-Jul-1994  mycroft Import the Motorola 68040 Floating Point Software Package.
 1.3.50.1 08-Jan-2002  nathanw Catch up to -current.
 1.3.46.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.2 26-Oct-1994  cgd new RCS ID format.
 1.1 05-Jul-1994  mycroft branches: 1.1.1;
Initial revision
 1.1.1.1 05-Jul-1994  mycroft Import the Motorola 68040 Floating Point Software Package.
 1.1 05-Jul-1994  mycroft branches: 1.1.1;
Initial revision
 1.1.1.2 05-Jul-1994  mycroft Clean up deleted files.
 1.1.1.1 05-Jul-1994  mycroft Import the Motorola 68040 Floating Point Software Package.
 1.3 18-Oct-2014  snj src is too big these days to tolerate superfluous apostrophes. It's
"its", people!
 1.2 26-Oct-1994  cgd branches: 1.2.216;
new RCS ID format.
 1.1 05-Jul-1994  mycroft branches: 1.1.1;
Initial revision
 1.1.1.1 05-Jul-1994  mycroft Import the Motorola 68040 Floating Point Software Package.
 1.2.216.1 03-Dec-2017  jdolecek update from HEAD
 1.3 26-Oct-1994  cgd new RCS ID format.
 1.2 05-Jul-1994  mycroft Port to NetBSD, with some bug fixes and minor performance tweaks.
 1.1 05-Jul-1994  mycroft branches: 1.1.1;
Initial revision
 1.1.1.1 05-Jul-1994  mycroft Import the Motorola 68040 Floating Point Software Package.
 1.6 20-Sep-2024  andvar s/resister/register/ in comments.
 1.5 02-Oct-2001  chs branches: 1.5.4; 1.5.246;
support building fpsp with MAKEOBJDIRPREFIX.
 1.4 16-Sep-2001  wiz Spell 'occurred' with two 'r's.
 1.3 25-Apr-1997  thorpej branches: 1.3.34; 1.3.36;
Minimalistic changes to not make assumptions about how C labels
are handled. This file's ".s" counterpart must now be pre-processed.
 1.2 26-Oct-1994  cgd new RCS ID format.
 1.1 05-Jul-1994  mycroft Port to NetBSD, with some bug fixes and minor performance tweaks.
 1.3.36.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.3.34.2 11-Oct-2001  fvdl Catch up with -current. Fix some bogons in the sparc64 kbd/ms
attach code. cd18xx conversion provided by mrg.
 1.3.34.1 01-Oct-2001  fvdl Catch up with -current.
 1.5.246.1 02-Aug-2025  perseant Sync with HEAD
 1.5.4.2 02-Oct-2001  chs support building fpsp with MAKEOBJDIRPREFIX.
 1.5.4.1 02-Oct-2001  chs file netbsd.sa was added on branch nathanw_sa on 2001-10-02 06:34:53 +0000
 1.6 07-Dec-2021  andvar fix various typos, mainly in comments.
 1.5 16-Sep-2001  wiz branches: 1.5.4;
Spell 'occurred' with two 'r's.
 1.4 13-Mar-2000  soren branches: 1.4.6; 1.4.8;
Fix doubled 'the's in comments.
 1.3 26-Oct-1994  cgd branches: 1.3.32;
new RCS ID format.
 1.2 05-Jul-1994  mycroft Port to NetBSD, with some bug fixes and minor performance tweaks.
 1.1 05-Jul-1994  mycroft branches: 1.1.1;
Initial revision
 1.1.1.1 05-Jul-1994  mycroft Import the Motorola 68040 Floating Point Software Package.
 1.3.32.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.4.8.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.4.6.1 01-Oct-2001  fvdl Catch up with -current.
 1.5.4.2 16-Sep-2001  wiz Spell 'occurred' with two 'r's.
 1.5.4.1 16-Sep-2001  wiz file res_func.sa was added on branch nathanw_sa on 2001-09-16 16:34:33 +0000
 1.6 08-Apr-2022  andvar s/postions/positions/
 1.5 08-Apr-2022  andvar fix various typos, mainly in comments, but also log messages, docs, game text.
 1.4 31-Jul-2021  andvar s/threshhold/threshold
 1.3 26-Oct-1994  cgd branches: 1.3.272;
new RCS ID format.
 1.2 05-Jul-1994  mycroft Port to NetBSD, with some bug fixes and minor performance tweaks.
 1.1 05-Jul-1994  mycroft branches: 1.1.1;
Initial revision
 1.1.1.1 05-Jul-1994  mycroft Import the Motorola 68040 Floating Point Software Package.
 1.3.272.1 01-Aug-2021  thorpej Sync with HEAD.
 1.3 26-Oct-1994  cgd new RCS ID format.
 1.2 05-Jul-1994  mycroft Port to NetBSD, with some bug fixes and minor performance tweaks.
 1.1 05-Jul-1994  mycroft branches: 1.1.1;
Initial revision
 1.1.1.1 05-Jul-1994  mycroft Import the Motorola 68040 Floating Point Software Package.
 1.2 26-Oct-1994  cgd new RCS ID format.
 1.1 05-Jul-1994  mycroft branches: 1.1.1;
Initial revision
 1.1.1.1 05-Jul-1994  mycroft Import the Motorola 68040 Floating Point Software Package.
 1.3 26-Oct-1994  cgd new RCS ID format.
 1.2 05-Jul-1994  mycroft Port to NetBSD, with some bug fixes and minor performance tweaks.
 1.1 05-Jul-1994  mycroft branches: 1.1.1;
Initial revision
 1.1.1.1 05-Jul-1994  mycroft Import the Motorola 68040 Floating Point Software Package.
 1.2 26-Oct-1994  cgd new RCS ID format.
 1.1 05-Jul-1994  mycroft branches: 1.1.1;
Initial revision
 1.1.1.1 05-Jul-1994  mycroft Import the Motorola 68040 Floating Point Software Package.
 1.3 26-Oct-1994  cgd new RCS ID format.
 1.2 05-Jul-1994  mycroft Port to NetBSD, with some bug fixes and minor performance tweaks.
 1.1 05-Jul-1994  mycroft branches: 1.1.1;
Initial revision
 1.1.1.1 05-Jul-1994  mycroft Import the Motorola 68040 Floating Point Software Package.
 1.2 26-Oct-1994  cgd new RCS ID format.
 1.1 05-Jul-1994  mycroft branches: 1.1.1;
Initial revision
 1.1.1.1 05-Jul-1994  mycroft Import the Motorola 68040 Floating Point Software Package.
 1.5 01-Sep-2014  matt Avoid trigraphs
 1.4 05-Feb-2003  perry branches: 1.4.152;
"Utilize" has exactly the same meaning as "use," but it is more
difficult to read and understand. Most manuals of English style
therefore say that you should use "use".
 1.3 26-Oct-1994  cgd new RCS ID format.
 1.2 05-Jul-1994  mycroft Port to NetBSD, with some bug fixes and minor performance tweaks.
 1.1 05-Jul-1994  mycroft branches: 1.1.1;
Initial revision
 1.1.1.1 05-Jul-1994  mycroft Import the Motorola 68040 Floating Point Software Package.
 1.4.152.1 03-Dec-2017  jdolecek update from HEAD
 1.2 26-Oct-1994  cgd new RCS ID format.
 1.1 05-Jul-1994  mycroft branches: 1.1.1;
Initial revision
 1.1.1.1 05-Jul-1994  mycroft Import the Motorola 68040 Floating Point Software Package.
 1.3 09-Feb-2010  wiz Fix typo.
 1.2 26-Oct-1994  cgd branches: 1.2.172; 1.2.192;
new RCS ID format.
 1.1 05-Jul-1994  mycroft branches: 1.1.1;
Initial revision
 1.1.1.1 05-Jul-1994  mycroft Import the Motorola 68040 Floating Point Software Package.
 1.2.192.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.2.172.1 11-Mar-2010  yamt sync with head
 1.5 20-Sep-2024  andvar s/resister/register/ in comments.
 1.4 16-Sep-2001  wiz branches: 1.4.4; 1.4.246;
Spell 'occurred' with two 'r's.
 1.3 26-Oct-1994  cgd branches: 1.3.44; 1.3.46;
new RCS ID format.
 1.2 05-Jul-1994  mycroft Port to NetBSD, with some bug fixes and minor performance tweaks.
 1.1 05-Jul-1994  mycroft branches: 1.1.1;
Initial revision
 1.1.1.1 05-Jul-1994  mycroft Import the Motorola 68040 Floating Point Software Package.
 1.3.46.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.3.44.1 01-Oct-2001  fvdl Catch up with -current.
 1.4.246.1 02-Aug-2025  perseant Sync with HEAD
 1.4.4.2 16-Sep-2001  wiz Spell 'occurred' with two 'r's.
 1.4.4.1 16-Sep-2001  wiz file skeleton.sa was added on branch nathanw_sa on 2001-09-16 16:34:33 +0000
 1.2 26-Oct-1994  cgd new RCS ID format.
 1.1 05-Jul-1994  mycroft branches: 1.1.1;
Initial revision
 1.1.1.1 05-Jul-1994  mycroft Import the Motorola 68040 Floating Point Software Package.
 1.5 05-Dec-2021  msaitoh s/MEMEORY/MEMORY/ in comment.
 1.4 13-Mar-2000  soren Fix doubled 'the's in comments.
 1.3 26-Oct-1994  cgd branches: 1.3.32;
new RCS ID format.
 1.2 05-Jul-1994  mycroft Port to NetBSD, with some bug fixes and minor performance tweaks.
 1.1 05-Jul-1994  mycroft branches: 1.1.1;
Initial revision
 1.1.1.1 05-Jul-1994  mycroft Import the Motorola 68040 Floating Point Software Package.
 1.3.32.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 26-Oct-1994  cgd new RCS ID format.
 1.1 05-Jul-1994  mycroft branches: 1.1.1;
Initial revision
 1.1.1.1 05-Jul-1994  mycroft Import the Motorola 68040 Floating Point Software Package.
 1.3 26-Oct-1994  cgd new RCS ID format.
 1.2 05-Jul-1994  mycroft Port to NetBSD, with some bug fixes and minor performance tweaks.
 1.1 05-Jul-1994  mycroft branches: 1.1.1;
Initial revision
 1.1.1.1 05-Jul-1994  mycroft Import the Motorola 68040 Floating Point Software Package.
 1.6 05-Dec-2021  msaitoh s/Overwirte/Overwrite/ in comment.
 1.5 21-Aug-2021  andvar fix mainly same typos as in my previous commit but outside sys/dev/dm.
 1.4 13-Mar-2000  soren Fix doubled 'the's in comments.
 1.3 26-Oct-1994  cgd branches: 1.3.32;
new RCS ID format.
 1.2 05-Jul-1994  mycroft Port to NetBSD, with some bug fixes and minor performance tweaks.
 1.1 05-Jul-1994  mycroft branches: 1.1.1;
Initial revision
 1.1.1.1 05-Jul-1994  mycroft Import the Motorola 68040 Floating Point Software Package.
 1.3.32.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.3 26-Oct-1994  cgd new RCS ID format.
 1.2 05-Jul-1994  mycroft Port to NetBSD, with some bug fixes and minor performance tweaks.
 1.1 05-Jul-1994  mycroft branches: 1.1.1;
Initial revision
 1.1.1.1 05-Jul-1994  mycroft Import the Motorola 68040 Floating Point Software Package.
 1.4 13-Mar-2000  soren Fix doubled 'the's in comments.
 1.3 26-Oct-1994  cgd branches: 1.3.32;
new RCS ID format.
 1.2 05-Jul-1994  mycroft Port to NetBSD, with some bug fixes and minor performance tweaks.
 1.1 05-Jul-1994  mycroft branches: 1.1.1;
Initial revision
 1.1.1.1 05-Jul-1994  mycroft Import the Motorola 68040 Floating Point Software Package.
 1.3.32.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.3 26-Oct-1994  cgd new RCS ID format.
 1.2 05-Jul-1994  mycroft Port to NetBSD, with some bug fixes and minor performance tweaks.
 1.1 05-Jul-1994  mycroft branches: 1.1.1;
Initial revision
 1.1.1.1 05-Jul-1994  mycroft Import the Motorola 68040 Floating Point Software Package.
 1.4 13-Mar-2000  soren Fix doubled 'the's in comments.
 1.3 26-Oct-1994  cgd branches: 1.3.32;
new RCS ID format.
 1.2 05-Jul-1994  mycroft Port to NetBSD, with some bug fixes and minor performance tweaks.
 1.1 05-Jul-1994  mycroft branches: 1.1.1;
Initial revision
 1.1.1.1 05-Jul-1994  mycroft Import the Motorola 68040 Floating Point Software Package.
 1.3.32.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.3 26-Oct-1994  cgd new RCS ID format.
 1.2 05-Jul-1994  mycroft Port to NetBSD, with some bug fixes and minor performance tweaks.
 1.1 05-Jul-1994  mycroft branches: 1.1.1;
Initial revision
 1.1.1.1 05-Jul-1994  mycroft Import the Motorola 68040 Floating Point Software Package.
 1.2 26-Oct-1994  cgd new RCS ID format.
 1.1 05-Jul-1994  mycroft branches: 1.1.1;
Initial revision
 1.1.1.1 05-Jul-1994  mycroft Import the Motorola 68040 Floating Point Software Package.
 1.5 08-Apr-2022  andvar fix various typos, mainly in comments, but also log messages, docs, game text.
 1.4 09-Dec-2001  briggs The new toolchain wants to generate relocatable branches to globally-defined
symbols--even when the branches are local and would otherwise work with
bxx.b. Compensate for this by shadowing the relevant labels with local
labels.
 1.3 26-Oct-1994  cgd branches: 1.3.46; 1.3.50;
new RCS ID format.
 1.2 05-Jul-1994  mycroft Port to NetBSD, with some bug fixes and minor performance tweaks.
 1.1 05-Jul-1994  mycroft branches: 1.1.1;
Initial revision
 1.1.1.1 05-Jul-1994  mycroft Import the Motorola 68040 Floating Point Software Package.
 1.3.50.1 08-Jan-2002  nathanw Catch up to -current.
 1.3.46.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.3 11-Jun-2001  wiz branches: 1.3.8;
Fix various misspellings of compatible/compatibility.
 1.2 26-Oct-1994  cgd branches: 1.2.44;
new RCS ID format.
 1.1 05-Jul-1994  mycroft branches: 1.1.1;
Initial revision
 1.1.1.1 05-Jul-1994  mycroft Import the Motorola 68040 Floating Point Software Package.
 1.2.44.1 21-Jun-2001  nathanw Catch up to -current.
 1.3.8.2 11-Jun-2001  wiz Fix various misspellings of compatible/compatibility.
 1.3.8.1 11-Jun-2001  wiz file x_bsun.sa was added on branch nathanw_sa on 2001-06-11 01:50:55 +0000
 1.2 26-Oct-1994  cgd new RCS ID format.
 1.1 05-Jul-1994  mycroft branches: 1.1.1;
Initial revision
 1.1.1.1 05-Jul-1994  mycroft Import the Motorola 68040 Floating Point Software Package.
 1.6 08-Dec-2024  andvar s/erroneoulsy/erroneously/ in comment.
 1.5 16-Sep-2001  wiz branches: 1.5.4; 1.5.246;
Spell 'occurred' with two 'r's.
 1.4 26-Oct-1994  cgd branches: 1.4.44; 1.4.46;
new RCS ID format.
 1.3 07-Jul-1994  mycroft branches: 1.3.2;
Rewrite an odd instruction.
 1.2 05-Jul-1994  mycroft Port to NetBSD, with some bug fixes and minor performance tweaks.
 1.1 05-Jul-1994  mycroft branches: 1.1.1;
Initial revision
 1.1.1.1 05-Jul-1994  mycroft Import the Motorola 68040 Floating Point Software Package.
 1.3.2.2 07-Jul-1994  mycroft Rewrite an odd instruction.
 1.3.2.1 07-Jul-1994  mycroft file x_operr.sa was added on branch netbsd-1-0 on 1994-07-07 01:49:59 +0000
 1.4.46.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.4.44.1 01-Oct-2001  fvdl Catch up with -current.
 1.5.246.1 02-Aug-2025  perseant Sync with HEAD
 1.5.4.2 16-Sep-2001  wiz Spell 'occurred' with two 'r's.
 1.5.4.1 16-Sep-2001  wiz file x_operr.sa was added on branch nathanw_sa on 2001-09-16 16:34:33 +0000
 1.4 20-Sep-2024  andvar s/resister/register/ in comments.
 1.3 16-Sep-2001  wiz branches: 1.3.4; 1.3.246;
Spell 'occurred' with two 'r's.
 1.2 26-Oct-1994  cgd branches: 1.2.44; 1.2.46;
new RCS ID format.
 1.1 05-Jul-1994  mycroft branches: 1.1.1;
Initial revision
 1.1.1.1 05-Jul-1994  mycroft Import the Motorola 68040 Floating Point Software Package.
 1.2.46.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.2.44.1 01-Oct-2001  fvdl Catch up with -current.
 1.3.246.1 02-Aug-2025  perseant Sync with HEAD
 1.3.4.2 16-Sep-2001  wiz Spell 'occurred' with two 'r's.
 1.3.4.1 16-Sep-2001  wiz file x_ovfl.sa was added on branch nathanw_sa on 2001-09-16 16:34:33 +0000
 1.4 16-Sep-2001  wiz branches: 1.4.4;
Spell 'occurred' with two 'r's.
 1.3 26-Oct-1994  cgd branches: 1.3.44; 1.3.46;
new RCS ID format.
 1.2 05-Jul-1994  mycroft Port to NetBSD, with some bug fixes and minor performance tweaks.
 1.1 05-Jul-1994  mycroft branches: 1.1.1;
Initial revision
 1.1.1.1 05-Jul-1994  mycroft Import the Motorola 68040 Floating Point Software Package.
 1.3.46.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.3.44.1 01-Oct-2001  fvdl Catch up with -current.
 1.4.4.2 16-Sep-2001  wiz Spell 'occurred' with two 'r's.
 1.4.4.1 16-Sep-2001  wiz file x_snan.sa was added on branch nathanw_sa on 2001-09-16 16:34:33 +0000
 1.5 08-Apr-2022  andvar fix various typos, mainly in comments, but also log messages, docs, game text.
 1.4 09-Dec-2001  briggs The new toolchain wants to generate relocatable branches to globally-defined
symbols--even when the branches are local and would otherwise work with
bxx.b. Compensate for this by shadowing the relevant labels with local
labels.
 1.3 26-Oct-1994  cgd branches: 1.3.46; 1.3.50;
new RCS ID format.
 1.2 05-Jul-1994  mycroft Port to NetBSD, with some bug fixes and minor performance tweaks.
 1.1 05-Jul-1994  mycroft branches: 1.1.1;
Initial revision
 1.1.1.1 05-Jul-1994  mycroft Import the Motorola 68040 Floating Point Software Package.
 1.3.50.1 08-Jan-2002  nathanw Catch up to -current.
 1.3.46.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.6 20-Sep-2024  andvar s/resister/register/ in comments.
 1.5 25-Jan-2022  andvar branches: 1.5.10;
fix various typos in comments.
 1.4 16-Sep-2001  wiz branches: 1.4.4;
Spell 'occurred' with two 'r's.
 1.3 26-Oct-1994  cgd branches: 1.3.44; 1.3.46;
new RCS ID format.
 1.2 05-Jul-1994  mycroft Port to NetBSD, with some bug fixes and minor performance tweaks.
 1.1 05-Jul-1994  mycroft branches: 1.1.1;
Initial revision
 1.1.1.1 05-Jul-1994  mycroft Import the Motorola 68040 Floating Point Software Package.
 1.3.46.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.3.44.1 01-Oct-2001  fvdl Catch up with -current.
 1.4.4.2 16-Sep-2001  wiz Spell 'occurred' with two 'r's.
 1.4.4.1 16-Sep-2001  wiz file x_unfl.sa was added on branch nathanw_sa on 2001-09-16 16:34:33 +0000
 1.5.10.1 02-Aug-2025  perseant Sync with HEAD
 1.2 26-Oct-1994  cgd new RCS ID format.
 1.1 05-Jul-1994  mycroft branches: 1.1.1;
Initial revision
 1.1.1.1 05-Jul-1994  mycroft Import the Motorola 68040 Floating Point Software Package.
 1.2 26-Oct-1994  cgd new RCS ID format.
 1.1 05-Jul-1994  mycroft branches: 1.1.1;
Initial revision
 1.1.1.1 05-Jul-1994  mycroft Import the Motorola 68040 Floating Point Software Package.
 1.38 30-Nov-2024  christos Create a new header lwp_private.h to contain _lwp_getprivate_fast,
_lwp_gettcb_fast, _lwp_settcb and remove them from mcontext.h, so that:
1. we don't need special hacks to hide them
2. we can include <lwp.h> where needed to get the necessary prototypes
without redefining them locally.
 1.37 04-Nov-2024  christos Undo previous lwp.h change.
 1.36 03-Nov-2024  christos Split __lwp_getprivate_fast and __lwp_*tcb from mcontext.h into a separate
lwp.h file.
 1.35 14-Jan-2024  thorpej branches: 1.35.2;
Add a common m68k interrupt dispatch implementation.
 1.34 27-Dec-2023  thorpej Add a header file for 68030-specific MMU definitions, specifically the
Transparent Translation registers, that do not exist on the 68851. A
big comment at the top of the file describes the differences between
the 68851 and the 68030's MMU.
 1.33 27-Dec-2023  thorpej Add new headers that describe the 68851 (and 68030) MMU and
68040 (and 68060) MMU structures using names that more closely
align with Motorola's documentation.

The definitions here automagically adapt to 4K or 8K pages, based
on the value of PGSHIFT, which must be a compile-time constant.
 1.32 01-Feb-2020  tsutsui Add MAX/MIN PAGE_SIZE and PAGE_SHIFT definitions of m68k for jemalloc(3).

Background:
- All m68k ports have fixed PAGE_SIZE value in their kernels,
but each port uses different PAGE_SIZE value (4096 or 8192)
due to historical reasons.
- Currently module(7) binaries are built per each port so
all m68k kernel sources don't support run-time variable PAGE_SIZE.
- MI <uvm/uvm_param.h> assumes that the port supports a variable
PAGE_SIZE on module(7) builds if both MAX_PAGE_SIZE and MIN_PAGE_SIZE
are defined and they have different values.
- On the other hand, jemalloc(3) checks MAX_PAGE_SHIFT in
src/external/bsd/jemalloc/include/jemalloc/internal/jemalloc_internal_defs.h
for internal optimization.
- m68k ports share userland binaries (especially pkgsrc binaries)
among all ports, so we need to define MAX_PAGE_SHIFT as 13 to
support m68k ports where PAGE_SIZE==8192.
(though this would affect only if static binaries built on
4k page hosts are executed on 8k page hosts)

To solve these inconsistency on PAGE_SIZE definitions,
we should have an independent PAGE_SIZE related definitions
for userland, but it requires major reorganization.
For now (especially for netbsd-9) we define MAX/MIN PAGE_SIZE and
PAGE_SHIFT values in <m68k/vmparam.h> only in !defined(_KERNEL) case.

Discussed on source-changes-d@ and tech-kern@ with christos@ and thorpej@:
https://mail-index.netbsd.org/source-changes-d/2020/01/thread1.html#012035
https://mail-index.netbsd.org/tech-kern/2020/01/thread1.html#025954

Should be pulled up to netbsd-9.
 1.31 22-Aug-2018  msaitoh branches: 1.31.4; 1.31.6;
- Cleanup for dynamic sysctl:
- Remove unused *_NAMES macros for sysctl.
- Remove unused *_MAXID for sysctls.
- Move CTL_MACHDEP sysctl definitions for m68k into m68k/include/cpu.h and
use them on all m68k machines.
 1.30 12-Jul-2018  maxv Remove the kernel PMC code. Sent yesterday on tech-kern@.

This change:

* Removes "options PERFCTRS", the associated includes, and the associated
ifdefs. In doing so, it removes several XXXSMPs in the MI code, which is
good.

* Removes the PMC code of ARM XSCALE.

* Removes all the pmc.h files. They were all empty, except for ARM XSCALE.

* Reorders the x86 PMC code not to rely on the legacy pmc.h file. The
definitions are put in sysarch.h.

* Removes the kern/sys_pmc.c file, and along with it, the sys_pmc_control
and sys_pmc_get_info syscalls. They are marked as OBSOL in kern,
netbsd32 and rump.

* Removes the pmc_evid_t and pmc_ctr_t types.

* Removes all the associated man pages. The sets are marked as obsolete.
 1.29 24-Dec-2015  christos branches: 1.29.16; 1.29.18;
fenv for m68k
 1.28 17-Jul-2013  matt branches: 1.28.8;
Export fpreg.h for libc
 1.27 17-Jul-2011  joerg branches: 1.27.2; 1.27.12; 1.27.16;
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.26 09-Feb-2007  ad Merge newlock2 to head.
 1.25 26-Jul-2006  drochner branches: 1.25.4;
don't install <machine/db_machdep.h>, this is kernel only
 1.24 13-Apr-2006  oster Populate /usr/include/m68k with both pmap_motorola.h and pte_motorola.h.
/usr/include/m68k/pmap.h expects to find pmap_motorola.h, and
/usr/include/machine/pte.h wants pte_motorola.h.
 1.23 11-Dec-2005  christos branches: 1.23.4; 1.23.6; 1.23.8; 1.23.10; 1.23.12;
merge ktrace-lwp.
 1.22 08-May-2004  kleink branches: 1.22.12;
Factor out W{CHAR,INT}_{MAX,MIN} into their own header file.
 1.21 22-Sep-2003  cl SA_SIGINFO support for m68k
 1.20 17-Jan-2003  thorpej branches: 1.20.2;
Merge the nathanw_sa branch.
 1.19 26-Nov-2002  lukem Remove KDIR=, since SYS_INCLUDE=symlinks and KDIR are not supported any more.
 1.18 07-Aug-2002  briggs Implement pmc(9) -- An interface to hardware performance monitoring
counters. These counters do not exist on all CPUs, but where they
do exist, can be used for counting events such as dcache misses that
would otherwise be difficult or impossible to instrument by code
inspection or hardware simulation.

pmc(9) is meant to be a general interface. Initially, the Intel XScale
counters are the only ones supported.
 1.17 13-Jul-2002  scw m68k syscall rototill:

- Switch all m68k-based ports over to __HAVE_SYSCALL_INTERN.
- Add systrace glue.
- Define struct mdproc in <m68k/proc.h> instead of <machine/proc.h>.
(They were all defined exactly the same anyway, other than a couple
of the MDP_* flags.)
 1.16 10-Apr-2002  briggs branches: 1.16.2;
bus_dma(9) pulled pretty much verbatim from next68k.
 1.15 28-Nov-2001  kleink No point in installing svr4_machdep.h.
 1.14 15-Apr-2001  kleink branches: 1.14.2; 1.14.8;
Add definitions of C99 integer format conversion macros.
XXX Fastest minimum-width integer types haven't been decided upon yet.
 1.13 15-Apr-2001  kleink Add definitions of C99 specified-width integer type limits.
XXX Fastest minimum-width integer types haven't been decided upon yet.
 1.12 14-Apr-2001  kleink Add definitions of C99 integer constant macros.
Tidy Makefiles up a little.
 1.11 14-Apr-2001  kleink Add definitions of C99 minimum-width and greatest-width integer types.
XXX Fastest minimum-width integer types haven't been decided upon yet.
 1.10 06-Apr-2001  tsutsui Install byte_swap.h on make includes.
 1.9 26-Jun-2000  kleink branches: 1.9.2;
Add <machine/int_types.h>, which provides namespace-pure definitions
of exact-width integer types.
 1.8 29-Apr-2000  thorpej Require that each each MACHINE/MACHINE_ARCH supply a lock.h. This file
contains the values __SIMPLELOCK_LOCKED and __SIMPLELOCK_UNLOCKED, which
replace the old SIMPLELOCK_LOCKED and SIMPLELOCK_UNLOCKED. These files
are also required to supply inline functions __cpu_simple_lock(),
__cpu_simple_lock_try(), and __cpu_simple_unlock() if locking is to be
supported on that platform (i.e. if MULTIPROCESSOR is defined in the
_KERNEL case). Change these functions to take an int * (&alp->lock_data)
rather than the struct simplelock * itself.

These changes make it possible for userland to use the locking primitives
by including <machine/lock.h>.
 1.7 17-Mar-2000  tron Install "machineendian_machdep.h".
 1.6 23-Dec-1999  kleink C99: Define a NAN macro in <math.h> which evaulates to a constant expression of
a single-precision quiet NaN; only to be defined on platforms that do support
this value.
 1.5 19-Apr-1999  kleink branches: 1.5.2;
Add COMPAT_SVR4 for m68k.
 1.4 09-Feb-1999  is branches: 1.4.4;
Provide a minimal instruction/data cache synchronization C binding.
(The function has always been in the kernels as special trap #12).
In response to PR 4951 by Hauke Fath.
 1.3 15-Jan-1999  bouyer Move the bswap functions from libutil to libc (this bups the
minor of libc and the major of libutil). For little-endian architectures
merge the bnswap() assembly versions with nto* and hton* using symbols
aliasing. Use symbol renaming for the bswap function in this case to avoid
namespace pollution.
Declare bswap* in machine/bswap.h, not machine/endian.h. For little-endian
machines, common code for inline macros go in machine/byte_swap.h
Sync libkern with libc.
Adjust #include in kernel sources for machine/bswap.h.
 1.2 12-Jul-1998  veego Add elf_machdep.h to the INCS list.
 1.1 12-Jun-1998  cgd Rework the way kernel include files are installed. In the new method,
as with user-land programs, include files are installed by each directory
in the tree that has includes to install. (This allows more flexibility
as to what gets installed, makes 'partial installs' easier, and gives us
more options as to which machines' includes get installed at any given
time.) The old SYS_INCLUDES={symlinks,copies} behaviours are _both_
still supported, though at least one bug in the 'symlinks' case is
fixed by this change. Include files can't be build before installation,
so directories that have includes as targets (e.g. dev/pci) have to move
those targets into a different Makefile.
 1.4.4.1 21-Jun-1999  thorpej Sync w/ -current.
 1.5.2.2 21-Apr-2001  bouyer Sync with HEAD
 1.5.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.9.2.2 21-Jun-2001  nathanw Catch up to -current.
 1.9.2.1 09-Apr-2001  nathanw Catch up with -current.
 1.14.8.10 11-Dec-2002  thorpej Sync with HEAD.
 1.14.8.9 13-Aug-2002  nathanw Catch up to -current.
 1.14.8.8 06-Aug-2002  nathanw m68k/lwp.h is gone.
 1.14.8.7 01-Aug-2002  nathanw Catch up to -current.
 1.14.8.6 17-Apr-2002  nathanw Catch up to -current.
 1.14.8.5 08-Jan-2002  nathanw Catch up to -current.
 1.14.8.4 21-Nov-2001  scw Install lwp.h during `includes' pass.
 1.14.8.3 17-Nov-2001  scw Kernel support for Scheduler Activations on m68k-based ports using
mvme68k as a testbed.

Boots multi-user on an mvme162, although userland support for SA is not
yet integrated/tested.
 1.14.8.2 10-Nov-2001  scw Kernel mcontext glue for Scheduler Activations on m68k from
Klaus Klein <kleink@netbsd.org>.
 1.14.8.1 15-Apr-2001  scw file Makefile was added on branch nathanw_sa on 2001-11-10 21:22:50 +0000
 1.14.2.3 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.14.2.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.14.2.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.16.2.2 31-Aug-2002  gehenna catch up with -current.
 1.16.2.1 16-Jul-2002  gehenna catch up with -current.
 1.20.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.20.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.20.2.1 03-Aug-2004  skrll Sync with HEAD
 1.22.12.3 26-Feb-2007  yamt sync with head.
 1.22.12.2 30-Dec-2006  yamt sync with head.
 1.22.12.1 21-Jun-2006  yamt sync with head.
 1.23.12.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.23.10.1 19-Apr-2006  elad sync with head - hopefully this will work
 1.23.8.2 11-Aug-2006  yamt sync with head
 1.23.8.1 24-May-2006  yamt sync with head.
 1.23.6.1 22-Apr-2006  simonb Sync with head.
 1.23.4.1 09-Sep-2006  rpaulo sync with head
 1.25.4.1 01-Feb-2007  ad Header file cleanup.
 1.27.16.1 28-Aug-2013  rmind sync with head
 1.27.12.2 03-Dec-2017  jdolecek update from HEAD
 1.27.12.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.27.2.1 22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.28.8.1 27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.29.18.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.29.18.1 10-Jun-2019  christos Sync with HEAD
 1.29.16.2 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.29.16.1 28-Jul-2018  pgoyette Sync with HEAD
 1.31.6.1 29-Feb-2020  ad Sync with head.
 1.31.4.1 10-Feb-2020  martin Pull up following revision(s) (requested by tsutsui in ticket #682):

sys/arch/next68k/include/vmparam.h: revision 1.27
sys/arch/mac68k/include/vmparam.h: revision 1.46
sys/arch/sun3/include/vmparam.h: revision 1.38
sys/arch/m68k/include/vmparam.h: revision 1.1
sys/arch/hp300/include/vmparam.h: revision 1.41
sys/arch/m68k/include/Makefile: revision 1.32
sys/arch/amiga/include/vmparam.h: revision 1.48
distrib/sets/lists/comp/ad.m68k: revision 1.63
sys/arch/x68k/include/vmparam.h: revision 1.40
sys/arch/mvme68k/include/vmparam.h: revision 1.38
sys/arch/luna68k/include/vmparam.h: revision 1.23
sys/arch/news68k/include/vmparam.h: revision 1.23
sys/arch/atari/include/vmparam.h: revision 1.34
sys/arch/cesfic/include/vmparam.h: revision 1.19

Add MAX/MIN PAGE_SIZE and PAGE_SHIFT definitions of m68k for jemalloc(3).

Background:
- All m68k ports have fixed PAGE_SIZE value in their kernels,
but each port uses different PAGE_SIZE value (4096 or 8192)
due to historical reasons.
- Currently module(7) binaries are built per each port so
all m68k kernel sources don't support run-time variable PAGE_SIZE.
- MI <uvm/uvm_param.h> assumes that the port supports a variable
PAGE_SIZE on module(7) builds if both MAX_PAGE_SIZE and MIN_PAGE_SIZE
are defined and they have different values.
- On the other hand, jemalloc(3) checks MAX_PAGE_SHIFT in
src/external/bsd/jemalloc/include/jemalloc/internal/jemalloc_internal_defs.h
for internal optimization.
- m68k ports share userland binaries (especially pkgsrc binaries)
among all ports, so we need to define MAX_PAGE_SHIFT as 13 to
support m68k ports where PAGE_SIZE==8192.
(though this would affect only if static binaries built on
4k page hosts are executed on 8k page hosts)

To solve these inconsistency on PAGE_SIZE definitions,
we should have an independent PAGE_SIZE related definitions
for userland, but it requires major reorganization.

For now (especially for netbsd-9) we define MAX/MIN PAGE_SIZE and
PAGE_SHIFT values in <m68k/vmparam.h> only in !defined(_KERNEL) case.

Discussed on source-changes-d@ and tech-kern@ with christos@ and thorpej@:
https://mail-index.netbsd.org/source-changes-d/2020/01/thread1.html#012035
https://mail-index.netbsd.org/tech-kern/2020/01/thread1.html#025954

Should be pulled up to netbsd-9.
 1.35.2.1 02-Aug-2025  perseant Sync with HEAD
 1.25 07-May-2019  kamil Switch all users (except ia64) of custom machine/ansi.h to common_ansi.h

Deduplicate the code among ports and poll definitions of types
directly from a compiler.

This fixes miscompilation of certain programs that instruct compilers
to generate code for different types. This bug has been detected with
-fshort-wchar in EFI firmware.

Proposed and discussed on a mailing list (twice).

Itanium uses custom !ELF fallback switch, temporarily leave it as it is.
 1.24 17-Jun-2015  martin branches: 1.24.18;
Make clock_t unsigned int everywhere.
Ok: matt@, mrg@
 1.23 17-Jul-2011  joerg branches: 1.23.12; 1.23.28; 1.23.30;
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.22 27-Mar-2010  tnozaki 1. {wctype,wctrans,mbstate}_t: switch MD to MI like other
libc implementation (such as *BSD and glibc2).

2. don't typedef void * wc{type,trans}_t, suggested by soda@-san.
it may pass through compiler type check, it's harmful.
so i introduce dummy struct __tag_wc{type,trans}_t(iconv_t already does).

no ABI change was made.
 1.21 11-Jan-2009  christos branches: 1.21.4; 1.21.6;
merge christos-time_t
 1.20 17-Oct-2007  garbled branches: 1.20.16; 1.20.18; 1.20.22; 1.20.30;
Merge the ppcoea-renovation branch to HEAD.

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

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

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.19 03-Sep-2007  drochner clean up some definitions around rune_t which are not needed anymore
 1.18 04-Oct-2006  tnozaki branches: 1.18.8; 1.18.16; 1.18.22; 1.18.26; 1.18.28;
fix gcc -Werror -Wmissing-braces problem
mbstate_t(this is opaque object)'s initializer should be ``{ 0 }'',
so changed 1st field of union from character array to integer.
 1.17 11-Dec-2005  christos branches: 1.17.20; 1.17.22;
merge ktrace-lwp.
 1.16 14-Apr-2005  matt branches: 1.16.2;
For GCC3 and beyond, use the __builtin_va_* types and functions to
deal with variable argument lists.
 1.15 07-Aug-2003  agc branches: 1.15.8;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.14 02-Mar-2003  tshiozak branches: 1.14.2;
add some ISO C 1995 I18N functions and types:
btowc, wctrans, towctrans, wcscoll, wcsxfrm, wctype_t and wctrans_t.
 1.13 03-Jan-2001  takemura replace 'long long' with int64_t to compile stand alone program with
compiler other than GCC.
 1.12 26-Dec-2000  itojun make mbstate_t bigger (32 -> 128 bytes).
XXX if you have libc after citrus locale import, please recompile libc,
and your applications that use mbstate_t (rather rare). really sorry
for the mess.
 1.11 21-Dec-2000  itojun populate _BSD_MBSTATE_T_. add warning regarding to rune_t.
 1.10 27-Jun-2000  kleink G/c _BSD_INTPTR_T_ and _BSD_UINTPTR_T_.
 1.9 27-Apr-1998  kleink branches: 1.9.14; 1.9.22;
Provide definitions for intptr_t and uintptr_t, signed resp. unsigned integral
types large enough to hold any pointer.
 1.8 23-Nov-1997  kleink Add _BSD_SUSECONDS_T_ and _BSD_USECONDS_T_; do some space vs. tab formatting
cleanup
 1.7 15-Nov-1996  jtc Define _BSD_CLOCKID_T_ and _BSD_TIMER_T_
 1.6 16-Mar-1996  jtc Add _BSD_WINT_T_ definition so we can handle wint_t type added in NA1.
 1.5 26-Oct-1994  cgd new RCS ID format.
 1.4 21-May-1994  cgd new way of naming things
 1.3 09-May-1994  chopps Add _SSIZE_T_.
 1.2 22-May-1993  cgd add rcsids to everything and clean up headers
 1.1 13-May-1993  cgd add from net2. were symlinks to ../../vax/include/*
 1.9.22.1 28-May-2000  minoura Citrus Project XPG4DL, an implementation of I18N (locale) framework,
is imported.
 1.9.14.2 05-Jan-2001  bouyer Sync with HEAD
 1.9.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.2.4 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.14.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.14.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.14.2.1 03-Aug-2004  skrll Sync with HEAD
 1.15.8.1 29-Apr-2005  kent sync with -current
 1.16.2.2 27-Oct-2007  yamt sync with head.
 1.16.2.1 30-Dec-2006  yamt sync with head.
 1.17.22.1 22-Oct-2006  yamt sync with head
 1.17.20.1 18-Nov-2006  ad Sync with head.
 1.18.28.1 06-Nov-2007  matt sync with HEAD
 1.18.26.1 02-Oct-2007  joerg Sync with HEAD.
 1.18.22.1 10-Sep-2007  skrll Sync with HEAD.
 1.18.16.1 03-Oct-2007  garbled Sync with HEAD
 1.18.8.1 09-Oct-2007  ad Sync with head.
 1.20.30.1 19-Jan-2009  skrll Sync with HEAD.
 1.20.22.2 11-Aug-2010  yamt sync with head.
 1.20.22.1 04-May-2009  yamt sync with head.
 1.20.18.3 04-Jan-2009  christos revert all but time_t
 1.20.18.2 30-Mar-2008  christos time_t is now __int64_t
 1.20.18.1 29-Mar-2008  christos Welcome to the time_t=long long dev_t=uint64_t branch.
 1.20.16.1 17-Jan-2009  mjf Sync with HEAD.
 1.21.6.1 30-May-2010  rmind sync with head
 1.21.4.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.23.30.1 22-Sep-2015  skrll Sync with HEAD
 1.23.28.1 16-Jul-2015  riz Pull up following revision(s) (requested by martin in ticket #846):
sys/arch/mips/include/ansi.h: revision 1.29
sys/arch/sh3/include/ansi.h: revision 1.16
sys/arch/sparc64/include/ansi.h: revision 1.18
sys/arch/m68k/include/ansi.h: revision 1.24
sys/arch/powerpc/include/ansi.h: revision 1.30
sys/arch/hppa/include/ansi.h: revision 1.14
sys/arch/i386/include/ansi.h: revision 1.27
sys/arch/alpha/include/ansi.h: revision 1.25
sys/arch/usermode/include/ansi.h: revision 1.5
sys/arch/sparc/include/ansi.h: revision 1.24
Make _BSD_CLOCK_T_ unsigned int so it's the same for IPL32 and LP64
environments. We don't really have a powerpc64 native userland
and the mips64 native userland is IPL32 so this shouldn't affect anything.
Make clock_t unsigned
Make clock_t unsigned int everywhere.
Ok: matt@, mrg@
 1.23.12.1 03-Dec-2017  jdolecek update from HEAD
 1.24.18.1 10-Jun-2019  christos Sync with HEAD
 1.4 10-Dec-2002  thorpej Rename __LDPGSZ to AOUT_LDPGSZ, to accurately reflect what it is.
 1.3 18-May-2001  fredette branches: 1.3.8;
Don't define __LDPGSZ if it's already defined.
 1.2 09-Apr-1997  thorpej branches: 1.2.34;
Garbage-collect some things no longer needed since there are no longer
m68k4k ports.
 1.1 08-Sep-1996  thorpej All of the m68k ports' exec.h's were essentially the same. Merge them.

Override the N_PAGSIZ() macro; this one checks the MID of the executable
and returns the appropriate page size.
 1.2.34.1 21-Jun-2001  nathanw Catch up to -current.
 1.3.8.2 11-Dec-2002  thorpej Sync with HEAD.
 1.3.8.1 18-May-2001  thorpej file aout_machdep.h was added on branch nathanw_sa on 2002-12-11 06:10:40 +0000
 1.37 06-Jan-2025  martin PR 58960: fix misunderstanding in semantic and provide both the original
id string as well as _NETBSD_REVISIONID.
Do not rely on string concatenation in the inline assembler, use .ascii
and .asciz for individual string parts instead.
 1.36 04-Jan-2025  martin PR 58960: m68k/asm.h: Respect NETBSD_REVISIONID.
 1.35 26-Sep-2023  tsutsui branches: 1.35.6;
Remove trailing spaces and TABs.
 1.34 17-Apr-2020  joerg Mark the .ident section as mergable string section to avoid redundant
entries.
 1.33 12-Sep-2013  joerg branches: 1.33.30; 1.33.40;
Pass PICFLAGS down to cc-as-as and use __PIC__ to decide if it is small
vs big PIC mode. Retire -DPIC and -DBIGPIC.
 1.32 18-Jul-2013  matt Adjust LEA_LCL, GOT_SETUP, INTERRUPT_{SAVE,RESTORE}REG for Coldfire
 1.31 16-Jul-2013  matt branches: 1.31.2;
Make INTERRUPT_{SAVE,RESTORE}REG visible to userland
 1.30 16-Jul-2013  matt Remove non __ELF__ clauses.
Add GOT_SETUP and LEA_LCL macros.
 1.29 16-Jul-2013  matt Add an END macro. reorder EXTBL macro
 1.28 12-Feb-2011  matt branches: 1.28.4; 1.28.14; 1.28.18;
Put RCSIDs in section .ident. (use .pushsection/.popsection)
 1.27 20-Dec-2010  joerg branches: 1.27.2; 1.27.4;
Consistently use .gnu.warning with .pushsectio and .popsection on all
architectures instead of obsolete STABS frames for linker warnings.
 1.26 20-Dec-2010  matt Move counting of faults, traps, intrs, soft[intr]s, syscalls, and nswtch
from uvmexp to per-cpu cpu_data and move them to 64bits. Remove unneeded
includes of <uvm/uvm_extern.h> and/or <uvm/uvm.h>.
 1.25 28-Apr-2008  martin branches: 1.25.22;
Remove clause 3 and 4 from TNF licenses
 1.24 20-Jan-2006  christos branches: 1.24.72; 1.24.74; 1.24.76;
Add a STRONG_ALIAS macro
 1.23 27-May-2001  chs branches: 1.23.8; 1.23.40; 1.23.52;
mcount() is named __mcount() on ELF, do the right thing.
 1.22 12-May-2001  chs define VECTOR() and friends in non-_KERNEL environments too.
 1.21 03-May-2001  fredette Add an EXTBL macro.
 1.20 23-Jun-2000  kleink branches: 1.20.2;
Add a WEAK_ALIAS() macro.
 1.19 25-Oct-1999  thorpej branches: 1.19.6;
Add register prefixes.
 1.18 01-May-1999  kleink branches: 1.18.2; 1.18.4; 1.18.6;
* Change multiple inclusion protection symbols to use the standard naming
convention (not that it should matter for assembly).
* Provide an additional set of _C_LABEL() macros for ELF.
* Provide a PIC_PLT() macro for the benefit of ELF.
 1.17 02-Dec-1998  thorpej branches: 1.17.6;
Argh, fix the ANSI CPP version of the a.out WARN_REFERENCES().
 1.16 02-Dec-1998  thorpej Implement WARN_REFERENCES().
 1.15 04-Oct-1997  thorpej Copyright assigned to The NetBSD Foundation.
 1.14 14-Jul-1997  thorpej branches: 1.14.2;
Don't have kernel vs. non-kernel versions of _ENTRY(); there's no
reason to omit the .type directive in the kernel case.
 1.13 24-Apr-1997  thorpej Add several useful macros:
- ENTRY_NOPROFILE() and ASENTRY_NOPROFILE(), similar to ENTRY() and
ASENTRY(), but without the profiling prologue.
- GLOBAL()/ASGLOBAL() and LOCAL()/ASLOCAL(), for defining global and
local variables with C and ASM labels.
- BSS()/ASBSS(), for defining items in the BSS segment, with C or
ASM labels.
- PANIC("panic message") - shorthand for calling panic() from assembly code.
- VECTOR(), ASVECTOR(), VECTOR_UNUSED - shorthand for defining entries
in the vector table.
Also, change RCSID() to pad out the string to even boundary.
 1.12 30-Nov-1996  jtc PROF -> GPROF
 1.11 24-Sep-1996  jtc Added new macro _PROF_PROLOG which contains the code sequence needed
to call mcount(). This is needed because the ``link a6,#0'' insn used
trips up gcc's ANSI preprocessor (A # in a function-type macro must be
followed by a macro argument). _PROF_PROLOG is also used in the i386
asm.h.

Solaris' asm_linkage.h has a MCOUNT macro similar to _PROF_PROLOG
except it expands to different code sequences based on whether a
function is being compiled with "prof" or "gprof" instrumentation.

I also discovered that the m68k ALTENTRY is very different than the
implementation used by other NetBSD ports. Usually ALTENTRY simply
provides an alternate function entry point. The m68k version takes a
second argument and jumps inside the second function when profiling is
enabled. The m68k behavior is similar to the ENTRY2 macro found in
solaris.

Providing ENTRY2 and changing all the code that uses ALTENTRY to use
it would be a desirable change.
 1.10 26-Mar-1995  briggs KERNEL -> _KERNEL
 1.9 26-Oct-1994  cgd new RCS ID format.
 1.8 18-Mar-1994  brezak Add RCSID macro; be sure ENTRY is in .text
 1.7 01-Mar-1994  glass so you can compile a kernel w/o using our hacked gas
 1.6 30-Jan-1994  mycroft Remove bogus \ that someone inserted.
 1.5 30-Jan-1994  mycroft GPROF --> PROF
 1.4 29-Jan-1994  mycroft Forgot the .even...
 1.3 29-Jan-1994  mycroft Fix typo.
 1.2 29-Jan-1994  mycroft Add .type directive.
 1.1 22-Jan-1994  briggs Define ENTRY and ALTENTRY--hopefully for both STDC and K&R style...
Nabbed & mangled from sun3/include/asm.h and locore.s...
 1.14.2.1 14-Oct-1997  thorpej Update marc-pcmcia branch from trunk.
 1.17.6.1 21-Jun-1999  thorpej Sync w/ -current.
 1.18.6.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.18.4.1 15-Nov-1999  fvdl Sync with -current
 1.18.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.19.6.1 25-Jul-2000  kleink Pull up rev. 1.20 (approved by thorpej):
For ELF, add a WEAK_ALIAS() macro.
 1.20.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.23.52.1 01-Feb-2006  yamt sync with head.
 1.23.40.1 21-Jun-2006  yamt sync with head.
 1.23.8.2 27-May-2001  chs mcount() is named __mcount() on ELF, do the right thing.
 1.23.8.1 27-May-2001  chs file asm.h was added on branch nathanw_sa on 2001-05-27 01:01:09 +0000
 1.24.76.1 16-May-2008  yamt sync with head.
 1.24.74.1 18-May-2008  yamt sync with head.
 1.24.72.1 02-Jun-2008  mjf Sync with HEAD.
 1.25.22.1 05-Mar-2011  rmind sync with head
 1.27.4.1 17-Feb-2011  bouyer Sync with HEAD
 1.27.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.28.18.2 18-May-2014  rmind sync with head
 1.28.18.1 28-Aug-2013  rmind sync with head
 1.28.14.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.28.4.1 22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.31.2.1 23-Jul-2013  riastradh sync with HEAD
 1.33.40.1 20-Apr-2020  bouyer Sync with HEAD
 1.33.30.1 21-Apr-2020  martin Sync with HEAD
 1.35.6.1 02-Aug-2025  perseant Sync with HEAD
 1.10 18-May-2022  andvar fix typos in word "access" and it derivatives, mainly in comments.
 1.9 20-Oct-2009  snj Remove 3rd and 4th clause on Leo Weppelman's license. OK leo@.
 1.8 03-Aug-2006  mhitch branches: 1.8.62;
gcc4 checks for and warns of matching constraints that don't specify
a register operand. Remove the matching constraint and change the output
operand constraint from "=m" (write-only) to "+m" (read-write).
 1.7 27-Jun-2006  tsutsui Backout previous since there is an objection and I'm not a toolchain guy.
 1.6 25-Jun-2006  tsutsui Fix "warning: matching constraint does not allow a register" on gcc4.
(I guess constraints "0-9" are valid only for register operands, right?)
 1.5 24-Dec-2005  perry branches: 1.5.4; 1.5.8; 1.5.16;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.
 1.4 25-Jan-2002  thorpej branches: 1.4.32;
Fix asm constraints. Sun3 kernels built with the new toolchain boot now.
 1.3 25-Jul-1998  is branches: 1.3.28; 1.3.32;
no semicolon, please
 1.2 05-Nov-1997  thorpej asm -> __asm__, volatile -> __volatile
 1.1 16-Sep-1996  leo branches: 1.1.14;
Add macro's that do bclr/bset in a single instruction.
 1.1.14.1 05-Nov-1997  thorpej Pullup from trunk: asm -> __asm__, volatile -> __volatile
 1.3.32.1 28-Feb-2002  nathanw Catch up to -current.
 1.3.28.1 11-Feb-2002  jdolecek Sync w/ -current.
 1.4.32.2 30-Dec-2006  yamt sync with head.
 1.4.32.1 21-Jun-2006  yamt sync with head.
 1.5.16.1 13-Jul-2006  gdamore Merge from HEAD.
 1.5.8.2 11-Aug-2006  yamt sync with head
 1.5.8.1 26-Jun-2006  yamt sync with head.
 1.5.4.1 09-Sep-2006  rpaulo sync with head
 1.8.62.1 11-Mar-2010  yamt sync with head
 1.4 31-Jan-2006  dsl Change sys/arch/xxx/include/bswap.h to #include machine/byte_swap.h then
sys/bswap.h in order to pick up the MD inline routines and the constant
folding definitions in the right order.
Code can include either sys/bswap.h or machine/bswap.h with the same effect.
 1.3 30-Mar-2001  leo branches: 1.3.8; 1.3.40; 1.3.52;
Optimize bswap16() and bswap32() functions to inline assembly.
 1.2 21-Aug-1999  simonb branches: 1.2.2; 1.2.14;
Include <sys/bswap.h> for function prototypes. i386, pc532 and vax
still include <machine/byte_swap.h> and define macros for some of
the bswap*() functions.
 1.1 15-Jan-1999  bouyer Move the bswap functions from libutil to libc (this bups the
minor of libc and the major of libutil). For little-endian architectures
merge the bnswap() assembly versions with nto* and hton* using symbols
aliasing. Use symbol renaming for the bswap function in this case to avoid
namespace pollution.
Declare bswap* in machine/bswap.h, not machine/endian.h. For little-endian
machines, common code for inline macros go in machine/byte_swap.h
Sync libkern with libc.
Adjust #include in kernel sources for machine/bswap.h.
 1.2.14.1 09-Apr-2001  nathanw Catch up with -current.
 1.2.2.1 21-Apr-2001  bouyer Sync with HEAD
 1.3.52.1 01-Feb-2006  yamt sync with head.
 1.3.40.1 21-Jun-2006  yamt sync with head.
 1.3.8.2 30-Mar-2001  leo Optimize bswap16() and bswap32() functions to inline assembly.
 1.3.8.1 30-Mar-2001  leo file bswap.h was added on branch nathanw_sa on 2001-03-30 20:00:06 +0000
 1.14 26-Sep-2023  tsutsui Remove trailing spaces and TABs.
 1.13 05-Dec-2021  msaitoh s/from from/from/ in comment.
 1.12 30-Jun-2011  wiz dependant -> dependent
 1.11 28-Apr-2008  martin 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 07-Jun-2007  tsutsui branches: 1.9.10;
Enable _pmap_set_page_cacheable(), _pmap_set_page_cacheinhibit() and
_pmap_page_is_cacheable() on all pmap_motorola.c ports and add
BUS_DMA_COHERENT support (from mvme68k) to common m68k bus_dma.c.

Tested with (not-yet-integrated) MI Sonic Ethernet driver on mac68k
http://mail-index.netbsd.org/port-mac68k/2007/06/07/0000.html
and ok'ed by thorpej.
 1.8 04-Mar-2007  christos branches: 1.8.2; 1.8.4; 1.8.10;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.7 21-Feb-2007  mrg add a pair of new bus_dma(9) functions:
int _bus_dmatag_subregion(bus_dma_tag_t tag,
bus_addr_t min_addr,
bus_addr_t max_addr,
bus_dma_tag_t *newtag,
int flags)
void _bus_dmatag_destroy(bus_dma_tag_t tag)

that allow a (normally broken/limited) device to restrict the bus address
range it can talk to. this is used by bce(4) to limit DMA addresses to
1GB range, the maximum the chip can address.

all this is from Yorick Hardy <yhardy@uj.ac.za> with input from several
people on tech-kern.

XXX: bus_dma(9) needs an update still.
 1.6 11-Dec-2005  christos branches: 1.6.26;
merge ktrace-lwp.
 1.5 09-Mar-2005  matt branches: 1.5.4;
Add a dm_maxsegsz public member to bus_dmamap_t. This allows a user of the API
to select the maximum segment size for each bus_dmamap_load (up to the maxsegsz
supplied to bus_dmamap_create). dm_maxsegsz is reset to the value supplied to
bus_dmamap_create when the dmamap is unloaded.
 1.4 28-Aug-2004  thorpej branches: 1.4.4; 1.4.6;
De-__P
 1.3 04-Dec-2003  keihan netbsd.org -> NetBSD.org

All "netbsd.org" is now gone from src/sys/arch.
 1.2 28-Jan-2003  kent branches: 1.2.2;
Introduce BUS_DMA_NOCACHE, and bus_dmamem_map() of i386 supports it.
 1.1 10-Apr-2002  briggs branches: 1.1.2; 1.1.8;
bus_dma(9) pulled pretty much verbatim from next68k.
 1.1.8.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.1.8.1 10-Apr-2002  jdolecek file bus_dma.h was added on branch kqueue on 2002-06-23 17:37:40 +0000
 1.1.2.2 17-Apr-2002  nathanw Catch up to -current.
 1.1.2.1 10-Apr-2002  nathanw file bus_dma.h was added on branch nathanw_sa on 2002-04-17 00:03:29 +0000
 1.2.2.5 01-Apr-2005  skrll Sync with HEAD.
 1.2.2.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.2.2.3 18-Sep-2004  skrll Sync with HEAD.
 1.2.2.2 03-Sep-2004  skrll Sync with HEAD
 1.2.2.1 03-Aug-2004  skrll Sync with HEAD
 1.4.6.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.4.4.1 29-Apr-2005  kent sync with -current
 1.5.4.2 03-Sep-2007  yamt sync with head.
 1.5.4.1 26-Feb-2007  yamt sync with head.
 1.6.26.2 12-Mar-2007  rmind Sync with HEAD.
 1.6.26.1 27-Feb-2007  yamt - sync with head.
- move sched_changepri back to kern_synch.c as it doesn't know PPQ anymore.
 1.8.10.1 26-Jun-2007  garbled Sync with HEAD.
 1.8.4.1 11-Jul-2007  mjf Sync with head.
 1.8.2.1 09-Jun-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 18-Mar-2014  riastradh Merge riastradh-drm2 to HEAD.
 1.10 18-Jul-2013  matt Teach to use coldfire isac byterev if available, otherwise let the compiler
figure it since there is rorw instruction to fall back on.
 1.9 28-Apr-2008  martin branches: 1.9.34; 1.9.44; 1.9.50; 1.9.58;
Remove clause 3 and 4 from TNF licenses
 1.8 30-Jan-2006  dsl branches: 1.8.72; 1.8.74; 1.8.76;
Move all the stuff that detects bswapxx(constant) into the MI sys/bswap.h
Put the minimum to define the required inline assembler or C into the MD files.
NB: there may be some fallout from this!
 1.7 28-Dec-2005  perry branches: 1.7.2;
inline -> __inline
 1.6 24-Dec-2005  perry __asm__ -> __asm
__const__ -> const
__inline__ -> inline
__volatile__ -> volatile
 1.5 24-Dec-2005  perry Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.
 1.4 05-Dec-2001  lukem branches: 1.4.32;
convert from macros to static inlines. allen briggs confirms resultant code
is the same with -Ox, for x>0 (as expected).
 1.3 09-Apr-2001  leo branches: 1.3.2; 1.3.4; 1.3.10;
Remove '_KERNEL' conditionalizing. This break userland apps.
Noted by Steve Allan.
 1.2 04-Apr-2001  is branches: 1.2.2;
This only works with data registers.
 1.1 30-Mar-2001  leo Optimize bswap16() and bswap32() functions to inline assembly.
 1.2.2.2 21-Jun-2001  nathanw Catch up to -current.
 1.2.2.1 09-Apr-2001  nathanw Catch up with -current.
 1.3.10.2 08-Jan-2002  nathanw Catch up to -current.
 1.3.10.1 09-Apr-2001  nathanw file byte_swap.h was added on branch nathanw_sa on 2002-01-08 00:25:54 +0000
 1.3.4.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.3.2.2 21-Apr-2001  bouyer Sync with HEAD
 1.3.2.1 09-Apr-2001  bouyer file byte_swap.h was added on branch thorpej_scsipi on 2001-04-21 17:53:55 +0000
 1.4.32.1 21-Jun-2006  yamt sync with head.
 1.7.2.1 01-Feb-2006  yamt sync with head.
 1.8.76.1 16-May-2008  yamt sync with head.
 1.8.74.1 18-May-2008  yamt sync with head.
 1.8.72.1 02-Jun-2008  mjf Sync with HEAD.
 1.9.58.1 23-Jul-2013  riastradh sync with HEAD
 1.9.50.1 28-Aug-2013  rmind sync with head
 1.9.44.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.9.34.1 22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.16 06-Jun-2010  mrg fix PR 6724 - convert m68k options to defflag's. this means that
M680[12346] are now available from opt_m68k_arch.h. FPSP meantioned
in the PR has already been fixed, and i could not find any more.

i built these kernels to ensure i did not break their builds:

amiga: GENERIC DRACO
atari: HADES FALCON MILAN-PCIIDE
mac68k: GENERIC
sun2: GENERIC
sun3: GENERIC GENERIC3X
cesfic: attempted GENERIC, does not build due to lack of machine/bus.h
hp300: GENERIC
luna68k: GENERIC
mvme68k: GENERIC
news68k: GENERIC
next68k: GENERIC
x68k: GENERIC
 1.15 28-Apr-2008  martin branches: 1.15.20; 1.15.22;
Remove clause 3 and 4 from TNF licenses
 1.14 17-Oct-2007  garbled branches: 1.14.16; 1.14.18; 1.14.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.13 13-Jun-2007  he branches: 1.13.10;
Fix the 060 variants to not have conflicting definitions for the
cache ops common to 060 and 040. Also remove the now-redundant
definitions for the 060 variant which simply pointed to the 040
variants.
This fixes the build of the mvme68k VME172 kernel.
 1.12 08-Jun-2007  tsutsui DCFA(), DCPA(), ICPL(), ICPP(), DCPL(), DCPP, DCFL(), and DCFP()
cache ops are identical between M68040 and M68060 and they are not
available on M68020 and M68030, so no need to check cputype even on
multi CPU kernels and they can always be inlined.

This improves MI Sonic xfer speed ~5%.
http://mail-index.netbsd.org/port-mac68k/2007/06/07/0003.html
 1.11 11-Dec-2005  christos branches: 1.11.30; 1.11.32; 1.11.38;
merge ktrace-lwp.
 1.10 28-Aug-2004  thorpej branches: 1.10.12;
De-__P
 1.9 02-Nov-2002  chs branches: 1.9.6;
finish conversion to the common m68k cacheops:
add support for machine-specific flavors of the ops for off-chip caches.
many thanks to Izumi Tsutsui for his help with this.
 1.8 05-Apr-2000  is branches: 1.8.12;
Bug fixes for 68020only or 68030only machines, by Aymeric Vincent.
 1.7 15-Jan-2000  aymeric make DCIAS work for 020-only / 030-only kernels
 1.6 27-Sep-1999  itohy branches: 1.6.2;
Add missing TBIA() definition for 68030-only machine.
 1.5 25-Sep-1999  is Replace leftover vm_offset_t's by paddr_t or vaddr_t, as appropriate.
Rename variables/parameters from "va" to "pa" where they are a paddr_t.
Correct DCIAS to take a paddr_t (instead of vaddr_t).
 1.4 23-Sep-1999  minoura #ifndef _M68K_CACHEOPS_H_ - #endif.
 1.3 02-Sep-1998  leo Nuke vm_offset_t/vm_size_t.
 1.2 15-Sep-1997  leo Add DCFA() definitions.
 1.1 02-Jun-1997  leo branches: 1.1.4;
An attempt to make a generic m68k implementation for cache control operations.
Not yet completely finished.
 1.1.4.1 22-Sep-1997  thorpej Update marc-pcmcia branch from trunk.
 1.6.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.8.12.1 11-Nov-2002  nathanw Catch up to -current
 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-Sep-2004  skrll Sync with HEAD
 1.10.12.1 03-Sep-2007  yamt sync with head.
 1.11.38.1 26-Jun-2007  garbled Sync with HEAD.
 1.11.32.1 11-Jul-2007  mjf Sync with head.
 1.11.30.1 15-Jul-2007  ad Sync with head.
 1.13.10.1 06-Nov-2007  matt sync with HEAD
 1.14.20.2 11-Aug-2010  yamt sync with head.
 1.14.20.1 16-May-2008  yamt sync with head.
 1.14.18.1 18-May-2008  yamt sync with head.
 1.14.16.1 02-Jun-2008  mjf Sync with HEAD.
 1.15.22.1 03-Jul-2010  rmind sync with head
 1.15.20.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.9 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.8 16-Feb-2006  perry branches: 1.8.68; 1.8.70; 1.8.72;
Change "inline" back to "__inline" in .h files -- C99 is still too
new, and some apps compile things in C89 mode. C89 keywords stay.

As per core@.
 1.7 24-Dec-2005  perry branches: 1.7.2; 1.7.4; 1.7.6;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.
 1.6 03-Nov-2002  chs branches: 1.6.22;
use "static __inline" instead of "extern __inline" so that we can
build without optimization.
 1.5 06-Nov-1999  thorpej branches: 1.5.12;
Add register prefixes.
 1.4 02-Sep-1998  leo branches: 1.4.12; 1.4.14; 1.4.18;
Nuke vm_offset_t/vm_size_t.
 1.3 05-Nov-1997  thorpej inline -> __inline
 1.2 13-Oct-1997  leo branches: 1.2.2;
Correct TBIS_20 parameters, add DCFA/DCPA defines for the 020/030 (From
Ignatios).
 1.1 02-Jun-1997  leo branches: 1.1.4;
An attempt to make a generic m68k implementation for cache control operations.
Not yet completely finished.
 1.1.4.1 14-Oct-1997  thorpej Update marc-pcmcia branch from trunk.
 1.2.2.1 05-Nov-1997  thorpej Update from trunk: inline -> __inline
 1.4.18.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.4.14.1 15-Nov-1999  fvdl Sync with -current
 1.4.12.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.5.12.1 11-Nov-2002  nathanw Catch up to -current
 1.6.22.1 21-Jun-2006  yamt sync with head.
 1.7.6.1 22-Apr-2006  simonb Sync with head.
 1.7.4.1 09-Sep-2006  rpaulo sync with head
 1.7.2.1 18-Feb-2006  yamt sync with head.
 1.8.72.1 16-May-2008  yamt sync with head.
 1.8.70.1 18-May-2008  yamt sync with head.
 1.8.68.1 02-Jun-2008  mjf Sync with HEAD.
 1.10 26-Sep-2023  tsutsui Remove trailing spaces and TABs.
 1.9 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.8 16-Feb-2006  perry branches: 1.8.68; 1.8.70; 1.8.72;
Change "inline" back to "__inline" in .h files -- C99 is still too
new, and some apps compile things in C89 mode. C89 keywords stay.

As per core@.
 1.7 24-Dec-2005  perry branches: 1.7.2; 1.7.4; 1.7.6;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.
 1.6 03-Nov-2002  chs branches: 1.6.22;
use "static __inline" instead of "extern __inline" so that we can
build without optimization.
 1.5 06-Nov-1999  thorpej branches: 1.5.12;
Add register prefixes.
 1.4 02-Sep-1998  leo branches: 1.4.12; 1.4.14; 1.4.18;
Nuke vm_offset_t/vm_size_t.
 1.3 05-Nov-1997  thorpej inline -> __inline
 1.2 13-Oct-1997  leo branches: 1.2.2;
Correct TBIS_20 parameters, add DCFA/DCPA defines for the 020/030 (From
Ignatios).
 1.1 02-Jun-1997  leo branches: 1.1.4;
An attempt to make a generic m68k implementation for cache control operations.
Not yet completely finished.
 1.1.4.1 14-Oct-1997  thorpej Update marc-pcmcia branch from trunk.
 1.2.2.1 05-Nov-1997  thorpej Update from trunk: inline -> __inline
 1.4.18.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.4.14.1 15-Nov-1999  fvdl Sync with -current
 1.4.12.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.5.12.1 11-Nov-2002  nathanw Catch up to -current
 1.6.22.1 21-Jun-2006  yamt sync with head.
 1.7.6.1 22-Apr-2006  simonb Sync with head.
 1.7.4.1 09-Sep-2006  rpaulo sync with head
 1.7.2.1 18-Feb-2006  yamt sync with head.
 1.8.72.1 16-May-2008  yamt sync with head.
 1.8.70.1 18-May-2008  yamt sync with head.
 1.8.68.1 02-Jun-2008  mjf Sync with HEAD.
 1.12 27-Dec-2023  thorpej Re-factor the 680x0 Function Code definitions into their own
separate file (as was done on the sun2/sun3 ports ages ago)
and switch everyone to the common header.
 1.11 28-Apr-2008  martin 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 08-Jun-2007  tsutsui branches: 1.9.10;
Use pointers for variables assigned to %a0 by __asm("%a0") so that
gcc may generate silightly better inlined code on optimization.
 1.8 16-Feb-2006  perry branches: 1.8.24; 1.8.26; 1.8.32;
Change "inline" back to "__inline" in .h files -- C99 is still too
new, and some apps compile things in C89 mode. C89 keywords stay.

As per core@.
 1.7 24-Dec-2005  perry branches: 1.7.2; 1.7.4; 1.7.6;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.
 1.6 03-Nov-2002  chs branches: 1.6.22;
use "static __inline" instead of "extern __inline" so that we can
build without optimization.
 1.5 06-Nov-1999  thorpej branches: 1.5.12;
Add register prefixes.
 1.4 25-Sep-1999  is branches: 1.4.2; 1.4.4; 1.4.8;
Replace leftover vm_offset_t's by paddr_t or vaddr_t, as appropriate.
Rename variables/parameters from "va" to "pa" where they are a paddr_t.
Correct DCIAS to take a paddr_t (instead of vaddr_t).
 1.3 02-Sep-1998  leo Nuke vm_offset_t/vm_size_t.
 1.2 05-Nov-1997  thorpej inline -> __inline
 1.1 02-Jun-1997  leo branches: 1.1.8;
An attempt to make a generic m68k implementation for cache control operations.
Not yet completely finished.
 1.1.8.1 05-Nov-1997  thorpej Update from trunk: inline -> __inline
 1.4.8.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.4.4.1 15-Nov-1999  fvdl Sync with -current
 1.4.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.5.12.1 11-Nov-2002  nathanw Catch up to -current
 1.6.22.2 03-Sep-2007  yamt sync with head.
 1.6.22.1 21-Jun-2006  yamt sync with head.
 1.7.6.1 22-Apr-2006  simonb Sync with head.
 1.7.4.1 09-Sep-2006  rpaulo sync with head
 1.7.2.1 18-Feb-2006  yamt sync with head.
 1.8.32.1 26-Jun-2007  garbled Sync with HEAD.
 1.8.26.1 11-Jul-2007  mjf Sync with head.
 1.8.24.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.15 27-Dec-2023  thorpej Re-factor the 680x0 Function Code definitions into their own
separate file (as was done on the sun2/sun3 ports ages ago)
and switch everyone to the common header.
 1.14 26-Sep-2023  tsutsui TAB/space cleanup.
 1.13 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.12 17-Oct-2007  garbled branches: 1.12.16; 1.12.18; 1.12.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.11 13-Jun-2007  he branches: 1.11.10;
Revert last commit to this file, and re-introduce the _60 variants
of the cache ops macros which are common between 040 and 060, as
per discussion with tsutsui@.
 1.10 13-Jun-2007  he Fix the 060 variants to not have conflicting definitions for the
cache ops common to 060 and 040. Also remove the now-redundant
definitions for the 060 variant which simply pointed to the 040
variants.
This fixes the build of the mvme68k VME172 kernel.
 1.9 08-Jun-2007  tsutsui Use pointers for variables assigned to %a0 by __asm("%a0") so that
gcc may generate silightly better inlined code on optimization.
 1.8 08-Jun-2007  tsutsui DCFA(), DCPA(), ICPL(), ICPP(), DCPL(), DCPP, DCFL(), and DCFP()
cache ops are identical between M68040 and M68060 and they are not
available on M68020 and M68030, so no need to check cputype even on
multi CPU kernels and they can always be inlined.

This improves MI Sonic xfer speed ~5%.
http://mail-index.netbsd.org/port-mac68k/2007/06/07/0003.html
 1.7 16-Feb-2006  perry branches: 1.7.24; 1.7.26; 1.7.32;
Change "inline" back to "__inline" in .h files -- C99 is still too
new, and some apps compile things in C89 mode. C89 keywords stay.

As per core@.
 1.6 24-Dec-2005  perry branches: 1.6.2; 1.6.4; 1.6.6;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.
 1.5 03-Nov-2002  chs branches: 1.5.22;
use "static __inline" instead of "extern __inline" so that we can
build without optimization.
 1.4 06-Nov-1999  thorpej branches: 1.4.12;
Add register prefixes.
 1.3 02-Sep-1998  leo branches: 1.3.12; 1.3.14; 1.3.18;
Nuke vm_offset_t/vm_size_t.
 1.2 05-Nov-1997  thorpej inline -> __inline
 1.1 02-Jun-1997  leo branches: 1.1.8;
An attempt to make a generic m68k implementation for cache control operations.
Not yet completely finished.
 1.1.8.1 05-Nov-1997  thorpej Update from trunk: inline -> __inline
 1.3.18.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.3.14.1 15-Nov-1999  fvdl Sync with -current
 1.3.12.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.4.12.1 11-Nov-2002  nathanw Catch up to -current
 1.5.22.2 03-Sep-2007  yamt sync with head.
 1.5.22.1 21-Jun-2006  yamt sync with head.
 1.6.6.1 22-Apr-2006  simonb Sync with head.
 1.6.4.1 09-Sep-2006  rpaulo sync with head
 1.6.2.1 18-Feb-2006  yamt sync with head.
 1.7.32.1 26-Jun-2007  garbled Sync with HEAD.
 1.7.26.1 11-Jul-2007  mjf Sync with head.
 1.7.24.1 15-Jul-2007  ad Sync with head.
 1.11.10.1 06-Nov-2007  matt sync with HEAD
 1.12.20.1 16-May-2008  yamt sync with head.
 1.12.18.1 18-May-2008  yamt sync with head.
 1.12.16.1 02-Jun-2008  mjf Sync with HEAD.
 1.7 20-Jan-2012  joerg Change CMSG_SPACE and CMSG_LEN to provide Integer Constant Expressions
again. This was changed in sys/socket.h r1.51 to work around fallout
from the IPv6 aux data migration. It broke the historic ABI on some
platforms. This commit restores compatibility for netbsd32 code on such
platforms and provides a template for future changes to the CMSG_*
alignment. Revert PCC/Clang workarounds in postfix and tmux.
 1.6 20-Mar-1999  thorpej branches: 1.6.182; 1.6.186;
Garbage-collect.
 1.5 28-Feb-1998  veego Sync it with the i386 version so lint doesn't complains about an syntax
error for __warn_references.
 1.4 04-Nov-1997  thorpej Bug fixes and cleanup from Chris Demetriou <cgd@pa.dec.com>:
- fix _C_LABEL so that it actually works.
- make __RENAME use _C_LABEL.
- fix __RENAME so that it expects an unquoted argument.
- fix __indr_reference and __warn_references so that they
supply their own final semicolon.
- define __warn_references to nothing if not GNU C (required
by the way it's used).

The __warn_references semicolon change has to be made
so that __warn_references can be defined into nothing.
(A ; all by itself isn't a great idea.) The __indr_reference
change was made for consistency.
 1.3 22-Oct-1997  thorpej Implement __RENAME() in <machine/cdefs.h>
 1.2 23-Mar-1995  jtc branches: 1.2.18;
Changed name of __weak_reference() to __indr_reference(). They really
are indirect references, and I want to add a real __weak_reference()
macro to <machine/cdefs.h> soon.
 1.1 19-Jan-1995  jtc This file, which will be included by <sys/cdefs.h>, will contain macros
such as __warn_references() and __weak_reference() which are actually
machine dependant. This will make it easier for ports that are being
bootstraped with ELF and ECOFF based toolchains.

This change also introduces a new macro, _C_LABEL(x). _C_LABEL expands
its argument, an identifier, to a character string of the identifier
name as it is represented in an object file.

For most ports, _C_LABEL(x) will expand to "_x", for ELF based ports
_C_LABEL(x) will expand to "x".
 1.2.18.2 04-Nov-1997  thorpej Pull up from trunk: bug fixes and cleaups.
 1.2.18.1 22-Oct-1997  thorpej Pull up from trunk: Implement __RENAME() in <machine/cdefs.h>
 1.6.186.1 18-Feb-2012  mrg merge to -current.
 1.6.182.1 17-Apr-2012  yamt sync with head
 1.25 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.24 27-Feb-2024  nat Use proper clockframe size for those platforms that require it.

XXX This is a tempory measure, better to fix clock interrupts to take the
common clockframe size.

OK thorpej@.
 1.23 20-Jan-2024  thorpej What good are comments, really, if you can't have a little color? Add
a note above CLKF_INTR() about why NetBSD will likely never switch to
using the "master" stack for the kernel, and thus why the not-enabled
version of CLKF_INTR() will never be enabled.

(Adding the comment here, rather than just deleting the code, has value,
I think, for future retrocomputing archeologists.)
 1.22 20-Jan-2024  thorpej Largely unify the <machine/cpu.h> headers on the m68k platforms.
 1.21 18-Jan-2024  thorpej Remove a comment that is no longer applicable.
 1.20 18-Jan-2024  thorpej Make the M68K_MMU_* defines real kernel options, available in opt_m68k_arch.h.
For 68030, 68040, and 68060, infer M68K_MMU_MOTOROLA. For 68010 and 68020, it
must be an explicit option (set in std.${MACHINE} or, in the case of hp300,
inferred from the specific model option).
 1.19 03-Jan-2024  thorpej G/C some bit defs that are redundant with mmu_{51,40}.h
 1.18 27-Dec-2023  thorpej Re-factor the 680x0 Function Code definitions into their own
separate file (as was done on the sun2/sun3 ports ages ago)
and switch everyone to the common header.
 1.17 01-Dec-2019  ad Fix false sharing problems with cpu_info. Identified with tprof(8).
This was a very nice win in my tests on a 48 CPU box.

- Reorganise cpu_data slightly according to usage.
- Put cpu_onproc into struct cpu_info alongside ci_curlwp (now is ci_onproc).
- On x86, put some items in their own cache lines according to usage, like
the IPI bitmask and ci_want_resched.
 1.16 22-Aug-2018  msaitoh - Cleanup for dynamic sysctl:
- Remove unused *_NAMES macros for sysctl.
- Remove unused *_MAXID for sysctls.
- Move CTL_MACHDEP sysctl definitions for m68k into m68k/include/cpu.h and
use them on all m68k machines.
 1.15 19-Sep-2011  rkujawa branches: 1.15.52; 1.15.54;
Move CACHELINE_* from bus_dma.c to cpu.h (needed for PCI configuration on amiga port).
 1.14 08-Feb-2011  rmind Remove clause 3 (UCB advertising clause) from the University of Utah
copyright. Confirmed by Mike Hibler, mike at cs.utah.edu - thanks!
Also, merge UCB and Utah copyright texts back into one, as they
originally were.

Extra verification by snj@.
 1.13 01-Jan-2011  he branches: 1.13.2; 1.13.4;
Protect the include of <sys/cpu_data.h> with a test for either _KERNEL
or _KMEMUSER. This should fix the build problem in libkvm for our m68k
ports.
 1.12 22-Dec-2010  matt Collect cpu_info and friends and move to m68k/include/cpu.h
Add a define __HAVE_CPU_DATA_FIRST which means that cpu_data is the first
member in struct cpu_info.
 1.11 11-Dec-2005  christos branches: 1.11.100;
merge ktrace-lwp.
 1.10 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.9 19-Jan-2003  thorpej branches: 1.9.2;
Merge the nathanw_sa branch.
 1.8 29-Sep-2002  wiz "definitions" has lots of 'i's, but that's not reason to leave one out.
 1.7 14-Jun-2001  thorpej branches: 1.7.2; 1.7.8;
Don't need to prototype child_return() here, it's in <sys/proc.h>.
 1.6 19-Dec-2000  scw branches: 1.6.2;
Unification of the m68k syscall() function.
 1.5 21-Oct-1997  gwr branches: 1.5.14;
Move the (boiled down) interface declarations into m68k.h
Too late for the release, unfortunately...
 1.4 09-Apr-1997  thorpej Prototype regdump().
 1.3 02-Feb-1997  thorpej prototype mappedcopy{in,out}(), {copy,zero}page().
 1.2 12-Sep-1996  thorpej Add an FPU_UNKNOWN constant; just a placeholder for any unknown FPU.
 1.1 11-Sep-1996  thorpej Factor out common Motorola 68k CPU definitions from the m68k port
cpu.h header files.

Some more work could be done here, but it's a good start.
 1.5.14.1 05-Jan-2001  bouyer Sync with HEAD
 1.6.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.7.8.3 18-Oct-2002  nathanw Catch up to -current.
 1.7.8.2 17-Nov-2001  scw Re-sync with current MI SA code.
 1.7.8.1 14-Jun-2001  scw file cpu.h was added on branch nathanw_sa on 2001-11-17 18:18:23 +0000
 1.7.2.1 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.9.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.9.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.9.2.1 03-Aug-2004  skrll Sync with HEAD
 1.11.100.1 05-Mar-2011  rmind sync with head
 1.13.4.1 17-Feb-2011  bouyer Sync with HEAD
 1.13.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.15.54.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.15.54.1 10-Jun-2019  christos Sync with HEAD
 1.15.52.1 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.10 26-Sep-2023  tsutsui TAB/space cleanup.
 1.9 26-Sep-2023  tsutsui Remove trailing spaces and TABs.
 1.8 05-Dec-2021  msaitoh s/expecially/especially/ in comment.
 1.7 07-Sep-2020  mrg move the __packed attribute from struct frame::F_t into the single
unaligned member inside. CTASSERT() the size is unchanged.

with this, sun3 and GCC 9 appears to work.
 1.6 02-Jul-2017  christos remove f_pad, conflicts with new <sys/file.h> define.
 1.5 08-Feb-2011  rmind branches: 1.5.14; 1.5.32;
Remove clause 3 (UCB advertising clause) from the University of Utah
copyright. Confirmed by Mike Hibler, mike at cs.utah.edu - thanks!
Also, merge UCB and Utah copyright texts back into one, as they
originally were.

Extra verification by snj@.
 1.4 11-Dec-2005  christos branches: 1.4.100; 1.4.106; 1.4.108;
merge ktrace-lwp.
 1.3 27-Oct-2003  cl branches: 1.3.4;
appease lint's ``warning: nonportable bit-field type'' in MD header
 1.2 23-Sep-2003  cl move #defines back to frame.h
 1.1 22-Sep-2003  cl SA_SIGINFO support for m68k
 1.3.4.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.3.4.3 18-Sep-2004  skrll Sync with HEAD.
 1.3.4.2 03-Aug-2004  skrll Sync with HEAD
 1.3.4.1 27-Oct-2003  skrll file cpuframe.h was added on branch ktrace-lwp on 2004-08-03 10:36:40 +0000
 1.4.108.1 17-Feb-2011  bouyer Sync with HEAD
 1.4.106.1 06-Jun-2011  jruoho Sync with HEAD.
 1.4.100.1 05-Mar-2011  rmind sync with head
 1.5.32.1 28-Aug-2017  skrll Sync with HEAD
 1.5.14.1 03-Dec-2017  jdolecek update from HEAD
 1.35 26-Sep-2023  tsutsui TAB/space cleanup.
 1.34 26-Sep-2023  tsutsui Remove trailing spaces and TABs.
 1.33 06-Nov-2017  christos Cleanup and clarify the ELFSIZE mess:

We now have 2 variables automatically set in elf_machdep.h:

ARCH_ELFSIZE: the size for userland binaries
KERN_ELFSIZE: the size for the kernel binaries

DB_ELFSIZE has been deleted and KERN_ELFSIZE should have always the
same values DB_ELFSIZE used to have.

In sys/exec_elf.h, if ELFSIZE is not set, it is set to KERN_ELFSIZE
for the kernel and ARCH_ELFSIZE for userland. These defaults should
eliminate the need for most manual ELFSIZE setting.
 1.32 05-Nov-2017  christos The XXX comment (do not pull in the uvm headers) might have been a nice idea
at the time, but now all other db_machdep files do this, so we follow suit.
 1.31 31-Jan-2012  mlelstv branches: 1.31.6;
Enable build of crash(8) for m86k platforms.
 1.30 26-May-2011  joerg branches: 1.30.4; 1.30.8;
Introduce DDB_EXPR_FMT and replace the logic around DB_EXPR_T_IS_QUAD.
 1.29 11-Apr-2011  mrg obsolete DB_AOUT_SYMBOLS. however, we need to leave most of the code
in db_sym.[ch] as it is used by the elf version of crash(8).

i will be cleaning up the db_sym.c code in a follow up commit to avoid
having dead code compiled.
 1.28 14-Jan-2011  rmind branches: 1.28.2;
Retire struct user, remove sys/user.h inclusions. Note sys/user.h header
as obsolete. Remove USER_TO_UAREA/UAREA_TO_USER macros.

Various #include fixes and review by matt@.
 1.27 01-Apr-2006  cherry branches: 1.27.88;
closes: PR kern/32359

modifies machine/db_machdep.h: BKPT_SET(inst) to BKPT_SET(inst, addr) for all archs ie; passess the
breakpoint address as well.

Patch from cherry@mahiti.org
 1.26 11-Dec-2005  christos branches: 1.26.4; 1.26.6; 1.26.8; 1.26.10; 1.26.12;
merge ktrace-lwp.
 1.25 28-Aug-2004  thorpej branches: 1.25.12;
- De-__P.
- Also define DB_ELF_SYMBOLS and DB_ELFSIZE.
 1.24 29-Apr-2003  scw branches: 1.24.2;
Add a BKPT_ADDR() macro which gives MD code a chance to munge a
breakpoint address before it's used. Currently a no-op on all but sh5.

This is useful on sh5, for example, to mask off the instruction
type encoding in the bottom two address bits, and makes it possible
to do "db> break $rXX" instead of manually munging the address.
 1.23 30-Mar-2003  kristerw Remove unneeded cast that prevents PC_REGS from being used as lvalue.
 1.22 26-Jun-2000  mrg <vm/vm_param.h> -> <uvm/uvm_param.h>
 1.21 02-Sep-1998  leo branches: 1.21.12;
Nuke vm_offset_t/vm_size_t.
 1.20 26-Jun-1997  thorpej #define DB_AOUT_SYMBOLS
 1.19 18-Feb-1997  gwr Remove some unnecessary <vm/*> headers. Have to keep <vm/vm_param.h>,
at least until boolean_t moves to <sys/types.h> or someplace...
Also make ddb_regs extern here. Closes PR#3213
 1.18 12-Feb-1997  gwr Add kgdb_reg_t, KGDB_NUMREGS, KGDB_BUFLEN
 1.17 06-Feb-1997  gwr branches: 1.17.2;
FIXUP_PC_AFTER_BREAK now takes an arg of type db_regs_t *
 1.16 05-Feb-1997  scottr db_expr_t is now a long.
 1.15 27-Jan-1997  gwr Include <machine/frame.h> and typedef db_regs_t using struct trapframe
(instead of replicating trapframe here by a different name). Update the
macros that refer to members of db_regs_t to use the trapframe members.
 1.14 15-Jan-1997  gwr Use db_regs_t instead of struct mc68020_saved_state
 1.13 29-Apr-1996  leo branches: 1.13.2;
Prototype + -Wall fixes.
 1.12 26-Oct-1994  cgd new RCS ID format.
 1.11 09-Oct-1994  mycroft Remove BYTE_MSF.
 1.10 23-May-1994  mycroft Merge with 4.4-Lite.
 1.9 18-Apr-1994  briggs vm/queue.h doesn't exist any more.
 1.8 31-Jan-1994  mycroft Specify the byte order.
 1.7 10-Jan-1994  mycroft Fix some bogus spacing.
 1.6 10-Jan-1994  mycroft Add some padding before SR.
 1.5 09-Jan-1994  mycroft T_WATCHPOINT doesn't really exist. Deal.
 1.4 09-Jan-1994  mycroft Alias T_TRAP15 to T_BREAKPOINT globally.
 1.3 09-Jan-1994  cgd kill logs, and minor cleanup
 1.2 10-Aug-1993  glass fixed problem that caused two consecutive segments to be using the same
pmeg unknowingly. still too many printfs, not sure how many are actualy
in the machine dependent code. reaches cpu_startup() where it stops
deliberately. next project: autoconfig(), maybe kgdb
 1.1 08-Aug-1993  glass various changes
 1.13.2.1 18-Jan-1997  thorpej Update from trunk.
 1.17.2.1 12-Mar-1997  is Merge in changes from Trunk
 1.21.12.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.24.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.24.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.24.2.1 03-Sep-2004  skrll Sync with HEAD
 1.25.12.1 21-Jun-2006  yamt sync with head.
 1.26.12.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.26.10.1 19-Apr-2006  elad sync with head - hopefully this will work
 1.26.8.1 11-Apr-2006  yamt sync with head
 1.26.6.1 22-Apr-2006  simonb Sync with head.
 1.26.4.1 09-Sep-2006  rpaulo sync with head
 1.27.88.3 31-May-2011  rmind sync with head
 1.27.88.2 21-Apr-2011  rmind sync with head
 1.27.88.1 05-Mar-2011  rmind sync with head
 1.28.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.30.8.1 18-Feb-2012  mrg merge to -current.
 1.30.4.1 17-Apr-2012  yamt sync with head
 1.31.6.1 03-Dec-2017  jdolecek update from HEAD
 1.9 06-Nov-2017  christos Cleanup and clarify the ELFSIZE mess:

We now have 2 variables automatically set in elf_machdep.h:

ARCH_ELFSIZE: the size for userland binaries
KERN_ELFSIZE: the size for the kernel binaries

DB_ELFSIZE has been deleted and KERN_ELFSIZE should have always the
same values DB_ELFSIZE used to have.

In sys/exec_elf.h, if ELFSIZE is not set, it is set to KERN_ELFSIZE
for the kernel and ARCH_ELFSIZE for userland. These defaults should
eliminate the need for most manual ELFSIZE setting.
 1.8 30-May-2009  skrll branches: 1.8.22;
Add TLS relocation definitions.
 1.7 28-Jan-2002  thorpej branches: 1.7.122;
Define EF_CPU32 and EF_M68000.
 1.6 09-Dec-2001  thorpej Add support for dumping ELF-cormat core files.
 1.5 02-Apr-2000  minoura branches: 1.5.8; 1.5.12;
Move dl* function definitions to libc on ELF.
Based on the patch supplied by Takuya Shiozaki <tshiozak@astec.co.jp>.
See http://mail-index.netbsd.org/tech-userlevel/2000/02/23/0000.html.
 1.4 30-Oct-1999  frueauf fix typo: s/EM_68k/EM_68K/
 1.3 25-Oct-1999  kleink Update to match new SVR4-style definition names in <sys/exec_elf.h>.
 1.2 12-Jul-1998  thorpej branches: 1.2.14; 1.2.16; 1.2.18;
Add m68k relocation types.
 1.1 12-Jul-1998  thorpej Basic elf_machdep.h for m68k; doesn't include relocations, yet.
 1.2.18.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.2.16.1 15-Nov-1999  fvdl Sync with -current
 1.2.14.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.5.12.2 28-Feb-2002  nathanw Catch up to -current.
 1.5.12.1 08-Jan-2002  nathanw Catch up to -current.
 1.5.8.2 11-Feb-2002  jdolecek Sync w/ -current.
 1.5.8.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.7.122.1 20-Jun-2009  yamt sync with head
 1.8.22.1 03-Dec-2017  jdolecek update from HEAD
 1.17 17-Mar-2000  mycroft In the `MY THAT'S GROSS' department...
Eliminate the recursive include of machine/endian.h from sys/endian.h.
 1.16 16-Mar-2000  mycroft Foolish consistency. Mainly, always use underscores and sys/endian.h.
 1.15 21-Aug-1999  simonb branches: 1.15.2;
Include <sys/endian.h> after defining whether where are little- or
big-endian. i386, pc532 and vax still include <machine/byte_swap.h>
and define macros for the {n,h}to{h,n}*() functions. mips also
defines some endian-independent assembly-code aliases for unaligned
memory accesses.
 1.14 24-Jan-1999  mycroft Mark [hn]to[nh][ls]() with __const__, so they are subject to CSE.
 1.13 15-Jan-1999  bouyer Move the bswap functions from libutil to libc (this bups the
minor of libc and the major of libutil). For little-endian architectures
merge the bnswap() assembly versions with nto* and hton* using symbols
aliasing. Use symbol renaming for the bswap function in this case to avoid
namespace pollution.
Declare bswap* in machine/bswap.h, not machine/endian.h. For little-endian
machines, common code for inline macros go in machine/byte_swap.h
Sync libkern with libc.
Adjust #include in kernel sources for machine/bswap.h.
 1.12 31-Jul-1998  mycroft (Always) (practice) (safe) (macro expansion).
 1.11 09-Oct-1997  bouyer branches: 1.11.4;
Add byte-swapping functions (bswap16, bswap32, bswap64) to libkern.
Only assembly version for i386 bswap16 and bswap32 for now (bswap64 uses
bswap32). Contribution of assembly versions of these are welcome.
Add byte-swapping of ext2fs metadata for big-endian systems.
Tested on i386 and sparc.
 1.10 13-Oct-1996  christos branches: 1.10.10;
use in_addr_t and in_port_t
 1.9 14-Aug-1996  thorpej Back out previous; this is a bigger problem than I expected.
 1.8 14-Aug-1996  thorpej The htonl(), htons(), etc. functions return u_long and u_short. Add
casts to the big-endian versions of these calls so that the compiler
won't complain when they're passed as arguments to printf().
 1.7 29-Mar-1996  briggs Make NTOH[SL] and HTON[SL] (void) (x) instead of (x) to get around
compiler warnings. Followed the lead set in the sparc port.
 1.6 26-Oct-1994  cgd new RCS ID format.
 1.5 10-Apr-1994  chopps protect against multiple inclusion
 1.4 06-Dec-1993  mycroft Add quad stuff, etc.
 1.3 13-Oct-1993  cgd get rid of #ifndef KERNEL around inclusion of cdefs.h
 1.2 22-May-1993  cgd add rcsids to everything and clean up headers
 1.1 13-May-1993  cgd add from net/2 sources. was symlink to ../../tahoe/include/endian.h
 1.10.10.1 14-Oct-1997  thorpej Update marc-pcmcia branch from trunk.
 1.11.4.1 08-Aug-1998  eeh Revert cdevsw mmap routines to return int.
 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.1 17-Mar-2000  mycroft branches: 1.1.6;
In the `MY THAT'S GROSS' department...
Eliminate the recursive include of machine/endian.h from sys/endian.h.
 1.1.6.2 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.1.6.1 17-Mar-2000  bouyer file endian_machdep.h was added on branch thorpej_scsipi on 2000-11-20 20:11:39 +0000
 1.2 08-Oct-1996  cgd moved to aout_machdep.h (via repository copy)
 1.1 08-Sep-1996  thorpej All of the m68k ports' exec.h's were essentially the same. Merge them.

Override the N_PAGSIZ() macro; this one checks the MID of the executable
and returns the appropriate page size.
 1.2 13-Jan-2024  thorpej Make getsfc() and getdfc() inlines; it's slightly smaller.
 1.1 27-Dec-2023  thorpej Re-factor the 680x0 Function Code definitions into their own
separate file (as was done on the sun2/sun3 ports ages ago)
and switch everyone to the common header.
 1.10 30-Oct-2024  riastradh Sprinkle <sys/featuretest.h> where _*_SOURCE macros are consulted.

Otherwise, the feature tests might come out wrong. For example,
header files that check for _NETBSD_SOURCE won't get the default when
no other _*_SOURCE macros are defined; header files that check for
_POSIX_C_SOURCE might miss _XOPEN_SOURCE, which is supposed to imply
a corresponding _POSIX_C_SOURCE.

PR lib/58752: various header files test _*_SOURCE macros but don't
include sys/featuretest.h
 1.9 26-Sep-2023  tsutsui branches: 1.9.6;
Remove trailing spaces and TABs.
 1.8 26-Oct-2019  christos disable -Wshadow because in c99 mode these get marked as builtins.
 1.7 13-Sep-2017  phx branches: 1.7.2; 1.7.6;
The __fgetenv() macro operates on a fenv_t, not on a fenv_t *.
Fixes a segfault in fegetenv() and feholdexcept().
 1.6 22-Mar-2017  chs branches: 1.6.6;
provide a common softfloat fenv implemenation and use it for softfloat builds.
restore ABI compatibility with previous releases for ieeefp.h on sh3.
add namespace.h protection for all the fenv interfaces.
use MKSOFTFLOAT on sh3 instead of assuming softfloat.
standardize on comparing MKSOFTFLOAT with "no".
remove the arm-specific softfloat fenv code (which also had several bugs).
fix logic errors in the arm hardfloat feraiseexcept() and feupdateenv().
 1.5 27-Feb-2017  chs use FPCR instead of FPSR to manipulate the exception mask.
 1.4 05-Jan-2016  ozaki-r branches: 1.4.2; 1.4.4;
Fix #endif; it should be after __END_DECLS

This unbreaks the build of sun2.
 1.3 29-Dec-2015  christos disable code that does not work for sun2/coldfire
 1.2 25-Dec-2015  christos branches: 1.2.2;
make this compile for c++
 1.1 24-Dec-2015  christos fenv for m68k
 1.2.2.4 28-Aug-2017  skrll Sync with HEAD
 1.2.2.3 19-Mar-2016  skrll Sync with HEAD
 1.2.2.2 27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.2.2.1 25-Dec-2015  skrll file fenv.h was added on branch nick-nhusb on 2015-12-27 12:09:37 +0000
 1.4.4.1 21-Apr-2017  bouyer Sync with HEAD
 1.4.2.2 26-Apr-2017  pgoyette Sync with HEAD
 1.4.2.1 20-Mar-2017  pgoyette Sync with HEAD
 1.6.6.1 23-Sep-2017  snj Pull up following revision(s) (requested by phx in ticket #286):
sys/arch/m68k/include/fenv.h: revision 1.7
The __fgetenv() macro operates on a fenv_t, not on a fenv_t *.
Fixes a segfault in fegetenv() and feholdexcept().
 1.7.6.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.7.2.2 03-Dec-2017  jdolecek update from HEAD
 1.7.2.1 13-Sep-2017  jdolecek file fenv.h was added on branch tls-maxphys on 2017-12-03 11:36:23 +0000
 1.9.6.1 02-Aug-2025  perseant Sync with HEAD
 1.27 07-Oct-2025  nat Get the constants right for m68k softfloat.

Now the libm test results are 0 failures, 1 expected failure.
 1.26 04-Oct-2025  riastradh x86, m68k <machine/float.h>: `Significand', not `mantissa'.

The IEEE 754 standard uses `significand' and has since its first
edition in 1985; Kahan and Knuth both use `significand' and
explicitly reject `mantissa'; `significand' doesn't have a
conflicting definition in logarithms; and in actual usage in the
floating-point and numerical analysis literature, `significand'
dominates.

No functional change intended -- comment-only.
 1.25 04-Oct-2025  nat Increase LDL_MIN_EXP for softfloat.

An exponent of zero(-16382) has special signifiance for softfloat.

Found by atf-tests testing exponent values lower than the possible minimum.
 1.24 30-Oct-2024  riastradh Sprinkle <sys/featuretest.h> where _*_SOURCE macros are consulted.

Otherwise, the feature tests might come out wrong. For example,
header files that check for _NETBSD_SOURCE won't get the default when
no other _*_SOURCE macros are defined; header files that check for
_POSIX_C_SOURCE might miss _XOPEN_SOURCE, which is supposed to imply
a corresponding _POSIX_C_SOURCE.

PR lib/58752: various header files test _*_SOURCE macros but don't
include sys/featuretest.h
 1.23 15-Jun-2024  rillig branches: 1.23.2;
{m68k,x86}/float.h: fix cross references
 1.22 31-Dec-2023  dholland {x86,m68k}/float.h: document LDBL_MIN behavior

It seems that even though both these platforms have 12-byte floats
that are pretty much the same representation and both allegedly
IEEE-compliant, they manifest the top bit of the mantissa and then
differ slightly in the behavior of the extra encodings this permits.

Thanks to riastradh@ for helping sort this out.
 1.21 18-Mar-2014  riastradh Merge riastradh-drm2 to HEAD.
 1.20 18-Jul-2013  matt Coldfire FPU looks like the 68010 FPU (no long double)
 1.19 11-Dec-2005  christos branches: 1.19.112; 1.19.122; 1.19.128; 1.19.136;
merge ktrace-lwp.
 1.18 26-Oct-2003  kleink Hide the extended-precision definitions from __mc68010__.
 1.17 23-Oct-2003  kleink * Move the definitions for types other than single-precision and double-
precision back to machine-dependent headers. C99 has no strict
requirement which, if any, extended-precision type `long double' must
match, and even between 80-bit formats there are differences in
implementation (m68k vs. x86).
* On arm, consider __VFP_FP__.
 1.16 12-May-2003  kleink branches: 1.16.2;
Rename <sys/float_ieee.h> to <sys/float_ieee754.h>, following libc's
convention for these.
 1.15 20-Apr-2003  bjh21 Use <sys/float_ieee.h> rather than <sys/math_ieee.h>, which doesn't exist.
 1.14 19-Apr-2003  christos PR/3012: Greg A. Woods: Write all float.h files [except the vax of course]
in terms of float_ieee.h
 1.13 27-Sep-1998  mycroft The smallest positive normalized number in extended precision is 2^-16383.
Underflow handling is different from i387.
 1.12 18-Feb-1998  mycroft Include correct information for long doubles (mc68881 extended precision).
 1.11 03-Feb-1998  mycroft Prototype __flt_rounds() consistently.
 1.10 20-Jun-1995  jtc branches: 1.10.18;
Wrap with #ifndef _XXX_FLOAT_H_/#define _XXX_FLOAT_H_/ ... /#endif.
 1.9 20-Jun-1995  jtc #include <sys/cdefs.h>.
Wrap __flt_rounds() declaration with __BEGIN_DECLS/__END_DECLS.
 1.8 07-Apr-1995  jtc Changed FLT_ROUNDS from constant to a call to __flt_rounds(), so that the
current rounding mode is accurately reported.
 1.7 26-Oct-1994  cgd new RCS ID format.
 1.6 11-Apr-1994  mycroft Someone made a typo.
 1.5 10-Apr-1994  chopps protect against multiple inclusion
 1.4 15-Aug-1993  mycroft Adjust DBL_MIN so it doesn't underflow.
 1.3 15-Aug-1993  mycroft Adjust DBL_MAX so it doesn't overflow.
 1.2 22-May-1993  cgd add rcsids to everything and clean up headers
 1.1 13-May-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.1 13-May-1993  cgd add hp300 kernel files. generic kernel files might need some help...
 1.10.18.1 08-May-1998  mycroft Sync with trunk, per request of mycroft.
 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.136.1 23-Jul-2013  riastradh sync with HEAD
 1.19.128.1 28-Aug-2013  rmind sync with head
 1.19.122.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.19.112.1 22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.23.2.1 02-Aug-2025  perseant Sync with HEAD
 1.3 18-Mar-2014  riastradh Merge riastradh-drm2 to HEAD.
 1.2 18-Jul-2013  matt Fix some definitions
 1.1 27-Jan-2009  martin branches: 1.1.2; 1.1.6; 1.1.8; 1.1.20; 1.1.30; 1.1.34; 1.1.42;
Move FPSR_ register bit definitions into their own file
 1.1.42.1 23-Jul-2013  riastradh sync with HEAD
 1.1.34.1 28-Aug-2013  rmind sync with head
 1.1.30.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.20.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.1.8.2 04-May-2009  yamt sync with head.
 1.1.8.1 27-Jan-2009  yamt file fpreg.h was added on branch yamt-nfs-mp on 2009-05-04 08:11:26 +0000
 1.1.6.2 03-Mar-2009  skrll Sync with HEAD.
 1.1.6.1 27-Jan-2009  skrll file fpreg.h was added on branch nick-hppapmap on 2009-03-03 18:29:02 +0000
 1.1.2.2 02-Feb-2009  snj Pull up following revision(s) (requested by martin in ticket #332):
sys/arch/m68k/fpe/fpu_emulate.h: revision 1.13
sys/arch/m68k/include/fpreg.h: revision 1.1
Move FPSR_ register bit definitions into their own file
 1.1.2.1 27-Jan-2009  snj file fpreg.h was added on branch netbsd-5 on 2009-02-02 00:32:23 +0000
 1.35 13-Jan-2024  thorpej G/C some unused definitions.
 1.34 12-Jan-2024  thorpej We only need one copy of getvbr() and setvbr().
 1.33 26-Sep-2023  tsutsui TAB/space cleanup.
 1.32 26-Sep-2023  tsutsui Remove trailing spaces and TABs.
 1.31 18-Feb-2019  thorpej Refactor the 68040 writeback() from each m68k port's trap handler into a
shared copy: m68040_writeback(). It is essentially a copy of the Atari
version, with some minor cosmetic tweaks and one small performance optimization
from the mvme68k port.

Tested by rjs@ on a Quadra 950. (Thanks!)
 1.30 08-Feb-2011  rmind branches: 1.30.56;
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 05-Apr-2008  tsutsui branches: 1.29.26; 1.29.32; 1.29.34;
Use generic atomic_cas_uint() for mutex(9) and rwlock(9), and
remodel old RAS based _lock_cas() implementation for m68010
into genereic atomic_cas_32().
Now sun2 kernel compiles and even works on multiuser. (hehe)

Tested on tme (emulationg 2/120 and 3/150) and (real) 3/80.
 1.28 13-Mar-2007  thorpej branches: 1.28.36;
LOCK_CAS_CHECK(): make sure we're in kernel mode.
 1.27 12-Mar-2007  thorpej branches: 1.27.2;
- Define LOCK_CAS_CHECK() in m68k/frame.h (there because it operates on
a clockframe).
- Call LOCK_CAS_CHECK() in clock_intr() (noted by Izumi Tsutsui).
 1.26 11-Dec-2005  christos branches: 1.26.26; 1.26.30;
merge ktrace-lwp.
 1.25 07-Sep-2005  drochner namespace sanity: don't expose compatibility sigcontext stuff
unnecessarily
 1.24 28-Aug-2004  thorpej branches: 1.24.10; 1.24.12; 1.24.14;
De-__P
 1.23 25-Sep-2003  christos constify siginfo/trapsignal
 1.22 23-Sep-2003  cl move #defines back to frame.h
 1.21 22-Sep-2003  cl SA_SIGINFO support for m68k
 1.20 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.19 17-Jan-2003  thorpej branches: 1.19.2;
Merge the nathanw_sa branch.
 1.18 16-Aug-2001  fredette branches: 1.18.6;
Added the crucial "packed" attribute to the type 8 frame structure.
 1.17 28-Mar-2001  fredette branches: 1.17.2;
Added support for the 68010 bus error frame.
 1.16 19-Apr-1999  kleink branches: 1.16.2; 1.16.14;
Move linux_reenter_syscall() to a common location and rename it to
reenter_syscall() - it's going to be shared with COMPAT_SVR4 and soon be
used by native code.
 1.15 03-May-1997  mycroft branches: 1.15.18;
Oops; put the __attribute__ in the right place.
 1.14 03-May-1997  mycroft Make sure struct trapframe is packed tightly.
 1.13 27-Jan-1997  gwr Protect this agains multiple includes so it can be included by db_machdep.h
 1.12 16-May-1996  is 3 more constants for 68060 access error trap stack frames.
 1.11 12-Mar-1996  is M68060 additional frame formats and bits. Closes PR 1174.

This shouldn't break anything; I find ... grep ... all the relevant
kernel sources subdirecotry trees I could think of for the defines
that don't use the new FSLW or FPF6 prefix. But in case it does anyway,
tell me immediately.
 1.10 12-May-1995  mycroft Redefine the first part of struct frame to be a struct trapframe, and add a
struct switchframe.
 1.9 12-May-1995  chopps add stdframe (4-word frame)
 1.8 26-Oct-1994  cgd new RCS ID format.
 1.7 23-May-1994  mycroft Add RCS ids.
 1.6 23-May-1994  mycroft Merge with 4.4-Lite.
 1.5 10-Apr-1994  chopps protect against multiple inclusion
 1.4 26-Jan-1994  mw Add support for 68040 frames and flag bits.
 1.3 01-Aug-1993  mycroft Add RCS identifiers (this time on the correct side of the branch), and
incorporate recent changes in netbsd-0-9 branch.
 1.2 22-May-1993  cgd add rcsids to everything and clean up headers
 1.1 13-May-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.1 13-May-1993  cgd add hp300 kernel files. generic kernel files might need some help...
 1.15.18.1 21-Jun-1999  thorpej Sync w/ -current.
 1.16.14.1 09-Apr-2001  nathanw Catch up with -current.
 1.16.2.1 21-Apr-2001  bouyer Sync with HEAD
 1.17.2.1 25-Aug-2001  thorpej Merge Aug 24 -current into the kqueue branch.
 1.18.6.3 02-Dec-2001  scw G/C the FPFRAME_IS_NULL() macro; it's been moved to the source file
where it's used.

Declare a global which holds a reference floating point `idle' frame
for use in cpu_{g,s}etmcontext(). This helps when restoring an FP
context saved in usermode.

XXX: Need to test this on 6888[12], which have more complex idle frames...
 1.18.6.2 21-Nov-2001  scw Add an MD flag for uc_flags which indicates if the exception frame
area of m68k's mcontext_t structure has valid contents.

In cpu_getcontext(), set the flag for all frame formats >= FMT4 such
that cpu_setcontext() does The Right Thing with both user and kernel
saved contexts.

Make null FP frame detection work for the 68060's FPU, and ensure we
always do at least an fsave/frestore when saving/restoring FPU regs.

Both kernel and user-level get/set context calls pass all Nathan's
context tests now.
 1.18.6.1 16-Aug-2001  scw file frame.h was added on branch nathanw_sa on 2001-11-21 20:25:03 +0000
 1.19.2.5 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.19.2.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.19.2.3 18-Sep-2004  skrll Sync with HEAD.
 1.19.2.2 03-Sep-2004  skrll Sync with HEAD
 1.19.2.1 03-Aug-2004  skrll Sync with HEAD
 1.24.14.1 10-Apr-2006  tron Pull up following revision(s) (requested by oster in ticket #1249):
sys/arch/m68k/include/frame.h: revision 1.25
namespace sanity: don't expose compatibility sigcontext stuff
unnecessarily
 1.24.12.2 03-Sep-2007  yamt sync with head.
 1.24.12.1 21-Jun-2006  yamt sync with head.
 1.24.10.1 10-Apr-2006  tron Pull up following revision(s) (requested by oster in ticket #1249):
sys/arch/m68k/include/frame.h: revision 1.25
namespace sanity: don't expose compatibility sigcontext stuff
unnecessarily
 1.26.30.2 10-Apr-2007  ad Sync with head.
 1.26.30.1 13-Mar-2007  ad Sync with head.
 1.26.26.2 24-Mar-2007  yamt sync with head.
 1.26.26.1 12-Mar-2007  rmind Sync with HEAD.
 1.27.2.1 11-Jul-2007  mjf Sync with head.
 1.28.36.1 02-Jun-2008  mjf Sync with HEAD.
 1.29.34.1 17-Feb-2011  bouyer Sync with HEAD
 1.29.32.1 06-Jun-2011  jruoho Sync with HEAD.
 1.29.26.1 05-Mar-2011  rmind sync with head
 1.30.56.1 10-Jun-2019  christos Sync with HEAD
 1.18 02-Jul-2025  christos use uint32_t like the x86 file does.
 1.17 22-Jan-2024  kre branches: 1.17.2;

Add multiple inclusion protection guard - the long double math routines
have a tendency to sometimes make that happen.

This seems to fix the sun3 build, and probably other m68k builds which
were working before the libm upgrades (it will do nothing for any that
were failing before that).
 1.16 20-Sep-2010  christos cargo cult the x86 changes.
 1.15 22-Feb-2007  mhitch branches: 1.15.46; 1.15.66; 1.15.68;
Extract extended precision fraction correctly. Now gdtoa works properly
on m68k for extended precision numbers.
 1.14 22-Feb-2007  mhitch Whitespace
 1.13 17-Feb-2007  mhitch From Christos: gdtoa fixes for m68k. M68k ports should build now, but
printing extended precision is a little off.
 1.12 11-Dec-2005  christos branches: 1.12.24; 1.12.26;
merge ktrace-lwp.
 1.11 15-Apr-2005  kleink branches: 1.11.2;
Push back the descriptions of NaN formats, and descriptions of the
distinction between signalling NaNs and quiet NaNs back into the
machine-dependent headers; treat the implementation of __nanf in the
same spirit.

IEEE 754 leaves the distinction between signalling NaNs and quiet NANs
to the implementation, and unlike our headers used to suggest they're
not identical in the interpretation of the fraction's MSb; in due
course, make those of hppa, mips, sh3, and sh5 reflect reality.
 1.10 28-Oct-2003  kleink branches: 1.10.8; 1.10.14;
Similar to sparc, make available the extended-precision definitions for
_KERNEL; the FPE package will require it once it's used on sun2.
 1.9 27-Oct-2003  kleink Err, rename some members added in previous to make them reflect their
semantics better.
 1.8 26-Oct-2003  kleink For convenient use in libc, add unions of the C floating types and their
corresponding structure definitions.
 1.7 26-Oct-2003  kleink Correct the position of the QUIETNAN bit.
 1.6 26-Oct-2003  kleink Use <sys/ieee754.h> where applicable.
 1.5 26-Oct-2003  kleink Hide the extended-precision definitions from __mc68010__.
 1.4 23-Oct-2003  kleink Account separately for the explicit integer bit in extended-precision
format, due to its role in denormal representation; inspired by communication
with Charles Hannum.
 1.3 23-Oct-2003  kleink Make struct ieee_ext actually match the layout of m68k extended-precision.
 1.2 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.1 30-Sep-1996  ws branches: 1.1.2; 1.1.52;
PowerPC port
 1.1.52.4 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.1.52.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.1.52.2 18-Sep-2004  skrll Sync with HEAD.
 1.1.52.1 03-Aug-2004  skrll Sync with HEAD
 1.1.2.1 14-Oct-1997  thorpej Update marc-pcmcia branch from trunk.
 1.10.14.1 19-Apr-2005  tron Pull up revision 1.11 (requested by kleink in ticket #163):
Push back the descriptions of NaN formats, and descriptions of the
distinction between signalling NaNs and quiet NaNs back into the
machine-dependent headers; treat the implementation of __nanf in the
same spirit.
IEEE 754 leaves the distinction between signalling NaNs and quiet NANs
to the implementation, and unlike our headers used to suggest they're
not identical in the interpretation of the fraction's MSb; in due
course, make those of hppa, mips, sh3, and sh5 reflect reality.
 1.10.8.1 29-Apr-2005  kent sync with -current
 1.11.2.1 26-Feb-2007  yamt sync with head.
 1.12.26.1 27-Feb-2007  yamt - sync with head.
- move sched_changepri back to kern_synch.c as it doesn't know PPQ anymore.
 1.12.24.1 07-May-2007  pavel Pull up following revision(s) (requested by manu in ticket #607):
lib/libc/arch/i386/gen/isnanl.c: revision 1.6
lib/libc/gdtoa/gdtoa.c: revision 1.2-1.3
lib/libc/arch/x86_64/gen/isnanl.c: revision 1.6
lib/libc/gdtoa/gdtoaimp.h: revision 1.6
sys/arch/m68k/include/ieee.h: revision 1.13
usr.bin/xlint/lint1/scan.l: revision 1.36-1.37
lib/libc/stdio/snprintf_ss.c: revision 1.4
lib/libc/arch/i386/gen/isfinitel.c: revision 1.2
lib/libc/stdio/vfscanf.c: revision 1.38
sys/arch/sparc/include/ieee.h: revision 1.11-1.12
lib/libc/gdtoa/dtoa.c: revision 1.4
lib/libc/stdio/Makefile.inc: revision 1.35
lib/libc/stdio/fvwrite.c: revision 1.17
lib/libc/arch/m68k/gen/fpclassifyl.c: revision 1.2
lib/libc/arch/i386/gen/isinfl.c: revision 1.6
lib/libc/arch/x86_64/gen/isinfl.c: revision 1.6
lib/libc/arch/x86_64/gen/isfinitel.c: revision 1.2
lib/libc/stdio/vfprintf.c: revision 1.55-1.57
lib/libc/stdio/vsnprintf_ss.c: revision 1.3
lib/libc/stdio/vfwprintf.c: revision 1.10
sys/arch/x86/include/ieee.h: revision 1.10
lib/libc/gdtoa/dmisc.c: revision 1.3
lib/libc/gdtoa/Makefile.inc: revision 1.5
sys/arch/hppa/include/ieee.h: revision 1.10
lib/libc/arch/x86_64/gen/fpclassifyl.c: revision 1.3
lib/libc/arch/i386/gen/fpclassifyl.c: revision 1.2
sys/sys/ieee754.h: revision 1.7
lib/libc/gdtoa/gdtoa.h: revision 1.7
include/stdio.h: revision 1.67-1.68
lib/libc/gdtoa/hdtoa.c: revision 1.1-1.4
lib/libc/gdtoa/ldtoa.c: revision 1.1-1.4
defined(_NETBSD_SOURCE) is equivalent to (!defined(_ANSI_SOURCE) &&
!defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE)), so there's no
need to check both of them.
Fix for issue reported in PR lib/35401 as well as related overflow bugs.
deal with hex doubles.
Instead of abusing stdio to get a signal-safe version of sprintf, provide one.
remove __SAFE
add long double and hex double support from freebsd.
make this compile.
add new prototypes.
add the new files to the build. Note I am not bumping libc now, because
these are not used yet.
Merge the int bit with the high fraction bit. Add constants/macros
needed by gdtoa.
add constants used by gdtoa
since the int bit is merged, do the explicit math.
ext_int bit is no more.
ext_int bit is no more.
- merge change from freebsd
- add support for building as vfprintf.c
- XXX: we strdup to simplify the freeing logic. This should be fixed for
efficiency in the vfprintf case.
use vfwprintf.c
enable wide doubles.
some int -> size_t
deal with sparc64 that has 112 bits of mantissa.
make extended precision gdtoa friendly.
int/size_t changes
make this gdtoa friendly.
remove dup definition
use dtoa() instead of returning empty when we don't have extended precision
information.
Fix previous, add forgotten pointer dereference in the call to dtoa().
Add a cheesy workaround marked XXX for the situation where the
strtod() implementation available in the environment does not
handle hex floats.
Discussed with and suggested by christos
From Christos: gdtoa fixes for m68k. M68k ports should build now, but
printing extended precision is a little off.
vax does not have <machine/ieee.h> or long double
It would be nice if the compiler provided something like __IEEE_MATH__
bring in FreeBSD's vfscanf() to gain multi-byte/collation support.
Unfortunately it is too difficult to make vfwscanf and this share
the same code like I did with printf, because for string parsing
the code is too different.
 1.15.68.1 05-Mar-2011  rmind sync with head
 1.15.66.1 22-Oct-2010  uebayasi Sync with HEAD (-D20101022).
 1.15.46.1 09-Oct-2010  yamt sync with head
 1.17.2.1 02-Aug-2025  perseant Sync with HEAD
 1.11 26-Sep-2023  tsutsui Remove trailing spaces and TABs.
 1.10 22-Mar-2017  chs provide a common softfloat fenv implemenation and use it for softfloat builds.
restore ABI compatibility with previous releases for ieeefp.h on sh3.
add namespace.h protection for all the fenv interfaces.
use MKSOFTFLOAT on sh3 instead of assuming softfloat.
standardize on comparing MKSOFTFLOAT with "no".
remove the arm-specific softfloat fenv code (which also had several bugs).
fix logic errors in the arm hardfloat feraiseexcept() and feupdateenv().
 1.9 27-Feb-2017  chs the FP_* constants need to be different from the new FE_* constants
to preserve the ABI, so shift them as needed when using them.
 1.8 25-Dec-2015  christos branches: 1.8.2; 1.8.4;
get rid of dup fenv.
 1.7 27-Jan-2009  martin branches: 1.7.24; 1.7.42;
The FE_* constants are used verbatim to set the RND field in the FPCR
register - so FE_UPWARD needs to be 3 and FE_DOWNWARD 2 - otherwise
our libc code for fpsetround(), fpgetround() and __flt_rounds() would
need to be adjust (and become slower). This fixes a failure in the
lib/libc/ieeefp/round regression test.

OK: matt
 1.6 05-Aug-2008  matt branches: 1.6.2; 1.6.4;
Update <machine/ieeefp.h> to use the C99 FE_* definitions instead of the
NetBSD defined ones. Redefine the NetBSD ones in terms of the C99 ones.
Step 1 to having <fenv.h>
 1.5 11-Dec-2005  christos branches: 1.5.74; 1.5.78; 1.5.80; 1.5.84;
merge ktrace-lwp.
 1.4 28-Aug-2004  thorpej De-__P
 1.3 05-Jan-1998  perry branches: 1.3.48;
RCSID Police.
 1.2 09-Apr-1995  mycroft Shift the bit positions.
 1.1 09-Apr-1995  mycroft Move fp_except and fp_rnd definitions to machine/include.
 1.3.48.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.3.48.2 18-Sep-2004  skrll Sync with HEAD.
 1.3.48.1 03-Sep-2004  skrll Sync with HEAD
 1.5.84.1 19-Oct-2008  haad Sync with HEAD.
 1.5.80.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.5.78.1 04-May-2009  yamt sync with head.
 1.5.74.1 28-Sep-2008  mjf Sync with HEAD.
 1.6.4.1 02-Feb-2009  snj Pull up following revision(s) (requested by martin in ticket #332):
sys/arch/m68k/include/ieeefp.h: revision 1.7
The FE_* constants are used verbatim to set the RND field in the FPCR
register - so FE_UPWARD needs to be 3 and FE_DOWNWARD 2 - otherwise
our libc code for fpsetround(), fpgetround() and __flt_rounds() would
need to be adjust (and become slower). This fixes a failure in the
lib/libc/ieeefp/round regression test.
OK: matt
 1.6.2.1 03-Mar-2009  skrll Sync with HEAD.
 1.7.42.2 28-Aug-2017  skrll Sync with HEAD
 1.7.42.1 27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.7.24.1 03-Dec-2017  jdolecek update from HEAD
 1.8.4.1 21-Apr-2017  bouyer Sync with HEAD
 1.8.2.2 26-Apr-2017  pgoyette Sync with HEAD
 1.8.2.1 20-Mar-2017  pgoyette Sync with HEAD
 1.4 13-Aug-2014  matt Include <sys/common_int_const.h> if __INTMAX_C_SUFFIX__ is defined.
 1.3 29-May-2010  tnozaki branches: 1.3.18;
fix wrong integer promotion rule(removed U suffix from UINT{8,16}_C).
see ISO/IEC 9899:1999 7.18.4.3.
 1.2 28-Apr-2008  martin branches: 1.2.20; 1.2.22;
Remove clause 3 and 4 from TNF licenses
 1.1 14-Apr-2001  kleink branches: 1.1.2; 1.1.4; 1.1.12; 1.1.130; 1.1.132; 1.1.134;
Add definitions of C99 integer constant macros.
 1.1.134.2 11-Aug-2010  yamt sync with head.
 1.1.134.1 16-May-2008  yamt sync with head.
 1.1.132.1 18-May-2008  yamt sync with head.
 1.1.130.1 02-Jun-2008  mjf Sync with HEAD.
 1.1.12.2 14-Apr-2001  kleink Add definitions of C99 integer constant macros.
 1.1.12.1 14-Apr-2001  kleink file int_const.h was added on branch nathanw_sa on 2001-04-14 22:38:39 +0000
 1.1.4.1 21-Jun-2001  nathanw Catch up to -current.
 1.1.2.2 21-Apr-2001  bouyer Sync with HEAD
 1.1.2.1 14-Apr-2001  bouyer file int_const.h was added on branch thorpej_scsipi on 2001-04-21 17:53:55 +0000
 1.2.22.1 30-May-2010  rmind sync with head
 1.2.20.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.3.18.1 03-Dec-2017  jdolecek update from HEAD
 1.6 17-Aug-2014  martin Revert previous (SCN*FAST*) and make PRI*FAST* identical.
Should fix the default (gcc 4.5 based) build.
 1.5 15-Aug-2014  martin Fix the SCN*FAST* defines
 1.4 13-Aug-2014  matt include <sys/common_int_fmtio.h> if __INTPTR_FMTd__ is defined
 1.3 28-Apr-2008  martin branches: 1.3.44;
Remove clause 3 and 4 from TNF licenses
 1.2 26-Apr-2001  kleink branches: 1.2.2; 1.2.10; 1.2.128; 1.2.130; 1.2.132;
Add definitions for C99 fastest minimum-width integer types.
 1.1 15-Apr-2001  kleink branches: 1.1.2;
Add definitions of C99 integer format conversion macros.
XXX Fastest minimum-width integer types haven't been decided upon yet.
 1.1.2.2 21-Apr-2001  bouyer Sync with HEAD
 1.1.2.1 15-Apr-2001  bouyer file int_fmtio.h was added on branch thorpej_scsipi on 2001-04-21 17:53:56 +0000
 1.2.132.1 16-May-2008  yamt sync with head.
 1.2.130.1 18-May-2008  yamt sync with head.
 1.2.128.1 02-Jun-2008  mjf Sync with HEAD.
 1.2.10.2 26-Apr-2001  kleink Add definitions for C99 fastest minimum-width integer types.
 1.2.10.1 26-Apr-2001  kleink file int_fmtio.h was added on branch nathanw_sa on 2001-04-26 16:25:23 +0000
 1.2.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.3.44.1 03-Dec-2017  jdolecek update from HEAD
 1.9 26-Sep-2023  tsutsui Remove trailing spaces and TABs.
 1.8 13-Aug-2014  matt Include <sys/common_init_limits.h> if __SIG_ATOMIC_MAX__ is defined.
 1.7 28-Apr-2008  martin branches: 1.7.44;
Remove clause 3 and 4 from TNF licenses
 1.6 17-Oct-2007  garbled branches: 1.6.16; 1.6.18; 1.6.20;
Merge the ppcoea-renovation branch to HEAD.

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

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

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.5 31-Aug-2007  drochner Fix definitions of UCHAR_MAX/USHRT_MAX and related
types. C99 requires that these definitions promote to (signed/unsigned)
integer the same way as the types the definition is for. And since
unsigned char/short fit into an "int" on all our archs and thus promote
to signed int, the definitions must not be unsigned.
Fixes PR lib/31306 by Neil Booth.
 1.4 11-Dec-2005  christos branches: 1.4.30; 1.4.38; 1.4.44; 1.4.48; 1.4.50;
merge ktrace-lwp.
 1.3 08-May-2004  kleink branches: 1.3.12;
Factor out W{CHAR,INT}_{MAX,MIN} into their own header file.
 1.2 26-Apr-2001  kleink branches: 1.2.2; 1.2.10; 1.2.26;
Add definitions for C99 fastest minimum-width integer types.
 1.1 15-Apr-2001  kleink branches: 1.1.2;
Add definitions of C99 specified-width integer type limits.
XXX Fastest minimum-width integer types haven't been decided upon yet.
 1.1.2.2 21-Apr-2001  bouyer Sync with HEAD
 1.1.2.1 15-Apr-2001  bouyer file int_limits.h was added on branch thorpej_scsipi on 2001-04-21 17:53:56 +0000
 1.2.26.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.2.26.2 18-Sep-2004  skrll Sync with HEAD.
 1.2.26.1 03-Aug-2004  skrll Sync with HEAD
 1.2.10.2 26-Apr-2001  kleink Add definitions for C99 fastest minimum-width integer types.
 1.2.10.1 26-Apr-2001  kleink file int_limits.h was added on branch nathanw_sa on 2001-04-26 16:25:23 +0000
 1.2.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.3.12.1 03-Sep-2007  yamt sync with head.
 1.4.50.1 06-Nov-2007  matt sync with HEAD
 1.4.48.1 03-Sep-2007  jmcneill Sync with HEAD.
 1.4.44.1 03-Sep-2007  skrll Sync with HEAD.
 1.4.38.1 03-Oct-2007  garbled Sync with HEAD
 1.4.30.1 09-Oct-2007  ad Sync with head.
 1.6.20.1 16-May-2008  yamt sync with head.
 1.6.18.1 18-May-2008  yamt sync with head.
 1.6.16.1 02-Jun-2008  mjf Sync with HEAD.
 1.7.44.1 03-Dec-2017  jdolecek update from HEAD
 1.6 15-Aug-2014  martin Fix editor mishap
 1.5 13-Aug-2014  matt include <sys/common_int_mwgwtypes.h> if __UINT_FAST64_TYPE__ is defined.
 1.4 28-Apr-2008  martin branches: 1.4.44;
Remove clause 3 and 4 from TNF licenses
 1.3 24-Dec-2005  perry branches: 1.3.74; 1.3.76; 1.3.78;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.
 1.2 26-Apr-2001  kleink branches: 1.2.2; 1.2.10; 1.2.42;
Add definitions for C99 fastest minimum-width integer types.
 1.1 14-Apr-2001  kleink branches: 1.1.2;
Add definitions of C99 minimum-width and greatest-width integer types.
XXX Fastest minimum-width integer types haven't been decided upon yet.
 1.1.2.2 21-Apr-2001  bouyer Sync with HEAD
 1.1.2.1 14-Apr-2001  bouyer file int_mwgwtypes.h was added on branch thorpej_scsipi on 2001-04-21 17:53:56 +0000
 1.2.42.1 21-Jun-2006  yamt sync with head.
 1.2.10.2 26-Apr-2001  kleink Add definitions for C99 fastest minimum-width integer types.
 1.2.10.1 26-Apr-2001  kleink file int_mwgwtypes.h was added on branch nathanw_sa on 2001-04-26 16:25:23 +0000
 1.2.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.3.78.1 16-May-2008  yamt sync with head.
 1.3.76.1 18-May-2008  yamt sync with head.
 1.3.74.1 02-Jun-2008  mjf Sync with HEAD.
 1.4.44.1 03-Dec-2017  jdolecek update from HEAD
 1.10 13-Aug-2014  matt Include <sys/common_int_types.h> if __UINTPTR_TYPE__ is defined.
 1.9 24-Dec-2005  perry branches: 1.9.122;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.
 1.8 11-Dec-2005  christos merge ktrace-lwp.
 1.7 06-Sep-2005  kleink signed -> __signed
 1.6 07-Aug-2003  agc branches: 1.6.16;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.5 28-Apr-2001  kleink branches: 1.5.8; 1.5.24;
* Move definitions of exact-width integer types from <machine/types.h>
to <sys/types.h> and <sys/stdint.h>.
* Add a new C99 <stdint.h> header, which provides integer types of
explicit width, related limits and integer constant macros.
* Extend <inttypes.h> to provide <stdint.h> definitions and format
macros for printf() and scanf().
* Add C99 strtoimax() and strtoumax() functions.
* Use the latter within scanf().
* Add C99 %j, %t and %z printf()/scanf() conversions for
intmax_t, pointer-type and size_t arguments.
 1.4 12-Apr-2001  kleink Replace the 'unsigned __COMPILER_INT64__' construct with a new name,
__COMPILER_UINT64__, to be supplied - if such a case is made, it shouldn't
be assumed that the unsigned type-specifier may be applied to it.
 1.3 03-Jan-2001  takemura branches: 1.3.2;
replace 'long long' with int64_t to compile stand alone program with
compiler other than GCC.
 1.2 27-Jun-2000  kleink branches: 1.2.2;
Resolve some formatting nits; add __intptr_t and __uintptr_t.
 1.1 26-Jun-2000  kleink Add <machine/int_types.h>, which provides namespace-pure definitions
of exact-width integer types.
 1.2.2.4 21-Apr-2001  bouyer Sync with HEAD
 1.2.2.3 05-Jan-2001  bouyer Sync with HEAD
 1.2.2.2 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.2.2.1 27-Jun-2000  bouyer file int_types.h was added on branch thorpej_scsipi on 2000-11-20 20:11:39 +0000
 1.3.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.5.24.4 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.5.24.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.5.24.2 18-Sep-2004  skrll Sync with HEAD.
 1.5.24.1 03-Aug-2004  skrll Sync with HEAD
 1.5.8.2 28-Apr-2001  kleink * Move definitions of exact-width integer types from <machine/types.h>
to <sys/types.h> and <sys/stdint.h>.
* Add a new C99 <stdint.h> header, which provides integer types of
explicit width, related limits and integer constant macros.
* Extend <inttypes.h> to provide <stdint.h> definitions and format
macros for printf() and scanf().
* Add C99 strtoimax() and strtoumax() functions.
* Use the latter within scanf().
* Add C99 %j, %t and %z printf()/scanf() conversions for
intmax_t, pointer-type and size_t arguments.
 1.5.8.1 28-Apr-2001  kleink file int_types.h was added on branch nathanw_sa on 2001-04-28 15:41:32 +0000
 1.6.16.1 21-Jun-2006  yamt sync with head.
 1.9.122.1 03-Dec-2017  jdolecek update from HEAD
 1.9 08-Feb-2024  andvar s/sharable/shareable in comments and documentation.
 1.8 19-Jan-2024  thorpej Now that we've agreed on the name "intr_depth", let's agree on the type, too.
 1.7 19-Jan-2024  thorpej Consistently use "intr_depth" as the name of the interrupt depth counter
on m68k platforms.
 1.6 19-Jan-2024  thorpej Add _KERNEL guards around most of the definitions in these files.
 1.5 16-Jan-2024  thorpej - Declare idepth as volatile.
- Provide a m68k_intrvec_intrhand() routine that returns the interrupt
handle for a given vectored interrupt. XXX This is gross and should
burn to the ground, but is needed to support legacy ISR interfaces.
 1.4 15-Jan-2024  thorpej Provide a m68k_count_intr() macro that hides the details of how interrupts
are counted, and also ensures that ci_data.cpu_nintr is incremented.
 1.3 15-Jan-2024  thorpej Use evcnt to count interrupts for the non-__HAVE_LEGACY_INTRCNT case.
 1.2 15-Jan-2024  thorpej Add the "ISR priority" notion that's used on some m68k platforms:

/*
* Some devices are particularly sensitive to interrupt
* handling latency. Unbuffered serial ports, for example,
* can lose data if their interrupts aren't handled with
* reasonable speed. For this reason, we sort interrupt
* handlers by an abstract "ISR" priority, inserting higher-
* priority interrupts before lower-priority interrupts.
*/

(...within the same shared auto-vectored interrupt list.)
 1.1 14-Jan-2024  thorpej Add a common m68k interrupt dispatch implementation.
 1.7 29-Jan-2023  mlelstv fix typo
 1.6 27-Jan-2023  tsutsui Use proper uintNN_t integer types.
 1.5 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.4 21-May-2001  fredette branches: 1.4.8; 1.4.126; 1.4.128; 1.4.130;
Added support for kernel cores on the sun2. This
increases sizeof(struct cpu_kcore_hdr).
 1.3 01-May-1997  gwr branches: 1.3.34;
Remove unused part of sun3_kcore_hdr.
 1.2 09-Apr-1997  thorpej New kcore.h for m68k, includes all possible m68k formats in a self-describing
layout, facilitating sharing libkvm on all m68ks.

NOTE: This changes the crash dump format of all m68k ports that use the
new libkvm!
 1.1 10-Mar-1996  leo Add the include files and the atari kernel support for new format panic
dumps.
 1.3.34.1 21-Jun-2001  nathanw Catch up to -current.
 1.4.130.1 16-May-2008  yamt sync with head.
 1.4.128.1 18-May-2008  yamt sync with head.
 1.4.126.1 02-Jun-2008  mjf Sync with HEAD.
 1.4.8.2 21-May-2001  fredette Added support for kernel cores on the sun2. This
increases sizeof(struct cpu_kcore_hdr).
 1.4.8.1 21-May-2001  fredette file kcore.h was added on branch nathanw_sa on 2001-05-21 14:48:59 +0000
 1.24 21-Jan-2019  dholland Fix wrong scoping of {U,}LLONG_MAX. More cases, not just amd64.
PR 53298 from Roberto E. Vargas Caballero.
 1.23 21-Apr-2014  matt branches: 1.23.26; 1.23.28;
Since all our compilers support __DBL_* and __FLT_*, use them to define
{DBL,FLT}_{DIG,MIN,MAX}
 1.22 11-Apr-2013  christos branches: 1.22.4; 1.22.8;
add missing SSIZE_MIN
 1.21 28-Mar-2012  christos branches: 1.21.2;
- Normalize inclusion protection (remove)
- Move CHAR_{MIN,MAX} to a common file.
- Fix broken comments
 1.20 07-Jun-2010  tnozaki branches: 1.20.8; 1.20.12;
1. MB_LEN_MAX switch MD to MI.
2. unfortunately hppa's MB_LEN_MAX is defined incorrectly 6 instead of 32
so we have to add more setlocale(3) __RENAME func, __setlocale50.
3. move setlocale1.c and setlocale32.c to lib/libc/compat/locale/*
prepareing for next libc major crunk.
4. bump libc minor version.
 1.19 17-Oct-2007  garbled branches: 1.19.20; 1.19.40; 1.19.42;
Merge the ppcoea-renovation branch to HEAD.

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

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

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.18 31-Aug-2007  drochner Fix definitions of UCHAR_MAX/USHRT_MAX and related
types. C99 requires that these definitions promote to (signed/unsigned)
integer the same way as the types the definition is for. And since
unsigned char/short fit into an "int" on all our archs and thus promote
to signed int, the definitions must not be unsigned.
Fixes PR lib/31306 by Neil Booth.
 1.17 11-Dec-2005  christos branches: 1.17.30; 1.17.38; 1.17.44; 1.17.48; 1.17.50;
merge ktrace-lwp.
 1.16 07-Aug-2003  agc branches: 1.16.16;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.15 28-Apr-2003  bjh21 branches: 1.15.2;
Add a new feature-test macro, _NETBSD_SOURCE. If this is defined
by the application, all NetBSD interfaces are made visible, even
if some other feature-test macro (like _POSIX_C_SOURCE) is defined.
<sys/featuretest.h> defined _NETBSD_SOURCE if none of _ANSI_SOURCE,
_POSIX_C_SOURCE and _XOPEN_SOURCE is defined, so as to preserve
existing behaviour.

This has two major advantages:
+ Programs that require non-POSIX facilities but define _POSIX_C_SOURCE
can trivially be overruled by putting -D_NETBSD_SOURCE in their CFLAGS.
+ It makes most of the #ifs simpler, in that they're all now ORs of the
various macros, rather than having checks for (!defined(_ANSI_SOURCE) ||
!defined(_POSIX_C_SOURCE) || !defined(_XOPEN_SOURCE)) all over the place.

I've tried not to change the semantics of the headers in any case where
_NETBSD_SOURCE wasn't defined, but there were some places where the
current semantics were clearly mad, and retaining them was harder than
correcting them. In particular, I've mostly normalised things so that
_ANSI_SOURCE gets you the smallest set of stuff, then _POSIX_C_SOURCE,
_XOPEN_SOURCE and _NETBSD_SOURCE in that order.

Tested by building for vax, encouraged by thorpej, and uncontested in
tech-userlevel for a week.
 1.14 04-May-2001  simonb branches: 1.14.8;
Be consistent with limit constants:
- use "U" suffix for unsigned constants
- use "L" suffix for long constants
- use "UL" suffix for unsigned long constants
- use hexadecimal instead of decimal

Fixes build problems with vi (now that warnings/errors are enabled) on
mips, powerpc and arm platforms.
 1.13 08-Aug-2000  tshiozak branches: 1.13.2;
Preparation for the future introduction of multibyte locale.
- MB_LEN_MAX is increased to 32.
- To ensure binary compatibility for old executables
under multibyte locale, versioned setlocale is added.
- __mb_len_cur definision is added in setlocale.c
and enable it in stdlib.h .
It is also important for multibyte locale stuffs,
but I just forgot.
 1.12 07-Mar-2000  kleink branches: 1.12.2; 1.12.4;
Define ISO C99 (unsigned) long long (min, max) symbols.
 1.11 06-Aug-1998  kleink branches: 1.11.12;
_POSIX_SOURCE -> _POSIX_C_SOURCE
 1.10 09-Jan-1998  perry multiple include protect machine/limits.h, fixes pr 4473 (from Mika Nystrom)
 1.9 26-Oct-1994  cgd new RCS ID format.
 1.8 05-Oct-1994  jtc Add constants required by XPG3
 1.7 09-May-1994  chopps Add SSIZE_MAX and SIZE_T_MAX, also fix other broken values.
 1.6 10-Apr-1994  chopps protect against multiple inclusion
 1.5 07-Dec-1993  mycroft Make sure min values are correct when used at a larger size.
 1.4 06-Dec-1993  mycroft Add quad support.
 1.3 18-Aug-1993  jtc Removed CLK_TCK, it's value is not machine dependant.
It's supposed to be defined in <time.h>, not <limits.h> anyway.
 1.2 22-May-1993  cgd add rcsids to everything and clean up headers
 1.1 13-May-1993  cgd add from net2. were symlinks to ../../vax/include/*
 1.11.12.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.12.4.1 09-Aug-2000  tshiozak pull up the following changes (approved by thorpej):
> cvs rdiff -r1.9 -r1.10 basesrc/include/locale.h
> cvs rdiff -r1.45 -r1.46 basesrc/include/stdlib.h
> cvs rdiff -r1.16 -r1.17 basesrc/lib/libc/locale/Makefile.inc
> cvs rdiff -r1.17 -r1.18 basesrc/lib/libc/locale/setlocale.c
> cvs rdiff -r0 -r1.2 basesrc/lib/libc/locale/setlocale_sb.c
> cvs rdiff -r1.6 -r1.7 syssrc/sys/arch/alpha/include/limits.h
> cvs rdiff -r1.1 -r1.2 syssrc/sys/arch/arm26/include/limits.h
> cvs rdiff -r1.7 -r1.8 syssrc/sys/arch/arm32/include/limits.h
> cvs rdiff -r1.14 -r1.15 syssrc/sys/arch/i386/include/limits.h
> cvs rdiff -r1.12 -r1.13 syssrc/sys/arch/m68k/include/limits.h
> cvs rdiff -r1.13 -r1.14 syssrc/sys/arch/mips/include/limits.h
> cvs rdiff -r1.10 -r1.11 syssrc/sys/arch/pc532/include/limits.h
> cvs rdiff -r1.6 -r1.7 syssrc/sys/arch/powerpc/include/limits.h
> cvs rdiff -r1.2 -r1.3 syssrc/sys/arch/sh3/include/limits.h
> cvs rdiff -r1.11 -r1.12 syssrc/sys/arch/sparc/include/limits.h
> cvs rdiff -r1.7 -r1.8 syssrc/sys/arch/sparc64/include/limits.h
> cvs rdiff -r1.9 -r1.10 syssrc/sys/arch/vax/include/limits.h
>
> Outline:
>
> Preparation for the future introduction of multibyte locale.
> - MB_LEN_MAX is increased to 32.
> - To ensure binary compatibility for old executables
> under multibyte locale, versioned setlocale is added.
> - __mb_len_cur definision is added in setlocale.c
> and enable it in stdlib.h .
> It is also important for multibyte locale stuffs,
> but I just forgot.
 1.12.2.1 28-May-2000  minoura Citrus Project XPG4DL, an implementation of I18N (locale) framework,
is imported.
 1.13.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.14.8.2 04-May-2001  simonb Be consistent with limit constants:
- use "U" suffix for unsigned constants
- use "L" suffix for long constants
- use "UL" suffix for unsigned long constants
- use hexadecimal instead of decimal

Fixes build problems with vi (now that warnings/errors are enabled) on
mips, powerpc and arm platforms.
 1.14.8.1 04-May-2001  simonb file limits.h was added on branch nathanw_sa on 2001-05-04 15:12:33 +0000
 1.15.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.15.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.15.2.1 03-Aug-2004  skrll Sync with HEAD
 1.16.16.1 03-Sep-2007  yamt sync with head.
 1.17.50.1 06-Nov-2007  matt sync with HEAD
 1.17.48.1 03-Sep-2007  jmcneill Sync with HEAD.
 1.17.44.1 03-Sep-2007  skrll Sync with HEAD.
 1.17.38.1 03-Oct-2007  garbled Sync with HEAD
 1.17.30.1 09-Oct-2007  ad Sync with head.
 1.19.42.1 03-Jul-2010  rmind sync with head
 1.19.40.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.19.20.1 11-Aug-2010  yamt sync with head.
 1.20.12.1 05-Apr-2012  mrg sync to latest -current.
 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 17-Apr-2012  yamt sync with head
 1.21.2.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.21.2.1 23-Jun-2013  tls resync from head
 1.22.8.1 10-Aug-2014  tls Rebase.
 1.22.4.1 18-May-2014  rmind sync with head
 1.23.28.1 10-Jun-2019  christos Sync with HEAD
 1.23.26.1 26-Jan-2019  pgoyette Sync with HEAD
 1.17 13-Feb-2022  riastradh m68k: __cpu_simple_unlock audit.

- Use `cc' clobbers in asm volatile because they touch the condition
codes.

- Use `memory' clobbers in asm volatile so the compiler doesn't move
up loads and stores in the critical section at _other_ addresses
than the lock so they happen before __cpu_simple_lock or
__cpu_simple_lock_try.

- Not sure if we have any (or if there even are any?) multicore m68k
systems out there, but __cpu_simple_unlock needs __insn_barrier
either way so the compiler doesn't delay loads and stores prior to
__cpu_simple_unlock so they happen after it.
 1.16 29-Nov-2019  riastradh Nix mb_* on m68k.
 1.15 17-Sep-2017  christos branches: 1.15.4;
more const.
 1.14 28-Apr-2008  martin branches: 1.14.44;
Remove clause 3 and 4 from TNF licenses
 1.13 17-Oct-2007  garbled branches: 1.13.16; 1.13.18; 1.13.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.12 10-Sep-2007  skrll Merge nick-csl-alignment.
 1.11 09-Feb-2007  ad branches: 1.11.6; 1.11.14; 1.11.18; 1.11.22; 1.11.24;
Merge newlock2 to head.
 1.10 16-Nov-2006  christos __unused removal on arguments; approved by core.
 1.9 28-Dec-2005  perry branches: 1.9.20; 1.9.22;
inline -> __inline
 1.8 24-Dec-2005  perry Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.
 1.7 11-Dec-2005  christos merge ktrace-lwp.
 1.6 28-Aug-2004  thorpej branches: 1.6.12;
De-__P
 1.5 26-Sep-2003  nathanw Move __cpu_simple_lock_t and __SIMPLELOCK_{UN,}LOCKED to machine/types.h
so that they can be used in a namespace-friendly way.
 1.4 17-Jan-2003  thorpej branches: 1.4.2;
Merge the nathanw_sa branch.
 1.3 02-May-2000  thorpej branches: 1.3.6; 1.3.14;
On the m68k, the most efficient type for __cpu_simple_lock_t is
an unsigned char, since that is what the `tas' instruction uses.

While I'm here, implement the __cpu_simple_lock family of routines.
Why? One, because they're easy. Two, so Steve can get master/slave
MVME systems talking across the backplane. :-)
 1.2 02-May-2000  thorpej Let each platform typedef the new __cpu_simple_lock_t, which should
be the most efficient type used for the atomic operations in the
simplelock structure, and should also be __volatile.
 1.1 29-Apr-2000  thorpej Require that each each MACHINE/MACHINE_ARCH supply a lock.h. This file
contains the values __SIMPLELOCK_LOCKED and __SIMPLELOCK_UNLOCKED, which
replace the old SIMPLELOCK_LOCKED and SIMPLELOCK_UNLOCKED. These files
are also required to supply inline functions __cpu_simple_lock(),
__cpu_simple_lock_try(), and __cpu_simple_unlock() if locking is to be
supported on that platform (i.e. if MULTIPROCESSOR is defined in the
_KERNEL case). Change these functions to take an int * (&alp->lock_data)
rather than the struct simplelock * itself.

These changes make it possible for userland to use the locking primitives
by including <machine/lock.h>.
 1.3.14.2 25-Nov-2001  scw Oops, got a bit too enthusiastic in the last change. Drop the volatile
qualifier from __rv, otherwise the compiler generates even worse code
than normal. ;)
 1.3.14.1 25-Nov-2001  scw In __cpu_simple_lock_try(), move the initialisation of __rv down into
the asm code otherwise the compiler optimises it away...
 1.3.6.2 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.3.6.1 02-May-2000  bouyer file lock.h was added on branch thorpej_scsipi on 2000-11-20 20:11:39 +0000
 1.4.2.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.4.2.3 18-Sep-2004  skrll Sync with HEAD.
 1.4.2.2 03-Sep-2004  skrll Sync with HEAD
 1.4.2.1 03-Aug-2004  skrll Sync with HEAD
 1.6.12.4 27-Oct-2007  yamt sync with head.
 1.6.12.3 26-Feb-2007  yamt sync with head.
 1.6.12.2 30-Dec-2006  yamt sync with head.
 1.6.12.1 21-Jun-2006  yamt sync with head.
 1.9.22.1 10-Dec-2006  yamt sync with head.
 1.9.20.2 06-Feb-2007  ad Make amiga & mac68k compile.
 1.9.20.1 18-Nov-2006  ad Sync with head.
 1.11.24.1 06-Nov-2007  matt sync with HEAD
 1.11.22.1 02-Oct-2007  joerg Sync with HEAD.
 1.11.18.1 15-Aug-2007  skrll Provide __SIMPLELOCK_{UN,}LOCKED_P and __cpu_simple_lock_{set,clear}
for all architectures.
 1.11.14.1 03-Oct-2007  garbled Sync with HEAD
 1.11.6.1 09-Oct-2007  ad Sync with head.
 1.13.20.1 16-May-2008  yamt sync with head.
 1.13.18.1 18-May-2008  yamt sync with head.
 1.13.16.1 02-Jun-2008  mjf Sync with HEAD.
 1.14.44.1 03-Dec-2017  jdolecek update from HEAD
 1.15.4.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.3 04-Nov-2024  christos Undo previous lwp.h change.
 1.2 03-Nov-2024  christos Split __lwp_getprivate_fast and __lwp_*tcb from mcontext.h into a separate
lwp.h file.
 1.1 17-Nov-2001  scw branches: 1.1.2;
file lwp.h was initially added on branch nathanw_sa.
 1.1.2.3 01-Aug-2002  nathanw Catch up to -current.
 1.1.2.2 18-Nov-2001  scw White space nit.
 1.1.2.1 17-Nov-2001  scw Kernel support for Scheduler Activations on m68k-based ports using
mvme68k as a testbed.

Boots multi-user on an mvme162, although userland support for SA is not
yet integrated/tested.
 1.2 01-Dec-2024  skrll branches: 1.2.4;
Shuffle code so it compiles
 1.1 30-Nov-2024  christos Create a new header lwp_private.h to contain _lwp_getprivate_fast,
_lwp_gettcb_fast, _lwp_settcb and remove them from mcontext.h, so that:
1. we don't need special hacks to hide them
2. we can include <lwp.h> where needed to get the necessary prototypes
without redefining them locally.
 1.2.4.2 02-Aug-2025  perseant Sync with HEAD
 1.2.4.1 01-Dec-2024  perseant file lwp_private.h was added on branch perseant-exfatfs on 2025-08-02 05:55:48 +0000
 1.27 13-Jan-2024  thorpej Make getsfc() and getdfc() inlines; it's slightly smaller.
 1.26 26-Sep-2023  tsutsui TAB/space cleanup.
 1.25 26-Sep-2023  tsutsui Remove trailing spaces and TABs.
 1.24 06-Apr-2019  thorpej Overhaul the API used to fetch and store individual memory cells in
userspace. The old fetch(9) and store(9) APIs (fubyte(), fuword(),
subyte(), suword(), etc.) are retired and replaced with new ufetch(9)
and ustore(9) APIs that can return proper error codes, etc. and are
implemented consistently across all platforms. The interrupt-safe
variants are no longer supported (and several of the existing attempts
at fuswintr(), etc. were buggy and not actually interrupt-safe).

Also augmement the ucas(9) API, making it consistently available on
all plaforms, supporting uniprocessor and multiprocessor systems, even
those that do not have CAS or LL/SC primitives.

Welcome to NetBSD 8.99.37.
 1.23 14-Mar-2019  thorpej G/C "MAPPECOPY". It is the deadest of wood, and never actually worked in
NetBSD.
 1.22 19-Feb-2012  rmind branches: 1.22.40;
Remove COMPAT_SA / KERN_SA. Welcome to 6.99.3!
Approved by core@.
 1.21 22-Dec-2011  tsutsui Adjust for function merge and move.
 1.20 15-Nov-2011  tsutsui branches: 1.20.4;
Merge copy-and-pasted fpu_probe() function (to share it among more m68k ports).
Tested on TT030, Sun3/80, and X68030.
 1.19 16-May-2011  tsutsui branches: 1.19.4;
- merge and move pasted m68k MD setreg() functions into m68k/m68k_machdep.c
- move m68881_save() and m68881_restore() declarations into <m68k/m68k.h>

Briefly tested and no obvious breakage on atari, sun3, and x68k.
 1.18 08-Feb-2011  rmind Remove clause 3 (UCB advertising clause) from the University of Utah
copyright. Confirmed by Mike Hibler, mike at cs.utah.edu - thanks!
Also, merge UCB and Utah copyright texts back into one, as they
originally were.

Extra verification by snj@.
 1.17 07-Jul-2010  chs branches: 1.17.2; 1.17.4;
implement ucas_* for m68k.
 1.16 19-Dec-2009  tsutsui branches: 1.16.2; 1.16.4;
Move declaration of setfunc_trampoline() into <m68k/m68k.h>.
 1.15 19-Dec-2009  tsutsui Move declaration of lwp_trampoline() into <m68k/m68k.h>.
 1.14 30-May-2009  martin Do not use lwp_trampoline for cpu_setfunc, we do not want to call
lwp_startup() after a setfunc. Grow a simplified setfunc_trampoline
instead.
 1.13 17-Oct-2007  garbled branches: 1.13.20; 1.13.30; 1.13.36;
Merge the ppcoea-renovation branch to HEAD.

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

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

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.12 21-May-2007  tsutsui branches: 1.12.10;
Move declarations of m68k common functions
from <machine/cpu.h> to <m68k/m68k.h>.
While here, remove some obsolete function decls.
 1.11 11-Dec-2005  christos branches: 1.11.30; 1.11.32; 1.11.38;
merge ktrace-lwp.
 1.10 28-Aug-2004  thorpej branches: 1.10.12;
De-__P
 1.9 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.8 14-Jun-2001  fredette branches: 1.8.8; 1.8.24;
Added prototypes for w16zero and w16copy, found
in the new w16copy.s.
 1.7 03-May-2001  fredette Add a CPU_68010 macro.
 1.6 21-Oct-1997  gwr branches: 1.6.26;
comments
 1.5 21-Oct-1997  gwr Declarations for things exported by sources in this directory.
(i.e. stuff that does not belong in <machine/cpu.h>)
 1.4 09-Apr-1997  thorpej branches: 1.4.8;
Prototype regdump().
 1.3 02-Feb-1997  thorpej prototype mappedcopy{in,out}(), {copy,zero}page().
 1.2 12-Sep-1996  thorpej Add an FPU_UNKNOWN constant; just a placeholder for any unknown FPU.
 1.1 11-Sep-1996  thorpej Factor out common Motorola 68k CPU definitions from the m68k port
cpu.h header files.

Some more work could be done here, but it's a good start.
 1.4.8.1 22-Oct-1997  mellon pull up from main trunk
 1.6.26.1 21-Jun-2001  nathanw Catch up to -current.
 1.8.24.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.8.24.3 18-Sep-2004  skrll Sync with HEAD.
 1.8.24.2 03-Sep-2004  skrll Sync with HEAD
 1.8.24.1 03-Aug-2004  skrll Sync with HEAD
 1.8.8.2 14-Jun-2001  fredette Added prototypes for w16zero and w16copy, found
in the new w16copy.s.
 1.8.8.1 14-Jun-2001  fredette file m68k.h was added on branch nathanw_sa on 2001-06-14 15:49:06 +0000
 1.10.12.1 03-Sep-2007  yamt sync with head.
 1.11.38.1 22-May-2007  matt Update to HEAD.
 1.11.32.1 11-Jul-2007  mjf Sync with head.
 1.11.30.1 27-May-2007  ad Sync with head.
 1.12.10.1 06-Nov-2007  matt sync with HEAD
 1.13.36.1 05-Jun-2009  snj branches: 1.13.36.1.2;
Pull up following revision(s) (requested by martin in ticket #787):
sys/arch/m68k/include/m68k.h: revision 1.14
sys/arch/m68k/m68k/switch_subr.s: revision 1.22
sys/arch/m68k/m68k/vm_machdep.c: revision 1.28
Do not use lwp_trampoline for cpu_setfunc, we do not want to call
lwp_startup() after a setfunc. Grow a simplified setfunc_trampoline
instead.
 1.13.36.1.2.1 21-Apr-2010  matt sync to netbsd-5
 1.13.30.1 05-Jun-2009  snj Pull up following revision(s) (requested by martin in ticket #787):
sys/arch/m68k/include/m68k.h: revision 1.14
sys/arch/m68k/m68k/switch_subr.s: revision 1.22
sys/arch/m68k/m68k/vm_machdep.c: revision 1.28
Do not use lwp_trampoline for cpu_setfunc, we do not want to call
lwp_startup() after a setfunc. Grow a simplified setfunc_trampoline
instead.
 1.13.20.3 11-Aug-2010  yamt sync with head.
 1.13.20.2 11-Mar-2010  yamt sync with head
 1.13.20.1 20-Jun-2009  yamt sync with head
 1.16.4.2 31-May-2011  rmind sync with head
 1.16.4.1 05-Mar-2011  rmind sync with head
 1.16.2.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.17.4.1 17-Feb-2011  bouyer Sync with HEAD
 1.17.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.19.4.1 17-Apr-2012  yamt sync with head
 1.20.4.2 24-Feb-2012  mrg sync to -current.
 1.20.4.1 18-Feb-2012  mrg merge to -current.
 1.22.40.1 10-Jun-2019  christos Sync with HEAD
 1.9 18-Mar-2014  riastradh Merge riastradh-drm2 to HEAD.
 1.8 18-Jul-2013  matt Coldfire FPU looks like the 68010 FPU (no long double)
 1.7 11-Dec-2005  christos branches: 1.7.112; 1.7.122; 1.7.128; 1.7.136;
merge ktrace-lwp.
 1.6 30-Oct-2003  kleink Don't define __HAVE_LONG_DOUBLE for __mc68010__.
 1.5 28-Oct-2003  kleink #define __HAVE_LONG_DOUBLE on platforms which implement a distinct
`long double' type.
 1.4 19-Feb-2002  simonb branches: 1.4.16;
Clean up some rampant code duplication wrt ieee number handling:
- Add alignment-safe double and float unions.
- Use the above for the __infinity and __nan constants on all
architectures that use the standard ieee754 representation of
those constants.
- Add a single copy of various ieee754 math functions (frexp, isinf,
isnan, ldexp and modf) that had numerous duplicates among the
arch-specific directories.
- Use the above functions on all architectures where the generic C
versions where used. Architectures that had local assembly
routines are untouched (for those functions only).
 1.3 05-Feb-2000  kleink branches: 1.3.6; 1.3.10; 1.3.14;
Improve namespace test macros a bit.
 1.2 04-Jan-2000  kleink const -> __const and include <sys/cdefs.h> earlier; fixes PR lib/9052
by Takahiro Kambe.
 1.1 23-Dec-1999  kleink C99: Define a NAN macro in <math.h> which evaulates to a constant expression of
a single-precision quiet NaN; only to be defined on platforms that do support
this value.
 1.3.14.1 28-Feb-2002  nathanw Catch up to -current.
 1.3.10.1 16-Mar-2002  jdolecek Catch up with -current.
 1.3.6.2 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.3.6.1 05-Feb-2000  bouyer file math.h was added on branch thorpej_scsipi on 2000-11-20 20:11:39 +0000
 1.4.16.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.4.16.2 18-Sep-2004  skrll Sync with HEAD.
 1.4.16.1 03-Aug-2004  skrll Sync with HEAD
 1.7.136.1 23-Jul-2013  riastradh sync with HEAD
 1.7.128.1 28-Aug-2013  rmind sync with head
 1.7.122.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.7.112.1 22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.16 30-Nov-2024  christos Create a new header lwp_private.h to contain _lwp_getprivate_fast,
_lwp_gettcb_fast, _lwp_settcb and remove them from mcontext.h, so that:
1. we don't need special hacks to hide them
2. we can include <lwp.h> where needed to get the necessary prototypes
without redefining them locally.
 1.15 04-Nov-2024  christos Undo previous lwp.h change.
 1.14 03-Nov-2024  christos Split __lwp_getprivate_fast and __lwp_*tcb from mcontext.h into a separate
lwp.h file.
 1.13 18-May-2024  thorpej branches: 1.13.2;
Clean up the <sys/ucontext.h> <-> <machine/mcontext.h> interface up
a little:
- Define _UC_MD_BIT* constants for the available machine-dependent bits,
and use those constants to define the machine-dependent bits as well
as the machine-independent bits that have machine-dependent values.
- Explicitly generate an error if _UC_TLSBASE, _UC_SETSTACK, or
_UC_CLRSTACK are not defined by <machine/mcontext.h>.
 1.12 04-Oct-2020  rin Add missing __{BEGIN,END}_DECLS in order to catch up with
sanitizer_linux_libcdep.cc rev 1.17:

http://cvsweb.netbsd.org/bsdweb.cgi/src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_linux_libcdep.cc#rev1.17

Fix build with HAVE_GCC=9.
 1.11 07-Sep-2020  mrg pass a pointer conversion via uintptr_t *and* the desired type casts.
avoids new GCC 9 warnings with C++ code.
 1.10 15-Feb-2018  kamil Introduce _UC_MACHINE_FP() as a macro

_UC_MACHINE_FP() is a helper macro to extract from mcontext a frame pointer.

Don't rely on this interface as a compiler might strip frame pointer or
optimize it making this interface unreliable.


For hppa assume a small frame context, for larger frames FP might be located
in a different register (4 instead of 3).

For ia64 there is no strict frame pointer, and registers might rotate.
Reuse 79 following:

./gcc/config/ia64/ia64.h:#define HARD_FRAME_POINTER_REGNUM LOC_REG (79)

Once ia64 will mature, this should be revisited.

A macro can encapsulate a real function for extracting Frame Pointer on
more complex CPUs / ABIs.


For the remaining CPUs, reuse standard register as defined in appropriate ABI.

The direct users of this macro are LLVM and GCC with Sanitizers.

Proposed on tech-userlevel@.

Sponsored by <The NetBSD Foundation>
 1.9 22-Nov-2011  joerg branches: 1.9.42;
Add TLS support for m68k.
 1.8 24-Feb-2011  joerg branches: 1.8.4;
Allow storing and receiving the LWP private pointer via ucontext_t
on all platforms except VAX and IA64. Add fast access via register for
AMD64, i386 and SH3 ports. Use this fast access in libpthread to replace
the stack based pthread_self(). Implement skeleton support for Alpha,
HPPA, PowerPC, SPARC and SPARC64, but leave it disabled.

Ports that support this feature provide __HAVE____LWP_GETPRIVATE_FAST in
machine/types.h and a corresponding __lwp_getprivate_fast in
machine/mcontext.h.

This material is based upon work partially supported by
The NetBSD Foundation under a contract with Joerg Sonnenberger.
 1.7 23-Feb-2011  joerg Fix ucontext32_t on AMD64. Add optional compile time assertions for
ucontext_t and ucontext32_t to ensure that they don't change.
Provide the constants for AMD64, ARM, i386, and M68K.
 1.6 28-Apr-2008  martin branches: 1.6.22; 1.6.28; 1.6.30;
Remove clause 3 and 4 from TNF licenses
 1.5 11-Dec-2005  christos branches: 1.5.74; 1.5.76; 1.5.78;
merge ktrace-lwp.
 1.4 08-Oct-2003  thorpej Add some accessor macros for the ucontext:
* _UC_MACHINE_PC() - access the program counter
* _UC_MACHINE_INTRV() - access the integer return value register
* _UC_MACHINE_SET_PC() - set the program counter (this requires
special handling on some platforms).
 1.3 22-Sep-2003  cl SA_SIGINFO support for m68k
 1.2 17-Jan-2003  thorpej branches: 1.2.2;
Merge the nathanw_sa branch.
 1.1 10-Nov-2001  scw branches: 1.1.2;
file mcontext.h was initially added on branch nathanw_sa.
 1.1.2.7 10-Jan-2003  thorpej On second thought, make __mc_frame _KERNEL || __M68K_MCONTEXT_PRIVATE.
 1.1.2.6 10-Jan-2003  thorpej Expose the remainder of the frame/fpframe in the mcontext to userland
(and namespace-cleanse the member names in doing so).
 1.1.2.5 28-Dec-2001  nathanw Add a macro, _UC_MACHINE_SP(), to fetch the user stack pointer from
a ucontext_t.
 1.1.2.4 02-Dec-2001  scw Add a comment about the padding in mcontext_t, and simplify fpregs.
 1.1.2.3 25-Nov-2001  scw When restoring thread context, check the _UC_USER bit and DTRT when
checking frame format and fpu saved state.

The whole `full fpu state cannot be saved/restored from userland' needs
more thought.

XXX: _UC_USER really ought to be defined in <sys/ucontext.h> ...
 1.1.2.2 21-Nov-2001  scw Add an MD flag for uc_flags which indicates if the exception frame
area of m68k's mcontext_t structure has valid contents.

In cpu_getcontext(), set the flag for all frame formats >= FMT4 such
that cpu_setcontext() does The Right Thing with both user and kernel
saved contexts.

Make null FP frame detection work for the 68060's FPU, and ensure we
always do at least an fsave/frestore when saving/restoring FPU regs.

Both kernel and user-level get/set context calls pass all Nathan's
context tests now.
 1.1.2.1 10-Nov-2001  scw Kernel mcontext glue for Scheduler Activations on m68k from
Klaus Klein <kleink@netbsd.org>.
 1.2.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.2.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.2.2.1 03-Aug-2004  skrll Sync with HEAD
 1.5.78.1 16-May-2008  yamt sync with head.
 1.5.76.1 18-May-2008  yamt sync with head.
 1.5.74.1 02-Jun-2008  mjf Sync with HEAD.
 1.6.30.1 05-Mar-2011  bouyer Sync with HEAD
 1.6.28.1 06-Jun-2011  jruoho Sync with HEAD.
 1.6.22.1 05-Mar-2011  rmind sync with head
 1.8.4.1 17-Apr-2012  yamt sync with head
 1.9.42.3 21-Mar-2018  martin Pull up the following, requested by kamil in ticket #552:

external/gpl3/gcc{.old}/dist/libsanitizer/asan/asan_linux.cc 1.4
sys/arch/aarch64/include/mcontext.h 1.2
sys/arch/alpha/include/mcontext.h 1.9
sys/arch/amd64/include/mcontext.h 1.19
sys/arch/arm/include/mcontext.h 1.19
sys/arch/hppa/include/mcontext.h 1.9
sys/arch/i386/include/mcontext.h 1.14
sys/arch/ia64/include/mcontext.h 1.6
sys/arch/m68k/include/mcontext.h 1.10
sys/arch/mips/include/mcontext.h 1.22
sys/arch/or1k/include/mcontext.h 1.2
sys/arch/powerpc/include/mcontext.h 1.18
sys/arch/riscv/include/mcontext.h 1.5
sys/arch/sh3/include/mcontext.h 1.11
sys/arch/sparc/include/mcontext.h 1.14-1.17
sys/arch/sparc64/include/mcontext.h 1.10
sys/arch/vax/include/mcontext.h 1.9
tests/lib/libc/sys/Makefile 1.50
tests/lib/libc/sys/t_ucontext.c 1.2-1.5
sys/arch/hppa/include/mcontext.h 1.10
sys/arch/ia64/include/mcontext.h 1.7

- Introduce _UC_MACHINE_FP(). _UC_MACHINE_FP() is a helper
macro to extract from mcontext a frame pointer.
- Add new tests in lib/libc/sys/t_ucontext:
* ucontext_sp (testing _UC_MACHINE_SP)
* ucontext_fp (testing _UC_MACHINE_FP)
* ucontext_pc (testing _UC_MACHINE_PC)
* ucontext_intrv (testing _UC_MACHINE_INTRV)

Add a dummy implementation of _UC_MACHINE_INTRV() for ia64.

Implement _UC_MACHINE_INTRV() for hppa.

Make the t_ucontext.c test more portable.

We now have _UC_MACHINE_FP.
 1.9.42.2 26-Feb-2018  snj revert ticket 552, which broke the build
 1.9.42.1 25-Feb-2018  snj Pull up following revision(s) (requested by kamil in ticket #552):
sys/arch/aarch64/include/mcontext.h: 1.2
sys/arch/alpha/include/mcontext.h: 1.9
sys/arch/amd64/include/mcontext.h: 1.19
sys/arch/arm/include/mcontext.h: 1.19
sys/arch/hppa/include/mcontext.h: 1.9
sys/arch/i386/include/mcontext.h: 1.14
sys/arch/ia64/include/mcontext.h: 1.6
sys/arch/m68k/include/mcontext.h: 1.10
sys/arch/mips/include/mcontext.h: 1.22
sys/arch/or1k/include/mcontext.h: 1.2
sys/arch/powerpc/include/mcontext.h: 1.18
sys/arch/riscv/include/mcontext.h: 1.5
sys/arch/sh3/include/mcontext.h: 1.11
sys/arch/sparc/include/mcontext.h: 1.14-1.17
sys/arch/sparc64/include/mcontext.h: 1.10
sys/arch/vax/include/mcontext.h: 1.9
tests/lib/libc/sys/Makefile: 1.50
tests/lib/libc/sys/t_ucontext.c: 1.2
Introduce _UC_MACHINE_FP() as a macro
_UC_MACHINE_FP() is a helper macro to extract from mcontext a frame pointer.
Don't rely on this interface as a compiler might strip frame pointer or
optimize it making this interface unreliable.
For hppa assume a small frame context, for larger frames FP might be located
in a different register (4 instead of 3).
For ia64 there is no strict frame pointer, and registers might rotate.
Reuse 79 following:
./gcc/config/ia64/ia64.h:#define HARD_FRAME_POINTER_REGNUM LOC_REG (79)
Once ia64 will mature, this should be revisited.
A macro can encapsulate a real function for extracting Frame Pointer on
more complex CPUs / ABIs.
For the remaining CPUs, reuse standard register as defined in appropriate ABI.
The direct users of this macro are LLVM and GCC with Sanitizers.
Proposed on tech-userlevel@.
Sponsored by <The NetBSD Foundation>
--
Improve _UC_MACHINE_FP() for SPARC/SPARC64
Introduce a static inline function _uc_machine_fp() that contains improved
caluclation of a frame pointer.
Algorithm:
uptr *stk_ptr;
# if defined (__arch64__)
stk_ptr = (uptr *) (*sp + 2047);
# else
stk_ptr = (uptr *) *sp;
# endif
*bp = stk_ptr[15];
Noted by <mrg>
--
Make _UC_MACHINE_FP() compile again and fix it so that it does not add
the offset twice.
--
fix _UC_MACHINE32_FP() -- use 32 bit pointer value so that [15] is
the right offset. do this by using __greg32_t, which is only in
the sparc64 version, and these are only useful there, so move them.
--
Add new tests in lib/libc/sys/t_ucontext
New tests:
- ucontext_sp
- ucontext_fp
- ucontext_pc
- ucontext_intrv
They test respectively:
- _UC_MACHINE_SP
- _UC_MACHINE_FP
- _UC_MACHINE_PC
- _UC_MACHINE_INTRV
These tests attempt to access and print the values from ucontext, without
interpreting the values.
This is a follow up of the _UC_MACHINE_FP() introduction.
These tests use PRIxREGISTER, and require to be built with -D_KERNTYPES.
Sponsored by <The NetBSD Foundation>
 1.13.2.1 02-Aug-2025  perseant Sync with HEAD
 1.3 08-Jul-2025  thorpej Add common '030 and '040/'060 routines for configuring the transparent
translation registers. Adjust luna68k and news68k to use them.
 1.2 01-Feb-2025  andvar s/Futhermore/Furthermore/ in comment.
 1.1 27-Dec-2023  thorpej branches: 1.1.2;
Add a header file for 68030-specific MMU definitions, specifically the
Transparent Translation registers, that do not exist on the 68851. A
big comment at the top of the file describes the differences between
the 68851 and the 68030's MMU.
 1.1.2.1 02-Aug-2025  perseant Sync with HEAD
 1.4 08-Jul-2025  thorpej Add common '030 and '040/'060 routines for configuring the transparent
translation registers. Adjust luna68k and news68k to use them.
 1.3 09-Feb-2024  andvar branches: 1.3.2;
fix spelling mistakes, mainly in comments and log messages.
 1.2 09-Jan-2024  thorpej Remove duplicated / slightly-tweaked loadustp() (load user segment table)
routines from all of the m68k ports using the shared pmap. Instead, in
pmap_init(), set up a function pointer to the appropriate mmu_load_urp*()
function in mmu_subr.s.
 1.1 27-Dec-2023  thorpej Add new headers that describe the 68851 (and 68030) MMU and
68040 (and 68060) MMU structures using names that more closely
align with Motorola's documentation.

The definitions here automagically adapt to 4K or 8K pages, based
on the value of PGSHIFT, which must be a compile-time constant.
 1.3.2.1 02-Aug-2025  perseant Sync with HEAD
 1.4 08-Feb-2024  andvar s/sharable/shareable in comments and documentation.
 1.3 09-Jan-2024  thorpej Statically-initialize the '851 / '030 protorp with MMU51_SRP_BITS. In
pmap_init(), re-initialize protorp with MMU51_CRP_BITS. Remove the now-
redundant code that does this in each of the m68k platforms.
 1.2 09-Jan-2024  thorpej Remove duplicated / slightly-tweaked loadustp() (load user segment table)
routines from all of the m68k ports using the shared pmap. Instead, in
pmap_init(), set up a function pointer to the appropriate mmu_load_urp*()
function in mmu_subr.s.
 1.1 27-Dec-2023  thorpej Add new headers that describe the 68851 (and 68030) MMU and
68040 (and 68060) MMU structures using names that more closely
align with Motorola's documentation.

The definitions here automagically adapt to 4K or 8K pages, based
on the value of PGSHIFT, which must be a compile-time constant.
 1.13 12-Jul-2023  riastradh machine/mutex.h: Sprinkle sys/types.h, omit machine/lock.h.

Turns out machine/lock.h is not needed for __cpu_simple_lock_t, which
always comes from sys/types.h. And, really, sys/types.h (or at least
sys/stdint.h) is needed for uintN_t and uintptr_t.
 1.12 09-Jul-2023  riastradh machine/mutex.h: Sprinkle includes so this can be used by crash(8).

XXX pullup-10
 1.11 25-Aug-2021  thorpej branches: 1.11.4;
- In kern_mutex.c, if MUTEX_CAS() is not defined, define it in terms of
atomic_cas_ulong().
- For arm, ia64, m68k, mips, or1k, riscv, vax: don't define our own
MUTEX_CAS(), as they either use atomic_cas_ulong() or equivalent
(atomic_cas_uint() on m68k).
- For alpha and sparc64, don't define MUTEX_CAS() in terms of their own
_lock_cas(), which has its own memory barriers; the call sites in
kern_mutex.c already have the appropriate memory barrier calls. Thus,
alpha and sparc64 can use default definition.
- For sh3, don't define MUTEX_CAS() in terms of its own _lock_cas();
atomic_cas_ulong() is strong-aliased to _lock_cas(), therefore defining
our own MUTEX_CAS() is redundant.

Per thread:
https://mail-index.netbsd.org/tech-kern/2021/07/25/msg027562.html
 1.10 08-Mar-2020  rin Remove mutex stubs for 68010 that merely fall back to C codes, and
do not work with kern_mutex.c rev 1.85 and later:

http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/kern/kern_mutex.c#rev1.85
http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/kern/kern_mutex.c#rev1.86

Fix sun2 kernel freeze during early boot stage in mutex_exit(9).
 1.9 29-Nov-2019  riastradh Nix now-unused definitions of MUTEX_GIVE/MUTEX_RECEIVE.
 1.8 29-Nov-2019  riastradh Nix mb_* on m68k.
 1.7 28-Apr-2008  martin branches: 1.7.88;
Remove clause 3 and 4 from TNF licenses
 1.6 05-Apr-2008  tsutsui branches: 1.6.2; 1.6.4;
Use generic atomic_cas_uint() for mutex(9) and rwlock(9), and
remodel old RAS based _lock_cas() implementation for m68010
into genereic atomic_cas_32().
Now sun2 kernel compiles and even works on multiuser. (hehe)

Tested on tme (emulationg 2/120 and 3/150) and (real) 3/80.
 1.5 21-Nov-2007  yamt branches: 1.5.14;
make kmutex_t and krwlock_t smaller by killing lock id.
ok'ed by Andrew Doran.
 1.4 11-Mar-2007  thorpej branches: 1.4.16; 1.4.18; 1.4.22; 1.4.24;
- Shrink ipl_cookie_t from 32-bits to 16-bits (large enough to hold
an SR value or an IPL_* constant).
- Take advange of the smaller ipl_cookie_t to shrink kmutex_t from
16 bytes to 8 bytes by overlapping storage where possible.
- Implement a RAS-based _lock_cas() for mc68010 systems (Sun2). See
sun68k/sun68k/isr.c.

Tested on various m68k platforms, but NOT Sun2. In any case, at least
Sun2 compiles now.
 1.3 15-Feb-2007  mhitch branches: 1.3.2; 1.3.4; 1.3.8;
Add lock stubs for m68k. Amiga builds and runs now.
 1.2 09-Feb-2007  ad Merge newlock2 to head.
 1.1 06-Feb-2007  ad branches: 1.1.2;
file mutex.h was initially added on branch newlock2.
 1.1.2.1 06-Feb-2007  ad Make amiga & mac68k compile.
 1.3.8.2 03-Dec-2007  ad Sync with HEAD.
 1.3.8.1 13-Mar-2007  ad Sync with head.
 1.3.4.4 07-Dec-2007  yamt sync with head
 1.3.4.3 03-Sep-2007  yamt sync with head.
 1.3.4.2 26-Feb-2007  yamt sync with head.
 1.3.4.1 15-Feb-2007  yamt file mutex.h was added on branch yamt-lazymbuf on 2007-02-26 09:07:11 +0000
 1.3.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.4.24.1 08-Dec-2007  mjf Sync with HEAD.
 1.4.22.1 21-Nov-2007  bouyer Sync with HEAD
 1.4.18.1 09-Jan-2008  matt sync with HEAD
 1.4.16.1 21-Nov-2007  joerg Sync with HEAD.
 1.5.14.1 02-Jun-2008  mjf Sync with HEAD.
 1.6.4.1 16-May-2008  yamt sync with head.
 1.6.2.1 18-May-2008  yamt sync with head.
 1.7.88.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.11.4.1 09-Aug-2023  martin Pull up following revision(s) (requested by maya in ticket #316):

sys/arch/m68k/include/mutex.h: revision 1.13
sys/arch/arm/include/cpu.h: revision 1.125
sys/arch/sun68k/include/intr.h: revision 1.21
sys/arch/arm/include/mutex.h: revision 1.28
sys/sys/rwlock.h: revision 1.18
sys/arch/powerpc/include/mutex.h: revision 1.7
sys/arch/arm/include/mutex.h: revision 1.29
sys/arch/powerpc/include/mutex.h: revision 1.8
sys/uvm/uvm_param.h: revision 1.42
sys/sys/ksem.h: revision 1.16
sys/arch/x86/include/mutex.h: revision 1.10
sys/sys/proc.h: revision 1.372
sys/sys/ksem.h: revision 1.17
sys/arch/ia64/include/mutex.h: revision 1.8
sys/arch/evbarm/include/intr.h: revision 1.29
sys/sys/lua.h: revision 1.9
sys/arch/next68k/include/intr.h: revision 1.23
sys/arch/ia64/include/mutex.h: revision 1.9
sys/arch/hp300/include/intr.h: revision 1.35
sys/arch/hp300/include/intr.h: revision 1.36
sys/arch/sparc/include/cpu.h: revision 1.111
sys/arch/hppa/include/mutex.h: revision 1.16
sys/arch/vax/include/intr.h: revision 1.31
sys/arch/hppa/include/mutex.h: revision 1.17
sys/arch/news68k/include/intr.h: revision 1.28
sys/arch/hppa/include/mutex.h: revision 1.18
sys/arch/hppa/include/intr.h: revision 1.3
sys/arch/hppa/include/mutex.h: revision 1.19
sys/arch/hppa/include/intr.h: revision 1.4
sys/sys/sched.h: revision 1.92
sys/opencrypto/cryptodev.h: revision 1.51
sys/arch/vax/include/mutex.h: revision 1.20
sys/arch/sparc64/include/mutex.h: revision 1.10
sys/arch/ia64/include/sapicvar.h: revision 1.2
sys/arch/riscv/include/mutex.h: revision 1.5
sys/arch/amiga/dev/grfabs_cc.c: revision 1.39
sys/external/bsd/drm2/include/linux/idr.h: revision 1.11
sys/arch/riscv/include/mutex.h: revision 1.6
sys/ddb/files.ddb: revision 1.16
sys/arch/mac68k/include/intr.h: revision 1.32
share/man/man4/ddb.4: revision 1.203
sys/ddb/db_command.c: revision 1.183
sys/arch/mips/include/mutex.h: revision 1.10
sys/ddb/db_command.c: revision 1.184
sys/arch/x68k/include/intr.h: revision 1.22
sys/arch/sparc/include/psl.h: revision 1.51
sys/arch/or1k/include/mutex.h: revision 1.4
sys/arch/mips/include/mutex.h: revision 1.11
sys/arch/arm/xscale/pxa2x0_intr.h: revision 1.16
sys/arch/sparc64/include/cpu.h: revision 1.134
sys/arch/sparc/include/psl.h: revision 1.52
sys/arch/or1k/include/mutex.h: revision 1.5
sys/arch/mvme68k/include/intr.h: revision 1.22
sys/arch/luna68k/include/intr.h: revision 1.16
external/cddl/osnet/sys/sys/kcondvar.h: revision 1.6
sys/arch/sparc/include/mutex.h: revision 1.12
sys/arch/sparc/include/mutex.h: revision 1.13
sys/arch/usermode/include/mutex.h: revision 1.5
sys/arch/usermode/include/mutex.h: revision 1.6
sys/kern/kern_core.c: revision 1.38
usr.sbin/crash/Makefile: revision 1.49
sys/arch/amiga/include/intr.h: revision 1.23
sys/arch/alpha/include/mutex.h: revision 1.12
sys/arch/alpha/include/mutex.h: revision 1.13
sys/arch/evbarm/lubbock/sacc_obio.c: revision 1.16
sys/ddb/ddb.h: revision 1.6
sys/arch/sparc64/include/mutex.h: revision 1.8
sys/arch/sh3/include/mutex.h: revision 1.12
sys/arch/evbarm/lubbock/sacc_obio.c: revision 1.17
sys/ddb/db_syncobj.c: revision 1.1
sys/arch/vax/include/mutex.h: revision 1.18
sys/arch/sparc64/include/psl.h: revision 1.63
sys/arch/sparc64/include/mutex.h: revision 1.9
sys/arch/sh3/include/mutex.h: revision 1.13
sys/arch/evbarm/lubbock/obio.c: revision 1.13
sys/arch/atari/include/intr.h: revision 1.23
sys/ddb/db_syncobj.c: revision 1.2
sys/arch/vax/include/mutex.h: revision 1.19
sys/arch/evbarm/g42xxeb/obio.c: revision 1.14
sys/arch/evbarm/g42xxeb/obio.c: revision 1.15
sys/arch/cesfic/include/intr.h: revision 1.14
sys/ddb/db_syncobj.h: revision 1.1
sys/arch/x86/include/cpu.h: revision 1.134
sys/arch/evbarm/g42xxeb/obio.c: revision 1.16
sys/arch/cesfic/include/intr.h: revision 1.15
sys/arch/arm/xscale/pxa2x0_intr.c: revision 1.26
sys/sys/cpu_data.h: revision 1.54
sys/arch/m68k/include/mutex.h: revision 1.12
sys/arch/ia64/acpi/madt.c: revision 1.6

sys/rwlock.h: Make this more self-contained for bool.

machine/mutex.h: Sprinkle includes so this can be used by crash(8).

ddb: New `show all tstiles' command.
Shows who's waiting for which locks and what the owner is up to.

Include psl.h for ipl_cookie_t if __MUTEX_PRIVATE

sys: Rip <sys/resourcevar.h> out of <uvm/uvm_param.h>.

And thus out of <sys/param.h>, which is exceedingly overused and
fragile and delenda est.

Should fix (some) issues with the recent inclusion of machine/lock.h
in various machine/mutex.h files.

arm/mutex.h: Need machine/intr.h, machine/lock.h.

For ipl_cookie_t and __cpu_simple_lock_t.
evbarm/intr.h: Define ipl_cookie_t before including ARM_INTR_IMPL.

Otherwise arm/mutex.h doesn't work, due to a cyclic dependency which
should really be fixed.
opencrypto/cryptodev.h: Fix includes.
- Move sys/condvar.h under #ifdef _KERNEL.
- Add some other necessary includes and forward declarations.
- Sort.

hp300/intr.h: Fix missing includes.
linux/idr.h: Need <sys/mutex.h> for kmutex_t.
amiga/intr.h: Don't define spl*() functions if !_KERNEL.

This is used by crash(8) now, and what's important is ipl_cookie_t.
cesfic/intr.h: Expose ipl_cookie_t to userland for crash(8).
cesfic/intr.h: Expose ipl_cookie_t to userland only with _KMEMUSER.

Probably not necessary but let's be a little more cautious about
this.

atari/intr.h: Expose ipl_cookie_t with _KMEMUSER for crash(8).

arm/cpu.h: Need sys/param.h for COHERENCY_UNIT.

Nix machine/param.h -- not meant to be used directly, pulled in by
sys/param.h.

Move the definition of ipl_cookie_t out of the kernel-only sections,
some _KMEMUSER applications need it.

ddb: Cast pointer to uintptr_t first before db_expr_t.

hppa/intr.h: Expose ipl_cookie_t to _KMEMUSER for crash(8).

luna68k/intr.h: Expose ipl_cookie_t to _KMEMUSER for crash(8).

mvme68k/intr.h: Expose ipl_cookie_t to _KMEMUSER for crash(8).

news68k/intr.h: Fix includes. Put some definitions under _KERNEL.

next68k/intr.h: Expose ipl_cookie_t to _KMEMUSER for crash(8).

sys/ksem.h: Hack around fstat(8) abuse of _KERNEL.

sun68k/intr.h: Expose ipl_cookie_t to _KMEMUSER for crash(8).

vax/intr.h: Expose ipl_cookie_t to _KMEMUSER for crash(8).

x68k/intr.h: Put functions under _KERNEL so crash(8) can use this.

Make ipl_cookie_t visible for _KMEMUSER userland applications.

fix editor mishap in previous

Explicitly include <sys/mutex.h> for kmutex_t.

Replace kmutex_t * (which may be undefined here) with struct kmutex *,
suggested by Taylor.

hp300/intr.h: Put most of this under #ifdef _KERNEL.
Only ipl_cookie_t really needs to be exposed now, for crash(8).

mac68k/intr.h: Expose ipl_cookie_t to _KMEMUSER for crash(8).
Make inclusion of sys/intr.h explicit for spl*.

fix hppa and vax builds.

machine/lock.h isn't necessary for __cpu_simple_lock_t, it's in
sys/types.h. avoids cpu_data.h vs sched.h include order issues.

move the hppa ipl_t typedef with the moved usage of it.
machine/mutex.h: Sprinkle sys/types.h, omit machine/lock.h.

Turns out machine/lock.h is not needed for __cpu_simple_lock_t, which
always comes from sys/types.h. And, really, sys/types.h (or at least
sys/stdint.h) is needed for uintN_t and uintptr_t.

ddb: Cast pointer to uintptr_t, then to db_expr_t.
Avoids warnings about conversion between pointer and integer of
different size on some architectures.

re-fix hppa builds.

this file uses __cpu_simple_lock(), not just the underlying type,
so it does need machine/lock.h.

Break cycle by using `struct kmutex *' instead of `kmutex_t *'.
sys/sched.h included sys/mutex.h
which includes sys/intr.h
which includes machine/intr.h
which on cats includes arm/footbridge/footbridge_intr.h
which includes arm/cpu.h
which includes sys/cpu_data.h
which includes sys/sched.h

But there was never any real need for sys/mutex.h in sys/sched.h,
because it only uses pointers to the opaque struct kmutex. Cycle
broken by using `struct kmutex *' instead of pulling in sys/mutex.h
for the definition of kmutex_t.

Side effect: This revealed that sys/cpu_data.h needed sys/intr.h
(which was pulled in accidentally by sys/mutex.h via sys/sched.h) for
SOFTINT_COUNT. Also revealed some other machine/cpu.h header files
were missing includes of sys/mutex.h for kmutex_t.

ia64: Need sys/types.h for u_int, vaddr_t; sys/mutex.h for kmutex_t.

explicitly include no longer implicitly included sys/mutex.h.

arm/xscale: Use sys/bitops.h fls32 - 1 instead of 31 - __builtin_clz.
Sidesteps namespace collision with `#define bits ...' in net/zlib.c.

complete the previous - there were two calls to find_first_bit() to fix.

arm/xscale: Missed a spot with previous find_first_bit commit.

evbarm/g42xxeb: Fix off-by-one in previous.

The original find_first_bit(x) was 31 - __builtin_clz((uint32_t)x),
which is equivalent to fls32(x) - 1, not to fls32(x).

Note that fls32 is 1-based and returns 0 for x=0.
 1.24 31-May-2021  simonb Include "opt_param.h" (ifdef _KERNEL_OPT) everywhere that MSGBUFSIZE is
referenced since some sources include <machine/param.h>.
 1.23 01-May-2020  isaki branches: 1.23.6;
Move machine dependent AUDIO_BLK_MS default value to <machine/param.h>.
If the port has __AUDIO_BLK_MS in <machine/param.h>, it will be used.
Otherwise the default value (currently 10 msec) defined in audio.c will
be used. This mechanism is for very old ports which cannot satisfactorily
handle 10 msec block. Currently hppa, m68k, sh3, sparc(!64) and vax are.

For port maintainers, if general models in your port cannot satisfactorily
handle 10 msec block, please consider to define your suitable longer period
(40 msec would be a good first choice).
But please don't be eager to make the default value shorter.

<machine/param.h> was discussed in source-changes-d. It's better than
ifdef storm, or adding 60+ new header files in every arch/*/include/
directories for this. Thanks mrg@, ad@, and everyone.
http://mail-index.netbsd.org/source-changes-d/2020/05/01/msg012572.html
 1.22 07-Jan-2019  jdolecek branches: 1.22.4;
move DEV_BSIZE, DEV_BSHIFT out of MD param.h, they are same on all ports

also move BLKDEV_IOSIZE, MAXPHYS, but allow override since some ports
have different value (powerpc uses NBPG for BLKDEV_IOSIZE, sun2/sun3
have lower MAXPHYS)
 1.21 24-Jan-2012  christos branches: 1.21.46; 1.21.48;
Use and define ALIGN() ALIGN_POINTER() and STACK_ALIGN() consistently,
and avoid definining them in 10 different places if not needed.
 1.20 20-Jan-2012  joerg Change CMSG_SPACE and CMSG_LEN to provide Integer Constant Expressions
again. This was changed in sys/socket.h r1.51 to work around fallout
from the IPv6 aux data migration. It broke the historic ABI on some
platforms. This commit restores compatibility for netbsd32 code on such
platforms and provides a template for future changes to the CMSG_*
alignment. Revert PCC/Clang workarounds in postfix and tmux.
 1.19 05-Mar-2011  matt branches: 1.19.4; 1.19.8;
If _KERNEL is not defined, force MACHINE to be "m68k". Userland should be
using uname/sysctl to get this value.
 1.18 08-Feb-2011  rmind Remove clause 3 (UCB advertising clause) from the University of Utah
copyright. Confirmed by Mike Hibler, mike at cs.utah.edu - thanks!
Also, merge UCB and Utah copyright texts back into one, as they
originally were.

Extra verification by snj@.
 1.17 08-Feb-2010  joerg branches: 1.17.2; 1.17.4; 1.17.6;
Remove separate mb_map. The nmbclusters is computed at boot time based
on the amount of physical memory and limited by NMBCLUSTERS if present.
Architectures without direct mapping also limit it based on the kmem_map
size, which is used as backing store. On i386 and ARM, the maximum KVA
used for mbuf clusters is limited to 64MB by default.

The old default limits and limits based on GATEWAY have been removed.
key_registered_sb_max is hard-wired to a value derived from 2048
clusters.
 1.16 11-Dec-2009  tsutsui branches: 1.16.2;
Refactoring MD segment related definitions on m68k ports:
- move macro SEGSHIFT, NBSEG, and SEGOFSET from <machine/param.h>
to <m68k/pmap_motorola.h> where they should belong
- also simplify NBSEG macro for both 020/030 and 040/060 cases
- also move m68k_trunc_seg(), m68k_round_seg(), and m68k_seg_offset()
(that use SEGOFSET) from <m68k/param.h> to <m68k/pmap_motorola.h>
- add comments about each segment size value used on pmap_motorola
implementation
- add TIA_SIZE, TIA_SHIFT, TIB_SIZE, and TIB_SHIFT macro which can be
used for ste/pte index sizes
- use proper vaddr_t cast instead of unsigned for SEGOFSET/PGOFSET macro

Tested on atari, hp300, and news68k.
 1.15 28-Aug-2006  yamt branches: 1.15.60;
- remove unused bdbtofsb.
- move the following macros from MD headers to sys/param.h.
ctod
dtoc
ctob
btoc
dbtob
btodb
 1.14 11-Dec-2005  christos branches: 1.14.4; 1.14.8;
merge ktrace-lwp.
 1.13 30-Oct-2003  mycroft branches: 1.13.16;
Allow a port to override MAXPHYS.
 1.12 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.11 26-Feb-2002  simonb branches: 1.11.16;
Purge CLSIZE, CLSIZELOG2 and MCLOFSET.
Be consistant in the way that MSIZE, MCLSHIFT, MCLBYTES and NMBCLUSTERS
are defined.
Remove old VM constants from cesfic port.
Bump MSIZE to 256 on mipsco (the only one that wasn't already 256).
 1.10 30-May-2001  mrg branches: 1.10.2; 1.10.8;
use _KERNEL_OPT
 1.9 03-May-2001  fredette Now only define MACHINE_ARCH, _MACHINE_ARCH, and
MID_MACHINE if they haven't already been defined.
 1.8 30-Jun-2000  itojun branches: 1.8.2;
raise MSIZE from 128 to 256.
- for sizeof(void *) == 8 arch, this is mandatory. MHLEN is too small
already (less than 80) and there are chances for unwanted packet loss due
to m_pullup restriction.
- for other cases, the change should avoid allocating clusters in most cases
(even when you have IPv4 IPsec tunnel, or IPv6 with moderate amount of
extension header)

portmasters: if your arch chokes with the change (high memory usage or
whatever), please backout the change for your arch.
 1.7 12-Dec-1999  scottr branches: 1.7.4;
Add m68k_seg_offset() and m68k_page_offset() to complement m68k_trunc_seg()
m68k_trunc_page(), respectively. Motivated primarily by a desire for
code clarity and symmetry.
 1.6 04-Dec-1999  ragge CL* discarding.
 1.5 29-Apr-1998  thorpej branches: 1.5.14; 1.5.20;
Pull in opt_gateway.h as appropriate.
 1.4 20-Sep-1997  leo Move the definition of MSGBUFSIZE up to the machine-arch level if
possible. Pointed out by Bernd Ernesti.
 1.3 10-Jul-1997  veego branches: 1.3.2;
Move the defines of UPAGES and NPTEPG back to the MD param.h, execpt that
the sun3[x] doesn't use NPTEPG.
 1.2 10-Jun-1997  veego Add the 'Mach derived conversion macros' from <arch>/include/param.h.
 1.1 10-Jun-1997  veego New MI include file. Based on the param.h from all m68k ports.
 1.3.2.1 22-Sep-1997  thorpej Update marc-pcmcia branch from trunk.
 1.5.20.2 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.5.20.1 21-Dec-1999  wrstuden Initial commit of recent changes to make DEV_BSIZE go away.

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

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

Non 2**n block support is automatic for LKM's and conditional for kernels
on "options NON_PO2_BLOCKS".
 1.5.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.7.4.1 23-Jul-2000  itojun pullup from main trunc (approved by releng-1-5)

raise MSIZE from 128 to 256.
- for sizeof(void *) == 8 arch, this is mandatory. MHLEN is too small
already (less than 80) and there are chances for unwanted packet loss due
to m_pullup restriction.
- for other cases, the change should avoid allocating clusters in most cases
(even when you have IPv4 IPsec tunnel, or IPv6 with moderate amount of
extension header)

portmasters: if your arch chokes with the change (high memory usage or
whatever), please backout the change for your arch.

1.1 -> 1.2 syssrc/sys/arch/amigappc/include/param.h
1.13 -> 1.14 syssrc/sys/arch/arc/include/param.h
1.1 -> 1.2 syssrc/sys/arch/arm26/include/param.h
1.17 -> 1.18 syssrc/sys/arch/arm32/include/param.h
1.6 -> 1.7 syssrc/sys/arch/bebox/include/param.h
1.4 -> 1.5 syssrc/sys/arch/cobalt/include/param.h
1.4 -> 1.5 syssrc/sys/arch/evbsh3/include/param.h
1.2 -> 1.3 syssrc/sys/arch/hpcmips/include/param.h
1.40 -> 1.41 syssrc/sys/arch/i386/include/param.h
1.7 -> 1.8 syssrc/sys/arch/m68k/include/param.h
1.9 -> 1.10 syssrc/sys/arch/macppc/include/param.h
1.4 -> 1.5 syssrc/sys/arch/mmeye/include/param.h
1.6 -> 1.7 syssrc/sys/arch/newsmips/include/param.h
1.7 -> 1.8 syssrc/sys/arch/ofppc/include/param.h
1.23 -> 1.24 syssrc/sys/arch/pc532/include/param.h
1.32 -> 1.33 syssrc/sys/arch/pmax/include/param.h
1.7 -> 1.8 syssrc/sys/arch/powerpc/include/param.h
1.1 -> 1.2 syssrc/sys/arch/prep/include/param.h
1.1 -> 1.2 syssrc/sys/arch/sgimips/include/param.h
1.3 -> 1.4 syssrc/sys/arch/sh3/include/param.h
1.44 -> 1.45 syssrc/sys/arch/sparc/include/param.h
1.21 -> 1.22 syssrc/sys/arch/sparc64/include/param.h
1.43 -> 1.44 syssrc/sys/arch/vax/include/param.h
 1.8.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.10.8.2 28-Feb-2002  nathanw Catch up to -current.
 1.10.8.1 30-May-2001  nathanw file param.h was added on branch nathanw_sa on 2002-02-28 04:10:34 +0000
 1.10.2.1 16-Mar-2002  jdolecek Catch up with -current.
 1.11.16.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.11.16.2 18-Sep-2004  skrll Sync with HEAD.
 1.11.16.1 03-Aug-2004  skrll Sync with HEAD
 1.13.16.1 30-Dec-2006  yamt sync with head.
 1.14.8.1 03-Sep-2006  yamt sync with head.
 1.14.4.1 09-Sep-2006  rpaulo sync with head
 1.15.60.1 11-Mar-2010  yamt sync with head
 1.16.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.17.6.1 17-Feb-2011  bouyer Sync with HEAD
 1.17.4.1 06-Jun-2011  jruoho Sync with HEAD.
 1.17.2.2 06-Mar-2011  rmind sync with head (and fix few botches with this)
 1.17.2.1 05-Mar-2011  rmind sync with head
 1.19.8.1 18-Feb-2012  mrg merge to -current.
 1.19.4.1 17-Apr-2012  yamt sync with head
 1.21.48.1 10-Jun-2019  christos Sync with HEAD
 1.21.46.1 18-Jan-2019  pgoyette Synch with HEAD
 1.22.4.1 18-May-2020  martin Pull up following revision(s) (requested by isaki in ticket #911):

sys/dev/audio/audiodef.h: revision 1.13
sys/dev/audio/audiodef.h: revision 1.14
sys/arch/sparc/include/param.h: revision 1.74
sys/arch/evbarm/conf/GENERIC64: revision 1.148
sys/arch/sh3/include/param.h: revision 1.25
sys/arch/evbarm/conf/GENERIC: revision 1.75
sys/arch/m68k/include/param.h: revision 1.23
sys/arch/amd64/conf/GENERIC: revision 1.564
sys/arch/hppa/include/param.h: revision 1.27
sys/dev/audio/audio.c: revision 1.68
sys/arch/vax/include/param.h: revision 1.63
sys/dev/audio/audio.c: revision 1.69

Reduce default AUDIO_BLK_MS from 40msec to 10msec on all platform except m68k
(m68k uses 40msec default as before). And remove the option from GENERIC.

- It's not good idea to set such parameter in individual GENERICs.
- 4msec is (probably no problem for most modern real hardware but)
too aggressive to be default.
- 10msec is too severe for antique machines but it's hard to draw a line.

Set AUDIO_BLK_MS 40 msec on other old(slow) architectures not only m68k.

Thanks tsutsui@ for comment about architecture choice.
And move it from audiodef.h to audio.c as suggested by joerg@.


Move machine dependent AUDIO_BLK_MS default value to <machine/param.h>.
If the port has __AUDIO_BLK_MS in <machine/param.h>, it will be used.

Otherwise the default value (currently 10 msec) defined in audio.c will
be used. This mechanism is for very old ports which cannot satisfactorily
handle 10 msec block. Currently hppa, m68k, sh3, sparc(!64) and vax are.

For port maintainers, if general models in your port cannot satisfactorily
handle 10 msec block, please consider to define your suitable longer period
(40 msec would be a good first choice).

But please don't be eager to make the default value shorter.
<machine/param.h> was discussed in source-changes-d. It's better than
ifdef storm, or adding 60+ new header files in every arch/*/include/
directories for this. Thanks mrg@, ad@, and everyone.
http://mail-index.netbsd.org/source-changes-d/2020/05/01/msg012572.html
 1.23.6.1 17-Jun-2021  thorpej Sync w/ HEAD.
 1.11 26-Sep-2023  tsutsui TAB/space cleanup.
 1.10 08-Feb-2011  rmind Remove clause 3 (UCB advertising clause) from the University of Utah
copyright. Confirmed by Mike Hibler, mike at cs.utah.edu - thanks!
Also, merge UCB and Utah copyright texts back into one, as they
originally were.

Extra verification by snj@.
 1.9 14-Jan-2011  rmind branches: 1.9.2; 1.9.4;
Retire struct user, remove sys/user.h inclusions. Note sys/user.h header
as obsolete. Remove USER_TO_UAREA/UAREA_TO_USER macros.

Various #include fixes and review by matt@.
 1.8 02-Dec-2009  tsutsui branches: 1.8.4;
Add a common pmap_bootstrap_finalize() function which initializes
lwp0 uarea, curlwp, and curpcb after MMU is turned on, using
lwp0uarea variable saved during pmap_bootstrap() (or equivalent functions)
for pmap_motorola based ports. Discussed with rmind@.
 1.7 04-Mar-2007  christos branches: 1.7.44;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.6 11-Dec-2005  christos branches: 1.6.26;
merge ktrace-lwp.
 1.5 07-Aug-2003  agc branches: 1.5.16;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.4 10-Aug-2000  scw branches: 1.4.24;
Add a `/t' modifier to the m68k ddb's `trace' command. This enables
one to perform a kernel traceback of any (non-swapped-out) process in
the system. For example, to show the traceback for PID 178:

db> t/t 0t178
trace: pid 178 at 0xabcd68
_mi_switch(0x109f60) + 164
...
db>
 1.3 03-Nov-1999  he Provide multiple inclusion protection.
 1.2 06-Jan-1998  thorpej branches: 1.2.14; 1.2.16; 1.2.18;
The user segment table pointer is no longer kept here. Change it to
a spare field.
 1.1 31-Mar-1997  gwr Need a common <m68k/pcb.h> for gdb.
 1.2.18.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.2.16.1 15-Nov-1999  fvdl Sync with -current
 1.2.14.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.4.24.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.4.24.2 18-Sep-2004  skrll Sync with HEAD.
 1.4.24.1 03-Aug-2004  skrll Sync with HEAD
 1.5.16.1 03-Sep-2007  yamt sync with head.
 1.6.26.1 12-Mar-2007  rmind Sync with HEAD.
 1.7.44.1 11-Mar-2010  yamt sync with head
 1.8.4.1 05-Mar-2011  rmind sync with head
 1.9.4.1 17-Feb-2011  bouyer Sync with HEAD
 1.9.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.6 28-Sep-2023  skrll whitespace nit
 1.5 28-Sep-2023  skrll #define<space> -> #define<tab> for consistency
 1.4 20-Dec-2020  skrll Support __HAVE_PMAP_PV_TRACK in sys/uvm/pmap based pmaps (aka common pmap)
 1.3 07-Aug-2020  skrll branches: 1.3.2;
Provide a pmap_segtab_deactivate for symmetry with pmap_segtab_activate
and use it in pmap_deactivate

Call pmap_md_xtab_{,de}activate from pmap_segtab_{,de}activate to be used
for PMAP_HWPAGEWALKER and any caches ops that might be required.

Provide empty (for now) pmap_md_xtab_{,de}activate functions on the
platforms that use sys/uvm/pmap
 1.2 18-Mar-2014  riastradh branches: 1.2.4; 1.2.8;
Merge riastradh-drm2 to HEAD.
 1.1 18-Jul-2013  matt branches: 1.1.2; 1.1.4;
pte and pmap files for the soft tlb on coldfire cpus.
(uncompiled and mostly probably wrong.)
 1.1.4.2 28-Aug-2013  rmind sync with head
 1.1.4.1 18-Jul-2013  rmind file pmap_coldfire.h was added on branch rmind-smpnet on 2013-08-28 23:59:18 +0000
 1.1.2.2 23-Jul-2013  riastradh sync with HEAD
 1.1.2.1 18-Jul-2013  riastradh file pmap_coldfire.h was added on branch riastradh-drm2 on 2013-07-23 21:07:34 +0000
 1.2.8.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.2.8.1 18-Mar-2014  tls file pmap_coldfire.h was added on branch tls-maxphys on 2014-08-20 00:03:10 +0000
 1.2.4.2 22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.2.4.1 18-Mar-2014  yamt file pmap_coldfire.h was added on branch yamt-pagecache on 2014-05-22 11:39:55 +0000
 1.3.2.1 03-Jan-2021  thorpej Sync w/ HEAD.
 1.43 31-Dec-2023  thorpej Provide a vtophys() function like other platforms do, and implement
kvtop() (which will be g/c'd shortly) in terms of it.
 1.42 27-Dec-2023  thorpej Stop using magic numbers for the MMU root pointer attributes and the
Translation Control register, and also get rid of "#if PGSHIFT == ..."
where those magic numbers are used.

Instead, define new macros: MMU51_SRP_BITS, MMU51_CRP_BITS, MMU51_TCR_BITS,
and MMU40_TCR_BITS, in terms of the definitions in mmu_{40,51}.h. These
automagically adapt to 8K and 4K pages based on the machine-specific value
of PGSHIFT.
 1.41 26-Dec-2023  thorpej Move active_pmap() and active_user_pmap() macros into pmap_motorola.c
 1.40 26-Dec-2023  thorpej - G/C the PMAP_ACTIVATE() macro, just call loadustp() directly.
- In pmap_activate(), rather than checking for an idle LWP and skipping
the loadustp() in that case, just check if the pmap being activate is
the kernel pmap. Also, KASSERT() that the specified lwp is the current
lwp.
 1.39 25-Dec-2023  thorpej loadustp(): Optimize for the overwhelmingly common case of "not the HP MMU".
Rather than converting the level 1 table address to a page number before
calling loadustp() only to have loadustp() convert it back to an address
for the '851, '030, '040, and '060, instead pass the address and convert
to a page number only in the case of the HP MMU.

This is a wash on HP MMU machines (9000/320 and 9000/350), and saves at
least 4 instructions (2x moveq + 2x lsXl) on every context switch on
everything else.
 1.38 26-Sep-2023  tsutsui Remove trailing spaces and TABs.
 1.37 19-Sep-2021  andvar fix various typos in comments, messages and documentation.
 1.36 14-Mar-2020  ad pmap_remove_all(): Return a boolean value to indicate the behaviour. If
true, all mappings have been removed, the pmap is totally cleared out, and
UVM can then avoid doing the work to call pmap_remove() for each map entry.
If false, either nothing has been done, or some helpful arch-specific voodoo
has taken place.
 1.35 01-Feb-2020  tsutsui Use "__nothing" macro defined in <sys/cdefs.h> for empty pmap_update().

Suggested by pgoyette@ in PR/54869.
 1.34 29-Oct-2011  tsutsui branches: 1.34.54; 1.34.60;
Use pool(9) for struct pv_entry allocations rather than
uvm_km_alloc(9)/uvm_km_free(9) and ancient homegrown pv_page_info structures.

Calling uvm_km_free(9) during pmap_remove(9) could cause rw_lock error
in uvm_unmap1() as noted in PR port-m68k/45519.

NetBSD/x68k (both real X68030 and XM6i emulator) still gets weird panic
(corrupted kernel stack pointer?) on some heavy load:
---
panic: MMU fault
Stopped in pid 363.1 (X68k) at netbsd:cpu_Debugger+0x6: unlk a6
db> tr
cpu_Debugger(4012004,8,1cbb528,2a618e0,2a5b000) + 6
db>
---
but it also occurs without this change so there might be some more bugs
in m68k pmap...
 1.33 03-Jun-2011  tsutsui - remove simple_lock(9) and use atomic_ops(3) to account pmap reference count,
perrequest from rmind@
- while here no need to export struct pmap on sun2/sun3/sun3x

No particular problem for a week on hp300 and sun3x kernels with disabled
tcp_vtw which has been broken for a month on low memory machines.
 1.32 06-Jan-2011  tsutsui branches: 1.32.2; 1.32.6;
Use #ifdef CACHE_HAVE_VAC rather than #ifdef M68K_MMU_HP where
the pmap code indends.
(though currently only MMU_HP machines have VAC in pmap_motorola ports)
 1.31 02-Jan-2011  tsutsui Make pmap_aliasmask unsigned and declare it in <m68k/pmap_motorola.h>.

XXX: does anyone still have working HP320 or HP350 with 020+HP_MMU+VAC?
 1.30 06-Jun-2010  he Only include opt_m68k_arch.h if _KERNEL_OPT is defined, so that librump
builds again. OK'ed by mrg@.
 1.29 06-Jun-2010  mrg fix PR 6724 - convert m68k options to defflag's. this means that
M680[12346] are now available from opt_m68k_arch.h. FPSP meantioned
in the PR has already been fixed, and i could not find any more.

i built these kernels to ensure i did not break their builds:

amiga: GENERIC DRACO
atari: HADES FALCON MILAN-PCIIDE
mac68k: GENERIC
sun2: GENERIC
sun3: GENERIC GENERIC3X
cesfic: attempted GENERIC, does not build due to lack of machine/bus.h
hp300: GENERIC
luna68k: GENERIC
mvme68k: GENERIC
news68k: GENERIC
next68k: GENERIC
x68k: GENERIC
 1.28 13-Dec-2009  tsutsui branches: 1.28.2; 1.28.4;
- update some comments
- use unsigned constant for shift op
 1.27 11-Dec-2009  tsutsui Define SYSMAP_VA in <m68k/pmap_motorola.h>
where the Sysmap pointer is declared.
 1.26 11-Dec-2009  tsutsui Refactoring MD segment related definitions on m68k ports:
- move macro SEGSHIFT, NBSEG, and SEGOFSET from <machine/param.h>
to <m68k/pmap_motorola.h> where they should belong
- also simplify NBSEG macro for both 020/030 and 040/060 cases
- also move m68k_trunc_seg(), m68k_round_seg(), and m68k_seg_offset()
(that use SEGOFSET) from <m68k/param.h> to <m68k/pmap_motorola.h>
- add comments about each segment size value used on pmap_motorola
implementation
- add TIA_SIZE, TIA_SHIFT, TIB_SIZE, and TIB_SHIFT macro which can be
used for ste/pte index sizes
- use proper vaddr_t cast instead of unsigned for SEGOFSET/PGOFSET macro

Tested on atari, hp300, and news68k.
 1.25 08-Dec-2009  tsutsui Remove unused M68K_SEG_SIZE macro. All sources use NBSEG directly.

XXX: It looks NBSEG definitions in <machine/param.h>
XXX: for all m68k port are incorrect, since 1997 or 2002.
 1.24 06-Dec-2009  tsutsui Move initialization of protection_codes[] and kernel_pmap()
from MD pmap bootstrap sources to common pmap_bootstrap_finalize().

Tested on atari, hp300, mac68k, and news68k.

XXX: Why is protection_codes[] array initialized at run time?
 1.23 06-Dec-2009  tsutsui pm_stfree in struct pmap is a bitmap value so make it unsigned.
 1.22 02-Dec-2009  tsutsui Add a common pmap_bootstrap_finalize() function which initializes
lwp0 uarea, curlwp, and curpcb after MMU is turned on, using
lwp0uarea variable saved during pmap_bootstrap() (or equivalent functions)
for pmap_motorola based ports. Discussed with rmind@.
 1.21 26-Aug-2009  thorpej Minor tweak to the pv_table management in the Hibler-derived m68k pmaps:
The head of the list is now a pv_header, which contains the first pv_entry
as well as a 16-bit attributes field (replaces the pmap_attributes array
plus the pv_entry::pv_flags field) as a 16-bit count of caller-specified
cache-inhibited mappings.

Tested on hp300 (shared pmap_motorola.c), changes to atari and amiga copies
are purely mechanical.
 1.20 17-Jan-2009  tsutsui Move extern decls for Sysseg, Sysptmap, Sysptsize, mem_size, virtual_avail,
virtual_end, and protection_codes[] to common <m68k/pmap_motorola.h>,
and also make protection_codes[] unsigned.

XXX: avail_start and avail_end should also be moved, but it causes
XXX: -Wshadow warnings in uvm/uvm_page.c:uvm_page_physload() and
XXX: I don't have a good idea of alternative names for now.
 1.19 28-Dec-2008  tsutsui Use the global kernel_pmap_ptr pointer in each MD pmap_bootstrap.c
(where MMU is not enabled yet) and make kernel_pmap_store static again.
Also consistently use uintptr_t on address conversion in RELOC() macro.

Tested on hp300 (PA != VA) and news68k (PA == VA).
 1.18 10-Dec-2008  tsutsui Restore kernel_pmap_store declaration since it's still used by
most m68k ports in pmap_bootstrap.c.
 1.17 10-Dec-2008  pooka Make kernel_pmap_ptr a const. Requested by steve_martin.
 1.16 06-Jan-2008  dsl branches: 1.16.6; 1.16.10; 1.16.16; 1.16.18;
include sys/simplelock.h
 1.15 17-Oct-2007  garbled branches: 1.15.2; 1.15.8;
Merge the ppcoea-renovation branch to HEAD.

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

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

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.14 07-Jun-2007  tsutsui branches: 1.14.10;
Enable _pmap_set_page_cacheable(), _pmap_set_page_cacheinhibit() and
_pmap_page_is_cacheable() on all pmap_motorola.c ports and add
BUS_DMA_COHERENT support (from mvme68k) to common m68k bus_dma.c.

Tested with (not-yet-integrated) MI Sonic Ethernet driver on mac68k
http://mail-index.netbsd.org/port-mac68k/2007/06/07/0000.html
and ok'ed by thorpej.
 1.13 12-May-2007  mhitch Changes to enable support of 8K pagesize.
 1.12 05-Mar-2007  tsutsui branches: 1.12.2; 1.12.4; 1.12.10;
Allocate msgbufaddr in pmap_bootstrap.c where it's initilized,
and move its declaration into <m68k/pmap_motorola.h>.
 1.11 04-Mar-2007  tsutsui Move declarations of CADDR1 and CADDR2 from m68k/pmap_motorola.c
to <m68k/pmap_motorola.h>.
 1.10 16-Feb-2006  perry branches: 1.10.20;
Change "inline" back to "__inline" in .h files -- C99 is still too
new, and some apps compile things in C89 mode. C89 keywords stay.

As per core@.
 1.9 24-Dec-2005  perry branches: 1.9.2; 1.9.4; 1.9.6;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.
 1.8 11-Dec-2005  christos merge ktrace-lwp.
 1.7 01-Apr-2005  yamt branches: 1.7.2;
merge yamt-km branch.
- don't use managed mappings/backing objects for wired memory allocations.
save some resources like pv_entry. also fix (most of) PR/27030.
- simplify kernel memory management API.
- simplify pmap bootstrap of some ports.
- some related cleanups.
 1.6 17-Jan-2005  atatat branches: 1.6.2;
Convert the PMAP_PREFER() macro from two arguments (offset and hint)
to four (adding size and direction).

In order for topdown uvm to be an option on ports using PMAP_PREFER,
they will need to "prefer" lower addresses if topdown is being used.
Additionally, at least one port also needs to know the size.
 1.5 28-Aug-2004  thorpej branches: 1.5.4;
De-__P
 1.4 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.3 02-Apr-2003  thorpej branches: 1.3.2;
Use PAGE_SIZE rather than NBPG.
 1.2 05-Nov-2002  chs branches: 1.2.2;
merge pmap.c for all 4k-page motorola-MMU (or compatible) m68k platforms.
 1.1 03-Nov-2002  chs merge pmap.h for all 4k-page motorola-MMU (or compatible) m68k platforms.
 1.2.2.2 11-Nov-2002  nathanw Catch up to -current
 1.2.2.1 05-Nov-2002  nathanw file pmap_motorola.h was added on branch nathanw_sa on 2002-11-11 21:59:38 +0000
 1.3.2.6 01-Apr-2005  skrll Sync with HEAD.
 1.3.2.5 17-Jan-2005  skrll Sync with HEAD.
 1.3.2.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.3.2.3 18-Sep-2004  skrll Sync with HEAD.
 1.3.2.2 03-Sep-2004  skrll Sync with HEAD
 1.3.2.1 03-Aug-2004  skrll Sync with HEAD
 1.5.4.1 29-Apr-2005  kent sync with -current
 1.6.2.1 23-Feb-2005  yamt change mac68k's kernel address space layout in order to simplify
interaction between upper layer of the vm during bootstrap.
- move Sysmap to the end of address space.
- move IOBase etc immediately after proc0 uarea.
- tweak virtual_avail/end accordingly.

tested by Chuck Silvers, on his quadra 950.
XXX this breaks other m68k platforms. i'll fix them later.
 1.7.2.2 21-Jan-2008  yamt sync with head
 1.7.2.1 03-Sep-2007  yamt sync with head.
 1.9.6.1 22-Apr-2006  simonb Sync with head.
 1.9.4.1 09-Sep-2006  rpaulo sync with head
 1.9.2.1 18-Feb-2006  yamt sync with head.
 1.10.20.2 17-May-2007  yamt sync with head.
 1.10.20.1 12-Mar-2007  rmind Sync with HEAD.
 1.12.10.2 26-Jun-2007  garbled Sync with HEAD.
 1.12.10.1 22-May-2007  matt Update to HEAD.
 1.12.4.1 11-Jul-2007  mjf Sync with head.
 1.12.2.2 09-Jun-2007  ad Sync with head.
 1.12.2.1 27-May-2007  ad Sync with head.
 1.14.10.2 09-Jan-2008  matt sync with HEAD
 1.14.10.1 06-Nov-2007  matt sync with HEAD
 1.15.8.1 08-Jan-2008  bouyer Sync with HEAD
 1.15.2.1 18-Feb-2008  mjf Sync with HEAD.
 1.16.18.1 19-Jan-2009  skrll Sync with HEAD.
 1.16.16.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.16.10.4 11-Aug-2010  yamt sync with head.
 1.16.10.3 11-Mar-2010  yamt sync with head
 1.16.10.2 16-Sep-2009  yamt sync with head
 1.16.10.1 04-May-2009  yamt sync with head.
 1.16.6.1 17-Jan-2009  mjf Sync with HEAD.
 1.28.4.3 12-Jun-2011  rmind sync with head
 1.28.4.2 05-Mar-2011  rmind sync with head
 1.28.4.1 03-Jul-2010  rmind sync with head
 1.28.2.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.32.6.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.32.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.34.60.1 29-Feb-2020  ad Sync with head.
 1.34.54.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.2 12-Jul-2018  maxv Remove the kernel PMC code. Sent yesterday on tech-kern@.

This change:

* Removes "options PERFCTRS", the associated includes, and the associated
ifdefs. In doing so, it removes several XXXSMPs in the MI code, which is
good.

* Removes the PMC code of ARM XSCALE.

* Removes all the pmc.h files. They were all empty, except for ARM XSCALE.

* Reorders the x86 PMC code not to rely on the legacy pmc.h file. The
definitions are put in sysarch.h.

* Removes the kern/sys_pmc.c file, and along with it, the sys_pmc_control
and sys_pmc_get_info syscalls. They are marked as OBSOL in kern,
netbsd32 and rump.

* Removes the pmc_evid_t and pmc_ctr_t types.

* Removes all the associated man pages. The sets are marked as obsolete.
 1.1 07-Aug-2002  briggs branches: 1.1.2; 1.1.4; 1.1.6; 1.1.202; 1.1.204;
Implement pmc(9) -- An interface to hardware performance monitoring
counters. These counters do not exist on all CPUs, but where they
do exist, can be used for counting events such as dcache misses that
would otherwise be difficult or impossible to instrument by code
inspection or hardware simulation.

pmc(9) is meant to be a general interface. Initially, the Intel XScale
counters are the only ones supported.
 1.1.204.1 10-Jun-2019  christos Sync with HEAD
 1.1.202.1 28-Jul-2018  pgoyette Sync with HEAD
 1.1.6.2 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.1.6.1 07-Aug-2002  jdolecek file pmc.h was added on branch kqueue on 2002-09-06 08:36:45 +0000
 1.1.4.2 31-Aug-2002  gehenna catch up with -current.
 1.1.4.1 07-Aug-2002  gehenna file pmc.h was added on branch gehenna-devsw on 2002-08-31 13:45:02 +0000
 1.1.2.2 13-Aug-2002  nathanw Catch up to -current.
 1.1.2.1 07-Aug-2002  nathanw file pmc.h was added on branch nathanw_sa on 2002-08-13 02:18:27 +0000
 1.8 06-Dec-2020  christos Don't expose register_t
 1.7 14-Jan-2011  rmind branches: 1.7.72;
Retire struct user, remove sys/user.h inclusions. Note sys/user.h header
as obsolete. Remove USER_TO_UAREA/UAREA_TO_USER macros.

Various #include fixes and review by matt@.
 1.6 21-Nov-2009  rmind branches: 1.6.4;
Include sys/user.h for MD proc.h (hppa and m68k ports).
 1.5 11-Dec-2005  christos branches: 1.5.78;
merge ktrace-lwp.
 1.4 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.3 17-Jan-2003  thorpej branches: 1.3.2;
Merge the nathanw_sa branch.
 1.2 13-Jul-2002  drochner branches: 1.2.2; 1.2.4; 1.2.6;
make sure struct proc and struct frame are declared
 1.1 13-Jul-2002  scw m68k syscall rototill:

- Switch all m68k-based ports over to __HAVE_SYSCALL_INTERN.
- Add systrace glue.
- Define struct mdproc in <m68k/proc.h> instead of <machine/proc.h>.
(They were all defined exactly the same anyway, other than a couple
of the MDP_* flags.)
 1.2.6.2 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.2.6.1 13-Jul-2002  jdolecek file proc.h was added on branch kqueue on 2002-09-06 08:36:46 +0000
 1.2.4.4 06-Aug-2002  nathanw Need to forward-declare struct lwp, not struct proc.
 1.2.4.3 02-Aug-2002  gmcgarry LWPify.
 1.2.4.2 01-Aug-2002  nathanw Catch up to -current.
 1.2.4.1 13-Jul-2002  nathanw file proc.h was added on branch nathanw_sa on 2002-08-01 02:42:15 +0000
 1.2.2.2 16-Jul-2002  gehenna catch up with -current.
 1.2.2.1 13-Jul-2002  gehenna file proc.h was added on branch gehenna-devsw on 2002-07-16 08:36:47 +0000
 1.3.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.3.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.3.2.1 03-Aug-2004  skrll Sync with HEAD
 1.5.78.1 11-Mar-2010  yamt sync with head
 1.6.4.1 05-Mar-2011  rmind sync with head
 1.7.72.1 14-Dec-2020  thorpej Sync w/ HEAD.
 1.22 18-Mar-2014  riastradh Merge riastradh-drm2 to HEAD.
 1.21 18-Jul-2013  matt Coldfire FPU looks like the 68010 FPU (no long double)
 1.20 21-Mar-2012  he branches: 1.20.2; 1.20.4; 1.20.10;
Use c89 function declarations in MCOUNT definition.
 1.19 07-Aug-2006  tsutsui branches: 1.19.96; 1.19.100;
Remove __P().
 1.18 16-Feb-2006  perry branches: 1.18.2;
Change "inline" back to "__inline" in .h files -- C99 is still too
new, and some apps compile things in C89 mode. C89 keywords stay.

As per core@.
 1.17 24-Dec-2005  perry branches: 1.17.2; 1.17.4; 1.17.6;
__asm__ -> __asm
__const__ -> const
__inline__ -> inline
__volatile__ -> volatile
 1.16 24-Dec-2005  perry Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.
 1.15 11-Dec-2005  christos merge ktrace-lwp.
 1.14 02-Oct-2005  chs put mcount.c in the normal object list, so that "make depend" works.
use a gcc attribute to prevent it from being instrumented.
 1.13 07-Aug-2003  agc branches: 1.13.16;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.12 27-May-2001  chs branches: 1.12.8; 1.12.24;
change the one non-extended asm back to using a single % before a
register name. the rule is that extended asms should have the
regsiter-prefix %s escaped by doubling them, but non-extended asms
don't do the escaping thing, so there the %s should not be doubled.
 1.11 18-May-2001  fredette Only on the 68010, define a different mcount() function,
one that doesn't use the memory-indirect addressing mode.
 1.10 07-Dec-2000  kleink branches: 1.10.2;
In the ELF toolchain, use __mcount instead of mcount.
 1.9 22-Nov-2000  leo Revert previous change. I cannot see why this ever worked... Pointed out
by Steve Woodford.
 1.8 19-Oct-2000  leo %%<reg> -> %<reg>
 1.7 06-Nov-1999  thorpej Add register prefixes.
 1.6 05-Nov-1997  thorpej branches: 1.6.14; 1.6.16; 1.6.20;
inline -> __inline
 1.5 05-Nov-1997  thorpej asm -> __asm__, volatile -> __volatile
 1.4 08-Apr-1997  leo branches: 1.4.8;
Turn the 'extern' definition of mcount() into a full prototype.
 1.3 26-Mar-1995  briggs KERNEL -> _KERNEL
 1.2 26-Oct-1994  cgd new RCS ID format.
 1.1 13-May-1994  mycroft Needed for new profiling code.
 1.4.8.2 05-Nov-1997  thorpej Update from trunk: inline -> __inline
 1.4.8.1 05-Nov-1997  thorpej Pullup from trunk: asm -> __asm__, volatile -> __volatile
 1.6.20.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.6.16.1 15-Nov-1999  fvdl Sync with -current
 1.6.14.2 08-Dec-2000  bouyer Sync with HEAD.
 1.6.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.10.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.12.24.4 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.12.24.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.12.24.2 18-Sep-2004  skrll Sync with HEAD.
 1.12.24.1 03-Aug-2004  skrll Sync with HEAD
 1.12.8.2 27-May-2001  chs change the one non-extended asm back to using a single % before a
register name. the rule is that extended asms should have the
regsiter-prefix %s escaped by doubling them, but non-extended asms
don't do the escaping thing, so there the %s should not be doubled.
 1.12.8.1 27-May-2001  chs file profile.h was added on branch nathanw_sa on 2001-05-27 00:58:58 +0000
 1.13.16.2 30-Dec-2006  yamt sync with head.
 1.13.16.1 21-Jun-2006  yamt sync with head.
 1.17.6.1 22-Apr-2006  simonb Sync with head.
 1.17.4.1 09-Sep-2006  rpaulo sync with head
 1.17.2.1 18-Feb-2006  yamt sync with head.
 1.18.2.1 11-Aug-2006  yamt sync with head
 1.19.100.1 05-Apr-2012  mrg sync to latest -current.
 1.19.96.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.19.96.1 17-Apr-2012  yamt sync with head
 1.20.10.1 23-Jul-2013  riastradh sync with HEAD
 1.20.4.1 28-Aug-2013  rmind sync with head
 1.20.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.19 16-Jan-2024  thorpej Provide PSLTOIPL() and IPLTOPSL() macros.
 1.18 14-Jan-2024  thorpej Provide a _splx() inline.
 1.17 12-Jan-2024  thorpej Make getsr() an inline in <m68k/psl.h> and G/C all of the now-redudant
copies.
 1.16 27-Jan-2023  tsutsui Use proper uintNN_t integer types.
 1.15 27-Jul-2012  matt Remove safepri and use IPL_SAFEPRI instead. This may be defined in a MD
header file (if not, a value of 0 is assmued).
 1.14 06-May-2009  mhitch branches: 1.14.12;
Add memory clobber to the instructions that change the IPL in the status
register. See also kern/38637.
 1.13 16-Feb-2006  perry branches: 1.13.72; 1.13.82; 1.13.86; 1.13.88;
Change "inline" back to "__inline" in .h files -- C99 is still too
new, and some apps compile things in C89 mode. C89 keywords stay.

As per core@.
 1.12 24-Dec-2005  perry branches: 1.12.2; 1.12.4; 1.12.6;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.
 1.11 11-Dec-2005  christos merge ktrace-lwp.
 1.10 07-Aug-2003  agc branches: 1.10.16;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.9 05-Aug-2001  matt branches: 1.9.6; 1.9.22;
If = is in a constraint, it must be the first character.
 1.8 11-Dec-2000  scw branches: 1.8.4;
Some micro-optimisations to _spl() and _splraise(), saving one instruction
in the former, and three to seven in the latter.
 1.7 06-Nov-1999  thorpej Add register prefixes.
 1.6 05-Aug-1999  thorpej branches: 1.6.2; 1.6.4; 1.6.8;
Change the semantics of splsoftclock() to be like other spl*() functions,
that is priority is rasied. Add a new spllowersoftclock() to provide the
atomic drop-to-softclock semantics that the old splsoftclock() provided,
and update calls accordingly.

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

XXX 4 platforms do not have priority-raising capability: newsmips, sparc,
XXX sparc64, and VAX. This platforms still have this bug until their
XXX spl*() functions are fixed.
 1.5 26-Oct-1994  cgd new RCS ID format.
 1.4 23-May-1994  mycroft Add RCS ids.
 1.3 23-May-1994  mycroft Merge with 4.4-Lite.
 1.2 22-May-1993  cgd add rcsids to everything and clean up headers
 1.1 13-May-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.1 13-May-1993  cgd add hp300 kernel files. generic kernel files might need some help...
 1.6.8.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.6.4.1 15-Nov-1999  fvdl Sync with -current
 1.6.2.2 13-Dec-2000  bouyer Sync with HEAD (for UBC fixes).
 1.6.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.8.4.1 25-Aug-2001  thorpej Merge Aug 24 -current into the kqueue branch.
 1.9.22.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.9.22.2 18-Sep-2004  skrll Sync with HEAD.
 1.9.22.1 03-Aug-2004  skrll Sync with HEAD
 1.9.6.2 05-Aug-2001  matt If = is in a constraint, it must be the first character.
 1.9.6.1 05-Aug-2001  matt file psl.h was added on branch nathanw_sa on 2001-08-05 04:40:04 +0000
 1.10.16.1 21-Jun-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.12.2.1 18-Feb-2006  yamt sync with head.
 1.13.88.1 10-May-2009  snj branches: 1.13.88.1.2;
Pull up following revision(s) (requested by mhitch in ticket #743):
sys/arch/m68k/include/psl.h: revision 1.14
Add memory clobber to the instructions that change the IPL in the status
register. See also kern/38637.
 1.13.88.1.2.1 21-Apr-2010  matt sync to netbsd-5
 1.13.86.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.13.82.1 10-May-2009  snj Pull up following revision(s) (requested by mhitch in ticket #743):
sys/arch/m68k/include/psl.h: revision 1.14
Add memory clobber to the instructions that change the IPL in the status
register. See also kern/38637.
 1.13.72.1 16-May-2009  yamt sync with head
 1.14.12.1 30-Oct-2012  yamt sync with head
 1.2 18-Mar-2014  riastradh branches: 1.2.4; 1.2.8;
Merge riastradh-drm2 to HEAD.
 1.1 18-Jul-2013  matt branches: 1.1.2; 1.1.4;
pte and pmap files for the soft tlb on coldfire cpus.
(uncompiled and mostly probably wrong.)
 1.1.4.2 28-Aug-2013  rmind sync with head
 1.1.4.1 18-Jul-2013  rmind file pte_coldfire.h was added on branch rmind-smpnet on 2013-08-28 23:59:18 +0000
 1.1.2.2 23-Jul-2013  riastradh sync with HEAD
 1.1.2.1 18-Jul-2013  riastradh file pte_coldfire.h was added on branch riastradh-drm2 on 2013-07-23 21:07:34 +0000
 1.2.8.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.2.8.1 18-Mar-2014  tls file pte_coldfire.h was added on branch tls-maxphys on 2014-08-20 00:03:10 +0000
 1.2.4.2 22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.2.4.1 18-Mar-2014  yamt file pte_coldfire.h was added on branch yamt-pagecache on 2014-05-22 11:39:55 +0000
 1.10 01-Jan-2024  thorpej Define PTE used in the pmap module int terms of the bit definitions
in mmu_{51,40}.h.
 1.9 27-Dec-2023  thorpej Stop using magic numbers for the MMU root pointer attributes and the
Translation Control register, and also get rid of "#if PGSHIFT == ..."
where those magic numbers are used.

Instead, define new macros: MMU51_SRP_BITS, MMU51_CRP_BITS, MMU51_TCR_BITS,
and MMU40_TCR_BITS, in terms of the definitions in mmu_{40,51}.h. These
automagically adapt to 8K and 4K pages based on the machine-specific value
of PGSHIFT.
 1.8 08-Feb-2011  rmind branches: 1.8.86;
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.7 07-Dec-2009  tsutsui branches: 1.7.4; 1.7.6; 1.7.8;
Remove "#if defined(amiga) || defined(atari)" for PG_SHIFT.
Use PGSHIFT from <machine/param.h> instead.
 1.6 17-Jan-2009  tsutsui Make st_entry_t and pt_entry_t unsigned.
These values contain paddr_t and bitmap flags.

XXX paddr_t is unsigned long, not unsigned int.
 1.5 17-Oct-2007  garbled branches: 1.5.16; 1.5.20; 1.5.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.4 05-Jun-2007  mhitch branches: 1.4.10;
Page table sizes depend on pagesize - fix M68K_MAX_PTSIZE to account for
pagesize. M68K_MAX_KPTSIZE also dependent on pagesize, and was 1/4 the
maximum size of a user pagetable.
 1.3 11-Dec-2005  christos branches: 1.3.30; 1.3.32; 1.3.38;
merge ktrace-lwp.
 1.2 07-Aug-2003  agc branches: 1.2.16;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.1 14-Oct-2002  chs branches: 1.1.2; 1.1.8;
merge pte.h for m68k w/ motorola or compatible MMU
(only 4k-page platforms so far).
 1.1.8.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.1.8.2 18-Sep-2004  skrll Sync with HEAD.
 1.1.8.1 03-Aug-2004  skrll Sync with HEAD
 1.1.2.2 18-Oct-2002  nathanw Catch up to -current.
 1.1.2.1 14-Oct-2002  nathanw file pte_motorola.h was added on branch nathanw_sa on 2002-10-18 02:38:15 +0000
 1.2.16.1 03-Sep-2007  yamt sync with head.
 1.3.38.1 26-Jun-2007  garbled Sync with HEAD.
 1.3.32.1 11-Jul-2007  mjf Sync with head.
 1.3.30.1 09-Jun-2007  ad Sync with head.
 1.4.10.1 06-Nov-2007  matt sync with HEAD
 1.5.28.1 19-Jan-2009  skrll Sync with HEAD.
 1.5.20.2 11-Mar-2010  yamt sync with head
 1.5.20.1 04-May-2009  yamt sync with head.
 1.5.16.1 17-Jan-2009  mjf Sync with HEAD.
 1.7.8.1 17-Feb-2011  bouyer Sync with HEAD
 1.7.6.1 06-Jun-2011  jruoho Sync with HEAD.
 1.7.4.1 05-Mar-2011  rmind sync with head
 1.8.86.1 27-Jun-2024  martin Pull up following revision(s) (requested by rin in ticket #724
to fix build fallout on the branch):

sys/arch/m68k/m68k/compat_16_sigreturn14.s: revision 1.6
sys/arch/mvme68k/mvme68k/locore.s: revision 1.129
sys/arch/news68k/news68k/locore.s: revision 1.84
sys/arch/hp300/hp300/locore.s: revision 1.183
sys/arch/m68k/m68k/compat_13_sigreturn13.s: revision 1.8
sys/arch/m68k/m68k/sigreturn.s: file removal
sys/arch/m68k/include/pte_motorola.h: revision 1.10
sys/arch/atari/atari/locore.s: revision 1.125
sys/arch/amiga/amiga/locore.s: revision 1.169
sys/arch/sun2/sun2/locore.s: revision 1.37
sys/arch/next68k/next68k/locore.s: revision 1.84
sys/arch/x68k/x68k/locore.s: revision 1.130
sys/arch/sun3/sun3x/locore.s: revision 1.77
sys/arch/cesfic/cesfic/locore.s: revision 1.45
sys/arch/m68k/conf/files.m68k: revision 1.53
sys/arch/sun3/sun3/locore.s: revision 1.109
sys/arch/luna68k/luna68k/locore.s: revision 1.81
sys/arch/mac68k/mac68k/locore.s: revision 1.182

Define PTE used in the pmap module int terms of the bit definitions
in mmu_{51,40}.h.

Make compat_13_sigreturn13.s and compat_16_sigreturn14.s build as their
own stand-alone files and G/C the now-empty sigreturn.s.
 1.13 18-Jun-2019  kamil Introduce PTRACE_REG_FP() a helper macro to retrieve the frame pointer

The macro is dummy for ia64 (the FP register is unknown and can change
freely) and sparc/sparc64 (not stored in struct reg).
 1.12 12-Apr-2017  kamil branches: 1.12.12;
Add new macro PTRACE_BREAKPOINT_ASM in <sys/ptrace.h> MD part

This macro ships with a MD-specific assembly instruction triggering
a software breakpoint.

Missing instruction for powerpc targets.

This code is used in ATF tests (lib/libc/sys/t_ptrace_wait).

Original patch by Nick Hudson, thanks!
 1.11 08-Apr-2017  kamil Add new ptrace(2) API: PT_SETSTEP & PT_CLEARSTEP

These operations allow to mark thread as a single-stepping one.

This allows to i.a.:
- single step and emit a signal (PT_SETSTEP & PT_CONTINUE)
- single step and trace syscall entry and exit (PT_SETSTEP & PT_SYSCALL)

The former is useful for debuggers like GDB or LLDB. The latter can be used
to singlestep a usermode kernel. These examples don't limit use-cases of
this interface.

Define PT_*STEP only for platforms defining PT_STEP.

Add new ATF tests setstep[1234].

These ptrace(2) operations first appeared in FreeBSD.

Sponsored by <The NetBSD Foundation>
 1.10 25-Sep-2015  christos branches: 1.10.2; 1.10.4;
For processors that have memory breakpoints, add macros for them to help
libproc
 1.9 15-Sep-2015  christos Provide access to pc/sp/syscall-return registers like we have for mcontext
 1.8 25-Jan-2008  skrll branches: 1.8.54; 1.8.74;
Define PT_MACHDEP_STRINGS
 1.7 26-Jan-1995  mycroft branches: 1.7.82; 1.7.144; 1.7.150;
Add PT_[GS]ETFPREGS.
 1.6 26-Oct-1994  cgd new RCS ID format.
 1.5 10-Apr-1994  chopps protect against multiple inclusion
 1.4 30-Jan-1994  mycroft PT_[SG]ETFPREGS are not yet implemented.
 1.3 28-Jan-1994  jtc Fix spelling error in Copyright notice
 1.2 09-Jan-1994  cgd define PT_STEP, and clean up some
 1.1 08-Jan-1994  cgd common code
 1.7.150.1 18-Feb-2008  mjf Sync with HEAD.
 1.7.144.1 23-Mar-2008  matt sync with HEAD
 1.7.82.1 04-Feb-2008  yamt sync with head.
 1.8.74.3 28-Aug-2017  skrll Sync with HEAD
 1.8.74.2 27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.8.74.1 22-Sep-2015  skrll Sync with HEAD
 1.8.54.1 03-Dec-2017  jdolecek update from HEAD
 1.10.4.1 21-Apr-2017  bouyer Sync with HEAD
 1.10.2.1 26-Apr-2017  pgoyette Sync with HEAD
 1.12.12.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.21 27-Oct-2019  rin Expose register difinitions for _STANDALONE.
Fix build failure in arch/luna68k/stand/boot.
 1.20 26-Oct-2019  christos Hide the register definitions that should eventually be removed (or prefixed
with _REG_ with #ifdef _KERNEL. This avoids conflicts with let's say PC in
<termcap.h>.
 1.19 04-Jan-2014  dsl branches: 1.19.30;
Remove __HAVE_PROCESS_XFPREGS and add the extra parameter for the size
of the fp save area to all the process_read_fpregs() and
process_write_fpregs() functions.
None of the functions have been modified to use the new parameters.
The size is set for all the writes, but some of the arch-specific reads
just pass NULL.
The amd64 (and i386) need variable sized fp register save areas in order
to support AVX and other enhanced register areas.
These functions are rarely called - so the extra argument won't matter.
 1.18 08-Feb-2011  rmind branches: 1.18.4; 1.18.14; 1.18.18;
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.17 11-Dec-2005  christos branches: 1.17.100; 1.17.106; 1.17.108;
merge ktrace-lwp.
 1.16 28-Aug-2004  thorpej De-__P
 1.15 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.14 17-Jan-2003  thorpej branches: 1.14.2;
Merge the nathanw_sa branch.
 1.13 19-Apr-1999  kleink branches: 1.13.20;
Define FP as a synonym for A6.
 1.12 17-Dec-1996  gwr branches: 1.12.24;
Add prototypes for process_read_regs, etc. (fix warnings)
 1.11 26-Mar-1995  briggs KERNEL -> _KERNEL
 1.10 26-Jan-1995  mycroft Add struct fpreg.
 1.9 26-Jan-1995  mycroft Rearrange struct reg to match what the rest of the world expects.
 1.8 26-Oct-1994  cgd new RCS ID format.
 1.7 08-Jan-1994  cgd HP300 -> M68K, and light trimming
 1.6 06-Jan-1994  mycroft Still need old #defines for now.
 1.5 06-Jan-1994  mycroft Implement `struct reg'.
 1.4 08-Dec-1993  mycroft Move #define of NIPCREG outside #fidef.
 1.3 02-Sep-1993  mycroft Ditto.
 1.2 22-May-1993  cgd add rcsids to everything and clean up headers
 1.1 13-May-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.1 13-May-1993  cgd add hp300 kernel files. generic kernel files might need some help...
 1.12.24.1 21-Jun-1999  thorpej Sync w/ -current.
 1.13.20.1 17-Nov-2001  scw Kernel support for Scheduler Activations on m68k-based ports using
mvme68k as a testbed.

Boots multi-user on an mvme162, although userland support for SA is not
yet integrated/tested.
 1.14.2.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.14.2.3 18-Sep-2004  skrll Sync with HEAD.
 1.14.2.2 03-Sep-2004  skrll Sync with HEAD
 1.14.2.1 03-Aug-2004  skrll Sync with HEAD
 1.17.108.1 17-Feb-2011  bouyer Sync with HEAD
 1.17.106.1 06-Jun-2011  jruoho Sync with HEAD.
 1.17.100.1 05-Mar-2011  rmind sync with head
 1.18.18.1 18-May-2014  rmind sync with head
 1.18.14.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.18.4.1 22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.19.30.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.6 29-Nov-2019  riastradh Largely eliminate the MD rwlock.h header file.

This was full of definitions that have been obsolete for over a
decade. The file still remains for __HAVE_RW_STUBS but that's all.
Used only internally in kern_rwlock.c now, not by <sys/rwlock.h>.
 1.5 28-Apr-2008  martin branches: 1.5.88;
Remove clause 3 and 4 from TNF licenses
 1.4 05-Apr-2008  tsutsui branches: 1.4.2; 1.4.4;
Use generic atomic_cas_uint() for mutex(9) and rwlock(9), and
remodel old RAS based _lock_cas() implementation for m68010
into genereic atomic_cas_32().
Now sun2 kernel compiles and even works on multiuser. (hehe)

Tested on tme (emulationg 2/120 and 3/150) and (real) 3/80.
 1.3 21-Nov-2007  yamt branches: 1.3.14;
make kmutex_t and krwlock_t smaller by killing lock id.
ok'ed by Andrew Doran.
 1.2 09-Feb-2007  ad branches: 1.2.4; 1.2.8; 1.2.24; 1.2.26; 1.2.30; 1.2.32;
Merge newlock2 to head.
 1.1 06-Feb-2007  ad branches: 1.1.2;
file rwlock.h was initially added on branch newlock2.
 1.1.2.1 06-Feb-2007  ad Make amiga & mac68k compile.
 1.2.32.1 08-Dec-2007  mjf Sync with HEAD.
 1.2.30.1 21-Nov-2007  bouyer Sync with HEAD
 1.2.26.1 09-Jan-2008  matt sync with HEAD
 1.2.24.1 21-Nov-2007  joerg Sync with HEAD.
 1.2.8.1 03-Dec-2007  ad Sync with HEAD.
 1.2.4.3 07-Dec-2007  yamt sync with head
 1.2.4.2 26-Feb-2007  yamt sync with head.
 1.2.4.1 09-Feb-2007  yamt file rwlock.h was added on branch yamt-lazymbuf on 2007-02-26 09:07:12 +0000
 1.3.14.1 02-Jun-2008  mjf Sync with HEAD.
 1.4.4.1 16-May-2008  yamt sync with head.
 1.4.2.1 18-May-2008  yamt sync with head.
 1.5.88.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.8 19-Feb-2012  rmind Remove COMPAT_SA / KERN_SA. Welcome to 6.99.3!
Approved by core@.
 1.7 15-Oct-2008  wrstuden branches: 1.7.28; 1.7.32;
Merge wrstuden-revivesa into HEAD. Catch some files that I forgot
to revive on HEAD in previous commit.
 1.6 11-May-2008  wrstuden branches: 1.6.2; 1.6.6;
Oops. These are supposed to come alive on the branch, not the head.
 1.5 10-May-2008  wrstuden Initial checkin of re-adding SA. Everything except kern_sa.c
compiles in GENERIC for i386. This is still a work-in-progress, but
this checkin covers most of the mechanical work (changing signalling
to be able to accomidate SA's process-wide signalling and re-adding
includes of sys/sa.h and savar.h). Subsequent changes will be much
more interesting.

Also, kern_sa.c has received partial cleanup. There's still more
to do, though.
 1.4 24-Mar-2008  yamt branches: 1.4.4;
remove an empty file.
 1.3 09-Feb-2007  ad branches: 1.3.44;
Merge newlock2 to head.
 1.2 17-Jan-2003  thorpej branches: 1.2.18; 1.2.48;
Merge the nathanw_sa branch.
 1.1 17-Nov-2001  scw branches: 1.1.2;
file saframe.h was initially added on branch nathanw_sa.
 1.1.2.3 02-Aug-2002  nathanw Add return address, remove upcall pointer.
 1.1.2.2 17-Nov-2001  scw Re-sync with current MI SA code.
 1.1.2.1 17-Nov-2001  scw Kernel support for Scheduler Activations on m68k-based ports using
mvme68k as a testbed.

Boots multi-user on an mvme162, although userland support for SA is not
yet integrated/tested.
 1.2.48.1 30-Jan-2007  ad Remove support for SA. Ok core@.
 1.2.18.1 26-Feb-2007  yamt sync with head.
 1.3.44.2 17-Jan-2009  mjf Sync with HEAD.
 1.3.44.1 03-Apr-2008  mjf Sync with HEAD.
 1.4.4.1 04-May-2009  yamt sync with head.
 1.6.6.1 19-Oct-2008  haad Sync with HEAD.
 1.6.2.2 11-May-2008  wrstuden Try this again, on the correct branch this time!

Initial checkin of re-adding SA. Everything except kern_sa.c
compiles in GENERIC for i386. This is still a work-in-progress, but
this checkin covers most of the mechanical work (changing signalling
to be able to accomidate SA's process-wide signalling and re-adding
includes of sys/sa.h and savar.h). Subsequent changes will be much
more interesting.

Also, kern_sa.c has received partial cleanup. There's still more
to do, though.
 1.6.2.1 11-May-2008  wrstuden file saframe.h was added on branch wrstuden-revivesa on 2008-05-11 00:23:34 +0000
 1.7.32.1 24-Feb-2012  mrg sync to -current.
 1.7.28.1 17-Apr-2012  yamt sync with head
 1.2 15-Sep-1998  thorpej Need 21 longs for jmp_buf now, due to 128-bit signal mask (and use
of the sigcontext structure in the jmp_buf).
 1.1 20-Dec-1994  cgd make the definition of _JBLEN mach. dep. header-dependent.
 1.28 29-Oct-2021  thorpej Define __HAVE_STRUCT_SIGCONTEXT regardless of its current visibility.
 1.27 27-Oct-2021  thorpej Make sigcontext13 visible only to _KERNEL.
 1.26 26-Oct-2021  christos Merge all MD __sigaction14_sigtramp.c copies into one:
- sparc and sparc64 were not using version 0 sigcontext when there were
no arguments in the signal version. This was probably a bug.
- vax is using +1 the version numbers of the other archs.
- Only hppa was defining __LIBC12_SOURCE__ so it was getting a working
sigcontext before. all the other ports that supported sigcontext had
the compat code disabled.
[pointed out by thorpej, thanks!]
If we want to remove sigcontext support from userland at least now there
is less work to do so.
 1.25 27-Jan-2009  martin Centralize fpu exception to siginfo code encoding for all m68k archs,
fixes a failure in the lib/libc/ieeefp/except regression test.
 1.24 19-Nov-2008  ad Make the emulations, exec formats, coredump, NFS, and the NFS server
into modules. By and large this commit:

- shuffles header files and ifdefs
- splits code out where necessary to be modular
- adds module glue for each of the components
- adds/replaces hooks for things that can be installed at runtime
 1.23 01-Apr-2006  oster branches: 1.23.62; 1.23.66; 1.23.72; 1.23.74; 1.23.76;
We don't need (or want!) to include cpuframe.h or have sigstate
visible to userland on m68k. Fixes numerous pkgsrc build issues where
"struct frame" as defined in cpuframe.h pollutes the local namespace.

Compile-tested full builds for hp300, mac68k, amiga, sun3, and next68k.

OK'ed by matt@.
 1.22 11-Dec-2005  christos branches: 1.22.4; 1.22.6; 1.22.8; 1.22.10; 1.22.12;
merge ktrace-lwp.
 1.21 07-Sep-2005  drochner namespace sanity: don't expose compatibility sigcontext stuff
unnecessarily
 1.20 29-Jul-2004  is branches: 1.20.10; 1.20.12; 1.20.14;
Revert last change. It breaks the build due to interactions with
frame.h.
 1.19 28-Jul-2004  is For a while, we exported symbols in the user namespace (which should only
be interesting for the kernel), thus breaking (e.g.) vim. (PR 26048)
 1.18 10-May-2004  drochner SIGTRAMP_VALID() should not pollute the user namespace
 1.17 26-Mar-2004  drochner nothing cares about __HAVE_SIGINFO anymore, so nuke it
 1.16 25-Nov-2003  christos bye, bye _MCONTEXT_TO_SIGCONTEXT and vice versa.
 1.15 18-Oct-2003  briggs Define SIGTRAMP_VALID(v).
 1.14 22-Sep-2003  cl SA_SIGINFO support for m68k
 1.13 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.12 28-Apr-2003  bjh21 branches: 1.12.2;
Add a new feature-test macro, _NETBSD_SOURCE. If this is defined
by the application, all NetBSD interfaces are made visible, even
if some other feature-test macro (like _POSIX_C_SOURCE) is defined.
<sys/featuretest.h> defined _NETBSD_SOURCE if none of _ANSI_SOURCE,
_POSIX_C_SOURCE and _XOPEN_SOURCE is defined, so as to preserve
existing behaviour.

This has two major advantages:
+ Programs that require non-POSIX facilities but define _POSIX_C_SOURCE
can trivially be overruled by putting -D_NETBSD_SOURCE in their CFLAGS.
+ It makes most of the #ifs simpler, in that they're all now ORs of the
various macros, rather than having checks for (!defined(_ANSI_SOURCE) ||
!defined(_POSIX_C_SOURCE) || !defined(_XOPEN_SOURCE)) all over the place.

I've tried not to change the semantics of the headers in any case where
_NETBSD_SOURCE wasn't defined, but there were some places where the
current semantics were clearly mad, and retaining them was harder than
correcting them. In particular, I've mostly normalised things so that
_ANSI_SOURCE gets you the smallest set of stuff, then _POSIX_C_SOURCE,
_XOPEN_SOURCE and _NETBSD_SOURCE in that order.

Tested by building for vax, encouraged by thorpej, and uncontested in
tech-userlevel for a week.
 1.11 17-Jan-2003  thorpej Merge the nathanw_sa branch.
 1.10 04-Jul-2002  thorpej During signal delivery, arrange to have the signal handler invoked
directly, using the trampoline only for the return path. Saves a
"jsr" in the trampoline.

Reviewed, tested and OK'd by Steve Woodford.
 1.9 23-Jun-2002  thorpej Swap the order of the sigcontext and hardware state in the sigframe.
 1.8 30-Sep-1998  thorpej branches: 1.8.26; 1.8.30; 1.8.38;
Pull in <m68k/frame.h> if __M68K_SIGNAL_PRIVATE, for sigstate.
 1.7 30-Sep-1998  thorpej Put the sigstate and sigframe definitions in signal.h, protected by
__M68K_SIGNAL_PRIVATE.
 1.6 15-Sep-1998  thorpej Define the new sigcontext structure.
 1.5 25-May-1998  kleink If any of _ANSI_SOURCE, _POSIX_C_SOURCE or _XOPEN_SOURCE are defined, don't
provide any identifiers other than sig_atomic_t.
 1.4 10-Jan-1995  jtc Only define sig_atomic_t when _ANSI_SOURCE is defined.
 1.3 26-Oct-1994  cgd new RCS ID format.
 1.2 10-Apr-1994  chopps protect against multiple inclusion
 1.1 13-Oct-1993  cgd md signal context.
 1.8.38.1 16-Jul-2002  gehenna catch up with -current.
 1.8.30.2 16-Jan-2003  thorpej * Include <sys/sigtypes.h> rather than <sys/signal.h> in <sys/ucontext.h>.
* Define _UCONTEXT_TO_SIGCONTEXT() and _SIGCONTEXT_TO_UCONTEXT()
macros for converting a ucontext -> sigcontext and back again.
These macros in turn use machine-dependent macros _MCONTEXT_TO_SIGCONTEXT()
and _SIGCONTEXT_TO_MCONTEXT() provided by <machine/signal.h>.

The conversion process is not 100% accurate, but should be close enough.

Also note that the mcontext conversion may not be enough for all platforms
(m68k is a good example of this). These macros should be used only if
you really know what you're doing.
 1.8.30.1 01-Aug-2002  nathanw Catch up to -current.
 1.8.26.1 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.12.2.4 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 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.20.14.1 06-Apr-2006  tron Pull up following revision(s) (requested by oster in ticket #1243):
sys/arch/m68k/include/signal.h: revision 1.23
We don't need (or want!) to include cpuframe.h or have sigstate
visible to userland on m68k. Fixes numerous pkgsrc build issues where
"struct frame" as defined in cpuframe.h pollutes the local namespace.
Compile-tested full builds for hp300, mac68k, amiga, sun3, and next68k.
OK'ed by matt@.
 1.20.12.1 21-Jun-2006  yamt sync with head.
 1.20.10.1 06-Apr-2006  tron Pull up following revision(s) (requested by oster in ticket #1243):
sys/arch/m68k/include/signal.h: revision 1.23
We don't need (or want!) to include cpuframe.h or have sigstate
visible to userland on m68k. Fixes numerous pkgsrc build issues where
"struct frame" as defined in cpuframe.h pollutes the local namespace.
Compile-tested full builds for hp300, mac68k, amiga, sun3, and next68k.
OK'ed by matt@.
 1.22.12.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.22.10.1 19-Apr-2006  elad sync with head - hopefully this will work
 1.22.8.1 11-Apr-2006  yamt sync with head
 1.22.6.1 22-Apr-2006  simonb Sync with head.
 1.22.4.1 09-Sep-2006  rpaulo sync with head
 1.23.76.1 02-Feb-2009  snj Pull up following revision(s) (requested by martin in ticket #332):
sys/arch/amiga/amiga/trap.c: revision 1.122
sys/arch/atari/atari/trap.c: revision 1.99
sys/arch/cesfic/cesfic/trap.c: revision 1.43
sys/arch/hp300/hp300/trap.c: revision 1.140
sys/arch/luna68k/luna68k/trap.c: revision 1.55
sys/arch/m68k/include/signal.h: revision 1.25
sys/arch/m68k/m68k/sig_machdep.c: revision 1.41
sys/arch/mac68k/mac68k/trap.c: revision 1.136 via patch
sys/arch/mvme68k/mvme68k/trap.c: revision 1.98
sys/arch/news68k/news68k/trap.c: revision 1.60
sys/arch/next68k/next68k/trap.c: revision 1.75
sys/arch/sun2/sun2/trap.c: revision 1.37
sys/arch/sun3/sun3/trap.c: revision 1.136
sys/arch/x68k/x68k/trap.c: revision 1.97
Centralize fpu exception to siginfo code encoding for all m68k archs,
fixes a failure in the lib/libc/ieeefp/except regression test.
 1.23.74.2 03-Mar-2009  skrll Sync with HEAD.
 1.23.74.1 19-Jan-2009  skrll Sync with HEAD.
 1.23.72.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.23.66.1 04-May-2009  yamt sync with head.
 1.23.62.1 17-Jan-2009  mjf Sync with HEAD.
 1.5 22-Dec-2011  tsutsui Remove obsolete header.
 1.4 28-Apr-2008  martin branches: 1.4.34; 1.4.38;
Remove clause 3 and 4 from TNF licenses
 1.3 03-Dec-2007  ad branches: 1.3.14; 1.3.16; 1.3.18;
Interrupt handling changes, in discussion since February:

- Reduce available SPL levels for hardware devices to none, vm, sched, high.
- Acquire kernel_lock only for interrupts at IPL_VM.
- Implement threaded soft interrupts.
 1.2 04-Mar-2007  tsutsui branches: 1.2.2; 1.2.4; 1.2.20; 1.2.22; 1.2.24; 1.2.30;
Hide #include <m68k/softintr.h> inside #ifdef _KERNEL in <machine/intr.h>
to avoid exporting unnecessary files to userland.
Should fix build.sh failure, which was pointed out by isaki@.

XXX: which userland program would require contents of <machine/intr.h>?
 1.1 04-Mar-2007  tsutsui Add common soft interrupt routines for m68k ports which use
hp300 derived simulated software interrupt with VAX REI emulation.
Just taken from hp300/hp300/softintr.c and sys/arch/hp300/include/intr.h.
 1.2.30.1 08-Dec-2007  mjf Sync with HEAD.
 1.2.24.3 07-Dec-2007  yamt sync with head
 1.2.24.2 03-Sep-2007  yamt sync with head.
 1.2.24.1 04-Mar-2007  yamt file softintr.h was added on branch yamt-lazymbuf on 2007-09-03 14:27:12 +0000
 1.2.22.1 09-Jan-2008  matt sync with HEAD
 1.2.20.1 09-Dec-2007  jmcneill Sync with HEAD.
 1.2.4.2 12-Mar-2007  rmind Sync with HEAD (missed new files in previous).
 1.2.4.1 04-Mar-2007  rmind file softintr.h was added on branch yamt-idlelwp on 2007-03-12 06:14:50 +0000
 1.2.2.1 03-Dec-2007  ad Sync with HEAD.
 1.3.18.1 16-May-2008  yamt sync with head.
 1.3.16.1 18-May-2008  yamt sync with head.
 1.3.14.1 02-Jun-2008  mjf Sync with HEAD.
 1.4.38.1 18-Feb-2012  mrg merge to -current.
 1.4.34.1 17-Apr-2012  yamt sync with head
 1.24 17-Jul-2011  joerg 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.23 11-Dec-2005  christos merge ktrace-lwp.
 1.22 14-Apr-2005  matt For GCC3 and beyond, use the __builtin_va_* types and functions to
deal with variable argument lists.
 1.21 07-Aug-2003  agc branches: 1.21.8;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.20 28-Apr-2003  bjh21 branches: 1.20.2;
Add a new feature-test macro, _NETBSD_SOURCE. If this is defined
by the application, all NetBSD interfaces are made visible, even
if some other feature-test macro (like _POSIX_C_SOURCE) is defined.
<sys/featuretest.h> defined _NETBSD_SOURCE if none of _ANSI_SOURCE,
_POSIX_C_SOURCE and _XOPEN_SOURCE is defined, so as to preserve
existing behaviour.

This has two major advantages:
+ Programs that require non-POSIX facilities but define _POSIX_C_SOURCE
can trivially be overruled by putting -D_NETBSD_SOURCE in their CFLAGS.
+ It makes most of the #ifs simpler, in that they're all now ORs of the
various macros, rather than having checks for (!defined(_ANSI_SOURCE) ||
!defined(_POSIX_C_SOURCE) || !defined(_XOPEN_SOURCE)) all over the place.

I've tried not to change the semantics of the headers in any case where
_NETBSD_SOURCE wasn't defined, but there were some places where the
current semantics were clearly mad, and retaining them was harder than
correcting them. In particular, I've mostly normalised things so that
_ANSI_SOURCE gets you the smallest set of stuff, then _POSIX_C_SOURCE,
_XOPEN_SOURCE and _NETBSD_SOURCE in that order.

Tested by building for vax, encouraged by thorpej, and uncontested in
tech-userlevel for a week.
 1.19 03-Feb-2000  kleink Add a C99-style va_copy macro.
 1.18 04-May-1999  christos branches: 1.18.2;
whitespace...
 1.17 03-May-1999  christos Define __builtin_*() for lint
 1.16 22-Jan-1999  mycroft branches: 1.16.4;
Use __builtin_next_arg(). Fixed PR 6862.
 1.15 27-Jul-1998  mycroft Delint.
 1.14 25-Dec-1995  mycroft branches: 1.14.16;
Stylistic changes.
 1.13 25-Dec-1995  mycroft Stylistic changes.
 1.12 25-Dec-1995  mycroft Update for GCC 2.7, and fix bugs.
 1.11 07-Sep-1995  jtc Fix bug when the second argument of va_start was a char, short or float.
(ie. not promoted); fixes PR# 1193. Thanks to Bernd Ernesti and Markus
Wild.
 1.10 26-Mar-1995  briggs KERNEL -> _KERNEL
 1.9 28-Jan-1995  jtc ANSI says that <stdarg.h>'s va_end macro must expand to a void expression.
For consistancy, I'm changing <varargs.h> too.
 1.8 28-Dec-1994  cgd do the right thing with strange-sized varargs objects.
 1.7 26-Oct-1994  cgd new RCS ID format.
 1.6 15-Oct-1994  cgd make <stdarg.h> a symlink, and clean up ports' stdarg.h and varargs.h files.
 1.5 21-May-1994  cgd update from lite
 1.4 10-Apr-1994  chopps protect against multiple inclusion
 1.3 28-Jan-1994  mycroft Protect against multiple inclusions.
 1.2 22-May-1993  cgd add rcsids to everything and clean up headers
 1.1 13-May-1993  cgd add from net2. were symlinks to ../../vax/include/*
 1.14.16.1 01-Feb-1999  cgd pull up revs 1.15-1.16 from trunk (PR#6862). (mycroft)
 1.16.4.1 21-Jun-1999  thorpej Sync w/ -current.
 1.18.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.20.2.4 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.20.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.20.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.20.2.1 03-Aug-2004  skrll Sync with HEAD
 1.21.8.1 29-Apr-2005  kent sync with -current
 1.3 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.2 11-Dec-2005  christos branches: 1.2.18; 1.2.76; 1.2.78; 1.2.80;
merge ktrace-lwp.
 1.1 11-Jul-2005  christos branches: 1.1.6;
new file
 1.1.6.2 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.1.6.1 11-Jul-2005  skrll file sunos_machdep.h was added on branch ktrace-lwp on 2005-11-10 13:57:09 +0000
 1.2.80.1 16-May-2008  yamt sync with head.
 1.2.78.1 18-May-2008  yamt sync with head.
 1.2.76.1 02-Jun-2008  mjf Sync with HEAD.
 1.2.18.2 21-Jun-2006  yamt sync with head.
 1.2.18.1 11-Dec-2005  yamt file sunos_machdep.h was added on branch yamt-lazymbuf on 2006-06-21 14:53:01 +0000
 1.6 19-Dec-2018  maxv Remove compat_svr4 and compat_svr4_32, as discussed on tech-kern@ recently,
but also as discussed several times in the past.
 1.5 28-Apr-2008  martin branches: 1.5.86; 1.5.88;
Remove clause 3 and 4 from TNF licenses
 1.4 11-Dec-2005  christos branches: 1.4.74; 1.4.76; 1.4.78;
merge ktrace-lwp.
 1.3 28-Aug-2004  thorpej De-__P
 1.2 13-Jul-2002  scw branches: 1.2.6;
m68k syscall rototill:

- Switch all m68k-based ports over to __HAVE_SYSCALL_INTERN.
- Add systrace glue.
- Define struct mdproc in <m68k/proc.h> instead of <machine/proc.h>.
(They were all defined exactly the same anyway, other than a couple
of the MDP_* flags.)
 1.1 19-Apr-1999  kleink branches: 1.1.2; 1.1.18; 1.1.22; 1.1.30;
Add COMPAT_SVR4 for m68k.
 1.1.30.1 16-Jul-2002  gehenna catch up with -current.
 1.1.22.1 01-Aug-2002  nathanw Catch up to -current.
 1.1.18.1 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.1.2.1 21-Jun-1999  thorpej Sync w/ -current.
 1.2.6.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.2.6.2 18-Sep-2004  skrll Sync with HEAD.
 1.2.6.1 03-Sep-2004  skrll Sync with HEAD
 1.4.78.1 16-May-2008  yamt sync with head.
 1.4.76.1 18-May-2008  yamt sync with head.
 1.4.74.1 02-Jun-2008  mjf Sync with HEAD.
 1.5.88.1 10-Jun-2019  christos Sync with HEAD
 1.5.86.1 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.5 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.4 07-Aug-2006  tsutsui branches: 1.4.58; 1.4.60; 1.4.62;
Remove __P().
 1.3 13-Apr-1999  kleink branches: 1.3.52; 1.3.66; 1.3.70;
* Declaration mismatch: len is a size_t, not a pointer to one.
* Userlevel header: remove argument names from declaration, use
__{BEGIN,END}_DECLS to ensure correct linkage.
 1.2 15-Feb-1999  hubertf branches: 1.2.2;
RCS ID police
 1.1 09-Feb-1999  is Provide a minimal instruction/data cache synchronization C binding.
(The function has always been in the kernels as special trap #12).
In response to PR 4951 by Hauke Fath.
 1.2.2.1 15-Apr-1999  kleink branches: 1.2.2.1.2;
Pull up rev. 1.3; approved by perry.
 1.2.2.1.2.1 21-Jun-1999  thorpej Sync w/ -current.
 1.3.70.1 11-Aug-2006  yamt sync with head
 1.3.66.1 09-Sep-2006  rpaulo sync with head
 1.3.52.1 30-Dec-2006  yamt sync with head.
 1.4.62.1 16-May-2008  yamt sync with head.
 1.4.60.1 18-May-2008  yamt sync with head.
 1.4.58.1 02-Jun-2008  mjf Sync with HEAD.
 1.3 22-Aug-2018  msaitoh - Cleanup for dynamic sysctl:
- Remove unused *_NAMES macros for sysctl.
- Remove unused *_MAXID for sysctls.
- Move CTL_MACHDEP sysctl definitions for m68k into m68k/include/cpu.h and
use them on all m68k machines.
 1.2 27-Feb-2008  xtraeme branches: 1.2.90; 1.2.92;
Remove CTL_MACHDEP_NAMES, it's not used anywhere.

Ok by martin@.
 1.1 17-Dec-1996  gwr branches: 1.1.78; 1.1.140; 1.1.160; 1.1.164;
CTL_MACHDEP definitions. (Common to all m68k ports.)
This should be included by each m68k port's cpu.h so
/usr/sbin/sysctl can be shared on all of them.
 1.1.164.1 03-Apr-2008  mjf Sync with HEAD.
 1.1.160.1 24-Mar-2008  keiichi sync with head.
 1.1.140.1 23-Mar-2008  matt sync with HEAD
 1.1.78.1 17-Mar-2008  yamt sync with head.
 1.2.92.1 10-Jun-2019  christos Sync with HEAD
 1.2.90.1 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.12 16-Oct-2024  isaki TAB/space cleanup.
 1.11 08-Feb-2011  rmind branches: 1.11.92;
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.10 11-Dec-2005  christos branches: 1.10.100; 1.10.106; 1.10.108;
merge ktrace-lwp.
 1.9 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.8 26-Oct-1994  cgd branches: 1.8.66;
new RCS ID format.
 1.7 23-May-1994  mycroft Add RCS ids.
 1.6 23-May-1994  mycroft Merge with 4.4-Lite.
 1.5 10-Apr-1994  chopps protect against multiple inclusion
 1.4 09-Jan-1994  mycroft Alias T_TRAP15 to T_BREAKPOINT globally.
 1.3 01-Aug-1993  mycroft Add RCS identifiers (this time on the correct side of the branch), and
incorporate recent changes in netbsd-0-9 branch.
 1.2 22-May-1993  cgd add rcsids to everything and clean up headers
 1.1 13-May-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.1 13-May-1993  cgd add hp300 kernel files. generic kernel files might need some help...
 1.8.66.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.8.66.2 18-Sep-2004  skrll Sync with HEAD.
 1.8.66.1 03-Aug-2004  skrll Sync with HEAD
 1.10.108.1 17-Feb-2011  bouyer Sync with HEAD
 1.10.106.1 06-Jun-2011  jruoho Sync with HEAD.
 1.10.100.1 05-Mar-2011  rmind sync with head
 1.11.92.1 02-Aug-2025  perseant Sync with HEAD
 1.34 24-Mar-2021  simonb s/depreciated/deprecated/g
 1.33 23-Jan-2016  christos branches: 1.33.30; 1.33.32;
expose the kernel types for standalone code.
 1.32 23-Jan-2016  christos Hide {p,v}{addr,size}_t and register_t (and a couple more types that
are machine-specific) from userland unless _KERNEL/_KMEMUSER and a
new _KERNTYPES variables is defined. The _KERNTYPES should be fixed
for many subsystems that should not be using it (rump)...
 1.31 27-Aug-2015  pooka Fix PTHREAD_FOO_INITIALIZER for C++ by not using volatile in the relevant
pthread types in C++ builds, attempt 2.

The problem with attempt 1 was making assumptions of what the MD
__cpu_simple_lock_t (declared volatile) looks like. To get a same type
except non-volatile, we change the MD type to __cpu_simple_lock_nv_t
and typedef __cpu_simple_lock_t as a volatile __cpu_simple_lock_nv_t.
IMO, __cpu_simple_lock_t should not be volatile at all, but changing it
now is too risky.

Fixes at least Rumprun w/ gcc 5.1/5.2. Furthermore, the mpd application
(and possibly others) will no longer require NetBSD-specific patches.

Tested: build.sh for i386, Rumprun for x86_64 w/ gcc 5.2.

Based on the patch from Christos in lib/49989.
 1.30 22-Nov-2011  joerg branches: 1.30.8; 1.30.26;
Add TLS support for m68k.
 1.29 22-Dec-2010  matt branches: 1.29.8;
Collect cpu_info and friends and move to m68k/include/cpu.h
Add a define __HAVE_CPU_DATA_FIRST which means that cpu_data is the first
member in struct cpu_info.
 1.28 11-Dec-2009  matt branches: 1.28.4;
Add PRIx{P,V}{ADDR,SIZE}, PRIu{P,V}SIZE, and PRIxREGISTER{,32,64} for all
(except where they will be added via merge). These should be used to print
{p,v}{addr,size}_t and register*_t as appropriate.
 1.27 17-Oct-2007  garbled branches: 1.27.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.26 02-Jun-2007  tsutsui branches: 1.26.10;
Add #define __NO_STRICT_ALIGNMENT.
 1.25 01-Jun-2007  skrll __HAVE_MD_RUNQUEUE is no longer relevant.
 1.24 24-Dec-2005  perry branches: 1.24.30; 1.24.32; 1.24.38;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.
 1.23 11-Dec-2005  christos merge ktrace-lwp.
 1.22 18-Jan-2004  martin branches: 1.22.16;
Do not export __HAVE_RAS to userland. Applications are supposed to try
rasctl() and detect failure with EOPNOTSUPP.
 1.21 26-Sep-2003  nathanw Move __cpu_simple_lock_t and __SIMPLELOCK_{UN,}LOCKED to machine/types.h
so that they can be used in a namespace-friendly way.
 1.20 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.19 28-Apr-2003  bjh21 branches: 1.19.2;
Add a new feature-test macro, _NETBSD_SOURCE. If this is defined
by the application, all NetBSD interfaces are made visible, even
if some other feature-test macro (like _POSIX_C_SOURCE) is defined.
<sys/featuretest.h> defined _NETBSD_SOURCE if none of _ANSI_SOURCE,
_POSIX_C_SOURCE and _XOPEN_SOURCE is defined, so as to preserve
existing behaviour.

This has two major advantages:
+ Programs that require non-POSIX facilities but define _POSIX_C_SOURCE
can trivially be overruled by putting -D_NETBSD_SOURCE in their CFLAGS.
+ It makes most of the #ifs simpler, in that they're all now ORs of the
various macros, rather than having checks for (!defined(_ANSI_SOURCE) ||
!defined(_POSIX_C_SOURCE) || !defined(_XOPEN_SOURCE)) all over the place.

I've tried not to change the semantics of the headers in any case where
_NETBSD_SOURCE wasn't defined, but there were some places where the
current semantics were clearly mad, and retaining them was harder than
correcting them. In particular, I've mostly normalised things so that
_ANSI_SOURCE gets you the smallest set of stuff, then _POSIX_C_SOURCE,
_XOPEN_SOURCE and _NETBSD_SOURCE in that order.

Tested by building for vax, encouraged by thorpej, and uncontested in
tech-userlevel for a week.
 1.18 17-Jan-2003  thorpej Merge the nathanw_sa branch.
 1.17 22-Sep-2002  simonb Use "#define\t" instead of "#define ".
 1.16 22-Sep-2002  gmcgarry Add __HAVE_MD_RUNQUEUE flag for MD code to override MI run queue primitives.
 1.15 13-Jul-2002  scw m68k syscall rototill:

- Switch all m68k-based ports over to __HAVE_SYSCALL_INTERN.
- Add systrace glue.
- Define struct mdproc in <m68k/proc.h> instead of <machine/proc.h>.
(They were all defined exactly the same anyway, other than a couple
of the MDP_* flags.)
 1.14 28-Apr-2001  kleink branches: 1.14.2; 1.14.8; 1.14.16;
* Move definitions of exact-width integer types from <machine/types.h>
to <sys/types.h> and <sys/stdint.h>.
* Add a new C99 <stdint.h> header, which provides integer types of
explicit width, related limits and integer constant macros.
* Extend <inttypes.h> to provide <stdint.h> definitions and format
macros for printf() and scanf().
* Add C99 strtoimax() and strtoumax() functions.
* Use the latter within scanf().
* Add C99 %j, %t and %z printf()/scanf() conversions for
intmax_t, pointer-type and size_t arguments.
 1.13 03-Jan-2001  takemura branches: 1.13.2;
replace 'long long' with int64_t to compile stand alone program with
compiler other than GCC.
 1.12 13-Aug-1998  eeh branches: 1.12.12;
Merge paddr_t changes into the main branch.
 1.11 14-Jun-1998  kleink branches: 1.11.2;
GC the unused `physadr' type, which was not able to hold a complete physical
address on 2 architectures anyhow. Also, move the definition of the `label_t'
type inside _KERNEL protection, since it is specific to the in-kernel
setjmp()/longjmp() implementations.
 1.10 05-Nov-1997  thorpej Mark uses of long long with /* LONGLONG */ for lint. From
Chris Demetriou <cgd@pa.dec.com>.
 1.9 06-Jul-1995  cgd branches: 1.9.18;
add <sys/cdefs.h> inclusions. namsspace-protect physadr, label_t
def'ns against _POSIX_SOURCE and _ANSI_SOURCE.
 1.8 26-Oct-1994  cgd new RCS ID format.
 1.7 20-Oct-1994  cgd update for new syscall args description mechanism
 1.6 20-Jul-1994  cgd define __BIT_TYPES_DEFINED__ for compatibility with things like BIND and nvi
 1.5 23-May-1994  cgd branches: 1.5.2;
can't use u_long
 1.4 10-Apr-1994  chopps protect against multiple inclusion
 1.3 14-Mar-1994  cgd add basic integral types (a la sparc port) that new nvi wants.
 1.2 22-May-1993  cgd add rcsids to everything and clean up headers
 1.1 13-May-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.1 13-May-1993  cgd add hp300 kernel files. generic kernel files might need some help...
 1.5.2.1 20-Jul-1994  cgd update from trunk.
 1.9.18.1 05-Nov-1997  thorpej Update from trunk: Mark usese of long long with /* LONGLONG */ for lint.
 1.11.2.2 12-Aug-1998  eeh Protect XOPEN and POSIX code from vm_offset_t, paddr_t, vaddr_t, vm_size_t, psize_t, and vsize_t.
 1.11.2.1 30-Jul-1998  eeh Split vm_offset_t and vm_size_t into paddr_t, psize_t, vaddr_t, and vsize_t.
 1.12.12.1 05-Jan-2001  bouyer Sync with HEAD
 1.13.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.14.16.1 16-Jul-2002  gehenna catch up with -current.
 1.14.8.4 18-Oct-2002  nathanw Catch up to -current.
 1.14.8.3 07-Oct-2002  gmcgarry All m68k ports now support RAS in the common cpu_switch().
 1.14.8.2 01-Aug-2002  nathanw Catch up to -current.
 1.14.8.1 28-Apr-2001  nathanw file types.h was added on branch nathanw_sa on 2002-08-01 02:42:16 +0000
 1.14.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.14.2.1 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.19.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.19.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.19.2.1 03-Aug-2004  skrll Sync with HEAD
 1.22.16.2 03-Sep-2007  yamt sync with head.
 1.22.16.1 21-Jun-2006  yamt sync with head.
 1.24.38.1 26-Jun-2007  garbled Sync with HEAD.
 1.24.32.1 11-Jul-2007  mjf Sync with head.
 1.24.30.1 09-Jun-2007  ad Sync with head.
 1.26.10.1 06-Nov-2007  matt sync with HEAD
 1.27.20.1 11-Mar-2010  yamt sync with head
 1.28.4.1 05-Mar-2011  rmind sync with head
 1.29.8.1 17-Apr-2012  yamt sync with head
 1.30.26.2 19-Mar-2016  skrll Sync with HEAD
 1.30.26.1 22-Sep-2015  skrll Sync with HEAD
 1.30.8.1 03-Dec-2017  jdolecek update from HEAD
 1.33.32.1 03-Apr-2021  thorpej Sync with HEAD.
 1.33.30.1 03-Apr-2021  thorpej Sync with HEAD.
 1.17 17-Jul-2011  joerg 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.16 11-Dec-2005  christos merge ktrace-lwp.
 1.15 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.14 26-Dec-1995  mycroft branches: 1.14.64;
Make the type of __builtin_va_list a long.
 1.13 26-Dec-1995  mycroft Use __builtin_va_alist.
 1.12 25-Dec-1995  mycroft Stylistic changes.
 1.11 25-Dec-1995  mycroft Update for GCC 2.7, and fix bugs.
 1.10 26-Mar-1995  briggs KERNEL -> _KERNEL
 1.9 28-Jan-1995  jtc ANSI says that <stdarg.h>'s va_end macro must expand to a void expression.
For consistancy, I'm changing <varargs.h> too.
 1.8 28-Dec-1994  cgd do the right thing with strange-sized varargs objects.
 1.7 26-Oct-1994  cgd new RCS ID format.
 1.6 15-Oct-1994  cgd make <stdarg.h> a symlink, and clean up ports' stdarg.h and varargs.h files.
 1.5 29-Jun-1994  deraadt _MACHINE_VARGS_H_
 1.4 21-May-1994  cgd update from lite
 1.3 16-May-1994  cgd USL copyright foo
 1.2 10-Apr-1994  chopps protect against multiple inclusion
 1.1 27-Jan-1994  pk move varargs stuff to arch/<machine>/include.
 1.14.64.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.14.64.2 18-Sep-2004  skrll Sync with HEAD.
 1.14.64.1 03-Aug-2004  skrll Sync with HEAD
 1.6 01-Feb-2024  andvar s/Prototol/Protocol/ and s/Umimplemented/Unimplemented/ in comments.
 1.5 19-Jan-2024  thorpej Ensuire VECO_TO_VECI() returns an 8-bit index.
 1.4 14-Jan-2024  thorpej Provide NAUTOVECTORS and NUSERVECTORS constants.
 1.3 13-Jan-2024  thorpej Expose saved_vbr directly.
 1.2 13-Jan-2024  thorpej Provide some vector table override hooks and interfaces needed by the
sun68k platforms.
 1.1 13-Jan-2024  thorpej Add a common vector table implementation for m68k platforms.
 1.1 01-Feb-2020  tsutsui branches: 1.1.2; 1.1.4; 1.1.8;
Add MAX/MIN PAGE_SIZE and PAGE_SHIFT definitions of m68k for jemalloc(3).

Background:
- All m68k ports have fixed PAGE_SIZE value in their kernels,
but each port uses different PAGE_SIZE value (4096 or 8192)
due to historical reasons.
- Currently module(7) binaries are built per each port so
all m68k kernel sources don't support run-time variable PAGE_SIZE.
- MI <uvm/uvm_param.h> assumes that the port supports a variable
PAGE_SIZE on module(7) builds if both MAX_PAGE_SIZE and MIN_PAGE_SIZE
are defined and they have different values.
- On the other hand, jemalloc(3) checks MAX_PAGE_SHIFT in
src/external/bsd/jemalloc/include/jemalloc/internal/jemalloc_internal_defs.h
for internal optimization.
- m68k ports share userland binaries (especially pkgsrc binaries)
among all ports, so we need to define MAX_PAGE_SHIFT as 13 to
support m68k ports where PAGE_SIZE==8192.
(though this would affect only if static binaries built on
4k page hosts are executed on 8k page hosts)

To solve these inconsistency on PAGE_SIZE definitions,
we should have an independent PAGE_SIZE related definitions
for userland, but it requires major reorganization.
For now (especially for netbsd-9) we define MAX/MIN PAGE_SIZE and
PAGE_SHIFT values in <m68k/vmparam.h> only in !defined(_KERNEL) case.

Discussed on source-changes-d@ and tech-kern@ with christos@ and thorpej@:
https://mail-index.netbsd.org/source-changes-d/2020/01/thread1.html#012035
https://mail-index.netbsd.org/tech-kern/2020/01/thread1.html#025954

Should be pulled up to netbsd-9.
 1.1.8.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.1.8.1 01-Feb-2020  martin file vmparam.h was added on branch phil-wifi on 2020-04-08 14:07:43 +0000
 1.1.4.2 29-Feb-2020  ad Sync with head.
 1.1.4.1 01-Feb-2020  ad file vmparam.h was added on branch ad-namecache on 2020-02-29 20:18:25 +0000
 1.1.2.2 10-Feb-2020  martin Pull up following revision(s) (requested by tsutsui in ticket #682):

sys/arch/next68k/include/vmparam.h: revision 1.27
sys/arch/mac68k/include/vmparam.h: revision 1.46
sys/arch/sun3/include/vmparam.h: revision 1.38
sys/arch/m68k/include/vmparam.h: revision 1.1
sys/arch/hp300/include/vmparam.h: revision 1.41
sys/arch/m68k/include/Makefile: revision 1.32
sys/arch/amiga/include/vmparam.h: revision 1.48
distrib/sets/lists/comp/ad.m68k: revision 1.63
sys/arch/x68k/include/vmparam.h: revision 1.40
sys/arch/mvme68k/include/vmparam.h: revision 1.38
sys/arch/luna68k/include/vmparam.h: revision 1.23
sys/arch/news68k/include/vmparam.h: revision 1.23
sys/arch/atari/include/vmparam.h: revision 1.34
sys/arch/cesfic/include/vmparam.h: revision 1.19

Add MAX/MIN PAGE_SIZE and PAGE_SHIFT definitions of m68k for jemalloc(3).

Background:
- All m68k ports have fixed PAGE_SIZE value in their kernels,
but each port uses different PAGE_SIZE value (4096 or 8192)
due to historical reasons.
- Currently module(7) binaries are built per each port so
all m68k kernel sources don't support run-time variable PAGE_SIZE.
- MI <uvm/uvm_param.h> assumes that the port supports a variable
PAGE_SIZE on module(7) builds if both MAX_PAGE_SIZE and MIN_PAGE_SIZE
are defined and they have different values.
- On the other hand, jemalloc(3) checks MAX_PAGE_SHIFT in
src/external/bsd/jemalloc/include/jemalloc/internal/jemalloc_internal_defs.h
for internal optimization.
- m68k ports share userland binaries (especially pkgsrc binaries)
among all ports, so we need to define MAX_PAGE_SHIFT as 13 to
support m68k ports where PAGE_SIZE==8192.
(though this would affect only if static binaries built on
4k page hosts are executed on 8k page hosts)

To solve these inconsistency on PAGE_SIZE definitions,
we should have an independent PAGE_SIZE related definitions
for userland, but it requires major reorganization.

For now (especially for netbsd-9) we define MAX/MIN PAGE_SIZE and
PAGE_SHIFT values in <m68k/vmparam.h> only in !defined(_KERNEL) case.

Discussed on source-changes-d@ and tech-kern@ with christos@ and thorpej@:
https://mail-index.netbsd.org/source-changes-d/2020/01/thread1.html#012035
https://mail-index.netbsd.org/tech-kern/2020/01/thread1.html#025954

Should be pulled up to netbsd-9.
 1.1.2.1 01-Feb-2020  martin file vmparam.h was added on branch netbsd-9 on 2020-02-10 18:46:40 +0000
 1.3 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.2 11-Dec-2005  christos branches: 1.2.74; 1.2.76; 1.2.78;
merge ktrace-lwp.
 1.1 08-May-2004  kleink branches: 1.1.2;
Factor out W{CHAR,INT}_{MAX,MIN} into their own header file.
 1.1.2.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.1.2.3 18-Sep-2004  skrll Sync with HEAD.
 1.1.2.2 03-Aug-2004  skrll Sync with HEAD
 1.1.2.1 08-May-2004  skrll file wchar_limits.h was added on branch ktrace-lwp on 2004-08-03 10:36:40 +0000
 1.2.78.1 16-May-2008  yamt sync with head.
 1.2.76.1 18-May-2008  yamt sync with head.
 1.2.74.1 02-Jun-2008  mjf Sync with HEAD.
 1.7 21-May-2007  tsutsui Remove unused m68k/bcopy.s.
(src/common/lib/libc/arch/m68k/string/bcopy.S in libkern is enough)
 1.6 11-Dec-2005  christos branches: 1.6.30; 1.6.32; 1.6.38;
merge ktrace-lwp.
 1.5 07-Aug-2003  agc branches: 1.5.16;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.4 10-Nov-1999  thorpej branches: 1.4.28;
Add register prefixes.
 1.3 12-Mar-1999  perry branches: 1.3.8; 1.3.10; 1.3.14;
exterminate ovbcopy. patches provided by Erik Bertelsen, pr-7145
 1.2 27-Feb-1998  thorpej Nuke memcpy() from here; it's in libkern.
 1.1 17-Mar-1997  gwr Separate bcopy and the copypage/zeropage stuff out of copy.s
so they can be used separately, and so the copyrights are
attributed to the right owners. (Catch-all files are bad)
 1.3.14.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.3.10.1 15-Nov-1999  fvdl Sync with -current
 1.3.8.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.4.28.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.4.28.2 18-Sep-2004  skrll Sync with HEAD.
 1.4.28.1 03-Aug-2004  skrll Sync with HEAD
 1.5.16.1 03-Sep-2007  yamt sync with head.
 1.6.38.1 22-May-2007  matt Update to HEAD.
 1.6.32.1 11-Jul-2007  mjf Sync with head.
 1.6.30.2 09-Jun-2007  ad Sync with head.
 1.6.30.1 27-May-2007  ad Sync with head.
 1.40 26-Sep-2023  tsutsui Remove trailing spaces and TABs.
 1.39 05-Jan-2023  tsutsui Fix out of bounds invalidate (and writeback) in bus_dmamap_sync(9) ops.

Detected by the POOL_REDZONE check in sys/kern/subr_pool.c that
has been activated if options DIAGNOSTIC is enabled on post netbsd-9.
The extra invalidate on DMASYNC_PREREAD op discards redzone pattern
data allocated right after an mbuf cluster without proper writeback
to memory so that it triggers false redzone assertions on freeing mbufs.
This bug was my botch in rev 1.25 committed 15 years ago. (sigh)

Fixes PR/57107 (kernel panic on -current when configuring network
with sn(4) on mac68k), as actually the bus_dma(9) op changes
in the past days were introduced for mac68k sn(4) improvements
by using the MI SONIC (src/sys/dev/ic/dp83932.c) driver.
https://mail-index.netbsd.org/port-mac68k/2007/06/01/0001.html

Should be pulled up to netbsd-9 and netbsd-10.
 1.38 26-Jul-2022  andvar branches: 1.38.4;
s/functin/function/ in copy pasted comment.
 1.37 05-Dec-2021  msaitoh s/from from/from/ in comment.
 1.36 19-Dec-2020  thorpej malloc(9) -> kmem(9)
 1.35 25-Oct-2013  martin branches: 1.35.34; 1.35.42;
Change a few __unused to __diagused/__debugused
 1.34 19-Oct-2013  martin Mark a variable that is only tested in DIAGNOSTIC kernels as potentially
unused.
 1.33 11-Jul-2012  rkujawa branches: 1.33.2; 1.33.4;
Add support for all 4 slots of G-REX 4000D and G-REX 1200. Also add
(untested yet) DMA support for G-REX bridges.
 1.32 19-Sep-2011  rkujawa branches: 1.32.2;
Move CACHELINE_* from bus_dma.c to cpu.h (needed for PCI configuration on amiga port).
 1.31 12-Nov-2010  uebayasi Pull in uvm/uvm.h where UVM's page level interface is used.
 1.30 06-Jun-2010  mrg fix PR 6724 - convert m68k options to defflag's. this means that
M680[12346] are now available from opt_m68k_arch.h. FPSP meantioned
in the PR has already been fixed, and i could not find any more.

i built these kernels to ensure i did not break their builds:

amiga: GENERIC DRACO
atari: HADES FALCON MILAN-PCIIDE
mac68k: GENERIC
sun2: GENERIC
sun3: GENERIC GENERIC3X
cesfic: attempted GENERIC, does not build due to lack of machine/bus.h
hp300: GENERIC
luna68k: GENERIC
mvme68k: GENERIC
news68k: GENERIC
next68k: GENERIC
x68k: GENERIC
 1.29 04-Jun-2008  ad branches: 1.29.18; 1.29.20;
vm_page: put TAILQ_ENTRY into a union with LIST_ENTRY, so we can use both.
 1.28 28-Apr-2008  martin branches: 1.28.2;
Remove clause 3 and 4 from TNF licenses
 1.27 17-Oct-2007  garbled branches: 1.27.16; 1.27.18; 1.27.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.26 09-Jun-2007  tsutsui branches: 1.26.10;
Fix pasto in previous.
 1.25 08-Jun-2007  tsutsui Unroll cache flush/purge ops per 8 cachelines (128bytes).
Improve MI Sonic xfer speed ~2%.
 1.24 07-Jun-2007  tsutsui Enable _pmap_set_page_cacheable(), _pmap_set_page_cacheinhibit() and
_pmap_page_is_cacheable() on all pmap_motorola.c ports and add
BUS_DMA_COHERENT support (from mvme68k) to common m68k bus_dma.c.

Tested with (not-yet-integrated) MI Sonic Ethernet driver on mac68k
http://mail-index.netbsd.org/port-mac68k/2007/06/07/0000.html
and ok'ed by thorpej.
 1.23 02-Jun-2007  tsutsui Fix bus_dmamap_sync(9) to do more proper cache flush operations.
Mostly taken from mvme68k.

Tested on (not yet integrated) mac68k SONIC Ethernet with MI dp83932.c.

XXX: should we also enable _pmap_set_page_cache{able,inhibit}()
XXX: functions in m68k/pmap_motorola.c for BUS_DMA_COHERENT support?
 1.22 05-Mar-2007  tsutsui branches: 1.22.2; 1.22.4; 1.22.10;
Use (char *) on pointer arith.
 1.21 04-Mar-2007  christos Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.20 21-Feb-2007  thorpej Replace the Mach-derived boolean_t type with the C99 bool type. A
future commit will replace use of TRUE and FALSE with true and false.
 1.19 22-Jul-2006  tsutsui branches: 1.19.10;
TAB/space cleanup.
 1.18 22-Jul-2006  tsutsui KNF, ANSIfy, de-__P(), bzero() -> memset()
 1.17 01-Mar-2006  yamt branches: 1.17.2;
merge yamt-uio_vmspace branch.

- use vmspace rather than proc or lwp where appropriate.
the latter is more natural to specify an address space.
(and less likely to be abused for random purposes.)
- fix a swdmover race.
 1.16 11-Dec-2005  christos branches: 1.16.2; 1.16.4; 1.16.6;
merge ktrace-lwp.
 1.15 24-Nov-2005  yamt bus_dmamem_map: honour BUS_DMA_NOWAIT. noted by Manuel Bouyer.
bus_space_map: always do NOWAIT allocation as it used to be before yamt-km.

we have too many copies!
 1.14 01-Apr-2005  yamt branches: 1.14.2; 1.14.8;
merge yamt-km branch.
- don't use managed mappings/backing objects for wired memory allocations.
save some resources like pv_entry. also fix (most of) PR/27030.
- simplify kernel memory management API.
- simplify pmap bootstrap of some ports.
- some related cleanups.
 1.13 09-Mar-2005  matt Add a dm_maxsegsz public member to bus_dmamap_t. This allows a user of the API
to select the maximum segment size for each bus_dmamap_load (up to the maxsegsz
supplied to bus_dmamap_create). dm_maxsegsz is reset to the value supplied to
bus_dmamap_create when the dmamap is unloaded.
 1.12 28-Nov-2004  thorpej branches: 1.12.4; 1.12.6;
bus_dmamap_load_mbuf(): Skip zero-length mbufs.
kern/24811
 1.11 16-Sep-2004  rumble Correct a few comment typos that have propagated through the
tree.
 1.10 16-May-2004  wiz "panicking" needs a k.
 1.9 04-Dec-2003  keihan netbsd.org -> NetBSD.org

All "netbsd.org" is now gone from src/sys/arch.
 1.8 29-Jun-2003  fvdl branches: 1.8.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.7 28-Jun-2003  darrenr Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V
 1.6 02-Apr-2003  thorpej Use PAGE_SIZE rather than NBPG.
 1.5 27-Sep-2002  provos remove trailing \n in panic(). approved perry.
 1.4 12-Jul-2002  scottr Correct misplaced #endif that causes compile-time error if
neither M68040 nor M68060 are configured into the kernel.
 1.3 04-Jul-2002  scottr Add (unimplemented) cases to handle the 68020 and 68030 to
bus_dmamap_sync(). This corrects a fatal bug on at least some 68030-
based Macs. Closes PR 17180.
 1.2 02-Jun-2002  drochner branches: 1.2.2;
move initialization of the "struct pglist" returned by uvm_pglistalloc()
from the calling code into uvm_pglistalloc() itself for consistency
and easier error handling
 1.1 10-Apr-2002  briggs branches: 1.1.2; 1.1.4; 1.1.6;
bus_dma(9) pulled pretty much verbatim from next68k.
 1.1.6.2 15-Jul-2002  thorpej pullup-1-6 ticket #497 (scottr).

Original log message:
Correct misplaced #endif that causes compile-time error if
neither M68040 nor M68060 are configured into the kernel.
 1.1.6.1 05-Jul-2002  lukem Pull up revision 1.3 (requested by scottr in ticket #435):
Add (unimplemented) cases to handle the 68020 and 68030 to
bus_dmamap_sync(). This corrects a fatal bug on at least some 68030-
based Macs. Closes PR 17180.
 1.1.4.2 16-Jul-2002  gehenna catch up with -current.
 1.1.4.1 14-Jul-2002  gehenna catch up with -current.
 1.1.2.5 18-Oct-2002  nathanw Catch up to -current.
 1.1.2.4 01-Aug-2002  nathanw Catch up to -current.
 1.1.2.3 20-Jun-2002  nathanw Catch up to -current.
 1.1.2.2 17-Apr-2002  nathanw Catch up to -current.
 1.1.2.1 10-Apr-2002  nathanw file bus_dma.c was added on branch nathanw_sa on 2002-04-17 00:03:30 +0000
 1.2.2.4 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.2.2.3 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.2.2.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.2.2.1 02-Jun-2002  jdolecek file bus_dma.c was added on branch kqueue on 2002-06-23 17:37:40 +0000
 1.8.2.7 11-Dec-2005  christos Sync with head.
 1.8.2.6 01-Apr-2005  skrll Sync with HEAD.
 1.8.2.5 18-Dec-2004  skrll Sync with HEAD.
 1.8.2.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.8.2.3 18-Sep-2004  skrll Sync with HEAD.
 1.8.2.2 03-Aug-2004  skrll Sync with HEAD
 1.8.2.1 02-Jul-2003  darrenr Apply the aborted ktrace-lwp changes to a specific branch. This is just for
others to review, I'm concerned that patch fuziness may have resulted in some
errant code being generated but I'll look at that later by comparing the diff
from the base to the branch with the file I attempt to apply to it. This will,
at the very least, put the changes in a better context for others to review
them and attempt to tinker with removing passing of 'struct lwp' through
the kernel.
 1.12.6.2 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.12.6.1 26-Jan-2005  yamt convert arch/m68k to new apis.
 1.12.4.1 29-Apr-2005  kent sync with -current
 1.14.8.1 29-Nov-2005  yamt sync with head.
 1.14.2.4 03-Sep-2007  yamt sync with head.
 1.14.2.3 26-Feb-2007  yamt sync with head.
 1.14.2.2 30-Dec-2006  yamt sync with head.
 1.14.2.1 21-Jun-2006  yamt sync with head.
 1.16.6.1 22-Apr-2006  simonb Sync with head.
 1.16.4.1 09-Sep-2006  rpaulo sync with head
 1.16.2.2 18-Feb-2006  yamt fix a typo.
 1.16.2.1 18-Feb-2006  yamt adapt bus_dma implementations.
 1.17.2.1 11-Aug-2006  yamt sync with head
 1.19.10.2 12-Mar-2007  rmind Sync with HEAD.
 1.19.10.1 27-Feb-2007  yamt - sync with head.
- move sched_changepri back to kern_synch.c as it doesn't know PPQ anymore.
 1.22.10.1 26-Jun-2007  garbled Sync with HEAD.
 1.22.4.1 11-Jul-2007  mjf Sync with head.
 1.22.2.2 15-Jul-2007  ad Sync with head.
 1.22.2.1 09-Jun-2007  ad Sync with head.
 1.26.10.1 06-Nov-2007  matt sync with HEAD
 1.27.20.3 11-Aug-2010  yamt sync with head.
 1.27.20.2 04-May-2009  yamt sync with head.
 1.27.20.1 16-May-2008  yamt sync with head.
 1.27.18.2 17-Jun-2008  yamt sync with head.
 1.27.18.1 18-May-2008  yamt sync with head.
 1.27.16.2 05-Jun-2008  mjf Sync with HEAD.

Also fix build.
 1.27.16.1 02-Jun-2008  mjf Sync with HEAD.
 1.28.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.29.20.2 05-Mar-2011  rmind sync with head
 1.29.20.1 03-Jul-2010  rmind sync with head
 1.29.18.2 16-Nov-2010  uebayasi Sync with HEAD.
 1.29.18.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.32.2.2 22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.32.2.1 30-Oct-2012  yamt sync with head
 1.33.4.1 18-May-2014  rmind sync with head
 1.33.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.35.42.1 03-Jan-2021  thorpej Sync w/ HEAD.
 1.35.34.1 07-Jan-2023  martin Pull up following revision(s) (requested by tsutsui in ticket #1564):

sys/arch/m68k/m68k/bus_dma.c: revision 1.39

Fix out of bounds invalidate (and writeback) in bus_dmamap_sync(9) ops.

Detected by the POOL_REDZONE check in sys/kern/subr_pool.c that
has been activated if options DIAGNOSTIC is enabled on post netbsd-9.

The extra invalidate on DMASYNC_PREREAD op discards redzone pattern
data allocated right after an mbuf cluster without proper writeback
to memory so that it triggers false redzone assertions on freeing mbufs.

This bug was my botch in rev 1.25 committed 15 years ago. (sigh)

Fixes PR/57107 (kernel panic on -current when configuring network
with sn(4) on mac68k), as actually the bus_dma(9) op changes
in the past days were introduced for mac68k sn(4) improvements
by using the MI SONIC (src/sys/dev/ic/dp83932.c) driver.

https://mail-index.netbsd.org/port-mac68k/2007/06/01/0001.html
 1.38.4.1 07-Jan-2023  martin Pull up following revision(s) (requested by tsutsui in ticket #39):

sys/arch/m68k/m68k/bus_dma.c: revision 1.39

Fix out of bounds invalidate (and writeback) in bus_dmamap_sync(9) ops.

Detected by the POOL_REDZONE check in sys/kern/subr_pool.c that
has been activated if options DIAGNOSTIC is enabled on post netbsd-9.

The extra invalidate on DMASYNC_PREREAD op discards redzone pattern
data allocated right after an mbuf cluster without proper writeback
to memory so that it triggers false redzone assertions on freeing mbufs.

This bug was my botch in rev 1.25 committed 15 years ago. (sigh)

Fixes PR/57107 (kernel panic on -current when configuring network
with sn(4) on mac68k), as actually the bus_dma(9) op changes
in the past days were introduced for mac68k sn(4) improvements
by using the MI SONIC (src/sys/dev/ic/dp83932.c) driver.

https://mail-index.netbsd.org/port-mac68k/2007/06/01/0001.html
 1.3 13-Jan-2024  thorpej Add buserr2030 and addrerr2030 aliases to busaddrerr2030.
 1.2 29-Apr-2023  isaki m68k: Support TT(Transparent Translation) for 020/030 buserror handler.
This avoids a panic when trying badaddr() against to an address where
bus error occurs in the TT region. Only luna68k and news68k use TT.
Discussed on port-m68k.
 1.1 15-Mar-2014  tsutsui branches: 1.1.4; 1.1.6; 1.1.10;
Add a common source of m68k bus error and address error handlers.

This will be included from each MD locore.s as other common m68k
asm files like trap_subr.s and support.s etc.
 1.1.10.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.10.1 15-Mar-2014  tls file busaddrerr.s was added on branch tls-maxphys on 2014-08-20 00:03:10 +0000
 1.1.6.2 22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.1.6.1 15-Mar-2014  yamt file busaddrerr.s was added on branch yamt-pagecache on 2014-05-22 11:39:56 +0000
 1.1.4.2 18-May-2014  rmind sync with head
 1.1.4.1 15-Mar-2014  rmind file busaddrerr.s was added on branch rmind-smpnet on 2014-05-18 17:45:16 +0000
 1.15 06-Jun-2010  mrg fix PR 6724 - convert m68k options to defflag's. this means that
M680[12346] are now available from opt_m68k_arch.h. FPSP meantioned
in the PR has already been fixed, and i could not find any more.

i built these kernels to ensure i did not break their builds:

amiga: GENERIC DRACO
atari: HADES FALCON MILAN-PCIIDE
mac68k: GENERIC
sun2: GENERIC
sun3: GENERIC GENERIC3X
cesfic: attempted GENERIC, does not build due to lack of machine/bus.h
hp300: GENERIC
luna68k: GENERIC
mvme68k: GENERIC
news68k: GENERIC
next68k: GENERIC
x68k: GENERIC
 1.14 28-Apr-2008  martin branches: 1.14.20; 1.14.22;
Remove clause 3 and 4 from TNF licenses
 1.13 17-Oct-2007  garbled branches: 1.13.16; 1.13.18; 1.13.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.12 08-Jun-2007  tsutsui branches: 1.12.10;
DCFA(), DCPA(), ICPL(), ICPP(), DCPL(), DCPP, DCFL(), and DCFP()
cache ops are identical between M68040 and M68060 and they are not
available on M68020 and M68030, so no need to check cputype even on
multi CPU kernels and they can always be inlined.

This improves MI Sonic xfer speed ~5%.
http://mail-index.netbsd.org/port-mac68k/2007/06/07/0003.html
 1.11 22-Jul-2006  tsutsui branches: 1.11.14; 1.11.16; 1.11.22;
KNF, ANSIfy, remove register decls
 1.10 11-Dec-2005  christos branches: 1.10.4; 1.10.8;
merge ktrace-lwp.
 1.9 10-Aug-2004  skrll branches: 1.9.12;
Include <sys/cdefs.h> once.
 1.8 15-Jul-2003  lukem __KERNEL_RCSID()
 1.7 02-Nov-2002  chs branches: 1.7.6;
finish conversion to the common m68k cacheops:
add support for machine-specific flavors of the ops for off-chip caches.
many thanks to Izumi Tsutsui for his help with this.
 1.6 15-Apr-2000  scw branches: 1.6.12;
Move <machine/cpu.h> above <m68k/*.h> so we get M680x0 #defines
for those m68k ports which define them in the former file.
 1.5 05-Apr-2000  is Bug fixes for 68020only or 68030only machines, by Aymeric Vincent.
 1.4 25-Sep-1999  is branches: 1.4.2;
Replace leftover vm_offset_t's by paddr_t or vaddr_t, as appropriate.
Rename variables/parameters from "va" to "pa" where they are a paddr_t.
Correct DCIAS to take a paddr_t (instead of vaddr_t).
 1.3 24-May-1998  is Back out the defopt for M680?0. As pointed out to me, this breaks ports which
dont use the M680?0 the way Amiga, Atari, Mac68k, and X68k do. I must have
missed this in the past discussion about this project.
 1.2 23-May-1998  is Move M680[2346]0 to opt_m68kcpu.h.
XXX Some explicit dependencies could be removed now from the individual
arch/$ARCH/conf/Makefile.$ARCH files, but this is still to be done.
 1.1 02-Jun-1997  leo An attempt to make a generic m68k implementation for cache control operations.
Not yet completely finished.
 1.4.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.6.12.1 11-Nov-2002  nathanw Catch up to -current
 1.7.6.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.7.6.3 18-Sep-2004  skrll Sync with HEAD.
 1.7.6.2 12-Aug-2004  skrll Sync with HEAD.
 1.7.6.1 03-Aug-2004  skrll Sync with HEAD
 1.9.12.2 03-Sep-2007  yamt sync with head.
 1.9.12.1 30-Dec-2006  yamt sync with head.
 1.10.8.1 11-Aug-2006  yamt sync with head
 1.10.4.1 09-Sep-2006  rpaulo sync with head
 1.11.22.1 26-Jun-2007  garbled Sync with HEAD.
 1.11.16.1 11-Jul-2007  mjf Sync with head.
 1.11.14.1 15-Jul-2007  ad Sync with head.
 1.12.10.1 06-Nov-2007  matt sync with HEAD
 1.13.20.2 11-Aug-2010  yamt sync with head.
 1.13.20.1 16-May-2008  yamt sync with head.
 1.13.18.1 18-May-2008  yamt sync with head.
 1.13.16.1 02-Jun-2008  mjf Sync with HEAD.
 1.14.22.1 03-Jul-2010  rmind sync with head
 1.14.20.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.15 08-Feb-2011  rmind Remove clause 3 (UCB advertising clause) from the University of Utah
copyright. Confirmed by Mike Hibler, mike at cs.utah.edu - thanks!
Also, merge UCB and Utah copyright texts back into one, as they
originally were.

Extra verification by snj@.
 1.14 23-Nov-2009  rmind branches: 1.14.4; 1.14.6; 1.14.8;
Use lwp_getpcb() on m68k ports, clean from struct user usage.
 1.13 24-Apr-2008  ad branches: 1.13.2; 1.13.4;
Merge proc::p_mutex and proc::p_smutex into a single adaptive mutex, since
we no longer need to guard against access from hardware interrupt handlers.

Additionally, if cloning a process with CLONE_SIGHAND, arrange to have the
child process share the parent's lock so that signal state may be kept in
sync. Partially addresses PR kern/37437.
 1.12 20-Dec-2007  dsl branches: 1.12.6; 1.12.8;
Convert all the system call entry points from:
int foo(struct lwp *l, void *v, register_t *retval)
to:
int foo(struct lwp *l, const struct foo_args *uap, register_t *retval)
Fixup compat code to not write into 'uap' and (in some cases) to actually
pass a correctly formatted 'uap' structure with the right name to the
next routine.
A few 'compat' routines that just call standard ones have been deleted.
All the 'compat' code compiles (along with the kernels required to test
build it).
98% done by automated scripts.
 1.11 09-Feb-2007  ad branches: 1.11.24; 1.11.32; 1.11.36;
Merge newlock2 to head.
 1.10 22-Jul-2006  tsutsui branches: 1.10.4;
- remove unused decls.
- remove parentheses from return arg
 1.9 11-Dec-2005  christos branches: 1.9.4; 1.9.8;
merge ktrace-lwp.
 1.8 14-Sep-2005  he Another set of files needing <compat/sys/signal.h> and
<compat/sys/signalvar.h> for native_sigset13_to_sigset().
 1.7 28-Aug-2004  thorpej branches: 1.7.12;
Use ANSI function decls and static.
 1.6 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.5 15-Jul-2003  lukem __KERNEL_RCSID()
 1.4 17-Jan-2003  thorpej branches: 1.4.2;
Merge the nathanw_sa branch.
 1.3 22-Dec-2000  jdolecek branches: 1.3.8;
split off thread specific stuff from struct sigacts to struct sigctx, leaving
only signal handler array sharable between threads
move other random signal stuff from struct proc to struct sigctx

This addresses kern/10981 by Matthew Orgass.
 1.2 16-Aug-1999  simonb branches: 1.2.2;
Spell "privilege" correctly (correct spelling from Jonathan Stone).
 1.1 01-Oct-1998  thorpej Implement compat_13_sys_sigreturn().
 1.2.2.1 05-Jan-2001  bouyer Sync with HEAD
 1.3.8.3 12-Jul-2002  nathanw No longer need to pull in lwp.h; proc.h pulls it in for us.
 1.3.8.2 29-May-2002  nathanw #include <sys/sa.h> before <sys/syscallargs.h>, to provide sa_upcall_t
now that <sys/param.h> doesn't include <sys/sa.h>.

(Behold the Power of Ed)
 1.3.8.1 17-Nov-2001  scw Kernel support for Scheduler Activations on m68k-based ports using
mvme68k as a testbed.

Boots multi-user on an mvme162, although userland support for SA is not
yet integrated/tested.
 1.4.2.5 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.4.2.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.4.2.3 18-Sep-2004  skrll Sync with HEAD.
 1.4.2.2 03-Sep-2004  skrll Sync with HEAD
 1.4.2.1 03-Aug-2004  skrll Sync with HEAD
 1.7.12.4 21-Jan-2008  yamt sync with head
 1.7.12.3 26-Feb-2007  yamt sync with head.
 1.7.12.2 30-Dec-2006  yamt sync with head.
 1.7.12.1 21-Jun-2006  yamt sync with head.
 1.9.8.1 11-Aug-2006  yamt sync with head
 1.9.4.1 09-Sep-2006  rpaulo sync with head
 1.10.4.2 06-Feb-2007  ad Make amiga & mac68k compile.
 1.10.4.1 30-Jan-2007  ad Remove support for SA. Ok core@.
 1.11.36.1 02-Jan-2008  bouyer Sync with HEAD
 1.11.32.1 26-Dec-2007  ad Sync with head.
 1.11.24.1 09-Jan-2008  matt sync with HEAD
 1.12.8.1 18-May-2008  yamt sync with head.
 1.12.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.13.4.2 14-May-2008  wrstuden Per discussion with ad at n dot o, revert signal mask handling
changes.

The l_sigstk changes are most likely totally un-needed as SA will
never use a signal stack - we send an upcall (or will as other
diffs are brought in).

The l_sigmask changes were too controvertial. In all honesty, I
think it's probably best to revert them. The main reason they were
there is the fact that in an SA process, we don't mask signals per
kernel thread, we mask them per user thread. In the kernel, we want
them all to get turned into upcalls. Thus the normal state of
l_sigmask in an SA process is for it to always be empty.

While we are in the process of delivering a signal, we want to
temporarily mask a signal (so we don't recursively exhaust our
upcall stacks). However signal delivery is rare (important, but
rare), and delivering back-to-back signals is even rarer. So rather
than cause every user of a signal mask to be prepared for this very
rare case, we will just add a second check later in the signal
delivery code. Said change is not in this diff.

This also un-compensates all of our compatability code for dealing
with SA. SA is a NetBSD-specific thing, so there's no need for
Irix, Linux, Solaris, SVR4 and so on to cope with it.

As previously, everything other than kern_sa.c compiles in i386
GENERIC as of this checkin. I will switch to ALL soon for compile
testing.
 1.13.4.1 10-May-2008  wrstuden Initial checkin of re-adding SA. Everything except kern_sa.c
compiles in GENERIC for i386. This is still a work-in-progress, but
this checkin covers most of the mechanical work (changing signalling
to be able to accomidate SA's process-wide signalling and re-adding
includes of sys/sa.h and savar.h). Subsequent changes will be much
more interesting.

Also, kern_sa.c has received partial cleanup. There's still more
to do, though.
 1.13.2.1 11-Mar-2010  yamt sync with head
 1.14.8.1 17-Feb-2011  bouyer Sync with HEAD
 1.14.6.1 06-Jun-2011  jruoho Sync with HEAD.
 1.14.4.1 05-Mar-2011  rmind sync with head
 1.8 17-Jan-2024  thorpej Make compat_13_sigreturn13.s and compat_16_sigreturn14.s build as their
own stand-alone files and G/C the now-empty sigreturn.s.
 1.7 07-Sep-2013  chs branches: 1.7.60;
switch to ELF naming for local labels.
 1.6 01-Aug-2013  matt Convert to motorola style.
 1.5 08-Feb-2011  rmind branches: 1.5.4; 1.5.14; 1.5.18;
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.4 11-Dec-2005  christos branches: 1.4.100; 1.4.106; 1.4.108;
merge ktrace-lwp.
 1.3 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.2 10-Nov-1999  thorpej branches: 1.2.28;
Add register prefixes.
 1.1 05-Oct-1998  thorpej branches: 1.1.12; 1.1.14; 1.1.18;
Fix a problem reported by Michael Hitch. Basically, our libc relies on the
non-standard way of invoking sigreturn, specifically a side-effect that I
overlooked. Thus, longjmp's return value was getting clobbered.

Sigh, so burn trap #3 just as sigreturn.

XXX We need an SVR4-style {get,set}context(2) to avoid wasting new
XXX trap vectors in the future.
 1.1.18.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.1.14.1 15-Nov-1999  fvdl Sync with -current
 1.1.12.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.2.28.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.2.28.2 18-Sep-2004  skrll Sync with HEAD.
 1.2.28.1 03-Aug-2004  skrll Sync with HEAD
 1.4.108.1 17-Feb-2011  bouyer Sync with HEAD
 1.4.106.1 06-Jun-2011  jruoho Sync with HEAD.
 1.4.100.1 05-Mar-2011  rmind sync with head
 1.5.18.2 18-May-2014  rmind sync with head
 1.5.18.1 28-Aug-2013  rmind sync with head
 1.5.14.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.5.4.1 22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.7.60.1 27-Jun-2024  martin Pull up following revision(s) (requested by rin in ticket #724
to fix build fallout on the branch):

sys/arch/m68k/m68k/compat_16_sigreturn14.s: revision 1.6
sys/arch/mvme68k/mvme68k/locore.s: revision 1.129
sys/arch/news68k/news68k/locore.s: revision 1.84
sys/arch/hp300/hp300/locore.s: revision 1.183
sys/arch/m68k/m68k/compat_13_sigreturn13.s: revision 1.8
sys/arch/m68k/m68k/sigreturn.s: file removal
sys/arch/m68k/include/pte_motorola.h: revision 1.10
sys/arch/atari/atari/locore.s: revision 1.125
sys/arch/amiga/amiga/locore.s: revision 1.169
sys/arch/sun2/sun2/locore.s: revision 1.37
sys/arch/next68k/next68k/locore.s: revision 1.84
sys/arch/x68k/x68k/locore.s: revision 1.130
sys/arch/sun3/sun3x/locore.s: revision 1.77
sys/arch/cesfic/cesfic/locore.s: revision 1.45
sys/arch/m68k/conf/files.m68k: revision 1.53
sys/arch/sun3/sun3/locore.s: revision 1.109
sys/arch/luna68k/luna68k/locore.s: revision 1.81
sys/arch/mac68k/mac68k/locore.s: revision 1.182

Define PTE used in the pmap module int terms of the bit definitions
in mmu_{51,40}.h.

Make compat_13_sigreturn13.s and compat_16_sigreturn14.s build as their
own stand-alone files and G/C the now-empty sigreturn.s.
 1.18 27-Oct-2021  thorpej Use the signal trampoline version constants from <sys/signal.h>.
 1.17 06-Apr-2019  thorpej Overhaul the API used to fetch and store individual memory cells in
userspace. The old fetch(9) and store(9) APIs (fubyte(), fuword(),
subyte(), suword(), etc.) are retired and replaced with new ufetch(9)
and ustore(9) APIs that can return proper error codes, etc. and are
implemented consistently across all platforms. The interrupt-safe
variants are no longer supported (and several of the existing attempts
at fuswintr(), etc. were buggy and not actually interrupt-safe).

Also augmement the ucas(9) API, making it consistently available on
all plaforms, supporting uniprocessor and multiprocessor systems, even
those that do not have CAS or LL/SC primitives.

Welcome to NetBSD 8.99.37.
 1.16 22-Dec-2011  tsutsui branches: 1.16.48;
Remove fuction declarations of m68881_restore() and m68881_save().
They are in <m68k/m68k.h>.
 1.15 08-Feb-2011  rmind branches: 1.15.4; 1.15.8;
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.14 23-Nov-2009  rmind branches: 1.14.4; 1.14.6; 1.14.8;
Use lwp_getpcb() on m68k ports, clean from struct user usage.
 1.13 25-Nov-2008  tsutsui Add #ifdef _KERNEL_OPT.
 1.12 24-Apr-2008  ad branches: 1.12.2; 1.12.4; 1.12.8; 1.12.10;
Merge proc::p_mutex and proc::p_smutex into a single adaptive mutex, since
we no longer need to guard against access from hardware interrupt handlers.

Additionally, if cloning a process with CLONE_SIGHAND, arrange to have the
child process share the parent's lock so that signal state may be kept in
sync. Partially addresses PR kern/37437.
 1.11 20-Dec-2007  dsl branches: 1.11.6; 1.11.8;
Convert all the system call entry points from:
int foo(struct lwp *l, void *v, register_t *retval)
to:
int foo(struct lwp *l, const struct foo_args *uap, register_t *retval)
Fixup compat code to not write into 'uap' and (in some cases) to actually
pass a correctly formatted 'uap' structure with the right name to the
next routine.
A few 'compat' routines that just call standard ones have been deleted.
All the 'compat' code compiles (along with the kernels required to test
build it).
98% done by automated scripts.
 1.10 04-Mar-2007  christos branches: 1.10.20; 1.10.28; 1.10.32;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.9 09-Feb-2007  ad branches: 1.9.2;
Merge newlock2 to head.
 1.8 22-Jul-2006  tsutsui branches: 1.8.4;
TAB/space cleanup.
 1.7 22-Jul-2006  tsutsui KNF and misc cosmetics
 1.6 11-Dec-2005  christos branches: 1.6.4; 1.6.8;
merge ktrace-lwp.
 1.5 14-Sep-2005  he Another set of files needing <compat/sys/signal.h> and
<compat/sys/signalvar.h> for native_sigset13_to_sigset().
 1.4 28-Aug-2004  thorpej branches: 1.4.12;
Use ANSI function decls and static.
 1.3 08-Oct-2003  thorpej branches: 1.3.4;
* Shuffle some data structures so, and add a flags word to ksiginfo_t.
Right now the only flag is used to indicate if a ksiginfo_t is a
result of a trap. Add a predicate macro to test for this flag.
* Add initialization macros for ksiginfo_t's.
* Add accssor macro for ksi_trap. Expands to 0 if the ksiginfo_t was
not the result of a trap. This matches the sigcontext trapcode semantics.
* In kpsendsig(), use KSI_TRAP_P() to select the lwp that gets the signal.
Inspired by Matthias Drochner's fix to kpsendsig(), but correctly handles
the case of non-trap-generated signals that have a > 0 si_code.

This patch fixes a signal delivery problem with threaded programs noted by
Matthias Drochner on tech-kern.

As discussed on tech-kern. Reviewed and OK's by Christos.
 1.2 25-Sep-2003  christos constify siginfo/trapsignal
 1.1 22-Sep-2003  cl SA_SIGINFO support for m68k
 1.3.4.6 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.3.4.5 21-Sep-2004  skrll Fix the sync with head I botched.
 1.3.4.4 18-Sep-2004  skrll Sync with HEAD.
 1.3.4.3 03-Sep-2004  skrll Sync with HEAD
 1.3.4.2 03-Aug-2004  skrll Sync with HEAD
 1.3.4.1 08-Oct-2003  skrll file compat_16_machdep.c was added on branch ktrace-lwp on 2004-08-03 10:36:59 +0000
 1.4.12.5 21-Jan-2008  yamt sync with head
 1.4.12.4 03-Sep-2007  yamt sync with head.
 1.4.12.3 26-Feb-2007  yamt sync with head.
 1.4.12.2 30-Dec-2006  yamt sync with head.
 1.4.12.1 21-Jun-2006  yamt sync with head.
 1.6.8.1 11-Aug-2006  yamt sync with head
 1.6.4.1 09-Sep-2006  rpaulo sync with head
 1.8.4.2 06-Feb-2007  ad Make amiga & mac68k compile.
 1.8.4.1 30-Jan-2007  ad Remove support for SA. Ok core@.
 1.9.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.10.32.1 02-Jan-2008  bouyer Sync with HEAD
 1.10.28.1 26-Dec-2007  ad Sync with head.
 1.10.20.1 09-Jan-2008  matt sync with HEAD
 1.11.8.1 18-May-2008  yamt sync with head.
 1.11.6.2 17-Jan-2009  mjf Sync with HEAD.
 1.11.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.12.10.1 19-Jan-2009  skrll Sync with HEAD.
 1.12.8.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.12.4.3 14-May-2008  wrstuden Per discussion with ad at n dot o, revert signal mask handling
changes.

The l_sigstk changes are most likely totally un-needed as SA will
never use a signal stack - we send an upcall (or will as other
diffs are brought in).

The l_sigmask changes were too controvertial. In all honesty, I
think it's probably best to revert them. The main reason they were
there is the fact that in an SA process, we don't mask signals per
kernel thread, we mask them per user thread. In the kernel, we want
them all to get turned into upcalls. Thus the normal state of
l_sigmask in an SA process is for it to always be empty.

While we are in the process of delivering a signal, we want to
temporarily mask a signal (so we don't recursively exhaust our
upcall stacks). However signal delivery is rare (important, but
rare), and delivering back-to-back signals is even rarer. So rather
than cause every user of a signal mask to be prepared for this very
rare case, we will just add a second check later in the signal
delivery code. Said change is not in this diff.

This also un-compensates all of our compatability code for dealing
with SA. SA is a NetBSD-specific thing, so there's no need for
Irix, Linux, Solaris, SVR4 and so on to cope with it.

As previously, everything other than kern_sa.c compiles in i386
GENERIC as of this checkin. I will switch to ALL soon for compile
testing.
 1.12.4.2 14-May-2008  wrstuden Per discussion with ad, remove most of the #include <sys/sa.h> lines
as they were including sa.h just for the type(s) needed for syscallargs.h.

Instead, create a new file, sys/satypes.h, which contains just the
types needed for syscallargs.h. Yes, there's only one now, but that
may change and it's probably more likely to change if it'd be difficult
to handle. :-)

Per discussion with matt at n dot o, add an include of satypes.h to
sigtypes.h. Upcall handlers are kinda signal handlers, and signalling
is the header file that's already included for syscallargs.h that
closest matches SA.

This shaves about 3000 lines off of the diff of the branch relative
to the base. That also represents about 18% of the total before this
checkin.

I think this reduction is very good thing.
 1.12.4.1 10-May-2008  wrstuden Initial checkin of re-adding SA. Everything except kern_sa.c
compiles in GENERIC for i386. This is still a work-in-progress, but
this checkin covers most of the mechanical work (changing signalling
to be able to accomidate SA's process-wide signalling and re-adding
includes of sys/sa.h and savar.h). Subsequent changes will be much
more interesting.

Also, kern_sa.c has received partial cleanup. There's still more
to do, though.
 1.12.2.2 11-Mar-2010  yamt sync with head
 1.12.2.1 04-May-2009  yamt sync with head.
 1.14.8.1 17-Feb-2011  bouyer Sync with HEAD
 1.14.6.1 06-Jun-2011  jruoho Sync with HEAD.
 1.14.4.1 05-Mar-2011  rmind sync with head
 1.15.8.1 18-Feb-2012  mrg merge to -current.
 1.15.4.1 17-Apr-2012  yamt sync with head
 1.16.48.1 10-Jun-2019  christos Sync with HEAD
 1.7 31-Oct-2024  isaki Fix indent.
 1.6 17-Jan-2024  thorpej branches: 1.6.2;
Make compat_13_sigreturn13.s and compat_16_sigreturn14.s build as their
own stand-alone files and G/C the now-empty sigreturn.s.
 1.5 07-Sep-2013  chs branches: 1.5.60;
switch to ELF naming for local labels.
 1.4 01-Aug-2013  matt Convert to motorola style.
 1.3 08-Feb-2011  rmind branches: 1.3.4; 1.3.14; 1.3.18;
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.2 11-Dec-2005  christos branches: 1.2.100; 1.2.106; 1.2.108;
merge ktrace-lwp.
 1.1 22-Sep-2003  cl branches: 1.1.4;
SA_SIGINFO support for m68k
 1.1.4.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.1.4.3 18-Sep-2004  skrll Sync with HEAD.
 1.1.4.2 03-Aug-2004  skrll Sync with HEAD
 1.1.4.1 22-Sep-2003  skrll file compat_16_sigreturn14.s was added on branch ktrace-lwp on 2004-08-03 10:36:59 +0000
 1.2.108.1 17-Feb-2011  bouyer Sync with HEAD
 1.2.106.1 06-Jun-2011  jruoho Sync with HEAD.
 1.2.100.1 05-Mar-2011  rmind sync with head
 1.3.18.2 18-May-2014  rmind sync with head
 1.3.18.1 28-Aug-2013  rmind sync with head
 1.3.14.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.3.4.1 22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.5.60.1 27-Jun-2024  martin Pull up following revision(s) (requested by rin in ticket #724
to fix build fallout on the branch):

sys/arch/m68k/m68k/compat_16_sigreturn14.s: revision 1.6
sys/arch/mvme68k/mvme68k/locore.s: revision 1.129
sys/arch/news68k/news68k/locore.s: revision 1.84
sys/arch/hp300/hp300/locore.s: revision 1.183
sys/arch/m68k/m68k/compat_13_sigreturn13.s: revision 1.8
sys/arch/m68k/m68k/sigreturn.s: file removal
sys/arch/m68k/include/pte_motorola.h: revision 1.10
sys/arch/atari/atari/locore.s: revision 1.125
sys/arch/amiga/amiga/locore.s: revision 1.169
sys/arch/sun2/sun2/locore.s: revision 1.37
sys/arch/next68k/next68k/locore.s: revision 1.84
sys/arch/x68k/x68k/locore.s: revision 1.130
sys/arch/sun3/sun3x/locore.s: revision 1.77
sys/arch/cesfic/cesfic/locore.s: revision 1.45
sys/arch/m68k/conf/files.m68k: revision 1.53
sys/arch/sun3/sun3/locore.s: revision 1.109
sys/arch/luna68k/luna68k/locore.s: revision 1.81
sys/arch/mac68k/mac68k/locore.s: revision 1.182

Define PTE used in the pmap module int terms of the bit definitions
in mmu_{51,40}.h.

Make compat_13_sigreturn13.s and compat_16_sigreturn14.s build as their
own stand-alone files and G/C the now-empty sigreturn.s.
 1.6.2.1 02-Aug-2025  perseant Sync with HEAD
 1.50 26-Sep-2023  tsutsui TAB/space cleanup.
 1.49 30-Jun-2020  maxv Make copystr() a MI C function, part of libkern and shared on all
architectures.

Notes:

- On alpha and ia64 the function is kept but gets renamed locally to avoid
symbol collision. This is because on these two arches, I am not sure
whether the ASM callers do not rely on fixed registers, so I prefer to
keep the ASM body for now.
- On Vax, only the symbol is removed, because the body is used from other
functions.
- On RISC-V, this change fixes a bug: copystr() was just a wrapper around
strlcpy(), but strlcpy() makes the operation less safe (strlen on the
source beyond its size).
- The kASan, kCSan and kMSan wrappers are removed, because now that
copystr() is in C, the compiler transformations are applied to it,
without the need for manual wrappers.

Could test on amd64 only, but should be fine.
 1.48 12-Apr-2019  thorpej Fix an asm-comments-vs-preprocessor-line-continuations mistake in
UFETCH_PROLOGUE and USTORE_PROLOGUE that caused a couple of important
instructions to be omitted, resulting in a fatal trap.

Thanks isaki@ for finding my mistake and providing the fix!
 1.47 06-Apr-2019  thorpej Overhaul the API used to fetch and store individual memory cells in
userspace. The old fetch(9) and store(9) APIs (fubyte(), fuword(),
subyte(), suword(), etc.) are retired and replaced with new ufetch(9)
and ustore(9) APIs that can return proper error codes, etc. and are
implemented consistently across all platforms. The interrupt-safe
variants are no longer supported (and several of the existing attempts
at fuswintr(), etc. were buggy and not actually interrupt-safe).

Also augmement the ucas(9) API, making it consistently available on
all plaforms, supporting uniprocessor and multiprocessor systems, even
those that do not have CAS or LL/SC primitives.

Welcome to NetBSD 8.99.37.
 1.46 14-Mar-2019  thorpej G/C "MAPPECOPY". It is the deadest of wood, and never actually worked in
NetBSD.
 1.45 07-Sep-2013  chs branches: 1.45.30;
switch to ELF naming for local labels.
 1.44 22-Jul-2013  matt Move to motorola syntax
Change all branches to use j.. instead of b.. (branches now use byte offsets)
(this causes it to go from 932 to 848 bytes of text)
Add GETCURPCB macro.
(binary identical before the b -> j changes)
 1.43 07-Jul-2010  chs branches: 1.43.8; 1.43.18; 1.43.22; 1.43.30;
implement ucas_* for m68k.
 1.42 20-Mar-2010  chs fix copy{in,out}{,str}() to return the error returned by uvm_fault().
fixes PR 41813.
 1.41 28-Apr-2008  martin branches: 1.41.20; 1.41.22;
Remove clause 3 and 4 from TNF licenses
 1.40 04-Mar-2007  christos branches: 1.40.40; 1.40.42; 1.40.44;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.39 11-Dec-2005  christos branches: 1.39.26;
merge ktrace-lwp.
 1.38 07-Aug-2003  agc branches: 1.38.16;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.37 28-Jul-2001  tsutsui branches: 1.37.6; 1.37.22;
bcopy -> memcpy
 1.36 10-Nov-1999  thorpej branches: 1.36.8;
Add register prefixes.
 1.35 07-Nov-1999  chs in copy{in,out,}str(), return an error if maxlen == 0.
 1.34 01-May-1999  kleink branches: 1.34.2; 1.34.4; 1.34.8;
Use _C_LABEL() for [fs]ubail symbols.
 1.33 24-Mar-1999  mrg branches: 1.33.4;
completely remove Mach VM support. all that is left is the all the
header files as UVM still uses (most of) these.
 1.32 15-Aug-1998  mycroft Assign my copyrights to TNF.
 1.31 15-Aug-1998  mycroft Make copyright notices with my name consistent.
 1.30 04-Mar-1998  thorpej In kcopy(), make sure we save and restore the old fault handler; kcopy()
is called from uiomove(), which may be in the code path of servicing
a non-fatal page fault caused by a copyin() or copyout().

Originally suggested by Steve Woodford.
 1.29 15-Feb-1998  thorpej Implement kcopy(), like bcopy(), but aborts if a fault is encountered.
Required for UVM.
 1.28 21-May-1997  jeremy Comment for susword was from fusword and hadn't been changed.
 1.27 25-Apr-1997  thorpej - Don't make assumptions about how C labels are handled.
- Use PANIC() where appropriate.
 1.26 17-Mar-1997  gwr Separate bcopy and copypage stuff from copy.s
 1.25 02-Feb-1997  thorpej Add two optimized functions used by pmap.c:
- copypage() -- a single page-aligned NBPG-byte copy.
- zeropage() -- a single page-aligned NBPG-byte zero.
These functions don't play around with alignment, etc. Their use
causes a measureable performance improvement in pmap_copy_page()
and pmap_copy_page().

A few m68k ports already had copypage() in their locore.s. It has
been moved here so it can be shared.
 1.24 20-Jul-1996  jtc Provide alternate memmove() entrypoint for memcpy(). This will help
in the transition from b*() to mem*().
 1.23 02-Feb-1996  mycroft assym.s -> assym.h
(Some ports did this already.)
 1.22 11-Dec-1995  thorpej Move bcopy/ovbcopy/memcpy into m68/m68k/copy.s, which is used by all
m68k ports already anyhow. No use in keeping 6 identical copies of this
function around.
 1.21 11-Feb-1995  mycroft Fix typos copied from i386 code.
 1.20 11-Feb-1995  gwr Make most of the labels local (start with "L")
Remove sun3-specific code (no longer necessary)
Add diagnostic to verify correct sfc/dfc (applies to all m68k).
 1.19 08-Feb-1995  mycroft Change comment style to match the rest of locore.
 1.18 08-Feb-1995  mycroft Oops. Change the su*() functions back to using d0, to avoid conflict with
the Sun 3 code.
 1.17 08-Feb-1995  mycroft Add fu/su functions from hp300, modified for Sun 3.
 1.16 08-Feb-1995  mycroft The count argument is always unsigned.
 1.15 08-Feb-1995  mycroft Pull in necessary include files to make the stand-alone.
 1.14 08-Feb-1995  mycroft Minor change.
 1.13 08-Feb-1995  mycroft Copy hp300 version, with Sun 3 sfc/dfc frobnication added.
 1.12 26-Oct-1994  cgd new RCS ID format.
 1.11 06-May-1994  briggs Add fuswintr and suswintr.
 1.10 28-Feb-1994  chopps copyinstr: 4321, not 2143 :^) also removed a couple beq's. fixes from
Michael Hitch.
 1.9 23-Jan-1994  cgd use <machine/asm.h> rather than "m68k/asm.h"
 1.8 22-Jan-1994  briggs Add include of "m68k/asm.h" and ditch ENTRY/ALTENTRY defines.
 1.7 22-Jan-1994  briggs Add includes and ENTRY defs so it will compile.
Fixup copyinstr to get rid of 64k limitation on maxlength.
Non-optimal solution--needs to be sped up, and other functions need to
be fixed to overcome same limitation.
 1.6 21-Jan-1994  cgd kill the TWOENTRY gunk
 1.5 21-Jan-1994  cgd move over from the sun3 tree, and generalize so that the sun3 sfc/dfc
twiddling doesn't happen on the rest of the archs. this file should
be included by m68k ports via '#include "m68k/copy.s"' at the end of
locore. arguably, it should be linked in from a seperate .o, but
i can't untangle the necessary include file inclusions w/o a m68k to
compile on.
 1.4 12-Oct-1993  glass sun3 port updated. netboot integrated.
 1.3 28-Aug-1993  glass last snapshot before uploading. we still have serious clock problems
 1.2 02-Aug-1993  glass cleanup, one time compile with -Wall, include systm.h
conversion to new asm.h, removal of ALTENTRY(), ENTRY() pairs replaced by
TWOENTRY().
moved idprom fetching stuff to sun3_startup
bug fixes to pmap
added to sun3_startup.c support for initializing the vm layout, and for
verifying the hardware vs the -Ds from config(8)
still doesn't link. but list is much shorter, and much stupider
 1.1 27-Jun-1993  glass clock.c: now compiles even if address is bogus :)
conf.c: compiled, until prom addition :)
cons.c: add entry for prom driver
lib.s: remove some includes; we're being included by locore.s
locore.s: include asm.h, syscall.h, add icode
m68k.s: now included by locore.s
added signal.s; contains signal support
sun3_startup.c: fixed compile bug in vector table initialization; fixed mon
usage
swapgeneric.c: doesn't refer to drivers we don't have
 1.33.4.1 21-Jun-1999  thorpej Sync w/ -current.
 1.34.8.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.34.4.1 15-Nov-1999  fvdl Sync with -current
 1.34.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.36.8.1 03-Aug-2001  lukem update to -current
 1.37.22.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.37.22.2 18-Sep-2004  skrll Sync with HEAD.
 1.37.22.1 03-Aug-2004  skrll Sync with HEAD
 1.37.6.2 28-Jul-2001  tsutsui bcopy -> memcpy
 1.37.6.1 28-Jul-2001  tsutsui file copy.s was added on branch nathanw_sa on 2001-07-28 13:08:35 +0000
 1.38.16.1 03-Sep-2007  yamt sync with head.
 1.39.26.1 12-Mar-2007  rmind Sync with HEAD.
 1.40.44.2 11-Aug-2010  yamt sync with head.
 1.40.44.1 16-May-2008  yamt sync with head.
 1.40.42.1 18-May-2008  yamt sync with head.
 1.40.40.1 02-Jun-2008  mjf Sync with HEAD.
 1.41.22.2 05-Mar-2011  rmind sync with head
 1.41.22.1 30-May-2010  rmind sync with head
 1.41.20.2 17-Aug-2010  uebayasi Sync with HEAD.
 1.41.20.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.43.30.1 23-Jul-2013  riastradh sync with HEAD
 1.43.22.2 18-May-2014  rmind sync with head
 1.43.22.1 28-Aug-2013  rmind sync with head
 1.43.18.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.43.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.45.30.1 10-Jun-2019  christos Sync with HEAD
 1.17 26-Sep-2023  tsutsui Remove trailing spaces and TABs.
 1.16 07-Sep-2013  chs switch to ELF naming for local labels.
 1.15 01-Aug-2013  matt Convert to motorola style.
 1.14 06-Jun-2010  mrg branches: 1.14.8; 1.14.18; 1.14.22;
fix PR 6724 - convert m68k options to defflag's. this means that
M680[12346] are now available from opt_m68k_arch.h. FPSP meantioned
in the PR has already been fixed, and i could not find any more.

i built these kernels to ensure i did not break their builds:

amiga: GENERIC DRACO
atari: HADES FALCON MILAN-PCIIDE
mac68k: GENERIC
sun2: GENERIC
sun3: GENERIC GENERIC3X
cesfic: attempted GENERIC, does not build due to lack of machine/bus.h
hp300: GENERIC
luna68k: GENERIC
mvme68k: GENERIC
news68k: GENERIC
next68k: GENERIC
x68k: GENERIC
 1.13 28-Apr-2008  martin branches: 1.13.20; 1.13.22;
Remove clause 3 and 4 from TNF licenses
 1.12 25-Feb-2006  wiz branches: 1.12.68; 1.12.70; 1.12.72;
Fix some typos.
 1.11 11-Dec-2005  christos branches: 1.11.2; 1.11.4; 1.11.6;
merge ktrace-lwp.
 1.10 04-Dec-2003  keihan branches: 1.10.16;
netbsd.org -> NetBSD.org

All "netbsd.org" is now gone from src/sys/arch.
 1.9 08-Apr-2003  thorpej branches: 1.9.2;
Use PAGE_SIZE rather than NBPG.
 1.8 18-May-2001  fredette branches: 1.8.8;
Only on the 68010, assemble versions of copypage
and zeropage that use the 68010's loop mode.
 1.7 10-Nov-1999  thorpej branches: 1.7.6;
Add register prefixes.
 1.6 24-May-1998  is branches: 1.6.14; 1.6.16; 1.6.20;
Back out the defopt for M680?0. As pointed out to me, this breaks ports which
dont use the M680?0 the way Amiga, Atari, Mac68k, and X68k do. I must have
missed this in the past discussion about this project.
 1.5 23-May-1998  is Move M680[2346]0 to opt_m68kcpu.h.
XXX Some explicit dependencies could be removed now from the individual
arch/$ARCH/conf/Makefile.$ARCH files, but this is still to be done.
 1.4 30-May-1997  jtc fix tipo
 1.3 30-May-1997  jtc New zeropage() implementation based on code contributed by Hiroshi Horitomo
<horimoto@cs-aoi.cs.sist.ac.jp> in PR #3641. I changed the code slightly.
Instead of clearing 13 registers (d1-d7,a1-a6) and zeroing 512 bytes per
loop iteration, I clear 8 registers (d1-d7,a1) and zero 256 bytes. This
reduces the size and complexity of the function.

On the '020, the simpler code is less than 1% slower. Surprisingly, it
is ~3% faster on the '040.
 1.2 29-May-1997  jtc Use movw when loading countdown registers.
 1.1 17-Mar-1997  gwr Separate bcopy and the copypage/zeropage stuff out of copy.s
so they can be used separately, and so the copyrights are
attributed to the right owners. (Catch-all files are bad)
 1.6.20.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.6.16.1 15-Nov-1999  fvdl Sync with -current
 1.6.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.7.6.1 21-Jun-2001  nathanw Catch up to -current.
 1.8.8.2 18-May-2001  fredette Only on the 68010, assemble versions of copypage
and zeropage that use the 68010's loop mode.
 1.8.8.1 18-May-2001  fredette file copypage.s was added on branch nathanw_sa on 2001-05-18 15:31:39 +0000
 1.9.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.9.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.9.2.1 03-Aug-2004  skrll Sync with HEAD
 1.10.16.1 21-Jun-2006  yamt sync with head.
 1.11.6.1 22-Apr-2006  simonb Sync with head.
 1.11.4.1 09-Sep-2006  rpaulo sync with head
 1.11.2.1 01-Mar-2006  yamt sync with head.
 1.12.72.2 11-Aug-2010  yamt sync with head.
 1.12.72.1 16-May-2008  yamt sync with head.
 1.12.70.1 18-May-2008  yamt sync with head.
 1.12.68.1 02-Jun-2008  mjf Sync with HEAD.
 1.13.22.1 03-Jul-2010  rmind sync with head
 1.13.20.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.14.22.2 18-May-2014  rmind sync with head
 1.14.22.1 28-Aug-2013  rmind sync with head
 1.14.18.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.14.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.8 20-Dec-2023  thorpej Remove unnecessary <sys/malloc.h> include.
 1.7 20-Nov-2019  pgoyette Move all non-emulation-specific coredump code into the coredump module,
and remove all #ifdef COREDUMP conditional compilation. Now, the
coredump module is completely separated from the emulation modules, and
they can all be independently loaded and unloaded.

Welcome to 9.99.18 !
 1.6 04-Jan-2014  dsl branches: 1.6.30;
Remove __HAVE_PROCESS_XFPREGS and add the extra parameter for the size
of the fp save area to all the process_read_fpregs() and
process_write_fpregs() functions.
None of the functions have been modified to use the new parameters.
The size is set for all the writes, but some of the arch-specific reads
just pass NULL.
The amd64 (and i386) need variable sized fp register save areas in order
to support AVX and other enhanced register areas.
These functions are rarely called - so the extra argument won't matter.
 1.5 01-Jan-2014  dsl Change the type of the 'cookie' that holds the state of the core dump file
from 'void *' to the actual type 'struct coredump_iostate *'.
In most of the code the contents of the structure are still unknown.
This just stops the wrong type of pointer being passed to the 'void *'
parameter.
I hope I've found everything, amd64 GENERIC and i386 GENERIC & ALL compile.
 1.4 08-Feb-2011  rmind branches: 1.4.4; 1.4.14; 1.4.18;
Remove clause 3 (UCB advertising clause) from the University of Utah
copyright. Confirmed by Mike Hibler, mike at cs.utah.edu - thanks!
Also, merge UCB and Utah copyright texts back into one, as they
originally were.

Extra verification by snj@.
 1.3 23-Nov-2009  rmind branches: 1.3.4; 1.3.6; 1.3.8;
Use lwp_getpcb() on m68k ports, clean from struct user usage.
 1.2 15-Aug-2009  matt Include <sys/exec_aout.h> explicitly instead of relying on <sys/exec.h> to
do it for us.
 1.1 19-Nov-2008  ad branches: 1.1.4; 1.1.6; 1.1.8; 1.1.12;
Make the emulations, exec formats, coredump, NFS, and the NFS server
into modules. By and large this commit:

- shuffles header files and ifdefs
- splits code out where necessary to be modular
- adds module glue for each of the components
- adds/replaces hooks for things that can be installed at runtime
 1.1.12.4 11-Mar-2010  yamt sync with head
 1.1.12.3 19-Aug-2009  yamt sync with head.
 1.1.12.2 04-May-2009  yamt sync with head.
 1.1.12.1 19-Nov-2008  yamt file core_machdep.c was added on branch yamt-nfs-mp on 2009-05-04 08:11:26 +0000
 1.1.8.2 19-Jan-2009  skrll Sync with HEAD.
 1.1.8.1 19-Nov-2008  skrll file core_machdep.c was added on branch nick-hppapmap on 2009-01-19 13:16:24 +0000
 1.1.6.2 17-Jan-2009  mjf Sync with HEAD.
 1.1.6.1 19-Nov-2008  mjf file core_machdep.c was added on branch mjf-devfs2 on 2009-01-17 13:28:10 +0000
 1.1.4.2 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.1.4.1 19-Nov-2008  haad file core_machdep.c was added on branch haad-dm on 2008-12-13 01:13:16 +0000
 1.3.8.1 17-Feb-2011  bouyer Sync with HEAD
 1.3.6.1 06-Jun-2011  jruoho Sync with HEAD.
 1.3.4.1 05-Mar-2011  rmind sync with head
 1.4.18.1 18-May-2014  rmind sync with head
 1.4.14.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.4.4.1 22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.6.30.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.2 05-Jan-2025  andvar fix various typos in comments.
 1.1 19-Sep-2010  tsutsui branches: 1.1.2; 1.1.4; 1.1.10; 1.1.102;
Add m68k MD cpu_in_cksum.c.
Based on sys/netinet/cpu_in_cksum.c but just modified
to use traditional MD m68k/oc_cksum.s.

Makes ~5% improvements of ttcp(1) xfer rates on ATARI TT030 + SMC_TT.
 1.1.102.1 02-Aug-2025  perseant Sync with HEAD
 1.1.10.2 05-Mar-2011  rmind sync with head
 1.1.10.1 19-Sep-2010  rmind file cpu_in_cksum.c was added on branch rmind-uvmplock on 2011-03-05 20:50:54 +0000
 1.1.4.2 22-Oct-2010  uebayasi Sync with HEAD (-D20101022).
 1.1.4.1 19-Sep-2010  uebayasi file cpu_in_cksum.c was added on branch uebayasi-xip on 2010-10-22 07:21:23 +0000
 1.1.2.2 09-Oct-2010  yamt sync with head
 1.1.2.1 19-Sep-2010  yamt file cpu_in_cksum.c was added on branch yamt-nfs-mp on 2010-10-09 03:31:49 +0000
 1.47 26-Sep-2023  tsutsui TAB/space cleanup.
 1.46 24-Jul-2021  andvar Fix all remaining typos, mainly in comments but also in few definitions and log messages, reported by me in PR kern/54889.
Also fixed some additional typos in comments, found on review of same files or typos.
 1.45 06-Apr-2021  simonb branches: 1.45.2;
Include <ddb/db_interface.h> to get ddb's db_disasm() prototype.
 1.44 26-Oct-2019  christos branches: 1.44.10;
Add missing FALLTHROUGH (I am not 100% certain if this is correct), but
breaking/returning will end up printing nothing.
 1.43 11-Jul-2019  msaitoh Fix typo (s/supress/suppress/).
 1.42 05-Feb-2019  mrg add fallthru comment.
 1.41 21-Sep-2014  christos branches: 1.41.20;
fix cut-n-paste
 1.40 19-Oct-2013  martin branches: 1.40.4;
Remove unused variable
 1.39 31-Jan-2012  mlelstv branches: 1.39.6; 1.39.10;
Enable build of crash(8) for m86k platforms.
 1.38 21-Feb-2007  thorpej branches: 1.38.80; 1.38.84;
Replace the Mach-derived boolean_t type with the C99 bool type. A
future commit will replace use of TRUE and FALSE with true and false.
 1.37 24-Nov-2006  wiz branches: 1.37.4;
Correct spelling of "immediate(ly)". From Zafer.
 1.36 22-Jul-2006  tsutsui branches: 1.36.4; 1.36.6;
TAB/space cleanup.
 1.35 22-Jul-2006  tsutsui KNF and misc cosmetics
 1.34 11-Dec-2005  christos branches: 1.34.4; 1.34.8;
merge ktrace-lwp.
 1.33 02-Jun-2005  tsutsui branches: 1.33.2;
Add consts and fix a shadow warning.
 1.32 30-May-2005  he Adapt to recent constification of db_interface.h and db_sym.h.
 1.31 17-May-2005  christos Yes, it was a cool trick >20 years ago to use "0123456789abcdef"[a] to
implement, xtoa(), but I think defining the samestring 50 times is a bit
too much. Defined HEXDIGITS and hexdigits in subr_prf.c and use it...
 1.30 28-Aug-2004  thorpej Use ANSI function decls and static.
 1.29 15-Jul-2003  lukem __KERNEL_RCSID()
 1.28 08-Jun-2002  yamt branches: 1.28.6;
make an auto const variable static.
 1.27 26-Dec-2001  thorpej branches: 1.27.8;
A statement must follow a label.
 1.26 24-Dec-2001  chs make this compile again after -ffreestanding.
 1.25 27-Sep-1999  itohy branches: 1.25.16; 1.25.20;
Make it compile again.
 1.24 25-Sep-1999  is vm_offset_t -> db_addr_t (mostly), v_addr_t (one place).
 1.23 09-Jun-1999  scottr Someone forgot to tell ddb that SWAP is not PEA.
 1.22 07-Oct-1998  scottr branches: 1.22.6; 1.22.8; 1.22.10;
Use the size field to distinguish between ADDX and ADDA. Fixes a problem
pointed out by Paul Goyette.
 1.21 07-Oct-1998  scottr Fix a problem pointed out by Paul Goyette: print_reglist() forgets that
it had a range of registers to print if A7 is among them.
 1.20 19-Jun-1997  scottr Disassemble the MOVE16 instruction. Also, correct the spelling of
`unknown' while were here, as suggested. From Denny Gentry
<denny1@home.com>, PR 3567.
 1.19 30-Oct-1996  is Add the 68060 bus control register to the list of known cpu superisor mode
registers.
 1.18 30-Oct-1996  is In my earlier patch to the m68k fmovem disassembler, I repaired the register
naming for fmovem, while breaking it for fmove. We probably never will
see normal fmove in the kernel, nevertheless it should be corrected while
somebody remembers.
Besides, the correct patch is smaller and thus easier to verify than the
origininal one.
 1.17 28-Oct-1996  is * Fix a few wrong fallthroughs in switch cases:
- add a missing return; at the end of a case, leading to wrong disassembly
of the next few instructions after fmovem.
- while we're here, correct the same bug in PBcc.

XXX there are a few other dubious fallthroughs in this file (which are
not explicitly marked with /* FALLTHROUGH */), which I didn't yet analyze.

* Fix other FMOVEM interpretation bugs:
- correct printing of FP data register lists if all are used (only FP0
would be mentioned)
- correct printing of FP data register lists in the case the list is reversed
(would have printed nothing)
- correct mapping of fp0-fp7 to register list bits (was reversed)
- correct printing of FP control register lists (this list is never reversed)
- correct printing of FMOVEM with FP control registers (the data direction
was interpreted the wrong way)

* While we're here, enhance the comments in MOVC's list of cpu control
registers
 1.16 24-Oct-1996  is First small hack at 68060 support: processor configuration register.
(We don't use the new instructions lpstop and plpa in our kernel, so no hurry.)
 1.15 12-Jun-1996  is Fix a few off-by-one errors in bitnumbers used by print_fcode.
ptestX fc,<ea>,M used to be printed with the wrong semantics of the fc
field, and could panic the kernel if fc was interpreted as a register number.
 1.14 29-Apr-1996  leo branches: 1.14.4;
Prototype + -Wall fixes.
 1.13 01-Apr-1996  briggs Clean up for higher warning level.
 1.12 14-Nov-1994  gwr Fix disassembly of 8-bit branch displacements (sign extend).
Fix invalid array references disassembling float instructions.
Make the system stack pointer visible in show regs.
Make "sr" a proper short, remove some junk...
 1.11 26-Oct-1994  cgd new RCS ID format.
 1.10 06-Oct-1994  chopps fix typo.
 1.9 30-Jun-1994  gwr Fix disassembly of branches with byte displacement.
Disassembler routine no longer prints the address because
db_examine now does it for us (fixes "double speak" bug).
 1.8 16-Jun-1994  chopps default is MIT syntax not moto.
 1.7 16-May-1994  gwr Fix disassembly of "mov #0xNNNN,sr"
 1.6 13-May-1994  gwr Print offset from symbol in same format as input parser understands
(so they can be cut and pasted in an xterm).
 1.5 09-May-1994  gwr This file was using off_t where it should have had db_expr_t and
these are, of course, no longer the same thing.
 1.4 04-Mar-1994  chopps That comment at least needed fixing now. Also changed some buffer
sizes to more reasonable ammounts.
 1.3 04-Mar-1994  chopps 1 pounds of coffee, 6 packs of smokes and a couple pizzas.
This is for backup purposes only. It works in a hacked up
user-mode setting. I have to get ddb working with amiga's to
test this any further though. I tested the main opcodes pretty
much, not too much testing on the fpu ops and it printed pflusha :^)

major externally visible changes still planned.
 1.2 28-Jan-1994  jtc Fix spelling error in Copyright notice
 1.1 09-Jan-1994  cgd stub.
 1.14.4.3 05-Dec-1996  rat Pullup request 1.17 -> 1.18 from Ignatios Souvatzis <is@beverly.rhein.de>

>In my earlier sys/arch/m68k/m68k/db_disasm.c patch request, I broke
>fmove register naming, while repairing fmovem.
 1.14.4.2 05-Dec-1996  rat Pullup 1.16 -> 1.17 request from Ignatios Souvatzis <ignatios@cs.uni-bonn.de>

>revision 1.17
>date: 1996/10/28 08:43:18; author: is; state: Exp; lines: +24 -13
>* Fix a few wrong fallthroughs in switch cases:
>- add a missing return; at the end of a case, leading to wrong disassembly
> of the next few instructions after fmovem.
>- while we're here, correct the same bug in PBcc.
>
> XXX there are a few other dubious fallthroughs in this file (which are
> not explicitly marked with /* FALLTHROUGH */), which I didn't yet analyze.
>
>* Fix other FMOVEM interpretation bugs:
>- correct printing of FP data register lists if all are used (only FP0
> would be mentioned)
>- correct printing of FP data register lists in the case the list is reversed
> (would have printed nothing)
>- correct mapping of fp0-fp7 to register list bits (was reversed)
>- correct printing of FP control register lists (this list is never reversed)
>- correct printing of FMOVEM with FP control registers (the data direction
> was interpreted the wrong way)
>
>* While we're here, enhance the comments in MOVC's list of cpu control
> registers
 1.14.4.1 12-Jun-1996  is Pull up fix from trunk: interpret function code field of (e.g.) ptest
correctly, don't panic when interpreting it as data register
 1.22.10.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.22.8.1 21-Jun-1999  thorpej Sync w/ -current.
 1.22.6.1 22-Jun-1999  perry pullup 1.22->1.23 (scottr)
 1.25.20.2 20-Jun-2002  nathanw Catch up to -current.
 1.25.20.1 08-Jan-2002  nathanw Catch up to -current.
 1.25.16.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.25.16.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.27.8.1 14-Jul-2002  gehenna catch up with -current.
 1.28.6.5 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.28.6.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.28.6.3 18-Sep-2004  skrll Sync with HEAD.
 1.28.6.2 03-Sep-2004  skrll Sync with HEAD
 1.28.6.1 03-Aug-2004  skrll Sync with HEAD
 1.33.2.2 26-Feb-2007  yamt sync with head.
 1.33.2.1 30-Dec-2006  yamt sync with head.
 1.34.8.1 11-Aug-2006  yamt sync with head
 1.34.4.1 09-Sep-2006  rpaulo sync with head
 1.36.6.1 10-Dec-2006  yamt sync with head.
 1.36.4.1 12-Jan-2007  ad Sync with head.
 1.37.4.1 27-Feb-2007  yamt - sync with head.
- move sched_changepri back to kern_synch.c as it doesn't know PPQ anymore.
 1.38.84.1 18-Feb-2012  mrg merge to -current.
 1.38.80.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.80.1 17-Apr-2012  yamt sync with head
 1.39.10.1 18-May-2014  rmind sync with head
 1.39.6.2 03-Dec-2017  jdolecek update from HEAD
 1.39.6.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.40.4.1 30-Oct-2014  martin Pull up following revision(s) (requested by maxv in ticket #167):
sys/arch/m68k/m68k/db_disasm.c: revision 1.41
fix cut-n-paste
 1.41.20.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.41.20.1 10-Jun-2019  christos Sync with HEAD
 1.44.10.1 17-Apr-2021  thorpej Sync with HEAD.
 1.45.2.1 01-Aug-2021  thorpej Sync with HEAD.
 1.11 26-Sep-2023  tsutsui Remove trailing spaces and TABs.
 1.10 06-Apr-2021  simonb Remove duplicate db_disasm() prototype.
 1.9 14-Mar-2009  dsl branches: 1.9.78;
Remove all the __P() from sys (excluding sys/dist)
Diff checked with grep and MK1 eyeball.
i386 and amd64 GENERIC and sys still build.
 1.8 21-Feb-2007  thorpej branches: 1.8.46; 1.8.54; 1.8.60;
Replace the Mach-derived boolean_t type with the C99 bool type. A
future commit will replace use of TRUE and FALSE with true and false.
 1.7 11-Dec-2005  christos branches: 1.7.26;
merge ktrace-lwp.
 1.6 28-Aug-2004  thorpej branches: 1.6.12;
Use ANSI function decls and static.
 1.5 25-Sep-1999  is branches: 1.5.36;
vm_offset_t -> db_addr_t (mostly), v_addr_t (one place).
 1.4 01-Apr-1996  briggs Clean up for higher warning level.
 1.3 26-Oct-1994  cgd new RCS ID format.
 1.2 05-Aug-1994  chopps mama always said to protect those macro args..
 1.1 04-Mar-1994  chopps branches: 1.1.2;
1 pounds of coffee, 6 packs of smokes and a couple pizzas.
This is for backup purposes only. It works in a hacked up
user-mode setting. I have to get ddb working with amiga's to
test this any further though. I tested the main opcodes pretty
much, not too much testing on the fpu ops and it printed pflusha :^)

major externally visible changes still planned.
 1.1.2.1 14-Aug-1994  mycroft update from trunk (minor)
 1.5.36.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.5.36.2 18-Sep-2004  skrll Sync with HEAD.
 1.5.36.1 03-Sep-2004  skrll Sync with HEAD
 1.6.12.1 26-Feb-2007  yamt sync with head.
 1.7.26.1 27-Feb-2007  yamt - sync with head.
- move sched_changepri back to kern_synch.c as it doesn't know PPQ anymore.
 1.8.60.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.8.54.1 28-Apr-2009  skrll Sync with HEAD.
 1.8.46.1 04-May-2009  yamt sync with head.
 1.9.78.1 17-Apr-2021  thorpej Sync with HEAD.
 1.36 26-Oct-2022  riastradh ddb/db_active.h: New home for extern db_active.

This can be included unconditionally, and db_active can then be
queried unconditionally; if DDB is not in the kernel, then db_active
is a constant zero. Reduces need for #include opt_ddb.h, #ifdef DDB.
 1.35 31-Jan-2012  mlelstv Enable build of crash(8) for m86k platforms.
 1.34 22-Feb-2007  thorpej branches: 1.34.80; 1.34.84;
TRUE -> true, FALSE -> false
 1.33 22-Jul-2006  tsutsui branches: 1.33.10;
KNF and misc cosmetics
 1.32 24-Dec-2005  perry branches: 1.32.4; 1.32.8;
bare asm -> __asm
 1.31 11-Dec-2005  christos merge ktrace-lwp.
 1.30 28-Aug-2004  thorpej branches: 1.30.12;
Use ANSI function decls and static.
 1.29 15-Jul-2003  lukem __KERNEL_RCSID()
 1.28 13-May-2002  matt branches: 1.28.10;
Nuke local extern label_t *db_recover; it's now in <ddb/db_extern.h>
 1.27 29-Jun-2000  mrg branches: 1.27.4; 1.27.8;
remove include of <vm/vm.h>. <vm/vm.h> -> <uvm/uvm_extern.h>
 1.26 12-Oct-1999  jdolecek branches: 1.26.2;
rename the MD Debugger() to cpu_Debugger()
add MI Debugger() which switches to console if wscons is used prior
to calling cpu_Debugger()
 1.25 04-Jul-1998  jonathan branches: 1.25.14;
defopt DDB.
 1.24 18-Feb-1997  gwr Define ddb_regs here (and extern in db_machdep.h)
 1.23 15-Jan-1997  gwr branches: 1.23.4;
Use db_regs_t instead of struct mc68020_saved_state
 1.22 13-Oct-1996  christos backout previous kprintf change
 1.21 11-Oct-1996  christos printf -> kprintf, sprintf -> ksprintf
 1.20 29-Apr-1996  leo Prototype + -Wall fixes.
 1.19 16-Mar-1996  mhitch change Debugger() from an int function to a void function to match the
prototype in sys/systm.h.
 1.18 22-Feb-1996  gwr Remove the hack that faked up an "ssp" value. It is now up to
locore.s to put the right sp in the frame. Also move memory
access code into db_memrw.c so it can be taken separately.
 1.17 09-Feb-1996  gwr eliminate setjmp.h
 1.16 09-Jun-1995  leo Atari no longer uses the default db_read/write functions.
 1.15 24-May-1995  gwr Compute value of ssp correctly.
 1.14 13-Feb-1995  chopps add amiga in here too
 1.13 18-Jan-1995  gwr Make kdb_trap return zero for traps that have not been "handled".
 1.12 28-Nov-1994  gwr The sun3 port now has its own db_read_bytes() too.
 1.11 17-Nov-1994  gwr The sun3 needs its own version of db_write_bytes() so just
added #ifndef sun3 around it for now. This function should
probably be provided by each port (like sun3/db_write.c).
 1.10 14-Nov-1994  gwr Fix disassembly of 8-bit branch displacements (sign extend).
Fix invalid array references disassembling float instructions.
Make the system stack pointer visible in show regs.
Make "sr" a proper short, remove some junk...
 1.9 26-Oct-1994  cgd new RCS ID format.
 1.8 09-Jan-1994  mycroft Gratuitous change.
 1.7 09-Jan-1994  mycroft Fix some #includes.
 1.6 09-Jan-1994  mycroft Thinko. code is always 0 on m68k; no need to print it.
 1.5 09-Jan-1994  mycroft Some more minor cleanup.
 1.4 09-Jan-1994  mycroft Clean up a bit.
 1.3 09-Jan-1994  cgd kill logs, and clean up. some of this will need cpu-dependent hooks.
 1.2 10-Aug-1993  glass fixed problem that caused two consecutive segments to be using the same
pmeg unknowingly. still too many printfs, not sure how many are actualy
in the machine dependent code. reaches cpu_startup() where it stops
deliberately. next project: autoconfig(), maybe kgdb
 1.1 08-Aug-1993  glass lots of changes, too many printfs
 1.23.4.1 12-Mar-1997  is Merge in changes from Trunk
 1.25.14.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.26.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.27.8.1 20-Jun-2002  nathanw Catch up to -current.
 1.27.4.1 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.28.10.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.28.10.3 18-Sep-2004  skrll Sync with HEAD.
 1.28.10.2 03-Sep-2004  skrll Sync with HEAD
 1.28.10.1 03-Aug-2004  skrll Sync with HEAD
 1.30.12.3 26-Feb-2007  yamt sync with head.
 1.30.12.2 30-Dec-2006  yamt sync with head.
 1.30.12.1 21-Jun-2006  yamt sync with head.
 1.32.8.1 11-Aug-2006  yamt sync with head
 1.32.4.1 09-Sep-2006  rpaulo sync with head
 1.33.10.1 27-Feb-2007  yamt - sync with head.
- move sched_changepri back to kern_synch.c as it doesn't know PPQ anymore.
 1.34.84.1 18-Feb-2012  mrg merge to -current.
 1.34.80.1 17-Apr-2012  yamt sync with head
 1.8 26-Sep-2023  tsutsui Remove trailing spaces and TABs.
 1.7 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.6 11-Dec-2005  christos branches: 1.6.74; 1.6.76; 1.6.78;
merge ktrace-lwp.
 1.5 02-Jun-2005  tsutsui Adapt to ddb constification.
 1.4 02-Nov-2002  chs branches: 1.4.6;
enhance the common m68k db_memrw.c to handle read-only kernel text
and switch all the motorola-MMU m68k platforms to use it.
 1.3 29-Jun-2000  mrg branches: 1.3.8;
remove include of <vm/vm.h>. <vm/vm.h> -> <uvm/uvm_extern.h>
 1.2 25-Sep-1999  is branches: 1.2.2;
vm_offset_t -> db_addr_t (mostly), v_addr_t (one place).
 1.1 22-Feb-1996  gwr Remove the hack that faked up an "ssp" value. It is now up to
locore.s to put the right sp in the frame. Also move memory
access code into db_memrw.c so it can be taken separately.
 1.2.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.3.8.1 11-Nov-2002  nathanw Catch up to -current
 1.4.6.1 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.6.78.1 16-May-2008  yamt sync with head.
 1.6.76.1 18-May-2008  yamt sync with head.
 1.6.74.1 02-Jun-2008  mjf Sync with HEAD.
 1.63 26-Sep-2023  tsutsui TAB/space cleanup.
 1.62 26-Sep-2023  tsutsui Remove trailing spaces and TABs.
 1.61 26-Jul-2022  chs curlwp is only available for ifdef _KERNEL.
 1.60 25-Jul-2022  chs use the pcb of the thread we are tracing rather than always curlwp.
 1.59 18-Oct-2015  maxv Add some {} when the meaning is too ambiguous. From Brainy.
 1.58 07-Nov-2013  christos branches: 1.58.6;
add ifdefs for kernel only variable
 1.57 31-Jan-2012  mlelstv branches: 1.57.6; 1.57.10;
Enable build of crash(8) for m86k platforms.
 1.56 01-Jul-2010  rmind branches: 1.56.8; 1.56.12;
Remove pfind() and pgfind(), fix locking in various broken uses of these.
Rename real routines to proc_find() and pgrp_find(), remove PFIND_* flags
and have consistent behaviour. Provide proc_find_raw() for special cases.
Fix memory leak in sysctl_proc_corename().

COMPAT_LINUX: rework ptrace() locking, minimise differences between
different versions per-arch.

Note: while this change adds some formal cosmetics for COMPAT_DARWIN and
COMPAT_IRIX - locking there is utterly broken (for ages).

Fixes PR/43176.
 1.55 23-Nov-2009  rmind branches: 1.55.2; 1.55.4;
Use lwp_getpcb() on m68k ports, clean from struct user usage.
 1.54 21-Oct-2009  rmind Remove uarea swap-out functionality:

- Addresses the issue described in PR/38828.
- Some simplification in threading and sleepq subsystems.
- Eliminates pmap_collect() and, as a side note, allows pmap optimisations.
- Eliminates XS_CTL_DATA_ONSTACK in scsipi code.
- Avoids few scans on LWP list and thus potentially long holds of proc_lock.
- Cuts ~1.5k lines of code. Reduces amd64 kernel size by ~4k.
- Removes __SWAP_BROKEN cases.

Tested on x86, mips, acorn32 (thanks <mpumford>) and partly tested on
acorn26 (thanks to <bjh21>).

Discussed on <tech-kern>, reviewed by <ad>.
 1.53 02-Jul-2008  rmind Remove proc_representative_lwp(), use a simple LIST_FIRST() instead.
OK by <ad>.
 1.52 17-Oct-2007  garbled branches: 1.52.16; 1.52.20; 1.52.22; 1.52.24;
Merge the ppcoea-renovation branch to HEAD.

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

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

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.51 12-Jun-2007  mhitch branches: 1.51.10;
Pass a frame pointer to trap() rather than the 'entire frame' trick. Gcc4
was optimizing away modifications to the frame contents (it's not nice to
trick gcc). Pass the pointer as the first argument to reduce the number
of places that would be changed otherwise. Fixes the getcwd regression
test on most m68k ports.
 1.50 22-Feb-2007  thorpej branches: 1.50.4; 1.50.6; 1.50.12;
TRUE -> true, FALSE -> false
 1.49 22-Feb-2007  tsutsui Fix lossage on bool changes.
 1.48 21-Feb-2007  thorpej Pick up some additional files that were missed before due to conflicts
with newlock2 merge:

Replace the Mach-derived boolean_t type with the C99 bool type. A
future commit will replace use of TRUE and FALSE with true and false.
 1.47 20-Feb-2007  ad - Add /a modifier to trace that allows a specific LWP to be selected.
- When doing trace/t, always note which pid/lid combination is being traced.
 1.46 17-Feb-2007  pavel Change the process/lwp flags seen by userland via sysctl back to the
P_*/L_* naming convention, and rename the in-kernel flags to avoid
conflict. (P_ -> PK_, L_ -> LW_ ). Add back the (now unused) LSDEAD
constant.

Restores source compatibility with pre-newlock2 tools like ps or top.

Reviewed by Andrew Doran.
 1.45 06-Sep-2006  ad branches: 1.45.6; 1.45.8; 1.45.10;
Use p_find(addr, PFIND_LOCKED) in case the proclist_lock is held.
 1.44 22-Jul-2006  tsutsui TAB/space cleanup.
 1.43 22-Jul-2006  tsutsui KNF and misc cosmetics
 1.42 11-Dec-2005  christos branches: 1.42.4; 1.42.8;
merge ktrace-lwp.
 1.41 30-May-2005  he branches: 1.41.2;
Adapt to recent constification of db_interface.h and db_sym.h.
 1.40 28-Aug-2004  thorpej Use ANSI function decls and static.
 1.39 15-Jul-2003  lukem __KERNEL_RCSID()
 1.38 17-Jan-2003  thorpej branches: 1.38.2;
Merge the nathanw_sa branch.
 1.37 26-Oct-2002  jdolecek g/c local offsetof(), it's defined in libkern.h
 1.36 14-May-2002  matt #include <db/db_extern.h>
 1.35 13-May-2002  matt Nuke local extern label_t *db_recover; it's now in <ddb/db_extern.h>
 1.34 07-Feb-2001  chs branches: 1.34.4; 1.34.8;
missed an underscore in previous.
 1.33 07-Feb-2001  chs fix previous to work with a.out as well.
 1.32 05-Feb-2001  chs remove signal trampoline stuff since it'll never be used in the kernel.
clean up the ELF support.
 1.31 18-Jan-2001  jdolecek make db_[e]regs[] const
 1.30 18-Jan-2001  scw const'ify the 1st parameter of db_var_short() to account for the
recent "struct db_variable" change.
 1.29 10-Aug-2000  scw Add a `/t' modifier to the m68k ddb's `trace' command. This enables
one to perform a kernel traceback of any (non-swapped-out) process in
the system. For example, to show the traceback for PID 178:

db> t/t 0t178
trace: pid 178 at 0xabcd68
_mi_switch(0x109f60) + 164
...
db>
 1.28 27-May-2000  jhawk Oops, omitted the rename from last.
Function in this file is db_stack_trace_print(),
not db_stack_trace_cmd().
 1.27 26-May-2000  jhawk branches: 1.27.2;
Rename the machine-specific stack trace printing functions
from db_stack_trace_cmd() to db_stack_trace_print(),
and add an additional argument, a function pointer for an
output routine (i.e. printf() or db_printf()).

Add db_stack_trace_cmd() in db_command.[ch], calling
db_stack_trace_print() with db_printf() as the printer.

Move count==-1 special handling from db_stack_trace_print() [nee
db_stack_trace_cmd()] to db_stack_trace_cmd() [nascent here].

Again, I'm unable to test compilation on all affected platforms,
so advance apologies for potential brokenness.
 1.26 25-Sep-1999  is branches: 1.26.2;
vm_offset_t -> db_addr_t (mostly), v_addr_t (one place).
 1.25 05-Apr-1999  scw branches: 1.25.2;
Add a check to my last 'fix' which ensures the fault really
did happen in kernel mode.
 1.24 04-Apr-1999  scw Fix a problem I noticed a while back but had too many other things
in the air to deal with it.
Basically, following a kernel fault (eg. dereferencing a NULL pointer
in kernel mode) a DDB 'trace' did not show the function where the
fault occurred. For example:

db> trace
_Debugger()
_panic()
_trap()
faultstkadj()
_pool_drain()
_uvm_pageout()
_start_pagedaemon()
_proc_trampoline()
db>

The 'faultstkadj()' line here is bogus. It is shown because the return
address to 'trap()' happens to point there, and since faultstkadj() has
no stack frame, DDB assumes it was the faulting function. In this example,
the _real_ function was pool_reclaim(), but you would have to look at
the program counter at the time of the fault to figure that one out.

This fix makes the trace command do the dirty work for you by grubbing
around in 'trap()'s argument list to find the *real* PC value at the
time of the fault, replacing the 'faultstkadj()' line with the real
function's name.
 1.23 15-Jan-1999  thorpej Eliminate use of CPP symbol "mc68020".
 1.22 14-May-1998  dbj Fixed stack trace address printing lossage when no symbols are available.
 1.21 13-Apr-1998  scottr Make type explicit for egcs, from Erik Bertelsen in PR 5287.
Dump the register qualifier while we're here, as suggested in the PR.
 1.20 05-Feb-1997  scottr db_expr_t is now a long.
 1.19 04-Feb-1997  gwr Adapt to changed definition of struct db_variable.
 1.18 27-Jan-1997  gwr Update for new struct member names in db_regs_t.
 1.17 15-Jan-1997  gwr Use db_regs_t instead of struct mc68020_saved_state
 1.16 29-Apr-1996  leo Prototype + -Wall fixes.
 1.15 22-Feb-1996  gwr Remove the hack that faked up an "ssp" value. It is now up to
locore.s to put the right sp in the frame. Also move memory
access code into db_memrw.c so it can be taken separately.
 1.14 13-Feb-1996  gwr Oops, label_t does not have implicit pointer type like jmp_buf
 1.13 09-Feb-1996  gwr eliminate setjmp.h
 1.12 24-May-1995  gwr Fix range check for kernel stack pointers.
 1.11 14-Nov-1994  gwr Fix disassembly of 8-bit branch displacements (sign extend).
Fix invalid array references disassembling float instructions.
Make the system stack pointer visible in show regs.
Make "sr" a proper short, remove some junk...
 1.10 26-Oct-1994  cgd new RCS ID format.
 1.9 13-May-1994  gwr Fix parentheses bug in code that counts function args.
 1.8 31-Jan-1994  mycroft Default to displaying 5 args if size is unknown. Allow for multiple addq's
following the jsr. Don't try to trace into the user's stack. Other minor
cleanup.
 1.7 10-Jan-1994  mycroft Deal with linkl in addition to linkw.
 1.6 10-Jan-1994  mycroft Fix a buglet.
 1.5 09-Jan-1994  mycroft Fix jmp_buf definitions.
 1.4 09-Jan-1994  mycroft KNFify, and fix a condition where we might miss the register saves if the
frame length is short.
 1.3 09-Jan-1994  cgd kill logs, and clean up. some of this will need cpu-dependent hooks.
 1.2 10-Aug-1993  glass fixed problem that caused two consecutive segments to be using the same
pmeg unknowingly. still too many printfs, not sure how many are actualy
in the machine dependent code. reaches cpu_startup() where it stops
deliberately. next project: autoconfig(), maybe kgdb
 1.1 08-Aug-1993  glass lots of changes, too many printfs
 1.25.2.2 05-Apr-1999  scw Add a check to my last 'fix' which ensures the fault really
did happen in kernel mode.
 1.25.2.1 05-Apr-1999  scw file db_trace.c was added on branch netbsd-1-4 on 1999-04-05 17:17:05 +0000
 1.26.2.2 11-Feb-2001  bouyer Sync with HEAD.
 1.26.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.27.2.1 22-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.34.8.4 11-Nov-2002  nathanw Catch up to -current
 1.34.8.3 12-Jul-2002  nathanw No longer need to pull in lwp.h; proc.h pulls it in for us.
 1.34.8.2 20-Jun-2002  nathanw Catch up to -current.
 1.34.8.1 17-Nov-2001  scw Kernel support for Scheduler Activations on m68k-based ports using
mvme68k as a testbed.

Boots multi-user on an mvme162, although userland support for SA is not
yet integrated/tested.
 1.34.4.1 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.38.2.5 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.38.2.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.38.2.3 18-Sep-2004  skrll Sync with HEAD.
 1.38.2.2 03-Sep-2004  skrll Sync with HEAD
 1.38.2.1 03-Aug-2004  skrll Sync with HEAD
 1.41.2.3 03-Sep-2007  yamt sync with head.
 1.41.2.2 26-Feb-2007  yamt sync with head.
 1.41.2.1 30-Dec-2006  yamt sync with head.
 1.42.8.2 14-Sep-2006  yamt sync with head.
 1.42.8.1 11-Aug-2006  yamt sync with head
 1.42.4.1 09-Sep-2006  rpaulo sync with head
 1.45.10.1 03-Sep-2007  wrstuden Sync w/ NetBSD-4-RC_1
 1.45.8.1 27-Feb-2007  yamt - sync with head.
- move sched_changepri back to kern_synch.c as it doesn't know PPQ anymore.
 1.45.6.1 18-Jun-2007  liamjfoy Pull up following revision(s) (requested by mhitch in ticket #728):
sys/arch/mvme68k/mvme68k/locore.s: revision 1.98
sys/arch/mac68k/mac68k/trap.c: revision 1.128
sys/arch/next68k/next68k/locore.s: revision 1.48
sys/arch/mac68k/mac68k/locore.s: revision 1.152
sys/arch/sun3/sun3/locore.s: revision 1.88
sys/arch/sun2/sun2/locore.s: revision 1.19
sys/arch/sun2/sun2/trap.c: revision 1.32
sys/arch/m68k/m68k/db_trace.c: revision 1.51
sys/arch/mvme68k/mvme68k/trap.c: revision 1.90
sys/arch/news68k/news68k/trap.c: revision 1.53
sys/arch/luna68k/luna68k/locore.s: revision 1.27
sys/arch/atari/atari/locore.s: revision 1.99
sys/arch/sun3/sun3/trap.c: revision 1.130
sys/arch/x68k/x68k/trap.c: revision 1.89
sys/arch/next68k/next68k/trap.c: revision 1.67
sys/arch/x68k/x68k/locore.s: revision 1.79
sys/arch/news68k/news68k/locore.s: revision 1.43
sys/arch/luna68k/luna68k/trap.c: revision 1.46
sys/arch/hp300/hp300/locore.s: revision 1.140
sys/arch/cesfic/cesfic/locore.s: revision 1.15
sys/arch/cesfic/cesfic/trap.c: revision 1.35
sys/arch/m68k/m68k/trap_subr.s: revision 1.12
sys/arch/amiga/amiga/locore.s: revision 1.143
Pass a frame pointer to trap() rather than the 'entire frame' trick. Gcc4
was optimizing away modifications to the frame contents (it's not nice to
trick gcc). Pass the pointer as the first argument to reduce the number
of places that would be changed otherwise. Fixes the getcwd regression
test on most m68k ports.
 1.50.12.1 26-Jun-2007  garbled Sync with HEAD.
 1.50.6.1 11-Jul-2007  mjf Sync with head.
 1.50.4.1 15-Jul-2007  ad Sync with head.
 1.51.10.1 06-Nov-2007  matt sync with HEAD
 1.52.24.1 03-Jul-2008  simonb Sync with head.
 1.52.22.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.52.20.3 11-Aug-2010  yamt sync with head.
 1.52.20.2 11-Mar-2010  yamt sync with head
 1.52.20.1 04-May-2009  yamt sync with head.
 1.52.16.1 28-Sep-2008  mjf Sync with HEAD.
 1.55.4.1 03-Jul-2010  rmind sync with head
 1.55.2.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.56.12.1 18-Feb-2012  mrg merge to -current.
 1.56.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.56.8.1 17-Apr-2012  yamt sync with head
 1.57.10.1 18-May-2014  rmind sync with head
 1.57.6.2 03-Dec-2017  jdolecek update from HEAD
 1.57.6.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.58.6.1 27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.3 10-Apr-2025  nat Revet to previous.

As pointed out to me on source-changes.
 1.2 09-Apr-2025  nat Add workaround for fpu test for kernels defined with M68040.

This is to accomodate kernels built without the -mlcfix option passed to
gas(1).

As discussed on tech-kern - It would be remiss of me otherwize.
 1.1 15-Nov-2011  tsutsui branches: 1.1.8; 1.1.90;
Merge copy-and-pasted fpu_probe() function (to share it among more m68k ports).
Tested on TT030, Sun3/80, and X68030.
 1.1.90.1 02-Aug-2025  perseant Sync with HEAD
 1.1.8.2 17-Apr-2012  yamt sync with head
 1.1.8.1 15-Nov-2011  yamt file fpu.c was added on branch yamt-pagecache on 2012-04-17 00:06:35 +0000
 1.4 31-Dec-2007  ad Remove COMPAT_HPUX.
 1.3 11-Dec-2005  christos branches: 1.3.50; 1.3.56; 1.3.64;
merge ktrace-lwp.
 1.2 15-Jul-2003  lukem branches: 1.2.16;
__KERNEL_RCSID()
 1.1 13-Jul-2002  scw branches: 1.1.2; 1.1.4; 1.1.6; 1.1.12;
m68k syscall rototill:

- Switch all m68k-based ports over to __HAVE_SYSCALL_INTERN.
- Add systrace glue.
- Define struct mdproc in <m68k/proc.h> instead of <machine/proc.h>.
(They were all defined exactly the same anyway, other than a couple
of the MDP_* flags.)
 1.1.12.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.1.12.2 18-Sep-2004  skrll Sync with HEAD.
 1.1.12.1 03-Aug-2004  skrll Sync with HEAD
 1.1.6.2 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.1.6.1 13-Jul-2002  jdolecek file hpux_syscall.c was added on branch kqueue on 2002-09-06 08:36:47 +0000
 1.1.4.2 01-Aug-2002  nathanw Catch up to -current.
 1.1.4.1 13-Jul-2002  nathanw file hpux_syscall.c was added on branch nathanw_sa on 2002-08-01 02:42:17 +0000
 1.1.2.2 16-Jul-2002  gehenna catch up with -current.
 1.1.2.1 13-Jul-2002  gehenna file hpux_syscall.c was added on branch gehenna-devsw on 2002-07-16 08:36:50 +0000
 1.2.16.1 21-Jan-2008  yamt sync with head
 1.3.64.1 02-Jan-2008  bouyer Sync with HEAD
 1.3.56.1 18-Feb-2008  mjf Sync with HEAD.
 1.3.50.1 23-Mar-2008  matt sync with HEAD
 1.12 19-Sep-2010  tsutsui Remove MD m68k/in_cksum.c which is obsolete since cpu_in_cksum refactoring
in 2008 and now superseded by m68k/cpu_in_cksum.c.
 1.11 22-Jul-2006  tsutsui branches: 1.11.62; 1.11.76; 1.11.82; 1.11.84;
KNF and misc cosmetics
 1.10 11-Dec-2005  christos branches: 1.10.4; 1.10.8;
merge ktrace-lwp.
 1.9 28-Aug-2004  thorpej branches: 1.9.12;
Use ANSI function decls and static.
 1.8 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.7 15-Jul-2003  lukem __KERNEL_RCSID()
 1.6 30-Apr-1996  briggs branches: 1.6.64;
Prototype oc_cksum().
 1.5 26-Oct-1994  cgd new RCS ID format.
 1.4 08-Jan-1994  cgd common code
 1.3 01-Aug-1993  mycroft Add RCS identifiers (this time on the correct side of the branch), and
incorporate recent changes in netbsd-0-9 branch.
 1.2 22-May-1993  cgd add rcsids to everything and clean up headers
 1.1 13-May-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.1 13-May-1993  cgd add hp300 kernel files. generic kernel files might need some help...
 1.6.64.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.6.64.3 18-Sep-2004  skrll Sync with HEAD.
 1.6.64.2 03-Sep-2004  skrll Sync with HEAD
 1.6.64.1 03-Aug-2004  skrll Sync with HEAD
 1.9.12.1 30-Dec-2006  yamt sync with head.
 1.10.8.1 11-Aug-2006  yamt sync with head
 1.10.4.1 09-Sep-2006  rpaulo sync with head
 1.11.84.1 05-Mar-2011  rmind sync with head
 1.11.82.1 22-Oct-2010  uebayasi Sync with HEAD (-D20101022).
 1.11.76.1 24-Oct-2010  jym Sync with HEAD
 1.11.62.1 09-Oct-2010  yamt sync with head
 1.7 22-Jul-2006  tsutsui TAB/space cleanup.
 1.6 22-Jul-2006  tsutsui KNF, ANSIfy, remove register decls
 1.5 11-Dec-2005  christos branches: 1.5.4; 1.5.8;
merge ktrace-lwp.
 1.4 07-Aug-2003  agc branches: 1.4.16;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.3 15-Jul-2003  lukem __KERNEL_RCSID()
 1.2 15-Mar-1997  is branches: 1.2.56;
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 12-Feb-1997  gwr branches: 1.1.4;
Machine-dependent KGDB sharable on all m68k machines.
 1.1.4.2 12-Mar-1997  is Merge in changes from Trunk
 1.1.4.1 12-Feb-1997  is file kgdb_m68k.c was added on branch is-newarp on 1997-03-12 21:14:52 +0000
 1.2.56.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.2.56.2 18-Sep-2004  skrll Sync with HEAD.
 1.2.56.1 03-Aug-2004  skrll Sync with HEAD
 1.4.16.1 30-Dec-2006  yamt sync with head.
 1.5.8.1 11-Aug-2006  yamt sync with head
 1.5.4.1 09-Sep-2006  rpaulo sync with head
 1.7 11-Jan-2009  cegger adaption for making kgdb_dev a dev_t
 1.6 22-Jul-2006  tsutsui branches: 1.6.58; 1.6.62; 1.6.70;
KNF and misc cosmetics
 1.5 24-Dec-2005  perry branches: 1.5.4; 1.5.8;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.
 1.4 11-Dec-2005  christos merge ktrace-lwp.
 1.3 07-Aug-2003  agc branches: 1.3.16;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.2 15-Jul-2003  lukem __KERNEL_RCSID()
 1.1 03-Nov-2002  chs branches: 1.1.2; 1.1.8;
merge all the m68k copies of kgdb_machdep.c.
 1.1.8.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.1.8.2 18-Sep-2004  skrll Sync with HEAD.
 1.1.8.1 03-Aug-2004  skrll Sync with HEAD
 1.1.2.2 11-Nov-2002  nathanw Catch up to -current
 1.1.2.1 03-Nov-2002  nathanw file kgdb_machdep.c was added on branch nathanw_sa on 2002-11-11 21:59:40 +0000
 1.3.16.2 30-Dec-2006  yamt sync with head.
 1.3.16.1 21-Jun-2006  yamt sync with head.
 1.5.8.1 11-Aug-2006  yamt sync with head
 1.5.4.1 09-Sep-2006  rpaulo sync with head
 1.6.70.1 19-Jan-2009  skrll Sync with HEAD.
 1.6.62.1 04-May-2009  yamt sync with head.
 1.6.58.1 17-Jan-2009  mjf Sync with HEAD.
 1.6 29-Apr-2023  skrll Fix build after previous. m68k uses symnum instead of symidx.
 1.5 28-Apr-2023  skrll Pass local symbols relocations in both passes and provide the kobj_reloc
implementation visibility of these relocations.

Currently all implementations resolve local symbol relocations in the first
pass and simply skip them in the second. The RISC-V implementation will
make use of this visiblity.
 1.4 03-Nov-2017  maxv Handle absolute relocations coming from the kernel: preserve SHN_ABS in
the kernel and module symbols, and when relocating a symbol that has
SHN_ABS, take its value as-is and don't return an error if it equals zero.

Sent on tech-kern@.
 1.3 14-Oct-2010  tsutsui branches: 1.3.18;
Fix reloc calcurations (mechanically pulled from working i386 and sh3).
Now options MODULAR works at least on news68k:

# uname -mrs
NetBSD 5.99.39 news68k
# modstat|grep filesys
coredump misc filesys 2 2790 -
exec_aout misc filesys 0 1866 coredump
exec_elf32 misc filesys 0 6072 coredump
exec_script misc filesys 0 972 -
kernfs vfs filesys 0 9734 -
mfs vfs filesys 0 3656 ffs
procfs vfs filesys 0 23924 -
#
 1.2 28-Apr-2008  martin branches: 1.2.20; 1.2.22;
Remove clause 3 and 4 from TNF licenses
 1.1 04-Jan-2008  ad branches: 1.1.2; 1.1.4; 1.1.6; 1.1.8; 1.1.14; 1.1.16; 1.1.18;
More linker stuff
 1.1.18.1 16-May-2008  yamt sync with head.
 1.1.16.1 18-May-2008  yamt sync with head.
 1.1.14.1 02-Jun-2008  mjf Sync with HEAD.
 1.1.8.2 18-Feb-2008  mjf Sync with HEAD.
 1.1.8.1 04-Jan-2008  mjf file kobj_machdep.c was added on branch mjf-devfs on 2008-02-18 21:04:44 +0000
 1.1.6.2 21-Jan-2008  yamt sync with head
 1.1.6.1 04-Jan-2008  yamt file kobj_machdep.c was added on branch yamt-lazymbuf on 2008-01-21 09:37:22 +0000
 1.1.4.2 09-Jan-2008  matt sync with HEAD
 1.1.4.1 04-Jan-2008  matt file kobj_machdep.c was added on branch matt-armv6 on 2008-01-09 01:47:01 +0000
 1.1.2.2 08-Jan-2008  bouyer Sync with HEAD
 1.1.2.1 04-Jan-2008  bouyer file kobj_machdep.c was added on branch bouyer-xeni386 on 2008-01-08 22:10:09 +0000
 1.2.22.1 05-Mar-2011  rmind sync with head
 1.2.20.1 22-Oct-2010  uebayasi Sync with HEAD (-D20101022).
 1.3.18.1 03-Dec-2017  jdolecek update from HEAD
 1.24 07-Mar-2015  christos adjust to new trace_{enter,exit} signatures.
 1.23 24-Mar-2014  christos branches: 1.23.6;
use cpu_{g,s}etmodel
 1.22 08-Feb-2011  rmind branches: 1.22.4; 1.22.14; 1.22.18;
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.21 23-Nov-2009  rmind branches: 1.21.4; 1.21.6; 1.21.8;
Use lwp_getpcb() on m68k ports, clean from struct user usage.
 1.20 25-Nov-2008  tsutsui Add #ifdef _KERNEL_OPT.
 1.19 21-Oct-2008  ad branches: 1.19.2;
Provide a small inline wrapper for sysent::sy_call() and use it to store
the active syscall description in struct lwp. To be used at some future
point to prevent unloading of modules that provide syscalls, while the
syscalls are in use.
 1.18 06-Feb-2008  dsl branches: 1.18.6; 1.18.10; 1.18.16;
Remove the 'args' parameter to 'trace_exit()' it is no longer used.
Instead of passing the (un)real system call code and syscall table pointer,
just pass the number of arguments - which is what ktrace really wants.
Ride forthcoming 4.99.53
 1.17 05-Jan-2008  dsl Don't pass 'curlwp' into trace_enter() and trace_exit().
 1.16 04-Mar-2007  tsutsui branches: 1.16.20; 1.16.26; 1.16.32;
Use (char *) on pointer arith.
XXX: these "params" variables seem unused.
 1.15 04-Mar-2007  christos Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.14 07-Mar-2006  thorpej branches: 1.14.2; 1.14.18;
Syscall debug tracing is handled by trace_enter() / trace_exit(). Change
trace_is_enabled() to return TRUE if SYSCALL_DEBUG is defined, and g/c
all of the SYSCALL_DEBUG handling from individual system call dispatch
routines.
 1.13 07-Mar-2006  thorpej Clean up fallout proc_is_traced_p() change:
- proc_is_traced_p() -> trace_is_enabled(), to match trace_enter() and
trace_exit().
- trace_is_enabled() becomes a real function.
- Remove unnecessary include files from various files that used to care
about KTRACE and SYSTRACE, but do no more.
 1.12 05-Mar-2006  christos Add a proc_is_traced_p() macro and use it, instead of copying the same code
in many places. Idea from thorpej.
 1.11 05-Mar-2006  christos branches: 1.11.2;
implement PT_SYSCALL
 1.10 11-Dec-2005  christos branches: 1.10.4; 1.10.6;
merge ktrace-lwp.
 1.9 02-Jul-2005  he branches: 1.9.2;
Delete now unused "bad" label.
 1.8 01-Jul-2005  christos PR/29607: Christian Biere systrace doesn't handle interrupted syscalls properly
Instead of jumping to the default "bad" case, jump to the error handling
switch, so that we can deal with ERESTART/EJUSTRETURN properly.
 1.7 31-Oct-2003  simonb Don't pass the (unused) return value args to the
trace_enter()/systrace_enter() functions.
 1.6 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.5 15-Jul-2003  lukem __KERNEL_RCSID()
 1.4 17-Jan-2003  thorpej branches: 1.4.2;
Merge the nathanw_sa branch.
 1.3 21-Dec-2002  manu Pass the system call table to trace_enter() and ktrsys() so that it is
possible to use alternate system call tables. This is usefull for
displaying correctly the arguments in Mach binaries traces.

If NULL is given, then the regular systam call table for the process is used.
 1.2 15-Nov-2002  manu Add a realcode argument to trace_enter and ktrsyscall. realcode is the
original system call number, which can be negative for a Mach trap.
We cannot just replace code by realcode, because ktrsyscall uses it as
an index in the system call table, thus crashing the kernel when the
value is negative.
 1.1 13-Jul-2002  scw branches: 1.1.2; 1.1.4; 1.1.6;
m68k syscall rototill:

- Switch all m68k-based ports over to __HAVE_SYSCALL_INTERN.
- Add systrace glue.
- Define struct mdproc in <m68k/proc.h> instead of <machine/proc.h>.
(They were all defined exactly the same anyway, other than a couple
of the MDP_* flags.)
 1.1.6.2 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.1.6.1 13-Jul-2002  jdolecek file linux_syscall.c was added on branch kqueue on 2002-09-06 08:36:48 +0000
 1.1.4.5 29-Dec-2002  thorpej Sync with HEAD.
 1.1.4.4 11-Dec-2002  thorpej Sync with HEAD.
 1.1.4.3 02-Aug-2002  gmcgarry LWPify.
 1.1.4.2 01-Aug-2002  nathanw Catch up to -current.
 1.1.4.1 13-Jul-2002  nathanw file linux_syscall.c was added on branch nathanw_sa on 2002-08-01 02:42:17 +0000
 1.1.2.2 16-Jul-2002  gehenna catch up with -current.
 1.1.2.1 13-Jul-2002  gehenna file linux_syscall.c was added on branch gehenna-devsw on 2002-07-16 08:36:50 +0000
 1.4.2.4 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.4.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.4.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.4.2.1 03-Aug-2004  skrll Sync with HEAD
 1.9.2.4 11-Feb-2008  yamt sync with head.
 1.9.2.3 21-Jan-2008  yamt sync with head
 1.9.2.2 03-Sep-2007  yamt sync with head.
 1.9.2.1 21-Jun-2006  yamt sync with head.
 1.10.6.1 22-Apr-2006  simonb Sync with head.
 1.10.4.1 09-Sep-2006  rpaulo sync with head
 1.11.2.2 13-Mar-2006  yamt sync with head.
 1.11.2.1 05-Mar-2006  yamt file linux_syscall.c was added on branch yamt-pdpolicy on 2006-03-13 09:06:57 +0000
 1.14.18.1 12-Mar-2007  rmind Sync with HEAD.
 1.14.2.2 07-Mar-2006  thorpej Syscall debug tracing is handled by trace_enter() / trace_exit(). Change
trace_is_enabled() to return TRUE if SYSCALL_DEBUG is defined, and g/c
all of the SYSCALL_DEBUG handling from individual system call dispatch
routines.
 1.14.2.1 07-Mar-2006  thorpej file linux_syscall.c was added on branch elad-kernelauth on 2006-03-07 07:21:51 +0000
 1.16.32.1 08-Jan-2008  bouyer Sync with HEAD
 1.16.26.1 18-Feb-2008  mjf Sync with HEAD.
 1.16.20.2 23-Mar-2008  matt sync with HEAD
 1.16.20.1 09-Jan-2008  matt sync with HEAD
 1.18.16.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.18.10.2 11-Mar-2010  yamt sync with head
 1.18.10.1 04-May-2009  yamt sync with head.
 1.18.6.1 17-Jan-2009  mjf Sync with HEAD.
 1.19.2.1 19-Jan-2009  skrll Sync with HEAD.
 1.21.8.1 17-Feb-2011  bouyer Sync with HEAD
 1.21.6.1 06-Jun-2011  jruoho Sync with HEAD.
 1.21.4.1 05-Mar-2011  rmind sync with head
 1.22.18.1 18-May-2014  rmind sync with head
 1.22.14.2 03-Dec-2017  jdolecek update from HEAD
 1.22.14.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.22.4.1 22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.23.6.1 06-Apr-2015  skrll Sync with HEAD
 1.11 23-Nov-2009  rmind Use lwp_getpcb() on m68k ports, clean from struct user usage.
 1.10 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.9 10-Feb-2007  tsutsui branches: 1.9.44; 1.9.46; 1.9.48;
Update for newlock2 merge.
 1.8 22-Jul-2006  tsutsui KNF and misc cosmetics
 1.7 11-Dec-2005  christos branches: 1.7.4; 1.7.8;
merge ktrace-lwp.
 1.6 28-Aug-2004  thorpej branches: 1.6.12;
Minor style nit.
 1.5 25-Sep-2003  christos constify siginfo/trapsignal
 1.4 22-Sep-2003  cl SA_SIGINFO support for m68k (emul linux)
 1.3 15-Jul-2003  lukem __KERNEL_RCSID()
 1.2 17-Jan-2003  thorpej branches: 1.2.2;
Merge the nathanw_sa branch.
 1.1 18-Jun-2001  christos branches: 1.1.2; 1.1.10;
Add a linux specific trapsignal() function. This is just a passthrough
on all platforms but the i386. On the i386 we look at T_PROTFLT and send
a SIGSEGV instead of SIGBUS. This makes allegro lisp 5.0 and pvs (a proof
verification system) to work.

XXX[1]: We need to go through each architecture and verify that we send
the correct signal on each trap type.
XXX[2]: trap.c on all other architectures but i386 needs to be modified
to s/trapsignal/(*p->p_emul->e_trapsignal)/g
 1.1.10.2 21-Jun-2002  gmcgarry LWPify.
 1.1.10.1 18-Jun-2001  gmcgarry file linux_trap.c was added on branch nathanw_sa on 2002-06-21 05:59:06 +0000
 1.1.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.2.2.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.2.2.3 18-Sep-2004  skrll Sync with HEAD.
 1.2.2.2 03-Sep-2004  skrll Sync with HEAD
 1.2.2.1 03-Aug-2004  skrll Sync with HEAD
 1.6.12.2 26-Feb-2007  yamt sync with head.
 1.6.12.1 30-Dec-2006  yamt sync with head.
 1.7.8.1 11-Aug-2006  yamt sync with head
 1.7.4.1 09-Sep-2006  rpaulo sync with head
 1.9.48.2 11-Mar-2010  yamt sync with head
 1.9.48.1 16-May-2008  yamt sync with head.
 1.9.46.1 18-May-2008  yamt sync with head.
 1.9.44.1 02-Jun-2008  mjf Sync with HEAD.
 1.11 06-Apr-2022  riastradh Nix trailing whitespace in files of membars, atomics, and lock stubs.

Will be touching many of these files soon for functional changes.

No functional change intended.
 1.10 08-Mar-2020  rin Remove mutex stubs for 68010 that merely fall back to C codes, and
do not work with kern_mutex.c rev 1.85 and later:

http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/kern/kern_mutex.c#rev1.85
http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/kern/kern_mutex.c#rev1.86

Fix sun2 kernel freeze during early boot stage in mutex_exit(9).
 1.9 01-Aug-2013  matt branches: 1.9.30;
Convert to motorola style.
 1.8 11-Nov-2009  skrll branches: 1.8.12; 1.8.22; 1.8.26;
Remove unnecessary and incorrect STRONG_ALIAS.
 1.7 25-May-2008  chs enable profiling of assembly functions.
 1.6 28-Apr-2008  martin branches: 1.6.2;
Remove clause 3 and 4 from TNF licenses
 1.5 05-Apr-2008  tsutsui branches: 1.5.2; 1.5.4;
Use generic atomic_cas_uint() for mutex(9) and rwlock(9), and
remodel old RAS based _lock_cas() implementation for m68010
into genereic atomic_cas_32().
Now sun2 kernel compiles and even works on multiuser. (hehe)

Tested on tme (emulationg 2/120 and 3/150) and (real) 3/80.
 1.4 02-Dec-2007  ad branches: 1.4.14;
Remove unused cpp goo
 1.3 11-Mar-2007  thorpej branches: 1.3.16; 1.3.18; 1.3.24;
Actually store the new value in the RAS _lock_cas(). Noticed by Izumi Tsutsui.
 1.2 11-Mar-2007  thorpej - Shrink ipl_cookie_t from 32-bits to 16-bits (large enough to hold
an SR value or an IPL_* constant).
- Take advange of the smaller ipl_cookie_t to shrink kmutex_t from
16 bytes to 8 bytes by overlapping storage where possible.
- Implement a RAS-based _lock_cas() for mc68010 systems (Sun2). See
sun68k/sun68k/isr.c.

Tested on various m68k platforms, but NOT Sun2. In any case, at least
Sun2 compiles now.
 1.1 15-Feb-2007  mhitch branches: 1.1.2; 1.1.4; 1.1.8;
Add lock stubs for m68k. Amiga builds and runs now.
 1.1.8.2 03-Dec-2007  ad Sync with HEAD.
 1.1.8.1 13-Mar-2007  ad Sync with head.
 1.1.4.4 07-Dec-2007  yamt sync with head
 1.1.4.3 03-Sep-2007  yamt sync with head.
 1.1.4.2 26-Feb-2007  yamt sync with head.
 1.1.4.1 15-Feb-2007  yamt file lock_stubs.s was added on branch yamt-lazymbuf on 2007-02-26 09:07:13 +0000
 1.1.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.3.24.1 08-Dec-2007  mjf Sync with HEAD.
 1.3.18.1 09-Jan-2008  matt sync with HEAD
 1.3.16.1 03-Dec-2007  joerg Sync with HEAD.
 1.4.14.1 02-Jun-2008  mjf Sync with HEAD.
 1.5.4.3 11-Mar-2010  yamt sync with head
 1.5.4.2 04-May-2009  yamt sync with head.
 1.5.4.1 16-May-2008  yamt sync with head.
 1.5.2.2 04-Jun-2008  yamt sync with head
 1.5.2.1 18-May-2008  yamt sync with head.
 1.6.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.8.26.1 28-Aug-2013  rmind sync with head
 1.8.22.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.8.12.1 22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.9.30.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.13 19-Jan-2024  thorpej Now that we've agreed on the name "intr_depth", let's agree on the type, too.
 1.12 19-Jan-2024  thorpej Consistently use "intr_depth" as the name of the interrupt depth counter
on m68k platforms.
 1.11 19-Jan-2024  thorpej Ensuire VECO_TO_VECI() returns an 8-bit index.
 1.10 16-Jan-2024  thorpej Add a hook to allow a platform to suppress reporting stray auto-vectored
interrupts.
 1.9 16-Jan-2024  thorpej Increment and decrement idepth in the assembly stubs, not C code. This
provides two advantages:
- Greater coverage for detecting "interrupt time".
- More flexibility for platform-specific interrupt stubs that might need
to do special processing before calling the common dispatcher.
 1.8 16-Jan-2024  thorpej - Declare idepth as volatile.
- Provide a m68k_intrvec_intrhand() routine that returns the interrupt
handle for a given vectored interrupt. XXX This is gross and should
burn to the ground, but is needed to support legacy ISR interfaces.
 1.7 15-Jan-2024  thorpej Insert a spurious interrupt handler at auto-vector IPL 0 that simply
abosrbs them. They'll get counted during the normal course of auto-vector
interrupt handling.
 1.6 15-Jan-2024  thorpej Provide a m68k_count_intr() macro that hides the details of how interrupts
are counted, and also ensures that ci_data.cpu_nintr is incremented.
 1.5 15-Jan-2024  thorpej Use evcnt to count interrupts for the non-__HAVE_LEGACY_INTRCNT case.
 1.4 15-Jan-2024  thorpej Add the "ISR priority" notion that's used on some m68k platforms:

/*
* Some devices are particularly sensitive to interrupt
* handling latency. Unbuffered serial ports, for example,
* can lose data if their interrupts aren't handled with
* reasonable speed. For this reason, we sort interrupt
* handlers by an abstract "ISR" priority, inserting higher-
* priority interrupts before lower-priority interrupts.
*/

(...within the same shared auto-vectored interrupt list.)
 1.3 15-Jan-2024  thorpej Wrap references to intrcnt[] in __HAVE_LEGACY_INTRCNT.
 1.2 15-Jan-2024  thorpej Declare intrcnt as a u_int array, and add a missing m68k_ih_free() call
in m68k_intr_disestablish().
 1.1 14-Jan-2024  thorpej Add a common m68k interrupt dispatch implementation.
 1.5 20-Jan-2024  thorpej Support the hardware-assisted AST on news68k in the common interrupt
stubs.
 1.4 19-Jan-2024  thorpej Consistently use "intr_depth" as the name of the interrupt depth counter
on m68k platforms.
 1.3 16-Jan-2024  thorpej Increment and decrement idepth in the assembly stubs, not C code. This
provides two advantages:
- Greater coverage for detecting "interrupt time".
- More flexibility for platform-specific interrupt stubs that might need
to do special processing before calling the common dispatcher.
 1.2 16-Jan-2024  thorpej - Declare idepth as volatile.
- Provide a m68k_intrvec_intrhand() routine that returns the interrupt
handle for a given vectored interrupt. XXX This is gross and should
burn to the ground, but is needed to support legacy ISR interfaces.
 1.1 14-Jan-2024  thorpej Add a common m68k interrupt dispatch implementation.
 1.12 16-Mar-2025  riastradh Clear trapframe on exec.

Do this for all architectures, even if the trapframe is fully
initialized -- makes it easier to audit and be confident it's
correct, and most likely (with the exception of sh3 which has an
intermediate call to ufetch_int in the middle) the compiler can
eliminate redundant stores in these routines.

PR kern/59084: exec/spawn leaks register content
 1.11 26-Sep-2023  tsutsui branches: 1.11.6;
Remove trailing spaces and TABs.
 1.10 06-Apr-2019  thorpej Overhaul the API used to fetch and store individual memory cells in
userspace. The old fetch(9) and store(9) APIs (fubyte(), fuword(),
subyte(), suword(), etc.) are retired and replaced with new ufetch(9)
and ustore(9) APIs that can return proper error codes, etc. and are
implemented consistently across all platforms. The interrupt-safe
variants are no longer supported (and several of the existing attempts
at fuswintr(), etc. were buggy and not actually interrupt-safe).

Also augmement the ucas(9) API, making it consistently available on
all plaforms, supporting uniprocessor and multiprocessor systems, even
those that do not have CAS or LL/SC primitives.

Welcome to NetBSD 8.99.37.
 1.9 16-May-2011  tsutsui branches: 1.9.56;
- merge and move pasted m68k MD setreg() functions into m68k/m68k_machdep.c
- move m68881_save() and m68881_restore() declarations into <m68k/m68k.h>

Briefly tested and no obvious breakage on atari, sun3, and x68k.
 1.8 07-Jul-2010  chs branches: 1.8.2;
implement ucas_* for m68k.
 1.7 28-Apr-2008  martin branches: 1.7.20; 1.7.22;
Remove clause 3 and 4 from TNF licenses
 1.6 11-Dec-2005  christos branches: 1.6.74; 1.6.76; 1.6.78;
merge ktrace-lwp.
 1.5 15-Jul-2003  lukem __KERNEL_RCSID()
 1.4 14-Jun-2000  veego branches: 1.4.26;
We don't need my name in this file.
 1.3 12-Jun-1997  veego branches: 1.3.22; 1.3.30;
Use <sys/param.h> and not <machine/param.h>
 1.2 09-Jun-1997  veego Initialize machine_arch from MACHINE_ARCH.
 1.1 06-Jun-1997  veego Add 'char machine_arch[] = "xxx";' for the new sysctl hw.machine_arch.
 1.3.30.1 22-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.3.22.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.4.26.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.4.26.2 18-Sep-2004  skrll Sync with HEAD.
 1.4.26.1 03-Aug-2004  skrll Sync with HEAD
 1.6.78.2 11-Aug-2010  yamt sync with head.
 1.6.78.1 16-May-2008  yamt sync with head.
 1.6.76.1 18-May-2008  yamt sync with head.
 1.6.74.1 02-Jun-2008  mjf Sync with HEAD.
 1.7.22.2 31-May-2011  rmind sync with head
 1.7.22.1 05-Mar-2011  rmind sync with head
 1.7.20.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.8.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.9.56.1 10-Jun-2019  christos Sync with HEAD
 1.11.6.1 02-Aug-2025  perseant Sync with HEAD
 1.55 05-Oct-2023  ad Arrange to update cached LWP credentials in userret() rather than during
syscall/trap entry, eliminating a test+branch on every syscall/trap.

This wasn't possible in the 3.99.x timeframe when l->l_cred came about
because there wasn't a reliable/timely way to force an ONPROC LWP running on
a remote CPU into the kernel (which is just about the only new thing in
this scheme).
 1.54 06-Apr-2019  kamil Centralized shared part of child_return() into MI part

Add a new function md_child_return() for MD specific bits only.

New child_return() is now part of MI and central code that handles
uniformly tracing code (KTR and ptrace(2)).

Synchronize value passed to ktrsysret() among ports to SYS_fork. This is
a traditional value and accessing p_lflag to check for PL_PPWAIT shall
use locking against proc_lock. Returning SYS_fork vs SYS_vfork still isn't
correct enough as there are more entry points to forking code. Instead of
making it too good, just settle with plain SYS_fork for all ports.
 1.53 06-Apr-2019  thorpej Overhaul the API used to fetch and store individual memory cells in
userspace. The old fetch(9) and store(9) APIs (fubyte(), fuword(),
subyte(), suword(), etc.) are retired and replaced with new ufetch(9)
and ustore(9) APIs that can return proper error codes, etc. and are
implemented consistently across all platforms. The interrupt-safe
variants are no longer supported (and several of the existing attempts
at fuswintr(), etc. were buggy and not actually interrupt-safe).

Also augmement the ucas(9) API, making it consistently available on
all plaforms, supporting uniprocessor and multiprocessor systems, even
those that do not have CAS or LL/SC primitives.

Welcome to NetBSD 8.99.37.
 1.52 03-Apr-2019  kamil Rework the fork(2)/vfork(2) event signalling under ptrace(2)

Remove the constraint of SIGTRAP event being maskable by a tracee.

Now all SIGTRAP TRAP_CHLD events are delivered to debugger.

This code touches MD specific logic and the child_return routine.
It's an intermediate step with a room for refactoring in future and
right now the least invasive approach. This allows to assert expected
behavior in already existing ATF tests and make the code prettier
in future keeping the same semantics. Probably there is a need for a MI
wrapper of child_return for shared functionality between ports.
 1.51 19-Dec-2018  maxv Remove compat_svr4 and compat_svr4_32, as discussed on tech-kern@ recently,
but also as discussed several times in the past.
 1.50 07-Mar-2015  christos branches: 1.50.16; 1.50.18;
adjust to new trace_{enter,exit} signatures.
 1.49 25-Oct-2013  martin branches: 1.49.6;
Mark a diagnostic-only variable
 1.48 19-Feb-2012  rmind branches: 1.48.2; 1.48.4;
Remove COMPAT_SA / KERN_SA. Welcome to 6.99.3!
Approved by core@.
 1.47 11-Feb-2012  martin Add a posix_spawn syscall, as discussed on tech-kern.
Based on the summer of code project by Charles Zhang, heavily reworked
later by me - all bugs are likely mine.
Ok: core, releng.
 1.46 08-Feb-2011  rmind branches: 1.46.4; 1.46.8;
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.45 20-Dec-2010  matt branches: 1.45.2; 1.45.4;
Move counting of faults, traps, intrs, soft[intr]s, syscalls, and nswtch
from uvmexp to per-cpu cpu_data and move them to 64bits. Remove unneeded
includes of <uvm/uvm_extern.h> and/or <uvm/uvm.h>.
 1.44 15-Oct-2010  tsutsui Get rid of more #ifdef COMPAT_AOUT_M68K dependent part.
Now compat_aoutm68k can be a module.

XXX: linux/svr4 ELF binaries also require a syscall return value in %a0?
 1.43 15-Oct-2010  tsutsui Fix typo.
 1.42 14-Oct-2010  tsutsui Un-ifdef COMPAT_AOUT_M68K for MODULAR kernel.
 1.41 26-Apr-2010  tsutsui lwp_uc_pool has been replaced with kmem(9)
so also replace <sys/pool.h> with <sys/kmem.h>.
 1.40 23-Apr-2010  rmind Remove lwp_uc_pool, replace it with kmem(9), plus add some consistency.
As discussed, a while ago, with ad@.
 1.39 25-Feb-2010  skrll branches: 1.39.2;
s/cpu_fork/cpu_lwp_fork/ in comment.
 1.38 23-Nov-2009  rmind branches: 1.38.2;
Use lwp_getpcb() on m68k ports, clean from struct user usage.
 1.37 11-Jan-2009  martin Now that COMPAT_50 is needed inside the kernel for the time_t changes,
piggyback it and guard the copying of syscall return values on it. Our
libc has been fixed quite some time ago, time to get rid of the bogus copy.
 1.36 21-Oct-2008  ad branches: 1.36.2;
Provide a small inline wrapper for sysent::sy_call() and use it to store
the active syscall description in struct lwp. To be used at some future
point to prevent unloading of modules that provide syscalls, while the
syscalls are in use.
 1.35 15-Oct-2008  wrstuden Merge wrstuden-revivesa into HEAD.
 1.34 06-Feb-2008  dsl branches: 1.34.6; 1.34.10; 1.34.12; 1.34.16;
Remove the 'args' parameter to 'trace_exit()' it is no longer used.
Instead of passing the (un)real system call code and syscall table pointer,
just pass the number of arguments - which is what ktrace really wants.
Ride forthcoming 4.99.53
 1.33 05-Jan-2008  dsl Don't pass 'curlwp' into trace_enter() and trace_exit().
 1.32 31-Dec-2007  ad Remove COMPAT_HPUX.
 1.31 29-Dec-2007  martin Make the copy of the syscall return value to register A0 independend of
options COMPAT_AOUT_M68K. Works around PR port-m68k/37631.
XXX we will phase out the copy to A0 completely and handle it in userland
XXX in the future.
 1.30 17-Oct-2007  garbled branches: 1.30.2; 1.30.8;
Merge the ppcoea-renovation branch to HEAD.

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

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

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.29 15-Aug-2007  ad branches: 1.29.2;
Changes to make ktrace LKM friendly and reduce ifdef KTRACE. Proposed
on tech-kern.
 1.28 04-Mar-2007  tsutsui branches: 1.28.2; 1.28.10; 1.28.14; 1.28.18;
Replace (void *) with (char *) where pointer arith is required.
 1.27 04-Mar-2007  christos Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.26 09-Feb-2007  ad branches: 1.26.2;
Merge newlock2 to head.
 1.25 22-Jul-2006  tsutsui branches: 1.25.4;
TAB/space cleanup.
 1.24 19-Jul-2006  ad - Hold a reference to the process credentials in each struct lwp.
- Update the reference on syscall and user trap if p_cred has changed.
- Collect accounting flags in the LWP, and collate on LWP exit.
 1.23 07-Mar-2006  thorpej branches: 1.23.2;
Syscall debug tracing is handled by trace_enter() / trace_exit(). Change
trace_is_enabled() to return TRUE if SYSCALL_DEBUG is defined, and g/c
all of the SYSCALL_DEBUG handling from individual system call dispatch
routines.
 1.22 07-Mar-2006  thorpej Clean up fallout proc_is_traced_p() change:
- proc_is_traced_p() -> trace_is_enabled(), to match trace_enter() and
trace_exit().
- trace_is_enabled() becomes a real function.
- Remove unnecessary include files from various files that used to care
about KTRACE and SYSTRACE, but do no more.
 1.21 06-Mar-2006  he syscall_fancy is only defined if either KTRACE or SYSTRACE is set,
so enclose its use in the same set of conditionals.
 1.20 05-Mar-2006  rjs Always define syscall_fancy.
 1.19 05-Mar-2006  christos Add a proc_is_traced_p() macro and use it, instead of copying the same code
in many places. Idea from thorpej.
 1.18 05-Mar-2006  christos branches: 1.18.2;
implement PT_SYSCALL
 1.17 11-Dec-2005  christos branches: 1.17.4; 1.17.6;
merge ktrace-lwp.
 1.16 10-Jul-2005  christos No point in declaring syscall_intern and syscall in a zillion places.
 1.15 01-Jul-2005  christos branches: 1.15.2;
PR/29607: Christian Biere systrace doesn't handle interrupted syscalls properly
Instead of jumping to the default "bad" case, jump to the error handling
switch, so that we can deal with ERESTART/EJUSTRETURN properly.
 1.14 28-Aug-2004  thorpej Use ANSI function decls and static.
 1.13 31-Oct-2003  simonb Don't pass the (unused) return value args to the
trace_enter()/systrace_enter() functions.
 1.12 22-Sep-2003  cl SA_SIGINFO support for m68k
 1.11 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.10 15-Jul-2003  lukem __KERNEL_RCSID()
 1.9 29-Jun-2003  fvdl branches: 1.9.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.8 28-Jun-2003  darrenr Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V
 1.7 17-Jan-2003  thorpej Merge the nathanw_sa branch.
 1.6 21-Dec-2002  manu Pass the system call table to trace_enter() and ktrsys() so that it is
possible to use alternate system call tables. This is usefull for
displaying correctly the arguments in Mach binaries traces.

If NULL is given, then the regular systam call table for the process is used.
 1.5 15-Nov-2002  manu Add a realcode argument to trace_enter and ktrsyscall. realcode is the
original system call number, which can be negative for a Mach trap.
We cannot just replace code by realcode, because ktrsyscall uses it as
an index in the system call table, thus crashing the kernel when the
value is negative.
 1.4 17-Jul-2002  fredette Only declare and define syscall_fancy if KTRACE and/or SYSTRACE are defined.
 1.3 13-Jul-2002  scw m68k syscall rototill:

- Switch all m68k-based ports over to __HAVE_SYSCALL_INTERN.
- Add systrace glue.
- Define struct mdproc in <m68k/proc.h> instead of <machine/proc.h>.
(They were all defined exactly the same anyway, other than a couple
of the MDP_* flags.)
 1.2 17-Jun-2002  christos MD systrace gluons.
 1.1 19-Dec-2000  scw branches: 1.1.2; 1.1.6; 1.1.10; 1.1.18;
Unification of the m68k syscall() function.
 1.1.18.3 21-Jul-2002  gehenna catch up with -current.
 1.1.18.2 16-Jul-2002  gehenna catch up with -current.
 1.1.18.1 14-Jul-2002  gehenna catch up with -current.
 1.1.10.10 29-Dec-2002  thorpej Sync with HEAD.
 1.1.10.9 11-Dec-2002  thorpej Sync with HEAD.
 1.1.10.8 02-Aug-2002  gmcgarry LWPify.
 1.1.10.7 01-Aug-2002  nathanw Catch up to -current.
 1.1.10.6 12-Jul-2002  nathanw No longer need to pull in lwp.h; proc.h pulls it in for us.
 1.1.10.5 24-Jun-2002  nathanw Curproc->curlwp renaming.

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

"curproc" is now #defined in proc.h as ((curlwp) ? (curlwp)->l_proc) : NULL)
so that it is always safe to reference curproc (*de*referencing curproc
is another story, but that's always been true).
 1.1.10.4 20-Jun-2002  nathanw Catch up to -current.
 1.1.10.3 04-Dec-2001  gmcgarry Make it compile with KTRACE.
 1.1.10.2 17-Nov-2001  scw Re-sync with current MI SA code.
 1.1.10.1 17-Nov-2001  scw Kernel support for Scheduler Activations on m68k-based ports using
mvme68k as a testbed.

Boots multi-user on an mvme162, although userland support for SA is not
yet integrated/tested.
 1.1.6.1 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.1.2.2 05-Jan-2001  bouyer Sync with HEAD
 1.1.2.1 19-Dec-2000  bouyer file m68k_syscall.c was added on branch thorpej_scsipi on 2001-01-05 17:34:36 +0000
 1.9.2.6 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.9.2.5 21-Sep-2004  skrll Fix the sync with head I botched.
 1.9.2.4 18-Sep-2004  skrll Sync with HEAD.
 1.9.2.3 03-Sep-2004  skrll Sync with HEAD
 1.9.2.2 03-Aug-2004  skrll Sync with HEAD
 1.9.2.1 02-Jul-2003  darrenr Apply the aborted ktrace-lwp changes to a specific branch. This is just for
others to review, I'm concerned that patch fuziness may have resulted in some
errant code being generated but I'll look at that later by comparing the diff
from the base to the branch with the file I attempt to apply to it. This will,
at the very least, put the changes in a better context for others to review
them and attempt to tinker with removing passing of 'struct lwp' through
the kernel.
 1.15.2.6 11-Feb-2008  yamt sync with head.
 1.15.2.5 21-Jan-2008  yamt sync with head
 1.15.2.4 03-Sep-2007  yamt sync with head.
 1.15.2.3 26-Feb-2007  yamt sync with head.
 1.15.2.2 30-Dec-2006  yamt sync with head.
 1.15.2.1 21-Jun-2006  yamt sync with head.
 1.17.6.1 22-Apr-2006  simonb Sync with head.
 1.17.4.1 09-Sep-2006  rpaulo sync with head
 1.18.2.3 11-Aug-2006  yamt sync with head
 1.18.2.2 13-Mar-2006  yamt sync with head.
 1.18.2.1 05-Mar-2006  yamt file m68k_syscall.c was added on branch yamt-pdpolicy on 2006-03-13 09:06:57 +0000
 1.23.2.2 07-Mar-2006  thorpej Syscall debug tracing is handled by trace_enter() / trace_exit(). Change
trace_is_enabled() to return TRUE if SYSCALL_DEBUG is defined, and g/c
all of the SYSCALL_DEBUG handling from individual system call dispatch
routines.
 1.23.2.1 07-Mar-2006  thorpej file m68k_syscall.c was added on branch elad-kernelauth on 2006-03-07 07:21:51 +0000
 1.25.4.1 30-Jan-2007  ad Remove support for SA. Ok core@.
 1.26.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.28.18.1 16-Aug-2007  jmcneill Sync with HEAD.
 1.28.14.1 03-Sep-2007  skrll Sync with HEAD.
 1.28.10.1 03-Oct-2007  garbled Sync with HEAD
 1.28.2.1 20-Aug-2007  ad Sync with HEAD.
 1.29.2.3 23-Mar-2008  matt sync with HEAD
 1.29.2.2 09-Jan-2008  matt sync with HEAD
 1.29.2.1 06-Nov-2007  matt sync with HEAD
 1.30.8.2 08-Jan-2008  bouyer Sync with HEAD
 1.30.8.1 02-Jan-2008  bouyer Sync with HEAD
 1.30.2.1 18-Feb-2008  mjf Sync with HEAD.
 1.34.16.2 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.34.16.1 19-Oct-2008  haad Sync with HEAD.
 1.34.12.3 15-Oct-2008  wrstuden Add sys/sa.h and sys/savar.h which I think are needed with
today's syscall change.
 1.34.12.2 14-Oct-2008  wrstuden Add a new vp-private flag, SAVP_FLAG_DELIVERING. This flag indicates
that the vp is in the process of delivering a new-thread upcall.
This is a BLOCKED or NEWPROC upcall. Do NOT generate any BLOCKED
upcalls while this is set. Set it at the end of sa_switchcall()
and clear it at syscall entry. Sadly, I have found no other
way to handle this. The old SA interface has no way for
userland to acknowledge that it got the upcall, so use syscall
entry as the indicator that libpthread got it.

This addresses the issue seen on current-users with firefox
dying with a blockedgen != unbockedgen error. The problem is we
deliver a BLOCKED upcall, but between the end of userret()
and when the CPU indicates that it's running in user mode, we take
a page fault. Said page fault blocks, blocking upcall delivery.
The original block, however, was short-lived, and the UNBLOCK
happens shortly. It happens before libpthread actually notices
the BLOCKED upcall. Boom!

Unfortunately a LOCKDEBUG/DIAGNOSTIC kernel still dies before
firefox opens. However this new issue is with uvm code calling
mtsleep when not holding a correct lock; sa_switch() is exploding
at KASSERT(lwp_locked(l, NULL)); before it's done _anything_.

Also, while here, add sa_system_disabled. This is an integer
that we examine when starting SA for a proc. If it's non-zero,
we error out. Once this is hooked into sysctl, you'll be able to
disable SA w/o recompiling.
 1.34.12.1 22-Jun-2008  wrstuden Re-add cpu_upcall() and page fault code. i386 kernels now compile.
They don't boot, but that seems to be a consequence of current from the
day this branch was started.
 1.34.10.3 11-Aug-2010  yamt sync with head.
 1.34.10.2 11-Mar-2010  yamt sync with head
 1.34.10.1 04-May-2009  yamt sync with head.
 1.34.6.1 17-Jan-2009  mjf Sync with HEAD.
 1.36.2.1 19-Jan-2009  skrll Sync with HEAD.
 1.38.2.2 22-Oct-2010  uebayasi Sync with HEAD (-D20101022).
 1.38.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.39.2.2 05-Mar-2011  rmind sync with head
 1.39.2.1 30-May-2010  rmind sync with head
 1.45.4.1 17-Feb-2011  bouyer Sync with HEAD
 1.45.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.46.8.2 24-Feb-2012  mrg sync to -current.
 1.46.8.1 18-Feb-2012  mrg merge to -current.
 1.46.4.2 22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.46.4.1 17-Apr-2012  yamt sync with head
 1.48.4.1 18-May-2014  rmind sync with head
 1.48.2.2 03-Dec-2017  jdolecek update from HEAD
 1.48.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.49.6.1 06-Apr-2015  skrll Sync with HEAD
 1.50.18.1 10-Jun-2019  christos Sync with HEAD
 1.50.16.1 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.4 20-Jan-2024  thorpej Largely unify the <machine/cpu.h> headers on the m68k platforms.
 1.3 06-Mar-2021  martin Minimal (but hackish) change to make a DEBUG kernel compilable.
 1.2 06-Apr-2019  thorpej branches: 1.2.4; 1.2.6; 1.2.14;
Overhaul the API used to fetch and store individual memory cells in
userspace. The old fetch(9) and store(9) APIs (fubyte(), fuword(),
subyte(), suword(), etc.) are retired and replaced with new ufetch(9)
and ustore(9) APIs that can return proper error codes, etc. and are
implemented consistently across all platforms. The interrupt-safe
variants are no longer supported (and several of the existing attempts
at fuswintr(), etc. were buggy and not actually interrupt-safe).

Also augmement the ucas(9) API, making it consistently available on
all plaforms, supporting uniprocessor and multiprocessor systems, even
those that do not have CAS or LL/SC primitives.

Welcome to NetBSD 8.99.37.
 1.1 18-Feb-2019  thorpej Refactor the 68040 writeback() from each m68k port's trap handler into a
shared copy: m68040_writeback(). It is essentially a copy of the Atari
version, with some minor cosmetic tweaks and one small performance optimization
from the mvme68k port.

Tested by rjs@ on a Quadra 950. (Thanks!)
 1.2.14.1 03-Apr-2021  thorpej Sync with HEAD.
 1.2.6.1 30-Aug-2022  martin Pull up following revision(s) (requested by tsutsui in ticket #1513):

sys/arch/m68k/m68k/m68k_trap.c: revision 1.3

Minimal (but hackish) change to make a DEBUG kernel compilable.
 1.2.4.2 10-Jun-2019  christos Sync with HEAD
 1.2.4.1 06-Apr-2019  christos file m68k_trap.c was added on branch phil-wifi on 2019-06-10 22:06:26 +0000
 1.28 14-Mar-2019  thorpej G/C "MAPPECOPY". It is the deadest of wood, and never actually worked in
NetBSD.
 1.27 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.26 08-Feb-2011  rmind branches: 1.26.54; 1.26.56;
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.25 05-Mar-2007  dogcow branches: 1.25.66; 1.25.72; 1.25.74;
semimechanically convert 'void foo' -> 'void *foo', as part of the continuing
caddr_t fallout.
 1.24 04-Mar-2007  christos Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.23 22-Feb-2007  thorpej TRUE -> true, FALSE -> false
 1.22 22-Jul-2006  tsutsui branches: 1.22.10;
KNF, ANSIfy, remove register decls
 1.21 11-Dec-2005  christos branches: 1.21.4; 1.21.8;
merge ktrace-lwp.
 1.20 01-Apr-2005  yamt branches: 1.20.2;
merge yamt-km branch.
- don't use managed mappings/backing objects for wired memory allocations.
save some resources like pv_entry. also fix (most of) PR/27030.
- simplify kernel memory management API.
- simplify pmap bootstrap of some ports.
- some related cleanups.
 1.19 04-Dec-2003  keihan branches: 1.19.8; 1.19.10;
netbsd.org -> NetBSD.org

All "netbsd.org" is now gone from src/sys/arch.
 1.18 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.17 15-Jul-2003  lukem __KERNEL_RCSID()
 1.16 02-Apr-2003  thorpej branches: 1.16.2;
Use PAGE_SIZE rather than NBPG.
 1.15 10-Sep-2001  chris branches: 1.15.4;
Update pmap_update to now take the updated pmap as an argument.
This will allow improvements to the pmaps so that they can more easily defer expensive operations, eg tlb/cache flush, til the last possible moment.

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

Reviewed by Jason.
 1.14 28-Jul-2001  tsutsui branches: 1.14.2;
bcopy -> memcpy
 1.13 24-Apr-2001  thorpej branches: 1.13.2;
Sprinkle pmap_update() calls after calls to:
- pmap_enter()
- pmap_remove()
- pmap_protect()
- pmap_kenter_pa()
- pmap_kremove()
as described in pmap(9).

These calls are relatively conservative. It may be possible to
optimize these a little more.
 1.12 29-Jun-2000  mrg branches: 1.12.2;
remove include of <vm/vm.h>. <vm/vm.h> -> <uvm/uvm_extern.h>
 1.11 26-Jun-2000  mrg remove/move more mach vm header files:

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

also includes a bunch of <vm/vm_page.h> include removals (due to redudancy
with <vm/vm.h>), and a scattering of other similar headers.
 1.10 26-Mar-2000  kleink Merge parts of chs-ubc2 into the trunk:
* Remove the casts to vaddr_t from the round_page() and trunc_page() macros to
make them type-generic, which is necessary i.e. to operate on file offsets
without truncating them.
* In due course, cast pointer arguments to these macros to an appropriate
integral type (paddr_t, vaddr_t).

Originally done by Chuck Silvers, updated by myself.
 1.9 18-Nov-1999  minoura pmap_enter() change.
 1.8 25-Sep-1999  is branches: 1.8.2; 1.8.8;
vm_offset_t -> vaddr_t or paddr_t, as appropriate.
 1.7 05-Aug-1999  minoura Use of pointer to register variables.
 1.6 08-Jul-1999  thorpej 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.5 18-Apr-1999  minoura Typo fix.
 1.4 31-Mar-1999  minoura branches: 1.4.2;
CADDR1 and CADDR2 should not be used here.
 1.3 26-Mar-1999  mycroft Changes for modified pmap_enter() API:
* Map the message buffer with access_type = VM_PROT_READ|VM_PROT_WRITE `just
because'.
* Map the file system buffers with access_type = VM_PROT_READ|VM_PROT_WRITE to
avoid possible problems with pagemove().
* Do not use VM_PROT_EXEC with either of the above.
* Map pages for /dev/mem with access_type = prot. Also, DO NOT use
pmap_kenter() for this, as we DO NOT want to lose modification information.
* Map pages in dumpsys() with VM_PROT_READ.
* Map pages in m68k mappedcopyin()/mappedcopyout() and writeback() with
access_type = prot.
* For now, bus_dma*(), pmap_map(), vmapbuf(), and similar functions still use
access_type = 0. This should probably be revisited.
 1.2 09-Jan-1999  itohy Eliminate `void *' arithmetic.
 1.1 02-Feb-1997  thorpej Add the Utah mappedcopyin/mappedcopyout functions to a common m68k
area. These functions are designed to improve performance of large
copyin/copyout operations by mapping the user page in to the kernel
address space and using bcopy(), rather then copying across protection
boundaries.

XXX This doesn't work yet -- the way it's called doesn't obey C calling
XXX conventions. That will be fixed soon.
 1.4.2.1 19-Apr-1999  cjs branches: 1.4.2.1.2;
Pull up to HEAD 1.5, per MINOURA Makoto <minoura@netbsd.org>.
 1.4.2.1.2.2 02-Aug-1999  thorpej Update from trunk.
 1.4.2.1.2.1 21-Jun-1999  thorpej Sync w/ -current.
 1.8.8.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.8.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.12.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.13.2.2 13-Sep-2001  thorpej Update the kqueue branch to HEAD.
 1.13.2.1 03-Aug-2001  lukem update to -current
 1.14.2.1 01-Oct-2001  fvdl Catch up with -current.
 1.15.4.4 12-Jul-2002  nathanw No longer need to pull in lwp.h; proc.h pulls it in for us.
 1.15.4.3 24-Jun-2002  nathanw Curproc->curlwp renaming.

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

"curproc" is now #defined in proc.h as ((curlwp) ? (curlwp)->l_proc) : NULL)
so that it is always safe to reference curproc (*de*referencing curproc
is another story, but that's always been true).
 1.15.4.2 17-Nov-2001  scw Kernel support for Scheduler Activations on m68k-based ports using
mvme68k as a testbed.

Boots multi-user on an mvme162, although userland support for SA is not
yet integrated/tested.
 1.15.4.1 10-Sep-2001  scw file mappedcopy.c was added on branch nathanw_sa on 2001-11-17 13:07:53 +0000
 1.16.2.4 01-Apr-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.10.1 26-Jan-2005  yamt convert arch/m68k to new apis.
 1.19.8.1 29-Apr-2005  kent sync with -current
 1.20.2.3 03-Sep-2007  yamt sync with head.
 1.20.2.2 26-Feb-2007  yamt sync with head.
 1.20.2.1 30-Dec-2006  yamt sync with head.
 1.21.8.1 11-Aug-2006  yamt sync with head
 1.21.4.1 09-Sep-2006  rpaulo sync with head
 1.22.10.2 12-Mar-2007  rmind Sync with HEAD.
 1.22.10.1 27-Feb-2007  yamt - sync with head.
- move sched_changepri back to kern_synch.c as it doesn't know PPQ anymore.
 1.25.74.1 17-Feb-2011  bouyer Sync with HEAD
 1.25.72.1 06-Jun-2011  jruoho Sync with HEAD.
 1.25.66.1 05-Mar-2011  rmind sync with head
 1.26.56.1 10-Jun-2019  christos Sync with HEAD
 1.26.54.1 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.4 17-Aug-2025  isaki m68k: Fix invalid instruction word.
PMOVE <ea>,TTn instruction doesn't support (An)+ addressing mode on 68030.
While some emulators (like QEMU) execute it without error, the real 68030
triggers a F-line trap.
Need to pullup netbsd-11.
 1.3 08-Jul-2025  thorpej branches: 1.3.2;
Add common '030 and '040/'060 routines for configuring the transparent
translation registers. Adjust luna68k and news68k to use them.
 1.2 09-Jan-2024  thorpej branches: 1.2.2;
Statically-initialize the '851 / '030 protorp with MMU51_SRP_BITS. In
pmap_init(), re-initialize protorp with MMU51_CRP_BITS. Remove the now-
redundant code that does this in each of the m68k platforms.
 1.1 09-Jan-2024  thorpej Remove duplicated / slightly-tweaked loadustp() (load user segment table)
routines from all of the m68k ports using the shared pmap. Instead, in
pmap_init(), set up a function pointer to the appropriate mmu_load_urp*()
function in mmu_subr.s.
 1.2.2.1 02-Aug-2025  perseant Sync with HEAD
 1.3.2.1 27-Aug-2025  martin Pull up following revision(s) (requested by isaki in ticket #20):

sys/arch/m68k/m68k/mmu_subr.s: revision 1.4

m68k: Fix invalid instruction word.

PMOVE <ea>,TTn instruction doesn't support (An)+ addressing mode on 68030.
 1.6 06-Apr-2000  jdolecek Switch to MI ns_cksum.c - the MD ns_cksum.c is equivalent to it
(modulo some u_intX_t vs. u_char type usage). In particular, the
MD version didn't contain any MD code.
 1.5 01-Apr-1996  briggs branches: 1.5.30;
Clean up for higher warning level.
 1.4 26-Oct-1994  cgd new RCS ID format.
 1.3 08-Jan-1994  cgd common code
 1.2 22-May-1993  cgd add rcsids to everything and clean up headers
 1.1 13-May-1993  cgd add from net2. was symlink to ../../tahoe/tahoe/ns_cksum.c
 1.5.30.1 20-Nov-2000  bouyer Remove files that are no longer on the trunck
 1.11 26-Sep-2023  tsutsui TAB/space cleanup.
 1.10 26-Sep-2023  tsutsui Remove trailing spaces and TABs.
 1.9 07-Sep-2013  chs switch to ELF naming for local labels.
 1.8 22-Jul-2013  matt use mvz[wb] when possible
 1.7 22-Jul-2013  matt Use motorola syntax
Adjust for coldfire
(no binary difference for non-coldfire
 1.6 23-Dec-2011  tsutsui branches: 1.6.6; 1.6.10; 1.6.18;
Remove UCB clause 3.
 1.5 10-Nov-1999  thorpej branches: 1.5.168; 1.5.172;
Add register prefixes.
 1.4 26-Oct-1994  cgd branches: 1.4.32; 1.4.34; 1.4.38;
new RCS ID format.
 1.3 01-Mar-1994  glass should use ENTRY() macro
 1.2 22-May-1993  cgd add rcsids to everything and clean up headers
 1.1 13-May-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.1 13-May-1993  cgd add hp300 kernel files. generic kernel files might need some help...
 1.4.38.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.4.34.1 15-Nov-1999  fvdl Sync with -current
 1.4.32.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.172.1 18-Feb-2012  mrg merge to -current.
 1.5.168.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.5.168.1 17-Apr-2012  yamt sync with head
 1.6.18.1 23-Jul-2013  riastradh sync with HEAD
 1.6.10.2 18-May-2014  rmind sync with head
 1.6.10.1 28-Aug-2013  rmind sync with head
 1.6.6.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.89 19-Jan-2024  thorpej Move physaccess(), physunaccess(), and kvtop() from vm_machdep.c to
pmap_motorola.c. They're legacy functions tied to that pmap implementation.
 1.88 18-Jan-2024  thorpej Make the M68K_MMU_* defines real kernel options, available in opt_m68k_arch.h.
For 68030, 68040, and 68060, infer M68K_MMU_MOTOROLA. For 68010 and 68020, it
must be an explicit option (set in std.${MACHINE} or, in the case of hp300,
inferred from the specific model option).
 1.87 09-Jan-2024  thorpej Statically-initialize the '851 / '030 protorp with MMU51_SRP_BITS. In
pmap_init(), re-initialize protorp with MMU51_CRP_BITS. Remove the now-
redundant code that does this in each of the m68k platforms.
 1.86 09-Jan-2024  thorpej Remove duplicated / slightly-tweaked loadustp() (load user segment table)
routines from all of the m68k ports using the shared pmap. Instead, in
pmap_init(), set up a function pointer to the appropriate mmu_load_urp*()
function in mmu_subr.s.
 1.85 31-Dec-2023  thorpej Provide a vtophys() function like other platforms do, and implement
kvtop() (which will be g/c'd shortly) in terms of it.
 1.84 28-Dec-2023  thorpej Missed 2 68060-specific cases in previous.
 1.83 28-Dec-2023  thorpej Be more careful with the types used for PTEs.
 1.82 26-Dec-2023  thorpej Move active_pmap() and active_user_pmap() macros into pmap_motorola.c
 1.81 26-Dec-2023  thorpej - G/C the PMAP_ACTIVATE() macro, just call loadustp() directly.
- In pmap_activate(), rather than checking for an idle LWP and skipping
the loadustp() in that case, just check if the pmap being activate is
the kernel pmap. Also, KASSERT() that the specified lwp is the current
lwp.
 1.80 20-Dec-2023  thorpej Remove unnecessary <sys/malloc.h> include.
 1.79 26-Sep-2023  tsutsui TAB/space cleanup.
 1.78 26-Sep-2023  tsutsui Remove trailing spaces and TABs.
 1.77 31-Jul-2022  chs in pmap_enter_ptpage(), if we are allowed to fail then fail rather than
waiting for memory to be available. when we are mapping an anon or uobj page
then we will be holding the lock for that page owner, and sleeping to wait
for memory with a page owner lock held is illegal because the pagedaemon
can wait for that lock, which will lead to deadlock. fixes PR 56932.
 1.76 16-Apr-2022  andvar fix various typos in comments and log messages.
 1.75 12-Oct-2021  andvar fix various typos, mainly in comments.
 1.74 16-Apr-2021  mrg check the result value of pmap_extract() and panic if it fails.
this is a "should never fail" case, and GCC 10 noticed that it
allows an uninitialised variable use.

tested by rin@ on amiga and mac68k.
 1.73 01-Feb-2021  skrll branches: 1.73.2;
"as appropos" -> "as appropriate" in comments
 1.72 23-Feb-2020  ad branches: 1.72.6;
UVM locking changes, proposed on tech-kern:

- Change the lock on uvm_object, vm_amap and vm_anon to be a RW lock.
- Break v_interlock and vmobjlock apart. v_interlock remains a mutex.
- Do partial PV list locking in the x86 pmap. Others to follow later.
 1.71 03-Sep-2018  riastradh branches: 1.71.6;
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.70 27-Jan-2018  chs branches: 1.70.2; 1.70.4;
apply the change from arch/x86/x86/pmap.c rev. 1.266 commitid vZRjvmxG7YTHLOfA:

In pmap_enter_ma(), only try to allocate pves if we might need them,
and even if that fails, only fail the operation if we later discover
that we really do need them. If we are replacing an existing mapping,
reuse the pv structure where possible.

This implements the requirement that pmap_enter(PMAP_CANFAIL) must not fail
when replacing an existing mapping with the first mapping of a new page,
which is an unintended consequence of the changes from the rmind-uvmplock
branch in 2011.

The problem arises when pmap_enter(PMAP_CANFAIL) is used to replace an existing
pmap mapping with a mapping of a different page (eg. to resolve a copy-on-write).
If that fails and leaves the old pmap entry in place, then UVM won't hold
the right locks when it eventually retries. This entanglement of the UVM and
pmap locking was done in rmind-uvmplock in order to improve performance,
but it also means that the UVM state and pmap state need to be kept in sync
more than they did before. It would be possible to handle this in the UVM code
instead of in the pmap code, but these pmap changes improve the handling of
low memory situations in general, and handling this in UVM would be clunky,
so this seemed like the better way to go.

This somewhat indirectly fixes PR 52706 on the remaining platforms where
this problem existed.
 1.69 23-Dec-2016  cherry branches: 1.69.8;
"Make NetBSD great again!"

Introduce uvm_hotplug(9) to the kernel.

Many thanks, in no particular order to:

TNF, for funding the project.

Chuck Silvers - for multiple API reviews and feedback.
Nick Hudson - for testing on multiple architectures and bugfix patches.
Everyone who helped with boot testing.

KeK (http://www.kek.org.in) for hosting the primary developers.
 1.68 22-Dec-2016  cherry switch all ports to use uvm_init.c:uvm_md_init()

uvm_setpagesize() is now subsumed within this funciton.
 1.67 25-Oct-2013  martin branches: 1.67.6; 1.67.10;
Mark a potentialy unused variable
 1.66 09-Jul-2012  rkujawa branches: 1.66.2; 1.66.4;
Set user page table base address dynamically on amiga. This unbreaks machines
with large Zorro III I/O spaces. Patch originally by Michael L. Hitch.
Test on an A4000.
 1.65 27-Jan-2012  para branches: 1.65.2; 1.65.8;
extending vmem(9) to be able to allocated resources for it's own needs.
simplifying uvm_map handling (no special kernel entries anymore no relocking)
make malloc(9) a thin wrapper around kmem(9)
(with private interface for interrupt safety reasons)

releng@ acknowledged
 1.64 03-Nov-2011  tsutsui branches: 1.64.4;
Use pool_allocator_meta rather than pool_allocator_nointr to allocate
struct pv_entry pool in the previous fix for PR port-m68k/45519.
Per comment from yamt@ on source-changes-d@:
http://mail-index.NetBSD.org/source-changes-d/2011/10/31/msg004211.html
 1.63 29-Oct-2011  tsutsui branches: 1.63.2;
Use pool(9) for struct pv_entry allocations rather than
uvm_km_alloc(9)/uvm_km_free(9) and ancient homegrown pv_page_info structures.

Calling uvm_km_free(9) during pmap_remove(9) could cause rw_lock error
in uvm_unmap1() as noted in PR port-m68k/45519.

NetBSD/x68k (both real X68030 and XM6i emulator) still gets weird panic
(corrupted kernel stack pointer?) on some heavy load:
---
panic: MMU fault
Stopped in pid 363.1 (X68k) at netbsd:cpu_Debugger+0x6: unlk a6
db> tr
cpu_Debugger(4012004,8,1cbb528,2a618e0,2a5b000) + 6
db>
---
but it also occurs without this change so there might be some more bugs
in m68k pmap...
 1.62 12-Jun-2011  rmind Welcome to 5.99.53! Merge rmind-uvmplock branch:

- Reorganize locking in UVM and provide extra serialisation for pmap(9).
New lock order: [vmpage-owner-lock] -> pmap-lock.

- Simplify locking in some pmap(9) modules by removing P->V locking.

- Use lock object on vmobjlock (and thus vnode_t::v_interlock) to share
the locks amongst UVM objects where necessary (tmpfs, layerfs, unionfs).

- Rewrite and optimise x86 TLB shootdown code, make it simpler and cleaner.
Add TLBSTATS option for x86 to collect statistics about TLB shootdowns.

- Unify /dev/mem et al in MI code and provide required locking (removes
kernel-lock on some ports). Also, avoid cache-aliasing issues.

Thanks to Andrew Doran and Joerg Sonnenberger, as their initial patches
formed the core changes of this branch.
 1.61 03-Jun-2011  tsutsui - remove simple_lock(9) and use atomic_ops(3) to account pmap reference count,
perrequest from rmind@
- while here no need to export struct pmap on sun2/sun3/sun3x

No particular problem for a week on hp300 and sun3x kernels with disabled
tcp_vtw which has been broken for a month on low memory machines.
 1.60 14-Jan-2011  rmind branches: 1.60.2; 1.60.6;
Retire struct user, remove sys/user.h inclusions. Note sys/user.h header
as obsolete. Remove USER_TO_UAREA/UAREA_TO_USER macros.

Various #include fixes and review by matt@.
 1.59 06-Jan-2011  tsutsui Use #ifdef CACHE_HAVE_VAC rather than #ifdef M68K_MMU_HP where
the pmap code indends.
(though currently only MMU_HP machines have VAC in pmap_motorola ports)
 1.58 02-Jan-2011  tsutsui Make pmap_aliasmask unsigned and declare it in <m68k/pmap_motorola.h>.

XXX: does anyone still have working HP320 or HP350 with 020+HP_MMU+VAC?
 1.57 10-Nov-2010  uebayasi Use more VM_PHYSMEM_*() accessors. No functional changes.
 1.56 06-Jun-2010  mrg fix PR 6724 - convert m68k options to defflag's. this means that
M680[12346] are now available from opt_m68k_arch.h. FPSP meantioned
in the PR has already been fixed, and i could not find any more.

i built these kernels to ensure i did not break their builds:

amiga: GENERIC DRACO
atari: HADES FALCON MILAN-PCIIDE
mac68k: GENERIC
sun2: GENERIC
sun3: GENERIC GENERIC3X
cesfic: attempted GENERIC, does not build due to lack of machine/bus.h
hp300: GENERIC
luna68k: GENERIC
mvme68k: GENERIC
news68k: GENERIC
next68k: GENERIC
x68k: GENERIC
 1.55 11-Dec-2009  tsutsui branches: 1.55.2; 1.55.4;
Move uvm_setpagesize() calls from locore.s to pmap_bootstrap_finalize().
Also explicitly set uvmexp.pagesize to prepare 8KB/page settings.

XXX: There is #ifdef !defined(amiga) && !defined(atari) workaround
XXX: because they have different pmap initialization functions.
 1.54 06-Dec-2009  tsutsui Move initialization of protection_codes[] and kernel_pmap()
from MD pmap bootstrap sources to common pmap_bootstrap_finalize().

Tested on atari, hp300, mac68k, and news68k.

XXX: Why is protection_codes[] array initialized at run time?
 1.53 06-Dec-2009  tsutsui pm_stfree in struct pmap is a bitmap value so make it unsigned.
 1.52 02-Dec-2009  tsutsui Add a common pmap_bootstrap_finalize() function which initializes
lwp0 uarea, curlwp, and curpcb after MMU is turned on, using
lwp0uarea variable saved during pmap_bootstrap() (or equivalent functions)
for pmap_motorola based ports. Discussed with rmind@.
 1.51 23-Nov-2009  rmind Use lwp_getpcb() on m68k ports, clean from struct user usage.
 1.50 07-Nov-2009  cegger Add a flags argument to pmap_kenter_pa(9).
Patch showed on tech-kern@ http://mail-index.netbsd.org/tech-kern/2009/11/04/msg006434.html
No objections.
 1.49 22-Oct-2009  rmind Simplify pmap_remove() a little by avoiding pmap_do_remove() layer, since
possibility to skip wired mappings is not needed anymore. Apart from that,
no functional differences are intended.
 1.48 21-Oct-2009  rmind Remove uarea swap-out functionality:

- Addresses the issue described in PR/38828.
- Some simplification in threading and sleepq subsystems.
- Eliminates pmap_collect() and, as a side note, allows pmap optimisations.
- Eliminates XS_CTL_DATA_ONSTACK in scsipi code.
- Avoids few scans on LWP list and thus potentially long holds of proc_lock.
- Cuts ~1.5k lines of code. Reduces amd64 kernel size by ~4k.
- Removes __SWAP_BROKEN cases.

Tested on x86, mips, acorn32 (thanks <mpumford>) and partly tested on
acorn26 (thanks to <bjh21>).

Discussed on <tech-kern>, reviewed by <ad>.
 1.47 11-Oct-2009  mhitch Fix DEBUG build - pv_flags does not exist anymore.
 1.46 26-Aug-2009  thorpej Minor tweak to the pv_table management in the Hibler-derived m68k pmaps:
The head of the list is now a pv_header, which contains the first pv_entry
as well as a 16-bit attributes field (replaces the pmap_attributes array
plus the pv_entry::pv_flags field) as a 16-bit count of caller-specified
cache-inhibited mappings.

Tested on hp300 (shared pmap_motorola.c), changes to atari and amiga copies
are purely mechanical.
 1.45 18-Aug-2009  thorpej Add a real API for testing if a page is a managed page, and adjust callers
to stop relying on vm_physseg_find() for this purpose.
 1.44 21-Apr-2009  cegger change pmap flags argument from int to u_int.
discussed with christos@ on source-changes-d@
 1.43 14-Mar-2009  dsl ANSIfy another 1261 function definitions.
The only ones left in sys are beyond by sed script!
(or in sys/dist or sys/external)
Mostly they have function pointer parameters.
 1.42 17-Jan-2009  tsutsui branches: 1.42.2;
Move extern decls for Sysseg, Sysptmap, Sysptsize, mem_size, virtual_avail,
virtual_end, and protection_codes[] to common <m68k/pmap_motorola.h>,
and also make protection_codes[] unsigned.

XXX: avail_start and avail_end should also be moved, but it causes
XXX: -Wshadow warnings in uvm/uvm_page.c:uvm_page_physload() and
XXX: I don't have a good idea of alternative names for now.
 1.41 28-Dec-2008  tsutsui Use the global kernel_pmap_ptr pointer in each MD pmap_bootstrap.c
(where MMU is not enabled yet) and make kernel_pmap_store static again.
Also consistently use uintptr_t on address conversion in RELOC() macro.

Tested on hp300 (PA != VA) and news68k (PA == VA).
 1.40 10-Dec-2008  tsutsui Prepare kernel_pmap_ptr as well as other m68k ports which have own pmap.c.
 1.39 28-Jun-2008  tsutsui branches: 1.39.2; 1.39.4;
- use TAILQ macro
- use NULL rather than 0 for pointers
No binary change.
 1.38 27-Jun-2008  tsutsui Remove ({ }) gcc extensions and use static inline functions instead.
 1.37 28-Apr-2008  martin branches: 1.37.2; 1.37.4;
Remove clause 3 and 4 from TNF licenses
 1.36 27-Apr-2008  tsutsui branches: 1.36.2;
Use mutex(9) for uvm_kernel_object. From Greg Oster.
 1.35 31-Dec-2007  ad branches: 1.35.6; 1.35.8;
Remove COMPAT_HPUX.
 1.34 17-Oct-2007  garbled branches: 1.34.2; 1.34.8;
Merge the ppcoea-renovation branch to HEAD.

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

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

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.33 23-Jul-2007  dogcow branches: 1.33.6;
Same change as -r1.133 of src/sys/arch/amiga/amiga/pmap.c :
As per hint from ad@, change uvm.kernel_object to uvm_kernel_object,
to adapt to the recent uvm changes.
 1.32 16-Jul-2007  macallan branches: 1.32.2; 1.32.4;
change pmap_phys_address()s parameter to paddr_t since that's what it gets
fed from mmap*() anyway
approved by gimpy
 1.31 07-Jun-2007  tsutsui Enable _pmap_set_page_cacheable(), _pmap_set_page_cacheinhibit() and
_pmap_page_is_cacheable() on all pmap_motorola.c ports and add
BUS_DMA_COHERENT support (from mvme68k) to common m68k bus_dma.c.

Tested with (not-yet-integrated) MI Sonic Ethernet driver on mac68k
http://mail-index.netbsd.org/port-mac68k/2007/06/07/0000.html
and ok'ed by thorpej.
 1.30 18-May-2007  mhitch Common m68k changes for idlelwp.
 1.29 05-Apr-2007  tnn branches: 1.29.4;
protectoin -> protection
 1.28 12-Mar-2007  ad branches: 1.28.2;
Pass an ipl argument to pool_init/POOL_INIT to be used when initializing
the pool's lock.
 1.27 04-Mar-2007  tsutsui branches: 1.27.2;
Move declarations of CADDR1 and CADDR2 from m68k/pmap_motorola.c
to <m68k/pmap_motorola.h>.
 1.26 04-Mar-2007  christos Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.25 22-Feb-2007  thorpej TRUE -> true, FALSE -> false
 1.24 22-Feb-2007  tsutsui Fix lossage on bool changes.
 1.23 21-Feb-2007  thorpej Replace the Mach-derived boolean_t type with the C99 bool type. A
future commit will replace use of TRUE and FALSE with true and false.
 1.22 30-Dec-2006  martin branches: 1.22.2;
Allow pmap_enter_ptpage to fail, sometimes. Pass WAIT/NOWAIT flags and
fix some obvious locking problems. This allows us to run a LOCKDEBUG
kernel now.
No objection from mhitch and chs.
 1.21 16-Sep-2006  mhitch branches: 1.21.4; 1.21.6;
Common m68k pmap has same problem with 68060 after 17 month old uvm changes.
Tested and verified on my Amiga (yes, I'm hoping to switch amiga to using
the common pmp_motorola.c).

Uvm changes over 17 months ago resulted in the 68040/060 segment table
page being entered with pmap_kenter(), which does not record the mapping
in the pv table. Attempting to inhibit caching of that page as required
by the 68060 hardware no longer changes the PTE and caused varying degrees
of multiple faulting, sometimes resulting in an unusable system. Apparently
very few people attempted to run a 68060 based system since that change.
Fix to to change the caching bits directly rather than using pmap_changebit().
 1.20 22-Jul-2006  tsutsui branches: 1.20.2; 1.20.4;
remove __P(), ANSIfy, KNF, use pmap_t rather than struct pmap *
 1.19 25-Jun-2006  tsutsui XXX: Appease gcc4 -Wuninitialized warnings.
 1.18 11-Dec-2005  christos branches: 1.18.4; 1.18.8; 1.18.16;
merge ktrace-lwp.
 1.17 03-Jun-2005  scw branches: 1.17.2;
Fix const fallout when DEBUG is defined.
 1.16 02-Jun-2005  tsutsui Fix one more shadow warning in #ifdef DIAGNOSTIC.
 1.15 02-Jun-2005  tsutsui Fix a shadow warning.
 1.14 01-Apr-2005  yamt merge yamt-km branch.
- don't use managed mappings/backing objects for wired memory allocations.
save some resources like pv_entry. also fix (most of) PR/27030.
- simplify kernel memory management API.
- simplify pmap bootstrap of some ports.
- some related cleanups.
 1.13 14-Feb-2005  chs fix an off-by-on in pmap_check_wiring(): we increment the PTP refcount
before calling this, so it's ok to see the max value here.
 1.12 01-Jan-2005  yamt branches: 1.12.2; 1.12.4;
introduce vm_map_kernel, a subclass of vm_map, and
move some kernel-only members of vm_map to it.
 1.11 01-Nov-2003  he Based on the historic hp300 pmap, initialize firstpage to TRUE, and
negate that after processing the first page.
 1.10 01-Nov-2003  he Initialize needcflush to FALSE in pmap_do_remove().
 1.9 28-Oct-2003  mycroft Remove bogus initializer.
 1.8 27-Oct-2003  cl initialize uninitialized
 1.7 27-Sep-2003  cl Cast through (void *) to appease gcc3.
 1.6 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.5 10-May-2003  thorpej branches: 1.5.2;
Back out the following chagne:
http://mail-index.netbsd.org/source-changes/2003/05/08/0068.html

There were some side-effects that I didn't anticipate, and fixing them
is proving to be more difficult than I thought, do just eject for now.
Maybe one day we can look at this again.

Fixes PR kern/21517.
 1.4 08-May-2003  thorpej Simplify the way the bounds of the managed kernel virtual address
space is advertised to UVM by making virtual_avail and virtual_end
first-class exported variables by UVM. Machine-dependent code is
responsible for initializing them before main() is called. Anything
that steals KVA must adjust these variables accordingly.

This reduces the number of instances of this info from 3 to 1, and
simplifies the pmap(9) interface by removing the pmap_virtual_space()
function call, and removing two arguments from pmap_steal_memory().

This also eliminates some kludges such as having to burn kernel_map
entries on space used by the kernel and stolen KVA.

This also eliminates use of VM_{MIN,MAX}_KERNEL_ADDRESS from MI code,
this giving MD code greater flexibility over the bounds of the managed
kernel virtual address space if a given port's specific platforms can
vary in this regard (this is especially true of the evb* ports).
 1.3 02-Apr-2003  thorpej Use PAGE_SIZE rather than NBPG.
 1.2 17-Jan-2003  thorpej Merge the nathanw_sa branch.
 1.1 05-Nov-2002  chs branches: 1.1.2;
merge pmap.c for all 4k-page motorola-MMU (or compatible) m68k platforms.
 1.1.2.3 13-Nov-2002  skrll LWPify. Taken from the work done on the machine specific files.
 1.1.2.2 11-Nov-2002  nathanw Catch up to -current
 1.1.2.1 05-Nov-2002  nathanw file pmap_motorola.c was added on branch nathanw_sa on 2002-11-11 21:59:41 +0000
 1.5.2.7 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.5.2.6 01-Apr-2005  skrll Sync with HEAD.
 1.5.2.5 15-Feb-2005  skrll Sync with HEAD.
 1.5.2.4 17-Jan-2005  skrll Sync with HEAD.
 1.5.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.5.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.5.2.1 03-Aug-2004  skrll Sync with HEAD
 1.12.4.5 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.12.4.4 23-Feb-2005  yamt change mac68k's kernel address space layout in order to simplify
interaction between upper layer of the vm during bootstrap.
- move Sysmap to the end of address space.
- move IOBase etc immediately after proc0 uarea.
- tweak virtual_avail/end accordingly.

tested by Chuck Silvers, on his quadra 950.
XXX this breaks other m68k platforms. i'll fix them later.
 1.12.4.3 18-Feb-2005  chs with the new km API, we must longer explicitly unmap and free the
st_map pages, so don't. also, use the correct km type for freeing the
st_map space on amiga.
 1.12.4.2 27-Jan-2005  yamt follow uvm_km_pgremove prototype change.
 1.12.4.1 26-Jan-2005  yamt convert arch/m68k to new apis.
 1.12.2.1 29-Apr-2005  kent sync with -current
 1.17.2.4 21-Jan-2008  yamt sync with head
 1.17.2.3 03-Sep-2007  yamt sync with head.
 1.17.2.2 26-Feb-2007  yamt sync with head.
 1.17.2.1 30-Dec-2006  yamt sync with head.
 1.18.16.1 13-Jul-2006  gdamore Merge from HEAD.
 1.18.8.2 11-Aug-2006  yamt sync with head
 1.18.8.1 26-Jun-2006  yamt sync with head.
 1.18.4.1 09-Sep-2006  rpaulo sync with head
 1.20.4.2 12-Jan-2007  ad Sync with head.
 1.20.4.1 18-Nov-2006  ad Sync with head.
 1.20.2.1 23-Sep-2006  snj Pull up following revision(s) (requested by mhitch in ticket #177):
sys/arch/m68k/m68k/pmap_motorola.c: revision 1.21
Common m68k pmap has same problem with 68060 after 17 month old uvm changes.
Tested and verified on my Amiga (yes, I'm hoping to switch amiga to using
the common pmp_motorola.c).
Uvm changes over 17 months ago resulted in the 68040/060 segment table
page being entered with pmap_kenter(), which does not record the mapping
in the pv table. Attempting to inhibit caching of that page as required
by the 68060 hardware no longer changes the PTE and caused varying degrees
of multiple faulting, sometimes resulting in an unusable system. Apparently
very few people attempted to run a 68060 based system since that change.
Fix to to change the caching bits directly rather than using pmap_changebit().
 1.21.6.1 04-Sep-2008  skrll Sync with netbsd-4.
 1.21.4.1 08-Jun-2008  bouyer Pull up following revision(s) (requested by hauke in ticket #1158):
sys/arch/m68k/m68k/pmap_motorola.c: revision 1.22
Allow pmap_enter_ptpage to fail, sometimes. Pass WAIT/NOWAIT flags and
fix some obvious locking problems. This allows us to run a LOCKDEBUG
kernel now.
No objection from mhitch and chs.
 1.22.2.4 15-Apr-2007  yamt sync with head.
 1.22.2.3 24-Mar-2007  yamt sync with head.
 1.22.2.2 12-Mar-2007  rmind Sync with HEAD.
 1.22.2.1 27-Feb-2007  yamt - sync with head.
- move sched_changepri back to kern_synch.c as it doesn't know PPQ anymore.
 1.27.2.5 20-Aug-2007  ad Sync with HEAD.
 1.27.2.4 09-Jun-2007  ad Sync with head.
 1.27.2.3 27-May-2007  ad Sync with head.
 1.27.2.2 10-Apr-2007  ad Sync with head.
 1.27.2.1 13-Mar-2007  ad Sync with head.
 1.28.2.1 11-Jul-2007  mjf Sync with head.
 1.29.4.3 03-Oct-2007  garbled Sync with HEAD
 1.29.4.2 26-Jun-2007  garbled Sync with HEAD.
 1.29.4.1 22-May-2007  matt Update to HEAD.
 1.32.4.1 15-Aug-2007  skrll Sync with HEAD.
 1.32.2.1 07-Aug-2007  matt Sync with HEAD.
 1.33.6.2 09-Jan-2008  matt sync with HEAD
 1.33.6.1 06-Nov-2007  matt sync with HEAD
 1.34.8.1 02-Jan-2008  bouyer Sync with HEAD
 1.34.2.1 18-Feb-2008  mjf Sync with HEAD.
 1.35.8.1 18-May-2008  yamt sync with head.
 1.35.6.3 17-Jan-2009  mjf Sync with HEAD.
 1.35.6.2 29-Jun-2008  mjf Sync with HEAD.
 1.35.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.36.2.6 11-Aug-2010  yamt sync with head.
 1.36.2.5 11-Mar-2010  yamt sync with head
 1.36.2.4 16-Sep-2009  yamt sync with head
 1.36.2.3 19-Aug-2009  yamt sync with head.
 1.36.2.2 04-May-2009  yamt sync with head.
 1.36.2.1 16-May-2008  yamt sync with head.
 1.37.4.2 03-Jul-2008  simonb Sync with head.
 1.37.4.1 27-Jun-2008  simonb Sync with head.
 1.37.2.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.39.4.2 28-Apr-2009  skrll Sync with HEAD.
 1.39.4.1 19-Jan-2009  skrll Sync with HEAD.
 1.39.2.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.42.2.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.55.4.4 12-Jun-2011  rmind sync with head
 1.55.4.3 05-Mar-2011  rmind sync with head
 1.55.4.2 03-Jul-2010  rmind sync with head
 1.55.4.1 16-Mar-2010  rmind Change struct uvm_object::vmobjlock to be dynamically allocated with
mutex_obj_alloc(). It allows us to share the locks among UVM objects.
 1.55.2.7 06-Nov-2010  uebayasi Fix build.
 1.55.2.6 04-Nov-2010  uebayasi Split physical device segment pages from "managed" to "managed
device". Cache that information as a flag PG_DEVICE so that callers
don't need to walk physsegs everytime.

Remove PQ_FIXED, which means that page daemon doesn't need to know
device segment pages at all. But still fault handlers need to know
them.

I think this is what I can do best now.
 1.55.2.5 31-Oct-2010  uebayasi We already have a flag PMAP_NOCACHE. s/PMAP_UNMANAGED/PMAN_NOCACHE/.
Pointed out by Chuck Silvers, thanks.
 1.55.2.4 30-Oct-2010  uebayasi Implement pmap_physload_device(9) to replace xmd(4) MD backend.
Implement pmap_mmap(9) and use it from mem(4) and xmd(4).
 1.55.2.3 17-Aug-2010  uebayasi Sync with HEAD.
 1.55.2.2 28-Apr-2010  uebayasi Always use struct vm_physseg *vm_physmem_ptrs[] in MD code.
 1.55.2.1 27-Apr-2010  uebayasi Support PMAP_UNMANAGED in some pmaps.

(Others should be converted eventually, but no problem while managed
device page is not used.)
 1.60.6.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.60.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.63.2.4 22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.63.2.3 30-Oct-2012  yamt sync with head
 1.63.2.2 17-Apr-2012  yamt sync with head
 1.63.2.1 10-Nov-2011  yamt sync with head
 1.64.4.1 18-Feb-2012  mrg merge to -current.
 1.65.8.1 07-Sep-2013  bouyer Pull up following revision(s) (requested by rkujawa in ticket #935):
sys/arch/amiga/amiga/amiga_init.c: revision 1.127
sys/arch/m68k/m68k/pmap_motorola.c: revision 1.66
Set user page table base address dynamically on amiga. This unbreaks =
machines
with large Zorro III I/O spaces. Patch originally by Michael L. Hitch.
Test on an A4000.
=20
=20
 1.65.2.1 07-Sep-2013  bouyer Pull up following revision(s) (requested by rkujawa in ticket #935):
sys/arch/amiga/amiga/amiga_init.c: revision 1.127
sys/arch/m68k/m68k/pmap_motorola.c: revision 1.66
Set user page table base address dynamically on amiga. This unbreaks =
machines
with large Zorro III I/O spaces. Patch originally by Michael L. Hitch.
Test on an A4000.
=20
=20
 1.66.4.1 18-May-2014  rmind sync with head
 1.66.2.2 03-Dec-2017  jdolecek update from HEAD
 1.66.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.67.10.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.67.6.1 05-Feb-2017  skrll Sync with HEAD
 1.69.8.1 27-Feb-2018  martin Pull up following revision(s) (requested by mrg in ticket #593):
sys/dev/marvell/mvxpsec.c: revision 1.2
sys/arch/m68k/m68k/pmap_motorola.c: revision 1.70
sys/opencrypto/crypto.c: revision 1.102
sys/arch/sparc64/sparc64/pmap.c: revision 1.308
sys/ufs/chfs/chfs_malloc.c: revision 1.5
sys/arch/powerpc/oea/pmap.c: revision 1.95
sys/sys/pool.h: revision 1.80,1.82
sys/kern/subr_pool.c: revision 1.209-1.216,1.219-1.220
sys/arch/alpha/alpha/pmap.c: revision 1.262
sys/kern/uipc_mbuf.c: revision 1.173
sys/uvm/uvm_fault.c: revision 1.202
sys/sys/mbuf.h: revision 1.172
sys/kern/subr_extent.c: revision 1.86
sys/arch/x86/x86/pmap.c: revision 1.266 (via patch)
sys/dev/dtv/dtv_scatter.c: revision 1.4

Allow only one pending call to a pool's backing allocator at a time.
Candidate fix for problems with hanging after kva fragmentation related
to PR kern/45718.

Proposed on tech-kern:
https://mail-index.NetBSD.org/tech-kern/2017/10/23/msg022472.html
Tested by bouyer@ on i386.

This makes one small change to the semantics of pool_prime and
pool_setlowat: they may fail with EWOULDBLOCK instead of ENOMEM, if
there is a pending call to the backing allocator in another thread but
we are not actually out of memory. That is unlikely because nearly
always these are used during initialization, when the pool is not in
use.

Define the new flag too for previous commit.

pool_grow can now fail even when sleeping is ok. Catch this case in pool_get
and retry.

Assert that pool_get failure happens only with PR_NOWAIT.
This would have caught the mistake I made last week leading to null
pointer dereferences all over the place, a mistake which I evidently
poorly scheduled alongside maxv's change to the panic message on x86
for null pointer dereferences.

Since pr_lock is now used to wait for two things now (PR_GROWING and
PR_WANTED) we need to loop for the condition we wanted.
make the KASSERTMSG/panic strings consistent as '%s: [%s], __func__, wchan'
Handle the ERESTART case from pool_grow()

don't pass 0 to the pool flags
Guess pool_cache_get(pc, 0) means PR_WAITOK here.
Earlier on in the same context we use kmem_alloc(sz, KM_SLEEP).

use PR_WAITOK everywhere.
use PR_NOWAIT.

Don't use 0 for PR_NOWAIT

use PR_NOWAIT instead of 0

panic ex nihilo -- PR_NOWAITing for zerot

Add assertions that either PR_WAITOK or PR_NOWAIT are set.
- fix an assert; we can reach there if we are nowait or limitfail.
- when priming the pool and failing with ERESTART, don't decrement the number
of pages; this avoids the issue of returning an ERESTART when we get to 0,
and is more correct.
- simplify the pool_grow code, and don't wakeup things if we ENOMEM.

In pmap_enter_ma(), only try to allocate pves if we might need them,
and even if that fails, only fail the operation if we later discover
that we really do need them. This implements the requirement that
pmap_enter(PMAP_CANFAIL) must not fail when replacing an existing
mapping with the first mapping of a new page, which is an unintended
consequence of the changes from the rmind-uvmplock branch in 2011.

The problem arises when pmap_enter(PMAP_CANFAIL) is used to replace an existing
pmap mapping with a mapping of a different page (eg. to resolve a copy-on-write).
If that fails and leaves the old pmap entry in place, then UVM won't hold
the right locks when it eventually retries. This entanglement of the UVM and
pmap locking was done in rmind-uvmplock in order to improve performance,
but it also means that the UVM state and pmap state need to be kept in sync
more than they did before. It would be possible to handle this in the UVM code
instead of in the pmap code, but these pmap changes improve the handling of
low memory situations in general, and handling this in UVM would be clunky,
so this seemed like the better way to go.

This somewhat indirectly fixes PR 52706, as well as the failing assertion
about "uvm_page_locked_p(old_pg)". (but only on x86, various other platforms
will need their own changes to handle this issue.)
In uvm_fault_upper_enter(), if pmap_enter(PMAP_CANFAIL) fails, assert that
the pmap did not leave around a now-stale pmap mapping for an old page.
If such a pmap mapping still existed after we unlocked the vm_map,
the UVM code would not know later that it would need to lock the
lower layer object while calling the pmap to remove or replace that
stale pmap mapping. See PR 52706 for further details.
hopefully workaround the irregularly "fork fails in init" problem.
if a pool is growing, and the grower is PR_NOWAIT, mark this.
if another caller wants to grow the pool and is also PR_NOWAIT,
busy-wait for the original caller, which should either succeed
or hard-fail fairly quickly.

implement the busy-wait by unlocking and relocking this pools
mutex and returning ERESTART. other methods (such as having
the caller do this) were significantly more code and this hack
is fairly localised.
ok chs@ riastradh@

Don't release the lock in the PR_NOWAIT allocation. Move flags setting
after the acquiring the mutex. (from Tobias Nygren)
apply the change from arch/x86/x86/pmap.c rev. 1.266 commitid vZRjvmxG7YTHLOfA:

In pmap_enter_ma(), only try to allocate pves if we might need them,
and even if that fails, only fail the operation if we later discover
that we really do need them. If we are replacing an existing mapping,
reuse the pv structure where possible.

This implements the requirement that pmap_enter(PMAP_CANFAIL) must not fail
when replacing an existing mapping with the first mapping of a new page,
which is an unintended consequence of the changes from the rmind-uvmplock
branch in 2011.

The problem arises when pmap_enter(PMAP_CANFAIL) is used to replace an existing
pmap mapping with a mapping of a different page (eg. to resolve a copy-on-write).
If that fails and leaves the old pmap entry in place, then UVM won't hold
the right locks when it eventually retries. This entanglement of the UVM and
pmap locking was done in rmind-uvmplock in order to improve performance,
but it also means that the UVM state and pmap state need to be kept in sync
more than they did before. It would be possible to handle this in the UVM code
instead of in the pmap code, but these pmap changes improve the handling of
low memory situations in general, and handling this in UVM would be clunky,
so this seemed like the better way to go.

This somewhat indirectly fixes PR 52706 on the remaining platforms where
this problem existed.
 1.70.4.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.70.4.1 10-Jun-2019  christos Sync with HEAD
 1.70.2.1 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.71.6.1 29-Feb-2020  ad Sync with head.
 1.72.6.1 03-Apr-2021  thorpej Sync with HEAD.
 1.73.2.1 17-Apr-2021  thorpej Sync with HEAD.
 1.8 26-May-2007  tsutsui Remove an obsolete file after yamt-idlelwp merge.
 1.7 11-Dec-2005  christos branches: 1.7.30; 1.7.32; 1.7.38;
merge ktrace-lwp.
 1.6 07-Aug-2003  agc branches: 1.6.16;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.5 17-Jan-2003  thorpej branches: 1.5.2;
Merge the nathanw_sa branch.
 1.4 26-May-2000  thorpej branches: 1.4.12; 1.4.26;
First sweep at scheduler state cleanup. Collect MI scheduler
state into global and per-CPU scheduler state:

- Global state: sched_qs (run queues), sched_whichqs (bitmap
of non-empty run queues), sched_slpque (sleep queues).
NOTE: These may collectively move into a struct schedstate
at some point in the future.

- Per-CPU state, struct schedstate_percpu: spc_runtime
(time process on this CPU started running), spc_flags
(replaces struct proc's p_schedflags), and
spc_curpriority (usrpri of processes on this CPU).

- Every platform must now supply a struct cpu_info and
a curcpu() macro. Simplify existing cpu_info declarations
where appropriate.

- All references to per-CPU scheduler state now made through
curcpu(). NOTE: this will likely be adjusted in the future
after further changes to struct proc are made.

Tested on i386 and Alpha. Changes are mostly mechanical, but apologies
in advance if it doesn't compile on a particular platform.
 1.3 10-Nov-1999  thorpej Add register prefixes.
 1.2 25-Apr-1997  thorpej branches: 1.2.22; 1.2.24; 1.2.28;
- Don't make assumptions about how C labels are handled.
- Use PANIC() where appropriate.
 1.1 09-Apr-1997  thorpej Factor out a few process manipulation routines found in all m68k
locore.s's. Currently includes run queue manipulation.
 1.2.28.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.2.24.1 15-Nov-1999  fvdl Sync with -current
 1.2.22.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.4.26.1 18-Dec-2002  gmcgarry Remove the scheduler semantics from machine-dependent context switch.
 1.4.12.2 05-Oct-2002  gmcgarry Don't try to invoke cpu_Debugger(), since it mightn't be available.
Just panic.
 1.4.12.1 17-Nov-2001  scw Kernel support for Scheduler Activations on m68k-based ports using
mvme68k as a testbed.

Boots multi-user on an mvme162, although userland support for SA is not
yet integrated/tested.
 1.5.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.5.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.5.2.1 03-Aug-2004  skrll Sync with HEAD
 1.6.16.1 03-Sep-2007  yamt sync with head.
 1.7.38.1 26-Jun-2007  garbled Sync with HEAD.
 1.7.32.1 11-Jul-2007  mjf Sync with head.
 1.7.30.2 09-Jun-2007  ad Sync with head.
 1.7.30.1 27-May-2007  ad Sync with head.
 1.31 10-Aug-2020  rin Forbid to set odd address to PC in process_write_regs() and process_set_pc().

Otherwise, address error occurs in kernel at rte instruction when returning
to the user level.

Found by tests/lib/libc/t_ptrace_*:access_regs_set_unaligned_pc_0x[137].
 1.30 04-Jan-2014  dsl Remove __HAVE_PROCESS_XFPREGS and add the extra parameter for the size
of the fp save area to all the process_read_fpregs() and
process_write_fpregs() functions.
None of the functions have been modified to use the new parameters.
The size is set for all the writes, but some of the arch-specific reads
just pass NULL.
The amd64 (and i386) need variable sized fp register save areas in order
to support AVX and other enhanced register areas.
These functions are rarely called - so the extra argument won't matter.
 1.29 14-Jan-2011  rmind branches: 1.29.8; 1.29.18; 1.29.22;
Retire struct user, remove sys/user.h inclusions. Note sys/user.h header
as obsolete. Remove USER_TO_UAREA/UAREA_TO_USER macros.

Various #include fixes and review by matt@.
 1.28 23-Nov-2009  rmind branches: 1.28.4;
Use lwp_getpcb() on m68k ports, clean from struct user usage.
 1.27 04-Mar-2007  christos branches: 1.27.44;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.26 22-Jul-2006  tsutsui branches: 1.26.10;
KNF and misc cosmetics
 1.25 24-Dec-2005  perry branches: 1.25.4; 1.25.8;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.
 1.24 11-Dec-2005  christos merge ktrace-lwp.
 1.23 01-Jun-2005  scw branches: 1.23.2;
Declare the second arg of process_write_{fp,}regs() to be const.
This permits sh5 to continue to re-use those functions in cpu_setmcontext()
with the recent change to Makefile.kern.inc (revision 1.62).
 1.22 28-Aug-2004  thorpej Use ANSI function decls and static.
 1.21 15-Jul-2003  lukem __KERNEL_RCSID()
 1.20 17-Jan-2003  thorpej branches: 1.20.2;
Merge the nathanw_sa branch.
 1.19 28-Jul-2001  tsutsui branches: 1.19.6;
bcopy -> memcpy
 1.18 06-Jan-1998  thorpej branches: 1.18.28;
Garbage-collect cpu_set_init_frame(); it hasn't been needed for some time
now.
 1.17 06-May-1996  gwr Fix "prototype disagrees about inline" error.
 1.16 29-Apr-1996  leo Prototype + -Wall fixes.
 1.15 13-Aug-1995  mycroft Lock the process in core before operating on it.
 1.14 12-May-1995  mycroft Conditionalize the code in process_frame() on the existance of
cpu_set_init_frame().
 1.13 11-May-1995  chopps fix typo
 1.12 11-May-1995  chopps conditional use of kstack, specifically there is no kstack on the amiga
 1.11 26-Jan-1995  mycroft Fix syntax errors.
 1.10 26-Jan-1995  mycroft Add process_{read,write}_fpregs().
 1.9 26-Oct-1994  cgd new RCS ID format.
 1.8 15-Aug-1994  cgd changes for the new sys_process.c, and some cleanup
 1.7 19-May-1994  mycroft branches: 1.7.2;
Speed up process_sstep() and process_set_pc().
 1.6 05-May-1994  cgd lots of changes: prototype migration, move lots of variables, definitions,
and structure elements around. kill some unnecessary type and macro
definitions. standardize clock handling. More changes than you'd want.
 1.5 04-May-1994  cgd Rename a lot of process flags.
 1.4 28-Jan-1994  jtc Fix spelling error in Copyright notice
 1.3 22-Jan-1994  briggs Add parameter of function process_sstep to function header as well as body.
(blush)
 1.2 21-Jan-1994  briggs New parameter to process_sstep().
 1.1 08-Jan-1994  cgd common code
 1.7.2.1 15-Aug-1994  mycroft update from trunk
 1.18.28.1 03-Aug-2001  lukem update to -current
 1.19.6.3 12-Jul-2002  nathanw No longer need to pull in lwp.h; proc.h pulls it in for us.
 1.19.6.2 17-Nov-2001  scw Kernel support for Scheduler Activations on m68k-based ports using
mvme68k as a testbed.

Boots multi-user on an mvme162, although userland support for SA is not
yet integrated/tested.
 1.19.6.1 28-Jul-2001  scw file process_machdep.c was added on branch nathanw_sa on 2001-11-17 13:07:53 +0000
 1.20.2.5 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.20.2.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.20.2.3 18-Sep-2004  skrll Sync with HEAD.
 1.20.2.2 03-Sep-2004  skrll Sync with HEAD
 1.20.2.1 03-Aug-2004  skrll Sync with HEAD
 1.23.2.3 03-Sep-2007  yamt sync with head.
 1.23.2.2 30-Dec-2006  yamt sync with head.
 1.23.2.1 21-Jun-2006  yamt sync with head.
 1.25.8.1 11-Aug-2006  yamt sync with head
 1.25.4.1 09-Sep-2006  rpaulo sync with head
 1.26.10.1 12-Mar-2007  rmind Sync with HEAD.
 1.27.44.1 11-Mar-2010  yamt sync with head
 1.28.4.1 05-Mar-2011  rmind sync with head
 1.29.22.1 18-May-2014  rmind sync with head
 1.29.18.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.29.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.7 05-Apr-2014  christos adjust to new signature; return consistent stuff. 0 is ok -1 is error
 1.6 29-Mar-2014  apb procfs_getcpuinfstr's len argument contains the buffer size on entry,
and the number of bytes used on return. Use the actual buffer size in a
snprintf call, instead of sizeof(*buf), which is always 1.
 1.5 22-Jul-2006  tsutsui branches: 1.5.96; 1.5.106; 1.5.112;
TAB/space cleanup.
 1.4 22-Jul-2006  tsutsui KNF and misc cosmetics
 1.3 11-Dec-2005  christos branches: 1.3.4; 1.3.8;
merge ktrace-lwp.
 1.2 01-Jan-2005  chs branches: 1.2.10;
add cases for '040 and '060 FPUs. from Radek Kujawa.
 1.1 16-Nov-2004  christos branches: 1.1.2;
moved from x86k/x68k
 1.1.2.3 17-Jan-2005  skrll Sync with HEAD.
 1.1.2.2 29-Nov-2004  skrll Sync with HEAD.
 1.1.2.1 16-Nov-2004  skrll file procfs_machdep.c was added on branch ktrace-lwp on 2004-11-29 07:24:04 +0000
 1.2.10.1 30-Dec-2006  yamt sync with head.
 1.3.8.1 11-Aug-2006  yamt sync with head
 1.3.4.1 09-Sep-2006  rpaulo sync with head
 1.5.112.1 18-May-2014  rmind sync with head
 1.5.106.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.5.96.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.7 22-Feb-1998  mycroft Move to libkern.
 1.6 25-Apr-1997  thorpej - Don't make assumptions about how C labels are handled.
- Use PANIC() where appropriate.
 1.5 15-Jan-1995  mycroft Faster version from Michael Schr"oder.
 1.4 26-Oct-1994  cgd new RCS ID format.
 1.3 13-Feb-1994  mycroft Do the right thing on overflow.
 1.2 03-Feb-1994  mycroft Minor tweak, though the assembler probably does this anyway.
 1.1 03-Feb-1994  mycroft Needed for multicast code. Retains UCB copyright, since it is derived from
the i386 code.
 1.7 23-Feb-2021  tsutsui Plug kernel stack leaks in reenter_syscall() for setcontext(2).

This fixes long standing kernel crashes (MMU fault, address error,
and silent freeze by a double bus fault etc. seen for ~10 years)
caused by kernel stack overflow, especially on x68k and sun3 running
Xorg based servers. See PR/55990 for more details.

"This change seems perfectly reasonable" from thorpej@ and
jklos@ also reported this also solved freeze of his mac68k system
with 10 megabyes of memory.

Should be pulled up to netbsd-9 and netbsd-8.
 1.6 21-Feb-2021  tsutsui Consistently use motorola style. No binary changes.

Seems missed in rev 1.3:
https://mail-index.netbsd.org/source-changes/2013/08/01/msg046378.html
 1.5 20-Feb-2021  tsutsui Replace magic numbers with proper macros prepared in assym.h.

No binary changes.
Note this is a preparation for a possible fix of PR port-m68k/55990.
 1.4 07-Sep-2013  chs branches: 1.4.22; 1.4.34; 1.4.42;
switch to ELF naming for local labels.
 1.3 01-Aug-2013  matt Convert to motorola style.
 1.2 10-Nov-1999  thorpej branches: 1.2.168; 1.2.178; 1.2.184;
Add register prefixes.
 1.1 19-Apr-1999  kleink branches: 1.1.2; 1.1.4; 1.1.6; 1.1.10;
Move linux_reenter_syscall() to a common location and rename it to
reenter_syscall() - it's going to be shared with COMPAT_SVR4 and soon be
used by native code.
 1.1.10.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.1.6.1 15-Nov-1999  fvdl Sync with -current
 1.1.4.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.1.2.1 21-Jun-1999  thorpej Sync w/ -current.
 1.2.184.2 18-May-2014  rmind sync with head
 1.2.184.1 28-Aug-2013  rmind sync with head
 1.2.178.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.2.168.1 22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.4.42.1 03-Apr-2021  thorpej Sync with HEAD.
 1.4.34.1 25-Feb-2021  martin Pull up following revision(s) (requested by tsutsui in ticket #1214):

sys/arch/m68k/m68k/reenter_syscall.s: revision 1.5
sys/arch/m68k/m68k/reenter_syscall.s: revision 1.6
sys/arch/m68k/m68k/reenter_syscall.s: revision 1.7

Replace magic numbers with proper macros prepared in assym.h.

No binary changes.

Note this is a preparation for a possible fix of PR port-m68k/55990.

Consistently use motorola style. No binary changes.
Seems missed in rev 1.3:
https://mail-index.netbsd.org/source-changes/2013/08/01/msg046378.html

Plug kernel stack leaks in reenter_syscall() for setcontext(2).
This fixes long standing kernel crashes (MMU fault, address error,
and silent freeze by a double bus fault etc. seen for ~10 years)
caused by kernel stack overflow, especially on x68k and sun3 running
Xorg based servers. See PR/55990 for more details.

"This change seems perfectly reasonable" from thorpej@ and
jklos@ also reported this also solved freeze of his mac68k system
with 10 megabyes of memory.

Should be pulled up to netbsd-9 and netbsd-8.
 1.4.22.1 25-Feb-2021  martin Pull up following revision(s) (requested by tsutsui in ticket #1659):

sys/arch/m68k/m68k/reenter_syscall.s: revision 1.5
sys/arch/m68k/m68k/reenter_syscall.s: revision 1.6
sys/arch/m68k/m68k/reenter_syscall.s: revision 1.7

Replace magic numbers with proper macros prepared in assym.h.

No binary changes.

Note this is a preparation for a possible fix of PR port-m68k/55990.

Consistently use motorola style. No binary changes.
Seems missed in rev 1.3:
https://mail-index.netbsd.org/source-changes/2013/08/01/msg046378.html

Plug kernel stack leaks in reenter_syscall() for setcontext(2).
This fixes long standing kernel crashes (MMU fault, address error,
and silent freeze by a double bus fault etc. seen for ~10 years)
caused by kernel stack overflow, especially on x68k and sun3 running
Xorg based servers. See PR/55990 for more details.

"This change seems perfectly reasonable" from thorpej@ and
jklos@ also reported this also solved freeze of his mac68k system
with 10 megabyes of memory.

Should be pulled up to netbsd-9 and netbsd-8.
 1.16 13-Jan-2024  thorpej Make getsfc() and getdfc() inlines; it's slightly smaller.
 1.15 03-Aug-2023  mrg ignore "-Warray-bounds" for various low level platform code that knows
how something is setup but technically is undefined behaviour. the
most common here is "extern int end;" and then using offsets of "&end"
that are outside the bounds of this 4-byte integer.

these uses are almost certainly all OK in reality.

found by GCC 12.
 1.14 06-Apr-2019  thorpej Overhaul the API used to fetch and store individual memory cells in
userspace. The old fetch(9) and store(9) APIs (fubyte(), fuword(),
subyte(), suword(), etc.) are retired and replaced with new ufetch(9)
and ustore(9) APIs that can return proper error codes, etc. and are
implemented consistently across all platforms. The interrupt-safe
variants are no longer supported (and several of the existing attempts
at fuswintr(), etc. were buggy and not actually interrupt-safe).

Also augmement the ucas(9) API, making it consistently available on
all plaforms, supporting uniprocessor and multiprocessor systems, even
those that do not have CAS or LL/SC primitives.

Welcome to NetBSD 8.99.37.
 1.13 08-Feb-2011  rmind branches: 1.13.56;
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.12 22-Jul-2006  tsutsui branches: 1.12.84; 1.12.90; 1.12.92;
KNF, ANSIfy, remove register decls
 1.11 11-Dec-2005  christos branches: 1.11.4; 1.11.8;
merge ktrace-lwp.
 1.10 02-Jun-2005  tsutsui branches: 1.10.2;
Fix hexstr() for -Wwritable-strings.
 1.9 17-May-2005  christos Yes, it was a cool trick >20 years ago to use "0123456789abcdef"[a] to
implement, xtoa(), but I think defining the samestring 50 times is a bit
too much. Defined HEXDIGITS and hexdigits in subr_prf.c and use it...
 1.8 28-Aug-2004  thorpej Use ANSI function decls and static.
 1.7 27-Sep-2003  mhitch Cast through (void *) to appease gcc3.
 1.6 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.5 15-Jul-2003  lukem __KERNEL_RCSID()
 1.4 02-Apr-2003  thorpej branches: 1.4.2;
Use PAGE_SIZE rather than NBPG.
 1.3 17-Jan-2003  thorpej Merge the nathanw_sa branch.
 1.2 21-Oct-1997  gwr branches: 1.2.32;
Fix warnings on the sun3 caused by the fact that sun3/include/cpu.h
does not (and should not) declare stuff like getsfc(). Instead,
include <m68k/m68k.h> for those declarations.
 1.1 09-Apr-1997  thorpej branches: 1.1.8;
Factor out the regdump() function used by all m68k ports.
 1.1.8.1 22-Oct-1997  mellon pull up from main trunk
 1.2.32.3 12-Jul-2002  nathanw No longer need to pull in lwp.h; proc.h pulls it in for us.
 1.2.32.2 24-Jun-2002  nathanw Curproc->curlwp renaming.

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

"curproc" is now #defined in proc.h as ((curlwp) ? (curlwp)->l_proc) : NULL)
so that it is always safe to reference curproc (*de*referencing curproc
is another story, but that's always been true).
 1.2.32.1 17-Nov-2001  scw Kernel support for Scheduler Activations on m68k-based ports using
mvme68k as a testbed.

Boots multi-user on an mvme162, although userland support for SA is not
yet integrated/tested.
 1.4.2.5 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.4.2.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.4.2.3 18-Sep-2004  skrll Sync with HEAD.
 1.4.2.2 03-Sep-2004  skrll Sync with HEAD
 1.4.2.1 03-Aug-2004  skrll Sync with HEAD
 1.10.2.1 30-Dec-2006  yamt sync with head.
 1.11.8.1 11-Aug-2006  yamt sync with head
 1.11.4.1 09-Sep-2006  rpaulo sync with head
 1.12.92.1 17-Feb-2011  bouyer Sync with HEAD
 1.12.90.1 06-Jun-2011  jruoho Sync with HEAD.
 1.12.84.1 05-Mar-2011  rmind sync with head
 1.13.56.1 10-Jun-2019  christos Sync with HEAD
 1.51 24-Apr-2021  tsutsui Restore comments for f_stackadj and reenter_syscall().

Taken from sys/compat/linux/arch/m68k/linux_machdep.c which was
originally implemented to use reenter_syscall() for sigreturn of
Linux binaries.
 1.50 27-Nov-2018  maxv Fix widespread leak in the sendsig_siginfo() functions. sigframe_siginfo
has padding, so zero it out properly. While here I'm also zeroing out some
other things in several ports, for safety. Same problem in netbsd32, so
fix that too.

I can't compile-test on each architecture, but there should be no
breakage (tm).

Overall this fixes at least 14 info leaks. Prompted by the discovery by
KLEAK of a leak in amd64's sendsig_siginfo.
 1.49 21-May-2012  martin branches: 1.49.14; 1.49.18; 1.49.26; 1.49.32; 1.49.38; 1.49.40;
Calling _lwp_create() with a bogus ucontext could trigger a kernel
assertion failure (and thus a crash in DIAGNOSTIC kernels). Independently
discovered by YAMAMOTO Takashi and Joel Sing.

To avoid this, introduce a cpu_mcontext_validate() function and move all
sanity checks from cpu_setmcontext() there. Also untangle the netbsd32
compat mess slightly and add a cpu_mcontext32_validate() cousin there.

Add an exhaustive atf test case, based partly on code from Joel Sing.

Should finally fix the remaining open part of PR kern/43903.
 1.48 19-Feb-2012  rmind Remove COMPAT_SA / KERN_SA. Welcome to 6.99.3!
Approved by core@.
 1.47 22-Dec-2011  tsutsui branches: 1.47.2;
Remove fuction declarations of m68881_restore() and m68881_save().
They are in <m68k/m68k.h>.
 1.46 24-Feb-2011  joerg branches: 1.46.4; 1.46.8;
Allow storing and receiving the LWP private pointer via ucontext_t
on all platforms except VAX and IA64. Add fast access via register for
AMD64, i386 and SH3 ports. Use this fast access in libpthread to replace
the stack based pthread_self(). Implement skeleton support for Alpha,
HPPA, PowerPC, SPARC and SPARC64, but leave it disabled.

Ports that support this feature provide __HAVE____LWP_GETPRIVATE_FAST in
machine/types.h and a corresponding __lwp_getprivate_fast in
machine/mcontext.h.

This material is based upon work partially supported by
The NetBSD Foundation under a contract with Joerg Sonnenberger.
 1.45 08-Feb-2011  rmind Remove clause 3 (UCB advertising clause) from the University of Utah
copyright. Confirmed by Mike Hibler, mike at cs.utah.edu - thanks!
Also, merge UCB and Utah copyright texts back into one, as they
originally were.

Extra verification by snj@.
 1.44 14-Jan-2011  rmind branches: 1.44.2; 1.44.4;
Retire struct user, remove sys/user.h inclusions. Note sys/user.h header
as obsolete. Remove USER_TO_UAREA/UAREA_TO_USER macros.

Various #include fixes and review by matt@.
 1.43 06-Jun-2010  mrg fix PR 6724 - convert m68k options to defflag's. this means that
M680[12346] are now available from opt_m68k_arch.h. FPSP meantioned
in the PR has already been fixed, and i could not find any more.

i built these kernels to ensure i did not break their builds:

amiga: GENERIC DRACO
atari: HADES FALCON MILAN-PCIIDE
mac68k: GENERIC
sun2: GENERIC
sun3: GENERIC GENERIC3X
cesfic: attempted GENERIC, does not build due to lack of machine/bus.h
hp300: GENERIC
luna68k: GENERIC
mvme68k: GENERIC
news68k: GENERIC
next68k: GENERIC
x68k: GENERIC
 1.42 23-Nov-2009  rmind branches: 1.42.2; 1.42.4;
Use lwp_getpcb() on m68k ports, clean from struct user usage.
 1.41 27-Jan-2009  martin Centralize fpu exception to siginfo code encoding for all m68k archs,
fixes a failure in the lib/libc/ieeefp/except regression test.
 1.40 19-Nov-2008  ad Make the emulations, exec formats, coredump, NFS, and the NFS server
into modules. By and large this commit:

- shuffles header files and ifdefs
- splits code out where necessary to be modular
- adds module glue for each of the components
- adds/replaces hooks for things that can be installed at runtime
 1.39 18-Oct-2008  martin branches: 1.39.2; 1.39.4;
Include saframe.h, fixes PR port-m68k/39761
 1.38 15-Oct-2008  wrstuden Merge wrstuden-revivesa into HEAD.
 1.37 24-Apr-2008  ad branches: 1.37.2; 1.37.4; 1.37.8;
Merge proc::p_mutex and proc::p_smutex into a single adaptive mutex, since
we no longer need to guard against access from hardware interrupt handlers.

Additionally, if cloning a process with CLONE_SIGHAND, arrange to have the
child process share the parent's lock so that signal state may be kept in
sync. Partially addresses PR kern/37437.
 1.36 17-Oct-2007  garbled branches: 1.36.16; 1.36.18;
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.35 08-Jul-2007  pooka branches: 1.35.10;
Initialize the link context in a signal frame to the receiving lwp's
link context instead of NULL. Otherwise, if we got a signal while the
lwp had a link context set, the link context would be set to NULL upon
return from signal delivery.

christos@tech-kern: "I think you are right."
 1.34 04-Mar-2007  christos branches: 1.34.2; 1.34.4; 1.34.10;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.33 09-Feb-2007  ad branches: 1.33.2;
Merge newlock2 to head.
 1.32 23-Oct-2006  he Const-ness is now (by the new gcc) propagated from structs to
members, so constify so as to not lose qualification.
 1.31 22-Jul-2006  tsutsui branches: 1.31.4; 1.31.6;
TAB/space cleanup.
 1.30 22-Jul-2006  tsutsui - include <m68k/m68k.h> for fputype decl
- some KNF
 1.29 11-Dec-2005  christos branches: 1.29.4; 1.29.8;
merge ktrace-lwp.
 1.28 28-Aug-2004  thorpej branches: 1.28.12;
Use ANSI function decls and static.
 1.27 13-Feb-2004  wiz Uppercase CPU, plural is CPUs.
 1.26 28-Oct-2003  mycroft Remove bogus initializer.
 1.25 27-Oct-2003  cl initialize uninitialized
 1.24 08-Oct-2003  thorpej * Shuffle some data structures so, and add a flags word to ksiginfo_t.
Right now the only flag is used to indicate if a ksiginfo_t is a
result of a trap. Add a predicate macro to test for this flag.
* Add initialization macros for ksiginfo_t's.
* Add accssor macro for ksi_trap. Expands to 0 if the ksiginfo_t was
not the result of a trap. This matches the sigcontext trapcode semantics.
* In kpsendsig(), use KSI_TRAP_P() to select the lwp that gets the signal.
Inspired by Matthias Drochner's fix to kpsendsig(), but correctly handles
the case of non-trap-generated signals that have a > 0 si_code.

This patch fixes a signal delivery problem with threaded programs noted by
Matthias Drochner on tech-kern.

As discussed on tech-kern. Reviewed and OK's by Christos.
 1.23 25-Sep-2003  christos constify siginfo/trapsignal
 1.22 22-Sep-2003  cl SA_SIGINFO support for m68k
 1.21 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.20 15-Jul-2003  lukem __KERNEL_RCSID()
 1.19 11-Apr-2003  nathanw branches: 1.19.2;
Make cpu_getmcontext() run the PC through ras_lookup() so that kernel
getcontext() plus userlevel setcontext() (as used in libpthread) respects
the atomicity of RAS regions.
 1.18 17-Jan-2003  thorpej Merge the nathanw_sa branch.
 1.17 04-Jul-2002  thorpej Add kernel support for having userland provide the signal trampoline:

* struct sigacts gets a new sigact_sigdesc structure, which has the
sigaction and the trampoline/version. Version 0 means "legacy kernel
provided trampoline". Other versions are coordinated with machine-
dependent code in libc.
* sigaction1() grows two more arguments -- the trampoline pointer and
the trampoline version.
* A new __sigaction_sigtramp() system call is provided to register a
trampoline along with a signal handler.
* The handler is no longer passed to sensig() functions. Instead,
sendsig() looks up the handler by peeking in the sigacts for the
process getting the signal (since it has to look in there for the
trampoline anyway).
* Native sendsig() functions now select the appropriate trampoline and
its arguments based on the trampoline version in the sigacts.

Changes to libc to use the new facility will be checked in later. Kernel
version not bumped; we will ride the 1.6C bump made recently.
 1.16 04-Jul-2002  thorpej During signal delivery, arrange to have the signal handler invoked
directly, using the trampoline only for the return path. Saves a
"jsr" in the trampoline.

Reviewed, tested and OK'd by Steve Woodford.
 1.15 28-Jul-2001  tsutsui branches: 1.15.6; 1.15.14;
bcopy -> memcpy
 1.14 22-Dec-2000  jdolecek branches: 1.14.4;
split off thread specific stuff from struct sigacts to struct sigctx, leaving
only signal handler array sharable between threads
move other random signal stuff from struct proc to struct sigctx

This addresses kern/10981 by Matthew Orgass.
 1.13 16-Aug-1999  simonb branches: 1.13.2;
Spell "privilege" correctly (correct spelling from Jonathan Stone).
 1.12 04-Oct-1998  thorpej Fix a typo in a comment.
 1.11 03-Oct-1998  scw Make this compile again when DEBUG is defined.
 1.10 30-Sep-1998  thorpej Adapt to signal changes.
 1.9 30-Sep-1998  thorpej Put the sigstate and sigframe definitions in signal.h, protected by
__M68K_SIGNAL_PRIVATE.
 1.8 08-May-1998  kleink Fix some arithmetics lossage on typeless pointers.
 1.7 15-Feb-1998  thorpej Add support for UVM.
 1.6 07-Jan-1998  is - avoid system stack underflow when calling sigreturn via trap #0
- make sure all sigreturn error conditions are reported to the caller,
instead of the place jumped to.
This is the bugfix part of pr 4628 by ITOH Yasufumi.
The performance optimization part will be handled seperately, after evaluating
its implications.
Testing on 68040 and removing the performance change from the proposed patch
by scottr. Half of the Amiga machdep.c change had to be done manually by me,
as the patchfile didn't apply cleanly.
XXX Yes, Amiga should be changed to use the common sig_machdep.c instead.
XXX Really soon now. I promise.
 1.5 06-Jan-1998  is Support 68060 (and, for the Amiga, even 68040 buserr frames) in the sendsig()
and, indirectly, sigreturn() functions.
XXX The Amiga should be switched to using sig_machdep.c instead.
 1.4 16-Oct-1997  carrel branches: 1.4.2;
Need to include vm/vm.h
 1.3 30-Apr-1997  gwr branches: 1.3.6;
Fix printf format vs. arg type warnings (in DEBUG sections).
 1.2 17-Mar-1997  gwr s/fpu_type/fputype/g
 1.1 13-Mar-1997  gwr Factor out sendsig() and sys_sigreturn() from $arch/machdep.c
 1.3.6.1 08-Sep-1997  thorpej Significantly restructure the way signal state for a process is stored.
Rather than using bitmasks to redundantly store the information kept
in the process's sigacts (because the sigacts was kept in the u-area),
hang sigacts directly off the process, and access it directly.

Simplify signal setup code tremendously by storing information in
the sigacts as an array of struct sigactions, rather than in a different
format, since userspace uses sigactions.

Make sigacts sharable by adding reference counting.
 1.4.2.1 07-Feb-1998  mellon Pull up 1.5 and 1.6 (is)
 1.13.2.1 05-Jan-2001  bouyer Sync with HEAD
 1.14.4.2 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.14.4.1 03-Aug-2001  lukem update to -current
 1.15.14.1 16-Jul-2002  gehenna catch up with -current.
 1.15.6.20 10-Jan-2003  thorpej Expose the remainder of the frame/fpframe in the mcontext to userland
(and namespace-cleanse the member names in doing so).
 1.15.6.19 05-Oct-2002  gmcgarry Make this compile for M68060.
 1.15.6.18 02-Aug-2002  nathanw Invokde upcalls directly.
 1.15.6.17 02-Aug-2002  gmcgarry LWPify.
 1.15.6.16 01-Aug-2002  nathanw Catch up to -current.
 1.15.6.15 12-Jul-2002  nathanw No longer need to pull in lwp.h; proc.h pulls it in for us.
 1.15.6.14 24-Jun-2002  nathanw Curproc->curlwp renaming.

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

"curproc" is now #defined in proc.h as ((curlwp) ? (curlwp)->l_proc) : NULL)
so that it is always safe to reference curproc (*de*referencing curproc
is another story, but that's always been true).
 1.15.6.13 21-Jun-2002  gmcgarry Include <sys/sa.h> before <sys/savar.h>
 1.15.6.12 29-May-2002  nathanw #include <sys/sa.h> before <sys/syscallargs.h>, to provide sa_upcall_t
now that <sys/param.h> doesn't include <sys/sa.h>.

(Behold the Power of Ed)
 1.15.6.11 28-Dec-2001  nathanw Garbage collect cpu_stashcontext().
 1.15.6.10 17-Dec-2001  nathanw Convert to new, smaller cpu_upcall().
 1.15.6.9 02-Dec-2001  scw Declare m68k_cached_fpu_idle_frame in sig_machdep.c instead of switch_subr.s.
Saves having to update all the genassym.cf's for the sizeof the structure.
 1.15.6.8 02-Dec-2001  scw Implement floating-point context save/restore in cpu_{get,set}mcontext()
such that we can deal with restoring the slightly limited contexts saved
by userland _getmcontext_u().

XXX: Turns out that these functions can be called for an lwp which
is != curproc, in which case FP-state needs to be retrieved from/stored in
the lwp's PCB.
 1.15.6.7 25-Nov-2001  scw When restoring thread context, check the _UC_USER bit and DTRT when
checking frame format and fpu saved state.

The whole `full fpu state cannot be saved/restored from userland' needs
more thought.

XXX: _UC_USER really ought to be defined in <sys/ucontext.h> ...
 1.15.6.6 21-Nov-2001  scw Add an MD flag for uc_flags which indicates if the exception frame
area of m68k's mcontext_t structure has valid contents.

In cpu_getcontext(), set the flag for all frame formats >= FMT4 such
that cpu_setcontext() does The Right Thing with both user and kernel
saved contexts.

Make null FP frame detection work for the 68060's FPU, and ensure we
always do at least an fsave/frestore when saving/restoring FPU regs.

Both kernel and user-level get/set context calls pass all Nathan's
context tests now.
 1.15.6.5 17-Nov-2001  thorpej Use sadata_upcall_free(), and copy the arg out to the user stack,
rather than providing a kernel pointer.
 1.15.6.4 17-Nov-2001  scw Re-sync with current MI SA code.
 1.15.6.3 17-Nov-2001  scw Kernel support for Scheduler Activations on m68k-based ports using
mvme68k as a testbed.

Boots multi-user on an mvme162, although userland support for SA is not
yet integrated/tested.
 1.15.6.2 10-Nov-2001  scw Kernel mcontext glue for Scheduler Activations on m68k from
Klaus Klein <kleink@netbsd.org>.
 1.15.6.1 28-Jul-2001  scw file sig_machdep.c was added on branch nathanw_sa on 2001-11-10 21:22:51 +0000
 1.19.2.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.19.2.3 18-Sep-2004  skrll Sync with HEAD.
 1.19.2.2 03-Sep-2004  skrll Sync with HEAD
 1.19.2.1 03-Aug-2004  skrll Sync with HEAD
 1.28.12.3 03-Sep-2007  yamt sync with head.
 1.28.12.2 26-Feb-2007  yamt sync with head.
 1.28.12.1 30-Dec-2006  yamt sync with head.
 1.29.8.1 11-Aug-2006  yamt sync with head
 1.29.4.1 09-Sep-2006  rpaulo sync with head
 1.31.6.1 10-Dec-2006  yamt sync with head.
 1.31.4.3 06-Feb-2007  ad Make amiga & mac68k compile.
 1.31.4.2 30-Jan-2007  ad Remove support for SA. Ok core@.
 1.31.4.1 18-Nov-2006  ad Sync with head.
 1.33.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.34.10.1 03-Oct-2007  garbled Sync with HEAD
 1.34.4.1 11-Jul-2007  mjf Sync with head.
 1.34.2.1 15-Jul-2007  ad Sync with head.
 1.35.10.1 06-Nov-2007  matt sync with HEAD
 1.36.18.1 18-May-2008  yamt sync with head.
 1.36.16.2 17-Jan-2009  mjf Sync with HEAD.
 1.36.16.1 02-Jun-2008  mjf Sync with HEAD.
 1.37.8.2 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.37.8.1 19-Oct-2008  haad Sync with HEAD.
 1.37.4.3 22-Jun-2008  wrstuden Re-add cpu_upcall() and page fault code. i386 kernels now compile.
They don't boot, but that seems to be a consequence of current from the
day this branch was started.
 1.37.4.2 14-May-2008  wrstuden Per discussion with ad at n dot o, revert signal mask handling
changes.

The l_sigstk changes are most likely totally un-needed as SA will
never use a signal stack - we send an upcall (or will as other
diffs are brought in).

The l_sigmask changes were too controvertial. In all honesty, I
think it's probably best to revert them. The main reason they were
there is the fact that in an SA process, we don't mask signals per
kernel thread, we mask them per user thread. In the kernel, we want
them all to get turned into upcalls. Thus the normal state of
l_sigmask in an SA process is for it to always be empty.

While we are in the process of delivering a signal, we want to
temporarily mask a signal (so we don't recursively exhaust our
upcall stacks). However signal delivery is rare (important, but
rare), and delivering back-to-back signals is even rarer. So rather
than cause every user of a signal mask to be prepared for this very
rare case, we will just add a second check later in the signal
delivery code. Said change is not in this diff.

This also un-compensates all of our compatability code for dealing
with SA. SA is a NetBSD-specific thing, so there's no need for
Irix, Linux, Solaris, SVR4 and so on to cope with it.

As previously, everything other than kern_sa.c compiles in i386
GENERIC as of this checkin. I will switch to ALL soon for compile
testing.
 1.37.4.1 10-May-2008  wrstuden Initial checkin of re-adding SA. Everything except kern_sa.c
compiles in GENERIC for i386. This is still a work-in-progress, but
this checkin covers most of the mechanical work (changing signalling
to be able to accomidate SA's process-wide signalling and re-adding
includes of sys/sa.h and savar.h). Subsequent changes will be much
more interesting.

Also, kern_sa.c has received partial cleanup. There's still more
to do, though.
 1.37.2.3 11-Aug-2010  yamt sync with head.
 1.37.2.2 11-Mar-2010  yamt sync with head
 1.37.2.1 04-May-2009  yamt sync with head.
 1.39.4.1 02-Feb-2009  snj Pull up following revision(s) (requested by martin in ticket #332):
sys/arch/amiga/amiga/trap.c: revision 1.122
sys/arch/atari/atari/trap.c: revision 1.99
sys/arch/cesfic/cesfic/trap.c: revision 1.43
sys/arch/hp300/hp300/trap.c: revision 1.140
sys/arch/luna68k/luna68k/trap.c: revision 1.55
sys/arch/m68k/include/signal.h: revision 1.25
sys/arch/m68k/m68k/sig_machdep.c: revision 1.41
sys/arch/mac68k/mac68k/trap.c: revision 1.136 via patch
sys/arch/mvme68k/mvme68k/trap.c: revision 1.98
sys/arch/news68k/news68k/trap.c: revision 1.60
sys/arch/next68k/next68k/trap.c: revision 1.75
sys/arch/sun2/sun2/trap.c: revision 1.37
sys/arch/sun3/sun3/trap.c: revision 1.136
sys/arch/x68k/x68k/trap.c: revision 1.97
Centralize fpu exception to siginfo code encoding for all m68k archs,
fixes a failure in the lib/libc/ieeefp/except regression test.
 1.39.2.2 03-Mar-2009  skrll Sync with HEAD.
 1.39.2.1 19-Jan-2009  skrll Sync with HEAD.
 1.42.4.2 05-Mar-2011  rmind sync with head
 1.42.4.1 03-Jul-2010  rmind sync with head
 1.42.2.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.44.4.2 05-Mar-2011  bouyer Sync with HEAD
 1.44.4.1 17-Feb-2011  bouyer Sync with HEAD
 1.44.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.46.8.3 02-Jun-2012  mrg sync to latest -current.
 1.46.8.2 24-Feb-2012  mrg sync to -current.
 1.46.8.1 18-Feb-2012  mrg merge to -current.
 1.46.4.2 23-May-2012  yamt sync with head.
 1.46.4.1 17-Apr-2012  yamt sync with head
 1.47.2.1 21-May-2012  riz Pull up following revision(s) (requested by martin in ticket #274):
sys/arch/amd64/amd64/process_machdep.c: revision 1.20
sys/kern/sys_lwp.c: revision 1.54
sys/arch/sparc64/sparc64/machdep.c: revision 1.267
sys/arch/mips/mips/cpu_subr.c: revision 1.16
sys/arch/vax/vax/machdep.c: revision 1.188
sys/sys/lwp.h: revision 1.161
sys/arch/sparc64/sparc64/netbsd32_machdep.c: revision 1.98
sys/arch/alpha/alpha/machdep.c: revision 1.339
sys/compat/sys/ucontext.h: revision 1.6
sys/arch/hppa/hppa/hppa_machdep.c: revision 1.28
distrib/sets/lists/tests/mi: revision 1.469
sys/arch/powerpc/powerpc/sig_machdep.c: revision 1.42
tests/lib/libc/sys/t_lwp_create.c: revision 1.1
tests/lib/libc/sys/Makefile: revision 1.23
sys/arch/arm/arm/sig_machdep.c: revision 1.42
sys/arch/amd64/include/mcontext.h: revision 1.15
sys/arch/amd64/amd64/machdep.c: revision 1.183
sys/arch/sh3/sh3/sh3_machdep.c: revision 1.99
sys/arch/i386/i386/machdep.c: revision 1.727
sys/compat/netbsd32/netbsd32_lwp.c: revision 1.13
sys/arch/sparc/sparc/machdep.c: revision 1.319
sys/arch/amd64/amd64/netbsd32_machdep.c: revision 1.76
sys/arch/m68k/m68k/sig_machdep.c: revision 1.49
sys/sys/ucontext.h: revision 1.16
sys/arch/mips/mips/netbsd32_machdep.c: revision 1.9
lib/libc/sys/_lwp_create.2: revision 1.5
Calling _lwp_create() with a bogus ucontext could trigger a kernel
assertion failure (and thus a crash in DIAGNOSTIC kernels). Independently
discovered by YAMAMOTO Takashi and Joel Sing.
To avoid this, introduce a cpu_mcontext_validate() function and move all
sanity checks from cpu_setmcontext() there. Also untangle the netbsd32
compat mess slightly and add a cpu_mcontext32_validate() cousin there.
Add an exhaustive atf test case, based partly on code from Joel Sing.
Should finally fix the remaining open part of PR kern/43903.
 1.49.40.1 10-Jun-2019  christos Sync with HEAD
 1.49.38.1 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.49.32.1 27-Jan-2019  martin Pull up following revision(s) (requested by maxv in ticket #1173):
sys/arch/hppa/hppa/sig_machdep.c: revision 1.26
sys/arch/arm/arm/sig_machdep.c: revision 1.51
sys/arch/i386/i386/machdep.c: revision 1.813
sys/arch/alpha/alpha/machdep.c: revision 1.352
sys/arch/m68k/m68k/sig_machdep.c: revision 1.50
sys/arch/usermode/target/i386/cpu_i386.c: revision 1.8
sys/arch/sparc64/sparc64/machdep.c: revision 1.289
sys/arch/sparc64/sparc64/netbsd32_machdep.c: revision 1.111
sys/arch/powerpc/powerpc/sig_machdep.c: revision 1.46
sys/arch/amd64/amd64/netbsd32_machdep.c: revision 1.117
sys/arch/sh3/sh3/sh3_machdep.c: revision 1.106
sys/arch/mips/mips/netbsd32_machdep.c: revision 1.16
sys/arch/mips/mips/sig_machdep.c: revision 1.24
sys/arch/riscv/riscv/sig_machdep.c: revision 1.2
sys/arch/usermode/target/x86_64/cpu_x86_64.c: revision 1.7
sys/arch/vax/vax/sig_machdep.c: revision 1.23

Fix widespread leak in the sendsig_siginfo() functions. sigframe_siginfo
has padding, so zero it out properly. While here I'm also zeroing out some
other things in several ports, for safety. Same problem in netbsd32, so
fix that too.

I can't compile-test on each architecture, but there should be no
breakage (tm).

Overall this fixes at least 14 info leaks. Prompted by the discovery by
KLEAK of a leak in amd64's sendsig_siginfo.
 1.49.26.1 30-Jan-2019  martin Pull up following revision(s) (requested by maxv in ticket #1677):

sys/arch/hppa/hppa/sig_machdep.c: revision 1.26
sys/arch/arm/arm/sig_machdep.c: revision 1.51
sys/arch/i386/i386/machdep.c: revision 1.813
sys/arch/alpha/alpha/machdep.c: revision 1.352
sys/arch/m68k/m68k/sig_machdep.c: revision 1.50
sys/arch/usermode/target/i386/cpu_i386.c: revision 1.8
sys/arch/sparc64/sparc64/machdep.c: revision 1.289
sys/arch/sparc64/sparc64/netbsd32_machdep.c: revision 1.111
sys/arch/powerpc/powerpc/sig_machdep.c: revision 1.46
sys/arch/amd64/amd64/netbsd32_machdep.c: revision 1.117
sys/arch/sh3/sh3/sh3_machdep.c: revision 1.106
sys/arch/mips/mips/netbsd32_machdep.c: revision 1.16
sys/arch/mips/mips/sig_machdep.c: revision 1.24
sys/arch/usermode/target/x86_64/cpu_x86_64.c: revision 1.7
sys/arch/vax/vax/sig_machdep.c: revision 1.23

Fix widespread leak in the sendsig_siginfo() functions. sigframe_siginfo
has padding, so zero it out properly. While here I'm also zeroing out some
other things in several ports, for safety. Same problem in netbsd32, so
fix that too.

I can't compile-test on each architecture, but there should be no
breakage (tm).

Overall this fixes at least 14 info leaks. Prompted by the discovery by
KLEAK of a leak in amd64's sendsig_siginfo.
 1.49.18.1 30-Jan-2019  martin Pull up following revision(s) (requested by maxv in ticket #1677):

sys/arch/hppa/hppa/sig_machdep.c: revision 1.26
sys/arch/arm/arm/sig_machdep.c: revision 1.51
sys/arch/i386/i386/machdep.c: revision 1.813
sys/arch/alpha/alpha/machdep.c: revision 1.352
sys/arch/m68k/m68k/sig_machdep.c: revision 1.50
sys/arch/usermode/target/i386/cpu_i386.c: revision 1.8
sys/arch/sparc64/sparc64/machdep.c: revision 1.289
sys/arch/sparc64/sparc64/netbsd32_machdep.c: revision 1.111
sys/arch/powerpc/powerpc/sig_machdep.c: revision 1.46
sys/arch/amd64/amd64/netbsd32_machdep.c: revision 1.117
sys/arch/sh3/sh3/sh3_machdep.c: revision 1.106
sys/arch/mips/mips/netbsd32_machdep.c: revision 1.16
sys/arch/mips/mips/sig_machdep.c: revision 1.24
sys/arch/usermode/target/x86_64/cpu_x86_64.c: revision 1.7
sys/arch/vax/vax/sig_machdep.c: revision 1.23

Fix widespread leak in the sendsig_siginfo() functions. sigframe_siginfo
has padding, so zero it out properly. While here I'm also zeroing out some
other things in several ports, for safety. Same problem in netbsd32, so
fix that too.

I can't compile-test on each architecture, but there should be no
breakage (tm).

Overall this fixes at least 14 info leaks. Prompted by the discovery by
KLEAK of a leak in amd64's sendsig_siginfo.
 1.49.14.1 30-Jan-2019  martin Pull up following revision(s) (requested by maxv in ticket #1677):

sys/arch/hppa/hppa/sig_machdep.c: revision 1.26
sys/arch/arm/arm/sig_machdep.c: revision 1.51
sys/arch/i386/i386/machdep.c: revision 1.813
sys/arch/alpha/alpha/machdep.c: revision 1.352
sys/arch/m68k/m68k/sig_machdep.c: revision 1.50
sys/arch/usermode/target/i386/cpu_i386.c: revision 1.8
sys/arch/sparc64/sparc64/machdep.c: revision 1.289
sys/arch/sparc64/sparc64/netbsd32_machdep.c: revision 1.111
sys/arch/powerpc/powerpc/sig_machdep.c: revision 1.46
sys/arch/amd64/amd64/netbsd32_machdep.c: revision 1.117
sys/arch/sh3/sh3/sh3_machdep.c: revision 1.106
sys/arch/mips/mips/netbsd32_machdep.c: revision 1.16
sys/arch/mips/mips/sig_machdep.c: revision 1.24
sys/arch/usermode/target/x86_64/cpu_x86_64.c: revision 1.7
sys/arch/vax/vax/sig_machdep.c: revision 1.23

Fix widespread leak in the sendsig_siginfo() functions. sigframe_siginfo
has padding, so zero it out properly. While here I'm also zeroing out some
other things in several ports, for safety. Same problem in netbsd32, so
fix that too.

I can't compile-test on each architecture, but there should be no
breakage (tm).

Overall this fixes at least 14 info leaks. Prompted by the discovery by
KLEAK of a leak in amd64's sendsig_siginfo.
 1.16 17-Jan-2024  thorpej Make sigcode.s and sunos_sigcode.s build as their own stand-alone files.
 1.15 01-Aug-2013  matt Convert to motorola style.
 1.14 08-Feb-2011  rmind branches: 1.14.4; 1.14.14; 1.14.18;
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.13 11-Dec-2005  christos branches: 1.13.100; 1.13.106; 1.13.108;
merge ktrace-lwp.
 1.12 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.11 04-Jul-2002  thorpej branches: 1.11.6;
During signal delivery, arrange to have the signal handler invoked
directly, using the trampoline only for the return path. Saves a
"jsr" in the trampoline.

Reviewed, tested and OK'd by Steve Woodford.
 1.10 26-Nov-2000  jdolecek branches: 1.10.4; 1.10.8; 1.10.16;
split m68k SunOS and SVR4-specific sigcode.s code to sunos_sigcode.s
and svr4_sigcode.s respectively
adjust individual m68k port's locore.s to include new sigcode files if
appropriate
 1.9 10-Nov-1999  thorpej Add register prefixes.
 1.8 29-Apr-1999  christos branches: 1.8.2; 1.8.4; 1.8.8;
Add sunos_sigcode, sunos_esigcode trampoline that uses trap 1
 1.7 19-Apr-1999  kleink Add COMPAT_SVR4 for m68k.
 1.6 05-Oct-1998  thorpej branches: 1.6.6;
Fix a problem reported by Michael Hitch. Basically, our libc relies on the
non-standard way of invoking sigreturn, specifically a side-effect that I
overlooked. Thus, longjmp's return value was getting clobbered.

Sigh, so burn trap #3 just as sigreturn.

XXX We need an SVR4-style {get,set}context(2) to avoid wasting new
XXX trap vectors in the future.
 1.5 01-Oct-1998  thorpej Oops, typo.
 1.4 30-Sep-1998  thorpej Use the new special syscall entry point, and specify SYS___sigreturn14.
Makes the sigcode grow by 4 bytes.

Note that we are no longer able to use the HP-UX breakpoint "sigcodetrap"
hack here, as a result. This means that BSD programs can no longer be
debugged by HP-UX debuggers. *Sniff* Don't break my heart...
 1.3 30-Sep-1998  thorpej Use the symbolic constant SYS_exit.
 1.2 25-Apr-1997  thorpej - Don't make assumptions about how C labels are handled.
- Use PANIC() where appropriate.
 1.1 13-Apr-1997  thorpej Common m68k sigcode.
 1.6.6.2 30-Apr-1999  perry branches: 1.6.6.2.2;
nuke sysv junk -- make last pullup cleaner
 1.6.6.1 30-Apr-1999  perry pullup 1.6->1.8 (christos): 1.7 pulled up to avoid conflicts
 1.6.6.2.2.1 21-Jun-1999  thorpej Sync w/ -current.
 1.8.8.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.8.4.1 15-Nov-1999  fvdl Sync with -current
 1.8.2.2 08-Dec-2000  bouyer Sync with HEAD.
 1.8.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.10.16.1 16-Jul-2002  gehenna catch up with -current.
 1.10.8.3 02-Aug-2002  nathanw Don't need upcallcode.
 1.10.8.2 01-Aug-2002  nathanw Catch up to -current.
 1.10.8.1 17-Nov-2001  scw Kernel support for Scheduler Activations on m68k-based ports using
mvme68k as a testbed.

Boots multi-user on an mvme162, although userland support for SA is not
yet integrated/tested.
 1.10.4.1 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.11.6.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.11.6.2 18-Sep-2004  skrll Sync with HEAD.
 1.11.6.1 03-Aug-2004  skrll Sync with HEAD
 1.13.108.1 17-Feb-2011  bouyer Sync with HEAD
 1.13.106.1 06-Jun-2011  jruoho Sync with HEAD.
 1.13.100.1 05-Mar-2011  rmind sync with head
 1.14.18.1 28-Aug-2013  rmind sync with head
 1.14.14.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.14.4.1 22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.12 17-Jan-2024  thorpej Make compat_13_sigreturn13.s and compat_16_sigreturn14.s build as their
own stand-alone files and G/C the now-empty sigreturn.s.
 1.11 08-Feb-2011  rmind branches: 1.11.86;
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.10 11-Dec-2005  christos branches: 1.10.100; 1.10.106; 1.10.108;
merge ktrace-lwp.
 1.9 22-Sep-2003  cl SA_SIGINFO support for m68k
 1.8 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.7 23-Jun-2003  martin branches: 1.7.2;
Make sure to include opt_foo.h if a defflag option FOO is used.
 1.6 26-Nov-2001  fredette COMPAT_SUNOS requires the 1.3 sigreturn code, so include it
even if COMPAT_13 isn't defined.
 1.5 10-Nov-1999  thorpej branches: 1.5.8; 1.5.12;
Add register prefixes.
 1.4 05-Oct-1998  thorpej branches: 1.4.12; 1.4.14; 1.4.18;
Fix a problem reported by Michael Hitch. Basically, our libc relies on the
non-standard way of invoking sigreturn, specifically a side-effect that I
overlooked. Thus, longjmp's return value was getting clobbered.

Sigh, so burn trap #3 just as sigreturn.

XXX We need an SVR4-style {get,set}context(2) to avoid wasting new
XXX trap vectors in the future.
 1.3 01-Oct-1998  thorpej Expect the syscall number to push to be in register d0.
 1.2 25-Apr-1997  thorpej - Don't make assumptions about how C labels are handled.
- Use PANIC() where appropriate.
 1.1 31-Jan-1996  thorpej Factor out the common (to all m68k ports) sigreturn routine.
 1.4.18.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.4.14.1 15-Nov-1999  fvdl Sync with -current
 1.4.12.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.5.12.1 08-Jan-2002  nathanw Catch up to -current.
 1.5.8.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.7.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.7.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.7.2.1 03-Aug-2004  skrll Sync with HEAD
 1.10.108.1 17-Feb-2011  bouyer Sync with HEAD
 1.10.106.1 06-Jun-2011  jruoho Sync with HEAD.
 1.10.100.1 05-Mar-2011  rmind sync with head
 1.11.86.1 27-Jun-2024  martin Pull up following revision(s) (requested by rin in ticket #724
to fix build fallout on the branch):

sys/arch/m68k/m68k/compat_16_sigreturn14.s: revision 1.6
sys/arch/mvme68k/mvme68k/locore.s: revision 1.129
sys/arch/news68k/news68k/locore.s: revision 1.84
sys/arch/hp300/hp300/locore.s: revision 1.183
sys/arch/m68k/m68k/compat_13_sigreturn13.s: revision 1.8
sys/arch/m68k/m68k/sigreturn.s: file removal
sys/arch/m68k/include/pte_motorola.h: revision 1.10
sys/arch/atari/atari/locore.s: revision 1.125
sys/arch/amiga/amiga/locore.s: revision 1.169
sys/arch/sun2/sun2/locore.s: revision 1.37
sys/arch/next68k/next68k/locore.s: revision 1.84
sys/arch/x68k/x68k/locore.s: revision 1.130
sys/arch/sun3/sun3x/locore.s: revision 1.77
sys/arch/cesfic/cesfic/locore.s: revision 1.45
sys/arch/m68k/conf/files.m68k: revision 1.53
sys/arch/sun3/sun3/locore.s: revision 1.109
sys/arch/luna68k/luna68k/locore.s: revision 1.81
sys/arch/mac68k/mac68k/locore.s: revision 1.182

Define PTE used in the pmap module int terms of the bit definitions
in mmu_{51,40}.h.

Make compat_13_sigreturn13.s and compat_16_sigreturn14.s build as their
own stand-alone files and G/C the now-empty sigreturn.s.
 1.2 03-Dec-2007  ad 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.1 04-Mar-2007  tsutsui branches: 1.1.4; 1.1.20; 1.1.22; 1.1.24; 1.1.30;
Add common soft interrupt routines for m68k ports which use
hp300 derived simulated software interrupt with VAX REI emulation.
Just taken from hp300/hp300/softintr.c and sys/arch/hp300/include/intr.h.
 1.1.30.1 08-Dec-2007  mjf Sync with HEAD.
 1.1.24.3 07-Dec-2007  yamt sync with head
 1.1.24.2 03-Sep-2007  yamt sync with head.
 1.1.24.1 04-Mar-2007  yamt file softintr.c was added on branch yamt-lazymbuf on 2007-09-03 14:27:15 +0000
 1.1.22.1 23-Mar-2008  matt sync with HEAD
 1.1.20.1 09-Dec-2007  jmcneill Sync with HEAD.
 1.1.4.2 12-Mar-2007  rmind Sync with HEAD.
 1.1.4.1 04-Mar-2007  rmind file softintr.c was added on branch yamt-idlelwp on 2007-03-12 05:48:54 +0000
 1.40 20-Dec-2023  thorpej Remove unnecessary <sys/malloc.h> include.
 1.39 26-Sep-2023  tsutsui TAB/space cleanup.
 1.38 08-Feb-2011  rmind Remove clause 3 (UCB advertising clause) from the University of Utah
copyright. Confirmed by Mike Hibler, mike at cs.utah.edu - thanks!
Also, merge UCB and Utah copyright texts back into one, as they
originally were.

Extra verification by snj@.
 1.37 23-Nov-2009  rmind branches: 1.37.4; 1.37.6; 1.37.8;
Use lwp_getpcb() on m68k ports, clean from struct user usage.
 1.36 24-Apr-2008  ad branches: 1.36.2; 1.36.4;
Merge proc::p_mutex and proc::p_smutex into a single adaptive mutex, since
we no longer need to guard against access from hardware interrupt handlers.

Additionally, if cloning a process with CLONE_SIGHAND, arrange to have the
child process share the parent's lock so that signal state may be kept in
sync. Partially addresses PR kern/37437.
 1.35 20-Dec-2007  dsl branches: 1.35.6; 1.35.8;
Convert all the system call entry points from:
int foo(struct lwp *l, void *v, register_t *retval)
to:
int foo(struct lwp *l, const struct foo_args *uap, register_t *retval)
Fixup compat code to not write into 'uap' and (in some cases) to actually
pass a correctly formatted 'uap' structure with the right name to the
next routine.
A few 'compat' routines that just call standard ones have been deleted.
All the 'compat' code compiles (along with the kernels required to test
build it).
98% done by automated scripts.
 1.34 04-Mar-2007  christos branches: 1.34.20; 1.34.28; 1.34.32;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.33 09-Feb-2007  ad branches: 1.33.2;
Merge newlock2 to head.
 1.32 22-Jul-2006  tsutsui branches: 1.32.4;
TAB/space cleanup.
 1.31 22-Jul-2006  tsutsui KNF, remove register decls
 1.30 11-Dec-2005  christos branches: 1.30.4; 1.30.8;
merge ktrace-lwp.
 1.29 14-Sep-2005  he Another file needing <compat/sys/signal.h> and <compat/sys/signalvar.h>
for native_sigset_to_sigset13().
 1.28 28-Aug-2004  thorpej branches: 1.28.12;
Use ANSI function decls and static.
 1.27 08-Oct-2003  thorpej * Shuffle some data structures so, and add a flags word to ksiginfo_t.
Right now the only flag is used to indicate if a ksiginfo_t is a
result of a trap. Add a predicate macro to test for this flag.
* Add initialization macros for ksiginfo_t's.
* Add accssor macro for ksi_trap. Expands to 0 if the ksiginfo_t was
not the result of a trap. This matches the sigcontext trapcode semantics.
* In kpsendsig(), use KSI_TRAP_P() to select the lwp that gets the signal.
Inspired by Matthias Drochner's fix to kpsendsig(), but correctly handles
the case of non-trap-generated signals that have a > 0 si_code.

This patch fixes a signal delivery problem with threaded programs noted by
Matthias Drochner on tech-kern.

As discussed on tech-kern. Reviewed and OK's by Christos.
 1.26 25-Sep-2003  christos constify siginfo/trapsignal
 1.25 22-Sep-2003  cl SA_SIGINFO support for m68k (compat sunos)
 1.24 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.23 15-Jul-2003  lukem __KERNEL_RCSID()
 1.22 17-Jan-2003  thorpej branches: 1.22.2;
Merge the nathanw_sa branch.
 1.21 04-Jul-2002  thorpej Add kernel support for having userland provide the signal trampoline:

* struct sigacts gets a new sigact_sigdesc structure, which has the
sigaction and the trampoline/version. Version 0 means "legacy kernel
provided trampoline". Other versions are coordinated with machine-
dependent code in libc.
* sigaction1() grows two more arguments -- the trampoline pointer and
the trampoline version.
* A new __sigaction_sigtramp() system call is provided to register a
trampoline along with a signal handler.
* The handler is no longer passed to sensig() functions. Instead,
sendsig() looks up the handler by peeking in the sigacts for the
process getting the signal (since it has to look in there for the
trampoline anyway).
* Native sendsig() functions now select the appropriate trampoline and
its arguments based on the trampoline version in the sigacts.

Changes to libc to use the new facility will be checked in later. Kernel
version not bumped; we will ride the 1.6C bump made recently.
 1.20 22-Dec-2000  jdolecek branches: 1.20.4; 1.20.8; 1.20.16;
split off thread specific stuff from struct sigacts to struct sigctx, leaving
only signal handler array sharable between threads
move other random signal stuff from struct proc to struct sigctx

This addresses kern/10981 by Matthew Orgass.
 1.19 16-Aug-1999  simonb branches: 1.19.2;
Spell "privilege" correctly (correct spelling from Jonathan Stone).
 1.18 25-Mar-1999  mrg remove opt_uvm.h
 1.17 25-Oct-1998  is Fix obvious typo in DEBUG code
 1.16 01-Oct-1998  thorpej Update for signal changes.
 1.15 08-May-1998  kleink Fix some arithmetics lossage on typeless pointers.
 1.14 22-Feb-1998  scw Implement changes for UVM.
 1.13 17-Oct-1997  briggs Include vm/vm.h.
 1.12 13-Oct-1996  christos branches: 1.12.12;
backout previous kprintf change
 1.11 11-Oct-1996  christos printf -> kprintf, sprintf -> ksprintf
 1.10 05-May-1996  veego Added an include for the sunos_sendsig prototyp
 1.9 30-Apr-1996  briggs Clean up a few printf format strings.
 1.8 04-Jan-1996  jtc Changed name of sigaltstack's ss_base field to ss_sp to match XPG4.2 and
traditional usage.
 1.7 10-Oct-1995  gwr Cosmetic: Kill trailing whitespace, etc.
 1.6 07-Oct-1995  mycroft Prefix names of system call implementation functions with `sys_'.
 1.5 21-Sep-1995  briggs Make sunos_sigreturn() match prototype.
 1.4 01-Sep-1995  mycroft SA_ONSTACK --> SS_ONSTACK
 1.3 23-Apr-1995  chopps add needed signal debug stuff so it will compile with DEBUG
 1.2 23-Apr-1995  briggs Make this actually compile...
 1.1 22-Apr-1995  christos Shared sunos_machdep.c
 1.12.12.1 08-Sep-1997  thorpej Significantly restructure the way signal state for a process is stored.
Rather than using bitmasks to redundantly store the information kept
in the process's sigacts (because the sigacts was kept in the u-area),
hang sigacts directly off the process, and access it directly.

Simplify signal setup code tremendously by storing information in
the sigacts as an array of struct sigactions, rather than in a different
format, since userspace uses sigactions.

Make sigacts sharable by adding reference counting.
 1.19.2.1 05-Jan-2001  bouyer Sync with HEAD
 1.20.16.1 16-Jul-2002  gehenna catch up with -current.
 1.20.8.5 01-Aug-2002  nathanw Catch up to -current.
 1.20.8.4 12-Jul-2002  nathanw No longer need to pull in lwp.h; proc.h pulls it in for us.
 1.20.8.3 24-Jun-2002  nathanw Curproc->curlwp renaming.

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

"curproc" is now #defined in proc.h as ((curlwp) ? (curlwp)->l_proc) : NULL)
so that it is always safe to reference curproc (*de*referencing curproc
is another story, but that's always been true).
 1.20.8.2 29-May-2002  nathanw #include <sys/sa.h> before <sys/syscallargs.h>, to provide sa_upcall_t
now that <sys/param.h> doesn't include <sys/sa.h>.

(Behold the Power of Ed)
 1.20.8.1 17-Nov-2001  scw Kernel support for Scheduler Activations on m68k-based ports using
mvme68k as a testbed.

Boots multi-user on an mvme162, although userland support for SA is not
yet integrated/tested.
 1.20.4.1 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.22.2.5 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.22.2.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.22.2.3 18-Sep-2004  skrll Sync with HEAD.
 1.22.2.2 03-Sep-2004  skrll Sync with HEAD
 1.22.2.1 03-Aug-2004  skrll Sync with HEAD
 1.28.12.5 21-Jan-2008  yamt sync with head
 1.28.12.4 03-Sep-2007  yamt sync with head.
 1.28.12.3 26-Feb-2007  yamt sync with head.
 1.28.12.2 30-Dec-2006  yamt sync with head.
 1.28.12.1 21-Jun-2006  yamt sync with head.
 1.30.8.1 11-Aug-2006  yamt sync with head
 1.30.4.1 09-Sep-2006  rpaulo sync with head
 1.32.4.2 06-Feb-2007  ad Make amiga & mac68k compile.
 1.32.4.1 30-Jan-2007  ad Remove support for SA. Ok core@.
 1.33.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.34.32.1 02-Jan-2008  bouyer Sync with HEAD
 1.34.28.1 26-Dec-2007  ad Sync with head.
 1.34.20.1 09-Jan-2008  matt sync with HEAD
 1.35.8.1 18-May-2008  yamt sync with head.
 1.35.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.36.4.3 14-May-2008  wrstuden Per discussion with ad at n dot o, revert signal mask handling
changes.

The l_sigstk changes are most likely totally un-needed as SA will
never use a signal stack - we send an upcall (or will as other
diffs are brought in).

The l_sigmask changes were too controvertial. In all honesty, I
think it's probably best to revert them. The main reason they were
there is the fact that in an SA process, we don't mask signals per
kernel thread, we mask them per user thread. In the kernel, we want
them all to get turned into upcalls. Thus the normal state of
l_sigmask in an SA process is for it to always be empty.

While we are in the process of delivering a signal, we want to
temporarily mask a signal (so we don't recursively exhaust our
upcall stacks). However signal delivery is rare (important, but
rare), and delivering back-to-back signals is even rarer. So rather
than cause every user of a signal mask to be prepared for this very
rare case, we will just add a second check later in the signal
delivery code. Said change is not in this diff.

This also un-compensates all of our compatability code for dealing
with SA. SA is a NetBSD-specific thing, so there's no need for
Irix, Linux, Solaris, SVR4 and so on to cope with it.

As previously, everything other than kern_sa.c compiles in i386
GENERIC as of this checkin. I will switch to ALL soon for compile
testing.
 1.36.4.2 14-May-2008  wrstuden Per discussion with ad, remove most of the #include <sys/sa.h> lines
as they were including sa.h just for the type(s) needed for syscallargs.h.

Instead, create a new file, sys/satypes.h, which contains just the
types needed for syscallargs.h. Yes, there's only one now, but that
may change and it's probably more likely to change if it'd be difficult
to handle. :-)

Per discussion with matt at n dot o, add an include of satypes.h to
sigtypes.h. Upcall handlers are kinda signal handlers, and signalling
is the header file that's already included for syscallargs.h that
closest matches SA.

This shaves about 3000 lines off of the diff of the branch relative
to the base. That also represents about 18% of the total before this
checkin.

I think this reduction is very good thing.
 1.36.4.1 10-May-2008  wrstuden Initial checkin of re-adding SA. Everything except kern_sa.c
compiles in GENERIC for i386. This is still a work-in-progress, but
this checkin covers most of the mechanical work (changing signalling
to be able to accomidate SA's process-wide signalling and re-adding
includes of sys/sa.h and savar.h). Subsequent changes will be much
more interesting.

Also, kern_sa.c has received partial cleanup. There's still more
to do, though.
 1.36.2.1 11-Mar-2010  yamt sync with head
 1.37.8.1 17-Feb-2011  bouyer Sync with HEAD
 1.37.6.1 06-Jun-2011  jruoho Sync with HEAD.
 1.37.4.1 05-Mar-2011  rmind sync with head
 1.8 17-Jan-2024  thorpej Make sigcode.s and sunos_sigcode.s build as their own stand-alone files.
 1.7 26-Sep-2023  tsutsui TAB/space cleanup.
 1.6 01-Aug-2013  matt Convert to motorola style.
 1.5 08-Feb-2011  rmind branches: 1.5.4; 1.5.14; 1.5.18;
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.4 11-Dec-2005  christos branches: 1.4.100; 1.4.106; 1.4.108;
merge ktrace-lwp.
 1.3 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.2 26-Nov-2000  jdolecek branches: 1.2.2; 1.2.26;
make this usable also standalone
 1.1 26-Nov-2000  jdolecek split m68k SunOS and SVR4-specific sigcode.s code to sunos_sigcode.s
and svr4_sigcode.s respectively
adjust individual m68k port's locore.s to include new sigcode files if
appropriate
 1.2.26.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.2.26.2 18-Sep-2004  skrll Sync with HEAD.
 1.2.26.1 03-Aug-2004  skrll Sync with HEAD
 1.2.2.2 08-Dec-2000  bouyer Sync with HEAD.
 1.2.2.1 26-Nov-2000  bouyer file sunos_sigcode.s was added on branch thorpej_scsipi on 2000-12-08 09:28:16 +0000
 1.4.108.1 17-Feb-2011  bouyer Sync with HEAD
 1.4.106.1 06-Jun-2011  jruoho Sync with HEAD.
 1.4.100.1 05-Mar-2011  rmind sync with head
 1.5.18.1 28-Aug-2013  rmind sync with head
 1.5.14.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.5.4.1 22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.24 06-Apr-2019  thorpej Overhaul the API used to fetch and store individual memory cells in
userspace. The old fetch(9) and store(9) APIs (fubyte(), fuword(),
subyte(), suword(), etc.) are retired and replaced with new ufetch(9)
and ustore(9) APIs that can return proper error codes, etc. and are
implemented consistently across all platforms. The interrupt-safe
variants are no longer supported (and several of the existing attempts
at fuswintr(), etc. were buggy and not actually interrupt-safe).

Also augmement the ucas(9) API, making it consistently available on
all plaforms, supporting uniprocessor and multiprocessor systems, even
those that do not have CAS or LL/SC primitives.

Welcome to NetBSD 8.99.37.
 1.23 07-Mar-2015  christos branches: 1.23.18;
adjust to new trace_{enter,exit} signatures.
 1.22 08-Feb-2011  rmind branches: 1.22.14; 1.22.32;
Remove clause 3 (UCB advertising clause) from the University of Utah
copyright. Confirmed by Mike Hibler, mike at cs.utah.edu - thanks!
Also, merge UCB and Utah copyright texts back into one, as they
originally were.

Extra verification by snj@.
 1.21 23-Nov-2009  rmind branches: 1.21.4; 1.21.6; 1.21.8;
Use lwp_getpcb() on m68k ports, clean from struct user usage.
 1.20 25-Nov-2008  tsutsui Add #ifdef _KERNEL_OPT.
 1.19 21-Oct-2008  ad branches: 1.19.2;
Provide a small inline wrapper for sysent::sy_call() and use it to store
the active syscall description in struct lwp. To be used at some future
point to prevent unloading of modules that provide syscalls, while the
syscalls are in use.
 1.18 06-Feb-2008  dsl branches: 1.18.6; 1.18.10; 1.18.16;
Remove the 'args' parameter to 'trace_exit()' it is no longer used.
Instead of passing the (un)real system call code and syscall table pointer,
just pass the number of arguments - which is what ktrace really wants.
Ride forthcoming 4.99.53
 1.17 05-Jan-2008  dsl Don't pass 'curlwp' into trace_enter() and trace_exit().
 1.16 04-Mar-2007  tsutsui branches: 1.16.20; 1.16.26; 1.16.32;
Use (char *) where pointer arith is required.
 1.15 04-Mar-2007  christos Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.14 22-Jul-2006  tsutsui branches: 1.14.10;
TAB/space cleanup.
 1.13 07-Mar-2006  thorpej branches: 1.13.2;
Syscall debug tracing is handled by trace_enter() / trace_exit(). Change
trace_is_enabled() to return TRUE if SYSCALL_DEBUG is defined, and g/c
all of the SYSCALL_DEBUG handling from individual system call dispatch
routines.
 1.12 07-Mar-2006  thorpej Clean up fallout proc_is_traced_p() change:
- proc_is_traced_p() -> trace_is_enabled(), to match trace_enter() and
trace_exit().
- trace_is_enabled() becomes a real function.
- Remove unnecessary include files from various files that used to care
about KTRACE and SYSTRACE, but do no more.
 1.11 05-Mar-2006  christos Add a proc_is_traced_p() macro and use it, instead of copying the same code
in many places. Idea from thorpej.
 1.10 05-Mar-2006  christos branches: 1.10.2;
implement PT_SYSCALL
 1.9 11-Dec-2005  christos branches: 1.9.4; 1.9.6;
merge ktrace-lwp.
 1.8 01-Jul-2005  christos branches: 1.8.2;
PR/29607: Christian Biere systrace doesn't handle interrupted syscalls properly
Instead of jumping to the default "bad" case, jump to the error handling
switch, so that we can deal with ERESTART/EJUSTRETURN properly.
 1.7 31-Oct-2003  simonb Don't pass the (unused) return value args to the
trace_enter()/systrace_enter() functions.
 1.6 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.5 15-Jul-2003  lukem __KERNEL_RCSID()
 1.4 17-Jan-2003  thorpej branches: 1.4.2;
Merge the nathanw_sa branch.
 1.3 21-Dec-2002  manu Pass the system call table to trace_enter() and ktrsys() so that it is
possible to use alternate system call tables. This is usefull for
displaying correctly the arguments in Mach binaries traces.

If NULL is given, then the regular systam call table for the process is used.
 1.2 15-Nov-2002  manu Add a realcode argument to trace_enter and ktrsyscall. realcode is the
original system call number, which can be negative for a Mach trap.
We cannot just replace code by realcode, because ktrsyscall uses it as
an index in the system call table, thus crashing the kernel when the
value is negative.
 1.1 13-Jul-2002  scw branches: 1.1.2; 1.1.4; 1.1.6;
m68k syscall rototill:

- Switch all m68k-based ports over to __HAVE_SYSCALL_INTERN.
- Add systrace glue.
- Define struct mdproc in <m68k/proc.h> instead of <machine/proc.h>.
(They were all defined exactly the same anyway, other than a couple
of the MDP_* flags.)
 1.1.6.2 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.1.6.1 13-Jul-2002  jdolecek file sunos_syscall.c was added on branch kqueue on 2002-09-06 08:36:49 +0000
 1.1.4.5 29-Dec-2002  thorpej Sync with HEAD.
 1.1.4.4 11-Dec-2002  thorpej Sync with HEAD.
 1.1.4.3 02-Aug-2002  gmcgarry LWPify.
 1.1.4.2 01-Aug-2002  nathanw Catch up to -current.
 1.1.4.1 13-Jul-2002  nathanw file sunos_syscall.c was added on branch nathanw_sa on 2002-08-01 02:42:18 +0000
 1.1.2.2 16-Jul-2002  gehenna catch up with -current.
 1.1.2.1 13-Jul-2002  gehenna file sunos_syscall.c was added on branch gehenna-devsw on 2002-07-16 08:36:53 +0000
 1.4.2.4 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.4.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.4.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.4.2.1 03-Aug-2004  skrll Sync with HEAD
 1.8.2.5 11-Feb-2008  yamt sync with head.
 1.8.2.4 21-Jan-2008  yamt sync with head
 1.8.2.3 03-Sep-2007  yamt sync with head.
 1.8.2.2 30-Dec-2006  yamt sync with head.
 1.8.2.1 21-Jun-2006  yamt sync with head.
 1.9.6.1 22-Apr-2006  simonb Sync with head.
 1.9.4.1 09-Sep-2006  rpaulo sync with head
 1.10.2.3 11-Aug-2006  yamt sync with head
 1.10.2.2 13-Mar-2006  yamt sync with head.
 1.10.2.1 05-Mar-2006  yamt file sunos_syscall.c was added on branch yamt-pdpolicy on 2006-03-13 09:06:57 +0000
 1.13.2.2 07-Mar-2006  thorpej Syscall debug tracing is handled by trace_enter() / trace_exit(). Change
trace_is_enabled() to return TRUE if SYSCALL_DEBUG is defined, and g/c
all of the SYSCALL_DEBUG handling from individual system call dispatch
routines.
 1.13.2.1 07-Mar-2006  thorpej file sunos_syscall.c was added on branch elad-kernelauth on 2006-03-07 07:21:51 +0000
 1.14.10.1 12-Mar-2007  rmind Sync with HEAD.
 1.16.32.1 08-Jan-2008  bouyer Sync with HEAD
 1.16.26.1 18-Feb-2008  mjf Sync with HEAD.
 1.16.20.2 23-Mar-2008  matt sync with HEAD
 1.16.20.1 09-Jan-2008  matt sync with HEAD
 1.18.16.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.18.10.2 11-Mar-2010  yamt sync with head
 1.18.10.1 04-May-2009  yamt sync with head.
 1.18.6.1 17-Jan-2009  mjf Sync with HEAD.
 1.19.2.1 19-Jan-2009  skrll Sync with HEAD.
 1.21.8.1 17-Feb-2011  bouyer Sync with HEAD
 1.21.6.1 06-Jun-2011  jruoho Sync with HEAD.
 1.21.4.1 05-Mar-2011  rmind sync with head
 1.22.32.1 06-Apr-2015  skrll Sync with HEAD
 1.22.14.1 03-Dec-2017  jdolecek update from HEAD
 1.23.18.1 10-Jun-2019  christos Sync with HEAD
 1.10 16-Jan-2024  thorpej Build m68k/support.s on its own; don't include it from locore.s
 1.9 13-Jan-2024  thorpej Make getsfc() and getdfc() inlines; it's slightly smaller.
 1.8 01-Aug-2013  matt Convert to motorola style.
 1.7 15-Nov-2011  tsutsui branches: 1.7.10; 1.7.14;
Move spread getsfc() and getdfc() functions into common m68k/support.s.

Note:
- ENTRY_NOPROFILE() is okay since they are used only for debug printf
- they are declared to return int so no need to put a return value into %a0
 1.6 08-Feb-2011  rmind branches: 1.6.4;
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.5 11-Dec-2005  christos branches: 1.5.100; 1.5.106; 1.5.108;
merge ktrace-lwp.
 1.4 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.3 13-Aug-2001  jdolecek branches: 1.3.6; 1.3.22;
g/c _remque()/_insque(); use the C version in libkern
 1.2 10-Nov-1999  thorpej branches: 1.2.8;
Add register prefixes.
 1.1 16-Mar-1997  thorpej branches: 1.1.22; 1.1.24; 1.1.28;
Some misc. m68k asm support routines. This file currently contains
setjmp/longjmp and _insque/_remque. More to come.
 1.1.28.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.1.24.1 15-Nov-1999  fvdl Sync with -current
 1.1.22.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.2.8.1 25-Aug-2001  thorpej Merge Aug 24 -current into the kqueue branch.
 1.3.22.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.3.22.2 18-Sep-2004  skrll Sync with HEAD.
 1.3.22.1 03-Aug-2004  skrll Sync with HEAD
 1.3.6.2 13-Aug-2001  jdolecek g/c _remque()/_insque(); use the C version in libkern
 1.3.6.1 13-Aug-2001  jdolecek file support.s was added on branch nathanw_sa on 2001-08-13 06:10:10 +0000
 1.5.108.1 17-Feb-2011  bouyer Sync with HEAD
 1.5.106.1 06-Jun-2011  jruoho Sync with HEAD.
 1.5.100.1 05-Mar-2011  rmind sync with head
 1.6.4.2 22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.6.4.1 17-Apr-2012  yamt sync with head
 1.7.14.1 28-Aug-2013  rmind sync with head
 1.7.10.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.34 19-Dec-2018  maxv Remove compat_svr4 and compat_svr4_32, as discussed on tech-kern@ recently,
but also as discussed several times in the past.
 1.33 22-Dec-2011  tsutsui branches: 1.33.46; 1.33.48;
Remove fuction declarations of m68881_restore() and m68881_save().
They are in <m68k/m68k.h>.
 1.32 10-Dec-2009  matt branches: 1.32.12; 1.32.16;
Change u_long to vaddr_t/vsize_t in exec code where appropriate (mostly
involves setregs and vmcmds). Should result in no code differences.
 1.31 23-Nov-2009  rmind Use lwp_getpcb() on m68k ports, clean from struct user usage.
 1.30 19-Nov-2008  ad Make the emulations, exec formats, coredump, NFS, and the NFS server
into modules. By and large this commit:

- shuffles header files and ifdefs
- splits code out where necessary to be modular
- adds module glue for each of the components
- adds/replaces hooks for things that can be installed at runtime
 1.29 28-Apr-2008  martin branches: 1.29.2; 1.29.6; 1.29.8;
Remove clause 3 and 4 from TNF licenses
 1.28 24-Apr-2008  ad branches: 1.28.2;
Merge proc::p_mutex and proc::p_smutex into a single adaptive mutex, since
we no longer need to guard against access from hardware interrupt handlers.

Additionally, if cloning a process with CLONE_SIGHAND, arrange to have the
child process share the parent's lock so that signal state may be kept in
sync. Partially addresses PR kern/37437.
 1.27 08-Jan-2008  elad branches: 1.27.6; 1.27.8;
In svr4_sys_sysarch(), remove redundant kauth(9) call. Permission is
checked by old_sysctl().

okay christos@.
 1.26 20-Dec-2007  dsl Convert all the system call entry points from:
int foo(struct lwp *l, void *v, register_t *retval)
to:
int foo(struct lwp *l, const struct foo_args *uap, register_t *retval)
Fixup compat code to not write into 'uap' and (in some cases) to actually
pass a correctly formatted 'uap' structure with the right name to the
next routine.
A few 'compat' routines that just call standard ones have been deleted.
All the 'compat' code compiles (along with the kernels required to test
build it).
98% done by automated scripts.
 1.25 04-Mar-2007  christos branches: 1.25.20; 1.25.26; 1.25.28; 1.25.32;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.24 09-Feb-2007  ad branches: 1.24.2;
Merge newlock2 to head.
 1.23 04-Jan-2007  elad Consistent usage of KAUTH_GENERIC_ISSUSER.
 1.22 23-Jul-2006  ad branches: 1.22.4;
Use the LWP cached credentials where sane.
 1.21 22-Jul-2006  tsutsui TAB/space cleanup.
 1.20 22-Jul-2006  tsutsui KNF and misc cosmetics
 1.19 14-May-2006  elad integrate kauth.
 1.18 11-Dec-2005  christos branches: 1.18.4; 1.18.6; 1.18.8; 1.18.10; 1.18.12;
merge ktrace-lwp.
 1.17 28-Aug-2004  thorpej branches: 1.17.12;
Use ANSI function decls and static.
 1.16 04-Dec-2003  atatat Dynamic sysctl.

Gone are the old kern_sysctl(), cpu_sysctl(), hw_sysctl(),
vfs_sysctl(), etc, routines, along with sysctl_int() et al. Now all
nodes are registered with the tree, and nodes can be added (or
removed) easily, and I/O to and from the tree is handled generically.

Since the nodes are registered with the tree, the mapping from name to
number (and back again) can now be discovered, instead of having to be
hard coded. Adding new nodes to the tree is likewise much simpler --
the new infrastructure handles almost all the work for simple types,
and just about anything else can be done with a small helper function.

All existing nodes are where they were before (numerically speaking),
so all existing consumers of sysctl information should notice no
difference.

PS - I'm sorry, but there's a distinct lack of documentation at the
moment. I'm working on sysctl(3/8/9) right now, and I promise to
watch out for buses.
 1.15 08-Oct-2003  thorpej * Shuffle some data structures so, and add a flags word to ksiginfo_t.
Right now the only flag is used to indicate if a ksiginfo_t is a
result of a trap. Add a predicate macro to test for this flag.
* Add initialization macros for ksiginfo_t's.
* Add accssor macro for ksi_trap. Expands to 0 if the ksiginfo_t was
not the result of a trap. This matches the sigcontext trapcode semantics.
* In kpsendsig(), use KSI_TRAP_P() to select the lwp that gets the signal.
Inspired by Matthias Drochner's fix to kpsendsig(), but correctly handles
the case of non-trap-generated signals that have a > 0 si_code.

This patch fixes a signal delivery problem with threaded programs noted by
Matthias Drochner on tech-kern.

As discussed on tech-kern. Reviewed and OK's by Christos.
 1.14 25-Sep-2003  christos constify siginfo/trapsignal
 1.13 22-Sep-2003  cl SA_SIGINFO support for m68k (compat svr4)
 1.12 15-Jul-2003  lukem __KERNEL_RCSID()
 1.11 29-Jun-2003  fvdl branches: 1.11.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.10 29-Jun-2003  thorpej Adapt to ktrace/lwp changes.
 1.9 17-Jan-2003  thorpej Merge the nathanw_sa branch.
 1.8 04-Jul-2002  thorpej Add kernel support for having userland provide the signal trampoline:

* struct sigacts gets a new sigact_sigdesc structure, which has the
sigaction and the trampoline/version. Version 0 means "legacy kernel
provided trampoline". Other versions are coordinated with machine-
dependent code in libc.
* sigaction1() grows two more arguments -- the trampoline pointer and
the trampoline version.
* A new __sigaction_sigtramp() system call is provided to register a
trampoline along with a signal handler.
* The handler is no longer passed to sensig() functions. Instead,
sendsig() looks up the handler by peeking in the sigacts for the
process getting the signal (since it has to look in there for the
trampoline anyway).
* Native sendsig() functions now select the appropriate trampoline and
its arguments based on the trampoline version in the sigacts.

Changes to libc to use the new facility will be checked in later. Kernel
version not bumped; we will ride the 1.6C bump made recently.
 1.7 31-Mar-2002  christos branches: 1.7.2;
compat signal array renaming.
 1.6 04-Feb-2001  jmc branches: 1.6.4; 1.6.8;
Back out last change. m68k.h is now in cpu.h (which got updated in between
my noticing this problem here on a sun3).
 1.5 04-Feb-2001  jmc Include m68k/m68k.h to pickup definition for fputype.
 1.4 22-Dec-2000  jdolecek split off thread specific stuff from struct sigacts to struct sigctx, leaving
only signal handler array sharable between threads
move other random signal stuff from struct proc to struct sigctx

This addresses kern/10981 by Matthew Orgass.
 1.3 29-Jun-2000  mrg remove include of <vm/vm.h>. <vm/vm.h> -> <uvm/uvm_extern.h>
 1.2 23-Sep-1999  frueauf branches: 1.2.2;
add missing #include <compat/svr4/svr4_lwp.h>. Ok'd by Klaus Klein.
 1.1 19-Apr-1999  kleink branches: 1.1.2;
Add COMPAT_SVR4 for m68k.
 1.1.2.1 21-Jun-1999  thorpej Sync w/ -current.
 1.2.2.2 05-Jan-2001  bouyer Sync with HEAD
 1.2.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.6.8.7 01-Aug-2002  nathanw Catch up to -current.
 1.6.8.6 12-Jul-2002  nathanw No longer need to pull in lwp.h; proc.h pulls it in for us.
 1.6.8.5 24-Jun-2002  nathanw Curproc->curlwp renaming.

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

"curproc" is now #defined in proc.h as ((curlwp) ? (curlwp)->l_proc) : NULL)
so that it is always safe to reference curproc (*de*referencing curproc
is another story, but that's always been true).
 1.6.8.4 29-May-2002  nathanw #include <sys/sa.h> before <sys/syscallargs.h>, to provide sa_upcall_t
now that <sys/param.h> doesn't include <sys/sa.h>.

(Behold the Power of Ed)
 1.6.8.3 17-Apr-2002  nathanw Catch up to -current.
 1.6.8.2 17-Nov-2001  scw Drop the 3rd parameter to svr4_getcontext().
 1.6.8.1 17-Nov-2001  scw Kernel support for Scheduler Activations on m68k-based ports using
mvme68k as a testbed.

Boots multi-user on an mvme162, although userland support for SA is not
yet integrated/tested.
 1.6.4.2 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.6.4.1 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.7.2.1 16-Jul-2002  gehenna catch up with -current.
 1.11.2.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.11.2.3 18-Sep-2004  skrll Sync with HEAD.
 1.11.2.2 03-Sep-2004  skrll Sync with HEAD
 1.11.2.1 03-Aug-2004  skrll Sync with HEAD
 1.17.12.5 21-Jan-2008  yamt sync with head
 1.17.12.4 03-Sep-2007  yamt sync with head.
 1.17.12.3 26-Feb-2007  yamt sync with head.
 1.17.12.2 30-Dec-2006  yamt sync with head.
 1.17.12.1 21-Jun-2006  yamt sync with head.
 1.18.12.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.18.10.3 13-May-2006  elad sprinkle some #include <sys/kauth.h> in files that use kauth kpi but
don't include it yet. hopefully this will prevent some fallout.
 1.18.10.2 10-Mar-2006  elad generic_authorize() -> kauth_authorize_generic().
 1.18.10.1 08-Mar-2006  elad Adapt to kernel authorization KPI.

I expect *some* lossage here...
 1.18.8.2 11-Aug-2006  yamt sync with head
 1.18.8.1 24-May-2006  yamt sync with head.
 1.18.6.1 01-Jun-2006  kardel Sync with head.
 1.18.4.1 09-Sep-2006  rpaulo sync with head
 1.22.4.3 06-Feb-2007  ad Make amiga & mac68k compile.
 1.22.4.2 30-Jan-2007  ad Remove support for SA. Ok core@.
 1.22.4.1 12-Jan-2007  ad Sync with head.
 1.24.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.25.32.2 10-Jan-2008  bouyer Sync with HEAD
 1.25.32.1 02-Jan-2008  bouyer Sync with HEAD
 1.25.28.1 26-Dec-2007  ad Sync with head.
 1.25.26.1 18-Feb-2008  mjf Sync with HEAD.
 1.25.20.2 23-Mar-2008  matt sync with HEAD
 1.25.20.1 09-Jan-2008  matt sync with HEAD
 1.27.8.1 18-May-2008  yamt sync with head.
 1.27.6.2 17-Jan-2009  mjf Sync with HEAD.
 1.27.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.28.2.3 11-Mar-2010  yamt sync with head
 1.28.2.2 04-May-2009  yamt sync with head.
 1.28.2.1 16-May-2008  yamt sync with head.
 1.29.8.1 19-Jan-2009  skrll Sync with HEAD.
 1.29.6.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.29.2.3 14-May-2008  wrstuden Per discussion with ad at n dot o, revert signal mask handling
changes.

The l_sigstk changes are most likely totally un-needed as SA will
never use a signal stack - we send an upcall (or will as other
diffs are brought in).

The l_sigmask changes were too controvertial. In all honesty, I
think it's probably best to revert them. The main reason they were
there is the fact that in an SA process, we don't mask signals per
kernel thread, we mask them per user thread. In the kernel, we want
them all to get turned into upcalls. Thus the normal state of
l_sigmask in an SA process is for it to always be empty.

While we are in the process of delivering a signal, we want to
temporarily mask a signal (so we don't recursively exhaust our
upcall stacks). However signal delivery is rare (important, but
rare), and delivering back-to-back signals is even rarer. So rather
than cause every user of a signal mask to be prepared for this very
rare case, we will just add a second check later in the signal
delivery code. Said change is not in this diff.

This also un-compensates all of our compatability code for dealing
with SA. SA is a NetBSD-specific thing, so there's no need for
Irix, Linux, Solaris, SVR4 and so on to cope with it.

As previously, everything other than kern_sa.c compiles in i386
GENERIC as of this checkin. I will switch to ALL soon for compile
testing.
 1.29.2.2 14-May-2008  wrstuden Per discussion with ad, remove most of the #include <sys/sa.h> lines
as they were including sa.h just for the type(s) needed for syscallargs.h.

Instead, create a new file, sys/satypes.h, which contains just the
types needed for syscallargs.h. Yes, there's only one now, but that
may change and it's probably more likely to change if it'd be difficult
to handle. :-)

Per discussion with matt at n dot o, add an include of satypes.h to
sigtypes.h. Upcall handlers are kinda signal handlers, and signalling
is the header file that's already included for syscallargs.h that
closest matches SA.

This shaves about 3000 lines off of the diff of the branch relative
to the base. That also represents about 18% of the total before this
checkin.

I think this reduction is very good thing.
 1.29.2.1 10-May-2008  wrstuden Initial checkin of re-adding SA. Everything except kern_sa.c
compiles in GENERIC for i386. This is still a work-in-progress, but
this checkin covers most of the mechanical work (changing signalling
to be able to accomidate SA's process-wide signalling and re-adding
includes of sys/sa.h and savar.h). Subsequent changes will be much
more interesting.

Also, kern_sa.c has received partial cleanup. There's still more
to do, though.
 1.32.16.1 18-Feb-2012  mrg merge to -current.
 1.32.12.1 17-Apr-2012  yamt sync with head
 1.33.48.1 10-Jun-2019  christos Sync with HEAD
 1.33.46.1 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.9 19-Dec-2018  maxv Remove compat_svr4 and compat_svr4_32, as discussed on tech-kern@ recently,
but also as discussed several times in the past.
 1.8 01-Aug-2013  matt branches: 1.8.28; 1.8.30;
Convert to motorola style.
 1.7 08-Feb-2011  rmind branches: 1.7.4; 1.7.14; 1.7.18;
Remove clause 3 (UCB advertising clause) from the University of Utah
copyright. Confirmed by Mike Hibler, mike at cs.utah.edu - thanks!
Also, merge UCB and Utah copyright texts back into one, as they
originally were.

Extra verification by snj@.
 1.6 28-Apr-2008  martin branches: 1.6.22; 1.6.28; 1.6.30;
Remove clause 3 and 4 from TNF licenses
 1.5 11-Dec-2005  christos branches: 1.5.74; 1.5.76; 1.5.78;
merge ktrace-lwp.
 1.4 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.3 13-Dec-2000  kleink branches: 1.3.24;
This code wasn't written in Utah or Berkeley.
 1.2 26-Nov-2000  jdolecek branches: 1.2.2;
make this usable also standalone
 1.1 26-Nov-2000  jdolecek split m68k SunOS and SVR4-specific sigcode.s code to sunos_sigcode.s
and svr4_sigcode.s respectively
adjust individual m68k port's locore.s to include new sigcode files if
appropriate
 1.2.2.3 13-Dec-2000  bouyer Sync with HEAD (for UBC fixes).
 1.2.2.2 08-Dec-2000  bouyer Sync with HEAD.
 1.2.2.1 26-Nov-2000  bouyer file svr4_sigcode.s was added on branch thorpej_scsipi on 2000-12-08 09:28:16 +0000
 1.3.24.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.3.24.2 18-Sep-2004  skrll Sync with HEAD.
 1.3.24.1 03-Aug-2004  skrll Sync with HEAD
 1.5.78.1 16-May-2008  yamt sync with head.
 1.5.76.1 18-May-2008  yamt sync with head.
 1.5.74.1 02-Jun-2008  mjf Sync with HEAD.
 1.6.30.1 17-Feb-2011  bouyer Sync with HEAD
 1.6.28.1 06-Jun-2011  jruoho Sync with HEAD.
 1.6.22.1 05-Mar-2011  rmind sync with head
 1.7.18.1 28-Aug-2013  rmind sync with head
 1.7.14.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.7.4.1 22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.8.30.1 10-Jun-2019  christos Sync with HEAD
 1.8.28.1 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.5 19-Dec-2018  maxv Remove compat_svr4 and compat_svr4_32, as discussed on tech-kern@ recently,
but also as discussed several times in the past.
 1.4 11-Dec-2005  christos branches: 1.4.164; 1.4.166;
merge ktrace-lwp.
 1.3 15-Jul-2003  lukem __KERNEL_RCSID()
 1.2 17-Jan-2003  thorpej branches: 1.2.2;
Merge the nathanw_sa branch.
 1.1 13-Jul-2002  scw branches: 1.1.2; 1.1.4; 1.1.6;
m68k syscall rototill:

- Switch all m68k-based ports over to __HAVE_SYSCALL_INTERN.
- Add systrace glue.
- Define struct mdproc in <m68k/proc.h> instead of <machine/proc.h>.
(They were all defined exactly the same anyway, other than a couple
of the MDP_* flags.)
 1.1.6.2 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.1.6.1 13-Jul-2002  jdolecek file svr4_syscall.c was added on branch kqueue on 2002-09-06 08:36:50 +0000
 1.1.4.2 01-Aug-2002  nathanw Catch up to -current.
 1.1.4.1 13-Jul-2002  nathanw file svr4_syscall.c was added on branch nathanw_sa on 2002-08-01 02:42:19 +0000
 1.1.2.2 16-Jul-2002  gehenna catch up with -current.
 1.1.2.1 13-Jul-2002  gehenna file svr4_syscall.c was added on branch gehenna-devsw on 2002-07-16 08:36:54 +0000
 1.2.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.2.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.2.2.1 03-Aug-2004  skrll Sync with HEAD
 1.4.166.1 10-Jun-2019  christos Sync with HEAD
 1.4.164.1 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.42 03-Apr-2025  nat Revert to previous.

Based on discussion and explaination from isaki@.
 1.41 03-Apr-2025  nat Revert to previous.

Based on information and discussion on source-change-d from isaki@

Many thanks for the explination.

(currently compile tested only).
 1.40 31-Mar-2025  nat Wrap up lc040 compatability nops in a macro.

Also add a comment describing why they are there so they wont be accidently
removed in the future.

Addresses PR port-mac68k/13078.
 1.39 30-Mar-2025  nat Sprinkle nop.

This is the kernel part of addressing the issue with fpu emulation on lc040
cpus.

The idea is that we might be switch from or to an f-line (MMU/FPU Trap)
instruction so prepend a nop to flush the caches.

Addresses part of PR/13078.

The second part to this (patch to binutils/gas) has been submitted upstream
and will be fixed when this part is reviewed and included in our local copy
of binutils or (hopefully) in a later version of binutils from upstream.

See:
https://sourceware.org/pipermail/binutils/2025-March/140270.html
 1.38 31-Oct-2024  isaki Fix indent.
 1.37 17-Jan-2024  thorpej branches: 1.37.2;
cpu_switchto(): No need for the pmap_activate() dance here; it's
already done for us in mi_switch().
 1.36 26-Sep-2023  tsutsui TAB/space cleanup.
 1.35 26-Sep-2023  tsutsui Remove trailing spaces and TABs.
 1.34 08-Jan-2020  skrll oldlwp is always non-NULL in cpu_switchto so remove the test for NULL.
 1.33 02-Oct-2018  mrg branches: 1.33.6;
fix diagnostic build.

XXX: pullup-7, pullup-8.
 1.32 14-Oct-2013  isaki branches: 1.32.28; 1.32.30;
Check whether we have an FPU regardless of FPU_EMULATE option.
It prevents a kernel panic when we don't have an FPU and FPU_EMULATE
option is not set.
Thanks tsutsui@ for advice.
 1.31 07-Sep-2013  chs switch to ELF naming for local labels.
 1.30 01-Aug-2013  matt Convert to motorola style.
 1.29 19-Feb-2012  rmind branches: 1.29.2; 1.29.4;
Remove COMPAT_SA / KERN_SA. Welcome to 6.99.3!
Approved by core@.
 1.28 22-Dec-2011  tsutsui Merge m68881_save() and m68881_restore() (using most common mvme68k ones).
All functions are checked by my eyes, and all GENERIC kernels compile.
 1.27 08-Feb-2011  rmind branches: 1.27.4; 1.27.8;
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.26 14-Jan-2011  rmind branches: 1.26.2; 1.26.4;
Retire struct user, remove sys/user.h inclusions. Note sys/user.h header
as obsolete. Remove USER_TO_UAREA/UAREA_TO_USER macros.

Various #include fixes and review by matt@.
 1.25 07-Jul-2010  chs enable usermode RAS for sun[23] also.
 1.24 06-Jun-2010  mrg fix PR 6724 - convert m68k options to defflag's. this means that
M680[12346] are now available from opt_m68k_arch.h. FPSP meantioned
in the PR has already been fixed, and i could not find any more.

i built these kernels to ensure i did not break their builds:

amiga: GENERIC DRACO
atari: HADES FALCON MILAN-PCIIDE
mac68k: GENERIC
sun2: GENERIC
sun3: GENERIC GENERIC3X
cesfic: attempted GENERIC, does not build due to lack of machine/bus.h
hp300: GENERIC
luna68k: GENERIC
mvme68k: GENERIC
news68k: GENERIC
next68k: GENERIC
x68k: GENERIC
 1.23 10-Dec-2009  rmind branches: 1.23.2; 1.23.4;
Rename L_ADDR to L_PCB and amend some comments accordingly.
 1.22 30-May-2009  martin Do not use lwp_trampoline for cpu_setfunc, we do not want to call
lwp_startup() after a setfunc. Grow a simplified setfunc_trampoline
instead.
 1.21 17-Oct-2007  garbled branches: 1.21.20; 1.21.30; 1.21.36;
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 02-Jun-2007  tsutsui branches: 1.20.10;
Remove another #ifdef PCB_CMAP2 portion.
 1.19 22-May-2007  mhitch Get rid of pcb_cmap2 - it hasn't been used for a long, long time.
 1.18 21-May-2007  tsutsui - update and add some comments for readability
- fix prototype of cpu_switchto(9) in comment
- use %sp@(8) style index rather than 8(%sp)
 1.17 20-May-2007  mhitch Add missing call to lwp_startup() in lwp_trampoline() (which was renamed
from proc_trampoline to match the other ports).

A DIAGNOSTIC kernel will now boot and run. LOCKDEBUG still doesn't work yet.
Also, my amiga no longer loses time.
 1.16 18-May-2007  mhitch Common m68k changes for idlelwp.
 1.15 09-Feb-2007  ad branches: 1.15.6; 1.15.8; 1.15.14;
Merge newlock2 to head.
 1.14 13-May-2006  skrll branches: 1.14.8; 1.14.12; 1.14.14;
Fix some more comments.
 1.13 11-Dec-2005  christos branches: 1.13.4; 1.13.6; 1.13.8; 1.13.12;
merge ktrace-lwp.
 1.12 14-Apr-2005  scw branches: 1.12.2;
In m68k_make_fpu_idle_frame(), replace fmove.x with fmove.d as the former
is not supported natively by the 060's FPU.

Fixes a problem on MVME177 reported by Matt Thomas on port-mvme68k@
 1.11 24-Mar-2004  wiz branches: 1.11.8; 1.11.14;
Move
(c) TNF
line from 4-clause UCB to 3-clause UCB license; in other words,
remove UCB's ad clause from the license TNF grants.
There is no point in TNF demanding that UCB's ad clause be followed
when even UCB doesn't demand it any longer.

Ok'd by board@ and agc@.
 1.10 04-Mar-2004  nathanw Centralize identical copies of proc_trampoline code.

(lots more opportunites here for the bored hacker, such as rei and trap0...)
 1.9 04-Jan-2004  jdolecek Rearrange process exit path to avoid need to free resources from different
process context ('reaper').

From within the exiting process context:
* deactivate pmap and free vmspace while we can still block
* introduce MD cpu_lwp_free() - this cleans all MD-specific context (such
as FPU state), and is the last potentially blocking operation;
all of cpu_wait(), and most of cpu_exit(), is now folded into cpu_lwp_free()
* process is now immediatelly marked as zombie and made available for pickup
by parent; the remaining last lwp continues the exit as fully detached
* MI (rather than MD) code bumps uvmexp.swtch, cpu_exit() is now same
for both 'process' and 'lwp' exit

uvm_lwp_exit() is modified to never block; the u-area memory is now
always just linked to the list of available u-areas. Introduce (blocking)
uvm_uarea_drain(), which is called to release the excessive u-area memory;
this is called by parent within wait4(), or by pagedaemon on memory shortage.
uvm_uarea_free() is now private function within uvm_glue.c.

MD process/lwp exit code now always calls lwp_exit2() immediatelly after
switching away from the exiting lwp.

g/c now unneeded routines and variables, including the reaper kernel thread
 1.8 04-Nov-2003  dsl Remove p_nras from struct proc - use LIST_EMPTY(&p->p_raslist) instead.
Remove p_raslock and rename p_lwplock p_lock (one lock is enough).
Simplify window test when adding a ras and correct test on VM_MAXUSER_ADDRESS.
Avoid unpredictable branch in i386 locore.S
(pad fields left in struct proc to avoid kernel bump)
 1.7 30-Oct-2003  mycroft In the 68010 code, we were reading sched_whichqs wrong...
 1.6 28-Oct-2003  mrg m68k_make_fpu_idle_frame() is not needed/wanted if defined(M68010)
 1.5 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.4 23-Jun-2003  martin branches: 1.4.2;
Make sure to include opt_foo.h if a defflag option FOO is used.
 1.3 05-Mar-2003  jklos Fix from Frederick Bruckman to get current kernels booting again.
 1.2 17-Jan-2003  thorpej Merge the nathanw_sa branch.
 1.1 17-Nov-2001  scw branches: 1.1.2; 1.1.14;
file switch_subr.s was initially added on branch nathanw_sa.
 1.1.14.1 18-Dec-2002  gmcgarry Remove the scheduler semantics from machine-dependent context switch.
 1.1.2.10 17-Jan-2003  lonewolf Fix panic on first pagefault on Amiga
 1.1.2.9 31-Dec-2002  thorpej Rename cpu_preempt() to cpu_switchto(), and make the caller remove the
new process from its run queue before calling cpu_switchto().

While here, make a few cpu_switch() and cpu_switchto() implementations
get the outgoing LWP from the args, rather than looking at the curlwp
variable.
 1.1.2.8 18-Sep-2002  nathanw Rearrange slightly and pass p, not l, to ras_lookup().
 1.1.2.7 17-Sep-2002  nathanw Catch up to -current.
 1.1.2.6 24-Jun-2002  nathanw Curproc->curlwp renaming.

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

"curproc" is now #defined in proc.h as ((curlwp) ? (curlwp)->l_proc) : NULL)
so that it is always safe to reference curproc (*de*referencing curproc
is another story, but that's always been true).
 1.1.2.5 02-Dec-2001  scw Declare m68k_cached_fpu_idle_frame in sig_machdep.c instead of switch_subr.s.
Saves having to update all the genassym.cf's for the sizeof the structure.
 1.1.2.4 02-Dec-2001  scw Add m68k_make_fpu_idle_frame(), which must be called at initialisation
to create a reference FP idle frame. (These are FPU-specific, so can't
be hand-crafted at compile time).

Also, in the m68010 case, redo the code in cpu_switch() which finds the
highest priority process to run.
 1.1.2.3 18-Nov-2001  scw Adapt to work on sun2/sun3/sun3x.
 1.1.2.2 18-Nov-2001  scw Oops, I had the meaning of cpu_switch()'s return value inverted.
 1.1.2.1 17-Nov-2001  scw Kernel support for Scheduler Activations on m68k-based ports using
mvme68k as a testbed.

Boots multi-user on an mvme162, although userland support for SA is not
yet integrated/tested.
 1.4.2.4 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.4.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.4.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.4.2.1 03-Aug-2004  skrll Sync with HEAD
 1.11.14.1 14-Apr-2005  tron Pull up revision 1.12 (requested by scw in ticket #152):
In m68k_make_fpu_idle_frame(), replace fmove.x with fmove.d as the
former is not supported natively by the 060's FPU.
Fixes a problem on MVME177 reported by Matt Thomas on port-mvme68k@
 1.11.8.1 29-Apr-2005  kent sync with -current
 1.12.2.3 03-Sep-2007  yamt sync with head.
 1.12.2.2 26-Feb-2007  yamt sync with head.
 1.12.2.1 21-Jun-2006  yamt sync with head.
 1.13.12.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.13.8.1 24-May-2006  yamt sync with head.
 1.13.6.1 01-Jun-2006  kardel Sync with head.
 1.13.4.1 09-Sep-2006  rpaulo sync with head
 1.14.14.1 04-Jun-2007  wrstuden Update to today's netbsd-4.
 1.14.12.1 30-May-2007  riz Pull up following revision(s) (requested by mhitch in ticket #683):
sys/arch/m68k/m68k/switch_subr.s: revision 1.19
sys/arch/amiga/include/pcb.h: revision 1.15
sys/arch/amiga/amiga/genassym.cf: revision 1.24
Get rid of pcb_cmap2 - it hasn't been used for a long, long time.
 1.14.8.1 30-Jan-2007  ad For now always call sched_unlock_idle/sched_lock_idle. They will be
removed by yamt's cpu_switchto() changes.
 1.15.14.2 26-Jun-2007  garbled Sync with HEAD.
 1.15.14.1 22-May-2007  matt Update to HEAD.
 1.15.8.1 11-Jul-2007  mjf Sync with head.
 1.15.6.2 09-Jun-2007  ad Sync with head.
 1.15.6.1 27-May-2007  ad Sync with head.
 1.20.10.1 06-Nov-2007  matt sync with HEAD
 1.21.36.1 05-Jun-2009  snj branches: 1.21.36.1.2;
Pull up following revision(s) (requested by martin in ticket #787):
sys/arch/m68k/include/m68k.h: revision 1.14
sys/arch/m68k/m68k/switch_subr.s: revision 1.22
sys/arch/m68k/m68k/vm_machdep.c: revision 1.28
Do not use lwp_trampoline for cpu_setfunc, we do not want to call
lwp_startup() after a setfunc. Grow a simplified setfunc_trampoline
instead.
 1.21.36.1.2.1 21-Apr-2010  matt sync to netbsd-5
 1.21.30.1 05-Jun-2009  snj Pull up following revision(s) (requested by martin in ticket #787):
sys/arch/m68k/include/m68k.h: revision 1.14
sys/arch/m68k/m68k/switch_subr.s: revision 1.22
sys/arch/m68k/m68k/vm_machdep.c: revision 1.28
Do not use lwp_trampoline for cpu_setfunc, we do not want to call
lwp_startup() after a setfunc. Grow a simplified setfunc_trampoline
instead.
 1.21.20.3 11-Aug-2010  yamt sync with head.
 1.21.20.2 11-Mar-2010  yamt sync with head
 1.21.20.1 20-Jun-2009  yamt sync with head
 1.23.4.2 05-Mar-2011  rmind sync with head
 1.23.4.1 03-Jul-2010  rmind sync with head
 1.23.2.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.26.4.1 17-Feb-2011  bouyer Sync with HEAD
 1.26.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.27.8.2 24-Feb-2012  mrg sync to -current.
 1.27.8.1 18-Feb-2012  mrg merge to -current.
 1.27.4.2 22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.27.4.1 17-Apr-2012  yamt sync with head
 1.29.4.2 18-May-2014  rmind sync with head
 1.29.4.1 28-Aug-2013  rmind sync with head
 1.29.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.32.30.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.32.30.1 10-Jun-2019  christos Sync with HEAD
 1.32.28.1 20-Oct-2018  pgoyette Sync with head
 1.33.6.1 17-Jan-2020  ad Sync with head.
 1.37.2.1 02-Aug-2025  perseant Sync with HEAD
 1.16 11-Apr-2019  kamil Fix CVS Id usage
 1.15 06-Jun-2010  mrg branches: 1.15.60;
fix PR 6724 - convert m68k options to defflag's. this means that
M680[12346] are now available from opt_m68k_arch.h. FPSP meantioned
in the PR has already been fixed, and i could not find any more.

i built these kernels to ensure i did not break their builds:

amiga: GENERIC DRACO
atari: HADES FALCON MILAN-PCIIDE
mac68k: GENERIC
sun2: GENERIC
sun3: GENERIC GENERIC3X
cesfic: attempted GENERIC, does not build due to lack of machine/bus.h
hp300: GENERIC
luna68k: GENERIC
mvme68k: GENERIC
news68k: GENERIC
next68k: GENERIC
x68k: GENERIC
 1.14 31-Dec-2007  ad branches: 1.14.10; 1.14.12; 1.14.30; 1.14.32;
Remove COMPAT_HPUX.
 1.13 20-Dec-2007  dsl Convert all the system call entry points from:
int foo(struct lwp *l, void *v, register_t *retval)
to:
int foo(struct lwp *l, const struct foo_args *uap, register_t *retval)
Fixup compat code to not write into 'uap' and (in some cases) to actually
pass a correctly formatted 'uap' structure with the right name to the
next routine.
A few 'compat' routines that just call standard ones have been deleted.
All the 'compat' code compiles (along with the kernels required to test
build it).
98% done by automated scripts.
 1.12 05-Mar-2007  he branches: 1.12.20; 1.12.26; 1.12.28; 1.12.32;
Cast to char* before doing pointer arithmetic.
 1.11 04-Mar-2007  christos Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.10 22-Feb-2007  thorpej TRUE -> true, FALSE -> false
 1.9 21-Feb-2007  thorpej Replace the Mach-derived boolean_t type with the C99 bool type. A
future commit will replace use of TRUE and FALSE with true and false.
 1.8 09-Feb-2007  ad branches: 1.8.2;
Merge newlock2 to head.
 1.7 22-Jul-2006  tsutsui branches: 1.7.4;
KNF and misc cosmetics
 1.6 11-Dec-2005  christos branches: 1.6.4; 1.6.8;
merge ktrace-lwp.
 1.5 28-Aug-2004  thorpej branches: 1.5.12;
Use ANSI function decls and static.
 1.4 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.3 02-Apr-2003  thorpej branches: 1.3.2;
Use PAGE_SIZE rather than NBPG.
 1.2 17-Jan-2003  thorpej Merge the nathanw_sa branch.
 1.1 03-Nov-2002  chs branches: 1.1.2;
use a merged sys_machdep.c for all the motorola-MMU m68k platforms.
 1.1.2.3 13-Nov-2002  skrll LWPify. Taken from the work done on the machine specific files.
 1.1.2.2 11-Nov-2002  nathanw Catch up to -current
 1.1.2.1 03-Nov-2002  nathanw file sys_machdep.c was added on branch nathanw_sa on 2002-11-11 21:59:42 +0000
 1.3.2.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.3.2.3 18-Sep-2004  skrll Sync with HEAD.
 1.3.2.2 03-Sep-2004  skrll Sync with HEAD
 1.3.2.1 03-Aug-2004  skrll Sync with HEAD
 1.5.12.4 21-Jan-2008  yamt sync with head
 1.5.12.3 03-Sep-2007  yamt sync with head.
 1.5.12.2 26-Feb-2007  yamt sync with head.
 1.5.12.1 30-Dec-2006  yamt sync with head.
 1.6.8.1 11-Aug-2006  yamt sync with head
 1.6.4.1 09-Sep-2006  rpaulo sync with head
 1.7.4.1 30-Jan-2007  ad Remove support for SA. Ok core@.
 1.8.2.2 12-Mar-2007  rmind Sync with HEAD.
 1.8.2.1 27-Feb-2007  yamt - sync with head.
- move sched_changepri back to kern_synch.c as it doesn't know PPQ anymore.
 1.12.32.1 02-Jan-2008  bouyer Sync with HEAD
 1.12.28.1 26-Dec-2007  ad Sync with head.
 1.12.26.1 18-Feb-2008  mjf Sync with HEAD.
 1.12.20.1 09-Jan-2008  matt sync with HEAD
 1.14.32.1 03-Jul-2010  rmind sync with head
 1.14.30.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.14.12.2 14-May-2008  wrstuden Per discussion with ad, remove most of the #include <sys/sa.h> lines
as they were including sa.h just for the type(s) needed for syscallargs.h.

Instead, create a new file, sys/satypes.h, which contains just the
types needed for syscallargs.h. Yes, there's only one now, but that
may change and it's probably more likely to change if it'd be difficult
to handle. :-)

Per discussion with matt at n dot o, add an include of satypes.h to
sigtypes.h. Upcall handlers are kinda signal handlers, and signalling
is the header file that's already included for syscallargs.h that
closest matches SA.

This shaves about 3000 lines off of the diff of the branch relative
to the base. That also represents about 18% of the total before this
checkin.

I think this reduction is very good thing.
 1.14.12.1 10-May-2008  wrstuden Initial checkin of re-adding SA. Everything except kern_sa.c
compiles in GENERIC for i386. This is still a work-in-progress, but
this checkin covers most of the mechanical work (changing signalling
to be able to accomidate SA's process-wide signalling and re-adding
includes of sys/sa.h and savar.h). Subsequent changes will be much
more interesting.

Also, kern_sa.c has received partial cleanup. There's still more
to do, though.
 1.14.10.1 11-Aug-2010  yamt sync with head.
 1.15.60.1 10-Jun-2019  christos Sync with HEAD
 1.17 31-Oct-2024  isaki Fix indent.
 1.16 26-Sep-2023  tsutsui branches: 1.16.6;
Remove trailing spaces and TABs.
 1.15 01-Aug-2013  matt Convert to motorola style.
 1.14 08-Feb-2011  rmind branches: 1.14.4; 1.14.14; 1.14.18;
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.13 17-Oct-2007  garbled branches: 1.13.42; 1.13.48; 1.13.50;
Merge the ppcoea-renovation branch to HEAD.

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

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

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.12 12-Jun-2007  mhitch branches: 1.12.10;
Pass a frame pointer to trap() rather than the 'entire frame' trick. Gcc4
was optimizing away modifications to the frame contents (it's not nice to
trick gcc). Pass the pointer as the first argument to reduce the number
of places that would be changed otherwise. Fixes the getcwd regression
test on most m68k ports.
 1.11 11-Dec-2005  christos branches: 1.11.24; 1.11.30; 1.11.32; 1.11.38; 1.11.40;
merge ktrace-lwp.
 1.10 22-Sep-2003  cl branches: 1.10.16;
SA_SIGINFO support for m68k
 1.9 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.8 23-Jun-2003  martin branches: 1.8.2;
Make sure to include opt_foo.h if a defflag option FOO is used.
 1.7 26-Nov-2001  fredette COMPAT_SUNOS requires the 1.3 sigreturn code, so include it
even if COMPAT_13 isn't defined.
 1.6 10-Nov-1999  thorpej branches: 1.6.8; 1.6.12;
Add register prefixes.
 1.5 05-Oct-1998  thorpej branches: 1.5.12; 1.5.14; 1.5.18;
Fix a problem reported by Michael Hitch. Basically, our libc relies on the
non-standard way of invoking sigreturn, specifically a side-effect that I
overlooked. Thus, longjmp's return value was getting clobbered.

Sigh, so burn trap #3 just as sigreturn.

XXX We need an SVR4-style {get,set}context(2) to avoid wasting new
XXX trap vectors in the future.
 1.4 02-Oct-1998  thorpej Oops, missing immediate qualifier, pointed out by Chas Williams.
 1.3 30-Sep-1998  thorpej Move trap #1 and trap #2 handlers here. Trap #1 handler now places
the cpmpat_13_sigreturn13 syscall number into d0 before calling the
sigreturn stub.
 1.2 04-Jun-1997  is Reorganize buserr/addrerr stuff, to allow omitting unused code in single-cpu
kernels, at the same time getting rid of up to 3 conditional branches and a
bit over one cacheline fetch (for the 68060; the saving is a bit smaller for
040 and yet smaller for the 020/30).
While we're here, also get rid of an redundant lea (using SP-relative
addressing) and of two redundant pushes.
While we're here, also fix a panic which would tear us down on 68060 machines
if a branch prediction error ever occured.
 1.1 25-Apr-1997  thorpej Add several common trap vector stubs. Not all of them are here (yet),
but several are.
 1.5.18.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.5.14.1 15-Nov-1999  fvdl Sync with -current
 1.5.12.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.6.12.1 08-Jan-2002  nathanw Catch up to -current.
 1.6.8.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.8.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.8.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.8.2.1 03-Aug-2004  skrll Sync with HEAD
 1.10.16.1 03-Sep-2007  yamt sync with head.
 1.11.40.1 03-Sep-2007  wrstuden Sync w/ NetBSD-4-RC_1
 1.11.38.1 26-Jun-2007  garbled Sync with HEAD.
 1.11.32.1 11-Jul-2007  mjf Sync with head.
 1.11.30.1 15-Jul-2007  ad Sync with head.
 1.11.24.1 18-Jun-2007  liamjfoy Pull up following revision(s) (requested by mhitch in ticket #728):
sys/arch/mvme68k/mvme68k/locore.s: revision 1.98
sys/arch/mac68k/mac68k/trap.c: revision 1.128
sys/arch/next68k/next68k/locore.s: revision 1.48
sys/arch/mac68k/mac68k/locore.s: revision 1.152
sys/arch/sun3/sun3/locore.s: revision 1.88
sys/arch/sun2/sun2/locore.s: revision 1.19
sys/arch/sun2/sun2/trap.c: revision 1.32
sys/arch/m68k/m68k/db_trace.c: revision 1.51
sys/arch/mvme68k/mvme68k/trap.c: revision 1.90
sys/arch/news68k/news68k/trap.c: revision 1.53
sys/arch/luna68k/luna68k/locore.s: revision 1.27
sys/arch/atari/atari/locore.s: revision 1.99
sys/arch/sun3/sun3/trap.c: revision 1.130
sys/arch/x68k/x68k/trap.c: revision 1.89
sys/arch/next68k/next68k/trap.c: revision 1.67
sys/arch/x68k/x68k/locore.s: revision 1.79
sys/arch/news68k/news68k/locore.s: revision 1.43
sys/arch/luna68k/luna68k/trap.c: revision 1.46
sys/arch/hp300/hp300/locore.s: revision 1.140
sys/arch/cesfic/cesfic/locore.s: revision 1.15
sys/arch/cesfic/cesfic/trap.c: revision 1.35
sys/arch/m68k/m68k/trap_subr.s: revision 1.12
sys/arch/amiga/amiga/locore.s: revision 1.143
Pass a frame pointer to trap() rather than the 'entire frame' trick. Gcc4
was optimizing away modifications to the frame contents (it's not nice to
trick gcc). Pass the pointer as the first argument to reduce the number
of places that would be changed otherwise. Fixes the getcwd regression
test on most m68k ports.
 1.12.10.1 06-Nov-2007  matt sync with HEAD
 1.13.50.1 17-Feb-2011  bouyer Sync with HEAD
 1.13.48.1 06-Jun-2011  jruoho Sync with HEAD.
 1.13.42.1 05-Mar-2011  rmind sync with head
 1.14.18.1 28-Aug-2013  rmind sync with head
 1.14.14.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.14.4.1 22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.16.6.1 02-Aug-2025  perseant Sync with HEAD
 1.3 13-Jan-2024  thorpej Expose saved_vbr directly.
 1.2 13-Jan-2024  thorpej Provide some vector table override hooks and interfaces needed by the
sun68k platforms.
 1.1 13-Jan-2024  thorpej Add a common vector table implementation for m68k platforms.
 1.43 19-Jan-2024  thorpej Move physaccess(), physunaccess(), and kvtop() from vm_machdep.c to
pmap_motorola.c. They're legacy functions tied to that pmap implementation.
 1.42 31-Dec-2023  thorpej Provide a vtophys() function like other platforms do, and implement
kvtop() (which will be g/c'd shortly) in terms of it.
 1.41 20-Dec-2023  thorpej Remove unnecessary <sys/malloc.h> include.
 1.40 26-Sep-2023  tsutsui TAB/space cleanup.
 1.39 25-Oct-2013  martin Mark a potentially unused variable
 1.38 19-Feb-2012  rmind branches: 1.38.2; 1.38.4;
Remove COMPAT_SA / KERN_SA. Welcome to 6.99.3!
Approved by core@.
 1.37 10-Feb-2011  pooka branches: 1.37.4; 1.37.8;
Make vmapbuf() return success/error and make physio deal with a
failure.
 1.36 08-Feb-2011  rmind Remove clause 3 (UCB advertising clause) from the University of Utah
copyright. Confirmed by Mike Hibler, mike at cs.utah.edu - thanks!
Also, merge UCB and Utah copyright texts back into one, as they
originally were.

Extra verification by snj@.
 1.35 14-Jan-2011  rmind branches: 1.35.2; 1.35.4;
Retire struct user, remove sys/user.h inclusions. Note sys/user.h header
as obsolete. Remove USER_TO_UAREA/UAREA_TO_USER macros.

Various #include fixes and review by matt@.
 1.34 19-Dec-2009  tsutsui branches: 1.34.4;
Move declaration of setfunc_trampoline() into <m68k/m68k.h>.
 1.33 19-Dec-2009  tsutsui Move declaration of lwp_trampoline() into <m68k/m68k.h>.
 1.32 19-Dec-2009  tsutsui Remove extern struct pcb *curpcb declaration. Now it's in <m68k/pcb.h>.
 1.31 29-Nov-2009  rmind Replace l_addr with uvm_lwp_getuarea() in various MD code, mostly cpu_lwp_fork().
 1.30 23-Nov-2009  rmind Use lwp_getpcb() on m68k ports, clean from struct user usage.
 1.29 07-Nov-2009  cegger Add a flags argument to pmap_kenter_pa(9).
Patch showed on tech-kern@ http://mail-index.netbsd.org/tech-kern/2009/11/04/msg006434.html
No objections.
 1.28 30-May-2009  martin Do not use lwp_trampoline for cpu_setfunc, we do not want to call
lwp_startup() after a setfunc. Grow a simplified setfunc_trampoline
instead.
 1.27 19-Nov-2008  ad Make the emulations, exec formats, coredump, NFS, and the NFS server
into modules. By and large this commit:

- shuffles header files and ifdefs
- splits code out where necessary to be modular
- adds module glue for each of the components
- adds/replaces hooks for things that can be installed at runtime
 1.26 17-Oct-2007  garbled branches: 1.26.16; 1.26.20; 1.26.26; 1.26.28; 1.26.30; 1.26.32;
Merge the ppcoea-renovation branch to HEAD.

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

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

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.25 26-May-2007  tsutsui branches: 1.25.10;
Use consistent cast.
 1.24 21-May-2007  tsutsui Remove a local declaration of lwp_trampoline().
 1.23 20-May-2007  mhitch Add missing call to lwp_startup() in lwp_trampoline() (which was renamed
from proc_trampoline to match the other ports).

A DIAGNOSTIC kernel will now boot and run. LOCKDEBUG still doesn't work yet.
Also, my amiga no longer loses time.
 1.22 19-May-2007  mhitch Spelling error, I should be old enough to know better.
 1.21 18-May-2007  mhitch Common m68k changes for idlelwp.
 1.20 04-Mar-2007  christos branches: 1.20.2; 1.20.4; 1.20.10;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.19 22-Feb-2007  thorpej TRUE -> true, FALSE -> false
 1.18 15-Feb-2007  mhitch branches: 1.18.2;
Kernel threads were running at splhigh on m68k systems because the status
register was inherited from proc0. Set the new process's status register
to PSL_LOWIPL. Raidframe reconstruction no longer causes my Amiga to lose
time.
 1.17 09-Feb-2007  ad Merge newlock2 to head.
 1.16 31-Aug-2006  matt branches: 1.16.2; 1.16.6;
Make cpu_coredump dependent on COREDUMP
 1.15 22-Jul-2006  tsutsui TAB/space cleanup.
 1.14 22-Jul-2006  tsutsui - remove parentheses from return
- remove trailing spaces
 1.13 11-Dec-2005  christos branches: 1.13.4; 1.13.8;
merge ktrace-lwp.
 1.12 10-Jun-2005  matt branches: 1.12.2;
Rework the coredump code to have no explicit knownledge of how coredump
i/o is done. Instead, pass an opaque cookie which is then passed to a
new routine, coredump_write, which does the actual i/o. This allows the
method of doing i/o to change without affecting any future MD code.
Also, make netbsd32_core.c [re]use core_netbsd.c (in a similar manner that
core_elf64.c uses core_elf32.c) and eliminate that code duplication.
cpu_coredump{,32} is now called twice, first with a NULL iocookie to fill
the core structure and a second to actually write md parts of the coredump.
All i/o is nolonger random access and is suitable for shipping over a stream.
 1.11 01-Apr-2005  yamt merge yamt-km branch.
- don't use managed mappings/backing objects for wired memory allocations.
save some resources like pv_entry. also fix (most of) PR/27030.
- simplify kernel memory management API.
- simplify pmap bootstrap of some ports.
- some related cleanups.
 1.10 17-Sep-2004  skrll branches: 1.10.4; 1.10.6;
There's no need to pass a proc value when using UIO_SYSSPACE with
vn_rdwr(9) and uiomove(9).

OK'd by Jason Thorpe
 1.9 28-Aug-2004  thorpej Garbage-collect pagemove(); nothing use it anymore (YAY!!!)
 1.8 28-Aug-2004  thorpej Use ANSI function decls and static.
 1.7 04-Jan-2004  jdolecek Rearrange process exit path to avoid need to free resources from different
process context ('reaper').

From within the exiting process context:
* deactivate pmap and free vmspace while we can still block
* introduce MD cpu_lwp_free() - this cleans all MD-specific context (such
as FPU state), and is the last potentially blocking operation;
all of cpu_wait(), and most of cpu_exit(), is now folded into cpu_lwp_free()
* process is now immediatelly marked as zombie and made available for pickup
by parent; the remaining last lwp continues the exit as fully detached
* MI (rather than MD) code bumps uvmexp.swtch, cpu_exit() is now same
for both 'process' and 'lwp' exit

uvm_lwp_exit() is modified to never block; the u-area memory is now
always just linked to the list of available u-areas. Introduce (blocking)
uvm_uarea_drain(), which is called to release the excessive u-area memory;
this is called by parent within wait4(), or by pagedaemon on memory shortage.
uvm_uarea_free() is now private function within uvm_glue.c.

MD process/lwp exit code now always calls lwp_exit2() immediatelly after
switching away from the exiting lwp.

g/c now unneeded routines and variables, including the reaper kernel thread
 1.6 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.5 29-Jun-2003  fvdl branches: 1.5.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.4 29-Jun-2003  thorpej Adapt to ktrace/lwp changes.
 1.3 02-Apr-2003  thorpej Use PAGE_SIZE rather than NBPG.
 1.2 17-Jan-2003  thorpej Merge the nathanw_sa branch.
 1.1 20-Oct-2002  chs branches: 1.1.2;
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.1.2.4 03-Dec-2002  gmcgarry Lost cpu_proc_fork() for hp300 during merge from current.
It comes back and all m68k ports will use it.
 1.1.2.3 13-Nov-2002  skrll LWPify. Taken from the work done on the machine specific files.
 1.1.2.2 11-Nov-2002  nathanw Catch up to -current
 1.1.2.1 20-Oct-2002  nathanw file vm_machdep.c was added on branch nathanw_sa on 2002-11-11 21:59:43 +0000
 1.5.2.6 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.5.2.5 01-Apr-2005  skrll Sync with HEAD.
 1.5.2.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.5.2.3 18-Sep-2004  skrll Sync with HEAD.
 1.5.2.2 03-Sep-2004  skrll Sync with HEAD
 1.5.2.1 03-Aug-2004  skrll Sync with HEAD
 1.10.6.1 26-Jan-2005  yamt convert arch/m68k to new apis.
 1.10.4.1 29-Apr-2005  kent sync with -current
 1.12.2.3 03-Sep-2007  yamt sync with head.
 1.12.2.2 26-Feb-2007  yamt sync with head.
 1.12.2.1 30-Dec-2006  yamt sync with head.
 1.13.8.2 03-Sep-2006  yamt sync with head.
 1.13.8.1 11-Aug-2006  yamt sync with head
 1.13.4.1 09-Sep-2006  rpaulo sync with head
 1.16.6.1 10-Mar-2007  bouyer Pull up following revision(s) (requested by mhitch in ticket #498):
sys/arch/m68k/m68k/vm_machdep.c: revision 1.18
Kernel threads were running at splhigh on m68k systems because the status
register was inherited from proc0. Set the new process's status register
to PSL_LOWIPL. Raidframe reconstruction no longer causes my Amiga to lose
time.
 1.16.2.1 06-Feb-2007  ad Make amiga & mac68k compile.
 1.18.2.2 12-Mar-2007  rmind Sync with HEAD.
 1.18.2.1 27-Feb-2007  yamt - sync with head.
- move sched_changepri back to kern_synch.c as it doesn't know PPQ anymore.
 1.20.10.2 26-Jun-2007  garbled Sync with HEAD.
 1.20.10.1 22-May-2007  matt Update to HEAD.
 1.20.4.1 11-Jul-2007  mjf Sync with head.
 1.20.2.1 27-May-2007  ad Sync with head.
 1.25.10.1 06-Nov-2007  matt sync with HEAD
 1.26.32.1 05-Jun-2009  snj branches: 1.26.32.1.2;
Pull up following revision(s) (requested by martin in ticket #787):
sys/arch/m68k/include/m68k.h: revision 1.14
sys/arch/m68k/m68k/switch_subr.s: revision 1.22
sys/arch/m68k/m68k/vm_machdep.c: revision 1.28
Do not use lwp_trampoline for cpu_setfunc, we do not want to call
lwp_startup() after a setfunc. Grow a simplified setfunc_trampoline
instead.
 1.26.32.1.2.1 21-Apr-2010  matt sync to netbsd-5
 1.26.30.1 05-Jun-2009  snj Pull up following revision(s) (requested by martin in ticket #787):
sys/arch/m68k/include/m68k.h: revision 1.14
sys/arch/m68k/m68k/switch_subr.s: revision 1.22
sys/arch/m68k/m68k/vm_machdep.c: revision 1.28
Do not use lwp_trampoline for cpu_setfunc, we do not want to call
lwp_startup() after a setfunc. Grow a simplified setfunc_trampoline
instead.
 1.26.28.1 19-Jan-2009  skrll Sync with HEAD.
 1.26.26.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.26.20.3 11-Mar-2010  yamt sync with head
 1.26.20.2 20-Jun-2009  yamt sync with head
 1.26.20.1 04-May-2009  yamt sync with head.
 1.26.16.1 17-Jan-2009  mjf Sync with HEAD.
 1.34.4.1 05-Mar-2011  rmind sync with head
 1.35.4.1 17-Feb-2011  bouyer Sync with HEAD
 1.35.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.37.8.1 24-Feb-2012  mrg sync to -current.
 1.37.4.2 22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.37.4.1 17-Apr-2012  yamt sync with head
 1.38.4.1 18-May-2014  rmind sync with head
 1.38.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.4 26-Sep-2023  tsutsui Remove trailing spaces and TABs.
 1.3 01-Aug-2013  matt Convert to motorola style.
 1.2 28-Apr-2008  martin branches: 1.2.34; 1.2.44; 1.2.50;
Remove clause 3 and 4 from TNF licenses
 1.1 14-Jun-2001  fredette branches: 1.1.2; 1.1.10; 1.1.128; 1.1.130; 1.1.132;
Added two functions that zero memory and copy memory
in an optimized fashion using only properly aligned
8- and 16-bit accesses.
 1.1.132.1 16-May-2008  yamt sync with head.
 1.1.130.1 18-May-2008  yamt sync with head.
 1.1.128.1 02-Jun-2008  mjf Sync with HEAD.
 1.1.10.2 14-Jun-2001  fredette Added two functions that zero memory and copy memory
in an optimized fashion using only properly aligned
8- and 16-bit accesses.
 1.1.10.1 14-Jun-2001  fredette file w16copy.s was added on branch nathanw_sa on 2001-06-14 15:38:17 +0000
 1.1.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.2.50.1 28-Aug-2013  rmind sync with head
 1.2.44.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.2.34.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")

RSS XML Feed