Home | History | Annotate | only in /src/sys/arch/powerpc/booke
History log of /src/sys/arch/powerpc/booke
RevisionDateAuthorComments
 1.3 22-Jul-2022  thorpej Drop using deprecated proplib functions.
 1.2 18-Jan-2011  matt branches: 1.2.4;
Add support for BookE Freescale MPC85xx (e500 core) processors.
Add fast softint support for PowerPC (though only booke uses it).
Redo FPU/VEC support and add e500 SPE support.
Rework trap/intrs to use a common trapframe format.
Support SOFTFLOAT (no hardfloat or fpu emulation) for BookE.
 1.1 07-Jan-2011  matt branches: 1.1.2; 1.1.4;
file board_prop.c was initially added on branch matt-nb5-pq3.
 1.1.4.1 06-Jun-2011  jruoho Sync with HEAD.
 1.1.2.1 07-Jan-2011  matt Add mpc85xx support for netbsd-5 (with some incompatible kernel changes).
 1.2.4.2 05-Mar-2011  rmind sync with head
 1.2.4.1 18-Jan-2011  rmind file board_prop.c was added on branch rmind-uvmplock on 2011-03-05 20:51:33 +0000
 1.3 17-Jun-2011  matt struct device * -> device_t
struct cfdata * -> cfdata_t
split device/softc (CFATTACH_DECL_NEW)
use device_accessors and device_private
constify
 1.2 18-Jan-2011  matt branches: 1.2.4; 1.2.6;
Add support for BookE Freescale MPC85xx (e500 core) processors.
Add fast softint support for PowerPC (though only booke uses it).
Redo FPU/VEC support and add e500 SPE support.
Rework trap/intrs to use a common trapframe format.
Support SOFTFLOAT (no hardfloat or fpu emulation) for BookE.
 1.1 07-Jan-2011  matt branches: 1.1.2; 1.1.4;
file booke_autoconf.c was initially added on branch matt-nb5-pq3.
 1.1.4.1 06-Jun-2011  jruoho Sync with HEAD.
 1.1.2.2 14-Oct-2011  matt Sync with current pulling P2020 and other newer processor support.
 1.1.2.1 07-Jan-2011  matt Add mpc85xx support for netbsd-5 (with some incompatible kernel changes).
 1.2.6.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.2.4.2 05-Mar-2011  rmind sync with head
 1.2.4.1 18-Jan-2011  rmind file booke_autoconf.c was added on branch rmind-uvmplock on 2011-03-05 20:51:33 +0000
 1.5 06-Jul-2020  rin Style and cosmetic changes. No binary changes intended.
 1.4 29-Jun-2011  dholland Add missing $NetBSD$ and/or __KERNEL_RCSID.
 1.3 15-Jun-2011  matt Rework to get the inlining working right. Also make slightly more portable
among powerpc variants.
 1.2 18-Jan-2011  matt branches: 1.2.4; 1.2.6;
Add support for BookE Freescale MPC85xx (e500 core) processors.
Add fast softint support for PowerPC (though only booke uses it).
Redo FPU/VEC support and add e500 SPE support.
Rework trap/intrs to use a common trapframe format.
Support SOFTFLOAT (no hardfloat or fpu emulation) for BookE.
 1.1 07-Jan-2011  matt branches: 1.1.2; 1.1.4;
file booke_cache.c was initially added on branch matt-nb5-pq3.
 1.1.4.1 06-Jun-2011  jruoho Sync with HEAD.
 1.1.2.2 14-Oct-2011  matt Sync with current pulling P2020 and other newer processor support.
 1.1.2.1 07-Jan-2011  matt Add mpc85xx support for netbsd-5 (with some incompatible kernel changes).
 1.2.6.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.2.4.2 05-Mar-2011  rmind sync with head
 1.2.4.1 18-Jan-2011  rmind file booke_cache.c was added on branch rmind-uvmplock on 2011-03-05 20:51:33 +0000
 1.35 05-Mar-2024  thorpej Move the at-shutdown call to resettodr() from cpu_reboot() to kern_reboot().

It's a small step, but it's a step.
 1.34 02-Feb-2024  andvar fix various typos in comments.
 1.33 30-Mar-2021  rin - Write-back msgbuf and update bootstr for reboot from halt.
- Remove dead code.
 1.32 06-Jul-2020  rin branches: 1.32.2; 1.32.4;
Include missing ksyms.h, opt_ddb.h, and opt_multiprocessor.h.
 1.31 06-Jul-2020  rin Style and cosmetic changes. No binary changes intended.
 1.30 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.29 31-Dec-2019  ad Rename uvm_free() -> uvm_availmem().
 1.28 27-Dec-2019  msaitoh s/sucess/success/ in comment.
 1.27 21-Dec-2019  ad uvmexp.free -> uvm_free()
 1.26 07-Apr-2019  thorpej Detangle some of the PowerPC CPU configuration spaghetti.
 1.25 06-Dec-2016  rin branches: 1.25.16;
PR port-evbppc/51564 (myself): wait for console input after halting the machine.
ok joerg
 1.24 11-Jul-2016  matt branches: 1.24.2;
Adapt to common pmap changes.
 1.23 23-Jan-2015  nonaka ddb MP support
 1.22 23-Jan-2015  nonaka When pmap_bootstrap is called, kcpuset_running has not been created yet.
 1.21 22-Sep-2014  matt branches: 1.21.2;
Change insn mask to properly match instructions (bctr/blr)
 1.20 24-Mar-2014  christos use cpu_{g,s}etmodel
 1.19 18-Mar-2014  riastradh Merge riastradh-drm2 to HEAD.
 1.18 17-Jul-2013  matt kcpuset_t changes for the pmap and removal of __cpuset_t
 1.17 29-Oct-2012  matt branches: 1.17.2; 1.17.8;
Make bus_dmamap_sync a noop for BookE.
 1.16 01-Aug-2012  matt branches: 1.16.2;
Add a machine splhist command to give (a incomplete) spl history.
(only the most recent are going to be accurate).

splraise(6) from 0 at 549214603
splraise(7) from 6 at 549214643 (+40)
splx(6) from 7 at 549214691 (+48)
splx(0) from 6 at 549214730 (+39)
 1.15 18-Jul-2012  matt If allocating lots of VA space for an io device, try to 'reserve' the space
so that the TLB might be able to create a large TLB entry to map it all.
 1.14 30-Jun-2011  matt branches: 1.14.2;
Modify mapiodev to take a third argument indicating whether the space
should be prefetchable (true) or not (false).
 1.13 29-Jun-2011  dholland Add missing $NetBSD$ and/or __KERNEL_RCSID.
 1.12 29-Jun-2011  matt Add cpu_hatch and cpu_boot_secondary_cpus.
 1.11 23-Jun-2011  matt Cleanup comments in pmap_tlb.c. Attach tlb evcnts.
eliminate ti_mask
Cleanup some of the MP code. Conditionalize shootdown code.
 1.10 21-Jun-2011  matt Reap the ci_ev_soft* evcnts since every variant implements __HAVE_FAST_SOFTINTS
 1.9 20-Jun-2011  matt Fixup PSL handling to be tolerant of modules. Move evbppc psl changes
into powerpc psl.h
 1.8 15-Jun-2011  matt Move the interrupt stub from booke_stubs.c into its own intr_stubs.c.
Move the "null" intrsw (used in startup) to intr_stubs.c as well.
 1.7 15-Jun-2011  matt lcsplx is dead. remove last vestiges of it.
 1.6 05-Jun-2011  matt Remove <machine/atomic.h>; use <sys/atomic.h> instead.
Add <powerpc/cpuset.h> (for mpc85xx pmap).
Add some initial MP code for mpc85xx
Rework ipi code to be common across all ppcs
Change PPC to keep curlwp in %r13 while in the kernel.
Move astpending from cpu_info to mdlwp
Improve cpu_need_resched to be more MP friendly.
 1.5 28-May-2011  matt branches: 1.5.2;
Cast physmem to uint64_t before calling ctob to avoid sign extension errors.
 1.4 17-Feb-2011  matt branches: 1.4.2;
add begging of single step support. Since BookE doesn't support PSL_SE, if
userret find PSL_SE set in SRR1, it will call booke_sstep to setup the
debug registers.
 1.3 16-Feb-2011  matt Count debug traps.
 1.2 18-Jan-2011  matt branches: 1.2.2;
Add support for BookE Freescale MPC85xx (e500 core) processors.
Add fast softint support for PowerPC (though only booke uses it).
Redo FPU/VEC support and add e500 SPE support.
Rework trap/intrs to use a common trapframe format.
Support SOFTFLOAT (no hardfloat or fpu emulation) for BookE.
 1.1 07-Jan-2011  matt branches: 1.1.2; 1.1.4;
file booke_machdep.c was initially added on branch matt-nb5-pq3.
 1.1.4.1 06-Jun-2011  jruoho Sync with HEAD.
 1.1.2.3 14-Oct-2011  matt Sync with current pulling P2020 and other newer processor support.
 1.1.2.2 17-Jan-2011  matt Add SPE (signal processing engine) support for mpc85xx/booke. Think of it
as AltiVec-lite (really lite). Genercize AltiVec support so that it could
the same interface could support SPE as well. Rework the FPU support along
the same lines. Move the __asm() to their own XXX_subr.S (altivec, fpu, spe).
 1.1.2.1 07-Jan-2011  matt Add mpc85xx support for netbsd-5 (with some incompatible kernel changes).
 1.2.2.2 05-Mar-2011  bouyer Sync with HEAD
 1.2.2.1 17-Feb-2011  bouyer Sync with HEAD
 1.4.2.4 12-Jun-2011  rmind sync with head
 1.4.2.3 31-May-2011  rmind sync with head
 1.4.2.2 05-Mar-2011  rmind sync with head
 1.4.2.1 17-Feb-2011  rmind file booke_machdep.c was added on branch rmind-uvmplock on 2011-03-05 20:51:33 +0000
 1.5.2.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.14.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.14.2.1 30-Oct-2012  yamt sync with head
 1.16.2.3 03-Dec-2017  jdolecek update from HEAD
 1.16.2.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.16.2.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.17.8.1 23-Jul-2013  riastradh sync with HEAD
 1.17.2.2 18-May-2014  rmind sync with head
 1.17.2.1 28-Aug-2013  rmind sync with head
 1.21.2.3 05-Feb-2017  skrll Sync with HEAD
 1.21.2.2 05-Oct-2016  skrll Sync with HEAD
 1.21.2.1 06-Apr-2015  skrll Sync with HEAD
 1.24.2.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.25.16.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.25.16.1 10-Jun-2019  christos Sync with HEAD
 1.32.4.1 03-Apr-2021  thorpej Sync with HEAD.
 1.32.2.1 03-Apr-2021  thorpej Sync with HEAD.
 1.39 24-Sep-2024  skrll Partially fix PMAP_MINIMALTLB compilation. From andvar@
 1.38 17-Apr-2023  skrll branches: 1.38.6;
KNF.
 1.37 07-Apr-2023  skrll Spaces to TAB
 1.36 26-Oct-2022  skrll MI PMAP hardware page table walker support.

This is based on code given to me by Matt Thomas a long time ago with
many updates and bugs fixes from me.
 1.35 25-Sep-2022  skrll Rename pmap_segtab_t *stp to stb for consistency with a future
pmap_pdetab_t *ptb. pmap_pdetab_t *ptp would be far too confusing.

NFC. Same code before and after.
 1.34 02-Oct-2021  skrll Pass the pmap in tlb_set_asid for the benefit of aarch64.
 1.33 02-Oct-2021  skrll Use KERNEL_PID instead of 0. NFC.
 1.32 19-Mar-2021  skrll Support pmap_growkernel and KASAN shadow mapping of the new KVA.

Neither mips nor ppc booke actually use pmap_growkernel (at present).

Thanks to rin@ for testing a similar patch on ppc booke.
 1.31 06-Jan-2021  rin Fix pmap_procwr() for powerpc/booke:

- Use PAGE_MASK, not PAGE_SIZE, to calculate page offset.
- Do not drop page offset of target address.
 1.30 20-Dec-2020  skrll Support __HAVE_PMAP_PV_TRACK in sys/uvm/pmap based pmaps (aka common pmap)
 1.29 06-Jul-2020  rin branches: 1.29.2;
Include missing opt_multiprocessor.h and opt_pmap.h.
 1.28 06-Jul-2020  rin Style and cosmetic changes. No binary changes intended.
 1.27 11-Mar-2020  thorpej With DEBUG defined, it's possible to execute a TLB-vs-segmap consistency
check from a (soft) interrupt handler. But if a platform does not otherwise
require the pmap_tlb_miss_lock, then where will be a brief window of
inconsistency that, while harmless, will still fire an assertion in the
consistency check.

Fix this with the following changes:
1- Refactor the pmap_tlb_miss_lock into MI code and rename it from
pmap_tlb_miss_lock_{enter,exit}() to pmap_tlb_miss_lock_{enter,exit}().
MD code can still define the "md" hooks as necessary, and if so, will
override the common implementation.
2- Provde a pmap_bootstrap_common() function to perform common pmap bootstrap
operations, namely initializing the pmap_tlb_miss_lock if it's needed.
If MD code overrides the implementation, it's responsible for initializing
its own lock.
3- Call pmap_bootstrap_common() from the mips, powerpc booke, and riscv
pmap_bootstrap() routines. (This required adding one for riscv.)
4- Switch powerpc booke to the common pmap_tlb_miss_lock.
5- Enable pmap_tlb_miss_lock if DEBUG is defined, even if it's not otherwise
required.

PR port-mips/55062 (Failed assertion in pmap_md_tlb_check_entry())
 1.26 03-Sep-2018  riastradh Rename min/max -> uimin/uimax for better honesty.

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

HOWEVER! Some subsystems have

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

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

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

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

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

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

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)
 1.25 24-Dec-2016  cherry branches: 1.25.14; 1.25.16;
Tell mpc85xx about uvm_hotplug(9)

Should fix the evbppc build breakage.
 1.24 11-Jul-2016  matt branches: 1.24.2;
Adapt to common pmap changes.
 1.23 05-Nov-2015  pgoyette Remove SYSVSHM-specific code. The value of shminfo.shmall is zero at
the time this pmap initialization code is called, so the increment is
a no-op. (Thanks christos@ for pointing it out.)
 1.22 26-Jan-2015  nonaka Avoid race condition between PTE update and TLB miss walk.
 1.21 23-Jan-2015  nonaka When pmap_bootstrap is called, kcpuset_running has not been created yet.
 1.20 09-Jan-2015  nonaka Use correct register for next cacheline address.
 1.19 05-Jan-2015  nonaka Initialize lock objects.
 1.18 18-Mar-2014  riastradh branches: 1.18.6;
Merge riastradh-drm2 to HEAD.
 1.17 17-Jul-2013  matt kcpuset_t changes for the pmap and removal of __cpuset_t
 1.16 07-Sep-2012  matt branches: 1.16.2; 1.16.4; 1.16.10;
Fool gcc into thinking we aren't using r31. We do use it but we don't
clobber it since it save and restore it from a temporary register.
 1.15 09-Jul-2012  matt More cleanup. Use a union (pmap_segtab) and a typedef (pmap_segtab_t). Add
more functionality from the mips pmap and try to make it more common to ease
the transition for mips in the future.
 1.14 05-Jul-2012  matt s/seg_tab/seg_ptr/
 1.13 29-Mar-2012  matt Add support PMAP_MINIMALTLB option. This changes the default use of TLB1
entries to map all of physical memory to using two TLB1 entries, one for
mapping text and one for data. The rest of memory is mapped using the
page table which is updated as needed. This is used to trap memory
corruption issues.
 1.12 02-Feb-2012  para branches: 1.12.2;
- bringing kmeminit_nkmempages back and revert pmaps that called this early
- use nkmempages to scale the kmem_arena
- reducing diff to pre kmem/vmem change
(NKMEMPAGES_MAX_DEFAULT will need adjusting on some archs)
 1.11 27-Jan-2012  para extending vmem(9) to be able to allocated resources for it's own needs.
simplifying uvm_map handling (no special kernel entries anymore no relocking)
make malloc(9) a thin wrapper around kmem(9)
(with private interface for interrupt safety reasons)

releng@ acknowledged
 1.10 27-Sep-2011  jym branches: 1.10.2; 1.10.6;
Modify *ASSERTMSG() so they are now used as variadic macros. The main goal
is to provide routines that do as KASSERT(9) says: append a message
to the panic format string when the assertion triggers, with optional
arguments.

Fix call sites to reflect the new definition.

Discussed on tech-kern@. See
http://mail-index.netbsd.org/tech-kern/2011/09/07/msg011427.html
 1.9 29-Jun-2011  dholland Add missing $NetBSD$ and/or __KERNEL_RCSID.
 1.8 29-Jun-2011  matt Add an empty pmap_md_tlb_info_init.
 1.7 23-Jun-2011  matt Move some MD parts back to the booke pmap.c. Cleanup initialization a bit.
 1.6 20-Jun-2011  matt PowerPC now exports a common view of cpu.h, vmparam.h and pmap.h
when building a MODULAR kernel or compiling _MODULE.
It should be noted that MODULAR or _MODULE export a view of the kernel
as being MULTIPROCESSOR (even if isn't).
The shared pmap TLB uses mdpg in places where it used mdpg to avoid
deadly embrance inclusion problems.
 1.5 12-Jun-2011  matt For debugging, use UVMHIST to create kernel histories pmaphist and
pmapexechist. This replaces the old pmapdebug/PDB stuff.
In ddb, you can just use kernhist_dump(pmaphist) to view the history
or vmstat -H from userland.
 1.4 05-Jun-2011  matt Remove <machine/atomic.h>; use <sys/atomic.h> instead.
Add <powerpc/cpuset.h> (for mpc85xx pmap).
Add some initial MP code for mpc85xx
Rework ipi code to be common across all ppcs
Change PPC to keep curlwp in %r13 while in the kernel.
Move astpending from cpu_info to mdlwp
Improve cpu_need_resched to be more MP friendly.
 1.3 17-Feb-2011  matt branches: 1.3.2; 1.3.4;
Use _PMAP_PRIVATE to control the inclusion of <powerpc/booke/cpuvar.h>.
This prevents most of the MI files from depending on it.
 1.2 18-Jan-2011  matt branches: 1.2.2;
Add support for BookE Freescale MPC85xx (e500 core) processors.
Add fast softint support for PowerPC (though only booke uses it).
Redo FPU/VEC support and add e500 SPE support.
Rework trap/intrs to use a common trapframe format.
Support SOFTFLOAT (no hardfloat or fpu emulation) for BookE.
 1.1 07-Jan-2011  matt branches: 1.1.2; 1.1.4;
file booke_pmap.c was initially added on branch matt-nb5-pq3.
 1.1.4.1 06-Jun-2011  jruoho Sync with HEAD.
 1.1.2.2 14-Oct-2011  matt Sync with current pulling P2020 and other newer processor support.
 1.1.2.1 07-Jan-2011  matt Add mpc85xx support for netbsd-5 (with some incompatible kernel changes).
 1.2.2.1 05-Mar-2011  bouyer Sync with HEAD
 1.3.4.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.3.2.3 12-Jun-2011  rmind sync with head
 1.3.2.2 05-Mar-2011  rmind sync with head
 1.3.2.1 17-Feb-2011  rmind file booke_pmap.c was added on branch rmind-uvmplock on 2011-03-05 20:51:33 +0000
 1.10.6.2 05-Apr-2012  mrg sync to latest -current.
 1.10.6.1 18-Feb-2012  mrg merge to -current.
 1.10.2.3 22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.10.2.2 30-Oct-2012  yamt sync with head
 1.10.2.1 17-Apr-2012  yamt sync with head
 1.12.2.1 09-May-2012  riz Pull up following revision(s) (requested by matt in ticket #241):
sys/arch/powerpc/conf/kern-mb.ldscript: revision 1.1
sys/arch/powerpc/include/booke/pmap.h: revision 1.9
sys/arch/powerpc/booke/e500_tlb.c: revision 1.8
sys/arch/powerpc/conf/files.powerpc: revision 1.83
sys/arch/powerpc/booke/booke_pmap.c: revision 1.13
sys/arch/powerpc/include/booke/e500var.h: revision 1.5
sys/arch/evbppc/mpc85xx/machdep.c: revision 1.23
Add ldscript which aligns .data to a 1MB boundary. (used for testing)
Add PMAP_MINIMALTLB defflag
Add vsize_t to pmap_md_{un,}map_poolpage.
Add pmap_kvptefill prototype.
Slightly change pmap_bootstrap prototype.
Add e500_tlb_minimize prototype.
Add support PMAP_MINIMALTLB option. This changes the default use of TLB1
entries to map all of physical memory to using two TLB1 entries, one for
mapping text and one for data. The rest of memory is mapped using the
page table which is updated as needed. This is used to trap memory
corruption issues.
Add support for PMAP_MINIMALTLB.
 1.16.10.1 23-Jul-2013  riastradh sync with HEAD
 1.16.4.1 28-Aug-2013  rmind sync with head
 1.16.2.2 03-Dec-2017  jdolecek update from HEAD
 1.16.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.18.6.4 05-Feb-2017  skrll Sync with HEAD
 1.18.6.3 05-Oct-2016  skrll Sync with HEAD
 1.18.6.2 27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.18.6.1 06-Apr-2015  skrll Sync with HEAD
 1.24.2.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.25.16.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.25.16.1 10-Jun-2019  christos Sync with HEAD
 1.25.14.1 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.29.2.2 03-Apr-2021  thorpej Sync with HEAD.
 1.29.2.1 03-Jan-2021  thorpej Sync w/ HEAD.
 1.38.6.1 02-Aug-2025  perseant Sync with HEAD
 1.12 02-Oct-2021  skrll Pass the pmap in tlb_set_asid for the benefit of aarch64.
 1.11 06-Jul-2020  rin Style and cosmetic changes. No binary changes intended.
 1.10 11-Jul-2016  matt Adapt to common pmap changes.
 1.9 30-Jun-2011  matt branches: 1.9.12; 1.9.30;
Modify mapiodev to take a third argument indicating whether the space
should be prefetchable (true) or not (false).
 1.8 29-Jun-2011  dholland Add missing $NetBSD$ and/or __KERNEL_RCSID.
 1.7 23-Jun-2011  matt Switch to using the common <common/pmap/tlb/tlb.h>
 1.6 15-Jun-2011  matt Move the interrupt stub from booke_stubs.c into its own intr_stubs.c.
Move the "null" intrsw (used in startup) to intr_stubs.c as well.
 1.5 05-Jun-2011  matt Remove <machine/atomic.h>; use <sys/atomic.h> instead.
Add <powerpc/cpuset.h> (for mpc85xx pmap).
Add some initial MP code for mpc85xx
Rework ipi code to be common across all ppcs
Change PPC to keep curlwp in %r13 while in the kernel.
Move astpending from cpu_info to mdlwp
Improve cpu_need_resched to be more MP friendly.
 1.4 18-Feb-2011  matt branches: 1.4.2; 1.4.4;
Make sure stub routines are not profiled.
 1.3 12-Feb-2011  matt When an OEA kernel is configured for multiple MMU types, use the new
powerpc fixup mechanism to bind the kernel to a particular MMU. This
avoids an indirect call for every pmap call.
 1.2 18-Jan-2011  matt branches: 1.2.2;
Add support for BookE Freescale MPC85xx (e500 core) processors.
Add fast softint support for PowerPC (though only booke uses it).
Redo FPU/VEC support and add e500 SPE support.
Rework trap/intrs to use a common trapframe format.
Support SOFTFLOAT (no hardfloat or fpu emulation) for BookE.
 1.1 07-Jan-2011  matt branches: 1.1.2; 1.1.4;
file booke_stubs.c was initially added on branch matt-nb5-pq3.
 1.1.4.1 06-Jun-2011  jruoho Sync with HEAD.
 1.1.2.4 14-Oct-2011  matt Sync with current pulling P2020 and other newer processor support.
 1.1.2.3 18-Feb-2011  matt Mark splhigh as __noprofile.
 1.1.2.2 18-Feb-2011  matt Add __noprofile attribute and use it to prevent stubs from being profiled.
 1.1.2.1 07-Jan-2011  matt Add mpc85xx support for netbsd-5 (with some incompatible kernel changes).
 1.2.2.2 05-Mar-2011  bouyer Sync with HEAD
 1.2.2.1 17-Feb-2011  bouyer Sync with HEAD
 1.4.4.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.4.2.3 12-Jun-2011  rmind sync with head
 1.4.2.2 05-Mar-2011  rmind sync with head
 1.4.2.1 18-Feb-2011  rmind file booke_stubs.c was added on branch rmind-uvmplock on 2011-03-05 20:51:33 +0000
 1.9.30.1 05-Oct-2016  skrll Sync with HEAD
 1.9.12.1 03-Dec-2017  jdolecek update from HEAD
 1.9 06-Jul-2020  rin Style and cosmetic changes. No binary changes intended.
 1.8 02-Mar-2020  rin Let copyinstr(9) return ENAMETOOLONG correctly if source is not
NUL-terminated; it cannot be determined by (uint8_t)data == '\0'
since data is right shifted at the end of loop.

Found by POOL_REDZONE.
 1.7 07-Apr-2019  thorpej branches: 1.7.4;
Detangle some of the PowerPC CPU configuration spaghetti.
 1.6 24-Jul-2014  joerg branches: 1.6.28;
#if 0 unused copyin_halfword.
 1.5 16-Mar-2012  matt branches: 1.5.2; 1.5.12;
Make sure to have copyinstr return ENAMETOOLONG if the string was too long.
 1.4 20-Jun-2011  matt branches: 1.4.2; 1.4.6; 1.4.8;
Cleanup includes.
 1.3 17-Feb-2011  matt branches: 1.3.2; 1.3.4;
add begging of single step support. Since BookE doesn't support PSL_SE, if
userret find PSL_SE set in SRR1, it will call booke_sstep to setup the
debug registers.
 1.2 18-Jan-2011  matt branches: 1.2.2;
Add support for BookE Freescale MPC85xx (e500 core) processors.
Add fast softint support for PowerPC (though only booke uses it).
Redo FPU/VEC support and add e500 SPE support.
Rework trap/intrs to use a common trapframe format.
Support SOFTFLOAT (no hardfloat or fpu emulation) for BookE.
 1.1 07-Jan-2011  matt branches: 1.1.2; 1.1.4;
file copyin.c was initially added on branch matt-nb5-pq3.
 1.1.4.1 06-Jun-2011  jruoho Sync with HEAD.
 1.1.2.2 14-Oct-2011  matt Sync with current pulling P2020 and other newer processor support.
 1.1.2.1 07-Jan-2011  matt Add mpc85xx support for netbsd-5 (with some incompatible kernel changes).
 1.2.2.1 05-Mar-2011  bouyer Sync with HEAD
 1.3.4.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.3.2.2 05-Mar-2011  rmind sync with head
 1.3.2.1 17-Feb-2011  rmind file copyin.c was added on branch rmind-uvmplock on 2011-03-05 20:51:34 +0000
 1.4.8.1 17-May-2012  riz Pull up following revision(s) (requested by matt in ticket #253):
sys/arch/powerpc/booke/copyin.c: revision 1.5
Make sure to have copyinstr return ENAMETOOLONG if the string was too long.
 1.4.6.1 05-Apr-2012  mrg sync to latest -current.
 1.4.2.1 17-Apr-2012  yamt sync with head
 1.5.12.1 10-Aug-2014  tls Rebase.
 1.5.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.6.28.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.6.28.1 10-Jun-2019  christos Sync with HEAD
 1.7.4.1 02-Mar-2020  martin Pull up following revision(s) (requested by rin in ticket #752):

sys/arch/powerpc/booke/copyin.c: revision 1.8

Let copyinstr(9) return ENAMETOOLONG correctly if source is not
NUL-terminated; it cannot be determined by (uint8_t)data == '\0'
since data is right shifted at the end of loop.

Found by POOL_REDZONE.
 1.3 18-Jul-2012  matt These are not used so nuke 'em.
 1.2 18-Jan-2011  matt branches: 1.2.4; 1.2.8;
Add support for BookE Freescale MPC85xx (e500 core) processors.
Add fast softint support for PowerPC (though only booke uses it).
Redo FPU/VEC support and add e500 SPE support.
Rework trap/intrs to use a common trapframe format.
Support SOFTFLOAT (no hardfloat or fpu emulation) for BookE.
 1.1 07-Jan-2011  matt branches: 1.1.2; 1.1.4;
file copyinstr.c was initially added on branch matt-nb5-pq3.
 1.1.4.1 06-Jun-2011  jruoho Sync with HEAD.
 1.1.2.1 07-Jan-2011  matt Add mpc85xx support for netbsd-5 (with some incompatible kernel changes).
 1.2.8.1 30-Oct-2012  yamt sync with head
 1.2.4.2 05-Mar-2011  rmind sync with head
 1.2.4.1 18-Jan-2011  rmind file copyinstr.c was added on branch rmind-uvmplock on 2011-03-05 20:51:34 +0000
 1.10 22-May-2022  andvar fix various small typos, mainly in comments.
 1.9 06-Jul-2020  rin Style and cosmetic changes. No binary changes intended.
 1.8 05-Mar-2020  rin copyoutstr(9): return ENAMETOOLONG correctly when source string is
not NUL-terminated.
 1.7 05-Mar-2020  rin copyoutstr(9): sync style with copyinstr(9).

- use variable name "done" instead of "lenp"
- return return value from setfault() on fault, instead of hardcoded EFAULT

No functional changes intended.
 1.6 04-Mar-2020  rin Comment out full function of optimized version of copyoutstr(9),
which has never been enabled so far.

Only for clarity. No binary changes.
 1.5 07-Apr-2019  thorpej branches: 1.5.4;
Detangle some of the PowerPC CPU configuration spaghetti.
 1.4 24-Jul-2014  joerg branches: 1.4.28;
#if 0 copyout_le32 and friends, they are currently unused.
 1.3 20-Jun-2011  matt branches: 1.3.12; 1.3.26;
Cleanup includes.
 1.2 18-Jan-2011  matt branches: 1.2.4; 1.2.6;
Add support for BookE Freescale MPC85xx (e500 core) processors.
Add fast softint support for PowerPC (though only booke uses it).
Redo FPU/VEC support and add e500 SPE support.
Rework trap/intrs to use a common trapframe format.
Support SOFTFLOAT (no hardfloat or fpu emulation) for BookE.
 1.1 07-Jan-2011  matt branches: 1.1.2; 1.1.4;
file copyout.c was initially added on branch matt-nb5-pq3.
 1.1.4.1 06-Jun-2011  jruoho Sync with HEAD.
 1.1.2.1 07-Jan-2011  matt Add mpc85xx support for netbsd-5 (with some incompatible kernel changes).
 1.2.6.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.2.4.2 05-Mar-2011  rmind sync with head
 1.2.4.1 18-Jan-2011  rmind file copyout.c was added on branch rmind-uvmplock on 2011-03-05 20:51:34 +0000
 1.3.26.1 10-Aug-2014  tls Rebase.
 1.3.12.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.4.28.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.4.28.1 10-Jun-2019  christos Sync with HEAD
 1.5.4.1 09-Mar-2020  martin Pull up following revision(s) (requested by rin in ticket #771):

sys/arch/powerpc/booke/copyout.c: revision 1.6
sys/arch/powerpc/booke/copyout.c: revision 1.7
sys/arch/powerpc/booke/copyout.c: revision 1.8

copyoutstr(9): sync style with copyinstr(9).
- use variable name "done" instead of "lenp"
- return return value from setfault() on fault, instead of hardcoded EFAULT
No functional changes intended.

copyoutstr(9): return ENAMETOOLONG correctly when source string is
not NUL-terminated.

Comment out full function of optimized version of copyoutstr(9),
which has never been enabled so far.
Only for clarity. No binary changes.
 1.3 18-Jul-2012  matt These are not used so nuke 'em.
 1.2 18-Jan-2011  matt branches: 1.2.4; 1.2.8;
Add support for BookE Freescale MPC85xx (e500 core) processors.
Add fast softint support for PowerPC (though only booke uses it).
Redo FPU/VEC support and add e500 SPE support.
Rework trap/intrs to use a common trapframe format.
Support SOFTFLOAT (no hardfloat or fpu emulation) for BookE.
 1.1 07-Jan-2011  matt branches: 1.1.2; 1.1.4;
file copyoutstr.c was initially added on branch matt-nb5-pq3.
 1.1.4.1 06-Jun-2011  jruoho Sync with HEAD.
 1.1.2.1 07-Jan-2011  matt Add mpc85xx support for netbsd-5 (with some incompatible kernel changes).
 1.2.8.1 30-Oct-2012  yamt sync with head
 1.2.4.2 05-Mar-2011  rmind sync with head
 1.2.4.1 18-Jan-2011  rmind file copyoutstr.c was added on branch rmind-uvmplock on 2011-03-05 20:51:34 +0000
 1.2 18-Jan-2011  matt branches: 1.2.4;
Add support for BookE Freescale MPC85xx (e500 core) processors.
Add fast softint support for PowerPC (though only booke uses it).
Redo FPU/VEC support and add e500 SPE support.
Rework trap/intrs to use a common trapframe format.
Support SOFTFLOAT (no hardfloat or fpu emulation) for BookE.
 1.1 07-Jan-2011  matt branches: 1.1.2; 1.1.4;
file e500_autoconf.c was initially added on branch matt-nb5-pq3.
 1.1.4.1 06-Jun-2011  jruoho Sync with HEAD.
 1.1.2.2 14-Oct-2011  matt Sync with current pulling P2020 and other newer processor support.
 1.1.2.1 07-Jan-2011  matt Add mpc85xx support for netbsd-5 (with some incompatible kernel changes).
 1.2.4.2 05-Mar-2011  rmind sync with head
 1.2.4.1 18-Jan-2011  rmind file e500_autoconf.c was added on branch rmind-uvmplock on 2011-03-05 20:51:34 +0000
 1.49 15-Sep-2024  andvar remove DIAGNOSTIC guard around ipl definition in e500_extintr().

It is used only for KASSERTMSG() only in this method, but still expects it
to exist, even if DIAGNOSTIC is not enabled.
 1.48 08-Sep-2024  andvar Use console_debbuger() or DDB guards for Debugger() and db_stack_trace_print().

Should allow to build these files without DDB enabled option.
 1.47 22-Jul-2022  thorpej branches: 1.47.10;
Stop using deprecated proplib functions.
 1.46 16-Mar-2022  andvar s/paniced/panicked/ and s/borken/broken/ in comments.
 1.45 11-Sep-2021  andvar Add missing double p and d for stopped and overriden accordingly.
Fix few more typos along the way, mainly in copy-pasted comments.
 1.44 06-Jul-2020  rin Drop unused opt_ddb.h.
 1.43 06-Jul-2020  rin Style and cosmetic changes. No binary changes intended.
 1.42 06-Jul-2020  rin XXX
Skip KASSERT which fires when !__HAVE_FAST_SOFTINTS. Just for debug.
 1.41 04-Jul-2020  rin Do not panic when splraise to IPL_NONE, which is required for
subr_cprng.c rev 1.36 and above:

http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/kern/subr_cprng.c#rev1.36
 1.40 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.39 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.38 16-Sep-2018  skrll interrupt has two 'r's

fix another typo while I'm here (flsah)
 1.37 26-Jan-2018  flxd branches: 1.37.2; 1.37.4;
Another try fixing printf format using the ultimate uintmax_t idiom.
 1.36 26-Jan-2018  christos fix printf format.
 1.35 01-Jun-2017  chs remove checks for failure after memory allocation calls that cannot fail:

kmem_alloc() with KM_SLEEP
kmem_zalloc() with KM_SLEEP
percpu_alloc()
pserialize_create()
psref_class_create()

all of these paths include an assertion that the allocation has not failed,
so callers should not assert that again.
 1.34 19-Oct-2016  nonaka Added MSI/MSI-X and interrupt_distribute(9) support for powerpc.
 1.33 14-Apr-2015  jmcneill branches: 1.33.2;
__HAVE_PREEEMPTION -> __HAVE_PREEMPTION
 1.32 23-Jan-2015  nonaka Initialize timer DR.
 1.31 23-Jan-2015  nonaka ddb MP support
 1.30 23-Jan-2015  nonaka Allow to share IPI interrupt.
 1.29 05-Jan-2015  nonaka Initialize lock objects.
 1.28 27-Dec-2014  nonaka Preliminary support for P1023.
 1.27 20-Dec-2014  nonaka Revert previous commit.
 1.26 19-Dec-2014  nonaka Pass ci->ci_cpuid as irq of IST_IPI.
Avoid "panic: e500_intr_cpu_hatch: failed to establish ipi interrupt!" on cpu1.
 1.25 19-Dec-2014  nonaka Added missing mutex_exit() at error path.
 1.24 19-May-2014  rmind branches: 1.24.4;
Implement MI IPI interface with cross-call support.
 1.23 29-Mar-2014  christos branches: 1.23.2;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.22 29-Oct-2012  matt branches: 1.22.2;
Change a KASSERT to a KASSERTMSG.
 1.21 01-Aug-2012  matt branches: 1.21.2;
Add a machine splhist command to give (a incomplete) spl history.
(only the most recent are going to be accurate).

splraise(6) from 0 at 549214603
splraise(7) from 6 at 549214643 (+40)
splx(6) from 7 at 549214691 (+48)
splx(0) from 6 at 549214730 (+39)
 1.20 18-Jul-2012  matt Add two missing interrupt sources for P1025.
 1.19 15-Jul-2012  matt Add support for the Freescale TWR-P1025 evaluation board and the P1025/P1016
QorIQ processors. XXX tsec isn't working yet on the TWR-P1025.
 1.18 09-Jul-2012  matt If we paniced because a watchdog timed out, PSL_CE will be clear. So don't
assert PSL_CE is set if panicstr is not NULL.
 1.17 08-Jun-2012  matt Compute softintr mask correctly.
 1.16 27-Sep-2011  jym branches: 1.16.2; 1.16.8;
Modify *ASSERTMSG() so they are now used as variadic macros. The main goal
is to provide routines that do as KASSERT(9) says: append a message
to the panic format string when the assertion triggers, with optional
arguments.

Fix call sites to reflect the new definition.

Discussed on tech-kern@. See
http://mail-index.netbsd.org/tech-kern/2011/09/07/msg011427.html
 1.15 29-Jun-2011  dholland Add missing $NetBSD$ and/or __KERNEL_RCSID.
 1.14 29-Jun-2011  matt Panic when an ipi is sent to unknown cpu.
 1.13 25-Jun-2011  matt Make powerpc work on BookE. At this time we only support DOZE (lightest
form of power-saving). By default, power-saving is disabled but can be
enabled in /etc/sysctl.conf by setting machdep.powersave=1
 1.12 21-Jun-2011  matt In e500_spl0, grab ci after disabling interrupts.
Consolidate a KASSERT.
 1.11 15-Jun-2011  matt Add IST_PULSE and intr_typename (converts IST_* to a name).
 1.10 14-Jun-2011  matt Take the fast softint support in e500_intr.c and make generic so that it can
be used to provide fast softint for other interrupt implementations.
 1.9 08-Jun-2011  matt Add an e500_idlespin to detect calls to idlespin when interrupts are blocked
or disabled.
 1.8 05-Jun-2011  matt Remove <machine/atomic.h>; use <sys/atomic.h> instead.
Add <powerpc/cpuset.h> (for mpc85xx pmap).
Add some initial MP code for mpc85xx
Rework ipi code to be common across all ppcs
Change PPC to keep curlwp in %r13 while in the kernel.
Move astpending from cpu_info to mdlwp
Improve cpu_need_resched to be more MP friendly.
 1.7 27-May-2011  matt branches: 1.7.2;
Remove debugging printf. Add missing IMU2 interrupt string.
 1.6 17-May-2011  dyoung Add some grotty #ifdef'age to make this compile w/o DIAGNOSTIC.
 1.5 21-Mar-2011  matt Fix a bug in onchip_intr_name_lookup
 1.4 16-Mar-2011  matt Fix various nits related to P2020 support.
 1.3 16-Feb-2011  matt branches: 1.3.2;
Cleanup intr_info initialization. Make it per SVR.
 1.2 18-Jan-2011  matt branches: 1.2.2;
Add support for BookE Freescale MPC85xx (e500 core) processors.
Add fast softint support for PowerPC (though only booke uses it).
Redo FPU/VEC support and add e500 SPE support.
Rework trap/intrs to use a common trapframe format.
Support SOFTFLOAT (no hardfloat or fpu emulation) for BookE.
 1.1 07-Jan-2011  matt branches: 1.1.2; 1.1.4;
file e500_intr.c was initially added on branch matt-nb5-pq3.
 1.1.4.1 06-Jun-2011  jruoho Sync with HEAD.
 1.1.2.2 14-Oct-2011  matt Sync with current pulling P2020 and other newer processor support.
 1.1.2.1 07-Jan-2011  matt Add mpc85xx support for netbsd-5 (with some incompatible kernel changes).
 1.2.2.1 17-Feb-2011  bouyer Sync with HEAD
 1.3.2.5 12-Jun-2011  rmind sync with head
 1.3.2.4 31-May-2011  rmind sync with head
 1.3.2.3 21-Apr-2011  rmind sync with head
 1.3.2.2 05-Mar-2011  rmind sync with head
 1.3.2.1 16-Feb-2011  rmind file e500_intr.c was added on branch rmind-uvmplock on 2011-03-05 20:51:34 +0000
 1.7.2.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.16.8.2 12-Jul-2012  riz Pull up following revision(s) (requested by matt in ticket #409):
sys/arch/powerpc/booke/e500_intr.c: revision 1.18
If we paniced because a watchdog timed out, PSL_CE will be clear. So don't
assert PSL_CE is set if panicstr is not NULL.
 1.16.8.1 13-Jun-2012  riz Pull up following revision(s) (requested by matt in ticket #338):
sys/arch/powerpc/booke/e500_intr.c: revision 1.17
Compute softintr mask correctly.
 1.16.2.2 22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.16.2.1 30-Oct-2012  yamt sync with head
 1.21.2.3 03-Dec-2017  jdolecek update from HEAD
 1.21.2.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.21.2.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.22.2.1 18-May-2014  rmind sync with head
 1.23.2.1 10-Aug-2014  tls Rebase.
 1.24.4.4 28-Aug-2017  skrll Sync with HEAD
 1.24.4.3 05-Dec-2016  skrll Sync with HEAD
 1.24.4.2 06-Jun-2015  skrll Sync with HEAD
 1.24.4.1 06-Apr-2015  skrll Sync with HEAD
 1.33.2.1 04-Nov-2016  pgoyette Sync with HEAD
 1.37.4.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.37.4.1 10-Jun-2019  christos Sync with HEAD
 1.37.2.1 30-Sep-2018  pgoyette Ssync with HEAD
 1.47.10.1 02-Aug-2025  perseant Sync with HEAD
 1.4 19-Dec-2014  nonaka Set correct stack pointer.
Please handle %r0 with care.
 1.3 27-Nov-2012  matt branches: 1.3.14;
Make the 85xx get closer to spinning up the secondary CPUs.
Don't assume TLB1[0] has the mapping for VA/PA 0.
Make sure the TLB1 entries that map physical memory have the M (memory
coherent) bit set.
 1.2 29-Jun-2011  matt branches: 1.2.2; 1.2.12;
More MP support.
 1.1 05-Jun-2011  matt branches: 1.1.2; 1.1.4; 1.1.6;
Remove <machine/atomic.h>; use <sys/atomic.h> instead.
Add <powerpc/cpuset.h> (for mpc85xx pmap).
Add some initial MP code for mpc85xx
Rework ipi code to be common across all ppcs
Change PPC to keep curlwp in %r13 while in the kernel.
Move astpending from cpu_info to mdlwp
Improve cpu_need_resched to be more MP friendly.
 1.1.6.2 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.1.6.1 05-Jun-2011  cherry file e500_mpsubr.S was added on branch cherry-xenmp on 2011-06-23 14:19:28 +0000
 1.1.4.2 12-Jun-2011  rmind sync with head
 1.1.4.1 05-Jun-2011  rmind file e500_mpsubr.S was added on branch rmind-uvmplock on 2011-06-12 00:24:03 +0000
 1.1.2.2 06-Jun-2011  jruoho Sync with HEAD.
 1.1.2.1 05-Jun-2011  jruoho file e500_mpsubr.S was added on branch jruoho-x86intr on 2011-06-06 09:06:25 +0000
 1.2.12.2 03-Dec-2017  jdolecek update from HEAD
 1.2.12.1 25-Feb-2013  tls resync with head
 1.2.2.1 16-Jan-2013  yamt sync with (a bit old) head
 1.3.14.1 06-Apr-2015  skrll Sync with HEAD
 1.8 10-Aug-2023  andvar fix typos in comments.
 1.7 29-May-2020  rin For struct timecounter, use C99 initializers.
Compile tested. No functional changes intended.
 1.6 21-Jan-2015  nonaka fix build failure with lockstat.
 1.5 29-Jul-2014  joerg branches: 1.5.2; 1.5.4;
GC openpic_read.
 1.4 29-Jun-2011  matt branches: 1.4.12; 1.4.26;
Only attach tc on primary cpu.
 1.3 25-Jun-2011  matt Make powerpc work on BookE. At this time we only support DOZE (lightest
form of power-saving). By default, power-saving is disabled but can be
enabled in /etc/sysctl.conf by setting machdep.powersave=1
 1.2 18-Jan-2011  matt branches: 1.2.4;
Add support for BookE Freescale MPC85xx (e500 core) processors.
Add fast softint support for PowerPC (though only booke uses it).
Redo FPU/VEC support and add e500 SPE support.
Rework trap/intrs to use a common trapframe format.
Support SOFTFLOAT (no hardfloat or fpu emulation) for BookE.
 1.1 07-Jan-2011  matt branches: 1.1.2; 1.1.4;
file e500_timer.c was initially added on branch matt-nb5-pq3.
 1.1.4.1 06-Jun-2011  jruoho Sync with HEAD.
 1.1.2.2 14-Oct-2011  matt Sync with current pulling P2020 and other newer processor support.
 1.1.2.1 07-Jan-2011  matt Add mpc85xx support for netbsd-5 (with some incompatible kernel changes).
 1.2.4.2 05-Mar-2011  rmind sync with head
 1.2.4.1 18-Jan-2011  rmind file e500_timer.c was added on branch rmind-uvmplock on 2011-03-05 20:51:34 +0000
 1.4.26.1 10-Aug-2014  tls Rebase.
 1.4.12.2 03-Dec-2017  jdolecek update from HEAD
 1.4.12.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.5.4.1 06-Apr-2015  skrll Sync with HEAD
 1.5.2.1 26-Jan-2015  martin Pull up following revision(s) (requested by nonaka in ticket #456):
sys/arch/powerpc/booke/e500_timer.c: revision 1.6
fix build failure with lockstat.
 1.24 31-May-2022  andvar fix various typos in comments, documentation and messages.
 1.23 07-Jul-2020  rin Revert previous; tmpfs should be fixed instead.

Pointed out by thorpej@, thanks!
 1.22 07-Jul-2020  rin Fix kernel panic due to tmpfs.

pmap for booke assumes that the ``va'' argument for pmap_kenter_pa(9) is
page-aligned. However, by recent changes, tmpfs became to use ``va'' with
page offset via ubc_uiomove(9). So, truncate it to page boundary.
 1.21 06-Jul-2020  rin Include missing opt_multiprocessor.h and opt_pmap.h.
 1.20 06-Jul-2020  rin Style and cosmetic changes. No binary changes intended.
 1.19 03-Sep-2018  riastradh Rename min/max -> uimin/uimax for better honesty.

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

HOWEVER! Some subsystems have

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

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

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

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

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

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

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)
 1.18 11-Jul-2016  matt branches: 1.18.16; 1.18.18;
Adapt to common pmap changes.
 1.17 19-Feb-2015  nonaka fix compile failure without DIAGNOSTIC.
 1.16 23-Jan-2015  nonaka - Use tlbivax instruction for TLB update/invalidate when MULTIPROCESSOR is
defined. Because TLB entry operation is not notified to another CPU.
- When TLB1 is updated, send IPI_TLB1SYNC to another CPU.
 1.15 28-Dec-2014  nonaka include "opt_ppcparam.h" for VERBOSE_INITPPC.
 1.14 26-Dec-2014  nonaka fix typo.
 1.13 09-Dec-2013  wiz branches: 1.13.4; 1.13.6;
Fix typo ("then" instead of "than")
 1.12 27-Nov-2012  matt branches: 1.12.2;
Make the 85xx get closer to spinning up the secondary CPUs.
Don't assume TLB1[0] has the mapping for VA/PA 0.
Make sure the TLB1 entries that map physical memory have the M (memory
coherent) bit set.
 1.11 25-Jul-2012  matt branches: 1.11.2;
When dealing with kernel invalidations, make sure to use context-synchronizing
instructions.
 1.10 18-Jul-2012  matt Don't assume 1:1 PA:VA mapping
 1.9 18-Jul-2012  matt Fix some SHIFTOUT to SHIFTIN
Add a lookup of tlb1 by pa. fix comparisions of xtlb entries by using
masks. (since xtlb can looked up by pa & va and va may not equal pa).
 1.8 29-Mar-2012  matt Add support PMAP_MINIMALTLB option. This changes the default use of TLB1
entries to map all of physical memory to using two TLB1 entries, one for
mapping text and one for data. The rest of memory is mapped using the
page table which is updated as needed. This is used to trap memory
corruption issues.
 1.7 30-Jun-2011  matt branches: 1.7.2; 1.7.6; 1.7.8;
Modify mapiodev to take a third argument indicating whether the space
should be prefetchable (true) or not (false).
 1.6 29-Jun-2011  matt Don't use TLB1 entries for device access if they are writethrough or not
cache-inhibited.
 1.5 23-Jun-2011  matt Cleanup comments in pmap_tlb.c. Attach tlb evcnts.
eliminate ti_mask
Cleanup some of the MP code. Conditionalize shootdown code.
 1.4 23-Jun-2011  matt Switch to using the common <common/pmap/tlb/tlb.h>
 1.3 05-Jun-2011  matt Remove <machine/atomic.h>; use <sys/atomic.h> instead.
Add <powerpc/cpuset.h> (for mpc85xx pmap).
Add some initial MP code for mpc85xx
Rework ipi code to be common across all ppcs
Change PPC to keep curlwp in %r13 while in the kernel.
Move astpending from cpu_info to mdlwp
Improve cpu_need_resched to be more MP friendly.
 1.2 18-Jan-2011  matt branches: 1.2.4; 1.2.6;
Add support for BookE Freescale MPC85xx (e500 core) processors.
Add fast softint support for PowerPC (though only booke uses it).
Redo FPU/VEC support and add e500 SPE support.
Rework trap/intrs to use a common trapframe format.
Support SOFTFLOAT (no hardfloat or fpu emulation) for BookE.
 1.1 07-Jan-2011  matt branches: 1.1.2; 1.1.4;
file e500_tlb.c was initially added on branch matt-nb5-pq3.
 1.1.4.1 06-Jun-2011  jruoho Sync with HEAD.
 1.1.2.3 14-Oct-2011  matt Sync with current pulling P2020 and other newer processor support.
 1.1.2.2 26-Jul-2011  matt When matching a TLB1 entry for an I/O mapping, make sure it's not cachable.
 1.1.2.1 07-Jan-2011  matt Add mpc85xx support for netbsd-5 (with some incompatible kernel changes).
 1.2.6.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.2.4.3 12-Jun-2011  rmind sync with head
 1.2.4.2 05-Mar-2011  rmind sync with head
 1.2.4.1 18-Jan-2011  rmind file e500_tlb.c was added on branch rmind-uvmplock on 2011-03-05 20:51:34 +0000
 1.7.8.1 09-May-2012  riz Pull up following revision(s) (requested by matt in ticket #241):
sys/arch/powerpc/conf/kern-mb.ldscript: revision 1.1
sys/arch/powerpc/include/booke/pmap.h: revision 1.9
sys/arch/powerpc/booke/e500_tlb.c: revision 1.8
sys/arch/powerpc/conf/files.powerpc: revision 1.83
sys/arch/powerpc/booke/booke_pmap.c: revision 1.13
sys/arch/powerpc/include/booke/e500var.h: revision 1.5
sys/arch/evbppc/mpc85xx/machdep.c: revision 1.23
Add ldscript which aligns .data to a 1MB boundary. (used for testing)
Add PMAP_MINIMALTLB defflag
Add vsize_t to pmap_md_{un,}map_poolpage.
Add pmap_kvptefill prototype.
Slightly change pmap_bootstrap prototype.
Add e500_tlb_minimize prototype.
Add support PMAP_MINIMALTLB option. This changes the default use of TLB1
entries to map all of physical memory to using two TLB1 entries, one for
mapping text and one for data. The rest of memory is mapped using the
page table which is updated as needed. This is used to trap memory
corruption issues.
Add support for PMAP_MINIMALTLB.
 1.7.6.1 05-Apr-2012  mrg sync to latest -current.
 1.7.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.7.2.3 16-Jan-2013  yamt sync with (a bit old) head
 1.7.2.2 30-Oct-2012  yamt sync with head
 1.7.2.1 17-Apr-2012  yamt sync with head
 1.11.2.3 03-Dec-2017  jdolecek update from HEAD
 1.11.2.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.11.2.1 25-Feb-2013  tls resync with head
 1.12.2.1 18-May-2014  rmind sync with head
 1.13.6.2 05-Oct-2016  skrll Sync with HEAD
 1.13.6.1 06-Apr-2015  skrll Sync with HEAD
 1.13.4.1 21-Feb-2015  martin Pull up following revision(s) (requested by nonaka in ticket #535):
sys/arch/powerpc/booke/e500_tlb.c: revision 1.17
fix compile failure without DIAGNOSTIC.
 1.18.18.1 10-Jun-2019  christos Sync with HEAD
 1.18.16.1 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.11 26-Jan-2015  nonaka Avoid race condition between PTE update and TLB miss walk.
 1.10 27-Nov-2012  matt branches: 1.10.14;
Make the 85xx get closer to spinning up the secondary CPUs.
Don't assume TLB1[0] has the mapping for VA/PA 0.
Make sure the TLB1 entries that map physical memory have the M (memory
coherent) bit set.
 1.9 01-Aug-2012  matt branches: 1.9.2;
Fix a problem where the kernel could randomly reset due to a watchdog event.
When an exception happens, the srr0 (exception PC) was being saved in the
normal location of the current callframe. This was fine except when the
routine was in its prologue after it had saved LR but had not yet updated the
stack pointer or when the routine was in its epilogue after it has restored
the stack pointer but not yet loaded the LR. In either case this would cause
the LR to be corrupted (either running the routine forever or by branching
to itself forever). Now we save and restore the contents of that memory
location so the corruption can't happen.
 1.8 29-Jun-2011  matt branches: 1.8.2; 1.8.8;
More MP support.
 1.7 20-Jun-2011  matt Make struct cpu_info the same size if building MODULAR
kernels or compiling a module.
 1.6 18-Jun-2011  matt Make a common genassym.cf (powerpc/genassym.cf) and then
only put specific stuff in foo/genassym.cf
 1.5 18-Jun-2011  matt Use FRAME_Rn (like ibm4xx and oea) instead of FRAME_n.
Include psl.h to get PSL_* values instead of getting them from assym.h
 1.4 15-Jun-2011  matt Now that the generic fixup code exists, there's no to patch the interrupts
directly since the stub fixup will do that automatically. Just need to add
stubs for the interrupt vectors and they get fixed automagically.
 1.3 05-Jun-2011  matt Remove <machine/atomic.h>; use <sys/atomic.h> instead.
Add <powerpc/cpuset.h> (for mpc85xx pmap).
Add some initial MP code for mpc85xx
Rework ipi code to be common across all ppcs
Change PPC to keep curlwp in %r13 while in the kernel.
Move astpending from cpu_info to mdlwp
Improve cpu_need_resched to be more MP friendly.
 1.2 18-Jan-2011  matt branches: 1.2.4; 1.2.6;
Add support for BookE Freescale MPC85xx (e500 core) processors.
Add fast softint support for PowerPC (though only booke uses it).
Redo FPU/VEC support and add e500 SPE support.
Rework trap/intrs to use a common trapframe format.
Support SOFTFLOAT (no hardfloat or fpu emulation) for BookE.
 1.1 07-Jan-2011  matt branches: 1.1.2; 1.1.4;
file genassym.cf was initially added on branch matt-nb5-pq3.
 1.1.4.1 06-Jun-2011  jruoho Sync with HEAD.
 1.1.2.3 13-Oct-2011  matt Use FRAME_R* like ibm4xx and oea
 1.1.2.2 17-Jan-2011  matt Add SPE (signal processing engine) support for mpc85xx/booke. Think of it
as AltiVec-lite (really lite). Genercize AltiVec support so that it could
the same interface could support SPE as well. Rework the FPU support along
the same lines. Move the __asm() to their own XXX_subr.S (altivec, fpu, spe).
 1.1.2.1 07-Jan-2011  matt Add mpc85xx support for netbsd-5 (with some incompatible kernel changes).
 1.2.6.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.2.4.3 12-Jun-2011  rmind sync with head
 1.2.4.2 05-Mar-2011  rmind sync with head
 1.2.4.1 18-Jan-2011  rmind file genassym.cf was added on branch rmind-uvmplock on 2011-03-05 20:51:34 +0000
 1.8.8.1 09-Aug-2012  jdc Pull up revisions:
src/sys/arch/powerpc/booke/genassym.cf revision 1.9
src/sys/arch/powerpc/booke/trap_subr.S revision 1.8
src/sys/arch/powerpc/include/frame.h revision 1.25
(requested by matt in ticket #461).

Fix a problem where the kernel could randomly reset due to a watchdog event.
When an exception happens, the srr0 (exception PC) was being saved in the
normal location of the current callframe. This was fine except when the
routine was in its prologue after it had saved LR but had not yet updated the
stack pointer or when the routine was in its epilogue after it has restored
the stack pointer but not yet loaded the LR. In either case this would cause
the LR to be corrupted (either running the routine forever or by branching
to itself forever). Now we save and restore the contents of that memory
location so the corruption can't happen.
 1.8.2.2 16-Jan-2013  yamt sync with (a bit old) head
 1.8.2.1 30-Oct-2012  yamt sync with head
 1.9.2.2 03-Dec-2017  jdolecek update from HEAD
 1.9.2.1 25-Feb-2013  tls resync with head
 1.10.14.1 06-Apr-2015  skrll Sync with HEAD
 1.3 06-Jul-2020  rin Style and cosmetic changes. No binary changes intended.
 1.2 18-Jan-2011  matt branches: 1.2.4;
Add support for BookE Freescale MPC85xx (e500 core) processors.
Add fast softint support for PowerPC (though only booke uses it).
Redo FPU/VEC support and add e500 SPE support.
Rework trap/intrs to use a common trapframe format.
Support SOFTFLOAT (no hardfloat or fpu emulation) for BookE.
 1.1 07-Jan-2011  matt branches: 1.1.2; 1.1.4;
file kcopy.c was initially added on branch matt-nb5-pq3.
 1.1.4.1 06-Jun-2011  jruoho Sync with HEAD.
 1.1.2.1 07-Jan-2011  matt Add mpc85xx support for netbsd-5 (with some incompatible kernel changes).
 1.2.4.2 05-Mar-2011  rmind sync with head
 1.2.4.1 18-Jan-2011  rmind file kcopy.c was added on branch rmind-uvmplock on 2011-03-05 20:51:34 +0000
 1.11 06-Jul-2020  rin Style and cosmetic changes. No binary changes intended.
 1.10 17-Mar-2017  chs apply changes to this file as well, as part of:
allow pcu_save() and pcu_discard() to be called on other threads,
ptrace needs to use it that way.
 1.9 16-Mar-2017  chs allow pcu_save() and pcu_discard() to be called on other threads,
ptrace needs to use it that way.
 1.8 16-May-2014  rmind branches: 1.8.4; 1.8.8; 1.8.12;
pcu(9):
- Remove PCU_KERNEL (hi matt!) and significantly simplify the code.
This experimental feature was tried on ARM did not meet the expectations.
It may be revived one day, but it should be done in a much simpler way.
- Add a message structure for xcall function, pass the LWP ower and thus
optimise a race condition: if LWP is discarding its state on a remote CPU,
but another LWP already did it - do not cause an unecessary re-faulting.
- Reduce the variety of flags for PCU operations (only PCU_VALID and
PCU_REENABLE are used now), pass them only to the pcu_state_load().
- Rename pcu_used_p() to pcu_valid_p(); hopefully it is less confusing.
- pcu_save_all_on_cpu: SPL ought to be used here.
- Update and improve the pcu(9) man page; it needs wizd(8) though.
 1.7 23-Aug-2013  matt branches: 1.7.2;
Get rid of MDLWP_USED{FPU,VEC}
 1.6 26-Dec-2012  matt branches: 1.6.2;
Update to new pcu_state_{load,state,release} definitions
 1.5 07-Jun-2011  matt branches: 1.5.2; 1.5.12;
zero PCU area when loading used area.
 1.4 02-May-2011  matt branches: 1.4.2; 1.4.4;
Make sure to enable the vector unit in the PSL when returning to userland.
 1.3 02-May-2011  matt Move powerpc to use pcu to manage FPU/AltiVec/SPE.
 1.2 18-Jan-2011  matt branches: 1.2.4;
Add support for BookE Freescale MPC85xx (e500 core) processors.
Add fast softint support for PowerPC (though only booke uses it).
Redo FPU/VEC support and add e500 SPE support.
Rework trap/intrs to use a common trapframe format.
Support SOFTFLOAT (no hardfloat or fpu emulation) for BookE.
 1.1 17-Jan-2011  matt branches: 1.1.2;
file spe.c was initially added on branch matt-nb5-pq3.
 1.1.2.1 17-Jan-2011  matt Add SPE (signal processing engine) support for mpc85xx/booke. Think of it
as AltiVec-lite (really lite). Genercize AltiVec support so that it could
the same interface could support SPE as well. Rework the FPU support along
the same lines. Move the __asm() to their own XXX_subr.S (altivec, fpu, spe).
 1.2.4.4 12-Jun-2011  rmind sync with head
 1.2.4.3 31-May-2011  rmind sync with head
 1.2.4.2 05-Mar-2011  rmind sync with head
 1.2.4.1 18-Jan-2011  rmind file spe.c was added on branch rmind-uvmplock on 2011-03-05 20:51:34 +0000
 1.4.4.2 06-Jun-2011  jruoho Sync with HEAD.
 1.4.4.1 02-May-2011  jruoho file spe.c was added on branch jruoho-x86intr on 2011-06-06 09:06:26 +0000
 1.4.2.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.5.12.3 03-Dec-2017  jdolecek update from HEAD
 1.5.12.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.5.12.1 25-Feb-2013  tls resync with head
 1.5.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.5.2.1 23-Jan-2013  yamt sync with head
 1.6.2.2 18-May-2014  rmind sync with head
 1.6.2.1 28-Aug-2013  rmind sync with head
 1.7.2.1 10-Aug-2014  tls Rebase.
 1.8.12.1 21-Apr-2017  bouyer Sync with HEAD
 1.8.8.1 20-Mar-2017  pgoyette Sync with HEAD
 1.8.4.1 28-Aug-2017  skrll Sync with HEAD
 1.6 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.5 06-Jul-2020  rin branches: 1.5.6;
Style and cosmetic changes. No binary changes intended.
 1.4 10-Aug-2014  joerg Skip .machine when building with clang.
 1.3 20-May-2012  matt branches: 1.3.2;
Fix SPE loading typo as described in PR/45731
 1.2 18-Jan-2011  matt branches: 1.2.4; 1.2.8; 1.2.10; 1.2.14; 1.2.16;
Add support for BookE Freescale MPC85xx (e500 core) processors.
Add fast softint support for PowerPC (though only booke uses it).
Redo FPU/VEC support and add e500 SPE support.
Rework trap/intrs to use a common trapframe format.
Support SOFTFLOAT (no hardfloat or fpu emulation) for BookE.
 1.1 17-Jan-2011  matt branches: 1.1.2;
file spe_subr.S was initially added on branch matt-nb5-pq3.
 1.1.2.1 17-Jan-2011  matt Add SPE (signal processing engine) support for mpc85xx/booke. Think of it
as AltiVec-lite (really lite). Genercize AltiVec support so that it could
the same interface could support SPE as well. Rework the FPU support along
the same lines. Move the __asm() to their own XXX_subr.S (altivec, fpu, spe).
 1.2.16.1 13-Jun-2012  riz Pull up following revision(s) (requested by matt in ticket #339):
sys/arch/powerpc/booke/spe_subr.S: revision 1.3
Fix SPE loading typo as described in PR/45731
 1.2.14.1 02-Jun-2012  mrg sync to latest -current.
 1.2.10.1 23-May-2012  yamt sync with head.
 1.2.8.2 06-Jun-2011  jruoho Sync with HEAD.
 1.2.8.1 18-Jan-2011  jruoho file spe_subr.S was added on branch jruoho-x86intr on 2011-06-06 09:06:26 +0000
 1.2.4.2 05-Mar-2011  rmind sync with head
 1.2.4.1 18-Jan-2011  rmind file spe_subr.S was added on branch rmind-uvmplock on 2011-03-05 20:51:34 +0000
 1.3.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.5.6.1 01-Aug-2021  thorpej Sync with HEAD.
 1.41 08-Sep-2024  andvar Use console_debbuger() or DDB guards for Debugger() and db_stack_trace_print().

Should allow to build these files without DDB enabled option.
 1.40 17-Apr-2023  skrll branches: 1.40.6;
Trailing whitespace
 1.39 26-Oct-2022  skrll MI PMAP hardware page table walker support.

This is based on code given to me by Matt Thomas a long time ago with
many updates and bugs fixes from me.
 1.38 25-Sep-2022  skrll Rename pmap_segtab_t *stp to stb for consistency with a future
pmap_pdetab_t *ptb. pmap_pdetab_t *ptp would be far too confusing.

NFC. Same code before and after.
 1.37 06-Mar-2021  rin For booke and ibm4xx, switch to software-based single-stepping for PT_STEP
ptrace(2) command from broken hardware-based implementation.

As described in proposal on port-powerpc@,

http://mail-index.netbsd.org/port-powerpc/2021/02/26/msg003597.html

hardware debug facilities of booke and 4xx use critical interrupts, that
are difficult to handle for this purpose; they are not automatically masked
when entering kernel mode via system call trap or hardware interrupt.
See my proposal above for more details.

Now, hardware debug facilities are exclusively usable by kernel itself.
They are much more functional than PSL_SE MSR bit of oea, and should be
useful to, e.g., support byte-granular watchpoint for DDB in the future.
 1.36 06-Jan-2021  rin Sort headers. Also, use <ddb/ddb.h> instead of db_interface.h and
db_machdep.h in order not to be bothered by subtle include order.

No functional changes intended.
 1.35 10-Sep-2020  rin branches: 1.35.2;
Fix build with UVMHIST; stop passing string literal to UVMHIST_LOG(),
and also cast pointer arguments into uintptr_t.
 1.34 15-Jul-2020  rin For booke and ibm4xx, emulate m[ft]msr in user mode, in the same
manner as oea.

Now, user process can decide by itself whether floating-point
exception triggers SIGFPE or not via fenv(3).
 1.33 15-Jul-2020  rin Do not use curlwp twice. No functional changes.
 1.32 07-Jul-2020  rin For booke, fix signo and other siginfo returned for userland by
syncing with oea and ibm4xx.

Now, tests/kernel/t_trapsignal:bus_handle and friends pass on booke.
 1.31 07-Jul-2020  rin Do not clear pcb_onfault for error path of setfault().
This is caller's responsibility, and all the callers actually do so.
 1.30 07-Jul-2020  rin For booke, restore callee saved registers when recovery for page fault
fails for kernel.

OOPS! How on the earth we had overlooked this error so far...
 1.29 06-Jul-2020  rin Include missing opt_altivec.h for PPC_HAVE_SPE.
 1.28 06-Jul-2020  rin Style and cosmetic changes. No binary changes intended.
 1.27 27-Jan-2018  flxd Fix more printf format strings for mfspr() (hi mrg).
 1.26 31-Jul-2014  joerg Fix macro spelling.
 1.25 31-Jul-2014  matt Don't use numeric constants for SPR. Use the symbolic name (SPR_PIR).
Add DBSR_BRT to KASSERT
 1.24 30-Jul-2014  joerg Replace mfpir with mfspr r, 286. The Power ISA and GAS disagree on the
semantics of this instruction, so prefer the well defined replacement.
 1.23 23-Aug-2013  matt branches: 1.23.2;
Get rid of MDLWP_USED{FPU,VEC}
 1.22 02-Aug-2012  matt branches: 1.22.2; 1.22.4;
Also supprese printing fatal traps if the process is being debugged.
 1.21 02-Aug-2012  matt Only print fatal trap info if the resulting signal would be uncaught.
(this avoid the messages from libcrypto when it probes for capabilities).
 1.20 01-Aug-2012  matt Add a machine splhist command to give (a incomplete) spl history.
(only the most recent are going to be accurate).

splraise(6) from 0 at 549214603
splraise(7) from 6 at 549214643 (+40)
splx(6) from 7 at 549214691 (+48)
splx(0) from 6 at 549214730 (+39)
 1.19 01-Aug-2012  matt Export dump_trapframe.
 1.18 23-Jul-2012  matt Add support for PPC FP emulation to BookE.
Pass a ksiginfo_t to fpu_emulation so it can give more detailed
info on signals.
 1.17 09-Jul-2012  matt More cleanup. Use a union (pmap_segtab) and a typedef (pmap_segtab_t). Add
more functionality from the mips pmap and try to make it more common to ease
the transition for mips in the future.
 1.16 05-Jul-2012  matt s/seg_tab/seg_ptr/
 1.15 17-May-2012  matt Allow user addresses >= 0x80000000
 1.14 19-Feb-2012  rmind Remove COMPAT_SA / KERN_SA. Welcome to 6.99.3!
Approved by core@.
 1.13 27-Sep-2011  jym branches: 1.13.2; 1.13.6;
Modify *ASSERTMSG() so they are now used as variadic macros. The main goal
is to provide routines that do as KASSERT(9) says: append a message
to the panic format string when the assertion triggers, with optional
arguments.

Fix call sites to reflect the new definition.

Discussed on tech-kern@. See
http://mail-index.netbsd.org/tech-kern/2011/09/07/msg011427.html
 1.12 21-Jun-2011  matt Switch to use new common cpu_ast routine.
 1.11 20-Jun-2011  matt PowerPC now exports a common view of cpu.h, vmparam.h and pmap.h
when building a MODULAR kernel or compiling _MODULE.
It should be noted that MODULAR or _MODULE export a view of the kernel
as being MULTIPROCESSOR (even if isn't).
The shared pmap TLB uses mdpg in places where it used mdpg to avoid
deadly embrance inclusion problems.
 1.10 14-Jun-2011  matt Make startlwp and upcallret common instead of having 3 mostly identical copies.
 1.9 13-Jun-2011  matt If uvm_fault returns EACCES, convert it to EFAULT.
 1.8 12-Jun-2011  matt For debugging, use UVMHIST to create kernel histories pmaphist and
pmapexechist. This replaces the old pmapdebug/PDB stuff.
In ddb, you can just use kernhist_dump(pmaphist) to view the history
or vmstat -H from userland.
 1.7 05-Jun-2011  matt Remove <machine/atomic.h>; use <sys/atomic.h> instead.
Add <powerpc/cpuset.h> (for mpc85xx pmap).
Add some initial MP code for mpc85xx
Rework ipi code to be common across all ppcs
Change PPC to keep curlwp in %r13 while in the kernel.
Move astpending from cpu_info to mdlwp
Improve cpu_need_resched to be more MP friendly.
 1.6 02-May-2011  matt branches: 1.6.2;
Move powerpc to use pcu to manage FPU/AltiVec/SPE.
 1.5 17-Feb-2011  matt branches: 1.5.2;
add begging of single step support. Since BookE doesn't support PSL_SE, if
userret find PSL_SE set in SRR1, it will call booke_sstep to setup the
debug registers.
 1.4 08-Feb-2011  matt If we get a PGM exception for a trap, use SIGTRAP/TRAP_BRKPT instead of
SIGILL/ILL_ILLTRP so GDB will recognize it.
 1.3 07-Feb-2011  matt Fix inverted test. cpu_setmcontext should return success. :)
 1.2 18-Jan-2011  matt branches: 1.2.2;
Add support for BookE Freescale MPC85xx (e500 core) processors.
Add fast softint support for PowerPC (though only booke uses it).
Redo FPU/VEC support and add e500 SPE support.
Rework trap/intrs to use a common trapframe format.
Support SOFTFLOAT (no hardfloat or fpu emulation) for BookE.
 1.1 07-Jan-2011  matt branches: 1.1.2; 1.1.4;
file trap.c was initially added on branch matt-nb5-pq3.
 1.1.4.1 06-Jun-2011  jruoho Sync with HEAD.
 1.1.2.5 14-Oct-2011  matt Sync with current pulling P2020 and other newer processor support.
 1.1.2.4 26-Jul-2011  matt netbsd-5 uses pool_put, not kmem_free for ucontexts
 1.1.2.3 17-Jan-2011  matt Add SPE (signal processing engine) support for mpc85xx/booke. Think of it
as AltiVec-lite (really lite). Genercize AltiVec support so that it could
the same interface could support SPE as well. Rework the FPU support along
the same lines. Move the __asm() to their own XXX_subr.S (altivec, fpu, spe).
 1.1.2.2 07-Jan-2011  matt Add support for emulating mfpvr and lwsync. GCC will emit lwsync but booke
doesn't lwsync (sync 1) so we "emulate" it by treating it as a noop since
the exception will have synchronized things for us.
 1.1.2.1 07-Jan-2011  matt Add mpc85xx support for netbsd-5 (with some incompatible kernel changes).
 1.2.2.2 05-Mar-2011  bouyer Sync with HEAD
 1.2.2.1 08-Feb-2011  bouyer Sync with HEAD
 1.5.2.4 12-Jun-2011  rmind sync with head
 1.5.2.3 31-May-2011  rmind sync with head
 1.5.2.2 05-Mar-2011  rmind sync with head
 1.5.2.1 17-Feb-2011  rmind file trap.c was added on branch rmind-uvmplock on 2011-03-05 20:51:34 +0000
 1.6.2.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.13.6.2 02-Jun-2012  mrg sync to latest -current.
 1.13.6.1 24-Feb-2012  mrg sync to -current.
 1.13.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.13.2.3 30-Oct-2012  yamt sync with head
 1.13.2.2 23-May-2012  yamt sync with head.
 1.13.2.1 17-Apr-2012  yamt sync with head
 1.22.4.1 28-Aug-2013  rmind sync with head
 1.22.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.23.2.1 10-Aug-2014  tls Rebase.
 1.35.2.1 03-Apr-2021  thorpej Sync with HEAD.
 1.40.6.1 02-Aug-2025  perseant Sync with HEAD
 1.15 05-Jul-2022  andvar fix various typos in comments.
 1.14 07-May-2022  rin Make this assemble correctly with clang.

At the moment, clang wrongly handles m[ft]sprgN (N >= 4);
use m[ft]spr for SPR_SPRGN instead.

Now, clang-compiled kernel seems working just fine on my RB800!
 1.13 06-Jul-2020  rin Include required opt_*.h for sure.
 1.12 26-Jan-2015  nonaka Avoid race condition between PTE update and TLB miss walk.
 1.11 18-Sep-2014  joerg branches: 1.11.2;
Typo
 1.10 31-Jul-2014  matt Use symbolic constant for SPR. Fix comment.
 1.9 30-Jul-2014  joerg Replace mfpir with mfspr r, 286. The Power ISA and GAS disagree on the
semantics of this instruction, so prefer the well defined replacement.
 1.8 01-Aug-2012  matt branches: 1.8.2; 1.8.12;
Fix a problem where the kernel could randomly reset due to a watchdog event.
When an exception happens, the srr0 (exception PC) was being saved in the
normal location of the current callframe. This was fine except when the
routine was in its prologue after it had saved LR but had not yet updated the
stack pointer or when the routine was in its epilogue after it has restored
the stack pointer but not yet loaded the LR. In either case this would cause
the LR to be corrupted (either running the routine forever or by branching
to itself forever). Now we save and restore the contents of that memory
location so the corruption can't happen.
 1.7 09-Jul-2012  matt Add hook so E500 watchdog can use a separate stack but leave it disabled by
default.
 1.6 21-Jun-2011  matt branches: 1.6.2; 1.6.8;
Nuke the mfsprg2 %r3 after sctrapexit. curlwp is already in %r13 and the
value fetched to %r3 isn't used.
 1.5 18-Jun-2011  matt Use FRAME_Rn (like ibm4xx and oea) instead of FRAME_n.
Include psl.h to get PSL_* values instead of getting them from assym.h
 1.4 15-Jun-2011  matt Now that the generic fixup code exists, there's no to patch the interrupts
directly since the stub fixup will do that automatically. Just need to add
stubs for the interrupt vectors and they get fixed automagically.
 1.3 05-Jun-2011  matt Remove <machine/atomic.h>; use <sys/atomic.h> instead.
Add <powerpc/cpuset.h> (for mpc85xx pmap).
Add some initial MP code for mpc85xx
Rework ipi code to be common across all ppcs
Change PPC to keep curlwp in %r13 while in the kernel.
Move astpending from cpu_info to mdlwp
Improve cpu_need_resched to be more MP friendly.
 1.2 18-Jan-2011  matt branches: 1.2.4; 1.2.6;
Add support for BookE Freescale MPC85xx (e500 core) processors.
Add fast softint support for PowerPC (though only booke uses it).
Redo FPU/VEC support and add e500 SPE support.
Rework trap/intrs to use a common trapframe format.
Support SOFTFLOAT (no hardfloat or fpu emulation) for BookE.
 1.1 07-Jan-2011  matt branches: 1.1.2; 1.1.4;
file trap_subr.S was initially added on branch matt-nb5-pq3.
 1.1.4.1 06-Jun-2011  jruoho Sync with HEAD.
 1.1.2.3 13-Oct-2011  matt Use FRAME_R* like ibm4xx and oea
 1.1.2.2 17-Jan-2011  matt Add SPE (signal processing engine) support for mpc85xx/booke. Think of it
as AltiVec-lite (really lite). Genercize AltiVec support so that it could
the same interface could support SPE as well. Rework the FPU support along
the same lines. Move the __asm() to their own XXX_subr.S (altivec, fpu, spe).
 1.1.2.1 07-Jan-2011  matt Add mpc85xx support for netbsd-5 (with some incompatible kernel changes).
 1.2.6.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.2.4.3 12-Jun-2011  rmind sync with head
 1.2.4.2 05-Mar-2011  rmind sync with head
 1.2.4.1 18-Jan-2011  rmind file trap_subr.S was added on branch rmind-uvmplock on 2011-03-05 20:51:34 +0000
 1.6.8.1 09-Aug-2012  jdc Pull up revisions:
src/sys/arch/powerpc/booke/genassym.cf revision 1.9
src/sys/arch/powerpc/booke/trap_subr.S revision 1.8
src/sys/arch/powerpc/include/frame.h revision 1.25
(requested by matt in ticket #461).

Fix a problem where the kernel could randomly reset due to a watchdog event.
When an exception happens, the srr0 (exception PC) was being saved in the
normal location of the current callframe. This was fine except when the
routine was in its prologue after it had saved LR but had not yet updated the
stack pointer or when the routine was in its epilogue after it has restored
the stack pointer but not yet loaded the LR. In either case this would cause
the LR to be corrupted (either running the routine forever or by branching
to itself forever). Now we save and restore the contents of that memory
location so the corruption can't happen.
 1.6.2.1 30-Oct-2012  yamt sync with head
 1.8.12.1 10-Aug-2014  tls Rebase.
 1.8.2.2 03-Dec-2017  jdolecek update from HEAD
 1.8.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.11.2.1 06-Apr-2015  skrll Sync with HEAD
 1.8 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.7 24-Apr-2021  thorpej branches: 1.7.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.6 06-Jul-2020  rin branches: 1.6.4;
Style and cosmetic changes. No binary changes intended.
 1.5 28-May-2011  matt Move debug printfs higher.
 1.4 16-Feb-2011  matt branches: 1.4.2;
Fill in LE bus_space_tag in attach args.
 1.3 08-Feb-2011  matt Allow code to allow inclusive/exclusive locators for subdevices.
(uses on mpc85xx to match on SVRs or not match on SVRs).
 1.2 18-Jan-2011  matt branches: 1.2.2;
Add support for BookE Freescale MPC85xx (e500 core) processors.
Add fast softint support for PowerPC (though only booke uses it).
Redo FPU/VEC support and add e500 SPE support.
Rework trap/intrs to use a common trapframe format.
Support SOFTFLOAT (no hardfloat or fpu emulation) for BookE.
 1.1 07-Jan-2011  matt branches: 1.1.2; 1.1.4;
file cpunode.c was initially added on branch matt-nb5-pq3.
 1.1.4.1 06-Jun-2011  jruoho Sync with HEAD.
 1.1.2.3 14-Oct-2011  matt Sync with current pulling P2020 and other newer processor support.
 1.1.2.2 02-Aug-2011  matt need to set cna_le_memt too.
 1.1.2.1 07-Jan-2011  matt Add mpc85xx support for netbsd-5 (with some incompatible kernel changes).
 1.2.2.2 17-Feb-2011  bouyer Sync with HEAD
 1.2.2.1 08-Feb-2011  bouyer Sync with HEAD
 1.4.2.3 31-May-2011  rmind sync with head
 1.4.2.2 05-Mar-2011  rmind sync with head
 1.4.2.1 16-Feb-2011  rmind file cpunode.c was added on branch rmind-uvmplock on 2011-03-05 20:51:34 +0000
 1.6.4.1 22-Mar-2021  thorpej Mechanical conversion of config_found_sm_loc() -> config_found().
CFARG_IATTR usage needs to be audited.
 1.7.8.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.4 06-Jul-2020  rin Style and cosmetic changes. No binary changes intended.
 1.3 01-Aug-2011  matt Add missing __KERNEL_RCSID
 1.2 18-Jan-2011  matt branches: 1.2.4;
Add support for BookE Freescale MPC85xx (e500 core) processors.
Add fast softint support for PowerPC (though only booke uses it).
Redo FPU/VEC support and add e500 SPE support.
Rework trap/intrs to use a common trapframe format.
Support SOFTFLOAT (no hardfloat or fpu emulation) for BookE.
 1.1 07-Jan-2011  matt branches: 1.1.2; 1.1.4;
file e500wdog.c was initially added on branch matt-nb5-pq3.
 1.1.4.1 06-Jun-2011  jruoho Sync with HEAD.
 1.1.2.1 07-Jan-2011  matt Add mpc85xx support for netbsd-5 (with some incompatible kernel changes).
 1.2.4.2 05-Mar-2011  rmind sync with head
 1.2.4.1 18-Jan-2011  rmind file e500wdog.c was added on branch rmind-uvmplock on 2011-03-05 20:51:34 +0000
 1.8 10-May-2023  riastradh powerpc: Use config_detach_children to reduce error branch bugs.
 1.7 06-Jul-2020  rin Drop unused opt_flash.h.
 1.6 06-Jul-2020  rin Style and cosmetic changes. No binary changes intended.
 1.5 18-Jul-2012  matt Map NOR as PREFETCHABLE.
 1.4 06-Aug-2011  cliff branches: 1.4.2;
nuke pq3cfi_addr() and just use ga_addr; obio already sorts out getting
address from chip select reg when cs locator is used.
 1.3 19-Jul-2011  cliff branches: 1.3.2;
add TNF copyright
 1.2 17-Jul-2011  dyoung #include <sys/bus.h> not <machine/bus.h>.
 1.1 15-Jul-2011  cliff Add support for CFI NOR, using MPC8536DS as initial example.
Only AMD/Fujitsu command set is suported so far.
This is still work in progress, be advised.
 1.3.2.2 26-Jul-2011  matt Add pq3cfi device
 1.3.2.1 19-Jul-2011  matt file pq3cfi.c was added on branch matt-nb5-pq3 on 2011-07-26 03:38:48 +0000
 1.4.2.1 30-Oct-2012  yamt sync with head
 1.2 06-Jul-2020  rin Style and cosmetic changes. No binary changes intended.
 1.1 02-Aug-2011  matt branches: 1.1.2;
Add simple driver to count single bit ECC errors.
 1.1.2.2 14-Oct-2011  matt Sync with current pulling P2020 and other newer processor support.
 1.1.2.1 02-Aug-2011  matt file pq3ddrc.c was added on branch matt-nb5-pq3 on 2011-10-14 17:21:25 +0000
 1.7 22-Jul-2022  thorpej Normalize how motoi2c controllers are attached.
 1.6 22-Jul-2022  thorpej Split the i2c controller into 2 separate instances. This aligns with
how the device is represented when using DeviceTree, and also allows us
to de-weirdify the shared motoi2c code.

XXX Because e500 interrupt code doesn't support shared interrupts, we
no longer establish one for the i2c controller, but this isn't a great
loss as motoi2c doesn't support using interrupts right now anyway.
 1.5 06-Jul-2020  rin Style and cosmetic changes. No binary changes intended.
 1.4 03-Sep-2018  riastradh Rename min/max -> uimin/uimax for better honesty.

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

HOWEVER! Some subsystems have

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

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

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

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

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

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

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)
 1.3 01-Aug-2011  matt branches: 1.3.52; 1.3.54;
Add missing __KERNEL_RCSID
 1.2 18-Jan-2011  matt branches: 1.2.4;
Add support for BookE Freescale MPC85xx (e500 core) processors.
Add fast softint support for PowerPC (though only booke uses it).
Redo FPU/VEC support and add e500 SPE support.
Rework trap/intrs to use a common trapframe format.
Support SOFTFLOAT (no hardfloat or fpu emulation) for BookE.
 1.1 07-Jan-2011  matt branches: 1.1.2; 1.1.4;
file pq3diic.c was initially added on branch matt-nb5-pq3.
 1.1.4.1 06-Jun-2011  jruoho Sync with HEAD.
 1.1.2.1 07-Jan-2011  matt Add mpc85xx support for netbsd-5 (with some incompatible kernel changes).
 1.2.4.2 05-Mar-2011  rmind sync with head
 1.2.4.1 18-Jan-2011  rmind file pq3diic.c was added on branch rmind-uvmplock on 2011-03-05 20:51:34 +0000
 1.3.54.1 10-Jun-2019  christos Sync with HEAD
 1.3.52.1 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.8 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.7 24-Apr-2021  thorpej branches: 1.7.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.6 06-Jul-2020  rin branches: 1.6.4;
Style and cosmetic changes. No binary changes intended.
 1.5 08-Dec-2018  thorpej Clean up initialization of com_regs structure, in preparation for
some additional changers.
 1.4 03-Sep-2018  riastradh Rename min/max -> uimin/uimax for better honesty.

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

HOWEVER! Some subsystems have

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

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

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

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

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

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

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)
 1.3 01-Aug-2011  matt branches: 1.3.52; 1.3.54;
Add missing __KERNEL_RCSID
 1.2 18-Jan-2011  matt branches: 1.2.4;
Add support for BookE Freescale MPC85xx (e500 core) processors.
Add fast softint support for PowerPC (though only booke uses it).
Redo FPU/VEC support and add e500 SPE support.
Rework trap/intrs to use a common trapframe format.
Support SOFTFLOAT (no hardfloat or fpu emulation) for BookE.
 1.1 07-Jan-2011  matt branches: 1.1.2; 1.1.4;
file pq3duart.c was initially added on branch matt-nb5-pq3.
 1.1.4.1 06-Jun-2011  jruoho Sync with HEAD.
 1.1.2.1 07-Jan-2011  matt Add mpc85xx support for netbsd-5 (with some incompatible kernel changes).
 1.2.4.2 05-Mar-2011  rmind sync with head
 1.2.4.1 18-Jan-2011  rmind file pq3duart.c was added on branch rmind-uvmplock on 2011-03-05 20:51:34 +0000
 1.3.54.1 10-Jun-2019  christos Sync with HEAD
 1.3.52.2 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.3.52.1 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.6.4.2 22-Mar-2021  thorpej Audit CFARG_IATTR in config_found() calls, and remove it in situations
where the interface attribute is not ambiguous.
 1.6.4.1 22-Mar-2021  thorpej Mechanical conversion of config_found_sm_loc() -> config_found().
CFARG_IATTR usage needs to be audited.
 1.7.8.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.12 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.11 24-Apr-2021  thorpej branches: 1.11.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.10 06-Jul-2020  rin branches: 1.10.4;
Style and cosmetic changes. No binary changes intended.
 1.9 21-Aug-2019  msaitoh Fix typo (s/contoller/controller/).
 1.8 23-Apr-2016  skrll branches: 1.8.18;
Merge nick-nhusb

- API / infrastructure changes to support memory management changes.
- Memory management improvements and bug fixes.
- HCDs should now be MP safe
- conversion to KERNHIST based debug
- FS/LS isoc support on ehci(4).
- conversion to kmem(9)
- Some USB 3 support - mostly from Takahiro HAYASHI (t-hash).
- interrupt transfers now get proper DMA operations
- general bug fixes
- kern/48308
- uhub status notification improvements
- umass(4) probe fix (applied to HEAD already)
- ohci(4) short transfer fix
 1.7 11-Sep-2015  skrll Trailing whitespace
 1.6 11-Sep-2015  skrll Fix up USBMODE registers in sc_vendor_init functions and not in the ehci
driver.
 1.5 20-Jul-2012  matt branches: 1.5.2; 1.5.14; 1.5.16; 1.5.20;
EHCI_USBINTR is 4 bytes long so use EOWRITE4
 1.4 12-Jun-2011  matt branches: 1.4.2;
Make sure to enable the USB interface.
 1.3 16-Feb-2011  matt branches: 1.3.2; 1.3.4;
Use LE bus space tag for EHCI register access.
Initialize SNOOP for all of RAM.
Use IPL_USB
 1.2 18-Jan-2011  matt branches: 1.2.2;
Add support for BookE Freescale MPC85xx (e500 core) processors.
Add fast softint support for PowerPC (though only booke uses it).
Redo FPU/VEC support and add e500 SPE support.
Rework trap/intrs to use a common trapframe format.
Support SOFTFLOAT (no hardfloat or fpu emulation) for BookE.
 1.1 07-Jan-2011  matt branches: 1.1.2; 1.1.4;
file pq3ehci.c was initially added on branch matt-nb5-pq3.
 1.1.4.1 06-Jun-2011  jruoho Sync with HEAD.
 1.1.2.2 02-Aug-2011  matt Pull in changes from -current to get ehci at cpunode working.
 1.1.2.1 07-Jan-2011  matt Add mpc85xx support for netbsd-5 (with some incompatible kernel changes).
 1.2.2.1 17-Feb-2011  bouyer Sync with HEAD
 1.3.4.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.3.2.2 05-Mar-2011  rmind sync with head
 1.3.2.1 16-Feb-2011  rmind file pq3ehci.c was added on branch rmind-uvmplock on 2011-03-05 20:51:34 +0000
 1.4.2.1 30-Oct-2012  yamt sync with head
 1.5.20.1 06-Sep-2016  skrll First pass at netbsd-7 updated with USB code from HEAD
 1.5.16.4 22-Sep-2015  skrll Sync with HEAD
 1.5.16.3 06-Apr-2015  skrll ehci_init return int not usb_status_t
 1.5.16.2 03-Dec-2014  skrll The grand renaming of structure members.

No functional change.
 1.5.16.1 03-Dec-2014  skrll Trailing whitespace.
 1.5.14.1 05-Apr-2017  snj Pull up following revision(s) (requested by skrll in ticket #1395):
share/man/man4/axe.4: netbsd-7-nhusb
share/man/man4/axen.4: netbsd-7-nhusb
share/man/man4/cdce.4: netbsd-7-nhusb
share/man/man4/uaudio.4: netbsd-7-nhusb
share/man/man4/ucom.4: netbsd-7-nhusb
share/man/man4/uep.4: netbsd-7-nhusb
share/man/man4/urtw.4: netbsd-7-nhusb
share/man/man4/usb.4: netbsd-7-nhusb
share/man/man4/uyap.4: netbsd-7-nhusb
share/man/man4/xhci.4: netbsd-7-nhusb
share/man/man9/usbdi.9: netbsd-7-nhusb
sys/arch/amd64/conf/ALL: netbsd-7-nhusb
sys/arch/amd64/conf/GENERIC: netbsd-7-nhusb
sys/arch/amiga/dev/slhci_zbus.c: netbsd-7-nhusb
sys/arch/arm/allwinner/awin_otg.c: netbsd-7-nhusb
sys/arch/arm/allwinner/awin_usb.c: netbsd-7-nhusb
sys/arch/arm/amlogic/amlogic_dwctwo.c: netbsd-7-nhusb
sys/arch/arm/at91/at91ohci.c: netbsd-7-nhusb
sys/arch/arm/broadcom/bcm2835_dwctwo.c: netbsd-7-nhusb
sys/arch/arm/broadcom/bcm53xx_usb.c: netbsd-7-nhusb
sys/arch/arm/ep93xx/epohci.c: netbsd-7-nhusb
sys/arch/arm/gemini/obio_ehci.c: netbsd-7-nhusb
sys/arch/arm/imx/files.imx23: netbsd-7-nhusb
sys/arch/arm/imx/imxusb.c: netbsd-7-nhusb
sys/arch/arm/imx/imxusbreg.h: netbsd-7-nhusb
sys/arch/arm/omap/obio_ohci.c: netbsd-7-nhusb
sys/arch/arm/omap/omap3_ehci.c: netbsd-7-nhusb
sys/arch/arm/omap/omapl1x_ohci.c: netbsd-7-nhusb
sys/arch/arm/omap/tiotg.c: netbsd-7-nhusb
sys/arch/arm/s3c2xx0/ohci_s3c24x0.c: netbsd-7-nhusb
sys/arch/arm/samsung/exynos_usb.c: netbsd-7-nhusb
sys/arch/arm/xscale/pxa2x0_ohci.c: netbsd-7-nhusb
sys/arch/arm/zynq/zynq_usb.c: netbsd-7-nhusb
sys/arch/hpcarm/dev/nbp_slhci.c: netbsd-7-nhusb
sys/arch/hpcmips/dev/plumohci.c: netbsd-7-nhusb
sys/arch/i386/conf/ALL: netbsd-7-nhusb
sys/arch/i386/conf/GENERIC: netbsd-7-nhusb
sys/arch/i386/pci/gcscehci.c: netbsd-7-nhusb
sys/arch/luna68k/conf/GENERIC: netbsd-7-nhusb
sys/arch/mips/adm5120/dev/ahci.c: netbsd-7-nhusb
sys/arch/mips/adm5120/dev/ahcivar.h: netbsd-7-nhusb
sys/arch/mips/alchemy/dev/ohci_aubus.c: netbsd-7-nhusb
sys/arch/mips/atheros/dev/ehci_arbus.c: netbsd-7-nhusb
sys/arch/mips/atheros/dev/ohci_arbus.c: netbsd-7-nhusb
sys/arch/mips/conf/files.adm5120: netbsd-7-nhusb
sys/arch/mips/ralink/ralink_ehci.c: netbsd-7-nhusb
sys/arch/mips/ralink/ralink_ohci.c: netbsd-7-nhusb
sys/arch/mips/rmi/rmixl_ehci.c: netbsd-7-nhusb
sys/arch/mips/rmi/rmixl_ohci.c: netbsd-7-nhusb
sys/arch/playstation2/dev/ohci_sbus.c: netbsd-7-nhusb
sys/arch/powerpc/booke/dev/pq3ehci.c: netbsd-7-nhusb
sys/arch/powerpc/ibm4xx/dev/dwctwo_plb.c: netbsd-7-nhusb
sys/arch/x68k/dev/slhci_intio.c: netbsd-7-nhusb
sys/conf/files: netbsd-7-nhusb
sys/dev/cardbus/ehci_cardbus.c: netbsd-7-nhusb
sys/dev/cardbus/ohci_cardbus.c: netbsd-7-nhusb
sys/dev/cardbus/uhci_cardbus.c: netbsd-7-nhusb
sys/dev/ic/sl811hs.c: netbsd-7-nhusb
sys/dev/ic/sl811hsvar.h: netbsd-7-nhusb
sys/dev/isa/slhci_isa.c: netbsd-7-nhusb
sys/dev/marvell/ehci_mv.c: netbsd-7-nhusb
sys/dev/pci/ehci_pci.c: netbsd-7-nhusb
sys/dev/pci/ohci_pci.c: netbsd-7-nhusb
sys/dev/pci/uhci_pci.c: netbsd-7-nhusb
sys/dev/pci/xhci_pci.c: netbsd-7-nhusb
sys/dev/pcmcia/slhci_pcmcia.c: netbsd-7-nhusb
sys/dev/usb/Makefile.usbdevs: netbsd-7-nhusb
sys/dev/usb/TODO: netbsd-7-nhusb
sys/dev/usb/TODO.usbmp: netbsd-7-nhusb
sys/dev/usb/aubtfwl.c: netbsd-7-nhusb
sys/dev/usb/auvitek.c: netbsd-7-nhusb
sys/dev/usb/auvitek_audio.c: netbsd-7-nhusb
sys/dev/usb/auvitek_dtv.c: netbsd-7-nhusb
sys/dev/usb/auvitek_i2c.c: netbsd-7-nhusb
sys/dev/usb/auvitek_video.c: netbsd-7-nhusb
sys/dev/usb/auvitekvar.h: netbsd-7-nhusb
sys/dev/usb/ehci.c: netbsd-7-nhusb
sys/dev/usb/ehcireg.h: netbsd-7-nhusb
sys/dev/usb/ehcivar.h: netbsd-7-nhusb
sys/dev/usb/emdtv.c: netbsd-7-nhusb
sys/dev/usb/emdtv_dtv.c: netbsd-7-nhusb
sys/dev/usb/emdtv_ir.c: netbsd-7-nhusb
sys/dev/usb/emdtvvar.h: netbsd-7-nhusb
sys/dev/usb/ezload.c: netbsd-7-nhusb
sys/dev/usb/ezload.h: netbsd-7-nhusb
sys/dev/usb/files.usb: netbsd-7-nhusb
sys/dev/usb/hid.c: netbsd-7-nhusb
sys/dev/usb/hid.h: netbsd-7-nhusb
sys/dev/usb/if_athn_usb.c: netbsd-7-nhusb
sys/dev/usb/if_athn_usb.h: netbsd-7-nhusb
sys/dev/usb/if_atu.c: netbsd-7-nhusb
sys/dev/usb/if_atureg.h: netbsd-7-nhusb
sys/dev/usb/if_aue.c: netbsd-7-nhusb
sys/dev/usb/if_auereg.h: netbsd-7-nhusb
sys/dev/usb/if_axe.c: netbsd-7-nhusb
sys/dev/usb/if_axen.c: netbsd-7-nhusb
sys/dev/usb/if_axenreg.h: netbsd-7-nhusb
sys/dev/usb/if_axereg.h: netbsd-7-nhusb
sys/dev/usb/if_cdce.c: netbsd-7-nhusb
sys/dev/usb/if_cdcereg.h: netbsd-7-nhusb
sys/dev/usb/if_cue.c: netbsd-7-nhusb
sys/dev/usb/if_cuereg.h: netbsd-7-nhusb
sys/dev/usb/if_kue.c: netbsd-7-nhusb
sys/dev/usb/if_kuereg.h: netbsd-7-nhusb
sys/dev/usb/if_otus.c: netbsd-7-nhusb
sys/dev/usb/if_otusvar.h: netbsd-7-nhusb
sys/dev/usb/if_rum.c: netbsd-7-nhusb
sys/dev/usb/if_rumreg.h: netbsd-7-nhusb
sys/dev/usb/if_rumvar.h: netbsd-7-nhusb
sys/dev/usb/if_run.c: netbsd-7-nhusb
sys/dev/usb/if_runvar.h: netbsd-7-nhusb
sys/dev/usb/if_smsc.c: netbsd-7-nhusb
sys/dev/usb/if_smscreg.h: netbsd-7-nhusb
sys/dev/usb/if_smscvar.h: netbsd-7-nhusb
sys/dev/usb/if_udav.c: netbsd-7-nhusb
sys/dev/usb/if_udavreg.h: netbsd-7-nhusb
sys/dev/usb/if_upgt.c: netbsd-7-nhusb
sys/dev/usb/if_upgtvar.h: netbsd-7-nhusb
sys/dev/usb/if_upl.c: netbsd-7-nhusb
sys/dev/usb/if_ural.c: netbsd-7-nhusb
sys/dev/usb/if_uralreg.h: netbsd-7-nhusb
sys/dev/usb/if_uralvar.h: netbsd-7-nhusb
sys/dev/usb/if_url.c: netbsd-7-nhusb
sys/dev/usb/if_urlreg.h: netbsd-7-nhusb
sys/dev/usb/if_urndis.c: netbsd-7-nhusb
sys/dev/usb/if_urndisreg.h: netbsd-7-nhusb
sys/dev/usb/if_urtw.c: netbsd-7-nhusb
sys/dev/usb/if_urtwn.c: netbsd-7-nhusb
sys/dev/usb/if_urtwn_data.h: netbsd-7-nhusb
sys/dev/usb/if_urtwnreg.h: netbsd-7-nhusb
sys/dev/usb/if_urtwnvar.h: netbsd-7-nhusb
sys/dev/usb/if_urtwreg.h: netbsd-7-nhusb
sys/dev/usb/if_zyd.c: netbsd-7-nhusb
sys/dev/usb/if_zydreg.h: netbsd-7-nhusb
sys/dev/usb/irmce.c: netbsd-7-nhusb
sys/dev/usb/moscom.c: netbsd-7-nhusb
sys/dev/usb/motg.c: netbsd-7-nhusb
sys/dev/usb/motgvar.h: netbsd-7-nhusb
sys/dev/usb/ohci.c: netbsd-7-nhusb
sys/dev/usb/ohcireg.h: netbsd-7-nhusb
sys/dev/usb/ohcivar.h: netbsd-7-nhusb
sys/dev/usb/pseye.c: netbsd-7-nhusb
sys/dev/usb/slurm.c: netbsd-7-nhusb
sys/dev/usb/stuirda.c: netbsd-7-nhusb
sys/dev/usb/u3g.c: netbsd-7-nhusb
sys/dev/usb/uark.c: netbsd-7-nhusb
sys/dev/usb/uatp.c: netbsd-7-nhusb
sys/dev/usb/uaudio.c: netbsd-7-nhusb
sys/dev/usb/uberry.c: netbsd-7-nhusb
sys/dev/usb/ubsa.c: netbsd-7-nhusb
sys/dev/usb/ubsa_common.c: netbsd-7-nhusb
sys/dev/usb/ubsavar.h: netbsd-7-nhusb
sys/dev/usb/ubt.c: netbsd-7-nhusb
sys/dev/usb/uchcom.c: netbsd-7-nhusb
sys/dev/usb/ucom.c: netbsd-7-nhusb
sys/dev/usb/ucomvar.h: netbsd-7-nhusb
sys/dev/usb/ucycom.c: netbsd-7-nhusb
sys/dev/usb/udl.c: netbsd-7-nhusb
sys/dev/usb/udl.h: netbsd-7-nhusb
sys/dev/usb/udsbr.c: netbsd-7-nhusb
sys/dev/usb/udsir.c: netbsd-7-nhusb
sys/dev/usb/uep.c: netbsd-7-nhusb
sys/dev/usb/uftdi.c: netbsd-7-nhusb
sys/dev/usb/uftdireg.h: netbsd-7-nhusb
sys/dev/usb/ugen.c: netbsd-7-nhusb
sys/dev/usb/ugensa.c: netbsd-7-nhusb
sys/dev/usb/uhci.c: netbsd-7-nhusb
sys/dev/usb/uhcireg.h: netbsd-7-nhusb
sys/dev/usb/uhcivar.h: netbsd-7-nhusb
sys/dev/usb/uhid.c: netbsd-7-nhusb
sys/dev/usb/uhidev.c: netbsd-7-nhusb
sys/dev/usb/uhidev.h: netbsd-7-nhusb
sys/dev/usb/uhmodem.c: netbsd-7-nhusb
sys/dev/usb/uhso.c: netbsd-7-nhusb
sys/dev/usb/uhub.c: netbsd-7-nhusb
sys/dev/usb/uipad.c: netbsd-7-nhusb
sys/dev/usb/uipaq.c: netbsd-7-nhusb
sys/dev/usb/uirda.c: netbsd-7-nhusb
sys/dev/usb/uirdavar.h: netbsd-7-nhusb
sys/dev/usb/ukbd.c: netbsd-7-nhusb
sys/dev/usb/ukbdmap.c: netbsd-7-nhusb
sys/dev/usb/ukyopon.c: netbsd-7-nhusb
sys/dev/usb/ukyopon.h: netbsd-7-nhusb
sys/dev/usb/ulpt.c: netbsd-7-nhusb
sys/dev/usb/umass.c: netbsd-7-nhusb
sys/dev/usb/umass_isdata.c: netbsd-7-nhusb
sys/dev/usb/umass_isdata.h: netbsd-7-nhusb
sys/dev/usb/umass_quirks.c: netbsd-7-nhusb
sys/dev/usb/umass_quirks.h: netbsd-7-nhusb
sys/dev/usb/umass_scsipi.c: netbsd-7-nhusb
sys/dev/usb/umass_scsipi.h: netbsd-7-nhusb
sys/dev/usb/umassvar.h: netbsd-7-nhusb
sys/dev/usb/umcs.c: netbsd-7-nhusb
sys/dev/usb/umct.c: netbsd-7-nhusb
sys/dev/usb/umidi.c: netbsd-7-nhusb
sys/dev/usb/umidi_quirks.c: netbsd-7-nhusb
sys/dev/usb/umidi_quirks.h: netbsd-7-nhusb
sys/dev/usb/umodem.c: netbsd-7-nhusb
sys/dev/usb/umodem_common.c: netbsd-7-nhusb
sys/dev/usb/umodemvar.h: netbsd-7-nhusb
sys/dev/usb/ums.c: netbsd-7-nhusb
sys/dev/usb/uplcom.c: netbsd-7-nhusb
sys/dev/usb/urio.c: netbsd-7-nhusb
sys/dev/usb/urio.h: netbsd-7-nhusb
sys/dev/usb/usb.c: netbsd-7-nhusb
sys/dev/usb/usb.h: netbsd-7-nhusb
sys/dev/usb/usb_mem.c: netbsd-7-nhusb
sys/dev/usb/usb_mem.h: netbsd-7-nhusb
sys/dev/usb/usb_quirks.c: netbsd-7-nhusb
sys/dev/usb/usb_quirks.h: netbsd-7-nhusb
sys/dev/usb/usb_subr.c: netbsd-7-nhusb
sys/dev/usb/usbdevices.config: netbsd-7-nhusb
sys/dev/usb/usbdevs: netbsd-7-nhusb
sys/dev/usb/usbdevs.h: netbsd-7-nhusb
sys/dev/usb/usbdevs_data.h: netbsd-7-nhusb
sys/dev/usb/usbdi.c: netbsd-7-nhusb
sys/dev/usb/usbdi.h: netbsd-7-nhusb
sys/dev/usb/usbdi_util.c: netbsd-7-nhusb
sys/dev/usb/usbdi_util.h: netbsd-7-nhusb
sys/dev/usb/usbdivar.h: netbsd-7-nhusb
sys/dev/usb/usbhid.h: netbsd-7-nhusb
sys/dev/usb/usbhist.h: netbsd-7-nhusb
sys/dev/usb/usbroothub.c: netbsd-7-nhusb
sys/dev/usb/usbroothub.h: netbsd-7-nhusb
sys/dev/usb/usbroothub_subr.c: delete
sys/dev/usb/usbroothub_subr.h: delete
sys/dev/usb/uscanner.c: netbsd-7-nhusb
sys/dev/usb/uslsa.c: netbsd-7-nhusb
sys/dev/usb/usscanner.c: netbsd-7-nhusb
sys/dev/usb/ustir.c: netbsd-7-nhusb
sys/dev/usb/uthum.c: netbsd-7-nhusb
sys/dev/usb/utoppy.c: netbsd-7-nhusb
sys/dev/usb/uts.c: netbsd-7-nhusb
sys/dev/usb/uvideo.c: netbsd-7-nhusb
sys/dev/usb/uvisor.c: netbsd-7-nhusb
sys/dev/usb/uvscom.c: netbsd-7-nhusb
sys/dev/usb/uyap.c: netbsd-7-nhusb
sys/dev/usb/uyap_firmware.h: netbsd-7-nhusb
sys/dev/usb/uyurex.c: netbsd-7-nhusb
sys/dev/usb/x1input_rdesc.h: netbsd-7-nhusb
sys/dev/usb/xhci.c: netbsd-7-nhusb
sys/dev/usb/xhcireg.h: netbsd-7-nhusb
sys/dev/usb/xhcivar.h: netbsd-7-nhusb
sys/dev/usb/xinput_rdesc.h: netbsd-7-nhusb
sys/external/bsd/common/conf/files.linux: netbsd-7-nhusb
sys/external/bsd/common/include/linux/err.h: netbsd-7-nhusb
sys/external/bsd/common/include/linux/kernel.h: netbsd-7-nhusb
sys/external/bsd/common/include/linux/workqueue.h: netbsd-7-nhusb
sys/external/bsd/common/linux/linux_work.c: netbsd-7-nhusb
sys/external/bsd/drm2/dist/drm/radeon/atombios_encoders.c: netbsd-7-nhusb
sys/external/bsd/drm2/dist/drm/radeon/radeon_legacy_encoders.c: netbsd-7-nhusb
sys/external/bsd/drm2/drm/files.drmkms: netbsd-7-nhusb
sys/external/bsd/drm2/i915drm/files.i915drmkms: netbsd-7-nhusb
sys/external/bsd/drm2/include/linux/err.h: delete
sys/external/bsd/drm2/include/linux/workqueue.h: delete
sys/external/bsd/drm2/linux/files.drmkms_linux: netbsd-7-nhusb
sys/external/bsd/drm2/linux/linux_work.c: delete
sys/external/bsd/dwc2/dwc2.c: netbsd-7-nhusb
sys/external/bsd/dwc2/dwc2.h: netbsd-7-nhusb
sys/external/bsd/dwc2/dwc2var.h: netbsd-7-nhusb
sys/external/bsd/dwc2/dwctwo2netbsd: netbsd-7-nhusb
sys/external/bsd/dwc2/conf/files.dwc2: netbsd-7-nhusb
sys/external/bsd/dwc2/dist/dwc2_core.c: netbsd-7-nhusb
sys/external/bsd/dwc2/dist/dwc2_core.h: netbsd-7-nhusb
sys/external/bsd/dwc2/dist/dwc2_coreintr.c: netbsd-7-nhusb
sys/external/bsd/dwc2/dist/dwc2_hcd.c: netbsd-7-nhusb
sys/external/bsd/dwc2/dist/dwc2_hcd.h: netbsd-7-nhusb
sys/external/bsd/dwc2/dist/dwc2_hcdddma.c: netbsd-7-nhusb
sys/external/bsd/dwc2/dist/dwc2_hcdintr.c: netbsd-7-nhusb
sys/external/bsd/dwc2/dist/dwc2_hcdqueue.c: netbsd-7-nhusb
sys/external/bsd/dwc2/dist/dwc2_hw.h: netbsd-7-nhusb
sys/modules/drmkms_linux/Makefile: netbsd-7-nhusb
sys/modules/i915drmkms/Makefile: netbsd-7-nhusb
sys/rump/dev/lib/libugenhc/ugenhc.c: netbsd-7-nhusb
sys/rump/dev/lib/libusb/Makefile: netbsd-7-nhusb
sys/rump/dev/lib/libusb/USB.ioconf: netbsd-7-nhusb
sys/rump/dev/lib/libusb/usb_at_ugenhc.c: delete
sys/rump/dev/lib/libusb/opt/opt_usb.h: delete
sys/rump/dev/lib/libusb/opt/opt_usbverbose.h: delete
sys/sys/mbuf.h: netbsd-7-nhusb
usr.sbin/usbdevs/usbdevs.8: netbsd-7-nhusb
usr.sbin/usbdevs/usbdevs.c: netbsd-7-nhusb
Merge netbsd-7-nhusb:
- API / infrastructure changes to support memory management changes.
- Memory management improvements and bug fixes.
- HCDs should now be MP safe
- conversion to KERNHIST based debug
- FS/LS isoc support on ehci(4).
- conversion to kmem(9)
- Some USB 3 support - mostly from Takahiro HAYASHI (t-hash).
- interrupt transfers now get proper DMA operations
- general bug fixes
- kern/48308
- uhub status notification improvements
- umass(4) probe fix (applied to HEAD already)
- ohci(4) short transfer fix
- Change the SOFTINT level from NET to SERIAL for the USB softint handler.
This gives the callback a chance of running when another softint handler
at SOFTINT_NET has blocked holding a lock, e.g. softnet_lock and most of
the network stack.
- kern/49065 - ifconfig tun0 ... sequence locks up system / lockup:
softnet_lock held across usb xfr
- kern/50491 - unkillable wait in usbd_transfer while using usmsc0
on raspberry pi 2
- kern/51395 - USB Ethernet makes xhci hang
- Various improvements to slhci(4)
- Various improvements to dwc2(4)
 1.5.2.1 03-Dec-2017  jdolecek update from HEAD
 1.8.18.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.10.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.11.8.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.62 26-Oct-2025  andvar s/creat /create/ in few more comments and error log messages.
 1.61 07-Jan-2025  andvar s/remaing/remaining/ s/containg/containing/, mainly in comments.
 1.60 29-Jun-2024  riastradh branches: 1.60.2;
if_stats(9): Add ifp argument to if_stat..._ref.

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

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

PR kern/58377
 1.59 09-Feb-2024  andvar fix spelling mistakes, mainly in comments and log messages.
 1.58 18-Sep-2022  thorpej Eliminate use of IFF_OACTIVE.
 1.57 07-May-2022  rin Obsolete mdio_lock for pq3mdio_mii_{read,write}reg().

Callers (mii(4) layer and atphy(4) driver) acquire mii_lock() for
this purpose.

Found by LOCKDEBUG.
 1.56 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.55 16-Jun-2021  riastradh branches: 1.55.2;
if_attach and if_initialize cannot fail, don't test return value

These were originally made failable back in 2017 when if_initialize
allocated a softint in every interface for link state changes, so
that it could fail gracefully instead of panicking:

https://mail-index.NetBSD.org/source-changes/2017/10/23/msg089053.html

However, this spawned many seldom- or never-tested error branches,
which are risky to have around. And that softint in every interface
has since been replaced by a single global workqueue, because link
state changes require thread context but not low latency or high
throughput:

https://mail-index.NetBSD.org/source-changes/2020/02/06/msg113759.html

So there is no longer any reason for if_initialize to fail. (The
subroutine if_stats_init can't fail because percpu_alloc can't fail
either.)

There is a snag: the softint_establish in if_percpuq_create could
fail, potentially leading to bad consequences later on trying to use
the softint. This change doesn't introduce any new bugs because of
the snag -- if_percpuq_attach was already broken. However, the snag
can be better addressed without spawning error branches, either by
using a single softint or making softints less scarce.

(Separate commit will change the signatures of if_attach and
if_initialize to return void, scheduled to ride whatever is the next
convenient kernel bump.)

Patch and testing on amd64 and evbmips64-eb by maya@; commit message
soliloquy, and compile-testing on evbppc/i386/earmv7hf, by me.
 1.54 24-Apr-2021  thorpej branches: 1.54.2;
Merge thorpej-cfargs branch:

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

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

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

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

...and a sentinel value CFARG_EOL.

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

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).
 1.53 22-Apr-2021  rin Fix rnd(9) support; events were not sampled actually in the previous.

Remove #if-0'ed and wrap long line for clarity.
 1.52 24-Jan-2021  rin branches: 1.52.2;
Add rnd(9) support.
 1.51 24-Jan-2021  rin Switch to if_percpuq_enqueue() from if_input().
 1.50 06-Jul-2020  rin branches: 1.50.2;
Style and cosmetic changes. No binary changes intended.
 1.49 30-Jan-2020  martin Fix typo
 1.48 29-Jan-2020  thorpej Adopt <net/if_stats.h>.
 1.47 30-Oct-2019  msaitoh branches: 1.47.2;
ether_input() automatically add input bytes to if_ibytes, so it's not
required to do in the driver who use ether_input().
 1.46 09-Jul-2019  msaitoh branches: 1.46.2;
Don't automatically set ec_capenable's ETHERCAP_VLAN_HWTAGGING bit in
vlan_config() to make it user-controllable. Instead, set the bit in
xxx_attach().
 1.45 28-May-2019  msaitoh Use ETHER_LOCK()/ETHER_UNLOCK() for all ethernet drivers to protect ec_multi*.
 1.44 23-May-2019  msaitoh No functional change:
- Simplify MII structure initialization and reference.
- u_int*_t -> uint*_t.
- KNF
 1.43 26-Apr-2019  msaitoh No functional change:
- u_int_{8,16,32}_t -> uint_{8,16,32}_t
- KNF.
- Tabify.
- Remove extra space.
 1.42 24-Apr-2019  msaitoh SIOCS is 'S'et function and the ioctl argument is ifreq.
SIOCG is 'G'et function and the ioctl armument is ifmediareq.
Before this change, SIOCG modify request unexpectedly but it doesn't cause a
real bug because the modification is overriden in ifmedia_ioctl().
 1.41 08-Mar-2019  msaitoh s/ the the / the /
 1.40 22-Jan-2019  msaitoh Change MII PHY read/write API from:

int (*mii_readreg_t)(device_t, int, int);
void (*mii_writereg_t)(device_t, int, int, int);
to:

int (*mii_readreg_t)(device_t, int, int, uint16_t *);
int (*mii_writereg_t)(device_t, int, int, uint16_t);

Now we can test if a read/write operation failed or not by the return value.

In 802.3 spec says that the PHY shall not respond to read/write transaction
to the unimplemented register(22.2.4.3). Detecting timeout can be used to
check whether a register is implemented or not (if the register conforms to
the spec). ukphy(4) can be used this for MII_MMDACR and MII_MMDAADR.

Note that I noticed that the following code do infinite loop in the
read/wirte function. If it accesses unimplemented PHY register, it will hang.
It should be fixed:

arm/at91/at91emac.c
arm/ep93xx/epe.c
arm/omap/omapl1x_emac.c
mips/ralink/ralink_eth.c
arch/powerpc/booke/dev/pq3etsec.c(read)
dev/cadence/if_cemac.c <- hkenken
dev/ic/lan9118.c


Tested with the following device:

axe+ukphy
axe+rgephy
axen+rgephy (tested by Andrius V)
wm+atphy
wm+ukphy
wm+igphy
wm+ihphy
wm+makphy
sk+makphy
sk+brgphy
sk+gentbi
msk+makphy
sip+icsphy
sip+ukphy
re+rgephy
bge+brgphy
bnx+brgphy
gsip+gphyter
rtk+rlphy
fxp+inphy (tested by Andrius V)
tlp+acphy
ex+exphy
epic+qsphy
vge+ciphy (tested by Andrius V)
vr+ukphy (tested by Andrius V)
vte+ukphy (tested by Andrius V)

Not tested (MAC):
arm:at91emac
arm:cemac
arm:epe
arm:geminigmac
arm:enet
arm:cpsw
arm:emac(omac)
arm:emac(sunxi)
arm:npe
evbppc:temac
macppc:bm
macppc:gm
mips:aumac
mips:ae
mips:cnmac
mips:reth
mips:sbmac
playstation2:smap
powerpc:tsec
powerpc:emac(ibm4xx)
sgimips:mec
sparc:be
sf
ne(ax88190, dl10019)
awge
ep
gem
hme
smsh
mtd
sm
age
alc
ale
bce
cas
et
jme
lii
nfe
pcn
ste
stge
tl
xi
aue
mue
smsc
udav
url

Not tested (PHY):
amhphy
bmtphy
dmphy
etphy
glxtphy
ikphy
iophy
lxtphy
nsphyter
pnaphy
rdcphy
sqphy
tlphy
tqphy
urlphy
 1.39 22-Dec-2018  maxv Replace M_ALIGN and MH_ALIGN by m_align.
 1.38 22-Dec-2018  maxv Replace: M_MOVE_PKTHDR -> m_move_pkthdr. No functional change, since the
former is a macro to the latter.
 1.37 03-Sep-2018  riastradh Rename min/max -> uimin/uimax for better honesty.

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

HOWEVER! Some subsystems have

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

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

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

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

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

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

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)
 1.36 10-Aug-2018  maxv Rename

ip6_undefer_csum -> in6_undefer_cksum
in6_delayed_cksum -> in6_undefer_cksum_tcpudp

The two previous names were inconsistent and misleading.

Put the two functions into in6_offload.c. Add comments to explain what
we're doing.

Same as IPv4.
 1.35 11-Jul-2018  maxv Rename

ip_undefer_csum -> in_undefer_cksum
in_delayed_cksum -> in_undefer_cksum_tcpudp

The two previous names were inconsistent and misleading.

Put the two functions into in_offload.c. Add comments to explain what
we're doing.

The same could be done for IPv6.
 1.34 26-Jun-2018  msaitoh branches: 1.34.2;
Implement the BPF direction filter (BIOC[GS]DIRECTION). It provides backward
compatibility with BIOC[GS]SEESENT ioctl. The userland interface is the same
as FreeBSD.

This change also fixes a bug that the direction is misunderstand on some
environment by passing the direction to bpf_mtap*() instead of checking
m->m_pkthdr.rcvif.
 1.33 01-Jun-2018  maxv Rename

M_CSUM_DATA_IPv6_HL -> M_CSUM_DATA_IPv6_IPHL
M_CSUM_DATA_IPv6_HL_SET -> M_CSUM_DATA_IPv6_SET

Reduces the diff against IPv4. Also, clarify the definitions.
 1.32 23-Oct-2017  msaitoh branches: 1.32.2;
If error occured in pq3etsec_attach(), free resources and return.
 1.31 02-Oct-2017  knakahara only get vtag when we have vtag like the other drivers.

like if_bge.c:1.312 and if_stge.c:1.64.
fixed by s-yamaguchi@IIJ, thanks.
 1.30 26-Sep-2017  knakahara VLAN ID uses pkthdr instead of mtag now. Contributed by s-yamaguchi@IIJ.

I just commit by proxy. Reviewed by joerg@n.o and christos@n.o, thanks.
See http://mail-index.netbsd.org/tech-net/2017/09/26/msg006459.html

XXX need pullup to -8 branch
 1.29 15-Dec-2016  ozaki-r branches: 1.29.8;
Move bpf_mtap and if_ipackets++ on Rx of each driver to percpuq if_input

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

Proposed on tech-kern and tech-net
 1.28 26-Jul-2016  nonaka IFQ_PURGE() must be called only after call if_initialize().
it lock ifp->if_snd.ifq_lock.
 1.27 10-Jun-2016  ozaki-r branches: 1.27.2;
Introduce m_set_rcvif and m_reset_rcvif

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

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

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

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

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

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

Acknowledgment: riastradh@ greatly helped this work.
Thank you very much!
 1.25 17-Feb-2015  nonaka Added Interrupt coalescing support.
 1.24 23-Jan-2015  nonaka Avoid if_snd race condition when MP.
 1.23 16-Jan-2015  nonaka Fix various conditions with setting IMASK.
 1.22 16-Jan-2015  nonaka Added missing tx bpf_mtap().
 1.21 16-Jan-2015  nonaka Replace if_attach with if_initialize and if_register.
 1.20 16-Jan-2015  nonaka Use IFQ_* macro instead of IF_*.
 1.19 07-Jan-2015  nonaka Remove non-printable character.
 1.18 20-Dec-2014  nonaka Revert previous accidental commit.
 1.17 20-Dec-2014  nonaka Revert previous commit.
 1.16 22-Jul-2012  matt branches: 1.16.2; 1.16.16;
Split mdio/mii access into its own "device" and update accordingly.
(on the P1025 the mdio functionality is separate from the etsec functions).
Provide locking for mii access.
 1.15 17-Jul-2012  matt The ETSEC on the P1025 has been moved/split so the MDIO stayed in the same
place but each ETSEC has been split into two virtual halves (G0 and G1) and
each one has a new different base address.
For some reason, tsec1 connects to phy 2 and tsec2 connects to phy 1.
Adjust config file to match
 1.14 15-Jul-2012  matt Add support for the Freescale TWR-P1025 evaluation board and the P1025/P1016
QorIQ processors. XXX tsec isn't working yet on the TWR-P1025.
 1.13 07-May-2012  matt Preserve some MACCFG2 bits
 1.12 20-Apr-2012  matt Don't use the current value of maccfg2.
 1.11 19-Apr-2012  matt Read maccfg1/maccfg2/ecntrl so we can preserve bits we don't change (like
GMII mode).
 1.10 21-Feb-2012  matt Don't rely on being able to allocate while in a softintr. So preallocate
all the bus_dma maps in ifinit where we can sleep.
 1.9 13-Oct-2011  matt branches: 1.9.2; 1.9.6; 1.9.8;
Fix printing of phy.
 1.8 27-Sep-2011  jym Modify *ASSERTMSG() so they are now used as variadic macros. The main goal
is to provide routines that do as KASSERT(9) says: append a message
to the panic format string when the assertion triggers, with optional
arguments.

Fix call sites to reflect the new definition.

Discussed on tech-kern@. See
http://mail-index.netbsd.org/tech-kern/2011/09/07/msg011427.html
 1.7 01-Aug-2011  matt Add missing __KERNEL_RCSID
 1.6 21-Jun-2011  matt Add DEBUG around a variable.
 1.5 17-Jun-2011  matt struct device * -> device_t
struct cfdata * -> cfdata_t
split device/softc (CFATTACH_DECL_NEW)
use device_accessors and device_private
constify
 1.4 12-Jun-2011  matt Make sure initialize the ATTR registers.
 1.3 16-Mar-2011  matt branches: 1.3.2;
Fix various nits related to P2020 support.
 1.2 18-Jan-2011  matt branches: 1.2.4;
Add support for BookE Freescale MPC85xx (e500 core) processors.
Add fast softint support for PowerPC (though only booke uses it).
Redo FPU/VEC support and add e500 SPE support.
Rework trap/intrs to use a common trapframe format.
Support SOFTFLOAT (no hardfloat or fpu emulation) for BookE.
 1.1 07-Jan-2011  matt branches: 1.1.2; 1.1.4;
file pq3etsec.c was initially added on branch matt-nb5-pq3.
 1.1.4.1 06-Jun-2011  jruoho Sync with HEAD.
 1.1.2.2 11-Jan-2011  matt Fix bpf_mtap call (tcpdump now works).
 1.1.2.1 07-Jan-2011  matt Add mpc85xx support for netbsd-5 (with some incompatible kernel changes).
 1.2.4.3 21-Apr-2011  rmind sync with head
 1.2.4.2 05-Mar-2011  rmind sync with head
 1.2.4.1 18-Jan-2011  rmind file pq3etsec.c was added on branch rmind-uvmplock on 2011-03-05 20:51:34 +0000
 1.3.2.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.9.8.2 03-Jul-2012  jdc Pull up revision 1.10 (requested by matt in ticket #382).

Don't rely on being able to allocate while in a softintr. So preallocate
all the bus_dma maps in ifinit where we can sleep.
 1.9.8.1 17-May-2012  riz Pull up following revision(s) (requested by matt in ticket #245):
sys/arch/powerpc/booke/dev/pq3etsec.c: revision 1.13
sys/arch/powerpc/include/booke/etsecreg.h: revision 1.4
sys/arch/powerpc/booke/dev/pq3etsec.c: revision 1.11
sys/arch/powerpc/booke/dev/pq3etsec.c: revision 1.12
Read maccfg1/maccfg2/ecntrl so we can preserve bits we don't change (like
GMII mode).
Don't use the current value of maccfg2.
Preserve some MACCFG2 bits
 1.9.6.3 02-Jun-2012  mrg sync to latest -current.
 1.9.6.2 29-Apr-2012  mrg sync to latest -current.
 1.9.6.1 24-Feb-2012  mrg sync to -current.
 1.9.2.3 30-Oct-2012  yamt sync with head
 1.9.2.2 23-May-2012  yamt sync with head.
 1.9.2.1 17-Apr-2012  yamt sync with head
 1.16.16.5 05-Feb-2017  skrll Sync with HEAD
 1.16.16.4 05-Oct-2016  skrll Sync with HEAD
 1.16.16.3 09-Jul-2016  skrll Sync with HEAD
 1.16.16.2 19-Mar-2016  skrll Sync with HEAD
 1.16.16.1 06-Apr-2015  skrll Sync with HEAD
 1.16.2.1 03-Dec-2017  jdolecek update from HEAD
 1.27.2.2 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.27.2.1 26-Jul-2016  pgoyette Sync with HEAD
 1.29.8.3 06-Nov-2019  martin Pull up following revision(s) (requested by msaitoh in ticket #1427):

sys/arch/arm/broadcom/bcm53xx_eth.c: revision 1.39
sys/dev/pcmcia/if_xi.c: revision 1.91
sys/dev/ic/aic6915.c: revision 1.40
sys/dev/pci/if_tl.c: revision 1.117
sys/arch/arm/gemini/gemini_gmac.c: revision 1.18
sys/dev/ic/elinkxl.c: revision 1.133
sys/dev/pci/if_ste.c: revision 1.57
sys/dev/pci/if_alc.c: revision 1.43
sys/dev/pci/if_stge.c: revision 1.72
sys/dev/pci/if_ale.c: revision 1.34
sys/dev/pci/if_age.c: revision 1.62
sys/dev/pci/if_txp.c: revision 1.60
sys/dev/ic/i82557.c: revision 1.156
sys/dev/pci/if_vte.c: revision 1.27
sys/arch/powerpc/booke/dev/pq3etsec.c: revision 1.47
sys/arch/arm/gemini/if_gpn.c: revision 1.13

if_percpuq(9) and ether_input() automatically increment if_ipackets, so don't add number of
RX frames from device's statistics counter to if_ipackets to avoid double
count.
 1.29.8.2 10-Dec-2017  snj Pull up following revision(s) (requested by msaitoh in ticket #427):
sys/arch/amiga/dev/if_bah_zbus.c: 1.17
sys/arch/arm/broadcom/bcm53xx_eth.c: 1.30
sys/arch/powerpc/booke/dev/pq3etsec.c: 1.32
sys/arch/usermode/dev/if_veth.c: 1.9
sys/dev/ic/an.c: 1.66
sys/dev/ic/athn.c: 1.17
sys/dev/ic/atw.c: 1.162
sys/dev/ic/bwi.c: 1.33
sys/dev/ic/dwc_gmac.c: 1.41-1.42
sys/dev/ic/malo.c: 1.10
sys/dev/ic/rt2560.c: 1.31
sys/dev/ic/rt2661.c: 1.36
sys/dev/ic/rt2860.c: 1.29
sys/dev/ic/rtw.c: 1.127
sys/dev/ic/rtwvar.h: 1.46
sys/dev/ic/smc90cx6.c: 1.71
sys/dev/ic/smc90cx6var.h: 1.12
sys/dev/ic/wi.c: 1.244
sys/dev/pci/if_ipw.c: 1.66
sys/dev/pci/if_iwi.c: 1.104
sys/dev/pci/if_iwm.c: 1.76
sys/dev/pci/if_iwn.c: 1.86
sys/dev/pci/if_rtwn.c: 1.13
sys/dev/pci/if_wm.c: 1.541
sys/dev/pci/if_wpi.c: 1.79
sys/dev/pci/ixgbe/ixgbe.c: 1.106
sys/dev/pci/ixgbe/ixv.c: 1.73 via patch
sys/dev/pcmcia/if_malo_pcmcia.c: 1.15
sys/dev/scsipi/if_se.c: 1.95
sys/dev/usb/if_upl.c: 1.60
sys/net/if.c: 1.396
sys/net/if.h: 1.241
sys/net/if_arc.h: 1.23
sys/net/if_arcsubr.c: 1.78
sys/net/if_bridge.c: 1.136-1.137
sys/net/if_etherip.c: 1.39
sys/net/if_faith.c: 1.56
sys/net/if_gif.c: 1.131
sys/net/if_loop.c: 1.96
sys/net/if_mpls.c: 1.30
sys/net/if_pppoe.c: 1.129
sys/net/if_srt.c: 1.27
sys/net/if_stf.c: 1.102
sys/net/if_tap.c: 1.100
sys/net/if_vlan.c: 1.105
sys/netinet/ip_carp.c: 1.91
sys/rump/net/lib/libshmif/if_shmem.c: 1.73-1.74
sys/rump/net/lib/libvirtif/if_virt.c: 1.55-1.56
if_initalize() and if_attach() failed when resource allocation failed
(e.g. allocating softint). Without this change, it panics. It's bad because
resource shortage really occured when a lot of pseudo interface is created.
To avoid this problem, don't panic and change return value of if_initialize()
and if_attach() to int. Caller fanction will be recover from error cleanly by
checking the return value.
Return if bah_attach_subr() failed.
If if_attach() failed in the attach function, return.
- If if_initialize() failed in the attach function, free resources and return.
- Add some missing frees in bridge_clone_destroy().
- KNF
If error occured in bcmeth_ccb_attach(), free resources and return.
If error occured in pq3etsec_attach(), free resources and return.
If error occured in the attach function, free resources and return.
- If if_initialize() failed in athn_attach(), free resources and return.
- Add missing pmf_event_deregister() in athn_detach().
- Free resources correctly on some errors in atw_attach().
- Use apint*() insread of printf() in the attach function.
If if_initialize() failed in the attach function, return.
- If if_initialize() failed in the attach function, free resources and return.
- Add missing dwc_gmac_free_dma_rings() and mutex_destroy() when attach
failed.
- If if_initialize() failed in the attach function, free resources and return.
- ifp is always not NULL in iwi_detach(). Check correctly with ifp->if_softc.
- If if_initialize() failed in the attach function, free resources and return.
- Fix error path in the attach function correctly.
If if_initialize() failed in the attach function, free resources and return.
If if_attach() failed in the attach function, free resources and return.
- If if_initialize() failed in the attach function, free resources and return.
- KNF
- If if_attach() failed in the attach function, free resources and return.
- KNF
Fix compile error.
Fix compile error.
We don't need '&mii', but just 'mii' for mii_detach().
Don't free sc_rthash twice
 1.29.8.1 24-Oct-2017  snj Pull up following revision(s) (requested by knakahara in ticket #302):
sys/arch/powerpc/booke/dev/pq3etsec.c: 1.30-1.31
sys/arch/x86/pci/if_vmx.c: 1.20
sys/dev/ic/i82557.c: 1.148
sys/dev/ic/rtl8169.c: 1.152
sys/dev/pci/cxgb/cxgb_sge.c: 1.5
sys/dev/pci/if_age.c: 1.51
sys/dev/pci/if_alc.c: 1.25
sys/dev/pci/if_ale.c: 1.23
sys/dev/pci/if_bge.c: 1.311
sys/dev/pci/if_bge.c: 1.312
sys/dev/pci/if_bnx.c: 1.62
sys/dev/pci/if_jme.c: 1.32
sys/dev/pci/if_nfe.c: 1.64
sys/dev/pci/if_sip.c: 1.167
sys/dev/pci/if_stge.c: 1.63-1.64
sys/dev/pci/if_ti.c: 1.102
sys/dev/pci/if_txp.c: 1.48
sys/dev/pci/if_vge.c: 1.61
sys/dev/pci/if_wm.c: 1.538
sys/dev/pci/ixgbe/ix_txrx.c: 1.29 via patch
sys/net/agr/if_agrether_hash.c: 1.4
sys/net/if_ether.h: 1.67-1.68
sys/net/if_ethersubr.c: 1.244
sys/net/if_vlan.c: 1.100
sys/net80211/ieee80211_input.c: 1.89
sys/net80211/ieee80211_output.c: 1.59
sys/sys/mbuf.h: 1.171
VLAN ID uses pkthdr instead of mtag now. Contributed by s-yamaguchi@IIJ.
I just commit by proxy. Reviewed by joerg@n.o and christos@n.o, thanks.
See http://mail-index.netbsd.org/tech-net/2017/09/26/msg006459.html
--
only get vtag when we have vtag like the other drivers.
--
- only get the vtag if we have it like the other drivers
- mask the hardware vlan tag
--
- add a constant for the vlan mask.
- enforce that we have a tag before we get it.
only get vtag when we have vtag like the other drivers.
like if_bge.c:1.312 and if_stge.c:1.64.
fixed by s-yamaguchi@IIJ, thanks.
 1.32.2.5 26-Jan-2019  pgoyette Sync with HEAD
 1.32.2.4 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.32.2.3 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.32.2.2 28-Jul-2018  pgoyette Sync with HEAD
 1.32.2.1 25-Jun-2018  pgoyette Sync with HEAD
 1.34.2.3 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.34.2.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.34.2.1 10-Jun-2019  christos Sync with HEAD
 1.46.2.1 06-Nov-2019  martin Pull up following revision(s) (requested by msaitoh in ticket #403):

sys/arch/arm/broadcom/bcm53xx_eth.c: revision 1.39
sys/dev/pcmcia/if_xi.c: revision 1.91
sys/dev/ic/aic6915.c: revision 1.40
sys/dev/pci/if_tl.c: revision 1.117
sys/arch/arm/gemini/gemini_gmac.c: revision 1.18
sys/dev/ic/elinkxl.c: revision 1.133
sys/dev/pci/if_ste.c: revision 1.57
sys/dev/pci/if_alc.c: revision 1.43
sys/dev/pci/if_stge.c: revision 1.72
sys/dev/pci/if_ale.c: revision 1.34
sys/dev/pci/if_age.c: revision 1.62
sys/dev/pci/if_txp.c: revision 1.60
sys/dev/ic/i82557.c: revision 1.156
sys/dev/pci/if_vte.c: revision 1.27
sys/arch/powerpc/booke/dev/pq3etsec.c: revision 1.47
sys/arch/arm/gemini/if_gpn.c: revision 1.13

if_percpuq(9) and ether_input() automatically increment if_ipackets, so don't add number of
RX frames from device's statistics counter to if_ipackets to avoid double
count.
 1.47.2.1 29-Feb-2020  ad Sync with head.
 1.50.2.1 03-Apr-2021  thorpej Sync with HEAD.
 1.52.2.2 03-Apr-2021  thorpej Give config_attach() the tagged variadic argument treatment and
mechanically convert all call sites.
 1.52.2.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.54.2.1 17-Jun-2021  thorpej Sync w/ HEAD.
 1.55.2.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.60.2.1 02-Aug-2025  perseant Sync with HEAD
 1.15 10-Aug-2025  andvar Fix few typos in comments.
 1.14 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.13 24-Apr-2021  thorpej branches: 1.13.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.12 06-Jul-2020  rin branches: 1.12.4;
Style and cosmetic changes. No binary changes intended.
 1.11 27-Dec-2014  nonaka Preliminary support for P1023.
 1.10 20-Dec-2014  nonaka Revert previous accidental commit.
 1.9 20-Dec-2014  nonaka Revert previous commit.
 1.8 15-Jul-2012  matt branches: 1.8.2; 1.8.16;
Add support for the Freescale TWR-P1025 evaluation board and the P1025/P1016
QorIQ processors. XXX tsec isn't working yet on the TWR-P1025.
 1.7 19-May-2012  matt Fix a few compile problems on non-P2020 platforms.
 1.6 17-May-2012  matt The P2020 doesn't have GPIO in the same place as othe 85xx. Deal with it.
 1.5 29-Mar-2012  matt Fix P2020 GPIO support (which has pins that are input/output instead of just
input or output).
 1.4 30-Jun-2011  matt branches: 1.4.2; 1.4.6; 1.4.8;
Fix RCSID
 1.3 16-Mar-2011  matt Fix various nits related to P2020 support.
 1.2 18-Jan-2011  matt branches: 1.2.4;
Add support for BookE Freescale MPC85xx (e500 core) processors.
Add fast softint support for PowerPC (though only booke uses it).
Redo FPU/VEC support and add e500 SPE support.
Rework trap/intrs to use a common trapframe format.
Support SOFTFLOAT (no hardfloat or fpu emulation) for BookE.
 1.1 07-Jan-2011  matt branches: 1.1.2; 1.1.4;
file pq3gpio.c was initially added on branch matt-nb5-pq3.
 1.1.4.1 06-Jun-2011  jruoho Sync with HEAD.
 1.1.2.2 14-Oct-2011  matt Sync with current pulling P2020 and other newer processor support.
 1.1.2.1 07-Jan-2011  matt Add mpc85xx support for netbsd-5 (with some incompatible kernel changes).
 1.2.4.3 21-Apr-2011  rmind sync with head
 1.2.4.2 05-Mar-2011  rmind sync with head
 1.2.4.1 18-Jan-2011  rmind file pq3gpio.c was added on branch rmind-uvmplock on 2011-03-05 20:51:35 +0000
 1.4.8.1 09-May-2012  riz Pull up following revision(s) (requested by matt in ticket #243):
sys/arch/powerpc/booke/dev/pq3gpio.c: revision 1.5
Fix P2020 GPIO support (which has pins that are input/output instead of just
input or output).
 1.4.6.2 02-Jun-2012  mrg sync to latest -current.
 1.4.6.1 05-Apr-2012  mrg sync to latest -current.
 1.4.2.3 30-Oct-2012  yamt sync with head
 1.4.2.2 23-May-2012  yamt sync with head.
 1.4.2.1 17-Apr-2012  yamt sync with head
 1.8.16.1 06-Apr-2015  skrll Sync with HEAD
 1.8.2.1 03-Dec-2017  jdolecek update from HEAD
 1.12.4.1 02-Apr-2021  thorpej config_found_ia() -> config_found() w/ CFARG_IATTR.
 1.13.8.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.5 10-May-2023  riastradh powerpc: Use config_detach_children to reduce error branch bugs.
 1.4 06-Jul-2020  rin Drop unused opt_flash.h.
 1.3 06-Jul-2020  rin Style and cosmetic changes. No binary changes intended.
 1.2 17-Jul-2011  dyoung #include <sys/bus.h> not <machine/bus.h>.
 1.1 30-Jun-2011  matt Unfinished (by far) NAND driver.
 1.7 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.6 24-Apr-2021  thorpej branches: 1.6.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.5 06-Jul-2020  rin branches: 1.5.4;
Style and cosmetic changes. No binary changes intended.
 1.4 25-Jun-2020  jdolecek avoid variable-length array
 1.3 28-May-2011  matt Move obio softc definitions to a header so it can use by children of obio.
 1.2 18-Jan-2011  matt branches: 1.2.4;
Add support for BookE Freescale MPC85xx (e500 core) processors.
Add fast softint support for PowerPC (though only booke uses it).
Redo FPU/VEC support and add e500 SPE support.
Rework trap/intrs to use a common trapframe format.
Support SOFTFLOAT (no hardfloat or fpu emulation) for BookE.
 1.1 07-Jan-2011  matt branches: 1.1.2; 1.1.4;
file pq3obio.c was initially added on branch matt-nb5-pq3.
 1.1.4.1 06-Jun-2011  jruoho Sync with HEAD.
 1.1.2.2 26-Jul-2011  matt Back port improvements from -HEAD.
 1.1.2.1 07-Jan-2011  matt Add mpc85xx support for netbsd-5 (with some incompatible kernel changes).
 1.2.4.3 31-May-2011  rmind sync with head
 1.2.4.2 05-Mar-2011  rmind sync with head
 1.2.4.1 18-Jan-2011  rmind file pq3obio.c was added on branch rmind-uvmplock on 2011-03-05 20:51:35 +0000
 1.5.4.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.5.4.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.5.4.4 04-Apr-2021  thorpej CFARG_SUBMATCH -> CFARG_SEARCH for the indirect configuration uses.
 1.5.4.3 03-Apr-2021  thorpej config_attach_loc() -> config_attach() with CFARG_LOCATORS argument.
 1.5.4.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.5.4.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.6.8.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.6 27-Feb-2015  nonaka Enable DMA transfer.
 1.5 26-Jul-2012  matt branches: 1.5.2; 1.5.14; 1.5.16;
When using DMA, make sure to initialize SNOOPing.
 1.4 23-Feb-2012  matt Use the new 32-bit and ESDHC support in sdhc.c
 1.3 29-Jun-2011  matt branches: 1.3.2; 1.3.6; 1.3.8;
Use a private bus_space for freescale eSDHC controller (only allows
32 bit access).
 1.2 18-Jan-2011  matt branches: 1.2.4;
Add support for BookE Freescale MPC85xx (e500 core) processors.
Add fast softint support for PowerPC (though only booke uses it).
Redo FPU/VEC support and add e500 SPE support.
Rework trap/intrs to use a common trapframe format.
Support SOFTFLOAT (no hardfloat or fpu emulation) for BookE.
 1.1 07-Jan-2011  matt branches: 1.1.2; 1.1.4;
file pq3sdhc.c was initially added on branch matt-nb5-pq3.
 1.1.4.1 06-Jun-2011  jruoho Sync with HEAD.
 1.1.2.1 07-Jan-2011  matt Add mpc85xx support for netbsd-5 (with some incompatible kernel changes).
 1.2.4.2 05-Mar-2011  rmind sync with head
 1.2.4.1 18-Jan-2011  rmind file pq3sdhc.c was added on branch rmind-uvmplock on 2011-03-05 20:51:35 +0000
 1.3.8.1 11-Jun-2012  riz Pull up following revision(s) (requested by matt in ticket #254):
sys/arch/powerpc/booke/dev/pq3sdhc.c: revision 1.4
sys/dev/sdmmc/sdhc.c: revision 1.11
sys/dev/sdmmc/sdhc.c: revision 1.13
Use the new 32-bit and ESDHC support in sdhc.c
Support 32-bit only access to the SDHC registers.
Add support for FreeScale &quot;Enhanced&quot; SDHC port.
Add support for CGM mode (XLP and BCM2835 (Arason)).
Do not read past array end, found by gcc -O3.
This could cause to HWRITE4() a bad value, but maybe last 2 bytes are
probably ignored by hardware anyway.
 1.3.6.1 24-Feb-2012  mrg sync to -current.
 1.3.2.2 30-Oct-2012  yamt sync with head
 1.3.2.1 17-Apr-2012  yamt sync with head
 1.5.16.1 06-Apr-2015  skrll Sync with HEAD
 1.5.14.1 09-Mar-2015  snj Pull up following revision(s) (requested by nonaka in ticket #577):
sys/arch/powerpc/booke/dev/pq3sdhc.c: revision 1.6
sys/dev/sdmmc/sdhc.c: revision 1.54
sys/dev/sdmmc/sdmmc.c: revision 1.24
eSDHC has no DMA_BOUNDARY in BLOCK_SIZE register.
So clear multi segment DMA transfer support bit.
--
fix to simulate multi-segment dma transfer for pq3sdhc(4).
--
pq3sdhc: Enable DMA transfer.
 1.5.2.1 03-Dec-2017  jdolecek update from HEAD
 1.32 22-Jul-2022  thorpej Stop using deprecated proplib functions.
 1.31 07-May-2022  rin Downgrade pq3pci_intrsources_lock and pq3pci_msigroups_lock from
spin to adaptive mutexes.

These locks are typically used during autoconf(9), not from
interrupt context.

Found by LOCKDEBUG.

XXX
I'm not sure whether these locks are really necessary...
Similar codes, e.g. in powerpc/pic/intr.c, do not use any locks.
 1.30 11-Jan-2022  andvar fix few typos in comments.
 1.29 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.28 24-Apr-2021  thorpej branches: 1.28.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.27 12-Nov-2020  rin branches: 1.27.2;
pq3pci_msi_claim(): remove KASSERT that is valid when allocating MSI
vectors, while apparently invalid when freeing them.
 1.26 12-Nov-2020  rin Oops, forget to commit local change necessary to support nvme(4) on RB800;
provide pci_intr_setattr(9) (no-op).
 1.25 07-Jul-2020  thorpej branches: 1.25.2;
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.24 06-Jul-2020  rin Style and cosmetic changes. No binary changes intended.
 1.23 01-Jun-2017  chs remove checks for failure after memory allocation calls that cannot fail:

kmem_alloc() with KM_SLEEP
kmem_zalloc() with KM_SLEEP
percpu_alloc()
pserialize_create()
psref_class_create()

all of these paths include an assertion that the allocation has not failed,
so callers should not assert that again.
 1.22 19-Oct-2016  nonaka Added MSI/MSI-X and interrupt_distribute(9) support for powerpc.
 1.21 02-Oct-2015  msaitoh branches: 1.21.2;
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.20 27-Dec-2014  nonaka Preliminary support for P1023.
 1.19 20-Dec-2014  nonaka Revert previous accidental commit.
 1.18 20-Dec-2014  nonaka Revert previous commit.
 1.17 30-Jul-2014  joerg branches: 1.17.4;
pq3pci_config_addr_read is only used in a #if 0 block, so hide it under
the same condition.
 1.16 29-Mar-2014  christos branches: 1.16.2;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.15 14-Aug-2012  he branches: 1.15.2; 1.15.4;
Make this build again by adding a couple of right-parens.
 1.14 13-Aug-2012  matt Deal with PCIe/PCI hoses with more than one window so the bus_space
encompasses all of it and reserves those portions not assigned so
no one can allocate from them.
 1.13 18-Jul-2012  matt Add P1025 support to the PCI truth tables.
P1025 only has two PCIe ports, not 3.
 1.12 27-Jan-2012  para converting extent(9) from malloc(9) to kmem(9)
preceding kmem-vmem-pool-uvm patch

releng@ acknowledged
 1.11 27-Sep-2011  jym branches: 1.11.2; 1.11.6;
Modify *ASSERTMSG() so they are now used as variadic macros. The main goal
is to provide routines that do as KASSERT(9) says: append a message
to the panic format string when the assertion triggers, with optional
arguments.

Fix call sites to reflect the new definition.

Discussed on tech-kern@. See
http://mail-index.netbsd.org/tech-kern/2011/09/07/msg011427.html
 1.10 17-Aug-2011  matt First pass of the new PCI MSI/MSI ABI definitions. (return EOPNOTSUPP for
now).
 1.9 17-Aug-2011  dyoung Redefine PCI_MSI_* and PCI_PCIE_* constants in terms of bits(3).

Use named constants and more conventional variable names in
pci_msi_establish() and pci_msi_disestablish(). Fix a couple of bugs:
pci_msi_establish() returned a pointer to the struct intrhand instead of
to the struct msi_hdl as it was intended to, and pci_msi_disestablish()
did not free(9) the msi_hdl.
 1.8 22-Jun-2011  matt Add support pci_intr_setattr.
Export non-inline version of pci api for modules (_MODULE is defined).
Fix definition of pc_conf_hook and pc_conf_interrupt.
Switch to using inlines instead of macros.
Switch ibm4xx to use <powerpc/pci_machdep.h>
 1.7 08-Jun-2011  matt When delivering MSIs, sometimes after clearing the MSI but before the interrupt
routine get called the MSI reasserts and we loop around and would detect a
spurious interrupt.

So now we keep track of the interrupts we have serviced successfully for this
dispatch loop. If we have to invoke an interrupt handler and that handler
indicates nothing was serviced, if we previously serviced it it isn't counter
as a spurious interrupt.
 1.6 17-May-2011  dyoung branches: 1.6.2;
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.5 04-Apr-2011  dyoung Neither pci_dma64_available(), pci_probe_device(), pci_mapreg_map(9),
pci_find_rom(), pci_intr_map(9), pci_enumerate_bus(), nor the match
predicate passed to pciide_compat_intr_establish() should ever modify
their pci_attach_args argument, so make their pci_attach_args arguments
const and deal with the fallout throughout the kernel.

For the most part, these changes add a 'const' where there was no
'const' before, however, some drivers and MD code used to modify
pci_attach_args. Now those drivers either copy their pci_attach_args
and modify the copy, or refrain from modifying pci_attach_args:

Xen: according to Manuel Bouyer, writing to pci_attach_args in
pci_intr_map() was a leftover from Xen 2. Probably a bug. I
stopped writing it. I have not tested this change.

siside(4): sis_hostbr_match() needlessly wrote to pci_attach_args.
Probably a bug. I use a temporary variable. I have not tested this
change.

slide(4): sl82c105_chip_map() overwrote the caller's pci_attach_args.
Probably a bug. Use a local pci_attach_args. I have not tested
this change.

viaide(4): via_sata_chip_map() and via_sata_chip_map_new() overwrote the
caller's pci_attach_args. Probably a bug. Make a local copy of the
caller's pci_attach_args and modify the copy. I have not tested
this change.

While I'm here, make pci_mapreg_submap() static.

With these changes in place, I have tested the compilation of these
kernels:

alpha GENERIC
amd64 GENERIC XEN3_DOM0
arc GENERIC
atari HADES MILAN-PCIIDE
bebox GENERIC
cats GENERIC
cobalt GENERIC
evbarm-eb NSLU2
evbarm-el ADI_BRH ARMADILLO9 CP3100 GEMINI GEMINI_MASTER GEMINI_SLAVE GUMSTIX
HDL_G IMX31LITE INTEGRATOR IQ31244 IQ80310 IQ80321 IXDP425 IXM1200
KUROBOX_PRO LUBBOCK MARVELL_NAS NAPPI SHEEVAPLUG SMDK2800 TEAMASA_NPWR
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
OPENBLOCKS266_OPT P2020RDB PMPPC RB800 WALNUT
hp700 GENERIC
i386 ALL XEN3_DOM0 XEN3_DOMU
ibmnws GENERIC
macppc GENERIC
mvmeppc GENERIC
netwinder GENERIC
ofppc GENERIC
prep GENERIC
sandpoint GENERIC
sgimips GENERIC32_IP2x
sparc GENERIC_SUN4U KRUPS
sparc64 GENERIC

As of Sun Apr 3 15:26:26 CDT 2011, I could not compile these kernels
with or without my patches in place:

### evbmips-el GDIUM

nbmake: nbmake: don't know how to make /home/dyoung/pristine-nbsd/src/sys/arch/mips/mips/softintr.c. Stop

### evbarm-el MPCSA_GENERIC
src/sys/arch/evbarm/conf/MPCSA_GENERIC:318: ds1672rtc*: unknown device `ds1672rtc'

### ia64 GENERIC

/tmp/genassym.28085/assym.c: In function 'f111':
/tmp/genassym.28085/assym.c:67: error: invalid application of 'sizeof' to incomplete type 'struct pcb'
/tmp/genassym.28085/assym.c:76: error: dereferencing pointer to incomplete type

### sgimips GENERIC32_IP3x

crmfb.o: In function `crmfb_attach':
crmfb.c:(.text+0x2304): undefined reference to `ddc_read_edid'
crmfb.c:(.text+0x2304): relocation truncated to fit: R_MIPS_26 against `ddc_read_edid'
crmfb.c:(.text+0x234c): undefined reference to `edid_parse'
crmfb.c:(.text+0x234c): relocation truncated to fit: R_MIPS_26 against `edid_parse'
crmfb.c:(.text+0x2354): undefined reference to `edid_print'
crmfb.c:(.text+0x2354): relocation truncated to fit: R_MIPS_26 against `edid_print'
 1.4 16-Mar-2011  matt Fix various nits related to P2020 support.
 1.3 08-Feb-2011  matt branches: 1.3.2;
Add P2020/P2010 truth table definition.
Remove trailing whitespace.
 1.2 18-Jan-2011  matt branches: 1.2.2;
Add support for BookE Freescale MPC85xx (e500 core) processors.
Add fast softint support for PowerPC (though only booke uses it).
Redo FPU/VEC support and add e500 SPE support.
Rework trap/intrs to use a common trapframe format.
Support SOFTFLOAT (no hardfloat or fpu emulation) for BookE.
 1.1 07-Jan-2011  matt branches: 1.1.2; 1.1.4;
file pq3pci.c was initially added on branch matt-nb5-pq3.
 1.1.4.1 06-Jun-2011  jruoho Sync with HEAD.
 1.1.2.2 14-Oct-2011  matt Sync with current pulling P2020 and other newer processor support.
 1.1.2.1 07-Jan-2011  matt Add mpc85xx support for netbsd-5 (with some incompatible kernel changes).
 1.2.2.1 08-Feb-2011  bouyer Sync with HEAD
 1.3.2.5 12-Jun-2011  rmind sync with head
 1.3.2.4 31-May-2011  rmind sync with head
 1.3.2.3 21-Apr-2011  rmind sync with head
 1.3.2.2 05-Mar-2011  rmind sync with head
 1.3.2.1 08-Feb-2011  rmind file pq3pci.c was added on branch rmind-uvmplock on 2011-03-05 20:51:35 +0000
 1.6.2.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.11.6.1 18-Feb-2012  mrg merge to -current.
 1.11.2.3 22-May-2014  yamt sync with head.

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

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.11.2.2 30-Oct-2012  yamt sync with head
 1.11.2.1 17-Apr-2012  yamt sync with head
 1.15.4.1 18-May-2014  rmind sync with head
 1.15.2.2 03-Dec-2017  jdolecek update from HEAD
 1.15.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.16.2.1 10-Aug-2014  tls Rebase.
 1.17.4.4 28-Aug-2017  skrll Sync with HEAD
 1.17.4.3 05-Dec-2016  skrll Sync with HEAD
 1.17.4.2 27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.17.4.1 06-Apr-2015  skrll Sync with HEAD
 1.21.2.1 04-Nov-2016  pgoyette Sync with HEAD
 1.25.2.1 14-Dec-2020  thorpej Sync w/ HEAD.
 1.27.2.1 23-Mar-2021  thorpej Convert config_found_ia() call sites where the device only carries
a single interface attribute to bare config_found() calls.
 1.28.8.1 04-Aug-2021  thorpej Adapt to CFARGS().

RSS XML Feed