Home | History | Annotate | only in /src/sys/arch/sh3
History log of /src/sys/arch/sh3
RevisionDateAuthorComments
 1.2 24-Feb-2002  uch branches: 1.2.12;
clean up Makefiles
 1.1 13-Sep-1999  itojun branches: 1.1.16;
Merge in NetBSD/sh3 from cvs.kame.net repository.

Tree structure:
- sys/arch/sh3: sh3 generic code
As commented, in-chip device drivers are put into sys/arch/sh3/dev.
- sys/arch/evbsh3: sh3 evaluation boards (pure sh3 CPU, no fancy external HW)
- sys/arch/mmeye: Brains mmEye, www.brains.co.jp
MI source code includes couple of #ifdef for sh3-coff support.
(sh3 uses coff or elf)

Needs some more improvements, especialy in sys/arch/sh3/conf/files.sh3,
to compile the tree (due to last minute tree structure change).
 1.1.16.1 16-Mar-2002  jdolecek Catch up with -current.
 1.2.12.2 24-Feb-2002  uch clean up Makefiles
 1.2.12.1 24-Feb-2002  uch file Makefile was added on branch nathanw_sa on 2002-02-24 20:10:54 +0000
 1.1 24-Feb-2002  uch branches: 1.1.2; 1.1.8; 1.1.16;
Move common exception vector and scheduler code to
sh3/sh3/exception_vector.S and sh3/sh3/locore_subr.S. exception
vectors are installed by sh_cpu_init(). machine/locore.S contains
kernel entry, interrupt handler, and some MD code.
 1.1.16.2 24-Feb-2002  uch Move common exception vector and scheduler code to
sh3/sh3/exception_vector.S and sh3/sh3/locore_subr.S. exception
vectors are installed by sh_cpu_init(). machine/locore.S contains
kernel entry, interrupt handler, and some MD code.
 1.1.16.1 24-Feb-2002  uch file Makefile.inc was added on branch nathanw_sa on 2002-02-24 18:19:44 +0000
 1.1.8.2 16-Mar-2002  jdolecek Catch up with -current.
 1.1.8.1 24-Feb-2002  jdolecek file Makefile.inc was added on branch kqueue on 2002-03-16 15:59:34 +0000
 1.1.2.1 28-Feb-2002  nathanw Catch up to -current.
 1.29 22-Sep-2018  rin - Determine KERN_AS automatically depending on whether OPT_MODULAR is
set or not, in the same way as libcompat.

- Specify OPT_MODULAR in the port Makefile instead of KERN_AS.

Now, KERN_AS=library is used for kernels without module(7) for all ports.

OK christos
 1.28 10-Mar-2013  christos branches: 1.28.36; 1.28.38;
Explicitly set KERN_AS (this could be done in /usr/src/sys/conf/Makefile.*)
so that modules work, on config files that did not set it explicitly. All
the files now use the standard logic, except the ones that set KERN_AS=obj
and Makefile.usermode which sets KERN_AS=library.
 1.27 21-Jan-2011  joerg branches: 1.27.4; 1.27.14;
Switch remaining platforms to modern CPP for assembler.
 1.26 06-May-2008  uwe branches: 1.26.22; 1.26.28; 1.26.30;
Default COPTS to "-Os -freorder-blocks" which is ~= -O2 but without
-falign-* that is too zealous for low-memory sh3 machines. I've been
using this for my hpcsh and landisk kernels for a very long time.
(besides, it's not 2001 anymore and pkgsrc/cross/sh is long since gone).
 1.25 01-Mar-2008  joerg branches: 1.25.2; 1.25.4;
Missing assym.h dependencies.
 1.24 28-Mar-2007  uwe branches: 1.24.14; 1.24.30; 1.24.34;
G/c ancient workaround that has been commented out for ages.
 1.23 02-Sep-2006  uwe branches: 1.23.8; 1.23.12; 1.23.14; 1.23.16;
There's no reason to use -Wno-parentheses.
 1.22 17-Mar-2006  uebayasi Stop using linker scripts on all sh3 ports.

The only information to be compensated is text section start address.
The default value is set arch-wise as DEFTEXTADDR. Each kernel config
can override the default value by setting TEXTADDR.

Tested on COMPUTEXEVB (evbsh3).

Reviewed By: uwe
 1.21 11-Dec-2005  christos branches: 1.21.4; 1.21.6; 1.21.8; 1.21.10; 1.21.12;
merge ktrace-lwp.
 1.20 31-May-2005  christos branches: 1.20.2;
s/GENASSYM/GENASSYM_CONF/ so we can use "GENASSYM" as the program name.
 1.19 04-Jun-2004  thorpej Add the %MAKEOPTIONSAPPEND token at the end of the file, after the
common Makefile.kern.inc has been included.
 1.18 17-Mar-2002  uch branches: 1.18.8; 1.18.14; 1.18.18;
cosmetic changes, fix comments.
 1.17 24-Feb-2002  uch Move common exception vector and scheduler code to
sh3/sh3/exception_vector.S and sh3/sh3/locore_subr.S. exception
vectors are installed by sh_cpu_init(). machine/locore.S contains
kernel entry, interrupt handler, and some MD code.
 1.16 09-Dec-2001  atatat Roll the rest of the ports over to the new MI kernel build machinery.
Any problems reported by testers have been fixed, and massive
cross-compiling of kernels has shown that any problems that remain
with actually building kernels are not related to this.
 1.15 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.14 26-Oct-2001  jmc Change defaults for kernel compiles. Default all to USETOOLS?=no and have
the etc Makefile override that by putting USETOOLS into $.MAKEOVERRIDES
This way the default for kernel compiles is still to use the installed
toolchain instead of depending on $TOOLDIR. $TOOLDIR can be used by
simply adding USETOOLS=yes to the command line as usual.

Adjust each ports template to set the default no setting and also pull in
bsd.own.mk if they weren't already to ensure they'll build correctly
with the new toolchain setup.
 1.13 23-Oct-2001  thorpej branches: 1.13.2;
Use MACHINE, not TARGET_MACHINE.
 1.12 29-May-2001  mrg branches: 1.12.2;
define _KERNEL_OPT as well as _KERNEL. we will use this in the future to
get kernel "opt_foo.h" headers, rather than _KERNEL && !_LKM.
 1.11 24-Mar-2001  matt Use ${THISSH3} instead of ../.. ; not everyone builds in ../compile/FOO
 1.10 22-Jan-2001  tsubai branches: 1.10.2;
-Dsh3 --> -D${TARGET_MACHINE}.
 1.9 04-Jan-2001  itojun use -O1 for now, -O2 dies
 1.8 03-Jan-2001  itojun share sys/arch/sh3/conf/Makefile.sh3 across sh3-based architectures.
cleanup param.h a bit.
 1.7 17-Dec-2000  jdolecek delete obsolete comment
 1.6 09-May-2000  hubertf Add "install" target, so "make install" after building the kernel
does something useful. The target can be redefined by putting a
install-kernel-${MACHINE_NAME} target that fits your needs into
/etc/mk.conf.
 1.5 09-May-2000  thorpej HAVE_GCC28 -> HAVE_EGCS, and make it match gcc 2.9 as well. Also,
make the use of -Wno-uninitialized explicit, don't rely on a compiler
hack to do it for us.
 1.4 01-Feb-2000  tsutsui Revert STRIPPROG -> STRIP
 1.3 24-Jan-2000  tron Add "dependall" target for comfort.
 1.2 19-Jan-2000  tsutsui STRIP -> STRIPPROG
 1.1 13-Sep-1999  itojun branches: 1.1.2;
Merge in NetBSD/sh3 from cvs.kame.net repository.

Tree structure:
- sys/arch/sh3: sh3 generic code
As commented, in-chip device drivers are put into sys/arch/sh3/dev.
- sys/arch/evbsh3: sh3 evaluation boards (pure sh3 CPU, no fancy external HW)
- sys/arch/mmeye: Brains mmEye, www.brains.co.jp
MI source code includes couple of #ifdef for sh3-coff support.
(sh3 uses coff or elf)

Needs some more improvements, especialy in sys/arch/sh3/conf/files.sh3,
to compile the tree (due to last minute tree structure change).
 1.1.2.4 27-Mar-2001  bouyer Sync with HEAD.
 1.1.2.3 11-Feb-2001  bouyer Sync with HEAD.
 1.1.2.2 05-Jan-2001  bouyer Sync with HEAD
 1.1.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.10.2.2 21-Jun-2001  nathanw Catch up to -current.
 1.10.2.1 09-Apr-2001  nathanw Catch up with -current.
 1.12.2.3 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.12.2.2 16-Mar-2002  jdolecek Catch up with -current.
 1.12.2.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.13.2.1 12-Nov-2001  thorpej Sync the thorpej-mips-cache branch with -current.
 1.18.18.1 06-Feb-2005  jmc Pull up patch (requested by martti in ticket #1086)
Move ipf to sys/dist/ipf and sync w. trunk
 1.18.14.4 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.18.14.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.18.14.2 18-Sep-2004  skrll Sync with HEAD.
 1.18.14.1 03-Aug-2004  skrll Sync with HEAD
 1.18.8.2 17-Mar-2002  uch cosmetic changes, fix comments.
 1.18.8.1 17-Mar-2002  uch file Makefile.sh3 was added on branch nathanw_sa on 2002-03-17 17:55:25 +0000
 1.20.2.4 17-Mar-2008  yamt sync with head.
 1.20.2.3 03-Sep-2007  yamt sync with head.
 1.20.2.2 30-Dec-2006  yamt sync with head.
 1.20.2.1 21-Jun-2006  yamt sync with head.
 1.21.12.1 28-Mar-2006  tron Merge 2006-03-28 NetBSD-current into the "peter-altq" branch.
 1.21.10.1 19-Apr-2006  elad sync with head - hopefully this will work
 1.21.8.2 03-Sep-2006  yamt sync with head.
 1.21.8.1 01-Apr-2006  yamt sync with head.
 1.21.6.1 22-Apr-2006  simonb Sync with head.
 1.21.4.1 09-Sep-2006  rpaulo sync with head
 1.23.16.1 29-Mar-2007  reinoud Pullup to -current
 1.23.14.1 11-Jul-2007  mjf Sync with head.
 1.23.12.1 10-Apr-2007  ad Sync with head.
 1.23.8.1 15-Apr-2007  yamt sync with head.
 1.24.34.2 02-Jun-2008  mjf Sync with HEAD.
 1.24.34.1 03-Apr-2008  mjf Sync with HEAD.
 1.24.30.1 24-Mar-2008  keiichi sync with head.
 1.24.14.1 23-Mar-2008  matt sync with HEAD
 1.25.4.1 16-May-2008  yamt sync with head.
 1.25.2.1 18-May-2008  yamt sync with head.
 1.26.30.1 08-Feb-2011  bouyer Sync with HEAD
 1.26.28.1 06-Jun-2011  jruoho Sync with HEAD.
 1.26.22.1 05-Mar-2011  rmind sync with head
 1.27.14.1 23-Jun-2013  tls resync from head
 1.27.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.28.38.1 10-Jun-2019  christos Sync with HEAD
 1.28.36.1 30-Sep-2018  pgoyette Ssync with HEAD
 1.11 24-Feb-2002  uch branches: 1.11.10;
clean up Makefiles
 1.10 09-Dec-2001  atatat Roll the rest of the ports over to the new MI kernel build machinery.
Any problems reported by testers have been fixed, and massive
cross-compiling of kernels has shown that any problems that remain
with actually building kernels are not related to this.
 1.9 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.8 26-Oct-2001  jmc Change defaults for kernel compiles. Default all to USETOOLS?=no and have
the etc Makefile override that by putting USETOOLS into $.MAKEOVERRIDES
This way the default for kernel compiles is still to use the installed
toolchain instead of depending on $TOOLDIR. $TOOLDIR can be used by
simply adding USETOOLS=yes to the command line as usual.

Adjust each ports template to set the default no setting and also pull in
bsd.own.mk if they weren't already to ensure they'll build correctly
with the new toolchain setup.
 1.7 29-May-2001  mrg branches: 1.7.2; 1.7.6;
define _KERNEL_OPT as well as _KERNEL. we will use this in the future to
get kernel "opt_foo.h" headers, rather than _KERNEL && !_LKM.
 1.6 17-Dec-2000  jdolecek branches: 1.6.2;
delete obsolete comment
 1.5 09-May-2000  hubertf Add "install" target, so "make install" after building the kernel
does something useful. The target can be redefined by putting a
install-kernel-${MACHINE_NAME} target that fits your needs into
/etc/mk.conf.
 1.4 01-Feb-2000  tsutsui Revert STRIPPROG -> STRIP
 1.3 24-Jan-2000  tron Add "dependall" target for comfort.
 1.2 19-Jan-2000  tsutsui STRIP -> STRIPPROG
 1.1 13-Sep-1999  itojun branches: 1.1.2;
Merge in NetBSD/sh3 from cvs.kame.net repository.

Tree structure:
- sys/arch/sh3: sh3 generic code
As commented, in-chip device drivers are put into sys/arch/sh3/dev.
- sys/arch/evbsh3: sh3 evaluation boards (pure sh3 CPU, no fancy external HW)
- sys/arch/mmeye: Brains mmEye, www.brains.co.jp
MI source code includes couple of #ifdef for sh3-coff support.
(sh3 uses coff or elf)

Needs some more improvements, especialy in sys/arch/sh3/conf/files.sh3,
to compile the tree (due to last minute tree structure change).
 1.1.2.2 05-Jan-2001  bouyer Sync with HEAD
 1.1.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.6.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.7.6.1 12-Nov-2001  thorpej Sync the thorpej-mips-cache branch with -current.
 1.7.2.2 16-Mar-2002  jdolecek Catch up with -current.
 1.7.2.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.11.10.2 24-Feb-2002  uch clean up Makefiles
 1.11.10.1 24-Feb-2002  uch file Makefile.sh3.be was added on branch nathanw_sa on 2002-02-24 20:10:55 +0000
 1.7 04-Jan-2001  itojun nuke obsolete Makefile templates.
split build-sh3 into two, for sh3e[bl].
 1.6 17-Dec-2000  jdolecek delete obsolete comment
 1.5 09-May-2000  hubertf Add "install" target, so "make install" after building the kernel
does something useful. The target can be redefined by putting a
install-kernel-${MACHINE_NAME} target that fits your needs into
/etc/mk.conf.
 1.4 01-Feb-2000  tsutsui Revert STRIPPROG -> STRIP
 1.3 24-Jan-2000  tron Add "dependall" target for comfort.
 1.2 19-Jan-2000  tsutsui STRIP -> STRIPPROG
 1.1 13-Sep-1999  itojun branches: 1.1.2;
Merge in NetBSD/sh3 from cvs.kame.net repository.

Tree structure:
- sys/arch/sh3: sh3 generic code
As commented, in-chip device drivers are put into sys/arch/sh3/dev.
- sys/arch/evbsh3: sh3 evaluation boards (pure sh3 CPU, no fancy external HW)
- sys/arch/mmeye: Brains mmEye, www.brains.co.jp
MI source code includes couple of #ifdef for sh3-coff support.
(sh3 uses coff or elf)

Needs some more improvements, especialy in sys/arch/sh3/conf/files.sh3,
to compile the tree (due to last minute tree structure change).
 1.1.2.2 05-Jan-2001  bouyer Sync with HEAD
 1.1.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.3 04-Jan-2001  itojun nuke obsolete Makefile templates.
split build-sh3 into two, for sh3e[bl].
 1.2 13-Sep-1999  itojun branches: 1.2.2;
add local def for CXX.
 1.1 13-Sep-1999  itojun Merge in NetBSD/sh3 from cvs.kame.net repository.

Tree structure:
- sys/arch/sh3: sh3 generic code
As commented, in-chip device drivers are put into sys/arch/sh3/dev.
- sys/arch/evbsh3: sh3 evaluation boards (pure sh3 CPU, no fancy external HW)
- sys/arch/mmeye: Brains mmEye, www.brains.co.jp
MI source code includes couple of #ifdef for sh3-coff support.
(sh3 uses coff or elf)

Needs some more improvements, especialy in sys/arch/sh3/conf/files.sh3,
to compile the tree (due to last minute tree structure change).
 1.2.2.1 05-Jan-2001  bouyer Sync with HEAD
 1.11 24-Feb-2002  uch branches: 1.11.10;
clean up Makefiles
 1.10 27-Feb-2001  msaitoh branches: 1.10.4;
modify target name because we can't recommend to use pkgsrc/cross
(though I'm not the person who did such BAD modification)
 1.9 26-Feb-2001  msaitoh add comment about $CPP

From source:

# XXX following definition is absolutely incorrect.
# Our cpp is not /usr/libexec/cpp but /usr/bin/cpp.
# True solution is:
# 1) copy /usr/bin/cpp into /usr/local/bin/sh-*-*-cpp
# 2) Edit CPP in sh-*-*-cpp correctly
# (e.g. "CPP=`$CC -print-prog-name=cpp`").
# 3) Edit STDINCDIR in sh-*-*-cpp correctly
# (e.g. STDINCDIR=/usr/local/sh-unknown-netbsdcoff/include)

# BROKEN
CPP=`$TARGET-gcc -print-prog-name=cpp`

# EXAMPLE
#CPP=/usr/local/bin/sh-unknown-netbsdcoff-cpp
#CPP=/usr/local/bin/sh-unknown-netbsdelf-cpp
 1.8 26-Feb-2001  msaitoh add "MACHINE_CPU=sh3"
 1.7 09-Jan-2001  itojun pass the right $CPP
 1.6 04-Jan-2001  itojun branches: 1.6.2;
committed local change by mistake :-)
 1.5 04-Jan-2001  itojun pkgsrc/cross/sh-* do not supply cpp
 1.4 04-Jan-2001  itojun cc -v is too verbose
 1.3 04-Jan-2001  itojun fix pathname to meet pkgsrc/cross/sh*
 1.2 04-Jan-2001  itojun content were mixed up
 1.1 04-Jan-2001  itojun nuke obsolete Makefile templates.
split build-sh3 into two, for sh3e[bl].
 1.6.2.4 12-Mar-2001  bouyer Sync with HEAD.
 1.6.2.3 18-Jan-2001  bouyer Sync with head (for UBC+NFS fixes, mostly).
 1.6.2.2 05-Jan-2001  bouyer Sync with HEAD
 1.6.2.1 04-Jan-2001  bouyer file build-sh3.eb was added on branch thorpej_scsipi on 2001-01-05 17:34:59 +0000
 1.10.4.1 16-Mar-2002  jdolecek Catch up with -current.
 1.11.10.2 24-Feb-2002  uch clean up Makefiles
 1.11.10.1 24-Feb-2002  uch file build-sh3.eb was added on branch nathanw_sa on 2002-02-24 20:10:55 +0000
 1.11 24-Feb-2002  uch branches: 1.11.10;
clean up Makefiles
 1.10 27-Feb-2001  msaitoh branches: 1.10.4;
modify target name because we can't recommend to use pkgsrc/cross
(though I'm not the person who did such BAD modification)
 1.9 26-Feb-2001  msaitoh add comment about $CPP

From source:

# XXX following definition is absolutely incorrect.
# Our cpp is not /usr/libexec/cpp but /usr/bin/cpp.
# True solution is:
# 1) copy /usr/bin/cpp into /usr/local/bin/sh-*-*-cpp
# 2) Edit CPP in sh-*-*-cpp correctly
# (e.g. "CPP=`$CC -print-prog-name=cpp`").
# 3) Edit STDINCDIR in sh-*-*-cpp correctly
# (e.g. STDINCDIR=/usr/local/sh-unknown-netbsdcoff/include)

# BROKEN
CPP=`$TARGET-gcc -print-prog-name=cpp`

# EXAMPLE
#CPP=/usr/local/bin/sh-unknown-netbsdcoff-cpp
#CPP=/usr/local/bin/sh-unknown-netbsdelf-cpp
 1.8 26-Feb-2001  msaitoh add "MACHINE_CPU=sh3"
 1.7 17-Jan-2001  itojun it looks that gas configured for little endian output runs as
big endian assembler, sometimes. explicitly have -little to specify
little endian output.
 1.6 09-Jan-2001  itojun pass the right $CPP
 1.5 04-Jan-2001  itojun branches: 1.5.2;
pkgsrc/cross/sh-* do not supply cpp
 1.4 04-Jan-2001  itojun cc -v is too verbose
 1.3 04-Jan-2001  itojun fix pathname to meet pkgsrc/cross/sh*
 1.2 04-Jan-2001  itojun content were mixed up
 1.1 04-Jan-2001  itojun nuke obsolete Makefile templates.
split build-sh3 into two, for sh3e[bl].
 1.5.2.4 12-Mar-2001  bouyer Sync with HEAD.
 1.5.2.3 18-Jan-2001  bouyer Sync with head (for UBC+NFS fixes, mostly).
 1.5.2.2 05-Jan-2001  bouyer Sync with HEAD
 1.5.2.1 04-Jan-2001  bouyer file build-sh3.el was added on branch thorpej_scsipi on 2001-01-05 17:35:00 +0000
 1.10.4.1 16-Mar-2002  jdolecek Catch up with -current.
 1.11.10.2 24-Feb-2002  uch clean up Makefiles
 1.11.10.1 24-Feb-2002  uch file build-sh3.el was added on branch nathanw_sa on 2002-02-24 20:10:56 +0000
 1.48 21-Oct-2020  christos make process_machdep.c included always since it provides register i/o used by
sys_process_getlwpstatus.c which is always included.
 1.47 20-Oct-2020  christos harmonize process_machdep.c inclusion.
 1.46 26-Jul-2011  dyoung Build sh3/sh3/sh3_bus_space.c only for mmeye.
 1.45 25-Jul-2011  dyoung Move some macros back to sh3/include/bus_funcs.h from
sh3/sh3/sh3_machdep.c, where I moved them by mistake.

Pull the bus_space(9) routines into a new module,
sh3/sh3/sh3_bus_space.c, that is built only on !landisk.

Fixes the mmeye and landisk builds. Should fix other sh3 ports.
 1.44 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.43 22-Nov-2008  uwe branches: 1.43.8; 1.43.14;
Sort
 1.42 22-Nov-2008  uwe Move COMPAT_16 signal stuff to the new compat_16_machdep.c file, so
that it can be built as part of a module.
 1.41 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.40 15-Mar-2008  uwe branches: 1.40.4; 1.40.10; 1.40.12;
defflag cache related options.
 1.39 02-Feb-2008  uwe branches: 1.39.2; 1.39.6;
Add cpu_in_cksum.S
 1.38 01-Feb-2008  tsutsui Catch up with "Refactor in_cksum/in4_cksum/in6_cksum implementations".
 1.37 25-Jan-2008  joerg 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.36 06-Jan-2008  ad Add MODULAR option. Include kernel linker stuff if MODULAR.
 1.35 17-Oct-2007  garbled branches: 1.35.2; 1.35.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.34 07-Jul-2007  tsutsui branches: 1.34.10;
Remove leftover netns stuff.
 1.33 22-Feb-2007  uwe branches: 1.33.4; 1.33.6; 1.33.12;
Add lock_stubs.S with fake _lock_cas - just to make the kernel compile
for now.
 1.32 11-Dec-2005  christos branches: 1.32.26;
merge ktrace-lwp.
 1.31 10-Jul-2005  uwe Implement syscall_intern for sh3.
 1.30 27-Jul-2003  thorpej branches: 1.30.16;
Since everyone uses clock_subr.c (or should, if they don't currently),
list it in conf/files instead of in every port's files.*.
 1.29 08-May-2003  christos branches: 1.29.2;
rename Locore.c -> locore_c.c so that we can compile on case insensitive
filesystems. (from John Gordon)
 1.28 10-May-2002  uch branches: 1.28.6;
remove COMPAT_13 staff. No 1.3 release of sh3 port. these are trace of
i386 port.
 1.27 09-May-2002  uch rework general exception, and TLB exception handling for new pmap.
all exception staffs are moved to exception.[ch]
 1.26 20-Apr-2002  thorpej * Defflag the SH3 and SH4 options.
* In <sh3/cputypes.h>, always define both SH3 and SH4 if _LKM is defined.
 1.25 27-Mar-2002  uch All the sh3 ports had an identical procfs_machdep.c, so use a common
file under arch/sh3/sh3.
 1.24 24-Mar-2002  uch Rework interrupt code.
+ Fully utilize SH SR.I[0:3] interrupt level.
+ software interrupt is emulated by TMU1, 2 one shot interrupt.
+ implement generic soft interrupts.
+ implement clockframe correctly.
 1.23 17-Mar-2002  uch cosmetic changes, fix comments.
 1.22 17-Mar-2002  uch add kernel stack debug option.
 1.21 02-Mar-2002  uch Initial support for KGDB on the sh3.
 1.20 28-Feb-2002  uch Cleanup register definition
 1.19 24-Feb-2002  uch Move common exception vector and scheduler code to
sh3/sh3/exception_vector.S and sh3/sh3/locore_subr.S. exception
vectors are installed by sh_cpu_init(). machine/locore.S contains
kernel entry, interrupt handler, and some MD code.
 1.18 22-Feb-2002  uch NetBSD/sh3 common part of clock routine.
 1.17 19-Feb-2002  uch Clean up functions
disable_intr, enable_intr, disable_interrupt, enable_interrupt,
disable_ext_intr, enable_ext_intr.
New functions:
for external interrupt:
_cpu_intr_suspend and _cpu_intr_resume.
for exception:
_cpu_exception_suspend and _cpu_exception_resume.
 1.16 17-Feb-2002  uch Add new MMU API. for detail, see sh3/mmu.h's comment.
 1.15 11-Feb-2002  uch add new cache routine.
 1.14 20-Nov-2001  lukem - replace "defopt" with "defparam" for options which must take a value,
as config(8) will warn for value-less defparam options
- minor whitespace/formatting cleanup
- consolidate opt_tcp_recvspace.h and opt_tcp_sendspace.h into opt_tcp_space.h
 1.13 10-Aug-2001  msaitoh G.C.
 1.12 23-Apr-2001  uch branches: 1.12.2;
dreamcast clock module was separated.
 1.11 21-Feb-2001  uch branches: 1.11.2;
move disksubr.c define to machine-port.
 1.10 06-Feb-2001  uch move machine-port specific file to machine directory.
for evbsh3, mmeye and dreamcast, use MI md_root.c
 1.9 04-Sep-2000  tsubai Disassembly support in DDB.
 1.8 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.7 14-Feb-2000  thorpej Allow arch-specific code to specify in4_cksum() like it can specify
in_cksum().
 1.6 14-Jan-2000  msaitoh use clock_subr.c
 1.5 14-Jan-2000  msaitoh in_cksum.c ->in_cksum.S
 1.4 21-Sep-1999  tsubai branches: 1.4.2;
Move common parts of machdep.c to sh3_machdep.c.
 1.3 14-Sep-1999  tsubai Catch up with -current.
 1.2 13-Sep-1999  msaitoh remove mainbus pseudo floppy drive
 1.1 13-Sep-1999  itojun Merge in NetBSD/sh3 from cvs.kame.net repository.

Tree structure:
- sys/arch/sh3: sh3 generic code
As commented, in-chip device drivers are put into sys/arch/sh3/dev.
- sys/arch/evbsh3: sh3 evaluation boards (pure sh3 CPU, no fancy external HW)
- sys/arch/mmeye: Brains mmEye, www.brains.co.jp
MI source code includes couple of #ifdef for sh3-coff support.
(sh3 uses coff or elf)

Needs some more improvements, especialy in sys/arch/sh3/conf/files.sh3,
to compile the tree (due to last minute tree structure change).
 1.4.2.3 12-Mar-2001  bouyer Sync with HEAD.
 1.4.2.2 11-Feb-2001  bouyer Sync with HEAD.
 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.11.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.12.2.4 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.12.2.3 16-Mar-2002  jdolecek Catch up with -current.
 1.12.2.2 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.12.2.1 25-Aug-2001  thorpej Merge Aug 24 -current into the kqueue branch.
 1.28.6.2 10-May-2002  uch remove COMPAT_13 staff. No 1.3 release of sh3 port. these are trace of
i386 port.
 1.28.6.1 10-May-2002  uch file files.sh3 was added on branch nathanw_sa on 2002-05-10 15:25:14 +0000
 1.29.2.4 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.29.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.29.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.29.2.1 03-Aug-2004  skrll Sync with HEAD
 1.30.16.6 17-Mar-2008  yamt sync with head.
 1.30.16.5 04-Feb-2008  yamt sync with head.
 1.30.16.4 21-Jan-2008  yamt sync with head
 1.30.16.3 03-Sep-2007  yamt sync with head.
 1.30.16.2 26-Feb-2007  yamt sync with head.
 1.30.16.1 21-Jun-2006  yamt sync with head.
 1.32.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.33.12.1 03-Oct-2007  garbled Sync with HEAD
 1.33.6.1 11-Jul-2007  mjf Sync with head.
 1.33.4.1 15-Jul-2007  ad Sync with head.
 1.34.10.3 23-Mar-2008  matt sync with HEAD
 1.34.10.2 09-Jan-2008  matt sync with HEAD
 1.34.10.1 06-Nov-2007  matt sync with HEAD
 1.35.8.1 08-Jan-2008  bouyer Sync with HEAD
 1.35.2.1 18-Feb-2008  mjf Sync with HEAD.
 1.39.6.2 17-Jan-2009  mjf Sync with HEAD.
 1.39.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.39.2.1 24-Mar-2008  keiichi sync with head.
 1.40.12.1 19-Jan-2009  skrll Sync with HEAD.
 1.40.10.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.40.4.1 04-May-2009  yamt sync with head.
 1.43.14.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.43.8.1 18-Mar-2010  rmind Unify /dev/{mem,kmem,zero,null} implementations in MI code. Based on patch
from Joerg Sonnenberger, proposed on tech-kern@, in February 2008.

Work and depression still in progress.
 1.5 20-Sep-2006  uwe Switch the rest of sh3 ports to todr(9)
Split code to handle on-chip rtc into a separate driver
Eliminate all todr code from clock.c
Move __HAVE_GENERIC_TODR to sh3/include/types.h
 1.4 11-Dec-2005  christos branches: 1.4.20; 1.4.22;
merge ktrace-lwp.
 1.3 18-Oct-2003  uwe branches: 1.3.16;
Config glue for adc(4).
 1.2 10-May-2002  uch branches: 1.2.6; 1.2.8; 1.2.14;
cosmetic changes.
 1.1 24-Mar-2002  uch shb device is integrated to sh3/dev/shb.c and clean up locators.
 1.2.14.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.2.14.2 18-Sep-2004  skrll Sync with HEAD.
 1.2.14.1 03-Aug-2004  skrll Sync with HEAD
 1.2.8.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.2.8.1 10-May-2002  jdolecek file files.shb was added on branch kqueue on 2002-06-23 17:40:33 +0000
 1.2.6.2 10-May-2002  uch cosmetic changes.
 1.2.6.1 10-May-2002  uch file files.shb was added on branch nathanw_sa on 2002-05-10 15:28:46 +0000
 1.3.16.1 30-Dec-2006  yamt sync with head.
 1.4.22.1 22-Oct-2006  yamt sync with head
 1.4.20.1 18-Nov-2006  ad Sync with head.
 1.2 11-Dec-2005  christos branches: 1.2.18;
merge ktrace-lwp.
 1.1 16-Aug-2005  nonaka branches: 1.1.6;
Added SH7751{,R} integrated PCI controller support.
 1.1.6.2 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.1.6.1 16-Aug-2005  skrll file files.shpcic was added on branch ktrace-lwp on 2005-11-10 13:58:37 +0000
 1.2.18.2 21-Jun-2006  yamt sync with head.
 1.2.18.1 11-Dec-2005  yamt file files.shpcic was added on branch yamt-lazymbuf on 2006-06-21 14:55:31 +0000
 1.7 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.6 02-Feb-2008  uwe branches: 1.6.8; 1.6.116; 1.6.120;
Add back std.sh3. For now it contains obvious EXEC_* options and
CPU_IN_CKSUM.

Introduce std.sh3e{b,l} that include std.sh3 and just add
corresponding endianness options.
 1.5 14-Sep-2001  msaitoh branches: 1.5.12; 1.5.24; 1.5.62;
remove obsolete file
 1.4 22-Jun-2000  fvdl branches: 1.4.2; 1.4.4;
Remove prefix construction for softdeps. Add SOFTDEP option to GENERIC.
 1.3 23-Feb-2000  msaitoh branches: 1.3.4;
remove PMAP_NEW
 1.2 15-Nov-1999  fvdl Add

prefix ../gnu/sys
cinclude "conf/files.softdep"
prefix

to all std.* files, so that soft dependencies can be activated using
"options SOFTDEP".
 1.1 13-Sep-1999  itojun branches: 1.1.2; 1.1.8;
Merge in NetBSD/sh3 from cvs.kame.net repository.

Tree structure:
- sys/arch/sh3: sh3 generic code
As commented, in-chip device drivers are put into sys/arch/sh3/dev.
- sys/arch/evbsh3: sh3 evaluation boards (pure sh3 CPU, no fancy external HW)
- sys/arch/mmeye: Brains mmEye, www.brains.co.jp
MI source code includes couple of #ifdef for sh3-coff support.
(sh3 uses coff or elf)

Needs some more improvements, especialy in sys/arch/sh3/conf/files.sh3,
to compile the tree (due to last minute tree structure change).
 1.1.8.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.1.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.3.4.1 23-Jun-2000  fvdl As on the trunk, update these for the move of ffs_softdep.c into the
kernel source itself. Remove prefix construction, and add the SOFTDEP
option to GENERIC kernels.
 1.4.4.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.4.2.1 01-Oct-2001  fvdl Catch up with -current.
 1.5.62.1 18-Feb-2008  mjf Sync with HEAD.
 1.5.24.1 04-Feb-2008  yamt sync with head.
 1.5.12.2 14-Sep-2001  msaitoh remove obsolete file
 1.5.12.1 14-Sep-2001  msaitoh file std.sh3 was added on branch nathanw_sa on 2001-09-14 11:39:40 +0000
 1.6.120.1 06-Jun-2021  cjep sync with head
 1.6.116.1 17-Jun-2021  thorpej Sync w/ HEAD.
 1.6.8.2 23-Mar-2008  matt sync with HEAD
 1.6.8.1 02-Feb-2008  matt file std.sh3 was added on branch matt-armv6 on 2008-03-23 02:04:21 +0000
 1.1 02-Feb-2008  uwe branches: 1.1.2; 1.1.4; 1.1.12;
Add back std.sh3. For now it contains obvious EXEC_* options and
CPU_IN_CKSUM.

Introduce std.sh3e{b,l} that include std.sh3 and just add
corresponding endianness options.
 1.1.12.2 23-Mar-2008  matt sync with HEAD
 1.1.12.1 02-Feb-2008  matt file std.sh3eb was added on branch matt-armv6 on 2008-03-23 02:04:21 +0000
 1.1.4.2 18-Feb-2008  mjf Sync with HEAD.
 1.1.4.1 02-Feb-2008  mjf file std.sh3eb was added on branch mjf-devfs on 2008-02-18 21:05:00 +0000
 1.1.2.2 04-Feb-2008  yamt sync with head.
 1.1.2.1 02-Feb-2008  yamt file std.sh3eb was added on branch yamt-lazymbuf on 2008-02-04 09:22:29 +0000
 1.1 02-Feb-2008  uwe branches: 1.1.2; 1.1.4; 1.1.12;
Add back std.sh3. For now it contains obvious EXEC_* options and
CPU_IN_CKSUM.

Introduce std.sh3e{b,l} that include std.sh3 and just add
corresponding endianness options.
 1.1.12.2 23-Mar-2008  matt sync with HEAD
 1.1.12.1 02-Feb-2008  matt file std.sh3el was added on branch matt-armv6 on 2008-03-23 02:04:21 +0000
 1.1.4.2 18-Feb-2008  mjf Sync with HEAD.
 1.1.4.1 02-Feb-2008  mjf file std.sh3el was added on branch mjf-devfs on 2008-02-18 21:05:00 +0000
 1.1.2.2 04-Feb-2008  yamt sync with head.
 1.1.2.1 02-Feb-2008  yamt file std.sh3el was added on branch yamt-lazymbuf on 2008-02-04 09:22:29 +0000
 1.16 20-Dec-2023  thorpej Remove unnecessary <sys/malloc.h>.
 1.15 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.14 24-Apr-2021  thorpej branches: 1.14.8;
Merge thorpej-cfargs branch:

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

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

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

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

...and a sentinel value CFARG_EOL.

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

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).
 1.13 08-Aug-2010  chs branches: 1.13.74;
make this compile with DIAGNOSTIC.
 1.12 30-Apr-2009  nonaka branches: 1.12.2; 1.12.4;
Support SH7706
 1.11 05-Apr-2009  uwe Register null hooks with pmf(9) for now, which is no worse than before
and allows us to test other things.
 1.10 16-Dec-2008  christos branches: 1.10.2;
replace bitmask_snprintf(9) with snprintb(3)
 1.9 27-Mar-2008  uwe branches: 1.9.4; 1.9.12;
Use cfdata_t, aprint_*.
 1.8 27-Mar-2008  uwe Use device_t. Convert to use CFATTACH_DECL_NEW.
 1.7 27-Oct-2006  uwe branches: 1.7.52;
Nuke GPROF cargo-cult I've been cut-n-pasting around in my drivers.
 1.6 11-Dec-2005  christos branches: 1.6.20; 1.6.22;
merge ktrace-lwp.
 1.5 26-Aug-2005  drochner s/locdesc_t/int/g
 1.4 30-Jun-2005  drochner branches: 1.4.2;
adaptions to config_search() change, and minor autoconf fixes, mostly from Havard Eidnes
 1.3 22-Oct-2003  uwe branches: 1.3.4;
Use adcvar.h.
 1.2 19-Oct-2003  uwe __KERNEL_RCSID.
 1.1 18-Oct-2003  uwe Driver for analog->digital converter in sh7709.
 1.3.4.5 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 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 22-Oct-2003  skrll file adc.c was added on branch ktrace-lwp on 2004-08-03 10:40:15 +0000
 1.4.2.2 30-Dec-2006  yamt sync with head.
 1.4.2.1 21-Jun-2006  yamt sync with head.
 1.6.22.1 10-Dec-2006  yamt sync with head.
 1.6.20.1 18-Nov-2006  ad Sync with head.
 1.7.52.2 17-Jan-2009  mjf Sync with HEAD.
 1.7.52.1 03-Apr-2008  mjf Sync with HEAD.
 1.9.12.2 28-Apr-2009  skrll Sync with HEAD.
 1.9.12.1 19-Jan-2009  skrll Sync with HEAD.
 1.9.4.2 11-Aug-2010  yamt sync with head.
 1.9.4.1 04-May-2009  yamt sync with head.
 1.10.2.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.12.4.1 05-Mar-2011  rmind sync with head
 1.12.2.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.13.74.6 05-Apr-2021  thorpej Treat config_probe() as if it were a boolean function; don't compare
return value > 0... except for the odd balls, which are now really easy
to spot.
 1.13.74.5 05-Apr-2021  thorpej config_match() -> config_probe() for the straight-forward indirect config
cases. There are still a few odd balls using config_match() which should
be sorted out later.
 1.13.74.4 04-Apr-2021  thorpej CFARG_SUBMATCH -> CFARG_SEARCH for the indirect configuration uses.
 1.13.74.3 03-Apr-2021  thorpej Give config_attach() the tagged variadic argument treatment and
mechanically convert all call sites.
 1.13.74.2 21-Mar-2021  thorpej CFARG_IATTR usage audit:

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

- Introduce a new cfarg_t enumerated type, that defines the types of
tag-value variadic arguments that can be passed to the various
config_*() functions (CFARG_SUBMATCH, CFARG_IATTR, and CFARG_LOCATORS,
for now, plus a CFARG_EOL sentinel).
- Collapse config_search_*() into config_search() that takes these
variadic arguments.
- Convert all call sites of config_search_*() to the new signature.
Noticed several incorrect usages along the way, which will be
audited in a future commit.
 1.14.8.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.2 11-Dec-2005  christos merge ktrace-lwp.
 1.1 22-Oct-2003  uwe branches: 1.1.4;
Use adcvar.h.
 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-Oct-2003  skrll file adcvar.h was added on branch ktrace-lwp on 2004-08-03 10:40:15 +0000
 1.2 13-Sep-1999  msaitoh remove mainbus pseudo floppy drive
 1.1 13-Sep-1999  itojun Merge in NetBSD/sh3 from cvs.kame.net repository.

Tree structure:
- sys/arch/sh3: sh3 generic code
As commented, in-chip device drivers are put into sys/arch/sh3/dev.
- sys/arch/evbsh3: sh3 evaluation boards (pure sh3 CPU, no fancy external HW)
- sys/arch/mmeye: Brains mmEye, www.brains.co.jp
MI source code includes couple of #ifdef for sh3-coff support.
(sh3 uses coff or elf)

Needs some more improvements, especialy in sys/arch/sh3/conf/files.sh3,
to compile the tree (due to last minute tree structure change).
 1.2 13-Sep-1999  msaitoh remove mainbus pseudo floppy drive
 1.1 13-Sep-1999  itojun Merge in NetBSD/sh3 from cvs.kame.net repository.

Tree structure:
- sys/arch/sh3: sh3 generic code
As commented, in-chip device drivers are put into sys/arch/sh3/dev.
- sys/arch/evbsh3: sh3 evaluation boards (pure sh3 CPU, no fancy external HW)
- sys/arch/mmeye: Brains mmEye, www.brains.co.jp
MI source code includes couple of #ifdef for sh3-coff support.
(sh3 uses coff or elf)

Needs some more improvements, especialy in sys/arch/sh3/conf/files.sh3,
to compile the tree (due to last minute tree structure change).
 1.6 24-Mar-2002  uch branches: 1.6.4;
mmeye specific devices are moved to mmeye/dev
 1.5 12-Feb-2002  uch ANSIfy KNF.
 1.4 01-Sep-2000  tsubai branches: 1.4.4;
Correct iosize.
 1.3 29-Jun-2000  mrg remove include of <vm/vm.h>. <vm/vm.h> -> <uvm/uvm_extern.h>
 1.2 14-Sep-1999  tsubai branches: 1.2.2;
Catch up with -current.
 1.1 13-Sep-1999  itojun Merge in NetBSD/sh3 from cvs.kame.net repository.

Tree structure:
- sys/arch/sh3: sh3 generic code
As commented, in-chip device drivers are put into sys/arch/sh3/dev.
- sys/arch/evbsh3: sh3 evaluation boards (pure sh3 CPU, no fancy external HW)
- sys/arch/mmeye: Brains mmEye, www.brains.co.jp
MI source code includes couple of #ifdef for sh3-coff support.
(sh3 uses coff or elf)

Needs some more improvements, especialy in sys/arch/sh3/conf/files.sh3,
to compile the tree (due to last minute tree structure change).
 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.4.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.4.4.1 16-Mar-2002  jdolecek Catch up with -current.
 1.6.4.2 24-Mar-2002  uch mmeye specific devices are moved to mmeye/dev
 1.6.4.1 24-Mar-2002  uch file pcic_shb.c was added on branch nathanw_sa on 2002-03-24 18:08:45 +0000
 1.5 24-Mar-2002  uch branches: 1.5.4;
mmeye specific devices are moved to mmeye/dev
 1.4 12-Feb-2002  uch ANSIfy KNF.
 1.3 29-Jun-2000  mrg branches: 1.3.4;
remove include of <vm/vm.h>. <vm/vm.h> -> <uvm/uvm_extern.h>
 1.2 14-Sep-1999  tsubai branches: 1.2.2;
Catch up with -current.
 1.1 13-Sep-1999  itojun Merge in NetBSD/sh3 from cvs.kame.net repository.

Tree structure:
- sys/arch/sh3: sh3 generic code
As commented, in-chip device drivers are put into sys/arch/sh3/dev.
- sys/arch/evbsh3: sh3 evaluation boards (pure sh3 CPU, no fancy external HW)
- sys/arch/mmeye: Brains mmEye, www.brains.co.jp
MI source code includes couple of #ifdef for sh3-coff support.
(sh3 uses coff or elf)

Needs some more improvements, especialy in sys/arch/sh3/conf/files.sh3,
to compile the tree (due to last minute tree structure change).
 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.4.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.3.4.1 16-Mar-2002  jdolecek Catch up with -current.
 1.5.4.2 24-Mar-2002  uch mmeye specific devices are moved to mmeye/dev
 1.5.4.1 24-Mar-2002  uch file pcic_shbsubr.c was added on branch nathanw_sa on 2002-03-24 18:08:45 +0000
 1.13 13-Oct-2025  thorpej Use "start-year" than "sh3_rtc_baseyear" as the RTC base year property
name, matching the dsrtc driver and the Devicetree binding.
 1.12 07-Sep-2025  thorpej Change todr_chip_handle::cookie -> todr_chip_handle::todr_dev, and
make it a device_t. Upcoming functional changes will require the
device_t associated with a TODR device.

Change todr_chip_handle::bus_cookie -> todr_chip_handle::todr_devaux.
Nothing was using the old field, but I decided to keep it around just
in cause something needs it in the future.

And with these largely mechanical yet semantically meaningful changes,
thus spake the Oracle: "Welcome to NetBSD 11.99.2."
 1.11 20-Dec-2023  thorpej Remove unnecessary <sys/malloc.h>.
 1.10 20-Nov-2014  christos use the inline bcdtobin and bintobcd directly instead through a macro.
 1.9 08-Sep-2014  martin Adapt formats for debug printfs to clock_subr type changes.
 1.8 22-May-2010  tsutsui branches: 1.8.18; 1.8.34;
HPW-50PA PERSONA seems to use a different RTC base year value
(1996, not 1900 or 2000) so handle the quirk by device properties
and set it in MD device_register().
Also make RTC baseyear value patchable in sh3/dev/rtc.c.

No visible changes to other sh3 RTC users.
 1.7 05-Apr-2009  uwe branches: 1.7.2; 1.7.4;
Register with pmf(9), tell it we don't need anything.
 1.6 16-Dec-2008  christos branches: 1.6.2;
replace bitmask_snprintf(9) with snprintb(3)
 1.5 28-Apr-2008  martin branches: 1.5.8;
Remove clause 3 and 4 from TNF licenses
 1.4 27-Mar-2008  uwe branches: 1.4.2; 1.4.4;
Add RCSID comment.
 1.3 27-Mar-2008  uwe Split device_t and softc. Use aprint_*.
 1.2 30-Mar-2007  uwe branches: 1.2.34;
On attach check if clock is running, mark it invalid if not. Return
error from gettime method if clock is not valid. Mark clock as valid
on settime.

Report more debugging info.
 1.1 20-Sep-2006  uwe branches: 1.1.2; 1.1.4; 1.1.8; 1.1.10; 1.1.14; 1.1.16;
Switch the rest of sh3 ports to todr(9)
Split code to handle on-chip rtc into a separate driver
Eliminate all todr code from clock.c
Move __HAVE_GENERIC_TODR to sh3/include/types.h
 1.1.16.1 11-Jul-2007  mjf Sync with head.
 1.1.14.1 10-Apr-2007  ad Sync with head.
 1.1.10.1 15-Apr-2007  yamt sync with head.
 1.1.8.3 03-Sep-2007  yamt sync with head.
 1.1.8.2 30-Dec-2006  yamt sync with head.
 1.1.8.1 20-Sep-2006  yamt file rtc.c was added on branch yamt-lazymbuf on 2006-12-30 20:46:54 +0000
 1.1.4.2 18-Nov-2006  ad Sync with head.
 1.1.4.1 20-Sep-2006  ad file rtc.c was added on branch newlock2 on 2006-11-18 21:29:31 +0000
 1.1.2.2 22-Oct-2006  yamt sync with head
 1.1.2.1 20-Sep-2006  yamt file rtc.c was added on branch yamt-splraiseipl on 2006-10-22 06:04:59 +0000
 1.2.34.3 17-Jan-2009  mjf Sync with HEAD.
 1.2.34.2 02-Jun-2008  mjf Sync with HEAD.
 1.2.34.1 03-Apr-2008  mjf Sync with HEAD.
 1.4.4.3 11-Aug-2010  yamt sync with head.
 1.4.4.2 04-May-2009  yamt 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.8.2 28-Apr-2009  skrll Sync with HEAD.
 1.5.8.1 19-Jan-2009  skrll Sync with HEAD.
 1.6.2.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.7.4.1 30-May-2010  rmind sync with head
 1.7.2.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.8.34.1 12-Nov-2014  snj Pull up following revision(s) (requested by martin in ticket #216):
share/man/man9/todr.9: revision 1.17
sys/arch/sh3/dev/rtc.c: revision 1.9
sys/dev/clock_subr.c: revision 1.17-1.22
sys/dev/clock_subr.h: revision 1.22
sys/fs/msdosfs/msdosfs_conv.c: revision 1.10
tools/compat/compat_defs.h: revision 1.98
tools/compat/dev/clock_subr.h: revision 1.1-1.2
usr.sbin/makefs/msdos/Makefile.inc: revision 1.6
clock_secs_to_ymdhms(9) takes seconds as a time_t, not int.
--
Make this compile- and usable from userland as well.
--
Add a slightly stripped down version of sys/dev/clock/clock_subr.h to make
this code available for tools.
--
Reformulate an overflow test so it can be used in tool builds (i.e. does
not depend on netbsd specific macros).
--
Make msdosfs time conversion use the y/m/d/h/m/s conversion functions
from clock_subr.c and compile that into the userland (and tools)
makefs as well.
--
Copy definitions of __type_min(t), __type_max(t), and some related macros,
from <sys/cdefs.h>, for use when building tools.
--
Revert previous; test secs > __type_max(time_t) again, now
that __type_max is available in tools/compat/compat_defs.h.
--
If HAVE_NBTOOL_CONFIG_H is set, then include "nbtool_config.h",
because this file is compiled as part of tools/makefs.
--
Counting leap years was fine while we had 32bit time_t - but now it
is not a good idea for dates far away in the future.
For dates in the year 2000 or later, use arithmetic instead (since the
repeating periods are well aligned). Should fix PR 49144.
--
Avoid overflowing the "year" value by making the field uint64_t. Adapt
arguments and local variables accordingly.
This now fixes PR 49144 for real.
--
Adapt formats for debug printfs to clock_subr type changes.
 1.8.18.1 03-Dec-2017  jdolecek update from HEAD
 1.65 17-Sep-2023  andvar remove unneeded whitespace in empty line from my previous commit.
 1.64 16-Sep-2023  andvar sh3/sci(4): replace undefined scistatus with DPRINTF.

Fixes the build with SCI_DEBUG enabled.
 1.63 21-Nov-2020  thorpej malloc(9) -> kmem(9)
 1.62 10-Nov-2019  chs branches: 1.62.8;
in many device attach paths, allocate memory with M_WAITOK instead of M_NOWAIT
and remove code to handle failures that can no longer happen.
 1.61 15-Nov-2014  christos branches: 1.61.20;
centralize the call unit / dialout macros
 1.60 25-Jul-2014  dholland Add d_discard to all struct cdevsw instances I could find.

All have been set to "nodiscard"; some should get a real implementation.
 1.59 19-Jun-2014  msaitoh fix -Werror=unused-but-set-variable compile error
 1.58 16-Mar-2014  dholland branches: 1.58.2;
Change (mostly mechanically) every cdevsw/bdevsw I can find to use
designated initializers.

I have not built every extant kernel so I have probably broken at
least one build; however I've also found and fixed some wrong
cdevsw/bdevsw entries so even if so I think we come out ahead.
 1.57 12-Dec-2012  tsutsui branches: 1.57.2;
Fix one more device/softc split error:
- set sc->sc_dev properly
 1.56 29-Oct-2012  chs fix device/softc split errors.
 1.55 27-Oct-2012  chs split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
 1.54 02-Feb-2012  tls branches: 1.54.6;
Entropy-pool implementation move and cleanup.

1) Move core entropy-pool code and source/sink/sample management code
to sys/kern from sys/dev.

2) Remove use of NRND as test for presence of entropy-pool code throughout
source tree.

3) Remove use of RND_ENABLED in device drivers as microoptimization to
avoid expensive operations on disabled entropy sources; make the
rnd_add calls do this directly so all callers benefit.

4) Fix bug in recent rnd_add_data()/rnd_add_uint32() changes that might
have lead to slight entropy overestimation for some sources.

5) Add new source types for environmental sensors, power sensors, VM
system events, and skew between clocks, with a sample implementation
for each.

ok releng to go in before the branch due to the difficulty of later
pullup (widespread #ifdef removal and moved files). Tested with release
builds on amd64 and evbarm and live testing on amd64.
 1.53 24-Apr-2011  rmind branches: 1.53.4; 1.53.8;
Rename ttymalloc() to tty_alloc(), and ttyfree() to tty_free() for
consistency. Remove some unnecessary malloc.h inclusions as well.
 1.52 14-Mar-2009  dsl branches: 1.52.4; 1.52.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.51 13-Jun-2008  cegger branches: 1.51.4; 1.51.10;
use device_lookup_private to get softc
 1.50 28-Apr-2008  martin branches: 1.50.2; 1.50.4;
Remove clause 3 and 4 from TNF licenses
 1.49 19-Nov-2007  ad branches: 1.49.14; 1.49.16; 1.49.18;
- Factor out too many copies of the same bit of tty code.
- Fix another tty signalling/wakeup problem.
 1.48 17-Oct-2007  garbled branches: 1.48.2;
Merge the ppcoea-renovation branch to HEAD.

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

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

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.47 09-Jul-2007  ad branches: 1.47.8; 1.47.10; 1.47.14;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements
 1.46 04-Mar-2007  christos branches: 1.46.2; 1.46.4; 1.46.10;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.45 01-Oct-2006  elad branches: 1.45.4;
More from Matt Fleming:

Adapt to KAUTH_DEVICE_TTY_PRIVSET and KAUTH_DEVICE_TTY_OPEN.
 1.44 01-Oct-2006  elad Adapt MD code to KAUTH_DEVICE_TTY_OPEN. Patch from Matt Fleming, thanks!
 1.43 23-Jul-2006  ad branches: 1.43.4; 1.43.6;
Use the LWP cached credentials where sane.
 1.42 14-May-2006  elad integrate kauth.
 1.41 07-Mar-2006  uebayasi branches: 1.41.2; 1.41.4;
* Don't define SET/CLR/ISSET locally.
* Avoid shadow in a pointer-to-function declaration.
 1.40 20-Feb-2006  thorpej branches: 1.40.2;
Use device_is_active() rather than testing dv_flags for DVF_ACTIVE
directly.
 1.39 11-Dec-2005  christos branches: 1.39.2; 1.39.4; 1.39.6;
merge ktrace-lwp.
 1.38 06-Sep-2005  kleink Change the driver open function's conditional for overriding exclusive tty
use from checking the proc's uid to suser(9), and account for the use of
privileges. Noted by David Holland in PR kern/31126.
 1.37 11-Mar-2005  matt branches: 1.37.4;
Don't compare scalars against NULL, use 0.
 1.36 13-Dec-2004  chs branches: 1.36.2; 1.36.4;
for drivers that support only one instance, use a global variable to ensure
that only one instance is configured rather than requiring that its
unit number be zero.
 1.35 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

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

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

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

based on work done by Jonathan Lemon for FreeBSD
initial NetBSD port done by Luke Mewburn and Jason Thorpe
 1.32 02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.31 01-Oct-2002  thorpej Use CFATTACH_DECL().
 1.30 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.29 27-Sep-2002  thorpej Rather than referencing the cfdriver directly in the cfdata entries,
instead use a string naming the driver. The cfdriver is then looked
up in a list which is built at run-time.
 1.28 06-Sep-2002  gehenna Merge the gehenna-devsw branch into the trunk.

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

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

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

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

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

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

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

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

- In compile time, device major numbers list is packed into the kernel and
the LKM framework will refer it to assign device major number dynamically.
 1.27 16-Aug-2002  msaitoh remove extra CRLF conversion
 1.26 19-May-2002  msaitoh branches: 1.26.4;
fix some overflow cases.
 1.25 28-Apr-2002  uch branches: 1.25.2;
Use "#define<tab>", white space nits.
 1.24 28-Apr-2002  msaitoh add missing softintr_establish() call.
 1.23 26-Apr-2002  msaitoh fix around PTR and PDR
 1.22 24-Mar-2002  uch Rework interrupt code.
+ Fully utilize SH SR.I[0:3] interrupt level.
+ software interrupt is emulated by TMU1, 2 one shot interrupt.
+ implement generic soft interrupts.
+ implement clockframe correctly.
 1.21 17-Mar-2002  atatat Convert ioctl code to use EPASSTHROUGH instead of -1 or ENOTTY for
indicating an unhandled "command". ERESTART is -1, which can lead to
confusion. ERESTART has been moved to -3 and EPASSTHROUGH has been
placed at -4. No ioctl code should now return -1 anywhere. The
ioctl() system call is now properly restartable.
 1.20 24-Feb-2002  uch use sh_clock_get_pclock() instead of PCLOCK.
 1.19 22-Feb-2002  uch New NetBSD/sh3 clock framework.
+ hardclock source is moved from TMU1 to TMU0.
+ SH3/SH4 common kernel support.
+ PCLOCK estimation.
+ remove duplicated code.
 1.18 12-Feb-2002  uch ANSIfy KNF.
 1.17 01-Feb-2002  uch if PCLOCK isn't setted, use estimated value calculated by kernel.
 1.16 10-Sep-2001  msaitoh add missing check for framing error
 1.15 12-Jun-2001  wiz branches: 1.15.2; 1.15.4;
receive, not recieve
 1.14 30-May-2001  lukem add missing #include "opt_kgdb.h"
 1.13 02-May-2001  scw Add `l_poll' to `struct linesw' and provide an xxxpoll() entry point
in each tty driver to indirect through it.

This allows tty line-disciplines to handle poll(2) system calls.
 1.12 14-Jan-2001  thorpej branches: 1.12.2;
Rename __GENERIC_SOFT_INTERRUPTS to __HAVE_GENERIC_SOFT_INTERRUPTS,
and place the definition in <machine/types.h>. This can now be used
as a flag to indicate whether or not <machine/intr.h> can be included
to get the generic soft interrupt API.
 1.11 22-Nov-2000  msaitoh - fix \n conversion from \n\r to \r\n
- cleanup
 1.10 02-Nov-2000  eeh Adapt to new line discipline scheme.
 1.9 19-Jun-2000  msaitoh branches: 1.9.2;
clear ORER, FER and PER bit of the SCSSR reg.
(This bits aren't cleared automatically)
 1.8 27-Mar-2000  msaitoh branches: 1.8.2;
fix the sci[f]cninit() bugs to work both SCI and SCIF at the same time.
 1.7 23-Mar-2000  thorpej New callout mechanism with two major improvements over the old
timeout()/untimeout() API:
- Clients supply callout handle storage, thus eliminating problems of
resource allocation.
- Insertion and removal of callouts is constant time, important as
this facility is used quite a lot in the kernel.

The old timeout()/untimeout() API has been removed from the kernel.
 1.6 22-Feb-2000  msaitoh bugfixes:
o SCI accesses SCI registers (not SCIF) correctly
o If there is serial inputs in boot time, it could hangup in interrupt routine
o some cleanups(KNF)
 1.5 07-Jan-2000  msaitoh implement send/recieve break signal routines
 1.4 17-Sep-1999  msaitoh branches: 1.4.2;
check SCI(F)CONSOLE
 1.3 16-Sep-1999  msaitoh sync with sci*.h and tmureg.h
 1.2 13-Sep-1999  msaitoh add some comments.
 1.1 13-Sep-1999  itojun Merge in NetBSD/sh3 from cvs.kame.net repository.

Tree structure:
- sys/arch/sh3: sh3 generic code
As commented, in-chip device drivers are put into sys/arch/sh3/dev.
- sys/arch/evbsh3: sh3 evaluation boards (pure sh3 CPU, no fancy external HW)
- sys/arch/mmeye: Brains mmEye, www.brains.co.jp
MI source code includes couple of #ifdef for sh3-coff support.
(sh3 uses coff or elf)

Needs some more improvements, especialy in sys/arch/sh3/conf/files.sh3,
to compile the tree (due to last minute tree structure change).
 1.4.2.4 18-Jan-2001  bouyer Sync with head (for UBC+NFS fixes, mostly).
 1.4.2.3 08-Dec-2000  bouyer Sync with HEAD.
 1.4.2.2 22-Nov-2000  bouyer Sync with HEAD.
 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.8.2.1 22-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.9.2.1 30-Sep-2001  he Pull up revisions 1.11,1.15 (requested by msaitoh):
Fix \n conversion from \n\r to \r\n, and some cleanup.
 1.12.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.15.4.3 13-Oct-2001  fvdl Revert the t_dev -> t_devvp change in struct tty. The way that tty
structs are currently used (especially by console ttys) aren't
ready for it, and this will require quite a few changes.
 1.15.4.2 10-Oct-2001  fvdl Convert all remaining devices.
 1.15.4.1 01-Oct-2001  fvdl Catch up with -current.
 1.15.2.6 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.15.2.5 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.15.2.4 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.15.2.3 16-Mar-2002  jdolecek Catch up with -current.
 1.15.2.2 11-Feb-2002  jdolecek Sync w/ -current.
 1.15.2.1 13-Sep-2001  thorpej Update the kqueue branch to HEAD.
 1.25.2.3 31-Aug-2002  gehenna catch up with -current.
 1.25.2.2 30-May-2002  gehenna Catch up with -current.
 1.25.2.1 19-May-2002  gehenna Add device switch.
Replace the access to devsw table and the hard-coded majors with devsw API.
 1.26.4.5 11-Nov-2002  nathanw Catch up to -current
 1.26.4.4 18-Oct-2002  nathanw Catch up to -current.
 1.26.4.3 17-Sep-2002  nathanw Catch up to -current.
 1.26.4.2 27-Aug-2002  nathanw Catch up to -current.
 1.26.4.1 19-May-2002  nathanw file sci.c was added on branch nathanw_sa on 2002-08-27 23:45:23 +0000
 1.33.6.7 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.33.6.6 01-Apr-2005  skrll Sync with HEAD.
 1.33.6.5 25-Jan-2005  skrll Adapt to branch.
 1.33.6.4 18-Dec-2004  skrll Sync with HEAD.
 1.33.6.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.33.6.2 18-Sep-2004  skrll Sync with HEAD.
 1.33.6.1 03-Aug-2004  skrll Sync with HEAD
 1.36.4.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.36.2.1 29-Apr-2005  kent sync with -current
 1.37.4.4 07-Dec-2007  yamt sync with head
 1.37.4.3 03-Sep-2007  yamt sync with head.
 1.37.4.2 30-Dec-2006  yamt sync with head.
 1.37.4.1 21-Jun-2006  yamt sync with head.
 1.39.6.2 01-Jun-2006  kardel Sync with head.
 1.39.6.1 22-Apr-2006  simonb Sync with head.
 1.39.4.1 09-Sep-2006  rpaulo sync with head
 1.39.2.1 01-Mar-2006  yamt sync with head.
 1.40.2.3 11-Aug-2006  yamt sync with head
 1.40.2.2 24-May-2006  yamt sync with head.
 1.40.2.1 13-Mar-2006  yamt sync with head.
 1.41.4.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.41.2.4 13-May-2006  elad sprinkle some #include <sys/kauth.h> in files that use kauth kpi but
don't include it yet. hopefully this will prevent some fallout.
 1.41.2.3 10-Mar-2006  elad generic_authorize() -> kauth_authorize_generic().
 1.41.2.2 08-Mar-2006  elad Adapt to kernel authorization KPI.

I expect *some* lossage here...
 1.41.2.1 07-Mar-2006  elad file sci.c was added on branch elad-kernelauth on 2006-03-08 00:43:13 +0000
 1.43.6.1 22-Oct-2006  yamt sync with head
 1.43.4.1 18-Nov-2006  ad Sync with head.
 1.45.4.1 12-Mar-2007  rmind Sync with HEAD.
 1.46.10.1 03-Oct-2007  garbled Sync with HEAD
 1.46.4.1 11-Jul-2007  mjf Sync with head.
 1.46.2.3 03-Dec-2007  ad Sync with HEAD.
 1.46.2.2 15-Jul-2007  ad Sync with head.
 1.46.2.1 01-Jul-2007  ad Adapt to callout API change.
 1.47.14.1 21-Nov-2007  bouyer Sync with HEAD
 1.47.10.2 09-Jan-2008  matt sync with HEAD
 1.47.10.1 06-Nov-2007  matt sync with HEAD
 1.47.8.1 21-Nov-2007  joerg Sync with HEAD.
 1.48.2.1 08-Dec-2007  mjf Sync with HEAD.
 1.49.18.2 04-May-2009  yamt sync with head.
 1.49.18.1 16-May-2008  yamt sync with head.
 1.49.16.2 17-Jun-2008  yamt sync with head.
 1.49.16.1 18-May-2008  yamt sync with head.
 1.49.14.2 29-Jun-2008  mjf Sync with HEAD.
 1.49.14.1 02-Jun-2008  mjf Sync with HEAD.
 1.50.4.1 18-Jun-2008  simonb Sync with head.
 1.50.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.51.10.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.51.4.1 28-Apr-2009  skrll Sync with HEAD.
 1.52.6.1 06-Jun-2011  jruoho Sync with HEAD.
 1.52.4.1 31-May-2011  rmind sync with head
 1.53.8.1 18-Feb-2012  mrg merge to -current.
 1.53.4.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.53.4.3 16-Jan-2013  yamt sync with (a bit old) head
 1.53.4.2 30-Oct-2012  yamt sync with head
 1.53.4.1 17-Apr-2012  yamt sync with head
 1.54.6.4 03-Dec-2017  jdolecek update from HEAD
 1.54.6.3 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.54.6.2 25-Feb-2013  tls resync with head
 1.54.6.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.57.2.1 18-May-2014  rmind sync with head
 1.58.2.1 10-Aug-2014  tls Rebase.
 1.61.20.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.62.8.1 14-Dec-2020  thorpej Sync w/ HEAD.
 1.70 16-Sep-2023  andvar sh3/scif(4): redefine DPRINTF again, not all SH ports has machine/debug.h.
Those are defined for hpc only.

unbreaks build for evbsh some kernel configs and SFIC_DEBUG still builds.
 1.69 15-Sep-2023  andvar sh3/scif(4): replace undefined scifstatus with DPRINTF.

fixes the build with SCIF_DEBUG enabled.
 1.68 21-Nov-2020  thorpej malloc(9) -> kmem(9)
 1.67 10-Nov-2019  chs branches: 1.67.8;
in many device attach paths, allocate memory with M_WAITOK instead of M_NOWAIT
and remove code to handle failures that can no longer happen.
 1.66 06-Dec-2015  tsutsui branches: 1.66.18;
Make options SCIFCONSOLE patchable via a variable using gdb(1) etc.

Tested on dreamcast.
 1.65 15-Nov-2014  christos branches: 1.65.2;
centralize the call unit / dialout macros
 1.64 25-Jul-2014  dholland Add d_discard to all struct cdevsw instances I could find.

All have been set to "nodiscard"; some should get a real implementation.
 1.63 16-Mar-2014  dholland branches: 1.63.2;
Change (mostly mechanically) every cdevsw/bdevsw I can find to use
designated initializers.

I have not built every extant kernel so I have probably broken at
least one build; however I've also found and fixed some wrong
cdevsw/bdevsw entries so even if so I think we come out ahead.
 1.62 09-Nov-2013  christos fixed unused variable warning
 1.61 02-Feb-2012  tls branches: 1.61.6; 1.61.10;
Entropy-pool implementation move and cleanup.

1) Move core entropy-pool code and source/sink/sample management code
to sys/kern from sys/dev.

2) Remove use of NRND as test for presence of entropy-pool code throughout
source tree.

3) Remove use of RND_ENABLED in device drivers as microoptimization to
avoid expensive operations on disabled entropy sources; make the
rnd_add calls do this directly so all callers benefit.

4) Fix bug in recent rnd_add_data()/rnd_add_uint32() changes that might
have lead to slight entropy overestimation for some sources.

5) Add new source types for environmental sensors, power sensors, VM
system events, and skew between clocks, with a sample implementation
for each.

ok releng to go in before the branch due to the difficulty of later
pullup (widespread #ifdef removal and moved files). Tested with release
builds on amd64 and evbarm and live testing on amd64.
 1.60 24-Apr-2011  rmind branches: 1.60.4; 1.60.8;
Rename ttymalloc() to tty_alloc(), and ttyfree() to tty_free() for
consistency. Remove some unnecessary malloc.h inclusions as well.
 1.59 05-Apr-2009  uwe branches: 1.59.4; 1.59.6;
Register null hooks with pmf(9) for now, which is no worse than before
and allows us to test other things.
 1.58 18-Mar-2009  cegger Ansify function definitions w/o arguments. Generated with sed.
 1.57 28-Apr-2008  martin branches: 1.57.8; 1.57.14;
Remove clause 3 and 4 from TNF licenses
 1.56 27-Mar-2008  uwe branches: 1.56.2; 1.56.4;
Split device_t and softc.
 1.55 03-Dec-2007  ad branches: 1.55.14;
Interrupt handling changes, in discussion since February:

- Reduce available SPL levels for hardware devices to none, vm, sched, high.
- Acquire kernel_lock only for interrupts at IPL_VM.
- Implement threaded soft interrupts.
 1.54 19-Nov-2007  ad - Factor out too many copies of the same bit of tty code.
- Fix another tty signalling/wakeup problem.
 1.53 06-Nov-2007  uwe Misc cleanup: use device_* and aprint_*, group declarations, g/c some
dead code, etc.
 1.52 17-Oct-2007  garbled branches: 1.52.2;
Merge the ppcoea-renovation branch to HEAD.

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

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

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.51 09-Jul-2007  ad branches: 1.51.8; 1.51.10; 1.51.14;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements
 1.50 04-Mar-2007  christos branches: 1.50.2; 1.50.4; 1.50.10;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.49 01-Oct-2006  elad branches: 1.49.4;
More from Matt Fleming:

Adapt to KAUTH_DEVICE_TTY_PRIVSET and KAUTH_DEVICE_TTY_OPEN.
 1.48 01-Oct-2006  elad Adapt MD code to KAUTH_DEVICE_TTY_OPEN. Patch from Matt Fleming, thanks!
 1.47 23-Jul-2006  ad branches: 1.47.4; 1.47.6;
Use the LWP cached credentials where sane.
 1.46 14-May-2006  elad integrate kauth.
 1.45 06-Mar-2006  he branches: 1.45.2; 1.45.4;
Remove yet another instance of the SET/CLR/ISSET macro triplet, now
that they are in <sys/types.h>.
 1.44 20-Feb-2006  thorpej branches: 1.44.2;
Use device_is_active() rather than testing dv_flags for DVF_ACTIVE
directly.
 1.43 23-Jan-2006  uwe branches: 1.43.2; 1.43.4;
Pacify -Wuninitialized for SH3 && SH4 case.
 1.42 11-Dec-2005  christos branches: 1.42.2;
merge ktrace-lwp.
 1.41 06-Sep-2005  kleink Change the driver open function's conditional for overriding exclusive tty
use from checking the proc's uid to suser(9), and account for the use of
privileges. Noted by David Holland in PR kern/31126.
 1.40 29-Jun-2005  christos branches: 1.40.2;
Need 2ms delay (from nonaka's landisk port).
 1.39 31-May-2005  uwe Fix shadowing.
 1.38 13-Dec-2004  chs for drivers that support only one instance, use a global variable to ensure
that only one instance is configured rather than requiring that its
unit number be zero.
 1.37 19-Oct-2004  uwe First step towards bus_space - wrap register accesses into macros.
Same object code is generated.
 1.36 19-Oct-2004  uwe KNF cosmetic. Same object code is generated.
Use continue for explicit empty loop body.
Use for (;;) instead of while (1).
Fix an indentation glitch.
 1.35 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

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

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

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

based on work done by Jonathan Lemon for FreeBSD
initial NetBSD port done by Luke Mewburn and Jason Thorpe
 1.32 02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.31 01-Oct-2002  thorpej Use CFATTACH_DECL().
 1.30 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.29 27-Sep-2002  thorpej Rather than referencing the cfdriver directly in the cfdata entries,
instead use a string naming the driver. The cfdriver is then looked
up in a list which is built at run-time.
 1.28 06-Sep-2002  gehenna Merge the gehenna-devsw branch into the trunk.

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

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

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

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

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

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

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

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

- In compile time, device major numbers list is packed into the kernel and
the LKM framework will refer it to assign device major number dynamically.
 1.27 16-Aug-2002  msaitoh remove extra CRLF conversion
 1.26 19-May-2002  msaitoh branches: 1.26.4;
fix some overflow cases.
 1.25 28-Apr-2002  uch branches: 1.25.2;
Use "#define<tab>", white space nits.
 1.24 24-Mar-2002  uch Rework interrupt code.
+ Fully utilize SH SR.I[0:3] interrupt level.
+ software interrupt is emulated by TMU1, 2 one shot interrupt.
+ implement generic soft interrupts.
+ implement clockframe correctly.
 1.23 17-Mar-2002  atatat Convert ioctl code to use EPASSTHROUGH instead of -1 or ENOTTY for
indicating an unhandled "command". ERESTART is -1, which can lead to
confusion. ERESTART has been moved to -3 and EPASSTHROUGH has been
placed at -4. No ioctl code should now return -1 anywhere. The
ioctl() system call is now properly restartable.
 1.22 02-Mar-2002  uch Initial support for KGDB on the sh3.
 1.21 22-Feb-2002  uch New NetBSD/sh3 clock framework.
+ hardclock source is moved from TMU1 to TMU0.
+ SH3/SH4 common kernel support.
+ PCLOCK estimation.
+ remove duplicated code.
 1.20 12-Feb-2002  uch ANSIfy KNF.
 1.19 01-Feb-2002  uch if PCLOCK isn't setted, use estimated value calculated by kernel.
 1.18 12-Jun-2001  wiz branches: 1.18.2; 1.18.4;
receive, not recieve
 1.17 30-May-2001  lukem add missing #include "opt_kgdb.h"
 1.16 02-May-2001  scw Add `l_poll' to `struct linesw' and provide an xxxpoll() entry point
in each tty driver to indirect through it.

This allows tty line-disciplines to handle poll(2) system calls.
 1.15 14-Jan-2001  thorpej branches: 1.15.2;
Rename __GENERIC_SOFT_INTERRUPTS to __HAVE_GENERIC_SOFT_INTERRUPTS,
and place the definition in <machine/types.h>. This can now be used
as a flag to indicate whether or not <machine/intr.h> can be included
to get the generic soft interrupt API.
 1.14 22-Nov-2000  msaitoh - fix \n conversion from \n\r to \r\n
- cleanup
 1.13 02-Nov-2000  eeh Adapt to new line discipline scheme.
 1.12 31-Oct-2000  msaitoh - fix error handing in getc.
Now we can handle BREAK signal and framing error correctly.

- cleanup.
 1.11 11-Jul-2000  msaitoh callout()->callout_reset()
 1.10 19-Jun-2000  msaitoh branches: 1.10.2;
clear the ER bit of the SCSSR2 reg.
(This bit isn't cleared automatically)
 1.9 27-Mar-2000  msaitoh branches: 1.9.2;
fix the sci[f]cninit() bugs to work both SCI and SCIF at the same time.
 1.8 23-Mar-2000  thorpej New callout mechanism with two major improvements over the old
timeout()/untimeout() API:
- Clients supply callout handle storage, thus eliminating problems of
resource allocation.
- Insertion and removal of callouts is constant time, important as
this facility is used quite a lot in the kernel.

The old timeout()/untimeout() API has been removed from the kernel.
 1.7 22-Feb-2000  msaitoh bugfixes:
o SCI accesses SCI registers (not SCIF) correctly
o If there is serial inputs in boot time, it could hangup in interrupt routine
o some cleanups(KNF)
 1.6 07-Jan-2000  msaitoh implement send/recieve break signal routines
 1.5 06-Oct-1999  msaitoh branches: 1.5.2;
- unset RS/CS flow control bit from default setting
- GC
 1.4 17-Sep-1999  msaitoh branches: 1.4.2;
check SCI(F)CONSOLE
 1.3 16-Sep-1999  msaitoh sync with sci*.h and tmureg.h
 1.2 13-Sep-1999  msaitoh add some comments.
 1.1 13-Sep-1999  itojun Merge in NetBSD/sh3 from cvs.kame.net repository.

Tree structure:
- sys/arch/sh3: sh3 generic code
As commented, in-chip device drivers are put into sys/arch/sh3/dev.
- sys/arch/evbsh3: sh3 evaluation boards (pure sh3 CPU, no fancy external HW)
- sys/arch/mmeye: Brains mmEye, www.brains.co.jp
MI source code includes couple of #ifdef for sh3-coff support.
(sh3 uses coff or elf)

Needs some more improvements, especialy in sys/arch/sh3/conf/files.sh3,
to compile the tree (due to last minute tree structure change).
 1.4.2.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.5.2.4 18-Jan-2001  bouyer Sync with head (for UBC+NFS fixes, mostly).
 1.5.2.3 08-Dec-2000  bouyer Sync with HEAD.
 1.5.2.2 22-Nov-2000  bouyer Sync with HEAD.
 1.5.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.9.2.1 22-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.10.2.3 30-Sep-2001  he Pull up revisions 1.14,1.18 (requested by msaitoh):
Fix \n conversion from \n\r to \r\n, and some cleanup.
 1.10.2.2 05-Nov-2000  tv Pullup 1.12 [msaitoh]:
fix error handing in getc
We can handle BREAK signal and framing error correctly.
 1.10.2.1 08-Aug-2000  msaitoh Pull up revision 1.11 (approved by thorpej):

fix old callout interface to new callout interface (callout_reset())
 1.15.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.18.4.2 13-Oct-2001  fvdl Revert the t_dev -> t_devvp change in struct tty. The way that tty
structs are currently used (especially by console ttys) aren't
ready for it, and this will require quite a few changes.
 1.18.4.1 10-Oct-2001  fvdl Convert all remaining devices.
 1.18.2.5 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.18.2.4 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.18.2.3 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.18.2.2 16-Mar-2002  jdolecek Catch up with -current.
 1.18.2.1 11-Feb-2002  jdolecek Sync w/ -current.
 1.25.2.3 31-Aug-2002  gehenna catch up with -current.
 1.25.2.2 30-May-2002  gehenna Catch up with -current.
 1.25.2.1 19-May-2002  gehenna Add device switch.
Replace the access to devsw table and the hard-coded majors with devsw API.
 1.26.4.5 11-Nov-2002  nathanw Catch up to -current
 1.26.4.4 18-Oct-2002  nathanw Catch up to -current.
 1.26.4.3 17-Sep-2002  nathanw Catch up to -current.
 1.26.4.2 27-Aug-2002  nathanw Catch up to -current.
 1.26.4.1 19-May-2002  nathanw file scif.c was added on branch nathanw_sa on 2002-08-27 23:45:23 +0000
 1.33.6.7 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.33.6.6 17-Jan-2005  skrll Adapt to branch.
 1.33.6.5 18-Dec-2004  skrll Sync with HEAD.
 1.33.6.4 19-Oct-2004  skrll Sync with HEAD
 1.33.6.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.33.6.2 18-Sep-2004  skrll Sync with HEAD.
 1.33.6.1 03-Aug-2004  skrll Sync with HEAD
 1.40.2.5 07-Dec-2007  yamt sync with head
 1.40.2.4 15-Nov-2007  yamt sync with head.
 1.40.2.3 03-Sep-2007  yamt sync with head.
 1.40.2.2 30-Dec-2006  yamt sync with head.
 1.40.2.1 21-Jun-2006  yamt sync with head.
 1.42.2.2 01-Mar-2006  yamt sync with head.
 1.42.2.1 01-Feb-2006  yamt sync with head.
 1.43.4.2 01-Jun-2006  kardel Sync with head.
 1.43.4.1 22-Apr-2006  simonb Sync with head.
 1.43.2.1 09-Sep-2006  rpaulo sync with head
 1.44.2.3 11-Aug-2006  yamt sync with head
 1.44.2.2 24-May-2006  yamt sync with head.
 1.44.2.1 13-Mar-2006  yamt sync with head.
 1.45.4.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.45.2.3 13-May-2006  elad sprinkle some #include <sys/kauth.h> in files that use kauth kpi but
don't include it yet. hopefully this will prevent some fallout.
 1.45.2.2 10-Mar-2006  elad generic_authorize() -> kauth_authorize_generic().
 1.45.2.1 08-Mar-2006  elad Adapt to kernel authorization KPI.

I expect *some* lossage here...
 1.47.6.1 22-Oct-2006  yamt sync with head
 1.47.4.1 18-Nov-2006  ad Sync with head.
 1.49.4.1 12-Mar-2007  rmind Sync with HEAD.
 1.50.10.1 03-Oct-2007  garbled Sync with HEAD
 1.50.4.1 11-Jul-2007  mjf Sync with head.
 1.50.2.2 03-Dec-2007  ad Sync with HEAD.
 1.50.2.1 15-Jul-2007  ad Sync with head.
 1.51.14.2 21-Nov-2007  bouyer Sync with HEAD
 1.51.14.1 13-Nov-2007  bouyer Sync with HEAD
 1.51.10.2 09-Jan-2008  matt sync with HEAD
 1.51.10.1 06-Nov-2007  matt sync with HEAD
 1.51.8.3 09-Dec-2007  jmcneill Sync with HEAD.
 1.51.8.2 21-Nov-2007  joerg Sync with HEAD.
 1.51.8.1 06-Nov-2007  joerg Sync with HEAD.
 1.52.2.2 08-Dec-2007  mjf Sync with HEAD.
 1.52.2.1 19-Nov-2007  mjf Sync with HEAD.
 1.55.14.2 02-Jun-2008  mjf Sync with HEAD.
 1.55.14.1 03-Apr-2008  mjf Sync with HEAD.
 1.56.4.2 04-May-2009  yamt sync with head.
 1.56.4.1 16-May-2008  yamt sync with head.
 1.56.2.1 18-May-2008  yamt sync with head.
 1.57.14.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.57.8.1 28-Apr-2009  skrll Sync with HEAD.
 1.59.6.1 06-Jun-2011  jruoho Sync with HEAD.
 1.59.4.1 31-May-2011  rmind sync with head
 1.60.8.1 18-Feb-2012  mrg merge to -current.
 1.60.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.60.4.1 17-Apr-2012  yamt sync with head
 1.61.10.1 18-May-2014  rmind sync with head
 1.61.6.2 03-Dec-2017  jdolecek update from HEAD
 1.61.6.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.63.2.1 10-Aug-2014  tls Rebase.
 1.65.2.1 27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.66.18.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.67.8.1 14-Dec-2020  thorpej Sync w/ HEAD.
 1.2 02-Mar-2002  uch branches: 1.2.10;
Initial support for KGDB on the sh3.
 1.1 24-Feb-2000  msaitoh branches: 1.1.6; 1.1.10;
global variable declaration
 1.1.10.1 16-Mar-2002  jdolecek 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 24-Feb-2000  bouyer file scifvar.h was added on branch thorpej_scsipi on 2000-11-20 20:24:28 +0000
 1.2.10.2 02-Mar-2002  uch Initial support for KGDB on the sh3.
 1.2.10.1 02-Mar-2002  uch file scifvar.h was added on branch nathanw_sa on 2002-03-02 22:26:28 +0000
 1.1 24-Feb-2000  msaitoh branches: 1.1.6;
global variable declaration
 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 24-Feb-2000  bouyer file scivar.h was added on branch thorpej_scsipi on 2000-11-20 20:24:28 +0000
 1.16 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.15 24-Apr-2021  thorpej branches: 1.15.8;
Merge thorpej-cfargs branch:

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

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

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

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

...and a sentinel value CFARG_EOL.

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

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).
 1.14 05-Apr-2009  uwe branches: 1.14.78;
Register null hooks with pmf(9) for now, which is no worse than before
and allows us to test other things.
 1.13 28-Apr-2008  martin branches: 1.13.8; 1.13.14;
Remove clause 3 and 4 from TNF licenses
 1.12 27-Mar-2008  uwe branches: 1.12.2; 1.12.4;
Use device_t, &c. Convert to use CFATTACH_DECL_NEW (no softc).
 1.11 29-Oct-2006  uwe branches: 1.11.52;
Lift extern shb_cd declaration to the top level.
Make all routines static.
 1.10 11-Dec-2005  christos branches: 1.10.20; 1.10.22;
merge ktrace-lwp.
 1.9 26-Aug-2005  drochner s/locdesc_t/int/g
 1.8 30-Jun-2005  drochner branches: 1.8.2;
adaptions to config_search() change, and minor autoconf fixes, mostly from Havard Eidnes
 1.7 15-Jul-2003  lukem __KERNEL_RCSID()
 1.6 02-Oct-2002  thorpej branches: 1.6.6;
Add trailing ; to CFATTACH_DECL.
 1.5 01-Oct-2002  thorpej Use CFATTACH_DECL().
 1.4 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.3 27-Sep-2002  thorpej Introduce a new routine, config_match(), which invokes the
cfattach->ca_match function in behalf of the caller. Use it
rather than invoking cfattach->ca_match directly.
 1.2 28-Apr-2002  uch branches: 1.2.6; 1.2.8;
Use "#define<tab>", white space nits.
 1.1 24-Mar-2002  uch shb device is integrated to sh3/dev/shb.c and clean up locators.
 1.2.8.3 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.2.8.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.2.8.1 28-Apr-2002  jdolecek file shb.c was added on branch kqueue on 2002-06-23 17:40:35 +0000
 1.2.6.2 18-Oct-2002  nathanw Catch up to -current.
 1.2.6.1 28-Apr-2002  nathanw file shb.c was added on branch nathanw_sa on 2002-10-18 02:39:43 +0000
 1.6.6.4 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.6.6.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.6.6.2 18-Sep-2004  skrll Sync with HEAD.
 1.6.6.1 03-Aug-2004  skrll Sync with HEAD
 1.8.2.2 30-Dec-2006  yamt sync with head.
 1.8.2.1 21-Jun-2006  yamt sync with head.
 1.10.22.1 10-Dec-2006  yamt sync with head.
 1.10.20.1 18-Nov-2006  ad Sync with head.
 1.11.52.2 02-Jun-2008  mjf Sync with HEAD.
 1.11.52.1 03-Apr-2008  mjf Sync with HEAD.
 1.12.4.2 04-May-2009  yamt sync with head.
 1.12.4.1 16-May-2008  yamt sync with head.
 1.12.2.1 18-May-2008  yamt sync with head.
 1.13.14.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.13.8.1 28-Apr-2009  skrll Sync with HEAD.
 1.14.78.6 05-Apr-2021  thorpej Treat config_probe() as if it were a boolean function; don't compare
return value > 0... except for the odd balls, which are now really easy
to spot.
 1.14.78.5 05-Apr-2021  thorpej config_match() -> config_probe() for the straight-forward indirect config
cases. There are still a few odd balls using config_match() which should
be sorted out later.
 1.14.78.4 04-Apr-2021  thorpej CFARG_SUBMATCH -> CFARG_SEARCH for the indirect configuration uses.
 1.14.78.3 03-Apr-2021  thorpej Give config_attach() the tagged variadic argument treatment and
mechanically convert all call sites.
 1.14.78.2 21-Mar-2021  thorpej CFARG_IATTR usage audit:

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

- Introduce a new cfarg_t enumerated type, that defines the types of
tag-value variadic arguments that can be passed to the various
config_*() functions (CFARG_SUBMATCH, CFARG_IATTR, and CFARG_LOCATORS,
for now, plus a CFARG_EOL sentinel).
- Collapse config_search_*() into config_search() that takes these
variadic arguments.
- Convert all call sites of config_search_*() to the new signature.
Noticed several incorrect usages along the way, which will be
audited in a future commit.
 1.15.8.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.23 20-Dec-2023  thorpej Remove unnecessary <sys/malloc.h>.
 1.22 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.21 24-Apr-2021  thorpej branches: 1.21.8;
Merge thorpej-cfargs branch:

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

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

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

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

...and a sentinel value CFARG_EOL.

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

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).
 1.20 07-Jul-2020  thorpej branches: 1.20.4;
Overhaul the interface to pci_configure_bus():
- Don't expose how PCI bus configuration resource management is implemented.
Provide a new resource provider API:

==> pciconf_resource_init() -- Initialize a PCI configuration resources
container.
==> pciconf_resource_add() -- Add a PCI configuration resource to the
container (I/O, MEM, or prefetchable MEM). Multiple resources of
each type may be added.
==> pciconf_resource_fini() -- Tear down the PCI configurtation resources
container once the bus has been configured.

This is much easier to use than the previous method of providing an
extent map for each kind of resource, and works better for e.g. ACPI
platforms that provide potentially multiple PCI resources in tables
provided by firmware.

- Re-implement PCI configuration resource management using vmem arenas,
rather than extent maps.
 1.19 14-Jun-2020  chs replace EX_NOWAIT with EX_WAITOK in device attach methods.
remove checks for failures that can no longer occur.
 1.18 02-Oct-2015  msaitoh PCI Extended Configuration stuff written by nonaka@:
- Add PCI Extended Configuration Space support into x86.
- Check register offset of pci_conf_read() in MD part. It returns (pcireg_t)-1
if it isn't accessible.
- Decode Extended Capability in PCI Extended Configuration Space.
Currently the following extended capabilities are decoded:
- Advanced Error Reporting
- Virtual Channel
- Device Serial Number
- Power Budgeting
- Root Complex Link Declaration
- Root Complex Event Collector Association
- Access Control Services
- Alternative Routing-ID Interpretation
- Address Translation Services
- Single Root IO Virtualization
- Page Request
- TPH Requester
- Latency Tolerance Reporting
- Secondary PCI Express
- Process Address Space ID
- LN Requester
- L1 PM Substates
The following extended capabilities are not decoded yet:
- Root Complex Internal Link Control
- Multi-Function Virtual Channel
- RCRB Header
- Vendor Unique
- Configuration Access Correction
- Multiple Root IO Virtualization
- Multicast
- Resizable BAR
- Dynamic Power Allocation
- Protocol Multiplexing
- Downstream Port Containment
- Precision Time Management
- M-PCIe
- Function Reading Status Queueing
- Readiness Time Reporting
- Designated Vendor-Specific
 1.17 27-Jan-2012  para branches: 1.17.6; 1.17.24;
converting extent(9) from malloc(9) to kmem(9)
preceding kmem-vmem-pool-uvm patch

releng@ acknowledged
 1.16 21-Jan-2012  nonaka fix my license notice.
 1.15 01-Jul-2011  dyoung branches: 1.15.2; 1.15.6;
#include <sys/bus.h> instead of <machine/bus.h>.
 1.14 17-May-2011  dyoung PCI_FLAGS_IO_ENABLED and PCI_FLAGS_MEM_ENABLED changed their functional
role in NetBSD (drivers are no longer supposed to write these to
pa_flags) without changing name. Correct that.

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

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

algor P4032 P5064 P6032
alpha GENERIC
amd64 GENERIC XEN3_DOM0
arc GENERIC
atari HADES MILAN-PCIIDE
bebox GENERIC
cats GENERIC
cobalt GENERIC
evbarm-el ADI_BRH ARMADILLO9 CP3100 GEMINI GEMINI_MASTER GEMINI_SLAVE
evbarm-el GUMSTIX HDL_G IMX31LITE INTEGRATOR IQ31244 IQ80310 IQ80321
evbarm-el IXDP425 IXM1200 KUROBOX_PRO
evbarm-el LUBBOCK MARVELL_NAS NAPPI NSLU2 SHEEVAPLUG SMDK2800 TEAMASA_NPWR
evbarm-el TEAMASA_NPWR_FC TS7200 TWINTAIL ZAO425
evbmips-el AP30 DBAU1500 DBAU1550 MALTA MERAKI MTX-1 OMSAL400 RB153 WGT624V3
evbmips64-el XLSATX
evbppc EV64260 MPC8536DS MPC8548CDS OPENBLOCKS200 OPENBLOCKS266
evbppc OPENBLOCKS266_OPT P2020RDB PMPPC RB800 WALNUT
hp700 GENERIC
i386 ALL XEN3_DOM0 XEN3_DOMU
ibmnws GENERIC
iyonix GENERIC
landisk GENERIC
macppc GENERIC
mvmeppc GENERIC
netwinder GENERIC
ofppc GENERIC
prep GENERIC
sandpoint GENERIC
sbmips-el GENERIC
sgimips GENERIC32_IP2x GENERIC32_IP3x
sparc GENERIC_SUN4U KRUPS
sparc64 GENERIC
 1.13 02-Aug-2009  nonaka branches: 1.13.4; 1.13.6;
fix build failure.
 1.12 27-Mar-2008  uwe branches: 1.12.4; 1.12.14; 1.12.22;
Convert to use CFATTACH_DECL_NEW (no softc).
 1.11 06-Nov-2007  uwe branches: 1.11.14;
Get rid of local product table, instead just match id register and
pci_devinfo(). While here, convert to device_t, aprint_*.
 1.10 24-Dec-2005  perry branches: 1.10.30; 1.10.48; 1.10.50; 1.10.54; 1.10.56;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.
 1.9 11-Dec-2005  christos merge ktrace-lwp.
 1.8 16-Aug-2005  nonaka Added SH7751{,R} integrated PCI controller support.
 1.7 24-Mar-2002  uch branches: 1.7.4; 1.7.10; 1.7.16;
mmeye specific devices are moved to mmeye/dev
 1.6 12-Feb-2002  uch ANSIfy KNF.
 1.5 15-Dec-2001  soren To make dev/pcmcia work on platforms with 64-bit bus_addr_t and
32-bit bus_size_t (sparc), change the pcmcia_mem_map(9) offsetp
argument to bus_size_t as it is used as a bus_space offset.
 1.4 29-Jun-2000  mrg branches: 1.4.4;
remove include of <vm/vm.h>. <vm/vm.h> -> <uvm/uvm_extern.h>
 1.3 20-Apr-2000  tsubai Fill paa_busname field in pcmciabus_attach_args.
 1.2 14-Sep-1999  tsubai branches: 1.2.2;
Catch up with -current.
 1.1 13-Sep-1999  itojun Merge in NetBSD/sh3 from cvs.kame.net repository.

Tree structure:
- sys/arch/sh3: sh3 generic code
As commented, in-chip device drivers are put into sys/arch/sh3/dev.
- sys/arch/evbsh3: sh3 evaluation boards (pure sh3 CPU, no fancy external HW)
- sys/arch/mmeye: Brains mmEye, www.brains.co.jp
MI source code includes couple of #ifdef for sh3-coff support.
(sh3 uses coff or elf)

Needs some more improvements, especialy in sys/arch/sh3/conf/files.sh3,
to compile the tree (due to last minute tree structure change).
 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.4.3 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.4.4.2 16-Mar-2002  jdolecek Catch up with -current.
 1.4.4.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.7.16.2 15-Nov-2007  yamt sync with head.
 1.7.16.1 21-Jun-2006  yamt sync with head.
 1.7.10.1 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.7.4.2 24-Mar-2002  uch mmeye specific devices are moved to mmeye/dev
 1.7.4.1 24-Mar-2002  uch file shpcic.c was added on branch nathanw_sa on 2002-03-24 18:08:44 +0000
 1.10.56.1 19-Nov-2007  mjf Sync with HEAD.
 1.10.54.1 13-Nov-2007  bouyer Sync with HEAD
 1.10.50.1 06-Nov-2007  matt sync with HEAD
 1.10.48.1 06-Nov-2007  joerg Sync with HEAD.
 1.10.30.1 03-Dec-2007  ad Sync with HEAD.
 1.11.14.1 03-Apr-2008  mjf Sync with HEAD.
 1.12.22.1 21-Apr-2010  matt sync to netbsd-5
 1.12.14.1 04-Oct-2009  snj Pull up following revision(s) (requested by mrg in ticket #1063):
sys/arch/landisk/dev/obio.c: revision 1.7
sys/arch/landisk/include/bus.h: revision 1.5
sys/arch/landisk/landisk/shpcic_machdep.c: revision 1.2
sys/arch/sh3/dev/shpcic.c: revision 1.13
sys/arch/sh3/dev/shpcicvar.h: revision 1.7
fix build failure.
 1.12.4.1 19-Aug-2009  yamt sync with head.
 1.13.6.1 06-Jun-2011  jruoho Sync with HEAD.
 1.13.4.1 31-May-2011  rmind sync with head
 1.15.6.1 18-Feb-2012  mrg merge to -current.
 1.15.2.1 17-Apr-2012  yamt sync with head
 1.17.24.1 27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.17.6.1 03-Dec-2017  jdolecek update from HEAD
 1.20.4.1 21-Mar-2021  thorpej Give config_found() the same variadic arguments treatment as
config_search(). This commit only adds the CFARG_EOL sentinel
to the existing config_found() calls. Conversion of config_found_sm_loc()
and config_found_ia() call sites will be in subsequent commits.
 1.21.8.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.2 24-Mar-2002  uch branches: 1.2.4;
mmeye specific devices are moved to mmeye/dev
 1.1 13-Sep-1999  itojun branches: 1.1.16;
Merge in NetBSD/sh3 from cvs.kame.net repository.

Tree structure:
- sys/arch/sh3: sh3 generic code
As commented, in-chip device drivers are put into sys/arch/sh3/dev.
- sys/arch/evbsh3: sh3 evaluation boards (pure sh3 CPU, no fancy external HW)
- sys/arch/mmeye: Brains mmEye, www.brains.co.jp
MI source code includes couple of #ifdef for sh3-coff support.
(sh3 uses coff or elf)

Needs some more improvements, especialy in sys/arch/sh3/conf/files.sh3,
to compile the tree (due to last minute tree structure change).
 1.1.16.1 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.2.4.2 24-Mar-2002  uch mmeye specific devices are moved to mmeye/dev
 1.2.4.1 24-Mar-2002  uch file shpcicreg.h was added on branch nathanw_sa on 2002-03-24 18:08:43 +0000
 1.9 21-Jan-2012  nonaka fix my license notice.
 1.8 01-Jul-2011  dyoung branches: 1.8.2; 1.8.6;
#include <sys/bus.h> instead of <machine/bus.h>.
 1.7 02-Aug-2009  nonaka fix build failure.
 1.6 11-Dec-2005  christos branches: 1.6.78; 1.6.88; 1.6.96;
merge ktrace-lwp.
 1.5 16-Aug-2005  nonaka Added SH7751{,R} integrated PCI controller support.
 1.4 24-Mar-2002  uch branches: 1.4.4; 1.4.10; 1.4.16;
mmeye specific devices are moved to mmeye/dev
 1.3 12-Feb-2002  uch ANSIfy KNF.
 1.2 15-Dec-2001  soren To make dev/pcmcia work on platforms with 64-bit bus_addr_t and
32-bit bus_size_t (sparc), change the pcmcia_mem_map(9) offsetp
argument to bus_size_t as it is used as a bus_space offset.
 1.1 13-Sep-1999  itojun branches: 1.1.16;
Merge in NetBSD/sh3 from cvs.kame.net repository.

Tree structure:
- sys/arch/sh3: sh3 generic code
As commented, in-chip device drivers are put into sys/arch/sh3/dev.
- sys/arch/evbsh3: sh3 evaluation boards (pure sh3 CPU, no fancy external HW)
- sys/arch/mmeye: Brains mmEye, www.brains.co.jp
MI source code includes couple of #ifdef for sh3-coff support.
(sh3 uses coff or elf)

Needs some more improvements, especialy in sys/arch/sh3/conf/files.sh3,
to compile the tree (due to last minute tree structure change).
 1.1.16.3 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.1.16.2 16-Mar-2002  jdolecek Catch up with -current.
 1.1.16.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.4.16.1 21-Jun-2006  yamt sync with head.
 1.4.10.1 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.4.4.2 24-Mar-2002  uch mmeye specific devices are moved to mmeye/dev
 1.4.4.1 24-Mar-2002  uch file shpcicvar.h was added on branch nathanw_sa on 2002-03-24 18:08:43 +0000
 1.6.96.1 21-Apr-2010  matt sync to netbsd-5
 1.6.88.1 04-Oct-2009  snj Pull up following revision(s) (requested by mrg in ticket #1063):
sys/arch/landisk/dev/obio.c: revision 1.7
sys/arch/landisk/include/bus.h: revision 1.5
sys/arch/landisk/landisk/shpcic_machdep.c: revision 1.2
sys/arch/sh3/dev/shpcic.c: revision 1.13
sys/arch/sh3/dev/shpcicvar.h: revision 1.7
fix build failure.
 1.6.78.1 19-Aug-2009  yamt sync with head.
 1.8.6.1 18-Feb-2012  mrg merge to -current.
 1.8.2.1 17-Apr-2012  yamt sync with head
 1.20 27-Jan-2025  andvar s/probeing/probing/ in comments.
 1.19 20-Dec-2023  thorpej branches: 1.19.2;
Remove unnecessary <sys/malloc.h>.
 1.18 25-Jul-2014  dholland Add d_discard to all struct cdevsw instances I could find.

All have been set to "nodiscard"; some should get a real implementation.
 1.17 16-Mar-2014  dholland branches: 1.17.2;
Change (mostly mechanically) every cdevsw/bdevsw I can find to use
designated initializers.

I have not built every extant kernel so I have probably broken at
least one build; however I've also found and fixed some wrong
cdevsw/bdevsw entries so even if so I think we come out ahead.
 1.16 27-Mar-2008  uwe branches: 1.16.38; 1.16.48; 1.16.54;
Split device_t and softc.
 1.15 04-Mar-2007  christos branches: 1.15.40;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.14 11-Dec-2005  christos branches: 1.14.26;
merge ktrace-lwp.
 1.13 15-Jul-2003  lukem branches: 1.13.16;
__KERNEL_RCSID()
 1.12 23-Oct-2002  jdolecek branches: 1.12.6;
merge kqueue branch into -current

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

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

based on work done by Jonathan Lemon for FreeBSD
initial NetBSD port done by Luke Mewburn and Jason Thorpe
 1.11 02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.10 01-Oct-2002  thorpej Use CFATTACH_DECL().
 1.9 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.8 27-Sep-2002  thorpej Rather than referencing the cfdriver directly in the cfdata entries,
instead use a string naming the driver. The cfdriver is then looked
up in a list which is built at run-time.
 1.7 06-Sep-2002  gehenna Merge the gehenna-devsw branch into the trunk.

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

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

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

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

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

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

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

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

- In compile time, device major numbers list is packed into the kernel and
the LKM framework will refer it to assign device major number dynamically.
 1.6 24-Mar-2002  uch branches: 1.6.2; 1.6.6;
Rework interrupt code.
+ Fully utilize SH SR.I[0:3] interrupt level.
+ software interrupt is emulated by TMU1, 2 one shot interrupt.
+ implement generic soft interrupts.
+ implement clockframe correctly.
 1.5 12-Feb-2002  uch ANSIfy KNF.
 1.4 31-Oct-2000  msaitoh branches: 1.4.2; 1.4.4; 1.4.6;
add interrupt mode into wdog

To use:

ioctl(fd, SIOWDOGSETMODE, &val)

val: WDOGM_RESET -> reset when counter expired
WDOGM_INTR -> print PC when counter expired (new!)

This interface is still under experimental.
 1.3 20-Apr-2000  msaitoh remove a debug log
 1.2 24-Feb-2000  msaitoh add RCSID and copyright
 1.1 24-Feb-2000  msaitoh watchdog timer
 1.4.6.3 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.4.6.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.4.6.1 16-Mar-2002  jdolecek Catch up with -current.
 1.4.4.1 10-Oct-2001  fvdl Convert all remaining devices.
 1.4.2.3 22-Nov-2000  bouyer Sync with HEAD.
 1.4.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.4.2.1 31-Oct-2000  bouyer file wdog.c was added on branch thorpej_scsipi on 2000-11-20 20:24:28 +0000
 1.6.6.4 11-Nov-2002  nathanw Catch up to -current
 1.6.6.3 18-Oct-2002  nathanw Catch up to -current.
 1.6.6.2 17-Sep-2002  nathanw Catch up to -current.
 1.6.6.1 24-Mar-2002  nathanw file wdog.c was added on branch nathanw_sa on 2002-09-17 21:17:24 +0000
 1.6.2.1 17-May-2002  gehenna Add device switch.
 1.12.6.4 24-Jan-2005  skrll Adapt to branch.
 1.12.6.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.12.6.2 18-Sep-2004  skrll Sync with HEAD.
 1.12.6.1 03-Aug-2004  skrll Sync with HEAD
 1.13.16.2 03-Sep-2007  yamt sync with head.
 1.13.16.1 21-Jun-2006  yamt sync with head.
 1.14.26.1 12-Mar-2007  rmind Sync with HEAD.
 1.15.40.1 03-Apr-2008  mjf Sync with HEAD.
 1.16.54.1 18-May-2014  rmind sync with head
 1.16.48.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.16.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.17.2.1 10-Aug-2014  tls Rebase.
 1.19.2.1 02-Aug-2025  perseant Sync with HEAD
 1.32 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.31 04-Nov-2024  christos Undo previous lwp.h change.
 1.30 03-Nov-2024  christos Split __lwp_getprivate_fast and __lwp_*tcb from mcontext.h into a separate
lwp.h file.
 1.29 12-Jul-2018  maxv branches: 1.29.36;
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.28 02-Mar-2018  uwe branches: 1.28.2; 1.28.4;
Introduce sh3/sysarch.h and add SH3_SYNC_ICACHE
 1.27 25-Aug-2016  christos fenv.h for sh
 1.26 17-Jul-2011  dyoung branches: 1.26.12; 1.26.30;
Do not install bus.h.
 1.25 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.24 09-Feb-2007  ad Merge newlock2 to head.
 1.23 26-Jul-2006  drochner branches: 1.23.4;
don't install <machine/db_machdep.h>, this is kernel only
 1.22 21-May-2006  uwe Nuke va-sh.h. stdarg.h and varargs.h now use __builtin_va_*.
 1.21 01-Feb-2006  dsl branches: 1.21.2; 1.21.4; 1.21.8; 1.21.10;
Need to install byte_swap.h and bswap.h needs to include sh3/byte_swap.h.
 1.20 11-Dec-2005  christos branches: 1.20.2; 1.20.4;
merge ktrace-lwp.
 1.19 08-May-2004  kleink branches: 1.19.12;
Factor out W{CHAR,INT}_{MAX,MIN} into their own header file.
 1.18 18-Jan-2003  thorpej branches: 1.18.2;
Merge the nathanw_sa branch.
 1.17 26-Nov-2002  lukem Remove KDIR=, since SYS_INCLUDE=symlinks and KDIR are not supported any more.
 1.16 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.15 10-May-2002  uch branches: 1.15.2; 1.15.6;
clean up disassembler code.
 1.14 09-May-2002  uch rework general exception, and TLB exception handling for new pmap.
all exception staffs are moved to exception.[ch]
 1.13 24-Mar-2002  uch Rework interrupt code.
+ Fully utilize SH SR.I[0:3] interrupt level.
+ software interrupt is emulated by TMU1, 2 one shot interrupt.
+ implement generic soft interrupts.
+ implement clockframe correctly.
 1.12 07-Mar-2002  thorpej Remove some files that no longer exist.
 1.11 15-Apr-2001  kleink branches: 1.11.2;
Add definitions of C99 integer format conversion macros.
XXX Fastest minimum-width integer types haven't been decided upon yet.
 1.10 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.9 14-Apr-2001  kleink Add definitions of C99 integer constant macros.
Tidy Makefiles up a little.
 1.8 26-Jun-2000  kleink branches: 1.8.2;
Add <machine/int_types.h>, which provides namespace-pure definitions
of exact-width integer types.
 1.7 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.6 17-Mar-2000  tron Install "machineendian_machdep.h".
 1.5 24-Feb-2000  msaitoh watchdog timer
 1.4 17-Jan-2000  kleink Add NAN constant glue for sh3.
 1.3 14-Jan-2000  msaitoh add cpgreg.h and pfcreg.h for "make includes"
 1.2 02-Jan-2000  msaitoh remove exec_coff.h
 1.1 13-Sep-1999  itojun branches: 1.1.2;
Merge in NetBSD/sh3 from cvs.kame.net repository.

Tree structure:
- sys/arch/sh3: sh3 generic code
As commented, in-chip device drivers are put into sys/arch/sh3/dev.
- sys/arch/evbsh3: sh3 evaluation boards (pure sh3 CPU, no fancy external HW)
- sys/arch/mmeye: Brains mmEye, www.brains.co.jp
MI source code includes couple of #ifdef for sh3-coff support.
(sh3 uses coff or elf)

Needs some more improvements, especialy in sys/arch/sh3/conf/files.sh3,
to compile the tree (due to last minute tree structure change).
 1.1.2.2 21-Apr-2001  bouyer Sync with HEAD
 1.1.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.8.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.11.2.3 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.11.2.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.11.2.1 16-Mar-2002  jdolecek Catch up with -current.
 1.15.6.4 11-Dec-2002  thorpej Sync with HEAD.
 1.15.6.3 13-Aug-2002  nathanw Catch up to -current.
 1.15.6.2 20-Jun-2002  thorpej Machine-dependent kernel portion of {get,set}context(). From
Klaus Klein.
 1.15.6.1 10-May-2002  thorpej file Makefile was added on branch nathanw_sa on 2002-06-20 23:00:49 +0000
 1.15.2.1 31-Aug-2002  gehenna catch up with -current.
 1.18.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.18.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.18.2.1 03-Aug-2004  skrll Sync with HEAD
 1.19.12.3 26-Feb-2007  yamt sync with head.
 1.19.12.2 30-Dec-2006  yamt sync with head.
 1.19.12.1 21-Jun-2006  yamt sync with head.
 1.20.4.1 09-Sep-2006  rpaulo sync with head
 1.20.2.1 18-Feb-2006  yamt sync with head.
 1.21.10.1 19-Jun-2006  chap Sync with head.
 1.21.8.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.21.4.2 11-Aug-2006  yamt sync with head
 1.21.4.1 24-May-2006  yamt sync with head.
 1.21.2.1 01-Jun-2006  kardel Sync with head.
 1.23.4.1 01-Feb-2007  ad Get sh3 compiling.
 1.26.30.1 05-Oct-2016  skrll Sync with HEAD
 1.26.12.1 03-Dec-2017  jdolecek update from HEAD
 1.28.4.1 10-Jun-2019  christos Sync with HEAD
 1.28.2.1 28-Jul-2018  pgoyette Sync with HEAD
 1.29.36.1 02-Aug-2025  perseant Sync with HEAD
 1.3 11-Dec-2005  christos merge ktrace-lwp.
 1.2 15-Oct-2003  uwe branches: 1.2.4;
Use 'CH' for channel select in the ADCSR bits format string for consistency.
 1.1 10-Oct-2003  uwe Register definitions for sh7709 analog->digital converter.
 1.2.4.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.2.4.3 18-Sep-2004  skrll Sync with HEAD.
 1.2.4.2 03-Aug-2004  skrll Sync with HEAD
 1.2.4.1 15-Oct-2003  skrll file adcreg.h was added on branch ktrace-lwp on 2004-08-03 10:40:15 +0000
 1.17 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.16 17-Jun-2015  martin branches: 1.16.18;
Make clock_t unsigned int everywhere.
Ok: matt@, mrg@
 1.15 17-Jul-2011  joerg branches: 1.15.12; 1.15.28; 1.15.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.14 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.13 11-Jan-2009  christos branches: 1.13.4; 1.13.6;
merge christos-time_t
 1.12 17-Oct-2007  garbled branches: 1.12.16; 1.12.18; 1.12.22; 1.12.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.11 03-Sep-2007  drochner clean up some definitions around rune_t which are not needed anymore
 1.10 04-Oct-2006  tnozaki branches: 1.10.8; 1.10.16; 1.10.22; 1.10.26; 1.10.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.9 15-May-2006  uwe branches: 1.9.8; 1.9.10;
Change _BSD_VA_LIST_ from "void *" to "__builtin_va_list" for newer
gcc versions and "char *" otherwise. This is what most other arches
use, modulo different __GNUC_PREREQ__.

This is in preparation for replacing stdarg.h and varargs.h with
versions based on __builtin_* instead of handwritten code that gcc
3.3.6 and up refuse to compile b/c of lhs casts.

Identical binary code produced.
 1.8 11-Dec-2005  christos branches: 1.8.4; 1.8.6; 1.8.8; 1.8.12;
merge ktrace-lwp.
 1.7 07-Aug-2003  agc branches: 1.7.16;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.6 02-Mar-2003  tshiozak branches: 1.6.2;
add some ISO C 1995 I18N functions and types:
btowc, wctrans, towctrans, wcscoll, wcsxfrm, wctype_t and wctrans_t.
 1.5 03-Jan-2001  takemura replace 'long long' with int64_t to compile stand alone program with
compiler other than GCC.
 1.4 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.3 21-Dec-2000  itojun populate _BSD_MBSTATE_T_. add warning regarding to rune_t.
 1.2 27-Jun-2000  kleink G/c _BSD_INTPTR_T_ and _BSD_UINTPTR_T_.
 1.1 13-Sep-1999  itojun branches: 1.1.2; 1.1.10;
Merge in NetBSD/sh3 from cvs.kame.net repository.

Tree structure:
- sys/arch/sh3: sh3 generic code
As commented, in-chip device drivers are put into sys/arch/sh3/dev.
- sys/arch/evbsh3: sh3 evaluation boards (pure sh3 CPU, no fancy external HW)
- sys/arch/mmeye: Brains mmEye, www.brains.co.jp
MI source code includes couple of #ifdef for sh3-coff support.
(sh3 uses coff or elf)

Needs some more improvements, especialy in sys/arch/sh3/conf/files.sh3,
to compile the tree (due to last minute tree structure change).
 1.1.10.1 28-May-2000  minoura Citrus Project XPG4DL, an implementation of I18N (locale) framework,
is imported.
 1.1.2.2 05-Jan-2001  bouyer Sync with HEAD
 1.1.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.6.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.6.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.6.2.1 03-Aug-2004  skrll Sync with HEAD
 1.7.16.3 27-Oct-2007  yamt sync with head.
 1.7.16.2 30-Dec-2006  yamt sync with head.
 1.7.16.1 21-Jun-2006  yamt sync with head.
 1.8.12.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.8.8.1 24-May-2006  yamt sync with head.
 1.8.6.1 01-Jun-2006  kardel Sync with head.
 1.8.4.1 09-Sep-2006  rpaulo sync with head
 1.9.10.1 22-Oct-2006  yamt sync with head
 1.9.8.1 18-Nov-2006  ad Sync with head.
 1.10.28.1 06-Nov-2007  matt sync with HEAD
 1.10.26.1 02-Oct-2007  joerg Sync with HEAD.
 1.10.22.1 10-Sep-2007  skrll Sync with HEAD.
 1.10.16.1 03-Oct-2007  garbled Sync with HEAD
 1.10.8.1 09-Oct-2007  ad Sync with head.
 1.12.30.1 19-Jan-2009  skrll Sync with HEAD.
 1.12.22.2 11-Aug-2010  yamt sync with head.
 1.12.22.1 04-May-2009  yamt sync with head.
 1.12.18.3 04-Jan-2009  christos revert all but time_t
 1.12.18.2 30-Mar-2008  christos time_t is now __int64_t
 1.12.18.1 29-Mar-2008  christos Welcome to the time_t=long long dev_t=uint64_t branch.
 1.12.16.1 17-Jan-2009  mjf Sync with HEAD.
 1.13.6.1 30-May-2010  rmind sync with head
 1.13.4.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.15.30.1 22-Sep-2015  skrll Sync with HEAD
 1.15.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.15.12.1 03-Dec-2017  jdolecek update from HEAD
 1.16.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 28-Apr-2002  uch branches: 1.3.6;
Use "#define<tab>", white space nits.
 1.2 17-Mar-2002  uch cosmetic changes, fix comments.
 1.1 13-Sep-1999  itojun branches: 1.1.16;
Merge in NetBSD/sh3 from cvs.kame.net repository.

Tree structure:
- sys/arch/sh3: sh3 generic code
As commented, in-chip device drivers are put into sys/arch/sh3/dev.
- sys/arch/evbsh3: sh3 evaluation boards (pure sh3 CPU, no fancy external HW)
- sys/arch/mmeye: Brains mmEye, www.brains.co.jp
MI source code includes couple of #ifdef for sh3-coff support.
(sh3 uses coff or elf)

Needs some more improvements, especialy in sys/arch/sh3/conf/files.sh3,
to compile the tree (due to last minute tree structure change).
 1.1.16.1 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.3.6.2 11-Dec-2002  thorpej Sync with HEAD.
 1.3.6.1 28-Apr-2002  thorpej file aout_machdep.h was added on branch nathanw_sa on 2002-12-11 06:11:54 +0000
 1.32 08-May-2025  uwe sh3: asm.h - no ## at token boundaries

For the ## "if the result is not a valid preprocessing token, the
behavior is undefined", so you 1) don't need to 2) must not use it to
concatenate a token with a non-token, like .arg or arg()

The point is kinda moot, as traditionally asm with cpp uses traditional
cpp, not ANSI cpp (many assemblers use # for literals, which conflicts
with the ANSI CPP # stringization and requires awkward workarounds),
but don't set a bad example even if it never gets called out by the
compiler.
 1.31 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.30 04-Jan-2025  martin PR 58960: sh3/asm.h: Respect _NETBSD_REVISIONID.
 1.29 17-Apr-2020  joerg branches: 1.29.26;
Mark the .ident section as mergable string section to avoid redundant
entries.
 1.28 12-Sep-2013  joerg branches: 1.28.30; 1.28.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.27 20-Dec-2010  joerg branches: 1.27.8; 1.27.18; 1.27.22;
Consistently use .gnu.warning with .pushsectio and .popsection on all
architectures instead of obsolete STABS frames for linker warnings.
 1.26 19-Sep-2008  uwe branches: 1.26.16;
Use pushsection/popsection for RCSID.
 1.25 20-Jan-2006  christos branches: 1.25.72; 1.25.76; 1.25.78; 1.25.82;
Add a STRONG_ALIAS macro
 1.24 06-Jan-2006  uwe Provide PIC_EPILOGUE_SLOT that is safe to use in delay slot.
 1.23 05-Jan-2006  uwe Introduce PIC_PROLOGUE_NOSAVE for functions that do non-local jumps
and don't need to save/restore r12. Shaves off two instructions.
 1.22 05-Jan-2006  uwe mova can only have r0 as destination, so PIC_PROLOGUE can not specify
an arbitrary temp register.
 1.21 05-Jan-2006  uwe Macros for .size directive.
 1.20 31-Dec-2005  uwe First cut at PIC macros.
 1.19 24-Dec-2005  uwe branches: 1.19.2;
Implement WARN_REFERENCES.
 1.18 24-Dec-2005  uwe Prettify.
 1.17 11-Dec-2005  christos merge ktrace-lwp.
 1.16 24-Nov-2003  uwe branches: 1.16.14; 1.16.16;
Definition of __KERNEL_RCSID for asm files.
 1.15 27-Aug-2003  uwe Bring _PROF_PROLOGUE back. The breakage was caused by calls to
__udivsi3 being treated specially by gcc.
 1.14 10-Aug-2003  uwe Undo previous. It breaks profiling, but I managed to test against the
wrong tree and so missed it.
 1.13 10-Aug-2003  uwe Real _PROF_PROLOGUE so that assembly language functions can be profiled.
 1.12 09-Aug-2003  uwe For ELF put RCSID strings into .ident section.
 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 28-Apr-2002  uch branches: 1.10.6; 1.10.12;
Use "#define<tab>", white space nits.
 1.9 17-Mar-2002  uch cosmetic changes, fix comments.
 1.8 16-Dec-2001  thorpej Consider __NO_LEADING_UNDERSCORES__ provided by the new ELF toolchain.
 1.7 10-Jun-2001  msaitoh branches: 1.7.2;
.type xxx,@function isn't supported under COFF
 1.6 09-Apr-2001  marcus Altentries should also be marked as functions, to keep linker happy.
 1.5 09-Apr-2001  marcus Mark syscalls as functions.
 1.4 25-Feb-2001  msaitoh branches: 1.4.2;
check __LEADING_UNDERSCORE
 1.3 14-Dec-2000  marcus Made weak_alias create correct labels on sh-elf.
 1.2 23-Jun-2000  kleink Add a WEAK_ALIAS() macro.
 1.1 13-Sep-1999  itojun branches: 1.1.2; 1.1.12;
Merge in NetBSD/sh3 from cvs.kame.net repository.

Tree structure:
- sys/arch/sh3: sh3 generic code
As commented, in-chip device drivers are put into sys/arch/sh3/dev.
- sys/arch/evbsh3: sh3 evaluation boards (pure sh3 CPU, no fancy external HW)
- sys/arch/mmeye: Brains mmEye, www.brains.co.jp
MI source code includes couple of #ifdef for sh3-coff support.
(sh3 uses coff or elf)

Needs some more improvements, especialy in sys/arch/sh3/conf/files.sh3,
to compile the tree (due to last minute tree structure change).
 1.1.12.1 25-Jul-2000  kleink Pull up rev. 1.2 (approved by thorpej):
For ELF, add a WEAK_ALIAS() macro.
 1.1.2.4 21-Apr-2001  bouyer Sync with HEAD
 1.1.2.3 12-Mar-2001  bouyer Sync with HEAD.
 1.1.2.2 05-Jan-2001  bouyer Sync with HEAD
 1.1.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.4.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.7.2.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.7.2.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.10.12.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.10.12.2 18-Sep-2004  skrll Sync with HEAD.
 1.10.12.1 03-Aug-2004  skrll Sync with HEAD
 1.10.6.2 28-Apr-2002  uch Use "#define<tab>", white space nits.
 1.10.6.1 28-Apr-2002  uch file asm.h was added on branch nathanw_sa on 2002-04-28 17:10:34 +0000
 1.16.16.1 21-Jun-2006  yamt sync with head.
 1.16.14.7 11-Jan-2006  tron Pull up following revision(s) (requested by uwe in ticket #1094):
sys/arch/sh3/include/asm.h: revision 1.24
Provide PIC_EPILOGUE_SLOT that is safe to use in delay slot.
 1.16.14.6 11-Jan-2006  tron Pull up following revision(s) (requested by uwe in ticket #1094):
sys/arch/sh3/include/asm.h: revision 1.23
Introduce PIC_PROLOGUE_NOSAVE for functions that do non-local jumps
and don't need to save/restore r12. Shaves off two instructions.
 1.16.14.5 11-Jan-2006  tron Pull up following revision(s) (requested by uwe in ticket #1094):
sys/arch/sh3/include/asm.h: revision 1.22
mova can only have r0 as destination, so PIC_PROLOGUE can not specify
an arbitrary temp register.
 1.16.14.4 11-Jan-2006  tron Pull up following revision(s) (requested by uwe in ticket #1094):
sys/arch/sh3/include/asm.h: revision 1.21
Macros for .size directive.
 1.16.14.3 11-Jan-2006  tron Pull up following revision(s) (requested by uwe in ticket #1094):
sys/arch/sh3/include/asm.h: revision 1.20
First cut at PIC macros.
 1.16.14.2 11-Jan-2006  tron Pull up following revision(s) (requested by uwe in ticket #1094):
sys/arch/sh3/include/asm.h: revision 1.19
Implement WARN_REFERENCES.
 1.16.14.1 11-Jan-2006  tron Pull up following revision(s) (requested by uwe in ticket #1094):
sys/arch/sh3/include/asm.h: revision 1.18
Prettify.
 1.19.2.2 01-Feb-2006  yamt sync with head.
 1.19.2.1 15-Jan-2006  yamt sync with head.
 1.25.82.1 19-Oct-2008  haad Sync with HEAD.
 1.25.78.1 24-Sep-2008  wrstuden Merge in changes between wrstuden-revivesa-base-2 and
wrstuden-revivesa-base-3.
 1.25.76.1 04-May-2009  yamt sync with head.
 1.25.72.1 28-Sep-2008  mjf Sync with HEAD.
 1.26.16.1 05-Mar-2011  rmind sync with head
 1.27.22.1 18-May-2014  rmind sync with head
 1.27.18.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.27.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.28.40.1 20-Apr-2020  bouyer Sync with HEAD
 1.28.30.1 21-Apr-2020  martin Sync with HEAD
 1.29.26.1 02-Aug-2025  perseant Sync with HEAD
 1.3 08-Mar-2002  uch branches: 1.3.8;
remove unneeded code and files.
 1.2 12-Feb-2002  uch ANSIfy KNF.
 1.1 13-Sep-1999  itojun branches: 1.1.16;
Merge in NetBSD/sh3 from cvs.kame.net repository.

Tree structure:
- sys/arch/sh3: sh3 generic code
As commented, in-chip device drivers are put into sys/arch/sh3/dev.
- sys/arch/evbsh3: sh3 evaluation boards (pure sh3 CPU, no fancy external HW)
- sys/arch/mmeye: Brains mmEye, www.brains.co.jp
MI source code includes couple of #ifdef for sh3-coff support.
(sh3 uses coff or elf)

Needs some more improvements, especialy in sys/arch/sh3/conf/files.sh3,
to compile the tree (due to last minute tree structure change).
 1.1.16.1 16-Mar-2002  jdolecek Catch up with -current.
 1.3.8.2 08-Mar-2002  uch remove unneeded code and files.
 1.3.8.1 08-Mar-2002  uch file bootinfo.h was added on branch nathanw_sa on 2002-03-08 13:22:15 +0000
 1.7 17-Feb-2008  uwe Define constants for setting bus widths of physical space areas in BCR2.
 1.6 11-Dec-2005  christos branches: 1.6.50; 1.6.56;
merge ktrace-lwp.
 1.5 29-Jun-2005  christos branches: 1.5.2;
more register definitions, from nonaka's landisk port.
 1.4 28-Apr-2002  uch branches: 1.4.6; 1.4.12;
Use "#define<tab>", white space nits.
 1.3 28-Feb-2002  uch Cleanup register definition
 1.2 16-Sep-1999  msaitoh branches: 1.2.16;
cleanup
 1.1 13-Sep-1999  itojun Merge in NetBSD/sh3 from cvs.kame.net repository.

Tree structure:
- sys/arch/sh3: sh3 generic code
As commented, in-chip device drivers are put into sys/arch/sh3/dev.
- sys/arch/evbsh3: sh3 evaluation boards (pure sh3 CPU, no fancy external HW)
- sys/arch/mmeye: Brains mmEye, www.brains.co.jp
MI source code includes couple of #ifdef for sh3-coff support.
(sh3 uses coff or elf)

Needs some more improvements, especialy in sys/arch/sh3/conf/files.sh3,
to compile the tree (due to last minute tree structure change).
 1.2.16.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.2.16.1 16-Mar-2002  jdolecek Catch up with -current.
 1.4.12.1 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.4.6.2 28-Apr-2002  uch Use "#define<tab>", white space nits.
 1.4.6.1 28-Apr-2002  uch file bscreg.h was added on branch nathanw_sa on 2002-04-28 17:10:34 +0000
 1.5.2.1 27-Feb-2008  yamt sync with head.
 1.6.56.1 18-Feb-2008  mjf Sync with HEAD.
 1.6.50.1 23-Mar-2008  matt sync with HEAD
 1.7 01-Feb-2006  dsl Need to install byte_swap.h and bswap.h needs to include sh3/byte_swap.h.
 1.6 31-Jan-2006  dsl branches: 1.6.2;
Make the sh3 bswap headers look like all the other ports
 1.5 24-Dec-2005  perry branches: 1.5.2;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.
 1.4 28-Apr-2002  uch branches: 1.4.6; 1.4.28;
Use "#define<tab>", white space nits.
 1.3 17-Mar-2002  uch cosmetic changes, fix comments.
 1.2 12-Feb-2002  uch ANSIfy KNF.
 1.1 13-Sep-1999  itojun branches: 1.1.16;
Merge in NetBSD/sh3 from cvs.kame.net repository.

Tree structure:
- sys/arch/sh3: sh3 generic code
As commented, in-chip device drivers are put into sys/arch/sh3/dev.
- sys/arch/evbsh3: sh3 evaluation boards (pure sh3 CPU, no fancy external HW)
- sys/arch/mmeye: Brains mmEye, www.brains.co.jp
MI source code includes couple of #ifdef for sh3-coff support.
(sh3 uses coff or elf)

Needs some more improvements, especialy in sys/arch/sh3/conf/files.sh3,
to compile the tree (due to last minute tree structure change).
 1.1.16.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.1.16.1 16-Mar-2002  jdolecek Catch up with -current.
 1.4.28.1 21-Jun-2006  yamt sync with head.
 1.4.6.2 28-Apr-2002  uch Use "#define<tab>", white space nits.
 1.4.6.1 28-Apr-2002  uch file bswap.h was added on branch nathanw_sa on 2002-04-28 17:10:34 +0000
 1.5.2.2 18-Feb-2006  yamt sync with head.
 1.5.2.1 01-Feb-2006  yamt sync with head.
 1.6.2.1 09-Sep-2006  rpaulo sync with head
 1.19 17-Jul-2011  dyoung Switch to new-style <sys/bus.h>.
 1.18 15-Mar-2010  uwe Sync with <sys/bus_proto.h>: constify source arg of bus_space_write* &co,
fix size_t vs. bus_size_t confusion.

Makes mmeye kernel build again.
 1.17 28-Apr-2008  martin branches: 1.17.20;
Remove clause 3 and 4 from TNF licenses
 1.16 04-Mar-2006  uwe branches: 1.16.68; 1.16.70; 1.16.72;
s/u_intN_t/uintN_t/
 1.15 16-Feb-2006  perry 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.14 29-Jan-2006  dsl branches: 1.14.2; 1.14.4;
Make almost everything #include <sys/bswap.h> instead of <machine/bswap.h>
The bswap.h and endian.h files are all rather incestuous, but I want to
get the constant folding stuff into one place - sys/bswap.h
 1.13 24-Dec-2005  perry branches: 1.13.2;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.
 1.12 11-Dec-2005  christos merge ktrace-lwp.
 1.11 15-Sep-2005  uwe Drop obsolete bus_space_* compat defs.
 1.10 11-Mar-2005  matt branches: 1.10.4;
Add missing stream methods (for wdc_pcmcia.c)
 1.9 28-Apr-2002  uch branches: 1.9.6; 1.9.12; 1.9.20; 1.9.22;
Use "#define<tab>", white space nits.
 1.8 28-Feb-2002  uch Remove #if 0 #endif
 1.7 12-Feb-2002  uch ANSIfy KNF.
 1.6 19-Jul-2001  thorpej Add BUS_DMA_READ and BUS_DMA_WRITE flags, that hint the back-end
at dmamap load time that the mapping will be used for a unidirectional
transfer of the specified direction.
 1.5 30-Jan-2001  msaitoh branches: 1.5.4;
add some macros for 8bit PCMCIA access
 1.4 26-Jun-2000  simonb Change the kernel mmap interface so that the offset to map is an
"off_t" and the return value is a "paddr_t" to allow mappings
at offsets past 2^31 bytes. Somewhat inspired by FreeBSD, which
only changed the offset to a "vm_offset_t".

Includes updates for the i386, pc532 and sh3 mmmmap from Jason Thorpe.
 1.3 24-Feb-2000  msaitoh branches: 1.3.4;
SH4!
 1.2 25-Jan-2000  drochner define a "BUS_SPACE_MAP_PREFETCHABLE" flag which basically means that
device accesses are idempotent (but should not be cached by the CPU)
 1.1 13-Sep-1999  itojun branches: 1.1.2;
Merge in NetBSD/sh3 from cvs.kame.net repository.

Tree structure:
- sys/arch/sh3: sh3 generic code
As commented, in-chip device drivers are put into sys/arch/sh3/dev.
- sys/arch/evbsh3: sh3 evaluation boards (pure sh3 CPU, no fancy external HW)
- sys/arch/mmeye: Brains mmEye, www.brains.co.jp
MI source code includes couple of #ifdef for sh3-coff support.
(sh3 uses coff or elf)

Needs some more improvements, especialy in sys/arch/sh3/conf/files.sh3,
to compile the tree (due to last minute tree structure change).
 1.1.2.2 11-Feb-2001  bouyer Sync with HEAD.
 1.1.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.3.4.2 08-Oct-2001  he Pull up revision 1.5 (requested by msaitoh):
Add missing macros for 8-bit PCMCIA access.
 1.3.4.1 30-Jun-2000  simonb Pull up revision 1.4 (requested by simonb):
Pull up mmap paddr_t/off_t changes from trunk.
 1.5.4.3 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.5.4.2 16-Mar-2002  jdolecek Catch up with -current.
 1.5.4.1 03-Aug-2001  lukem update to -current
 1.9.22.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.9.20.1 29-Apr-2005  kent sync with -current
 1.9.12.2 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.9.12.1 01-Apr-2005  skrll Sync with HEAD.
 1.9.6.2 28-Apr-2002  uch Use "#define<tab>", white space nits.
 1.9.6.1 28-Apr-2002  uch file bus.h was added on branch nathanw_sa on 2002-04-28 17:10:34 +0000
 1.10.4.1 21-Jun-2006  yamt sync with head.
 1.13.2.2 18-Feb-2006  yamt sync with head.
 1.13.2.1 01-Feb-2006  yamt sync with head.
 1.14.4.1 22-Apr-2006  simonb Sync with head.
 1.14.2.1 09-Sep-2006  rpaulo sync with head
 1.16.72.2 11-Aug-2010  yamt sync with head.
 1.16.72.1 16-May-2008  yamt sync with head.
 1.16.70.1 18-May-2008  yamt sync with head.
 1.16.68.1 02-Jun-2008  mjf Sync with HEAD.
 1.17.20.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.2 23-Sep-2019  skrll Provide PRIxBUSADDR, PRIxBUSSIZE, PRIuBUSSIZE, and PRIxBSH for all arches
to follow arm and (generic) mips.

Reviewed by christos.
 1.1 01-Jul-2011  dyoung branches: 1.1.54;
Per discussion at
<http://mail-index.netbsd.org/tech-kern/2010/04/02/msg007941.html>,
divide each machine's bus.h into bus_defs.h (constants & data types)
and bus_funcs.h (macro implementations of bus_space(9) routines and MD
prototypes).

Note that some bus_space(9) routines' implementation will move to .c
files from inline subroutines or macros in .h files.

I've only made the split for machine architectures where there is PCI.
All of the non-PCI-having architectures will require a similar split.

These #include files are not referenced by any (committed) Makefiles or
header files, yet. Changes to Makefiles, to <sys/bus.h>, and to some
more machine-dependent files will dribble in before I throw the switch.
 1.1.54.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.4 25-Jul-2011  dyoung Move some macros back to sh3/include/bus_funcs.h from
sh3/sh3/sh3_machdep.c, where I moved them by mistake.

Pull the bus_space(9) routines into a new module,
sh3/sh3/sh3_bus_space.c, that is built only on !landisk.

Fixes the mmeye and landisk builds. Should fix other sh3 ports.
 1.3 25-Jul-2011  dyoung Move the sh_memio_*() declarations back to sh3/include/bus_funcs.h.
Should fix the mmeye build.
 1.2 20-Jul-2011  dyoung Remove redundant, static inline bus_space(9) declarations
from sh3/bus_funcs.h and move the non-inline definitions to
sh3/sh3_machdep.c.
 1.1 01-Jul-2011  dyoung Per discussion at
<http://mail-index.netbsd.org/tech-kern/2010/04/02/msg007941.html>,
divide each machine's bus.h into bus_defs.h (constants & data types)
and bus_funcs.h (macro implementations of bus_space(9) routines and MD
prototypes).

Note that some bus_space(9) routines' implementation will move to .c
files from inline subroutines or macros in .h files.

I've only made the split for machine architectures where there is PCI.
All of the non-PCI-having architectures will require a similar split.

These #include files are not referenced by any (committed) Makefiles or
header files, yet. Changes to Makefiles, to <sys/bus.h>, and to some
more machine-dependent files will dribble in before I throw the switch.
 1.4 17-Feb-2006  skrll branches: 1.4.12;
Match comment against #endif with #ifdef
 1.3 16-Feb-2006  perry 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.2 02-Feb-2006  skrll branches: 1.2.2;
Fix the multiple inclusion protection. hi dsl.
 1.1 31-Jan-2006  dsl branches: 1.1.2; 1.1.4;
Make the sh3 bswap headers look like all the other ports
 1.1.4.3 18-Feb-2006  yamt sync with head.
 1.1.4.2 01-Feb-2006  yamt sync with head.
 1.1.4.1 31-Jan-2006  yamt file byte_swap.h was added on branch yamt-uio_vmspace on 2006-02-01 14:51:31 +0000
 1.1.2.1 09-Sep-2006  rpaulo sync with head
 1.2.2.1 22-Apr-2006  simonb Sync with head.
 1.4.12.2 21-Jun-2006  yamt sync with head.
 1.4.12.1 17-Feb-2006  yamt file byte_swap.h was added on branch yamt-lazymbuf on 2006-06-21 14:55:31 +0000
 1.9 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.8 24-Sep-2006  tsutsui branches: 1.8.52; 1.8.54; 1.8.56;
Allow shared PV mappings in pmap_enter(9) even on SH4 if VAs of shared pages
have the same virtual cache indexes (i.e. they won't cause virtual cache
aliases). Also prepare PMAP_PREFER(9) for SH4 to avoid some possible virtual
cache aliases.
More stuff should be added in pmap_enter(9), but at least this changes
should fix some existing problems. See discussion on port-sh3 ML for details.

OK'ed by uwe and chs, and closes PR port-sh3/34243.
 1.7 21-Jan-2006  uwe branches: 1.7.18; 1.7.20;
There's no need to duplicate cpu type ifdef dance here. cputypes.h
already defines CPU_IS_SH[34] as constants for kernels that support
only single cpu type.
 1.6 11-Dec-2005  christos branches: 1.6.2;
merge ktrace-lwp.
 1.5 29-Jun-2005  christos branches: 1.5.2;
more info for sh4 from nonaka's landisk port.
 1.4 09-May-2002  uch branches: 1.4.6; 1.4.12;
remove obsolete interface. add defines for inquire cache feature.
 1.3 28-Apr-2002  uch Use "#define<tab>", white space nits.
 1.2 17-Feb-2002  uch branches: 1.2.2; 1.2.8;
change register naming.
 1.1 11-Feb-2002  uch add new cache routine.
 1.2.8.3 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.2.8.2 16-Mar-2002  jdolecek Catch up with -current.
 1.2.8.1 17-Feb-2002  jdolecek file cache.h was added on branch kqueue on 2002-03-16 15:59:36 +0000
 1.2.2.2 20-Jun-2002  nathanw Catch up to -current.
 1.2.2.1 28-Feb-2002  nathanw Catch up to -current.
 1.4.12.1 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.4.6.2 09-May-2002  uch remove obsolete interface. add defines for inquire cache feature.
 1.4.6.1 09-May-2002  uch file cache.h was added on branch nathanw_sa on 2002-05-09 12:30:46 +0000
 1.5.2.2 30-Dec-2006  yamt sync with head.
 1.5.2.1 21-Jun-2006  yamt sync with head.
 1.6.2.1 01-Feb-2006  yamt sync with head.
 1.7.20.1 22-Oct-2006  yamt sync with head
 1.7.18.1 18-Nov-2006  ad Sync with head.
 1.8.56.1 16-May-2008  yamt sync with head.
 1.8.54.1 18-May-2008  yamt sync with head.
 1.8.52.1 02-Jun-2008  mjf Sync with HEAD.
 1.10 16-May-2009  nonaka Added SH7706 cache flush op.
 1.9 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.8 04-Mar-2006  uwe branches: 1.8.68; 1.8.70; 1.8.72;
s/u_intN_t/uintN_t/
 1.7 24-Dec-2005  perry branches: 1.7.4; 1.7.6;
__asm__ -> __asm
__const__ -> const
__inline__ -> inline
__volatile__ -> volatile
 1.6 28-Apr-2002  uch branches: 1.6.6; 1.6.28;
Use "#define<tab>", white space nits.
 1.5 17-Mar-2002  uch cosmetic changes, fix comments.
 1.4 16-Mar-2002  chs branches: 1.4.2;
only comments may follow #endif on a line.
 1.3 28-Feb-2002  uch branches: 1.3.2;
Cleanup register definition
 1.2 17-Feb-2002  uch change register naming.
 1.1 11-Feb-2002  uch add new cache routine.
 1.3.2.3 20-Jun-2002  nathanw Catch up to -current.
 1.3.2.2 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.3.2.1 28-Feb-2002  nathanw Catch up to -current.
 1.4.2.3 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.4.2.2 16-Mar-2002  jdolecek Catch up with -current.
 1.4.2.1 16-Mar-2002  jdolecek file cache_sh3.h was added on branch kqueue on 2002-03-16 15:59:36 +0000
 1.6.28.1 21-Jun-2006  yamt sync with head.
 1.6.6.2 28-Apr-2002  uch Use "#define<tab>", white space nits.
 1.6.6.1 28-Apr-2002  uch file cache_sh3.h was added on branch nathanw_sa on 2002-04-28 17:10:34 +0000
 1.7.6.1 22-Apr-2006  simonb Sync with head.
 1.7.4.1 09-Sep-2006  rpaulo sync with head
 1.8.72.2 20-Jun-2009  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 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.11 04-Mar-2006  uwe branches: 1.11.68; 1.11.70; 1.11.72;
s/u_intN_t/uintN_t/
 1.10 24-Dec-2005  perry branches: 1.10.4; 1.10.6;
__asm__ -> __asm
__const__ -> const
__inline__ -> inline
__volatile__ -> volatile
 1.9 11-Dec-2005  christos merge ktrace-lwp.
 1.8 07-Jul-2005  nonaka Added EMODE cache operation.
 1.7 30-Jun-2005  nonaka branches: 1.7.2;
remove EMODE support code.
- EMODE support doesn't work fine yet.
- This code is broken for dreamcast.
dramcast call sh4_icache_sync_all() before sh4_cache_config().
(at locore.S)
 1.6 29-Jun-2005  christos more additions from nonaka's landisk port.
 1.5 28-Apr-2002  uch branches: 1.5.6; 1.5.12;
Use "#define<tab>", white space nits.
 1.4 17-Mar-2002  uch cosmetic changes, fix comments.
 1.3 28-Feb-2002  uch branches: 1.3.2; 1.3.8;
Cleanup register definition
 1.2 17-Feb-2002  uch change register naming.
 1.1 11-Feb-2002  uch add new cache routine.
 1.3.8.3 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.3.8.2 16-Mar-2002  jdolecek Catch up with -current.
 1.3.8.1 28-Feb-2002  jdolecek file cache_sh4.h was added on branch kqueue on 2002-03-16 15:59:36 +0000
 1.3.2.3 20-Jun-2002  nathanw Catch up to -current.
 1.3.2.2 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.3.2.1 28-Feb-2002  nathanw Catch up to -current.
 1.5.12.1 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.5.6.2 28-Apr-2002  uch Use "#define<tab>", white space nits.
 1.5.6.1 28-Apr-2002  uch file cache_sh4.h was added on branch nathanw_sa on 2002-04-28 17:10:34 +0000
 1.7.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.72.1 16-May-2008  yamt sync with head.
 1.11.70.1 18-May-2008  yamt sync with head.
 1.11.68.1 02-Jun-2008  mjf Sync with HEAD.
 1.3 28-Feb-2002  uch branches: 1.3.10;
Cleanup register definition
 1.2 17-Jan-2000  msaitoh branches: 1.2.8;
add some bit definitions
 1.1 13-Sep-1999  itojun branches: 1.1.2;
Merge in NetBSD/sh3 from cvs.kame.net repository.

Tree structure:
- sys/arch/sh3: sh3 generic code
As commented, in-chip device drivers are put into sys/arch/sh3/dev.
- sys/arch/evbsh3: sh3 evaluation boards (pure sh3 CPU, no fancy external HW)
- sys/arch/mmeye: Brains mmEye, www.brains.co.jp
MI source code includes couple of #ifdef for sh3-coff support.
(sh3 uses coff or elf)

Needs some more improvements, especialy in sys/arch/sh3/conf/files.sh3,
to compile the tree (due to last minute tree structure change).
 1.1.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.2.8.1 16-Mar-2002  jdolecek Catch up with -current.
 1.3.10.2 28-Feb-2002  uch Cleanup register definition
 1.3.10.1 28-Feb-2002  uch file ccrreg.h was added on branch nathanw_sa on 2002-02-28 01:56:58 +0000
 1.6 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.5 28-Apr-2002  uch branches: 1.5.6; 1.5.152; 1.5.156;
Use "#define<tab>", white space nits.
 1.4 17-Mar-2002  uch cosmetic changes, fix comments.
 1.3 16-Dec-2001  thorpej Consider __NO_LEADING_UNDERSCORES__ provided by the new ELF toolchain.
 1.2 25-Feb-2001  msaitoh branches: 1.2.4;
check __LEADING_UNDERSCORE instead of __sh3__
 1.1 13-Sep-1999  itojun branches: 1.1.2;
Merge in NetBSD/sh3 from cvs.kame.net repository.

Tree structure:
- sys/arch/sh3: sh3 generic code
As commented, in-chip device drivers are put into sys/arch/sh3/dev.
- sys/arch/evbsh3: sh3 evaluation boards (pure sh3 CPU, no fancy external HW)
- sys/arch/mmeye: Brains mmEye, www.brains.co.jp
MI source code includes couple of #ifdef for sh3-coff support.
(sh3 uses coff or elf)

Needs some more improvements, especialy in sys/arch/sh3/conf/files.sh3,
to compile the tree (due to last minute tree structure change).
 1.1.2.1 12-Mar-2001  bouyer Sync with HEAD.
 1.2.4.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.2.4.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.5.156.1 18-Feb-2012  mrg merge to -current.
 1.5.152.1 17-Apr-2012  yamt sync with head
 1.5.6.2 28-Apr-2002  uch Use "#define<tab>", white space nits.
 1.5.6.1 28-Apr-2002  uch file cdefs.h was added on branch nathanw_sa on 2002-04-28 17:10:34 +0000
 1.5 11-Jul-2020  uwe Fix doc comment for sh_clock_init.

Forgot to update it back in 2006 when sh3 ports were converted to
todr(9) and its second argument (struct rtc_ops) was removed.
 1.4 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.3 20-Sep-2006  uwe branches: 1.3.52; 1.3.54; 1.3.56;
Switch the rest of sh3 ports to todr(9)
Split code to handle on-chip rtc into a separate driver
Eliminate all todr code from clock.c
Move __HAVE_GENERIC_TODR to sh3/include/types.h
 1.2 28-Apr-2002  uch branches: 1.2.6; 1.2.28; 1.2.58; 1.2.60;
Use "#define<tab>", white space nits.
 1.1 22-Feb-2002  uch branches: 1.1.2; 1.1.8;
New NetBSD/sh3 clock framework.
+ hardclock source is moved from TMU1 to TMU0.
+ SH3/SH4 common kernel support.
+ PCLOCK estimation.
+ remove duplicated code.
 1.1.8.3 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.1.8.2 16-Mar-2002  jdolecek Catch up with -current.
 1.1.8.1 22-Feb-2002  jdolecek file clock.h was added on branch kqueue on 2002-03-16 15:59:37 +0000
 1.1.2.2 20-Jun-2002  nathanw Catch up to -current.
 1.1.2.1 28-Feb-2002  nathanw Catch up to -current.
 1.2.60.1 22-Oct-2006  yamt sync with head
 1.2.58.1 18-Nov-2006  ad Sync with head.
 1.2.28.1 30-Dec-2006  yamt sync with head.
 1.2.6.2 28-Apr-2002  uch Use "#define<tab>", white space nits.
 1.2.6.1 28-Apr-2002  uch file clock.h was added on branch nathanw_sa on 2002-04-28 17:10:34 +0000
 1.3.56.1 16-May-2008  yamt sync with head.
 1.3.54.1 18-May-2008  yamt sync with head.
 1.3.52.1 02-Jun-2008  mjf Sync with HEAD.
 1.6 28-Apr-2002  uch branches: 1.6.6;
Use "#define<tab>", white space nits.
 1.5 17-Mar-2002  uch cosmetic changes, fix comments.
 1.4 02-Aug-2000  msaitoh branches: 1.4.4;
check _BYTE_ORDER instead of BYTE_ORDER
 1.3 04-Jun-2000  mycroft branches: 1.3.2;
Move a bunch of the COFF definitions into exec_coff.h, so they can be used by
other code. XXX Not tested on SH3 yet.
 1.2 02-Jan-2000  msaitoh branches: 1.2.2;
EXEC_COFF cleanup
 1.1 13-Sep-1999  itojun branches: 1.1.2;
Merge in NetBSD/sh3 from cvs.kame.net repository.

Tree structure:
- sys/arch/sh3: sh3 generic code
As commented, in-chip device drivers are put into sys/arch/sh3/dev.
- sys/arch/evbsh3: sh3 evaluation boards (pure sh3 CPU, no fancy external HW)
- sys/arch/mmeye: Brains mmEye, www.brains.co.jp
MI source code includes couple of #ifdef for sh3-coff support.
(sh3 uses coff or elf)

Needs some more improvements, especialy in sys/arch/sh3/conf/files.sh3,
to compile the tree (due to last minute tree structure change).
 1.1.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.2.2.1 22-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.3.2.1 08-Aug-2000  msaitoh Pullup revision 1.4 (approved by thorpej):

check _BYTE_ORDER instead of BYTE_ORDER to fix namespace pollution
(it's necessary to compile src/usr.bin/xlint/llib)
 1.4.4.1 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.6.6.2 28-Apr-2002  uch Use "#define<tab>", white space nits.
 1.6.6.1 28-Apr-2002  uch file coff_machdep.h was added on branch nathanw_sa on 2002-04-28 17:10:34 +0000
 1.5 28-Apr-2002  uch branches: 1.5.6;
Use "#define<tab>", white space nits.
 1.4 17-Mar-2002  uch cosmetic changes, fix comments.
 1.3 28-Feb-2002  uch Cleanup register definition
 1.2 16-Sep-1999  msaitoh branches: 1.2.16;
remove extra Id
 1.1 13-Sep-1999  itojun Merge in NetBSD/sh3 from cvs.kame.net repository.

Tree structure:
- sys/arch/sh3: sh3 generic code
As commented, in-chip device drivers are put into sys/arch/sh3/dev.
- sys/arch/evbsh3: sh3 evaluation boards (pure sh3 CPU, no fancy external HW)
- sys/arch/mmeye: Brains mmEye, www.brains.co.jp
MI source code includes couple of #ifdef for sh3-coff support.
(sh3 uses coff or elf)

Needs some more improvements, especialy in sys/arch/sh3/conf/files.sh3,
to compile the tree (due to last minute tree structure change).
 1.2.16.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.2.16.1 16-Mar-2002  jdolecek Catch up with -current.
 1.5.6.2 28-Apr-2002  uch Use "#define<tab>", white space nits.
 1.5.6.1 28-Apr-2002  uch file cpgreg.h was added on branch nathanw_sa on 2002-04-28 17:10:35 +0000
 1.61 23-Feb-2022  andvar fix various typos in comments, mainly immediatly/immediately/,
as well shared and recently fixed typos in OpenBSD code by Jonathan Grey.
 1.60 03-Aug-2020  uwe SH3_P2SEG_FUNC(f) - get a P2 address of a function.


Just SH3_P1SEG_TO_P2SEG + cast, but we now define SH3_P1SEG_TO_P2SEG
and SH3_P2SEG_TO_P1SEG to use arithmetic, not bitwise ops. That gives
the same result for the correct P1/P2 input values, but addition can
be done at link time with addends. Thus SH3_P2SEG_FUNC compiles to a
constant P2 address.
 1.59 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.58 23-Nov-2019  ad cpu_need_resched():

- Remove all code that should be MI, leaving the bare minimum under arch/.
- Make the required actions very explicit.
- Pass in LWP pointer for convenience.
- When a trap is required on another CPU, have the IPI set it locally.
- Expunge cpu_did_resched().
 1.57 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.56 19-Oct-2013  christos branches: 1.56.28; 1.56.30;
make cpu_need_resched() macros consistent; __USE flags
 1.55 22-Dec-2010  nisimura branches: 1.55.8; 1.55.18; 1.55.22;
PROC_PC() should have been changed to LWP_PC().
 1.54 21-Oct-2009  rmind branches: 1.54.4;
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 22-Mar-2008  uwe branches: 1.53.4;
Revert interrupt stack changes. There are some issues and, at least
in the current form, they complicate implementation of fast software
interrupts. I'd rather get fast softints in now and may be revisit
interrupt stack later.
 1.52 16-Mar-2008  uwe Rewrite RUN_P2, RUN_P1 in asm. gcc4 is too happy to optimize away
assigned-goto versions if try to do anything fancy with them
(discovered by trying to wrap RUN_P2 into an "if").
 1.51 27-Feb-2008  xtraeme Remove CTL_MACHDEP_NAMES, it's not used anywhere.

Ok by martin@.
 1.50 07-Jan-2008  uwe branches: 1.50.2; 1.50.6;
Now that sh3 has didicated interrupt stack we can check for cpu_intr_p
with simple sp comparison, so we can drop ci_idepth.
 1.49 14-Dec-2007  uwe Use dedicated interrupt stack. Tested on hpcsh and landisk. This has
been sitting in my tree for quite a while. While here s/top/bottom/
in a few places related to stacks to confirm to conventional
terminology.
 1.48 03-Dec-2007  ad branches: 1.48.2; 1.48.6;
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.47 17-Oct-2007  garbled branches: 1.47.2;
Merge the ppcoea-renovation branch to HEAD.

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

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

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.46 01-Oct-2007  ad Make want_resched a member of cpu_info.
 1.45 04-Aug-2007  ad branches: 1.45.2; 1.45.4;
Add ci_cpuid where it's missing.
 1.44 17-May-2007  yamt branches: 1.44.2; 1.44.4; 1.44.8;
merge yamt-idlelwp branch. asked by core@. some ports still needs work.

from doc/BRANCHES:

idle lwp, and some changes depending on it.

1. separate context switching and thread scheduling.
(cf. gmcgarry_ctxsw)
2. implement idle lwp.
3. clean up related MD/MI interfaces.
4. make scheduler(s) modular.
 1.43 16-Feb-2007  ad branches: 1.43.2; 1.43.6; 1.43.8; 1.43.14;
Remove spllowersoftclock() and CLKF_BASEPRI(), and always dispatch callouts
via a soft interrupt. In the near future, softclock will be run from process
context.
 1.42 09-Feb-2007  ad Merge newlock2 to head.
 1.41 21-Jan-2006  uwe branches: 1.41.18;
Declare cpu_reset as __attribute__((__noreturn__)).
 1.40 21-Jan-2006  uwe Hide RUN_P2 and RUN_P1 from lint.
Drop CONSTCOND as lint doesn't see that code now.
While here, tweak them a bit to use less casts.
 1.39 21-Jan-2006  uwe Use uint32_t.
 1.38 24-Dec-2005  perry branches: 1.38.2;
__asm__ -> __asm
__const__ -> const
__inline__ -> inline
__volatile__ -> volatile
 1.37 11-Dec-2005  christos merge ktrace-lwp.
 1.36 25-Sep-2004  yamt branches: 1.36.12;
include sys/cpu_data.h only if defined(_KERNEL)
 1.35 22-Sep-2004  yamt move some per-cpu data definitions to MI place so that they can be modified
without touching all ports. discussed on tech-kern@.
 1.34 24-Mar-2004  wiz 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.33 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.32 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.31 18-Jan-2003  thorpej branches: 1.31.2;
Merge the nathanw_sa branch.
 1.30 13-Nov-2002  msaitoh add some definitions for P[VR]R register
 1.29 07-May-2002  thorpej branches: 1.29.6;
Make CLKF_INTR() slightly less broken. The previous definition always
tested true if the CPU was running in the kernel at the time of the clock
interrupt, therefore all such time (kernel and idle) was counted as interrupt
time. The new definition simply punts on trying to count interrupt time,
which allows us to see kernel and idle time.
 1.28 28-Apr-2002  uch Use "#define<tab>", white space nits.
 1.27 26-Apr-2002  msaitoh add SH4 Processor Version Register
 1.26 24-Mar-2002  uch Rework interrupt code.
+ Fully utilize SH SR.I[0:3] interrupt level.
+ software interrupt is emulated by TMU1, 2 one shot interrupt.
+ implement generic soft interrupts.
+ implement clockframe correctly.
 1.25 17-Mar-2002  uch cosmetic changes, fix comments.
 1.24 17-Mar-2002  uch change to per-process AST.
 1.23 08-Mar-2002  uch cpu_swapout() moved to cpu.h
 1.22 04-Mar-2002  uch CTL_MACHDEP definitions are integrated into sh3/include/cpu.h again.
 1.21 03-Mar-2002  uch machine dependent sysctl are moved to machine/cpu.h
dreamcast, hpcsh ... CPU_CONSDEV
mmeye, evbsh3 ... CPU_CONSDEV, CPU_LOADANDRESET
 1.20 28-Feb-2002  uch cpu_dumpconf, reserve_dumppages, dumpsys, cpu_reset are moved to sh3/sh3_machdep.c
 1.19 24-Feb-2002  uch Move common exception vector and scheduler code to
sh3/sh3/exception_vector.S and sh3/sh3/locore_subr.S. exception
vectors are installed by sh_cpu_init(). machine/locore.S contains
kernel entry, interrupt handler, and some MD code.
 1.18 22-Feb-2002  uch New NetBSD/sh3 clock framework.
+ hardclock source is moved from TMU1 to TMU0.
+ SH3/SH4 common kernel support.
+ PCLOCK estimation.
+ remove duplicated code.
 1.17 19-Feb-2002  uch Clean up function declaration.
 1.16 17-Feb-2002  uch Add new MMU API. for detail, see sh3/mmu.h's comment.
 1.15 12-Feb-2002  uch ANSIfy KNF.
 1.14 11-Feb-2002  uch add useful macro for running P2, P1 area.
 1.13 24-Jun-2001  msaitoh branches: 1.13.2;
fix KERNELMODE() macro (check MD bits, too)
 1.12 30-May-2001  mrg use _KERNEL_OPT
 1.11 02-Feb-2001  thorpej branches: 1.11.2;
Add some comments about P/USEG
 1.10 25-Aug-2000  thorpej Make need_resched() take a "struct cpu_info *" argument. This
causes gives a primitive form of processor affinity. Its use in
roundrobin() still needs some work.
 1.9 07-Jun-2000  tsubai branches: 1.9.2;
Remove child_return prototype; it is now in sys/proc.h.
 1.8 26-May-2000  thorpej branches: 1.8.2;
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.7 24-Feb-2000  msaitoh SH4!
 1.6 14-Jan-2000  msaitoh add SH3_{PHYS,P1SEG,P2SEG}_TO_{PHYS,P1SEG,P2SEG} macros
 1.5 24-Dec-1999  msaitoh back to previous one (suggested by cgd)
 1.4 21-Dec-1999  msaitoh move sysctl definitions into ${MACHINE}/include/cpu.h
 1.3 21-Dec-1999  msaitoh G.C.
 1.2 14-Sep-1999  tsubai branches: 1.2.2; 1.2.8;
Catch up with -current.
 1.1 13-Sep-1999  itojun Merge in NetBSD/sh3 from cvs.kame.net repository.

Tree structure:
- sys/arch/sh3: sh3 generic code
As commented, in-chip device drivers are put into sys/arch/sh3/dev.
- sys/arch/evbsh3: sh3 evaluation boards (pure sh3 CPU, no fancy external HW)
- sys/arch/mmeye: Brains mmEye, www.brains.co.jp
MI source code includes couple of #ifdef for sh3-coff support.
(sh3 uses coff or elf)

Needs some more improvements, especialy in sys/arch/sh3/conf/files.sh3,
to compile the tree (due to last minute tree structure change).
 1.2.8.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.2.2.2 11-Feb-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.8.2.1 22-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.9.2.1 08-Oct-2001  he Pull up revision 1.13 (requested by msaitoh):
Fix KERNELMODE macro (check MD bits too).
 1.11.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.13.2.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.13.2.1 16-Mar-2002  jdolecek Catch up with -current.
 1.29.6.4 11-Dec-2002  thorpej Sync with HEAD.
 1.29.6.3 24-Jun-2002  nathanw Curproc->curlwp renaming.

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

"curproc" is now #defined in proc.h as ((curlwp) ? (curlwp)->l_proc) : NULL)
so that it is always safe to reference curproc (*de*referencing curproc
is another story, but that's always been true).
 1.29.6.2 21-Jun-2002  thorpej Add support for scheduler activations on SuperH. Boots multi-user
on Dreamcast (SH4) with stock userland.
 1.29.6.1 07-May-2002  thorpej file cpu.h was added on branch nathanw_sa on 2002-06-21 21:26:27 +0000
 1.31.2.5 19-Oct-2004  skrll Sync with HEAD
 1.31.2.4 24-Sep-2004  skrll Sync with HEAD.
 1.31.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.31.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.31.2.1 03-Aug-2004  skrll Sync with HEAD
 1.36.12.8 24-Mar-2008  yamt sync with head.
 1.36.12.7 17-Mar-2008  yamt sync with head.
 1.36.12.6 21-Jan-2008  yamt sync with head
 1.36.12.5 07-Dec-2007  yamt sync with head
 1.36.12.4 27-Oct-2007  yamt sync with head.
 1.36.12.3 03-Sep-2007  yamt sync with head.
 1.36.12.2 26-Feb-2007  yamt sync with head.
 1.36.12.1 21-Jun-2006  yamt sync with head.
 1.38.2.1 01-Feb-2006  yamt sync with head.
 1.41.18.1 01-Feb-2007  ad Get sh3 compiling.
 1.43.14.2 03-Oct-2007  garbled Sync with HEAD
 1.43.14.1 22-May-2007  matt Update to HEAD.
 1.43.8.1 11-Jul-2007  mjf Sync with head.
 1.43.6.4 03-Dec-2007  ad Sync with HEAD.
 1.43.6.3 09-Oct-2007  ad Sync with head.
 1.43.6.2 20-Aug-2007  ad Sync with HEAD.
 1.43.6.1 27-May-2007  ad Sync with head.
 1.43.2.2 05-Apr-2007  uwe Provide cpu_did_resched() that MI code calls with proper locking.
 1.43.2.1 25-Mar-2007  uwe Adapt sh3 to yamt-idlelwp.
 1.44.8.3 09-Dec-2007  jmcneill Sync with HEAD.
 1.44.8.2 02-Oct-2007  joerg Sync with HEAD.
 1.44.8.1 04-Aug-2007  jmcneill Sync with HEAD.
 1.44.4.1 15-Aug-2007  skrll Sync with HEAD.
 1.44.2.1 07-Aug-2007  matt Sync with HEAD.
 1.45.4.1 06-Oct-2007  yamt sync with head.
 1.45.2.3 23-Mar-2008  matt sync with HEAD
 1.45.2.2 09-Jan-2008  matt sync with HEAD
 1.45.2.1 06-Nov-2007  matt sync with HEAD
 1.47.2.3 18-Feb-2008  mjf Sync with HEAD.
 1.47.2.2 27-Dec-2007  mjf Sync with HEAD.
 1.47.2.1 08-Dec-2007  mjf Sync with HEAD.
 1.48.6.2 08-Jan-2008  bouyer Sync with HEAD
 1.48.6.1 02-Jan-2008  bouyer Sync with HEAD
 1.48.2.1 26-Dec-2007  ad Sync with head.
 1.50.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.50.2.1 24-Mar-2008  keiichi sync with head.
 1.53.4.1 11-Mar-2010  yamt sync with head
 1.54.4.1 05-Mar-2011  rmind sync with head
 1.55.22.1 18-May-2014  rmind sync with head
 1.55.18.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.55.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.56.30.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.56.30.1 10-Jun-2019  christos Sync with HEAD
 1.56.28.1 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.15 03-Mar-2002  uch branches: 1.15.8;
SR related parts moved to psl.h. cpufunc.h segments.h are removed.
kernel mode checking is only SR.MD. no check stack pointer.
 1.14 28-Feb-2002  uch Cleanup register definition
 1.13 22-Feb-2002  uch New NetBSD/sh3 clock framework.
+ hardclock source is moved from TMU1 to TMU0.
+ SH3/SH4 common kernel support.
+ PCLOCK estimation.
+ remove duplicated code.
 1.12 19-Feb-2002  uch Clean up functions
disable_intr, enable_intr, disable_interrupt, enable_interrupt,
disable_ext_intr, enable_ext_intr.
New functions:
for external interrupt:
_cpu_intr_suspend and _cpu_intr_resume.
for exception:
_cpu_exception_suspend and _cpu_exception_resume.
 1.11 17-Feb-2002  uch Add new MMU API. for detail, see sh3/mmu.h's comment.
 1.10 12-Feb-2002  uch ANSIfy KNF.
 1.9 11-Feb-2002  uch add new cache routine.
 1.8 08-Feb-2002  uch add SH-internal memory mapped register access method.
 1.7 24-Jun-2001  msaitoh branches: 1.7.2;
use MMUCR_TF macro defined in mmureg.h
 1.6 06-Sep-2000  tsubai Add breakpoint().
 1.5 04-Sep-2000  msaitoh - move MMUCR_VALIDBITS definition into mmureg.h.
- access correct address in cacheflush().
 1.4 24-Feb-2000  msaitoh branches: 1.4.4;
SH4!
 1.3 12-Jan-2000  msaitoh KNF
 1.2 16-Sep-1999  msaitoh branches: 1.2.2;
enclose tlbflush(), disable_intr() and enable_intr() with #ifder _KERNEL
 1.1 13-Sep-1999  itojun Merge in NetBSD/sh3 from cvs.kame.net repository.

Tree structure:
- sys/arch/sh3: sh3 generic code
As commented, in-chip device drivers are put into sys/arch/sh3/dev.
- sys/arch/evbsh3: sh3 evaluation boards (pure sh3 CPU, no fancy external HW)
- sys/arch/mmeye: Brains mmEye, www.brains.co.jp
MI source code includes couple of #ifdef for sh3-coff support.
(sh3 uses coff or elf)

Needs some more improvements, especialy in sys/arch/sh3/conf/files.sh3,
to compile the tree (due to last minute tree structure change).
 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.4.1 21-Sep-2000  msaitoh pullup a part of rev. 1.5 (approved by thorpej):

access correct address in cacheflush().
 1.7.2.1 16-Mar-2002  jdolecek Catch up with -current.
 1.15.8.2 03-Mar-2002  uch SR related parts moved to psl.h. cpufunc.h segments.h are removed.
kernel mode checking is only SR.MD. no check stack pointer.
 1.15.8.1 03-Mar-2002  uch file cpufunc.h was added on branch nathanw_sa on 2002-03-03 14:31:26 +0000
 1.14 28-Jul-2020  skrll _LKM -> _MODULE
 1.13 25-Jul-2020  uwe Define CPU_PRODUCT_STX7105.

I'm not sure if this should rather be named CPU_PRODUCT_ST40_300, but
that's probably too general. These constants don't have to be
backward compatible, so we can re-do this properly later if we need to.
 1.12 21-Apr-2009  nonaka Add SH7706
 1.11 28-Apr-2008  martin branches: 1.11.8; 1.11.14;
Remove clause 3 and 4 from TNF licenses
 1.10 21-Jan-2006  uwe branches: 1.10.72; 1.10.74; 1.10.76;
Add CONSTCOND to make lint happy.
 1.9 11-Dec-2005  christos branches: 1.9.2;
merge ktrace-lwp.
 1.8 29-Jun-2005  christos branches: 1.8.2;
more additions from nonaka's landisk port.
 1.7 28-Apr-2002  uch branches: 1.7.6; 1.7.12;
Use "#define<tab>", white space nits.
 1.6 23-Apr-2002  uch remove duplicated SH3, SH4 define.
 1.5 20-Apr-2002  thorpej * Defflag the SH3 and SH4 options.
* In <sh3/cputypes.h>, always define both SH3 and SH4 if _LKM is defined.
 1.4 16-Apr-2002  uch Define all CPU types if _LKM is defined.
 1.3 24-Mar-2002  uch Rework interrupt code.
+ Fully utilize SH SR.I[0:3] interrupt level.
+ software interrupt is emulated by TMU1, 2 one shot interrupt.
+ implement generic soft interrupts.
+ implement clockframe correctly.
 1.2 17-Feb-2002  uch To determine CPU architecture and product, add cpu_arch and cpu_prduct variables.
these are initialized by sh_cpu_init()@sh3/sh3_machdep.c
(see sh3/include/cputypes.h for detail.)
add "options SH3" for SH3 kernel config file.
 1.1 13-Sep-1999  itojun branches: 1.1.16;
Merge in NetBSD/sh3 from cvs.kame.net repository.

Tree structure:
- sys/arch/sh3: sh3 generic code
As commented, in-chip device drivers are put into sys/arch/sh3/dev.
- sys/arch/evbsh3: sh3 evaluation boards (pure sh3 CPU, no fancy external HW)
- sys/arch/mmeye: Brains mmEye, www.brains.co.jp
MI source code includes couple of #ifdef for sh3-coff support.
(sh3 uses coff or elf)

Needs some more improvements, especialy in sys/arch/sh3/conf/files.sh3,
to compile the tree (due to last minute tree structure change).
 1.1.16.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.1.16.1 16-Mar-2002  jdolecek Catch up with -current.
 1.7.12.1 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.7.6.2 28-Apr-2002  uch Use "#define<tab>", white space nits.
 1.7.6.1 28-Apr-2002  uch file cputypes.h was added on branch nathanw_sa on 2002-04-28 17:10:35 +0000
 1.8.2.1 21-Jun-2006  yamt sync with head.
 1.9.2.1 01-Feb-2006  yamt sync with head.
 1.10.76.2 04-May-2009  yamt sync with head.
 1.10.76.1 16-May-2008  yamt sync with head.
 1.10.74.1 18-May-2008  yamt sync with head.
 1.10.72.1 02-Jun-2008  mjf Sync with HEAD.
 1.11.14.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.11.8.1 28-Apr-2009  skrll Sync with HEAD.
 1.2 11-Dec-2005  christos merge ktrace-lwp.
 1.1 05-Nov-2003  uwe branches: 1.1.4;
Register definitions for SH7709 DAC.
 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 05-Nov-2003  skrll file dacreg.h was added on branch ktrace-lwp on 2004-08-03 10:40:15 +0000
 1.3 10-May-2002  uch branches: 1.3.4;
clean up disassembler code.
 1.2 28-Apr-2002  uch Use "#define<tab>", white space nits.
 1.1 13-Sep-1999  itojun branches: 1.1.16;
Merge in NetBSD/sh3 from cvs.kame.net repository.

Tree structure:
- sys/arch/sh3: sh3 generic code
As commented, in-chip device drivers are put into sys/arch/sh3/dev.
- sys/arch/evbsh3: sh3 evaluation boards (pure sh3 CPU, no fancy external HW)
- sys/arch/mmeye: Brains mmEye, www.brains.co.jp
MI source code includes couple of #ifdef for sh3-coff support.
(sh3 uses coff or elf)

Needs some more improvements, especialy in sys/arch/sh3/conf/files.sh3,
to compile the tree (due to last minute tree structure change).
 1.1.16.1 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.3.4.2 10-May-2002  uch clean up disassembler code.
 1.3.4.1 10-May-2002  uch file db_disasm.h was added on branch nathanw_sa on 2002-05-10 15:27:06 +0000
 1.18 02-Sep-2023  andvar remove (db_addr_t) cast in sh3 PC_REGS(regs) definition.

Fixes KGDB build option for SH3/4 code.
 1.17 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.16 26-May-2011  joerg branches: 1.16.14;
Introduce DDB_EXPR_FMT and replace the logic around DB_EXPR_T_IS_QUAD.
 1.15 14-Jan-2011  rmind branches: 1.15.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.14 07-Jun-2008  uwe branches: 1.14.20;
Fix IS_BREAKPOINT_TRAP: EXP_BREAK is not a breakpoint trap, it's UBC
(user break controller) trap, and we use UBC for single-stepping, not
for ddb breakpoints. ddb breakpoints are "trapa 0xc3".
 1.13 21-Feb-2007  thorpej branches: 1.13.42; 1.13.44; 1.13.46; 1.13.48;
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.12 10-May-2006  skrll branches: 1.12.14;
Fix a bunch of cast lvalues.
 1.11 01-Apr-2006  cherry 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.10 18-Dec-2005  uwe branches: 1.10.4; 1.10.6; 1.10.8; 1.10.10; 1.10.12;
Declare ddb_regs extern in db_machdep.h and provide the defintion in
db_interface.c.
 1.9 29-Apr-2003  scw branches: 1.9.18;
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.8 09-May-2002  uch branches: 1.8.6;
rework general exception, and TLB exception handling for new pmap.
all exception staffs are moved to exception.[ch]
 1.7 28-Apr-2002  uch Use "#define<tab>", white space nits.
 1.6 17-Mar-2002  uch cosmetic changes, fix comments.
 1.5 02-Mar-2002  uch Initial support for KGDB on the sh3.
 1.4 08-Feb-2002  uch TLB dump command added to DDB
 1.3 08-Sep-2000  tsubai branches: 1.3.4;
DDB single step and stack trace support.
 1.2 29-Jun-2000  mrg remove include of <vm/vm.h>. <vm/vm.h> -> <uvm/uvm_extern.h>
 1.1 13-Sep-1999  itojun branches: 1.1.2;
Merge in NetBSD/sh3 from cvs.kame.net repository.

Tree structure:
- sys/arch/sh3: sh3 generic code
As commented, in-chip device drivers are put into sys/arch/sh3/dev.
- sys/arch/evbsh3: sh3 evaluation boards (pure sh3 CPU, no fancy external HW)
- sys/arch/mmeye: Brains mmEye, www.brains.co.jp
MI source code includes couple of #ifdef for sh3-coff support.
(sh3 uses coff or elf)

Needs some more improvements, especialy in sys/arch/sh3/conf/files.sh3,
to compile the tree (due to last minute tree structure change).
 1.1.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.3.4.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.3.4.1 16-Mar-2002  jdolecek Catch up with -current.
 1.8.6.2 09-May-2002  uch rework general exception, and TLB exception handling for new pmap.
all exception staffs are moved to exception.[ch]
 1.8.6.1 09-May-2002  uch file db_machdep.h was added on branch nathanw_sa on 2002-05-09 12:24:21 +0000
 1.9.18.2 26-Feb-2007  yamt sync with head.
 1.9.18.1 21-Jun-2006  yamt sync with head.
 1.10.12.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.10.10.2 11-May-2006  elad sync with head
 1.10.10.1 19-Apr-2006  elad sync with head - hopefully this will work
 1.10.8.2 24-May-2006  yamt sync with head.
 1.10.8.1 11-Apr-2006  yamt sync with head
 1.10.6.2 01-Jun-2006  kardel 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.12.14.1 27-Feb-2007  yamt - sync with head.
- move sched_changepri back to kern_synch.c as it doesn't know PPQ anymore.
 1.13.48.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.13.46.1 04-May-2009  yamt sync with head.
 1.13.44.1 17-Jun-2008  yamt sync with head.
 1.13.42.1 29-Jun-2008  mjf Sync with HEAD.
 1.14.20.2 31-May-2011  rmind sync with head
 1.14.20.1 05-Mar-2011  rmind sync with head
 1.15.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.16.14.1 03-Dec-2017  jdolecek update from HEAD
 1.7 06-Oct-2021  andvar s/embeded/embedded/ in comments and messages.
 1.6 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.5 21-Jan-2006  uwe branches: 1.5.72; 1.5.74; 1.5.76;
Use foo &= ~(type)mask; instead of foo &= (type)~mask; to make lint happy.
While here, convert to uintN_t.
 1.4 24-Dec-2005  perry branches: 1.4.2;
__asm__ -> __asm
__const__ -> const
__inline__ -> inline
__volatile__ -> volatile
 1.3 08-Nov-2002  tsutsui branches: 1.3.22;
Add _reg_bset_[124]() and _reg_bclr_[124]() macro for
SH embeded device registers.
 1.2 28-Apr-2002  uch branches: 1.2.6;
Use "#define<tab>", white space nits.
 1.1 28-Feb-2002  uch branches: 1.1.6; 1.1.10;
Cleanup register definition
 1.1.10.2 20-Jun-2002  nathanw Catch up to -current.
 1.1.10.1 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.1.6.3 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.1.6.2 16-Mar-2002  jdolecek Catch up with -current.
 1.1.6.1 28-Feb-2002  jdolecek file devreg.h was added on branch kqueue on 2002-03-16 15:59:37 +0000
 1.2.6.2 11-Nov-2002  nathanw Catch up to -current
 1.2.6.1 28-Apr-2002  nathanw file devreg.h was added on branch nathanw_sa on 2002-11-11 22:04:02 +0000
 1.3.22.1 21-Jun-2006  yamt sync with head.
 1.4.2.1 01-Feb-2006  yamt sync with head.
 1.5.76.1 16-May-2008  yamt sync with head.
 1.5.74.1 18-May-2008  yamt sync with head.
 1.5.72.1 02-Jun-2008  mjf Sync with HEAD.
 1.9 16-May-2013  christos name it like other ports do
 1.8 23-Nov-2009  pooka branches: 1.8.12; 1.8.22;
If cpu_disklabel includes struct dkbad, define __HAVE_DISKLABEL_DKBAD.
This allows use of subr_disk_mbr on all archs. Default to it for
the rump disk component. No functional change for regular kernels.
(The other option would've been to include dkbad in disklabels
everywhere, but arguably this approach has less possible side-effects,
especially given that wedges and related magic will take over the
world any second now).
 1.7 11-Dec-2005  christos branches: 1.7.78;
merge ktrace-lwp.
 1.6 12-Jun-2005  dyoung Make disklabel(8) and fdisk(8) into "host tools " last step: build
and install ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-disklabel,
${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-fdisk by "reaching over" to
the sources in ${NETBSDSRCDIR}/sbin/{disklabel fdisk}/.

To avoid clashes with a build-host's header files, especially on
*BSD, the host-tools versions of fdisk and disklabel search for
#includes such as disklabel.h, disklabel_acorn.h, disklabel_gpt.h,
and bootinfo.h in a new #includes namespace, nbinclude/. That is,
they #include <nbinclude/sys/disklabel.h>, <nbinclude/machine/disklabel.h>,
<nbinclude/sparc64/disklabel.h>, instead of <sys/disklabel.h> and
such. I have also updated the system headers to #include from
nbinclude/-space when HAVE_NBTOOL_CONFIG_H is #defined.
 1.5 08-Oct-2003  lukem Overhaul MBR handling (part 1):

<sys/bootblock.h>:
* Added definitions for the Master Boot Record (MBR) used by
a variety of systems (primarily i386), including the format
of the BIOS Parameter Block (BPB).
This information was cribbed from a variety of sources
including <sys/disklabel_mbr.h> which this is a superset of.

As part of this, some data structure elements and #defines
were renamed to be more "namespace friendly" and consistent
with other bootblocks and MBR documentation.
Update all uses of the old names to the new names.

<sys/disklabel_mbr.h>:
* Deprecated in favor of <sys/bootblock.h> (the latter is more
"host tool" friendly).

amd64 & i386:
* Renamed /usr/mdec/bootxx_dosfs to /usr/mdec/bootxx_msdos, to
be consistent with the naming convention of the msdosfs tools.

* Removed /usr/mdec/bootxx_ufs, as it's equivalent to bootxx_ffsv1
and it's confusing to have two functionally equivalent bootblocks,
especially given that "ufs" has multiple meanings (it could be
a synonym for "ffs", or the group of ffs/lfs/ext2fs file systems).

* Rework pbr.S (the first sector of bootxx_*):
+ Ensure that BPB (bytes 11..89) and the partition table
(bytes 446..509) do not contain code.
+ Add support for booting from FAT partitions if BOOT_FROM_FAT
is defined. (Only set for bootxx_msdos).
+ Remove "dummy" partition 3; if people want to installboot(8)
these to the start of the disk they can use fdisk(8) to
create a real MBR partition table...
+ Compile with TERSE_ERROR so it fits because of the above.
Whilst this is less user friendly, I feel it's important
to have a valid partition table and BPB in the MBR/PBR.

* Renamed /usr/mdec/biosboot to /usr/mdec/boot, to be consistent
with other platforms.

* Enable SUPPORT_DOSFS in /usr/mdec/boot (stage2), so that
we can boot off FAT partitions.

* Crank version of /usr/mdec/boot to 3.1, and fix some of the other
entries in the version file.

installboot(8) (i386):
* Read the existing MBR of the filesystem and retain the BIOS
Parameter Block (BPB) in bytes 11..89 and the MBR partition
table in bytes 446..509. (Previously installboot(8) would
trash those two sections of the MBR.)

mbrlabel(8):
* Use sys/lib/libkern/xlat_mbr_fstype.c instead of homegrown code
to map the MBR partition type to the NetBSD disklabel type.


Test built "make release" for i386, and new bootblocks verified to work
(even off FAT!).
 1.4 22-May-2002  uch branches: 1.4.2; 1.4.8;
change disklabel to
16 partition.
no bsd area of the disk.
 1.3 28-Apr-2002  uch branches: 1.3.2;
Use "#define<tab>", white space nits.
 1.2 12-Feb-2002  uch ANSIfy KNF.
 1.1 13-Sep-1999  itojun branches: 1.1.16;
Merge in NetBSD/sh3 from cvs.kame.net repository.

Tree structure:
- sys/arch/sh3: sh3 generic code
As commented, in-chip device drivers are put into sys/arch/sh3/dev.
- sys/arch/evbsh3: sh3 evaluation boards (pure sh3 CPU, no fancy external HW)
- sys/arch/mmeye: Brains mmEye, www.brains.co.jp
MI source code includes couple of #ifdef for sh3-coff support.
(sh3 uses coff or elf)

Needs some more improvements, especialy in sys/arch/sh3/conf/files.sh3,
to compile the tree (due to last minute tree structure change).
 1.1.16.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.1.16.1 16-Mar-2002  jdolecek Catch up with -current.
 1.3.2.1 30-May-2002  gehenna Catch up with -current.
 1.4.8.4 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.4.8.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.4.8.2 18-Sep-2004  skrll Sync with HEAD.
 1.4.8.1 03-Aug-2004  skrll Sync with HEAD
 1.4.2.2 22-May-2002  uch change disklabel to
16 partition.
no bsd area of the disk.
 1.4.2.1 22-May-2002  uch file disklabel.h was added on branch nathanw_sa on 2002-05-22 15:01:34 +0000
 1.7.78.1 11-Mar-2010  yamt sync with head
 1.8.22.1 23-Jun-2013  tls resync from head
 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.5 30-Sep-2025  rillig sh3/dmacreg.h: revert snprintb change

The the snprintb format strings produced nice-looking output, even
though they combine the 'f' and ':' conversions, which in other cases
can produce garbled output. Instead of "fixing" these particular format
strings, the snprintb function should allow these variants.
 1.4 29-Sep-2025  rillig sh3/dmacreg.h: fix snprintb definitions

In the previous definitions, the 'f' conversion was combined with the
':' conversion, which snprintb rejects at runtime, starting with
snprintb.c 1.47 from 2024-04-07.
 1.3 29-Mar-2007  uwe Include #include <sh3/devreg.h> like other *reg.h do.
 1.2 11-Dec-2005  christos branches: 1.2.26; 1.2.30; 1.2.32;
merge ktrace-lwp.
 1.1 08-Apr-2004  uwe branches: 1.1.2; 1.1.14;
Register definitions for sh3 integrated DMA controller.
 1.1.14.1 03-Sep-2007  yamt sync with head.
 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-Apr-2004  skrll file dmacreg.h was added on branch ktrace-lwp on 2004-08-03 10:40:16 +0000
 1.2.32.1 11-Jul-2007  mjf Sync with head.
 1.2.30.1 10-Apr-2007  ad Sync with head.
 1.2.26.1 15-Apr-2007  yamt sync with head.
 1.13 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.12 05-Dec-2016  joerg binutils decided to shuffle around its extensions a long time ago. Since
we don't actually use them for anything, follow them.
 1.11 23-Oct-2014  christos branches: 1.11.2; 1.11.4;
instead of bitching about the missing endianness, get it.
 1.10 30-May-2009  skrll branches: 1.10.22; 1.10.38;
Add TLS relocation definitions.
 1.9 25-Nov-2006  riz branches: 1.9.56;
Don't worry about the ELF32_MACHDEP_ENDIANNESS macro when compiling
a host tool - it's never used there.
 1.8 28-Apr-2002  uch branches: 1.8.6; 1.8.28; 1.8.58; 1.8.60;
Use "#define<tab>", white space nits.
 1.7 29-Jan-2002  thorpej Add SuperH ELF header flags.
 1.6 29-Jan-2002  thorpej Add SuperH relocation types.
 1.5 09-Dec-2001  thorpej Add support for dumping ELF-cormat core files.
 1.4 29-Mar-2001  marcus branches: 1.4.2;
When the endians are little, they are little.
 1.3 02-Apr-2000  minoura branches: 1.3.6;
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.2 25-Oct-1999  kleink Update to match new SVR4-style definition names in <sys/exec_elf.h>.
 1.1 13-Sep-1999  itojun branches: 1.1.2; 1.1.4; 1.1.6;
Merge in NetBSD/sh3 from cvs.kame.net repository.

Tree structure:
- sys/arch/sh3: sh3 generic code
As commented, in-chip device drivers are put into sys/arch/sh3/dev.
- sys/arch/evbsh3: sh3 evaluation boards (pure sh3 CPU, no fancy external HW)
- sys/arch/mmeye: Brains mmEye, www.brains.co.jp
MI source code includes couple of #ifdef for sh3-coff support.
(sh3 uses coff or elf)

Needs some more improvements, especialy in sys/arch/sh3/conf/files.sh3,
to compile the tree (due to last minute tree structure change).
 1.1.6.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.1.4.1 15-Nov-1999  fvdl Sync with -current
 1.1.2.2 21-Apr-2001  bouyer Sync with HEAD
 1.1.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.3.6.1 09-Apr-2001  nathanw Catch up with -current.
 1.4.2.3 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.4.2.2 11-Feb-2002  jdolecek Sync w/ -current.
 1.4.2.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.8.60.1 10-Dec-2006  yamt sync with head.
 1.8.58.1 12-Jan-2007  ad Sync with head.
 1.8.28.1 30-Dec-2006  yamt sync with head.
 1.8.6.2 28-Apr-2002  uch Use "#define<tab>", white space nits.
 1.8.6.1 28-Apr-2002  uch file elf_machdep.h was added on branch nathanw_sa on 2002-04-28 17:10:35 +0000
 1.9.56.1 20-Jun-2009  yamt sync with head
 1.10.38.1 25-Jan-2015  martin Pull up following revision(s) (requested by mrg for ticket #448):
sys/arch/sh3/include/elf_machdep.h: revision 1.11
instead of bitching about the missing endianness, get it.
 1.10.22.1 03-Dec-2017  jdolecek update from HEAD
 1.11.4.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.11.2.1 05-Feb-2017  skrll Sync with HEAD
 1.4 17-Mar-2000  mycroft In the `MY THAT'S GROSS' department...
Eliminate the recursive include of machine/endian.h from sys/endian.h.
 1.3 16-Mar-2000  mycroft Foolish consistency. Mainly, always use underscores and sys/endian.h.
 1.2 14-Jan-2000  msaitoh block prototype definitions with _LOCORE (for .S)
 1.1 13-Sep-1999  itojun branches: 1.1.2;
Merge in NetBSD/sh3 from cvs.kame.net repository.

Tree structure:
- sys/arch/sh3: sh3 generic code
As commented, in-chip device drivers are put into sys/arch/sh3/dev.
- sys/arch/evbsh3: sh3 evaluation boards (pure sh3 CPU, no fancy external HW)
- sys/arch/mmeye: Brains mmEye, www.brains.co.jp
MI source code includes couple of #ifdef for sh3-coff support.
(sh3 uses coff or elf)

Needs some more improvements, especialy in sys/arch/sh3/conf/files.sh3,
to compile the tree (due to last minute tree structure change).
 1.1.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.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:24:29 +0000
 1.12 16-May-2009  nonaka Add SH4 INTEVT codes for GPIO.
 1.11 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.10 23-Mar-2008  uwe branches: 1.10.2; 1.10.4;
Sort SH4_INTEVT_PCI* codes.
 1.9 22-Jul-2006  uwe branches: 1.9.58;
exp_type[] was constified in exception.c but an extern declaration in
db_interface.c was not updated. Declare it publicly. While here,
constify the array itself too.
 1.8 04-Mar-2006  uwe branches: 1.8.2;
s/u_intN_t/uintN_t/
 1.7 11-Dec-2005  christos branches: 1.7.4; 1.7.6;
merge ktrace-lwp.
 1.6 29-Jun-2005  christos branches: 1.6.2;
more additions from nonaka's landisk port.
 1.5 25-Mar-2004  uwe INTEVT2 values for DMAC interrupts.
 1.4 29-Dec-2002  uwe branches: 1.4.2;
Add sh7709 INTEVT2 codes for IRQs, PINTs, IRDA and ADC.
 1.3 09-May-2002  uch branches: 1.3.6; 1.3.8;
rework general exception, and TLB exception handling for new pmap.
all exception staffs are moved to exception.[ch]
 1.2 28-Apr-2002  uch Use "#define<tab>", white space nits.
 1.1 24-Mar-2002  uch branches: 1.1.2;
Rework interrupt code.
+ Fully utilize SH SR.I[0:3] interrupt level.
+ software interrupt is emulated by TMU1, 2 one shot interrupt.
+ implement generic soft interrupts.
+ implement clockframe correctly.
 1.1.2.2 20-Jun-2002  nathanw Catch up to -current.
 1.1.2.1 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.3.8.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.3.8.1 09-May-2002  jdolecek file exception.h was added on branch kqueue on 2002-06-23 17:40:39 +0000
 1.3.6.2 29-Dec-2002  thorpej Sync with HEAD.
 1.3.6.1 09-May-2002  thorpej file exception.h was added on branch nathanw_sa on 2002-12-29 19:37:28 +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.6.2.3 24-Mar-2008  yamt sync with head.
 1.6.2.2 30-Dec-2006  yamt sync with head.
 1.6.2.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.8.2.1 11-Aug-2006  yamt sync with head
 1.9.58.2 02-Jun-2008  mjf Sync with HEAD.
 1.9.58.1 03-Apr-2008  mjf Sync with HEAD.
 1.10.4.2 20-Jun-2009  yamt sync with head
 1.10.4.1 16-May-2008  yamt sync with head.
 1.10.2.1 18-May-2008  yamt sync with head.
 1.2 02-Jan-2000  msaitoh remove exec_coff.h
 1.1 13-Sep-1999  itojun branches: 1.1.2;
Merge in NetBSD/sh3 from cvs.kame.net repository.

Tree structure:
- sys/arch/sh3: sh3 generic code
As commented, in-chip device drivers are put into sys/arch/sh3/dev.
- sys/arch/evbsh3: sh3 evaluation boards (pure sh3 CPU, no fancy external HW)
- sys/arch/mmeye: Brains mmEye, www.brains.co.jp
MI source code includes couple of #ifdef for sh3-coff support.
(sh3 uses coff or elf)

Needs some more improvements, especialy in sys/arch/sh3/conf/files.sh3,
to compile the tree (due to last minute tree structure change).
 1.1.2.1 20-Nov-2000  bouyer Remove files that are no longer on the trunck
 1.4 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.3 22-Mar-2017  chs branches: 1.3.12; 1.3.52;
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.2 25-Aug-2016  christos branches: 1.2.2; 1.2.4; 1.2.6;
fake some stuff for softfloat.
 1.1 25-Aug-2016  christos fenv.h for sh
 1.2.6.1 21-Apr-2017  bouyer Sync with HEAD
 1.2.4.3 28-Aug-2017  skrll Sync with HEAD
 1.2.4.2 05-Oct-2016  skrll Sync with HEAD
 1.2.4.1 25-Aug-2016  skrll file fenv.h was added on branch nick-nhusb on 2016-10-05 20:55:35 +0000
 1.2.2.3 26-Apr-2017  pgoyette Sync with HEAD
 1.2.2.2 14-Sep-2016  pgoyette Sync with HEAD
 1.2.2.1 25-Aug-2016  pgoyette file fenv.h was added on branch pgoyette-localcount on 2016-09-14 03:04:17 +0000
 1.3.52.1 02-Aug-2025  perseant Sync with HEAD
 1.3.12.2 03-Dec-2017  jdolecek update from HEAD
 1.3.12.1 22-Mar-2017  jdolecek file fenv.h was added on branch tls-maxphys on 2017-12-03 11:36:42 +0000
 1.5 12-May-2003  kleink Rename <sys/float_ieee.h> to <sys/float_ieee754.h>, following libc's
convention for these.
 1.4 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.3 28-Apr-2002  uch branches: 1.3.6;
Use "#define<tab>", white space nits.
 1.2 17-Mar-2002  uch cosmetic changes, fix comments.
 1.1 13-Sep-1999  itojun branches: 1.1.16;
Merge in NetBSD/sh3 from cvs.kame.net repository.

Tree structure:
- sys/arch/sh3: sh3 generic code
As commented, in-chip device drivers are put into sys/arch/sh3/dev.
- sys/arch/evbsh3: sh3 evaluation boards (pure sh3 CPU, no fancy external HW)
- sys/arch/mmeye: Brains mmEye, www.brains.co.jp
MI source code includes couple of #ifdef for sh3-coff support.
(sh3 uses coff or elf)

Needs some more improvements, especialy in sys/arch/sh3/conf/files.sh3,
to compile the tree (due to last minute tree structure change).
 1.1.16.1 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.3.6.2 28-Apr-2002  uch Use "#define<tab>", white space nits.
 1.3.6.1 28-Apr-2002  uch file float.h was added on branch nathanw_sa on 2002-04-28 17:10:35 +0000
 1.1 25-Aug-2016  christos branches: 1.1.2; 1.1.4; 1.1.18;
fenv.h for sh
 1.1.18.2 03-Dec-2017  jdolecek update from HEAD
 1.1.18.1 25-Aug-2016  jdolecek file fpreg.h was added on branch tls-maxphys on 2017-12-03 11:36:42 +0000
 1.1.4.2 05-Oct-2016  skrll Sync with HEAD
 1.1.4.1 25-Aug-2016  skrll file fpreg.h was added on branch nick-nhusb on 2016-10-05 20:55:35 +0000
 1.1.2.2 14-Sep-2016  pgoyette Sync with HEAD
 1.1.2.1 25-Aug-2016  pgoyette file fpreg.h was added on branch pgoyette-localcount on 2016-09-14 03:04:17 +0000
 1.20 19-Feb-2012  rmind Remove COMPAT_SA / KERN_SA. Welcome to 6.99.3!
Approved by core@.
 1.19 22-Nov-2008  uwe branches: 1.19.16; 1.19.20;
Move COMPAT_16 signal stuff to the new compat_16_machdep.c file, so
that it can be built as part of a module.
 1.18 15-Oct-2008  wrstuden branches: 1.18.2;
Merge wrstuden-revivesa into HEAD.
 1.17 01-Jun-2008  uwe branches: 1.17.4;
Add GBR register to switchframe.

While here, reorder switchframe so that we can shave off a few
instructions when restoring it (group stack registers at the end, make
sure that last and first registers are safe to load/store in delay
slots).
 1.16 01-Jun-2008  uwe Add GBR register to trapframe.
 1.15 09-Feb-2007  ad branches: 1.15.44; 1.15.46; 1.15.48; 1.15.50;
Merge newlock2 to head.
 1.14 11-Dec-2005  christos branches: 1.14.20;
merge ktrace-lwp.
 1.13 24-Mar-2004  wiz branches: 1.13.16;
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.12 23-Nov-2003  uwe Implement siginfo for sh3.
 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 18-Jan-2003  thorpej branches: 1.10.2;
Merge the nathanw_sa branch.
 1.9 23-Jun-2002  thorpej When delivering a signal, don't push the signum, code, and context pointer,
or handler onto the stack. Instead, just stuff them into the correct
argument registers (handler is a "4th arg").
 1.8 09-May-2002  uch branches: 1.8.2; 1.8.6;
s/trapno/expevt/ for clarity.
 1.7 28-Apr-2002  uch Use "#define<tab>", white space nits.
 1.6 24-Mar-2002  uch Rework interrupt code.
+ Fully utilize SH SR.I[0:3] interrupt level.
+ software interrupt is emulated by TMU1, 2 one shot interrupt.
+ implement generic soft interrupts.
+ implement clockframe correctly.
 1.5 17-Mar-2002  uch cosmetic changes, fix comments.
 1.4 17-Mar-2002  uch kernel stack fix. old code simply P3 address converted to P1, it
caused memory destruction when kernel stack grow over 1 page. new
code use P3 address for kernel stack. but for the sake of debug, P1
kernel stack mode remain.
 1.3 24-Feb-2002  uch Move common exception vector and scheduler code to
sh3/sh3/exception_vector.S and sh3/sh3/locore_subr.S. exception
vectors are installed by sh_cpu_init(). machine/locore.S contains
kernel entry, interrupt handler, and some MD code.
 1.2 08-Sep-2000  tsubai branches: 1.2.4;
DDB single step and stack trace support.
 1.1 13-Sep-1999  itojun branches: 1.1.2;
Merge in NetBSD/sh3 from cvs.kame.net repository.

Tree structure:
- sys/arch/sh3: sh3 generic code
As commented, in-chip device drivers are put into sys/arch/sh3/dev.
- sys/arch/evbsh3: sh3 evaluation boards (pure sh3 CPU, no fancy external HW)
- sys/arch/mmeye: Brains mmEye, www.brains.co.jp
MI source code includes couple of #ifdef for sh3-coff support.
(sh3 uses coff or elf)

Needs some more improvements, especialy in sys/arch/sh3/conf/files.sh3,
to compile the tree (due to last minute tree structure change).
 1.1.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.2.4.3 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.2.4.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.2.4.1 16-Mar-2002  jdolecek Catch up with -current.
 1.8.6.4 01-Aug-2002  nathanw Catch up to -current.
 1.8.6.3 05-Jul-2002  thorpej When delivering an upcall, invoke the upcall directly, using the
trampoline only to exit if the upcall returns.
 1.8.6.2 21-Jun-2002  thorpej Add support for scheduler activations on SuperH. Boots multi-user
on Dreamcast (SH4) with stock userland.
 1.8.6.1 09-May-2002  thorpej file frame.h was added on branch nathanw_sa on 2002-06-21 21:26:27 +0000
 1.8.2.1 17-Jul-2002  gehenna catch up with -current.
 1.10.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.10.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.10.2.1 03-Aug-2004  skrll Sync with HEAD
 1.13.16.1 26-Feb-2007  yamt sync with head.
 1.14.20.1 30-Jan-2007  ad Remove support for SA. Ok core@.
 1.15.50.4 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.15.50.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.15.50.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.15.50.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.15.48.1 04-May-2009  yamt sync with head.
 1.15.46.1 04-Jun-2008  yamt sync with head
 1.15.44.2 17-Jan-2009  mjf Sync with HEAD.
 1.15.44.1 02-Jun-2008  mjf Sync with HEAD.
 1.17.4.2 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.17.4.1 19-Oct-2008  haad Sync with HEAD.
 1.18.2.1 19-Jan-2009  skrll Sync with HEAD.
 1.19.20.1 24-Feb-2012  mrg sync to -current.
 1.19.16.1 17-Apr-2012  yamt sync with head
 1.8 11-Dec-2005  christos merge ktrace-lwp.
 1.7 15-Apr-2005  kleink 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.6 26-Oct-2003  kleink branches: 1.6.8; 1.6.14;
Use <sys/ieee754.h> where applicable.
 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 28-Feb-2002  uch branches: 1.4.12; 1.4.18;
Remove #if 0 #endif
 1.3 03-May-2001  kleink branches: 1.3.2;
There is no extended-precision format on sh3.
 1.2 02-Aug-2000  msaitoh branches: 1.2.2;
check _BYTE_ORDER instead of BYTE_ORDER
 1.1 13-Sep-1999  itojun branches: 1.1.2; 1.1.12;
Merge in NetBSD/sh3 from cvs.kame.net repository.

Tree structure:
- sys/arch/sh3: sh3 generic code
As commented, in-chip device drivers are put into sys/arch/sh3/dev.
- sys/arch/evbsh3: sh3 evaluation boards (pure sh3 CPU, no fancy external HW)
- sys/arch/mmeye: Brains mmEye, www.brains.co.jp
MI source code includes couple of #ifdef for sh3-coff support.
(sh3 uses coff or elf)

Needs some more improvements, especialy in sys/arch/sh3/conf/files.sh3,
to compile the tree (due to last minute tree structure change).
 1.1.12.2 03-May-2001  he Pull up revision 1.3 (requested by kleink):
There is no extended-precision format on sh3.
 1.1.12.1 08-Aug-2000  msaitoh Pullup revision 1.2 (approved by thorpej):

check _BYTE_ORDER instead of BYTE_ORDER to fix namespace pollution
(and it's necessary to compile src/usr.bin/xlint/llib)
 1.1.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.2.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.3.2.1 16-Mar-2002  jdolecek Catch up with -current.
 1.4.18.4 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.4.18.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.4.18.2 18-Sep-2004  skrll Sync with HEAD.
 1.4.18.1 03-Aug-2004  skrll Sync with HEAD
 1.4.12.2 28-Feb-2002  uch Remove #if 0 #endif
 1.4.12.1 28-Feb-2002  uch file ieee.h was added on branch nathanw_sa on 2002-02-28 01:58:54 +0000
 1.6.14.1 19-Apr-2005  tron Pull up revision 1.7 (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.6.8.1 29-Apr-2005  kent sync with -current
 1.7 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.6 25-Aug-2016  christos branches: 1.6.2;
fake some stuff for softfloat.
 1.5 25-Aug-2016  christos use fenv.h
 1.4 05-Aug-2008  matt branches: 1.4.38; 1.4.58; 1.4.62;
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.3 28-Apr-2002  uch branches: 1.3.6; 1.3.114; 1.3.118; 1.3.120; 1.3.124;
Use "#define<tab>", white space nits.
 1.2 17-Mar-2002  uch cosmetic changes, fix comments.
 1.1 13-Sep-1999  itojun branches: 1.1.16;
Merge in NetBSD/sh3 from cvs.kame.net repository.

Tree structure:
- sys/arch/sh3: sh3 generic code
As commented, in-chip device drivers are put into sys/arch/sh3/dev.
- sys/arch/evbsh3: sh3 evaluation boards (pure sh3 CPU, no fancy external HW)
- sys/arch/mmeye: Brains mmEye, www.brains.co.jp
MI source code includes couple of #ifdef for sh3-coff support.
(sh3 uses coff or elf)

Needs some more improvements, especialy in sys/arch/sh3/conf/files.sh3,
to compile the tree (due to last minute tree structure change).
 1.1.16.1 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.3.124.1 19-Oct-2008  haad Sync with HEAD.
 1.3.120.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.3.118.1 04-May-2009  yamt sync with head.
 1.3.114.1 28-Sep-2008  mjf Sync with HEAD.
 1.3.6.2 28-Apr-2002  uch Use "#define<tab>", white space nits.
 1.3.6.1 28-Apr-2002  uch file ieeefp.h was added on branch nathanw_sa on 2002-04-28 17:10:35 +0000
 1.4.62.2 26-Apr-2017  pgoyette Resolve a couple of conflicts
 1.4.62.1 26-Apr-2017  pgoyette Sync with HEAD
 1.4.58.2 28-Aug-2017  skrll Sync with HEAD
 1.4.58.1 05-Oct-2016  skrll Sync with HEAD
 1.4.38.1 03-Dec-2017  jdolecek update from HEAD
 1.6.2.1 21-Apr-2017  bouyer Sync with HEAD
 1.5 13-Aug-2014  matt Include <sys/common_int_const.h> if __INTMAX_C_SUFFIX__ is defined.
 1.4 29-May-2010  tnozaki branches: 1.4.18;
fix wrong integer promotion rule(removed U suffix from UINT{8,16}_C).
see ISO/IEC 9899:1999 7.18.4.3.
 1.3 28-Apr-2008  martin branches: 1.3.20; 1.3.22;
Remove clause 3 and 4 from TNF licenses
 1.2 28-Apr-2002  uch branches: 1.2.6; 1.2.114; 1.2.116; 1.2.118;
Use "#define<tab>", white space nits.
 1.1 14-Apr-2001  kleink branches: 1.1.2; 1.1.4; 1.1.6;
Add definitions of C99 integer constant macros.
 1.1.6.1 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 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:54:36 +0000
 1.2.118.2 11-Aug-2010  yamt sync with head.
 1.2.118.1 16-May-2008  yamt sync with head.
 1.2.116.1 18-May-2008  yamt sync with head.
 1.2.114.1 02-Jun-2008  mjf Sync with HEAD.
 1.2.6.2 28-Apr-2002  uch Use "#define<tab>", white space nits.
 1.2.6.1 28-Apr-2002  uch file int_const.h was added on branch nathanw_sa on 2002-04-28 17:10:36 +0000
 1.3.22.1 30-May-2010  rmind sync with head
 1.3.20.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.4.18.1 03-Dec-2017  jdolecek update from HEAD
 1.5 13-Aug-2014  matt include <sys/common_int_fmtio.h> if __INTPTR_FMTd__ is defined
 1.4 28-Apr-2008  martin branches: 1.4.44;
Remove clause 3 and 4 from TNF licenses
 1.3 28-Apr-2002  uch branches: 1.3.6; 1.3.114; 1.3.116; 1.3.118;
Use "#define<tab>", white space nits.
 1.2 26-Apr-2001  kleink branches: 1.2.2; 1.2.4;
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:54:36 +0000
 1.2.4.1 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.2.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.3.118.1 16-May-2008  yamt sync with head.
 1.3.116.1 18-May-2008  yamt sync with head.
 1.3.114.1 02-Jun-2008  mjf Sync with HEAD.
 1.3.6.2 28-Apr-2002  uch Use "#define<tab>", white space nits.
 1.3.6.1 28-Apr-2002  uch file int_fmtio.h was added on branch nathanw_sa on 2002-04-28 17:10:36 +0000
 1.4.44.1 03-Dec-2017  jdolecek update from HEAD
 1.9 13-Aug-2014  matt Include <sys/common_init_limits.h> if __SIG_ATOMIC_MAX__ is defined.
 1.8 28-Apr-2008  martin branches: 1.8.44;
Remove clause 3 and 4 from TNF licenses
 1.7 17-Oct-2007  garbled branches: 1.7.16; 1.7.18; 1.7.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.6 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.5 11-Dec-2005  christos branches: 1.5.30; 1.5.38; 1.5.44; 1.5.48; 1.5.50;
merge ktrace-lwp.
 1.4 08-May-2004  kleink branches: 1.4.12;
Factor out W{CHAR,INT}_{MAX,MIN} into their own header file.
 1.3 28-Apr-2002  uch branches: 1.3.6; 1.3.12;
Use "#define<tab>", white space nits.
 1.2 26-Apr-2001  kleink branches: 1.2.2; 1.2.4;
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:54:37 +0000
 1.2.4.1 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.2.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.3.12.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.3.12.2 18-Sep-2004  skrll Sync with HEAD.
 1.3.12.1 03-Aug-2004  skrll Sync with HEAD
 1.3.6.2 28-Apr-2002  uch Use "#define<tab>", white space nits.
 1.3.6.1 28-Apr-2002  uch file int_limits.h was added on branch nathanw_sa on 2002-04-28 17:10:36 +0000
 1.4.12.1 03-Sep-2007  yamt sync with head.
 1.5.50.1 06-Nov-2007  matt sync with HEAD
 1.5.48.1 03-Sep-2007  jmcneill Sync with HEAD.
 1.5.44.1 03-Sep-2007  skrll Sync with HEAD.
 1.5.38.1 03-Oct-2007  garbled Sync with HEAD
 1.5.30.1 09-Oct-2007  ad Sync with head.
 1.7.20.1 16-May-2008  yamt sync with head.
 1.7.18.1 18-May-2008  yamt sync with head.
 1.7.16.1 02-Jun-2008  mjf Sync with HEAD.
 1.8.44.1 03-Dec-2017  jdolecek update from HEAD
 1.6 13-Aug-2014  matt include <sys/common_int_mwgwtypes.h> if __UINT_FAST64_TYPE__ is defined.
 1.5 28-Apr-2008  martin branches: 1.5.44;
Remove clause 3 and 4 from TNF licenses
 1.4 24-Dec-2005  perry branches: 1.4.74; 1.4.76; 1.4.78;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.
 1.3 28-Apr-2002  uch branches: 1.3.6; 1.3.28;
Use "#define<tab>", white space nits.
 1.2 26-Apr-2001  kleink branches: 1.2.2; 1.2.4;
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:54:37 +0000
 1.2.4.1 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.2.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.3.28.1 21-Jun-2006  yamt sync with head.
 1.3.6.2 28-Apr-2002  uch Use "#define<tab>", white space nits.
 1.3.6.1 28-Apr-2002  uch file int_mwgwtypes.h was added on branch nathanw_sa on 2002-04-28 17:10:36 +0000
 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.44.1 03-Dec-2017  jdolecek update from HEAD
 1.9 13-Aug-2014  matt Include <sys/common_int_types.h> if __UINTPTR_TYPE__ is defined.
 1.8 24-Dec-2005  perry branches: 1.8.122;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.
 1.7 11-Dec-2005  christos merge ktrace-lwp.
 1.6 25-May-2005  kleink branches: 1.6.2;
Include <sys/cdefs.h> for __signed; related to lib/30072.
 1.5 07-Aug-2003  agc branches: 1.5.6; 1.5.14;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.4 28-Apr-2001  kleink branches: 1.4.18; 1.4.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.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.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:24:30 +0000
 1.3.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.4.24.4 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 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.4.18.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.4.18.1 28-Apr-2001  kleink file int_types.h was added on branch nathanw_sa on 2001-04-28 15:41:33 +0000
 1.5.14.1 28-May-2005  tron Pull up revision 1.6 (requested by klein in ticket #346):
Include <sys/cdefs.h> for __signed; related to lib/30072.
 1.5.6.1 29-May-2005  riz Pull up revision 1.6 (requested by kleink in ticket #1555):
Include <sys/cdefs.h> for __signed; related to lib/30072.
 1.6.2.1 21-Jun-2006  yamt sync with head.
 1.8.122.1 03-Dec-2017  jdolecek update from HEAD
 1.10 11-Dec-2005  christos merge ktrace-lwp.
 1.9 16-Aug-2005  nonaka Added SH7751{,R} integrated PCI controller support.
 1.8 29-Jun-2005  christos branches: 1.8.2;
more additions from nonaka's landisk port.
 1.7 07-Oct-2003  uwe Add definitions for IRR0 bits.
 1.6 28-Apr-2002  uch branches: 1.6.6; 1.6.12;
Use "#define<tab>", white space nits.
 1.5 24-Mar-2002  uch add SH7750S IPRD register define
 1.4 28-Feb-2002  uch Cleanup register definition
 1.3 02-Aug-2000  msaitoh branches: 1.3.4;
check _BYTE_ORDER instead of BYTE_ORDER
 1.2 16-Sep-1999  msaitoh branches: 1.2.2; 1.2.12;
remove extra Id
 1.1 13-Sep-1999  itojun Merge in NetBSD/sh3 from cvs.kame.net repository.

Tree structure:
- sys/arch/sh3: sh3 generic code
As commented, in-chip device drivers are put into sys/arch/sh3/dev.
- sys/arch/evbsh3: sh3 evaluation boards (pure sh3 CPU, no fancy external HW)
- sys/arch/mmeye: Brains mmEye, www.brains.co.jp
MI source code includes couple of #ifdef for sh3-coff support.
(sh3 uses coff or elf)

Needs some more improvements, especialy in sys/arch/sh3/conf/files.sh3,
to compile the tree (due to last minute tree structure change).
 1.2.12.1 08-Aug-2000  msaitoh Pullup revision 1.3 (approved by thorpej):

check _BYTE_ORDER instead of BYTE_ORDER to fix namespace pollution
(and it's necessary to compile src/usr.bin/xlint/llib)
 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.4.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.3.4.1 16-Mar-2002  jdolecek Catch up with -current.
 1.6.12.4 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.6.12.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.6.12.2 18-Sep-2004  skrll Sync with HEAD.
 1.6.12.1 03-Aug-2004  skrll Sync with HEAD
 1.6.6.2 28-Apr-2002  uch Use "#define<tab>", white space nits.
 1.6.6.1 28-Apr-2002  uch file intcreg.h was added on branch nathanw_sa on 2002-04-28 17:10:36 +0000
 1.8.2.1 21-Jun-2006  yamt sync with head.
 1.26 21-Mar-2009  uwe Interrupt handling changes (revision 1.23) bumped down _IPL_N to 8 for
some reason. Restore it to correct 16.

HTF did hpcsh work all this time with hd6446x_imask[_IPL_N] indexed
with IPLs 0..15 is a mistery... Discovered by accidentally triggering
hd64461 timer interrupt that is not enabled and should have been
masked.

_IPL_N used to be *also incorrect* 15 before Andy's change, which
makes one wonder if dumb luck is severly underappreciated.
 1.25 28-Apr-2008  martin branches: 1.25.8; 1.25.10; 1.25.14;
Remove clause 3 and 4 from TNF licenses
 1.24 04-Jan-2008  uwe branches: 1.24.6; 1.24.8; 1.24.10;
G/c bogus includes that do nothing but add circular dependency between
intr.h and mutex.h
 1.23 03-Dec-2007  ad branches: 1.23.6;
Interrupt handling changes, in discussion since February:

- Reduce available SPL levels for hardware devices to none, vm, sched, high.
- Acquire kernel_lock only for interrupts at IPL_VM.
- Implement threaded soft interrupts.
 1.22 24-Jan-2006  uwe branches: 1.22.28; 1.22.46; 1.22.48; 1.22.54;
EVTCODE_TO_MAP_INDEX - tweak to help gcc produce better code.
 1.21 11-Dec-2005  christos branches: 1.21.2;
merge ktrace-lwp.
 1.20 16-Aug-2005  nonaka Added SH7751{,R} integrated PCI controller support.
 1.19 04-Nov-2003  uwe branches: 1.19.16;
Redo a quick hack for intc_intr_disable() and intc_intr_enable() to have
a saner interface/semantic.
 1.18 18-Oct-2003  uwe Make intc_intr_priority() return old level. While here, make the code
more compact by factoring out register update to happen in one place,
outside the switch statements.

Add intc_intr_disable() and intc_intr_enable().
 1.17 28-Apr-2002  uch branches: 1.17.6; 1.17.12;
Use "#define<tab>", white space nits.
 1.16 24-Mar-2002  uch Rework interrupt code.
+ Fully utilize SH SR.I[0:3] interrupt level.
+ software interrupt is emulated by TMU1, 2 one shot interrupt.
+ implement generic soft interrupts.
+ implement clockframe correctly.
 1.15 03-Mar-2002  uch branches: 1.15.2;
SR related parts moved to psl.h. cpufunc.h segments.h are removed.
kernel mode checking is only SR.MD. no check stack pointer.
 1.14 19-Feb-2002  uch Clean up functions
disable_intr, enable_intr, disable_interrupt, enable_interrupt,
disable_ext_intr, enable_ext_intr.
New functions:
for external interrupt:
_cpu_intr_suspend and _cpu_intr_resume.
for exception:
_cpu_exception_suspend and _cpu_exception_resume.
 1.13 12-Feb-2002  uch ANSIfy KNF.
 1.12 16-Sep-2001  wiz Spell 'occurred' with two 'r's.
 1.11 13-Apr-2001  thorpej branches: 1.11.2; 1.11.4;
Remove the use of splimp() from the NetBSD kernel. splnet()
and only splnet() is allowed for the protection of data structures
used by network devices.
 1.10 14-Jan-2001  thorpej branches: 1.10.2;
Make sure everybody has an splvm() and equate it with splimp() (splimp()
is the historical name for this interrupt level, and the historical name
is going to go away in the near future).
 1.9 22-Aug-2000  thorpej Add spllock(). See spl(9) for details.
 1.8 21-Aug-2000  thorpej Make sure we provide splsched() as described in spl(9).
 1.7 17-Aug-2000  msaitoh add an INTEVT code for WDT
 1.6 06-Jul-2000  msaitoh make spllower() return void.
 1.5 13-Apr-2000  msaitoh branches: 1.5.4;
move the Interrput Priority Level (IPL_*) definitions into MD part.
 1.4 24-Feb-2000  msaitoh multiple interrputs!!!
 1.3 27-Dec-1999  msaitoh fix missing SCI IRQ mask/unmask code.
 1.2 14-Sep-1999  tsubai branches: 1.2.2;
Catch up with -current.
 1.1 13-Sep-1999  itojun Merge in NetBSD/sh3 from cvs.kame.net repository.

Tree structure:
- sys/arch/sh3: sh3 generic code
As commented, in-chip device drivers are put into sys/arch/sh3/dev.
- sys/arch/evbsh3: sh3 evaluation boards (pure sh3 CPU, no fancy external HW)
- sys/arch/mmeye: Brains mmEye, www.brains.co.jp
MI source code includes couple of #ifdef for sh3-coff support.
(sh3 uses coff or elf)

Needs some more improvements, especialy in sys/arch/sh3/conf/files.sh3,
to compile the tree (due to last minute tree structure change).
 1.2.2.3 21-Apr-2001  bouyer Sync with HEAD
 1.2.2.2 18-Jan-2001  bouyer Sync with head (for UBC+NFS fixes, mostly).
 1.2.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.5.4.1 08-Aug-2000  msaitoh Pullup revision 1.6 (approved by thorpej):

fix the return value of the spllower() to void.
 1.10.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.11.4.1 01-Oct-2001  fvdl Catch up with -current.
 1.11.2.3 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.11.2.2 16-Mar-2002  jdolecek Catch up with -current.
 1.11.2.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.15.2.1 17-Mar-2002  thorpej IPL_IMP -> IPL_VM
 1.17.12.4 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.17.12.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.17.12.2 18-Sep-2004  skrll Sync with HEAD.
 1.17.12.1 03-Aug-2004  skrll Sync with HEAD
 1.17.6.2 28-Apr-2002  uch Use "#define<tab>", white space nits.
 1.17.6.1 28-Apr-2002  uch file intr.h was added on branch nathanw_sa on 2002-04-28 17:10:36 +0000
 1.19.16.3 21-Jan-2008  yamt sync with head
 1.19.16.2 07-Dec-2007  yamt sync with head
 1.19.16.1 21-Jun-2006  yamt sync with head.
 1.21.2.1 01-Feb-2006  yamt sync with head.
 1.22.54.2 18-Feb-2008  mjf Sync with HEAD.
 1.22.54.1 08-Dec-2007  mjf Sync with HEAD.
 1.22.48.1 09-Jan-2008  matt sync with HEAD
 1.22.46.1 09-Dec-2007  jmcneill Sync with HEAD.
 1.22.28.1 03-Dec-2007  ad Sync with HEAD.
 1.23.6.1 08-Jan-2008  bouyer Sync with HEAD
 1.24.10.2 04-May-2009  yamt sync with head.
 1.24.10.1 16-May-2008  yamt sync with head.
 1.24.8.1 18-May-2008  yamt sync with head.
 1.24.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.25.14.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.25.10.1 24-Mar-2009  snj Pull up following revision(s) (requested by uwe in ticket #591):
sys/arch/sh3/include/intr.h: revision 1.26
Interrupt handling changes (revision 1.23) bumped down _IPL_N to 8 for
some reason. Restore it to correct 16.
HTF did hpcsh work all this time with hd6446x_imask[_IPL_N] indexed
with IPLs 0..15 is a mistery... Discovered by accidentally triggering
hd64461 timer interrupt that is not enabled and should have been
masked.
_IPL_N used to be *also incorrect* 15 before Andy's change, which
makes one wonder if dumb luck is severly underappreciated.
 1.25.8.1 28-Apr-2009  skrll Sync with HEAD.
 1.15 21-Jan-2019  dholland Fix wrong scoping of {U,}LLONG_MAX. More cases, not just amd64.
PR 53298 from Roberto E. Vargas Caballero.
 1.14 21-Apr-2014  matt branches: 1.14.26; 1.14.28;
Since all our compilers support __DBL_* and __FLT_*, use them to define
{DBL,FLT}_{DIG,MIN,MAX}
 1.13 11-Apr-2013  christos branches: 1.13.4; 1.13.8;
add missing SSIZE_MIN
 1.12 28-Mar-2012  christos branches: 1.12.2;
- Normalize inclusion protection (remove)
- Move CHAR_{MIN,MAX} to a common file.
- Fix broken comments
 1.11 07-Jun-2010  tnozaki branches: 1.11.8; 1.11.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.10 17-Oct-2007  garbled branches: 1.10.20; 1.10.40; 1.10.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.9 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.8 11-Dec-2005  christos branches: 1.8.30; 1.8.38; 1.8.44; 1.8.48; 1.8.50;
merge ktrace-lwp.
 1.7 07-Aug-2003  agc branches: 1.7.16;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.6 28-Apr-2003  bjh21 branches: 1.6.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.5 28-Apr-2002  uch branches: 1.5.6;
Use "#define<tab>", white space nits.
 1.4 17-Mar-2002  uch cosmetic changes, fix comments.
 1.3 08-Aug-2000  tshiozak branches: 1.3.4;
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.2 07-Mar-2000  kleink branches: 1.2.2; 1.2.4;
Define ISO C99 (unsigned) long long (min, max) symbols.
 1.1 13-Sep-1999  itojun branches: 1.1.2;
Merge in NetBSD/sh3 from cvs.kame.net repository.

Tree structure:
- sys/arch/sh3: sh3 generic code
As commented, in-chip device drivers are put into sys/arch/sh3/dev.
- sys/arch/evbsh3: sh3 evaluation boards (pure sh3 CPU, no fancy external HW)
- sys/arch/mmeye: Brains mmEye, www.brains.co.jp
MI source code includes couple of #ifdef for sh3-coff support.
(sh3 uses coff or elf)

Needs some more improvements, especialy in sys/arch/sh3/conf/files.sh3,
to compile the tree (due to last minute tree structure change).
 1.1.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.2.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.2.2.1 28-May-2000  minoura Citrus Project XPG4DL, an implementation of I18N (locale) framework,
is imported.
 1.3.4.1 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.5.6.2 28-Apr-2002  uch Use "#define<tab>", white space nits.
 1.5.6.1 28-Apr-2002  uch file limits.h was added on branch nathanw_sa on 2002-04-28 17:10:36 +0000
 1.6.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.6.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.6.2.1 03-Aug-2004  skrll Sync with HEAD
 1.7.16.1 03-Sep-2007  yamt sync with head.
 1.8.50.1 06-Nov-2007  matt sync with HEAD
 1.8.48.1 03-Sep-2007  jmcneill Sync with HEAD.
 1.8.44.1 03-Sep-2007  skrll Sync with HEAD.
 1.8.38.1 03-Oct-2007  garbled Sync with HEAD
 1.8.30.1 09-Oct-2007  ad Sync with head.
 1.10.42.1 03-Jul-2010  rmind sync with head
 1.10.40.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.10.20.1 11-Aug-2010  yamt sync with head.
 1.11.12.1 05-Apr-2012  mrg sync to latest -current.
 1.11.8.2 22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.11.8.1 17-Apr-2012  yamt sync with head
 1.12.2.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.12.2.1 23-Jun-2013  tls resync from head
 1.13.8.1 10-Aug-2014  tls Rebase.
 1.13.4.1 18-May-2014  rmind sync with head
 1.14.28.1 10-Jun-2019  christos Sync with HEAD
 1.14.26.1 26-Jan-2019  pgoyette Sync with HEAD
 1.19 13-Feb-2022  riastradh sh3: __cpu_simple_unlock needs __insn_barrier.

No multiprocessor support here but the compiler can still reorder
memory access.
 1.18 29-Nov-2019  riastradh Nix mb_* on sh3.
 1.17 17-Sep-2017  christos branches: 1.17.4;
more const.
 1.16 13-Oct-2009  uwe branches: 1.16.22;
Fix inline asm for tas.b. "=m" is not restrictive enough and gcc may
decide to use addressing modes that tas.b does not support. 'V' is
advertised to be "non-offsettable" subset of 'm' but there's a bug in
gcc that prevents "=V" from working.

When in doubt use brute force, so pass lock pointer as "r" input and
declare "memory" as clobbered.

Landisk kernel diff is 5 instructions (register choice for lock
address in __cpu_simple_lock_try).

sys/dev/raidframe/rf_copyback.c - where old __asm triggered incorrect code
- successfully compiles (as part of sys/rump/dev/lib/libraidframe).
 1.15 28-Apr-2008  martin 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 10-Sep-2007  skrll Merge nick-csl-alignment.
 1.12 12-Mar-2007  uwe branches: 1.12.8; 1.12.12; 1.12.16; 1.12.18;
Note in that TAS.B in inline asm clobbers "cc".
Use MOVT instead of clear+rotate with carry in __cpu_simple_lock_try.
 1.11 09-Feb-2007  ad branches: 1.11.2; 1.11.6;
Merge newlock2 to head.
 1.10 03-Jan-2006  uwe branches: 1.10.18;
Nuke __P.
 1.9 28-Dec-2005  perry branches: 1.9.2;
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 26-Sep-2003  nathanw branches: 1.6.16;
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.5 14-Feb-2003  itohy branches: 1.5.2;
- Change __cpu_simple_lock_t from int to unsigned char.
This makes simple lock work on big-endian platforms.
- Assembly-level optimization of __cpu_simple_lock_try().

OK'd by Gregory McGarry. Closes PR port-sh3/20311.
 1.4 16-Sep-2002  gmcgarry Implement CPU spinlocks. Compile-tested only.
 1.3 17-Mar-2002  uch branches: 1.3.8;
cosmetic changes, fix comments.
 1.2 02-May-2000  thorpej branches: 1.2.6; 1.2.10;
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.2.10.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.2.10.1 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.2.6.2 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.2.6.1 02-May-2000  bouyer file lock.h was added on branch thorpej_scsipi on 2000-11-20 20:24:30 +0000
 1.3.8.2 17-Sep-2002  nathanw Catch up to -current.
 1.3.8.1 17-Mar-2002  nathanw file lock.h was added on branch nathanw_sa on 2002-09-17 21:17:25 +0000
 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.4 27-Oct-2007  yamt sync with head.
 1.6.16.3 03-Sep-2007  yamt sync with head.
 1.6.16.2 26-Feb-2007  yamt sync with head.
 1.6.16.1 21-Jun-2006  yamt sync with head.
 1.9.2.1 15-Jan-2006  yamt sync with head.
 1.10.18.1 01-Feb-2007  ad Get sh3 compiling.
 1.11.6.2 09-Oct-2007  ad Sync with head.
 1.11.6.1 13-Mar-2007  ad Sync with head.
 1.11.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.12.18.1 06-Nov-2007  matt sync with HEAD
 1.12.16.1 02-Oct-2007  joerg Sync with HEAD.
 1.12.12.1 15-Aug-2007  skrll Provide __SIMPLELOCK_{UN,}LOCKED_P and __cpu_simple_lock_{set,clear}
for all architectures.
 1.12.8.1 03-Oct-2007  garbled Sync with HEAD
 1.14.20.2 11-Mar-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.16.22.1 03-Dec-2017  jdolecek update from HEAD
 1.17.4.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.22 04-Feb-2011  uwe Since __INTR_MASK + __EXCEPTION_UNBLOCK is common sequence, provide
__INTR_MASK_EXCEPTION_UNBLOCK combo version that does stc/ldc just once.
 1.21 04-Feb-2011  uwe __EXCEPTION_ENTRY - "tst" already does logical AND, so shave off extra
"mov" and "and" and just test PSL_MD bit directly.

While here - shuffle around instructions to construct PSL_MD to break
dependencies.

While still here - only interrupt vector uses SSR and SPC as function
args, so don't bother saving them here in r4 and r5. Other vectors
don't need them and interrupt vector can just as well "stc" them
directly before exceptions are enabled.
 1.20 18-Jan-2011  joerg branches: 1.20.2;
Allow co-existance of traditional and modern CPP
 1.19 01-Jun-2008  uwe branches: 1.19.20; 1.19.26;
Add GBR register to trapframe.
 1.18 31-May-2008  uwe In __EXCEPTION_RETURN use ldc.l to shave off couple of instructions.
 1.17 28-Apr-2008  martin branches: 1.17.2;
Remove clause 3 and 4 from TNF licenses
 1.16 23-Feb-2008  uwe branches: 1.16.2; 1.16.4;
Tweak __EXCEPTION_BLOCK so that original SR value is preserved in Rm.
We can then often use just "ldc Rm, sr" instead of matching
__EXCEPTION_UNBLOCK and thus shave off a few instructions.
 1.15 17-Oct-2007  garbled branches: 1.15.12; 1.15.16;
Merge the ppcoea-renovation branch to HEAD.

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

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

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.14 25-Sep-2007  uwe Shave off an instruction in __EXCEPTION_UNBLOCK.
 1.13 25-Sep-2007  uwe Misc comment fixes.
 1.12 25-Sep-2007  uwe Don't expose asm macros (traditional cpp) to C code (ANSI cpp) so that
we don't have to do weird dances protecting # that indicates asm
immediate operand from being iterpreted as cpp stringification
operator.
 1.11 23-Jan-2006  uwe branches: 1.11.28; 1.11.36; 1.11.46; 1.11.48; 1.11.50;
Use cpp-safe labels.
 1.10 11-Dec-2005  christos branches: 1.10.2;
merge ktrace-lwp.
 1.9 01-Oct-2003  uwe branches: 1.9.16;
Whitespace nit.
 1.8 18-Jan-2003  thorpej branches: 1.8.2;
Merge the nathanw_sa branch.
 1.7 09-May-2002  uch branches: 1.7.6;
s/trapno/expevt/ for clarity.
 1.6 28-Apr-2002  uch Use "#define<tab>", white space nits.
 1.5 24-Mar-2002  uch Rework interrupt code.
+ Fully utilize SH SR.I[0:3] interrupt level.
+ software interrupt is emulated by TMU1, 2 one shot interrupt.
+ implement generic soft interrupts.
+ implement clockframe correctly.
 1.4 17-Mar-2002  uch cosmetic changes, fix comments.
 1.3 17-Mar-2002  uch kernel stack fix. old code simply P3 address converted to P1, it
caused memory destruction when kernel stack grow over 1 page. new
code use P3 address for kernel stack. but for the sake of debug, P1
kernel stack mode remain.
 1.2 28-Feb-2002  uch branches: 1.2.2; 1.2.8;
Change foo_r0_r1 macro in sh3/locore.h to foo(Rn, Rm)
 1.1 24-Feb-2002  uch Move common exception vector and scheduler code to
sh3/sh3/exception_vector.S and sh3/sh3/locore_subr.S. exception
vectors are installed by sh_cpu_init(). machine/locore.S contains
kernel entry, interrupt handler, and some MD code.
 1.2.8.3 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.2.8.2 16-Mar-2002  jdolecek Catch up with -current.
 1.2.8.1 28-Feb-2002  jdolecek file locore.h was added on branch kqueue on 2002-03-16 15:59:38 +0000
 1.2.2.3 20-Jun-2002  nathanw Catch up to -current.
 1.2.2.2 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.2.2.1 28-Feb-2002  nathanw Catch up to -current.
 1.7.6.2 21-Jun-2002  thorpej Add support for scheduler activations on SuperH. Boots multi-user
on Dreamcast (SH4) with stock userland.
 1.7.6.1 09-May-2002  thorpej file locore.h was added on branch nathanw_sa on 2002-06-21 21:26:28 +0000
 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.9.16.3 27-Feb-2008  yamt sync with head.
 1.9.16.2 27-Oct-2007  yamt sync with head.
 1.9.16.1 21-Jun-2006  yamt sync with head.
 1.10.2.1 01-Feb-2006  yamt sync with head.
 1.11.50.1 06-Oct-2007  yamt sync with head.
 1.11.48.2 23-Mar-2008  matt sync with HEAD
 1.11.48.1 06-Nov-2007  matt sync with HEAD
 1.11.46.1 02-Oct-2007  joerg Sync with HEAD.
 1.11.36.1 03-Oct-2007  garbled Sync with HEAD
 1.11.28.1 09-Oct-2007  ad Sync with head.
 1.15.16.2 02-Jun-2008  mjf Sync with HEAD.
 1.15.16.1 03-Apr-2008  mjf Sync with HEAD.
 1.15.12.1 24-Mar-2008  keiichi sync with head.
 1.16.4.2 04-May-2009  yamt sync with head.
 1.16.4.1 16-May-2008  yamt sync with head.
 1.16.2.2 04-Jun-2008  yamt sync with head
 1.16.2.1 18-May-2008  yamt sync with head.
 1.17.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.19.26.1 06-Jun-2011  jruoho Sync with HEAD.
 1.19.20.1 05-Mar-2011  rmind sync with head
 1.20.2.1 08-Feb-2011  bouyer Sync with HEAD
 1.2 04-Nov-2024  christos Undo previous lwp.h change.
 1.1 03-Nov-2024  christos Split __lwp_getprivate_fast and __lwp_*tcb from mcontext.h into a separate
lwp.h file.
 1.1 30-Nov-2024  christos branches: 1.1.4;
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.1.4.2 02-Aug-2025  perseant Sync with HEAD
 1.1.4.1 30-Nov-2024  perseant file lwp_private.h was added on branch perseant-exfatfs on 2025-08-02 05:56:07 +0000
 1.3 19-Feb-2002  simonb branches: 1.3.12;
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.2 05-Feb-2000  kleink branches: 1.2.6; 1.2.10;
Improve namespace test macros a bit.
 1.1 17-Jan-2000  kleink Add NAN constant glue for sh3.
 1.2.10.1 16-Mar-2002  jdolecek Catch up with -current.
 1.2.6.2 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.2.6.1 05-Feb-2000  bouyer file math.h was added on branch thorpej_scsipi on 2000-11-20 20:24:30 +0000
 1.3.12.2 19-Feb-2002  simonb 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.12.1 19-Feb-2002  simonb file math.h was added on branch nathanw_sa on 2002-02-19 13:08:16 +0000
 1.17 27-Apr-2025  uwe sh3/mcontext.h: make asm-friendly, respect _LOCORE
 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 27-Dec-2019  kamil Harmonize the namespace of fast TLS base pointer getter functions

Protect __lwp_getprivate_fast() with _RTLD_SOURCE, _LIBC_SOURCE and
__LIBPTHREAD_SOURCE__.

Include in this namespace <sys/tcl.h> and use __BEGIN_DECLS/__END_DECLS
for the sake of consistency.
 1.11 15-Feb-2018  kamil branches: 1.11.4;
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.10 12-Sep-2012  manu branches: 1.10.32;
setcontext() used to be incompatible with -lpthread since it affected
the TLS pointer, therefore wrecking the pthread environement.

Some ports had _UC_TLSBASE flag or equivalent (_UC_UNIQUE on alpha)
that controlled whether setcontext() would change the TLS pointer.
This change let libpthread override setcontext() with its own version
that unsets _UC_TLSBASE, enabling safe usage of setcontext() with
-lpthread.

We also have the following required changes here:
- rename alpha's _UC_UNIQUE into _UC_TLSBASE
- add _UC_TLSBASE definition in header file for all ports
(powerpc, sh3, sparc and sparc64 lack the implementation for now)
- introduce a libc stub that can be overriden for setcontext()
- modify MD libcs swapcontext() implementations so that they use the
setcontext() libc stub instead of doing a plain system call.

While we are there:
- document various MD _UC_* flags in header file
- add libc and libpthread tests for swapcontext() behavior
(hopefully helpful to spot MD problems introduced with this change)

Future work:
- Deciding whether kernel support or _UC_TLSBASE should be added for
powerpc, sh3, sparc and sparc64 is left to portmasters
sparc64

Approved by core@
 1.9 25-Feb-2011  joerg branches: 1.9.4;
Be nicer to software that insists on -ansi and use __inline.
 1.8 24-Feb-2011  joerg 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 01-Jun-2008  uwe branches: 1.7.20; 1.7.26; 1.7.28;
Recycle unused _REG_EXPEVT slot in mcontext for _REG_GBR.

As the size of mcontext is not changed, we avoid the hassle of
versioning all the calls that use it.

_REG_EXPEVT was never used by any code in the tree. Reporting EXPEVT
makes sense only for signals and in that case we pass it to userland
in ksi_trap already which is official MI way to get this (MD) information.

Old binaries running on new kernels will now have their GBR set from
new mcontext, but that's ok too, as GBR was not properly supported by
old kernels (not saved in trapframe), so old binaries couldn't have
possibly used it anyway.
 1.6 28-Apr-2008  martin branches: 1.6.2;
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 22-Nov-2003  uwe Add _UC_SETSTACK, _UC_CLRSTACK flags. Add __fpr_fpul to __fpregset_t
and redefine __fpr_regs as an array of 32 ints (SH3E has 16, SH4 has
32 32-bit FP registers) to reserve the space for FPU registers - we
will properly redefine this as a union when we do support FPU.
 1.3 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.2 18-Jan-2003  thorpej branches: 1.2.2;
Merge the nathanw_sa branch.
 1.1 20-Jun-2002  thorpej branches: 1.1.2;
file mcontext.h was initially added on branch nathanw_sa.
 1.1.2.2 20-Jun-2002  thorpej Provide _UC_MACHINE_SP().
 1.1.2.1 20-Jun-2002  thorpej Machine-dependent kernel portion of {get,set}context(). From
Klaus Klein.
 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.2 04-May-2009  yamt sync with head.
 1.5.78.1 16-May-2008  yamt sync with head.
 1.5.76.2 04-Jun-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.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.7.28.1 05-Mar-2011  bouyer Sync with HEAD
 1.7.26.1 06-Jun-2011  jruoho Sync with HEAD.
 1.7.20.1 05-Mar-2011  rmind sync with head
 1.9.4.1 30-Oct-2012  yamt sync with head
 1.10.32.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.10.32.2 26-Feb-2018  snj revert ticket 552, which broke the build
 1.10.32.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.11.4.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.13.2.1 02-Aug-2025  perseant Sync with HEAD
 1.2 16-Sep-1999  msaitoh remove sh3/include/mmeye.h
 1.1 13-Sep-1999  itojun Merge in NetBSD/sh3 from cvs.kame.net repository.

Tree structure:
- sys/arch/sh3: sh3 generic code
As commented, in-chip device drivers are put into sys/arch/sh3/dev.
- sys/arch/evbsh3: sh3 evaluation boards (pure sh3 CPU, no fancy external HW)
- sys/arch/mmeye: Brains mmEye, www.brains.co.jp
MI source code includes couple of #ifdef for sh3-coff support.
(sh3 uses coff or elf)

Needs some more improvements, especialy in sys/arch/sh3/conf/files.sh3,
to compile the tree (due to last minute tree structure change).
 1.11 23-Feb-2022  andvar fix various typos in comments, mainly immediatly/immediately/,
as well shared and recently fixed typos in OpenBSD code by Jonathan Grey.
 1.10 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.9 04-Mar-2006  uwe branches: 1.9.68; 1.9.70; 1.9.72;
s/u_intN_t/uintN_t/
 1.8 24-Jan-2006  uwe branches: 1.8.2; 1.8.4;
Consistently apply ifdef logic so that in SH3-only or SH4-only kernel
all references to CPU cpecific functions are direct, and unused hooks
are not defined.
 1.7 23-Jan-2006  uwe Delclare __sh_PTEH for SH3 && SH4 case.
 1.6 23-Jan-2006  uwe Fix sh_tlb_update signature for SH3 && SH4 case.
 1.5 09-May-2002  uch branches: 1.5.6; 1.5.28; 1.5.40;
remove obsoleted functions. add sh_tlb_update() for update TLB.
MMU mode is changed to multiple virtual storage mode for new pmap code.
 1.4 28-Apr-2002  uch Use "#define<tab>", white space nits.
 1.3 28-Feb-2002  uch branches: 1.3.2; 1.3.8;
Cleanup register definition
 1.2 22-Feb-2002  uch New NetBSD/sh3 clock framework.
+ hardclock source is moved from TMU1 to TMU0.
+ SH3/SH4 common kernel support.
+ PCLOCK estimation.
+ remove duplicated code.
 1.1 17-Feb-2002  uch Add new MMU API. for detail, see sh3/mmu.h's comment.
 1.3.8.3 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.3.8.2 16-Mar-2002  jdolecek Catch up with -current.
 1.3.8.1 28-Feb-2002  jdolecek file mmu.h was added on branch kqueue on 2002-03-16 15:59:38 +0000
 1.3.2.3 20-Jun-2002  nathanw Catch up to -current.
 1.3.2.2 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.3.2.1 28-Feb-2002  nathanw Catch up to -current.
 1.5.40.1 01-Feb-2006  yamt sync with head.
 1.5.28.1 21-Jun-2006  yamt sync with head.
 1.5.6.2 09-May-2002  uch remove obsoleted functions. add sh_tlb_update() for update TLB.
MMU mode is changed to multiple virtual storage mode for new pmap code.
 1.5.6.1 09-May-2002  uch file mmu.h was added on branch nathanw_sa on 2002-05-09 12:27:05 +0000
 1.8.4.1 22-Apr-2006  simonb Sync with head.
 1.8.2.1 09-Sep-2006  rpaulo sync with head
 1.9.72.1 16-May-2008  yamt sync with head.
 1.9.70.1 18-May-2008  yamt sync with head.
 1.9.68.1 02-Jun-2008  mjf Sync with HEAD.
 1.7 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.6 04-Mar-2006  uwe branches: 1.6.68; 1.6.70; 1.6.72;
s/u_intN_t/uintN_t/
 1.5 24-Dec-2005  perry branches: 1.5.4; 1.5.6;
__asm__ -> __asm
__const__ -> const
__inline__ -> inline
__volatile__ -> volatile
 1.4 09-May-2002  uch branches: 1.4.6; 1.4.28;
fix ASID mask define
 1.3 28-Apr-2002  uch Use "#define<tab>", white space nits.
 1.2 28-Feb-2002  uch branches: 1.2.2; 1.2.8;
Cleanup register definition
 1.1 17-Feb-2002  uch Add new MMU API. for detail, see sh3/mmu.h's comment.
 1.2.8.3 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.2.8.2 16-Mar-2002  jdolecek Catch up with -current.
 1.2.8.1 28-Feb-2002  jdolecek file mmu_sh3.h was added on branch kqueue on 2002-03-16 15:59:38 +0000
 1.2.2.3 20-Jun-2002  nathanw Catch up to -current.
 1.2.2.2 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.2.2.1 28-Feb-2002  nathanw Catch up to -current.
 1.4.28.1 21-Jun-2006  yamt sync with head.
 1.4.6.2 09-May-2002  uch fix ASID mask define
 1.4.6.1 09-May-2002  uch file mmu_sh3.h was added on branch nathanw_sa on 2002-05-09 12:26:17 +0000
 1.5.6.1 22-Apr-2006  simonb Sync with head.
 1.5.4.1 09-Sep-2006  rpaulo sync with head
 1.6.72.1 16-May-2008  yamt sync with head.
 1.6.70.1 18-May-2008  yamt sync with head.
 1.6.68.1 02-Jun-2008  mjf Sync with HEAD.
 1.8 28-Apr-2023  andvar fix few typos and grammar in comments.
 1.7 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.6 04-Mar-2006  uwe branches: 1.6.68; 1.6.70; 1.6.72;
s/u_intN_t/uintN_t/
 1.5 24-Dec-2005  perry branches: 1.5.4; 1.5.6;
__asm__ -> __asm
__const__ -> const
__inline__ -> inline
__volatile__ -> volatile
 1.4 09-May-2002  uch branches: 1.4.6; 1.4.28;
fix ASID mask define
 1.3 28-Apr-2002  uch Use "#define<tab>", white space nits.
 1.2 28-Feb-2002  uch branches: 1.2.2; 1.2.8;
Cleanup register definition
 1.1 17-Feb-2002  uch Add new MMU API. for detail, see sh3/mmu.h's comment.
 1.2.8.3 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.2.8.2 16-Mar-2002  jdolecek Catch up with -current.
 1.2.8.1 28-Feb-2002  jdolecek file mmu_sh4.h was added on branch kqueue on 2002-03-16 15:59:38 +0000
 1.2.2.3 20-Jun-2002  nathanw Catch up to -current.
 1.2.2.2 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.2.2.1 28-Feb-2002  nathanw Catch up to -current.
 1.4.28.1 21-Jun-2006  yamt sync with head.
 1.4.6.2 09-May-2002  uch fix ASID mask define
 1.4.6.1 09-May-2002  uch file mmu_sh4.h was added on branch nathanw_sa on 2002-05-09 12:26:17 +0000
 1.5.6.1 22-Apr-2006  simonb Sync with head.
 1.5.4.1 09-Sep-2006  rpaulo sync with head
 1.6.72.1 16-May-2008  yamt sync with head.
 1.6.70.1 18-May-2008  yamt sync with head.
 1.6.68.1 02-Jun-2008  mjf Sync with HEAD.
 1.8 28-Feb-2002  uch branches: 1.8.10;
Cleanup register definition
 1.7 17-Feb-2002  uch Add new MMU API. for detail, see sh3/mmu.h's comment.
 1.6 11-Feb-2002  uch add defines
 1.5 08-Feb-2002  uch add SH3/SH4 namespace free defines.
 1.4 04-Sep-2000  msaitoh branches: 1.4.4;
- move MMUCR_VALIDBITS definition into mmureg.h.
- access correct address in cacheflush().
 1.3 20-Mar-2000  msaitoh move MMUCR register definitions into mmureg.h
 1.2 16-Sep-1999  msaitoh branches: 1.2.2;
remove extra Id
 1.1 13-Sep-1999  itojun Merge in NetBSD/sh3 from cvs.kame.net repository.

Tree structure:
- sys/arch/sh3: sh3 generic code
As commented, in-chip device drivers are put into sys/arch/sh3/dev.
- sys/arch/evbsh3: sh3 evaluation boards (pure sh3 CPU, no fancy external HW)
- sys/arch/mmeye: Brains mmEye, www.brains.co.jp
MI source code includes couple of #ifdef for sh3-coff support.
(sh3 uses coff or elf)

Needs some more improvements, especialy in sys/arch/sh3/conf/files.sh3,
to compile the tree (due to last minute tree structure change).
 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.4.1 16-Mar-2002  jdolecek Catch up with -current.
 1.8.10.2 28-Feb-2002  uch Cleanup register definition
 1.8.10.1 28-Feb-2002  uch file mmureg.h was added on branch nathanw_sa on 2002-02-28 01:56:58 +0000
 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 29-Nov-2019  riastradh Nix now-unused definitions of MUTEX_GIVE/MUTEX_RECEIVE.
 1.9 28-Apr-2008  martin branches: 1.9.88;
Remove clause 3 and 4 from TNF licenses
 1.8 29-Nov-2007  ad branches: 1.8.14; 1.8.16; 1.8.18;
Pending review by uwe@:

- Make _lock_cas() do "compare and swap", not "compare and set".
- Add aliases for atomic_cas_ulong() and friends.
 1.7 21-Nov-2007  yamt make kmutex_t and krwlock_t smaller by killing lock id.
ok'ed by Andrew Doran.
 1.6 14-Mar-2007  uwe branches: 1.6.14; 1.6.16; 1.6.20; 1.6.22;
Implement fast-path mutex_enter and mutex_exit stubs.
 1.5 12-Mar-2007  uwe branches: 1.5.2;
Use simple mutexes. This file is effectively a copy of arm's one now.
 1.4 22-Feb-2007  uwe branches: 1.4.2; 1.4.6;
Undef __HAVE_MUTEX_STUBS, there are no mutex stubs yet.
 1.3 15-Feb-2007  ad branches: 1.3.2;
Add MUTEX_CLEAR_WAITERS().
 1.2 09-Feb-2007  ad Merge newlock2 to head.
 1.1 01-Feb-2007  ad branches: 1.1.2;
file mutex.h was initially added on branch newlock2.
 1.1.2.2 02-Feb-2007  ad Fix declarations. Spotted by uebayasi.
 1.1.2.1 01-Feb-2007  ad Get sh3 compiling.
 1.3.2.3 24-Mar-2007  yamt sync with head.
 1.3.2.2 12-Mar-2007  rmind Sync with HEAD.
 1.3.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.4.6.3 03-Dec-2007  ad Sync with HEAD.
 1.4.6.2 10-Apr-2007  ad Sync with head.
 1.4.6.1 13-Mar-2007  ad Sync with head.
 1.4.2.4 07-Dec-2007  yamt sync with head
 1.4.2.3 03-Sep-2007  yamt sync with head.
 1.4.2.2 26-Feb-2007  yamt sync with head.
 1.4.2.1 22-Feb-2007  yamt file mutex.h was added on branch yamt-lazymbuf on 2007-02-26 09:08:06 +0000
 1.5.2.1 11-Jul-2007  mjf Sync with head.
 1.6.22.1 08-Dec-2007  mjf Sync with HEAD.
 1.6.20.1 21-Nov-2007  bouyer Sync with HEAD
 1.6.16.1 09-Jan-2008  matt sync with HEAD
 1.6.14.2 03-Dec-2007  joerg Sync with HEAD.
 1.6.14.1 21-Nov-2007  joerg Sync with HEAD.
 1.8.18.1 16-May-2008  yamt sync with head.
 1.8.16.1 18-May-2008  yamt sync with head.
 1.8.14.1 02-Jun-2008  mjf Sync with HEAD.
 1.9.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.26 31-May-2021  simonb Include "opt_param.h" (ifdef _KERNEL_OPT) everywhere that MSGBUFSIZE is
referenced since some sources include <machine/param.h>.
 1.25 01-May-2020  isaki branches: 1.25.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.24 07-Jan-2019  jdolecek branches: 1.24.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.23 10-Feb-2012  para branches: 1.23.46; 1.23.48;
proper sizing of kmem_arena on different ports

PR port-i386/45946: Kernel locks up in VMEM system
 1.22 24-Jan-2012  christos Use and define ALIGN() ALIGN_POINTER() and STACK_ALIGN() consistently,
and avoid definining them in 10 different places if not needed.
 1.21 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.20 08-Feb-2010  joerg branches: 1.20.10; 1.20.14;
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.19 26-Oct-2007  uwe branches: 1.19.20; 1.19.40;
We don't need MIN_LWP_ALIGNMENT.
 1.18 17-Oct-2007  garbled Merge the ppcoea-renovation branch to HEAD.

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

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

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.17 23-Sep-2007  pooka branches: 1.17.2;
include machine/cpu.h instead of sh3/cpu.h. Effectively it's the
same, but makes rump build on sh3 platforms.
 1.16 09-Feb-2007  ad branches: 1.16.6; 1.16.14; 1.16.22; 1.16.24; 1.16.26;
Merge newlock2 to head.
 1.15 28-Aug-2006  yamt branches: 1.15.2;
- 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 24-Mar-2004  wiz branches: 1.13.16;
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.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 09-May-2002  uch branches: 1.11.6; 1.11.12;
new pmap designed for SH3/SH4.
 1.10 28-Apr-2002  uch Use "#define<tab>", white space nits.
 1.9 17-Mar-2002  uch kernel stack fix. old code simply P3 address converted to P1, it
caused memory destruction when kernel stack grow over 1 page. new
code use P3 address for kernel stack. but for the sake of debug, P1
kernel stack mode remain.
 1.8 10-Mar-2002  uch common part are moved to sh3/include/param.h
 1.7 28-Feb-2002  uch Remove #if 0 #endif
 1.6 26-Feb-2002  simonb 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.5 04-Jan-2001  itojun branches: 1.5.4;
split MACHINE_ARCH sh3e[lb]. userland build still needs checking.
 1.4 30-Jun-2000  itojun 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.3 11-Feb-2000  thorpej branches: 1.3.4;
Update for the NKMEMPAGES changes.
 1.2 04-Dec-1999  ragge CL* discarding.
 1.1 13-Sep-1999  itojun branches: 1.1.2; 1.1.8;
Merge in NetBSD/sh3 from cvs.kame.net repository.

Tree structure:
- sys/arch/sh3: sh3 generic code
As commented, in-chip device drivers are put into sys/arch/sh3/dev.
- sys/arch/evbsh3: sh3 evaluation boards (pure sh3 CPU, no fancy external HW)
- sys/arch/mmeye: Brains mmEye, www.brains.co.jp
MI source code includes couple of #ifdef for sh3-coff support.
(sh3 uses coff or elf)

Needs some more improvements, especialy in sys/arch/sh3/conf/files.sh3,
to compile the tree (due to last minute tree structure change).
 1.1.8.2 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.1.8.1 21-Dec-1999  wrstuden Initial commit of recent changes to make DEV_BSIZE go away.

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

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

Non 2**n block support is automatic for LKM's and conditional for kernels
on "options NON_PO2_BLOCKS".
 1.1.2.2 05-Jan-2001  bouyer Sync with HEAD
 1.1.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.3.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.5.4.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.5.4.1 16-Mar-2002  jdolecek Catch up with -current.
 1.11.12.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.11.12.2 18-Sep-2004  skrll Sync with HEAD.
 1.11.12.1 03-Aug-2004  skrll Sync with HEAD
 1.11.6.2 09-May-2002  uch new pmap designed for SH3/SH4.
 1.11.6.1 09-May-2002  uch file param.h was added on branch nathanw_sa on 2002-05-09 12:28:09 +0000
 1.13.16.3 27-Oct-2007  yamt sync with head.
 1.13.16.2 26-Feb-2007  yamt 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.2.1 01-Feb-2007  ad Get sh3 compiling.
 1.16.26.1 06-Oct-2007  yamt sync with head.
 1.16.24.1 06-Nov-2007  matt sync with HEAD
 1.16.22.2 28-Oct-2007  joerg Sync with HEAD.
 1.16.22.1 02-Oct-2007  joerg Sync with HEAD.
 1.16.14.1 03-Oct-2007  garbled Sync with HEAD
 1.16.6.2 03-Dec-2007  ad Sync with HEAD.
 1.16.6.1 09-Oct-2007  ad Sync with head.
 1.17.2.1 13-Nov-2007  bouyer Sync with HEAD
 1.19.40.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.19.20.1 11-Mar-2010  yamt sync with head
 1.20.14.1 18-Feb-2012  mrg merge to -current.
 1.20.10.1 17-Apr-2012  yamt sync with head
 1.23.48.1 10-Jun-2019  christos Sync with HEAD
 1.23.46.1 18-Jan-2019  pgoyette Synch with HEAD
 1.24.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.25.6.1 17-Jun-2021  thorpej Sync w/ HEAD.
 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 28-Apr-2008  martin branches: 1.9.88;
Remove clause 3 and 4 from TNF licenses
 1.8 04-Mar-2007  christos branches: 1.8.40; 1.8.42; 1.8.44;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.7 09-May-2002  uch branches: 1.7.6; 1.7.28; 1.7.66;
new pmap designed for SH3/SH4.
 1.6 28-Apr-2002  uch Use "#define<tab>", white space nits.
 1.5 17-Mar-2002  uch cosmetic changes, fix comments.
 1.4 17-Mar-2002  uch kernel stack fix. old code simply P3 address converted to P1, it
caused memory destruction when kernel stack grow over 1 page. new
code use P3 address for kernel stack. but for the sake of debug, P1
kernel stack mode remain.
 1.3 03-Mar-2002  uch SR related parts moved to psl.h. cpufunc.h segments.h are removed.
kernel mode checking is only SR.MD. no check stack pointer.
 1.2 14-Sep-1999  tsubai branches: 1.2.16;
Catch up with -current.
 1.1 13-Sep-1999  itojun Merge in NetBSD/sh3 from cvs.kame.net repository.

Tree structure:
- sys/arch/sh3: sh3 generic code
As commented, in-chip device drivers are put into sys/arch/sh3/dev.
- sys/arch/evbsh3: sh3 evaluation boards (pure sh3 CPU, no fancy external HW)
- sys/arch/mmeye: Brains mmEye, www.brains.co.jp
MI source code includes couple of #ifdef for sh3-coff support.
(sh3 uses coff or elf)

Needs some more improvements, especialy in sys/arch/sh3/conf/files.sh3,
to compile the tree (due to last minute tree structure change).
 1.2.16.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.2.16.1 16-Mar-2002  jdolecek Catch up with -current.
 1.7.66.1 12-Mar-2007  rmind Sync with HEAD.
 1.7.28.1 03-Sep-2007  yamt sync with head.
 1.7.6.2 09-May-2002  uch new pmap designed for SH3/SH4.
 1.7.6.1 09-May-2002  uch file pcb.h was added on branch nathanw_sa on 2002-05-09 12:28:09 +0000
 1.8.44.1 16-May-2008  yamt sync with head.
 1.8.42.1 18-May-2008  yamt sync with head.
 1.8.40.1 02-Jun-2008  mjf Sync with HEAD.
 1.9.88.1 10-Jun-2019  christos Sync with HEAD
 1.3 21-Jan-2012  nonaka fix my license notice.
 1.2 11-Dec-2005  christos branches: 1.2.18; 1.2.114; 1.2.118;
merge ktrace-lwp.
 1.1 16-Aug-2005  nonaka branches: 1.1.6;
Added SH7751{,R} integrated PCI controller support.
 1.1.6.2 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.1.6.1 16-Aug-2005  skrll file pcicreg.h was added on branch ktrace-lwp on 2005-11-10 13:58:38 +0000
 1.2.118.1 18-Feb-2012  mrg merge to -current.
 1.2.114.1 17-Apr-2012  yamt sync with head
 1.2.18.2 21-Jun-2006  yamt sync with head.
 1.2.18.1 11-Dec-2005  yamt file pcicreg.h was added on branch yamt-lazymbuf on 2006-06-21 14:55:31 +0000
 1.2 24-Feb-2002  uch branches: 1.2.10;
remove obsolete file.
 1.1 01-Feb-2002  uch branches: 1.1.2;
if PCLOCK isn't setted, use estimated value calculated by kernel.
 1.1.2.3 16-Mar-2002  jdolecek Catch up with -current.
 1.1.2.2 11-Feb-2002  jdolecek Sync w/ -current.
 1.1.2.1 01-Feb-2002  jdolecek file pclock.h was added on branch kqueue on 2002-02-11 20:09:01 +0000
 1.2.10.2 24-Feb-2002  uch remove obsolete file.
 1.2.10.1 24-Feb-2002  uch file pclock.h was added on branch nathanw_sa on 2002-02-24 18:13:07 +0000
 1.6 28-Apr-2002  uch branches: 1.6.6;
Use "#define<tab>", white space nits.
 1.5 17-Mar-2002  uch cosmetic changes, fix comments.
 1.4 28-Feb-2002  uch Cleanup register definition
 1.3 21-Feb-2001  uch branches: 1.3.4;
add SH7709/SH7709A I/O port register define
 1.2 16-Sep-1999  msaitoh branches: 1.2.2;
remove extra Id
 1.1 13-Sep-1999  itojun Merge in NetBSD/sh3 from cvs.kame.net repository.

Tree structure:
- sys/arch/sh3: sh3 generic code
As commented, in-chip device drivers are put into sys/arch/sh3/dev.
- sys/arch/evbsh3: sh3 evaluation boards (pure sh3 CPU, no fancy external HW)
- sys/arch/mmeye: Brains mmEye, www.brains.co.jp
MI source code includes couple of #ifdef for sh3-coff support.
(sh3 uses coff or elf)

Needs some more improvements, especialy in sys/arch/sh3/conf/files.sh3,
to compile the tree (due to last minute tree structure change).
 1.2.2.1 12-Mar-2001  bouyer Sync with HEAD.
 1.3.4.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.3.4.1 16-Mar-2002  jdolecek Catch up with -current.
 1.6.6.2 28-Apr-2002  uch Use "#define<tab>", white space nits.
 1.6.6.1 28-Apr-2002  uch file pfcreg.h was added on branch nathanw_sa on 2002-04-28 17:10:37 +0000
 1.3 28-Feb-2002  uch branches: 1.3.10;
Remove unneeded header.
 1.2 21-Sep-2001  chs fix type-o.
 1.1 13-Sep-1999  itojun branches: 1.1.14; 1.1.16;
Merge in NetBSD/sh3 from cvs.kame.net repository.

Tree structure:
- sys/arch/sh3: sh3 generic code
As commented, in-chip device drivers are put into sys/arch/sh3/dev.
- sys/arch/evbsh3: sh3 evaluation boards (pure sh3 CPU, no fancy external HW)
- sys/arch/mmeye: Brains mmEye, www.brains.co.jp
MI source code includes couple of #ifdef for sh3-coff support.
(sh3 uses coff or elf)

Needs some more improvements, especialy in sys/arch/sh3/conf/files.sh3,
to compile the tree (due to last minute tree structure change).
 1.1.16.2 16-Mar-2002  jdolecek Catch up with -current.
 1.1.16.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.1.14.1 01-Oct-2001  fvdl Catch up with -current.
 1.3.10.2 28-Feb-2002  uch Remove unneeded header.
 1.3.10.1 28-Feb-2002  uch file pio.h was added on branch nathanw_sa on 2002-02-28 01:52:29 +0000
 1.37 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.36 03-Sep-2016  christos branches: 1.36.16;
Fix pmap_prefer for topdown and turn topdown on.
 1.35 14-Nov-2010  uebayasi branches: 1.35.18; 1.35.36;
Move struct vm_page_md definition from vmparam.h to pmap.h, because
it's used only by pmap. vmparam.h has definitions for wider
audience.

All GENERIC kernels build tested, except ia64.

powerpc/include/booke/vmparam.h has one too, but it has no pmap.h,
so it's left as is.
 1.34 21-Oct-2009  rmind branches: 1.34.2; 1.34.4;
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.33 09-Dec-2008  pooka Make pmap_kernel() a MI macro for struct pmap *kernel_pmap_ptr,
which is now the "API" provided by the pmap module. pmap_kernel()
remains as the syntactic sugar.

Bonus cosmetics round: move all the pmap_t pointer typedefs into
uvm_pmap.h.

Thanks to Greg Oster for providing cpu muscle for doing test builds.
 1.32 28-Apr-2008  martin branches: 1.32.6; 1.32.8;
Remove clause 3 and 4 from TNF licenses
 1.31 21-Mar-2007  uwe branches: 1.31.34; 1.31.36; 1.31.38;
There are only 32 bits in a VA, not 33 - sync comment with this harsh reality.
 1.30 21-Feb-2007  thorpej branches: 1.30.4; 1.30.6; 1.30.8;
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.29 24-Sep-2006  tsutsui branches: 1.29.4;
Allow shared PV mappings in pmap_enter(9) even on SH4 if VAs of shared pages
have the same virtual cache indexes (i.e. they won't cause virtual cache
aliases). Also prepare PMAP_PREFER(9) for SH4 to avoid some possible virtual
cache aliases.
More stuff should be added in pmap_enter(9), but at least this changes
should fix some existing problems. See discussion on port-sh3 ML for details.

OK'ed by uwe and chs, and closes PR port-sh3/34243.
 1.28 10-Apr-2006  uwe branches: 1.28.8; 1.28.10;
Decorate pmap_remove_all() with /* ARGSUSED */
 1.27 16-Feb-2006  perry branches: 1.27.2; 1.27.4; 1.27.6;
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.26 24-Dec-2005  perry branches: 1.26.2; 1.26.4; 1.26.6;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.
 1.25 22-Sep-2002  chs branches: 1.25.22;
it really helps to get the stub right before cutting + pasting it 27 times.
alas, I did not. doh.
 1.24 22-Sep-2002  chs add pmap_remove_all() hook (empty on most platforms so far).
 1.23 09-May-2002  uch branches: 1.23.6;
new pmap designed for SH3/SH4.
 1.22 28-Apr-2002  uch Use "#define<tab>", white space nits.
 1.21 04-Apr-2002  uch remove obsolete functions, decralations and structure.
 1.20 03-Apr-2002  msaitoh sync with i386/include/pmap.h rev. 1.45:

make dangerous pmap_copy() and pmap_move() no-op.
 1.19 03-Mar-2002  uch SR related parts moved to psl.h. cpufunc.h segments.h are removed.
kernel mode checking is only SR.MD. no check stack pointer.
 1.18 28-Feb-2002  uch Remove #if 0 #endif
 1.17 17-Feb-2002  uch Add new MMU API. for detail, see sh3/mmu.h's comment.
 1.16 12-Feb-2002  uch ANSIfy KNF.
 1.15 11-Feb-2002  uch clean up redundant PTE PG_* defines.
PG_RO -> PG_KR
PG_RW -> PG_KW
PG_u -> PG_URKR
PG_PROT -> PG_UW
PG_AVAIL1 -> PG_PVLIST
 1.14 10-Sep-2001  chris Update pmap_update to now take the updated pmap as an argument.
This will allow improvements to the pmaps so that they can more easily defer expensive operations, eg tlb/cache flush, til the last possible moment.

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

Reviewed by Jason.
 1.13 26-May-2001  chs branches: 1.13.2; 1.13.4;
replace {simple_,}lock{_data,}_t with struct {simple,}lock {,*}.
 1.12 22-Apr-2001  thorpej Undo a misguided previous change to the pmap_update() API.
 1.11 22-Apr-2001  uch make this compile again under SH4
 1.10 22-Apr-2001  thorpej Give pmap_update() an argument (a pmap_t) so that it knows which
pmap it should be updating.
 1.9 21-Apr-2001  thorpej pmap_update() should not be equated with "flush entire TLB", it is
used to process deferred pmap operations. Since these pmaps don't
defer anything, pmap_update() is a noop.
 1.8 19-Feb-2001  msaitoh branches: 1.8.2;
temporary fix a serious pmap problem with dummy PMAP_{MAP,UNMAP}_POOLPAGE().

To fix correctly, set IOM_RAM_BEGIN with P0 addr instead of P1 addr and
fix machdep.c and pmap.c.
 1.7 02-Feb-2001  thorpej Rewrite how mod/ref emulation is done. In particular, make
modified attribute checking actually work. Previously, a
page could be reported as modified even if it wasn't! This
is very bad, and e.g. caused the VM system to attempt to
"clean" pages of read-only files.

Only lip-services is paid to referenced attribute emulation.
This could be improved.
 1.6 28-Sep-2000  is We do wired page accounting. Tell UVM about this.
 1.5 25-Apr-2000  tsubai branches: 1.5.4;
Use P1SEG to map pool pages.
 1.4 24-Feb-2000  msaitoh SH4!
 1.3 14-Jan-2000  msaitoh remove SH3_PHYS_TO_P1SEG macro
 1.2 14-Sep-1999  tsubai branches: 1.2.2;
Catch up with -current.
 1.1 13-Sep-1999  itojun Merge in NetBSD/sh3 from cvs.kame.net repository.

Tree structure:
- sys/arch/sh3: sh3 generic code
As commented, in-chip device drivers are put into sys/arch/sh3/dev.
- sys/arch/evbsh3: sh3 evaluation boards (pure sh3 CPU, no fancy external HW)
- sys/arch/mmeye: Brains mmEye, www.brains.co.jp
MI source code includes couple of #ifdef for sh3-coff support.
(sh3 uses coff or elf)

Needs some more improvements, especialy in sys/arch/sh3/conf/files.sh3,
to compile the tree (due to last minute tree structure change).
 1.2.2.4 23-Apr-2001  bouyer Sync with HEAD.
 1.2.2.3 12-Mar-2001  bouyer Sync with HEAD.
 1.2.2.2 11-Feb-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.5.4.1 28-Sep-2000  is Pullup from -current, requested by is, approved by thorpej:

sys/arch/arm32/include/pmap.h 1.18
sys/arch/atari/include/pmap.h 1.21
sys/arch/i386/include/pmap.h 1.50
sys/arch/pc532/include/pmap.h 1.29
sys/arch/sh3/include/pmap.h 1.6

These are architectures that do implemented wired page accounting;
advertize it to UVM, so that mlock() from non-root processes works.
 1.8.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.13.4.1 01-Oct-2001  fvdl Catch up with -current.
 1.13.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.13.2.3 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.13.2.2 16-Mar-2002  jdolecek Catch up with -current.
 1.13.2.1 13-Sep-2001  thorpej Update the kqueue branch to HEAD.
 1.23.6.2 18-Oct-2002  nathanw Catch up to -current.
 1.23.6.1 09-May-2002  nathanw file pmap.h was added on branch nathanw_sa on 2002-10-18 02:39:44 +0000
 1.25.22.4 03-Sep-2007  yamt sync with head.
 1.25.22.3 26-Feb-2007  yamt sync with head.
 1.25.22.2 30-Dec-2006  yamt sync with head.
 1.25.22.1 21-Jun-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.26.2.1 18-Feb-2006  yamt sync with head.
 1.27.6.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.27.4.1 19-Apr-2006  elad sync with head - hopefully this will work
 1.27.2.1 11-Apr-2006  yamt sync with head
 1.28.10.1 22-Oct-2006  yamt sync with head
 1.28.8.1 18-Nov-2006  ad Sync with head.
 1.29.4.2 24-Mar-2007  yamt sync with head.
 1.29.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.30.8.1 29-Mar-2007  reinoud Pullup to -current
 1.30.6.1 11-Jul-2007  mjf Sync with head.
 1.30.4.1 10-Apr-2007  ad Sync with head.
 1.31.38.3 11-Mar-2010  yamt sync with head
 1.31.38.2 04-May-2009  yamt sync with head.
 1.31.38.1 16-May-2008  yamt sync with head.
 1.31.36.1 18-May-2008  yamt sync with head.
 1.31.34.2 17-Jan-2009  mjf Sync with HEAD.
 1.31.34.1 02-Jun-2008  mjf Sync with HEAD.
 1.32.8.1 19-Jan-2009  skrll Sync with HEAD.
 1.32.6.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.34.4.1 05-Mar-2011  rmind sync with head
 1.34.2.1 16-Nov-2010  uebayasi Sync with HEAD.
 1.35.36.1 05-Oct-2016  skrll Sync with HEAD
 1.35.18.1 03-Dec-2017  jdolecek update from HEAD
 1.36.16.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.2 14-Sep-1999  tsubai Catch up with -current.
 1.1 13-Sep-1999  itojun Merge in NetBSD/sh3 from cvs.kame.net repository.

Tree structure:
- sys/arch/sh3: sh3 generic code
As commented, in-chip device drivers are put into sys/arch/sh3/dev.
- sys/arch/evbsh3: sh3 evaluation boards (pure sh3 CPU, no fancy external HW)
- sys/arch/mmeye: Brains mmEye, www.brains.co.jp
MI source code includes couple of #ifdef for sh3-coff support.
(sh3 uses coff or elf)

Needs some more improvements, especialy in sys/arch/sh3/conf/files.sh3,
to compile the tree (due to last minute tree structure change).
 1.4 30-Jul-2020  uwe Publicly declare st40_pmb_init().
 1.3 30-Jul-2020  uwe ST40_PMB_DA_BITS - all values for the non-continuous size field.

Size field has two reserved bits in the middle. Don't depend on them
being zero, they can be defined in future versions. Provide exhaustive
list with all possibile "filler" bits in the middle so that we
correctly report the size field value regardless of the unrelated bits.
 1.2 30-Jul-2020  uwe Add snprintb formats. Fix PASCR name.
 1.1 25-Jul-2020  uwe Definitions for ST40 Privileged Mapping Buffer.
 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:39:49 +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:53 +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:51 +0000
 1.18 08-Jan-2019  jdolecek remove <machine/param.h> include, nothing from it is actually used here
 1.17 08-Jul-2012  dsl branches: 1.17.38; 1.17.40;
The MDP_USEDFPU (amd64 and sh3) and MDP_SSTEP (sh3) are lwp flags not
process ones, rename to MDL_xxx.
 1.16 26-Jan-2011  uwe branches: 1.16.4;
Add MDP_SSTEP flag. Not used yet.
 1.15 14-Jan-2011  rmind branches: 1.15.2; 1.15.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.14 21-Nov-2009  rmind branches: 1.14.4;
Use lwp_getpcb() on mips, powerpc and sh3, clean from struct user usage.
 1.13 15-Feb-2008  uwe branches: 1.13.10;
G/c vestiges of curpute hack that was obsoleted by the fast TLB miss handler.
 1.12 09-Feb-2007  ad branches: 1.12.24; 1.12.30;
Merge newlock2 to head.
 1.11 11-Oct-2006  he Forward-declare "struct lwp" before using it in an argument declaration.
Gets rid of a recurring lint warning whenever this file is included.
 1.10 11-Dec-2005  christos branches: 1.10.20; 1.10.22;
merge ktrace-lwp.
 1.9 10-Jul-2005  uwe Implement syscall_intern for sh3.
 1.8 10-Jul-2005  uwe Cosmetic: use uintN_t, drop leading underscores from the volatile
keyword, use extern in function declarations.
 1.7 24-Mar-2004  wiz branches: 1.7.16;
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.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 18-Jan-2003  thorpej branches: 1.5.2;
Merge the nathanw_sa branch.
 1.4 09-May-2002  uch branches: 1.4.6;
new pmap designed for SH3/SH4.
 1.3 17-Mar-2002  uch kernel stack fix. old code simply P3 address converted to P1, it
caused memory destruction when kernel stack grow over 1 page. new
code use P3 address for kernel stack. but for the sake of debug, P1
kernel stack mode remain.
 1.2 10-Mar-2002  uch proc0 and page table intialize routines are moved to sh3_machdep.c
 1.1 13-Sep-1999  itojun branches: 1.1.16;
Merge in NetBSD/sh3 from cvs.kame.net repository.

Tree structure:
- sys/arch/sh3: sh3 generic code
As commented, in-chip device drivers are put into sys/arch/sh3/dev.
- sys/arch/evbsh3: sh3 evaluation boards (pure sh3 CPU, no fancy external HW)
- sys/arch/mmeye: Brains mmEye, www.brains.co.jp
MI source code includes couple of #ifdef for sh3-coff support.
(sh3 uses coff or elf)

Needs some more improvements, especialy in sys/arch/sh3/conf/files.sh3,
to compile the tree (due to last minute tree structure change).
 1.1.16.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.1.16.1 16-Mar-2002  jdolecek Catch up with -current.
 1.4.6.3 22-Jun-2002  thorpej Include <machine/param.h> for UPAGES.
 1.4.6.2 21-Jun-2002  thorpej Add support for scheduler activations on SuperH. Boots multi-user
on Dreamcast (SH4) with stock userland.
 1.4.6.1 09-May-2002  thorpej file proc.h was added on branch nathanw_sa on 2002-06-21 21:26:28 +0000
 1.5.2.4 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 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.7.16.4 27-Feb-2008  yamt sync with head.
 1.7.16.3 26-Feb-2007  yamt sync with head.
 1.7.16.2 30-Dec-2006  yamt sync with head.
 1.7.16.1 21-Jun-2006  yamt sync with head.
 1.10.22.1 22-Oct-2006  yamt sync with head
 1.10.20.2 01-Feb-2007  ad Get sh3 compiling.
 1.10.20.1 18-Nov-2006  ad Sync with head.
 1.12.30.1 18-Feb-2008  mjf Sync with HEAD.
 1.12.24.1 23-Mar-2008  matt sync with HEAD
 1.13.10.1 11-Mar-2010  yamt sync with head
 1.14.4.1 05-Mar-2011  rmind sync with head
 1.15.4.1 08-Feb-2011  bouyer Sync with HEAD
 1.15.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.16.4.1 30-Oct-2012  yamt sync with head
 1.17.40.1 10-Jun-2019  christos Sync with HEAD
 1.17.38.1 18-Jan-2019  pgoyette Synch with HEAD
 1.6 26-Jul-2022  andvar s/fucntion/function/ in comments.
 1.5 26-Oct-2006  uwe Fix __mcount to use bsrf to call _mcount. We know it's in the same
module (in the same file even), so we know the offset at link time and
don't need a reloc. This kills the last text relocation in the sh3
libc.so.

While here, tweak the code slightly to put delay slots into use.
 1.4 28-Apr-2002  uch branches: 1.4.6; 1.4.28; 1.4.58; 1.4.60;
Use "#define<tab>", white space nits.
 1.3 04-Feb-2002  thorpej Fix for ELF + __NO_LEADING_UNDERSCORES__.
 1.2 22-Aug-2000  tsubai branches: 1.2.4;
MD part of mcount.
 1.1 13-Sep-1999  itojun branches: 1.1.2;
Merge in NetBSD/sh3 from cvs.kame.net repository.

Tree structure:
- sys/arch/sh3: sh3 generic code
As commented, in-chip device drivers are put into sys/arch/sh3/dev.
- sys/arch/evbsh3: sh3 evaluation boards (pure sh3 CPU, no fancy external HW)
- sys/arch/mmeye: Brains mmEye, www.brains.co.jp
MI source code includes couple of #ifdef for sh3-coff support.
(sh3 uses coff or elf)

Needs some more improvements, especialy in sys/arch/sh3/conf/files.sh3,
to compile the tree (due to last minute tree structure change).
 1.1.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.2.4.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.2.4.1 11-Feb-2002  jdolecek Sync w/ -current.
 1.4.60.1 10-Dec-2006  yamt sync with head.
 1.4.58.1 18-Nov-2006  ad Sync with head.
 1.4.28.1 30-Dec-2006  yamt sync with head.
 1.4.6.2 28-Apr-2002  uch Use "#define<tab>", white space nits.
 1.4.6.1 28-Apr-2002  uch file profile.h was added on branch nathanw_sa on 2002-04-28 17:10:37 +0000
 1.13 27-Jun-2025  andvar Fix various typos, mainly in comments.
 1.12 03-Aug-2020  uwe branches: 1.12.26;
_cpu_exception_suspend - return old SR

In a typical use case we do a very short code sequence with PSL_BL set
and restore the old PSL_BL value with _cpu_exception_resume that does
the full read/mask/set dance. In reality we are just restoring SR to
its old state as no other modifications to SR can possibly happen. So
return old SR and let the caller restore it in one instruction.
 1.11 26-Jan-2011  uwe Add sh4 PSL_FD - FPU disable bit.
 1.10 04-Jan-2008  uwe branches: 1.10.32; 1.10.38; 1.10.40;
There's no need to pull in machine/intr.h here.
 1.9 15-Oct-2006  uwe branches: 1.9.28; 1.9.34; 1.9.42;
Don't include <machine/intr.h> in asm sources.
 1.8 11-Dec-2005  christos branches: 1.8.20; 1.8.22;
merge ktrace-lwp.
 1.7 07-Aug-2003  agc branches: 1.7.16;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.6 09-May-2002  uch branches: 1.6.6; 1.6.12;
remove unused macro.
 1.5 28-Apr-2002  uch Use "#define<tab>", white space nits.
 1.4 24-Mar-2002  uch Rework interrupt code.
+ Fully utilize SH SR.I[0:3] interrupt level.
+ software interrupt is emulated by TMU1, 2 one shot interrupt.
+ implement generic soft interrupts.
+ implement clockframe correctly.
 1.3 03-Mar-2002  uch SR related parts moved to psl.h. cpufunc.h segments.h are removed.
kernel mode checking is only SR.MD. no check stack pointer.
 1.2 16-May-2001  msaitoh branches: 1.2.2;
sigreturn() fix (from kleink)
 1.1 13-Sep-1999  itojun branches: 1.1.12; 1.1.14;
Merge in NetBSD/sh3 from cvs.kame.net repository.

Tree structure:
- sys/arch/sh3: sh3 generic code
As commented, in-chip device drivers are put into sys/arch/sh3/dev.
- sys/arch/evbsh3: sh3 evaluation boards (pure sh3 CPU, no fancy external HW)
- sys/arch/mmeye: Brains mmEye, www.brains.co.jp
MI source code includes couple of #ifdef for sh3-coff support.
(sh3 uses coff or elf)

Needs some more improvements, especialy in sys/arch/sh3/conf/files.sh3,
to compile the tree (due to last minute tree structure change).
 1.1.14.1 21-Jun-2001  nathanw Catch up to -current.
 1.1.12.1 26-May-2001  he Pull up revision 1.2 (requested by kleink):
Validate Status Register passed from userland in sigreturn().
 1.2.2.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.2.2.1 16-Mar-2002  jdolecek Catch up with -current.
 1.6.12.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.6.12.2 18-Sep-2004  skrll Sync with HEAD.
 1.6.12.1 03-Aug-2004  skrll Sync with HEAD
 1.6.6.2 09-May-2002  uch remove unused macro.
 1.6.6.1 09-May-2002  uch file psl.h was added on branch nathanw_sa on 2002-05-09 12:31:39 +0000
 1.7.16.2 21-Jan-2008  yamt sync with head
 1.7.16.1 30-Dec-2006  yamt sync with head.
 1.8.22.1 22-Oct-2006  yamt sync with head
 1.8.20.1 18-Nov-2006  ad Sync with head.
 1.9.42.1 08-Jan-2008  bouyer Sync with HEAD
 1.9.34.1 18-Feb-2008  mjf Sync with HEAD.
 1.9.28.1 09-Jan-2008  matt sync with HEAD
 1.10.40.1 08-Feb-2011  bouyer Sync with HEAD
 1.10.38.1 06-Jun-2011  jruoho Sync with HEAD.
 1.10.32.1 05-Mar-2011  rmind sync with head
 1.12.26.1 02-Aug-2025  perseant Sync with HEAD
 1.12 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.11 04-Mar-2006  uwe branches: 1.11.68; 1.11.70; 1.11.72;
s/u_intN_t/uintN_t/
 1.10 11-Dec-2005  christos branches: 1.10.4; 1.10.6;
merge ktrace-lwp.
 1.9 10-Aug-2003  chs branches: 1.9.16;
fix typos in comments.
 1.8 09-May-2002  uch branches: 1.8.6; 1.8.12;
new pmap designed for SH3/SH4.
 1.7 28-Apr-2002  uch Use "#define<tab>", white space nits.
 1.6 17-Feb-2002  uch Add new MMU API. for detail, see sh3/mmu.h's comment.
 1.5 11-Feb-2002  uch change PTE PG_* bit define to support SH4 PCMCIA space attribute fully.
for detail, see pte.h.
 1.4 24-Feb-2000  msaitoh branches: 1.4.8;
SH4!
 1.3 24-Feb-2000  msaitoh G.C.
 1.2 14-Jan-2000  msaitoh write through bit (SH4)
 1.1 13-Sep-1999  itojun branches: 1.1.2;
Merge in NetBSD/sh3 from cvs.kame.net repository.

Tree structure:
- sys/arch/sh3: sh3 generic code
As commented, in-chip device drivers are put into sys/arch/sh3/dev.
- sys/arch/evbsh3: sh3 evaluation boards (pure sh3 CPU, no fancy external HW)
- sys/arch/mmeye: Brains mmEye, www.brains.co.jp
MI source code includes couple of #ifdef for sh3-coff support.
(sh3 uses coff or elf)

Needs some more improvements, especialy in sys/arch/sh3/conf/files.sh3,
to compile the tree (due to last minute tree structure change).
 1.1.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.4.8.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.4.8.1 16-Mar-2002  jdolecek Catch up with -current.
 1.8.12.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.8.12.2 18-Sep-2004  skrll Sync with HEAD.
 1.8.12.1 03-Aug-2004  skrll Sync with HEAD
 1.8.6.2 09-May-2002  uch new pmap designed for SH3/SH4.
 1.8.6.1 09-May-2002  uch file pte.h was added on branch nathanw_sa on 2002-05-09 12:28:09 +0000
 1.9.16.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.72.1 16-May-2008  yamt sync with head.
 1.11.70.1 18-May-2008  yamt sync with head.
 1.11.68.1 02-Jun-2008  mjf Sync with HEAD.
 1.19 15-Oct-2020  mgorny Fix the machine-dependent ptrace requests to respect LWP number

Fix the machine-dependent ptrace register-related requests (e.g.
PT_GETXMMREGS, PT_GETXSTATE on x86) to correctly respect the LWP number
passed as the data argument. Before this change, these requests
did not operate on the requested LWP of a multithreaded program.

This change required moving ptrace_update_lwp() out of unit scope,
and changing ptrace_machdep_dorequest() function to take a pointer
to pointer as the second argument, consistently with ptrace_regs().

I am planning to extend the ATF ptrace() register tests in the future
to check for regressions in multithreaded programs, as time permits.

Reviewed by kamil.
 1.18 14-Sep-2020  mrg apply some parens to make macros safe. fixes GCC 9 sanitizer issues.
 1.17 24-Dec-2019  kamil Introduce PT_LWPSTATUS + PT_LWPNEXT, obsolete PT_LWPINFO

PT_LWPINFO is a legacy ptrace(2) operation that was originally intended
to retrieve the thread (LWP) information inside a traced process.

It has a number of flaws and is confused with PT_LWPINFO from FreeBSD.

PT_LWPSTATUS and PT_LWPNEXT address the problems (shortly by: rename,
removal of pl_event) and introduces new features: signal context
(pl_sigpend, pl_sigmask), LWP name (pl_name), LWP TLS base address
(pl_private). The private pointer was so far missing information for
a debugger.

PT_LWPSTATUS@nnn is now shipped with core(5) files and contain LWP specific
information, so far missed in the core(5) files.

PT_LWPSTATUS retrieves LWP information for the prompted thread.
PT_LWPNEXT retrieves LWP information for the next thread, borrowing the
semantics from NetBSD specific PT_LWPINFO.

PT_LWPINFO is namespaced with __LEGACY_PT_LWPINFO and still available for
the foreseeable future, without plans of removing it.

Add ATF tests for PT_LWPSTATUS + PT_LWPNEXT.

Keep ATF tests for PT_LWPINFO.

Switch GDB to new API.

Proposed on tech-kern@.
 1.16 04-Oct-2019  maya Provide PTRACE_ILLEGAL_ASM, using an illegal slot instruction
 1.15 18-Jun-2019  kamil branches: 1.15.2;
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.14 12-Apr-2017  kamil branches: 1.14.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.13 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.12 25-Sep-2015  christos branches: 1.12.2; 1.12.4;
For processors that have memory breakpoints, add macros for them to help
libproc
 1.11 15-Sep-2015  christos Provide access to pc/sp/syscall-return registers like we have for mcontext
 1.10 31-Oct-2011  uwe branches: 1.10.12; 1.10.30;
#if-0'ed defines for PT_GETFPREGS and PT_SETFPREGS. Not used yet, but
reserve the numbers as they are "leaked" to readelf(1), that has to know
them as NT_NETBSDCORE_FIRSTMACH + x (see get_netbsd_elfcore_note_type).
 1.9 28-Jan-2011  uwe Implement PT_STEP.
 1.8 27-Oct-2008  uwe branches: 1.8.14; 1.8.20; 1.8.22;
Implement PT___GETREGS40 and PT___SETREGS40 under COMPAT_40 so that
old gdb works on newer kernels.
 1.7 26-Oct-2008  uwe branches: 1.7.2;
Add r_gbr to struct reg. Provide old definition as struct __reg40.
Rename old PT_GETREG to PT___GETREG40, PT_SETREG to PT___SETREG40.
 1.6 26-Oct-2008  uwe Oops, make #endif comment properly reflect the test.
 1.5 26-Oct-2008  uwe Multiple inclusion protection.
 1.4 25-Jan-2008  skrll branches: 1.4.6; 1.4.10; 1.4.16;
Define PT_MACHDEP_STRINGS
 1.3 28-Feb-2002  uch branches: 1.3.12; 1.3.34; 1.3.96; 1.3.102;
Remove #if 0 #endif
 1.2 10-May-2000  msaitoh branches: 1.2.8;
supports single step!
 1.1 13-Sep-1999  itojun branches: 1.1.2;
Merge in NetBSD/sh3 from cvs.kame.net repository.

Tree structure:
- sys/arch/sh3: sh3 generic code
As commented, in-chip device drivers are put into sys/arch/sh3/dev.
- sys/arch/evbsh3: sh3 evaluation boards (pure sh3 CPU, no fancy external HW)
- sys/arch/mmeye: Brains mmEye, www.brains.co.jp
MI source code includes couple of #ifdef for sh3-coff support.
(sh3 uses coff or elf)

Needs some more improvements, especialy in sys/arch/sh3/conf/files.sh3,
to compile the tree (due to last minute tree structure change).
 1.1.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.2.8.1 16-Mar-2002  jdolecek Catch up with -current.
 1.3.102.1 18-Feb-2008  mjf Sync with HEAD.
 1.3.96.1 23-Mar-2008  matt sync with HEAD
 1.3.34.1 04-Feb-2008  yamt sync with head.
 1.3.12.2 28-Feb-2002  uch Remove #if 0 #endif
 1.3.12.1 28-Feb-2002  uch file ptrace.h was added on branch nathanw_sa on 2002-02-28 01:58:54 +0000
 1.4.16.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.4.10.1 04-May-2009  yamt sync with head.
 1.4.6.1 17-Jan-2009  mjf Sync with HEAD.
 1.7.2.1 19-Jan-2009  skrll Sync with HEAD.
 1.8.22.1 08-Feb-2011  bouyer Sync with HEAD
 1.8.20.1 06-Jun-2011  jruoho Sync with HEAD.
 1.8.14.1 05-Mar-2011  rmind sync with head
 1.10.30.3 28-Aug-2017  skrll Sync with HEAD
 1.10.30.2 27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.10.30.1 22-Sep-2015  skrll Sync with HEAD
 1.10.12.1 03-Dec-2017  jdolecek update from HEAD
 1.12.4.1 21-Apr-2017  bouyer Sync with HEAD
 1.12.2.1 26-Apr-2017  pgoyette Sync with HEAD
 1.14.12.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.14.12.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.15.2.1 18-Oct-2020  martin Pull up following revision(s) (requested by kamil in ticket #1117):

sys/arch/sh3/include/ptrace.h: revision 1.19
sys/arch/amd64/amd64/process_machdep.c: revision 1.48
sys/arch/sh3/sh3/process_machdep.c: revision 1.23
sys/arch/sh3/sh3/process_machdep.c: revision 1.24
sys/arch/i386/i386/process_machdep.c: revision 1.95
sys/arch/x86/x86/fpu.c (apply patch)
sys/kern/sys_ptrace_common.c: revision 1.84
sys/arch/powerpc/powerpc/process_machdep.c: revision 1.40
sys/sys/ptrace.h: revision 1.71
sys/arch/powerpc/powerpc/process_machdep.c: revision 1.41
(all via patch, adapted)

Fix s87_tw reconstruction to correctly indicate register states

Fix the code reconstructing s87_tw (full tag word) from fx_sw (abridged
tag word) to correctly represent all register states. The previous code
only distinguished between empty/non-empty registers, and assigned
'regular value' to all non-empty registers. The new code explicitly
distinguishes the two other tag word values: empty and special.

Fix the machine-dependent ptrace register-related requests (e.g.
PT_GETXMMREGS, PT_GETXSTATE on x86) to correctly respect the LWP number
passed as the data argument. Before this change, these requests
did not operate on the requested LWP of a multithreaded program.
This change required moving ptrace_update_lwp() out of unit scope,
and changing ptrace_machdep_dorequest() function to take a pointer
to pointer as the second argument, consistently with ptrace_regs().

I am planning to extend the ATF ptrace() register tests in the future
to check for regressions in multithreaded programs, as time permits.

Reviewed by kamil.

Add missing 'error' declaration
 1.7 26-Oct-2008  uwe Fix typo in comment inherited from i386 (spotted by mjf@).
 1.6 26-Oct-2008  uwe Add r_gbr to struct reg. Provide old definition as struct __reg40.
Rename old PT_GETREG to PT___GETREG40, PT_SETREG to PT___SETREG40.
 1.5 11-Dec-2005  christos branches: 1.5.74; 1.5.78; 1.5.84;
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 28-Apr-2002  uch branches: 1.3.6; 1.3.12;
Use "#define<tab>", white space nits.
 1.2 13-Apr-2000  msaitoh branches: 1.2.8;
exports MACH and MACL registers, too.
 1.1 13-Sep-1999  itojun branches: 1.1.2;
Merge in NetBSD/sh3 from cvs.kame.net repository.

Tree structure:
- sys/arch/sh3: sh3 generic code
As commented, in-chip device drivers are put into sys/arch/sh3/dev.
- sys/arch/evbsh3: sh3 evaluation boards (pure sh3 CPU, no fancy external HW)
- sys/arch/mmeye: Brains mmEye, www.brains.co.jp
MI source code includes couple of #ifdef for sh3-coff support.
(sh3 uses coff or elf)

Needs some more improvements, especialy in sys/arch/sh3/conf/files.sh3,
to compile the tree (due to last minute tree structure change).
 1.1.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.2.8.1 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.3.12.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.3.12.2 18-Sep-2004  skrll Sync with HEAD.
 1.3.12.1 03-Aug-2004  skrll Sync with HEAD
 1.3.6.2 28-Apr-2002  uch Use "#define<tab>", white space nits.
 1.3.6.1 28-Apr-2002  uch file reg.h was added on branch nathanw_sa on 2002-04-28 17:10:37 +0000
 1.5.84.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.5.78.1 04-May-2009  yamt sync with head.
 1.5.74.1 17-Jan-2009  mjf Sync with HEAD.
 1.11 19-Oct-2006  uwe SH_RCR2_BITS for bitmask_snprintf.
 1.10 03-Sep-2006  uwe branches: 1.10.2; 1.10.4;
Add comments to RCR1 and RCR2 bits.
 1.9 04-Mar-2006  uwe branches: 1.9.2;
s/u_intN_t/uintN_t/
 1.8 28-Apr-2002  uch branches: 1.8.6; 1.8.28; 1.8.42; 1.8.44;
Use "#define<tab>", white space nits.
 1.7 17-Mar-2002  uch cosmetic changes, fix comments.
 1.6 28-Feb-2002  uch Cleanup register definition
 1.5 22-Feb-2002  uch New NetBSD/sh3 clock framework.
+ hardclock source is moved from TMU1 to TMU0.
+ SH3/SH4 common kernel support.
+ PCLOCK estimation.
+ remove duplicated code.
 1.4 22-Apr-2001  uch branches: 1.4.2;
add RTC control register 1 defines.
 1.3 21-Dec-1999  msaitoh branches: 1.3.6;
add some register definitions
 1.2 16-Sep-1999  msaitoh branches: 1.2.2; 1.2.8;
remove extra Id
 1.1 13-Sep-1999  itojun Merge in NetBSD/sh3 from cvs.kame.net repository.

Tree structure:
- sys/arch/sh3: sh3 generic code
As commented, in-chip device drivers are put into sys/arch/sh3/dev.
- sys/arch/evbsh3: sh3 evaluation boards (pure sh3 CPU, no fancy external HW)
- sys/arch/mmeye: Brains mmEye, www.brains.co.jp
MI source code includes couple of #ifdef for sh3-coff support.
(sh3 uses coff or elf)

Needs some more improvements, especialy in sys/arch/sh3/conf/files.sh3,
to compile the tree (due to last minute tree structure change).
 1.2.8.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.2.2.2 23-Apr-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.3.6.1 21-Jun-2001  nathanw Catch up to -current.
 1.4.2.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.4.2.1 16-Mar-2002  jdolecek Catch up with -current.
 1.8.44.1 22-Apr-2006  simonb Sync with head.
 1.8.42.1 09-Sep-2006  rpaulo sync with head
 1.8.28.2 30-Dec-2006  yamt sync with head.
 1.8.28.1 21-Jun-2006  yamt sync with head.
 1.8.6.2 28-Apr-2002  uch Use "#define<tab>", white space nits.
 1.8.6.1 28-Apr-2002  uch file rtcreg.h was added on branch nathanw_sa on 2002-04-28 17:10:37 +0000
 1.9.2.1 14-Sep-2006  yamt sync with head.
 1.10.4.1 22-Oct-2006  yamt sync with head
 1.10.2.1 18-Nov-2006  ad Sync with head.
 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 29-Nov-2007  ad branches: 1.4.14; 1.4.16; 1.4.18;
Pending review by uwe@:

- Make _lock_cas() do "compare and swap", not "compare and set".
- Add aliases for atomic_cas_ulong() and friends.
 1.3 21-Nov-2007  yamt 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 01-Feb-2007  ad branches: 1.1.2;
file rwlock.h was initially added on branch newlock2.
 1.1.2.1 01-Feb-2007  ad Get sh3 compiling.
 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.2 03-Dec-2007  joerg 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:08:06 +0000
 1.4.18.1 16-May-2008  yamt sync with head.
 1.4.16.1 18-May-2008  yamt sync with head.
 1.4.14.1 02-Jun-2008  mjf Sync with HEAD.
 1.5.88.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.12 17-Aug-2021  andvar fix multiplei repetitive typos in comments, messages and documentation. mainly because copy paste code big amount of files are affected.
 1.11 28-May-2019  msaitoh s/recieve/receive/
 1.10 18-Feb-2006  uwe branches: 1.10.160;
Make _BASE visible regardless of #ifdef SHx.
Add defines for SMR bits in IrDA mode in 7709.
 1.9 14-Feb-2006  uwe Fix file comment to include the expansion for 'F' in "SCIF".
 1.8 14-Feb-2006  uwe Define scif register base(s) and offsets.
Express old defines in terms of base + offset.
Use uintN_t.
 1.7 13-Feb-2006  uwe Move/merge common defintions out of ifdef.
 1.6 11-Dec-2005  christos branches: 1.6.2; 1.6.4; 1.6.6;
merge ktrace-lwp.
 1.5 29-Jun-2005  christos branches: 1.5.2;
more additions from nonaka's landisk port.
 1.4 19-May-2002  msaitoh branches: 1.4.4; 1.4.10;
fix some overflow cases.
 1.3 28-Apr-2002  uch branches: 1.3.2;
Use "#define<tab>", white space nits.
 1.2 16-Sep-1999  msaitoh branches: 1.2.16;
cleanup
 1.1 13-Sep-1999  itojun Merge in NetBSD/sh3 from cvs.kame.net repository.

Tree structure:
- sys/arch/sh3: sh3 generic code
As commented, in-chip device drivers are put into sys/arch/sh3/dev.
- sys/arch/evbsh3: sh3 evaluation boards (pure sh3 CPU, no fancy external HW)
- sys/arch/mmeye: Brains mmEye, www.brains.co.jp
MI source code includes couple of #ifdef for sh3-coff support.
(sh3 uses coff or elf)

Needs some more improvements, especialy in sys/arch/sh3/conf/files.sh3,
to compile the tree (due to last minute tree structure change).
 1.2.16.1 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.3.2.1 30-May-2002  gehenna Catch up with -current.
 1.4.10.1 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.4.4.2 19-May-2002  msaitoh fix some overflow cases.
 1.4.4.1 19-May-2002  msaitoh file scifreg.h was added on branch nathanw_sa on 2002-05-19 15:10:47 +0000
 1.5.2.1 21-Jun-2006  yamt sync with head.
 1.6.6.1 22-Apr-2006  simonb Sync with head.
 1.6.4.1 09-Sep-2006  rpaulo sync with head
 1.6.2.1 18-Feb-2006  yamt sync with head.
 1.10.160.1 10-Jun-2019  christos Sync with HEAD
 1.10 14-May-2013  tsutsui Add a definition of SCSCMR1, smart card mode register available on 7750 etc.
 1.9 30-Apr-2009  nonaka branches: 1.9.12; 1.9.22;
Added some register definition.
 1.8 01-Jul-2003  uwe branches: 1.8.108; 1.8.122;
Correct the macro name for SCP0DT bit.
Addresses port-sh3/22025 by FURUKAWA Masashi.
 1.7 28-Apr-2002  uch branches: 1.7.6;
Use "#define<tab>", white space nits.
 1.6 26-Apr-2002  msaitoh fix around PTR and PDR
 1.5 25-Apr-2002  msaitoh add missing SCPDR_SCP0DT definition
 1.4 24-Mar-2002  uch Rework interrupt code.
+ Fully utilize SH SR.I[0:3] interrupt level.
+ software interrupt is emulated by TMU1, 2 one shot interrupt.
+ implement generic soft interrupts.
+ implement clockframe correctly.
 1.3 12-Jun-2001  wiz branches: 1.3.2;
receive, not recieve
 1.2 16-Sep-1999  msaitoh branches: 1.2.14;
cleanup
 1.1 13-Sep-1999  itojun Merge in NetBSD/sh3 from cvs.kame.net repository.

Tree structure:
- sys/arch/sh3: sh3 generic code
As commented, in-chip device drivers are put into sys/arch/sh3/dev.
- sys/arch/evbsh3: sh3 evaluation boards (pure sh3 CPU, no fancy external HW)
- sys/arch/mmeye: Brains mmEye, www.brains.co.jp
MI source code includes couple of #ifdef for sh3-coff support.
(sh3 uses coff or elf)

Needs some more improvements, especialy in sys/arch/sh3/conf/files.sh3,
to compile the tree (due to last minute tree structure change).
 1.2.14.1 21-Jun-2001  nathanw Catch up to -current.
 1.3.2.1 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.7.6.2 28-Apr-2002  uch Use "#define<tab>", white space nits.
 1.7.6.1 28-Apr-2002  uch file scireg.h was added on branch nathanw_sa on 2002-04-28 17:10:37 +0000
 1.8.122.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.8.108.1 04-May-2009  yamt sync with head.
 1.9.22.1 23-Jun-2013  tls resync from head
 1.9.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.3 03-Mar-2002  uch branches: 1.3.8;
SR related parts moved to psl.h. cpufunc.h segments.h are removed.
kernel mode checking is only SR.MD. no check stack pointer.
 1.2 24-Jun-2001  msaitoh branches: 1.2.2;
fix KERNELMODE() macro (check MD bits, too)
 1.1 13-Sep-1999  itojun branches: 1.1.12;
Merge in NetBSD/sh3 from cvs.kame.net repository.

Tree structure:
- sys/arch/sh3: sh3 generic code
As commented, in-chip device drivers are put into sys/arch/sh3/dev.
- sys/arch/evbsh3: sh3 evaluation boards (pure sh3 CPU, no fancy external HW)
- sys/arch/mmeye: Brains mmEye, www.brains.co.jp
MI source code includes couple of #ifdef for sh3-coff support.
(sh3 uses coff or elf)

Needs some more improvements, especialy in sys/arch/sh3/conf/files.sh3,
to compile the tree (due to last minute tree structure change).
 1.1.12.1 08-Oct-2001  he Pull up revision 1.2 (requested by msaitoh):
Fix KERNELMODE macro (check MD bits too).
 1.2.2.1 16-Mar-2002  jdolecek Catch up with -current.
 1.3.8.2 03-Mar-2002  uch SR related parts moved to psl.h. cpufunc.h segments.h are removed.
kernel mode checking is only SR.MD. no check stack pointer.
 1.3.8.1 03-Mar-2002  uch file segments.h was added on branch nathanw_sa on 2002-03-03 14:31:26 +0000
 1.3 05-Jan-2006  uwe Provide defines for offsets into the jump buffer.
 1.2 28-Apr-2002  uch branches: 1.2.6; 1.2.26; 1.2.28; 1.2.40;
Use "#define<tab>", white space nits.
 1.1 13-Sep-1999  itojun branches: 1.1.16;
Merge in NetBSD/sh3 from cvs.kame.net repository.

Tree structure:
- sys/arch/sh3: sh3 generic code
As commented, in-chip device drivers are put into sys/arch/sh3/dev.
- sys/arch/evbsh3: sh3 evaluation boards (pure sh3 CPU, no fancy external HW)
- sys/arch/mmeye: Brains mmEye, www.brains.co.jp
MI source code includes couple of #ifdef for sh3-coff support.
(sh3 uses coff or elf)

Needs some more improvements, especialy in sys/arch/sh3/conf/files.sh3,
to compile the tree (due to last minute tree structure change).
 1.1.16.1 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.2.40.1 15-Jan-2006  yamt sync with head.
 1.2.28.1 21-Jun-2006  yamt sync with head.
 1.2.26.1 11-Jan-2006  tron Pull up following revision(s) (requested by uwe in ticket #1098):
sys/arch/sh3/include/setjmp.h: revision 1.3
Provide defines for offsets into the jump buffer.
 1.2.6.2 28-Apr-2002  uch Use "#define<tab>", white space nits.
 1.2.6.1 28-Apr-2002  uch file setjmp.h was added on branch nathanw_sa on 2002-04-28 17:10:37 +0000
 1.3 28-Apr-2002  uch branches: 1.3.6;
Use "#define<tab>", white space nits.
 1.2 02-Aug-2000  msaitoh branches: 1.2.4;
check _BYTE_ORDER instead of BYTE_ORDER
 1.1 13-Sep-1999  itojun branches: 1.1.2; 1.1.12;
Merge in NetBSD/sh3 from cvs.kame.net repository.

Tree structure:
- sys/arch/sh3: sh3 generic code
As commented, in-chip device drivers are put into sys/arch/sh3/dev.
- sys/arch/evbsh3: sh3 evaluation boards (pure sh3 CPU, no fancy external HW)
- sys/arch/mmeye: Brains mmEye, www.brains.co.jp
MI source code includes couple of #ifdef for sh3-coff support.
(sh3 uses coff or elf)

Needs some more improvements, especialy in sys/arch/sh3/conf/files.sh3,
to compile the tree (due to last minute tree structure change).
 1.1.12.1 08-Aug-2000  msaitoh Pullup revision 1.2 (approved by thorpej):

check _BYTE_ORDER instead of BYTE_ORDER to fix namespace pollution
(and it's necessary to compile src/usr.bin/xlint/llib)
 1.1.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.2.4.1 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.3.6.2 28-Apr-2002  uch Use "#define<tab>", white space nits.
 1.3.6.1 28-Apr-2002  uch file sh_opcode.h was added on branch nathanw_sa on 2002-04-28 17:10:37 +0000
 1.3 24-Mar-2002  uch branches: 1.3.4;
shb device is integrated to sh3/dev/shb.c and clean up locators.
 1.2 12-Feb-2002  uch ANSIfy KNF.
 1.1 13-Sep-1999  itojun branches: 1.1.16;
Merge in NetBSD/sh3 from cvs.kame.net repository.

Tree structure:
- sys/arch/sh3: sh3 generic code
As commented, in-chip device drivers are put into sys/arch/sh3/dev.
- sys/arch/evbsh3: sh3 evaluation boards (pure sh3 CPU, no fancy external HW)
- sys/arch/mmeye: Brains mmEye, www.brains.co.jp
MI source code includes couple of #ifdef for sh3-coff support.
(sh3 uses coff or elf)

Needs some more improvements, especialy in sys/arch/sh3/conf/files.sh3,
to compile the tree (due to last minute tree structure change).
 1.1.16.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.1.16.1 16-Mar-2002  jdolecek Catch up with -current.
 1.3.4.2 24-Mar-2002  uch shb device is integrated to sh3/dev/shb.c and clean up locators.
 1.3.4.1 24-Mar-2002  uch file shbvar.h was added on branch nathanw_sa on 2002-03-24 18:00:42 +0000
 1.17 29-Oct-2021  thorpej Define __HAVE_STRUCT_SIGCONTEXT regardless of its current visibility.
 1.16 27-Oct-2021  thorpej Make sigcontext13 visible only to _KERNEL. Make sigcontext visible only
to _LIBC and _KERNEL.
 1.15 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.14 29-Nov-2017  christos need <sys/sigtypes.h> for sigset_t
 1.13 19-Nov-2008  ad branches: 1.13.26;
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.12 11-Dec-2005  christos branches: 1.12.74; 1.12.78; 1.12.84; 1.12.86;
merge ktrace-lwp.
 1.11 10-May-2004  drochner SIGTRAMP_VALID() should not pollute the user namespace
 1.10 26-Mar-2004  drochner nothing cares about __HAVE_SIGINFO anymore, so nuke it
 1.9 25-Nov-2003  christos bye, bye _MCONTEXT_TO_SIGCONTEXT and vice versa.
 1.8 23-Nov-2003  uwe Implement siginfo for sh3.
 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 28-Apr-2003  bjh21 branches: 1.6.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.5 18-Jan-2003  thorpej Merge the nathanw_sa branch.
 1.4 10-May-2002  uch branches: 1.4.6;
remove COMPAT_13 staff. No 1.3 release of sh3 port. these are trace of
i386 port.
 1.3 09-May-2002  uch s/trapno/expevt/ for clarity.
 1.2 28-Apr-2002  uch Use "#define<tab>", white space nits.
 1.1 13-Sep-1999  itojun branches: 1.1.16;
Merge in NetBSD/sh3 from cvs.kame.net repository.

Tree structure:
- sys/arch/sh3: sh3 generic code
As commented, in-chip device drivers are put into sys/arch/sh3/dev.
- sys/arch/evbsh3: sh3 evaluation boards (pure sh3 CPU, no fancy external HW)
- sys/arch/mmeye: Brains mmEye, www.brains.co.jp
MI source code includes couple of #ifdef for sh3-coff support.
(sh3 uses coff or elf)

Needs some more improvements, especialy in sys/arch/sh3/conf/files.sh3,
to compile the tree (due to last minute tree structure change).
 1.1.16.1 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.4.6.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.4.6.1 10-May-2002  thorpej file signal.h was added on branch nathanw_sa on 2003-01-16 03:14:57 +0000
 1.6.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.6.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.6.2.1 03-Aug-2004  skrll Sync with HEAD
 1.12.86.1 19-Jan-2009  skrll Sync with HEAD.
 1.12.84.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.12.78.1 04-May-2009  yamt sync with head.
 1.12.74.1 17-Jan-2009  mjf Sync with HEAD.
 1.13.26.1 03-Dec-2017  jdolecek update from HEAD
 1.11 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.10 03-Jul-2011  mrg add GCC 4.5 support.
 1.9 21-May-2006  uwe New stdarg.h and varargs.h based on arm and i386 versions.

Use __builtin_va_* instead of hand written code in va-sh.h that uses
LHS casts. Slightly worse code is generated by gcc 3.3.3, but LHS
casts are outlawed in gcc 3.3.6 and gcc 4.

Build-tested on hpcsh (le) and mmeye (be), run-tested on hpcsh.
 1.8 11-Dec-2005  christos branches: 1.8.4; 1.8.6; 1.8.8; 1.8.12; 1.8.14;
merge ktrace-lwp.
 1.7 05-Jan-2005  uwe branches: 1.7.10;
Fix lint stub for va_start so that lint is actually happy about it.
 1.6 28-Apr-2003  bjh21 branches: 1.6.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.5 28-Apr-2002  uch branches: 1.5.6;
Use "#define<tab>", white space nits.
 1.4 04-Feb-2002  thorpej * Make this lint'able.
* Reduce some code duplication.
 1.3 03-Feb-2000  kleink branches: 1.3.8;
Add a C99-style va_copy macro.
 1.2 16-Sep-1999  msaitoh branches: 1.2.2;
add NetBSD RCS ID
 1.1 13-Sep-1999  itojun Merge in NetBSD/sh3 from cvs.kame.net repository.

Tree structure:
- sys/arch/sh3: sh3 generic code
As commented, in-chip device drivers are put into sys/arch/sh3/dev.
- sys/arch/evbsh3: sh3 evaluation boards (pure sh3 CPU, no fancy external HW)
- sys/arch/mmeye: Brains mmEye, www.brains.co.jp
MI source code includes couple of #ifdef for sh3-coff support.
(sh3 uses coff or elf)

Needs some more improvements, especialy in sys/arch/sh3/conf/files.sh3,
to compile the tree (due to last minute tree structure change).
 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.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.3.8.1 11-Feb-2002  jdolecek Sync w/ -current.
 1.5.6.2 28-Apr-2002  uch Use "#define<tab>", white space nits.
 1.5.6.1 28-Apr-2002  uch file stdarg.h was added on branch nathanw_sa on 2002-04-28 17:10:38 +0000
 1.6.2.1 17-Jan-2005  skrll Sync with HEAD.
 1.7.10.1 21-Jun-2006  yamt sync with head.
 1.8.14.1 19-Jun-2006  chap Sync with head.
 1.8.12.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.8.8.1 24-May-2006  yamt sync with head.
 1.8.6.1 01-Jun-2006  kardel Sync with head.
 1.8.4.1 09-Sep-2006  rpaulo sync with head
 1.1 02-Mar-2018  uwe Introduce sh3/sysarch.h and add SH3_SYNC_ICACHE
 1.11 04-Mar-2006  uwe s/u_intN_t/uintN_t/
 1.10 11-Dec-2005  christos branches: 1.10.4; 1.10.6;
merge ktrace-lwp.
 1.9 03-Jul-2005  nonaka branches: 1.9.2;
fix timer prescaler definition.
 1.8 29-Jun-2005  christos more additions from nonaka's landisk port.
 1.7 28-Apr-2002  uch branches: 1.7.6; 1.7.12;
Use "#define<tab>", white space nits.
 1.6 28-Feb-2002  uch Cleanup register definition
 1.5 22-Feb-2002  uch New NetBSD/sh3 clock framework.
+ hardclock source is moved from TMU1 to TMU0.
+ SH3/SH4 common kernel support.
+ PCLOCK estimation.
+ remove duplicated code.
 1.4 20-Mar-2000  msaitoh branches: 1.4.8;
Add the definitions of SH4's TPSC field of TCR register
(This field is not compatible with SH3's)
 1.3 17-Jan-2000  msaitoh add some bit definitions
 1.2 16-Sep-1999  msaitoh branches: 1.2.2;
cleanup
 1.1 13-Sep-1999  itojun Merge in NetBSD/sh3 from cvs.kame.net repository.

Tree structure:
- sys/arch/sh3: sh3 generic code
As commented, in-chip device drivers are put into sys/arch/sh3/dev.
- sys/arch/evbsh3: sh3 evaluation boards (pure sh3 CPU, no fancy external HW)
- sys/arch/mmeye: Brains mmEye, www.brains.co.jp
MI source code includes couple of #ifdef for sh3-coff support.
(sh3 uses coff or elf)

Needs some more improvements, especialy in sys/arch/sh3/conf/files.sh3,
to compile the tree (due to last minute tree structure change).
 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.8.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.4.8.1 16-Mar-2002  jdolecek Catch up with -current.
 1.7.12.1 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.7.6.2 28-Apr-2002  uch Use "#define<tab>", white space nits.
 1.7.6.1 28-Apr-2002  uch file tmureg.h was added on branch nathanw_sa on 2002-04-28 17:10:38 +0000
 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.4 09-May-2002  uch branches: 1.4.4;
rework general exception, and TLB exception handling for new pmap.
all exception staffs are moved to exception.[ch]
 1.3 28-Apr-2002  uch Use "#define<tab>", white space nits.
 1.2 17-Mar-2002  uch change to per-process AST.
 1.1 13-Sep-1999  itojun branches: 1.1.16;
Merge in NetBSD/sh3 from cvs.kame.net repository.

Tree structure:
- sys/arch/sh3: sh3 generic code
As commented, in-chip device drivers are put into sys/arch/sh3/dev.
- sys/arch/evbsh3: sh3 evaluation boards (pure sh3 CPU, no fancy external HW)
- sys/arch/mmeye: Brains mmEye, www.brains.co.jp
MI source code includes couple of #ifdef for sh3-coff support.
(sh3 uses coff or elf)

Needs some more improvements, especialy in sys/arch/sh3/conf/files.sh3,
to compile the tree (due to last minute tree structure change).
 1.1.16.1 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.4.4.2 09-May-2002  uch rework general exception, and TLB exception handling for new pmap.
all exception staffs are moved to exception.[ch]
 1.4.4.1 09-May-2002  uch file trap.h was added on branch nathanw_sa on 2002-05-09 12:24:21 +0000
 1.4 24-Mar-2002  uch branches: 1.4.4;
Rework interrupt code.
+ Fully utilize SH SR.I[0:3] interrupt level.
+ software interrupt is emulated by TMU1, 2 one shot interrupt.
+ implement generic soft interrupts.
+ implement clockframe correctly.
 1.3 02-Mar-2002  uch Add SH7709A INTEVT2 register define.
 1.2 28-Feb-2002  uch Cleanup register definition
 1.1 13-Sep-1999  itojun branches: 1.1.16;
Merge in NetBSD/sh3 from cvs.kame.net repository.

Tree structure:
- sys/arch/sh3: sh3 generic code
As commented, in-chip device drivers are put into sys/arch/sh3/dev.
- sys/arch/evbsh3: sh3 evaluation boards (pure sh3 CPU, no fancy external HW)
- sys/arch/mmeye: Brains mmEye, www.brains.co.jp
MI source code includes couple of #ifdef for sh3-coff support.
(sh3 uses coff or elf)

Needs some more improvements, especialy in sys/arch/sh3/conf/files.sh3,
to compile the tree (due to last minute tree structure change).
 1.1.16.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.1.16.1 16-Mar-2002  jdolecek Catch up with -current.
 1.4.4.2 24-Mar-2002  uch Rework interrupt code.
+ Fully utilize SH SR.I[0:3] interrupt level.
+ software interrupt is emulated by TMU1, 2 one shot interrupt.
+ implement generic soft interrupts.
+ implement clockframe correctly.
 1.4.4.1 24-Mar-2002  uch file trapreg.h was added on branch nathanw_sa on 2002-03-24 18:04:40 +0000
 1.38 30-Apr-2020  skrll G/C __HAVE_AST_PERPROC
 1.37 23-Jan-2016  christos expose the kernel types for standalone code.
 1.36 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.35 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.34 17-Jul-2011  dyoung branches: 1.34.12; 1.34.30;
Switch to new-style <sys/bus.h>.
 1.33 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.32 12-Mar-2011  joerg branches: 1.32.2;
Add TLS support for AMD64, i386 and SH3.

This material is based upon work partially supported by
The NetBSD Foundation under a contract with Joerg Sonnenberger.
 1.31 24-Feb-2011  joerg 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.30 22-Dec-2010  matt branches: 1.30.2; 1.30.4;
Add a define __HAVE_CPU_DATA_FIRST which means that cpu_data is the first
member in struct cpu_info.
 1.29 11-Dec-2009  matt branches: 1.29.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.28 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.27 20-Jan-2008  joerg branches: 1.27.10;
Now that __HAVE_TIMECOUNTER and __HAVE_GENERIC_TODR are invariants,
remove the conditionals and the code associated with the undef case.
 1.26 17-Oct-2007  garbled branches: 1.26.2; 1.26.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.25 14-Jul-2007  ad branches: 1.25.10;
Generic soft interrupts are mandatory.
 1.24 24-Sep-2006  tsutsui branches: 1.24.8; 1.24.16;
Add timecounter support for SH3 ports. From gdamore on port-sh3,
with several minor fixes by me.

Previously sh3 ports use two timers (TMU1 and TMU2) as oneshot timer
to cause real hardware interrupts by softintr(9), but now softintr(9)
uses only TMU1 and TMU2 is configured as freerunning counter for
timecounter(9).

Tested on my dreamcast.
 1.23 20-Sep-2006  uwe Switch the rest of sh3 ports to todr(9)
Split code to handle on-chip rtc into a separate driver
Eliminate all todr code from clock.c
Move __HAVE_GENERIC_TODR to sh3/include/types.h
 1.22 11-Dec-2005  christos branches: 1.22.20; 1.22.22;
merge ktrace-lwp.
 1.21 10-Jul-2005  uwe Implement syscall_intern for sh3.
 1.20 10-Jul-2005  uwe Cosmetic: drop leading underscores from the volatile keyword.
 1.19 18-Jan-2005  chs branches: 1.19.8;
sh3 no longer abuses cf_unit.
 1.18 18-Jan-2004  martin branches: 1.18.8;
Do not export __HAVE_RAS to userland. Applications are supposed to try
rasctl() and detect failure with EOPNOTSUPP.
 1.17 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.16 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.15 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 16-Dec-2002  thorpej Add support for RAS (initially added by me on nathanw_sa branch).
 1.13 16-Dec-2002  thorpej Use MI setrunqueue()/remrunqueue().
 1.12 22-Sep-2002  simonb Use "#define\t" instead of "#define ".
 1.11 22-Sep-2002  gmcgarry Add __HAVE_MD_RUNQUEUE flag for MD code to override MI run queue primitives.
 1.10 28-Apr-2002  uch branches: 1.10.6;
Use "#define<tab>", white space nits.
 1.9 24-Mar-2002  uch Rework interrupt code.
+ Fully utilize SH SR.I[0:3] interrupt level.
+ software interrupt is emulated by TMU1, 2 one shot interrupt.
+ implement generic soft interrupts.
+ implement clockframe correctly.
 1.8 17-Mar-2002  uch cosmetic changes, fix comments.
 1.7 17-Mar-2002  uch change to per-process AST.
 1.6 28-Feb-2002  simonb Use "#define<tab>".
 1.5 28-Apr-2001  kleink branches: 1.5.2;
* 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 03-Jan-2001  takemura branches: 1.4.2;
replace 'long long' with int64_t to compile stand alone program with
compiler other than GCC.
 1.3 04-Sep-2000  tsubai Correct label_t size.
 1.2 05-Feb-2000  cgd add __BROKEN_CONFIG_UNIT_USAGE #define, becuase these ports do very
wrong things with device configuration data "cf_unit" information.
 1.1 13-Sep-1999  itojun branches: 1.1.2;
Merge in NetBSD/sh3 from cvs.kame.net repository.

Tree structure:
- sys/arch/sh3: sh3 generic code
As commented, in-chip device drivers are put into sys/arch/sh3/dev.
- sys/arch/evbsh3: sh3 evaluation boards (pure sh3 CPU, no fancy external HW)
- sys/arch/mmeye: Brains mmEye, www.brains.co.jp
MI source code includes couple of #ifdef for sh3-coff support.
(sh3 uses coff or elf)

Needs some more improvements, especialy in sys/arch/sh3/conf/files.sh3,
to compile the tree (due to last minute tree structure change).
 1.1.2.2 05-Jan-2001  bouyer Sync with HEAD
 1.1.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.4.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.5.2.3 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.5.2.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.5.2.1 16-Mar-2002  jdolecek Catch up with -current.
 1.10.6.4 16-Dec-2002  thorpej Sync with HEAD.
 1.10.6.3 18-Oct-2002  nathanw Catch up to -current.
 1.10.6.2 07-Oct-2002  thorpej Add support for restartable atomic sequences.
 1.10.6.1 28-Apr-2002  thorpej file types.h was added on branch nathanw_sa on 2002-10-07 03:11:03 +0000
 1.15.2.5 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.15.2.4 24-Jan-2005  skrll Sync with HEAD.
 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.18.8.1 29-Apr-2005  kent sync with -current
 1.19.8.4 21-Jan-2008  yamt sync with head
 1.19.8.3 03-Sep-2007  yamt sync with head.
 1.19.8.2 30-Dec-2006  yamt sync with head.
 1.19.8.1 21-Jun-2006  yamt sync with head.
 1.22.22.1 22-Oct-2006  yamt sync with head
 1.22.20.1 18-Nov-2006  ad Sync with head.
 1.24.16.1 03-Oct-2007  garbled Sync with HEAD
 1.24.8.1 15-Jul-2007  ad Sync with head.
 1.25.10.2 23-Mar-2008  matt sync with HEAD
 1.25.10.1 06-Nov-2007  matt sync with HEAD
 1.26.8.1 23-Jan-2008  bouyer Sync with HEAD.
 1.26.2.1 18-Feb-2008  mjf Sync with HEAD.
 1.27.10.1 11-Mar-2010  yamt sync with head
 1.29.4.3 21-Apr-2011  rmind sync with head
 1.29.4.2 05-Mar-2011  rmind sync with head
 1.29.4.1 18-Mar-2010  rmind Unify /dev/{mem,kmem,zero,null} implementations in MI code. Based on patch
from Joerg Sonnenberger, proposed on tech-kern@, in February 2008.

Work and depression still in progress.
 1.30.4.1 05-Mar-2011  bouyer Sync with HEAD
 1.30.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.32.2.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.34.30.2 19-Mar-2016  skrll Sync with HEAD
 1.34.30.1 22-Sep-2015  skrll Sync with HEAD
 1.34.12.1 03-Dec-2017  jdolecek update from HEAD
 1.5 06-Jun-2008  uwe Provide defines for bits we use.
 1.4 04-Mar-2006  uwe branches: 1.4.68; 1.4.70; 1.4.72; 1.4.74;
s/u_intN_t/uintN_t/
 1.3 28-Apr-2002  uch branches: 1.3.6; 1.3.28; 1.3.42; 1.3.44;
Use "#define<tab>", white space nits.
 1.2 28-Feb-2002  uch Cleanup register definition
 1.1 13-Sep-1999  itojun branches: 1.1.16;
Merge in NetBSD/sh3 from cvs.kame.net repository.

Tree structure:
- sys/arch/sh3: sh3 generic code
As commented, in-chip device drivers are put into sys/arch/sh3/dev.
- sys/arch/evbsh3: sh3 evaluation boards (pure sh3 CPU, no fancy external HW)
- sys/arch/mmeye: Brains mmEye, www.brains.co.jp
MI source code includes couple of #ifdef for sh3-coff support.
(sh3 uses coff or elf)

Needs some more improvements, especialy in sys/arch/sh3/conf/files.sh3,
to compile the tree (due to last minute tree structure change).
 1.1.16.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.1.16.1 16-Mar-2002  jdolecek Catch up with -current.
 1.3.44.1 22-Apr-2006  simonb Sync with head.
 1.3.42.1 09-Sep-2006  rpaulo sync with head
 1.3.28.1 21-Jun-2006  yamt sync with head.
 1.3.6.2 28-Apr-2002  uch Use "#define<tab>", white space nits.
 1.3.6.1 28-Apr-2002  uch file ubcreg.h was added on branch nathanw_sa on 2002-04-28 17:10:38 +0000
 1.4.74.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.4.72.1 04-May-2009  yamt sync with head.
 1.4.70.1 17-Jun-2008  yamt sync with head.
 1.4.68.1 29-Jun-2008  mjf Sync with HEAD.
 1.18 07-Jan-2020  skrll Fix indentation. NFCI
 1.17 01-Dec-2019  ad sh3: make ASTs work as expected, and fix a few things in the TLB refill path.
With help from uwe@ and martin@.
 1.16 30-Nov-2019  ad Revert previous. Looks like it requires a more extensive fix.
 1.15 29-Nov-2019  ad PR port-sparc/54718 (sparc install hangs since recent scheduler changes)

- userret() must be called every time we return to user, it's not optional.
- If clearing the AST with interrupts off, you must loop over userret().
 1.14 02-Nov-2016  pgoyette branches: 1.14.16;
* Split sys/kern/sys_process.c into three parts:
1 - ptrace(2) syscall for native emulation
2 - common ptrace(2) syscall code (shared with compat_netbsd32)
3 - support routines that are shared with PROCFS and/or KTRACE

* Add module glue for #1 and #2. Both modules will be built-in to the
kernel if "options PTRACE" is included in the config file (this is
the default, defined in sys/conf/std).

* Mark the ptrace(2) syscall as modular in syscalls.master (generated
files will be committed shortly).

* Conditionalize all remaining portions of PTRACE code on a new kernel
option PTRACE_HOOKS.

XXX Instead of PROCFS depending on 'options PTRACE', we should probably
just add a procfs attribute to the sys/kern/sys_process.c file's
entry in files.kern, and add PROCFS to the "#if defineds" for
process_domem(). It's really confusing to have two different ways
of requiring this file.
 1.13 08-Jul-2012  dsl branches: 1.13.2; 1.13.16; 1.13.20;
The MDP_USEDFPU (amd64 and sh3) and MDP_SSTEP (sh3) are lwp flags not
process ones, rename to MDL_xxx.
 1.12 08-Feb-2011  rmind branches: 1.12.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.11 28-Jan-2011  uwe Implement PT_STEP.
 1.10 05-Nov-2007  ad branches: 1.10.42; 1.10.48; 1.10.50;
Don't set l_usrpri / spc_curpriority here. mi_userret() does it.
 1.9 16-Feb-2006  perry branches: 1.9.24; 1.9.42; 1.9.44; 1.9.48;
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.8 24-Dec-2005  perry branches: 1.8.2; 1.8.4; 1.8.6;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.
 1.7 11-Dec-2005  christos merge ktrace-lwp.
 1.6 31-Oct-2003  cl branches: 1.6.16;
Reduce code duplication by adding mi_userret() in sys/userret.h
containing signal posting, kernel-exit handling and sa_upcall processing.

XXX the pc532, sparc, sparc64 and vax ports should have their
XXX userret() code rearranged to use this.
 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 18-Jan-2003  thorpej branches: 1.4.2;
Merge the nathanw_sa branch.
 1.3 09-May-2002  uch branches: 1.3.6; 1.3.8;
remove postsig. postsig is called by ast().
 1.2 28-Apr-2002  msaitoh add missing postsig() call.
I don't know whether this is true fix or not.
 1.1 17-Mar-2002  uch branches: 1.1.4;
change to per-process AST.
 1.1.4.2 20-Jun-2002  nathanw Catch up to -current.
 1.1.4.1 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.3.8.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.3.8.1 09-May-2002  jdolecek file userret.h was added on branch kqueue on 2002-06-23 17:40:45 +0000
 1.3.6.3 26-Sep-2002  nathanw Change "if (l->l_flag & L_SA_UPCALL)" to "while (l->l_flag & L_SA_UPCALL)"
in userret() functions or equivalent, to permit delivery of multiple upcalls
in a single kernel entry.

XXX It's getting crowded in here. Collapsing posting signals, upcalls, and
XXX kernel-exit handling into one mechanism would be nice.
 1.3.6.2 21-Jun-2002  thorpej Add support for scheduler activations on SuperH. Boots multi-user
on Dreamcast (SH4) with stock userland.
 1.3.6.1 09-May-2002  thorpej file userret.h was added on branch nathanw_sa on 2002-06-21 21:26:28 +0000
 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 15-Nov-2007  yamt sync with head.
 1.8.6.1 22-Apr-2006  simonb Sync with head.
 1.8.4.1 09-Sep-2006  rpaulo sync with head
 1.8.2.1 18-Feb-2006  yamt sync with head.
 1.9.48.1 13-Nov-2007  bouyer Sync with HEAD
 1.9.44.1 06-Nov-2007  matt sync with HEAD
 1.9.42.1 06-Nov-2007  joerg Sync with HEAD.
 1.9.24.1 03-Dec-2007  ad Sync with HEAD.
 1.10.50.2 17-Feb-2011  bouyer Sync with HEAD
 1.10.50.1 08-Feb-2011  bouyer Sync with HEAD
 1.10.48.1 06-Jun-2011  jruoho Sync with HEAD.
 1.10.42.1 05-Mar-2011  rmind sync with head
 1.12.4.1 30-Oct-2012  yamt sync with head
 1.13.20.1 04-Nov-2016  pgoyette Sync with HEAD
 1.13.16.1 05-Dec-2016  skrll Sync with HEAD
 1.13.2.1 03-Dec-2017  jdolecek update from HEAD
 1.14.16.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.7 21-May-2006  uwe Nuke va-sh.h. stdarg.h and varargs.h now use __builtin_va_*.
 1.6 31-Jan-2006  dsl branches: 1.6.2; 1.6.4; 1.6.6; 1.6.10; 1.6.12;
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.5 28-Apr-2002  uch branches: 1.5.6; 1.5.28; 1.5.40;
Use "#define<tab>", white space nits.
 1.4 02-Aug-2000  msaitoh branches: 1.4.4;
check _BYTE_ORDER instead of BYTE_ORDER
 1.3 24-Feb-2000  msaitoh branches: 1.3.4;
include <machine/endian.h>
 1.2 16-Sep-1999  msaitoh branches: 1.2.2;
add NetBSD RCS ID
 1.1 13-Sep-1999  itojun Merge in NetBSD/sh3 from cvs.kame.net repository.

Tree structure:
- sys/arch/sh3: sh3 generic code
As commented, in-chip device drivers are put into sys/arch/sh3/dev.
- sys/arch/evbsh3: sh3 evaluation boards (pure sh3 CPU, no fancy external HW)
- sys/arch/mmeye: Brains mmEye, www.brains.co.jp
MI source code includes couple of #ifdef for sh3-coff support.
(sh3 uses coff or elf)

Needs some more improvements, especialy in sys/arch/sh3/conf/files.sh3,
to compile the tree (due to last minute tree structure change).
 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.4.1 08-Aug-2000  msaitoh Pullup revision 1.4 (approved by thorpej):

check _BYTE_ORDER instead of BYTE_ORDER to fix namespace pollution
(and it's necessary to compile src/usr.bin/xlint/llib)
 1.4.4.1 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.5.40.1 01-Feb-2006  yamt sync with head.
 1.5.28.1 21-Jun-2006  yamt sync with head.
 1.5.6.2 28-Apr-2002  uch Use "#define<tab>", white space nits.
 1.5.6.1 28-Apr-2002  uch file va-sh.h was added on branch nathanw_sa on 2002-04-28 17:10:38 +0000
 1.6.12.1 19-Jun-2006  chap Sync with head.
 1.6.10.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.6.6.1 24-May-2006  yamt sync with head.
 1.6.4.1 01-Jun-2006  kardel Sync with head.
 1.6.2.1 09-Sep-2006  rpaulo sync with head
 1.8 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.7 21-May-2006  uwe New stdarg.h and varargs.h based on arm and i386 versions.

Use __builtin_va_* instead of hand written code in va-sh.h that uses
LHS casts. Slightly worse code is generated by gcc 3.3.3, but LHS
casts are outlawed in gcc 3.3.6 and gcc 4.

Build-tested on hpcsh (le) and mmeye (be), run-tested on hpcsh.
 1.6 28-Apr-2002  uch branches: 1.6.6; 1.6.28; 1.6.42; 1.6.44; 1.6.46; 1.6.50; 1.6.52;
Use "#define<tab>", white space nits.
 1.5 17-Mar-2002  uch cosmetic changes, fix comments.
 1.4 04-Feb-2002  thorpej * Make this lint'able.
* Reduce some code duplication.
 1.3 03-Feb-2000  kleink branches: 1.3.8;
Add a C99-style va_copy macro.
 1.2 16-Sep-1999  msaitoh branches: 1.2.2;
add NetBSD RCS ID
 1.1 13-Sep-1999  itojun Merge in NetBSD/sh3 from cvs.kame.net repository.

Tree structure:
- sys/arch/sh3: sh3 generic code
As commented, in-chip device drivers are put into sys/arch/sh3/dev.
- sys/arch/evbsh3: sh3 evaluation boards (pure sh3 CPU, no fancy external HW)
- sys/arch/mmeye: Brains mmEye, www.brains.co.jp
MI source code includes couple of #ifdef for sh3-coff support.
(sh3 uses coff or elf)

Needs some more improvements, especialy in sys/arch/sh3/conf/files.sh3,
to compile the tree (due to last minute tree structure change).
 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.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.3.8.1 11-Feb-2002  jdolecek Sync w/ -current.
 1.6.52.1 19-Jun-2006  chap Sync with head.
 1.6.50.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.6.46.1 24-May-2006  yamt sync with head.
 1.6.44.1 01-Jun-2006  kardel Sync with head.
 1.6.42.1 09-Sep-2006  rpaulo sync with head
 1.6.28.1 21-Jun-2006  yamt sync with head.
 1.6.6.2 28-Apr-2002  uch Use "#define<tab>", white space nits.
 1.6.6.1 28-Apr-2002  uch file varargs.h was added on branch nathanw_sa on 2002-04-28 17:10:38 +0000
 1.22 03-Sep-2016  christos Fix pmap_prefer for topdown and turn topdown on.
 1.21 14-Nov-2010  uebayasi branches: 1.21.18; 1.21.36;
Move struct vm_page_md definition from vmparam.h to pmap.h, because
it's used only by pmap. vmparam.h has definitions for wider
audience.

All GENERIC kernels build tested, except ia64.

powerpc/include/booke/vmparam.h has one too, but it has no pmap.h,
so it's left as is.
 1.20 06-Nov-2010  uebayasi Remove incomplete, never worked dynamic run-time memory registration
(uvm_page_physload(9)). This functionality will be re-added later.
 1.19 06-Mar-2009  joerg branches: 1.19.2; 1.19.4;
Remove SHMMAXPGS from all kernel configs. Dynamically compute the
initial limit as 1/4 of the physical memory. Ensure the limit is at
least 1024 pages, the old default on most platforms.
 1.18 28-Apr-2008  martin branches: 1.18.8; 1.18.14;
Remove clause 3 and 4 from TNF licenses
 1.17 04-Mar-2006  uwe branches: 1.17.68; 1.17.70; 1.17.72;
s/u_intN_t/uintN_t/
 1.16 02-Apr-2003  thorpej branches: 1.16.18; 1.16.32; 1.16.34;
Use PAGE_SIZE rather than NBPG.
 1.15 02-Apr-2003  thorpej We use 4K pages on the sh3/sh4; make PAGE_SIZE, PAGE_SHIFT, and PAGE_MASK
compile-time constants.
 1.14 10-Dec-2002  thorpej Use __LDPGSZ (which must be == USRTEXT) as the text address for a.out
executables, and eliminate the USRTEXT constant, which was only used
by the a.out exec code.
 1.13 09-May-2002  uch branches: 1.13.6;
new pmap designed for SH3/SH4.
 1.12 28-Apr-2002  uch Use "#define<tab>", white space nits.
 1.11 17-Mar-2002  uch cosmetic changes, fix comments.
 1.10 15-Nov-2001  soren MAXSLP is defined to be a machine-independent scheduling parameter,
so move it into sys/param.h.
 1.9 01-May-2001  thorpej branches: 1.9.2;
Per discussion w/ chuck and chuck, restructure the md page stuff
to use a structure called "vm_page_md", and use __HAVE_VM_PAGE_MD
and __HAVE_PMAP_PHYSSEG.
 1.8 29-Apr-2001  thorpej Add a VM_MDPAGE_MEMBERS macro that defines pmap-specific data for
each vm_page structure. Add a VM_MDPAGE_INIT() macro to init this
data when pages are initialized by UVM. These macros are mandatory,
but ports may #define them to nothing if they are not needed/used.

This deprecates struct pmap_physseg. As a transitional measure,
allow a port to #define PMAP_PHYSSEG so that it can continue to
use it until its pmap is converted to use VM_MDPAGE_MEMBERS.

Use all this stuff to eliminate a lot of extra work in the Alpha
pmap module (it's smaller and faster now). Changes to other pmap
modules will follow.
 1.7 07-Feb-2001  uch branches: 1.7.2;
move VM_PHYSSEG_MAX, VM_NFREELIST, VM_FREELIST_DEFAULT defines to
machine/vmparam.h
 1.6 25-Apr-2000  tsubai GC VM_MBUF_SIZE.
 1.5 11-Feb-2000  thorpej Update for the NKMEMPAGES changes.
 1.4 26-Jan-2000  tsutsui Remove obsoleted macros.
 1.3 04-Dec-1999  ragge CL* discarding.
 1.2 14-Sep-1999  tsubai branches: 1.2.2; 1.2.8;
Catch up with -current.
 1.1 13-Sep-1999  itojun Merge in NetBSD/sh3 from cvs.kame.net repository.

Tree structure:
- sys/arch/sh3: sh3 generic code
As commented, in-chip device drivers are put into sys/arch/sh3/dev.
- sys/arch/evbsh3: sh3 evaluation boards (pure sh3 CPU, no fancy external HW)
- sys/arch/mmeye: Brains mmEye, www.brains.co.jp
MI source code includes couple of #ifdef for sh3-coff support.
(sh3 uses coff or elf)

Needs some more improvements, especialy in sys/arch/sh3/conf/files.sh3,
to compile the tree (due to last minute tree structure change).
 1.2.8.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.2.2.2 11-Feb-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.7.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.9.2.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.9.2.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.13.6.2 11-Dec-2002  thorpej Sync with HEAD.
 1.13.6.1 09-May-2002  thorpej file vmparam.h was added on branch nathanw_sa on 2002-12-11 06:11:54 +0000
 1.16.34.1 22-Apr-2006  simonb Sync with head.
 1.16.32.1 09-Sep-2006  rpaulo sync with head
 1.16.18.1 21-Jun-2006  yamt sync with head.
 1.17.72.2 04-May-2009  yamt sync with head.
 1.17.72.1 16-May-2008  yamt sync with head.
 1.17.70.1 18-May-2008  yamt sync with head.
 1.17.68.1 02-Jun-2008  mjf Sync with HEAD.
 1.18.14.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.18.8.1 28-Apr-2009  skrll Sync with HEAD.
 1.19.4.1 05-Mar-2011  rmind sync with head
 1.19.2.4 16-Nov-2010  uebayasi Sync with HEAD.
 1.19.2.3 26-Apr-2010  uebayasi Remove the unfinished code to add a memory segment after uvm_page_init().
It doesn't even compile.

(In the future, we should allocate struct vm_page [] on the added memory
segment for NUMA's sake.)
 1.19.2.2 25-Feb-2010  uebayasi Make this reall build.
 1.19.2.1 23-Feb-2010  uebayasi Convert all VM_MDPAGE_INIT()'s to take struct vm_page_md * and paddr_t.
 1.21.36.1 05-Oct-2016  skrll Sync with HEAD
 1.21.18.1 03-Dec-2017  jdolecek update from HEAD
 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:40:16 +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 07-Sep-2015  dholland Final bit of PR 41200: headers that declare ioctls should include sys/ioccom.h.
This covers most if not all of the MD headers.

XXX: a lot of the ioctl definitions in some of these files are cutpasted.
 1.6 28-Apr-2002  uch branches: 1.6.6; 1.6.162; 1.6.182;
Use "#define<tab>", white space nits.
 1.5 17-Mar-2002  uch cosmetic changes, fix comments.
 1.4 12-Feb-2002  uch ANSIfy KNF.
 1.3 31-Oct-2000  msaitoh branches: 1.3.2; 1.3.6;
add interrupt mode into wdog

To use:

ioctl(fd, SIOWDOGSETMODE, &val)

val: WDOGM_RESET -> reset when counter expired
WDOGM_INTR -> print PC when counter expired (new!)

This interface is still under experimental.
 1.2 24-Feb-2000  msaitoh add RCSID and copyright
 1.1 24-Feb-2000  msaitoh watchdog timer
 1.3.6.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.3.6.1 16-Mar-2002  jdolecek Catch up with -current.
 1.3.2.3 22-Nov-2000  bouyer Sync with HEAD.
 1.3.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.3.2.1 31-Oct-2000  bouyer file wdogvar.h was added on branch thorpej_scsipi on 2000-11-20 20:24:31 +0000
 1.6.182.1 22-Sep-2015  skrll Sync with HEAD
 1.6.162.1 03-Dec-2017  jdolecek update from HEAD
 1.6.6.2 28-Apr-2002  uch Use "#define<tab>", white space nits.
 1.6.6.1 28-Apr-2002  uch file wdogvar.h was added on branch nathanw_sa on 2002-04-28 17:10:38 +0000
 1.6 11-Dec-2005  christos merge ktrace-lwp.
 1.5 03-Jul-2005  uwe Make this file suitable for use in asm sources.
 1.4 28-Apr-2002  uch branches: 1.4.6; 1.4.12;
Use "#define<tab>", white space nits.
 1.3 17-Jan-2000  msaitoh branches: 1.3.8;
add some bit definitions
 1.2 16-Sep-1999  msaitoh branches: 1.2.2;
remove extra Id
 1.1 13-Sep-1999  itojun Merge in NetBSD/sh3 from cvs.kame.net repository.

Tree structure:
- sys/arch/sh3: sh3 generic code
As commented, in-chip device drivers are put into sys/arch/sh3/dev.
- sys/arch/evbsh3: sh3 evaluation boards (pure sh3 CPU, no fancy external HW)
- sys/arch/mmeye: Brains mmEye, www.brains.co.jp
MI source code includes couple of #ifdef for sh3-coff support.
(sh3 uses coff or elf)

Needs some more improvements, especialy in sys/arch/sh3/conf/files.sh3,
to compile the tree (due to last minute tree structure change).
 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 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.4.12.1 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.4.6.2 28-Apr-2002  uch Use "#define<tab>", white space nits.
 1.4.6.1 28-Apr-2002  uch file wdtreg.h was added on branch nathanw_sa on 2002-04-28 17:10:38 +0000
 1.18 08-May-2003  christos rename Locore.c -> locore_c.c so that we can compile on case insensitive
filesystems. (from John Gordon)
 1.17 02-Apr-2003  thorpej Use PAGE_SIZE rather than NBPG.
 1.16 20-Mar-2003  tsutsui Rewrite user space access functions which use gcc's "labels as values"
extension in asm to avoid unexpected code omission during optimization
which causes wrong return value on faults.
 1.15 18-Jan-2003  thorpej Merge the nathanw_sa branch.
 1.14 16-Dec-2002  thorpej Add support for RAS (initially added by me on nathanw_sa branch).
 1.13 16-Dec-2002  thorpej Use MI setrunqueue()/remrunqueue().
 1.12 09-May-2002  uch branches: 1.12.6;
new pmap designed for SH3/SH4.
 1.11 29-Apr-2002  uch KNF.
 1.10 28-Apr-2002  uch Use "#define<tab>", white space nits.
 1.9 24-Mar-2002  uch Rework interrupt code.
+ Fully utilize SH SR.I[0:3] interrupt level.
+ software interrupt is emulated by TMU1, 2 one shot interrupt.
+ implement generic soft interrupts.
+ implement clockframe correctly.
 1.8 17-Mar-2002  uch kernel stack fix. old code simply P3 address converted to P1, it
caused memory destruction when kernel stack grow over 1 page. new
code use P3 address for kernel stack. but for the sake of debug, P1
kernel stack mode remain.
 1.7 03-Mar-2002  uch remove temporal debug code.
 1.6 17-Feb-2002  uch ANSIfy. remove #if 0 ... #endif.
 1.5 28-Sep-2001  chs don't depend on other headers to include sys/proc.h for us.
 1.4 29-Jun-2000  mrg branches: 1.4.2; 1.4.4;
remove include of <vm/vm.h>. <vm/vm.h> -> <uvm/uvm_extern.h>
 1.3 26-May-2000  thorpej 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.2 08-Dec-1999  msaitoh fix copyinstr(9) bug (from Charles M. Hannum).
 1.1 13-Sep-1999  itojun branches: 1.1.2; 1.1.8;
Merge in NetBSD/sh3 from cvs.kame.net repository.

Tree structure:
- sys/arch/sh3: sh3 generic code
As commented, in-chip device drivers are put into sys/arch/sh3/dev.
- sys/arch/evbsh3: sh3 evaluation boards (pure sh3 CPU, no fancy external HW)
- sys/arch/mmeye: Brains mmEye, www.brains.co.jp
MI source code includes couple of #ifdef for sh3-coff support.
(sh3 uses coff or elf)

Needs some more improvements, especialy in sys/arch/sh3/conf/files.sh3,
to compile the tree (due to last minute tree structure change).
 1.1.8.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.1.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.4.4.3 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.4.4.2 16-Mar-2002  jdolecek Catch up with -current.
 1.4.4.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.4.2.1 01-Oct-2001  fvdl Catch up with -current.
 1.12.6.5 16-Dec-2002  thorpej Sync with HEAD.
 1.12.6.4 07-Oct-2002  thorpej Add support for restartable atomic sequences.
 1.12.6.3 24-Jun-2002  nathanw Curproc->curlwp renaming.

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

"curproc" is now #defined in proc.h as ((curlwp) ? (curlwp)->l_proc) : NULL)
so that it is always safe to reference curproc (*de*referencing curproc
is another story, but that's always been true).
 1.12.6.2 21-Jun-2002  thorpej Add support for scheduler activations on SuperH. Boots multi-user
on Dreamcast (SH4) with stock userland.
 1.12.6.1 09-May-2002  thorpej file Locore.c was added on branch nathanw_sa on 2002-06-21 21:26:30 +0000
 1.8 06-Feb-2001  uch move machine-port specific file to machine directory.
for evbsh3, mmeye and dreamcast, use MI md_root.c
 1.7 01-Jun-2000  matt Fix a missing cases of devpp -> booted_device, partp -> booted_parition
 1.6 01-Jun-2000  matt Don't pass booted_* to findroot/getdevice, access them via the globals.
Also, make findroot static. This eliminates unneeded clearing of them
and make their use consistent among the ports.
 1.5 01-Jun-2000  matt Make booted_device global (and booted_parition for consitency).
Eliminate it from header files and other extern definitions.
 1.4 17-Sep-1999  thorpej branches: 1.4.2; 1.4.10;
Centralize the declaration and clearing of `cold'.
 1.3 15-Sep-1999  thorpej Rename the machine-dependent autoconfiguration entry point `cpu_configure()',
and rename config_init() to configure() and call cpu_configure() from there.
 1.2 14-Sep-1999  tsubai Catch up with -current.
 1.1 13-Sep-1999  itojun Merge in NetBSD/sh3 from cvs.kame.net repository.

Tree structure:
- sys/arch/sh3: sh3 generic code
As commented, in-chip device drivers are put into sys/arch/sh3/dev.
- sys/arch/evbsh3: sh3 evaluation boards (pure sh3 CPU, no fancy external HW)
- sys/arch/mmeye: Brains mmEye, www.brains.co.jp
MI source code includes couple of #ifdef for sh3-coff support.
(sh3 uses coff or elf)

Needs some more improvements, especialy in sys/arch/sh3/conf/files.sh3,
to compile the tree (due to last minute tree structure change).
 1.4.10.1 22-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.4.2.2 11-Feb-2001  bouyer Sync with HEAD.
 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.19 18-Nov-2013  skrll Really remove unused variable.
 1.18 14-Nov-2013  skrll Removed unused variable
 1.17 07-Nov-2013  christos fix unused variables
 1.16 18-Mar-2009  cegger branches: 1.16.12; 1.16.22; 1.16.26;
Ansify function definitions w/o arguments. Generated with sed.
 1.15 28-Apr-2008  martin branches: 1.15.8; 1.15.14;
Remove clause 3 and 4 from TNF licenses
 1.14 15-Mar-2008  uwe branches: 1.14.2; 1.14.4;
defflag cache related options.
 1.13 06-Nov-2007  uwe branches: 1.13.10; 1.13.14;
Convert to aprint_*
 1.12 24-Sep-2006  tsutsui branches: 1.12.8; 1.12.26; 1.12.28; 1.12.32; 1.12.34;
Allow shared PV mappings in pmap_enter(9) even on SH4 if VAs of shared pages
have the same virtual cache indexes (i.e. they won't cause virtual cache
aliases). Also prepare PMAP_PREFER(9) for SH4 to avoid some possible virtual
cache aliases.
More stuff should be added in pmap_enter(9), but at least this changes
should fix some existing problems. See discussion on port-sh3 ML for details.

OK'ed by uwe and chs, and closes PR port-sh3/34243.
 1.11 02-Jan-2006  uwe branches: 1.11.18; 1.11.20;
KNF: space after the keyword, blank line between function declarations
and variable definitions.
 1.10 02-Jan-2006  uwe Prepend "cpu0: " to autoconfiguration messages.
While here move separator space to the beginning of optional messages.
Tweak write-through/back message so that is parses as expected.

PR: port-sh3/31315
 1.9 24-Dec-2005  perry branches: 1.9.2;
__asm__ -> __asm
__const__ -> const
__inline__ -> inline
__volatile__ -> volatile
 1.8 11-Dec-2005  christos merge ktrace-lwp.
 1.7 15-Jul-2003  lukem branches: 1.7.16;
__KERNEL_RCSID()
 1.6 09-May-2002  uch branches: 1.6.6; 1.6.12;
IOM_RAM_BEGIN is changed to specify physical address.
 1.5 28-Apr-2002  uch Use "#define<tab>", white space nits.
 1.4 22-Apr-2002  uch make these compile with gcc -O0
 1.3 10-Mar-2002  uch branches: 1.3.2;
use IOM_RAM_BEGIN macro instead of ram_start.
 1.2 17-Feb-2002  uch branches: 1.2.2;
sh_cpu_init() is added. its initialize cache, MMU ops appropriately.
machine locore code call this at first.
 1.1 11-Feb-2002  uch add new cache routine.
 1.2.2.3 20-Jun-2002  nathanw Catch up to -current.
 1.2.2.2 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.2.2.1 28-Feb-2002  nathanw Catch up to -current.
 1.3.2.3 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.3.2.2 16-Mar-2002  jdolecek Catch up with -current.
 1.3.2.1 10-Mar-2002  jdolecek file cache.c was added on branch kqueue on 2002-03-16 15:59:40 +0000
 1.6.12.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.6.12.2 18-Sep-2004  skrll Sync with HEAD.
 1.6.12.1 03-Aug-2004  skrll Sync with HEAD
 1.6.6.2 09-May-2002  uch IOM_RAM_BEGIN is changed to specify physical address.
 1.6.6.1 09-May-2002  uch file cache.c was added on branch nathanw_sa on 2002-05-09 12:32:10 +0000
 1.7.16.4 17-Mar-2008  yamt sync with head.
 1.7.16.3 15-Nov-2007  yamt sync with head.
 1.7.16.2 30-Dec-2006  yamt sync with head.
 1.7.16.1 21-Jun-2006  yamt sync with head.
 1.9.2.1 15-Jan-2006  yamt sync with head.
 1.11.20.1 22-Oct-2006  yamt sync with head
 1.11.18.1 18-Nov-2006  ad Sync with head.
 1.12.34.1 19-Nov-2007  mjf Sync with HEAD.
 1.12.32.1 13-Nov-2007  bouyer Sync with HEAD
 1.12.28.2 23-Mar-2008  matt sync with HEAD
 1.12.28.1 06-Nov-2007  matt sync with HEAD
 1.12.26.1 06-Nov-2007  joerg Sync with HEAD.
 1.12.8.1 03-Dec-2007  ad Sync with HEAD.
 1.13.14.2 02-Jun-2008  mjf Sync with HEAD.
 1.13.14.1 03-Apr-2008  mjf Sync with HEAD.
 1.13.10.1 24-Mar-2008  keiichi sync with head.
 1.14.4.2 04-May-2009  yamt sync with head.
 1.14.4.1 16-May-2008  yamt sync with head.
 1.14.2.1 18-May-2008  yamt sync with head.
 1.15.14.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.15.8.1 28-Apr-2009  skrll Sync with HEAD.
 1.16.26.1 18-May-2014  rmind sync with head
 1.16.22.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.16.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.16 12-Feb-2012  matt Change old-style function defintions to C89 prototypes.

Approved by releng.
 1.15 30-Apr-2009  nonaka branches: 1.15.12; 1.15.16;
Support SH7706
 1.14 28-Apr-2008  martin branches: 1.14.14;
Remove clause 3 and 4 from TNF licenses
 1.13 15-Mar-2008  uwe branches: 1.13.2; 1.13.4;
defflag cache related options.
 1.12 04-Mar-2006  uwe branches: 1.12.44; 1.12.64; 1.12.68;
s/u_intN_t/uintN_t/
 1.11 24-Dec-2005  perry branches: 1.11.4; 1.11.6;
__asm__ -> __asm
__const__ -> const
__inline__ -> inline
__volatile__ -> volatile
 1.10 11-Dec-2005  christos merge ktrace-lwp.
 1.9 15-Jul-2003  lukem branches: 1.9.16;
__KERNEL_RCSID()
 1.8 25-Jan-2003  tsutsui branches: 1.8.2;
Make sure cache_sh[34]_op_*() functions actually inlined.
 1.7 08-Nov-2002  tsutsui Add _reg_bset_[124]() and _reg_bclr_[124]() macro for
SH embeded device registers.
 1.6 10-May-2002  uch branches: 1.6.6;
cosmetic changes.
 1.5 28-Apr-2002  uch Use "#define<tab>", white space nits.
 1.4 24-Mar-2002  uch Rework interrupt code.
+ Fully utilize SH SR.I[0:3] interrupt level.
+ software interrupt is emulated by TMU1, 2 one shot interrupt.
+ implement generic soft interrupts.
+ implement clockframe correctly.
 1.3 03-Mar-2002  uch branches: 1.3.4;
SR related parts moved to psl.h. cpufunc.h segments.h are removed.
kernel mode checking is only SR.MD. no check stack pointer.
 1.2 17-Feb-2002  uch branches: 1.2.2;
change register naming.
 1.1 11-Feb-2002  uch add new cache routine.
 1.2.2.3 20-Jun-2002  nathanw Catch up to -current.
 1.2.2.2 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.2.2.1 28-Feb-2002  nathanw Catch up to -current.
 1.3.4.3 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.3.4.2 16-Mar-2002  jdolecek Catch up with -current.
 1.3.4.1 03-Mar-2002  jdolecek file cache_sh3.c was added on branch kqueue on 2002-03-16 15:59:40 +0000
 1.6.6.2 11-Nov-2002  nathanw Catch up to -current
 1.6.6.1 10-May-2002  nathanw file cache_sh3.c was added on branch nathanw_sa on 2002-11-11 22:04:03 +0000
 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.9.16.2 17-Mar-2008  yamt sync with head.
 1.9.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.12.68.2 02-Jun-2008  mjf Sync with HEAD.
 1.12.68.1 03-Apr-2008  mjf Sync with HEAD.
 1.12.64.1 24-Mar-2008  keiichi sync with head.
 1.12.44.1 23-Mar-2008  matt sync with HEAD
 1.13.4.2 04-May-2009  yamt sync with head.
 1.13.4.1 16-May-2008  yamt sync with head.
 1.13.2.1 18-May-2008  yamt sync with head.
 1.14.14.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.15.16.1 18-Feb-2012  mrg merge to -current.
 1.15.12.1 17-Apr-2012  yamt sync with head
 1.25 25-Jul-2020  uwe Start teaching sh3 code about STX7105.

Kernel option STX7105 to select CPU product (TODO: all of the options
that select CPU product should be defflag'ed to opt_cputype.h).

The ST40 cache sizes can be customized for each product. For now just
hardcode the STx7105 values in the switch, but may be they should be
kernel options.
 1.24 14-May-2013  tsutsui Don't call sh4_icache_sync_all() before sh_cache_ops is initialized.
Instead, use SH4_EMODE_CACHE_FLUSH() or SH4_CACHE_FLUSH() macro to
invalidate cache before initializing CCR.
This seems to suppress random file system corruption on wd(4) at acardide(4)
(which uses bus-master DMA and calls many cache flush ops) during pkgsrc
packages builds on landisk.
 1.23 12-Dec-2012  tsutsui Sprinkle redundant comments about PAD_P1_SWITCH to avoid stupid confusion.
 1.22 12-Dec-2012  tsutsui Revert part of the previous (reverting RUN_P1 -> PAD_P1_SWITCH again).
We can assume all icache ops are called from (and will return to) P1
so no need to bother to jump to P1 at end of functions.
Pointed out by uwe@.
 1.21 12-Dec-2012  tsutsui Fix fallouts in rev 1.19:
http://www.nerv.org/~ryo/netbsd/netbsd/?q=id:20080316T191753Z.1654448ada03ce3c4668f3fe472796d0b771e147
- revert RUN_P1 -> PAD_P1_SWITCH changes where RUN_P1 is
actually required (all icache CCIA ops still need RUN_P2)
- sh4_dcache_wbinv_all() and sh4_dcache_wbinv_range_index()
(which manipulate CCDA arrays) are no longer have RUN_P2 so
we can't call them directly from sh4_icache_sync_all() and
sh4_icache_sync_range_index() funcitons; use function pointers
(which have appropriate addresses) instead for 7750 and 7750S
 1.20 28-Apr-2008  martin branches: 1.20.34; 1.20.44;
Remove clause 3 and 4 from TNF licenses
 1.19 16-Mar-2008  uwe branches: 1.19.2; 1.19.4;
Only SH7750 and SH7750S require updates to memory-mapped data cache
arrays to be performed while running on P2. Don't penalize other cpus
that can do it from P1.
 1.18 15-Mar-2008  uwe defflag cache related options.
 1.17 29-Mar-2007  uwe branches: 1.17.14; 1.17.30; 1.17.34;
Mark inline functions we call while running on P2 with
__attribute__((always_inline)) or gcc might decide not to inline them,
resulting in P2->P1 call while we mess with the cache, and kernel
would just hang immediately on boot.
 1.16 24-Sep-2006  tsutsui branches: 1.16.2; 1.16.4; 1.16.8; 1.16.10; 1.16.12;
Allow shared PV mappings in pmap_enter(9) even on SH4 if VAs of shared pages
have the same virtual cache indexes (i.e. they won't cause virtual cache
aliases). Also prepare PMAP_PREFER(9) for SH4 to avoid some possible virtual
cache aliases.
More stuff should be added in pmap_enter(9), but at least this changes
should fix some existing problems. See discussion on port-sh3 ML for details.

OK'ed by uwe and chs, and closes PR port-sh3/34243.
 1.15 24-Dec-2005  perry branches: 1.15.20; 1.15.22;
__asm__ -> __asm
__const__ -> const
__inline__ -> inline
__volatile__ -> volatile
 1.14 11-Dec-2005  christos merge ktrace-lwp.
 1.13 22-Oct-2005  nonaka fix EMODE instruction cache range index op.
 1.12 07-Jul-2005  nonaka branches: 1.12.2;
Added EMODE cache operation.
 1.11 30-Jun-2005  nonaka branches: 1.11.2;
remove EMODE support code.
- EMODE support doesn't work fine yet.
- This code is broken for dreamcast.
dramcast call sh4_icache_sync_all() before sh4_cache_config().
(at locore.S)
 1.10 29-Jun-2005  christos additions from nonaka's landisk port.
 1.9 15-Jul-2003  lukem __KERNEL_RCSID()
 1.8 25-Jan-2003  tsutsui branches: 1.8.2;
Make sure cache_sh[34]_op_*() functions actually inlined.
 1.7 08-Nov-2002  tsutsui Add _reg_bset_[124]() and _reg_bclr_[124]() macro for
SH embeded device registers.
 1.6 09-May-2002  uch branches: 1.6.6;
fix comment
 1.5 28-Apr-2002  uch Use "#define<tab>", white space nits.
 1.4 17-Mar-2002  uch write-through mode for now. since SH4 kernel access page table via P2. XXX
 1.3 03-Mar-2002  uch branches: 1.3.4;
SR related parts moved to psl.h. cpufunc.h segments.h are removed.
kernel mode checking is only SR.MD. no check stack pointer.
 1.2 17-Feb-2002  uch branches: 1.2.2;
change register naming.
 1.1 11-Feb-2002  uch add new cache routine.
 1.2.2.3 20-Jun-2002  nathanw Catch up to -current.
 1.2.2.2 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.2.2.1 28-Feb-2002  nathanw Catch up to -current.
 1.3.4.3 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.3.4.2 16-Mar-2002  jdolecek Catch up with -current.
 1.3.4.1 03-Mar-2002  jdolecek file cache_sh4.c was added on branch kqueue on 2002-03-16 15:59:40 +0000
 1.6.6.2 11-Nov-2002  nathanw Catch up to -current
 1.6.6.1 09-May-2002  nathanw file cache_sh4.c was added on branch nathanw_sa on 2002-11-11 22:04:03 +0000
 1.8.2.4 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 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.11.2.4 17-Mar-2008  yamt sync with head.
 1.11.2.3 03-Sep-2007  yamt sync with head.
 1.11.2.2 30-Dec-2006  yamt sync with head.
 1.11.2.1 21-Jun-2006  yamt sync with head.
 1.12.2.1 26-Oct-2005  yamt sync with head
 1.15.22.1 22-Oct-2006  yamt sync with head
 1.15.20.1 18-Nov-2006  ad Sync with head.
 1.16.12.1 29-Mar-2007  reinoud Pullup to -current
 1.16.10.1 11-Jul-2007  mjf Sync with head.
 1.16.8.1 10-Apr-2007  ad Sync with head.
 1.16.4.1 15-Apr-2007  yamt sync with head.
 1.16.2.1 20-Apr-2007  bouyer Pull up following revision(s) (requested by uwe in ticket #586):
sys/arch/sh3/sh3/cache_sh4.c: revision 1.17
sys/arch/sh3/sh3/mmu_sh4.c: revision 1.12
Mark inline functions we call while running on P2 with
__attribute__((always_inline)) or gcc might decide not to inline them,
resulting in P2->P1 call while we mess with the cache, and kernel
would just hang immediately on boot.
Makes sh4 kernel compiled with -Os actually work.
 1.17.34.2 02-Jun-2008  mjf Sync with HEAD.
 1.17.34.1 03-Apr-2008  mjf Sync with HEAD.
 1.17.30.1 24-Mar-2008  keiichi sync with head.
 1.17.14.1 23-Mar-2008  matt sync with HEAD
 1.19.4.1 16-May-2008  yamt sync with head.
 1.19.2.1 18-May-2008  yamt sync with head.
 1.20.44.2 23-Jun-2013  tls resync from head
 1.20.44.1 25-Feb-2013  tls resync with head
 1.20.34.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.34.1 16-Jan-2013  yamt sync with (a bit old) head
 1.41 03-Aug-2020  uwe _cpu_exception_suspend - return old SR

In a typical use case we do a very short code sequence with PSL_BL set
and restore the old PSL_BL value with _cpu_exception_resume that does
the full read/mask/set dance. In reality we are just restoring SR to
its old state as no other modifications to SR can possibly happen. So
return old SR and let the caller restore it in one instruction.
 1.40 18-Mar-2009  cegger Ansify function definitions w/o arguments. Generated with sed.
 1.39 28-Apr-2008  martin branches: 1.39.8; 1.39.14;
Remove clause 3 and 4 from TNF licenses
 1.38 30-Mar-2007  uwe branches: 1.38.34; 1.38.36; 1.38.38;
In sh_clock_init just make sure that rtc oscillator is running, but
don't start rtc, so that rtc(4) can report wall time as invalid if
clock was not running on attach.
 1.37 19-Oct-2006  uwe branches: 1.37.4; 1.37.8; 1.37.10;
Oops, don't stop rtc when enabling rtc oscillator - we would stall it
until rtc(4) attaches and starts the clock (that caused my Jornada to
lose about 12 secs during boot).
 1.36 11-Oct-2006  uwe Oops, fix bug in previous. On SH4 (two-issue) sh_clock.cpuclock is
the spin count divided by two, so introduce a variable to hold the
original number that we later use to compute pclock.
 1.35 11-Oct-2006  uwe Do calculations to estimate cpu and pclock using 64-bit and doing all
the multiplications first. Round to nearest, instead of down.

When estimating pclock don't compute sh_clock.cpucycle_1us * 1000000
sh_clock.cpuclock is exactly that (but without rounding errors).

This improves timekeeping on my Jornada.
 1.34 24-Sep-2006  tsutsui Add timecounter support for SH3 ports. From gdamore on port-sh3,
with several minor fixes by me.

Previously sh3 ports use two timers (TMU1 and TMU2) as oneshot timer
to cause real hardware interrupts by softintr(9), but now softintr(9)
uses only TMU1 and TMU2 is configured as freerunning counter for
timecounter(9).

Tested on my dreamcast.
 1.33 20-Sep-2006  uwe Switch the rest of sh3 ports to todr(9)
Split code to handle on-chip rtc into a separate driver
Eliminate all todr code from clock.c
Move __HAVE_GENERIC_TODR to sh3/include/types.h
 1.32 05-Sep-2006  uwe branches: 1.32.2; 1.32.4;
Switch dreamcast to MI todr(9).

Dreamcast does not use SuperH on-chip RTC, so do it seprately from
other sh3 ports. Convert dreamcast rtc code into a real device
instead of searching/attaching it manually.

Tested by Nick Hudson.
 1.31 04-Mar-2006  uwe branches: 1.31.2;
s/u_intN_t/uintN_t/
 1.30 11-Dec-2005  christos branches: 1.30.4; 1.30.6;
merge ktrace-lwp.
 1.29 01-Jul-2004  yamt branches: 1.29.12;
defparam HZ.
 1.28 15-Jul-2003  lukem __KERNEL_RCSID()
 1.27 08-Nov-2002  tsutsui branches: 1.27.6;
Add _reg_bset_[124]() and _reg_bclr_[124]() macro for
SH embeded device registers.
 1.26 18-Jul-2002  mjl Correct obviously switched args to memset()
 1.25 28-Apr-2002  uch branches: 1.25.2; 1.25.6;
Use "#define<tab>", white space nits.
 1.24 24-Mar-2002  uch Rework interrupt code.
+ Fully utilize SH SR.I[0:3] interrupt level.
+ software interrupt is emulated by TMU1, 2 one shot interrupt.
+ implement generic soft interrupts.
+ implement clockframe correctly.
 1.23 03-Mar-2002  uch SR related parts moved to psl.h. cpufunc.h segments.h are removed.
kernel mode checking is only SR.MD. no check stack pointer.
 1.22 28-Feb-2002  uch Cleanup register definition
 1.21 22-Feb-2002  uch New NetBSD/sh3 clock framework.
+ hardclock source is moved from TMU1 to TMU0.
+ SH3/SH4 common kernel support.
+ PCLOCK estimation.
+ remove duplicated code.
 1.20 19-Feb-2002  uch Clean up functions
disable_intr, enable_intr, disable_interrupt, enable_interrupt,
disable_ext_intr, enable_ext_intr.
New functions:
for external interrupt:
_cpu_intr_suspend and _cpu_intr_resume.
for exception:
_cpu_exception_suspend and _cpu_exception_resume.
 1.19 12-Feb-2002  uch ANSIfy KNF.
 1.18 01-Feb-2002  uch if PCLOCK isn't setted, use estimated value calculated by kernel.
 1.17 22-Jul-2001  tsubai Make this compile again.
 1.16 24-Jun-2001  msaitoh branches: 1.16.2;
fix microtime()
 1.15 23-Apr-2001  uch dreamcast clock module was separated.
 1.14 07-Mar-2001  itohy Add RTC_OFFSET support to inittodr() on dreamcast.
No changes to other sh ports.
 1.13 22-Jan-2001  tsubai branches: 1.13.2;
#ifdef DREAMCAST --> #ifdef dreamcast.
 1.12 22-Jan-2001  itojun sync indent.
 1.11 21-Jan-2001  marcus Oops. Left a debug printout in there...
 1.10 16-Jan-2001  marcus Dreamcast uses a different realtime clock than the builtin RTC.
 1.9 20-Mar-2000  msaitoh - Use macro
- RTCCNT is not 16000Hz but 16384Hz (not used)
- fix the bug in 16bit int <-> BCD conversion macro (SH4)
 1.8 24-Feb-2000  msaitoh watchdog timer
 1.7 17-Jan-2000  msaitoh - check whether tv_usec == 1000000, too.
- set the reload count of the timer unit 1 correctly
(Timer unit counts from TCOR to 0 (i.e. the length of the counts equals
to TCOR + 1)).
- use macros.
 1.6 15-Jan-2000  msaitoh inittodr() and resettodr() supports SH4
 1.5 14-Jan-2000  msaitoh use clock_subr.c
 1.4 08-Dec-1999  msaitoh calculate microtime() correctly.
 1.3 23-Sep-1999  msaitoh branches: 1.3.2; 1.3.8;
Fix RWKREG register reset code in resettodr().
 1.2 16-Sep-1999  msaitoh sync with tmureg.h
 1.1 13-Sep-1999  itojun Merge in NetBSD/sh3 from cvs.kame.net repository.

Tree structure:
- sys/arch/sh3: sh3 generic code
As commented, in-chip device drivers are put into sys/arch/sh3/dev.
- sys/arch/evbsh3: sh3 evaluation boards (pure sh3 CPU, no fancy external HW)
- sys/arch/mmeye: Brains mmEye, www.brains.co.jp
MI source code includes couple of #ifdef for sh3-coff support.
(sh3 uses coff or elf)

Needs some more improvements, especialy in sys/arch/sh3/conf/files.sh3,
to compile the tree (due to last minute tree structure change).
 1.3.8.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.3.2.4 12-Mar-2001  bouyer Sync with HEAD.
 1.3.2.3 11-Feb-2001  bouyer Sync with HEAD.
 1.3.2.2 18-Jan-2001  bouyer Sync with head (for UBC+NFS fixes, mostly).
 1.3.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.13.2.2 21-Jun-2001  nathanw Catch up to -current.
 1.13.2.1 09-Apr-2001  nathanw Catch up with -current.
 1.16.2.5 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.16.2.4 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.16.2.3 16-Mar-2002  jdolecek Catch up with -current.
 1.16.2.2 11-Feb-2002  jdolecek Sync w/ -current.
 1.16.2.1 03-Aug-2001  lukem update to -current
 1.25.6.3 11-Nov-2002  nathanw Catch up to -current
 1.25.6.2 01-Aug-2002  nathanw Catch up to -current.
 1.25.6.1 28-Apr-2002  nathanw file clock.c was added on branch nathanw_sa on 2002-08-01 02:43:18 +0000
 1.25.2.1 21-Jul-2002  gehenna catch up with -current.
 1.27.6.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.27.6.2 18-Sep-2004  skrll Sync with HEAD.
 1.27.6.1 03-Aug-2004  skrll Sync with HEAD
 1.29.12.3 03-Sep-2007  yamt sync with head.
 1.29.12.2 30-Dec-2006  yamt sync with head.
 1.29.12.1 21-Jun-2006  yamt sync with head.
 1.30.6.1 22-Apr-2006  simonb Sync with head.
 1.30.4.1 09-Sep-2006  rpaulo sync with head
 1.31.2.1 14-Sep-2006  yamt sync with head.
 1.32.4.1 22-Oct-2006  yamt sync with head
 1.32.2.1 18-Nov-2006  ad Sync with head.
 1.37.10.1 11-Jul-2007  mjf Sync with head.
 1.37.8.1 10-Apr-2007  ad Sync with head.
 1.37.4.1 15-Apr-2007  yamt sync with head.
 1.38.38.2 04-May-2009  yamt sync with head.
 1.38.38.1 16-May-2008  yamt sync with head.
 1.38.36.1 18-May-2008  yamt sync with head.
 1.38.34.1 02-Jun-2008  mjf Sync with HEAD.
 1.39.14.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.39.8.1 28-Apr-2009  skrll Sync with HEAD.
 1.36 08-Sep-2024  rillig fix a/an grammar in obvious cases
 1.35 20-Dec-2023  thorpej branches: 1.35.2;
Remove unnecessary <sys/malloc.h>.
 1.34 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.33 29-Jun-2009  dholland branches: 1.33.64;
Convert 67 namei call sites to use namei_simple, in these functions:

check_console, veriexecclose, veriexec_delete, veriexec_file_add,
emul_find_root, coff_load_shlib (sh3 version), coff_load_shlib,
compat_20_sys_statfs, compat_20_netbsd32_statfs,
ELFNAME2(netbsd32,probe_noteless), darwin_sys_statfs,
ibcs2_sys_statfs, ibcs2_sys_statvfs, linux_sys_uselib,
osf1_sys_statfs, sunos_sys_statfs, sunos32_sys_statfs,
ultrix_sys_statfs, do_sys_mount, fss_create_files (3 of 4),
adosfs_mount, cd9660_mount, coda_ioctl, coda_mount, ext2fs_mount,
ffs_mount, filecore_mount, hfs_mount, lfs_mount, msdosfs_mount,
ntfs_mount, sysvbfs_mount, udf_mount, union_mount, sys_chflags,
sys_lchflags, sys_chmod, sys_lchmod, sys_chown, sys_lchown,
sys___posix_chown, sys___posix_lchown, sys_link, do_sys_pstatvfs,
sys_quotactl, sys_revoke, sys_truncate, do_sys_utimes, sys_extattrctl,
sys_extattr_set_file, sys_extattr_set_link, sys_extattr_get_file,
sys_extattr_get_link, sys_extattr_delete_file,
sys_extattr_delete_link, sys_extattr_list_file, sys_extattr_list_link,
sys_setxattr, sys_lsetxattr, sys_getxattr, sys_lgetxattr,
sys_listxattr, sys_llistxattr, sys_removexattr, sys_lremovexattr

All have been scrutinized (several times, in fact) and compile-tested,
but not all have been explicitly tested in action.

XXX: While I haven't (intentionally) changed the use or nonuse of
XXX: TRYEMULROOT in any of these places, I'm not convinced all the
XXX: uses are correct; an audit might be desirable.
 1.32 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.31 19-Nov-2008  ad branches: 1.31.4;
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.30 25-Feb-2008  dholland branches: 1.30.4; 1.30.10; 1.30.12;
This code was not compiling on amd64 (is there any reason, beyond lack
of demand, that it's not MI?) and it shouldn't have been compiling on
sh3 either, because it was passing int * to size_t *. I have fixed
this up.

Compile-tested, and looked at by uebayasi@.
 1.29 08-Dec-2007  pooka branches: 1.29.8; 1.29.12;
Remove cn_lwp from struct componentname. curlwp should be used
from on. The NDINIT() macro no longer takes the lwp parameter and
associates the credentials of the calling thread with the namei
structure.
 1.28 17-Oct-2007  garbled branches: 1.28.4;
Merge the ppcoea-renovation branch to HEAD.

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

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

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.27 23-Jun-2007  dsl branches: 1.27.8; 1.27.10;
Pass TRYEMULROOT to NDINIT() instead of using CHECK_ALT_XXX.
(Code is inside a big #if 0)
 1.26 04-Mar-2007  christos branches: 1.26.2; 1.26.4; 1.26.10;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.25 23-Jul-2006  ad branches: 1.25.10;
Use the LWP cached credentials where sane.
 1.24 14-May-2006  elad integrate kauth.
 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 17-Sep-2004  skrll branches: 1.22.12;
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.21 11-Aug-2003  christos I don't understand why there this is here, since we have exec_ecoff.c in kern,
but remove the stack setup function anyway.
 1.20 15-Jul-2003  lukem __KERNEL_RCSID()
 1.19 29-Jun-2003  fvdl branches: 1.19.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
 1.18 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.17 05-Oct-2002  chs count executable image pages as executable for vm-usage purposes.
also, always do the VTEXT vs. v_writecount mutual exclusion
(which we previously skipped if the text or data segment was empty).
 1.16 27-Sep-2002  provos remove trailing \n in panic(). approved perry.
 1.15 28-Apr-2002  uch branches: 1.15.4; 1.15.6;
Use "#define<tab>", white space nits.
 1.14 16-Mar-2002  christos catch-up with stackgap change.
 1.13 12-Feb-2002  uch ANSIfy KNF.
 1.12 14-Dec-2001  thorpej Use __sh__ instead of __sh3__.
 1.11 30-Oct-2001  thorpej - Add a new vnode flag VEXECMAP, which indicates that a vnode has
executable mappings. Stop overloading VTEXT for this purpose (VTEXT
also has another meaning).
- Rename vn_marktext() to vn_markexec(), and use it when executable
mappings of a vnode are established.
- In places where we want to set VTEXT, set it in v_flag directly, rather
than making a function call to do this (it no longer makes sense to
use a function call, since we no longer overload VTEXT with VEXECMAP's
meaning).

VEXECMAP suggested by Chuq Silvers.
 1.10 22-Jan-2001  tsubai branches: 1.10.4; 1.10.6;
#ifdef sh3 --> #ifdef __sh3__.
 1.9 29-Jun-2000  mrg remove include of <vm/vm.h>. <vm/vm.h> -> <uvm/uvm_extern.h>
 1.8 13-Apr-2000  msaitoh KNF
 1.7 11-Apr-2000  chs add a new function vn_marktext() for exec code to let others know
that the vnode is now being used as process text.
 1.6 02-Jan-2000  msaitoh EXEC_COFF cleanup
 1.5 24-Dec-1999  msaitoh round_page(data_segment_size), too
 1.4 17-Dec-1999  msaitoh round textsize only if the binary is demand-pagable
(for backward compatibility)
 1.3 16-Dec-1999  msaitoh - round_page(ep_tsize). This fixes a bug which cause panic in pmap_enter_pv().
- DPRINTF cleanup.
 1.2 09-Dec-1999  msaitoh demand paging for ZMAGIC SH COFF binary!
 1.1 13-Sep-1999  itojun branches: 1.1.2; 1.1.8;
Merge in NetBSD/sh3 from cvs.kame.net repository.

Tree structure:
- sys/arch/sh3: sh3 generic code
As commented, in-chip device drivers are put into sys/arch/sh3/dev.
- sys/arch/evbsh3: sh3 evaluation boards (pure sh3 CPU, no fancy external HW)
- sys/arch/mmeye: Brains mmEye, www.brains.co.jp
MI source code includes couple of #ifdef for sh3-coff support.
(sh3 uses coff or elf)

Needs some more improvements, especialy in sys/arch/sh3/conf/files.sh3,
to compile the tree (due to last minute tree structure change).
 1.1.8.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.1.2.2 11-Feb-2001  bouyer Sync with HEAD.
 1.1.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.10.6.1 12-Nov-2001  thorpej Sync the thorpej-mips-cache branch with -current.
 1.10.4.4 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.10.4.3 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.10.4.2 16-Mar-2002  jdolecek Catch up with -current.
 1.10.4.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.15.6.2 18-Oct-2002  nathanw Catch up to -current.
 1.15.6.1 28-Apr-2002  nathanw file coff_exec.c was added on branch nathanw_sa on 2002-10-18 02:39:44 +0000
 1.15.4.2 02-Oct-2003  tron Pull up revision 1.17 (requested by junyoung in ticket #1488):
count executable image pages as executable for vm-usage purposes.
also, always do the VTEXT vs. v_writecount mutual exclusion
(which we previously skipped if the text or data segment was empty).
 1.15.4.1 27-Sep-2003  tron Pull up revision 1.16 (requested by junyoung in ticket #1466):
remove trailing \n in panic(). approved perry.
 1.19.2.5 06-Feb-2005  skrll Adapt to branch
 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-Aug-2004  skrll Sync with HEAD
 1.19.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.22.12.5 27-Feb-2008  yamt sync with head.
 1.22.12.4 21-Jan-2008  yamt sync with head
 1.22.12.3 03-Sep-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 08-Mar-2006  elad Adapt to kernel authorization KPI.

I expect *some* lossage here...
 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 01-Jun-2006  kardel Sync with head.
 1.23.4.1 09-Sep-2006  rpaulo sync with head
 1.25.10.1 12-Mar-2007  rmind Sync with HEAD.
 1.26.10.1 26-Jun-2007  garbled Sync with HEAD.
 1.26.4.1 11-Jul-2007  mjf Sync with head.
 1.26.2.1 15-Jul-2007  ad Sync with head.
 1.27.10.3 23-Mar-2008  matt sync with HEAD
 1.27.10.2 09-Jan-2008  matt sync with HEAD
 1.27.10.1 06-Nov-2007  matt sync with HEAD
 1.27.8.1 09-Dec-2007  jmcneill Sync with HEAD.
 1.28.4.1 26-Dec-2007  ad Sync with head.
 1.29.12.2 17-Jan-2009  mjf Sync with HEAD.
 1.29.12.1 03-Apr-2008  mjf Sync with HEAD.
 1.29.8.1 24-Mar-2008  keiichi sync with head.
 1.30.12.2 28-Apr-2009  skrll Sync with HEAD.
 1.30.12.1 19-Jan-2009  skrll Sync with HEAD.
 1.30.10.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.30.4.2 18-Jul-2009  yamt sync with head.
 1.30.4.1 04-May-2009  yamt sync with head.
 1.31.4.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.33.64.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.35.2.1 02-Aug-2025  perseant Sync with HEAD
 1.5 10-May-2002  uch branches: 1.5.4;
remove COMPAT_13 staff. No 1.3 release of sh3 port. these are trace of
i386 port.
 1.4 12-Feb-2002  uch ANSIfy KNF.
 1.3 16-May-2001  msaitoh branches: 1.3.2;
sigreturn() fix (from kleink)
 1.2 22-Dec-2000  jdolecek branches: 1.2.2;
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.1 13-Sep-1999  itojun branches: 1.1.2; 1.1.12;
Merge in NetBSD/sh3 from cvs.kame.net repository.

Tree structure:
- sys/arch/sh3: sh3 generic code
As commented, in-chip device drivers are put into sys/arch/sh3/dev.
- sys/arch/evbsh3: sh3 evaluation boards (pure sh3 CPU, no fancy external HW)
- sys/arch/mmeye: Brains mmEye, www.brains.co.jp
MI source code includes couple of #ifdef for sh3-coff support.
(sh3 uses coff or elf)

Needs some more improvements, especialy in sys/arch/sh3/conf/files.sh3,
to compile the tree (due to last minute tree structure change).
 1.1.12.1 26-May-2001  he Pull up revision 1.3 (requested by kleink):
Validate Status Register passed from userland in sigreturn().
 1.1.2.1 05-Jan-2001  bouyer Sync with HEAD
 1.2.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.3.2.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.3.2.1 16-Mar-2002  jdolecek Catch up with -current.
 1.5.4.2 10-May-2002  uch remove COMPAT_13 staff. No 1.3 release of sh3 port. these are trace of
i386 port.
 1.5.4.1 10-May-2002  uch file compat_13_machdep.c was added on branch nathanw_sa on 2002-05-10 15:25:13 +0000
 1.2 27-Oct-2021  thorpej Use the signal trampoline version constants from <sys/signal.h>.
 1.1 22-Nov-2008  uwe branches: 1.1.4; 1.1.6; 1.1.8; 1.1.12;
Move COMPAT_16 signal stuff to the new compat_16_machdep.c file, so
that it can be built as part of a module.
 1.1.12.2 04-May-2009  yamt sync with head.
 1.1.12.1 22-Nov-2008  yamt file compat_16_machdep.c was added on branch yamt-nfs-mp on 2009-05-04 08:11:52 +0000
 1.1.8.2 19-Jan-2009  skrll Sync with HEAD.
 1.1.8.1 22-Nov-2008  skrll file compat_16_machdep.c was added on branch nick-hppapmap on 2009-01-19 13:16:43 +0000
 1.1.6.2 17-Jan-2009  mjf Sync with HEAD.
 1.1.6.1 22-Nov-2008  mjf file compat_16_machdep.c was added on branch mjf-devfs2 on 2009-01-17 13:28:29 +0000
 1.1.4.2 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.1.4.1 22-Nov-2008  haad file compat_16_machdep.c was added on branch haad-dm on 2008-12-13 01:13:25 +0000
 1.6 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.5 01-Jan-2014  dsl branches: 1.5.30;
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 27-Jan-2011  uwe branches: 1.4.4; 1.4.14; 1.4.18;
Include only headers that are actually used.
 1.3 21-Nov-2009  rmind branches: 1.3.4; 1.3.6; 1.3.8;
Use lwp_getpcb() on mips, powerpc and sh3, 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:52 +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:43 +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:29 +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:25 +0000
 1.3.8.1 08-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.5.30.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.14 05-Apr-2009  uwe Register with pmf(9), tell it we don't need anything.
 1.13 28-Apr-2008  martin branches: 1.13.8; 1.13.14;
Remove clause 3 and 4 from TNF licenses
 1.12 26-Mar-2008  uwe branches: 1.12.2; 1.12.4;
Use device_t. Convert to use CFATTACH_DECL_NEW.
 1.11 03-Dec-2007  ad branches: 1.11.14;
Interrupt handling changes, in discussion since February:

- Reduce available SPL levels for hardware devices to none, vm, sched, high.
- Acquire kernel_lock only for interrupts at IPL_VM.
- Implement threaded soft interrupts.
 1.10 06-Nov-2007  uwe Convert to aprint_*
 1.9 11-Oct-2006  uwe branches: 1.9.8; 1.9.26; 1.9.28; 1.9.32; 1.9.34;
Lift extern cpu_cd declaration to the top-level.
Make match/attach routines static.
Whitespace cosmetics.
 1.8 02-Jan-2006  uwe branches: 1.8.18; 1.8.20;
Add space between cpu speed and "MHz" in the attachment message.
 1.7 11-Dec-2005  christos branches: 1.7.2;
merge ktrace-lwp.
 1.6 15-Jul-2003  lukem branches: 1.6.16;
__KERNEL_RCSID()
 1.5 02-Oct-2002  thorpej branches: 1.5.6;
Add trailing ; to CFATTACH_DECL.
 1.4 01-Oct-2002  thorpej Use CFATTACH_DECL().
 1.3 27-Sep-2002  thorpej Declare all cfattach structures const.
 1.2 28-Apr-2002  uch branches: 1.2.6; 1.2.8;
Use "#define<tab>", white space nits.
 1.1 24-Mar-2002  uch branches: 1.1.2;
add cpu device.
 1.1.2.2 20-Jun-2002  nathanw Catch up to -current.
 1.1.2.1 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.2.8.3 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.2.8.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.2.8.1 28-Apr-2002  jdolecek file cpu.c was added on branch kqueue on 2002-06-23 17:40:49 +0000
 1.2.6.2 18-Oct-2002  nathanw Catch up to -current.
 1.2.6.1 28-Apr-2002  nathanw file cpu.c was added on branch nathanw_sa on 2002-10-18 02:39:44 +0000
 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.6.16.4 07-Dec-2007  yamt sync with head
 1.6.16.3 15-Nov-2007  yamt sync with head.
 1.6.16.2 30-Dec-2006  yamt sync with head.
 1.6.16.1 21-Jun-2006  yamt sync with head.
 1.7.2.1 15-Jan-2006  yamt sync with head.
 1.8.20.1 22-Oct-2006  yamt sync with head
 1.8.18.1 18-Nov-2006  ad Sync with head.
 1.9.34.2 08-Dec-2007  mjf Sync with HEAD.
 1.9.34.1 19-Nov-2007  mjf Sync with HEAD.
 1.9.32.1 13-Nov-2007  bouyer Sync with HEAD
 1.9.28.2 09-Jan-2008  matt sync with HEAD
 1.9.28.1 06-Nov-2007  matt sync with HEAD
 1.9.26.2 09-Dec-2007  jmcneill Sync with HEAD.
 1.9.26.1 06-Nov-2007  joerg Sync with HEAD.
 1.9.8.1 03-Dec-2007  ad Sync with HEAD.
 1.11.14.2 02-Jun-2008  mjf Sync with HEAD.
 1.11.14.1 03-Apr-2008  mjf Sync with HEAD.
 1.12.4.2 04-May-2009  yamt sync with head.
 1.12.4.1 16-May-2008  yamt sync with head.
 1.12.2.1 18-May-2008  yamt sync with head.
 1.13.14.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.13.8.1 28-Apr-2009  skrll Sync with HEAD.
 1.12 07-Feb-2024  msaitoh Remove ryo@'s mail addresses.
 1.11 18-Sep-2021  uwe Fix trailing backslashes in a macro that got misaligned.
 1.10 18-Sep-2021  uwe Fix one comment edit missed in previous.
 1.9 18-Sep-2021  uwe Do not obfuscate r0 as "reg_tmp0".

Using r0 as a temp is a common choice. Some instructions _must_ use
r0 as the destination (like mova or instructions with immediates).
ABI uses r0 as the return register. So a helpful name is not that
helpful for the former use case (temp) and is confusing for the latter
two (ISA or ABI constraints). Same object code is generated.
 1.8 18-Sep-2021  uwe Space after comma in operands. Same object code is generated.
 1.7 18-Sep-2021  rin Support __PIC__ build, in order to avoid text relocations for
/usr/tests/net/in_cksum/in_cksum.

Now, all the tests for in_cksum successfully pass for sh[34].

No binary changes for kernel.
 1.6 18-Sep-2021  rin cksum128mod: Prepare jump address by 'mova', instead of 'mov.l'.

Since both this 'mova' and 'and #imm' above must be used against r0,
we need extra 'mov r0, r3'. However, this should still be good both for
sh3 and sh4:

- For sh3, 'mov.l' at odd half-word address is removed; pipeline hazard
due to instruction fetch is resolved.

- For sh4, data cache line is no longer assigned for this 'mov.l'.

Also:

- Upcoming __PIC__ support (in order to avoid text relocations when built
in tests/net/in_cksum) becomes simpler; no need CALL_DATUM_LOCAL() for
cksum128_tail.

- Shave off 4 bytes from text.

No regression is observed for sh3 (hpcsh) and sh4 (landisk).
 1.5 06-Jan-2015  christos We never want the c definitions in <sys/endian.h>
 1.4 27-Sep-2011  christos branches: 1.4.12; 1.4.30;
move the size marker back to where it was, but fix the name.
 1.3 26-Sep-2011  christos compute the entry size correctly.
 1.2 02-Feb-2008  uwe branches: 1.2.2; 1.2.4; 1.2.12;
Convert in_cksum() to new generalized cpu_in_cksum().
 1.1 02-Feb-2008  uwe Rename in_cksum.S to cpu_in_cksum.S as is to preserve original code in
the new file history.
 1.2.12.2 23-Mar-2008  matt sync with HEAD
 1.2.12.1 02-Feb-2008  matt file cpu_in_cksum.S was added on branch matt-armv6 on 2008-03-23 02:04:21 +0000
 1.2.4.2 18-Feb-2008  mjf Sync with HEAD.
 1.2.4.1 02-Feb-2008  mjf file cpu_in_cksum.S was added on branch mjf-devfs on 2008-02-18 21:05:01 +0000
 1.2.2.2 04-Feb-2008  yamt sync with head.
 1.2.2.1 02-Feb-2008  yamt file cpu_in_cksum.S was added on branch yamt-lazymbuf on 2008-02-04 09:22:30 +0000
 1.4.30.1 06-Apr-2015  skrll Sync with HEAD
 1.4.12.1 03-Dec-2017  jdolecek update from HEAD
 1.23 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.22 20-Mar-2014  christos branches: 1.22.30;
kill sprintf
 1.21 07-Jun-2008  uwe branches: 1.21.32; 1.21.42; 1.21.48;
print trapa operand in hex.
 1.20 21-Feb-2007  thorpej branches: 1.20.42; 1.20.44; 1.20.46; 1.20.48;
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 23-Oct-2006  uwe branches: 1.19.4;
Kill get_ascii and its alternative format, it's not very useful. We'd
better use it for something else later. I'm also thinking of g/c'ing
the temp buffer and emit disassembly with db_printf direcly, and
get_ascii gets in the way.
 1.18 23-Oct-2006  uwe Const-poision. While here, rename the argument s/code/pc/.
 1.17 23-Oct-2006  uwe Be careful when fetching instruction to disassemble. Check for
unalinged address, refuse to disassemble P4 area (on-chip i/o regs),
use fusword/kcopy to fetch the instruction.
 1.16 22-Oct-2006  uwe Instead of referring *code repeatedly, fetch it once into a local variable.
Identical object code for f_* is produced with -O.
 1.15 22-Oct-2006  uwe Whitespace cosmetics in declarations of local variables.
 1.14 22-Oct-2006  uwe Rename get_opcode argument for consistency.
 1.13 21-Jan-2006  uwe branches: 1.13.18; 1.13.20;
Tweak the way we compute displacement for bra/bsr.
Makes lint happy, makes code shorter too.
 1.12 21-Jan-2006  uwe "if (foo) return;" in one line is bad style.
 1.11 21-Jan-2006  uwe Use space in "static\tvoid".
 1.10 21-Jan-2006  uwe Use uint16_t instead of u_short for instructions.
There's no reason for buf argument to be unsigned char.
0x7f is not a printing character.
 1.9 11-Dec-2005  christos branches: 1.9.2;
merge ktrace-lwp.
 1.8 24-Nov-2003  uwe branches: 1.8.16;
In db_disasm call get_ascii only if necessary.
 1.7 15-Jul-2003  lukem __KERNEL_RCSID()
 1.6 10-May-2002  uch branches: 1.6.6; 1.6.12;
clean up disassembler code.
 1.5 12-Feb-2002  uch ANSIfy KNF.
 1.4 04-Sep-2000  tsubai branches: 1.4.4;
Disassembly support in DDB.
 1.3 09-Aug-2000  tv %r, %n -> db_format_radix()
 1.2 25-May-2000  jhawk Interface change: db_printsym() takes a third argument, pr, a function
pointer indicating how to print the symbol. This allows db_printsym()
to called in places where db_printf() is not an appropriate output
function.

While straightforward, apologies in advance if I've introduced any minor
syntax errors; I was unable to test compilation this on all the affected
platforms.
 1.1 13-Sep-1999  itojun branches: 1.1.2;
Merge in NetBSD/sh3 from cvs.kame.net repository.

Tree structure:
- sys/arch/sh3: sh3 generic code
As commented, in-chip device drivers are put into sys/arch/sh3/dev.
- sys/arch/evbsh3: sh3 evaluation boards (pure sh3 CPU, no fancy external HW)
- sys/arch/mmeye: Brains mmEye, www.brains.co.jp
MI source code includes couple of #ifdef for sh3-coff support.
(sh3 uses coff or elf)

Needs some more improvements, especialy in sys/arch/sh3/conf/files.sh3,
to compile the tree (due to last minute tree structure change).
 1.1.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.4.4.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.4.4.1 16-Mar-2002  jdolecek Catch up with -current.
 1.6.12.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.6.12.2 18-Sep-2004  skrll Sync with HEAD.
 1.6.12.1 03-Aug-2004  skrll Sync with HEAD
 1.6.6.2 10-May-2002  uch clean up disassembler code.
 1.6.6.1 10-May-2002  uch file db_disasm.c was added on branch nathanw_sa on 2002-05-10 15:27:06 +0000
 1.8.16.3 26-Feb-2007  yamt sync with head.
 1.8.16.2 30-Dec-2006  yamt sync with head.
 1.8.16.1 21-Jun-2006  yamt sync with head.
 1.9.2.1 01-Feb-2006  yamt sync with head.
 1.13.20.2 10-Dec-2006  yamt sync with head.
 1.13.20.1 22-Oct-2006  yamt sync with head
 1.13.18.1 18-Nov-2006  ad Sync with head.
 1.19.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.20.48.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.20.46.1 04-May-2009  yamt sync with head.
 1.20.44.1 17-Jun-2008  yamt sync with head.
 1.20.42.1 29-Jun-2008  mjf Sync with HEAD.
 1.21.48.1 18-May-2014  rmind sync with head
 1.21.42.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.21.32.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.22.30.1 10-Jun-2019  christos Sync with HEAD
 1.67 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.66 23-Feb-2021  mrg introduce DDB_END_CMD and replace more than 20 copies of the same
list of NULLs and 0. idea from rillig@.

all touched ports built, several booted.
 1.65 03-Aug-2020  uwe branches: 1.65.2;
SH3_P2SEG_FUNC(f) - get a P2 address of a function.


Just SH3_P1SEG_TO_P2SEG + cast, but we now define SH3_P1SEG_TO_P2SEG
and SH3_P2SEG_TO_P1SEG to use arithmetic, not bitwise ops. That gives
the same result for the correct P1/P2 input values, but addition can
be done at link time with addends. Thus SH3_P2SEG_FUNC compiles to a
constant P2 address.
 1.64 03-Aug-2020  uwe db_tlbdump_cmd - get rid of RUN_P2/P1, use functions instead.

Move the bits of code to read TLB entries into separate functions and
call them via P2 pointers instead of doing P2/P1 switch inline.
 1.63 03-Aug-2020  uwe Declare __db_cachedump_sh3/sh4 __noinline too.

Previous commit only did that for the definitions. Forgot to apply
the attribute to the declarations too.
 1.62 03-Aug-2020  uwe db_cachedump_cmd - call the dump function via P2 directly.

Instead of calling RUN_P2 at the very beginning of both cpu-specific
cache dump functions just call them via P2 pointers. This effectively
just makes db_cachedump_cmd into a shared RUN_P2 code for both of
them. Drop RUN_P1 at the end as we are getting back to P1 anyway
because that's where the return address is. Any necessary padding is
provided by the sh_icache_sync_all() call.
 1.61 28-Jan-2011  uwe Implement PT_STEP.
 1.60 26-Jan-2011  uwe BRCR and BAMRA have different format in sh3 and sh4, so there's no
point in using SH_() wrapper to refer to them in code that is already
model-specific.
 1.59 21-Nov-2009  rmind branches: 1.59.4; 1.59.6; 1.59.8;
Use lwp_getpcb() on mips, powerpc and sh3, clean from struct user usage.
 1.58 18-Mar-2009  cegger Ansify function definitions w/o arguments. Generated with sed.
 1.57 08-Jun-2008  uwe branches: 1.57.6; 1.57.12;
Match PC address for single-stepping, program BARA = tf->tf_spc before
returning from exception.

Makes single-stepping work on sh3 - without matching the address sh3
gets stuck at the instruction we are at, getting EXPEVT_BREAK before
executing the instruction.
 1.56 07-Jun-2008  uwe Cosmetics: add blank lines to make db_trap() call more prominent.
s/kdb/ddb/ is a comment (does anyone really still calls it kdb?)
 1.55 07-Jun-2008  uwe We never pass type = -1 to kdb_trap() so g/c that cargo-culted case.
 1.54 07-Jun-2008  uwe Use _SH_TRA_BREAK instead of hardcoded constant under ifdef KGDB too.
 1.53 06-Jun-2008  uwe Support single-stepping in DDB for sh3 too, it has different format of
UBC registers.
 1.52 01-Jun-2008  uwe Add GBR register to switchframe.

While here, reorder switchframe so that we can shave off a few
instructions when restoring it (group stack registers at the end, make
sure that last and first registers are safe to load/store in delay
slots).
 1.51 01-Jun-2008  uwe Add GBR register to trapframe.
 1.50 22-Mar-2008  uwe branches: 1.50.2; 1.50.4; 1.50.6;
Revert interrupt stack changes. There are some issues and, at least
in the current form, they complicate implementation of fast software
interrupts. I'd rather get fast softints in now and may be revisit
interrupt stack later.
 1.49 22-Mar-2008  uwe Oops, delete commented out line forgotten in previous.
 1.48 22-Mar-2008  uwe On SH4 we must be running on P2 to access memory-mapped TLB arrays.
Print DA2 again - that messenger was shot in 1.34
 1.47 15-Mar-2008  uwe Add "mach reset" command that resets machine by taking a trap with
exceptions disabled. Fix db_stackcheck_cmd (have_addr is now bool).
Supply help strings for mach commands.
 1.46 14-Dec-2007  uwe branches: 1.46.2; 1.46.6;
Use dedicated interrupt stack. Tested on hpcsh and landisk. This has
been sitting in my tree for quite a while. While here s/top/bottom/
in a few places related to stacks to confirm to conventional
terminology.
 1.45 17-Oct-2007  garbled branches: 1.45.4; 1.45.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.44 22-Sep-2007  martin Add a new option DDB_VERBOSE_HELP that adds online help to ddb.
From Adam Hamsik.
Minor modifications by me, all bugs are probably mine.
 1.43 17-May-2007  uwe branches: 1.43.8; 1.43.10;
Print pc/pr when faulting in ddb, it comes in handy.
 1.42 23-Feb-2007  uwe branches: 1.42.4; 1.42.6; 1.42.12;
Sprinkle static so that gcc can eliminate simple helper functions that
get inlined.
 1.41 23-Feb-2007  uwe Catch up with bool rototill.
 1.40 22-Feb-2007  thorpej TRUE -> true, FALSE -> false
 1.39 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.38 24-Jan-2007  hubertf branches: 1.38.2;
Remove duplicate #includes, patch contributed in private mail
by Slava Semushin <slava.semushin@gmail.com>.

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

Thanks to martin@ for the input on testing.
 1.37 06-Sep-2006  uwe branches: 1.37.2;
__db_print_symbol: don't try to be too smart with db_print_loc_and_inst.

We can have in a register an address that points to/into some variable
in the data segment, but db_print_loc_and_inst only looks for
functions, so it will misprint it as something unrelated from libkern
+ huge offset. E.g. instead of netbsd:cpu_info_store it would print
netbsd:prop_string_create_cstring+0xdeadbeef

Worse, if the address happens to be odd (char field in a struct, an
element of char array), attempt at printing the "instruction" at that
address will cause a fault and will abort "mach frame".

Disassemly is not really that useful in "mach frame" listing anyway
and more often just clutters things by overflowing 80 columns.
 1.36 05-Sep-2006  uwe Cosmetics - space auxiliary defines so that they are not visually
hidden in surrounding code.
 1.35 04-Sep-2006  uwe s/0/NULL/ for pointers.
 1.34 23-Aug-2006  uwe Make columns align with the header when dumping sh4 tlb.
Ifdef out dump of data array 2, it causes weird effects on landisk.
Minor whitespace cosmetic.
 1.33 22-Jul-2006  uwe exp_type[] was constified in exception.c but an extern declaration in
db_interface.c was not updated. Declare it publicly. While here,
constify the array itself too.
 1.32 24-Dec-2005  perry branches: 1.32.4; 1.32.8;
__asm__ -> __asm
__const__ -> const
__inline__ -> inline
__volatile__ -> volatile
 1.31 18-Dec-2005  uwe Declare ddb_regs extern in db_machdep.h and provide the defintion in
db_interface.c.
 1.30 11-Dec-2005  christos merge ktrace-lwp.
 1.29 04-Jun-2005  uwe branches: 1.29.2;
Catch up with constification.
 1.28 03-Jun-2005  tsutsui Adapt to ddb constification.
 1.27 31-May-2005  chs adapt to const changes.
 1.26 08-Mar-2005  uwe db_stackcheck_cmd: catch up with proc => lwp changes.
This is just a quick fix to make KSTACK_DEBUG kernels compilable.
Formatting needs improvment (group lwps from one process together, etc).
PR port-sh3/29621
 1.25 08-Mar-2005  uwe KNF: use "continue" as explicit empty loop body.
 1.24 08-Mar-2005  uwe Use uint<N>_t instead of u_int<N>_t.
 1.23 15-Jul-2003  lukem branches: 1.23.8; 1.23.10;
__KERNEL_RCSID()
 1.22 02-Apr-2003  thorpej branches: 1.22.2;
Use PAGE_SIZE rather than NBPG.
 1.21 08-Nov-2002  tsutsui Add _reg_bset_[124]() and _reg_bclr_[124]() macro for
SH embeded device registers.
 1.20 04-Nov-2002  itohy Fix asm usage. "tf" is an output operand, not an input.
 1.19 13-May-2002  matt branches: 1.19.6;
Nuke local extern label_t *db_recover; it's now in <ddb/db_extern.h>
 1.18 10-May-2002  uch cosmetic changes.
 1.17 09-May-2002  uch adapted to pmap and exception code changes.
 1.16 28-Apr-2002  uch Use "#define<tab>", white space nits.
 1.15 22-Apr-2002  uch make these compile with gcc -O0
 1.14 24-Mar-2002  uch Rework interrupt code.
+ Fully utilize SH SR.I[0:3] interrupt level.
+ software interrupt is emulated by TMU1, 2 one shot interrupt.
+ implement generic soft interrupts.
+ implement clockframe correctly.
 1.13 17-Mar-2002  uch add kernel stack and trapframe debug command.
 1.12 03-Mar-2002  uch SR related parts moved to psl.h. cpufunc.h segments.h are removed.
kernel mode checking is only SR.MD. no check stack pointer.
 1.11 02-Mar-2002  uch Initial support for KGDB on the sh3.
 1.10 28-Feb-2002  uch Cleanup register definition
 1.9 19-Feb-2002  uch Clean up function declaration.
 1.8 17-Feb-2002  uch add cache dump
 1.7 12-Feb-2002  uch ANSIfy KNF.
 1.6 11-Feb-2002  uch machine tlb command print PFN with AREA number.
 1.5 08-Feb-2002  uch TLB dump command added to DDB
 1.4 16-Oct-2001  msaitoh s/BYTE_ORDER/_BYTE_ORDER/g
 1.3 08-Sep-2000  tsubai branches: 1.3.4;
DDB single step and stack trace support.
 1.2 29-Jun-2000  mrg remove include of <vm/vm.h>. <vm/vm.h> -> <uvm/uvm_extern.h>
 1.1 13-Sep-1999  itojun branches: 1.1.2;
Merge in NetBSD/sh3 from cvs.kame.net repository.

Tree structure:
- sys/arch/sh3: sh3 generic code
As commented, in-chip device drivers are put into sys/arch/sh3/dev.
- sys/arch/evbsh3: sh3 evaluation boards (pure sh3 CPU, no fancy external HW)
- sys/arch/mmeye: Brains mmEye, www.brains.co.jp
MI source code includes couple of #ifdef for sh3-coff support.
(sh3 uses coff or elf)

Needs some more improvements, especialy in sys/arch/sh3/conf/files.sh3,
to compile the tree (due to last minute tree structure change).
 1.1.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.3.4.3 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.3.4.2 16-Mar-2002  jdolecek Catch up with -current.
 1.3.4.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.19.6.2 11-Nov-2002  nathanw Catch up to -current
 1.19.6.1 13-May-2002  nathanw file db_interface.c was added on branch nathanw_sa on 2002-11-11 22:04:04 +0000
 1.22.2.5 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.22.2.4 01-Apr-2005  skrll Sync with HEAD.
 1.22.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.22.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.22.2.1 03-Aug-2004  skrll Sync with HEAD
 1.23.10.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.23.8.1 29-Apr-2005  kent sync with -current
 1.29.2.8 24-Mar-2008  yamt sync with head.
 1.29.2.7 17-Mar-2008  yamt sync with head.
 1.29.2.6 21-Jan-2008  yamt sync with head
 1.29.2.5 27-Oct-2007  yamt sync with head.
 1.29.2.4 03-Sep-2007  yamt sync with head.
 1.29.2.3 26-Feb-2007  yamt sync with head.
 1.29.2.2 30-Dec-2006  yamt sync with head.
 1.29.2.1 21-Jun-2006  yamt sync with head.
 1.32.8.3 14-Sep-2006  yamt sync with head.
 1.32.8.2 03-Sep-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.37.2.1 01-Feb-2007  ad Sync with head.
 1.38.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.42.12.2 03-Oct-2007  garbled Sync with HEAD
 1.42.12.1 22-May-2007  matt Update to HEAD.
 1.42.6.1 11-Jul-2007  mjf Sync with head.
 1.42.4.2 09-Oct-2007  ad Sync with head.
 1.42.4.1 27-May-2007  ad Sync with head.
 1.43.10.3 23-Mar-2008  matt sync with HEAD
 1.43.10.2 09-Jan-2008  matt sync with HEAD
 1.43.10.1 06-Nov-2007  matt sync with HEAD
 1.43.8.1 02-Oct-2007  joerg Sync with HEAD.
 1.45.8.1 02-Jan-2008  bouyer Sync with HEAD
 1.45.4.1 26-Dec-2007  ad Sync with head.
 1.46.6.3 29-Jun-2008  mjf Sync with HEAD.
 1.46.6.2 02-Jun-2008  mjf Sync with HEAD.
 1.46.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.46.2.1 24-Mar-2008  keiichi sync with head.
 1.50.6.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.50.4.2 11-Mar-2010  yamt sync with head
 1.50.4.1 04-May-2009  yamt sync with head.
 1.50.2.2 17-Jun-2008  yamt sync with head.
 1.50.2.1 04-Jun-2008  yamt sync with head
 1.57.12.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.57.6.1 28-Apr-2009  skrll Sync with HEAD.
 1.59.8.1 08-Feb-2011  bouyer Sync with HEAD
 1.59.6.1 06-Jun-2011  jruoho Sync with HEAD.
 1.59.4.1 05-Mar-2011  rmind sync with head
 1.65.2.1 03-Apr-2021  thorpej Sync with HEAD.
 1.9 07-Jun-2008  uwe Sync icache before returning from db_write_bytes so that we don't get
stuck at a ddb breakpoint.
 1.8 24-Feb-2006  uwe branches: 1.8.68; 1.8.70; 1.8.72; 1.8.74;
Use 4- or 2-bytes aligned accesses if possible.
Makes it possible to examine hw registers that require 4- or 2-byte accesses.
 1.7 11-Dec-2005  christos branches: 1.7.2; 1.7.4; 1.7.6;
merge ktrace-lwp.
 1.6 03-Jun-2005  tsutsui branches: 1.6.2;
Adapt to ddb constification.
 1.5 15-Jul-2003  lukem __KERNEL_RCSID()
 1.4 12-Feb-2002  uch branches: 1.4.12; 1.4.18;
ANSIfy KNF.
 1.3 04-Sep-2000  tsubai branches: 1.3.4;
Make this (at least) compile on sh3.
 1.2 29-Jun-2000  mrg remove include of <vm/vm.h>. <vm/vm.h> -> <uvm/uvm_extern.h>
 1.1 13-Sep-1999  itojun branches: 1.1.2;
Merge in NetBSD/sh3 from cvs.kame.net repository.

Tree structure:
- sys/arch/sh3: sh3 generic code
As commented, in-chip device drivers are put into sys/arch/sh3/dev.
- sys/arch/evbsh3: sh3 evaluation boards (pure sh3 CPU, no fancy external HW)
- sys/arch/mmeye: Brains mmEye, www.brains.co.jp
MI source code includes couple of #ifdef for sh3-coff support.
(sh3 uses coff or elf)

Needs some more improvements, especialy in sys/arch/sh3/conf/files.sh3,
to compile the tree (due to last minute tree structure change).
 1.1.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.3.4.1 16-Mar-2002  jdolecek Catch up with -current.
 1.4.18.4 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.4.18.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.4.18.2 18-Sep-2004  skrll Sync with HEAD.
 1.4.18.1 03-Aug-2004  skrll Sync with HEAD
 1.4.12.2 12-Feb-2002  uch ANSIfy KNF.
 1.4.12.1 12-Feb-2002  uch file db_memrw.c was added on branch nathanw_sa on 2002-02-12 15:26:50 +0000
 1.6.2.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 01-Mar-2006  yamt sync with head.
 1.8.74.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.8.72.1 04-May-2009  yamt sync with head.
 1.8.70.1 17-Jun-2008  yamt sync with head.
 1.8.68.1 29-Jun-2008  mjf Sync with HEAD.
 1.26 09-May-2019  ryo fix backtrace. it was broken.
- use db_read_bytes() to avoid faults.
- quite a few functions do not use frame pointers,
therefore always detect stack depth without a frame pointer.
however, since the framepointer(=r14) is used as a trapframe,
the code to detect the frame pointer is still needed.
- dump the contents of trapframe during backtracing.
- KNF
 1.25 09-Nov-2013  christos branches: 1.25.30;
remove unused code
 1.24 06-Aug-2013  uwe db_stack_trace_print: support trace/[at], starting trace from switchframe.
 1.23 08-Jun-2008  uwe branches: 1.23.32; 1.23.42; 1.23.48;
Use "pc" and "sr" instead of "spc" and "ssr" to refer to those
registers in DDB. Names with initial "s" (for "saved") are somewhat
confusing to use. The fact that we use SPC/SSR registers to retrieve
values of PC/SR at the moment of trap is an immaterial implementation
detail.
 1.22 15-Apr-2008  uwe branches: 1.22.2; 1.22.4; 1.22.6;
Handle leaf routines that were interrupted.
Clean up/prettify debug printfs and compile them unconditionally,
but only enable them if db_trace_debug is set.
 1.21 22-Feb-2007  thorpej branches: 1.21.42;
TRUE -> true, FALSE -> false
 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 21-Jan-2006  uwe branches: 1.19.24;
CONSTCOND.
 1.18 24-Dec-2005  perry branches: 1.18.2;
bare asm -> __asm
 1.17 11-Dec-2005  christos merge ktrace-lwp.
 1.16 31-May-2005  chs branches: 1.16.2;
adapt to const changes.
 1.15 20-Apr-2005  uwe Teach db_stack_trace_print() to step through trap frames so that
backtraces on kernel exceptions are actually useful. Stop tracing at
traps from user mode for now.
 1.14 19-Apr-2005  uwe Fix pasto in comment.
 1.13 23-Feb-2004  uwe branches: 1.13.8;
Wrap "unknown instruction in prologue" in TRACE_DEBUG. gcc3 reorders
instructions so that prologue code and function code get mixed, and
you get a lot of noice from this printf, making traceback very hard to
read if not useless.
 1.12 22-Oct-2003  uwe Don't compare an integer variable to NULL.
 1.11 15-Jul-2003  lukem __KERNEL_RCSID()
 1.10 13-Apr-2003  tsutsui branches: 1.10.2;
Fix typo in printf message.
 1.9 28-Apr-2002  uch branches: 1.9.6;
Use "#define<tab>", white space nits.
 1.8 24-Feb-2002  uch _start -> start.
 1.7 12-Feb-2002  uch ANSIfy KNF.
 1.6 18-Jan-2001  jdolecek branches: 1.6.4;
make db_[e]regs[] const
 1.5 02-Nov-2000  msaitoh Add support stacktrace when a function contains "mov #n,r3; sub r3,r15"
 1.4 08-Sep-2000  tsubai DDB single step and stack trace support.
 1.3 26-May-2000  jhawk 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.2 25-May-2000  jhawk Interface change: db_printsym() takes a third argument, pr, a function
pointer indicating how to print the symbol. This allows db_printsym()
to called in places where db_printf() is not an appropriate output
function.

While straightforward, apologies in advance if I've introduced any minor
syntax errors; I was unable to test compilation this on all the affected
platforms.
 1.1 13-Sep-1999  itojun branches: 1.1.2;
Merge in NetBSD/sh3 from cvs.kame.net repository.

Tree structure:
- sys/arch/sh3: sh3 generic code
As commented, in-chip device drivers are put into sys/arch/sh3/dev.
- sys/arch/evbsh3: sh3 evaluation boards (pure sh3 CPU, no fancy external HW)
- sys/arch/mmeye: Brains mmEye, www.brains.co.jp
MI source code includes couple of #ifdef for sh3-coff support.
(sh3 uses coff or elf)

Needs some more improvements, especialy in sys/arch/sh3/conf/files.sh3,
to compile the tree (due to last minute tree structure change).
 1.1.2.3 11-Feb-2001  bouyer Sync with HEAD.
 1.1.2.2 22-Nov-2000  bouyer Sync with HEAD.
 1.1.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.6.4.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.6.4.1 16-Mar-2002  jdolecek Catch up with -current.
 1.9.6.2 28-Apr-2002  uch Use "#define<tab>", white space nits.
 1.9.6.1 28-Apr-2002  uch file db_trace.c was added on branch nathanw_sa on 2002-04-28 17:10:39 +0000
 1.10.2.4 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.10.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.10.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.10.2.1 03-Aug-2004  skrll Sync with HEAD
 1.13.8.1 29-Apr-2005  kent sync with -current
 1.16.2.2 26-Feb-2007  yamt sync with head.
 1.16.2.1 21-Jun-2006  yamt sync with head.
 1.18.2.1 01-Feb-2006  yamt sync with head.
 1.19.24.1 27-Feb-2007  yamt - sync with head.
- move sched_changepri back to kern_synch.c as it doesn't know PPQ anymore.
 1.21.42.2 29-Jun-2008  mjf Sync with HEAD.
 1.21.42.1 02-Jun-2008  mjf Sync with HEAD.
 1.22.6.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.22.4.1 04-May-2009  yamt sync with head.
 1.22.2.1 17-Jun-2008  yamt sync with head.
 1.23.48.2 18-May-2014  rmind sync with head
 1.23.48.1 28-Aug-2013  rmind sync with head
 1.23.42.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.23.32.1 22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.25.30.1 10-Jun-2019  christos Sync with HEAD
 1.8 18-Mar-2009  cegger Ansify function definitions w/o arguments. Generated with sed.
 1.7 28-Apr-2008  martin branches: 1.7.8; 1.7.14;
Remove clause 3 and 4 from TNF licenses
 1.6 04-Mar-2006  uwe branches: 1.6.68; 1.6.70; 1.6.72;
s/u_intN_t/uintN_t/
 1.5 11-Dec-2005  christos branches: 1.5.4; 1.5.6;
merge ktrace-lwp.
 1.4 15-Jul-2003  lukem branches: 1.4.16;
__KERNEL_RCSID()
 1.3 28-Apr-2002  uch branches: 1.3.6; 1.3.12;
Use "#define<tab>", white space nits.
 1.2 24-Mar-2002  uch branches: 1.2.2;
Rework interrupt code.
+ Fully utilize SH SR.I[0:3] interrupt level.
+ software interrupt is emulated by TMU1, 2 one shot interrupt.
+ implement generic soft interrupts.
+ implement clockframe correctly.
 1.1 28-Feb-2002  uch branches: 1.1.6;
Cleanup register definition
 1.1.6.3 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.1.6.2 16-Mar-2002  jdolecek Catch up with -current.
 1.1.6.1 28-Feb-2002  jdolecek file devreg.c was added on branch kqueue on 2002-03-16 15:59:41 +0000
 1.2.2.2 20-Jun-2002  nathanw Catch up to -current.
 1.2.2.1 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.3.12.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.3.12.2 18-Sep-2004  skrll Sync with HEAD.
 1.3.12.1 03-Aug-2004  skrll Sync with HEAD
 1.3.6.2 28-Apr-2002  uch Use "#define<tab>", white space nits.
 1.3.6.1 28-Apr-2002  uch file devreg.c was added on branch nathanw_sa on 2002-04-28 17:10:39 +0000
 1.4.16.1 21-Jun-2006  yamt sync with head.
 1.5.6.1 22-Apr-2006  simonb Sync with head.
 1.5.4.1 09-Sep-2006  rpaulo sync with head
 1.6.72.2 04-May-2009  yamt sync with head.
 1.6.72.1 16-May-2008  yamt sync with head.
 1.6.70.1 18-May-2008  yamt sync with head.
 1.6.68.1 02-Jun-2008  mjf Sync with HEAD.
 1.7.14.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.7.8.1 28-Apr-2009  skrll Sync with HEAD.
 1.32 02-Jun-2024  andvar s/corruptted/corrupted/ in return messages.
 1.31 10-Feb-2024  andvar Fix various typos in comments, log messages and documentation.
 1.30 03-Apr-2019  christos centralize setdisklabel(9)
 1.29 16-May-2013  christos branches: 1.29.34;
Complete the dosparts -> mbrparts conversion. Only x86k new uses dosparts
because it also uses struct dos_partition.
 1.28 19-Feb-2011  kiyohara branches: 1.28.4; 1.28.14;
Support mmEye-WLF.
Also maybe support mmEye-WL, mmEye2, mmEye2-HS.
 1.27 02-Jan-2008  ad branches: 1.27.32; 1.27.38; 1.27.40;
Merge vmlocking2 to head.
 1.26 17-Oct-2007  garbled branches: 1.26.2; 1.26.4; 1.26.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.25 08-Oct-2007  ad Merge brelse() changes from the vmlocking branch.
 1.24 29-Jul-2007  ad branches: 1.24.4; 1.24.6; 1.24.8;
It's not a good idea for device drivers to modify b_flags, as they don't
need to understand the locking around that field. Instead of setting
B_ERROR, set b_error instead. b_error is 'owned' by whoever completes
the I/O request.
 1.23 06-Mar-2007  he branches: 1.23.2; 1.23.10; 1.23.12; 1.23.14;
Cast to char* before doing pointer arithmetic.
 1.22 25-Nov-2006  scw branches: 1.22.4;
Replace the myriad copies of bounds_check_with_label() with a single MI
version.

Add disk_blocksize(9) so that disk drivers can record the physical
block size of a disk if it is different to DEV_BSIZE. Right now this
simply initialises dk_blkshift and dk_byteshift according to the
supplied block size. This information is used in the MI version of
bounds_check_with_label().
 1.21 04-Mar-2006  uwe branches: 1.21.14; 1.21.16;
s/u_intN_t/uintN_t/
 1.20 29-Jan-2006  dsl branches: 1.20.2; 1.20.4;
Make almost everything #include <sys/bswap.h> instead of <machine/bswap.h>
The bswap.h and endian.h files are all rather incestuous, but I want to
get the constant folding stuff into one place - sys/bswap.h
 1.19 11-Dec-2005  christos branches: 1.19.2;
merge ktrace-lwp.
 1.18 01-Jun-2005  scw branches: 1.18.2;
Fix const fallout.
 1.17 31-Oct-2003  tsutsui In swap_endian_disklabel(), don't forget copy members which are not
needed to byteswap.
 1.16 08-Oct-2003  lukem Overhaul MBR handling (part 1):

<sys/bootblock.h>:
* Added definitions for the Master Boot Record (MBR) used by
a variety of systems (primarily i386), including the format
of the BIOS Parameter Block (BPB).
This information was cribbed from a variety of sources
including <sys/disklabel_mbr.h> which this is a superset of.

As part of this, some data structure elements and #defines
were renamed to be more "namespace friendly" and consistent
with other bootblocks and MBR documentation.
Update all uses of the old names to the new names.

<sys/disklabel_mbr.h>:
* Deprecated in favor of <sys/bootblock.h> (the latter is more
"host tool" friendly).

amd64 & i386:
* Renamed /usr/mdec/bootxx_dosfs to /usr/mdec/bootxx_msdos, to
be consistent with the naming convention of the msdosfs tools.

* Removed /usr/mdec/bootxx_ufs, as it's equivalent to bootxx_ffsv1
and it's confusing to have two functionally equivalent bootblocks,
especially given that "ufs" has multiple meanings (it could be
a synonym for "ffs", or the group of ffs/lfs/ext2fs file systems).

* Rework pbr.S (the first sector of bootxx_*):
+ Ensure that BPB (bytes 11..89) and the partition table
(bytes 446..509) do not contain code.
+ Add support for booting from FAT partitions if BOOT_FROM_FAT
is defined. (Only set for bootxx_msdos).
+ Remove "dummy" partition 3; if people want to installboot(8)
these to the start of the disk they can use fdisk(8) to
create a real MBR partition table...
+ Compile with TERSE_ERROR so it fits because of the above.
Whilst this is less user friendly, I feel it's important
to have a valid partition table and BPB in the MBR/PBR.

* Renamed /usr/mdec/biosboot to /usr/mdec/boot, to be consistent
with other platforms.

* Enable SUPPORT_DOSFS in /usr/mdec/boot (stage2), so that
we can boot off FAT partitions.

* Crank version of /usr/mdec/boot to 3.1, and fix some of the other
entries in the version file.

installboot(8) (i386):
* Read the existing MBR of the filesystem and retain the BIOS
Parameter Block (BPB) in bytes 11..89 and the MBR partition
table in bytes 446..509. (Previously installboot(8) would
trash those two sections of the MBR.)

mbrlabel(8):
* Use sys/lib/libkern/xlat_mbr_fstype.c instead of homegrown code
to map the MBR partition type to the NetBSD disklabel type.


Test built "make release" for i386, and new bootblocks verified to work
(even off FAT!).
 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 15-Jul-2003  lukem __KERNEL_RCSID()
 1.13 12-May-2003  thorpej branches: 1.13.2;
Include <sys/disk.h>.
 1.12 10-May-2003  thorpej Change bounds_check_with_label() to take a pointer to the disk structure,
rather than the label itself. This paves the way for some future changes.
 1.11 02-May-2003  dsl Change return type of readdisklabel() to const char *
I hope I've found all the correct places!
 1.10 16-Apr-2003  bouyer Nake return values from bounds_check_with_label() conform to the man
page: -1 for error, 0 for EOF, 1 otherwise. Inspired by an OpenBSD commit
message, pointed out by Miod Vallat in private mail.
vax/mba/hp.c: check return value <= 0, not < 0 to be concistent with how
other places handle return values from bounds_check_with_label().
 1.9 22-Jul-2002  tsutsui Fix disklabel handling on sh3 ports:

- By default, use disklabels in the native endian.
- With options BSDDISKLABEL_EI, kernels can read/write labels
in the opposite endian.
- With options COMPAT_MMEYE_OLDLABEL, kernels accept labels
in format used on old mmeyes.
(Some old mmeyes have "the bootstrap kernel to load kernel from disks"
on their flash ROMs and it is not easy to update kernels on the ROMs.)
- While here, use leXXtoh() to read some values in MBR.
 1.8 28-Apr-2002  uch branches: 1.8.2; 1.8.6;
Use "#define<tab>", white space nits.
 1.7 17-Mar-2002  uch cosmetic changes, fix comments.
 1.6 19-Feb-2002  wiz strategy should have an 'r'. Inspired by similar change in OpenBSD.
 1.5 12-Feb-2002  uch ANSIfy KNF.
 1.4 20-Nov-2000  chs branches: 1.4.2; 1.4.4;
rationalize the use of b_flags for geteblk() buffers.
rather than assigning to the whole field, set or clear individual flags,
which implies that the B_BUSY and B_INVAL flags will remain set.
this allows us to make the assertion in brelse() that B_BUSY is set,
which is the purpose of all this.
 1.3 22-Feb-2000  msaitoh calculate checksum correctly
 1.2 18-Jan-2000  thorpej Use b_cylinder as defined in sys/buf.h
 1.1 13-Sep-1999  itojun branches: 1.1.2; 1.1.8;
Merge in NetBSD/sh3 from cvs.kame.net repository.

Tree structure:
- sys/arch/sh3: sh3 generic code
As commented, in-chip device drivers are put into sys/arch/sh3/dev.
- sys/arch/evbsh3: sh3 evaluation boards (pure sh3 CPU, no fancy external HW)
- sys/arch/mmeye: Brains mmEye, www.brains.co.jp
MI source code includes couple of #ifdef for sh3-coff support.
(sh3 uses coff or elf)

Needs some more improvements, especialy in sys/arch/sh3/conf/files.sh3,
to compile the tree (due to last minute tree structure change).
 1.1.8.1 21-Dec-1999  wrstuden Initial commit of recent changes to make DEV_BSIZE go away.

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

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

Non 2**n block support is automatic for LKM's and conditional for kernels
on "options NON_PO2_BLOCKS".
 1.1.2.2 22-Nov-2000  bouyer Sync with HEAD.
 1.1.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.4.4.3 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.4.4.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.4.4.1 16-Mar-2002  jdolecek Catch up with -current.
 1.4.2.1 10-Oct-2001  fvdl Convert all remaining devices.
 1.8.6.2 01-Aug-2002  nathanw Catch up to -current.
 1.8.6.1 28-Apr-2002  nathanw file disksubr.c was added on branch nathanw_sa on 2002-08-01 02:43:18 +0000
 1.8.2.1 31-Aug-2002  gehenna catch up with -current.
 1.13.2.4 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.13.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.13.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.13.2.1 03-Aug-2004  skrll Sync with HEAD
 1.18.2.5 21-Jan-2008  yamt sync with head
 1.18.2.4 27-Oct-2007  yamt sync with head.
 1.18.2.3 03-Sep-2007  yamt sync with head.
 1.18.2.2 30-Dec-2006  yamt sync with head.
 1.18.2.1 21-Jun-2006  yamt sync with head.
 1.19.2.1 01-Feb-2006  yamt sync with head.
 1.20.4.1 22-Apr-2006  simonb Sync with head.
 1.20.2.1 09-Sep-2006  rpaulo sync with head
 1.21.16.1 10-Dec-2006  yamt sync with head.
 1.21.14.1 12-Jan-2007  ad Sync with head.
 1.22.4.1 12-Mar-2007  rmind Sync with HEAD.
 1.23.14.1 15-Aug-2007  skrll Sync with HEAD.
 1.23.12.1 07-Aug-2007  matt Sync with HEAD.
 1.23.10.2 16-Oct-2007  garbled Sync with HEAD
 1.23.10.1 03-Oct-2007  garbled Sync with HEAD
 1.23.2.2 09-Oct-2007  ad Sync with head.
 1.23.2.1 19-Aug-2007  ad - Back out the biodone() changes.
- Eliminate B_ERROR (from HEAD).
 1.24.8.1 14-Oct-2007  yamt sync with head.
 1.24.6.2 09-Jan-2008  matt sync with HEAD
 1.24.6.1 06-Nov-2007  matt sync with HEAD
 1.24.4.1 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.26.8.1 02-Jan-2008  bouyer Sync with HEAD
 1.26.4.1 31-Dec-2007  ad Make compile with new buffer cache locking scheme.

XXX This should be largely MI, please do not make another clone of disksubr.c.
 1.26.2.1 18-Feb-2008  mjf Sync with HEAD.
 1.27.40.1 05-Mar-2011  bouyer Sync with HEAD
 1.27.38.1 06-Jun-2011  jruoho Sync with HEAD.
 1.27.32.1 05-Mar-2011  rmind sync with head
 1.28.14.1 23-Jun-2013  tls resync from head
 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.29.34.1 10-Jun-2019  christos Sync with HEAD
 1.3 08-Mar-2002  uch branches: 1.3.8;
remove unneeded code and files.
 1.2 12-Feb-2002  uch ANSIfy KNF.
 1.1 13-Sep-1999  itojun branches: 1.1.16;
Merge in NetBSD/sh3 from cvs.kame.net repository.

Tree structure:
- sys/arch/sh3: sh3 generic code
As commented, in-chip device drivers are put into sys/arch/sh3/dev.
- sys/arch/evbsh3: sh3 evaluation boards (pure sh3 CPU, no fancy external HW)
- sys/arch/mmeye: Brains mmEye, www.brains.co.jp
MI source code includes couple of #ifdef for sh3-coff support.
(sh3 uses coff or elf)

Needs some more improvements, especialy in sys/arch/sh3/conf/files.sh3,
to compile the tree (due to last minute tree structure change).
 1.1.16.1 16-Mar-2002  jdolecek Catch up with -current.
 1.3.8.2 08-Mar-2002  uch remove unneeded code and files.
 1.3.8.1 08-Mar-2002  uch file dkbad.c was added on branch nathanw_sa on 2002-03-08 13:22:15 +0000
 1.75 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.74 15-Sep-2021  rin For kernel mode address error, do not overwrite tf->tf_spc and tf->tf_r0
*before* checking pcb->pbc_onfault != NULL.

Should fix part of

PR port-sh3/56382
PR port-sh3/56401

i.e., DDB will no longer wrongly indicate NULL as fault PC for kernel mode
address error (and 0xe == EFAULT as r0).

Yes, we have another bugs that cause panics described in the two PRs, but
now we can examine them more easily :).
 1.73 03-Dec-2019  ad One more tweak.
 1.72 03-Dec-2019  ad tlb_exception: in slow path, check for usermode before calling userret().
 1.71 01-Dec-2019  ad sh3: make ASTs work as expected, and fix a few things in the TLB refill path.
With help from uwe@ and martin@.
 1.70 30-Nov-2019  ad Revert previous. Looks like it requires a more extensive fix.
 1.69 29-Nov-2019  ad PR port-sparc/54718 (sparc install hangs since recent scheduler changes)

- userret() must be called every time we return to user, it's not optional.
- If clearing the AST with interrupts off, you must loop over userret().
 1.68 21-Nov-2019  ad mi_userret(): take care of calling preempt(), set spc_curpriority directly,
and remove MD code that does the same.
 1.67 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.66 22-Oct-2017  uwe branches: 1.66.4;
tlb_exception - set ksi_addr to va also when a userland page is not found.
Helps SIGSEGV handlers for PROT_NONE red zones.
 1.65 20-Jun-2017  uwe Use vmspace::vm_minsaddr instead of hardcoding USRSTACK.
Requested by joerg@.
 1.64 04-Mar-2015  skrll branches: 1.64.10;
Handle EINVAL in the fault path and send SIGBUS on mmap'd access past EOF.

From martin@
 1.63 08-Jul-2012  dsl branches: 1.63.2; 1.63.16;
The MDP_USEDFPU (amd64 and sh3) and MDP_SSTEP (sh3) are lwp flags not
process ones, rename to MDL_xxx.
 1.62 19-Feb-2012  rmind Remove COMPAT_SA / KERN_SA. Welcome to 6.99.3!
Approved by core@.
 1.61 28-Jan-2011  uwe branches: 1.61.4; 1.61.8;
Implement PT_STEP.
 1.60 27-Jan-2011  uwe general_exception: when printing current mode in the panic message,
test "usermode" directly instead of testing for EXP_USER bit.
 1.59 14-Jan-2011  rmind branches: 1.59.2; 1.59.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.58 29-Dec-2010  nisimura one more line for lwp_getpcb() conversion.
 1.57 29-Dec-2010  nisimura use lwp_getpcb() to hide the detail about how struct pcb is populated.
 1.56 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.55 20-Mar-2010  chs fix copy{in,out}{,str}() to return the error returned by uvm_fault().
fixes PR 41813.
 1.54 21-Nov-2009  rmind branches: 1.54.2; 1.54.4;
Use lwp_getpcb() on mips, powerpc and sh3, clean from struct user usage.
 1.53 19-Dec-2008  njoly Fix remaining archs (arm, luna68k, powerpc and sh3) that were still
using a proc argument instead of an expected lwp for ADDUPROF macro.

ok by christos.
 1.52 21-Oct-2008  wrstuden branches: 1.52.2;
upcallret() will work much better if it's not in the middle of another
routine!
 1.51 15-Oct-2008  wrstuden Merge wrstuden-revivesa into HEAD.
 1.50 07-Jun-2008  uwe branches: 1.50.4;
Pass trap code to kgdb_trap().
 1.49 07-Jun-2008  uwe Move EXPEVT_BREAK case next to EXPEVT_TRAPA case, they both generate
SIGTRAP and it's easier to read when they are together.
 1.48 21-May-2008  ad Remove unneeded playing about with kernel_lock.
 1.47 20-May-2008  uwe Add semicolon that was lost some 5 years ago.
Reported missing by proper do-while macro hygiene in systm.h.
 1.46 21-Feb-2008  uwe branches: 1.46.6; 1.46.8; 1.46.10; 1.46.12;
Use __arraycount.
 1.45 21-Feb-2008  uwe Revert previous, it's too noisy and misleading (e.g. single stepping
in ddb is not "fatal"). Need to redo it, but not now.
 1.44 08-Jan-2008  uwe In general_exception() in do_panic case print error message *before*
we drop into ddb.
 1.43 17-Oct-2007  garbled branches: 1.43.2; 1.43.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.42 01-Oct-2007  ad Make want_resched a member of cpu_info.
 1.41 24-Sep-2007  uwe Do RAS check in sh_vector_interrupt, don't abuse ast() for that.
 1.40 27-Aug-2007  uwe branches: 1.40.2; 1.40.4;
Move child_return() and startlwp() to be in the same file with
cpu_lwp_fork() that is used to call them.
 1.39 15-Aug-2007  ad Changes to make ktrace LKM friendly and reduce ifdef KTRACE. Proposed
on tech-kern.
 1.38 17-May-2007  yamt branches: 1.38.4; 1.38.8;
merge yamt-idlelwp branch. asked by core@. some ports still needs work.

from doc/BRANCHES:

idle lwp, and some changes depending on it.

1. separate context switching and thread scheduling.
(cf. gmcgarry_ctxsw)
2. implement idle lwp.
3. clean up related MD/MI interfaces.
4. make scheduler(s) modular.
 1.37 30-Mar-2007  uwe branches: 1.37.4;
Re-enable interrupts in tlb_exception too.
 1.36 14-Mar-2007  uwe Convert _lock_cas to RAS. Check for restart in ast() on return from interrupt.
 1.35 21-Feb-2007  thorpej branches: 1.35.4; 1.35.6;
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.34 09-Feb-2007  ad branches: 1.34.2;
Merge newlock2 to head.
 1.33 08-Oct-2006  uwe branches: 1.33.2; 1.33.4;
general_exception() is called with all interrupts masked in SR
(effectively we were running syscalls with interrupts disabled).
splx back to previous interrupt level from tf->tf_ssr.

XXX: tlb_exception() still has that problem.
 1.32 04-Sep-2006  uwe branches: 1.32.2; 1.32.4;
general_exception: g/c infinite loop after the call to panic.
 1.31 22-Jul-2006  uwe tlb_exception: Move and indent TLB_ASSERT to reduce visual clutter.
Fix function name in the panic message. Print expevt on panic.
Split panic message so that the dumped numbers are on a separate line.
 1.30 22-Jul-2006  uwe exp_type[] was constified in exception.c but an extern declaration in
db_interface.c was not updated. Declare it publicly. While here,
constify the array itself too.
 1.29 22-Jul-2006  uwe Report traps from user break controller as ksi_code = TRAP_TRACE
 1.28 22-Jul-2006  uwe Minor cosmetics.
 1.27 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.26 16-Mar-2006  he Transform to new signature for uvm_fault() by dropping the third arg.
Discussed with drochner.
 1.25 07-Mar-2006  thorpej branches: 1.25.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.24 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.23 11-Dec-2005  christos branches: 1.23.4; 1.23.6; 1.23.8;
merge ktrace-lwp.
 1.22 10-Jul-2005  uwe Implement syscall_intern for sh3.
 1.21 01-Jul-2005  christos branches: 1.21.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.20 31-May-2005  uwe Constify as -Wcast-qual seyeth.
 1.19 24-Mar-2004  wiz 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.18 14-Mar-2004  cl add kernel part of concurrency support for SA on MP systems
- move per VP data into struct sadata_vp referenced from l->l_savp
* VP id
* lock on VP data
* LWP on VP
* recently blocked LWP on VP
* queue of LWPs woken which ran on this VP before sleep
* faultaddr
* LWP cache for upcalls
* upcall queue
- add current concurrency and requested concurrency variables
- make process exit run LWP on all VPs
- make signal delivery consider all VPs
- make timer events consider all VPs
- add sa_newsavp to allocate new sadata_vp structure
- add sa_increaseconcurrency to prepare new VP
- make sys_sa_setconcurrency request new VP or wakeup idle VP
- make sa_yield lower current concurrency
- set sa_cpu = VP id in upcalls
- maintain cached LWPs per VP
 1.17 24-Nov-2003  uwe general_exception() now receives TEA as a third argument. For user
mode EXPEVT_ADDR_ERR_{LD,ST} traps pass it as ksi_addr, also use it to
decide if this is a SIGBUS (unaliged access) or SIGSEGV (kernel VA
access).

Report EXPEVT_TLB_PROT_LD as SEGV_ACCERR, not SEGV_MAPERR.

While here, consistently use standard uint32_t instead of u_int32_t.
 1.16 23-Nov-2003  uwe Implement siginfo for sh3.
 1.15 31-Oct-2003  simonb Don't pass the (unused) return value args to the
trace_enter()/systrace_enter() functions.
 1.14 31-Oct-2003  uwe When signaling SIGTRAP for debugger break adjust pc to point back to
the TRAPA instruction. This makes gdb much happier.
 1.13 31-Oct-2003  uwe tlb_exception: pacify -Wuninitialized by adding default case.
 1.12 22-Oct-2003  uwe Don't compare an integer to NULL.
 1.11 13-Oct-2003  cl add MD part of SA/pthread pagefault handling on sh3
 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 15-Jul-2003  lukem __KERNEL_RCSID()
 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 09-Mar-2003  tsutsui In tlb_exception(), don't panic immediately on access at va == 0
from kernel mode if fault hander is set.
 1.5 18-Jan-2003  thorpej Merge the nathanw_sa branch.
 1.4 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.3 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.2 17-Jun-2002  christos branches: 1.2.2; 1.2.4; 1.2.6;
MD systrace gluons.
 1.1 09-May-2002  uch branches: 1.1.2;
rework general exception, and TLB exception handling for new pmap.
all exception staffs are moved to exception.[ch]
 1.1.2.1 15-Jul-2002  gehenna catch up with -current.
 1.2.6.3 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.2.6.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.2.6.1 17-Jun-2002  jdolecek file exception.c was added on branch kqueue on 2002-06-23 17:40:50 +0000
 1.2.4.6 07-Jan-2003  thorpej In the SA universe, the switch-to-this-LWP decision is made at a
different level than where preempt() calls are made, which renders
the "newlwp" argument useless. Replace it with a "more work to do"
boolean argument. Returning to userspace preempt() calls pass 0.
"Voluntary" preemptions in e.g. uiomove() pass 1. This will be used
to indicate to the SA subsystem that the LWP is not yet finished in
the kernel.

Collapse the SA vs. non-SA cases of preempt() together, making the
conditional code block much smaller, and don't call sa_preempt() if
more work is to come.

NOTE: THIS IS NOT A COMPLETE FIX TO THE preempt()-in-uiomove() PROBLEM
THAT CURRENTLY EXISTS FOR SA PROCESSES.
 1.2.4.5 29-Dec-2002  thorpej Sync with HEAD.
 1.2.4.4 11-Dec-2002  thorpej Sync with HEAD.
 1.2.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.2.4.2 21-Jun-2002  thorpej Add support for scheduler activations on SuperH. Boots multi-user
on Dreamcast (SH4) with stock userland.
 1.2.4.1 17-Jun-2002  thorpej file exception.c was added on branch nathanw_sa on 2002-06-21 21:26:31 +0000
 1.2.2.1 20-Jun-2002  nathanw Catch up to -current.
 1.8.2.5 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 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.21.2.7 27-Feb-2008  yamt sync with head.
 1.21.2.6 21-Jan-2008  yamt sync with head
 1.21.2.5 27-Oct-2007  yamt sync with head.
 1.21.2.4 03-Sep-2007  yamt sync with head.
 1.21.2.3 26-Feb-2007  yamt sync with head.
 1.21.2.2 30-Dec-2006  yamt sync with head.
 1.21.2.1 21-Jun-2006  yamt sync with head.
 1.23.8.4 14-Sep-2006  yamt sync with head.
 1.23.8.3 11-Aug-2006  yamt sync with head
 1.23.8.2 01-Apr-2006  yamt sync with head.
 1.23.8.1 13-Mar-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.2.2 19-Apr-2006  elad sync with head - hopefully this will work
 1.25.2.1 07-Mar-2006  elad file exception.c was added on branch elad-kernelauth on 2006-04-19 02:33:44 +0000
 1.32.4.1 22-Oct-2006  yamt sync with head
 1.32.2.3 01-Feb-2007  ad Get sh3 compiling.
 1.32.2.2 30-Jan-2007  ad Remove support for SA. Ok core@.
 1.32.2.1 18-Nov-2006  ad Sync with head.
 1.33.4.1 04-Jun-2007  wrstuden Update to today's netbsd-4.
 1.33.2.1 30-May-2007  riz Pull up following revision(s) (requested by uwe in ticket #681):
sys/arch/sh3/sh3/exception.c: revision 1.37
Re-enable interrupts in tlb_exception too.
 1.34.2.4 15-Apr-2007  yamt sync with head.
 1.34.2.3 25-Mar-2007  uwe Adapt sh3 to yamt-idlelwp.
 1.34.2.2 24-Mar-2007  yamt sync with head.
 1.34.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.35.6.1 11-Jul-2007  mjf Sync with head.
 1.35.4.4 09-Oct-2007  ad Sync with head.
 1.35.4.3 20-Aug-2007  ad Sync with HEAD.
 1.35.4.2 27-May-2007  ad Sync with head.
 1.35.4.1 10-Apr-2007  ad Sync with head.
 1.37.4.2 03-Oct-2007  garbled Sync with HEAD
 1.37.4.1 22-May-2007  matt Update to HEAD.
 1.38.8.3 02-Oct-2007  joerg Sync with HEAD.
 1.38.8.2 03-Sep-2007  jmcneill Sync with HEAD.
 1.38.8.1 16-Aug-2007  jmcneill Sync with HEAD.
 1.38.4.1 03-Sep-2007  skrll Sync with HEAD.
 1.40.4.1 06-Oct-2007  yamt sync with head.
 1.40.2.3 23-Mar-2008  matt sync with HEAD
 1.40.2.2 09-Jan-2008  matt sync with HEAD
 1.40.2.1 06-Nov-2007  matt sync with HEAD
 1.43.8.1 08-Jan-2008  bouyer Sync with HEAD
 1.43.2.1 18-Feb-2008  mjf Sync with HEAD.
 1.46.12.4 30-Jun-2008  wrstuden Change how we make SA threads not generate upcalls. Instead of clearing
LW_SA, use a private flag, LP_SA_NOBLOCK, that we set when we want
to not generate upcalls. This means we do NOT need to lock (l)
(ourselves) to set it.

Adjust tests that look at LW_SA. Now, we are an upcall-generating
lwp if ((l->l_flag & LW_SA) && (~l->l_pflag & LP_SA_NOBLOCK)).

Introduce code pattern to set & remember this:

f = ~l->l_pflag & LP_SA_NOBLOCK;
l->l_pflag |= LP_SA_NOBLOCK;

...

/* f is now LP_SA_NOBLOCK if it wasn't set in l_pflag before */

l->l_pflag ^= f;

I updated a lot of the trap handlers to do trap handling iff LP_SA_NOBLOCK
is not set. I tried to figure out if the trap handler could be triggered
for user-based faults as opposed to kernel faults to user addresses, and
only look at LP_SA_NOBLOCK for the latter.

Above is a result of discussions with rmind at to reduce lock twiddling.

Also, per same discussions, add locking to sys_sa_preempt(). p_lock is
the lock we want.

Also, per same discussions, remove use of LSSUSPENDED as a thread state.
We needed to use it when we were emulating the 4.X and previous behavior
of hiding cached threads. For the moment, we now have them instead
remain visible to all and have them sleeping on the "lwpcache" wait
channel.

sa_newcachelwp(): sa_putcachelwp() wants savp_mutex held, not p_lock.

Tweak some comments.
 1.46.12.3 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.46.12.2 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.46.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.46.10.3 11-Aug-2010  yamt sync with head.
 1.46.10.2 11-Mar-2010  yamt sync with head
 1.46.10.1 04-May-2009  yamt sync with head.
 1.46.8.2 17-Jun-2008  yamt sync with head.
 1.46.8.1 04-Jun-2008  yamt sync with head
 1.46.6.4 17-Jan-2009  mjf Sync with HEAD.
 1.46.6.3 29-Jun-2008  mjf Sync with HEAD.
 1.46.6.2 02-Jun-2008  mjf Sync with HEAD.
 1.46.6.1 21-Feb-2008  mjf file exception.c was added on branch mjf-devfs2 on 2008-06-02 13:22:38 +0000
 1.50.4.2 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.50.4.1 19-Oct-2008  haad Sync with HEAD.
 1.52.2.1 19-Jan-2009  skrll Sync with HEAD.
 1.54.4.2 05-Mar-2011  rmind sync with head
 1.54.4.1 30-May-2010  rmind sync with head
 1.54.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.59.4.1 08-Feb-2011  bouyer Sync with HEAD
 1.59.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.61.8.1 24-Feb-2012  mrg sync to -current.
 1.61.4.2 30-Oct-2012  yamt sync with head
 1.61.4.1 17-Apr-2012  yamt sync with head
 1.63.16.2 28-Aug-2017  skrll Sync with HEAD
 1.63.16.1 06-Apr-2015  skrll Sync with HEAD
 1.63.2.1 03-Dec-2017  jdolecek update from HEAD
 1.64.10.1 19-Feb-2018  snj Pull up following revision(s) (requested by uwe in ticket #554):
sys/arch/sh3/sh3/exception.c: 1.66
tlb_exception - set ksi_addr to va also when a userland page is not found.
Helps SIGSEGV handlers for PROT_NONE red zones.
 1.66.4.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.66.4.1 10-Jun-2019  christos Sync with HEAD
 1.53 26-Jul-2021  andvar Revert rename back to OFSET, since the name follows historical PGOFSET definition. Noted by tsutsui.
 1.52 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.51 01-Dec-2019  ad branches: 1.51.12;
sh3: make ASTs work as expected, and fix a few things in the TLB refill path.
With help from uwe@ and martin@.
 1.50 02-Nov-2016  pgoyette branches: 1.50.16;
* Split sys/kern/sys_process.c into three parts:
1 - ptrace(2) syscall for native emulation
2 - common ptrace(2) syscall code (shared with compat_netbsd32)
3 - support routines that are shared with PROCFS and/or KTRACE

* Add module glue for #1 and #2. Both modules will be built-in to the
kernel if "options PTRACE" is included in the config file (this is
the default, defined in sys/conf/std).

* Mark the ptrace(2) syscall as modular in syscalls.master (generated
files will be committed shortly).

* Conditionalize all remaining portions of PTRACE code on a new kernel
option PTRACE_HOOKS.

XXX Instead of PROCFS depending on 'options PTRACE', we should probably
just add a procfs attribute to the sys/kern/sys_process.c file's
entry in files.kern, and add PROCFS to the "#if defineds" for
process_domem(). It's really confusing to have two different ways
of requiring this file.
 1.49 04-Feb-2011  uwe branches: 1.49.14; 1.49.32; 1.49.36;
Use __INTR_MASK_EXCEPTION_UNBLOCK combo.
 1.48 04-Feb-2011  uwe __EXCEPTION_ENTRY - "tst" already does logical AND, so shave off extra
"mov" and "and" and just test PSL_MD bit directly.

While here - shuffle around instructions to construct PSL_MD to break
dependencies.

While still here - only interrupt vector uses SSR and SPC as function
args, so don't bother saving them here in r4 and r5. Other vectors
don't need them and interrupt vector can just as well "stc" them
directly before exceptions are enabled.
 1.47 28-Jan-2011  uwe Implement PT_STEP.
 1.46 20-Dec-2010  matt branches: 1.46.2; 1.46.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.45 23-Jan-2009  uwe branches: 1.45.6;
Revert two previous revisions and just use __pmap_kernel directly again.
There's no reason to pretend we don't know what kernel_pmap_ptr is.
 1.44 23-Jan-2009  uch __pmap_kernel is pointer not symbol from pmap.c 1.68. set correct address.
 1.43 09-Dec-2008  pooka Make pmap_kernel() a MI macro for struct pmap *kernel_pmap_ptr,
which is now the "API" provided by the pmap module. pmap_kernel()
remains as the syntactic sugar.

Bonus cosmetics round: move all the pmap_t pointer typedefs into
uvm_pmap.h.

Thanks to Greg Oster for providing cpu muscle for doing test builds.
 1.42 08-Jun-2008  uwe branches: 1.42.4; 1.42.6;
sh_vector_generic - reorder literals to improve locality of reference.
 1.41 08-Jun-2008  uwe Match PC address for single-stepping, program BARA = tf->tf_spc before
returning from exception.

Makes single-stepping work on sh3 - without matching the address sh3
gets stuck at the instruction we are at, getting EXPEVT_BREAK before
executing the instruction.
 1.40 06-Jun-2008  uwe Bah, got tf_ubc = 0 logic wrong in previous. Revert that part, it's bogus.
 1.39 06-Jun-2008  uwe Support single-stepping in DDB for sh3 too, it has different format of
UBC registers.
 1.38 28-Apr-2008  martin branches: 1.38.2;
Remove clause 3 and 4 from TNF licenses
 1.37 22-Mar-2008  uwe branches: 1.37.2; 1.37.4;
Revert interrupt stack changes. There are some issues and, at least
in the current form, they complicate implementation of fast software
interrupts. I'd rather get fast softints in now and may be revisit
interrupt stack later.
 1.36 23-Feb-2008  uwe Now that __EXCEPTION_BLOCK does the right thing, preserving SR for us,
we don't have to open-code it here.
 1.35 14-Feb-2008  uwe branches: 1.35.2; 1.35.6;
If we are returning from a nested interrupt we know we are returning
to kernel so we can skip the PSL_MD check.
 1.34 14-Dec-2007  uwe Use dedicated interrupt stack. Tested on hpcsh and landisk. This has
been sitting in my tree for quite a while. While here s/top/bottom/
in a few places related to stacks to confirm to conventional
terminology.
 1.33 17-Oct-2007  garbled branches: 1.33.2; 1.33.4; 1.33.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.32 25-Sep-2007  uwe sh_vector_interrupt - while here, shave off a few cycles and run with
exceptions disabled only the code that really needs to.
 1.31 24-Sep-2007  uwe Do RAS check in sh_vector_interrupt, don't abuse ast() for that.
 1.30 20-Aug-2007  uwe branches: 1.30.2; 1.30.4;
Add back comma between operands lost in s/tab/space/ cosmetics of 1.21
(as(1) doesn't mind, apparently)
 1.29 18-May-2007  uwe branches: 1.29.4; 1.29.8;
Implement fast path TLB miss handling. Walk the page table without
creating a trapframe, with exceptions disabled and using only BANK1
registers. If a valid pte is found, load it and return. Otherwise
create a trapframe and proceed to the full-blown C handler.
 1.28 18-Mar-2007  uwe branches: 1.28.4;
Don't do curupte checks if the miss address is in user space.
 1.27 17-Mar-2007  uwe Shave off few instructions when doing ldtlb.
 1.26 17-Mar-2007  uwe Cosmetic - fix local label name to match the name of the var it refers.
 1.25 16-Mar-2007  uwe Use dt to loop over md_upte in sh3_vector_tlbmiss. Saves a few instructions.
 1.24 15-Mar-2007  uwe Comment sh3_vector_tlbmiss. Same object code is generated.
 1.23 15-Mar-2007  uwe Arrange for data blocks to start on 32B cache line boundary.
 1.22 15-Mar-2007  uwe Use .L* for local labels. Misc cosmetic.
Same object code is generated.
 1.21 14-Mar-2007  uwe branches: 1.21.2;
s/TAB/space/ to separate instruction operands. There are quite a few
cpp macros and long src operands anyway that destroy any intended
"neatly lined up" effect that TAB was supposed to achieve.

White space change only, same object code is generated, but it is much
easier on the eyes now.
 1.20 21-Sep-2006  uwe branches: 1.20.2; 1.20.4; 1.20.8; 1.20.10; 1.20.12;
Don't truncate TEA when we call tlb_exception from sh_vector_generic.
 1.19 22-Aug-2006  uwe branches: 1.19.2; 1.19.4;
Follow up to revision 1.16 (that only dealt with sh3).
Pass untruncated va=TEA to tlb_exception() from sh4_vector_tlbmiss too.
 1.18 08-Feb-2006  uwe branches: 1.18.2;
sh3_vector_tlbmiss: don't waste perfectly good delay slots.
 1.17 08-Feb-2006  uwe While here, shave off few bytes and few cycles off of the sh3_vector_tlbmiss.

Since the registers we use are at the very end of address space, we
can load their addresses as small immediate negative constants instead
of loading them from memory.
 1.16 07-Feb-2006  uwe Pass untruncated va=TEA to tlb_exception(), not its VPN.
 1.15 22-Jan-2006  uwe branches: 1.15.2; 1.15.4;
Use macros from <machine/asm.h>. Provide .size
Provide LINTSTUBs.
 1.14 11-Dec-2005  christos branches: 1.14.2;
merge ktrace-lwp.
 1.13 24-Nov-2003  uwe branches: 1.13.16;
Cosmetic: in sh_vector_generic use named label instead of numeric
label for the curlwp address. Same object code is generated.
 1.12 24-Nov-2003  uwe Add __KERNEL_RCSID.
 1.11 24-Nov-2003  uwe Pass TEA to general_exception. While here add a couple of comments.
 1.10 18-Jan-2003  thorpej branches: 1.10.2;
Merge the nathanw_sa branch.
 1.9 09-May-2002  uch branches: 1.9.6;
rework general exception, and TLB exception handling for new pmap.
all exception staffs are moved to exception.[ch]
 1.8 28-Apr-2002  uch Use "#define<tab>", white space nits.
 1.7 22-Apr-2002  uch make these compile with gcc -O0
 1.6 28-Mar-2002  uch add uvmexp.intrs++
 1.5 24-Mar-2002  uch Rework interrupt code.
+ Fully utilize SH SR.I[0:3] interrupt level.
+ software interrupt is emulated by TMU1, 2 one shot interrupt.
+ implement generic soft interrupts.
+ implement clockframe correctly.
 1.4 17-Mar-2002  uch cosmetic changes, fix comments.
 1.3 17-Mar-2002  uch kernel stack fix. old code simply P3 address converted to P1, it
caused memory destruction when kernel stack grow over 1 page. new
code use P3 address for kernel stack. but for the sake of debug, P1
kernel stack mode remain.
 1.2 28-Feb-2002  uch branches: 1.2.2; 1.2.8;
Change foo_r0_r1 macro in sh3/locore.h to foo(Rn, Rm)
 1.1 24-Feb-2002  uch Move common exception vector and scheduler code to
sh3/sh3/exception_vector.S and sh3/sh3/locore_subr.S. exception
vectors are installed by sh_cpu_init(). machine/locore.S contains
kernel entry, interrupt handler, and some MD code.
 1.2.8.3 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.2.8.2 16-Mar-2002  jdolecek Catch up with -current.
 1.2.8.1 28-Feb-2002  jdolecek file exception_vector.S was added on branch kqueue on 2002-03-16 15:59:41 +0000
 1.2.2.3 20-Jun-2002  nathanw Catch up to -current.
 1.2.2.2 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.2.2.1 28-Feb-2002  nathanw Catch up to -current.
 1.9.6.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.9.6.1 09-May-2002  nathanw file exception_vector.S was added on branch nathanw_sa on 2002-06-24 22:07:20 +0000
 1.10.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.10.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.10.2.1 03-Aug-2004  skrll Sync with HEAD
 1.13.16.7 24-Mar-2008  yamt sync with head.
 1.13.16.6 27-Feb-2008  yamt sync with head.
 1.13.16.5 21-Jan-2008  yamt sync with head
 1.13.16.4 27-Oct-2007  yamt sync with head.
 1.13.16.3 03-Sep-2007  yamt sync with head.
 1.13.16.2 30-Dec-2006  yamt sync with head.
 1.13.16.1 21-Jun-2006  yamt sync with head.
 1.14.2.2 18-Feb-2006  yamt sync with head.
 1.14.2.1 01-Feb-2006  yamt sync with head.
 1.15.4.1 22-Apr-2006  simonb Sync with head.
 1.15.2.1 09-Sep-2006  rpaulo sync with head
 1.18.2.1 03-Sep-2006  yamt sync with head.
 1.19.4.1 22-Oct-2006  yamt sync with head
 1.19.2.1 18-Nov-2006  ad Sync with head.
 1.20.12.1 03-Jun-2008  skrll Sync with netbsd-4.
 1.20.10.1 11-Jul-2007  mjf Sync with head.
 1.20.8.5 09-Oct-2007  ad Sync with head.
 1.20.8.4 20-Aug-2007  ad Sync with HEAD.
 1.20.8.3 15-Jul-2007  ad Sync with head.
 1.20.8.2 27-May-2007  ad Sync with head.
 1.20.8.1 10-Apr-2007  ad Sync with head.
 1.20.4.1 24-Mar-2007  yamt sync with head.
 1.20.2.1 22-Feb-2008  bouyer Pull up following revision(s) (requested by uwe in ticket #1075):
sys/arch/sh3/sh3/exception_vector.S: revision 1.21 - 1.30
sys/arch/sh3/sh3/genassym.cf: revision 1.11 - 1.12
sys/arch/sh3/sh3/pmap.c: revision 1.63
Implement fast path TLB miss handling. Walk the page table without
creating a trapframe, with exceptions disabled and using only BANK1
registers. If a valid pte is found, load it and return. Otherwise
create a trapframe and proceed to the full-blown C handler.
 1.21.2.2 29-Mar-2007  reinoud Pullup to -current
 1.21.2.1 18-Mar-2007  reinoud First attempt to bring branch in sync with HEAD
 1.28.4.2 03-Oct-2007  garbled Sync with HEAD
 1.28.4.1 22-May-2007  matt Update to HEAD.
 1.29.8.2 02-Oct-2007  joerg Sync with HEAD.
 1.29.8.1 03-Sep-2007  jmcneill Sync with HEAD.
 1.29.4.1 03-Sep-2007  skrll Sync with HEAD.
 1.30.4.1 06-Oct-2007  yamt sync with head.
 1.30.2.3 23-Mar-2008  matt sync with HEAD
 1.30.2.2 09-Jan-2008  matt sync with HEAD
 1.30.2.1 06-Nov-2007  matt sync with HEAD
 1.33.8.1 02-Jan-2008  bouyer Sync with HEAD
 1.33.4.1 26-Dec-2007  ad Sync with head.
 1.33.2.1 18-Feb-2008  mjf Sync with HEAD.
 1.35.6.4 17-Jan-2009  mjf Sync with HEAD.
 1.35.6.3 29-Jun-2008  mjf Sync with HEAD.
 1.35.6.2 02-Jun-2008  mjf Sync with HEAD.
 1.35.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.35.2.1 24-Mar-2008  keiichi sync with head.
 1.37.4.2 04-May-2009  yamt sync with head.
 1.37.4.1 16-May-2008  yamt sync with head.
 1.37.2.2 17-Jun-2008  yamt sync with head.
 1.37.2.1 18-May-2008  yamt sync with head.
 1.38.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.42.6.2 03-Mar-2009  skrll Sync with HEAD.
 1.42.6.1 19-Jan-2009  skrll Sync with HEAD.
 1.42.4.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.45.6.1 05-Mar-2011  rmind sync with head
 1.46.4.1 08-Feb-2011  bouyer Sync with HEAD
 1.46.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.49.36.1 04-Nov-2016  pgoyette Sync with HEAD
 1.49.32.1 05-Dec-2016  skrll Sync with HEAD
 1.49.14.1 03-Dec-2017  jdolecek update from HEAD
 1.50.16.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.51.12.1 01-Aug-2021  thorpej Sync with HEAD.
 1.21 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.20 14-Jan-2011  rmind branches: 1.20.60;
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.19 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.18 10-Dec-2009  rmind branches: 1.18.4;
Rename L_ADDR to L_PCB and amend some comments accordingly.
 1.17 01-Jun-2008  uwe Add GBR register to switchframe.

While here, reorder switchframe so that we can shave off a few
instructions when restoring it (group stack registers at the end, make
sure that last and first registers are safe to load/store in delay
slots).
 1.16 01-Jun-2008  uwe Add GBR register to trapframe.
 1.15 30-Apr-2008  martin branches: 1.15.2;
Convert TNF licenses to new 2 clause variant
 1.14 22-Mar-2008  uwe branches: 1.14.2; 1.14.4;
Revert interrupt stack changes. There are some issues and, at least
in the current form, they complicate implementation of fast software
interrupts. I'd rather get fast softints in now and may be revisit
interrupt stack later.
 1.13 17-Oct-2007  garbled branches: 1.13.16;
Merge the ppcoea-renovation branch to HEAD.

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

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

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.12 18-May-2007  uwe branches: 1.12.10;
Implement fast path TLB miss handling. Walk the page table without
creating a trapframe, with exceptions disabled and using only BANK1
registers. If a valid pte is found, load it and return. Otherwise
create a trapframe and proceed to the full-blown C handler.
 1.11 24-Mar-2007  uwe branches: 1.11.4;
G/c unused defines/includes.
 1.10 11-Dec-2005  christos branches: 1.10.24; 1.10.26; 1.10.30; 1.10.32; 1.10.34; 1.10.36;
merge ktrace-lwp.
 1.9 18-Jan-2004  uwe branches: 1.9.16;
G/c symbols related to structs proc and mdproc.
 1.8 20-Mar-2003  tsutsui branches: 1.8.2;
Rewrite user space access functions which use gcc's "labels as values"
extension in asm to avoid unexpected code omission during optimization
which causes wrong return value on faults.
 1.7 18-Jan-2003  thorpej Merge the nathanw_sa branch.
 1.6 23-Jun-2002  thorpej When delivering a signal, don't push the signum, code, and context pointer,
or handler onto the stack. Instead, just stuff them into the correct
argument registers (handler is a "4th arg").
 1.5 09-May-2002  uch branches: 1.5.2; 1.5.6;
adapted to pmap and exception code changes.
 1.4 28-Mar-2002  uch add uvmexp.intrs++
 1.3 24-Mar-2002  uch Rework interrupt code.
+ Fully utilize SH SR.I[0:3] interrupt level.
+ software interrupt is emulated by TMU1, 2 one shot interrupt.
+ implement generic soft interrupts.
+ implement clockframe correctly.
 1.2 17-Mar-2002  uch kernel stack fix. old code simply P3 address converted to P1, it
caused memory destruction when kernel stack grow over 1 page. new
code use P3 address for kernel stack. but for the sake of debug, P1
kernel stack mode remain.
 1.1 24-Feb-2002  uch branches: 1.1.2; 1.1.8;
Move common exception vector and scheduler code to
sh3/sh3/exception_vector.S and sh3/sh3/locore_subr.S. exception
vectors are installed by sh_cpu_init(). machine/locore.S contains
kernel entry, interrupt handler, and some MD code.
 1.1.8.4 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.1.8.3 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.1.8.2 16-Mar-2002  jdolecek Catch up with -current.
 1.1.8.1 24-Feb-2002  jdolecek file genassym.cf was added on branch kqueue on 2002-03-16 15:59:41 +0000
 1.1.2.3 20-Jun-2002  nathanw Catch up to -current.
 1.1.2.2 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.1.2.1 28-Feb-2002  nathanw Catch up to -current.
 1.5.6.4 01-Aug-2002  nathanw Catch up to -current.
 1.5.6.3 05-Jul-2002  thorpej When delivering an upcall, invoke the upcall directly, using the
trampoline only to exit if the upcall returns.
 1.5.6.2 21-Jun-2002  thorpej Add support for scheduler activations on SuperH. Boots multi-user
on Dreamcast (SH4) with stock userland.
 1.5.6.1 09-May-2002  thorpej file genassym.cf was added on branch nathanw_sa on 2002-06-21 21:26:31 +0000
 1.5.2.1 17-Jul-2002  gehenna catch up 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.9.16.2 24-Mar-2008  yamt sync with head.
 1.9.16.1 03-Sep-2007  yamt sync with head.
 1.10.36.1 03-Jun-2008  skrll Sync with netbsd-4.
 1.10.34.1 29-Mar-2007  reinoud Pullup to -current
 1.10.32.1 11-Jul-2007  mjf Sync with head.
 1.10.30.2 27-May-2007  ad Sync with head.
 1.10.30.1 10-Apr-2007  ad Sync with head.
 1.10.26.1 15-Apr-2007  yamt sync with head.
 1.10.24.1 22-Feb-2008  bouyer Pull up following revision(s) (requested by uwe in ticket #1075):
sys/arch/sh3/sh3/exception_vector.S: revision 1.21 - 1.30
sys/arch/sh3/sh3/genassym.cf: revision 1.11 - 1.12
sys/arch/sh3/sh3/pmap.c: revision 1.63
Implement fast path TLB miss handling. Walk the page table without
creating a trapframe, with exceptions disabled and using only BANK1
registers. If a valid pte is found, load it and return. Otherwise
create a trapframe and proceed to the full-blown C handler.
 1.11.4.1 22-May-2007  matt Update to HEAD.
 1.12.10.1 06-Nov-2007  matt sync with HEAD
 1.13.16.2 02-Jun-2008  mjf Sync with HEAD.
 1.13.16.1 03-Apr-2008  mjf Sync with HEAD.
 1.14.4.3 11-Mar-2010  yamt sync with head
 1.14.4.2 04-May-2009  yamt sync with head.
 1.14.4.1 16-May-2008  yamt sync with head.
 1.14.2.2 04-Jun-2008  yamt sync with head
 1.14.2.1 18-May-2008  yamt sync with head.
 1.15.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.18.4.1 05-Mar-2011  rmind sync with head
 1.20.60.1 10-Jun-2019  christos Sync with HEAD
 1.11 02-Feb-2008  uwe Rename in_cksum.S to cpu_in_cksum.S as is to preserve original code in
the new file history.
 1.10 11-Apr-2006  uwe branches: 1.10.38; 1.10.44;
Fix typo in comment in previous.
 1.9 11-Apr-2006  uwe Cosmetic. Same object code generated.
 1.8 11-Apr-2006  uwe Shave off few instructions by replacing mov src, dst; swap.w dst, dst;
with swap.w src, dst in REDUCE.
 1.7 11-Apr-2006  uwe Shave off few instructions by replacing mov #imm, reg; sub reg, dst
with add #-imm, dst
 1.6 22-Jan-2006  uwe branches: 1.6.2; 1.6.4; 1.6.6; 1.6.8; 1.6.10;
Use bsr instead of mova+jsr.
 1.5 22-Jan-2006  uwe LINTSTUBs.
 1.4 16-Oct-2001  msaitoh branches: 1.4.14; 1.4.36; 1.4.48;
s/BYTE_ORDER/_BYTE_ORDER/g
 1.3 14-Feb-2001  msaitoh branches: 1.3.4;
_C_LABEL()
 1.2 22-Feb-2000  msaitoh branches: 1.2.4; 1.2.6;
Fix the bug which cause invalid slot exception under SH4.
This exception doesn't occurs under SH3
 1.1 14-Jan-2000  msaitoh in_cksum.S (bi-endian)
 1.2.6.3 12-Mar-2001  bouyer Sync with HEAD.
 1.2.6.2 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.2.6.1 22-Feb-2000  bouyer file in_cksum.S was added on branch thorpej_scsipi on 2000-11-20 20:24:32 +0000
 1.2.4.1 08-Oct-2001  he Pull up revision 1.3 (requested by msaitoh):
Add missing _C_LABEL().
 1.3.4.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.4.48.1 01-Feb-2006  yamt sync with head.
 1.4.36.2 04-Feb-2008  yamt sync with head.
 1.4.36.1 21-Jun-2006  yamt sync with head.
 1.4.14.2 16-Oct-2001  msaitoh s/BYTE_ORDER/_BYTE_ORDER/g
 1.4.14.1 16-Oct-2001  msaitoh file in_cksum.S was added on branch nathanw_sa on 2001-10-16 02:07:47 +0000
 1.6.10.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.6.8.1 19-Apr-2006  elad sync with head - hopefully this will work
 1.6.6.1 24-May-2006  yamt sync with head.
 1.6.4.1 22-Apr-2006  simonb Sync with head.
 1.6.2.1 09-Sep-2006  rpaulo sync with head
 1.10.44.1 18-Feb-2008  mjf Sync with HEAD.
 1.10.38.1 23-Mar-2008  matt sync with HEAD
 1.2 10-Aug-2001  msaitoh branches: 1.2.14;
byebye
 1.1 13-Sep-1999  itojun branches: 1.1.16;
Merge in NetBSD/sh3 from cvs.kame.net repository.

Tree structure:
- sys/arch/sh3: sh3 generic code
As commented, in-chip device drivers are put into sys/arch/sh3/dev.
- sys/arch/evbsh3: sh3 evaluation boards (pure sh3 CPU, no fancy external HW)
- sys/arch/mmeye: Brains mmEye, www.brains.co.jp
MI source code includes couple of #ifdef for sh3-coff support.
(sh3 uses coff or elf)

Needs some more improvements, especialy in sys/arch/sh3/conf/files.sh3,
to compile the tree (due to last minute tree structure change).
 1.1.16.1 25-Aug-2001  thorpej Merge Aug 24 -current into the kqueue branch.
 1.2.14.2 10-Aug-2001  msaitoh byebye
 1.2.14.1 10-Aug-2001  msaitoh file in_cksum.c was added on branch nathanw_sa on 2001-08-10 18:55:09 +0000
 1.30 20-Dec-2023  thorpej Remove unnecessary <sys/malloc.h>.
 1.29 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.28 30-Apr-2009  nonaka branches: 1.28.4;
Support SH7706
 1.27 28-Apr-2008  martin branches: 1.27.14;
Remove clause 3 and 4 from TNF licenses
 1.26 23-Mar-2008  uwe branches: 1.26.2; 1.26.4;
G/c old softint code.
 1.25 23-Mar-2008  uwe intc_intr_enable/disable: TMU3 and TMU4 are handled by INTPRI00 &co.
Correctly propagate requests to enable/disable their interrupts.
 1.24 22-Mar-2008  uwe Revert interrupt stack changes. There are some issues and, at least
in the current form, they complicate implementation of fast software
interrupts. I'd rather get fast softints in now and may be revisit
interrupt stack later.
 1.23 07-Jan-2008  uwe branches: 1.23.6;
Add endif comment for __HAVE_FAST_SOFTINTS.
 1.22 07-Jan-2008  uwe cpu_intr_p - we can simply check if we are running on the interrupt stack.
 1.21 03-Dec-2007  ad branches: 1.21.6;
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.20 10-Oct-2006  uwe branches: 1.20.8; 1.20.26; 1.20.28; 1.20.34;
Don't call spl*() in setsoft(), as softintr_schedule() already calls
setsoft() inside _cpu_intr_suspend().
 1.19 24-Sep-2006  tsutsui Add timecounter support for SH3 ports. From gdamore on port-sh3,
with several minor fixes by me.

Previously sh3 ports use two timers (TMU1 and TMU2) as oneshot timer
to cause real hardware interrupts by softintr(9), but now softintr(9)
uses only TMU1 and TMU2 is configured as freerunning counter for
timecounter(9).

Tested on my dreamcast.
 1.18 25-Jan-2006  uwe branches: 1.18.18; 1.18.20;
Wrap sh3 and sh4 parts into respective ifdefs.
Declare local functions static.
ANSI'ify functions without arguments.
 1.17 11-Dec-2005  christos branches: 1.17.2;
merge ktrace-lwp.
 1.16 16-Aug-2005  nonaka Added SH7751{,R} integrated PCI controller support.
 1.15 03-Jul-2005  uwe branches: 1.15.2;
Add SH_INTEVT_WDT_ITI in intc_intr_priority.
 1.14 29-Jun-2005  christos additions from nonaka's landisk port.
 1.13 25-Mar-2004  uwe intc_intr_priority: map DMAC and IRDA interrupts.
 1.12 20-Nov-2003  uwe In intc_intr_priority() don't panic if the evtcode is not one of
those, that have their priority set in IPR registers, e.g. IRL
interrupts on Dreamcast. Reported by Christian Groessler.
 1.11 04-Nov-2003  uwe Redo a quick hack for intc_intr_disable() and intc_intr_enable() to have
a saner interface/semantic.
 1.10 01-Nov-2003  uwe In intc_intr_priority init iprreg to pacify gcc.
 1.9 18-Oct-2003  uwe Make intc_intr_priority() return old level. While here, make the code
more compact by factoring out register update to happen in one place,
outside the switch statements.

Add intc_intr_disable() and intc_intr_enable().
 1.8 08-Oct-2003  uwe Add IPR mappings for remaining sh7709 IRQx.
While here, fix couple of typos.
 1.7 08-Aug-2003  uwe Add more sh7709 interrupt sources. Split sh3 and sh4 specific
switches because of conflicts in exception codes.
 1.6 15-Jul-2003  lukem __KERNEL_RCSID()
 1.5 10-Nov-2002  tsutsui branches: 1.5.6;
Make sure to stop timer count before writing timer counter registers
in tmu[12]_oneshot(). Otherwise sometimes interrupts would be lost.
 1.4 08-Nov-2002  tsutsui Add _reg_bset_[124]() and _reg_bclr_[124]() macro for
SH embeded device registers.
 1.3 27-Sep-2002  provos remove trailing \n in panic(). approved perry.
 1.2 28-Apr-2002  uch branches: 1.2.6; 1.2.8;
Use "#define<tab>", white space nits.
 1.1 24-Mar-2002  uch branches: 1.1.2;
Rework interrupt code.
+ Fully utilize SH SR.I[0:3] interrupt level.
+ software interrupt is emulated by TMU1, 2 one shot interrupt.
+ implement generic soft interrupts.
+ implement clockframe correctly.
 1.1.2.2 20-Jun-2002  nathanw Catch up to -current.
 1.1.2.1 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.2.8.3 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.2.8.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.2.8.1 28-Apr-2002  jdolecek file interrupt.c was added on branch kqueue on 2002-06-23 17:40:51 +0000
 1.2.6.3 11-Nov-2002  nathanw Catch up to -current
 1.2.6.2 18-Oct-2002  nathanw Catch up to -current.
 1.2.6.1 28-Apr-2002  nathanw file interrupt.c was added on branch nathanw_sa on 2002-10-18 02:39:44 +0000
 1.5.6.4 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 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.15.2.5 24-Mar-2008  yamt sync with head.
 1.15.2.4 21-Jan-2008  yamt sync with head
 1.15.2.3 07-Dec-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.2.1 01-Feb-2006  yamt sync with head.
 1.18.20.1 22-Oct-2006  yamt sync with head
 1.18.18.1 18-Nov-2006  ad Sync with head.
 1.20.34.2 18-Feb-2008  mjf Sync with HEAD.
 1.20.34.1 08-Dec-2007  mjf Sync with HEAD.
 1.20.28.1 09-Jan-2008  matt sync with HEAD
 1.20.26.1 09-Dec-2007  jmcneill Sync with HEAD.
 1.20.8.1 03-Dec-2007  ad Sync with HEAD.
 1.21.6.1 08-Jan-2008  bouyer Sync with HEAD
 1.23.6.2 02-Jun-2008  mjf Sync with HEAD.
 1.23.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.26.4.2 04-May-2009  yamt sync with head.
 1.26.4.1 16-May-2008  yamt sync with head.
 1.26.2.1 18-May-2008  yamt sync with head.
 1.27.14.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.28.4.1 05-Mar-2011  rmind sync with head
 1.17 21-Nov-2009  rmind Use lwp_getpcb() on mips, powerpc and sh3, clean from struct user usage.
 1.16 18-Oct-2009  snj Move Matthias Pfaller's files to 2-clause license. OK matthias@.
 1.15 11-Jan-2009  cegger adaption for making kgdb_dev a dev_t
 1.14 28-Apr-2008  martin branches: 1.14.8;
Remove clause 3 and 4 from TNF licenses
 1.13 04-Mar-2006  uwe branches: 1.13.68; 1.13.70; 1.13.72;
s/u_intN_t/uintN_t/
 1.12 24-Dec-2005  perry branches: 1.12.4; 1.12.6;
__asm__ -> __asm
__const__ -> const
__inline__ -> inline
__volatile__ -> volatile
 1.11 11-Dec-2005  christos merge ktrace-lwp.
 1.10 15-Jul-2003  lukem branches: 1.10.16;
__KERNEL_RCSID()
 1.9 02-Apr-2003  thorpej branches: 1.9.2;
Use PAGE_SIZE rather than NBPG.
 1.8 09-May-2002  uch branches: 1.8.6;
adapted to pmap and exception code changes.
 1.7 28-Apr-2002  uch Use "#define<tab>", white space nits.
 1.6 02-Mar-2002  uch Initial support for KGDB on the sh3.
 1.5 19-Feb-2002  uch Clean up function declaration.
 1.4 12-Feb-2002  uch ANSIfy KNF.
 1.3 20-Nov-2001  lukem - pull in opt_kgdb.h where necessary
- replace opt_kgdb_machdep.h with opt_kgdb.h
- defparam opt_kgdb.h:
KGDB_DEV KGDB_DEVNAME KGDB_DEVADDR KGDB_DEVRATE KGDB_DEVMODE
- move from opt_ddbparam.h to opt_ddb.h:
DDB_FROMCONSOLE DDB_ONPANIC DDB_HISTORY_SIZE DDB_BREAK_CHAR SYMTAB_SPACE
- replace KGDBDEV with KGDB_DEV
- replace KGDBADDR with KGDB_DEVADDR
- replace KGDBMODE with KGDB_DEVMODE
- replace KGDBRATE with KGDB_DEVRATE
- use `9600' instead of `0x2580' for 9600 baud rate
- use correct quotes for options KGDB_DEVNAME="\"com\""
- use correct quotes for options KGDB_DEV="17*256+0"
- remove unnecessary dependancy on Makefile for kgdb_stub.o
- minor whitespace cleanup
 1.2 29-Jun-2000  mrg branches: 1.2.4;
remove include of <vm/vm.h>. <vm/vm.h> -> <uvm/uvm_extern.h>
 1.1 13-Sep-1999  itojun branches: 1.1.2;
Merge in NetBSD/sh3 from cvs.kame.net repository.

Tree structure:
- sys/arch/sh3: sh3 generic code
As commented, in-chip device drivers are put into sys/arch/sh3/dev.
- sys/arch/evbsh3: sh3 evaluation boards (pure sh3 CPU, no fancy external HW)
- sys/arch/mmeye: Brains mmEye, www.brains.co.jp
MI source code includes couple of #ifdef for sh3-coff support.
(sh3 uses coff or elf)

Needs some more improvements, especialy in sys/arch/sh3/conf/files.sh3,
to compile the tree (due to last minute tree structure change).
 1.1.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.2.4.3 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.2.4.2 16-Mar-2002  jdolecek Catch up with -current.
 1.2.4.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.8.6.2 09-May-2002  uch adapted to pmap and exception code changes.
 1.8.6.1 09-May-2002  uch file kgdb_machdep.c was added on branch nathanw_sa on 2002-05-09 12:29:17 +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.12.6.1 22-Apr-2006  simonb Sync with head.
 1.12.4.1 09-Sep-2006  rpaulo sync with head
 1.13.72.3 11-Mar-2010  yamt sync with head
 1.13.72.2 04-May-2009  yamt sync with head.
 1.13.72.1 16-May-2008  yamt sync with head.
 1.13.70.1 18-May-2008  yamt sync with head.
 1.13.68.2 17-Jan-2009  mjf Sync with HEAD.
 1.13.68.1 02-Jun-2008  mjf Sync with HEAD.
 1.14.8.1 19-Jan-2009  skrll Sync with HEAD.
 1.8 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.7 09-Apr-2019  uwe Fix previous. P is the final (relocated) address not just the offset.
 1.6 09-Apr-2019  uwe Support R_SH_REL32 (encountered in .eh_frame).
 1.5 03-Nov-2017  maxv branches: 1.5.4;
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.4 21-Nov-2008  uwe branches: 1.4.26;
G/c all reloc types except R_SH_DIR32 - which is the only one we
expect from a kmod that only have unresolved external symbols.
 1.3 28-Apr-2008  martin branches: 1.3.6; 1.3.8;
Remove clause 3 and 4 from TNF licenses
 1.2 26-Mar-2008  uwe branches: 1.2.2; 1.2.4;
Fix R_SH_DIR32 calculation (XXX: some other relocs look wrong too).
Sync icache after module is linked.
 1.1 04-Jan-2008  ad branches: 1.1.2; 1.1.4; 1.1.6; 1.1.8; 1.1.14;
More linker stuff
 1.1.14.3 17-Jan-2009  mjf Sync with HEAD.
 1.1.14.2 02-Jun-2008  mjf Sync with HEAD.
 1.1.14.1 03-Apr-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:05:01 +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:39:17 +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:48:49 +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:23 +0000
 1.2.4.2 04-May-2009  yamt sync with head.
 1.2.4.1 16-May-2008  yamt sync with head.
 1.2.2.1 18-May-2008  yamt sync with head.
 1.3.8.1 19-Jan-2009  skrll Sync with HEAD.
 1.3.6.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.4.26.1 03-Dec-2017  jdolecek update from HEAD
 1.5.4.1 10-Jun-2019  christos Sync with HEAD
 1.13 25-May-2008  chs enable profiling of assembly functions.
 1.12 10-Feb-2008  ad branches: 1.12.6; 1.12.8; 1.12.10; 1.12.12;
Add aliases for atomic_cas_foo_ni().
 1.11 29-Nov-2007  ad Pending review by uwe@:

- Make _lock_cas() do "compare and swap", not "compare and set".
- Add aliases for atomic_cas_ulong() and friends.
 1.10 17-Oct-2007  garbled branches: 1.10.2;
Merge the ppcoea-renovation branch to HEAD.

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

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

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.9 24-Sep-2007  uwe Do RAS check in sh_vector_interrupt, don't abuse ast() for that.
 1.8 14-Mar-2007  uwe branches: 1.8.6; 1.8.14; 1.8.16; 1.8.18;
More nano-optimizations to mutex stubs: rely on _lock_cas to preserve
things for us to shave off a few cycles.
 1.7 14-Mar-2007  uwe Tweak to shave off a few cycles.
 1.6 14-Mar-2007  uwe Convert _lock_cas to RAS. Check for restart in ast() on return from interrupt.
 1.5 14-Mar-2007  uwe Oops. Don't define stubs if LOCKDEBUG.
 1.4 14-Mar-2007  uwe LINTSTUB: include <sys/mutex.h> to make the lint stub lintable.
 1.3 14-Mar-2007  uwe Implement fast-path mutex_enter and mutex_exit stubs.
 1.2 23-Feb-2007  uwe branches: 1.2.2; 1.2.6; 1.2.8; 1.2.10;
Brute force _lock_cas() by disabling interrupts.
Need to redo it with RAS later.
 1.1 22-Feb-2007  uwe Add lock_stubs.S with fake _lock_cas - just to make the kernel compile
for now.
 1.2.10.1 11-Jul-2007  mjf Sync with head.
 1.2.8.3 03-Dec-2007  ad Sync with HEAD.
 1.2.8.2 09-Oct-2007  ad Sync with head.
 1.2.8.1 10-Apr-2007  ad Sync with head.
 1.2.6.3 24-Mar-2007  yamt sync with head.
 1.2.6.2 27-Feb-2007  yamt - sync with head.
- move sched_changepri back to kern_synch.c as it doesn't know PPQ anymore.
 1.2.6.1 23-Feb-2007  yamt file lock_stubs.S was added on branch yamt-idlelwp on 2007-02-27 16:53:00 +0000
 1.2.2.6 11-Feb-2008  yamt sync with head.
 1.2.2.5 07-Dec-2007  yamt sync with head
 1.2.2.4 27-Oct-2007  yamt sync with head.
 1.2.2.3 03-Sep-2007  yamt sync with head.
 1.2.2.2 26-Feb-2007  yamt sync with head.
 1.2.2.1 23-Feb-2007  yamt file lock_stubs.S was added on branch yamt-lazymbuf on 2007-02-26 09:08:08 +0000
 1.8.18.1 06-Oct-2007  yamt sync with head.
 1.8.16.3 23-Mar-2008  matt sync with HEAD
 1.8.16.2 09-Jan-2008  matt sync with HEAD
 1.8.16.1 06-Nov-2007  matt sync with HEAD
 1.8.14.2 03-Dec-2007  joerg Sync with HEAD.
 1.8.14.1 02-Oct-2007  joerg Sync with HEAD.
 1.8.6.1 03-Oct-2007  garbled Sync with HEAD
 1.10.2.2 18-Feb-2008  mjf Sync with HEAD.
 1.10.2.1 08-Dec-2007  mjf Sync with HEAD.
 1.12.12.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.12.10.1 04-May-2009  yamt sync with head.
 1.12.8.1 04-Jun-2008  yamt sync with head
 1.12.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.32 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.31 27-Nov-2009  rmind - Use uvm_lwp_setuarea() instead of directly setting address to lwp_t::l_addr.
- Replace most remaining uses of l_addr with uvm_lwp_getuarea() or lwp_getpcb().
- Amend assembly in ports where it accesses PCB via struct user.
- Rename L_ADDR to L_PCB in few places. Reduce sys/user.h inclusions.
 1.30 21-Nov-2009  rmind Use lwp_getpcb() on mips, powerpc and sh3, clean from struct user usage.
 1.29 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.28 23-Feb-2008  uwe branches: 1.28.2; 1.28.4;
Set curlwp and curpcb in cpu_switchto instead of cpu_switch_prepare.
We can now skip cpu_switch_prepare for the "fast" switch case (when
"returning" is true) which we will need for fast soft interrupts.
 1.27 15-Feb-2008  uwe branches: 1.27.2; 1.27.6;
G/c vestiges of curpute hack that was obsoleted by the fast TLB miss handler.
sh3_switch_setup() has nothing to do now.
 1.26 24-Oct-2007  ad branches: 1.26.2;
Make ras_lookup() lockless.
 1.25 17-Oct-2007  garbled Merge the ppcoea-renovation branch to HEAD.

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

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

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.24 01-Oct-2007  ad branches: 1.24.2;
Make want_resched a member of cpu_info.
 1.23 17-May-2007  yamt branches: 1.23.8; 1.23.10; 1.23.12;
merge yamt-idlelwp branch. asked by core@. some ports still needs work.

from doc/BRANCHES:

idle lwp, and some changes depending on it.

1. separate context switching and thread scheduling.
(cf. gmcgarry_ctxsw)
2. implement idle lwp.
3. clean up related MD/MI interfaces.
4. make scheduler(s) modular.
 1.22 17-Mar-2007  uwe branches: 1.22.4;
sh3_switch_setup: make md_upte[] map uarea pages in reverse order so
that mapping for the bottom of the stack (practically the only page we
ever touch) is found on earlier iterations through md_upte[] in the
tlb miss handler.
 1.21 16-Mar-2007  uwe Cosmetic changes in {sh3,sh4}_switch_setup to make them easier to read.
Same object code is generated.
 1.20 16-Mar-2007  uwe There's no sense in duplicating function prototype in preceding comments.
While here, make ANSI'fy idle() definition.
 1.19 12-Mar-2007  uwe branches: 1.19.2; 1.19.4;
Do cpu_exit with proper locking.

Rename assembly cpu_exit to cpu_do_exit and make a C version of
cpu_exit() to do proper locking. While here, g/c switch_exit entry
point and don't call lwp_exit2 from cpu_exit.
From ad@

Completes PR port-sh3/35971 - my Jornada now boots to multiuser with a
LOCKDEBUG kernel.
 1.18 12-Mar-2007  uwe Cosmetic. Group function declarations and variable definitions.
 1.17 11-Mar-2007  ad PR port-sh3/35971: Mutex error on SH3 DIAGNOSTIC kernels
 1.16 04-Mar-2007  tsutsui branches: 1.16.2;
Call uvm_pageidlezero() only if uvm.page_idle_zero is true.
 1.15 04-Mar-2007  christos Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.14 09-Feb-2007  ad branches: 1.14.2;
Merge newlock2 to head.
 1.13 04-Mar-2006  uwe branches: 1.13.14;
s/u_intN_t/uintN_t/
 1.12 23-Jan-2006  uwe branches: 1.12.2; 1.12.4;
Wrap sh3_switch_setup/sh4_switch_setup into the same ifdefs that are
used in vm_machdep.c at their invocation sites.
 1.11 21-Jan-2006  uwe Lintable no-ops for LOCKDEBUG macros.
 1.10 24-Dec-2005  perry branches: 1.10.2;
__asm__ -> __asm
__const__ -> const
__inline__ -> inline
__volatile__ -> volatile
 1.9 11-Dec-2005  christos merge ktrace-lwp.
 1.8 31-May-2005  uwe branches: 1.8.2;
Rename s/newlwp/nlwp/ parameter to cpu_switch_prepare() to avoid
shadowing a function of the same name. Rename oldlwp to match.
 1.7 16-Nov-2003  uwe Fix cpu_switchto() to correctly prepare new lwp before switching to it.
Fixes PR port-sh3/19956.

Big thanks to Christian Limpach <cl@> for pointing this out and
explaning what the fix is.
 1.6 05-Nov-2003  uwe Add closing parenthesis missed in previous.
 1.5 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.4 22-Oct-2003  uwe Don't compare a char to NULL.
 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 15-Jul-2003  lukem __KERNEL_RCSID()
 1.1 08-May-2003  christos branches: 1.1.2;
rename Locore.c -> locore_c.c so that we can compile on case insensitive
filesystems. (from John Gordon)
 1.1.2.4 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.1.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.1.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.1.2.1 03-Aug-2004  skrll Sync with HEAD
 1.8.2.5 27-Feb-2008  yamt sync with head.
 1.8.2.4 27-Oct-2007  yamt sync with head.
 1.8.2.3 03-Sep-2007  yamt sync with head.
 1.8.2.2 26-Feb-2007  yamt sync with head.
 1.8.2.1 21-Jun-2006  yamt sync with head.
 1.10.2.1 01-Feb-2006  yamt sync with head.
 1.12.4.1 22-Apr-2006  simonb Sync with head.
 1.12.2.1 09-Sep-2006  rpaulo sync with head
 1.13.14.1 01-Feb-2007  ad Get sh3 compiling.
 1.14.2.4 05-Apr-2007  uwe Setting curlwp is now responsibility of MD code.
 1.14.2.3 25-Mar-2007  uwe Adapt sh3 to yamt-idlelwp.
 1.14.2.2 24-Mar-2007  yamt sync with head.
 1.14.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.16.2.5 03-Dec-2007  ad Sync with HEAD.
 1.16.2.4 09-Oct-2007  ad Sync with head.
 1.16.2.3 27-May-2007  ad Sync with head.
 1.16.2.2 10-Apr-2007  ad Sync with head.
 1.16.2.1 13-Mar-2007  ad Sync with head.
 1.19.4.1 18-Mar-2007  reinoud First attempt to bring branch in sync with HEAD
 1.19.2.1 11-Jul-2007  mjf Sync with head.
 1.22.4.2 03-Oct-2007  garbled Sync with HEAD
 1.22.4.1 22-May-2007  matt Update to HEAD.
 1.23.12.1 06-Oct-2007  yamt sync with head.
 1.23.10.2 23-Mar-2008  matt sync with HEAD
 1.23.10.1 06-Nov-2007  matt sync with HEAD
 1.23.8.2 28-Oct-2007  joerg Sync with HEAD.
 1.23.8.1 02-Oct-2007  joerg Sync with HEAD.
 1.24.2.1 13-Nov-2007  bouyer Sync with HEAD
 1.26.2.1 18-Feb-2008  mjf Sync with HEAD.
 1.27.6.2 02-Jun-2008  mjf Sync with HEAD.
 1.27.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.27.2.1 24-Mar-2008  keiichi sync with head.
 1.28.4.2 11-Mar-2010  yamt sync with head
 1.28.4.1 16-May-2008  yamt sync with head.
 1.28.2.1 18-May-2008  yamt sync with head.
 1.61 15-Jul-2021  rin For cpu_switchto(), inherit PSL_IMASK field of SR between lwp's.

Otherwise, IPL is lost during context switch, which allows improper
interrupts when, e.g., spin mutexes are hold.

With this fix, full ATF is successfully completed on DIAGNOSTIC
kernel (with one KASSERT in uvm_map.c, which triggers kern/51254,
converted to printf).

Thanks uwe@ for review and suggesting optimization.

Also thanks ad@ for useful comment, and ryo@ for giving me reference
manuals of SH-4!
 1.60 03-Aug-2020  uwe branches: 1.60.6;
_cpu_exception_suspend - return old SR

In a typical use case we do a very short code sequence with PSL_BL set
and restore the old PSL_BL value with _cpu_exception_resume that does
the full read/mask/set dance. In reality we are just restoring SR to
its old state as no other modifications to SR can possibly happen. So
return old SR and let the caller restore it in one instruction.
 1.59 03-Aug-2020  uwe _cpu_exception_suspend, _cpu_exception_resume - cosmetics

Use PSL_BL instead of magic hex in comments. Use spaces between
operands. Same object code is generated.
 1.58 08-Jan-2020  skrll oldlwp is always non-NULL in cpu_switchto so remove the test for NULL.
 1.57 06-Apr-2019  thorpej branches: 1.57.6;
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.56 08-Feb-2018  dholland branches: 1.56.4;
Typos.
 1.55 15-Feb-2015  skrll port-sh3/49613: errno does not set by some systemcall at error case

Branch to correct point when error detected.
 1.54 01-Feb-2011  uwe branches: 1.54.10; 1.54.14; 1.54.30; 1.54.32;
cpu_setfunc() must use lwp_trampoline to arrange for the recycled lwp
to go through lwp_startup() the first time it's switched to.

This makes NetBSD-4.x SA binaries work on current. Tested with dig(1)
in NetBSD-4.x chroot on landisk.

Looks like this mistake of mine was picked up and replicated in
several other ports, sorry.

Reported by chuck@ in PR kern/44500
 1.53 20-Mar-2010  chs branches: 1.53.2; 1.53.4;
fix copy{in,out}{,str}() to return the error returned by uvm_fault().
fixes PR 41813.
 1.52 09-Jun-2009  uwe branches: 1.52.2; 1.52.4;
Fix logic error in copyinstr() when deciding whether to return EFAULT
or ENAMETOOLONG.

From OpenBSD revision 1.9 by miod@
 1.51 09-Jun-2009  uwe Spell "handler" correctly.
 1.50 13-Feb-2009  apb Use "defopt MODULAR" in sys/conf/files, and #include "opt_modular.h"
in all kernel sources that use the MODULAR option.
Proposed in tech-kern on 18 Jan 2009.
 1.49 22-Nov-2008  uwe branches: 1.49.4;
Provide COMPAT_16 sigcode for MODULAR kernels too (to avoid the
trouble of adding compat_16_locore.S just for these 20 bytes - at
least for now).
 1.48 01-Jun-2008  uwe branches: 1.48.4; 1.48.6; 1.48.8; 1.48.10;
Add GBR register to switchframe.

While here, reorder switchframe so that we can shave off a few
instructions when restoring it (group stack registers at the end, make
sure that last and first registers are safe to load/store in delay
slots).
 1.47 28-Apr-2008  martin branches: 1.47.2;
Remove clause 3 and 4 from TNF licenses
 1.46 23-Feb-2008  uwe branches: 1.46.2; 1.46.4;
Set curlwp and curpcb in cpu_switchto instead of cpu_switch_prepare.
We can now skip cpu_switch_prepare for the "fast" switch case (when
"returning" is true) which we will need for fast soft interrupts.
 1.45 23-Feb-2008  uwe Shave off a few instructions by using callee-save registers to cache
stuff. Profit from the fact that __EXCEPTION_BLOCK now preserves SR
and replace __EXCEPTION_UNBLOCK with just an "ldc" to restore SR.
 1.44 23-Feb-2008  uwe Misc cosmetic changes to cpu_switchto: use asm comments to have a few
more chars before we wrap, replace remaining ,<TAB> with ,<SPACE> in
operands, clarify a few comments. Note new "bool returning" argument
(not used yet as it's always false unless we have fast soft
interrupts). Same object code generated.
 1.43 15-Feb-2008  uwe branches: 1.43.2; 1.43.6;
sh4_switch_resume: Now that r2 is free use it to keep SH4_PTEH to
avoid re-fetching it uncached while running on P2.
 1.42 15-Feb-2008  uwe Prettify sh4_switch_resume - <TAB> between operands only makes the
code hard to read as any intdended "neatly lined up" effect is
destroyed by long label names anyway.

G/c unused SH4_ITLB_AA.

No functional change.
 1.41 15-Feb-2008  uwe Use dt instruction for the loop, free r2 we used as a counter.
 1.40 15-Feb-2008  uwe sh4_switch_resume: don't jump back to P1 b/c we are going to return
immediately after that anyway and our caller is in P1.

Besides we were not switching to P1 anyway, b/c mova is pc-relative so
without additional arithmetic we were still jumping to a P2 address.
 1.39 15-Feb-2008  uwe We don't need to/can't wire u-area if we use P1_STACK.

Not actually tested the P1_STACK case, but I guess it was never tested
on SH4 anyway (it would write garbage to TLB). It used to work on SH3
b/c "wiring" was done using curupte hack and that was just an
innocuous pointer update.
 1.38 15-Feb-2008  uwe G/c vestiges of curpute hack that was obsoleted by the fast TLB miss handler.
 1.37 17-Oct-2007  garbled branches: 1.37.2;
Merge the ppcoea-renovation branch to HEAD.

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

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

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.36 21-May-2007  tsutsui branches: 1.36.10;
Fix prototype of cpu_switchto(9) in LINTSTUB comment.
 1.35 17-May-2007  yamt merge yamt-idlelwp branch. asked by core@. some ports still needs work.

from doc/BRANCHES:

idle lwp, and some changes depending on it.

1. separate context switching and thread scheduling.
(cf. gmcgarry_ctxsw)
2. implement idle lwp.
3. clean up related MD/MI interfaces.
4. make scheduler(s) modular.
 1.34 16-Mar-2007  uwe branches: 1.34.4;
Comment proc_trampoline properly.
 1.33 16-Mar-2007  uwe L_MD_PCB and L_MD_UPTE are small enough to be used as immediate values.
 1.32 12-Mar-2007  uwe branches: 1.32.2; 1.32.4;
Do cpu_exit with proper locking.

Rename assembly cpu_exit to cpu_do_exit and make a C version of
cpu_exit() to do proper locking. While here, g/c switch_exit entry
point and don't call lwp_exit2 from cpu_exit.
From ad@

Completes PR port-sh3/35971 - my Jornada now boots to multiuser with a
LOCKDEBUG kernel.
 1.31 11-Mar-2007  uwe Factor out code to save processor state to pcb->pcb_sf switchframe
into a macro. While here, clarify l->l_md.md_pcb->pcb_sf
vs. l->l_md.md_pcb confusion with proper naming and some comments.
Idea from OpenBSD.
 1.30 16-Nov-2006  uwe branches: 1.30.2; 1.30.4; 1.30.8; 1.30.14;
Enforce correct userspace bounds in copy{in,out}str().

From Miod Vallat <miod@openbsd.org>.
 1.29 23-Oct-2006  uwe fu* function should read bytes/shorts as unsigned, so s/exts/extu/
 1.28 23-Jan-2006  uwe branches: 1.28.18; 1.28.20;
Don't waste rts delay slots in sh3_switch_resume and savectx.
longjmp needs to arrange for a call to setjmp to return 1.
 1.27 23-Jan-2006  uwe LINTSTUB: include <sh3/locore.h> - to check *_switch_resume prototypes.
 1.26 23-Jan-2006  uwe Provide sh3_switch_resume/sh4_switch_resume with own copies of L_MD_UPTE.
Move SET_ENTRY_SIZE(sh4_switch_resume) under ifdef SH4.
 1.25 23-Jan-2006  uwe In onfault handlers of copyinstr and copyoutstr move EFAULT to the
correct register. This code worked correctly only because the right
register already contained EFAULT.
 1.24 23-Jan-2006  uwe LINTSTUBs. Provide .size (except for the switch maze of jumps).
 1.23 23-Jan-2006  uwe Fix few labels with dots in the middle that I've missed in previous.
 1.22 23-Jan-2006  uwe Use cpp-safe labels.
 1.21 11-Dec-2005  christos branches: 1.21.2;
merge ktrace-lwp.
 1.20 26-Mar-2004  drochner branches: 1.20.16;
fix references to the syscall formerly known as SYS___sigreturn14
 1.19 18-Jan-2004  uwe Implement proper switch_exit in assembler. Since cpu_switch is
reduced to just a call to switch_exit, g/c the C version and add a one
instruction assembler version that just falls through to switch_exit.

Addresses PR#24007 by Jaromir Dolecek <jdolecek@netbsd> and makes sh3
kernels work again after his elimination of the reaper. Tested on hpcsh.
 1.18 18-Jan-2004  uwe s/proc/lwp/ in comments.
 1.17 24-Nov-2003  uwe Old sigcode (to be copied out to the bottom of the user stack) is only
necessary for COMPAT_16.
 1.16 24-Nov-2003  uwe Cosmetic: u_int32_t -> uint32_t in comments, trim trailing whitespace.
Add __KERNEL_RCSID.
 1.15 16-Nov-2003  uwe Fix cpu_switchto() to correctly prepare new lwp before switching to it.
Fixes PR port-sh3/19956.

Big thanks to Christian Limpach <cl@> for pointing this out and
explaning what the fix is.
 1.14 20-Mar-2003  tsutsui branches: 1.14.2;
Rewrite user space access functions which use gcc's "labels as values"
extension in asm to avoid unexpected code omission during optimization
which causes wrong return value on faults.
 1.13 18-Jan-2003  thorpej Merge the nathanw_sa branch.
 1.12 23-Jun-2002  thorpej When delivering a signal, arrange for the handler to be invoked
directly. The trampoline is now used only for the return, and
makes it another 2 instructions shorter.
 1.11 23-Jun-2002  thorpej When delivering a signal, don't push the signum, code, and context pointer,
or handler onto the stack. Instead, just stuff them into the correct
argument registers (handler is a "4th arg").
 1.10 09-May-2002  uch branches: 1.10.2; 1.10.6;
new pmap designed for SH3/SH4.
 1.9 28-Apr-2002  uch Use "#define<tab>", white space nits.
 1.8 22-Apr-2002  uch make these compile with gcc -O0
 1.7 24-Mar-2002  uch Rework interrupt code.
+ Fully utilize SH SR.I[0:3] interrupt level.
+ software interrupt is emulated by TMU1, 2 one shot interrupt.
+ implement generic soft interrupts.
+ implement clockframe correctly.
 1.6 17-Mar-2002  uch kernel stack fix. old code simply P3 address converted to P1, it
caused memory destruction when kernel stack grow over 1 page. new
code use P3 address for kernel stack. but for the sake of debug, P1
kernel stack mode remain.
 1.5 03-Mar-2002  uch branches: 1.5.4;
remove temporal debug code.
 1.4 28-Feb-2002  uch branches: 1.4.2;
Change foo_r0_r1 macro in sh3/locore.h to foo(Rn, Rm)
 1.3 24-Feb-2002  uch Move common exception vector and scheduler code to
sh3/sh3/exception_vector.S and sh3/sh3/locore_subr.S. exception
vectors are installed by sh_cpu_init(). machine/locore.S contains
kernel entry, interrupt handler, and some MD code.
 1.2 22-Feb-2002  uch New NetBSD/sh3 clock framework.
+ hardclock source is moved from TMU1 to TMU0.
+ SH3/SH4 common kernel support.
+ PCLOCK estimation.
+ remove duplicated code.
 1.1 19-Feb-2002  uch Clean up functions
disable_intr, enable_intr, disable_interrupt, enable_interrupt,
disable_ext_intr, enable_ext_intr.
New functions:
for external interrupt:
_cpu_intr_suspend and _cpu_intr_resume.
for exception:
_cpu_exception_suspend and _cpu_exception_resume.
 1.4.2.3 20-Jun-2002  nathanw Catch up to -current.
 1.4.2.2 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.4.2.1 28-Feb-2002  nathanw Catch up to -current.
 1.5.4.4 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.5.4.3 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.5.4.2 16-Mar-2002  jdolecek Catch up with -current.
 1.5.4.1 03-Mar-2002  jdolecek file locore_subr.S was added on branch kqueue on 2002-03-16 15:59:42 +0000
 1.10.6.6 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.10.6.5 10-Aug-2002  thorpej Garbage-collect upcallcode.
 1.10.6.4 01-Aug-2002  nathanw Catch up to -current.
 1.10.6.3 05-Jul-2002  thorpej When delivering an upcall, invoke the upcall directly, using the
trampoline only to exit if the upcall returns.
 1.10.6.2 21-Jun-2002  thorpej Add support for scheduler activations on SuperH. Boots multi-user
on Dreamcast (SH4) with stock userland.
 1.10.6.1 09-May-2002  thorpej file locore_subr.S was added on branch nathanw_sa on 2002-06-21 21:26:32 +0000
 1.10.2.1 17-Jul-2002  gehenna catch up with -current.
 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.20.16.4 27-Feb-2008  yamt sync with head.
 1.20.16.3 03-Sep-2007  yamt sync with head.
 1.20.16.2 30-Dec-2006  yamt sync with head.
 1.20.16.1 21-Jun-2006  yamt sync with head.
 1.21.2.1 01-Feb-2006  yamt sync with head.
 1.28.20.1 10-Dec-2006  yamt sync with head.
 1.28.18.1 18-Nov-2006  ad Sync with head.
 1.30.14.1 10-Jun-2009  bouyer Pull up following revision(s) (requested by uwe in ticket #1323):
sys/arch/sh3/sh3/locore_subr.S: revision 1.52
Fix logic error in copyinstr() when deciding whether to return EFAULT
or ENAMETOOLONG.
From OpenBSD revision 1.9 by miod@
 1.30.8.3 27-May-2007  ad Sync with head.
 1.30.8.2 10-Apr-2007  ad Sync with head.
 1.30.8.1 13-Mar-2007  ad Sync with head.
 1.30.4.3 25-Mar-2007  uwe Adapt sh3 to yamt-idlelwp.
 1.30.4.2 24-Mar-2007  yamt sync with head.
 1.30.4.1 12-Mar-2007  rmind Sync with HEAD.
 1.30.2.1 10-Jun-2009  bouyer Pull up following revision(s) (requested by uwe in ticket #1323):
sys/arch/sh3/sh3/locore_subr.S: revision 1.52
Fix logic error in copyinstr() when deciding whether to return EFAULT
or ENAMETOOLONG.
From OpenBSD revision 1.9 by miod@
 1.32.4.1 18-Mar-2007  reinoud First attempt to bring branch in sync with HEAD
 1.32.2.1 11-Jul-2007  mjf Sync with head.
 1.34.4.1 22-May-2007  matt Update to HEAD.
 1.36.10.2 23-Mar-2008  matt sync with HEAD
 1.36.10.1 06-Nov-2007  matt sync with HEAD
 1.37.2.1 18-Feb-2008  mjf Sync with HEAD.
 1.43.6.3 17-Jan-2009  mjf Sync with HEAD.
 1.43.6.2 02-Jun-2008  mjf Sync with HEAD.
 1.43.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.43.2.1 24-Mar-2008  keiichi sync with head.
 1.46.4.4 11-Aug-2010  yamt sync with head.
 1.46.4.3 20-Jun-2009  yamt sync with head
 1.46.4.2 04-May-2009  yamt sync with head.
 1.46.4.1 16-May-2008  yamt sync with head.
 1.46.2.2 04-Jun-2008  yamt sync with head
 1.46.2.1 18-May-2008  yamt sync with head.
 1.47.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.48.10.1 10-Jun-2009  bouyer branches: 1.48.10.1.2;
Pull up following revision(s) (requested by uwe in ticket #802):
sys/arch/sh3/sh3/locore_subr.S: revision 1.52
Fix logic error in copyinstr() when deciding whether to return EFAULT
or ENAMETOOLONG.
From OpenBSD revision 1.9 by miod@
 1.48.10.1.2.1 21-Apr-2010  matt sync to netbsd-5
 1.48.8.1 10-Jun-2009  bouyer Pull up following revision(s) (requested by uwe in ticket #802):
sys/arch/sh3/sh3/locore_subr.S: revision 1.52
Fix logic error in copyinstr() when deciding whether to return EFAULT
or ENAMETOOLONG.
From OpenBSD revision 1.9 by miod@
 1.48.6.2 03-Mar-2009  skrll Sync with HEAD.
 1.48.6.1 19-Jan-2009  skrll Sync with HEAD.
 1.48.4.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.49.4.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.52.4.2 05-Mar-2011  rmind sync with head
 1.52.4.1 30-May-2010  rmind sync with head
 1.52.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.53.4.1 08-Feb-2011  bouyer Sync with HEAD
 1.53.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.54.32.1 06-Apr-2015  skrll Sync with HEAD
 1.54.30.1 17-Feb-2015  martin Pull up following revision(s) (requested by skrll in ticket #524):
sys/arch/sh3/sh3/locore_subr.S: revision 1.55
port-sh3/49613: errno does not set by some systemcall at error case
Branch to correct point when error detected.
 1.54.14.1 03-Dec-2017  jdolecek update from HEAD
 1.54.10.1 16-Feb-2015  martin Pull up following revision(s) (requested by skrll in ticket #1254):
sys/arch/sh3/sh3/locore_subr.S: revision 1.55
port-sh3/49613: errno does not set by some systemcall at error case
Branch to correct point when error detected.
 1.56.4.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.56.4.1 10-Jun-2019  christos Sync with HEAD
 1.57.6.1 17-Jan-2020  ad Sync with head.
 1.60.6.1 01-Aug-2021  thorpej Sync with HEAD.
 1.3 06-Feb-2001  uch move machine-port specific file to machine directory.
for evbsh3, mmeye and dreamcast, use MI md_root.c
 1.2 13-Sep-1999  msaitoh branches: 1.2.2;
remove mainbus pseudo floppy drive
 1.1 13-Sep-1999  itojun Merge in NetBSD/sh3 from cvs.kame.net repository.

Tree structure:
- sys/arch/sh3: sh3 generic code
As commented, in-chip device drivers are put into sys/arch/sh3/dev.
- sys/arch/evbsh3: sh3 evaluation boards (pure sh3 CPU, no fancy external HW)
- sys/arch/mmeye: Brains mmEye, www.brains.co.jp
MI source code includes couple of #ifdef for sh3-coff support.
(sh3 uses coff or elf)

Needs some more improvements, especialy in sys/arch/sh3/conf/files.sh3,
to compile the tree (due to last minute tree structure change).
 1.2.2.1 11-Feb-2001  bouyer Sync with HEAD.
 1.4 06-Feb-2001  uch move machine-port specific file to machine directory.
for evbsh3, mmeye and dreamcast, use MI md_root.c
 1.3 17-Jan-2001  itojun the kernel for SH3-based WinCE machines (little endian), by uch.
MACHINE=hpcsh, MACHINE_CPU=sh3el.

bootloader: ftp://f77.nop.or.jp/users/uch/hpcboot/
original patch: ftp://f77.nop.or.jp/users/uch/hpcsh/

sys/sh3/sh3/md_root.c: add #ifdef MEMORY_DISK_DYNAMIC
 1.2 24-Feb-2000  msaitoh variable start address of the main memory (now we can use
the area 2 as main memory with "options IOM_RAM_BEGIN=0x88000000")
 1.1 13-Sep-1999  itojun branches: 1.1.2;
Merge in NetBSD/sh3 from cvs.kame.net repository.

Tree structure:
- sys/arch/sh3: sh3 generic code
As commented, in-chip device drivers are put into sys/arch/sh3/dev.
- sys/arch/evbsh3: sh3 evaluation boards (pure sh3 CPU, no fancy external HW)
- sys/arch/mmeye: Brains mmEye, www.brains.co.jp
MI source code includes couple of #ifdef for sh3-coff support.
(sh3 uses coff or elf)

Needs some more improvements, especialy in sys/arch/sh3/conf/files.sh3,
to compile the tree (due to last minute tree structure change).
 1.1.2.3 11-Feb-2001  bouyer Sync with HEAD.
 1.1.2.2 18-Jan-2001  bouyer Sync with head (for UBC+NFS fixes, mostly).
 1.1.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.30 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.29 08-Feb-2011  rmind branches: 1.29.2;
Remove clause 3 (UCB advertising clause) from the University of Utah
copyright. Confirmed by Mike Hibler, mike at cs.utah.edu - thanks!
Also, merge UCB and Utah copyright texts back into one, as they
originally were.

Extra verification by snj@.
 1.28 10-Nov-2010  uebayasi branches: 1.28.2; 1.28.4;
Use more VM_PHYSMEM_*() accessors. No functional changes.
 1.27 06-Nov-2010  uebayasi Machine dependent code is considered as part of UVM. Include
internal API header.
 1.26 04-Mar-2007  christos branches: 1.26.40; 1.26.64; 1.26.66;
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 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.23 26-Dec-2006  elad branches: 1.23.2;
Make machdep scope architecture-agnostic by removing all arch-specific
requests and centralizing them all. The result is that some of these
are not used on some architectures, but the documentation was updated
to reflect that.
 1.22 22-Dec-2006  elad Add requests indicating access to unmanaged memory for arm, pc532, powerpc,
sh3, sh5, and vax, and use them instead of KAUTH_GENERIC_ISSUSER.

Update documentation and example secmodel code.
 1.21 23-Jul-2006  ad branches: 1.21.4; 1.21.8;
Use the LWP cached credentials where sane.
 1.20 14-May-2006  elad integrate kauth.
 1.19 11-Dec-2005  christos branches: 1.19.4; 1.19.6; 1.19.8; 1.19.10; 1.19.12;
merge ktrace-lwp.
 1.18 24-Mar-2004  wiz branches: 1.18.16;
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.17 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.16 15-Jul-2003  lukem __KERNEL_RCSID()
 1.15 14-Jun-2003  tsutsui branches: 1.15.2;
mmap(2) function on sh3 should return page number, not physical address.
 1.14 02-Apr-2003  thorpej Use PAGE_SIZE rather than NBPG.
 1.13 23-Oct-2002  jdolecek merge kqueue branch into -current

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

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

based on work done by Jonathan Lemon for FreeBSD
initial NetBSD port done by Luke Mewburn and Jason Thorpe
 1.12 06-Sep-2002  gehenna Merge the gehenna-devsw branch into the trunk.

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

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

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

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

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

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

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

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

- In compile time, device major numbers list is packed into the kernel and
the LKM framework will refer it to assign device major number dynamically.
 1.11 09-May-2002  uch branches: 1.11.2; 1.11.6;
suitable for SH3/SH4 memory architecture.
support non-contiguos memory banks.
 1.10 07-May-2002  thorpej Fix reading values mapped in P1 via /dev/kmem (problem uncovered by
uch's new pmap).
 1.9 27-Feb-2002  christos - Use DEV_ constants, instead of documenting the numbers!
- Delete cdev_decl(mm); where appropriate, and other hand-crufting [hi powerpc!]
 1.8 12-Feb-2002  uch ANSIfy KNF.
 1.7 10-Sep-2001  chris Update pmap_update to now take the updated pmap as an argument.
This will allow improvements to the pmaps so that they can more easily defer expensive operations, eg tlb/cache flush, til the last possible moment.

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

Reviewed by Jason.
 1.6 24-Apr-2001  thorpej branches: 1.6.2; 1.6.4;
Sprinkle pmap_update() calls after calls to:
- pmap_enter()
- pmap_remove()
- pmap_protect()
- pmap_kenter_pa()
- pmap_kremove()
as described in pmap(9).

These calls are relatively conservative. It may be possible to
optimize these a little more.
 1.5 29-Jun-2000  mrg branches: 1.5.2;
remove include of <vm/vm.h>. <vm/vm.h> -> <uvm/uvm_extern.h>
 1.4 26-Jun-2000  simonb Change the kernel mmap interface so that the offset to map is an
"off_t" and the return value is a "paddr_t" to allow mappings
at offsets past 2^31 bytes. Somewhat inspired by FreeBSD, which
only changed the offset to a "vm_offset_t".

Includes updates for the i386, pc532 and sh3 mmmmap from Jason Thorpe.
 1.3 04-Dec-1999  ragge branches: 1.3.4;
CL* discarding.
 1.2 13-Nov-1999  thorpej Update for pmap_enter() API change. No functional difference.
 1.1 13-Sep-1999  itojun branches: 1.1.2; 1.1.4; 1.1.8;
Merge in NetBSD/sh3 from cvs.kame.net repository.

Tree structure:
- sys/arch/sh3: sh3 generic code
As commented, in-chip device drivers are put into sys/arch/sh3/dev.
- sys/arch/evbsh3: sh3 evaluation boards (pure sh3 CPU, no fancy external HW)
- sys/arch/mmeye: Brains mmEye, www.brains.co.jp
MI source code includes couple of #ifdef for sh3-coff support.
(sh3 uses coff or elf)

Needs some more improvements, especialy in sys/arch/sh3/conf/files.sh3,
to compile the tree (due to last minute tree structure change).
 1.1.8.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.1.4.1 15-Nov-1999  fvdl Sync with -current
 1.1.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.3.4.1 30-Jun-2000  simonb Pull up mmap paddr_t/off_t changes from trunk.
 1.5.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.6.4.2 10-Oct-2001  fvdl Convert all remaining devices.
 1.6.4.1 01-Oct-2001  fvdl Catch up with -current.
 1.6.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.6.2.3 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.6.2.2 16-Mar-2002  jdolecek Catch up with -current.
 1.6.2.1 13-Sep-2001  thorpej Update the kqueue branch to HEAD.
 1.11.6.5 11-Nov-2002  nathanw Catch up to -current
 1.11.6.4 17-Sep-2002  nathanw Catch up to -current.
 1.11.6.3 24-Jun-2002  nathanw Curproc->curlwp renaming.

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

"curproc" is now #defined in proc.h as ((curlwp) ? (curlwp)->l_proc) : NULL)
so that it is always safe to reference curproc (*de*referencing curproc
is another story, but that's always been true).
 1.11.6.2 21-Jun-2002  thorpej Add support for scheduler activations on SuperH. Boots multi-user
on Dreamcast (SH4) with stock userland.
 1.11.6.1 09-May-2002  thorpej file mem.c was added on branch nathanw_sa on 2002-06-21 21:26:32 +0000
 1.11.2.2 06-Jun-2002  gehenna fix missing #include <sys/conf.h>
 1.11.2.1 17-May-2002  gehenna Add the character device switch.
 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.18.16.4 03-Sep-2007  yamt sync with head.
 1.18.16.3 26-Feb-2007  yamt sync with head.
 1.18.16.2 30-Dec-2006  yamt sync with head.
 1.18.16.1 21-Jun-2006  yamt sync with head.
 1.19.12.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.19.10.4 13-May-2006  elad sprinkle some #include <sys/kauth.h> in files that use kauth kpi but
don't include it yet. hopefully this will prevent some fallout.
 1.19.10.3 10-Mar-2006  elad generic_authorize() -> kauth_authorize_generic().
 1.19.10.2 08-Mar-2006  elad Fix syntax error.

Excellent catch by Masao Uebayashi, thanks!
 1.19.10.1 08-Mar-2006  elad Adapt to kernel authorization KPI.

I expect *some* lossage here...
 1.19.8.2 11-Aug-2006  yamt sync with head
 1.19.8.1 24-May-2006  yamt sync with head.
 1.19.6.1 01-Jun-2006  kardel Sync with head.
 1.19.4.1 09-Sep-2006  rpaulo sync with head
 1.21.8.1 06-Jan-2007  bouyer Pull up following revision(s) (requested by elad in ticket #316):
share/examples/secmodel/secmodel_example.c: revision 1.10 via patch
sys/arch/i386/i386/sys_machdep.c: revision 1.79
sys/arch/amd64/amd64/netbsd32_machdep.c: revision 1.31
share/man/man9/secmodel_bsd44.9: revision 1.9
sys/arch/vax/vax/mem.c: revision 1.34 via patch
sys/arch/sh3/sh3/mem.c: revision 1.23 via patch
sys/arch/sh5/sh5/mem.c: revision 1.14 via patch
sys/secmodel/bsd44/secmodel_bsd44_suser.c: revision 1.22 via patch
sys/arch/powerpc/powerpc/mem.c: revision 1.27 via patch
sys/arch/x86/x86/x86_machdep.c: revision 1.5
sys/arch/alpha/alpha/machdep.c: revision 1.291
sys/arch/arm/arm32/mem.c: revision 1.17 via patch
sys/secmodel/bsd44/secmodel_bsd44_securelevel.c: revision 1.20
sys/sys/kauth.h: revision 1.29 via patch
sys/arch/amd64/amd64/sys_machdep.c: revision 1.10
share/man/man9/kauth.9: revision 1.43 via patch
sys/arch/xen/i386/sys_machdep.c: revision 1.10
sys/kern/kern_auth.c: revision 1.35
sys/arch/pc532/pc532/mem.c: revision 1.43 via patch
Make machdep scope architecture-agnostic by removing all arch-specific
requests and centralizing them all. The result is that some of these
are not used on some architectures, but the documentation was updated
to reflect that.
 1.21.4.1 12-Jan-2007  ad Sync with head.
 1.23.2.2 12-Mar-2007  rmind Sync with HEAD.
 1.23.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.26.66.1 18-Mar-2010  rmind Unify /dev/{mem,kmem,zero,null} implementations in MI code. Based on patch
from Joerg Sonnenberger, proposed on tech-kern@, in February 2008.

Work and depression still in progress.
 1.26.64.3 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.26.64.2 27-May-2010  uebayasi Fix build.
 1.26.64.1 28-Apr-2010  uebayasi Always use struct vm_physseg *vm_physmem_ptrs[] in MD code.
 1.26.40.1 29-Mar-2008  mjf Add a mem_init() function for each architecture that requests a device
node for /dev/mem, /dev/null, /dev/zero, etc.

This will disappear when I move this code (and others) to be a
pseudo-device. When we have machine-independent mem code this will all be
unnecessary anyway.
 1.28.4.1 17-Feb-2011  bouyer Sync with HEAD
 1.28.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.29.2.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.18 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.17 16-Mar-2008  uwe branches: 1.17.2; 1.17.4;
If we bother to report number of wired TLB entries we might as well do
it correctly.
 1.16 06-Nov-2007  uwe branches: 1.16.10; 1.16.14;
Convert to aprint_*
 1.15 12-Feb-2006  uwe branches: 1.15.24; 1.15.42; 1.15.44; 1.15.48; 1.15.50;
While here, use uintN_t.
 1.14 12-Feb-2006  uwe Revert changes made in 1.10. They should not be necessary (we are
doing a single word store). I've been running my Jornada without them
for a very long time, but got no word from dreamcast folks. Thanks to
Nick Hudson for testing it on dreamcast finally.
 1.13 24-Jan-2006  uwe branches: 1.13.2; 1.13.4;
Consistently apply ifdef logic so that in SH3-only or SH4-only kernel
all references to CPU cpecific functions are direct, and unused hooks
are not defined.
 1.12 02-Jan-2006  uwe Prepend "cpu0: " to autoconfiguration messages.
While here re-wrap some lines to be more readable.

PR: port-sh3/31315
 1.11 11-Dec-2005  christos branches: 1.11.2;
merge ktrace-lwp.
 1.10 30-Dec-2004  tsutsui branches: 1.10.10;
Protect accesses to PTE/TLB registers with
_cpu_exception_suspend()/_cpu_exception_resume() pair.

Should fix spontaneous reboot problem on heavy load reported by
Christian Groessler on port-dreamcast.
 1.9 15-Jul-2003  lukem branches: 1.9.2; 1.9.6;
__KERNEL_RCSID()
 1.8 09-May-2002  uch branches: 1.8.6; 1.8.12;
remove obsoleted functions. add sh_tlb_update() for update TLB.
MMU mode is changed to multiple virtual storage mode for new pmap code.
 1.7 28-Apr-2002  uch Use "#define<tab>", white space nits.
 1.6 22-Apr-2002  uch make these compile with gcc -O0
 1.5 17-Mar-2002  uch remove obsoleted functions.
 1.4 03-Mar-2002  uch branches: 1.4.4;
SR related parts moved to psl.h. cpufunc.h segments.h are removed.
kernel mode checking is only SR.MD. no check stack pointer.
 1.3 28-Feb-2002  uch branches: 1.3.2;
Cleanup register definition
 1.2 22-Feb-2002  uch print MMU infomation.
 1.1 17-Feb-2002  uch Add new MMU API. for detail, see sh3/mmu.h's comment.
 1.3.2.3 20-Jun-2002  nathanw Catch up to -current.
 1.3.2.2 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.3.2.1 28-Feb-2002  nathanw Catch up to -current.
 1.4.4.3 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.4.4.2 16-Mar-2002  jdolecek Catch up with -current.
 1.4.4.1 03-Mar-2002  jdolecek file mmu.c was added on branch kqueue on 2002-03-16 15:59:42 +0000
 1.8.12.4 17-Jan-2005  skrll Sync with HEAD.
 1.8.12.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.8.12.2 18-Sep-2004  skrll Sync with HEAD.
 1.8.12.1 03-Aug-2004  skrll Sync with HEAD
 1.8.6.2 09-May-2002  uch remove obsoleted functions. add sh_tlb_update() for update TLB.
MMU mode is changed to multiple virtual storage mode for new pmap code.
 1.8.6.1 09-May-2002  uch file mmu.c was added on branch nathanw_sa on 2002-05-09 12:27:05 +0000
 1.9.6.1 10-Jan-2005  jmc Pullup rev 1.10 (requested by tsutsui in ticket #1072)

Protect accesses to PTE/TLB registers with
_cpu_exception_suspend()/_cpu_exception_resume() pair. Prevents
spontaneous reboot under heavy load
 1.9.2.1 10-Jan-2005  jmc Pullup rev 1.10 (requested by tsutsui in ticket #1072)

Protect accesses to PTE/TLB registers with
_cpu_exception_suspend()/_cpu_exception_resume() pair. Prevents
spontaneous reboot under heavy load
 1.10.10.3 17-Mar-2008  yamt sync with head.
 1.10.10.2 15-Nov-2007  yamt sync with head.
 1.10.10.1 21-Jun-2006  yamt sync with head.
 1.11.2.3 18-Feb-2006  yamt sync with head.
 1.11.2.2 01-Feb-2006  yamt sync with head.
 1.11.2.1 15-Jan-2006  yamt sync with head.
 1.13.4.1 22-Apr-2006  simonb Sync with head.
 1.13.2.1 09-Sep-2006  rpaulo sync with head
 1.15.50.1 19-Nov-2007  mjf Sync with HEAD.
 1.15.48.1 13-Nov-2007  bouyer Sync with HEAD
 1.15.44.2 23-Mar-2008  matt sync with HEAD
 1.15.44.1 06-Nov-2007  matt sync with HEAD
 1.15.42.1 06-Nov-2007  joerg Sync with HEAD.
 1.15.24.1 03-Dec-2007  ad Sync with HEAD.
 1.16.14.2 02-Jun-2008  mjf Sync with HEAD.
 1.16.14.1 03-Apr-2008  mjf Sync with HEAD.
 1.16.10.1 24-Mar-2008  keiichi sync with head.
 1.17.4.1 16-May-2008  yamt sync with head.
 1.17.2.1 18-May-2008  yamt sync with head.
 1.16 15-Jul-2025  andvar Fix various typos in comments.
 1.15 12-Feb-2012  matt branches: 1.15.84;
Change old-style function defintions to C89 prototypes.

Approved by releng.
 1.14 28-Apr-2008  martin branches: 1.14.34; 1.14.38;
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 27-May-2007  uwe branches: 1.12.10;
In sh3_tlb_update we need to ensure we are not interrupted while
meesing with the TLB. That would usually show up as misterious kernel
crashes under heavy load.

Prettify the code while here so that traversal of the memory mapped
TLB arrays looks congruent in all functions.

Fixes PR 34706
 1.11 04-Mar-2006  uwe branches: 1.11.18; 1.11.24; 1.11.26; 1.11.32; 1.11.34;
s/u_intN_t/uintN_t/
 1.10 24-Dec-2005  perry branches: 1.10.4; 1.10.6;
__asm__ -> __asm
__const__ -> const
__inline__ -> inline
__volatile__ -> volatile
 1.9 11-Dec-2005  christos merge ktrace-lwp.
 1.8 04-Apr-2005  uwe branches: 1.8.2;
Revert previous. It causes df(1) to reset my Jornada 680 sometimes.
And df(1) that is called during /etc/daily run resets it almost always.
 1.7 30-Dec-2004  tsutsui branches: 1.7.2; 1.7.8;
Protect accesses to PTE/TLB registers with
_cpu_exception_suspend()/_cpu_exception_resume() pair.

Should fix spontaneous reboot problem on heavy load reported by
Christian Groessler on port-dreamcast.
 1.6 15-Jul-2003  lukem branches: 1.6.2; 1.6.6;
__KERNEL_RCSID()
 1.5 09-May-2002  uch branches: 1.5.6; 1.5.12;
remove obsoleted functions. add sh_tlb_update() for update TLB.
MMU mode is changed to multiple virtual storage mode for new pmap code.
 1.4 28-Apr-2002  uch Use "#define<tab>", white space nits.
 1.3 17-Mar-2002  uch zero clear all TLB entry to avoid unexpected VPN match.
 1.2 03-Mar-2002  uch branches: 1.2.4;
SR related parts moved to psl.h. cpufunc.h segments.h are removed.
kernel mode checking is only SR.MD. no check stack pointer.
 1.1 17-Feb-2002  uch branches: 1.1.2;
Add new MMU API. for detail, see sh3/mmu.h's comment.
 1.1.2.3 20-Jun-2002  nathanw Catch up to -current.
 1.1.2.2 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.1.2.1 28-Feb-2002  nathanw Catch up to -current.
 1.2.4.3 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.2.4.2 16-Mar-2002  jdolecek Catch up with -current.
 1.2.4.1 03-Mar-2002  jdolecek file mmu_sh3.c was added on branch kqueue on 2002-03-16 15:59:42 +0000
 1.5.12.5 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.5.12.4 17-Jan-2005  skrll Sync with HEAD.
 1.5.12.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.5.12.2 18-Sep-2004  skrll Sync with HEAD.
 1.5.12.1 03-Aug-2004  skrll Sync with HEAD
 1.5.6.2 09-May-2002  uch remove obsoleted functions. add sh_tlb_update() for update TLB.
MMU mode is changed to multiple virtual storage mode for new pmap code.
 1.5.6.1 09-May-2002  uch file mmu_sh3.c was added on branch nathanw_sa on 2002-05-09 12:27:05 +0000
 1.6.6.1 10-Jan-2005  jmc Pullup rev 1.7 (requested by tsutsui in ticket #1072)

Protect accesses to PTE/TLB registers with
_cpu_exception_suspend()/_cpu_exception_resume() pair. Prevents
spontaneous reboot under heavy load
 1.6.2.1 10-Jan-2005  jmc Pullup rev 1.7 (requested by tsutsui in ticket #1072)

Protect accesses to PTE/TLB registers with
_cpu_exception_suspend()/_cpu_exception_resume() pair. Prevents
spontaneous reboot under heavy load
 1.7.8.1 04-Apr-2005  tron Pull up revision 1.8 (requested by uwe in ticket #108):
Revert previous. It causes df(1) to reset my Jornada 680 sometimes.
And df(1) that is called during /etc/daily run resets it almost always.
 1.7.2.1 29-Apr-2005  kent sync with -current
 1.8.2.2 03-Sep-2007  yamt sync with head.
 1.8.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.34.1 04-Jun-2007  wrstuden Update to today's netbsd-4.
 1.11.32.1 26-Jun-2007  garbled Sync with HEAD.
 1.11.26.1 11-Jul-2007  mjf Sync with head.
 1.11.24.1 09-Jun-2007  ad Sync with head.
 1.11.18.1 30-May-2007  riz Pull up following revision(s) (requested by uwe in ticket #680):
sys/arch/sh3/sh3/mmu_sh3.c: revision 1.12
In sh3_tlb_update we need to ensure we are not interrupted while
meesing with the TLB. That would usually show up as misterious kernel
crashes under heavy load.
Prettify the code while here so that traversal of the memory mapped
TLB arrays looks congruent in all functions.
Fixes PR 34706
 1.12.10.1 06-Nov-2007  matt 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.38.1 18-Feb-2012  mrg merge to -current.
 1.14.34.1 17-Apr-2012  yamt sync with head
 1.15.84.1 02-Aug-2025  perseant Sync with HEAD
 1.21 04-Aug-2020  uwe Avoid inline RUN_P2 when accessing TLB via memory mapped arrays.

Move code that needs to run from P2 into separate functions and call
them via P2 pointer.
 1.20 03-Aug-2020  uwe sh4_mmu_start - cosmetics.

Split construction of the initial MMUCR value into several assignments
for readability. Same object code is generated.
 1.19 03-Aug-2020  uwe sh4_mmu_start - call sh4_tlb_invalidate_all directly.
 1.18 03-Aug-2020  uwe sh4_tlb_invalidate_addr - refactor to avoid RUN_P2.

Introduce __sh4_tlb_assoc that performs the associative write. Call
it from sh4_tlb_invalidate_addr. In sh4_tlb_update do not call
sh4_tlb_invalidate_addr, call __sh4_tlb_assoc directly. We need to do
the song and dance to block exceptions and set PTEH anyway for the new
value, so don't waste all that effort.
 1.17 03-Aug-2020  uwe sh4_tlb_invalidate_addr - use the right constant.

VPN mask happens to be the same in many registers, but since we are
writing the value to UTLB data array, use that particular constant for
consistency. Same object code is generated.
 1.16 03-Aug-2020  uwe Split compound assertion into several, one for each term.
 1.15 03-Aug-2020  uwe _cpu_exception_suspend - return old SR

In a typical use case we do a very short code sequence with PSL_BL set
and restore the old PSL_BL value with _cpu_exception_resume that does
the full read/mask/set dance. In reality we are just restoring SR to
its old state as no other modifications to SR can possibly happen. So
return old SR and let the caller restore it in one instruction.
 1.14 12-Feb-2012  matt Change old-style function defintions to C89 prototypes.

Approved by releng.
 1.13 28-Apr-2008  martin branches: 1.13.34; 1.13.38;
Remove clause 3 and 4 from TNF licenses
 1.12 31-Mar-2007  uwe branches: 1.12.34; 1.12.36; 1.12.38;
Mark __sh4_itlb_invalidate_all we call while running on P2 with
__attribute__((always_inline)) or gcc might decide not to inline it,
resulting in P2->P1 call.
 1.11 04-Mar-2006  uwe branches: 1.11.18; 1.11.20; 1.11.24; 1.11.26;
s/u_intN_t/uintN_t/
 1.10 24-Dec-2005  perry branches: 1.10.4; 1.10.6;
__asm__ -> __asm
__const__ -> const
__inline__ -> inline
__volatile__ -> volatile
 1.9 11-Dec-2005  christos merge ktrace-lwp.
 1.8 30-Dec-2004  tsutsui branches: 1.8.10;
Protect accesses to PTE/TLB registers with
_cpu_exception_suspend()/_cpu_exception_resume() pair.

Should fix spontaneous reboot problem on heavy load reported by
Christian Groessler on port-dreamcast.
 1.7 15-Jul-2003  lukem branches: 1.7.2; 1.7.6;
__KERNEL_RCSID()
 1.6 04-Nov-2002  itohy branches: 1.6.6;
Initialize UTLB/ITLB data array 1 to zero.
If the VPN / PPN are not aligned to page boundary (the page size
is set by SZ bits in data array 1, which are random when power-up time),
unexpected exception occurs in some rare case, it seems....
Initialize SZ to zero (1KB page). Also, clear VPN / PPN to zero just in case.

Make __sh4_itlb_invalidate_all() static.
 1.5 09-May-2002  uch branches: 1.5.6;
remove obsoleted functions. add sh_tlb_update() for update TLB.
MMU mode is changed to multiple virtual storage mode for new pmap code.
 1.4 28-Apr-2002  uch Use "#define<tab>", white space nits.
 1.3 17-Mar-2002  uch reserve wired entries for kernel stack.
 1.2 03-Mar-2002  uch branches: 1.2.4;
SR related parts moved to psl.h. cpufunc.h segments.h are removed.
kernel mode checking is only SR.MD. no check stack pointer.
 1.1 17-Feb-2002  uch branches: 1.1.2;
Add new MMU API. for detail, see sh3/mmu.h's comment.
 1.1.2.3 20-Jun-2002  nathanw Catch up to -current.
 1.1.2.2 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.1.2.1 28-Feb-2002  nathanw Catch up to -current.
 1.2.4.3 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.2.4.2 16-Mar-2002  jdolecek Catch up with -current.
 1.2.4.1 03-Mar-2002  jdolecek file mmu_sh4.c was added on branch kqueue on 2002-03-16 15:59:42 +0000
 1.5.6.2 11-Nov-2002  nathanw Catch up to -current
 1.5.6.1 09-May-2002  nathanw file mmu_sh4.c was added on branch nathanw_sa on 2002-11-11 22:04:06 +0000
 1.6.6.4 17-Jan-2005  skrll Sync with HEAD.
 1.6.6.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.6.6.2 18-Sep-2004  skrll Sync with HEAD.
 1.6.6.1 03-Aug-2004  skrll Sync with HEAD
 1.7.6.1 10-Jan-2005  jmc Pullup rev 1.8 (requested by tsutsui in ticket #1072)

Protect accesses to PTE/TLB registers with
_cpu_exception_suspend()/_cpu_exception_resume() pair. Prevents
spontaneous reboot under heavy load
 1.7.2.1 10-Jan-2005  jmc Pullup rev 1.8 (requested by tsutsui in ticket #1072)

Protect accesses to PTE/TLB registers with
_cpu_exception_suspend()/_cpu_exception_resume() pair. Prevents
spontaneous reboot under heavy load
 1.8.10.2 03-Sep-2007  yamt sync with head.
 1.8.10.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.26.1 11-Jul-2007  mjf Sync with head.
 1.11.24.1 10-Apr-2007  ad Sync with head.
 1.11.20.1 15-Apr-2007  yamt sync with head.
 1.11.18.1 20-Apr-2007  bouyer Pull up following revision(s) (requested by uwe in ticket #586):
sys/arch/sh3/sh3/cache_sh4.c: revision 1.17
sys/arch/sh3/sh3/mmu_sh4.c: revision 1.12
Mark inline functions we call while running on P2 with
__attribute__((always_inline)) or gcc might decide not to inline them,
resulting in P2->P1 call while we mess with the cache, and kernel
would just hang immediately on boot.
Makes sh4 kernel compiled with -Os actually work.
 1.12.38.1 16-May-2008  yamt sync with head.
 1.12.36.1 18-May-2008  yamt sync with head.
 1.12.34.1 02-Jun-2008  mjf Sync with HEAD.
 1.13.38.1 18-Feb-2012  mrg merge to -current.
 1.13.34.1 17-Apr-2012  yamt sync with head
 1.2 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.1 13-Sep-1999  itojun branches: 1.1.2;
Merge in NetBSD/sh3 from cvs.kame.net repository.

Tree structure:
- sys/arch/sh3: sh3 generic code
As commented, in-chip device drivers are put into sys/arch/sh3/dev.
- sys/arch/evbsh3: sh3 evaluation boards (pure sh3 CPU, no fancy external HW)
- sys/arch/mmeye: Brains mmEye, www.brains.co.jp
MI source code includes couple of #ifdef for sh3-coff support.
(sh3 uses coff or elf)

Needs some more improvements, especialy in sys/arch/sh3/conf/files.sh3,
to compile the tree (due to last minute tree structure change).
 1.1.2.1 20-Nov-2000  bouyer Remove files that are no longer on the trunck
 1.94 08-Sep-2021  rin Hmm, remove one more parentheses from return.
 1.93 08-Sep-2021  rin Restore braces for if/else statements which have logically single line,
but physically multiple lines.

This is recommended by an example in style:
http://cvsweb.netbsd.org/bsdweb.cgi/src/share/misc/style#rev1.58

Thanks tsutsui@ for pointing it out.
 1.92 08-Sep-2021  rin Redo a part of rev 1.89:
- Improve uniformity of panic messages. Also, use __func__ instead of
hard-coded function names.
 1.91 08-Sep-2021  rin Redo a part of rev 1.89:

- Remove redundant parentheses/braces/comments.
- Fix indents.

No binary changes confirmed this time.
 1.90 08-Sep-2021  rin Revert rev 1.89:
http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/arch/sh3/sh3/pmap.c#rev1.89

I misunderstood evaluation order of ? operator.

I should have split the commit into two parts, i.e., with and without
binary diffs, in order to avoid such a serious mistake.

Thanks rillig@ so much for careful check!!!!
 1.89 08-Sep-2021  rin Misc cosmetic fixes:
- Remove redundant parentheses/braces/comments.
- Improve uniformity of panic messages. Also, use __func__ instead of
hard-coded function names.
- Fix indents.
 1.88 08-Sep-2021  rin Turn KASSERT's added for PR port-sh3/56381 into KDASSERT's;
they are less likely expected to fire again.
 1.87 02-Sep-2021  rin Add missing NULL check for __pmap_pv_alloc() (== pool_get() with
PR_NOWAIT) in __pmap_pv_enter().

Then, handle this failure in pmap_enter(); return ENOMEM if
PMAP_CANFAIL, and panic otherwise.
 1.86 02-Sep-2021  rin PR port-sh3/56381

pmap_enter() returns ENOMEM if __pmap_pte_alloc() fails and PMAP_CANFAIL
flag is specified. In this case, remove pv via __pmap_pv_remove() if it is
added to p-v map list via __pmap_pv_enter().

Otherwise, pmap becomes an inconsistent state, which results in an infinite
loop in pmap_page_protect(), as reported in the PR.

Also, KASSERT's are added for sure, in order to detect the infinite loops.

Great thanks to chs@ for finding out this bug!!
 1.85 26-Jul-2021  andvar Revert rename back to OFSET, since the name follows historical PGOFSET definition. Noted by tsutsui.
 1.84 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.83 01-Aug-2020  uwe branches: 1.83.6;
pmap_unwire - deobfuscate.

Don't hide assignments inside if (). Remove redundant entry == 0 test
b/c _PG_WIRED test afterwards covers that and the compiler actually
elimiates it anyway. Same object code is generated.
 1.82 02-Feb-2017  uwe pmap_steal_memory - a few more s/start/avail_start/ fixes for the
hotplug conversion.
 1.81 02-Feb-2017  uwe pmap_steal_memory - s/start/avail_start/ to fix mistake in the hotplug
conversion. The kernel now panics (can't unplug memory from the
middle of a segment) instead of triggering a reset.
 1.80 24-Dec-2016  cherry branches: 1.80.2;
Use the correct page frame number to steal pages during boot.

Fixes the related sh3 kernel build breakage.
 1.79 23-Dec-2016  cherry "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.78 03-Sep-2016  christos Fix pmap_prefer for topdown and turn topdown on.
 1.77 12-Nov-2010  uebayasi branches: 1.77.18; 1.77.36; 1.77.40;
Put VM_PAGE_TO_MD() definition in one place. No functional changes.
 1.76 10-Nov-2010  uebayasi Use more VM_PHYSMEM_*() accessors. No functional changes.
 1.75 30-Oct-2010  uebayasi Use VM_PAGE_TO_MD() to locate struct vm_page_md. No functional
changes.
 1.74 07-Nov-2009  cegger branches: 1.74.2; 1.74.4;
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.73 09-Jun-2009  uwe In pmap_protect(), compute the bitmask to set in the ptes only once, instead
of every iteration. From OpenBSD.
 1.72 21-Apr-2009  cegger change pmap flags argument from int to u_int.
discussed with christos@ on source-changes-d@
 1.71 18-Mar-2009  cegger Ansify function definitions w/o arguments. Generated with sed.
 1.70 23-Jan-2009  uwe branches: 1.70.2;
Unhide __pmap_kernel for the benefit of fast tlb miss handlers.
 1.69 10-Dec-2008  pooka Make kernel_pmap_ptr a const. Requested by steve_martin.
 1.68 09-Dec-2008  pooka Make pmap_kernel() a MI macro for struct pmap *kernel_pmap_ptr,
which is now the "API" provided by the pmap module. pmap_kernel()
remains as the syntactic sugar.

Bonus cosmetics round: move all the pmap_t pointer typedefs into
uvm_pmap.h.

Thanks to Greg Oster for providing cpu muscle for doing test builds.
 1.67 28-Apr-2008  martin branches: 1.67.6; 1.67.8;
Remove clause 3 and 4 from TNF licenses
 1.66 17-Oct-2007  garbled branches: 1.66.16; 1.66.18; 1.66.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.65 16-Jul-2007  macallan branches: 1.65.10;
change pmap_phys_address()s parameter to paddr_t since that's what it gets
fed from mmap*() anyway
approved by gimpy
 1.64 25-May-2007  uwe Clarify comments in pmap_enter.
 1.63 18-May-2007  uwe Implement fast path TLB miss handling. Walk the page table without
creating a trapframe, with exceptions disabled and using only BANK1
registers. If a valid pte is found, load it and return. Otherwise
create a trapframe and proceed to the full-blown C handler.
 1.62 12-Mar-2007  ad branches: 1.62.2; 1.62.8;
Pass an ipl argument to pool_init/POOL_INIT to be used when initializing
the pool's lock.
 1.61 04-Mar-2007  christos branches: 1.61.2;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.60 22-Feb-2007  thorpej TRUE -> true, FALSE -> false
 1.59 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.58 18-Nov-2006  tsutsui branches: 1.58.2; 1.58.4; 1.58.6;
Disable sosend_loan() in sys/kern/uipc_socket.c temporarily on CPUs
which have virtual address indexed cache and whose pmaps don't always
allow normal shared mappings even for read only pages.

In future, these pmaps should be rewritten to handle such read only
shared mappings properly like ARM pmap, but currently we just disable
sosend_loan() to avoid unnecessary uncached mappings and cache flushes
on MIPS3 CPUs, or map/unmap thrashing on SH4.

Discussed with thorpej a while ago.
 1.57 24-Oct-2006  uwe __pmap_kpte_lookup: verify that ptp is not NULL.
 1.56 24-Sep-2006  tsutsui Allow shared PV mappings in pmap_enter(9) even on SH4 if VAs of shared pages
have the same virtual cache indexes (i.e. they won't cause virtual cache
aliases). Also prepare PMAP_PREFER(9) for SH4 to avoid some possible virtual
cache aliases.
More stuff should be added in pmap_enter(9), but at least this changes
should fix some existing problems. See discussion on port-sh3 ML for details.

OK'ed by uwe and chs, and closes PR port-sh3/34243.
 1.55 07-Aug-2006  tsutsui branches: 1.55.4; 1.55.6;
uvm_pagealloc(9) can fail, so handle that case in pmap_enter(9).
 1.54 04-Mar-2006  uwe branches: 1.54.2;
s/u_intN_t/uintN_t/
 1.53 09-Feb-2006  uwe pmap_extract: handle P1 and P2 (MMU bypass) addresses specially.
PMAP_MAP_POOLPAGE maps pa -> P1 va, so we must handle this case here.
PR port-sh3/26569 by Nick Hudson.
 1.52 21-Jan-2006  uwe branches: 1.52.2; 1.52.4;
Add NOTREACHED after calls to panic().
 1.51 11-Dec-2005  christos branches: 1.51.2;
merge ktrace-lwp.
 1.50 30-Dec-2003  pk branches: 1.50.16;
Replace the traditional buffer memory management -- based on fixed per buffer
virtual memory reservation and a private pool of memory pages -- by a scheme
based on memory pools.

This allows better utilization of memory because buffers can now be allocated
with a granularity finer than the system's native page size (useful for
filesystems with e.g. 1k or 2k fragment sizes). It also avoids fragmentation
of virtual to physical memory mappings (due to the former fixed virtual
address reservation) resulting in better utilization of MMU resources on some
platforms. Finally, the scheme is more flexible by allowing run-time decisions
on the amount of memory to be used for buffers.

On the other hand, the effectiveness of the LRU queue for buffer recycling
may be somewhat reduced compared to the traditional method since, due to the
nature of the pool based memory allocation, the actual least recently used
buffer may release its memory to a pool different from the one needed by a
newly allocated buffer. However, this effect will kick in only if the
system is under memory pressure.
 1.49 10-Aug-2003  chs fix typos in comments.
 1.48 15-Jul-2003  lukem __KERNEL_RCSID()
 1.47 14-Jun-2003  tsutsui branches: 1.47.2;
Allow user pmap to pmap_enter device (bus-space) memory.
 1.46 14-Jun-2003  tsutsui Fix lack of parentheses bug which causes wrong pte settings.
 1.45 10-May-2003  thorpej 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.44 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.43 02-Apr-2003  thorpej Use PAGE_SIZE rather than NBPG.
 1.42 18-Jan-2003  thorpej Merge the nathanw_sa branch.
 1.41 16-Dec-2002  thorpej Initialize pools in pmap_init(); the low-water mark must be set when
it is safe to allocate pages via the normal mechanism.
 1.40 09-May-2002  uch branches: 1.40.6;
new pmap designed for SH3/SH4.
 1.39 28-Apr-2002  uch Use "#define<tab>", white space nits.
 1.38 04-Apr-2002  uch remove obsolete functions, decralations and structure.
 1.37 03-Apr-2002  msaitoh sync with i386/i386/pmap.c rev. 1.94:

make dangerous pmap_copy() and pmap_move() no-op.
 1.36 27-Mar-2002  chs avoid accounting errors in pmap_enter() by only updating the counters
once the operation can no longer fail. fixes PR 16028.
 1.35 17-Mar-2002  uch cosmetic changes, fix comments.
 1.34 08-Mar-2002  thorpej Pool deals fairly well with physical memory shortage, but it doesn't
deal with shortages of the VM maps where the backing pages are mapped
(usually kmem_map). Try to deal with this:

* Group all information about the backend allocator for a pool in a
separate structure. The pool references this structure, rather than
the individual fields.
* Change the pool_init() API accordingly, and adjust all callers.
* Link all pools using the same backend allocator on a list.
* The backend allocator is responsible for waiting for physical memory
to become available, but will still fail if it cannot callocate KVA
space for the pages. If this happens, carefully drain all pools using
the same backend allocator, so that some KVA space can be freed.
* Change pool_reclaim() to indicate if it actually succeeded in freeing
some pages, and use that information to make draining easier and more
efficient.
* Get rid of PR_URGENT. There was only one use of it, and it could be
dealt with by the caller.

From art@openbsd.org.
 1.33 17-Feb-2002  uch Add new MMU API. for detail, see sh3/mmu.h's comment.
 1.32 12-Feb-2002  uch ANSIfy KNF.
 1.31 11-Feb-2002  uch clean up redundant PTE PG_* defines.
PG_RO -> PG_KR
PG_RW -> PG_KW
PG_u -> PG_URKR
PG_PROT -> PG_UW
PG_AVAIL1 -> PG_PVLIST
 1.30 02-Jan-2002  chs pmap_page_protect(VM_PROT_NONE) must remove all mappings in the PV list,
even if they are wired. we need to be able to remove all mappings to
pages that are being freed due to (eg.) file truncation.
 1.29 15-Nov-2001  chs fix pmap_extract() to handle addresses with a PTP but an invalid PTE.
 1.28 19-Sep-2001  chs Fix kern/13049: missing unlock on failure exit from pmap_enter()
 1.27 15-Sep-2001  chs a whole bunch of changes to improve performance and robustness under load:

- remove special treatment of pager_map mappings in pmaps. this is
required now, since I've removed the globals that expose the address range.
pager_map now uses pmap_kenter_pa() instead of pmap_enter(), so there's
no longer any need to special-case it.
- eliminate struct uvm_vnode by moving its fields into struct vnode.
- rewrite the pageout path. the pager is now responsible for handling the
high-level requests instead of only getting control after a bunch of work
has already been done on its behalf. this will allow us to UBCify LFS,
which needs tighter control over its pages than other filesystems do.
writing a page to disk no longer requires making it read-only, which
allows us to write wired pages without causing all kinds of havoc.
- use a new PG_PAGEOUT flag to indicate that a page should be freed
on behalf of the pagedaemon when it's unlocked. this flag is very similar
to PG_RELEASED, but unlike PG_RELEASED, PG_PAGEOUT can be cleared if the
pageout fails due to eg. an indirect-block buffer being locked.
this allows us to remove the "version" field from struct vm_page,
and together with shrinking "loan_count" from 32 bits to 16,
struct vm_page is now 4 bytes smaller.
- no longer use PG_RELEASED for swap-backed pages. if the page is busy
because it's being paged out, we can't release the swap slot to be
reallocated until that write is complete, but unlike with vnodes we
don't keep a count of in-progress writes so there's no good way to
know when the write is done. instead, when we need to free a busy
swap-backed page, just sleep until we can get it busy ourselves.
- implement a fast-path for extending writes which allows us to avoid
zeroing new pages. this substantially reduces cpu usage.
- encapsulate the data used by the genfs code in a struct genfs_node,
which must be the first element of the filesystem-specific vnode data
for filesystems which use genfs_{get,put}pages().
- eliminate many of the UVM pagerops, since they aren't needed anymore
now that the pager "put" operation is a higher-level operation.
- enhance the genfs code to allow NFS to use the genfs_{get,put}pages
instead of a modified copy.
- clean up struct vnode by removing all the fields that used to be used by
the vfs_cluster.c code (which we don't use anymore with UBC).
- remove kmem_object and mb_object since they were useless.
instead of allocating pages to these objects, we now just allocate
pages with no object. such pages are mapped in the kernel until they
are freed, so we can use the mapping to find the page to free it.
this allows us to remove splvm() protection in several places.

The sum of all these changes improves write throughput on my
decstation 5000/200 to within 1% of the rate of NetBSD 1.5
and reduces the elapsed time for "make release" of a NetBSD 1.5
source tree on my 128MB pc to 10% less than a 1.5 kernel took.
 1.26 10-Sep-2001  chris Update pmap_update to now take the updated pmap as an argument.
This will allow improvements to the pmaps so that they can more easily defer expensive operations, eg tlb/cache flush, til the last possible moment.

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

Reviewed by Jason.
 1.25 20-Jul-2001  ichiro branches: 1.25.2;
use definition of memory size for physical area
0x20000000 -> SH3_P1234SEG_SIZE
 1.24 02-Jun-2001  chs branches: 1.24.2;
replace vm_map{,_entry}_t with struct vm_map{,_entry} *.
 1.23 26-May-2001  chs replace vm_page_t with struct vm_page *.
 1.22 26-May-2001  chs replace {simple_,}lock{_data,}_t with struct {simple,}lock {,*}.
 1.21 25-May-2001  sommerfeld Replicate pte unmap change from i386 pmap.c
(fix kern/12554 workaround).
 1.20 13-May-2001  tshiozak Correct a simple bug in the recent commit (pmap.c:1.19) by thopej.
I guess he indents to prepare a temporary variable for saving the next
pointer of a list element, but he seems to forget to substitute the
pointer for the variable. This often causes my dreamcast panic.
 1.19 25-Apr-2001  thorpej Work around the problem that causes kern/12554. Basically,
there are some pathological cases that cause pmap_page_protect()
to be called on a wired page to revoke all mappings. We
need to skip mappings that are actually wired to prevent Bad
things from happening later.

THIS IS JUST A WORK-AROUND. We need to prevent the pathological
behavior from happening in UVM to begin with. But it's unclear
what the right solution is there, right now.
 1.18 24-Apr-2001  thorpej Sprinkle pmap_update() calls after calls to:
- pmap_enter()
- pmap_remove()
- pmap_protect()
- pmap_kenter_pa()
- pmap_kremove()
as described in pmap(9).

These calls are relatively conservative. It may be possible to
optimize these a little more.
 1.17 22-Apr-2001  thorpej Remove pmap_kenter_pgs(). It was never really adopted by
anything, and the interface itself wasn't as flexible as
callers would have probably liked.
 1.16 21-Apr-2001  thorpej pmap_update() should not be equated with "flush entire TLB", it is
used to process deferred pmap operations. Since these pmaps don't
defer anything, pmap_update() is a noop.
 1.15 15-Mar-2001  chs eliminate the KERN_* error codes in favor of the traditional E* codes.
the mapping is:

KERN_SUCCESS 0
KERN_INVALID_ADDRESS EFAULT
KERN_PROTECTION_FAILURE EACCES
KERN_NO_SPACE ENOMEM
KERN_INVALID_ARGUMENT EINVAL
KERN_FAILURE various, mostly turn into KASSERTs
KERN_RESOURCE_SHORTAGE ENOMEM
KERN_NOT_RECEIVER <unused>
KERN_NO_ACCESS <unused>
KERN_PAGES_LOCKED <unused>
 1.14 02-Feb-2001  thorpej branches: 1.14.2;
Rewrite how mod/ref emulation is done. In particular, make
modified attribute checking actually work. Previously, a
page could be reported as modified even if it wasn't! This
is very bad, and e.g. caused the VM system to attempt to
"clean" pages of read-only files.

Only lip-services is paid to referenced attribute emulation.
This could be improved.
 1.13 14-Jan-2001  thorpej splimp() -> splvm()
 1.12 15-Dec-2000  tsubai Make this compile again.
 1.11 30-Aug-2000  tsubai Initialize pv_head locks.
 1.10 29-Jun-2000  mrg remove include of <vm/vm.h>. <vm/vm.h> -> <uvm/uvm_extern.h>
 1.9 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.8 02-Jun-2000  thorpej branches: 1.8.2;
When allocating new PT pages during early bootstrap (i.e. before
pmap_init() has finished), make sure to zero them.
 1.7 24-Apr-2000  tsubai branches: 1.7.2;
Sync with current i386 pmap.c.
 1.6 10-Apr-2000  thorpej Use UVM_PGA_ZERO in pmap_alloc_ptp().
 1.5 02-Apr-2000  thorpej Instead of checking vm_physmem[<physseg>].pgs to determine if
uvm_page_init() has completed, add a boolean uvm.page_init_done,
and test against that. Use this same boolean (rather than
pmap_initialized) in pmap_growkernel() to determine if we are
being called via uvm_page_init() to grow the kernel address space.

This fixes a problem on some i386 configurations where pmap_init()
itself was needing to have the kernel page table grown, and since
pmap_initialized was not yet set to TRUE, pmap_growkernel() was
choosing the wrong code path.

Fix tested by Havard Eidnes.
 1.4 24-Feb-2000  msaitoh SH4!
 1.3 13-Nov-1999  thorpej Update for pmap_enter() API change. No functional difference.
 1.2 14-Sep-1999  tsubai branches: 1.2.2; 1.2.4; 1.2.8;
Catch up with -current.
 1.1 13-Sep-1999  itojun Merge in NetBSD/sh3 from cvs.kame.net repository.

Tree structure:
- sys/arch/sh3: sh3 generic code
As commented, in-chip device drivers are put into sys/arch/sh3/dev.
- sys/arch/evbsh3: sh3 evaluation boards (pure sh3 CPU, no fancy external HW)
- sys/arch/mmeye: Brains mmEye, www.brains.co.jp
MI source code includes couple of #ifdef for sh3-coff support.
(sh3 uses coff or elf)

Needs some more improvements, especialy in sys/arch/sh3/conf/files.sh3,
to compile the tree (due to last minute tree structure change).
 1.2.8.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.2.4.1 15-Nov-1999  fvdl Sync with -current
 1.2.2.6 23-Apr-2001  bouyer Sync with HEAD.
 1.2.2.5 27-Mar-2001  bouyer Sync with HEAD.
 1.2.2.4 11-Feb-2001  bouyer Sync with HEAD.
 1.2.2.3 18-Jan-2001  bouyer Sync with head (for UBC+NFS fixes, mostly).
 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.7.2.1 22-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.8.2.1 28-Mar-2002  he Pull up revision 1.36 (via patch, requested by chs):
Avoid accounting errors in pmap_enter() by only updating the counters
once the operation can no longer fail. Fixes PR#16028.
 1.14.2.2 21-Jun-2001  nathanw Catch up to -current.
 1.14.2.1 09-Apr-2001  nathanw Catch up with -current.
 1.24.2.5 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.24.2.4 16-Mar-2002  jdolecek Catch up with -current.
 1.24.2.3 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.24.2.2 13-Sep-2001  thorpej Update the kqueue branch to HEAD.
 1.24.2.1 03-Aug-2001  lukem update to -current
 1.25.2.1 01-Oct-2001  fvdl Catch up with -current.
 1.40.6.3 16-Dec-2002  thorpej Sync with HEAD; makes kernel boot on my Dreamcast again.
 1.40.6.2 21-Jun-2002  thorpej Add support for scheduler activations on SuperH. Boots multi-user
on Dreamcast (SH4) with stock userland.
 1.40.6.1 09-May-2002  thorpej file pmap.c was added on branch nathanw_sa on 2002-06-21 21:26:33 +0000
 1.47.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.47.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.47.2.1 03-Aug-2004  skrll Sync with HEAD
 1.50.16.4 03-Sep-2007  yamt sync with head.
 1.50.16.3 26-Feb-2007  yamt sync with head.
 1.50.16.2 30-Dec-2006  yamt sync with head.
 1.50.16.1 21-Jun-2006  yamt sync with head.
 1.51.2.2 18-Feb-2006  yamt sync with head.
 1.51.2.1 01-Feb-2006  yamt sync with head.
 1.52.4.1 22-Apr-2006  simonb Sync with head.
 1.52.2.1 09-Sep-2006  rpaulo sync with head
 1.54.2.1 11-Aug-2006  yamt sync with head
 1.55.6.2 10-Dec-2006  yamt sync with head.
 1.55.6.1 22-Oct-2006  yamt sync with head
 1.55.4.2 12-Jan-2007  ad Sync with head.
 1.55.4.1 18-Nov-2006  ad Sync with head.
 1.58.6.1 03-Jun-2008  skrll Sync with netbsd-4.
 1.58.4.3 24-Mar-2007  yamt sync with head.
 1.58.4.2 12-Mar-2007  rmind Sync with HEAD.
 1.58.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.58.2.1 22-Feb-2008  bouyer Pull up following revision(s) (requested by uwe in ticket #1075):
sys/arch/sh3/sh3/exception_vector.S: revision 1.21 - 1.30
sys/arch/sh3/sh3/genassym.cf: revision 1.11 - 1.12
sys/arch/sh3/sh3/pmap.c: revision 1.63
Implement fast path TLB miss handling. Walk the page table without
creating a trapframe, with exceptions disabled and using only BANK1
registers. If a valid pte is found, load it and return. Otherwise
create a trapframe and proceed to the full-blown C handler.
 1.61.2.3 20-Aug-2007  ad Sync with HEAD.
 1.61.2.2 27-May-2007  ad Sync with head.
 1.61.2.1 13-Mar-2007  ad Sync with head.
 1.62.8.3 03-Oct-2007  garbled Sync with HEAD
 1.62.8.2 26-Jun-2007  garbled Sync with HEAD.
 1.62.8.1 22-May-2007  matt Update to HEAD.
 1.62.2.1 11-Jul-2007  mjf Sync with head.
 1.65.10.1 06-Nov-2007  matt sync with HEAD
 1.66.20.4 11-Mar-2010  yamt sync with head
 1.66.20.3 20-Jun-2009  yamt sync with head
 1.66.20.2 04-May-2009  yamt sync with head.
 1.66.20.1 16-May-2008  yamt sync with head.
 1.66.18.1 18-May-2008  yamt sync with head.
 1.66.16.2 17-Jan-2009  mjf Sync with HEAD.
 1.66.16.1 02-Jun-2008  mjf Sync with HEAD.
 1.67.8.3 28-Apr-2009  skrll Sync with HEAD.
 1.67.8.2 03-Mar-2009  skrll Sync with HEAD.
 1.67.8.1 19-Jan-2009  skrll Sync with HEAD.
 1.67.6.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.70.2.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.74.4.1 05-Mar-2011  rmind sync with head
 1.74.2.8 10-Nov-2010  uebayasi Fix thinko; make vm_physseg ptr swap really work.
 1.74.2.7 10-Nov-2010  uebayasi Always use VM_PHYSMEM_PTR().
 1.74.2.6 06-Nov-2010  uebayasi Sync with HEAD.
 1.74.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.74.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.74.2.3 28-Apr-2010  uebayasi Always use struct vm_physseg *vm_physmem_ptrs[] in MD code.
 1.74.2.2 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.74.2.1 25-Feb-2010  uebayasi Use VM_PAGE_TO_MD(). Only compile tested.
 1.77.40.2 20-Mar-2017  pgoyette Sync with HEAD
 1.77.40.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.77.36.2 05-Feb-2017  skrll Sync with HEAD
 1.77.36.1 05-Oct-2016  skrll Sync with HEAD
 1.77.18.1 03-Dec-2017  jdolecek update from HEAD
 1.80.2.1 21-Apr-2017  bouyer Sync with HEAD
 1.83.6.1 01-Aug-2021  thorpej Sync with HEAD.
 1.2 14-Sep-1999  tsubai Catch up with -current.
 1.1 13-Sep-1999  itojun Merge in NetBSD/sh3 from cvs.kame.net repository.

Tree structure:
- sys/arch/sh3: sh3 generic code
As commented, in-chip device drivers are put into sys/arch/sh3/dev.
- sys/arch/evbsh3: sh3 evaluation boards (pure sh3 CPU, no fancy external HW)
- sys/arch/mmeye: Brains mmEye, www.brains.co.jp
MI source code includes couple of #ifdef for sh3-coff support.
(sh3 uses coff or elf)

Needs some more improvements, especialy in sys/arch/sh3/conf/files.sh3,
to compile the tree (due to last minute tree structure change).
 1.2 04-Aug-2020  uwe st40_pmb_dump - factor out.

Print the WT bit as either "WT" or "CB" when C is set, as "--"
otherwise. Few other minor tweaks.
 1.1 30-Jul-2020  uwe Code to dump PMB contents.
 1.25 19-Oct-2020  christos _KERNEL_OPT police
 1.24 15-Oct-2020  martin Add missing 'error' declaration
 1.23 15-Oct-2020  mgorny Fix the machine-dependent ptrace requests to respect LWP number

Fix the machine-dependent ptrace register-related requests (e.g.
PT_GETXMMREGS, PT_GETXSTATE on x86) to correctly respect the LWP number
passed as the data argument. Before this change, these requests
did not operate on the requested LWP of a multithreaded program.

This change required moving ptrace_update_lwp() out of unit scope,
and changing ptrace_machdep_dorequest() function to take a pointer
to pointer as the second argument, consistently with ptrace_regs().

I am planning to extend the ATF ptrace() register tests in the future
to check for regressions in multithreaded programs, as time permits.

Reviewed by kamil.
 1.22 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.21 02-Nov-2016  pgoyette branches: 1.21.16; 1.21.20;
* Split sys/kern/sys_process.c into three parts:
1 - ptrace(2) syscall for native emulation
2 - common ptrace(2) syscall code (shared with compat_netbsd32)
3 - support routines that are shared with PROCFS and/or KTRACE

* Add module glue for #1 and #2. Both modules will be built-in to the
kernel if "options PTRACE" is included in the config file (this is
the default, defined in sys/conf/std).

* Mark the ptrace(2) syscall as modular in syscalls.master (generated
files will be committed shortly).

* Conditionalize all remaining portions of PTRACE code on a new kernel
option PTRACE_HOOKS.

XXX Instead of PROCFS depending on 'options PTRACE', we should probably
just add a procfs attribute to the sys/kern/sys_process.c file's
entry in files.kern, and add PROCFS to the "#if defineds" for
process_domem(). It's really confusing to have two different ways
of requiring this file.
 1.20 08-Jul-2012  dsl branches: 1.20.2; 1.20.16; 1.20.20;
The MDP_USEDFPU (amd64 and sh3) and MDP_SSTEP (sh3) are lwp flags not
process ones, rename to MDL_xxx.
 1.19 28-Jan-2011  uwe branches: 1.19.4;
Implement PT_STEP.
 1.18 21-Nov-2009  rmind branches: 1.18.4; 1.18.6; 1.18.8;
Use lwp_getpcb() on mips, powerpc and sh3, clean from struct user usage.
 1.17 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.16 27-Oct-2008  uwe Implement PT___GETREGS40 and PT___SETREGS40 under COMPAT_40 so that
old gdb works on newer kernels.
 1.15 27-Oct-2008  uwe Compile conditionally depending on options PTRACE and COREDUMP.
 1.14 26-Oct-2008  uwe branches: 1.14.2;
process_read_regs, process_write_regs - handle reg::r_gbr
 1.13 04-Mar-2007  christos branches: 1.13.40; 1.13.44; 1.13.50;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.12 21-Jan-2006  uwe branches: 1.12.24;
ANSI'fy.
 1.11 24-Dec-2005  perry branches: 1.11.2;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.
 1.10 11-Dec-2005  christos merge ktrace-lwp.
 1.9 01-Jun-2005  scw branches: 1.9.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.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 18-Jan-2003  thorpej branches: 1.6.2;
Merge the nathanw_sa branch.
 1.5 29-Apr-2002  uch branches: 1.5.6;
remove #if 0 #endif
 1.4 03-Mar-2002  uch SR related parts moved to psl.h. cpufunc.h segments.h are removed.
kernel mode checking is only SR.MD. no check stack pointer.
 1.3 12-Feb-2002  uch ANSIfy KNF.
 1.2 13-Apr-2000  msaitoh branches: 1.2.8;
- save/restore more registers in process_{read,write}_regs()
- return EINVAL in process_sstep (temporary)
 1.1 13-Sep-1999  itojun branches: 1.1.2;
Merge in NetBSD/sh3 from cvs.kame.net repository.

Tree structure:
- sys/arch/sh3: sh3 generic code
As commented, in-chip device drivers are put into sys/arch/sh3/dev.
- sys/arch/evbsh3: sh3 evaluation boards (pure sh3 CPU, no fancy external HW)
- sys/arch/mmeye: Brains mmEye, www.brains.co.jp
MI source code includes couple of #ifdef for sh3-coff support.
(sh3 uses coff or elf)

Needs some more improvements, especialy in sys/arch/sh3/conf/files.sh3,
to compile the tree (due to last minute tree structure change).
 1.1.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.2.8.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.2.8.1 16-Mar-2002  jdolecek Catch up with -current.
 1.5.6.2 21-Jun-2002  thorpej Add support for scheduler activations on SuperH. Boots multi-user
on Dreamcast (SH4) with stock userland.
 1.5.6.1 29-Apr-2002  thorpej file process_machdep.c was added on branch nathanw_sa on 2002-06-21 21:26:33 +0000
 1.6.2.4 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.6.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.6.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.6.2.1 03-Aug-2004  skrll 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.11.2.1 01-Feb-2006  yamt sync with head.
 1.12.24.1 12-Mar-2007  rmind Sync with HEAD.
 1.13.50.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.13.44.2 11-Mar-2010  yamt sync with head
 1.13.44.1 04-May-2009  yamt sync with head.
 1.13.40.1 17-Jan-2009  mjf Sync with HEAD.
 1.14.2.1 19-Jan-2009  skrll Sync with HEAD.
 1.18.8.1 08-Feb-2011  bouyer Sync with HEAD
 1.18.6.1 06-Jun-2011  jruoho Sync with HEAD.
 1.18.4.1 05-Mar-2011  rmind sync with head
 1.19.4.1 30-Oct-2012  yamt sync with head
 1.20.20.1 04-Nov-2016  pgoyette Sync with HEAD
 1.20.16.1 05-Dec-2016  skrll Sync with HEAD
 1.20.2.1 03-Dec-2017  jdolecek update from HEAD
 1.21.20.1 18-Oct-2020  martin Pull up following revision(s) (requested by kamil in ticket #1117):

sys/arch/sh3/include/ptrace.h: revision 1.19
sys/arch/amd64/amd64/process_machdep.c: revision 1.48
sys/arch/sh3/sh3/process_machdep.c: revision 1.23
sys/arch/sh3/sh3/process_machdep.c: revision 1.24
sys/arch/i386/i386/process_machdep.c: revision 1.95
sys/arch/x86/x86/fpu.c (apply patch)
sys/kern/sys_ptrace_common.c: revision 1.84
sys/arch/powerpc/powerpc/process_machdep.c: revision 1.40
sys/sys/ptrace.h: revision 1.71
sys/arch/powerpc/powerpc/process_machdep.c: revision 1.41
(all via patch, adapted)

Fix s87_tw reconstruction to correctly indicate register states

Fix the code reconstructing s87_tw (full tag word) from fx_sw (abridged
tag word) to correctly represent all register states. The previous code
only distinguished between empty/non-empty registers, and assigned
'regular value' to all non-empty registers. The new code explicitly
distinguishes the two other tag word values: empty and special.

Fix the machine-dependent ptrace register-related requests (e.g.
PT_GETXMMREGS, PT_GETXSTATE on x86) to correctly respect the LWP number
passed as the data argument. Before this change, these requests
did not operate on the requested LWP of a multithreaded program.
This change required moving ptrace_update_lwp() out of unit scope,
and changing ptrace_machdep_dorequest() function to take a pointer
to pointer as the second argument, consistently with ptrace_regs().

I am planning to extend the ATF ptrace() register tests in the future
to check for regressions in multithreaded programs, as time permits.

Reviewed by kamil.

Add missing 'error' declaration
 1.21.16.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.6 05-Apr-2014  christos adjust to new signature; return consistent stuff. 0 is ok -1 is error
 1.5 11-Dec-2005  christos branches: 1.5.112; 1.5.122; 1.5.128;
merge ktrace-lwp.
 1.4 15-Jul-2003  lukem __KERNEL_RCSID()
 1.3 27-Mar-2002  uch branches: 1.3.2; 1.3.8; 1.3.14;
All the sh3 ports had an identical procfs_machdep.c, so use a common
file under arch/sh3/sh3.
 1.2 17-Jan-2001  itojun branches: 1.2.2;
procfs_machdep is per port (not per CPU).
 1.1 17-Jan-2001  fvdl Add machdep file for procfs. Currently only used for linux-style
/proc/cpuinfo (only active when procfs is mounted with -o linux).
For ports other than the i386 this currently produces an empty
string.
 1.2.2.1 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.3.14.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.3.14.2 18-Sep-2004  skrll Sync with HEAD.
 1.3.14.1 03-Aug-2004  skrll Sync with HEAD
 1.3.8.2 27-Mar-2002  uch All the sh3 ports had an identical procfs_machdep.c, so use a common
file under arch/sh3/sh3.
 1.3.8.1 27-Mar-2002  uch file procfs_machdep.c was added on branch nathanw_sa on 2002-03-27 10:44:40 +0000
 1.3.2.1 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.5.128.1 18-May-2014  rmind sync with head
 1.5.122.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 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.1 25-Jul-2011  dyoung Move some macros back to sh3/include/bus_funcs.h from
sh3/sh3/sh3_machdep.c, where I moved them by mistake.

Pull the bus_space(9) routines into a new module,
sh3/sh3/sh3_bus_space.c, that is built only on !landisk.

Fixes the mmeye and landisk builds. Should fix other sh3 ports.
 1.114 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.113 20-Dec-2023  thorpej branches: 1.113.2;
Remove unnecessary <sys/malloc.h>.
 1.112 23-Feb-2022  andvar fix various typos in comments, mainly immediatly/immediately/,
as well shared and recently fixed typos in OpenBSD code by Jonathan Grey.
 1.111 01-Nov-2021  thorpej Use "stack_t" instead of "struct sigaltstack", as the former is the
newer standardized name. NFC.
 1.110 11-Jun-2020  ad uvm_availmem(): give it a boolean argument to specify whether a recent
cached value will do, or if the very latest total must be fetched. It can
be called thousands of times a second and fetching the totals impacts not
only the calling LWP but other CPUs doing unrelated activity in the VM
system.
 1.109 31-Dec-2019  ad Rename uvm_free() -> uvm_availmem().
 1.108 21-Dec-2019  ad uvmexp.free -> uvm_free()
 1.107 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.106 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.105 22-Dec-2016  cherry branches: 1.105.8; 1.105.14; 1.105.16;
switch all ports to use uvm_init.c:uvm_md_init()

uvm_setpagesize() is now subsumed within this funciton.
 1.104 02-Nov-2016  pgoyette * Split sys/kern/sys_process.c into three parts:
1 - ptrace(2) syscall for native emulation
2 - common ptrace(2) syscall code (shared with compat_netbsd32)
3 - support routines that are shared with PROCFS and/or KTRACE

* Add module glue for #1 and #2. Both modules will be built-in to the
kernel if "options PTRACE" is included in the config file (this is
the default, defined in sys/conf/std).

* Mark the ptrace(2) syscall as modular in syscalls.master (generated
files will be committed shortly).

* Conditionalize all remaining portions of PTRACE code on a new kernel
option PTRACE_HOOKS.

XXX Instead of PROCFS depending on 'options PTRACE', we should probably
just add a procfs attribute to the sys/kern/sys_process.c file's
entry in files.kern, and add PROCFS to the "#if defineds" for
process_domem(). It's really confusing to have two different ways
of requiring this file.
 1.103 22-Nov-2015  tsutsui branches: 1.103.2;
Remove \n from set_cpumodel(), and explicitly print \n during boot instead.

Fixes dmesg on NetBSD/dreamcast 7.0 (and probably NetBSD/hpcsh 7.0):
---
NetBSD 7.0 (GENERIC.201509250726Z)
SEGA Dreamcasttotal memory = 16384 KB
avail memory = 13668 KB
---
which was mangled when cpu_getmode() and cpu_setmodel() were introduced:
http://mail-index.netbsd.org/source-changes/2014/03/24/msg053273.html

Should be pulled up to netbsd-7 and netbsd-7-0.
 1.102 24-Mar-2014  christos branches: 1.102.4; 1.102.6; 1.102.8;
use cpu_{g,s}etmodel
 1.101 21-Sep-2012  ryo branches: 1.101.2;
adapt for _UC_TLSBASE.

Approved by manu@ and msaitoh@
 1.100 08-Jul-2012  dsl branches: 1.100.2;
The MDP_USEDFPU (amd64 and sh3) and MDP_SSTEP (sh3) are lwp flags not
process ones, rename to MDL_xxx.
 1.99 21-May-2012  martin 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.98 19-Feb-2012  rmind Remove COMPAT_SA / KERN_SA. Welcome to 6.99.3!
Approved by core@.
 1.97 12-Feb-2012  matt branches: 1.97.2;
Change old-style function defintions to C89 prototypes.

Approved by releng.
 1.96 25-Jul-2011  dyoung branches: 1.96.2; 1.96.6;
Move some macros back to sh3/include/bus_funcs.h from
sh3/sh3/sh3_machdep.c, where I moved them by mistake.

Pull the bus_space(9) routines into a new module,
sh3/sh3/sh3_bus_space.c, that is built only on !landisk.

Fixes the mmeye and landisk builds. Should fix other sh3 ports.
 1.95 25-Jul-2011  dyoung Move the sh_memio_*() declarations back to sh3/include/bus_funcs.h.
Should fix the mmeye build.
 1.94 25-Jul-2011  dyoung #include <sys/bus.h>. Should fix most of the SH3 ports.
 1.93 20-Jul-2011  dyoung Remove redundant, static inline bus_space(9) declarations
from sh3/bus_funcs.h and move the non-inline definitions to
sh3/sh3_machdep.c.
 1.92 04-Mar-2011  joerg Refactor ps_strings access. Based on PK_32, write either the normal
version or the 32bit compat layout in execve1. Introduce a new function
copyin_psstrings for reading it back from userland and converting it to
the native layout. Refactor procfs to share most of the code with the
kern.proc_args sysctl handler.

This material is based upon work partially supported by
The NetBSD Foundation under a contract with Joerg Sonnenberger.
 1.91 24-Feb-2011  joerg 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.90 28-Jan-2011  uwe Implement PT_STEP.
 1.89 26-Jan-2011  uwe Clear MDP_SSTEP in setregs().
 1.88 14-Jan-2011  rmind branches: 1.88.2; 1.88.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.87 06-Nov-2010  uebayasi Machine dependent code is considered as part of UVM. Include
internal API header.
 1.86 08-Feb-2010  joerg branches: 1.86.2;
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.85 10-Dec-2009  matt branches: 1.85.2;
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.84 27-Nov-2009  rmind - Use uvm_lwp_setuarea() instead of directly setting address to lwp_t::l_addr.
- Replace most remaining uses of l_addr with uvm_lwp_getuarea() or lwp_getpcb().
- Amend assembly in ports where it accesses PCB via struct user.
- Rename L_ADDR to L_PCB in few places. Reduce sys/user.h inclusions.
 1.83 26-Nov-2009  matt Kill proc0paddr. Use lwp0.l_addr instead.
 1.82 21-Nov-2009  rmind Use lwp_getpcb() on mips, powerpc and sh3, clean from struct user usage.
 1.81 11-Aug-2009  matt Remove all declarations of physmem from sys/arch. Add an include of
<sys/systm.h> to the one file that did not already contain it.
This now means that physmem can be changed by updating systm.h and uvm_page.c
(excluding fixing printfs)
 1.80 18-Mar-2009  cegger Ansify function definitions w/o arguments. Generated with sed.
 1.79 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.78 22-Nov-2008  uwe branches: 1.78.4;
Move COMPAT_16 signal stuff to the new compat_16_machdep.c file, so
that it can be built as part of a module.
 1.77 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.76 15-Oct-2008  wrstuden branches: 1.76.2;
Merge wrstuden-revivesa into HEAD.
 1.75 02-Jul-2008  ad branches: 1.75.2;
Replce exec_map with a pool. Proposed on tech-kern@, reviewed by chs@.
 1.74 01-Jun-2008  uwe branches: 1.74.2;
Recycle unused _REG_EXPEVT slot in mcontext for _REG_GBR.

As the size of mcontext is not changed, we avoid the hassle of
versioning all the calls that use it.

_REG_EXPEVT was never used by any code in the tree. Reporting EXPEVT
makes sense only for signals and in that case we pass it to userland
in ksi_trap already which is official MI way to get this (MD) information.

Old binaries running on new kernels will now have their GBR set from
new mcontext, but that's ok too, as GBR was not properly supported by
old kernels (not saved in trapframe), so old binaries couldn't have
possibly used it anyway.
 1.73 01-Jun-2008  uwe Add GBR register to trapframe.
 1.72 28-Apr-2008  martin branches: 1.72.2;
Remove clause 3 and 4 from TNF licenses
 1.71 24-Apr-2008  ad branches: 1.71.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.70 22-Mar-2008  uwe branches: 1.70.2;
Revert interrupt stack changes. There are some issues and, at least
in the current form, they complicate implementation of fast software
interrupts. I'd rather get fast softints in now and may be revisit
interrupt stack later.
 1.69 15-Feb-2008  uwe branches: 1.69.6;
G/c vestiges of curpute hack that was obsoleted by the fast TLB miss handler.
 1.68 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.67 14-Dec-2007  uwe Use dedicated interrupt stack. Tested on hpcsh and landisk. This has
been sitting in my tree for quite a while. While here s/top/bottom/
in a few places related to stacks to confirm to conventional
terminology.
 1.66 17-Oct-2007  garbled branches: 1.66.2; 1.66.4; 1.66.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.65 14-Oct-2007  uwe For KSTACK_DEBUG fill lwp0 switchframe with 0xb4 too to match
what we do to other lwps in sh3_setup_uarea in vm_machdep.c.
 1.64 20-Aug-2007  uwe branches: 1.64.2; 1.64.4;
Fix couple of whitespace glitches.
 1.63 08-Jul-2007  pooka branches: 1.63.4; 1.63.8;
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.62 04-Mar-2007  christos branches: 1.62.2; 1.62.4; 1.62.10;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.61 22-Feb-2007  thorpej TRUE -> true, FALSE -> false
 1.60 09-Feb-2007  ad branches: 1.60.2;
Merge newlock2 to head.
 1.59 04-Mar-2006  uwe branches: 1.59.14;
s/u_intN_t/uintN_t/
 1.58 21-Jan-2006  uwe branches: 1.58.2; 1.58.4;
Add lint comments. Hide computed goto in cpu_reset() from lint.
Remove infinite loop from cpu_reset(), gcc accepts computed goto as
the sign that function never returns.
 1.57 24-Dec-2005  perry branches: 1.57.2;
__asm__ -> __asm
__const__ -> const
__inline__ -> inline
__volatile__ -> volatile
 1.56 11-Dec-2005  christos merge ktrace-lwp.
 1.55 25-Apr-2005  lukem branches: 1.55.2;
Move the MI printing of `copyright' to the MD cpu_startup() code
where the printing of `version' is already performed.
This has the benefit of allowing the copyright to be available
via dmesg(8) on platforms which need the `msgbuf' to be setup
in cpu_startup() before printed output is remembered.
 1.54 30-Dec-2003  pk branches: 1.54.8;
Replace the traditional buffer memory management -- based on fixed per buffer
virtual memory reservation and a private pool of memory pages -- by a scheme
based on memory pools.

This allows better utilization of memory because buffers can now be allocated
with a granularity finer than the system's native page size (useful for
filesystems with e.g. 1k or 2k fragment sizes). It also avoids fragmentation
of virtual to physical memory mappings (due to the former fixed virtual
address reservation) resulting in better utilization of MMU resources on some
platforms. Finally, the scheme is more flexible by allowing run-time decisions
on the amount of memory to be used for buffers.

On the other hand, the effectiveness of the LRU queue for buffer recycling
may be somewhat reduced compared to the traditional method since, due to the
nature of the pool based memory allocation, the actual least recently used
buffer may release its memory to a pool different from the one needed by a
newly allocated buffer. However, this effect will kick in only if the
system is under memory pressure.
 1.53 23-Nov-2003  uwe Implement siginfo for sh3.
 1.52 26-Sep-2003  simonb Fix "constify sendsig/trapsignal" fallout for non-siginfo'd archs. Test
compiled on most architectures.
 1.51 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.50 03-Aug-2003  uwe When passing &buffers to uvm_map, add a cast to (void *). Without it,
gcc3 with -O2 produces "dereferencing type-punned pointer will break
strict-aliasing rules" warning.
 1.49 15-Jul-2003  lukem __KERNEL_RCSID()
 1.48 11-Apr-2003  nathanw branches: 1.48.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.47 02-Apr-2003  thorpej Use PAGE_SIZE rather than NBPG.
 1.46 18-Jan-2003  thorpej Merge the nathanw_sa branch.
 1.45 25-Aug-2002  thorpej Make nbuf, nswbuf, and bufpages unsigned. Make all operations on these
variables unsigned, and update places where their values are printed.
 1.44 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.43 23-Jun-2002  thorpej When delivering a signal, arrange for the handler to be invoked
directly. The trampoline is now used only for the return, and
makes it another 2 instructions shorter.
 1.42 23-Jun-2002  thorpej When delivering a signal, don't push the signum, code, and context pointer,
or handler onto the stack. Instead, just stuff them into the correct
argument registers (handler is a "4th arg").
 1.41 10-May-2002  uch branches: 1.41.2; 1.41.6;
remove COMPAT_13 staff. No 1.3 release of sh3 port. these are trace of
i386 port.
 1.40 09-May-2002  uch new pmap designed for SH3/SH4.
 1.39 29-Apr-2002  uch remove #if 0 #endif
 1.38 28-Apr-2002  uch Use "#define<tab>", white space nits.
 1.37 22-Apr-2002  uch make these compile with gcc -O0
 1.36 24-Mar-2002  uch Rework interrupt code.
+ Fully utilize SH SR.I[0:3] interrupt level.
+ software interrupt is emulated by TMU1, 2 one shot interrupt.
+ implement generic soft interrupts.
+ implement clockframe correctly.
 1.35 18-Mar-2002  itojun s/PS_STRINGS/p->p_psstr/, as requested by christos
 1.34 17-Mar-2002  uch cosmetic changes, fix comments.
 1.33 17-Mar-2002  uch kernel stack fix. old code simply P3 address converted to P1, it
caused memory destruction when kernel stack grow over 1 page. new
code use P3 address for kernel stack. but for the sake of debug, P1
kernel stack mode remain.
 1.32 10-Mar-2002  uch proc0 and page table intialize routines are moved to sh3_machdep.c
 1.31 06-Mar-2002  tsutsui Change type of dumpmag to u_int32_t since it is actually
a 32bit unsigned magic number.
As per discussion on tech-kern, and fixes port-sparc64/11949.
 1.30 02-Mar-2002  uch Initial support for KGDB on the sh3.
 1.29 28-Feb-2002  uch cpu_reset:
Set EXPEVT to 0x20(manual reset) before jump to reset vector.
 1.28 28-Feb-2002  uch cpu_dumpconf, reserve_dumppages, dumpsys, cpu_reset are moved to sh3/sh3_machdep.c
 1.27 28-Feb-2002  uch Cleanup register definition
 1.26 24-Feb-2002  uch Move common exception vector and scheduler code to
sh3/sh3/exception_vector.S and sh3/sh3/locore_subr.S. exception
vectors are installed by sh_cpu_init(). machine/locore.S contains
kernel entry, interrupt handler, and some MD code.
 1.25 22-Feb-2002  uch New NetBSD/sh3 clock framework.
+ hardclock source is moved from TMU1 to TMU0.
+ SH3/SH4 common kernel support.
+ PCLOCK estimation.
+ remove duplicated code.
 1.24 17-Feb-2002  uch sh_cpu_init() is added. its initialize cache, MMU ops appropriately.
machine locore code call this at first.
 1.23 12-Feb-2002  uch ANSIfy KNF.
 1.22 11-Feb-2002  uch add new cache routine.
 1.21 03-Feb-2002  thorpej In setregs(), pass PS_STRINGS in r9.
 1.20 01-Feb-2002  uch if PCLOCK isn't setted, use estimated value calculated by kernel.
 1.19 28-Sep-2001  chs don't depend on other headers to include sys/proc.h for us.
 1.18 10-Sep-2001  chris Update pmap_update to now take the updated pmap as an argument.
This will allow improvements to the pmaps so that they can more easily defer expensive operations, eg tlb/cache flush, til the last possible moment.

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

Reviewed by Jason.
 1.17 01-Sep-2001  msaitoh branches: 1.17.2;
s/cpu_startup/sh3_startup/g in panic messages
 1.16 12-Aug-2001  jdolecek Move _insque()/_remque() to libkern. Once remaining uses would
be converted to <sys/queue.h> macros, _insque()/_remque() would be eliminated
altogether.
 1.15 02-Jun-2001  chs branches: 1.15.2;
replace vm_map{,_entry}_t with struct vm_map{,_entry} *.
 1.14 30-May-2001  lukem add missing #include "opt_kgdb.h"
 1.13 16-May-2001  msaitoh sigreturn() fix (from kleink)
 1.12 24-Apr-2001  thorpej Sprinkle pmap_update() calls after calls to:
- pmap_enter()
- pmap_remove()
- pmap_protect()
- pmap_kenter_pa()
- pmap_kremove()
as described in pmap(9).

These calls are relatively conservative. It may be possible to
optimize these a little more.
 1.11 15-Mar-2001  chs eliminate the KERN_* error codes in favor of the traditional E* codes.
the mapping is:

KERN_SUCCESS 0
KERN_INVALID_ADDRESS EFAULT
KERN_PROTECTION_FAILURE EACCES
KERN_NO_SPACE ENOMEM
KERN_INVALID_ARGUMENT EINVAL
KERN_FAILURE various, mostly turn into KASSERTs
KERN_RESOURCE_SHORTAGE ENOMEM
KERN_NOT_RECEIVER <unused>
KERN_NO_ACCESS <unused>
KERN_PAGES_LOCKED <unused>
 1.10 22-Dec-2000  jdolecek branches: 1.10.2;
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.9 13-Sep-2000  thorpej Add an align argument to uvm_map() and some callers of that
routine. Works similarly fto pmap_prefer(), but allows callers
to specify a minimum power-of-two alignment of the region.
How we ever got along without this for so long is beyond me.
 1.8 29-Jun-2000  mrg remove include of <vm/vm.h>. <vm/vm.h> -> <uvm/uvm_extern.h>
 1.7 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.6 26-May-2000  thorpej branches: 1.6.4;
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.5 25-Apr-2000  tsubai Use P1SEG to map pool pages.
 1.4 06-Feb-2000  msaitoh remove COMPAT_NOMID stuff
 1.3 19-Jan-2000  thorpej Move callout initialization to a single location; no need to duplicate
that code all over the place.
 1.2 04-Dec-1999  ragge CL* discarding.
 1.1 21-Sep-1999  tsubai branches: 1.1.2; 1.1.8;
Move common parts of machdep.c to sh3_machdep.c.
 1.1.8.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.1.2.3 27-Mar-2001  bouyer Sync with HEAD.
 1.1.2.2 05-Jan-2001  bouyer Sync with HEAD
 1.1.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.6.4.1 26-May-2001  he Pull up revision 1.13 (requested by kleink):
Validate Status Register passed from userland in sigreturn().
 1.10.2.2 21-Jun-2001  nathanw Catch up to -current.
 1.10.2.1 09-Apr-2001  nathanw Catch up with -current.
 1.15.2.7 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.15.2.6 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.15.2.5 16-Mar-2002  jdolecek Catch up with -current.
 1.15.2.4 11-Feb-2002  jdolecek Sync w/ -current.
 1.15.2.3 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.15.2.2 13-Sep-2001  thorpej Update the kqueue branch to HEAD.
 1.15.2.1 25-Aug-2001  thorpej Merge Aug 24 -current into the kqueue branch.
 1.17.2.1 01-Oct-2001  fvdl Catch up with -current.
 1.41.6.9 27-Aug-2002  nathanw Catch up to -current.
 1.41.6.8 10-Aug-2002  thorpej Garbage-collect upcallcode.
 1.41.6.7 02-Aug-2002  nathanw LWPify sigexit() call.
 1.41.6.6 01-Aug-2002  nathanw Catch up to -current.
 1.41.6.5 05-Jul-2002  thorpej When delivering an upcall, invoke the upcall directly, using the
trampoline only to exit if the upcall returns.
 1.41.6.4 24-Jun-2002  nathanw Curproc->curlwp renaming.

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

"curproc" is now #defined in proc.h as ((curlwp) ? (curlwp)->l_proc) : NULL)
so that it is always safe to reference curproc (*de*referencing curproc
is another story, but that's always been true).
 1.41.6.3 21-Jun-2002  thorpej Add support for scheduler activations on SuperH. Boots multi-user
on Dreamcast (SH4) with stock userland.
 1.41.6.2 20-Jun-2002  thorpej Machine-dependent kernel portion of {get,set}context(). From
Klaus Klein.
 1.41.6.1 10-May-2002  thorpej file sh3_machdep.c was added on branch nathanw_sa on 2002-06-20 23:00:51 +0000
 1.41.2.2 31-Aug-2002  gehenna catch up with -current.
 1.41.2.1 17-Jul-2002  gehenna catch up with -current.
 1.48.2.4 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.48.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.48.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.48.2.1 03-Aug-2004  skrll Sync with HEAD
 1.54.8.1 29-Apr-2005  kent sync with -current
 1.55.2.7 24-Mar-2008  yamt sync with head.
 1.55.2.6 27-Feb-2008  yamt sync with head.
 1.55.2.5 21-Jan-2008  yamt sync with head
 1.55.2.4 27-Oct-2007  yamt sync with head.
 1.55.2.3 03-Sep-2007  yamt sync with head.
 1.55.2.2 26-Feb-2007  yamt sync with head.
 1.55.2.1 21-Jun-2006  yamt sync with head.
 1.57.2.1 01-Feb-2006  yamt sync with head.
 1.58.4.1 22-Apr-2006  simonb Sync with head.
 1.58.2.1 09-Sep-2006  rpaulo sync with head
 1.59.14.2 01-Feb-2007  ad Get sh3 compiling.
 1.59.14.1 30-Jan-2007  ad Remove support for SA. Ok core@.
 1.60.2.2 12-Mar-2007  rmind Sync with HEAD.
 1.60.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.62.10.2 16-Oct-2007  garbled Sync with HEAD
 1.62.10.1 03-Oct-2007  garbled Sync with HEAD
 1.62.4.1 11-Jul-2007  mjf Sync with head.
 1.62.2.3 23-Oct-2007  ad Sync with head.
 1.62.2.2 09-Oct-2007  ad Sync with head.
 1.62.2.1 15-Jul-2007  ad Sync with head.
 1.63.8.2 26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.63.8.1 03-Sep-2007  jmcneill Sync with HEAD.
 1.63.4.1 03-Sep-2007  skrll Sync with HEAD.
 1.64.4.1 18-Oct-2007  yamt sync with head.
 1.64.2.3 23-Mar-2008  matt sync with HEAD
 1.64.2.2 09-Jan-2008  matt sync with HEAD
 1.64.2.1 06-Nov-2007  matt sync with HEAD
 1.66.8.1 02-Jan-2008  bouyer Sync with HEAD
 1.66.4.1 26-Dec-2007  ad Sync with head.
 1.66.2.1 18-Feb-2008  mjf Sync with HEAD.
 1.69.6.4 17-Jan-2009  mjf Sync with HEAD.
 1.69.6.3 02-Jul-2008  mjf Sync with HEAD.
 1.69.6.2 02-Jun-2008  mjf Sync with HEAD.
 1.69.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.70.2.2 04-Jun-2008  yamt sync with head
 1.70.2.1 18-May-2008  yamt sync with head.
 1.71.2.4 11-Mar-2010  yamt sync with head
 1.71.2.3 19-Aug-2009  yamt sync with head.
 1.71.2.2 04-May-2009  yamt sync with head.
 1.71.2.1 16-May-2008  yamt sync with head.
 1.72.2.5 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.72.2.4 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.72.2.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.72.2.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.72.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.74.2.1 03-Jul-2008  simonb Sync with head.
 1.75.2.2 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.75.2.1 19-Oct-2008  haad Sync with HEAD.
 1.76.2.2 28-Apr-2009  skrll Sync with HEAD.
 1.76.2.1 19-Jan-2009  skrll Sync with HEAD.
 1.78.4.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.85.2.2 27-May-2010  uebayasi Fix build.
 1.85.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.86.2.1 05-Mar-2011  rmind sync with head
 1.88.4.2 05-Mar-2011  bouyer Sync with HEAD
 1.88.4.1 08-Feb-2011  bouyer Sync with HEAD
 1.88.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.96.6.3 02-Jun-2012  mrg sync to latest -current.
 1.96.6.2 24-Feb-2012  mrg sync to -current.
 1.96.6.1 18-Feb-2012  mrg merge to -current.
 1.96.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.96.2.3 30-Oct-2012  yamt sync with head
 1.96.2.2 23-May-2012  yamt sync with head.
 1.96.2.1 17-Apr-2012  yamt sync with head
 1.97.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.100.2.3 03-Dec-2017  jdolecek update from HEAD
 1.100.2.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.100.2.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.101.2.1 18-May-2014  rmind sync with head
 1.102.8.2 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.102.8.1 26-Dec-2015  snj Pull up following revision(s) (requested by tsutsui in ticket #1051):
sys/arch/sh3/sh3/sh3_machdep.c: revision 1.103
sys/arch/landisk/landisk/machdep.c: revision 1.18
Remove \n from set_cpumodel(), and explicitly print \n during boot instead.
Fixes dmesg on NetBSD/dreamcast 7.0 (and probably NetBSD/hpcsh 7.0):
---
NetBSD 7.0 (GENERIC.201509250726Z)
SEGA Dreamcasttotal memory = 16384 KB
avail memory = 13668 KB
---
which was mangled when cpu_getmode() and cpu_setmodel() were introduced:
http://mail-index.netbsd.org/source-changes/2014/03/24/msg053273.html
 1.102.6.3 05-Feb-2017  skrll Sync with HEAD
 1.102.6.2 05-Dec-2016  skrll Sync with HEAD
 1.102.6.1 27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.102.4.2 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.102.4.1 26-Dec-2015  snj branches: 1.102.4.1.4;
Pull up following revision(s) (requested by tsutsui in ticket #1051):
sys/arch/landisk/landisk/machdep.c: revision 1.18
sys/arch/sh3/sh3/sh3_machdep.c: revision 1.103
Remove \n from set_cpumodel(), and explicitly print \n during boot instead.
Fixes dmesg on NetBSD/dreamcast 7.0 (and probably NetBSD/hpcsh 7.0):
---
NetBSD 7.0 (GENERIC.201509250726Z)
SEGA Dreamcasttotal memory = 16384 KB
avail memory = 13668 KB
---
which was mangled when cpu_getmode() and cpu_setmodel() were introduced:
http://mail-index.netbsd.org/source-changes/2014/03/24/msg053273.html
 1.102.4.1.4.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.103.2.2 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.103.2.1 04-Nov-2016  pgoyette Sync with HEAD
 1.105.16.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.105.16.1 10-Jun-2019  christos Sync with HEAD
 1.105.14.1 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.105.8.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.113.2.1 02-Aug-2025  perseant Sync with HEAD
 1.4 10-May-2002  uch branches: 1.4.4;
clean up disassembler code.
 1.3 04-Sep-2000  tsubai branches: 1.3.2; 1.3.6;
Downcase mnemonics.
 1.2 04-Sep-2000  tsubai Disassembly support in DDB.
 1.1 01-Sep-2000  msaitoh sh3 disassembler written by Akinori Koketsu.
 1.3.6.1 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.3.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.3.2.1 04-Sep-2000  bouyer file sh3disasm.c was added on branch thorpej_scsipi on 2000-11-20 20:24:33 +0000
 1.4.4.2 10-May-2002  uch clean up disassembler code.
 1.4.4.1 10-May-2002  uch file sh3disasm.c was added on branch nathanw_sa on 2002-05-10 15:27:06 +0000
 1.14 02-Mar-2018  uwe Introduce sh3/sysarch.h and add SH3_SYNC_ICACHE
 1.13 22-Dec-2007  dsl branches: 1.13.12;
Fix the remaining sys_sysarch() stub function.
 1.12 09-Feb-2007  ad branches: 1.12.24; 1.12.32; 1.12.36;
Merge newlock2 to head.
 1.11 11-Dec-2005  christos branches: 1.11.20;
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 15-Jul-2003  lukem __KERNEL_RCSID()
 1.8 18-Jan-2003  thorpej branches: 1.8.2;
Merge the nathanw_sa branch.
 1.7 10-May-2002  uch branches: 1.7.6;
cosmetic changes.
 1.6 03-Mar-2002  uch SR related parts moved to psl.h. cpufunc.h segments.h are removed.
kernel mode checking is only SR.MD. no check stack pointer.
 1.5 12-Feb-2002  uch ANSIfy KNF.
 1.4 29-Jun-2000  mrg branches: 1.4.4;
remove include of <vm/vm.h>. <vm/vm.h> -> <uvm/uvm_extern.h>
 1.3 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.2 13-Apr-2000  msaitoh remove sys_vtrace()
 1.1 13-Sep-1999  itojun branches: 1.1.2;
Merge in NetBSD/sh3 from cvs.kame.net repository.

Tree structure:
- sys/arch/sh3: sh3 generic code
As commented, in-chip device drivers are put into sys/arch/sh3/dev.
- sys/arch/evbsh3: sh3 evaluation boards (pure sh3 CPU, no fancy external HW)
- sys/arch/mmeye: Brains mmEye, www.brains.co.jp
MI source code includes couple of #ifdef for sh3-coff support.
(sh3 uses coff or elf)

Needs some more improvements, especialy in sys/arch/sh3/conf/files.sh3,
to compile the tree (due to last minute tree structure change).
 1.1.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.4.4.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.4.4.1 16-Mar-2002  jdolecek Catch up with -current.
 1.7.6.2 21-Jun-2002  thorpej Add support for scheduler activations on SuperH. Boots multi-user
on Dreamcast (SH4) with stock userland.
 1.7.6.1 10-May-2002  thorpej file sys_machdep.c was added on branch nathanw_sa on 2002-06-21 21:26:34 +0000
 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.2 21-Jan-2008  yamt sync with head
 1.10.16.1 26-Feb-2007  yamt sync with head.
 1.11.20.1 30-Jan-2007  ad Remove support for SA. Ok core@.
 1.12.36.1 02-Jan-2008  bouyer Sync with HEAD
 1.12.32.1 26-Dec-2007  ad Sync with head.
 1.12.24.1 09-Jan-2008  matt sync with HEAD
 1.13.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.13.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.16 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.15 26-Jun-2013  matt branches: 1.15.34;
Collapse syscall_fancy/syscall_plain to syscall and p_trace_enabled.
Use sy_invoke
 1.14 19-Feb-2012  rmind branches: 1.14.2;
Remove COMPAT_SA / KERN_SA. Welcome to 6.99.3!
Approved by core@.
 1.13 20-Dec-2010  matt branches: 1.13.8; 1.13.12;
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.12 21-Oct-2008  ad branches: 1.12.16;
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.11 15-Oct-2008  wrstuden Merge wrstuden-revivesa into HEAD.
 1.10 06-Feb-2008  dsl branches: 1.10.6; 1.10.10; 1.10.12; 1.10.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.9 05-Jan-2008  dsl Don't pass 'curlwp' into trace_enter() and trace_exit().
 1.8 04-Mar-2007  christos branches: 1.8.20; 1.8.26; 1.8.32;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.7 09-Feb-2007  ad branches: 1.7.2;
Merge newlock2 to head.
 1.6 07-Mar-2006  thorpej branches: 1.6.2; 1.6.10; 1.6.14;
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.5 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.4 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.3 05-Mar-2006  christos branches: 1.3.2;
implement PT_SYSCALL
 1.2 11-Dec-2005  christos branches: 1.2.4; 1.2.6;
merge ktrace-lwp.
 1.1 10-Jul-2005  uwe branches: 1.1.6;
Implement syscall_intern for sh3.
 1.1.6.2 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.1.6.1 10-Jul-2005  skrll file syscall.c was added on branch ktrace-lwp on 2005-11-10 13:58:38 +0000
 1.2.6.1 22-Apr-2006  simonb Sync with head.
 1.2.4.1 09-Sep-2006  rpaulo sync with head
 1.3.2.2 13-Mar-2006  yamt sync with head.
 1.3.2.1 05-Mar-2006  yamt file syscall.c was added on branch yamt-pdpolicy on 2006-03-13 09:07:02 +0000
 1.6.14.1 30-Jan-2007  ad Remove support for SA. Ok core@.
 1.6.10.6 11-Feb-2008  yamt sync with head.
 1.6.10.5 21-Jan-2008  yamt sync with head
 1.6.10.4 03-Sep-2007  yamt sync with head.
 1.6.10.3 26-Feb-2007  yamt sync with head.
 1.6.10.2 21-Jun-2006  yamt sync with head.
 1.6.10.1 07-Mar-2006  yamt file syscall.c was added on branch yamt-lazymbuf on 2006-06-21 14:55:39 +0000
 1.6.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.6.2.1 07-Mar-2006  thorpej file syscall.c was added on branch elad-kernelauth on 2006-03-07 07:21:51 +0000
 1.7.2.1 12-Mar-2007  rmind Sync with HEAD.
 1.8.32.1 08-Jan-2008  bouyer Sync with HEAD
 1.8.26.1 18-Feb-2008  mjf Sync with HEAD.
 1.8.20.2 23-Mar-2008  matt sync with HEAD
 1.8.20.1 09-Jan-2008  matt sync with HEAD
 1.10.16.2 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.10.16.1 19-Oct-2008  haad Sync with HEAD.
 1.10.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.10.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.10.10.1 04-May-2009  yamt sync with head.
 1.10.6.1 17-Jan-2009  mjf Sync with HEAD.
 1.12.16.1 05-Mar-2011  rmind sync with head
 1.13.12.1 24-Feb-2012  mrg sync to -current.
 1.13.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.13.8.1 17-Apr-2012  yamt sync with head
 1.14.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.15.34.1 10-Jun-2019  christos Sync with HEAD
 1.41 09-May-2002  uch branches: 1.41.4;
rework general exception, and TLB exception handling for new pmap.
all exception staffs are moved to exception.[ch]
 1.40 28-Apr-2002  uch Use "#define<tab>", white space nits.
 1.39 24-Mar-2002  uch Rework interrupt code.
+ Fully utilize SH SR.I[0:3] interrupt level.
+ software interrupt is emulated by TMU1, 2 one shot interrupt.
+ implement generic soft interrupts.
+ implement clockframe correctly.
 1.38 17-Mar-2002  uch change to per-process AST.
 1.37 03-Mar-2002  uch SR related parts moved to psl.h. cpufunc.h segments.h are removed.
kernel mode checking is only SR.MD. no check stack pointer.
 1.36 02-Mar-2002  uch Initial support for KGDB on the sh3.
 1.35 28-Feb-2002  uch Cleanup register definition
 1.34 24-Feb-2002  uch Move common exception vector and scheduler code to
sh3/sh3/exception_vector.S and sh3/sh3/locore_subr.S. exception
vectors are installed by sh_cpu_init(). machine/locore.S contains
kernel entry, interrupt handler, and some MD code.
 1.33 19-Feb-2002  uch Clean up functions
disable_intr, enable_intr, disable_interrupt, enable_interrupt,
disable_ext_intr, enable_ext_intr.
New functions:
for external interrupt:
_cpu_intr_suspend and _cpu_intr_resume.
for exception:
_cpu_exception_suspend and _cpu_exception_resume.
 1.32 17-Feb-2002  uch Add new MMU API. for detail, see sh3/mmu.h's comment.
 1.31 14-Feb-2002  chs allow writing to write-only mappings. fixes PR 3493.
 1.30 11-Feb-2002  uch wrap #ifdef SH4
 1.29 11-Feb-2002  uch change PTE PG_* bit define to support SH4 PCMCIA space attribute fully.
for detail, see pte.h.
 1.28 10-Aug-2001  msaitoh fix a ldtlb handling bug:

- set to PTE{H,L,A} and call LDTLB must do atomically.
- never call LDTLB when it's unnecessary.

Broken kernel oocasionally causes cpu reset when /etc/security is called.
Now fix this problem.
 1.27 24-Jun-2001  msaitoh branches: 1.27.2;
fix KERNELMODE() macro (check MD bits, too)
 1.26 02-Jun-2001  chs replace vm_map{,_entry}_t with struct vm_map{,_entry} *.
 1.25 30-May-2001  lukem add missing #include "opt_kgdb.h"
 1.24 18-Mar-2001  chs missed some KERN_FAILUREs.
 1.23 15-Mar-2001  chs eliminate the KERN_* error codes in favor of the traditional E* codes.
the mapping is:

KERN_SUCCESS 0
KERN_INVALID_ADDRESS EFAULT
KERN_PROTECTION_FAILURE EACCES
KERN_NO_SPACE ENOMEM
KERN_INVALID_ARGUMENT EINVAL
KERN_FAILURE various, mostly turn into KASSERTs
KERN_RESOURCE_SHORTAGE ENOMEM
KERN_NOT_RECEIVER <unused>
KERN_NO_ACCESS <unused>
KERN_PAGES_LOCKED <unused>
 1.22 06-Mar-2001  thorpej Clean up TLB trap handling a little.
- When printing a user trap, include p->p_comm in the message.
- In the TLB fault handler, don't just go charging along if
the fault can't be handled. If we get a fatal kernel TLB
fault, we need to panic! Or, if DDB is enabled, call the
Debugger().
 1.21 22-Nov-2000  msaitoh branches: 1.21.2;
const struct sysent
 1.20 08-Nov-2000  msaitoh check whether SH4_PCMCIA is defined or not.
fixes PR. 11441.
 1.19 08-Sep-2000  msaitoh remove extra #endif
 1.18 08-Sep-2000  msaitoh sync with i386's revision 1.133:

It's legal to mmap pages in the lower part of the stack (<limit),
and use them, so allow this by relaxing the check for it.
 1.17 04-Sep-2000  tsubai Add DDB hook.
 1.16 09-Aug-2000  msaitoh 2nd argument of SYS___syscall(code, ...) is quad alignmented.
On little endian mode, 1st argument is not r5 but r4.
 1.15 29-Jun-2000  mrg remove include of <vm/vm.h>. <vm/vm.h> -> <uvm/uvm_extern.h>
 1.14 07-Jun-2000  tsubai branches: 1.14.2;
child_return() should take void *arg.
 1.13 06-Jun-2000  soren defopt SYSCALL_DEBUG.
 1.12 27-May-2000  sommerfeld branches: 1.12.2;
Reduce use of curproc in several places:

- Change ktrace interface to pass in the current process, rather than
p->p_tracep, since the various ktr* function need curproc anyway.

- Add curproc as a parameter to mi_switch() since all callers had it
handy anyway.

- Add a second proc argument for inferior() since callers all had
curproc handy.

Also, miscellaneous cleanups in ktrace:

- ktrace now always uses file-based, rather than vnode-based I/O
(simplifies, increases type safety); eliminate KTRFLAG_FD & KTRFAC_FD.
Do non-blocking I/O, and yield a finite number of times when receiving
EWOULDBLOCK before giving up.

- move code duplicated between sys_fktrace and sys_ktrace into ktrace_common.

- simplify interface to ktrwrite()
 1.11 26-May-2000  thorpej 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.10 24-May-2000  thorpej Use preempt(), not an open-coded equivalent (which won't be
equivalent for long).
 1.9 20-Apr-2000  msaitoh add a copyfault routine into the TLB miss handler
 1.8 13-Apr-2000  msaitoh Catch the breakpoint trap ("trapa #0xc3") and send SIGTRAP.
Now works breakpoint and continue!

TODO: single step
 1.7 24-Feb-2000  msaitoh SH4!
 1.6 24-Feb-2000  msaitoh multiple interrputs!!!
 1.5 03-Jan-2000  msaitoh userret() if the user process will be killed.
Now the NetBSD/sh3 works very stable!
 1.4 05-Dec-1999  ragge clrnd()/clbase() discarding.
 1.3 21-Oct-1999  msaitoh print a trap type in hexadecimal instead of decimal.
 1.2 14-Sep-1999  tsubai branches: 1.2.2; 1.2.4; 1.2.6;
Catch up with -current.
 1.1 13-Sep-1999  itojun Merge in NetBSD/sh3 from cvs.kame.net repository.

Tree structure:
- sys/arch/sh3: sh3 generic code
As commented, in-chip device drivers are put into sys/arch/sh3/dev.
- sys/arch/evbsh3: sh3 evaluation boards (pure sh3 CPU, no fancy external HW)
- sys/arch/mmeye: Brains mmEye, www.brains.co.jp
MI source code includes couple of #ifdef for sh3-coff support.
(sh3 uses coff or elf)

Needs some more improvements, especialy in sys/arch/sh3/conf/files.sh3,
to compile the tree (due to last minute tree structure change).
 1.2.6.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.2.4.1 15-Nov-1999  fvdl Sync with -current
 1.2.2.5 27-Mar-2001  bouyer Sync with HEAD.
 1.2.2.4 12-Mar-2001  bouyer Sync with HEAD.
 1.2.2.3 08-Dec-2000  bouyer Sync with HEAD.
 1.2.2.2 22-Nov-2000  bouyer Sync with HEAD.
 1.2.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.12.2.1 22-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.14.2.3 25-Nov-2001  he Pull up revision 1.28 (via patch, requested by msaitoh):
Fix LDTLB handling bug.
 1.14.2.2 08-Oct-2001  he Pull up revisions 1.20,1.27 (via patch, requested by msaitoh):
Add missing SH4_PCMCIA cases. Fixes PR#11441.
Fix KERNELMODE macro (check MD bits too).
 1.14.2.1 18-Aug-2000  msaitoh Pullup revision 1.16 (approved by thorpej):

fix a byte-order bug.
(2nd argument of SYS___syscall(code, ...) is quad alignmented.
On little endian mode, 1st argument is not r5 but r4).
 1.21.2.2 21-Jun-2001  nathanw Catch up to -current.
 1.21.2.1 09-Apr-2001  nathanw Catch up with -current.
 1.27.2.3 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.27.2.2 16-Mar-2002  jdolecek Catch up with -current.
 1.27.2.1 25-Aug-2001  thorpej Merge Aug 24 -current into the kqueue branch.
 1.41.4.2 09-May-2002  uch rework general exception, and TLB exception handling for new pmap.
all exception staffs are moved to exception.[ch]
 1.41.4.1 09-May-2002  uch file trap.c was added on branch nathanw_sa on 2002-05-09 12:24:22 +0000
 1.84 20-Dec-2023  thorpej Remove unnecessary <sys/malloc.h>.
 1.83 06-Oct-2023  skrll Convert the l2->l_md.md_astpending assignments into KASSERTs.

l_md is zeroised by lwp_create with

memset(&l2->l_startzero, 0, sizeof(*l2) -
offsetof(lwp_t, l_startzero));
 1.82 24-May-2022  andvar fix various typos in comments, docs and log messages.
 1.81 30-Nov-2020  msaitoh s/ we we / we /
 1.80 06-Apr-2019  kamil branches: 1.80.12;
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.79 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.78 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.77 23-Dec-2016  cherry branches: 1.77.16;
"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.76 07-Nov-2013  christos branches: 1.76.6; 1.76.10;
fix unused variables
 1.75 19-Feb-2012  rmind branches: 1.75.2; 1.75.4;
Remove COMPAT_SA / KERN_SA. Welcome to 6.99.3!
Approved by core@.
 1.74 13-Feb-2012  martin add missing MD code for posix_spawn
 1.73 13-Jun-2011  uch branches: 1.73.2; 1.73.6;
include uvm_page.h for vm_physmem[]
 1.72 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.71 10-Feb-2011  pooka branches: 1.71.2;
Make vmapbuf() return success/error and make physio deal with a
failure.
 1.70 01-Feb-2011  uwe cpu_setfunc() must use lwp_trampoline to arrange for the recycled lwp
to go through lwp_startup() the first time it's switched to.

This makes NetBSD-4.x SA binaries work on current. Tested with dig(1)
in NetBSD-4.x chroot on landisk.

Looks like this mistake of mine was picked up and replicated in
several other ports, sorry.

Reported by chuck@ in PR kern/44500
 1.69 14-Jan-2011  rmind branches: 1.69.2; 1.69.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.68 29-Dec-2010  nisimura use lwp_getpcb() to hide the detail about how struct pcb is populated.
 1.67 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.66 10-Dec-2009  uch branches: 1.66.2; 1.66.4;
u-area is no longer zero-cleared. reset here
 1.65 29-Nov-2009  rmind Replace l_addr with uvm_lwp_getuarea() in various MD code, mostly cpu_lwp_fork().
 1.64 21-Nov-2009  rmind Use lwp_getpcb() on mips, powerpc and sh3, clean from struct user usage.
 1.63 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.62 15-Feb-2008  uwe branches: 1.62.6; 1.62.10; 1.62.16; 1.62.18;
G/c vestiges of curpute hack that was obsoleted by the fast TLB miss handler.
sh3_switch_setup() has nothing to do now so don't bother calling it.
 1.61 17-Oct-2007  garbled branches: 1.61.2;
Merge the ppcoea-renovation branch to HEAD.

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

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

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.60 27-Aug-2007  uwe branches: 1.60.2;
Move child_return() and startlwp() to be in the same file with
cpu_lwp_fork() that is used to call them.
 1.59 21-Aug-2007  uwe Factor out code to setup lwp u-area into a separate function used by
both cpu_lwp_fork and cpu_setfunc.
 1.58 17-Aug-2007  ad cpu_lwp_fork: don't rely on struct mdlwp being zeroed in advance.
 1.57 26-May-2007  tsutsui branches: 1.57.4; 1.57.8;
Update function names in comments.
 1.56 17-May-2007  yamt merge yamt-idlelwp branch. asked by core@. some ports still needs work.

from doc/BRANCHES:

idle lwp, and some changes depending on it.

1. separate context switching and thread scheduling.
(cf. gmcgarry_ctxsw)
2. implement idle lwp.
3. clean up related MD/MI interfaces.
4. make scheduler(s) modular.
 1.55 04-Mar-2007  christos branches: 1.55.2; 1.55.4; 1.55.10;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.54 22-Feb-2007  uwe Provide an empty cpu_lwp_free2().
 1.53 31-Aug-2006  matt branches: 1.53.8;
Make cpu_coredump dependent on COREDUMP
 1.52 10-May-2006  skrll Fix a bunch of cast lvalues.
 1.51 23-Jan-2006  uwe branches: 1.51.2; 1.51.4; 1.51.6; 1.51.8; 1.51.10;
Pacify -Wuninitialized for SH3 && SH4 case.
 1.50 23-Jan-2006  uwe Fix the sense of #else/#endif comments.
 1.49 11-Dec-2005  christos branches: 1.49.2;
merge ktrace-lwp.
 1.48 10-Jun-2005  matt branches: 1.48.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.47 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.46 09-Jan-2005  tsutsui branches: 1.46.2; 1.46.4;
Small optimization in vmapbuf()/vunmapbuf().

BTW, should we also pass 'VM_PROT_READ|VM_PROT_WRITE' to flags
with PMAP_WIRED for pmap_enter() in vmapbuf()?
 1.45 17-Sep-2004  skrll 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.44 28-Aug-2004  thorpej Garbage-collect pagemove(); nothing use it anymore (YAY!!!)
 1.43 24-Mar-2004  wiz 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.42 18-Jan-2004  uwe Implement proper switch_exit in assembler. Since cpu_switch is
reduced to just a call to switch_exit, g/c the C version and add a one
instruction assembler version that just falls through to switch_exit.

Addresses PR#24007 by Jaromir Dolecek <jdolecek@netbsd> and makes sh3
kernels work again after his elimination of the reaper. Tested on hpcsh.
 1.41 06-Jan-2004  tsutsui MD cpu_lwp_free() should have the second arg.
 1.40 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.39 15-Nov-2003  uwe Tweak KDASSERT to avoid double negation.
 1.38 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.37 15-Jul-2003  lukem __KERNEL_RCSID()
 1.36 02-Apr-2003  thorpej branches: 1.36.2;
Use PAGE_SIZE rather than NBPG.
 1.35 18-Jan-2003  thorpej Merge the nathanw_sa branch.
 1.34 22-Sep-2002  gmcgarry Update for cpu_switch() prototype change. No functional change.
 1.33 09-May-2002  uch branches: 1.33.6;
new pmap designed for SH3/SH4.
 1.32 28-Apr-2002  uch Use "#define<tab>", white space nits.
 1.31 24-Mar-2002  uch Rework interrupt code.
+ Fully utilize SH SR.I[0:3] interrupt level.
+ software interrupt is emulated by TMU1, 2 one shot interrupt.
+ implement generic soft interrupts.
+ implement clockframe correctly.
 1.30 17-Mar-2002  uch cosmetic changes, fix comments.
 1.29 17-Mar-2002  uch kernel stack fix. old code simply P3 address converted to P1, it
caused memory destruction when kernel stack grow over 1 page. new
code use P3 address for kernel stack. but for the sake of debug, P1
kernel stack mode remain.
 1.28 08-Mar-2002  uch cpu_swapout() moved to cpu.h
 1.27 04-Mar-2002  simonb Don't need to declare phys_map - it is declared in <uvm/uvm_extern.h>.
 1.26 03-Mar-2002  uch SR related parts moved to psl.h. cpufunc.h segments.h are removed.
kernel mode checking is only SR.MD. no check stack pointer.
 1.25 19-Feb-2002  uch Clean up function declaration.
 1.24 17-Feb-2002  uch Add new MMU API. for detail, see sh3/mmu.h's comment.
 1.23 12-Feb-2002  uch ANSIfy KNF.
 1.22 16-Sep-2001  wiz Grammar improvements in comments.
 1.21 16-Sep-2001  wiz Spell 'occurred' with two 'r's.
 1.20 10-Sep-2001  chris Update pmap_update to now take the updated pmap as an argument.
This will allow improvements to the pmaps so that they can more easily defer expensive operations, eg tlb/cache flush, til the last possible moment.

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

Reviewed by Jason.
 1.19 19-Aug-2001  chs branches: 1.19.2;
I was wrong, sh4 does have a VAC.
change vmapbuf()/vmunmapbuf() back to using pmap_enter()/pmap_remove().
 1.18 19-Aug-2001  chs typo in previous.
 1.17 19-Aug-2001  chs use pmap_k* in vmapbuf() and vunmapbuf() since there's no VAC on this platform.

in vunmapbuf(), call pmap_*remove() explicitly since uvm_km_free_wakeup()
will soon no longer do it for us.
 1.16 24-Jun-2001  msaitoh branches: 1.16.2;
cpu_fork() fix:
- add cacheflush() when sh4
- convert kr15 from P2 area to P1 area (SH4)
 1.15 02-Jun-2001  chs replace vm_map{,_entry}_t with struct vm_map{,_entry} *.
 1.14 24-Apr-2001  thorpej Sprinkle pmap_update() calls after calls to:
- pmap_enter()
- pmap_remove()
- pmap_protect()
- pmap_kenter_pa()
- pmap_kremove()
as described in pmap(9).

These calls are relatively conservative. It may be possible to
optimize these a little more.
 1.13 21-Apr-2001  thorpej pmap_update() should not be equated with "flush entire TLB", it is
used to process deferred pmap operations. Since these pmaps don't
defer anything, pmap_update() is a noop.
 1.12 08-Sep-2000  msaitoh branches: 1.12.2;
delete an obsolete comment.
 1.11 29-Jun-2000  mrg remove include of <vm/vm.h>. <vm/vm.h> -> <uvm/uvm_extern.h>
 1.10 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.9 28-May-2000  thorpej branches: 1.9.2;
Rather than starting init and creating kthreads by forking and then
doing a cpu_set_kpc(), just pass the entry point and argument all
the way down the fork path starting with fork1(). In order to
avoid special-casing the normal fork in every cpu_fork(), MI code
passes down child_return() and the child process pointer explicitly.

This fixes a race condition on multiprocessor systems; a CPU could
grab the newly created processes (which has been placed on a run queue)
before cpu_set_kpc() would be performed.
 1.8 26-Mar-2000  kleink branches: 1.8.2;
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.7 20-Jan-2000  sommerfeld Fix PR9240: comment above cpu_fork() out of synch with reality on most ports.
(comment change only, but was wrong for more than just i386).
 1.6 07-Jan-2000  msaitoh enable cpu_coredump()
 1.5 07-Jan-2000  msaitoh use PSL_IMASK macro
 1.4 04-Dec-1999  ragge CL* discarding.
 1.3 13-Nov-1999  thorpej Update for pmap_enter() API change. No functional difference.
 1.2 14-Sep-1999  tsubai branches: 1.2.2; 1.2.4; 1.2.8;
Catch up with -current.
 1.1 13-Sep-1999  itojun Merge in NetBSD/sh3 from cvs.kame.net repository.

Tree structure:
- sys/arch/sh3: sh3 generic code
As commented, in-chip device drivers are put into sys/arch/sh3/dev.
- sys/arch/evbsh3: sh3 evaluation boards (pure sh3 CPU, no fancy external HW)
- sys/arch/mmeye: Brains mmEye, www.brains.co.jp
MI source code includes couple of #ifdef for sh3-coff support.
(sh3 uses coff or elf)

Needs some more improvements, especialy in sys/arch/sh3/conf/files.sh3,
to compile the tree (due to last minute tree structure change).
 1.2.8.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.2.4.1 15-Nov-1999  fvdl Sync with -current
 1.2.2.2 23-Apr-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.8.2.1 22-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.9.2.2 08-Oct-2001  he Pull up revision 1.16 (requested by msaitoh):
Fix two SH4 issues in cpu_fork().
 1.9.2.1 21-Sep-2000  msaitoh pullup revision 1.12 (approved by thorpej):

delete an obsolete comment.
 1.12.2.1 21-Jun-2001  nathanw Catch up to -current.
 1.16.2.6 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.16.2.5 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.16.2.4 16-Mar-2002  jdolecek Catch up with -current.
 1.16.2.3 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.16.2.2 13-Sep-2001  thorpej Update the kqueue branch to HEAD.
 1.16.2.1 25-Aug-2001  thorpej Merge Aug 24 -current into the kqueue branch.
 1.19.2.1 01-Oct-2001  fvdl Catch up with -current.
 1.33.6.6 18-Dec-2002  thorpej * cpu_lwp_fork(): Move some code out of processor-model specific blocks
to avoid duplication.
* cpu_setfunc(): Fix uninitialized "tf" variable (oops!) and make sure
l->l_md.md_regs gets initialized.
 1.33.6.5 16-Dec-2002  thorpej Following a critical tip from Greg McGarry, fully initialize the LWP
in cpu_setfunc(), as cached LWPs will not be fully initialized when
they arrive there.

SH4 no longer spontaneously reboots when running the "sa1" test (i.e.
the test seems to run properly for a while), although there still seem
to be some problems.
 1.33.6.4 18-Oct-2002  nathanw Catch up to -current.
 1.33.6.3 24-Jun-2002  nathanw Curproc->curlwp renaming.

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

"curproc" is now #defined in proc.h as ((curlwp) ? (curlwp)->l_proc) : NULL)
so that it is always safe to reference curproc (*de*referencing curproc
is another story, but that's always been true).
 1.33.6.2 21-Jun-2002  thorpej Add support for scheduler activations on SuperH. Boots multi-user
on Dreamcast (SH4) with stock userland.
 1.33.6.1 09-May-2002  thorpej file vm_machdep.c was added on branch nathanw_sa on 2002-06-21 21:26:35 +0000
 1.36.2.7 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.36.2.6 01-Apr-2005  skrll Sync with HEAD.
 1.36.2.5 17-Jan-2005  skrll Sync with HEAD.
 1.36.2.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.36.2.3 18-Sep-2004  skrll Sync with HEAD.
 1.36.2.2 03-Sep-2004  skrll Sync with HEAD
 1.36.2.1 03-Aug-2004  skrll Sync with HEAD
 1.46.4.1 02-Feb-2005  yamt convert arch/sh3 to new apis.
 1.46.2.1 29-Apr-2005  kent sync with -current
 1.48.2.5 27-Feb-2008  yamt sync with head.
 1.48.2.4 03-Sep-2007  yamt sync with head.
 1.48.2.3 26-Feb-2007  yamt sync with head.
 1.48.2.2 30-Dec-2006  yamt sync with head.
 1.48.2.1 21-Jun-2006  yamt sync with head.
 1.49.2.1 01-Feb-2006  yamt sync with head.
 1.51.10.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.51.8.1 11-May-2006  elad sync with head
 1.51.6.2 03-Sep-2006  yamt sync with head.
 1.51.6.1 24-May-2006  yamt sync with head.
 1.51.4.1 01-Jun-2006  kardel Sync with head.
 1.51.2.1 09-Sep-2006  rpaulo sync with head
 1.53.8.4 25-Apr-2007  skrll Typo in comment.
 1.53.8.3 25-Mar-2007  uwe Adapt sh3 to yamt-idlelwp.
 1.53.8.2 12-Mar-2007  rmind Sync with HEAD.
 1.53.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.55.10.3 03-Oct-2007  garbled Sync with HEAD
 1.55.10.2 26-Jun-2007  garbled Sync with HEAD.
 1.55.10.1 22-May-2007  matt Update to HEAD.
 1.55.4.1 11-Jul-2007  mjf Sync with head.
 1.55.2.3 09-Oct-2007  ad Sync with head.
 1.55.2.2 20-Aug-2007  ad Sync with HEAD.
 1.55.2.1 27-May-2007  ad Sync with head.
 1.57.8.1 03-Sep-2007  jmcneill Sync with HEAD.
 1.57.4.1 03-Sep-2007  skrll Sync with HEAD.
 1.60.2.2 23-Mar-2008  matt sync with HEAD
 1.60.2.1 06-Nov-2007  matt sync with HEAD
 1.61.2.1 18-Feb-2008  mjf Sync with HEAD.
 1.62.18.1 19-Jan-2009  skrll Sync with HEAD.
 1.62.16.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.62.10.3 11-Aug-2010  yamt sync with head.
 1.62.10.2 11-Mar-2010  yamt sync with head
 1.62.10.1 04-May-2009  yamt sync with head.
 1.62.6.1 17-Jan-2009  mjf Sync with HEAD.
 1.66.4.5 05-Mar-2011  rmind sync with head
 1.66.4.4 30-May-2010  rmind sync with head
 1.66.4.3 25-Apr-2010  rmind A round of compile and other fixes to previous.
 1.66.4.2 25-Apr-2010  rmind - Invent mm_md_getva() and mm_md_relva() routines, provided by MD and
indicated with __HAVE_MM_MD_PREFER_VA. It will be used to deal with
cache aliasing issues and thus fix little MIPS, ARM and friends.

- Convert dev_mem_readwrite() to use unmanaged mappings. Fix a missed
offset addition in a case of direct map. Sprinkle various comments in
the memory device driver.

- Add missing direct map handling on hp700 and vax. Make checks across
m68k ports more consistent, reduce the diffs. Fix kernacc check miss
on news68k. Minor off-by-one fix for alpha. Add MEMC_PHYS_BASE for
mmap() case check on acorn26. Misc clean-up.
 1.66.4.1 18-Mar-2010  rmind Unify /dev/{mem,kmem,zero,null} implementations in MI code. Based on patch
from Joerg Sonnenberger, proposed on tech-kern@, in February 2008.

Work and depression still in progress.
 1.66.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.69.4.2 17-Feb-2011  bouyer Sync with HEAD
 1.69.4.1 08-Feb-2011  bouyer Sync with HEAD
 1.69.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.71.2.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.73.6.2 24-Feb-2012  mrg sync to -current.
 1.73.6.1 18-Feb-2012  mrg merge to -current.
 1.73.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.73.2.1 17-Apr-2012  yamt sync with head
 1.75.4.1 18-May-2014  rmind sync with head
 1.75.2.2 03-Dec-2017  jdolecek update from HEAD
 1.75.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.76.10.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.76.6.1 05-Feb-2017  skrll Sync with HEAD
 1.77.16.1 10-Jun-2019  christos Sync with HEAD
 1.80.12.1 14-Dec-2020  thorpej Sync w/ HEAD.

RSS XML Feed